MCPcopy Index your code
hub / github.com/hey-api/hey-api / createClient

Function createClient

packages/openapi-python/src/generate.ts:33–125  ·  view source on GitHub ↗
(
  userConfig?: LazyOrAsync<MaybeArray<UserConfig>>,
  logger = new Logger(),
)

Source from the content-addressed store, hash-verified

31 * @param userConfig User provided {@link UserConfig} configuration(s).
32 */
33export async function createClient(
34 userConfig?: LazyOrAsync<MaybeArray<UserConfig>>,
35 logger = new Logger(),
36): Promise<ReadonlyArray<Context>> {
37 const resolvedConfig = typeof userConfig === 'function' ? await userConfig() : userConfig;
38 const userConfigs = resolvedConfig
39 ? resolvedConfig instanceof Array
40 ? resolvedConfig
41 : [resolvedConfig]
42 : [];
43
44 let rawLogs = userConfigs.find((config) => getLogs(config.logs).level !== 'silent')?.logs;
45 if (typeof rawLogs === 'string') {
46 rawLogs = getLogs(rawLogs);
47 }
48
49 let jobs: Configs['jobs'] = [];
50
51 try {
52 checkNodeVersion();
53
54 const eventCreateClient = logger.timeEvent('createClient');
55
56 const eventConfig = logger.timeEvent('config');
57 const resolved = await resolveJobs({ logger, userConfigs });
58 const dependencies = resolved.dependencies;
59 jobs = resolved.jobs;
60 const printIntro = jobs.some((job) => job.config.logs.level !== 'silent');
61 if (printIntro) printCliIntro(__dirname);
62 eventConfig.timeEnd();
63
64 const configErrors = jobs.flatMap((job) =>
65 job.errors.map((error) => ({ error, jobIndex: job.index })),
66 );
67 if (configErrors.length) {
68 throw new ConfigValidationError(configErrors);
69 }
70
71 const outputs = await Promise.all(
72 jobs.map(async (job) => {
73 try {
74 return await pCreateClient({
75 config: job.config,
76 dependencies,
77 jobIndex: job.index,
78 logger,
79 });
80 } catch (error) {
81 if (error instanceof Error) {
82 throw new JobError('', {
83 error,
84 jobIndex: job.index,
85 });
86 }
87 }
88 }),
89 );
90 const contexts = outputs.filter((ctx): ctx is Context => ctx !== undefined);

Callers 3

opencode.test.tsFile · 0.90
opencode.test.tsFile · 0.90
index.tsFile · 0.50

Calls 13

getLogsFunction · 0.90
checkNodeVersionFunction · 0.90
resolveJobsFunction · 0.90
printCliIntroFunction · 0.90
getInputErrorFunction · 0.90
logCrashReportFunction · 0.90
printCrashReportFunction · 0.90
shouldReportCrashFunction · 0.90
findMethod · 0.80
timeEventMethod · 0.80
reportMethod · 0.80

Tested by

no test coverage detected