@hey-api/openapi-ts 0.88.2 → 0.89.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{config-C5xWXzTz.d.cts → config-CBa-XLy8.d.cts} +1007 -839
- package/dist/{config-eqVtXEeO.d.mts → config-uoaRJc6A.d.mts} +1008 -840
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/internal.cjs +1 -1
- package/dist/internal.d.cts +1 -1
- package/dist/internal.d.mts +1 -1
- package/dist/internal.mjs +1 -1
- package/dist/openApi-AbaojA3X.mjs +13 -0
- package/dist/openApi-AbaojA3X.mjs.map +1 -0
- package/dist/openApi-CSMCX27Y.cjs +13 -0
- package/dist/openApi-CSMCX27Y.cjs.map +1 -0
- package/dist/run.cjs +1 -1
- package/dist/run.cjs.map +1 -1
- package/dist/run.mjs +1 -1
- package/dist/run.mjs.map +1 -1
- package/dist/src-CmkI6L90.mjs +11 -0
- package/dist/src-CmkI6L90.mjs.map +1 -0
- package/dist/src-odo5Y_R2.cjs +19 -0
- package/dist/src-odo5Y_R2.cjs.map +1 -0
- package/package.json +2 -2
- package/dist/openApi-DlyxIg9f.mjs +0 -17
- package/dist/openApi-DlyxIg9f.mjs.map +0 -1
- package/dist/openApi-DszQAwQH.cjs +0 -17
- package/dist/openApi-DszQAwQH.cjs.map +0 -1
- package/dist/src-9qIIwEzI.cjs +0 -19
- package/dist/src-9qIIwEzI.cjs.map +0 -1
- package/dist/src-BNSjnWaN.mjs +0 -11
- package/dist/src-BNSjnWaN.mjs.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"openApi-DszQAwQH.cjs","names":["__filename","__dirname","path","fs","ts","fs","path","path","colors","registryRegExp","getRegistryUrl","parseShorthand","queryParams: string | undefined","registryRegExp","getRegistryUrl","namespace","parseShorthand","defaultWatch: Watch","inputs: Array<Input>","input: Input","logs: Config['logs']","a: Partial<UserConfig>","b: Partial<UserConfig>","merged: UserConfig","valueToObject: ValueToObject","mappers","ts","path","fs","fields","defaultValue","defaultConfig","uniqueItems: Array<IR.SchemaObject>","typeIds: Array<string>","path","result: OperationResponsesMap","errors: Omit<IR.SchemaObject, 'properties'> &\n Pick<Required<IR.SchemaObject>, 'properties'>","responses: Omit<IR.SchemaObject, 'properties'> &\n Pick<Required<IR.SchemaObject>, 'properties'>","defaultResponse: IR.ResponseObject | undefined","result: R | void | undefined","ts","ts","ts","ts","modifiers: Array<ts.Modifier>","ts","ts","typeExprFactory: TypeExprFactory | undefined","typeIdxFactory: TypeIdxFactory | undefined","typeOfExprFactory: TypeOfExprFactory | undefined","typeOperatorFactory: TypeOperatorFactory | undefined","typeQueryFactory: TypeQueryFactory | undefined","ts","base","ts","ts","ts","ts","ts","entries: Record<string, string>","ts","ts","ts","ts","base","ts","ts","asFactory: AsFactory | undefined","ts","ts","ts","ts","ts","ts","ts","ts","attrFactory: AttrFactory | undefined","awaitFactory: AwaitFactory | undefined","callFactory: CallFactory | undefined","returnFactory: ReturnFactory | undefined","ts","base","ts","ts","ts","ts","ts","ts","missing: Array<string>","ts","ts","ts","normalized: Array<string | ts.Expression>","ts","spans: Array<ts.TemplateSpan>","ts","ts","ts","ts","elseNode: ts.Statement | undefined","ts","ts","ts","ts","flat: Array<ts.TypeNode>","ts","ts","ts","missing: Array<string>","ts","ts","ts","fromValue","ts","base","ts","ts","missing: Array<string>","ts","missing: Array<string>","flat: Array<ts.TypeNode>","ts","ts","normalized: Array<string | ts.TypeNode>","ts","spans: Array<ts.TemplateLiteralTypeSpan>","exprValue","typeValue","auth: Array<Auth>","path","nameToLocations: Record<string, Set<Location>>","signatureParameters: SignatureParameters","fields: Array<Field>","signatureParameter: SignatureParameter","className: string | undefined","methodName: string | undefined","classCandidates: Array<string>","path","dataType","result: OperationParameters","query: SymbolMeta","responseTypeValue: ReturnType<typeof getResponseType> | undefined","statements: Array<ReturnType<typeof $.return | typeof $.const>>","args: Array<ReturnType<typeof $.expr>>","config: Array<ReturnType<typeof $.object>>","clientExpression: ReturnType<typeof $.attr | typeof $.binary>","EOL","comments: Array<string>","createHttpRequests: AngularCommonPlugin['Handler']","methodAccess: ReturnType<typeof $.attr | typeof $.call>","createHttpResources: AngularCommonPlugin['Handler']","handler: AngularCommonPlugin['Handler']","defaultConfig: AngularCommonPlugin['Config']","defineConfig","__filename","__dirname","path","renamed: Map<string, string> | undefined","fs","dirPath","errorResponse: Url","path","createClient: PluginHandler","defaultConfig: HeyApiClientAngularPlugin['Config']","defineConfig","defaultConfig","defaultConfig: HeyApiClientAxiosPlugin['Config']","defineConfig","defaultConfig","defaultConfig: HeyApiClientFetchPlugin['Config']","defineConfig","defaultConfig","defaultConfig: HeyApiClientKyPlugin['Config']","defineConfig","defaultConfig","defaultConfig: HeyApiClientNextPlugin['Config']","defineConfig","defaultConfig","defaultConfig: HeyApiClientNuxtPlugin['Config']","defineConfig","defaultConfig","defaultConfig: HeyApiClientOfetchPlugin['Config']","defineConfig","defaultConfig","satisfies: typeof semver.satisfies","handler: HeyApiSchemasPlugin['Handler']","defaultConfig: HeyApiSchemasPlugin['Config']","defineConfig","defaultConfig","p","m","t","g","node","handlerV1: HeyApiSdkPlugin['Handler']","handler: HeyApiSdkPlugin['Handler']","handlerV1","defaultConfig: HeyApiSdkPlugin['Config']","defineConfig","defaultConfig","bigIntExpressions: ExpressionTransformer","dateExpressions: ExpressionTransformer","ts","query: SymbolMeta","nodes: Array<ts.Expression | ts.Statement | Expr>","arrayNodes: Array<ts.Expression | ts.Statement | Expr>","handler: HeyApiTransformersPlugin['Handler']","defaultConfig: HeyApiTransformersPlugin['Config']","defineConfig","defaultConfig","types: Array<TypeTsDsl>","comments: Array<string>","typeofItems: Array<\n | 'bigint'\n | 'boolean'\n | 'function'\n | 'number'\n | 'object'\n | 'string'\n | 'symbol'\n | 'undefined'\n >","key: string | undefined","node","type","irSchema: IR.SchemaObject","properties: Record<string, IR.SchemaObject>","required: Array<string>","operationToDataType","data: IR.SchemaObject","dataRequired: Array<string>","irSchemaToAst","node","data: IR.SchemaObject","dataRequired: Array<string>","node","irSchemaToAst","arrayToAst","itemTypes: Array<MaybeTsDsl<TypeTsDsl>>","irSchemaToAst","booleanToAst","enumToAst","irSchemaToAst","neverToAst","nullToAst","numberToAst","objectToAst","indexSchemas: Array<IR.SchemaObject>","irSchemaToAst","p","stringToAst","query: SymbolMeta","queryTypeId: SymbolMeta","symbolTypeId","tupleToAst","itemTypes: Array<MaybeTsDsl<TypeTsDsl>>","irSchemaToAst","undefinedToAst","unknownToAst","voidToAst","irSchemaWithTypeToAst","arrayToAst","booleanToAst","enumToAst","numberToAst","neverToAst","nullToAst","objectToAst","stringToAst","tupleToAst","undefinedToAst","unknownToAst","voidToAst","irSchemaToAst","irSchemaWithTypeToAst","handleComponent","handlerV1: HeyApiTypeScriptPlugin['Handler']","servers: Array<IR.ServerObject>","webhookNames: Array<string>","Api","irSchemaToAstV1","handler: HeyApiTypeScriptPlugin['Handler']","handlerV1","defaultConfig: HeyApiTypeScriptPlugin['Config']","Api","defineConfig","defaultConfig","handleMeta","useTypeData","useTypeError","typeErrorName: string | undefined","useTypeResponse","createMutationOptions","useTypeData","useTypeError","useTypeResponse","fnOptions","statements: Array<ReturnType<typeof $.var | typeof $.return>>","handleMeta","TOptionsType","createQueryKeyFunction","createQueryKeyLiteral","tagsExpression: ReturnType<typeof $.array> | undefined","createQueryKeyType","queryKeyStatement","useTypeData","optionsParamName","createQueryOptions","keyExpression: ReturnType<typeof $.call>","queryKeyStatement","tagsExpr: ReturnType<typeof $.array> | undefined","useTypeData","statements: Array<ReturnType<typeof $.return | typeof $.const>>","handleMeta","handlerV0: PiniaColadaPlugin['Handler']","queryFn: string","handler: PiniaColadaPlugin['Handler']","defaultConfig: PiniaColadaPlugin['Config']","handler","defineConfig","defaultConfig","typeErrorName: string | undefined","tagsArray: TsDsl<ts.ArrayLiteralExpression> | undefined","statements: Array<TsDsl<any>>","fnOptions","statements: Array<TsDsl<any>>","optionsParamName","statements: Array<TsDsl<any>>","handlerV5: PluginHandler","queryFn: string","handler: PluginHandler","defaultConfig: TanStackAngularQueryPlugin['Config']","handler","defineConfig","defaultConfig","defaultConfig: TanStackReactQueryPlugin['Config']","handler","defineConfig","defaultConfig","defaultConfig: TanStackSolidQueryPlugin['Config']","handler","defineConfig","defaultConfig","defaultConfig: TanStackSvelteQueryPlugin['Config']","handler","defineConfig","defaultConfig","defaultConfig: TanStackVueQueryPlugin['Config']","handler","defineConfig","defaultConfig","Api","identifiers","exportAst","identifiers","nullToAst","result: Partial<Omit<Ast, 'typeName'>>","identifiers","objectToAst","result: Partial<Omit<Ast, 'typeName'>>","irSchemaToAst","stringToAst","result: Partial<Omit<Ast, 'typeName'>>","identifiers","irSchemaWithTypeToAst","nullToAst","objectToAst","stringToAst","irSchemaToAst","ast: Partial<Ast>","query: SymbolMeta","irSchemaWithTypeToAst","handleComponent","handlerV2: ArktypePlugin['Handler']","handler: ArktypePlugin['Handler']","handlerV2","defaultConfig: ArktypePlugin['Config']","Api","fields","defaultValue","defineConfig","defaultConfig","errorsTypeReference: ReturnType<typeof $.type> | undefined","responsesTypeReference: ReturnType<typeof $.type> | undefined","handler: FastifyPlugin['Handler']","defaultConfig: FastifyPlugin['Config']","defineConfig","defaultConfig","statements: Array<TsDsl<any>>","handlerV2: SwrPlugin['Handler']","queryFn: string","handler: SwrPlugin['Handler']","defaultConfig: SwrPlugin['Config']","handler","defineConfig","defaultConfig","identifiers","defaultValidatorResolver","identifiers","args: ValidatorResolverArgs","Api","identifiers","exportAst","v","identifiers","numberParameter","irOperationToAst","schemaData: IR.SchemaObject","properties: Record<string, IR.SchemaObject>","required: Array<string>","path","irWebhookToAst","schemaData: IR.SchemaObject","properties: Record<string, IR.SchemaObject>","required: Array<string>","unknownToAst","identifiers","arrayToAst","result: Omit<Ast, 'typeName'>","identifiers","unknownToAst","irSchemaToAst","booleanToAst","pipes: Array<ReturnType<typeof $.call>>","identifiers","enumToAst","enumMembers: Array<ReturnType<typeof $.literal>>","unknownToAst","identifiers","neverToAst","identifiers","nullToAst","identifiers","numberToAst","literalValue: ReturnType<typeof $.fromValue>","identifiers","pipes: Array<ReturnType<typeof $.call>>","numberParameter","defaultObjectBaseResolver","identifiers","objectToAst","result: Partial<Omit<Ast, 'typeName'>>","pipes: Array<ReturnType<typeof $.call>>","irSchemaToAst","additional: ReturnType<typeof $.call | typeof $.expr> | null | undefined","args: ObjectBaseResolverArgs","defaultFormatResolver","identifiers","stringToAst","pipes: Array<ReturnType<typeof $.call>>","args: FormatResolverArgs","tupleToAst","result: Partial<Omit<Ast, 'typeName'>>","identifiers","irSchemaToAst","unknownToAst","undefinedToAst","identifiers","voidToAst","identifiers","irSchemaWithTypeToAst","arrayToAst","booleanToAst","enumToAst","numberToAst","neverToAst","nullToAst","objectToAst","stringToAst","tupleToAst","undefinedToAst","unknownToAst","voidToAst","irSchemaToAst","ast: Ast","query: SymbolMeta","identifiers","irSchemaWithTypeToAst","callParameter: ReturnType<typeof $.fromValue> | undefined","numberParameter","handleComponent","handlerV1: ValibotPlugin['Handler']","handler: ValibotPlugin['Handler']","defaultConfig: ValibotPlugin['Config']","Api","defineConfig","defaultConfig","defaultValidatorResolver","args: ValidatorResolverArgs","defaultValidatorResolver","args: ValidatorResolverArgs","args: ValidatorResolverArgs","schemaData: IR.SchemaObject","properties: Record<string, IR.SchemaObject>","required: Array<string>","path","schemaData: IR.SchemaObject","properties: Record<string, IR.SchemaObject>","required: Array<string>","unknownToAst","result: Partial<Omit<Ast, 'typeName'>>","arrayToAst","result: Partial<Omit<Ast, 'typeName'>>","unknownToAst","irSchemaToAst","intersectionExpression: ReturnType<typeof $.expr | typeof $.call>","checks: Array<ReturnType<typeof $.call>>","booleanToAst","result: Partial<Omit<Ast, 'typeName'>>","chain: ReturnType<typeof $.call>","enumToAst","result: Partial<Omit<Ast, 'typeName'>>","enumMembers: Array<ReturnType<typeof $.literal>>","literalMembers: Array<ReturnType<typeof $.call>>","unknownToAst","neverToAst","result: Partial<Omit<Ast, 'typeName'>>","nullToAst","result: Partial<Omit<Ast, 'typeName'>>","numberToAst","result: Partial<Omit<Ast, 'typeName'>>","checks: Array<ReturnType<typeof $.call>>","defaultObjectBaseResolver","objectToAst","result: Partial<Omit<Ast, 'typeName'>>","irSchemaToAst","additional: ReturnType<typeof $.call | typeof $.expr> | null | undefined","args: ObjectBaseResolverArgs","defaultFormatResolver","stringToAst","result: Partial<Omit<Ast, 'typeName'>>","chain: ReturnType<typeof $.call>","args: FormatResolverArgs","checks: Array<ReturnType<typeof $.call>>","tupleToAst","result: Partial<Omit<Ast, 'typeName'>>","tupleElements","tupleElements: Array<ReturnType<typeof $.call | typeof $.expr>>","irSchemaToAst","undefinedToAst","result: Partial<Omit<Ast, 'typeName'>>","voidToAst","result: Partial<Omit<Ast, 'typeName'>>","irSchemaWithTypeToAst","arrayToAst","booleanToAst","enumToAst","numberToAst","neverToAst","nullToAst","objectToAst","stringToAst","tupleToAst","undefinedToAst","unknownToAst","voidToAst","irSchemaToAst","ast: Partial<Ast>","query: SymbolMeta","irSchemaWithTypeToAst","schema","handleComponent","handlerMini: ZodPlugin['Handler']","unknownToAst","arrayToAst","arrayExpression: ReturnType<typeof $.call> | undefined","unknownToAst","irSchemaToAst","intersectionExpression: ReturnType<typeof $.call | typeof $.expr>","booleanToAst","chain: ReturnType<typeof $.call>","enumToAst","enumMembers: Array<ReturnType<typeof $.literal>>","literalMembers: Array<ReturnType<typeof $.call>>","unknownToAst","enumExpression: ReturnType<typeof $.call>","neverToAst","nullToAst","numberToAst","defaultObjectBaseResolver","objectToAst","irSchemaToAst","additional: ReturnType<typeof $.call | typeof $.expr> | null | undefined","result: Partial<Omit<Ast, 'typeName'>>","args: ObjectBaseResolverArgs","defaultFormatResolver","stringToAst","chain: ReturnType<typeof $.call>","args: FormatResolverArgs","tupleToAst","tupleElements","tupleElements: Array<ReturnType<typeof $.call | typeof $.expr>>","irSchemaToAst","undefinedToAst","voidToAst","irSchemaWithTypeToAst","arrayToAst","booleanToAst","enumToAst","numberToAst","neverToAst","nullToAst","objectToAst","stringToAst","tupleToAst","undefinedToAst","unknownToAst","voidToAst","irSchemaToAst","ast: Partial<Ast>","query: SymbolMeta","irSchemaWithTypeToAst","handleComponent","handlerV3: ZodPlugin['Handler']","result: Partial<Omit<Ast, 'typeName'>>","result: Partial<Omit<Ast, 'typeName'>>","intersectionExpression: ReturnType<typeof $.call | typeof $.expr>","result: Partial<Omit<Ast, 'typeName'>>","chain: ReturnType<typeof $.call>","result: Partial<Omit<Ast, 'typeName'>>","enumMembers: Array<ReturnType<typeof $.literal>>","literalMembers: Array<ReturnType<typeof $.call>>","result: Partial<Omit<Ast, 'typeName'>>","result: Partial<Omit<Ast, 'typeName'>>","result: Partial<Omit<Ast, 'typeName'>>","result: Partial<Omit<Ast, 'typeName'>>","additional: ReturnType<typeof $.call | typeof $.expr> | null | undefined","args: ObjectBaseResolverArgs","result: Partial<Omit<Ast, 'typeName'>>","chain: ReturnType<typeof $.call>","args: FormatResolverArgs","result: Partial<Omit<Ast, 'typeName'>>","tupleElements","tupleElements: Array<ReturnType<typeof $.call | typeof $.expr>>","result: Partial<Omit<Ast, 'typeName'>>","result: Partial<Omit<Ast, 'typeName'>>","ast: Partial<Ast>","query: SymbolMeta","schema","handlerV4: ZodPlugin['Handler']","handler: ZodPlugin['Handler']","defaultConfig: ZodPlugin['Config']","colors","fields","defaultValue","defaultConfig","defaultPluginConfigs: {\n [K in PluginNames]: Plugin.Config<PluginConfigMap[K]>;\n}","angularCommon","heyApiClientAngular","heyApiClientAxios","heyApiClientFetch","heyApiClientKy","heyApiClientNext","heyApiClientNuxt","heyApiClientOfetch","heyApiSchemas","heyApiSdk","heyApiTransformers","heyApiTypeScript","piniaColada","tanStackAngularQuery","tanStackReactQuery","tanStackSolidQuery","tanStackSvelteQuery","tanStackVueQuery","plugins: Config['plugins']","context: PluginContext","userPlugin","defaultConfig","defaultPlugin","userPluginsConfig: Config['plugins']","definedPlugins: UserConfig['plugins']","configs: Array<UserConfig>","dependencies: Record<string, string>","configurationFile: string | undefined","colors","results: Array<ArrayOnly<ConfigResult>>","errors: Array<Error>","path","plugins: Pick<Config, 'plugins' | 'pluginOrder'>","config: Config","joinedValues","values: string[]","search: string[]","entries: Array<[string, string]>","arrayBuffer: ArrayBuffer | undefined","hasChanged: boolean | undefined","response: Response | undefined","ts","imports: Map<string, Binding>","exports: Map<string, Binding>","exports","path","lines: Array<string>","specifiers: Array<ts.ExportSpecifier>","namespaceBinding: string | undefined","finalAlias: string | undefined","name","specifiers: Array<ts.ImportSpecifier>","defaultBinding: ts.Identifier | undefined","namedImports: Array<{\n isTypeOnly: boolean;\n name: string;\n propertyName: ts.ModuleExportName | undefined;\n }>","isTypeOnly","base","declIndex: Map<string, number>","walkDeclarations: WalkFn","walkTopological: WalkFn","order: Array<string>","getGroup: GetPointerPriorityFn","walk: WalkFn","matchIrPointerToGroup: MatchPointerToGroupFn<IrTopLevelKind>","patterns: Record<IrTopLevelKind, RegExp>","kind","kindPriority: KindPriority","partial: Partial<KindPriority>","getIrPointerPriority: GetPointerPriorityFn","defaultGetKind: Required<Required<Hooks>['operations']>['getKind']","callback: (event: WalkEvent<TKind>) => void","events: ReadonlyArray<TKind>","options: WalkOptions<TKind>","event: WalkEvent | undefined","baseEvent: BaseEvent","symbolIn: SymbolIn","path","result: EventHooks","Project","base","result: string","path","namespace","keys: Array<string>","regexps: Array<RegExp>","path","filters: Filters","dependencies: Set<string> | undefined","resourceMetadata: ResourceMetadata","path","namespace","base","path","walkSchemas","path","rootEnums: Record<string, unknown>","rootEnumSignatures: Record<string, string>","inlineEnums: Array<{\n key: string | number | null;\n node: unknown;\n parent: unknown;\n path: ReadonlyArray<string | number>;\n signature: string;\n }>","signatureToName: Record<string, string | undefined>","signatureToSchema: Record<string, unknown>","path","childResult: Partial<PointerDependenciesResult>","worklist: Set<string>","graph: Graph","walk","path","deprecated: boolean | undefined","tags: Set<string> | undefined","cache: Cache","path","originals: OriginalSchemas","split: SplitSchemas","deepEqual","walk","path","colors","filterSpec","filtered: typeof spec.definitions","path","contentToSchema","mediaTypeObjects","objects: Array<Content>","values: Array<string>","getSchemaType","parseSchemaJsDoc","parseSchemaMeta","parseArray","schemaItems: Array<IR.SchemaObject>","schemaToIrSchema","parseBoolean","parseNumber","parseObject","schemaProperties: Record<string, IR.SchemaObject>","parseString","initIrSchema","irSchema: IR.SchemaObject","parseAllOf","valueSchemas: ReadonlyArray<IR.SchemaObject>","irDiscriminatorSchema: IR.SchemaObject","parseOneType","nestedItems: Array<IR.SchemaObject>","parseEnum","enumType: SchemaType<SchemaObject> | 'null' | undefined","parseRef","irSchema","parseNullableType","typeIrSchema: IR.SchemaObject","parseType","parseUnknown","parseSchema","isPaginationType","paginationField","name","getSchemaType","parseOperationJsDoc","initIrOperation","irOperation: IR.OperationObject","operationToIrOperation","requestBodyObject: IRBodyObject","requestBodyObjectRequired: Array<string>","schema: SchemaObject","mediaTypeObjects","content","paginationField","schemaToIrSchema","contentToSchema","securitySchemeObjects: Map<string, IR.SecurityObject>","irSecuritySchemeObject: IR.SecurityObject | undefined","parsePathOperation","path","defaultExplode","defaultStyle","parametersArrayToObject","parametersObject: IR.ParametersObject","parameterToIrParameter","finalSchema: SchemaObject","paginationField","irParameter: IR.ParameterObject","schemaToIrSchema","parseServers","schemes: ReadonlyArray<string>","path","validateOpenApiSpec","issues: Array<ValidatorIssue>","path","validateOpenApiSpec","state: State","path","commonOperation: OperationObject","operationArgs: Omit<\n Parameters<typeof parsePathOperation>[0],\n 'method'\n >","parametersArrayToObject","filterSpec","filtered: typeof spec.components.parameters","filtered: typeof spec.components.requestBodies","filtered: typeof spec.components.responses","filtered: typeof spec.components.schemas","path","contentToSchema","mediaTypeObjects","objects: Array<Content>","parseSchemaJsDoc","parseSchemaMeta","parseArray","schemaItems: Array<IR.SchemaObject>","schemaToIrSchema","parseBoolean","parseNumber","parseObject","schemaProperties: Record<string, IR.SchemaObject>","parseString","initIrSchema","irSchema: IR.SchemaObject","parseAllOf","valueSchemas: ReadonlyArray<IR.SchemaObject>","irDiscriminatorSchema: IR.SchemaObject","parseOneType","nestedItems: Array<IR.SchemaObject>","parseAnyOf","parseEnum","enumType: SchemaType<SchemaObject> | 'null' | undefined","parseOneOf","parseRef","irSchema","typeIrSchema: IR.SchemaObject","parseType","parseUnknown","parseSchema","isPaginationType","paginationField","refSchema: SchemaObject | ReferenceObject | undefined","mediaTypeObjects","content","name","parseOperationJsDoc","initIrOperation","irOperation: IR.OperationObject","operationToIrOperation","mediaTypeObjects","content","paginationField","schemaToIrSchema","contentToSchema","securitySchemeObjects: Map<string, IR.SecurityObject>","parsePathOperation","path","defaultAllowReserved","defaultExplode","defaultStyle","parametersArrayToObject","parametersObject: IR.ParametersObject","parameterToIrParameter","mediaTypeObjects","content","finalSchema: SchemaObject","paginationField","irParameter: IR.ParameterObject","schemaToIrSchema","parseParameter","requestBodyToIrRequestBody","mediaTypeObjects","content","irRequestBody: IR.RequestBodyObject","schemaToIrSchema","parseRequestBody","parseServers","validateOpenApiSpec","issues: Array<ValidatorIssue>","path","validateOpenApiSpec","state: State","path","operationArgs: Omit<\n Parameters<typeof parsePathOperation>[0],\n 'method' | 'operation'\n > & {\n operation: Omit<\n Parameters<typeof parsePathOperation>[0]['operation'],\n 'responses'\n >;\n }","parametersArrayToObject","filtered: typeof spec.components.parameters","filtered: typeof spec.components.requestBodies","filtered: typeof spec.components.responses","filtered: typeof spec.components.schemas","path","objects: Array<Content>","schemaItems: Array<IR.SchemaObject>","schemaProperties: Record<string, IR.SchemaObject>","patternProperties: Record<string, IR.SchemaObject>","irSchema: IR.SchemaObject","valueSchemas: ReadonlyArray<IR.SchemaObject>","irDiscriminatorSchema: IR.SchemaObject","nestedItems: Array<IR.SchemaObject>","enumType: SchemaType<SchemaObject> | undefined","irSchema","irRefSchema: IR.SchemaObject","typeIrSchema: IR.SchemaObject","refSchema: SchemaObject | undefined","content","name","schema","irOperation: IR.OperationObject","content","securitySchemeObjects: Map<string, IR.SecurityObject>","path","parametersObject: IR.ParametersObject","content","finalSchema: SchemaObject","irParameter: IR.ParameterObject","content","irRequestBody: IR.RequestBodyObject","issues: Array<ValidatorIssue>","path","state: Parameters<typeof parseWebhookOperation>[0]['state']","operationArgs: Omit<\n Parameters<typeof parseWebhookOperation>[0],\n 'method'\n >","state: State","path","operationArgs: Omit<\n Parameters<typeof parsePathOperation>[0],\n 'method'\n >"],"sources":["../src/generate/tsConfig.ts","../src/generate/utils.ts","../src/error.ts","../src/utils/input/heyApi.ts","../src/utils/input/readme.ts","../src/utils/input/scalar.ts","../src/utils/input/index.ts","../src/config/input.ts","../src/config/logs.ts","../src/config/merge.ts","../src/config/utils/config.ts","../src/config/output.ts","../src/config/packages.ts","../src/config/parser.ts","../src/plugins/shared/utils/config.ts","../src/utils/stringCase.ts","../src/openApi/shared/utils/name.ts","../src/ir/parameter.ts","../src/ir/schema.ts","../src/ir/utils.ts","../src/ir/operation.ts","../src/openApi/common/parser/sanitize.ts","../src/plugins/@hey-api/client-core/utils.ts","../src/plugins/shared/utils/refs.ts","../src/ts-dsl/base.ts","../src/ts-dsl/expr/id.ts","../src/ts-dsl/layout/newline.ts","../src/ts-dsl/mixins/apply.ts","../src/ts-dsl/mixins/args.ts","../src/ts-dsl/decl/decorator.ts","../src/ts-dsl/mixins/decorator.ts","../src/ts-dsl/layout/doc.ts","../src/ts-dsl/mixins/doc.ts","../src/ts-dsl/mixins/modifiers.ts","../src/ts-dsl/type/param.ts","../src/ts-dsl/mixins/type-params.ts","../src/ts-dsl/mixins/value.ts","../src/ts-dsl/mixins/type-args.ts","../src/ts-dsl/mixins/type-expr.ts","../src/ts-dsl/type/attr.ts","../src/ts-dsl/type/expr.ts","../src/ts-dsl/decl/field.ts","../src/ts-dsl/stmt/stmt.ts","../src/ts-dsl/mixins/do.ts","../src/ts-dsl/mixins/optional.ts","../src/ts-dsl/token.ts","../src/ts-dsl/decl/pattern.ts","../src/ts-dsl/mixins/pattern.ts","../src/ts-dsl/decl/param.ts","../src/ts-dsl/mixins/param.ts","../src/ts-dsl/decl/init.ts","../src/ts-dsl/decl/method.ts","../src/ts-dsl/decl/class.ts","../src/utils/regexp.ts","../src/ts-dsl/expr/prefix.ts","../src/ts-dsl/mixins/as.ts","../src/ts-dsl/expr/literal.ts","../src/ts-dsl/utils/prop.ts","../src/ts-dsl/decl/member.ts","../src/ts-dsl/decl/enum.ts","../src/ts-dsl/decl/func.ts","../src/ts-dsl/decl/getter.ts","../src/ts-dsl/decl/setter.ts","../src/ts-dsl/mixins/layout.ts","../src/ts-dsl/expr/array.ts","../src/ts-dsl/mixins/expr.ts","../src/ts-dsl/expr/as.ts","../src/ts-dsl/expr/binary.ts","../src/ts-dsl/mixins/operator.ts","../src/ts-dsl/expr/attr.ts","../src/ts-dsl/expr/await.ts","../src/ts-dsl/expr/call.ts","../src/ts-dsl/expr/expr.ts","../src/ts-dsl/layout/hint.ts","../src/ts-dsl/mixins/hint.ts","../src/ts-dsl/expr/prop.ts","../src/ts-dsl/expr/object.ts","../src/ts-dsl/expr/fromValue.ts","../src/ts-dsl/expr/new.ts","../src/ts-dsl/expr/regexp.ts","../src/ts-dsl/expr/template.ts","../src/ts-dsl/expr/ternary.ts","../src/ts-dsl/expr/typeof.ts","../src/ts-dsl/layout/note.ts","../src/ts-dsl/stmt/if.ts","../src/ts-dsl/stmt/return.ts","../src/ts-dsl/stmt/throw.ts","../src/ts-dsl/stmt/var.ts","../src/ts-dsl/type/alias.ts","../src/ts-dsl/type/and.ts","../src/ts-dsl/type/literal.ts","../src/ts-dsl/type/idx-sig.ts","../src/ts-dsl/type/prop.ts","../src/ts-dsl/type/object.ts","../src/ts-dsl/type/tuple.ts","../src/ts-dsl/type/fromValue.ts","../src/ts-dsl/type/func.ts","../src/ts-dsl/type/idx.ts","../src/ts-dsl/type/mapped.ts","../src/ts-dsl/type/operator.ts","../src/ts-dsl/type/or.ts","../src/ts-dsl/type/query.ts","../src/ts-dsl/type/template.ts","../src/ts-dsl/index.ts","../src/utils/transform.ts","../src/plugins/@hey-api/sdk/shared/auth.ts","../src/plugins/@hey-api/sdk/shared/constants.ts","../src/utils/ref.ts","../src/plugins/@hey-api/sdk/shared/signature.ts","../src/plugins/@hey-api/sdk/shared/validator.ts","../src/plugins/@hey-api/sdk/shared/operation.ts","../src/utils/escape.ts","../src/plugins/shared/utils/operation.ts","../src/plugins/@angular/common/httpRequests.ts","../src/plugins/@angular/common/httpResources.ts","../src/plugins/@angular/common/plugin.ts","../src/plugins/@angular/common/config.ts","../src/plugins/@hey-api/client-core/config.ts","../src/generate/client.ts","../src/utils/url.ts","../src/plugins/@hey-api/client-core/client.ts","../src/plugins/@hey-api/client-core/createClientConfig.ts","../src/plugins/@hey-api/client-core/plugin.ts","../src/plugins/@hey-api/client-angular/config.ts","../src/plugins/@hey-api/client-axios/config.ts","../src/plugins/@hey-api/client-fetch/config.ts","../src/plugins/@hey-api/client-ky/config.ts","../src/plugins/@hey-api/client-next/config.ts","../src/plugins/@hey-api/client-nuxt/config.ts","../src/plugins/@hey-api/client-ofetch/config.ts","../src/config/utils/package.ts","../src/openApi/shared/utils/identifier.ts","../src/plugins/@hey-api/schemas/plugin.ts","../src/plugins/@hey-api/schemas/config.ts","../src/plugins/@hey-api/sdk/shared/class.ts","../src/plugins/@hey-api/sdk/shared/functions.ts","../src/plugins/@hey-api/sdk/shared/typeOptions.ts","../src/plugins/@hey-api/sdk/v1/plugin.ts","../src/plugins/@hey-api/sdk/plugin.ts","../src/plugins/@hey-api/sdk/config.ts","../src/plugins/@hey-api/transformers/expressions.ts","../src/plugins/@hey-api/transformers/plugin.ts","../src/plugins/@hey-api/transformers/config.ts","../src/plugins/@hey-api/typescript/shared/clientOptions.ts","../src/plugins/shared/utils/schema.ts","../src/plugins/@hey-api/typescript/shared/export.ts","../src/plugins/@hey-api/typescript/shared/operation.ts","../src/plugins/@hey-api/typescript/shared/webhook.ts","../src/plugins/@hey-api/typescript/shared/webhooks.ts","../src/plugins/@hey-api/typescript/v1/toAst/array.ts","../src/plugins/@hey-api/typescript/v1/toAst/boolean.ts","../src/plugins/@hey-api/typescript/v1/toAst/enum.ts","../src/plugins/@hey-api/typescript/v1/toAst/never.ts","../src/plugins/@hey-api/typescript/v1/toAst/null.ts","../src/plugins/@hey-api/typescript/v1/toAst/number.ts","../src/plugins/@hey-api/typescript/v1/toAst/object.ts","../src/plugins/@hey-api/typescript/v1/toAst/string.ts","../src/plugins/@hey-api/typescript/v1/toAst/tuple.ts","../src/plugins/@hey-api/typescript/v1/toAst/undefined.ts","../src/plugins/@hey-api/typescript/v1/toAst/unknown.ts","../src/plugins/@hey-api/typescript/v1/toAst/void.ts","../src/plugins/@hey-api/typescript/v1/toAst/index.ts","../src/plugins/@hey-api/typescript/v1/plugin.ts","../src/plugins/@hey-api/typescript/api.ts","../src/plugins/@hey-api/typescript/plugin.ts","../src/plugins/@hey-api/typescript/config.ts","../src/plugins/@pinia/colada/meta.ts","../src/plugins/@pinia/colada/useType.ts","../src/plugins/@pinia/colada/utils.ts","../src/plugins/@pinia/colada/mutationOptions.ts","../src/plugins/@pinia/colada/queryKey.ts","../src/plugins/@pinia/colada/queryOptions.ts","../src/plugins/@pinia/colada/v0/plugin.ts","../src/plugins/@pinia/colada/plugin.ts","../src/plugins/@pinia/colada/config.ts","../src/plugins/@tanstack/query-core/shared/useType.ts","../src/plugins/@tanstack/query-core/queryKey.ts","../src/plugins/@tanstack/query-core/shared/meta.ts","../src/plugins/@tanstack/query-core/v5/infiniteQueryOptions.ts","../src/plugins/@tanstack/query-core/v5/mutationOptions.ts","../src/plugins/@tanstack/query-core/v5/queryOptions.ts","../src/plugins/@tanstack/query-core/v5/useQuery.ts","../src/plugins/@tanstack/query-core/v5/plugin.ts","../src/plugins/@tanstack/query-core/plugin.ts","../src/plugins/@tanstack/angular-query-experimental/config.ts","../src/plugins/@tanstack/react-query/config.ts","../src/plugins/@tanstack/solid-query/config.ts","../src/plugins/@tanstack/svelte-query/config.ts","../src/plugins/@tanstack/vue-query/config.ts","../src/plugins/arktype/v2/api.ts","../src/plugins/arktype/api.ts","../src/plugins/arktype/constants.ts","../src/plugins/arktype/shared/export.ts","../src/plugins/arktype/v2/toAst/null.ts","../src/plugins/arktype/v2/toAst/object.ts","../src/plugins/arktype/v2/toAst/string.ts","../src/plugins/arktype/v2/toAst/index.ts","../src/plugins/arktype/v2/plugin.ts","../src/plugins/arktype/plugin.ts","../src/plugins/arktype/config.ts","../src/plugins/fastify/plugin.ts","../src/plugins/fastify/config.ts","../src/plugins/swr/v2/useSwr.ts","../src/plugins/swr/v2/plugin.ts","../src/plugins/swr/plugin.ts","../src/plugins/swr/config.ts","../src/plugins/valibot/v1/constants.ts","../src/plugins/valibot/v1/api.ts","../src/plugins/valibot/api.ts","../src/plugins/valibot/shared/pipesToAst.ts","../src/plugins/valibot/shared/export.ts","../src/plugins/valibot/shared/numbers.ts","../src/plugins/valibot/shared/operation.ts","../src/plugins/valibot/shared/webhook.ts","../src/plugins/valibot/v1/toAst/unknown.ts","../src/plugins/valibot/v1/toAst/array.ts","../src/plugins/valibot/v1/toAst/boolean.ts","../src/plugins/valibot/v1/toAst/enum.ts","../src/plugins/valibot/v1/toAst/never.ts","../src/plugins/valibot/v1/toAst/null.ts","../src/plugins/valibot/v1/toAst/number.ts","../src/plugins/valibot/v1/toAst/object.ts","../src/plugins/valibot/v1/toAst/string.ts","../src/plugins/valibot/v1/toAst/tuple.ts","../src/plugins/valibot/v1/toAst/undefined.ts","../src/plugins/valibot/v1/toAst/void.ts","../src/plugins/valibot/v1/toAst/index.ts","../src/plugins/valibot/v1/plugin.ts","../src/plugins/valibot/plugin.ts","../src/plugins/valibot/config.ts","../src/plugins/zod/constants.ts","../src/plugins/zod/mini/api.ts","../src/plugins/zod/v3/api.ts","../src/plugins/zod/v4/api.ts","../src/plugins/zod/api.ts","../src/plugins/zod/shared/export.ts","../src/plugins/zod/shared/module.ts","../src/plugins/zod/shared/numbers.ts","../src/plugins/zod/shared/operation.ts","../src/plugins/zod/shared/webhook.ts","../src/plugins/zod/mini/toAst/unknown.ts","../src/plugins/zod/mini/toAst/array.ts","../src/plugins/zod/mini/toAst/boolean.ts","../src/plugins/zod/mini/toAst/enum.ts","../src/plugins/zod/mini/toAst/never.ts","../src/plugins/zod/mini/toAst/null.ts","../src/plugins/zod/mini/toAst/number.ts","../src/plugins/zod/mini/toAst/object.ts","../src/plugins/zod/mini/toAst/string.ts","../src/plugins/zod/mini/toAst/tuple.ts","../src/plugins/zod/mini/toAst/undefined.ts","../src/plugins/zod/mini/toAst/void.ts","../src/plugins/zod/mini/toAst/index.ts","../src/plugins/zod/mini/plugin.ts","../src/plugins/zod/v3/toAst/unknown.ts","../src/plugins/zod/v3/toAst/array.ts","../src/plugins/zod/v3/toAst/boolean.ts","../src/plugins/zod/v3/toAst/enum.ts","../src/plugins/zod/v3/toAst/never.ts","../src/plugins/zod/v3/toAst/null.ts","../src/plugins/zod/v3/toAst/number.ts","../src/plugins/zod/v3/toAst/object.ts","../src/plugins/zod/v3/toAst/string.ts","../src/plugins/zod/v3/toAst/tuple.ts","../src/plugins/zod/v3/toAst/undefined.ts","../src/plugins/zod/v3/toAst/void.ts","../src/plugins/zod/v3/toAst/index.ts","../src/plugins/zod/v3/plugin.ts","../src/plugins/zod/v4/toAst/unknown.ts","../src/plugins/zod/v4/toAst/array.ts","../src/plugins/zod/v4/toAst/boolean.ts","../src/plugins/zod/v4/toAst/enum.ts","../src/plugins/zod/v4/toAst/never.ts","../src/plugins/zod/v4/toAst/null.ts","../src/plugins/zod/v4/toAst/number.ts","../src/plugins/zod/v4/toAst/object.ts","../src/plugins/zod/v4/toAst/string.ts","../src/plugins/zod/v4/toAst/tuple.ts","../src/plugins/zod/v4/toAst/undefined.ts","../src/plugins/zod/v4/toAst/void.ts","../src/plugins/zod/v4/toAst/index.ts","../src/plugins/zod/v4/plugin.ts","../src/plugins/zod/plugin.ts","../src/plugins/zod/config.ts","../src/plugins/config.ts","../src/config/plugins.ts","../src/config/init.ts","../src/plugins/@hey-api/client-core/bundle/params.ts","../src/plugins/@hey-api/client-core/bundle/pathSerializer.ts","../src/plugins/@hey-api/client-fetch/bundle/utils.ts","../src/getSpec.ts","../src/generate/renderer.ts","../src/utils/minHeap.ts","../src/graph/walk.ts","../src/ir/graph.ts","../src/plugins/shared/utils/instance.ts","../src/ir/context.ts","../src/openApi/shared/utils/operation.ts","../src/openApi/shared/utils/filter.ts","../src/openApi/shared/graph/meta.ts","../src/openApi/shared/utils/schema.ts","../src/openApi/shared/utils/schemaChildRelationships.ts","../src/openApi/shared/utils/transforms.ts","../src/openApi/shared/transforms/utils.ts","../src/openApi/shared/transforms/enums.ts","../src/openApi/shared/transforms/propertiesRequiredByDefault.ts","../src/openApi/shared/utils/deepEqual.ts","../src/openApi/shared/utils/graph.ts","../src/openApi/shared/transforms/readWrite.ts","../src/openApi/shared/transforms/index.ts","../src/openApi/shared/utils/parameter.ts","../src/openApi/shared/utils/validator.ts","../src/openApi/2.0.x/parser/filter.ts","../src/ir/mediaType.ts","../src/openApi/2.0.x/parser/mediaType.ts","../src/ir/pagination.ts","../src/openApi/shared/utils/discriminator.ts","../src/openApi/2.0.x/parser/schema.ts","../src/openApi/2.0.x/parser/pagination.ts","../src/openApi/2.0.x/parser/operation.ts","../src/openApi/2.0.x/parser/parameter.ts","../src/openApi/2.0.x/parser/server.ts","../src/openApi/2.0.x/parser/validate.ts","../src/openApi/2.0.x/parser/index.ts","../src/openApi/3.0.x/parser/filter.ts","../src/openApi/3.0.x/parser/mediaType.ts","../src/openApi/3.0.x/parser/schema.ts","../src/openApi/3.0.x/parser/pagination.ts","../src/openApi/3.0.x/parser/operation.ts","../src/openApi/3.0.x/parser/parameter.ts","../src/openApi/3.0.x/parser/requestBody.ts","../src/openApi/3.0.x/parser/server.ts","../src/openApi/3.0.x/parser/validate.ts","../src/openApi/3.0.x/parser/index.ts","../src/openApi/3.1.x/parser/filter.ts","../src/openApi/3.1.x/parser/mediaType.ts","../src/openApi/3.1.x/parser/schema.ts","../src/openApi/3.1.x/parser/pagination.ts","../src/openApi/3.1.x/parser/operation.ts","../src/openApi/3.1.x/parser/parameter.ts","../src/openApi/3.1.x/parser/requestBody.ts","../src/openApi/3.1.x/parser/server.ts","../src/openApi/3.1.x/parser/validate.ts","../src/openApi/3.1.x/parser/webhook.ts","../src/openApi/3.1.x/parser/index.ts","../src/openApi/index.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nimport ts from 'typescript';\n\nimport type { UserOutput } from '~/types/output';\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\nexport const findPackageJson = (): unknown | undefined => {\n let dir = __dirname;\n while (dir !== path.dirname(dir)) {\n const files = fs.readdirSync(dir);\n const candidates = files.filter((file) => file === 'package.json');\n\n if (candidates[0]) {\n const packageJsonPath = path.join(dir, candidates[0]);\n return JSON.parse(\n fs.readFileSync(packageJsonPath, {\n encoding: 'utf8',\n }),\n );\n }\n\n dir = path.dirname(dir);\n }\n\n return;\n};\n\nexport const loadPackageJson = () => {\n const packageJson = findPackageJson();\n\n const safePackage = {\n bugs: {\n url: '',\n },\n name: '',\n version: '',\n };\n\n if (packageJson && typeof packageJson === 'object') {\n if ('name' in packageJson && typeof packageJson.name === 'string') {\n safePackage.name = packageJson.name;\n }\n\n if ('version' in packageJson && typeof packageJson.version === 'string') {\n safePackage.version = packageJson.version;\n }\n\n if (\n 'bugs' in packageJson &&\n packageJson.bugs &&\n typeof packageJson.bugs === 'object'\n ) {\n if (\n 'url' in packageJson.bugs &&\n typeof packageJson.bugs.url === 'string'\n ) {\n safePackage.bugs.url = packageJson.bugs.url;\n if (safePackage.bugs.url && !safePackage.bugs.url.endsWith('/')) {\n safePackage.bugs.url += '/';\n }\n }\n }\n }\n\n return safePackage;\n};\n\nexport const findTsConfigPath = (\n tsConfigPath?: UserOutput['tsConfigPath'],\n): string | null => {\n if (tsConfigPath === null) {\n return null;\n }\n\n if (tsConfigPath) {\n const resolved = path.isAbsolute(tsConfigPath)\n ? tsConfigPath\n : path.resolve(__dirname, tsConfigPath);\n return fs.existsSync(resolved) ? resolved : null;\n }\n\n let dir = __dirname;\n while (dir !== path.dirname(dir)) {\n const files = fs.readdirSync(dir);\n const candidates = files\n .filter((file) => file.startsWith('tsconfig') && file.endsWith('.json'))\n .sort((file) => (file === 'tsconfig.json' ? -1 : 1));\n\n if (candidates[0]) {\n return path.join(dir, candidates[0]);\n }\n\n dir = path.dirname(dir);\n }\n\n return null;\n};\n\nexport const loadTsConfig = (\n configPath: string | null,\n): ts.ParsedCommandLine | null => {\n if (!configPath) {\n return null;\n }\n\n const raw = ts.readConfigFile(configPath, ts.sys.readFile);\n\n if (raw.error) {\n throw new Error(`Couldn't read tsconfig from path: ${configPath}`);\n }\n\n return ts.parseJsonConfigFileContent(\n raw.config,\n ts.sys,\n path.dirname(configPath),\n );\n};\n","import type { PathLike } from 'node:fs';\nimport fs from 'node:fs';\n\nexport const ensureDirSync = (path: PathLike) => {\n if (!fs.existsSync(path)) {\n fs.mkdirSync(path, { recursive: true });\n }\n};\n","import fs from 'node:fs';\nimport path from 'node:path';\n\nimport colors from 'ansi-colors';\n\nimport { loadPackageJson } from '~/generate/tsConfig';\nimport { ensureDirSync } from '~/generate/utils';\n\ntype IJobError = {\n error: Error;\n jobIndex: number;\n};\n\n/**\n * Represents a single configuration error.\n *\n * Used for reporting issues with a specific config instance.\n */\nexport class ConfigError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'ConfigError';\n }\n}\n\n/**\n * Aggregates multiple config errors with their job indices for reporting.\n */\nexport class ConfigValidationError extends Error {\n readonly errors: ReadonlyArray<IJobError>;\n\n constructor(errors: Array<IJobError>) {\n super(\n `Found ${errors.length} configuration ${errors.length === 1 ? 'error' : 'errors'}.`,\n );\n this.name = 'ConfigValidationError';\n this.errors = errors;\n }\n}\n\n/**\n * Represents a runtime error originating from a specific job.\n *\n * Used for reporting job-level failures that are not config validation errors.\n */\nexport class JobError extends Error {\n readonly originalError: IJobError;\n\n constructor(message: string, error: IJobError) {\n super(message);\n this.name = 'JobError';\n this.originalError = error;\n }\n}\n\nexport class HeyApiError extends Error {\n args: ReadonlyArray<unknown>;\n event: string;\n pluginName: string;\n\n constructor({\n args,\n error,\n event,\n name,\n pluginName,\n }: {\n args: unknown[];\n error: Error;\n event: string;\n name: string;\n pluginName: string;\n }) {\n const message = error instanceof Error ? error.message : 'Unknown error';\n super(message);\n\n this.args = args;\n this.cause = error.cause;\n this.event = event;\n this.name = name || error.name;\n this.pluginName = pluginName;\n this.stack = error.stack;\n }\n}\n\nexport const logCrashReport = (\n error: unknown,\n logsDir: string,\n): string | undefined => {\n if (error instanceof ConfigError || error instanceof ConfigValidationError) {\n return;\n }\n\n if (error instanceof JobError) {\n error = error.originalError.error;\n }\n\n const logName = `openapi-ts-error-${Date.now()}.log`;\n const fullDir = path.resolve(process.cwd(), logsDir);\n ensureDirSync(fullDir);\n const logPath = path.resolve(fullDir, logName);\n\n let logContent = `[${new Date().toISOString()}] `;\n\n if (error instanceof HeyApiError) {\n logContent += `${error.name} during event \"${error.event}\"\\n`;\n if (error.pluginName) {\n logContent += `Plugin: ${error.pluginName}\\n`;\n }\n logContent += `Arguments: ${JSON.stringify(error.args, null, 2)}\\n\\n`;\n }\n\n const message = error instanceof Error ? error.message : String(error);\n const stack = error instanceof Error ? error.stack : undefined;\n\n logContent += `Error: ${message}\\n`;\n if (stack) {\n logContent += `Stack:\\n${stack}\\n`;\n }\n\n fs.writeFileSync(logPath, logContent);\n\n return logPath;\n};\n\nexport const openGitHubIssueWithCrashReport = async (error: unknown) => {\n const packageJson = loadPackageJson();\n if (!packageJson.bugs.url) return;\n\n if (error instanceof JobError) {\n error = error.originalError.error;\n }\n\n let body = '';\n\n if (error instanceof HeyApiError) {\n if (error.pluginName) {\n body += `**Plugin**: \\`${error.pluginName}\\`\\n`;\n }\n body += `**Event**: \\`${error.event}\\`\\n`;\n body += `**Arguments**:\\n\\`\\`\\`ts\\n${JSON.stringify(error.args, null, 2)}\\n\\`\\`\\`\\n\\n`;\n }\n\n const message = error instanceof Error ? error.message : String(error);\n const stack = error instanceof Error ? error.stack : undefined;\n\n body += `**Error**: \\`${message}\\`\\n`;\n if (stack) {\n body += `\\n**Stack Trace**:\\n\\`\\`\\`\\n${stack}\\n\\`\\`\\``;\n }\n\n const search = new URLSearchParams({\n body,\n labels: 'bug 🔥',\n title: 'Crash Report',\n });\n const url = `${packageJson.bugs.url}new?${search.toString()}`;\n const open = (await import('open')).default;\n await open(url);\n};\n\nexport const printCrashReport = ({\n error,\n logPath,\n}: {\n error: unknown;\n logPath: string | undefined;\n}) => {\n if (error instanceof ConfigValidationError && error.errors.length) {\n const groupByJob = new Map<number, Array<Error>>();\n for (const { error: err, jobIndex } of error.errors) {\n if (!groupByJob.has(jobIndex)) {\n groupByJob.set(jobIndex, []);\n }\n groupByJob.get(jobIndex)!.push(err);\n }\n\n for (const [jobIndex, errors] of groupByJob.entries()) {\n const jobPrefix = colors.gray(`[Job ${jobIndex + 1}] `);\n const count = errors.length;\n const baseString = colors.red(\n `Found ${count} configuration ${count === 1 ? 'error' : 'errors'}:`,\n );\n console.error(`${jobPrefix}❗️ ${baseString}`);\n errors.forEach((err, index) => {\n const itemPrefixStr = ` [${index + 1}] `;\n const itemPrefix = colors.red(itemPrefixStr);\n console.error(`${jobPrefix}${itemPrefix}${colors.white(err.message)}`);\n });\n }\n } else {\n let jobPrefix = colors.gray('[root] ');\n if (error instanceof JobError) {\n jobPrefix = colors.gray(`[Job ${error.originalError.jobIndex + 1}] `);\n error = error.originalError.error;\n }\n\n const baseString = colors.red('Failed with the message:');\n console.error(`${jobPrefix}❌ ${baseString}`);\n const itemPrefixStr = ` `;\n const itemPrefix = colors.red(itemPrefixStr);\n console.error(\n `${jobPrefix}${itemPrefix}${typeof error === 'string' ? error : error instanceof Error ? error.message : 'Unknown error'}`,\n );\n }\n\n if (logPath) {\n const jobPrefix = colors.gray('[root] ');\n console.error(\n `${jobPrefix}${colors.cyan('📄 Crash log saved to:')} ${colors.gray(logPath)}`,\n );\n }\n};\n\nexport const shouldReportCrash = async ({\n error,\n isInteractive,\n}: {\n error: unknown;\n isInteractive: boolean | undefined;\n}): Promise<boolean> => {\n if (\n !isInteractive ||\n error instanceof ConfigError ||\n error instanceof ConfigValidationError\n ) {\n return false;\n }\n\n return new Promise((resolve) => {\n const jobPrefix = colors.gray('[root] ');\n console.log(\n `${jobPrefix}${colors.yellow('📢 Open a GitHub issue with crash details? (y/N):')}`,\n );\n process.stdin.setEncoding('utf8');\n process.stdin.once('data', (data: string) => {\n resolve(data.trim().toLowerCase() === 'y');\n });\n });\n};\n","import type { Input } from '~/types/input';\n\n// Regular expression to match Hey API Registry input formats:\n// - {organization}/{project}?{queryParams}\nconst registryRegExp = /^([\\w-]+)\\/([\\w-]+)(?:\\?([\\w=&.-]*))?$/;\n\nexport const heyApiRegistryBaseUrl = 'https://get.heyapi.dev';\n\n/**\n * Creates a full Hey API Registry URL.\n *\n * @param organization - Hey API organization slug\n * @param project - Hey API project slug\n * @param queryParams - Optional query parameters\n * @returns The full Hey API registry URL.\n */\nexport const getRegistryUrl = (\n organization: string,\n project: string,\n queryParams?: string,\n): string =>\n `${heyApiRegistryBaseUrl}/${organization}/${project}${queryParams ? `?${queryParams}` : ''}`;\n\nexport interface Parsed {\n organization: string;\n project: string;\n queryParams?: string;\n}\n\n/**\n * Parses a Hey API input string and extracts components.\n *\n * @param input - Hey API configuration input\n * @returns Parsed Hey API input components\n * @throws Error if the input format is invalid\n */\nexport const parseShorthand = (\n input: Input & {\n path: string;\n },\n): Parsed => {\n let organization = input.organization;\n let project = input.project;\n let queryParams: string | undefined;\n\n if (input.path) {\n const match = input.path.match(registryRegExp);\n\n if (!match) {\n throw new Error(\n `Invalid Hey API shorthand format. Expected \"organization/project?queryParams\" or \"organization/project\", received: ${input.path}`,\n );\n }\n\n organization = match[1];\n project = match[2];\n queryParams = match[3];\n }\n\n if (!organization) {\n throw new Error('The Hey API organization cannot be empty.');\n }\n\n if (!project) {\n throw new Error('The Hey API project cannot be empty.');\n }\n\n const result: Parsed = {\n organization,\n project,\n queryParams,\n };\n\n return result;\n};\n\n/**\n * Transforms a Hey API shorthand string to the corresponding API URL.\n *\n * @param input - Hey API configuration input\n * @returns The Hey API Registry URL\n */\nexport const inputToHeyApiPath = (\n input: Input & {\n path: string;\n },\n): Partial<Input> => {\n const parsed = parseShorthand(input);\n return {\n path: getRegistryUrl(\n parsed.organization,\n parsed.project,\n parsed.queryParams,\n ),\n registry: 'hey-api',\n };\n};\n","import type { Input } from '~/types/input';\n\n// Regular expression to match ReadMe API Registry input formats:\n// - @{organization}/{project}#{uuid}\n// - {uuid}\nconst registryRegExp = /^(@([\\w-]+)\\/([\\w\\-.]+)#)?([\\w-]+)$/;\n\n/**\n * Creates a full ReadMe API Registry URL.\n *\n * @param uuid - ReadMe UUID\n * @returns The full ReadMe API registry URL.\n */\nexport const getRegistryUrl = (uuid: string): string =>\n `https://dash.readme.com/api/v1/api-registry/${uuid}`;\n\nexport interface Parsed {\n organization?: string;\n project?: string;\n uuid: string;\n}\n\nconst namespace = 'readme';\n\n/**\n * Parses a ReadMe input string and extracts components.\n *\n * @param shorthand - ReadMe format string (@org/project#uuid or uuid)\n * @returns Parsed ReadMe input components\n * @throws Error if the input format is invalid\n */\nexport const parseShorthand = (shorthand: string): Parsed => {\n const match = shorthand.match(registryRegExp);\n\n if (!match) {\n throw new Error(\n `Invalid ReadMe shorthand format. Expected \"${namespace}:@organization/project#uuid\" or \"${namespace}:uuid\", received: ${namespace}:${shorthand}`,\n );\n }\n\n const [, , organization, project, uuid] = match;\n\n if (!uuid) {\n throw new Error('The ReadMe UUID cannot be empty.');\n }\n\n const result: Parsed = {\n organization,\n project,\n uuid,\n };\n\n return result;\n};\n\n/**\n * Transforms a ReadMe shorthand string to the corresponding API URL.\n *\n * @param input - ReadMe format string\n * @returns The ReadMe API Registry URL\n */\nexport const inputToReadmePath = (input: string): Partial<Input> => {\n const shorthand = input.slice(`${namespace}:`.length);\n const parsed = parseShorthand(shorthand);\n return {\n ...parsed,\n path: getRegistryUrl(parsed.uuid),\n registry: 'readme',\n };\n};\n","import type { Input } from '~/types/input';\n\n// Regular expression to match Scalar API Registry input formats:\n// - @{organization}/{project}\nconst registryRegExp = /^(@[\\w-]+)\\/([\\w.-]+)$/;\n\n/**\n * Creates a full Scalar API Registry URL.\n *\n * @param organization - Scalar organization slug\n * @param project - Scalar project slug\n * @returns The full Scalar API registry URL.\n */\nexport const getRegistryUrl = (organization: string, project: string): string =>\n `https://registry.scalar.com/${organization}/apis/${project}/latest?format=json`;\n\nexport interface Parsed {\n organization: string;\n project: string;\n}\n\nconst namespace = 'scalar';\n\n/**\n * Parses a Scalar input string and extracts components.\n *\n * @param shorthand - Scalar format string (@org/project)\n * @returns Parsed Scalar input components\n * @throws Error if the input format is invalid\n */\nexport const parseShorthand = (shorthand: string): Parsed => {\n const match = shorthand.match(registryRegExp);\n\n if (!match) {\n throw new Error(\n `Invalid Scalar shorthand format. Expected \"${namespace}:@organization/project\", received: ${namespace}:${shorthand}`,\n );\n }\n\n const [, organization, project] = match;\n\n if (!organization) {\n throw new Error('The Scalar organization cannot be empty.');\n }\n\n if (!project) {\n throw new Error('The Scalar project cannot be empty.');\n }\n\n const result: Parsed = {\n organization,\n project,\n };\n\n return result;\n};\n\n/**\n * Transforms a Scalar shorthand string to the corresponding API URL.\n *\n * @param input - Scalar format string\n * @returns The Scalar API Registry URL\n */\nexport const inputToScalarPath = (input: string): Partial<Input> => {\n const shorthand = input.slice(`${namespace}:`.length);\n const parsed = parseShorthand(shorthand);\n return {\n ...parsed,\n path: getRegistryUrl(parsed.organization, parsed.project),\n registry: 'scalar',\n };\n};\n","import type { Input } from '~/types/input';\n\nimport { heyApiRegistryBaseUrl, inputToHeyApiPath } from './heyApi';\nimport { inputToReadmePath } from './readme';\nimport { inputToScalarPath } from './scalar';\n\nexport const inputToApiRegistry = (\n input: Input & {\n path: string;\n },\n) => {\n if (input.path.startsWith('readme:')) {\n Object.assign(input, inputToReadmePath(input.path));\n return;\n }\n\n if (input.path.startsWith('scalar:')) {\n Object.assign(input, inputToScalarPath(input.path));\n return;\n }\n\n if (input.path.startsWith('.')) {\n return;\n }\n\n if (input.path.startsWith(heyApiRegistryBaseUrl)) {\n input.path = input.path.slice(heyApiRegistryBaseUrl.length + 1);\n Object.assign(input, inputToHeyApiPath(input as Input & { path: string }));\n return;\n }\n\n const parts = input.path.split('/');\n if (parts.length === 2 && parts.filter(Boolean).length === 2) {\n Object.assign(input, inputToHeyApiPath(input as Input & { path: string }));\n return;\n }\n};\n","import type { Config, UserConfig } from '~/types/config';\nimport type { Input, Watch } from '~/types/input';\nimport { inputToApiRegistry } from '~/utils/input';\nimport { heyApiRegistryBaseUrl } from '~/utils/input/heyApi';\n\nconst defaultWatch: Watch = {\n enabled: false,\n interval: 1_000,\n timeout: 60_000,\n};\n\n// watch only remote files\nconst getWatch = (input: Pick<Input, 'path' | 'watch'>): Watch => {\n let watch = { ...defaultWatch };\n\n // we cannot watch spec passed as an object\n if (typeof input.path !== 'string') {\n return watch;\n }\n\n if (typeof input.watch === 'boolean') {\n watch.enabled = input.watch;\n } else if (typeof input.watch === 'number') {\n watch.enabled = true;\n watch.interval = input.watch;\n } else if (input.watch) {\n watch = {\n ...watch,\n ...input.watch,\n };\n }\n\n return watch;\n};\n\nexport const getInput = (userConfig: UserConfig): Config['input'] => {\n const userInputs =\n userConfig.input instanceof Array ? userConfig.input : [userConfig.input];\n\n const inputs: Array<Input> = [];\n\n for (const userInput of userInputs) {\n let input: Input = {\n path: '',\n watch: defaultWatch,\n };\n\n if (typeof userInput === 'string') {\n input.path = userInput;\n } else if (\n userInput &&\n (userInput.path !== undefined || userInput.organization !== undefined)\n ) {\n // @ts-expect-error\n input = {\n ...input,\n path: heyApiRegistryBaseUrl,\n ...userInput,\n };\n\n if (input.watch !== undefined) {\n input.watch = getWatch(input);\n }\n } else {\n input = {\n ...input,\n path: userInput,\n };\n }\n\n if (typeof input.path === 'string') {\n inputToApiRegistry(input as Input & { path: string });\n }\n\n if (\n userConfig.watch !== undefined &&\n input.watch.enabled === defaultWatch.enabled &&\n input.watch.interval === defaultWatch.interval &&\n input.watch.timeout === defaultWatch.timeout\n ) {\n input.watch = getWatch({\n path: input.path,\n // @ts-expect-error\n watch: userConfig.watch,\n });\n }\n\n if (input.path) {\n inputs.push(input);\n }\n }\n\n return inputs;\n};\n","import type { Config, UserConfig } from '~/types/config';\n\nexport const getLogs = (\n userConfig: Pick<UserConfig, 'logs'> | undefined,\n): Config['logs'] => {\n let logs: Config['logs'] = {\n file: true,\n level: 'info',\n path: process.cwd(),\n };\n\n if (typeof userConfig?.logs === 'string') {\n logs.path = userConfig.logs;\n } else {\n logs = {\n ...logs,\n ...userConfig?.logs,\n };\n }\n\n return logs;\n};\n","import type { UserConfig } from '~/types/config';\n\nconst mergeObjects = (\n objA: Record<string, unknown> | undefined,\n objB: Record<string, unknown> | undefined,\n): Record<string, unknown> => {\n const a = objA || {};\n const b = objB || {};\n return {\n ...a,\n ...b,\n };\n};\n\nexport const mergeConfigs = (\n configA: UserConfig | undefined,\n configB: UserConfig | undefined,\n): UserConfig => {\n const a: Partial<UserConfig> = configA || {};\n const b: Partial<UserConfig> = configB || {};\n const merged: UserConfig = {\n ...(a as UserConfig),\n ...(b as UserConfig),\n };\n if (typeof merged.logs === 'object') {\n merged.logs = mergeObjects(\n a.logs as Record<string, unknown>,\n b.logs as Record<string, unknown>,\n );\n }\n return merged;\n};\n","type ObjectType<T> =\n Extract<T, Record<string, any>> extends never\n ? Record<string, any>\n : Extract<T, Record<string, any>>;\n\ntype NotArray<T> = T extends any[] ? never : T;\ntype NotFunction<T> = T extends (...args: any[]) => any ? never : T;\ntype PlainObject<T> = T extends object\n ? NotFunction<T> extends never\n ? never\n : NotArray<T> extends never\n ? never\n : T\n : never;\n\ntype MappersType<T> = {\n boolean: T extends boolean\n ? (value: boolean) => Partial<ObjectType<T>>\n : never;\n function: T extends (...args: any[]) => any\n ? (value: (...args: any[]) => any) => Partial<ObjectType<T>>\n : never;\n number: T extends number ? (value: number) => Partial<ObjectType<T>> : never;\n object?: PlainObject<T> extends never\n ? never\n : (\n value: Partial<PlainObject<T>>,\n defaultValue: PlainObject<T>,\n ) => Partial<ObjectType<T>>;\n string: T extends string ? (value: string) => Partial<ObjectType<T>> : never;\n} extends infer U\n ? { [K in keyof U as U[K] extends never ? never : K]: U[K] }\n : never;\n\ntype IsObjectOnly<T> = T extends Record<string, any> | undefined\n ? Extract<\n T,\n string | boolean | number | ((...args: any[]) => any)\n > extends never\n ? true\n : false\n : false;\n\nexport type ValueToObject = <\n T extends\n | undefined\n | string\n | boolean\n | number\n | ((...args: any[]) => any)\n | Record<string, any>,\n>(\n args: {\n defaultValue: ObjectType<T>;\n value: T;\n } & (IsObjectOnly<T> extends true\n ? {\n mappers?: MappersType<T>;\n }\n : {\n mappers: MappersType<T>;\n }),\n) => PlainObject<T>;\n\nconst isPlainObject = (value: unknown): value is Record<string, any> =>\n typeof value === 'object' &&\n value !== null &&\n !Array.isArray(value) &&\n typeof value !== 'function';\n\nconst mergeResult = <T>(\n result: ObjectType<T>,\n mapped: Record<string, any>,\n): ObjectType<T> => {\n for (const [key, value] of Object.entries(mapped)) {\n if (value !== undefined && value !== '') {\n (result as Record<string, any>)[key] = value;\n }\n }\n return result;\n};\n\nexport const valueToObject: ValueToObject = ({\n defaultValue,\n mappers,\n value,\n}) => {\n let result = { ...defaultValue };\n\n switch (typeof value) {\n case 'boolean':\n if (mappers && 'boolean' in mappers) {\n const mapper = mappers.boolean as (\n value: boolean,\n ) => Record<string, any>;\n result = mergeResult(result, mapper(value));\n }\n break;\n case 'function':\n if (mappers && 'function' in mappers) {\n const mapper = mappers.function as (\n value: (...args: any[]) => any,\n ) => Record<string, any>;\n result = mergeResult(result, mapper(value as (...args: any[]) => any));\n }\n break;\n case 'number':\n if (mappers && 'number' in mappers) {\n const mapper = mappers.number as (value: number) => Record<string, any>;\n result = mergeResult(result, mapper(value));\n }\n break;\n case 'string':\n if (mappers && 'string' in mappers) {\n const mapper = mappers.string as (value: string) => Record<string, any>;\n result = mergeResult(result, mapper(value));\n }\n break;\n case 'object':\n if (isPlainObject(value)) {\n if (\n mappers &&\n 'object' in mappers &&\n typeof mappers.object === 'function'\n ) {\n const mapper = mappers.object as (\n value: Record<string, any>,\n defaultValue: ObjectType<any>,\n ) => Partial<ObjectType<any>>;\n result = mergeResult(result, mapper(value, defaultValue));\n } else {\n result = mergeResult(result, value);\n }\n }\n break;\n }\n\n return result as any;\n};\n","import ts from 'typescript';\n\nimport { findTsConfigPath, loadTsConfig } from '~/generate/tsConfig';\nimport type { Config, UserConfig } from '~/types/config';\n\nimport { valueToObject } from './utils/config';\n\nexport const getOutput = (userConfig: UserConfig): Config['output'] => {\n if (userConfig.output instanceof Array) {\n throw new Error(\n 'Unexpected array of outputs in user configuration. This should have been expanded already.',\n );\n }\n\n const output = valueToObject({\n defaultValue: {\n clean: true,\n fileName: {\n case: 'preserve',\n name: '{{name}}',\n suffix: '.gen',\n },\n format: null,\n indexFile: true,\n lint: null,\n path: '',\n },\n mappers: {\n object: (fields, defaultValue) => ({\n ...fields,\n fileName: valueToObject({\n defaultValue: {\n ...(defaultValue.fileName as Extract<\n typeof defaultValue.fileName,\n Record<string, unknown>\n >),\n },\n mappers: {\n function: (name) => ({ name }),\n string: (name) => ({ name }),\n },\n value: fields.fileName,\n }),\n }),\n string: (path) => ({ path }),\n },\n value: userConfig.output,\n }) as Config['output'];\n output.tsConfig = loadTsConfig(findTsConfigPath(output.tsConfigPath));\n if (\n output.importFileExtension === undefined &&\n output.tsConfig?.options.moduleResolution ===\n ts.ModuleResolutionKind.NodeNext\n ) {\n output.importFileExtension = '.js';\n }\n if (\n output.importFileExtension &&\n !output.importFileExtension.startsWith('.')\n ) {\n output.importFileExtension = `.${output.importFileExtension}`;\n }\n return output;\n};\n","import fs from 'node:fs';\nimport path from 'node:path';\n\n/**\n * Finds and reads the project's package.json file by searching upwards from the config file location,\n * or from process.cwd() if no config file is provided.\n * This ensures we get the correct dependencies even in monorepo setups.\n *\n * @param configFilePath - The path to the configuration file (e.g., openapi-ts.config.ts)\n * @returns An object containing all project dependencies (dependencies, devDependencies, peerDependencies, optionalDependencies)\n */\nexport const getProjectDependencies = (\n configFilePath?: string,\n): Record<string, string> => {\n let currentDir = configFilePath\n ? path.dirname(configFilePath)\n : process.cwd();\n\n while (currentDir !== path.dirname(currentDir)) {\n const packageJsonPath = path.join(currentDir, 'package.json');\n\n if (fs.existsSync(packageJsonPath)) {\n try {\n const packageJson = JSON.parse(\n fs.readFileSync(packageJsonPath, 'utf8'),\n );\n return {\n ...packageJson.dependencies,\n ...packageJson.devDependencies,\n ...packageJson.peerDependencies,\n ...packageJson.optionalDependencies,\n };\n } catch {\n // Silently ignore JSON parsing errors and continue searching\n }\n }\n\n const parentDir = path.dirname(currentDir);\n if (parentDir === currentDir) {\n break;\n }\n currentDir = parentDir;\n }\n\n return {};\n};\n","import type { Config, UserConfig } from '~/types/config';\n\nimport { valueToObject } from './utils/config';\n\nexport const defaultPaginationKeywords = [\n 'after',\n 'before',\n 'cursor',\n 'offset',\n 'page',\n 'start',\n] as const;\n\nexport const getParser = (userConfig: UserConfig): Config['parser'] => {\n const parser = valueToObject({\n defaultValue: {\n hooks: {},\n pagination: {\n keywords: defaultPaginationKeywords,\n },\n transforms: {\n enums: {\n case: 'PascalCase',\n enabled: false,\n mode: 'root',\n name: '{{name}}Enum',\n },\n propertiesRequiredByDefault: false,\n readWrite: {\n enabled: true,\n requests: {\n case: 'preserve',\n name: '{{name}}Writable',\n },\n responses: {\n case: 'preserve',\n name: '{{name}}',\n },\n },\n },\n validate_EXPERIMENTAL: false,\n },\n mappers: {\n object: (fields, defaultValue) => ({\n ...fields,\n pagination: valueToObject({\n defaultValue: {\n ...(defaultValue.pagination as Extract<\n typeof defaultValue.pagination,\n Record<string, unknown>\n >),\n },\n value: fields.pagination,\n }),\n transforms: valueToObject({\n defaultValue: {\n ...(defaultValue.transforms as Extract<\n typeof defaultValue.transforms,\n Record<string, unknown>\n >),\n },\n mappers: {\n object: (fields, defaultValue) => ({\n ...fields,\n enums: valueToObject({\n defaultValue: {\n ...(defaultValue.enums as Extract<\n typeof defaultValue.enums,\n Record<string, unknown>\n >),\n enabled:\n fields.enums !== undefined\n ? Boolean(fields.enums)\n : (\n defaultValue.enums as Extract<\n typeof defaultValue.enums,\n Record<string, unknown>\n >\n ).enabled,\n },\n mappers: {\n boolean: (enabled) => ({ enabled }),\n string: (mode) => ({ mode }),\n },\n value: fields.enums,\n }),\n propertiesRequiredByDefault:\n fields.propertiesRequiredByDefault !== undefined\n ? fields.propertiesRequiredByDefault\n : defaultValue.propertiesRequiredByDefault,\n readWrite: valueToObject({\n defaultValue: {\n ...(defaultValue.readWrite as Extract<\n typeof defaultValue.readWrite,\n Record<string, unknown>\n >),\n enabled:\n fields.readWrite !== undefined\n ? Boolean(fields.readWrite)\n : (\n defaultValue.readWrite as Extract<\n typeof defaultValue.readWrite,\n Record<string, unknown>\n >\n ).enabled,\n },\n mappers: {\n boolean: (enabled) => ({ enabled }),\n object: (fields, defaultValue) => ({\n ...fields,\n requests: valueToObject({\n defaultValue: {\n ...(defaultValue.requests as Extract<\n typeof defaultValue.requests,\n Record<string, unknown>\n >),\n },\n mappers: {\n function: (name) => ({ name }),\n string: (name) => ({ name }),\n },\n value: fields.requests,\n }),\n responses: valueToObject({\n defaultValue: {\n ...(defaultValue.responses as Extract<\n typeof defaultValue.responses,\n Record<string, unknown>\n >),\n },\n mappers: {\n function: (name) => ({ name }),\n string: (name) => ({ name }),\n },\n value: fields.responses,\n }),\n }),\n },\n value: fields.readWrite,\n }),\n }),\n },\n value: fields.transforms,\n }),\n validate_EXPERIMENTAL:\n fields.validate_EXPERIMENTAL === true\n ? 'warn'\n : fields.validate_EXPERIMENTAL,\n }),\n },\n value: userConfig.parser,\n });\n return parser as Config['parser'];\n};\n","import type { Plugin } from '~/plugins';\n\nexport const definePluginConfig =\n <T extends Plugin.Types>(defaultConfig: Plugin.Config<T>) =>\n (\n userConfig?: Omit<T['config'], 'name'>,\n ): Omit<Plugin.Config<T>, 'name'> & {\n /**\n * Cast name to `any` so it doesn't throw type error in `plugins` array.\n * We could allow any `string` as plugin `name` in the object syntax, but\n * that TypeScript trick would cause all string methods to appear as\n * suggested auto completions, which is undesirable.\n */\n name: any;\n } => ({\n ...defaultConfig,\n config: {\n ...defaultConfig.config,\n ...userConfig,\n },\n });\n\n/**\n * Reusable mappers for `enabled` and `name` fields.\n */\nexport const mappers = {\n boolean: (enabled: boolean) => ({ enabled }),\n function: (name: (...args: any[]) => any) => ({ name }),\n string: (name: string) => ({ name }),\n} as const;\n","import type { StringCase } from '~/types/case';\n\nconst uppercaseRegExp = /[\\p{Lu}]/u;\nconst lowercaseRegExp = /[\\p{Ll}]/u;\nconst identifierRegExp = /([\\p{Alpha}\\p{N}_]|$)/u;\nconst separatorsRegExp = /[_.\\- `\\\\[\\]{}\\\\/]+/;\n\nconst leadingSeparatorsRegExp = new RegExp(`^${separatorsRegExp.source}`);\nconst separatorsAndIdentifierRegExp = new RegExp(\n `${separatorsRegExp.source}${identifierRegExp.source}`,\n 'gu',\n);\nconst numbersAndIdentifierRegExp = new RegExp(\n `\\\\d+${identifierRegExp.source}`,\n 'gu',\n);\n\nconst preserveCase = ({\n case: _case,\n string,\n}: {\n readonly case: StringCase;\n string: string;\n}) => {\n let isLastCharLower = false;\n let isLastCharUpper = false;\n let isLastLastCharUpper = false;\n let isLastLastCharPreserved = false;\n\n const separator =\n _case === 'snake_case' || _case === 'SCREAMING_SNAKE_CASE' ? '_' : '-';\n\n for (let index = 0; index < string.length; index++) {\n const character = string[index]!;\n isLastLastCharPreserved =\n index > 2 ? string[index - 3] === separator : true;\n\n let nextIndex = index + 1;\n let nextCharacter = string[nextIndex];\n separatorsRegExp.lastIndex = 0;\n while (nextCharacter && separatorsRegExp.test(nextCharacter)) {\n nextIndex += 1;\n nextCharacter = string[nextIndex];\n }\n const isSeparatorBeforeNextCharacter = nextIndex !== index + 1;\n\n lowercaseRegExp.lastIndex = 0;\n uppercaseRegExp.lastIndex = 0;\n if (\n uppercaseRegExp.test(character) &&\n (isLastCharLower ||\n (nextCharacter &&\n !isSeparatorBeforeNextCharacter &&\n nextCharacter !== 's' &&\n lowercaseRegExp.test(nextCharacter)))\n ) {\n // insert separator behind character\n string = `${string.slice(0, index)}${separator}${string.slice(index)}`;\n index++;\n isLastLastCharUpper = isLastCharUpper;\n isLastCharLower = false;\n isLastCharUpper = true;\n } else if (\n isLastCharUpper &&\n isLastLastCharUpper &&\n lowercaseRegExp.test(character) &&\n !isLastLastCharPreserved &&\n // naive detection of plurals\n !(\n character === 's' &&\n (!nextCharacter || nextCharacter.toLocaleLowerCase() !== nextCharacter)\n )\n ) {\n // insert separator 2 characters behind\n string = `${string.slice(0, index - 1)}${separator}${string.slice(index - 1)}`;\n isLastLastCharUpper = isLastCharUpper;\n isLastCharLower = true;\n isLastCharUpper = false;\n } else {\n const characterLower = character.toLocaleLowerCase();\n const characterUpper = character.toLocaleUpperCase();\n isLastLastCharUpper = isLastCharUpper;\n isLastCharLower =\n characterLower === character && characterUpper !== character;\n isLastCharUpper =\n characterUpper === character && characterLower !== character;\n }\n }\n\n return string;\n};\n\nexport const stringCase = ({\n case: _case,\n stripLeadingSeparators = true,\n value,\n}: {\n readonly case: StringCase | undefined;\n /**\n * If leading separators have a semantic meaning, we might not want to\n * remove them.\n */\n stripLeadingSeparators?: boolean;\n value: string;\n}): string => {\n let result = value.trim();\n\n if (!result.length) {\n return '';\n }\n\n if (!_case || _case === 'preserve') {\n return result;\n }\n\n if (result.length === 1) {\n separatorsRegExp.lastIndex = 0;\n if (separatorsRegExp.test(result)) {\n return '';\n }\n\n return _case === 'PascalCase' || _case === 'SCREAMING_SNAKE_CASE'\n ? result.toLocaleUpperCase()\n : result.toLocaleLowerCase();\n }\n\n const hasUpperCase = result !== result.toLocaleLowerCase();\n\n if (hasUpperCase) {\n result = preserveCase({ case: _case, string: result });\n }\n\n if (stripLeadingSeparators || result[0] !== value[0]) {\n result = result.replace(leadingSeparatorsRegExp, '');\n }\n\n result =\n _case === 'SCREAMING_SNAKE_CASE'\n ? result.toLocaleUpperCase()\n : result.toLocaleLowerCase();\n\n if (_case === 'PascalCase') {\n result = `${result.charAt(0).toLocaleUpperCase()}${result.slice(1)}`;\n }\n\n if (_case === 'snake_case' || _case === 'SCREAMING_SNAKE_CASE') {\n result = result.replaceAll(\n separatorsAndIdentifierRegExp,\n (match, identifier, offset) => {\n if (offset === 0 && !stripLeadingSeparators) {\n return match;\n }\n return `_${identifier}`;\n },\n );\n\n if (result[result.length - 1] === '_') {\n // strip trailing underscore\n result = result.slice(0, result.length - 1);\n }\n } else {\n separatorsAndIdentifierRegExp.lastIndex = 0;\n numbersAndIdentifierRegExp.lastIndex = 0;\n\n result = result.replaceAll(\n numbersAndIdentifierRegExp,\n (match, _, offset) => {\n if (['_', '-', '.'].includes(result.charAt(offset + match.length))) {\n return match;\n }\n\n return match.toLocaleUpperCase();\n },\n );\n\n result = result.replaceAll(\n separatorsAndIdentifierRegExp,\n (match, identifier, offset) => {\n if (\n offset === 0 &&\n !stripLeadingSeparators &&\n match[0] &&\n value.startsWith(match[0])\n ) {\n return match;\n }\n return identifier.toLocaleUpperCase();\n },\n );\n }\n\n return result;\n};\n","import { stringCase } from '~/utils/stringCase';\n\nimport type { StringCase, StringName } from '../../../types/case';\n\nexport const buildName = ({\n config,\n name,\n}: {\n config: {\n case: StringCase;\n name?: StringName;\n };\n name: string;\n}): string => {\n if (typeof config.name === 'function') {\n name = config.name(name);\n } else if (config.name) {\n const separator = config.case === 'preserve' ? '' : '-';\n name = config.name.replace('{{name}}', `${separator}${name}${separator}`);\n }\n\n return stringCase({ case: config.case, value: name });\n};\n","import type { Context } from './context';\nimport type { Pagination } from './pagination';\nimport type { IR } from './types';\n\nconst getPaginationSchema = ({\n context,\n parameter,\n}: {\n context: Context;\n parameter: IR.ParameterObject;\n}): IR.SchemaObject | undefined => {\n if (!parameter.pagination) {\n return;\n }\n\n if (parameter.pagination === true) {\n return parameter.schema;\n }\n\n let schema = parameter.schema;\n if (schema.$ref) {\n schema = context.resolveIrRef<IR.SchemaObject>(schema.$ref);\n }\n\n return schema.properties![parameter.pagination]!;\n};\n\nexport const hasParameterGroupObjectRequired = (\n parameterGroup?: Record<string, IR.ParameterObject>,\n): boolean => {\n for (const name in parameterGroup) {\n if (parameterGroup[name]!.required) {\n return true;\n }\n }\n\n return false;\n};\n\nexport const hasParametersObjectRequired = (\n parameters: IR.ParametersObject | undefined,\n): boolean => {\n if (!parameters) {\n return false;\n }\n\n if (hasParameterGroupObjectRequired(parameters.cookie)) {\n return true;\n }\n\n if (hasParameterGroupObjectRequired(parameters.header)) {\n return true;\n }\n\n if (hasParameterGroupObjectRequired(parameters.path)) {\n return true;\n }\n\n if (hasParameterGroupObjectRequired(parameters.query)) {\n return true;\n }\n\n return false;\n};\n\nexport const parameterWithPagination = ({\n context,\n parameters,\n}: {\n context: Context;\n parameters: IR.ParametersObject | undefined;\n}): Pagination | undefined => {\n if (!parameters) {\n return;\n }\n\n for (const name in parameters.cookie) {\n const parameter = parameters.cookie[name]!;\n if (parameter.pagination) {\n return {\n in: parameter.location,\n name:\n parameter.pagination === true\n ? parameter.name\n : `${parameter.name}.${parameter.pagination}`,\n schema: getPaginationSchema({ context, parameter })!,\n };\n }\n }\n\n for (const name in parameters.header) {\n const parameter = parameters.header[name]!;\n if (parameter.pagination) {\n return {\n in: parameter.location,\n name:\n parameter.pagination === true\n ? parameter.name\n : `${parameter.name}.${parameter.pagination}`,\n schema: getPaginationSchema({ context, parameter })!,\n };\n }\n }\n\n for (const name in parameters.path) {\n const parameter = parameters.path[name]!;\n if (parameter.pagination) {\n return {\n in: parameter.location,\n name:\n parameter.pagination === true\n ? parameter.name\n : `${parameter.name}.${parameter.pagination}`,\n schema: getPaginationSchema({ context, parameter })!,\n };\n }\n }\n\n for (const name in parameters.query) {\n const parameter = parameters.query[name]!;\n if (parameter.pagination) {\n return {\n in: parameter.location,\n name:\n parameter.pagination === true\n ? parameter.name\n : `${parameter.name}.${parameter.pagination}`,\n schema: getPaginationSchema({ context, parameter })!,\n };\n }\n }\n\n return;\n};\n","import type { IR } from './types';\n\n/**\n * Ensure we don't produce redundant types, e.g. string | string.\n */\nexport const deduplicateSchema = <T extends IR.SchemaObject>({\n detectFormat = true,\n schema,\n}: {\n detectFormat?: boolean;\n schema: T;\n}): T => {\n if (!schema.items) {\n return schema;\n }\n\n const uniqueItems: Array<IR.SchemaObject> = [];\n const typeIds: Array<string> = [];\n\n for (const item of schema.items) {\n // skip nested schemas for now, handle if necessary\n if ((!item.type && item.items) || schema.type === 'tuple') {\n uniqueItems.push(item);\n continue;\n }\n\n if (\n // no `type` might still include `$ref` or `const`\n !item.type ||\n item.type === 'boolean' ||\n item.type === 'integer' ||\n item.type === 'null' ||\n item.type === 'number' ||\n item.type === 'string' ||\n item.type === 'unknown' ||\n item.type === 'void'\n ) {\n // const needs namespace to handle empty string values, otherwise\n // fallback would equal an actual value and we would skip an item\n const constant = item.const !== undefined ? `const-${item.const}` : '';\n const format =\n item.format !== undefined && detectFormat\n ? `format-${item.format}`\n : '';\n\n // Include validation constraints in the type ID to avoid incorrect deduplication\n const constraints = [\n item.minLength !== undefined ? `minLength-${item.minLength}` : '',\n item.maxLength !== undefined ? `maxLength-${item.maxLength}` : '',\n item.minimum !== undefined ? `minimum-${item.minimum}` : '',\n item.maximum !== undefined ? `maximum-${item.maximum}` : '',\n item.exclusiveMinimum !== undefined\n ? `exclusiveMinimum-${item.exclusiveMinimum}`\n : '',\n item.exclusiveMaximum !== undefined\n ? `exclusiveMaximum-${item.exclusiveMaximum}`\n : '',\n item.minItems !== undefined ? `minItems-${item.minItems}` : '',\n item.maxItems !== undefined ? `maxItems-${item.maxItems}` : '',\n item.pattern !== undefined ? `pattern-${item.pattern}` : '',\n ].join('');\n\n const typeId = `${item.$ref ?? ''}${item.type ?? ''}${constant}${format}${constraints}`;\n if (!typeIds.includes(typeId)) {\n typeIds.push(typeId);\n uniqueItems.push(item);\n }\n continue;\n }\n\n uniqueItems.push(item);\n }\n\n let result = { ...schema };\n result.items = uniqueItems;\n\n if (\n result.items.length <= 1 &&\n result.type !== 'array' &&\n result.type !== 'enum' &&\n result.type !== 'tuple'\n ) {\n // bring the only item up to clean up the schema\n const liftedSchema = result.items[0];\n delete result.logicalOperator;\n delete result.items;\n result = {\n ...result,\n ...liftedSchema,\n };\n }\n\n // exclude unknown if it's the only type left\n if (result.type === 'unknown') {\n return {} as T;\n }\n\n return result;\n};\n","import type { IR } from './types';\n\n/**\n * Simply adds `items` to the schema. Also handles setting the logical operator\n * and avoids setting it for a single item or tuples.\n */\nexport const addItemsToSchema = ({\n items,\n logicalOperator = 'or',\n mutateSchemaOneItem = false,\n schema,\n}: {\n items: Array<IR.SchemaObject>;\n logicalOperator?: IR.SchemaObject['logicalOperator'];\n mutateSchemaOneItem?: boolean;\n schema: IR.SchemaObject;\n}) => {\n if (!items.length) {\n return schema;\n }\n\n if (schema.type === 'tuple') {\n schema.items = items;\n return schema;\n }\n\n if (items.length !== 1) {\n schema.items = items;\n schema.logicalOperator = logicalOperator;\n return schema;\n }\n\n if (mutateSchemaOneItem) {\n // bring composition up to avoid extraneous brackets\n schema = {\n ...schema,\n ...items[0],\n };\n return schema;\n }\n\n schema.items = items;\n return schema;\n};\n","import type { Context } from './context';\nimport type { Pagination } from './pagination';\nimport {\n hasParametersObjectRequired,\n parameterWithPagination,\n} from './parameter';\nimport { deduplicateSchema } from './schema';\nimport type { IR } from './types';\nimport { addItemsToSchema } from './utils';\n\nexport const hasOperationDataRequired = (\n operation: IR.OperationObject,\n): boolean => {\n if (hasParametersObjectRequired(operation.parameters)) {\n return true;\n }\n\n if (operation.body?.required) {\n return true;\n }\n\n return false;\n};\n\nexport const createOperationKey = ({\n method,\n path,\n}: {\n method: string;\n path: string;\n}) => `${method.toUpperCase()} ${path}`;\n\nexport const operationPagination = ({\n context,\n operation,\n}: {\n context: Context;\n operation: IR.OperationObject;\n}): Pagination | undefined => {\n const body = operation.body;\n\n if (!body || !body.pagination) {\n return parameterWithPagination({\n context,\n parameters: operation.parameters,\n });\n }\n\n if (body.pagination === true) {\n return {\n in: 'body',\n name: 'body',\n schema: body.schema,\n };\n }\n\n const schema = body.schema;\n const resolvedSchema = schema.$ref\n ? context.resolveIrRef<IR.RequestBodyObject | IR.SchemaObject>(schema.$ref)\n : schema;\n\n const finalSchema =\n 'schema' in resolvedSchema ? resolvedSchema.schema : resolvedSchema;\n const paginationProp = finalSchema?.properties?.[body.pagination];\n\n if (!paginationProp) {\n return parameterWithPagination({\n context,\n parameters: operation.parameters,\n });\n }\n\n return {\n in: 'body',\n name: body.pagination,\n schema: paginationProp,\n };\n};\n\ntype StatusGroup = '1XX' | '2XX' | '3XX' | '4XX' | '5XX' | 'default';\n\nexport const statusCodeToGroup = ({\n statusCode,\n}: {\n statusCode: string;\n}): StatusGroup => {\n switch (statusCode) {\n case '1XX':\n return '1XX';\n case '2XX':\n return '2XX';\n case '3XX':\n return '3XX';\n case '4XX':\n return '4XX';\n case '5XX':\n return '5XX';\n case 'default':\n return 'default';\n default:\n return `${statusCode[0]}XX` as StatusGroup;\n }\n};\n\ninterface OperationResponsesMap {\n /**\n * A deduplicated union of all error types. Unknown types are omitted.\n */\n error?: IR.SchemaObject;\n /**\n * An object containing a map of status codes for each error type.\n */\n errors?: IR.SchemaObject;\n /**\n * A deduplicated union of all response types. Unknown types are omitted.\n */\n response?: IR.SchemaObject;\n /**\n * An object containing a map of status codes for each response type.\n */\n responses?: IR.SchemaObject;\n}\n\nexport const operationResponsesMap = (\n operation: IR.OperationObject,\n): OperationResponsesMap => {\n const result: OperationResponsesMap = {};\n\n if (!operation.responses) {\n return result;\n }\n\n const errors: Omit<IR.SchemaObject, 'properties'> &\n Pick<Required<IR.SchemaObject>, 'properties'> = {\n properties: {},\n type: 'object',\n };\n\n const responses: Omit<IR.SchemaObject, 'properties'> &\n Pick<Required<IR.SchemaObject>, 'properties'> = {\n properties: {},\n type: 'object',\n };\n\n // store default response to be evaluated last\n let defaultResponse: IR.ResponseObject | undefined;\n\n for (const name in operation.responses) {\n const response = operation.responses[name]!;\n\n switch (statusCodeToGroup({ statusCode: name })) {\n case '1XX':\n case '3XX':\n // TODO: parser - handle informational and redirection status codes\n break;\n case '2XX':\n responses.properties[name] = response.schema;\n break;\n case '4XX':\n case '5XX':\n errors.properties[name] = response.schema;\n break;\n case 'default':\n defaultResponse = response;\n break;\n }\n }\n\n // infer default response type\n if (defaultResponse) {\n let inferred = false;\n\n // assume default is intended for success if none exists yet\n if (!Object.keys(responses.properties).length) {\n responses.properties.default = defaultResponse.schema;\n inferred = true;\n }\n\n const description = (\n defaultResponse.schema.description ?? ''\n ).toLocaleLowerCase();\n const $ref = (defaultResponse.schema.$ref ?? '').toLocaleLowerCase();\n\n // TODO: parser - this could be rewritten using regular expressions\n const successKeywords = ['success'];\n if (\n successKeywords.some(\n (keyword) => description.includes(keyword) || $ref.includes(keyword),\n )\n ) {\n responses.properties.default = defaultResponse.schema;\n inferred = true;\n }\n\n // TODO: parser - this could be rewritten using regular expressions\n const errorKeywords = ['error', 'problem'];\n if (\n errorKeywords.some(\n (keyword) => description.includes(keyword) || $ref.includes(keyword),\n )\n ) {\n errors.properties.default = defaultResponse.schema;\n inferred = true;\n }\n\n // if no keyword match, assume default schema is intended for error\n if (!inferred) {\n errors.properties.default = defaultResponse.schema;\n }\n }\n\n const errorKeys = Object.keys(errors.properties);\n if (errorKeys.length) {\n errors.required = errorKeys;\n result.errors = errors;\n\n let errorUnion = addItemsToSchema({\n items: Object.values(errors.properties),\n mutateSchemaOneItem: true,\n schema: {},\n });\n errorUnion = deduplicateSchema({ schema: errorUnion });\n if (Object.keys(errorUnion).length && errorUnion.type !== 'unknown') {\n result.error = errorUnion;\n }\n }\n\n const responseKeys = Object.keys(responses.properties);\n if (responseKeys.length) {\n responses.required = responseKeys;\n result.responses = responses;\n\n let responseUnion = addItemsToSchema({\n items: Object.values(responses.properties),\n mutateSchemaOneItem: true,\n schema: {},\n });\n responseUnion = deduplicateSchema({ schema: responseUnion });\n if (Object.keys(responseUnion).length && responseUnion.type !== 'unknown') {\n result.response = responseUnion;\n }\n }\n\n return result;\n};\n","/**\n * Sanitizes namespace identifiers so they are valid TypeScript identifiers of a certain form.\n *\n * 1: Remove any leading characters that are illegal as starting character of a typescript identifier.\n * 2: Replace illegal characters in remaining part of type name with hyphen (-).\n *\n * Step 1 should perhaps instead also replace illegal characters with underscore, or prefix with it, like sanitizeEnumName\n * does. The way this is now one could perhaps end up removing all characters, if all are illegal start characters. It\n * would be sort of a breaking change to do so, though, previously generated code might change then.\n *\n * JavaScript identifier regexp pattern retrieved from https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#identifiers\n *\n * The output of this is expected to be converted to PascalCase\n */\nexport const sanitizeNamespaceIdentifier = (name: string) =>\n name\n .replace(/^[^\\p{ID_Start}]+/u, '')\n .replace(/[^$\\u200c\\u200d\\p{ID_Continue}]/gu, '-')\n .replace(/[$+]/g, '-');\n","import type { PluginClientNames } from '~/plugins/types';\nimport type { Config } from '~/types/config';\n\nexport const getClientBaseUrlKey = (config: Config) => {\n const client = getClientPlugin(config);\n if (\n client.name === '@hey-api/client-axios' ||\n client.name === '@hey-api/client-nuxt'\n ) {\n return 'baseURL';\n }\n return 'baseUrl';\n};\n\nexport const getClientPlugin = (\n config: Config,\n): Config['plugins'][PluginClientNames] & { name: PluginClientNames } => {\n for (const name of config.pluginOrder) {\n const plugin = config.plugins[name];\n if (plugin?.tags?.includes('client')) {\n return plugin as Config['plugins'][PluginClientNames] & {\n name: PluginClientNames;\n };\n }\n }\n\n return {\n config: {\n // @ts-expect-error\n name: '',\n },\n // @ts-expect-error\n name: '',\n };\n};\n","import type { FromRefs, ToRefs } from '../types/refs';\n\n/**\n * Wraps a single value in a Ref object.\n *\n * @example\n * ```ts\n * const r = toRef(123); // { value: 123 }\n * console.log(r.value); // 123\n * ```\n */\nexport const toRef = <T>(value: T): { value: T } => ({ value });\n\n/**\n * Unwraps a single Ref object to its value.\n *\n * @example\n * ```ts\n * const r = { value: 42 };\n * const n = fromRef(r); // 42\n * console.log(n); // 42\n * ```\n */\nexport const fromRef = <T>(ref: { value: T }): T => ref.value;\n\n/**\n * Converts an object of Refs back to a plain object (unwraps all refs).\n *\n * @example\n * ```ts\n * const refs = { a: { value: 1 }, b: { value: \"x\" } };\n * const plain = fromRefs(refs); // { a: 1, b: \"x\" }\n * ```\n */\nexport const fromRefs = <T extends ToRefs<Record<string, unknown>>>(\n obj: T,\n): FromRefs<T> => {\n const result = {} as FromRefs<T>;\n for (const key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n result[key] = fromRef(obj[key]!) as (typeof result)[typeof key];\n }\n }\n return result;\n};\n\n/**\n * Converts a plain object to an object of Refs (deep, per property).\n *\n * @example\n * ```ts\n * const obj = { a: 1, b: \"x\" };\n * const refs = toRefs(obj); // { a: { value: 1 }, b: { value: \"x\" } }\n * ```\n */\nexport const toRefs = <T extends Record<string, unknown>>(\n obj: T,\n): ToRefs<T> => {\n const result = {} as ToRefs<T>;\n for (const key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n result[key] = toRef(obj[key]);\n }\n }\n return result;\n};\n","import ts from 'typescript';\n\nexport type MaybeArray<T> = T | ReadonlyArray<T>;\n\nexport interface ITsDsl<T extends ts.Node = ts.Node> {\n $render(): T;\n}\n\nexport abstract class TsDsl<T extends ts.Node = ts.Node> implements ITsDsl<T> {\n abstract $render(): T;\n\n /** Conditionally applies a callback to this builder. */\n $if<T extends TsDsl, V, R extends TsDsl = T>(\n this: T,\n value: V,\n ifTrue: (self: T, v: Exclude<V, false | null | undefined>) => R | void,\n ifFalse?: (self: T, v: Extract<V, false | null | undefined>) => R | void,\n ): R | T;\n $if<T extends TsDsl, V, R extends TsDsl = T>(\n this: T,\n value: V,\n ifTrue: (v: Exclude<V, false | null | undefined>) => R | void,\n ifFalse?: (v: Extract<V, false | null | undefined>) => R | void,\n ): R | T;\n $if<T extends TsDsl, V, R extends TsDsl = T>(\n this: T,\n value: V,\n ifTrue: () => R | void,\n ifFalse?: () => R | void,\n ): R | T;\n $if<T extends TsDsl, V, R extends TsDsl = T>(\n this: T,\n value: V,\n ifTrue: any,\n ifFalse?: any,\n ): R | T {\n if (value) {\n // Try calling with (self, value), then (value), then ()\n let result: R | void | undefined;\n try {\n result = ifTrue?.(this, value as Exclude<V, false | null | undefined>);\n } catch {\n // ignore and try other signatures\n }\n if (result === undefined) {\n try {\n result = ifTrue?.(value as Exclude<V, false | null | undefined>);\n } catch {\n // ignore and try zero-arg\n }\n }\n if (result === undefined) {\n try {\n result = ifTrue?.();\n } catch {\n // swallow\n }\n }\n return (result ?? this) as R | T;\n }\n if (ifFalse) {\n let result: R | void | undefined;\n try {\n result = ifFalse?.(this, value as Extract<V, false | null | undefined>);\n } catch {\n // ignore\n }\n if (result === undefined) {\n try {\n result = ifFalse?.(value as Extract<V, false | null | undefined>);\n } catch {\n // ignore\n }\n }\n if (result === undefined) {\n try {\n result = ifFalse?.();\n } catch {\n // ignore\n }\n }\n return (result ?? this) as R | T;\n }\n return this;\n }\n\n protected $maybeId<T extends string | ts.Expression>(\n expr: T,\n ): T extends string ? ts.Identifier : T {\n return (\n typeof expr === 'string' ? ts.factory.createIdentifier(expr) : expr\n ) as T extends string ? ts.Identifier : T;\n }\n\n protected $node<I>(value: I): NodeOfMaybe<I> {\n if (value === undefined) {\n return undefined as NodeOfMaybe<I>;\n }\n if (typeof value === 'string') {\n return ts.factory.createIdentifier(value) as NodeOfMaybe<I>;\n }\n if (value instanceof Array) {\n return value.map((item) => this.unwrap(item)) as NodeOfMaybe<I>;\n }\n return this.unwrap(value as any) as NodeOfMaybe<I>;\n }\n\n protected $type<I>(\n value: I,\n args?: ReadonlyArray<ts.TypeNode>,\n ): TypeOfMaybe<I> {\n if (value === undefined) {\n return undefined as TypeOfMaybe<I>;\n }\n if (typeof value === 'string') {\n return ts.factory.createTypeReferenceNode(value, args) as TypeOfMaybe<I>;\n }\n if (typeof value === 'boolean') {\n const literal = value\n ? ts.factory.createTrue()\n : ts.factory.createFalse();\n return ts.factory.createLiteralTypeNode(literal) as TypeOfMaybe<I>;\n }\n if (typeof value === 'number') {\n return ts.factory.createLiteralTypeNode(\n ts.factory.createNumericLiteral(value),\n ) as TypeOfMaybe<I>;\n }\n if (value instanceof Array) {\n return value.map((item) => this.$type(item, args)) as TypeOfMaybe<I>;\n }\n return this.unwrap(value as any) as TypeOfMaybe<I>;\n }\n\n protected unwrap<I>(value: I): I extends TsDsl<infer N> ? N : I {\n return (\n value instanceof TsDsl ? value.$render() : value\n ) as I extends TsDsl<infer N> ? N : I;\n }\n}\n\ntype NodeOfMaybe<I> = undefined extends I\n ? NodeOf<NonNullable<I>> | undefined\n : NodeOf<I>;\n\ntype NodeOf<I> =\n I extends ReadonlyArray<infer U>\n ? ReadonlyArray<U extends TsDsl<infer N> ? N : U>\n : I extends string\n ? ts.Expression\n : I extends TsDsl<infer N>\n ? N\n : I extends ts.Node\n ? I\n : never;\n\nexport type MaybeTsDsl<T> =\n T extends TsDsl<infer U>\n ? U | TsDsl<U>\n : T extends ts.Node\n ? T | TsDsl<T>\n : never;\n\nexport abstract class TypeTsDsl<\n T extends\n | ts.LiteralTypeNode\n | ts.QualifiedName\n | ts.TypeElement\n | ts.TypeNode\n | ts.TypeParameterDeclaration = ts.TypeNode,\n> extends TsDsl<T> {}\n\ntype TypeOfMaybe<I> = undefined extends I\n ? TypeOf<NonNullable<I>> | undefined\n : TypeOf<I>;\n\ntype TypeOf<I> =\n I extends ReadonlyArray<infer U>\n ? ReadonlyArray<TypeOf<U>>\n : I extends string\n ? ts.TypeNode\n : I extends boolean\n ? ts.LiteralTypeNode\n : I extends TsDsl<infer N>\n ? N\n : I extends ts.TypeNode\n ? I\n : never;\n","import ts from 'typescript';\n\nimport { TsDsl } from '../base';\n\nexport class IdTsDsl extends TsDsl<ts.Identifier> {\n protected name: string;\n\n constructor(name: string) {\n super();\n this.name = name;\n }\n\n $render(): ts.Identifier {\n return ts.factory.createIdentifier(this.name);\n }\n}\n","import type ts from 'typescript';\n\nimport { TsDsl } from '../base';\nimport { IdTsDsl } from '../expr/id';\n\nexport class NewlineTsDsl extends TsDsl<ts.Identifier> {\n $render(): ts.Identifier {\n return this.$node(new IdTsDsl('\\n'));\n }\n}\n","/* eslint-disable @typescript-eslint/no-unsafe-function-type */\nexport function mixin(target: Function, ...sources: ReadonlyArray<Function>) {\n const targetProto = target.prototype;\n for (const src of sources) {\n let resolvedSource = src;\n if (typeof src === 'function') {\n try {\n const candidate = src(target);\n if (candidate?.prototype) {\n resolvedSource = candidate;\n }\n } catch {\n // noop\n }\n }\n const sourceProto = resolvedSource.prototype;\n if (!sourceProto) continue;\n for (const [key, descriptor] of Object.entries(\n Object.getOwnPropertyDescriptors(sourceProto),\n )) {\n if (key === 'constructor') continue;\n if (key === '$render' && !descriptor.value.mixin) continue;\n Object.defineProperty(targetProto, key, descriptor);\n }\n }\n}\n","import type ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\n\n/**\n * Adds `.arg()` and `.args()` for managing expression arguments in call-like nodes.\n */\nexport class ArgsMixin extends TsDsl {\n protected _args?: Array<string | MaybeTsDsl<ts.Expression>>;\n\n /** Adds a single expression argument. */\n arg(arg: string | MaybeTsDsl<ts.Expression>): this {\n (this._args ??= []).push(arg);\n return this;\n }\n\n /** Adds one or more expression arguments. */\n args(...args: ReadonlyArray<string | MaybeTsDsl<ts.Expression>>): this {\n (this._args ??= []).push(...args);\n return this;\n }\n\n /** Renders the arguments into an array of `Expression`s. */\n protected $args(): ReadonlyArray<ts.Expression> {\n if (!this._args) return [];\n return this.$node(this._args).map((arg) => this.$maybeId(arg));\n }\n\n $render(): ts.Node {\n throw new Error('noop');\n }\n}\n","/* eslint-disable @typescript-eslint/no-empty-object-type, @typescript-eslint/no-unsafe-declaration-merging */\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport { mixin } from '../mixins/apply';\nimport { ArgsMixin } from '../mixins/args';\n\nexport class DecoratorTsDsl extends TsDsl<ts.Decorator> {\n protected name: string | ts.Expression;\n\n constructor(\n name: string | ts.Expression,\n ...args: ReadonlyArray<string | MaybeTsDsl<ts.Expression>>\n ) {\n super();\n this.name = name;\n this.args(...args);\n }\n\n $render(): ts.Decorator {\n const args = this.$args();\n return ts.factory.createDecorator(\n args.length\n ? ts.factory.createCallExpression(\n this.$maybeId(this.name),\n undefined,\n args,\n )\n : this.$maybeId(this.name),\n );\n }\n}\n\nexport interface DecoratorTsDsl extends ArgsMixin {}\nmixin(DecoratorTsDsl, ArgsMixin);\n","import type ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport { DecoratorTsDsl } from '../decl/decorator';\n\nexport class DecoratorMixin extends TsDsl {\n protected decorators?: Array<DecoratorTsDsl>;\n\n /** Adds a decorator (e.g. `@sealed({ in: 'root' })`). */\n decorator(\n name: string | ts.Expression,\n ...args: ReadonlyArray<string | MaybeTsDsl<ts.Expression>>\n ): this {\n (this.decorators ??= []).push(new DecoratorTsDsl(name, ...args));\n return this;\n }\n\n /** Renders the decorators into an array of `ts.Decorator`s. */\n protected $decorators(): ReadonlyArray<ts.Decorator> {\n if (!this.decorators) return [];\n return this.$node(this.decorators);\n }\n\n $render(): ts.Node {\n throw new Error('noop');\n }\n}\n","import ts from 'typescript';\n\nimport type { MaybeArray } from '../base';\nimport { TsDsl } from '../base';\nimport { IdTsDsl } from '../expr/id';\n\nexport class DocTsDsl extends TsDsl<ts.Node> {\n protected _lines: Array<string> = [];\n\n constructor(lines?: MaybeArray<string>, fn?: (d: DocTsDsl) => void) {\n super();\n if (lines) {\n if (typeof lines === 'string') {\n this.add(lines);\n } else {\n this.add(...lines);\n }\n }\n fn?.(this);\n }\n\n add(...lines: ReadonlyArray<string>): this {\n this._lines.push(...lines);\n return this;\n }\n\n apply<T extends ts.Node>(node: T): T {\n const lines = this._lines.filter((line) => Boolean(line) || line === '');\n if (!lines.length) return node;\n\n const jsdocTexts = lines.map((line) =>\n ts.factory.createJSDocText(`${line}\\n`),\n );\n\n const jsdoc = ts.factory.createJSDocComment(\n ts.factory.createNodeArray(jsdocTexts),\n undefined,\n );\n\n const cleanedJsdoc = ts\n .createPrinter()\n .printNode(\n ts.EmitHint.Unspecified,\n jsdoc,\n node.getSourceFile?.() ??\n ts.createSourceFile('', '', ts.ScriptTarget.Latest),\n )\n .replace('/*', '')\n .replace('* */', '');\n\n ts.addSyntheticLeadingComment(\n node,\n ts.SyntaxKind.MultiLineCommentTrivia,\n cleanedJsdoc,\n true,\n );\n\n return node;\n }\n\n $render(): ts.Node {\n // this class does not build a standalone node;\n // it modifies other nodes via `apply()`.\n // Return a dummy comment node for compliance.\n return this.$node(new IdTsDsl(''));\n }\n}\n","import type { ITsDsl, MaybeArray } from '../base';\nimport { DocTsDsl } from '../layout/doc';\n\nexport function DocMixin<\n TBase extends new (...args: ReadonlyArray<any>) => ITsDsl,\n>(Base: TBase) {\n const $renderBase = Base.prototype.$render;\n\n class Mixin extends Base {\n _doc?: DocTsDsl;\n\n doc(lines?: MaybeArray<string>, fn?: (d: DocTsDsl) => void): this {\n this._doc = new DocTsDsl(lines, fn);\n return this;\n }\n\n override $render(...args: Parameters<ITsDsl['$render']>) {\n const node = $renderBase.apply(this, args);\n return this._doc ? this._doc.apply(node) : node;\n }\n }\n\n // @ts-expect-error\n Mixin.prototype.$render.mixin = true;\n\n return Mixin;\n}\n\nexport type DocMixin = InstanceType<ReturnType<typeof DocMixin>>;\n","import ts from 'typescript';\n\nimport type { TsDsl } from '../base';\n\n/**\n * Creates an accessor for adding TypeScript modifiers to a parent DSL node.\n *\n * @param parent - The parent DSL node to which modifiers will be added.\n * @returns An object with a `list` method that returns the collected modifiers.\n */\nexport function createModifierAccessor<Parent extends TsDsl>(parent: Parent) {\n const modifiers: Array<ts.Modifier> = [];\n\n /**\n * Adds a modifier of the specified kind to the modifiers list if the condition is true.\n *\n * @param kind - The syntax kind of the modifier to add.\n * @param condition - Whether to add the modifier (default: true).\n * @returns The parent DSL node for chaining.\n */\n function _m(kind: ts.ModifierSyntaxKind, condition = true): Parent {\n if (condition) {\n modifiers.push(ts.factory.createModifier(kind));\n }\n return parent;\n }\n\n Object.assign(parent, { _m }); // attaches to parent\n\n /**\n * Returns the list of collected modifiers.\n *\n * @returns Array of TypeScript modifiers.\n */\n function list() {\n return modifiers;\n }\n\n return { list };\n}\n\ntype Target = object & {\n _m?(kind: ts.ModifierSyntaxKind, condition?: boolean): unknown;\n};\n\n/**\n * Mixin that adds an `abstract` modifier to a node.\n */\nexport class AbstractMixin {\n /**\n * Adds the `abstract` keyword modifier if the condition is true.\n *\n * @param condition - Whether to add the modifier (default: true).\n * @returns The target object for chaining.\n */\n abstract<T extends Target>(this: T, condition: boolean = true): T {\n return this._m!(ts.SyntaxKind.AbstractKeyword, condition) as T;\n }\n}\n\n/**\n * Mixin that adds an `async` modifier to a node.\n */\nexport class AsyncMixin {\n /**\n * Adds the `async` keyword modifier if the condition is true.\n *\n * @param condition - Whether to add the modifier (default: true).\n * @returns The target object for chaining.\n */\n async<T extends Target>(this: T, condition: boolean = true): T {\n return this._m!(ts.SyntaxKind.AsyncKeyword, condition) as T;\n }\n}\n\n/**\n * Mixin that adds a `const` modifier to a node.\n */\nexport class ConstMixin {\n /**\n * Adds the `const` keyword modifier if the condition is true.\n *\n * @param condition - Whether to add the modifier (default: true).\n * @returns The target object for chaining.\n */\n const<T extends Target>(this: T, condition: boolean = true): T {\n return this._m!(ts.SyntaxKind.ConstKeyword, condition) as T;\n }\n}\n\n/**\n * Mixin that adds a `declare` modifier to a node.\n */\nexport class DeclareMixin {\n /**\n * Adds the `declare` keyword modifier if the condition is true.\n *\n * @param condition - Whether to add the modifier (default: true).\n * @returns The target object for chaining.\n */\n declare<T extends Target>(this: T, condition: boolean = true): T {\n return this._m!(ts.SyntaxKind.DeclareKeyword, condition) as T;\n }\n}\n\n/**\n * Mixin that adds a `default` modifier to a node.\n */\nexport class DefaultMixin {\n /**\n * Adds the `default` keyword modifier if the condition is true.\n *\n * @param condition - Whether to add the modifier (default: true).\n * @returns The target object for chaining.\n */\n default<T extends Target>(this: T, condition: boolean = true): T {\n return this._m!(ts.SyntaxKind.DefaultKeyword, condition) as T;\n }\n}\n\n/**\n * Mixin that adds an `export` modifier to a node.\n */\nexport class ExportMixin {\n /**\n * Adds the `export` keyword modifier if the condition is true.\n *\n * @param condition - Whether to add the modifier (default: true).\n * @returns The target object for chaining.\n */\n export<T extends Target>(this: T, condition: boolean = true): T {\n return this._m!(ts.SyntaxKind.ExportKeyword, condition) as T;\n }\n}\n\n/**\n * Mixin that adds an `override` modifier to a node.\n */\nexport class OverrideMixin {\n /**\n * Adds the `override` keyword modifier if the condition is true.\n *\n * @param condition - Whether to add the modifier (default: true).\n * @returns The target object for chaining.\n */\n override<T extends Target>(this: T, condition: boolean = true): T {\n return this._m!(ts.SyntaxKind.OverrideKeyword, condition) as T;\n }\n}\n\n/**\n * Mixin that adds a `private` modifier to a node.\n */\nexport class PrivateMixin {\n /**\n * Adds the `private` keyword modifier if the condition is true.\n *\n * @param condition - Whether to add the modifier (default: true).\n * @returns The target object for chaining.\n */\n private<T extends Target>(this: T, condition: boolean = true): T {\n return this._m!(ts.SyntaxKind.PrivateKeyword, condition) as T;\n }\n}\n\n/**\n * Mixin that adds a `protected` modifier to a node.\n */\nexport class ProtectedMixin {\n /**\n * Adds the `protected` keyword modifier if the condition is true.\n *\n * @param condition - Whether to add the modifier (default: true).\n * @returns The target object for chaining.\n */\n protected<T extends Target>(this: T, condition: boolean = true): T {\n return this._m!(ts.SyntaxKind.ProtectedKeyword, condition) as T;\n }\n}\n\n/**\n * Mixin that adds a `public` modifier to a node.\n */\nexport class PublicMixin {\n /**\n * Adds the `public` keyword modifier if the condition is true.\n *\n * @param condition - Whether to add the modifier (default: true).\n * @returns The target object for chaining.\n */\n public<T extends Target>(this: T, condition: boolean = true): T {\n return this._m!(ts.SyntaxKind.PublicKeyword, condition) as T;\n }\n}\n\n/**\n * Mixin that adds a `readonly` modifier to a node.\n */\nexport class ReadonlyMixin {\n /**\n * Adds the `readonly` keyword modifier if the condition is true.\n *\n * @param condition - Whether to add the modifier (default: true).\n * @returns The target object for chaining.\n */\n readonly<T extends Target>(this: T, condition: boolean = true): T {\n return this._m!(ts.SyntaxKind.ReadonlyKeyword, condition) as T;\n }\n}\n\n/**\n * Mixin that adds a `static` modifier to a node.\n */\nexport class StaticMixin {\n /**\n * Adds the `static` keyword modifier if the condition is true.\n *\n * @param condition - Whether to add the modifier (default: true).\n * @returns The target object for chaining.\n */\n static<T extends Target>(this: T, condition: boolean = true): T {\n return this._m!(ts.SyntaxKind.StaticKeyword, condition) as T;\n }\n}\n","import ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TypeTsDsl } from '../base';\n\nexport class TypeParamTsDsl extends TypeTsDsl<ts.TypeParameterDeclaration> {\n protected name?: string | ts.Identifier;\n protected constraint?: string | MaybeTsDsl<TypeTsDsl> | boolean;\n protected defaultValue?: string | MaybeTsDsl<TypeTsDsl> | boolean;\n\n constructor(\n name?: string | ts.Identifier,\n fn?: (name: TypeParamTsDsl) => void,\n ) {\n super();\n this.name = name;\n fn?.(this);\n }\n\n default(value: string | MaybeTsDsl<TypeTsDsl> | boolean): this {\n this.defaultValue = value;\n return this;\n }\n\n extends(constraint: string | MaybeTsDsl<TypeTsDsl> | boolean): this {\n this.constraint = constraint;\n return this;\n }\n\n $render(): ts.TypeParameterDeclaration {\n if (!this.name) throw new Error('Missing type name');\n return ts.factory.createTypeParameterDeclaration(\n undefined,\n this.$maybeId(this.name),\n this.$type(this.constraint),\n this.$type(this.defaultValue),\n );\n }\n}\n","import type ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport { TypeParamTsDsl } from '../type/param';\n\nexport class TypeParamsMixin extends TsDsl {\n protected _generics?: Array<string | MaybeTsDsl<TypeParamTsDsl>>;\n\n /** Adds a single type parameter (e.g. `T` in `Array<T>`). */\n generic(...args: ConstructorParameters<typeof TypeParamTsDsl>): this {\n const g = new TypeParamTsDsl(...args);\n (this._generics ??= []).push(g);\n return this;\n }\n\n /** Adds type parameters (e.g. `Map<string, T>`). */\n generics(...args: ReadonlyArray<string | MaybeTsDsl<TypeParamTsDsl>>): this {\n (this._generics ??= []).push(...args);\n return this;\n }\n\n /** Returns the type parameters as an array of ts.TypeParameterDeclaration nodes. */\n protected $generics():\n | ReadonlyArray<ts.TypeParameterDeclaration>\n | undefined {\n return this._generics?.map((g) => {\n const node = typeof g === 'string' ? new TypeParamTsDsl(g) : g;\n return this.$node(node);\n });\n }\n\n $render(): ts.Node {\n throw new Error('noop');\n }\n}\n","import type ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\n\nexport class ValueMixin extends TsDsl {\n protected value?: string | MaybeTsDsl<ts.Expression>;\n\n /** Sets the initializer expression (e.g. `= expr`). */\n assign<T extends this>(this: T, expr: string | MaybeTsDsl<ts.Expression>): T {\n this.value = expr;\n return this;\n }\n\n protected $value(): ts.Expression | undefined {\n return this.$node(this.value);\n }\n\n $render(): ts.Node {\n throw new Error('noop');\n }\n}\n","import type ts from 'typescript';\n\nimport type { MaybeTsDsl, TypeTsDsl } from '../base';\nimport { TsDsl } from '../base';\n\nexport class TypeArgsMixin extends TsDsl {\n protected _generics?: Array<string | MaybeTsDsl<TypeTsDsl>>;\n\n /** Adds a single type argument (e.g. `string` in `Foo<string>`). */\n generic(arg: string | MaybeTsDsl<TypeTsDsl>): this {\n (this._generics ??= []).push(arg);\n return this;\n }\n\n /** Adds type arguments (e.g. `Map<string, number>`). */\n generics(...args: ReadonlyArray<string | MaybeTsDsl<TypeTsDsl>>): this {\n (this._generics ??= []).push(...args);\n return this;\n }\n\n /** Returns the type arguments as an array of ts.TypeNode nodes. */\n protected $generics(): ReadonlyArray<ts.TypeNode> | undefined {\n return this.$type(this._generics);\n }\n\n $render(): ts.Node {\n throw new Error('noop');\n }\n}\n","import ts from 'typescript';\n\nimport type { MaybeTsDsl, TypeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport type { TypeOfExprTsDsl } from '../expr/typeof';\nimport type { TypeExprTsDsl } from '../type/expr';\nimport type { TypeIdxTsDsl } from '../type/idx';\nimport type { TypeOperatorTsDsl } from '../type/operator';\nimport type { TypeQueryTsDsl } from '../type/query';\n\ntype TypeExprFactory = (\n nameOrFn?: string | ((t: TypeExprTsDsl) => void),\n fn?: (t: TypeExprTsDsl) => void,\n) => TypeExprTsDsl;\nlet typeExprFactory: TypeExprFactory | undefined;\n/** Registers the TypeExpr DSL factory after its module has finished evaluating. */\nexport function registerLazyAccessTypeExprFactory(\n factory: TypeExprFactory,\n): void {\n typeExprFactory = factory;\n}\n\ntype TypeIdxFactory = (\n expr: MaybeTsDsl<TypeTsDsl>,\n index: string | number | MaybeTsDsl<ts.TypeNode>,\n) => TypeIdxTsDsl;\nlet typeIdxFactory: TypeIdxFactory | undefined;\n/** Registers the TypeIdxTsDsl DSL factory after its module has finished evaluating. */\nexport function registerLazyAccessTypeIdxFactory(\n factory: TypeIdxFactory,\n): void {\n typeIdxFactory = factory;\n}\n\ntype TypeOfExprFactory = (\n expr: string | MaybeTsDsl<ts.Expression>,\n) => TypeOfExprTsDsl;\nlet typeOfExprFactory: TypeOfExprFactory | undefined;\n/** Registers the TypeOfExpr DSL factory after its module has finished evaluating. */\nexport function registerLazyAccessTypeOfExprFactory(\n factory: TypeOfExprFactory,\n): void {\n typeOfExprFactory = factory;\n}\n\ntype TypeOperatorFactory = () => TypeOperatorTsDsl;\nlet typeOperatorFactory: TypeOperatorFactory | undefined;\n/** Registers the TypeOperatorTsDsl DSL factory after its module has finished evaluating. */\nexport function registerLazyAccessTypeOperatorFactory(\n factory: TypeOperatorFactory,\n): void {\n typeOperatorFactory = factory;\n}\n\ntype TypeQueryFactory = (\n expr: string | MaybeTsDsl<TypeTsDsl | ts.Expression>,\n) => TypeQueryTsDsl;\nlet typeQueryFactory: TypeQueryFactory | undefined;\n/** Registers the TypeQuery DSL factory after its module has finished evaluating. */\nexport function registerLazyAccessTypeQueryFactory(\n factory: TypeQueryFactory,\n): void {\n typeQueryFactory = factory;\n}\n\nexport class TypeExprMixin {\n /** Creates an indexed-access type (e.g. `Foo<T>[K]`). */\n idx(\n this: MaybeTsDsl<TypeTsDsl>,\n index: string | number | MaybeTsDsl<ts.TypeNode>,\n ): TypeIdxTsDsl {\n return typeIdxFactory!(this, index);\n }\n\n /** Shorthand: builds `keyof T`. */\n keyof(this: MaybeTsDsl<TypeTsDsl>): TypeOperatorTsDsl {\n return typeOperatorFactory!().keyof(this);\n }\n\n /** Shorthand: builds `readonly T`. */\n readonly(this: MaybeTsDsl<TypeTsDsl>): TypeOperatorTsDsl {\n return typeOperatorFactory!().readonly(this);\n }\n\n /** Create a TypeExpr DSL node representing ReturnType<this>. */\n returnType(this: MaybeTsDsl<ts.Expression>): TypeExprTsDsl {\n return typeExprFactory!('ReturnType').generic(typeQueryFactory!(this));\n }\n\n /** Create a TypeOfExpr DSL node representing typeof this. */\n typeofExpr(this: MaybeTsDsl<ts.Expression>): TypeOfExprTsDsl {\n return typeOfExprFactory!(this);\n }\n\n /** Create a TypeQuery DSL node representing typeof this. */\n typeofType(this: MaybeTsDsl<TypeTsDsl | ts.Expression>): TypeQueryTsDsl {\n return typeQueryFactory!(this);\n }\n\n /**\n * Create a `typeof` operator that narrows its return type based on the receiver.\n *\n * - If `this` is a `TsDsl<ts.Expression>` → returns TypeOfExprTsDsl\n * - If `this` is a `TsDsl<TypeTsDsl>` → returns TypeQueryTsDsl\n * - If `this` is a raw ts.Expression → returns TypeOfExprTsDsl\n * - Otherwise → returns TypeQueryTsDsl\n */\n typeof<T extends MaybeTsDsl<TypeTsDsl | ts.Expression>>(\n this: T,\n ): T extends MaybeTsDsl<ts.Expression>\n ? TypeOfExprTsDsl\n : T extends MaybeTsDsl<TypeTsDsl>\n ? TypeQueryTsDsl\n : TypeQueryTsDsl | TypeOfExprTsDsl {\n if (this instanceof TsDsl) {\n const node = this.$render();\n return ts.isExpression(node)\n ? (typeOfExprFactory!(this) as any)\n : (typeQueryFactory!(this) as any);\n }\n\n if (ts.isExpression(this as any)) {\n return typeOfExprFactory!(this as ts.Expression) as any;\n }\n\n return typeQueryFactory!(this) as any;\n }\n\n /** Shorthand: builds `unique T`. */\n unique(this: MaybeTsDsl<TypeTsDsl>): TypeOperatorTsDsl {\n return typeOperatorFactory!().unique(this);\n }\n}\n","/* eslint-disable @typescript-eslint/no-empty-object-type, @typescript-eslint/no-unsafe-declaration-merging */\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TypeTsDsl } from '../base';\nimport { mixin } from '../mixins/apply';\nimport { TypeExprMixin } from '../mixins/type-expr';\n\nexport class TypeAttrTsDsl extends TypeTsDsl<ts.QualifiedName> {\n protected _base?: string | MaybeTsDsl<ts.EntityName>;\n protected right: string | ts.Identifier;\n\n constructor(\n base: string | MaybeTsDsl<ts.EntityName>,\n right: string | ts.Identifier,\n );\n constructor(right: string | ts.Identifier);\n constructor(\n baseOrRight: string | MaybeTsDsl<ts.EntityName>,\n maybeRight?: string | ts.Identifier,\n ) {\n super();\n if (maybeRight) {\n this.base(baseOrRight);\n this.right = maybeRight;\n } else {\n this.base(undefined);\n this.right = baseOrRight as string | ts.Identifier;\n }\n }\n\n base(base?: string | MaybeTsDsl<ts.EntityName>): this {\n this._base = base;\n return this;\n }\n\n $render(): ts.QualifiedName {\n if (!this._base) {\n throw new Error('TypeAttrTsDsl: missing base for qualified name');\n }\n const left = this.$node(this._base);\n if (!ts.isEntityName(left)) {\n throw new Error('TypeAttrTsDsl: base must be an EntityName');\n }\n const right = this.$maybeId(this.right);\n return ts.factory.createQualifiedName(left, right);\n }\n}\n\nexport interface TypeAttrTsDsl extends TypeExprMixin {}\nmixin(TypeAttrTsDsl, TypeExprMixin);\n","/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */\nimport ts from 'typescript';\n\nimport { TypeTsDsl } from '../base';\nimport { mixin } from '../mixins/apply';\nimport { TypeArgsMixin } from '../mixins/type-args';\nimport {\n registerLazyAccessTypeExprFactory,\n TypeExprMixin,\n} from '../mixins/type-expr';\nimport { TypeAttrTsDsl } from './attr';\n\nexport class TypeExprTsDsl extends TypeTsDsl<ts.TypeReferenceNode> {\n protected _exprInput?: string | ts.Identifier | TypeAttrTsDsl;\n\n constructor();\n constructor(fn: (t: TypeExprTsDsl) => void);\n constructor(name: string);\n constructor(name: string, fn?: (t: TypeExprTsDsl) => void);\n constructor(\n nameOrFn?: string | ((t: TypeExprTsDsl) => void),\n fn?: (t: TypeExprTsDsl) => void,\n ) {\n super();\n if (typeof nameOrFn === 'string') {\n this._exprInput = nameOrFn;\n fn?.(this);\n } else {\n nameOrFn?.(this);\n }\n }\n\n /** Accesses a nested type (e.g. `Foo.Bar`). */\n attr(right: string | ts.Identifier | TypeAttrTsDsl): this {\n this._exprInput =\n right instanceof TypeAttrTsDsl\n ? right.base(this._exprInput)\n : new TypeAttrTsDsl(this._exprInput!, right);\n return this;\n }\n\n $render(): ts.TypeReferenceNode {\n if (!this._exprInput)\n throw new Error('TypeExpr must have either an expression or an object');\n return ts.factory.createTypeReferenceNode(\n // @ts-expect-error --- need to fix types\n this.$type(this._exprInput),\n this.$generics(),\n );\n }\n}\n\nexport interface TypeExprTsDsl extends TypeArgsMixin, TypeExprMixin {}\nmixin(TypeExprTsDsl, TypeArgsMixin, TypeExprMixin);\n\nregisterLazyAccessTypeExprFactory(\n (...args) =>\n new TypeExprTsDsl(...(args as ConstructorParameters<typeof TypeExprTsDsl>)),\n);\n","/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */\nimport ts from 'typescript';\n\nimport { TsDsl, TypeTsDsl } from '../base';\nimport { mixin } from '../mixins/apply';\nimport { DecoratorMixin } from '../mixins/decorator';\nimport { DocMixin } from '../mixins/doc';\nimport {\n createModifierAccessor,\n PrivateMixin,\n ProtectedMixin,\n PublicMixin,\n ReadonlyMixin,\n StaticMixin,\n} from '../mixins/modifiers';\nimport { ValueMixin } from '../mixins/value';\nimport { TypeExprTsDsl } from '../type/expr';\n\nexport class FieldTsDsl extends TsDsl<ts.PropertyDeclaration> {\n protected modifiers = createModifierAccessor(this);\n protected name: string;\n protected _type?: TypeTsDsl;\n\n constructor(name: string, fn?: (f: FieldTsDsl) => void) {\n super();\n this.name = name;\n fn?.(this);\n }\n\n /** Sets the field type. */\n type(type: string | TypeTsDsl): this {\n this._type = type instanceof TypeTsDsl ? type : new TypeExprTsDsl(type);\n return this;\n }\n\n /** Builds the `PropertyDeclaration` node. */\n $render(): ts.PropertyDeclaration {\n return ts.factory.createPropertyDeclaration(\n [...this.$decorators(), ...this.modifiers.list()],\n this.name,\n undefined,\n this.$type(this._type),\n this.$value(),\n );\n }\n}\n\nexport interface FieldTsDsl\n extends DecoratorMixin,\n DocMixin,\n PrivateMixin,\n ProtectedMixin,\n PublicMixin,\n ReadonlyMixin,\n StaticMixin,\n ValueMixin {}\nmixin(\n FieldTsDsl,\n DecoratorMixin,\n DocMixin,\n PrivateMixin,\n ProtectedMixin,\n PublicMixin,\n ReadonlyMixin,\n StaticMixin,\n ValueMixin,\n);\n","import ts from 'typescript';\n\nimport { TsDsl } from '../base';\n\nexport class StmtTsDsl extends TsDsl<ts.Statement> {\n protected _inner: ts.Expression | ts.Statement | TsDsl<any>;\n\n constructor(inner: ts.Expression | ts.Statement | TsDsl<any>) {\n super();\n this._inner = inner;\n }\n\n $render(): ts.Statement {\n const node = this.$node(this._inner);\n return ts.isStatement(node)\n ? node\n : ts.factory.createExpressionStatement(node);\n }\n}\n","import type ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport { StmtTsDsl } from '../stmt/stmt';\n\n/**\n * Adds `.do()` for appending statements or expressions to a body.\n */\nexport class DoMixin extends TsDsl {\n protected _do?: Array<MaybeTsDsl<ts.Expression | ts.Statement>>;\n\n /** Adds one or more expressions/statements to the body. */\n do(...items: ReadonlyArray<MaybeTsDsl<ts.Expression | ts.Statement>>): this {\n (this._do ??= []).push(...items);\n return this;\n }\n\n /** Renders the collected `.do()` calls into an array of `Statement` nodes. */\n protected $do(): ReadonlyArray<ts.Statement> {\n if (!this._do) return [];\n return this.$node(this._do.map((item) => new StmtTsDsl(item)));\n }\n\n $render(): ts.Node {\n throw new Error('noop');\n }\n}\n","export class OptionalMixin {\n protected _optional?: boolean;\n\n /** Marks the node as optional when the condition is true. */\n optional<T extends this>(this: T, condition?: boolean): T {\n this._optional = arguments.length === 0 ? true : Boolean(condition);\n return this;\n }\n\n /** Marks the node as required when the condition is true. */\n required<T extends this>(this: T, condition?: boolean): T {\n this._optional = arguments.length === 0 ? false : !condition;\n return this;\n }\n}\n","import ts from 'typescript';\n\nimport { TsDsl } from './base';\n\nexport class TokenTsDsl<K extends ts.SyntaxKind = never> extends TsDsl<\n ts.Token<K>\n> {\n protected _kind?: K;\n\n /** Sets the token kind */\n kind(kind: K): this {\n this._kind = kind;\n return this;\n }\n\n /** Creates `-` */\n minus(): TokenTsDsl<ts.SyntaxKind.MinusToken> {\n return (this as TokenTsDsl<ts.SyntaxKind.MinusToken>).kind(\n ts.SyntaxKind.MinusToken,\n );\n }\n\n /** Creates `?` (optional) */\n optional(): TokenTsDsl<ts.SyntaxKind.QuestionToken> {\n return (this as TokenTsDsl<ts.SyntaxKind.QuestionToken>).kind(\n ts.SyntaxKind.QuestionToken,\n );\n }\n\n /** Creates `+` */\n plus(): TokenTsDsl<ts.SyntaxKind.PlusToken> {\n return (this as TokenTsDsl<ts.SyntaxKind.PlusToken>).kind(\n ts.SyntaxKind.PlusToken,\n );\n }\n\n /** Creates `?.` (optional chaining token) */\n questionDot(): TokenTsDsl<ts.SyntaxKind.QuestionDotToken> {\n return (this as TokenTsDsl<ts.SyntaxKind.QuestionDotToken>).kind(\n ts.SyntaxKind.QuestionDotToken,\n );\n }\n\n /** Creates `readonly` */\n readonly(): TokenTsDsl<ts.SyntaxKind.ReadonlyKeyword> {\n return (this as TokenTsDsl<ts.SyntaxKind.ReadonlyKeyword>).kind(\n ts.SyntaxKind.ReadonlyKeyword,\n );\n }\n\n /** Creates `...` (spread / rest) */\n spread(): TokenTsDsl<ts.SyntaxKind.DotDotDotToken> {\n return (this as TokenTsDsl<ts.SyntaxKind.DotDotDotToken>).kind(\n ts.SyntaxKind.DotDotDotToken,\n );\n }\n\n /** Renders the final token */\n $render(): ts.Token<K> {\n if (!this._kind) {\n throw new Error(`Token missing \\`.kind(kind)\\``);\n }\n // @ts-expect-error\n return ts.factory.createToken(this._kind);\n }\n}\n","import ts from 'typescript';\n\nimport type { MaybeArray } from '../base';\nimport { TsDsl } from '../base';\nimport { IdTsDsl } from '../expr/id';\nimport { TokenTsDsl } from '../token';\n\n/**\n * Builds binding patterns (e.g. `{ foo, bar }`, `[a, b, ...rest]`).\n */\nexport class PatternTsDsl extends TsDsl<ts.BindingName> {\n protected pattern?:\n | { kind: 'array'; values: ReadonlyArray<string> }\n | { kind: 'object'; values: Record<string, string> };\n protected _spread?: string;\n\n /** Defines an array pattern (e.g. `[a, b, c]`). */\n array(...props: ReadonlyArray<string> | [ReadonlyArray<string>]): this {\n const values =\n props[0] instanceof Array\n ? [...props[0]]\n : (props as ReadonlyArray<string>);\n this.pattern = { kind: 'array', values };\n return this;\n }\n\n /** Defines an object pattern (e.g. `{ a, b: alias }`). */\n object(\n ...props: ReadonlyArray<MaybeArray<string> | Record<string, string>>\n ): this {\n const entries: Record<string, string> = {};\n for (const p of props) {\n if (typeof p === 'string') entries[p] = p;\n else if (p instanceof Array) for (const n of p) entries[n] = n;\n else Object.assign(entries, p);\n }\n this.pattern = { kind: 'object', values: entries };\n return this;\n }\n\n /** Adds a spread element (e.g. `...rest`, `...options`, `...args`). */\n spread(name: string): this {\n this._spread = name;\n return this;\n }\n\n /** Builds and returns a BindingName (ObjectBindingPattern, ArrayBindingPattern, or Identifier). */\n $render(): ts.BindingName {\n if (!this.pattern) {\n throw new Error('PatternTsDsl requires object() or array() pattern');\n }\n\n if (this.pattern.kind === 'object') {\n const elements = Object.entries(this.pattern.values).map(\n ([key, alias]) =>\n key === alias\n ? ts.factory.createBindingElement(\n undefined,\n undefined,\n key,\n undefined,\n )\n : ts.factory.createBindingElement(undefined, key, alias, undefined),\n );\n const spread = this.createSpread();\n if (spread) elements.push(spread);\n return ts.factory.createObjectBindingPattern(elements);\n }\n\n if (this.pattern.kind === 'array') {\n const elements = this.pattern.values.map((p) =>\n ts.factory.createBindingElement(undefined, undefined, p, undefined),\n );\n const spread = this.createSpread();\n if (spread) elements.push(spread);\n return ts.factory.createArrayBindingPattern(elements);\n }\n\n throw new Error('PatternTsDsl requires object() or array() pattern');\n }\n\n private createSpread(): ts.BindingElement | undefined {\n return this._spread\n ? ts.factory.createBindingElement(\n this.$node(new TokenTsDsl().spread()),\n undefined,\n this.$node(new IdTsDsl(this._spread)),\n )\n : undefined;\n }\n}\n","import type ts from 'typescript';\n\nimport type { MaybeArray } from '../base';\nimport { TsDsl } from '../base';\nimport { PatternTsDsl } from '../decl/pattern';\n\n/**\n * Mixin providing `.array()`, `.object()`, and `.spread()` methods for defining destructuring patterns.\n */\nexport class PatternMixin extends TsDsl {\n protected pattern?: PatternTsDsl;\n\n /** Defines an array binding pattern. */\n array(...props: ReadonlyArray<string> | [ReadonlyArray<string>]): this {\n (this.pattern ??= new PatternTsDsl()).array(...props);\n return this;\n }\n\n /** Defines an object binding pattern. */\n object(\n ...props: ReadonlyArray<MaybeArray<string> | Record<string, string>>\n ): this {\n (this.pattern ??= new PatternTsDsl()).object(...props);\n return this;\n }\n\n /** Adds a spread element (e.g. `...args`, `...options`) to the pattern. */\n spread(name: string): this {\n (this.pattern ??= new PatternTsDsl()).spread(name);\n return this;\n }\n\n /** Renders the pattern into a `BindingName`. */\n protected $pattern(): ts.BindingName | undefined {\n return this.$node(this.pattern);\n }\n\n $render(): ts.Node {\n throw new Error('noop');\n }\n}\n","/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */\nimport ts from 'typescript';\n\nimport { TsDsl, TypeTsDsl } from '../base';\nimport { mixin } from '../mixins/apply';\nimport { DecoratorMixin } from '../mixins/decorator';\nimport { OptionalMixin } from '../mixins/optional';\nimport { PatternMixin } from '../mixins/pattern';\nimport { ValueMixin } from '../mixins/value';\nimport { TokenTsDsl } from '../token';\nimport { TypeExprTsDsl } from '../type/expr';\n\nexport class ParamTsDsl extends TsDsl<ts.ParameterDeclaration> {\n protected name?: string;\n protected _type?: TypeTsDsl;\n\n constructor(\n name: string | ((p: ParamTsDsl) => void),\n fn?: (p: ParamTsDsl) => void,\n ) {\n super();\n if (typeof name === 'string') {\n this.name = name;\n fn?.(this);\n } else {\n name(this);\n }\n }\n\n /** Sets the parameter type. */\n type(type: string | TypeTsDsl): this {\n this._type = type instanceof TypeTsDsl ? type : new TypeExprTsDsl(type);\n return this;\n }\n\n $render(): ts.ParameterDeclaration {\n const name = this.$pattern() ?? this.name;\n if (!name)\n throw new Error(\n 'Param must have either a name or a destructuring pattern',\n );\n return ts.factory.createParameterDeclaration(\n this.$decorators(),\n undefined,\n name,\n this._optional ? this.$node(new TokenTsDsl().optional()) : undefined,\n this.$type(this._type),\n this.$value(),\n );\n }\n}\n\nexport interface ParamTsDsl\n extends DecoratorMixin,\n OptionalMixin,\n PatternMixin,\n ValueMixin {}\nmixin(ParamTsDsl, DecoratorMixin, OptionalMixin, PatternMixin, ValueMixin);\n","import type ts from 'typescript';\n\nimport { type MaybeTsDsl, TsDsl } from '../base';\nimport { ParamTsDsl } from '../decl/param';\n\nexport class ParamMixin extends TsDsl {\n protected _params?: Array<MaybeTsDsl<ts.ParameterDeclaration>>;\n\n /** Adds a parameter. */\n param(\n name: string | ((p: ParamTsDsl) => void),\n fn?: (p: ParamTsDsl) => void,\n ): this {\n const p = new ParamTsDsl(name, fn);\n (this._params ??= []).push(p);\n return this;\n }\n\n /** Adds multiple parameters. */\n params(...params: ReadonlyArray<MaybeTsDsl<ts.ParameterDeclaration>>): this {\n (this._params ??= []).push(...params);\n return this;\n }\n\n /** Renders the parameters into an array of `ParameterDeclaration`s. */\n protected $params(): ReadonlyArray<ts.ParameterDeclaration> {\n if (!this._params) return [];\n return this.$node(this._params);\n }\n\n $render(): ts.Node {\n throw new Error('noop');\n }\n}\n","/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */\nimport ts from 'typescript';\n\nimport { TsDsl } from '../base';\nimport { mixin } from '../mixins/apply';\nimport { DecoratorMixin } from '../mixins/decorator';\nimport { DoMixin } from '../mixins/do';\nimport { DocMixin } from '../mixins/doc';\nimport {\n createModifierAccessor,\n PrivateMixin,\n ProtectedMixin,\n PublicMixin,\n} from '../mixins/modifiers';\nimport { ParamMixin } from '../mixins/param';\n\nexport class InitTsDsl extends TsDsl<ts.ConstructorDeclaration> {\n protected modifiers = createModifierAccessor(this);\n\n constructor(fn?: (i: InitTsDsl) => void) {\n super();\n fn?.(this);\n }\n\n /** Builds the `ConstructorDeclaration` node. */\n $render(): ts.ConstructorDeclaration {\n return ts.factory.createConstructorDeclaration(\n [...this.$decorators(), ...this.modifiers.list()],\n this.$params(),\n ts.factory.createBlock(this.$do(), true),\n );\n }\n}\n\nexport interface InitTsDsl\n extends DecoratorMixin,\n DoMixin,\n DocMixin,\n ParamMixin,\n PrivateMixin,\n ProtectedMixin,\n PublicMixin {}\nmixin(\n InitTsDsl,\n DecoratorMixin,\n DoMixin,\n DocMixin,\n ParamMixin,\n PrivateMixin,\n ProtectedMixin,\n PublicMixin,\n);\n","/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */\nimport ts from 'typescript';\n\nimport { TsDsl, TypeTsDsl } from '../base';\nimport { mixin } from '../mixins/apply';\nimport { DecoratorMixin } from '../mixins/decorator';\nimport { DoMixin } from '../mixins/do';\nimport { DocMixin } from '../mixins/doc';\nimport {\n AbstractMixin,\n AsyncMixin,\n createModifierAccessor,\n PrivateMixin,\n ProtectedMixin,\n PublicMixin,\n StaticMixin,\n} from '../mixins/modifiers';\nimport { OptionalMixin } from '../mixins/optional';\nimport { ParamMixin } from '../mixins/param';\nimport { TypeParamsMixin } from '../mixins/type-params';\nimport { TokenTsDsl } from '../token';\nimport { TypeExprTsDsl } from '../type/expr';\n\nexport class MethodTsDsl extends TsDsl<ts.MethodDeclaration> {\n protected modifiers = createModifierAccessor(this);\n protected name: string;\n protected _returns?: TypeTsDsl;\n\n constructor(name: string, fn?: (m: MethodTsDsl) => void) {\n super();\n this.name = name;\n fn?.(this);\n }\n\n /** Sets the return type. */\n returns(type: string | TypeTsDsl): this {\n this._returns = type instanceof TypeTsDsl ? type : new TypeExprTsDsl(type);\n return this;\n }\n\n /** Builds the `MethodDeclaration` node. */\n $render(): ts.MethodDeclaration {\n return ts.factory.createMethodDeclaration(\n [...this.$decorators(), ...this.modifiers.list()],\n undefined,\n this.name,\n this._optional ? this.$node(new TokenTsDsl().optional()) : undefined,\n this.$generics(),\n this.$params(),\n this.$type(this._returns),\n ts.factory.createBlock(this.$do(), true),\n );\n }\n}\n\nexport interface MethodTsDsl\n extends AbstractMixin,\n AsyncMixin,\n DecoratorMixin,\n DoMixin,\n DocMixin,\n OptionalMixin,\n ParamMixin,\n PrivateMixin,\n ProtectedMixin,\n PublicMixin,\n StaticMixin,\n TypeParamsMixin {}\nmixin(\n MethodTsDsl,\n AbstractMixin,\n AsyncMixin,\n DecoratorMixin,\n DoMixin,\n DocMixin,\n OptionalMixin,\n ParamMixin,\n PrivateMixin,\n ProtectedMixin,\n PublicMixin,\n StaticMixin,\n TypeParamsMixin,\n);\n","/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport { NewlineTsDsl } from '../layout/newline';\nimport { mixin } from '../mixins/apply';\nimport { DecoratorMixin } from '../mixins/decorator';\nimport { DocMixin } from '../mixins/doc';\nimport {\n AbstractMixin,\n createModifierAccessor,\n DefaultMixin,\n ExportMixin,\n} from '../mixins/modifiers';\nimport { TypeParamsMixin } from '../mixins/type-params';\nimport { FieldTsDsl } from './field';\nimport { InitTsDsl } from './init';\nimport { MethodTsDsl } from './method';\n\nexport class ClassTsDsl extends TsDsl<ts.ClassDeclaration> {\n protected heritageClauses: Array<ts.HeritageClause> = [];\n protected body: Array<MaybeTsDsl<ts.ClassElement | NewlineTsDsl>> = [];\n protected modifiers = createModifierAccessor(this);\n protected name: string;\n\n constructor(name: string) {\n super();\n this.name = name;\n }\n\n /** Adds one or more class members (fields, methods, etc.). */\n do(...items: ReadonlyArray<MaybeTsDsl<ts.ClassElement | ts.Node>>): this {\n // @ts-expect-error --- IGNORE ---\n this.body.push(...items);\n return this;\n }\n\n /** Adds a base class to extend from. */\n extends(base?: string | ts.Expression | false | null): this {\n if (!base) return this;\n this.heritageClauses.push(\n ts.factory.createHeritageClause(ts.SyntaxKind.ExtendsKeyword, [\n ts.factory.createExpressionWithTypeArguments(\n this.$maybeId(base),\n undefined,\n ),\n ]),\n );\n return this;\n }\n\n /** Adds a class field. */\n field(name: string, fn?: (f: FieldTsDsl) => void): this {\n const f = new FieldTsDsl(name, fn);\n this.body.push(f);\n return this;\n }\n\n /** Adds a class constructor. */\n init(fn?: (i: InitTsDsl) => void): this {\n const i = new InitTsDsl(fn);\n this.body.push(i);\n return this;\n }\n\n /** Adds a class method. */\n method(name: string, fn?: (m: MethodTsDsl) => void): this {\n const m = new MethodTsDsl(name, fn);\n this.body.push(m);\n return this;\n }\n\n /** Inserts an empty line between members for formatting. */\n newline(): this {\n this.body.push(new NewlineTsDsl());\n return this;\n }\n\n /** Builds the `ClassDeclaration` node. */\n $render(): ts.ClassDeclaration {\n const body = this.$node(this.body) as ReadonlyArray<ts.ClassElement>;\n return ts.factory.createClassDeclaration(\n [...this.$decorators(), ...this.modifiers.list()],\n this.name,\n this.$generics(),\n this.heritageClauses,\n body,\n );\n }\n}\n\nexport interface ClassTsDsl\n extends AbstractMixin,\n DecoratorMixin,\n DefaultMixin,\n DocMixin,\n ExportMixin,\n TypeParamsMixin {}\nmixin(\n ClassTsDsl,\n AbstractMixin,\n DecoratorMixin,\n DefaultMixin,\n DocMixin,\n ExportMixin,\n TypeParamsMixin,\n);\n","/**\n * Matches characters from the start as long as they're not allowed.\n */\nexport const illegalStartCharactersRegExp = /^[^$_\\p{ID_Start}]+/u;\n\n/**\n * Matches string if it contains only digits and optionally decimal point or\n * leading minus sign.\n */\nexport const numberRegExp = /^-?\\d+(\\.\\d+)?$/;\n\nexport const reservedBrowserGlobalsRegExp =\n /^(document|history|location|navigator|window)$/g;\n\nexport const reservedJavaScriptGlobalsRegExp =\n /^(console|Array|Date|Error|Function|JSON|Map|Math|Object|Promise|RegExp|Set|WeakMap|WeakSet)$/g;\n\nexport const reservedJavaScriptKeywordsRegExp =\n /^(arguments|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|eval|export|extends|false|finally|for|from|function|if|implements|import|in|instanceof|interface|let|new|null|package|private|protected|public|return|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)$/g;\n\nexport const reservedNodeGlobalsRegExp = /^(global|process|Buffer)$/g;\n\nexport const reservedTypeScriptKeywordsRegExp =\n /^(any|as|bigint|boolean|namespace|never|null|number|string|symbol|type|undefined|unknown|void)$/g;\n\n/**\n * Javascript identifier regexp pattern retrieved from\n * {@link} https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#identifiers\n */\nexport const validTypescriptIdentifierRegExp =\n /^[$_\\p{ID_Start}][$\\u200c\\u200d\\p{ID_Continue}]*$/u;\n","import ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\n\nexport class PrefixTsDsl extends TsDsl<ts.PrefixUnaryExpression> {\n protected _expr?: string | MaybeTsDsl<ts.Expression>;\n protected _op?: ts.PrefixUnaryOperator;\n\n constructor(\n expr?: string | MaybeTsDsl<ts.Expression>,\n op?: ts.PrefixUnaryOperator,\n ) {\n super();\n this._expr = expr;\n this._op = op;\n }\n\n /** Sets the operand (the expression being prefixed). */\n expr(expr: string | MaybeTsDsl<ts.Expression>): this {\n this._expr = expr;\n return this;\n }\n\n /** Sets the operator to MinusToken for negation (`-`). */\n neg(): this {\n this._op = ts.SyntaxKind.MinusToken;\n return this;\n }\n\n /** Sets the operator to ExclamationToken for logical NOT (`!`). */\n not(): this {\n this._op = ts.SyntaxKind.ExclamationToken;\n return this;\n }\n\n /** Sets the operator (e.g. `ts.SyntaxKind.ExclamationToken` for `!`). */\n op(op: ts.PrefixUnaryOperator): this {\n this._op = op;\n return this;\n }\n\n /** Renders the prefix unary expression node. */\n $render(): ts.PrefixUnaryExpression {\n if (!this._expr) {\n throw new Error('Missing expression for prefix unary expression');\n }\n if (!this._op) {\n throw new Error('Missing operator for prefix unary expression');\n }\n return ts.factory.createPrefixUnaryExpression(\n this._op,\n this.$node(this._expr),\n );\n }\n}\n","import type ts from 'typescript';\n\nimport type { MaybeTsDsl, TypeTsDsl } from '../base';\nimport type { AsTsDsl } from '../expr/as';\n\ntype AsFactory = (\n expr: string | MaybeTsDsl<ts.Expression>,\n type: string | TypeTsDsl,\n) => AsTsDsl;\nlet asFactory: AsFactory | undefined;\n/** Registers the As DSL factory after its module has finished evaluating. */\nexport function registerLazyAccessAsFactory(factory: AsFactory): void {\n asFactory = factory;\n}\n\nexport class AsMixin {\n /** Creates an `as` type assertion expression (e.g. `value as Type`). */\n as(\n this: string | MaybeTsDsl<ts.Expression>,\n type: string | TypeTsDsl,\n ): AsTsDsl {\n return asFactory!(this, type);\n }\n}\n","/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging, @typescript-eslint/no-empty-object-type */\nimport ts from 'typescript';\n\nimport { TsDsl } from '../base';\nimport { PrefixTsDsl } from '../expr/prefix';\nimport { mixin } from '../mixins/apply';\nimport { AsMixin } from '../mixins/as';\n\nexport class LiteralTsDsl extends TsDsl<ts.LiteralTypeNode['literal']> {\n protected value: string | number | boolean | null;\n\n constructor(value: string | number | boolean | null) {\n super();\n this.value = value;\n }\n\n $render(): ts.LiteralTypeNode['literal'] {\n if (typeof this.value === 'boolean') {\n return this.value ? ts.factory.createTrue() : ts.factory.createFalse();\n }\n if (typeof this.value === 'number') {\n const expr = ts.factory.createNumericLiteral(Math.abs(this.value));\n return this.value < 0 ? this.$node(new PrefixTsDsl(expr).neg()) : expr;\n }\n if (typeof this.value === 'string') {\n return ts.factory.createStringLiteral(this.value, true);\n }\n if (this.value === null) {\n return ts.factory.createNull();\n }\n throw new Error(`Unsupported literal: ${String(this.value)}`);\n }\n}\n\nexport interface LiteralTsDsl extends AsMixin {}\nmixin(LiteralTsDsl, AsMixin);\n","import ts from 'typescript';\n\nimport { numberRegExp, validTypescriptIdentifierRegExp } from '~/utils/regexp';\n\nimport { IdTsDsl } from '../expr/id';\nimport { LiteralTsDsl } from '../expr/literal';\n\nexport const safeMemberName = (name: string): ts.PropertyName => {\n validTypescriptIdentifierRegExp.lastIndex = 0;\n if (validTypescriptIdentifierRegExp.test(name)) {\n return new IdTsDsl(name).$render();\n }\n return new LiteralTsDsl(name).$render() as ts.StringLiteral;\n};\n\nexport const safePropName = (name: string): ts.PropertyName => {\n numberRegExp.lastIndex = 0;\n if (numberRegExp.test(name)) {\n return name.startsWith('-')\n ? (new LiteralTsDsl(name).$render() as ts.StringLiteral)\n : ts.factory.createNumericLiteral(name);\n }\n\n validTypescriptIdentifierRegExp.lastIndex = 0;\n if (validTypescriptIdentifierRegExp.test(name)) {\n return new IdTsDsl(name).$render();\n }\n\n return new LiteralTsDsl(name).$render() as ts.StringLiteral;\n};\n","/* eslint-disable @typescript-eslint/no-empty-object-type, @typescript-eslint/no-unsafe-declaration-merging */\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport { mixin } from '../mixins/apply';\nimport { DocMixin } from '../mixins/doc';\nimport { safeMemberName } from '../utils/prop';\n\ntype Value = string | number | MaybeTsDsl<ts.Expression>;\ntype ValueFn = Value | ((m: EnumMemberTsDsl) => void);\n\nexport class EnumMemberTsDsl extends TsDsl<ts.EnumMember> {\n private _name: string;\n private _value?: Value;\n\n constructor(name: string, value?: ValueFn) {\n super();\n this._name = name;\n if (typeof value === 'function') {\n value(this);\n } else {\n this.value(value);\n }\n }\n\n /** Sets the enum member value. */\n value(value?: Value): this {\n this._value = value;\n return this;\n }\n\n $render(): ts.EnumMember {\n return ts.factory.createEnumMember(\n safeMemberName(this._name),\n this.$node(this._value),\n );\n }\n}\n\nexport interface EnumMemberTsDsl extends DocMixin {}\nmixin(EnumMemberTsDsl, DocMixin);\n","/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport { mixin } from '../mixins/apply';\nimport { DocMixin } from '../mixins/doc';\nimport {\n ConstMixin,\n createModifierAccessor,\n ExportMixin,\n} from '../mixins/modifiers';\nimport { EnumMemberTsDsl } from './member';\n\ntype Value = string | number | MaybeTsDsl<ts.Expression>;\ntype ValueFn = Value | ((m: EnumMemberTsDsl) => void);\n\nexport class EnumTsDsl extends TsDsl<ts.EnumDeclaration> {\n private _members: Array<EnumMemberTsDsl> = [];\n private _name: string | ts.Identifier;\n protected modifiers = createModifierAccessor(this);\n\n constructor(name: string | ts.Identifier, fn?: (e: EnumTsDsl) => void) {\n super();\n this._name = name;\n fn?.(this);\n }\n\n /** Adds an enum member. */\n member(name: string, value?: ValueFn): this {\n const m = new EnumMemberTsDsl(name, value);\n this._members.push(m);\n return this;\n }\n\n /** Adds multiple enum members. */\n members(...members: ReadonlyArray<EnumMemberTsDsl>): this {\n this._members.push(...members);\n return this;\n }\n\n /** Renders the enum declaration. */\n $render(): ts.EnumDeclaration {\n return ts.factory.createEnumDeclaration(\n this.modifiers.list(),\n this._name,\n this.$node(this._members),\n );\n }\n}\n\nexport interface EnumTsDsl extends ConstMixin, DocMixin, ExportMixin {}\nmixin(EnumTsDsl, ConstMixin, DocMixin, ExportMixin);\n","/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */\nimport ts from 'typescript';\n\nimport { TsDsl, TypeTsDsl } from '../base';\nimport { mixin } from '../mixins/apply';\nimport { AsMixin } from '../mixins/as';\nimport { DecoratorMixin } from '../mixins/decorator';\nimport { DoMixin } from '../mixins/do';\nimport { DocMixin } from '../mixins/doc';\nimport {\n AbstractMixin,\n AsyncMixin,\n createModifierAccessor,\n PrivateMixin,\n ProtectedMixin,\n PublicMixin,\n StaticMixin,\n} from '../mixins/modifiers';\nimport { ParamMixin } from '../mixins/param';\nimport { TypeParamsMixin } from '../mixins/type-params';\nimport { TypeExprTsDsl } from '../type/expr';\n\ntype FuncMode = 'arrow' | 'decl' | 'expr';\n\nclass ImplFuncTsDsl<M extends FuncMode = 'arrow'> extends TsDsl<\n M extends 'decl'\n ? ts.FunctionDeclaration\n : M extends 'expr'\n ? ts.FunctionExpression\n : ts.ArrowFunction\n> {\n protected mode: FuncMode;\n protected modifiers = createModifierAccessor(this);\n protected name?: string;\n protected _returns?: TypeTsDsl;\n\n constructor();\n constructor(fn: (f: ImplFuncTsDsl<'arrow'>) => void);\n constructor(name: string);\n constructor(name: string, fn: (f: ImplFuncTsDsl<'decl'>) => void);\n constructor(\n nameOrFn?: string | ((f: ImplFuncTsDsl<'arrow'>) => void),\n fn?: (f: ImplFuncTsDsl<'decl'>) => void,\n ) {\n super();\n if (typeof nameOrFn === 'string') {\n this.name = nameOrFn;\n this.mode = 'decl';\n fn?.(this as unknown as FuncTsDsl<'decl'>);\n } else {\n this.mode = 'arrow';\n nameOrFn?.(this as unknown as FuncTsDsl<'arrow'>);\n }\n }\n\n /** Switches the function to an arrow function form. */\n arrow(): FuncTsDsl<'arrow'> {\n this.mode = 'arrow';\n return this as unknown as FuncTsDsl<'arrow'>;\n }\n\n /** Switches the function to a function declaration form. */\n decl(): FuncTsDsl<'decl'> {\n this.mode = 'decl';\n return this as unknown as FuncTsDsl<'decl'>;\n }\n\n /** Switches the function to a function expression form. */\n expr(): FuncTsDsl<'expr'> {\n this.mode = 'expr';\n return this as unknown as FuncTsDsl<'expr'>;\n }\n\n /** Sets the return type. */\n returns(type: string | TypeTsDsl): this {\n this._returns = type instanceof TypeTsDsl ? type : new TypeExprTsDsl(type);\n return this;\n }\n\n $render(): M extends 'decl'\n ? ts.FunctionDeclaration\n : M extends 'expr'\n ? ts.FunctionExpression\n : ts.ArrowFunction {\n if (this.mode === 'decl') {\n if (!this.name) throw new Error('Function declaration requires a name');\n return ts.factory.createFunctionDeclaration(\n [...this.$decorators(), ...this.modifiers.list()],\n undefined,\n this.name,\n this.$generics(),\n this.$params(),\n this.$type(this._returns),\n ts.factory.createBlock(this.$do(), true),\n ) as any;\n }\n\n if (this.mode === 'expr') {\n return ts.factory.createFunctionExpression(\n this.modifiers.list(),\n undefined,\n this.name,\n this.$generics(),\n this.$params(),\n this.$type(this._returns),\n ts.factory.createBlock(this.$do(), true),\n ) as any;\n }\n\n const body = this.$do();\n const exprBody =\n body.length === 1 && ts.isReturnStatement(body[0]!)\n ? (body[0].expression ?? ts.factory.createBlock(body, true))\n : ts.factory.createBlock(body, true);\n\n return ts.factory.createArrowFunction(\n this.modifiers.list(),\n this.$generics(),\n this.$params(),\n this.$type(this._returns),\n undefined,\n exprBody,\n ) as any;\n }\n}\n\ninterface ImplFuncTsDsl\n extends AbstractMixin,\n AsMixin,\n AsyncMixin,\n DecoratorMixin,\n DoMixin,\n DocMixin,\n ParamMixin,\n PrivateMixin,\n ProtectedMixin,\n PublicMixin,\n StaticMixin,\n TypeParamsMixin {}\nmixin(\n ImplFuncTsDsl,\n AbstractMixin,\n AsMixin,\n AsyncMixin,\n DecoratorMixin,\n DoMixin,\n DocMixin,\n ParamMixin,\n PrivateMixin,\n ProtectedMixin,\n PublicMixin,\n StaticMixin,\n TypeParamsMixin,\n);\n\nexport const FuncTsDsl = ImplFuncTsDsl as {\n new (): FuncTsDsl<'arrow'>;\n new (fn: (f: FuncTsDsl<'arrow'>) => void): FuncTsDsl<'arrow'>;\n new (name: string): FuncTsDsl<'decl'>;\n new (name: string, fn: (f: FuncTsDsl<'decl'>) => void): FuncTsDsl<'decl'>;\n} & typeof ImplFuncTsDsl;\nexport type FuncTsDsl<M extends FuncMode = 'arrow'> = ImplFuncTsDsl<M>;\n","/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */\nimport ts from 'typescript';\n\nimport { TsDsl } from '../base';\nimport { mixin } from '../mixins/apply';\nimport { DecoratorMixin } from '../mixins/decorator';\nimport { DoMixin } from '../mixins/do';\nimport { DocMixin } from '../mixins/doc';\nimport type { AsyncMixin } from '../mixins/modifiers';\nimport {\n AbstractMixin,\n createModifierAccessor,\n PrivateMixin,\n ProtectedMixin,\n PublicMixin,\n StaticMixin,\n} from '../mixins/modifiers';\nimport { ParamMixin } from '../mixins/param';\n\nexport class GetterTsDsl extends TsDsl<ts.GetAccessorDeclaration> {\n protected modifiers = createModifierAccessor(this);\n protected name: string | ts.PropertyName;\n\n constructor(name: string | ts.PropertyName, fn?: (g: GetterTsDsl) => void) {\n super();\n this.name = name;\n fn?.(this);\n }\n\n $render(): ts.GetAccessorDeclaration {\n return ts.factory.createGetAccessorDeclaration(\n [...this.$decorators(), ...this.modifiers.list()],\n this.name,\n this.$params(),\n undefined,\n ts.factory.createBlock(this.$do(), true),\n );\n }\n}\n\nexport interface GetterTsDsl\n extends AbstractMixin,\n AsyncMixin,\n DecoratorMixin,\n DoMixin,\n DocMixin,\n ParamMixin,\n PrivateMixin,\n ProtectedMixin,\n PublicMixin,\n StaticMixin {}\nmixin(\n GetterTsDsl,\n AbstractMixin,\n DecoratorMixin,\n DoMixin,\n DocMixin,\n ParamMixin,\n PrivateMixin,\n ProtectedMixin,\n PublicMixin,\n StaticMixin,\n);\n","/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */\nimport ts from 'typescript';\n\nimport { TsDsl } from '../base';\nimport { mixin } from '../mixins/apply';\nimport { DecoratorMixin } from '../mixins/decorator';\nimport { DoMixin } from '../mixins/do';\nimport { DocMixin } from '../mixins/doc';\nimport type { AsyncMixin } from '../mixins/modifiers';\nimport {\n AbstractMixin,\n createModifierAccessor,\n PrivateMixin,\n ProtectedMixin,\n PublicMixin,\n StaticMixin,\n} from '../mixins/modifiers';\nimport { ParamMixin } from '../mixins/param';\n\nexport class SetterTsDsl extends TsDsl<ts.SetAccessorDeclaration> {\n protected modifiers = createModifierAccessor(this);\n protected name: string | ts.PropertyName;\n\n constructor(name: string | ts.PropertyName, fn?: (s: SetterTsDsl) => void) {\n super();\n this.name = name;\n fn?.(this);\n }\n\n $render(): ts.SetAccessorDeclaration {\n return ts.factory.createSetAccessorDeclaration(\n [...this.$decorators(), ...this.modifiers.list()],\n this.name,\n this.$params(),\n ts.factory.createBlock(this.$do(), true),\n );\n }\n}\n\nexport interface SetterTsDsl\n extends AbstractMixin,\n AsyncMixin,\n DecoratorMixin,\n DoMixin,\n DocMixin,\n ParamMixin,\n PrivateMixin,\n ProtectedMixin,\n PublicMixin,\n StaticMixin {}\nmixin(\n SetterTsDsl,\n AbstractMixin,\n DecoratorMixin,\n DoMixin,\n DocMixin,\n ParamMixin,\n PrivateMixin,\n ProtectedMixin,\n PublicMixin,\n StaticMixin,\n);\n","export class LayoutMixin {\n protected static readonly DEFAULT_THRESHOLD = 3;\n protected layout: boolean | number | undefined;\n\n /** Sets automatic line output with optional threshold (default: 3). */\n auto(threshold: number = LayoutMixin.DEFAULT_THRESHOLD): this {\n this.layout = threshold;\n return this;\n }\n\n /** Sets single line output. */\n inline(): this {\n this.layout = false;\n return this;\n }\n\n /** Sets multi line output. */\n pretty(): this {\n this.layout = true;\n return this;\n }\n\n /** Computes whether output should be multiline based on layout setting and element count. */\n protected $multiline(count: number): boolean {\n if (this.layout === undefined) {\n this.layout = LayoutMixin.DEFAULT_THRESHOLD;\n }\n return typeof this.layout === 'number' ? count >= this.layout : this.layout;\n }\n}\n","/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport { mixin } from '../mixins/apply';\nimport { AsMixin } from '../mixins/as';\nimport { LayoutMixin } from '../mixins/layout';\nimport { LiteralTsDsl } from './literal';\n\nexport class ArrayTsDsl extends TsDsl<ts.ArrayLiteralExpression> {\n protected _elements: Array<\n | { expr: MaybeTsDsl<ts.Expression>; kind: 'element' }\n | { expr: MaybeTsDsl<ts.Expression>; kind: 'spread' }\n > = [];\n\n constructor(\n ...exprs: Array<string | number | boolean | MaybeTsDsl<ts.Expression>>\n ) {\n super();\n this.elements(...exprs);\n }\n\n /** Adds a single array element. */\n element(expr: string | number | boolean | MaybeTsDsl<ts.Expression>): this {\n const node =\n typeof expr === 'string' ||\n typeof expr === 'number' ||\n typeof expr === 'boolean'\n ? new LiteralTsDsl(expr)\n : expr;\n this._elements.push({ expr: node, kind: 'element' });\n return this;\n }\n\n /** Adds multiple array elements. */\n elements(\n ...exprs: ReadonlyArray<\n string | number | boolean | MaybeTsDsl<ts.Expression>\n >\n ): this {\n for (const expr of exprs) this.element(expr);\n return this;\n }\n\n /** Adds a spread element (`...expr`). */\n spread(expr: MaybeTsDsl<ts.Expression>): this {\n this._elements.push({ expr, kind: 'spread' });\n return this;\n }\n\n $render(): ts.ArrayLiteralExpression {\n const elements = this._elements.map((item) => {\n const node = this.$node(item.expr);\n return item.kind === 'spread'\n ? ts.factory.createSpreadElement(node)\n : node;\n });\n\n return ts.factory.createArrayLiteralExpression(\n elements,\n this.$multiline(this._elements.length),\n );\n }\n}\n\nexport interface ArrayTsDsl extends AsMixin, LayoutMixin {}\nmixin(ArrayTsDsl, AsMixin, LayoutMixin);\n","import type ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport type { AttrTsDsl } from '../expr/attr';\nimport type { AwaitTsDsl } from '../expr/await';\nimport type { CallTsDsl } from '../expr/call';\nimport type { ReturnTsDsl } from '../stmt/return';\n\ntype AttrFactory = (\n expr: string | MaybeTsDsl<ts.Expression>,\n name: string | ts.MemberName | number,\n) => AttrTsDsl;\nlet attrFactory: AttrFactory | undefined;\n/** Registers the Attr DSL factory after its module has finished evaluating. */\nexport function registerLazyAccessAttrFactory(factory: AttrFactory): void {\n attrFactory = factory;\n}\n\ntype AwaitFactory = (expr: string | MaybeTsDsl<ts.Expression>) => AwaitTsDsl;\nlet awaitFactory: AwaitFactory | undefined;\n/** Registers the Await DSL factory after its module has finished evaluating. */\nexport function registerLazyAccessAwaitFactory(factory: AwaitFactory): void {\n awaitFactory = factory;\n}\n\ntype CallFactory = (\n expr: string | MaybeTsDsl<ts.Expression>,\n args: ReadonlyArray<string | MaybeTsDsl<ts.Expression> | undefined>,\n) => CallTsDsl;\nlet callFactory: CallFactory | undefined;\n/** Registers the Call DSL factory after its module has finished evaluating. */\nexport function registerLazyAccessCallFactory(factory: CallFactory): void {\n callFactory = factory;\n}\n\ntype ReturnFactory = (expr: string | MaybeTsDsl<ts.Expression>) => ReturnTsDsl;\nlet returnFactory: ReturnFactory | undefined;\n/** Registers the Return DSL factory after its module has finished evaluating. */\nexport function registerLazyAccessReturnFactory(factory: ReturnFactory): void {\n returnFactory = factory;\n}\n\nexport class ExprMixin {\n /** Accesses a property on the current expression (e.g. `this.foo`). */\n attr(\n this: string | MaybeTsDsl<ts.Expression>,\n name: string | ts.MemberName | number,\n ): AttrTsDsl {\n return attrFactory!(this, name);\n }\n\n /** Awaits the current expression (e.g. `await expr`). */\n await(this: string | MaybeTsDsl<ts.Expression>): AwaitTsDsl {\n return awaitFactory!(this);\n }\n\n /** Calls the current expression (e.g. `fn(arg1, arg2)`). */\n call(\n this: string | MaybeTsDsl<ts.Expression>,\n ...args: ReadonlyArray<string | MaybeTsDsl<ts.Expression> | undefined>\n ): CallTsDsl {\n return callFactory!(this, args);\n }\n\n /** Produces a `return` statement returning the current expression. */\n return(this: string | MaybeTsDsl<ts.Expression>): ReturnTsDsl {\n return returnFactory!(this);\n }\n}\n","/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl, TypeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport { mixin } from '../mixins/apply';\nimport { AsMixin, registerLazyAccessAsFactory } from '../mixins/as';\nimport { ExprMixin } from '../mixins/expr';\n\nexport class AsTsDsl extends TsDsl<ts.AsExpression> {\n protected expr: string | MaybeTsDsl<ts.Expression>;\n protected type: string | TypeTsDsl;\n\n constructor(\n expr: string | MaybeTsDsl<ts.Expression>,\n type: string | TypeTsDsl,\n ) {\n super();\n this.expr = expr;\n this.type = type;\n }\n\n $render() {\n return ts.factory.createAsExpression(\n this.$node(this.expr),\n this.$type(this.type),\n );\n }\n}\n\nexport interface AsTsDsl extends AsMixin, ExprMixin {}\nmixin(AsTsDsl, AsMixin, ExprMixin);\n\nregisterLazyAccessAsFactory((...args) => new AsTsDsl(...args));\n","/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport { mixin } from '../mixins/apply';\nimport { AsMixin } from '../mixins/as';\nimport { ExprMixin } from '../mixins/expr';\n\ntype Expr = string | MaybeTsDsl<ts.Expression>;\ntype Op = Operator | ts.BinaryOperator;\ntype Operator =\n | '!='\n | '!=='\n | '&&'\n | '*'\n | '+'\n | '-'\n | '/'\n | '<'\n | '<='\n | '='\n | '=='\n | '==='\n | '>'\n | '>='\n | '??'\n | '||';\n\nexport class BinaryTsDsl extends TsDsl<ts.BinaryExpression> {\n protected _base: Expr;\n protected _expr?: Expr;\n protected _op?: Op;\n\n constructor(base: Expr, op?: Op, expr?: Expr) {\n super();\n this._base = base;\n this._op = op;\n this._expr = expr;\n }\n\n /** Logical AND — `this && expr` */\n and(expr: Expr): this {\n return this.opAndExpr('&&', expr);\n }\n\n /** Creates an assignment expression (e.g. `this = expr`). */\n assign(expr: Expr): this {\n return this.opAndExpr('=', expr);\n }\n\n /** Nullish coalescing — `this ?? expr` */\n coalesce(expr: Expr): this {\n return this.opAndExpr('??', expr);\n }\n\n /** Division — `this / expr` */\n div(expr: Expr): this {\n return this.opAndExpr('/', expr);\n }\n\n /** Strict equality — `this === expr` */\n eq(expr: Expr): this {\n return this.opAndExpr('===', expr);\n }\n\n /** Greater than — `this > expr` */\n gt(expr: Expr): this {\n return this.opAndExpr('>', expr);\n }\n\n /** Greater than or equal — `this >= expr` */\n gte(expr: Expr): this {\n return this.opAndExpr('>=', expr);\n }\n\n /** Loose equality — `this == expr` */\n looseEq(expr: Expr): this {\n return this.opAndExpr('==', expr);\n }\n\n /** Loose inequality — `this != expr` */\n looseNeq(expr: Expr): this {\n return this.opAndExpr('!=', expr);\n }\n\n /** Less than — `this < expr` */\n lt(expr: Expr): this {\n return this.opAndExpr('<', expr);\n }\n\n /** Less than or equal — `this <= expr` */\n lte(expr: Expr): this {\n return this.opAndExpr('<=', expr);\n }\n\n /** Subtraction — `this - expr` */\n minus(expr: Expr): this {\n return this.opAndExpr('-', expr);\n }\n\n /** Strict inequality — `this !== expr` */\n neq(expr: Expr): this {\n return this.opAndExpr('!==', expr);\n }\n\n /** Logical OR — `this || expr` */\n or(expr: Expr): this {\n return this.opAndExpr('||', expr);\n }\n\n /** Addition — `this + expr` */\n plus(expr: Expr): this {\n return this.opAndExpr('+', expr);\n }\n\n /** Multiplication — `this * expr` */\n times(expr: Expr): this {\n return this.opAndExpr('*', expr);\n }\n\n $render(): ts.BinaryExpression {\n if (!this._op) {\n throw new Error('BinaryTsDsl: missing operator');\n }\n if (this._expr === undefined) {\n throw new Error('BinaryTsDsl: missing right-hand expression');\n }\n const base = this.$node(this._base);\n const expr = this.$node(this._expr);\n const operator =\n typeof this._op === 'string' ? this.opToToken(this._op) : this._op;\n return ts.factory.createBinaryExpression(base, operator, expr);\n }\n\n /** Sets the binary operator and right-hand operand for this expression. */\n private opAndExpr(op: Op, expr: Expr): this {\n this._expr = expr;\n this._op = op;\n return this;\n }\n\n private opToToken(op: Operator): ts.BinaryOperator | ts.BinaryOperatorToken {\n const tokenMap: Record<Operator, ts.BinaryOperator> = {\n '!=': ts.SyntaxKind.ExclamationEqualsToken,\n '!==': ts.SyntaxKind.ExclamationEqualsEqualsToken,\n '&&': ts.SyntaxKind.AmpersandAmpersandToken,\n '*': ts.SyntaxKind.AsteriskToken,\n '+': ts.SyntaxKind.PlusToken,\n '-': ts.SyntaxKind.MinusToken,\n '/': ts.SyntaxKind.SlashToken,\n '<': ts.SyntaxKind.LessThanToken,\n '<=': ts.SyntaxKind.LessThanEqualsToken,\n '=': ts.SyntaxKind.EqualsToken,\n '==': ts.SyntaxKind.EqualsEqualsToken,\n '===': ts.SyntaxKind.EqualsEqualsEqualsToken,\n '>': ts.SyntaxKind.GreaterThanToken,\n '>=': ts.SyntaxKind.GreaterThanEqualsToken,\n '??': ts.SyntaxKind.QuestionQuestionToken,\n '||': ts.SyntaxKind.BarBarToken,\n };\n const token = tokenMap[op];\n if (!token) {\n throw new Error(`Unsupported operator: ${op}`);\n }\n return token;\n }\n}\n\nexport interface BinaryTsDsl extends AsMixin, ExprMixin {}\nmixin(BinaryTsDsl, AsMixin, ExprMixin);\n","import type ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { BinaryTsDsl } from '../expr/binary';\n\ntype This = string | MaybeTsDsl<ts.Expression>;\ntype Expr = string | MaybeTsDsl<ts.Expression>;\n\nexport class OperatorMixin {\n /** Logical AND — `this && expr` */\n and(this: This, expr: Expr): BinaryTsDsl {\n return new BinaryTsDsl(this).and(expr);\n }\n\n /** Creates an assignment expression (e.g. `this = expr`). */\n assign(this: This, expr: Expr): BinaryTsDsl {\n return new BinaryTsDsl(this, '=', expr);\n }\n\n /** Nullish coalescing — `this ?? expr` */\n coalesce(this: This, expr: Expr): BinaryTsDsl {\n return new BinaryTsDsl(this).coalesce(expr);\n }\n\n /** Division — `this / expr` */\n div(this: This, expr: Expr): BinaryTsDsl {\n return new BinaryTsDsl(this).div(expr);\n }\n\n /** Strict equality — `this === expr` */\n eq(this: This, expr: Expr): BinaryTsDsl {\n return new BinaryTsDsl(this).eq(expr);\n }\n\n /** Greater than — `this > expr` */\n gt(this: This, expr: Expr): BinaryTsDsl {\n return new BinaryTsDsl(this).gt(expr);\n }\n\n /** Greater than or equal — `this >= expr` */\n gte(this: This, expr: Expr): BinaryTsDsl {\n return new BinaryTsDsl(this).gte(expr);\n }\n\n /** Loose equality — `this == expr` */\n looseEq(this: This, expr: Expr): BinaryTsDsl {\n return new BinaryTsDsl(this).looseEq(expr);\n }\n\n /** Loose inequality — `this != expr` */\n looseNeq(this: This, expr: Expr): BinaryTsDsl {\n return new BinaryTsDsl(this).looseNeq(expr);\n }\n\n /** Less than — `this < expr` */\n lt(this: This, expr: Expr): BinaryTsDsl {\n return new BinaryTsDsl(this).lt(expr);\n }\n\n /** Less than or equal — `this <= expr` */\n lte(this: This, expr: Expr): BinaryTsDsl {\n return new BinaryTsDsl(this).lte(expr);\n }\n\n /** Subtraction — `this - expr` */\n minus(this: This, expr: Expr): BinaryTsDsl {\n return new BinaryTsDsl(this).minus(expr);\n }\n\n /** Strict inequality — `this !== expr` */\n neq(this: This, expr: Expr): BinaryTsDsl {\n return new BinaryTsDsl(this).neq(expr);\n }\n\n /** Logical OR — `this || expr` */\n or(this: This, expr: Expr): BinaryTsDsl {\n return new BinaryTsDsl(this).or(expr);\n }\n\n /** Addition — `this + expr` */\n plus(this: This, expr: Expr): BinaryTsDsl {\n return new BinaryTsDsl(this).plus(expr);\n }\n\n /** Multiplication — `this * expr` */\n times(this: This, expr: Expr): BinaryTsDsl {\n return new BinaryTsDsl(this).times(expr);\n }\n}\n","/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */\nimport ts from 'typescript';\n\nimport { validTypescriptIdentifierRegExp } from '~/utils/regexp';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport { mixin } from '../mixins/apply';\nimport { AsMixin } from '../mixins/as';\nimport { ExprMixin, registerLazyAccessAttrFactory } from '../mixins/expr';\nimport { OperatorMixin } from '../mixins/operator';\nimport { OptionalMixin } from '../mixins/optional';\nimport { TokenTsDsl } from '../token';\nimport { LiteralTsDsl } from './literal';\n\nexport class AttrTsDsl extends TsDsl<\n ts.PropertyAccessExpression | ts.ElementAccessExpression\n> {\n protected left: string | MaybeTsDsl<ts.Expression>;\n protected right: string | ts.MemberName | number;\n\n constructor(\n left: string | MaybeTsDsl<ts.Expression>,\n right: string | ts.MemberName | number,\n ) {\n super();\n this.left = left;\n this.right = right;\n }\n\n $render(): ts.PropertyAccessExpression | ts.ElementAccessExpression {\n const leftNode = this.$node(this.left);\n validTypescriptIdentifierRegExp.lastIndex = 0;\n if (\n typeof this.right === 'number' ||\n (typeof this.right === 'string' &&\n !validTypescriptIdentifierRegExp.test(this.right))\n ) {\n if (this._optional) {\n return ts.factory.createElementAccessChain(\n leftNode,\n this.$node(new TokenTsDsl().questionDot()),\n this.$node(new LiteralTsDsl(this.right)),\n );\n }\n return ts.factory.createElementAccessExpression(\n leftNode,\n this.$node(new LiteralTsDsl(this.right)),\n );\n }\n if (this._optional) {\n return ts.factory.createPropertyAccessChain(\n leftNode,\n this.$node(new TokenTsDsl().questionDot()),\n this.$maybeId(this.right),\n );\n }\n return ts.factory.createPropertyAccessExpression(\n leftNode,\n this.$maybeId(this.right),\n );\n }\n}\n\nexport interface AttrTsDsl\n extends AsMixin,\n ExprMixin,\n OperatorMixin,\n OptionalMixin {}\nmixin(AttrTsDsl, AsMixin, ExprMixin, OperatorMixin, OptionalMixin);\n\nregisterLazyAccessAttrFactory((...args) => new AttrTsDsl(...args));\n","/* eslint-disable @typescript-eslint/no-empty-object-type, @typescript-eslint/no-unsafe-declaration-merging */\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport { mixin } from '../mixins/apply';\nimport { ExprMixin, registerLazyAccessAwaitFactory } from '../mixins/expr';\n\nexport class AwaitTsDsl extends TsDsl<ts.AwaitExpression> {\n protected _awaitExpr: string | MaybeTsDsl<ts.Expression>;\n\n constructor(expr: string | MaybeTsDsl<ts.Expression>) {\n super();\n this._awaitExpr = expr;\n }\n\n $render(): ts.AwaitExpression {\n return ts.factory.createAwaitExpression(this.$node(this._awaitExpr));\n }\n}\n\nexport interface AwaitTsDsl extends ExprMixin {}\nmixin(AwaitTsDsl, ExprMixin);\n\nregisterLazyAccessAwaitFactory((...args) => new AwaitTsDsl(...args));\n","/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport { mixin } from '../mixins/apply';\nimport { ArgsMixin } from '../mixins/args';\nimport { AsMixin } from '../mixins/as';\nimport { ExprMixin, registerLazyAccessCallFactory } from '../mixins/expr';\nimport { TypeArgsMixin } from '../mixins/type-args';\n\nexport class CallTsDsl extends TsDsl<ts.CallExpression> {\n protected _callee: string | MaybeTsDsl<ts.Expression>;\n\n constructor(\n callee: string | MaybeTsDsl<ts.Expression>,\n ...args: ReadonlyArray<string | MaybeTsDsl<ts.Expression> | undefined>\n ) {\n super();\n this._callee = callee;\n this.args(\n ...args.filter((a): a is NonNullable<typeof a> => a !== undefined),\n );\n }\n\n $render(): ts.CallExpression {\n return ts.factory.createCallExpression(\n this.$node(this._callee),\n this.$generics(),\n this.$args(),\n );\n }\n}\n\nexport interface CallTsDsl\n extends ArgsMixin,\n AsMixin,\n ExprMixin,\n TypeArgsMixin {}\nmixin(CallTsDsl, ArgsMixin, AsMixin, ExprMixin, TypeArgsMixin);\n\nregisterLazyAccessCallFactory((expr, args) => new CallTsDsl(expr, ...args));\n","/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */\nimport type ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport { mixin } from '../mixins/apply';\nimport { AsMixin } from '../mixins/as';\nimport { ExprMixin } from '../mixins/expr';\nimport { OperatorMixin } from '../mixins/operator';\nimport { TypeExprMixin } from '../mixins/type-expr';\n\nexport class ExprTsDsl extends TsDsl<ts.Expression> {\n protected _exprInput: string | MaybeTsDsl<ts.Expression>;\n\n constructor(id: string | MaybeTsDsl<ts.Expression>) {\n super();\n this._exprInput = id;\n }\n\n $render(): ts.Expression {\n return this.$node(this._exprInput);\n }\n}\n\nexport interface ExprTsDsl\n extends AsMixin,\n ExprMixin,\n OperatorMixin,\n TypeExprMixin {}\nmixin(ExprTsDsl, AsMixin, ExprMixin, OperatorMixin, TypeExprMixin);\n","import ts from 'typescript';\n\nimport type { MaybeArray } from '../base';\nimport { TsDsl } from '../base';\nimport { IdTsDsl } from '../expr/id';\n\nexport class HintTsDsl extends TsDsl<ts.Node> {\n protected _lines: Array<string> = [];\n\n constructor(lines?: MaybeArray<string>, fn?: (d: HintTsDsl) => void) {\n super();\n if (lines) {\n if (typeof lines === 'string') {\n this.add(lines);\n } else {\n this.add(...lines);\n }\n }\n fn?.(this);\n }\n\n add(...lines: ReadonlyArray<string>): this {\n this._lines.push(...lines);\n return this;\n }\n\n apply<T extends ts.Node>(node: T): T {\n const lines = this._lines.filter((line) => Boolean(line) || line === '');\n if (!lines.length) return node;\n\n for (const line of lines) {\n ts.addSyntheticLeadingComment(\n node,\n ts.SyntaxKind.SingleLineCommentTrivia,\n ` ${line}`,\n false,\n );\n }\n\n return node;\n }\n\n $render(): ts.Node {\n // this class does not build a standalone node;\n // it modifies other nodes via `apply()`.\n // Return a dummy comment node for compliance.\n return this.$node(new IdTsDsl(''));\n }\n}\n","import type { ITsDsl, MaybeArray } from '../base';\nimport { HintTsDsl } from '../layout/hint';\n\nexport function HintMixin<\n TBase extends new (...args: ReadonlyArray<any>) => ITsDsl,\n>(Base: TBase) {\n const $renderBase = Base.prototype.$render;\n\n class Mixin extends Base {\n _hint?: HintTsDsl;\n\n hint(lines?: MaybeArray<string>, fn?: (h: HintTsDsl) => void): this {\n this._hint = new HintTsDsl(lines, fn);\n return this;\n }\n\n override $render(...args: Parameters<ITsDsl['$render']>) {\n const node = $renderBase.apply(this, args);\n return this._hint ? this._hint.apply(node) : node;\n }\n }\n\n // @ts-expect-error\n Mixin.prototype.$render.mixin = true;\n\n return Mixin;\n}\n\nexport type HintMixin = InstanceType<ReturnType<typeof HintMixin>>;\n","/* eslint-disable @typescript-eslint/no-empty-object-type, @typescript-eslint/no-unsafe-declaration-merging */\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport { GetterTsDsl } from '../decl/getter';\nimport { SetterTsDsl } from '../decl/setter';\nimport { mixin } from '../mixins/apply';\nimport { DocMixin } from '../mixins/doc';\nimport { safePropName } from '../utils/prop';\nimport { IdTsDsl } from './id';\n\ntype Expr = string | MaybeTsDsl<ts.Expression>;\ntype Stmt = string | MaybeTsDsl<ts.Statement>;\ntype Kind = 'computed' | 'getter' | 'prop' | 'setter' | 'spread';\n\ntype Meta =\n | { kind: 'computed'; name: string }\n | { kind: 'getter'; name: string }\n | { kind: 'prop'; name: string }\n | { kind: 'setter'; name: string }\n | { kind: 'spread'; name?: undefined };\n\nexport class ObjectPropTsDsl extends TsDsl<ts.ObjectLiteralElementLike> {\n protected _value?: Expr | Stmt;\n protected meta: Meta;\n\n constructor(meta: Meta) {\n super();\n this.meta = meta;\n }\n\n /** Returns true when all required builder calls are present. */\n get isValid(): boolean {\n return this.missingRequiredCalls().length === 0;\n }\n\n value(value: Expr | Stmt | ((p: ObjectPropTsDsl) => void)) {\n if (typeof value === 'function') {\n value(this);\n } else {\n this._value = value;\n }\n return this;\n }\n\n $render(): ts.ObjectLiteralElementLike {\n this.$validate();\n const node = this.$node(this._value);\n if (this.meta.kind === 'spread') {\n if (ts.isStatement(node)) {\n throw new Error(\n 'Invalid spread: object spread must be an expression, not a statement.',\n );\n }\n return ts.factory.createSpreadAssignment(node);\n }\n if (this.meta.kind === 'getter') {\n const getter = new GetterTsDsl(safePropName(this.meta.name)).do(node);\n return this.$node(getter);\n }\n if (this.meta.kind === 'setter') {\n const setter = new SetterTsDsl(safePropName(this.meta.name)).do(node);\n return this.$node(setter);\n }\n if (ts.isIdentifier(node) && node.text === this.meta.name) {\n return ts.factory.createShorthandPropertyAssignment(this.meta.name);\n }\n if (ts.isStatement(node)) {\n throw new Error(\n 'Invalid property: object property value must be an expression, not a statement.',\n );\n }\n return ts.factory.createPropertyAssignment(\n this.meta.kind === 'computed'\n ? ts.factory.createComputedPropertyName(\n this.$node(new IdTsDsl(this.meta.name)),\n )\n : safePropName(this.meta.name),\n node,\n );\n }\n\n $validate(): asserts this is this & {\n _value: Expr | Stmt;\n kind: Kind;\n } {\n const missing = this.missingRequiredCalls();\n if (missing.length === 0) return;\n throw new Error(\n `Object property${this.meta.name ? ` \"${this.meta.name}\"` : ''} missing ${missing.join(' and ')}`,\n );\n }\n\n private missingRequiredCalls(): ReadonlyArray<string> {\n const missing: Array<string> = [];\n if (!this._value) missing.push('.value()');\n return missing;\n }\n}\n\nexport interface ObjectPropTsDsl extends DocMixin {}\nmixin(ObjectPropTsDsl, DocMixin);\n","/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport { mixin } from '../mixins/apply';\nimport { AsMixin } from '../mixins/as';\nimport { ExprMixin } from '../mixins/expr';\nimport { HintMixin } from '../mixins/hint';\nimport { LayoutMixin } from '../mixins/layout';\nimport { ObjectPropTsDsl } from './prop';\n\ntype Expr = string | MaybeTsDsl<ts.Expression>;\ntype Stmt = string | MaybeTsDsl<ts.Statement>;\ntype ExprFn = Expr | ((p: ObjectPropTsDsl) => void);\ntype StmtFn = Stmt | ((p: ObjectPropTsDsl) => void);\n\nexport class ObjectTsDsl extends TsDsl<ts.ObjectLiteralExpression> {\n protected _props: Array<ObjectPropTsDsl> = [];\n\n constructor(...props: Array<ObjectPropTsDsl>) {\n super();\n this.props(...props);\n }\n\n /** Adds a computed property (e.g. `{ [expr]: value }`). */\n computed(name: string, expr: ExprFn): this {\n this._props.push(\n new ObjectPropTsDsl({ kind: 'computed', name }).value(expr),\n );\n return this;\n }\n\n /** Adds a getter property (e.g. `{ get foo() { ... } }`). */\n getter(name: string, stmt: StmtFn): this {\n this._props.push(new ObjectPropTsDsl({ kind: 'getter', name }).value(stmt));\n return this;\n }\n\n /** Returns true if object has at least one property or spread. */\n hasProps(): boolean {\n return this._props.length > 0;\n }\n\n /** Returns true if object has no properties or spreads. */\n get isEmpty(): boolean {\n return this._props.length === 0;\n }\n\n /** Adds a property assignment. */\n prop(name: string, expr: ExprFn): this {\n this._props.push(new ObjectPropTsDsl({ kind: 'prop', name }).value(expr));\n return this;\n }\n\n /** Adds multiple properties. */\n props(...props: ReadonlyArray<ObjectPropTsDsl>): this {\n this._props.push(...props);\n return this;\n }\n\n /** Adds a setter property (e.g. `{ set foo(v) { ... } }`). */\n setter(name: string, stmt: StmtFn): this {\n this._props.push(new ObjectPropTsDsl({ kind: 'setter', name }).value(stmt));\n return this;\n }\n\n /** Adds a spread property (e.g. `{ ...options }`). */\n spread(expr: ExprFn): this {\n this._props.push(new ObjectPropTsDsl({ kind: 'spread' }).value(expr));\n return this;\n }\n\n /** Builds and returns the object literal expression. */\n $render(): ts.ObjectLiteralExpression {\n return ts.factory.createObjectLiteralExpression(\n this.$node(this._props),\n this.$multiline(this._props.length),\n );\n }\n}\n\nexport interface ObjectTsDsl\n extends AsMixin,\n ExprMixin,\n HintMixin,\n LayoutMixin {}\nmixin(ObjectTsDsl, AsMixin, ExprMixin, HintMixin, LayoutMixin);\n","import type ts from 'typescript';\n\nimport { TsDsl } from '../base';\nimport { ArrayTsDsl } from './array';\nimport { LiteralTsDsl } from './literal';\nimport { ObjectTsDsl } from './object';\n\nexport const fromValue = (\n input: unknown,\n options?: {\n layout?: 'pretty';\n },\n): TsDsl<ts.Expression> => {\n if (input instanceof TsDsl) {\n return input;\n }\n\n if (input === null) {\n return new LiteralTsDsl(input);\n }\n\n if (\n typeof input === 'number' ||\n typeof input === 'boolean' ||\n typeof input === 'string'\n ) {\n return new LiteralTsDsl(input);\n }\n\n if (input instanceof Array) {\n const arr = new ArrayTsDsl(...input.map((v) => fromValue(v, options)));\n if (options?.layout === 'pretty') arr.pretty();\n return arr;\n }\n\n if (typeof input === 'object') {\n const obj = new ObjectTsDsl();\n for (const [key, val] of Object.entries(input)) {\n const expr = fromValue(val, options);\n obj.prop(key, expr);\n }\n if (options?.layout === 'pretty') obj.pretty();\n return obj;\n }\n\n throw new Error(`$.fromValue(): Unsupported input type ${String(input)}`);\n};\n","/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport { mixin } from '../mixins/apply';\nimport { ArgsMixin } from '../mixins/args';\nimport { ExprMixin } from '../mixins/expr';\nimport { TypeArgsMixin } from '../mixins/type-args';\n\nexport class NewTsDsl extends TsDsl<ts.NewExpression> {\n protected classExpr: string | MaybeTsDsl<ts.Expression>;\n\n constructor(\n classExpr: string | MaybeTsDsl<ts.Expression>,\n ...args: ReadonlyArray<string | MaybeTsDsl<ts.Expression>>\n ) {\n super();\n this.classExpr = classExpr;\n this.args(...args);\n }\n\n /** Builds the `NewExpression` node. */\n $render(): ts.NewExpression {\n return ts.factory.createNewExpression(\n this.$node(this.classExpr),\n this.$generics(),\n this.$args(),\n );\n }\n}\n\nexport interface NewTsDsl extends ArgsMixin, ExprMixin, TypeArgsMixin {}\nmixin(NewTsDsl, ArgsMixin, ExprMixin, TypeArgsMixin);\n","import ts from 'typescript';\n\nimport { TsDsl } from '../base';\n\ntype RegexFlag = 'g' | 'i' | 'm' | 's' | 'u' | 'y';\n\ntype RegexFlags<Avail extends string = RegexFlag> =\n | ''\n | {\n [K in Avail]: `${K}${RegexFlags<Exclude<Avail, K>>}`;\n }[Avail];\n\nexport class RegExpTsDsl extends TsDsl<ts.RegularExpressionLiteral> {\n protected pattern: string;\n protected flags?: RegexFlags;\n\n constructor(pattern: string, flags?: RegexFlags) {\n super();\n this.pattern = pattern;\n this.flags = flags;\n }\n\n /** Emits a RegularExpressionLiteral node. */\n $render(): ts.RegularExpressionLiteral {\n const patternContent =\n this.pattern.startsWith('/') && this.pattern.endsWith('/')\n ? this.pattern.slice(1, -1)\n : this.pattern;\n const escapedPattern = patternContent.replace(/(?<!\\\\)\\//g, '\\\\/');\n const literal = `/${escapedPattern}/${this.flags ?? ''}`;\n return ts.factory.createRegularExpressionLiteral(literal);\n }\n}\n","import ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\n\nexport class TemplateTsDsl extends TsDsl<\n ts.TemplateExpression | ts.NoSubstitutionTemplateLiteral\n> {\n protected parts: Array<string | MaybeTsDsl<ts.Expression>> = [];\n\n constructor(value?: string | MaybeTsDsl<ts.Expression>) {\n super();\n if (value !== undefined) this.add(value);\n }\n\n add(value: string | MaybeTsDsl<ts.Expression>): this {\n this.parts.push(value);\n return this;\n }\n\n $render(): ts.TemplateExpression | ts.NoSubstitutionTemplateLiteral {\n const parts = this.$node(this.parts);\n\n const normalized: Array<string | ts.Expression> = [];\n // merge consecutive string parts\n for (let index = 0; index < parts.length; index++) {\n const current = parts[index]!;\n if (typeof current === 'string') {\n let merged = current;\n while (\n index + 1 < parts.length &&\n typeof parts[index + 1] === 'string'\n ) {\n merged += parts[index + 1];\n index++;\n }\n normalized.push(merged);\n } else {\n normalized.push(current);\n }\n }\n\n if (normalized.length === 0 || typeof normalized[0] !== 'string') {\n normalized.unshift('');\n }\n\n if (normalized.length === 1 && typeof normalized[0] === 'string') {\n return ts.factory.createNoSubstitutionTemplateLiteral(normalized[0]);\n }\n\n if (\n normalized.length === 2 &&\n typeof normalized[0] === 'string' &&\n typeof normalized[1] !== 'string'\n ) {\n return ts.factory.createTemplateExpression(\n ts.factory.createTemplateHead(normalized[0]),\n [\n ts.factory.createTemplateSpan(\n normalized[1]!,\n ts.factory.createTemplateTail(''),\n ),\n ],\n );\n }\n\n const head = ts.factory.createTemplateHead(normalized.shift() as string);\n const spans: Array<ts.TemplateSpan> = [];\n\n while (normalized.length) {\n const expr = normalized.shift() as ts.Expression;\n const next =\n typeof normalized[0] === 'string' ? (normalized.shift() as string) : '';\n const isLast = normalized.length === 0;\n spans.push(\n ts.factory.createTemplateSpan(\n expr,\n isLast\n ? ts.factory.createTemplateTail(next)\n : ts.factory.createTemplateMiddle(next),\n ),\n );\n }\n\n return ts.factory.createTemplateExpression(head, spans);\n }\n}\n","import ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\n\nexport class TernaryTsDsl extends TsDsl<ts.ConditionalExpression> {\n protected _condition?: string | MaybeTsDsl<ts.Expression>;\n protected _then?: string | MaybeTsDsl<ts.Expression>;\n protected _else?: string | MaybeTsDsl<ts.Expression>;\n\n constructor(condition?: string | MaybeTsDsl<ts.Expression>) {\n super();\n if (condition) this.condition(condition);\n }\n\n condition(condition: string | MaybeTsDsl<ts.Expression>) {\n this._condition = condition;\n return this;\n }\n\n do(expr: string | MaybeTsDsl<ts.Expression>) {\n this._then = expr;\n return this;\n }\n\n otherwise(expr: string | MaybeTsDsl<ts.Expression>) {\n this._else = expr;\n return this;\n }\n\n $render(): ts.ConditionalExpression {\n if (!this._condition) throw new Error('Missing condition in ternary');\n if (!this._then) throw new Error('Missing then expression in ternary');\n if (!this._else) throw new Error('Missing else expression in ternary');\n\n return ts.factory.createConditionalExpression(\n this.$node(this._condition),\n undefined,\n this.$node(this._then),\n undefined,\n this.$node(this._else),\n );\n }\n}\n","/* eslint-disable @typescript-eslint/no-empty-object-type, @typescript-eslint/no-unsafe-declaration-merging */\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport { mixin } from '../mixins/apply';\nimport { OperatorMixin } from '../mixins/operator';\nimport { registerLazyAccessTypeOfExprFactory } from '../mixins/type-expr';\n\nexport class TypeOfExprTsDsl extends TsDsl<ts.TypeOfExpression> {\n protected _expr: string | MaybeTsDsl<ts.Expression>;\n\n constructor(expr: string | MaybeTsDsl<ts.Expression>) {\n super();\n this._expr = expr;\n }\n\n $render(): ts.TypeOfExpression {\n return ts.factory.createTypeOfExpression(this.$node(this._expr));\n }\n}\n\nexport interface TypeOfExprTsDsl extends OperatorMixin {}\nmixin(TypeOfExprTsDsl, OperatorMixin);\n\nregisterLazyAccessTypeOfExprFactory((...args) => new TypeOfExprTsDsl(...args));\n","import ts from 'typescript';\n\nimport type { MaybeArray } from '../base';\nimport { TsDsl } from '../base';\nimport { IdTsDsl } from '../expr/id';\n\nexport class NoteTsDsl extends TsDsl<ts.Node> {\n protected _lines: Array<string> = [];\n\n constructor(lines?: MaybeArray<string>, fn?: (d: NoteTsDsl) => void) {\n super();\n if (lines) {\n if (typeof lines === 'string') {\n this.add(lines);\n } else {\n this.add(...lines);\n }\n }\n fn?.(this);\n }\n\n add(...lines: ReadonlyArray<string>): this {\n this._lines.push(...lines);\n return this;\n }\n\n apply<T extends ts.Node>(node: T): T {\n const lines = this._lines.filter((line) => Boolean(line) || line === '');\n if (!lines.length) return node;\n\n ts.addSyntheticLeadingComment(\n node,\n ts.SyntaxKind.MultiLineCommentTrivia,\n `\\n${lines.join('\\n')}\\n`,\n true,\n );\n\n return node;\n }\n\n $render(): ts.Node {\n // this class does not build a standalone node;\n // it modifies other nodes via `apply()`.\n // Return a dummy comment node for compliance.\n return this.$node(new IdTsDsl(''));\n }\n}\n","/* eslint-disable @typescript-eslint/no-empty-object-type, @typescript-eslint/no-unsafe-declaration-merging */\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport { mixin } from '../mixins/apply';\nimport { DoMixin } from '../mixins/do';\n\nexport class IfTsDsl extends TsDsl<ts.IfStatement> {\n protected _condition?: string | MaybeTsDsl<ts.Expression>;\n protected _else?: ReadonlyArray<MaybeTsDsl<ts.Statement>>;\n\n constructor(condition?: string | MaybeTsDsl<ts.Expression>) {\n super();\n if (condition) this.condition(condition);\n }\n\n condition(condition: string | MaybeTsDsl<ts.Expression>): this {\n this._condition = condition;\n return this;\n }\n\n otherwise(...statements: ReadonlyArray<MaybeTsDsl<ts.Statement>>): this {\n this._else = statements;\n return this;\n }\n\n $render(): ts.IfStatement {\n if (!this._condition) throw new Error('Missing condition in if');\n\n const thenStmts = this.$do();\n if (!thenStmts.length) throw new Error('Missing then block in if');\n\n const condition = this.$node(this._condition);\n const thenBlock =\n thenStmts.length === 1\n ? thenStmts[0]!\n : ts.factory.createBlock(thenStmts, true);\n const thenNode = ts.isBlock(thenBlock)\n ? thenBlock\n : ts.factory.createBlock([thenBlock], true);\n\n let elseNode: ts.Statement | undefined;\n if (this._else) {\n const elseStmts = this.$node(this._else);\n const elseBlock =\n elseStmts.length === 1\n ? elseStmts[0]!\n : ts.factory.createBlock(elseStmts, true);\n elseNode = ts.isBlock(elseBlock)\n ? elseBlock\n : ts.factory.createBlock([elseBlock], true);\n }\n\n return ts.factory.createIfStatement(condition, thenNode, elseNode);\n }\n}\n\nexport interface IfTsDsl extends DoMixin {}\nmixin(IfTsDsl, DoMixin);\n","/* eslint-disable @typescript-eslint/no-empty-object-type, @typescript-eslint/no-unsafe-declaration-merging */\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport { mixin } from '../mixins/apply';\nimport { ExprMixin, registerLazyAccessReturnFactory } from '../mixins/expr';\n\nexport class ReturnTsDsl extends TsDsl<ts.ReturnStatement> {\n protected _returnExpr?: string | MaybeTsDsl<ts.Expression>;\n\n constructor(expr?: string | MaybeTsDsl<ts.Expression>) {\n super();\n this._returnExpr = expr;\n }\n\n $render(): ts.ReturnStatement {\n return ts.factory.createReturnStatement(this.$node(this._returnExpr));\n }\n}\n\nexport interface ReturnTsDsl extends ExprMixin {}\nmixin(ReturnTsDsl, ExprMixin);\n\nregisterLazyAccessReturnFactory((...args) => new ReturnTsDsl(...args));\n","import ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport { LiteralTsDsl } from '../expr/literal';\n\nexport class ThrowTsDsl extends TsDsl<ts.ThrowStatement> {\n protected error: string | MaybeTsDsl<ts.Expression>;\n protected msg?: string | MaybeTsDsl<ts.Expression>;\n protected useNew: boolean;\n\n constructor(error: string | MaybeTsDsl<ts.Expression>, useNew = true) {\n super();\n this.error = error;\n this.useNew = useNew;\n }\n\n message(value: string | MaybeTsDsl<ts.Expression>): this {\n this.msg = value;\n return this;\n }\n\n $render(): ts.ThrowStatement {\n const errorNode = this.$node(this.error);\n const messageNode = this.$node(this.msg ? [this.msg] : []).map((expr) =>\n typeof expr === 'string' ? new LiteralTsDsl(expr).$render() : expr,\n );\n if (this.useNew) {\n return ts.factory.createThrowStatement(\n ts.factory.createNewExpression(errorNode, undefined, messageNode),\n );\n }\n const args = messageNode.length\n ? [ts.factory.createCallExpression(errorNode, undefined, messageNode)]\n : [errorNode];\n return ts.factory.createThrowStatement(args[0]!);\n }\n}\n","/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */\nimport ts from 'typescript';\n\nimport { TsDsl, TypeTsDsl } from '../base';\nimport { mixin } from '../mixins/apply';\nimport { DocMixin } from '../mixins/doc';\nimport { HintMixin } from '../mixins/hint';\nimport {\n createModifierAccessor,\n DefaultMixin,\n ExportMixin,\n} from '../mixins/modifiers';\nimport { PatternMixin } from '../mixins/pattern';\nimport { ValueMixin } from '../mixins/value';\nimport { TypeExprTsDsl } from '../type/expr';\n\nexport class VarTsDsl extends TsDsl<ts.VariableStatement> {\n protected kind: ts.NodeFlags = ts.NodeFlags.None;\n protected modifiers = createModifierAccessor(this);\n protected name?: string;\n protected _type?: TypeTsDsl;\n\n constructor(name?: string) {\n super();\n this.name = name;\n }\n\n const(): this {\n this.kind = ts.NodeFlags.Const;\n return this;\n }\n\n let(): this {\n this.kind = ts.NodeFlags.Let;\n return this;\n }\n\n /** Sets the variable type. */\n type(type: string | TypeTsDsl): this {\n this._type = type instanceof TypeTsDsl ? type : new TypeExprTsDsl(type);\n return this;\n }\n\n var(): this {\n this.kind = ts.NodeFlags.None;\n return this;\n }\n\n $render(): ts.VariableStatement {\n const name = this.$pattern() ?? this.name;\n if (!name)\n throw new Error('Var must have either a name or a destructuring pattern');\n return ts.factory.createVariableStatement(\n this.modifiers.list(),\n ts.factory.createVariableDeclarationList(\n [\n ts.factory.createVariableDeclaration(\n name,\n undefined,\n this.$type(this._type),\n this.$value(),\n ),\n ],\n this.kind,\n ),\n );\n }\n}\n\nexport interface VarTsDsl\n extends DefaultMixin,\n DocMixin,\n ExportMixin,\n HintMixin,\n PatternMixin,\n ValueMixin {}\nmixin(\n VarTsDsl,\n DefaultMixin,\n DocMixin,\n ExportMixin,\n HintMixin,\n PatternMixin,\n ValueMixin,\n);\n","/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport { mixin } from '../mixins/apply';\nimport { DocMixin } from '../mixins/doc';\nimport { createModifierAccessor, ExportMixin } from '../mixins/modifiers';\nimport { TypeParamsMixin } from '../mixins/type-params';\n\nexport class TypeAliasTsDsl extends TsDsl<ts.TypeAliasDeclaration> {\n protected value?: MaybeTsDsl<ts.TypeNode>;\n protected modifiers = createModifierAccessor(this);\n protected name: string;\n\n constructor(name: string, fn?: (t: TypeAliasTsDsl) => void) {\n super();\n this.name = name;\n fn?.(this);\n }\n\n /** Sets the type expression on the right-hand side of `= ...`. */\n type(node: MaybeTsDsl<ts.TypeNode>): this {\n this.value = node;\n return this;\n }\n\n /** Renders a `TypeAliasDeclaration` node. */\n $render(): ts.TypeAliasDeclaration {\n if (!this.value)\n throw new Error(`Type alias '${this.name}' is missing a type definition`);\n return ts.factory.createTypeAliasDeclaration(\n this.modifiers.list(),\n this.name,\n this.$generics(),\n this.$type(this.value),\n );\n }\n}\n\nexport interface TypeAliasTsDsl\n extends DocMixin,\n ExportMixin,\n TypeParamsMixin {}\nmixin(TypeAliasTsDsl, DocMixin, ExportMixin, TypeParamsMixin);\n","import ts from 'typescript';\n\nimport { TypeTsDsl } from '../base';\n\nexport class TypeAndTsDsl extends TypeTsDsl<ts.IntersectionTypeNode> {\n protected _types: Array<string | ts.TypeNode | TypeTsDsl> = [];\n\n constructor(...nodes: Array<string | ts.TypeNode | TypeTsDsl>) {\n super();\n this.types(...nodes);\n }\n\n types(...nodes: Array<string | ts.TypeNode | TypeTsDsl>): this {\n this._types.push(...nodes);\n return this;\n }\n\n $render(): ts.IntersectionTypeNode {\n const flat: Array<ts.TypeNode> = [];\n\n for (const n of this._types) {\n const t = this.$type(n);\n if (ts.isIntersectionTypeNode(t)) {\n flat.push(...t.types);\n } else {\n flat.push(t);\n }\n }\n\n return ts.factory.createIntersectionTypeNode(flat);\n }\n}\n","import ts from 'typescript';\n\nimport { TypeTsDsl } from '../base';\nimport { LiteralTsDsl } from '../expr/literal';\n\nexport class TypeLiteralTsDsl extends TypeTsDsl<ts.LiteralTypeNode> {\n protected value: string | number | boolean | null;\n\n constructor(value: string | number | boolean | null) {\n super();\n this.value = value;\n }\n\n $render(): ts.LiteralTypeNode {\n return ts.factory.createLiteralTypeNode(\n this.$node(new LiteralTsDsl(this.value)),\n );\n }\n}\n","/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TypeTsDsl } from '../base';\nimport { mixin } from '../mixins/apply';\nimport { DocMixin } from '../mixins/doc';\nimport { createModifierAccessor, ReadonlyMixin } from '../mixins/modifiers';\n\ntype Type = string | MaybeTsDsl<ts.TypeNode>;\n\nexport class TypeIdxSigTsDsl extends TypeTsDsl<ts.IndexSignatureDeclaration> {\n protected modifiers = createModifierAccessor(this);\n protected _key?: Type;\n protected _name: string;\n protected _type?: Type;\n\n constructor(name: string, fn?: (i: TypeIdxSigTsDsl) => void) {\n super();\n this._name = name;\n fn?.(this);\n }\n\n /** Returns true when all required builder calls are present. */\n get isValid(): boolean {\n return this.missingRequiredCalls().length === 0;\n }\n\n /** Sets the key type: `[name: T]` */\n key(type: Type): this {\n this._key = type;\n return this;\n }\n\n /** Sets the property type. */\n type(type: Type): this {\n this._type = type;\n return this;\n }\n\n $render(): ts.IndexSignatureDeclaration {\n this.$validate();\n return ts.factory.createIndexSignature(\n this.modifiers.list(),\n [\n ts.factory.createParameterDeclaration(\n undefined,\n undefined,\n this._name,\n undefined,\n this.$type(this._key),\n ),\n ],\n this.$type(this._type),\n );\n }\n\n $validate(): asserts this is this & {\n _key: Type;\n _name: string;\n _type: Type;\n } {\n const missing = this.missingRequiredCalls();\n if (missing.length === 0) return;\n throw new Error(\n `Index signature${this._name ? ` \"${this._name}\"` : ''} missing ${missing.join(' and ')}`,\n );\n }\n\n private missingRequiredCalls(): ReadonlyArray<string> {\n const missing: Array<string> = [];\n if (!this._key) missing.push('.key()');\n if (!this._name) missing.push('.name()');\n if (!this._type) missing.push('.\\u200Btype()');\n return missing;\n }\n}\n\nexport interface TypeIdxSigTsDsl extends DocMixin, ReadonlyMixin {}\nmixin(TypeIdxSigTsDsl, DocMixin, ReadonlyMixin);\n","/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TypeTsDsl } from '../base';\nimport { mixin } from '../mixins/apply';\nimport { DocMixin } from '../mixins/doc';\nimport { createModifierAccessor, ReadonlyMixin } from '../mixins/modifiers';\nimport { OptionalMixin } from '../mixins/optional';\nimport { TokenTsDsl } from '../token';\nimport { safePropName } from '../utils/prop';\n\nexport class TypePropTsDsl extends TypeTsDsl<ts.TypeElement> {\n protected modifiers = createModifierAccessor(this);\n protected name: string;\n protected _type?: string | MaybeTsDsl<ts.TypeNode>;\n\n constructor(name: string, fn: (p: TypePropTsDsl) => void) {\n super();\n this.name = name;\n fn(this);\n }\n\n /** Sets the property type. */\n type(type: string | MaybeTsDsl<ts.TypeNode>): this {\n this._type = type;\n return this;\n }\n\n /** Builds and returns the property signature. */\n $render(): ts.TypeElement {\n if (!this._type) {\n throw new Error(`Type not specified for property '${this.name}'`);\n }\n return ts.factory.createPropertySignature(\n this.modifiers.list(),\n safePropName(this.name),\n this._optional ? this.$node(new TokenTsDsl().optional()) : undefined,\n this.$type(this._type),\n );\n }\n}\n\nexport interface TypePropTsDsl extends DocMixin, OptionalMixin, ReadonlyMixin {}\nmixin(TypePropTsDsl, DocMixin, OptionalMixin, ReadonlyMixin);\n","import ts from 'typescript';\n\nimport { TypeTsDsl } from '../base';\nimport { TypeIdxSigTsDsl } from './idx-sig';\nimport { TypePropTsDsl } from './prop';\n\nexport class TypeObjectTsDsl extends TypeTsDsl<ts.TypeNode> {\n protected props: Array<TypePropTsDsl | TypeIdxSigTsDsl> = [];\n\n /** Returns true if object has at least one property or spread. */\n hasProps(): boolean {\n return this.props.length > 0;\n }\n\n /** Adds an index signature to the object type. */\n idxSig(name: string, fn: (i: TypeIdxSigTsDsl) => void): this {\n const idx = new TypeIdxSigTsDsl(name, fn);\n this.props.push(idx);\n return this;\n }\n\n /** Returns true if object has no properties or spreads. */\n get isEmpty(): boolean {\n return !this.props.length;\n }\n\n /** Adds a property signature (returns property builder). */\n prop(name: string, fn: (p: TypePropTsDsl) => void): this {\n const prop = new TypePropTsDsl(name, fn);\n this.props.push(prop);\n return this;\n }\n\n $render(): ts.TypeNode {\n return ts.factory.createTypeLiteralNode(this.$node(this.props));\n }\n}\n","import ts from 'typescript';\n\nimport { TypeTsDsl } from '../base';\n\nexport class TypeTupleTsDsl extends TypeTsDsl<ts.TupleTypeNode> {\n protected _elements: Array<string | ts.TypeNode | TypeTsDsl> = [];\n\n constructor(...nodes: Array<string | ts.TypeNode | TypeTsDsl>) {\n super();\n this.elements(...nodes);\n }\n\n elements(...types: Array<string | ts.TypeNode | TypeTsDsl>): this {\n this._elements.push(...types);\n return this;\n }\n\n $render(): ts.TupleTypeNode {\n return ts.factory.createTupleTypeNode(\n this._elements.map((t) => this.$type(t)),\n );\n }\n}\n","import type ts from 'typescript';\n\nimport { TsDsl } from '../base';\nimport { TypeLiteralTsDsl } from './literal';\nimport { TypeObjectTsDsl } from './object';\nimport { TypeTupleTsDsl } from './tuple';\n\nexport const fromValue = (input: unknown): TsDsl<ts.TypeNode> => {\n if (input instanceof TsDsl) {\n return input;\n }\n\n if (input === null) {\n return new TypeLiteralTsDsl(input);\n }\n\n if (\n typeof input === 'number' ||\n typeof input === 'boolean' ||\n typeof input === 'string'\n ) {\n return new TypeLiteralTsDsl(input);\n }\n\n if (input instanceof Array) {\n const arr = new TypeTupleTsDsl(...input.map((v) => fromValue(v)));\n return arr;\n }\n\n if (typeof input === 'object') {\n const obj = new TypeObjectTsDsl();\n for (const [key, val] of Object.entries(input)) {\n const type = fromValue(val);\n obj.prop(key, (p) => p.type(type));\n }\n return obj;\n }\n\n throw new Error(\n `$.type.fromValue(): Unsupported input type ${String(input)}`,\n );\n};\n","/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */\nimport ts from 'typescript';\n\nimport { TypeTsDsl } from '../base';\nimport { mixin } from '../mixins/apply';\nimport { DocMixin } from '../mixins/doc';\nimport { ParamMixin } from '../mixins/param';\nimport { TypeParamsMixin } from '../mixins/type-params';\nimport { TypeExprTsDsl } from './expr';\n\nexport class TypeFuncTsDsl extends TypeTsDsl<ts.FunctionTypeNode> {\n protected _returns?: TypeTsDsl;\n\n /** Sets the return type. */\n returns(type: string | TypeTsDsl): this {\n this._returns = type instanceof TypeTsDsl ? type : new TypeExprTsDsl(type);\n return this;\n }\n\n $render(): ts.FunctionTypeNode {\n if (this._returns === undefined) {\n throw new Error('Missing return type in function type DSL');\n }\n return ts.factory.createFunctionTypeNode(\n this.$generics(),\n this.$params(),\n this.$type(this._returns),\n );\n }\n}\n\nexport interface TypeFuncTsDsl extends DocMixin, ParamMixin, TypeParamsMixin {}\nmixin(TypeFuncTsDsl, DocMixin, ParamMixin, TypeParamsMixin);\n","/* eslint-disable @typescript-eslint/no-empty-object-type, @typescript-eslint/no-unsafe-declaration-merging */\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TypeTsDsl } from '../base';\nimport { mixin } from '../mixins/apply';\nimport {\n registerLazyAccessTypeIdxFactory,\n TypeExprMixin,\n} from '../mixins/type-expr';\n\nexport class TypeIdxTsDsl extends TypeTsDsl<ts.IndexedAccessTypeNode> {\n protected _base: string | MaybeTsDsl<ts.TypeNode>;\n protected _index: string | MaybeTsDsl<ts.TypeNode> | number;\n\n constructor(\n base: string | MaybeTsDsl<ts.TypeNode>,\n index: string | MaybeTsDsl<ts.TypeNode> | number,\n ) {\n super();\n this._base = base;\n this._index = index;\n }\n\n base(base: string | MaybeTsDsl<ts.TypeNode>): this {\n this._base = base;\n return this;\n }\n\n index(index: string | MaybeTsDsl<ts.TypeNode> | number): this {\n this._index = index;\n return this;\n }\n\n $render(): ts.IndexedAccessTypeNode {\n return ts.factory.createIndexedAccessTypeNode(\n this.$type(this._base),\n this.$type(this._index),\n );\n }\n}\n\nexport interface TypeIdxTsDsl extends TypeExprMixin {}\nmixin(TypeIdxTsDsl, TypeExprMixin);\n\nregisterLazyAccessTypeIdxFactory((...args) => new TypeIdxTsDsl(...args));\n","import ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TypeTsDsl } from '../base';\nimport { TokenTsDsl } from '../token';\n\nexport class TypeMappedTsDsl extends TypeTsDsl<ts.MappedTypeNode> {\n protected questionToken?: TokenTsDsl<\n | ts.SyntaxKind.QuestionToken\n | ts.SyntaxKind.PlusToken\n | ts.SyntaxKind.MinusToken\n >;\n protected readonlyToken?: TokenTsDsl<\n | ts.SyntaxKind.ReadonlyKeyword\n | ts.SyntaxKind.MinusToken\n | ts.SyntaxKind.PlusToken\n >;\n protected _key?: string | MaybeTsDsl<ts.TypeNode>;\n protected _name?: string;\n protected _type?: string | MaybeTsDsl<ts.TypeNode>;\n\n constructor(name?: string) {\n super();\n this.name(name);\n }\n\n /** Returns true when all required builder calls are present. */\n get isValid(): boolean {\n return this.missingRequiredCalls().length === 0;\n }\n\n /** Sets the key constraint: `[K in Constraint]` */\n key(type: string | MaybeTsDsl<ts.TypeNode>): this {\n this._key = type;\n return this;\n }\n\n /** Removes `readonly` from the mapped members (`[K in X]-readonly`). */\n mutable(): this {\n this.readonlyToken = new TokenTsDsl().minus();\n return this;\n }\n\n /** Sets the parameter name: `{ [Name in keyof T]: U }` */\n name(name?: string): this {\n this._name = name;\n return this;\n }\n\n /** Makes `[K in X]?:` optional. */\n optional(): this {\n this.questionToken = new TokenTsDsl().optional();\n return this;\n }\n\n /** Makes `[K in X]` readonly */\n readonly(): this {\n this.readonlyToken = new TokenTsDsl().readonly();\n return this;\n }\n\n /** Removes `?` from the mapped members (`[K in X]-?:`). */\n required(): this {\n this.questionToken = new TokenTsDsl().minus();\n return this;\n }\n\n /** Sets the mapped value type: `[K in X]: ValueType` */\n type(type: string | MaybeTsDsl<ts.TypeNode>): this {\n this._type = type;\n return this;\n }\n\n $render(): ts.MappedTypeNode {\n this.$validate();\n return ts.factory.createMappedTypeNode(\n this.$node(this.readonlyToken),\n ts.factory.createTypeParameterDeclaration(\n undefined,\n this._name,\n this.$type(this._key),\n undefined,\n ),\n undefined,\n this.$node(this.questionToken),\n this.$type(this._type),\n undefined,\n );\n }\n\n $validate(): asserts this is this & {\n _key: string | MaybeTsDsl<ts.TypeNode>;\n _name: string;\n _type: string | MaybeTsDsl<ts.TypeNode>;\n } {\n const missing = this.missingRequiredCalls();\n if (missing.length === 0) return;\n throw new Error(\n `Mapped type${this._name ? ` \"${this._name}\"` : ''} missing ${missing.join(' and ')}`,\n );\n }\n\n private missingRequiredCalls(): ReadonlyArray<string> {\n const missing: Array<string> = [];\n if (!this._key) missing.push('.key()');\n if (!this._name) missing.push('.name()');\n if (!this._type) missing.push('.\\u200Btype()');\n return missing;\n }\n}\n","import ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TypeTsDsl } from '../base';\nimport { registerLazyAccessTypeOperatorFactory } from '../mixins/type-expr';\n\ntype Op =\n | ts.SyntaxKind.KeyOfKeyword\n | ts.SyntaxKind.ReadonlyKeyword\n | ts.SyntaxKind.UniqueKeyword;\ntype Type = string | MaybeTsDsl<ts.TypeNode>;\n\n/**\n * Builds a TypeScript `TypeOperatorNode`, such as:\n *\n * - `keyof T`\n * - `readonly U`\n * - `unique V`\n *\n * This DSL provides both a generic `.operator()` API and convenient\n * shorthand methods (`.keyof()`, `.readonly()`, `.unique()`).\n *\n * The node will throw during render if required fields are missing.\n */\nexport class TypeOperatorTsDsl extends TypeTsDsl<ts.TypeOperatorNode> {\n protected _op?: Op;\n protected _type?: Type;\n\n /** Shorthand: builds `keyof T`. */\n keyof(type: Type): this {\n this.operator(ts.SyntaxKind.KeyOfKeyword);\n this.type(type);\n return this;\n }\n\n /** Sets the operator explicitly. */\n operator(op: Op): this {\n this._op = op;\n return this;\n }\n\n /** Shorthand: builds `readonly T`. */\n readonly(type: Type): this {\n this.operator(ts.SyntaxKind.ReadonlyKeyword);\n this.type(type);\n return this;\n }\n\n /** Sets the target type of the operator. */\n type(type: Type): this {\n this._type = type;\n return this;\n }\n\n /** Shorthand: builds `unique T`. */\n unique(type: Type): this {\n this.operator(ts.SyntaxKind.UniqueKeyword);\n this.type(type);\n return this;\n }\n\n $render(): ts.TypeOperatorNode {\n this.$validate();\n return ts.factory.createTypeOperatorNode(this._op, this.$type(this._type));\n }\n\n /** Throws if required fields are not set. */\n $validate(): asserts this is this & {\n _op: Op;\n _type: Type;\n } {\n const missing = this.missingRequiredCalls();\n if (missing.length === 0) return;\n throw new Error(`Type operator missing ${missing.join(' and ')}`);\n }\n\n private missingRequiredCalls(): ReadonlyArray<string> {\n const missing: Array<string> = [];\n if (!this._op) missing.push('.operator()');\n if (!this._type) missing.push('.\\u200Btype()');\n return missing;\n }\n}\n\nregisterLazyAccessTypeOperatorFactory(\n (...args) => new TypeOperatorTsDsl(...args),\n);\n","import ts from 'typescript';\n\nimport { TypeTsDsl } from '../base';\n\nexport class TypeOrTsDsl extends TypeTsDsl<ts.UnionTypeNode> {\n protected _types: Array<string | ts.TypeNode | TypeTsDsl> = [];\n\n constructor(...nodes: Array<string | ts.TypeNode | TypeTsDsl>) {\n super();\n this.types(...nodes);\n }\n\n types(...nodes: Array<string | ts.TypeNode | TypeTsDsl>): this {\n this._types.push(...nodes);\n return this;\n }\n\n $render(): ts.UnionTypeNode {\n const flat: Array<ts.TypeNode> = [];\n\n for (const n of this._types) {\n const t = this.$type(n);\n if (ts.isUnionTypeNode(t)) {\n flat.push(...t.types);\n } else {\n flat.push(t);\n }\n }\n\n return ts.factory.createUnionTypeNode(flat);\n }\n}\n","/* eslint-disable @typescript-eslint/no-empty-object-type, @typescript-eslint/no-unsafe-declaration-merging */\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TypeTsDsl } from '../base';\nimport { mixin } from '../mixins/apply';\nimport {\n registerLazyAccessTypeQueryFactory,\n TypeExprMixin,\n} from '../mixins/type-expr';\n\nexport class TypeQueryTsDsl extends TypeTsDsl<ts.TypeQueryNode> {\n protected _expr: string | MaybeTsDsl<TypeTsDsl | ts.Expression>;\n\n constructor(expr: string | MaybeTsDsl<TypeTsDsl | ts.Expression>) {\n super();\n this._expr = expr;\n }\n\n $render(): ts.TypeQueryNode {\n const expr = this.$node(this._expr);\n return ts.factory.createTypeQueryNode(expr as unknown as ts.EntityName);\n }\n}\n\nexport interface TypeQueryTsDsl extends TypeExprMixin {}\nmixin(TypeQueryTsDsl, TypeExprMixin);\n\nregisterLazyAccessTypeQueryFactory((...args) => new TypeQueryTsDsl(...args));\n","import ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TypeTsDsl } from '../base';\n\nexport class TypeTemplateTsDsl extends TypeTsDsl<ts.TemplateLiteralTypeNode> {\n protected parts: Array<string | MaybeTsDsl<ts.TypeNode>> = [];\n\n constructor(value?: string | MaybeTsDsl<ts.TypeNode>) {\n super();\n if (value !== undefined) this.add(value);\n }\n\n /** Adds a raw string segment or embedded type expression. */\n add(part: string | MaybeTsDsl<ts.TypeNode>): this {\n this.parts.push(part);\n return this;\n }\n\n /** Renders a TemplateLiteralTypeNode. */\n $render(): ts.TemplateLiteralTypeNode {\n const parts = this.$node(this.parts);\n\n const normalized: Array<string | ts.TypeNode> = [];\n // merge consecutive string parts\n for (let index = 0; index < parts.length; index++) {\n const current = parts[index]!;\n if (typeof current === 'string') {\n let merged = current;\n while (\n index + 1 < parts.length &&\n typeof parts[index + 1] === 'string'\n ) {\n merged += parts[index + 1]!;\n index++;\n }\n normalized.push(merged);\n } else {\n normalized.push(current);\n }\n }\n\n if (normalized.length === 0 || typeof normalized[0] !== 'string') {\n normalized.unshift('');\n }\n\n if (normalized.length === 1 && typeof normalized[0] === 'string') {\n return ts.factory.createTemplateLiteralType(\n ts.factory.createTemplateHead(normalized[0]),\n [],\n );\n }\n\n if (\n normalized.length === 2 &&\n typeof normalized[0] === 'string' &&\n typeof normalized[1] !== 'string'\n ) {\n return ts.factory.createTemplateLiteralType(\n ts.factory.createTemplateHead(normalized[0]),\n [\n ts.factory.createTemplateLiteralTypeSpan(\n normalized[1]!,\n ts.factory.createTemplateTail(''),\n ),\n ],\n );\n }\n\n const head = ts.factory.createTemplateHead(normalized.shift() as string);\n const spans: Array<ts.TemplateLiteralTypeSpan> = [];\n\n while (normalized.length) {\n const type = normalized.shift() as ts.TypeNode;\n const next =\n typeof normalized[0] === 'string' ? (normalized.shift() as string) : '';\n const isLast = normalized.length === 0;\n spans.push(\n ts.factory.createTemplateLiteralTypeSpan(\n type,\n isLast\n ? ts.factory.createTemplateTail(next)\n : ts.factory.createTemplateMiddle(next),\n ),\n );\n }\n\n return ts.factory.createTemplateLiteralType(head, spans);\n }\n}\n","import { ClassTsDsl } from './decl/class';\nimport { DecoratorTsDsl } from './decl/decorator';\nimport { EnumTsDsl } from './decl/enum';\nimport { FieldTsDsl } from './decl/field';\nimport { FuncTsDsl } from './decl/func';\nimport { GetterTsDsl } from './decl/getter';\nimport { InitTsDsl } from './decl/init';\nimport { EnumMemberTsDsl } from './decl/member';\nimport { MethodTsDsl } from './decl/method';\nimport { ParamTsDsl } from './decl/param';\nimport { PatternTsDsl } from './decl/pattern';\nimport { SetterTsDsl } from './decl/setter';\nimport { ArrayTsDsl } from './expr/array';\nimport { AsTsDsl } from './expr/as';\nimport { AttrTsDsl } from './expr/attr';\nimport { AwaitTsDsl } from './expr/await';\nimport { BinaryTsDsl } from './expr/binary';\nimport { CallTsDsl } from './expr/call';\nimport { ExprTsDsl } from './expr/expr';\nimport { fromValue as exprValue } from './expr/fromValue';\nimport { IdTsDsl } from './expr/id';\nimport { LiteralTsDsl } from './expr/literal';\nimport { NewTsDsl } from './expr/new';\nimport { ObjectTsDsl } from './expr/object';\nimport { PrefixTsDsl } from './expr/prefix';\nimport { ObjectPropTsDsl } from './expr/prop';\nimport { RegExpTsDsl } from './expr/regexp';\nimport { TemplateTsDsl } from './expr/template';\nimport { TernaryTsDsl } from './expr/ternary';\nimport { TypeOfExprTsDsl } from './expr/typeof';\nimport { DocTsDsl } from './layout/doc';\nimport { HintTsDsl } from './layout/hint';\nimport { NewlineTsDsl } from './layout/newline';\nimport { NoteTsDsl } from './layout/note';\nimport { IfTsDsl } from './stmt/if';\nimport { ReturnTsDsl } from './stmt/return';\nimport { StmtTsDsl } from './stmt/stmt';\nimport { ThrowTsDsl } from './stmt/throw';\nimport { VarTsDsl } from './stmt/var';\nimport { TokenTsDsl } from './token';\nimport { TypeAliasTsDsl } from './type/alias';\nimport { TypeAndTsDsl } from './type/and';\nimport { TypeAttrTsDsl } from './type/attr';\nimport { TypeExprTsDsl } from './type/expr';\nimport { fromValue as typeValue } from './type/fromValue';\nimport { TypeFuncTsDsl } from './type/func';\nimport { TypeIdxTsDsl } from './type/idx';\nimport { TypeLiteralTsDsl } from './type/literal';\nimport { TypeMappedTsDsl } from './type/mapped';\nimport { TypeObjectTsDsl } from './type/object';\nimport { TypeOperatorTsDsl } from './type/operator';\nimport { TypeOrTsDsl } from './type/or';\nimport { TypeParamTsDsl } from './type/param';\nimport { TypeQueryTsDsl } from './type/query';\nimport { TypeTemplateTsDsl } from './type/template';\nimport { TypeTupleTsDsl } from './type/tuple';\n\nconst base = {\n /** Creates an array literal expression (e.g. `[1, 2, 3]`). */\n array: (...args: ConstructorParameters<typeof ArrayTsDsl>) =>\n new ArrayTsDsl(...args),\n\n /** Creates an `as` type assertion expression (e.g. `value as Type`). */\n as: (...args: ConstructorParameters<typeof AsTsDsl>) => new AsTsDsl(...args),\n\n /** Creates a property access expression (e.g. `obj.foo`). */\n attr: (...args: ConstructorParameters<typeof AttrTsDsl>) =>\n new AttrTsDsl(...args),\n\n /** Creates an await expression (e.g. `await promise`). */\n await: (...args: ConstructorParameters<typeof AwaitTsDsl>) =>\n new AwaitTsDsl(...args),\n\n /** Creates a binary expression (e.g. `a + b`). */\n binary: (...args: ConstructorParameters<typeof BinaryTsDsl>) =>\n new BinaryTsDsl(...args),\n\n /** Creates a function or method call expression (e.g. `fn(arg)`). */\n call: (...args: ConstructorParameters<typeof CallTsDsl>) =>\n new CallTsDsl(...args),\n\n /** Creates a class declaration or expression. */\n class: (...args: ConstructorParameters<typeof ClassTsDsl>) =>\n new ClassTsDsl(...args),\n\n /** Creates a constant variable declaration (`const`). */\n const: (...args: ConstructorParameters<typeof VarTsDsl>) =>\n new VarTsDsl(...args).const(),\n\n /** Creates a decorator expression (e.g. `@decorator`). */\n decorator: (...args: ConstructorParameters<typeof DecoratorTsDsl>) =>\n new DecoratorTsDsl(...args),\n\n /** Creates a JSDoc documentation block. */\n doc: (...args: ConstructorParameters<typeof DocTsDsl>) =>\n new DocTsDsl(...args),\n\n /** Creates an enum declaration. */\n enum: (...args: ConstructorParameters<typeof EnumTsDsl>) =>\n new EnumTsDsl(...args),\n\n /** Creates a general expression node. */\n expr: (...args: ConstructorParameters<typeof ExprTsDsl>) =>\n new ExprTsDsl(...args),\n\n /** Creates a field declaration in a class or object. */\n field: (...args: ConstructorParameters<typeof FieldTsDsl>) =>\n new FieldTsDsl(...args),\n\n /** Converts a runtime value into a corresponding expression node. */\n fromValue: (...args: Parameters<typeof exprValue>) => exprValue(...args),\n\n /** Creates a function expression or declaration. */\n func: ((nameOrFn?: any, fn?: any) => {\n if (nameOrFn === undefined) return new FuncTsDsl();\n if (typeof nameOrFn !== 'string') return new FuncTsDsl(nameOrFn);\n if (fn === undefined) return new FuncTsDsl(nameOrFn);\n return new FuncTsDsl(nameOrFn, fn);\n }) as {\n (): FuncTsDsl<'arrow'>;\n (fn: (f: FuncTsDsl<'arrow'>) => void): FuncTsDsl<'arrow'>;\n (name: string): FuncTsDsl<'decl'>;\n (name: string, fn: (f: FuncTsDsl<'decl'>) => void): FuncTsDsl<'decl'>;\n (\n name?: string,\n fn?: (f: FuncTsDsl<'decl'>) => void,\n ): FuncTsDsl<'arrow'> | FuncTsDsl<'decl'>;\n },\n\n /** Creates a getter method declaration. */\n getter: (...args: ConstructorParameters<typeof GetterTsDsl>) =>\n new GetterTsDsl(...args),\n\n /** Creates a single-line comment (//). */\n hint: (...args: ConstructorParameters<typeof HintTsDsl>) =>\n new HintTsDsl(...args),\n\n /** Creates an identifier (e.g. `foo`). */\n id: (...args: ConstructorParameters<typeof IdTsDsl>) => new IdTsDsl(...args),\n\n /** Creates an if statement. */\n if: (...args: ConstructorParameters<typeof IfTsDsl>) => new IfTsDsl(...args),\n\n /** Creates an initialization block or statement. */\n init: (...args: ConstructorParameters<typeof InitTsDsl>) =>\n new InitTsDsl(...args),\n\n /** Creates a let variable declaration (`let`). */\n let: (...args: ConstructorParameters<typeof VarTsDsl>) =>\n new VarTsDsl(...args).let(),\n\n /** Creates a literal value (e.g. string, number, boolean). */\n literal: (...args: ConstructorParameters<typeof LiteralTsDsl>) =>\n new LiteralTsDsl(...args),\n\n /** Creates an enum member declaration. */\n member: (...args: ConstructorParameters<typeof EnumMemberTsDsl>) =>\n new EnumMemberTsDsl(...args),\n\n /** Creates a method declaration inside a class or object. */\n method: (...args: ConstructorParameters<typeof MethodTsDsl>) =>\n new MethodTsDsl(...args),\n\n /** Creates a negation expression (`-x`). */\n neg: (...args: ConstructorParameters<typeof PrefixTsDsl>) =>\n new PrefixTsDsl(...args).neg(),\n\n /** Creates a new expression (e.g. `new ClassName()`). */\n new: (...args: ConstructorParameters<typeof NewTsDsl>) =>\n new NewTsDsl(...args),\n\n /** Creates a newline (for formatting purposes). */\n newline: (...args: ConstructorParameters<typeof NewlineTsDsl>) =>\n new NewlineTsDsl(...args),\n\n /** Creates a logical NOT expression (`!x`). */\n not: (...args: ConstructorParameters<typeof PrefixTsDsl>) =>\n new PrefixTsDsl(...args).not(),\n\n /** Creates a block comment (/* ... *\\/). */\n note: (...args: ConstructorParameters<typeof NoteTsDsl>) =>\n new NoteTsDsl(...args),\n\n /** Creates an object literal expression. */\n object: (...args: ConstructorParameters<typeof ObjectTsDsl>) =>\n new ObjectTsDsl(...args),\n\n /** Creates a parameter declaration for functions or methods. */\n param: (...args: ConstructorParameters<typeof ParamTsDsl>) =>\n new ParamTsDsl(...args),\n\n /** Creates a pattern for destructuring or matching. */\n pattern: (...args: ConstructorParameters<typeof PatternTsDsl>) =>\n new PatternTsDsl(...args),\n\n /** Creates a prefix unary expression (e.g. `-x`, `!x`, `~x`). */\n prefix: (...args: ConstructorParameters<typeof PrefixTsDsl>) =>\n new PrefixTsDsl(...args),\n\n /** Creates an object literal property (e.g. `{ foo: bar }`). */\n prop: (...args: ConstructorParameters<typeof ObjectPropTsDsl>) =>\n new ObjectPropTsDsl(...args),\n\n /** Creates a regular expression literal (e.g. `/foo/gi`). */\n regexp: (...args: ConstructorParameters<typeof RegExpTsDsl>) =>\n new RegExpTsDsl(...args),\n\n /** Creates a return statement. */\n return: (...args: ConstructorParameters<typeof ReturnTsDsl>) =>\n new ReturnTsDsl(...args),\n\n /** Creates a setter method declaration. */\n setter: (...args: ConstructorParameters<typeof SetterTsDsl>) =>\n new SetterTsDsl(...args),\n\n /** Wraps an expression or statement-like value into a `StmtTsDsl`. */\n stmt: (...args: ConstructorParameters<typeof StmtTsDsl>) =>\n new StmtTsDsl(...args),\n\n /** Creates a template literal expression. */\n template: (...args: ConstructorParameters<typeof TemplateTsDsl>) =>\n new TemplateTsDsl(...args),\n\n /** Creates a ternary conditional expression (if ? then : else). */\n ternary: (...args: ConstructorParameters<typeof TernaryTsDsl>) =>\n new TernaryTsDsl(...args),\n\n /** Creates a throw statement. */\n throw: (...args: ConstructorParameters<typeof ThrowTsDsl>) =>\n new ThrowTsDsl(...args),\n\n /** Creates a syntax token (e.g. `?`, `readonly`, `+`, `-`). */\n token: (...args: ConstructorParameters<typeof TokenTsDsl>) =>\n new TokenTsDsl(...args),\n\n /** Creates a basic type reference or type expression (e.g. Foo or Foo<T>). */\n type: Object.assign(\n (...args: ConstructorParameters<typeof TypeExprTsDsl>) =>\n new TypeExprTsDsl(...args),\n {\n /** Creates a type alias declaration (e.g. `type Foo = Bar`). */\n alias: (...args: ConstructorParameters<typeof TypeAliasTsDsl>) =>\n new TypeAliasTsDsl(...args),\n\n /** Creates an intersection type (e.g. `A & B`). */\n and: (...args: ConstructorParameters<typeof TypeAndTsDsl>) =>\n new TypeAndTsDsl(...args),\n\n /** Creates a qualified type reference (e.g. Foo.Bar). */\n attr: (...args: ConstructorParameters<typeof TypeAttrTsDsl>) =>\n new TypeAttrTsDsl(...args),\n\n /** Creates a basic type reference or type expression (e.g. Foo or Foo<T>). */\n expr: (...args: ConstructorParameters<typeof TypeExprTsDsl>) =>\n new TypeExprTsDsl(...args),\n\n /** Converts a runtime value into a corresponding type expression node. */\n fromValue: (...args: Parameters<typeof typeValue>) => typeValue(...args),\n\n /** Creates a function type node (e.g. `(a: string) => number`). */\n func: (...args: ConstructorParameters<typeof TypeFuncTsDsl>) =>\n new TypeFuncTsDsl(...args),\n\n /** Creates an indexed-access type (e.g. `Foo<T>[K]`). */\n idx: (...args: ConstructorParameters<typeof TypeIdxTsDsl>) =>\n new TypeIdxTsDsl(...args),\n\n /** Creates a literal type node (e.g. 'foo', 42, or true). */\n literal: (...args: ConstructorParameters<typeof TypeLiteralTsDsl>) =>\n new TypeLiteralTsDsl(...args),\n\n /** Creates a mapped type (e.g. `{ [K in keyof T]: U }`). */\n mapped: (...args: ConstructorParameters<typeof TypeMappedTsDsl>) =>\n new TypeMappedTsDsl(...args),\n\n /** Creates a type literal node (e.g. { foo: string }). */\n object: (...args: ConstructorParameters<typeof TypeObjectTsDsl>) =>\n new TypeObjectTsDsl(...args),\n\n /** Creates a type operator node (e.g. `readonly T`, `keyof T`, `unique T`). */\n operator: (...args: ConstructorParameters<typeof TypeOperatorTsDsl>) =>\n new TypeOperatorTsDsl(...args),\n\n /** Represents a union type (e.g. `A | B | C`). */\n or: (...args: ConstructorParameters<typeof TypeOrTsDsl>) =>\n new TypeOrTsDsl(...args),\n\n /** Creates a type parameter (e.g. `<T>`). */\n param: (...args: ConstructorParameters<typeof TypeParamTsDsl>) =>\n new TypeParamTsDsl(...args),\n\n /** Creates a type query node (e.g. `typeof Foo`). */\n query: (...args: ConstructorParameters<typeof TypeQueryTsDsl>) =>\n new TypeQueryTsDsl(...args),\n\n /** Builds a TypeScript template literal *type* (e.g. `${Foo}-${Bar}` as a type). */\n template: (...args: ConstructorParameters<typeof TypeTemplateTsDsl>) =>\n new TypeTemplateTsDsl(...args),\n\n /** Creates a tuple type (e.g. [A, B, C]). */\n tuple: (...args: ConstructorParameters<typeof TypeTupleTsDsl>) =>\n new TypeTupleTsDsl(...args),\n },\n ),\n\n /** Creates a runtime `typeof` expression (e.g. typeof x). */\n typeofExpr: (...args: ConstructorParameters<typeof TypeOfExprTsDsl>) =>\n new TypeOfExprTsDsl(...args),\n\n /** Creates a variable declaration (var). */\n var: (...args: ConstructorParameters<typeof VarTsDsl>) =>\n new VarTsDsl(...args),\n};\n\nexport const $ = Object.assign(\n (...args: ConstructorParameters<typeof ExprTsDsl>) => new ExprTsDsl(...args),\n base,\n);\n\nexport type DollarTsDsl = {\n /**\n * Entry point to the TypeScript DSL.\n *\n * `$` creates a general expression node by default, but also exposes\n * builders for all other constructs such as `.type()`, `.call()`,\n * `.object()`, `.func()`, etc.\n *\n * Example:\n * ```ts\n * const node = $('console').attr('log').call($.literal('Hello'));\n * ```\n *\n * Returns:\n * - A new `ExprTsDsl` instance when called directly.\n * - The `base` factory object for constructing more specific nodes.\n */\n $: typeof $;\n};\n\nexport type { MaybeTsDsl, TypeTsDsl } from './base';\nexport { TsDsl } from './base';\n","import type { Config } from '~/types/config';\n\nexport const transformClassName = ({\n config,\n name,\n}: {\n config: Config;\n name: string;\n}) => {\n const plugin = config.plugins['@hey-api/sdk'];\n if (plugin?.config.classNameBuilder) {\n let customName = '';\n\n if (typeof plugin.config.classNameBuilder === 'function') {\n customName = plugin.config.classNameBuilder(name);\n } else {\n customName = plugin.config.classNameBuilder.replace('{{name}}', name);\n }\n\n return customName;\n }\n\n return name;\n};\n","import type { Context } from '~/ir/context';\nimport type { IR } from '~/ir/types';\n\nimport type { Auth } from '../../client-core/bundle/auth';\nimport type { HeyApiSdkPlugin } from '../types';\n\n// TODO: parser - handle more security types\nconst securitySchemeObjectToAuthObject = ({\n securitySchemeObject,\n}: {\n securitySchemeObject: IR.SecurityObject;\n}): Auth | undefined => {\n if (securitySchemeObject.type === 'openIdConnect') {\n return {\n scheme: 'bearer',\n type: 'http',\n };\n }\n\n if (securitySchemeObject.type === 'oauth2') {\n if (\n securitySchemeObject.flows.password ||\n securitySchemeObject.flows.authorizationCode ||\n securitySchemeObject.flows.clientCredentials ||\n securitySchemeObject.flows.implicit\n ) {\n return {\n scheme: 'bearer',\n type: 'http',\n };\n }\n\n return;\n }\n\n if (securitySchemeObject.type === 'apiKey') {\n if (securitySchemeObject.in === 'header') {\n return {\n name: securitySchemeObject.name,\n type: 'apiKey',\n };\n }\n\n if (\n securitySchemeObject.in === 'query' ||\n securitySchemeObject.in == 'cookie'\n ) {\n return {\n in: securitySchemeObject.in,\n name: securitySchemeObject.name,\n type: 'apiKey',\n };\n }\n\n return;\n }\n\n if (securitySchemeObject.type === 'http') {\n const scheme = securitySchemeObject.scheme.toLowerCase();\n if (scheme === 'bearer' || scheme === 'basic') {\n return {\n scheme: scheme as 'bearer' | 'basic',\n type: 'http',\n };\n }\n\n return;\n }\n\n return;\n};\n\nexport const operationAuth = ({\n operation,\n plugin,\n}: {\n context: Context;\n operation: IR.OperationObject;\n plugin: HeyApiSdkPlugin['Instance'];\n}): Array<Auth> => {\n if (!operation.security || !plugin.config.auth) {\n return [];\n }\n\n const auth: Array<Auth> = [];\n\n for (const securitySchemeObject of operation.security) {\n const authObject = securitySchemeObjectToAuthObject({\n securitySchemeObject,\n });\n if (authObject) {\n auth.push(authObject);\n } else {\n console.warn(\n `❗️ SDK warning: unsupported security scheme. Please open an issue if you'd like it added https://github.com/hey-api/openapi-ts/issues\\n${JSON.stringify(securitySchemeObject, null, 2)}`,\n );\n }\n }\n\n return auth;\n};\n","export const nuxtTypeComposable = 'TComposable';\nexport const nuxtTypeDefault = 'DefaultT';\nexport const nuxtTypeResponse = 'ResT';\n","const jsonPointerSlash = /~1/g;\nconst jsonPointerTilde = /~0/g;\n\n/**\n * Returns the reusable component name from `$ref`.\n */\nexport const refToName = ($ref: string): string => {\n const path = jsonPointerToPath($ref);\n const name = path[path.length - 1]!;\n // refs using unicode characters become encoded, didn't investigate why\n // but the suspicion is this comes from `@hey-api/json-schema-ref-parser`\n return decodeURI(name);\n};\n\n/**\n * Encodes a path segment for use in a JSON Pointer (RFC 6901).\n *\n * - Replaces all '~' with '~0'.\n * - Replaces all '/' with '~1'.\n *\n * This ensures that path segments containing these characters are safely\n * represented in JSON Pointer strings.\n *\n * @param segment - The path segment (string or number) to encode.\n * @returns The encoded segment as a string.\n */\nexport const encodeJsonPointerSegment = (segment: string | number): string =>\n String(segment).replace(/~/g, '~0').replace(/\\//g, '~1');\n\n/**\n * Converts a JSON Pointer string (RFC 6901) to an array of path segments.\n *\n * - Removes the leading '#' if present.\n * - Splits the pointer on '/'.\n * - Decodes '~1' to '/' and '~0' to '~' in each segment.\n * - Returns an empty array for the root pointer ('#' or '').\n *\n * @param pointer - The JSON Pointer string to convert (e.g., '#/components/schemas/Foo').\n * @returns An array of decoded path segments.\n */\nexport const jsonPointerToPath = (pointer: string): ReadonlyArray<string> => {\n let clean = pointer.trim();\n if (clean.startsWith('#')) {\n clean = clean.slice(1);\n }\n if (clean.startsWith('/')) {\n clean = clean.slice(1);\n }\n if (!clean) {\n return [];\n }\n return clean\n .split('/')\n .map((part) =>\n part.replace(jsonPointerSlash, '/').replace(jsonPointerTilde, '~'),\n );\n};\n\n/**\n * Normalizes a JSON Pointer string to a canonical form.\n *\n * - Ensures the pointer starts with '#'.\n * - Removes trailing slashes (except for root).\n * - Collapses multiple consecutive slashes into one.\n * - Trims whitespace from the input.\n *\n * @param pointer - The JSON Pointer string to normalize.\n * @returns The normalized JSON Pointer string.\n */\nexport const normalizeJsonPointer = (pointer: string): string => {\n let normalized = pointer.trim();\n if (!normalized.startsWith('#')) {\n normalized = `#${normalized}`;\n }\n // Remove trailing slashes (except for root)\n if (normalized.length > 1 && normalized.endsWith('/')) {\n normalized = normalized.slice(0, -1);\n }\n // Collapse multiple slashes\n normalized = normalized.replace(/\\/+/g, '/');\n return normalized;\n};\n\n/**\n * Encode path as JSON Pointer (RFC 6901).\n *\n * @param path\n * @returns\n */\nexport const pathToJsonPointer = (\n path: ReadonlyArray<string | number>,\n): string => {\n const segments = path.map(encodeJsonPointerSegment).join('/');\n return '#' + (segments ? `/${segments}` : '');\n};\n\nexport const resolveRef = <T>({\n $ref,\n spec,\n}: {\n $ref: string;\n spec: Record<string, any>;\n}): T => {\n // refs using unicode characters become encoded, didn't investigate why\n // but the suspicion is this comes from `@hey-api/json-schema-ref-parser`\n const path = jsonPointerToPath(decodeURI($ref));\n\n let current = spec;\n\n for (const part of path) {\n const segment = part as keyof typeof current;\n if (current[segment] === undefined) {\n throw new Error(`Reference not found: ${$ref}`);\n }\n current = current[segment];\n }\n\n return current as T;\n};\n","import type { IR } from '~/ir/types';\nimport type { PluginInstance } from '~/plugins/shared/utils/instance';\nimport { refToName } from '~/utils/ref';\nimport { stringCase } from '~/utils/stringCase';\n\nimport type { Field } from '../../client-core/bundle/params';\n\ntype Location = keyof IR.ParametersObject | 'body';\n\ntype SignatureParameter = {\n /**\n * Is this parameter required in the SDK method signature?\n */\n isRequired: boolean;\n /**\n * Parameter name in the SDK method signature.\n */\n name: string;\n /**\n * If the name was modified due to conflicts, this holds the original name.\n */\n originalName?: string;\n /**\n * Parameter schema object.\n */\n schema: IR.SchemaObject;\n};\n\ntype SignatureParameters = Record<string, SignatureParameter>;\n\ntype Signature = {\n fields: ReadonlyArray<Field>;\n parameters: SignatureParameters;\n};\n\n/**\n * Collects and resolves all operation parameters for flattened SDK signatures.\n * - Prefixes all conflicting names with their location (e.g. path_foo, query_foo)\n * - Returns a flat map of resolved parameter names to their metadata\n */\nexport const getSignatureParameters = ({\n operation,\n}: {\n operation: IR.OperationObject;\n plugin: PluginInstance;\n}): Signature | undefined => {\n // TODO: add cookies\n const locations = [\n 'header',\n 'path',\n 'query',\n ] as const satisfies ReadonlyArray<Location>;\n const nameToLocations: Record<string, Set<Location>> = {};\n\n const addParameter = (name: string, location: Location): void => {\n if (!nameToLocations[name]) {\n nameToLocations[name] = new Set();\n }\n nameToLocations[name].add(location);\n };\n\n for (const location of locations) {\n const parameters = operation.parameters?.[location];\n if (parameters) {\n for (const key in parameters) {\n const parameter = parameters[key]!;\n addParameter(parameter.name, location);\n }\n }\n }\n\n if (operation.body) {\n // spread body if there's only a single object\n if (\n !operation.body.schema.logicalOperator &&\n operation.body.schema.type === 'object' &&\n operation.body.schema.properties\n ) {\n const properties = operation.body.schema.properties;\n for (const key in properties) {\n addParameter(key, 'body');\n }\n } else if (operation.body.schema.$ref) {\n // alias body for more ergonomic naming, e.g. user if the type is User\n const name = refToName(operation.body.schema.$ref);\n const key = stringCase({ case: 'camelCase', value: name });\n addParameter(key, 'body');\n } else {\n addParameter('body', 'body');\n }\n }\n\n const conflicts = new Set<string>();\n for (const name in nameToLocations) {\n if (nameToLocations[name]!.size > 1) {\n conflicts.add(name);\n }\n }\n\n const signatureParameters: SignatureParameters = {};\n const fields: Array<Field> = [];\n\n for (const location of locations) {\n const parameters = operation.parameters?.[location];\n if (parameters) {\n for (const key in parameters) {\n const parameter = parameters[key]!;\n const originalName = parameter.name;\n const name = conflicts.has(originalName)\n ? `${location}_${originalName}`\n : originalName;\n const signatureParameter: SignatureParameter = {\n isRequired: parameter.required ?? false,\n name,\n schema: parameter.schema,\n };\n if (name !== originalName) {\n signatureParameter.originalName = originalName;\n }\n signatureParameters[name] = signatureParameter;\n fields.push({\n in: location === 'header' ? 'headers' : location,\n key: name,\n ...(name !== originalName ? { map: originalName } : {}),\n });\n }\n }\n }\n\n if (operation.body) {\n const location = 'body';\n if (\n !operation.body.schema.logicalOperator &&\n operation.body.schema.type === 'object' &&\n operation.body.schema.properties\n ) {\n const properties = operation.body.schema.properties;\n for (const originalName in properties) {\n const property = properties[originalName]!;\n const name = conflicts.has(originalName)\n ? `${location}_${originalName}`\n : originalName;\n const signatureParameter: SignatureParameter = {\n isRequired: property.required?.includes(originalName) ?? false,\n name,\n schema: property,\n };\n if (name !== originalName) {\n signatureParameter.originalName = originalName;\n }\n signatureParameters[name] = signatureParameter;\n fields.push({\n in: location,\n key: name,\n ...(name !== originalName ? { map: originalName } : {}),\n });\n }\n } else if (operation.body.schema.$ref) {\n const value = refToName(operation.body.schema.$ref);\n const originalName = stringCase({ case: 'camelCase', value });\n const name = conflicts.has(originalName)\n ? `${location}_${originalName}`\n : originalName;\n const signatureParameter: SignatureParameter = {\n isRequired: operation.body.required ?? false,\n name,\n schema: operation.body.schema,\n };\n if (name !== originalName) {\n signatureParameter.originalName = originalName;\n }\n signatureParameters[name] = signatureParameter;\n fields.push({\n key: name,\n map: 'body',\n });\n } else {\n // never alias body\n signatureParameters.body = {\n isRequired: operation.body.required ?? false,\n name: 'body',\n schema: operation.body.schema,\n };\n fields.push({ in: 'body' });\n }\n }\n\n if (!Object.keys(signatureParameters).length) {\n return;\n }\n\n return { fields, parameters: signatureParameters };\n};\n","import type { IR } from '~/ir/types';\nimport type { $ } from '~/ts-dsl';\n\nimport type { HeyApiSdkPlugin } from '../types';\n\ninterface ValidatorProps {\n operation: IR.OperationObject;\n plugin: HeyApiSdkPlugin['Instance'];\n}\n\nexport const createRequestValidator = ({\n operation,\n plugin,\n}: ValidatorProps): ReturnType<typeof $.func> | undefined => {\n if (!plugin.config.validator.request) return;\n\n const validator = plugin.getPluginOrThrow(plugin.config.validator.request);\n if (!validator.api.createRequestValidator) return;\n\n return validator.api.createRequestValidator({\n operation,\n // @ts-expect-error\n plugin: validator,\n });\n};\n\nexport const createResponseValidator = ({\n operation,\n plugin,\n}: ValidatorProps): ReturnType<typeof $.func> | undefined => {\n if (!plugin.config.validator.response) return;\n\n const validator = plugin.getPluginOrThrow(plugin.config.validator.response);\n if (!validator.api.createResponseValidator) return;\n\n return validator.api.createResponseValidator({\n operation,\n // @ts-expect-error\n plugin: validator,\n });\n};\n","import type { SymbolMeta } from '@hey-api/codegen-core';\n\nimport type { Context } from '~/ir/context';\nimport { statusCodeToGroup } from '~/ir/operation';\nimport type { IR } from '~/ir/types';\nimport { sanitizeNamespaceIdentifier } from '~/openApi/common/parser/sanitize';\nimport { getClientPlugin } from '~/plugins/@hey-api/client-core/utils';\nimport { toRefs } from '~/plugins/shared/utils/refs';\nimport { $ } from '~/ts-dsl';\nimport { reservedJavaScriptKeywordsRegExp } from '~/utils/regexp';\nimport { stringCase } from '~/utils/stringCase';\nimport { transformClassName } from '~/utils/transform';\n\nimport type { Field, Fields } from '../../client-core/bundle/params';\nimport type { HeyApiSdkPlugin } from '../types';\nimport { operationAuth } from './auth';\nimport { nuxtTypeComposable, nuxtTypeDefault } from './constants';\nimport { getSignatureParameters } from './signature';\nimport { createRequestValidator, createResponseValidator } from './validator';\n\ninterface ClassNameEntry {\n /**\n * Name of the class where this function appears.\n */\n className: string;\n /**\n * Name of the function within the class.\n */\n methodName: string;\n /**\n * JSONPath-like array to class location.\n */\n path: ReadonlyArray<string>;\n}\n\nconst operationClassName = ({\n context,\n value,\n}: {\n context: Context;\n value: string;\n}) => {\n const name = stringCase({\n case: 'PascalCase',\n value: sanitizeNamespaceIdentifier(value),\n });\n return transformClassName({\n config: context.config,\n name,\n });\n};\n\nconst getOperationMethodName = ({\n operation,\n plugin,\n}: {\n operation: IR.OperationObject;\n plugin: {\n config: Pick<\n HeyApiSdkPlugin['Instance']['config'],\n 'asClass' | 'methodNameBuilder'\n >;\n };\n}) => {\n if (plugin.config.methodNameBuilder) {\n return plugin.config.methodNameBuilder(operation);\n }\n\n const handleIllegal = !plugin.config.asClass;\n if (handleIllegal && operation.id.match(reservedJavaScriptKeywordsRegExp)) {\n return `${operation.id}_`;\n }\n\n return operation.id;\n};\n\n/**\n * Returns a list of classes where this operation appears in the generated SDK.\n */\nexport const operationClasses = ({\n context,\n operation,\n plugin,\n}: {\n context: Context;\n operation: IR.OperationObject;\n plugin: {\n config: Pick<\n HeyApiSdkPlugin['Instance']['config'],\n 'asClass' | 'classStructure' | 'instance'\n >;\n };\n}): Map<string, ClassNameEntry> => {\n const classNames = new Map<string, ClassNameEntry>();\n\n let className: string | undefined;\n let methodName: string | undefined;\n let classCandidates: Array<string> = [];\n\n if (plugin.config.classStructure === 'auto' && operation.operationId) {\n classCandidates = operation.operationId.split(/[./]/).filter(Boolean);\n if (classCandidates.length > 1) {\n const methodCandidate = classCandidates.pop()!;\n methodName = stringCase({\n case: 'camelCase',\n value: sanitizeNamespaceIdentifier(methodCandidate),\n });\n className = classCandidates.pop()!;\n }\n }\n\n const rootClasses = plugin.config.instance\n ? [plugin.config.instance as string]\n : (operation.tags ?? ['default']);\n\n for (const rootClass of rootClasses) {\n const finalClassName = operationClassName({\n context,\n value: className || rootClass,\n });\n\n // Default path\n let path = [rootClass];\n if (className) {\n // If root class is already within classCandidates or the same as className\n // do not add it again as this will cause a recursion issue.\n if (classCandidates.includes(rootClass) || rootClass === className) {\n path = [...classCandidates, className];\n } else {\n path = [rootClass, ...classCandidates, className];\n }\n }\n\n classNames.set(rootClass, {\n className: finalClassName,\n methodName: methodName || getOperationMethodName({ operation, plugin }),\n path: path.map((value) =>\n operationClassName({\n context,\n value,\n }),\n ),\n });\n }\n\n return classNames;\n};\n\n/** TODO: needs complete refactor */\nexport const operationOptionsType = ({\n isDataAllowed = true,\n operation,\n plugin,\n throwOnError,\n}: {\n isDataAllowed?: boolean;\n operation: IR.OperationObject;\n plugin: HeyApiSdkPlugin['Instance'];\n throwOnError?: string;\n}) => {\n const client = getClientPlugin(plugin.context.config);\n const isNuxtClient = client.name === '@hey-api/client-nuxt';\n\n const symbolDataType = isDataAllowed\n ? plugin.querySymbol({\n category: 'type',\n resource: 'operation',\n resourceId: operation.id,\n role: 'data',\n tool: 'typescript',\n })\n : undefined;\n\n const symbolOptions = plugin.referenceSymbol({\n category: 'type',\n resource: 'client-options',\n tool: 'sdk',\n });\n\n if (isNuxtClient) {\n const symbolResponseType = plugin.querySymbol({\n category: 'type',\n resource: 'operation',\n resourceId: operation.id,\n role: 'response',\n });\n const dataType = isDataAllowed\n ? symbolDataType?.placeholder || 'unknown'\n : 'never';\n const responseType = symbolResponseType?.placeholder || 'unknown';\n return `${symbolOptions.placeholder}<${nuxtTypeComposable}, ${dataType}, ${responseType}, ${nuxtTypeDefault}>`;\n }\n\n // TODO: refactor this to be more generic, works for now\n if (throwOnError) {\n const dataType = isDataAllowed\n ? symbolDataType?.placeholder || 'unknown'\n : 'never';\n return `${symbolOptions.placeholder}<${dataType}, ${throwOnError}>`;\n }\n const dataType = isDataAllowed ? symbolDataType?.placeholder : 'never';\n return dataType\n ? `${symbolOptions.placeholder}<${dataType}>`\n : symbolOptions.placeholder;\n};\n\ntype OperationParameters = {\n argNames: Array<string>;\n fields: Array<Field | Fields>;\n parameters: Array<ReturnType<typeof $.param>>;\n};\n\nexport const operationParameters = ({\n isRequiredOptions,\n operation,\n plugin,\n}: {\n isRequiredOptions: boolean;\n operation: IR.OperationObject;\n plugin: HeyApiSdkPlugin['Instance'];\n}): OperationParameters => {\n const result: OperationParameters = {\n argNames: [],\n fields: [],\n parameters: [],\n };\n\n const pluginTypeScript = plugin.getPluginOrThrow('@hey-api/typescript');\n const client = getClientPlugin(plugin.context.config);\n const isNuxtClient = client.name === '@hey-api/client-nuxt';\n\n if (plugin.config.paramsStructure === 'flat') {\n const signature = getSignatureParameters({ operation, plugin });\n const flatParams = $.type.object();\n\n if (signature) {\n let isParametersRequired = false;\n\n for (const key in signature.parameters) {\n const parameter = signature.parameters[key]!;\n if (parameter.isRequired) {\n isParametersRequired = true;\n }\n flatParams.prop(parameter.name, (p) =>\n p.required(parameter.isRequired).type(\n pluginTypeScript.api.schemaToType({\n plugin: pluginTypeScript,\n schema: parameter.schema,\n state: toRefs({\n path: [],\n }),\n }),\n ),\n );\n }\n\n result.argNames.push('parameters');\n for (const field of signature.fields) {\n result.fields.push(field);\n }\n\n result.parameters.push(\n $.param('parameters', (p) =>\n p.required(isParametersRequired).type(flatParams),\n ),\n );\n }\n }\n\n result.parameters.push(\n $.param('options', (p) =>\n p.required(isRequiredOptions).type(\n operationOptionsType({\n isDataAllowed: plugin.config.paramsStructure === 'grouped',\n operation,\n plugin,\n throwOnError: isNuxtClient ? undefined : 'ThrowOnError',\n }),\n ),\n ),\n );\n\n return result;\n};\n\n/**\n * Infers `responseType` value from provided response content type. This is\n * an adapted version of `getParseAs()` from the Fetch API client.\n *\n * From Axios documentation:\n * `responseType` indicates the type of data that the server will respond with\n * options are: 'arraybuffer', 'document', 'json', 'text', 'stream'\n * browser only: 'blob'\n */\nconst getResponseType = (\n contentType: string | null | undefined,\n):\n | 'arraybuffer'\n | 'blob'\n | 'document'\n | 'json'\n | 'stream'\n | 'text'\n | undefined => {\n if (!contentType) {\n return;\n }\n\n const cleanContent = contentType.split(';')[0]?.trim();\n\n if (!cleanContent) {\n return;\n }\n\n if (\n cleanContent.startsWith('application/json') ||\n cleanContent.endsWith('+json')\n ) {\n return 'json';\n }\n\n // Axios does not handle form data out of the box\n // if (cleanContent === 'multipart/form-data') {\n // return 'formData';\n // }\n\n if (\n ['application/', 'audio/', 'image/', 'video/'].some((type) =>\n cleanContent.startsWith(type),\n )\n ) {\n return 'blob';\n }\n\n if (cleanContent.startsWith('text/')) {\n return 'text';\n }\n\n return;\n};\n\nexport const operationStatements = ({\n isRequiredOptions,\n opParameters,\n operation,\n plugin,\n}: {\n isRequiredOptions: boolean;\n opParameters: OperationParameters;\n operation: IR.OperationObject;\n plugin: HeyApiSdkPlugin['Instance'];\n}): Array<ReturnType<typeof $.return | typeof $.const>> => {\n const client = getClientPlugin(plugin.context.config);\n const isNuxtClient = client.name === '@hey-api/client-nuxt';\n\n const symbolResponseType = plugin.querySymbol({\n category: 'type',\n resource: 'operation',\n resourceId: operation.id,\n role: isNuxtClient ? 'response' : 'responses',\n });\n const responseType = symbolResponseType?.placeholder || 'unknown';\n\n const symbolErrorType = plugin.querySymbol({\n category: 'type',\n resource: 'operation',\n resourceId: operation.id,\n role: isNuxtClient ? 'error' : 'errors',\n });\n const errorType = symbolErrorType?.placeholder || 'unknown';\n\n // TODO: transform parameters\n // const query = {\n // BarBaz: options.query.bar_baz,\n // qux_quux: options.query.qux_quux,\n // fooBar: options.query.foo_bar,\n // };\n\n // if (operation.parameters) {\n // for (const name in operation.parameters.query) {\n // const parameter = operation.parameters.query[name]\n // if (parameter.name !== fieldName({ context, name: parameter.name })) {\n // console.warn(parameter.name)\n // }\n // }\n // }\n\n const reqOptions = $.object();\n\n if (operation.body) {\n switch (operation.body.type) {\n case 'form-data': {\n const symbol = plugin.referenceSymbol({\n category: 'external',\n resource: 'client.formDataBodySerializer',\n });\n reqOptions.spread(symbol.placeholder);\n break;\n }\n case 'json':\n // jsonBodySerializer is the default, no need to specify\n break;\n case 'text':\n case 'octet-stream':\n // ensure we don't use any serializer by default\n reqOptions.prop('bodySerializer', $.literal(null));\n break;\n case 'url-search-params': {\n const symbol = plugin.referenceSymbol({\n category: 'external',\n resource: 'client.urlSearchParamsBodySerializer',\n });\n reqOptions.spread(symbol.placeholder);\n break;\n }\n }\n }\n\n // TODO: parser - set parseAs to skip inference if every response has the same\n // content type. currently impossible because successes do not contain\n // header information\n\n const paramSerializers = $.object();\n\n for (const name in operation.parameters?.query) {\n const parameter = operation.parameters.query[name]!;\n\n if (\n parameter.schema.type === 'array' ||\n parameter.schema.type === 'tuple'\n ) {\n if (parameter.style !== 'form' || !parameter.explode) {\n // override the default settings for array serialization\n paramSerializers.prop(\n parameter.name,\n $.object().prop(\n 'array',\n $.object()\n .$if(parameter.explode === false, (o) =>\n o.prop('explode', $.literal(parameter.explode)),\n )\n .$if(parameter.style !== 'form', (o) =>\n o.prop('style', $.literal(parameter.style)),\n ),\n ),\n );\n }\n } else if (parameter.schema.type === 'object') {\n if (parameter.style !== 'deepObject' || !parameter.explode) {\n // override the default settings for object serialization\n paramSerializers.prop(\n parameter.name,\n $.object().prop(\n 'object',\n $.object()\n .$if(parameter.explode === false, (o) =>\n o.prop('explode', $.literal(parameter.explode)),\n )\n .$if(parameter.style !== 'deepObject', (o) =>\n o.prop('style', $.literal(parameter.style)),\n ),\n ),\n );\n }\n }\n }\n\n if (paramSerializers.hasProps()) {\n // TODO: if all parameters have the same serialization,\n // apply it globally to reduce output size\n reqOptions.prop(\n 'querySerializer',\n $.object().prop('parameters', paramSerializers),\n );\n }\n\n const requestValidator = createRequestValidator({ operation, plugin });\n const responseValidator = createResponseValidator({ operation, plugin });\n if (requestValidator) {\n reqOptions.prop('requestValidator', requestValidator.arrow());\n }\n\n if (plugin.config.transformer) {\n const query: SymbolMeta = {\n category: 'transform',\n resource: 'operation',\n resourceId: operation.id,\n role: 'response',\n };\n if (plugin.isSymbolRegistered(query)) {\n const ref = plugin.referenceSymbol(query);\n reqOptions.prop('responseTransformer', $(ref.placeholder));\n }\n }\n\n let hasServerSentEvents = false;\n let responseTypeValue: ReturnType<typeof getResponseType> | undefined;\n\n for (const statusCode in operation.responses) {\n const response = operation.responses[statusCode]!;\n\n // try to infer `responseType` option for Axios. We don't need this in\n // Fetch API client because it automatically detects the correct response\n // during runtime.\n if (!responseTypeValue && client.name === '@hey-api/client-axios') {\n // this doesn't handle default status code for now\n if (statusCodeToGroup({ statusCode }) === '2XX') {\n responseTypeValue = getResponseType(response.mediaType);\n if (responseTypeValue) {\n reqOptions.prop('responseType', $.literal(responseTypeValue));\n }\n }\n }\n\n if (response.mediaType === 'text/event-stream') {\n hasServerSentEvents = true;\n }\n }\n\n if (responseValidator) {\n reqOptions.prop('responseValidator', responseValidator.arrow());\n }\n\n if (plugin.config.responseStyle === 'data') {\n reqOptions.prop('responseStyle', $.literal(plugin.config.responseStyle));\n }\n\n const auth = operationAuth({ context: plugin.context, operation, plugin });\n if (auth.length) {\n reqOptions.prop('security', $.fromValue(auth));\n }\n\n reqOptions.prop('url', $.literal(operation.path));\n\n // options must go last to allow overriding parameters above\n reqOptions.spread('options');\n\n const statements: Array<ReturnType<typeof $.return | typeof $.const>> = [];\n const hasParams = opParameters.argNames.length;\n\n if (hasParams) {\n const args: Array<ReturnType<typeof $.expr>> = [];\n const config: Array<ReturnType<typeof $.object>> = [];\n for (const argName of opParameters.argNames) {\n args.push($(argName));\n }\n for (const field of opParameters.fields) {\n const shape = $.object();\n if ('in' in field) {\n shape.prop('in', $.literal(field.in));\n }\n if ('key' in field) {\n if (field.key) {\n shape.prop('key', $.literal(field.key));\n }\n if (field.map) {\n shape.prop('map', $.literal(field.map));\n }\n }\n config.push(shape);\n }\n const symbol = plugin.referenceSymbol({\n category: 'external',\n resource: 'client.buildClientParams',\n });\n statements.push(\n $.const('params').assign(\n $(symbol.placeholder).call(\n $.array(...args),\n $.array($.object().prop('args', $.array(...config))),\n ),\n ),\n );\n reqOptions.spread('params');\n }\n\n if (operation.body) {\n const parameterContentType = operation.parameters?.header?.['content-type'];\n const hasRequiredContentType = Boolean(parameterContentType?.required);\n // spreading required Content-Type on generated header would throw a TypeScript error\n if (!hasRequiredContentType) {\n const headers = $.object()\n .pretty()\n // form-data does not need Content-Type header, browser will set it automatically\n .prop(\n parameterContentType?.name ?? 'Content-Type',\n $.literal(\n operation.body.type === 'form-data'\n ? null\n : operation.body.mediaType,\n ),\n )\n .spread($('options').attr('headers').required(isRequiredOptions));\n if (hasParams) {\n headers.spread($('params').attr('headers'));\n }\n reqOptions.prop('headers', headers);\n }\n }\n\n const symbolClient = plugin.config.client\n ? plugin.getSymbol({\n category: 'client',\n })\n : undefined;\n\n let clientExpression: ReturnType<typeof $.attr | typeof $.binary>;\n const optionsClient = $('options').attr('client').required(isRequiredOptions);\n if (plugin.config.instance) {\n clientExpression = optionsClient.coalesce($('this').attr('client'));\n } else if (symbolClient) {\n clientExpression = optionsClient.coalesce(symbolClient.placeholder);\n } else {\n clientExpression = optionsClient;\n }\n\n let functionName = hasServerSentEvents\n ? clientExpression.attr('sse')\n : clientExpression;\n functionName = functionName.attr(operation.method);\n\n statements.push(\n $.return(\n functionName\n .call(reqOptions)\n .$if(\n isNuxtClient,\n (f) =>\n f\n .generic(nuxtTypeComposable)\n .generic(`${responseType} | ${nuxtTypeDefault}`)\n .generic(errorType)\n .generic(nuxtTypeDefault),\n (f) =>\n f.generic(responseType).generic(errorType).generic('ThrowOnError'),\n )\n .$if(plugin.config.responseStyle === 'data', (f) =>\n f.generic($.type.literal(plugin.config.responseStyle)),\n ),\n ),\n );\n\n return statements;\n};\n","import { EOL } from 'node:os';\n\nimport { validTypescriptIdentifierRegExp } from './regexp';\n\nexport const escapeName = (value: string): string => {\n if (value || value === '') {\n validTypescriptIdentifierRegExp.lastIndex = 0;\n const validName = validTypescriptIdentifierRegExp.test(value);\n if (!validName) {\n return `'${value}'`;\n }\n }\n return value;\n};\n\nexport const unescapeName = (value: string): string => {\n if (value && value.startsWith(\"'\") && value.endsWith(\"'\")) {\n return value.slice(1, value.length - 1);\n }\n return value;\n};\n\nexport const escapeComment = (value: string) =>\n value\n .replace(/\\*\\//g, '*')\n .replace(/\\/\\*/g, '*')\n .replace(/\\r?\\n(.*)/g, (_l, w) => EOL + w.trim());\n","import type { Context } from '~/ir/context';\nimport { hasOperationDataRequired } from '~/ir/operation';\nimport type { IR } from '~/ir/types';\nimport { getClientPlugin } from '~/plugins/@hey-api/client-core/utils';\nimport { escapeComment } from '~/utils/escape';\n\nexport const createOperationComment = (\n operation: IR.OperationObject,\n): ReadonlyArray<string> | undefined => {\n const comments: Array<string> = [];\n\n if (operation.summary) {\n comments.push(escapeComment(operation.summary));\n }\n\n if (operation.description) {\n if (comments.length) {\n comments.push(''); // Add an empty line between summary and description\n }\n\n comments.push(escapeComment(operation.description));\n }\n\n if (operation.deprecated) {\n if (comments.length) {\n comments.push(''); // Add an empty line before deprecated\n }\n\n comments.push('@deprecated');\n }\n\n return comments.length ? comments : undefined;\n};\n\nexport const isOperationOptionsRequired = ({\n context,\n operation,\n}: {\n context: Context;\n operation: IR.OperationObject;\n}): boolean => {\n const client = getClientPlugin(context.config);\n const isNuxtClient = client.name === '@hey-api/client-nuxt';\n const plugin = context.config.plugins['@hey-api/sdk'];\n if (plugin) {\n if (!plugin.config.client && !plugin.config.instance) {\n return true;\n }\n if (plugin.config.paramsStructure === 'flat') {\n return false;\n }\n }\n return isNuxtClient || hasOperationDataRequired(operation);\n};\n\nexport const hasOperationSse = ({\n operation,\n}: {\n operation: IR.OperationObject;\n}): boolean => {\n for (const statusCode in operation.responses) {\n const response = operation.responses[statusCode]!;\n if (response.mediaType === 'text/event-stream') {\n return true;\n }\n }\n return false;\n};\n","import type { Symbol } from '@hey-api/codegen-core';\n\nimport type { IR } from '~/ir/types';\nimport { buildName } from '~/openApi/shared/utils/name';\nimport { operationClasses } from '~/plugins/@hey-api/sdk/shared/operation';\nimport {\n createOperationComment,\n isOperationOptionsRequired,\n} from '~/plugins/shared/utils/operation';\nimport { $ } from '~/ts-dsl';\nimport { stringCase } from '~/utils/stringCase';\n\nimport type { AngularCommonPlugin } from './types';\n\ninterface AngularRequestClassEntry {\n className: string;\n classes: Set<string>;\n methods: Set<string>;\n nodes: Array<ReturnType<typeof $.method | typeof $.field | typeof $.newline>>;\n root: boolean;\n}\n\nconst generateAngularClassRequests = ({\n plugin,\n}: {\n plugin: AngularCommonPlugin['Instance'];\n}) => {\n const requestClasses = new Map<string, AngularRequestClassEntry>();\n const generatedClasses = new Set<string>();\n\n const sdkPlugin = plugin.getPluginOrThrow('@hey-api/sdk');\n\n plugin.forEach(\n 'operation',\n ({ operation }) => {\n const isRequiredOptions = isOperationOptionsRequired({\n context: plugin.context,\n operation,\n });\n\n const classes = operationClasses({\n context: plugin.context,\n operation,\n plugin: sdkPlugin,\n });\n\n for (const entry of classes.values()) {\n entry.path.forEach((currentClassName, index) => {\n if (!requestClasses.has(currentClassName)) {\n requestClasses.set(currentClassName, {\n className: currentClassName,\n classes: new Set(),\n methods: new Set(),\n nodes: [],\n root: !index,\n });\n }\n\n const parentClassName = entry.path[index - 1];\n if (parentClassName && parentClassName !== currentClassName) {\n const parentClass = requestClasses.get(parentClassName)!;\n parentClass.classes.add(currentClassName);\n requestClasses.set(parentClassName, parentClass);\n }\n\n const isLast = entry.path.length === index + 1;\n if (!isLast) {\n return;\n }\n\n const currentClass = requestClasses.get(currentClassName)!;\n\n const requestMethodName =\n plugin.config.httpRequests.methodNameBuilder(operation);\n\n if (currentClass.methods.has(requestMethodName)) {\n return;\n }\n\n const methodNode = generateAngularRequestMethod({\n isRequiredOptions,\n methodName: requestMethodName,\n operation,\n plugin,\n });\n\n if (!currentClass.nodes.length) {\n currentClass.nodes.push(methodNode);\n } else {\n currentClass.nodes.push($.newline(), methodNode);\n }\n\n currentClass.methods.add(requestMethodName);\n requestClasses.set(currentClassName, currentClass);\n });\n }\n },\n {\n order: 'declarations',\n },\n );\n\n const generateClass = (currentClass: AngularRequestClassEntry) => {\n if (generatedClasses.has(currentClass.className)) {\n return;\n }\n\n if (currentClass.classes.size) {\n for (const childClassName of currentClass.classes) {\n const childClass = requestClasses.get(childClassName)!;\n generateClass(childClass);\n\n currentClass.nodes.push(\n $.field(\n stringCase({ case: 'camelCase', value: childClass.className }),\n ).assign(\n $.new(\n buildName({\n config: {\n case: 'preserve',\n name: plugin.config.httpRequests.classNameBuilder,\n },\n name: childClass.className,\n }),\n ),\n ),\n );\n }\n }\n\n const symbolInjectable = plugin.referenceSymbol({\n category: 'external',\n resource: '@angular/core.Injectable',\n });\n const symbolClass = plugin.registerSymbol({\n exported: true,\n meta: {\n category: 'utility',\n resource: 'class',\n resourceId: currentClass.className,\n tool: 'angular',\n },\n name: buildName({\n config: {\n case: 'preserve',\n name: plugin.config.httpRequests.classNameBuilder,\n },\n name: currentClass.className,\n }),\n });\n const node = $.class(symbolClass.placeholder)\n .export(symbolClass.exported)\n .$if(currentClass.root, (c) =>\n c.decorator(\n symbolInjectable.placeholder,\n $.object().prop('providedIn', $.literal('root')),\n ),\n )\n .do(...currentClass.nodes);\n plugin.setSymbolValue(symbolClass, node);\n\n generatedClasses.add(currentClass.className);\n };\n\n for (const requestClass of requestClasses.values()) {\n generateClass(requestClass);\n }\n};\n\nconst generateAngularFunctionRequests = ({\n plugin,\n}: {\n plugin: AngularCommonPlugin['Instance'];\n}) => {\n plugin.forEach(\n 'operation',\n ({ operation }) => {\n const isRequiredOptions = isOperationOptionsRequired({\n context: plugin.context,\n operation,\n });\n\n const symbol = plugin.registerSymbol({\n exported: true,\n meta: {\n category: 'utility',\n resource: 'operation',\n resourceId: operation.id,\n role: 'data',\n tool: 'angular',\n },\n name: plugin.config.httpRequests.methodNameBuilder(operation),\n });\n const node = generateAngularRequestFunction({\n isRequiredOptions,\n operation,\n plugin,\n symbol,\n });\n plugin.setSymbolValue(symbol, node);\n },\n {\n order: 'declarations',\n },\n );\n};\n\nconst generateRequestCallExpression = ({\n operation,\n plugin,\n}: {\n operation: IR.OperationObject;\n plugin: AngularCommonPlugin['Instance'];\n}) => {\n const symbolClient = plugin.getSymbol({\n category: 'client',\n });\n\n const optionsClient = $('options')\n .attr('client')\n .optional()\n .$if(symbolClient, (c, s) => c.coalesce(s.placeholder));\n\n return optionsClient\n .attr('requestOptions')\n .call(\n $.object()\n .prop('responseStyle', $.literal('data'))\n .prop('method', $.literal(operation.method.toUpperCase()))\n .prop('url', $.literal(operation.path))\n .spread('options'),\n );\n};\n\nconst generateAngularRequestMethod = ({\n isRequiredOptions,\n methodName,\n operation,\n plugin,\n}: {\n isRequiredOptions: boolean;\n methodName: string;\n operation: IR.OperationObject;\n plugin: AngularCommonPlugin['Instance'];\n}) => {\n const symbolHttpRequest = plugin.referenceSymbol({\n category: 'external',\n resource: '@angular/common/http.HttpRequest',\n });\n\n const symbolOptions = plugin.referenceSymbol({\n category: 'type',\n resource: 'client-options',\n tool: 'sdk',\n });\n\n const symbolDataType = plugin.querySymbol({\n category: 'type',\n resource: 'operation',\n resourceId: operation.id,\n role: 'data',\n tool: 'typescript',\n });\n const dataType = symbolDataType?.placeholder || 'unknown';\n\n return $.method(methodName)\n .public()\n .$if(createOperationComment(operation), (c, v) => c.doc(v))\n .param('options', (p) =>\n p\n .required(isRequiredOptions)\n .type(`${symbolOptions.placeholder}<${dataType}, ThrowOnError>`),\n )\n .generic('ThrowOnError', (g) => g.extends('boolean').default(false))\n .returns(`${symbolHttpRequest.placeholder}<unknown>`)\n .do(\n $.return(\n generateRequestCallExpression({\n operation,\n plugin,\n }),\n ),\n );\n};\n\nconst generateAngularRequestFunction = ({\n isRequiredOptions,\n operation,\n plugin,\n symbol,\n}: {\n isRequiredOptions: boolean;\n operation: IR.OperationObject;\n plugin: AngularCommonPlugin['Instance'];\n symbol: Symbol;\n}) => {\n const symbolHttpRequest = plugin.referenceSymbol({\n category: 'external',\n resource: '@angular/common/http.HttpRequest',\n });\n\n const symbolOptions = plugin.referenceSymbol({\n category: 'type',\n resource: 'client-options',\n tool: 'sdk',\n });\n\n const symbolDataType = plugin.querySymbol({\n category: 'type',\n resource: 'operation',\n resourceId: operation.id,\n role: 'data',\n tool: 'typescript',\n });\n const dataType = symbolDataType?.placeholder || 'unknown';\n\n return $.const(symbol.placeholder)\n .export(symbol.exported)\n .$if(createOperationComment(operation), (c, v) => c.doc(v))\n .assign(\n $.func()\n .param('options', (p) =>\n p\n .required(isRequiredOptions)\n .type(`${symbolOptions.placeholder}<${dataType}, ThrowOnError>`),\n )\n .generic('ThrowOnError', (g) => g.extends('boolean').default(false))\n .returns(`${symbolHttpRequest.placeholder}<unknown>`)\n .do(\n $.return(\n generateRequestCallExpression({\n operation,\n plugin,\n }),\n ),\n ),\n );\n};\n\nexport const createHttpRequests: AngularCommonPlugin['Handler'] = ({\n plugin,\n}) => {\n if (plugin.config.httpRequests.asClass) {\n generateAngularClassRequests({ plugin });\n } else {\n generateAngularFunctionRequests({ plugin });\n }\n};\n","import type { Symbol } from '@hey-api/codegen-core';\n\nimport type { IR } from '~/ir/types';\nimport { buildName } from '~/openApi/shared/utils/name';\nimport { operationClasses } from '~/plugins/@hey-api/sdk/shared/operation';\nimport {\n createOperationComment,\n isOperationOptionsRequired,\n} from '~/plugins/shared/utils/operation';\nimport { $ } from '~/ts-dsl';\nimport { stringCase } from '~/utils/stringCase';\n\nimport type { AngularCommonPlugin } from './types';\n\ninterface AngularServiceClassEntry {\n className: string;\n classes: Set<string>;\n methods: Set<string>;\n nodes: Array<ReturnType<typeof $.method | typeof $.field | typeof $.newline>>;\n root: boolean;\n}\n\nconst generateAngularClassServices = ({\n plugin,\n}: {\n plugin: AngularCommonPlugin['Instance'];\n}) => {\n const serviceClasses = new Map<string, AngularServiceClassEntry>();\n const generatedClasses = new Set<string>();\n\n const sdkPlugin = plugin.getPluginOrThrow('@hey-api/sdk');\n\n plugin.forEach(\n 'operation',\n ({ operation }) => {\n const isRequiredOptions = isOperationOptionsRequired({\n context: plugin.context,\n operation,\n });\n\n const classes = operationClasses({\n context: plugin.context,\n operation,\n plugin: sdkPlugin,\n });\n\n for (const entry of classes.values()) {\n entry.path.forEach((currentClassName, index) => {\n if (!serviceClasses.has(currentClassName)) {\n serviceClasses.set(currentClassName, {\n className: currentClassName,\n classes: new Set(),\n methods: new Set(),\n nodes: [],\n root: !index,\n });\n }\n\n const parentClassName = entry.path[index - 1];\n if (parentClassName && parentClassName !== currentClassName) {\n const parentClass = serviceClasses.get(parentClassName)!;\n parentClass.classes.add(currentClassName);\n serviceClasses.set(parentClassName, parentClass);\n }\n\n const isLast = entry.path.length === index + 1;\n if (!isLast) {\n return;\n }\n\n const currentClass = serviceClasses.get(currentClassName)!;\n\n const resourceMethodName =\n plugin.config.httpResources.methodNameBuilder(operation);\n\n if (currentClass.methods.has(resourceMethodName)) {\n return;\n }\n\n const methodNode = generateAngularResourceMethod({\n isRequiredOptions,\n methodName: resourceMethodName,\n operation,\n plugin,\n });\n\n if (!currentClass.nodes.length) {\n currentClass.nodes.push(methodNode);\n } else {\n currentClass.nodes.push($.newline(), methodNode);\n }\n\n currentClass.methods.add(resourceMethodName);\n serviceClasses.set(currentClassName, currentClass);\n });\n }\n },\n {\n order: 'declarations',\n },\n );\n\n const generateClass = (currentClass: AngularServiceClassEntry) => {\n if (generatedClasses.has(currentClass.className)) {\n return;\n }\n\n if (currentClass.classes.size) {\n for (const childClassName of currentClass.classes) {\n const childClass = serviceClasses.get(childClassName)!;\n generateClass(childClass);\n\n currentClass.nodes.push(\n $.field(\n stringCase({\n case: 'camelCase',\n value: childClass.className,\n }),\n ).assign(\n $.new(\n buildName({\n config: {\n case: 'preserve',\n name: plugin.config.httpResources.classNameBuilder,\n },\n name: childClass.className,\n }),\n ),\n ),\n );\n }\n }\n\n const symbolInjectable = plugin.referenceSymbol({\n category: 'external',\n resource: '@angular/core.Injectable',\n });\n const symbolClass = plugin.registerSymbol({\n exported: true,\n name: buildName({\n config: {\n case: 'preserve',\n name: plugin.config.httpResources.classNameBuilder,\n },\n name: currentClass.className,\n }),\n });\n const node = $.class(symbolClass.placeholder)\n .export(symbolClass.exported)\n .$if(currentClass.root, (c) =>\n c.decorator(\n symbolInjectable.placeholder,\n $.object().prop('providedIn', $.literal('root')),\n ),\n )\n .do(...currentClass.nodes);\n plugin.setSymbolValue(symbolClass, node);\n\n generatedClasses.add(currentClass.className);\n };\n\n for (const serviceClass of serviceClasses.values()) {\n generateClass(serviceClass);\n }\n};\n\nconst generateAngularFunctionServices = ({\n plugin,\n}: {\n plugin: AngularCommonPlugin['Instance'];\n}) => {\n plugin.forEach(\n 'operation',\n ({ operation }) => {\n const isRequiredOptions = isOperationOptionsRequired({\n context: plugin.context,\n operation,\n });\n\n const symbol = plugin.registerSymbol({\n exported: true,\n name: plugin.config.httpResources.methodNameBuilder(operation),\n });\n const node = generateAngularResourceFunction({\n isRequiredOptions,\n operation,\n plugin,\n symbol,\n });\n plugin.setSymbolValue(symbol, node);\n },\n {\n order: 'declarations',\n },\n );\n};\n\nconst generateResourceCallExpression = ({\n operation,\n plugin,\n}: {\n operation: IR.OperationObject;\n plugin: AngularCommonPlugin['Instance'];\n}) => {\n const sdkPlugin = plugin.getPluginOrThrow('@hey-api/sdk');\n\n const symbolHttpResource = plugin.referenceSymbol({\n category: 'external',\n resource: '@angular/common/http.httpResource',\n });\n\n const symbolResponseType = plugin.querySymbol({\n category: 'type',\n resource: 'operation',\n resourceId: operation.id,\n role: 'response',\n });\n const responseType = symbolResponseType?.placeholder || 'unknown';\n\n if (plugin.config.httpRequests.asClass) {\n // For class-based request methods, use inject and class hierarchy\n const classes = operationClasses({\n context: plugin.context,\n operation,\n plugin: sdkPlugin,\n });\n\n const firstEntry = Array.from(classes.values())[0];\n if (firstEntry) {\n // Import the root class from HTTP requests\n const rootClassName = firstEntry.path[0]!;\n const symbolClass = plugin.referenceSymbol({\n category: 'utility',\n resource: 'class',\n resourceId: rootClassName,\n tool: 'angular',\n });\n\n // Build the method access path using inject\n const symbolInject = plugin.referenceSymbol({\n category: 'external',\n resource: '@angular/core.inject',\n });\n let methodAccess: ReturnType<typeof $.attr | typeof $.call> = $(\n symbolInject.placeholder,\n ).call(symbolClass.placeholder);\n\n // Navigate through the class hierarchy\n for (let i = 1; i < firstEntry.path.length; i++) {\n const className = firstEntry.path[i];\n if (className) {\n methodAccess = methodAccess.attr(\n stringCase({\n case: 'camelCase',\n value: className,\n }),\n );\n }\n }\n\n methodAccess = methodAccess.attr(\n plugin.config.httpRequests.methodNameBuilder(operation),\n );\n\n return $(symbolHttpResource.placeholder)\n .call(\n $.func().do(\n $.const('opts').assign(\n $.ternary('options')\n .do($('options').call())\n .otherwise($.id('undefined')),\n ),\n $.return(\n $.ternary('opts')\n .do(methodAccess.call('opts'))\n .otherwise($.id('undefined')),\n ),\n ),\n )\n .generic(responseType);\n }\n } else {\n const symbolHttpRequest = plugin.referenceSymbol({\n category: 'utility',\n resource: 'operation',\n resourceId: operation.id,\n role: 'data',\n tool: 'angular',\n });\n\n return $(symbolHttpResource.placeholder)\n .call(\n $.func().do(\n $.const('opts').assign(\n $.ternary('options')\n .do($('options').call())\n .otherwise($.id('undefined')),\n ),\n $.return(\n $.ternary('opts')\n .do($(symbolHttpRequest.placeholder).call('opts'))\n .otherwise($.id('undefined')),\n ),\n ),\n )\n .generic(responseType);\n }\n\n // Fallback return (should not reach here)\n return $(symbolHttpResource.placeholder).call(\n $.func()\n .do($.return($.id('undefined')))\n .generic(responseType),\n );\n};\n\nconst generateAngularResourceMethod = ({\n isRequiredOptions,\n methodName,\n operation,\n plugin,\n}: {\n isRequiredOptions: boolean;\n methodName: string;\n operation: IR.OperationObject;\n plugin: AngularCommonPlugin['Instance'];\n}) => {\n const symbolOptions = plugin.referenceSymbol({\n category: 'type',\n resource: 'client-options',\n tool: 'sdk',\n });\n\n const symbolDataType = plugin.querySymbol({\n category: 'type',\n resource: 'operation',\n resourceId: operation.id,\n role: 'data',\n tool: 'typescript',\n });\n const dataType = symbolDataType?.placeholder || 'unknown';\n\n return $.method(methodName)\n .public()\n .$if(createOperationComment(operation), (c, v) => c.doc(v))\n .param('options', (p) =>\n p\n .required(isRequiredOptions)\n .type(\n `() => ${symbolOptions.placeholder}<${dataType}, ThrowOnError> | undefined`,\n ),\n )\n .generic('ThrowOnError', (g) => g.extends('boolean').default(false))\n .do(\n $.return(\n generateResourceCallExpression({\n operation,\n plugin,\n }),\n ),\n );\n};\n\nconst generateAngularResourceFunction = ({\n isRequiredOptions,\n operation,\n plugin,\n symbol,\n}: {\n isRequiredOptions: boolean;\n operation: IR.OperationObject;\n plugin: AngularCommonPlugin['Instance'];\n symbol: Symbol;\n}) => {\n const symbolOptions = plugin.referenceSymbol({\n category: 'type',\n resource: 'client-options',\n tool: 'sdk',\n });\n\n const symbolDataType = plugin.querySymbol({\n category: 'type',\n resource: 'operation',\n resourceId: operation.id,\n role: 'data',\n tool: 'typescript',\n });\n const dataType = symbolDataType?.placeholder || 'unknown';\n\n return $.const(symbol.placeholder)\n .export(symbol.exported)\n .$if(createOperationComment(operation), (c, v) => c.doc(v))\n .assign(\n $.func()\n .param('options', (p) =>\n p\n .required(isRequiredOptions)\n .type(\n `() => ${symbolOptions.placeholder}<${dataType}, ThrowOnError> | undefined`,\n ),\n )\n .generic('ThrowOnError', (g) => g.extends('boolean').default(false))\n .do(\n $.return(\n generateResourceCallExpression({\n operation,\n plugin,\n }),\n ),\n ),\n );\n};\n\nexport const createHttpResources: AngularCommonPlugin['Handler'] = ({\n plugin,\n}) => {\n if (plugin.config.httpResources.asClass) {\n generateAngularClassServices({ plugin });\n } else {\n generateAngularFunctionServices({ plugin });\n }\n};\n","import { createHttpRequests } from './httpRequests';\nimport { createHttpResources } from './httpResources';\nimport type { AngularCommonPlugin } from './types';\n\nexport const handler: AngularCommonPlugin['Handler'] = ({ plugin }) => {\n plugin.registerSymbol({\n external: '@angular/common/http',\n kind: 'type',\n meta: {\n category: 'external',\n resource: '@angular/common/http.HttpRequest',\n },\n name: 'HttpRequest',\n });\n plugin.registerSymbol({\n external: '@angular/core',\n meta: {\n category: 'external',\n resource: '@angular/core.inject',\n },\n name: 'inject',\n });\n plugin.registerSymbol({\n external: '@angular/core',\n meta: {\n category: 'external',\n resource: '@angular/core.Injectable',\n },\n name: 'Injectable',\n });\n plugin.registerSymbol({\n external: '@angular/common/http',\n meta: {\n category: 'external',\n resource: '@angular/common/http.httpResource',\n },\n name: 'httpResource',\n });\n\n if (plugin.config.httpRequests.enabled) {\n createHttpRequests({ plugin });\n }\n\n if (plugin.config.httpResources.enabled) {\n createHttpResources({ plugin });\n }\n};\n","import { definePluginConfig } from '~/plugins/shared/utils/config';\n\nimport { handler } from './plugin';\nimport type { AngularCommonPlugin } from './types';\n\nexport const defaultConfig: AngularCommonPlugin['Config'] = {\n config: {\n exportFromIndex: false,\n },\n dependencies: ['@hey-api/client-angular', '@hey-api/sdk'],\n handler,\n name: '@angular/common',\n resolveConfig: (plugin, context) => {\n plugin.config.httpRequests = context.valueToObject({\n defaultValue: {\n asClass: false,\n classNameBuilder: '{{name}}Requests',\n enabled: true,\n },\n mappers: {\n boolean: (enabled) => ({ enabled }),\n },\n value: plugin.config.httpRequests,\n });\n\n if (!plugin.config.httpRequests.methodNameBuilder) {\n const { asClass } = plugin.config.httpRequests;\n plugin.config.httpRequests.methodNameBuilder = (operation) =>\n asClass ? String(operation.id) : `${String(operation.id)}Request`;\n }\n\n plugin.config.httpResources = context.valueToObject({\n defaultValue: {\n asClass: false,\n classNameBuilder: '{{name}}Resources',\n enabled: true,\n },\n mappers: {\n boolean: (enabled) => ({ enabled }),\n },\n value: plugin.config.httpResources,\n });\n\n if (!plugin.config.httpResources.methodNameBuilder) {\n const { asClass } = plugin.config.httpResources;\n plugin.config.httpResources.methodNameBuilder = (operation) =>\n asClass ? String(operation.id) : `${String(operation.id)}Resource`;\n }\n },\n};\n\n/**\n * Type helper for `@angular/common` plugin, returns {@link Plugin.Config} object\n */\nexport const defineConfig = definePluginConfig(defaultConfig);\n","export const clientDefaultConfig = {\n baseUrl: true,\n bundle: true,\n exportFromIndex: false,\n} as const;\n\nexport const clientDefaultMeta = {\n dependencies: ['@hey-api/typescript'],\n tags: ['client'],\n} as const;\n","import fs from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nimport type { IProject, ProjectRenderMeta } from '@hey-api/codegen-core';\n\nimport type { DefinePlugin } from '~/plugins';\nimport type { Client } from '~/plugins/@hey-api/client-core/types';\nimport { getClientPlugin } from '~/plugins/@hey-api/client-core/utils';\nimport type { Config } from '~/types/config';\n\nimport { ensureDirSync } from './utils';\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\n/**\n * Returns absolute path to the client folder. This is hard-coded for now.\n */\nexport const clientFolderAbsolutePath = (config: Config): string => {\n const client = getClientPlugin(config);\n\n if ('bundle' in client.config && client.config.bundle) {\n // not proud of this one\n const renamed: Map<string, string> | undefined =\n // @ts-expect-error\n config._FRAGILE_CLIENT_BUNDLE_RENAMED;\n return path.resolve(\n config.output.path,\n 'client',\n `${renamed?.get('index') ?? 'index'}.ts`,\n );\n }\n\n return client.name;\n};\n\n/**\n * Recursively copies files and directories.\n * This is a PnP-compatible alternative to fs.cpSync that works with Yarn PnP's\n * virtualized filesystem.\n */\nconst copyRecursivePnP = (src: string, dest: string) => {\n const stat = fs.statSync(src);\n\n if (stat.isDirectory()) {\n if (!fs.existsSync(dest)) {\n fs.mkdirSync(dest, { recursive: true });\n }\n\n const files = fs.readdirSync(src);\n for (const file of files) {\n copyRecursivePnP(path.join(src, file), path.join(dest, file));\n }\n } else {\n const content = fs.readFileSync(src);\n fs.writeFileSync(dest, content);\n }\n};\n\nconst renameFile = ({\n filePath,\n project,\n renamed,\n}: {\n filePath: string;\n project: IProject;\n renamed: Map<string, string>;\n}) => {\n const extension = path.extname(filePath);\n const name = path.basename(filePath, extension);\n const renamedName = project.fileName?.(name) || name;\n if (renamedName !== name) {\n const outputPath = path.dirname(filePath);\n fs.renameSync(\n filePath,\n path.resolve(outputPath, `${renamedName}${extension}`),\n );\n renamed.set(name, renamedName);\n }\n};\n\nconst replaceImports = ({\n filePath,\n meta,\n renamed,\n}: {\n filePath: string;\n meta: ProjectRenderMeta;\n renamed: Map<string, string>;\n}) => {\n let content = fs.readFileSync(filePath, 'utf8');\n\n content = content.replace(\n /from\\s+['\"](\\.\\.?\\/[^'\"]*?)['\"]/g,\n (match, importPath) => {\n const importIndex = match.indexOf(importPath);\n const extension = path.extname(importPath);\n const fileName = path.basename(importPath, extension);\n const importDir = path.dirname(importPath);\n const replacedName =\n (renamed.get(fileName) ?? fileName) +\n (meta.importFileExtension ? meta.importFileExtension : extension);\n const replacedMatch =\n match.slice(0, importIndex) +\n [importDir, replacedName].filter(Boolean).join('/') +\n match.slice(importIndex + importPath.length);\n return replacedMatch;\n },\n );\n\n const header = '// This file is auto-generated by @hey-api/openapi-ts\\n\\n';\n\n content = `${header}${content}`;\n\n fs.writeFileSync(filePath, content, 'utf8');\n};\n\n/**\n * Creates a `client` folder containing the same modules as the client package.\n */\nexport const generateClientBundle = ({\n meta,\n outputPath,\n plugin,\n project,\n}: {\n meta: ProjectRenderMeta;\n outputPath: string;\n plugin: DefinePlugin<Client.Config & { name: string }>['Config'];\n project?: IProject;\n}): Map<string, string> | undefined => {\n const renamed = new Map<string, string>();\n\n // copy Hey API clients to output\n const isHeyApiClientPlugin = plugin.name.startsWith('@hey-api/client-');\n if (isHeyApiClientPlugin) {\n // copy client core\n const coreOutputPath = path.resolve(outputPath, 'core');\n ensureDirSync(coreOutputPath);\n const coreDistPath = path.resolve(__dirname, 'clients', 'core');\n copyRecursivePnP(coreDistPath, coreOutputPath);\n\n // copy client bundle\n const clientOutputPath = path.resolve(outputPath, 'client');\n ensureDirSync(clientOutputPath);\n const clientDistFolderName = plugin.name.slice('@hey-api/client-'.length);\n const clientDistPath = path.resolve(\n __dirname,\n 'clients',\n clientDistFolderName,\n );\n copyRecursivePnP(clientDistPath, clientOutputPath);\n\n if (project) {\n const copiedCoreFiles = fs.readdirSync(coreOutputPath);\n for (const file of copiedCoreFiles) {\n renameFile({\n filePath: path.resolve(coreOutputPath, file),\n project,\n renamed,\n });\n }\n\n const copiedClientFiles = fs.readdirSync(clientOutputPath);\n for (const file of copiedClientFiles) {\n renameFile({\n filePath: path.resolve(clientOutputPath, file),\n project,\n renamed,\n });\n }\n }\n\n const coreFiles = fs.readdirSync(coreOutputPath);\n for (const file of coreFiles) {\n replaceImports({\n filePath: path.resolve(coreOutputPath, file),\n meta,\n renamed,\n });\n }\n\n const clientFiles = fs.readdirSync(clientOutputPath);\n for (const file of clientFiles) {\n replaceImports({\n filePath: path.resolve(clientOutputPath, file),\n meta,\n renamed,\n });\n }\n return renamed;\n }\n\n const clientSrcPath = path.isAbsolute(plugin.name)\n ? path.dirname(plugin.name)\n : undefined;\n\n // copy custom local client to output\n if (clientSrcPath) {\n const dirPath = path.resolve(outputPath, 'client');\n ensureDirSync(dirPath);\n copyRecursivePnP(clientSrcPath, dirPath);\n return;\n }\n\n // copy third-party client to output\n const clientModulePath = path.normalize(require.resolve(plugin.name));\n const clientModulePathComponents = clientModulePath.split(path.sep);\n const clientDistPath = clientModulePathComponents\n .slice(0, clientModulePathComponents.indexOf('dist') + 1)\n .join(path.sep);\n\n const indexJsFile =\n clientModulePathComponents[clientModulePathComponents.length - 1];\n const distFiles = [indexJsFile!, 'index.d.mts', 'index.d.cts'];\n const dirPath = path.resolve(outputPath, 'client');\n ensureDirSync(dirPath);\n for (const file of distFiles) {\n fs.copyFileSync(\n path.resolve(clientDistPath, file),\n path.resolve(dirPath, file),\n );\n }\n\n return;\n};\n","const parseUrlRegExp =\n /^(([^:/?#]+):)?((\\/\\/)?([^:/?#]*)(:?([^/?#]*)))?([^?#]*)(\\?([^#]*))?(#(.*))?/;\n\ninterface Url {\n host: string;\n path: string;\n port: string;\n protocol: string;\n}\n\nexport const parseUrl = (value: string): Url => {\n const errorResponse: Url = {\n host: '',\n path: '',\n port: '',\n protocol: '',\n };\n\n parseUrlRegExp.lastIndex = 0;\n const match = value.match(parseUrlRegExp);\n\n if (!match) {\n return errorResponse;\n }\n\n const host = match[5] || '';\n\n // value is a relative file system path\n if (host === '.' || host === '..') {\n return errorResponse;\n }\n\n const path = match[8] || '';\n const protocol = match[2] || '';\n\n // value is probably a Windows file system path\n if (protocol.length === 1) {\n return errorResponse;\n }\n\n return {\n host,\n path: path === '/' ? '' : path,\n port: match[7] || '',\n protocol,\n };\n};\n","import { clientFolderAbsolutePath } from '~/generate/client';\nimport { $ } from '~/ts-dsl';\nimport { parseUrl } from '~/utils/url';\n\nimport type { PluginHandler } from './types';\nimport { getClientBaseUrlKey } from './utils';\n\nconst resolveBaseUrlString = ({\n plugin,\n}: Parameters<PluginHandler>[0]): string | undefined => {\n const { baseUrl } = plugin.config;\n\n if (baseUrl === false) {\n return;\n }\n\n if (typeof baseUrl === 'string') {\n return baseUrl;\n }\n\n const { servers } = plugin.context.ir;\n\n if (!servers) {\n return;\n }\n\n return servers[typeof baseUrl === 'number' ? baseUrl : 0]?.url;\n};\n\nexport const createClient: PluginHandler = ({ plugin }) => {\n const clientModule = clientFolderAbsolutePath(plugin.context.config);\n const symbolCreateClient = plugin.registerSymbol({\n external: clientModule,\n name: 'createClient',\n });\n const symbolCreateConfig = plugin.registerSymbol({\n external: clientModule,\n name: 'createConfig',\n });\n const symbolClientOptions = plugin.referenceSymbol({\n category: 'type',\n resource: 'client',\n role: 'options',\n });\n\n const { runtimeConfigPath } = plugin.config;\n const symbolCreateClientConfig = runtimeConfigPath\n ? plugin.registerSymbol({\n external: runtimeConfigPath,\n name: 'createClientConfig',\n })\n : undefined;\n\n const defaultVals = $.object();\n\n const resolvedBaseUrl = resolveBaseUrlString({\n plugin: plugin as any,\n });\n if (resolvedBaseUrl) {\n const url = parseUrl(resolvedBaseUrl);\n if (url.protocol && url.host && !resolvedBaseUrl.includes('{')) {\n defaultVals.prop(\n getClientBaseUrlKey(plugin.context.config),\n $.literal(resolvedBaseUrl),\n );\n } else if (resolvedBaseUrl !== '/' && resolvedBaseUrl.startsWith('/')) {\n const baseUrl = resolvedBaseUrl.endsWith('/')\n ? resolvedBaseUrl.slice(0, -1)\n : resolvedBaseUrl;\n defaultVals.prop(\n getClientBaseUrlKey(plugin.context.config),\n $.literal(baseUrl),\n );\n }\n }\n\n if ('throwOnError' in plugin.config && plugin.config.throwOnError) {\n defaultVals.prop('throwOnError', $.literal(true));\n }\n\n const createConfigParameters = [\n $(symbolCreateConfig.placeholder)\n .call(defaultVals.hasProps() ? defaultVals : undefined)\n .generic(symbolClientOptions.placeholder),\n ];\n\n const symbolClient = plugin.registerSymbol({\n exported: true,\n meta: {\n category: 'client',\n },\n name: 'client',\n });\n const statement = $.const(symbolClient.placeholder)\n .export(symbolClient.exported)\n .assign(\n $(symbolCreateClient.placeholder).$if(\n symbolCreateClientConfig,\n (c, s) => c.call($(s.placeholder).call(...createConfigParameters)),\n (c) => c.call(...createConfigParameters),\n ),\n );\n plugin.setSymbolValue(symbolClient, statement);\n};\n","import { clientFolderAbsolutePath } from '~/generate/client';\nimport { $ } from '~/ts-dsl';\n\nimport type { PluginHandler } from './types';\n\nexport const createClientConfigType = ({\n plugin,\n}: Parameters<PluginHandler>[0]) => {\n const clientModule = clientFolderAbsolutePath(plugin.context.config);\n const symbolClientOptions = plugin.referenceSymbol({\n category: 'type',\n resource: 'client',\n role: 'options',\n });\n const symbolConfig = plugin.registerSymbol({\n external: clientModule,\n kind: 'type',\n name: 'Config',\n });\n const symbolDefaultClientOptions = plugin.registerSymbol({\n external: clientModule,\n kind: 'type',\n name: 'ClientOptions',\n });\n const symbolCreateClientConfig = plugin.registerSymbol({\n exported: true,\n kind: 'type',\n name: 'CreateClientConfig',\n });\n\n const typeCreateClientConfig = $.type\n .alias(symbolCreateClientConfig.placeholder)\n .export(symbolCreateClientConfig.exported)\n .doc([\n 'The `createClientConfig()` function will be called on client initialization',\n \"and the returned object will become the client's initial configuration.\",\n '',\n 'You may want to initialize your client this way instead of calling',\n \"`setConfig()`. This is useful for example if you're using Next.js\",\n 'to ensure your client always has the correct values.',\n ])\n .generic('T', (g) =>\n g\n .extends(symbolDefaultClientOptions.placeholder)\n .default(symbolClientOptions.placeholder),\n )\n .type(\n $.type\n .func()\n .param('override', (p) =>\n p\n .optional()\n .type(\n $.type(symbolConfig.placeholder).generic(\n $.type.and(symbolDefaultClientOptions.placeholder, 'T'),\n ),\n ),\n )\n .returns(\n $.type(symbolConfig.placeholder).generic(\n $.type.and(\n $.type('Required').generic(\n symbolDefaultClientOptions.placeholder,\n ),\n 'T',\n ),\n ),\n ),\n );\n plugin.setSymbolValue(symbolCreateClientConfig, typeCreateClientConfig);\n};\n","import { createClient } from './client';\nimport { createClientConfigType } from './createClientConfig';\nimport type { PluginHandler } from './types';\n\nexport const clientPluginHandler = ({\n plugin,\n}: Parameters<PluginHandler>[0]) => {\n createClientConfigType({ plugin });\n createClient({ plugin });\n};\n","import {\n clientDefaultConfig,\n clientDefaultMeta,\n} from '~/plugins/@hey-api/client-core/config';\nimport { clientPluginHandler } from '~/plugins/@hey-api/client-core/plugin';\nimport { definePluginConfig } from '~/plugins/shared/utils/config';\n\nimport type { HeyApiClientAngularPlugin } from './types';\n\nexport const defaultConfig: HeyApiClientAngularPlugin['Config'] = {\n ...clientDefaultMeta,\n config: {\n ...clientDefaultConfig,\n throwOnError: false,\n },\n handler: clientPluginHandler,\n name: '@hey-api/client-angular',\n};\n\n/**\n * Type helper for `@hey-api/client-angular` plugin, returns {@link Plugin.Config} object\n */\nexport const defineConfig = definePluginConfig(defaultConfig);\n","import {\n clientDefaultConfig,\n clientDefaultMeta,\n} from '~/plugins/@hey-api/client-core/config';\nimport { clientPluginHandler } from '~/plugins/@hey-api/client-core/plugin';\nimport { definePluginConfig } from '~/plugins/shared/utils/config';\n\nimport type { HeyApiClientAxiosPlugin } from './types';\n\nexport const defaultConfig: HeyApiClientAxiosPlugin['Config'] = {\n ...clientDefaultMeta,\n config: {\n ...clientDefaultConfig,\n throwOnError: false,\n },\n handler: clientPluginHandler,\n name: '@hey-api/client-axios',\n};\n\n/**\n * Type helper for `@hey-api/client-axios` plugin, returns {@link Plugin.Config} object\n */\nexport const defineConfig = definePluginConfig(defaultConfig);\n","import {\n clientDefaultConfig,\n clientDefaultMeta,\n} from '~/plugins/@hey-api/client-core/config';\nimport { clientPluginHandler } from '~/plugins/@hey-api/client-core/plugin';\nimport { definePluginConfig } from '~/plugins/shared/utils/config';\n\nimport type { HeyApiClientFetchPlugin } from './types';\n\nexport const defaultConfig: HeyApiClientFetchPlugin['Config'] = {\n ...clientDefaultMeta,\n config: {\n ...clientDefaultConfig,\n throwOnError: false,\n },\n handler: clientPluginHandler,\n name: '@hey-api/client-fetch',\n};\n\n/**\n * Type helper for `@hey-api/client-fetch` plugin, returns {@link Plugin.Config} object\n */\nexport const defineConfig = definePluginConfig(defaultConfig);\n","import {\n clientDefaultConfig,\n clientDefaultMeta,\n} from '~/plugins/@hey-api/client-core/config';\nimport { clientPluginHandler } from '~/plugins/@hey-api/client-core/plugin';\nimport { definePluginConfig } from '~/plugins/shared/utils/config';\n\nimport type { HeyApiClientKyPlugin } from './types';\n\nexport const defaultConfig: HeyApiClientKyPlugin['Config'] = {\n ...clientDefaultMeta,\n config: {\n ...clientDefaultConfig,\n throwOnError: false,\n },\n handler: clientPluginHandler,\n name: '@hey-api/client-ky',\n};\n\n/**\n * Type helper for `@hey-api/client-ky` plugin, returns {@link Plugin.Config} object\n */\nexport const defineConfig = definePluginConfig(defaultConfig);\n","import {\n clientDefaultConfig,\n clientDefaultMeta,\n} from '~/plugins/@hey-api/client-core/config';\nimport { clientPluginHandler } from '~/plugins/@hey-api/client-core/plugin';\nimport { definePluginConfig } from '~/plugins/shared/utils/config';\n\nimport type { HeyApiClientNextPlugin } from './types';\n\nexport const defaultConfig: HeyApiClientNextPlugin['Config'] = {\n ...clientDefaultMeta,\n config: {\n ...clientDefaultConfig,\n throwOnError: false,\n },\n handler: clientPluginHandler,\n name: '@hey-api/client-next',\n};\n\n/**\n * Type helper for `@hey-api/client-next` plugin, returns {@link Plugin.Config} object\n */\nexport const defineConfig = definePluginConfig(defaultConfig);\n","import {\n clientDefaultConfig,\n clientDefaultMeta,\n} from '~/plugins/@hey-api/client-core/config';\nimport { clientPluginHandler } from '~/plugins/@hey-api/client-core/plugin';\nimport { definePluginConfig } from '~/plugins/shared/utils/config';\n\nimport type { HeyApiClientNuxtPlugin } from './types';\n\nexport const defaultConfig: HeyApiClientNuxtPlugin['Config'] = {\n ...clientDefaultMeta,\n config: clientDefaultConfig,\n handler: clientPluginHandler,\n name: '@hey-api/client-nuxt',\n};\n\n/**\n * Type helper for `@hey-api/client-nuxt` plugin, returns {@link Plugin.Config} object\n */\nexport const defineConfig = definePluginConfig(defaultConfig);\n","import {\n clientDefaultConfig,\n clientDefaultMeta,\n} from '~/plugins/@hey-api/client-core/config';\nimport { clientPluginHandler } from '~/plugins/@hey-api/client-core/plugin';\nimport { definePluginConfig } from '~/plugins/shared/utils/config';\n\nimport type { HeyApiClientOfetchPlugin } from './types';\n\nexport const defaultConfig: HeyApiClientOfetchPlugin['Config'] = {\n ...clientDefaultMeta,\n config: {\n ...clientDefaultConfig,\n throwOnError: false,\n },\n handler: clientPluginHandler,\n name: '@hey-api/client-ofetch',\n};\n\n/**\n * Type helper for `@hey-api/client-ofetch` plugin, returns {@link Plugin.Config} object\n */\nexport const defineConfig = definePluginConfig(defaultConfig);\n","import type { RangeOptions, SemVer } from 'semver';\nimport * as semver from 'semver';\n\nexport type Package = {\n /**\n * Get the installed version of a package.\n * @param name The name of the package to get the version for.\n * @returns A SemVer object containing version information, or undefined if the package is not installed\n * or the version string is invalid.\n */\n getVersion: (name: string) => SemVer | undefined;\n /**\n * Check if a given package is installed in the project.\n * @param name The name of the package to check.\n */\n isInstalled: (name: string) => boolean;\n /**\n * Check if the installed version of a package or a given SemVer object satisfies a semver range.\n * @param nameOrVersion The name of the package to check, or a SemVer object.\n * @param range The semver range to check against.\n * @returns True if the version satisfies the range, false otherwise.\n */\n satisfies: (\n nameOrVersion: string | SemVer,\n range: string,\n optionsOrLoose?: boolean | RangeOptions,\n ) => boolean;\n};\n\nexport const satisfies: typeof semver.satisfies = (...args) =>\n semver.satisfies(...args);\n\nexport const packageFactory = (\n dependencies: Record<string, string>,\n): Package => ({\n getVersion: (name) => {\n const version = dependencies[name];\n if (!version) return;\n try {\n let parsed = semver.parse(version);\n if (parsed) return parsed;\n\n const min = semver.minVersion(version);\n if (min) return min;\n\n parsed = semver.coerce(version);\n if (parsed) return parsed;\n } catch {\n // noop\n }\n return;\n },\n isInstalled: (name) => Boolean(dependencies[name]),\n satisfies: (nameOrVersion, range, optionsOrLoose) => {\n const version =\n typeof nameOrVersion === 'string'\n ? dependencies[nameOrVersion]\n : nameOrVersion;\n return version ? satisfies(version, range, optionsOrLoose) : false;\n },\n});\n","import {\n illegalStartCharactersRegExp,\n reservedBrowserGlobalsRegExp,\n reservedJavaScriptGlobalsRegExp,\n reservedJavaScriptKeywordsRegExp,\n reservedNodeGlobalsRegExp,\n reservedTypeScriptKeywordsRegExp,\n} from '~/utils/regexp';\n\nconst regexps = [\n reservedJavaScriptKeywordsRegExp,\n reservedTypeScriptKeywordsRegExp,\n reservedJavaScriptGlobalsRegExp,\n reservedNodeGlobalsRegExp,\n reservedBrowserGlobalsRegExp,\n];\n\nexport const ensureValidIdentifier = (name: string): string => {\n let identifier = name.replace(/[^$\\u200c\\u200d\\p{ID_Continue}]/gu, '_');\n\n illegalStartCharactersRegExp.lastIndex = 0;\n if (illegalStartCharactersRegExp.test(identifier)) {\n return `_${identifier}`;\n }\n\n for (const regexp of regexps) {\n if (identifier.startsWith('_')) {\n return identifier;\n }\n\n identifier = identifier.replace(regexp, '_$1');\n }\n\n return identifier;\n};\n","import { satisfies } from '~/config/utils/package';\nimport type { Context } from '~/ir/context';\nimport type { OpenApiV2_0_XTypes } from '~/openApi/2.0.x';\nimport type { OpenApiV3_0_XTypes } from '~/openApi/3.0.x';\nimport type { OpenApiV3_1_XTypes } from '~/openApi/3.1.x';\nimport { ensureValidIdentifier } from '~/openApi/shared/utils/identifier';\nimport type { OpenApi } from '~/openApi/types';\nimport { $ } from '~/ts-dsl';\n\nimport type { HeyApiSchemasPlugin } from './types';\n\nconst stripSchema = ({\n plugin,\n schema,\n}: {\n plugin: HeyApiSchemasPlugin['Instance'];\n schema:\n | OpenApiV2_0_XTypes['SchemaObject']\n | OpenApiV3_0_XTypes['SchemaObject']\n | OpenApiV3_1_XTypes['SchemaObject'];\n}) => {\n if (plugin.config.type === 'form') {\n if (schema.description) {\n delete schema.description;\n }\n\n if (schema['x-enum-descriptions']) {\n delete schema['x-enum-descriptions'];\n }\n\n if (schema['x-enum-varnames']) {\n delete schema['x-enum-varnames'];\n }\n\n if (schema['x-enumNames']) {\n delete schema['x-enumNames'];\n }\n\n if (schema.title) {\n delete schema.title;\n }\n }\n};\n\nconst schemaToJsonSchemaDraft_04 = ({\n context,\n plugin,\n schema: _schema,\n}: {\n context: Context;\n plugin: HeyApiSchemasPlugin['Instance'];\n schema: OpenApiV2_0_XTypes['SchemaObject'];\n}): OpenApiV2_0_XTypes['SchemaObject'] => {\n if (Array.isArray(_schema)) {\n return _schema.map((item) =>\n schemaToJsonSchemaDraft_04({\n context,\n plugin,\n schema: item,\n }),\n ) as unknown as OpenApiV2_0_XTypes['SchemaObject'];\n }\n\n const schema = structuredClone(_schema);\n\n if (schema.$ref) {\n // refs using unicode characters become encoded, didn't investigate why\n // but the suspicion is this comes from `@hey-api/json-schema-ref-parser`\n schema.$ref = decodeURI(schema.$ref);\n return schema;\n }\n\n stripSchema({ plugin, schema });\n\n if (\n schema.additionalProperties &&\n typeof schema.additionalProperties !== 'boolean'\n ) {\n schema.additionalProperties = schemaToJsonSchemaDraft_04({\n context,\n plugin,\n schema: schema.additionalProperties,\n });\n }\n\n if (schema.allOf) {\n schema.allOf = schema.allOf.map((item) =>\n schemaToJsonSchemaDraft_04({\n context,\n plugin,\n schema: item,\n }),\n );\n }\n\n if (schema.items) {\n schema.items = schemaToJsonSchemaDraft_04({\n context,\n plugin,\n schema: schema.items as OpenApiV2_0_XTypes['SchemaObject'],\n });\n }\n\n if (schema.properties) {\n for (const name in schema.properties) {\n const property = schema.properties[name]!;\n\n if (typeof property !== 'boolean') {\n schema.properties[name] = schemaToJsonSchemaDraft_04({\n context,\n plugin,\n schema: property,\n });\n }\n }\n }\n\n return schema;\n};\n\nconst schemaToJsonSchemaDraft_05 = ({\n context,\n plugin,\n schema: _schema,\n}: {\n context: Context;\n plugin: HeyApiSchemasPlugin['Instance'];\n schema:\n | OpenApiV3_0_XTypes['SchemaObject']\n | OpenApiV3_0_XTypes['ReferenceObject'];\n}):\n | OpenApiV3_0_XTypes['SchemaObject']\n | OpenApiV3_0_XTypes['ReferenceObject'] => {\n if (Array.isArray(_schema)) {\n return _schema.map((item) =>\n schemaToJsonSchemaDraft_05({\n context,\n plugin,\n schema: item,\n }),\n ) as\n | OpenApiV3_0_XTypes['SchemaObject']\n | OpenApiV3_0_XTypes['ReferenceObject'];\n }\n\n const schema = structuredClone(_schema);\n\n if ('$ref' in schema) {\n // refs using unicode characters become encoded, didn't investigate why\n // but the suspicion is this comes from `@hey-api/json-schema-ref-parser`\n schema.$ref = decodeURI(schema.$ref);\n return schema;\n }\n\n stripSchema({ plugin, schema });\n\n if (\n schema.additionalProperties &&\n typeof schema.additionalProperties !== 'boolean'\n ) {\n schema.additionalProperties = schemaToJsonSchemaDraft_05({\n context,\n plugin,\n schema: schema.additionalProperties,\n });\n }\n\n if (schema.allOf) {\n schema.allOf = schema.allOf.map((item) =>\n schemaToJsonSchemaDraft_05({\n context,\n plugin,\n schema: item,\n }),\n );\n }\n\n if (schema.anyOf) {\n schema.anyOf = schema.anyOf.map((item) =>\n schemaToJsonSchemaDraft_05({\n context,\n plugin,\n schema: item,\n }),\n );\n }\n\n if (schema.items) {\n schema.items = schemaToJsonSchemaDraft_05({\n context,\n plugin,\n schema: schema.items,\n });\n }\n\n if (schema.oneOf) {\n schema.oneOf = schema.oneOf.map((item) =>\n schemaToJsonSchemaDraft_05({\n context,\n plugin,\n schema: item,\n }),\n );\n }\n\n if (schema.properties) {\n for (const name in schema.properties) {\n const property = schema.properties[name]!;\n\n if (typeof property !== 'boolean') {\n schema.properties[name] = schemaToJsonSchemaDraft_05({\n context,\n plugin,\n schema: property,\n });\n }\n }\n }\n\n return schema;\n};\n\nconst schemaToJsonSchema2020_12 = ({\n context,\n plugin,\n schema: _schema,\n}: {\n context: Context;\n plugin: HeyApiSchemasPlugin['Instance'];\n schema: OpenApiV3_1_XTypes['SchemaObject'];\n}): OpenApiV3_1_XTypes['SchemaObject'] => {\n if (Array.isArray(_schema)) {\n return _schema.map((item) =>\n schemaToJsonSchema2020_12({\n context,\n plugin,\n schema: item,\n }),\n ) as OpenApiV3_1_XTypes['SchemaObject'];\n }\n\n const schema = structuredClone(_schema);\n\n stripSchema({ plugin, schema });\n\n if (schema.$ref) {\n // refs using unicode characters become encoded, didn't investigate why\n // but the suspicion is this comes from `@hey-api/json-schema-ref-parser`\n schema.$ref = decodeURI(schema.$ref);\n }\n\n if (\n schema.additionalProperties &&\n typeof schema.additionalProperties !== 'boolean'\n ) {\n schema.additionalProperties = schemaToJsonSchema2020_12({\n context,\n plugin,\n schema: schema.additionalProperties,\n });\n }\n\n if (schema.allOf) {\n schema.allOf = schema.allOf.map((item) =>\n schemaToJsonSchema2020_12({\n context,\n plugin,\n schema: item,\n }),\n );\n }\n\n if (schema.anyOf) {\n schema.anyOf = schema.anyOf.map((item) =>\n schemaToJsonSchema2020_12({\n context,\n plugin,\n schema: item,\n }),\n );\n }\n\n if (schema.items) {\n schema.items = schemaToJsonSchema2020_12({\n context,\n plugin,\n schema: schema.items,\n });\n }\n\n if (schema.oneOf) {\n schema.oneOf = schema.oneOf.map((item) =>\n schemaToJsonSchema2020_12({\n context,\n plugin,\n schema: item,\n }),\n );\n }\n\n if (schema.prefixItems) {\n schema.prefixItems = schema.prefixItems.map((item) =>\n schemaToJsonSchema2020_12({\n context,\n plugin,\n schema: item,\n }),\n );\n }\n\n if (schema.properties) {\n for (const name in schema.properties) {\n const property = schema.properties[name]!;\n\n if (typeof property !== 'boolean') {\n schema.properties[name] = schemaToJsonSchema2020_12({\n context,\n plugin,\n schema: property,\n });\n }\n }\n }\n\n return schema;\n};\n\nconst schemaName = ({\n name,\n plugin,\n schema,\n}: {\n name: string;\n plugin: HeyApiSchemasPlugin['Instance'];\n schema:\n | OpenApiV2_0_XTypes['SchemaObject']\n | OpenApiV3_0_XTypes['ReferenceObject']\n | OpenApiV3_0_XTypes['SchemaObject']\n | OpenApiV3_1_XTypes['SchemaObject'];\n}): string => {\n let customName = '';\n\n if (plugin.config.nameBuilder) {\n if (typeof plugin.config.nameBuilder === 'function') {\n customName = plugin.config.nameBuilder(name, schema);\n } else {\n customName = plugin.config.nameBuilder.replace('{{name}}', name);\n }\n }\n\n if (!customName) {\n customName = `${name}Schema`;\n }\n\n return ensureValidIdentifier(customName);\n};\n\nconst schemasV2_0_X = ({\n context,\n plugin,\n}: {\n context: Context<OpenApi.V2_0_X>;\n plugin: HeyApiSchemasPlugin['Instance'];\n}) => {\n if (!context.spec.definitions) {\n return;\n }\n\n for (const name in context.spec.definitions) {\n const schema = context.spec.definitions[name]!;\n const symbol = plugin.registerSymbol({\n exported: true,\n meta: {\n category: 'schema',\n resource: 'definition',\n resourceId: name,\n tool: 'json-schema',\n },\n name: schemaName({ name, plugin, schema }),\n });\n const obj = schemaToJsonSchemaDraft_04({\n context,\n plugin,\n schema,\n });\n const statement = $.const(symbol.placeholder)\n .export(symbol.exported)\n .assign(\n $(\n $.fromValue(obj, {\n layout: 'pretty',\n }),\n ).as('const'),\n );\n plugin.setSymbolValue(symbol, statement);\n }\n};\n\nconst schemasV3_0_X = ({\n context,\n plugin,\n}: {\n context: Context<OpenApi.V3_0_X>;\n plugin: HeyApiSchemasPlugin['Instance'];\n}) => {\n if (!context.spec.components) {\n return;\n }\n\n for (const name in context.spec.components.schemas) {\n const schema = context.spec.components.schemas[name]!;\n const symbol = plugin.registerSymbol({\n exported: true,\n meta: {\n category: 'schema',\n resource: 'definition',\n resourceId: name,\n tool: 'json-schema',\n },\n name: schemaName({ name, plugin, schema }),\n });\n const obj = schemaToJsonSchemaDraft_05({\n context,\n plugin,\n schema,\n });\n const statement = $.const(symbol.placeholder)\n .export(symbol.exported)\n .assign(\n $(\n $.fromValue(obj, {\n layout: 'pretty',\n }),\n ).as('const'),\n );\n plugin.setSymbolValue(symbol, statement);\n }\n};\n\nconst schemasV3_1_X = ({\n context,\n plugin,\n}: {\n context: Context<OpenApi.V3_1_X>;\n plugin: HeyApiSchemasPlugin['Instance'];\n}) => {\n if (!context.spec.components) {\n return;\n }\n\n for (const name in context.spec.components.schemas) {\n const schema = context.spec.components.schemas[name]!;\n const symbol = plugin.registerSymbol({\n exported: true,\n meta: {\n category: 'schema',\n resource: 'definition',\n resourceId: name,\n tool: 'json-schema',\n },\n name: schemaName({ name, plugin, schema }),\n });\n const obj = schemaToJsonSchema2020_12({\n context,\n plugin,\n schema,\n });\n const statement = $.const(symbol.placeholder)\n .export(symbol.exported)\n .assign(\n $(\n $.fromValue(obj, {\n layout: 'pretty',\n }),\n ).as('const'),\n );\n plugin.setSymbolValue(symbol, statement);\n }\n};\n\nexport const handler: HeyApiSchemasPlugin['Handler'] = ({ plugin }) => {\n if ('swagger' in plugin.context.spec) {\n schemasV2_0_X({\n context: plugin.context as Context<OpenApi.V2_0_X>,\n plugin,\n });\n return;\n }\n\n if (satisfies(plugin.context.spec.openapi, '>=3.0.0 <3.1.0')) {\n schemasV3_0_X({\n context: plugin.context as Context<OpenApi.V3_0_X>,\n plugin,\n });\n return;\n }\n\n if (satisfies(plugin.context.spec.openapi, '>=3.1.0')) {\n schemasV3_1_X({\n context: plugin.context as Context<OpenApi.V3_1_X>,\n plugin,\n });\n return;\n }\n\n throw new Error('Unsupported OpenAPI specification');\n};\n","import { definePluginConfig } from '~/plugins/shared/utils/config';\n\nimport { handler } from './plugin';\nimport type { HeyApiSchemasPlugin } from './types';\n\nexport const defaultConfig: HeyApiSchemasPlugin['Config'] = {\n config: {\n exportFromIndex: false,\n nameBuilder: (name) => `${name}Schema`,\n type: 'json',\n },\n handler,\n name: '@hey-api/schemas',\n};\n\n/**\n * Type helper for `@hey-api/schemas` plugin, returns {@link Plugin.Config} object\n */\nexport const defineConfig = definePluginConfig(defaultConfig);\n","import type { Symbol } from '@hey-api/codegen-core';\n\nimport { getClientPlugin } from '~/plugins/@hey-api/client-core/utils';\nimport {\n createOperationComment,\n isOperationOptionsRequired,\n} from '~/plugins/shared/utils/operation';\nimport type { TsDsl } from '~/ts-dsl';\nimport { $ } from '~/ts-dsl';\nimport { stringCase } from '~/utils/stringCase';\n\nimport type { HeyApiSdkPlugin } from '../types';\nimport { nuxtTypeComposable, nuxtTypeDefault } from './constants';\nimport {\n operationClasses,\n operationParameters,\n operationStatements,\n} from './operation';\n\ntype SdkClassEntry = {\n /**\n * Name of the class.\n */\n className: string;\n /**\n * Class names for child classes located inside this class.\n */\n classes: Set<string>;\n /**\n * Symbol ID for the class.\n */\n id: number;\n /**\n * Track unique added method nodes.\n */\n methods: Set<string>;\n /**\n * List of class nodes containing methods.\n */\n nodes: Array<TsDsl>;\n /**\n * Is this a root class?\n */\n root: boolean;\n};\n\nexport const registryName = '__registry';\n\nconst createRegistryClass = ({\n sdkName,\n symbol,\n}: {\n plugin: HeyApiSdkPlugin['Instance'];\n sdkName: string;\n symbol: Symbol;\n}): TsDsl => {\n const defaultKey = 'defaultKey';\n const instances = 'instances';\n return $.class(symbol.placeholder)\n .export(symbol.exported)\n .generic('T')\n .field(defaultKey, (f) =>\n f.private().readonly().assign($.literal('default')),\n )\n .newline()\n .field(instances, (f) =>\n f\n .private()\n .readonly()\n .type($.type('Map').generics('string', 'T'))\n .assign($.new('Map')),\n )\n .newline()\n .method('get', (m) =>\n m\n .returns('T')\n .param('key', (p) => p.type('string').optional())\n .do(\n $.const('instance').assign(\n $('this')\n .attr('instances')\n .attr('get')\n .call($('key').coalesce($('this').attr(defaultKey))),\n ),\n $.if($.not('instance')).do(\n $.throw('Error').message(\n $.template('No SDK client found. Create one with \"new ')\n .add(sdkName)\n .add('()\" to fix this error.'),\n ),\n ),\n $.return('instance'),\n ),\n )\n .newline()\n .method('set', (m) =>\n m\n .returns('void')\n .param('value', (p) => p.type('T'))\n .param('key', (p) => p.type('string').optional())\n .do(\n $('this')\n .attr(instances)\n .attr('set')\n .call($('key').coalesce($('this').attr(defaultKey)), 'value'),\n ),\n );\n};\n\nconst createClientClass = ({\n plugin,\n symbol,\n}: {\n plugin: HeyApiSdkPlugin['Instance'];\n symbol: Symbol;\n}): TsDsl => {\n const symClient = plugin.getSymbol({\n category: 'client',\n });\n const optionalClient = Boolean(plugin.config.client && symClient);\n const symbolClient = plugin.referenceSymbol({\n category: 'external',\n resource: 'client.Client',\n });\n return $.class(symbol.placeholder)\n .export(symbol.exported)\n .field('client', (f) => f.protected().type(symbolClient.placeholder))\n .newline()\n .init((i) =>\n i\n .param('args', (p) =>\n p\n .optional(optionalClient)\n .type(\n $.type\n .object()\n .prop('client', (p) =>\n p.optional(optionalClient).type(symbolClient.placeholder),\n ),\n ),\n )\n .do(\n $('this')\n .attr('client')\n .assign(\n $('args')\n .attr('client')\n .optional(optionalClient)\n .$if(optionalClient, (a) => a.coalesce(symClient!.placeholder)),\n ),\n ),\n );\n};\n\nexport const generateClassSdk = ({\n plugin,\n}: {\n plugin: HeyApiSdkPlugin['Instance'];\n}): void => {\n const client = getClientPlugin(plugin.context.config);\n const isAngularClient = client.name === '@hey-api/client-angular';\n const isNuxtClient = client.name === '@hey-api/client-nuxt';\n const sdkClasses = new Map<string, SdkClassEntry>();\n /**\n * Track unique added classes.\n */\n const generatedClasses = new Set<string>();\n\n plugin.forEach(\n 'operation',\n ({ operation }) => {\n const isRequiredOptions = isOperationOptionsRequired({\n context: plugin.context,\n operation,\n });\n const symbolResponse = isNuxtClient\n ? plugin.querySymbol({\n category: 'type',\n resource: 'operation',\n resourceId: operation.id,\n role: 'response',\n })\n : undefined;\n\n const classes = operationClasses({\n context: plugin.context,\n operation,\n plugin,\n });\n\n for (const entry of classes.values()) {\n entry.path.forEach((currentClassName, index) => {\n const symbolCurrentClass = plugin.referenceSymbol({\n category: 'utility',\n resource: 'class',\n resourceId: currentClassName,\n tool: 'sdk',\n });\n if (!sdkClasses.has(symbolCurrentClass.meta!.resourceId!)) {\n sdkClasses.set(symbolCurrentClass.meta!.resourceId!, {\n className: symbolCurrentClass.meta!.resourceId!,\n classes: new Set(),\n id: symbolCurrentClass.id,\n methods: new Set(),\n nodes: [],\n root: !index,\n });\n }\n\n const parentClassName = entry.path[index - 1];\n if (parentClassName) {\n const symbolParentClass = plugin.referenceSymbol({\n category: 'utility',\n resource: 'class',\n resourceId: parentClassName,\n tool: 'sdk',\n });\n if (\n symbolParentClass.meta?.resourceId !==\n symbolCurrentClass.meta?.resourceId\n ) {\n const parentClass = sdkClasses.get(\n symbolParentClass.meta!.resourceId!,\n )!;\n parentClass.classes.add(symbolCurrentClass.meta!.resourceId!);\n sdkClasses.set(symbolParentClass.meta!.resourceId!, parentClass);\n }\n }\n\n const isLast = entry.path.length === index + 1;\n // add methods only to the last class\n if (!isLast) {\n return;\n }\n\n const currentClass = sdkClasses.get(\n symbolCurrentClass.meta!.resourceId!,\n )!;\n\n // avoid duplicate methods\n if (currentClass.methods.has(entry.methodName)) {\n return;\n }\n\n const opParameters = operationParameters({\n isRequiredOptions,\n operation,\n plugin,\n });\n const statements = operationStatements({\n isRequiredOptions,\n opParameters,\n operation,\n plugin,\n });\n const functionNode = $.method(entry.methodName, (m) =>\n m\n .$if(createOperationComment(operation), (m, v) => m.doc(v))\n .public()\n .static(!isAngularClient && !plugin.config.instance)\n .$if(\n isNuxtClient,\n (m) =>\n m\n .generic(nuxtTypeComposable, (t) =>\n t\n .extends(\n plugin.referenceSymbol({\n category: 'external',\n resource: 'client.Composable',\n }).placeholder,\n )\n .default($.type.literal('$fetch')),\n )\n .generic(nuxtTypeDefault, (t) =>\n t.$if(symbolResponse, (t, s) =>\n t.extends(s.placeholder).default(s.placeholder),\n ),\n ),\n (m) =>\n m.generic('ThrowOnError', (t) =>\n t\n .extends('boolean')\n .default(\n ('throwOnError' in client.config\n ? client.config.throwOnError\n : false) ?? false,\n ),\n ),\n )\n .params(...opParameters.parameters)\n .do(...statements),\n );\n\n if (!currentClass.nodes.length) {\n currentClass.nodes.push(functionNode);\n } else {\n currentClass.nodes.push($.newline(), functionNode);\n }\n\n currentClass.methods.add(entry.methodName);\n\n sdkClasses.set(symbolCurrentClass.meta!.resourceId!, currentClass);\n });\n }\n },\n {\n order: 'declarations',\n },\n );\n\n const symbolHeyApiClient = plugin.config.instance\n ? plugin.registerSymbol({\n exported: false,\n kind: 'class',\n meta: {\n category: 'utility',\n resource: 'class',\n resourceId: 'HeyApiClient',\n tool: 'sdk',\n },\n name: 'HeyApiClient',\n })\n : undefined;\n const symbolHeyApiRegistry = plugin.config.instance\n ? plugin.registerSymbol({\n exported: false,\n kind: 'class',\n meta: {\n category: 'utility',\n resource: 'class',\n resourceId: 'HeyApiRegistry',\n tool: 'sdk',\n },\n name: 'HeyApiRegistry',\n })\n : undefined;\n\n const generateClass = (currentClass: SdkClassEntry) => {\n if (generatedClasses.has(currentClass.className)) {\n return;\n }\n\n const resourceId = currentClass.className;\n generatedClasses.add(resourceId);\n\n if (currentClass.classes.size) {\n for (const childClassName of currentClass.classes) {\n const childClass = sdkClasses.get(childClassName)!;\n generateClass(childClass);\n\n const refChildClass = plugin.referenceSymbol({\n category: 'utility',\n resource: 'class',\n resourceId: childClass.className,\n tool: 'sdk',\n });\n\n const originalMemberName = stringCase({\n case: 'camelCase',\n value: refChildClass.meta!.resourceId!,\n });\n // avoid collisions with existing method names\n let memberName = originalMemberName;\n if (currentClass.methods.has(memberName)) {\n let index = 2;\n let attempt = `${memberName}${index}`;\n while (currentClass.methods.has(attempt)) {\n attempt = `${memberName}${index++}`;\n }\n memberName = attempt;\n }\n currentClass.methods.add(memberName);\n\n const subClassReferenceNode = plugin.isSymbolRegistered(\n refChildClass.id,\n )\n ? $.field(memberName, (f) =>\n f\n .static(!plugin.config.instance)\n .assign(\n plugin.config.instance\n ? $.new(refChildClass.placeholder).args(\n $.object().prop('client', $('this').attr('client')),\n )\n : $(refChildClass.placeholder),\n ),\n )\n : $.getter(memberName, (g) =>\n g\n .$if(!plugin.config.instance, (g) => g.public().static())\n .do(\n $.return(\n plugin.config.instance\n ? $.new(refChildClass.placeholder).args(\n $.object().prop('client', $('this').attr('client')),\n )\n : refChildClass.placeholder,\n ),\n ),\n );\n\n if (!currentClass.nodes.length) {\n currentClass.nodes.push(subClassReferenceNode);\n } else {\n currentClass.nodes.push($.newline(), subClassReferenceNode);\n }\n }\n }\n\n if (\n symbolHeyApiClient &&\n !plugin.gen.symbols.hasValue(symbolHeyApiClient.id)\n ) {\n const node = createClientClass({\n plugin,\n symbol: symbolHeyApiClient,\n });\n plugin.setSymbolValue(symbolHeyApiClient, node);\n }\n\n const symbol = plugin.registerSymbol({\n exported: true,\n kind: 'class',\n meta: {\n category: 'utility',\n resource: 'class',\n resourceId,\n tool: 'sdk',\n },\n name: resourceId,\n });\n\n if (currentClass.root && symbolHeyApiRegistry) {\n const symClient = plugin.getSymbol({\n category: 'client',\n });\n const isClientRequired = !plugin.config.client || !symClient;\n const symbolClient = plugin.referenceSymbol({\n category: 'external',\n resource: 'client.Client',\n });\n const ctor = $.init((i) =>\n i\n .param('args', (p) =>\n p.required(isClientRequired).type(\n $.type\n .object()\n .prop('client', (p) =>\n p.required(isClientRequired).type(symbolClient.placeholder),\n )\n .prop('key', (p) => p.optional().type('string')),\n ),\n )\n .do(\n $('super').call('args'),\n $(symbol.placeholder)\n .attr(registryName)\n .attr('set')\n .call('this', $('args').attr('key').required(isClientRequired)),\n ),\n );\n\n if (!currentClass.nodes.length) {\n currentClass.nodes.unshift(ctor);\n } else {\n currentClass.nodes.unshift(ctor, $.newline());\n }\n\n const node = createRegistryClass({\n plugin,\n sdkName: symbol.placeholder,\n symbol: symbolHeyApiRegistry,\n });\n plugin.setSymbolValue(symbolHeyApiRegistry, node);\n const registryNode = $.field(registryName, (f) =>\n f\n .public()\n .static()\n .readonly()\n .assign(\n $.new(symbolHeyApiRegistry.placeholder).generic(symbol.placeholder),\n ),\n );\n currentClass.nodes.unshift(registryNode, $.newline());\n }\n\n const node = $.class(symbol.placeholder)\n .export(symbol.exported)\n .extends(symbolHeyApiClient?.placeholder)\n .$if(currentClass.root && isAngularClient, (c) =>\n c.decorator(\n plugin.referenceSymbol({\n category: 'external',\n resource: '@angular/core.Injectable',\n }).placeholder,\n $.object().prop('providedIn', $.literal('root')),\n ),\n )\n .do(...currentClass.nodes);\n plugin.setSymbolValue(symbol, node);\n };\n\n for (const sdkClass of sdkClasses.values()) {\n generateClass(sdkClass);\n }\n};\n","import type { IR } from '~/ir/types';\nimport { getClientPlugin } from '~/plugins/@hey-api/client-core/utils';\nimport {\n createOperationComment,\n isOperationOptionsRequired,\n} from '~/plugins/shared/utils/operation';\nimport { $ } from '~/ts-dsl';\nimport { reservedJavaScriptKeywordsRegExp } from '~/utils/regexp';\n\nimport type { HeyApiSdkPlugin } from '../types';\nimport { nuxtTypeComposable, nuxtTypeDefault } from './constants';\nimport { operationParameters, operationStatements } from './operation';\n\nconst serviceFunctionIdentifier = ({\n id,\n operation,\n plugin,\n}: {\n id: string;\n operation: IR.OperationObject;\n plugin: HeyApiSdkPlugin['Instance'];\n}) => {\n if (plugin.config.methodNameBuilder) {\n return plugin.config.methodNameBuilder(operation);\n }\n\n if (id.match(reservedJavaScriptKeywordsRegExp)) {\n return `${id}_`;\n }\n\n return id;\n};\n\nexport const generateFlatSdk = ({\n plugin,\n}: {\n plugin: HeyApiSdkPlugin['Instance'];\n}): void => {\n const client = getClientPlugin(plugin.context.config);\n const isNuxtClient = client.name === '@hey-api/client-nuxt';\n\n plugin.forEach(\n 'operation',\n (event) => {\n const { operation } = event;\n const isRequiredOptions = isOperationOptionsRequired({\n context: plugin.context,\n operation,\n });\n const symbolResponse = isNuxtClient\n ? plugin.querySymbol({\n category: 'type',\n resource: 'operation',\n resourceId: operation.id,\n role: 'response',\n })\n : undefined;\n const opParameters = operationParameters({\n isRequiredOptions,\n operation,\n plugin,\n });\n const statements = operationStatements({\n isRequiredOptions,\n opParameters,\n operation,\n plugin,\n });\n const symbol = plugin.registerSymbol({\n exported: true,\n meta: {\n category: 'sdk',\n path: event._path,\n resource: 'operation',\n resourceId: operation.id,\n tags: event.tags,\n tool: 'sdk',\n },\n name: serviceFunctionIdentifier({\n id: operation.id,\n operation,\n plugin,\n }),\n });\n const node = $.const(symbol.placeholder)\n .export(symbol.exported)\n .$if(createOperationComment(operation), (c, v) => c.doc(v))\n .assign(\n $.func()\n .params(...opParameters.parameters)\n .$if(\n isNuxtClient,\n (f) =>\n f\n .generic(nuxtTypeComposable, (g) =>\n g\n .extends(\n plugin.referenceSymbol({\n category: 'external',\n resource: 'client.Composable',\n }).placeholder,\n )\n .default($.type.literal('$fetch')),\n )\n .generic(nuxtTypeDefault, (g) =>\n g.$if(\n symbolResponse,\n (t, s) => t.extends(s.placeholder).default(s.placeholder),\n (t) => t.default('undefined'),\n ),\n ),\n (f) =>\n f.generic('ThrowOnError', (g) =>\n g\n .extends('boolean')\n .default(\n ('throwOnError' in client.config\n ? client.config.throwOnError\n : false) ?? false,\n ),\n ),\n )\n .do(...statements),\n );\n plugin.setSymbolValue(symbol, node);\n },\n {\n order: 'declarations',\n },\n );\n};\n","import { clientFolderAbsolutePath } from '~/generate/client';\nimport { getClientPlugin } from '~/plugins/@hey-api/client-core/utils';\nimport { $ } from '~/ts-dsl';\n\nimport type { HeyApiSdkPlugin } from '../types';\nimport { nuxtTypeDefault, nuxtTypeResponse } from './constants';\n\nexport const createTypeOptions = ({\n plugin,\n}: {\n plugin: HeyApiSdkPlugin['Instance'];\n}) => {\n const clientModule = clientFolderAbsolutePath(plugin.context.config);\n const client = getClientPlugin(plugin.context.config);\n const isNuxtClient = client.name === '@hey-api/client-nuxt';\n\n const symbolTDataShape = plugin.registerSymbol({\n external: clientModule,\n kind: 'type',\n name: 'TDataShape',\n });\n const symbolClient = plugin.registerSymbol({\n external: clientModule,\n kind: 'type',\n meta: {\n category: 'external',\n resource: 'client.Client',\n tool: client.name,\n },\n name: 'Client',\n });\n const symbolClientOptions = plugin.registerSymbol({\n external: clientModule,\n kind: 'type',\n name: 'Options',\n });\n const symbolOptions = plugin.registerSymbol({\n exported: true,\n kind: 'type',\n meta: {\n category: 'type',\n resource: 'client-options',\n tool: 'sdk',\n },\n name: 'Options',\n });\n\n const typeOptions = $.type\n .alias(symbolOptions.placeholder)\n .export(symbolOptions.exported)\n .$if(\n isNuxtClient,\n (t) =>\n t\n .generic('TComposable', (g) =>\n g\n .extends(\n plugin.referenceSymbol({\n category: 'external',\n resource: 'client.Composable',\n }).placeholder,\n )\n .default($.type.literal('$fetch')),\n )\n .generic('TData', (g) =>\n g\n .extends(symbolTDataShape.placeholder)\n .default(symbolTDataShape.placeholder),\n )\n .generic(nuxtTypeResponse, (g) => g.default('unknown'))\n .generic(nuxtTypeDefault, (g) => g.default('undefined')),\n (t) =>\n t\n .generic('TData', (g) =>\n g\n .extends(symbolTDataShape.placeholder)\n .default(symbolTDataShape.placeholder),\n )\n .generic('ThrowOnError', (g) =>\n g.extends('boolean').default('boolean'),\n ),\n )\n .type(\n $.type.and(\n $.type(symbolClientOptions.placeholder).$if(\n isNuxtClient,\n (t) =>\n t\n .generic('TComposable')\n .generic('TData')\n .generic(nuxtTypeResponse)\n .generic(nuxtTypeDefault),\n (t) => t.generic('TData').generic('ThrowOnError'),\n ),\n $.type\n .object()\n .prop('client', (p) =>\n p\n .doc([\n 'You can provide a client instance returned by `createClient()` instead of',\n 'individual options. This might be also useful if you want to implement a',\n 'custom client.',\n ])\n .required(!plugin.config.client && !plugin.config.instance)\n .type(symbolClient.placeholder),\n )\n .prop('meta', (p) =>\n p\n .doc([\n 'You can pass arbitrary values through the `meta` object. This can be',\n \"used to access values that aren't defined as part of the SDK function.\",\n ])\n .optional()\n .type($.type('Record').generics('string', 'unknown')),\n ),\n ),\n );\n plugin.setSymbolValue(symbolOptions, typeOptions);\n};\n","import { clientFolderAbsolutePath } from '~/generate/client';\nimport { getClientPlugin } from '~/plugins/@hey-api/client-core/utils';\n\nimport { generateClassSdk } from '../shared/class';\nimport { generateFlatSdk } from '../shared/functions';\nimport { createTypeOptions } from '../shared/typeOptions';\nimport type { HeyApiSdkPlugin } from '../types';\n\nexport const handlerV1: HeyApiSdkPlugin['Handler'] = ({ plugin }) => {\n const clientModule = clientFolderAbsolutePath(plugin.context.config);\n const client = getClientPlugin(plugin.context.config);\n const isAngularClient = client.name === '@hey-api/client-angular';\n const isNuxtClient = client.name === '@hey-api/client-nuxt';\n\n plugin.registerSymbol({\n external: clientModule,\n meta: {\n category: 'external',\n resource: 'client.formDataBodySerializer',\n tool: client.name,\n },\n name: 'formDataBodySerializer',\n });\n plugin.registerSymbol({\n external: clientModule,\n meta: {\n category: 'external',\n resource: 'client.urlSearchParamsBodySerializer',\n tool: client.name,\n },\n name: 'urlSearchParamsBodySerializer',\n });\n plugin.registerSymbol({\n external: clientModule,\n meta: {\n category: 'external',\n resource: 'client.buildClientParams',\n tool: client.name,\n },\n name: 'buildClientParams',\n });\n if (isNuxtClient) {\n plugin.registerSymbol({\n external: clientModule,\n kind: 'type',\n meta: {\n category: 'external',\n resource: 'client.Composable',\n tool: client.name,\n },\n name: 'Composable',\n });\n }\n if (isAngularClient && plugin.config.asClass) {\n plugin.registerSymbol({\n external: '@angular/core',\n meta: {\n category: 'external',\n resource: '@angular/core.Injectable',\n },\n name: 'Injectable',\n });\n }\n\n createTypeOptions({ plugin });\n\n if (plugin.config.asClass) {\n generateClassSdk({ plugin });\n } else {\n generateFlatSdk({ plugin });\n }\n};\n","import type { HeyApiSdkPlugin } from './types';\nimport { handlerV1 } from './v1/plugin';\n\nexport const handler: HeyApiSdkPlugin['Handler'] = (args) => handlerV1(args);\n","import { definePluginConfig } from '~/plugins/shared/utils/config';\n\nimport { handler } from './plugin';\nimport type { HeyApiSdkPlugin } from './types';\n\nexport const defaultConfig: HeyApiSdkPlugin['Config'] = {\n config: {\n asClass: false,\n auth: true,\n classNameBuilder: '{{name}}',\n classStructure: 'auto',\n client: true,\n exportFromIndex: true,\n instance: false,\n operationId: true,\n paramsStructure: 'grouped',\n response: 'body',\n responseStyle: 'fields',\n transformer: false,\n validator: false,\n },\n dependencies: ['@hey-api/typescript'],\n handler,\n name: '@hey-api/sdk',\n resolveConfig: (plugin, context) => {\n if (plugin.config.client) {\n if (typeof plugin.config.client === 'boolean') {\n plugin.config.client = context.pluginByTag('client', {\n defaultPlugin: '@hey-api/client-fetch',\n });\n }\n\n plugin.dependencies.add(plugin.config.client!);\n } else {\n plugin.config.client = false;\n }\n\n if (plugin.config.transformer) {\n if (typeof plugin.config.transformer === 'boolean') {\n plugin.config.transformer = context.pluginByTag('transformer');\n }\n\n plugin.dependencies.add(plugin.config.transformer!);\n } else {\n plugin.config.transformer = false;\n }\n\n if (typeof plugin.config.validator !== 'object') {\n plugin.config.validator = {\n request: plugin.config.validator,\n response: plugin.config.validator,\n };\n }\n\n if (plugin.config.validator.request) {\n if (typeof plugin.config.validator.request === 'boolean') {\n plugin.config.validator.request = context.pluginByTag('validator');\n }\n\n plugin.dependencies.add(plugin.config.validator.request!);\n } else {\n plugin.config.validator.request = false;\n }\n\n if (plugin.config.validator.response) {\n if (typeof plugin.config.validator.response === 'boolean') {\n plugin.config.validator.response = context.pluginByTag('validator');\n }\n\n plugin.dependencies.add(plugin.config.validator.response!);\n } else {\n plugin.config.validator.response = false;\n }\n\n if (plugin.config.instance) {\n if (typeof plugin.config.instance !== 'string') {\n plugin.config.instance = 'Sdk';\n }\n\n plugin.config.asClass = true;\n } else {\n plugin.config.instance = false;\n }\n\n // Set default classNameBuilder based on client type\n if (plugin.config.classNameBuilder === '{{name}}') {\n if (plugin.config.client === '@hey-api/client-angular') {\n plugin.config.classNameBuilder = '{{name}}Service';\n }\n }\n },\n};\n\n/**\n * Type helper for `@hey-api/sdk` plugin, returns {@link Plugin.Config} object\n */\nexport const defineConfig = definePluginConfig(defaultConfig);\n","import type ts from 'typescript';\n\nimport type { IR } from '~/ir/types';\nimport { $ } from '~/ts-dsl';\n\nimport type { UserConfig } from './types';\n\nexport type ExpressionTransformer = ({\n config,\n dataExpression,\n schema,\n}: {\n config: Omit<UserConfig, 'name'>;\n dataExpression?:\n | ts.Expression\n | ReturnType<typeof $.expr | typeof $.attr>\n | string;\n schema: IR.SchemaObject;\n}) => Array<ReturnType<typeof $.fromValue>> | undefined;\n\nexport const bigIntExpressions: ExpressionTransformer = ({\n dataExpression,\n schema,\n}) => {\n if (schema.type !== 'integer' || schema.format !== 'int64') {\n return;\n }\n\n const bigIntCallExpression =\n dataExpression !== undefined\n ? $('BigInt').call($.expr(dataExpression).attr('toString').call())\n : undefined;\n\n if (bigIntCallExpression) {\n if (typeof dataExpression === 'string') {\n return [bigIntCallExpression];\n }\n\n if (dataExpression) {\n return [$.expr(dataExpression).assign(bigIntCallExpression)];\n }\n }\n\n return;\n};\n\nexport const dateExpressions: ExpressionTransformer = ({\n dataExpression,\n schema,\n}) => {\n if (\n schema.type !== 'string' ||\n !(schema.format === 'date' || schema.format === 'date-time')\n ) {\n return;\n }\n\n if (typeof dataExpression === 'string') {\n return [$.new('Date').arg(dataExpression)];\n }\n\n if (dataExpression) {\n return [$.expr(dataExpression).assign($.new('Date').arg(dataExpression))];\n }\n\n return;\n};\n","import type { SymbolMeta } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport { createOperationKey, operationResponsesMap } from '~/ir/operation';\nimport type { IR } from '~/ir/types';\nimport { buildName } from '~/openApi/shared/utils/name';\nimport { $ } from '~/ts-dsl';\nimport { TsDsl } from '~/ts-dsl';\nimport { refToName } from '~/utils/ref';\n\nimport type { HeyApiTransformersPlugin } from './types';\n\nconst dataVariableName = 'data';\n\n// Track symbols that are currently being built so recursive references\n// can emit calls to transformers that will be implemented later.\nconst buildingSymbols = new Set<number>();\n\ntype Expr = ReturnType<typeof $.fromValue | typeof $.return | typeof $.if>;\n\nconst ensureStatements = (\n nodes: Array<Expr | ts.Expression | ts.Statement>,\n): Array<ts.Statement | ReturnType<typeof $.return>> =>\n nodes.map((node) => $.stmt(node).$render());\n\nconst isNodeReturnStatement = ({\n node,\n}: {\n node: ts.Expression | ts.Statement | Expr;\n}) => {\n if (node instanceof TsDsl) {\n node = node.$render();\n }\n return node.kind === ts.SyntaxKind.ReturnStatement;\n};\n\nconst schemaResponseTransformerNodes = ({\n plugin,\n schema,\n}: {\n plugin: HeyApiTransformersPlugin['Instance'];\n schema: IR.SchemaObject;\n}): Array<ts.Expression | ts.Statement | Expr> => {\n const nodes = processSchemaType({\n dataExpression: $(dataVariableName),\n plugin,\n schema,\n });\n // append return statement if one does not already exist\n if (nodes.length) {\n const last = nodes[nodes.length - 1]!;\n if (!isNodeReturnStatement({ node: last })) {\n nodes.push($.return(dataVariableName));\n }\n }\n return nodes;\n};\n\nconst processSchemaType = ({\n dataExpression,\n plugin,\n schema,\n}: {\n dataExpression?:\n | ts.Expression\n | string\n | ReturnType<typeof $.attr | typeof $.expr>;\n plugin: HeyApiTransformersPlugin['Instance'];\n schema: IR.SchemaObject;\n}): Array<Expr | ts.Expression | ts.Statement> => {\n if (schema.$ref) {\n const query: SymbolMeta = {\n category: 'transform',\n resource: 'definition',\n resourceId: schema.$ref,\n };\n\n let symbol = plugin.getSymbol(query);\n\n if (!symbol) {\n // Register a placeholder symbol immediately and set its value to null\n // as a stop token to prevent infinite recursion for self-referential\n // schemas. We also mark this symbol as \"building\" so that nested\n // references to it can emit calls that will be implemented later.\n symbol = plugin.registerSymbol({\n meta: query,\n name: buildName({\n config: {\n case: 'camelCase',\n name: '{{name}}SchemaResponseTransformer',\n },\n name: refToName(schema.$ref),\n }),\n });\n plugin.setSymbolValue(symbol, null);\n }\n\n // Only compute the implementation if the symbol isn't already being built.\n // This prevents infinite recursion on self-referential schemas. We still\n // allow emitting a call when the symbol is currently being built so\n // parent nodes can reference the transformer that will be emitted later.\n const existingValue = plugin.gen.symbols.getValue(symbol.id);\n if (!existingValue && !buildingSymbols.has(symbol.id)) {\n buildingSymbols.add(symbol.id);\n try {\n const refSchema = plugin.context.resolveIrRef<IR.SchemaObject>(\n schema.$ref,\n );\n const nodes = schemaResponseTransformerNodes({\n plugin,\n schema: refSchema,\n });\n\n if (nodes.length) {\n const node = $.const(symbol.placeholder).assign(\n // TODO: parser - add types, generate types without transforms\n $.func()\n .param(dataVariableName, (p) => p.type('any'))\n .do(...ensureStatements(nodes)),\n );\n plugin.setSymbolValue(symbol, node);\n }\n } finally {\n buildingSymbols.delete(symbol.id);\n }\n }\n\n // Only emit a call if the symbol has a value (implementation) OR the\n // symbol is currently being built (recursive reference) — in the\n // latter case we allow emitting a call that will be implemented later.\n const currentValue = plugin.gen.symbols.getValue(symbol.id);\n if (currentValue || buildingSymbols.has(symbol.id)) {\n const ref = plugin.referenceSymbol(query);\n const callExpression = $(ref.placeholder).call(dataExpression);\n\n if (dataExpression) {\n // In a map callback, the item needs to be returned, not just the transformation result\n if (typeof dataExpression === 'string' && dataExpression === 'item') {\n return [$.return(callExpression)];\n }\n\n return [\n typeof dataExpression === 'string'\n ? callExpression\n : $(dataExpression).assign(callExpression),\n ];\n }\n }\n\n return [];\n }\n\n if (schema.type === 'array') {\n if (!dataExpression || typeof dataExpression === 'string') {\n return [];\n }\n\n // TODO: parser - handle tuples and complex arrays\n const nodes = !schema.items\n ? []\n : processSchemaType({\n dataExpression: 'item',\n plugin,\n schema: schema.items?.[0]\n ? schema.items[0]\n : {\n ...schema,\n type: undefined,\n },\n });\n\n if (!nodes.length) {\n return [];\n }\n\n // Ensure the map callback has a return statement for the item\n const mapCallbackStatements = ensureStatements(nodes);\n const hasReturnStatement = mapCallbackStatements.some((stmt) =>\n isNodeReturnStatement({ node: stmt }),\n );\n\n if (!hasReturnStatement) {\n mapCallbackStatements.push($.return('item'));\n }\n\n return [\n $(dataExpression).assign(\n $(dataExpression)\n .attr('map')\n .call(\n $.func()\n .param('item', (p) => p.type('any'))\n .do(...mapCallbackStatements),\n ),\n ),\n ];\n }\n\n if (schema.type === 'object') {\n let nodes: Array<ts.Expression | ts.Statement | Expr> = [];\n const required = schema.required ?? [];\n\n for (const name in schema.properties) {\n const property = schema.properties[name]!;\n const propertyAccessExpression = $(\n dataExpression || dataVariableName,\n ).attr(name);\n const propertyNodes = processSchemaType({\n dataExpression: propertyAccessExpression,\n plugin,\n schema: property,\n });\n if (!propertyNodes.length) {\n continue;\n }\n const noNullableTypesInSchema = !property.items?.find(\n (x) => x.type === 'null',\n );\n const requiredField = required.includes(name);\n // Cannot fully rely on required fields\n // Such value has to be present, but it doesn't guarantee that this value is not nullish\n if (requiredField && noNullableTypesInSchema) {\n nodes = nodes.concat(propertyNodes);\n } else {\n nodes.push(\n // todo: Probably, it would make more sense to go with if(x !== undefined && x !== null) instead of if(x)\n // this place influences all underlying transformers, while it's not exactly transformer itself\n // Keep in mind that !!0 === false, so it already makes output for Bigint undesirable\n $.if(propertyAccessExpression).do(...ensureStatements(propertyNodes)),\n );\n }\n }\n\n return nodes;\n }\n\n if (schema.items) {\n if (schema.items.length === 1) {\n return processSchemaType({\n dataExpression: 'item',\n plugin,\n schema: schema.items[0]!,\n });\n }\n\n let arrayNodes: Array<ts.Expression | ts.Statement | Expr> = [];\n // process 2 items if one of them is null\n if (\n schema.logicalOperator === 'and' ||\n (schema.items.length === 2 &&\n schema.items.find(\n (item) => item.type === 'null' || item.type === 'void',\n ))\n ) {\n for (const item of schema.items) {\n const nodes = processSchemaType({\n dataExpression: dataExpression || 'item',\n plugin,\n schema: item,\n });\n if (nodes.length) {\n if (dataExpression) {\n arrayNodes = arrayNodes.concat(nodes);\n } else {\n // processed means the item was transformed\n arrayNodes.push(\n $.if('item').do(...ensureStatements(nodes)),\n $.return('item'),\n );\n }\n }\n }\n return arrayNodes;\n }\n\n // assume enums do not contain transformable values\n if (schema.type !== 'enum') {\n if (\n !(schema.items ?? []).every((item) =>\n (\n ['boolean', 'integer', 'null', 'number', 'string'] as ReadonlyArray<\n typeof item.type\n >\n ).includes(item.type),\n )\n ) {\n console.warn(\n `❗️ Transformers warning: schema ${JSON.stringify(schema)} is too complex and won't be currently processed. This will likely produce an incomplete transformer which is not what you want. Please open an issue if you'd like this improved https://github.com/hey-api/openapi-ts/issues`,\n );\n }\n }\n }\n\n for (const transformer of plugin.config.transformers) {\n const t = transformer({\n config: plugin.config,\n dataExpression,\n schema,\n });\n if (t) {\n return t;\n }\n }\n\n return [];\n};\n\n// handles only response transformers for now\nexport const handler: HeyApiTransformersPlugin['Handler'] = ({ plugin }) => {\n plugin.forEach(\n 'operation',\n ({ operation }) => {\n const { response } = operationResponsesMap(operation);\n if (!response) return;\n\n if (response.items && response.items.length > 1) {\n if (plugin.context.config.logs.level === 'debug') {\n console.warn(\n `❗️ Transformers warning: route ${createOperationKey(operation)} has ${response.items.length} non-void success responses. This is currently not handled and we will not generate a response transformer. Please open an issue if you'd like this feature https://github.com/hey-api/openapi-ts/issues`,\n );\n }\n return;\n }\n\n const symbolResponse = plugin.querySymbol({\n category: 'type',\n resource: 'operation',\n resourceId: operation.id,\n role: 'response',\n });\n if (!symbolResponse) return;\n\n // TODO: parser - consider handling simple string response which is also a date\n const nodes = schemaResponseTransformerNodes({\n plugin,\n schema: response,\n });\n if (!nodes.length) return;\n const symbol = plugin.registerSymbol({\n exported: true,\n meta: {\n category: 'transform',\n resource: 'operation',\n resourceId: operation.id,\n role: 'response',\n },\n name: buildName({\n config: {\n case: 'camelCase',\n name: '{{name}}ResponseTransformer',\n },\n name: operation.id,\n }),\n });\n const value = $.const(symbol.placeholder)\n .export(symbol.exported)\n .assign(\n // TODO: parser - add types, generate types without transforms\n $.func()\n .async()\n .param(dataVariableName, (p) => p.type('any'))\n .returns($.type('Promise').generic(symbolResponse.placeholder))\n .do(...ensureStatements(nodes)),\n );\n plugin.setSymbolValue(symbol, value);\n },\n {\n order: 'declarations',\n },\n );\n};\n","import { definePluginConfig } from '~/plugins/shared/utils/config';\n\nimport { bigIntExpressions, dateExpressions } from './expressions';\nimport { handler } from './plugin';\nimport type { HeyApiTransformersPlugin } from './types';\n\nexport const defaultConfig: HeyApiTransformersPlugin['Config'] = {\n config: {\n bigInt: true,\n dates: true,\n exportFromIndex: false,\n transformers: [],\n typeTransformers: [],\n },\n dependencies: ['@hey-api/typescript'],\n handler,\n name: '@hey-api/transformers',\n resolveConfig: (plugin) => {\n if (!plugin.config.transformers) {\n plugin.config.transformers = [];\n }\n\n if (plugin.config.dates) {\n plugin.config.transformers = [\n ...plugin.config.transformers,\n dateExpressions,\n ];\n }\n\n if (plugin.config.bigInt) {\n plugin.config.transformers = [\n ...plugin.config.transformers,\n bigIntExpressions,\n ];\n }\n },\n tags: ['transformer'],\n};\n\n/**\n * Type helper for `@hey-api/transformers`, returns {@link Plugin.Config} object\n */\nexport const defineConfig = definePluginConfig(defaultConfig);\n","import type { Symbol } from '@hey-api/codegen-core';\n\nimport type { IR } from '~/ir/types';\nimport {\n getClientBaseUrlKey,\n getClientPlugin,\n} from '~/plugins/@hey-api/client-core/utils';\nimport type { TypeTsDsl } from '~/ts-dsl';\nimport { $ } from '~/ts-dsl';\nimport { parseUrl } from '~/utils/url';\n\nimport type { HeyApiTypeScriptPlugin } from '../types';\n\nconst serverToBaseUrlType = ({ server }: { server: IR.ServerObject }) => {\n const url = parseUrl(server.url);\n\n if (url.protocol && url.host) {\n return $.type.literal(server.url);\n }\n\n return $.type\n .template()\n .add(url.protocol || $.type('string'))\n .add('://')\n .add(url.host || $.type('string'))\n .add(url.port ? `:${url.port}` : '')\n .add(url.path || '');\n};\n\nexport const createClientOptions = ({\n plugin,\n servers,\n symbolClientOptions,\n}: {\n plugin: HeyApiTypeScriptPlugin['Instance'];\n servers: ReadonlyArray<IR.ServerObject>;\n symbolClientOptions: Symbol;\n}) => {\n const client = getClientPlugin(plugin.context.config);\n\n const types: Array<TypeTsDsl> = servers.map((server) =>\n serverToBaseUrlType({ server }),\n );\n\n if (!servers.length) {\n types.push($.type('string'));\n } else if (\n !('strictBaseUrl' in client.config && client.config.strictBaseUrl)\n ) {\n types.push($.type.and($.type('string'), $.type.object()));\n }\n\n const node = $.type\n .alias(symbolClientOptions.placeholder)\n .export(symbolClientOptions.exported)\n .type(\n $.type\n .object()\n .prop(getClientBaseUrlKey(plugin.context.config), (p) =>\n p.type($.type.or(...types)),\n ),\n );\n plugin.setSymbolValue(symbolClientOptions, node);\n};\n","import type { IR } from '~/ir/types';\nimport { escapeComment } from '~/utils/escape';\n\nexport const createSchemaComment = (\n schema: IR.SchemaObject,\n): ReadonlyArray<string> | undefined => {\n const comments: Array<string> = [];\n\n if (schema.title) {\n comments.push(escapeComment(schema.title));\n }\n\n if (schema.description) {\n if (comments.length) {\n comments.push(''); // Add an empty line between title and description\n }\n comments.push(escapeComment(schema.description));\n }\n\n if (schema.deprecated) {\n if (comments.length) {\n comments.push(''); // Add an empty line before deprecated\n }\n comments.push('@deprecated');\n }\n\n return comments.length ? comments : undefined;\n};\n","import type { Symbol } from '@hey-api/codegen-core';\n\nimport type { IR } from '~/ir/types';\nimport { createSchemaComment } from '~/plugins/shared/utils/schema';\nimport type { MaybeTsDsl, TypeTsDsl } from '~/ts-dsl';\nimport { $ } from '~/ts-dsl';\nimport { numberRegExp } from '~/utils/regexp';\nimport { stringCase } from '~/utils/stringCase';\n\nimport type { HeyApiTypeScriptPlugin } from '../types';\n\nconst schemaToEnumObject = ({\n plugin,\n schema,\n}: {\n plugin: HeyApiTypeScriptPlugin['Instance'];\n schema: IR.SchemaObject;\n}) => {\n const typeofItems: Array<\n | 'bigint'\n | 'boolean'\n | 'function'\n | 'number'\n | 'object'\n | 'string'\n | 'symbol'\n | 'undefined'\n > = [];\n\n const obj = (schema.items ?? []).map((item, index) => {\n const typeOfItemConst = typeof item.const;\n\n if (!typeofItems.includes(typeOfItemConst)) {\n // track types of enum values because some modes support\n // only enums with string and number types\n typeofItems.push(typeOfItemConst);\n }\n\n let key: string | undefined;\n if (item.title) {\n key = item.title;\n } else if (typeOfItemConst === 'number' || typeOfItemConst === 'string') {\n key = `${item.const}`;\n } else if (typeOfItemConst === 'boolean') {\n key = item.const ? 'true' : 'false';\n } else if (item.const === null) {\n key = 'null';\n } else {\n key = `${index}`;\n }\n\n if (key) {\n key = stringCase({\n case: plugin.config.enums.case,\n stripLeadingSeparators: false,\n value: key,\n });\n\n numberRegExp.lastIndex = 0;\n // TypeScript enum keys cannot be numbers\n if (\n numberRegExp.test(key) &&\n plugin.config.enums.enabled &&\n (plugin.config.enums.mode === 'typescript' ||\n plugin.config.enums.mode === 'typescript-const')\n ) {\n key = `_${key}`;\n }\n }\n\n return {\n key,\n schema: item,\n };\n });\n\n return {\n obj,\n typeofItems,\n };\n};\n\nexport const exportType = ({\n plugin,\n schema,\n symbol,\n type,\n}: {\n plugin: HeyApiTypeScriptPlugin['Instance'];\n schema: IR.SchemaObject;\n symbol: Symbol;\n type: MaybeTsDsl<TypeTsDsl>;\n}) => {\n // root enums have an additional export\n if (schema.type === 'enum' && plugin.config.enums.enabled) {\n const enumObject = schemaToEnumObject({ plugin, schema });\n\n if (plugin.config.enums.mode === 'javascript') {\n // JavaScript enums might want to ignore null values\n if (\n plugin.config.enums.constantsIgnoreNull &&\n enumObject.typeofItems.includes('object')\n ) {\n enumObject.obj = enumObject.obj.filter(\n (item) => item.schema.const !== null,\n );\n }\n\n const objectNode = $.const(symbol.placeholder)\n .export()\n .$if(createSchemaComment(schema), (c, v) => c.doc(v))\n .assign(\n $.object(\n ...enumObject.obj.map((item) =>\n $.prop({ kind: 'prop', name: item.key })\n .$if(createSchemaComment(item.schema), (p, v) => p.doc(v))\n .value($.fromValue(item.schema.const)),\n ),\n ).as('const'),\n );\n\n const node = $.type\n .alias(symbol.placeholder)\n .export()\n .$if(createSchemaComment(schema), (t, v) => t.doc(v))\n .type(\n $.type(symbol.placeholder)\n .idx($.type(symbol.placeholder).typeof().keyof())\n .typeof(),\n );\n plugin.setSymbolValue(symbol, [objectNode, node]);\n return;\n } else if (\n plugin.config.enums.mode === 'typescript' ||\n plugin.config.enums.mode === 'typescript-const'\n ) {\n // TypeScript enums support only string and number values\n const shouldCreateTypeScriptEnum = !enumObject.typeofItems.some(\n (type) => type !== 'number' && type !== 'string',\n );\n if (shouldCreateTypeScriptEnum) {\n const enumNode = $.enum(symbol.placeholder)\n .export()\n .$if(createSchemaComment(schema), (e, v) => e.doc(v))\n .const(plugin.config.enums.mode === 'typescript-const')\n .members(\n ...enumObject.obj.map((item) =>\n $.member(item.key)\n .$if(createSchemaComment(item.schema), (m, v) => m.doc(v))\n .value($.fromValue(item.schema.const)),\n ),\n );\n plugin.setSymbolValue(symbol, enumNode);\n return;\n }\n }\n }\n\n const node = $.type\n .alias(symbol.placeholder)\n .export(symbol.exported)\n .$if(createSchemaComment(schema), (t, v) => t.doc(v))\n .type(type);\n plugin.setSymbolValue(symbol, node);\n};\n","import { operationResponsesMap } from '~/ir/operation';\nimport { deduplicateSchema } from '~/ir/schema';\nimport type { IR } from '~/ir/types';\nimport { buildName } from '~/openApi/shared/utils/name';\nimport { $ } from '~/ts-dsl';\n\nimport { irSchemaToAst } from '../v1/plugin';\nimport type { IrSchemaToAstOptions } from './types';\n\nconst irParametersToIrSchema = ({\n parameters,\n}: {\n parameters: Record<string, IR.ParameterObject>;\n}): IR.SchemaObject => {\n const irSchema: IR.SchemaObject = {\n type: 'object',\n };\n\n if (parameters) {\n const properties: Record<string, IR.SchemaObject> = {};\n const required: Array<string> = [];\n\n for (const key in parameters) {\n const parameter = parameters[key]!;\n\n properties[parameter.name] = deduplicateSchema({\n detectFormat: false,\n schema: parameter.schema,\n });\n\n if (parameter.required) {\n required.push(parameter.name);\n }\n }\n\n irSchema.properties = properties;\n\n if (required.length) {\n irSchema.required = required;\n }\n }\n\n return irSchema;\n};\n\nconst operationToDataType = ({\n operation,\n plugin,\n state,\n}: IrSchemaToAstOptions & {\n operation: IR.OperationObject;\n}) => {\n const data: IR.SchemaObject = {\n type: 'object',\n };\n const dataRequired: Array<string> = [];\n\n if (!data.properties) {\n data.properties = {};\n }\n\n if (operation.body) {\n data.properties.body = operation.body.schema;\n\n if (operation.body.required) {\n dataRequired.push('body');\n }\n } else {\n data.properties.body = {\n type: 'never',\n };\n }\n\n // TODO: parser - handle cookie parameters\n\n // do not set headers to never so we can always pass arbitrary values\n if (operation.parameters?.header) {\n data.properties.headers = irParametersToIrSchema({\n parameters: operation.parameters.header,\n });\n\n if (data.properties.headers.required) {\n dataRequired.push('headers');\n }\n }\n\n if (operation.parameters?.path) {\n data.properties.path = irParametersToIrSchema({\n parameters: operation.parameters.path,\n });\n\n if (data.properties.path.required) {\n dataRequired.push('path');\n }\n } else {\n data.properties.path = {\n type: 'never',\n };\n }\n\n if (operation.parameters?.query) {\n data.properties.query = irParametersToIrSchema({\n parameters: operation.parameters.query,\n });\n\n if (data.properties.query.required) {\n dataRequired.push('query');\n }\n } else {\n data.properties.query = {\n type: 'never',\n };\n }\n\n data.properties.url = {\n const: operation.path,\n type: 'string',\n };\n dataRequired.push('url');\n\n data.required = dataRequired;\n\n const symbol = plugin.registerSymbol({\n exported: true,\n kind: 'type',\n meta: {\n category: 'type',\n path: state.path.value,\n resource: 'operation',\n resourceId: operation.id,\n role: 'data',\n tags: state.tags?.value,\n tool: 'typescript',\n },\n name: buildName({\n config: plugin.config.requests,\n name: operation.id,\n }),\n });\n const node = $.type\n .alias(symbol.placeholder)\n .export(symbol.exported)\n .type(\n irSchemaToAst({\n plugin,\n schema: data,\n state,\n }),\n );\n plugin.setSymbolValue(symbol, node);\n};\n\nexport const operationToType = ({\n operation,\n plugin,\n state,\n}: IrSchemaToAstOptions & {\n operation: IR.OperationObject;\n}) => {\n operationToDataType({ operation, plugin, state });\n\n const { error, errors, response, responses } =\n operationResponsesMap(operation);\n\n if (errors) {\n const symbolErrors = plugin.registerSymbol({\n exported: true,\n kind: 'type',\n meta: {\n category: 'type',\n path: state.path.value,\n resource: 'operation',\n resourceId: operation.id,\n role: 'errors',\n tags: state.tags?.value,\n tool: 'typescript',\n },\n name: buildName({\n config: plugin.config.errors,\n name: operation.id,\n }),\n });\n const node = $.type\n .alias(symbolErrors.placeholder)\n .export(symbolErrors.exported)\n .type(\n irSchemaToAst({\n plugin,\n schema: errors,\n state,\n }),\n );\n plugin.setSymbolValue(symbolErrors, node);\n\n if (error) {\n const symbol = plugin.registerSymbol({\n exported: true,\n kind: 'type',\n meta: {\n category: 'type',\n path: state.path.value,\n resource: 'operation',\n resourceId: operation.id,\n role: 'error',\n tags: state.tags?.value,\n tool: 'typescript',\n },\n name: buildName({\n config: {\n case: plugin.config.errors.case,\n name: plugin.config.errors.error,\n },\n name: operation.id,\n }),\n });\n const node = $.type\n .alias(symbol.placeholder)\n .export(symbol.exported)\n .type(\n $.type(symbolErrors.placeholder).idx(\n $.type(symbolErrors.placeholder).keyof(),\n ),\n );\n plugin.setSymbolValue(symbol, node);\n }\n }\n\n if (responses) {\n const symbolResponses = plugin.registerSymbol({\n exported: true,\n kind: 'type',\n meta: {\n category: 'type',\n path: state.path.value,\n resource: 'operation',\n resourceId: operation.id,\n role: 'responses',\n tags: state.tags?.value,\n tool: 'typescript',\n },\n name: buildName({\n config: plugin.config.responses,\n name: operation.id,\n }),\n });\n const node = $.type\n .alias(symbolResponses.placeholder)\n .export(symbolResponses.exported)\n .type(\n irSchemaToAst({\n plugin,\n schema: responses,\n state,\n }),\n );\n plugin.setSymbolValue(symbolResponses, node);\n\n if (response) {\n const symbol = plugin.registerSymbol({\n exported: true,\n kind: 'type',\n meta: {\n category: 'type',\n path: state.path.value,\n resource: 'operation',\n resourceId: operation.id,\n role: 'response',\n tags: state.tags?.value,\n tool: 'typescript',\n },\n name: buildName({\n config: {\n case: plugin.config.responses.case,\n name: plugin.config.responses.response,\n },\n name: operation.id,\n }),\n });\n const node = $.type\n .alias(symbol.placeholder)\n .export(symbol.exported)\n .type(\n $.type(symbolResponses.placeholder).idx(\n $.type(symbolResponses.placeholder).keyof(),\n ),\n );\n plugin.setSymbolValue(symbol, node);\n }\n }\n};\n","import type { IR } from '~/ir/types';\nimport { buildName } from '~/openApi/shared/utils/name';\nimport { createSchemaComment } from '~/plugins/shared/utils/schema';\nimport { $ } from '~/ts-dsl';\n\nimport { irSchemaToAst } from '../v1/plugin';\nimport type { IrSchemaToAstOptions } from './types';\n\nconst operationToDataType = ({\n operation,\n plugin,\n state,\n}: IrSchemaToAstOptions & {\n operation: IR.OperationObject;\n}): string => {\n const data: IR.SchemaObject = {\n type: 'object',\n };\n const dataRequired: Array<string> = [];\n\n if (!data.properties) {\n data.properties = {};\n }\n\n if (operation.body) {\n const symbolWebhookPayload = plugin.registerSymbol({\n exported: true,\n kind: 'type',\n meta: {\n category: 'type',\n path: state.path.value,\n resource: 'webhook',\n resourceId: operation.id,\n role: 'data',\n tags: state.tags?.value,\n tool: 'typescript',\n },\n name: buildName({\n config: {\n case: plugin.config.webhooks.case,\n name: plugin.config.webhooks.payload,\n },\n name: operation.id,\n }),\n });\n const node = $.type\n .alias(symbolWebhookPayload.placeholder)\n .export(symbolWebhookPayload.exported)\n .$if(createSchemaComment(operation.body.schema), (t, v) => t.doc(v))\n .type(\n irSchemaToAst({\n plugin,\n schema: operation.body.schema,\n state,\n }),\n );\n plugin.setSymbolValue(symbolWebhookPayload, node);\n\n plugin.registerSymbol({\n exported: true,\n kind: 'type',\n meta: {\n category: 'type',\n path: state.path.value,\n resource: 'definition',\n resourceId: symbolWebhookPayload.placeholder,\n tags: state.tags?.value,\n tool: 'typescript',\n },\n name: symbolWebhookPayload.name,\n placeholder: symbolWebhookPayload.placeholder,\n });\n data.properties.body = { $ref: symbolWebhookPayload.placeholder };\n dataRequired.push('body');\n } else {\n data.properties.body = { type: 'never' };\n }\n\n data.properties.key = {\n const: operation.path,\n type: 'string',\n };\n dataRequired.push('key');\n\n data.properties.path = { type: 'never' };\n data.properties.query = { type: 'never' };\n\n data.required = dataRequired;\n\n const symbolWebhookRequest = plugin.registerSymbol({\n exported: true,\n kind: 'type',\n meta: {\n category: 'type',\n path: state.path.value,\n resource: 'webhook',\n resourceId: operation.id,\n role: 'data',\n tags: state.tags?.value,\n tool: 'typescript',\n },\n name: buildName({\n config: plugin.config.webhooks,\n name: operation.id,\n }),\n });\n const node = $.type\n .alias(symbolWebhookRequest.placeholder)\n .export(symbolWebhookRequest.exported)\n .type(\n irSchemaToAst({\n plugin,\n schema: data,\n state,\n }),\n );\n plugin.setSymbolValue(symbolWebhookRequest, node);\n\n return symbolWebhookRequest.placeholder;\n};\n\nexport const webhookToType = ({\n operation,\n plugin,\n state,\n}: IrSchemaToAstOptions & {\n operation: IR.OperationObject;\n}): string => {\n const name = operationToDataType({ operation, plugin, state });\n return name;\n\n // don't handle webhook responses for now, users only need requestBody\n};\n","import type { Symbol } from '@hey-api/codegen-core';\n\nimport { $ } from '~/ts-dsl';\n\nimport type { HeyApiTypeScriptPlugin } from '../types';\n\nexport const createWebhooks = ({\n plugin,\n symbolWebhooks,\n webhookNames,\n}: {\n plugin: HeyApiTypeScriptPlugin['Instance'];\n symbolWebhooks: Symbol;\n webhookNames: ReadonlyArray<string>;\n}) => {\n if (!webhookNames.length) return;\n\n const node = $.type\n .alias(symbolWebhooks.placeholder)\n .export(symbolWebhooks.exported)\n .type($.type.or(...webhookNames));\n plugin.setSymbolValue(symbolWebhooks, node);\n};\n","import { deduplicateSchema } from '~/ir/schema';\nimport type { SchemaWithType } from '~/plugins';\nimport { toRef } from '~/plugins/shared/utils/refs';\nimport type { MaybeTsDsl, TypeTsDsl } from '~/ts-dsl';\nimport { $ } from '~/ts-dsl';\n\nimport type { IrSchemaToAstOptions } from '../../shared/types';\nimport { irSchemaToAst } from '../plugin';\n\nexport const arrayToAst = ({\n plugin,\n schema,\n state,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'array'>;\n}): TypeTsDsl => {\n if (!schema.items) {\n return $.type('Array').generic($.type(plugin.config.topType));\n }\n\n schema = deduplicateSchema({ detectFormat: true, schema });\n\n const itemTypes: Array<MaybeTsDsl<TypeTsDsl>> = [];\n\n if (schema.items) {\n schema.items.forEach((item, index) => {\n const type = irSchemaToAst({\n plugin,\n schema: item,\n state: {\n ...state,\n path: toRef([...state.path.value, 'items', index]),\n },\n });\n itemTypes.push(type);\n });\n }\n\n if (itemTypes.length === 1) {\n return $.type('Array').generic(itemTypes[0]!);\n }\n\n return schema.logicalOperator === 'and'\n ? $.type('Array').generic($.type.and(...itemTypes))\n : $.type('Array').generic($.type.or(...itemTypes));\n};\n","import type { SchemaWithType } from '~/plugins';\nimport type { TypeTsDsl } from '~/ts-dsl';\nimport { $ } from '~/ts-dsl';\n\nimport type { IrSchemaToAstOptions } from '../../shared/types';\n\nexport const booleanToAst = ({\n schema,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'boolean'>;\n}): TypeTsDsl => {\n if (schema.const !== undefined) {\n return $.type.literal(schema.const as boolean);\n }\n\n return $.type('boolean');\n};\n","import type { SchemaWithType } from '~/plugins';\nimport type { MaybeTsDsl, TypeTsDsl } from '~/ts-dsl';\n\nimport type { IrSchemaToAstOptions } from '../../shared/types';\nimport { irSchemaToAst } from '../plugin';\n\nexport const enumToAst = ({\n plugin,\n schema,\n state,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'enum'>;\n}): MaybeTsDsl<TypeTsDsl> => {\n const type = irSchemaToAst({\n plugin,\n schema: {\n ...schema,\n type: undefined,\n },\n state,\n });\n return type;\n};\n","import type { SchemaWithType } from '~/plugins';\nimport type { TypeTsDsl } from '~/ts-dsl';\nimport { $ } from '~/ts-dsl';\n\nimport type { IrSchemaToAstOptions } from '../../shared/types';\n\nexport const neverToAst = (\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _args: IrSchemaToAstOptions & {\n schema: SchemaWithType<'never'>;\n },\n): TypeTsDsl => {\n const node = $.type('never');\n return node;\n};\n","import type { SchemaWithType } from '~/plugins';\nimport type { TypeTsDsl } from '~/ts-dsl';\nimport { $ } from '~/ts-dsl';\n\nimport type { IrSchemaToAstOptions } from '../../shared/types';\n\nexport const nullToAst = (\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _args: IrSchemaToAstOptions & {\n schema: SchemaWithType<'null'>;\n },\n): TypeTsDsl => {\n const node = $.type.literal(null);\n return node;\n};\n","import type { SchemaWithType } from '~/plugins';\nimport type { TypeTsDsl } from '~/ts-dsl';\nimport { $ } from '~/ts-dsl';\n\nimport type { IrSchemaToAstOptions } from '../../shared/types';\n\nexport const numberToAst = ({\n plugin,\n schema,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'integer' | 'number'>;\n}): TypeTsDsl => {\n if (schema.const !== undefined) {\n return $.type.literal(schema.const as number);\n }\n\n if (schema.type === 'integer' && schema.format === 'int64') {\n // TODO: parser - add ability to skip type transformers\n if (plugin.getPlugin('@hey-api/transformers')?.config.bigInt) {\n return $.type('bigint');\n }\n }\n\n return $.type('number');\n};\n","import type { IR } from '~/ir/types';\nimport type { SchemaWithType } from '~/plugins';\nimport { toRef } from '~/plugins/shared/utils/refs';\nimport { createSchemaComment } from '~/plugins/shared/utils/schema';\nimport type { TypeTsDsl } from '~/ts-dsl';\nimport { $ } from '~/ts-dsl';\n\nimport type { IrSchemaToAstOptions } from '../../shared/types';\nimport { irSchemaToAst } from '../plugin';\n\nexport const objectToAst = ({\n plugin,\n schema,\n state,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'object'>;\n}): TypeTsDsl => {\n // TODO: parser - handle constants\n const shape = $.type.object();\n const required = schema.required ?? [];\n let indexSchemas: Array<IR.SchemaObject> = [];\n let hasOptionalProperties = false;\n\n for (const name in schema.properties) {\n const property = schema.properties[name]!;\n const propertyType = irSchemaToAst({\n plugin,\n schema: property,\n state: {\n ...state,\n path: toRef([...state.path.value, 'properties', name]),\n },\n });\n const isRequired = required.includes(name);\n shape.prop(name, (p) =>\n p\n .$if(createSchemaComment(property), (p, v) => p.doc(v))\n .readonly(property.accessScope === 'read')\n .required(isRequired)\n .type(propertyType),\n );\n indexSchemas.push(property);\n\n if (!isRequired) {\n hasOptionalProperties = true;\n }\n }\n\n // include pattern value schemas into the index union\n if (schema.patternProperties) {\n for (const pattern in schema.patternProperties) {\n const ir = schema.patternProperties[pattern]!;\n indexSchemas.unshift(ir);\n }\n }\n\n const hasPatterns =\n !!schema.patternProperties &&\n Object.keys(schema.patternProperties).length > 0;\n\n const addPropsRaw = schema.additionalProperties;\n const addPropsObj =\n addPropsRaw !== false && addPropsRaw\n ? (addPropsRaw as IR.SchemaObject)\n : undefined;\n const shouldCreateIndex =\n hasPatterns ||\n (!!addPropsObj && (addPropsObj.type !== 'never' || !indexSchemas.length));\n\n if (shouldCreateIndex) {\n // only inject additionalProperties when it’s not \"never\"\n const addProps = addPropsObj;\n if (addProps && addProps.type !== 'never') {\n indexSchemas.unshift(addProps);\n } else if (\n !hasPatterns &&\n !indexSchemas.length &&\n addProps &&\n addProps.type === 'never'\n ) {\n // keep \"never\" only when there are NO patterns and NO explicit properties\n indexSchemas = [addProps];\n }\n\n if (hasOptionalProperties) {\n indexSchemas.push({ type: 'undefined' });\n }\n\n const type =\n indexSchemas.length === 1\n ? irSchemaToAst({\n plugin,\n schema: indexSchemas[0]!,\n state,\n })\n : irSchemaToAst({\n plugin,\n schema: { items: indexSchemas, logicalOperator: 'or' },\n state,\n });\n\n if (schema.propertyNames?.$ref) {\n return $.type\n .mapped('key')\n .key(\n irSchemaToAst({\n plugin,\n schema: {\n $ref: schema.propertyNames.$ref,\n },\n state,\n }),\n )\n .optional()\n .type(type);\n }\n\n shape.idxSig('key', (i) => i.key('string').type(type));\n }\n\n return shape;\n};\n","import type { SymbolMeta } from '@hey-api/codegen-core';\n\nimport type { SchemaWithType } from '~/plugins';\nimport type { TypeTsDsl } from '~/ts-dsl';\nimport { $ } from '~/ts-dsl';\nimport { stringCase } from '~/utils/stringCase';\n\nimport type { IrSchemaToAstOptions } from '../../shared/types';\n\nexport const stringToAst = ({\n plugin,\n schema,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'string'>;\n}): TypeTsDsl => {\n if (schema.const !== undefined) {\n return $.type.literal(schema.const as string);\n }\n\n if (schema.format) {\n if (schema.format === 'binary') {\n return $.type.or($.type('Blob'), $.type('File'));\n }\n\n if (schema.format === 'date-time' || schema.format === 'date') {\n // TODO: parser - add ability to skip type transformers\n if (plugin.getPlugin('@hey-api/transformers')?.config.dates) {\n return $.type('Date');\n }\n }\n\n if (schema.format === 'typeid' && typeof schema.example === 'string') {\n const parts = String(schema.example).split('_');\n parts.pop(); // remove the ID part\n const type = parts.join('_');\n\n const query: SymbolMeta = {\n category: 'type',\n resource: 'type-id',\n resourceId: type,\n tool: 'typescript',\n };\n if (!plugin.getSymbol(query)) {\n const queryTypeId: SymbolMeta = {\n category: 'type',\n resource: 'type-id',\n tool: 'typescript',\n variant: 'container',\n };\n\n if (!plugin.getSymbol(queryTypeId)) {\n const symbolTypeId = plugin.registerSymbol({\n exported: true,\n kind: 'type',\n meta: queryTypeId,\n name: 'TypeID',\n });\n const nodeTypeId = $.type\n .alias(symbolTypeId.placeholder)\n .export(symbolTypeId.exported)\n .generic('T', (g) => g.extends('string'))\n .type(\n $.type.template().add($.type('T')).add('_').add($.type('string')),\n );\n plugin.setSymbolValue(symbolTypeId, nodeTypeId);\n }\n\n const symbolTypeId = plugin.referenceSymbol(queryTypeId);\n const symbolTypeName = plugin.registerSymbol({\n exported: true,\n kind: 'type',\n meta: query,\n name: stringCase({\n case: plugin.config.case,\n value: `${type}_id`,\n }),\n });\n const node = $.type\n .alias(symbolTypeName.placeholder)\n .export(symbolTypeName.exported)\n .type($.type(symbolTypeId.placeholder).generic($.type.literal(type)));\n plugin.setSymbolValue(symbolTypeName, node);\n }\n const symbol = plugin.referenceSymbol(query);\n return $.type(symbol.placeholder);\n }\n }\n\n return $.type('string');\n};\n","import type { SchemaWithType } from '~/plugins';\nimport { toRef } from '~/plugins/shared/utils/refs';\nimport type { MaybeTsDsl, TypeTsDsl } from '~/ts-dsl';\nimport { $ } from '~/ts-dsl';\n\nimport type { IrSchemaToAstOptions } from '../../shared/types';\nimport { irSchemaToAst } from '../plugin';\n\nexport const tupleToAst = ({\n plugin,\n schema,\n state,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'tuple'>;\n}): MaybeTsDsl<TypeTsDsl> => {\n let itemTypes: Array<MaybeTsDsl<TypeTsDsl>> = [];\n\n if (schema.const && Array.isArray(schema.const)) {\n itemTypes = schema.const.map((value) => $.type.fromValue(value));\n } else if (schema.items) {\n schema.items.forEach((item, index) => {\n const type = irSchemaToAst({\n plugin,\n schema: item,\n state: {\n ...state,\n path: toRef([...state.path.value, 'items', index]),\n },\n });\n itemTypes.push(type);\n });\n }\n\n return $.type.tuple(...itemTypes);\n};\n","import type { SchemaWithType } from '~/plugins';\nimport type { TypeTsDsl } from '~/ts-dsl';\nimport { $ } from '~/ts-dsl';\n\nimport type { IrSchemaToAstOptions } from '../../shared/types';\n\nexport const undefinedToAst = (\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _args: IrSchemaToAstOptions & {\n schema: SchemaWithType<'undefined'>;\n },\n): TypeTsDsl => {\n const node = $.type('undefined');\n return node;\n};\n","import type { SchemaWithType } from '~/plugins';\nimport type { TypeTsDsl } from '~/ts-dsl';\nimport { $ } from '~/ts-dsl';\n\nimport type { IrSchemaToAstOptions } from '../../shared/types';\n\nexport const unknownToAst = ({\n plugin,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'unknown'>;\n}): TypeTsDsl => {\n const node = $.type(plugin.config.topType);\n return node;\n};\n","import type { SchemaWithType } from '~/plugins';\nimport type { TypeTsDsl } from '~/ts-dsl';\nimport { $ } from '~/ts-dsl';\n\nimport type { IrSchemaToAstOptions } from '../../shared/types';\n\nexport const voidToAst = (\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _args: IrSchemaToAstOptions & {\n schema: SchemaWithType<'void'>;\n },\n): TypeTsDsl => {\n const node = $.type('void');\n return node;\n};\n","import type { SchemaWithType } from '~/plugins';\nimport type { MaybeTsDsl, TypeTsDsl } from '~/ts-dsl';\n\nimport type { IrSchemaToAstOptions } from '../../shared/types';\nimport { arrayToAst } from './array';\nimport { booleanToAst } from './boolean';\nimport { enumToAst } from './enum';\nimport { neverToAst } from './never';\nimport { nullToAst } from './null';\nimport { numberToAst } from './number';\nimport { objectToAst } from './object';\nimport { stringToAst } from './string';\nimport { tupleToAst } from './tuple';\nimport { undefinedToAst } from './undefined';\nimport { unknownToAst } from './unknown';\nimport { voidToAst } from './void';\n\nexport const irSchemaWithTypeToAst = ({\n schema,\n ...args\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType;\n}): MaybeTsDsl<TypeTsDsl> => {\n const transformersPlugin = args.plugin.getPlugin('@hey-api/transformers');\n if (transformersPlugin?.config.typeTransformers) {\n for (const typeTransformer of transformersPlugin.config.typeTransformers) {\n const typeNode = typeTransformer({ schema });\n if (typeNode) {\n return typeNode;\n }\n }\n }\n\n switch (schema.type) {\n case 'array':\n return arrayToAst({\n ...args,\n schema: schema as SchemaWithType<'array'>,\n });\n case 'boolean':\n return booleanToAst({\n ...args,\n schema: schema as SchemaWithType<'boolean'>,\n });\n case 'enum':\n return enumToAst({\n ...args,\n schema: schema as SchemaWithType<'enum'>,\n });\n case 'integer':\n case 'number':\n return numberToAst({\n ...args,\n schema: schema as SchemaWithType<'integer' | 'number'>,\n });\n case 'never':\n return neverToAst({\n ...args,\n schema: schema as SchemaWithType<'never'>,\n });\n case 'null':\n return nullToAst({\n ...args,\n schema: schema as SchemaWithType<'null'>,\n });\n case 'object':\n return objectToAst({\n ...args,\n schema: schema as SchemaWithType<'object'>,\n });\n case 'string':\n return stringToAst({\n ...args,\n schema: schema as SchemaWithType<'string'>,\n });\n case 'tuple':\n return tupleToAst({\n ...args,\n schema: schema as SchemaWithType<'tuple'>,\n });\n case 'undefined':\n return undefinedToAst({\n ...args,\n schema: schema as SchemaWithType<'undefined'>,\n });\n case 'unknown':\n return unknownToAst({\n ...args,\n schema: schema as SchemaWithType<'unknown'>,\n });\n case 'void':\n return voidToAst({\n ...args,\n schema: schema as SchemaWithType<'void'>,\n });\n }\n};\n","import { deduplicateSchema } from '~/ir/schema';\nimport type { IR } from '~/ir/types';\nimport { buildName } from '~/openApi/shared/utils/name';\nimport type { SchemaWithType } from '~/plugins';\nimport { toRefs } from '~/plugins/shared/utils/refs';\nimport type { MaybeTsDsl, TypeTsDsl } from '~/ts-dsl';\nimport { $ } from '~/ts-dsl';\nimport { pathToJsonPointer, refToName } from '~/utils/ref';\n\nimport { createClientOptions } from '../shared/clientOptions';\nimport { exportType } from '../shared/export';\nimport { operationToType } from '../shared/operation';\nimport type { IrSchemaToAstOptions, PluginState } from '../shared/types';\nimport { webhookToType } from '../shared/webhook';\nimport { createWebhooks } from '../shared/webhooks';\nimport type { HeyApiTypeScriptPlugin } from '../types';\nimport { irSchemaWithTypeToAst } from './toAst';\n\nexport const irSchemaToAst = ({\n plugin,\n schema,\n state,\n}: IrSchemaToAstOptions & {\n schema: IR.SchemaObject;\n}): MaybeTsDsl<TypeTsDsl> => {\n if (schema.$ref) {\n const symbol = plugin.referenceSymbol({\n category: 'type',\n resource: 'definition',\n resourceId: schema.$ref,\n });\n return $.type(symbol.placeholder);\n }\n\n if (schema.type) {\n return irSchemaWithTypeToAst({\n plugin,\n schema: schema as SchemaWithType,\n state,\n });\n }\n\n if (schema.items) {\n schema = deduplicateSchema({ detectFormat: false, schema });\n if (schema.items) {\n const itemTypes = schema.items.map((item) =>\n irSchemaToAst({ plugin, schema: item, state }),\n );\n return schema.logicalOperator === 'and'\n ? $.type.and(...itemTypes)\n : $.type.or(...itemTypes);\n }\n\n return irSchemaToAst({ plugin, schema, state });\n }\n\n // catch-all fallback for failed schemas\n return irSchemaWithTypeToAst({\n plugin,\n schema: {\n type: 'unknown',\n },\n state,\n });\n};\n\nconst handleComponent = ({\n plugin,\n schema,\n state,\n}: IrSchemaToAstOptions & {\n schema: IR.SchemaObject;\n}) => {\n const type = irSchemaToAst({ plugin, schema, state });\n\n // Don't tag enums as 'type' since they export runtime artifacts (values)\n const isEnum = schema.type === 'enum' && plugin.config.enums.enabled;\n\n const $ref = pathToJsonPointer(state.path.value);\n const symbol = plugin.registerSymbol({\n exported: true,\n kind: isEnum ? undefined : 'type',\n meta: {\n category: 'type',\n path: state.path.value,\n resource: 'definition',\n resourceId: $ref,\n tags: state.tags?.value,\n tool: 'typescript',\n },\n name: buildName({\n config: plugin.config.definitions,\n name: refToName($ref),\n }),\n });\n exportType({\n plugin,\n schema,\n symbol,\n type,\n });\n};\n\nexport const handlerV1: HeyApiTypeScriptPlugin['Handler'] = ({ plugin }) => {\n // reserve identifier for ClientOptions\n const symbolClientOptions = plugin.registerSymbol({\n exported: true,\n kind: 'type',\n meta: {\n category: 'type',\n resource: 'client',\n role: 'options',\n tool: 'typescript',\n },\n name: buildName({\n config: {\n case: plugin.config.case,\n },\n name: 'ClientOptions',\n }),\n });\n // reserve identifier for Webhooks\n const symbolWebhooks = plugin.registerSymbol({\n exported: true,\n kind: 'type',\n meta: {\n category: 'type',\n resource: 'webhook',\n tool: 'typescript',\n variant: 'container',\n },\n name: buildName({\n config: {\n case: plugin.config.case,\n },\n name: 'Webhooks',\n }),\n });\n\n const servers: Array<IR.ServerObject> = [];\n const webhookNames: Array<string> = [];\n\n plugin.forEach(\n 'operation',\n 'parameter',\n 'requestBody',\n 'schema',\n 'server',\n 'webhook',\n (event) => {\n const state = toRefs<PluginState>({\n path: event._path,\n tags: event.tags,\n });\n switch (event.type) {\n case 'operation':\n operationToType({\n operation: event.operation,\n plugin,\n state,\n });\n break;\n case 'parameter':\n handleComponent({\n plugin,\n schema: event.parameter.schema,\n state,\n });\n break;\n case 'requestBody':\n handleComponent({\n plugin,\n schema: event.requestBody.schema,\n state,\n });\n break;\n case 'schema':\n handleComponent({\n plugin,\n schema: event.schema,\n state,\n });\n break;\n case 'server':\n servers.push(event.server);\n break;\n case 'webhook':\n webhookNames.push(\n webhookToType({\n operation: event.operation,\n plugin,\n state,\n }),\n );\n break;\n }\n },\n {\n order: 'declarations',\n },\n );\n\n createClientOptions({ plugin, servers, symbolClientOptions });\n createWebhooks({ plugin, symbolWebhooks, webhookNames });\n};\n","import type { MaybeTsDsl, TypeTsDsl } from '~/ts-dsl';\n\nimport { irSchemaToAstV1 } from './v1/api';\n\nexport type IApi = {\n schemaToType: (\n args: Parameters<typeof irSchemaToAstV1>[0],\n ) => MaybeTsDsl<TypeTsDsl>;\n};\n\nexport class Api implements IApi {\n schemaToType(\n args: Parameters<typeof irSchemaToAstV1>[0],\n ): MaybeTsDsl<TypeTsDsl> {\n return irSchemaToAstV1(args);\n }\n}\n","import type { HeyApiTypeScriptPlugin } from './types';\nimport { handlerV1 } from './v1/plugin';\n\nexport const handler: HeyApiTypeScriptPlugin['Handler'] = (args) =>\n handlerV1(args);\n","import { definePluginConfig } from '~/plugins/shared/utils/config';\n\nimport { Api } from './api';\nimport { handler } from './plugin';\nimport type { HeyApiTypeScriptPlugin } from './types';\n\nexport const defaultConfig: HeyApiTypeScriptPlugin['Config'] = {\n api: new Api(),\n config: {\n case: 'PascalCase',\n exportFromIndex: true,\n topType: 'unknown',\n },\n handler,\n name: '@hey-api/typescript',\n resolveConfig: (plugin, context) => {\n plugin.config.definitions = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'PascalCase',\n name: '{{name}}',\n },\n mappers: {\n function: (name) => ({ name }),\n string: (name) => ({ name }),\n },\n value: plugin.config.definitions,\n });\n\n plugin.config.enums = context.valueToObject({\n defaultValue: {\n case: 'SCREAMING_SNAKE_CASE',\n constantsIgnoreNull: false,\n enabled: Boolean(plugin.config.enums),\n mode: 'javascript',\n },\n mappers: {\n boolean: (enabled) => ({ enabled }),\n string: (mode) => ({ mode }),\n },\n value: plugin.config.enums,\n });\n\n plugin.config.errors = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'PascalCase',\n error: '{{name}}Error',\n name: '{{name}}Errors',\n },\n mappers: {\n function: (name) => ({ name }),\n string: (name) => ({ name }),\n },\n value: plugin.config.errors,\n });\n\n plugin.config.requests = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'PascalCase',\n name: '{{name}}Data',\n },\n mappers: {\n function: (name) => ({ name }),\n string: (name) => ({ name }),\n },\n value: plugin.config.requests,\n });\n\n plugin.config.responses = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'PascalCase',\n name: '{{name}}Responses',\n response: '{{name}}Response',\n },\n mappers: {\n function: (name) => ({ name }),\n string: (name) => ({ name }),\n },\n value: plugin.config.responses,\n });\n\n plugin.config.webhooks = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'PascalCase',\n name: '{{name}}WebhookRequest',\n payload: '{{name}}WebhookPayload',\n },\n mappers: {\n function: (name) => ({ name }),\n string: (name) => ({ name }),\n },\n value: plugin.config.webhooks,\n });\n },\n};\n\n/**\n * Type helper for `@hey-api/typescript` plugin, returns {@link Plugin.Config} object\n */\nexport const defineConfig = definePluginConfig(defaultConfig);\n","import type { IR } from '~/ir/types';\nimport { $ } from '~/ts-dsl';\n\nimport type { PiniaColadaPlugin } from './types';\n\nexport const handleMeta = (\n plugin: PiniaColadaPlugin['Instance'],\n operation: IR.OperationObject,\n configPath: 'queryOptions' | 'mutationOptions',\n): ReturnType<typeof $.fromValue> | undefined => {\n const metaFn = plugin.config[configPath].meta;\n if (!metaFn) return;\n\n const metaObject = metaFn(operation);\n if (!Object.keys(metaObject).length) return;\n\n return $.fromValue(metaObject);\n};\n","import type { IR } from '~/ir/types';\nimport { getClientPlugin } from '~/plugins/@hey-api/client-core/utils';\nimport { operationOptionsType } from '~/plugins/@hey-api/sdk/shared/operation';\n\nimport type { PiniaColadaPlugin } from './types';\n\nexport const useTypeData = ({\n operation,\n plugin,\n}: {\n operation: IR.OperationObject;\n plugin: PiniaColadaPlugin['Instance'];\n}): string => {\n const pluginSdk = plugin.getPluginOrThrow('@hey-api/sdk');\n const typeData = operationOptionsType({ operation, plugin: pluginSdk });\n return typeData;\n};\n\nexport const useTypeError = ({\n operation,\n plugin,\n}: {\n operation: IR.OperationObject;\n plugin: PiniaColadaPlugin['Instance'];\n}): string => {\n const client = getClientPlugin(plugin.context.config);\n\n const symbolErrorType = plugin.querySymbol({\n category: 'type',\n resource: 'operation',\n resourceId: operation.id,\n role: 'error',\n });\n\n let typeErrorName: string | undefined = symbolErrorType?.placeholder;\n if (!typeErrorName) {\n typeErrorName = 'Error';\n }\n if (client.name === '@hey-api/client-axios') {\n const symbol = plugin.referenceSymbol({\n category: 'external',\n resource: 'axios.AxiosError',\n });\n typeErrorName = `${symbol.placeholder}<${typeErrorName}>`;\n }\n return typeErrorName;\n};\n\nexport const useTypeResponse = ({\n operation,\n plugin,\n}: {\n operation: IR.OperationObject;\n plugin: PiniaColadaPlugin['Instance'];\n}): string => {\n const symbolResponseType = plugin.querySymbol({\n category: 'type',\n resource: 'operation',\n resourceId: operation.id,\n role: 'response',\n });\n return symbolResponseType?.placeholder || 'unknown';\n};\n","import { getClientPlugin } from '~/plugins/@hey-api/client-core/utils';\n\nimport type { PiniaColadaPlugin } from './types';\n\nexport const getPublicTypeData = ({\n plugin,\n typeData,\n}: {\n plugin: PiniaColadaPlugin['Instance'];\n typeData: string;\n}) => {\n const client = getClientPlugin(plugin.context.config);\n const isNuxtClient = client.name === '@hey-api/client-nuxt';\n const strippedTypeData = isNuxtClient\n ? `Omit<${typeData}, 'composable'>`\n : typeData;\n\n return { isNuxtClient, strippedTypeData };\n};\n","import type { IR } from '~/ir/types';\nimport { buildName } from '~/openApi/shared/utils/name';\nimport { createOperationComment } from '~/plugins/shared/utils/operation';\nimport { $ } from '~/ts-dsl';\n\nimport { handleMeta } from './meta';\nimport type { PiniaColadaPlugin } from './types';\nimport { useTypeData, useTypeError, useTypeResponse } from './useType';\nimport { getPublicTypeData } from './utils';\n\nexport const createMutationOptions = ({\n operation,\n plugin,\n queryFn,\n}: {\n operation: IR.OperationObject;\n plugin: PiniaColadaPlugin['Instance'];\n queryFn: string;\n}): void => {\n const symbolMutationOptionsType = plugin.referenceSymbol({\n category: 'external',\n resource: `${plugin.name}.UseMutationOptions`,\n });\n\n const typeData = useTypeData({ operation, plugin });\n const typeError = useTypeError({ operation, plugin });\n const typeResponse = useTypeResponse({ operation, plugin });\n const { isNuxtClient, strippedTypeData } = getPublicTypeData({\n plugin,\n typeData,\n });\n // TODO: better types syntax\n const mutationType = isNuxtClient\n ? `${symbolMutationOptionsType.placeholder}<${typeResponse}, ${strippedTypeData}, ${typeError}>`\n : `${symbolMutationOptionsType.placeholder}<${typeResponse}, ${typeData}, ${typeError}>`;\n\n const fnOptions = 'fnOptions';\n\n const awaitSdkFn = $(queryFn)\n .call(\n $.object()\n .pretty()\n .spread('options')\n .spread(fnOptions)\n .prop('throwOnError', $.literal(true)),\n )\n .await();\n\n const statements: Array<ReturnType<typeof $.var | typeof $.return>> = [];\n\n if (plugin.getPluginOrThrow('@hey-api/sdk').config.responseStyle === 'data') {\n statements.push($.return(awaitSdkFn));\n } else {\n statements.push(\n $.const().object('data').assign(awaitSdkFn),\n $.return('data'),\n );\n }\n\n const mutationOpts = $.object()\n .pretty()\n .prop(\n 'mutation',\n $.func()\n .async()\n .param(fnOptions, (p) =>\n p.$if(isNuxtClient, (f) => f.type(`Partial<${strippedTypeData}>`)),\n )\n .do(...statements),\n )\n .$if(handleMeta(plugin, operation, 'mutationOptions'), (o, v) =>\n o.prop('meta', v),\n );\n const symbolMutationOptions = plugin.registerSymbol({\n exported: true,\n name: buildName({\n config: plugin.config.mutationOptions,\n name: operation.id,\n }),\n });\n const statement = $.const(symbolMutationOptions.placeholder)\n .export(symbolMutationOptions.exported)\n .$if(plugin.config.comments && createOperationComment(operation), (c, v) =>\n c.doc(v),\n )\n .assign(\n $.func()\n .param('options', (p) =>\n p.optional().type(`Partial<${strippedTypeData}>`),\n )\n .returns(mutationType)\n .do($.return(mutationOpts)),\n );\n plugin.setSymbolValue(symbolMutationOptions, statement);\n};\n","import type { Symbol } from '@hey-api/codegen-core';\n\nimport { clientFolderAbsolutePath } from '~/generate/client';\nimport { hasOperationDataRequired } from '~/ir/operation';\nimport type { IR } from '~/ir/types';\nimport { buildName } from '~/openApi/shared/utils/name';\nimport { getClientBaseUrlKey } from '~/plugins/@hey-api/client-core/utils';\nimport { $ } from '~/ts-dsl';\n\nimport type { PiniaColadaPlugin } from './types';\nimport { useTypeData } from './useType';\nimport { getPublicTypeData } from './utils';\n\nconst TOptionsType = 'TOptions';\n\nexport const createQueryKeyFunction = ({\n plugin,\n}: {\n plugin: PiniaColadaPlugin['Instance'];\n}) => {\n const symbolCreateQueryKey = plugin.registerSymbol({\n meta: {\n category: 'utility',\n resource: 'createQueryKey',\n tool: plugin.name,\n },\n name: buildName({\n config: {\n case: plugin.config.case,\n },\n name: 'createQueryKey',\n }),\n });\n const symbolQueryKeyType = plugin.referenceSymbol({\n category: 'type',\n resource: 'QueryKey',\n tool: plugin.name,\n });\n const symbolJsonValue = plugin.referenceSymbol({\n category: 'external',\n resource: `${plugin.name}._JSONValue`,\n });\n\n const returnType = $.type(symbolQueryKeyType.placeholder)\n .generic(TOptionsType)\n .idx(0);\n\n const baseUrlKey = getClientBaseUrlKey(plugin.context.config);\n\n const symbolOptions = plugin.referenceSymbol({\n category: 'type',\n resource: 'client-options',\n tool: 'sdk',\n });\n const symbolClient = plugin.getSymbol({\n category: 'client',\n });\n\n const clientModule = clientFolderAbsolutePath(plugin.context.config);\n const symbolSerializeQueryValue = plugin.registerSymbol({\n external: clientModule,\n meta: {\n category: 'external',\n resource: `${clientModule}.serializeQueryKeyValue`,\n },\n name: 'serializeQueryKeyValue',\n });\n\n const fn = $.const(symbolCreateQueryKey.placeholder).assign(\n $.func()\n .param('id', (p) => p.type('string'))\n .param('options', (p) => p.optional().type(TOptionsType))\n .param('tags', (p) => p.optional().type('ReadonlyArray<string>'))\n .returns($.type.tuple(returnType))\n .generic(TOptionsType, (g) => g.extends(symbolOptions.placeholder))\n .do(\n $.const('params')\n .type(returnType)\n .assign(\n $.object()\n .prop('_id', 'id')\n .prop(\n baseUrlKey,\n `options?.${baseUrlKey} || (options?.client ?? ${symbolClient?.placeholder}).getConfig().${baseUrlKey}`,\n )\n .as(returnType),\n ),\n $.if('tags').do(\n $('params')\n .attr('tags')\n .assign($('tags').as('unknown').as(symbolJsonValue.placeholder)),\n ),\n $.if($('options').attr('body').optional().neq($.id('undefined'))).do(\n $.const('normalizedBody').assign(\n $(symbolSerializeQueryValue.placeholder).call(\n $('options').attr('body'),\n ),\n ),\n $.if($('normalizedBody').neq($.id('undefined'))).do(\n $('params').attr('body').assign('normalizedBody'),\n ),\n ),\n $.if($('options').attr('path').optional()).do(\n $('params').attr('path').assign($('options').attr('path')),\n ),\n $.if($('options').attr('query').optional().neq($.id('undefined'))).do(\n $.const('normalizedQuery').assign(\n $(symbolSerializeQueryValue.placeholder).call(\n $('options').attr('query'),\n ),\n ),\n $.if($('normalizedQuery').neq($.id('undefined'))).do(\n $('params').attr('query').assign('normalizedQuery'),\n ),\n ),\n $.return($.array($('params'))),\n ),\n );\n plugin.setSymbolValue(symbolCreateQueryKey, fn);\n};\n\nconst createQueryKeyLiteral = ({\n id,\n operation,\n plugin,\n}: {\n id: string;\n operation: IR.OperationObject;\n plugin: PiniaColadaPlugin['Instance'];\n}) => {\n const config = plugin.config.queryKeys;\n let tagsExpression: ReturnType<typeof $.array> | undefined;\n if (config.tags && operation.tags && operation.tags.length > 0) {\n tagsExpression = $.array(...operation.tags.map((tag) => $.literal(tag)));\n }\n\n const symbolCreateQueryKey = plugin.referenceSymbol({\n category: 'utility',\n resource: 'createQueryKey',\n tool: plugin.name,\n });\n const createQueryKeyCallExpression = $(symbolCreateQueryKey.placeholder).call(\n $.literal(id),\n 'options',\n tagsExpression,\n );\n return createQueryKeyCallExpression;\n};\n\nexport const createQueryKeyType = ({\n plugin,\n}: {\n plugin: PiniaColadaPlugin['Instance'];\n}) => {\n const symbolJsonValue = plugin.referenceSymbol({\n category: 'external',\n resource: `${plugin.name}._JSONValue`,\n });\n\n const symbolOptions = plugin.referenceSymbol({\n category: 'type',\n resource: 'client-options',\n tool: 'sdk',\n });\n const symbolQueryKeyType = plugin.registerSymbol({\n exported: true,\n kind: 'type',\n meta: {\n category: 'type',\n resource: 'QueryKey',\n tool: plugin.name,\n },\n name: 'QueryKey',\n });\n const queryKeyType = $.type\n .alias(symbolQueryKeyType.placeholder)\n .export(symbolQueryKeyType.exported)\n .generic(TOptionsType, (g) => g.extends($.type(symbolOptions.placeholder)))\n .type(\n $.type.tuple(\n $.type.and(\n $.type(`Pick<${TOptionsType}, 'path'>`),\n $.type\n .object()\n .prop('_id', (p) => p.type('string'))\n .prop(getClientBaseUrlKey(plugin.context.config), (p) =>\n p.optional().type(symbolJsonValue.placeholder),\n )\n .prop('body', (p) => p.optional().type(symbolJsonValue.placeholder))\n .prop('query', (p) =>\n p.optional().type(symbolJsonValue.placeholder),\n )\n .prop('tags', (p) =>\n p.optional().type(symbolJsonValue.placeholder),\n ),\n ),\n ),\n );\n plugin.setSymbolValue(symbolQueryKeyType, queryKeyType);\n};\n\nexport const queryKeyStatement = ({\n operation,\n plugin,\n symbol,\n}: {\n operation: IR.OperationObject;\n plugin: PiniaColadaPlugin['Instance'];\n symbol: Symbol;\n}) => {\n const typeData = useTypeData({ operation, plugin });\n const { strippedTypeData } = getPublicTypeData({ plugin, typeData });\n const statement = $.const(symbol.placeholder)\n .export(symbol.exported)\n .assign(\n $.func()\n .param('options', (p) =>\n p\n .required(hasOperationDataRequired(operation))\n .type(strippedTypeData),\n )\n .do(\n createQueryKeyLiteral({\n id: operation.id,\n operation,\n plugin,\n }).return(),\n ),\n );\n return statement;\n};\n","import type { IR } from '~/ir/types';\nimport { buildName } from '~/openApi/shared/utils/name';\nimport {\n createOperationComment,\n hasOperationSse,\n isOperationOptionsRequired,\n} from '~/plugins/shared/utils/operation';\nimport { $ } from '~/ts-dsl';\n\nimport { handleMeta } from './meta';\nimport {\n createQueryKeyFunction,\n createQueryKeyType,\n queryKeyStatement,\n} from './queryKey';\nimport type { PiniaColadaPlugin } from './types';\nimport { useTypeData } from './useType';\nimport { getPublicTypeData } from './utils';\n\nconst optionsParamName = 'options';\nconst fnOptions = 'context';\n\nexport const createQueryOptions = ({\n operation,\n plugin,\n queryFn,\n}: {\n operation: IR.OperationObject;\n plugin: PiniaColadaPlugin['Instance'];\n queryFn: string;\n}): void => {\n if (hasOperationSse({ operation })) {\n return;\n }\n\n const isRequiredOptions = isOperationOptionsRequired({\n context: plugin.context,\n operation,\n });\n if (\n !plugin.getSymbol({\n category: 'utility',\n resource: 'createQueryKey',\n tool: plugin.name,\n })\n ) {\n createQueryKeyType({ plugin });\n createQueryKeyFunction({ plugin });\n }\n\n let keyExpression: ReturnType<typeof $.call>;\n if (plugin.config.queryKeys.enabled) {\n const symbolQueryKey = plugin.registerSymbol({\n exported: true,\n name: buildName({\n config: plugin.config.queryKeys,\n name: operation.id,\n }),\n });\n const node = queryKeyStatement({\n operation,\n plugin,\n symbol: symbolQueryKey,\n });\n plugin.setSymbolValue(symbolQueryKey, node);\n keyExpression = $(symbolQueryKey.placeholder).call(optionsParamName);\n } else {\n const symbolCreateQueryKey = plugin.referenceSymbol({\n category: 'utility',\n resource: 'createQueryKey',\n tool: plugin.name,\n });\n // Optionally include tags when configured\n let tagsExpr: ReturnType<typeof $.array> | undefined;\n if (\n plugin.config.queryKeys.tags &&\n operation.tags &&\n operation.tags.length > 0\n ) {\n tagsExpr = $.array(...operation.tags.map((t) => $.literal(t)));\n }\n keyExpression = $(symbolCreateQueryKey.placeholder).call(\n $.literal(operation.id),\n optionsParamName,\n tagsExpr,\n );\n }\n\n const typeData = useTypeData({ operation, plugin });\n const { strippedTypeData } = getPublicTypeData({\n plugin,\n typeData,\n });\n const awaitSdkFn = $(queryFn)\n .call(\n $.object()\n .spread(optionsParamName)\n .spread(fnOptions)\n .prop('throwOnError', $.literal(true)),\n )\n .await();\n\n const statements: Array<ReturnType<typeof $.return | typeof $.const>> = [];\n if (plugin.getPluginOrThrow('@hey-api/sdk').config.responseStyle === 'data') {\n statements.push($.return(awaitSdkFn));\n } else {\n statements.push(\n $.const().object('data').assign(awaitSdkFn),\n $.return('data'),\n );\n }\n\n const queryOpts = $.object()\n .pretty()\n .prop('key', keyExpression)\n .prop(\n 'query',\n $.func()\n .async()\n .param(fnOptions)\n .do(...statements),\n )\n .$if(handleMeta(plugin, operation, 'queryOptions'), (o, v) =>\n o.prop('meta', v),\n );\n\n const symbolQueryOptionsFn = plugin.registerSymbol({\n exported: true,\n meta: {\n category: 'hook',\n resource: 'operation',\n resourceId: operation.id,\n role: 'queryOptions',\n tool: plugin.name,\n },\n name: buildName({\n config: plugin.config.queryOptions,\n name: operation.id,\n }),\n });\n const symbolDefineQueryOptions = plugin.referenceSymbol({\n category: 'external',\n resource: `${plugin.name}.defineQueryOptions`,\n });\n const statement = $.const(symbolQueryOptionsFn.placeholder)\n .export(symbolQueryOptionsFn.exported)\n .$if(plugin.config.comments && createOperationComment(operation), (c, v) =>\n c.doc(v),\n )\n .assign(\n $(symbolDefineQueryOptions.placeholder).call(\n $.func()\n .param(optionsParamName, (p) =>\n p.required(isRequiredOptions).type(strippedTypeData),\n )\n .do($.return(queryOpts)),\n ),\n );\n plugin.setSymbolValue(symbolQueryOptionsFn, statement);\n};\n","import { registryName } from '~/plugins/@hey-api/sdk/shared/class';\nimport { operationClasses } from '~/plugins/@hey-api/sdk/shared/operation';\nimport { stringCase } from '~/utils/stringCase';\n\nimport { createMutationOptions } from '../mutationOptions';\nimport { createQueryOptions } from '../queryOptions';\nimport type { PiniaColadaPlugin } from '../types';\n\nexport const handlerV0: PiniaColadaPlugin['Handler'] = ({ plugin }) => {\n plugin.registerSymbol({\n external: plugin.name,\n meta: {\n category: 'external',\n resource: `${plugin.name}.defineQueryOptions`,\n },\n name: 'defineQueryOptions',\n });\n plugin.registerSymbol({\n external: plugin.name,\n kind: 'type',\n meta: {\n category: 'external',\n resource: `${plugin.name}.UseMutationOptions`,\n },\n name: 'UseMutationOptions',\n });\n plugin.registerSymbol({\n external: plugin.name,\n kind: 'type',\n meta: {\n category: 'external',\n resource: `${plugin.name}.UseQueryOptions`,\n },\n name: 'UseQueryOptions',\n });\n plugin.registerSymbol({\n external: plugin.name,\n kind: 'type',\n meta: {\n category: 'external',\n resource: `${plugin.name}._JSONValue`,\n },\n name: '_JSONValue',\n });\n plugin.registerSymbol({\n external: 'axios',\n kind: 'type',\n meta: {\n category: 'external',\n resource: 'axios.AxiosError',\n },\n name: 'AxiosError',\n });\n\n const sdkPlugin = plugin.getPluginOrThrow('@hey-api/sdk');\n\n plugin.forEach(\n 'operation',\n ({ operation }) => {\n const classes = sdkPlugin.config.asClass\n ? operationClasses({\n context: plugin.context,\n operation,\n plugin: sdkPlugin,\n })\n : undefined;\n const entry = classes ? classes.values().next().value : undefined;\n // TODO: this should use class graph to determine correct path string\n // as it's really easy to break once we change the class casing\n let queryFn: string;\n if (entry) {\n const symbolClass = plugin.referenceSymbol({\n category: 'utility',\n resource: 'class',\n resourceId: entry.path[0],\n tool: 'sdk',\n });\n queryFn = [\n symbolClass.placeholder,\n ...(sdkPlugin.config.instance ? [registryName, 'get()'] : []),\n ...entry.path.slice(1).map((className) =>\n stringCase({\n case: 'camelCase',\n value: className,\n }),\n ),\n entry.methodName,\n ]\n .filter(Boolean)\n .join('.');\n } else {\n queryFn = plugin.referenceSymbol({\n category: 'sdk',\n resource: 'operation',\n resourceId: operation.id,\n }).placeholder;\n }\n\n if (plugin.hooks.operation.isQuery(operation)) {\n if (plugin.config.queryOptions.enabled) {\n createQueryOptions({ operation, plugin, queryFn });\n }\n }\n\n if (plugin.hooks.operation.isMutation(operation)) {\n if (plugin.config.mutationOptions.enabled) {\n createMutationOptions({ operation, plugin, queryFn });\n }\n }\n },\n {\n order: 'declarations',\n },\n );\n};\n","import type { PiniaColadaPlugin } from './types';\nimport { handlerV0 } from './v0/plugin';\n\nexport const handler: PiniaColadaPlugin['Handler'] = (args) => handlerV0(args);\n","import { definePluginConfig } from '~/plugins/shared/utils/config';\n\nimport { handler } from './plugin';\nimport type { PiniaColadaPlugin } from './types';\n\nexport const defaultConfig: PiniaColadaPlugin['Config'] = {\n config: {\n case: 'camelCase',\n comments: true,\n exportFromIndex: false,\n },\n dependencies: ['@hey-api/typescript', '@hey-api/sdk'],\n handler: handler as PiniaColadaPlugin['Handler'],\n name: '@pinia/colada',\n resolveConfig: (plugin, context) => {\n plugin.config.mutationOptions = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'camelCase',\n enabled: true,\n name: '{{name}}Mutation',\n },\n mappers: {\n boolean: (enabled) => ({ enabled }),\n function: (name) => ({ name }),\n string: (name) => ({ name }),\n },\n value: plugin.config.mutationOptions,\n });\n\n plugin.config.queryKeys = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'camelCase',\n enabled: true,\n name: '{{name}}QueryKey',\n tags: false,\n },\n mappers: {\n boolean: (enabled) => ({ enabled }),\n function: (name) => ({ name }),\n string: (name) => ({ name }),\n },\n value: plugin.config.queryKeys,\n });\n\n plugin.config.queryOptions = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'camelCase',\n enabled: true,\n name: '{{name}}Query',\n },\n mappers: {\n boolean: (enabled) => ({ enabled }),\n function: (name) => ({ name }),\n string: (name) => ({ name }),\n },\n value: plugin.config.queryOptions,\n });\n },\n};\n\n/**\n * Type helper for `@pinia/colada` plugin, returns {@link Plugin.Config} object\n */\nexport const defineConfig = definePluginConfig(defaultConfig);\n","import type { IR } from '~/ir/types';\nimport { getClientPlugin } from '~/plugins/@hey-api/client-core/utils';\nimport { operationOptionsType } from '~/plugins/@hey-api/sdk/shared/operation';\n\nimport type { PluginInstance } from '../types';\n\nexport const useTypeData = ({\n operation,\n plugin,\n}: {\n operation: IR.OperationObject;\n plugin: PluginInstance;\n}): string => {\n const pluginSdk = plugin.getPluginOrThrow('@hey-api/sdk');\n const typeData = operationOptionsType({ operation, plugin: pluginSdk });\n return typeData;\n};\n\nexport const useTypeError = ({\n operation,\n plugin,\n}: {\n operation: IR.OperationObject;\n plugin: PluginInstance;\n}): string => {\n const client = getClientPlugin(plugin.context.config);\n\n const symbolErrorType = plugin.querySymbol({\n category: 'type',\n resource: 'operation',\n resourceId: operation.id,\n role: 'error',\n });\n\n let typeErrorName: string | undefined = symbolErrorType?.placeholder;\n if (!typeErrorName) {\n const symbol = plugin.referenceSymbol({\n category: 'external',\n resource: `${plugin.name}.DefaultError`,\n });\n typeErrorName = symbol.placeholder;\n }\n if (client.name === '@hey-api/client-axios') {\n const symbol = plugin.referenceSymbol({\n category: 'external',\n resource: 'axios.AxiosError',\n });\n typeErrorName = `${symbol.placeholder}<${typeErrorName}>`;\n }\n return typeErrorName;\n};\n\nexport const useTypeResponse = ({\n operation,\n plugin,\n}: {\n operation: IR.OperationObject;\n plugin: PluginInstance;\n}): string => {\n const symbolResponseType = plugin.querySymbol({\n category: 'type',\n resource: 'operation',\n resourceId: operation.id,\n role: 'response',\n });\n return symbolResponseType?.placeholder || 'unknown';\n};\n","import type { Symbol } from '@hey-api/codegen-core';\nimport type ts from 'typescript';\n\nimport { hasOperationDataRequired } from '~/ir/operation';\nimport type { IR } from '~/ir/types';\nimport { buildName } from '~/openApi/shared/utils/name';\nimport { getClientBaseUrlKey } from '~/plugins/@hey-api/client-core/utils';\nimport type { TsDsl } from '~/ts-dsl';\nimport { $ } from '~/ts-dsl';\n\nimport { useTypeData } from './shared/useType';\nimport type { PluginInstance } from './types';\n\nconst TOptionsType = 'TOptions';\n\nexport const createQueryKeyFunction = ({\n plugin,\n}: {\n plugin: PluginInstance;\n}) => {\n const symbolCreateQueryKey = plugin.registerSymbol({\n meta: {\n category: 'utility',\n resource: 'createQueryKey',\n tool: plugin.name,\n },\n name: buildName({\n config: {\n case: plugin.config.case,\n },\n name: 'createQueryKey',\n }),\n });\n const symbolQueryKeyType = plugin.referenceSymbol({\n category: 'type',\n resource: 'QueryKey',\n tool: plugin.name,\n });\n\n const baseUrlKey = getClientBaseUrlKey(plugin.context.config);\n\n const symbolClient = plugin.getSymbol({\n category: 'client',\n });\n\n const symbolOptions = plugin.referenceSymbol({\n category: 'type',\n resource: 'client-options',\n tool: 'sdk',\n });\n\n const returnType = $.type(symbolQueryKeyType.placeholder)\n .generic(TOptionsType)\n .idx(0);\n\n const fn = $.const(symbolCreateQueryKey.placeholder).assign(\n $.func()\n .param('id', (p) => p.type('string'))\n .param('options', (p) => p.optional().type(TOptionsType))\n .param('infinite', (p) => p.optional().type('boolean'))\n .param('tags', (p) => p.optional().type('ReadonlyArray<string>'))\n .generic(TOptionsType, (g) => g.extends(symbolOptions.placeholder))\n .returns($.type.tuple(returnType))\n .do(\n $.const('params')\n .type(returnType)\n .assign(\n $.object()\n .prop('_id', 'id')\n .prop(\n baseUrlKey,\n `options?.${baseUrlKey} || (options?.client ?? ${symbolClient?.placeholder}).getConfig().${baseUrlKey}`,\n )\n .as(returnType),\n ),\n $.if('infinite').do($('params').attr('_infinite').assign('infinite')),\n $.if('tags').do($('params').attr('tags').assign('tags')),\n $.if($('options').attr('body').optional()).do(\n $('params').attr('body').assign($('options').attr('body')),\n ),\n $.if($('options').attr('headers').optional()).do(\n $('params').attr('headers').assign($('options').attr('headers')),\n ),\n $.if($('options').attr('path').optional()).do(\n $('params').attr('path').assign($('options').attr('path')),\n ),\n $.if($('options').attr('query').optional()).do(\n $('params').attr('query').assign($('options').attr('query')),\n ),\n $.return($.array().element($('params'))),\n ),\n );\n plugin.setSymbolValue(symbolCreateQueryKey, fn);\n};\n\nconst createQueryKeyLiteral = ({\n id,\n isInfinite,\n operation,\n plugin,\n}: {\n id: string;\n isInfinite?: boolean;\n operation: IR.OperationObject;\n plugin: PluginInstance;\n}) => {\n const config = isInfinite\n ? plugin.config.infiniteQueryKeys\n : plugin.config.queryKeys;\n let tagsArray: TsDsl<ts.ArrayLiteralExpression> | undefined;\n if (config.tags && operation.tags && operation.tags.length > 0) {\n tagsArray = $.array().elements(...operation.tags);\n }\n const symbolCreateQueryKey = plugin.referenceSymbol({\n category: 'utility',\n resource: 'createQueryKey',\n tool: plugin.name,\n });\n const createQueryKeyCallExpression = $(symbolCreateQueryKey.placeholder).call(\n $.literal(id),\n 'options',\n isInfinite || tagsArray ? $.literal(Boolean(isInfinite)) : undefined,\n tagsArray,\n );\n return createQueryKeyCallExpression;\n};\n\nexport const createQueryKeyType = ({ plugin }: { plugin: PluginInstance }) => {\n const symbolOptions = plugin.referenceSymbol({\n category: 'type',\n resource: 'client-options',\n tool: 'sdk',\n });\n const symbolQueryKeyType = plugin.registerSymbol({\n exported: true,\n kind: 'type',\n meta: {\n category: 'type',\n resource: 'QueryKey',\n tool: plugin.name,\n },\n name: 'QueryKey',\n });\n const queryKeyType = $.type\n .alias(symbolQueryKeyType.placeholder)\n .export(symbolQueryKeyType.exported)\n .generic(TOptionsType, (g) => g.extends(symbolOptions.placeholder))\n .type(\n $.type.tuple(\n $.type.and(\n $.type(\n `Pick<${TOptionsType}, '${getClientBaseUrlKey(plugin.context.config)}' | 'body' | 'headers' | 'path' | 'query'>`,\n ),\n $.type\n .object()\n .prop('_id', (p) => p.type('string'))\n .prop('_infinite', (p) => p.optional().type('boolean'))\n .prop('tags', (p) => p.optional().type('ReadonlyArray<string>')),\n ),\n ),\n );\n plugin.setSymbolValue(symbolQueryKeyType, queryKeyType);\n};\n\nexport const queryKeyStatement = ({\n isInfinite,\n operation,\n plugin,\n symbol,\n typeQueryKey,\n}: {\n isInfinite: boolean;\n operation: IR.OperationObject;\n plugin: PluginInstance;\n symbol: Symbol;\n typeQueryKey?: string;\n}) => {\n const typeData = useTypeData({ operation, plugin });\n const statement = $.const(symbol.placeholder)\n .export(symbol.exported)\n .assign(\n $.func()\n .param('options', (p) =>\n p.required(hasOperationDataRequired(operation)).type(typeData),\n )\n .$if(isInfinite && typeQueryKey, (f, v) => f.returns(v))\n .do(\n createQueryKeyLiteral({\n id: operation.id,\n isInfinite,\n operation,\n plugin,\n }).return(),\n ),\n );\n return statement;\n};\n","import type { IR } from '~/ir/types';\nimport { $ } from '~/ts-dsl';\n\nimport type { PluginInstance } from '../types';\n\nexport const handleMeta = (\n plugin: PluginInstance,\n operation: IR.OperationObject,\n configPath: 'queryOptions' | 'infiniteQueryOptions' | 'mutationOptions',\n): ReturnType<typeof $.fromValue> | undefined => {\n const metaFn = plugin.config[configPath].meta;\n if (!metaFn) return;\n\n const metaObject = metaFn(operation);\n if (!Object.keys(metaObject).length) return;\n\n return $.fromValue(metaObject);\n};\n","import { operationPagination } from '~/ir/operation';\nimport type { IR } from '~/ir/types';\nimport { buildName } from '~/openApi/shared/utils/name';\nimport {\n createOperationComment,\n isOperationOptionsRequired,\n} from '~/plugins/shared/utils/operation';\nimport type { TsDsl } from '~/ts-dsl';\nimport { $ } from '~/ts-dsl';\n\nimport {\n createQueryKeyFunction,\n createQueryKeyType,\n queryKeyStatement,\n} from '../queryKey';\nimport { handleMeta } from '../shared/meta';\nimport { useTypeData, useTypeError, useTypeResponse } from '../shared/useType';\nimport type { PluginInstance } from '../types';\n\nconst createInfiniteParamsFunction = ({\n plugin,\n}: {\n plugin: PluginInstance;\n}) => {\n const symbolCreateInfiniteParams = plugin.registerSymbol({\n meta: {\n category: 'utility',\n resource: 'createInfiniteParams',\n tool: plugin.name,\n },\n name: buildName({\n config: {\n case: plugin.config.case,\n },\n name: 'createInfiniteParams',\n }),\n });\n\n const fn = $.const(symbolCreateInfiniteParams.placeholder).assign(\n $.func()\n .generic('K', (g) =>\n g.extends(\n \"Pick<QueryKey<Options>[0], 'body' | 'headers' | 'path' | 'query'>\",\n ),\n )\n .param('queryKey', (p) => p.type('QueryKey<Options>'))\n .param('page', (p) => p.type('K'))\n .do(\n $.const('params').assign($.object().spread($('queryKey').attr(0))),\n $.if($('page').attr('body')).do(\n $('params')\n .attr('body')\n .assign(\n $.object()\n .pretty()\n .spread($('queryKey').attr(0).attr('body').as('any'))\n .spread($('page').attr('body').as('any')),\n ),\n ),\n $.if($('page').attr('headers')).do(\n $('params')\n .attr('headers')\n .assign(\n $.object()\n .pretty()\n .spread($('queryKey').attr(0).attr('headers'))\n .spread($('page').attr('headers')),\n ),\n ),\n $.if($('page').attr('path')).do(\n $('params')\n .attr('path')\n .assign(\n $.object()\n .pretty()\n .spread($('queryKey').attr(0).attr('path').as('any'))\n .spread($('page').attr('path').as('any')),\n ),\n ),\n $.if($('page').attr('query')).do(\n $('params')\n .attr('query')\n .assign(\n $.object()\n .pretty()\n .spread($('queryKey').attr(0).attr('query').as('any'))\n .spread($('page').attr('query').as('any')),\n ),\n ),\n $.return($('params').as('unknown').as($('page').typeofType())),\n ),\n );\n plugin.setSymbolValue(symbolCreateInfiniteParams, fn);\n};\n\nexport const createInfiniteQueryOptions = ({\n operation,\n plugin,\n queryFn,\n}: {\n operation: IR.OperationObject;\n plugin: PluginInstance;\n queryFn: string;\n}): void => {\n const pagination = operationPagination({\n context: plugin.context,\n operation,\n });\n\n if (!pagination) {\n return;\n }\n\n const isRequiredOptions = isOperationOptionsRequired({\n context: plugin.context,\n operation,\n });\n\n if (\n !plugin.getSymbol({\n category: 'utility',\n resource: 'createQueryKey',\n tool: plugin.name,\n })\n ) {\n createQueryKeyType({ plugin });\n createQueryKeyFunction({ plugin });\n }\n\n if (\n !plugin.getSymbol({\n category: 'utility',\n resource: 'createInfiniteParams',\n tool: plugin.name,\n })\n ) {\n createInfiniteParamsFunction({ plugin });\n }\n\n const symbolInfiniteQueryOptions = plugin.referenceSymbol({\n category: 'external',\n resource: `${plugin.name}.infiniteQueryOptions`,\n });\n const symbolInfiniteDataType = plugin.referenceSymbol({\n category: 'external',\n resource: `${plugin.name}.InfiniteData`,\n });\n\n const typeData = useTypeData({ operation, plugin });\n const typeError = useTypeError({ operation, plugin });\n const typeResponse = useTypeResponse({ operation, plugin });\n\n const symbolQueryKeyType = plugin.referenceSymbol({\n category: 'type',\n resource: 'QueryKey',\n tool: plugin.name,\n });\n const typeQueryKey = `${symbolQueryKeyType.placeholder}<${typeData}>`;\n const typePageObjectParam = `Pick<${typeQueryKey}[0], 'body' | 'headers' | 'path' | 'query'>`;\n const pluginTypeScript = plugin.getPluginOrThrow('@hey-api/typescript');\n const type = pluginTypeScript.api.schemaToType({\n plugin: pluginTypeScript,\n schema: pagination.schema,\n state: {\n path: {\n value: [],\n },\n },\n });\n\n const symbolInfiniteQueryKey = plugin.registerSymbol({\n exported: true,\n name: buildName({\n config: plugin.config.infiniteQueryKeys,\n name: operation.id,\n }),\n });\n const node = queryKeyStatement({\n isInfinite: true,\n operation,\n plugin,\n symbol: symbolInfiniteQueryKey,\n typeQueryKey,\n });\n plugin.setSymbolValue(symbolInfiniteQueryKey, node);\n\n const awaitSdkFn = $(queryFn)\n .call(\n $.object()\n .spread('options')\n .spread('params')\n .prop('signal', $('signal'))\n .prop('throwOnError', $.literal(true)),\n )\n .await();\n\n const symbolCreateInfiniteParams = plugin.referenceSymbol({\n category: 'utility',\n resource: 'createInfiniteParams',\n tool: plugin.name,\n });\n\n const statements: Array<TsDsl<any>> = [\n $.const('page')\n .type(typePageObjectParam)\n .hint('@ts-ignore')\n .assign(\n $.ternary($('pageParam').typeof().eq($.literal('object')))\n .do('pageParam')\n .otherwise(\n $.object()\n .pretty()\n .prop(\n pagination.in,\n $.object().pretty().prop(pagination.name, $('pageParam')),\n ),\n ),\n ),\n $.const('params').assign(\n $(symbolCreateInfiniteParams.placeholder).call('queryKey', 'page'),\n ),\n ];\n\n if (plugin.getPluginOrThrow('@hey-api/sdk').config.responseStyle === 'data') {\n statements.push($.return(awaitSdkFn));\n } else {\n statements.push(\n $.const().object('data').assign(awaitSdkFn),\n $.return('data'),\n );\n }\n\n const symbolInfiniteQueryOptionsFn = plugin.registerSymbol({\n exported: true,\n name: buildName({\n config: plugin.config.infiniteQueryOptions,\n name: operation.id,\n }),\n });\n const statement = $.const(symbolInfiniteQueryOptionsFn.placeholder)\n .export(symbolInfiniteQueryOptionsFn.exported)\n .$if(plugin.config.comments && createOperationComment(operation), (c, v) =>\n c.doc(v),\n )\n .assign(\n $.func()\n .param('options', (p) => p.required(isRequiredOptions).type(typeData))\n .do(\n $.return(\n $(symbolInfiniteQueryOptions.placeholder)\n .call(\n $.object()\n .pretty()\n .hint('@ts-ignore')\n .prop(\n 'queryFn',\n $.func()\n .async()\n .param((p) => p.object('pageParam', 'queryKey', 'signal'))\n .do(...statements),\n )\n .prop(\n 'queryKey',\n $(symbolInfiniteQueryKey.placeholder).call('options'),\n )\n .$if(\n handleMeta(plugin, operation, 'infiniteQueryOptions'),\n (o, v) => o.prop('meta', v),\n ),\n )\n .generics(\n // TODO: better types syntax\n typeResponse,\n typeError || 'unknown',\n `${symbolInfiniteDataType.placeholder}<${typeResponse}>`,\n typeQueryKey,\n $.type.or(type, typePageObjectParam),\n ),\n ),\n ),\n );\n plugin.setSymbolValue(symbolInfiniteQueryOptionsFn, statement);\n};\n","import type { IR } from '~/ir/types';\nimport { buildName } from '~/openApi/shared/utils/name';\nimport { createOperationComment } from '~/plugins/shared/utils/operation';\nimport type { TsDsl } from '~/ts-dsl';\nimport { $ } from '~/ts-dsl';\n\nimport { handleMeta } from '../shared/meta';\nimport { useTypeData, useTypeError, useTypeResponse } from '../shared/useType';\nimport type { PluginInstance } from '../types';\n\nexport const createMutationOptions = ({\n operation,\n plugin,\n queryFn,\n}: {\n operation: IR.OperationObject;\n plugin: PluginInstance;\n queryFn: string;\n}): void => {\n const symbolMutationOptionsType = plugin.referenceSymbol({\n category: 'external',\n resource: `${plugin.name}.MutationOptions`,\n });\n\n const typeData = useTypeData({ operation, plugin });\n const typeError = useTypeError({ operation, plugin });\n const typeResponse = useTypeResponse({ operation, plugin });\n // TODO: better types syntax\n const mutationType = `${symbolMutationOptionsType.placeholder}<${typeResponse}, ${typeError}, ${typeData}>`;\n\n const fnOptions = 'fnOptions';\n\n const awaitSdkFn = $(queryFn)\n .call(\n $.object()\n .spread('options')\n .spread(fnOptions)\n .prop('throwOnError', $.literal(true)),\n )\n .await();\n\n const statements: Array<TsDsl<any>> = [];\n if (plugin.getPluginOrThrow('@hey-api/sdk').config.responseStyle === 'data') {\n statements.push($.return(awaitSdkFn));\n } else {\n statements.push(\n $.const().object('data').assign(awaitSdkFn),\n $.return('data'),\n );\n }\n\n const mutationOptionsFn = 'mutationOptions';\n const symbolMutationOptions = plugin.registerSymbol({\n exported: true,\n name: buildName({\n config: plugin.config.mutationOptions,\n name: operation.id,\n }),\n });\n const statement = $.const(symbolMutationOptions.placeholder)\n .export(symbolMutationOptions.exported)\n .$if(plugin.config.comments && createOperationComment(operation), (c, v) =>\n c.doc(v),\n )\n .assign(\n $.func()\n .param('options', (p) => p.optional().type(`Partial<${typeData}>`))\n .returns(mutationType)\n .do(\n $.const(mutationOptionsFn)\n .type(mutationType)\n .assign(\n $.object()\n .pretty()\n .prop(\n 'mutationFn',\n $.func()\n .async()\n .param(fnOptions)\n .do(...statements),\n )\n .$if(handleMeta(plugin, operation, 'mutationOptions'), (c, v) =>\n c.prop('meta', v),\n ),\n ),\n $(mutationOptionsFn).return(),\n ),\n );\n plugin.setSymbolValue(symbolMutationOptions, statement);\n};\n","import type { IR } from '~/ir/types';\nimport { buildName } from '~/openApi/shared/utils/name';\nimport {\n createOperationComment,\n hasOperationSse,\n isOperationOptionsRequired,\n} from '~/plugins/shared/utils/operation';\nimport type { TsDsl } from '~/ts-dsl';\nimport { $ } from '~/ts-dsl';\n\nimport {\n createQueryKeyFunction,\n createQueryKeyType,\n queryKeyStatement,\n} from '../queryKey';\nimport { handleMeta } from '../shared/meta';\nimport { useTypeData, useTypeError, useTypeResponse } from '../shared/useType';\nimport type { PluginInstance } from '../types';\n\nconst optionsParamName = 'options';\n\nexport const createQueryOptions = ({\n operation,\n plugin,\n queryFn,\n}: {\n operation: IR.OperationObject;\n plugin: PluginInstance;\n queryFn: string;\n}): void => {\n if (hasOperationSse({ operation })) {\n return;\n }\n\n const isRequiredOptions = isOperationOptionsRequired({\n context: plugin.context,\n operation,\n });\n\n if (\n !plugin.getSymbol({\n category: 'utility',\n resource: 'createQueryKey',\n tool: plugin.name,\n })\n ) {\n createQueryKeyType({ plugin });\n createQueryKeyFunction({ plugin });\n }\n\n const symbolQueryOptions = plugin.referenceSymbol({\n category: 'external',\n resource: `${plugin.name}.queryOptions`,\n });\n\n const symbolQueryKey = plugin.registerSymbol({\n exported: true,\n name: buildName({\n config: plugin.config.queryKeys,\n name: operation.id,\n }),\n });\n const node = queryKeyStatement({\n isInfinite: false,\n operation,\n plugin,\n symbol: symbolQueryKey,\n });\n plugin.setSymbolValue(symbolQueryKey, node);\n\n const typeData = useTypeData({ operation, plugin });\n const typeError = useTypeError({ operation, plugin });\n const typeResponse = useTypeResponse({ operation, plugin });\n\n const awaitSdkFn = $(queryFn)\n .call(\n $.object()\n .spread(optionsParamName)\n .spread($('queryKey').attr(0))\n .prop('signal', $('signal'))\n .prop('throwOnError', $.literal(true)),\n )\n .await();\n\n const statements: Array<TsDsl<any>> = [];\n if (plugin.getPluginOrThrow('@hey-api/sdk').config.responseStyle === 'data') {\n statements.push($.return(awaitSdkFn));\n } else {\n statements.push(\n $.const().object('data').assign(awaitSdkFn),\n $.return('data'),\n );\n }\n\n const queryOptionsObj = $.object()\n .pretty()\n .prop(\n 'queryFn',\n $.func()\n .async()\n .param((p) => p.object('queryKey', 'signal'))\n .do(...statements),\n )\n .prop('queryKey', $(symbolQueryKey.placeholder).call(optionsParamName))\n .$if(handleMeta(plugin, operation, 'queryOptions'), (o, v) =>\n o.prop('meta', v),\n );\n\n const symbolQueryOptionsFn = plugin.registerSymbol({\n exported: plugin.config.queryOptions.exported,\n meta: {\n category: 'hook',\n resource: 'operation',\n resourceId: operation.id,\n role: 'queryOptions',\n tool: plugin.name,\n },\n name: buildName({\n config: plugin.config.queryOptions,\n name: operation.id,\n }),\n });\n // TODO: add type error\n // TODO: AxiosError<PutSubmissionMetaError>\n const statement = $.const(symbolQueryOptionsFn.placeholder)\n .export(symbolQueryOptionsFn.exported)\n .$if(plugin.config.comments && createOperationComment(operation), (c, v) =>\n c.doc(v),\n )\n .assign(\n $.func()\n .param(optionsParamName, (p) =>\n p.required(isRequiredOptions).type(typeData),\n )\n .do(\n $(symbolQueryOptions.placeholder)\n .call(queryOptionsObj)\n .generics(\n typeResponse,\n typeError,\n typeResponse,\n $(symbolQueryKey.placeholder).returnType(),\n )\n .return(),\n ),\n );\n plugin.setSymbolValue(symbolQueryOptionsFn, statement);\n};\n","import type { IR } from '~/ir/types';\nimport { buildName } from '~/openApi/shared/utils/name';\nimport {\n createOperationComment,\n hasOperationSse,\n isOperationOptionsRequired,\n} from '~/plugins/shared/utils/operation';\nimport { $ } from '~/ts-dsl';\n\nimport { useTypeData } from '../shared/useType';\nimport type { PluginInstance } from '../types';\n\nconst optionsParamName = 'options';\n\nexport const createUseQuery = ({\n operation,\n plugin,\n}: {\n operation: IR.OperationObject;\n plugin: PluginInstance;\n}): void => {\n if (hasOperationSse({ operation })) {\n return;\n }\n\n if (!('useQuery' in plugin.config)) {\n return;\n }\n\n const symbolUseQueryFn = plugin.registerSymbol({\n exported: true,\n name: buildName({\n config: plugin.config.useQuery,\n name: operation.id,\n }),\n });\n\n const symbolUseQuery = plugin.referenceSymbol({\n category: 'external',\n resource: `${plugin.name}.useQuery`,\n });\n\n const isRequiredOptions = isOperationOptionsRequired({\n context: plugin.context,\n operation,\n });\n const typeData = useTypeData({ operation, plugin });\n\n const symbolQueryOptionsFn = plugin.referenceSymbol({\n category: 'hook',\n resource: 'operation',\n resourceId: operation.id,\n role: 'queryOptions',\n tool: plugin.name,\n });\n const statement = $.const(symbolUseQueryFn.placeholder)\n .export(symbolUseQueryFn.exported)\n .$if(plugin.config.comments && createOperationComment(operation), (c, v) =>\n c.doc(v),\n )\n .assign(\n $.func()\n .param(optionsParamName, (p) =>\n p.required(isRequiredOptions).type(typeData),\n )\n .do(\n $(symbolUseQuery.placeholder)\n .call($(symbolQueryOptionsFn.placeholder).call(optionsParamName))\n .return(),\n ),\n );\n plugin.setSymbolValue(symbolUseQueryFn, statement);\n};\n","import { registryName } from '~/plugins/@hey-api/sdk/shared/class';\nimport { operationClasses } from '~/plugins/@hey-api/sdk/shared/operation';\nimport { stringCase } from '~/utils/stringCase';\n\nimport type { PluginHandler } from '../types';\nimport { createInfiniteQueryOptions } from './infiniteQueryOptions';\nimport { createMutationOptions } from './mutationOptions';\nimport { createQueryOptions } from './queryOptions';\nimport { createUseQuery } from './useQuery';\n\nexport const handlerV5: PluginHandler = ({ plugin }) => {\n plugin.registerSymbol({\n external: plugin.name,\n kind: 'type',\n meta: {\n category: 'external',\n resource: `${plugin.name}.DefaultError`,\n },\n name: 'DefaultError',\n });\n plugin.registerSymbol({\n external: plugin.name,\n kind: 'type',\n meta: {\n category: 'external',\n resource: `${plugin.name}.InfiniteData`,\n },\n name: 'InfiniteData',\n });\n const mutationsType =\n plugin.name === '@tanstack/angular-query-experimental' ||\n plugin.name === '@tanstack/svelte-query' ||\n plugin.name === '@tanstack/solid-query'\n ? 'MutationOptions'\n : 'UseMutationOptions';\n plugin.registerSymbol({\n external: plugin.name,\n kind: 'type',\n meta: {\n category: 'external',\n resource: `${plugin.name}.MutationOptions`,\n },\n name: mutationsType,\n });\n plugin.registerSymbol({\n external: plugin.name,\n meta: {\n category: 'external',\n resource: `${plugin.name}.infiniteQueryOptions`,\n },\n name: 'infiniteQueryOptions',\n });\n plugin.registerSymbol({\n external: plugin.name,\n meta: {\n category: 'external',\n resource: `${plugin.name}.queryOptions`,\n },\n name: 'queryOptions',\n });\n plugin.registerSymbol({\n external: plugin.name,\n meta: {\n category: 'external',\n resource: `${plugin.name}.useQuery`,\n },\n name: 'useQuery',\n });\n plugin.registerSymbol({\n external: 'axios',\n kind: 'type',\n meta: {\n category: 'external',\n resource: 'axios.AxiosError',\n },\n name: 'AxiosError',\n });\n\n const sdkPlugin = plugin.getPluginOrThrow('@hey-api/sdk');\n\n plugin.forEach(\n 'operation',\n ({ operation }) => {\n const classes = sdkPlugin.config.asClass\n ? operationClasses({\n context: plugin.context,\n operation,\n plugin: sdkPlugin,\n })\n : undefined;\n const entry = classes ? classes.values().next().value : undefined;\n // TODO: this should use class graph to determine correct path string\n // as it's really easy to break once we change the class casing\n let queryFn: string;\n if (entry) {\n const symbolClass = plugin.referenceSymbol({\n category: 'utility',\n resource: 'class',\n resourceId: entry.path[0],\n tool: 'sdk',\n });\n queryFn = [\n symbolClass.placeholder,\n ...(sdkPlugin.config.instance ? [registryName, 'get()'] : []),\n ...entry.path.slice(1).map((className) =>\n stringCase({\n case: 'camelCase',\n value: className,\n }),\n ),\n entry.methodName,\n ]\n .filter(Boolean)\n .join('.');\n } else {\n queryFn = plugin.referenceSymbol({\n category: 'sdk',\n resource: 'operation',\n resourceId: operation.id,\n }).placeholder;\n }\n\n if (plugin.hooks.operation.isQuery(operation)) {\n if (plugin.config.queryOptions.enabled) {\n createQueryOptions({ operation, plugin, queryFn });\n }\n\n if (plugin.config.infiniteQueryOptions.enabled) {\n createInfiniteQueryOptions({ operation, plugin, queryFn });\n }\n\n if ('useQuery' in plugin.config && plugin.config.useQuery.enabled) {\n createUseQuery({ operation, plugin });\n }\n }\n\n if (plugin.hooks.operation.isMutation(operation)) {\n if (plugin.config.mutationOptions.enabled) {\n createMutationOptions({ operation, plugin, queryFn });\n }\n }\n },\n {\n order: 'declarations',\n },\n );\n};\n","import type { PluginHandler } from './types';\nimport { handlerV5 } from './v5/plugin';\n\nexport const handler: PluginHandler = (args) =>\n handlerV5(args as Parameters<PluginHandler>[0]);\n","import { handler } from '~/plugins/@tanstack/query-core/plugin';\nimport { definePluginConfig } from '~/plugins/shared/utils/config';\n\nimport type { TanStackAngularQueryPlugin } from './types';\n\nexport const defaultConfig: TanStackAngularQueryPlugin['Config'] = {\n config: {\n case: 'camelCase',\n comments: true,\n exportFromIndex: false,\n },\n dependencies: ['@hey-api/sdk', '@hey-api/typescript'],\n handler: handler as TanStackAngularQueryPlugin['Handler'],\n name: '@tanstack/angular-query-experimental',\n resolveConfig: (plugin, context) => {\n plugin.config.infiniteQueryKeys = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'camelCase',\n enabled: true,\n name: '{{name}}InfiniteQueryKey',\n tags: false,\n },\n mappers: {\n boolean: (enabled) => ({ enabled }),\n function: (name) => ({ name }),\n string: (name) => ({ name }),\n },\n value: plugin.config.infiniteQueryKeys,\n });\n\n plugin.config.infiniteQueryOptions = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'camelCase',\n enabled: true,\n name: '{{name}}InfiniteOptions',\n },\n mappers: {\n boolean: (enabled) => ({ enabled }),\n function: (name) => ({ name }),\n string: (name) => ({ name }),\n },\n value: plugin.config.infiniteQueryOptions,\n });\n\n plugin.config.mutationOptions = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'camelCase',\n enabled: true,\n name: '{{name}}Mutation',\n },\n mappers: {\n boolean: (enabled) => ({ enabled }),\n function: (name) => ({ name }),\n string: (name) => ({ name }),\n },\n value: plugin.config.mutationOptions,\n });\n\n plugin.config.queryKeys = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'camelCase',\n enabled: true,\n name: '{{name}}QueryKey',\n tags: false,\n },\n mappers: {\n boolean: (enabled) => ({ enabled }),\n function: (name) => ({ name }),\n string: (name) => ({ name }),\n },\n value: plugin.config.queryKeys,\n });\n\n plugin.config.queryOptions = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'camelCase',\n enabled: true,\n exported: true,\n name: '{{name}}Options',\n },\n mappers: {\n boolean: (enabled) => ({ enabled }),\n function: (name) => ({ name }),\n string: (name) => ({ name }),\n },\n value: plugin.config.queryOptions,\n });\n },\n};\n\n/**\n * Type helper for `@tanstack/angular-query-experimental` plugin, returns {@link Plugin.Config} object\n */\nexport const defineConfig = definePluginConfig(defaultConfig);\n","import { handler } from '~/plugins/@tanstack/query-core/plugin';\nimport { definePluginConfig } from '~/plugins/shared/utils/config';\n\nimport type { TanStackReactQueryPlugin } from './types';\n\nexport const defaultConfig: TanStackReactQueryPlugin['Config'] = {\n config: {\n case: 'camelCase',\n comments: true,\n exportFromIndex: false,\n },\n dependencies: ['@hey-api/sdk', '@hey-api/typescript'],\n handler: handler as TanStackReactQueryPlugin['Handler'],\n name: '@tanstack/react-query',\n resolveConfig: (plugin, context) => {\n plugin.config.infiniteQueryKeys = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'camelCase',\n enabled: true,\n name: '{{name}}InfiniteQueryKey',\n tags: false,\n },\n mappers: {\n boolean: (enabled) => ({ enabled }),\n function: (name) => ({ name }),\n string: (name) => ({ name }),\n },\n value: plugin.config.infiniteQueryKeys,\n });\n\n plugin.config.infiniteQueryOptions = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'camelCase',\n enabled: true,\n name: '{{name}}InfiniteOptions',\n },\n mappers: {\n boolean: (enabled) => ({ enabled }),\n function: (name) => ({ name }),\n string: (name) => ({ name }),\n },\n value: plugin.config.infiniteQueryOptions,\n });\n\n plugin.config.mutationOptions = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'camelCase',\n enabled: true,\n name: '{{name}}Mutation',\n },\n mappers: {\n boolean: (enabled) => ({ enabled }),\n function: (name) => ({ name }),\n string: (name) => ({ name }),\n },\n value: plugin.config.mutationOptions,\n });\n\n plugin.config.queryKeys = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'camelCase',\n enabled: true,\n name: '{{name}}QueryKey',\n tags: false,\n },\n mappers: {\n boolean: (enabled) => ({ enabled }),\n function: (name) => ({ name }),\n string: (name) => ({ name }),\n },\n value: plugin.config.queryKeys,\n });\n\n plugin.config.queryOptions = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'camelCase',\n enabled: true,\n exported: true,\n name: '{{name}}Options',\n },\n mappers: {\n boolean: (enabled) => ({ enabled }),\n function: (name) => ({ name }),\n string: (name) => ({ name }),\n },\n value: plugin.config.queryOptions,\n });\n\n plugin.config.useQuery = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'camelCase',\n enabled: false,\n name: 'use{{name}}Query',\n },\n mappers: {\n boolean: (enabled) => ({ enabled }),\n function: (name) => ({ enabled: true, name }),\n object: (fields) => ({ enabled: true, ...fields }),\n string: (name) => ({ enabled: true, name }),\n },\n value: plugin.config.useQuery,\n });\n\n if (plugin.config.useQuery.enabled) {\n // useQuery hooks consume queryOptions\n if (!plugin.config.queryOptions.enabled) {\n plugin.config.queryOptions.enabled = true;\n plugin.config.queryOptions.exported = false;\n }\n }\n },\n};\n\n/**\n * Type helper for `@tanstack/react-query` plugin, returns {@link Plugin.Config} object\n */\nexport const defineConfig = definePluginConfig(defaultConfig);\n","import { handler } from '~/plugins/@tanstack/query-core/plugin';\nimport { definePluginConfig } from '~/plugins/shared/utils/config';\n\nimport type { TanStackSolidQueryPlugin } from './types';\n\nexport const defaultConfig: TanStackSolidQueryPlugin['Config'] = {\n config: {\n case: 'camelCase',\n comments: true,\n exportFromIndex: false,\n },\n dependencies: ['@hey-api/sdk', '@hey-api/typescript'],\n handler: handler as TanStackSolidQueryPlugin['Handler'],\n name: '@tanstack/solid-query',\n resolveConfig: (plugin, context) => {\n plugin.config.infiniteQueryKeys = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'camelCase',\n enabled: true,\n name: '{{name}}InfiniteQueryKey',\n tags: false,\n },\n mappers: {\n boolean: (enabled) => ({ enabled }),\n function: (name) => ({ name }),\n string: (name) => ({ name }),\n },\n value: plugin.config.infiniteQueryKeys,\n });\n\n plugin.config.infiniteQueryOptions = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'camelCase',\n enabled: true,\n name: '{{name}}InfiniteOptions',\n },\n mappers: {\n boolean: (enabled) => ({ enabled }),\n function: (name) => ({ name }),\n string: (name) => ({ name }),\n },\n value: plugin.config.infiniteQueryOptions,\n });\n\n plugin.config.mutationOptions = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'camelCase',\n enabled: true,\n name: '{{name}}Mutation',\n },\n mappers: {\n boolean: (enabled) => ({ enabled }),\n function: (name) => ({ name }),\n string: (name) => ({ name }),\n },\n value: plugin.config.mutationOptions,\n });\n\n plugin.config.queryKeys = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'camelCase',\n enabled: true,\n name: '{{name}}QueryKey',\n tags: false,\n },\n mappers: {\n boolean: (enabled) => ({ enabled }),\n function: (name) => ({ name }),\n string: (name) => ({ name }),\n },\n value: plugin.config.queryKeys,\n });\n\n plugin.config.queryOptions = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'camelCase',\n enabled: true,\n exported: true,\n name: '{{name}}Options',\n },\n mappers: {\n boolean: (enabled) => ({ enabled }),\n function: (name) => ({ name }),\n string: (name) => ({ name }),\n },\n value: plugin.config.queryOptions,\n });\n },\n};\n\n/**\n * Type helper for `@tanstack/solid-query` plugin, returns {@link Plugin.Config} object\n */\nexport const defineConfig = definePluginConfig(defaultConfig);\n","import { handler } from '~/plugins/@tanstack/query-core/plugin';\nimport { definePluginConfig } from '~/plugins/shared/utils/config';\n\nimport type { TanStackSvelteQueryPlugin } from './types';\n\nexport const defaultConfig: TanStackSvelteQueryPlugin['Config'] = {\n config: {\n case: 'camelCase',\n comments: true,\n exportFromIndex: false,\n },\n dependencies: ['@hey-api/sdk', '@hey-api/typescript'],\n handler: handler as TanStackSvelteQueryPlugin['Handler'],\n name: '@tanstack/svelte-query',\n resolveConfig: (plugin, context) => {\n plugin.config.infiniteQueryKeys = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'camelCase',\n enabled: true,\n name: '{{name}}InfiniteQueryKey',\n tags: false,\n },\n mappers: {\n boolean: (enabled) => ({ enabled }),\n function: (name) => ({ name }),\n string: (name) => ({ name }),\n },\n value: plugin.config.infiniteQueryKeys,\n });\n\n plugin.config.infiniteQueryOptions = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'camelCase',\n enabled: true,\n name: '{{name}}InfiniteOptions',\n },\n mappers: {\n boolean: (enabled) => ({ enabled }),\n function: (name) => ({ name }),\n string: (name) => ({ name }),\n },\n value: plugin.config.infiniteQueryOptions,\n });\n\n plugin.config.mutationOptions = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'camelCase',\n enabled: true,\n name: '{{name}}Mutation',\n },\n mappers: {\n boolean: (enabled) => ({ enabled }),\n function: (name) => ({ name }),\n string: (name) => ({ name }),\n },\n value: plugin.config.mutationOptions,\n });\n\n plugin.config.queryKeys = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'camelCase',\n enabled: true,\n name: '{{name}}QueryKey',\n tags: false,\n },\n mappers: {\n boolean: (enabled) => ({ enabled }),\n function: (name) => ({ name }),\n string: (name) => ({ name }),\n },\n value: plugin.config.queryKeys,\n });\n\n plugin.config.queryOptions = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'camelCase',\n enabled: true,\n exported: true,\n name: '{{name}}Options',\n },\n mappers: {\n boolean: (enabled) => ({ enabled }),\n function: (name) => ({ name }),\n string: (name) => ({ name }),\n },\n value: plugin.config.queryOptions,\n });\n },\n};\n\n/**\n * Type helper for `@tanstack/svelte-query` plugin, returns {@link Plugin.Config} object\n */\nexport const defineConfig = definePluginConfig(defaultConfig);\n","import { handler } from '~/plugins/@tanstack/query-core/plugin';\nimport { definePluginConfig } from '~/plugins/shared/utils/config';\n\nimport type { TanStackVueQueryPlugin } from './types';\n\nexport const defaultConfig: TanStackVueQueryPlugin['Config'] = {\n config: {\n case: 'camelCase',\n comments: true,\n exportFromIndex: false,\n },\n dependencies: ['@hey-api/sdk', '@hey-api/typescript'],\n handler: handler as TanStackVueQueryPlugin['Handler'],\n name: '@tanstack/vue-query',\n resolveConfig: (plugin, context) => {\n plugin.config.infiniteQueryKeys = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'camelCase',\n enabled: true,\n name: '{{name}}InfiniteQueryKey',\n tags: false,\n },\n mappers: {\n boolean: (enabled) => ({ enabled }),\n function: (name) => ({ name }),\n string: (name) => ({ name }),\n },\n value: plugin.config.infiniteQueryKeys,\n });\n\n plugin.config.infiniteQueryOptions = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'camelCase',\n enabled: true,\n name: '{{name}}InfiniteOptions',\n },\n mappers: {\n boolean: (enabled) => ({ enabled }),\n function: (name) => ({ name }),\n string: (name) => ({ name }),\n },\n value: plugin.config.infiniteQueryOptions,\n });\n\n plugin.config.mutationOptions = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'camelCase',\n enabled: true,\n name: '{{name}}Mutation',\n },\n mappers: {\n boolean: (enabled) => ({ enabled }),\n function: (name) => ({ name }),\n string: (name) => ({ name }),\n },\n value: plugin.config.mutationOptions,\n });\n\n plugin.config.queryKeys = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'camelCase',\n enabled: true,\n name: '{{name}}QueryKey',\n tags: false,\n },\n mappers: {\n boolean: (enabled) => ({ enabled }),\n function: (name) => ({ name }),\n string: (name) => ({ name }),\n },\n value: plugin.config.queryKeys,\n });\n\n plugin.config.queryOptions = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'camelCase',\n enabled: true,\n exported: true,\n name: '{{name}}Options',\n },\n mappers: {\n boolean: (enabled) => ({ enabled }),\n function: (name) => ({ name }),\n string: (name) => ({ name }),\n },\n value: plugin.config.queryOptions,\n });\n },\n};\n\n/**\n * Type helper for `@tanstack/vue-query` plugin, returns {@link Plugin.Config} object\n */\nexport const defineConfig = definePluginConfig(defaultConfig);\n","import { $ } from '~/ts-dsl';\n\nimport type { ValidatorArgs } from '../shared/types';\n\nexport const createRequestValidatorV2 = ({\n operation,\n plugin,\n}: ValidatorArgs): ReturnType<typeof $.func> | undefined => {\n const symbol = plugin.getSymbol({\n category: 'schema',\n resource: 'operation',\n resourceId: operation.id,\n role: 'data',\n tool: 'arktype',\n });\n if (!symbol) return;\n\n // const out = User({\n // name: \"Alan Turing\",\n // device: {\n // platform: \"enigma\",\n // versions: [0, \"1\", 0n]\n // }\n // })\n // if (out instanceof type.errors) {\n // // hover out.summary to see validation errors\n // console.error(out.summary)\n // } else {\n // // hover out to see your validated data\n // console.log(`Hello, ${out.name}`)\n // }\n const dataParameterName = 'data';\n return $.func()\n .async()\n .param(dataParameterName)\n .do(\n $(symbol.placeholder)\n .attr('parseAsync')\n .call(dataParameterName)\n .await()\n .return(),\n );\n};\n\nexport const createResponseValidatorV2 = ({\n operation,\n plugin,\n}: ValidatorArgs): ReturnType<typeof $.func> | undefined => {\n const symbol = plugin.getSymbol({\n category: 'schema',\n resource: 'operation',\n resourceId: operation.id,\n role: 'responses',\n tool: 'arktype',\n });\n if (!symbol) return;\n\n const dataParameterName = 'data';\n return $.func()\n .async()\n .param(dataParameterName)\n .do(\n $(symbol.placeholder)\n .attr('parseAsync')\n .call(dataParameterName)\n .await()\n .return(),\n );\n};\n","import type { $ } from '~/ts-dsl';\n\nimport type { ValidatorArgs } from './shared/types';\nimport { createRequestValidatorV2, createResponseValidatorV2 } from './v2/api';\n\nexport type IApi = {\n createRequestValidator: (\n args: ValidatorArgs,\n ) => ReturnType<typeof $.func> | undefined;\n createResponseValidator: (\n args: ValidatorArgs,\n ) => ReturnType<typeof $.func> | undefined;\n};\n\nexport class Api implements IApi {\n createRequestValidator(\n args: ValidatorArgs,\n ): ReturnType<typeof $.func> | undefined {\n return createRequestValidatorV2(args);\n }\n\n createResponseValidator(\n args: ValidatorArgs,\n ): ReturnType<typeof $.func> | undefined {\n return createResponseValidatorV2(args);\n }\n}\n","export const identifiers = {\n keywords: {\n false: 'false',\n true: 'true',\n },\n /**\n * {@link https://arktype.io/docs/primitives#number Number}\n */\n number: {\n Infinity: 'Infinity',\n NaN: 'NaN',\n NegativeInfinity: 'NegativeInfinity',\n epoch: 'epoch',\n integer: 'integer',\n safe: 'safe',\n },\n /**\n * {@link https://arktype.io/docs/primitives Primitives}\n */\n primitives: {\n bigint: 'bigint',\n boolean: 'boolean',\n keywords: 'keywords',\n null: 'null',\n number: 'number',\n string: 'string',\n symbol: 'symbol',\n undefined: 'undefined',\n unit: 'unit',\n },\n /**\n * {@link https://arktype.io/docs/primitives#string String}\n */\n string: {\n NFC: 'NFC',\n NFD: 'NFD',\n NFKC: 'NFKC',\n NFKD: 'NFKD',\n alpha: 'alpha',\n alphanumeric: 'alphanumeric',\n base64: 'base64',\n capitalize: 'capitalize',\n creditCard: 'creditCard',\n date: 'date',\n digits: 'digits',\n email: 'email',\n epoch: 'epoch',\n hex: 'hex',\n integer: 'integer',\n ip: 'ip',\n iso: 'iso',\n json: 'json',\n lower: 'lower',\n normalize: 'normalize',\n numeric: 'numeric',\n parse: 'parse',\n preformatted: 'preformatted',\n regex: 'regex',\n semver: 'semver',\n trim: 'trim',\n upper: 'upper',\n url: 'url',\n uuid: 'uuid',\n v1: 'v1',\n v2: 'v2',\n v3: 'v3',\n v4: 'v4',\n v5: 'v5',\n v6: 'v6',\n v7: 'v7',\n v8: 'v8',\n },\n /**\n * {@link https://arktype.io/docs/type-api Type API}\n */\n type: {\n $: '$',\n allows: 'allows',\n and: 'and',\n array: 'array',\n as: 'as',\n assert: 'assert',\n brand: 'brand',\n configure: 'configure',\n default: 'default',\n describe: 'describe',\n description: 'description',\n equals: 'equals',\n exclude: 'exclude',\n expression: 'expression',\n extends: 'extends',\n extract: 'extract',\n filter: 'filter',\n from: 'from',\n ifEquals: 'ifEquals',\n ifExtends: 'ifExtends',\n infer: 'infer',\n inferIn: 'inferIn',\n intersect: 'intersect',\n json: 'json',\n meta: 'meta',\n narrow: 'narrow',\n onDeepUndeclaredKey: 'onDeepUndeclaredKey',\n onUndeclaredKey: 'onUndeclaredKey',\n optional: 'optional',\n or: 'or',\n overlaps: 'overlaps',\n pipe: 'pipe',\n select: 'select',\n to: 'to',\n toJsonSchema: 'toJsonSchema',\n },\n};\n","import type { Symbol } from '@hey-api/codegen-core';\n\nimport type { IR } from '~/ir/types';\nimport { createSchemaComment } from '~/plugins/shared/utils/schema';\nimport { $ } from '~/ts-dsl';\n\nimport { identifiers } from '../constants';\nimport type { ArktypePlugin } from '../types';\nimport type { Ast } from './types';\n\nexport const exportAst = ({\n ast,\n plugin,\n schema,\n symbol,\n typeInferSymbol,\n}: {\n ast: Ast;\n plugin: ArktypePlugin['Instance'];\n schema: IR.SchemaObject;\n symbol: Symbol;\n typeInferSymbol: Symbol | undefined;\n}): void => {\n const type = plugin.referenceSymbol({\n category: 'external',\n resource: 'arktype.type',\n });\n\n const statement = $.const(symbol.placeholder)\n .export(symbol.exported)\n .$if(plugin.config.comments && createSchemaComment(schema), (c, v) =>\n c.doc(v),\n )\n // .type(\n // ast.typeName\n // ? (tsc.propertyAccessExpression({\n // expression: z.placeholder,\n // name: ast.typeName,\n // }) as unknown as ts.TypeNode)\n // : undefined,\n // )\n .assign(\n $(type.placeholder).call(ast.def ? $.literal(ast.def) : ast.expression),\n );\n plugin.setSymbolValue(symbol, statement);\n\n if (typeInferSymbol) {\n const inferType = $.type\n .alias(typeInferSymbol.placeholder)\n .export(typeInferSymbol.exported)\n .type(\n $.type(symbol.placeholder).attr(identifiers.type.infer).typeofType(),\n );\n plugin.setSymbolValue(typeInferSymbol, inferType);\n }\n};\n","import type { SchemaWithType } from '~/plugins/shared/types/schema';\n\nimport { identifiers } from '../../constants';\nimport type { Ast, IrSchemaToAstOptions } from '../../shared/types';\n\nexport const nullToAst = (\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _args: IrSchemaToAstOptions & {\n schema: SchemaWithType<'null'>;\n },\n): Omit<Ast, 'typeName'> => {\n const result: Partial<Omit<Ast, 'typeName'>> = {};\n result.def = identifiers.primitives.null;\n return result as Omit<Ast, 'typeName'>;\n};\n","import type { SchemaWithType } from '~/plugins/shared/types/schema';\nimport { toRef } from '~/plugins/shared/utils/refs';\nimport { $ } from '~/ts-dsl';\n\n// import { identifiers } from '../../constants';\nimport type { Ast, IrSchemaToAstOptions } from '../../shared/types';\nimport { irSchemaToAst } from '../plugin';\n\nexport const objectToAst = ({\n plugin,\n schema,\n state,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'object'>;\n}): Omit<Ast, 'typeName'> => {\n const result: Partial<Omit<Ast, 'typeName'>> = {};\n\n // TODO: parser - handle constants\n\n const shape = $.object().pretty();\n\n const required = schema.required ?? [];\n\n for (const name in schema.properties) {\n const property = schema.properties[name]!;\n const isRequired = required.includes(name);\n\n const propertyAst = irSchemaToAst({\n optional: !isRequired,\n plugin,\n schema: property,\n state: {\n ...state,\n path: toRef([...state.path.value, 'properties', name]),\n },\n });\n if (propertyAst.hasLazyExpression) {\n result.hasLazyExpression = true;\n }\n\n // if (propertyAst.hasCircularReference) {\n // properties.push(\n // tsc.getAccessorDeclaration({\n // name: propertyName,\n // // @ts-expect-error\n // returnType: propertyAst.typeName\n // ? tsc.propertyAccessExpression({\n // expression: 'TODO',\n // name: propertyAst.typeName,\n // })\n // : undefined,\n // statements: [\n // tsc.returnStatement({\n // expression: propertyAst.expression,\n // }),\n // ],\n // }),\n // );\n // } else {\n // properties.push(\n // tsc.propertyAssignment({\n // initializer: propertyAst.expression,\n // name: ts.factory.createComputedPropertyName(\n // ts.factory.createStringLiteral(`${propertyName}?`),\n // ),\n // }),\n // );\n // }\n\n shape.prop(isRequired ? name : `${name}?`, propertyAst.expression);\n }\n\n if (\n schema.additionalProperties &&\n (!schema.properties || !Object.keys(schema.properties).length)\n ) {\n const additionalAst = irSchemaToAst({\n plugin,\n schema: schema.additionalProperties,\n state: {\n ...state,\n path: toRef([...state.path.value, 'additionalProperties']),\n },\n });\n // name: identifiers.record,\n result.expression = $('TODO').attr('record').call(\n // name: identifiers.string,\n $('TODO').attr('string').call(),\n additionalAst.expression,\n );\n if (additionalAst.hasLazyExpression) {\n result.hasLazyExpression = true;\n }\n\n // Return with typeName for circular references\n if (result.hasLazyExpression) {\n return {\n ...result,\n typeName: 'TODO',\n } as Ast;\n }\n\n return result as Omit<Ast, 'typeName'>;\n }\n\n result.expression = shape;\n\n // return with typeName for circular references\n if (result.hasLazyExpression) {\n return {\n ...result,\n typeName: 'TODO',\n } as Ast;\n }\n\n return result as Omit<Ast, 'typeName'>;\n};\n","import type { SchemaWithType } from '~/plugins/shared/types/schema';\n\nimport { identifiers } from '../../constants';\nimport type { Ast, IrSchemaToAstOptions } from '../../shared/types';\n\nexport const stringToAst = ({\n schema,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'string'>;\n}): Omit<Ast, 'typeName'> => {\n const result: Partial<Omit<Ast, 'typeName'>> = {};\n\n if (typeof schema.const === 'string') {\n result.def = schema.const;\n return result as Omit<Ast, 'typeName'>;\n }\n\n let def = identifiers.primitives.string;\n\n if (schema.format) {\n switch (schema.format) {\n case 'date':\n case 'date-time':\n case 'time':\n def = `${def}.${identifiers.string.date}.${identifiers.string.iso}`;\n break;\n case 'email':\n def = `${def}.${identifiers.string.email}`;\n break;\n case 'ipv4':\n def = `${def}.${identifiers.string.ip}.${identifiers.string.v4}`;\n break;\n case 'ipv6':\n def = `${def}.${identifiers.string.ip}.${identifiers.string.v6}`;\n break;\n case 'uri':\n def = `${def}.${identifiers.string.url}`;\n break;\n case 'uuid':\n def = `${def}.${identifiers.string.uuid}`;\n break;\n }\n }\n\n if (schema.minLength === schema.maxLength && schema.minLength !== undefined) {\n def = `${schema.minLength} <= ${def} <= ${schema.maxLength}`;\n } else {\n if (schema.maxLength !== undefined) {\n def = `${def} <= ${schema.maxLength}`;\n\n if (schema.minLength !== undefined) {\n def = `${schema.minLength} <= ${def}`;\n }\n } else if (schema.minLength !== undefined) {\n def = `${def} >= ${schema.minLength}`;\n }\n }\n\n if (schema.pattern) {\n def = `/${schema.pattern}/`;\n }\n\n result.def = def;\n\n return result as Omit<Ast, 'typeName'>;\n};\n","import type { SchemaWithType } from '~/plugins/shared/types/schema';\nimport { $ } from '~/ts-dsl';\n\nimport type { Ast, IrSchemaToAstOptions } from '../../shared/types';\nimport { nullToAst } from './null';\nimport { objectToAst } from './object';\nimport { stringToAst } from './string';\n// import { arrayToAst } from \"./array\";\n// import { booleanToAst } from \"./boolean\";\n// import { enumToAst } from \"./enum\";\n// import { neverToAst } from \"./never\";\n// import { numberToAst } from \"./number\";\n// import { tupleToAst } from \"./tuple\";\n// import { undefinedToAst } from \"./undefined\";\n// import { unknownToAst } from \"./unknown\";\n// import { voidToAst } from \"./void\";\n\nexport const irSchemaWithTypeToAst = ({\n schema,\n ...args\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType;\n}): Omit<Ast, 'typeName'> => {\n switch (schema.type) {\n // case 'array':\n // return arrayToAst({\n // ...args,\n // schema: schema as SchemaWithType<'array'>,\n // });\n // case 'boolean':\n // return booleanToAst({\n // ...args,\n // schema: schema as SchemaWithType<'boolean'>,\n // });\n // case 'enum':\n // return enumToAst({\n // ...args,\n // schema: schema as SchemaWithType<'enum'>,\n // });\n // case 'integer':\n // case 'number':\n // return numberToAst({\n // ...args,\n // schema: schema as SchemaWithType<'integer' | 'number'>,\n // });\n // case 'never':\n // return neverToAst({\n // ...args,\n // schema: schema as SchemaWithType<'never'>,\n // });\n case 'null':\n return nullToAst({\n ...args,\n schema: schema as SchemaWithType<'null'>,\n });\n case 'object':\n return objectToAst({\n ...args,\n schema: schema as SchemaWithType<'object'>,\n });\n case 'string':\n return stringToAst({\n ...args,\n schema: schema as SchemaWithType<'string'>,\n });\n // case 'tuple':\n // return tupleToAst({\n // ...args,\n // schema: schema as SchemaWithType<'tuple'>,\n // });\n // case 'undefined':\n // return undefinedToAst({\n // ...args,\n // schema: schema as SchemaWithType<'undefined'>,\n // });\n // case 'unknown':\n // return unknownToAst({\n // ...args,\n // schema: schema as SchemaWithType<'unknown'>,\n // });\n // case 'void':\n // return voidToAst({\n // ...args,\n // schema: schema as SchemaWithType<'void'>,\n // });\n }\n\n const type = args.plugin.referenceSymbol({\n category: 'external',\n resource: 'arktype.type',\n });\n\n const expression = $(type.placeholder).call(\n $.object()\n .prop('name', $.literal('string'))\n .prop('platform', $.literal(\"'android' | 'ios'\"))\n .prop('versions?', $.literal('(number | string)[]')),\n );\n\n return {\n def: '',\n expression,\n hasLazyExpression: false,\n };\n};\n","import type { SymbolMeta } from '@hey-api/codegen-core';\n\nimport { deduplicateSchema } from '~/ir/schema';\nimport type { IR } from '~/ir/types';\nimport { buildName } from '~/openApi/shared/utils/name';\nimport type { SchemaWithType } from '~/plugins/shared/types/schema';\nimport { toRefs } from '~/plugins/shared/utils/refs';\nimport { $ } from '~/ts-dsl';\nimport { pathToJsonPointer, refToName } from '~/utils/ref';\n\nimport { exportAst } from '../shared/export';\nimport type { Ast, IrSchemaToAstOptions, PluginState } from '../shared/types';\nimport type { ArktypePlugin } from '../types';\nimport { irSchemaWithTypeToAst } from './toAst';\n\nexport const irSchemaToAst = ({\n // optional,\n plugin,\n schema,\n state,\n}: IrSchemaToAstOptions & {\n /**\n * Accept `optional` to handle optional object properties. We can't handle\n * this inside the object function because `.optional()` must come before\n * `.default()` which is handled in this function.\n */\n optional?: boolean;\n schema: IR.SchemaObject;\n}): Ast => {\n let ast: Partial<Ast> = {};\n\n // const z = plugin.referenceSymbol({\n // category: 'external',\n // resource: 'arktype.type',\n // });\n\n if (schema.$ref) {\n const query: SymbolMeta = {\n category: 'schema',\n resource: 'definition',\n resourceId: schema.$ref,\n tool: 'arktype',\n };\n const refSymbol = plugin.referenceSymbol(query);\n if (plugin.isSymbolRegistered(query)) {\n const ref = $(refSymbol.placeholder);\n ast.expression = ref;\n } else {\n // expression: z.placeholder,\n // name: identifiers.lazy,\n const lazyExpression = $('TODO')\n .attr('TODO')\n .call($.func().returns('any').do($.return(refSymbol.placeholder)));\n ast.expression = lazyExpression;\n ast.hasLazyExpression = true;\n state.hasLazyExpression.value = true;\n }\n } else if (schema.type) {\n const typeAst = irSchemaWithTypeToAst({\n plugin,\n schema: schema as SchemaWithType,\n state,\n });\n ast.def = typeAst.def;\n ast.expression = typeAst.expression;\n ast.hasLazyExpression = typeAst.hasLazyExpression;\n\n if (plugin.config.metadata && schema.description) {\n // TODO: add description\n // ast.expression = tsc.callExpression({\n // functionName: tsc.propertyAccessExpression({\n // expression: ast.expression,\n // name: identifiers.register,\n // }),\n // parameters: [\n // tsc.propertyAccessExpression({\n // expression: z.placeholder,\n // name: identifiers.globalRegistry,\n // }),\n // tsc.objectExpression({\n // obj: [\n // {\n // key: 'description',\n // value: tsc.stringLiteral({ text: schema.description }),\n // },\n // ],\n // }),\n // ],\n // });\n }\n } else if (schema.items) {\n schema = deduplicateSchema({ schema });\n\n if (schema.items) {\n // const itemSchemas = schema.items.map((item, index) =>\n // irSchemaToAst({\n // plugin,\n // schema: item,\n // state: {\n // ...state,\n // _path: [...state._path, 'items', index],\n // },\n // }),\n // );\n // if (schema.logicalOperator === 'and') {\n // const firstSchema = schema.items[0]!;\n // // we want to add an intersection, but not every schema can use the same API.\n // // if the first item contains another array or not an object, we cannot use\n // // `.merge()` as that does not exist on `.union()` and non-object schemas.\n // if (\n // firstSchema.logicalOperator === 'or' ||\n // (firstSchema.type && firstSchema.type !== 'object')\n // ) {\n // ast.expression = tsc.callExpression({\n // functionName: tsc.propertyAccessExpression({\n // expression: z.placeholder,\n // name: identifiers.intersection,\n // }),\n // parameters: itemSchemas.map((schema) => schema.expression),\n // });\n // } else {\n // ast.expression = itemSchemas[0]!.expression;\n // itemSchemas.slice(1).forEach((schema) => {\n // ast.expression = tsc.callExpression({\n // functionName: tsc.propertyAccessExpression({\n // expression: ast.expression!,\n // name: identifiers.and,\n // }),\n // parameters: [\n // schema.hasCircularReference\n // ? tsc.callExpression({\n // functionName: tsc.propertyAccessExpression({\n // expression: z.placeholder,\n // name: identifiers.lazy,\n // }),\n // parameters: [\n // tsc.arrowFunction({\n // statements: [\n // tsc.returnStatement({\n // expression: schema.expression,\n // }),\n // ],\n // }),\n // ],\n // })\n // : schema.expression,\n // ],\n // });\n // });\n // }\n // } else {\n // ast.expression = tsc.callExpression({\n // functionName: tsc.propertyAccessExpression({\n // expression: z.placeholder,\n // name: identifiers.union,\n // }),\n // parameters: [\n // tsc.arrayLiteralExpression({\n // elements: itemSchemas.map((schema) => schema.expression),\n // }),\n // ],\n // });\n // }\n } else {\n ast = irSchemaToAst({ plugin, schema, state });\n }\n } else {\n // catch-all fallback for failed schemas\n const typeAst = irSchemaWithTypeToAst({\n plugin,\n schema: {\n type: 'unknown',\n },\n state,\n });\n ast.def = typeAst.def;\n ast.expression = typeAst.expression;\n }\n\n // TODO: remove later\n if (!ast.expression) {\n const typeAst = irSchemaWithTypeToAst({\n plugin,\n schema: {\n type: 'unknown',\n },\n state,\n });\n ast.expression = typeAst.expression;\n }\n // END TODO: remove later\n\n // if (ast.expression) {\n // if (schema.accessScope === 'read') {\n // ast.expression = tsc.callExpression({\n // functionName: tsc.propertyAccessExpression({\n // expression: ast.expression,\n // name: identifiers.readonly,\n // }),\n // });\n // }\n\n // if (optional) {\n // ast.expression = tsc.callExpression({\n // functionName: tsc.propertyAccessExpression({\n // expression: z.placeholder,\n // name: identifiers.optional,\n // }),\n // parameters: [ast.expression],\n // });\n // ast.typeName = identifiers.ZodOptional;\n // }\n\n // if (schema.default !== undefined) {\n // const isBigInt = schema.type === 'integer' && schema.format === 'int64';\n // const callParameter = numberParameter({\n // isBigInt,\n // value: schema.default,\n // });\n // if (callParameter) {\n // ast.expression = tsc.callExpression({\n // functionName: tsc.propertyAccessExpression({\n // expression: ast.expression,\n // name: identifiers.default,\n // }),\n // parameters: [callParameter],\n // });\n // }\n // }\n // }\n\n return ast as Ast;\n};\n\nconst handleComponent = ({\n plugin,\n schema,\n state,\n}: IrSchemaToAstOptions & {\n schema: IR.SchemaObject;\n}): void => {\n const $ref = pathToJsonPointer(state.path.value);\n const ast = irSchemaToAst({ plugin, schema, state });\n const baseName = refToName($ref);\n const symbol = plugin.registerSymbol({\n exported: true,\n meta: {\n category: 'schema',\n path: state.path.value,\n resource: 'definition',\n resourceId: $ref,\n tags: state.tags?.value,\n tool: 'arktype',\n },\n name: buildName({\n config: plugin.config.definitions,\n name: baseName,\n }),\n });\n const typeInferSymbol = plugin.config.definitions.types.infer.enabled\n ? plugin.registerSymbol({\n exported: true,\n kind: 'type',\n meta: {\n category: 'type',\n path: state.path.value,\n resource: 'definition',\n resourceId: $ref,\n tool: 'arktype',\n variant: 'infer',\n },\n name: buildName({\n config: plugin.config.definitions.types.infer,\n name: baseName,\n }),\n })\n : undefined;\n exportAst({\n ast,\n plugin,\n schema,\n symbol,\n typeInferSymbol,\n });\n};\n\nexport const handlerV2: ArktypePlugin['Handler'] = ({ plugin }) => {\n plugin.registerSymbol({\n external: 'arktype',\n meta: {\n category: 'external',\n resource: 'arktype.type',\n },\n name: 'type',\n });\n\n plugin.forEach(\n 'operation',\n 'parameter',\n 'requestBody',\n 'schema',\n 'webhook',\n (event) => {\n const state = toRefs<PluginState>({\n hasLazyExpression: false,\n path: event._path,\n tags: event.tags,\n });\n switch (event.type) {\n // case 'operation':\n // operationToZodSchema({\n // getZodSchema: (schema) => {\n // const state: State = {\n // circularReferenceTracker: [],\n // currentReferenceTracker: [],\n // hasCircularReference: false,\n // };\n // return schemaToZodSchema({ plugin, schema, state });\n // },\n // operation: event.operation,\n // plugin,\n // });\n // break;\n case 'parameter':\n handleComponent({\n plugin,\n schema: event.parameter.schema,\n state,\n });\n break;\n case 'requestBody':\n handleComponent({\n plugin,\n schema: event.requestBody.schema,\n state,\n });\n break;\n case 'schema':\n handleComponent({\n plugin,\n schema: event.schema,\n state,\n });\n break;\n // case 'webhook':\n // webhookToZodSchema({\n // getZodSchema: (schema) => {\n // const state: State = {\n // circularReferenceTracker: [],\n // currentReferenceTracker: [],\n // hasCircularReference: false,\n // };\n // return schemaToZodSchema({ plugin, schema, state });\n // },\n // operation: event.operation,\n // plugin,\n // });\n // break;\n }\n },\n );\n};\n","import type { ArktypePlugin } from './types';\nimport { handlerV2 } from './v2/plugin';\n\nexport const handler: ArktypePlugin['Handler'] = (args) => handlerV2(args);\n","import { definePluginConfig, mappers } from '~/plugins/shared/utils/config';\n\nimport { Api } from './api';\nimport { handler } from './plugin';\nimport type { ArktypePlugin } from './types';\n\nexport const defaultConfig: ArktypePlugin['Config'] = {\n api: new Api(),\n config: {\n case: 'PascalCase',\n comments: true,\n exportFromIndex: false,\n metadata: false,\n },\n handler,\n name: 'arktype',\n resolveConfig: (plugin, context) => {\n plugin.config.types = context.valueToObject({\n defaultValue: {\n infer: {\n case: 'PascalCase',\n enabled: false,\n },\n },\n mappers: {\n object: (fields, defaultValue) => ({\n ...fields,\n infer: context.valueToObject({\n defaultValue: {\n ...(defaultValue.infer as Extract<\n typeof defaultValue.infer,\n Record<string, unknown>\n >),\n enabled:\n fields.infer !== undefined\n ? Boolean(fields.infer)\n : (\n defaultValue.infer as Extract<\n typeof defaultValue.infer,\n Record<string, unknown>\n >\n ).enabled,\n },\n mappers,\n value: fields.infer,\n }),\n }),\n },\n value: plugin.config.types,\n });\n\n plugin.config.definitions = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'PascalCase',\n enabled: true,\n name: '{{name}}',\n types: {\n ...plugin.config.types,\n infer: {\n ...(plugin.config.types.infer as Extract<\n typeof plugin.config.types.infer,\n Record<string, unknown>\n >),\n name: '{{name}}',\n },\n },\n },\n mappers: {\n ...mappers,\n object: (fields, defaultValue) => ({\n ...fields,\n types: context.valueToObject({\n defaultValue: defaultValue.types!,\n mappers: {\n object: (fields, defaultValue) => ({\n ...fields,\n infer: context.valueToObject({\n defaultValue: {\n ...(defaultValue.infer as Extract<\n typeof defaultValue.infer,\n Record<string, unknown>\n >),\n enabled:\n fields.infer !== undefined\n ? Boolean(fields.infer)\n : (\n defaultValue.infer as Extract<\n typeof defaultValue.infer,\n Record<string, unknown>\n >\n ).enabled,\n },\n mappers,\n value: fields.infer,\n }),\n }),\n },\n value: fields.types,\n }),\n }),\n },\n value: plugin.config.definitions,\n });\n\n plugin.config.requests = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'PascalCase',\n enabled: true,\n name: '{{name}}Data',\n types: {\n ...plugin.config.types,\n infer: {\n ...(plugin.config.types.infer as Extract<\n typeof plugin.config.types.infer,\n Record<string, unknown>\n >),\n name: '{{name}}Data',\n },\n },\n },\n mappers: {\n ...mappers,\n object: (fields, defaultValue) => ({\n ...fields,\n types: context.valueToObject({\n defaultValue: defaultValue.types!,\n mappers: {\n object: (fields, defaultValue) => ({\n ...fields,\n infer: context.valueToObject({\n defaultValue: {\n ...(defaultValue.infer as Extract<\n typeof defaultValue.infer,\n Record<string, unknown>\n >),\n enabled:\n fields.infer !== undefined\n ? Boolean(fields.infer)\n : (\n defaultValue.infer as Extract<\n typeof defaultValue.infer,\n Record<string, unknown>\n >\n ).enabled,\n },\n mappers,\n value: fields.infer,\n }),\n }),\n },\n value: fields.types,\n }),\n }),\n },\n value: plugin.config.requests,\n });\n\n plugin.config.responses = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'PascalCase',\n enabled: true,\n name: '{{name}}Response',\n types: {\n ...plugin.config.types,\n infer: {\n ...(plugin.config.types.infer as Extract<\n typeof plugin.config.types.infer,\n Record<string, unknown>\n >),\n name: '{{name}}Response',\n },\n },\n },\n mappers: {\n ...mappers,\n object: (fields, defaultValue) => ({\n ...fields,\n types: context.valueToObject({\n defaultValue: defaultValue.types!,\n mappers: {\n object: (fields, defaultValue) => ({\n ...fields,\n infer: context.valueToObject({\n defaultValue: {\n ...(defaultValue.infer as Extract<\n typeof defaultValue.infer,\n Record<string, unknown>\n >),\n enabled:\n fields.infer !== undefined\n ? Boolean(fields.infer)\n : (\n defaultValue.infer as Extract<\n typeof defaultValue.infer,\n Record<string, unknown>\n >\n ).enabled,\n },\n mappers,\n value: fields.infer,\n }),\n }),\n },\n value: fields.types,\n }),\n }),\n },\n value: plugin.config.responses,\n });\n\n plugin.config.webhooks = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'PascalCase',\n enabled: true,\n name: '{{name}}WebhookRequest',\n types: {\n ...plugin.config.types,\n infer: {\n ...(plugin.config.types.infer as Extract<\n typeof plugin.config.types.infer,\n Record<string, unknown>\n >),\n name: '{{name}}WebhookRequest',\n },\n },\n },\n mappers: {\n ...mappers,\n object: (fields, defaultValue) => ({\n ...fields,\n types: context.valueToObject({\n defaultValue: defaultValue.types!,\n mappers: {\n object: (fields, defaultValue) => ({\n ...fields,\n infer: context.valueToObject({\n defaultValue: {\n ...(defaultValue.infer as Extract<\n typeof defaultValue.infer,\n Record<string, unknown>\n >),\n enabled:\n fields.infer !== undefined\n ? Boolean(fields.infer)\n : (\n defaultValue.infer as Extract<\n typeof defaultValue.infer,\n Record<string, unknown>\n >\n ).enabled,\n },\n mappers,\n value: fields.infer,\n }),\n }),\n },\n value: fields.types,\n }),\n }),\n },\n value: plugin.config.webhooks,\n });\n },\n tags: ['validator'],\n};\n\n/**\n * Type helper for Arktype plugin, returns {@link Plugin.Config} object\n */\nexport const defineConfig = definePluginConfig(defaultConfig);\n","import { operationResponsesMap } from '~/ir/operation';\nimport { hasParameterGroupObjectRequired } from '~/ir/parameter';\nimport type { IR } from '~/ir/types';\nimport { $ } from '~/ts-dsl';\n\nimport type { FastifyPlugin } from './types';\n\nconst operationToRouteHandler = ({\n operation,\n plugin,\n}: {\n operation: IR.OperationObject;\n plugin: FastifyPlugin['Instance'];\n}) => {\n const type = $.type.object();\n\n const symbolDataType = plugin.querySymbol({\n category: 'type',\n resource: 'operation',\n resourceId: operation.id,\n role: 'data',\n tool: 'typescript',\n });\n if (symbolDataType) {\n if (operation.body) {\n type.prop('Body', (p) =>\n p\n .required(operation.body!.required)\n .type($.type(symbolDataType.placeholder).idx($.type.literal('body'))),\n );\n }\n\n if (operation.parameters) {\n if (operation.parameters.header) {\n type.prop('Headers', (p) =>\n p\n .required(\n hasParameterGroupObjectRequired(operation.parameters!.header),\n )\n .type(\n $.type(symbolDataType.placeholder).idx($.type.literal('headers')),\n ),\n );\n }\n\n if (operation.parameters.path) {\n type.prop('Params', (p) =>\n p\n .required(\n hasParameterGroupObjectRequired(operation.parameters!.path),\n )\n .type(\n $.type(symbolDataType.placeholder).idx($.type.literal('path')),\n ),\n );\n }\n\n if (operation.parameters.query) {\n type.prop('Querystring', (p) =>\n p\n .required(\n hasParameterGroupObjectRequired(operation.parameters!.query),\n )\n .type(\n $.type(symbolDataType.placeholder).idx($.type.literal('query')),\n ),\n );\n }\n }\n }\n\n const { errors, responses } = operationResponsesMap(operation);\n\n let errorsTypeReference: ReturnType<typeof $.type> | undefined;\n const symbolErrorType = plugin.querySymbol({\n category: 'type',\n resource: 'operation',\n resourceId: operation.id,\n role: 'errors',\n });\n if (symbolErrorType && errors && errors.properties) {\n const keys = Object.keys(errors.properties);\n if (keys.length) {\n const hasDefaultResponse = keys.includes('default');\n if (!hasDefaultResponse) {\n errorsTypeReference = $.type(symbolErrorType.placeholder);\n } else if (keys.length > 1) {\n errorsTypeReference = $.type('Omit', (t) =>\n t.generics(\n $.type(symbolErrorType.placeholder),\n $.type.literal('default'),\n ),\n );\n }\n }\n }\n\n let responsesTypeReference: ReturnType<typeof $.type> | undefined = undefined;\n const symbolResponseType = plugin.querySymbol({\n category: 'type',\n resource: 'operation',\n resourceId: operation.id,\n role: 'responses',\n });\n if (symbolResponseType && responses && responses.properties) {\n const keys = Object.keys(responses.properties);\n if (keys.length) {\n const hasDefaultResponse = keys.includes('default');\n if (!hasDefaultResponse) {\n responsesTypeReference = $.type(symbolResponseType.placeholder);\n } else if (keys.length > 1) {\n responsesTypeReference = $.type('Omit', (t) =>\n t.generics(\n $.type(symbolResponseType.placeholder),\n $.type.literal('default'),\n ),\n );\n }\n }\n }\n\n const replyTypes = [errorsTypeReference, responsesTypeReference].filter(\n (t): t is ReturnType<typeof $.type> => t !== undefined,\n );\n if (replyTypes.length) {\n type.prop('Reply', (p) => p.type($.type.and(...replyTypes)));\n }\n\n if (type.isEmpty) {\n return;\n }\n\n const symbolRouteHandler = plugin.referenceSymbol({\n category: 'type',\n resource: 'route-handler',\n tool: 'fastify',\n });\n return {\n name: operation.id,\n type: $.type(symbolRouteHandler.placeholder, (t) => t.generic(type)),\n };\n};\n\nexport const handler: FastifyPlugin['Handler'] = ({ plugin }) => {\n plugin.registerSymbol({\n external: 'fastify',\n kind: 'type',\n meta: {\n category: 'type',\n resource: 'route-handler',\n tool: 'fastify',\n },\n name: 'RouteHandler',\n });\n\n const symbolRouteHandlers = plugin.registerSymbol({\n exported: true,\n kind: 'type',\n name: 'RouteHandlers',\n });\n\n const type = $.type.object();\n\n plugin.forEach(\n 'operation',\n ({ operation }) => {\n const routeHandler = operationToRouteHandler({ operation, plugin });\n if (routeHandler) {\n type.prop(routeHandler.name, (p) => p.type(routeHandler.type));\n }\n },\n {\n order: 'declarations',\n },\n );\n\n const node = $.type\n .alias(symbolRouteHandlers.placeholder)\n .export(symbolRouteHandlers.exported)\n .type(type);\n plugin.setSymbolValue(symbolRouteHandlers, node);\n};\n","import { definePluginConfig } from '~/plugins/shared/utils/config';\n\nimport { handler } from './plugin';\nimport type { FastifyPlugin } from './types';\n\nexport const defaultConfig: FastifyPlugin['Config'] = {\n config: {\n exportFromIndex: false,\n },\n dependencies: ['@hey-api/typescript'],\n handler,\n name: 'fastify',\n};\n\n/**\n * Type helper for `fastify` plugin, returns {@link Plugin.Config} object\n */\nexport const defineConfig = definePluginConfig(defaultConfig);\n","import type { IR } from '~/ir/types';\nimport { buildName } from '~/openApi/shared/utils/name';\nimport {\n createOperationComment,\n hasOperationSse,\n} from '~/plugins/shared/utils/operation';\nimport type { TsDsl } from '~/ts-dsl';\nimport { $ } from '~/ts-dsl';\n\nimport type { SwrPlugin } from '../types';\n\nexport const createUseSwr = ({\n operation,\n plugin,\n queryFn,\n}: {\n operation: IR.OperationObject;\n plugin: SwrPlugin['Instance'];\n queryFn: string;\n}): void => {\n if (hasOperationSse({ operation })) {\n return;\n }\n\n const symbolUseSwr = plugin.referenceSymbol({\n category: 'external',\n resource: 'swr',\n });\n const symbolUseQueryFn = plugin.registerSymbol({\n exported: true,\n name: buildName({\n config: plugin.config.useSwr,\n name: operation.id,\n }),\n });\n\n const awaitSdkFn = $(queryFn)\n .call($.object().prop('throwOnError', $.literal(true)))\n .await();\n\n const statements: Array<TsDsl<any>> = [];\n if (plugin.getPluginOrThrow('@hey-api/sdk').config.responseStyle === 'data') {\n statements.push($.return(awaitSdkFn));\n } else {\n statements.push(\n $.const().object('data').assign(awaitSdkFn),\n $.return('data'),\n );\n }\n\n const statement = $.const(symbolUseQueryFn.placeholder)\n .export(symbolUseQueryFn.exported)\n .$if(plugin.config.comments && createOperationComment(operation), (c, v) =>\n c.doc(v),\n )\n .assign(\n $.func().do(\n $(symbolUseSwr.placeholder)\n .call(\n $.literal(operation.path),\n $.func()\n .async()\n .do(...statements),\n )\n .return(),\n ),\n );\n plugin.setSymbolValue(symbolUseQueryFn, statement);\n};\n","import { registryName } from '~/plugins/@hey-api/sdk/shared/class';\nimport { operationClasses } from '~/plugins/@hey-api/sdk/shared/operation';\nimport { stringCase } from '~/utils/stringCase';\n\nimport type { SwrPlugin } from '../types';\nimport { createUseSwr } from './useSwr';\n\nexport const handlerV2: SwrPlugin['Handler'] = ({ plugin }) => {\n plugin.registerSymbol({\n external: 'swr',\n importKind: 'default',\n kind: 'function',\n meta: {\n category: 'external',\n resource: 'swr',\n },\n name: 'useSWR',\n });\n\n const sdkPlugin = plugin.getPluginOrThrow('@hey-api/sdk');\n\n plugin.forEach(\n 'operation',\n ({ operation }) => {\n const classes = sdkPlugin.config.asClass\n ? operationClasses({\n context: plugin.context,\n operation,\n plugin: sdkPlugin,\n })\n : undefined;\n const entry = classes ? classes.values().next().value : undefined;\n // TODO: this should use class graph to determine correct path string\n // as it's really easy to break once we change the class casing\n let queryFn: string;\n if (entry) {\n const symbolClass = plugin.referenceSymbol({\n category: 'utility',\n resource: 'class',\n resourceId: entry.path[0],\n tool: 'sdk',\n });\n queryFn = [\n symbolClass.placeholder,\n ...(sdkPlugin.config.instance ? [registryName, 'get()'] : []),\n ...entry.path.slice(1).map((className) =>\n stringCase({\n case: 'camelCase',\n value: className,\n }),\n ),\n entry.methodName,\n ]\n .filter(Boolean)\n .join('.');\n } else {\n queryFn = plugin.referenceSymbol({\n category: 'sdk',\n resource: 'operation',\n resourceId: operation.id,\n }).placeholder;\n }\n\n if (plugin.hooks.operation.isQuery(operation)) {\n // if (plugin.config.queryOptions.enabled) {\n // createQueryOptions({ operation, plugin, queryFn });\n // }\n\n // if (plugin.config.infiniteQueryOptions.enabled) {\n // createInfiniteQueryOptions({ operation, plugin, queryFn });\n // }\n\n if (plugin.config.useSwr.enabled) {\n createUseSwr({ operation, plugin, queryFn });\n }\n }\n },\n {\n order: 'declarations',\n },\n );\n};\n","import type { SwrPlugin } from './types';\nimport { handlerV2 } from './v2/plugin';\n\nexport const handler: SwrPlugin['Handler'] = (args) => handlerV2(args);\n","import { definePluginConfig } from '~/plugins/shared/utils/config';\n\nimport { handler } from './plugin';\nimport type { SwrPlugin } from './types';\n\nexport const defaultConfig: SwrPlugin['Config'] = {\n config: {\n case: 'camelCase',\n comments: true,\n exportFromIndex: false,\n },\n dependencies: ['@hey-api/sdk', '@hey-api/typescript'],\n handler: handler as SwrPlugin['Handler'],\n name: 'swr',\n resolveConfig: (plugin, context) => {\n plugin.config.infiniteQueryKeys = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'camelCase',\n enabled: true,\n name: '{{name}}InfiniteQueryKey',\n tags: false,\n },\n mappers: {\n boolean: (enabled) => ({ enabled }),\n function: (name) => ({ name }),\n string: (name) => ({ name }),\n },\n value: plugin.config.infiniteQueryKeys,\n });\n\n plugin.config.infiniteQueryOptions = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'camelCase',\n enabled: true,\n name: '{{name}}InfiniteOptions',\n },\n mappers: {\n boolean: (enabled) => ({ enabled }),\n function: (name) => ({ name }),\n string: (name) => ({ name }),\n },\n value: plugin.config.infiniteQueryOptions,\n });\n\n plugin.config.mutationOptions = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'camelCase',\n enabled: true,\n name: '{{name}}Mutation',\n },\n mappers: {\n boolean: (enabled) => ({ enabled }),\n function: (name) => ({ name }),\n string: (name) => ({ name }),\n },\n value: plugin.config.mutationOptions,\n });\n\n plugin.config.queryKeys = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'camelCase',\n enabled: true,\n name: '{{name}}QueryKey',\n tags: false,\n },\n mappers: {\n boolean: (enabled) => ({ enabled }),\n function: (name) => ({ name }),\n string: (name) => ({ name }),\n },\n value: plugin.config.queryKeys,\n });\n\n plugin.config.queryOptions = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'camelCase',\n enabled: true,\n exported: true,\n name: '{{name}}Options',\n },\n mappers: {\n boolean: (enabled) => ({ enabled }),\n function: (name) => ({ name }),\n string: (name) => ({ name }),\n },\n value: plugin.config.queryOptions,\n });\n\n plugin.config.useSwr = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'camelCase',\n enabled: true,\n name: 'use{{name}}',\n },\n mappers: {\n boolean: (enabled) => ({ enabled }),\n function: (name) => ({ enabled: true, name }),\n object: (fields) => ({ enabled: true, ...fields }),\n string: (name) => ({ enabled: true, name }),\n },\n value: plugin.config.useSwr,\n });\n\n if (plugin.config.useSwr.enabled) {\n // useSwr hooks consume queryOptions\n if (!plugin.config.queryOptions.enabled) {\n plugin.config.queryOptions.enabled = true;\n plugin.config.queryOptions.exported = false;\n }\n }\n },\n};\n\n/**\n * Type helper for `swr` plugin, returns {@link Plugin.Config} object\n */\nexport const defineConfig = definePluginConfig(defaultConfig);\n","export const identifiers = {\n /**\n * {@link https://valibot.dev/api/#actions Actions}\n */\n actions: {\n args: 'args',\n base64: 'base64',\n bic: 'bic',\n brand: 'brand',\n bytes: 'bytes',\n check: 'check',\n checkItems: 'checkItems',\n creditCard: 'creditCard',\n cuid2: 'cuid2',\n decimal: 'decimal',\n description: 'description',\n digits: 'digits',\n email: 'email',\n emoji: 'emoji',\n empty: 'empty',\n endsWith: 'endsWith',\n entries: 'entries',\n everyItem: 'everyItem',\n excludes: 'excludes',\n filterItems: 'filterItems',\n findItem: 'findItem',\n finite: 'finite',\n flavor: 'flavor',\n graphemes: 'graphemes',\n gtValue: 'gtValue',\n hash: 'hash',\n hexColor: 'hexColor',\n hexadecimal: 'hexadecimal',\n imei: 'imei',\n includes: 'includes',\n integer: 'integer',\n ip: 'ip',\n ipv4: 'ipv4',\n ipv6: 'ipv6',\n isoDate: 'isoDate',\n isoDateTime: 'isoDateTime',\n isoTime: 'isoTime',\n isoTimeSecond: 'isoTimeSecond',\n isoTimestamp: 'isoTimestamp',\n isoWeek: 'isoWeek',\n length: 'length',\n ltValue: 'ltValue',\n mac: 'mac',\n mac48: 'mac48',\n mac64: 'mac64',\n mapItems: 'mapItems',\n maxBytes: 'maxBytes',\n maxEntries: 'maxEntries',\n maxGraphemes: 'maxGraphemes',\n maxLength: 'maxLength',\n maxSize: 'maxSize',\n maxValue: 'maxValue',\n maxWords: 'maxWords',\n metadata: 'metadata',\n mimeType: 'mimeType',\n minBytes: 'minBytes',\n minEntries: 'minEntries',\n minGraphemes: 'minGraphemes',\n minLength: 'minLength',\n minSize: 'minSize',\n minValue: 'minValue',\n minWords: 'minWords',\n multipleOf: 'multipleOf',\n nanoid: 'nanoid',\n nonEmpty: 'nonEmpty',\n normalize: 'normalize',\n notBytes: 'notBytes',\n notEntries: 'notEntries',\n notGraphemes: 'notGraphemes',\n notLength: 'notLength',\n notSize: 'notSize',\n notValue: 'notValue',\n notValues: 'notValues',\n notWords: 'notWords',\n octal: 'octal',\n parseJson: 'parseJson',\n partialCheck: 'partialCheck',\n rawCheck: 'rawCheck',\n rawTransform: 'rawTransform',\n readonly: 'readonly',\n reduceItems: 'reduceItems',\n regex: 'regex',\n returns: 'returns',\n rfcEmail: 'rfcEmail',\n safeInteger: 'safeInteger',\n size: 'size',\n slug: 'slug',\n someItem: 'someItem',\n sortItems: 'sortItems',\n startsWith: 'startsWith',\n stringifyJson: 'stringifyJson',\n title: 'title',\n toLowerCase: 'toLowerCase',\n toMaxValue: 'toMaxValue',\n toMinValue: 'toMinValue',\n toUpperCase: 'toUpperCase',\n transform: 'transform',\n trim: 'trim',\n trimEnd: 'trimEnd',\n trimStart: 'trimStart',\n ulid: 'ulid',\n url: 'url',\n uuid: 'uuid',\n value: 'value',\n values: 'values',\n words: 'words',\n },\n /**\n * {@link https://valibot.dev/api/#async Async}\n */\n async: {\n argsAsync: 'argsAsync',\n arrayAsync: 'arrayAsync',\n awaitAsync: 'awaitAsync',\n checkAsync: 'checkAsync',\n checkItemsAsync: 'checkItemsAsync',\n customAsync: 'customAsync',\n exactOptionalAsync: 'exactOptionalAsync',\n fallbackAsync: 'fallbackAsync',\n forwardAsync: 'forwardAsync',\n getDefaultsAsync: 'getDefaultsAsync',\n getFallbacksAsync: 'getFallbacksAsync',\n intersectAsync: 'intersectAsync',\n lazyAsync: 'lazyAsync',\n looseObjectAsync: 'looseObjectAsync',\n looseTupleAsync: 'looseTupleAsync',\n mapAsync: 'mapAsync',\n nonNullableAsync: 'nonNullableAsync',\n nonNullishAsync: 'nonNullishAsync',\n nonOptionalAsync: 'nonOptionalAsync',\n nullableAsync: 'nullableAsync',\n nullishAsync: 'nullishAsync',\n objectAsync: 'objectAsync',\n objectWithRestAsync: 'objectWithRestAsync',\n optionalAsync: 'optionalAsync',\n parseAsync: 'parseAsync',\n parserAsync: 'parserAsync',\n partialAsync: 'partialAsync',\n partialCheckAsync: 'partialCheckAsync',\n pipeAsync: 'pipeAsync',\n rawCheckAsync: 'rawCheckAsync',\n rawTransformAsync: 'rawTransformAsync',\n recordAsync: 'recordAsync',\n requiredAsync: 'requiredAsync',\n returnsAsync: 'returnsAsync',\n safeParseAsync: 'safeParseAsync',\n safeParserAsync: 'safeParserAsync',\n setAsync: 'setAsync',\n strictObjectAsync: 'strictObjectAsync',\n strictTupleAsync: 'strictTupleAsync',\n transformAsync: 'transformAsync',\n tupleAsync: 'tupleAsync',\n tupleWithRestAsync: 'tupleWithRestAsync',\n undefinedableAsync: 'undefinedableAsync',\n unionAsync: 'unionAsync',\n variantAsync: 'variantAsync',\n },\n /**\n * {@link https://valibot.dev/api/#methods Methods}\n */\n methods: {\n assert: 'assert',\n config: 'config',\n fallback: 'fallback',\n flatten: 'flatten',\n forward: 'forward',\n getDefault: 'getDefault',\n getDefaults: 'getDefaults',\n getDescription: 'getDescription',\n getFallback: 'getFallback',\n getFallbacks: 'getFallbacks',\n getMetadata: 'getMetadata',\n getTitle: 'getTitle',\n is: 'is',\n keyof: 'keyof',\n message: 'message',\n omit: 'omit',\n parse: 'parse',\n parser: 'parser',\n partial: 'partial',\n pick: 'pick',\n pipe: 'pipe',\n required: 'required',\n safeParse: 'safeParse',\n safeParser: 'safeParser',\n summarize: 'summarize',\n unwrap: 'unwrap',\n },\n /**\n * {@link https://valibot.dev/api/#schemas Schemas}\n */\n schemas: {\n any: 'any',\n array: 'array',\n bigInt: 'bigint',\n blob: 'blob',\n boolean: 'boolean',\n custom: 'custom',\n date: 'date',\n enum: 'enum',\n exactOptional: 'exactOptional',\n file: 'file',\n function: 'function',\n instance: 'instance',\n intersect: 'intersect',\n lazy: 'lazy',\n literal: 'literal',\n looseObject: 'looseObject',\n looseTuple: 'looseTuple',\n map: 'map',\n nan: 'nan',\n never: 'never',\n nonNullable: 'nonNullable',\n nonNullish: 'nonNullish',\n nonOptional: 'nonOptional',\n null: 'null',\n nullable: 'nullable',\n nullish: 'nullish',\n number: 'number',\n object: 'object',\n objectWithRest: 'objectWithRest',\n optional: 'optional',\n picklist: 'picklist',\n promise: 'promise',\n record: 'record',\n set: 'set',\n strictObject: 'strictObject',\n strictTuple: 'strictTuple',\n string: 'string',\n symbol: 'symbol',\n tuple: 'tuple',\n tupleWithRest: 'tupleWithRest',\n undefined: 'undefined',\n undefinedable: 'undefinedable',\n union: 'union',\n unknown: 'unknown',\n variant: 'variant',\n void: 'void',\n },\n /**\n * {@link https://valibot.dev/api/#storages Storages}\n */\n storages: {\n // TODO: implement if necessary\n },\n /**\n * {@link https://valibot.dev/api/#types Types}\n */\n types: {\n // TODO: implement if necessary\n GenericSchema: 'GenericSchema',\n },\n /**\n * {@link https://valibot.dev/api/#utils Utils}\n */\n utils: {\n // TODO: implement if necessary\n },\n};\n","import { $ } from '~/ts-dsl';\n\nimport type { ValidatorArgs } from '../shared/types';\nimport type { ValidatorResolverArgs } from '../types';\nimport { identifiers } from './constants';\n\nconst defaultValidatorResolver = ({\n schema,\n v,\n}: ValidatorResolverArgs): ReturnType<typeof $.return> =>\n $(v.placeholder)\n .attr(identifiers.async.parseAsync)\n .call(schema.placeholder, 'data')\n .await()\n .return();\n\nexport const createRequestValidatorV1 = ({\n operation,\n plugin,\n}: ValidatorArgs): ReturnType<typeof $.func> | undefined => {\n const symbol = plugin.getSymbol({\n category: 'schema',\n resource: 'operation',\n resourceId: operation.id,\n role: 'data',\n tool: 'valibot',\n });\n if (!symbol) return;\n\n const v = plugin.referenceSymbol({\n category: 'external',\n resource: 'valibot.v',\n });\n const args: ValidatorResolverArgs = {\n $,\n operation,\n pipes: [],\n plugin,\n schema: symbol,\n v,\n };\n const validator = plugin.config['~resolvers']?.validator;\n const resolver =\n typeof validator === 'function' ? validator : validator?.request;\n const candidates = [resolver, defaultValidatorResolver];\n for (const candidate of candidates) {\n const statements = candidate?.(args);\n if (statements === null) return;\n if (statements !== undefined) {\n return $.func()\n .async()\n .param('data')\n .do(...(statements instanceof Array ? statements : [statements]));\n }\n }\n return;\n};\n\nexport const createResponseValidatorV1 = ({\n operation,\n plugin,\n}: ValidatorArgs): ReturnType<typeof $.func> | undefined => {\n const symbol = plugin.getSymbol({\n category: 'schema',\n resource: 'operation',\n resourceId: operation.id,\n role: 'responses',\n tool: 'valibot',\n });\n if (!symbol) return;\n\n const v = plugin.referenceSymbol({\n category: 'external',\n resource: 'valibot.v',\n });\n const args: ValidatorResolverArgs = {\n $,\n operation,\n pipes: [],\n plugin,\n schema: symbol,\n v,\n };\n const validator = plugin.config['~resolvers']?.validator;\n const resolver =\n typeof validator === 'function' ? validator : validator?.response;\n const candidates = [resolver, defaultValidatorResolver];\n for (const candidate of candidates) {\n const statements = candidate?.(args);\n if (statements === null) return;\n if (statements !== undefined) {\n return $.func()\n .async()\n .param('data')\n .do(...(statements instanceof Array ? statements : [statements]));\n }\n }\n return;\n};\n","import type { $ } from '~/ts-dsl';\n\nimport type { ValidatorArgs } from './shared/types';\nimport { createRequestValidatorV1, createResponseValidatorV1 } from './v1/api';\n\nexport type IApi = {\n createRequestValidator: (\n args: ValidatorArgs,\n ) => ReturnType<typeof $.func> | undefined;\n createResponseValidator: (\n args: ValidatorArgs,\n ) => ReturnType<typeof $.func> | undefined;\n};\n\nexport class Api implements IApi {\n createRequestValidator(\n args: ValidatorArgs,\n ): ReturnType<typeof $.func> | undefined {\n return createRequestValidatorV1(args);\n }\n\n createResponseValidator(\n args: ValidatorArgs,\n ): ReturnType<typeof $.func> | undefined {\n return createResponseValidatorV1(args);\n }\n}\n","import { $ } from '~/ts-dsl';\n\nimport type { ValibotPlugin } from '../types';\nimport { identifiers } from '../v1/constants';\n\nexport const pipesToAst = ({\n pipes,\n plugin,\n}: {\n pipes: ReadonlyArray<ReturnType<typeof $.call | typeof $.expr>>;\n plugin: ValibotPlugin['Instance'];\n}): ReturnType<typeof $.call | typeof $.expr> => {\n if (pipes.length === 1) {\n return pipes[0]!;\n }\n\n const v = plugin.referenceSymbol({\n category: 'external',\n resource: 'valibot.v',\n });\n return $(v.placeholder)\n .attr(identifiers.methods.pipe)\n .call(...pipes);\n};\n","import type { Symbol } from '@hey-api/codegen-core';\n\nimport type { IR } from '~/ir/types';\nimport { createSchemaComment } from '~/plugins/shared/utils/schema';\nimport { $ } from '~/ts-dsl';\n\nimport { identifiers } from '../v1/constants';\nimport { pipesToAst } from './pipesToAst';\nimport type { Ast, IrSchemaToAstOptions } from './types';\n\nexport const exportAst = ({\n ast,\n plugin,\n schema,\n state,\n symbol,\n}: IrSchemaToAstOptions & {\n ast: Ast;\n schema: IR.SchemaObject;\n symbol: Symbol;\n}): void => {\n const v = plugin.referenceSymbol({\n category: 'external',\n resource: 'valibot.v',\n });\n\n const statement = $.const(symbol.placeholder)\n .export(symbol.exported)\n .$if(plugin.config.comments && createSchemaComment(schema), (c, v) =>\n c.doc(v),\n )\n .$if(state.hasLazyExpression.value, (c) =>\n c.type(\n $.type(v.placeholder).attr(\n ast.typeName || identifiers.types.GenericSchema,\n ),\n ),\n )\n .assign(pipesToAst({ pipes: ast.pipes, plugin }));\n plugin.setSymbolValue(symbol, statement);\n};\n","import { $ } from '~/ts-dsl';\n\nexport const INTEGER_FORMATS = {\n int16: {\n max: 32767,\n maxError: 'Invalid value: Expected int16 to be <= 2^15-1',\n min: -32768,\n minError: 'Invalid value: Expected int16 to be >= -2^15',\n needsBigInt: false,\n },\n int32: {\n max: 2147483647,\n maxError: 'Invalid value: Expected int32 to be <= 2^31-1',\n min: -2147483648,\n minError: 'Invalid value: Expected int32 to be >= -2^31',\n needsBigInt: false,\n },\n int64: {\n max: '9223372036854775807',\n maxError: 'Invalid value: Expected int64 to be <= 2^63-1',\n min: '-9223372036854775808',\n minError: 'Invalid value: Expected int64 to be >= -2^63',\n needsBigInt: true,\n },\n int8: {\n max: 127,\n maxError: 'Invalid value: Expected int8 to be <= 2^7-1',\n min: -128,\n minError: 'Invalid value: Expected int8 to be >= -2^7',\n needsBigInt: false,\n },\n uint16: {\n max: 65535,\n maxError: 'Invalid value: Expected uint16 to be <= 2^16-1',\n min: 0,\n minError: 'Invalid value: Expected uint16 to be >= 0',\n needsBigInt: false,\n },\n uint32: {\n max: 4294967295,\n maxError: 'Invalid value: Expected uint32 to be <= 2^32-1',\n min: 0,\n minError: 'Invalid value: Expected uint32 to be >= 0',\n needsBigInt: false,\n },\n uint64: {\n max: '18446744073709551615',\n maxError: 'Invalid value: Expected uint64 to be <= 2^64-1',\n min: '0',\n minError: 'Invalid value: Expected uint64 to be >= 0',\n needsBigInt: true,\n },\n uint8: {\n max: 255,\n maxError: 'Invalid value: Expected uint8 to be <= 2^8-1',\n min: 0,\n minError: 'Invalid value: Expected uint8 to be >= 0',\n needsBigInt: false,\n },\n} as const;\n\nexport type IntegerFormat = keyof typeof INTEGER_FORMATS;\n\nexport const isIntegerFormat = (\n format: string | undefined,\n): format is IntegerFormat => format !== undefined && format in INTEGER_FORMATS;\n\nexport const needsBigIntForFormat = (format: string | undefined): boolean =>\n isIntegerFormat(format) && INTEGER_FORMATS[format].needsBigInt;\n\nexport const numberParameter = ({\n isBigInt,\n value,\n}: {\n isBigInt: boolean;\n value: unknown;\n}): ReturnType<typeof $.call | typeof $.fromValue> => {\n const expression = $.fromValue(value);\n\n if (\n isBigInt &&\n (typeof value === 'bigint' ||\n typeof value === 'number' ||\n typeof value === 'string' ||\n typeof value === 'boolean')\n ) {\n return $('BigInt').call(expression);\n }\n\n return expression;\n};\n","import { operationResponsesMap } from '~/ir/operation';\nimport type { IR } from '~/ir/types';\nimport { buildName } from '~/openApi/shared/utils/name';\n\nimport { exportAst } from './export';\nimport type { Ast, IrSchemaToAstOptions } from './types';\n\nexport const irOperationToAst = ({\n getAst,\n operation,\n plugin,\n state,\n}: IrSchemaToAstOptions & {\n getAst: (\n schema: IR.SchemaObject,\n path: ReadonlyArray<string | number>,\n ) => Ast;\n operation: IR.OperationObject;\n}) => {\n if (plugin.config.requests.enabled) {\n const requiredProperties = new Set<string>();\n\n const schemaData: IR.SchemaObject = {\n properties: {\n body: {\n type: 'never',\n },\n path: {\n type: 'never',\n },\n query: {\n type: 'never',\n },\n },\n type: 'object',\n };\n\n if (operation.parameters) {\n // TODO: add support for cookies\n\n if (operation.parameters.header) {\n const properties: Record<string, IR.SchemaObject> = {};\n const required: Array<string> = [];\n\n for (const key in operation.parameters.header) {\n const parameter = operation.parameters.header[key]!;\n properties[parameter.name] = parameter.schema;\n if (parameter.required) {\n required.push(parameter.name);\n requiredProperties.add('headers');\n }\n }\n\n if (Object.keys(properties).length) {\n schemaData.properties!.headers = {\n properties,\n required,\n type: 'object',\n };\n }\n }\n\n if (operation.parameters.path) {\n const properties: Record<string, IR.SchemaObject> = {};\n const required: Array<string> = [];\n\n for (const key in operation.parameters.path) {\n const parameter = operation.parameters.path[key]!;\n properties[parameter.name] = parameter.schema;\n if (parameter.required) {\n required.push(parameter.name);\n requiredProperties.add('path');\n }\n }\n\n if (Object.keys(properties).length) {\n schemaData.properties!.path = {\n properties,\n required,\n type: 'object',\n };\n }\n }\n\n if (operation.parameters.query) {\n const properties: Record<string, IR.SchemaObject> = {};\n const required: Array<string> = [];\n\n for (const key in operation.parameters.query) {\n const parameter = operation.parameters.query[key]!;\n properties[parameter.name] = parameter.schema;\n if (parameter.required) {\n required.push(parameter.name);\n requiredProperties.add('query');\n }\n }\n\n if (Object.keys(properties).length) {\n schemaData.properties!.query = {\n properties,\n required,\n type: 'object',\n };\n }\n }\n }\n\n if (operation.body) {\n schemaData.properties!.body = operation.body.schema;\n\n if (operation.body.required) {\n requiredProperties.add('body');\n }\n }\n\n schemaData.required = [...requiredProperties];\n\n const ast = getAst(schemaData, state.path.value);\n const symbol = plugin.registerSymbol({\n exported: true,\n meta: {\n category: 'schema',\n path: state.path.value,\n resource: 'operation',\n resourceId: operation.id,\n role: 'data',\n tags: state.tags?.value,\n tool: 'valibot',\n },\n name: buildName({\n config: plugin.config.requests,\n name: operation.id,\n }),\n });\n exportAst({\n ast,\n plugin,\n schema: schemaData,\n state,\n symbol,\n });\n }\n\n if (plugin.config.responses.enabled) {\n if (operation.responses) {\n const { response } = operationResponsesMap(operation);\n\n if (response) {\n const path = [...state.path.value, 'responses'];\n const ast = getAst(response, path);\n const symbol = plugin.registerSymbol({\n exported: true,\n meta: {\n category: 'schema',\n path,\n resource: 'operation',\n resourceId: operation.id,\n role: 'responses',\n tags: state.tags?.value,\n tool: 'valibot',\n },\n name: buildName({\n config: plugin.config.responses,\n name: operation.id,\n }),\n });\n exportAst({\n ast,\n plugin,\n schema: response,\n state,\n symbol,\n });\n }\n }\n }\n};\n","import type { IR } from '~/ir/types';\nimport { buildName } from '~/openApi/shared/utils/name';\n\nimport { exportAst } from './export';\nimport type { Ast, IrSchemaToAstOptions } from './types';\n\nexport const irWebhookToAst = ({\n getAst,\n operation,\n plugin,\n state,\n}: IrSchemaToAstOptions & {\n getAst: (\n schema: IR.SchemaObject,\n path: ReadonlyArray<string | number>,\n ) => Ast;\n operation: IR.OperationObject;\n}) => {\n if (plugin.config.webhooks.enabled) {\n const requiredProperties = new Set<string>();\n\n const schemaData: IR.SchemaObject = {\n properties: {\n body: {\n type: 'never',\n },\n path: {\n type: 'never',\n },\n query: {\n type: 'never',\n },\n },\n type: 'object',\n };\n\n if (operation.parameters) {\n // TODO: add support for cookies\n\n if (operation.parameters.header) {\n const properties: Record<string, IR.SchemaObject> = {};\n const required: Array<string> = [];\n\n for (const key in operation.parameters.header) {\n const parameter = operation.parameters.header[key]!;\n properties[parameter.name] = parameter.schema;\n if (parameter.required) {\n required.push(parameter.name);\n requiredProperties.add('headers');\n }\n }\n\n if (Object.keys(properties).length) {\n schemaData.properties!.headers = {\n properties,\n required,\n type: 'object',\n };\n }\n }\n\n if (operation.parameters.path) {\n const properties: Record<string, IR.SchemaObject> = {};\n const required: Array<string> = [];\n\n for (const key in operation.parameters.path) {\n const parameter = operation.parameters.path[key]!;\n properties[parameter.name] = parameter.schema;\n if (parameter.required) {\n required.push(parameter.name);\n requiredProperties.add('path');\n }\n }\n\n if (Object.keys(properties).length) {\n schemaData.properties!.path = {\n properties,\n required,\n type: 'object',\n };\n }\n }\n\n if (operation.parameters.query) {\n const properties: Record<string, IR.SchemaObject> = {};\n const required: Array<string> = [];\n\n for (const key in operation.parameters.query) {\n const parameter = operation.parameters.query[key]!;\n properties[parameter.name] = parameter.schema;\n if (parameter.required) {\n required.push(parameter.name);\n requiredProperties.add('query');\n }\n }\n\n if (Object.keys(properties).length) {\n schemaData.properties!.query = {\n properties,\n required,\n type: 'object',\n };\n }\n }\n }\n\n if (operation.body) {\n schemaData.properties!.body = operation.body.schema;\n\n if (operation.body.required) {\n requiredProperties.add('body');\n }\n }\n\n schemaData.required = [...requiredProperties];\n\n const ast = getAst(schemaData, state.path.value);\n const symbol = plugin.registerSymbol({\n exported: true,\n meta: {\n category: 'schema',\n path: state.path.value,\n resource: 'webhook',\n resourceId: operation.id,\n role: 'data',\n tags: state.tags?.value,\n tool: 'valibot',\n },\n name: buildName({\n config: plugin.config.webhooks,\n name: operation.id,\n }),\n });\n exportAst({\n ast,\n plugin,\n schema: schemaData,\n state,\n symbol,\n });\n }\n};\n","import type { SchemaWithType } from '~/plugins';\nimport { $ } from '~/ts-dsl';\n\nimport type { IrSchemaToAstOptions } from '../../shared/types';\nimport { identifiers } from '../constants';\n\nexport const unknownToAst = ({\n plugin,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'unknown'>;\n}) => {\n const v = plugin.referenceSymbol({\n category: 'external',\n resource: 'valibot.v',\n });\n\n const expression = $(v.placeholder).attr(identifiers.schemas.unknown).call();\n return expression;\n};\n","import { deduplicateSchema } from '~/ir/schema';\nimport type { SchemaWithType } from '~/plugins';\nimport { toRef } from '~/plugins/shared/utils/refs';\nimport { $ } from '~/ts-dsl';\n\nimport { pipesToAst } from '../../shared/pipesToAst';\nimport type { Ast, IrSchemaToAstOptions } from '../../shared/types';\nimport { identifiers } from '../constants';\nimport { irSchemaToAst } from '../plugin';\nimport { unknownToAst } from './unknown';\n\nexport const arrayToAst = ({\n plugin,\n schema,\n state,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'array'>;\n}): Omit<Ast, 'typeName'> => {\n const result: Omit<Ast, 'typeName'> = {\n pipes: [],\n };\n\n const v = plugin.referenceSymbol({\n category: 'external',\n resource: 'valibot.v',\n });\n const functionName = $(v.placeholder).attr(identifiers.schemas.array);\n\n if (!schema.items) {\n const expression = functionName.call(\n unknownToAst({\n plugin,\n schema: {\n type: 'unknown',\n },\n state,\n }),\n );\n result.pipes.push(expression);\n } else {\n schema = deduplicateSchema({ schema });\n\n // at least one item is guaranteed\n const itemExpressions = schema.items!.map((item, index) => {\n const itemAst = irSchemaToAst({\n plugin,\n schema: item,\n state: {\n ...state,\n path: toRef([...state.path.value, 'items', index]),\n },\n });\n if (itemAst.hasLazyExpression) {\n result.hasLazyExpression = true;\n }\n return pipesToAst({ pipes: itemAst.pipes, plugin });\n });\n\n if (itemExpressions.length === 1) {\n const expression = functionName.call(...itemExpressions);\n result.pipes.push(expression);\n } else {\n if (schema.logicalOperator === 'and') {\n // TODO: parser - handle intersection\n // return tsc.typeArrayNode(\n // tsc.typeIntersectionNode({ types: itemExpressions }),\n // );\n }\n\n // TODO: parser - handle union\n // return tsc.typeArrayNode(tsc.typeUnionNode({ types: itemExpressions }));\n\n const expression = functionName.call(\n unknownToAst({\n plugin,\n schema: {\n type: 'unknown',\n },\n state,\n }),\n );\n result.pipes.push(expression);\n }\n }\n\n if (schema.minItems === schema.maxItems && schema.minItems !== undefined) {\n const expression = $(v.placeholder)\n .attr(identifiers.actions.length)\n .call($.fromValue(schema.minItems));\n result.pipes.push(expression);\n } else {\n if (schema.minItems !== undefined) {\n const expression = $(v.placeholder)\n .attr(identifiers.actions.minLength)\n .call($.fromValue(schema.minItems));\n result.pipes.push(expression);\n }\n\n if (schema.maxItems !== undefined) {\n const expression = $(v.placeholder)\n .attr(identifiers.actions.maxLength)\n .call($.fromValue(schema.maxItems));\n result.pipes.push(expression);\n }\n }\n\n return result as Omit<Ast, 'typeName'>;\n};\n","import type { SchemaWithType } from '~/plugins';\nimport { $ } from '~/ts-dsl';\n\nimport { pipesToAst } from '../../shared/pipesToAst';\nimport type { IrSchemaToAstOptions } from '../../shared/types';\nimport { identifiers } from '../constants';\n\nexport const booleanToAst = ({\n plugin,\n schema,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'boolean'>;\n}): ReturnType<typeof $.call | typeof $.expr> => {\n const pipes: Array<ReturnType<typeof $.call>> = [];\n\n const v = plugin.referenceSymbol({\n category: 'external',\n resource: 'valibot.v',\n });\n\n if (typeof schema.const === 'boolean') {\n pipes.push(\n $(v.placeholder)\n .attr(identifiers.schemas.literal)\n .call($.literal(schema.const)),\n );\n return pipesToAst({ pipes, plugin });\n }\n\n pipes.push($(v.placeholder).attr(identifiers.schemas.boolean).call());\n return pipesToAst({ pipes, plugin });\n};\n","import type { SchemaWithType } from '~/plugins';\nimport { $ } from '~/ts-dsl';\n\nimport type { IrSchemaToAstOptions } from '../../shared/types';\nimport { identifiers } from '../constants';\nimport { unknownToAst } from './unknown';\n\nexport const enumToAst = ({\n plugin,\n schema,\n state,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'enum'>;\n}): ReturnType<typeof $.call> => {\n const enumMembers: Array<ReturnType<typeof $.literal>> = [];\n\n let isNullable = false;\n\n for (const item of schema.items ?? []) {\n // Zod supports only string enums\n if (item.type === 'string' && typeof item.const === 'string') {\n enumMembers.push($.literal(item.const));\n } else if (item.type === 'null' || item.const === null) {\n isNullable = true;\n }\n }\n\n if (!enumMembers.length) {\n return unknownToAst({\n plugin,\n schema: {\n type: 'unknown',\n },\n state,\n });\n }\n\n const v = plugin.referenceSymbol({\n category: 'external',\n resource: 'valibot.v',\n });\n\n let resultExpression = $(v.placeholder)\n .attr(identifiers.schemas.picklist)\n .call($.array(...enumMembers));\n\n if (isNullable) {\n resultExpression = $(v.placeholder)\n .attr(identifiers.schemas.nullable)\n .call(resultExpression);\n }\n\n return resultExpression;\n};\n","import type { SchemaWithType } from '~/plugins';\nimport { $ } from '~/ts-dsl';\n\nimport type { IrSchemaToAstOptions } from '../../shared/types';\nimport { identifiers } from '../constants';\n\nexport const neverToAst = ({\n plugin,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'never'>;\n}) => {\n const v = plugin.referenceSymbol({\n category: 'external',\n resource: 'valibot.v',\n });\n const expression = $(v.placeholder).attr(identifiers.schemas.never).call();\n return expression;\n};\n","import type { SchemaWithType } from '~/plugins';\nimport { $ } from '~/ts-dsl';\n\nimport type { IrSchemaToAstOptions } from '../../shared/types';\nimport { identifiers } from '../constants';\n\nexport const nullToAst = ({\n plugin,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'null'>;\n}) => {\n const v = plugin.referenceSymbol({\n category: 'external',\n resource: 'valibot.v',\n });\n const expression = $(v.placeholder).attr(identifiers.schemas.null).call();\n return expression;\n};\n","import type { SchemaWithType } from '~/plugins';\nimport { $ } from '~/ts-dsl';\n\nimport {\n INTEGER_FORMATS,\n isIntegerFormat,\n needsBigIntForFormat,\n numberParameter,\n} from '../../shared/numbers';\nimport { pipesToAst } from '../../shared/pipesToAst';\nimport type { IrSchemaToAstOptions } from '../../shared/types';\nimport { identifiers } from '../constants';\n\nexport const numberToAst = ({\n plugin,\n schema,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'integer' | 'number'>;\n}) => {\n const format = schema.format;\n const isInteger = schema.type === 'integer';\n const isBigInt = needsBigIntForFormat(format);\n const formatInfo = isIntegerFormat(format) ? INTEGER_FORMATS[format] : null;\n\n const v = plugin.referenceSymbol({\n category: 'external',\n resource: 'valibot.v',\n });\n\n // Return early if const is defined since we can create a literal type directly without additional validation\n if (schema.const !== undefined && schema.const !== null) {\n const constValue = schema.const;\n let literalValue: ReturnType<typeof $.fromValue>;\n\n // Case 1: Number with no format -> generate literal with the number\n if (typeof constValue === 'number' && !format) {\n literalValue = $.literal(constValue);\n }\n // Case 2: Number with format -> check if format needs BigInt, generate appropriate literal\n else if (typeof constValue === 'number' && format) {\n if (isBigInt) {\n // Format requires BigInt, convert number to BigInt\n literalValue = $('BigInt').call($.literal(constValue));\n } else {\n // Regular format, use number as-is\n literalValue = $.literal(constValue);\n }\n }\n // Case 3: Format that allows string -> generate BigInt literal (for int64/uint64 formats)\n else if (typeof constValue === 'string' && isBigInt) {\n // Remove 'n' suffix if present in string\n const cleanString = constValue.endsWith('n')\n ? constValue.slice(0, -1)\n : constValue;\n literalValue = $('BigInt').call($.literal(cleanString));\n }\n // Case 4: Const is typeof bigint (literal) -> transform from literal to BigInt()\n else if (typeof constValue === 'bigint') {\n // Convert BigInt to string and remove 'n' suffix that toString() adds\n const bigintString = constValue.toString();\n const cleanString = bigintString.endsWith('n')\n ? bigintString.slice(0, -1)\n : bigintString;\n literalValue = $('BigInt').call($.literal(cleanString));\n }\n // Default case: use value as-is for other types\n else {\n literalValue = $.fromValue(constValue);\n }\n\n return $(v.placeholder)\n .attr(identifiers.schemas.literal)\n .call(literalValue);\n }\n\n const pipes: Array<ReturnType<typeof $.call>> = [];\n\n // For bigint formats (int64, uint64), create union of number, string, and bigint with transform\n if (isBigInt) {\n const unionExpression = $(v.placeholder)\n .attr(identifiers.schemas.union)\n .call(\n $.array(\n $(v.placeholder).attr(identifiers.schemas.number).call(),\n $(v.placeholder).attr(identifiers.schemas.string).call(),\n $(v.placeholder).attr(identifiers.schemas.bigInt).call(),\n ),\n );\n pipes.push(unionExpression);\n\n // Add transform to convert to BigInt\n const transformExpression = $(v.placeholder)\n .attr(identifiers.actions.transform)\n .call($.func().param('x').do($('BigInt').call('x').return()));\n pipes.push(transformExpression);\n } else {\n // For regular number formats, use number schema\n const expression = $(v.placeholder).attr(identifiers.schemas.number).call();\n pipes.push(expression);\n }\n\n // Add integer validation for integer types (except when using bigint union)\n if (!isBigInt && isInteger) {\n const expression = $(v.placeholder)\n .attr(identifiers.actions.integer)\n .call();\n pipes.push(expression);\n }\n\n // Add format-specific range validations\n if (formatInfo) {\n const minValue = formatInfo.min;\n const maxValue = formatInfo.max;\n const minErrorMessage = formatInfo.minError;\n const maxErrorMessage = formatInfo.maxError;\n\n // Add minimum value validation\n const minExpression = $(v.placeholder)\n .attr(identifiers.actions.minValue)\n .call(\n isBigInt ? $('BigInt').call($.literal(minValue)) : $.literal(minValue),\n $.literal(minErrorMessage),\n );\n pipes.push(minExpression);\n\n // Add maximum value validation\n const maxExpression = $(v.placeholder)\n .attr(identifiers.actions.maxValue)\n .call(\n isBigInt ? $('BigInt').call($.literal(maxValue)) : $.literal(maxValue),\n $.literal(maxErrorMessage),\n );\n pipes.push(maxExpression);\n }\n\n if (schema.exclusiveMinimum !== undefined) {\n const expression = $(v.placeholder)\n .attr(identifiers.actions.gtValue)\n .call(numberParameter({ isBigInt, value: schema.exclusiveMinimum }));\n pipes.push(expression);\n } else if (schema.minimum !== undefined) {\n const expression = $(v.placeholder)\n .attr(identifiers.actions.minValue)\n .call(numberParameter({ isBigInt, value: schema.minimum }));\n pipes.push(expression);\n }\n\n if (schema.exclusiveMaximum !== undefined) {\n const expression = $(v.placeholder)\n .attr(identifiers.actions.ltValue)\n .call(numberParameter({ isBigInt, value: schema.exclusiveMaximum }));\n pipes.push(expression);\n } else if (schema.maximum !== undefined) {\n const expression = $(v.placeholder)\n .attr(identifiers.actions.maxValue)\n .call(numberParameter({ isBigInt, value: schema.maximum }));\n pipes.push(expression);\n }\n\n return pipesToAst({ pipes, plugin });\n};\n","import type { SchemaWithType } from '~/plugins';\nimport { toRef } from '~/plugins/shared/utils/refs';\nimport { $ } from '~/ts-dsl';\n\nimport { pipesToAst } from '../../shared/pipesToAst';\nimport type { Ast, IrSchemaToAstOptions } from '../../shared/types';\nimport type { ObjectBaseResolverArgs } from '../../types';\nimport { identifiers } from '../constants';\nimport { irSchemaToAst } from '../plugin';\n\nfunction defaultObjectBaseResolver({\n additional,\n pipes,\n plugin,\n shape,\n}: ObjectBaseResolverArgs): number {\n const v = plugin.referenceSymbol({\n category: 'external',\n resource: 'valibot.v',\n });\n\n // Handle `additionalProperties: { type: 'never' }` → v.strictObject()\n if (additional === null) {\n return pipes.push(\n $(v.placeholder).attr(identifiers.schemas.strictObject).call(shape),\n );\n }\n\n // Handle additionalProperties as schema → v.record() or v.objectWithRest()\n if (additional) {\n if (shape.isEmpty) {\n return pipes.push(\n $(v.placeholder)\n .attr(identifiers.schemas.record)\n .call(\n $(v.placeholder).attr(identifiers.schemas.string).call(),\n additional,\n ),\n );\n }\n\n // If there are named properties, use v.objectWithRest() to validate both\n return pipes.push(\n $(v.placeholder)\n .attr(identifiers.schemas.objectWithRest)\n .call(shape, additional),\n );\n }\n\n // Default case → v.object()\n return pipes.push(\n $(v.placeholder).attr(identifiers.schemas.object).call(shape),\n );\n}\n\nexport const objectToAst = ({\n plugin,\n schema,\n state,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'object'>;\n}): Omit<Ast, 'typeName'> => {\n const result: Partial<Omit<Ast, 'typeName'>> = {};\n const pipes: Array<ReturnType<typeof $.call>> = [];\n\n // TODO: parser - handle constants\n\n const shape = $.object().pretty();\n const required = schema.required ?? [];\n\n for (const name in schema.properties) {\n const property = schema.properties[name]!;\n const isRequired = required.includes(name);\n\n const propertyAst = irSchemaToAst({\n optional: !isRequired,\n plugin,\n schema: property,\n state: {\n ...state,\n path: toRef([...state.path.value, 'properties', name]),\n },\n });\n if (propertyAst.hasLazyExpression) result.hasLazyExpression = true;\n\n shape.prop(name, pipesToAst({ pipes: propertyAst.pipes, plugin }));\n }\n\n let additional: ReturnType<typeof $.call | typeof $.expr> | null | undefined;\n if (schema.additionalProperties && schema.additionalProperties.type) {\n if (schema.additionalProperties.type === 'never') {\n additional = null;\n } else {\n const additionalAst = irSchemaToAst({\n plugin,\n schema: schema.additionalProperties,\n state: {\n ...state,\n path: toRef([...state.path.value, 'additionalProperties']),\n },\n });\n if (additionalAst.hasLazyExpression) result.hasLazyExpression = true;\n additional = pipesToAst({ pipes: additionalAst.pipes, plugin });\n }\n }\n\n const args: ObjectBaseResolverArgs = {\n $,\n additional,\n pipes,\n plugin,\n schema,\n shape,\n };\n const resolver = plugin.config['~resolvers']?.object?.base;\n if (!resolver?.(args)) defaultObjectBaseResolver(args);\n\n result.pipes = [pipesToAst({ pipes, plugin })];\n return result as Omit<Ast, 'typeName'>;\n};\n","import type { SchemaWithType } from '~/plugins';\nimport { $ } from '~/ts-dsl';\n\nimport { pipesToAst } from '../../shared/pipesToAst';\nimport type { IrSchemaToAstOptions } from '../../shared/types';\nimport type { FormatResolverArgs } from '../../types';\nimport { identifiers } from '../constants';\n\nconst defaultFormatResolver = ({\n pipes,\n plugin,\n schema,\n}: FormatResolverArgs): boolean | number => {\n const v = plugin.referenceSymbol({\n category: 'external',\n resource: 'valibot.v',\n });\n\n switch (schema.format) {\n case 'date':\n return pipes.push(\n $(v.placeholder).attr(identifiers.actions.isoDate).call(),\n );\n case 'date-time':\n return pipes.push(\n $(v.placeholder).attr(identifiers.actions.isoTimestamp).call(),\n );\n case 'email':\n return pipes.push(\n $(v.placeholder).attr(identifiers.actions.email).call(),\n );\n case 'ipv4':\n case 'ipv6':\n return pipes.push($(v.placeholder).attr(identifiers.actions.ip).call());\n case 'time':\n return pipes.push(\n $(v.placeholder).attr(identifiers.actions.isoTimeSecond).call(),\n );\n case 'uri':\n return pipes.push($(v.placeholder).attr(identifiers.actions.url).call());\n case 'uuid':\n return pipes.push($(v.placeholder).attr(identifiers.actions.uuid).call());\n }\n\n return true;\n};\n\nexport const stringToAst = ({\n plugin,\n schema,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'string'>;\n}): ReturnType<typeof $.call | typeof $.expr> => {\n const pipes: Array<ReturnType<typeof $.call>> = [];\n\n const v = plugin.referenceSymbol({\n category: 'external',\n resource: 'valibot.v',\n });\n\n if (typeof schema.const === 'string') {\n pipes.push(\n $(v.placeholder)\n .attr(identifiers.schemas.literal)\n .call($.literal(schema.const)),\n );\n return pipesToAst({ pipes, plugin });\n }\n\n pipes.push($(v.placeholder).attr(identifiers.schemas.string).call());\n\n if (schema.format) {\n const args: FormatResolverArgs = { $, pipes, plugin, schema };\n const resolver =\n plugin.config['~resolvers']?.string?.formats?.[schema.format];\n if (!resolver?.(args)) defaultFormatResolver(args);\n }\n\n if (schema.minLength === schema.maxLength && schema.minLength !== undefined) {\n pipes.push(\n $(v.placeholder)\n .attr(identifiers.actions.length)\n .call($.literal(schema.minLength)),\n );\n } else {\n if (schema.minLength !== undefined) {\n pipes.push(\n $(v.placeholder)\n .attr(identifiers.actions.minLength)\n .call($.literal(schema.minLength)),\n );\n }\n\n if (schema.maxLength !== undefined) {\n pipes.push(\n $(v.placeholder)\n .attr(identifiers.actions.maxLength)\n .call($.literal(schema.maxLength)),\n );\n }\n }\n\n if (schema.pattern) {\n pipes.push(\n $(v.placeholder)\n .attr(identifiers.actions.regex)\n .call($.regexp(schema.pattern)),\n );\n }\n\n return pipesToAst({ pipes, plugin });\n};\n","import type { SchemaWithType } from '~/plugins';\nimport { toRef } from '~/plugins/shared/utils/refs';\nimport { $ } from '~/ts-dsl';\n\nimport { pipesToAst } from '../../shared/pipesToAst';\nimport type { Ast, IrSchemaToAstOptions } from '../../shared/types';\nimport { identifiers } from '../constants';\nimport { irSchemaToAst } from '../plugin';\nimport { unknownToAst } from './unknown';\n\nexport const tupleToAst = ({\n plugin,\n schema,\n state,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'tuple'>;\n}): Omit<Ast, 'typeName'> => {\n const result: Partial<Omit<Ast, 'typeName'>> = {};\n\n const v = plugin.referenceSymbol({\n category: 'external',\n resource: 'valibot.v',\n });\n\n if (schema.const && Array.isArray(schema.const)) {\n const tupleElements = schema.const.map((value) =>\n $(v.placeholder)\n .attr(identifiers.schemas.literal)\n .call($.fromValue(value)),\n );\n result.pipes = [\n $(v.placeholder)\n .attr(identifiers.schemas.tuple)\n .call($.array(...tupleElements)),\n ];\n return result as Omit<Ast, 'typeName'>;\n }\n\n if (schema.items) {\n const tupleElements = schema.items.map((item, index) => {\n const schemaPipes = irSchemaToAst({\n plugin,\n schema: item,\n state: {\n ...state,\n path: toRef([...state.path.value, 'items', index]),\n },\n });\n if (schemaPipes.hasLazyExpression) {\n result.hasLazyExpression = true;\n }\n return pipesToAst({ pipes: schemaPipes.pipes, plugin });\n });\n result.pipes = [\n $(v.placeholder)\n .attr(identifiers.schemas.tuple)\n .call($.array(...tupleElements)),\n ];\n return result as Omit<Ast, 'typeName'>;\n }\n\n return {\n pipes: [\n unknownToAst({\n plugin,\n schema: {\n type: 'unknown',\n },\n state,\n }),\n ],\n };\n};\n","import type { SchemaWithType } from '~/plugins';\nimport { $ } from '~/ts-dsl';\n\nimport type { IrSchemaToAstOptions } from '../../shared/types';\nimport { identifiers } from '../constants';\n\nexport const undefinedToAst = ({\n plugin,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'undefined'>;\n}) => {\n const v = plugin.referenceSymbol({\n category: 'external',\n resource: 'valibot.v',\n });\n\n const expression = $(v.placeholder)\n .attr(identifiers.schemas.undefined)\n .call();\n return expression;\n};\n","import type { SchemaWithType } from '~/plugins';\nimport { $ } from '~/ts-dsl';\n\nimport type { IrSchemaToAstOptions } from '../../shared/types';\nimport { identifiers } from '../constants';\n\nexport const voidToAst = ({\n plugin,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'void'>;\n}) => {\n const v = plugin.referenceSymbol({\n category: 'external',\n resource: 'valibot.v',\n });\n\n const expression = $(v.placeholder).attr(identifiers.schemas.void).call();\n return expression;\n};\n","import type { SchemaWithType } from '~/plugins';\nimport type { $ } from '~/ts-dsl';\n\nimport { pipesToAst } from '../../shared/pipesToAst';\nimport type { IrSchemaToAstOptions } from '../../shared/types';\nimport { arrayToAst } from './array';\nimport { booleanToAst } from './boolean';\nimport { enumToAst } from './enum';\nimport { neverToAst } from './never';\nimport { nullToAst } from './null';\nimport { numberToAst } from './number';\nimport { objectToAst } from './object';\nimport { stringToAst } from './string';\nimport { tupleToAst } from './tuple';\nimport { undefinedToAst } from './undefined';\nimport { unknownToAst } from './unknown';\nimport { voidToAst } from './void';\n\nexport const irSchemaWithTypeToAst = ({\n schema,\n ...args\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType;\n}): {\n anyType?: string;\n expression: ReturnType<typeof $.call | typeof $.expr>;\n} => {\n switch (schema.type) {\n case 'array':\n return {\n expression: pipesToAst({\n pipes: arrayToAst({\n ...args,\n schema: schema as SchemaWithType<'array'>,\n }).pipes,\n plugin: args.plugin,\n }),\n };\n case 'boolean':\n return {\n expression: booleanToAst({\n ...args,\n schema: schema as SchemaWithType<'boolean'>,\n }),\n };\n case 'enum':\n return {\n expression: enumToAst({\n ...args,\n schema: schema as SchemaWithType<'enum'>,\n }),\n };\n case 'integer':\n case 'number':\n return {\n expression: numberToAst({\n ...args,\n schema: schema as SchemaWithType<'integer' | 'number'>,\n }),\n };\n case 'never':\n return {\n expression: neverToAst({\n ...args,\n schema: schema as SchemaWithType<'never'>,\n }),\n };\n case 'null':\n return {\n expression: nullToAst({\n ...args,\n schema: schema as SchemaWithType<'null'>,\n }),\n };\n case 'object':\n return {\n expression: pipesToAst({\n pipes: objectToAst({\n ...args,\n schema: schema as SchemaWithType<'object'>,\n }).pipes,\n plugin: args.plugin,\n }),\n };\n case 'string':\n // For string schemas with int64/uint64 formats, use number handler to generate union with transform\n if (schema.format === 'int64' || schema.format === 'uint64') {\n return {\n expression: numberToAst({\n ...args,\n schema: schema as SchemaWithType<'integer' | 'number'>,\n }),\n };\n }\n return {\n expression: stringToAst({\n ...args,\n schema: schema as SchemaWithType<'string'>,\n }),\n };\n case 'tuple':\n return {\n expression: pipesToAst({\n pipes: tupleToAst({\n ...args,\n schema: schema as SchemaWithType<'tuple'>,\n }).pipes,\n plugin: args.plugin,\n }),\n };\n case 'undefined':\n return {\n expression: undefinedToAst({\n ...args,\n schema: schema as SchemaWithType<'undefined'>,\n }),\n };\n case 'unknown':\n return {\n expression: unknownToAst({\n ...args,\n schema: schema as SchemaWithType<'unknown'>,\n }),\n };\n case 'void':\n return {\n expression: voidToAst({\n ...args,\n schema: schema as SchemaWithType<'void'>,\n }),\n };\n }\n};\n","import type { SymbolMeta } from '@hey-api/codegen-core';\n\nimport { deduplicateSchema } from '~/ir/schema';\nimport type { IR } from '~/ir/types';\nimport { buildName } from '~/openApi/shared/utils/name';\nimport type { SchemaWithType } from '~/plugins';\nimport { toRef, toRefs } from '~/plugins/shared/utils/refs';\nimport { $ } from '~/ts-dsl';\nimport { pathToJsonPointer, refToName } from '~/utils/ref';\n\nimport { exportAst } from '../shared/export';\nimport { numberParameter } from '../shared/numbers';\nimport { irOperationToAst } from '../shared/operation';\nimport { pipesToAst } from '../shared/pipesToAst';\nimport type { Ast, IrSchemaToAstOptions, PluginState } from '../shared/types';\nimport { irWebhookToAst } from '../shared/webhook';\nimport type { ValibotPlugin } from '../types';\nimport { identifiers } from './constants';\nimport { irSchemaWithTypeToAst } from './toAst';\n\nexport const irSchemaToAst = ({\n optional,\n plugin,\n schema,\n state,\n}: IrSchemaToAstOptions & {\n /**\n * Accept `optional` to handle optional object properties. We can't handle\n * this inside the object function because `.optional()` must come before\n * `.default()` which is handled in this function.\n */\n optional?: boolean;\n schema: IR.SchemaObject;\n}): Ast => {\n const ast: Ast = {\n pipes: [],\n };\n\n const v = plugin.referenceSymbol({\n category: 'external',\n resource: 'valibot.v',\n });\n\n if (schema.$ref) {\n const query: SymbolMeta = {\n category: 'schema',\n resource: 'definition',\n resourceId: schema.$ref,\n tool: 'valibot',\n };\n const refSymbol = plugin.referenceSymbol(query);\n if (plugin.isSymbolRegistered(query)) {\n const ref = $(refSymbol.placeholder);\n ast.pipes.push(ref);\n } else {\n const lazyExpression = $(v.placeholder)\n .attr(identifiers.schemas.lazy)\n .call($.func().do($(refSymbol.placeholder).return()));\n ast.pipes.push(lazyExpression);\n state.hasLazyExpression.value = true;\n }\n } else if (schema.type) {\n const typeAst = irSchemaWithTypeToAst({\n plugin,\n schema: schema as SchemaWithType,\n state,\n });\n ast.typeName = typeAst.anyType;\n ast.pipes.push(typeAst.expression);\n\n if (plugin.config.metadata && schema.description) {\n const expression = $(v.placeholder)\n .attr(identifiers.actions.metadata)\n .call($.object().prop('description', $.literal(schema.description)));\n ast.pipes.push(expression);\n }\n } else if (schema.items) {\n schema = deduplicateSchema({ schema });\n\n if (schema.items) {\n const itemsAst = schema.items.map((item, index) => {\n const itemAst = irSchemaToAst({\n plugin,\n schema: item,\n state: {\n ...state,\n path: toRef([...state.path.value, 'items', index]),\n },\n });\n return pipesToAst({ pipes: itemAst.pipes, plugin });\n });\n\n if (schema.logicalOperator === 'and') {\n const intersectExpression = $(v.placeholder)\n .attr(identifiers.schemas.intersect)\n .call($.array(...itemsAst));\n ast.pipes.push(intersectExpression);\n } else {\n const unionExpression = $(v.placeholder)\n .attr(identifiers.schemas.union)\n .call($.array(...itemsAst));\n ast.pipes.push(unionExpression);\n }\n } else {\n const schemaPipes = irSchemaToAst({ plugin, schema, state });\n ast.pipes.push(...schemaPipes.pipes);\n }\n } else {\n // catch-all fallback for failed schemas\n const typeAst = irSchemaWithTypeToAst({\n plugin,\n schema: {\n type: 'unknown',\n },\n state,\n });\n ast.typeName = typeAst.anyType;\n ast.pipes.push(typeAst.expression);\n }\n\n if (ast.pipes.length) {\n if (schema.accessScope === 'read') {\n const readonlyExpression = $(v.placeholder)\n .attr(identifiers.actions.readonly)\n .call();\n ast.pipes.push(readonlyExpression);\n }\n\n let callParameter: ReturnType<typeof $.fromValue> | undefined;\n\n if (schema.default !== undefined) {\n const isBigInt = schema.type === 'integer' && schema.format === 'int64';\n callParameter = numberParameter({ isBigInt, value: schema.default });\n ast.pipes = [\n $(v.placeholder)\n .attr(identifiers.schemas.optional)\n .call(pipesToAst({ pipes: ast.pipes, plugin }), callParameter),\n ];\n }\n\n if (optional && !callParameter) {\n ast.pipes = [\n $(v.placeholder)\n .attr(identifiers.schemas.optional)\n .call(pipesToAst({ pipes: ast.pipes, plugin })),\n ];\n }\n }\n\n return ast as Ast;\n};\n\nconst handleComponent = ({\n plugin,\n schema,\n state,\n}: IrSchemaToAstOptions & {\n schema: IR.SchemaObject;\n}): void => {\n const $ref = pathToJsonPointer(state.path.value);\n const ast = irSchemaToAst({ plugin, schema, state });\n const baseName = refToName($ref);\n const symbol = plugin.registerSymbol({\n exported: true,\n meta: {\n category: 'schema',\n path: state.path.value,\n resource: 'definition',\n resourceId: $ref,\n tags: state.tags?.value,\n tool: 'valibot',\n },\n name: buildName({\n config: plugin.config.definitions,\n name: baseName,\n }),\n });\n exportAst({\n ast,\n plugin,\n schema,\n state,\n symbol,\n });\n};\n\nexport const handlerV1: ValibotPlugin['Handler'] = ({ plugin }) => {\n plugin.registerSymbol({\n external: 'valibot',\n importKind: 'namespace',\n meta: {\n category: 'external',\n resource: 'valibot.v',\n },\n name: 'v',\n });\n\n plugin.forEach(\n 'operation',\n 'parameter',\n 'requestBody',\n 'schema',\n 'webhook',\n (event) => {\n const state = toRefs<PluginState>({\n hasLazyExpression: false,\n path: event._path,\n tags: event.tags,\n });\n switch (event.type) {\n case 'operation':\n irOperationToAst({\n getAst: (schema, path) => {\n const state = toRefs<PluginState>({\n hasLazyExpression: false,\n path,\n tags: event.tags,\n });\n return irSchemaToAst({ plugin, schema, state });\n },\n operation: event.operation,\n plugin,\n state,\n });\n break;\n case 'parameter':\n handleComponent({\n plugin,\n schema: event.parameter.schema,\n state,\n });\n break;\n case 'requestBody':\n handleComponent({\n plugin,\n schema: event.requestBody.schema,\n state,\n });\n break;\n case 'schema':\n handleComponent({\n plugin,\n schema: event.schema,\n state,\n });\n break;\n case 'webhook':\n irWebhookToAst({\n getAst: (schema, path) => {\n const state = toRefs<PluginState>({\n hasLazyExpression: false,\n path,\n tags: event.tags,\n });\n return irSchemaToAst({ plugin, schema, state });\n },\n operation: event.operation,\n plugin,\n state,\n });\n break;\n }\n },\n );\n};\n","import type { ValibotPlugin } from './types';\nimport { handlerV1 } from './v1/plugin';\n\nexport const handler: ValibotPlugin['Handler'] = (args) => handlerV1(args);\n","import { definePluginConfig } from '~/plugins/shared/utils/config';\n\nimport { Api } from './api';\nimport { handler } from './plugin';\nimport type { ValibotPlugin } from './types';\n\nexport const defaultConfig: ValibotPlugin['Config'] = {\n api: new Api(),\n config: {\n case: 'camelCase',\n comments: true,\n exportFromIndex: false,\n metadata: false,\n },\n handler,\n name: 'valibot',\n resolveConfig: (plugin, context) => {\n plugin.config.definitions = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'camelCase',\n enabled: true,\n name: 'v{{name}}',\n },\n mappers: {\n boolean: (enabled) => ({ enabled }),\n function: (name) => ({ name }),\n string: (name) => ({ name }),\n },\n value: plugin.config.definitions,\n });\n\n plugin.config.requests = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'camelCase',\n enabled: true,\n name: 'v{{name}}Data',\n },\n mappers: {\n boolean: (enabled) => ({ enabled }),\n function: (name) => ({ name }),\n string: (name) => ({ name }),\n },\n value: plugin.config.requests,\n });\n\n plugin.config.responses = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'camelCase',\n enabled: true,\n name: 'v{{name}}Response',\n },\n mappers: {\n boolean: (enabled) => ({ enabled }),\n function: (name) => ({ name }),\n string: (name) => ({ name }),\n },\n value: plugin.config.responses,\n });\n\n plugin.config.webhooks = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'camelCase',\n enabled: true,\n name: 'v{{name}}WebhookRequest',\n },\n mappers: {\n boolean: (enabled) => ({ enabled }),\n function: (name) => ({ name }),\n string: (name) => ({ name }),\n },\n value: plugin.config.webhooks,\n });\n },\n tags: ['validator'],\n};\n\n/**\n * Type helper for Valibot plugin, returns {@link Plugin.Config} object\n */\nexport const defineConfig = definePluginConfig(defaultConfig);\n","// TODO: this is inaccurate, it combines identifiers for all supported versions\nexport const identifiers = {\n ZodMiniOptional: 'ZodMiniOptional',\n ZodOptional: 'ZodOptional',\n _default: '_default',\n and: 'and',\n array: 'array',\n bigint: 'bigint',\n boolean: 'boolean',\n check: 'check',\n coerce: 'coerce',\n date: 'date',\n datetime: 'datetime',\n default: 'default',\n describe: 'describe',\n email: 'email',\n enum: 'enum',\n globalRegistry: 'globalRegistry',\n gt: 'gt',\n gte: 'gte',\n infer: 'infer',\n int: 'int',\n intersection: 'intersection',\n ip: 'ip',\n ipv4: 'ipv4',\n ipv6: 'ipv6',\n iso: 'iso',\n lazy: 'lazy',\n length: 'length',\n literal: 'literal',\n lt: 'lt',\n lte: 'lte',\n max: 'max',\n maxLength: 'maxLength',\n min: 'min',\n minLength: 'minLength',\n never: 'never',\n null: 'null',\n nullable: 'nullable',\n number: 'number',\n object: 'object',\n optional: 'optional',\n parseAsync: 'parseAsync',\n readonly: 'readonly',\n record: 'record',\n regex: 'regex',\n register: 'register',\n string: 'string',\n time: 'time',\n tuple: 'tuple',\n undefined: 'undefined',\n union: 'union',\n unknown: 'unknown',\n url: 'url',\n uuid: 'uuid',\n void: 'void',\n};\n","import { $ } from '~/ts-dsl';\n\nimport { identifiers } from '../constants';\nimport type { ValidatorArgs } from '../shared/types';\nimport type { ValidatorResolverArgs } from '../types';\n\nconst defaultValidatorResolver = ({\n schema,\n}: ValidatorResolverArgs): ReturnType<typeof $.return> =>\n $(schema.placeholder)\n .attr(identifiers.parseAsync)\n .call('data')\n .await()\n .return();\n\nexport const createRequestValidatorMini = ({\n operation,\n plugin,\n}: ValidatorArgs): ReturnType<typeof $.func> | undefined => {\n const symbol = plugin.getSymbol({\n category: 'schema',\n resource: 'operation',\n resourceId: operation.id,\n role: 'data',\n tool: 'zod',\n });\n if (!symbol) return;\n\n const args: ValidatorResolverArgs = {\n $,\n chain: undefined,\n operation,\n plugin,\n schema: symbol,\n };\n const validator = plugin.config['~resolvers']?.validator;\n const resolver =\n typeof validator === 'function' ? validator : validator?.request;\n const candidates = [resolver, defaultValidatorResolver];\n for (const candidate of candidates) {\n const statements = candidate?.(args);\n if (statements === null) return;\n if (statements !== undefined) {\n return $.func()\n .async()\n .param('data')\n .do(...(statements instanceof Array ? statements : [statements]));\n }\n }\n return;\n};\n\nexport const createResponseValidatorMini = ({\n operation,\n plugin,\n}: ValidatorArgs): ReturnType<typeof $.func> | undefined => {\n const symbol = plugin.getSymbol({\n category: 'schema',\n resource: 'operation',\n resourceId: operation.id,\n role: 'responses',\n tool: 'zod',\n });\n if (!symbol) return;\n\n const args: ValidatorResolverArgs = {\n $,\n chain: undefined,\n operation,\n plugin,\n schema: symbol,\n };\n const validator = plugin.config['~resolvers']?.validator;\n const resolver =\n typeof validator === 'function' ? validator : validator?.response;\n const candidates = [resolver, defaultValidatorResolver];\n for (const candidate of candidates) {\n const statements = candidate?.(args);\n if (statements === null) return;\n if (statements !== undefined) {\n return $.func()\n .async()\n .param('data')\n .do(...(statements instanceof Array ? statements : [statements]));\n }\n }\n return;\n};\n","import { $ } from '~/ts-dsl';\n\nimport { identifiers } from '../constants';\nimport type { ValidatorArgs } from '../shared/types';\nimport type { ValidatorResolverArgs } from '../types';\n\nconst defaultValidatorResolver = ({\n schema,\n}: ValidatorResolverArgs): ReturnType<typeof $.return> =>\n $(schema.placeholder)\n .attr(identifiers.parseAsync)\n .call('data')\n .await()\n .return();\n\nexport const createRequestValidatorV3 = ({\n operation,\n plugin,\n}: ValidatorArgs): ReturnType<typeof $.func> | undefined => {\n const symbol = plugin.getSymbol({\n category: 'schema',\n resource: 'operation',\n resourceId: operation.id,\n role: 'data',\n tool: 'zod',\n });\n if (!symbol) return;\n\n const args: ValidatorResolverArgs = {\n $,\n chain: undefined,\n operation,\n plugin,\n schema: symbol,\n };\n const validator = plugin.config['~resolvers']?.validator;\n const resolver =\n typeof validator === 'function' ? validator : validator?.request;\n const candidates = [resolver, defaultValidatorResolver];\n for (const candidate of candidates) {\n const statements = candidate?.(args);\n if (statements === null) return;\n if (statements !== undefined) {\n return $.func()\n .async()\n .param('data')\n .do(...(statements instanceof Array ? statements : [statements]));\n }\n }\n return;\n};\n\nexport const createResponseValidatorV3 = ({\n operation,\n plugin,\n}: ValidatorArgs): ReturnType<typeof $.func> | undefined => {\n const symbol = plugin.getSymbol({\n category: 'schema',\n resource: 'operation',\n resourceId: operation.id,\n role: 'responses',\n tool: 'zod',\n });\n if (!symbol) return;\n\n const args: ValidatorResolverArgs = {\n $,\n chain: undefined,\n operation,\n plugin,\n schema: symbol,\n };\n const validator = plugin.config['~resolvers']?.validator;\n const resolver =\n typeof validator === 'function' ? validator : validator?.response;\n const candidates = [resolver, defaultValidatorResolver];\n for (const candidate of candidates) {\n const statements = candidate?.(args);\n if (statements === null) return;\n if (statements !== undefined) {\n return $.func()\n .async()\n .param('data')\n .do(...(statements instanceof Array ? statements : [statements]));\n }\n }\n return;\n};\n","import { $ } from '~/ts-dsl';\n\nimport { identifiers } from '../constants';\nimport type { ValidatorArgs } from '../shared/types';\nimport type { ValidatorResolverArgs } from '../types';\n\nconst defaultValidatorResolver = ({\n schema,\n}: ValidatorResolverArgs): ReturnType<typeof $.return> =>\n $(schema.placeholder)\n .attr(identifiers.parseAsync)\n .call('data')\n .await()\n .return();\n\nexport const createRequestValidatorV4 = ({\n operation,\n plugin,\n}: ValidatorArgs): ReturnType<typeof $.func> | undefined => {\n const symbol = plugin.getSymbol({\n category: 'schema',\n resource: 'operation',\n resourceId: operation.id,\n role: 'data',\n tool: 'zod',\n });\n if (!symbol) return;\n\n const args: ValidatorResolverArgs = {\n $,\n chain: undefined,\n operation,\n plugin,\n schema: symbol,\n };\n const validator = plugin.config['~resolvers']?.validator;\n const resolver =\n typeof validator === 'function' ? validator : validator?.request;\n const candidates = [resolver, defaultValidatorResolver];\n for (const candidate of candidates) {\n const statements = candidate?.(args);\n if (statements === null) return;\n if (statements !== undefined) {\n return $.func()\n .async()\n .param('data')\n .do(...(statements instanceof Array ? statements : [statements]));\n }\n }\n return;\n};\n\nexport const createResponseValidatorV4 = ({\n operation,\n plugin,\n}: ValidatorArgs): ReturnType<typeof $.func> | undefined => {\n const symbol = plugin.getSymbol({\n category: 'schema',\n resource: 'operation',\n resourceId: operation.id,\n role: 'responses',\n tool: 'zod',\n });\n if (!symbol) return;\n\n const args: ValidatorResolverArgs = {\n $,\n chain: undefined,\n operation,\n plugin,\n schema: symbol,\n };\n const validator = plugin.config['~resolvers']?.validator;\n const resolver =\n typeof validator === 'function' ? validator : validator?.response;\n const candidates = [resolver, defaultValidatorResolver];\n for (const candidate of candidates) {\n const statements = candidate?.(args);\n if (statements === null) return;\n if (statements !== undefined) {\n return $.func()\n .async()\n .param('data')\n .do(...(statements instanceof Array ? statements : [statements]));\n }\n }\n return;\n};\n","import type { $ } from '~/ts-dsl';\n\nimport {\n createRequestValidatorMini,\n createResponseValidatorMini,\n} from './mini/api';\nimport type { ValidatorArgs } from './shared/types';\nimport { createRequestValidatorV3, createResponseValidatorV3 } from './v3/api';\nimport { createRequestValidatorV4, createResponseValidatorV4 } from './v4/api';\n\nexport type IApi = {\n createRequestValidator: (\n args: ValidatorArgs,\n ) => ReturnType<typeof $.func> | undefined;\n createResponseValidator: (\n args: ValidatorArgs,\n ) => ReturnType<typeof $.func> | undefined;\n};\n\nexport class Api implements IApi {\n createRequestValidator(\n args: ValidatorArgs,\n ): ReturnType<typeof $.func> | undefined {\n const { plugin } = args;\n switch (plugin.config.compatibilityVersion) {\n case 3:\n return createRequestValidatorV3(args);\n case 'mini':\n return createRequestValidatorMini(args);\n case 4:\n default:\n return createRequestValidatorV4(args);\n }\n }\n\n createResponseValidator(\n args: ValidatorArgs,\n ): ReturnType<typeof $.func> | undefined {\n const { plugin } = args;\n switch (plugin.config.compatibilityVersion) {\n case 3:\n return createResponseValidatorV3(args);\n case 'mini':\n return createResponseValidatorMini(args);\n case 4:\n default:\n return createResponseValidatorV4(args);\n }\n }\n}\n","import type { Symbol } from '@hey-api/codegen-core';\n\nimport type { IR } from '~/ir/types';\nimport { createSchemaComment } from '~/plugins/shared/utils/schema';\nimport { $ } from '~/ts-dsl';\n\nimport { identifiers } from '../constants';\nimport type { ZodPlugin } from '../types';\nimport type { Ast } from './types';\n\nexport const exportAst = ({\n ast,\n plugin,\n schema,\n symbol,\n typeInferSymbol,\n}: {\n ast: Ast;\n plugin: ZodPlugin['Instance'];\n schema: IR.SchemaObject;\n symbol: Symbol;\n typeInferSymbol: Symbol | undefined;\n}): void => {\n const z = plugin.referenceSymbol({\n category: 'external',\n resource: 'zod.z',\n });\n\n const statement = $.const(symbol.placeholder)\n .export(symbol.exported)\n .$if(plugin.config.comments && createSchemaComment(schema), (c, v) =>\n c.doc(v),\n )\n .$if(ast.typeName, (c, v) => c.type($.type(z.placeholder).attr(v)))\n .assign(ast.expression);\n plugin.setSymbolValue(symbol, statement);\n\n if (typeInferSymbol) {\n const inferType = $.type\n .alias(typeInferSymbol.placeholder)\n .export(typeInferSymbol.exported)\n .type(\n $.type(z.placeholder)\n .attr(identifiers.infer)\n .generic($(symbol.placeholder).typeofType()),\n );\n plugin.setSymbolValue(typeInferSymbol, inferType);\n }\n};\n","import type { ZodPlugin } from '../types';\n\nexport const getZodModule = ({\n plugin,\n}: {\n plugin: ZodPlugin['Instance'];\n}): string => {\n const version = plugin.package.getVersion('zod');\n\n if (version) {\n if (plugin.package.satisfies(version, '<4.0.0')) {\n switch (plugin.config.compatibilityVersion) {\n case 3:\n default:\n return 'zod';\n case 4:\n return 'zod/v4';\n case 'mini':\n return 'zod/v4-mini';\n }\n }\n }\n\n switch (plugin.config.compatibilityVersion) {\n case 3:\n return 'zod/v3';\n case 4:\n default:\n return 'zod';\n case 'mini':\n return 'zod/mini';\n }\n};\n","import { $ } from '~/ts-dsl';\n\nexport const numberParameter = ({\n isBigInt,\n value,\n}: {\n isBigInt: boolean;\n value: unknown;\n}): ReturnType<typeof $.call | typeof $.fromValue> => {\n const expr = $.fromValue(value);\n\n if (\n isBigInt &&\n (typeof value === 'bigint' ||\n typeof value === 'number' ||\n typeof value === 'string' ||\n typeof value === 'boolean')\n ) {\n return $('BigInt').call(expr);\n }\n\n return expr;\n};\n","import { operationResponsesMap } from '~/ir/operation';\nimport type { IR } from '~/ir/types';\nimport { buildName } from '~/openApi/shared/utils/name';\n\nimport { exportAst } from './export';\nimport type { Ast, IrSchemaToAstOptions } from './types';\n\nexport const irOperationToAst = ({\n getAst,\n operation,\n plugin,\n state,\n}: IrSchemaToAstOptions & {\n getAst: (\n schema: IR.SchemaObject,\n path: ReadonlyArray<string | number>,\n ) => Ast;\n operation: IR.OperationObject;\n}): void => {\n if (plugin.config.requests.enabled) {\n const requiredProperties = new Set<string>();\n\n const schemaData: IR.SchemaObject = {\n properties: {\n body: {\n type: 'never',\n },\n path: {\n type: 'never',\n },\n query: {\n type: 'never',\n },\n },\n type: 'object',\n };\n\n if (operation.parameters) {\n // TODO: add support for cookies\n\n if (operation.parameters.header) {\n const properties: Record<string, IR.SchemaObject> = {};\n const required: Array<string> = [];\n\n for (const key in operation.parameters.header) {\n const parameter = operation.parameters.header[key]!;\n properties[parameter.name] = parameter.schema;\n if (parameter.required) {\n required.push(parameter.name);\n requiredProperties.add('headers');\n }\n }\n\n if (Object.keys(properties).length) {\n schemaData.properties!.headers = {\n properties,\n required,\n type: 'object',\n };\n }\n }\n\n if (operation.parameters.path) {\n const properties: Record<string, IR.SchemaObject> = {};\n const required: Array<string> = [];\n\n for (const key in operation.parameters.path) {\n const parameter = operation.parameters.path[key]!;\n properties[parameter.name] = parameter.schema;\n if (parameter.required) {\n required.push(parameter.name);\n requiredProperties.add('path');\n }\n }\n\n if (Object.keys(properties).length) {\n schemaData.properties!.path = {\n properties,\n required,\n type: 'object',\n };\n }\n }\n\n if (operation.parameters.query) {\n const properties: Record<string, IR.SchemaObject> = {};\n const required: Array<string> = [];\n\n for (const key in operation.parameters.query) {\n const parameter = operation.parameters.query[key]!;\n properties[parameter.name] = parameter.schema;\n if (parameter.required) {\n required.push(parameter.name);\n requiredProperties.add('query');\n }\n }\n\n if (Object.keys(properties).length) {\n schemaData.properties!.query = {\n properties,\n required,\n type: 'object',\n };\n }\n }\n }\n\n if (operation.body) {\n schemaData.properties!.body = operation.body.schema;\n\n if (operation.body.required) {\n requiredProperties.add('body');\n }\n }\n\n schemaData.required = [...requiredProperties];\n\n const ast = getAst(schemaData, state.path.value);\n const symbol = plugin.registerSymbol({\n exported: true,\n meta: {\n category: 'schema',\n path: state.path.value,\n resource: 'operation',\n resourceId: operation.id,\n role: 'data',\n tags: state.tags?.value,\n tool: 'zod',\n },\n name: buildName({\n config: plugin.config.requests,\n name: operation.id,\n }),\n });\n const typeInferSymbol = plugin.config.requests.types.infer.enabled\n ? plugin.registerSymbol({\n exported: true,\n kind: 'type',\n meta: {\n category: 'type',\n path: state.path.value,\n resource: 'operation',\n resourceId: operation.id,\n role: 'data',\n tags: state.tags?.value,\n tool: 'zod',\n variant: 'infer',\n },\n name: buildName({\n config: plugin.config.requests.types.infer,\n name: operation.id,\n }),\n })\n : undefined;\n exportAst({\n ast,\n plugin,\n schema: schemaData,\n symbol,\n typeInferSymbol,\n });\n }\n\n if (plugin.config.responses.enabled) {\n if (operation.responses) {\n const { response } = operationResponsesMap(operation);\n\n if (response) {\n const path = [...state.path.value, 'responses'];\n const ast = getAst(response, path);\n const symbol = plugin.registerSymbol({\n exported: true,\n meta: {\n category: 'schema',\n path,\n resource: 'operation',\n resourceId: operation.id,\n role: 'responses',\n tags: state.tags?.value,\n tool: 'zod',\n },\n name: buildName({\n config: plugin.config.responses,\n name: operation.id,\n }),\n });\n const typeInferSymbol = plugin.config.responses.types.infer.enabled\n ? plugin.registerSymbol({\n exported: true,\n kind: 'type',\n meta: {\n category: 'type',\n path,\n resource: 'operation',\n resourceId: operation.id,\n role: 'responses',\n tags: state.tags?.value,\n tool: 'zod',\n variant: 'infer',\n },\n name: buildName({\n config: plugin.config.responses.types.infer,\n name: operation.id,\n }),\n })\n : undefined;\n exportAst({\n ast,\n plugin,\n schema: response,\n symbol,\n typeInferSymbol,\n });\n }\n }\n }\n};\n","import type { IR } from '~/ir/types';\nimport { buildName } from '~/openApi/shared/utils/name';\n\nimport { exportAst } from './export';\nimport type { Ast, IrSchemaToAstOptions } from './types';\n\nexport const irWebhookToAst = ({\n getAst,\n operation,\n plugin,\n state,\n}: IrSchemaToAstOptions & {\n getAst: (\n schema: IR.SchemaObject,\n path: ReadonlyArray<string | number>,\n ) => Ast;\n operation: IR.OperationObject;\n}) => {\n if (plugin.config.webhooks.enabled) {\n const requiredProperties = new Set<string>();\n\n const schemaData: IR.SchemaObject = {\n properties: {\n body: {\n type: 'never',\n },\n path: {\n type: 'never',\n },\n query: {\n type: 'never',\n },\n },\n type: 'object',\n };\n\n if (operation.parameters) {\n // TODO: add support for cookies\n\n if (operation.parameters.header) {\n const properties: Record<string, IR.SchemaObject> = {};\n const required: Array<string> = [];\n\n for (const key in operation.parameters.header) {\n const parameter = operation.parameters.header[key]!;\n properties[parameter.name] = parameter.schema;\n if (parameter.required) {\n required.push(parameter.name);\n requiredProperties.add('headers');\n }\n }\n\n if (Object.keys(properties).length) {\n schemaData.properties!.headers = {\n properties,\n required,\n type: 'object',\n };\n }\n }\n\n if (operation.parameters.path) {\n const properties: Record<string, IR.SchemaObject> = {};\n const required: Array<string> = [];\n\n for (const key in operation.parameters.path) {\n const parameter = operation.parameters.path[key]!;\n properties[parameter.name] = parameter.schema;\n if (parameter.required) {\n required.push(parameter.name);\n requiredProperties.add('path');\n }\n }\n\n if (Object.keys(properties).length) {\n schemaData.properties!.path = {\n properties,\n required,\n type: 'object',\n };\n }\n }\n\n if (operation.parameters.query) {\n const properties: Record<string, IR.SchemaObject> = {};\n const required: Array<string> = [];\n\n for (const key in operation.parameters.query) {\n const parameter = operation.parameters.query[key]!;\n properties[parameter.name] = parameter.schema;\n if (parameter.required) {\n required.push(parameter.name);\n requiredProperties.add('query');\n }\n }\n\n if (Object.keys(properties).length) {\n schemaData.properties!.query = {\n properties,\n required,\n type: 'object',\n };\n }\n }\n }\n\n if (operation.body) {\n schemaData.properties!.body = operation.body.schema;\n\n if (operation.body.required) {\n requiredProperties.add('body');\n }\n }\n\n schemaData.required = [...requiredProperties];\n\n const ast = getAst(schemaData, state.path.value);\n const symbol = plugin.registerSymbol({\n exported: true,\n meta: {\n category: 'schema',\n path: state.path.value,\n resource: 'webhook',\n resourceId: operation.id,\n role: 'data',\n tags: state.tags?.value,\n tool: 'zod',\n },\n name: buildName({\n config: plugin.config.webhooks,\n name: operation.id,\n }),\n });\n const typeInferSymbol = plugin.config.webhooks.types.infer.enabled\n ? plugin.registerSymbol({\n exported: true,\n kind: 'type',\n meta: {\n category: 'type',\n path: state.path.value,\n resource: 'webhook',\n resourceId: operation.id,\n role: 'data',\n tags: state.tags?.value,\n tool: 'zod',\n variant: 'infer',\n },\n name: buildName({\n config: plugin.config.webhooks.types.infer,\n name: operation.id,\n }),\n })\n : undefined;\n exportAst({\n ast,\n plugin,\n schema: schemaData,\n symbol,\n typeInferSymbol,\n });\n }\n};\n","import type { SchemaWithType } from '~/plugins';\nimport { $ } from '~/ts-dsl';\n\nimport { identifiers } from '../../constants';\nimport type { Ast, IrSchemaToAstOptions } from '../../shared/types';\n\nexport const unknownToAst = ({\n plugin,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'unknown'>;\n}): Omit<Ast, 'typeName'> => {\n const z = plugin.referenceSymbol({\n category: 'external',\n resource: 'zod.z',\n });\n const result: Partial<Omit<Ast, 'typeName'>> = {};\n result.expression = $(z.placeholder).attr(identifiers.unknown).call();\n return result as Omit<Ast, 'typeName'>;\n};\n","import { deduplicateSchema } from '~/ir/schema';\nimport type { SchemaWithType } from '~/plugins';\nimport { toRef } from '~/plugins/shared/utils/refs';\nimport { $ } from '~/ts-dsl';\n\nimport { identifiers } from '../../constants';\nimport type { Ast, IrSchemaToAstOptions } from '../../shared/types';\nimport { irSchemaToAst } from '../plugin';\nimport { unknownToAst } from './unknown';\n\nexport const arrayToAst = ({\n plugin,\n schema,\n state,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'array'>;\n}): Omit<Ast, 'typeName'> => {\n const z = plugin.referenceSymbol({\n category: 'external',\n resource: 'zod.z',\n });\n\n const result: Partial<Omit<Ast, 'typeName'>> = {};\n\n const functionName = $(z.placeholder).attr(identifiers.array);\n\n if (!schema.items) {\n result.expression = functionName.call(\n unknownToAst({\n plugin,\n schema: {\n type: 'unknown',\n },\n state,\n }).expression,\n );\n } else {\n schema = deduplicateSchema({ schema });\n\n // at least one item is guaranteed\n const itemExpressions = schema.items!.map((item, index) => {\n const itemAst = irSchemaToAst({\n plugin,\n schema: item,\n state: {\n ...state,\n path: toRef([...state.path.value, 'items', index]),\n },\n });\n if (itemAst.hasLazyExpression) {\n result.hasLazyExpression = true;\n }\n return itemAst.expression;\n });\n\n if (itemExpressions.length === 1) {\n result.expression = functionName.call(...itemExpressions);\n } else {\n if (schema.logicalOperator === 'and') {\n const firstSchema = schema.items![0]!;\n // we want to add an intersection, but not every schema can use the same API.\n // if the first item contains another array or not an object, we cannot use\n // `.intersection()` as that does not exist on `.union()` and non-object schemas.\n let intersectionExpression: ReturnType<typeof $.expr | typeof $.call>;\n if (\n firstSchema.logicalOperator === 'or' ||\n (firstSchema.type && firstSchema.type !== 'object')\n ) {\n intersectionExpression = $(z.placeholder)\n .attr(identifiers.intersection)\n .call(...itemExpressions);\n } else {\n intersectionExpression = itemExpressions[0]!;\n for (let i = 1; i < itemExpressions.length; i++) {\n intersectionExpression = $(z.placeholder)\n .attr(identifiers.intersection)\n .call(intersectionExpression, itemExpressions[i]);\n }\n }\n\n result.expression = functionName.call(intersectionExpression);\n } else {\n result.expression = $(z.placeholder)\n .attr(identifiers.array)\n .call(\n $(z.placeholder)\n .attr(identifiers.union)\n .call($.array(...itemExpressions)),\n );\n }\n }\n }\n\n const checks: Array<ReturnType<typeof $.call>> = [];\n\n if (schema.minItems === schema.maxItems && schema.minItems !== undefined) {\n checks.push(\n $(z.placeholder)\n .attr(identifiers.length)\n .call($.fromValue(schema.minItems)),\n );\n } else {\n if (schema.minItems !== undefined) {\n checks.push(\n $(z.placeholder)\n .attr(identifiers.minLength)\n .call($.fromValue(schema.minItems)),\n );\n }\n\n if (schema.maxItems !== undefined) {\n checks.push(\n $(z.placeholder)\n .attr(identifiers.maxLength)\n .call($.fromValue(schema.maxItems)),\n );\n }\n }\n\n if (checks.length) {\n result.expression = result.expression\n .attr(identifiers.check)\n .call(...checks);\n }\n\n return result as Omit<Ast, 'typeName'>;\n};\n","import type { SchemaWithType } from '~/plugins';\nimport { $ } from '~/ts-dsl';\n\nimport { identifiers } from '../../constants';\nimport type { Ast, IrSchemaToAstOptions } from '../../shared/types';\n\nexport const booleanToAst = ({\n plugin,\n schema,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'boolean'>;\n}): Omit<Ast, 'typeName'> => {\n const result: Partial<Omit<Ast, 'typeName'>> = {};\n let chain: ReturnType<typeof $.call>;\n\n const z = plugin.referenceSymbol({\n category: 'external',\n resource: 'zod.z',\n });\n\n if (typeof schema.const === 'boolean') {\n chain = $(z.placeholder)\n .attr(identifiers.literal)\n .call($.literal(schema.const));\n result.expression = chain;\n return result as Omit<Ast, 'typeName'>;\n }\n\n chain = $(z.placeholder).attr(identifiers.boolean).call();\n result.expression = chain;\n return result as Omit<Ast, 'typeName'>;\n};\n","import type { SchemaWithType } from '~/plugins';\nimport { $ } from '~/ts-dsl';\n\nimport { identifiers } from '../../constants';\nimport type { Ast, IrSchemaToAstOptions } from '../../shared/types';\nimport { unknownToAst } from './unknown';\n\nexport const enumToAst = ({\n plugin,\n schema,\n state,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'enum'>;\n}): Omit<Ast, 'typeName'> => {\n const z = plugin.referenceSymbol({\n category: 'external',\n resource: 'zod.z',\n });\n\n const result: Partial<Omit<Ast, 'typeName'>> = {};\n\n const enumMembers: Array<ReturnType<typeof $.literal>> = [];\n const literalMembers: Array<ReturnType<typeof $.call>> = [];\n\n let isNullable = false;\n let allStrings = true;\n\n for (const item of schema.items ?? []) {\n // Zod supports string, number, and boolean enums\n if (item.type === 'string' && typeof item.const === 'string') {\n const literal = $.literal(item.const);\n enumMembers.push(literal);\n literalMembers.push(\n $(z.placeholder).attr(identifiers.literal).call(literal),\n );\n } else if (\n (item.type === 'number' || item.type === 'integer') &&\n typeof item.const === 'number'\n ) {\n allStrings = false;\n const literal = $.literal(item.const);\n literalMembers.push(\n $(z.placeholder).attr(identifiers.literal).call(literal),\n );\n } else if (item.type === 'boolean' && typeof item.const === 'boolean') {\n allStrings = false;\n const literal = $.literal(item.const);\n literalMembers.push(\n $(z.placeholder).attr(identifiers.literal).call(literal),\n );\n } else if (item.type === 'null' || item.const === null) {\n isNullable = true;\n }\n }\n\n if (!literalMembers.length) {\n return unknownToAst({\n plugin,\n schema: {\n type: 'unknown',\n },\n state,\n });\n }\n\n // Use z.enum() for pure string enums, z.union() for mixed or non-string types\n if (allStrings && enumMembers.length > 0) {\n result.expression = $(z.placeholder)\n .attr(identifiers.enum)\n .call($.array(...enumMembers));\n } else if (literalMembers.length === 1) {\n // For single-member unions, use the member directly instead of wrapping in z.union()\n result.expression = literalMembers[0]!;\n } else {\n result.expression = $(z.placeholder)\n .attr(identifiers.union)\n .call($.array(...literalMembers));\n }\n\n if (isNullable) {\n result.expression = $(z.placeholder)\n .attr(identifiers.nullable)\n .call(result.expression);\n }\n\n return result as Omit<Ast, 'typeName'>;\n};\n","import type { SchemaWithType } from '~/plugins';\nimport { $ } from '~/ts-dsl';\n\nimport { identifiers } from '../../constants';\nimport type { Ast, IrSchemaToAstOptions } from '../../shared/types';\n\nexport const neverToAst = ({\n plugin,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'never'>;\n}): Omit<Ast, 'typeName'> => {\n const z = plugin.referenceSymbol({\n category: 'external',\n resource: 'zod.z',\n });\n const result: Partial<Omit<Ast, 'typeName'>> = {};\n result.expression = $(z.placeholder).attr(identifiers.never).call();\n return result as Omit<Ast, 'typeName'>;\n};\n","import type { SchemaWithType } from '~/plugins';\nimport { $ } from '~/ts-dsl';\n\nimport { identifiers } from '../../constants';\nimport type { Ast, IrSchemaToAstOptions } from '../../shared/types';\n\nexport const nullToAst = ({\n plugin,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'null'>;\n}): Omit<Ast, 'typeName'> => {\n const z = plugin.referenceSymbol({\n category: 'external',\n resource: 'zod.z',\n });\n const result: Partial<Omit<Ast, 'typeName'>> = {};\n result.expression = $(z.placeholder).attr(identifiers.null).call();\n return result as Omit<Ast, 'typeName'>;\n};\n","import type { SchemaWithType } from '~/plugins';\nimport { $ } from '~/ts-dsl';\n\nimport { identifiers } from '../../constants';\nimport { numberParameter } from '../../shared/numbers';\nimport type { Ast, IrSchemaToAstOptions } from '../../shared/types';\n\nexport const numberToAst = ({\n plugin,\n schema,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'integer' | 'number'>;\n}): Omit<Ast, 'typeName'> => {\n const z = plugin.referenceSymbol({\n category: 'external',\n resource: 'zod.z',\n });\n\n const result: Partial<Omit<Ast, 'typeName'>> = {};\n\n const isBigInt = schema.type === 'integer' && schema.format === 'int64';\n\n if (typeof schema.const === 'number') {\n // TODO: parser - handle bigint constants\n result.expression = $(z.placeholder)\n .attr(identifiers.literal)\n .call($.literal(schema.const));\n return result as Omit<Ast, 'typeName'>;\n }\n\n result.expression = isBigInt\n ? $(z.placeholder).attr(identifiers.coerce).attr(identifiers.bigint).call()\n : $(z.placeholder).attr(identifiers.number).call();\n\n if (!isBigInt && schema.type === 'integer') {\n result.expression = $(z.placeholder).attr(identifiers.int).call();\n }\n\n const checks: Array<ReturnType<typeof $.call>> = [];\n\n if (schema.exclusiveMinimum !== undefined) {\n checks.push(\n $(z.placeholder)\n .attr(identifiers.gt)\n .call(numberParameter({ isBigInt, value: schema.exclusiveMinimum })),\n );\n } else if (schema.minimum !== undefined) {\n checks.push(\n $(z.placeholder)\n .attr(identifiers.gte)\n .call(numberParameter({ isBigInt, value: schema.minimum })),\n );\n }\n\n if (schema.exclusiveMaximum !== undefined) {\n checks.push(\n $(z.placeholder)\n .attr(identifiers.lt)\n .call(numberParameter({ isBigInt, value: schema.exclusiveMaximum })),\n );\n } else if (schema.maximum !== undefined) {\n checks.push(\n $(z.placeholder)\n .attr(identifiers.lte)\n .call(numberParameter({ isBigInt, value: schema.maximum })),\n );\n }\n\n if (checks.length) {\n result.expression = result.expression\n .attr(identifiers.check)\n .call(...checks);\n }\n\n return result as Omit<Ast, 'typeName'>;\n};\n","import type { SchemaWithType } from '~/plugins';\nimport { toRef } from '~/plugins/shared/utils/refs';\nimport { $ } from '~/ts-dsl';\n\nimport { identifiers } from '../../constants';\nimport type { Ast, IrSchemaToAstOptions } from '../../shared/types';\nimport type { ObjectBaseResolverArgs } from '../../types';\nimport { irSchemaToAst } from '../plugin';\n\nfunction defaultObjectBaseResolver({\n additional,\n plugin,\n shape,\n}: ObjectBaseResolverArgs): ReturnType<typeof $.call> {\n const z = plugin.referenceSymbol({\n category: 'external',\n resource: 'zod.z',\n });\n\n if (additional) {\n return $(z.placeholder)\n .attr(identifiers.record)\n .call($(z.placeholder).attr(identifiers.string).call(), additional);\n }\n\n return $(z.placeholder).attr(identifiers.object).call(shape);\n}\n\nexport const objectToAst = ({\n plugin,\n schema,\n state,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'object'>;\n}): Omit<Ast, 'typeName'> => {\n const result: Partial<Omit<Ast, 'typeName'>> = {};\n\n // TODO: parser - handle constants\n\n const shape = $.object().pretty();\n const required = schema.required ?? [];\n\n for (const name in schema.properties) {\n const property = schema.properties[name]!;\n const isRequired = required.includes(name);\n\n const propertyAst = irSchemaToAst({\n optional: !isRequired,\n plugin,\n schema: property,\n state: {\n ...state,\n path: toRef([...state.path.value, 'properties', name]),\n },\n });\n if (propertyAst.hasLazyExpression) {\n result.hasLazyExpression = true;\n }\n\n if (propertyAst.hasLazyExpression) {\n shape.getter(name, propertyAst.expression.return());\n } else {\n shape.prop(name, propertyAst.expression);\n }\n }\n\n let additional: ReturnType<typeof $.call | typeof $.expr> | null | undefined;\n if (\n schema.additionalProperties &&\n (!schema.properties || !Object.keys(schema.properties).length)\n ) {\n const additionalAst = irSchemaToAst({\n plugin,\n schema: schema.additionalProperties,\n state: {\n ...state,\n path: toRef([...state.path.value, 'additionalProperties']),\n },\n });\n if (additionalAst.hasLazyExpression) result.hasLazyExpression = true;\n additional = additionalAst.expression;\n }\n\n const args: ObjectBaseResolverArgs = {\n $,\n additional,\n chain: undefined,\n plugin,\n schema,\n shape,\n };\n const resolver = plugin.config['~resolvers']?.object?.base;\n const chain = resolver?.(args) ?? defaultObjectBaseResolver(args);\n result.expression = chain;\n\n return result as Omit<Ast, 'typeName'>;\n};\n","import type { SchemaWithType } from '~/plugins';\nimport { $ } from '~/ts-dsl';\n\nimport { identifiers } from '../../constants';\nimport type { Ast, IrSchemaToAstOptions } from '../../shared/types';\nimport type { FormatResolverArgs } from '../../types';\n\nconst defaultFormatResolver = ({\n chain,\n plugin,\n schema,\n}: FormatResolverArgs): ReturnType<typeof $.call> => {\n const z = plugin.referenceSymbol({\n category: 'external',\n resource: 'zod.z',\n });\n\n switch (schema.format) {\n case 'date':\n return $(z.placeholder)\n .attr(identifiers.iso)\n .attr(identifiers.date)\n .call();\n case 'date-time': {\n const obj = $.object()\n .$if(plugin.config.dates.offset, (o) =>\n o.prop('offset', $.literal(true)),\n )\n .$if(plugin.config.dates.local, (o) =>\n o.prop('local', $.literal(true)),\n );\n return $(z.placeholder)\n .attr(identifiers.iso)\n .attr(identifiers.datetime)\n .call(obj.hasProps() ? obj : undefined);\n }\n case 'email':\n return $(z.placeholder).attr(identifiers.email).call();\n case 'ipv4':\n return $(z.placeholder).attr(identifiers.ipv4).call();\n case 'ipv6':\n return $(z.placeholder).attr(identifiers.ipv6).call();\n case 'time':\n return $(z.placeholder)\n .attr(identifiers.iso)\n .attr(identifiers.time)\n .call();\n case 'uri':\n return $(z.placeholder).attr(identifiers.url).call();\n case 'uuid':\n return $(z.placeholder).attr(identifiers.uuid).call();\n default:\n return chain;\n }\n};\n\nexport const stringToAst = ({\n plugin,\n schema,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'string'>;\n}): Omit<Ast, 'typeName'> => {\n const result: Partial<Omit<Ast, 'typeName'>> = {};\n let chain: ReturnType<typeof $.call>;\n\n const z = plugin.referenceSymbol({\n category: 'external',\n resource: 'zod.z',\n });\n\n if (typeof schema.const === 'string') {\n chain = $(z.placeholder)\n .attr(identifiers.literal)\n .call($.literal(schema.const));\n result.expression = chain;\n return result as Omit<Ast, 'typeName'>;\n }\n\n chain = $(z.placeholder).attr(identifiers.string).call();\n\n if (schema.format) {\n const args: FormatResolverArgs = { $, chain, plugin, schema };\n const resolver =\n plugin.config['~resolvers']?.string?.formats?.[schema.format];\n chain = resolver?.(args) ?? defaultFormatResolver(args);\n }\n\n const checks: Array<ReturnType<typeof $.call>> = [];\n\n if (schema.minLength === schema.maxLength && schema.minLength !== undefined) {\n checks.push(\n $(z.placeholder)\n .attr(identifiers.length)\n .call($.literal(schema.minLength)),\n );\n } else {\n if (schema.minLength !== undefined) {\n checks.push(\n $(z.placeholder)\n .attr(identifiers.minLength)\n .call($.literal(schema.minLength)),\n );\n }\n\n if (schema.maxLength !== undefined) {\n checks.push(\n $(z.placeholder)\n .attr(identifiers.maxLength)\n .call($.literal(schema.maxLength)),\n );\n }\n }\n\n if (schema.pattern) {\n checks.push(\n $(z.placeholder).attr(identifiers.regex).call($.regexp(schema.pattern)),\n );\n }\n\n if (checks.length) {\n chain = chain.attr(identifiers.check).call(...checks);\n }\n\n result.expression = chain;\n return result as Omit<Ast, 'typeName'>;\n};\n","import type { SchemaWithType } from '~/plugins';\nimport { toRef } from '~/plugins/shared/utils/refs';\nimport { $ } from '~/ts-dsl';\n\nimport { identifiers } from '../../constants';\nimport type { Ast, IrSchemaToAstOptions } from '../../shared/types';\nimport { irSchemaToAst } from '../plugin';\n\nexport const tupleToAst = ({\n plugin,\n schema,\n state,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'tuple'>;\n}): Omit<Ast, 'typeName'> => {\n const z = plugin.referenceSymbol({\n category: 'external',\n resource: 'zod.z',\n });\n\n const result: Partial<Omit<Ast, 'typeName'>> = {};\n\n if (schema.const && Array.isArray(schema.const)) {\n const tupleElements = schema.const.map((value) =>\n $(z.placeholder).attr(identifiers.literal).call($.fromValue(value)),\n );\n result.expression = $(z.placeholder)\n .attr(identifiers.tuple)\n .call($.array(...tupleElements));\n return result as Omit<Ast, 'typeName'>;\n }\n\n const tupleElements: Array<ReturnType<typeof $.call | typeof $.expr>> = [];\n\n if (schema.items) {\n schema.items.forEach((item, index) => {\n const itemSchema = irSchemaToAst({\n plugin,\n schema: item,\n state: {\n ...state,\n path: toRef([...state.path.value, 'items', index]),\n },\n });\n tupleElements.push(itemSchema.expression);\n if (itemSchema.hasLazyExpression) {\n result.hasLazyExpression = true;\n }\n });\n }\n\n result.expression = $(z.placeholder)\n .attr(identifiers.tuple)\n .call($.array(...tupleElements));\n\n return result as Omit<Ast, 'typeName'>;\n};\n","import type { SchemaWithType } from '~/plugins';\nimport { $ } from '~/ts-dsl';\n\nimport { identifiers } from '../../constants';\nimport type { Ast, IrSchemaToAstOptions } from '../../shared/types';\n\nexport const undefinedToAst = ({\n plugin,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'undefined'>;\n}): Omit<Ast, 'typeName'> => {\n const z = plugin.referenceSymbol({\n category: 'external',\n resource: 'zod.z',\n });\n const result: Partial<Omit<Ast, 'typeName'>> = {};\n result.expression = $(z.placeholder).attr(identifiers.undefined).call();\n return result as Omit<Ast, 'typeName'>;\n};\n","import type { SchemaWithType } from '~/plugins';\nimport { $ } from '~/ts-dsl';\n\nimport { identifiers } from '../../constants';\nimport type { Ast, IrSchemaToAstOptions } from '../../shared/types';\n\nexport const voidToAst = ({\n plugin,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'void'>;\n}): Omit<Ast, 'typeName'> => {\n const z = plugin.referenceSymbol({\n category: 'external',\n resource: 'zod.z',\n });\n const result: Partial<Omit<Ast, 'typeName'>> = {};\n result.expression = $(z.placeholder).attr(identifiers.void).call();\n return result as Omit<Ast, 'typeName'>;\n};\n","import type { SchemaWithType } from '~/plugins';\n\nimport type { Ast, IrSchemaToAstOptions } from '../../shared/types';\nimport { arrayToAst } from './array';\nimport { booleanToAst } from './boolean';\nimport { enumToAst } from './enum';\nimport { neverToAst } from './never';\nimport { nullToAst } from './null';\nimport { numberToAst } from './number';\nimport { objectToAst } from './object';\nimport { stringToAst } from './string';\nimport { tupleToAst } from './tuple';\nimport { undefinedToAst } from './undefined';\nimport { unknownToAst } from './unknown';\nimport { voidToAst } from './void';\n\nexport const irSchemaWithTypeToAst = ({\n schema,\n ...args\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType;\n}): Omit<Ast, 'typeName'> => {\n switch (schema.type) {\n case 'array':\n return arrayToAst({\n ...args,\n schema: schema as SchemaWithType<'array'>,\n });\n case 'boolean':\n return booleanToAst({\n ...args,\n schema: schema as SchemaWithType<'boolean'>,\n });\n case 'enum':\n return enumToAst({\n ...args,\n schema: schema as SchemaWithType<'enum'>,\n });\n case 'integer':\n case 'number':\n return numberToAst({\n ...args,\n schema: schema as SchemaWithType<'integer' | 'number'>,\n });\n case 'never':\n return neverToAst({\n ...args,\n schema: schema as SchemaWithType<'never'>,\n });\n case 'null':\n return nullToAst({\n ...args,\n schema: schema as SchemaWithType<'null'>,\n });\n case 'object':\n return objectToAst({\n ...args,\n schema: schema as SchemaWithType<'object'>,\n });\n case 'string':\n return stringToAst({\n ...args,\n schema: schema as SchemaWithType<'string'>,\n });\n case 'tuple':\n return tupleToAst({\n ...args,\n schema: schema as SchemaWithType<'tuple'>,\n });\n case 'undefined':\n return undefinedToAst({\n ...args,\n schema: schema as SchemaWithType<'undefined'>,\n });\n case 'unknown':\n return unknownToAst({\n ...args,\n schema: schema as SchemaWithType<'unknown'>,\n });\n case 'void':\n return voidToAst({\n ...args,\n schema: schema as SchemaWithType<'void'>,\n });\n }\n};\n","import type { SymbolMeta } from '@hey-api/codegen-core';\n\nimport { deduplicateSchema } from '~/ir/schema';\nimport type { IR } from '~/ir/types';\nimport { buildName } from '~/openApi/shared/utils/name';\nimport type { SchemaWithType } from '~/plugins';\nimport { toRef, toRefs } from '~/plugins/shared/utils/refs';\nimport { $ } from '~/ts-dsl';\nimport { pathToJsonPointer, refToName } from '~/utils/ref';\n\nimport { identifiers } from '../constants';\nimport { exportAst } from '../shared/export';\nimport { getZodModule } from '../shared/module';\nimport { numberParameter } from '../shared/numbers';\nimport { irOperationToAst } from '../shared/operation';\nimport type { Ast, IrSchemaToAstOptions, PluginState } from '../shared/types';\nimport { irWebhookToAst } from '../shared/webhook';\nimport type { ZodPlugin } from '../types';\nimport { irSchemaWithTypeToAst } from './toAst';\n\nexport const irSchemaToAst = ({\n optional,\n plugin,\n schema,\n state,\n}: IrSchemaToAstOptions & {\n /**\n * Accept `optional` to handle optional object properties. We can't handle\n * this inside the object function because `.optional()` must come before\n * `.default()` which is handled in this function.\n */\n optional?: boolean;\n schema: IR.SchemaObject;\n}): Ast => {\n let ast: Partial<Ast> = {};\n\n const z = plugin.referenceSymbol({\n category: 'external',\n resource: 'zod.z',\n });\n\n if (schema.$ref) {\n const query: SymbolMeta = {\n category: 'schema',\n resource: 'definition',\n resourceId: schema.$ref,\n tool: 'zod',\n };\n const refSymbol = plugin.referenceSymbol(query);\n if (plugin.isSymbolRegistered(query)) {\n ast.expression = $(refSymbol.placeholder);\n } else {\n ast.expression = $(z.placeholder)\n .attr(identifiers.lazy)\n .call($.func().returns('any').do($(refSymbol.placeholder).return()));\n ast.hasLazyExpression = true;\n state.hasLazyExpression.value = true;\n }\n } else if (schema.type) {\n const typeAst = irSchemaWithTypeToAst({\n plugin,\n schema: schema as SchemaWithType,\n state,\n });\n ast.expression = typeAst.expression;\n ast.hasLazyExpression = typeAst.hasLazyExpression;\n\n if (plugin.config.metadata && schema.description) {\n ast.expression = ast.expression\n .attr(identifiers.register)\n .call(\n $(z.placeholder).attr(identifiers.globalRegistry),\n $.object()\n .pretty()\n .prop('description', $.literal(schema.description)),\n );\n }\n } else if (schema.items) {\n schema = deduplicateSchema({ schema });\n\n if (schema.items) {\n const itemSchemas = schema.items.map((item, index) =>\n irSchemaToAst({\n plugin,\n schema: item,\n state: {\n ...state,\n path: toRef([...state.path.value, 'items', index]),\n },\n }),\n );\n\n if (schema.logicalOperator === 'and') {\n const firstSchema = schema.items[0]!;\n // we want to add an intersection, but not every schema can use the same API.\n // if the first item contains another array or not an object, we cannot use\n // `.merge()` as that does not exist on `.union()` and non-object schemas.\n if (\n firstSchema.logicalOperator === 'or' ||\n (firstSchema.type && firstSchema.type !== 'object')\n ) {\n ast.expression = $(z.placeholder)\n .attr(identifiers.intersection)\n .call(...itemSchemas.map((schema) => schema.expression));\n } else {\n ast.expression = itemSchemas[0]!.expression;\n itemSchemas.slice(1).forEach((schema) => {\n ast.expression = $(z.placeholder)\n .attr(identifiers.intersection)\n .call(\n ast.expression,\n schema.hasLazyExpression\n ? $(z.placeholder)\n .attr(identifiers.lazy)\n .call($.func().do(schema.expression.return()))\n : schema.expression,\n );\n });\n }\n } else {\n ast.expression = $(z.placeholder)\n .attr(identifiers.union)\n .call(\n $.array()\n .pretty()\n .elements(...itemSchemas.map((schema) => schema.expression)),\n );\n }\n } else {\n ast = irSchemaToAst({ plugin, schema, state });\n }\n } else {\n // catch-all fallback for failed schemas\n const typeAst = irSchemaWithTypeToAst({\n plugin,\n schema: {\n type: 'unknown',\n },\n state,\n });\n ast.expression = typeAst.expression;\n }\n\n if (ast.expression) {\n if (schema.accessScope === 'read') {\n ast.expression = $(z.placeholder)\n .attr(identifiers.readonly)\n .call(ast.expression);\n }\n\n if (optional) {\n ast.expression = $(z.placeholder)\n .attr(identifiers.optional)\n .call(ast.expression);\n ast.typeName = identifiers.ZodMiniOptional;\n }\n\n if (schema.default !== undefined) {\n const isBigInt = schema.type === 'integer' && schema.format === 'int64';\n ast.expression = $(z.placeholder)\n .attr(identifiers._default)\n .call(\n ast.expression,\n numberParameter({\n isBigInt,\n value: schema.default,\n }),\n );\n }\n }\n\n return ast as Ast;\n};\n\nconst handleComponent = ({\n plugin,\n schema,\n state,\n}: IrSchemaToAstOptions & {\n schema: IR.SchemaObject;\n}): void => {\n const $ref = pathToJsonPointer(state.path.value);\n const ast = irSchemaToAst({ plugin, schema, state });\n const baseName = refToName($ref);\n const symbol = plugin.registerSymbol({\n exported: true,\n meta: {\n category: 'schema',\n path: state.path.value,\n resource: 'definition',\n resourceId: $ref,\n tags: state.tags?.value,\n tool: 'zod',\n },\n name: buildName({\n config: plugin.config.definitions,\n name: baseName,\n }),\n });\n const typeInferSymbol = plugin.config.definitions.types.infer.enabled\n ? plugin.registerSymbol({\n exported: true,\n kind: 'type',\n meta: {\n category: 'type',\n path: state.path.value,\n resource: 'definition',\n resourceId: $ref,\n tags: state.tags?.value,\n tool: 'zod',\n variant: 'infer',\n },\n name: buildName({\n config: plugin.config.definitions.types.infer,\n name: baseName,\n }),\n })\n : undefined;\n exportAst({\n ast,\n plugin,\n schema,\n symbol,\n typeInferSymbol,\n });\n};\n\nexport const handlerMini: ZodPlugin['Handler'] = ({ plugin }) => {\n plugin.registerSymbol({\n external: getZodModule({ plugin }),\n importKind: 'namespace',\n meta: {\n category: 'external',\n resource: 'zod.z',\n },\n name: 'z',\n });\n\n plugin.forEach(\n 'operation',\n 'parameter',\n 'requestBody',\n 'schema',\n 'webhook',\n (event) => {\n const state = toRefs<PluginState>({\n hasLazyExpression: false,\n path: event._path,\n tags: event.tags,\n });\n switch (event.type) {\n case 'operation':\n irOperationToAst({\n getAst: (schema, path) => {\n const state = toRefs<PluginState>({\n hasLazyExpression: false,\n path,\n tags: event.tags,\n });\n return irSchemaToAst({ plugin, schema, state });\n },\n operation: event.operation,\n plugin,\n state,\n });\n break;\n case 'parameter':\n handleComponent({\n plugin,\n schema: event.parameter.schema,\n state,\n });\n break;\n case 'requestBody':\n handleComponent({\n plugin,\n schema: event.requestBody.schema,\n state,\n });\n break;\n case 'schema':\n handleComponent({\n plugin,\n schema: event.schema,\n state,\n });\n break;\n case 'webhook':\n irWebhookToAst({\n getAst: (schema, path) => {\n const state = toRefs<PluginState>({\n hasLazyExpression: false,\n path,\n tags: event.tags,\n });\n return irSchemaToAst({ plugin, schema, state });\n },\n operation: event.operation,\n plugin,\n state,\n });\n break;\n }\n },\n );\n};\n","import type { SchemaWithType } from '~/plugins';\nimport { $ } from '~/ts-dsl';\n\nimport { identifiers } from '../../constants';\nimport type { IrSchemaToAstOptions } from '../../shared/types';\n\nexport const unknownToAst = ({\n plugin,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'unknown'>;\n}) => {\n const z = plugin.referenceSymbol({\n category: 'external',\n resource: 'zod.z',\n });\n const expression = $(z.placeholder).attr(identifiers.unknown).call();\n return expression;\n};\n","import { deduplicateSchema } from '~/ir/schema';\nimport type { SchemaWithType } from '~/plugins';\nimport { toRef } from '~/plugins/shared/utils/refs';\nimport { $ } from '~/ts-dsl';\n\nimport { identifiers } from '../../constants';\nimport type { Ast, IrSchemaToAstOptions } from '../../shared/types';\nimport { irSchemaToAst } from '../plugin';\nimport { unknownToAst } from './unknown';\n\nexport const arrayToAst = ({\n plugin,\n schema,\n state,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'array'>;\n}): Omit<Ast, 'typeName'> & {\n anyType?: string;\n} => {\n const z = plugin.referenceSymbol({\n category: 'external',\n resource: 'zod.z',\n });\n\n const functionName = $(z.placeholder).attr(identifiers.array);\n\n let arrayExpression: ReturnType<typeof $.call> | undefined;\n let hasLazyExpression = false;\n\n if (!schema.items) {\n arrayExpression = functionName.call(\n unknownToAst({\n plugin,\n schema: {\n type: 'unknown',\n },\n state,\n }),\n );\n } else {\n schema = deduplicateSchema({ schema });\n\n // at least one item is guaranteed\n const itemExpressions = schema.items!.map((item, index) => {\n const itemAst = irSchemaToAst({\n plugin,\n schema: item,\n state: {\n ...state,\n path: toRef([...state.path.value, 'items', index]),\n },\n });\n if (itemAst.hasLazyExpression) {\n hasLazyExpression = true;\n }\n return itemAst.expression;\n });\n\n if (itemExpressions.length === 1) {\n arrayExpression = functionName.call(...itemExpressions);\n } else {\n if (schema.logicalOperator === 'and') {\n const firstSchema = schema.items![0]!;\n // we want to add an intersection, but not every schema can use the same API.\n // if the first item contains another array or not an object, we cannot use\n // `.and()` as that does not exist on `.union()` and non-object schemas.\n let intersectionExpression: ReturnType<typeof $.call | typeof $.expr>;\n if (\n firstSchema.logicalOperator === 'or' ||\n (firstSchema.type && firstSchema.type !== 'object')\n ) {\n intersectionExpression = $(z.placeholder)\n .attr(identifiers.intersection)\n .call(...itemExpressions);\n } else {\n intersectionExpression = itemExpressions[0]!;\n for (let i = 1; i < itemExpressions.length; i++) {\n intersectionExpression = intersectionExpression\n .attr(identifiers.and)\n .call(itemExpressions[i]);\n }\n }\n\n arrayExpression = functionName.call(intersectionExpression);\n } else {\n arrayExpression = $(z.placeholder)\n .attr(identifiers.array)\n .call(\n $(z.placeholder)\n .attr(identifiers.union)\n .call($.array(...itemExpressions)),\n );\n }\n }\n }\n\n if (schema.minItems === schema.maxItems && schema.minItems !== undefined) {\n arrayExpression = arrayExpression\n .attr(identifiers.length)\n .call($.fromValue(schema.minItems));\n } else {\n if (schema.minItems !== undefined) {\n arrayExpression = arrayExpression\n .attr(identifiers.min)\n .call($.fromValue(schema.minItems));\n }\n\n if (schema.maxItems !== undefined) {\n arrayExpression = arrayExpression\n .attr(identifiers.max)\n .call($.fromValue(schema.maxItems));\n }\n }\n\n return {\n expression: arrayExpression,\n hasLazyExpression,\n };\n};\n","import type { SchemaWithType } from '~/plugins';\nimport { $ } from '~/ts-dsl';\n\nimport { identifiers } from '../../constants';\nimport type { IrSchemaToAstOptions } from '../../shared/types';\n\nexport const booleanToAst = ({\n plugin,\n schema,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'boolean'>;\n}): ReturnType<typeof $.call> => {\n let chain: ReturnType<typeof $.call>;\n\n const z = plugin.referenceSymbol({\n category: 'external',\n resource: 'zod.z',\n });\n\n if (typeof schema.const === 'boolean') {\n chain = $(z.placeholder)\n .attr(identifiers.literal)\n .call($.literal(schema.const));\n return chain;\n }\n\n chain = $(z.placeholder).attr(identifiers.boolean).call();\n return chain;\n};\n","import type { SchemaWithType } from '~/plugins';\nimport { $ } from '~/ts-dsl';\n\nimport { identifiers } from '../../constants';\nimport type { IrSchemaToAstOptions } from '../../shared/types';\nimport { unknownToAst } from './unknown';\n\nexport const enumToAst = ({\n plugin,\n schema,\n state,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'enum'>;\n}): ReturnType<typeof $.call> => {\n const z = plugin.referenceSymbol({\n category: 'external',\n resource: 'zod.z',\n });\n\n const enumMembers: Array<ReturnType<typeof $.literal>> = [];\n const literalMembers: Array<ReturnType<typeof $.call>> = [];\n\n let isNullable = false;\n let allStrings = true;\n\n for (const item of schema.items ?? []) {\n // Zod supports string, number, and boolean enums\n if (item.type === 'string' && typeof item.const === 'string') {\n const literal = $.literal(item.const);\n enumMembers.push(literal);\n literalMembers.push(\n $(z.placeholder).attr(identifiers.literal).call(literal),\n );\n } else if (\n (item.type === 'number' || item.type === 'integer') &&\n typeof item.const === 'number'\n ) {\n allStrings = false;\n const literal = $.literal(item.const);\n literalMembers.push(\n $(z.placeholder).attr(identifiers.literal).call(literal),\n );\n } else if (item.type === 'boolean' && typeof item.const === 'boolean') {\n allStrings = false;\n const literal = $.literal(item.const);\n literalMembers.push(\n $(z.placeholder).attr(identifiers.literal).call(literal),\n );\n } else if (item.type === 'null' || item.const === null) {\n isNullable = true;\n }\n }\n\n if (!literalMembers.length) {\n return unknownToAst({\n plugin,\n schema: {\n type: 'unknown',\n },\n state,\n });\n }\n\n // Use z.enum() for pure string enums, z.union() for mixed or non-string types\n let enumExpression: ReturnType<typeof $.call>;\n if (allStrings && enumMembers.length > 0) {\n enumExpression = $(z.placeholder)\n .attr(identifiers.enum)\n .call($.array(...enumMembers));\n } else if (literalMembers.length === 1) {\n // For single-member unions, use the member directly instead of wrapping in z.union()\n enumExpression = literalMembers[0]!;\n } else {\n enumExpression = $(z.placeholder)\n .attr(identifiers.union)\n .call($.array(...literalMembers));\n }\n\n if (isNullable) {\n enumExpression = enumExpression.attr(identifiers.nullable).call();\n }\n\n return enumExpression;\n};\n","import type { SchemaWithType } from '~/plugins';\nimport { $ } from '~/ts-dsl';\n\nimport { identifiers } from '../../constants';\nimport type { IrSchemaToAstOptions } from '../../shared/types';\n\nexport const neverToAst = ({\n plugin,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'never'>;\n}) => {\n const z = plugin.referenceSymbol({\n category: 'external',\n resource: 'zod.z',\n });\n const expression = $(z.placeholder).attr(identifiers.never).call();\n return expression;\n};\n","import type { SchemaWithType } from '~/plugins';\nimport { $ } from '~/ts-dsl';\n\nimport { identifiers } from '../../constants';\nimport type { IrSchemaToAstOptions } from '../../shared/types';\n\nexport const nullToAst = ({\n plugin,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'null'>;\n}) => {\n const z = plugin.referenceSymbol({\n category: 'external',\n resource: 'zod.z',\n });\n const expression = $(z.placeholder).attr(identifiers.null).call();\n return expression;\n};\n","import type { SchemaWithType } from '~/plugins';\nimport { $ } from '~/ts-dsl';\n\nimport { identifiers } from '../../constants';\nimport { numberParameter } from '../../shared/numbers';\nimport type { IrSchemaToAstOptions } from '../../shared/types';\n\nexport const numberToAst = ({\n plugin,\n schema,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'integer' | 'number'>;\n}) => {\n const z = plugin.referenceSymbol({\n category: 'external',\n resource: 'zod.z',\n });\n\n const isBigInt = schema.type === 'integer' && schema.format === 'int64';\n\n if (typeof schema.const === 'number') {\n // TODO: parser - handle bigint constants\n const expression = $(z.placeholder)\n .attr(identifiers.literal)\n .call($.literal(schema.const));\n return expression;\n }\n\n let numberExpression = isBigInt\n ? $(z.placeholder).attr(identifiers.coerce).attr(identifiers.bigint).call()\n : $(z.placeholder).attr(identifiers.number).call();\n\n if (!isBigInt && schema.type === 'integer') {\n numberExpression = numberExpression.attr(identifiers.int).call();\n }\n\n if (schema.exclusiveMinimum !== undefined) {\n numberExpression = numberExpression\n .attr(identifiers.gt)\n .call(numberParameter({ isBigInt, value: schema.exclusiveMinimum }));\n } else if (schema.minimum !== undefined) {\n numberExpression = numberExpression\n .attr(identifiers.gte)\n .call(numberParameter({ isBigInt, value: schema.minimum }));\n }\n\n if (schema.exclusiveMaximum !== undefined) {\n numberExpression = numberExpression\n .attr(identifiers.lt)\n .call(numberParameter({ isBigInt, value: schema.exclusiveMaximum }));\n } else if (schema.maximum !== undefined) {\n numberExpression = numberExpression\n .attr(identifiers.lte)\n .call(numberParameter({ isBigInt, value: schema.maximum }));\n }\n\n return numberExpression;\n};\n","import type { SchemaWithType } from '~/plugins';\nimport { toRef } from '~/plugins/shared/utils/refs';\nimport { $ } from '~/ts-dsl';\n\nimport { identifiers } from '../../constants';\nimport type { Ast, IrSchemaToAstOptions } from '../../shared/types';\nimport type { ObjectBaseResolverArgs } from '../../types';\nimport { irSchemaToAst } from '../plugin';\n\nfunction defaultObjectBaseResolver({\n additional,\n plugin,\n shape,\n}: ObjectBaseResolverArgs): ReturnType<typeof $.call> {\n const z = plugin.referenceSymbol({\n category: 'external',\n resource: 'zod.z',\n });\n\n if (additional) {\n return $(z.placeholder).attr(identifiers.record).call(additional);\n }\n\n return $(z.placeholder).attr(identifiers.object).call(shape);\n}\n\nexport const objectToAst = ({\n plugin,\n schema,\n state,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'object'>;\n}): Omit<Ast, 'typeName'> & {\n anyType?: string;\n} => {\n let hasLazyExpression = false;\n\n // TODO: parser - handle constants\n\n const shape = $.object().pretty();\n const required = schema.required ?? [];\n\n for (const name in schema.properties) {\n const property = schema.properties[name]!;\n const isRequired = required.includes(name);\n\n const propertyExpression = irSchemaToAst({\n optional: !isRequired,\n plugin,\n schema: property,\n state: {\n ...state,\n path: toRef([...state.path.value, 'properties', name]),\n },\n });\n\n if (propertyExpression.hasLazyExpression) hasLazyExpression = true;\n\n shape.prop(name, propertyExpression.expression);\n }\n\n let additional: ReturnType<typeof $.call | typeof $.expr> | null | undefined;\n const result: Partial<Omit<Ast, 'typeName'>> = {};\n if (\n schema.additionalProperties &&\n (!schema.properties || !Object.keys(schema.properties).length)\n ) {\n const additionalAst = irSchemaToAst({\n plugin,\n schema: schema.additionalProperties,\n state: {\n ...state,\n path: toRef([...state.path.value, 'additionalProperties']),\n },\n });\n hasLazyExpression = additionalAst.hasLazyExpression || hasLazyExpression;\n additional = additionalAst.expression;\n }\n\n const args: ObjectBaseResolverArgs = {\n $,\n additional,\n chain: undefined,\n plugin,\n schema,\n shape,\n };\n const resolver = plugin.config['~resolvers']?.object?.base;\n const chain = resolver?.(args) ?? defaultObjectBaseResolver(args);\n result.expression = chain;\n\n return {\n anyType: 'AnyZodObject',\n expression: result.expression!,\n hasLazyExpression,\n };\n};\n","import type { SchemaWithType } from '~/plugins';\nimport { $ } from '~/ts-dsl';\n\nimport { identifiers } from '../../constants';\nimport type { IrSchemaToAstOptions } from '../../shared/types';\nimport type { FormatResolverArgs } from '../../types';\n\nconst defaultFormatResolver = ({\n chain,\n plugin,\n schema,\n}: FormatResolverArgs): ReturnType<typeof $.call> => {\n switch (schema.format) {\n case 'date':\n return chain.attr(identifiers.date).call();\n case 'date-time': {\n const obj = $.object()\n .$if(plugin.config.dates.offset, (o) =>\n o.prop('offset', $.literal(true)),\n )\n .$if(plugin.config.dates.local, (o) =>\n o.prop('local', $.literal(true)),\n );\n return chain\n .attr(identifiers.datetime)\n .call(obj.hasProps() ? obj : undefined);\n }\n case 'email':\n return chain.attr(identifiers.email).call();\n case 'ipv4':\n case 'ipv6':\n return chain.attr(identifiers.ip).call();\n case 'time':\n return chain.attr(identifiers.time).call();\n case 'uri':\n return chain.attr(identifiers.url).call();\n case 'uuid':\n return chain.attr(identifiers.uuid).call();\n default:\n return chain;\n }\n};\n\nexport const stringToAst = ({\n plugin,\n schema,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'string'>;\n}): ReturnType<typeof $.call> => {\n let chain: ReturnType<typeof $.call>;\n\n const z = plugin.referenceSymbol({\n category: 'external',\n resource: 'zod.z',\n });\n\n if (typeof schema.const === 'string') {\n chain = $(z.placeholder)\n .attr(identifiers.literal)\n .call($.literal(schema.const));\n return chain;\n }\n\n chain = $(z.placeholder).attr(identifiers.string).call();\n\n if (schema.format) {\n const args: FormatResolverArgs = { $, chain, plugin, schema };\n const resolver =\n plugin.config['~resolvers']?.string?.formats?.[schema.format];\n chain = resolver?.(args) ?? defaultFormatResolver(args);\n }\n\n if (schema.minLength === schema.maxLength && schema.minLength !== undefined) {\n chain = chain.attr(identifiers.length).call($.literal(schema.minLength));\n } else {\n if (schema.minLength !== undefined) {\n chain = chain.attr(identifiers.min).call($.literal(schema.minLength));\n }\n\n if (schema.maxLength !== undefined) {\n chain = chain.attr(identifiers.max).call($.literal(schema.maxLength));\n }\n }\n\n if (schema.pattern) {\n chain = chain.attr(identifiers.regex).call($.regexp(schema.pattern));\n }\n\n return chain;\n};\n","import type { SchemaWithType } from '~/plugins';\nimport { toRef } from '~/plugins/shared/utils/refs';\nimport { $ } from '~/ts-dsl';\n\nimport { identifiers } from '../../constants';\nimport type { Ast, IrSchemaToAstOptions } from '../../shared/types';\nimport { irSchemaToAst } from '../plugin';\n\nexport const tupleToAst = ({\n plugin,\n schema,\n state,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'tuple'>;\n}): Omit<Ast, 'typeName'> & {\n anyType?: string;\n} => {\n const z = plugin.referenceSymbol({\n category: 'external',\n resource: 'zod.z',\n });\n\n let hasLazyExpression = false;\n\n if (schema.const && Array.isArray(schema.const)) {\n const tupleElements = schema.const.map((value) =>\n $(z.placeholder).attr(identifiers.literal).call($.fromValue(value)),\n );\n const expression = $(z.placeholder)\n .attr(identifiers.tuple)\n .call($.array(...tupleElements));\n return {\n expression,\n hasLazyExpression,\n };\n }\n\n const tupleElements: Array<ReturnType<typeof $.call | typeof $.expr>> = [];\n\n if (schema.items) {\n schema.items.forEach((item, index) => {\n const itemSchema = irSchemaToAst({\n plugin,\n schema: item,\n state: {\n ...state,\n path: toRef([...state.path.value, 'items', index]),\n },\n });\n tupleElements.push(itemSchema.expression);\n if (itemSchema.hasLazyExpression) {\n hasLazyExpression = true;\n }\n });\n }\n\n const expression = $(z.placeholder)\n .attr(identifiers.tuple)\n .call($.array(...tupleElements));\n\n return {\n expression,\n hasLazyExpression,\n };\n};\n","import type { SchemaWithType } from '~/plugins';\nimport { $ } from '~/ts-dsl';\n\nimport { identifiers } from '../../constants';\nimport type { IrSchemaToAstOptions } from '../../shared/types';\n\nexport const undefinedToAst = ({\n plugin,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'undefined'>;\n}) => {\n const z = plugin.referenceSymbol({\n category: 'external',\n resource: 'zod.z',\n });\n const expression = $(z.placeholder).attr(identifiers.undefined).call();\n return expression;\n};\n","import type { SchemaWithType } from '~/plugins';\nimport { $ } from '~/ts-dsl';\n\nimport { identifiers } from '../../constants';\nimport type { IrSchemaToAstOptions } from '../../shared/types';\n\nexport const voidToAst = ({\n plugin,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'void'>;\n}) => {\n const z = plugin.referenceSymbol({\n category: 'external',\n resource: 'zod.z',\n });\n const expression = $(z.placeholder).attr(identifiers.void).call();\n return expression;\n};\n","import type { SchemaWithType } from '~/plugins';\n\nimport type { Ast, IrSchemaToAstOptions } from '../../shared/types';\nimport { arrayToAst } from './array';\nimport { booleanToAst } from './boolean';\nimport { enumToAst } from './enum';\nimport { neverToAst } from './never';\nimport { nullToAst } from './null';\nimport { numberToAst } from './number';\nimport { objectToAst } from './object';\nimport { stringToAst } from './string';\nimport { tupleToAst } from './tuple';\nimport { undefinedToAst } from './undefined';\nimport { unknownToAst } from './unknown';\nimport { voidToAst } from './void';\n\nexport const irSchemaWithTypeToAst = ({\n schema,\n ...args\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType;\n}): Omit<Ast, 'typeName'> & {\n anyType?: string;\n} => {\n switch (schema.type) {\n case 'array':\n return arrayToAst({\n ...args,\n schema: schema as SchemaWithType<'array'>,\n });\n case 'boolean':\n return {\n expression: booleanToAst({\n ...args,\n schema: schema as SchemaWithType<'boolean'>,\n }),\n };\n case 'enum':\n return {\n expression: enumToAst({\n ...args,\n schema: schema as SchemaWithType<'enum'>,\n }),\n };\n case 'integer':\n case 'number':\n return {\n expression: numberToAst({\n ...args,\n schema: schema as SchemaWithType<'integer' | 'number'>,\n }),\n };\n case 'never':\n return {\n expression: neverToAst({\n ...args,\n schema: schema as SchemaWithType<'never'>,\n }),\n };\n case 'null':\n return {\n expression: nullToAst({\n ...args,\n schema: schema as SchemaWithType<'null'>,\n }),\n };\n case 'object':\n return objectToAst({\n ...args,\n schema: schema as SchemaWithType<'object'>,\n });\n case 'string':\n return {\n expression: stringToAst({\n ...args,\n schema: schema as SchemaWithType<'string'>,\n }),\n };\n case 'tuple':\n return tupleToAst({\n ...args,\n schema: schema as SchemaWithType<'tuple'>,\n });\n case 'undefined':\n return {\n expression: undefinedToAst({\n ...args,\n schema: schema as SchemaWithType<'undefined'>,\n }),\n };\n case 'unknown':\n return {\n expression: unknownToAst({\n ...args,\n schema: schema as SchemaWithType<'unknown'>,\n }),\n };\n case 'void':\n return {\n expression: voidToAst({\n ...args,\n schema: schema as SchemaWithType<'void'>,\n }),\n };\n }\n};\n","import type { SymbolMeta } from '@hey-api/codegen-core';\n\nimport { deduplicateSchema } from '~/ir/schema';\nimport type { IR } from '~/ir/types';\nimport { buildName } from '~/openApi/shared/utils/name';\nimport type { SchemaWithType } from '~/plugins';\nimport { toRef, toRefs } from '~/plugins/shared/utils/refs';\nimport { $ } from '~/ts-dsl';\nimport { pathToJsonPointer, refToName } from '~/utils/ref';\n\nimport { identifiers } from '../constants';\nimport { exportAst } from '../shared/export';\nimport { getZodModule } from '../shared/module';\nimport { numberParameter } from '../shared/numbers';\nimport { irOperationToAst } from '../shared/operation';\nimport type { Ast, IrSchemaToAstOptions, PluginState } from '../shared/types';\nimport { irWebhookToAst } from '../shared/webhook';\nimport type { ZodPlugin } from '../types';\nimport { irSchemaWithTypeToAst } from './toAst';\n\nexport const irSchemaToAst = ({\n optional,\n plugin,\n schema,\n state,\n}: IrSchemaToAstOptions & {\n /**\n * Accept `optional` to handle optional object properties. We can't handle\n * this inside the object function because `.optional()` must come before\n * `.default()` which is handled in this function.\n */\n optional?: boolean;\n schema: IR.SchemaObject;\n}): Ast => {\n let ast: Partial<Ast> = {};\n\n const z = plugin.referenceSymbol({\n category: 'external',\n resource: 'zod.z',\n });\n\n if (schema.$ref) {\n const query: SymbolMeta = {\n category: 'schema',\n resource: 'definition',\n resourceId: schema.$ref,\n tool: 'zod',\n };\n const refSymbol = plugin.referenceSymbol(query);\n if (plugin.isSymbolRegistered(query)) {\n ast.expression = $(refSymbol.placeholder);\n } else {\n ast.expression = $(z.placeholder)\n .attr(identifiers.lazy)\n .call($.func().do($(refSymbol.placeholder).return()));\n ast.hasLazyExpression = true;\n state.hasLazyExpression.value = true;\n }\n } else if (schema.type) {\n const typeAst = irSchemaWithTypeToAst({\n plugin,\n schema: schema as SchemaWithType,\n state,\n });\n ast.expression = typeAst.expression;\n ast.typeName = typeAst.anyType;\n\n if (plugin.config.metadata && schema.description) {\n ast.expression = ast.expression\n .attr(identifiers.describe)\n .call($.literal(schema.description));\n }\n } else if (schema.items) {\n schema = deduplicateSchema({ schema });\n\n if (schema.items) {\n const itemTypes = schema.items.map((item, index) => {\n const typeAst = irSchemaToAst({\n plugin,\n schema: item,\n state: {\n ...state,\n path: toRef([...state.path.value, 'items', index]),\n },\n });\n return typeAst.expression;\n });\n\n if (schema.logicalOperator === 'and') {\n const firstSchema = schema.items[0]!;\n // we want to add an intersection, but not every schema can use the same API.\n // if the first item contains another array or not an object, we cannot use\n // `.merge()` as that does not exist on `.union()` and non-object schemas.\n if (\n firstSchema.logicalOperator === 'or' ||\n (firstSchema.type && firstSchema.type !== 'object')\n ) {\n ast.expression = $(z.placeholder)\n .attr(identifiers.intersection)\n .call(...itemTypes);\n } else {\n ast.expression = itemTypes[0];\n itemTypes.slice(1).forEach((item) => {\n ast.expression = ast.expression!.attr(identifiers.and).call(item);\n });\n }\n } else {\n ast.expression = $(z.placeholder)\n .attr(identifiers.union)\n .call(\n $.array()\n .pretty()\n .elements(...itemTypes),\n );\n }\n } else {\n ast = irSchemaToAst({ plugin, schema, state });\n }\n } else {\n // catch-all fallback for failed schemas\n const typeAst = irSchemaWithTypeToAst({\n plugin,\n schema: {\n type: 'unknown',\n },\n state,\n });\n ast.expression = typeAst.expression;\n ast.typeName = typeAst.anyType;\n }\n\n if (ast.expression) {\n if (schema.accessScope === 'read') {\n ast.expression = ast.expression.attr(identifiers.readonly).call();\n }\n\n if (optional) {\n ast.expression = ast.expression.attr(identifiers.optional).call();\n }\n\n if (schema.default !== undefined) {\n const isBigInt = schema.type === 'integer' && schema.format === 'int64';\n ast.expression = ast.expression.attr(identifiers.default).call(\n numberParameter({\n isBigInt,\n value: schema.default,\n }),\n );\n }\n }\n\n if (state.hasLazyExpression.value) {\n if (!ast.typeName) {\n ast.typeName = 'ZodTypeAny';\n }\n } else if (ast.typeName) {\n ast.typeName = undefined;\n }\n\n return ast as Ast;\n};\n\nconst handleComponent = ({\n plugin,\n schema,\n state,\n}: IrSchemaToAstOptions & {\n schema: IR.SchemaObject;\n}): void => {\n const $ref = pathToJsonPointer(state.path.value);\n const ast = irSchemaToAst({ plugin, schema, state });\n const baseName = refToName($ref);\n const symbol = plugin.registerSymbol({\n exported: true,\n meta: {\n category: 'schema',\n path: state.path.value,\n resource: 'definition',\n resourceId: $ref,\n tags: state.tags?.value,\n tool: 'zod',\n },\n name: buildName({\n config: plugin.config.definitions,\n name: baseName,\n }),\n });\n const typeInferSymbol = plugin.config.definitions.types.infer.enabled\n ? plugin.registerSymbol({\n exported: true,\n kind: 'type',\n meta: {\n category: 'type',\n path: state.path.value,\n resource: 'definition',\n resourceId: $ref,\n tags: state.tags?.value,\n tool: 'zod',\n variant: 'infer',\n },\n name: buildName({\n config: plugin.config.definitions.types.infer,\n name: baseName,\n }),\n })\n : undefined;\n exportAst({\n ast,\n plugin,\n schema,\n symbol,\n typeInferSymbol,\n });\n};\n\nexport const handlerV3: ZodPlugin['Handler'] = ({ plugin }) => {\n plugin.registerSymbol({\n external: getZodModule({ plugin }),\n meta: {\n category: 'external',\n resource: 'zod.z',\n },\n name: 'z',\n });\n\n plugin.forEach(\n 'operation',\n 'parameter',\n 'requestBody',\n 'schema',\n 'webhook',\n (event) => {\n const state = toRefs<PluginState>({\n hasLazyExpression: false,\n path: event._path,\n tags: event.tags,\n });\n switch (event.type) {\n case 'operation':\n irOperationToAst({\n getAst: (schema, path) => {\n const state = toRefs<PluginState>({\n hasLazyExpression: false,\n path,\n tags: event.tags,\n });\n return irSchemaToAst({ plugin, schema, state });\n },\n operation: event.operation,\n plugin,\n state,\n });\n break;\n case 'parameter':\n handleComponent({\n plugin,\n schema: event.parameter.schema,\n state,\n });\n break;\n case 'requestBody':\n handleComponent({\n plugin,\n schema: event.requestBody.schema,\n state,\n });\n break;\n case 'schema':\n handleComponent({\n plugin,\n schema: event.schema,\n state,\n });\n break;\n case 'webhook':\n irWebhookToAst({\n getAst: (schema, path) => {\n const state = toRefs<PluginState>({\n hasLazyExpression: false,\n path,\n tags: event.tags,\n });\n return irSchemaToAst({ plugin, schema, state });\n },\n operation: event.operation,\n plugin,\n state,\n });\n break;\n }\n },\n );\n};\n","import type { SchemaWithType } from '~/plugins';\nimport { $ } from '~/ts-dsl';\n\nimport { identifiers } from '../../constants';\nimport type { Ast, IrSchemaToAstOptions } from '../../shared/types';\n\nexport const unknownToAst = ({\n plugin,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'unknown'>;\n}): Omit<Ast, 'typeName'> => {\n const result: Partial<Omit<Ast, 'typeName'>> = {};\n const z = plugin.referenceSymbol({\n category: 'external',\n resource: 'zod.z',\n });\n result.expression = $(z.placeholder).attr(identifiers.unknown).call();\n return result as Omit<Ast, 'typeName'>;\n};\n","import { deduplicateSchema } from '~/ir/schema';\nimport type { SchemaWithType } from '~/plugins';\nimport { toRef } from '~/plugins/shared/utils/refs';\nimport { $ } from '~/ts-dsl';\n\nimport { identifiers } from '../../constants';\nimport type { Ast, IrSchemaToAstOptions } from '../../shared/types';\nimport { irSchemaToAst } from '../plugin';\nimport { unknownToAst } from './unknown';\n\nexport const arrayToAst = ({\n plugin,\n schema,\n state,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'array'>;\n}): Omit<Ast, 'typeName'> => {\n const result: Partial<Omit<Ast, 'typeName'>> = {};\n\n const z = plugin.referenceSymbol({\n category: 'external',\n resource: 'zod.z',\n });\n\n const functionName = $(z.placeholder).attr(identifiers.array);\n\n if (!schema.items) {\n result.expression = functionName.call(\n unknownToAst({\n plugin,\n schema: {\n type: 'unknown',\n },\n state,\n }).expression,\n );\n } else {\n schema = deduplicateSchema({ schema });\n\n // at least one item is guaranteed\n const itemExpressions = schema.items!.map((item, index) => {\n const itemAst = irSchemaToAst({\n plugin,\n schema: item,\n state: {\n ...state,\n path: toRef([...state.path.value, 'items', index]),\n },\n });\n if (itemAst.hasLazyExpression) {\n result.hasLazyExpression = true;\n }\n return itemAst.expression;\n });\n\n if (itemExpressions.length === 1) {\n result.expression = functionName.call(...itemExpressions);\n } else {\n if (schema.logicalOperator === 'and') {\n const firstSchema = schema.items![0]!;\n // we want to add an intersection, but not every schema can use the same API.\n // if the first item contains another array or not an object, we cannot use\n // `.and()` as that does not exist on `.union()` and non-object schemas.\n let intersectionExpression: ReturnType<typeof $.call | typeof $.expr>;\n if (\n firstSchema.logicalOperator === 'or' ||\n (firstSchema.type && firstSchema.type !== 'object')\n ) {\n intersectionExpression = $(z.placeholder)\n .attr(identifiers.intersection)\n .call(...itemExpressions);\n } else {\n intersectionExpression = itemExpressions[0]!;\n for (let i = 1; i < itemExpressions.length; i++) {\n intersectionExpression = intersectionExpression\n .attr(identifiers.and)\n .call(itemExpressions[i]);\n }\n }\n\n result.expression = functionName.call(intersectionExpression);\n } else {\n result.expression = $(z.placeholder)\n .attr(identifiers.array)\n .call(\n $(z.placeholder)\n .attr(identifiers.union)\n .call($.array(...itemExpressions)),\n );\n }\n }\n }\n\n if (schema.minItems === schema.maxItems && schema.minItems !== undefined) {\n result.expression = result.expression\n .attr(identifiers.length)\n .call($.fromValue(schema.minItems));\n } else {\n if (schema.minItems !== undefined) {\n result.expression = result.expression\n .attr(identifiers.min)\n .call($.fromValue(schema.minItems));\n }\n\n if (schema.maxItems !== undefined) {\n result.expression = result.expression\n .attr(identifiers.max)\n .call($.fromValue(schema.maxItems));\n }\n }\n\n return result as Omit<Ast, 'typeName'>;\n};\n","import type { SchemaWithType } from '~/plugins';\nimport { $ } from '~/ts-dsl';\n\nimport { identifiers } from '../../constants';\nimport type { Ast, IrSchemaToAstOptions } from '../../shared/types';\n\nexport const booleanToAst = ({\n plugin,\n schema,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'boolean'>;\n}): Omit<Ast, 'typeName'> => {\n const result: Partial<Omit<Ast, 'typeName'>> = {};\n let chain: ReturnType<typeof $.call>;\n\n const z = plugin.referenceSymbol({\n category: 'external',\n resource: 'zod.z',\n });\n\n if (typeof schema.const === 'boolean') {\n chain = $(z.placeholder)\n .attr(identifiers.literal)\n .call($.literal(schema.const));\n result.expression = chain;\n return result as Omit<Ast, 'typeName'>;\n }\n\n chain = $(z.placeholder).attr(identifiers.boolean).call();\n result.expression = chain;\n return result as Omit<Ast, 'typeName'>;\n};\n","import type { SchemaWithType } from '~/plugins';\nimport { $ } from '~/ts-dsl';\n\nimport { identifiers } from '../../constants';\nimport type { Ast, IrSchemaToAstOptions } from '../../shared/types';\nimport { unknownToAst } from './unknown';\n\nexport const enumToAst = ({\n plugin,\n schema,\n state,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'enum'>;\n}): Omit<Ast, 'typeName'> => {\n const result: Partial<Omit<Ast, 'typeName'>> = {};\n\n const z = plugin.referenceSymbol({\n category: 'external',\n resource: 'zod.z',\n });\n\n const enumMembers: Array<ReturnType<typeof $.literal>> = [];\n const literalMembers: Array<ReturnType<typeof $.call>> = [];\n\n let isNullable = false;\n let allStrings = true;\n\n for (const item of schema.items ?? []) {\n // Zod supports string, number, and boolean enums\n if (item.type === 'string' && typeof item.const === 'string') {\n const literal = $.literal(item.const);\n enumMembers.push(literal);\n literalMembers.push(\n $(z.placeholder).attr(identifiers.literal).call(literal),\n );\n } else if (\n (item.type === 'number' || item.type === 'integer') &&\n typeof item.const === 'number'\n ) {\n allStrings = false;\n const literal = $.literal(item.const);\n literalMembers.push(\n $(z.placeholder).attr(identifiers.literal).call(literal),\n );\n } else if (item.type === 'boolean' && typeof item.const === 'boolean') {\n allStrings = false;\n const literal = $.literal(item.const);\n literalMembers.push(\n $(z.placeholder).attr(identifiers.literal).call(literal),\n );\n } else if (item.type === 'null' || item.const === null) {\n isNullable = true;\n }\n }\n\n if (!literalMembers.length) {\n return unknownToAst({\n plugin,\n schema: {\n type: 'unknown',\n },\n state,\n });\n }\n\n // Use z.enum() for pure string enums, z.union() for mixed or non-string types\n if (allStrings && enumMembers.length > 0) {\n result.expression = $(z.placeholder)\n .attr(identifiers.enum)\n .call($.array(...enumMembers));\n } else if (literalMembers.length === 1) {\n // For single-member unions, use the member directly instead of wrapping in z.union()\n result.expression = literalMembers[0]!;\n } else {\n result.expression = $(z.placeholder)\n .attr(identifiers.union)\n .call($.array(...literalMembers));\n }\n\n if (isNullable) {\n result.expression = $(z.placeholder)\n .attr(identifiers.nullable)\n .call(result.expression);\n }\n\n return result as Omit<Ast, 'typeName'>;\n};\n","import type { SchemaWithType } from '~/plugins';\nimport { $ } from '~/ts-dsl';\n\nimport { identifiers } from '../../constants';\nimport type { Ast, IrSchemaToAstOptions } from '../../shared/types';\n\nexport const neverToAst = ({\n plugin,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'never'>;\n}): Omit<Ast, 'typeName'> => {\n const result: Partial<Omit<Ast, 'typeName'>> = {};\n const z = plugin.referenceSymbol({\n category: 'external',\n resource: 'zod.z',\n });\n result.expression = $(z.placeholder).attr(identifiers.never).call();\n return result as Omit<Ast, 'typeName'>;\n};\n","import type { SchemaWithType } from '~/plugins';\nimport { $ } from '~/ts-dsl';\n\nimport { identifiers } from '../../constants';\nimport type { Ast, IrSchemaToAstOptions } from '../../shared/types';\n\nexport const nullToAst = ({\n plugin,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'null'>;\n}): Omit<Ast, 'typeName'> => {\n const result: Partial<Omit<Ast, 'typeName'>> = {};\n const z = plugin.referenceSymbol({\n category: 'external',\n resource: 'zod.z',\n });\n result.expression = $(z.placeholder).attr(identifiers.null).call();\n return result as Omit<Ast, 'typeName'>;\n};\n","import type { SchemaWithType } from '~/plugins';\nimport { $ } from '~/ts-dsl';\n\nimport { identifiers } from '../../constants';\nimport { numberParameter } from '../../shared/numbers';\nimport type { Ast, IrSchemaToAstOptions } from '../../shared/types';\n\nexport const numberToAst = ({\n plugin,\n schema,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'integer' | 'number'>;\n}): Omit<Ast, 'typeName'> => {\n const result: Partial<Omit<Ast, 'typeName'>> = {};\n\n const isBigInt = schema.type === 'integer' && schema.format === 'int64';\n\n const z = plugin.referenceSymbol({\n category: 'external',\n resource: 'zod.z',\n });\n\n if (typeof schema.const === 'number') {\n // TODO: parser - handle bigint constants\n result.expression = $(z.placeholder)\n .attr(identifiers.literal)\n .call($.literal(schema.const));\n return result as Omit<Ast, 'typeName'>;\n }\n\n result.expression = isBigInt\n ? $(z.placeholder).attr(identifiers.coerce).attr(identifiers.bigint).call()\n : $(z.placeholder).attr(identifiers.number).call();\n\n if (!isBigInt && schema.type === 'integer') {\n result.expression = $(z.placeholder).attr(identifiers.int).call();\n }\n\n if (schema.exclusiveMinimum !== undefined) {\n result.expression = result.expression\n .attr(identifiers.gt)\n .call(numberParameter({ isBigInt, value: schema.exclusiveMinimum }));\n } else if (schema.minimum !== undefined) {\n result.expression = result.expression\n .attr(identifiers.gte)\n .call(numberParameter({ isBigInt, value: schema.minimum }));\n }\n\n if (schema.exclusiveMaximum !== undefined) {\n result.expression = result.expression\n .attr(identifiers.lt)\n .call(numberParameter({ isBigInt, value: schema.exclusiveMaximum }));\n } else if (schema.maximum !== undefined) {\n result.expression = result.expression\n .attr(identifiers.lte)\n .call(numberParameter({ isBigInt, value: schema.maximum }));\n }\n\n return result as Omit<Ast, 'typeName'>;\n};\n","import type { SchemaWithType } from '~/plugins';\nimport { toRef } from '~/plugins/shared/utils/refs';\nimport { $ } from '~/ts-dsl';\n\nimport { identifiers } from '../../constants';\nimport type { Ast, IrSchemaToAstOptions } from '../../shared/types';\nimport type { ObjectBaseResolverArgs } from '../../types';\nimport { irSchemaToAst } from '../plugin';\n\nfunction defaultObjectBaseResolver({\n additional,\n plugin,\n shape,\n}: ObjectBaseResolverArgs): ReturnType<typeof $.call> {\n const z = plugin.referenceSymbol({\n category: 'external',\n resource: 'zod.z',\n });\n\n if (additional) {\n return $(z.placeholder)\n .attr(identifiers.record)\n .call($(z.placeholder).attr(identifiers.string).call(), additional);\n }\n\n return $(z.placeholder).attr(identifiers.object).call(shape);\n}\n\nexport const objectToAst = ({\n plugin,\n schema,\n state,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'object'>;\n}): Omit<Ast, 'typeName'> => {\n const result: Partial<Omit<Ast, 'typeName'>> = {};\n\n // TODO: parser - handle constants\n\n const shape = $.object().pretty();\n const required = schema.required ?? [];\n\n for (const name in schema.properties) {\n const property = schema.properties[name]!;\n const isRequired = required.includes(name);\n\n const propertyAst = irSchemaToAst({\n optional: !isRequired,\n plugin,\n schema: property,\n state: {\n ...state,\n path: toRef([...state.path.value, 'properties', name]),\n },\n });\n if (propertyAst.hasLazyExpression) {\n result.hasLazyExpression = true;\n }\n\n if (propertyAst.hasLazyExpression) {\n shape.getter(name, propertyAst.expression.return());\n } else {\n shape.prop(name, propertyAst.expression);\n }\n }\n\n let additional: ReturnType<typeof $.call | typeof $.expr> | null | undefined;\n if (\n schema.additionalProperties &&\n (!schema.properties || !Object.keys(schema.properties).length)\n ) {\n const additionalAst = irSchemaToAst({\n plugin,\n schema: schema.additionalProperties,\n state: {\n ...state,\n path: toRef([...state.path.value, 'additionalProperties']),\n },\n });\n if (additionalAst.hasLazyExpression) result.hasLazyExpression = true;\n additional = additionalAst.expression;\n }\n\n const args: ObjectBaseResolverArgs = {\n $,\n additional,\n chain: undefined,\n plugin,\n schema,\n shape,\n };\n const resolver = plugin.config['~resolvers']?.object?.base;\n const chain = resolver?.(args) ?? defaultObjectBaseResolver(args);\n result.expression = chain;\n\n // Return with typeName for circular references\n if (result.hasLazyExpression) {\n return {\n ...result,\n typeName: 'ZodType',\n } as Ast;\n }\n\n return result as Omit<Ast, 'typeName'>;\n};\n","import type { SchemaWithType } from '~/plugins';\nimport { $ } from '~/ts-dsl';\n\nimport { identifiers } from '../../constants';\nimport type { Ast, IrSchemaToAstOptions } from '../../shared/types';\nimport type { FormatResolverArgs } from '../../types';\n\nconst defaultFormatResolver = ({\n chain,\n plugin,\n schema,\n}: FormatResolverArgs): ReturnType<typeof $.call> => {\n const z = plugin.referenceSymbol({\n category: 'external',\n resource: 'zod.z',\n });\n\n switch (schema.format) {\n case 'date':\n return $(z.placeholder)\n .attr(identifiers.iso)\n .attr(identifiers.date)\n .call();\n case 'date-time': {\n const obj = $.object()\n .$if(plugin.config.dates.offset, (o) =>\n o.prop('offset', $.literal(true)),\n )\n .$if(plugin.config.dates.local, (o) =>\n o.prop('local', $.literal(true)),\n );\n return $(z.placeholder)\n .attr(identifiers.iso)\n .attr(identifiers.datetime)\n .call(obj.hasProps() ? obj : undefined);\n }\n case 'email':\n return $(z.placeholder).attr(identifiers.email).call();\n case 'ipv4':\n return $(z.placeholder).attr(identifiers.ipv4).call();\n case 'ipv6':\n return $(z.placeholder).attr(identifiers.ipv6).call();\n case 'time':\n return $(z.placeholder)\n .attr(identifiers.iso)\n .attr(identifiers.time)\n .call();\n case 'uri':\n return $(z.placeholder).attr(identifiers.url).call();\n case 'uuid':\n return $(z.placeholder).attr(identifiers.uuid).call();\n default:\n return chain;\n }\n};\n\nexport const stringToAst = ({\n plugin,\n schema,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'string'>;\n}): Omit<Ast, 'typeName'> => {\n const result: Partial<Omit<Ast, 'typeName'>> = {};\n let chain: ReturnType<typeof $.call>;\n\n const z = plugin.referenceSymbol({\n category: 'external',\n resource: 'zod.z',\n });\n\n if (typeof schema.const === 'string') {\n chain = $(z.placeholder)\n .attr(identifiers.literal)\n .call($.literal(schema.const));\n result.expression = chain;\n return result as Omit<Ast, 'typeName'>;\n }\n\n chain = $(z.placeholder).attr(identifiers.string).call();\n\n if (schema.format) {\n const args: FormatResolverArgs = { $, chain, plugin, schema };\n const resolver =\n plugin.config['~resolvers']?.string?.formats?.[schema.format];\n chain = resolver?.(args) ?? defaultFormatResolver(args);\n }\n\n if (schema.minLength === schema.maxLength && schema.minLength !== undefined) {\n chain = chain.attr(identifiers.length).call($.literal(schema.minLength));\n } else {\n if (schema.minLength !== undefined) {\n chain = chain.attr(identifiers.min).call($.literal(schema.minLength));\n }\n\n if (schema.maxLength !== undefined) {\n chain = chain.attr(identifiers.max).call($.literal(schema.maxLength));\n }\n }\n\n if (schema.pattern) {\n chain = chain.attr(identifiers.regex).call($.regexp(schema.pattern));\n }\n\n result.expression = chain;\n return result as Omit<Ast, 'typeName'>;\n};\n","import type { SchemaWithType } from '~/plugins';\nimport { toRef } from '~/plugins/shared/utils/refs';\nimport { $ } from '~/ts-dsl';\n\nimport { identifiers } from '../../constants';\nimport type { Ast, IrSchemaToAstOptions } from '../../shared/types';\nimport { irSchemaToAst } from '../plugin';\n\nexport const tupleToAst = ({\n plugin,\n schema,\n state,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'tuple'>;\n}): Omit<Ast, 'typeName'> => {\n const result: Partial<Omit<Ast, 'typeName'>> = {};\n\n const z = plugin.referenceSymbol({\n category: 'external',\n resource: 'zod.z',\n });\n\n if (schema.const && Array.isArray(schema.const)) {\n const tupleElements = schema.const.map((value) =>\n $(z.placeholder).attr(identifiers.literal).call($.fromValue(value)),\n );\n result.expression = $(z.placeholder)\n .attr(identifiers.tuple)\n .call($.array(...tupleElements));\n return result as Omit<Ast, 'typeName'>;\n }\n\n const tupleElements: Array<ReturnType<typeof $.call | typeof $.expr>> = [];\n\n if (schema.items) {\n schema.items.forEach((item, index) => {\n const itemSchema = irSchemaToAst({\n plugin,\n schema: item,\n state: {\n ...state,\n path: toRef([...state.path.value, 'items', index]),\n },\n });\n tupleElements.push(itemSchema.expression);\n if (itemSchema.hasLazyExpression) {\n result.hasLazyExpression = true;\n }\n });\n }\n\n result.expression = $(z.placeholder)\n .attr(identifiers.tuple)\n .call($.array(...tupleElements));\n\n return result as Omit<Ast, 'typeName'>;\n};\n","import type { SchemaWithType } from '~/plugins';\nimport { $ } from '~/ts-dsl';\n\nimport { identifiers } from '../../constants';\nimport type { Ast, IrSchemaToAstOptions } from '../../shared/types';\n\nexport const undefinedToAst = ({\n plugin,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'undefined'>;\n}): Omit<Ast, 'typeName'> => {\n const result: Partial<Omit<Ast, 'typeName'>> = {};\n const z = plugin.referenceSymbol({\n category: 'external',\n resource: 'zod.z',\n });\n result.expression = $(z.placeholder).attr(identifiers.undefined).call();\n return result as Omit<Ast, 'typeName'>;\n};\n","import type { SchemaWithType } from '~/plugins';\nimport { $ } from '~/ts-dsl';\n\nimport { identifiers } from '../../constants';\nimport type { Ast, IrSchemaToAstOptions } from '../../shared/types';\n\nexport const voidToAst = ({\n plugin,\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType<'void'>;\n}): Omit<Ast, 'typeName'> => {\n const result: Partial<Omit<Ast, 'typeName'>> = {};\n const z = plugin.referenceSymbol({\n category: 'external',\n resource: 'zod.z',\n });\n result.expression = $(z.placeholder).attr(identifiers.void).call();\n return result as Omit<Ast, 'typeName'>;\n};\n","import type { SchemaWithType } from '~/plugins';\n\nimport type { Ast, IrSchemaToAstOptions } from '../../shared/types';\nimport { arrayToAst } from './array';\nimport { booleanToAst } from './boolean';\nimport { enumToAst } from './enum';\nimport { neverToAst } from './never';\nimport { nullToAst } from './null';\nimport { numberToAst } from './number';\nimport { objectToAst } from './object';\nimport { stringToAst } from './string';\nimport { tupleToAst } from './tuple';\nimport { undefinedToAst } from './undefined';\nimport { unknownToAst } from './unknown';\nimport { voidToAst } from './void';\n\nexport const irSchemaWithTypeToAst = ({\n schema,\n ...args\n}: IrSchemaToAstOptions & {\n schema: SchemaWithType;\n}): Omit<Ast, 'typeName'> => {\n switch (schema.type) {\n case 'array':\n return arrayToAst({\n ...args,\n schema: schema as SchemaWithType<'array'>,\n });\n case 'boolean':\n return booleanToAst({\n ...args,\n schema: schema as SchemaWithType<'boolean'>,\n });\n case 'enum':\n return enumToAst({\n ...args,\n schema: schema as SchemaWithType<'enum'>,\n });\n case 'integer':\n case 'number':\n return numberToAst({\n ...args,\n schema: schema as SchemaWithType<'integer' | 'number'>,\n });\n case 'never':\n return neverToAst({\n ...args,\n schema: schema as SchemaWithType<'never'>,\n });\n case 'null':\n return nullToAst({\n ...args,\n schema: schema as SchemaWithType<'null'>,\n });\n case 'object':\n return objectToAst({\n ...args,\n schema: schema as SchemaWithType<'object'>,\n });\n case 'string':\n return stringToAst({\n ...args,\n schema: schema as SchemaWithType<'string'>,\n });\n case 'tuple':\n return tupleToAst({\n ...args,\n schema: schema as SchemaWithType<'tuple'>,\n });\n case 'undefined':\n return undefinedToAst({\n ...args,\n schema: schema as SchemaWithType<'undefined'>,\n });\n case 'unknown':\n return unknownToAst({\n ...args,\n schema: schema as SchemaWithType<'unknown'>,\n });\n case 'void':\n return voidToAst({\n ...args,\n schema: schema as SchemaWithType<'void'>,\n });\n }\n};\n","import type { SymbolMeta } from '@hey-api/codegen-core';\n\nimport { deduplicateSchema } from '~/ir/schema';\nimport type { IR } from '~/ir/types';\nimport { buildName } from '~/openApi/shared/utils/name';\nimport type { SchemaWithType } from '~/plugins';\nimport { toRef, toRefs } from '~/plugins/shared/utils/refs';\nimport { $ } from '~/ts-dsl';\nimport { pathToJsonPointer, refToName } from '~/utils/ref';\n\nimport { identifiers } from '../constants';\nimport { exportAst } from '../shared/export';\nimport { getZodModule } from '../shared/module';\nimport { numberParameter } from '../shared/numbers';\nimport { irOperationToAst } from '../shared/operation';\nimport type { Ast, IrSchemaToAstOptions, PluginState } from '../shared/types';\nimport { irWebhookToAst } from '../shared/webhook';\nimport type { ZodPlugin } from '../types';\nimport { irSchemaWithTypeToAst } from './toAst';\n\nexport const irSchemaToAst = ({\n optional,\n plugin,\n schema,\n state,\n}: IrSchemaToAstOptions & {\n /**\n * Accept `optional` to handle optional object properties. We can't handle\n * this inside the object function because `.optional()` must come before\n * `.default()` which is handled in this function.\n */\n optional?: boolean;\n schema: IR.SchemaObject;\n}): Ast => {\n let ast: Partial<Ast> = {};\n\n const z = plugin.referenceSymbol({\n category: 'external',\n resource: 'zod.z',\n });\n\n if (schema.$ref) {\n const query: SymbolMeta = {\n category: 'schema',\n resource: 'definition',\n resourceId: schema.$ref,\n tool: 'zod',\n };\n const refSymbol = plugin.referenceSymbol(query);\n if (plugin.isSymbolRegistered(query)) {\n ast.expression = $(refSymbol.placeholder);\n } else {\n ast.expression = $(z.placeholder)\n .attr(identifiers.lazy)\n .call($.func().returns('any').do($(refSymbol.placeholder).return()));\n ast.hasLazyExpression = true;\n state.hasLazyExpression.value = true;\n }\n } else if (schema.type) {\n const typeAst = irSchemaWithTypeToAst({\n plugin,\n schema: schema as SchemaWithType,\n state,\n });\n ast.expression = typeAst.expression;\n ast.hasLazyExpression = typeAst.hasLazyExpression;\n\n if (plugin.config.metadata && schema.description) {\n ast.expression = ast.expression\n .attr(identifiers.register)\n .call(\n $(z.placeholder).attr(identifiers.globalRegistry),\n $.object()\n .pretty()\n .prop('description', $.literal(schema.description)),\n );\n }\n } else if (schema.items) {\n schema = deduplicateSchema({ schema });\n\n if (schema.items) {\n const itemSchemas = schema.items.map((item, index) =>\n irSchemaToAst({\n plugin,\n schema: item,\n state: {\n ...state,\n path: toRef([...state.path.value, 'items', index]),\n },\n }),\n );\n\n if (schema.logicalOperator === 'and') {\n const firstSchema = schema.items[0]!;\n // we want to add an intersection, but not every schema can use the same API.\n // if the first item contains another array or not an object, we cannot use\n // `.merge()` as that does not exist on `.union()` and non-object schemas.\n if (\n firstSchema.logicalOperator === 'or' ||\n (firstSchema.type && firstSchema.type !== 'object')\n ) {\n ast.expression = $(z.placeholder)\n .attr(identifiers.intersection)\n .call(...itemSchemas.map((schema) => schema.expression));\n } else {\n ast.expression = itemSchemas[0]!.expression;\n itemSchemas.slice(1).forEach((schema) => {\n ast.expression = ast\n .expression!.attr(identifiers.and)\n .call(\n schema.hasLazyExpression\n ? $(z.placeholder)\n .attr(identifiers.lazy)\n .call($.func().do(schema.expression.return()))\n : schema.expression,\n );\n });\n }\n } else {\n ast.expression = $(z.placeholder)\n .attr(identifiers.union)\n .call(\n $.array()\n .pretty()\n .elements(...itemSchemas.map((schema) => schema.expression)),\n );\n }\n } else {\n ast = irSchemaToAst({\n plugin,\n schema,\n state,\n });\n }\n } else {\n // catch-all fallback for failed schemas\n const typeAst = irSchemaWithTypeToAst({\n plugin,\n schema: {\n type: 'unknown',\n },\n state,\n });\n ast.expression = typeAst.expression;\n }\n\n if (ast.expression) {\n if (schema.accessScope === 'read') {\n ast.expression = ast.expression.attr(identifiers.readonly).call();\n }\n\n if (optional) {\n ast.expression = $(z.placeholder)\n .attr(identifiers.optional)\n .call(ast.expression);\n ast.typeName = identifiers.ZodOptional;\n }\n\n if (schema.default !== undefined) {\n const isBigInt = schema.type === 'integer' && schema.format === 'int64';\n ast.expression = ast.expression.attr(identifiers.default).call(\n numberParameter({\n isBigInt,\n value: schema.default,\n }),\n );\n }\n }\n\n return ast as Ast;\n};\n\nconst handleComponent = ({\n plugin,\n schema,\n state,\n}: IrSchemaToAstOptions & {\n schema: IR.SchemaObject;\n}): void => {\n const $ref = pathToJsonPointer(state.path.value);\n const ast = irSchemaToAst({ plugin, schema, state });\n const baseName = refToName($ref);\n const symbol = plugin.registerSymbol({\n exported: true,\n meta: {\n category: 'schema',\n path: state.path.value,\n resource: 'definition',\n resourceId: $ref,\n tags: state.tags?.value,\n tool: 'zod',\n },\n name: buildName({\n config: plugin.config.definitions,\n name: baseName,\n }),\n });\n const typeInferSymbol = plugin.config.definitions.types.infer.enabled\n ? plugin.registerSymbol({\n exported: true,\n kind: 'type',\n meta: {\n category: 'type',\n path: state.path.value,\n resource: 'definition',\n resourceId: $ref,\n tags: state.tags?.value,\n tool: 'zod',\n variant: 'infer',\n },\n name: buildName({\n config: plugin.config.definitions.types.infer,\n name: baseName,\n }),\n })\n : undefined;\n exportAst({\n ast,\n plugin,\n schema,\n symbol,\n typeInferSymbol,\n });\n};\n\nexport const handlerV4: ZodPlugin['Handler'] = ({ plugin }) => {\n plugin.registerSymbol({\n external: getZodModule({ plugin }),\n meta: {\n category: 'external',\n resource: 'zod.z',\n },\n name: 'z',\n });\n\n plugin.forEach(\n 'operation',\n 'parameter',\n 'requestBody',\n 'schema',\n 'webhook',\n (event) => {\n const state = toRefs<PluginState>({\n hasLazyExpression: false,\n path: event._path,\n tags: event.tags,\n });\n switch (event.type) {\n case 'operation':\n irOperationToAst({\n getAst: (schema, path) => {\n const state = toRefs<PluginState>({\n hasLazyExpression: false,\n path,\n tags: event.tags,\n });\n return irSchemaToAst({ plugin, schema, state });\n },\n operation: event.operation,\n plugin,\n state,\n });\n break;\n case 'parameter':\n handleComponent({\n plugin,\n schema: event.parameter.schema,\n state,\n });\n break;\n case 'requestBody':\n handleComponent({\n plugin,\n schema: event.requestBody.schema,\n state,\n });\n break;\n case 'schema':\n handleComponent({\n plugin,\n schema: event.schema,\n state,\n });\n break;\n case 'webhook':\n irWebhookToAst({\n getAst: (schema, path) => {\n const state = toRefs<PluginState>({\n hasLazyExpression: false,\n path,\n tags: event.tags,\n });\n return irSchemaToAst({ plugin, schema, state });\n },\n operation: event.operation,\n plugin,\n state,\n });\n break;\n }\n },\n );\n};\n","import { handlerMini } from './mini/plugin';\nimport type { ZodPlugin } from './types';\nimport { handlerV3 } from './v3/plugin';\nimport { handlerV4 } from './v4/plugin';\n\nexport const handler: ZodPlugin['Handler'] = (args) => {\n const { plugin } = args;\n switch (plugin.config.compatibilityVersion) {\n case 3:\n return handlerV3(args);\n case 'mini':\n return handlerMini(args);\n case 4:\n default:\n return handlerV4(args);\n }\n};\n","import colors from 'ansi-colors';\n\nimport { definePluginConfig, mappers } from '~/plugins/shared/utils/config';\n\nimport { Api } from './api';\nimport { handler } from './plugin';\nimport type { ZodPlugin } from './types';\n\ntype CompatibilityVersion = NonNullable<\n ZodPlugin['Config']['config']['compatibilityVersion']\n>;\n\nexport const defaultConfig: ZodPlugin['Config'] = {\n api: new Api(),\n config: {\n case: 'camelCase',\n comments: true,\n exportFromIndex: false,\n metadata: false,\n },\n handler,\n name: 'zod',\n resolveConfig: (plugin, context) => {\n const packageName = 'zod';\n const version = context.package.getVersion(packageName);\n\n const inferCompatibleVersion = (): CompatibilityVersion => {\n if (version && (version.major === 4 || version.major === 3)) {\n return version.major;\n }\n\n // default compatibility version\n return 4;\n };\n\n const ensureCompatibleVersion = (\n compatibilityVersion: CompatibilityVersion | undefined,\n ): CompatibilityVersion => {\n if (!compatibilityVersion) {\n return inferCompatibleVersion();\n }\n\n if (!version) {\n return compatibilityVersion;\n }\n\n if (\n compatibilityVersion === 4 ||\n compatibilityVersion === 3 ||\n compatibilityVersion === 'mini'\n ) {\n if (!context.package.satisfies(version, '>=3.25.0 <5.0.0')) {\n const compatibleVersion = inferCompatibleVersion();\n console.warn(\n `🔌 ${colors.yellow('Warning:')} Installed ${colors.cyan(packageName)} ${colors.cyan(`v${version.version}`)} does not support compatibility version ${colors.yellow(String(compatibilityVersion))}, using ${colors.yellow(String(compatibleVersion))}.`,\n );\n return compatibleVersion;\n }\n }\n\n return compatibilityVersion;\n };\n\n plugin.config.compatibilityVersion = ensureCompatibleVersion(\n plugin.config.compatibilityVersion,\n );\n\n plugin.config.dates = context.valueToObject({\n defaultValue: {\n local: false,\n offset: false,\n },\n value: plugin.config.dates,\n });\n\n plugin.config.types = context.valueToObject({\n defaultValue: {\n infer: {\n case: 'PascalCase',\n enabled: false,\n },\n },\n mappers: {\n object: (fields, defaultValue) => ({\n ...fields,\n infer: context.valueToObject({\n defaultValue: {\n ...(defaultValue.infer as Extract<\n typeof defaultValue.infer,\n Record<string, unknown>\n >),\n enabled:\n fields.infer !== undefined\n ? Boolean(fields.infer)\n : (\n defaultValue.infer as Extract<\n typeof defaultValue.infer,\n Record<string, unknown>\n >\n ).enabled,\n },\n mappers,\n value: fields.infer,\n }),\n }),\n },\n value: plugin.config.types,\n });\n\n plugin.config.definitions = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'camelCase',\n enabled: true,\n name: 'z{{name}}',\n types: {\n ...plugin.config.types,\n infer: {\n ...(plugin.config.types.infer as Extract<\n typeof plugin.config.types.infer,\n Record<string, unknown>\n >),\n name: '{{name}}ZodType',\n },\n },\n },\n mappers: {\n ...mappers,\n object: (fields, defaultValue) => ({\n ...fields,\n types: context.valueToObject({\n defaultValue: defaultValue.types!,\n mappers: {\n object: (fields, defaultValue) => ({\n ...fields,\n infer: context.valueToObject({\n defaultValue: {\n ...(defaultValue.infer as Extract<\n typeof defaultValue.infer,\n Record<string, unknown>\n >),\n enabled:\n fields.infer !== undefined\n ? Boolean(fields.infer)\n : (\n defaultValue.infer as Extract<\n typeof defaultValue.infer,\n Record<string, unknown>\n >\n ).enabled,\n },\n mappers,\n value: fields.infer,\n }),\n }),\n },\n value: fields.types,\n }),\n }),\n },\n value: plugin.config.definitions,\n });\n\n plugin.config.requests = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'camelCase',\n enabled: true,\n name: 'z{{name}}Data',\n types: {\n ...plugin.config.types,\n infer: {\n ...(plugin.config.types.infer as Extract<\n typeof plugin.config.types.infer,\n Record<string, unknown>\n >),\n name: '{{name}}DataZodType',\n },\n },\n },\n mappers: {\n ...mappers,\n object: (fields, defaultValue) => ({\n ...fields,\n types: context.valueToObject({\n defaultValue: defaultValue.types!,\n mappers: {\n object: (fields, defaultValue) => ({\n ...fields,\n infer: context.valueToObject({\n defaultValue: {\n ...(defaultValue.infer as Extract<\n typeof defaultValue.infer,\n Record<string, unknown>\n >),\n enabled:\n fields.infer !== undefined\n ? Boolean(fields.infer)\n : (\n defaultValue.infer as Extract<\n typeof defaultValue.infer,\n Record<string, unknown>\n >\n ).enabled,\n },\n mappers,\n value: fields.infer,\n }),\n }),\n },\n value: fields.types,\n }),\n }),\n },\n value: plugin.config.requests,\n });\n\n plugin.config.responses = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'camelCase',\n enabled: true,\n name: 'z{{name}}Response',\n types: {\n ...plugin.config.types,\n infer: {\n ...(plugin.config.types.infer as Extract<\n typeof plugin.config.types.infer,\n Record<string, unknown>\n >),\n name: '{{name}}ResponseZodType',\n },\n },\n },\n mappers: {\n ...mappers,\n object: (fields, defaultValue) => ({\n ...fields,\n types: context.valueToObject({\n defaultValue: defaultValue.types!,\n mappers: {\n object: (fields, defaultValue) => ({\n ...fields,\n infer: context.valueToObject({\n defaultValue: {\n ...(defaultValue.infer as Extract<\n typeof defaultValue.infer,\n Record<string, unknown>\n >),\n enabled:\n fields.infer !== undefined\n ? Boolean(fields.infer)\n : (\n defaultValue.infer as Extract<\n typeof defaultValue.infer,\n Record<string, unknown>\n >\n ).enabled,\n },\n mappers,\n value: fields.infer,\n }),\n }),\n },\n value: fields.types,\n }),\n }),\n },\n value: plugin.config.responses,\n });\n\n plugin.config.webhooks = context.valueToObject({\n defaultValue: {\n case: plugin.config.case ?? 'camelCase',\n enabled: true,\n name: 'z{{name}}WebhookRequest',\n types: {\n ...plugin.config.types,\n infer: {\n ...(plugin.config.types.infer as Extract<\n typeof plugin.config.types.infer,\n Record<string, unknown>\n >),\n name: '{{name}}WebhookRequestZodType',\n },\n },\n },\n mappers: {\n ...mappers,\n object: (fields, defaultValue) => ({\n ...fields,\n types: context.valueToObject({\n defaultValue: defaultValue.types!,\n mappers: {\n object: (fields, defaultValue) => ({\n ...fields,\n infer: context.valueToObject({\n defaultValue: {\n ...(defaultValue.infer as Extract<\n typeof defaultValue.infer,\n Record<string, unknown>\n >),\n enabled:\n fields.infer !== undefined\n ? Boolean(fields.infer)\n : (\n defaultValue.infer as Extract<\n typeof defaultValue.infer,\n Record<string, unknown>\n >\n ).enabled,\n },\n mappers,\n value: fields.infer,\n }),\n }),\n },\n value: fields.types,\n }),\n }),\n },\n value: plugin.config.webhooks,\n });\n },\n tags: ['validator'],\n};\n\n/**\n * Type helper for Zod plugin, returns {@link Plugin.Config} object\n */\nexport const defineConfig = definePluginConfig(defaultConfig);\n","import type { Plugin } from '~/plugins';\nimport type { AngularCommonPlugin } from '~/plugins/@angular/common';\nimport { defaultConfig as angularCommon } from '~/plugins/@angular/common';\nimport type { HeyApiClientAngularPlugin } from '~/plugins/@hey-api/client-angular';\nimport { defaultConfig as heyApiClientAngular } from '~/plugins/@hey-api/client-angular';\nimport type { HeyApiClientAxiosPlugin } from '~/plugins/@hey-api/client-axios';\nimport { defaultConfig as heyApiClientAxios } from '~/plugins/@hey-api/client-axios';\nimport type { HeyApiClientFetchPlugin } from '~/plugins/@hey-api/client-fetch';\nimport { defaultConfig as heyApiClientFetch } from '~/plugins/@hey-api/client-fetch';\nimport type { HeyApiClientKyPlugin } from '~/plugins/@hey-api/client-ky';\nimport { defaultConfig as heyApiClientKy } from '~/plugins/@hey-api/client-ky';\nimport type { HeyApiClientNextPlugin } from '~/plugins/@hey-api/client-next';\nimport { defaultConfig as heyApiClientNext } from '~/plugins/@hey-api/client-next';\nimport type { HeyApiClientNuxtPlugin } from '~/plugins/@hey-api/client-nuxt';\nimport { defaultConfig as heyApiClientNuxt } from '~/plugins/@hey-api/client-nuxt';\nimport type { HeyApiClientOfetchPlugin } from '~/plugins/@hey-api/client-ofetch';\nimport { defaultConfig as heyApiClientOfetch } from '~/plugins/@hey-api/client-ofetch';\nimport type { HeyApiSchemasPlugin } from '~/plugins/@hey-api/schemas';\nimport { defaultConfig as heyApiSchemas } from '~/plugins/@hey-api/schemas';\nimport type { HeyApiSdkPlugin } from '~/plugins/@hey-api/sdk';\nimport { defaultConfig as heyApiSdk } from '~/plugins/@hey-api/sdk';\nimport type { HeyApiTransformersPlugin } from '~/plugins/@hey-api/transformers';\nimport { defaultConfig as heyApiTransformers } from '~/plugins/@hey-api/transformers';\nimport type { HeyApiTypeScriptPlugin } from '~/plugins/@hey-api/typescript';\nimport { defaultConfig as heyApiTypeScript } from '~/plugins/@hey-api/typescript';\nimport type { PiniaColadaPlugin } from '~/plugins/@pinia/colada';\nimport { defaultConfig as piniaColada } from '~/plugins/@pinia/colada';\nimport type { TanStackAngularQueryPlugin } from '~/plugins/@tanstack/angular-query-experimental';\nimport { defaultConfig as tanStackAngularQuery } from '~/plugins/@tanstack/angular-query-experimental';\nimport type { TanStackReactQueryPlugin } from '~/plugins/@tanstack/react-query';\nimport { defaultConfig as tanStackReactQuery } from '~/plugins/@tanstack/react-query';\nimport type { TanStackSolidQueryPlugin } from '~/plugins/@tanstack/solid-query';\nimport { defaultConfig as tanStackSolidQuery } from '~/plugins/@tanstack/solid-query';\nimport type { TanStackSvelteQueryPlugin } from '~/plugins/@tanstack/svelte-query';\nimport { defaultConfig as tanStackSvelteQuery } from '~/plugins/@tanstack/svelte-query';\nimport type { TanStackVueQueryPlugin } from '~/plugins/@tanstack/vue-query';\nimport { defaultConfig as tanStackVueQuery } from '~/plugins/@tanstack/vue-query';\nimport type { ArktypePlugin } from '~/plugins/arktype';\nimport { defaultConfig as arktype } from '~/plugins/arktype';\nimport type { FastifyPlugin } from '~/plugins/fastify';\nimport { defaultConfig as fastify } from '~/plugins/fastify';\nimport type { SwrPlugin } from '~/plugins/swr';\nimport { defaultConfig as swr } from '~/plugins/swr';\nimport type { PluginNames } from '~/plugins/types';\nimport type { ValibotPlugin } from '~/plugins/valibot';\nimport { defaultConfig as valibot } from '~/plugins/valibot';\nimport type { ZodPlugin } from '~/plugins/zod';\nimport { defaultConfig as zod } from '~/plugins/zod';\n\nexport interface PluginConfigMap {\n '@angular/common': AngularCommonPlugin['Types'];\n '@hey-api/client-angular': HeyApiClientAngularPlugin['Types'];\n '@hey-api/client-axios': HeyApiClientAxiosPlugin['Types'];\n '@hey-api/client-fetch': HeyApiClientFetchPlugin['Types'];\n '@hey-api/client-ky': HeyApiClientKyPlugin['Types'];\n '@hey-api/client-next': HeyApiClientNextPlugin['Types'];\n '@hey-api/client-nuxt': HeyApiClientNuxtPlugin['Types'];\n '@hey-api/client-ofetch': HeyApiClientOfetchPlugin['Types'];\n '@hey-api/schemas': HeyApiSchemasPlugin['Types'];\n '@hey-api/sdk': HeyApiSdkPlugin['Types'];\n '@hey-api/transformers': HeyApiTransformersPlugin['Types'];\n '@hey-api/typescript': HeyApiTypeScriptPlugin['Types'];\n '@pinia/colada': PiniaColadaPlugin['Types'];\n '@tanstack/angular-query-experimental': TanStackAngularQueryPlugin['Types'];\n '@tanstack/react-query': TanStackReactQueryPlugin['Types'];\n '@tanstack/solid-query': TanStackSolidQueryPlugin['Types'];\n '@tanstack/svelte-query': TanStackSvelteQueryPlugin['Types'];\n '@tanstack/vue-query': TanStackVueQueryPlugin['Types'];\n arktype: ArktypePlugin['Types'];\n fastify: FastifyPlugin['Types'];\n swr: SwrPlugin['Types'];\n valibot: ValibotPlugin['Types'];\n zod: ZodPlugin['Types'];\n}\n\nexport const defaultPluginConfigs: {\n [K in PluginNames]: Plugin.Config<PluginConfigMap[K]>;\n} = {\n '@angular/common': angularCommon,\n '@hey-api/client-angular': heyApiClientAngular,\n '@hey-api/client-axios': heyApiClientAxios,\n '@hey-api/client-fetch': heyApiClientFetch,\n '@hey-api/client-ky': heyApiClientKy,\n '@hey-api/client-next': heyApiClientNext,\n '@hey-api/client-nuxt': heyApiClientNuxt,\n '@hey-api/client-ofetch': heyApiClientOfetch,\n '@hey-api/schemas': heyApiSchemas,\n '@hey-api/sdk': heyApiSdk,\n '@hey-api/transformers': heyApiTransformers,\n '@hey-api/typescript': heyApiTypeScript,\n '@pinia/colada': piniaColada,\n '@tanstack/angular-query-experimental': tanStackAngularQuery,\n '@tanstack/react-query': tanStackReactQuery,\n '@tanstack/solid-query': tanStackSolidQuery,\n '@tanstack/svelte-query': tanStackSvelteQuery,\n '@tanstack/vue-query': tanStackVueQuery,\n arktype,\n fastify,\n swr,\n valibot,\n zod,\n};\n","import { defaultPluginConfigs } from '~/plugins/config';\nimport type {\n AnyPluginName,\n PluginContext,\n PluginNames,\n} from '~/plugins/types';\nimport type { Config, UserConfig } from '~/types/config';\n\nimport { valueToObject } from './utils/config';\nimport { packageFactory } from './utils/package';\n\n/**\n * Default plugins used to generate artifacts if plugins aren't specified.\n */\nexport const defaultPlugins = [\n '@hey-api/typescript',\n '@hey-api/sdk',\n] as const satisfies ReadonlyArray<PluginNames>;\n\nconst getPluginsConfig = ({\n dependencies,\n userPlugins,\n userPluginsConfig,\n}: {\n dependencies: Record<string, string>;\n userPlugins: ReadonlyArray<AnyPluginName>;\n userPluginsConfig: Config['plugins'];\n}): Pick<Config, 'plugins' | 'pluginOrder'> => {\n const circularReferenceTracker = new Set<AnyPluginName>();\n const pluginOrder = new Set<AnyPluginName>();\n const plugins: Config['plugins'] = {};\n\n const dfs = (name: AnyPluginName) => {\n if (circularReferenceTracker.has(name)) {\n throw new Error(`Circular reference detected at '${name}'`);\n }\n\n if (pluginOrder.has(name)) {\n return;\n }\n\n circularReferenceTracker.add(name);\n\n const defaultPlugin = defaultPluginConfigs[name as PluginNames];\n const userPlugin = userPluginsConfig[name as PluginNames];\n\n if (!defaultPlugin && !userPlugin) {\n throw new Error(\n `unknown plugin dependency \"${name}\" - do you need to register a custom plugin with this name?`,\n );\n }\n\n const plugin = {\n ...defaultPlugin,\n ...userPlugin,\n config: {\n ...defaultPlugin?.config,\n ...userPlugin?.config,\n },\n dependencies: new Set([\n ...(defaultPlugin?.dependencies || []),\n ...(userPlugin?.dependencies || []),\n ]),\n };\n\n if (plugin.resolveConfig) {\n const context: PluginContext = {\n package: packageFactory(dependencies),\n pluginByTag: (tag, props = {}) => {\n const { defaultPlugin, errorMessage } = props;\n\n for (const userPlugin of userPlugins) {\n const defaultConfig =\n defaultPluginConfigs[userPlugin as PluginNames] ||\n userPluginsConfig[userPlugin as PluginNames];\n if (\n defaultConfig &&\n defaultConfig.tags?.includes(tag) &&\n userPlugin !== name\n ) {\n return userPlugin as any;\n }\n }\n\n if (defaultPlugin) {\n const defaultConfig =\n defaultPluginConfigs[defaultPlugin as PluginNames] ||\n userPluginsConfig[defaultPlugin as PluginNames];\n if (\n defaultConfig &&\n defaultConfig.tags?.includes(tag) &&\n defaultPlugin !== name\n ) {\n return defaultPlugin;\n }\n }\n\n throw new Error(\n errorMessage ||\n `missing plugin - no plugin with tag \"${tag}\" found`,\n );\n },\n valueToObject,\n };\n // @ts-expect-error\n plugin.resolveConfig(plugin, context);\n }\n\n for (const dependency of plugin.dependencies) {\n dfs(dependency);\n }\n\n circularReferenceTracker.delete(name);\n pluginOrder.add(name);\n\n // @ts-expect-error\n plugins[name] = plugin;\n };\n\n for (const name of userPlugins) {\n dfs(name);\n }\n\n return {\n pluginOrder: Array.from(pluginOrder) as ReadonlyArray<PluginNames>,\n plugins,\n };\n};\n\nconst isPluginClient = (plugin: Required<UserConfig>['plugins'][number]) => {\n if (typeof plugin === 'string') {\n return plugin.startsWith('@hey-api/client');\n }\n\n return (\n plugin.name.startsWith('@hey-api/client') ||\n // @ts-expect-error\n (plugin.tags && plugin.tags.includes('client'))\n );\n};\n\nexport const getPlugins = ({\n dependencies,\n userConfig,\n}: {\n dependencies: Record<string, string>;\n userConfig: UserConfig;\n}): Pick<Config, 'plugins' | 'pluginOrder'> => {\n const userPluginsConfig: Config['plugins'] = {};\n\n let definedPlugins: UserConfig['plugins'] = defaultPlugins;\n\n if (userConfig.plugins) {\n userConfig.plugins = userConfig.plugins.filter(\n (plugin) =>\n (typeof plugin === 'string' && plugin) ||\n (typeof plugin !== 'string' && plugin.name),\n );\n if (\n userConfig.plugins.length === 1 &&\n isPluginClient(userConfig.plugins[0]!)\n ) {\n definedPlugins = [...defaultPlugins, ...userConfig.plugins];\n } else {\n definedPlugins = userConfig.plugins;\n }\n }\n\n const userPlugins = definedPlugins\n .map((plugin) => {\n if (typeof plugin === 'string') {\n return plugin;\n }\n\n const pluginName = plugin.name;\n\n if (pluginName) {\n // @ts-expect-error\n if (plugin.handler) {\n // @ts-expect-error\n userPluginsConfig[pluginName] = plugin;\n } else {\n // @ts-expect-error\n userPluginsConfig[pluginName] = {\n config: { ...plugin },\n };\n // @ts-expect-error\n delete userPluginsConfig[pluginName]!.config.name;\n }\n }\n\n return pluginName;\n })\n .filter(Boolean);\n\n return getPluginsConfig({ dependencies, userPlugins, userPluginsConfig });\n};\n","import path from 'node:path';\n\nimport colors from 'ansi-colors';\n\nimport { ConfigError } from '~/error';\nimport type { Config, UserConfig } from '~/types/config';\nimport type { ArrayOnly } from '~/types/utils';\nimport type { Logger } from '~/utils/logger';\n\nimport { getInput } from './input';\nimport { getLogs } from './logs';\nimport { mergeConfigs } from './merge';\nimport { getOutput } from './output';\nimport { getProjectDependencies } from './packages';\nimport { getParser } from './parser';\nimport { getPlugins } from './plugins';\n\ntype ConfigResult = {\n config: Config;\n errors: ReadonlyArray<Error>;\n jobIndex: number;\n};\n\nexport type Configs = {\n dependencies: Record<string, string>;\n results: ReadonlyArray<ConfigResult>;\n};\n\n/**\n * Detect if the current session is interactive based on TTY status and environment variables.\n * This is used as a fallback when the user doesn't explicitly set the interactive option.\n * @internal\n */\nexport const detectInteractiveSession = (): boolean =>\n Boolean(\n process.stdin.isTTY &&\n process.stdout.isTTY &&\n !process.env.CI &&\n !process.env.NO_INTERACTIVE &&\n !process.env.NO_INTERACTION,\n );\n\n/**\n * @internal\n */\nexport const initConfigs = async ({\n logger,\n userConfigs,\n}: {\n logger: Logger;\n userConfigs: ReadonlyArray<UserConfig>;\n}): Promise<Configs> => {\n const configs: Array<UserConfig> = [];\n let dependencies: Record<string, string> = {};\n\n const eventLoad = logger.timeEvent('load');\n for (const userConfig of userConfigs) {\n let configurationFile: string | undefined = undefined;\n if (userConfig?.configFile) {\n const parts = userConfig.configFile.split('.');\n configurationFile = parts.slice(0, parts.length - 1).join('.');\n }\n\n const eventC12 = logger.timeEvent('c12');\n // c12 is ESM-only since v3\n const { loadConfig } = await import('c12');\n const { config: configFromFile, configFile: loadedConfigFile } =\n await loadConfig<UserConfig>({\n configFile: configurationFile,\n name: 'openapi-ts',\n });\n eventC12.timeEnd();\n\n if (!Object.keys(dependencies).length) {\n // TODO: handle dependencies for multiple configs properly?\n dependencies = getProjectDependencies(\n Object.keys(configFromFile).length ? loadedConfigFile : undefined,\n );\n }\n\n const mergedConfigs =\n configFromFile instanceof Array\n ? configFromFile.map((config) => mergeConfigs(config, userConfig))\n : [mergeConfigs(configFromFile, userConfig)];\n\n for (const mergedConfig of mergedConfigs) {\n const input = getInput(mergedConfig);\n\n if (mergedConfig.output instanceof Array) {\n const countInputs = input.length;\n const countOutputs = mergedConfig.output.length;\n if (countOutputs > 1) {\n if (countInputs !== countOutputs) {\n console.warn(\n `⚙️ ${colors.yellow('Warning:')} You provided ${colors.cyan(String(countInputs))} ${colors.cyan(countInputs === 1 ? 'input' : 'inputs')} and ${colors.yellow(String(countOutputs))} ${colors.yellow('outputs')}. This is probably not what you want as it will produce identical output in multiple locations. You most likely want to provide a single output or the same number of outputs as inputs.`,\n );\n for (const output of mergedConfig.output) {\n configs.push({ ...mergedConfig, input, output });\n }\n } else {\n mergedConfig.output.forEach((output, index) => {\n configs.push({ ...mergedConfig, input: input[index]!, output });\n });\n }\n } else {\n configs.push({\n ...mergedConfig,\n input,\n output: mergedConfig.output[0] ?? '',\n });\n }\n } else {\n configs.push({ ...mergedConfig, input });\n }\n }\n }\n eventLoad.timeEnd();\n\n const results: Array<ArrayOnly<ConfigResult>> = [];\n\n const eventBuild = logger.timeEvent('build');\n for (const userConfig of configs) {\n const logs = getLogs(userConfig);\n const input = getInput(userConfig);\n const output = getOutput(userConfig);\n const parser = getParser(userConfig);\n\n const errors: Array<Error> = [];\n\n if (!input.length) {\n errors.push(\n new ConfigError(\n 'missing input - which OpenAPI specification should we use to generate your output?',\n ),\n );\n }\n\n if (!output.path) {\n errors.push(\n new ConfigError(\n 'missing output - where should we generate your output?',\n ),\n );\n }\n\n output.path = path.resolve(process.cwd(), output.path);\n\n let plugins: Pick<Config, 'plugins' | 'pluginOrder'>;\n\n try {\n plugins = getPlugins({ dependencies, userConfig });\n } catch (error) {\n errors.push(error);\n plugins = {\n pluginOrder: [],\n plugins: {},\n };\n }\n\n const config: Config = {\n configFile: userConfig.configFile ?? '',\n dryRun: userConfig.dryRun ?? false,\n input,\n interactive: userConfig.interactive ?? detectInteractiveSession(),\n logs,\n output,\n parser,\n pluginOrder: plugins.pluginOrder,\n plugins: plugins.plugins,\n };\n\n const jobIndex = results.length;\n\n if (logs.level === 'debug') {\n const jobPrefix = colors.gray(`[Job ${jobIndex + 1}] `);\n console.warn(`${jobPrefix}${colors.cyan('config:')}`, config);\n }\n\n results.push({ config, errors, jobIndex });\n }\n eventBuild.timeEnd();\n\n return { dependencies, results };\n};\n","type Slot = 'body' | 'headers' | 'path' | 'query';\n\nexport type Field =\n | {\n in: Exclude<Slot, 'body'>;\n /**\n * Field name. This is the name we want the user to see and use.\n */\n key: string;\n /**\n * Field mapped name. This is the name we want to use in the request.\n * If omitted, we use the same value as `key`.\n */\n map?: string;\n }\n | {\n in: Extract<Slot, 'body'>;\n /**\n * Key isn't required for bodies.\n */\n key?: string;\n map?: string;\n }\n | {\n /**\n * Field name. This is the name we want the user to see and use.\n */\n key: string;\n /**\n * Field mapped name. This is the name we want to use in the request.\n * If `in` is omitted, `map` aliases `key` to the transport layer.\n */\n map: Slot;\n };\n\nexport interface Fields {\n allowExtra?: Partial<Record<Slot, boolean>>;\n args?: ReadonlyArray<Field>;\n}\n\nexport type FieldsConfig = ReadonlyArray<Field | Fields>;\n\nconst extraPrefixesMap: Record<string, Slot> = {\n $body_: 'body',\n $headers_: 'headers',\n $path_: 'path',\n $query_: 'query',\n};\nconst extraPrefixes = Object.entries(extraPrefixesMap);\n\ntype KeyMap = Map<\n string,\n | {\n in: Slot;\n map?: string;\n }\n | {\n in?: never;\n map: Slot;\n }\n>;\n\nconst buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => {\n if (!map) {\n map = new Map();\n }\n\n for (const config of fields) {\n if ('in' in config) {\n if (config.key) {\n map.set(config.key, {\n in: config.in,\n map: config.map,\n });\n }\n } else if ('key' in config) {\n map.set(config.key, {\n map: config.map,\n });\n } else if (config.args) {\n buildKeyMap(config.args, map);\n }\n }\n\n return map;\n};\n\ninterface Params {\n body: unknown;\n headers: Record<string, unknown>;\n path: Record<string, unknown>;\n query: Record<string, unknown>;\n}\n\nconst stripEmptySlots = (params: Params) => {\n for (const [slot, value] of Object.entries(params)) {\n if (value && typeof value === 'object' && !Object.keys(value).length) {\n delete params[slot as Slot];\n }\n }\n};\n\nexport const buildClientParams = (\n args: ReadonlyArray<unknown>,\n fields: FieldsConfig,\n) => {\n const params: Params = {\n body: {},\n headers: {},\n path: {},\n query: {},\n };\n\n const map = buildKeyMap(fields);\n\n let config: FieldsConfig[number] | undefined;\n\n for (const [index, arg] of args.entries()) {\n if (fields[index]) {\n config = fields[index];\n }\n\n if (!config) {\n continue;\n }\n\n if ('in' in config) {\n if (config.key) {\n const field = map.get(config.key)!;\n const name = field.map || config.key;\n if (field.in) {\n (params[field.in] as Record<string, unknown>)[name] = arg;\n }\n } else {\n params.body = arg;\n }\n } else {\n for (const [key, value] of Object.entries(arg ?? {})) {\n const field = map.get(key);\n\n if (field) {\n if (field.in) {\n const name = field.map || key;\n (params[field.in] as Record<string, unknown>)[name] = value;\n } else {\n params[field.map] = value;\n }\n } else {\n const extra = extraPrefixes.find(([prefix]) =>\n key.startsWith(prefix),\n );\n\n if (extra) {\n const [prefix, slot] = extra;\n (params[slot] as Record<string, unknown>)[\n key.slice(prefix.length)\n ] = value;\n } else if ('allowExtra' in config && config.allowExtra) {\n for (const [slot, allowed] of Object.entries(config.allowExtra)) {\n if (allowed) {\n (params[slot as Slot] as Record<string, unknown>)[key] = value;\n break;\n }\n }\n }\n }\n }\n }\n }\n\n stripEmptySlots(params);\n\n return params;\n};\n","interface SerializeOptions<T>\n extends SerializePrimitiveOptions,\n SerializerOptions<T> {}\n\ninterface SerializePrimitiveOptions {\n allowReserved?: boolean;\n name: string;\n}\n\nexport interface SerializerOptions<T> {\n /**\n * @default true\n */\n explode: boolean;\n style: T;\n}\n\nexport type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited';\nexport type ArraySeparatorStyle = ArrayStyle | MatrixStyle;\ntype MatrixStyle = 'label' | 'matrix' | 'simple';\nexport type ObjectStyle = 'form' | 'deepObject';\ntype ObjectSeparatorStyle = ObjectStyle | MatrixStyle;\n\ninterface SerializePrimitiveParam extends SerializePrimitiveOptions {\n value: string;\n}\n\nexport const separatorArrayExplode = (style: ArraySeparatorStyle) => {\n switch (style) {\n case 'label':\n return '.';\n case 'matrix':\n return ';';\n case 'simple':\n return ',';\n default:\n return '&';\n }\n};\n\nexport const separatorArrayNoExplode = (style: ArraySeparatorStyle) => {\n switch (style) {\n case 'form':\n return ',';\n case 'pipeDelimited':\n return '|';\n case 'spaceDelimited':\n return '%20';\n default:\n return ',';\n }\n};\n\nexport const separatorObjectExplode = (style: ObjectSeparatorStyle) => {\n switch (style) {\n case 'label':\n return '.';\n case 'matrix':\n return ';';\n case 'simple':\n return ',';\n default:\n return '&';\n }\n};\n\nexport const serializeArrayParam = ({\n allowReserved,\n explode,\n name,\n style,\n value,\n}: SerializeOptions<ArraySeparatorStyle> & {\n value: unknown[];\n}) => {\n if (!explode) {\n const joinedValues = (\n allowReserved ? value : value.map((v) => encodeURIComponent(v as string))\n ).join(separatorArrayNoExplode(style));\n switch (style) {\n case 'label':\n return `.${joinedValues}`;\n case 'matrix':\n return `;${name}=${joinedValues}`;\n case 'simple':\n return joinedValues;\n default:\n return `${name}=${joinedValues}`;\n }\n }\n\n const separator = separatorArrayExplode(style);\n const joinedValues = value\n .map((v) => {\n if (style === 'label' || style === 'simple') {\n return allowReserved ? v : encodeURIComponent(v as string);\n }\n\n return serializePrimitiveParam({\n allowReserved,\n name,\n value: v as string,\n });\n })\n .join(separator);\n return style === 'label' || style === 'matrix'\n ? separator + joinedValues\n : joinedValues;\n};\n\nexport const serializePrimitiveParam = ({\n allowReserved,\n name,\n value,\n}: SerializePrimitiveParam) => {\n if (value === undefined || value === null) {\n return '';\n }\n\n if (typeof value === 'object') {\n throw new Error(\n 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.',\n );\n }\n\n return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;\n};\n\nexport const serializeObjectParam = ({\n allowReserved,\n explode,\n name,\n style,\n value,\n valueOnly,\n}: SerializeOptions<ObjectSeparatorStyle> & {\n value: Record<string, unknown> | Date;\n valueOnly?: boolean;\n}) => {\n if (value instanceof Date) {\n return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;\n }\n\n if (style !== 'deepObject' && !explode) {\n let values: string[] = [];\n Object.entries(value).forEach(([key, v]) => {\n values = [\n ...values,\n key,\n allowReserved ? (v as string) : encodeURIComponent(v as string),\n ];\n });\n const joinedValues = values.join(',');\n switch (style) {\n case 'form':\n return `${name}=${joinedValues}`;\n case 'label':\n return `.${joinedValues}`;\n case 'matrix':\n return `;${name}=${joinedValues}`;\n default:\n return joinedValues;\n }\n }\n\n const separator = separatorObjectExplode(style);\n const joinedValues = Object.entries(value)\n .map(([key, v]) =>\n serializePrimitiveParam({\n allowReserved,\n name: style === 'deepObject' ? `${name}[${key}]` : key,\n value: v as string,\n }),\n )\n .join(separator);\n return style === 'label' || style === 'matrix'\n ? separator + joinedValues\n : joinedValues;\n};\n","import { getAuthToken } from '../../client-core/bundle/auth';\nimport type { QuerySerializerOptions } from '../../client-core/bundle/bodySerializer';\nimport { jsonBodySerializer } from '../../client-core/bundle/bodySerializer';\nimport {\n serializeArrayParam,\n serializeObjectParam,\n serializePrimitiveParam,\n} from '../../client-core/bundle/pathSerializer';\nimport { getUrl } from '../../client-core/bundle/utils';\nimport type { Client, ClientOptions, Config, RequestOptions } from './types';\n\nexport const createQuerySerializer = <T = unknown>({\n parameters = {},\n ...args\n}: QuerySerializerOptions = {}) => {\n const querySerializer = (queryParams: T) => {\n const search: string[] = [];\n if (queryParams && typeof queryParams === 'object') {\n for (const name in queryParams) {\n const value = queryParams[name];\n\n if (value === undefined || value === null) {\n continue;\n }\n\n const options = parameters[name] || args;\n\n if (Array.isArray(value)) {\n const serializedArray = serializeArrayParam({\n allowReserved: options.allowReserved,\n explode: true,\n name,\n style: 'form',\n value,\n ...options.array,\n });\n if (serializedArray) search.push(serializedArray);\n } else if (typeof value === 'object') {\n const serializedObject = serializeObjectParam({\n allowReserved: options.allowReserved,\n explode: true,\n name,\n style: 'deepObject',\n value: value as Record<string, unknown>,\n ...options.object,\n });\n if (serializedObject) search.push(serializedObject);\n } else {\n const serializedPrimitive = serializePrimitiveParam({\n allowReserved: options.allowReserved,\n name,\n value: value as string,\n });\n if (serializedPrimitive) search.push(serializedPrimitive);\n }\n }\n }\n return search.join('&');\n };\n return querySerializer;\n};\n\n/**\n * Infers parseAs value from provided Content-Type header.\n */\nexport const getParseAs = (\n contentType: string | null,\n): Exclude<Config['parseAs'], 'auto'> => {\n if (!contentType) {\n // If no Content-Type header is provided, the best we can do is return the raw response body,\n // which is effectively the same as the 'stream' option.\n return 'stream';\n }\n\n const cleanContent = contentType.split(';')[0]?.trim();\n\n if (!cleanContent) {\n return;\n }\n\n if (\n cleanContent.startsWith('application/json') ||\n cleanContent.endsWith('+json')\n ) {\n return 'json';\n }\n\n if (cleanContent === 'multipart/form-data') {\n return 'formData';\n }\n\n if (\n ['application/', 'audio/', 'image/', 'video/'].some((type) =>\n cleanContent.startsWith(type),\n )\n ) {\n return 'blob';\n }\n\n if (cleanContent.startsWith('text/')) {\n return 'text';\n }\n\n return;\n};\n\nconst checkForExistence = (\n options: Pick<RequestOptions, 'auth' | 'query'> & {\n headers: Headers;\n },\n name?: string,\n): boolean => {\n if (!name) {\n return false;\n }\n if (\n options.headers.has(name) ||\n options.query?.[name] ||\n options.headers.get('Cookie')?.includes(`${name}=`)\n ) {\n return true;\n }\n return false;\n};\n\nexport const setAuthParams = async ({\n security,\n ...options\n}: Pick<Required<RequestOptions>, 'security'> &\n Pick<RequestOptions, 'auth' | 'query'> & {\n headers: Headers;\n }) => {\n for (const auth of security) {\n if (checkForExistence(options, auth.name)) {\n continue;\n }\n\n const token = await getAuthToken(auth, options.auth);\n\n if (!token) {\n continue;\n }\n\n const name = auth.name ?? 'Authorization';\n\n switch (auth.in) {\n case 'query':\n if (!options.query) {\n options.query = {};\n }\n options.query[name] = token;\n break;\n case 'cookie':\n options.headers.append('Cookie', `${name}=${token}`);\n break;\n case 'header':\n default:\n options.headers.set(name, token);\n break;\n }\n }\n};\n\nexport const buildUrl: Client['buildUrl'] = (options) =>\n getUrl({\n baseUrl: options.baseUrl as string,\n path: options.path,\n query: options.query,\n querySerializer:\n typeof options.querySerializer === 'function'\n ? options.querySerializer\n : createQuerySerializer(options.querySerializer),\n url: options.url,\n });\n\nexport const mergeConfigs = (a: Config, b: Config): Config => {\n const config = { ...a, ...b };\n if (config.baseUrl?.endsWith('/')) {\n config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);\n }\n config.headers = mergeHeaders(a.headers, b.headers);\n return config;\n};\n\nconst headersEntries = (headers: Headers): Array<[string, string]> => {\n const entries: Array<[string, string]> = [];\n headers.forEach((value, key) => {\n entries.push([key, value]);\n });\n return entries;\n};\n\nexport const mergeHeaders = (\n ...headers: Array<Required<Config>['headers'] | undefined>\n): Headers => {\n const mergedHeaders = new Headers();\n for (const header of headers) {\n if (!header) {\n continue;\n }\n\n const iterator =\n header instanceof Headers\n ? headersEntries(header)\n : Object.entries(header);\n\n for (const [key, value] of iterator) {\n if (value === null) {\n mergedHeaders.delete(key);\n } else if (Array.isArray(value)) {\n for (const v of value) {\n mergedHeaders.append(key, v as string);\n }\n } else if (value !== undefined) {\n // assume object headers are meant to be JSON stringified, i.e. their\n // content value in OpenAPI specification is 'application/json'\n mergedHeaders.set(\n key,\n typeof value === 'object' ? JSON.stringify(value) : (value as string),\n );\n }\n }\n }\n return mergedHeaders;\n};\n\ntype ErrInterceptor<Err, Res, Req, Options> = (\n error: Err,\n response: Res,\n request: Req,\n options: Options,\n) => Err | Promise<Err>;\n\ntype ReqInterceptor<Req, Options> = (\n request: Req,\n options: Options,\n) => Req | Promise<Req>;\n\ntype ResInterceptor<Res, Req, Options> = (\n response: Res,\n request: Req,\n options: Options,\n) => Res | Promise<Res>;\n\nclass Interceptors<Interceptor> {\n fns: Array<Interceptor | null> = [];\n\n clear(): void {\n this.fns = [];\n }\n\n eject(id: number | Interceptor): void {\n const index = this.getInterceptorIndex(id);\n if (this.fns[index]) {\n this.fns[index] = null;\n }\n }\n\n exists(id: number | Interceptor): boolean {\n const index = this.getInterceptorIndex(id);\n return Boolean(this.fns[index]);\n }\n\n getInterceptorIndex(id: number | Interceptor): number {\n if (typeof id === 'number') {\n return this.fns[id] ? id : -1;\n }\n return this.fns.indexOf(id);\n }\n\n update(\n id: number | Interceptor,\n fn: Interceptor,\n ): number | Interceptor | false {\n const index = this.getInterceptorIndex(id);\n if (this.fns[index]) {\n this.fns[index] = fn;\n return id;\n }\n return false;\n }\n\n use(fn: Interceptor): number {\n this.fns.push(fn);\n return this.fns.length - 1;\n }\n}\n\nexport interface Middleware<Req, Res, Err, Options> {\n error: Interceptors<ErrInterceptor<Err, Res, Req, Options>>;\n request: Interceptors<ReqInterceptor<Req, Options>>;\n response: Interceptors<ResInterceptor<Res, Req, Options>>;\n}\n\nexport const createInterceptors = <Req, Res, Err, Options>(): Middleware<\n Req,\n Res,\n Err,\n Options\n> => ({\n error: new Interceptors<ErrInterceptor<Err, Res, Req, Options>>(),\n request: new Interceptors<ReqInterceptor<Req, Options>>(),\n response: new Interceptors<ResInterceptor<Res, Req, Options>>(),\n});\n\nconst defaultQuerySerializer = createQuerySerializer({\n allowReserved: false,\n array: {\n explode: true,\n style: 'form',\n },\n object: {\n explode: true,\n style: 'deepObject',\n },\n});\n\nconst defaultHeaders = {\n 'Content-Type': 'application/json',\n};\n\nexport const createConfig = <T extends ClientOptions = ClientOptions>(\n override: Config<Omit<ClientOptions, keyof T> & T> = {},\n): Config<Omit<ClientOptions, keyof T> & T> => ({\n ...jsonBodySerializer,\n headers: defaultHeaders,\n parseAs: 'auto',\n querySerializer: defaultQuerySerializer,\n ...override,\n});\n","import { getResolvedInput, sendRequest } from '@hey-api/json-schema-ref-parser';\n\nimport { mergeHeaders } from '~/plugins/@hey-api/client-fetch/bundle';\nimport type { Input } from '~/types/input';\nimport type { WatchValues } from '~/types/types';\n\ntype SpecResponse = {\n arrayBuffer: ArrayBuffer | undefined;\n error?: never;\n resolvedInput: ReturnType<typeof getResolvedInput>;\n response?: never;\n};\n\ntype SpecError = {\n arrayBuffer?: never;\n error: 'not-modified' | 'not-ok';\n resolvedInput?: never;\n response: Response;\n};\n\n/**\n * @internal\n */\nexport const getSpec = async ({\n fetchOptions,\n inputPath,\n timeout,\n watch,\n}: {\n fetchOptions?: RequestInit;\n inputPath: Input['path'];\n timeout: number | undefined;\n watch: WatchValues;\n}): Promise<SpecResponse | SpecError> => {\n const resolvedInput = getResolvedInput({ pathOrUrlOrSchema: inputPath });\n\n let arrayBuffer: ArrayBuffer | undefined;\n // boolean signals whether the file has **definitely** changed\n let hasChanged: boolean | undefined;\n let response: Response | undefined;\n\n if (resolvedInput.type === 'url') {\n // do NOT send HEAD request on first run or if unsupported\n if (watch.lastValue && watch.isHeadMethodSupported !== false) {\n try {\n const request = await sendRequest({\n fetchOptions: {\n method: 'HEAD',\n ...fetchOptions,\n headers: mergeHeaders(fetchOptions?.headers, watch.headers),\n },\n timeout,\n url: resolvedInput.path,\n });\n\n if (request.response.status >= 300) {\n return {\n error: 'not-ok',\n response: request.response,\n };\n }\n\n response = request.response;\n } catch (error) {\n return {\n error: 'not-ok',\n response: new Response(error.message),\n };\n }\n\n if (!response.ok && watch.isHeadMethodSupported) {\n // assume the server is no longer running\n // do nothing, it might be restarted later\n return {\n error: 'not-ok',\n response,\n };\n }\n\n if (watch.isHeadMethodSupported === undefined) {\n watch.isHeadMethodSupported = response.ok;\n }\n\n if (response.status === 304) {\n return {\n error: 'not-modified',\n response,\n };\n }\n\n if (hasChanged === undefined) {\n const eTag = response.headers.get('ETag');\n if (eTag) {\n hasChanged = eTag !== watch.headers.get('If-None-Match');\n\n if (hasChanged) {\n watch.headers.set('If-None-Match', eTag);\n }\n }\n }\n\n if (hasChanged === undefined) {\n const lastModified = response.headers.get('Last-Modified');\n if (lastModified) {\n hasChanged = lastModified !== watch.headers.get('If-Modified-Since');\n\n if (hasChanged) {\n watch.headers.set('If-Modified-Since', lastModified);\n }\n }\n }\n\n // we definitely know the input has not changed\n if (hasChanged === false) {\n return {\n error: 'not-modified',\n response,\n };\n }\n }\n\n try {\n const request = await sendRequest({\n fetchOptions: {\n method: 'GET',\n ...fetchOptions,\n },\n timeout,\n url: resolvedInput.path,\n });\n\n if (request.response.status >= 300) {\n return {\n error: 'not-ok',\n response: request.response,\n };\n }\n\n response = request.response;\n } catch (error) {\n return {\n error: 'not-ok',\n response: new Response(error.message),\n };\n }\n\n if (!response.ok) {\n // assume the server is no longer running\n // do nothing, it might be restarted later\n return {\n error: 'not-ok',\n response,\n };\n }\n\n arrayBuffer = response.body\n ? await response.arrayBuffer()\n : new ArrayBuffer(0);\n\n if (hasChanged === undefined) {\n const content = new TextDecoder().decode(arrayBuffer);\n hasChanged = content !== watch.lastValue;\n watch.lastValue = content;\n }\n } else {\n // we do not support watch mode for files or raw spec data\n if (!watch.lastValue) {\n watch.lastValue = resolvedInput.type;\n } else {\n hasChanged = false;\n }\n }\n\n if (hasChanged === false) {\n return {\n error: 'not-modified',\n response: response!,\n };\n }\n\n return {\n arrayBuffer,\n resolvedInput,\n };\n};\n","import path from 'node:path';\n\nimport type {\n BiMap,\n Binding,\n File,\n IProject,\n ProjectRenderMeta,\n Renderer,\n Symbol,\n} from '@hey-api/codegen-core';\nimport { createBinding, mergeBindings, renderIds } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport { ensureValidIdentifier } from '~/openApi/shared/utils/identifier';\nimport { $, TsDsl } from '~/ts-dsl';\n\nconst printer = ts.createPrinter({\n newLine: ts.NewLineKind.LineFeed,\n removeComments: false,\n});\n\nconst createSourceFile = (sourceText: string): ts.SourceFile =>\n ts.createSourceFile(\n '',\n sourceText,\n ts.ScriptTarget.ESNext,\n false,\n ts.ScriptKind.TS,\n );\n\nconst blankSourceFile = createSourceFile('');\n\nconst unescapeUnicode = (value: string) =>\n value.replace(/\\\\u([0-9a-fA-F]{4})/g, (_, hex: string) =>\n String.fromCharCode(Number.parseInt(hex, 16)),\n );\n\n/** Print a TypeScript node to a string. */\nfunction nodeToString(node: ts.Node): string {\n const result = printer.printNode(\n ts.EmitHint.Unspecified,\n node,\n blankSourceFile,\n );\n\n try {\n /**\n * TypeScript Compiler API escapes unicode characters by default and there\n * is no way to disable this behavior\n * {@link https://github.com/microsoft/TypeScript/issues/36174}\n */\n return unescapeUnicode(result);\n } catch {\n return result;\n }\n}\n\nconst nodeBuiltins = new Set([\n 'buffer',\n 'child_process',\n 'cluster',\n 'console',\n 'constants',\n 'crypto',\n 'dgram',\n 'dns',\n 'domain',\n 'events',\n 'freelist',\n 'fs',\n 'http',\n 'https',\n 'module',\n 'net',\n 'os',\n 'path',\n 'process',\n 'punycode',\n 'querystring',\n 'readline',\n 'repl',\n 'stream',\n 'string_decoder',\n 'timers',\n 'tls',\n 'tty',\n 'url',\n 'util',\n 'v8',\n 'vm',\n 'worker_threads',\n 'zlib',\n]);\n\nexport class TypeScriptRenderer implements Renderer {\n renderFile(\n symbolsAndExports: string,\n file: File,\n project: IProject,\n meta?: ProjectRenderMeta,\n ): string {\n const imports: Map<string, Binding> = new Map();\n symbolsAndExports = renderIds(symbolsAndExports, (symbolId) => {\n const symbol = project.symbols.get(symbolId);\n const replaced = this.replacerFn({ file, project, symbol });\n if (symbol) {\n this.addBinding({ bindings: imports, file, meta, project, symbol });\n }\n return replaced;\n });\n if (!symbolsAndExports.length) return '';\n let output = '';\n const headerLines = this.getHeaderLines();\n output += `${headerLines.join('\\n')}${headerLines.length ? '\\n\\n' : ''}`;\n const importLines = this.getImportLines(imports, file, project);\n output += `${importLines.join('\\n')}${importLines.length ? '\\n\\n' : ''}`;\n return `${output}${symbolsAndExports}`;\n }\n\n renderSymbols(\n file: File,\n project: IProject,\n meta?: ProjectRenderMeta,\n ): string {\n const exports: Map<string, Binding> = new Map();\n let output = '';\n const bodyLines = this.getBodyLines(file, project);\n output += `${bodyLines.join('\\n\\n')}${bodyLines.length ? '\\n' : ''}`;\n output = renderIds(output, (symbolId) => {\n if (!file.symbols.body.includes(symbolId)) return;\n const symbol = project.symbols.get(symbolId);\n return this.replacerFn({ file, project, symbol });\n });\n for (const symbolId of file.symbols.exports) {\n const symbol = project.symbols.get(symbolId);\n if (symbol) {\n this.addBinding({ bindings: exports, file, meta, project, symbol });\n }\n }\n // cast everything into namespace exports for now\n for (const binding of exports.values()) {\n binding.namespaceBinding = true;\n binding.typeNamespaceBinding =\n binding.names &&\n binding.typeNames &&\n binding.names.length === binding.typeNames.length &&\n binding.names.every((name) => (binding.typeNames ?? []).includes(name));\n }\n const exportLines = this.getExportLines(exports, file, project);\n output += `${exportLines.join('\\n')}${exportLines.length ? '\\n' : ''}`;\n return output;\n }\n\n private addBinding({\n bindings,\n file,\n meta,\n project,\n symbol,\n }: {\n bindings: Map<string, Binding>;\n file: File;\n meta?: ProjectRenderMeta;\n project: IProject;\n symbol: Symbol;\n }): void {\n if (!symbol.external && !project.symbols.hasValue(symbol.id)) {\n return;\n }\n\n const [symbolFile] = project.symbolIdToFiles(symbol.id);\n if (!symbolFile || file === symbolFile) return;\n\n const modulePath = this.getBindingPath(file, symbolFile, meta);\n const existing = bindings.get(modulePath);\n const binding = createBinding({\n file,\n modulePath,\n symbol,\n symbolFile,\n });\n if (existing) {\n mergeBindings(existing, binding);\n bindings.set(modulePath, existing);\n } else {\n bindings.set(modulePath, binding);\n }\n }\n\n private getBindingPath(\n currentFile: File,\n symbolFile: File,\n meta?: ProjectRenderMeta,\n ): string {\n if (!currentFile.path || !symbolFile.path) {\n return '';\n }\n if (symbolFile.external && !path.isAbsolute(symbolFile.path)) {\n return symbolFile.path;\n }\n let relativePath = path.posix.relative(\n path.posix.dirname(\n currentFile.path.split(path.sep).join(path.posix.sep), // normalize to posix\n ),\n symbolFile.path.split(path.sep).join(path.posix.sep), // normalize to posix\n );\n if (!relativePath.startsWith('.') && relativePath !== '') {\n relativePath = `./${relativePath}`;\n }\n if (symbolFile.extension === '.ts') {\n if (relativePath.endsWith(symbolFile.extension)) {\n relativePath = relativePath.slice(0, -symbolFile.extension.length);\n }\n if (meta?.importFileExtension) {\n relativePath += meta.importFileExtension;\n } else if (relativePath.endsWith('/index')) {\n relativePath = relativePath.slice(0, -'/index'.length);\n }\n }\n return relativePath;\n }\n\n private getBodyLine(value: unknown, lines: Array<string>): void {\n if (value instanceof TsDsl) {\n const node = value.$render();\n lines.push(nodeToString(node));\n } else if (typeof value === 'string') {\n lines.push(value);\n } else if (value instanceof Array) {\n for (const node of value) {\n this.getBodyLine(node, lines);\n }\n } else if (value !== undefined && value !== null) {\n lines.push(nodeToString(value as any));\n }\n }\n\n private getBodyLines(file: File, project: IProject): Array<string> {\n const lines: Array<string> = [];\n for (const symbolId of file.symbols.body) {\n this.getBodyLine(project.symbols.getValue(symbolId), lines);\n }\n return lines;\n }\n\n private getExportLines(\n bindings: Map<string, Binding>,\n file: File,\n project: IProject,\n ): Array<string> {\n const lines: Array<string> = [];\n\n for (const [from, value] of bindings.entries()) {\n const specifiers: Array<ts.ExportSpecifier> = [];\n let namespaceBinding: string | undefined;\n let isTypeOnly = false;\n\n if (value.namespaceBinding !== undefined) {\n if (typeof value.namespaceBinding === 'string') {\n namespaceBinding = renderIds(value.namespaceBinding, (symbolId) => {\n const symbol = project.symbols.get(symbolId);\n return this.replacerFn({ file, project, symbol });\n });\n }\n if (value.typeNamespaceBinding) {\n isTypeOnly = true;\n }\n } else if (value.names && value.names.length > 0) {\n if (\n value.names.every((name) => (value.typeNames ?? []).includes(name))\n ) {\n isTypeOnly = true;\n }\n\n for (const name of value.names) {\n const alias = value.aliases?.[name];\n let finalName = name;\n let finalAlias: string | undefined;\n if (alias && alias !== finalName) {\n finalAlias = finalName;\n finalName = alias;\n }\n finalName = renderIds(finalName, (symbolId) => {\n const symbol = project.symbols.get(symbolId);\n const name = this.replacerFn({ file, project, symbol });\n const [symbolFile] = project.symbolIdToFiles(symbolId);\n const sourceName = symbolFile\n ? symbolFile.resolvedNames.get(symbolId)\n : undefined;\n if (sourceName && sourceName !== name) {\n // handle only simple imports for now\n if (!finalAlias) {\n finalAlias = sourceName;\n }\n }\n return name;\n });\n if (finalAlias) {\n finalAlias = renderIds(finalAlias, (symbolId) => {\n const symbol = project.symbols.get(symbolId);\n return this.replacerFn({ file, project, symbol });\n });\n // remove redundant alias\n if (finalAlias === finalName) {\n finalAlias = undefined;\n }\n }\n const specifier = ts.factory.createExportSpecifier(\n isTypeOnly ? false : (value.typeNames?.includes(name) ?? false),\n finalAlias ? $.id(finalAlias).$render() : undefined,\n $.id(finalName).$render(),\n );\n specifiers.push(specifier);\n }\n }\n\n const exportClause = namespaceBinding\n ? ts.factory.createNamespaceExport($.id(namespaceBinding).$render())\n : specifiers.length\n ? ts.factory.createNamedExports(specifiers)\n : undefined;\n\n const node = ts.factory.createExportDeclaration(\n undefined,\n isTypeOnly,\n exportClause,\n $.literal(from).$render(),\n );\n lines.push(nodeToString(node));\n }\n\n return lines;\n }\n\n private getHeaderLines(): Array<string> {\n return ['// This file is auto-generated by @hey-api/openapi-ts'];\n }\n\n private getImportLines(\n bindings: Map<string, Binding>,\n file: File,\n project: IProject,\n ): Array<string> {\n const lines: Array<string> = [];\n\n let lastGroup = -1;\n const importSortKey = (binding: Binding): [number, number, string] => {\n const path = binding.from;\n if (!path.startsWith('.')) {\n // Node.js built-in\n if (nodeBuiltins.has(path.split('/')[0]!)) {\n return [0, 0, path];\n }\n // external package\n return [1, 0, path];\n }\n // sibling relative\n if (path.startsWith('./')) {\n return [2, 0, path];\n }\n // parent relative\n const parentCount = path.match(/\\.\\.\\//g)?.length ?? 0;\n return [2, parentCount, path];\n };\n\n const sortedBindings = Array.from(bindings.values())\n .map((value) => ({\n ...value,\n k: importSortKey(value),\n }))\n .sort(\n (a, b) =>\n a.k[0] - b.k[0] || a.k[1] - b.k[1] || a.k[2].localeCompare(b.k[2]),\n );\n\n for (const value of sortedBindings) {\n let specifiers: Array<ts.ImportSpecifier> = [];\n let defaultBinding: ts.Identifier | undefined;\n let namespaceBinding: string | undefined;\n let isTypeOnly = false;\n\n if (value.defaultBinding) {\n const processedDefaultBinding = renderIds(\n value.defaultBinding,\n (symbolId) => {\n const symbol = project.symbols.get(symbolId);\n return this.replacerFn({ file, project, symbol });\n },\n );\n defaultBinding = $.id(processedDefaultBinding).$render();\n if (value.typeDefaultBinding) {\n isTypeOnly = true;\n }\n } else if (typeof value.namespaceBinding === 'string') {\n namespaceBinding = renderIds(value.namespaceBinding, (symbolId) => {\n const symbol = project.symbols.get(symbolId);\n return this.replacerFn({ file, project, symbol });\n });\n if (value.typeNamespaceBinding) {\n isTypeOnly = true;\n }\n } else if (value.names && value.names.length > 0) {\n if (value.names.every((name) => value.typeNames?.includes(name))) {\n isTypeOnly = true;\n }\n\n const namedImports: Array<{\n isTypeOnly: boolean;\n name: string;\n propertyName: ts.ModuleExportName | undefined;\n }> = [];\n\n for (const name of value.names) {\n const alias = value.aliases?.[name];\n let finalName = name;\n let finalAlias: string | undefined;\n if (alias && alias !== finalName) {\n finalAlias = finalName;\n finalName = alias;\n }\n finalName = renderIds(finalName, (symbolId) => {\n const symbol = project.symbols.get(symbolId);\n const name = this.replacerFn({ file, project, symbol });\n const [symbolFile] = project.symbolIdToFiles(symbolId);\n const sourceName = symbolFile\n ? symbolFile.resolvedNames.get(symbolId)\n : undefined;\n if (sourceName && sourceName !== name) {\n // handle only simple imports for now\n if (!finalAlias) {\n finalAlias = sourceName;\n }\n }\n return name;\n });\n if (finalAlias) {\n finalAlias = renderIds(finalAlias, (symbolId) => {\n const symbol = project.symbols.get(symbolId);\n return this.replacerFn({ file, project, symbol });\n });\n // remove redundant alias\n if (finalAlias === finalName) {\n finalAlias = undefined;\n }\n }\n namedImports.push({\n isTypeOnly: isTypeOnly\n ? false\n : (value.typeNames?.includes(name) ?? false),\n name: finalName,\n propertyName: finalAlias ? $.id(finalAlias).$render() : undefined,\n });\n }\n\n specifiers = namedImports\n .sort((a, b) => a.name.localeCompare(b.name))\n .map(({ isTypeOnly, name, propertyName }) =>\n ts.factory.createImportSpecifier(\n isTypeOnly,\n propertyName,\n $.id(name).$render(),\n ),\n );\n }\n\n const importClause = ts.factory.createImportClause(\n isTypeOnly,\n defaultBinding,\n namespaceBinding\n ? ts.factory.createNamespaceImport($.id(namespaceBinding).$render())\n : specifiers.length\n ? ts.factory.createNamedImports(specifiers)\n : undefined,\n );\n\n const node = ts.factory.createImportDeclaration(\n undefined,\n importClause,\n $.literal(value.from).$render(),\n );\n\n if (lastGroup !== -1 && value.k[0] !== lastGroup) {\n lines.push(''); // add empty line between groups\n }\n\n lines.push(nodeToString(node));\n lastGroup = value.k[0];\n }\n\n return lines;\n }\n\n private getUniqueName(base: string, names: BiMap<number, string>): string {\n let index = 2;\n let name = base;\n while (names.hasValue(name)) {\n name = `${base}${index}`;\n index += 1;\n }\n return name;\n }\n\n private replacerFn({\n file,\n project,\n symbol,\n }: {\n file: File;\n project: IProject;\n symbol: Symbol | undefined;\n }): string | undefined {\n if (!symbol) return;\n const cached = file.resolvedNames.get(symbol.id);\n if (cached) return cached;\n if (!symbol.name) return;\n const [symbolFile] = project.symbolIdToFiles(symbol.id);\n const symbolFileResolvedName = symbolFile?.resolvedNames.get(symbol.id);\n let name = ensureValidIdentifier(symbolFileResolvedName ?? symbol.name);\n const conflictId = file.resolvedNames.getKey(name);\n if (conflictId !== undefined) {\n const conflictSymbol = project.symbols.get(conflictId);\n if (conflictSymbol) {\n const kinds = [conflictSymbol.kind, symbol.kind];\n if (\n kinds.every((kind) => kind === 'type') ||\n kinds.every((kind) => kind !== 'type') ||\n // avoid conflicts between class and type of the same name\n (kinds.includes('class') && kinds.includes('type'))\n ) {\n name = this.getUniqueName(name, file.resolvedNames);\n }\n }\n }\n file.resolvedNames.set(symbol.id, name);\n return name;\n }\n}\n","export class MinHeap {\n private heap: Array<string> = [];\n\n constructor(public declIndex: Map<string, number>) {}\n\n isEmpty(): boolean {\n return !this.heap.length;\n }\n\n pop(): string | undefined {\n const [top] = this.heap;\n if (!this.heap.length) return;\n const last = this.heap.pop()!;\n if (!this.heap.length) return top;\n this.heap[0] = last;\n this.sinkDown(0);\n return top;\n }\n\n push(item: string): void {\n this.heap.push(item);\n this.bubbleUp(this.heap.length - 1);\n }\n\n private bubbleUp(index: number): void {\n const heap = this.heap;\n while (index > 0) {\n const parent = Math.floor((index - 1) / 2);\n const parentVal = heap[parent]!;\n const curVal = heap[index]!;\n if (this.declIndex.get(parentVal)! <= this.declIndex.get(curVal)!) break;\n heap[parent] = curVal;\n heap[index] = parentVal;\n index = parent;\n }\n }\n\n private sinkDown(index: number): void {\n const heap = this.heap;\n const len = heap.length;\n while (true) {\n const left = 2 * index + 1;\n const right = 2 * index + 2;\n let smallest = index;\n if (left < len) {\n const leftVal = heap[left]!;\n const smallestVal = heap[smallest]!;\n if (this.declIndex.get(leftVal)! < this.declIndex.get(smallestVal)!)\n smallest = left;\n }\n if (right < len) {\n const rightVal = heap[right]!;\n const smallestVal = heap[smallest]!;\n if (this.declIndex.get(rightVal)! < this.declIndex.get(smallestVal)!)\n smallest = right;\n }\n if (smallest === index) break;\n const tmp = heap[smallest]!;\n heap[smallest] = heap[index]!;\n heap[index] = tmp;\n index = smallest;\n }\n }\n}\n","import { MinHeap } from '~/utils/minHeap';\n\nimport type { GetPointerPriorityFn, WalkFn } from './types/walk';\n\n/**\n * Walk the nodes of the graph in declaration (insertion) order.\n * This is a cheap alternative to `walkTopological` when dependency ordering\n * is not required and the caller only wants nodes in the order they were\n * added to the graph.\n */\nconst walkDeclarations: WalkFn = (graph, callback, options) => {\n const pointers = Array.from(graph.nodes.keys());\n\n if (options?.preferGroups && options.preferGroups.length > 0) {\n // emit nodes that match each preferred group in order, preserving insertion order\n const emitted = new Set<string>();\n if (options.matchPointerToGroup) {\n for (const kind of options.preferGroups) {\n for (const pointer of pointers) {\n const result = options.matchPointerToGroup(pointer);\n if (!result.matched) continue;\n if (result.kind === kind) {\n emitted.add(pointer);\n callback(pointer, graph.nodes.get(pointer)!);\n }\n }\n }\n }\n\n // emit anything not covered by the preferGroups (in declaration order)\n for (const pointer of pointers) {\n if (emitted.has(pointer)) continue;\n callback(pointer, graph.nodes.get(pointer)!);\n }\n return;\n }\n\n // fallback: simple declaration order\n for (const pointer of pointers) {\n callback(pointer, graph.nodes.get(pointer)!);\n }\n};\n\n/**\n * Walks the nodes of the graph in topological order (dependencies before dependents).\n * Calls the callback for each node pointer in order.\n * Nodes in cycles are grouped together and emitted in arbitrary order within the group.\n *\n * @param graph - The dependency graph\n * @param callback - Function to call for each node pointer\n */\nconst walkTopological: WalkFn = (graph, callback, options) => {\n // stable Kahn's algorithm that respects declaration order as a tiebreaker.\n const pointers = Array.from(graph.nodes.keys());\n // base insertion order\n const baseIndex = new Map<string, number>();\n pointers.forEach((pointer, index) => baseIndex.set(pointer, index));\n\n // composite decl index: group priority then base insertion order\n const declIndex = new Map<string, number>();\n for (const pointer of pointers) {\n const priority = options?.getPointerPriority?.(pointer) ?? 10;\n const composite = priority * 1_000_000 + (baseIndex.get(pointer) ?? 0);\n declIndex.set(pointer, composite);\n }\n\n // build dependency sets for each pointer\n const depsOf = new Map<string, Set<string>>();\n for (const pointer of pointers) {\n const raw = graph.subtreeDependencies?.get(pointer) ?? new Set();\n const filtered = new Set<string>();\n for (const rawPointer of raw) {\n if (rawPointer === pointer) continue; // ignore self-dependencies for ordering\n if (graph.nodes.has(rawPointer)) {\n filtered.add(rawPointer);\n }\n }\n depsOf.set(pointer, filtered);\n }\n\n // build inDegree and dependents adjacency\n const inDegree = new Map<string, number>();\n const dependents = new Map<string, Set<string>>();\n for (const pointer of pointers) {\n inDegree.set(pointer, 0);\n }\n for (const [pointer, deps] of depsOf) {\n inDegree.set(pointer, deps.size);\n for (const d of deps) {\n if (!dependents.has(d)) {\n dependents.set(d, new Set());\n }\n dependents.get(d)!.add(pointer);\n }\n }\n\n // sort pointers by declaration order\n const sortByDecl = (arr: Array<string>) =>\n arr.sort((a, b) => declIndex.get(a)! - declIndex.get(b)!);\n\n // initialize queue with zero-inDegree nodes in declaration order\n // use min-heap prioritized by declaration index to avoid repeated full sorts\n const heap = new MinHeap(declIndex);\n for (const pointer of pointers) {\n if ((inDegree.get(pointer) ?? 0) === 0) {\n heap.push(pointer);\n }\n }\n\n const emitted = new Set<string>();\n const order: Array<string> = [];\n\n while (!heap.isEmpty()) {\n const cur = heap.pop()!;\n if (emitted.has(cur)) continue;\n emitted.add(cur);\n order.push(cur);\n\n const deps = dependents.get(cur);\n if (!deps) continue;\n\n for (const dep of deps) {\n const v = (inDegree.get(dep) ?? 0) - 1;\n inDegree.set(dep, v);\n if (v === 0) {\n heap.push(dep);\n }\n }\n }\n\n // emit remaining nodes (cycles) in declaration order\n const remaining = pointers.filter((pointer) => !emitted.has(pointer));\n sortByDecl(remaining);\n for (const pointer of remaining) {\n emitted.add(pointer);\n order.push(pointer);\n }\n\n // prefer specified groups when safe\n let finalOrder = order;\n if (options?.preferGroups && options.preferGroups.length > 0) {\n // build group priority map (lower = earlier)\n const groupPriority = new Map<string, number>();\n for (let i = 0; i < options.preferGroups.length; i++) {\n const k = options.preferGroups[i];\n if (k) {\n groupPriority.set(k, i);\n }\n }\n\n const getGroup: GetPointerPriorityFn = (pointer) => {\n if (options.matchPointerToGroup) {\n const result = options.matchPointerToGroup(pointer);\n if (result.matched) {\n return groupPriority.has(result.kind)\n ? groupPriority.get(result.kind)!\n : options.preferGroups!.length;\n }\n }\n return options.preferGroups!.length;\n };\n\n // proposed order: sort by (groupPriority, originalIndex)\n const proposed = [...order].sort((a, b) => {\n const ga = getGroup(a);\n const gb = getGroup(b);\n return ga !== gb ? ga - gb : order.indexOf(a) - order.indexOf(b);\n });\n\n // build quick lookup of original index and proposed index\n const proposedIndex = new Map<string, number>();\n for (let i = 0; i < proposed.length; i++) {\n proposedIndex.set(proposed[i]!, i);\n }\n\n // only validate edges where group(dep) > group(node)\n const violated = (() => {\n for (const [node, deps] of depsOf) {\n for (const dep of deps) {\n const gDep = getGroup(dep);\n const gNode = getGroup(node);\n if (gDep <= gNode) continue; // not a crossing edge, cannot be violated by grouping\n const pDep = proposedIndex.get(dep)!;\n const pNode = proposedIndex.get(node)!;\n if (pDep >= pNode) {\n return true;\n }\n }\n }\n return false;\n })();\n\n if (!violated) {\n finalOrder = proposed;\n }\n }\n\n for (const pointer of finalOrder) {\n callback(pointer, graph.nodes.get(pointer)!);\n }\n};\n\nexport const walk: WalkFn = (graph, callback, options) => {\n if (options?.order === 'topological') {\n return walkTopological(graph, callback, options);\n }\n return walkDeclarations(graph, callback, options);\n};\n","import type { GetPointerPriorityFn, MatchPointerToGroupFn } from '~/graph';\n\nexport const irTopLevelKinds = [\n 'operation',\n 'parameter',\n 'requestBody',\n 'schema',\n 'server',\n 'webhook',\n] as const;\n\nexport type IrTopLevelKind = (typeof irTopLevelKinds)[number];\n\n/**\n * Checks if a pointer matches a known top-level IR component (schema, parameter, etc) and returns match info.\n *\n * @param pointer - The IR pointer string (e.g. '#/components/schemas/Foo')\n * @param kind - (Optional) The component kind to check\n * @returns { matched: true, kind: IrTopLevelKind } | { matched: false } - Whether it matched, and the matched kind if so\n */\nexport const matchIrPointerToGroup: MatchPointerToGroupFn<IrTopLevelKind> = (\n pointer,\n kind,\n) => {\n const patterns: Record<IrTopLevelKind, RegExp> = {\n operation:\n /^#\\/paths\\/[^/]+\\/(get|put|post|delete|options|head|patch|trace)$/,\n parameter: /^#\\/components\\/parameters\\/[^/]+$/,\n requestBody: /^#\\/components\\/requestBodies\\/[^/]+$/,\n schema: /^#\\/components\\/schemas\\/[^/]+$/,\n server: /^#\\/servers\\/(\\d+|[^/]+)$/,\n webhook:\n /^#\\/webhooks\\/[^/]+\\/(get|put|post|delete|options|head|patch|trace)$/,\n };\n if (kind) {\n return patterns[kind].test(pointer)\n ? { kind, matched: true }\n : { matched: false };\n }\n for (const key of Object.keys(patterns)) {\n const kind = key as IrTopLevelKind;\n if (patterns[kind].test(pointer)) {\n return { kind, matched: true };\n }\n }\n return { matched: false };\n};\n\n// default grouping preference (earlier groups emitted first when safe)\nexport const preferGroups = [\n 'server',\n 'schema',\n 'parameter',\n 'requestBody',\n 'operation',\n 'webhook',\n] satisfies ReadonlyArray<IrTopLevelKind>;\n\ntype KindPriority = Record<IrTopLevelKind, number>;\n\n// default group priority (lower = earlier)\n// built from `preferGroups` so the priority order stays in sync with the prefer-groups array.\nconst kindPriority: KindPriority = (() => {\n const partial: Partial<KindPriority> = {};\n for (let i = 0; i < preferGroups.length; i++) {\n const k = preferGroups[i];\n if (k) partial[k] = i;\n }\n // Ensure all known kinds exist in the map (fall back to a high index).\n for (const k of irTopLevelKinds) {\n if (partial[k] === undefined) {\n partial[k] = preferGroups.length;\n }\n }\n return partial as KindPriority;\n})();\n\nconst defaultPriority = 10;\n\nexport const getIrPointerPriority: GetPointerPriorityFn = (pointer) => {\n const result = matchIrPointerToGroup(pointer);\n if (result.matched) {\n return kindPriority[result.kind] ?? defaultPriority;\n }\n return defaultPriority;\n};\n","import path from 'node:path';\n\nimport type {\n IProject,\n Symbol,\n SymbolIdentifier,\n SymbolIn,\n SymbolMeta,\n} from '@hey-api/codegen-core';\n\nimport { HeyApiError } from '~/error';\nimport type { MatchPointerToGroupFn, WalkOptions } from '~/graph';\nimport { walk } from '~/graph';\nimport type { Context } from '~/ir/context';\nimport type { IrTopLevelKind } from '~/ir/graph';\nimport {\n getIrPointerPriority,\n irTopLevelKinds,\n matchIrPointerToGroup,\n preferGroups,\n} from '~/ir/graph';\nimport type { IR } from '~/ir/types';\nimport type { OpenApi } from '~/openApi/types';\nimport type { Hooks } from '~/parser/types/hooks';\nimport type { Plugin } from '~/plugins';\nimport type { PluginConfigMap } from '~/plugins/config';\nimport { jsonPointerToPath } from '~/utils/ref';\n\nimport type { BaseEvent, WalkEvent } from '../types/instance';\n\nconst defaultGetFilePath = (symbol: Symbol): string | undefined => {\n if (!symbol.meta?.pluginName || typeof symbol.meta.pluginName !== 'string') {\n return;\n }\n if (symbol.meta.pluginName.startsWith('@hey-api/client-')) {\n return 'client';\n }\n if (symbol.meta.pluginName === '@hey-api/typescript') {\n return 'types';\n }\n if (symbol.meta.pluginName.startsWith('@hey-api/')) {\n return symbol.meta.pluginName.split('/')[1];\n }\n return symbol.meta.pluginName;\n};\n\nconst defaultGetKind: Required<Required<Hooks>['operations']>['getKind'] = (\n operation,\n) => {\n switch (operation.method) {\n case 'delete':\n case 'patch':\n case 'post':\n case 'put':\n return ['mutation'];\n case 'get':\n return ['query'];\n default:\n return;\n }\n};\n\ntype EventHooks = {\n [K in keyof Required<NonNullable<Hooks['events']>>]: Array<\n NonNullable<NonNullable<Hooks['events']>[K]>\n >;\n};\n\nexport class PluginInstance<T extends Plugin.Types = Plugin.Types> {\n api: T['api'];\n config: Omit<T['resolvedConfig'], 'name'>;\n context: Context;\n dependencies: Required<Plugin.Config<T>>['dependencies'] = [];\n private eventHooks: EventHooks;\n gen: IProject;\n private handler: Plugin.Config<T>['handler'];\n name: T['resolvedConfig']['name'];\n /**\n * The package metadata and utilities for the current context, constructed\n * from the provided dependencies. Used for managing package-related\n * information such as name, version, and dependency resolution during\n * code generation.\n */\n package: Context['package'];\n\n constructor(\n props: Pick<\n Required<Plugin.Config<T>>,\n 'config' | 'dependencies' | 'handler'\n > & {\n api?: T['api'];\n context: Context<OpenApi.V2_0_X | OpenApi.V3_0_X | OpenApi.V3_1_X>;\n gen: IProject;\n name: string;\n },\n ) {\n this.api = props.api ?? {};\n this.config = props.config;\n this.context = props.context;\n this.dependencies = props.dependencies;\n this.eventHooks = this.buildEventHooks();\n this.gen = props.gen;\n this.handler = props.handler;\n this.name = props.name;\n this.package = props.context.package;\n }\n\n /**\n * Iterates over various input elements as specified by the event types, in\n * a specific order: servers, schemas, parameters, request bodies, then\n * operations.\n *\n * This ensures, for example, that schemas are always processed before\n * operations, which may reference them.\n *\n * @template TKind - The event type(s) to yield. Defaults to all event types.\n * @param events - The event types to walk over. If none are provided, all event types are included.\n * @param callback - Function to execute for each event.\n *\n * @example\n * // Iterate over all operations and schemas\n * plugin.forEach('operation', 'schema', (event) => {\n * if (event.type === 'operation') {\n * // handle operation\n * } else if (event.type === 'schema') {\n * // handle schema\n * }\n * });\n */\n forEach<TKind extends IrTopLevelKind = IrTopLevelKind>(\n ...args: [\n ...events: ReadonlyArray<TKind>,\n callback: (event: WalkEvent<TKind>) => void,\n ]\n ): void;\n forEach<TKind extends IrTopLevelKind = IrTopLevelKind>(\n ...args: [\n ...events: ReadonlyArray<TKind>,\n callback: (event: WalkEvent<TKind>) => void,\n options: WalkOptions<TKind>,\n ]\n ): void;\n forEach<TKind extends IrTopLevelKind = IrTopLevelKind>(\n ...args: [\n ...events: ReadonlyArray<TKind>,\n callback: (event: WalkEvent<TKind>) => void,\n options: any,\n ]\n ): void {\n if (!this.context.graph) {\n throw new Error('No graph available in context');\n }\n\n let callback: (event: WalkEvent<TKind>) => void;\n let events: ReadonlyArray<TKind>;\n let options: WalkOptions<TKind> = {\n getPointerPriority: getIrPointerPriority,\n // default functions operate on the full union of kinds; cast them\n // to the WalkOptions generic to keep strict typing for callers.\n matchPointerToGroup:\n matchIrPointerToGroup as unknown as MatchPointerToGroupFn<TKind>,\n order: 'topological',\n preferGroups: preferGroups as unknown as ReadonlyArray<TKind>,\n };\n if (typeof args[args.length - 1] === 'function') {\n events = args.slice(0, -1);\n callback = args[args.length - 1];\n } else {\n events = args.slice(0, -2);\n callback = args[args.length - 2];\n options = {\n ...options,\n ...args[args.length - 1],\n };\n }\n const eventSet = new Set(events.length ? events : irTopLevelKinds);\n\n walk(\n this.context.graph,\n (pointer, nodeInfo) => {\n const result = matchIrPointerToGroup(pointer);\n if (!result.matched || !eventSet.has(result.kind)) return;\n let event: WalkEvent | undefined;\n const baseEvent: BaseEvent = {\n _path: jsonPointerToPath(pointer),\n pointer,\n tags: nodeInfo.tags ? Array.from(nodeInfo.tags) : undefined,\n };\n switch (result.kind) {\n case 'operation':\n event = {\n ...baseEvent,\n method: nodeInfo.key as keyof IR.PathItemObject,\n operation: nodeInfo.node as IR.OperationObject,\n path: baseEvent._path[1] as string,\n type: result.kind,\n } satisfies WalkEvent<'operation'>;\n break;\n case 'parameter':\n event = {\n ...baseEvent,\n name: nodeInfo.key as string,\n parameter: nodeInfo.node as IR.ParameterObject,\n type: result.kind,\n } satisfies WalkEvent<'parameter'>;\n break;\n case 'requestBody':\n event = {\n ...baseEvent,\n name: nodeInfo.key as string,\n requestBody: nodeInfo.node as IR.RequestBodyObject,\n type: result.kind,\n } satisfies WalkEvent<'requestBody'>;\n break;\n case 'schema':\n event = {\n ...baseEvent,\n name: nodeInfo.key as string,\n schema: nodeInfo.node as IR.SchemaObject,\n type: result.kind,\n } satisfies WalkEvent<'schema'>;\n break;\n case 'server':\n event = {\n ...baseEvent,\n server: nodeInfo.node as IR.ServerObject,\n type: result.kind,\n } satisfies WalkEvent<'server'>;\n break;\n case 'webhook':\n event = {\n ...baseEvent,\n key: baseEvent._path[1] as string,\n method: nodeInfo.key as keyof IR.PathItemObject,\n operation: nodeInfo.node as IR.OperationObject,\n type: result.kind,\n } satisfies WalkEvent<'webhook'>;\n break;\n }\n if (event) {\n try {\n callback(event as WalkEvent<TKind>);\n } catch (error) {\n this.forEachError(error, event);\n }\n }\n },\n options,\n );\n }\n\n /**\n * Retrieves a registered plugin instance by its name from the context. This\n * allows plugins to access other plugins that have been registered in the\n * same context, enabling cross-plugin communication and dependencies.\n *\n * @param name Plugin name as defined in the configuration.\n * @returns The plugin instance if found, undefined otherwise.\n */\n getPlugin<TName extends keyof PluginConfigMap>(\n name: TName,\n ): TName extends any\n ? PluginInstance<PluginConfigMap[TName]> | undefined\n : never {\n return this.context.plugins[name] as any;\n }\n\n /**\n * Retrieves a registered plugin instance by its name from the context. This\n * allows plugins to access other plugins that have been registered in the\n * same context, enabling cross-plugin communication and dependencies.\n *\n * @param name Plugin name as defined in the configuration.\n * @returns The plugin instance if found, throw otherwise.\n */\n getPluginOrThrow<TName extends keyof PluginConfigMap>(\n name: TName,\n ): TName extends any ? PluginInstance<PluginConfigMap[TName]> : never {\n const plugin = this.getPlugin(name);\n if (!plugin) throw new Error(`plugin not found ${name}`);\n return plugin as any;\n }\n\n getSymbol(identifier: SymbolIdentifier): Symbol | undefined {\n return this.gen.symbols.get(identifier);\n }\n\n hooks = {\n operation: {\n isMutation: (operation: IR.OperationObject): boolean =>\n this.isOperationKind(operation, 'mutation'),\n isQuery: (operation: IR.OperationObject): boolean =>\n this.isOperationKind(operation, 'query'),\n },\n };\n\n isSymbolRegistered(identifier: SymbolIdentifier): boolean {\n return this.gen.symbols.isRegistered(identifier);\n }\n\n querySymbol(filter: SymbolMeta): Symbol | undefined {\n return this.gen.symbols.query(filter)[0];\n }\n\n referenceSymbol(meta: SymbolMeta): Symbol {\n return this.gen.symbols.reference(meta);\n }\n\n registerSymbol(symbol: SymbolIn): Symbol {\n const symbolIn: SymbolIn = {\n ...symbol,\n exportFrom:\n symbol.exportFrom ??\n (!symbol.external &&\n this.context.config.output.indexFile &&\n this.config.exportFromIndex\n ? ['index']\n : undefined),\n getFilePath: symbol.getFilePath ?? this.getSymbolFilePath.bind(this),\n meta: {\n pluginName: path.isAbsolute(this.name) ? 'custom' : this.name,\n ...symbol.meta,\n },\n };\n for (const hook of this.eventHooks['symbol:register:before']) {\n hook({ plugin: this, symbol: symbolIn });\n }\n const symbolOut = this.gen.symbols.register(symbolIn);\n for (const hook of this.eventHooks['symbol:register:after']) {\n hook({ plugin: this, symbol: symbolOut });\n }\n return symbolOut;\n }\n\n /**\n * Executes plugin's handler function.\n */\n async run(): Promise<void> {\n for (const hook of this.eventHooks['plugin:handler:before']) {\n hook({ plugin: this });\n }\n await this.handler({ plugin: this });\n for (const hook of this.eventHooks['plugin:handler:after']) {\n hook({ plugin: this });\n }\n }\n\n setSymbolValue(symbol: Symbol, value: unknown): void {\n for (const hook of this.eventHooks['symbol:setValue:before']) {\n hook({ plugin: this, symbol, value });\n }\n this.gen.symbols.setValue(symbol.id, value);\n for (const hook of this.eventHooks['symbol:setValue:after']) {\n hook({ plugin: this, symbol, value });\n }\n }\n\n private buildEventHooks(): EventHooks {\n const result: EventHooks = {\n 'plugin:handler:after': [],\n 'plugin:handler:before': [],\n 'symbol:register:after': [],\n 'symbol:register:before': [],\n 'symbol:setValue:after': [],\n 'symbol:setValue:before': [],\n };\n const scopes = [\n this.config['~hooks']?.events,\n this.context.config.parser.hooks.events,\n ];\n for (const scope of scopes) {\n if (!scope) continue;\n for (const [key, value] of Object.entries(scope)) {\n if (value) {\n result[key as keyof typeof result].push(value.bind(scope) as any);\n }\n }\n }\n return result;\n }\n\n private forEachError(error: unknown, event: WalkEvent) {\n const originalError =\n error instanceof Error ? error : new Error(String(error));\n throw new HeyApiError({\n args: [event],\n error: originalError,\n event: event.type,\n name: 'Error',\n pluginName: this.name,\n });\n }\n\n private getSymbolFilePath(symbol: Symbol): string | undefined {\n const hooks = [\n this.config['~hooks']?.symbols,\n this.context.config.parser.hooks.symbols,\n ];\n for (const hook of hooks) {\n const result = hook?.getFilePath?.(symbol);\n if (result !== undefined) return result;\n }\n return defaultGetFilePath(symbol);\n }\n\n private isOperationKind(\n operation: IR.OperationObject,\n kind: 'mutation' | 'query',\n ): boolean {\n const method = kind === 'query' ? 'isQuery' : 'isMutation';\n const hooks = [\n this.config['~hooks']?.operations?.[method],\n this.config['~hooks']?.operations?.getKind,\n this.context.config.parser.hooks.operations?.[method],\n this.context.config.parser.hooks.operations?.getKind,\n defaultGetKind,\n ];\n for (const hook of hooks) {\n if (hook) {\n const result = hook(operation);\n if (result !== undefined) {\n return typeof result === 'boolean' ? result : result.includes(kind);\n }\n }\n }\n return false;\n }\n}\n","import { Project } from '@hey-api/codegen-core';\n\nimport type { Package } from '~/config/utils/package';\nimport { packageFactory } from '~/config/utils/package';\nimport { TypeScriptRenderer } from '~/generate/renderer';\nimport type { Graph } from '~/graph';\nimport { buildName } from '~/openApi/shared/utils/name';\nimport type { PluginConfigMap } from '~/plugins/config';\nimport { PluginInstance } from '~/plugins/shared/utils/instance';\nimport type { PluginNames } from '~/plugins/types';\nimport type { Config } from '~/types/config';\nimport type { Logger } from '~/utils/logger';\nimport { resolveRef } from '~/utils/ref';\n\nimport type { IR } from './types';\n\nexport class Context<Spec extends Record<string, any> = any> {\n /**\n * Configuration for parsing and generating the output. This\n * is a mix of user-provided and default values.\n */\n config: Config;\n /**\n * The code generation project instance used to manage files, symbols,\n */\n gen: Project;\n /**\n * The dependency graph built from the intermediate representation.\n */\n graph: Graph | undefined;\n /**\n * Intermediate representation model obtained from `spec`.\n */\n ir: IR.Model = {};\n /**\n * Logger instance.\n */\n logger: Logger;\n /**\n * The package metadata and utilities for the current context, constructed\n * from the provided dependencies. Used for managing package-related\n * information such as name, version, and dependency resolution during\n * code generation.\n */\n package: Package;\n /**\n * A map of registered plugin instances, keyed by plugin name. Plugins are\n * registered through the `registerPlugin` method and can be accessed by\n * their configured name from the config.\n */\n plugins: Partial<\n Record<PluginNames, PluginInstance<PluginConfigMap[keyof PluginConfigMap]>>\n > = {};\n /**\n * Resolved specification from `input`.\n */\n spec: Spec;\n\n constructor({\n config,\n dependencies,\n logger,\n spec,\n }: {\n config: Config;\n dependencies: Record<string, string>;\n logger: Logger;\n spec: Spec;\n }) {\n this.config = config;\n this.gen = new Project({\n defaultFileName: 'index',\n fileName: (base) => {\n const name = buildName({\n config: config.output.fileName,\n name: base,\n });\n const { suffix } = config.output.fileName;\n if (!suffix) {\n return name;\n }\n return name === 'index' || name.endsWith(suffix)\n ? name\n : `${name}${suffix}`;\n },\n renderers: {\n // TODO: allow overriding via config with custom renderers\n '.ts': new TypeScriptRenderer(),\n },\n root: config.output.path,\n });\n this.logger = logger;\n this.package = packageFactory(dependencies);\n this.spec = spec;\n }\n\n /**\n * Returns a resolved and dereferenced schema from `spec`.\n */\n dereference<T>(schema: { $ref: string }) {\n const resolved = this.resolveRef<T>(schema.$ref);\n const dereferenced = {\n ...schema,\n ...resolved,\n } as T;\n // @ts-expect-error\n delete dereferenced.$ref;\n return dereferenced;\n }\n\n /**\n * Registers a new plugin to the global context.\n *\n * @param name Plugin name.\n * @returns Registered plugin instance.\n */\n private registerPlugin<T extends PluginNames>(\n name: T,\n ): PluginInstance<PluginConfigMap[T]> {\n const plugin = this.config.plugins[name]!;\n const instance = new PluginInstance({\n api: plugin.api,\n config: plugin.config as any,\n context: this as any,\n dependencies: plugin.dependencies ?? [],\n gen: this.gen,\n handler: plugin.handler,\n name: plugin.name,\n });\n this.plugins[instance.name] = instance;\n return instance;\n }\n\n /**\n * Registers all plugins in the order specified by the configuration and returns\n * an array of the registered PluginInstance objects. Each plugin is instantiated\n * and added to the context's plugins map.\n *\n * @returns {ReadonlyArray<PluginInstance>} An array of registered plugin instances in order.\n */\n registerPlugins(): ReadonlyArray<PluginInstance> {\n return this.config.pluginOrder.map((name) => this.registerPlugin(name));\n }\n\n // TODO: parser - works the same as resolveRef, but for IR schemas.\n // for now, they map 1:1, but if they diverge (like with OpenAPI 2.0),\n // we will want to rewrite $refs at parse time, so they continue pointing\n // to the correct IR location\n resolveIrRef<T>($ref: string) {\n return resolveRef<T>({\n $ref,\n spec: this.ir,\n });\n }\n\n /**\n * Returns a resolved reference from `spec`.\n */\n resolveRef<T>($ref: string) {\n return resolveRef<T>({\n $ref,\n spec: this.spec,\n });\n }\n}\n","import type { Context } from '~/ir/context';\nimport { createOperationKey } from '~/ir/operation';\nimport { sanitizeNamespaceIdentifier } from '~/openApi/common/parser/sanitize';\nimport { stringCase } from '~/utils/stringCase';\n\nimport type { State } from '../types/state';\n\nexport const httpMethods = [\n 'delete',\n 'get',\n 'head',\n 'options',\n 'patch',\n 'post',\n 'put',\n 'trace',\n] as const;\n\n/**\n * Returns an operation ID to use across the application. By default, we try\n * to use the provided ID. If it's not provided or the SDK is configured\n * to exclude it, we generate operation ID from its location.\n */\nexport const operationToId = ({\n context,\n count = 1,\n id,\n method,\n path,\n state,\n}: {\n context: Context;\n count?: number;\n id: string | undefined;\n method: string;\n path: string;\n state: Pick<State, 'ids'>;\n}): string => {\n let result: string;\n\n const { output } = context.config;\n const targetCase =\n (output !== undefined && typeof output === 'object' && 'case' in output\n ? output.case\n : undefined) ?? 'camelCase';\n\n if (\n id &&\n (!context.config.plugins['@hey-api/sdk'] ||\n context.config.plugins['@hey-api/sdk'].config.operationId)\n ) {\n result = stringCase({\n case: targetCase,\n value: sanitizeNamespaceIdentifier(id),\n });\n } else {\n const pathWithoutPlaceholders = path\n .replace(/{(.*?)}/g, 'by-$1')\n // replace slashes with hyphens for camelcase method at the end\n .replace(/[/:+]/g, '-');\n\n result = stringCase({\n case: targetCase,\n value: `${method}-${pathWithoutPlaceholders}`,\n });\n }\n\n if (count > 1) {\n result = `${result}${count}`;\n }\n\n if (state.ids.has(result)) {\n return operationToId({\n context,\n count: count + 1,\n id,\n method,\n path,\n state,\n });\n }\n\n state.ids.set(result, createOperationKey({ method, path }));\n\n return result;\n};\n","import { createOperationKey } from '~/ir/operation';\nimport type { PathItemObject, PathsObject } from '~/openApi/3.1.x/types/spec';\nimport type { OpenApi } from '~/openApi/types';\nimport type { Logger } from '~/utils/logger';\n\nimport type { Config } from '../../../types/config';\nimport type { ResourceMetadata } from '../graph/meta';\nimport { httpMethods } from './operation';\n\ntype FilterNamespace =\n | 'body'\n | 'operation'\n | 'parameter'\n | 'response'\n | 'schema'\n | 'unknown';\n\nconst namespaceNeedle = '/';\n\nexport const addNamespace = (\n namespace: FilterNamespace,\n value: string = '',\n): string => `${namespace}${namespaceNeedle}${value}`;\n\nexport const removeNamespace = (\n key: string,\n): {\n name: string;\n namespace: FilterNamespace;\n} => {\n const index = key.indexOf(namespaceNeedle);\n const name = key.slice(index + 1);\n return {\n name,\n namespace: key.slice(0, index)! as FilterNamespace,\n };\n};\n\n/**\n * Converts reference strings from OpenAPI $ref keywords into namespaces.\n *\n * @example '#/components/schemas/Foo' -> 'schema'\n */\nexport const stringToNamespace = (value: string): FilterNamespace => {\n switch (value) {\n case 'parameters':\n return 'parameter';\n case 'requestBodies':\n return 'body';\n case 'responses':\n return 'response';\n case 'definitions':\n case 'schemas':\n return 'schema';\n default:\n return 'unknown';\n }\n};\n\ntype FiltersConfigToState<T> = {\n [K in keyof T]-?: NonNullable<T[K]> extends ReadonlyArray<infer U>\n ? Set<U>\n : NonNullable<T[K]> extends object\n ? FiltersConfigToState<NonNullable<T[K]>>\n : T[K];\n};\n\nexport type Filters = FiltersConfigToState<\n NonNullable<Config['parser']['filters']>\n>;\n\ninterface SetAndRegExps {\n regexps: Array<RegExp>;\n set: Set<string>;\n}\n\nconst createFiltersSetAndRegExps = (\n type: FilterNamespace,\n filters: ReadonlyArray<string> | undefined,\n): SetAndRegExps => {\n const keys: Array<string> = [];\n const regexps: Array<RegExp> = [];\n if (filters) {\n for (const value of filters) {\n if (value.startsWith('/') && value.endsWith('/')) {\n regexps.push(new RegExp(value.slice(1, value.length - 1)));\n } else {\n keys.push(addNamespace(type, value));\n }\n }\n }\n return {\n regexps,\n set: new Set(keys),\n };\n};\n\ninterface CollectFiltersSetFromRegExps {\n excludeOperations: SetAndRegExps;\n excludeParameters: SetAndRegExps;\n excludeRequestBodies: SetAndRegExps;\n excludeResponses: SetAndRegExps;\n excludeSchemas: SetAndRegExps;\n includeOperations: SetAndRegExps;\n includeParameters: SetAndRegExps;\n includeRequestBodies: SetAndRegExps;\n includeResponses: SetAndRegExps;\n includeSchemas: SetAndRegExps;\n}\n\nconst collectFiltersSetFromRegExpsOpenApiV2 = ({\n excludeOperations,\n excludeSchemas,\n includeOperations,\n includeSchemas,\n spec,\n}: CollectFiltersSetFromRegExps & {\n spec: OpenApi.V2_0_X;\n}) => {\n if (\n (excludeOperations.regexps.length || includeOperations.regexps.length) &&\n spec.paths\n ) {\n for (const entry of Object.entries(spec.paths)) {\n const path = entry[0] as keyof PathsObject;\n const pathItem = entry[1] as PathItemObject;\n for (const method of httpMethods) {\n const operation = pathItem[method];\n if (!operation) {\n continue;\n }\n\n const key = createOperationKey({ method, path });\n if (excludeOperations.regexps.some((regexp) => regexp.test(key))) {\n excludeOperations.set.add(addNamespace('operation', key));\n }\n if (includeOperations.regexps.some((regexp) => regexp.test(key))) {\n includeOperations.set.add(addNamespace('operation', key));\n }\n }\n }\n }\n\n if (spec.definitions) {\n // TODO: add parameters\n\n if (excludeSchemas.regexps.length || includeSchemas.regexps.length) {\n for (const key of Object.keys(spec.definitions)) {\n if (excludeSchemas.regexps.some((regexp) => regexp.test(key))) {\n excludeSchemas.set.add(addNamespace('schema', key));\n }\n if (includeSchemas.regexps.some((regexp) => regexp.test(key))) {\n includeSchemas.set.add(addNamespace('schema', key));\n }\n }\n }\n }\n};\n\nconst collectFiltersSetFromRegExpsOpenApiV3 = ({\n excludeOperations,\n excludeParameters,\n excludeRequestBodies,\n excludeResponses,\n excludeSchemas,\n includeOperations,\n includeParameters,\n includeRequestBodies,\n includeResponses,\n includeSchemas,\n spec,\n}: CollectFiltersSetFromRegExps & {\n spec: OpenApi.V3_0_X | OpenApi.V3_1_X;\n}) => {\n if (\n (excludeOperations.regexps.length || includeOperations.regexps.length) &&\n spec.paths\n ) {\n for (const entry of Object.entries(spec.paths)) {\n const path = entry[0] as keyof PathsObject;\n const pathItem = entry[1] as PathItemObject;\n for (const method of httpMethods) {\n const operation = pathItem[method];\n if (!operation) {\n continue;\n }\n\n const key = createOperationKey({ method, path });\n if (excludeOperations.regexps.some((regexp) => regexp.test(key))) {\n excludeOperations.set.add(addNamespace('operation', key));\n }\n if (includeOperations.regexps.some((regexp) => regexp.test(key))) {\n includeOperations.set.add(addNamespace('operation', key));\n }\n }\n }\n }\n\n if (spec.components) {\n if (\n (excludeParameters.regexps.length || includeParameters.regexps.length) &&\n spec.components.parameters\n ) {\n for (const key of Object.keys(spec.components.parameters)) {\n if (excludeParameters.regexps.some((regexp) => regexp.test(key))) {\n excludeParameters.set.add(addNamespace('parameter', key));\n }\n if (includeParameters.regexps.some((regexp) => regexp.test(key))) {\n includeParameters.set.add(addNamespace('parameter', key));\n }\n }\n }\n\n if (\n (excludeRequestBodies.regexps.length ||\n includeRequestBodies.regexps.length) &&\n spec.components.requestBodies\n ) {\n for (const key of Object.keys(spec.components.requestBodies)) {\n if (excludeRequestBodies.regexps.some((regexp) => regexp.test(key))) {\n excludeRequestBodies.set.add(addNamespace('body', key));\n }\n if (includeRequestBodies.regexps.some((regexp) => regexp.test(key))) {\n includeRequestBodies.set.add(addNamespace('body', key));\n }\n }\n }\n\n if (\n (excludeResponses.regexps.length || includeResponses.regexps.length) &&\n spec.components.responses\n ) {\n for (const key of Object.keys(spec.components.responses)) {\n if (excludeResponses.regexps.some((regexp) => regexp.test(key))) {\n excludeResponses.set.add(addNamespace('response', key));\n }\n if (includeResponses.regexps.some((regexp) => regexp.test(key))) {\n includeResponses.set.add(addNamespace('response', key));\n }\n }\n }\n\n if (\n (excludeSchemas.regexps.length || includeSchemas.regexps.length) &&\n spec.components.schemas\n ) {\n for (const key of Object.keys(spec.components.schemas)) {\n if (excludeSchemas.regexps.some((regexp) => regexp.test(key))) {\n excludeSchemas.set.add(addNamespace('schema', key));\n }\n if (includeSchemas.regexps.some((regexp) => regexp.test(key))) {\n includeSchemas.set.add(addNamespace('schema', key));\n }\n }\n }\n }\n};\n\nconst collectFiltersSetFromRegExps = ({\n spec,\n ...filters\n}: CollectFiltersSetFromRegExps & {\n spec: OpenApi.V2_0_X | OpenApi.V3_0_X | OpenApi.V3_1_X;\n}): void => {\n if ('swagger' in spec) {\n collectFiltersSetFromRegExpsOpenApiV2({ ...filters, spec });\n } else {\n collectFiltersSetFromRegExpsOpenApiV3({ ...filters, spec });\n }\n};\n\nexport const createFilters = (\n config: Config['parser']['filters'],\n spec: OpenApi.V2_0_X | OpenApi.V3_0_X | OpenApi.V3_1_X,\n logger: Logger,\n): Filters => {\n const eventCreateFilters = logger.timeEvent('create-filters');\n const excludeOperations = createFiltersSetAndRegExps(\n 'operation',\n config?.operations?.exclude,\n );\n const includeOperations = createFiltersSetAndRegExps(\n 'operation',\n config?.operations?.include,\n );\n const excludeParameters = createFiltersSetAndRegExps(\n 'parameter',\n config?.parameters?.exclude,\n );\n const includeParameters = createFiltersSetAndRegExps(\n 'parameter',\n config?.parameters?.include,\n );\n const excludeRequestBodies = createFiltersSetAndRegExps(\n 'body',\n config?.requestBodies?.exclude,\n );\n const includeRequestBodies = createFiltersSetAndRegExps(\n 'body',\n config?.requestBodies?.include,\n );\n const excludeResponses = createFiltersSetAndRegExps(\n 'response',\n config?.responses?.exclude,\n );\n const includeResponses = createFiltersSetAndRegExps(\n 'response',\n config?.responses?.include,\n );\n const excludeSchemas = createFiltersSetAndRegExps(\n 'schema',\n config?.schemas?.exclude,\n );\n const includeSchemas = createFiltersSetAndRegExps(\n 'schema',\n config?.schemas?.include,\n );\n\n collectFiltersSetFromRegExps({\n excludeOperations,\n excludeParameters,\n excludeRequestBodies,\n excludeResponses,\n excludeSchemas,\n includeOperations,\n includeParameters,\n includeRequestBodies,\n includeResponses,\n includeSchemas,\n spec,\n });\n\n const filters: Filters = {\n deprecated: config?.deprecated ?? true,\n operations: {\n exclude: excludeOperations.set,\n include: includeOperations.set,\n },\n orphans: config?.orphans ?? false,\n parameters: {\n exclude: excludeParameters.set,\n include: includeParameters.set,\n },\n preserveOrder: config?.preserveOrder ?? false,\n requestBodies: {\n exclude: excludeRequestBodies.set,\n include: includeRequestBodies.set,\n },\n responses: {\n exclude: excludeResponses.set,\n include: includeResponses.set,\n },\n schemas: {\n exclude: excludeSchemas.set,\n include: includeSchemas.set,\n },\n tags: {\n exclude: new Set(config?.tags?.exclude),\n include: new Set(config?.tags?.include),\n },\n };\n eventCreateFilters.timeEnd();\n return filters;\n};\n\nexport const hasFilters = (config: Config['parser']['filters']): boolean => {\n if (!config) {\n return false;\n }\n\n // we explicitly want to strip orphans or deprecated\n if (config.orphans === false || config.deprecated === false) {\n return true;\n }\n\n return Boolean(\n config.operations?.exclude?.length ||\n config.operations?.include?.length ||\n config.parameters?.exclude?.length ||\n config.parameters?.include?.length ||\n config.requestBodies?.exclude?.length ||\n config.requestBodies?.include?.length ||\n config.responses?.exclude?.length ||\n config.responses?.include?.length ||\n config.schemas?.exclude?.length ||\n config.schemas?.include?.length ||\n config.tags?.exclude?.length ||\n config.tags?.include?.length,\n );\n};\n\n/**\n * Collect operations that satisfy the include/exclude filters and schema dependencies.\n */\nconst collectOperations = ({\n filters,\n parameters,\n requestBodies,\n resourceMetadata,\n responses,\n schemas,\n}: {\n filters: Filters;\n parameters: Set<string>;\n requestBodies: Set<string>;\n resourceMetadata: ResourceMetadata;\n responses: Set<string>;\n schemas: Set<string>;\n}): {\n operations: Set<string>;\n} => {\n const finalSet = new Set<string>();\n const initialSet = filters.operations.include.size\n ? filters.operations.include\n : new Set(resourceMetadata.operations.keys());\n const stack = [...initialSet];\n while (stack.length) {\n const key = stack.pop()!;\n\n if (filters.operations.exclude.has(key) || finalSet.has(key)) {\n continue;\n }\n\n const node = resourceMetadata.operations.get(key);\n\n if (!node) {\n continue;\n }\n\n if (!filters.deprecated && node.deprecated) {\n continue;\n }\n\n if (\n filters.tags.exclude.size &&\n node.tags.size &&\n [...filters.tags.exclude].some((tag) => node.tags.has(tag))\n ) {\n continue;\n }\n\n if (\n filters.tags.include.size &&\n !new Set([...filters.tags.include].filter((tag) => node.tags.has(tag)))\n .size\n ) {\n continue;\n }\n\n // skip operation if it references any component not included\n if (\n [...node.dependencies].some((dependency) => {\n const { namespace } = removeNamespace(dependency);\n switch (namespace) {\n case 'body':\n return !requestBodies.has(dependency);\n case 'parameter':\n return !parameters.has(dependency);\n case 'response':\n return !responses.has(dependency);\n case 'schema':\n return !schemas.has(dependency);\n default:\n return false;\n }\n })\n ) {\n continue;\n }\n\n finalSet.add(key);\n }\n return { operations: finalSet };\n};\n\n/**\n * Collect parameters that satisfy the include/exclude filters and schema dependencies.\n */\nconst collectParameters = ({\n filters,\n resourceMetadata,\n schemas,\n}: {\n filters: Filters;\n resourceMetadata: ResourceMetadata;\n schemas: Set<string>;\n}): {\n parameters: Set<string>;\n} => {\n const finalSet = new Set<string>();\n const initialSet = filters.parameters.include.size\n ? filters.parameters.include\n : new Set(resourceMetadata.parameters.keys());\n const stack = [...initialSet];\n while (stack.length) {\n const key = stack.pop()!;\n\n if (filters.parameters.exclude.has(key) || finalSet.has(key)) {\n continue;\n }\n\n const node = resourceMetadata.parameters.get(key);\n\n if (!node) {\n continue;\n }\n\n if (!filters.deprecated && node.deprecated) {\n continue;\n }\n\n finalSet.add(key);\n\n if (!node.dependencies.size) {\n continue;\n }\n\n for (const dependency of node.dependencies) {\n const { namespace } = removeNamespace(dependency);\n switch (namespace) {\n case 'body': {\n if (filters.requestBodies.exclude.has(dependency)) {\n finalSet.delete(key);\n } else if (!finalSet.has(dependency)) {\n stack.push(dependency);\n }\n break;\n }\n case 'schema': {\n if (filters.schemas.exclude.has(dependency)) {\n finalSet.delete(key);\n } else if (!schemas.has(dependency)) {\n schemas.add(dependency);\n }\n break;\n }\n }\n }\n }\n return { parameters: finalSet };\n};\n\n/**\n * Collect request bodies that satisfy the include/exclude filters and schema dependencies.\n */\nconst collectRequestBodies = ({\n filters,\n resourceMetadata,\n schemas,\n}: {\n filters: Filters;\n resourceMetadata: ResourceMetadata;\n schemas: Set<string>;\n}): {\n requestBodies: Set<string>;\n} => {\n const finalSet = new Set<string>();\n const initialSet = filters.requestBodies.include.size\n ? filters.requestBodies.include\n : new Set(resourceMetadata.requestBodies.keys());\n const stack = [...initialSet];\n while (stack.length) {\n const key = stack.pop()!;\n\n if (filters.requestBodies.exclude.has(key) || finalSet.has(key)) {\n continue;\n }\n\n const node = resourceMetadata.requestBodies.get(key);\n\n if (!node) {\n continue;\n }\n\n if (!filters.deprecated && node.deprecated) {\n continue;\n }\n\n finalSet.add(key);\n\n if (!node.dependencies.size) {\n continue;\n }\n\n for (const dependency of node.dependencies) {\n const { namespace } = removeNamespace(dependency);\n switch (namespace) {\n case 'body': {\n if (filters.requestBodies.exclude.has(dependency)) {\n finalSet.delete(key);\n } else if (!finalSet.has(dependency)) {\n stack.push(dependency);\n }\n break;\n }\n case 'schema': {\n if (filters.schemas.exclude.has(dependency)) {\n finalSet.delete(key);\n } else if (!schemas.has(dependency)) {\n schemas.add(dependency);\n }\n break;\n }\n }\n }\n }\n return { requestBodies: finalSet };\n};\n\n/**\n * Collect responses that satisfy the include/exclude filters and schema dependencies.\n */\nconst collectResponses = ({\n filters,\n resourceMetadata,\n schemas,\n}: {\n filters: Filters;\n resourceMetadata: ResourceMetadata;\n schemas: Set<string>;\n}): {\n responses: Set<string>;\n} => {\n const finalSet = new Set<string>();\n const initialSet = filters.responses.include.size\n ? filters.responses.include\n : new Set(resourceMetadata.responses.keys());\n const stack = [...initialSet];\n while (stack.length) {\n const key = stack.pop()!;\n\n if (filters.responses.exclude.has(key) || finalSet.has(key)) {\n continue;\n }\n\n const node = resourceMetadata.responses.get(key);\n\n if (!node) {\n continue;\n }\n\n if (!filters.deprecated && node.deprecated) {\n continue;\n }\n\n finalSet.add(key);\n\n if (!node.dependencies.size) {\n continue;\n }\n\n for (const dependency of node.dependencies) {\n const { namespace } = removeNamespace(dependency);\n switch (namespace) {\n case 'body': {\n if (filters.requestBodies.exclude.has(dependency)) {\n finalSet.delete(key);\n } else if (!finalSet.has(dependency)) {\n stack.push(dependency);\n }\n break;\n }\n case 'schema': {\n if (filters.schemas.exclude.has(dependency)) {\n finalSet.delete(key);\n } else if (!schemas.has(dependency)) {\n schemas.add(dependency);\n }\n break;\n }\n }\n }\n }\n return { responses: finalSet };\n};\n\n/**\n * Collect schemas that satisfy the include/exclude filters.\n */\nconst collectSchemas = ({\n filters,\n resourceMetadata,\n}: {\n filters: Filters;\n resourceMetadata: ResourceMetadata;\n}): {\n schemas: Set<string>;\n} => {\n const finalSet = new Set<string>();\n const initialSet = filters.schemas.include.size\n ? filters.schemas.include\n : new Set(resourceMetadata.schemas.keys());\n const stack = [...initialSet];\n while (stack.length) {\n const key = stack.pop()!;\n\n if (filters.schemas.exclude.has(key) || finalSet.has(key)) {\n continue;\n }\n\n const node = resourceMetadata.schemas.get(key);\n\n if (!node) {\n continue;\n }\n\n if (!filters.deprecated && node.deprecated) {\n continue;\n }\n\n finalSet.add(key);\n\n if (!node.dependencies.size) {\n continue;\n }\n\n for (const dependency of node.dependencies) {\n const { namespace } = removeNamespace(dependency);\n switch (namespace) {\n case 'schema': {\n if (\n !finalSet.has(dependency) &&\n !filters.schemas.exclude.has(dependency)\n ) {\n stack.push(dependency);\n }\n break;\n }\n }\n }\n }\n return { schemas: finalSet };\n};\n\n/**\n * Drop parameters that depend on already excluded parameters.\n */\nconst dropExcludedParameters = ({\n filters,\n parameters,\n resourceMetadata,\n}: {\n filters: Filters;\n parameters: Set<string>;\n resourceMetadata: ResourceMetadata;\n}): void => {\n if (!filters.parameters.exclude.size) {\n return;\n }\n\n for (const key of parameters) {\n const node = resourceMetadata.parameters.get(key);\n\n if (!node?.dependencies.size) {\n continue;\n }\n\n for (const excludedKey of filters.parameters.exclude) {\n if (node.dependencies.has(excludedKey)) {\n parameters.delete(key);\n break;\n }\n }\n }\n};\n\n/**\n * Drop request bodies that depend on already excluded request bodies.\n */\nconst dropExcludedRequestBodies = ({\n filters,\n requestBodies,\n resourceMetadata,\n}: {\n filters: Filters;\n requestBodies: Set<string>;\n resourceMetadata: ResourceMetadata;\n}): void => {\n if (!filters.requestBodies.exclude.size) {\n return;\n }\n\n for (const key of requestBodies) {\n const node = resourceMetadata.requestBodies.get(key);\n\n if (!node?.dependencies.size) {\n continue;\n }\n\n for (const excludedKey of filters.requestBodies.exclude) {\n if (node.dependencies.has(excludedKey)) {\n requestBodies.delete(key);\n break;\n }\n }\n }\n};\n\n/**\n * Drop responses that depend on already excluded responses.\n */\nconst dropExcludedResponses = ({\n filters,\n resourceMetadata,\n responses,\n}: {\n filters: Filters;\n resourceMetadata: ResourceMetadata;\n responses: Set<string>;\n}): void => {\n if (!filters.responses.exclude.size) {\n return;\n }\n\n for (const key of responses) {\n const node = resourceMetadata.responses.get(key);\n\n if (!node?.dependencies.size) {\n continue;\n }\n\n for (const excludedKey of filters.responses.exclude) {\n if (node.dependencies.has(excludedKey)) {\n responses.delete(key);\n break;\n }\n }\n }\n};\n\n/**\n * Drop schemas that depend on already excluded schemas.\n */\nconst dropExcludedSchemas = ({\n filters,\n resourceMetadata,\n schemas,\n}: {\n filters: Filters;\n resourceMetadata: ResourceMetadata;\n schemas: Set<string>;\n}): void => {\n if (!filters.schemas.exclude.size) {\n return;\n }\n\n for (const key of schemas) {\n const node = resourceMetadata.schemas.get(key);\n\n if (!node?.dependencies.size) {\n continue;\n }\n\n for (const excludedKey of filters.schemas.exclude) {\n if (node.dependencies.has(excludedKey)) {\n schemas.delete(key);\n break;\n }\n }\n }\n};\n\nconst dropOrphans = ({\n operationDependencies,\n parameters,\n requestBodies,\n responses,\n schemas,\n}: {\n operationDependencies: Set<string>;\n parameters: Set<string>;\n requestBodies: Set<string>;\n responses: Set<string>;\n schemas: Set<string>;\n}) => {\n for (const key of schemas) {\n if (!operationDependencies.has(key)) {\n schemas.delete(key);\n }\n }\n for (const key of parameters) {\n if (!operationDependencies.has(key)) {\n parameters.delete(key);\n }\n }\n for (const key of requestBodies) {\n if (!operationDependencies.has(key)) {\n requestBodies.delete(key);\n }\n }\n for (const key of responses) {\n if (!operationDependencies.has(key)) {\n responses.delete(key);\n }\n }\n};\n\nconst collectOperationDependencies = ({\n operations,\n resourceMetadata,\n}: {\n operations: Set<string>;\n resourceMetadata: ResourceMetadata;\n}): {\n operationDependencies: Set<string>;\n} => {\n const finalSet = new Set<string>();\n const initialSet = new Set(\n [...operations].flatMap((key) => [\n ...(resourceMetadata.operations.get(key)?.dependencies ?? []),\n ]),\n );\n const stack = [...initialSet];\n while (stack.length) {\n const key = stack.pop()!;\n\n if (finalSet.has(key)) {\n continue;\n }\n\n finalSet.add(key);\n\n const { namespace } = removeNamespace(key);\n let dependencies: Set<string> | undefined;\n if (namespace === 'body') {\n dependencies = resourceMetadata.requestBodies.get(key)?.dependencies;\n } else if (namespace === 'operation') {\n dependencies = resourceMetadata.operations.get(key)?.dependencies;\n } else if (namespace === 'parameter') {\n dependencies = resourceMetadata.parameters.get(key)?.dependencies;\n } else if (namespace === 'response') {\n dependencies = resourceMetadata.responses.get(key)?.dependencies;\n } else if (namespace === 'schema') {\n dependencies = resourceMetadata.schemas.get(key)?.dependencies;\n }\n\n if (!dependencies?.size) {\n continue;\n }\n\n for (const dependency of dependencies) {\n if (!finalSet.has(dependency)) {\n stack.push(dependency);\n }\n }\n }\n return { operationDependencies: finalSet };\n};\n\nexport const createFilteredDependencies = ({\n filters,\n logger,\n resourceMetadata,\n}: {\n filters: Filters;\n logger: Logger;\n resourceMetadata: ResourceMetadata;\n}): {\n operations: Set<string>;\n parameters: Set<string>;\n requestBodies: Set<string>;\n responses: Set<string>;\n schemas: Set<string>;\n} => {\n const eventCreateFilteredDependencies = logger.timeEvent(\n 'create-filtered-dependencies',\n );\n const { schemas } = collectSchemas({ filters, resourceMetadata });\n const { parameters } = collectParameters({\n filters,\n resourceMetadata,\n schemas,\n });\n const { requestBodies } = collectRequestBodies({\n filters,\n resourceMetadata,\n schemas,\n });\n const { responses } = collectResponses({\n filters,\n resourceMetadata,\n schemas,\n });\n\n dropExcludedSchemas({ filters, resourceMetadata, schemas });\n dropExcludedParameters({ filters, parameters, resourceMetadata });\n dropExcludedRequestBodies({ filters, requestBodies, resourceMetadata });\n dropExcludedResponses({ filters, resourceMetadata, responses });\n\n // collect operations after dropping components\n const { operations } = collectOperations({\n filters,\n parameters,\n requestBodies,\n resourceMetadata,\n responses,\n schemas,\n });\n\n if (!filters.orphans && operations.size) {\n const { operationDependencies } = collectOperationDependencies({\n operations,\n resourceMetadata,\n });\n dropOrphans({\n operationDependencies,\n parameters,\n requestBodies,\n responses,\n schemas,\n });\n }\n\n eventCreateFilteredDependencies.timeEnd();\n return {\n operations,\n parameters,\n requestBodies,\n responses,\n schemas,\n };\n};\n","import type { Graph } from '~/graph';\nimport { createOperationKey } from '~/ir/operation';\nimport type { Logger } from '~/utils/logger';\nimport { jsonPointerToPath } from '~/utils/ref';\n\nimport { addNamespace, stringToNamespace } from '../utils/filter';\nimport { httpMethods } from '../utils/operation';\n\nexport type ResourceMetadata = {\n operations: Map<\n string,\n {\n dependencies: Set<string>;\n deprecated: boolean;\n tags: Set<string>;\n }\n >;\n parameters: Map<\n string,\n {\n dependencies: Set<string>;\n deprecated: boolean;\n }\n >;\n requestBodies: Map<\n string,\n {\n dependencies: Set<string>;\n deprecated: boolean;\n }\n >;\n responses: Map<\n string,\n {\n dependencies: Set<string>;\n deprecated: boolean;\n }\n >;\n schemas: Map<\n string,\n {\n dependencies: Set<string>;\n deprecated: boolean;\n }\n >;\n};\n\n/**\n * Builds a resource metadata map from a Graph, matching the old Graph interface\n * for compatibility with filtering code.\n */\nexport const buildResourceMetadata = (\n graph: Graph,\n logger: Logger,\n): {\n resourceMetadata: ResourceMetadata;\n} => {\n const eventBuildResourceMetadata = logger.timeEvent(\n 'build-resource-metadata',\n );\n const resourceMetadata: ResourceMetadata = {\n operations: new Map(),\n parameters: new Map(),\n requestBodies: new Map(),\n responses: new Map(),\n schemas: new Map(),\n };\n\n const getDependencies = (pointer: string): Set<string> => {\n const dependencies = new Set<string>();\n const nodeDependencies = graph.transitiveDependencies.get(pointer);\n if (nodeDependencies?.size) {\n for (const dependency of nodeDependencies) {\n const path = jsonPointerToPath(dependency);\n const type = path[path.length - 2];\n const name = path[path.length - 1];\n if (type && name) {\n const namespace = stringToNamespace(type);\n if (namespace === 'unknown') {\n console.warn(`unsupported type: ${type}`);\n }\n dependencies.add(addNamespace(namespace, name));\n }\n }\n }\n return dependencies;\n };\n\n // Process each node to find top-level resources\n for (const [pointer, nodeInfo] of graph.nodes) {\n // const node = nodeInfo.node as Record<string, unknown>;\n const path = jsonPointerToPath(pointer);\n\n // OpenAPI 3.x\n if (path[0] === 'components') {\n if (path.length === 3) {\n if (path[1] === 'schemas') {\n // Schema: #/components/schemas/{name}\n const name = path[path.length - 1]!;\n resourceMetadata.schemas.set(addNamespace('schema', name), {\n dependencies: getDependencies(pointer),\n deprecated: nodeInfo.deprecated ?? false,\n });\n } else if (path[1] === 'parameters') {\n // Parameter: #/components/parameters/{name}\n const name = path[path.length - 1]!;\n resourceMetadata.parameters.set(addNamespace('parameter', name), {\n dependencies: getDependencies(pointer),\n deprecated: nodeInfo.deprecated ?? false,\n });\n } else if (path[1] === 'requestBodies') {\n // RequestBody: #/components/requestBodies/{name}\n const name = path[path.length - 1]!;\n resourceMetadata.requestBodies.set(addNamespace('body', name), {\n dependencies: getDependencies(pointer),\n deprecated: nodeInfo.deprecated ?? false,\n });\n } else if (path[1] === 'responses') {\n // Response: #/components/responses/{name}\n const name = path[path.length - 1]!;\n resourceMetadata.responses.set(addNamespace('response', name), {\n dependencies: getDependencies(pointer),\n deprecated: nodeInfo.deprecated ?? false,\n });\n }\n }\n continue;\n }\n\n if (path[0] === 'paths') {\n if (\n path.length === 3 &&\n httpMethods.includes(path[2] as (typeof httpMethods)[number])\n ) {\n // Operation: #/paths/{path}/{method}\n const method = path[path.length - 1]!;\n const operationPath = path.slice(1, -1).join('/');\n const operationKey = createOperationKey({\n method,\n path: operationPath,\n });\n resourceMetadata.operations.set(\n addNamespace('operation', operationKey),\n {\n dependencies: getDependencies(pointer),\n deprecated: nodeInfo.deprecated ?? false,\n tags: nodeInfo.tags ?? new Set(),\n },\n );\n }\n continue;\n }\n\n // OpenAPI 2.0\n if (path[0] === 'definitions') {\n if (path.length === 2) {\n // Schema: #/definitions/{name}\n const name = path[path.length - 1]!;\n resourceMetadata.schemas.set(addNamespace('schema', name), {\n dependencies: getDependencies(pointer),\n deprecated: nodeInfo.deprecated ?? false,\n });\n }\n continue;\n }\n }\n\n eventBuildResourceMetadata.timeEnd();\n return { resourceMetadata };\n};\n","export const deepClone = <T>(obj: T): T => JSON.parse(JSON.stringify(obj));\n","export const childSchemaRelationships = [\n ['additionalProperties', 'single'],\n ['allOf', 'array'],\n ['anyOf', 'array'],\n ['contains', 'single'],\n ['dependentSchemas', 'objectMap'],\n ['else', 'single'],\n ['if', 'single'],\n ['items', 'singleOrArray'],\n ['oneOf', 'array'],\n ['patternProperties', 'objectMap'],\n ['properties', 'objectMap'],\n ['propertyNames', 'single'],\n ['then', 'single'],\n] as const;\n","export const getSchemasObject = (\n spec: unknown,\n): Record<string, unknown> | undefined => {\n if (hasComponentsSchemasObject(spec)) {\n return (spec as any).components.schemas;\n }\n if (hasDefinitionsObject(spec)) {\n return (spec as any).definitions;\n }\n return;\n};\n\n/**\n * Checks if the given spec has a valid OpenAPI 3.x components.schemas object.\n * Returns true if present, false otherwise.\n */\nexport const hasComponentsSchemasObject = (spec: unknown): boolean =>\n typeof spec === 'object' &&\n spec !== null &&\n 'components' in spec &&\n typeof (spec as any).components === 'object' &&\n (spec as any).components !== null &&\n 'schemas' in (spec as any).components &&\n typeof (spec as any).components.schemas === 'object' &&\n (spec as any).components.schemas !== null;\n\n/**\n * Checks if the given spec has a valid OpenAPI 2.0 definitions object.\n * Returns true if present, false otherwise.\n */\nexport const hasDefinitionsObject = (spec: unknown): boolean =>\n typeof spec === 'object' &&\n spec !== null &&\n 'definitions' in spec &&\n typeof (spec as any).definitions === 'object' &&\n (spec as any).definitions !== null;\n","type Obj =\n | Record<string, unknown>\n | Set<string>\n | ReadonlyArray<string | undefined>;\n\nconst hasName = (obj: Obj, value: string): boolean => {\n if (obj instanceof Set) {\n return obj.has(value);\n }\n if (obj instanceof Array) {\n return obj.includes(value);\n }\n return value in obj;\n};\n\nexport const getUniqueComponentName = ({\n base,\n components,\n extraComponents,\n}: {\n base: string;\n /**\n * Input components.\n */\n components: Obj;\n /**\n * Temporary input components, waiting to be inserted for example.\n */\n extraComponents?: Obj;\n}): string => {\n let index = 2;\n let name = base;\n while (\n hasName(components, name) ||\n (extraComponents && hasName(extraComponents, name))\n ) {\n name = `${base}${index}`;\n index += 1;\n }\n return name;\n};\n\nexport const isPathRootSchema = (path: ReadonlyArray<string | number>) =>\n (path.length === 3 && path[0] === 'components' && path[1] === 'schemas') ||\n (path.length === 2 && path[0] === 'definitions');\n\nexport const specToSchemasPointerNamespace = (spec: unknown): string => {\n if (spec && typeof spec === 'object') {\n if ('swagger' in spec) {\n // #/definitions/SchemaName\n return '#/definitions/';\n }\n\n if ('openapi' in spec) {\n // #/components/schemas/SchemaName\n return '#/components/schemas/';\n }\n }\n\n return '';\n};\n","import { jsonPointerToPath } from '~/utils/ref';\n\nimport type { Config } from '../../../types/config';\nimport { buildName } from '../utils/name';\nimport { deepClone } from '../utils/schema';\nimport { childSchemaRelationships } from '../utils/schemaChildRelationships';\nimport { getSchemasObject } from '../utils/transforms';\nimport {\n getUniqueComponentName,\n isPathRootSchema,\n specToSchemasPointerNamespace,\n} from './utils';\n\ntype EnumsConfig = Config['parser']['transforms']['enums'];\n\n/**\n * Generate a unique, structural signature for an enum schema for deduplication.\n * Only considers 'type' and sorted 'enum' values, ignoring other fields.\n *\n * @param schema - The schema object to analyze\n * @returns A string signature if the schema is an enum, otherwise undefined\n */\nconst getEnumSignature = (schema: unknown): string | undefined => {\n if (\n !schema ||\n typeof schema !== 'object' ||\n !('enum' in schema) ||\n !(schema.enum instanceof Array)\n ) {\n return;\n }\n // Use type + sorted enum values for signature\n const type = ('type' in schema ? schema.type : undefined) || '';\n const values = [...schema.enum].sort();\n return JSON.stringify({ type, values });\n};\n\ntype NodeInfo = {\n key: string | number | null;\n node: unknown;\n parent: unknown;\n path: ReadonlyArray<string | number>;\n};\n\n/**\n * Recursively walk all schemas in the OpenAPI spec, visiting every object/array\n * that could contain an enum. Calls the visitor with node info for each.\n *\n * @param key - The key of the current node\n * @param node - The current node\n * @param parent - The parent node\n * @param path - The path to the current node\n * @param visitor - Function to call for each visited node\n */\nconst walkSchemas = ({\n key,\n node,\n parent,\n path,\n visitor,\n}: NodeInfo & {\n visitor: (nodeInfo: NodeInfo) => void;\n}) => {\n if (!node || typeof node !== 'object' || node instanceof Array) return;\n\n const value = node as Record<string, unknown>;\n\n if (\n 'type' in value ||\n 'enum' in value ||\n childSchemaRelationships.some(([keyword]) => keyword in value)\n ) {\n visitor({ key, node, parent, path });\n }\n\n for (const [k, v] of Object.entries(value)) {\n if (typeof v === 'object' && v !== null) {\n if (v instanceof Array) {\n v.forEach((item, index) =>\n walkSchemas({\n key: index,\n node: item,\n parent: v,\n path: [...path, k, index],\n visitor,\n }),\n );\n } else {\n walkSchemas({\n key: k,\n node: v,\n parent: node,\n path: [...path, k],\n visitor,\n });\n }\n }\n }\n};\n\n/**\n * Inlines all root/top-level enums by replacing $refs to them with the actual enum schema,\n * and then removes the now-unreferenced root enums from the schemas object.\n *\n * @param spec - The OpenAPI spec object to transform\n */\nconst inlineMode = ({ spec }: { spec: unknown }) => {\n const schemasObj = getSchemasObject(spec);\n if (!schemasObj) {\n return;\n }\n\n const schemasPointerNamespace = specToSchemasPointerNamespace(spec);\n\n // Collect all root enums\n const rootEnums: Record<string, unknown> = {};\n for (const [name, schema] of Object.entries(schemasObj)) {\n const signature = getEnumSignature(schema);\n if (signature) {\n rootEnums[`${schemasPointerNamespace}${name}`] = schema;\n }\n }\n\n // Walk the spec and replace $refs to root enums with inline enum schemas\n const replaceEnumRefs = (node: unknown) => {\n if (node instanceof Array) {\n node.forEach(replaceEnumRefs);\n } else if (node && typeof node === 'object') {\n for (const [k, v] of Object.entries(node)) {\n if (k === '$ref' && typeof v === 'string' && v in rootEnums) {\n // Replace $ref with a deep clone of the enum schema\n Object.assign(node, deepClone(rootEnums[v]));\n delete (node as Record<string, unknown>)['$ref'];\n } else {\n replaceEnumRefs(v);\n }\n }\n }\n };\n replaceEnumRefs(spec);\n\n // Remove unreferenced root enums\n for (const pointer of Object.keys(rootEnums)) {\n const path = jsonPointerToPath(pointer);\n const name = path[path.length - 1]!;\n if (name) {\n delete schemasObj[name];\n }\n }\n};\n\n/**\n * Promotes all inline enums to reusable root components (if mode is 'root'),\n * deduplicates by signature, and replaces inline enums with $refs.\n *\n * Naming, casing, and deduplication are controlled by the enums transform config.\n * Existing root enums are reused if structurally identical.\n *\n * @param spec - The OpenAPI spec object to transform\n * @param config - The enums transform config\n */\nconst rootMode = ({ config, spec }: { config: EnumsConfig; spec: unknown }) => {\n const schemasObj = getSchemasObject(spec);\n if (!schemasObj) {\n return;\n }\n\n // Build a map of existing root enum signatures to their names for deduplication\n const rootEnumSignatures: Record<string, string> = {};\n for (const [name, schema] of Object.entries(schemasObj)) {\n const signature = getEnumSignature(schema);\n if (signature) {\n rootEnumSignatures[signature] = name;\n }\n }\n\n // Collect all inline enums (not at root schemas)\n const inlineEnums: Array<{\n key: string | number | null;\n node: unknown;\n parent: unknown;\n path: ReadonlyArray<string | number>;\n signature: string;\n }> = [];\n\n walkSchemas({\n key: null,\n node: spec,\n parent: null,\n path: [],\n visitor: (nodeInfo) => {\n if (!isPathRootSchema(nodeInfo.path)) {\n const signature = getEnumSignature(nodeInfo.node);\n if (signature) {\n inlineEnums.push({ ...nodeInfo, signature });\n }\n }\n },\n });\n\n // Deduplicate and assign unique names for promoted enums\n const signatureToName: Record<string, string | undefined> = {};\n const signatureToSchema: Record<string, unknown> = {};\n\n for (const { key, node, signature } of inlineEnums) {\n if (signature in signatureToName) {\n // Already handled\n continue;\n }\n\n // Use existing root enum if available\n if (signature in rootEnumSignatures) {\n signatureToName[signature] = rootEnumSignatures[signature];\n continue;\n }\n\n // Generate a unique name for the new root enum using config\n const base = buildName({\n config,\n name:\n typeof node === 'object' &&\n node &&\n 'title' in node &&\n typeof node.title === 'string'\n ? node.title\n : String(key),\n });\n const name = getUniqueComponentName({\n base,\n components: schemasObj,\n extraComponents: Object.values(signatureToName),\n });\n signatureToName[signature] = name;\n signatureToSchema[signature] = node;\n }\n\n // Add new root enums to the schemas object\n for (const [signature, name] of Object.entries(signatureToName)) {\n // Only add if not already present\n const schema = signatureToSchema[signature];\n if (name && !(name in schemasObj) && schema && typeof schema === 'object') {\n schemasObj[name] = schema;\n }\n }\n\n // Replace inline enums with $ref to the new root enum\n const schemasPointerNamespace = specToSchemasPointerNamespace(spec);\n for (const { key, parent, signature } of inlineEnums) {\n const name = signatureToName[signature];\n if (name && key != null && parent && typeof parent === 'object') {\n (parent as Record<string, unknown>)[key] = {\n $ref: `${schemasPointerNamespace}${name}`,\n };\n }\n }\n};\n\n/**\n * Applies the enums transform according to the configured mode ('inline' or 'root').\n *\n * - In 'inline' mode, all root enums are inlined and removed.\n * - In 'root' mode, all inline enums are promoted to root components and deduplicated.\n *\n * @param config - The enums transform config\n * @param spec - The OpenAPI spec object to transform\n */\nexport const enumsTransform = ({\n config,\n spec,\n}: {\n config: EnumsConfig;\n spec: unknown;\n}) => {\n if (config.mode === 'inline') {\n inlineMode({ spec });\n return;\n }\n\n if (config.mode === 'root') {\n rootMode({ config, spec });\n return;\n }\n};\n","import { childSchemaRelationships } from '../utils/schemaChildRelationships';\n\ntype NodeInfo = {\n key: string | number | null;\n node: unknown;\n parent: unknown;\n path: ReadonlyArray<string | number>;\n};\n\n/**\n * Recursively walk all schemas in the OpenAPI spec, visiting every object.\n * Calls the visitor with node info for each.\n *\n * @param key - The key of the current node\n * @param node - The current node\n * @param parent - The parent node\n * @param path - The path to the current node\n * @param visitor - Function to call for each visited node\n */\nconst walkSchemas = ({\n key,\n node,\n parent,\n path,\n visitor,\n}: NodeInfo & {\n visitor: (nodeInfo: NodeInfo) => void;\n}) => {\n if (!node || typeof node !== 'object' || node instanceof Array) return;\n\n const value = node as Record<string, unknown>;\n\n if (\n 'type' in value ||\n childSchemaRelationships.some(([keyword]) => keyword in value)\n ) {\n visitor({ key, node, parent, path });\n }\n\n for (const [k, v] of Object.entries(value)) {\n if (typeof v === 'object' && v !== null) {\n if (v instanceof Array) {\n v.forEach((item, index) =>\n walkSchemas({\n key: index,\n node: item,\n parent: v,\n path: [...path, k, index],\n visitor,\n }),\n );\n } else {\n walkSchemas({\n key: k,\n node: v,\n parent: node,\n path: [...path, k],\n visitor,\n });\n }\n }\n }\n};\n\n/**\n * Applies the properties required by default transform\n *\n * @param spec - The OpenAPI spec object to transform\n */\nexport const propertiesRequiredByDefaultTransform = ({\n spec,\n}: {\n spec: unknown;\n}) => {\n walkSchemas({\n key: null,\n node: spec,\n parent: null,\n path: [],\n visitor: (nodeInfo) => {\n if (\n nodeInfo.node &&\n typeof nodeInfo.node === 'object' &&\n 'type' in nodeInfo.node &&\n nodeInfo.node.type === 'object' &&\n 'properties' in nodeInfo.node &&\n nodeInfo.node.properties &&\n typeof nodeInfo.node.properties === 'object' &&\n !('required' in nodeInfo.node)\n ) {\n const propKeys = Object.keys(\n nodeInfo.node.properties as Record<string, unknown>,\n );\n if (propKeys.length > 0) {\n (nodeInfo.node as Record<string, unknown>).required = propKeys;\n }\n }\n },\n });\n};\n","/**\n * Deep equality for JSON-compatible values (objects, arrays, primitives).\n * Used to determine whether read/write pruned variants actually differ.\n */\nconst deepEqual = (a: unknown, b: unknown): boolean => {\n if (a === b) return true;\n if (a === null || b === null) return a === b;\n const typeA = typeof a;\n const typeB = typeof b;\n if (typeA !== typeB) return false;\n if (typeA !== 'object') return false;\n\n // Arrays\n if (Array.isArray(a) || Array.isArray(b)) {\n if (!Array.isArray(a) || !Array.isArray(b)) return false;\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if (!deepEqual(a[i], b[i])) return false;\n }\n return true;\n }\n\n // Plain objects\n const objA = a as Record<string, unknown>;\n const objB = b as Record<string, unknown>;\n const keysA = Object.keys(objA).sort();\n const keysB = Object.keys(objB).sort();\n if (keysA.length !== keysB.length) return false;\n for (let i = 0; i < keysA.length; i++) {\n if (keysA[i] !== keysB[i]) return false;\n }\n for (const key of keysA) {\n if (!deepEqual(objA[key], objB[key])) return false;\n }\n return true;\n};\n\nexport default deepEqual;\n","import type { Graph, NodeInfo } from '~/graph';\nimport type { Logger } from '~/utils/logger';\nimport { normalizeJsonPointer, pathToJsonPointer } from '~/utils/ref';\n\nimport { childSchemaRelationships } from './schemaChildRelationships';\n\n/**\n * Represents the possible access scopes for OpenAPI nodes.\n * - 'normal': Default scope for regular nodes.\n * - 'read': Node is read-only (e.g., readOnly: true).\n * - 'write': Node is write-only (e.g., writeOnly: true).\n */\nexport type Scope = 'normal' | 'read' | 'write';\n\n/**\n * Ensures every relevant child node (e.g., properties, items) in the graph has a `scopes` property.\n * If a node does not have its own scopes, it inherits from its parent if available.\n *\n * @param nodes - Map of JSON Pointer to NodeInfo.\n */\nexport const annotateChildScopes = (nodes: Graph['nodes']): void => {\n for (const [, nodeInfo] of nodes) {\n if (nodeInfo.scopes) continue;\n\n if (nodeInfo.parentPointer) {\n const parentInfo = nodes.get(nodeInfo.parentPointer);\n if (parentInfo?.scopes) {\n nodeInfo.scopes = new Set(parentInfo.scopes);\n }\n }\n }\n};\n\ninterface Cache {\n parentToChildren: Map<string, Array<string>>;\n subtreeDependencies: Map<string, Set<string>>;\n transitiveDependencies: Map<string, Set<string>>;\n}\n\ntype PointerDependenciesResult = {\n subtreeDependencies: Set<string>;\n transitiveDependencies: Set<string>;\n};\n\n/**\n * Recursively collects all $ref dependencies in the subtree rooted at `pointer`.\n */\nconst collectPointerDependencies = ({\n cache,\n graph,\n pointer,\n visited,\n}: {\n cache: Cache;\n graph: Graph;\n pointer: string;\n visited: Set<string>;\n}): PointerDependenciesResult => {\n const cached = cache.transitiveDependencies.get(pointer);\n if (cached) {\n return {\n subtreeDependencies: cache.subtreeDependencies.get(pointer)!,\n transitiveDependencies: cached,\n };\n }\n\n if (visited.has(pointer)) {\n return {\n subtreeDependencies: new Set(),\n transitiveDependencies: new Set(),\n };\n }\n visited.add(pointer);\n\n const nodeInfo = graph.nodes.get(pointer);\n if (!nodeInfo) {\n return {\n subtreeDependencies: new Set(),\n transitiveDependencies: new Set(),\n };\n }\n\n const transitiveDependencies = new Set<string>();\n const subtreeDependencies = new Set<string>();\n\n // Add direct $ref dependencies for this node\n // (from the dependencies map, or by checking nodeInfo.node directly)\n // We'll use the dependencies map for consistency:\n const nodeDependencies = graph.nodeDependencies.get(pointer);\n if (nodeDependencies) {\n for (const depPointer of nodeDependencies) {\n transitiveDependencies.add(depPointer);\n subtreeDependencies.add(depPointer);\n // Recursively collect dependencies of the referenced node\n const depResult = collectPointerDependencies({\n cache,\n graph,\n pointer: depPointer,\n visited,\n });\n for (const dependency of depResult.transitiveDependencies) {\n transitiveDependencies.add(dependency);\n }\n }\n }\n\n const children = cache.parentToChildren.get(pointer) ?? [];\n for (const childPointer of children) {\n let childResult: Partial<PointerDependenciesResult> = {\n subtreeDependencies: cache.subtreeDependencies.get(childPointer),\n transitiveDependencies: cache.transitiveDependencies.get(childPointer),\n };\n if (\n !childResult.subtreeDependencies ||\n !childResult.transitiveDependencies\n ) {\n childResult = collectPointerDependencies({\n cache,\n graph,\n pointer: childPointer,\n visited,\n });\n cache.transitiveDependencies.set(\n childPointer,\n childResult.transitiveDependencies!,\n );\n cache.subtreeDependencies.set(\n childPointer,\n childResult.subtreeDependencies!,\n );\n }\n for (const dependency of childResult.transitiveDependencies!) {\n transitiveDependencies.add(dependency);\n }\n for (const dependency of childResult.subtreeDependencies!) {\n subtreeDependencies.add(dependency);\n }\n }\n\n cache.transitiveDependencies.set(pointer, transitiveDependencies);\n cache.subtreeDependencies.set(pointer, subtreeDependencies);\n return {\n subtreeDependencies,\n transitiveDependencies,\n };\n};\n\n/**\n * Propagates scopes through the graph using a worklist algorithm.\n * Each node's scopes will be updated to include any scopes inherited via $ref dependencies, combinator/child relationships, and parent relationships.\n * Handles cycles and deep chains efficiently.\n *\n * Whenever a node's scopes change, all dependents are notified:\n * - Its parent (if any)\n * - All nodes that reference it via $ref (reverse dependencies)\n * - Combinator parents (allOf/anyOf/oneOf) if applicable\n *\n * @param graph - The Graph structure containing nodes, dependencies, and reverseNodeDependencies.\n */\nexport const propagateScopes = (graph: Graph): void => {\n const worklist: Set<string> = new Set(\n Array.from(graph.nodes.entries())\n .filter(([, nodeInfo]) => nodeInfo.scopes && nodeInfo.scopes.size > 0)\n .map(([pointer]) => pointer),\n );\n\n /**\n * Notifies all dependents of a node that its scopes may have changed.\n * Dependents include:\n * - The parent node (if any)\n * - All nodes that reference this node via $ref (reverse dependencies)\n * - Combinator parents (allOf/anyOf/oneOf) if this node is a combinator child\n *\n * @param pointer - The JSON pointer of the node whose dependents to notify\n * @param nodeInfo - The NodeInfo of the node\n * @param childPointer - (Optional) The pointer of the child, used to detect combinator parents\n */\n const notifyAllDependents = (\n pointer: string,\n nodeInfo: NodeInfo,\n childPointer?: string,\n ) => {\n if (nodeInfo.parentPointer) {\n worklist.add(nodeInfo.parentPointer);\n }\n const reverseNodeDependencies = graph.reverseNodeDependencies.get(pointer);\n if (reverseNodeDependencies) {\n for (const dependentPointer of reverseNodeDependencies) {\n worklist.add(dependentPointer);\n }\n }\n if (childPointer) {\n // If this is a combinator child, notify the combinator parent\n const combinatorChildMatch = childPointer.match(\n /(.*)\\/(allOf|anyOf|oneOf)\\/\\d+$/,\n );\n if (combinatorChildMatch) {\n const combinatorParentPointer = combinatorChildMatch[1];\n if (combinatorParentPointer) {\n worklist.add(combinatorParentPointer);\n }\n }\n }\n };\n\n /**\n * Propagates scopes from a child node to its parent node.\n * If the parent's scopes change, notifies all dependents.\n *\n * @param pointer - The parent node's pointer\n * @param nodeInfo - The parent node's NodeInfo\n * @param childPointer - The child node's pointer\n */\n const propagateChildScopes = (\n pointer: string,\n nodeInfo: NodeInfo,\n childPointer: string,\n ): void => {\n if (!nodeInfo?.scopes) return;\n const childInfo = graph.nodes.get(childPointer);\n if (!childInfo?.scopes) return;\n const changed = propagateScopesToNode(childInfo, nodeInfo);\n if (changed) {\n notifyAllDependents(pointer, nodeInfo, childPointer);\n }\n };\n\n while (worklist.size > 0) {\n const pointer = worklist.values().next().value!;\n worklist.delete(pointer);\n\n const nodeInfo = graph.nodes.get(pointer);\n if (!nodeInfo) continue;\n\n if (!nodeInfo.scopes) {\n nodeInfo.scopes = new Set();\n }\n\n const node = nodeInfo.node as Record<string, unknown>;\n\n // Propagate scopes from all child schema relationships (combinators, properties, etc.)\n for (const [keyword, type] of childSchemaRelationships) {\n if (!node || typeof node !== 'object' || !(keyword in node)) continue;\n const value = node[keyword];\n if (type === 'array' && value instanceof Array) {\n for (let index = 0; index < value.length; index++) {\n const childPointer = `${pointer}/${keyword}/${index}`;\n propagateChildScopes(pointer, nodeInfo, childPointer);\n }\n } else if (\n type === 'objectMap' &&\n typeof value === 'object' &&\n value !== null &&\n !(value instanceof Array)\n ) {\n for (const key of Object.keys(value)) {\n const childPointer = `${pointer}/${keyword}/${key}`;\n propagateChildScopes(pointer, nodeInfo, childPointer);\n }\n } else if (\n type === 'single' &&\n typeof value === 'object' &&\n value !== null\n ) {\n const childPointer = `${pointer}/${keyword}`;\n propagateChildScopes(pointer, nodeInfo, childPointer);\n } else if (type === 'singleOrArray') {\n if (value instanceof Array) {\n for (let index = 0; index < value.length; index++) {\n const childPointer = `${pointer}/${keyword}/${index}`;\n propagateChildScopes(pointer, nodeInfo, childPointer);\n }\n } else if (typeof value === 'object' && value !== null) {\n const childPointer = `${pointer}/${keyword}`;\n propagateChildScopes(pointer, nodeInfo, childPointer);\n }\n }\n }\n\n // Propagate scopes from $ref dependencies\n const nodeDependencies = graph.nodeDependencies.get(pointer);\n if (nodeDependencies) {\n for (const depPointer of nodeDependencies) {\n const depNode = graph.nodes.get(depPointer);\n if (depNode?.scopes) {\n const changed = propagateScopesToNode(depNode, nodeInfo);\n if (changed) {\n notifyAllDependents(pointer, nodeInfo);\n }\n }\n }\n }\n\n // Propagate scopes up the parent chain\n if (nodeInfo.parentPointer) {\n const parentInfo = graph.nodes.get(nodeInfo.parentPointer);\n if (parentInfo) {\n const changed = propagateScopesToNode(nodeInfo, parentInfo);\n if (changed) {\n notifyAllDependents(nodeInfo.parentPointer, parentInfo);\n }\n }\n }\n }\n};\n\n/**\n * Propagates scopes from one node to another.\n * Adds any scopes from fromNodeInfo to toNodeInfo that are not already present.\n * Returns true if any scopes were added, false otherwise.\n *\n * @param fromNodeInfo - The node to propagate scopes from\n * @param toNodeInfo - The node to propagate scopes to\n * @returns boolean - Whether any scopes were added\n */\nconst propagateScopesToNode = (\n fromNodeInfo: NodeInfo,\n toNodeInfo: NodeInfo,\n): boolean => {\n if (!fromNodeInfo.scopes) {\n return false;\n }\n\n if (!toNodeInfo.scopes) {\n toNodeInfo.scopes = new Set();\n }\n\n let changed = false;\n\n for (const scope of fromNodeInfo.scopes) {\n if (!toNodeInfo.scopes.has(scope)) {\n toNodeInfo.scopes.add(scope);\n changed = true;\n }\n }\n\n return changed;\n};\n\n/**\n * Seeds each node in the graph with its local access scope(s) based on its own properties.\n * - 'read' if readOnly: true\n * - 'write' if writeOnly: true\n * - 'normal' if node is an object property\n *\n * Only non-array objects are considered for scope seeding.\n *\n * @param nodes - Map of JSON Pointer to NodeInfo.\n */\nexport const seedLocalScopes = (nodes: Graph['nodes']): void => {\n for (const [pointer, nodeInfo] of nodes) {\n const { node } = nodeInfo;\n\n if (typeof node !== 'object' || node === null || node instanceof Array) {\n continue;\n }\n\n if ('readOnly' in node && node.readOnly === true) {\n nodeInfo.scopes = new Set(['read']);\n } else if ('writeOnly' in node && node.writeOnly === true) {\n nodeInfo.scopes = new Set(['write']);\n } else if (pointer.match(/\\/properties\\/[^/]+$/)) {\n nodeInfo.scopes = new Set(['normal']);\n }\n }\n};\n\n/**\n * Builds a graph of all nodes in an OpenAPI spec, indexed by normalized JSON Pointer,\n * and tracks all $ref dependencies and reverse dependencies between nodes.\n *\n * - All keys in the returned maps are normalized JSON Pointers (RFC 6901, always starting with '#').\n * - The `nodes` map allows fast lookup of any node and its parent/key context.\n * - The `dependencies` map records, for each node, the set of normalized pointers it references via $ref.\n * - The `reverseNodeDependencies` map records, for each node, the set of nodes that reference it via $ref.\n * - After construction, all nodes will have their local and propagated scopes annotated.\n *\n * @param root The root object (e.g., the OpenAPI spec)\n * @returns An object with:\n * - nodes: Map from normalized JSON Pointer string to NodeInfo\n * - dependencies: Map from normalized JSON Pointer string to Set of referenced normalized JSON Pointers\n * - reverseNodeDependencies: Map from normalized JSON Pointer string to Set of referencing normalized JSON Pointers\n */\nexport const buildGraph = (\n root: unknown,\n logger: Logger,\n): {\n graph: Graph;\n} => {\n const eventBuildGraph = logger.timeEvent('build-graph');\n const graph: Graph = {\n nodeDependencies: new Map(),\n nodes: new Map(),\n reverseNodeDependencies: new Map(),\n subtreeDependencies: new Map(),\n transitiveDependencies: new Map(),\n };\n\n const walk = ({\n key,\n node,\n parentPointer,\n path,\n }: NodeInfo & {\n path: ReadonlyArray<string | number>;\n }) => {\n if (typeof node !== 'object' || node === null) {\n return;\n }\n\n const pointer = pathToJsonPointer(path);\n\n let deprecated: boolean | undefined;\n let tags: Set<string> | undefined;\n\n if (typeof node === 'object' && node !== null) {\n // Check for deprecated property\n if ('deprecated' in node && typeof node.deprecated === 'boolean') {\n deprecated = Boolean(node.deprecated);\n }\n // If this node has a $ref, record the dependency\n if ('$ref' in node && typeof node.$ref === 'string') {\n const refPointer = normalizeJsonPointer(node.$ref);\n if (!graph.nodeDependencies.has(pointer)) {\n graph.nodeDependencies.set(pointer, new Set());\n }\n graph.nodeDependencies.get(pointer)!.add(refPointer);\n }\n // Check for tags property (should be an array of strings)\n if ('tags' in node && node.tags instanceof Array) {\n tags = new Set(node.tags.filter((tag) => typeof tag === 'string'));\n }\n }\n\n graph.nodes.set(pointer, { deprecated, key, node, parentPointer, tags });\n\n if (node instanceof Array) {\n node.forEach((item, index) =>\n walk({\n key: index,\n node: item,\n parentPointer: pointer,\n path: [...path, index],\n }),\n );\n } else {\n for (const [childKey, value] of Object.entries(node)) {\n walk({\n key: childKey,\n node: value,\n parentPointer: pointer,\n path: [...path, childKey],\n });\n }\n }\n };\n\n walk({\n key: null,\n node: root,\n parentPointer: null,\n path: [],\n });\n\n const cache: Cache = {\n parentToChildren: new Map(),\n subtreeDependencies: new Map(),\n transitiveDependencies: new Map(),\n };\n\n for (const [pointer, nodeInfo] of graph.nodes) {\n const parent = nodeInfo.parentPointer;\n if (!parent) continue;\n if (!cache.parentToChildren.has(parent)) {\n cache.parentToChildren.set(parent, []);\n }\n cache.parentToChildren.get(parent)!.push(pointer);\n }\n\n for (const [pointerFrom, pointers] of graph.nodeDependencies) {\n for (const pointerTo of pointers) {\n if (!graph.reverseNodeDependencies.has(pointerTo)) {\n graph.reverseNodeDependencies.set(pointerTo, new Set());\n }\n graph.reverseNodeDependencies.get(pointerTo)!.add(pointerFrom);\n }\n }\n\n seedLocalScopes(graph.nodes);\n propagateScopes(graph);\n annotateChildScopes(graph.nodes);\n\n for (const pointer of graph.nodes.keys()) {\n const result = collectPointerDependencies({\n cache,\n graph,\n pointer,\n visited: new Set(),\n });\n graph.transitiveDependencies.set(pointer, result.transitiveDependencies);\n graph.subtreeDependencies.set(pointer, result.subtreeDependencies);\n }\n\n eventBuildGraph.timeEnd();\n\n // functions creating data for debug scripts located in `dev/`\n // const { maxChildren, maxDepth, totalNodes } = debugTools.graph.analyzeStructure(graph);\n // const nodesForViz = debugTools.graph.exportForVisualization(graph);\n // fs.writeFileSync('dev/graph.json', JSON.stringify(nodesForViz, null, 2));\n\n return { graph };\n};\n","import type { Graph } from '~/graph';\nimport type { Logger } from '~/utils/logger';\nimport { jsonPointerToPath } from '~/utils/ref';\n\nimport type { Config } from '../../../types/config';\nimport deepEqual from '../utils/deepEqual';\nimport { buildGraph, type Scope } from '../utils/graph';\nimport { buildName } from '../utils/name';\nimport { deepClone } from '../utils/schema';\nimport { childSchemaRelationships } from '../utils/schemaChildRelationships';\nimport {\n getSchemasObject,\n hasComponentsSchemasObject,\n hasDefinitionsObject,\n} from '../utils/transforms';\nimport {\n getUniqueComponentName,\n isPathRootSchema,\n specToSchemasPointerNamespace,\n} from './utils';\n\ntype OriginalSchemas = Record<string, unknown>;\n\ntype SplitSchemas = {\n /** Key is the original schema pointer. */\n mapping: Record<\n string,\n {\n read?: string;\n write?: string;\n }\n >;\n /** splitPointer -> originalPointer */\n reverseMapping: Record<string, string>;\n /** name -> schema object */\n schemas: Record<string, unknown>;\n};\n\ntype ReadWriteConfig = Config['parser']['transforms']['readWrite'];\n\nconst schemaKeys = new Set([\n 'additionalProperties',\n 'allOf',\n 'anyOf',\n 'items',\n 'not',\n 'oneOf',\n 'patternProperties',\n 'properties',\n 'schema',\n]);\n\nconst getComponentContext = (\n path: ReadonlyArray<string | number>,\n): Scope | undefined => {\n // OpenAPI 3.x: #/components/{type}/{name}\n if (path.length === 3 && path[0] === 'components') {\n const type = path[1];\n if (type === 'parameters') return 'write';\n if (type === 'requestBodies') return 'write';\n if (type === 'responses') return 'read';\n if (type === 'headers') return 'read';\n }\n // OpenAPI 2.x: #/parameters/{name}, #/responses/{name}\n if (path.length === 2) {\n const type = path[0];\n if (type === 'parameters') return 'write';\n if (type === 'responses') return 'read';\n }\n return;\n};\n\n/**\n * Capture the original schema objects by pointer before splitting.\n * This is used to safely remove only the true originals after splitting,\n * even if names are swapped or overwritten by split variants.\n */\nconst captureOriginalSchemas = (\n spec: unknown,\n logger: Logger,\n): OriginalSchemas => {\n const event = logger.timeEvent('capture-original-schemas');\n const originals: OriginalSchemas = {};\n if (hasComponentsSchemasObject(spec)) {\n for (const [name, obj] of Object.entries(\n (spec as any).components.schemas,\n )) {\n originals[`#/components/schemas/${name}`] = obj;\n }\n } else if (hasDefinitionsObject(spec)) {\n for (const [name, obj] of Object.entries((spec as any).definitions)) {\n originals[`#/definitions/${name}`] = obj;\n }\n }\n event.timeEnd();\n return originals;\n};\n\n/**\n * Inserts split schemas into the spec at the correct location (OpenAPI 3.x or 2.0).\n * This function is robust to spec version and will assign all split schemas\n * to either components.schemas (OAS3) or definitions (OAS2).\n *\n * @param spec - The OpenAPI spec object\n * @param split - The split schemas (from splitSchemas)\n */\nconst insertSplitSchemasIntoSpec = ({\n logger,\n spec,\n split,\n}: {\n logger: Logger;\n spec: unknown;\n split: Pick<SplitSchemas, 'schemas'>;\n}) => {\n const event = logger.timeEvent('insert-split-schemas-into-spec');\n if (hasComponentsSchemasObject(spec)) {\n Object.assign((spec as any).components.schemas, split.schemas);\n } else if (hasDefinitionsObject(spec)) {\n Object.assign((spec as any).definitions, split.schemas);\n }\n event.timeEnd();\n};\n\n/**\n * Prunes a schema by removing all child schemas (in any structural keyword)\n * that are marked with the given scope (readOnly/writeOnly), or that are $ref to a schema\n * that is exclusively the excluded scope (according to the graph).\n *\n * Uses childSchemaRelationships for parity with graph traversal.\n * Returns true if the schema itself should be removed from its parent.\n *\n * @param graph - The Graph containing all nodes and their scopes\n * @param schema - The schema object to prune\n * @param scope - The scope to exclude ('readOnly' or 'writeOnly')\n * @returns boolean - Whether the schema should be removed from its parent\n */\nconst pruneSchemaByScope = (\n graph: Graph,\n schema: unknown,\n scope: 'readOnly' | 'writeOnly',\n): boolean => {\n if (schema && typeof schema === 'object') {\n // Handle $ref schemas\n if ('$ref' in schema && typeof schema.$ref === 'string') {\n const nodeInfo = graph.nodes.get(schema.$ref);\n if (nodeInfo?.scopes) {\n // Only remove $ref if the referenced schema is *exclusively* the excluded scope.\n // This ensures 'normal' or multi-scope schemas are always kept.\n if (\n (scope === 'writeOnly' &&\n nodeInfo.scopes.size === 1 &&\n nodeInfo.scopes.has('write')) ||\n (scope === 'readOnly' &&\n nodeInfo.scopes.size === 1 &&\n nodeInfo.scopes.has('read'))\n ) {\n delete (schema as Record<string, unknown>)['$ref'];\n // If the schema is now empty, remove it\n if (\n !childSchemaRelationships.some(([keyword]) => keyword in schema)\n ) {\n return true;\n }\n }\n }\n }\n // Recursively prune all child schemas according to childSchemaRelationships\n for (const [keyword, type] of childSchemaRelationships) {\n if (!(keyword in schema)) {\n continue;\n }\n const value = (schema as Record<string, unknown>)[keyword];\n if (type === 'array' && value instanceof Array) {\n for (let index = value.length - 1; index >= 0; index--) {\n const item = value[index];\n if (\n item &&\n typeof item === 'object' &&\n (item as Record<string, unknown>)[scope] === true\n ) {\n value.splice(index, 1);\n } else {\n const shouldRemove = pruneSchemaByScope(graph, item, scope);\n if (shouldRemove) value.splice(index, 1);\n }\n }\n if (!value.length) {\n delete (schema as Record<string, unknown>)[keyword];\n }\n } else if (\n type === 'objectMap' &&\n typeof value === 'object' &&\n value !== null &&\n !(value instanceof Array)\n ) {\n const objMap = value as Record<string, unknown>;\n // Track removed properties for object schemas to update required array\n const removedProperties = new Set<string>();\n\n for (const key of Object.keys(objMap)) {\n const prop = objMap[key];\n if (\n prop &&\n typeof prop === 'object' &&\n (prop as Record<string, unknown>)[scope] === true\n ) {\n delete objMap[key];\n // Track removed properties for object schemas\n if (keyword === 'properties') {\n removedProperties.add(key);\n }\n } else {\n const shouldRemove = pruneSchemaByScope(graph, prop, scope);\n if (shouldRemove) {\n delete objMap[key];\n // Track removed properties for object schemas\n if (keyword === 'properties') {\n removedProperties.add(key);\n }\n }\n }\n }\n\n // Update required array if properties were removed\n if (\n removedProperties.size > 0 &&\n keyword === 'properties' &&\n 'required' in schema &&\n Array.isArray((schema as Record<string, unknown>).required)\n ) {\n const required = (schema as Record<string, unknown>)\n .required as string[];\n const filteredRequired = required.filter(\n (prop) => !removedProperties.has(prop),\n );\n\n if (!filteredRequired.length) {\n delete (schema as Record<string, unknown>).required;\n } else {\n (schema as Record<string, unknown>).required = filteredRequired;\n }\n }\n\n if (!Object.keys(objMap).length) {\n delete (schema as Record<string, unknown>)[keyword];\n }\n } else if (\n type === 'single' &&\n typeof value === 'object' &&\n value !== null\n ) {\n if ((value as Record<string, unknown>)[scope] === true) {\n delete (schema as Record<string, unknown>)[keyword];\n } else {\n const shouldRemove = pruneSchemaByScope(graph, value, scope);\n if (shouldRemove) {\n delete (schema as Record<string, unknown>)[keyword];\n }\n }\n } else if (type === 'singleOrArray') {\n if (value instanceof Array) {\n for (let index = value.length - 1; index >= 0; index--) {\n const item = value[index];\n if (\n item &&\n typeof item === 'object' &&\n (item as Record<string, unknown>)[scope] === true\n ) {\n value.splice(index, 1);\n } else {\n const shouldRemove = pruneSchemaByScope(graph, item, scope);\n if (shouldRemove) value.splice(index, 1);\n }\n }\n if (!value.length) {\n delete (schema as Record<string, unknown>)[keyword];\n }\n } else if (typeof value === 'object' && value !== null) {\n if ((value as Record<string, unknown>)[scope] === true) {\n delete (schema as Record<string, unknown>)[keyword];\n } else {\n const shouldRemove = pruneSchemaByScope(graph, value, scope);\n if (shouldRemove) {\n delete (schema as Record<string, unknown>)[keyword];\n }\n }\n }\n }\n }\n // After all removals, if this is type: object and has no structural fields, remove it\n if (\n (schema as Record<string, unknown>).type === 'object' &&\n !childSchemaRelationships.some(([keyword]) => keyword in schema)\n ) {\n return true;\n }\n }\n return false;\n};\n\n/**\n * Remove only the true original schemas that were split, by object identity.\n * This is robust to swaps, overwrites, and name collisions.\n *\n * @param originalSchemas - Map of original pointers to their schema objects (captured before splitting)\n * @param spec - The OpenAPI spec object\n * @param split - The split mapping (from splitSchemas)\n */\nconst removeOriginalSplitSchemas = ({\n logger,\n originalSchemas,\n spec,\n split,\n}: {\n logger: Logger;\n originalSchemas: OriginalSchemas;\n spec: unknown;\n split: Pick<SplitSchemas, 'mapping'>;\n}) => {\n const event = logger.timeEvent('remove-original-split-schemas');\n const schemasObj = getSchemasObject(spec);\n\n for (const originalPointer of Object.keys(split.mapping)) {\n const path = jsonPointerToPath(originalPointer);\n const name = path[path.length - 1]!;\n if (\n typeof name === 'string' &&\n schemasObj &&\n Object.prototype.hasOwnProperty.call(schemasObj, name) &&\n schemasObj[name] === originalSchemas[originalPointer]\n ) {\n delete schemasObj[name];\n }\n }\n event.timeEnd();\n};\n\n/**\n * Splits schemas with both 'read' and 'write' scopes into read/write variants.\n * Returns the new schemas and a mapping from original pointer to new variant pointers.\n *\n * @param config - The readWrite transform config\n * @param graph - The Graph containing all nodes and their scopes\n * @param spec - The OpenAPI spec object\n * @returns SplitSchemas - The split schemas and pointer mappings\n */\nexport const splitSchemas = ({\n config,\n graph,\n logger,\n spec,\n}: {\n config: ReadWriteConfig;\n graph: Graph;\n logger: Logger;\n spec: unknown;\n}): SplitSchemas => {\n const event = logger.timeEvent('split-schemas');\n const existingNames = new Set<string>();\n const split: SplitSchemas = {\n mapping: {},\n reverseMapping: {},\n schemas: {},\n };\n\n const schemasPointerNamespace = specToSchemasPointerNamespace(spec);\n const schemasNamespaceSegments =\n schemasPointerNamespace.split('/').length - 1;\n\n /**\n * Extracts the schema name from pointer, but only if it's a top-level schema\n * pointer. Returns an empty string if it's a nested pointer.\n * @param pointer\n * @returns Schema's base name.\n */\n const pointerToSchema = (pointer: string): string => {\n if (pointer.startsWith(schemasPointerNamespace)) {\n const path = jsonPointerToPath(pointer);\n if (path.length === schemasNamespaceSegments) {\n return path[schemasNamespaceSegments - 1] || '';\n }\n }\n return '';\n };\n\n // Collect all existing schema names\n for (const pointer of graph.nodes.keys()) {\n const name = pointerToSchema(pointer);\n if (name) existingNames.add(name);\n }\n\n for (const [pointer, nodeInfo] of graph.nodes) {\n const name = pointerToSchema(pointer);\n // Only split top-level schemas, with either read-only or write-only scopes (or both).\n if (\n !name ||\n !(nodeInfo.scopes?.has('read') || nodeInfo.scopes?.has('write')) ||\n !nodeInfo.scopes?.has('normal')\n ) {\n continue;\n }\n\n // read variant\n const readSchema = deepClone<unknown>(nodeInfo.node);\n pruneSchemaByScope(graph, readSchema, 'writeOnly');\n const readBase = buildName({\n config: config.responses,\n name,\n });\n const readName =\n readBase === name\n ? readBase\n : getUniqueComponentName({\n base: readBase,\n components: existingNames,\n });\n existingNames.add(readName);\n split.schemas[readName] = readSchema;\n const readPointer = `${schemasPointerNamespace}${readName}`;\n\n // write variant\n const writeSchema = deepClone<unknown>(nodeInfo.node);\n pruneSchemaByScope(graph, writeSchema, 'readOnly');\n\n // Check if this schema (or any of its descendants) references any schema that\n // will need read/write variants. This is determined by checking transitive\n // dependencies for schemas with both 'normal' and ('read' or 'write') scopes.\n const transitiveDeps =\n graph.transitiveDependencies.get(pointer) || new Set();\n const referencesReadWriteSchemas = Array.from(transitiveDeps).some(\n (depPointer) => {\n const depNodeInfo = graph.nodes.get(depPointer);\n return (\n depNodeInfo?.scopes?.has('normal') &&\n (depNodeInfo.scopes.has('read') || depNodeInfo.scopes.has('write'))\n );\n },\n );\n\n // If pruning did not change anything (both variants equal and equal to original),\n // and the schema doesn't reference any schemas that will have read/write variants,\n // skip splitting and keep the original single schema.\n if (\n !referencesReadWriteSchemas &&\n deepEqual(readSchema, writeSchema) &&\n deepEqual(readSchema, nodeInfo.node)\n ) {\n continue;\n }\n const writeBase = buildName({\n config: config.requests,\n name,\n });\n const writeName =\n writeBase === name && writeBase !== readName\n ? writeBase\n : getUniqueComponentName({\n base: writeBase,\n components: existingNames,\n });\n existingNames.add(writeName);\n split.schemas[writeName] = writeSchema;\n const writePointer = `${schemasPointerNamespace}${writeName}`;\n\n split.mapping[pointer] = {\n read: readPointer,\n write: writePointer,\n };\n split.reverseMapping[readPointer] = pointer;\n split.reverseMapping[writePointer] = pointer;\n }\n\n event.timeEnd();\n return split;\n};\n\ntype WalkArgs = {\n context: Scope | null;\n currentPointer: string | null;\n inSchema: boolean;\n node: unknown;\n path: ReadonlyArray<string | number>;\n visited?: Set<string>;\n};\n\n/**\n * Recursively updates $ref fields in the spec to point to the correct read/write variant\n * according to the current context (read/write), using the split mapping.\n *\n * @param spec - The OpenAPI spec object\n * @param split - The split mapping (from splitSchemas)\n */\nexport const updateRefsInSpec = ({\n logger,\n spec,\n split,\n}: {\n logger: Logger;\n spec: unknown;\n split: Omit<SplitSchemas, 'schemas'>;\n}): void => {\n const event = logger.timeEvent('update-refs-in-spec');\n const schemasPointerNamespace = specToSchemasPointerNamespace(spec);\n\n const walk = ({\n context,\n currentPointer,\n inSchema,\n node,\n path,\n visited = new Set(),\n }: WalkArgs): void => {\n if (node instanceof Array) {\n node.forEach((item, index) =>\n walk({\n context,\n currentPointer,\n inSchema,\n node: item,\n path: [...path, index],\n visited,\n }),\n );\n } else if (node && typeof node === 'object') {\n // Detect if we're entering a split schema variant\n let nextPointer = currentPointer;\n let nextContext = context;\n if (isPathRootSchema(path)) {\n // Use the last path segment instead of a fixed index (path[2]) because\n // path depth varies across OAS2/OAS3 and contexts; fixed indexing is brittle.\n const nameSegment = path[path.length - 1] as string;\n nextPointer = `${schemasPointerNamespace}${nameSegment}`;\n const originalPointer = split.reverseMapping[nextPointer];\n if (originalPointer) {\n const mapping = split.mapping[originalPointer];\n if (mapping?.read === nextPointer) {\n nextContext = 'read';\n } else if (mapping?.write === nextPointer) {\n nextContext = 'write';\n }\n }\n // For schemas that are not split variants, keep the inherited context.\n // This ensures that $refs inside these schemas are resolved based on\n // where the schema is actually used (requestBody vs responses), not\n // based on the schema's own scopes which track readOnly/writeOnly fields.\n }\n\n const compContext = getComponentContext(path);\n if (compContext !== undefined) {\n // For each component, walk with the correct context\n for (const key in node) {\n if (!Object.prototype.hasOwnProperty.call(node, key)) {\n continue;\n }\n walk({\n context: compContext,\n currentPointer: nextPointer,\n inSchema: false,\n node: (node as Record<string, unknown>)[key],\n path: [...path, key],\n visited,\n });\n }\n return;\n }\n\n for (const key in node) {\n if (!Object.prototype.hasOwnProperty.call(node, key)) {\n continue;\n }\n const value = (node as Record<string, unknown>)[key];\n\n // Only treat context switches at the OpenAPI structure level (not inside schemas)\n if (!inSchema) {\n if (key === 'requestBody') {\n walk({\n context: 'write',\n currentPointer: nextPointer,\n inSchema: false,\n node: value,\n path: [...path, key],\n visited,\n });\n continue;\n }\n if (key === 'responses') {\n walk({\n context: 'read',\n currentPointer: nextPointer,\n inSchema: false,\n node: value,\n path: [...path, key],\n visited,\n });\n continue;\n }\n if (key === 'parameters' && Array.isArray(value)) {\n value.forEach((param, index) => {\n if (param && typeof param === 'object' && 'schema' in param) {\n walk({\n context: 'write',\n currentPointer: nextPointer,\n inSchema: true,\n node: param.schema,\n path: [...path, key, index, 'schema'],\n visited,\n });\n }\n // Also handle content (OpenAPI 3.x)\n if (param && typeof param === 'object' && 'content' in param) {\n walk({\n context: 'write',\n currentPointer: nextPointer,\n inSchema: false,\n node: param.content,\n path: [...path, key, index, 'content'],\n visited,\n });\n }\n });\n continue;\n }\n // OpenAPI 3.x: headers in responses\n if (\n key === 'headers' &&\n typeof value === 'object' &&\n value !== null\n ) {\n for (const headerKey in value) {\n if (!Object.prototype.hasOwnProperty.call(value, headerKey)) {\n continue;\n }\n walk({\n context: 'read',\n currentPointer: nextPointer,\n inSchema: false,\n node: (value as Record<string, unknown>)[headerKey],\n path: [...path, key, headerKey],\n visited,\n });\n }\n continue;\n }\n }\n\n // Entering a schema context\n if (schemaKeys.has(key)) {\n walk({\n context: nextContext,\n currentPointer: nextPointer,\n inSchema: true,\n node: value,\n path: [...path, key],\n visited,\n });\n } else if (key === '$ref' && typeof value === 'string') {\n // Prefer exact match first\n const map = split.mapping[value];\n if (map) {\n if (nextContext === 'read' && map.read) {\n (node as Record<string, unknown>)[key] = map.read;\n } else if (nextContext === 'write' && map.write) {\n (node as Record<string, unknown>)[key] = map.write;\n } else if (!nextContext && map.read) {\n // For schemas with no context (unused in operations), default to read variant\n // This ensures $refs in unused schemas don't point to removed originals\n (node as Record<string, unknown>)[key] = map.read;\n }\n }\n } else {\n walk({\n context: nextContext,\n currentPointer: nextPointer,\n inSchema,\n node: value,\n path: [...path, key],\n visited,\n });\n }\n }\n }\n };\n walk({\n context: null,\n currentPointer: null,\n inSchema: false,\n node: spec,\n path: [],\n });\n event.timeEnd();\n};\n\n/**\n * Orchestrates the full read/write transform:\n * - Captures original schemas\n * - Splits schemas into read/write variants\n * - Inserts split schemas into the spec\n * - Updates $refs throughout the spec\n * - Removes original schemas that were split\n *\n * @param config - The readWrite transform config\n * @param spec - The OpenAPI spec object\n */\nexport const readWriteTransform = ({\n config,\n logger,\n spec,\n}: {\n config: ReadWriteConfig;\n logger: Logger;\n spec: unknown;\n}) => {\n const { graph } = buildGraph(spec, logger);\n const originalSchemas = captureOriginalSchemas(spec, logger);\n const split = splitSchemas({ config, graph, logger, spec });\n insertSplitSchemasIntoSpec({ logger, spec, split });\n updateRefsInSpec({ logger, spec, split });\n removeOriginalSplitSchemas({ logger, originalSchemas, spec, split });\n};\n","import type { Context } from '~/ir/context';\n\nimport { enumsTransform } from './enums';\nimport { propertiesRequiredByDefaultTransform } from './propertiesRequiredByDefault';\nimport { readWriteTransform } from './readWrite';\n\nexport const transformOpenApiSpec = ({ context }: { context: Context }) => {\n const { logger } = context;\n const eventTransformOpenApiSpec = logger.timeEvent('transform-openapi-spec');\n if (context.config.parser.transforms.enums.enabled) {\n enumsTransform({\n config: context.config.parser.transforms.enums,\n spec: context.spec,\n });\n }\n\n if (context.config.parser.transforms.propertiesRequiredByDefault) {\n propertiesRequiredByDefaultTransform({ spec: context.spec });\n }\n\n if (context.config.parser.transforms.readWrite.enabled) {\n readWriteTransform({\n config: context.config.parser.transforms.readWrite,\n logger,\n spec: context.spec,\n });\n }\n eventTransformOpenApiSpec.timeEnd();\n};\n","import type { IR } from '~/ir/types';\n\nexport const mergeParametersObjects = ({\n source,\n target,\n}: {\n source: IR.ParametersObject | undefined;\n target: IR.ParametersObject | undefined;\n}): IR.ParametersObject | undefined => {\n const result = { ...target };\n\n if (source) {\n if (source.cookie) {\n if (result.cookie) {\n result.cookie = {\n ...result.cookie,\n ...source.cookie,\n };\n } else {\n result.cookie = source.cookie;\n }\n }\n\n if (source.header) {\n if (result.header) {\n result.header = {\n ...result.header,\n ...source.header,\n };\n } else {\n result.header = source.header;\n }\n }\n\n if (source.path) {\n if (result.path) {\n result.path = {\n ...result.path,\n ...source.path,\n };\n } else {\n result.path = source.path;\n }\n }\n\n if (source.query) {\n if (result.query) {\n result.query = {\n ...result.query,\n ...source.query,\n };\n } else {\n result.query = source.query;\n }\n }\n }\n\n if (!Object.keys(result).length) {\n return;\n }\n\n return result;\n};\n","import colors from 'ansi-colors';\n\nimport type { Context } from '~/ir/context';\n\nexport interface ValidatorIssue {\n /**\n * Machine-readable issue code\n *\n * @example\n * 'invalid_type'\n */\n code: 'duplicate_key' | 'invalid_type' | 'missing_required_field';\n /**\n * Optional additional data.\n *\n * @example\n * 'expectedType'\n */\n context?: Record<string, any>;\n /**\n * Human-readable issue summary.\n */\n message: string;\n /**\n * JSONPath-like array to issue location.\n */\n path: ReadonlyArray<string | number>;\n /**\n * Error severity.\n */\n severity: 'error' | 'warning';\n}\n\nexport interface ValidatorResult {\n issues: ReadonlyArray<ValidatorIssue>;\n valid: boolean;\n}\n\nconst isSimpleKey = (key: string) => /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key);\n\nconst formatPath = (path: ReadonlyArray<string | number>): string =>\n path\n .map((segment, i) => {\n if (typeof segment === 'number') {\n return `[${segment}]`;\n }\n\n if (i === 0) {\n // first segment no dot or brackets\n return segment;\n }\n\n return isSimpleKey(segment)\n ? `.${segment}`\n : `['${segment.replace(/\"/g, \"\\\\'\")}']`;\n })\n .join('');\n\nconst formatValidatorIssue = (issue: ValidatorIssue): string => {\n const pathStr = formatPath(issue.path);\n const level =\n issue.severity === 'error' ? colors.bold.red : colors.bold.yellow;\n\n const highlightedMessage = issue.message.replace(/`([^`]+)`/g, (_, code) =>\n colors.yellow(`\\`${code}\\``),\n );\n\n return `${level(`[${issue.severity.toUpperCase()}]`)} ${colors.cyan(pathStr)}: ${highlightedMessage}`;\n};\n\nconst shouldPrint = ({\n context,\n issue,\n}: {\n context: Context;\n issue: ValidatorIssue;\n}) => {\n if (context.config.logs.level === 'silent') {\n return false;\n }\n\n if (issue.severity === 'error') {\n return context.config.logs.level !== 'warn';\n }\n\n return true;\n};\n\nexport const handleValidatorResult = ({\n context,\n result,\n}: {\n context: Context;\n result: ValidatorResult;\n}) => {\n for (const issue of result.issues) {\n if (shouldPrint({ context, issue })) {\n console.log(formatValidatorIssue(issue));\n }\n }\n\n if (!result.valid) {\n process.exit(1);\n }\n};\n","import { createOperationKey } from '~/ir/operation';\nimport { addNamespace, removeNamespace } from '~/openApi/shared/utils/filter';\nimport { httpMethods } from '~/openApi/shared/utils/operation';\nimport type { Logger } from '~/utils/logger';\n\nimport type {\n OpenApiV2_0_X,\n OperationObject,\n PathItemObject,\n PathsObject,\n} from '../types/spec';\n\n/**\n * Replace source spec with filtered version.\n */\nexport const filterSpec = ({\n logger,\n operations,\n preserveOrder,\n schemas,\n spec,\n}: {\n logger: Logger;\n operations: Set<string>;\n parameters: Set<string>;\n preserveOrder: boolean;\n requestBodies: Set<string>;\n responses: Set<string>;\n schemas: Set<string>;\n spec: OpenApiV2_0_X;\n}) => {\n const eventFilterSpec = logger.timeEvent('filter-spec');\n if (spec.definitions) {\n const filtered: typeof spec.definitions = {};\n\n if (preserveOrder) {\n for (const [name, source] of Object.entries(spec.definitions)) {\n if (schemas.has(addNamespace('schema', name))) {\n filtered[name] = source;\n }\n }\n } else {\n for (const key of schemas) {\n const { name } = removeNamespace(key);\n const source = spec.definitions[name];\n if (source) {\n filtered[name] = source;\n }\n }\n }\n\n spec.definitions = filtered;\n }\n\n if (spec.paths) {\n for (const entry of Object.entries(spec.paths)) {\n const path = entry[0] as keyof PathsObject;\n const pathItem = entry[1] as PathItemObject;\n\n for (const method of httpMethods) {\n // @ts-expect-error\n const operation = pathItem[method] as OperationObject;\n if (!operation) {\n continue;\n }\n\n const key = addNamespace(\n 'operation',\n createOperationKey({ method, path }),\n );\n if (!operations.has(key)) {\n // @ts-expect-error\n delete pathItem[method];\n }\n }\n\n // remove paths that have no operations left\n if (!Object.keys(pathItem).length) {\n delete spec.paths[path];\n }\n }\n }\n eventFilterSpec.timeEnd();\n};\n","const fileLikeRegExp =\n /^(application\\/(pdf|rtf|msword|vnd\\.(ms-|openxmlformats-officedocument\\.)|zip|x-(7z|tar|rar|zip|iso)|octet-stream|gzip|x-msdownload|json\\+download|xml|x-yaml|x-7z-compressed|x-tar)|text\\/(yaml|css|javascript)|audio\\/(mpeg|wav)|video\\/(mp4|x-matroska)|image\\/(vnd\\.adobe\\.photoshop|svg\\+xml))(; ?charset=[^;]+)?$/i;\nconst jsonMimeRegExp = /^application\\/(.*\\+)?json(;.*)?$/i;\nconst multipartFormDataMimeRegExp = /^multipart\\/form-data(;.*)?$/i;\nconst textMimeRegExp = /^text\\/[a-z0-9.+-]+(;.*)?$/i;\nconst xWwwFormUrlEncodedMimeRegExp =\n /^application\\/x-www-form-urlencoded(;.*)?$/i;\nconst octetStreamMimeRegExp = /^application\\/octet-stream(;.*)?$/i;\n\nexport type IRMediaType =\n | 'form-data'\n | 'json'\n | 'text'\n | 'url-search-params'\n | 'octet-stream';\n\nexport const isMediaTypeFileLike = ({\n mediaType,\n}: {\n mediaType: string;\n}): boolean => {\n fileLikeRegExp.lastIndex = 0;\n return fileLikeRegExp.test(mediaType);\n};\n\nexport const mediaTypeToIrMediaType = ({\n mediaType,\n}: {\n mediaType: string;\n}): IRMediaType | undefined => {\n jsonMimeRegExp.lastIndex = 0;\n if (jsonMimeRegExp.test(mediaType)) {\n return 'json';\n }\n\n multipartFormDataMimeRegExp.lastIndex = 0;\n if (multipartFormDataMimeRegExp.test(mediaType)) {\n return 'form-data';\n }\n\n textMimeRegExp.lastIndex = 0;\n if (textMimeRegExp.test(mediaType)) {\n return 'text';\n }\n\n xWwwFormUrlEncodedMimeRegExp.lastIndex = 0;\n if (xWwwFormUrlEncodedMimeRegExp.test(mediaType)) {\n return 'url-search-params';\n }\n\n octetStreamMimeRegExp.lastIndex = 0;\n if (octetStreamMimeRegExp.test(mediaType)) {\n return 'octet-stream';\n }\n\n return;\n};\n","import type { IRMediaType } from '~/ir/mediaType';\nimport { isMediaTypeFileLike, mediaTypeToIrMediaType } from '~/ir/mediaType';\n\nimport type {\n ReferenceObject,\n ResponseObject,\n SchemaObject,\n} from '../types/spec';\n\ninterface Content {\n mediaType: string;\n schema: SchemaObject | ReferenceObject | undefined;\n type: IRMediaType | undefined;\n}\n\nexport const contentToSchema = ({\n content,\n}: {\n content: Content;\n}): SchemaObject | undefined => {\n const { mediaType, schema } = content;\n\n if (schema && '$ref' in schema) {\n return {\n allOf: [{ ...schema }],\n };\n }\n\n if (!schema) {\n if (isMediaTypeFileLike({ mediaType })) {\n return {\n format: 'binary',\n type: 'string',\n };\n }\n return;\n }\n\n if (\n schema.type === 'string' &&\n !schema.format &&\n isMediaTypeFileLike({ mediaType })\n ) {\n return {\n ...schema,\n format: 'binary',\n };\n }\n\n return schema;\n};\n\nexport const mediaTypeObjects = ({\n mimeTypes,\n response,\n}: {\n mimeTypes: ReadonlyArray<string> | undefined;\n response: Pick<ResponseObject, 'schema'>;\n}): ReadonlyArray<Content> => {\n const objects: Array<Content> = [];\n\n for (const mediaType of mimeTypes ?? []) {\n objects.push({\n mediaType,\n schema: response.schema,\n type: mediaTypeToIrMediaType({ mediaType }),\n });\n }\n\n return objects;\n};\n","import type { Config } from '~/types/config';\n\nimport type { IR } from './types';\n\nexport function getPaginationKeywordsRegExp(\n pagination: Config['parser']['pagination'],\n): RegExp {\n const pattern = `^(${pagination.keywords.join('|')})$`;\n return new RegExp(pattern);\n}\n\nexport interface Pagination {\n in: 'body' | 'cookie' | 'header' | 'path' | 'query';\n name: string;\n schema: IR.SchemaObject;\n}\n","import { refToName } from '~/utils/ref';\n\nexport const discriminatorValues = (\n $ref: string,\n mapping?: Record<string, string>,\n shouldUseRefAsValue?: () => boolean,\n): ReadonlyArray<string> => {\n const values: Array<string> = [];\n\n for (const name in mapping) {\n if (mapping[name] === $ref) {\n values.push(name);\n }\n }\n\n if (!values.length && (!shouldUseRefAsValue || shouldUseRefAsValue())) {\n return [refToName($ref)];\n }\n\n return values;\n};\n","import type { Context } from '~/ir/context';\nimport type { IR } from '~/ir/types';\nimport { addItemsToSchema } from '~/ir/utils';\nimport type {\n SchemaState,\n SchemaType,\n SchemaWithRequired,\n} from '~/openApi/shared/types/schema';\nimport { discriminatorValues } from '~/openApi/shared/utils/discriminator';\nimport { refToName } from '~/utils/ref';\n\nimport type { SchemaObject } from '../types/spec';\n\nexport const getSchemaType = ({\n schema,\n}: {\n schema: SchemaObject;\n}): SchemaType<SchemaObject> | undefined => {\n if (schema.type) {\n return schema.type;\n }\n\n // infer object based on the presence of properties\n if (schema.properties) {\n return 'object';\n }\n\n return;\n};\n\nconst parseSchemaJsDoc = ({\n irSchema,\n schema,\n}: {\n irSchema: IR.SchemaObject;\n schema: SchemaObject;\n}) => {\n if (schema.example) {\n irSchema.example = schema.example;\n }\n\n if (schema.description) {\n irSchema.description = schema.description;\n }\n\n if (schema.title) {\n irSchema.title = schema.title;\n }\n};\n\nconst parseSchemaMeta = ({\n irSchema,\n schema,\n}: {\n irSchema: IR.SchemaObject;\n schema: SchemaObject;\n}) => {\n if (schema.default !== undefined) {\n irSchema.default = schema.default;\n }\n\n if (schema.exclusiveMaximum) {\n if (schema.maximum !== undefined) {\n irSchema.exclusiveMaximum = schema.maximum;\n }\n } else if (schema.maximum !== undefined) {\n irSchema.maximum = schema.maximum;\n }\n\n if (schema.exclusiveMinimum) {\n if (schema.minimum !== undefined) {\n irSchema.exclusiveMinimum = schema.minimum;\n }\n } else if (schema.minimum !== undefined) {\n irSchema.minimum = schema.minimum;\n }\n\n if (schema.format) {\n irSchema.format = schema.format;\n }\n\n if (schema.maxItems !== undefined) {\n irSchema.maxItems = schema.maxItems;\n }\n\n if (schema.maxLength !== undefined) {\n irSchema.maxLength = schema.maxLength;\n }\n\n if (schema.minItems !== undefined) {\n irSchema.minItems = schema.minItems;\n }\n\n if (schema.minLength !== undefined) {\n irSchema.minLength = schema.minLength;\n }\n\n if (schema.pattern) {\n irSchema.pattern = schema.pattern;\n }\n\n if (schema.readOnly) {\n irSchema.accessScope = 'read';\n }\n};\n\nconst parseArray = ({\n context,\n irSchema = {},\n schema,\n state,\n}: {\n context: Context;\n irSchema?: IR.SchemaObject;\n schema: SchemaObject;\n state: SchemaState;\n}): IR.SchemaObject => {\n if (schema.maxItems && schema.maxItems === schema.minItems) {\n irSchema.type = 'tuple';\n } else {\n irSchema.type = 'array';\n }\n\n let schemaItems: Array<IR.SchemaObject> = [];\n\n if (schema.items) {\n const irItemsSchema = schemaToIrSchema({\n context,\n schema: schema.items,\n state,\n });\n\n if (\n !schemaItems.length &&\n schema.maxItems &&\n schema.maxItems === schema.minItems\n ) {\n schemaItems = Array(schema.maxItems).fill(irItemsSchema);\n } else {\n if ('$ref' in schema.items) {\n schemaItems.push(irItemsSchema);\n } else {\n const ofArray = schema.items.allOf;\n if (ofArray && ofArray.length > 1 && !schema.items['x-nullable']) {\n // bring composition up to avoid incorrectly nested arrays\n irSchema = {\n ...irSchema,\n ...irItemsSchema,\n };\n } else {\n schemaItems.push(irItemsSchema);\n }\n }\n }\n }\n\n irSchema = addItemsToSchema({\n items: schemaItems,\n schema: irSchema,\n });\n\n return irSchema;\n};\n\nconst parseBoolean = ({\n irSchema = {},\n}: {\n context: Context;\n irSchema?: IR.SchemaObject;\n schema: SchemaObject;\n state: SchemaState;\n}): IR.SchemaObject => {\n irSchema.type = 'boolean';\n\n return irSchema;\n};\n\nconst parseNumber = ({\n irSchema = {},\n schema,\n}: {\n context: Context;\n irSchema?: IR.SchemaObject;\n schema: SchemaWithRequired<SchemaObject, 'type'>;\n state: SchemaState;\n}): IR.SchemaObject => {\n irSchema.type = schema.type;\n\n return irSchema;\n};\n\nconst parseObject = ({\n context,\n irSchema = {},\n schema,\n state,\n}: {\n context: Context;\n irSchema?: IR.SchemaObject;\n schema: SchemaObject;\n state: SchemaState;\n}): IR.SchemaObject => {\n irSchema.type = 'object';\n\n const schemaProperties: Record<string, IR.SchemaObject> = {};\n\n for (const name in schema.properties) {\n const property = schema.properties[name]!;\n if (typeof property === 'boolean') {\n // TODO: parser - handle boolean properties\n } else {\n const irPropertySchema = schemaToIrSchema({\n context,\n schema: property,\n state,\n });\n schemaProperties[name] = irPropertySchema;\n }\n }\n\n if (Object.keys(schemaProperties).length) {\n irSchema.properties = schemaProperties;\n }\n\n if (schema.additionalProperties === undefined) {\n if (!irSchema.properties) {\n irSchema.additionalProperties = {\n type: 'unknown',\n };\n }\n } else if (typeof schema.additionalProperties === 'boolean') {\n // Avoid [key: string]: never for empty objects with additionalProperties: false inside allOf\n // This would override inherited properties from other schemas in the composition\n const isEmptyObjectInAllOf =\n state.inAllOf &&\n schema.additionalProperties === false &&\n (!schema.properties || !Object.keys(schema.properties).length);\n\n if (!isEmptyObjectInAllOf) {\n irSchema.additionalProperties = {\n type: schema.additionalProperties ? 'unknown' : 'never',\n };\n }\n } else {\n const irAdditionalPropertiesSchema = schemaToIrSchema({\n context,\n schema: schema.additionalProperties,\n state,\n });\n irSchema.additionalProperties = irAdditionalPropertiesSchema;\n }\n\n if (schema.required) {\n irSchema.required = schema.required;\n }\n\n return irSchema;\n};\n\nconst parseString = ({\n irSchema = {},\n}: {\n context: Context;\n irSchema?: IR.SchemaObject;\n schema: SchemaObject;\n state: SchemaState;\n}): IR.SchemaObject => {\n irSchema.type = 'string';\n\n return irSchema;\n};\n\nconst initIrSchema = ({\n schema,\n}: {\n schema: SchemaObject;\n}): IR.SchemaObject => {\n const irSchema: IR.SchemaObject = {};\n\n parseSchemaJsDoc({\n irSchema,\n schema,\n });\n\n return irSchema;\n};\n\nconst parseAllOf = ({\n context,\n schema,\n state,\n}: {\n context: Context;\n schema: SchemaWithRequired<SchemaObject, 'allOf'>;\n state: SchemaState;\n}): IR.SchemaObject => {\n let irSchema = initIrSchema({ schema });\n\n const schemaItems: Array<IR.SchemaObject> = [];\n const schemaType = getSchemaType({ schema });\n\n const compositionSchemas = schema.allOf;\n\n for (const compositionSchema of compositionSchemas) {\n const originalInAllOf = state.inAllOf;\n // Don't propagate inAllOf flag to $ref schemas to avoid issues with reusable components\n if (!('$ref' in compositionSchema)) {\n state.inAllOf = true;\n }\n const irCompositionSchema = schemaToIrSchema({\n context,\n schema: compositionSchema,\n state,\n });\n state.inAllOf = originalInAllOf;\n if (state.inAllOf === undefined) {\n delete state.inAllOf;\n }\n\n if (schema.required) {\n if (irCompositionSchema.required) {\n irCompositionSchema.required = [\n ...irCompositionSchema.required,\n ...schema.required,\n ];\n } else {\n irCompositionSchema.required = schema.required;\n }\n }\n\n schemaItems.push(irCompositionSchema);\n\n if (compositionSchema.$ref) {\n const ref = context.resolveRef<SchemaObject>(compositionSchema.$ref);\n // `$ref` should be passed from the root `parseSchema()` call\n if (ref.discriminator && state.$ref) {\n const values = discriminatorValues(state.$ref);\n const valueSchemas: ReadonlyArray<IR.SchemaObject> = values.map(\n (value) => ({\n const: value,\n type: 'string',\n }),\n );\n const irDiscriminatorSchema: IR.SchemaObject = {\n properties: {\n [ref.discriminator]:\n valueSchemas.length > 1\n ? {\n items: valueSchemas,\n logicalOperator: 'or',\n }\n : valueSchemas[0]!,\n },\n type: 'object',\n };\n if (ref.required?.includes(ref.discriminator)) {\n irDiscriminatorSchema.required = [ref.discriminator];\n }\n schemaItems.push(irDiscriminatorSchema);\n }\n }\n }\n\n if (schemaType === 'object') {\n const irObjectSchema = parseOneType({\n context,\n schema: {\n ...schema,\n type: 'object',\n },\n state,\n });\n\n if (irObjectSchema.properties) {\n for (const requiredProperty of irObjectSchema.required ?? []) {\n if (!irObjectSchema.properties[requiredProperty]) {\n for (const compositionSchema of compositionSchemas) {\n // TODO: parser - this could be probably resolved more accurately\n const finalCompositionSchema = compositionSchema.$ref\n ? context.resolveRef<SchemaObject>(compositionSchema.$ref)\n : compositionSchema;\n\n if (\n getSchemaType({ schema: finalCompositionSchema }) === 'object'\n ) {\n const irCompositionSchema = parseOneType({\n context,\n schema: {\n ...finalCompositionSchema,\n type: 'object',\n },\n state,\n });\n\n if (irCompositionSchema.properties?.[requiredProperty]) {\n irObjectSchema.properties[requiredProperty] =\n irCompositionSchema.properties[requiredProperty];\n break;\n }\n }\n }\n }\n }\n schemaItems.push(irObjectSchema);\n }\n }\n\n irSchema = addItemsToSchema({\n items: schemaItems,\n logicalOperator: 'and',\n mutateSchemaOneItem: true,\n schema: irSchema,\n });\n\n if (schema['x-nullable']) {\n // nest composition to avoid producing an intersection with null\n const nestedItems: Array<IR.SchemaObject> = [\n {\n type: 'null',\n },\n ];\n\n if (schemaItems.length) {\n nestedItems.unshift(irSchema);\n }\n\n irSchema = {\n items: nestedItems,\n logicalOperator: 'or',\n };\n\n // TODO: parser - this is a hack to bring back up meta fields\n // without it, some schemas were missing original deprecated\n if (nestedItems[0]!.deprecated) {\n irSchema.deprecated = nestedItems[0]!.deprecated;\n }\n\n // TODO: parser - this is a hack to bring back up meta fields\n // without it, some schemas were missing original description\n if (nestedItems[0]!.description) {\n irSchema.description = nestedItems[0]!.description;\n }\n }\n\n return irSchema;\n};\n\nconst parseEnum = ({\n context,\n schema,\n state,\n}: {\n context: Context;\n schema: SchemaWithRequired<SchemaObject, 'enum'>;\n state: SchemaState;\n}): IR.SchemaObject => {\n let irSchema = initIrSchema({ schema });\n\n irSchema.type = 'enum';\n\n const schemaItems: Array<IR.SchemaObject> = [];\n\n for (const [index, enumValue] of schema.enum.entries()) {\n const typeOfEnumValue = typeof enumValue;\n let enumType: SchemaType<SchemaObject> | 'null' | undefined;\n\n if (\n typeOfEnumValue === 'string' ||\n typeOfEnumValue === 'number' ||\n typeOfEnumValue === 'boolean'\n ) {\n enumType = typeOfEnumValue;\n } else if (typeOfEnumValue === 'object' && Array.isArray(enumValue)) {\n enumType = 'array';\n } else if (enumValue === null) {\n // nullable must be true\n if (schema['x-nullable']) {\n enumType = 'null';\n }\n } else {\n console.warn(\n '🚨',\n `unhandled \"${typeOfEnumValue}\" typeof value \"${enumValue}\" for enum`,\n schema.enum,\n );\n }\n\n if (!enumType) {\n continue;\n }\n\n const irTypeSchema = parseOneType({\n context,\n schema: {\n description: schema['x-enum-descriptions']?.[index],\n title:\n schema['x-enum-varnames']?.[index] ?? schema['x-enumNames']?.[index],\n // cast enum to string temporarily\n type: enumType === 'null' ? 'string' : enumType,\n },\n state,\n });\n\n irTypeSchema.const = enumValue;\n\n // cast enum back\n if (enumType === 'null') {\n irTypeSchema.type = enumType;\n }\n\n if (irTypeSchema.type === 'array') {\n irTypeSchema.type = 'tuple';\n }\n\n schemaItems.push(irTypeSchema);\n }\n\n irSchema = addItemsToSchema({\n items: schemaItems,\n schema: irSchema,\n });\n\n return irSchema;\n};\n\nconst parseRef = ({\n context,\n schema,\n state,\n}: {\n context: Context;\n schema: SchemaWithRequired<SchemaObject, '$ref'>;\n state: SchemaState;\n}): IR.SchemaObject => {\n const irSchema: IR.SchemaObject = {};\n // Inline non-component refs (e.g. #/paths/...) to avoid generating orphaned named types\n const isComponentsRef = schema.$ref.startsWith('#/definitions/');\n if (!isComponentsRef) {\n if (!state.circularReferenceTracker.has(schema.$ref)) {\n const refSchema = context.resolveRef<SchemaObject>(schema.$ref);\n const originalRef = state.$ref;\n state.$ref = schema.$ref;\n const irSchema = schemaToIrSchema({\n context,\n schema: refSchema,\n state,\n });\n state.$ref = originalRef;\n return irSchema;\n }\n // Fallback to preserving the ref if circular\n }\n\n // refs using unicode characters become encoded, didn't investigate why\n // but the suspicion is this comes from `@hey-api/json-schema-ref-parser`\n irSchema.$ref = decodeURI(schema.$ref);\n\n // rewrite definitions refs as the internal schema follows OpenAPI 3.x syntax\n // and stores all definitions as reusable schemas\n irSchema.$ref = irSchema.$ref.replace(\n /#\\/definitions\\/([^/]+)/g,\n '#/components/schemas/$1',\n );\n\n if (!state.circularReferenceTracker.has(schema.$ref)) {\n const refSchema = context.resolveRef<SchemaObject>(schema.$ref);\n const originalRef = state.$ref;\n state.$ref = schema.$ref;\n schemaToIrSchema({\n context,\n schema: refSchema,\n state,\n });\n state.$ref = originalRef;\n }\n\n return irSchema;\n};\n\nconst parseNullableType = ({\n context,\n irSchema,\n schema,\n state,\n}: {\n context: Context;\n irSchema?: IR.SchemaObject;\n schema: SchemaWithRequired<SchemaObject, 'type'>;\n state: SchemaState;\n}): IR.SchemaObject => {\n if (!irSchema) {\n irSchema = initIrSchema({ schema });\n }\n\n const typeIrSchema: IR.SchemaObject = {};\n\n parseSchemaMeta({ irSchema: typeIrSchema, schema });\n\n if (typeIrSchema.default === null) {\n // clear to avoid duplicate default inside the non-null schema.\n // this would produce incorrect validator output\n delete typeIrSchema.default;\n }\n\n const schemaItems: Array<IR.SchemaObject> = [\n parseOneType({\n context,\n irSchema: typeIrSchema,\n schema,\n state,\n }),\n {\n type: 'null',\n },\n ];\n\n irSchema = addItemsToSchema({\n items: schemaItems,\n schema: irSchema,\n });\n\n return irSchema;\n};\n\nconst parseType = ({\n context,\n schema,\n state,\n}: {\n context: Context;\n schema: SchemaWithRequired<SchemaObject, 'type'>;\n state: SchemaState;\n}): IR.SchemaObject => {\n const irSchema = initIrSchema({ schema });\n\n parseSchemaMeta({ irSchema, schema });\n\n const type = getSchemaType({ schema });\n\n if (!type) {\n return irSchema;\n }\n\n if (schema['x-nullable']) {\n return parseNullableType({\n context,\n irSchema,\n schema: {\n ...schema,\n type,\n },\n state,\n });\n }\n\n return parseOneType({\n context,\n irSchema,\n schema: {\n ...schema,\n type,\n },\n state,\n });\n};\n\nconst parseOneType = ({\n context,\n irSchema,\n schema,\n state,\n}: {\n context: Context;\n irSchema?: IR.SchemaObject;\n schema: SchemaWithRequired<SchemaObject, 'type'>;\n state: SchemaState;\n}): IR.SchemaObject => {\n if (!irSchema) {\n irSchema = initIrSchema({ schema });\n\n parseSchemaMeta({ irSchema, schema });\n }\n\n switch (schema.type) {\n case 'array':\n return parseArray({\n context,\n irSchema,\n schema,\n state,\n });\n case 'boolean':\n return parseBoolean({\n context,\n irSchema,\n schema,\n state,\n });\n case 'integer':\n case 'number':\n return parseNumber({\n context,\n irSchema,\n schema,\n state,\n });\n case 'object':\n return parseObject({\n context,\n irSchema,\n schema,\n state,\n });\n case 'string':\n return parseString({\n context,\n irSchema,\n schema,\n state,\n });\n default:\n // gracefully handle invalid type\n return parseUnknown({\n context,\n irSchema,\n schema,\n });\n }\n};\n\nconst parseUnknown = ({\n irSchema,\n schema,\n}: {\n context: Context;\n irSchema?: IR.SchemaObject;\n schema: SchemaObject;\n}): IR.SchemaObject => {\n if (!irSchema) {\n irSchema = initIrSchema({ schema });\n }\n\n irSchema.type = 'unknown';\n\n parseSchemaMeta({ irSchema, schema });\n\n return irSchema;\n};\n\nexport const schemaToIrSchema = ({\n context,\n schema,\n state,\n}: {\n context: Context;\n schema: SchemaObject;\n state: SchemaState | undefined;\n}): IR.SchemaObject => {\n if (!state) {\n state = {\n circularReferenceTracker: new Set(),\n };\n }\n\n if (state.$ref) {\n state.circularReferenceTracker.add(state.$ref);\n }\n\n if (schema.$ref) {\n return parseRef({\n context,\n schema: schema as SchemaWithRequired<SchemaObject, '$ref'>,\n state,\n });\n }\n\n if (schema.enum) {\n return parseEnum({\n context,\n schema: schema as SchemaWithRequired<SchemaObject, 'enum'>,\n state,\n });\n }\n\n if (schema.allOf) {\n return parseAllOf({\n context,\n schema: schema as SchemaWithRequired<SchemaObject, 'allOf'>,\n state,\n });\n }\n\n // infer object based on the presence of properties\n if (schema.type || schema.properties) {\n return parseType({\n context,\n schema: schema as SchemaWithRequired<SchemaObject, 'type'>,\n state,\n });\n }\n\n return parseUnknown({ context, schema });\n};\n\nexport const parseSchema = ({\n $ref,\n context,\n schema,\n}: {\n $ref: string;\n context: Context;\n schema: SchemaObject;\n}) => {\n if (!context.ir.components) {\n context.ir.components = {};\n }\n\n if (!context.ir.components.schemas) {\n context.ir.components.schemas = {};\n }\n\n context.ir.components.schemas[refToName($ref)] = schemaToIrSchema({\n context,\n schema,\n state: {\n $ref,\n circularReferenceTracker: new Set(),\n },\n });\n};\n","import type { Context } from '~/ir/context';\nimport { getPaginationKeywordsRegExp } from '~/ir/pagination';\nimport type { SchemaType } from '~/openApi/shared/types/schema';\n\nimport type { ParameterObject, ReferenceObject } from '../types/spec';\nimport type { SchemaObject } from '../types/spec';\nimport { getSchemaType } from './schema';\n\nconst isPaginationType = (\n schemaType: SchemaType<SchemaObject> | undefined,\n): boolean =>\n schemaType === 'boolean' ||\n schemaType === 'integer' ||\n schemaType === 'number' ||\n schemaType === 'string';\n\n// We handle only simple values for now, up to 1 nested field\nexport const paginationField = ({\n context,\n name,\n schema,\n}: {\n context: Context;\n name: string;\n schema:\n | ParameterObject\n | SchemaObject\n | ReferenceObject\n | {\n in: undefined;\n };\n}): boolean | string => {\n const paginationRegExp = getPaginationKeywordsRegExp(\n context.config.parser.pagination,\n );\n if (paginationRegExp.test(name)) {\n return true;\n }\n\n if ('$ref' in schema) {\n const ref = context.resolveRef<ParameterObject | SchemaObject>(\n schema.$ref ?? '',\n );\n\n if ('in' in ref && ref.in) {\n const refSchema =\n 'schema' in ref\n ? ref.schema\n : {\n ...ref,\n in: undefined,\n };\n\n return paginationField({\n context,\n name,\n schema: refSchema,\n });\n }\n\n return paginationField({\n context,\n name,\n schema: ref,\n });\n }\n\n if ('in' in schema) {\n if (!schema.in) {\n return false;\n }\n\n const finalSchema =\n 'schema' in schema\n ? schema.schema\n : {\n ...schema,\n in: undefined,\n };\n\n return paginationField({\n context,\n name,\n schema: finalSchema,\n });\n }\n\n for (const name in schema.properties) {\n const paginationRegExp = getPaginationKeywordsRegExp(\n context.config.parser.pagination,\n );\n\n if (paginationRegExp.test(name)) {\n const property = schema.properties[name]!;\n\n if (typeof property !== 'boolean' && !('$ref' in property)) {\n const schemaType = getSchemaType({ schema: property });\n // TODO: resolve deeper references\n\n if (isPaginationType(schemaType)) {\n return name;\n }\n }\n }\n }\n\n for (const allOf of schema.allOf ?? []) {\n const pagination = paginationField({\n context,\n name,\n schema: allOf,\n });\n if (pagination) {\n return pagination;\n }\n }\n\n return false;\n};\n","import type { Context } from '~/ir/context';\nimport type { IR, IRBodyObject } from '~/ir/types';\nimport type { State } from '~/openApi/shared/types/state';\nimport { operationToId } from '~/openApi/shared/utils/operation';\n\nimport type {\n OperationObject,\n ParameterObject,\n PathItemObject,\n ResponseObject,\n SchemaObject,\n SecuritySchemeObject,\n} from '../types/spec';\nimport { contentToSchema, mediaTypeObjects } from './mediaType';\nimport { paginationField } from './pagination';\nimport { schemaToIrSchema } from './schema';\n\ninterface Operation\n extends Omit<OperationObject, 'parameters'>,\n Pick<IR.OperationObject, 'parameters'> {\n requestBody?: OperationObject['parameters'];\n}\n\nconst parseOperationJsDoc = ({\n irOperation,\n operation,\n}: {\n irOperation: IR.OperationObject;\n operation: Operation;\n}) => {\n if (operation.deprecated !== undefined) {\n irOperation.deprecated = operation.deprecated;\n }\n\n if (operation.description) {\n irOperation.description = operation.description;\n }\n\n if (operation.summary) {\n irOperation.summary = operation.summary;\n }\n\n if (operation.tags?.length) {\n irOperation.tags = operation.tags;\n }\n};\n\nconst initIrOperation = ({\n context,\n method,\n operation,\n path,\n state,\n}: Pick<IR.OperationObject, 'method' | 'path'> & {\n context: Context;\n operation: Operation;\n state: State;\n}): IR.OperationObject => {\n const irOperation: IR.OperationObject = {\n id: operationToId({\n context,\n id: operation.operationId,\n method,\n path,\n state,\n }),\n method,\n path,\n };\n\n if (operation.operationId) {\n irOperation.operationId = operation.operationId;\n }\n\n parseOperationJsDoc({\n irOperation,\n operation,\n });\n\n return irOperation;\n};\n\nconst operationToIrOperation = ({\n context,\n method,\n operation,\n path,\n securitySchemesMap,\n state,\n}: Pick<IR.OperationObject, 'method' | 'path'> & {\n context: Context;\n operation: Operation;\n securitySchemesMap: Map<string, SecuritySchemeObject>;\n state: State;\n}): IR.OperationObject => {\n const irOperation = initIrOperation({\n context,\n method,\n operation,\n path,\n state,\n });\n\n if (operation.parameters) {\n irOperation.parameters = operation.parameters;\n }\n\n let isRequestBodyRequired = false;\n const requestBodyObject: IRBodyObject = {\n mediaType: '',\n schema: {\n properties: {},\n required: [],\n type: 'object',\n },\n };\n const requestBodyObjectRequired: Array<string> = [];\n\n // Check if there are any body parameters (not formData) to determine default media type\n const hasBodyParameter = operation.requestBody?.some((param) => {\n const resolvedParam =\n '$ref' in param ? context.resolveRef<ParameterObject>(param.$ref) : param;\n return resolvedParam.in === 'body';\n });\n\n for (const requestBodyParameter of operation.requestBody ?? []) {\n const requestBody =\n '$ref' in requestBodyParameter\n ? context.resolveRef<ParameterObject>(requestBodyParameter.$ref)\n : requestBodyParameter;\n const schema: SchemaObject =\n requestBody.in === 'body'\n ? requestBody.schema\n : {\n ...requestBody,\n format: requestBody.type === 'file' ? 'binary' : requestBody.format,\n required: undefined,\n type: requestBody.type === 'file' ? 'string' : requestBody.type,\n };\n\n // Only default to JSON if we have body parameters and no consumes specified\n // FormData parameters without consumes should not get a default media type\n let mimeTypes = operation.consumes;\n if (!mimeTypes && hasBodyParameter && requestBody.in === 'body') {\n mimeTypes = ['application/json'];\n }\n\n const contents = mediaTypeObjects({\n mimeTypes,\n response: { schema },\n });\n // TODO: add support for multiple content types, for now prefer JSON\n const content =\n contents.find((content) => content.type === 'json') || contents[0];\n\n if (content) {\n const pagination = paginationField({\n context,\n name: '',\n schema:\n content.schema && '$ref' in content.schema\n ? {\n allOf: [{ ...content.schema }],\n description: requestBody.description,\n }\n : {\n description: requestBody.description,\n ...content.schema,\n },\n });\n\n const irSchema = schemaToIrSchema({\n context,\n schema:\n '$ref' in requestBody\n ? {\n allOf: [\n {\n ...requestBody,\n $ref: requestBody.$ref as string,\n required: [],\n type: 'string',\n },\n ],\n description: requestBody.description,\n }\n : content.schema && '$ref' in content.schema\n ? {\n allOf: [{ ...content.schema }],\n description: requestBody.description,\n }\n : {\n description: requestBody.description,\n ...content.schema,\n },\n state: undefined,\n });\n\n requestBodyObject.mediaType = content.mediaType;\n\n if (requestBody.in === 'body') {\n requestBodyObject.schema = irSchema;\n } else {\n requestBodyObject.schema.properties![requestBody.name] = irSchema;\n\n if (requestBody.required) {\n requestBodyObjectRequired.push(requestBody.name);\n }\n }\n\n if (pagination) {\n requestBodyObject.pagination = pagination;\n }\n\n if (content.type) {\n requestBodyObject.type = content.type;\n }\n }\n\n if (requestBody.required) {\n isRequestBodyRequired = true;\n }\n }\n\n if (requestBodyObject.mediaType) {\n if (requestBodyObjectRequired.length) {\n requestBodyObject.schema.required = requestBodyObjectRequired;\n }\n\n irOperation.body = requestBodyObject;\n\n if (isRequestBodyRequired) {\n irOperation.body.required = isRequestBodyRequired;\n }\n }\n\n for (const name in operation.responses) {\n if (!irOperation.responses) {\n irOperation.responses = {};\n }\n\n const response = operation.responses[name]!;\n const responseObject =\n '$ref' in response\n ? context.resolveRef<ResponseObject>(response.$ref)\n : response;\n const contents = mediaTypeObjects({\n // assume JSON by default\n mimeTypes: operation.produces ? operation.produces : ['application/json'],\n response: responseObject,\n });\n // TODO: add support for multiple content types, for now prefer JSON\n const content =\n contents.find((content) => content.type === 'json') || contents[0];\n\n if (content) {\n irOperation.responses[name] = {\n mediaType: content.mediaType,\n schema: schemaToIrSchema({\n context,\n schema: {\n description: responseObject.description,\n ...contentToSchema({ content }),\n },\n state: undefined,\n }),\n };\n } else {\n irOperation.responses[name] = {\n schema: {\n description: responseObject.description,\n // TODO: parser - cover all statues with empty response bodies\n // 1xx, 204, 205, 304\n type: name === '204' ? 'void' : 'unknown',\n },\n };\n }\n }\n\n if (operation.security) {\n const securitySchemeObjects: Map<string, IR.SecurityObject> = new Map();\n\n for (const securityRequirementObject of operation.security) {\n for (const name in securityRequirementObject) {\n const securitySchemeObject = securitySchemesMap.get(name);\n\n if (!securitySchemeObject) {\n continue;\n }\n\n let irSecuritySchemeObject: IR.SecurityObject | undefined;\n\n if (securitySchemeObject.type === 'apiKey') {\n irSecuritySchemeObject = securitySchemeObject;\n }\n\n if (securitySchemeObject.type === 'basic') {\n irSecuritySchemeObject = {\n description: securitySchemeObject.description,\n scheme: 'basic',\n type: 'http',\n };\n }\n\n if (securitySchemeObject.type === 'oauth2') {\n irSecuritySchemeObject = {\n description: securitySchemeObject.description,\n flows: {},\n type: 'oauth2',\n };\n\n switch (securitySchemeObject.flow) {\n case 'accessCode':\n irSecuritySchemeObject.flows.authorizationCode = {\n authorizationUrl: securitySchemeObject.authorizationUrl!,\n scopes: securitySchemeObject.scopes,\n tokenUrl: securitySchemeObject.tokenUrl!,\n };\n break;\n case 'application':\n irSecuritySchemeObject.flows.clientCredentials = {\n scopes: securitySchemeObject.scopes,\n tokenUrl: securitySchemeObject.tokenUrl!,\n };\n break;\n case 'implicit':\n irSecuritySchemeObject.flows.implicit = {\n authorizationUrl: securitySchemeObject.authorizationUrl!,\n scopes: securitySchemeObject.scopes,\n };\n break;\n case 'password':\n irSecuritySchemeObject.flows.password = {\n scopes: securitySchemeObject.scopes,\n tokenUrl: securitySchemeObject.tokenUrl!,\n };\n break;\n }\n }\n\n if (!irSecuritySchemeObject) {\n continue;\n }\n\n securitySchemeObjects.set(name, irSecuritySchemeObject);\n }\n }\n\n if (securitySchemeObjects.size) {\n irOperation.security = Array.from(securitySchemeObjects.values());\n }\n }\n\n // TODO: parser - handle servers\n // qux: operation.servers\n\n return irOperation;\n};\n\nexport const parsePathOperation = ({\n context,\n method,\n operation,\n path,\n securitySchemesMap,\n state,\n}: {\n context: Context;\n method: Extract<\n keyof PathItemObject,\n 'delete' | 'get' | 'head' | 'options' | 'patch' | 'post' | 'put' | 'trace'\n >;\n operation: Operation;\n path: keyof IR.PathsObject;\n securitySchemesMap: Map<string, SecuritySchemeObject>;\n state: State;\n}) => {\n if (!context.ir.paths) {\n context.ir.paths = {};\n }\n\n if (!context.ir.paths[path]) {\n context.ir.paths[path] = {};\n }\n\n context.ir.paths[path][method] = operationToIrOperation({\n context,\n method,\n operation,\n path,\n securitySchemesMap,\n state,\n });\n};\n","import type { Context } from '~/ir/context';\nimport type { IR } from '~/ir/types';\n\nimport type {\n OperationObject,\n ParameterObject,\n ReferenceObject,\n SchemaObject,\n} from '../types/spec';\nimport { paginationField } from './pagination';\nimport { schemaToIrSchema } from './schema';\n\ntype Parameter = Exclude<ParameterObject, { in: 'body' }>;\n\n/**\n * Returns default parameter `explode` based on value of `collectionFormat`.\n */\nconst defaultExplode = (\n collectionFormat: Parameter['collectionFormat'],\n): boolean => {\n switch (collectionFormat) {\n case 'multi':\n return true;\n case 'csv':\n case 'pipes':\n case 'ssv':\n case 'tsv':\n default:\n return false;\n }\n};\n\n/**\n * Returns default parameter `style` based on value of `in`.\n */\nconst defaultStyle = (\n _in: Parameter['in'],\n): Required<IR.ParameterObject>['style'] => {\n switch (_in) {\n case 'header':\n case 'path':\n return 'simple';\n case 'query':\n default:\n return 'form';\n }\n};\n\nexport const parametersArrayToObject = ({\n context,\n operation,\n parameters,\n}: {\n context: Context;\n operation: OperationObject;\n parameters?: ReadonlyArray<ParameterObject | ReferenceObject>;\n}): IR.ParametersObject | undefined => {\n if (!parameters || !Object.keys(parameters).length) {\n return;\n }\n\n const parametersObject: IR.ParametersObject = {};\n\n for (const parameterOrReference of parameters) {\n const parameter =\n '$ref' in parameterOrReference\n ? context.dereference<ParameterObject>(parameterOrReference)\n : parameterOrReference;\n\n // push request body parameters into a separate field\n if (parameter.in === 'body' || parameter.in === 'formData') {\n // @ts-expect-error\n if (!operation.requestBody) {\n // @ts-expect-error\n operation.requestBody = [];\n }\n\n // @ts-expect-error\n operation.requestBody.push(parameter);\n continue;\n }\n\n if (!parametersObject[parameter.in]) {\n parametersObject[parameter.in] = {};\n }\n\n // lowercase keys for case insensitive access\n parametersObject[parameter.in]![parameter.name.toLocaleLowerCase()] =\n parameterToIrParameter({\n $ref: `#/todo/real/path/to/parameter/${parameter.name}`,\n context,\n parameter,\n });\n }\n\n return parametersObject;\n};\n\nconst parameterToIrParameter = ({\n $ref,\n context,\n parameter,\n}: {\n $ref: string;\n context: Context;\n parameter: Parameter;\n}): IR.ParameterObject => {\n const schema = parameter;\n\n const finalSchema: SchemaObject =\n schema && '$ref' in schema\n ? {\n allOf: [\n {\n ...schema,\n $ref: schema.$ref as string,\n required: Array.isArray(schema.required) ? schema.required : [],\n type: schema.type as SchemaObject['type'],\n },\n ],\n description: parameter.description,\n }\n : {\n description: parameter.description,\n ...schema,\n required: Array.isArray(schema.required) ? schema.required : [],\n type: schema.type as SchemaObject['type'],\n };\n\n const pagination = paginationField({\n context,\n name: parameter.name,\n schema: finalSchema,\n });\n\n const style = defaultStyle(parameter.in);\n const explode = defaultExplode(parameter.collectionFormat);\n const allowReserved = false;\n\n const irParameter: IR.ParameterObject = {\n allowReserved,\n explode,\n location: parameter.in as IR.ParameterObject['location'],\n name: parameter.name,\n schema: schemaToIrSchema({\n context,\n schema: finalSchema,\n state: {\n $ref,\n circularReferenceTracker: new Set(),\n },\n }),\n style,\n };\n\n if (parameter.description) {\n irParameter.description = parameter.description;\n }\n\n if (pagination) {\n irParameter.pagination = pagination;\n }\n\n if (parameter.required) {\n irParameter.required = parameter.required;\n }\n\n return irParameter;\n};\n","import type { Context } from '~/ir/context';\nimport { parseUrl } from '~/utils/url';\n\nexport const parseServers = ({ context }: { context: Context }) => {\n let schemes: ReadonlyArray<string> = context.spec.schemes ?? [];\n let host = context.spec.host ?? '';\n const path = context.spec.basePath ?? '';\n\n for (const input of context.config.input) {\n if (typeof input.path === 'string') {\n const url = parseUrl(input.path);\n\n if (!schemes.length) {\n if (url.protocol) {\n schemes = [url.protocol] as typeof schemes;\n }\n }\n\n if (!host) {\n host = `${url.host}${url.port ? `:${url.port}` : ''}`;\n }\n }\n }\n\n if (!schemes.length) {\n schemes = [''];\n }\n\n const servers = schemes\n .map((scheme) => `${scheme ? `${scheme}://` : ''}${host}${path}`)\n .filter(Boolean);\n\n if (servers.length) {\n context.ir.servers = servers.map((url) => ({\n url,\n }));\n }\n};\n","import { createOperationKey } from '~/ir/operation';\nimport { httpMethods } from '~/openApi/shared/utils/operation';\nimport type {\n ValidatorIssue,\n ValidatorResult,\n} from '~/openApi/shared/utils/validator';\nimport type { Logger } from '~/utils/logger';\n\nimport type { OpenApiV2_0_X, PathItemObject, PathsObject } from '../types/spec';\n\nexport const validateOpenApiSpec = (\n spec: OpenApiV2_0_X,\n logger: Logger,\n): ValidatorResult => {\n const eventValidate = logger.timeEvent('validate');\n const issues: Array<ValidatorIssue> = [];\n const operationIds = new Map();\n\n if (spec.paths) {\n for (const entry of Object.entries(spec.paths)) {\n const path = entry[0] as keyof PathsObject;\n const pathItem = entry[1] as PathItemObject;\n for (const method of httpMethods) {\n if (method === 'trace') {\n continue;\n }\n\n const operation = pathItem[method];\n if (!operation) {\n continue;\n }\n\n const operationKey = createOperationKey({ method, path });\n\n if (operation.operationId) {\n if (!operationIds.has(operation.operationId)) {\n operationIds.set(operation.operationId, operationKey);\n } else {\n issues.push({\n code: 'duplicate_key',\n context: {\n key: 'operationId',\n value: operation.operationId,\n },\n message:\n 'Duplicate `operationId` found. Each `operationId` must be unique.',\n path: ['paths', path, method, 'operationId'],\n severity: 'error',\n });\n }\n }\n }\n }\n }\n\n eventValidate.timeEnd();\n return {\n issues,\n valid: !issues.some((issue) => issue.severity === 'error'),\n };\n};\n","import type { Context } from '~/ir/context';\nimport { buildResourceMetadata } from '~/openApi/shared/graph/meta';\nimport { transformOpenApiSpec } from '~/openApi/shared/transforms';\nimport type { State } from '~/openApi/shared/types/state';\nimport {\n createFilteredDependencies,\n createFilters,\n hasFilters,\n} from '~/openApi/shared/utils/filter';\nimport { buildGraph } from '~/openApi/shared/utils/graph';\nimport { mergeParametersObjects } from '~/openApi/shared/utils/parameter';\nimport { handleValidatorResult } from '~/openApi/shared/utils/validator';\n\nimport type {\n OpenApiV2_0_X,\n OperationObject,\n PathItemObject,\n PathsObject,\n SecuritySchemeObject,\n} from '../types/spec';\nimport { filterSpec } from './filter';\nimport { parsePathOperation } from './operation';\nimport { parametersArrayToObject } from './parameter';\nimport { parseSchema } from './schema';\nimport { parseServers } from './server';\nimport { validateOpenApiSpec } from './validate';\n\ntype PathKeys<T extends keyof PathsObject = keyof PathsObject> =\n keyof T extends infer K ? (K extends `/${string}` ? K : never) : never;\n\nexport const parseV2_0_X = (context: Context<OpenApiV2_0_X>) => {\n if (context.config.parser.validate_EXPERIMENTAL) {\n const result = validateOpenApiSpec(context.spec, context.logger);\n handleValidatorResult({ context, result });\n }\n\n const shouldFilterSpec = hasFilters(context.config.parser.filters);\n if (shouldFilterSpec) {\n const filters = createFilters(\n context.config.parser.filters,\n context.spec,\n context.logger,\n );\n const { graph } = buildGraph(context.spec, context.logger);\n const { resourceMetadata } = buildResourceMetadata(graph, context.logger);\n const sets = createFilteredDependencies({\n filters,\n logger: context.logger,\n resourceMetadata,\n });\n filterSpec({\n ...sets,\n logger: context.logger,\n preserveOrder: filters.preserveOrder,\n spec: context.spec,\n });\n }\n\n transformOpenApiSpec({ context });\n\n const state: State = {\n ids: new Map(),\n };\n const securitySchemesMap = new Map<string, SecuritySchemeObject>();\n\n for (const name in context.spec.securityDefinitions) {\n const securitySchemeObject = context.spec.securityDefinitions[name]!;\n securitySchemesMap.set(name, securitySchemeObject);\n }\n\n if (context.spec.definitions) {\n for (const name in context.spec.definitions) {\n const $ref = `#/definitions/${name}`;\n const schema = context.spec.definitions[name]!;\n\n parseSchema({\n $ref,\n context,\n schema,\n });\n }\n }\n\n parseServers({ context });\n\n for (const path in context.spec.paths) {\n if (path.startsWith('x-')) {\n continue;\n }\n\n const pathItem = context.spec.paths[path as PathKeys]!;\n\n const finalPathItem = pathItem.$ref\n ? {\n ...context.resolveRef<PathItemObject>(pathItem.$ref),\n ...pathItem,\n }\n : pathItem;\n\n const commonOperation: OperationObject = {\n consumes: context.spec.consumes,\n produces: context.spec.produces,\n responses: {},\n security: context.spec.security,\n };\n const operationArgs: Omit<\n Parameters<typeof parsePathOperation>[0],\n 'method'\n > = {\n context,\n operation: {\n ...commonOperation,\n parameters: parametersArrayToObject({\n context,\n operation: commonOperation,\n parameters: finalPathItem.parameters,\n }),\n },\n path: path as PathKeys,\n securitySchemesMap,\n state,\n };\n\n if (finalPathItem.delete) {\n const parameters = mergeParametersObjects({\n source: parametersArrayToObject({\n context,\n operation: finalPathItem.delete,\n parameters: finalPathItem.delete.parameters,\n }),\n target: operationArgs.operation.parameters,\n });\n parsePathOperation({\n ...operationArgs,\n method: 'delete',\n operation: {\n ...operationArgs.operation,\n ...finalPathItem.delete,\n parameters,\n },\n });\n }\n\n if (finalPathItem.get) {\n const parameters = mergeParametersObjects({\n source: parametersArrayToObject({\n context,\n operation: finalPathItem.get,\n parameters: finalPathItem.get.parameters,\n }),\n target: operationArgs.operation.parameters,\n });\n parsePathOperation({\n ...operationArgs,\n method: 'get',\n operation: {\n ...operationArgs.operation,\n ...finalPathItem.get,\n parameters,\n },\n });\n }\n\n if (finalPathItem.head) {\n const parameters = mergeParametersObjects({\n source: parametersArrayToObject({\n context,\n operation: finalPathItem.head,\n parameters: finalPathItem.head.parameters,\n }),\n target: operationArgs.operation.parameters,\n });\n parsePathOperation({\n ...operationArgs,\n method: 'head',\n operation: {\n ...operationArgs.operation,\n ...finalPathItem.head,\n parameters,\n },\n });\n }\n\n if (finalPathItem.options) {\n const parameters = mergeParametersObjects({\n source: parametersArrayToObject({\n context,\n operation: finalPathItem.options,\n parameters: finalPathItem.options.parameters,\n }),\n target: operationArgs.operation.parameters,\n });\n parsePathOperation({\n ...operationArgs,\n method: 'options',\n operation: {\n ...operationArgs.operation,\n ...finalPathItem.options,\n parameters,\n },\n });\n }\n\n if (finalPathItem.patch) {\n const parameters = mergeParametersObjects({\n source: parametersArrayToObject({\n context,\n operation: finalPathItem.patch,\n parameters: finalPathItem.patch.parameters,\n }),\n target: operationArgs.operation.parameters,\n });\n parsePathOperation({\n ...operationArgs,\n method: 'patch',\n operation: {\n ...operationArgs.operation,\n ...finalPathItem.patch,\n parameters,\n },\n });\n }\n\n if (finalPathItem.post) {\n const parameters = mergeParametersObjects({\n source: parametersArrayToObject({\n context,\n operation: finalPathItem.post,\n parameters: finalPathItem.post.parameters,\n }),\n target: operationArgs.operation.parameters,\n });\n parsePathOperation({\n ...operationArgs,\n method: 'post',\n operation: {\n ...operationArgs.operation,\n ...finalPathItem.post,\n parameters,\n },\n });\n }\n\n if (finalPathItem.put) {\n const parameters = mergeParametersObjects({\n source: parametersArrayToObject({\n context,\n operation: finalPathItem.put,\n parameters: finalPathItem.put.parameters,\n }),\n target: operationArgs.operation.parameters,\n });\n parsePathOperation({\n ...operationArgs,\n method: 'put',\n operation: {\n ...operationArgs.operation,\n ...finalPathItem.put,\n parameters,\n },\n });\n }\n }\n};\n","import { createOperationKey } from '~/ir/operation';\nimport { addNamespace, removeNamespace } from '~/openApi/shared/utils/filter';\nimport { httpMethods } from '~/openApi/shared/utils/operation';\nimport type { Logger } from '~/utils/logger';\n\nimport type { OpenApiV3_0_X, PathItemObject, PathsObject } from '../types/spec';\n\n/**\n * Replace source spec with filtered version.\n */\nexport const filterSpec = ({\n logger,\n operations,\n parameters,\n preserveOrder,\n requestBodies,\n responses,\n schemas,\n spec,\n}: {\n logger: Logger;\n operations: Set<string>;\n parameters: Set<string>;\n preserveOrder: boolean;\n requestBodies: Set<string>;\n responses: Set<string>;\n schemas: Set<string>;\n spec: OpenApiV3_0_X;\n}) => {\n const eventFilterSpec = logger.timeEvent('filter-spec');\n if (spec.components) {\n if (spec.components.parameters) {\n const filtered: typeof spec.components.parameters = {};\n\n if (preserveOrder) {\n for (const [name, source] of Object.entries(\n spec.components.parameters,\n )) {\n if (parameters.has(addNamespace('parameter', name))) {\n filtered[name] = source;\n }\n }\n } else {\n for (const key of parameters) {\n const { name } = removeNamespace(key);\n const source = spec.components.parameters[name];\n if (source) {\n filtered[name] = source;\n }\n }\n }\n\n spec.components.parameters = filtered;\n }\n\n if (spec.components.requestBodies) {\n const filtered: typeof spec.components.requestBodies = {};\n\n if (preserveOrder) {\n for (const [name, source] of Object.entries(\n spec.components.requestBodies,\n )) {\n if (requestBodies.has(addNamespace('body', name))) {\n filtered[name] = source;\n }\n }\n } else {\n for (const key of requestBodies) {\n const { name } = removeNamespace(key);\n const source = spec.components.requestBodies[name];\n if (source) {\n filtered[name] = source;\n }\n }\n }\n\n spec.components.requestBodies = filtered;\n }\n\n if (spec.components.responses) {\n const filtered: typeof spec.components.responses = {};\n\n if (preserveOrder) {\n for (const [name, source] of Object.entries(\n spec.components.responses,\n )) {\n if (responses.has(addNamespace('response', name))) {\n filtered[name] = source;\n }\n }\n } else {\n for (const key of responses) {\n const { name } = removeNamespace(key);\n const source = spec.components.responses[name];\n if (source) {\n filtered[name] = source;\n }\n }\n }\n\n spec.components.responses = filtered;\n }\n\n if (spec.components.schemas) {\n const filtered: typeof spec.components.schemas = {};\n\n if (preserveOrder) {\n for (const [name, source] of Object.entries(spec.components.schemas)) {\n if (schemas.has(addNamespace('schema', name))) {\n filtered[name] = source;\n }\n }\n } else {\n for (const key of schemas) {\n const { name } = removeNamespace(key);\n const source = spec.components.schemas[name];\n if (source) {\n filtered[name] = source;\n }\n }\n }\n\n spec.components.schemas = filtered;\n }\n }\n\n if (spec.paths) {\n for (const entry of Object.entries(spec.paths)) {\n const path = entry[0] as keyof PathsObject;\n const pathItem = entry[1] as PathItemObject;\n\n for (const method of httpMethods) {\n const operation = pathItem[method];\n if (!operation) {\n continue;\n }\n\n const key = addNamespace(\n 'operation',\n createOperationKey({ method, path }),\n );\n if (!operations.has(key)) {\n delete pathItem[method];\n }\n }\n\n // remove paths that have no operations left\n if (!Object.keys(pathItem).length) {\n delete spec.paths[path];\n }\n }\n }\n eventFilterSpec.timeEnd();\n};\n","import type { IRMediaType } from '~/ir/mediaType';\nimport { isMediaTypeFileLike, mediaTypeToIrMediaType } from '~/ir/mediaType';\n\nimport type {\n MediaTypeObject,\n ReferenceObject,\n SchemaObject,\n} from '../types/spec';\n\ninterface Content {\n mediaType: string;\n schema: SchemaObject | ReferenceObject | undefined;\n type: IRMediaType | undefined;\n}\n\nexport const contentToSchema = ({\n content,\n}: {\n content: Content;\n}): SchemaObject | undefined => {\n const { mediaType, schema } = content;\n\n if (schema && '$ref' in schema) {\n return {\n allOf: [{ ...schema }],\n };\n }\n\n if (!schema) {\n if (isMediaTypeFileLike({ mediaType })) {\n return {\n format: 'binary',\n type: 'string',\n };\n }\n return;\n }\n\n if (\n schema.type === 'string' &&\n !schema.format &&\n isMediaTypeFileLike({ mediaType })\n ) {\n return {\n ...schema,\n format: 'binary',\n };\n }\n\n return schema;\n};\n\nexport const mediaTypeObjects = ({\n content,\n}: {\n content: Record<string, MediaTypeObject> | undefined;\n}): ReadonlyArray<Content> => {\n const objects: Array<Content> = [];\n\n for (const mediaType in content) {\n objects.push({\n mediaType,\n schema: content[mediaType]!.schema,\n type: mediaTypeToIrMediaType({ mediaType }),\n });\n }\n\n return objects;\n};\n","import type { Context } from '~/ir/context';\nimport type { IR } from '~/ir/types';\nimport { addItemsToSchema } from '~/ir/utils';\nimport type {\n SchemaState,\n SchemaType,\n SchemaWithRequired,\n} from '~/openApi/shared/types/schema';\nimport { discriminatorValues } from '~/openApi/shared/utils/discriminator';\nimport { refToName } from '~/utils/ref';\n\nimport type { ReferenceObject, SchemaObject } from '../types/spec';\n\nexport const getSchemaType = ({\n schema,\n}: {\n schema: SchemaObject;\n}): SchemaType<SchemaObject> | undefined => {\n if (schema.type) {\n return schema.type;\n }\n\n // infer object based on the presence of properties\n if (schema.properties) {\n return 'object';\n }\n\n return;\n};\n\nconst parseSchemaJsDoc = ({\n irSchema,\n schema,\n}: {\n irSchema: IR.SchemaObject;\n schema: SchemaObject;\n}) => {\n if (schema.deprecated !== undefined) {\n irSchema.deprecated = schema.deprecated;\n }\n\n if (schema.example) {\n irSchema.example = schema.example;\n }\n\n if (schema.description) {\n irSchema.description = schema.description;\n }\n\n if (schema.title) {\n irSchema.title = schema.title;\n }\n};\n\nconst parseSchemaMeta = ({\n irSchema,\n schema,\n}: {\n irSchema: IR.SchemaObject;\n schema: SchemaObject;\n}) => {\n if (schema.default !== undefined) {\n irSchema.default = schema.default;\n }\n\n if (schema.exclusiveMaximum) {\n if (schema.maximum !== undefined) {\n irSchema.exclusiveMaximum = schema.maximum;\n }\n } else if (schema.maximum !== undefined) {\n irSchema.maximum = schema.maximum;\n }\n\n if (schema.exclusiveMinimum) {\n if (schema.minimum !== undefined) {\n irSchema.exclusiveMinimum = schema.minimum;\n }\n } else if (schema.minimum !== undefined) {\n irSchema.minimum = schema.minimum;\n }\n\n if (schema.format) {\n irSchema.format = schema.format;\n }\n\n if (schema.maxItems !== undefined) {\n irSchema.maxItems = schema.maxItems;\n }\n\n if (schema.maxLength !== undefined) {\n irSchema.maxLength = schema.maxLength;\n }\n\n if (schema.minItems !== undefined) {\n irSchema.minItems = schema.minItems;\n }\n\n if (schema.minLength !== undefined) {\n irSchema.minLength = schema.minLength;\n }\n\n if (schema.pattern) {\n irSchema.pattern = schema.pattern;\n }\n\n if (schema.readOnly) {\n irSchema.accessScope = 'read';\n } else if (schema.writeOnly) {\n irSchema.accessScope = 'write';\n }\n};\n\nconst parseArray = ({\n context,\n irSchema = {},\n schema,\n state,\n}: {\n context: Context;\n irSchema?: IR.SchemaObject;\n schema: SchemaObject;\n state: SchemaState;\n}): IR.SchemaObject => {\n if (schema.maxItems && schema.maxItems === schema.minItems) {\n irSchema.type = 'tuple';\n } else {\n irSchema.type = 'array';\n }\n\n let schemaItems: Array<IR.SchemaObject> = [];\n\n if (schema.items) {\n const irItemsSchema = schemaToIrSchema({\n context,\n schema: schema.items,\n state,\n });\n\n if (\n !schemaItems.length &&\n schema.maxItems &&\n schema.maxItems === schema.minItems\n ) {\n schemaItems = Array(schema.maxItems).fill(irItemsSchema);\n } else {\n if ('$ref' in schema.items) {\n schemaItems.push(irItemsSchema);\n } else {\n const ofArray =\n schema.items.allOf || schema.items.anyOf || schema.items.oneOf;\n if (ofArray && ofArray.length > 1 && !schema.items.nullable) {\n // bring composition up to avoid incorrectly nested arrays\n irSchema = {\n ...irSchema,\n ...irItemsSchema,\n };\n } else {\n schemaItems.push(irItemsSchema);\n }\n }\n }\n }\n\n irSchema = addItemsToSchema({\n items: schemaItems,\n schema: irSchema,\n });\n\n return irSchema;\n};\n\nconst parseBoolean = ({\n irSchema = {},\n}: {\n context: Context;\n irSchema?: IR.SchemaObject;\n schema: SchemaObject;\n state: SchemaState;\n}): IR.SchemaObject => {\n irSchema.type = 'boolean';\n\n return irSchema;\n};\n\nconst parseNumber = ({\n irSchema = {},\n schema,\n}: {\n context: Context;\n irSchema?: IR.SchemaObject;\n schema: SchemaWithRequired<SchemaObject, 'type'>;\n state: SchemaState;\n}): IR.SchemaObject => {\n irSchema.type = schema.type;\n\n return irSchema;\n};\n\nconst parseObject = ({\n context,\n irSchema = {},\n schema,\n state,\n}: {\n context: Context;\n irSchema?: IR.SchemaObject;\n schema: SchemaObject;\n state: SchemaState;\n}): IR.SchemaObject => {\n irSchema.type = 'object';\n\n const schemaProperties: Record<string, IR.SchemaObject> = {};\n\n for (const name in schema.properties) {\n const property = schema.properties[name]!;\n if (typeof property === 'boolean') {\n // TODO: parser - handle boolean properties\n } else {\n schemaProperties[name] = schemaToIrSchema({\n context,\n schema: property,\n state,\n });\n }\n }\n\n if (Object.keys(schemaProperties).length) {\n irSchema.properties = schemaProperties;\n }\n\n if (schema.additionalProperties === undefined) {\n if (!irSchema.properties) {\n irSchema.additionalProperties = {\n type: 'unknown',\n };\n }\n } else if (typeof schema.additionalProperties === 'boolean') {\n // Avoid [key: string]: never for empty objects with additionalProperties: false inside allOf\n // This would override inherited properties from other schemas in the composition\n const isEmptyObjectInAllOf =\n state.inAllOf &&\n schema.additionalProperties === false &&\n (!schema.properties || !Object.keys(schema.properties).length);\n\n if (!isEmptyObjectInAllOf) {\n irSchema.additionalProperties = {\n type: schema.additionalProperties ? 'unknown' : 'never',\n };\n }\n } else {\n const irAdditionalPropertiesSchema = schemaToIrSchema({\n context,\n schema: schema.additionalProperties,\n state,\n });\n irSchema.additionalProperties = irAdditionalPropertiesSchema;\n }\n\n if (schema.required) {\n irSchema.required = schema.required;\n }\n\n return irSchema;\n};\n\nconst parseString = ({\n irSchema = {},\n}: {\n context: Context;\n irSchema?: IR.SchemaObject;\n schema: SchemaObject;\n state: SchemaState;\n}): IR.SchemaObject => {\n irSchema.type = 'string';\n\n return irSchema;\n};\n\nconst initIrSchema = ({\n schema,\n}: {\n schema: SchemaObject;\n}): IR.SchemaObject => {\n const irSchema: IR.SchemaObject = {};\n\n parseSchemaJsDoc({\n irSchema,\n schema,\n });\n\n return irSchema;\n};\n\nconst parseAllOf = ({\n context,\n schema,\n state,\n}: {\n context: Context;\n schema: SchemaWithRequired<SchemaObject, 'allOf'>;\n state: SchemaState;\n}): IR.SchemaObject => {\n let irSchema = initIrSchema({ schema });\n\n const schemaItems: Array<IR.SchemaObject> = [];\n const schemaType = getSchemaType({ schema });\n\n const compositionSchemas = schema.allOf;\n\n for (const compositionSchema of compositionSchemas) {\n const originalInAllOf = state.inAllOf;\n // Don't propagate inAllOf flag to $ref schemas to avoid issues with reusable components\n if (!('$ref' in compositionSchema)) {\n state.inAllOf = true;\n }\n const irCompositionSchema = schemaToIrSchema({\n context,\n schema: compositionSchema,\n state,\n });\n state.inAllOf = originalInAllOf;\n if (state.inAllOf === undefined) {\n delete state.inAllOf;\n }\n\n if (schema.required) {\n if (irCompositionSchema.required) {\n irCompositionSchema.required = [\n ...irCompositionSchema.required,\n ...schema.required,\n ];\n } else {\n irCompositionSchema.required = schema.required;\n }\n }\n\n schemaItems.push(irCompositionSchema);\n\n if ('$ref' in compositionSchema) {\n const ref = context.resolveRef<SchemaObject>(compositionSchema.$ref);\n // `$ref` should be passed from the root `parseSchema()` call\n if (ref.discriminator && state.$ref) {\n const values = discriminatorValues(\n state.$ref,\n ref.discriminator.mapping,\n // If the ref has oneOf, we only use the schema name as the value\n // only if current schema is part of the oneOf. Else it is extending\n // the ref schema\n ref.oneOf\n ? () => ref.oneOf!.some((o) => '$ref' in o && o.$ref === state.$ref)\n : undefined,\n );\n\n if (values.length > 0) {\n const valueSchemas: ReadonlyArray<IR.SchemaObject> = values.map(\n (value) => ({\n const: value,\n type: 'string',\n }),\n );\n const irDiscriminatorSchema: IR.SchemaObject = {\n properties: {\n [ref.discriminator.propertyName]:\n valueSchemas.length > 1\n ? {\n items: valueSchemas,\n logicalOperator: 'or',\n }\n : valueSchemas[0]!,\n },\n type: 'object',\n };\n if (ref.required?.includes(ref.discriminator.propertyName)) {\n irDiscriminatorSchema.required = [ref.discriminator.propertyName];\n }\n schemaItems.push(irDiscriminatorSchema);\n }\n }\n }\n }\n\n if (schemaType === 'object') {\n const irObjectSchema = parseOneType({\n context,\n schema: {\n ...schema,\n type: 'object',\n },\n state,\n });\n\n if (irObjectSchema.properties) {\n for (const requiredProperty of irObjectSchema.required ?? []) {\n if (!irObjectSchema.properties[requiredProperty]) {\n for (const compositionSchema of compositionSchemas) {\n // TODO: parser - this could be probably resolved more accurately\n const finalCompositionSchema =\n '$ref' in compositionSchema\n ? context.resolveRef<SchemaObject>(compositionSchema.$ref)\n : compositionSchema;\n\n if (\n getSchemaType({ schema: finalCompositionSchema }) === 'object'\n ) {\n const irCompositionSchema = parseOneType({\n context,\n schema: {\n ...finalCompositionSchema,\n type: 'object',\n },\n state,\n });\n\n if (irCompositionSchema.properties?.[requiredProperty]) {\n irObjectSchema.properties[requiredProperty] =\n irCompositionSchema.properties[requiredProperty];\n break;\n }\n }\n }\n }\n }\n schemaItems.push(irObjectSchema);\n }\n }\n\n irSchema = addItemsToSchema({\n items: schemaItems,\n logicalOperator: 'and',\n mutateSchemaOneItem: true,\n schema: irSchema,\n });\n\n if (schema.nullable) {\n // nest composition to avoid producing an intersection with null\n const nestedItems: Array<IR.SchemaObject> = [\n {\n type: 'null',\n },\n ];\n\n if (schemaItems.length) {\n nestedItems.unshift(irSchema);\n }\n\n irSchema = {\n items: nestedItems,\n logicalOperator: 'or',\n };\n\n // TODO: parser - this is a hack to bring back up meta fields\n // without it, some schemas were missing original deprecated\n if (nestedItems[0]!.deprecated) {\n irSchema.deprecated = nestedItems[0]!.deprecated;\n }\n\n // TODO: parser - this is a hack to bring back up meta fields\n // without it, some schemas were missing original description\n if (nestedItems[0]!.description) {\n irSchema.description = nestedItems[0]!.description;\n }\n }\n\n return irSchema;\n};\n\nconst parseAnyOf = ({\n context,\n schema,\n state,\n}: {\n context: Context;\n schema: SchemaWithRequired<SchemaObject, 'anyOf'>;\n state: SchemaState;\n}): IR.SchemaObject => {\n let irSchema = initIrSchema({ schema });\n\n const schemaItems: Array<IR.SchemaObject> = [];\n const schemaType = getSchemaType({ schema });\n\n const compositionSchemas = schema.anyOf;\n\n for (const compositionSchema of compositionSchemas) {\n let irCompositionSchema = schemaToIrSchema({\n context,\n schema: compositionSchema,\n state,\n });\n\n // `$ref` should be defined with discriminators\n if (schema.discriminator && irCompositionSchema.$ref != null) {\n const values = discriminatorValues(\n irCompositionSchema.$ref,\n schema.discriminator.mapping,\n );\n const valueSchemas: ReadonlyArray<IR.SchemaObject> = values.map(\n (value) => ({\n const: value,\n type: 'string',\n }),\n );\n const irDiscriminatorSchema: IR.SchemaObject = {\n properties: {\n [schema.discriminator.propertyName]:\n valueSchemas.length > 1\n ? {\n items: valueSchemas,\n logicalOperator: 'or',\n }\n : valueSchemas[0]!,\n },\n type: 'object',\n };\n irCompositionSchema = {\n items: [irDiscriminatorSchema, irCompositionSchema],\n logicalOperator: 'and',\n };\n }\n\n schemaItems.push(irCompositionSchema);\n }\n\n if (schema.nullable) {\n schemaItems.push({ type: 'null' });\n }\n\n irSchema = addItemsToSchema({\n items: schemaItems,\n mutateSchemaOneItem: true,\n schema: irSchema,\n });\n\n if (schemaType === 'object') {\n // nest composition to avoid producing a union with object properties\n const irObjectSchema = parseOneType({\n context,\n schema: {\n ...schema,\n type: 'object',\n },\n state,\n });\n\n if (irObjectSchema.properties) {\n irSchema = {\n items: [irSchema, irObjectSchema],\n logicalOperator: 'and',\n };\n }\n }\n\n return irSchema;\n};\n\nconst parseEnum = ({\n context,\n schema,\n state,\n}: {\n context: Context;\n schema: SchemaWithRequired<SchemaObject, 'enum'>;\n state: SchemaState;\n}): IR.SchemaObject => {\n let irSchema = initIrSchema({ schema });\n\n irSchema.type = 'enum';\n\n const schemaItems: Array<IR.SchemaObject> = [];\n\n for (const [index, enumValue] of schema.enum.entries()) {\n const typeOfEnumValue = typeof enumValue;\n let enumType: SchemaType<SchemaObject> | 'null' | undefined;\n\n if (\n typeOfEnumValue === 'string' ||\n typeOfEnumValue === 'number' ||\n typeOfEnumValue === 'boolean'\n ) {\n enumType = typeOfEnumValue;\n } else if (typeOfEnumValue === 'object' && Array.isArray(enumValue)) {\n enumType = 'array';\n } else if (enumValue === null) {\n // nullable must be true\n if (schema.nullable) {\n enumType = 'null';\n }\n } else {\n console.warn(\n '🚨',\n `unhandled \"${typeOfEnumValue}\" typeof value \"${enumValue}\" for enum`,\n schema.enum,\n );\n }\n\n if (!enumType) {\n continue;\n }\n\n const irTypeSchema = parseOneType({\n context,\n schema: {\n description: schema['x-enum-descriptions']?.[index],\n title:\n schema['x-enum-varnames']?.[index] ?? schema['x-enumNames']?.[index],\n // cast enum to string temporarily\n type: enumType === 'null' ? 'string' : enumType,\n },\n state,\n });\n\n irTypeSchema.const = enumValue;\n\n // cast enum back\n if (enumType === 'null') {\n irTypeSchema.type = enumType;\n }\n\n if (irTypeSchema.type === 'array') {\n irTypeSchema.type = 'tuple';\n }\n\n schemaItems.push(irTypeSchema);\n }\n\n irSchema = addItemsToSchema({\n items: schemaItems,\n schema: irSchema,\n });\n\n return irSchema;\n};\n\nconst parseOneOf = ({\n context,\n schema,\n state,\n}: {\n context: Context;\n schema: SchemaWithRequired<SchemaObject, 'oneOf'>;\n state: SchemaState;\n}): IR.SchemaObject => {\n let irSchema = initIrSchema({ schema });\n\n let schemaItems: Array<IR.SchemaObject> = [];\n const schemaType = getSchemaType({ schema });\n\n const compositionSchemas = schema.oneOf;\n\n for (const compositionSchema of compositionSchemas) {\n let irCompositionSchema = schemaToIrSchema({\n context,\n schema: compositionSchema,\n state,\n });\n\n // `$ref` should be defined with discriminators\n if (schema.discriminator && irCompositionSchema.$ref != null) {\n const values = discriminatorValues(\n irCompositionSchema.$ref,\n schema.discriminator.mapping,\n );\n const valueSchemas: ReadonlyArray<IR.SchemaObject> = values.map(\n (value) => ({\n const: value,\n type: 'string',\n }),\n );\n const irDiscriminatorSchema: IR.SchemaObject = {\n properties: {\n [schema.discriminator.propertyName]:\n valueSchemas.length > 1\n ? {\n items: valueSchemas,\n logicalOperator: 'or',\n }\n : valueSchemas[0]!,\n },\n required: [schema.discriminator.propertyName],\n type: 'object',\n };\n irCompositionSchema = {\n items: [irDiscriminatorSchema, irCompositionSchema],\n logicalOperator: 'and',\n };\n }\n\n // since we know oneOf will be using \"or\" logical operator, if the parsed\n // composition schema also has an \"or\" operator, we can bring it up\n // to avoid unnecessary brackets\n if (\n irCompositionSchema.logicalOperator === 'or' &&\n irCompositionSchema.type !== 'array' &&\n irCompositionSchema.items\n ) {\n schemaItems = schemaItems.concat(irCompositionSchema.items);\n } else {\n schemaItems.push(irCompositionSchema);\n }\n }\n\n if (schema.nullable) {\n schemaItems.push({ type: 'null' });\n }\n\n irSchema = addItemsToSchema({\n items: schemaItems,\n mutateSchemaOneItem: true,\n schema: irSchema,\n });\n\n if (schemaType === 'object') {\n // nest composition to avoid producing a union with object properties\n const irObjectSchema = parseOneType({\n context,\n schema: {\n ...schema,\n type: 'object',\n },\n state,\n });\n\n if (irObjectSchema.properties) {\n irSchema = {\n items: [irSchema, irObjectSchema],\n logicalOperator: 'and',\n };\n }\n }\n\n return irSchema;\n};\n\nconst parseRef = ({\n context,\n schema,\n state,\n}: {\n context: Context;\n schema: ReferenceObject;\n state: SchemaState;\n}): IR.SchemaObject => {\n // Inline non-component refs (e.g. #/paths/...) to avoid generating orphaned named types\n const isComponentsRef = schema.$ref.startsWith('#/components/');\n if (!isComponentsRef) {\n if (!state.circularReferenceTracker.has(schema.$ref)) {\n const refSchema = context.resolveRef<SchemaObject>(schema.$ref);\n const originalRef = state.$ref;\n state.$ref = schema.$ref;\n const irSchema = schemaToIrSchema({\n context,\n schema: refSchema,\n state,\n });\n state.$ref = originalRef;\n return irSchema;\n }\n // Fallback to preserving the ref if circular\n }\n\n const irSchema: IR.SchemaObject = {};\n\n // refs using unicode characters become encoded, didn't investigate why\n // but the suspicion is this comes from `@hey-api/json-schema-ref-parser`\n irSchema.$ref = decodeURI(schema.$ref);\n\n if (!state.circularReferenceTracker.has(schema.$ref)) {\n const refSchema = context.resolveRef<SchemaObject>(schema.$ref);\n const originalRef = state.$ref;\n state.$ref = schema.$ref;\n schemaToIrSchema({\n context,\n schema: refSchema,\n state,\n });\n state.$ref = originalRef;\n }\n\n return irSchema;\n};\n\nconst parseNullableType = ({\n context,\n irSchema,\n schema,\n state,\n}: {\n context: Context;\n irSchema?: IR.SchemaObject;\n schema: SchemaWithRequired<SchemaObject, 'type'>;\n state: SchemaState;\n}): IR.SchemaObject => {\n if (!irSchema) {\n irSchema = initIrSchema({ schema });\n }\n\n const typeIrSchema: IR.SchemaObject = {};\n\n parseSchemaMeta({ irSchema: typeIrSchema, schema });\n\n if (typeIrSchema.default === null) {\n // clear to avoid duplicate default inside the non-null schema.\n // this would produce incorrect validator output\n delete typeIrSchema.default;\n }\n\n const schemaItems: Array<IR.SchemaObject> = [\n parseOneType({\n context,\n irSchema: typeIrSchema,\n schema,\n state,\n }),\n {\n type: 'null',\n },\n ];\n\n irSchema = addItemsToSchema({\n items: schemaItems,\n schema: irSchema,\n });\n\n return irSchema;\n};\n\nconst parseType = ({\n context,\n schema,\n state,\n}: {\n context: Context;\n schema: SchemaWithRequired<SchemaObject, 'type'>;\n state: SchemaState;\n}): IR.SchemaObject => {\n const irSchema = initIrSchema({ schema });\n\n parseSchemaMeta({ irSchema, schema });\n\n const type = getSchemaType({ schema });\n\n if (!type) {\n return irSchema;\n }\n\n if (!schema.nullable) {\n return parseOneType({\n context,\n irSchema,\n schema: {\n ...schema,\n type,\n },\n state,\n });\n }\n\n return parseNullableType({\n context,\n irSchema,\n schema: {\n ...schema,\n type,\n },\n state,\n });\n};\n\nconst parseOneType = ({\n context,\n irSchema,\n schema,\n state,\n}: {\n context: Context;\n irSchema?: IR.SchemaObject;\n schema: SchemaWithRequired<SchemaObject, 'type'>;\n state: SchemaState;\n}): IR.SchemaObject => {\n if (!irSchema) {\n irSchema = initIrSchema({ schema });\n\n parseSchemaMeta({ irSchema, schema });\n }\n\n switch (schema.type) {\n case 'array':\n return parseArray({\n context,\n irSchema,\n schema,\n state,\n });\n case 'boolean':\n return parseBoolean({\n context,\n irSchema,\n schema,\n state,\n });\n case 'integer':\n case 'number':\n return parseNumber({\n context,\n irSchema,\n schema,\n state,\n });\n case 'object':\n return parseObject({\n context,\n irSchema,\n schema,\n state,\n });\n case 'string':\n return parseString({\n context,\n irSchema,\n schema,\n state,\n });\n default:\n // gracefully handle invalid type\n return parseUnknown({\n context,\n irSchema,\n schema,\n });\n }\n};\n\nconst parseUnknown = ({\n irSchema,\n schema,\n}: {\n context: Context;\n irSchema?: IR.SchemaObject;\n schema: SchemaObject;\n}): IR.SchemaObject => {\n if (!irSchema) {\n irSchema = initIrSchema({ schema });\n }\n\n irSchema.type = 'unknown';\n\n parseSchemaMeta({ irSchema, schema });\n\n return irSchema;\n};\n\nexport const schemaToIrSchema = ({\n context,\n schema,\n state,\n}: {\n context: Context;\n schema: SchemaObject | ReferenceObject;\n state: SchemaState | undefined;\n}): IR.SchemaObject => {\n if (!state) {\n state = {\n circularReferenceTracker: new Set(),\n };\n }\n\n if (state.$ref) {\n state.circularReferenceTracker.add(state.$ref);\n }\n\n if ('$ref' in schema) {\n return parseRef({\n context,\n schema,\n state,\n });\n }\n\n if (schema.enum) {\n return parseEnum({\n context,\n schema: schema as SchemaWithRequired<SchemaObject, 'enum'>,\n state,\n });\n }\n\n if (schema.allOf) {\n return parseAllOf({\n context,\n schema: schema as SchemaWithRequired<SchemaObject, 'allOf'>,\n state,\n });\n }\n\n if (schema.anyOf) {\n return parseAnyOf({\n context,\n schema: schema as SchemaWithRequired<SchemaObject, 'anyOf'>,\n state,\n });\n }\n\n if (schema.oneOf) {\n return parseOneOf({\n context,\n schema: schema as SchemaWithRequired<SchemaObject, 'oneOf'>,\n state,\n });\n }\n\n // infer object based on the presence of properties\n if (schema.type || schema.properties) {\n return parseType({\n context,\n schema: schema as SchemaWithRequired<SchemaObject, 'type'>,\n state,\n });\n }\n\n return parseUnknown({ context, schema });\n};\n\nexport const parseSchema = ({\n $ref,\n context,\n schema,\n}: {\n $ref: string;\n context: Context;\n schema: SchemaObject | ReferenceObject;\n}) => {\n if (!context.ir.components) {\n context.ir.components = {};\n }\n\n if (!context.ir.components.schemas) {\n context.ir.components.schemas = {};\n }\n\n context.ir.components.schemas[refToName($ref)] = schemaToIrSchema({\n context,\n schema,\n state: {\n $ref,\n circularReferenceTracker: new Set(),\n },\n });\n};\n","import type { Context } from '~/ir/context';\nimport { getPaginationKeywordsRegExp } from '~/ir/pagination';\nimport type { SchemaType } from '~/openApi/shared/types/schema';\n\nimport type {\n ParameterObject,\n ReferenceObject,\n RequestBodyObject,\n} from '../types/spec';\nimport type { SchemaObject } from '../types/spec';\nimport { mediaTypeObjects } from './mediaType';\nimport { getSchemaType } from './schema';\n\nconst isPaginationType = (\n schemaType: SchemaType<SchemaObject> | undefined,\n): boolean =>\n schemaType === 'boolean' ||\n schemaType === 'integer' ||\n schemaType === 'number' ||\n schemaType === 'string';\n\n// We handle only simple values for now, up to 1 nested field\nexport const paginationField = ({\n context,\n name,\n schema,\n}: {\n context: Context;\n name: string;\n schema: SchemaObject | ReferenceObject;\n}): boolean | string => {\n const paginationRegExp = getPaginationKeywordsRegExp(\n context.config.parser.pagination,\n );\n if (paginationRegExp.test(name)) {\n return true;\n }\n\n if ('$ref' in schema) {\n const ref = context.resolveRef<\n ParameterObject | RequestBodyObject | SchemaObject\n >(schema.$ref);\n\n if ('content' in ref || 'in' in ref) {\n let refSchema: SchemaObject | ReferenceObject | undefined;\n\n if ('in' in ref) {\n refSchema = ref.schema;\n }\n\n if (!refSchema) {\n // parameter or body\n const contents = mediaTypeObjects({ content: ref.content });\n // TODO: add support for multiple content types, for now prefer JSON\n const content =\n contents.find((content) => content.type === 'json') || contents[0];\n if (content?.schema) {\n refSchema = content.schema;\n }\n }\n\n if (!refSchema) {\n return false;\n }\n\n return paginationField({\n context,\n name,\n schema: refSchema,\n });\n }\n\n return paginationField({\n context,\n name,\n schema: ref,\n });\n }\n\n for (const name in schema.properties) {\n const paginationRegExp = getPaginationKeywordsRegExp(\n context.config.parser.pagination,\n );\n\n if (paginationRegExp.test(name)) {\n const property = schema.properties[name]!;\n\n if (typeof property !== 'boolean' && !('$ref' in property)) {\n const schemaType = getSchemaType({ schema: property });\n // TODO: resolve deeper references\n\n if (isPaginationType(schemaType)) {\n return name;\n }\n }\n }\n }\n\n for (const allOf of schema.allOf ?? []) {\n const pagination = paginationField({\n context,\n name,\n schema: allOf,\n });\n if (pagination) {\n return pagination;\n }\n }\n\n return false;\n};\n","import type { Context } from '~/ir/context';\nimport type { IR } from '~/ir/types';\nimport type { State } from '~/openApi/shared/types/state';\nimport { operationToId } from '~/openApi/shared/utils/operation';\n\nimport type {\n OperationObject,\n PathItemObject,\n RequestBodyObject,\n ResponseObject,\n SecuritySchemeObject,\n} from '../types/spec';\nimport { contentToSchema, mediaTypeObjects } from './mediaType';\nimport { paginationField } from './pagination';\nimport { schemaToIrSchema } from './schema';\n\ninterface Operation\n extends Omit<OperationObject, 'parameters'>,\n Pick<IR.OperationObject, 'parameters'> {}\n\nconst parseOperationJsDoc = ({\n irOperation,\n operation,\n}: {\n irOperation: IR.OperationObject;\n operation: Operation;\n}) => {\n if (operation.deprecated !== undefined) {\n irOperation.deprecated = operation.deprecated;\n }\n\n if (operation.description) {\n irOperation.description = operation.description;\n }\n\n if (operation.summary) {\n irOperation.summary = operation.summary;\n }\n\n if (operation.tags?.length) {\n irOperation.tags = operation.tags;\n }\n};\n\nconst initIrOperation = ({\n context,\n method,\n operation,\n path,\n state,\n}: Pick<IR.OperationObject, 'method' | 'path'> & {\n context: Context;\n operation: Operation;\n state: State;\n}): IR.OperationObject => {\n const irOperation: IR.OperationObject = {\n id: operationToId({\n context,\n id: operation.operationId,\n method,\n path,\n state,\n }),\n method,\n path,\n };\n\n if (operation.operationId) {\n irOperation.operationId = operation.operationId;\n }\n\n parseOperationJsDoc({\n irOperation,\n operation,\n });\n\n return irOperation;\n};\n\nconst operationToIrOperation = ({\n context,\n method,\n operation,\n path,\n securitySchemesMap,\n state,\n}: Pick<IR.OperationObject, 'method' | 'path'> & {\n context: Context;\n operation: Operation;\n securitySchemesMap: Map<string, SecuritySchemeObject>;\n state: State;\n}): IR.OperationObject => {\n const irOperation = initIrOperation({\n context,\n method,\n operation,\n path,\n state,\n });\n\n if (operation.parameters) {\n irOperation.parameters = operation.parameters;\n }\n\n if (operation.requestBody) {\n const requestBody =\n '$ref' in operation.requestBody\n ? context.resolveRef<RequestBodyObject>(operation.requestBody.$ref)\n : operation.requestBody;\n const contents = mediaTypeObjects({ content: requestBody.content });\n // TODO: add support for multiple content types, for now prefer JSON\n const content =\n contents.find((content) => content.type === 'json') || contents[0];\n\n if (content) {\n const pagination = paginationField({\n context,\n name: '',\n schema:\n content.schema && '$ref' in content.schema\n ? {\n allOf: [{ ...content.schema }],\n description: requestBody.description,\n }\n : {\n description: requestBody.description,\n ...content.schema,\n },\n });\n\n irOperation.body = {\n mediaType: content.mediaType,\n schema: schemaToIrSchema({\n context,\n schema:\n '$ref' in operation.requestBody\n ? {\n allOf: [{ ...operation.requestBody }],\n description: requestBody.description,\n }\n : content.schema && '$ref' in content.schema\n ? {\n allOf: [{ ...content.schema }],\n description: requestBody.description,\n }\n : {\n description: requestBody.description,\n ...content.schema,\n },\n state: undefined,\n }),\n };\n\n if (pagination) {\n irOperation.body.pagination = pagination;\n }\n\n if (requestBody.required) {\n irOperation.body.required = requestBody.required;\n }\n\n if (content.type) {\n irOperation.body.type = content.type;\n }\n }\n }\n\n for (const name in operation.responses) {\n if (!irOperation.responses) {\n irOperation.responses = {};\n }\n\n const response = operation.responses[name]!;\n const responseObject =\n '$ref' in response\n ? context.resolveRef<ResponseObject>(response.$ref)\n : response;\n const contents = mediaTypeObjects({ content: responseObject.content });\n // TODO: add support for multiple content types, for now prefer JSON\n const content =\n contents.find((content) => content.type === 'json') || contents[0];\n\n if (content) {\n irOperation.responses[name] = {\n mediaType: content.mediaType,\n schema: schemaToIrSchema({\n context,\n schema: {\n description: responseObject.description,\n ...contentToSchema({ content }),\n },\n state: undefined,\n }),\n };\n } else {\n irOperation.responses[name] = {\n schema: {\n description: responseObject.description,\n // TODO: parser - cover all statues with empty response bodies\n // 1xx, 204, 205, 304\n type: name === '204' ? 'void' : 'unknown',\n },\n };\n }\n }\n\n if (operation.security) {\n const securitySchemeObjects: Map<string, IR.SecurityObject> = new Map();\n\n for (const securityRequirementObject of operation.security) {\n for (const name in securityRequirementObject) {\n const securitySchemeObject = securitySchemesMap.get(name);\n\n if (!securitySchemeObject) {\n continue;\n }\n\n securitySchemeObjects.set(name, securitySchemeObject);\n }\n }\n\n if (securitySchemeObjects.size) {\n irOperation.security = Array.from(securitySchemeObjects.values());\n }\n }\n\n // TODO: parser - handle servers\n // qux: operation.servers\n\n return irOperation;\n};\n\nexport const parsePathOperation = ({\n context,\n method,\n operation,\n path,\n securitySchemesMap,\n state,\n}: {\n context: Context;\n method: Extract<\n keyof PathItemObject,\n 'delete' | 'get' | 'head' | 'options' | 'patch' | 'post' | 'put' | 'trace'\n >;\n operation: Operation;\n path: keyof IR.PathsObject;\n securitySchemesMap: Map<string, SecuritySchemeObject>;\n state: State;\n}) => {\n if (!context.ir.paths) {\n context.ir.paths = {};\n }\n\n if (!context.ir.paths[path]) {\n context.ir.paths[path] = {};\n }\n\n if (operation.servers) {\n context.ir.servers = [...(context.ir.servers ?? []), ...operation.servers];\n }\n\n context.ir.paths[path][method] = operationToIrOperation({\n context,\n method,\n operation,\n path,\n securitySchemesMap,\n state,\n });\n};\n","import type { Context } from '~/ir/context';\nimport type { IR } from '~/ir/types';\nimport { refToName } from '~/utils/ref';\n\nimport type {\n ParameterObject,\n ReferenceObject,\n SchemaObject,\n} from '../types/spec';\nimport { mediaTypeObjects } from './mediaType';\nimport { paginationField } from './pagination';\nimport { schemaToIrSchema } from './schema';\n\n/**\n * Returns default parameter `allowReserved` based on value of `in`.\n */\nconst defaultAllowReserved = (\n _in: ParameterObject['in'],\n): boolean | undefined => {\n switch (_in) {\n // this keyword only applies to parameters with an `in` value of `query`\n case 'query':\n return false;\n default:\n return;\n }\n};\n\n/**\n * Returns default parameter `explode` based on value of `style`.\n */\nconst defaultExplode = (style: Required<ParameterObject>['style']): boolean => {\n switch (style) {\n // default value for `deepObject` is `false`, but that behavior is undefined\n // so we use `true` to make this work with the `client-fetch` package\n case 'deepObject':\n case 'form':\n return true;\n default:\n return false;\n }\n};\n\n/**\n * Returns default parameter `style` based on value of `in`.\n */\nconst defaultStyle = (\n _in: ParameterObject['in'],\n): Required<IR.ParameterObject>['style'] => {\n switch (_in) {\n case 'header':\n case 'path':\n return 'simple';\n case 'cookie':\n case 'query':\n return 'form';\n }\n};\n\nexport const parametersArrayToObject = ({\n context,\n parameters,\n}: {\n context: Context;\n parameters?: ReadonlyArray<ParameterObject | ReferenceObject>;\n}): IR.ParametersObject | undefined => {\n if (!parameters || !Object.keys(parameters).length) {\n return;\n }\n\n const parametersObject: IR.ParametersObject = {};\n\n for (const parameterOrReference of parameters) {\n const parameter =\n '$ref' in parameterOrReference\n ? context.dereference<ParameterObject>(parameterOrReference)\n : parameterOrReference;\n\n if (!parametersObject[parameter.in]) {\n parametersObject[parameter.in] = {};\n }\n\n // lowercase keys for case insensitive access\n parametersObject[parameter.in]![parameter.name.toLocaleLowerCase()] =\n parameterToIrParameter({\n $ref: `#/todo/real/path/to/parameter/${parameter.name}`,\n context,\n parameter,\n });\n }\n\n return parametersObject;\n};\n\nconst parameterToIrParameter = ({\n $ref,\n context,\n parameter,\n}: {\n $ref: string;\n context: Context;\n parameter: ParameterObject;\n}): IR.ParameterObject => {\n // TODO: parser - fix\n let schema = parameter.schema;\n\n if (!schema) {\n const contents = mediaTypeObjects({ content: parameter.content });\n // TODO: add support for multiple content types, for now prefer JSON\n const content =\n contents.find((content) => content.type === 'json') || contents[0];\n if (content) {\n schema = content.schema;\n }\n }\n\n const finalSchema: SchemaObject =\n schema && '$ref' in schema\n ? {\n allOf: [{ ...schema }],\n deprecated: parameter.deprecated,\n description: parameter.description,\n }\n : {\n deprecated: parameter.deprecated,\n description: parameter.description,\n ...schema,\n };\n\n const pagination = paginationField({\n context,\n name: parameter.name,\n schema: finalSchema,\n });\n\n const style = parameter.style || defaultStyle(parameter.in);\n const explode =\n parameter.explode !== undefined ? parameter.explode : defaultExplode(style);\n const allowReserved =\n parameter.allowReserved !== undefined\n ? parameter.allowReserved\n : defaultAllowReserved(parameter.in);\n\n const irParameter: IR.ParameterObject = {\n allowReserved,\n explode,\n location: parameter.in,\n name: parameter.name,\n schema: schemaToIrSchema({\n context,\n schema: finalSchema,\n state: {\n $ref,\n circularReferenceTracker: new Set(),\n },\n }),\n style,\n };\n\n if (parameter.deprecated) {\n irParameter.deprecated = parameter.deprecated;\n }\n\n if (parameter.description) {\n irParameter.description = parameter.description;\n }\n\n if (pagination) {\n irParameter.pagination = pagination;\n }\n\n if (parameter.required) {\n irParameter.required = parameter.required;\n }\n\n return irParameter;\n};\n\nexport const parseParameter = ({\n $ref,\n context,\n parameter,\n}: {\n $ref: string;\n context: Context;\n parameter: ParameterObject;\n}) => {\n if (!context.ir.components) {\n context.ir.components = {};\n }\n\n if (!context.ir.components.parameters) {\n context.ir.components.parameters = {};\n }\n\n context.ir.components.parameters[refToName($ref)] = parameterToIrParameter({\n $ref,\n context,\n parameter,\n });\n};\n","import type { Context } from '~/ir/context';\nimport type { IR } from '~/ir/types';\nimport { refToName } from '~/utils/ref';\n\nimport type { RequestBodyObject, SchemaObject } from '../types/spec';\nimport { mediaTypeObjects } from './mediaType';\nimport { schemaToIrSchema } from './schema';\n\nconst requestBodyToIrRequestBody = ({\n $ref,\n context,\n requestBody,\n}: {\n $ref: string;\n context: Context;\n requestBody: RequestBodyObject;\n}): IR.RequestBodyObject => {\n // TODO: parser - fix\n const contents = mediaTypeObjects({ content: requestBody.content });\n // TODO: add support for multiple content types, for now prefer JSON\n const content =\n contents.find((content) => content.type === 'json') || contents[0];\n const schema = content ? content.schema : undefined;\n\n const finalSchema: SchemaObject = {\n description: requestBody.description,\n ...schema,\n };\n\n const irRequestBody: IR.RequestBodyObject = {\n schema: schemaToIrSchema({\n context,\n schema: finalSchema,\n state: {\n $ref,\n circularReferenceTracker: new Set(),\n },\n }),\n };\n\n if (requestBody.description) {\n irRequestBody.description = requestBody.description;\n }\n\n if (requestBody.required) {\n irRequestBody.required = requestBody.required;\n }\n\n return irRequestBody;\n};\n\nexport const parseRequestBody = ({\n $ref,\n context,\n requestBody,\n}: {\n $ref: string;\n context: Context;\n requestBody: RequestBodyObject;\n}) => {\n if (!context.ir.components) {\n context.ir.components = {};\n }\n\n if (!context.ir.components.requestBodies) {\n context.ir.components.requestBodies = {};\n }\n\n context.ir.components.requestBodies[refToName($ref)] =\n requestBodyToIrRequestBody({\n $ref,\n context,\n requestBody,\n });\n};\n","import type { Context } from '~/ir/context';\nimport { parseUrl } from '~/utils/url';\n\nexport const parseServers = ({ context }: { context: Context }) => {\n if (context.spec.servers) {\n context.ir.servers = context.spec.servers;\n return;\n }\n\n for (const input of context.config.input) {\n if (typeof input.path === 'string') {\n const url = parseUrl(input.path);\n context.ir.servers = [\n {\n url: `${url.protocol ? `${url.protocol}://` : ''}${url.host}${url.port ? `:${url.port}` : ''}`,\n },\n ];\n }\n }\n\n if (!context.ir.servers) {\n context.ir.servers = [\n {\n url: '/',\n },\n ];\n }\n};\n","import { createOperationKey } from '~/ir/operation';\nimport { httpMethods } from '~/openApi/shared/utils/operation';\nimport type {\n ValidatorIssue,\n ValidatorResult,\n} from '~/openApi/shared/utils/validator';\nimport type { Logger } from '~/utils/logger';\n\nimport type { OpenApiV3_0_X, PathItemObject, PathsObject } from '../types/spec';\n\nexport const validateOpenApiSpec = (\n spec: OpenApiV3_0_X,\n logger: Logger,\n): ValidatorResult => {\n const eventValidate = logger.timeEvent('validate');\n const issues: Array<ValidatorIssue> = [];\n const operationIds = new Map();\n\n if (spec.paths) {\n for (const entry of Object.entries(spec.paths)) {\n const path = entry[0] as keyof PathsObject;\n const pathItem = entry[1] as PathItemObject;\n for (const method of httpMethods) {\n const operation = pathItem[method];\n if (!operation) {\n continue;\n }\n\n const operationKey = createOperationKey({ method, path });\n\n if (operation.operationId) {\n if (!operationIds.has(operation.operationId)) {\n operationIds.set(operation.operationId, operationKey);\n } else {\n issues.push({\n code: 'duplicate_key',\n context: {\n key: 'operationId',\n value: operation.operationId,\n },\n message:\n 'Duplicate `operationId` found. Each `operationId` must be unique.',\n path: ['paths', path, method, 'operationId'],\n severity: 'error',\n });\n }\n }\n }\n }\n }\n\n if (spec.servers) {\n if (typeof spec.servers !== 'object' || !Array.isArray(spec.servers)) {\n issues.push({\n code: 'invalid_type',\n message: '`servers` must be an array.',\n path: [],\n severity: 'error',\n });\n }\n\n for (let index = 0; index < spec.servers.length; index++) {\n const server = spec.servers[index];\n if (!server || typeof server !== 'object') {\n issues.push({\n code: 'invalid_type',\n context: {\n actual: typeof server,\n expected: 'object',\n },\n message: 'Each entry in `servers` must be an object.',\n path: ['servers', index],\n severity: 'error',\n });\n } else {\n if (!server.url) {\n issues.push({\n code: 'missing_required_field',\n context: {\n field: 'url',\n },\n message: 'Missing required field `url` in server object.',\n path: ['servers', index],\n severity: 'error',\n });\n }\n }\n }\n }\n\n eventValidate.timeEnd();\n return {\n issues,\n valid: !issues.some((issue) => issue.severity === 'error'),\n };\n};\n","import type { Context } from '~/ir/context';\nimport { buildResourceMetadata } from '~/openApi/shared/graph/meta';\nimport { transformOpenApiSpec } from '~/openApi/shared/transforms';\nimport type { State } from '~/openApi/shared/types/state';\nimport {\n createFilteredDependencies,\n createFilters,\n hasFilters,\n} from '~/openApi/shared/utils/filter';\nimport { buildGraph } from '~/openApi/shared/utils/graph';\nimport { mergeParametersObjects } from '~/openApi/shared/utils/parameter';\nimport { handleValidatorResult } from '~/openApi/shared/utils/validator';\n\nimport type {\n OpenApiV3_0_X,\n ParameterObject,\n PathItemObject,\n PathsObject,\n RequestBodyObject,\n SecuritySchemeObject,\n} from '../types/spec';\nimport { filterSpec } from './filter';\nimport { parsePathOperation } from './operation';\nimport { parametersArrayToObject, parseParameter } from './parameter';\nimport { parseRequestBody } from './requestBody';\nimport { parseSchema } from './schema';\nimport { parseServers } from './server';\nimport { validateOpenApiSpec } from './validate';\n\nexport const parseV3_0_X = (context: Context<OpenApiV3_0_X>) => {\n if (context.config.parser.validate_EXPERIMENTAL) {\n const result = validateOpenApiSpec(context.spec, context.logger);\n handleValidatorResult({ context, result });\n }\n\n const shouldFilterSpec = hasFilters(context.config.parser.filters);\n if (shouldFilterSpec) {\n const filters = createFilters(\n context.config.parser.filters,\n context.spec,\n context.logger,\n );\n const { graph } = buildGraph(context.spec, context.logger);\n const { resourceMetadata } = buildResourceMetadata(graph, context.logger);\n const sets = createFilteredDependencies({\n filters,\n logger: context.logger,\n resourceMetadata,\n });\n filterSpec({\n ...sets,\n logger: context.logger,\n preserveOrder: filters.preserveOrder,\n spec: context.spec,\n });\n }\n\n transformOpenApiSpec({ context });\n\n const state: State = {\n ids: new Map(),\n };\n const securitySchemesMap = new Map<string, SecuritySchemeObject>();\n\n // TODO: parser - handle more component types, old parser handles only parameters and schemas\n if (context.spec.components) {\n for (const name in context.spec.components.securitySchemes) {\n const securityOrReference =\n context.spec.components.securitySchemes[name]!;\n const securitySchemeObject =\n '$ref' in securityOrReference\n ? context.resolveRef<SecuritySchemeObject>(securityOrReference.$ref)\n : securityOrReference;\n securitySchemesMap.set(name, securitySchemeObject);\n }\n\n for (const name in context.spec.components.parameters) {\n const $ref = `#/components/parameters/${name}`;\n const parameterOrReference = context.spec.components.parameters[name]!;\n const parameter =\n '$ref' in parameterOrReference\n ? context.resolveRef<ParameterObject>(parameterOrReference.$ref)\n : parameterOrReference;\n\n parseParameter({\n $ref,\n context,\n parameter,\n });\n }\n\n for (const name in context.spec.components.requestBodies) {\n const $ref = `#/components/requestBodies/${name}`;\n const requestBodyOrReference =\n context.spec.components.requestBodies[name]!;\n const requestBody =\n '$ref' in requestBodyOrReference\n ? context.resolveRef<RequestBodyObject>(requestBodyOrReference.$ref)\n : requestBodyOrReference;\n\n parseRequestBody({\n $ref,\n context,\n requestBody,\n });\n }\n\n for (const name in context.spec.components.schemas) {\n const $ref = `#/components/schemas/${name}`;\n const schema = context.spec.components.schemas[name]!;\n\n parseSchema({\n $ref,\n context,\n schema,\n });\n }\n }\n\n parseServers({ context });\n\n for (const path in context.spec.paths) {\n const pathItem = context.spec.paths[path as keyof PathsObject]!;\n\n const finalPathItem = pathItem.$ref\n ? {\n ...context.resolveRef<PathItemObject>(pathItem.$ref),\n ...pathItem,\n }\n : pathItem;\n\n const operationArgs: Omit<\n Parameters<typeof parsePathOperation>[0],\n 'method' | 'operation'\n > & {\n operation: Omit<\n Parameters<typeof parsePathOperation>[0]['operation'],\n 'responses'\n >;\n } = {\n context,\n operation: {\n description: finalPathItem.description,\n parameters: parametersArrayToObject({\n context,\n parameters: finalPathItem.parameters,\n }),\n security: context.spec.security,\n servers: finalPathItem.servers,\n summary: finalPathItem.summary,\n },\n path: path as keyof PathsObject,\n securitySchemesMap,\n state,\n };\n\n if (finalPathItem.delete) {\n parsePathOperation({\n ...operationArgs,\n method: 'delete',\n operation: {\n ...operationArgs.operation,\n ...finalPathItem.delete,\n parameters: mergeParametersObjects({\n source: parametersArrayToObject({\n context,\n parameters: finalPathItem.delete.parameters,\n }),\n target: operationArgs.operation.parameters,\n }),\n },\n });\n }\n\n if (finalPathItem.get) {\n parsePathOperation({\n ...operationArgs,\n method: 'get',\n operation: {\n ...operationArgs.operation,\n ...finalPathItem.get,\n parameters: mergeParametersObjects({\n source: parametersArrayToObject({\n context,\n parameters: finalPathItem.get.parameters,\n }),\n target: operationArgs.operation.parameters,\n }),\n },\n });\n }\n\n if (finalPathItem.head) {\n parsePathOperation({\n ...operationArgs,\n method: 'head',\n operation: {\n ...operationArgs.operation,\n ...finalPathItem.head,\n parameters: mergeParametersObjects({\n source: parametersArrayToObject({\n context,\n parameters: finalPathItem.head.parameters,\n }),\n target: operationArgs.operation.parameters,\n }),\n },\n });\n }\n\n if (finalPathItem.options) {\n parsePathOperation({\n ...operationArgs,\n method: 'options',\n operation: {\n ...operationArgs.operation,\n ...finalPathItem.options,\n parameters: mergeParametersObjects({\n source: parametersArrayToObject({\n context,\n parameters: finalPathItem.options.parameters,\n }),\n target: operationArgs.operation.parameters,\n }),\n },\n });\n }\n\n if (finalPathItem.patch) {\n parsePathOperation({\n ...operationArgs,\n method: 'patch',\n operation: {\n ...operationArgs.operation,\n ...finalPathItem.patch,\n parameters: mergeParametersObjects({\n source: parametersArrayToObject({\n context,\n parameters: finalPathItem.patch.parameters,\n }),\n target: operationArgs.operation.parameters,\n }),\n },\n });\n }\n\n if (finalPathItem.post) {\n parsePathOperation({\n ...operationArgs,\n method: 'post',\n operation: {\n ...operationArgs.operation,\n ...finalPathItem.post,\n parameters: mergeParametersObjects({\n source: parametersArrayToObject({\n context,\n parameters: finalPathItem.post.parameters,\n }),\n target: operationArgs.operation.parameters,\n }),\n },\n });\n }\n\n if (finalPathItem.put) {\n parsePathOperation({\n ...operationArgs,\n method: 'put',\n operation: {\n ...operationArgs.operation,\n ...finalPathItem.put,\n parameters: mergeParametersObjects({\n source: parametersArrayToObject({\n context,\n parameters: finalPathItem.put.parameters,\n }),\n target: operationArgs.operation.parameters,\n }),\n },\n });\n }\n\n if (finalPathItem.trace) {\n parsePathOperation({\n ...operationArgs,\n method: 'trace',\n operation: {\n ...operationArgs.operation,\n ...finalPathItem.trace,\n parameters: mergeParametersObjects({\n source: parametersArrayToObject({\n context,\n parameters: finalPathItem.trace.parameters,\n }),\n target: operationArgs.operation.parameters,\n }),\n },\n });\n }\n }\n};\n","import { createOperationKey } from '~/ir/operation';\nimport { addNamespace, removeNamespace } from '~/openApi/shared/utils/filter';\nimport { httpMethods } from '~/openApi/shared/utils/operation';\nimport type { Logger } from '~/utils/logger';\n\nimport type { OpenApiV3_1_X, PathItemObject, PathsObject } from '../types/spec';\n\n/**\n * Replace source spec with filtered version.\n */\nexport const filterSpec = ({\n logger,\n operations,\n parameters,\n preserveOrder,\n requestBodies,\n responses,\n schemas,\n spec,\n}: {\n logger: Logger;\n operations: Set<string>;\n parameters: Set<string>;\n preserveOrder: boolean;\n requestBodies: Set<string>;\n responses: Set<string>;\n schemas: Set<string>;\n spec: OpenApiV3_1_X;\n}) => {\n const eventFilterSpec = logger.timeEvent('filter-spec');\n if (spec.components) {\n if (spec.components.parameters) {\n const filtered: typeof spec.components.parameters = {};\n\n if (preserveOrder) {\n for (const [name, source] of Object.entries(\n spec.components.parameters,\n )) {\n if (parameters.has(addNamespace('parameter', name))) {\n filtered[name] = source;\n }\n }\n } else {\n for (const key of parameters) {\n const { name } = removeNamespace(key);\n const source = spec.components.parameters[name];\n if (source) {\n filtered[name] = source;\n }\n }\n }\n\n spec.components.parameters = filtered;\n }\n\n if (spec.components.requestBodies) {\n const filtered: typeof spec.components.requestBodies = {};\n\n if (preserveOrder) {\n for (const [name, source] of Object.entries(\n spec.components.requestBodies,\n )) {\n if (requestBodies.has(addNamespace('body', name))) {\n filtered[name] = source;\n }\n }\n } else {\n for (const key of requestBodies) {\n const { name } = removeNamespace(key);\n const source = spec.components.requestBodies[name];\n if (source) {\n filtered[name] = source;\n }\n }\n }\n\n spec.components.requestBodies = filtered;\n }\n\n if (spec.components.responses) {\n const filtered: typeof spec.components.responses = {};\n\n if (preserveOrder) {\n for (const [name, source] of Object.entries(\n spec.components.responses,\n )) {\n if (responses.has(addNamespace('response', name))) {\n filtered[name] = source;\n }\n }\n } else {\n for (const key of responses) {\n const { name } = removeNamespace(key);\n const source = spec.components.responses[name];\n if (source) {\n filtered[name] = source;\n }\n }\n }\n\n spec.components.responses = filtered;\n }\n\n if (spec.components.schemas) {\n const filtered: typeof spec.components.schemas = {};\n\n if (preserveOrder) {\n for (const [name, source] of Object.entries(spec.components.schemas)) {\n if (schemas.has(addNamespace('schema', name))) {\n filtered[name] = source;\n }\n }\n } else {\n for (const key of schemas) {\n const { name } = removeNamespace(key);\n const source = spec.components.schemas[name];\n if (source) {\n filtered[name] = source;\n }\n }\n }\n\n spec.components.schemas = filtered;\n }\n }\n\n if (spec.paths) {\n for (const entry of Object.entries(spec.paths)) {\n const path = entry[0] as keyof PathsObject;\n const pathItem = entry[1] as PathItemObject;\n\n for (const method of httpMethods) {\n const operation = pathItem[method];\n if (!operation) {\n continue;\n }\n\n const key = addNamespace(\n 'operation',\n createOperationKey({ method, path }),\n );\n if (!operations.has(key)) {\n delete pathItem[method];\n }\n }\n\n // remove paths that have no operations left\n if (!Object.keys(pathItem).length) {\n delete spec.paths[path];\n }\n }\n }\n eventFilterSpec.timeEnd();\n};\n","import type { IRMediaType } from '~/ir/mediaType';\nimport { isMediaTypeFileLike, mediaTypeToIrMediaType } from '~/ir/mediaType';\n\nimport type { MediaTypeObject, SchemaObject } from '../types/spec';\n\ninterface Content {\n mediaType: string;\n schema: SchemaObject | undefined;\n type: IRMediaType | undefined;\n}\n\nexport const contentToSchema = ({\n content,\n}: {\n content: Content;\n}): SchemaObject | undefined => {\n const { mediaType, schema } = content;\n\n if (!schema) {\n if (isMediaTypeFileLike({ mediaType })) {\n return {\n format: 'binary',\n type: 'string',\n };\n }\n return;\n }\n\n if (\n schema.type === 'string' &&\n !schema.format &&\n isMediaTypeFileLike({ mediaType })\n ) {\n return {\n ...schema,\n format: 'binary',\n };\n }\n\n return schema;\n};\n\nexport const mediaTypeObjects = ({\n content,\n}: {\n content: Record<string, MediaTypeObject> | undefined;\n}): ReadonlyArray<Content> => {\n const objects: Array<Content> = [];\n\n for (const mediaType in content) {\n objects.push({\n mediaType,\n schema: content[mediaType]!.schema,\n type: mediaTypeToIrMediaType({ mediaType }),\n });\n }\n\n return objects;\n};\n","import type { Context } from '~/ir/context';\nimport type { IR } from '~/ir/types';\nimport { addItemsToSchema } from '~/ir/utils';\nimport type {\n SchemaState,\n SchemaType,\n SchemaWithRequired,\n} from '~/openApi/shared/types/schema';\nimport { discriminatorValues } from '~/openApi/shared/utils/discriminator';\nimport { refToName } from '~/utils/ref';\n\nimport type { SchemaObject } from '../types/spec';\n\nexport const getSchemaTypes = ({\n schema,\n}: {\n schema: SchemaObject;\n}): ReadonlyArray<SchemaType<SchemaObject>> => {\n if (typeof schema.type === 'string') {\n return [schema.type];\n }\n\n if (schema.type) {\n return schema.type;\n }\n\n // infer object based on the presence of properties\n if (schema.properties) {\n return ['object'];\n }\n\n return [];\n};\n\nconst parseSchemaJsDoc = ({\n irSchema,\n schema,\n}: {\n irSchema: IR.SchemaObject;\n schema: SchemaObject;\n}) => {\n if (schema.deprecated !== undefined) {\n irSchema.deprecated = schema.deprecated;\n }\n\n if (schema.example) {\n irSchema.example = schema.example;\n }\n\n if (schema.description) {\n irSchema.description = schema.description;\n }\n\n if (schema.title) {\n irSchema.title = schema.title;\n }\n};\n\nconst parseSchemaMeta = ({\n irSchema,\n schema,\n}: {\n irSchema: IR.SchemaObject;\n schema: SchemaObject;\n}) => {\n if (schema.const !== undefined) {\n irSchema.const = schema.const;\n\n // try to infer schema type\n if (!schema.type) {\n if (schema.const === null) {\n irSchema.type = 'null';\n } else {\n switch (typeof schema.const) {\n case 'bigint':\n case 'number':\n irSchema.type = 'number';\n break;\n case 'boolean':\n irSchema.type = 'boolean';\n break;\n case 'string':\n irSchema.type = 'string';\n break;\n }\n }\n }\n }\n\n if (schema.default !== undefined) {\n irSchema.default = schema.default;\n }\n\n if (schema.exclusiveMaximum !== undefined) {\n irSchema.exclusiveMaximum = schema.exclusiveMaximum;\n }\n\n if (schema.exclusiveMinimum !== undefined) {\n irSchema.exclusiveMinimum = schema.exclusiveMinimum;\n }\n\n if (schema.format) {\n irSchema.format = schema.format;\n }\n\n if (schema.maximum !== undefined) {\n irSchema.maximum = schema.maximum;\n }\n\n if (schema.maxItems !== undefined) {\n irSchema.maxItems = schema.maxItems;\n }\n\n if (schema.maxLength !== undefined) {\n irSchema.maxLength = schema.maxLength;\n }\n\n if (schema.minimum !== undefined) {\n irSchema.minimum = schema.minimum;\n }\n\n if (schema.minItems !== undefined) {\n irSchema.minItems = schema.minItems;\n }\n\n if (schema.minLength !== undefined) {\n irSchema.minLength = schema.minLength;\n }\n\n if (schema.pattern) {\n irSchema.pattern = schema.pattern;\n }\n\n if (schema.readOnly) {\n irSchema.accessScope = 'read';\n } else if (schema.writeOnly) {\n irSchema.accessScope = 'write';\n }\n};\n\nconst parseArray = ({\n context,\n irSchema = {},\n schema,\n state,\n}: {\n context: Context;\n irSchema?: IR.SchemaObject;\n schema: SchemaObject;\n state: SchemaState;\n}): IR.SchemaObject => {\n if (\n (schema.prefixItems && schema.prefixItems.length) ||\n (schema.maxItems && schema.maxItems === schema.minItems) ||\n schema.const !== undefined\n ) {\n irSchema.type = 'tuple';\n } else {\n irSchema.type = 'array';\n }\n\n let schemaItems: Array<IR.SchemaObject> = [];\n\n for (const item of schema.prefixItems ?? []) {\n const irItemSchema = schemaToIrSchema({\n context,\n schema: item,\n state,\n });\n schemaItems.push(irItemSchema);\n }\n\n if (schema.items) {\n const irItemsSchema = schemaToIrSchema({\n context,\n schema: schema.items,\n state,\n });\n\n if (\n !schemaItems.length &&\n schema.maxItems &&\n schema.maxItems === schema.minItems\n ) {\n schemaItems = Array(schema.maxItems).fill(irItemsSchema);\n } else {\n const ofArray =\n schema.items.allOf || schema.items.anyOf || schema.items.oneOf;\n if (\n ofArray &&\n ofArray.length > 1 &&\n !getSchemaTypes({ schema: schema.items }).includes('null')\n ) {\n // bring composition up to avoid incorrectly nested arrays\n irSchema = {\n ...irSchema,\n ...irItemsSchema,\n };\n } else {\n schemaItems.push(irItemsSchema);\n }\n }\n }\n\n irSchema = addItemsToSchema({\n items: schemaItems,\n schema: irSchema,\n });\n\n return irSchema;\n};\n\nconst parseBoolean = ({\n irSchema = {},\n}: {\n context: Context;\n irSchema?: IR.SchemaObject;\n schema: SchemaObject;\n}): IR.SchemaObject => {\n irSchema.type = 'boolean';\n\n return irSchema;\n};\n\nconst parseNull = ({\n irSchema = {},\n}: {\n context: Context;\n irSchema?: IR.SchemaObject;\n schema: SchemaObject;\n}) => {\n irSchema.type = 'null';\n\n return irSchema;\n};\n\nconst parseNumber = ({\n irSchema = {},\n schema,\n}: {\n context: Context;\n irSchema?: IR.SchemaObject;\n schema: Omit<SchemaObject, 'type'> & {\n type: SchemaType<SchemaObject>;\n };\n}): IR.SchemaObject => {\n irSchema.type = schema.type;\n\n return irSchema;\n};\n\nconst parseObject = ({\n context,\n irSchema = {},\n schema,\n state,\n}: {\n context: Context;\n irSchema?: IR.SchemaObject;\n schema: SchemaObject;\n state: SchemaState;\n}): IR.SchemaObject => {\n irSchema.type = 'object';\n\n const schemaProperties: Record<string, IR.SchemaObject> = {};\n\n for (const name in schema.properties) {\n const property = schema.properties[name]!;\n if (typeof property === 'boolean') {\n // TODO: parser - handle boolean properties\n } else {\n const irPropertySchema = schemaToIrSchema({\n context,\n schema: property,\n state,\n });\n schemaProperties[name] = irPropertySchema;\n }\n }\n\n if (Object.keys(schemaProperties).length) {\n irSchema.properties = schemaProperties;\n }\n\n if (schema.additionalProperties === undefined) {\n if (!irSchema.properties) {\n irSchema.additionalProperties = {\n type: 'unknown',\n };\n }\n } else if (typeof schema.additionalProperties === 'boolean') {\n // Avoid [key: string]: never for empty objects with additionalProperties: false inside allOf\n // This would override inherited properties from other schemas in the composition\n const isEmptyObjectInAllOf =\n state.inAllOf &&\n schema.additionalProperties === false &&\n (!schema.properties || !Object.keys(schema.properties).length) &&\n (!schema.patternProperties ||\n !Object.keys(schema.patternProperties).length);\n\n if (!isEmptyObjectInAllOf) {\n irSchema.additionalProperties = {\n type: schema.additionalProperties ? 'unknown' : 'never',\n };\n }\n } else {\n const irAdditionalPropertiesSchema = schemaToIrSchema({\n context,\n schema: schema.additionalProperties,\n state,\n });\n irSchema.additionalProperties = irAdditionalPropertiesSchema;\n }\n\n if (schema.patternProperties) {\n const patternProperties: Record<string, IR.SchemaObject> = {};\n\n for (const pattern in schema.patternProperties) {\n const patternSchema = schema.patternProperties[pattern]!;\n const irPatternSchema = schemaToIrSchema({\n context,\n schema: patternSchema,\n state,\n });\n patternProperties[pattern] = irPatternSchema;\n }\n\n if (Object.keys(patternProperties).length) {\n irSchema.patternProperties = patternProperties;\n }\n }\n\n if (schema.propertyNames) {\n irSchema.propertyNames = schemaToIrSchema({\n context,\n schema: schema.propertyNames,\n state,\n });\n }\n\n if (schema.required) {\n irSchema.required = schema.required;\n }\n\n return irSchema;\n};\n\nconst parseString = ({\n irSchema = {},\n}: {\n context: Context;\n irSchema?: IR.SchemaObject;\n schema: SchemaObject;\n}): IR.SchemaObject => {\n irSchema.type = 'string';\n\n return irSchema;\n};\n\nconst initIrSchema = ({\n schema,\n}: {\n schema: SchemaObject;\n}): IR.SchemaObject => {\n const irSchema: IR.SchemaObject = {};\n\n parseSchemaJsDoc({\n irSchema,\n schema,\n });\n\n return irSchema;\n};\n\nconst parseAllOf = ({\n context,\n schema,\n state,\n}: {\n context: Context;\n schema: SchemaWithRequired<SchemaObject, 'allOf'>;\n state: SchemaState;\n}): IR.SchemaObject => {\n let irSchema = initIrSchema({ schema });\n parseSchemaMeta({ irSchema, schema });\n\n const schemaItems: Array<IR.SchemaObject> = [];\n const schemaTypes = getSchemaTypes({ schema });\n\n const compositionSchemas = schema.allOf;\n\n for (const compositionSchema of compositionSchemas) {\n const originalInAllOf = state.inAllOf;\n // Don't propagate inAllOf flag to $ref schemas to avoid issues with reusable components\n if (!('$ref' in compositionSchema)) {\n state.inAllOf = true;\n }\n const irCompositionSchema = schemaToIrSchema({\n context,\n schema: compositionSchema,\n state,\n });\n state.inAllOf = originalInAllOf;\n if (state.inAllOf === undefined) {\n delete state.inAllOf;\n }\n\n if (schema.required) {\n if (irCompositionSchema.required) {\n irCompositionSchema.required = [\n ...irCompositionSchema.required,\n ...schema.required,\n ];\n } else {\n irCompositionSchema.required = schema.required;\n }\n }\n\n schemaItems.push(irCompositionSchema);\n\n if (compositionSchema.$ref) {\n const ref = context.resolveRef<SchemaObject>(compositionSchema.$ref);\n // `$ref` should be passed from the root `parseSchema()` call\n if (ref.discriminator && state.$ref) {\n const values = discriminatorValues(\n state.$ref,\n ref.discriminator.mapping,\n // If the ref has oneOf, we only use the schema name as the value\n // only if current schema is part of the oneOf. Else it is extending\n // the ref schema\n ref.oneOf\n ? () => ref.oneOf!.some((o) => '$ref' in o && o.$ref === state.$ref)\n : undefined,\n );\n if (values.length > 0) {\n const valueSchemas: ReadonlyArray<IR.SchemaObject> = values.map(\n (value) => ({\n const: value,\n type: 'string',\n }),\n );\n const irDiscriminatorSchema: IR.SchemaObject = {\n properties: {\n [ref.discriminator.propertyName]:\n valueSchemas.length > 1\n ? {\n items: valueSchemas,\n logicalOperator: 'or',\n }\n : valueSchemas[0]!,\n },\n type: 'object',\n };\n if (ref.required?.includes(ref.discriminator.propertyName)) {\n irDiscriminatorSchema.required = [ref.discriminator.propertyName];\n }\n schemaItems.push(irDiscriminatorSchema);\n }\n }\n }\n }\n\n if (schemaTypes.includes('object')) {\n const irObjectSchema = parseOneType({\n context,\n schema: {\n ...schema,\n type: 'object',\n },\n state,\n });\n\n if (irObjectSchema.properties) {\n for (const requiredProperty of irObjectSchema.required ?? []) {\n if (!irObjectSchema.properties[requiredProperty]) {\n for (const compositionSchema of compositionSchemas) {\n // TODO: parser - this could be probably resolved more accurately\n const finalCompositionSchema = compositionSchema.$ref\n ? context.resolveRef<SchemaObject>(compositionSchema.$ref)\n : compositionSchema;\n\n if (\n getSchemaTypes({ schema: finalCompositionSchema }).includes(\n 'object',\n )\n ) {\n const irCompositionSchema = parseOneType({\n context,\n schema: {\n ...finalCompositionSchema,\n type: 'object',\n },\n state,\n });\n\n if (irCompositionSchema.properties?.[requiredProperty]) {\n irObjectSchema.properties[requiredProperty] =\n irCompositionSchema.properties[requiredProperty];\n break;\n }\n }\n }\n }\n }\n schemaItems.push(irObjectSchema);\n }\n }\n\n irSchema = addItemsToSchema({\n items: schemaItems,\n logicalOperator: 'and',\n mutateSchemaOneItem: true,\n schema: irSchema,\n });\n\n if (schemaTypes.includes('null')) {\n // nest composition to avoid producing an intersection with null\n const nestedItems: Array<IR.SchemaObject> = [\n {\n type: 'null',\n },\n ];\n\n if (schemaItems.length) {\n nestedItems.unshift(irSchema);\n }\n\n irSchema = {\n items: nestedItems,\n logicalOperator: 'or',\n };\n }\n\n return irSchema;\n};\n\nconst parseAnyOf = ({\n context,\n schema,\n state,\n}: {\n context: Context;\n schema: SchemaWithRequired<SchemaObject, 'anyOf'>;\n state: SchemaState;\n}): IR.SchemaObject => {\n let irSchema = initIrSchema({ schema });\n parseSchemaMeta({ irSchema, schema });\n\n const schemaItems: Array<IR.SchemaObject> = [];\n const schemaTypes = getSchemaTypes({ schema });\n\n const compositionSchemas = schema.anyOf;\n\n for (const compositionSchema of compositionSchemas) {\n let irCompositionSchema = schemaToIrSchema({\n context,\n schema: compositionSchema,\n state,\n });\n\n // `$ref` should be defined with discriminators\n if (schema.discriminator && irCompositionSchema.$ref != null) {\n const values = discriminatorValues(\n irCompositionSchema.$ref,\n schema.discriminator.mapping,\n );\n const valueSchemas: ReadonlyArray<IR.SchemaObject> = values.map(\n (value) => ({\n const: value,\n type: 'string',\n }),\n );\n const irDiscriminatorSchema: IR.SchemaObject = {\n properties: {\n [schema.discriminator.propertyName]:\n valueSchemas.length > 1\n ? {\n items: valueSchemas,\n logicalOperator: 'or',\n }\n : valueSchemas[0]!,\n },\n type: 'object',\n };\n irCompositionSchema = {\n items: [irDiscriminatorSchema, irCompositionSchema],\n logicalOperator: 'and',\n };\n }\n\n schemaItems.push(irCompositionSchema);\n }\n\n if (schemaTypes.includes('null')) {\n schemaItems.push({ type: 'null' });\n }\n\n irSchema = addItemsToSchema({\n items: schemaItems,\n mutateSchemaOneItem: true,\n schema: irSchema,\n });\n\n if (schemaTypes.includes('object')) {\n // nest composition to avoid producing a union with object properties\n const irObjectSchema = parseOneType({\n context,\n schema: {\n ...schema,\n type: 'object',\n },\n state,\n });\n\n if (irObjectSchema.properties) {\n irSchema = {\n items: [irSchema, irObjectSchema],\n logicalOperator: 'and',\n };\n }\n }\n\n return irSchema;\n};\n\nconst parseEnum = ({\n context,\n schema,\n state,\n}: {\n context: Context;\n schema: SchemaWithRequired<SchemaObject, 'enum'>;\n state: SchemaState;\n}): IR.SchemaObject => {\n let irSchema = initIrSchema({ schema });\n\n irSchema.type = 'enum';\n\n const schemaItems: Array<IR.SchemaObject> = [];\n const schemaTypes = getSchemaTypes({ schema });\n\n for (const [index, enumValue] of schema.enum.entries()) {\n const typeOfEnumValue = typeof enumValue;\n let enumType: SchemaType<SchemaObject> | undefined;\n\n if (\n typeOfEnumValue === 'string' ||\n typeOfEnumValue === 'number' ||\n typeOfEnumValue === 'boolean'\n ) {\n enumType = typeOfEnumValue;\n } else if (typeOfEnumValue === 'object' && Array.isArray(enumValue)) {\n enumType = 'array';\n } else if (enumValue === null) {\n // type must contain null\n if (schemaTypes.includes('null')) {\n enumType = 'null';\n }\n } else {\n console.warn(\n '🚨',\n `unhandled \"${typeOfEnumValue}\" typeof value \"${enumValue}\" for enum`,\n schema.enum,\n );\n }\n\n if (!enumType) {\n continue;\n }\n\n const irTypeSchema = parseOneType({\n context,\n schema: {\n const: enumValue,\n description: schema['x-enum-descriptions']?.[index],\n title:\n schema['x-enum-varnames']?.[index] ?? schema['x-enumNames']?.[index],\n type: enumType,\n },\n state,\n });\n\n schemaItems.push(irTypeSchema);\n }\n\n irSchema = addItemsToSchema({\n items: schemaItems,\n schema: irSchema,\n });\n\n return irSchema;\n};\n\nconst parseOneOf = ({\n context,\n schema,\n state,\n}: {\n context: Context;\n schema: SchemaWithRequired<SchemaObject, 'oneOf'>;\n state: SchemaState;\n}): IR.SchemaObject => {\n let irSchema = initIrSchema({ schema });\n parseSchemaMeta({ irSchema, schema });\n\n let schemaItems: Array<IR.SchemaObject> = [];\n const schemaTypes = getSchemaTypes({ schema });\n\n const compositionSchemas = schema.oneOf;\n\n for (const compositionSchema of compositionSchemas) {\n let irCompositionSchema = schemaToIrSchema({\n context,\n schema: compositionSchema,\n state,\n });\n\n // `$ref` should be defined with discriminators\n if (schema.discriminator && irCompositionSchema.$ref != null) {\n const values = discriminatorValues(\n irCompositionSchema.$ref,\n schema.discriminator.mapping,\n );\n const valueSchemas: ReadonlyArray<IR.SchemaObject> = values.map(\n (value) => ({\n const: value,\n type: 'string',\n }),\n );\n const irDiscriminatorSchema: IR.SchemaObject = {\n properties: {\n [schema.discriminator.propertyName]:\n valueSchemas.length > 1\n ? {\n items: valueSchemas,\n logicalOperator: 'or',\n }\n : valueSchemas[0]!,\n },\n required: [schema.discriminator.propertyName],\n type: 'object',\n };\n irCompositionSchema = {\n items: [irDiscriminatorSchema, irCompositionSchema],\n logicalOperator: 'and',\n };\n }\n\n // since we know oneOf will be using \"or\" logical operator, if the parsed\n // composition schema also has an \"or\" operator, we can bring it up\n // to avoid unnecessary brackets\n if (\n irCompositionSchema.logicalOperator === 'or' &&\n irCompositionSchema.type !== 'array' &&\n irCompositionSchema.items\n ) {\n schemaItems = schemaItems.concat(irCompositionSchema.items);\n } else {\n schemaItems.push(irCompositionSchema);\n }\n }\n\n if (schemaTypes.includes('null')) {\n schemaItems.push({ type: 'null' });\n }\n\n irSchema = addItemsToSchema({\n items: schemaItems,\n mutateSchemaOneItem: true,\n schema: irSchema,\n });\n\n if (schemaTypes.includes('object')) {\n // nest composition to avoid producing a union with object properties\n const irObjectSchema = parseOneType({\n context,\n schema: {\n ...schema,\n type: 'object',\n },\n state,\n });\n\n if (irObjectSchema.properties) {\n irSchema = {\n items: [irSchema, irObjectSchema],\n logicalOperator: 'and',\n };\n }\n }\n\n return irSchema;\n};\n\nconst parseRef = ({\n context,\n schema,\n state,\n}: {\n context: Context;\n schema: SchemaWithRequired<SchemaObject, '$ref'>;\n state: SchemaState;\n}): IR.SchemaObject => {\n // Inline non-component refs (e.g. #/paths/...) to avoid generating orphaned named types\n const isComponentsRef = schema.$ref.startsWith('#/components/');\n if (!isComponentsRef) {\n if (!state.circularReferenceTracker.has(schema.$ref)) {\n const refSchema = context.resolveRef<SchemaObject>(schema.$ref);\n const originalRef = state.$ref;\n state.$ref = schema.$ref;\n const irSchema = schemaToIrSchema({\n context,\n schema: refSchema,\n state,\n });\n state.$ref = originalRef;\n return irSchema;\n }\n // Fallback to preserving the ref if circular\n }\n\n let irSchema = initIrSchema({ schema });\n parseSchemaMeta({ irSchema, schema });\n\n const irRefSchema: IR.SchemaObject = {};\n\n // refs using unicode characters become encoded, didn't investigate why\n // but the suspicion is this comes from `@hey-api/json-schema-ref-parser`\n irRefSchema.$ref = decodeURI(schema.$ref);\n\n if (!state.circularReferenceTracker.has(schema.$ref)) {\n const refSchema = context.resolveRef<SchemaObject>(schema.$ref);\n const originalRef = state.$ref;\n state.$ref = schema.$ref;\n schemaToIrSchema({\n context,\n schema: refSchema,\n state,\n });\n state.$ref = originalRef;\n }\n\n const schemaItems: Array<IR.SchemaObject> = [];\n schemaItems.push(irRefSchema);\n\n if (schema.type && typeof schema.type !== 'string') {\n if (schema.type.includes('null')) {\n schemaItems.push({ type: 'null' });\n }\n }\n\n irSchema = addItemsToSchema({\n items: schemaItems,\n mutateSchemaOneItem: true,\n schema: irSchema,\n });\n\n return irSchema;\n};\n\nconst parseOneType = ({\n context,\n irSchema,\n schema,\n state,\n}: {\n context: Context;\n irSchema?: IR.SchemaObject;\n schema: Omit<SchemaObject, 'type'> & {\n type: SchemaType<SchemaObject>;\n };\n state: SchemaState;\n}): IR.SchemaObject => {\n if (!irSchema) {\n irSchema = initIrSchema({ schema });\n parseSchemaMeta({ irSchema, schema });\n }\n\n switch (schema.type) {\n case 'array':\n return parseArray({\n context,\n irSchema,\n schema,\n state,\n });\n case 'boolean':\n return parseBoolean({\n context,\n irSchema,\n schema,\n });\n case 'integer':\n case 'number':\n return parseNumber({\n context,\n irSchema,\n schema,\n });\n case 'null':\n return parseNull({\n context,\n irSchema,\n schema,\n });\n case 'object':\n return parseObject({\n context,\n irSchema,\n schema,\n state,\n });\n case 'string':\n return parseString({\n context,\n irSchema,\n schema,\n });\n default:\n // gracefully handle invalid type\n return parseUnknown({ context, irSchema, schema });\n }\n};\n\nconst parseManyTypes = ({\n context,\n irSchema,\n schema,\n state,\n}: {\n context: Context;\n irSchema?: IR.SchemaObject;\n schema: Omit<SchemaObject, 'type'> & {\n type: ReadonlyArray<SchemaType<SchemaObject>>;\n };\n state: SchemaState;\n}): IR.SchemaObject => {\n if (!irSchema) {\n irSchema = initIrSchema({ schema });\n }\n\n const typeIrSchema: IR.SchemaObject = {};\n\n parseSchemaMeta({ irSchema: typeIrSchema, schema });\n\n if (schema.type.includes('null') && typeIrSchema.default === null) {\n // clear to avoid duplicate default inside the non-null schema.\n // this would produce incorrect validator output\n delete typeIrSchema.default;\n }\n\n const schemaItems: Array<IR.SchemaObject> = [];\n\n for (const type of schema.type) {\n if (type === 'null') {\n schemaItems.push({ type: 'null' });\n } else {\n const irTypeSchema = parseOneType({\n context,\n irSchema: { ...typeIrSchema },\n schema: {\n ...schema,\n type,\n },\n state,\n });\n\n schemaItems.push(irTypeSchema);\n }\n }\n\n irSchema = addItemsToSchema({\n items: schemaItems,\n schema: irSchema,\n });\n\n return irSchema;\n};\n\nconst parseType = ({\n context,\n schema,\n state,\n}: {\n context: Context;\n schema: SchemaWithRequired<SchemaObject, 'type'>;\n state: SchemaState;\n}): IR.SchemaObject => {\n const irSchema = initIrSchema({ schema });\n\n parseSchemaMeta({ irSchema, schema });\n\n const schemaTypes = getSchemaTypes({ schema });\n\n if (schemaTypes.length === 1) {\n return parseOneType({\n context,\n irSchema,\n schema: {\n ...schema,\n type: schemaTypes[0]!,\n },\n state,\n });\n }\n\n return parseManyTypes({\n context,\n irSchema,\n schema: {\n ...schema,\n type: schemaTypes,\n },\n state,\n });\n};\n\nconst parseUnknown = ({\n irSchema,\n schema,\n}: {\n context: Context;\n irSchema?: IR.SchemaObject;\n schema: SchemaObject;\n}): IR.SchemaObject => {\n if (!irSchema) {\n irSchema = initIrSchema({ schema });\n }\n\n irSchema.type = 'unknown';\n\n parseSchemaMeta({ irSchema, schema });\n\n return irSchema;\n};\n\nexport const schemaToIrSchema = ({\n context,\n schema,\n state,\n}: {\n context: Context;\n schema: SchemaObject;\n state: SchemaState | undefined;\n}): IR.SchemaObject => {\n if (!state) {\n state = {\n circularReferenceTracker: new Set(),\n };\n }\n\n if (state.$ref) {\n state.circularReferenceTracker.add(state.$ref);\n }\n\n if (schema.$ref) {\n return parseRef({\n context,\n schema: schema as SchemaWithRequired<SchemaObject, '$ref'>,\n state,\n });\n }\n\n if (schema.enum) {\n return parseEnum({\n context,\n schema: schema as SchemaWithRequired<SchemaObject, 'enum'>,\n state,\n });\n }\n\n if (schema.allOf) {\n return parseAllOf({\n context,\n schema: schema as SchemaWithRequired<SchemaObject, 'allOf'>,\n state,\n });\n }\n\n if (schema.anyOf) {\n return parseAnyOf({\n context,\n schema: schema as SchemaWithRequired<SchemaObject, 'anyOf'>,\n state,\n });\n }\n\n if (schema.oneOf) {\n return parseOneOf({\n context,\n schema: schema as SchemaWithRequired<SchemaObject, 'oneOf'>,\n state,\n });\n }\n\n // infer object based on the presence of properties\n if (schema.type || schema.properties) {\n return parseType({\n context,\n schema: schema as SchemaWithRequired<SchemaObject, 'type'>,\n state,\n });\n }\n\n return parseUnknown({ context, schema });\n};\n\nexport const parseSchema = ({\n $ref,\n context,\n schema,\n}: {\n $ref: string;\n context: Context;\n schema: SchemaObject;\n}) => {\n if (!context.ir.components) {\n context.ir.components = {};\n }\n\n if (!context.ir.components.schemas) {\n context.ir.components.schemas = {};\n }\n\n context.ir.components.schemas[refToName($ref)] = schemaToIrSchema({\n context,\n schema,\n state: {\n $ref,\n circularReferenceTracker: new Set(),\n },\n });\n};\n","import type { Context } from '~/ir/context';\nimport { getPaginationKeywordsRegExp } from '~/ir/pagination';\nimport type { SchemaType } from '~/openApi/shared/types/schema';\n\nimport type { ParameterObject, RequestBodyObject } from '../types/spec';\nimport type { SchemaObject } from '../types/spec';\nimport { mediaTypeObjects } from './mediaType';\nimport { getSchemaTypes } from './schema';\n\nconst isPaginationType = (\n schemaTypes: ReadonlyArray<SchemaType<SchemaObject>>,\n): boolean =>\n schemaTypes.includes('boolean') ||\n schemaTypes.includes('integer') ||\n schemaTypes.includes('number') ||\n schemaTypes.includes('string');\n\n// We handle only simple values for now, up to 1 nested field\nexport const paginationField = ({\n context,\n name,\n schema,\n}: {\n context: Context;\n name: string;\n schema: SchemaObject;\n}): boolean | string => {\n const paginationRegExp = getPaginationKeywordsRegExp(\n context.config.parser.pagination,\n );\n if (paginationRegExp.test(name)) {\n return true;\n }\n\n if (schema.$ref) {\n const ref = context.resolveRef<\n ParameterObject | RequestBodyObject | SchemaObject\n >(schema.$ref);\n\n if ('content' in ref || 'in' in ref) {\n let refSchema: SchemaObject | undefined;\n\n if ('in' in ref) {\n refSchema = ref.schema;\n }\n\n if (!refSchema) {\n // parameter or body\n const contents = mediaTypeObjects({ content: ref.content });\n // TODO: add support for multiple content types, for now prefer JSON\n const content =\n contents.find((content) => content.type === 'json') || contents[0];\n if (content?.schema) {\n refSchema = content.schema;\n }\n }\n\n if (!refSchema) {\n return false;\n }\n\n return paginationField({\n context,\n name,\n schema: refSchema,\n });\n }\n\n return paginationField({\n context,\n name,\n schema: ref,\n });\n }\n\n for (const name in schema.properties) {\n const paginationRegExp = getPaginationKeywordsRegExp(\n context.config.parser.pagination,\n );\n\n if (paginationRegExp.test(name)) {\n const property = schema.properties[name]!;\n\n if (typeof property !== 'boolean') {\n // TODO: resolve deeper references\n const schemaTypes = getSchemaTypes({ schema: property });\n\n if (!schemaTypes.length) {\n const compositionSchemas = property.anyOf ?? property.oneOf;\n const nonNullCompositionSchemas = (compositionSchemas ?? []).filter(\n (schema) => schema.type !== 'null',\n );\n if (nonNullCompositionSchemas.length === 1) {\n const schemaTypes = getSchemaTypes({\n schema: nonNullCompositionSchemas[0]!,\n });\n if (isPaginationType(schemaTypes)) {\n return name;\n }\n }\n }\n\n if (isPaginationType(schemaTypes)) {\n return name;\n }\n }\n }\n }\n\n for (const allOf of schema.allOf ?? []) {\n const pagination = paginationField({\n context,\n name,\n schema: allOf,\n });\n if (pagination) {\n return pagination;\n }\n }\n\n return false;\n};\n","import type { Context } from '~/ir/context';\nimport type { IR } from '~/ir/types';\nimport type { State } from '~/openApi/shared/types/state';\nimport type { httpMethods } from '~/openApi/shared/utils/operation';\nimport { operationToId } from '~/openApi/shared/utils/operation';\n\nimport type {\n OperationObject,\n RequestBodyObject,\n ResponseObject,\n SecuritySchemeObject,\n} from '../types/spec';\nimport { contentToSchema, mediaTypeObjects } from './mediaType';\nimport { paginationField } from './pagination';\nimport { schemaToIrSchema } from './schema';\n\ninterface Operation\n extends Omit<OperationObject, 'parameters'>,\n Pick<IR.OperationObject, 'parameters'> {}\n\nconst parseOperationJsDoc = ({\n irOperation,\n operation,\n}: {\n irOperation: IR.OperationObject;\n operation: Operation;\n}) => {\n if (operation.deprecated !== undefined) {\n irOperation.deprecated = operation.deprecated;\n }\n\n if (operation.description) {\n irOperation.description = operation.description;\n }\n\n if (operation.summary) {\n irOperation.summary = operation.summary;\n }\n\n if (operation.tags?.length) {\n irOperation.tags = operation.tags;\n }\n};\n\nconst initIrOperation = ({\n context,\n method,\n operation,\n path,\n state,\n}: Pick<IR.OperationObject, 'method' | 'path'> & {\n context: Context;\n operation: Operation;\n state: State;\n}): IR.OperationObject => {\n const irOperation: IR.OperationObject = {\n id: operationToId({\n context,\n id: operation.operationId,\n method,\n path,\n state,\n }),\n method,\n path,\n };\n\n if (operation.operationId) {\n irOperation.operationId = operation.operationId;\n }\n\n parseOperationJsDoc({\n irOperation,\n operation,\n });\n\n return irOperation;\n};\n\nconst operationToIrOperation = ({\n context,\n method,\n operation,\n path,\n securitySchemesMap,\n state,\n}: Pick<IR.OperationObject, 'method' | 'path'> & {\n context: Context;\n operation: Operation;\n securitySchemesMap: Map<string, SecuritySchemeObject>;\n state: State;\n}): IR.OperationObject => {\n const irOperation = initIrOperation({\n context,\n method,\n operation,\n path,\n state,\n });\n\n if (operation.parameters) {\n irOperation.parameters = operation.parameters;\n }\n\n if (operation.requestBody) {\n const requestBody =\n '$ref' in operation.requestBody\n ? context.resolveRef<RequestBodyObject>(operation.requestBody.$ref)\n : operation.requestBody;\n const contents = mediaTypeObjects({ content: requestBody.content });\n // TODO: add support for multiple content types, for now prefer JSON\n const content =\n contents.find((content) => content.type === 'json') || contents[0];\n\n if (content) {\n const pagination = paginationField({\n context,\n name: '',\n schema: {\n description: requestBody.description,\n ...content.schema,\n },\n });\n\n irOperation.body = {\n mediaType: content.mediaType,\n schema: schemaToIrSchema({\n context,\n schema: {\n description: requestBody.description,\n ...('$ref' in operation.requestBody\n ? operation.requestBody\n : content.schema),\n },\n state: undefined,\n }),\n };\n\n if (pagination) {\n irOperation.body.pagination = pagination;\n }\n\n if (requestBody.required) {\n irOperation.body.required = requestBody.required;\n }\n\n if (content.type) {\n irOperation.body.type = content.type;\n }\n }\n }\n\n for (const name in operation.responses) {\n if (!irOperation.responses) {\n irOperation.responses = {};\n }\n\n const response = operation.responses[name]!;\n const responseObject =\n '$ref' in response\n ? context.resolveRef<ResponseObject>(response.$ref)\n : response;\n const contents = mediaTypeObjects({ content: responseObject.content });\n // TODO: add support for multiple content types, for now prefer JSON\n const content =\n contents.find((content) => content.type === 'json') || contents[0];\n\n if (content) {\n irOperation.responses[name] = {\n mediaType: content.mediaType,\n schema: schemaToIrSchema({\n context,\n schema: {\n description: responseObject.description,\n ...contentToSchema({ content }),\n },\n state: undefined,\n }),\n };\n } else {\n irOperation.responses[name] = {\n schema: {\n description: responseObject.description,\n // TODO: parser - cover all statues with empty response bodies\n // 1xx, 204, 205, 304\n type: name === '204' ? 'void' : 'unknown',\n },\n };\n }\n }\n\n if (operation.security) {\n const securitySchemeObjects: Map<string, IR.SecurityObject> = new Map();\n\n for (const securityRequirementObject of operation.security) {\n for (const name in securityRequirementObject) {\n const securitySchemeObject = securitySchemesMap.get(name);\n\n if (!securitySchemeObject) {\n continue;\n }\n\n securitySchemeObjects.set(name, securitySchemeObject);\n }\n }\n\n if (securitySchemeObjects.size) {\n irOperation.security = Array.from(securitySchemeObjects.values());\n }\n }\n\n // TODO: parser - handle servers\n // qux: operation.servers\n\n return irOperation;\n};\n\nconst parseOperationObject = ({\n context,\n method,\n operation,\n path,\n securitySchemesMap,\n state,\n}: {\n context: Context;\n method: (typeof httpMethods)[number];\n operation: Operation;\n path: keyof IR.PathsObject;\n securitySchemesMap: Map<string, SecuritySchemeObject>;\n state: State;\n}) => {\n if (operation.servers) {\n context.ir.servers = [...(context.ir.servers ?? []), ...operation.servers];\n }\n\n const parsed = operationToIrOperation({\n context,\n method,\n operation,\n path,\n securitySchemesMap,\n state,\n });\n\n return { parsed };\n};\n\nexport const parsePathOperation = ({\n context,\n method,\n path,\n ...options\n}: {\n context: Context;\n method: (typeof httpMethods)[number];\n operation: Operation;\n path: keyof IR.PathsObject;\n securitySchemesMap: Map<string, SecuritySchemeObject>;\n state: State;\n}) => {\n if (!context.ir.paths) {\n context.ir.paths = {};\n }\n\n if (!context.ir.paths[path]) {\n context.ir.paths[path] = {};\n }\n\n const { parsed } = parseOperationObject({\n context,\n method,\n path,\n ...options,\n });\n\n context.ir.paths[path][method] = parsed;\n};\n\nexport const parseWebhookOperation = ({\n context,\n key,\n method,\n ...options\n}: {\n context: Context;\n key: string;\n method: (typeof httpMethods)[number];\n operation: Operation;\n securitySchemesMap: Map<string, SecuritySchemeObject>;\n state: State;\n}) => {\n if (!context.ir.webhooks) {\n context.ir.webhooks = {};\n }\n\n if (!context.ir.webhooks[key]) {\n context.ir.webhooks[key] = {};\n }\n\n const { parsed } = parseOperationObject({\n context,\n method,\n path: key as `/${string}`,\n ...options,\n });\n\n context.ir.webhooks[key][method] = parsed;\n};\n","import type { Context } from '~/ir/context';\nimport type { IR } from '~/ir/types';\nimport { refToName } from '~/utils/ref';\n\nimport type {\n ParameterObject,\n ReferenceObject,\n SchemaObject,\n} from '../types/spec';\nimport { mediaTypeObjects } from './mediaType';\nimport { paginationField } from './pagination';\nimport { schemaToIrSchema } from './schema';\n\n/**\n * Returns default parameter `allowReserved` based on value of `in`.\n */\nconst defaultAllowReserved = (\n _in: ParameterObject['in'],\n): boolean | undefined => {\n switch (_in) {\n // this keyword only applies to parameters with an `in` value of `query`\n case 'query':\n return false;\n default:\n return;\n }\n};\n\n/**\n * Returns default parameter `explode` based on value of `style`.\n */\nconst defaultExplode = (style: Required<ParameterObject>['style']): boolean => {\n switch (style) {\n // default value for `deepObject` is `false`, but that behavior is undefined\n // so we use `true` to make this work with the `client-fetch` package\n case 'deepObject':\n case 'form':\n return true;\n default:\n return false;\n }\n};\n\n/**\n * Returns default parameter `style` based on value of `in`.\n */\nconst defaultStyle = (\n _in: ParameterObject['in'],\n): Required<ParameterObject>['style'] => {\n switch (_in) {\n case 'header':\n case 'path':\n return 'simple';\n case 'cookie':\n case 'query':\n return 'form';\n }\n};\n\nexport const parametersArrayToObject = ({\n context,\n parameters,\n}: {\n context: Context;\n parameters?: ReadonlyArray<ParameterObject | ReferenceObject>;\n}): IR.ParametersObject | undefined => {\n if (!parameters || !Object.keys(parameters).length) {\n return;\n }\n\n const parametersObject: IR.ParametersObject = {};\n\n for (const parameterOrReference of parameters) {\n const parameter =\n '$ref' in parameterOrReference\n ? context.dereference<ParameterObject>(parameterOrReference)\n : parameterOrReference;\n\n if (!parametersObject[parameter.in]) {\n parametersObject[parameter.in] = {};\n }\n\n // lowercase keys for case insensitive access\n parametersObject[parameter.in]![parameter.name.toLocaleLowerCase()] =\n parameterToIrParameter({\n $ref: `#/todo/real/path/to/parameter/${parameter.name}`,\n context,\n parameter,\n });\n }\n\n return parametersObject;\n};\n\nconst parameterToIrParameter = ({\n $ref,\n context,\n parameter,\n}: {\n $ref: string;\n context: Context;\n parameter: ParameterObject;\n}): IR.ParameterObject => {\n // TODO: parser - fix\n let schema = parameter.schema;\n\n if (!schema) {\n const contents = mediaTypeObjects({ content: parameter.content });\n // TODO: add support for multiple content types, for now prefer JSON\n const content =\n contents.find((content) => content.type === 'json') || contents[0];\n if (content) {\n schema = content.schema;\n }\n }\n\n const finalSchema: SchemaObject = {\n deprecated: parameter.deprecated,\n description: parameter.description,\n ...schema,\n };\n\n const pagination = paginationField({\n context,\n name: parameter.name,\n schema: finalSchema,\n });\n\n const style = parameter.style || defaultStyle(parameter.in);\n const explode =\n parameter.explode !== undefined ? parameter.explode : defaultExplode(style);\n const allowReserved =\n parameter.allowReserved !== undefined\n ? parameter.allowReserved\n : defaultAllowReserved(parameter.in);\n\n const irParameter: IR.ParameterObject = {\n allowReserved,\n explode,\n location: parameter.in,\n name: parameter.name,\n schema: schemaToIrSchema({\n context,\n schema: finalSchema,\n state: {\n $ref,\n circularReferenceTracker: new Set(),\n },\n }),\n style,\n };\n\n if (parameter.deprecated) {\n irParameter.deprecated = parameter.deprecated;\n }\n\n if (parameter.description) {\n irParameter.description = parameter.description;\n }\n\n if (pagination) {\n irParameter.pagination = pagination;\n }\n\n if (parameter.required) {\n irParameter.required = parameter.required;\n }\n\n return irParameter;\n};\n\nexport const parseParameter = ({\n $ref,\n context,\n parameter,\n}: {\n $ref: string;\n context: Context;\n parameter: ParameterObject;\n}) => {\n if (!context.ir.components) {\n context.ir.components = {};\n }\n\n if (!context.ir.components.parameters) {\n context.ir.components.parameters = {};\n }\n\n context.ir.components.parameters[refToName($ref)] = parameterToIrParameter({\n $ref,\n context,\n parameter,\n });\n};\n","import type { Context } from '~/ir/context';\nimport type { IR } from '~/ir/types';\nimport { refToName } from '~/utils/ref';\n\nimport type { RequestBodyObject, SchemaObject } from '../types/spec';\nimport { mediaTypeObjects } from './mediaType';\nimport { schemaToIrSchema } from './schema';\n\nconst requestBodyToIrRequestBody = ({\n $ref,\n context,\n requestBody,\n}: {\n $ref: string;\n context: Context;\n requestBody: RequestBodyObject;\n}): IR.RequestBodyObject => {\n // TODO: parser - fix\n const contents = mediaTypeObjects({ content: requestBody.content });\n // TODO: add support for multiple content types, for now prefer JSON\n const content =\n contents.find((content) => content.type === 'json') || contents[0];\n const schema = content ? content.schema : undefined;\n\n const finalSchema: SchemaObject = {\n description: requestBody.description,\n ...schema,\n };\n\n const irRequestBody: IR.RequestBodyObject = {\n schema: schemaToIrSchema({\n context,\n schema: finalSchema,\n state: {\n $ref,\n circularReferenceTracker: new Set(),\n },\n }),\n };\n\n if (requestBody.description) {\n irRequestBody.description = requestBody.description;\n }\n\n if (requestBody.required) {\n irRequestBody.required = requestBody.required;\n }\n\n return irRequestBody;\n};\n\nexport const parseRequestBody = ({\n $ref,\n context,\n requestBody,\n}: {\n $ref: string;\n context: Context;\n requestBody: RequestBodyObject;\n}) => {\n if (!context.ir.components) {\n context.ir.components = {};\n }\n\n if (!context.ir.components.requestBodies) {\n context.ir.components.requestBodies = {};\n }\n\n context.ir.components.requestBodies[refToName($ref)] =\n requestBodyToIrRequestBody({\n $ref,\n context,\n requestBody,\n });\n};\n","import type { Context } from '~/ir/context';\nimport { parseUrl } from '~/utils/url';\n\nexport const parseServers = ({ context }: { context: Context }) => {\n if (context.spec.servers) {\n context.ir.servers = context.spec.servers;\n return;\n }\n\n for (const input of context.config.input) {\n if (typeof input.path === 'string') {\n const url = parseUrl(input.path);\n context.ir.servers = [\n {\n url: `${url.protocol ? `${url.protocol}://` : ''}${url.host}${url.port ? `:${url.port}` : ''}`,\n },\n ];\n }\n }\n\n if (!context.ir.servers) {\n context.ir.servers = [\n {\n url: '/',\n },\n ];\n }\n};\n","import { createOperationKey } from '~/ir/operation';\nimport { httpMethods } from '~/openApi/shared/utils/operation';\nimport type {\n ValidatorIssue,\n ValidatorResult,\n} from '~/openApi/shared/utils/validator';\nimport type { Logger } from '~/utils/logger';\n\nimport type { OpenApiV3_1_X, PathItemObject, PathsObject } from '../types/spec';\n\nexport const validateOpenApiSpec = (\n spec: OpenApiV3_1_X,\n logger: Logger,\n): ValidatorResult => {\n const eventValidate = logger.timeEvent('validate');\n const issues: Array<ValidatorIssue> = [];\n const operationIds = new Map();\n\n if (spec.paths) {\n for (const entry of Object.entries(spec.paths)) {\n const path = entry[0] as keyof PathsObject;\n const pathItem = entry[1] as PathItemObject;\n for (const method of httpMethods) {\n const operation = pathItem[method];\n if (!operation) {\n continue;\n }\n\n const operationKey = createOperationKey({ method, path });\n\n if (operation.operationId) {\n if (!operationIds.has(operation.operationId)) {\n operationIds.set(operation.operationId, operationKey);\n } else {\n issues.push({\n code: 'duplicate_key',\n context: {\n key: 'operationId',\n value: operation.operationId,\n },\n message:\n 'Duplicate `operationId` found. Each `operationId` must be unique.',\n path: ['paths', path, method, 'operationId'],\n severity: 'error',\n });\n }\n }\n }\n }\n }\n\n if (spec.servers) {\n if (typeof spec.servers !== 'object' || !Array.isArray(spec.servers)) {\n issues.push({\n code: 'invalid_type',\n message: '`servers` must be an array.',\n path: [],\n severity: 'error',\n });\n }\n\n for (let index = 0; index < spec.servers.length; index++) {\n const server = spec.servers[index];\n if (!server || typeof server !== 'object') {\n issues.push({\n code: 'invalid_type',\n context: {\n actual: typeof server,\n expected: 'object',\n },\n message: 'Each entry in `servers` must be an object.',\n path: ['servers', index],\n severity: 'error',\n });\n } else {\n if (!server.url) {\n issues.push({\n code: 'missing_required_field',\n context: {\n field: 'url',\n },\n message: 'Missing required field `url` in server object.',\n path: ['servers', index],\n severity: 'error',\n });\n }\n }\n }\n }\n\n eventValidate.timeEnd();\n return {\n issues,\n valid: !issues.some((issue) => issue.severity === 'error'),\n };\n};\n","import type { Context } from '~/ir/context';\nimport { mergeParametersObjects } from '~/openApi/shared/utils/parameter';\n\nimport type { OpenApiV3_1_X, PathItemObject } from '../types/spec';\nimport { parseWebhookOperation } from './operation';\nimport { parametersArrayToObject } from './parameter';\n\nexport const parseWebhooks = ({\n context,\n securitySchemesMap,\n}: Pick<Parameters<typeof parseWebhookOperation>[0], 'securitySchemesMap'> & {\n context: Context<OpenApiV3_1_X>;\n}) => {\n const state: Parameters<typeof parseWebhookOperation>[0]['state'] = {\n ids: new Map(),\n };\n\n for (const key in context.spec.webhooks) {\n const webhook = context.spec.webhooks[key]!;\n\n const finalWebhook =\n '$ref' in webhook\n ? {\n ...context.resolveRef<PathItemObject>(webhook.$ref!),\n ...webhook,\n }\n : webhook;\n\n const operationArgs: Omit<\n Parameters<typeof parseWebhookOperation>[0],\n 'method'\n > = {\n context,\n key,\n operation: {\n description: finalWebhook.description,\n parameters: parametersArrayToObject({\n context,\n parameters: finalWebhook.parameters,\n }),\n security: context.spec.security,\n servers: finalWebhook.servers,\n summary: finalWebhook.summary,\n },\n securitySchemesMap,\n state,\n };\n\n if (finalWebhook.delete) {\n parseWebhookOperation({\n ...operationArgs,\n method: 'delete',\n operation: {\n ...operationArgs.operation,\n ...finalWebhook.delete,\n parameters: mergeParametersObjects({\n source: parametersArrayToObject({\n context,\n parameters: finalWebhook.delete.parameters,\n }),\n target: operationArgs.operation.parameters,\n }),\n },\n });\n }\n\n if (finalWebhook.get) {\n parseWebhookOperation({\n ...operationArgs,\n method: 'get',\n operation: {\n ...operationArgs.operation,\n ...finalWebhook.get,\n parameters: mergeParametersObjects({\n source: parametersArrayToObject({\n context,\n parameters: finalWebhook.get.parameters,\n }),\n target: operationArgs.operation.parameters,\n }),\n },\n });\n }\n\n if (finalWebhook.head) {\n parseWebhookOperation({\n ...operationArgs,\n method: 'head',\n operation: {\n ...operationArgs.operation,\n ...finalWebhook.head,\n parameters: mergeParametersObjects({\n source: parametersArrayToObject({\n context,\n parameters: finalWebhook.head.parameters,\n }),\n target: operationArgs.operation.parameters,\n }),\n },\n });\n }\n\n if (finalWebhook.options) {\n parseWebhookOperation({\n ...operationArgs,\n method: 'options',\n operation: {\n ...operationArgs.operation,\n ...finalWebhook.options,\n parameters: mergeParametersObjects({\n source: parametersArrayToObject({\n context,\n parameters: finalWebhook.options.parameters,\n }),\n target: operationArgs.operation.parameters,\n }),\n },\n });\n }\n\n if (finalWebhook.patch) {\n parseWebhookOperation({\n ...operationArgs,\n method: 'patch',\n operation: {\n ...operationArgs.operation,\n ...finalWebhook.patch,\n parameters: mergeParametersObjects({\n source: parametersArrayToObject({\n context,\n parameters: finalWebhook.patch.parameters,\n }),\n target: operationArgs.operation.parameters,\n }),\n },\n });\n }\n\n if (finalWebhook.post) {\n parseWebhookOperation({\n ...operationArgs,\n method: 'post',\n operation: {\n ...operationArgs.operation,\n ...finalWebhook.post,\n parameters: mergeParametersObjects({\n source: parametersArrayToObject({\n context,\n parameters: finalWebhook.post.parameters,\n }),\n target: operationArgs.operation.parameters,\n }),\n },\n });\n }\n\n if (finalWebhook.put) {\n parseWebhookOperation({\n ...operationArgs,\n method: 'put',\n operation: {\n ...operationArgs.operation,\n ...finalWebhook.put,\n parameters: mergeParametersObjects({\n source: parametersArrayToObject({\n context,\n parameters: finalWebhook.put.parameters,\n }),\n target: operationArgs.operation.parameters,\n }),\n },\n });\n }\n\n if (finalWebhook.trace) {\n parseWebhookOperation({\n ...operationArgs,\n method: 'trace',\n operation: {\n ...operationArgs.operation,\n ...finalWebhook.trace,\n parameters: mergeParametersObjects({\n source: parametersArrayToObject({\n context,\n parameters: finalWebhook.trace.parameters,\n }),\n target: operationArgs.operation.parameters,\n }),\n },\n });\n }\n }\n};\n","import type { Context } from '~/ir/context';\nimport { buildResourceMetadata } from '~/openApi/shared/graph/meta';\nimport { transformOpenApiSpec } from '~/openApi/shared/transforms';\nimport type { State } from '~/openApi/shared/types/state';\nimport {\n createFilteredDependencies,\n createFilters,\n hasFilters,\n} from '~/openApi/shared/utils/filter';\nimport { buildGraph } from '~/openApi/shared/utils/graph';\nimport { mergeParametersObjects } from '~/openApi/shared/utils/parameter';\nimport { handleValidatorResult } from '~/openApi/shared/utils/validator';\n\nimport type {\n OpenApiV3_1_X,\n ParameterObject,\n PathItemObject,\n PathsObject,\n RequestBodyObject,\n SecuritySchemeObject,\n} from '../types/spec';\nimport { filterSpec } from './filter';\nimport { parsePathOperation } from './operation';\nimport { parametersArrayToObject, parseParameter } from './parameter';\nimport { parseRequestBody } from './requestBody';\nimport { parseSchema } from './schema';\nimport { parseServers } from './server';\nimport { validateOpenApiSpec } from './validate';\nimport { parseWebhooks } from './webhook';\n\nexport const parseV3_1_X = (context: Context<OpenApiV3_1_X>) => {\n if (context.config.parser.validate_EXPERIMENTAL) {\n const result = validateOpenApiSpec(context.spec, context.logger);\n handleValidatorResult({ context, result });\n }\n\n const shouldFilterSpec = hasFilters(context.config.parser.filters);\n if (shouldFilterSpec) {\n const filters = createFilters(\n context.config.parser.filters,\n context.spec,\n context.logger,\n );\n const { graph } = buildGraph(context.spec, context.logger);\n const { resourceMetadata } = buildResourceMetadata(graph, context.logger);\n const sets = createFilteredDependencies({\n filters,\n logger: context.logger,\n resourceMetadata,\n });\n filterSpec({\n ...sets,\n logger: context.logger,\n preserveOrder: filters.preserveOrder,\n spec: context.spec,\n });\n }\n\n transformOpenApiSpec({ context });\n\n const state: State = {\n ids: new Map(),\n };\n const securitySchemesMap = new Map<string, SecuritySchemeObject>();\n\n // TODO: parser - handle more component types, old parser handles only parameters and schemas\n if (context.spec.components) {\n for (const name in context.spec.components.securitySchemes) {\n const securityOrReference =\n context.spec.components.securitySchemes[name]!;\n const securitySchemeObject =\n '$ref' in securityOrReference\n ? context.resolveRef<SecuritySchemeObject>(securityOrReference.$ref)\n : securityOrReference;\n securitySchemesMap.set(name, securitySchemeObject);\n }\n\n for (const name in context.spec.components.parameters) {\n const $ref = `#/components/parameters/${name}`;\n const parameterOrReference = context.spec.components.parameters[name]!;\n const parameter =\n '$ref' in parameterOrReference\n ? context.resolveRef<ParameterObject>(parameterOrReference.$ref)\n : parameterOrReference;\n\n parseParameter({\n $ref,\n context,\n parameter,\n });\n }\n\n for (const name in context.spec.components.requestBodies) {\n const $ref = `#/components/requestBodies/${name}`;\n const requestBodyOrReference =\n context.spec.components.requestBodies[name]!;\n const requestBody =\n '$ref' in requestBodyOrReference\n ? context.resolveRef<RequestBodyObject>(requestBodyOrReference.$ref)\n : requestBodyOrReference;\n\n parseRequestBody({\n $ref,\n context,\n requestBody,\n });\n }\n\n for (const name in context.spec.components.schemas) {\n const $ref = `#/components/schemas/${name}`;\n const schema = context.spec.components.schemas[name]!;\n\n parseSchema({\n $ref,\n context,\n schema,\n });\n }\n }\n\n parseServers({ context });\n\n for (const path in context.spec.paths) {\n const pathItem = context.spec.paths[path as keyof PathsObject]!;\n\n const finalPathItem = pathItem.$ref\n ? {\n ...context.resolveRef<PathItemObject>(pathItem.$ref),\n ...pathItem,\n }\n : pathItem;\n\n const operationArgs: Omit<\n Parameters<typeof parsePathOperation>[0],\n 'method'\n > = {\n context,\n operation: {\n description: finalPathItem.description,\n parameters: parametersArrayToObject({\n context,\n parameters: finalPathItem.parameters,\n }),\n security: context.spec.security,\n servers: finalPathItem.servers,\n summary: finalPathItem.summary,\n },\n path: path as keyof PathsObject,\n securitySchemesMap,\n state,\n };\n\n if (finalPathItem.delete) {\n parsePathOperation({\n ...operationArgs,\n method: 'delete',\n operation: {\n ...operationArgs.operation,\n ...finalPathItem.delete,\n parameters: mergeParametersObjects({\n source: parametersArrayToObject({\n context,\n parameters: finalPathItem.delete.parameters,\n }),\n target: operationArgs.operation.parameters,\n }),\n },\n });\n }\n\n if (finalPathItem.get) {\n parsePathOperation({\n ...operationArgs,\n method: 'get',\n operation: {\n ...operationArgs.operation,\n ...finalPathItem.get,\n parameters: mergeParametersObjects({\n source: parametersArrayToObject({\n context,\n parameters: finalPathItem.get.parameters,\n }),\n target: operationArgs.operation.parameters,\n }),\n },\n });\n }\n\n if (finalPathItem.head) {\n parsePathOperation({\n ...operationArgs,\n method: 'head',\n operation: {\n ...operationArgs.operation,\n ...finalPathItem.head,\n parameters: mergeParametersObjects({\n source: parametersArrayToObject({\n context,\n parameters: finalPathItem.head.parameters,\n }),\n target: operationArgs.operation.parameters,\n }),\n },\n });\n }\n\n if (finalPathItem.options) {\n parsePathOperation({\n ...operationArgs,\n method: 'options',\n operation: {\n ...operationArgs.operation,\n ...finalPathItem.options,\n parameters: mergeParametersObjects({\n source: parametersArrayToObject({\n context,\n parameters: finalPathItem.options.parameters,\n }),\n target: operationArgs.operation.parameters,\n }),\n },\n });\n }\n\n if (finalPathItem.patch) {\n parsePathOperation({\n ...operationArgs,\n method: 'patch',\n operation: {\n ...operationArgs.operation,\n ...finalPathItem.patch,\n parameters: mergeParametersObjects({\n source: parametersArrayToObject({\n context,\n parameters: finalPathItem.patch.parameters,\n }),\n target: operationArgs.operation.parameters,\n }),\n },\n });\n }\n\n if (finalPathItem.post) {\n parsePathOperation({\n ...operationArgs,\n method: 'post',\n operation: {\n ...operationArgs.operation,\n ...finalPathItem.post,\n parameters: mergeParametersObjects({\n source: parametersArrayToObject({\n context,\n parameters: finalPathItem.post.parameters,\n }),\n target: operationArgs.operation.parameters,\n }),\n },\n });\n }\n\n if (finalPathItem.put) {\n parsePathOperation({\n ...operationArgs,\n method: 'put',\n operation: {\n ...operationArgs.operation,\n ...finalPathItem.put,\n parameters: mergeParametersObjects({\n source: parametersArrayToObject({\n context,\n parameters: finalPathItem.put.parameters,\n }),\n target: operationArgs.operation.parameters,\n }),\n },\n });\n }\n\n if (finalPathItem.trace) {\n parsePathOperation({\n ...operationArgs,\n method: 'trace',\n operation: {\n ...operationArgs.operation,\n ...finalPathItem.trace,\n parameters: mergeParametersObjects({\n source: parametersArrayToObject({\n context,\n parameters: finalPathItem.trace.parameters,\n }),\n target: operationArgs.operation.parameters,\n }),\n },\n });\n }\n }\n\n parseWebhooks({ context, securitySchemesMap });\n};\n","import { satisfies } from '~/config/utils/package';\nimport { Context } from '~/ir/context';\nimport { parseV2_0_X } from '~/openApi/2.0.x';\nimport { parseV3_0_X } from '~/openApi/3.0.x';\nimport { parseV3_1_X } from '~/openApi/3.1.x';\nimport type { OpenApi } from '~/openApi/types';\nimport type { Config } from '~/types/config';\nimport type { Logger } from '~/utils/logger';\n\n/**\n * @internal\n * Parse the resolved OpenAPI specification. This will populate and return\n * `context` with intermediate representation obtained from the parsed spec.\n */\nexport const parseOpenApiSpec = ({\n config,\n dependencies,\n logger,\n spec,\n}: {\n config: Config;\n dependencies: Record<string, string>;\n logger: Logger;\n spec: unknown;\n}): Context => {\n const context = new Context({\n config,\n dependencies,\n logger,\n spec: spec as OpenApi.V2_0_X | OpenApi.V3_0_X | OpenApi.V3_1_X,\n });\n\n if ('swagger' in context.spec) {\n parseV2_0_X(context as Context<OpenApi.V2_0_X>);\n return context;\n }\n\n if (satisfies(context.spec.openapi, '>=3.0.0 <3.1.0')) {\n parseV3_0_X(context as Context<OpenApi.V3_0_X>);\n return context;\n }\n\n if (satisfies(context.spec.openapi, '>=3.1.0')) {\n parseV3_1_X(context as Context<OpenApi.V3_1_X>);\n return context;\n }\n\n throw new Error('Unsupported OpenAPI specification');\n};\n"],"mappings":"g0BAQA,MAAMA,IAAAA,EAAAA,EAAAA,eAAAA,QAAAA,MAAAA,CAAAA,cAAAA,WAAAA,CAAAA,KAA2C,CAC3CC,GAAYC,EAAAA,QAAK,QAAQF,GAAW,CAE7B,OAA6C,CACxD,IAAI,EAAMC,GACV,KAAO,IAAQC,EAAAA,QAAK,QAAQ,EAAI,EAAE,CAEhC,IAAM,EADQC,EAAAA,QAAG,YAAY,EAAI,CACR,OAAQ,GAAS,IAAS,eAAe,CAElE,GAAI,EAAW,GAAI,CACjB,IAAM,EAAkBD,EAAAA,QAAK,KAAK,EAAK,EAAW,GAAG,CACrD,OAAO,KAAK,MACVC,EAAAA,QAAG,aAAa,EAAiB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