···11+import type { MaybeArray, MaybeFunc } from '@hey-api/types';
12import colors from 'ansi-colors';
23// @ts-expect-error
34import colorSupport from 'color-support';
4556colors.enabled = colorSupport().hasBasic;
66-77-/**
88- * Accepts a value or a readonly array of values of type T.
99- */
1010-export type MaybeArray<T> = T | ReadonlyArray<T>;
1111-1212-/**
1313- * Accepts a value or a function returning a value.
1414- */
1515-export type MaybeFunc<T extends (...args: Array<any>) => any> =
1616- | T
1717- | ReturnType<T>;
187198const DEBUG_NAMESPACE = 'heyapi';
209
···11+MIT License
22+33+Copyright (c) Hey API
44+55+Permission is hereby granted, free of charge, to any person obtaining a copy
66+of this software and associated documentation files (the "Software"), to deal
77+in the Software without restriction, including without limitation the rights
88+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
99+copies of the Software, and to permit persons to whom the Software is
1010+furnished to do so, subject to the following conditions:
1111+1212+The above copyright notice and this permission notice shall be included in all
1313+copies or substantial portions of the Software.
1414+1515+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1616+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1717+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121+SOFTWARE.
···11+import type { OptionValues } from 'commander';
22+import { Command } from 'commander';
33+44+// import { createClient } from '~/index';
55+import pkg from '../package.json' assert { type: 'json' };
66+77+const stringToBoolean = (
88+ value: string | undefined,
99+): boolean | string | undefined => {
1010+ if (value === 'true') return true;
1111+ if (value === 'false') return false;
1212+ return value;
1313+};
1414+1515+const processParams = (
1616+ obj: OptionValues,
1717+ booleanKeys: ReadonlyArray<string>,
1818+): OptionValues => {
1919+ for (const key of booleanKeys) {
2020+ const value = obj[key];
2121+ if (typeof value === 'string') {
2222+ const parsedValue = stringToBoolean(value);
2323+ delete obj[key];
2424+ obj[key] = parsedValue;
2525+ }
2626+ }
2727+ return obj;
2828+};
2929+3030+export const runCli = async (): Promise<void> => {
3131+ const params = new Command()
3232+ .name(Object.keys(pkg.bin)[0]!)
3333+ .usage('[options]')
3434+ .version(pkg.version)
3535+ .option('-c, --client <value>', 'HTTP client to generate')
3636+ .option('-d, --debug', 'Set log level to debug')
3737+ .option('--dry-run [value]', 'Skip writing files to disk?')
3838+ .option('-f, --file [value]', 'Path to the config file')
3939+ .option(
4040+ '-i, --input <value>',
4141+ 'OpenAPI specification (path, url, or string content)',
4242+ )
4343+ .option('-l, --logs [value]', 'Logs folder')
4444+ .option('-o, --output <value>', 'Output folder')
4545+ .option('-p, --plugins [value...]', "List of plugins you'd like to use")
4646+ .option('-s, --silent', 'Set log level to silent')
4747+ .option(
4848+ '--no-log-file',
4949+ 'Disable writing a log file. Works like --silent but without suppressing console output',
5050+ )
5151+ .option(
5252+ '-w, --watch [value]',
5353+ 'Regenerate the client when the input file changes?',
5454+ )
5555+ .parse(process.argv)
5656+ .opts();
5757+5858+ let userConfig: Record<string, unknown>;
5959+6060+ try {
6161+ userConfig = processParams(params, ['dryRun', 'logFile']);
6262+6363+ if (userConfig.file) {
6464+ userConfig.configFile = userConfig.file;
6565+ delete userConfig.file;
6666+ }
6767+6868+ if (params.plugins === true) {
6969+ userConfig.plugins = [];
7070+ } else if (params.plugins) {
7171+ userConfig.plugins = params.plugins;
7272+ } else if (userConfig.client) {
7373+ userConfig.plugins = ['@hey-api/sdk'];
7474+ }
7575+7676+ if (userConfig.client) {
7777+ (userConfig.plugins as Array<string>).push(userConfig.client as string);
7878+ delete userConfig.client;
7979+ }
8080+8181+ userConfig.logs = userConfig.logs
8282+ ? {
8383+ path: userConfig.logs,
8484+ }
8585+ : {};
8686+8787+ if (userConfig.debug) {
8888+ (userConfig.logs as Record<string, unknown>).level = 'debug';
8989+ delete userConfig.debug;
9090+ } else if (userConfig.silent) {
9191+ (userConfig.logs as Record<string, unknown>).level = 'silent';
9292+ delete userConfig.silent;
9393+ }
9494+9595+ (userConfig.logs as Record<string, unknown>).file = userConfig.logFile;
9696+ delete userConfig.logFile;
9797+9898+ if (typeof params.watch === 'string') {
9999+ userConfig.watch = Number.parseInt(params.watch, 10);
100100+ }
101101+102102+ if (!Object.keys(userConfig.logs as Record<string, unknown>).length) {
103103+ delete userConfig.logs;
104104+ }
105105+106106+ // const context = await createClient(
107107+ // userConfig as unknown as Required<Parameters<typeof createClient>>[0],
108108+ // );
109109+ // if (
110110+ // !context[0]?.config.input.some(
111111+ // (input) => input.watch && input.watch.enabled,
112112+ // )
113113+ // ) {
114114+ // process.exit(0);
115115+ // }
116116+ process.exit(0);
117117+ } catch {
118118+ process.exit(1);
119119+ }
120120+};
+71
packages/openapi-python/src/config/types.d.ts
···11+// import { MaybeArray } from "@hey-api/types";
22+33+export interface UserConfig {
44+ /**
55+ * Path to the config file. Set this value if you don't use the default
66+ * config file name, or it's not located in the project root.
77+ */
88+ configFile?: string;
99+ /**
1010+ * Skip writing files to disk?
1111+ *
1212+ * @default false
1313+ */
1414+ dryRun?: boolean;
1515+ /**
1616+ * Path to the OpenAPI specification. This can be:
1717+ * - path
1818+ * - URL
1919+ * - API registry shorthand
2020+ *
2121+ * Both JSON and YAML file formats are supported. You can also pass the parsed
2222+ * object directly if you're fetching the file yourself.
2323+ *
2424+ * Alternatively, you can define a configuration object with more options.
2525+ *
2626+ * If you define an array, we will generate a single output from multiple
2727+ * inputs. If you define an array of outputs with the same length, we will
2828+ * generate multiple outputs, one for each input.
2929+ */
3030+ // input: MaybeArray<UserInput | Required<UserInput>['path']>;
3131+ /**
3232+ * Show an interactive error reporting tool when the program crashes? You
3333+ * generally want to keep this disabled (default).
3434+ *
3535+ * @default false
3636+ */
3737+ interactive?: boolean;
3838+ /**
3939+ * The relative location of the logs folder.
4040+ *
4141+ * @default process.cwd()
4242+ */
4343+ // logs?: string | Logs;
4444+ /**
4545+ * Path to the output folder.
4646+ *
4747+ * If you define an array of outputs with the same length as inputs, we will
4848+ * generate multiple outputs, one for each input.
4949+ */
5050+ // output: MaybeArray<string | UserOutput>;
5151+ /**
5252+ * Customize how the input is parsed and transformed before it's passed to
5353+ * plugins.
5454+ */
5555+ // parser?: UserParser;
5656+ /**
5757+ * Plugins generate artifacts from `input`. By default, we generate SDK
5858+ * functions and TypeScript interfaces. If you manually define `plugins`,
5959+ * you need to include the default plugins if you wish to use them.
6060+ *
6161+ * @default ['@hey-api/sdk']
6262+ */
6363+ // plugins?: ReadonlyArray<
6464+ // | PluginNames
6565+ // | {
6666+ // [K in PluginNames]: PluginConfigMap[K]['config'] & {
6767+ // name: K;
6868+ // };
6969+ // }[PluginNames]
7070+ // >;
7171+}
+120
packages/openapi-python/src/index.ts
···11+// OVERRIDES
22+// hard-coded here because build process doesn't pick up overrides from separate files
33+import '@hey-api/codegen-core';
44+55+declare module '@hey-api/codegen-core' {
66+ interface ProjectRenderMeta {
77+ /**
88+ * If specified, this will be the file extension used when importing
99+ * other modules. By default, we don't add a file extension and let the
1010+ * runtime resolve it.
1111+ *
1212+ * @default null
1313+ */
1414+ importFileExtension?: (string & {}) | null;
1515+ }
1616+1717+ interface SymbolMeta {
1818+ category?:
1919+ | 'client'
2020+ | 'external'
2121+ | 'hook'
2222+ | 'schema'
2323+ | 'sdk'
2424+ | 'transform'
2525+ | 'type'
2626+ | 'utility'
2727+ | (string & {});
2828+ /**
2929+ * Path to the resource this symbol represents.
3030+ */
3131+ path?: ReadonlyArray<string | number>;
3232+ /**
3333+ * Name of the plugin that registered this symbol.
3434+ */
3535+ pluginName?: string;
3636+ resource?:
3737+ | 'client'
3838+ | 'definition'
3939+ | 'operation'
4040+ | 'webhook'
4141+ | (string & {});
4242+ resourceId?: string;
4343+ role?:
4444+ | 'data'
4545+ | 'error'
4646+ | 'errors'
4747+ | 'options'
4848+ | 'response'
4949+ | 'responses'
5050+ | (string & {});
5151+ /**
5252+ * Tags associated with this symbol.
5353+ */
5454+ tags?: ReadonlyArray<string>;
5555+ tool?:
5656+ | 'angular'
5757+ | 'arktype'
5858+ | 'fastify'
5959+ | 'json-schema'
6060+ | 'sdk'
6161+ | 'typescript'
6262+ | 'valibot'
6363+ | 'zod'
6464+ | (string & {});
6565+ variant?: 'container' | (string & {});
6666+ }
6767+}
6868+// END OVERRIDES
6969+7070+import type { LazyOrAsync, MaybeArray } from '@hey-api/types';
7171+import colors from 'ansi-colors';
7272+// @ts-expect-error
7373+import colorSupport from 'color-support';
7474+7575+import type { UserConfig } from '~/config/types';
7676+7777+colors.enabled = colorSupport().hasBasic;
7878+7979+// export { createClient } from '~/generate';
8080+8181+/**
8282+ * Type helper for openapi-ts.config.ts, returns {@link MaybeArray<UserConfig>} object(s)
8383+ */
8484+export const defineConfig = async <T extends MaybeArray<UserConfig>>(
8585+ config: LazyOrAsync<T>,
8686+): Promise<T> => (typeof config === 'function' ? await config() : config);
8787+8888+// export { defaultPaginationKeywords } from '~/config/parser';
8989+// export { defaultPlugins } from '~/config/plugins';
9090+// export type { IR } from '~/ir/types';
9191+// export { OperationPath, OperationStrategy } from '~/openApi/shared/locations';
9292+// export type {
9393+// OpenApi,
9494+// OpenApiMetaObject,
9595+// OpenApiOperationObject,
9696+// OpenApiParameterObject,
9797+// OpenApiRequestBodyObject,
9898+// OpenApiResponseObject,
9999+// OpenApiSchemaObject,
100100+// } from '~/openApi/types';
101101+// export type { DefinePlugin, Plugin } from '~/plugins';
102102+// export type { AngularClient } from '~/plugins/@hey-api/client-angular';
103103+// export type { AxiosClient } from '~/plugins/@hey-api/client-axios';
104104+// export {
105105+// clientDefaultConfig,
106106+// clientDefaultMeta,
107107+// } from '~/plugins/@hey-api/client-core/config';
108108+// export { clientPluginHandler } from '~/plugins/@hey-api/client-core/plugin';
109109+// export type { Client } from '~/plugins/@hey-api/client-core/types';
110110+// export type { FetchClient } from '~/plugins/@hey-api/client-fetch';
111111+// export type { NextClient } from '~/plugins/@hey-api/client-next';
112112+// export type { NuxtClient } from '~/plugins/@hey-api/client-nuxt';
113113+// export type { OfetchClient } from '~/plugins/@hey-api/client-ofetch';
114114+// export type { ExpressionTransformer } from '~/plugins/@hey-api/transformers/expressions';
115115+// export type { TypeTransformer } from '~/plugins/@hey-api/transformers/types';
116116+// export { definePluginConfig } from '~/plugins/shared/utils/config';
117117+// export * from '~/ts-dsl';
118118+// export type { UserConfig } from '~/types/config';
119119+// export { utils } from '~/utils/exports';
120120+// export { Logger } from '~/utils/logger';
+5
packages/openapi-python/src/run.ts
···11+#!/usr/bin/env node
22+33+import { runCli } from '~/cli';
44+55+runCli();
···11import path from 'node:path';
2233+import type { ArrayOnly } from '@hey-api/types';
34import colors from 'ansi-colors';
4556import { ConfigError } from '~/error';
67import type { Config, UserConfig } from '~/types/config';
77-import type { ArrayOnly } from '~/types/utils';
88import type { Logger } from '~/utils/logger';
991010import { getInput } from './input';
···11-import type { MaybePromise } from '~/types/utils';
11+import type { MaybePromise } from '@hey-api/types';
2233import type { FeatureToggle } from '../../shared';
44
+1-1
packages/openapi-ts/src/config/output/types.d.ts
···22 NameConflictResolver,
33 RenderContext,
44} from '@hey-api/codegen-core';
55+import type { MaybeArray, MaybeFunc } from '@hey-api/types';
56import type ts from 'typescript';
6777-import type { MaybeArray, MaybeFunc } from '~/types/utils';
88import type { Casing, NameTransformer } from '~/utils/naming';
991010import type { NamingOptions } from '../shared';
+2-1
packages/openapi-ts/src/generate.ts
···11+import type { LazyOrAsync, MaybeArray } from '@hey-api/types';
22+13import { checkNodeVersion } from '~/config/engine';
24import type { Configs } from '~/config/init';
35import { initConfigs } from '~/config/init';
···1315} from '~/error';
1416import type { Context } from '~/ir/context';
1517import type { UserConfig } from '~/types/config';
1616-import type { LazyOrAsync, MaybeArray } from '~/types/utils';
1718import { printCliIntro } from '~/utils/cli';
1819import { Logger } from '~/utils/logger';
1920
+1-1
packages/openapi-ts/src/index.ts
···6767}
6868// END OVERRIDES
69697070+import type { LazyOrAsync, MaybeArray } from '@hey-api/types';
7071import colors from 'ansi-colors';
7172// @ts-expect-error
7273import colorSupport from 'color-support';
73747475import type { UserConfig } from '~/types/config';
7575-import type { LazyOrAsync, MaybeArray } from '~/types/utils';
76767777colors.enabled = colorSupport().hasBasic;
7878
+2-1
packages/openapi-ts/src/ir/intents.ts
···11+import type { MaybePromise } from '@hey-api/types';
22+13import type { CodeSampleObject } from '~/openApi/shared/types';
22-import type { MaybePromise } from '~/types/utils';
3445import type { IR } from './types';
56
···11+import type { MaybeArray } from '@hey-api/types';
22+13import type { EnumExtensions } from '~/openApi/shared/types';
2433-import type { MaybeArray } from '../../../types/utils';
45import type { SpecificationExtensions } from './spec';
56import type { OpenApiSchemaExtensions } from './spec-extensions';
67
···11import type { Refs, Symbol } from '@hey-api/codegen-core';
22+import type { MaybeArray } from '@hey-api/types';
23import type ts from 'typescript';
3445import type { IR } from '~/ir/types';
···910} from '~/plugins/shared/utils/coerce';
1011import type { GetIntegerLimit } from '~/plugins/shared/utils/formats';
1112import type { $, DollarTsDsl, TsDsl } from '~/ts-dsl';
1212-import type { MaybeArray } from '~/types/utils';
13131414import type { Chain } from '../shared/chain';
1515import type { Ast, PluginState } from '../shared/types';
-12
packages/openapi-ts/src/ts-dsl/base.ts
···24242525import type { AccessOptions } from './utils/context';
26262727-/**
2828- * Accepts a value or a readonly array of values of type T.
2929- */
3030-export type MaybeArray<T> = T | ReadonlyArray<T>;
3131-3232-/**
3333- * Accepts a value or a function returning a value.
3434- */
3535-export type MaybeFunc<T extends (...args: Array<any>) => any> =
3636- | T
3737- | ReturnType<T>;
3838-3927export abstract class TsDsl<T extends ts.Node = ts.Node> implements Node<T> {
4028 // eslint-disable-next-line @typescript-eslint/no-unused-vars
4129 analyze(_: AnalysisContext): void {}
+1-1
packages/openapi-ts/src/ts-dsl/decl/pattern.ts
···11import type { AnalysisContext } from '@hey-api/codegen-core';
22+import type { MaybeArray } from '@hey-api/types';
23import ts from 'typescript';
3444-import type { MaybeArray } from '../base';
55import { TsDsl } from '../base';
66import { IdTsDsl } from '../expr/id';
77import { TokenTsDsl } from '../token';
+1-1
packages/openapi-ts/src/ts-dsl/layout/doc.ts
···11import type { AnalysisContext } from '@hey-api/codegen-core';
22+import type { MaybeArray } from '@hey-api/types';
23import ts from 'typescript';
3444-import type { MaybeArray } from '../base';
55import { TsDsl } from '../base';
66import { IdTsDsl } from '../expr/id';
77import type { TsDslContext } from '../utils/context';
+1-1
packages/openapi-ts/src/ts-dsl/layout/hint.ts
···11import type { AnalysisContext } from '@hey-api/codegen-core';
22+import type { MaybeArray } from '@hey-api/types';
23import ts from 'typescript';
3444-import type { MaybeArray } from '../base';
55import { TsDsl } from '../base';
66import { IdTsDsl } from '../expr/id';
77import type { TsDslContext } from '../utils/context';
+1-1
packages/openapi-ts/src/ts-dsl/layout/note.ts
···11import type { AnalysisContext } from '@hey-api/codegen-core';
22+import type { MaybeArray } from '@hey-api/types';
23import ts from 'typescript';
3444-import type { MaybeArray } from '../base';
55import { TsDsl } from '../base';
66import { IdTsDsl } from '../expr/id';
77import type { TsDslContext } from '../utils/context';
+1-1
packages/openapi-ts/src/ts-dsl/mixins/pattern.ts
···11import type { AnalysisContext, Node } from '@hey-api/codegen-core';
22+import type { MaybeArray } from '@hey-api/types';
23import type ts from 'typescript';
3444-import type { MaybeArray } from '../base';
55import { PatternTsDsl } from '../decl/pattern';
66import type { BaseCtor, MixinCtor } from './types';
77
+2-1
packages/openapi-ts/src/ts-dsl/utils/context.ts
···11import type { BindingKind, NodeScope, Symbol } from '@hey-api/codegen-core';
22import { isSymbol } from '@hey-api/codegen-core';
33+import type { MaybeFunc } from '@hey-api/types';
34import type ts from 'typescript';
4556import type { DollarTsDsl } from '~/ts-dsl';
67import { $, TypeScriptRenderer } from '~/ts-dsl';
7888-import type { MaybeFunc, TsDsl } from '../base';
99+import type { TsDsl } from '../base';
910import type { CallArgs } from '../expr/call';
10111112export type NodeChain = ReadonlyArray<TsDsl>;
+1-1
packages/openapi-ts/src/ts-dsl/utils/render.ts
···11import type { RenderContext, Renderer } from '@hey-api/codegen-core';
22+import type { MaybeArray, MaybeFunc } from '@hey-api/types';
23import ts from 'typescript';
3445import type { TsDsl } from '~/ts-dsl';
56import { $ } from '~/ts-dsl';
6777-import type { MaybeArray, MaybeFunc } from '../base';
88import type {
99 ModuleExport,
1010 ModuleImport,
+2-1
packages/openapi-ts/src/types/config.d.ts
···11+import type { MaybeArray } from '@hey-api/types';
22+13import type { Output, UserOutput } from '~/config/output';
24import type { Plugin } from '~/plugins';
35import type { PluginConfigMap } from '~/plugins/config';
···68import type { Input, UserInput, Watch } from './input';
79import type { Logs } from './logs';
810import type { Parser, UserParser } from './parser';
99-import type { MaybeArray } from './utils';
10111112export interface UserConfig {
1213 /**