···11// This file is auto-generated by @hey-api/openapi-ts
2233+import type { Options as KyOptions } from 'ky';
44+import type ky from 'ky';
55+36import type { Auth } from '../core/auth.gen';
47import type {
58 ServerSentEventsOptions,
···38413942export interface Config<T extends ClientOptions = ClientOptions>
4043 extends Omit<
4141- import('ky').Options,
4444+ KyOptions,
4245 'body' | 'headers' | 'method' | 'prefixUrl' | 'retry' | 'throwHttpErrors'
4346 >,
4447 CoreConfig {
···5053 * Ky instance to use. You can use this option to provide a custom
5154 * ky instance.
5255 */
5353- ky?: typeof import('ky').default;
5656+ ky?: typeof ky;
5457 /**
5558 * Additional ky-specific options that will be passed directly to ky.
5659 * This allows you to use any ky option not explicitly exposed in the config.
5760 */
5858- kyOptions?: Omit<import('ky').Options, 'method' | 'prefixUrl'>;
6161+ kyOptions?: Omit<KyOptions, 'method' | 'prefixUrl'>;
5962 /**
6063 * Return the response data parsed in a specified format. By default, `auto`
6164 * will infer the appropriate method from the `Content-Type` response header.
···11-import { describe, expect, it, vi } from 'vitest';
22-31import { Project } from '../project/project';
4253// Mock Planner so we control what files appear in project.files
-2
packages/codegen-core/src/__tests__/refs.test.ts
···11-import { describe, expect, it } from 'vitest';
22-31import { fromRef, fromRefs, ref, refs } from '../refs/refs';
42import type { Refs } from '../refs/types';
53
···11-import { describe, expect, it } from 'vitest';
22-31import { SymbolRegistry } from '../symbols/registry';
42import { Symbol } from '../symbols/symbol';
53
···11-import { describe, expect, it, vi } from 'vitest';
22-31import type { Auth } from '../core/auth';
42import { getParseAs, setAuthParams } from '../utils';
53
···11+import type {
22+ BaseOutput,
33+ BaseUserOutput,
44+ UserPostProcessor,
55+} from '@hey-api/shared';
66+import type { AnyString } from '@hey-api/types';
77+88+import type { PostProcessorPreset } from './postprocess';
99+1010+type ImportFileExtensions = '.py';
1111+1212+export type UserOutput = BaseUserOutput & {
1313+ /**
1414+ * If specified, this will be the file extension used when importing
1515+ * other modules. By default, we don't add a file extension and let the
1616+ * runtime resolve it. If you're using moduleResolution `nodenext` or
1717+ * `node16`, we default to `.js`.
1818+ *
1919+ * @default undefined
2020+ */
2121+ importFileExtension?: ImportFileExtensions | AnyString | null;
2222+ /**
2323+ * Post-processing commands to run on the output folder, executed in order.
2424+ *
2525+ * Use preset strings for common tools, or provide custom configurations.
2626+ *
2727+ * @example ['biome:lint', 'prettier']
2828+ * @example [{ command: 'dprint', args: ['fmt', '{{path}}'] }]
2929+ * @example ['eslint', { command: 'prettier', args: ['{{path}}', '--write'] }]
3030+ *
3131+ * @default []
3232+ */
3333+ postProcess?: ReadonlyArray<PostProcessorPreset | UserPostProcessor>;
3434+ /**
3535+ * Whether `export * from 'module'` should be used when possible
3636+ * instead of named exports.
3737+ *
3838+ * @default false
3939+ */
4040+ preferExportAll?: boolean;
4141+};
4242+4343+export type Output = BaseOutput & {
4444+ /**
4545+ * If specified, this will be the file extension used when importing
4646+ * other modules. By default, we don't add a file extension and let the
4747+ * runtime resolve it. If you're using moduleResolution `nodenext` or
4848+ * `node16`, we default to `.js`.
4949+ */
5050+ importFileExtension: ImportFileExtensions | AnyString | null | undefined;
5151+ /**
5252+ * Whether `export * from 'module'` should be used when possible
5353+ * instead of named exports.
5454+ */
5555+ preferExportAll: boolean;
5656+};
···11-import type { 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- input: MaybeArray<string>;
3232- /**
3333- * Show an interactive error reporting tool when the program crashes? You
3434- * generally want to keep this disabled (default).
3535- *
3636- * @default false
3737- */
3838- interactive?: boolean;
3939- /**
4040- * The relative location of the logs folder.
4141- *
4242- * @default process.cwd()
4343- */
4444- // logs?: string | Logs;
4545- logs?:
4646- | string
4747- | {
4848- level?: 'debug' | 'info' | 'warn' | 'error' | 'silent';
4949- };
5050- /**
5151- * Path to the output folder.
5252- *
5353- * If you define an array of outputs with the same length as inputs, we will
5454- * generate multiple outputs, one for each input.
5555- */
5656- // output: MaybeArray<string | UserOutput>;
5757- output: MaybeArray<string>;
5858- /**
5959- * Customize how the input is parsed and transformed before it's passed to
6060- * plugins.
6161- */
6262- // parser?: UserParser;
6363- /**
6464- * Plugins generate artifacts from `input`. By default, we generate SDK
6565- * functions and TypeScript interfaces. If you manually define `plugins`,
6666- * you need to include the default plugins if you wish to use them.
6767- *
6868- * @default ['@hey-api/sdk']
6969- */
7070- // plugins?: ReadonlyArray<
7171- // | PluginNames
7272- // | {
7373- // [K in PluginNames]: PluginConfigMap[K]['config'] & {
7474- // name: K;
7575- // };
7676- // }[PluginNames]
7777- // >;
7878- /**
7979- * @deprecated use `input.watch` instead
8080- */
8181- watch?: boolean | number;
8282-}
+34
packages/openapi-python/src/config/types.ts
···11+import type {
22+ BaseConfig,
33+ BaseUserConfig,
44+ Plugin,
55+ PluginConfigMap,
66+ PluginNames,
77+} from '@hey-api/shared';
88+99+import type { Output, UserOutput } from './output/types';
1010+1111+export type UserConfig = BaseUserConfig<UserOutput> & {
1212+ /**
1313+ * Plugins generate artifacts from `input`. By default, we generate SDK
1414+ * functions and TypeScript interfaces. If you manually define `plugins`,
1515+ * you need to include the default plugins if you wish to use them.
1616+ *
1717+ * @default ['@hey-api/sdk']
1818+ */
1919+ plugins?: ReadonlyArray<
2020+ | PluginNames
2121+ | {
2222+ [K in PluginNames]: PluginConfigMap[K]['config'] & {
2323+ name: K;
2424+ };
2525+ }[PluginNames]
2626+ >;
2727+};
2828+2929+export type Config = BaseConfig<UserConfig, Output> & {
3030+ pluginOrder: ReadonlyArray<keyof PluginConfigMap>;
3131+ plugins: {
3232+ [K in PluginNames]?: Plugin.Config<PluginConfigMap[K]>;
3333+ };
3434+};
+38
packages/openapi-python/src/config/validate.ts
···11+import { ConfigError, getInput } from '@hey-api/shared';
22+33+import type { Job } from './expand';
44+import { getOutput } from './output/config';
55+66+export type ValidationResult = {
77+ errors: Array<ConfigError>;
88+ job: Job;
99+};
1010+1111+export function validateJobs(
1212+ jobs: ReadonlyArray<Job>,
1313+): ReadonlyArray<ValidationResult> {
1414+ return jobs.map((job) => {
1515+ const errors: Array<ConfigError> = [];
1616+ const { config } = job;
1717+1818+ const inputs = getInput(config);
1919+ if (!inputs.length) {
2020+ errors.push(
2121+ new ConfigError(
2222+ 'missing input - which OpenAPI specification should we use to generate your output?',
2323+ ),
2424+ );
2525+ }
2626+2727+ const output = getOutput(config);
2828+ if (!output.path) {
2929+ errors.push(
3030+ new ConfigError(
3131+ 'missing output - where should we generate your output?',
3232+ ),
3333+ );
3434+ }
3535+3636+ return { errors, job };
3737+ });
3838+}
+193
packages/openapi-python/src/createClient.ts
···11+import path from 'node:path';
22+33+import { type Logger, Project } from '@hey-api/codegen-core';
44+import { $RefParser } from '@hey-api/json-schema-ref-parser';
55+import {
66+ applyNaming,
77+ buildGraph,
88+ compileInputPath,
99+ Context,
1010+ getSpec,
1111+ type Input,
1212+ logInputPaths,
1313+ type OpenApi,
1414+ parseOpenApiSpec,
1515+ patchOpenApiSpec,
1616+ postprocessOutput,
1717+ type WatchValues,
1818+} from '@hey-api/shared';
1919+import colors from 'ansi-colors';
2020+2121+import { postProcessors } from '~/config/output/postprocess';
2222+import type { Config } from '~/config/types';
2323+// import { generateOutput } from '~/generate/output';
2424+// import { TypeScriptRenderer } from '~/ts-dsl';
2525+2626+export async function createClient({
2727+ config,
2828+ dependencies,
2929+ jobIndex,
3030+ logger,
3131+ watches: _watches,
3232+}: {
3333+ config: Config;
3434+ dependencies: Record<string, string>;
3535+ jobIndex: number;
3636+ logger: Logger;
3737+ /**
3838+ * Always undefined on the first run, defined on subsequent runs.
3939+ */
4040+ watches?: ReadonlyArray<WatchValues>;
4141+}): Promise<Context | undefined> {
4242+ const watches: ReadonlyArray<WatchValues> =
4343+ _watches ||
4444+ Array.from({ length: config.input.length }, () => ({
4545+ headers: new Headers(),
4646+ }));
4747+4848+ const inputPaths = config.input.map((input) => compileInputPath(input));
4949+5050+ // on first run, print the message as soon as possible
5151+ if (config.logs.level !== 'silent' && !_watches) {
5252+ logInputPaths(inputPaths, jobIndex);
5353+ }
5454+5555+ const getSpecData = async (input: Input, index: number) => {
5656+ const eventSpec = logger.timeEvent('spec');
5757+ const { arrayBuffer, error, resolvedInput, response } = await getSpec({
5858+ fetchOptions: input.fetch,
5959+ inputPath: inputPaths[index]!.path,
6060+ timeout: input.watch.timeout,
6161+ watch: watches[index]!,
6262+ });
6363+ eventSpec.timeEnd();
6464+6565+ // throw on first run if there's an error to preserve user experience
6666+ // if in watch mode, subsequent errors won't throw to gracefully handle
6767+ // cases where server might be reloading
6868+ if (error && !_watches) {
6969+ throw new Error(
7070+ `Request failed with status ${response.status}: ${response.statusText}`,
7171+ );
7272+ }
7373+7474+ return { arrayBuffer, resolvedInput };
7575+ };
7676+ const specData = (
7777+ await Promise.all(
7878+ config.input.map((input, index) => getSpecData(input, index)),
7979+ )
8080+ ).filter((data) => data.arrayBuffer || data.resolvedInput);
8181+8282+ let context: Context | undefined;
8383+8484+ if (specData.length) {
8585+ const refParser = new $RefParser();
8686+ const data =
8787+ specData.length > 1
8888+ ? await refParser.bundleMany({
8989+ arrayBuffer: specData.map((data) => data.arrayBuffer!),
9090+ pathOrUrlOrSchemas: [],
9191+ resolvedInputs: specData.map((data) => data.resolvedInput!),
9292+ })
9393+ : await refParser.bundle({
9494+ arrayBuffer: specData[0]!.arrayBuffer,
9595+ pathOrUrlOrSchema: undefined,
9696+ resolvedInput: specData[0]!.resolvedInput,
9797+ });
9898+9999+ // on subsequent runs in watch mode, print the message only if we know we're
100100+ // generating the output
101101+ if (config.logs.level !== 'silent' && _watches) {
102102+ console.clear();
103103+ logInputPaths(inputPaths, jobIndex);
104104+ }
105105+106106+ const eventInputPatch = logger.timeEvent('input.patch');
107107+ patchOpenApiSpec({ patchOptions: config.parser.patch, spec: data });
108108+ eventInputPatch.timeEnd();
109109+110110+ const eventParser = logger.timeEvent('parser');
111111+ // TODO: allow overriding via config
112112+ const project = new Project({
113113+ defaultFileName: 'index',
114114+ fileName: (base) => {
115115+ const name = applyNaming(base, config.output.fileName);
116116+ const { suffix } = config.output.fileName;
117117+ if (!suffix) {
118118+ return name;
119119+ }
120120+ return name === 'index' || name.endsWith(suffix)
121121+ ? name
122122+ : `${name}${suffix}`;
123123+ },
124124+ nameConflictResolvers: config.output.nameConflictResolver
125125+ ? {
126126+ typescript: config.output.nameConflictResolver,
127127+ }
128128+ : undefined,
129129+ renderers: [
130130+ // TODO: attach renderer
131131+ // new TypeScriptRenderer({
132132+ // header: config.output.header,
133133+ // preferExportAll: config.output.preferExportAll,
134134+ // preferFileExtension: config.output.importFileExtension || undefined,
135135+ // resolveModuleName: config.output.resolveModuleName,
136136+ // }),
137137+ ],
138138+ root: config.output.path,
139139+ });
140140+ context = new Context<
141141+ OpenApi.V2_0_X | OpenApi.V3_0_X | OpenApi.V3_1_X,
142142+ Config
143143+ >({
144144+ config,
145145+ dependencies,
146146+ logger,
147147+ project,
148148+ spec: data as OpenApi.V2_0_X | OpenApi.V3_0_X | OpenApi.V3_1_X,
149149+ });
150150+ parseOpenApiSpec(context);
151151+ context.graph = buildGraph(context.ir, logger).graph;
152152+ eventParser.timeEnd();
153153+154154+ const eventGenerator = logger.timeEvent('generator');
155155+ // await generateOutput({ context });
156156+ eventGenerator.timeEnd();
157157+158158+ const eventPostprocess = logger.timeEvent('postprocess');
159159+ if (!config.dryRun) {
160160+ const jobPrefix = colors.gray(`[Job ${jobIndex + 1}] `);
161161+ postprocessOutput(config.output, postProcessors, jobPrefix);
162162+163163+ if (config.logs.level !== 'silent') {
164164+ const outputPath = process.env.INIT_CWD
165165+ ? `./${path.relative(process.env.INIT_CWD, config.output.path)}`
166166+ : config.output.path;
167167+ console.log(
168168+ `${jobPrefix}${colors.green('✅ Done!')} Your output is in ${colors.cyanBright(outputPath)}`,
169169+ );
170170+ }
171171+ }
172172+ eventPostprocess.timeEnd();
173173+ }
174174+175175+ const watchedInput = config.input.find(
176176+ (input, index) =>
177177+ input.watch.enabled && typeof inputPaths[index]!.path === 'string',
178178+ );
179179+180180+ if (watchedInput) {
181181+ setTimeout(() => {
182182+ createClient({
183183+ config,
184184+ dependencies,
185185+ jobIndex,
186186+ logger,
187187+ watches,
188188+ });
189189+ }, watchedInput.watch.interval);
190190+ }
191191+192192+ return context;
193193+}
···11+import type { IndexExportOption, NameTransformer } from '@hey-api/shared';
22+import type { DefinePlugin, Plugin } from '@hey-api/shared';
33+44+// import type { OperationsStrategy } from '@hey-api/shared';
55+import type { PluginClientNames, PluginValidatorNames } from '~/plugins/types';
66+77+// import type { ExamplesConfig, UserExamplesConfig } from './examples';
88+// import type { OperationsConfig, UserOperationsConfig } from './operations';
99+1010+export type UserConfig = Plugin.Name<'@hey-api/sdk'> &
1111+ Plugin.Hooks & {
1212+ /**
1313+ * Should the generated functions contain auth mechanisms? You may want to
1414+ * disable this option if you're handling auth yourself or defining it
1515+ * globally on the client and want to reduce the size of generated code.
1616+ *
1717+ * @default true
1818+ */
1919+ auth?: boolean;
2020+ /**
2121+ * Use an internal client instance to send HTTP requests? This is useful if
2222+ * you don't want to manually pass the client to each SDK function.
2323+ *
2424+ * You can customize the selected client output through its plugin. You can
2525+ * also set `client` to `true` to automatically choose the client from your
2626+ * defined plugins. If we can't detect a client plugin when using `true`, we
2727+ * will default to `@hey-api/client-fetch`.
2828+ *
2929+ * @default true
3030+ */
3131+ client?: PluginClientNames | boolean;
3232+ /**
3333+ * Generate code examples for SDK operations and attach them to the
3434+ * input source (e.g. via `x-codeSamples`).
3535+ *
3636+ * Set to `false` to disable example generation entirely, or provide an
3737+ * object for fine-grained control over the output and post-processing.
3838+ *
3939+ * @default false
4040+ */
4141+ // examples?: boolean | UserExamplesConfig;
4242+ /**
4343+ * Whether exports should be re-exported in the index file.
4444+ *
4545+ * @default true
4646+ */
4747+ exportFromIndex?: boolean;
4848+ /**
4949+ * Define the structure of generated SDK operations.
5050+ *
5151+ * String shorthand:
5252+ * - `'byTags'` – one container per operation tag
5353+ * - `'flat'` – standalone functions, no container
5454+ * - `'single'` – all operations in a single container
5555+ * - custom function for full control
5656+ *
5757+ * Use the object form for advanced configuration.
5858+ *
5959+ * @default 'flat'
6060+ */
6161+ // operations?: OperationsStrategy | UserOperationsConfig;
6262+ /**
6363+ * Define how request parameters are structured in generated SDK methods.
6464+ *
6565+ * - `'flat'` merges parameters into a single object.
6666+ * - `'grouped'` separates parameters by transport layer.
6767+ *
6868+ * Use `'flat'` for simpler calls or `'grouped'` for stricter typing and code clarity.
6969+ *
7070+ * @default 'grouped'
7171+ */
7272+ paramsStructure?: 'flat' | 'grouped';
7373+ /**
7474+ * **This feature works only with the Fetch client**
7575+ *
7676+ * Should we return only data or multiple fields (data, error, response, etc.)?
7777+ *
7878+ * @default 'fields'
7979+ */
8080+ responseStyle?: 'data' | 'fields';
8181+ /**
8282+ * Transform response data before returning. This is useful if you want to
8383+ * convert for example ISO strings into Date objects. However, transformation
8484+ * adds runtime overhead, so it's not recommended to use unless necessary.
8585+ *
8686+ * You can customize the selected transformer output through its plugin. You
8787+ * can also set `transformer` to `true` to automatically choose the
8888+ * transformer from your defined plugins.
8989+ *
9090+ * @default false
9191+ */
9292+ transformer?: '@hey-api/transformers' | boolean;
9393+ /**
9494+ * Validate request and/or response data against schema before returning.
9595+ * This is useful if you want to ensure the request and/or response conforms
9696+ * to a desired shape. However, validation adds runtime overhead, so it's
9797+ * not recommended to use unless absolutely necessary.
9898+ *
9999+ * You can customize the validator output through its plugin. You can also
100100+ * set `validator` to `true` to automatically choose the validator from your
101101+ * defined plugins.
102102+ *
103103+ * You can enable/disable validation for requests and responses separately
104104+ * by setting `validator` to an object `{ request, response }`.
105105+ *
106106+ * Ensure you have declared the selected library as a dependency to avoid
107107+ * errors.
108108+ *
109109+ * @default false
110110+ */
111111+ validator?:
112112+ | PluginValidatorNames
113113+ | boolean
114114+ | {
115115+ /**
116116+ * Validate request data against schema before sending.
117117+ *
118118+ * Can be a validator plugin name or boolean (true to auto-select, false
119119+ * to disable).
120120+ *
121121+ * @default false
122122+ */
123123+ request?: PluginValidatorNames | boolean;
124124+ /**
125125+ * Validate response data against schema before returning.
126126+ *
127127+ * Can be a validator plugin name or boolean (true to auto-select, false
128128+ * to disable).
129129+ *
130130+ * @default false
131131+ */
132132+ response?: PluginValidatorNames | boolean;
133133+ };
134134+135135+ // DEPRECATED OPTIONS BELOW
136136+137137+ /**
138138+ * Group operation methods into classes? When enabled, you can select which
139139+ * classes to export with `sdk.include` and/or transform their names with
140140+ * `sdk.classNameBuilder`.
141141+ *
142142+ * Note that by enabling this option, your SDKs will **NOT**
143143+ * support {@link https://developer.mozilla.org/docs/Glossary/Tree_shaking tree-shaking}.
144144+ * For this reason, it is disabled by default.
145145+ *
146146+ * @deprecated Use `operations: { strategy: "byTags" }` or `operations: { strategy: "single" }` instead.
147147+ * @default false
148148+ */
149149+ // eslint-disable-next-line typescript-sort-keys/interface
150150+ asClass?: boolean;
151151+ /**
152152+ * Customize the generated class names. The name variable is obtained from
153153+ * your OpenAPI specification tags or `instance` value.
154154+ *
155155+ * This option has no effect if `sdk.asClass` is `false`.
156156+ *
157157+ * @deprecated Use `operations: { containerName: "..." }` instead.
158158+ */
159159+ classNameBuilder?: NameTransformer;
160160+ /**
161161+ * How should we structure your SDK? By default, we try to infer the ideal
162162+ * structure using `operationId` keywords. If you prefer a flatter structure,
163163+ * you can set `classStructure` to `off` to disable this behavior.
164164+ *
165165+ * @deprecated Use `operations: { nesting: "operationId" }` or `operations: { nesting: "id" }` instead.
166166+ * @default 'auto'
167167+ */
168168+ classStructure?: 'auto' | 'off';
169169+ /**
170170+ * Set `instance` to create an instantiable SDK. Using `true` will use the
171171+ * default instance name; in practice, you want to define your own by passing
172172+ * a string value.
173173+ *
174174+ * @deprecated Use `operations: { strategy: "single", containerName: "Name", methods: "instance" }` instead.
175175+ * @default false
176176+ */
177177+ instance?: string | boolean;
178178+ /**
179179+ * Customise the name of methods within the service. By default,
180180+ * `operation.id` is used.
181181+ *
182182+ * @deprecated Use `operations: { methodName: "..." }` instead.
183183+ */
184184+ methodNameBuilder?: NameTransformer;
185185+ /**
186186+ * Use operation ID to generate operation names?
187187+ *
188188+ * @deprecated Use `operations: { nesting: "operationId" }` or `operations: { nesting: "id" }` instead.
189189+ * @default true
190190+ */
191191+ operationId?: boolean;
192192+ /**
193193+ * Define shape of returned value from service calls
194194+ *
195195+ * @deprecated
196196+ * @default 'body'
197197+ */
198198+ response?: 'body' | 'response';
199199+ };
200200+201201+export type Config = Plugin.Name<'@hey-api/sdk'> &
202202+ Plugin.Hooks &
203203+ IndexExportOption & {
204204+ /**
205205+ * Should the generated functions contain auth mechanisms? You may want to
206206+ * disable this option if you're handling auth yourself or defining it
207207+ * globally on the client and want to reduce the size of generated code.
208208+ *
209209+ * @default true
210210+ */
211211+ auth: boolean;
212212+ /**
213213+ * Use an internal client instance to send HTTP requests? This is useful if
214214+ * you don't want to manually pass the client to each SDK function.
215215+ *
216216+ * You can customize the selected client output through its plugin. You can
217217+ * also set `client` to `true` to automatically choose the client from your
218218+ * defined plugins. If we can't detect a client plugin when using `true`, we
219219+ * will default to `@hey-api/client-fetch`.
220220+ *
221221+ * @default true
222222+ */
223223+ client: PluginClientNames | false;
224224+ /**
225225+ * Configuration for generating SDK code examples.
226226+ */
227227+ // examples: ExamplesConfig;
228228+ /**
229229+ * Define the structure of generated SDK operations.
230230+ */
231231+ // operations: OperationsConfig;
232232+ /**
233233+ * Define how request parameters are structured in generated SDK methods.
234234+ *
235235+ * - `'flat'` merges parameters into a single object.
236236+ * - `'grouped'` separates parameters by transport layer.
237237+ *
238238+ * Use `'flat'` for simpler calls or `'grouped'` for stricter typing and code clarity.
239239+ *
240240+ * @default 'grouped'
241241+ */
242242+ paramsStructure: 'flat' | 'grouped';
243243+ /**
244244+ * **This feature works only with the Fetch client**
245245+ *
246246+ * Should we return only data or multiple fields (data, error, response, etc.)?
247247+ *
248248+ * @default 'fields'
249249+ */
250250+ responseStyle: 'data' | 'fields';
251251+ /**
252252+ * Transform response data before returning. This is useful if you want to
253253+ * convert for example ISO strings into Date objects. However, transformation
254254+ * adds runtime overhead, so it's not recommended to use unless necessary.
255255+ *
256256+ * You can customize the selected transformer output through its plugin. You
257257+ * can also set `transformer` to `true` to automatically choose the
258258+ * transformer from your defined plugins.
259259+ *
260260+ * @default false
261261+ */
262262+ transformer: '@hey-api/transformers' | false;
263263+ /**
264264+ * Validate request and/or response data against schema before returning.
265265+ * This is useful if you want to ensure the request and/or response conforms
266266+ * to a desired shape. However, validation adds runtime overhead, so it's
267267+ * not recommended to use unless absolutely necessary.
268268+ */
269269+ validator: {
270270+ /**
271271+ * The validator plugin to use for request validation, or false to disable.
272272+ *
273273+ * @default false
274274+ */
275275+ request: PluginValidatorNames | false;
276276+ /**
277277+ * The validator plugin to use for response validation, or false to disable.
278278+ *
279279+ * @default false
280280+ */
281281+ response: PluginValidatorNames | false;
282282+ };
283283+284284+ // DEPRECATED OPTIONS BELOW
285285+286286+ /**
287287+ * Define shape of returned value from service calls
288288+ *
289289+ * @deprecated
290290+ * @default 'body'
291291+ */
292292+ // eslint-disable-next-line typescript-sort-keys/interface
293293+ response: 'body' | 'response';
294294+ };
295295+296296+export type HeyApiSdkPlugin = DefinePlugin<UserConfig, Config>;
···33import { fileURLToPath } from 'node:url';
4455import { createClient, type UserConfig } from '@hey-api/openapi-ts';
66-import { describe, expect, it } from 'vitest';
7687import { getFilePaths, getSpecsPath } from '../../utils';
98
-1
packages/openapi-ts-tests/main/test/3.0.x.test.ts
···33import { fileURLToPath } from 'node:url';
4455import { createClient, type UserConfig } from '@hey-api/openapi-ts';
66-import { describe, expect, it } from 'vitest';
7687import { getFilePaths, getSpecsPath } from '../../utils';
98
-1
packages/openapi-ts-tests/main/test/3.1.x.test.ts
···33import { fileURLToPath } from 'node:url';
4455import { createClient, type UserConfig } from '@hey-api/openapi-ts';
66-import { describe, expect, it } from 'vitest';
7687import { getFilePaths, getSpecsPath } from '../../utils';
98
···11// This file is auto-generated by @hey-api/openapi-ts
2233+import type { Options as KyOptions } from 'ky';
44+import type ky from 'ky';
55+36import type { Auth } from '../core/auth.gen';
47import type {
58 ServerSentEventsOptions,
···38413942export interface Config<T extends ClientOptions = ClientOptions>
4043 extends Omit<
4141- import('ky').Options,
4444+ KyOptions,
4245 'body' | 'headers' | 'method' | 'prefixUrl' | 'retry' | 'throwHttpErrors'
4346 >,
4447 CoreConfig {
···5053 * Ky instance to use. You can use this option to provide a custom
5154 * ky instance.
5255 */
5353- ky?: typeof import('ky').default;
5656+ ky?: typeof ky;
5457 /**
5558 * Additional ky-specific options that will be passed directly to ky.
5659 * This allows you to use any ky option not explicitly exposed in the config.
5760 */
5858- kyOptions?: Omit<import('ky').Options, 'method' | 'prefixUrl'>;
6161+ kyOptions?: Omit<KyOptions, 'method' | 'prefixUrl'>;
5962 /**
6063 * Return the response data parsed in a specified format. By default, `auto`
6164 * will infer the appropriate method from the `Content-Type` response header.
···11// This file is auto-generated by @hey-api/openapi-ts
2233+import type { Options as KyOptions } from 'ky';
44+import type ky from 'ky';
55+36import type { Auth } from '../core/auth.gen';
47import type {
58 ServerSentEventsOptions,
···38413942export interface Config<T extends ClientOptions = ClientOptions>
4043 extends Omit<
4141- import('ky').Options,
4444+ KyOptions,
4245 'body' | 'headers' | 'method' | 'prefixUrl' | 'retry' | 'throwHttpErrors'
4346 >,
4447 CoreConfig {
···5053 * Ky instance to use. You can use this option to provide a custom
5154 * ky instance.
5255 */
5353- ky?: typeof import('ky').default;
5656+ ky?: typeof ky;
5457 /**
5558 * Additional ky-specific options that will be passed directly to ky.
5659 * This allows you to use any ky option not explicitly exposed in the config.
5760 */
5858- kyOptions?: Omit<import('ky').Options, 'method' | 'prefixUrl'>;
6161+ kyOptions?: Omit<KyOptions, 'method' | 'prefixUrl'>;
5962 /**
6063 * Return the response data parsed in a specified format. By default, `auto`
6164 * will infer the appropriate method from the `Content-Type` response header.
···11// This file is auto-generated by @hey-api/openapi-ts
2233+import type { Options as KyOptions } from 'ky';
44+import type ky from 'ky';
55+36import type { Auth } from '../core/auth.gen';
47import type {
58 ServerSentEventsOptions,
···38413942export interface Config<T extends ClientOptions = ClientOptions>
4043 extends Omit<
4141- import('ky').Options,
4444+ KyOptions,
4245 'body' | 'headers' | 'method' | 'prefixUrl' | 'retry' | 'throwHttpErrors'
4346 >,
4447 CoreConfig {
···5053 * Ky instance to use. You can use this option to provide a custom
5154 * ky instance.
5255 */
5353- ky?: typeof import('ky').default;
5656+ ky?: typeof ky;
5457 /**
5558 * Additional ky-specific options that will be passed directly to ky.
5659 * This allows you to use any ky option not explicitly exposed in the config.
5760 */
5858- kyOptions?: Omit<import('ky').Options, 'method' | 'prefixUrl'>;
6161+ kyOptions?: Omit<KyOptions, 'method' | 'prefixUrl'>;
5962 /**
6063 * Return the response data parsed in a specified format. By default, `auto`
6164 * will infer the appropriate method from the `Content-Type` response header.
···11// This file is auto-generated by @hey-api/openapi-ts
2233+import type { Options as KyOptions } from 'ky';
44+import type ky from 'ky';
55+36import type { Auth } from '../core/auth.gen';
47import type {
58 ServerSentEventsOptions,
···38413942export interface Config<T extends ClientOptions = ClientOptions>
4043 extends Omit<
4141- import('ky').Options,
4444+ KyOptions,
4245 'body' | 'headers' | 'method' | 'prefixUrl' | 'retry' | 'throwHttpErrors'
4346 >,
4447 CoreConfig {
···5053 * Ky instance to use. You can use this option to provide a custom
5154 * ky instance.
5255 */
5353- ky?: typeof import('ky').default;
5656+ ky?: typeof ky;
5457 /**
5558 * Additional ky-specific options that will be passed directly to ky.
5659 * This allows you to use any ky option not explicitly exposed in the config.
5760 */
5858- kyOptions?: Omit<import('ky').Options, 'method' | 'prefixUrl'>;
6161+ kyOptions?: Omit<KyOptions, 'method' | 'prefixUrl'>;
5962 /**
6063 * Return the response data parsed in a specified format. By default, `auto`
6164 * will infer the appropriate method from the `Content-Type` response header.
···11// This file is auto-generated by @hey-api/openapi-ts
2233+import type { Options as KyOptions } from 'ky';
44+import type ky from 'ky';
55+36import type { Auth } from '../core/auth.gen';
47import type {
58 ServerSentEventsOptions,
···38413942export interface Config<T extends ClientOptions = ClientOptions>
4043 extends Omit<
4141- import('ky').Options,
4444+ KyOptions,
4245 'body' | 'headers' | 'method' | 'prefixUrl' | 'retry' | 'throwHttpErrors'
4346 >,
4447 CoreConfig {
···5053 * Ky instance to use. You can use this option to provide a custom
5154 * ky instance.
5255 */
5353- ky?: typeof import('ky').default;
5656+ ky?: typeof ky;
5457 /**
5558 * Additional ky-specific options that will be passed directly to ky.
5659 * This allows you to use any ky option not explicitly exposed in the config.
5760 */
5858- kyOptions?: Omit<import('ky').Options, 'method' | 'prefixUrl'>;
6161+ kyOptions?: Omit<KyOptions, 'method' | 'prefixUrl'>;
5962 /**
6063 * Return the response data parsed in a specified format. By default, `auto`
6164 * will infer the appropriate method from the `Content-Type` response header.
···11// This file is auto-generated by @hey-api/openapi-ts
2233+import type { Options as KyOptions } from 'ky';
44+import type ky from 'ky';
55+36import type { Auth } from '../core/auth.gen';
47import type {
58 ServerSentEventsOptions,
···38413942export interface Config<T extends ClientOptions = ClientOptions>
4043 extends Omit<
4141- import('ky').Options,
4444+ KyOptions,
4245 'body' | 'headers' | 'method' | 'prefixUrl' | 'retry' | 'throwHttpErrors'
4346 >,
4447 CoreConfig {
···5053 * Ky instance to use. You can use this option to provide a custom
5154 * ky instance.
5255 */
5353- ky?: typeof import('ky').default;
5656+ ky?: typeof ky;
5457 /**
5558 * Additional ky-specific options that will be passed directly to ky.
5659 * This allows you to use any ky option not explicitly exposed in the config.
5760 */
5858- kyOptions?: Omit<import('ky').Options, 'method' | 'prefixUrl'>;
6161+ kyOptions?: Omit<KyOptions, 'method' | 'prefixUrl'>;
5962 /**
6063 * Return the response data parsed in a specified format. By default, `auto`
6164 * will infer the appropriate method from the `Content-Type` response header.
···11// This file is auto-generated by @hey-api/openapi-ts
2233+import type { Options as KyOptions } from 'ky';
44+import type ky from 'ky';
55+36import type { Auth } from '../core/auth.gen.ts';
47import type {
58 ServerSentEventsOptions,
···38413942export interface Config<T extends ClientOptions = ClientOptions>
4043 extends Omit<
4141- import('ky').Options,
4444+ KyOptions,
4245 'body' | 'headers' | 'method' | 'prefixUrl' | 'retry' | 'throwHttpErrors'
4346 >,
4447 CoreConfig {
···5053 * Ky instance to use. You can use this option to provide a custom
5154 * ky instance.
5255 */
5353- ky?: typeof import('ky').default;
5656+ ky?: typeof ky;
5457 /**
5558 * Additional ky-specific options that will be passed directly to ky.
5659 * This allows you to use any ky option not explicitly exposed in the config.
5760 */
5858- kyOptions?: Omit<import('ky').Options, 'method' | 'prefixUrl'>;
6161+ kyOptions?: Omit<KyOptions, 'method' | 'prefixUrl'>;
5962 /**
6063 * Return the response data parsed in a specified format. By default, `auto`
6164 * will infer the appropriate method from the `Content-Type` response header.
···11// This file is auto-generated by @hey-api/openapi-ts
2233+import type { Options as KyOptions } from 'ky';
44+import type ky from 'ky';
55+36import type { Auth } from '../core/auth.gen';
47import type {
58 ServerSentEventsOptions,
···38413942export interface Config<T extends ClientOptions = ClientOptions>
4043 extends Omit<
4141- import('ky').Options,
4444+ KyOptions,
4245 'body' | 'headers' | 'method' | 'prefixUrl' | 'retry' | 'throwHttpErrors'
4346 >,
4447 CoreConfig {
···5053 * Ky instance to use. You can use this option to provide a custom
5154 * ky instance.
5255 */
5353- ky?: typeof import('ky').default;
5656+ ky?: typeof ky;
5457 /**
5558 * Additional ky-specific options that will be passed directly to ky.
5659 * This allows you to use any ky option not explicitly exposed in the config.
5760 */
5858- kyOptions?: Omit<import('ky').Options, 'method' | 'prefixUrl'>;
6161+ kyOptions?: Omit<KyOptions, 'method' | 'prefixUrl'>;
5962 /**
6063 * Return the response data parsed in a specified format. By default, `auto`
6164 * will infer the appropriate method from the `Content-Type` response header.
···11// This file is auto-generated by @hey-api/openapi-ts
2233+import type { Options as KyOptions } from 'ky';
44+import type ky from 'ky';
55+36import type { Auth } from '../core/auth.gen';
47import type {
58 ServerSentEventsOptions,
···38413942export interface Config<T extends ClientOptions = ClientOptions>
4043 extends Omit<
4141- import('ky').Options,
4444+ KyOptions,
4245 'body' | 'headers' | 'method' | 'prefixUrl' | 'retry' | 'throwHttpErrors'
4346 >,
4447 CoreConfig {
···5053 * Ky instance to use. You can use this option to provide a custom
5154 * ky instance.
5255 */
5353- ky?: typeof import('ky').default;
5656+ ky?: typeof ky;
5457 /**
5558 * Additional ky-specific options that will be passed directly to ky.
5659 * This allows you to use any ky option not explicitly exposed in the config.
5760 */
5858- kyOptions?: Omit<import('ky').Options, 'method' | 'prefixUrl'>;
6161+ kyOptions?: Omit<KyOptions, 'method' | 'prefixUrl'>;
5962 /**
6063 * Return the response data parsed in a specified format. By default, `auto`
6164 * will infer the appropriate method from the `Content-Type` response header.
···11// This file is auto-generated by @hey-api/openapi-ts
2233+import type { Options as KyOptions } from 'ky';
44+import type ky from 'ky';
55+36import type { Auth } from '../core/auth.gen.js';
47import type {
58 ServerSentEventsOptions,
···38413942export interface Config<T extends ClientOptions = ClientOptions>
4043 extends Omit<
4141- import('ky').Options,
4444+ KyOptions,
4245 'body' | 'headers' | 'method' | 'prefixUrl' | 'retry' | 'throwHttpErrors'
4346 >,
4447 CoreConfig {
···5053 * Ky instance to use. You can use this option to provide a custom
5154 * ky instance.
5255 */
5353- ky?: typeof import('ky').default;
5656+ ky?: typeof ky;
5457 /**
5558 * Additional ky-specific options that will be passed directly to ky.
5659 * This allows you to use any ky option not explicitly exposed in the config.
5760 */
5858- kyOptions?: Omit<import('ky').Options, 'method' | 'prefixUrl'>;
6161+ kyOptions?: Omit<KyOptions, 'method' | 'prefixUrl'>;
5962 /**
6063 * Return the response data parsed in a specified format. By default, `auto`
6164 * will infer the appropriate method from the `Content-Type` response header.
···11// This file is auto-generated by @hey-api/openapi-ts
2233+import type { Options as KyOptions } from 'ky';
44+import type ky from 'ky';
55+36import type { Auth } from '../core/auth.gen.js';
47import type {
58 ServerSentEventsOptions,
···38413942export interface Config<T extends ClientOptions = ClientOptions>
4043 extends Omit<
4141- import('ky').Options,
4444+ KyOptions,
4245 'body' | 'headers' | 'method' | 'prefixUrl' | 'retry' | 'throwHttpErrors'
4346 >,
4447 CoreConfig {
···5053 * Ky instance to use. You can use this option to provide a custom
5154 * ky instance.
5255 */
5353- ky?: typeof import('ky').default;
5656+ ky?: typeof ky;
5457 /**
5558 * Additional ky-specific options that will be passed directly to ky.
5659 * This allows you to use any ky option not explicitly exposed in the config.
5760 */
5858- kyOptions?: Omit<import('ky').Options, 'method' | 'prefixUrl'>;
6161+ kyOptions?: Omit<KyOptions, 'method' | 'prefixUrl'>;
5962 /**
6063 * Return the response data parsed in a specified format. By default, `auto`
6164 * will infer the appropriate method from the `Content-Type` response header.
···11import * as v from 'valibot';
22-import { beforeAll, describe, expect, it } from 'vitest';
3243import { setupValibotTest } from './test-helper';
54
-1
packages/openapi-ts-tests/main/test/cli.test.ts
···11import path from 'node:path';
2233import { sync } from 'cross-spawn';
44-import { describe, expect, it } from 'vitest';
5465import { getSpecsPath } from '../../utils';
76
···4455import { customClientPlugin } from '@hey-api/custom-client/plugin';
66import { createClient, type UserConfig } from '@hey-api/openapi-ts';
77-import { describe, expect, it } from 'vitest';
8798import type { PluginClientNames } from '../../../openapi-ts/src/plugins/types';
109import { getFilePaths, getSpecsPath } from '../../utils';
···11import * as v from 'valibot';
22-import { beforeAll, describe, expect, it } from 'vitest';
3243import { setupValibotTest } from './test-helper';
54
···11import * as v from 'valibot';
22-import { beforeAll, describe, expect, it } from 'vitest';
3243import { setupValibotTest } from './test-helper';
54
···33import { fileURLToPath } from 'node:url';
4455import { createClient, type UserConfig } from '@hey-api/openapi-ts';
66-import { describe, expect, it } from 'vitest';
7687import { getFilePaths, getSpecsPath } from '../../utils';
98
···11import * as v from 'valibot';
22-import { beforeAll, describe, expect, it } from 'vitest';
3243import { setupValibotTest } from './test-helper';
54
···11import type { Mock } from 'vitest';
22-import { beforeEach, describe, expect, it, vi } from 'vitest';
3243import { runCli } from '~/cli';
54import { createClient } from '~/index';
···2233import { createClient } from '~/index';
4455-import pkg from '../../package.json' assert { type: 'json' };
55+import pkg from '../../package.json';
66import { cliToConfig } from './adapter';
7788const binName = Object.keys(pkg.bin)[0]!;
+2-1
packages/openapi-ts/src/cli/schema.ts
···11+import type { PluginNames } from '@hey-api/shared';
12import type { MaybeArray } from '@hey-api/types';
2333-import type { PluginClientNames, PluginNames } from '~/plugins/types';
44+import type { PluginClientNames } from '~/plugins/types';
4556export interface CliOptions {
67 client?: PluginClientNames;
···11+import path from 'node:path';
22+import { fileURLToPath } from 'node:url';
33+14import { log } from '@hey-api/codegen-core';
55+import type { PostProcessor, UserPostProcessor } from '@hey-api/shared';
66+import {
77+ findTsConfigPath,
88+ loadTsConfig,
99+ resolveSource,
1010+ valueToObject,
1111+} from '@hey-api/shared';
1212+import type { MaybeArray } from '@hey-api/types';
213import ts from 'typescript';
31444-import { findTsConfigPath, loadTsConfig } from '~/generate/tsConfig';
55-66-import type { Config, UserConfig } from '../types';
77-import { valueToObject } from '../utils/config';
88-import type { PostProcessor, UserPostProcessor } from './postprocess';
915import { postProcessors } from './postprocess';
1010-import { resolveSource } from './source/config';
1111-import type { UserOutput } from './types';
1616+import type { Output, UserOutput } from './types';
1717+1818+const __filename = fileURLToPath(import.meta.url);
1919+const __dirname = path.dirname(__filename);
12201313-export function getOutput(userConfig: UserConfig): Config['output'] {
2121+export function getOutput(userConfig: {
2222+ output: MaybeArray<string | UserOutput>;
2323+}): Output {
1424 if (userConfig.output instanceof Array) {
1525 throw new Error(
1626 'Unexpected array of outputs in user configuration. This should have been expanded already.',
···5969 }),
6070 },
6171 value: userOutput,
6262- }) as Config['output'];
6363- output.tsConfig = loadTsConfig(findTsConfigPath(output.tsConfigPath));
7272+ }) as Output;
7373+ output.tsConfig = loadTsConfig(
7474+ findTsConfigPath(__dirname, output.tsConfigPath),
7575+ );
6476 if (
6577 output.importFileExtension === undefined &&
6678 (output.tsConfig?.options.moduleResolution ===
-3
packages/openapi-ts/src/config/output/index.ts
···11-export { getOutput } from './config';
22-export { postprocessOutput } from './postprocess';
33-export type { Output, UserOutput } from './types';
···11-import type {
22- NameConflictResolver,
33- RenderContext,
44-} from '@hey-api/codegen-core';
55-import type { MaybeArray, MaybeFunc } from '@hey-api/types';
66-import type ts from 'typescript';
77-88-import type { Casing, NameTransformer } from '~/utils/naming';
99-1010-import type { NamingOptions } from '../shared';
1111-import type {
1212- Formatters,
1313- Linters,
1414- PostProcessor,
1515- PostProcessorPreset,
1616- UserPostProcessor,
1717-} from './postprocess';
1818-import type { SourceConfig, UserSourceConfig } from './source/types';
1919-2020-type ImportFileExtensions = '.js' | '.ts';
2121-2222-type Header = MaybeFunc<
2323- (ctx: RenderContext) => MaybeArray<string> | null | undefined
2424->;
2525-2626-export type UserOutput = {
2727- /**
2828- * Defines casing of the output fields. By default, we preserve `input`
2929- * values as data transforms incur a performance penalty at runtime.
3030- *
3131- * @default undefined
3232- */
3333- case?: Casing;
3434- /**
3535- * Clean the `output` folder on every run? If disabled, this folder may
3636- * be used to store additional files. The default option is `true` to
3737- * reduce the risk of keeping outdated files around when configuration,
3838- * input, or package version changes.
3939- *
4040- * @default true
4141- */
4242- clean?: boolean;
4343- /**
4444- * Optional function to transform file names before they are used.
4545- *
4646- * @param name The original file name.
4747- * @returns The transformed file name.
4848- * @default '{{name}}'
4949- */
5050- fileName?:
5151- | NameTransformer
5252- | {
5353- /**
5454- * Casing convention for generated names.
5555- *
5656- * @default 'preserve'
5757- */
5858- case?: Casing;
5959- /**
6060- * Naming pattern for generated names.
6161- *
6262- * @default '{{name}}'
6363- */
6464- name?: NameTransformer;
6565- /**
6666- * Suffix to append to file names (before the extension). For example,
6767- * with a suffix of `.gen`, `example.ts` becomes `example.gen.ts`.
6868- *
6969- * @default '.gen'
7070- * @example
7171- * // Given a suffix of `.gen`
7272- * 'index.ts' -> 'index.ts' (index files are not renamed)
7373- * 'user.ts' -> 'user.gen.ts'
7474- * 'order.gen.ts' -> 'order.gen.ts' (files already containing the suffix are not renamed)
7575- */
7676- suffix?: string | null;
7777- };
7878- /**
7979- * Which formatter to use to process output folder?
8080- *
8181- * @default null
8282- * @deprecated Use `postProcess` instead.
8383- */
8484- format?: Formatters | null;
8585- /**
8686- * Text to include at the top of every generated file.
8787- */
8888- header?: Header;
8989- /**
9090- * If specified, this will be the file extension used when importing
9191- * other modules. By default, we don't add a file extension and let the
9292- * runtime resolve it. If you're using moduleResolution `nodenext` or
9393- * `node16`, we default to `.js`.
9494- *
9595- * @default undefined
9696- */
9797- importFileExtension?: ImportFileExtensions | (string & {}) | null;
9898- /**
9999- * Should the exports from plugin files be re-exported in the index
100100- * barrel file? By default, this is enabled and only default plugins
101101- * are re-exported.
102102- *
103103- * @default true
104104- */
105105- indexFile?: boolean;
106106- /**
107107- * Which linter to use to process output folder?
108108- *
109109- * @default null
110110- * @deprecated Use `postProcess` instead.
111111- */
112112- lint?: Linters | null;
113113- /**
114114- * Optional name conflict resolver to customize how naming conflicts
115115- * are handled.
116116- */
117117- nameConflictResolver?: NameConflictResolver;
118118- /**
119119- * The absolute path to the output folder.
120120- */
121121- path: string;
122122- /**
123123- * Post-processing commands to run on the output folder, executed in order.
124124- *
125125- * Use preset strings for common tools, or provide custom configurations.
126126- *
127127- * @example ['biome:lint', 'prettier']
128128- * @example [{ command: 'dprint', args: ['fmt', '{{path}}'] }]
129129- * @example ['eslint', { command: 'prettier', args: ['{{path}}', '--write'] }]
130130- *
131131- * @default []
132132- */
133133- postProcess?: ReadonlyArray<PostProcessorPreset | UserPostProcessor>;
134134- /**
135135- * Whether `export * from 'module'` should be used when possible
136136- * instead of named exports.
137137- *
138138- * @default false
139139- */
140140- preferExportAll?: boolean;
141141- /**
142142- * Optional function to transform module specifiers.
143143- *
144144- * @default undefined
145145- */
146146- resolveModuleName?: (moduleName: string) => string | undefined;
147147- /**
148148- * Configuration for generating a copy of the input source used to produce this output.
149149- *
150150- * Set to `false` to skip generating the source, or `true` to use defaults.
151151- *
152152- * You can also provide a configuration object to further customize behavior.
153153- *
154154- * @default false
155155- */
156156- source?: boolean | UserSourceConfig;
157157- /**
158158- * Relative or absolute path to the tsconfig file we should use to
159159- * generate the output. If a path to tsconfig file is not provided, we
160160- * attempt to find one starting from the location of the
161161- * `@hey-api/openapi-ts` configuration file and traversing up.
162162- *
163163- * @default undefined
164164- */
165165- tsConfigPath?: (string & {}) | null;
166166-};
167167-168168-export type Output = {
169169- /**
170170- * Defines casing of the output fields. By default, we preserve `input`
171171- * values as data transforms incur a performance penalty at runtime.
172172- */
173173- case: Casing | undefined;
174174- /**
175175- * Clean the `output` folder on every run? If disabled, this folder may
176176- * be used to store additional files. The default option is `true` to
177177- * reduce the risk of keeping outdated files around when configuration,
178178- * input, or package version changes.
179179- */
180180- clean: boolean;
181181- /**
182182- * Optional function to transform file names before they are used.
183183- *
184184- * @param name The original file name.
185185- * @returns The transformed file name.
186186- */
187187- fileName: NamingOptions & {
188188- /**
189189- * Suffix to append to file names (before the extension). For example,
190190- * with a suffix of `.gen`, `example.ts` becomes `example.gen.ts`.
191191- *
192192- * @example
193193- * // Given a suffix of `.gen`
194194- * 'index.ts' -> 'index.ts' (index files are not renamed)
195195- * 'user.ts' -> 'user.gen.ts'
196196- * 'order.gen.ts' -> 'order.gen.ts' (files already containing the suffix are not renamed)
197197- */
198198- suffix: string | null;
199199- };
200200- /**
201201- * Which formatter to use to process output folder?
202202- */
203203- format: Formatters | null;
204204- /**
205205- * Text to include at the top of every generated file.
206206- */
207207- header: Header;
208208- /**
209209- * If specified, this will be the file extension used when importing
210210- * other modules. By default, we don't add a file extension and let the
211211- * runtime resolve it. If you're using moduleResolution `nodenext` or
212212- * `node16`, we default to `.js`.
213213- */
214214- importFileExtension: ImportFileExtensions | (string & {}) | null | undefined;
215215- /**
216216- * Should the exports from plugin files be re-exported in the index
217217- * barrel file? By default, this is enabled and only default plugins
218218- * are re-exported.
219219- */
220220- indexFile: boolean;
221221- /**
222222- * Which linter to use to process output folder?
223223- */
224224- lint: Linters | null;
225225- /**
226226- * Optional name conflict resolver to customize how naming conflicts
227227- * are handled.
228228- */
229229- nameConflictResolver: NameConflictResolver | undefined;
230230- /**
231231- * The absolute path to the output folder.
232232- */
233233- path: string;
234234- /**
235235- * Post-processing commands to run on the output folder, executed in order.
236236- */
237237- postProcess: ReadonlyArray<PostProcessor>;
238238- /**
239239- * Whether `export * from 'module'` should be used when possible
240240- * instead of named exports.
241241- */
242242- preferExportAll: boolean;
243243- /**
244244- * Optional function to transform module specifiers.
245245- */
246246- resolveModuleName: ((moduleName: string) => string | undefined) | undefined;
247247- /**
248248- * Configuration for generating a copy of the input source used to produce this output.
249249- */
250250- source: SourceConfig;
251251- /**
252252- * The parsed TypeScript configuration used to generate the output.
253253- * If no `tsconfig` file path was provided or found, this will be `null`.
254254- */
255255- tsConfig: ts.ParsedCommandLine | null;
256256- /**
257257- * Relative or absolute path to the tsconfig file we should use to
258258- * generate the output. If a path to tsconfig file is not provided, we
259259- * attempt to find one starting from the location of the
260260- * `@hey-api/openapi-ts` configuration file and traversing up.
261261- */
262262- tsConfigPath: (string & {}) | null | undefined;
263263-};
+100
packages/openapi-ts/src/config/output/types.ts
···11+import type {
22+ BaseOutput,
33+ BaseUserOutput,
44+ UserPostProcessor,
55+} from '@hey-api/shared';
66+import type { AnyString } from '@hey-api/types';
77+import type ts from 'typescript';
88+99+import type { Formatters, Linters, PostProcessorPreset } from './postprocess';
1010+1111+type ImportFileExtensions = '.js' | '.ts';
1212+1313+export type UserOutput = BaseUserOutput & {
1414+ /**
1515+ * Which formatter to use to process output folder?
1616+ *
1717+ * @default null
1818+ * @deprecated Use `postProcess` instead.
1919+ */
2020+ format?: Formatters | null;
2121+ /**
2222+ * If specified, this will be the file extension used when importing
2323+ * other modules. By default, we don't add a file extension and let the
2424+ * runtime resolve it. If you're using moduleResolution `nodenext` or
2525+ * `node16`, we default to `.js`.
2626+ *
2727+ * @default undefined
2828+ */
2929+ importFileExtension?: ImportFileExtensions | AnyString | null;
3030+ /**
3131+ * Which linter to use to process output folder?
3232+ *
3333+ * @default null
3434+ * @deprecated Use `postProcess` instead.
3535+ */
3636+ lint?: Linters | null;
3737+ /**
3838+ * Post-processing commands to run on the output folder, executed in order.
3939+ *
4040+ * Use preset strings for common tools, or provide custom configurations.
4141+ *
4242+ * @example ['biome:lint', 'prettier']
4343+ * @example [{ command: 'dprint', args: ['fmt', '{{path}}'] }]
4444+ * @example ['eslint', { command: 'prettier', args: ['{{path}}', '--write'] }]
4545+ *
4646+ * @default []
4747+ */
4848+ postProcess?: ReadonlyArray<PostProcessorPreset | UserPostProcessor>;
4949+ /**
5050+ * Whether `export * from 'module'` should be used when possible
5151+ * instead of named exports.
5252+ *
5353+ * @default false
5454+ */
5555+ preferExportAll?: boolean;
5656+ /**
5757+ * Relative or absolute path to the tsconfig file we should use to
5858+ * generate the output. If a path to tsconfig file is not provided, we
5959+ * attempt to find one starting from the location of the
6060+ * `@hey-api/openapi-ts` configuration file and traversing up.
6161+ *
6262+ * @default undefined
6363+ */
6464+ tsConfigPath?: AnyString | null;
6565+};
6666+6767+export type Output = BaseOutput & {
6868+ /**
6969+ * Which formatter to use to process output folder?
7070+ */
7171+ format: Formatters | null;
7272+ /**
7373+ * If specified, this will be the file extension used when importing
7474+ * other modules. By default, we don't add a file extension and let the
7575+ * runtime resolve it. If you're using moduleResolution `nodenext` or
7676+ * `node16`, we default to `.js`.
7777+ */
7878+ importFileExtension: ImportFileExtensions | AnyString | null | undefined;
7979+ /**
8080+ * Which linter to use to process output folder?
8181+ */
8282+ lint: Linters | null;
8383+ /**
8484+ * Whether `export * from 'module'` should be used when possible
8585+ * instead of named exports.
8686+ */
8787+ preferExportAll: boolean;
8888+ /**
8989+ * The parsed TypeScript configuration used to generate the output.
9090+ * If no `tsconfig` file path was provided or found, this will be `null`.
9191+ */
9292+ tsConfig: ts.ParsedCommandLine | null;
9393+ /**
9494+ * Relative or absolute path to the tsconfig file we should use to
9595+ * generate the output. If a path to tsconfig file is not provided, we
9696+ * attempt to find one starting from the location of the
9797+ * `@hey-api/openapi-ts` configuration file and traversing up.
9898+ */
9999+ tsConfigPath: AnyString | null | undefined;
100100+};
···11-import type { Casing, NameTransformer } from '~/utils/naming';
22-33-export type FeatureToggle = {
44- /**
55- * Whether this feature is enabled.
66- */
77- enabled: boolean;
88-};
99-1010-export type IndexExportOption = {
1111- /**
1212- * Whether exports should be re-exported in the index file.
1313- */
1414- exportFromIndex: boolean;
1515-};
1616-1717-export type NamingOptions = {
1818- /**
1919- * Casing convention for generated names.
2020- */
2121- case: Casing;
2222- /**
2323- * Naming pattern for generated names.
2424- */
2525- name: NameTransformer;
2626-};
-108
packages/openapi-ts/src/config/types.d.ts
···11-import type { MaybeArray } from '@hey-api/types';
22-33-import type { Plugin } from '~/plugins';
44-import type { PluginConfigMap } from '~/plugins/config';
55-import type { PluginNames } from '~/plugins/types';
66-import type { Input, UserInput, Watch } from '~/types/input';
77-import type { Logs } from '~/types/logs';
88-import type { Parser, UserParser } from '~/types/parser';
99-1010-import type { Output, UserOutput } from './output';
1111-1212-export type UserConfig = {
1313- /**
1414- * Path to the config file. Set this value if you don't use the default
1515- * config file name, or it's not located in the project root.
1616- */
1717- configFile?: string;
1818- /**
1919- * Skip writing files to disk?
2020- *
2121- * @default false
2222- */
2323- dryRun?: boolean;
2424- /**
2525- * Path to the OpenAPI specification. This can be:
2626- * - path
2727- * - URL
2828- * - API registry shorthand
2929- *
3030- * Both JSON and YAML file formats are supported. You can also pass the parsed
3131- * object directly if you're fetching the file yourself.
3232- *
3333- * Alternatively, you can define a configuration object with more options.
3434- *
3535- * If you define an array, we will generate a single output from multiple
3636- * inputs. If you define an array of outputs with the same length, we will
3737- * generate multiple outputs, one for each input.
3838- */
3939- input: MaybeArray<UserInput | Required<UserInput>['path']>;
4040- /**
4141- * Show an interactive error reporting tool when the program crashes? You
4242- * generally want to keep this disabled (default).
4343- *
4444- * @default false
4545- */
4646- interactive?: boolean;
4747- /**
4848- * The relative location of the logs folder.
4949- *
5050- * @default process.cwd()
5151- */
5252- logs?: string | Logs;
5353- /**
5454- * Path to the output folder.
5555- *
5656- * If you define an array of outputs with the same length as inputs, we will
5757- * generate multiple outputs, one for each input.
5858- */
5959- output: MaybeArray<string | UserOutput>;
6060- /**
6161- * Customize how the input is parsed and transformed before it's passed to
6262- * plugins.
6363- */
6464- parser?: UserParser;
6565- /**
6666- * Plugins generate artifacts from `input`. By default, we generate SDK
6767- * functions and TypeScript interfaces. If you manually define `plugins`,
6868- * you need to include the default plugins if you wish to use them.
6969- *
7070- * @default ['@hey-api/typescript', '@hey-api/sdk']
7171- */
7272- plugins?: ReadonlyArray<
7373- | PluginNames
7474- | {
7575- [K in PluginNames]: PluginConfigMap[K]['config'] & {
7676- name: K;
7777- };
7878- }[PluginNames]
7979- >;
8080- /**
8181- * @deprecated use `input.watch` instead
8282- */
8383- watch?: boolean | number | Watch;
8484-};
8585-8686-export type Config = Omit<
8787- Required<UserConfig>,
8888- 'input' | 'logs' | 'output' | 'parser' | 'plugins' | 'watch'
8989-> & {
9090- /**
9191- * Path to the input specification.
9292- */
9393- input: ReadonlyArray<Input>;
9494- logs: Logs;
9595- /**
9696- * Path to the output folder.
9797- */
9898- output: Output;
9999- /**
100100- * Customize how the input is parsed and transformed before it's passed to
101101- * plugins.
102102- */
103103- parser: Parser;
104104- pluginOrder: ReadonlyArray<keyof PluginConfigMap>;
105105- plugins: {
106106- [K in PluginNames]?: Plugin.Config<PluginConfigMap[K]>;
107107- };
108108-};
+34
packages/openapi-ts/src/config/types.ts
···11+import type {
22+ BaseConfig,
33+ BaseUserConfig,
44+ Plugin,
55+ PluginConfigMap,
66+ PluginNames,
77+} from '@hey-api/shared';
88+99+import type { Output, UserOutput } from './output/types';
1010+1111+export type UserConfig = BaseUserConfig<UserOutput> & {
1212+ /**
1313+ * Plugins generate artifacts from `input`. By default, we generate SDK
1414+ * functions and TypeScript interfaces. If you manually define `plugins`,
1515+ * you need to include the default plugins if you wish to use them.
1616+ *
1717+ * @default ['@hey-api/typescript', '@hey-api/sdk']
1818+ */
1919+ plugins?: ReadonlyArray<
2020+ | PluginNames
2121+ | {
2222+ [K in PluginNames]: PluginConfigMap[K]['config'] & {
2323+ name: K;
2424+ };
2525+ }[PluginNames]
2626+ >;
2727+};
2828+2929+export type Config = BaseConfig<UserConfig, Output> & {
3030+ pluginOrder: ReadonlyArray<keyof PluginConfigMap>;
3131+ plugins: {
3232+ [K in PluginNames]?: Plugin.Config<PluginConfigMap[K]>;
3333+ };
3434+};
+10
packages/openapi-ts/src/config/utils.ts
···11+import type { Context, PluginInstance } from '@hey-api/shared';
22+33+import type { Config } from './types';
44+55+export function getTypedConfig(plugin: PluginInstance | Context): Config {
66+ if ('context' in plugin) {
77+ return plugin.context.config as Config;
88+ }
99+ return plugin.config as Config;
1010+}
···11-import type { RangeOptions, SemVer } from 'semver';
22-import * as semver from 'semver';
33-44-export type Package = {
55- /**
66- * Get the installed version of a package.
77- * @param name The name of the package to get the version for.
88- * @returns A SemVer object containing version information, or undefined if the package is not installed
99- * or the version string is invalid.
1010- */
1111- getVersion: (name: string) => SemVer | undefined;
1212- /**
1313- * Check if a given package is installed in the project.
1414- * @param name The name of the package to check.
1515- */
1616- isInstalled: (name: string) => boolean;
1717- /**
1818- * Check if the installed version of a package or a given SemVer object satisfies a semver range.
1919- * @param nameOrVersion The name of the package to check, or a SemVer object.
2020- * @param range The semver range to check against.
2121- * @returns True if the version satisfies the range, false otherwise.
2222- */
2323- satisfies: (
2424- nameOrVersion: string | SemVer,
2525- range: string,
2626- optionsOrLoose?: boolean | RangeOptions,
2727- ) => boolean;
2828-};
2929-3030-export const satisfies: typeof semver.satisfies = (...args) =>
3131- semver.satisfies(...args);
3232-3333-export const packageFactory = (
3434- dependencies: Record<string, string>,
3535-): Package => ({
3636- getVersion: (name) => {
3737- const version = dependencies[name];
3838- if (!version) return;
3939- try {
4040- let parsed = semver.parse(version);
4141- if (parsed) return parsed;
4242-4343- const min = semver.minVersion(version);
4444- if (min) return min;
4545-4646- parsed = semver.coerce(version);
4747- if (parsed) return parsed;
4848- } catch {
4949- // noop
5050- }
5151- return;
5252- },
5353- isInstalled: (name) => Boolean(dependencies[name]),
5454- satisfies: (nameOrVersion, range, optionsOrLoose) => {
5555- const version =
5656- typeof nameOrVersion === 'string'
5757- ? dependencies[nameOrVersion]
5858- : nameOrVersion;
5959- return version ? satisfies(version, range, optionsOrLoose) : false;
6060- },
6161-});
+4-5
packages/openapi-ts/src/config/validate.ts
···11-import { ConfigError } from '~/error';
11+import { ConfigError, getInput } from '@hey-api/shared';
2233import type { Job } from './expand';
44-import { getInput } from './input';
55-import { getOutput } from './output';
44+import { getOutput } from './output/config';
6577-export interface ValidationResult {
66+export type ValidationResult = {
87 errors: Array<ConfigError>;
98 job: Job;
1010-}
99+};
11101211export function validateJobs(
1312 jobs: ReadonlyArray<Job>,
···11-import { Logger } from '@hey-api/codegen-core';
22-import type { LazyOrAsync, MaybeArray } from '@hey-api/types';
11+import path from 'node:path';
22+import { fileURLToPath } from 'node:url';
3344-import { checkNodeVersion } from '~/config/engine';
55-import type { Configs } from '~/config/init';
66-import { resolveJobs } from '~/config/init';
77-import { getLogs } from '~/config/logs';
88-import type { UserConfig } from '~/config/types';
99-import { createClient as pCreateClient } from '~/createClient';
44+import { Logger } from '@hey-api/codegen-core';
55+import type { Context } from '@hey-api/shared';
106import {
77+ checkNodeVersion,
118 ConfigValidationError,
99+ getLogs,
1210 JobError,
1311 logCrashReport,
1412 openGitHubIssueWithCrashReport,
1313+ printCliIntro,
1514 printCrashReport,
1615 shouldReportCrash,
1717-} from '~/error';
1818-import type { Context } from '~/ir/context';
1919-import { printCliIntro } from '~/utils/cli';
1616+} from '@hey-api/shared';
1717+import type { LazyOrAsync, MaybeArray } from '@hey-api/types';
1818+1919+import type { Configs } from '~/config/init';
2020+import { resolveJobs } from '~/config/init';
2121+import type { UserConfig } from '~/config/types';
2222+import { createClient as pCreateClient } from '~/createClient';
2323+2424+const __filename = fileURLToPath(import.meta.url);
2525+const __dirname = path.dirname(__filename);
20262127/**
2228 * Generate a client from the provided configuration.
···3642 : [];
37433844 let rawLogs = userConfigs.find(
3939- (config) => getLogs(config).level !== 'silent',
4545+ (config) => getLogs(config.logs).level !== 'silent',
4046 )?.logs;
4147 if (typeof rawLogs === 'string') {
4242- rawLogs = getLogs({ logs: rawLogs });
4848+ rawLogs = getLogs(rawLogs);
4349 }
44504551 let jobs: Configs['jobs'] = [];
···5460 const dependencies = resolved.dependencies;
5561 jobs = resolved.jobs;
5662 const printIntro = jobs.some((job) => job.config.logs.level !== 'silent');
5757- if (printIntro) printCliIntro();
6363+ if (printIntro) printCliIntro(__dirname);
5864 eventConfig.timeEnd();
59656066 const configErrors = jobs.flatMap((job) =>
···7480 logger,
7581 });
7682 } catch (error) {
7777- throw new JobError('', {
7878- error,
7979- jobIndex: job.index,
8080- });
8383+ if (error instanceof Error) {
8484+ throw new JobError('', {
8585+ error,
8686+ jobIndex: job.index,
8787+ });
8888+ }
8189 }
8290 }),
8391 );
···108116 userConfigs.some((config) => config.interactive) ??
109117 false;
110118 if (await shouldReportCrash({ error, isInteractive })) {
111111- await openGitHubIssueWithCrashReport(error);
119119+ await openGitHubIssueWithCrashReport(error, __dirname);
112120 }
113121 }
114122
+2-3
packages/openapi-ts/src/generate/client.ts
···33import { fileURLToPath } from 'node:url';
4455import type { IProject, ProjectRenderMeta } from '@hey-api/codegen-core';
66+import type { DefinePlugin } from '@hey-api/shared';
77+import { ensureDirSync } from '@hey-api/shared';
6879import type { Config } from '~/config/types';
88-import type { DefinePlugin } from '~/plugins';
910import type { Client } from '~/plugins/@hey-api/client-core/types';
1011import { getClientPlugin } from '~/plugins/@hey-api/client-core/utils';
1111-1212-import { ensureDirSync } from './utils';
13121413const __filename = fileURLToPath(import.meta.url);
1514const __dirname = path.dirname(__filename);
+10-10
packages/openapi-ts/src/generate/output.ts
···11import fs from 'node:fs';
22import path from 'node:path';
3344-import type { Context } from '~/ir/context';
55-import { IntentContext } from '~/ir/intents';
44+import type { Context } from '@hey-api/shared';
55+import { IntentContext } from '@hey-api/shared';
66+77+import { getTypedConfig } from '~/config/utils';
68import { getClientPlugin } from '~/plugins/@hey-api/client-core/utils';
79810import { generateClientBundle } from './client';
···1618 }
1719 }
18201919- const client = getClientPlugin(context.config);
2020- if (
2121- 'bundle' in client.config &&
2222- client.config.bundle &&
2323- !context.config.dryRun
2424- ) {
2121+ const config = getTypedConfig(context);
2222+2323+ const client = getClientPlugin(config);
2424+ if ('bundle' in client.config && client.config.bundle && !config.dryRun) {
2525 // not proud of this one
2626 // @ts-expect-error
2727- context.config._FRAGILE_CLIENT_BUNDLE_RENAMED = generateClientBundle({
2727+ config._FRAGILE_CLIENT_BUNDLE_RENAMED = generateClientBundle({
2828 meta: {
2929- importFileExtension: context.config.output.importFileExtension,
2929+ importFileExtension: config.output.importFileExtension,
3030 },
3131 outputPath,
3232 // @ts-expect-error
···11-import { describe, expect, it } from 'vitest';
22-33-import type { Graph } from '~/graph';
41import {
52 getIrPointerPriority,
63 matchIrPointerToGroup,
74 preferGroups,
88-} from '~/ir/graph';
99-import { buildGraph } from '~/openApi/shared/utils/graph';
1010-55+} from '../../ir/graph';
66+import { buildGraph } from '../../openApi/shared/utils/graph';
77+import type { Graph } from '../types/graph';
118import { walk } from '../walk';
1291310const loggerStub = {
···11-import { describe, expect, it } from 'vitest';
22-31import type { IrTopLevelKind } from '../graph';
42import { matchIrPointerToGroup } from '../graph';
53
···11-import { describe, expect, it } from 'vitest';
22-31import type { IRMediaType } from '../mediaType';
42import { isMediaTypeFileLike, mediaTypeToIrMediaType } from '../mediaType';
53
···11import type { MaybePromise } from '@hey-api/types';
2233-import type { CodeSampleObject } from '~/openApi/shared/types';
44-33+import type { CodeSampleObject } from '..//openApi/shared/types';
54import type { IR } from './types';
6576export interface ExampleIntent {
···11-import type { Config } from '~/config/types';
22-11+import type { Parser } from '../config/parser/types';
32import type { IR } from './types';
4354export function getPaginationKeywordsRegExp(
66- pagination: Config['parser']['pagination'],
55+ pagination: Parser['pagination'],
76): RegExp {
87 const pattern = `^(${pagination.keywords.join('|')})$`;
98 return new RegExp(pattern);
···11+/* eslint-disable @typescript-eslint/no-namespace */
12import type { Symbol } from '@hey-api/codegen-core';
2333-import type { JsonSchemaDraft2020_12 } from '~/openApi/3.1.x/types/json-schema-draft-2020-12';
44+import type { JsonSchemaDraft2020_12 } from '../openApi/3.1.x/types/json-schema-draft-2020-12';
45import type {
66+ ReferenceObject as IRReferenceObject,
57 SecuritySchemeObject,
68 ServerObject,
77-} from '~/openApi/3.1.x/types/spec';
88-99+} from '../openApi/3.1.x/types/spec';
910import type { IRMediaType } from './mediaType';
10111112/**
···248249 export type ParametersObject = IRParametersObject;
249250 export type PathItemObject = IRPathItemObject;
250251 export type PathsObject = IRPathsObject;
251251- export type ReferenceObject = ReferenceObject;
252252+ export type ReferenceObject = IRReferenceObject;
252253 export type RequestBodyObject = IRRequestBodyObject;
253254 export type ResponseObject = IRResponseObject;
254255 export type ResponsesObject = IRResponsesObject;
···11-import { describe, expect, it } from 'vitest';
22-33-import type { Context } from '~/ir/context';
44-11+import type { Context } from '../../../../ir/context';
52import type { ParameterObject, SecuritySchemeObject } from '../../types/spec';
63import { parsePathOperation } from '../operation';
74
···11-import { describe, expect, it } from 'vitest';
22-33-import type { Context } from '~/ir/context';
44-import type { OpenApi } from '~/openApi/types';
55-11+import type { Context } from '../../../../ir/context';
22+import type { OpenApi } from '../../../types';
63import { parseServers } from '../server';
7485describe('parseServers', () => {
···11-import type { Context } from '~/ir/context';
22-import { buildResourceMetadata } from '~/openApi/shared/graph/meta';
33-import { transformOpenApiSpec } from '~/openApi/shared/transforms';
44-import type { State } from '~/openApi/shared/types/state';
11+import type { Context } from '../../../ir/context';
22+import { buildResourceMetadata } from '../../../openApi/shared/graph/meta';
33+import { transformOpenApiSpec } from '../../../openApi/shared/transforms';
44+import type { State } from '../../../openApi/shared/types/state';
55import {
66 createFilteredDependencies,
77 createFilters,
88 hasFilters,
99-} from '~/openApi/shared/utils/filter';
1010-import { buildGraph } from '~/openApi/shared/utils/graph';
1111-import { mergeParametersObjects } from '~/openApi/shared/utils/parameter';
1212-import { handleValidatorResult } from '~/openApi/shared/utils/validator';
1313-99+} from '../../../openApi/shared/utils/filter';
1010+import { buildGraph } from '../../../openApi/shared/utils/graph';
1111+import { mergeParametersObjects } from '../../../openApi/shared/utils/parameter';
1212+import { handleValidatorResult } from '../../../openApi/shared/utils/validator';
1413import type {
1514 OpenApiV2_0_X,
1615 OperationObject,
···11-import type { Context } from '~/ir/context';
22-import type { IR, IRBodyObject } from '~/ir/types';
33-import type { State } from '~/openApi/shared/types/state';
44-import { operationToId } from '~/openApi/shared/utils/operation';
55-11+import type { Context } from '../../../ir/context';
22+import type { IR } from '../../../ir/types';
33+import type { State } from '../../../openApi/shared/types/state';
44+import { operationToId } from '../../../openApi/shared/utils/operation';
65import type {
76 OperationObject,
87 ParameterObject,
···111110 }
112111113112 let isRequestBodyRequired = false;
114114- const requestBodyObject: IRBodyObject = {
113113+ const requestBodyObject: IR.BodyObject = {
115114 mediaType: '',
116115 schema: {
117116 properties: {},
···11-import type { Context } from '~/ir/context';
22-import { getPaginationKeywordsRegExp } from '~/ir/pagination';
33-import type { SchemaType } from '~/openApi/shared/types/schema';
44-11+import type { Context } from '../../../ir/context';
22+import { getPaginationKeywordsRegExp } from '../../../ir/pagination';
33+import type { SchemaType } from '../../../openApi/shared/types/schema';
54import type { ParameterObject, ReferenceObject } from '../types/spec';
65import type { SchemaObject } from '../types/spec';
76import { getSchemaType } from './schema';
···11-import type { Context } from '~/ir/context';
22-import type { IR } from '~/ir/types';
33-11+import type { Context } from '../../../ir/context';
22+import type { IR } from '../../../ir/types';
43import type {
54 OperationObject,
65 ParameterObject,
···11-import type { Context } from '~/ir/context';
22-import type { IR } from '~/ir/types';
33-import { addItemsToSchema } from '~/ir/utils';
11+import type { Context } from '../../../ir/context';
22+import type { IR } from '../../../ir/types';
33+import { addItemsToSchema } from '../../../ir/utils';
44import type {
55 SchemaState,
66 SchemaType,
77 SchemaWithRequired,
88-} from '~/openApi/shared/types/schema';
99-import { discriminatorValues } from '~/openApi/shared/utils/discriminator';
1010-import { isTopLevelComponentRef, refToName } from '~/utils/ref';
1111-88+} from '../../../openApi/shared/types/schema';
99+import { discriminatorValues } from '../../../openApi/shared/utils/discriminator';
1010+import { isTopLevelComponentRef, refToName } from '../../../utils/ref';
1211import type { SchemaObject } from '../types/spec';
13121413export const getSchemaType = ({
···11-import type { CodeSampleObject, EnumExtensions } from '~/openApi/shared/types';
22-11+import type {
22+ CodeSampleObject,
33+ EnumExtensions,
44+} from '../../../openApi/shared/types';
35import type { JsonSchemaDraft4 } from './json-schema-draft-4';
46import type { OpenApiV2_0_X_Nullable_Extensions } from './openapi-spec-extensions';
57
···11-import { describe, expect, it } from 'vitest';
22-33-import type { Context } from '~/ir/context';
44-11+import type { Context } from '../../../../ir/context';
52import type { SecuritySchemeObject } from '../../types/spec';
63import { parsePathOperation } from '../operation';
74
···11-import type { Context } from '~/ir/context';
22-import { buildResourceMetadata } from '~/openApi/shared/graph/meta';
33-import { transformOpenApiSpec } from '~/openApi/shared/transforms';
44-import type { State } from '~/openApi/shared/types/state';
11+import type { Context } from '../../../ir/context';
22+import { buildResourceMetadata } from '../../../openApi/shared/graph/meta';
33+import { transformOpenApiSpec } from '../../../openApi/shared/transforms';
44+import type { State } from '../../../openApi/shared/types/state';
55import {
66 createFilteredDependencies,
77 createFilters,
88 hasFilters,
99-} from '~/openApi/shared/utils/filter';
1010-import { buildGraph } from '~/openApi/shared/utils/graph';
1111-import { mergeParametersObjects } from '~/openApi/shared/utils/parameter';
1212-import { handleValidatorResult } from '~/openApi/shared/utils/validator';
1313-99+} from '../../../openApi/shared/utils/filter';
1010+import { buildGraph } from '../../../openApi/shared/utils/graph';
1111+import { mergeParametersObjects } from '../../../openApi/shared/utils/parameter';
1212+import { handleValidatorResult } from '../../../openApi/shared/utils/validator';
1413import type {
1514 OpenApiV3_0_X,
1615 ParameterObject,
···11-import type { Context } from '~/ir/context';
22-import type { IR } from '~/ir/types';
33-import type { State } from '~/openApi/shared/types/state';
44-import { operationToId } from '~/openApi/shared/utils/operation';
55-11+import type { Context } from '../../../ir/context';
22+import type { IR } from '../../../ir/types';
33+import type { State } from '../../../openApi/shared/types/state';
44+import { operationToId } from '../../../openApi/shared/utils/operation';
65import type {
76 OperationObject,
87 PathItemObject,
···11-import type { Context } from '~/ir/context';
22-import { getPaginationKeywordsRegExp } from '~/ir/pagination';
33-import type { SchemaType } from '~/openApi/shared/types/schema';
44-11+import type { Context } from '../../../ir/context';
22+import { getPaginationKeywordsRegExp } from '../../../ir/pagination';
33+import type { SchemaType } from '../../../openApi/shared/types/schema';
54import type {
65 ParameterObject,
76 ReferenceObject,
···11-import type { Context } from '~/ir/context';
22-import type { IR } from '~/ir/types';
33-import { refToName } from '~/utils/ref';
44-11+import type { Context } from '../../../ir/context';
22+import type { IR } from '../../../ir/types';
33+import { refToName } from '../../../utils/ref';
54import type {
65 ParameterObject,
76 ReferenceObject,
···11-import type { Context } from '~/ir/context';
22-import type { IR } from '~/ir/types';
33-import { refToName } from '~/utils/ref';
44-11+import type { Context } from '../../../ir/context';
22+import type { IR } from '../../../ir/types';
33+import { refToName } from '../../../utils/ref';
54import type { RequestBodyObject, SchemaObject } from '../types/spec';
65import { mediaTypeObjects } from './mediaType';
76import { schemaToIrSchema } from './schema';
···11-import type { Context } from '~/ir/context';
22-import type { IR } from '~/ir/types';
33-import { addItemsToSchema } from '~/ir/utils';
11+import type { Context } from '../../../ir/context';
22+import type { IR } from '../../../ir/types';
33+import { addItemsToSchema } from '../../../ir/utils';
44import type {
55 SchemaState,
66 SchemaType,
77 SchemaWithRequired,
88-} from '~/openApi/shared/types/schema';
99-import { discriminatorValues } from '~/openApi/shared/utils/discriminator';
1010-import { isTopLevelComponentRef, refToName } from '~/utils/ref';
1111-88+} from '../../../openApi/shared/types/schema';
99+import { discriminatorValues } from '../../../openApi/shared/utils/discriminator';
1010+import { isTopLevelComponentRef, refToName } from '../../../utils/ref';
1211import type { ReferenceObject, SchemaObject } from '../types/spec';
13121413export const getSchemaType = ({
···11-import { describe, expect, it } from 'vitest';
22-33-import type { Context } from '~/ir/context';
44-11+import type { Context } from '../../../../ir/context';
52import type { SecuritySchemeObject } from '../../types/spec';
63import { parsePathOperation } from '../operation';
74
···11-import type { Context } from '~/ir/context';
22-import { buildResourceMetadata } from '~/openApi/shared/graph/meta';
33-import { transformOpenApiSpec } from '~/openApi/shared/transforms';
44-import type { State } from '~/openApi/shared/types/state';
11+import type { Context } from '../../../ir/context';
22+import { buildResourceMetadata } from '../../../openApi/shared/graph/meta';
33+import { transformOpenApiSpec } from '../../../openApi/shared/transforms';
44+import type { State } from '../../../openApi/shared/types/state';
55import {
66 createFilteredDependencies,
77 createFilters,
88 hasFilters,
99-} from '~/openApi/shared/utils/filter';
1010-import { buildGraph } from '~/openApi/shared/utils/graph';
1111-import { mergeParametersObjects } from '~/openApi/shared/utils/parameter';
1212-import { handleValidatorResult } from '~/openApi/shared/utils/validator';
1313-99+} from '../../../openApi/shared/utils/filter';
1010+import { buildGraph } from '../../../openApi/shared/utils/graph';
1111+import { mergeParametersObjects } from '../../../openApi/shared/utils/parameter';
1212+import { handleValidatorResult } from '../../../openApi/shared/utils/validator';
1413import type {
1514 OpenApiV3_1_X,
1615 ParameterObject,
···11-import type { Context } from '~/ir/context';
22-import type { IR } from '~/ir/types';
33-import type { State } from '~/openApi/shared/types/state';
44-import type { httpMethods } from '~/openApi/shared/utils/operation';
55-import { operationToId } from '~/openApi/shared/utils/operation';
66-11+import type { Context } from '../../../ir/context';
22+import type { IR } from '../../../ir/types';
33+import type { State } from '../../../openApi/shared/types/state';
44+import type { httpMethods } from '../../../openApi/shared/utils/operation';
55+import { operationToId } from '../../../openApi/shared/utils/operation';
76import type {
87 OperationObject,
98 ReferenceObject,
···11-import type { Context } from '~/ir/context';
22-import { getPaginationKeywordsRegExp } from '~/ir/pagination';
33-import type { SchemaType } from '~/openApi/shared/types/schema';
44-11+import type { Context } from '../../../ir/context';
22+import { getPaginationKeywordsRegExp } from '../../../ir/pagination';
33+import type { SchemaType } from '../../../openApi/shared/types/schema';
54import type { ParameterObject, RequestBodyObject } from '../types/spec';
65import type { SchemaObject } from '../types/spec';
76import { mediaTypeObjects } from './mediaType';
···11-import type { Context } from '~/ir/context';
22-import type { IR } from '~/ir/types';
33-import { refToName } from '~/utils/ref';
44-11+import type { Context } from '../../../ir/context';
22+import type { IR } from '../../../ir/types';
33+import { refToName } from '../../../utils/ref';
54import type {
65 ParameterObject,
76 ReferenceObject,
···11-import type { Context } from '~/ir/context';
22-import type { IR } from '~/ir/types';
33-import { refToName } from '~/utils/ref';
44-11+import type { Context } from '../../../ir/context';
22+import type { IR } from '../../../ir/types';
33+import { refToName } from '../../../utils/ref';
54import type { RequestBodyObject, SchemaObject } from '../types/spec';
65import { mediaTypeObjects } from './mediaType';
76import { schemaToIrSchema } from './schema';
···11-import type { Context } from '~/ir/context';
22-import type { IR } from '~/ir/types';
33-import { addItemsToSchema } from '~/ir/utils';
11+import type { Context } from '../../../ir/context';
22+import type { IR } from '../../../ir/types';
33+import { addItemsToSchema } from '../../../ir/utils';
44import type {
55 SchemaState,
66 SchemaType,
77 SchemaWithRequired,
88-} from '~/openApi/shared/types/schema';
99-import { discriminatorValues } from '~/openApi/shared/utils/discriminator';
1010-import { isTopLevelComponentRef, refToName } from '~/utils/ref';
1111-88+} from '../../../openApi/shared/types/schema';
99+import { discriminatorValues } from '../../../openApi/shared/utils/discriminator';
1010+import { isTopLevelComponentRef, refToName } from '../../../utils/ref';
1211import type { SchemaObject } from '../types/spec';
13121413export const getSchemaTypes = ({
···11-import type { Context } from '~/ir/context';
22-import { mergeParametersObjects } from '~/openApi/shared/utils/parameter';
33-11+import type { Context } from '../../../ir/context';
22+import { mergeParametersObjects } from '../../../openApi/shared/utils/parameter';
43import type { OpenApiV3_1_X, PathItemObject } from '../types/spec';
54import { parseWebhookOperation } from './operation';
65import { parametersArrayToObject } from './parameter';
···11-import type { CodeSampleObject } from '~/openApi/shared/types';
22-11+import type { CodeSampleObject } from '../../../openApi/shared/types';
32import type { JsonSchemaDraft2020_12 } from './json-schema-draft-2020-12';
4354/**
···11import type { Logger } from '@hey-api/codegen-core';
2233-import type { Graph } from '~/graph';
44-import { createOperationKey } from '~/ir/operation';
55-import { jsonPointerToPath } from '~/utils/ref';
66-33+import type { Graph } from '../../../graph';
44+import { createOperationKey } from '../../../ir/operation';
55+import { jsonPointerToPath } from '../../../utils/ref';
76import { addNamespace, stringToNamespace } from '../utils/filter';
87import { httpMethods } from '../utils/operation';
98
···11import type { StructureLocation } from '@hey-api/codegen-core';
2233-import type { IR } from '~/ir/types';
33+import type { IR } from '../../../ir/types';
4455/**
66 * A function that derives path segments from an operation.
···11-import type { Context } from '~/ir/context';
22-11+import type { Context } from '../../../ir/context';
32import { enumsTransform } from './enums';
43import { propertiesRequiredByDefaultTransform } from './propertiesRequiredByDefault';
54import { readWriteTransform } from './readWrite';
···11import colors from 'ansi-colors';
2233-import type { Context } from '~/ir/context';
33+import type { Context } from '../../../ir/context';
4455export interface ValidatorIssue {
66 /**
···11-import type { OpenApiV2_0_X, OpenApiV2_0_XTypes } from '~/openApi/2.0.x';
22-import type { OpenApiV3_0_X, OpenApiV3_0_XTypes } from '~/openApi/3.0.x';
33-import type { OpenApiV3_1_X, OpenApiV3_1_XTypes } from '~/openApi/3.1.x';
11+/* eslint-disable @typescript-eslint/no-namespace */
22+import type { OpenApiV2_0_X, OpenApiV2_0_XTypes } from './2.0.x';
33+import type { OpenApiV3_0_X, OpenApiV3_0_XTypes } from './3.0.x';
44+import type { OpenApiV3_1_X, OpenApiV3_1_XTypes } from './3.1.x';
4556export namespace OpenApi {
67 export type V2_0_X = OpenApiV2_0_X;
···11import type { Node, Symbol, SymbolIn } from '@hey-api/codegen-core';
2233-import type { IROperationObject } from '~/ir/types';
44-import type { PluginInstance } from '~/plugins/shared/utils/instance';
33+import type { IROperationObject } from '../ir/types';
44+import type { PluginInstance } from '../plugins/shared/utils/instance';
5566export type Hooks = {
77 /**
···11-import type { PluginContext } from '~/plugins/types';
11+import type { PluginContext } from '@hey-api/shared';
2233import type { UserConfig } from '../types';
44import type { HttpRequestsConfig, UserHttpRequestsConfig } from './types';
···11import type {
22 OperationPathStrategy,
33 OperationStructureStrategy,
44-} from '~/openApi/shared/locations';
55-import { OperationPath, OperationStrategy } from '~/openApi/shared/locations';
44+} from '@hey-api/shared';
55+import { OperationPath, OperationStrategy } from '@hey-api/shared';
6677import type { AngularCommonPlugin } from '../types';
88
···11-import type { PluginContext } from '~/plugins/types';
11+import type { PluginContext } from '@hey-api/shared';
2233import type { UserConfig } from '../types';
44import type { HttpResourcesConfig, UserHttpResourcesConfig } from './types';
···11import type {
22 OperationPathStrategy,
33 OperationStructureStrategy,
44-} from '~/openApi/shared/locations';
55-import { OperationPath, OperationStrategy } from '~/openApi/shared/locations';
44+} from '@hey-api/shared';
55+import { OperationPath, OperationStrategy } from '@hey-api/shared';
6677import type { AngularCommonPlugin } from '../types';
88
···11-import type { IndexExportOption } from '~/config/shared';
22-import type { OperationsStrategy } from '~/openApi/shared/locations';
33-import type { DefinePlugin, Plugin } from '~/plugins';
11+import type { IndexExportOption } from '@hey-api/shared';
22+import type { DefinePlugin, Plugin } from '@hey-api/shared';
33+import type { OperationsStrategy } from '@hey-api/shared';
4455import type {
66 HttpRequestsConfig,
···11-import type { IR } from '~/ir/types';
11+import type { IR } from '@hey-api/shared';
22+23import type { $ } from '~/ts-dsl';
3445type Expression = ReturnType<typeof $.expr>;
···11-import { definePluginConfig } from '~/plugins/shared/utils/config';
11+import { definePluginConfig } from '@hey-api/shared';
2233import { Api } from './api';
44// import { handler } from './plugin';
···11import type {
22+ Casing,
23 FeatureToggle,
34 IndexExportOption,
55+ NameTransformer,
46 NamingOptions,
55-} from '~/config/shared';
66-import type { DefinePlugin, Plugin } from '~/plugins';
77-import type { Casing, NameTransformer } from '~/utils/naming';
77+} from '@hey-api/shared';
88+import type { DefinePlugin, Plugin } from '@hey-api/shared';
89910import type { IApi } from './api';
1011
···11import type { HttpClient } from '@angular/common/http';
22import { HttpHeaders } from '@angular/common/http';
33-import { describe, expect, it, vi } from 'vitest';
4354import { createClient } from '../bundle/client';
65
···11import { HttpHeaders } from '@angular/common/http';
22-import { describe, expect, it, vi } from 'vitest';
3243import type { Auth } from '../../client-core/bundle/auth';
54import type { Client } from '../bundle/types';
···11-import type { DefinePlugin, Plugin } from '~/plugins';
11+import type { DefinePlugin, Plugin } from '@hey-api/shared';
22+23import type { Client } from '~/plugins/@hey-api/client-core/types';
3445export type UserConfig = Plugin.Name<'@hey-api/client-angular'> &
···11import type { AxiosInstance } from 'axios';
22import axios from 'axios';
33-import { describe, expect, it, vi } from 'vitest';
4354import { createClient } from '../bundle/client';
65
···11-import { describe, expect, it, vi } from 'vitest';
22-31import type { Auth } from '../../client-core/bundle/auth';
42import {
53 axiosHeadersKeywords,
···11-import type { DefinePlugin, Plugin } from '~/plugins';
11+import type { DefinePlugin, Plugin } from '@hey-api/shared';
22+23import type { Client } from '~/plugins/@hey-api/client-core/types';
3445export type UserConfig = Plugin.Name<'@hey-api/client-axios'> &
···11-import { describe, expect, it } from 'vitest';
22-31import type { FieldsConfig } from '../bundle/params';
42import { buildClientParams } from '../bundle/params';
53
···11+/* eslint-disable @typescript-eslint/no-namespace */
12import type { Plugin } from '~/plugins';
23import type { HeyApiClientAngularPlugin } from '~/plugins/@hey-api/client-angular';
34import type { HeyApiClientAxiosPlugin } from '~/plugins/@hey-api/client-axios';
···11-import { describe, expect, it, vi } from 'vitest';
22-31import type { ResolvedRequestOptions } from '../bundle';
42import { createClient } from '../bundle/client';
53
···11-import { describe, expect, it, vi } from 'vitest';
22-31import type { Auth } from '../../client-core/bundle/auth';
42import type { Client } from '../bundle/types';
53import { buildUrl, getParseAs, setAuthParams } from '../bundle/utils';
···11-import type { DefinePlugin, Plugin } from '~/plugins';
11+import type { DefinePlugin, Plugin } from '@hey-api/shared';
22+23import type { Client } from '~/plugins/@hey-api/client-core/types';
3445export type UserConfig = Plugin.Name<'@hey-api/client-fetch'> &
···11import type { KyInstance } from 'ky';
22import { HTTPError } from 'ky';
33-import { describe, expect, it, vi } from 'vitest';
4354import type { ResolvedRequestOptions } from '../bundle';
65import { createClient } from '../bundle/client';
···11-import { describe, expect, it, vi } from 'vitest';
22-31import type { Auth } from '../../client-core/bundle/auth';
42import type { Client } from '../bundle/types';
53import { buildUrl, getParseAs, setAuthParams } from '../bundle/utils';
···11+import type { Options as KyOptions } from 'ky';
22+import type ky from 'ky';
33+14import type { Auth } from '../../client-core/bundle/auth';
25import type {
36 ServerSentEventsOptions,
···36393740export interface Config<T extends ClientOptions = ClientOptions>
3841 extends Omit<
3939- import('ky').Options,
4242+ KyOptions,
4043 'body' | 'headers' | 'method' | 'prefixUrl' | 'retry' | 'throwHttpErrors'
4144 >,
4245 CoreConfig {
···4851 * Ky instance to use. You can use this option to provide a custom
4952 * ky instance.
5053 */
5151- ky?: typeof import('ky').default;
5454+ ky?: typeof ky;
5255 /**
5356 * Additional ky-specific options that will be passed directly to ky.
5457 * This allows you to use any ky option not explicitly exposed in the config.
5558 */
5656- kyOptions?: Omit<import('ky').Options, 'method' | 'prefixUrl'>;
5959+ kyOptions?: Omit<KyOptions, 'method' | 'prefixUrl'>;
5760 /**
5861 * Return the response data parsed in a specified format. By default, `auto`
5962 * will infer the appropriate method from the `Content-Type` response header.
···11-import type { DefinePlugin, Plugin } from '~/plugins';
11+import type { DefinePlugin, Plugin } from '@hey-api/shared';
22+23import type { Client } from '~/plugins/@hey-api/client-core/types';
3445export type UserConfig = Plugin.Name<'@hey-api/client-ky'> &
···11-import { describe, expect, it, vi } from 'vitest';
22-31import { createClient } from '../bundle/client';
42import type { ResolvedRequestOptions } from '../bundle/types';
53
···11-import { describe, expect, it, vi } from 'vitest';
22-31import type { Auth } from '../../client-core/bundle/auth';
42import { getParseAs, setAuthParams } from '../bundle/utils';
53
···11-import type { DefinePlugin, Plugin } from '~/plugins';
11+import type { DefinePlugin, Plugin } from '@hey-api/shared';
22+23import type { Client } from '~/plugins/@hey-api/client-core/types';
3445export type UserConfig = Plugin.Name<'@hey-api/client-next'> &
···11-import { describe, expect, it, vi } from 'vitest';
22-31import type { Auth } from '../../client-core/bundle/auth';
42import { mergeInterceptors, setAuthParams } from '../bundle/utils';
53
···11-import type { DefinePlugin, Plugin } from '~/plugins';
11+import type { DefinePlugin, Plugin } from '@hey-api/shared';
22+23import type { Client } from '~/plugins/@hey-api/client-core/types';
3445export type UserConfig = Plugin.Name<'@hey-api/client-nuxt'> & Client.Config;
···11-import { describe, expect, it, vi } from 'vitest';
22-31import { createClient } from '../bundle/client';
42import type { ResolvedRequestOptions } from '../bundle/types';
53
···11-import { describe, expect, it, vi } from 'vitest';
22-31import type { Auth } from '../../client-core/bundle/auth';
42import type { ResolvedRequestOptions } from '../bundle/types';
53import {
···11-import type { DefinePlugin, Plugin } from '~/plugins';
11+import type { DefinePlugin, Plugin } from '@hey-api/shared';
22+23import type { Client } from '~/plugins/@hey-api/client-core/types';
3445export type UserConfig = Plugin.Name<'@hey-api/client-ofetch'> &
···11-import { definePluginConfig } from '~/plugins/shared/utils/config';
11+import { definePluginConfig } from '@hey-api/shared';
2233import { handler } from './plugin';
44import type { HeyApiSchemasPlugin } from './types';
···11-import { satisfies } from '~/config/utils/package';
22-import type { Context } from '~/ir/context';
33-import type { OpenApiV2_0_XTypes } from '~/openApi/2.0.x';
44-import type { OpenApiV3_0_XTypes } from '~/openApi/3.0.x';
55-import type { OpenApiV3_1_XTypes } from '~/openApi/3.1.x';
66-import type { OpenApi } from '~/openApi/types';
11+import type {
22+ Context,
33+ OpenApi,
44+ OpenApiV2_0_XTypes,
55+ OpenApiV3_0_XTypes,
66+ OpenApiV3_1_XTypes,
77+} from '@hey-api/shared';
88+import { satisfies } from '@hey-api/shared';
99+710import { $ } from '~/ts-dsl';
811912import type { HeyApiSchemasPlugin } from './types';
···11-import type { OpenApiV2_0_XTypes } from '~/openApi/2.0.x';
22-import type { OpenApiV3_0_XTypes } from '~/openApi/3.0.x';
33-import type { OpenApiV3_1_XTypes } from '~/openApi/3.1.x';
44-import type { DefinePlugin, Plugin } from '~/plugins';
11+import type {
22+ DefinePlugin,
33+ OpenApiV2_0_XTypes,
44+ OpenApiV3_0_XTypes,
55+ OpenApiV3_1_XTypes,
66+ Plugin,
77+} from '@hey-api/shared';
5869export type UserConfig = Plugin.Name<'@hey-api/schemas'> &
710 Plugin.Hooks & {
···11-import type { PluginContext } from '~/plugins/types';
11+import type { PluginContext } from '@hey-api/shared';
2233import type { UserConfig } from '../types';
44import type { ExamplesConfig } from './types';
···11-import type { FeatureToggle } from '~/config/shared';
22-import type { IR } from '~/ir/types';
33-import type { LinguistLanguages } from '~/openApi/shared/types';
11+import type { FeatureToggle, IR, LinguistLanguages } from '@hey-api/shared';
22+import type { MaybeFunc } from '@hey-api/types';
33+44import type { CallArgs, DollarTsDsl, ExampleOptions } from '~/ts-dsl';
55-import type { MaybeFunc } from '~/types/utils';
6576export type UserExamplesConfig = Omit<ExampleOptions, 'payload'> & {
87 /**
···11import { log } from '@hey-api/codegen-core';
22-33-import type { OperationsStrategy } from '~/openApi/shared/locations';
44-import type { PluginContext } from '~/plugins/types';
22+import type { OperationsStrategy, PluginContext } from '@hey-api/shared';
5364import type { UserConfig } from '../types';
75import type { OperationsConfig, UserOperationsConfig } from './types';
···11import type {
22 OperationPathStrategy,
33 OperationStructureStrategy,
44-} from '~/openApi/shared/locations';
55-import { OperationPath, OperationStrategy } from '~/openApi/shared/locations';
44+} from '@hey-api/shared';
55+import { OperationPath, OperationStrategy } from '@hey-api/shared';
6677import type { HeyApiSdkPlugin } from '../types';
88
···11-import type { Context } from '~/ir/context';
22-import type { IR } from '~/ir/types';
11+import type { Context, IR } from '@hey-api/shared';
3243import type { Auth } from '../../client-core/bundle/auth';
54import type { HeyApiSdkPlugin } from '../types';
···11-import type { IR } from '~/ir/types';
22-import type { PluginInstance } from '~/plugins/shared/utils/instance';
33-import { toCase } from '~/utils/naming';
44-import { refToName } from '~/utils/ref';
11+import type { IR, PluginInstance } from '@hey-api/shared';
22+import { refToName, toCase } from '@hey-api/shared';
5364import type { Field } from '../../client-core/bundle/params';
75
···11-import type { IR } from '~/ir/types';
11+import type { IR } from '@hey-api/shared';
22+23import type { $ } from '~/ts-dsl';
3445import type { HeyApiSdkPlugin } from '../types';
···11-import type { IndexExportOption } from '~/config/shared';
22-import type { OperationsStrategy } from '~/openApi/shared/locations';
33-import type { DefinePlugin, Plugin } from '~/plugins';
11+import type { IndexExportOption, NameTransformer } from '@hey-api/shared';
22+import type { DefinePlugin, Plugin } from '@hey-api/shared';
33+import type { OperationsStrategy } from '@hey-api/shared';
44+45import type { PluginClientNames, PluginValidatorNames } from '~/plugins/types';
55-import type { NameTransformer } from '~/utils/naming';
6677import type { ExamplesConfig, UserExamplesConfig } from './examples';
88import type { OperationsConfig, UserOperationsConfig } from './operations';
···11+import type { IR } from '@hey-api/shared';
12import type ts from 'typescript';
2333-import type { IR } from '~/ir/types';
44import { $ } from '~/ts-dsl';
5566import type { UserConfig } from './types';
···11import type { SymbolMeta } from '@hey-api/codegen-core';
22+import type { IR } from '@hey-api/shared';
33+import {
44+ applyNaming,
55+ createOperationKey,
66+ operationResponsesMap,
77+ refToName,
88+} from '@hey-api/shared';
29import type ts from 'typescript';
31044-import { createOperationKey, operationResponsesMap } from '~/ir/operation';
55-import type { IR } from '~/ir/types';
611import { $ } from '~/ts-dsl';
77-import { applyNaming } from '~/utils/naming';
88-import { refToName } from '~/utils/ref';
9121013import type { HeyApiTransformersPlugin } from './types';
1114
···11+import type { IndexExportOption } from '@hey-api/shared';
22+import type { IR } from '@hey-api/shared';
33+import type { DefinePlugin, Plugin } from '@hey-api/shared';
14import type ts from 'typescript';
22-33-import type { IndexExportOption } from '~/config/shared';
44-import type { IR } from '~/ir/types';
55-import type { DefinePlugin, Plugin } from '~/plugins';
6576import type { ExpressionTransformer } from './expressions';
87
···11-import { definePluginConfig } from '~/plugins/shared/utils/config';
11+import { definePluginConfig } from '@hey-api/shared';
2233import { Api } from './api';
44import { handler } from './plugin';
···11import { fromRef } from '@hey-api/codegen-core';
22+import type { IR } from '@hey-api/shared';
33+import { applyNaming, toCase } from '@hey-api/shared';
44+import { pathToJsonPointer, refToName } from '@hey-api/shared';
2533-import type { IR } from '~/ir/types';
46import { createSchemaComment } from '~/plugins/shared/utils/schema';
57import type { MaybeTsDsl, TypeTsDsl } from '~/ts-dsl';
68import { $, regexp } from '~/ts-dsl';
77-import { applyNaming, toCase } from '~/utils/naming';
88-import { pathToJsonPointer, refToName } from '~/utils/ref';
991010import type { HeyApiTypeScriptPlugin } from '../types';
1111import type { IrSchemaToAstOptions } from './types';
···11import { fromRef } from '@hey-api/codegen-core';
22+import type { IR } from '@hey-api/shared';
33+import { applyNaming } from '@hey-api/shared';
44+import { operationResponsesMap } from '@hey-api/shared';
55+import { deduplicateSchema } from '@hey-api/shared';
2633-import { operationResponsesMap } from '~/ir/operation';
44-import { deduplicateSchema } from '~/ir/schema';
55-import type { IR } from '~/ir/types';
67import { $ } from '~/ts-dsl';
77-import { applyNaming } from '~/utils/naming';
8899import { irSchemaToAst } from '../v1/plugin';
1010import type { IrSchemaToAstOptions } from './types';
···11import type { Symbol } from '@hey-api/codegen-core';
22import { fromRef } from '@hey-api/codegen-core';
33+import type { IR } from '@hey-api/shared';
44+import { applyNaming } from '@hey-api/shared';
3544-import type { IR } from '~/ir/types';
56import { createSchemaComment } from '~/plugins/shared/utils/schema';
67import { $ } from '~/ts-dsl';
77-import { applyNaming } from '~/utils/naming';
8899import { irSchemaToAst } from '../v1/plugin';
1010import type { IrSchemaToAstOptions } from './types';
···11import type {
22+ Casing,
23 FeatureToggle,
34 IndexExportOption,
55+ NameTransformer,
46 NamingOptions,
55-} from '~/config/shared';
66-import type { DefinePlugin, Plugin } from '~/plugins';
77-import type { Casing, NameTransformer } from '~/utils/naming';
77+} from '@hey-api/shared';
88+import type { DefinePlugin, Plugin } from '@hey-api/shared';
89910import type { IApi } from './api';
1011
···11import type { Symbol } from '@hey-api/codegen-core';
22import { refs } from '@hey-api/codegen-core';
33+import type { IR } from '@hey-api/shared';
44+import type { SchemaWithType } from '@hey-api/shared';
55+import { applyNaming } from '@hey-api/shared';
66+import { deduplicateSchema } from '@hey-api/shared';
3744-import { deduplicateSchema } from '~/ir/schema';
55-import type { IR } from '~/ir/types';
66-import type { SchemaWithType } from '~/plugins';
78import type { MaybeTsDsl, TypeTsDsl } from '~/ts-dsl';
89import { $ } from '~/ts-dsl';
99-import { applyNaming } from '~/utils/naming';
10101111import { createClientOptions } from '../shared/clientOptions';
1212import { exportType } from '../shared/export';
···11import { fromRef, ref } from '@hey-api/codegen-core';
22+import type { SchemaWithType } from '@hey-api/shared';
33+import { deduplicateSchema } from '@hey-api/shared';
2433-import { deduplicateSchema } from '~/ir/schema';
44-import type { SchemaWithType } from '~/plugins';
55import type { MaybeTsDsl, TypeTsDsl } from '~/ts-dsl';
66import { $ } from '~/ts-dsl';
77
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import type { TypeTsDsl } from '~/ts-dsl';
34import { $ } from '~/ts-dsl';
45
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import type { MaybeTsDsl, TypeTsDsl } from '~/ts-dsl';
3445import type { IrSchemaToAstOptions } from '../../shared/types';
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import type { MaybeTsDsl, TypeTsDsl } from '~/ts-dsl';
3445import type { IrSchemaToAstOptions } from '../../shared/types';
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import type { TypeTsDsl } from '~/ts-dsl';
34import { $ } from '~/ts-dsl';
45
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import type { TypeTsDsl } from '~/ts-dsl';
34import { $ } from '~/ts-dsl';
45
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import type { TypeTsDsl } from '~/ts-dsl';
34import { $ } from '~/ts-dsl';
45
···11import { fromRef, ref } from '@hey-api/codegen-core';
22+import type { IR } from '@hey-api/shared';
33+import type { SchemaWithType } from '@hey-api/shared';
2433-import type { IR } from '~/ir/types';
44-import type { SchemaWithType } from '~/plugins';
55import { createSchemaComment } from '~/plugins/shared/utils/schema';
66import type { TypeTsDsl } from '~/ts-dsl';
77import { $ } from '~/ts-dsl';
···11import type { SymbolMeta } from '@hey-api/codegen-core';
22+import type { SchemaWithType } from '@hey-api/shared';
33+import { toCase } from '@hey-api/shared';
2433-import type { SchemaWithType } from '~/plugins';
45import type { TypeTsDsl } from '~/ts-dsl';
56import { $ } from '~/ts-dsl';
66-import { toCase } from '~/utils/naming';
7788import type { IrSchemaToAstOptions } from '../../shared/types';
99
···11import { fromRef, ref } from '@hey-api/codegen-core';
22+import type { SchemaWithType } from '@hey-api/shared';
2333-import type { SchemaWithType } from '~/plugins';
44import type { MaybeTsDsl, TypeTsDsl } from '~/ts-dsl';
55import { $ } from '~/ts-dsl';
66
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import type { TypeTsDsl } from '~/ts-dsl';
34import { $ } from '~/ts-dsl';
45
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import type { TypeTsDsl } from '~/ts-dsl';
34import { $ } from '~/ts-dsl';
45
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import type { TypeTsDsl } from '~/ts-dsl';
34import { $ } from '~/ts-dsl';
45
···11-import { definePluginConfig } from '~/plugins/shared/utils/config';
11+import { definePluginConfig } from '@hey-api/shared';
2233import { handler } from './plugin';
44import type { PiniaColadaPlugin } from './types';
···11-import type { IR } from '~/ir/types';
11+import type { IR } from '@hey-api/shared';
22+23import { $ } from '~/ts-dsl';
3445import type { PiniaColadaPlugin } from './types';
···11import type {
22+ Casing,
23 FeatureToggle,
34 IndexExportOption,
55+ NameTransformer,
46 NamingOptions,
55-} from '~/config/shared';
66-import type { IR } from '~/ir/types';
77-import type { DefinePlugin, Plugin } from '~/plugins';
88-import type { Casing, NameTransformer } from '~/utils/naming';
77+} from '@hey-api/shared';
88+import type { IR } from '@hey-api/shared';
99+import type { DefinePlugin, Plugin } from '@hey-api/shared';
9101011export type UserConfig = Plugin.Name<'@pinia/colada'> &
1112 Plugin.Hooks & {
···11-import type { IR } from '~/ir/types';
11+import type { IR } from '@hey-api/shared';
22+23import { $ } from '~/ts-dsl';
3445import type { PiniaColadaPlugin } from './types';
···11import type {
22+ Casing,
23 FeatureToggle,
34 IndexExportOption,
55+ NameTransformer,
46 NamingOptions,
55-} from '~/config/shared';
66-import type { IR } from '~/ir/types';
77-import type { DefinePlugin, Plugin } from '~/plugins';
88-import type { Casing, NameTransformer } from '~/utils/naming';
77+} from '@hey-api/shared';
88+import type { IR } from '@hey-api/shared';
99+import type { DefinePlugin, Plugin } from '@hey-api/shared';
9101011export type UserConfig = Plugin.Name<'@tanstack/angular-query-experimental'> &
1112 Plugin.Hooks & {
···11-import type { IR } from '~/ir/types';
11+import type { IR } from '@hey-api/shared';
22+23import { $ } from '~/ts-dsl';
3445import type { PluginInstance } from '../types';
···11import { ref } from '@hey-api/codegen-core';
22+import type { IR } from '@hey-api/shared';
33+import { applyNaming, operationPagination } from '@hey-api/shared';
2433-import { operationPagination } from '~/ir/operation';
44-import type { IR } from '~/ir/types';
55import {
66 createOperationComment,
77 isOperationOptionsRequired,
88} from '~/plugins/shared/utils/operation';
99import type { TsDsl } from '~/ts-dsl';
1010import { $ } from '~/ts-dsl';
1111-import { applyNaming } from '~/utils/naming';
12111312import {
1413 createQueryKeyFunction,
···11-import type { IR } from '~/ir/types';
11+import type { IR } from '@hey-api/shared';
22+import { applyNaming } from '@hey-api/shared';
33+24import { createOperationComment } from '~/plugins/shared/utils/operation';
35import type { TsDsl } from '~/ts-dsl';
46import { $ } from '~/ts-dsl';
55-import { applyNaming } from '~/utils/naming';
6778import { handleMeta } from '../shared/meta';
89import { useTypeData, useTypeError, useTypeResponse } from '../shared/useType';
···11-import type { IR } from '~/ir/types';
11+import type { IR } from '@hey-api/shared';
22+import { applyNaming } from '@hey-api/shared';
33+24import {
35 createOperationComment,
46 hasOperationSse,
···68} from '~/plugins/shared/utils/operation';
79import type { TsDsl } from '~/ts-dsl';
810import { $ } from '~/ts-dsl';
99-import { applyNaming } from '~/utils/naming';
10111112import {
1213 createQueryKeyFunction,
···11-import type { IR } from '~/ir/types';
11+import type { IR } from '@hey-api/shared';
22+import { applyNaming } from '@hey-api/shared';
33+24import {
35 createOperationComment,
46 hasOperationSse,
57 isOperationOptionsRequired,
68} from '~/plugins/shared/utils/operation';
79import { $ } from '~/ts-dsl';
88-import { applyNaming } from '~/utils/naming';
9101011import { useTypeData } from '../shared/useType';
1112import type { PluginInstance } from '../types';
···11import type {
22+ Casing,
23 FeatureToggle,
34 IndexExportOption,
55+ NameTransformer,
46 NamingOptions,
55-} from '~/config/shared';
66-import type { IR } from '~/ir/types';
77-import type { DefinePlugin, Plugin } from '~/plugins';
88-import type { Casing, NameTransformer } from '~/utils/naming';
77+} from '@hey-api/shared';
88+import type { IR } from '@hey-api/shared';
99+import type { DefinePlugin, Plugin } from '@hey-api/shared';
9101011export type UserConfig = Plugin.Name<'@tanstack/react-query'> &
1112 Plugin.Hooks & {
···11import type {
22+ Casing,
23 FeatureToggle,
34 IndexExportOption,
55+ NameTransformer,
46 NamingOptions,
55-} from '~/config/shared';
66-import type { IR } from '~/ir/types';
77-import type { DefinePlugin, Plugin } from '~/plugins';
88-import type { Casing, NameTransformer } from '~/utils/naming';
77+} from '@hey-api/shared';
88+import type { IR } from '@hey-api/shared';
99+import type { DefinePlugin, Plugin } from '@hey-api/shared';
9101011export type UserConfig = Plugin.Name<'@tanstack/solid-query'> &
1112 Plugin.Hooks & {
···11import type {
22+ Casing,
23 FeatureToggle,
34 IndexExportOption,
55+ NameTransformer,
46 NamingOptions,
55-} from '~/config/shared';
66-import type { IR } from '~/ir/types';
77-import type { DefinePlugin, Plugin } from '~/plugins';
88-import type { Casing, NameTransformer } from '~/utils/naming';
77+} from '@hey-api/shared';
88+import type { IR } from '@hey-api/shared';
99+import type { DefinePlugin, Plugin } from '@hey-api/shared';
9101011export type UserConfig = Plugin.Name<'@tanstack/svelte-query'> &
1112 Plugin.Hooks & {
···11import type {
22+ Casing,
23 FeatureToggle,
34 IndexExportOption,
55+ NameTransformer,
46 NamingOptions,
55-} from '~/config/shared';
66-import type { IR } from '~/ir/types';
77-import type { DefinePlugin, Plugin } from '~/plugins';
88-import type { Casing, NameTransformer } from '~/utils/naming';
77+} from '@hey-api/shared';
88+import type { IR } from '@hey-api/shared';
99+import type { DefinePlugin, Plugin } from '@hey-api/shared';
9101011export type UserConfig = Plugin.Name<'@tanstack/vue-query'> &
1112 Plugin.Hooks & {
+1-1
packages/openapi-ts/src/plugins/arktype/config.ts
···11-import { definePluginConfig, mappers } from '~/plugins/shared/utils/config';
11+import { definePluginConfig, mappers } from '@hey-api/shared';
2233import { Api } from './api';
44import { handler } from './plugin';
···11import type { Symbol } from '@hey-api/codegen-core';
22+import type { IR } from '@hey-api/shared';
2333-import type { IR } from '~/ir/types';
44import { createSchemaComment } from '~/plugins/shared/utils/schema';
55import { $ } from '~/ts-dsl';
66
···11import type { Refs, SymbolMeta } from '@hey-api/codegen-core';
22+import type { IR } from '@hey-api/shared';
23import type ts from 'typescript';
3444-import type { IR } from '~/ir/types';
55import type { $ } from '~/ts-dsl';
6677import type { ArktypePlugin } from '../types';
···11import type {
22+ Casing,
23 FeatureToggle,
34 IndexExportOption,
55+ NameTransformer,
46 NamingOptions,
55-} from '~/config/shared';
66-import type { DefinePlugin, Plugin } from '~/plugins';
77-import type { Casing, NameTransformer } from '~/utils/naming';
77+} from '@hey-api/shared';
88+import type { DefinePlugin, Plugin } from '@hey-api/shared';
89910import type { IApi } from './api';
1011
···11import type { SymbolMeta } from '@hey-api/codegen-core';
22import { fromRef, refs } from '@hey-api/codegen-core';
33+import type { IR } from '@hey-api/shared';
44+import { applyNaming } from '@hey-api/shared';
55+import { deduplicateSchema } from '@hey-api/shared';
66+import { pathToJsonPointer, refToName } from '@hey-api/shared';
3744-import { deduplicateSchema } from '~/ir/schema';
55-import type { IR } from '~/ir/types';
66-import type { SchemaWithType } from '~/plugins/shared/types/schema';
88+import type { SchemaWithType } from '~/plugins';
79import { $ } from '~/ts-dsl';
88-import { applyNaming } from '~/utils/naming';
99-import { pathToJsonPointer, refToName } from '~/utils/ref';
10101111import { exportAst } from '../shared/export';
1212import type { Ast, IrSchemaToAstOptions, PluginState } from '../shared/types';
···11-import type { SchemaWithType } from '~/plugins/shared/types/schema';
11+import type { SchemaWithType } from '~/plugins';
22import { $ } from '~/ts-dsl';
3344import type { Ast, IrSchemaToAstOptions } from '../../shared/types';
···11-import type { SchemaWithType } from '~/plugins/shared/types/schema';
11+import type { SchemaWithType } from '~/plugins';
2233import { identifiers } from '../../constants';
44import type { Ast, IrSchemaToAstOptions } from '../../shared/types';
···11import { fromRef, ref } from '@hey-api/codegen-core';
2233-import type { SchemaWithType } from '~/plugins/shared/types/schema';
33+import type { SchemaWithType } from '~/plugins';
44import { $ } from '~/ts-dsl';
5566// import { identifiers } from '../../constants';
···11-import type { SchemaWithType } from '~/plugins/shared/types/schema';
11+import type { SchemaWithType } from '~/plugins';
2233import { identifiers } from '../../constants';
44import type { Ast, IrSchemaToAstOptions } from '../../shared/types';
+2-53
packages/openapi-ts/src/plugins/config.ts
···11-import type { Plugin } from '~/plugins';
22-import type { AngularCommonPlugin } from '~/plugins/@angular/common';
11+import type { Plugin, PluginConfigMap, PluginNames } from '@hey-api/shared';
22+33import { defaultConfig as angularCommon } from '~/plugins/@angular/common';
44-import type { FakerJsFakerPlugin } from '~/plugins/@faker-js/faker';
54import { defaultConfig as fakerJsFaker } from '~/plugins/@faker-js/faker';
66-import type { HeyApiClientAngularPlugin } from '~/plugins/@hey-api/client-angular';
75import { defaultConfig as heyApiClientAngular } from '~/plugins/@hey-api/client-angular';
88-import type { HeyApiClientAxiosPlugin } from '~/plugins/@hey-api/client-axios';
96import { defaultConfig as heyApiClientAxios } from '~/plugins/@hey-api/client-axios';
1010-import type { HeyApiClientFetchPlugin } from '~/plugins/@hey-api/client-fetch';
117import { defaultConfig as heyApiClientFetch } from '~/plugins/@hey-api/client-fetch';
1212-import type { HeyApiClientKyPlugin } from '~/plugins/@hey-api/client-ky';
138import { defaultConfig as heyApiClientKy } from '~/plugins/@hey-api/client-ky';
1414-import type { HeyApiClientNextPlugin } from '~/plugins/@hey-api/client-next';
159import { defaultConfig as heyApiClientNext } from '~/plugins/@hey-api/client-next';
1616-import type { HeyApiClientNuxtPlugin } from '~/plugins/@hey-api/client-nuxt';
1710import { defaultConfig as heyApiClientNuxt } from '~/plugins/@hey-api/client-nuxt';
1818-import type { HeyApiClientOfetchPlugin } from '~/plugins/@hey-api/client-ofetch';
1911import { defaultConfig as heyApiClientOfetch } from '~/plugins/@hey-api/client-ofetch';
2020-import type { HeyApiSchemasPlugin } from '~/plugins/@hey-api/schemas';
2112import { defaultConfig as heyApiSchemas } from '~/plugins/@hey-api/schemas';
2222-import type { HeyApiSdkPlugin } from '~/plugins/@hey-api/sdk';
2313import { defaultConfig as heyApiSdk } from '~/plugins/@hey-api/sdk';
2424-import type { HeyApiTransformersPlugin } from '~/plugins/@hey-api/transformers';
2514import { defaultConfig as heyApiTransformers } from '~/plugins/@hey-api/transformers';
2626-import type { HeyApiTypeScriptPlugin } from '~/plugins/@hey-api/typescript';
2715import { defaultConfig as heyApiTypeScript } from '~/plugins/@hey-api/typescript';
2828-import type { PiniaColadaPlugin } from '~/plugins/@pinia/colada';
2916import { defaultConfig as piniaColada } from '~/plugins/@pinia/colada';
3030-import type { TanStackAngularQueryPlugin } from '~/plugins/@tanstack/angular-query-experimental';
3117import { defaultConfig as tanStackAngularQuery } from '~/plugins/@tanstack/angular-query-experimental';
3232-import type { TanStackReactQueryPlugin } from '~/plugins/@tanstack/react-query';
3318import { defaultConfig as tanStackReactQuery } from '~/plugins/@tanstack/react-query';
3434-import type { TanStackSolidQueryPlugin } from '~/plugins/@tanstack/solid-query';
3519import { defaultConfig as tanStackSolidQuery } from '~/plugins/@tanstack/solid-query';
3636-import type { TanStackSvelteQueryPlugin } from '~/plugins/@tanstack/svelte-query';
3720import { defaultConfig as tanStackSvelteQuery } from '~/plugins/@tanstack/svelte-query';
3838-import type { TanStackVueQueryPlugin } from '~/plugins/@tanstack/vue-query';
3921import { defaultConfig as tanStackVueQuery } from '~/plugins/@tanstack/vue-query';
4040-import type { ArktypePlugin } from '~/plugins/arktype';
4122import { defaultConfig as arktype } from '~/plugins/arktype';
4242-import type { FastifyPlugin } from '~/plugins/fastify';
4323import { defaultConfig as fastify } from '~/plugins/fastify';
4444-import type { SwrPlugin } from '~/plugins/swr';
4524import { defaultConfig as swr } from '~/plugins/swr';
4646-import type { PluginNames } from '~/plugins/types';
4747-import type { ValibotPlugin } from '~/plugins/valibot';
4825import { defaultConfig as valibot } from '~/plugins/valibot';
4949-import type { ZodPlugin } from '~/plugins/zod';
5026import { defaultConfig as zod } from '~/plugins/zod';
5151-5252-export interface PluginConfigMap {
5353- '@angular/common': AngularCommonPlugin['Types'];
5454- '@faker-js/faker': FakerJsFakerPlugin['Types'];
5555- '@hey-api/client-angular': HeyApiClientAngularPlugin['Types'];
5656- '@hey-api/client-axios': HeyApiClientAxiosPlugin['Types'];
5757- '@hey-api/client-fetch': HeyApiClientFetchPlugin['Types'];
5858- '@hey-api/client-ky': HeyApiClientKyPlugin['Types'];
5959- '@hey-api/client-next': HeyApiClientNextPlugin['Types'];
6060- '@hey-api/client-nuxt': HeyApiClientNuxtPlugin['Types'];
6161- '@hey-api/client-ofetch': HeyApiClientOfetchPlugin['Types'];
6262- '@hey-api/schemas': HeyApiSchemasPlugin['Types'];
6363- '@hey-api/sdk': HeyApiSdkPlugin['Types'];
6464- '@hey-api/transformers': HeyApiTransformersPlugin['Types'];
6565- '@hey-api/typescript': HeyApiTypeScriptPlugin['Types'];
6666- '@pinia/colada': PiniaColadaPlugin['Types'];
6767- '@tanstack/angular-query-experimental': TanStackAngularQueryPlugin['Types'];
6868- '@tanstack/react-query': TanStackReactQueryPlugin['Types'];
6969- '@tanstack/solid-query': TanStackSolidQueryPlugin['Types'];
7070- '@tanstack/svelte-query': TanStackSvelteQueryPlugin['Types'];
7171- '@tanstack/vue-query': TanStackVueQueryPlugin['Types'];
7272- arktype: ArktypePlugin['Types'];
7373- fastify: FastifyPlugin['Types'];
7474- swr: SwrPlugin['Types'];
7575- valibot: ValibotPlugin['Types'];
7676- zod: ZodPlugin['Types'];
7777-}
78277928export const defaultPluginConfigs: {
8029 [K in PluginNames]: Plugin.Config<PluginConfigMap[K]>;
+1-1
packages/openapi-ts/src/plugins/fastify/config.ts
···11-import { definePluginConfig } from '~/plugins/shared/utils/config';
11+import { definePluginConfig } from '@hey-api/shared';
2233import { handler } from './plugin';
44import type { FastifyPlugin } from './types';
+6-3
packages/openapi-ts/src/plugins/fastify/plugin.ts
···11-import { operationResponsesMap } from '~/ir/operation';
22-import { hasParameterGroupObjectRequired } from '~/ir/parameter';
33-import type { IR } from '~/ir/types';
11+import type { IR } from '@hey-api/shared';
22+import {
33+ hasParameterGroupObjectRequired,
44+ operationResponsesMap,
55+} from '@hey-api/shared';
66+47import { $ } from '~/ts-dsl';
5869import type { FastifyPlugin } from './types';
···11-import type { DefinePlugin, Plugin } from '~/plugins';
11+import type { DefinePlugin, Plugin } from '@hey-api/shared';
2233export type UserConfig = Plugin.Name<'fastify'> &
44 Plugin.Hooks & {
+1-2
packages/openapi-ts/src/plugins/index.ts
···11-export type { SchemaWithType } from './shared/types/schema';
22-export type { DefinePlugin, Plugin } from './types';
11+export type { DefinePlugin, Plugin, SchemaWithType } from '@hey-api/shared';
···11-import type { IrTopLevelKind } from '~/ir/graph';
22-import type { IR } from '~/ir/types';
11+import type { IrTopLevelKind } from '../../../ir/graph';
22+import type { IR } from '../../../ir/types';
3344export type BaseEvent = {
55 /**
···11-import type { IR } from '~/ir/types';
22-import { escapeComment } from '~/utils/escape';
11+import { escapeComment, type IR } from '@hey-api/shared';
3243export const createSchemaComment = (
54 schema: IR.SchemaObject,
+1-1
packages/openapi-ts/src/plugins/swr/config.ts
···11-import { definePluginConfig } from '~/plugins/shared/utils/config';
11+import { definePluginConfig } from '@hey-api/shared';
2233import { handler } from './plugin';
44import type { SwrPlugin } from './types';
···11import type {
22+ Casing,
23 FeatureToggle,
34 IndexExportOption,
55+ NameTransformer,
46 NamingOptions,
55-} from '~/config/shared';
66-import type { IR } from '~/ir/types';
77-import type { DefinePlugin, Plugin } from '~/plugins';
88-import type { Casing, NameTransformer } from '~/utils/naming';
77+} from '@hey-api/shared';
88+import type { IR } from '@hey-api/shared';
99+import type { DefinePlugin, Plugin } from '@hey-api/shared';
9101011export type UserConfig = Plugin.Name<'swr'> &
1112 Plugin.Hooks & {
+3-2
packages/openapi-ts/src/plugins/swr/v2/useSwr.ts
···11-import type { IR } from '~/ir/types';
11+import type { IR } from '@hey-api/shared';
22+import { applyNaming } from '@hey-api/shared';
33+24import {
35 createOperationComment,
46 hasOperationSse,
57} from '~/plugins/shared/utils/operation';
68import type { TsDsl } from '~/ts-dsl';
79import { $ } from '~/ts-dsl';
88-import { applyNaming } from '~/utils/naming';
9101011import type { SwrPlugin } from '../types';
1112
···11-import { definePluginConfig } from '~/plugins/shared/utils/config';
11+import { definePluginConfig } from '@hey-api/shared';
2233import { Api } from './api';
44import { handler } from './plugin';
···11import type { Refs, Symbol } from '@hey-api/codegen-core';
22+import type { IR } from '@hey-api/shared';
2333-import type { IR } from '~/ir/types';
44import type { Plugin, SchemaWithType } from '~/plugins';
55import type {
66 MaybeBigInt,
···204204}
205205206206export interface ValidatorResolverContext extends BaseContext {
207207- operation: IR.Operation;
207207+ operation: IR.OperationObject;
208208 /**
209209 * Provides access to commonly used symbols within the plugin.
210210 */
···11import type { Symbol } from '@hey-api/codegen-core';
22+import type { IR } from '@hey-api/shared';
2333-import type { IR } from '~/ir/types';
44import { createSchemaComment } from '~/plugins/shared/utils/schema';
55import { $ } from '~/ts-dsl';
66
···11import { fromRef } from '@hey-api/codegen-core';
22-33-import { operationResponsesMap } from '~/ir/operation';
44-import type { IR } from '~/ir/types';
55-import { applyNaming } from '~/utils/naming';
22+import type { IR } from '@hey-api/shared';
33+import { applyNaming } from '@hey-api/shared';
44+import { operationResponsesMap } from '@hey-api/shared';
6576import { exportAst } from './export';
87import type { Ast, IrSchemaToAstOptions } from './types';
···11import type { Refs, SymbolMeta } from '@hey-api/codegen-core';
22+import type { IR } from '@hey-api/shared';
23import type ts from 'typescript';
33-44-import type { IR } from '~/ir/types';
5465import type { ValibotPlugin } from '../types';
76import type { Pipes } from './pipes';
···11import { fromRef } from '@hey-api/codegen-core';
22-33-import type { IR } from '~/ir/types';
44-import { applyNaming } from '~/utils/naming';
22+import type { IR } from '@hey-api/shared';
33+import { applyNaming } from '@hey-api/shared';
5465import { exportAst } from './export';
76import type { Ast, IrSchemaToAstOptions } from './types';
···11import type {
22+ Casing,
23 FeatureToggle,
34 IndexExportOption,
55+ NameTransformer,
46 NamingOptions,
55-} from '~/config/shared';
66-import type { DefinePlugin, Plugin } from '~/plugins';
77-import type { Casing, NameTransformer } from '~/utils/naming';
77+} from '@hey-api/shared';
88+import type { DefinePlugin, Plugin } from '@hey-api/shared';
89910import type { IApi } from './api';
1011import type { Resolvers } from './resolvers';
···11import type { SymbolMeta } from '@hey-api/codegen-core';
22import { fromRef, ref, refs } from '@hey-api/codegen-core';
33+import type { IR, SchemaWithType } from '@hey-api/shared';
44+import {
55+ applyNaming,
66+ deduplicateSchema,
77+ pathToJsonPointer,
88+ refToName,
99+} from '@hey-api/shared';
31044-import { deduplicateSchema } from '~/ir/schema';
55-import type { IR } from '~/ir/types';
66-import type { SchemaWithType } from '~/plugins';
711import { maybeBigInt } from '~/plugins/shared/utils/coerce';
812import { $ } from '~/ts-dsl';
99-import { applyNaming } from '~/utils/naming';
1010-import { pathToJsonPointer, refToName } from '~/utils/ref';
11131214import { exportAst } from '../shared/export';
1315import { irOperationToAst } from '../shared/operation';
···11import { fromRef, ref } from '@hey-api/codegen-core';
22+import type { SchemaWithType } from '@hey-api/shared';
33+import { deduplicateSchema } from '@hey-api/shared';
2433-import { deduplicateSchema } from '~/ir/schema';
44-import type { SchemaWithType } from '~/plugins';
55import { $ } from '~/ts-dsl';
6677import { pipesToNode } from '../../shared/pipes';
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import { $ } from '~/ts-dsl';
3445import { pipesToNode } from '../../shared/pipes';
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import { $ } from '~/ts-dsl';
3445import type { EnumResolverContext } from '../../resolvers';
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import { shouldCoerceToBigInt } from '~/plugins/shared/utils/coerce';
34import type { $ } from '~/ts-dsl';
45
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import { $ } from '~/ts-dsl';
3445import type { IrSchemaToAstOptions } from '../../shared/types';
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import { $ } from '~/ts-dsl';
3445import type { IrSchemaToAstOptions } from '../../shared/types';
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import {
34 maybeBigInt,
45 shouldCoerceToBigInt,
···11import { fromRef, ref } from '@hey-api/codegen-core';
22+import type { SchemaWithType } from '@hey-api/shared';
2333-import type { SchemaWithType } from '~/plugins';
44import { $ } from '~/ts-dsl';
5566import type { ObjectResolverContext } from '../../resolvers';
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import { $ } from '~/ts-dsl';
3445import type { StringResolverContext } from '../../resolvers';
···11import { fromRef, ref } from '@hey-api/codegen-core';
22+import type { SchemaWithType } from '@hey-api/shared';
2333-import type { SchemaWithType } from '~/plugins';
44import { $ } from '~/ts-dsl';
5566import { pipesToNode } from '../../shared/pipes';
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import { $ } from '~/ts-dsl';
3445import type { IrSchemaToAstOptions } from '../../shared/types';
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import { $ } from '~/ts-dsl';
3445import type { IrSchemaToAstOptions } from '../../shared/types';
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import { $ } from '~/ts-dsl';
3445import type { IrSchemaToAstOptions } from '../../shared/types';
+1-2
packages/openapi-ts/src/plugins/zod/config.ts
···11+import { definePluginConfig, mappers } from '@hey-api/shared';
12import colors from 'ansi-colors';
22-33-import { definePluginConfig, mappers } from '~/plugins/shared/utils/config';
4354import { Api } from './api';
65import { handler } from './plugin';
···11import type { SymbolMeta } from '@hey-api/codegen-core';
22import { fromRef, ref, refs } from '@hey-api/codegen-core';
33+import type { IR } from '@hey-api/shared';
44+import type { SchemaWithType } from '@hey-api/shared';
55+import { applyNaming } from '@hey-api/shared';
66+import { deduplicateSchema } from '@hey-api/shared';
77+import { pathToJsonPointer, refToName } from '@hey-api/shared';
3844-import { deduplicateSchema } from '~/ir/schema';
55-import type { IR } from '~/ir/types';
66-import type { SchemaWithType } from '~/plugins';
79import { maybeBigInt } from '~/plugins/shared/utils/coerce';
810import { $ } from '~/ts-dsl';
99-import { applyNaming } from '~/utils/naming';
1010-import { pathToJsonPointer, refToName } from '~/utils/ref';
11111212import { identifiers } from '../constants';
1313import { exportAst } from '../shared/export';
···11import { fromRef, ref } from '@hey-api/codegen-core';
22+import type { SchemaWithType } from '@hey-api/shared';
33+import { deduplicateSchema } from '@hey-api/shared';
2433-import { deduplicateSchema } from '~/ir/schema';
44-import type { SchemaWithType } from '~/plugins';
55import { $ } from '~/ts-dsl';
6677import { identifiers } from '../../constants';
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import { $ } from '~/ts-dsl';
3445import { identifiers } from '../../constants';
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import { $ } from '~/ts-dsl';
3445import { identifiers } from '../../constants';
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import { shouldCoerceToBigInt } from '~/plugins/shared/utils/coerce';
3445import type { Ast, IrSchemaToAstOptions } from '../../shared/types';
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import { $ } from '~/ts-dsl';
3445import { identifiers } from '../../constants';
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import { $ } from '~/ts-dsl';
3445import { identifiers } from '../../constants';
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import {
34 maybeBigInt,
45 shouldCoerceToBigInt,
···11import { fromRef, ref } from '@hey-api/codegen-core';
22+import type { SchemaWithType } from '@hey-api/shared';
2333-import type { SchemaWithType } from '~/plugins';
44import { $ } from '~/ts-dsl';
5566import { identifiers } from '../../constants';
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import { $ } from '~/ts-dsl';
3445import { identifiers } from '../../constants';
···11import { fromRef, ref } from '@hey-api/codegen-core';
22+import type { SchemaWithType } from '@hey-api/shared';
2333-import type { SchemaWithType } from '~/plugins';
44import { $ } from '~/ts-dsl';
5566import { identifiers } from '../../constants';
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import { $ } from '~/ts-dsl';
3445import { identifiers } from '../../constants';
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import { $ } from '~/ts-dsl';
3445import { identifiers } from '../../constants';
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import { $ } from '~/ts-dsl';
3445import { identifiers } from '../../constants';
···11import type { Refs, Symbol } from '@hey-api/codegen-core';
22+import type { IR } from '@hey-api/shared';
23import type { MaybeArray } from '@hey-api/types';
34import type ts from 'typescript';
4555-import type { IR } from '~/ir/types';
66import type { Plugin, SchemaWithType } from '~/plugins';
77import type {
88 MaybeBigInt,
···217217}
218218219219export interface ValidatorResolverContext extends BaseContext {
220220- operation: IR.Operation;
220220+ operation: IR.OperationObject;
221221 /**
222222 * Provides access to commonly used symbols within the plugin.
223223 */
···11import type { Symbol } from '@hey-api/codegen-core';
22+import type { IR } from '@hey-api/shared';
2333-import type { IR } from '~/ir/types';
44import { createSchemaComment } from '~/plugins/shared/utils/schema';
55import { $ } from '~/ts-dsl';
66
···11import { fromRef } from '@hey-api/codegen-core';
22-33-import { operationResponsesMap } from '~/ir/operation';
44-import type { IR } from '~/ir/types';
55-import { applyNaming } from '~/utils/naming';
22+import type { IR } from '@hey-api/shared';
33+import { applyNaming } from '@hey-api/shared';
44+import { operationResponsesMap } from '@hey-api/shared';
6576import { exportAst } from './export';
87import type { Ast, IrSchemaToAstOptions } from './types';
···11import type { Refs, SymbolMeta } from '@hey-api/codegen-core';
22+import type { IR } from '@hey-api/shared';
23import type ts from 'typescript';
3444-import type { IR } from '~/ir/types';
55import type { $ } from '~/ts-dsl';
6677import type { ZodPlugin } from '../types';
···11import { fromRef } from '@hey-api/codegen-core';
22-33-import type { IR } from '~/ir/types';
44-import { applyNaming } from '~/utils/naming';
22+import type { IR } from '@hey-api/shared';
33+import { applyNaming } from '@hey-api/shared';
5465import { exportAst } from './export';
76import type { Ast, IrSchemaToAstOptions } from './types';
···11import type {
22+ Casing,
23 FeatureToggle,
34 IndexExportOption,
55+ NameTransformer,
46 NamingOptions,
55-} from '~/config/shared';
66-import type { DefinePlugin, Plugin } from '~/plugins';
77-import type { Casing, NameTransformer } from '~/utils/naming';
77+} from '@hey-api/shared';
88+import type { DefinePlugin, Plugin } from '@hey-api/shared';
89910import type { IApi } from './api';
1011import type { Resolvers } from './resolvers';
+5-5
packages/openapi-ts/src/plugins/zod/v3/plugin.ts
···11import type { SymbolMeta } from '@hey-api/codegen-core';
22import { fromRef, ref, refs } from '@hey-api/codegen-core';
33+import type { IR } from '@hey-api/shared';
44+import type { SchemaWithType } from '@hey-api/shared';
55+import { applyNaming } from '@hey-api/shared';
66+import { deduplicateSchema } from '@hey-api/shared';
77+import { pathToJsonPointer, refToName } from '@hey-api/shared';
3844-import { deduplicateSchema } from '~/ir/schema';
55-import type { IR } from '~/ir/types';
66-import type { SchemaWithType } from '~/plugins';
79import { maybeBigInt } from '~/plugins/shared/utils/coerce';
810import { $ } from '~/ts-dsl';
99-import { applyNaming } from '~/utils/naming';
1010-import { pathToJsonPointer, refToName } from '~/utils/ref';
11111212import { identifiers } from '../constants';
1313import { exportAst } from '../shared/export';
···11import { fromRef, ref } from '@hey-api/codegen-core';
22+import type { SchemaWithType } from '@hey-api/shared';
33+import { deduplicateSchema } from '@hey-api/shared';
2433-import { deduplicateSchema } from '~/ir/schema';
44-import type { SchemaWithType } from '~/plugins';
55import { $ } from '~/ts-dsl';
6677import { identifiers } from '../../constants';
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import { $ } from '~/ts-dsl';
3445import { identifiers } from '../../constants';
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import { $ } from '~/ts-dsl';
3445import { identifiers } from '../../constants';
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import { shouldCoerceToBigInt } from '~/plugins/shared/utils/coerce';
3445import type { Ast, IrSchemaToAstOptions } from '../../shared/types';
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import { $ } from '~/ts-dsl';
3445import { identifiers } from '../../constants';
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import { $ } from '~/ts-dsl';
3445import { identifiers } from '../../constants';
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import {
34 maybeBigInt,
45 shouldCoerceToBigInt,
···11import { fromRef, ref } from '@hey-api/codegen-core';
22+import type { SchemaWithType } from '@hey-api/shared';
2333-import type { SchemaWithType } from '~/plugins';
44import { $ } from '~/ts-dsl';
5566import { identifiers } from '../../constants';
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import { $ } from '~/ts-dsl';
3445import { identifiers } from '../../constants';
···11import { fromRef, ref } from '@hey-api/codegen-core';
22+import type { SchemaWithType } from '@hey-api/shared';
2333-import type { SchemaWithType } from '~/plugins';
44import { $ } from '~/ts-dsl';
5566import { identifiers } from '../../constants';
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import { $ } from '~/ts-dsl';
3445import { identifiers } from '../../constants';
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import { $ } from '~/ts-dsl';
3445import { identifiers } from '../../constants';
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import { $ } from '~/ts-dsl';
3445import { identifiers } from '../../constants';
+5-5
packages/openapi-ts/src/plugins/zod/v4/plugin.ts
···11import type { SymbolMeta } from '@hey-api/codegen-core';
22import { fromRef, ref, refs } from '@hey-api/codegen-core';
33+import type { IR } from '@hey-api/shared';
44+import type { SchemaWithType } from '@hey-api/shared';
55+import { applyNaming } from '@hey-api/shared';
66+import { deduplicateSchema } from '@hey-api/shared';
77+import { pathToJsonPointer, refToName } from '@hey-api/shared';
3844-import { deduplicateSchema } from '~/ir/schema';
55-import type { IR } from '~/ir/types';
66-import type { SchemaWithType } from '~/plugins';
79import { maybeBigInt } from '~/plugins/shared/utils/coerce';
810import { $ } from '~/ts-dsl';
99-import { applyNaming } from '~/utils/naming';
1010-import { pathToJsonPointer, refToName } from '~/utils/ref';
11111212import { identifiers } from '../constants';
1313import { exportAst } from '../shared/export';
···11import { fromRef, ref } from '@hey-api/codegen-core';
22+import type { SchemaWithType } from '@hey-api/shared';
33+import { deduplicateSchema } from '@hey-api/shared';
2433-import { deduplicateSchema } from '~/ir/schema';
44-import type { SchemaWithType } from '~/plugins';
55import { $ } from '~/ts-dsl';
6677import { identifiers } from '../../constants';
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import { $ } from '~/ts-dsl';
3445import { identifiers } from '../../constants';
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import { $ } from '~/ts-dsl';
3445import { identifiers } from '../../constants';
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import { shouldCoerceToBigInt } from '~/plugins/shared/utils/coerce';
3445import type { Ast, IrSchemaToAstOptions } from '../../shared/types';
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import { $ } from '~/ts-dsl';
3445import { identifiers } from '../../constants';
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import { $ } from '~/ts-dsl';
3445import { identifiers } from '../../constants';
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import {
34 maybeBigInt,
45 shouldCoerceToBigInt,
···11import { fromRef, ref } from '@hey-api/codegen-core';
22+import type { SchemaWithType } from '@hey-api/shared';
2333-import type { SchemaWithType } from '~/plugins';
44import { $ } from '~/ts-dsl';
5566import { identifiers } from '../../constants';
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import { $ } from '~/ts-dsl';
3445import { identifiers } from '../../constants';
···11import { fromRef, ref } from '@hey-api/codegen-core';
22+import type { SchemaWithType } from '@hey-api/shared';
2333-import type { SchemaWithType } from '~/plugins';
44import { $ } from '~/ts-dsl';
5566import { identifiers } from '../../constants';
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import { $ } from '~/ts-dsl';
3445import { identifiers } from '../../constants';
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import { $ } from '~/ts-dsl';
3445import { identifiers } from '../../constants';
···11-import type { SchemaWithType } from '~/plugins';
11+import type { SchemaWithType } from '@hey-api/shared';
22+23import { $ } from '~/ts-dsl';
3445import { identifiers } from '../../constants';
+2-1
packages/openapi-ts/src/ts-dsl/base.ts
···2020 nodeBrand,
2121 ref,
2222} from '@hey-api/codegen-core';
2323+import type { AnyString } from '@hey-api/types';
2324import ts from 'typescript';
24252526import type { AccessOptions } from './utils/context';
···6061 readonly '~brand' = nodeBrand;
61626263 /** Branding property to identify the DSL class at runtime. */
6363- abstract readonly '~dsl': string & {};
6464+ abstract readonly '~dsl': AnyString;
64656566 /** Conditionally applies a callback to this builder. */
6667 $if<T extends TsDsl, V, R extends TsDsl = T>(
···11import type { RenderContext } from '@hey-api/codegen-core';
22import { Project } from '@hey-api/codegen-core';
33import ts from 'typescript';
44-import { describe, expect, it } from 'vitest';
5465import type { TsDsl } from '~/ts-dsl';
76
···11-import type { FeatureToggle, NamingOptions } from '~/config/shared';
22-import type {
33- OpenApiMetaObject,
44- OpenApiOperationObject,
55- OpenApiParameterObject,
66- OpenApiRequestBodyObject,
77- OpenApiResponseObject,
88- OpenApiSchemaObject,
99-} from '~/openApi/types';
1010-import type { Hooks } from '~/parser/types/hooks';
1111-import type { Casing, NameTransformer } from '~/utils/naming';
1212-1313-type EnumsMode = 'inline' | 'root';
1414-1515-export type UserParser = {
1616- /**
1717- * Filters can be used to select a subset of your input before it's passed
1818- * to plugins.
1919- */
2020- filters?: Filters;
2121- /**
2222- * Optional hooks to override default plugin behavior.
2323- *
2424- * Use these to classify resources, control which outputs are generated,
2525- * or provide custom behavior for specific resources.
2626- */
2727- hooks?: Hooks;
2828- /**
2929- * Pagination configuration.
3030- */
3131- pagination?: {
3232- /**
3333- * Array of keywords to be considered as pagination field names.
3434- * These will be used to detect pagination fields in schemas and parameters.
3535- *
3636- * @default ['after', 'before', 'cursor', 'offset', 'page', 'start']
3737- */
3838- keywords?: ReadonlyArray<string>;
3939- };
4040- /**
4141- * Custom input transformations to execute before parsing. Use this
4242- * to modify, fix, or enhance input before it's passed to plugins.
4343- */
4444- patch?: Patch;
4545- /**
4646- * Built-in transformations that modify or normalize the input before it's
4747- * passed to plugins. These options enable predictable, documented behaviors
4848- * and are distinct from custom patches. Use this to perform structural
4949- * changes to input in a standardized way.
5050- */
5151- transforms?: {
5252- /**
5353- * Your input might contain two types of enums:
5454- * - enums defined as reusable components (root enums)
5555- * - non-reusable enums nested within other schemas (inline enums)
5656- *
5757- * You may want all enums to be reusable. This is because only root enums
5858- * are typically exported by plugins. Inline enums will never be directly
5959- * importable since they're nested inside other schemas.
6060- *
6161- * For example, to export nested enum types with the `@hey-api/typescript`
6262- * plugin, set `enums` to `root`. Likewise, if you don't want to export any
6363- * enum types, set `enums` to `inline`.
6464- *
6565- * @default false
6666- */
6767- enums?:
6868- | boolean
6969- | EnumsMode
7070- | {
7171- /**
7272- * Casing convention for generated names.
7373- *
7474- * @default 'PascalCase'
7575- */
7676- case?: Casing;
7777- /**
7878- * Whether this feature is enabled.
7979- *
8080- * @default true
8181- */
8282- enabled?: boolean;
8383- /**
8484- * Controls whether enums are promoted to reusable root components
8585- * ('root') or kept inline within schemas ('inline').
8686- *
8787- * @default 'root'
8888- */
8989- mode?: EnumsMode;
9090- /**
9191- * Customize the generated name of enums.
9292- *
9393- * @default '{{name}}Enum'
9494- */
9595- name?: NameTransformer;
9696- };
9797- /**
9898- * By default, any object schema with a missing `required` keyword is
9999- * interpreted as "no properties are required." This is the correct
100100- * behavior according to the OpenAPI standard. However, some specifications
101101- * interpret a missing `required` keyword as "all properties should be
102102- * required."
103103- *
104104- * This option allows you to change the default behavior so that
105105- * properties are required by default unless explicitly marked as optional.
106106- *
107107- * @default false
108108- */
109109- propertiesRequiredByDefault?: boolean;
110110- /**
111111- * Your schemas might contain read-only or write-only fields. Using such
112112- * schemas directly could mean asking the user to provide a read-only
113113- * field in requests, or expecting a write-only field in responses.
114114- *
115115- * We separate schemas for requests and responses if direct usage
116116- * would result in such scenarios. You can still disable this
117117- * behavior if you prefer.
118118- *
119119- * @default true
120120- */
121121- readWrite?:
122122- | boolean
123123- | {
124124- /**
125125- * Whether this feature is enabled.
126126- *
127127- * @default true
128128- */
129129- enabled?: boolean;
130130- /**
131131- * Configuration for generated request-specific schemas.
132132- *
133133- * Can be:
134134- * - `string` or `function`: Shorthand for `{ name: string | function }`
135135- * - `object`: Full configuration object
136136- *
137137- * @default '{{name}}Writable'
138138- */
139139- requests?:
140140- | NameTransformer
141141- | {
142142- /**
143143- * Casing convention for generated names.
144144- *
145145- * @default 'preserve'
146146- */
147147- case?: Casing;
148148- /**
149149- * Customize the generated name of schemas used in requests or
150150- * containing write-only fields.
151151- *
152152- * @default '{{name}}Writable'
153153- */
154154- name?: NameTransformer;
155155- };
156156- /**
157157- * Configuration for generated response-specific schemas.
158158- *
159159- * Can be:
160160- * - `string` or `function`: Shorthand for `{ name: string | function }`
161161- * - `object`: Full configuration object
162162- *
163163- * @default '{{name}}'
164164- */
165165- responses?:
166166- | NameTransformer
167167- | {
168168- /**
169169- * Casing convention for generated names.
170170- *
171171- * @default 'preserve'
172172- */
173173- case?: Casing;
174174- /**
175175- * Customize the generated name of schemas used in responses or
176176- * containing read-only fields. We default to the original name
177177- * to avoid breaking output when a read-only field is added.
178178- *
179179- * @default '{{name}}'
180180- */
181181- name?: NameTransformer;
182182- };
183183- };
184184- };
185185- /**
186186- * **This is an experimental feature.**
187187- *
188188- * Validate the input before generating output? This is an experimental,
189189- * lightweight feature and support will be added on an ad hoc basis. Setting
190190- * `validate_EXPERIMENTAL` to `true` is the same as `warn`.
191191- *
192192- * @default false
193193- */
194194- validate_EXPERIMENTAL?: boolean | 'strict' | 'warn';
195195-};
196196-197197-export type Parser = {
198198- /**
199199- * Filters can be used to select a subset of your input before it's passed
200200- * to plugins.
201201- */
202202- filters?: Filters;
203203- /**
204204- * Optional hooks to override default plugin behavior.
205205- *
206206- * Use these to classify resources, control which outputs are generated,
207207- * or provide custom behavior for specific resources.
208208- */
209209- hooks: Hooks;
210210- /**
211211- * Pagination configuration.
212212- */
213213- pagination: {
214214- /**
215215- * Array of keywords to be considered as pagination field names.
216216- * These will be used to detect pagination fields in schemas and parameters.
217217- *
218218- * @default ['after', 'before', 'cursor', 'offset', 'page', 'start']
219219- */
220220- keywords: ReadonlyArray<string>;
221221- };
222222- /**
223223- * Custom input transformations to execute before parsing. Use this
224224- * to modify, fix, or enhance input before it's passed to plugins.
225225- */
226226- patch?: Patch;
227227- /**
228228- * Built-in transformations that modify or normalize the input before it's
229229- * passed to plugins. These options enable predictable, documented behaviors
230230- * and are distinct from custom patches. Use this to perform structural
231231- * changes to input in a standardized way.
232232- */
233233- transforms: {
234234- /**
235235- * Your input might contain two types of enums:
236236- * - enums defined as reusable components (root enums)
237237- * - non-reusable enums nested within other schemas (inline enums)
238238- *
239239- * You may want all enums to be reusable. This is because only root enums
240240- * are typically exported by plugins. Inline enums will never be directly
241241- * importable since they're nested inside other schemas.
242242- *
243243- * For example, to export nested enum types with the `@hey-api/typescript`
244244- * plugin, set `enums` to `root`. Likewise, if you don't want to export any
245245- * enum types, set `enums` to `inline`.
246246- */
247247- enums: NamingOptions &
248248- FeatureToggle & {
249249- /**
250250- * Controls whether enums are promoted to reusable root components
251251- * ('root') or kept inline within schemas ('inline').
252252- *
253253- * @default 'root'
254254- */
255255- mode: EnumsMode;
256256- };
257257- /**
258258- * By default, any object schema with a missing `required` keyword is
259259- * interpreted as "no properties are required." This is the correct
260260- * behavior according to the OpenAPI standard. However, some specifications
261261- * interpret a missing `required` keyword as "all properties should be
262262- * required."
263263- *
264264- * This option allows you to change the default behavior so that
265265- * properties are required by default unless explicitly marked as optional.
266266- *
267267- * @default false
268268- */
269269- propertiesRequiredByDefault: boolean;
270270- /**
271271- * Your schemas might contain read-only or write-only fields. Using such
272272- * schemas directly could mean asking the user to provide a read-only
273273- * field in requests, or expecting a write-only field in responses.
274274- *
275275- * We separate schemas for requests and responses if direct usage
276276- * would result in such scenarios. You can still disable this
277277- * behavior if you prefer.
278278- */
279279- readWrite: FeatureToggle & {
280280- /**
281281- * Configuration for generated request-specific schemas.
282282- */
283283- requests: NamingOptions;
284284- /**
285285- * Configuration for generated response-specific schemas.
286286- */
287287- responses: NamingOptions;
288288- };
289289- };
290290- /**
291291- * **This is an experimental feature.**
292292- *
293293- * Validate the input before generating output? This is an experimental,
294294- * lightweight feature and support will be added on an ad hoc basis. Setting
295295- * `validate_EXPERIMENTAL` to `true` is the same as `warn`.
296296- *
297297- * @default false
298298- */
299299- validate_EXPERIMENTAL: false | 'strict' | 'warn';
300300-};
301301-302302-export type Filters = {
303303- /**
304304- * Include deprecated resources in the output?
305305- *
306306- * @default true
307307- */
308308- deprecated?: boolean;
309309- operations?: {
310310- /**
311311- * Prevent operations matching the `exclude` filters from being processed.
312312- *
313313- * In case of conflicts, `exclude` takes precedence over `include`.
314314- *
315315- * @example ['GET /api/v1/foo']
316316- */
317317- exclude?: ReadonlyArray<string>;
318318- /**
319319- * Process only operations matching the `include` filters.
320320- *
321321- * In case of conflicts, `exclude` takes precedence over `include`.
322322- *
323323- * @example ['GET /api/v1/foo']
324324- */
325325- include?: ReadonlyArray<string>;
326326- };
327327- /**
328328- * Keep reusable components without any references from operations in the
329329- * output? By default, we exclude orphaned resources.
330330- *
331331- * @default false
332332- */
333333- orphans?: boolean;
334334- parameters?: {
335335- /**
336336- * Prevent parameters matching the `exclude` filters from being processed.
337337- *
338338- * In case of conflicts, `exclude` takes precedence over `include`.
339339- *
340340- * @example ['QueryParam']
341341- */
342342- exclude?: ReadonlyArray<string>;
343343- /**
344344- * Process only parameters matching the `include` filters.
345345- *
346346- * In case of conflicts, `exclude` takes precedence over `include`.
347347- *
348348- * @example ['QueryParam']
349349- */
350350- include?: ReadonlyArray<string>;
351351- };
352352- /**
353353- * Should we preserve the key order when overwriting your input? This
354354- * option is disabled by default to improve performance.
355355- *
356356- * @default false
357357- */
358358- preserveOrder?: boolean;
359359- requestBodies?: {
360360- /**
361361- * Prevent request bodies matching the `exclude` filters from being processed.
362362- *
363363- * In case of conflicts, `exclude` takes precedence over `include`.
364364- *
365365- * @example ['Foo']
366366- */
367367- exclude?: ReadonlyArray<string>;
368368- /**
369369- * Process only request bodies matching the `include` filters.
370370- *
371371- * In case of conflicts, `exclude` takes precedence over `include`.
372372- *
373373- * @example ['Foo']
374374- */
375375- include?: ReadonlyArray<string>;
376376- };
377377- responses?: {
378378- /**
379379- * Prevent responses matching the `exclude` filters from being processed.
380380- *
381381- * In case of conflicts, `exclude` takes precedence over `include`.
382382- *
383383- * @example ['Foo']
384384- */
385385- exclude?: ReadonlyArray<string>;
386386- /**
387387- * Process only responses matching the `include` filters.
388388- *
389389- * In case of conflicts, `exclude` takes precedence over `include`.
390390- *
391391- * @example ['Foo']
392392- */
393393- include?: ReadonlyArray<string>;
394394- };
395395- schemas?: {
396396- /**
397397- * Prevent schemas matching the `exclude` filters from being processed.
398398- *
399399- * In case of conflicts, `exclude` takes precedence over `include`.
400400- *
401401- * @example ['Foo']
402402- */
403403- exclude?: ReadonlyArray<string>;
404404- /**
405405- * Process only schemas matching the `include` filters.
406406- *
407407- * In case of conflicts, `exclude` takes precedence over `include`.
408408- *
409409- * @example ['Foo']
410410- */
411411- include?: ReadonlyArray<string>;
412412- };
413413- tags?: {
414414- /**
415415- * Prevent tags matching the `exclude` filters from being processed.
416416- *
417417- * In case of conflicts, `exclude` takes precedence over `include`.
418418- *
419419- * @example ['foo']
420420- */
421421- exclude?: ReadonlyArray<string>;
422422- /**
423423- * Process only tags matching the `include` filters.
424424- *
425425- * In case of conflicts, `exclude` takes precedence over `include`.
426426- *
427427- * @example ['foo']
428428- */
429429- include?: ReadonlyArray<string>;
430430- };
431431-};
432432-433433-export type Patch = {
434434- /**
435435- * Patch the OpenAPI meta object in place. Useful for modifying general metadata such as title, description, version, or custom fields before further processing.
436436- *
437437- * @param meta The OpenAPI meta object for the current version.
438438- */
439439- meta?: (
440440- meta:
441441- | OpenApiMetaObject.V2_0_X
442442- | OpenApiMetaObject.V3_0_X
443443- | OpenApiMetaObject.V3_1_X,
444444- ) => void;
445445- /**
446446- * Patch OpenAPI operations in place. The key is the operation method and operation path, and the function receives the operation object to modify directly.
447447- *
448448- * @example
449449- * operations: {
450450- * 'GET /foo': (operation) => {
451451- * operation.responses['200'].description = 'foo';
452452- * }
453453- * }
454454- */
455455- operations?: Record<
456456- string,
457457- (
458458- operation:
459459- | OpenApiOperationObject.V2_0_X
460460- | OpenApiOperationObject.V3_0_X
461461- | OpenApiOperationObject.V3_1_X,
462462- ) => void
463463- >;
464464- /**
465465- * Patch OpenAPI parameters in place. The key is the parameter name, and the function receives the parameter object to modify directly.
466466- *
467467- * @example
468468- * parameters: {
469469- * limit: (parameter) => {
470470- * parameter.schema.type = 'integer';
471471- * }
472472- * }
473473- */
474474- parameters?: Record<
475475- string,
476476- (
477477- parameter: OpenApiParameterObject.V3_0_X | OpenApiParameterObject.V3_1_X,
478478- ) => void
479479- >;
480480- /**
481481- * Patch OpenAPI request bodies in place. The key is the request body name, and the function receives the request body object to modify directly.
482482- *
483483- * @example
484484- * requestBodies: {
485485- * CreateUserRequest: (requestBody) => {
486486- * requestBody.required = true;
487487- * }
488488- * }
489489- */
490490- requestBodies?: Record<
491491- string,
492492- (
493493- requestBody:
494494- | OpenApiRequestBodyObject.V3_0_X
495495- | OpenApiRequestBodyObject.V3_1_X,
496496- ) => void
497497- >;
498498- /**
499499- * Patch OpenAPI responses in place. The key is the response name, and the function receives the response object to modify directly.
500500- *
501501- * @example
502502- * responses: {
503503- * NotFound: (response) => {
504504- * response.description = 'Resource not found.';
505505- * }
506506- * }
507507- */
508508- responses?: Record<
509509- string,
510510- (
511511- response: OpenApiResponseObject.V3_0_X | OpenApiResponseObject.V3_1_X,
512512- ) => void
513513- >;
514514- /**
515515- * Each function receives the schema object to be modified in place. Common
516516- * use cases include fixing incorrect data types, removing unwanted
517517- * properties, adding missing fields, or standardizing date/time formats.
518518- *
519519- * @example
520520- * ```js
521521- * schemas: {
522522- * Foo: (schema) => {
523523- * // convert date-time format to timestamp
524524- * delete schema.properties.updatedAt.format;
525525- * schema.properties.updatedAt.type = 'number';
526526- * },
527527- * Bar: (schema) => {
528528- * // add missing property
529529- * schema.properties.metadata = {
530530- * additionalProperties: true,
531531- * type: 'object',
532532- * };
533533- * schema.required = ['metadata'];
534534- * },
535535- * Baz: (schema) => {
536536- * // remove property
537537- * delete schema.properties.internalField;
538538- * }
539539- * }
540540- * ```
541541- */
542542- schemas?: Record<
543543- string,
544544- (
545545- schema:
546546- | OpenApiSchemaObject.V2_0_X
547547- | OpenApiSchemaObject.V3_0_X
548548- | OpenApiSchemaObject.V3_1_X,
549549- ) => void
550550- >;
551551- /**
552552- * Patch the OpenAPI version string. The function receives the current version and should return the new version string.
553553- * Useful for normalizing or overriding the version value before further processing.
554554- *
555555- * @param version The current OpenAPI version string.
556556- * @returns The new version string to use.
557557- *
558558- * @example
559559- * version: (version) => version.replace(/^v/, '')
560560- */
561561- version?: string | ((version: string) => string);
562562-};
···11-export interface WatchValues {
11+export type WatchValues = {
22 /**
33 * Headers to be sent with each HEAD and/or GET request. This effectively
44 * serves as a mechanism resolver because setting certain headers will opt
···1414 * String content of the last successfully fetched specification.
1515 */
1616 lastValue?: string;
1717-}
1717+};
···11-import type { Casing } from './naming';
22-import { toCase } from './naming';
11+import { toCase } from './naming/naming';
22+import type { Casing } from './naming/types';
3344/**
55 * Utilities shared across the package.
···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 colors from 'ansi-colors';
22+import { sync } from 'cross-spawn';
33+44+type Output = {
55+ /**
66+ * The absolute path to the output folder.
77+ */
88+ path: string;
99+ /**
1010+ * Post-processing commands to run on the output folder, executed in order.
1111+ */
1212+ postProcess: ReadonlyArray<string | UserPostProcessor>;
1313+};
1414+1515+export type UserPostProcessor = {
1616+ /**
1717+ * Arguments to pass to the command. Use `{{path}}` as a placeholder
1818+ * for the output directory path.
1919+ *
2020+ * @example ['format', '--write', '{{path}}']
2121+ */
2222+ args: ReadonlyArray<string>;
2323+ /**
2424+ * The command to run (e.g., 'biome', 'prettier', 'eslint').
2525+ */
2626+ command: string;
2727+ /**
2828+ * Display name for logging. Defaults to the command name.
2929+ */
3030+ name?: string;
3131+};
3232+3333+export type PostProcessor = {
3434+ /**
3535+ * Arguments to pass to the command.
3636+ */
3737+ args: ReadonlyArray<string>;
3838+ /**
3939+ * The command to run.
4040+ */
4141+ command: string;
4242+ /**
4343+ * Display name for logging.
4444+ */
4545+ name: string;
4646+};
4747+4848+export function postprocessOutput(
4949+ config: Output,
5050+ postProcessors: Record<string, PostProcessor>,
5151+ jobPrefix: string,
5252+): void {
5353+ for (const processor of config.postProcess) {
5454+ const resolved =
5555+ typeof processor === 'string' ? postProcessors[processor] : processor;
5656+5757+ // TODO: show warning
5858+ if (!resolved) continue;
5959+6060+ const name = resolved.name ?? resolved.command;
6161+ const args = resolved.args.map((arg) =>
6262+ arg.replace('{{path}}', config.path),
6363+ );
6464+6565+ console.log(`${jobPrefix}🧹 Running ${colors.cyanBright(name)}`);
6666+ sync(resolved.command, args);
6767+ }
6868+}
+6
packages/shared/src/config/output/types.ts
···11+import type { RenderContext } from '@hey-api/codegen-core';
22+import type { MaybeArray, MaybeFunc } from '@hey-api/types';
33+44+export type OutputHeader = MaybeFunc<
55+ (ctx: RenderContext) => MaybeArray<string> | null | undefined
66+>;
+130
packages/shared/src/config/parser/filters.ts
···11+export type Filters = {
22+ /**
33+ * Include deprecated resources in the output?
44+ *
55+ * @default true
66+ */
77+ deprecated?: boolean;
88+ operations?: {
99+ /**
1010+ * Prevent operations matching the `exclude` filters from being processed.
1111+ *
1212+ * In case of conflicts, `exclude` takes precedence over `include`.
1313+ *
1414+ * @example ['GET /api/v1/foo']
1515+ */
1616+ exclude?: ReadonlyArray<string>;
1717+ /**
1818+ * Process only operations matching the `include` filters.
1919+ *
2020+ * In case of conflicts, `exclude` takes precedence over `include`.
2121+ *
2222+ * @example ['GET /api/v1/foo']
2323+ */
2424+ include?: ReadonlyArray<string>;
2525+ };
2626+ /**
2727+ * Keep reusable components without any references from operations in the
2828+ * output? By default, we exclude orphaned resources.
2929+ *
3030+ * @default false
3131+ */
3232+ orphans?: boolean;
3333+ parameters?: {
3434+ /**
3535+ * Prevent parameters matching the `exclude` filters from being processed.
3636+ *
3737+ * In case of conflicts, `exclude` takes precedence over `include`.
3838+ *
3939+ * @example ['QueryParam']
4040+ */
4141+ exclude?: ReadonlyArray<string>;
4242+ /**
4343+ * Process only parameters matching the `include` filters.
4444+ *
4545+ * In case of conflicts, `exclude` takes precedence over `include`.
4646+ *
4747+ * @example ['QueryParam']
4848+ */
4949+ include?: ReadonlyArray<string>;
5050+ };
5151+ /**
5252+ * Should we preserve the key order when overwriting your input? This
5353+ * option is disabled by default to improve performance.
5454+ *
5555+ * @default false
5656+ */
5757+ preserveOrder?: boolean;
5858+ requestBodies?: {
5959+ /**
6060+ * Prevent request bodies matching the `exclude` filters from being processed.
6161+ *
6262+ * In case of conflicts, `exclude` takes precedence over `include`.
6363+ *
6464+ * @example ['Foo']
6565+ */
6666+ exclude?: ReadonlyArray<string>;
6767+ /**
6868+ * Process only request bodies matching the `include` filters.
6969+ *
7070+ * In case of conflicts, `exclude` takes precedence over `include`.
7171+ *
7272+ * @example ['Foo']
7373+ */
7474+ include?: ReadonlyArray<string>;
7575+ };
7676+ responses?: {
7777+ /**
7878+ * Prevent responses matching the `exclude` filters from being processed.
7979+ *
8080+ * In case of conflicts, `exclude` takes precedence over `include`.
8181+ *
8282+ * @example ['Foo']
8383+ */
8484+ exclude?: ReadonlyArray<string>;
8585+ /**
8686+ * Process only responses matching the `include` filters.
8787+ *
8888+ * In case of conflicts, `exclude` takes precedence over `include`.
8989+ *
9090+ * @example ['Foo']
9191+ */
9292+ include?: ReadonlyArray<string>;
9393+ };
9494+ schemas?: {
9595+ /**
9696+ * Prevent schemas matching the `exclude` filters from being processed.
9797+ *
9898+ * In case of conflicts, `exclude` takes precedence over `include`.
9999+ *
100100+ * @example ['Foo']
101101+ */
102102+ exclude?: ReadonlyArray<string>;
103103+ /**
104104+ * Process only schemas matching the `include` filters.
105105+ *
106106+ * In case of conflicts, `exclude` takes precedence over `include`.
107107+ *
108108+ * @example ['Foo']
109109+ */
110110+ include?: ReadonlyArray<string>;
111111+ };
112112+ tags?: {
113113+ /**
114114+ * Prevent tags matching the `exclude` filters from being processed.
115115+ *
116116+ * In case of conflicts, `exclude` takes precedence over `include`.
117117+ *
118118+ * @example ['foo']
119119+ */
120120+ exclude?: ReadonlyArray<string>;
121121+ /**
122122+ * Process only tags matching the `include` filters.
123123+ *
124124+ * In case of conflicts, `exclude` takes precedence over `include`.
125125+ *
126126+ * @example ['foo']
127127+ */
128128+ include?: ReadonlyArray<string>;
129129+ };
130130+};
+141
packages/shared/src/config/parser/patch.ts
···11+import type { MaybeFunc } from '@hey-api/types';
22+33+import type {
44+ OpenApiMetaObject,
55+ OpenApiOperationObject,
66+ OpenApiParameterObject,
77+ OpenApiRequestBodyObject,
88+ OpenApiResponseObject,
99+ OpenApiSchemaObject,
1010+} from '../../openApi/types';
1111+1212+export type Patch = {
1313+ /**
1414+ * Patch the OpenAPI meta object in place. Useful for modifying general metadata such as title, description, version, or custom fields before further processing.
1515+ *
1616+ * @param meta The OpenAPI meta object for the current version.
1717+ */
1818+ meta?: (
1919+ meta:
2020+ | OpenApiMetaObject.V2_0_X
2121+ | OpenApiMetaObject.V3_0_X
2222+ | OpenApiMetaObject.V3_1_X,
2323+ ) => void;
2424+ /**
2525+ * Patch OpenAPI operations in place. The key is the operation method and operation path, and the function receives the operation object to modify directly.
2626+ *
2727+ * @example
2828+ * operations: {
2929+ * 'GET /foo': (operation) => {
3030+ * operation.responses['200'].description = 'foo';
3131+ * }
3232+ * }
3333+ */
3434+ operations?: Record<
3535+ string,
3636+ (
3737+ operation:
3838+ | OpenApiOperationObject.V2_0_X
3939+ | OpenApiOperationObject.V3_0_X
4040+ | OpenApiOperationObject.V3_1_X,
4141+ ) => void
4242+ >;
4343+ /**
4444+ * Patch OpenAPI parameters in place. The key is the parameter name, and the function receives the parameter object to modify directly.
4545+ *
4646+ * @example
4747+ * parameters: {
4848+ * limit: (parameter) => {
4949+ * parameter.schema.type = 'integer';
5050+ * }
5151+ * }
5252+ */
5353+ parameters?: Record<
5454+ string,
5555+ (
5656+ parameter: OpenApiParameterObject.V3_0_X | OpenApiParameterObject.V3_1_X,
5757+ ) => void
5858+ >;
5959+ /**
6060+ * Patch OpenAPI request bodies in place. The key is the request body name, and the function receives the request body object to modify directly.
6161+ *
6262+ * @example
6363+ * requestBodies: {
6464+ * CreateUserRequest: (requestBody) => {
6565+ * requestBody.required = true;
6666+ * }
6767+ * }
6868+ */
6969+ requestBodies?: Record<
7070+ string,
7171+ (
7272+ requestBody:
7373+ | OpenApiRequestBodyObject.V3_0_X
7474+ | OpenApiRequestBodyObject.V3_1_X,
7575+ ) => void
7676+ >;
7777+ /**
7878+ * Patch OpenAPI responses in place. The key is the response name, and the function receives the response object to modify directly.
7979+ *
8080+ * @example
8181+ * responses: {
8282+ * NotFound: (response) => {
8383+ * response.description = 'Resource not found.';
8484+ * }
8585+ * }
8686+ */
8787+ responses?: Record<
8888+ string,
8989+ (
9090+ response: OpenApiResponseObject.V3_0_X | OpenApiResponseObject.V3_1_X,
9191+ ) => void
9292+ >;
9393+ /**
9494+ * Each function receives the schema object to be modified in place. Common
9595+ * use cases include fixing incorrect data types, removing unwanted
9696+ * properties, adding missing fields, or standardizing date/time formats.
9797+ *
9898+ * @example
9999+ * ```js
100100+ * schemas: {
101101+ * Foo: (schema) => {
102102+ * // convert date-time format to timestamp
103103+ * delete schema.properties.updatedAt.format;
104104+ * schema.properties.updatedAt.type = 'number';
105105+ * },
106106+ * Bar: (schema) => {
107107+ * // add missing property
108108+ * schema.properties.metadata = {
109109+ * additionalProperties: true,
110110+ * type: 'object',
111111+ * };
112112+ * schema.required = ['metadata'];
113113+ * },
114114+ * Baz: (schema) => {
115115+ * // remove property
116116+ * delete schema.properties.internalField;
117117+ * }
118118+ * }
119119+ * ```
120120+ */
121121+ schemas?: Record<
122122+ string,
123123+ (
124124+ schema:
125125+ | OpenApiSchemaObject.V2_0_X
126126+ | OpenApiSchemaObject.V3_0_X
127127+ | OpenApiSchemaObject.V3_1_X,
128128+ ) => void
129129+ >;
130130+ /**
131131+ * Patch the OpenAPI version string. The function receives the current version and should return the new version string.
132132+ * Useful for normalizing or overriding the version value before further processing.
133133+ *
134134+ * @param version The current OpenAPI version string.
135135+ * @returns The new version string to use.
136136+ *
137137+ * @example
138138+ * version: (version) => version.replace(/^v/, '')
139139+ */
140140+ version?: MaybeFunc<(version: string) => string>;
141141+};
+294
packages/shared/src/config/parser/types.ts
···11+import type { Hooks } from '../../parser/hooks';
22+import type { Casing, NameTransformer } from '../../utils/naming/types';
33+import type { FeatureToggle, NamingOptions } from '../shared';
44+import type { Filters } from './filters';
55+import type { Patch } from './patch';
66+77+type EnumsMode = 'inline' | 'root';
88+99+export type UserParser = {
1010+ /**
1111+ * Filters can be used to select a subset of your input before it's passed
1212+ * to plugins.
1313+ */
1414+ filters?: Filters;
1515+ /**
1616+ * Optional hooks to override default plugin behavior.
1717+ *
1818+ * Use these to classify resources, control which outputs are generated,
1919+ * or provide custom behavior for specific resources.
2020+ */
2121+ hooks?: Hooks;
2222+ /**
2323+ * Pagination configuration.
2424+ */
2525+ pagination?: {
2626+ /**
2727+ * Array of keywords to be considered as pagination field names.
2828+ * These will be used to detect pagination fields in schemas and parameters.
2929+ *
3030+ * @default ['after', 'before', 'cursor', 'offset', 'page', 'start']
3131+ */
3232+ keywords?: ReadonlyArray<string>;
3333+ };
3434+ /**
3535+ * Custom input transformations to execute before parsing. Use this
3636+ * to modify, fix, or enhance input before it's passed to plugins.
3737+ */
3838+ patch?: Patch;
3939+ /**
4040+ * Built-in transformations that modify or normalize the input before it's
4141+ * passed to plugins. These options enable predictable, documented behaviors
4242+ * and are distinct from custom patches. Use this to perform structural
4343+ * changes to input in a standardized way.
4444+ */
4545+ transforms?: {
4646+ /**
4747+ * Your input might contain two types of enums:
4848+ * - enums defined as reusable components (root enums)
4949+ * - non-reusable enums nested within other schemas (inline enums)
5050+ *
5151+ * You may want all enums to be reusable. This is because only root enums
5252+ * are typically exported by plugins. Inline enums will never be directly
5353+ * importable since they're nested inside other schemas.
5454+ *
5555+ * For example, to export nested enum types with the `@hey-api/typescript`
5656+ * plugin, set `enums` to `root`. Likewise, if you don't want to export any
5757+ * enum types, set `enums` to `inline`.
5858+ *
5959+ * @default false
6060+ */
6161+ enums?:
6262+ | boolean
6363+ | EnumsMode
6464+ | {
6565+ /**
6666+ * Casing convention for generated names.
6767+ *
6868+ * @default 'PascalCase'
6969+ */
7070+ case?: Casing;
7171+ /**
7272+ * Whether this feature is enabled.
7373+ *
7474+ * @default true
7575+ */
7676+ enabled?: boolean;
7777+ /**
7878+ * Controls whether enums are promoted to reusable root components
7979+ * ('root') or kept inline within schemas ('inline').
8080+ *
8181+ * @default 'root'
8282+ */
8383+ mode?: EnumsMode;
8484+ /**
8585+ * Customize the generated name of enums.
8686+ *
8787+ * @default '{{name}}Enum'
8888+ */
8989+ name?: NameTransformer;
9090+ };
9191+ /**
9292+ * By default, any object schema with a missing `required` keyword is
9393+ * interpreted as "no properties are required." This is the correct
9494+ * behavior according to the OpenAPI standard. However, some specifications
9595+ * interpret a missing `required` keyword as "all properties should be
9696+ * required."
9797+ *
9898+ * This option allows you to change the default behavior so that
9999+ * properties are required by default unless explicitly marked as optional.
100100+ *
101101+ * @default false
102102+ */
103103+ propertiesRequiredByDefault?: boolean;
104104+ /**
105105+ * Your schemas might contain read-only or write-only fields. Using such
106106+ * schemas directly could mean asking the user to provide a read-only
107107+ * field in requests, or expecting a write-only field in responses.
108108+ *
109109+ * We separate schemas for requests and responses if direct usage
110110+ * would result in such scenarios. You can still disable this
111111+ * behavior if you prefer.
112112+ *
113113+ * @default true
114114+ */
115115+ readWrite?:
116116+ | boolean
117117+ | {
118118+ /**
119119+ * Whether this feature is enabled.
120120+ *
121121+ * @default true
122122+ */
123123+ enabled?: boolean;
124124+ /**
125125+ * Configuration for generated request-specific schemas.
126126+ *
127127+ * Can be:
128128+ * - `string` or `function`: Shorthand for `{ name: string | function }`
129129+ * - `object`: Full configuration object
130130+ *
131131+ * @default '{{name}}Writable'
132132+ */
133133+ requests?:
134134+ | NameTransformer
135135+ | {
136136+ /**
137137+ * Casing convention for generated names.
138138+ *
139139+ * @default 'preserve'
140140+ */
141141+ case?: Casing;
142142+ /**
143143+ * Customize the generated name of schemas used in requests or
144144+ * containing write-only fields.
145145+ *
146146+ * @default '{{name}}Writable'
147147+ */
148148+ name?: NameTransformer;
149149+ };
150150+ /**
151151+ * Configuration for generated response-specific schemas.
152152+ *
153153+ * Can be:
154154+ * - `string` or `function`: Shorthand for `{ name: string | function }`
155155+ * - `object`: Full configuration object
156156+ *
157157+ * @default '{{name}}'
158158+ */
159159+ responses?:
160160+ | NameTransformer
161161+ | {
162162+ /**
163163+ * Casing convention for generated names.
164164+ *
165165+ * @default 'preserve'
166166+ */
167167+ case?: Casing;
168168+ /**
169169+ * Customize the generated name of schemas used in responses or
170170+ * containing read-only fields. We default to the original name
171171+ * to avoid breaking output when a read-only field is added.
172172+ *
173173+ * @default '{{name}}'
174174+ */
175175+ name?: NameTransformer;
176176+ };
177177+ };
178178+ };
179179+ /**
180180+ * **This is an experimental feature.**
181181+ *
182182+ * Validate the input before generating output? This is an experimental,
183183+ * lightweight feature and support will be added on an ad hoc basis. Setting
184184+ * `validate_EXPERIMENTAL` to `true` is the same as `warn`.
185185+ *
186186+ * @default false
187187+ */
188188+ validate_EXPERIMENTAL?: boolean | 'strict' | 'warn';
189189+};
190190+191191+export type Parser = {
192192+ /**
193193+ * Filters can be used to select a subset of your input before it's passed
194194+ * to plugins.
195195+ */
196196+ filters?: Filters;
197197+ /**
198198+ * Optional hooks to override default plugin behavior.
199199+ *
200200+ * Use these to classify resources, control which outputs are generated,
201201+ * or provide custom behavior for specific resources.
202202+ */
203203+ hooks: Hooks;
204204+ /**
205205+ * Pagination configuration.
206206+ */
207207+ pagination: {
208208+ /**
209209+ * Array of keywords to be considered as pagination field names.
210210+ * These will be used to detect pagination fields in schemas and parameters.
211211+ *
212212+ * @default ['after', 'before', 'cursor', 'offset', 'page', 'start']
213213+ */
214214+ keywords: ReadonlyArray<string>;
215215+ };
216216+ /**
217217+ * Custom input transformations to execute before parsing. Use this
218218+ * to modify, fix, or enhance input before it's passed to plugins.
219219+ */
220220+ patch?: Patch;
221221+ /**
222222+ * Built-in transformations that modify or normalize the input before it's
223223+ * passed to plugins. These options enable predictable, documented behaviors
224224+ * and are distinct from custom patches. Use this to perform structural
225225+ * changes to input in a standardized way.
226226+ */
227227+ transforms: {
228228+ /**
229229+ * Your input might contain two types of enums:
230230+ * - enums defined as reusable components (root enums)
231231+ * - non-reusable enums nested within other schemas (inline enums)
232232+ *
233233+ * You may want all enums to be reusable. This is because only root enums
234234+ * are typically exported by plugins. Inline enums will never be directly
235235+ * importable since they're nested inside other schemas.
236236+ *
237237+ * For example, to export nested enum types with the `@hey-api/typescript`
238238+ * plugin, set `enums` to `root`. Likewise, if you don't want to export any
239239+ * enum types, set `enums` to `inline`.
240240+ */
241241+ enums: NamingOptions &
242242+ FeatureToggle & {
243243+ /**
244244+ * Controls whether enums are promoted to reusable root components
245245+ * ('root') or kept inline within schemas ('inline').
246246+ *
247247+ * @default 'root'
248248+ */
249249+ mode: EnumsMode;
250250+ };
251251+ /**
252252+ * By default, any object schema with a missing `required` keyword is
253253+ * interpreted as "no properties are required." This is the correct
254254+ * behavior according to the OpenAPI standard. However, some specifications
255255+ * interpret a missing `required` keyword as "all properties should be
256256+ * required."
257257+ *
258258+ * This option allows you to change the default behavior so that
259259+ * properties are required by default unless explicitly marked as optional.
260260+ *
261261+ * @default false
262262+ */
263263+ propertiesRequiredByDefault: boolean;
264264+ /**
265265+ * Your schemas might contain read-only or write-only fields. Using such
266266+ * schemas directly could mean asking the user to provide a read-only
267267+ * field in requests, or expecting a write-only field in responses.
268268+ *
269269+ * We separate schemas for requests and responses if direct usage
270270+ * would result in such scenarios. You can still disable this
271271+ * behavior if you prefer.
272272+ */
273273+ readWrite: FeatureToggle & {
274274+ /**
275275+ * Configuration for generated request-specific schemas.
276276+ */
277277+ requests: NamingOptions;
278278+ /**
279279+ * Configuration for generated response-specific schemas.
280280+ */
281281+ responses: NamingOptions;
282282+ };
283283+ };
284284+ /**
285285+ * **This is an experimental feature.**
286286+ *
287287+ * Validate the input before generating output? This is an experimental,
288288+ * lightweight feature and support will be added on an ad hoc basis. Setting
289289+ * `validate_EXPERIMENTAL` to `true` is the same as `warn`.
290290+ *
291291+ * @default false
292292+ */
293293+ validate_EXPERIMENTAL: false | 'strict' | 'warn';
294294+};
+294
packages/shared/src/config/shared.ts
···11+import type { NameConflictResolver } from '@hey-api/codegen-core';
22+import type { MaybeArray } from '@hey-api/types';
33+44+import type { Plugin } from '../plugins/types';
55+import type { Logs } from '../types/logs';
66+import type { Casing, NameTransformer } from '../utils/naming/types';
77+import type { Input, UserInput, UserWatch } from './input/types';
88+import type { PostProcessor } from './output/postprocess';
99+import type { SourceConfig, UserSourceConfig } from './output/source/types';
1010+import type { OutputHeader } from './output/types';
1111+import type { Parser, UserParser } from './parser/types';
1212+1313+export type FeatureToggle = {
1414+ /**
1515+ * Whether this feature is enabled.
1616+ */
1717+ enabled: boolean;
1818+};
1919+2020+export type IndexExportOption = {
2121+ /**
2222+ * Whether exports should be re-exported in the index file.
2323+ */
2424+ exportFromIndex: boolean;
2525+};
2626+2727+export type NamingOptions = {
2828+ /**
2929+ * Casing convention for generated names.
3030+ */
3131+ case: Casing;
3232+ /**
3333+ * Naming pattern for generated names.
3434+ */
3535+ name: NameTransformer;
3636+};
3737+3838+/**
3939+ * Base output shape all packages must satisfy.
4040+ */
4141+export interface BaseUserOutput {
4242+ /**
4343+ * Defines casing of the output fields. By default, we preserve `input`
4444+ * values as data transforms incur a performance penalty at runtime.
4545+ *
4646+ * @default undefined
4747+ */
4848+ case?: Casing;
4949+ /**
5050+ * Clean the `output` folder on every run? If disabled, this folder may
5151+ * be used to store additional files. The default option is `true` to
5252+ * reduce the risk of keeping outdated files around when configuration,
5353+ * input, or package version changes.
5454+ *
5555+ * @default true
5656+ */
5757+ clean?: boolean;
5858+ /**
5959+ * Optional function to transform file names before they are used.
6060+ *
6161+ * @param name The original file name.
6262+ * @returns The transformed file name.
6363+ * @default '{{name}}'
6464+ */
6565+ fileName?:
6666+ | NameTransformer
6767+ | {
6868+ /**
6969+ * Casing convention for generated names.
7070+ *
7171+ * @default 'preserve'
7272+ */
7373+ case?: Casing;
7474+ /**
7575+ * Naming pattern for generated names.
7676+ *
7777+ * @default '{{name}}'
7878+ */
7979+ name?: NameTransformer;
8080+ /**
8181+ * Suffix to append to file names (before the extension). For example,
8282+ * with a suffix of `.gen`, `example.ts` becomes `example.gen.ts`.
8383+ *
8484+ * @default '.gen'
8585+ * @example
8686+ * // Given a suffix of `.gen`
8787+ * 'index.ts' -> 'index.ts' (index files are not renamed)
8888+ * 'user.ts' -> 'user.gen.ts'
8989+ * 'order.gen.ts' -> 'order.gen.ts' (files already containing the suffix are not renamed)
9090+ */
9191+ suffix?: string | null;
9292+ };
9393+ /**
9494+ * Text to include at the top of every generated file.
9595+ */
9696+ header?: OutputHeader;
9797+ /**
9898+ * Should the exports from plugin files be re-exported in the index
9999+ * barrel file? By default, this is enabled and only default plugins
100100+ * are re-exported.
101101+ *
102102+ * @default true
103103+ */
104104+ indexFile?: boolean;
105105+ /**
106106+ * Optional name conflict resolver to customize how naming conflicts
107107+ * are handled.
108108+ */
109109+ nameConflictResolver?: NameConflictResolver;
110110+ /**
111111+ * The absolute path to the output folder.
112112+ */
113113+ path: string;
114114+ /**
115115+ * Optional function to transform module specifiers.
116116+ *
117117+ * @default undefined
118118+ */
119119+ resolveModuleName?: (moduleName: string) => string | undefined;
120120+ /**
121121+ * Configuration for generating a copy of the input source used to produce this output.
122122+ *
123123+ * Set to `false` to skip generating the source, or `true` to use defaults.
124124+ *
125125+ * You can also provide a configuration object to further customize behavior.
126126+ *
127127+ * @default false
128128+ */
129129+ source?: boolean | UserSourceConfig;
130130+}
131131+132132+/**
133133+ * Base output shape all packages must satisfy.
134134+ */
135135+export interface BaseOutput {
136136+ /**
137137+ * Defines casing of the output fields. By default, we preserve `input`
138138+ * values as data transforms incur a performance penalty at runtime.
139139+ */
140140+ case: Casing | undefined;
141141+ /**
142142+ * Clean the `output` folder on every run? If disabled, this folder may
143143+ * be used to store additional files. The default option is `true` to
144144+ * reduce the risk of keeping outdated files around when configuration,
145145+ * input, or package version changes.
146146+ */
147147+ clean: boolean;
148148+ /**
149149+ * Optional function to transform file names before they are used.
150150+ *
151151+ * @param name The original file name.
152152+ * @returns The transformed file name.
153153+ */
154154+ fileName: NamingOptions & {
155155+ /**
156156+ * Suffix to append to file names (before the extension). For example,
157157+ * with a suffix of `.gen`, `example.ts` becomes `example.gen.ts`.
158158+ *
159159+ * @example
160160+ * // Given a suffix of `.gen`
161161+ * 'index.ts' -> 'index.ts' (index files are not renamed)
162162+ * 'user.ts' -> 'user.gen.ts'
163163+ * 'order.gen.ts' -> 'order.gen.ts' (files already containing the suffix are not renamed)
164164+ */
165165+ suffix: string | null;
166166+ };
167167+ /**
168168+ * Text to include at the top of every generated file.
169169+ */
170170+ header: OutputHeader;
171171+ /**
172172+ * Should the exports from plugin files be re-exported in the index
173173+ * barrel file? By default, this is enabled and only default plugins
174174+ * are re-exported.
175175+ */
176176+ indexFile: boolean;
177177+ /**
178178+ * Optional name conflict resolver to customize how naming conflicts
179179+ * are handled.
180180+ */
181181+ nameConflictResolver: NameConflictResolver | undefined;
182182+ /**
183183+ * The absolute path to the output folder.
184184+ */
185185+ path: string;
186186+ /**
187187+ * Post-processing commands to run on the output folder, executed in order.
188188+ */
189189+ postProcess: ReadonlyArray<PostProcessor>;
190190+ /**
191191+ * Optional function to transform module specifiers.
192192+ */
193193+ resolveModuleName: ((moduleName: string) => string | undefined) | undefined;
194194+ /**
195195+ * Configuration for generating a copy of the input source used to produce this output.
196196+ */
197197+ source: SourceConfig;
198198+}
199199+200200+/**
201201+ * Core configuration shared across all packages.
202202+ */
203203+export type BaseUserConfig<TOutput extends BaseUserOutput> = {
204204+ /**
205205+ * Path to the config file. Set this value if you don't use the default
206206+ * config file name, or it's not located in the project root.
207207+ */
208208+ configFile?: string;
209209+ /**
210210+ * Skip writing files to disk?
211211+ *
212212+ * @default false
213213+ */
214214+ dryRun?: boolean;
215215+ /**
216216+ * Path to the OpenAPI specification. This can be:
217217+ * - path
218218+ * - URL
219219+ * - API registry shorthand
220220+ *
221221+ * Both JSON and YAML file formats are supported. You can also pass the parsed
222222+ * object directly if you're fetching the file yourself.
223223+ *
224224+ * Alternatively, you can define a configuration object with more options.
225225+ *
226226+ * If you define an array, we will generate a single output from multiple
227227+ * inputs. If you define an array of outputs with the same length, we will
228228+ * generate multiple outputs, one for each input.
229229+ */
230230+ input: MaybeArray<UserInput | Required<UserInput>['path']>;
231231+ /**
232232+ * Show an interactive error reporting tool when the program crashes? You
233233+ * generally want to keep this disabled (default).
234234+ *
235235+ * @default false
236236+ */
237237+ interactive?: boolean;
238238+ /**
239239+ * The relative location of the logs folder.
240240+ *
241241+ * @default process.cwd()
242242+ */
243243+ logs?: string | Logs;
244244+ /**
245245+ * Path to the output folder.
246246+ *
247247+ * If you define an array of outputs with the same length as inputs, we will
248248+ * generate multiple outputs, one for each input.
249249+ */
250250+ output: MaybeArray<string | TOutput>;
251251+ /**
252252+ * Customize how the input is parsed and transformed before it's passed to
253253+ * plugins.
254254+ */
255255+ parser?: UserParser;
256256+ /**
257257+ * @deprecated use `input.watch` instead
258258+ */
259259+ watch?: UserWatch;
260260+};
261261+262262+/**
263263+ * Core configuration shared across all packages.
264264+ */
265265+export type BaseConfig<
266266+ TUserConfig extends object,
267267+ TOutput extends BaseOutput,
268268+> = Omit<
269269+ Required<TUserConfig>,
270270+ 'input' | 'logs' | 'output' | 'parser' | 'plugins' | 'watch'
271271+> & {
272272+ /**
273273+ * Path to the input specification.
274274+ */
275275+ input: ReadonlyArray<Input>;
276276+ logs: Logs;
277277+ /**
278278+ * Path to the output folder.
279279+ */
280280+ output: TOutput;
281281+ /**
282282+ * Customize how the input is parsed and transformed before it's passed to
283283+ * plugins.
284284+ */
285285+ parser: Parser;
286286+ // Loose types - packages override via intersection
287287+ pluginOrder: ReadonlyArray<string>;
288288+ plugins: Record<string, Plugin.Config<Plugin.Types> | undefined>;
289289+};
290290+291291+/**
292292+ * For shared utilities that operate on any config.
293293+ */
294294+export type AnyConfig = BaseConfig<Record<string, unknown>, BaseOutput>;
+63
packages/shared/src/config/utils/dependencies.ts
···11+import type { RangeOptions, SemVer } from 'semver';
22+import * as semver from 'semver';
33+44+export type Dependency = {
55+ /**
66+ * Get the installed version of a package.
77+ * @param name The name of the package to get the version for.
88+ * @returns A SemVer object containing version information, or undefined if the package is not installed
99+ * or the version string is invalid.
1010+ */
1111+ getVersion: (name: string) => SemVer | undefined;
1212+ /**
1313+ * Check if a given package is installed in the project.
1414+ * @param name The name of the package to check.
1515+ */
1616+ isInstalled: (name: string) => boolean;
1717+ /**
1818+ * Check if the installed version of a package or a given SemVer object satisfies a semver range.
1919+ * @param nameOrVersion The name of the package to check, or a SemVer object.
2020+ * @param range The semver range to check against.
2121+ * @returns True if the version satisfies the range, false otherwise.
2222+ */
2323+ satisfies: (
2424+ nameOrVersion: string | SemVer,
2525+ range: string,
2626+ optionsOrLoose?: boolean | RangeOptions,
2727+ ) => boolean;
2828+};
2929+3030+export const satisfies: typeof semver.satisfies = (...args) =>
3131+ semver.satisfies(...args);
3232+3333+export function dependencyFactory(
3434+ dependencies: Record<string, string>,
3535+): Dependency {
3636+ return {
3737+ getVersion: (name) => {
3838+ const version = dependencies[name];
3939+ if (!version) return;
4040+ try {
4141+ let parsed = semver.parse(version);
4242+ if (parsed) return parsed;
4343+4444+ const min = semver.minVersion(version);
4545+ if (min) return min;
4646+4747+ parsed = semver.coerce(version);
4848+ if (parsed) return parsed;
4949+ } catch {
5050+ // noop
5151+ }
5252+ return;
5353+ },
5454+ isInstalled: (name) => Boolean(dependencies[name]),
5555+ satisfies: (nameOrVersion, range, optionsOrLoose) => {
5656+ const version =
5757+ typeof nameOrVersion === 'string'
5858+ ? dependencies[nameOrVersion]
5959+ : nameOrVersion;
6060+ return version ? satisfies(version, range, optionsOrLoose) : false;
6161+ },
6262+ };
6363+}
+136
packages/shared/src/index.ts
···11+export { printCliIntro } from './cli';
22+export { checkNodeVersion } from './config/engine';
33+export { getInput } from './config/input/input';
44+export { compileInputPath, logInputPaths } from './config/input/path';
55+export type { Input, UserInput, UserWatch, Watch } from './config/input/types';
66+export { getLogs } from './config/logs';
77+export type {
88+ PostProcessor,
99+ UserPostProcessor,
1010+} from './config/output/postprocess';
1111+export { postprocessOutput } from './config/output/postprocess';
1212+export { resolveSource } from './config/output/source/config';
1313+export type {
1414+ SourceConfig,
1515+ UserSourceConfig,
1616+} from './config/output/source/types';
1717+export type { OutputHeader } from './config/output/types';
1818+export { defaultPaginationKeywords, getParser } from './config/parser/config';
1919+export type { Filters } from './config/parser/filters';
2020+export type { Patch } from './config/parser/patch';
2121+export type { Parser, UserParser } from './config/parser/types';
2222+export type {
2323+ AnyConfig,
2424+ BaseConfig,
2525+ BaseOutput,
2626+ BaseUserConfig,
2727+ BaseUserOutput,
2828+ FeatureToggle,
2929+ IndexExportOption,
3030+ NamingOptions,
3131+} from './config/shared';
3232+export type { ValueToObject } from './config/utils/config';
3333+export { valueToObject } from './config/utils/config';
3434+export type { Dependency } from './config/utils/dependencies';
3535+export { dependencyFactory, satisfies } from './config/utils/dependencies';
3636+export { debugTools } from './debug';
3737+export {
3838+ ConfigError,
3939+ ConfigValidationError,
4040+ HeyApiError,
4141+ JobError,
4242+ logCrashReport,
4343+ openGitHubIssueWithCrashReport,
4444+ printCrashReport,
4545+ shouldReportCrash,
4646+} from './error';
4747+export { ensureDirSync } from './fs';
4848+export { getSpec } from './getSpec';
4949+export { Context } from './ir/context';
5050+export { IntentContext } from './ir/intents';
5151+export {
5252+ createOperationKey,
5353+ hasOperationDataRequired,
5454+ operationPagination,
5555+ operationResponsesMap,
5656+ statusCodeToGroup,
5757+} from './ir/operation';
5858+export {
5959+ hasParameterGroupObjectRequired,
6060+ hasParametersObjectRequired,
6161+ parameterWithPagination,
6262+} from './ir/parameter';
6363+export { deduplicateSchema } from './ir/schema';
6464+export type { IR } from './ir/types';
6565+export { parseOpenApiSpec } from './openApi';
6666+export type { OpenApiV2_0_X, OpenApiV2_0_XTypes } from './openApi/2.0.x';
6767+export { parseV2_0_X } from './openApi/2.0.x';
6868+export type { OpenApiV3_0_X, OpenApiV3_0_XTypes } from './openApi/3.0.x';
6969+export { parseV3_0_X } from './openApi/3.0.x';
7070+export type { OpenApiV3_1_X, OpenApiV3_1_XTypes } from './openApi/3.1.x';
7171+export { parseV3_1_X } from './openApi/3.1.x';
7272+export type { OperationsStrategy } from './openApi/shared/locations';
7373+export type {
7474+ OperationPathStrategy,
7575+ OperationStructureStrategy,
7676+} from './openApi/shared/locations';
7777+export { OperationPath, OperationStrategy } from './openApi/shared/locations';
7878+export type {
7979+ CodeSampleObject,
8080+ EnumExtensions,
8181+ LinguistLanguages,
8282+} from './openApi/shared/types/openapi-spec-extensions';
8383+export { buildGraph } from './openApi/shared/utils/graph';
8484+export { patchOpenApiSpec } from './openApi/shared/utils/patch';
8585+export type {
8686+ OpenApi,
8787+ OpenApiMetaObject,
8888+ OpenApiOperationObject,
8989+ OpenApiParameterObject,
9090+ OpenApiRequestBodyObject,
9191+ OpenApiResponseObject,
9292+ OpenApiSchemaObject,
9393+} from './openApi/types';
9494+export type { Hooks } from './parser/hooks';
9595+export type { SchemaWithType } from './plugins/shared/types/schema';
9696+export { definePluginConfig, mappers } from './plugins/shared/utils/config';
9797+export type { PluginInstanceTypes } from './plugins/shared/utils/instance';
9898+export { PluginInstance } from './plugins/shared/utils/instance';
9999+export type {
100100+ AnyPluginName,
101101+ DefinePlugin,
102102+ Plugin,
103103+ PluginConfigMap,
104104+ PluginContext,
105105+ PluginNames,
106106+} from './plugins/types';
107107+export {
108108+ findPackageJson,
109109+ findTsConfigPath,
110110+ loadPackageJson,
111111+ loadTsConfig,
112112+} from './tsConfig';
113113+export type { Logs } from './types/logs';
114114+export type { WatchValues } from './types/watch';
115115+export { escapeComment } from './utils/escape';
116116+export { utils } from './utils/exports';
117117+export { inputToApiRegistry } from './utils/input';
118118+export { heyApiRegistryBaseUrl } from './utils/input/heyApi';
119119+export { MinHeap } from './utils/minHeap';
120120+export { applyNaming, resolveNaming, toCase } from './utils/naming/naming';
121121+export type {
122122+ Casing,
123123+ NameTransformer,
124124+ NamingConfig,
125125+ NamingRule,
126126+} from './utils/naming/types';
127127+export {
128128+ encodeJsonPointerSegment,
129129+ isTopLevelComponentRef,
130130+ jsonPointerToPath,
131131+ normalizeJsonPointer,
132132+ pathToJsonPointer,
133133+ refToName,
134134+ resolveRef,
135135+} from './utils/ref';
136136+export { parseUrl } from './utils/url';
···11#!/usr/bin/env bash
2233-result=$(pnpx turbo run build --affected --dry-run=json 2>&1)
33+result=$(pnpm turbo run build --affected --dry-run=json 2>&1)
4455-# turbo may emit warnings or other text before the JSON output. Extract the
66-# first JSON object/array found in the output so `jq` can parse it safely.
75json=$(printf '%s\n' "$result" | awk '/^{/ {flag=1} flag {print}')
8697if [ -z "$json" ]; then
108 echo "Error: no JSON output from turbo; aborting." >&2
99+ echo "Raw result was:"
1010+ echo "$result"
1111 exit 1
1212fi
13131414+echo "Affected tasks:"
1515+echo "$json" | jq -r '.tasks[].directory'
1616+1417packages=$(echo "$json" | jq -r '.tasks[].directory' | grep '^packages/' | while read -r dir; do
1518 if [ "$(jq -r '.private' "$dir/package.json")" != "true" ]; then
1619 echo "./$dir"
1720 fi
1821done)
19222323+echo "Packages to publish:"
2424+echo "$packages"
2525+2026if [ -n "$packages" ]; then
2127 pnpx pkg-pr-new publish --pnpm $packages
2828+else
2929+ echo "No packages to publish"
2230fi