fork of hey-api/openapi-ts because I need some additional things
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #3179 from hey-api/refactor/plugin-types

refactor: compose plugin types

authored by

Lubos and committed by
GitHub
37ae25a8 720c012c

+1775 -2841
+1 -1
dev/openapi-ts.config.ts
··· 141 141 // callback(source) { 142 142 // console.log('Source generated, length:', source.length); 143 143 // }, 144 - // enabled: false, 144 + enabled: false, 145 145 // extension: 'yaml', 146 146 // fileName: 'spec', 147 147 // path: null,
+5 -9
packages/openapi-ts/src/config/output/source/types.d.ts
··· 1 1 import type { MaybePromise } from '~/types/utils'; 2 2 3 + import type { FeatureToggle } from '../../shared'; 4 + 3 5 // TODO: json-schema-ref-parser needs to expose source extension so 4 6 // we can default to it 5 7 type SourceExtension = 'json'; ··· 16 18 */ 17 19 callback?: (source: string) => MaybePromise<void>; 18 20 /** 19 - * Whether the source should be generated at all. 20 - * 21 - * When `false`, no source file is created or processed. 21 + * Whether this feature is enabled. 22 22 * 23 23 * @default true 24 24 */ ··· 60 60 serialize?: (input: Record<string, any>) => MaybePromise<string>; 61 61 } 62 62 63 - export interface SourceConfig { 63 + export type SourceConfig = FeatureToggle & { 64 64 /** 65 65 * Callback invoked with the serialized source string. 66 66 * 67 67 * Runs after the `serialize` function. 68 68 */ 69 69 callback?: (source: string) => MaybePromise<void>; 70 - /** 71 - * Whether the source should be generated at all. 72 - */ 73 - enabled: boolean; 74 70 /** 75 71 * File extension for the source file. 76 72 */ ··· 87 83 * Function to serialize the input object into a string. 88 84 */ 89 85 serialize: (input: Record<string, any>) => MaybePromise<string>; 90 - } 86 + };
+4 -11
packages/openapi-ts/src/config/output/types.d.ts
··· 7 7 import type { MaybeArray, MaybeFunc } from '~/types/utils'; 8 8 import type { Casing, NameTransformer } from '~/utils/naming'; 9 9 10 + import type { NamingOptions } from '../shared'; 10 11 import type { SourceConfig, UserSourceConfig } from './source/types'; 11 12 12 13 export type Formatters = 'biome' | 'prettier'; ··· 47 48 | NameTransformer 48 49 | { 49 50 /** 50 - * The casing convention to use for generated file names. 51 + * Casing convention for generated names. 51 52 * 52 53 * @default 'preserve' 53 54 */ 54 55 case?: Casing; 55 56 /** 56 - * Custom naming pattern for generated file names. 57 + * Naming pattern for generated names. 57 58 * 58 59 * @default '{{name}}' 59 60 */ ··· 166 167 * @param name The original file name. 167 168 * @returns The transformed file name. 168 169 */ 169 - fileName: { 170 - /** 171 - * The casing convention to use for generated file names. 172 - */ 173 - case: Casing; 174 - /** 175 - * Custom naming pattern for generated file names. 176 - */ 177 - name: NameTransformer; 170 + fileName: NamingOptions & { 178 171 /** 179 172 * Suffix to append to file names (before the extension). For example, 180 173 * with a suffix of `.gen`, `example.ts` becomes `example.gen.ts`.
+26
packages/openapi-ts/src/config/shared.d.ts
··· 1 + import type { Casing, NameTransformer } from '~/utils/naming'; 2 + 3 + export type FeatureToggle = { 4 + /** 5 + * Whether this feature is enabled. 6 + */ 7 + enabled: boolean; 8 + }; 9 + 10 + export type IndexExportOption = { 11 + /** 12 + * Whether exports should be re-exported in the index file. 13 + */ 14 + exportFromIndex: boolean; 15 + }; 16 + 17 + export type NamingOptions = { 18 + /** 19 + * Casing convention for generated names. 20 + */ 21 + case: Casing; 22 + /** 23 + * Naming pattern for generated names. 24 + */ 25 + name: NameTransformer; 26 + };
+4 -7
packages/openapi-ts/src/plugins/@angular/common/httpRequests/types.d.ts
··· 1 + import type { FeatureToggle } from '~/config/shared'; 1 2 import type { 2 3 OperationPathStrategy, 3 4 OperationsStrategy, ··· 37 38 */ 38 39 containerName?: NamingRule; 39 40 /** 40 - * Whether or not to create HTTP Request instances. 41 + * Whether this feature is enabled. 41 42 * 42 43 * @default true 43 44 */ ··· 103 104 strategyDefaultTag?: string; 104 105 } 105 106 106 - export interface HttpRequestsConfig { 107 + export type HttpRequestsConfig = FeatureToggle & { 107 108 /** 108 109 * Type of container for grouped operations. 109 110 * ··· 134 135 */ 135 136 containerName: NamingConfig; 136 137 /** 137 - * Whether or not to create HTTP Request instances. 138 - */ 139 - enabled: boolean; 140 - /** 141 138 * Customize method/function names. 142 139 * 143 140 * Applied to the final segment of the path (the method name). ··· 186 183 * Only applies when `strategy` is `'byTags'`. 187 184 */ 188 185 strategyDefaultTag: string; 189 - } 186 + };
+4 -7
packages/openapi-ts/src/plugins/@angular/common/httpResources/types.d.ts
··· 1 + import type { FeatureToggle } from '~/config/shared'; 1 2 import type { 2 3 OperationPathStrategy, 3 4 OperationsStrategy, ··· 37 38 */ 38 39 containerName?: NamingRule; 39 40 /** 40 - * Whether or not to create HTTP resource APIs. 41 + * Whether this feature is enabled. 41 42 * 42 43 * @default true 43 44 */ ··· 103 104 strategyDefaultTag?: string; 104 105 } 105 106 106 - export interface HttpResourcesConfig { 107 + export type HttpResourcesConfig = FeatureToggle & { 107 108 /** 108 109 * Type of container for grouped operations. 109 110 * ··· 134 135 */ 135 136 containerName: NamingConfig; 136 137 /** 137 - * Whether or not to create HTTP resource APIs. 138 - */ 139 - enabled: boolean; 140 - /** 141 138 * Customize method/function names. 142 139 * 143 140 * Applied to the final segment of the path (the method name). ··· 186 183 * Only applies when `strategy` is `'byTags'`. 187 184 */ 188 185 strategyDefaultTag: string; 189 - } 186 + };
+4 -10
packages/openapi-ts/src/plugins/@angular/common/types.d.ts
··· 1 + import type { IndexExportOption } from '~/config/shared'; 1 2 import type { OperationsStrategy } from '~/openApi/shared/locations'; 2 3 import type { DefinePlugin, Plugin } from '~/plugins'; 3 4 ··· 13 14 export type UserConfig = Plugin.Name<'@angular/common'> & 14 15 Plugin.Hooks & { 15 16 /** 16 - * Should the exports from the generated files be re-exported in the index 17 - * barrel file? 17 + * Whether exports should be re-exported in the index file. 18 18 * 19 19 * @default false 20 20 */ ··· 34 34 }; 35 35 36 36 export type Config = Plugin.Name<'@angular/common'> & 37 - Plugin.Hooks & { 38 - /** 39 - * Should the exports from the generated files be re-exported in the index 40 - * barrel file? 41 - * 42 - * @default false 43 - */ 44 - exportFromIndex: boolean; 37 + Plugin.Hooks & 38 + IndexExportOption & { 45 39 /** 46 40 * Options for generating HTTP Request instances. 47 41 */
+31
packages/openapi-ts/src/plugins/@faker-js/faker/api.ts
··· 1 + import type { IR } from '~/ir/types'; 2 + import type { $ } from '~/ts-dsl'; 3 + 4 + type Expression = ReturnType<typeof $.expr>; 5 + 6 + export type IApi = { 7 + /** 8 + * Generate a Faker expression for a schema. 9 + * 10 + * Returns an expression that, when executed, produces a valid instance. 11 + */ 12 + generateValue(schema: IR.SchemaObject): Expression; 13 + /** 14 + * Get a reference to an exported generator function. 15 + * 16 + * Returns an identifier that can be called, e.g., `fakeUser()` 17 + */ 18 + getGeneratorRef(schema: IR.SchemaObject): Expression; 19 + }; 20 + 21 + export class Api implements IApi { 22 + // eslint-disable-next-line @typescript-eslint/no-unused-vars 23 + generateValue(_schema: IR.SchemaObject): Expression { 24 + return undefined as any; 25 + } 26 + 27 + // eslint-disable-next-line @typescript-eslint/no-unused-vars 28 + getGeneratorRef(_schema: IR.SchemaObject): Expression { 29 + return undefined as any; 30 + } 31 + }
+37
packages/openapi-ts/src/plugins/@faker-js/faker/config.ts
··· 1 + import { definePluginConfig } from '~/plugins/shared/utils/config'; 2 + 3 + import { Api } from './api'; 4 + // import { handler } from './plugin'; 5 + import type { FakerJsFakerPlugin } from './types'; 6 + 7 + export const defaultConfig: FakerJsFakerPlugin['Config'] = { 8 + api: new Api(), 9 + config: { 10 + case: 'camelCase', 11 + exportFromIndex: false, 12 + }, 13 + // handler, 14 + handler: () => {}, 15 + name: '@faker-js/faker', 16 + resolveConfig: (plugin, context) => { 17 + plugin.config.definitions = context.valueToObject({ 18 + defaultValue: { 19 + case: plugin.config.case ?? 'camelCase', 20 + enabled: true, 21 + name: 'v{{name}}', 22 + }, 23 + mappers: { 24 + boolean: (enabled) => ({ enabled }), 25 + function: (name) => ({ name }), 26 + string: (name) => ({ name }), 27 + }, 28 + value: plugin.config.definitions, 29 + }); 30 + }, 31 + tags: ['mocker'], 32 + }; 33 + 34 + /** 35 + * Type helper for Faker plugin, returns {@link Plugin.Config} object 36 + */ 37 + export const defineConfig = definePluginConfig(defaultConfig);
+2
packages/openapi-ts/src/plugins/@faker-js/faker/index.ts
··· 1 + export { defaultConfig, defineConfig } from './config'; 2 + export type { FakerJsFakerPlugin } from './types';
+56
packages/openapi-ts/src/plugins/@faker-js/faker/resolvers/types.d.ts
··· 1 + // TODO: later 2 + import type { Symbol } from '@hey-api/codegen-core'; 3 + 4 + import type { Plugin, SchemaWithType } from '~/plugins'; 5 + import type { $, DollarTsDsl } from '~/ts-dsl'; 6 + 7 + import type { FakerJsFakerPlugin } from '../types'; 8 + 9 + type Expression = ReturnType<typeof $.expr>; 10 + 11 + export type Resolvers = Plugin.Resolvers<{ 12 + array?: (ctx: ArrayResolverContext) => Expression | undefined; 13 + number?: (ctx: NumberResolverContext) => Expression | undefined; 14 + object?: (ctx: ObjectResolverContext) => Expression | undefined; 15 + string?: (ctx: StringResolverContext) => Expression | undefined; 16 + }>; 17 + 18 + interface BaseContext extends DollarTsDsl { 19 + plugin: FakerJsFakerPlugin['Instance']; 20 + symbols: { 21 + faker: Symbol; 22 + }; 23 + } 24 + 25 + export interface ArrayResolverContext extends BaseContext { 26 + nodes: { 27 + items: (ctx: ArrayResolverContext) => Expression; 28 + length: (ctx: ArrayResolverContext) => Expression | undefined; 29 + }; 30 + schema: SchemaWithType<'array'>; 31 + } 32 + 33 + export interface NumberResolverContext extends BaseContext { 34 + nodes: { 35 + base: (ctx: NumberResolverContext) => Expression; 36 + max: (ctx: NumberResolverContext) => Expression | undefined; 37 + min: (ctx: NumberResolverContext) => Expression | undefined; 38 + }; 39 + schema: SchemaWithType<'integer' | 'number'>; 40 + } 41 + 42 + export interface ObjectResolverContext extends BaseContext { 43 + nodes: { 44 + properties: (ctx: ObjectResolverContext) => Expression; 45 + }; 46 + schema: SchemaWithType<'object'>; 47 + } 48 + 49 + export interface StringResolverContext extends BaseContext { 50 + nodes: { 51 + base: (ctx: StringResolverContext) => Expression; 52 + format: (ctx: StringResolverContext) => Expression | undefined; 53 + pattern: (ctx: StringResolverContext) => Expression | undefined; 54 + }; 55 + schema: SchemaWithType<'string'>; 56 + }
+93
packages/openapi-ts/src/plugins/@faker-js/faker/types.d.ts
··· 1 + import type { 2 + FeatureToggle, 3 + IndexExportOption, 4 + NamingOptions, 5 + } from '~/config/shared'; 6 + import type { DefinePlugin, Plugin } from '~/plugins'; 7 + import type { Casing, NameTransformer } from '~/utils/naming'; 8 + 9 + import type { IApi } from './api'; 10 + 11 + export type UserConfig = Plugin.Name<'@faker-js/faker'> & 12 + Plugin.Hooks & { 13 + // Resolvers & { 14 + /** 15 + * Casing convention for generated names. 16 + * 17 + * @default 'camelCase' 18 + */ 19 + case?: Casing; 20 + /** 21 + * Configuration for reusable schema definitions. 22 + * 23 + * Can be: 24 + * - `boolean`: Shorthand for `{ enabled: boolean }` 25 + * - `string` or `function`: Shorthand for `{ name: string | function }` 26 + * - `object`: Full configuration object 27 + */ 28 + definitions?: 29 + | boolean 30 + | NameTransformer 31 + | { 32 + /** 33 + * Casing convention for generated names. 34 + * 35 + * @default 'camelCase' 36 + */ 37 + case?: Casing; 38 + /** 39 + * Whether this feature is enabled. 40 + * 41 + * @default true 42 + */ 43 + enabled?: boolean; 44 + /** 45 + * Naming pattern for generated names. 46 + * 47 + * @default 'fake{{name}}' 48 + */ 49 + name?: NameTransformer; 50 + }; 51 + /** 52 + * Whether exports should be re-exported in the index file. 53 + * 54 + * @default false 55 + */ 56 + exportFromIndex?: boolean; 57 + /** 58 + * Faker locale for generated data. 59 + * 60 + * @default 'en' 61 + */ 62 + locale?: string; 63 + /** 64 + * Seed for deterministic output. When set, Faker will produce 65 + * the same values across runs. 66 + */ 67 + seed?: number; 68 + }; 69 + 70 + export type Config = Plugin.Name<'@faker-js/faker'> & 71 + Plugin.Hooks & 72 + IndexExportOption & { 73 + // Resolvers & { 74 + /** 75 + * Casing convention for generated names. 76 + */ 77 + case: Casing; 78 + /** 79 + * Configuration for reusable schema definitions. 80 + */ 81 + definitions: NamingOptions & FeatureToggle; 82 + /** 83 + * Faker locale for generated data. 84 + */ 85 + locale: string; 86 + /** 87 + * Seed for deterministic output. When set, Faker will produce 88 + * the same values across runs. 89 + */ 90 + seed?: number; 91 + }; 92 + 93 + export type FakerJsFakerPlugin = DefinePlugin<UserConfig, Config, IApi>;
+1 -2
packages/openapi-ts/src/plugins/@hey-api/client-core/types.d.ts
··· 42 42 */ 43 43 bundle?: boolean; 44 44 /** 45 - * Should the exports from the generated files be re-exported in the index 46 - * barrel file? 45 + * Whether exports should be re-exported in the index file. 47 46 * 48 47 * @default false 49 48 */
+1 -2
packages/openapi-ts/src/plugins/@hey-api/schemas/types.d.ts
··· 6 6 export type UserConfig = Plugin.Name<'@hey-api/schemas'> & 7 7 Plugin.Hooks & { 8 8 /** 9 - * Should the exports from the generated files be re-exported in the index 10 - * barrel file? 9 + * Whether exports should be re-exported in the index file. 11 10 * 12 11 * @default false 13 12 */
+31 -33
packages/openapi-ts/src/plugins/@hey-api/sdk/examples/types.d.ts
··· 1 + import type { FeatureToggle } from '~/config/shared'; 1 2 import type { IR } from '~/ir/types'; 2 3 import type { LinguistLanguages } from '~/openApi/shared/types'; 3 4 import type { CallArgs, DollarTsDsl, ExampleOptions } from '~/ts-dsl'; 4 5 import type { MaybeFunc } from '~/types/utils'; 5 6 6 - export interface UserExamplesConfig extends ExampleOptions { 7 + export type UserExamplesConfig = Omit<ExampleOptions, 'payload'> & { 7 8 /** 8 - * Whether to generate SDK code examples. 9 + * Whether this feature is enabled. 9 10 * 10 11 * @default true 11 12 */ ··· 36 37 * @returns The final example string. 37 38 */ 38 39 transform?: (example: string, operation: IR.OperationObject) => string; 39 - } 40 + }; 40 41 41 - export interface ExamplesConfig extends ExampleOptions { 42 - /** 43 - * Whether to generate SDK code examples. 44 - */ 45 - enabled: boolean; 46 - /** 47 - * The programming language for the generated examples. 48 - * 49 - * This is used to display the language label in code blocks in 50 - * documentation UIs. 51 - */ 52 - language: LinguistLanguages; 53 - /** 54 - * Example request payload. 55 - */ 56 - payload?: MaybeFunc< 57 - ( 58 - operation: IR.OperationObject, 59 - ctx: DollarTsDsl, 60 - ) => CallArgs | CallArgs[number] 61 - >; 62 - /** 63 - * Transform the generated example string. 64 - * 65 - * @param example The generated example string. 66 - * @param operation The operation the example was generated for. 67 - * @returns The final example string. 68 - */ 69 - transform?: (example: string, operation: IR.OperationObject) => string; 70 - } 42 + export type ExamplesConfig = Omit<ExampleOptions, 'payload'> & 43 + FeatureToggle & { 44 + /** 45 + * The programming language for the generated examples. 46 + * 47 + * This is used to display the language label in code blocks in 48 + * documentation UIs. 49 + */ 50 + language: LinguistLanguages; 51 + /** 52 + * Example request payload. 53 + */ 54 + payload?: MaybeFunc< 55 + ( 56 + operation: IR.OperationObject, 57 + ctx: DollarTsDsl, 58 + ) => CallArgs | CallArgs[number] 59 + >; 60 + /** 61 + * Transform the generated example string. 62 + * 63 + * @param example The generated example string. 64 + * @param operation The operation the example was generated for. 65 + * @returns The final example string. 66 + */ 67 + transform?: (example: string, operation: IR.OperationObject) => string; 68 + };
+4 -10
packages/openapi-ts/src/plugins/@hey-api/sdk/types.d.ts
··· 1 + import type { IndexExportOption } from '~/config/shared'; 1 2 import type { OperationsStrategy } from '~/openApi/shared/locations'; 2 3 import type { DefinePlugin, Plugin } from '~/plugins'; 3 4 import type { PluginClientNames, PluginValidatorNames } from '~/plugins/types'; ··· 39 40 */ 40 41 examples?: boolean | UserExamplesConfig; 41 42 /** 42 - * Should the exports from the generated files be re-exported in the index 43 - * barrel file? 43 + * Whether exports should be re-exported in the index file. 44 44 * 45 45 * @default true 46 46 */ ··· 199 199 }; 200 200 201 201 export type Config = Plugin.Name<'@hey-api/sdk'> & 202 - Plugin.Hooks & { 202 + Plugin.Hooks & 203 + IndexExportOption & { 203 204 /** 204 205 * Should the generated functions contain auth mechanisms? You may want to 205 206 * disable this option if you're handling auth yourself or defining it ··· 224 225 * Configuration for generating SDK code examples. 225 226 */ 226 227 examples: ExamplesConfig; 227 - /** 228 - * Should the exports from the generated files be re-exported in the index 229 - * barrel file? 230 - * 231 - * @default true 232 - */ 233 - exportFromIndex: boolean; 234 228 /** 235 229 * Define the structure of generated SDK operations. 236 230 */
+4 -10
packages/openapi-ts/src/plugins/@hey-api/transformers/types.d.ts
··· 1 1 import type ts from 'typescript'; 2 2 3 + import type { IndexExportOption } from '~/config/shared'; 3 4 import type { IR } from '~/ir/types'; 4 5 import type { DefinePlugin, Plugin } from '~/plugins'; 5 6 ··· 30 31 */ 31 32 dates?: boolean; 32 33 /** 33 - * Should the exports from the generated files be re-exported in the index 34 - * barrel file? 34 + * Whether exports should be re-exported in the index file. 35 35 * 36 36 * @default false 37 37 */ ··· 47 47 }; 48 48 49 49 export type Config = Plugin.Name<'@hey-api/transformers'> & 50 - Plugin.Hooks & { 50 + Plugin.Hooks & 51 + IndexExportOption & { 51 52 /** 52 53 * Convert long integers into BigInt values? 53 54 * ··· 60 61 * @default true 61 62 */ 62 63 dates: boolean; 63 - /** 64 - * Should the exports from the generated files be re-exported in the index 65 - * barrel file? 66 - * 67 - * @default false 68 - */ 69 - exportFromIndex: boolean; 70 64 /** 71 65 * Custom transforms to apply to the generated code. 72 66 */
+35 -131
packages/openapi-ts/src/plugins/@hey-api/typescript/types.d.ts
··· 1 + import type { 2 + FeatureToggle, 3 + IndexExportOption, 4 + NamingOptions, 5 + } from '~/config/shared'; 1 6 import type { DefinePlugin, Plugin } from '~/plugins'; 2 7 import type { Casing, NameTransformer } from '~/utils/naming'; 3 8 ··· 8 13 export type UserConfig = Plugin.Name<'@hey-api/typescript'> & 9 14 Plugin.Hooks & { 10 15 /** 11 - * The casing convention to use for generated names. 16 + * Casing convention for generated names. 12 17 * 13 18 * @default 'PascalCase' 14 19 */ ··· 29 34 | NameTransformer 30 35 | { 31 36 /** 32 - * The casing convention to use for generated definition names. 37 + * Casing convention for generated names. 33 38 * 34 39 * @default 'PascalCase' 35 40 */ 36 41 case?: Casing; 37 42 /** 38 - * Custom naming pattern for generated definition names. The name variable 39 - * is obtained from the schema name. 43 + * Naming pattern for generated names. 40 44 * 41 45 * @default '{{name}}' 42 46 */ ··· 56 60 | EnumsType 57 61 | { 58 62 /** 59 - * The casing convention to use for generated names. 63 + * Casing convention for generated names. 60 64 * 61 65 * @default 'SCREAMING_SNAKE_CASE' 62 66 */ ··· 72 76 */ 73 77 constantsIgnoreNull?: boolean; 74 78 /** 75 - * Whether to generate runtime enums. 79 + * Whether this feature is enabled. 76 80 * 77 81 * @default true 78 82 */ ··· 104 108 | NameTransformer 105 109 | { 106 110 /** 107 - * The casing convention to use for generated error type names. 111 + * Casing convention for generated names. 108 112 * 109 113 * @default 'PascalCase' 110 114 */ 111 115 case?: Casing; 112 116 /** 113 - * Custom naming pattern for generated error type names. The name 114 - * variable is obtained from the operation name. 117 + * Naming pattern for generated names. 115 118 * 116 119 * @default '{{name}}Error' 117 120 */ 118 121 error?: NameTransformer; 119 122 /** 120 - * Custom naming pattern for generated error type names. The name 121 - * variable is obtained from the operation name. 123 + * Naming pattern for generated names. 122 124 * 123 125 * @default '{{name}}Errors' 124 126 */ 125 127 name?: NameTransformer; 126 128 }; 127 129 /** 128 - * Should the exports from the generated files be re-exported in the index 129 - * barrel file? 130 + * Whether exports should be re-exported in the index file. 130 131 * 131 132 * @default true 132 133 */ ··· 147 148 | NameTransformer 148 149 | { 149 150 /** 150 - * The casing convention to use for generated request type names. 151 + * Casing convention for generated names. 151 152 * 152 153 * @default 'PascalCase' 153 154 */ 154 155 case?: Casing; 155 156 /** 156 - * Custom naming pattern for generated request type names. The name 157 - * variable is obtained from the operation name. 157 + * Naming pattern for generated names. 158 158 * 159 159 * @default '{{name}}Data' 160 160 */ ··· 175 175 | NameTransformer 176 176 | { 177 177 /** 178 - * The casing convention to use for generated response type names. 178 + * Casing convention for generated names. 179 179 * 180 180 * @default 'PascalCase' 181 181 */ 182 182 case?: Casing; 183 183 /** 184 - * Custom naming pattern for generated response type names. The name 185 - * variable is obtained from the operation name. 184 + * Naming pattern for generated names. 186 185 * 187 186 * @default '{{name}}Responses' 188 187 */ 189 188 name?: NameTransformer; 190 189 /** 191 - * Custom naming pattern for generated response type names. The name 192 - * variable is obtained from the operation name. 190 + * Naming pattern for generated names. 193 191 * 194 192 * @default '{{name}}Response' 195 193 */ ··· 220 218 | NameTransformer 221 219 | { 222 220 /** 223 - * The casing convention to use for generated webhook type names. 221 + * Casing convention for generated names. 224 222 * 225 223 * @default 'PascalCase' 226 224 */ 227 225 case?: Casing; 228 226 /** 229 - * Custom naming pattern for generated webhook type names. The name 230 - * variable is obtained from the webhook key. 227 + * Naming pattern for generated names. 231 228 * 232 229 * @default '{{name}}WebhookRequest' 233 230 */ 234 231 name?: NameTransformer; 235 232 /** 236 - * Custom naming pattern for generated webhook type names. The name 237 - * variable is obtained from the webhook key. 233 + * Naming pattern for generated names. 238 234 * 239 235 * @default '{{name}}WebhookPayload' 240 236 */ ··· 243 239 }; 244 240 245 241 export type Config = Plugin.Name<'@hey-api/typescript'> & 246 - Plugin.Hooks & { 242 + Plugin.Hooks & 243 + IndexExportOption & { 247 244 /** 248 - * The casing convention to use for generated names. 249 - * 250 - * @default 'PascalCase' 245 + * Casing convention for generated names. 251 246 */ 252 247 case: Exclude<Casing, 'SCREAMING_SNAKE_CASE'>; 253 248 /** ··· 256 251 * Controls generation of shared types that can be referenced across 257 252 * requests and responses. 258 253 */ 259 - definitions: { 260 - /** 261 - * The casing convention to use for generated definition names. 262 - * 263 - * @default 'PascalCase' 264 - */ 265 - case: Casing; 266 - /** 267 - * Custom naming pattern for generated definition names. The name variable 268 - * is obtained from the schema name. 269 - * 270 - * @default '{{name}}' 271 - */ 272 - name: NameTransformer; 273 - }; 254 + definitions: NamingOptions; 274 255 /** 275 256 * By default, enums are emitted as types to preserve runtime-free output. 276 257 * ··· 278 259 * TypeScript enums for runtime usage, interoperability, or integration with 279 260 * other tools. 280 261 */ 281 - enums: { 262 + enums: FeatureToggle & { 282 263 /** 283 - * The casing convention to use for generated names. 284 - * 285 - * @default 'SCREAMING_SNAKE_CASE' 264 + * Casing convention for generated names. 286 265 */ 287 266 case: Casing; 288 267 /** ··· 295 274 * @default false 296 275 */ 297 276 constantsIgnoreNull: boolean; 298 - /** 299 - * Whether to generate runtime enums. 300 - * 301 - * @default false 302 - */ 303 - enabled: boolean; 304 277 /** 305 278 * Specifies the output mode for generated enums. 306 279 * ··· 322 295 * - `string` or `function`: Shorthand for `{ name: string | function }` 323 296 * - `object`: Full configuration object 324 297 */ 325 - errors: { 298 + errors: NamingOptions & { 326 299 /** 327 - * The casing convention to use for generated error type names. 328 - * 329 - * @default 'PascalCase' 330 - */ 331 - case: Casing; 332 - /** 333 - * Custom naming pattern for generated error type names. The name 334 - * variable is obtained from the operation name. 335 - * 336 - * @default '{{name}}Error' 300 + * Naming pattern for generated names. 337 301 */ 338 302 error: NameTransformer; 339 - /** 340 - * Custom naming pattern for generated error type names. The name 341 - * variable is obtained from the operation name. 342 - * 343 - * @default '{{name}}Errors' 344 - */ 345 - name: NameTransformer; 346 303 }; 347 304 /** 348 - * Should the exports from the generated files be re-exported in the index 349 - * barrel file? 350 - * 351 - * @default true 352 - */ 353 - exportFromIndex: boolean; 354 - /** 355 305 * Configuration for request-specific types. 356 306 * 357 307 * Controls generation of types for request bodies, query parameters, path 358 308 * parameters, and headers. 359 309 */ 360 - requests: { 361 - /** 362 - * The casing convention to use for generated request type names. 363 - * 364 - * @default 'PascalCase' 365 - */ 366 - case: Casing; 367 - /** 368 - * Custom naming pattern for generated request type names. The name 369 - * variable is obtained from the operation name. 370 - * 371 - * @default '{{name}}Data' 372 - */ 373 - name: NameTransformer; 374 - }; 310 + requests: NamingOptions; 375 311 /** 376 312 * Configuration for response-specific types. 377 313 * 378 314 * Controls generation of types for response bodies and status codes. 379 315 */ 380 - responses: { 316 + responses: NamingOptions & { 381 317 /** 382 - * The casing convention to use for generated response type names. 383 - * 384 - * @default 'PascalCase' 385 - */ 386 - case: Casing; 387 - /** 388 - * Custom naming pattern for generated response type names. The name 389 - * variable is obtained from the operation name. 390 - * 391 - * @default '{{name}}Responses' 392 - */ 393 - name: NameTransformer; 394 - /** 395 - * Custom naming pattern for generated response type names. The name 396 - * variable is obtained from the operation name. 397 - * 398 - * @default '{{name}}Response' 318 + * Naming pattern for generated names. 399 319 */ 400 320 response: NameTransformer; 401 321 }; ··· 410 330 * 411 331 * Controls generation of types for webhook payloads and webhook requests. 412 332 */ 413 - webhooks: { 414 - /** 415 - * The casing convention to use for generated webhook type names. 416 - * 417 - * @default 'PascalCase' 418 - */ 419 - case: Casing; 420 - /** 421 - * Custom naming pattern for generated webhook type names. The name 422 - * variable is obtained from the webhook key. 423 - * 424 - * @default '{{name}}WebhookRequest' 425 - */ 426 - name: NameTransformer; 333 + webhooks: NamingOptions & { 427 334 /** 428 - * Custom naming pattern for generated webhook type names. The name 429 - * variable is obtained from the webhook key. 430 - * 431 - * @default '{{name}}WebhookPayload' 335 + * Naming pattern for generated names. 432 336 */ 433 337 payload: NameTransformer; 434 338 };
+85 -145
packages/openapi-ts/src/plugins/@pinia/colada/types.d.ts
··· 1 + import type { 2 + FeatureToggle, 3 + IndexExportOption, 4 + NamingOptions, 5 + } from '~/config/shared'; 1 6 import type { IR } from '~/ir/types'; 2 7 import type { DefinePlugin, Plugin } from '~/plugins'; 3 8 import type { Casing, NameTransformer } from '~/utils/naming'; ··· 5 10 export type UserConfig = Plugin.Name<'@pinia/colada'> & 6 11 Plugin.Hooks & { 7 12 /** 8 - * The casing convention to use for generated names. 13 + * Casing convention for generated names. 9 14 * 10 15 * @default 'camelCase' 11 16 */ ··· 22 27 */ 23 28 comments?: boolean; 24 29 /** 25 - * Should the exports from the generated files be re-exported in the index 26 - * barrel file? 30 + * Whether exports should be re-exported in the index file. 27 31 * 28 32 * @default false 29 33 */ ··· 45 49 | NameTransformer 46 50 | { 47 51 /** 48 - * The casing convention to use for generated names. 52 + * Casing convention for generated names. 49 53 * 50 54 * @default 'camelCase' 51 55 */ 52 56 case?: Casing; 53 57 /** 54 - * Whether to generate mutation options helpers. 58 + * Whether this feature is enabled. 55 59 * 56 60 * @default true 57 61 */ ··· 80 84 */ 81 85 meta?: (operation: IR.OperationObject) => Record<string, unknown>; 82 86 /** 83 - * Custom naming pattern for generated mutation options names. The name variable is 84 - * obtained from the SDK function name. 87 + * Naming pattern for generated names. 85 88 * 86 89 * @default '{{name}}Mutation' 87 90 */ ··· 104 107 | NameTransformer 105 108 | { 106 109 /** 107 - * The casing convention to use for generated names. 110 + * Casing convention for generated names. 108 111 * 109 112 * @default 'camelCase' 110 113 */ 111 114 case?: Casing; 112 115 /** 113 - * Whether to generate query keys. 116 + * Whether this feature is enabled. 114 117 * 115 118 * @default true 116 119 */ 117 120 enabled?: boolean; 118 121 /** 119 - * Custom naming pattern for generated query key names. The name variable is 120 - * obtained from the SDK function name. 122 + * Naming pattern for generated names. 121 123 * 122 124 * @default '{{name}}QueryKey' 123 125 */ ··· 147 149 | NameTransformer 148 150 | { 149 151 /** 150 - * The casing convention to use for generated names. 152 + * Casing convention for generated names. 151 153 * 152 154 * @default 'camelCase' 153 155 */ 154 156 case?: Casing; 155 157 /** 156 - * Whether to generate query options helpers. 158 + * Whether this feature is enabled. 157 159 * 158 160 * @default true 159 161 */ ··· 182 184 */ 183 185 meta?: (operation: IR.OperationObject) => Record<string, unknown>; 184 186 /** 185 - * Custom naming pattern for generated query options names. The name variable is 186 - * obtained from the SDK function name. 187 + * Naming pattern for generated names. 187 188 * 188 189 * @default '{{name}}Query' 189 190 */ ··· 192 193 }; 193 194 194 195 export type Config = Plugin.Name<'@pinia/colada'> & 195 - Plugin.Hooks & { 196 + Plugin.Hooks & 197 + IndexExportOption & { 196 198 /** 197 - * The casing convention to use for generated names. 198 - * 199 - * @default 'camelCase' 199 + * Casing convention for generated names. 200 200 */ 201 201 case: Casing; 202 202 /** ··· 205 205 * @default true 206 206 */ 207 207 comments: boolean; 208 - /** 209 - * Should the exports from the generated files be re-exported in the index barrel file? 210 - * 211 - * @default false 212 - */ 213 - exportFromIndex: boolean; 214 208 /** 215 209 * Resolved configuration for generated mutation options helpers. 216 210 */ 217 - mutationOptions: { 218 - /** 219 - * The casing convention to use for generated names. 220 - * 221 - * @default 'camelCase' 222 - */ 223 - case: Casing; 224 - /** 225 - * Whether to generate mutation options helpers. 226 - * 227 - * @default true 228 - */ 229 - enabled: boolean; 230 - /** 231 - * Custom function to generate metadata for the operation. 232 - * Can return any valid meta object that will be included in the generated mutation options. 233 - * 234 - * @param operation - The operation object containing all available metadata 235 - * @returns A meta object with any properties you want to include 236 - * 237 - * @example 238 - * ```ts 239 - * meta: (operation) => ({ 240 - * customField: operation.id, 241 - * isDeprecated: operation.deprecated, 242 - * tags: operation.tags, 243 - * customObject: { 244 - * method: operation.method, 245 - * path: operation.path 246 - * } 247 - * }) 248 - * ``` 249 - * 250 - * @default undefined 251 - */ 252 - meta: 253 - | ((operation: IR.OperationObject) => Record<string, unknown>) 254 - | undefined; 255 - /** 256 - * Custom naming pattern for generated mutation options names. The name variable is 257 - * obtained from the SDK function name. 258 - * 259 - * @default '{{name}}Mutation' 260 - */ 261 - name: NameTransformer; 262 - }; 211 + mutationOptions: NamingOptions & 212 + FeatureToggle & { 213 + /** 214 + * Custom function to generate metadata for the operation. 215 + * Can return any valid meta object that will be included in the generated mutation options. 216 + * 217 + * @param operation - The operation object containing all available metadata 218 + * @returns A meta object with any properties you want to include 219 + * 220 + * @example 221 + * ```ts 222 + * meta: (operation) => ({ 223 + * customField: operation.id, 224 + * isDeprecated: operation.deprecated, 225 + * tags: operation.tags, 226 + * customObject: { 227 + * method: operation.method, 228 + * path: operation.path 229 + * } 230 + * }) 231 + * ``` 232 + * 233 + * @default undefined 234 + */ 235 + meta: 236 + | ((operation: IR.OperationObject) => Record<string, unknown>) 237 + | undefined; 238 + }; 263 239 /** 264 240 * Resolved configuration for generated query keys. 265 241 * 266 242 * See {@link https://pinia-colada.esm.dev/guide/query-keys.html Query Keys} 267 243 */ 268 - queryKeys: { 269 - /** 270 - * The casing convention to use for generated names. 271 - * 272 - * @default 'camelCase' 273 - */ 274 - case: Casing; 275 - /** 276 - * Whether to generate query keys. 277 - * 278 - * @default true 279 - */ 280 - enabled: boolean; 281 - /** 282 - * Custom naming pattern for generated query key names. The name variable is 283 - * obtained from the SDK function name. 284 - * 285 - * @default '{{name}}QueryKey' 286 - */ 287 - name: NameTransformer; 288 - /** 289 - * Whether to include operation tags in query keys. 290 - * This will make query keys larger but provides better cache invalidation capabilities. 291 - * 292 - * @default false 293 - */ 294 - tags: boolean; 295 - }; 244 + queryKeys: NamingOptions & 245 + FeatureToggle & { 246 + /** 247 + * Whether to include operation tags in query keys. 248 + * This will make query keys larger but provides better cache invalidation capabilities. 249 + * 250 + * @default false 251 + */ 252 + tags: boolean; 253 + }; 296 254 /** 297 255 * Resolved configuration for generated query options helpers. 298 256 * 299 257 * See {@link https://pinia-colada.esm.dev/guide/queries.html Queries} 300 258 */ 301 - queryOptions: { 302 - /** 303 - * The casing convention to use for generated names. 304 - * 305 - * @default 'camelCase' 306 - */ 307 - case: Casing; 308 - /** 309 - * Whether to generate query options helpers. 310 - * 311 - * @default true 312 - */ 313 - enabled: boolean; 314 - /** 315 - * Custom function to generate metadata for the operation. 316 - * Can return any valid meta object that will be included in the generated query options. 317 - * 318 - * @param operation - The operation object containing all available metadata 319 - * @returns A meta object with any properties you want to include 320 - * 321 - * @example 322 - * ```ts 323 - * meta: (operation) => ({ 324 - * customField: operation.id, 325 - * isDeprecated: operation.deprecated, 326 - * tags: operation.tags, 327 - * customObject: { 328 - * method: operation.method, 329 - * path: operation.path 330 - * } 331 - * }) 332 - * ``` 333 - * 334 - * @default undefined 335 - */ 336 - meta: 337 - | ((operation: IR.OperationObject) => Record<string, unknown>) 338 - | undefined; 339 - /** 340 - * Custom naming pattern for generated query options names. The name variable is 341 - * obtained from the SDK function name. 342 - * 343 - * @default '{{name}}Query' 344 - */ 345 - name: NameTransformer; 346 - }; 259 + queryOptions: NamingOptions & 260 + FeatureToggle & { 261 + /** 262 + * Custom function to generate metadata for the operation. 263 + * Can return any valid meta object that will be included in the generated query options. 264 + * 265 + * @param operation - The operation object containing all available metadata 266 + * @returns A meta object with any properties you want to include 267 + * 268 + * @example 269 + * ```ts 270 + * meta: (operation) => ({ 271 + * customField: operation.id, 272 + * isDeprecated: operation.deprecated, 273 + * tags: operation.tags, 274 + * customObject: { 275 + * method: operation.method, 276 + * path: operation.path 277 + * } 278 + * }) 279 + * ``` 280 + * 281 + * @default undefined 282 + */ 283 + meta: 284 + | ((operation: IR.OperationObject) => Record<string, unknown>) 285 + | undefined; 286 + }; 347 287 }; 348 288 349 289 export type PiniaColadaPlugin = DefinePlugin<UserConfig, Config>;
+126 -228
packages/openapi-ts/src/plugins/@tanstack/angular-query-experimental/types.d.ts
··· 1 + import type { 2 + FeatureToggle, 3 + IndexExportOption, 4 + NamingOptions, 5 + } from '~/config/shared'; 1 6 import type { IR } from '~/ir/types'; 2 7 import type { DefinePlugin, Plugin } from '~/plugins'; 3 8 import type { Casing, NameTransformer } from '~/utils/naming'; ··· 5 10 export type UserConfig = Plugin.Name<'@tanstack/angular-query-experimental'> & 6 11 Plugin.Hooks & { 7 12 /** 8 - * The casing convention to use for generated names. 13 + * Casing convention for generated names. 9 14 * 10 15 * @default 'camelCase' 11 16 */ ··· 22 27 */ 23 28 comments?: boolean; 24 29 /** 25 - * Should the exports from the generated files be re-exported in the index barrel file? 30 + * Whether exports should be re-exported in the index file. 26 31 * 27 32 * @default false 28 33 */ ··· 44 49 | NameTransformer 45 50 | { 46 51 /** 47 - * The casing convention to use for generated names. 52 + * Casing convention for generated names. 48 53 * 49 54 * @default 'camelCase' 50 55 */ 51 56 case?: Casing; 52 57 /** 53 - * Whether to generate infinite query key helpers. 58 + * Whether this feature is enabled. 54 59 * 55 60 * @default true 56 61 */ 57 62 enabled?: boolean; 58 63 /** 59 - * Custom naming pattern for generated infinite query key names. The name variable is 60 - * obtained from the SDK function name. 64 + * Naming pattern for generated names. 61 65 * 62 66 * @default '{{name}}InfiniteQueryKey' 63 67 * @see https://tanstack.com/query/v5/docs/framework/angular/reference/infiniteQueryOptions ··· 88 92 | NameTransformer 89 93 | { 90 94 /** 91 - * The casing convention to use for generated names. 95 + * Casing convention for generated names. 92 96 * 93 97 * @default 'camelCase' 94 98 */ 95 99 case?: Casing; 96 100 /** 97 - * Whether to generate infinite query options helpers. 101 + * Whether this feature is enabled. 98 102 * 99 103 * @default true 100 104 */ ··· 122 126 */ 123 127 meta?: (operation: IR.OperationObject) => Record<string, unknown>; 124 128 /** 125 - * Custom naming pattern for generated infinite query options names. The name variable is 126 - * obtained from the SDK function name. 129 + * Naming pattern for generated names. 127 130 * 128 131 * @default '{{name}}InfiniteOptions' 129 132 * @see https://tanstack.com/query/v5/docs/framework/angular/reference/infiniteQueryOptions ··· 147 150 | NameTransformer 148 151 | { 149 152 /** 150 - * The casing convention to use for generated names. 153 + * Casing convention for generated names. 151 154 * 152 155 * @default 'camelCase' 153 156 */ 154 157 case?: Casing; 155 158 /** 156 - * Whether to generate mutation options helpers. 159 + * Whether this feature is enabled. 157 160 * 158 161 * @default true 159 162 */ ··· 181 184 */ 182 185 meta?: (operation: IR.OperationObject) => Record<string, unknown>; 183 186 /** 184 - * Custom naming pattern for generated mutation options names. The name variable is 185 - * obtained from the SDK function name. 187 + * Naming pattern for generated names. 186 188 * 187 189 * @default '{{name}}Mutation' 188 190 * @see https://tanstack.com/query/v5/docs/framework/angular/reference/useMutation ··· 206 208 | NameTransformer 207 209 | { 208 210 /** 209 - * The casing convention to use for generated names. 211 + * Casing convention for generated names. 210 212 * 211 213 * @default 'camelCase' 212 214 */ 213 215 case?: Casing; 214 216 /** 215 - * Whether to generate query keys. 217 + * Whether this feature is enabled. 216 218 * 217 219 * @default true 218 220 */ 219 221 enabled?: boolean; 220 222 /** 221 - * Custom naming pattern for generated query key names. The name variable is 222 - * obtained from the SDK function name. 223 + * Naming pattern for generated names. 223 224 * 224 225 * @default '{{name}}QueryKey' 225 226 * @see https://tanstack.com/query/v5/docs/framework/angular/reference/queryKey ··· 250 251 | NameTransformer 251 252 | { 252 253 /** 253 - * The casing convention to use for generated names. 254 + * Casing convention for generated names. 254 255 * 255 256 * @default 'camelCase' 256 257 */ 257 258 case?: Casing; 258 259 /** 259 - * Whether to generate query options helpers. 260 + * Whether this feature is enabled. 260 261 * 261 262 * @default true 262 263 */ ··· 290 291 */ 291 292 meta?: (operation: IR.OperationObject) => Record<string, unknown>; 292 293 /** 293 - * Custom naming pattern for generated query options names. The name variable is 294 - * obtained from the SDK function name. 294 + * Naming pattern for generated names. 295 295 * 296 296 * @default '{{name}}Options' 297 297 * @see https://tanstack.com/query/v5/docs/framework/angular/reference/queryOptions ··· 301 301 }; 302 302 303 303 export type Config = Plugin.Name<'@tanstack/angular-query-experimental'> & 304 - Plugin.Hooks & { 304 + Plugin.Hooks & 305 + IndexExportOption & { 305 306 /** 306 - * The casing convention to use for generated names. 307 - * 308 - * @default 'camelCase' 307 + * Casing convention for generated names. 309 308 */ 310 309 case: Casing; 311 310 /** ··· 315 314 */ 316 315 comments: boolean; 317 316 /** 318 - * Should the exports from the generated files be re-exported in the index barrel file? 319 - * 320 - * @default false 321 - */ 322 - exportFromIndex: boolean; 323 - /** 324 317 * Resolved configuration for generated infinite query key helpers. 325 318 * 326 319 * @see https://tanstack.com/query/v5/docs/framework/angular/reference/infiniteQueryOptions 327 320 */ 328 - infiniteQueryKeys: { 329 - /** 330 - * The casing convention to use for generated names. 331 - * 332 - * @default 'camelCase' 333 - */ 334 - case: Casing; 335 - /** 336 - * Whether to generate infinite query key helpers. 337 - * 338 - * @default true 339 - */ 340 - enabled: boolean; 341 - /** 342 - * Custom naming pattern for generated infinite query key names. The name variable is 343 - * obtained from the SDK function name. 344 - * 345 - * @default '{{name}}InfiniteQueryKey' 346 - * @see https://tanstack.com/query/v5/docs/framework/angular/reference/infiniteQueryOptions 347 - */ 348 - name: NameTransformer; 349 - /** 350 - * Whether to include operation tags in infinite query keys. 351 - * This will make query keys larger but provides better cache invalidation capabilities. 352 - * 353 - * @default false 354 - */ 355 - tags: boolean; 356 - }; 321 + infiniteQueryKeys: NamingOptions & 322 + FeatureToggle & { 323 + /** 324 + * Whether to include operation tags in infinite query keys. 325 + * This will make query keys larger but provides better cache invalidation capabilities. 326 + * 327 + * @default false 328 + */ 329 + tags: boolean; 330 + }; 357 331 /** 358 332 * Resolved configuration for generated infinite query options helpers. 359 333 * 360 334 * @see https://tanstack.com/query/v5/docs/framework/angular/reference/infiniteQueryOptions 361 335 */ 362 - infiniteQueryOptions: { 363 - /** 364 - * The casing convention to use for generated names. 365 - * 366 - * @default 'camelCase' 367 - */ 368 - case: Casing; 369 - /** 370 - * Whether to generate infinite query options helpers. 371 - * 372 - * @default true 373 - */ 374 - enabled: boolean; 375 - /** 376 - * Custom function to generate metadata for the operation. 377 - * Can return any valid meta object that will be included in the generated infinite query options. 378 - * @param operation - The operation object containing all available metadata 379 - * @returns A meta object with any properties you want to include 380 - * 381 - * @example 382 - * ```ts 383 - * meta: (operation) => ({ 384 - * customField: operation.id, 385 - * isDeprecated: operation.deprecated, 386 - * tags: operation.tags, 387 - * customObject: { 388 - * method: operation.method, 389 - * path: operation.path 390 - * } 391 - * }) 392 - * ``` 393 - * 394 - * @default undefined 395 - */ 396 - meta: (operation: IR.OperationObject) => Record<string, unknown>; 397 - /** 398 - * Custom naming pattern for generated infinite query options names. The name variable is 399 - * obtained from the SDK function name. 400 - * 401 - * @default '{{name}}InfiniteOptions' 402 - * @see https://tanstack.com/query/v5/docs/framework/angular/reference/infiniteQueryOptions 403 - */ 404 - name: NameTransformer; 405 - }; 336 + infiniteQueryOptions: NamingOptions & 337 + FeatureToggle & { 338 + /** 339 + * Custom function to generate metadata for the operation. 340 + * Can return any valid meta object that will be included in the generated infinite query options. 341 + * @param operation - The operation object containing all available metadata 342 + * @returns A meta object with any properties you want to include 343 + * 344 + * @example 345 + * ```ts 346 + * meta: (operation) => ({ 347 + * customField: operation.id, 348 + * isDeprecated: operation.deprecated, 349 + * tags: operation.tags, 350 + * customObject: { 351 + * method: operation.method, 352 + * path: operation.path 353 + * } 354 + * }) 355 + * ``` 356 + * 357 + * @default undefined 358 + */ 359 + meta: (operation: IR.OperationObject) => Record<string, unknown>; 360 + }; 406 361 /** 407 362 * Resolved configuration for generated mutation options helpers. 408 363 * 409 364 * @see https://tanstack.com/query/v5/docs/framework/angular/reference/useMutation 410 365 */ 411 - mutationOptions: { 412 - /** 413 - * The casing convention to use for generated names. 414 - * 415 - * @default 'camelCase' 416 - */ 417 - case: Casing; 418 - /** 419 - * Whether to generate mutation options helpers. 420 - * 421 - * @default true 422 - */ 423 - enabled: boolean; 424 - /** 425 - * Custom function to generate metadata for the operation. 426 - * Can return any valid meta object that will be included in the generated mutation options. 427 - * @param operation - The operation object containing all available metadata 428 - * @returns A meta object with any properties you want to include 429 - * 430 - * @example 431 - * ```ts 432 - * meta: (operation) => ({ 433 - * customField: operation.id, 434 - * isDeprecated: operation.deprecated, 435 - * tags: operation.tags, 436 - * customObject: { 437 - * method: operation.method, 438 - * path: operation.path 439 - * } 440 - * }) 441 - * ``` 442 - * 443 - * @default undefined 444 - */ 445 - meta: (operation: IR.OperationObject) => Record<string, unknown>; 446 - /** 447 - * Custom naming pattern for generated mutation options names. The name variable is 448 - * obtained from the SDK function name. 449 - * 450 - * @default '{{name}}Mutation' 451 - * @see https://tanstack.com/query/v5/docs/framework/angular/reference/useMutation 452 - */ 453 - name: NameTransformer; 454 - }; 366 + mutationOptions: NamingOptions & 367 + FeatureToggle & { 368 + /** 369 + * Custom function to generate metadata for the operation. 370 + * Can return any valid meta object that will be included in the generated mutation options. 371 + * @param operation - The operation object containing all available metadata 372 + * @returns A meta object with any properties you want to include 373 + * 374 + * @example 375 + * ```ts 376 + * meta: (operation) => ({ 377 + * customField: operation.id, 378 + * isDeprecated: operation.deprecated, 379 + * tags: operation.tags, 380 + * customObject: { 381 + * method: operation.method, 382 + * path: operation.path 383 + * } 384 + * }) 385 + * ``` 386 + * 387 + * @default undefined 388 + */ 389 + meta: (operation: IR.OperationObject) => Record<string, unknown>; 390 + }; 455 391 /** 456 392 * Resolved configuration for generated query keys. 457 393 * 458 394 * @see https://tanstack.com/query/v5/docs/framework/angular/reference/queryKey 459 395 */ 460 - queryKeys: { 461 - /** 462 - * The casing convention to use for generated names. 463 - * 464 - * @default 'camelCase' 465 - */ 466 - case: Casing; 467 - /** 468 - * Whether to generate query keys. 469 - * 470 - * @default true 471 - */ 472 - enabled: boolean; 473 - /** 474 - * Custom naming pattern for generated query key names. The name variable is 475 - * obtained from the SDK function name. 476 - * 477 - * @default '{{name}}QueryKey' 478 - * @see https://tanstack.com/query/v5/docs/framework/angular/reference/queryKey 479 - */ 480 - name: NameTransformer; 481 - /** 482 - * Whether to include operation tags in query keys. 483 - * This will make query keys larger but provides better cache invalidation capabilities. 484 - * 485 - * @default false 486 - */ 487 - tags: boolean; 488 - }; 396 + queryKeys: NamingOptions & 397 + FeatureToggle & { 398 + /** 399 + * Whether to include operation tags in query keys. 400 + * This will make query keys larger but provides better cache invalidation capabilities. 401 + * 402 + * @default false 403 + */ 404 + tags: boolean; 405 + }; 489 406 /** 490 407 * Resolved configuration for generated query options helpers. 491 408 * 492 409 * @see https://tanstack.com/query/v5/docs/framework/angular/reference/queryOptions 493 410 */ 494 - queryOptions: { 495 - /** 496 - * The casing convention to use for generated names. 497 - * 498 - * @default 'camelCase' 499 - */ 500 - case: Casing; 501 - /** 502 - * Whether to generate query options helpers. 503 - * 504 - * @default true 505 - */ 506 - enabled: boolean; 507 - /** 508 - * Whether to export generated symbols. 509 - * 510 - * @default true 511 - */ 512 - exported: boolean; 513 - /** 514 - * Custom function to generate metadata for the operation. 515 - * Can return any valid meta object that will be included in the generated query options. 516 - * @param operation - The operation object containing all available metadata 517 - * @returns A meta object with any properties you want to include 518 - * 519 - * @example 520 - * ```ts 521 - * meta: (operation) => ({ 522 - * customField: operation.id, 523 - * isDeprecated: operation.deprecated, 524 - * tags: operation.tags, 525 - * customObject: { 526 - * method: operation.method, 527 - * path: operation.path 528 - * } 529 - * }) 530 - * ``` 531 - * 532 - * @default undefined 533 - */ 534 - meta: (operation: IR.OperationObject) => Record<string, unknown>; 535 - /** 536 - * Custom naming pattern for generated query options names. The name variable is 537 - * obtained from the SDK function name. 538 - * 539 - * @default '{{name}}Options' 540 - * @see https://tanstack.com/query/v5/docs/framework/angular/reference/queryOptions 541 - */ 542 - name: NameTransformer; 543 - }; 411 + queryOptions: NamingOptions & 412 + FeatureToggle & { 413 + /** 414 + * Whether to export generated symbols. 415 + * 416 + * @default true 417 + */ 418 + exported: boolean; 419 + /** 420 + * Custom function to generate metadata for the operation. 421 + * Can return any valid meta object that will be included in the generated query options. 422 + * @param operation - The operation object containing all available metadata 423 + * @returns A meta object with any properties you want to include 424 + * 425 + * @example 426 + * ```ts 427 + * meta: (operation) => ({ 428 + * customField: operation.id, 429 + * isDeprecated: operation.deprecated, 430 + * tags: operation.tags, 431 + * customObject: { 432 + * method: operation.method, 433 + * path: operation.path 434 + * } 435 + * }) 436 + * ``` 437 + * 438 + * @default undefined 439 + */ 440 + meta: (operation: IR.OperationObject) => Record<string, unknown>; 441 + }; 544 442 }; 545 443 546 444 export type TanStackAngularQueryPlugin = DefinePlugin<UserConfig, Config>;
+133 -259
packages/openapi-ts/src/plugins/@tanstack/react-query/types.d.ts
··· 1 + import type { 2 + FeatureToggle, 3 + IndexExportOption, 4 + NamingOptions, 5 + } from '~/config/shared'; 1 6 import type { IR } from '~/ir/types'; 2 7 import type { DefinePlugin, Plugin } from '~/plugins'; 3 8 import type { Casing, NameTransformer } from '~/utils/naming'; ··· 5 10 export type UserConfig = Plugin.Name<'@tanstack/react-query'> & 6 11 Plugin.Hooks & { 7 12 /** 8 - * The casing convention to use for generated names. 13 + * Casing convention for generated names. 9 14 * 10 15 * @default 'camelCase' 11 16 */ ··· 22 27 */ 23 28 comments?: boolean; 24 29 /** 25 - * Should the exports from the generated files be re-exported in the index 26 - * barrel file? 30 + * Whether exports should be re-exported in the index file. 27 31 * 28 32 * @default false 29 33 */ ··· 45 49 | NameTransformer 46 50 | { 47 51 /** 48 - * The casing convention to use for generated names. 52 + * Casing convention for generated names. 49 53 * 50 54 * @default 'camelCase' 51 55 */ 52 56 case?: Casing; 53 57 /** 54 - * Whether to generate infinite query key helpers. 58 + * Whether this feature is enabled. 55 59 * 56 60 * @default true 57 61 */ 58 62 enabled?: boolean; 59 63 /** 60 - * Custom naming pattern for generated infinite query key names. The name variable is 61 - * obtained from the SDK function name. 64 + * Naming pattern for generated names. 62 65 * 63 66 * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/infiniteQueryOptions infiniteQueryOptions} 64 67 * ··· 90 93 | NameTransformer 91 94 | { 92 95 /** 93 - * The casing convention to use for generated names. 96 + * Casing convention for generated names. 94 97 * 95 98 * @default 'camelCase' 96 99 */ 97 100 case?: Casing; 98 101 /** 99 - * Whether to generate infinite query options helpers. 102 + * Whether this feature is enabled. 100 103 * 101 104 * @default true 102 105 */ ··· 125 128 */ 126 129 meta?: (operation: IR.OperationObject) => Record<string, unknown>; 127 130 /** 128 - * Custom naming pattern for generated infinite query options names. The name variable is 129 - * obtained from the SDK function name. 131 + * Naming pattern for generated names. 130 132 * 131 133 * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/infiniteQueryOptions infiniteQueryOptions} 132 134 * ··· 151 153 | NameTransformer 152 154 | { 153 155 /** 154 - * The casing convention to use for generated names. 156 + * Casing convention for generated names. 155 157 * 156 158 * @default 'camelCase' 157 159 */ 158 160 case?: Casing; 159 161 /** 160 - * Whether to generate mutation options helpers. 162 + * Whether this feature is enabled. 161 163 * 162 164 * @default true 163 165 */ ··· 186 188 */ 187 189 meta?: (operation: IR.OperationObject) => Record<string, unknown>; 188 190 /** 189 - * Custom naming pattern for generated mutation options names. The name variable is 190 - * obtained from the SDK function name. 191 + * Naming pattern for generated names. 191 192 * 192 193 * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/useMutation useMutation} 193 194 * ··· 212 213 | NameTransformer 213 214 | { 214 215 /** 215 - * The casing convention to use for generated names. 216 + * Casing convention for generated names. 216 217 * 217 218 * @default 'camelCase' 218 219 */ 219 220 case?: Casing; 220 221 /** 221 - * Whether to generate query keys. 222 + * Whether this feature is enabled. 222 223 * 223 224 * @default true 224 225 */ 225 226 enabled?: boolean; 226 227 /** 227 - * Custom naming pattern for generated query key names. The name variable is 228 - * obtained from the SDK function name. 228 + * Naming pattern for generated names. 229 229 * 230 230 * See {@link https://tanstack.com/query/v5/docs/framework/react/guides/query-keys Query Keys} 231 231 * ··· 257 257 | NameTransformer 258 258 | { 259 259 /** 260 - * The casing convention to use for generated names. 260 + * Casing convention for generated names. 261 261 * 262 262 * @default 'camelCase' 263 263 */ 264 264 case?: Casing; 265 265 /** 266 - * Whether to generate query options helpers. 266 + * Whether this feature is enabled. 267 267 * 268 268 * @default true 269 269 */ ··· 298 298 */ 299 299 meta?: (operation: IR.OperationObject) => Record<string, unknown>; 300 300 /** 301 - * Custom naming pattern for generated query options names. The name variable is 302 - * obtained from the SDK function name. 301 + * Naming pattern for generated names. 303 302 * 304 303 * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/queryOptions queryOptions} 305 304 * ··· 324 323 | NameTransformer 325 324 | { 326 325 /** 327 - * The casing convention to use for generated names. 326 + * Casing convention for generated names. 328 327 * 329 328 * @default 'camelCase' 330 329 */ 331 330 case?: Casing; 332 331 /** 333 - * Whether to generate `useQuery()` function helpers. 332 + * Whether this feature is enabled. 334 333 * 335 334 * @default true 336 335 */ 337 336 enabled?: boolean; 338 337 /** 339 - * Custom naming pattern for generated `useQuery()` function names. The name variable is 340 - * obtained from the SDK function name. 338 + * Naming pattern for generated names. 341 339 * 342 340 * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/useQuery useQuery} 343 341 * ··· 348 346 }; 349 347 350 348 export type Config = Plugin.Name<'@tanstack/react-query'> & 351 - Plugin.Hooks & { 349 + Plugin.Hooks & 350 + IndexExportOption & { 352 351 /** 353 - * The casing convention to use for generated names. 354 - * 355 - * @default 'camelCase' 352 + * Casing convention for generated names. 356 353 */ 357 354 case: Casing; 358 355 /** ··· 362 359 */ 363 360 comments: boolean; 364 361 /** 365 - * Should the exports from the generated files be re-exported in the index barrel file? 366 - * 367 - * @default false 368 - */ 369 - exportFromIndex: boolean; 370 - /** 371 362 * Resolved configuration for generated infinite query key helpers. 372 363 * 373 364 * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/infiniteQueryOptions infiniteQueryOptions} 374 365 */ 375 - infiniteQueryKeys: { 376 - /** 377 - * The casing convention to use for generated names. 378 - * 379 - * @default 'camelCase' 380 - */ 381 - case: Casing; 382 - /** 383 - * Whether to generate infinite query key helpers. 384 - * 385 - * @default true 386 - */ 387 - enabled: boolean; 388 - /** 389 - * Custom naming pattern for generated infinite query key names. The name variable is obtained from the SDK function name. 390 - * 391 - * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/infiniteQueryOptions infiniteQueryOptions} 392 - * 393 - * @default '{{name}}InfiniteQueryKey' 394 - */ 395 - name: NameTransformer; 396 - /** 397 - * Whether to include operation tags in infinite query keys. 398 - * This will make query keys larger but provides better cache invalidation capabilities. 399 - * 400 - * @default false 401 - */ 402 - tags: boolean; 403 - }; 366 + infiniteQueryKeys: NamingOptions & 367 + FeatureToggle & { 368 + /** 369 + * Whether to include operation tags in infinite query keys. 370 + * This will make query keys larger but provides better cache invalidation capabilities. 371 + * 372 + * @default false 373 + */ 374 + tags: boolean; 375 + }; 404 376 /** 405 377 * Resolved configuration for generated infinite query options helpers. 406 378 * 407 379 * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/infiniteQueryOptions infiniteQueryOptions} 408 380 */ 409 - infiniteQueryOptions: { 410 - /** 411 - * The casing convention to use for generated names. 412 - * 413 - * @default 'camelCase' 414 - */ 415 - case: Casing; 416 - /** 417 - * Whether to generate infinite query options helpers. 418 - * 419 - * @default true 420 - */ 421 - enabled: boolean; 422 - /** 423 - * Custom function to generate metadata for the operation. 424 - * Can return any valid meta object that will be included in the generated infinite query options. 425 - * 426 - * @param operation - The operation object containing all available metadata 427 - * @returns A meta object with any properties you want to include 428 - * 429 - * @example 430 - * ```ts 431 - * meta: (operation) => ({ 432 - * customField: operation.id, 433 - * isDeprecated: operation.deprecated, 434 - * tags: operation.tags, 435 - * customObject: { 436 - * method: operation.method, 437 - * path: operation.path 438 - * } 439 - * }) 440 - * ``` 441 - * 442 - * @default undefined 443 - */ 444 - meta: (operation: IR.OperationObject) => Record<string, unknown>; 445 - /** 446 - * Custom naming pattern for generated infinite query options names. The name variable is obtained from the SDK function name. 447 - * 448 - * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/infiniteQueryOptions infiniteQueryOptions} 449 - * 450 - * @default '{{name}}InfiniteOptions' 451 - */ 452 - name: NameTransformer; 453 - }; 381 + infiniteQueryOptions: NamingOptions & 382 + FeatureToggle & { 383 + /** 384 + * Custom function to generate metadata for the operation. 385 + * Can return any valid meta object that will be included in the generated infinite query options. 386 + * 387 + * @param operation - The operation object containing all available metadata 388 + * @returns A meta object with any properties you want to include 389 + * 390 + * @example 391 + * ```ts 392 + * meta: (operation) => ({ 393 + * customField: operation.id, 394 + * isDeprecated: operation.deprecated, 395 + * tags: operation.tags, 396 + * customObject: { 397 + * method: operation.method, 398 + * path: operation.path 399 + * } 400 + * }) 401 + * ``` 402 + * 403 + * @default undefined 404 + */ 405 + meta: (operation: IR.OperationObject) => Record<string, unknown>; 406 + }; 454 407 /** 455 408 * Resolved configuration for generated mutation options helpers. 456 409 * 457 410 * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/useMutation useMutation} 458 411 */ 459 - mutationOptions: { 460 - /** 461 - * The casing convention to use for generated names. 462 - * 463 - * @default 'camelCase' 464 - */ 465 - case: Casing; 466 - /** 467 - * Whether to generate mutation options helpers. 468 - * 469 - * @default true 470 - */ 471 - enabled: boolean; 472 - /** 473 - * Custom function to generate metadata for the operation. 474 - * Can return any valid meta object that will be included in the generated mutation options. 475 - * 476 - * @param operation - The operation object containing all available metadata 477 - * @returns A meta object with any properties you want to include 478 - * 479 - * @example 480 - * ```ts 481 - * meta: (operation) => ({ 482 - * customField: operation.id, 483 - * isDeprecated: operation.deprecated, 484 - * tags: operation.tags, 485 - * customObject: { 486 - * method: operation.method, 487 - * path: operation.path 488 - * } 489 - * }) 490 - * ``` 491 - * 492 - * @default undefined 493 - */ 494 - meta: (operation: IR.OperationObject) => Record<string, unknown>; 495 - /** 496 - * Custom naming pattern for generated mutation options names. The name variable is obtained from the SDK function name. 497 - * 498 - * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/useMutation useMutation} 499 - * 500 - * @default '{{name}}Mutation' 501 - */ 502 - name: NameTransformer; 503 - }; 412 + mutationOptions: NamingOptions & 413 + FeatureToggle & { 414 + /** 415 + * Custom function to generate metadata for the operation. 416 + * Can return any valid meta object that will be included in the generated mutation options. 417 + * 418 + * @param operation - The operation object containing all available metadata 419 + * @returns A meta object with any properties you want to include 420 + * 421 + * @example 422 + * ```ts 423 + * meta: (operation) => ({ 424 + * customField: operation.id, 425 + * isDeprecated: operation.deprecated, 426 + * tags: operation.tags, 427 + * customObject: { 428 + * method: operation.method, 429 + * path: operation.path 430 + * } 431 + * }) 432 + * ``` 433 + * 434 + * @default undefined 435 + */ 436 + meta: (operation: IR.OperationObject) => Record<string, unknown>; 437 + }; 504 438 /** 505 439 * Resolved configuration for generated query keys. 506 440 * 507 441 * See {@link https://tanstack.com/query/v5/docs/framework/react/guides/query-keys Query Keys} 508 442 */ 509 - queryKeys: { 510 - /** 511 - * The casing convention to use for generated names. 512 - * 513 - * @default 'camelCase' 514 - */ 515 - case: Casing; 516 - /** 517 - * Whether to generate query keys. 518 - * 519 - * @default true 520 - */ 521 - enabled: boolean; 522 - /** 523 - * Custom naming pattern for generated query key names. The name variable is obtained from the SDK function name. 524 - * 525 - * See {@link https://tanstack.com/query/v5/docs/framework/react/guides/query-keys Query Keys} 526 - * 527 - * @default '{{name}}QueryKey' 528 - */ 529 - name: NameTransformer; 530 - /** 531 - * Whether to include operation tags in query keys. 532 - * This will make query keys larger but provides better cache invalidation capabilities. 533 - * 534 - * @default false 535 - */ 536 - tags: boolean; 537 - }; 443 + queryKeys: NamingOptions & 444 + FeatureToggle & { 445 + /** 446 + * Whether to include operation tags in query keys. 447 + * This will make query keys larger but provides better cache invalidation capabilities. 448 + * 449 + * @default false 450 + */ 451 + tags: boolean; 452 + }; 538 453 /** 539 454 * Resolved configuration for generated query options helpers. 540 455 * 541 456 * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/queryOptions queryOptions} 542 457 */ 543 - queryOptions: { 544 - /** 545 - * The casing convention to use for generated names. 546 - * 547 - * @default 'camelCase' 548 - */ 549 - case: Casing; 550 - /** 551 - * Whether to generate query options helpers. 552 - * 553 - * @default true 554 - */ 555 - enabled: boolean; 556 - /** 557 - * Whether to export generated symbols. 558 - * 559 - * @default true 560 - */ 561 - exported: boolean; 562 - /** 563 - * Custom function to generate metadata for the operation. 564 - * Can return any valid meta object that will be included in the generated query options. 565 - * 566 - * @param operation - The operation object containing all available metadata 567 - * @returns A meta object with any properties you want to include 568 - * 569 - * @example 570 - * ```ts 571 - * meta: (operation) => ({ 572 - * customField: operation.id, 573 - * isDeprecated: operation.deprecated, 574 - * tags: operation.tags, 575 - * customObject: { 576 - * method: operation.method, 577 - * path: operation.path 578 - * } 579 - * }) 580 - * ``` 581 - * 582 - * @default undefined 583 - */ 584 - meta: (operation: IR.OperationObject) => Record<string, unknown>; 585 - /** 586 - * Custom naming pattern for generated query options names. The name variable is obtained from the SDK function name. 587 - * 588 - * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/queryOptions queryOptions} 589 - * 590 - * @default '{{name}}Options' 591 - */ 592 - name: NameTransformer; 593 - }; 458 + queryOptions: NamingOptions & 459 + FeatureToggle & { 460 + /** 461 + * Whether to export generated symbols. 462 + * 463 + * @default true 464 + */ 465 + exported: boolean; 466 + /** 467 + * Custom function to generate metadata for the operation. 468 + * Can return any valid meta object that will be included in the generated query options. 469 + * 470 + * @param operation - The operation object containing all available metadata 471 + * @returns A meta object with any properties you want to include 472 + * 473 + * @example 474 + * ```ts 475 + * meta: (operation) => ({ 476 + * customField: operation.id, 477 + * isDeprecated: operation.deprecated, 478 + * tags: operation.tags, 479 + * customObject: { 480 + * method: operation.method, 481 + * path: operation.path 482 + * } 483 + * }) 484 + * ``` 485 + * 486 + * @default undefined 487 + */ 488 + meta: (operation: IR.OperationObject) => Record<string, unknown>; 489 + }; 594 490 /** 595 491 * Configuration for generated `useQuery()` function helpers. 596 492 * 597 493 * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/useQuery useQuery} 598 494 */ 599 - useQuery: { 600 - /** 601 - * The casing convention to use for generated names. 602 - * 603 - * @default 'camelCase' 604 - */ 605 - case: Casing; 606 - /** 607 - * Whether to generate `useQuery()` function helpers. 608 - * 609 - * @default true 610 - */ 611 - enabled: boolean; 612 - /** 613 - * Custom naming pattern for generated `useQuery()` function names. The name variable is 614 - * obtained from the SDK function name. 615 - * 616 - * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/useQuery useQuery} 617 - * 618 - * @default 'use{{name}}Query' 619 - */ 620 - name: NameTransformer; 621 - }; 495 + useQuery: NamingOptions & FeatureToggle; 622 496 }; 623 497 624 498 export type TanStackReactQueryPlugin = DefinePlugin<UserConfig, Config>;
+126 -228
packages/openapi-ts/src/plugins/@tanstack/solid-query/types.d.ts
··· 1 + import type { 2 + FeatureToggle, 3 + IndexExportOption, 4 + NamingOptions, 5 + } from '~/config/shared'; 1 6 import type { IR } from '~/ir/types'; 2 7 import type { DefinePlugin, Plugin } from '~/plugins'; 3 8 import type { Casing, NameTransformer } from '~/utils/naming'; ··· 5 10 export type UserConfig = Plugin.Name<'@tanstack/solid-query'> & 6 11 Plugin.Hooks & { 7 12 /** 8 - * The casing convention to use for generated names. 13 + * Casing convention for generated names. 9 14 * 10 15 * @default 'camelCase' 11 16 */ ··· 22 27 */ 23 28 comments?: boolean; 24 29 /** 25 - * Should the exports from the generated files be re-exported in the index barrel file? 30 + * Whether exports should be re-exported in the index file. 26 31 * 27 32 * @default false 28 33 */ ··· 44 49 | NameTransformer 45 50 | { 46 51 /** 47 - * The casing convention to use for generated names. 52 + * Casing convention for generated names. 48 53 * 49 54 * @default 'camelCase' 50 55 */ 51 56 case?: Casing; 52 57 /** 53 - * Whether to generate infinite query key helpers. 58 + * Whether this feature is enabled. 54 59 * 55 60 * @default true 56 61 */ 57 62 enabled?: boolean; 58 63 /** 59 - * Custom naming pattern for generated infinite query key names. The name variable is 60 - * obtained from the SDK function name. 64 + * Naming pattern for generated names. 61 65 * 62 66 * @default '{{name}}InfiniteQueryKey' 63 67 * @see https://tanstack.com/query/v5/docs/framework/solid/reference/createInfiniteQuery ··· 88 92 | NameTransformer 89 93 | { 90 94 /** 91 - * The casing convention to use for generated names. 95 + * Casing convention for generated names. 92 96 * 93 97 * @default 'camelCase' 94 98 */ 95 99 case?: Casing; 96 100 /** 97 - * Whether to generate infinite query options helpers. 101 + * Whether this feature is enabled. 98 102 * 99 103 * @default true 100 104 */ ··· 123 127 */ 124 128 meta?: (operation: IR.OperationObject) => Record<string, unknown>; 125 129 /** 126 - * Custom naming pattern for generated infinite query options names. The name variable is 127 - * obtained from the SDK function name. 130 + * Naming pattern for generated names. 128 131 * 129 132 * @default '{{name}}InfiniteOptions' 130 133 * @see https://tanstack.com/query/v5/docs/framework/solid/reference/createInfiniteQuery ··· 148 151 | NameTransformer 149 152 | { 150 153 /** 151 - * The casing convention to use for generated names. 154 + * Casing convention for generated names. 152 155 * 153 156 * @default 'camelCase' 154 157 */ 155 158 case?: Casing; 156 159 /** 157 - * Whether to generate mutation options helpers. 160 + * Whether this feature is enabled. 158 161 * 159 162 * @default true 160 163 */ ··· 182 185 */ 183 186 meta?: (operation: IR.OperationObject) => Record<string, unknown>; 184 187 /** 185 - * Custom naming pattern for generated mutation options names. The name variable is 186 - * obtained from the SDK function name. 188 + * Naming pattern for generated names. 187 189 * 188 190 * @default '{{name}}Mutation' 189 191 * @see https://tanstack.com/query/v5/docs/framework/solid/reference/createMutation ··· 207 209 | NameTransformer 208 210 | { 209 211 /** 210 - * The casing convention to use for generated names. 212 + * Casing convention for generated names. 211 213 * 212 214 * @default 'camelCase' 213 215 */ 214 216 case?: Casing; 215 217 /** 216 - * Whether to generate query keys. 218 + * Whether this feature is enabled. 217 219 * 218 220 * @default true 219 221 */ 220 222 enabled?: boolean; 221 223 /** 222 - * Custom naming pattern for generated query key names. The name variable is 223 - * obtained from the SDK function name. 224 + * Naming pattern for generated names. 224 225 * 225 226 * @default '{{name}}QueryKey' 226 227 * @see https://tanstack.com/query/v5/docs/framework/solid/reference/queryKey ··· 251 252 | NameTransformer 252 253 | { 253 254 /** 254 - * The casing convention to use for generated names. 255 + * Casing convention for generated names. 255 256 * 256 257 * @default 'camelCase' 257 258 */ 258 259 case?: Casing; 259 260 /** 260 - * Whether to generate query options helpers. 261 + * Whether this feature is enabled. 261 262 * 262 263 * @default true 263 264 */ ··· 291 292 */ 292 293 meta?: (operation: IR.OperationObject) => Record<string, unknown>; 293 294 /** 294 - * Custom naming pattern for generated query options names. The name variable is 295 - * obtained from the SDK function name. 295 + * Naming pattern for generated names. 296 296 * 297 297 * @default '{{name}}Options' 298 298 * @see https://tanstack.com/query/v5/docs/framework/solid/reference/createQuery ··· 302 302 }; 303 303 304 304 export type Config = Plugin.Name<'@tanstack/solid-query'> & 305 - Plugin.Hooks & { 305 + Plugin.Hooks & 306 + IndexExportOption & { 306 307 /** 307 - * The casing convention to use for generated names. 308 - * 309 - * @default 'camelCase' 308 + * Casing convention for generated names. 310 309 */ 311 310 case: Casing; 312 311 /** ··· 316 315 */ 317 316 comments: boolean; 318 317 /** 319 - * Should the exports from the generated files be re-exported in the index barrel file? 320 - * 321 - * @default false 322 - */ 323 - exportFromIndex: boolean; 324 - /** 325 318 * Resolved configuration for generated infinite query key helpers. 326 319 * 327 320 * @see https://tanstack.com/query/v5/docs/framework/solid/reference/createInfiniteQuery 328 321 */ 329 - infiniteQueryKeys: { 330 - /** 331 - * The casing convention to use for generated names. 332 - * 333 - * @default 'camelCase' 334 - */ 335 - case: Casing; 336 - /** 337 - * Whether to generate infinite query key helpers. 338 - * 339 - * @default true 340 - */ 341 - enabled: boolean; 342 - /** 343 - * Custom naming pattern for generated infinite query key names. The name variable is 344 - * obtained from the SDK function name. 345 - * 346 - * @default '{{name}}InfiniteQueryKey' 347 - * @see https://tanstack.com/query/v5/docs/framework/solid/reference/createInfiniteQuery 348 - */ 349 - name: NameTransformer; 350 - /** 351 - * Whether to include operation tags in infinite query keys. 352 - * This will make query keys larger but provides better cache invalidation capabilities. 353 - * 354 - * @default false 355 - */ 356 - tags: boolean; 357 - }; 322 + infiniteQueryKeys: NamingOptions & 323 + FeatureToggle & { 324 + /** 325 + * Whether to include operation tags in infinite query keys. 326 + * This will make query keys larger but provides better cache invalidation capabilities. 327 + * 328 + * @default false 329 + */ 330 + tags: boolean; 331 + }; 358 332 /** 359 333 * Resolved configuration for generated infinite query options helpers. 360 334 * 361 335 * @see https://tanstack.com/query/v5/docs/framework/solid/reference/createInfiniteQuery 362 336 */ 363 - infiniteQueryOptions: { 364 - /** 365 - * The casing convention to use for generated names. 366 - * 367 - * @default 'camelCase' 368 - */ 369 - case: Casing; 370 - /** 371 - * Whether to generate infinite query options helpers. 372 - * 373 - * @default true 374 - */ 375 - enabled: boolean; 376 - /** 377 - * Custom function to generate metadata for the operation. 378 - * Can return any valid meta object that will be included in the generated infinite query options. 379 - * @param operation - The operation object containing all available metadata 380 - * @returns A meta object with any properties you want to include 381 - * 382 - * @example 383 - * ```ts 384 - * meta: (operation) => ({ 385 - * customField: operation.id, 386 - * isDeprecated: operation.deprecated, 387 - * tags: operation.tags, 388 - * customObject: { 389 - * method: operation.method, 390 - * path: operation.path 391 - * } 392 - * }) 393 - * ``` 394 - * 395 - * @default undefined 396 - */ 397 - meta: (operation: IR.OperationObject) => Record<string, unknown>; 398 - /** 399 - * Custom naming pattern for generated infinite query options names. The name variable is 400 - * obtained from the SDK function name. 401 - * 402 - * @default '{{name}}InfiniteOptions' 403 - * @see https://tanstack.com/query/v5/docs/framework/solid/reference/createInfiniteQuery 404 - */ 405 - name: NameTransformer; 406 - }; 337 + infiniteQueryOptions: NamingOptions & 338 + FeatureToggle & { 339 + /** 340 + * Custom function to generate metadata for the operation. 341 + * Can return any valid meta object that will be included in the generated infinite query options. 342 + * @param operation - The operation object containing all available metadata 343 + * @returns A meta object with any properties you want to include 344 + * 345 + * @example 346 + * ```ts 347 + * meta: (operation) => ({ 348 + * customField: operation.id, 349 + * isDeprecated: operation.deprecated, 350 + * tags: operation.tags, 351 + * customObject: { 352 + * method: operation.method, 353 + * path: operation.path 354 + * } 355 + * }) 356 + * ``` 357 + * 358 + * @default undefined 359 + */ 360 + meta: (operation: IR.OperationObject) => Record<string, unknown>; 361 + }; 407 362 /** 408 363 * Resolved configuration for generated mutation options helpers. 409 364 * 410 365 * @see https://tanstack.com/query/v5/docs/framework/solid/reference/createMutation 411 366 */ 412 - mutationOptions: { 413 - /** 414 - * The casing convention to use for generated names. 415 - * 416 - * @default 'camelCase' 417 - */ 418 - case: Casing; 419 - /** 420 - * Whether to generate mutation options helpers. 421 - * 422 - * @default true 423 - */ 424 - enabled: boolean; 425 - /** 426 - * Custom function to generate metadata for the operation. 427 - * Can return any valid meta object that will be included in the generated mutation options. 428 - * @param operation - The operation object containing all available metadata 429 - * @returns A meta object with any properties you want to include 430 - * 431 - * @example 432 - * ```ts 433 - * meta: (operation) => ({ 434 - * customField: operation.id, 435 - * isDeprecated: operation.deprecated, 436 - * tags: operation.tags, 437 - * customObject: { 438 - * method: operation.method, 439 - * path: operation.path 440 - * } 441 - * }) 442 - * ``` 443 - * 444 - * @default undefined 445 - */ 446 - meta: (operation: IR.OperationObject) => Record<string, unknown>; 447 - /** 448 - * Custom naming pattern for generated mutation options names. The name variable is 449 - * obtained from the SDK function name. 450 - * 451 - * @default '{{name}}Mutation' 452 - * @see https://tanstack.com/query/v5/docs/framework/solid/reference/createMutation 453 - */ 454 - name: NameTransformer; 455 - }; 367 + mutationOptions: NamingOptions & 368 + FeatureToggle & { 369 + /** 370 + * Custom function to generate metadata for the operation. 371 + * Can return any valid meta object that will be included in the generated mutation options. 372 + * @param operation - The operation object containing all available metadata 373 + * @returns A meta object with any properties you want to include 374 + * 375 + * @example 376 + * ```ts 377 + * meta: (operation) => ({ 378 + * customField: operation.id, 379 + * isDeprecated: operation.deprecated, 380 + * tags: operation.tags, 381 + * customObject: { 382 + * method: operation.method, 383 + * path: operation.path 384 + * } 385 + * }) 386 + * ``` 387 + * 388 + * @default undefined 389 + */ 390 + meta: (operation: IR.OperationObject) => Record<string, unknown>; 391 + }; 456 392 /** 457 393 * Resolved configuration for generated query keys. 458 394 * 459 395 * @see https://tanstack.com/query/v5/docs/framework/solid/reference/queryKey 460 396 */ 461 - queryKeys: { 462 - /** 463 - * The casing convention to use for generated names. 464 - * 465 - * @default 'camelCase' 466 - */ 467 - case: Casing; 468 - /** 469 - * Whether to generate query keys. 470 - * 471 - * @default true 472 - */ 473 - enabled: boolean; 474 - /** 475 - * Custom naming pattern for generated query key names. The name variable is 476 - * obtained from the SDK function name. 477 - * 478 - * @default '{{name}}QueryKey' 479 - * @see https://tanstack.com/query/v5/docs/framework/solid/reference/queryKey 480 - */ 481 - name: NameTransformer; 482 - /** 483 - * Whether to include operation tags in query keys. 484 - * This will make query keys larger but provides better cache invalidation capabilities. 485 - * 486 - * @default false 487 - */ 488 - tags: boolean; 489 - }; 397 + queryKeys: NamingOptions & 398 + FeatureToggle & { 399 + /** 400 + * Whether to include operation tags in query keys. 401 + * This will make query keys larger but provides better cache invalidation capabilities. 402 + * 403 + * @default false 404 + */ 405 + tags: boolean; 406 + }; 490 407 /** 491 408 * Resolved configuration for generated query options helpers. 492 409 * 493 410 * @see https://tanstack.com/query/v5/docs/framework/solid/reference/createQuery 494 411 */ 495 - queryOptions: { 496 - /** 497 - * The casing convention to use for generated names. 498 - * 499 - * @default 'camelCase' 500 - */ 501 - case: Casing; 502 - /** 503 - * Whether to generate query options helpers. 504 - * 505 - * @default true 506 - */ 507 - enabled: boolean; 508 - /** 509 - * Whether to export generated symbols. 510 - * 511 - * @default true 512 - */ 513 - exported: boolean; 514 - /** 515 - * Custom function to generate metadata for the operation. 516 - * Can return any valid meta object that will be included in the generated query options. 517 - * @param operation - The operation object containing all available metadata 518 - * @returns A meta object with any properties you want to include 519 - * 520 - * @example 521 - * ```ts 522 - * meta: (operation) => ({ 523 - * customField: operation.id, 524 - * isDeprecated: operation.deprecated, 525 - * tags: operation.tags, 526 - * customObject: { 527 - * method: operation.method, 528 - * path: operation.path 529 - * } 530 - * }) 531 - * ``` 532 - * 533 - * @default undefined 534 - */ 535 - meta: (operation: IR.OperationObject) => Record<string, unknown>; 536 - /** 537 - * Custom naming pattern for generated query options names. The name variable is 538 - * obtained from the SDK function name. 539 - * 540 - * @default '{{name}}Options' 541 - * @see https://tanstack.com/query/v5/docs/framework/solid/reference/createQuery 542 - */ 543 - name: NameTransformer; 544 - }; 412 + queryOptions: NamingOptions & 413 + FeatureToggle & { 414 + /** 415 + * Whether to export generated symbols. 416 + * 417 + * @default true 418 + */ 419 + exported: boolean; 420 + /** 421 + * Custom function to generate metadata for the operation. 422 + * Can return any valid meta object that will be included in the generated query options. 423 + * @param operation - The operation object containing all available metadata 424 + * @returns A meta object with any properties you want to include 425 + * 426 + * @example 427 + * ```ts 428 + * meta: (operation) => ({ 429 + * customField: operation.id, 430 + * isDeprecated: operation.deprecated, 431 + * tags: operation.tags, 432 + * customObject: { 433 + * method: operation.method, 434 + * path: operation.path 435 + * } 436 + * }) 437 + * ``` 438 + * 439 + * @default undefined 440 + */ 441 + meta: (operation: IR.OperationObject) => Record<string, unknown>; 442 + }; 545 443 }; 546 444 547 445 export type TanStackSolidQueryPlugin = DefinePlugin<UserConfig, Config>;
+126 -228
packages/openapi-ts/src/plugins/@tanstack/svelte-query/types.d.ts
··· 1 + import type { 2 + FeatureToggle, 3 + IndexExportOption, 4 + NamingOptions, 5 + } from '~/config/shared'; 1 6 import type { IR } from '~/ir/types'; 2 7 import type { DefinePlugin, Plugin } from '~/plugins'; 3 8 import type { Casing, NameTransformer } from '~/utils/naming'; ··· 5 10 export type UserConfig = Plugin.Name<'@tanstack/svelte-query'> & 6 11 Plugin.Hooks & { 7 12 /** 8 - * The casing convention to use for generated names. 13 + * Casing convention for generated names. 9 14 * 10 15 * @default 'camelCase' 11 16 */ ··· 22 27 */ 23 28 comments?: boolean; 24 29 /** 25 - * Should the exports from the generated files be re-exported in the index barrel file? 30 + * Whether exports should be re-exported in the index file. 26 31 * 27 32 * @default false 28 33 */ ··· 44 49 | NameTransformer 45 50 | { 46 51 /** 47 - * The casing convention to use for generated names. 52 + * Casing convention for generated names. 48 53 * 49 54 * @default 'camelCase' 50 55 */ 51 56 case?: Casing; 52 57 /** 53 - * Whether to generate infinite query key helpers. 58 + * Whether this feature is enabled. 54 59 * 55 60 * @default true 56 61 */ 57 62 enabled?: boolean; 58 63 /** 59 - * Custom naming pattern for generated infinite query key names. The name variable is 60 - * obtained from the SDK function name. 64 + * Naming pattern for generated names. 61 65 * 62 66 * @default '{{name}}InfiniteQueryKey' 63 67 * @see https://tanstack.com/query/v5/docs/framework/svelte/reference/functions/createinfinitequery ··· 88 92 | NameTransformer 89 93 | { 90 94 /** 91 - * The casing convention to use for generated names. 95 + * Casing convention for generated names. 92 96 * 93 97 * @default 'camelCase' 94 98 */ 95 99 case?: Casing; 96 100 /** 97 - * Whether to generate infinite query options helpers. 101 + * Whether this feature is enabled. 98 102 * 99 103 * @default true 100 104 */ ··· 122 126 */ 123 127 meta?: (operation: IR.OperationObject) => Record<string, unknown>; 124 128 /** 125 - * Custom naming pattern for generated infinite query options names. The name variable is 126 - * obtained from the SDK function name. 129 + * Naming pattern for generated names. 127 130 * 128 131 * @default '{{name}}InfiniteOptions' 129 132 * @see https://tanstack.com/query/v5/docs/framework/svelte/reference/functions/createinfinitequery ··· 147 150 | NameTransformer 148 151 | { 149 152 /** 150 - * The casing convention to use for generated names. 153 + * Casing convention for generated names. 151 154 * 152 155 * @default 'camelCase' 153 156 */ 154 157 case?: Casing; 155 158 /** 156 - * Whether to generate mutation options helpers. 159 + * Whether this feature is enabled. 157 160 * 158 161 * @default true 159 162 */ ··· 181 184 */ 182 185 meta?: (operation: IR.OperationObject) => Record<string, unknown>; 183 186 /** 184 - * Custom naming pattern for generated mutation options names. The name variable is 185 - * obtained from the SDK function name. 187 + * Naming pattern for generated names. 186 188 * 187 189 * @default '{{name}}Mutation' 188 190 * @see https://tanstack.com/query/v5/docs/framework/svelte/reference/functions/createmutation ··· 206 208 | NameTransformer 207 209 | { 208 210 /** 209 - * The casing convention to use for generated names. 211 + * Casing convention for generated names. 210 212 * 211 213 * @default 'camelCase' 212 214 */ 213 215 case?: Casing; 214 216 /** 215 - * Whether to generate query keys. 217 + * Whether this feature is enabled. 216 218 * 217 219 * @default true 218 220 */ 219 221 enabled?: boolean; 220 222 /** 221 - * Custom naming pattern for generated query key names. The name variable is 222 - * obtained from the SDK function name. 223 + * Naming pattern for generated names. 223 224 * 224 225 * @default '{{name}}QueryKey' 225 226 * @see https://tanstack.com/query/v5/docs/framework/react/guides/query-keys ··· 250 251 | NameTransformer 251 252 | { 252 253 /** 253 - * The casing convention to use for generated names. 254 + * Casing convention for generated names. 254 255 * 255 256 * @default 'camelCase' 256 257 */ 257 258 case?: Casing; 258 259 /** 259 - * Whether to generate query options helpers. 260 + * Whether this feature is enabled. 260 261 * 261 262 * @default true 262 263 */ ··· 290 291 */ 291 292 meta?: (operation: IR.OperationObject) => Record<string, unknown>; 292 293 /** 293 - * Custom naming pattern for generated query options names. The name variable is 294 - * obtained from the SDK function name. 294 + * Naming pattern for generated names. 295 295 * 296 296 * @default '{{name}}Options' 297 297 * @see https://tanstack.com/query/v5/docs/framework/svelte/reference/functions/createquery ··· 301 301 }; 302 302 303 303 export type Config = Plugin.Name<'@tanstack/svelte-query'> & 304 - Plugin.Hooks & { 304 + Plugin.Hooks & 305 + IndexExportOption & { 305 306 /** 306 - * The casing convention to use for generated names. 307 - * 308 - * @default 'camelCase' 307 + * Casing convention for generated names. 309 308 */ 310 309 case: Casing; 311 310 /** ··· 315 314 */ 316 315 comments: boolean; 317 316 /** 318 - * Should the exports from the generated files be re-exported in the index barrel file? 319 - * 320 - * @default false 321 - */ 322 - exportFromIndex: boolean; 323 - /** 324 317 * Resolved configuration for generated infinite query key helpers. 325 318 * 326 319 * @see https://tanstack.com/query/v5/docs/framework/svelte/reference/functions/createinfinitequery 327 320 */ 328 - infiniteQueryKeys: { 329 - /** 330 - * The casing convention to use for generated names. 331 - * 332 - * @default 'camelCase' 333 - */ 334 - case: Casing; 335 - /** 336 - * Whether to generate infinite query key helpers. 337 - * 338 - * @default true 339 - */ 340 - enabled: boolean; 341 - /** 342 - * Custom naming pattern for generated infinite query key names. The name variable is 343 - * obtained from the SDK function name. 344 - * 345 - * @default '{{name}}InfiniteQueryKey' 346 - * @see https://tanstack.com/query/v5/docs/framework/svelte/reference/functions/createinfinitequery 347 - */ 348 - name: NameTransformer; 349 - /** 350 - * Whether to include operation tags in infinite query keys. 351 - * This will make query keys larger but provides better cache invalidation capabilities. 352 - * 353 - * @default false 354 - */ 355 - tags: boolean; 356 - }; 321 + infiniteQueryKeys: NamingOptions & 322 + FeatureToggle & { 323 + /** 324 + * Whether to include operation tags in infinite query keys. 325 + * This will make query keys larger but provides better cache invalidation capabilities. 326 + * 327 + * @default false 328 + */ 329 + tags: boolean; 330 + }; 357 331 /** 358 332 * Resolved configuration for generated infinite query options helpers. 359 333 * 360 334 * @see https://tanstack.com/query/v5/docs/framework/svelte/reference/functions/createinfinitequery 361 335 */ 362 - infiniteQueryOptions: { 363 - /** 364 - * The casing convention to use for generated names. 365 - * 366 - * @default 'camelCase' 367 - */ 368 - case: Casing; 369 - /** 370 - * Whether to generate infinite query options helpers. 371 - * 372 - * @default true 373 - */ 374 - enabled: boolean; 375 - /** 376 - * Custom function to generate metadata for the operation. 377 - * Can return any valid meta object that will be included in the generated infinite query options. 378 - * @param operation - The operation object containing all available metadata 379 - * @returns A meta object with any properties you want to include 380 - * 381 - * @example 382 - * ```ts 383 - * meta: (operation) => ({ 384 - * customField: operation.id, 385 - * isDeprecated: operation.deprecated, 386 - * tags: operation.tags, 387 - * customObject: { 388 - * method: operation.method, 389 - * path: operation.path 390 - * } 391 - * }) 392 - * ``` 393 - * 394 - * @default undefined 395 - */ 396 - meta: (operation: IR.OperationObject) => Record<string, unknown>; 397 - /** 398 - * Custom naming pattern for generated infinite query options names. The name variable is 399 - * obtained from the SDK function name. 400 - * 401 - * @default '{{name}}InfiniteOptions' 402 - * @see https://tanstack.com/query/v5/docs/framework/svelte/reference/functions/createinfinitequery 403 - */ 404 - name: NameTransformer; 405 - }; 336 + infiniteQueryOptions: NamingOptions & 337 + FeatureToggle & { 338 + /** 339 + * Custom function to generate metadata for the operation. 340 + * Can return any valid meta object that will be included in the generated infinite query options. 341 + * @param operation - The operation object containing all available metadata 342 + * @returns A meta object with any properties you want to include 343 + * 344 + * @example 345 + * ```ts 346 + * meta: (operation) => ({ 347 + * customField: operation.id, 348 + * isDeprecated: operation.deprecated, 349 + * tags: operation.tags, 350 + * customObject: { 351 + * method: operation.method, 352 + * path: operation.path 353 + * } 354 + * }) 355 + * ``` 356 + * 357 + * @default undefined 358 + */ 359 + meta: (operation: IR.OperationObject) => Record<string, unknown>; 360 + }; 406 361 /** 407 362 * Resolved configuration for generated mutation options helpers. 408 363 * 409 364 * @see https://tanstack.com/query/v5/docs/framework/svelte/reference/functions/createmutation 410 365 */ 411 - mutationOptions: { 412 - /** 413 - * The casing convention to use for generated names. 414 - * 415 - * @default 'camelCase' 416 - */ 417 - case: Casing; 418 - /** 419 - * Whether to generate mutation options helpers. 420 - * 421 - * @default true 422 - */ 423 - enabled: boolean; 424 - /** 425 - * Custom function to generate metadata for the operation. 426 - * Can return any valid meta object that will be included in the generated mutation options. 427 - * @param operation - The operation object containing all available metadata 428 - * @returns A meta object with any properties you want to include 429 - * 430 - * @example 431 - * ```ts 432 - * meta: (operation) => ({ 433 - * customField: operation.id, 434 - * isDeprecated: operation.deprecated, 435 - * tags: operation.tags, 436 - * customObject: { 437 - * method: operation.method, 438 - * path: operation.path 439 - * } 440 - * }) 441 - * ``` 442 - * 443 - * @default undefined 444 - */ 445 - meta: (operation: IR.OperationObject) => Record<string, unknown>; 446 - /** 447 - * Custom naming pattern for generated mutation options names. The name variable is 448 - * obtained from the SDK function name. 449 - * 450 - * @default '{{name}}Mutation' 451 - * @see https://tanstack.com/query/v5/docs/framework/svelte/reference/functions/createmutation 452 - */ 453 - name: NameTransformer; 454 - }; 366 + mutationOptions: NamingOptions & 367 + FeatureToggle & { 368 + /** 369 + * Custom function to generate metadata for the operation. 370 + * Can return any valid meta object that will be included in the generated mutation options. 371 + * @param operation - The operation object containing all available metadata 372 + * @returns A meta object with any properties you want to include 373 + * 374 + * @example 375 + * ```ts 376 + * meta: (operation) => ({ 377 + * customField: operation.id, 378 + * isDeprecated: operation.deprecated, 379 + * tags: operation.tags, 380 + * customObject: { 381 + * method: operation.method, 382 + * path: operation.path 383 + * } 384 + * }) 385 + * ``` 386 + * 387 + * @default undefined 388 + */ 389 + meta: (operation: IR.OperationObject) => Record<string, unknown>; 390 + }; 455 391 /** 456 392 * Resolved configuration for generated query keys. 457 393 * 458 394 * @see https://tanstack.com/query/v5/docs/framework/react/guides/query-keys 459 395 */ 460 - queryKeys: { 461 - /** 462 - * The casing convention to use for generated names. 463 - * 464 - * @default 'camelCase' 465 - */ 466 - case: Casing; 467 - /** 468 - * Whether to generate query keys. 469 - * 470 - * @default true 471 - */ 472 - enabled: boolean; 473 - /** 474 - * Custom naming pattern for generated query key names. The name variable is 475 - * obtained from the SDK function name. 476 - * 477 - * @default '{{name}}QueryKey' 478 - * @see https://tanstack.com/query/v5/docs/framework/react/guides/query-keys 479 - */ 480 - name: NameTransformer; 481 - /** 482 - * Whether to include operation tags in query keys. 483 - * This will make query keys larger but provides better cache invalidation capabilities. 484 - * 485 - * @default false 486 - */ 487 - tags: boolean; 488 - }; 396 + queryKeys: NamingOptions & 397 + FeatureToggle & { 398 + /** 399 + * Whether to include operation tags in query keys. 400 + * This will make query keys larger but provides better cache invalidation capabilities. 401 + * 402 + * @default false 403 + */ 404 + tags: boolean; 405 + }; 489 406 /** 490 407 * Resolved configuration for generated query options helpers. 491 408 * 492 409 * @see https://tanstack.com/query/v5/docs/framework/svelte/reference/functions/createquery 493 410 */ 494 - queryOptions: { 495 - /** 496 - * The casing convention to use for generated names. 497 - * 498 - * @default 'camelCase' 499 - */ 500 - case: Casing; 501 - /** 502 - * Whether to generate query options helpers. 503 - * 504 - * @default true 505 - */ 506 - enabled: boolean; 507 - /** 508 - * Whether to export generated symbols. 509 - * 510 - * @default true 511 - */ 512 - exported: boolean; 513 - /** 514 - * Custom function to generate metadata for the operation. 515 - * Can return any valid meta object that will be included in the generated query options. 516 - * @param operation - The operation object containing all available metadata 517 - * @returns A meta object with any properties you want to include 518 - * 519 - * @example 520 - * ```ts 521 - * meta: (operation) => ({ 522 - * customField: operation.id, 523 - * isDeprecated: operation.deprecated, 524 - * tags: operation.tags, 525 - * customObject: { 526 - * method: operation.method, 527 - * path: operation.path 528 - * } 529 - * }) 530 - * ``` 531 - * 532 - * @default undefined 533 - */ 534 - meta: (operation: IR.OperationObject) => Record<string, unknown>; 535 - /** 536 - * Custom naming pattern for generated query options names. The name variable is 537 - * obtained from the SDK function name. 538 - * 539 - * @default '{{name}}Options' 540 - * @see https://tanstack.com/query/v5/docs/framework/svelte/reference/functions/createquery 541 - */ 542 - name: NameTransformer; 543 - }; 411 + queryOptions: NamingOptions & 412 + FeatureToggle & { 413 + /** 414 + * Whether to export generated symbols. 415 + * 416 + * @default true 417 + */ 418 + exported: boolean; 419 + /** 420 + * Custom function to generate metadata for the operation. 421 + * Can return any valid meta object that will be included in the generated query options. 422 + * @param operation - The operation object containing all available metadata 423 + * @returns A meta object with any properties you want to include 424 + * 425 + * @example 426 + * ```ts 427 + * meta: (operation) => ({ 428 + * customField: operation.id, 429 + * isDeprecated: operation.deprecated, 430 + * tags: operation.tags, 431 + * customObject: { 432 + * method: operation.method, 433 + * path: operation.path 434 + * } 435 + * }) 436 + * ``` 437 + * 438 + * @default undefined 439 + */ 440 + meta: (operation: IR.OperationObject) => Record<string, unknown>; 441 + }; 544 442 }; 545 443 546 444 export type TanStackSvelteQueryPlugin = DefinePlugin<UserConfig, Config>;
+129 -231
packages/openapi-ts/src/plugins/@tanstack/vue-query/types.d.ts
··· 1 + import type { 2 + FeatureToggle, 3 + IndexExportOption, 4 + NamingOptions, 5 + } from '~/config/shared'; 1 6 import type { IR } from '~/ir/types'; 2 7 import type { DefinePlugin, Plugin } from '~/plugins'; 3 8 import type { Casing, NameTransformer } from '~/utils/naming'; ··· 5 10 export type UserConfig = Plugin.Name<'@tanstack/vue-query'> & 6 11 Plugin.Hooks & { 7 12 /** 8 - * The casing convention to use for generated names. 13 + * Casing convention for generated names. 9 14 * 10 15 * @default 'camelCase' 11 16 */ ··· 22 27 */ 23 28 comments?: boolean; 24 29 /** 25 - * Should the exports from the generated files be re-exported in the index barrel file? 30 + * Whether exports should be re-exported in the index file. 26 31 * 27 32 * @default false 28 33 */ ··· 44 49 | NameTransformer 45 50 | { 46 51 /** 47 - * The casing convention to use for generated names. 52 + * Casing convention for generated names. 48 53 * 49 54 * @default 'camelCase' 50 55 */ 51 56 case?: Casing; 52 57 /** 53 - * Whether to generate infinite query key helpers. 58 + * Whether this feature is enabled. 54 59 * 55 60 * @default true 56 61 */ 57 62 enabled?: boolean; 58 63 /** 59 - * Custom naming pattern for generated infinite query key names. The name variable is 60 - * obtained from the SDK function name. 64 + * Naming pattern for generated names. 61 65 * 62 66 * @default '{{name}}InfiniteQueryKey' 63 67 * @see https://tanstack.com/query/v5/docs/framework/vue/reference/infiniteQueryOptions ··· 88 92 | NameTransformer 89 93 | { 90 94 /** 91 - * The casing convention to use for generated names. 95 + * Casing convention for generated names. 92 96 * 93 97 * @default 'camelCase' 94 98 */ 95 99 case?: Casing; 96 100 /** 97 - * Whether to generate infinite query options helpers. 101 + * Whether this feature is enabled. 98 102 * 99 103 * @default true 100 104 */ ··· 123 127 */ 124 128 meta?: (operation: IR.OperationObject) => Record<string, unknown>; 125 129 /** 126 - * Custom naming pattern for generated infinite query options names. The name variable is 127 - * obtained from the SDK function name. 130 + * Naming pattern for generated names. 128 131 * 129 132 * @default '{{name}}InfiniteOptions' 130 133 * @see https://tanstack.com/query/v5/docs/framework/vue/reference/infiniteQueryOptions ··· 148 151 | NameTransformer 149 152 | { 150 153 /** 151 - * The casing convention to use for generated names. 154 + * Casing convention for generated names. 152 155 * 153 156 * @default 'camelCase' 154 157 */ 155 158 case?: Casing; 156 159 /** 157 - * Whether to generate mutation options helpers. 160 + * Whether this feature is enabled. 158 161 * 159 162 * @default true 160 163 */ ··· 183 186 */ 184 187 meta?: (operation: IR.OperationObject) => Record<string, unknown>; 185 188 /** 186 - * Custom naming pattern for generated mutation options names. The name variable is 187 - * obtained from the SDK function name. 189 + * Naming pattern for generated names. 188 190 * 189 191 * @default '{{name}}Mutation' 190 192 * @see https://tanstack.com/query/v5/docs/framework/vue/reference/useMutation ··· 208 210 | NameTransformer 209 211 | { 210 212 /** 211 - * The casing convention to use for generated names. 213 + * Casing convention for generated names. 212 214 * 213 215 * @default 'camelCase' 214 216 */ 215 217 case?: Casing; 216 218 /** 217 - * Whether to generate query keys. 219 + * Whether this feature is enabled. 218 220 * 219 221 * @default true 220 222 */ 221 223 enabled?: boolean; 222 224 /** 223 - * Custom naming pattern for generated query key names. The name variable is 224 - * obtained from the SDK function name. 225 + * Naming pattern for generated names. 225 226 * 226 227 * @default '{{name}}QueryKey' 227 228 * @see https://tanstack.com/query/v5/docs/framework/vue/reference/queryKey ··· 252 253 | NameTransformer 253 254 | { 254 255 /** 255 - * The casing convention to use for generated names. 256 + * Casing convention for generated names. 256 257 * 257 258 * @default 'camelCase' 258 259 */ 259 260 case?: Casing; 260 261 /** 261 - * Whether to generate query options helpers. 262 + * Whether this feature is enabled. 262 263 * 263 264 * @default true 264 265 */ ··· 293 294 */ 294 295 meta?: (operation: IR.OperationObject) => Record<string, unknown>; 295 296 /** 296 - * Custom naming pattern for generated query options names. The name variable is 297 - * obtained from the SDK function name. 297 + * Naming pattern for generated names. 298 298 * 299 299 * @default '{{name}}Options' 300 300 * @see https://tanstack.com/query/v5/docs/framework/vue/reference/queryOptions ··· 304 304 }; 305 305 306 306 export type Config = Plugin.Name<'@tanstack/vue-query'> & 307 - Plugin.Hooks & { 307 + Plugin.Hooks & 308 + IndexExportOption & { 308 309 /** 309 - * The casing convention to use for generated names. 310 - * 311 - * @default 'camelCase' 310 + * Casing convention for generated names. 312 311 */ 313 312 case: Casing; 314 313 /** ··· 317 316 * @default true 318 317 */ 319 318 comments: boolean; 320 - /** 321 - * Should the exports from the generated files be re-exported in the index barrel file? 322 - * 323 - * @default false 324 - */ 325 - exportFromIndex: boolean; 326 319 /** 327 320 * Resolved configuration for generated infinite query key helpers. 328 321 * 329 322 * @see https://tanstack.com/query/v5/docs/framework/vue/reference/infiniteQueryOptions 330 323 */ 331 - infiniteQueryKeys: { 332 - /** 333 - * The casing convention to use for generated names. 334 - * 335 - * @default 'camelCase' 336 - */ 337 - case: Casing; 338 - /** 339 - * Whether to generate infinite query key helpers. 340 - * 341 - * @default true 342 - */ 343 - enabled: boolean; 344 - /** 345 - * Custom naming pattern for generated infinite query key names. The name variable is 346 - * obtained from the SDK function name. 347 - * 348 - * @default '{{name}}InfiniteQueryKey' 349 - * @see https://tanstack.com/query/v5/docs/framework/vue/reference/infiniteQueryOptions 350 - */ 351 - name: NameTransformer; 352 - /** 353 - * Whether to include operation tags in infinite query keys. 354 - * This will make query keys larger but provides better cache invalidation capabilities. 355 - * 356 - * @default false 357 - */ 358 - tags: boolean; 359 - }; 324 + infiniteQueryKeys: NamingOptions & 325 + FeatureToggle & { 326 + /** 327 + * Whether to include operation tags in infinite query keys. 328 + * This will make query keys larger but provides better cache invalidation capabilities. 329 + * 330 + * @default false 331 + */ 332 + tags: boolean; 333 + }; 360 334 /** 361 335 * Resolved configuration for generated infinite query options helpers. 362 336 * 363 337 * @see https://tanstack.com/query/v5/docs/framework/vue/reference/infiniteQueryOptions 364 338 */ 365 - infiniteQueryOptions: { 366 - /** 367 - * The casing convention to use for generated names. 368 - * 369 - * @default 'camelCase' 370 - */ 371 - case: Casing; 372 - /** 373 - * Whether to generate infinite query options helpers. 374 - * 375 - * @default true 376 - */ 377 - enabled: boolean; 378 - /** 379 - * Custom function to generate metadata for the operation. 380 - * Can return any valid meta object that will be included in the generated infinite query options. 381 - * 382 - * @param operation - The operation object containing all available metadata 383 - * @returns A meta object with any properties you want to include 384 - * 385 - * @example 386 - * ```ts 387 - * meta: (operation) => ({ 388 - * customField: operation.id, 389 - * isDeprecated: operation.deprecated, 390 - * tags: operation.tags, 391 - * customObject: { 392 - * method: operation.method, 393 - * path: operation.path 394 - * } 395 - * }) 396 - * ``` 397 - * 398 - * @default undefined 399 - */ 400 - meta: (operation: IR.OperationObject) => Record<string, unknown>; 401 - /** 402 - * Custom naming pattern for generated infinite query options names. The name variable is 403 - * obtained from the SDK function name. 404 - * 405 - * @default '{{name}}InfiniteOptions' 406 - * @see https://tanstack.com/query/v5/docs/framework/vue/reference/infiniteQueryOptions 407 - */ 408 - name: NameTransformer; 409 - }; 339 + infiniteQueryOptions: NamingOptions & 340 + FeatureToggle & { 341 + /** 342 + * Custom function to generate metadata for the operation. 343 + * Can return any valid meta object that will be included in the generated infinite query options. 344 + * 345 + * @param operation - The operation object containing all available metadata 346 + * @returns A meta object with any properties you want to include 347 + * 348 + * @example 349 + * ```ts 350 + * meta: (operation) => ({ 351 + * customField: operation.id, 352 + * isDeprecated: operation.deprecated, 353 + * tags: operation.tags, 354 + * customObject: { 355 + * method: operation.method, 356 + * path: operation.path 357 + * } 358 + * }) 359 + * ``` 360 + * 361 + * @default undefined 362 + */ 363 + meta: (operation: IR.OperationObject) => Record<string, unknown>; 364 + }; 410 365 /** 411 366 * Resolved configuration for generated mutation options helpers. 412 367 * 413 368 * @see https://tanstack.com/query/v5/docs/framework/vue/reference/useMutation 414 369 */ 415 - mutationOptions: { 416 - /** 417 - * The casing convention to use for generated names. 418 - * 419 - * @default 'camelCase' 420 - */ 421 - case: Casing; 422 - /** 423 - * Whether to generate mutation options helpers. 424 - * 425 - * @default true 426 - */ 427 - enabled: boolean; 428 - /** 429 - * Custom function to generate metadata for the operation. 430 - * Can return any valid meta object that will be included in the generated mutation options. 431 - * 432 - * @param operation - The operation object containing all available metadata 433 - * @returns A meta object with any properties you want to include 434 - * 435 - * @example 436 - * ```ts 437 - * meta: (operation) => ({ 438 - * customField: operation.id, 439 - * isDeprecated: operation.deprecated, 440 - * tags: operation.tags, 441 - * customObject: { 442 - * method: operation.method, 443 - * path: operation.path 444 - * } 445 - * }) 446 - * ``` 447 - * 448 - * @default undefined 449 - */ 450 - meta: (operation: IR.OperationObject) => Record<string, unknown>; 451 - /** 452 - * Custom naming pattern for generated mutation options names. The name variable is 453 - * obtained from the SDK function name. 454 - * 455 - * @default '{{name}}Mutation' 456 - * @see https://tanstack.com/query/v5/docs/framework/vue/reference/useMutation 457 - */ 458 - name: NameTransformer; 459 - }; 370 + mutationOptions: NamingOptions & 371 + FeatureToggle & { 372 + /** 373 + * Custom function to generate metadata for the operation. 374 + * Can return any valid meta object that will be included in the generated mutation options. 375 + * 376 + * @param operation - The operation object containing all available metadata 377 + * @returns A meta object with any properties you want to include 378 + * 379 + * @example 380 + * ```ts 381 + * meta: (operation) => ({ 382 + * customField: operation.id, 383 + * isDeprecated: operation.deprecated, 384 + * tags: operation.tags, 385 + * customObject: { 386 + * method: operation.method, 387 + * path: operation.path 388 + * } 389 + * }) 390 + * ``` 391 + * 392 + * @default undefined 393 + */ 394 + meta: (operation: IR.OperationObject) => Record<string, unknown>; 395 + }; 460 396 /** 461 397 * Resolved configuration for generated query keys. 462 398 * 463 399 * @see https://tanstack.com/query/v5/docs/framework/vue/reference/queryKey 464 400 */ 465 - queryKeys: { 466 - /** 467 - * The casing convention to use for generated names. 468 - * 469 - * @default 'camelCase' 470 - */ 471 - case: Casing; 472 - /** 473 - * Whether to generate query keys. 474 - * 475 - * @default true 476 - */ 477 - enabled: boolean; 478 - /** 479 - * Custom naming pattern for generated query key names. The name variable is 480 - * obtained from the SDK function name. 481 - * 482 - * @default '{{name}}QueryKey' 483 - * @see https://tanstack.com/query/v5/docs/framework/vue/reference/queryKey 484 - */ 485 - name: NameTransformer; 486 - /** 487 - * Whether to include operation tags in query keys. 488 - * This will make query keys larger but provides better cache invalidation capabilities. 489 - * 490 - * @default false 491 - */ 492 - tags: boolean; 493 - }; 401 + queryKeys: NamingOptions & 402 + FeatureToggle & { 403 + /** 404 + * Whether to include operation tags in query keys. 405 + * This will make query keys larger but provides better cache invalidation capabilities. 406 + * 407 + * @default false 408 + */ 409 + tags: boolean; 410 + }; 494 411 /** 495 412 * Resolved configuration for generated query options helpers. 496 413 * 497 414 * @see https://tanstack.com/query/v5/docs/framework/vue/reference/queryOptions 498 415 */ 499 - queryOptions: { 500 - /** 501 - * The casing convention to use for generated names. 502 - * 503 - * @default 'camelCase' 504 - */ 505 - case: Casing; 506 - /** 507 - * Whether to generate query options helpers. 508 - * 509 - * @default true 510 - */ 511 - enabled: boolean; 512 - /** 513 - * Whether to export generated symbols. 514 - * 515 - * @default true 516 - */ 517 - exported: boolean; 518 - /** 519 - * Custom function to generate metadata for the operation. 520 - * Can return any valid meta object that will be included in the generated query options. 521 - * 522 - * @param operation - The operation object containing all available metadata 523 - * @returns A meta object with any properties you want to include 524 - * 525 - * @example 526 - * ```ts 527 - * meta: (operation) => ({ 528 - * customField: operation.id, 529 - * isDeprecated: operation.deprecated, 530 - * tags: operation.tags, 531 - * customObject: { 532 - * method: operation.method, 533 - * path: operation.path 534 - * } 535 - * }) 536 - * ``` 537 - * 538 - * @default undefined 539 - */ 540 - meta: (operation: IR.OperationObject) => Record<string, unknown>; 541 - /** 542 - * Custom naming pattern for generated query options names. The name variable is 543 - * obtained from the SDK function name. 544 - * 545 - * @default '{{name}}Options' 546 - * @see https://tanstack.com/query/v5/docs/framework/vue/reference/queryOptions 547 - */ 548 - name: NameTransformer; 549 - }; 416 + queryOptions: NamingOptions & 417 + FeatureToggle & { 418 + /** 419 + * Whether to export generated symbols. 420 + * 421 + * @default true 422 + */ 423 + exported: boolean; 424 + /** 425 + * Custom function to generate metadata for the operation. 426 + * Can return any valid meta object that will be included in the generated query options. 427 + * 428 + * @param operation - The operation object containing all available metadata 429 + * @returns A meta object with any properties you want to include 430 + * 431 + * @example 432 + * ```ts 433 + * meta: (operation) => ({ 434 + * customField: operation.id, 435 + * isDeprecated: operation.deprecated, 436 + * tags: operation.tags, 437 + * customObject: { 438 + * method: operation.method, 439 + * path: operation.path 440 + * } 441 + * }) 442 + * ``` 443 + * 444 + * @default undefined 445 + */ 446 + meta: (operation: IR.OperationObject) => Record<string, unknown>; 447 + }; 550 448 }; 551 449 552 450 export type TanStackVueQueryPlugin = DefinePlugin<UserConfig, Config>;
+70 -242
packages/openapi-ts/src/plugins/arktype/types.d.ts
··· 1 + import type { 2 + FeatureToggle, 3 + IndexExportOption, 4 + NamingOptions, 5 + } from '~/config/shared'; 1 6 import type { DefinePlugin, Plugin } from '~/plugins'; 2 7 import type { Casing, NameTransformer } from '~/utils/naming'; 3 8 ··· 6 11 export type UserConfig = Plugin.Name<'arktype'> & 7 12 Plugin.Hooks & { 8 13 /** 9 - * The casing convention to use for generated names. 14 + * Casing convention for generated names. 10 15 * 11 16 * @default 'PascalCase' 12 17 */ ··· 33 38 | NameTransformer 34 39 | { 35 40 /** 36 - * The casing convention to use for generated names. 41 + * Casing convention for generated names. 37 42 * 38 43 * @default 'PascalCase' 39 44 */ 40 45 case?: Casing; 41 46 /** 42 - * Whether to generate Arktype schemas for reusable definitions. 47 + * Whether this feature is enabled. 43 48 * 44 49 * @default true 45 50 */ 46 51 enabled?: boolean; 47 52 /** 48 - * Custom naming pattern for generated schema names. The name variable 49 - * is obtained from the schema name. 53 + * Naming pattern for generated names. 50 54 * 51 55 * @default '{{name}}' 52 56 */ ··· 72 76 | NameTransformer 73 77 | { 74 78 /** 75 - * The casing convention to use for generated type names. 79 + * Casing convention for generated names. 76 80 * 77 81 * @default 'PascalCase' 78 82 */ 79 83 case?: Casing; 80 84 /** 81 - * Whether to generate TypeScript types from Arktype schemas. 85 + * Whether this feature is enabled. 82 86 * 83 87 * @default true 84 88 */ 85 89 enabled?: boolean; 86 90 /** 87 - * Custom naming pattern for generated type names. The name variable is 88 - * obtained from the Arktype schema name. 91 + * Naming pattern for generated names. 89 92 * 90 93 * @default '{{name}}' 91 94 */ ··· 94 97 }; 95 98 }; 96 99 /** 97 - * Should the exports from the generated files be re-exported in the index 98 - * barrel file? 100 + * Whether exports should be re-exported in the index file. 99 101 * 100 102 * @default false 101 103 */ ··· 126 128 | NameTransformer 127 129 | { 128 130 /** 129 - * The casing convention to use for generated names. 131 + * Casing convention for generated names. 130 132 * 131 133 * @default 'PascalCase' 132 134 */ 133 135 case?: Casing; 134 136 /** 135 - * Whether to generate Arktype schemas for request definitions. 137 + * Whether this feature is enabled. 136 138 * 137 139 * @default true 138 140 */ 139 141 enabled?: boolean; 140 142 /** 141 - * Custom naming pattern for generated schema names. The name variable 142 - * is obtained from the operation name. 143 + * Naming pattern for generated names. 143 144 * 144 145 * @default '{{name}}Data' 145 146 */ ··· 165 166 | NameTransformer 166 167 | { 167 168 /** 168 - * The casing convention to use for generated type names. 169 + * Casing convention for generated names. 169 170 * 170 171 * @default 'PascalCase' 171 172 */ 172 173 case?: Casing; 173 174 /** 174 - * Whether to generate TypeScript types from Arktype schemas. 175 + * Whether this feature is enabled. 175 176 * 176 177 * @default true 177 178 */ 178 179 enabled?: boolean; 179 180 /** 180 - * Custom naming pattern for generated type names. The name variable is 181 - * obtained from the Arktype schema name. 181 + * Naming pattern for generated names. 182 182 * 183 183 * @default '{{name}}Data' 184 184 */ ··· 204 204 | NameTransformer 205 205 | { 206 206 /** 207 - * The casing convention to use for generated names. 207 + * Casing convention for generated names. 208 208 * 209 209 * @default 'PascalCase' 210 210 */ 211 211 case?: Casing; 212 212 /** 213 - * Whether to generate Arktype schemas for response definitions. 213 + * Whether this feature is enabled. 214 214 * 215 215 * @default true 216 216 */ 217 217 enabled?: boolean; 218 218 /** 219 - * Custom naming pattern for generated schema names. The name variable 220 - * is obtained from the operation name. 219 + * Naming pattern for generated names. 221 220 * 222 221 * @default '{{name}}Response' 223 222 */ ··· 243 242 | NameTransformer 244 243 | { 245 244 /** 246 - * The casing convention to use for generated type names. 245 + * Casing convention for generated names. 247 246 * 248 247 * @default 'PascalCase' 249 248 */ 250 249 case?: Casing; 251 250 /** 252 - * Whether to generate TypeScript types from Arktype schemas. 251 + * Whether this feature is enabled. 253 252 * 254 253 * @default true 255 254 */ 256 255 enabled?: boolean; 257 256 /** 258 - * Custom naming pattern for generated type names. The name variable is 259 - * obtained from the Arktype schema name. 257 + * Naming pattern for generated names. 260 258 * 261 259 * @default '{{name}}Response' 262 260 */ ··· 285 283 | NameTransformer 286 284 | { 287 285 /** 288 - * The casing convention to use for generated type names. 286 + * Casing convention for generated names. 289 287 * 290 288 * @default 'PascalCase' 291 289 */ 292 290 case?: Casing; 293 291 /** 294 - * Whether to generate TypeScript types from Arktype schemas. 292 + * Whether this feature is enabled. 295 293 * 296 294 * @default true 297 295 */ ··· 315 313 | NameTransformer 316 314 | { 317 315 /** 318 - * The casing convention to use for generated names. 316 + * Casing convention for generated names. 319 317 * 320 318 * @default 'PascalCase' 321 319 */ 322 320 case?: Casing; 323 321 /** 324 - * Whether to generate Arktype schemas for webhook definitions. 322 + * Whether this feature is enabled. 325 323 * 326 324 * @default true 327 325 */ 328 326 enabled?: boolean; 329 327 /** 330 - * Custom naming pattern for generated schema names. The name variable 331 - * is obtained from the webhook key. 328 + * Naming pattern for generated names. 332 329 * 333 330 * @default '{{name}}WebhookRequest' 334 331 */ ··· 354 351 | NameTransformer 355 352 | { 356 353 /** 357 - * The casing convention to use for generated type names. 354 + * Casing convention for generated names. 358 355 * 359 356 * @default 'PascalCase' 360 357 */ 361 358 case?: Casing; 362 359 /** 363 - * Whether to generate TypeScript types from Arktype schemas. 360 + * Whether this feature is enabled. 364 361 * 365 362 * @default true 366 363 */ 367 364 enabled?: boolean; 368 365 /** 369 - * Custom naming pattern for generated type names. The name variable is 370 - * obtained from the Arktype schema name. 366 + * Naming pattern for generated names. 371 367 * 372 368 * @default '{{name}}WebhookRequest' 373 369 */ ··· 378 374 }; 379 375 380 376 export type Config = Plugin.Name<'arktype'> & 381 - Plugin.Hooks & { 377 + Plugin.Hooks & 378 + IndexExportOption & { 382 379 /** 383 - * The casing convention to use for generated names. 384 - * 385 - * @default 'PascalCase' 380 + * Casing convention for generated names. 386 381 */ 387 382 case: Casing; 388 383 /** ··· 397 392 * Controls generation of shared Arktype schemas that can be referenced across 398 393 * requests and responses. 399 394 */ 400 - definitions: { 401 - /** 402 - * The casing convention to use for generated names. 403 - * 404 - * @default 'PascalCase' 405 - */ 406 - case: Casing; 407 - /** 408 - * Whether to generate Arktype schemas for reusable definitions. 409 - * 410 - * @default true 411 - */ 412 - enabled: boolean; 413 - /** 414 - * Custom naming pattern for generated schema names. The name variable is 415 - * obtained from the schema name. 416 - * 417 - * @default '{{name}}' 418 - */ 419 - name: NameTransformer; 420 - /** 421 - * Configuration for TypeScript type generation from Arktype schemas. 422 - * 423 - * Controls generation of TypeScript types based on the generated Arktype schemas. 424 - */ 425 - types: { 395 + definitions: NamingOptions & 396 + FeatureToggle & { 426 397 /** 427 - * Configuration for `infer` types. 398 + * Configuration for TypeScript type generation from Arktype schemas. 399 + * 400 + * Controls generation of TypeScript types based on the generated Arktype schemas. 428 401 */ 429 - infer: { 430 - /** 431 - * The casing convention to use for generated type names. 432 - * 433 - * @default 'PascalCase' 434 - */ 435 - case: Casing; 436 - /** 437 - * Whether to generate TypeScript types from Arktype schemas. 438 - * 439 - * @default true 440 - */ 441 - enabled: boolean; 402 + types: { 442 403 /** 443 - * Custom naming pattern for generated type names. The name variable is 444 - * obtained from the Arktype schema name. 445 - * 446 - * @default '{{name}}' 404 + * Configuration for `infer` types. 447 405 */ 448 - name: NameTransformer; 406 + infer: NamingOptions & FeatureToggle; 449 407 }; 450 408 }; 451 - }; 452 - /** 453 - * Should the exports from the generated files be re-exported in the index 454 - * barrel file? 455 - * 456 - * @default false 457 - */ 458 - exportFromIndex: boolean; 459 409 /** 460 410 * Enable Arktype metadata support? It's often useful to associate a schema with 461 411 * some additional metadata for documentation, code generation, AI ··· 470 420 * Controls generation of Arktype schemas for request bodies, query parameters, path 471 421 * parameters, and headers. 472 422 */ 473 - requests: { 474 - /** 475 - * The casing convention to use for generated names. 476 - * 477 - * @default 'PascalCase' 478 - */ 479 - case: Casing; 480 - /** 481 - * Whether to generate Arktype schemas for request definitions. 482 - * 483 - * @default true 484 - */ 485 - enabled: boolean; 486 - /** 487 - * Custom naming pattern for generated schema names. The name variable is 488 - * obtained from the operation name. 489 - * 490 - * @default '{{name}}Data' 491 - */ 492 - name: NameTransformer; 493 - /** 494 - * Configuration for TypeScript type generation from Arktype schemas. 495 - * 496 - * Controls generation of TypeScript types based on the generated Arktype schemas. 497 - */ 498 - types: { 423 + requests: NamingOptions & 424 + FeatureToggle & { 499 425 /** 500 - * Configuration for `infer` types. 426 + * Configuration for TypeScript type generation from Arktype schemas. 427 + * 428 + * Controls generation of TypeScript types based on the generated Arktype schemas. 501 429 */ 502 - infer: { 430 + types: { 503 431 /** 504 - * The casing convention to use for generated type names. 505 - * 506 - * @default 'PascalCase' 432 + * Configuration for `infer` types. 507 433 */ 508 - case: Casing; 509 - /** 510 - * Whether to generate TypeScript types from Arktype schemas. 511 - * 512 - * @default true 513 - */ 514 - enabled: boolean; 515 - /** 516 - * Custom naming pattern for generated type names. The name variable is 517 - * obtained from the Arktype schema name. 518 - * 519 - * @default '{{name}}Data' 520 - */ 521 - name: NameTransformer; 434 + infer: NamingOptions & FeatureToggle; 522 435 }; 523 436 }; 524 - }; 525 437 /** 526 438 * Configuration for response-specific Arktype schemas. 527 439 * 528 440 * Controls generation of Arktype schemas for response bodies, error responses, 529 441 * and status codes. 530 442 */ 531 - responses: { 532 - /** 533 - * The casing convention to use for generated names. 534 - * 535 - * @default 'PascalCase' 536 - */ 537 - case: Casing; 538 - /** 539 - * Whether to generate Arktype schemas for response definitions. 540 - * 541 - * @default true 542 - */ 543 - enabled: boolean; 544 - /** 545 - * Custom naming pattern for generated schema names. The name variable is 546 - * obtained from the operation name. 547 - * 548 - * @default '{{name}}Response' 549 - */ 550 - name: NameTransformer; 551 - /** 552 - * Configuration for TypeScript type generation from Arktype schemas. 553 - * 554 - * Controls generation of TypeScript types based on the generated Arktype schemas. 555 - */ 556 - types: { 443 + responses: NamingOptions & 444 + FeatureToggle & { 557 445 /** 558 - * Configuration for `infer` types. 446 + * Configuration for TypeScript type generation from Arktype schemas. 447 + * 448 + * Controls generation of TypeScript types based on the generated Arktype schemas. 559 449 */ 560 - infer: { 561 - /** 562 - * The casing convention to use for generated type names. 563 - * 564 - * @default 'PascalCase' 565 - */ 566 - case: Casing; 567 - /** 568 - * Whether to generate TypeScript types from Arktype schemas. 569 - * 570 - * @default true 571 - */ 572 - enabled: boolean; 450 + types: { 573 451 /** 574 - * Custom naming pattern for generated type names. The name variable is 575 - * obtained from the Arktype schema name. 576 - * 577 - * @default '{{name}}Response' 452 + * Configuration for `infer` types. 578 453 */ 579 - name: NameTransformer; 454 + infer: NamingOptions & FeatureToggle; 580 455 }; 581 456 }; 582 - }; 583 457 /** 584 458 * Configuration for TypeScript type generation from Arktype schemas. 585 459 * ··· 589 463 /** 590 464 * Configuration for `infer` types. 591 465 */ 592 - infer: { 466 + infer: FeatureToggle & { 593 467 /** 594 - * The casing convention to use for generated type names. 595 - * 596 - * @default 'PascalCase' 468 + * Casing convention for generated names. 597 469 */ 598 470 case: Casing; 599 - /** 600 - * Whether to generate TypeScript types from Arktype schemas. 601 - * 602 - * @default true 603 - */ 604 - enabled: boolean; 605 471 }; 606 472 }; 607 473 /** ··· 609 475 * 610 476 * Controls generation of Arktype schemas for webhook payloads. 611 477 */ 612 - webhooks: { 613 - /** 614 - * The casing convention to use for generated names. 615 - * 616 - * @default 'PascalCase' 617 - */ 618 - case: Casing; 619 - /** 620 - * Whether to generate Arktype schemas for webhook definitions. 621 - * 622 - * @default true 623 - */ 624 - enabled: boolean; 625 - /** 626 - * Custom naming pattern for generated schema names. The name variable is 627 - * is obtained from the webhook key. 628 - * 629 - * @default '{{name}}WebhookRequest' 630 - */ 631 - name: NameTransformer; 632 - /** 633 - * Configuration for TypeScript type generation from Arktype schemas. 634 - * 635 - * Controls generation of TypeScript types based on the generated Arktype schemas. 636 - */ 637 - types: { 478 + webhooks: NamingOptions & 479 + FeatureToggle & { 638 480 /** 639 - * Configuration for `infer` types. 481 + * Configuration for TypeScript type generation from Arktype schemas. 482 + * 483 + * Controls generation of TypeScript types based on the generated Arktype schemas. 640 484 */ 641 - infer: { 485 + types: { 642 486 /** 643 - * The casing convention to use for generated type names. 644 - * 645 - * @default 'PascalCase' 487 + * Configuration for `infer` types. 646 488 */ 647 - case: Casing; 648 - /** 649 - * Whether to generate TypeScript types from Arktype schemas. 650 - * 651 - * @default true 652 - */ 653 - enabled: boolean; 654 - /** 655 - * Custom naming pattern for generated type names. The name variable is 656 - * obtained from the Arktype schema name. 657 - * 658 - * @default '{{name}}WebhookRequest' 659 - */ 660 - name: NameTransformer; 489 + infer: NamingOptions & FeatureToggle; 661 490 }; 662 491 }; 663 - }; 664 492 }; 665 493 666 494 export type ArktypePlugin = DefinePlugin<UserConfig, Config, IApi>;
+4
packages/openapi-ts/src/plugins/config.ts
··· 1 1 import type { Plugin } from '~/plugins'; 2 2 import type { AngularCommonPlugin } from '~/plugins/@angular/common'; 3 3 import { defaultConfig as angularCommon } from '~/plugins/@angular/common'; 4 + import type { FakerJsFakerPlugin } from '~/plugins/@faker-js/faker'; 5 + import { defaultConfig as fakerJsFaker } from '~/plugins/@faker-js/faker'; 4 6 import type { HeyApiClientAngularPlugin } from '~/plugins/@hey-api/client-angular'; 5 7 import { defaultConfig as heyApiClientAngular } from '~/plugins/@hey-api/client-angular'; 6 8 import type { HeyApiClientAxiosPlugin } from '~/plugins/@hey-api/client-axios'; ··· 49 51 50 52 export interface PluginConfigMap { 51 53 '@angular/common': AngularCommonPlugin['Types']; 54 + '@faker-js/faker': FakerJsFakerPlugin['Types']; 52 55 '@hey-api/client-angular': HeyApiClientAngularPlugin['Types']; 53 56 '@hey-api/client-axios': HeyApiClientAxiosPlugin['Types']; 54 57 '@hey-api/client-fetch': HeyApiClientFetchPlugin['Types']; ··· 77 80 [K in PluginNames]: Plugin.Config<PluginConfigMap[K]>; 78 81 } = { 79 82 '@angular/common': angularCommon, 83 + '@faker-js/faker': fakerJsFaker, 80 84 '@hey-api/client-angular': heyApiClientAngular, 81 85 '@hey-api/client-axios': heyApiClientAxios, 82 86 '@hey-api/client-fetch': heyApiClientFetch,
+1 -2
packages/openapi-ts/src/plugins/fastify/types.d.ts
··· 3 3 export type UserConfig = Plugin.Name<'fastify'> & 4 4 Plugin.Hooks & { 5 5 /** 6 - * Should the exports from the generated files be re-exported in the index 7 - * barrel file? 6 + * Whether exports should be re-exported in the index file. 8 7 * 9 8 * @default false 10 9 */
+133 -259
packages/openapi-ts/src/plugins/swr/types.d.ts
··· 1 + import type { 2 + FeatureToggle, 3 + IndexExportOption, 4 + NamingOptions, 5 + } from '~/config/shared'; 1 6 import type { IR } from '~/ir/types'; 2 7 import type { DefinePlugin, Plugin } from '~/plugins'; 3 8 import type { Casing, NameTransformer } from '~/utils/naming'; ··· 5 10 export type UserConfig = Plugin.Name<'swr'> & 6 11 Plugin.Hooks & { 7 12 /** 8 - * The casing convention to use for generated names. 13 + * Casing convention for generated names. 9 14 * 10 15 * @default 'camelCase' 11 16 */ ··· 22 27 */ 23 28 comments?: boolean; 24 29 /** 25 - * Should the exports from the generated files be re-exported in the index 26 - * barrel file? 30 + * Whether exports should be re-exported in the index file. 27 31 * 28 32 * @default false 29 33 */ ··· 45 49 | NameTransformer 46 50 | { 47 51 /** 48 - * The casing convention to use for generated names. 52 + * Casing convention for generated names. 49 53 * 50 54 * @default 'camelCase' 51 55 */ 52 56 case?: Casing; 53 57 /** 54 - * Whether to generate infinite query key helpers. 58 + * Whether this feature is enabled. 55 59 * 56 60 * @default true 57 61 */ 58 62 enabled?: boolean; 59 63 /** 60 - * Custom naming pattern for generated infinite query key names. The name variable is 61 - * obtained from the SDK function name. 64 + * Naming pattern for generated names. 62 65 * 63 66 * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/infiniteQueryOptions infiniteQueryOptions} 64 67 * ··· 90 93 | NameTransformer 91 94 | { 92 95 /** 93 - * The casing convention to use for generated names. 96 + * Casing convention for generated names. 94 97 * 95 98 * @default 'camelCase' 96 99 */ 97 100 case?: Casing; 98 101 /** 99 - * Whether to generate infinite query options helpers. 102 + * Whether this feature is enabled. 100 103 * 101 104 * @default true 102 105 */ ··· 125 128 */ 126 129 meta?: (operation: IR.OperationObject) => Record<string, unknown>; 127 130 /** 128 - * Custom naming pattern for generated infinite query options names. The name variable is 129 - * obtained from the SDK function name. 131 + * Naming pattern for generated names. 130 132 * 131 133 * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/infiniteQueryOptions infiniteQueryOptions} 132 134 * ··· 151 153 | NameTransformer 152 154 | { 153 155 /** 154 - * The casing convention to use for generated names. 156 + * Casing convention for generated names. 155 157 * 156 158 * @default 'camelCase' 157 159 */ 158 160 case?: Casing; 159 161 /** 160 - * Whether to generate mutation options helpers. 162 + * Whether this feature is enabled. 161 163 * 162 164 * @default true 163 165 */ ··· 186 188 */ 187 189 meta?: (operation: IR.OperationObject) => Record<string, unknown>; 188 190 /** 189 - * Custom naming pattern for generated mutation options names. The name variable is 190 - * obtained from the SDK function name. 191 + * Naming pattern for generated names. 191 192 * 192 193 * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/useMutation useMutation} 193 194 * ··· 212 213 | NameTransformer 213 214 | { 214 215 /** 215 - * The casing convention to use for generated names. 216 + * Casing convention for generated names. 216 217 * 217 218 * @default 'camelCase' 218 219 */ 219 220 case?: Casing; 220 221 /** 221 - * Whether to generate query keys. 222 + * Whether this feature is enabled. 222 223 * 223 224 * @default true 224 225 */ 225 226 enabled?: boolean; 226 227 /** 227 - * Custom naming pattern for generated query key names. The name variable is 228 - * obtained from the SDK function name. 228 + * Naming pattern for generated names. 229 229 * 230 230 * See {@link https://tanstack.com/query/v5/docs/framework/react/guides/query-keys Query Keys} 231 231 * ··· 257 257 | NameTransformer 258 258 | { 259 259 /** 260 - * The casing convention to use for generated names. 260 + * Casing convention for generated names. 261 261 * 262 262 * @default 'camelCase' 263 263 */ 264 264 case?: Casing; 265 265 /** 266 - * Whether to generate query options helpers. 266 + * Whether this feature is enabled. 267 267 * 268 268 * @default true 269 269 */ ··· 298 298 */ 299 299 meta?: (operation: IR.OperationObject) => Record<string, unknown>; 300 300 /** 301 - * Custom naming pattern for generated query options names. The name variable is 302 - * obtained from the SDK function name. 301 + * Naming pattern for generated names. 303 302 * 304 303 * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/queryOptions queryOptions} 305 304 * ··· 324 323 | NameTransformer 325 324 | { 326 325 /** 327 - * The casing convention to use for generated names. 326 + * Casing convention for generated names. 328 327 * 329 328 * @default 'camelCase' 330 329 */ 331 330 case?: Casing; 332 331 /** 333 - * Whether to generate `useSwr()` function helpers. 332 + * Whether this feature is enabled. 334 333 * 335 334 * @default true 336 335 */ 337 336 enabled?: boolean; 338 337 /** 339 - * Custom naming pattern for generated `useSwr()` function names. The name variable is 340 - * obtained from the SDK function name. 338 + * Naming pattern for generated names. 341 339 * 342 340 * See {@link https://swr.vercel.app/docs/api API} 343 341 * ··· 348 346 }; 349 347 350 348 export type Config = Plugin.Name<'swr'> & 351 - Plugin.Hooks & { 349 + Plugin.Hooks & 350 + IndexExportOption & { 352 351 /** 353 - * The casing convention to use for generated names. 354 - * 355 - * @default 'camelCase' 352 + * Casing convention for generated names. 356 353 */ 357 354 case: Casing; 358 355 /** ··· 362 359 */ 363 360 comments: boolean; 364 361 /** 365 - * Should the exports from the generated files be re-exported in the index barrel file? 366 - * 367 - * @default false 368 - */ 369 - exportFromIndex: boolean; 370 - /** 371 362 * Resolved configuration for generated infinite query key helpers. 372 363 * 373 364 * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/infiniteQueryOptions infiniteQueryOptions} 374 365 */ 375 - infiniteQueryKeys: { 376 - /** 377 - * The casing convention to use for generated names. 378 - * 379 - * @default 'camelCase' 380 - */ 381 - case: Casing; 382 - /** 383 - * Whether to generate infinite query key helpers. 384 - * 385 - * @default true 386 - */ 387 - enabled: boolean; 388 - /** 389 - * Custom naming pattern for generated infinite query key names. The name variable is obtained from the SDK function name. 390 - * 391 - * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/infiniteQueryOptions infiniteQueryOptions} 392 - * 393 - * @default '{{name}}InfiniteQueryKey' 394 - */ 395 - name: NameTransformer; 396 - /** 397 - * Whether to include operation tags in infinite query keys. 398 - * This will make query keys larger but provides better cache invalidation capabilities. 399 - * 400 - * @default false 401 - */ 402 - tags: boolean; 403 - }; 366 + infiniteQueryKeys: NamingOptions & 367 + FeatureToggle & { 368 + /** 369 + * Whether to include operation tags in infinite query keys. 370 + * This will make query keys larger but provides better cache invalidation capabilities. 371 + * 372 + * @default false 373 + */ 374 + tags: boolean; 375 + }; 404 376 /** 405 377 * Resolved configuration for generated infinite query options helpers. 406 378 * 407 379 * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/infiniteQueryOptions infiniteQueryOptions} 408 380 */ 409 - infiniteQueryOptions: { 410 - /** 411 - * The casing convention to use for generated names. 412 - * 413 - * @default 'camelCase' 414 - */ 415 - case: Casing; 416 - /** 417 - * Whether to generate infinite query options helpers. 418 - * 419 - * @default true 420 - */ 421 - enabled: boolean; 422 - /** 423 - * Custom function to generate metadata for the operation. 424 - * Can return any valid meta object that will be included in the generated infinite query options. 425 - * 426 - * @param operation - The operation object containing all available metadata 427 - * @returns A meta object with any properties you want to include 428 - * 429 - * @example 430 - * ```ts 431 - * meta: (operation) => ({ 432 - * customField: operation.id, 433 - * isDeprecated: operation.deprecated, 434 - * tags: operation.tags, 435 - * customObject: { 436 - * method: operation.method, 437 - * path: operation.path 438 - * } 439 - * }) 440 - * ``` 441 - * 442 - * @default undefined 443 - */ 444 - meta: (operation: IR.OperationObject) => Record<string, unknown>; 445 - /** 446 - * Custom naming pattern for generated infinite query options names. The name variable is obtained from the SDK function name. 447 - * 448 - * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/infiniteQueryOptions infiniteQueryOptions} 449 - * 450 - * @default '{{name}}InfiniteOptions' 451 - */ 452 - name: NameTransformer; 453 - }; 381 + infiniteQueryOptions: NamingOptions & 382 + FeatureToggle & { 383 + /** 384 + * Custom function to generate metadata for the operation. 385 + * Can return any valid meta object that will be included in the generated infinite query options. 386 + * 387 + * @param operation - The operation object containing all available metadata 388 + * @returns A meta object with any properties you want to include 389 + * 390 + * @example 391 + * ```ts 392 + * meta: (operation) => ({ 393 + * customField: operation.id, 394 + * isDeprecated: operation.deprecated, 395 + * tags: operation.tags, 396 + * customObject: { 397 + * method: operation.method, 398 + * path: operation.path 399 + * } 400 + * }) 401 + * ``` 402 + * 403 + * @default undefined 404 + */ 405 + meta: (operation: IR.OperationObject) => Record<string, unknown>; 406 + }; 454 407 /** 455 408 * Resolved configuration for generated mutation options helpers. 456 409 * 457 410 * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/useMutation useMutation} 458 411 */ 459 - mutationOptions: { 460 - /** 461 - * The casing convention to use for generated names. 462 - * 463 - * @default 'camelCase' 464 - */ 465 - case: Casing; 466 - /** 467 - * Whether to generate mutation options helpers. 468 - * 469 - * @default true 470 - */ 471 - enabled: boolean; 472 - /** 473 - * Custom function to generate metadata for the operation. 474 - * Can return any valid meta object that will be included in the generated mutation options. 475 - * 476 - * @param operation - The operation object containing all available metadata 477 - * @returns A meta object with any properties you want to include 478 - * 479 - * @example 480 - * ```ts 481 - * meta: (operation) => ({ 482 - * customField: operation.id, 483 - * isDeprecated: operation.deprecated, 484 - * tags: operation.tags, 485 - * customObject: { 486 - * method: operation.method, 487 - * path: operation.path 488 - * } 489 - * }) 490 - * ``` 491 - * 492 - * @default undefined 493 - */ 494 - meta: (operation: IR.OperationObject) => Record<string, unknown>; 495 - /** 496 - * Custom naming pattern for generated mutation options names. The name variable is obtained from the SDK function name. 497 - * 498 - * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/useMutation useMutation} 499 - * 500 - * @default '{{name}}Mutation' 501 - */ 502 - name: NameTransformer; 503 - }; 412 + mutationOptions: NamingOptions & 413 + FeatureToggle & { 414 + /** 415 + * Custom function to generate metadata for the operation. 416 + * Can return any valid meta object that will be included in the generated mutation options. 417 + * 418 + * @param operation - The operation object containing all available metadata 419 + * @returns A meta object with any properties you want to include 420 + * 421 + * @example 422 + * ```ts 423 + * meta: (operation) => ({ 424 + * customField: operation.id, 425 + * isDeprecated: operation.deprecated, 426 + * tags: operation.tags, 427 + * customObject: { 428 + * method: operation.method, 429 + * path: operation.path 430 + * } 431 + * }) 432 + * ``` 433 + * 434 + * @default undefined 435 + */ 436 + meta: (operation: IR.OperationObject) => Record<string, unknown>; 437 + }; 504 438 /** 505 439 * Resolved configuration for generated query keys. 506 440 * 507 441 * See {@link https://tanstack.com/query/v5/docs/framework/react/guides/query-keys Query Keys} 508 442 */ 509 - queryKeys: { 510 - /** 511 - * The casing convention to use for generated names. 512 - * 513 - * @default 'camelCase' 514 - */ 515 - case: Casing; 516 - /** 517 - * Whether to generate query keys. 518 - * 519 - * @default true 520 - */ 521 - enabled: boolean; 522 - /** 523 - * Custom naming pattern for generated query key names. The name variable is obtained from the SDK function name. 524 - * 525 - * See {@link https://tanstack.com/query/v5/docs/framework/react/guides/query-keys Query Keys} 526 - * 527 - * @default '{{name}}QueryKey' 528 - */ 529 - name: NameTransformer; 530 - /** 531 - * Whether to include operation tags in query keys. 532 - * This will make query keys larger but provides better cache invalidation capabilities. 533 - * 534 - * @default false 535 - */ 536 - tags: boolean; 537 - }; 443 + queryKeys: NamingOptions & 444 + FeatureToggle & { 445 + /** 446 + * Whether to include operation tags in query keys. 447 + * This will make query keys larger but provides better cache invalidation capabilities. 448 + * 449 + * @default false 450 + */ 451 + tags: boolean; 452 + }; 538 453 /** 539 454 * Resolved configuration for generated query options helpers. 540 455 * 541 456 * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/queryOptions queryOptions} 542 457 */ 543 - queryOptions: { 544 - /** 545 - * The casing convention to use for generated names. 546 - * 547 - * @default 'camelCase' 548 - */ 549 - case: Casing; 550 - /** 551 - * Whether to generate query options helpers. 552 - * 553 - * @default true 554 - */ 555 - enabled: boolean; 556 - /** 557 - * Whether to export generated symbols. 558 - * 559 - * @default true 560 - */ 561 - exported: boolean; 562 - /** 563 - * Custom function to generate metadata for the operation. 564 - * Can return any valid meta object that will be included in the generated query options. 565 - * 566 - * @param operation - The operation object containing all available metadata 567 - * @returns A meta object with any properties you want to include 568 - * 569 - * @example 570 - * ```ts 571 - * meta: (operation) => ({ 572 - * customField: operation.id, 573 - * isDeprecated: operation.deprecated, 574 - * tags: operation.tags, 575 - * customObject: { 576 - * method: operation.method, 577 - * path: operation.path 578 - * } 579 - * }) 580 - * ``` 581 - * 582 - * @default undefined 583 - */ 584 - meta: (operation: IR.OperationObject) => Record<string, unknown>; 585 - /** 586 - * Custom naming pattern for generated query options names. The name variable is obtained from the SDK function name. 587 - * 588 - * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/queryOptions queryOptions} 589 - * 590 - * @default '{{name}}Options' 591 - */ 592 - name: NameTransformer; 593 - }; 458 + queryOptions: NamingOptions & 459 + FeatureToggle & { 460 + /** 461 + * Whether to export generated symbols. 462 + * 463 + * @default true 464 + */ 465 + exported: boolean; 466 + /** 467 + * Custom function to generate metadata for the operation. 468 + * Can return any valid meta object that will be included in the generated query options. 469 + * 470 + * @param operation - The operation object containing all available metadata 471 + * @returns A meta object with any properties you want to include 472 + * 473 + * @example 474 + * ```ts 475 + * meta: (operation) => ({ 476 + * customField: operation.id, 477 + * isDeprecated: operation.deprecated, 478 + * tags: operation.tags, 479 + * customObject: { 480 + * method: operation.method, 481 + * path: operation.path 482 + * } 483 + * }) 484 + * ``` 485 + * 486 + * @default undefined 487 + */ 488 + meta: (operation: IR.OperationObject) => Record<string, unknown>; 489 + }; 594 490 /** 595 491 * Configuration for generated `useSwr()` function helpers. 596 492 * 597 493 * See {@link https://swr.vercel.app/docs/api API} 598 494 */ 599 - useSwr: { 600 - /** 601 - * The casing convention to use for generated names. 602 - * 603 - * @default 'camelCase' 604 - */ 605 - case: Casing; 606 - /** 607 - * Whether to generate `useSwr()` function helpers. 608 - * 609 - * @default true 610 - */ 611 - enabled: boolean; 612 - /** 613 - * Custom naming pattern for generated `useSwr()` function names. The name variable is 614 - * obtained from the SDK function name. 615 - * 616 - * See {@link https://swr.vercel.app/docs/api API} 617 - * 618 - * @default 'use{{name}}' 619 - */ 620 - name: NameTransformer; 621 - }; 495 + useSwr: NamingOptions & FeatureToggle; 622 496 }; 623 497 624 498 export type SwrPlugin = DefinePlugin<UserConfig, Config>;
+7 -5
packages/openapi-ts/src/plugins/types.d.ts
··· 12 12 | '@hey-api/client-nuxt' 13 13 | '@hey-api/client-ofetch'; 14 14 15 + export type PluginMockNames = '@faker-js/faker'; 16 + 15 17 export type PluginValidatorNames = 'arktype' | 'valibot' | 'zod'; 16 18 17 19 export type PluginNames = 18 20 | PluginClientNames 21 + | PluginMockNames 22 + | PluginValidatorNames 19 23 | '@angular/common' 20 24 | '@hey-api/schemas' 21 25 | '@hey-api/sdk' ··· 28 32 | '@tanstack/svelte-query' 29 33 | '@tanstack/vue-query' 30 34 | 'fastify' 31 - | 'swr' 32 - | PluginValidatorNames; 35 + | 'swr'; 33 36 34 37 export type AnyPluginName = PluginNames | (string & {}); 35 38 36 - type PluginTag = 'client' | 'sdk' | 'transformer' | 'validator'; 39 + type PluginTag = 'client' | 'mocker' | 'sdk' | 'transformer' | 'validator'; 37 40 38 41 export type PluginContext = { 39 42 package: Package; ··· 51 54 52 55 type BaseConfig = { 53 56 /** 54 - * Should the exports from the plugin's file be re-exported in the index 55 - * barrel file? 57 + * Whether exports should be re-exported in the index file. 56 58 */ 57 59 exportFromIndex?: boolean; 58 60 name: AnyPluginName;
+7
packages/openapi-ts/src/plugins/valibot/resolvers/index.ts
··· 1 + export type { 2 + NumberResolverContext, 3 + ObjectResolverContext, 4 + Resolvers, 5 + StringResolverContext, 6 + ValidatorResolverContext, 7 + } from './types';
+170
packages/openapi-ts/src/plugins/valibot/resolvers/types.d.ts
··· 1 + import type { Refs, Symbol } from '@hey-api/codegen-core'; 2 + 3 + import type { IR } from '~/ir/types'; 4 + import type { Plugin, SchemaWithType } from '~/plugins'; 5 + import type { 6 + MaybeBigInt, 7 + ShouldCoerceToBigInt, 8 + } from '~/plugins/shared/utils/coerce'; 9 + import type { GetIntegerLimit } from '~/plugins/shared/utils/formats'; 10 + import type { $, DollarTsDsl } from '~/ts-dsl'; 11 + 12 + import type { Pipe, PipeResult, Pipes, PipesUtils } from '../shared/pipes'; 13 + import type { Ast, PluginState } from '../shared/types'; 14 + import type { ValibotPlugin } from '../types'; 15 + 16 + export type Resolvers = Plugin.Resolvers<{ 17 + /** 18 + * Resolver for number schemas. 19 + * 20 + * Allows customization of how number types are rendered. 21 + * 22 + * Returning `undefined` will execute the default resolver logic. 23 + */ 24 + number?: (ctx: NumberResolverContext) => PipeResult | undefined; 25 + /** 26 + * Resolver for object schemas. 27 + * 28 + * Allows customization of how object types are rendered. 29 + * 30 + * Returning `undefined` will execute the default resolver logic. 31 + */ 32 + object?: (ctx: ObjectResolverContext) => PipeResult | undefined; 33 + /** 34 + * Resolver for string schemas. 35 + * 36 + * Allows customization of how string types are rendered. 37 + * 38 + * Returning `undefined` will execute the default resolver logic. 39 + */ 40 + string?: (ctx: StringResolverContext) => PipeResult | undefined; 41 + /** 42 + * Resolvers for request and response validators. 43 + * 44 + * Allow customization of validator function bodies. 45 + * 46 + * Example path: `~resolvers.validator.request` or `~resolvers.validator.response` 47 + * 48 + * Returning `undefined` will execute the default resolver logic. 49 + */ 50 + validator?: 51 + | ValidatorResolver 52 + | { 53 + /** 54 + * Controls how the request validator function body is generated. 55 + * 56 + * Returning `undefined` will execute the default resolver logic. 57 + */ 58 + request?: ValidatorResolver; 59 + /** 60 + * Controls how the response validator function body is generated. 61 + * 62 + * Returning `undefined` will execute the default resolver logic. 63 + */ 64 + response?: ValidatorResolver; 65 + }; 66 + }>; 67 + 68 + type ValidatorResolver = ( 69 + ctx: ValidatorResolverContext, 70 + ) => PipeResult | null | undefined; 71 + 72 + interface BaseContext extends DollarTsDsl { 73 + /** 74 + * Functions for working with pipes. 75 + */ 76 + pipes: PipesUtils & { 77 + /** 78 + * The current pipe. 79 + * 80 + * In Valibot, this represents a list of call expressions ("pipes") 81 + * being assembled to form a schema definition. 82 + * 83 + * Each pipe can be extended, modified, or replaced to customize 84 + * the resulting schema. 85 + */ 86 + current: Pipes; 87 + }; 88 + /** 89 + * The plugin instance. 90 + */ 91 + plugin: ValibotPlugin['Instance']; 92 + /** 93 + * Provides access to commonly used symbols within the plugin. 94 + */ 95 + symbols: { 96 + v: Symbol; 97 + }; 98 + } 99 + 100 + export interface NumberResolverContext extends BaseContext { 101 + /** 102 + * Nodes used to build different parts of the number schema. 103 + */ 104 + nodes: { 105 + base: (ctx: NumberResolverContext) => PipeResult; 106 + const: (ctx: NumberResolverContext) => PipeResult | undefined; 107 + max: (ctx: NumberResolverContext) => PipeResult | undefined; 108 + min: (ctx: NumberResolverContext) => PipeResult | undefined; 109 + }; 110 + schema: SchemaWithType<'integer' | 'number'>; 111 + /** 112 + * Utility functions for number schema processing. 113 + */ 114 + utils: { 115 + getIntegerLimit: GetIntegerLimit; 116 + maybeBigInt: MaybeBigInt; 117 + shouldCoerceToBigInt: ShouldCoerceToBigInt; 118 + }; 119 + } 120 + 121 + export interface ObjectResolverContext extends BaseContext { 122 + /** 123 + * Nodes used to build different parts of the object schema. 124 + */ 125 + nodes: { 126 + /** 127 + * If `additionalProperties` is `false` or `{ type: 'never' }`, returns `null` 128 + * to indicate no additional properties are allowed. 129 + */ 130 + additionalProperties: ( 131 + ctx: ObjectResolverContext, 132 + ) => Pipe | null | undefined; 133 + base: (ctx: ObjectResolverContext) => PipeResult; 134 + shape: (ctx: ObjectResolverContext) => ReturnType<typeof $.object>; 135 + }; 136 + schema: SchemaWithType<'object'>; 137 + /** 138 + * Utility functions for object schema processing. 139 + */ 140 + utils: { 141 + ast: Partial<Omit<Ast, 'typeName'>>; 142 + state: Refs<PluginState>; 143 + }; 144 + } 145 + 146 + export interface StringResolverContext extends BaseContext { 147 + /** 148 + * Nodes used to build different parts of the string schema. 149 + */ 150 + nodes: { 151 + base: (ctx: StringResolverContext) => PipeResult; 152 + const: (ctx: StringResolverContext) => PipeResult | undefined; 153 + format: (ctx: StringResolverContext) => PipeResult | undefined; 154 + length: (ctx: StringResolverContext) => PipeResult | undefined; 155 + maxLength: (ctx: StringResolverContext) => PipeResult | undefined; 156 + minLength: (ctx: StringResolverContext) => PipeResult | undefined; 157 + pattern: (ctx: StringResolverContext) => PipeResult | undefined; 158 + }; 159 + schema: SchemaWithType<'string'>; 160 + } 161 + 162 + export interface ValidatorResolverContext extends BaseContext { 163 + operation: IR.Operation; 164 + /** 165 + * Provides access to commonly used symbols within the plugin. 166 + */ 167 + symbols: BaseContext['symbols'] & { 168 + schema: Symbol; 169 + }; 170 + }
+27 -281
packages/openapi-ts/src/plugins/valibot/types.d.ts
··· 1 - import type { Refs, Symbol } from '@hey-api/codegen-core'; 2 - 3 - import type { IR } from '~/ir/types'; 4 - import type { DefinePlugin, Plugin, SchemaWithType } from '~/plugins'; 5 1 import type { 6 - MaybeBigInt, 7 - ShouldCoerceToBigInt, 8 - } from '~/plugins/shared/utils/coerce'; 9 - import type { GetIntegerLimit } from '~/plugins/shared/utils/formats'; 10 - import type { $, DollarTsDsl } from '~/ts-dsl'; 2 + FeatureToggle, 3 + IndexExportOption, 4 + NamingOptions, 5 + } from '~/config/shared'; 6 + import type { DefinePlugin, Plugin } from '~/plugins'; 11 7 import type { Casing, NameTransformer } from '~/utils/naming'; 12 8 13 9 import type { IApi } from './api'; 14 - import type { Pipe, PipeResult, PipesUtils } from './shared/pipes'; 15 - import type { Ast, PluginState } from './shared/types'; 10 + import type { Resolvers } from './resolvers'; 16 11 17 12 export type UserConfig = Plugin.Name<'valibot'> & 18 13 Plugin.Hooks & 19 14 Resolvers & { 20 15 /** 21 - * The casing convention to use for generated names. 16 + * Casing convention for generated names. 22 17 * 23 18 * @default 'camelCase' 24 19 */ ··· 45 40 | NameTransformer 46 41 | { 47 42 /** 48 - * The casing convention to use for generated names. 43 + * Casing convention for generated names. 49 44 * 50 45 * @default 'camelCase' 51 46 */ 52 47 case?: Casing; 53 48 /** 54 - * Whether to generate Valibot schemas for reusable definitions. 49 + * Whether this feature is enabled. 55 50 * 56 51 * @default true 57 52 */ 58 53 enabled?: boolean; 59 54 /** 60 - * Custom naming pattern for generated schema names. The name variable 61 - * is obtained from the schema name. 55 + * Naming pattern for generated names. 62 56 * 63 57 * @default 'v{{name}}' 64 58 */ 65 59 name?: NameTransformer; 66 60 }; 67 61 /** 68 - * Should the exports from the generated files be re-exported in the index 69 - * barrel file? 62 + * Whether exports should be re-exported in the index file. 70 63 * 71 64 * @default false 72 65 */ ··· 95 88 | NameTransformer 96 89 | { 97 90 /** 98 - * The casing convention to use for generated names. 91 + * Casing convention for generated names. 99 92 * 100 93 * @default 'camelCase' 101 94 */ 102 95 case?: Casing; 103 96 /** 104 - * Whether to generate Valibot schemas for request definitions. 97 + * Whether this feature is enabled. 105 98 * 106 99 * @default true 107 100 */ 108 101 enabled?: boolean; 109 102 /** 110 - * Custom naming pattern for generated schema names. The name variable 111 - * is obtained from the operation name. 103 + * Naming pattern for generated names. 112 104 * 113 105 * @default 'v{{name}}Data' 114 106 */ ··· 130 122 | NameTransformer 131 123 | { 132 124 /** 133 - * The casing convention to use for generated names. 125 + * Casing convention for generated names. 134 126 * 135 127 * @default 'camelCase' 136 128 */ 137 129 case?: Casing; 138 130 /** 139 - * Whether to generate Valibot schemas for response definitions. 131 + * Whether this feature is enabled. 140 132 * 141 133 * @default true 142 134 */ 143 135 enabled?: boolean; 144 136 /** 145 - * Custom naming pattern for generated schema names. The name variable 146 - * is obtained from the operation name. 137 + * Naming pattern for generated names. 147 138 * 148 139 * @default 'v{{name}}Response' 149 140 */ ··· 166 157 | NameTransformer 167 158 | { 168 159 /** 169 - * The casing convention to use for generated names. 160 + * Casing convention for generated names. 170 161 * 171 162 * @default 'camelCase' 172 163 */ 173 164 case?: Casing; 174 165 /** 175 - * Whether to generate Valibot schemas for webhook definitions. 166 + * Whether this feature is enabled. 176 167 * 177 168 * @default true 178 169 */ 179 170 enabled?: boolean; 180 171 /** 181 - * Custom naming pattern for generated schema names. The name variable 182 - * is obtained from the webhook key. 172 + * Naming pattern for generated names. 183 173 * 184 174 * @default 'v{{name}}WebhookRequest' 185 175 */ ··· 189 179 190 180 export type Config = Plugin.Name<'valibot'> & 191 181 Plugin.Hooks & 192 - Resolvers & { 182 + Resolvers & 183 + IndexExportOption & { 193 184 /** 194 - * The casing convention to use for generated names. 195 - * 196 - * @default 'camelCase' 185 + * Casing convention for generated names. 197 186 */ 198 187 case: Casing; 199 188 /** ··· 208 197 * Controls generation of shared Valibot schemas that can be referenced 209 198 * across requests and responses. 210 199 */ 211 - definitions: { 212 - /** 213 - * The casing convention to use for generated names. 214 - * 215 - * @default 'camelCase' 216 - */ 217 - case: Casing; 218 - /** 219 - * Whether to generate Valibot schemas for reusable definitions. 220 - * 221 - * @default true 222 - */ 223 - enabled: boolean; 224 - /** 225 - * Custom naming pattern for generated schema names. The name variable is 226 - * obtained from the schema name. 227 - * 228 - * @default 'v{{name}}' 229 - */ 230 - name: NameTransformer; 231 - }; 232 - /** 233 - * Should the exports from the generated files be re-exported in the index 234 - * barrel file? 235 - * 236 - * @default false 237 - */ 238 - exportFromIndex: boolean; 200 + definitions: NamingOptions & FeatureToggle; 239 201 /** 240 202 * Enable Valibot metadata support? It's often useful to associate a schema 241 203 * with some additional metadata for documentation, code generation, AI ··· 250 212 * Controls generation of Valibot schemas for request bodies, query 251 213 * parameters, path parameters, and headers. 252 214 */ 253 - requests: { 254 - /** 255 - * The casing convention to use for generated names. 256 - * 257 - * @default 'camelCase' 258 - */ 259 - case: Casing; 260 - /** 261 - * Whether to generate Valibot schemas for request definitions. 262 - * 263 - * @default true 264 - */ 265 - enabled: boolean; 266 - /** 267 - * Custom naming pattern for generated schema names. The name variable is 268 - * obtained from the operation name. 269 - * 270 - * @default 'v{{name}}Data' 271 - */ 272 - name: NameTransformer; 273 - }; 215 + requests: NamingOptions & FeatureToggle; 274 216 /** 275 217 * Configuration for response-specific Valibot schemas. 276 218 * 277 219 * Controls generation of Valibot schemas for response bodies, error 278 220 * responses, and status codes. 279 221 */ 280 - responses: { 281 - /** 282 - * The casing convention to use for generated names. 283 - * 284 - * @default 'camelCase' 285 - */ 286 - case: Casing; 287 - /** 288 - * Whether to generate Valibot schemas for response definitions. 289 - * 290 - * @default true 291 - */ 292 - enabled: boolean; 293 - /** 294 - * Custom naming pattern for generated schema names. The name variable is 295 - * obtained from the operation name. 296 - * 297 - * @default 'v{{name}}Response' 298 - */ 299 - name: NameTransformer; 300 - }; 222 + responses: NamingOptions & FeatureToggle; 301 223 /** 302 224 * Configuration for webhook-specific Valibot schemas. 303 225 * 304 226 * Controls generation of Valibot schemas for webhook payloads. 305 227 */ 306 - webhooks: { 307 - /** 308 - * The casing convention to use for generated names. 309 - * 310 - * @default 'camelCase' 311 - */ 312 - case: Casing; 313 - /** 314 - * Whether to generate Valibot schemas for webhook definitions. 315 - * 316 - * @default true 317 - */ 318 - enabled: boolean; 319 - /** 320 - * Custom naming pattern for generated schema names. The name variable 321 - * is obtained from the webhook key. 322 - * 323 - * @default 'v{{name}}WebhookRequest' 324 - */ 325 - name: NameTransformer; 326 - }; 327 - }; 328 - 329 - interface BaseResolverContext extends DollarTsDsl { 330 - /** 331 - * Functions for working with pipes. 332 - */ 333 - pipes: PipesUtils & { 334 - /** 335 - * The current pipe. 336 - * 337 - * In Valibot, this represents a list of call expressions ("pipes") 338 - * being assembled to form a schema definition. 339 - * 340 - * Each pipe can be extended, modified, or replaced to customize 341 - * the resulting schema. 342 - */ 343 - current: Pipes; 344 - }; 345 - /** 346 - * The plugin instance. 347 - */ 348 - plugin: ValibotPlugin['Instance']; 349 - /** 350 - * Provides access to commonly used symbols within the plugin. 351 - */ 352 - symbols: { 353 - v: Symbol; 354 - }; 355 - } 356 - 357 - export interface NumberResolverContext extends BaseResolverContext { 358 - /** 359 - * Nodes used to build different parts of the number schema. 360 - */ 361 - nodes: { 362 - base: (ctx: NumberResolverContext) => PipeResult; 363 - const: (ctx: NumberResolverContext) => PipeResult | undefined; 364 - max: (ctx: NumberResolverContext) => PipeResult | undefined; 365 - min: (ctx: NumberResolverContext) => PipeResult | undefined; 366 - }; 367 - schema: SchemaWithType<'integer' | 'number'>; 368 - /** 369 - * Utility functions for number schema processing. 370 - */ 371 - utils: { 372 - getIntegerLimit: GetIntegerLimit; 373 - maybeBigInt: MaybeBigInt; 374 - shouldCoerceToBigInt: ShouldCoerceToBigInt; 375 - }; 376 - } 377 - 378 - export interface ObjectResolverContext extends BaseResolverContext { 379 - /** 380 - * Nodes used to build different parts of the object schema. 381 - */ 382 - nodes: { 383 - /** 384 - * If `additionalProperties` is `false` or `{ type: 'never' }`, returns `null` 385 - * to indicate no additional properties are allowed. 386 - */ 387 - additionalProperties: ( 388 - ctx: ObjectResolverContext, 389 - ) => Pipe | null | undefined; 390 - base: (ctx: ObjectResolverContext) => PipeResult; 391 - shape: (ctx: ObjectResolverContext) => ReturnType<typeof $.object>; 392 - }; 393 - schema: SchemaWithType<'object'>; 394 - /** 395 - * Utility functions for object schema processing. 396 - */ 397 - utils: { 398 - ast: Partial<Omit<Ast, 'typeName'>>; 399 - state: Refs<PluginState>; 400 - }; 401 - } 402 - 403 - export interface StringResolverContext extends BaseResolverContext { 404 - /** 405 - * Nodes used to build different parts of the string schema. 406 - */ 407 - nodes: { 408 - base: (ctx: StringResolverContext) => PipeResult; 409 - const: (ctx: StringResolverContext) => PipeResult | undefined; 410 - format: (ctx: StringResolverContext) => PipeResult | undefined; 411 - length: (ctx: StringResolverContext) => PipeResult | undefined; 412 - maxLength: (ctx: StringResolverContext) => PipeResult | undefined; 413 - minLength: (ctx: StringResolverContext) => PipeResult | undefined; 414 - pattern: (ctx: StringResolverContext) => PipeResult | undefined; 415 - }; 416 - schema: SchemaWithType<'string'>; 417 - } 418 - 419 - export interface ValidatorResolverContext extends BaseResolverContext { 420 - operation: IR.Operation; 421 - /** 422 - * Provides access to commonly used symbols within the plugin. 423 - */ 424 - symbols: BaseResolverContext['symbols'] & { 425 - schema: Symbol; 228 + webhooks: NamingOptions & FeatureToggle; 426 229 }; 427 - } 428 - 429 - type ValidatorResolver = ( 430 - ctx: ValidatorResolverContext, 431 - ) => PipeResult | null | undefined; 432 - 433 - type Resolvers = Plugin.Resolvers<{ 434 - /** 435 - * Resolver for number schemas. 436 - * 437 - * Allows customization of how number types are rendered. 438 - * 439 - * Returning `undefined` will execute the default resolver logic. 440 - */ 441 - number?: (ctx: NumberResolverContext) => PipeResult | undefined; 442 - /** 443 - * Resolver for object schemas. 444 - * 445 - * Allows customization of how object types are rendered. 446 - * 447 - * Returning `undefined` will execute the default resolver logic. 448 - */ 449 - object?: (ctx: ObjectResolverContext) => PipeResult | undefined; 450 - /** 451 - * Resolver for string schemas. 452 - * 453 - * Allows customization of how string types are rendered. 454 - * 455 - * Returning `undefined` will execute the default resolver logic. 456 - */ 457 - string?: (ctx: StringResolverContext) => PipeResult | undefined; 458 - /** 459 - * Resolvers for request and response validators. 460 - * 461 - * Allow customization of validator function bodies. 462 - * 463 - * Example path: `~resolvers.validator.request` or `~resolvers.validator.response` 464 - * 465 - * Returning `undefined` will execute the default resolver logic. 466 - */ 467 - validator?: 468 - | ValidatorResolver 469 - | { 470 - /** 471 - * Controls how the request validator function body is generated. 472 - * 473 - * Returning `undefined` will execute the default resolver logic. 474 - */ 475 - request?: ValidatorResolver; 476 - /** 477 - * Controls how the response validator function body is generated. 478 - * 479 - * Returning `undefined` will execute the default resolver logic. 480 - */ 481 - response?: ValidatorResolver; 482 - }; 483 - }>; 484 230 485 231 export type ValibotPlugin = DefinePlugin<UserConfig, Config, IApi>;
+1 -1
packages/openapi-ts/src/plugins/valibot/v1/api.ts
··· 1 1 import { $ } from '~/ts-dsl'; 2 2 3 + import type { ValidatorResolverContext } from '../resolvers'; 3 4 import { pipes } from '../shared/pipes'; 4 5 import type { ValidatorArgs } from '../shared/types'; 5 - import type { ValidatorResolverContext } from '../types'; 6 6 import { identifiers } from './constants'; 7 7 8 8 const validatorResolver = (
+1 -1
packages/openapi-ts/src/plugins/valibot/v1/toAst/number.ts
··· 6 6 import { getIntegerLimit } from '~/plugins/shared/utils/formats'; 7 7 import { $ } from '~/ts-dsl'; 8 8 9 + import type { NumberResolverContext } from '../../resolvers'; 9 10 import type { Pipe, PipeResult, Pipes } from '../../shared/pipes'; 10 11 import { pipes } from '../../shared/pipes'; 11 12 import type { IrSchemaToAstOptions } from '../../shared/types'; 12 - import type { NumberResolverContext } from '../../types'; 13 13 import { identifiers } from '../constants'; 14 14 15 15 function baseNode(ctx: NumberResolverContext): PipeResult {
+1 -1
packages/openapi-ts/src/plugins/valibot/v1/toAst/object.ts
··· 3 3 import type { SchemaWithType } from '~/plugins'; 4 4 import { $ } from '~/ts-dsl'; 5 5 6 + import type { ObjectResolverContext } from '../../resolvers'; 6 7 import type { Pipe, PipeResult } from '../../shared/pipes'; 7 8 import { pipes } from '../../shared/pipes'; 8 9 import type { Ast, IrSchemaToAstOptions } from '../../shared/types'; 9 - import type { ObjectResolverContext } from '../../types'; 10 10 import { identifiers } from '../constants'; 11 11 import { irSchemaToAst } from '../plugin'; 12 12
+1 -1
packages/openapi-ts/src/plugins/valibot/v1/toAst/string.ts
··· 1 1 import type { SchemaWithType } from '~/plugins'; 2 2 import { $ } from '~/ts-dsl'; 3 3 4 + import type { StringResolverContext } from '../../resolvers'; 4 5 import type { Pipe, PipeResult, Pipes } from '../../shared/pipes'; 5 6 import { pipes } from '../../shared/pipes'; 6 7 import type { IrSchemaToAstOptions } from '../../shared/types'; 7 - import type { StringResolverContext } from '../../types'; 8 8 import { identifiers } from '../constants'; 9 9 10 10 function baseNode(ctx: StringResolverContext): PipeResult {
+1 -1
packages/openapi-ts/src/plugins/zod/mini/api.ts
··· 1 1 import { $ } from '~/ts-dsl'; 2 2 3 3 import { identifiers } from '../constants'; 4 + import type { ValidatorResolverContext } from '../resolvers'; 4 5 import type { ValidatorArgs } from '../shared/types'; 5 - import type { ValidatorResolverContext } from '../types'; 6 6 7 7 const validatorResolver = ( 8 8 ctx: ValidatorResolverContext,
+1 -1
packages/openapi-ts/src/plugins/zod/mini/toAst/number.ts
··· 7 7 import { $ } from '~/ts-dsl'; 8 8 9 9 import { identifiers } from '../../constants'; 10 + import type { NumberResolverContext } from '../../resolvers'; 10 11 import type { Chain } from '../../shared/chain'; 11 12 import type { Ast, IrSchemaToAstOptions } from '../../shared/types'; 12 - import type { NumberResolverContext } from '../../types'; 13 13 14 14 function baseNode(ctx: NumberResolverContext): Chain { 15 15 const { schema, symbols } = ctx;
+1 -1
packages/openapi-ts/src/plugins/zod/mini/toAst/object.ts
··· 4 4 import { $ } from '~/ts-dsl'; 5 5 6 6 import { identifiers } from '../../constants'; 7 + import type { ObjectResolverContext } from '../../resolvers'; 7 8 import type { Chain } from '../../shared/chain'; 8 9 import type { Ast, IrSchemaToAstOptions } from '../../shared/types'; 9 - import type { ObjectResolverContext } from '../../types'; 10 10 import { irSchemaToAst } from '../plugin'; 11 11 12 12 function additionalPropertiesNode(
+1 -1
packages/openapi-ts/src/plugins/zod/mini/toAst/string.ts
··· 2 2 import { $ } from '~/ts-dsl'; 3 3 4 4 import { identifiers } from '../../constants'; 5 + import type { StringResolverContext } from '../../resolvers'; 5 6 import type { Chain } from '../../shared/chain'; 6 7 import type { Ast, IrSchemaToAstOptions } from '../../shared/types'; 7 - import type { StringResolverContext } from '../../types'; 8 8 9 9 function baseNode(ctx: StringResolverContext): Chain { 10 10 const { z } = ctx.symbols;
+7
packages/openapi-ts/src/plugins/zod/resolvers/index.ts
··· 1 + export type { 2 + NumberResolverContext, 3 + ObjectResolverContext, 4 + Resolvers, 5 + StringResolverContext, 6 + ValidatorResolverContext, 7 + } from './types';
+174
packages/openapi-ts/src/plugins/zod/resolvers/types.d.ts
··· 1 + import type { Refs, Symbol } from '@hey-api/codegen-core'; 2 + import type ts from 'typescript'; 3 + 4 + import type { IR } from '~/ir/types'; 5 + import type { Plugin, SchemaWithType } from '~/plugins'; 6 + import type { 7 + MaybeBigInt, 8 + ShouldCoerceToBigInt, 9 + } from '~/plugins/shared/utils/coerce'; 10 + import type { GetIntegerLimit } from '~/plugins/shared/utils/formats'; 11 + import type { $, DollarTsDsl, TsDsl } from '~/ts-dsl'; 12 + import type { MaybeArray } from '~/types/utils'; 13 + 14 + import type { Chain } from '../shared/chain'; 15 + import type { Ast, PluginState } from '../shared/types'; 16 + import type { ZodPlugin } from '../types'; 17 + 18 + export type Resolvers = Plugin.Resolvers<{ 19 + /** 20 + * Resolver for number schemas. 21 + * 22 + * Allows customization of how number types are rendered. 23 + * 24 + * Returning `undefined` will execute the default resolver logic. 25 + */ 26 + number?: (ctx: NumberResolverContext) => Chain | undefined; 27 + /** 28 + * Resolver for object schemas. 29 + * 30 + * Allows customization of how object types are rendered. 31 + * 32 + * Returning `undefined` will execute the default resolver logic. 33 + */ 34 + object?: (ctx: ObjectResolverContext) => Chain | undefined; 35 + /** 36 + * Resolver for string schemas. 37 + * 38 + * Allows customization of how string types are rendered. 39 + * 40 + * Returning `undefined` will execute the default resolver logic. 41 + */ 42 + string?: (ctx: StringResolverContext) => Chain | undefined; 43 + /** 44 + * Resolvers for request and response validators. 45 + * 46 + * Allow customization of validator function bodies. 47 + * 48 + * Example path: `~resolvers.validator.request` or `~resolvers.validator.response` 49 + * 50 + * Returning `undefined` will execute the default resolver logic. 51 + */ 52 + validator?: 53 + | ValidatorResolver 54 + | { 55 + /** 56 + * Controls how the request validator function body is generated. 57 + * 58 + * Returning `undefined` will execute the default resolver logic. 59 + */ 60 + request?: ValidatorResolver; 61 + /** 62 + * Controls how the response validator function body is generated. 63 + * 64 + * Returning `undefined` will execute the default resolver logic. 65 + */ 66 + response?: ValidatorResolver; 67 + }; 68 + }>; 69 + 70 + type ValidatorResolver = ( 71 + ctx: ValidatorResolverContext, 72 + ) => MaybeArray<TsDsl<ts.Statement>> | null | undefined; 73 + 74 + interface BaseContext extends DollarTsDsl { 75 + /** 76 + * Functions for working with chains. 77 + */ 78 + chain: { 79 + /** 80 + * The current chain. 81 + * 82 + * In Zod, this represents a chain of call expressions ("chains") 83 + * being assembled to form a schema definition. 84 + * 85 + * Each chain can be extended, modified, or replaced to customize 86 + * the resulting schema. 87 + */ 88 + current: Chain; 89 + }; 90 + /** 91 + * The plugin instance. 92 + */ 93 + plugin: ZodPlugin['Instance']; 94 + /** 95 + * Provides access to commonly used symbols within the plugin. 96 + */ 97 + symbols: { 98 + z: Symbol; 99 + }; 100 + } 101 + 102 + export interface NumberResolverContext extends BaseContext { 103 + /** 104 + * Nodes used to build different parts of the number schema. 105 + */ 106 + nodes: { 107 + base: (ctx: NumberResolverContext) => Chain; 108 + const: (ctx: NumberResolverContext) => Chain | undefined; 109 + max: (ctx: NumberResolverContext) => Chain | undefined; 110 + min: (ctx: NumberResolverContext) => Chain | undefined; 111 + }; 112 + schema: SchemaWithType<'integer' | 'number'>; 113 + /** 114 + * Utility functions for number schema processing. 115 + */ 116 + utils: { 117 + ast: Partial<Omit<Ast, 'typeName'>>; 118 + getIntegerLimit: GetIntegerLimit; 119 + maybeBigInt: MaybeBigInt; 120 + shouldCoerceToBigInt: ShouldCoerceToBigInt; 121 + state: Refs<PluginState>; 122 + }; 123 + } 124 + 125 + export interface ObjectResolverContext extends BaseContext { 126 + /** 127 + * Nodes used to build different parts of the object schema. 128 + */ 129 + nodes: { 130 + /** 131 + * If `additionalProperties` is `false` or `{ type: 'never' }`, returns `null` 132 + * to indicate no additional properties are allowed. 133 + */ 134 + additionalProperties: ( 135 + ctx: ObjectResolverContext, 136 + ) => Chain | null | undefined; 137 + base: (ctx: ObjectResolverContext) => Chain; 138 + shape: (ctx: ObjectResolverContext) => ReturnType<typeof $.object>; 139 + }; 140 + schema: SchemaWithType<'object'>; 141 + /** 142 + * Utility functions for object schema processing. 143 + */ 144 + utils: { 145 + ast: Partial<Omit<Ast, 'typeName'>>; 146 + state: Refs<PluginState>; 147 + }; 148 + } 149 + 150 + export interface StringResolverContext extends BaseContext { 151 + /** 152 + * Nodes used to build different parts of the string schema. 153 + */ 154 + nodes: { 155 + base: (ctx: StringResolverContext) => Chain; 156 + const: (ctx: StringResolverContext) => Chain | undefined; 157 + format: (ctx: StringResolverContext) => Chain | undefined; 158 + length: (ctx: StringResolverContext) => Chain | undefined; 159 + maxLength: (ctx: StringResolverContext) => Chain | undefined; 160 + minLength: (ctx: StringResolverContext) => Chain | undefined; 161 + pattern: (ctx: StringResolverContext) => Chain | undefined; 162 + }; 163 + schema: SchemaWithType<'string'>; 164 + } 165 + 166 + export interface ValidatorResolverContext extends BaseContext { 167 + operation: IR.Operation; 168 + /** 169 + * Provides access to commonly used symbols within the plugin. 170 + */ 171 + symbols: BaseContext['symbols'] & { 172 + schema: Symbol; 173 + }; 174 + }
+71 -413
packages/openapi-ts/src/plugins/zod/types.d.ts
··· 1 - import type { Refs, Symbol } from '@hey-api/codegen-core'; 2 - import type ts from 'typescript'; 3 - 4 - import type { IR } from '~/ir/types'; 5 - import type { DefinePlugin, Plugin, SchemaWithType } from '~/plugins'; 6 1 import type { 7 - MaybeBigInt, 8 - ShouldCoerceToBigInt, 9 - } from '~/plugins/shared/utils/coerce'; 10 - import type { GetIntegerLimit } from '~/plugins/shared/utils/formats'; 11 - import type { $, DollarTsDsl, TsDsl } from '~/ts-dsl'; 12 - import type { MaybeArray } from '~/types/utils'; 2 + FeatureToggle, 3 + IndexExportOption, 4 + NamingOptions, 5 + } from '~/config/shared'; 6 + import type { DefinePlugin, Plugin } from '~/plugins'; 13 7 import type { Casing, NameTransformer } from '~/utils/naming'; 14 8 15 9 import type { IApi } from './api'; 16 - import type { Chain } from './shared/chain'; 17 - import type { Ast, PluginState } from './shared/types'; 10 + import type { Resolvers } from './resolvers'; 18 11 19 12 export type UserConfig = Plugin.Name<'zod'> & 20 13 Plugin.Hooks & 21 14 Resolvers & { 22 15 /** 23 - * The casing convention to use for generated names. 16 + * Casing convention for generated names. 24 17 * 25 18 * @default 'camelCase' 26 19 */ ··· 86 79 | NameTransformer 87 80 | { 88 81 /** 89 - * The casing convention to use for generated names. 82 + * Casing convention for generated names. 90 83 * 91 84 * @default 'camelCase' 92 85 */ 93 86 case?: Casing; 94 87 /** 95 - * Whether to generate Zod schemas for reusable definitions. 88 + * Whether this feature is enabled. 96 89 * 97 90 * @default true 98 91 */ 99 92 enabled?: boolean; 100 93 /** 101 - * Custom naming pattern for generated schema names. The name variable 102 - * is obtained from the schema name. 94 + * Naming pattern for generated names. 103 95 * 104 96 * @default 'z{{name}}' 105 97 */ ··· 125 117 | NameTransformer 126 118 | { 127 119 /** 128 - * The casing convention to use for generated type names. 120 + * Casing convention for generated names. 129 121 * 130 122 * @default 'PascalCase' 131 123 */ 132 124 case?: Casing; 133 125 /** 134 - * Whether to generate TypeScript types from Zod schemas. 126 + * Whether this feature is enabled. 135 127 * 136 128 * @default true 137 129 */ 138 130 enabled?: boolean; 139 131 /** 140 - * Custom naming pattern for generated type names. The name variable is 141 - * obtained from the Zod schema name. 132 + * Naming pattern for generated names. 142 133 * 143 134 * @default '{{name}}ZodType' 144 135 */ ··· 147 138 }; 148 139 }; 149 140 /** 150 - * Should the exports from the generated files be re-exported in the index 151 - * barrel file? 141 + * Whether exports should be re-exported in the index file. 152 142 * 153 143 * @default false 154 144 */ ··· 179 169 | NameTransformer 180 170 | { 181 171 /** 182 - * The casing convention to use for generated names. 172 + * Casing convention for generated names. 183 173 * 184 174 * @default 'camelCase' 185 175 */ 186 176 case?: Casing; 187 177 /** 188 - * Whether to generate Zod schemas for request definitions. 178 + * Whether this feature is enabled. 189 179 * 190 180 * @default true 191 181 */ 192 182 enabled?: boolean; 193 183 /** 194 - * Custom naming pattern for generated schema names. The name variable 195 - * is obtained from the operation name. 184 + * Naming pattern for generated names. 196 185 * 197 186 * @default 'z{{name}}Data' 198 187 */ ··· 218 207 | NameTransformer 219 208 | { 220 209 /** 221 - * The casing convention to use for generated type names. 210 + * Casing convention for generated names. 222 211 * 223 212 * @default 'PascalCase' 224 213 */ 225 214 case?: Casing; 226 215 /** 227 - * Whether to generate TypeScript types from Zod schemas. 216 + * Whether this feature is enabled. 228 217 * 229 218 * @default true 230 219 */ 231 220 enabled?: boolean; 232 221 /** 233 - * Custom naming pattern for generated type names. The name variable is 234 - * obtained from the Zod schema name. 222 + * Naming pattern for generated names. 235 223 * 236 224 * @default '{{name}}DataZodType' 237 225 */ ··· 257 245 | NameTransformer 258 246 | { 259 247 /** 260 - * The casing convention to use for generated names. 248 + * Casing convention for generated names. 261 249 * 262 250 * @default 'camelCase' 263 251 */ 264 252 case?: Casing; 265 253 /** 266 - * Whether to generate Zod schemas for response definitions. 254 + * Whether this feature is enabled. 267 255 * 268 256 * @default true 269 257 */ 270 258 enabled?: boolean; 271 259 /** 272 - * Custom naming pattern for generated schema names. The name variable 273 - * is obtained from the operation name. 260 + * Naming pattern for generated names. 274 261 * 275 262 * @default 'z{{name}}Response' 276 263 */ ··· 296 283 | NameTransformer 297 284 | { 298 285 /** 299 - * The casing convention to use for generated type names. 286 + * Casing convention for generated names. 300 287 * 301 288 * @default 'PascalCase' 302 289 */ 303 290 case?: Casing; 304 291 /** 305 - * Whether to generate TypeScript types from Zod schemas. 292 + * Whether this feature is enabled. 306 293 * 307 294 * @default true 308 295 */ 309 296 enabled?: boolean; 310 297 /** 311 - * Custom naming pattern for generated type names. The name variable is 312 - * obtained from the Zod schema name. 298 + * Naming pattern for generated names. 313 299 * 314 300 * @default '{{name}}ResponseZodType' 315 301 */ ··· 338 324 | NameTransformer 339 325 | { 340 326 /** 341 - * The casing convention to use for generated type names. 327 + * Casing convention for generated names. 342 328 * 343 329 * @default 'PascalCase' 344 330 */ 345 331 case?: Casing; 346 332 /** 347 - * Whether to generate TypeScript types from Zod schemas. 333 + * Whether this feature is enabled. 348 334 * 349 335 * @default true 350 336 */ ··· 368 354 | NameTransformer 369 355 | { 370 356 /** 371 - * The casing convention to use for generated names. 357 + * Casing convention for generated names. 372 358 * 373 359 * @default 'camelCase' 374 360 */ 375 361 case?: Casing; 376 362 /** 377 - * Whether to generate Zod schemas for webhook definitions. 363 + * Whether this feature is enabled. 378 364 * 379 365 * @default true 380 366 */ 381 367 enabled?: boolean; 382 368 /** 383 - * Custom naming pattern for generated schema names. The name variable 384 - * is obtained from the webhook key. 369 + * Naming pattern for generated names. 385 370 * 386 371 * @default 'z{{name}}WebhookRequest' 387 372 */ ··· 407 392 | NameTransformer 408 393 | { 409 394 /** 410 - * The casing convention to use for generated type names. 395 + * Casing convention for generated names. 411 396 * 412 397 * @default 'PascalCase' 413 398 */ 414 399 case?: Casing; 415 400 /** 416 - * Whether to generate TypeScript types from Zod schemas. 401 + * Whether this feature is enabled. 417 402 * 418 403 * @default true 419 404 */ 420 405 enabled?: boolean; 421 406 /** 422 - * Custom naming pattern for generated type names. The name variable is 423 - * obtained from the Zod schema name. 407 + * Naming pattern for generated names. 424 408 * 425 409 * @default '{{name}}WebhookRequestZodType' 426 410 */ ··· 432 416 433 417 export type Config = Plugin.Name<'zod'> & 434 418 Plugin.Hooks & 435 - Resolvers & { 419 + Resolvers & 420 + IndexExportOption & { 436 421 /** 437 - * The casing convention to use for generated names. 438 - * 439 - * @default 'camelCase' 422 + * Casing convention for generated names. 440 423 */ 441 424 case: Casing; 442 425 /** ··· 488 471 * Controls generation of shared Zod schemas that can be referenced across 489 472 * requests and responses. 490 473 */ 491 - definitions: { 492 - /** 493 - * The casing convention to use for generated names. 494 - * 495 - * @default 'camelCase' 496 - */ 497 - case: Casing; 498 - /** 499 - * Whether to generate Zod schemas for reusable definitions. 500 - * 501 - * @default true 502 - */ 503 - enabled: boolean; 504 - /** 505 - * Custom naming pattern for generated schema names. The name variable is 506 - * obtained from the schema name. 507 - * 508 - * @default 'z{{name}}' 509 - */ 510 - name: NameTransformer; 511 - /** 512 - * Configuration for TypeScript type generation from Zod schemas. 513 - * 514 - * Controls generation of TypeScript types based on the generated Zod schemas. 515 - */ 516 - types: { 474 + definitions: NamingOptions & 475 + FeatureToggle & { 517 476 /** 518 - * Configuration for `infer` types. 477 + * Configuration for TypeScript type generation from Zod schemas. 478 + * 479 + * Controls generation of TypeScript types based on the generated Zod schemas. 519 480 */ 520 - infer: { 521 - /** 522 - * The casing convention to use for generated type names. 523 - * 524 - * @default 'PascalCase' 525 - */ 526 - case: Casing; 481 + types: { 527 482 /** 528 - * Whether to generate TypeScript types from Zod schemas. 529 - * 530 - * @default true 483 + * Configuration for `infer` types. 531 484 */ 532 - enabled: boolean; 533 - /** 534 - * Custom naming pattern for generated type names. The name variable is 535 - * obtained from the Zod schema name. 536 - * 537 - * @default '{{name}}ZodType' 538 - */ 539 - name: NameTransformer; 485 + infer: NamingOptions & FeatureToggle; 540 486 }; 541 487 }; 542 - }; 543 - /** 544 - * Should the exports from the generated files be re-exported in the index 545 - * barrel file? 546 - * 547 - * @default false 548 - */ 549 - exportFromIndex: boolean; 550 488 /** 551 489 * Enable Zod metadata support? It's often useful to associate a schema with 552 490 * some additional metadata for documentation, code generation, AI ··· 561 499 * Controls generation of Zod schemas for request bodies, query parameters, path 562 500 * parameters, and headers. 563 501 */ 564 - requests: { 565 - /** 566 - * The casing convention to use for generated names. 567 - * 568 - * @default 'camelCase' 569 - */ 570 - case: Casing; 571 - /** 572 - * Whether to generate Zod schemas for request definitions. 573 - * 574 - * @default true 575 - */ 576 - enabled: boolean; 577 - /** 578 - * Custom naming pattern for generated schema names. The name variable is 579 - * obtained from the operation name. 580 - * 581 - * @default 'z{{name}}Data' 582 - */ 583 - name: NameTransformer; 584 - /** 585 - * Configuration for TypeScript type generation from Zod schemas. 586 - * 587 - * Controls generation of TypeScript types based on the generated Zod schemas. 588 - */ 589 - types: { 502 + requests: NamingOptions & 503 + FeatureToggle & { 590 504 /** 591 - * Configuration for `infer` types. 505 + * Configuration for TypeScript type generation from Zod schemas. 506 + * 507 + * Controls generation of TypeScript types based on the generated Zod schemas. 592 508 */ 593 - infer: { 594 - /** 595 - * The casing convention to use for generated type names. 596 - * 597 - * @default 'PascalCase' 598 - */ 599 - case: Casing; 600 - /** 601 - * Whether to generate TypeScript types from Zod schemas. 602 - * 603 - * @default true 604 - */ 605 - enabled: boolean; 509 + types: { 606 510 /** 607 - * Custom naming pattern for generated type names. The name variable is 608 - * obtained from the Zod schema name. 609 - * 610 - * @default '{{name}}DataZodType' 511 + * Configuration for `infer` types. 611 512 */ 612 - name: NameTransformer; 513 + infer: NamingOptions & FeatureToggle; 613 514 }; 614 515 }; 615 - }; 616 516 /** 617 517 * Configuration for response-specific Zod schemas. 618 518 * 619 519 * Controls generation of Zod schemas for response bodies, error responses, 620 520 * and status codes. 621 521 */ 622 - responses: { 623 - /** 624 - * The casing convention to use for generated names. 625 - * 626 - * @default 'camelCase' 627 - */ 628 - case: Casing; 629 - /** 630 - * Whether to generate Zod schemas for response definitions. 631 - * 632 - * @default true 633 - */ 634 - enabled: boolean; 635 - /** 636 - * Custom naming pattern for generated schema names. The name variable is 637 - * obtained from the operation name. 638 - * 639 - * @default 'z{{name}}Response' 640 - */ 641 - name: NameTransformer; 642 - /** 643 - * Configuration for TypeScript type generation from Zod schemas. 644 - * 645 - * Controls generation of TypeScript types based on the generated Zod schemas. 646 - */ 647 - types: { 522 + responses: NamingOptions & 523 + FeatureToggle & { 648 524 /** 649 - * Configuration for `infer` types. 525 + * Configuration for TypeScript type generation from Zod schemas. 526 + * 527 + * Controls generation of TypeScript types based on the generated Zod schemas. 650 528 */ 651 - infer: { 652 - /** 653 - * The casing convention to use for generated type names. 654 - * 655 - * @default 'PascalCase' 656 - */ 657 - case: Casing; 658 - /** 659 - * Whether to generate TypeScript types from Zod schemas. 660 - * 661 - * @default true 662 - */ 663 - enabled: boolean; 529 + types: { 664 530 /** 665 - * Custom naming pattern for generated type names. The name variable is 666 - * obtained from the Zod schema name. 667 - * 668 - * @default '{{name}}ResponseZodType' 531 + * Configuration for `infer` types. 669 532 */ 670 - name: NameTransformer; 533 + infer: NamingOptions & FeatureToggle; 671 534 }; 672 535 }; 673 - }; 674 536 /** 675 537 * Configuration for TypeScript type generation from Zod schemas. 676 538 * ··· 680 542 /** 681 543 * Configuration for `infer` types. 682 544 */ 683 - infer: { 545 + infer: FeatureToggle & { 684 546 /** 685 - * The casing convention to use for generated type names. 686 - * 687 - * @default 'PascalCase' 547 + * Casing convention for generated names. 688 548 */ 689 549 case: Casing; 690 - /** 691 - * Whether to generate TypeScript types from Zod schemas. 692 - * 693 - * @default true 694 - */ 695 - enabled: boolean; 696 550 }; 697 551 }; 698 552 /** ··· 700 554 * 701 555 * Controls generation of Zod schemas for webhook payloads. 702 556 */ 703 - webhooks: { 704 - /** 705 - * The casing convention to use for generated names. 706 - * 707 - * @default 'camelCase' 708 - */ 709 - case: Casing; 710 - /** 711 - * Whether to generate Zod schemas for webhook definitions. 712 - * 713 - * @default true 714 - */ 715 - enabled: boolean; 716 - /** 717 - * Custom naming pattern for generated schema names. The name variable is 718 - * is obtained from the webhook key. 719 - * 720 - * @default 'z{{name}}WebhookRequest' 721 - */ 722 - name: NameTransformer; 723 - /** 724 - * Configuration for TypeScript type generation from Zod schemas. 725 - * 726 - * Controls generation of TypeScript types based on the generated Zod schemas. 727 - */ 728 - types: { 557 + webhooks: NamingOptions & 558 + FeatureToggle & { 729 559 /** 730 - * Configuration for `infer` types. 560 + * Configuration for TypeScript type generation from Zod schemas. 561 + * 562 + * Controls generation of TypeScript types based on the generated Zod schemas. 731 563 */ 732 - infer: { 733 - /** 734 - * The casing convention to use for generated type names. 735 - * 736 - * @default 'PascalCase' 737 - */ 738 - case: Casing; 739 - /** 740 - * Whether to generate TypeScript types from Zod schemas. 741 - * 742 - * @default true 743 - */ 744 - enabled: boolean; 564 + types: { 745 565 /** 746 - * Custom naming pattern for generated type names. The name variable is 747 - * obtained from the Zod schema name. 748 - * 749 - * @default '{{name}}WebhookRequestZodType' 566 + * Configuration for `infer` types. 750 567 */ 751 - name: NameTransformer; 568 + infer: NamingOptions & FeatureToggle; 752 569 }; 753 570 }; 754 - }; 755 571 }; 756 - 757 - interface BaseResolverContext extends DollarTsDsl { 758 - /** 759 - * Functions for working with chains. 760 - */ 761 - chain: { 762 - /** 763 - * The current chain. 764 - * 765 - * In Zod, this represents a chain of call expressions ("chains") 766 - * being assembled to form a schema definition. 767 - * 768 - * Each chain can be extended, modified, or replaced to customize 769 - * the resulting schema. 770 - */ 771 - current: Chain; 772 - }; 773 - /** 774 - * The plugin instance. 775 - */ 776 - plugin: ZodPlugin['Instance']; 777 - /** 778 - * Provides access to commonly used symbols within the plugin. 779 - */ 780 - symbols: { 781 - z: Symbol; 782 - }; 783 - } 784 - 785 - export interface NumberResolverContext extends BaseResolverContext { 786 - /** 787 - * Nodes used to build different parts of the number schema. 788 - */ 789 - nodes: { 790 - base: (ctx: NumberResolverContext) => Chain; 791 - const: (ctx: NumberResolverContext) => Chain | undefined; 792 - max: (ctx: NumberResolverContext) => Chain | undefined; 793 - min: (ctx: NumberResolverContext) => Chain | undefined; 794 - }; 795 - schema: SchemaWithType<'integer' | 'number'>; 796 - /** 797 - * Utility functions for number schema processing. 798 - */ 799 - utils: { 800 - ast: Partial<Omit<Ast, 'typeName'>>; 801 - getIntegerLimit: GetIntegerLimit; 802 - maybeBigInt: MaybeBigInt; 803 - shouldCoerceToBigInt: ShouldCoerceToBigInt; 804 - state: Refs<PluginState>; 805 - }; 806 - } 807 - 808 - export interface ObjectResolverContext extends BaseResolverContext { 809 - /** 810 - * Nodes used to build different parts of the object schema. 811 - */ 812 - nodes: { 813 - /** 814 - * If `additionalProperties` is `false` or `{ type: 'never' }`, returns `null` 815 - * to indicate no additional properties are allowed. 816 - */ 817 - additionalProperties: ( 818 - ctx: ObjectResolverContext, 819 - ) => Chain | null | undefined; 820 - base: (ctx: ObjectResolverContext) => Chain; 821 - shape: (ctx: ObjectResolverContext) => ReturnType<typeof $.object>; 822 - }; 823 - schema: SchemaWithType<'object'>; 824 - /** 825 - * Utility functions for object schema processing. 826 - */ 827 - utils: { 828 - ast: Partial<Omit<Ast, 'typeName'>>; 829 - state: Refs<PluginState>; 830 - }; 831 - } 832 - 833 - export interface StringResolverContext extends BaseResolverContext { 834 - /** 835 - * Nodes used to build different parts of the string schema. 836 - */ 837 - nodes: { 838 - base: (ctx: StringResolverContext) => Chain; 839 - const: (ctx: StringResolverContext) => Chain | undefined; 840 - format: (ctx: StringResolverContext) => Chain | undefined; 841 - length: (ctx: StringResolverContext) => Chain | undefined; 842 - maxLength: (ctx: StringResolverContext) => Chain | undefined; 843 - minLength: (ctx: StringResolverContext) => Chain | undefined; 844 - pattern: (ctx: StringResolverContext) => Chain | undefined; 845 - }; 846 - schema: SchemaWithType<'string'>; 847 - } 848 - 849 - export interface ValidatorResolverContext extends BaseResolverContext { 850 - operation: IR.Operation; 851 - /** 852 - * Provides access to commonly used symbols within the plugin. 853 - */ 854 - symbols: BaseResolverContext['symbols'] & { 855 - schema: Symbol; 856 - }; 857 - } 858 - 859 - type ValidatorResolver = ( 860 - ctx: ValidatorResolverContext, 861 - ) => MaybeArray<TsDsl<ts.Statement>> | null | undefined; 862 - 863 - type Resolvers = Plugin.Resolvers<{ 864 - /** 865 - * Resolver for number schemas. 866 - * 867 - * Allows customization of how number types are rendered. 868 - * 869 - * Returning `undefined` will execute the default resolver logic. 870 - */ 871 - number?: (ctx: NumberResolverContext) => Chain | undefined; 872 - /** 873 - * Resolver for object schemas. 874 - * 875 - * Allows customization of how object types are rendered. 876 - * 877 - * Returning `undefined` will execute the default resolver logic. 878 - */ 879 - object?: (ctx: ObjectResolverContext) => Chain | undefined; 880 - /** 881 - * Resolver for string schemas. 882 - * 883 - * Allows customization of how string types are rendered. 884 - * 885 - * Returning `undefined` will execute the default resolver logic. 886 - */ 887 - string?: (ctx: StringResolverContext) => Chain | undefined; 888 - /** 889 - * Resolvers for request and response validators. 890 - * 891 - * Allow customization of validator function bodies. 892 - * 893 - * Example path: `~resolvers.validator.request` or `~resolvers.validator.response` 894 - * 895 - * Returning `undefined` will execute the default resolver logic. 896 - */ 897 - validator?: 898 - | ValidatorResolver 899 - | { 900 - /** 901 - * Controls how the request validator function body is generated. 902 - * 903 - * Returning `undefined` will execute the default resolver logic. 904 - */ 905 - request?: ValidatorResolver; 906 - /** 907 - * Controls how the response validator function body is generated. 908 - * 909 - * Returning `undefined` will execute the default resolver logic. 910 - */ 911 - response?: ValidatorResolver; 912 - }; 913 - }>; 914 572 915 573 export type ZodPlugin = DefinePlugin<UserConfig, Config, IApi>;
+1 -1
packages/openapi-ts/src/plugins/zod/v3/api.ts
··· 1 1 import { $ } from '~/ts-dsl'; 2 2 3 3 import { identifiers } from '../constants'; 4 + import type { ValidatorResolverContext } from '../resolvers'; 4 5 import type { ValidatorArgs } from '../shared/types'; 5 - import type { ValidatorResolverContext } from '../types'; 6 6 7 7 const validatorResolver = ( 8 8 ctx: ValidatorResolverContext,
+1 -1
packages/openapi-ts/src/plugins/zod/v3/toAst/number.ts
··· 7 7 import { $ } from '~/ts-dsl'; 8 8 9 9 import { identifiers } from '../../constants'; 10 + import type { NumberResolverContext } from '../../resolvers'; 10 11 import type { Chain } from '../../shared/chain'; 11 12 import type { Ast, IrSchemaToAstOptions } from '../../shared/types'; 12 - import type { NumberResolverContext } from '../../types'; 13 13 14 14 function baseNode(ctx: NumberResolverContext): Chain { 15 15 const { schema, symbols } = ctx;
+1 -1
packages/openapi-ts/src/plugins/zod/v3/toAst/object.ts
··· 4 4 import { $ } from '~/ts-dsl'; 5 5 6 6 import { identifiers } from '../../constants'; 7 + import type { ObjectResolverContext } from '../../resolvers'; 7 8 import type { Chain } from '../../shared/chain'; 8 9 import type { Ast, IrSchemaToAstOptions } from '../../shared/types'; 9 - import type { ObjectResolverContext } from '../../types'; 10 10 import { irSchemaToAst } from '../plugin'; 11 11 12 12 function additionalPropertiesNode(
+1 -1
packages/openapi-ts/src/plugins/zod/v3/toAst/string.ts
··· 2 2 import { $ } from '~/ts-dsl'; 3 3 4 4 import { identifiers } from '../../constants'; 5 + import type { StringResolverContext } from '../../resolvers'; 5 6 import type { Chain } from '../../shared/chain'; 6 7 import type { IrSchemaToAstOptions } from '../../shared/types'; 7 - import type { StringResolverContext } from '../../types'; 8 8 9 9 function baseNode(ctx: StringResolverContext): Chain { 10 10 const { z } = ctx.symbols;
+1 -1
packages/openapi-ts/src/plugins/zod/v4/api.ts
··· 1 1 import { $ } from '~/ts-dsl'; 2 2 3 3 import { identifiers } from '../constants'; 4 + import type { ValidatorResolverContext } from '../resolvers'; 4 5 import type { ValidatorArgs } from '../shared/types'; 5 - import type { ValidatorResolverContext } from '../types'; 6 6 7 7 const validatorResolver = ( 8 8 ctx: ValidatorResolverContext,
+1 -1
packages/openapi-ts/src/plugins/zod/v4/toAst/number.ts
··· 7 7 import { $ } from '~/ts-dsl'; 8 8 9 9 import { identifiers } from '../../constants'; 10 + import type { NumberResolverContext } from '../../resolvers'; 10 11 import type { Chain } from '../../shared/chain'; 11 12 import type { Ast, IrSchemaToAstOptions } from '../../shared/types'; 12 - import type { NumberResolverContext } from '../../types'; 13 13 14 14 function baseNode(ctx: NumberResolverContext): Chain { 15 15 const { schema, symbols } = ctx;
+1 -1
packages/openapi-ts/src/plugins/zod/v4/toAst/object.ts
··· 4 4 import { $ } from '~/ts-dsl'; 5 5 6 6 import { identifiers } from '../../constants'; 7 + import type { ObjectResolverContext } from '../../resolvers'; 7 8 import type { Chain } from '../../shared/chain'; 8 9 import type { Ast, IrSchemaToAstOptions } from '../../shared/types'; 9 - import type { ObjectResolverContext } from '../../types'; 10 10 import { irSchemaToAst } from '../plugin'; 11 11 12 12 function additionalPropertiesNode(
+1 -1
packages/openapi-ts/src/plugins/zod/v4/toAst/string.ts
··· 2 2 import { $ } from '~/ts-dsl'; 3 3 4 4 import { identifiers } from '../../constants'; 5 + import type { StringResolverContext } from '../../resolvers'; 5 6 import type { Chain } from '../../shared/chain'; 6 7 import type { Ast, IrSchemaToAstOptions } from '../../shared/types'; 7 - import type { StringResolverContext } from '../../types'; 8 8 9 9 function baseNode(ctx: StringResolverContext): Chain { 10 10 const { z } = ctx.symbols;
+1 -1
packages/openapi-ts/src/types/input.d.ts
··· 170 170 171 171 export type Watch = { 172 172 /** 173 - * Regenerate the client when the input file changes? 173 + * Whether this feature is enabled. 174 174 * 175 175 * @default false 176 176 */
+19 -70
packages/openapi-ts/src/types/parser.d.ts
··· 1 + import type { FeatureToggle, NamingOptions } from '~/config/shared'; 1 2 import type { 2 3 OpenApiMetaObject, 3 4 OpenApiOperationObject, ··· 68 69 | EnumsMode 69 70 | { 70 71 /** 71 - * The casing convention to use for generated names. 72 + * Casing convention for generated names. 72 73 * 73 74 * @default 'PascalCase' 74 75 */ 75 76 case?: Casing; 76 77 /** 77 - * Whether to transform all enums. 78 + * Whether this feature is enabled. 78 79 * 79 80 * @default true 80 81 */ ··· 121 122 | boolean 122 123 | { 123 124 /** 124 - * Whether to split read-only and write-only schemas. 125 + * Whether this feature is enabled. 125 126 * 126 127 * @default true 127 128 */ ··· 139 140 | NameTransformer 140 141 | { 141 142 /** 142 - * The casing convention to use for generated names. 143 + * Casing convention for generated names. 143 144 * 144 145 * @default 'preserve' 145 146 */ ··· 165 166 | NameTransformer 166 167 | { 167 168 /** 168 - * The casing convention to use for generated names. 169 + * Casing convention for generated names. 169 170 * 170 171 * @default 'preserve' 171 172 */ ··· 243 244 * plugin, set `enums` to `root`. Likewise, if you don't want to export any 244 245 * enum types, set `enums` to `inline`. 245 246 */ 246 - enums: { 247 - /** 248 - * The casing convention to use for generated names. 249 - * 250 - * @default 'PascalCase' 251 - */ 252 - case: Casing; 253 - /** 254 - * Whether to transform all enums. 255 - * 256 - * @default true 257 - */ 258 - enabled: boolean; 259 - /** 260 - * Controls whether enums are promoted to reusable root components 261 - * ('root') or kept inline within schemas ('inline'). 262 - * 263 - * @default 'root' 264 - */ 265 - mode: EnumsMode; 266 - /** 267 - * Customize the generated name of enums. 268 - * 269 - * @default '{{name}}Enum' 270 - */ 271 - name: NameTransformer; 272 - }; 247 + enums: NamingOptions & 248 + FeatureToggle & { 249 + /** 250 + * Controls whether enums are promoted to reusable root components 251 + * ('root') or kept inline within schemas ('inline'). 252 + * 253 + * @default 'root' 254 + */ 255 + mode: EnumsMode; 256 + }; 273 257 /** 274 258 * By default, any object schema with a missing `required` keyword is 275 259 * interpreted as "no properties are required." This is the correct ··· 292 276 * would result in such scenarios. You can still disable this 293 277 * behavior if you prefer. 294 278 */ 295 - readWrite: { 296 - /** 297 - * Whether to split read-only and write-only schemas. 298 - * 299 - * @default true 300 - */ 301 - enabled: boolean; 279 + readWrite: FeatureToggle & { 302 280 /** 303 281 * Configuration for generated request-specific schemas. 304 282 */ 305 - requests: { 306 - /** 307 - * The casing convention to use for generated names. 308 - * 309 - * @default 'preserve' 310 - */ 311 - case: Casing; 312 - /** 313 - * Customize the generated name of schemas used in requests or 314 - * containing write-only fields. 315 - * 316 - * @default '{{name}}Writable' 317 - */ 318 - name: NameTransformer; 319 - }; 283 + requests: NamingOptions; 320 284 /** 321 285 * Configuration for generated response-specific schemas. 322 286 */ 323 - responses: { 324 - /** 325 - * The casing convention to use for generated names. 326 - * 327 - * @default 'preserve' 328 - */ 329 - case: Casing; 330 - /** 331 - * Customize the generated name of schemas used in responses or 332 - * containing read-only fields. We default to the original name 333 - * to avoid breaking output when a read-only field is added. 334 - * 335 - * @default '{{name}}' 336 - */ 337 - name: NameTransformer; 338 - }; 287 + responses: NamingOptions; 339 288 }; 340 289 }; 341 290 /**