@hey-api/openapi-ts 0.89.0 → 0.89.2

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openApi-Dz9FsU_q.mjs","names":["__filename","__dirname","path","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","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","Mixed","Mixed","impl: T | undefined","Mixed","index: number","reserved","Mixed","lines","Mixed","Mixed","Mixed","Mixed","Mixed","Mixed","Mixed","entries: Record<string, string>","Mixed","name: string | ReturnType<typeof this.$pattern>","Mixed","Mixed","Mixed","Mixed","f","Mixed","Mixed","Mixed","node","Mixed","Mixed","Mixed","Mixed","Mixed","Mixed","Mixed","Mixed","Mixed","lines","Mixed","result","missing: Array<string>","Mixed","Mixed","Mixed","Mixed","normalized: Array<string | ts.Expression>","spans: Array<ts.TemplateSpan>","Mixed","Mixed","lines","Mixed","Mixed","Mixed","Mixed","Mixed","Mixed","Mixed","flat: Array<ts.TypeNode>","Mixed","Mixed","missing: Array<string>","Mixed","Mixed","Mixed","fromValue","Mixed","Mixed","Mixed","missing: Array<string>","Mixed","missing: Array<string>","Mixed","flat: Array<ts.TypeNode>","Mixed","normalized: Array<string | ts.TypeNode>","spans: Array<ts.TemplateLiteralTypeSpan>","parentCount: number","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","result: OperationParameters","query: SymbolMeta","ref","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>","f","comments: Array<string>","createHttpRequests: AngularCommonPlugin['Handler']","methodAccess: ReturnType<typeof $.attr | typeof $.call>","createHttpResources: AngularCommonPlugin['Handler']","handler: AngularCommonPlugin['Handler']","defaultConfig: AngularCommonPlugin['Config']","defineConfig","renamed: Map<string, string> | undefined","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","f","p","m","t","node","symbolClient","f","handlerV1: HeyApiSdkPlugin['Handler']","handler: HeyApiSdkPlugin['Handler']","handlerV1","defaultConfig: HeyApiSdkPlugin['Config']","defineConfig","defaultConfig","bigIntExpressions: ExpressionTransformer","dateExpressions: ExpressionTransformer","query: SymbolMeta","mapCallbackStatements: Array<Expr>","nodes: Array<Expr>","arrayNodes: Array<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","symbol","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>","webhooks: Array<Symbol>","Api","irSchemaToAstV1","handler: HeyApiTypeScriptPlugin['Handler']","handlerV1","defaultConfig: HeyApiTypeScriptPlugin['Config']","Api","defineConfig","defaultConfig","handleMeta","useTypeData","useTypeError","useTypeResponse","useTypeData","createMutationOptions","fnOptions","statements: Array<ReturnType<typeof $.var | typeof $.return>>","f","handleMeta","useTypeResponse","useTypeError","TOptionsType","createQueryKeyFunction","createQueryKeyLiteral","tagsExpression: ReturnType<typeof $.array> | undefined","createQueryKeyType","queryKeyStatement","optionsParamName","createQueryOptions","keyExpression: ReturnType<typeof $.call>","queryKeyStatement","tagsExpr: ReturnType<typeof $.array> | undefined","statements: Array<ReturnType<typeof $.return | typeof $.const>>","handleMeta","handlerV0: PiniaColadaPlugin['Handler']","queryFn: ReturnType<typeof $.expr | typeof $.call | typeof $.attr>","handler: PiniaColadaPlugin['Handler']","defaultConfig: PiniaColadaPlugin['Config']","handler","defineConfig","defaultConfig","tagsArray: TsDsl<ts.ArrayLiteralExpression> | undefined","f","statements: Array<TsDsl<any>>","fnOptions","statements: Array<TsDsl<any>>","optionsParamName","statements: Array<TsDsl<any>>","handlerV5: PluginHandler","queryFn: ReturnType<typeof $.expr | typeof $.call | typeof $.attr>","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","ref","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: ReturnType<typeof $.expr | typeof $.call | typeof $.attr>","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","ref","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']","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","results: Array<ArrayOnly<ConfigResult>>","errors: Array<Error>","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","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","result: EventHooks","result: string","path","namespace","keys: Array<string>","regexps: Array<RegExp>","path","regexp","filters: Filters","dependencies: Set<string> | undefined","resourceMetadata: ResourceMetadata","path","namespace","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","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","parseExtensions","initIrSchema","irSchema: IR.SchemaObject","parseAllOf","ref","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","ref","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>","findDiscriminatorsInSchema","resolvedSchema: SchemaObject","getAllDiscriminatorValues","values: Array<string>","parseSchemaJsDoc","parseSchemaMeta","parseArray","schemaItems: Array<IR.SchemaObject>","schemaToIrSchema","parseBoolean","parseNumber","parseObject","schemaProperties: Record<string, IR.SchemaObject>","parseString","parseExtensions","initIrSchema","irSchema: IR.SchemaObject","parseAllOf","discriminatorsToAdd: Array<DiscriminatorInfo>","ref","valueSchemas: ReadonlyArray<IR.SchemaObject>","discriminatorProperty: IR.SchemaObject","inlineSchema: IR.SchemaObject | undefined","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","ref","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>","resolvedSchema: SchemaObject","values: Array<string>","schemaItems: Array<IR.SchemaObject>","schemaProperties: Record<string, IR.SchemaObject>","patternProperties: Record<string, IR.SchemaObject>","irSchema: IR.SchemaObject","discriminatorsToAdd: Array<DiscriminatorInfo>","ref","valueSchemas: ReadonlyArray<IR.SchemaObject>","discriminatorProperty: IR.SchemaObject","inlineSchema: IR.SchemaObject | undefined","irDiscriminatorSchema: IR.SchemaObject","nestedItems: Array<IR.SchemaObject>","enumType: SchemaType<SchemaObject> | undefined","irSchema","irRefSchema: IR.SchemaObject","typeIrSchema: IR.SchemaObject","ref","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/ts-dsl/base.ts","../src/ts-dsl/expr/id.ts","../src/ts-dsl/layout/newline.ts","../src/ts-dsl/mixins/args.ts","../src/ts-dsl/expr/prefix.ts","../src/ts-dsl/utils/factories.ts","../src/ts-dsl/mixins/as.ts","../src/ts-dsl/expr/literal.ts","../src/ts-dsl/utils/regexp.ts","../src/ts-dsl/utils/keywords.ts","../src/ts-dsl/utils/reserved.ts","../src/ts-dsl/utils/name.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/optional.ts","../src/ts-dsl/mixins/value.ts","../src/ts-dsl/token.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/decl/pattern.ts","../src/ts-dsl/mixins/pattern.ts","../src/ts-dsl/decl/param.ts","../src/ts-dsl/mixins/param.ts","../src/ts-dsl/mixins/layout.ts","../src/ts-dsl/stmt/block.ts","../src/ts-dsl/decl/init.ts","../src/ts-dsl/mixins/type-returns.ts","../src/ts-dsl/decl/method.ts","../src/ts-dsl/decl/class.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/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/try.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/utils/lazy.ts","../src/ts-dsl/render/utils.ts","../src/ts-dsl/render/typescript.ts","../src/ts-dsl/index.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/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/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/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 preferExportAll: false,\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 output.tsConfig?.options.moduleResolution ===\n ts.ModuleResolutionKind.Node16)\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 *\n * @deprecated\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","// TODO: symbol should be protected, but needs to be public to satisfy types\nimport type {\n AnalysisContext,\n AstContext,\n File,\n FromRef,\n Language,\n Node,\n Symbol,\n} from '@hey-api/codegen-core';\nimport {\n fromRef,\n isNode,\n isRef,\n isSymbol,\n nodeBrand,\n} from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nexport type MaybeArray<T> = T | ReadonlyArray<T>;\n\nexport abstract class TsDsl<T extends ts.Node = ts.Node> implements Node<T> {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n analyze(_: AnalysisContext): void {}\n exported?: boolean;\n file?: File;\n language: Language = 'typescript';\n parent?: Node;\n root?: Node;\n symbol?: Symbol;\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n toAst(_: AstContext): T {\n return undefined as unknown as T;\n }\n readonly '~brand' = nodeBrand;\n\n /** Branding property to identify the DSL class at runtime. */\n abstract readonly '~dsl': string;\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>(ctx: AstContext, value: I): NodeOfMaybe<I> {\n if (value === undefined) {\n return undefined as NodeOfMaybe<I>;\n }\n // @ts-expect-error\n if (isRef(value)) value = fromRef(value);\n if (isSymbol(value)) {\n return this.$maybeId(value.finalName) as NodeOfMaybe<I>;\n }\n if (typeof value === 'string') {\n return this.$maybeId(value) as NodeOfMaybe<I>;\n }\n if (value instanceof Array) {\n return value.map((item) => {\n if (isRef(item)) item = fromRef(item);\n return this.unwrap(item, ctx);\n }) as NodeOfMaybe<I>;\n }\n return this.unwrap(value as any, ctx) as NodeOfMaybe<I>;\n }\n\n protected $type<I>(\n ctx: AstContext,\n value: I,\n args?: ReadonlyArray<ts.TypeNode>,\n ): TypeOfMaybe<I> {\n if (value === undefined) {\n return undefined as TypeOfMaybe<I>;\n }\n // @ts-expect-error\n if (isRef(value)) value = fromRef(value);\n if (isSymbol(value)) {\n return ts.factory.createTypeReferenceNode(\n value.finalName,\n args,\n ) 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(ctx, item, args)) as TypeOfMaybe<I>;\n }\n return this.unwrap(value as any, ctx) as TypeOfMaybe<I>;\n }\n\n /** Unwraps nested nodes into raw TypeScript AST. */\n private unwrap<I>(\n value: I,\n ctx: AstContext,\n ): I extends TsDsl<infer N> ? N : I {\n return (isNode(value) ? value.toAst(ctx) : value) as I extends TsDsl<\n infer N\n >\n ? N\n : I;\n }\n}\n\ntype NodeOfMaybe<I> = undefined extends I\n ? NodeOf<NonNullable<FromRef<I>>> | undefined\n : NodeOf<FromRef<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<FromRef<I>>> | undefined\n : TypeOf<FromRef<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 type { AnalysisContext } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport { TsDsl } from '../base';\n\nconst Mixed = TsDsl<ts.Identifier>;\n\nexport class IdTsDsl extends Mixed {\n readonly '~dsl' = 'IdTsDsl';\n\n protected name: string;\n\n constructor(name: string) {\n super();\n this.name = name;\n }\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n }\n\n override toAst() {\n return ts.factory.createIdentifier(this.name);\n }\n}\n","import type { AnalysisContext, AstContext } from '@hey-api/codegen-core';\nimport type ts from 'typescript';\n\nimport { TsDsl } from '../base';\nimport { IdTsDsl } from '../expr/id';\n\nexport class NewlineTsDsl extends TsDsl<ts.Identifier> {\n readonly '~dsl' = 'NewlineTsDsl';\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n }\n\n override toAst(ctx: AstContext): ts.Identifier {\n return this.$node(ctx, new IdTsDsl('\\n'));\n }\n}\n","import type {\n AnalysisContext,\n AstContext,\n Node,\n Ref,\n Symbol,\n} from '@hey-api/codegen-core';\nimport { ref } from '@hey-api/codegen-core';\nimport type ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport type { BaseCtor, MixinCtor } from './types';\n\ntype Arg = Symbol | string | MaybeTsDsl<ts.Expression>;\n\nexport interface ArgsMethods extends Node {\n /** Renders the arguments into an array of `Expression`s. */\n $args(ctx: AstContext): ReadonlyArray<ts.Expression>;\n /** Adds a single expression argument. */\n arg(arg: Arg | undefined): this;\n /** Adds one or more expression arguments. */\n args(...args: ReadonlyArray<Arg | undefined>): this;\n}\n\n/**\n * Adds `.arg()` and `.args()` for managing expression arguments in call-like nodes.\n */\nexport function ArgsMixin<T extends ts.Node, TBase extends BaseCtor<T>>(\n Base: TBase,\n) {\n abstract class Args extends Base {\n protected _args: Array<Ref<Arg>> = [];\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n for (const arg of this._args) {\n ctx.analyze(arg);\n }\n }\n\n protected arg(arg: Arg | undefined): this {\n if (arg !== undefined) this._args.push(ref(arg));\n return this;\n }\n\n protected args(...args: ReadonlyArray<Arg | undefined>): this {\n this._args.push(\n ...args\n .filter((a): a is NonNullable<typeof a> => a !== undefined)\n .map((a) => ref(a)),\n );\n return this;\n }\n\n protected $args(ctx: AstContext): ReadonlyArray<ts.Expression> {\n return this.$node(ctx, this._args).map((arg) => this.$node(ctx, arg));\n }\n }\n\n return Args as unknown as MixinCtor<TBase, ArgsMethods>;\n}\n","import type { AnalysisContext, AstContext } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\n\nconst Mixed = TsDsl<ts.PrefixUnaryExpression>;\n\nexport class PrefixTsDsl extends Mixed {\n readonly '~dsl' = 'PrefixTsDsl';\n\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 override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n ctx.analyze(this._expr);\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 override toAst(ctx: AstContext) {\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(ctx, this._expr),\n );\n }\n}\n","import type { AsCtor } from '../expr/as';\nimport type { AttrCtor } from '../expr/attr';\nimport type { AwaitCtor } from '../expr/await';\nimport type { CallCtor } from '../expr/call';\nimport type { TypeOfExprCtor } from '../expr/typeof';\nimport type { ReturnCtor } from '../stmt/return';\nimport type { TypeExprCtor } from '../type/expr';\nimport type { TypeIdxCtor } from '../type/idx';\nimport type { TypeOperatorCtor } from '../type/operator';\nimport type { TypeQueryCtor } from '../type/query';\n\ntype Ctor = (...args: Array<any>) => any;\n\ntype Factory<T extends Ctor> = {\n (...args: Parameters<T>): ReturnType<T>;\n /** Sets the implementation of this factory. */\n set(fn: T): void;\n};\n\nfunction createFactory<T extends Ctor>(name: string): Factory<T> {\n let impl: T | undefined;\n\n const slot = ((...args: Parameters<T>) => {\n if (!impl) throw new Error(`${name} factory not registered`);\n return impl(...args);\n }) as Factory<T>;\n\n slot.set = (fn: T) => {\n impl = fn;\n };\n\n return slot;\n}\n\nexport const f = {\n /** Factory for creating `as` type assertion expressions (e.g. `value as Type`). */\n as: createFactory<AsCtor>('as'),\n\n /** Factory for creating property access expressions (e.g. `obj.foo`). */\n attr: createFactory<AttrCtor>('attr'),\n\n /** Factory for creating await expressions (e.g. `await promise`). */\n await: createFactory<AwaitCtor>('await'),\n\n /** Factory for creating function or method call expressions (e.g. `fn(arg)`). */\n call: createFactory<CallCtor>('call'),\n\n /** Factory for creating return statements. */\n return: createFactory<ReturnCtor>('return'),\n\n /** Factories for creating type nodes. */\n type: {\n /** Factory for creating basic type references or type expressions (e.g. Foo or Foo<T>). */\n expr: createFactory<TypeExprCtor>('type.expr'),\n\n /** Factory for creating indexed-access types (e.g. `Foo<T>[K]`). */\n idx: createFactory<TypeIdxCtor>('type.idx'),\n\n /** Factory for creating type operator nodes (e.g. `readonly T`, `keyof T`, `unique T`). */\n operator: createFactory<TypeOperatorCtor>('type.operator'),\n\n /** Factory for creating type query nodes (e.g. `typeof Foo`). */\n query: createFactory<TypeQueryCtor>('type.query'),\n },\n\n /** Factory for creating `typeof` expressions (e.g. `typeof value`). */\n typeofExpr: createFactory<TypeOfExprCtor>('typeofExpr'),\n};\n","import type { AnalysisContext, Node } from '@hey-api/codegen-core';\nimport type ts from 'typescript';\n\nimport { f } from '../utils/factories';\nimport type { BaseCtor, DropFirst, MixinCtor } from './types';\n\nexport interface AsMethods extends Node {\n /** Creates an `as` type assertion expression (e.g. `value as Type`). */\n as(...args: DropFirst<Parameters<typeof f.as>>): ReturnType<typeof f.as>;\n}\n\nexport function AsMixin<T extends ts.Expression, TBase extends BaseCtor<T>>(\n Base: TBase,\n) {\n abstract class As extends Base {\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n }\n\n protected as(\n ...args: DropFirst<Parameters<typeof f.as>>\n ): ReturnType<typeof f.as> {\n return f.as(this, ...args);\n }\n }\n\n return As as unknown as MixinCtor<TBase, AsMethods>;\n}\n","import type { AnalysisContext, AstContext } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport { TsDsl } from '../base';\nimport { PrefixTsDsl } from '../expr/prefix';\nimport { AsMixin } from '../mixins/as';\n\nconst Mixed = AsMixin(TsDsl<ts.LiteralTypeNode['literal']>);\n\nexport class LiteralTsDsl extends Mixed {\n readonly '~dsl' = 'LiteralTsDsl';\n\n protected value: string | number | boolean | null;\n\n constructor(value: string | number | boolean | null) {\n super();\n this.value = value;\n }\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n }\n\n override toAst(ctx: AstContext) {\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\n ? this.$node(ctx, new PrefixTsDsl(expr).neg())\n : 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","/**\n * Matches characters from the start as long as they're not allowed.\n */\nconst 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 */\nconst numberRegExp = /^-?\\d+(\\.\\d+)?$/;\n\n/**\n * Javascript identifier regexp pattern retrieved from\n * {@link} https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#identifiers\n */\nconst validTypescriptIdentifierRegExp =\n /^[$_\\p{ID_Start}][$\\u200c\\u200d\\p{ID_Continue}]*$/u;\n\nexport const regexp = {\n /**\n * Matches characters from the start as long as they're not allowed.\n */\n illegalStartCharacters: illegalStartCharactersRegExp,\n /**\n * Matches string if it contains only digits and optionally decimal point or\n * leading minus sign.\n */\n number: numberRegExp,\n /**\n * Javascript identifier regexp pattern retrieved from\n * {@link} https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#identifiers\n */\n typeScriptIdentifier: validTypescriptIdentifierRegExp,\n};\n","const browserGlobals = [\n 'document',\n 'history',\n 'location',\n 'navigator',\n 'window',\n];\n\nconst javaScriptGlobals = [\n 'console',\n 'Array',\n 'Date',\n 'Error',\n 'Function',\n 'JSON',\n 'Map',\n 'Math',\n 'Object',\n 'Promise',\n 'RegExp',\n 'Set',\n 'WeakMap',\n 'WeakSet',\n];\n\nconst javaScriptKeywords = [\n 'arguments',\n 'async',\n 'await',\n 'break',\n 'case',\n 'catch',\n 'class',\n 'const',\n 'continue',\n 'debugger',\n 'default',\n 'delete',\n 'do',\n 'else',\n 'enum',\n 'eval',\n 'export',\n 'extends',\n 'false',\n 'finally',\n 'for',\n 'from',\n 'function',\n 'if',\n 'implements',\n 'import',\n 'in',\n 'instanceof',\n 'interface',\n 'let',\n 'new',\n 'null',\n 'package',\n 'private',\n 'protected',\n 'public',\n 'return',\n 'static',\n 'super',\n 'switch',\n 'this',\n 'throw',\n 'true',\n 'try',\n 'typeof',\n 'var',\n 'void',\n 'while',\n 'with',\n 'yield',\n];\n\nconst nodeGlobals = ['global', 'process', 'Buffer'];\n\nconst typeScriptKeywords = [\n 'any',\n 'as',\n 'bigint',\n 'boolean',\n 'namespace',\n 'never',\n 'null',\n 'number',\n 'string',\n 'symbol',\n 'type',\n 'undefined',\n 'unknown',\n 'void',\n];\n\nexport const keywords = {\n browserGlobals,\n javaScriptGlobals,\n javaScriptKeywords,\n nodeGlobals,\n typeScriptKeywords,\n};\n","import { keywords } from './keywords';\n\ntype List = ReadonlyArray<string>;\n\nexport class ReservedList {\n private _array: List;\n private _set: Set<string>;\n\n constructor(values: List) {\n this._array = values;\n this._set = new Set(values);\n }\n\n get '~values'() {\n return this._set;\n }\n\n /**\n * Updates the reserved list with new values.\n *\n * @param values New reserved values or a function that receives the previous\n * reserved values and returns the new ones.\n */\n set(values: List | ((prev: List) => List)): void {\n const vals = typeof values === 'function' ? values(this._array) : values;\n this._array = vals;\n this._set = new Set(vals);\n }\n}\n\nconst runtimeReserved = new ReservedList([\n ...keywords.browserGlobals,\n ...keywords.javaScriptGlobals,\n ...keywords.javaScriptKeywords,\n ...keywords.nodeGlobals,\n ...keywords.typeScriptKeywords,\n]);\n\nconst typeReserved = new ReservedList([\n ...keywords.javaScriptKeywords,\n ...keywords.typeScriptKeywords,\n]);\n\n/**\n * Reserved names for identifiers. These names will not be used\n * for variables, functions, classes, or other identifiers in generated code.\n */\nexport const reserved = {\n /**\n * Reserved names for runtime identifiers. These names will not be used\n * for variables, functions, classes, or other runtime identifiers in\n * generated code.\n */\n runtime: runtimeReserved,\n /**\n * Reserved names for type identifiers. These names will not be used\n * for type or interface identifiers in generated code.\n */\n type: typeReserved,\n};\n","import type ts from 'typescript';\n\nimport type { TsDsl } from '../base';\nimport { IdTsDsl } from '../expr/id';\nimport { LiteralTsDsl } from '../expr/literal';\nimport { regexp } from './regexp';\nimport type { ReservedList } from './reserved';\nimport { reserved } from './reserved';\n\nexport const safeMemberName = (name: string): TsDsl<ts.PropertyName> => {\n regexp.typeScriptIdentifier.lastIndex = 0;\n if (regexp.typeScriptIdentifier.test(name)) {\n return new IdTsDsl(name);\n }\n return new LiteralTsDsl(name) as TsDsl<ts.PropertyName>;\n};\n\nexport const safePropName = (name: string): TsDsl<ts.PropertyName> => {\n regexp.number.lastIndex = 0;\n if (regexp.number.test(name)) {\n return name.startsWith('-')\n ? (new LiteralTsDsl(name) as TsDsl<ts.PropertyName>)\n : (new LiteralTsDsl(Number(name)) as TsDsl<ts.PropertyName>);\n }\n\n regexp.typeScriptIdentifier.lastIndex = 0;\n if (regexp.typeScriptIdentifier.test(name)) {\n return new IdTsDsl(name);\n }\n\n return new LiteralTsDsl(name) as TsDsl<ts.PropertyName>;\n};\n\nconst safeName = (name: string, reserved: ReservedList): string => {\n let sanitized = '';\n let index: number;\n\n const first = name[0]!;\n regexp.illegalStartCharacters.lastIndex = 0;\n if (regexp.illegalStartCharacters.test(first)) {\n sanitized += '_';\n index = 0;\n } else {\n sanitized += first;\n index = 1;\n }\n\n while (index < name.length) {\n const char = name[index]!;\n sanitized += /^[\\u200c\\u200d\\p{ID_Continue}]$/u.test(char) ? char : '_';\n index += 1;\n }\n\n if (reserved['~values'].has(sanitized)) {\n sanitized = `${sanitized}_`;\n }\n\n return sanitized || '_';\n};\n\nexport const safeRuntimeName = (name: string) =>\n safeName(name, reserved.runtime);\n\nexport const safeTypeName = (name: string) => safeName(name, reserved.type);\n","import type {\n AnalysisContext,\n AstContext,\n Ref,\n Symbol,\n} from '@hey-api/codegen-core';\nimport { isSymbol, ref } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport { ArgsMixin } from '../mixins/args';\nimport { safeRuntimeName } from '../utils/name';\n\nexport type DecoratorName = Symbol | string | MaybeTsDsl<ts.Expression>;\n\nconst Mixed = ArgsMixin(TsDsl<ts.Decorator>);\n\nexport class DecoratorTsDsl extends Mixed {\n readonly '~dsl' = 'DecoratorTsDsl';\n\n protected name: Ref<DecoratorName>;\n\n constructor(\n name: DecoratorName,\n ...args: ReadonlyArray<string | MaybeTsDsl<ts.Expression>>\n ) {\n super();\n this.name = ref(name);\n if (isSymbol(name)) {\n name.setNameSanitizer(safeRuntimeName);\n }\n this.args(...args);\n }\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n ctx.analyze(this.name);\n }\n\n override toAst(ctx: AstContext) {\n const target = this.$node(ctx, this.name);\n const args = this.$args(ctx);\n return ts.factory.createDecorator(\n args.length\n ? ts.factory.createCallExpression(target, undefined, args)\n : target,\n );\n }\n}\n","import type {\n AnalysisContext,\n AstContext,\n Node,\n Symbol,\n} from '@hey-api/codegen-core';\nimport type ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { DecoratorTsDsl } from '../decl/decorator';\nimport type { BaseCtor, MixinCtor } from './types';\n\nexport interface DecoratorMethods extends Node {\n /** Renders the decorators into an array of `ts.Decorator`s. */\n $decorators(ctx: AstContext): ReadonlyArray<ts.Decorator>;\n /** Adds a decorator (e.g. `@sealed({ in: 'root' })`). */\n decorator(\n name: Symbol | string | MaybeTsDsl<ts.Expression>,\n ...args: ReadonlyArray<string | MaybeTsDsl<ts.Expression>>\n ): this;\n}\n\nexport function DecoratorMixin<T extends ts.Node, TBase extends BaseCtor<T>>(\n Base: TBase,\n) {\n abstract class Decorator extends Base {\n protected decorators: Array<DecoratorTsDsl> = [];\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n for (const decorator of this.decorators) {\n ctx.analyze(decorator);\n }\n }\n\n protected decorator(\n name: Symbol | string | MaybeTsDsl<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 protected $decorators(ctx: AstContext): ReadonlyArray<ts.Decorator> {\n return this.$node(ctx, this.decorators);\n }\n }\n\n return Decorator as unknown as MixinCtor<TBase, DecoratorMethods>;\n}\n","import type { AnalysisContext, AstContext } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport type { MaybeArray } from '../base';\nimport { TsDsl } from '../base';\nimport { IdTsDsl } from '../expr/id';\n\ntype DocMaybeLazy<T> = ((ctx: AstContext) => T) | T;\nexport type DocFn = (d: DocTsDsl) => void;\nexport type DocLines = DocMaybeLazy<MaybeArray<string>>;\n\nexport class DocTsDsl extends TsDsl<ts.Node> {\n readonly '~dsl' = 'DocTsDsl';\n\n protected _lines: Array<DocLines> = [];\n\n constructor(lines?: DocLines, fn?: DocFn) {\n super();\n if (lines) this.add(lines);\n fn?.(this);\n }\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n }\n\n add(lines: DocLines): this {\n this._lines.push(lines);\n return this;\n }\n\n apply<T extends ts.Node>(ctx: AstContext, node: T): T {\n const lines = this._lines.reduce((lines: Array<string>, line: DocLines) => {\n if (typeof line === 'function') line = line(ctx);\n for (const l of typeof line === 'string' ? [line] : line) {\n if (l || l === '') lines.push(l);\n }\n return lines;\n }, []);\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 override toAst(ctx: AstContext): 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(ctx, new IdTsDsl(''));\n }\n}\n","import type { AnalysisContext, AstContext, Node } from '@hey-api/codegen-core';\nimport type ts from 'typescript';\n\nimport type { DocFn, DocLines } from '../layout/doc';\nimport { DocTsDsl } from '../layout/doc';\nimport type { BaseCtor, MixinCtor } from './types';\n\nexport interface DocMethods extends Node {\n $docs<T extends ts.Node>(ctx: AstContext, node: T): T;\n doc(lines?: DocLines, fn?: DocFn): this;\n}\n\nexport function DocMixin<T extends ts.Node, TBase extends BaseCtor<T>>(\n Base: TBase,\n) {\n abstract class Doc extends Base {\n private _doc?: DocTsDsl;\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n }\n\n protected doc(lines?: DocLines, fn?: DocFn): this {\n this._doc = new DocTsDsl(lines, fn);\n return this;\n }\n\n protected $docs<T extends ts.Node>(ctx: AstContext, node: T): T {\n return this._doc ? this._doc.apply(ctx, node) : node;\n }\n }\n\n return Doc as unknown as MixinCtor<TBase, DocMethods>;\n}\n","import type { AnalysisContext } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport type { BaseCtor, MixinCtor } from './types';\n\nexport type Modifiers = {\n modifiers: Array<ts.Modifier>;\n};\n\nexport interface ModifierMethods extends Modifiers {\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.\n * @returns The parent node for chaining.\n */\n _m(kind: ts.ModifierSyntaxKind, condition: boolean): this;\n}\n\nfunction ModifiersMixin<T extends ts.Node, TBase extends BaseCtor<T>>(\n Base: TBase,\n) {\n abstract class Modifiers extends Base {\n protected modifiers: Array<ts.Modifier> = [];\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n }\n\n protected _m(kind: ts.ModifierSyntaxKind, condition: boolean): this {\n if (condition) this.modifiers.push(ts.factory.createModifier(kind));\n return this;\n }\n }\n\n return Modifiers as unknown as MixinCtor<TBase, ModifierMethods>;\n}\n\nexport interface AbstractMethods extends Modifiers {\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(condition?: boolean): this;\n}\n\n/**\n * Mixin that adds an `abstract` modifier to a node.\n */\nexport function AbstractMixin<T extends ts.Node, TBase extends BaseCtor<T>>(\n Base: TBase,\n) {\n const Mixed = ModifiersMixin(Base as BaseCtor<T>);\n\n abstract class Abstract extends Mixed {\n protected abstract(condition?: boolean): this {\n const cond = arguments.length === 0 ? true : Boolean(condition);\n return this._m(ts.SyntaxKind.AbstractKeyword, cond);\n }\n }\n\n return Abstract as unknown as MixinCtor<TBase, AbstractMethods>;\n}\n\nexport interface AsyncMethods extends Modifiers {\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(condition?: boolean): this;\n}\n\n/**\n * Mixin that adds an `async` modifier to a node.\n */\nexport function AsyncMixin<T extends ts.Node, TBase extends BaseCtor<T>>(\n Base: TBase,\n) {\n const Mixed = ModifiersMixin(Base as BaseCtor<T>);\n\n abstract class Async extends Mixed {\n protected async(condition?: boolean): this {\n const cond = arguments.length === 0 ? true : Boolean(condition);\n return this._m(ts.SyntaxKind.AsyncKeyword, cond);\n }\n }\n\n return Async as unknown as MixinCtor<TBase, AsyncMethods>;\n}\n\nexport interface ConstMethods extends Modifiers {\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(condition?: boolean): this;\n}\n\n/**\n * Mixin that adds a `const` modifier to a node.\n */\nexport function ConstMixin<T extends ts.Node, TBase extends BaseCtor<T>>(\n Base: TBase,\n) {\n const Mixed = ModifiersMixin(Base as BaseCtor<T>);\n\n abstract class Const extends Mixed {\n protected const(condition?: boolean): this {\n const cond = arguments.length === 0 ? true : Boolean(condition);\n return this._m(ts.SyntaxKind.ConstKeyword, cond);\n }\n }\n\n return Const as unknown as MixinCtor<TBase, ConstMethods>;\n}\n\nexport interface DeclareMethods extends Modifiers {\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(condition?: boolean): this;\n}\n\n/**\n * Mixin that adds a `declare` modifier to a node.\n */\nexport function DeclareMixin<T extends ts.Node, TBase extends BaseCtor<T>>(\n Base: TBase,\n) {\n const Mixed = ModifiersMixin(Base as BaseCtor<T>);\n\n abstract class Declare extends Mixed {\n protected declare(condition?: boolean): this {\n const cond = arguments.length === 0 ? true : Boolean(condition);\n return this._m(ts.SyntaxKind.DeclareKeyword, cond);\n }\n }\n\n return Declare as unknown as MixinCtor<TBase, DeclareMethods>;\n}\n\nexport interface DefaultMethods extends Modifiers {\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(condition?: boolean): this;\n}\n\n/**\n * Mixin that adds a `default` modifier to a node.\n */\nexport function DefaultMixin<T extends ts.Node, TBase extends BaseCtor<T>>(\n Base: TBase,\n) {\n const Mixed = ModifiersMixin(Base as BaseCtor<T>);\n\n abstract class Default extends Mixed {\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 protected default(condition?: boolean): this {\n const cond = arguments.length === 0 ? true : Boolean(condition);\n return this._m(ts.SyntaxKind.DefaultKeyword, cond);\n }\n }\n\n return Default as unknown as MixinCtor<TBase, DefaultMethods>;\n}\n\nexport interface ExportMethods extends Modifiers {\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(condition?: boolean): this;\n}\n\n/**\n * Mixin that adds an `export` modifier to a node.\n */\nexport function ExportMixin<T extends ts.Node, TBase extends BaseCtor<T>>(\n Base: TBase,\n) {\n const Mixed = ModifiersMixin(Base as BaseCtor<T>);\n\n abstract class Export extends Mixed {\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 protected export(condition?: boolean): this {\n const cond = arguments.length === 0 ? true : Boolean(condition);\n this.exported = cond;\n // TODO: remove this side-effect once planner handles exported flag\n if (this.symbol) this.symbol.setExported(cond);\n return this._m(ts.SyntaxKind.ExportKeyword, cond);\n }\n }\n\n return Export as unknown as MixinCtor<TBase, ExportMethods>;\n}\n\nexport interface OverrideMethods extends Modifiers {\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(condition?: boolean): this;\n}\n\n/**\n * Mixin that adds an `override` modifier to a node.\n */\nexport function OverrideMixin<T extends ts.Node, TBase extends BaseCtor<T>>(\n Base: TBase,\n) {\n const Mixed = ModifiersMixin(Base as BaseCtor<T>);\n\n abstract class Override extends Mixed {\n protected override(condition?: boolean): this {\n const cond = arguments.length === 0 ? true : Boolean(condition);\n return this._m(ts.SyntaxKind.OverrideKeyword, cond);\n }\n }\n\n return Override as unknown as MixinCtor<TBase, OverrideMethods>;\n}\n\nexport interface PrivateMethods extends Modifiers {\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(condition?: boolean): this;\n}\n\n/**\n * Mixin that adds a `private` modifier to a node.\n */\nexport function PrivateMixin<T extends ts.Node, TBase extends BaseCtor<T>>(\n Base: TBase,\n) {\n const Mixed = ModifiersMixin(Base as BaseCtor<T>);\n\n abstract class Private extends Mixed {\n protected private(condition?: boolean): this {\n const cond = arguments.length === 0 ? true : Boolean(condition);\n return this._m(ts.SyntaxKind.PrivateKeyword, cond);\n }\n }\n\n return Private as unknown as MixinCtor<TBase, PrivateMethods>;\n}\n\nexport interface ProtectedMethods extends Modifiers {\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(condition?: boolean): this;\n}\n\n/**\n * Mixin that adds a `protected` modifier to a node.\n */\nexport function ProtectedMixin<T extends ts.Node, TBase extends BaseCtor<T>>(\n Base: TBase,\n) {\n const Mixed = ModifiersMixin(Base as BaseCtor<T>);\n\n abstract class Protected extends Mixed {\n protected protected(condition?: boolean): this {\n const cond = arguments.length === 0 ? true : Boolean(condition);\n return this._m(ts.SyntaxKind.ProtectedKeyword, cond);\n }\n }\n\n return Protected as unknown as MixinCtor<TBase, ProtectedMethods>;\n}\n\nexport interface PublicMethods extends Modifiers {\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(condition?: boolean): this;\n}\n\n/**\n * Mixin that adds a `public` modifier to a node.\n */\nexport function PublicMixin<T extends ts.Node, TBase extends BaseCtor<T>>(\n Base: TBase,\n) {\n const Mixed = ModifiersMixin(Base as BaseCtor<T>);\n\n abstract class Public extends Mixed {\n protected public(condition?: boolean): this {\n const cond = arguments.length === 0 ? true : Boolean(condition);\n return this._m(ts.SyntaxKind.PublicKeyword, cond);\n }\n }\n\n return Public as unknown as MixinCtor<TBase, PublicMethods>;\n}\n\nexport interface ReadonlyMethods extends Modifiers {\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(condition?: boolean): this;\n}\n\n/**\n * Mixin that adds a `readonly` modifier to a node.\n */\nexport function ReadonlyMixin<T extends ts.Node, TBase extends BaseCtor<T>>(\n Base: TBase,\n) {\n const Mixed = ModifiersMixin(Base as BaseCtor<T>);\n\n abstract class Readonly extends Mixed {\n protected readonly(condition?: boolean): this {\n const cond = arguments.length === 0 ? true : Boolean(condition);\n return this._m(ts.SyntaxKind.ReadonlyKeyword, cond);\n }\n }\n\n return Readonly as unknown as MixinCtor<TBase, ReadonlyMethods>;\n}\n\nexport interface StaticMethods extends Modifiers {\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(condition?: boolean): this;\n}\n\n/**\n * Mixin that adds a `static` modifier to a node.\n */\nexport function StaticMixin<T extends ts.Node, TBase extends BaseCtor<T>>(\n Base: TBase,\n) {\n const Mixed = ModifiersMixin(Base as BaseCtor<T>);\n\n abstract class Static extends Mixed {\n protected static(condition?: boolean): this {\n const cond = arguments.length === 0 ? true : Boolean(condition);\n return this._m(ts.SyntaxKind.StaticKeyword, cond);\n }\n }\n\n return Static as unknown as MixinCtor<TBase, StaticMethods>;\n}\n","import type {\n AnalysisContext,\n AstContext,\n Ref,\n Symbol,\n} from '@hey-api/codegen-core';\nimport { ref } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl, TypeTsDsl } from '../base';\nimport { TsDsl } from '../base';\n\nexport type TypeParamName = Symbol | string;\nexport type TypeParamExpr = Symbol | string | boolean | MaybeTsDsl<TypeTsDsl>;\n\nconst Mixed = TsDsl<ts.TypeParameterDeclaration>;\n\nexport class TypeParamTsDsl extends Mixed {\n readonly '~dsl' = 'TypeParamTsDsl';\n\n protected constraint?: Ref<TypeParamExpr>;\n protected defaultValue?: Ref<TypeParamExpr>;\n protected name?: Ref<TypeParamName>;\n\n constructor(name?: TypeParamName, fn?: (name: TypeParamTsDsl) => void) {\n super();\n if (name) this.name = ref(name);\n fn?.(this);\n }\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n ctx.analyze(this.name);\n ctx.analyze(this.constraint);\n ctx.analyze(this.defaultValue);\n }\n\n default(value: TypeParamExpr): this {\n this.defaultValue = ref(value);\n return this;\n }\n\n extends(constraint: TypeParamExpr): this {\n this.constraint = ref(constraint);\n return this;\n }\n\n override toAst(ctx: AstContext) {\n if (!this.name) throw new Error('Missing type name');\n return ts.factory.createTypeParameterDeclaration(\n undefined,\n this.$node(ctx, this.name) as ts.Identifier,\n this.$type(ctx, this.constraint),\n this.$type(ctx, this.defaultValue),\n );\n }\n}\n","import type {\n AnalysisContext,\n AstContext,\n Node,\n Symbol,\n} from '@hey-api/codegen-core';\nimport { isSymbol } from '@hey-api/codegen-core';\nimport type ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TypeParamTsDsl } from '../type/param';\nimport type { BaseCtor, MixinCtor } from './types';\n\nexport interface TypeParamsMethods extends Node {\n /** Returns the type parameters as an array of ts.TypeParameterDeclaration nodes. */\n $generics(\n ast: AstContext,\n ): ReadonlyArray<ts.TypeParameterDeclaration> | undefined;\n /** Adds a single type parameter (e.g. `T` in `Array<T>`). */\n generic(...args: ConstructorParameters<typeof TypeParamTsDsl>): this;\n /** Adds type parameters (e.g. `Map<string, T>`). */\n generics(\n ...args: ReadonlyArray<Symbol | string | MaybeTsDsl<TypeParamTsDsl>>\n ): this;\n}\n\nexport function TypeParamsMixin<T extends ts.Node, TBase extends BaseCtor<T>>(\n Base: TBase,\n) {\n abstract class TypeParams extends Base {\n protected _generics: Array<MaybeTsDsl<TypeParamTsDsl>> = [];\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n for (const g of this._generics) {\n ctx.analyze(g);\n }\n }\n\n protected generic(\n ...args: ConstructorParameters<typeof TypeParamTsDsl>\n ): this {\n const g = new TypeParamTsDsl(...args);\n this._generics.push(g);\n return this;\n }\n\n protected generics(\n ...args: ReadonlyArray<Symbol | string | MaybeTsDsl<TypeParamTsDsl>>\n ): this {\n for (let arg of args) {\n if (typeof arg === 'string' || isSymbol(arg)) {\n arg = new TypeParamTsDsl(arg);\n }\n this._generics.push(arg);\n }\n return this;\n }\n\n protected $generics(\n ctx: AstContext,\n ): ReadonlyArray<ts.TypeParameterDeclaration> | undefined {\n return this.$node(ctx, this._generics);\n }\n }\n\n return TypeParams as unknown as MixinCtor<TBase, TypeParamsMethods>;\n}\n","import type { AnalysisContext, Node } from '@hey-api/codegen-core';\nimport type ts from 'typescript';\n\nimport type { BaseCtor, MixinCtor } from './types';\n\nexport interface OptionalMethods extends Node {\n _optional?: boolean;\n /** Marks the node as optional when the condition is true. */\n optional(condition?: boolean): this;\n /** Marks the node as required when the condition is true. */\n required(condition?: boolean): this;\n}\n\nexport function OptionalMixin<T extends ts.Node, TBase extends BaseCtor<T>>(\n Base: TBase,\n) {\n abstract class Optional extends Base {\n protected _optional?: boolean;\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n }\n\n protected optional(condition?: boolean): this {\n this._optional = arguments.length === 0 ? true : Boolean(condition);\n return this;\n }\n\n protected required(condition?: boolean): this {\n this._optional = arguments.length === 0 ? false : !condition;\n return this;\n }\n }\n\n return Optional as unknown as MixinCtor<TBase, OptionalMethods>;\n}\n","import type { AnalysisContext, AstContext, Node } from '@hey-api/codegen-core';\nimport type ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport type { BaseCtor, MixinCtor } from './types';\n\nexport type ValueExpr = string | MaybeTsDsl<ts.Expression>;\n\nexport interface ValueMethods extends Node {\n $value(ctx: AstContext): ts.Expression | undefined;\n /** Sets the initializer expression (e.g. `= expr`). */\n assign(expr: ValueExpr): this;\n}\n\nexport function ValueMixin<T extends ts.Node, TBase extends BaseCtor<T>>(\n Base: TBase,\n) {\n abstract class Value extends Base {\n protected value?: ValueExpr;\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n ctx.analyze(this.value);\n }\n\n protected assign(expr: ValueExpr): this {\n this.value = expr;\n return this;\n }\n\n protected $value(ctx: AstContext): ts.Expression | undefined {\n return this.$node(ctx, this.value);\n }\n }\n\n return Value as unknown as MixinCtor<TBase, ValueMethods>;\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 readonly '~dsl' = 'TokenTsDsl';\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 override toAst(): 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 type {\n AnalysisContext,\n AstContext,\n Node,\n Ref,\n Symbol,\n} from '@hey-api/codegen-core';\nimport { ref } from '@hey-api/codegen-core';\nimport type ts from 'typescript';\n\nimport type { MaybeTsDsl, TypeTsDsl } from '../base';\nimport type { BaseCtor, MixinCtor } from './types';\n\ntype Arg = Symbol | string | MaybeTsDsl<TypeTsDsl>;\n\nexport interface TypeArgsMethods extends Node {\n /** Returns the type arguments as an array of ts.TypeNode nodes. */\n $generics(ctx: AstContext): ReadonlyArray<ts.TypeNode> | undefined;\n /** Adds a single type argument (e.g. `string` in `Foo<string>`). */\n generic(arg: Arg): this;\n /** Adds type arguments (e.g. `Map<string, number>`). */\n generics(...args: ReadonlyArray<Arg>): this;\n}\n\nexport function TypeArgsMixin<T extends ts.Node, TBase extends BaseCtor<T>>(\n Base: TBase,\n) {\n abstract class TypeArgs extends Base {\n protected _generics: Array<Ref<Arg>> = [];\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n for (const g of this._generics) {\n ctx.analyze(g);\n }\n }\n\n protected generic(arg: Arg): this {\n this._generics.push(ref(arg));\n return this;\n }\n\n protected generics(...args: ReadonlyArray<Arg>): this {\n this._generics.push(...args.map((a) => ref(a)));\n return this;\n }\n\n protected $generics(\n ctx: AstContext,\n ): ReadonlyArray<ts.TypeNode> | undefined {\n return this.$type(ctx, this._generics);\n }\n }\n\n return TypeArgs as unknown as MixinCtor<TBase, TypeArgsMethods>;\n}\n","import type { AnalysisContext, Node } from '@hey-api/codegen-core';\nimport type ts from 'typescript';\n\nimport type { MaybeTsDsl, TypeTsDsl } from '../base';\nimport { f } from '../utils/factories';\nimport type { BaseCtor, DropFirst, MixinCtor } from './types';\n\nexport interface TypeExprMethods extends Node {\n /** Creates an indexed-access type (e.g. `Foo<T>[K]`). */\n idx(\n this: Parameters<typeof f.type.idx>[0],\n ...args: DropFirst<Parameters<typeof f.type.idx>>\n ): ReturnType<typeof f.type.idx>;\n /** Shorthand: builds `keyof T`. */\n keyof(this: MaybeTsDsl<TypeTsDsl>): ReturnType<typeof f.type.operator>;\n /** Shorthand: builds `readonly T`. */\n readonly(this: MaybeTsDsl<TypeTsDsl>): ReturnType<typeof f.type.operator>;\n /** Create a TypeExpr node representing ReturnType<this>. */\n returnType(\n this: Parameters<typeof f.type.query>[0],\n ...args: DropFirst<Parameters<typeof f.type.query>>\n ): ReturnType<typeof f.type.expr>;\n /** Create a TypeOfExpr node representing typeof this. */\n typeofExpr(\n this: Parameters<typeof f.typeofExpr>[0],\n ...args: DropFirst<Parameters<typeof f.typeofExpr>>\n ): ReturnType<typeof f.typeofExpr>;\n /** Create a TypeQuery node representing typeof this. */\n typeofType(\n this: Parameters<typeof f.type.query>[0],\n ...args: DropFirst<Parameters<typeof f.type.query>>\n ): ReturnType<typeof f.type.query>;\n /** Shorthand: builds `unique T`. */\n unique(this: MaybeTsDsl<TypeTsDsl>): ReturnType<typeof f.type.operator>;\n}\n\nexport function TypeExprMixin<T extends ts.Node, TBase extends BaseCtor<T>>(\n Base: TBase,\n) {\n abstract class TypeExpr extends Base {\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n }\n\n protected idx(\n this: Parameters<typeof f.type.idx>[0],\n ...args: DropFirst<Parameters<typeof f.type.idx>>\n ): ReturnType<typeof f.type.idx> {\n return f.type.idx(this, ...args);\n }\n\n protected keyof(this: TypeTsDsl): ReturnType<typeof f.type.operator> {\n return f.type.operator().keyof(this);\n }\n\n protected readonly(this: TypeTsDsl): ReturnType<typeof f.type.operator> {\n return f.type.operator().readonly(this);\n }\n\n protected returnType(\n this: Parameters<typeof f.type.query>[0],\n ...args: DropFirst<Parameters<typeof f.type.query>>\n ): ReturnType<typeof f.type.expr> {\n return f.type.expr('ReturnType').generic(f.type.query(this, ...args));\n }\n\n protected typeofExpr(\n this: Parameters<typeof f.typeofExpr>[0],\n ...args: DropFirst<Parameters<typeof f.typeofExpr>>\n ): ReturnType<typeof f.typeofExpr> {\n return f.typeofExpr(this, ...args);\n }\n\n protected typeofType(\n this: Parameters<typeof f.type.query>[0],\n ...args: DropFirst<Parameters<typeof f.type.query>>\n ): ReturnType<typeof f.type.query> {\n return f.type.query(this, ...args);\n }\n\n protected unique(this: TypeTsDsl): ReturnType<typeof f.type.operator> {\n return f.type.operator().unique(this);\n }\n }\n\n return TypeExpr as unknown as MixinCtor<TBase, TypeExprMethods>;\n}\n","import type {\n AnalysisContext,\n AstContext,\n Ref,\n Symbol,\n} from '@hey-api/codegen-core';\nimport { isRef, ref } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport { TypeExprMixin } from '../mixins/type-expr';\n\ntype Base = Symbol | string | MaybeTsDsl<ts.EntityName>;\ntype Right = Symbol | string | ts.Identifier;\n\nconst Mixed = TypeExprMixin(TsDsl<ts.QualifiedName>);\n\nexport class TypeAttrTsDsl extends Mixed {\n readonly '~dsl' = 'TypeAttrTsDsl';\n\n protected _base?: Ref<Base>;\n protected _right!: Ref<Right>;\n\n constructor(base: Base | Ref<Base>, right: string | ts.Identifier);\n constructor(right: Right);\n constructor(base: Base | Ref<Base>, right?: Right) {\n super();\n if (right) {\n this.base(base);\n this.right(right);\n } else {\n this.base();\n this.right(base as Right);\n }\n }\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n ctx.analyze(this._base);\n ctx.analyze(this._right);\n }\n\n base(base?: Base | Ref<Base>): this {\n if (isRef(base)) {\n this._base = base;\n } else {\n this._base = base ? ref(base) : undefined;\n }\n return this;\n }\n\n right(right: Right): this {\n this._right = ref(right);\n return this;\n }\n\n override toAst(ctx: AstContext) {\n if (!this._base) {\n throw new Error('TypeAttrTsDsl: missing base for qualified name');\n }\n const left = this.$node(ctx, this._base);\n if (!ts.isEntityName(left)) {\n throw new Error('TypeAttrTsDsl: base must be an EntityName');\n }\n return ts.factory.createQualifiedName(\n left,\n this.$node(ctx, this._right) as ts.Identifier,\n );\n }\n}\n","import type {\n AnalysisContext,\n AstContext,\n Ref,\n Symbol,\n} from '@hey-api/codegen-core';\nimport { isNode, ref } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport { TsDsl } from '../base';\nimport { TypeArgsMixin } from '../mixins/type-args';\nimport { TypeExprMixin } from '../mixins/type-expr';\nimport { f } from '../utils/factories';\nimport { TypeAttrTsDsl } from './attr';\n\nexport type TypeExprName = Symbol | string;\nexport type TypeExprExpr = TypeExprName | TypeAttrTsDsl;\nexport type TypeExprFn = (t: TypeExprTsDsl) => void;\nexport type TypeExprCtor = (\n nameOrFn?: TypeExprName | TypeExprFn,\n fn?: TypeExprFn,\n) => TypeExprTsDsl;\n\nconst Mixed = TypeArgsMixin(TypeExprMixin(TsDsl<ts.TypeReferenceNode>));\n\nexport class TypeExprTsDsl extends Mixed {\n readonly '~dsl' = 'TypeExprTsDsl';\n\n protected _exprInput?: Ref<TypeExprExpr>;\n\n constructor();\n constructor(fn: TypeExprFn);\n constructor(name: TypeExprName);\n constructor(name: TypeExprName, fn?: TypeExprFn);\n constructor(name?: TypeExprName | TypeExprFn, fn?: TypeExprFn) {\n super();\n if (typeof name === 'function') {\n name(this);\n } else {\n this._exprInput = name ? ref(name) : undefined;\n fn?.(this);\n }\n }\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n ctx.analyze(this._exprInput);\n }\n\n /** Accesses a nested type (e.g. `Foo.Bar`). */\n attr(right: string | ts.Identifier | TypeAttrTsDsl): this {\n this._exprInput = isNode(right)\n ? ref(right.base(this._exprInput))\n : ref(new TypeAttrTsDsl(this._exprInput!, right));\n return this;\n }\n\n override toAst(ctx: AstContext) {\n if (!this._exprInput) throw new Error('TypeExpr must have an expression');\n return ts.factory.createTypeReferenceNode(\n this.$type(ctx, this._exprInput) as ts.EntityName,\n this.$generics(ctx),\n );\n }\n}\n\nf.type.expr.set(\n (...args) =>\n new TypeExprTsDsl(...(args as ConstructorParameters<typeof TypeExprTsDsl>)),\n);\n","import type {\n AnalysisContext,\n AstContext,\n Symbol,\n} from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport { TsDsl, TypeTsDsl } from '../base';\nimport { DecoratorMixin } from '../mixins/decorator';\nimport { DocMixin } from '../mixins/doc';\nimport {\n PrivateMixin,\n ProtectedMixin,\n PublicMixin,\n ReadonlyMixin,\n StaticMixin,\n} from '../mixins/modifiers';\nimport { OptionalMixin } from '../mixins/optional';\nimport { ValueMixin } from '../mixins/value';\nimport { TokenTsDsl } from '../token';\nimport type { TypeExprName } from '../type/expr';\nimport { TypeExprTsDsl } from '../type/expr';\n\nexport type FieldName = Symbol | string;\nexport type FieldType = TypeExprName | TypeTsDsl;\n\nconst Mixed = DecoratorMixin(\n DocMixin(\n OptionalMixin(\n PrivateMixin(\n ProtectedMixin(\n PublicMixin(\n ReadonlyMixin(\n StaticMixin(ValueMixin(TsDsl<ts.PropertyDeclaration>)),\n ),\n ),\n ),\n ),\n ),\n ),\n);\n\nexport class FieldTsDsl extends Mixed {\n readonly '~dsl' = 'FieldTsDsl';\n\n protected name: FieldName;\n protected _type?: TypeTsDsl;\n\n constructor(name: FieldName, fn?: (f: FieldTsDsl) => void) {\n super();\n this.name = name;\n fn?.(this);\n }\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n ctx.analyze(this._type);\n }\n\n /** Sets the field type. */\n type(type: FieldType): this {\n this._type = type instanceof TypeTsDsl ? type : new TypeExprTsDsl(type);\n return this;\n }\n\n override toAst(ctx: AstContext) {\n const node = ts.factory.createPropertyDeclaration(\n [...this.$decorators(ctx), ...this.modifiers],\n this.$node(ctx, this.name) as ts.PropertyName,\n this._optional ? this.$node(ctx, new TokenTsDsl().optional()) : undefined,\n this.$type(ctx, this._type),\n this.$value(ctx),\n );\n return this.$docs(ctx, node);\n }\n}\n","import type { AnalysisContext, AstContext } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport { TsDsl } from '../base';\n\nconst Mixed = TsDsl<ts.Statement>;\n\nexport class StmtTsDsl extends Mixed {\n readonly '~dsl' = 'StmtTsDsl';\n\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 override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n ctx.analyze(this._inner);\n }\n\n override toAst(ctx: AstContext) {\n const node = this.$node(ctx, this._inner);\n return ts.isStatement(node)\n ? node\n : ts.factory.createExpressionStatement(node);\n }\n}\n","import type { AnalysisContext, AstContext, Node } from '@hey-api/codegen-core';\nimport type ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { StmtTsDsl } from '../stmt/stmt';\nimport type { BaseCtor, MixinCtor } from './types';\n\nexport type DoExpr = MaybeTsDsl<ts.Expression | ts.Statement>;\n\nexport interface DoMethods extends Node {\n /** Renders the collected `.do()` calls into an array of `Statement` nodes. */\n $do(ctx: AstContext): ReadonlyArray<ts.Statement>;\n _do: Array<DoExpr>;\n /** Adds one or more expressions/statements to the body. */\n do(...items: ReadonlyArray<DoExpr>): this;\n}\n\n/**\n * Adds `.do()` for appending statements or expressions to a body.\n */\nexport function DoMixin<T extends ts.Node, TBase extends BaseCtor<T>>(\n Base: TBase,\n) {\n abstract class Do extends Base {\n protected _do: Array<DoExpr> = [];\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n ctx.pushScope();\n try {\n for (const item of this._do) {\n ctx.analyze(item);\n }\n } finally {\n ctx.popScope();\n }\n }\n\n protected do(...items: ReadonlyArray<DoExpr>): this {\n this._do.push(...items);\n return this;\n }\n\n protected $do(ctx: AstContext): ReadonlyArray<ts.Statement> {\n return this.$node(\n ctx,\n this._do.map((item) => new StmtTsDsl(item)),\n );\n }\n }\n\n return Do as unknown as MixinCtor<TBase, DoMethods>;\n}\n","import type { AnalysisContext, AstContext } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport type { MaybeArray } from '../base';\nimport { TsDsl } from '../base';\nimport { IdTsDsl } from '../expr/id';\nimport { TokenTsDsl } from '../token';\n\nconst Mixed = TsDsl<ts.BindingName>;\n\n/**\n * Builds binding patterns (e.g. `{ foo, bar }`, `[a, b, ...rest]`).\n */\nexport class PatternTsDsl extends Mixed {\n readonly '~dsl' = 'PatternTsDsl';\n\n protected pattern?:\n | { kind: 'array'; values: ReadonlyArray<string> }\n | { kind: 'object'; values: Record<string, string> };\n protected _spread?: string;\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n }\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 override toAst(ctx: AstContext) {\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(ctx);\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(ctx);\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(ctx: AstContext): ts.BindingElement | undefined {\n return this._spread\n ? ts.factory.createBindingElement(\n this.$node(ctx, new TokenTsDsl().spread()),\n undefined,\n this.$node(ctx, new IdTsDsl(this._spread)),\n )\n : undefined;\n }\n}\n","import type { AnalysisContext, AstContext, Node } from '@hey-api/codegen-core';\nimport type ts from 'typescript';\n\nimport type { MaybeArray } from '../base';\nimport { PatternTsDsl } from '../decl/pattern';\nimport type { BaseCtor, MixinCtor } from './types';\n\nexport interface PatternMethods extends Node {\n /** Renders the pattern into a `BindingName`. */\n $pattern(ctx: AstContext): ts.BindingName | undefined;\n /** Defines an array binding pattern. */\n array(...props: ReadonlyArray<string> | [ReadonlyArray<string>]): this;\n /** Defines an object binding pattern. */\n object(\n ...props: ReadonlyArray<MaybeArray<string> | Record<string, string>>\n ): this;\n /** Adds a spread element (e.g. `...args`, `...options`) to the pattern. */\n spread(name: string): this;\n}\n\n/**\n * Mixin providing `.array()`, `.object()`, and `.spread()` methods for defining destructuring patterns.\n */\nexport function PatternMixin<T extends ts.Node, TBase extends BaseCtor<T>>(\n Base: TBase,\n) {\n abstract class Pattern extends Base {\n protected pattern?: PatternTsDsl;\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n ctx.analyze(this.pattern);\n }\n\n protected array(\n ...props: ReadonlyArray<string> | [ReadonlyArray<string>]\n ): this {\n (this.pattern ??= new PatternTsDsl()).array(...props);\n return this;\n }\n\n protected 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 protected 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(ctx: AstContext): ts.BindingName | undefined {\n if (!this.pattern) return;\n return this.$node(ctx, this.pattern);\n }\n }\n\n return Pattern as unknown as MixinCtor<TBase, PatternMethods>;\n}\n","import type {\n AnalysisContext,\n AstContext,\n Ref,\n Symbol,\n} from '@hey-api/codegen-core';\nimport { fromRef, isSymbolRef, ref } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport { TsDsl, TypeTsDsl } from '../base';\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 type ParamName = Symbol | string;\nexport type ParamCtor = (\n name: ParamName | ((p: ParamTsDsl) => void),\n fn?: (p: ParamTsDsl) => void,\n) => ParamTsDsl;\n\nconst Mixed = DecoratorMixin(\n OptionalMixin(PatternMixin(ValueMixin(TsDsl<ts.ParameterDeclaration>))),\n);\n\nexport class ParamTsDsl extends Mixed {\n readonly '~dsl' = 'ParamTsDsl';\n\n protected name?: Ref<ParamName>;\n protected _type?: TypeTsDsl;\n\n constructor(\n name: ParamName | ((p: ParamTsDsl) => void),\n fn?: (p: ParamTsDsl) => void,\n ) {\n super();\n if (typeof name === 'function') {\n name(this);\n } else {\n this.name = ref(name);\n fn?.(this);\n }\n }\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n ctx.analyze(this.name);\n ctx.analyze(this._type);\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 override toAst(ctx: AstContext) {\n let name: string | ReturnType<typeof this.$pattern> = this.$pattern(ctx);\n if (!name && this.name) {\n name = isSymbolRef(this.name)\n ? fromRef(this.name).finalName\n : (fromRef(this.name) as string);\n }\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(ctx),\n undefined,\n name,\n this._optional ? this.$node(ctx, new TokenTsDsl().optional()) : undefined,\n this.$type(ctx, this._type),\n this.$value(ctx),\n );\n }\n}\n","import type { AnalysisContext, AstContext, Node } from '@hey-api/codegen-core';\nimport type ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport type { ParamCtor, ParamName } from '../decl/param';\nimport { ParamTsDsl } from '../decl/param';\nimport type { BaseCtor, MixinCtor } from './types';\n\nexport interface ParamMethods extends Node {\n /** Renders the parameters into an array of `ParameterDeclaration`s. */\n $params(ast: AstContext): ReadonlyArray<ts.ParameterDeclaration>;\n /** Adds a parameter. */\n param(...args: Parameters<ParamCtor>): this;\n /** Adds multiple parameters. */\n params(...params: ReadonlyArray<MaybeTsDsl<ts.ParameterDeclaration>>): this;\n}\n\nexport function ParamMixin<T extends ts.Node, TBase extends BaseCtor<T>>(\n Base: TBase,\n) {\n abstract class Param extends Base {\n protected _params: Array<MaybeTsDsl<ts.ParameterDeclaration>> = [];\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n for (const param of this._params) {\n ctx.analyze(param);\n }\n }\n\n protected param(\n name: ParamName | ((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 protected params(\n ...params: ReadonlyArray<MaybeTsDsl<ts.ParameterDeclaration>>\n ): this {\n this._params.push(...params);\n return this;\n }\n\n protected $params(ctx: AstContext): ReadonlyArray<ts.ParameterDeclaration> {\n return this.$node(ctx, this._params);\n }\n }\n\n return Param as unknown as MixinCtor<TBase, ParamMethods>;\n}\n","import type { AnalysisContext, Node } from '@hey-api/codegen-core';\nimport type ts from 'typescript';\n\nimport type { BaseCtor, MixinCtor } from './types';\n\nexport interface LayoutMethods extends Node {\n /** Computes whether output should be multiline based on layout setting and element count. */\n $multiline(count: number): boolean;\n /** Sets automatic line output with optional threshold (default: 3). */\n auto(threshold?: number): this;\n /** Sets single line output. */\n inline(): this;\n /** Sets multi line output. */\n pretty(): this;\n}\n\nexport function LayoutMixin<T extends ts.Node, TBase extends BaseCtor<T>>(\n Base: TBase,\n) {\n abstract class Layout extends Base {\n protected static readonly DEFAULT_THRESHOLD = 3;\n protected layout: boolean | number | undefined;\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n }\n\n protected auto(threshold: number = Layout.DEFAULT_THRESHOLD): this {\n this.layout = threshold;\n return this;\n }\n\n protected inline(): this {\n this.layout = false;\n return this;\n }\n\n protected pretty(): this {\n this.layout = true;\n return this;\n }\n\n protected $multiline(count: number): boolean {\n if (this.layout === undefined) {\n this.layout = Layout.DEFAULT_THRESHOLD;\n }\n if (count === 0) return false;\n return typeof this.layout === 'number'\n ? count >= this.layout\n : this.layout;\n }\n }\n\n return Layout as unknown as MixinCtor<TBase, LayoutMethods>;\n}\n","import type { AnalysisContext, AstContext } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport { TsDsl } from '../base';\nimport type { DoExpr } from '../mixins/do';\nimport { DoMixin } from '../mixins/do';\nimport { LayoutMixin } from '../mixins/layout';\n\nconst Mixed = DoMixin(LayoutMixin(TsDsl<ts.Block>));\n\nexport class BlockTsDsl extends Mixed {\n readonly '~dsl' = 'BlockTsDsl';\n\n constructor(...items: Array<DoExpr>) {\n super();\n this.do(...items);\n }\n\n override analyze(ctx: AnalysisContext) {\n super.analyze(ctx);\n }\n\n override toAst(ctx: AstContext) {\n const statements = this.$do(ctx);\n return ts.factory.createBlock(\n statements,\n this.$multiline(statements.length),\n );\n }\n}\n","import type { AnalysisContext, AstContext } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport { TsDsl } from '../base';\nimport { DecoratorMixin } from '../mixins/decorator';\nimport { DoMixin } from '../mixins/do';\nimport { DocMixin } from '../mixins/doc';\nimport { PrivateMixin, ProtectedMixin, PublicMixin } from '../mixins/modifiers';\nimport { ParamMixin } from '../mixins/param';\nimport { BlockTsDsl } from '../stmt/block';\n\nconst Mixed = DecoratorMixin(\n DoMixin(\n DocMixin(\n ParamMixin(\n PrivateMixin(\n ProtectedMixin(PublicMixin(TsDsl<ts.ConstructorDeclaration>)),\n ),\n ),\n ),\n ),\n);\n\nexport class InitTsDsl extends Mixed {\n readonly '~dsl' = 'InitTsDsl';\n\n constructor(fn?: (i: InitTsDsl) => void) {\n super();\n fn?.(this);\n }\n\n override analyze(ctx: AnalysisContext): void {\n ctx.pushScope();\n try {\n super.analyze(ctx);\n } finally {\n ctx.popScope();\n }\n }\n\n override toAst(ctx: AstContext) {\n const node = ts.factory.createConstructorDeclaration(\n [...this.$decorators(ctx), ...this.modifiers],\n this.$params(ctx),\n this.$node(ctx, new BlockTsDsl(...this._do).pretty()),\n );\n return this.$docs(ctx, node);\n }\n}\n","import type { AnalysisContext, AstContext, Node } from '@hey-api/codegen-core';\nimport type ts from 'typescript';\n\nimport { TypeTsDsl } from '../base';\nimport type { TypeExprName } from '../type/expr';\nimport { TypeExprTsDsl } from '../type/expr';\nimport type { BaseCtor, MixinCtor } from './types';\n\nexport interface TypeReturnsMethods extends Node {\n /** Returns the return type node. */\n $returns(ctx: AstContext): ts.TypeNode | undefined;\n /** Sets the return type. */\n returns(type: TypeExprName | TypeTsDsl): this;\n}\n\nexport function TypeReturnsMixin<T extends ts.Node, TBase extends BaseCtor<T>>(\n Base: TBase,\n) {\n abstract class TypeReturns extends Base {\n protected _returns?: TypeTsDsl;\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n ctx.analyze(this._returns);\n }\n\n protected returns(type: TypeExprName | TypeTsDsl): this {\n this._returns =\n type instanceof TypeTsDsl ? type : new TypeExprTsDsl(type);\n return this;\n }\n\n protected $returns(ctx: AstContext): ts.TypeNode | undefined {\n return this.$type(ctx, this._returns);\n }\n }\n\n return TypeReturns as unknown as MixinCtor<TBase, TypeReturnsMethods>;\n}\n","import type { AnalysisContext, AstContext } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport { TsDsl } from '../base';\nimport { DecoratorMixin } from '../mixins/decorator';\nimport { DoMixin } from '../mixins/do';\nimport { DocMixin } from '../mixins/doc';\nimport {\n AbstractMixin,\n AsyncMixin,\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 { TypeReturnsMixin } from '../mixins/type-returns';\nimport { BlockTsDsl } from '../stmt/block';\nimport { TokenTsDsl } from '../token';\n\nconst Mixed = AbstractMixin(\n AsyncMixin(\n DecoratorMixin(\n DoMixin(\n DocMixin(\n OptionalMixin(\n ParamMixin(\n PrivateMixin(\n ProtectedMixin(\n PublicMixin(\n StaticMixin(\n TypeParamsMixin(\n TypeReturnsMixin(TsDsl<ts.MethodDeclaration>),\n ),\n ),\n ),\n ),\n ),\n ),\n ),\n ),\n ),\n ),\n ),\n);\n\nexport class MethodTsDsl extends Mixed {\n readonly '~dsl' = 'MethodTsDsl';\n\n protected name: string;\n\n constructor(name: string, fn?: (m: MethodTsDsl) => void) {\n super();\n this.name = name;\n fn?.(this);\n }\n\n override analyze(ctx: AnalysisContext): void {\n ctx.pushScope();\n try {\n super.analyze(ctx);\n } finally {\n ctx.popScope();\n }\n }\n\n override toAst(ctx: AstContext) {\n const node = ts.factory.createMethodDeclaration(\n [...this.$decorators(ctx), ...this.modifiers],\n undefined,\n this.name,\n this._optional ? this.$node(ctx, new TokenTsDsl().optional()) : undefined,\n this.$generics(ctx),\n this.$params(ctx),\n this.$returns(ctx),\n this.$node(ctx, new BlockTsDsl(...this._do).pretty()),\n );\n return this.$docs(ctx, node);\n }\n}\n","import type {\n AnalysisContext,\n AstContext,\n Ref,\n Symbol,\n} from '@hey-api/codegen-core';\nimport { isSymbol, ref } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport { NewlineTsDsl } from '../layout/newline';\nimport { DecoratorMixin } from '../mixins/decorator';\nimport { DocMixin } from '../mixins/doc';\nimport { AbstractMixin, DefaultMixin, ExportMixin } from '../mixins/modifiers';\nimport { TypeParamsMixin } from '../mixins/type-params';\nimport { safeRuntimeName } from '../utils/name';\nimport type { FieldName } from './field';\nimport { FieldTsDsl } from './field';\nimport { InitTsDsl } from './init';\nimport { MethodTsDsl } from './method';\n\ntype Base = Symbol | string;\ntype Name = Symbol | string;\ntype Body = Array<MaybeTsDsl<ts.ClassElement | ts.Node>>;\n\nconst Mixed = AbstractMixin(\n DecoratorMixin(\n DefaultMixin(\n DocMixin(ExportMixin(TypeParamsMixin(TsDsl<ts.ClassDeclaration>))),\n ),\n ),\n);\n\nexport class ClassTsDsl extends Mixed {\n readonly '~dsl' = 'ClassTsDsl';\n\n protected baseClass?: Ref<Base>;\n protected body: Body = [];\n protected name: Ref<Name>;\n\n constructor(name: Name) {\n super();\n this.name = ref(name);\n if (isSymbol(name)) {\n name.setKind('class');\n name.setNameSanitizer(safeRuntimeName);\n name.setNode(this);\n }\n }\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n ctx.analyze(this.baseClass);\n ctx.analyze(this.name);\n ctx.pushScope();\n try {\n for (const item of this.body) {\n ctx.analyze(item);\n }\n } finally {\n ctx.popScope();\n }\n }\n\n /** Adds one or more class members (fields, methods, etc.). */\n do(...items: Body): this {\n this.body.push(...items);\n return this;\n }\n\n /** Records a base class to extend from. */\n extends(base?: Base): this {\n this.baseClass = base ? ref(base) : undefined;\n return this;\n }\n\n /** Adds a class field. */\n field(name: FieldName, 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 override toAst(ctx: AstContext) {\n const body = this.$node(ctx, this.body) as ReadonlyArray<ts.ClassElement>;\n const node = ts.factory.createClassDeclaration(\n [...this.$decorators(ctx), ...this.modifiers],\n this.$node(ctx, this.name) as ts.Identifier,\n this.$generics(ctx),\n this._heritage(ctx),\n body,\n );\n return this.$docs(ctx, node);\n }\n\n /** Builds heritage clauses (extends). */\n private _heritage(ctx: AstContext): ReadonlyArray<ts.HeritageClause> {\n const node = this.$node(ctx, this.baseClass);\n if (!node) return [];\n return [\n ts.factory.createHeritageClause(ts.SyntaxKind.ExtendsKeyword, [\n ts.factory.createExpressionWithTypeArguments(node, undefined),\n ]),\n ];\n }\n}\n","import type { AnalysisContext, AstContext } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport { DocMixin } from '../mixins/doc';\nimport { safeMemberName } from '../utils/name';\n\ntype Value = string | number | MaybeTsDsl<ts.Expression>;\ntype ValueFn = Value | ((m: EnumMemberTsDsl) => void);\n\nconst Mixed = DocMixin(TsDsl<ts.EnumMember>);\n\nexport class EnumMemberTsDsl extends Mixed {\n readonly '~dsl' = 'EnumMemberTsDsl';\n\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 override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n ctx.analyze(this._value);\n }\n\n /** Sets the enum member value. */\n value(value?: Value): this {\n this._value = value;\n return this;\n }\n\n override toAst(ctx: AstContext) {\n const node = ts.factory.createEnumMember(\n this.$node(ctx, safeMemberName(this._name)),\n this.$node(ctx, this._value),\n );\n return this.$docs(ctx, node);\n }\n}\n","import type {\n AnalysisContext,\n AstContext,\n Ref,\n Symbol,\n} from '@hey-api/codegen-core';\nimport { isSymbol, ref } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport { DocMixin } from '../mixins/doc';\nimport { ConstMixin, ExportMixin } from '../mixins/modifiers';\nimport { safeRuntimeName } from '../utils/name';\nimport { EnumMemberTsDsl } from './member';\n\nexport type EnumName = Symbol | string;\ntype Value = string | number | MaybeTsDsl<ts.Expression>;\ntype ValueFn = Value | ((m: EnumMemberTsDsl) => void);\n\nconst Mixed = ConstMixin(DocMixin(ExportMixin(TsDsl<ts.EnumDeclaration>)));\n\nexport class EnumTsDsl extends Mixed {\n readonly '~dsl' = 'EnumTsDsl';\n\n private _members: Array<EnumMemberTsDsl> = [];\n private _name: Ref<EnumName>;\n\n constructor(name: EnumName, fn?: (e: EnumTsDsl) => void) {\n super();\n this._name = ref(name);\n if (isSymbol(name)) {\n name.setKind('enum');\n name.setNameSanitizer(safeRuntimeName);\n name.setNode(this);\n }\n fn?.(this);\n }\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n ctx.analyze(this._name);\n ctx.pushScope();\n try {\n for (const member of this._members) {\n ctx.analyze(member);\n }\n } finally {\n ctx.popScope();\n }\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 override toAst(ctx: AstContext) {\n const node = ts.factory.createEnumDeclaration(\n this.modifiers,\n this.$node(ctx, this._name) as ts.Identifier,\n this.$node(ctx, this._members) as ReadonlyArray<ts.EnumMember>,\n );\n return this.$docs(ctx, node);\n }\n}\n","import type {\n AnalysisContext,\n AstContext,\n Ref,\n Symbol,\n} from '@hey-api/codegen-core';\nimport { isSymbol, ref } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport { TsDsl } from '../base';\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 PrivateMixin,\n ProtectedMixin,\n PublicMixin,\n StaticMixin,\n} from '../mixins/modifiers';\nimport { ParamMixin } from '../mixins/param';\nimport { TypeParamsMixin } from '../mixins/type-params';\nimport { TypeReturnsMixin } from '../mixins/type-returns';\nimport { BlockTsDsl } from '../stmt/block';\nimport { safeRuntimeName } from '../utils/name';\n\nexport type FuncMode = 'arrow' | 'decl' | 'expr';\nexport type FuncName = Symbol | string;\n\nconst Mixed = AbstractMixin(\n AsMixin(\n AsyncMixin(\n DecoratorMixin(\n DoMixin(\n DocMixin(\n ParamMixin(\n PrivateMixin(\n ProtectedMixin(\n PublicMixin(\n StaticMixin(\n TypeParamsMixin(\n TypeReturnsMixin(TsDsl<ts.ArrowFunction>),\n ),\n ),\n ),\n ),\n ),\n ),\n ),\n ),\n ),\n ),\n ),\n);\n\nclass ImplFuncTsDsl<M extends FuncMode = 'arrow'> extends Mixed {\n readonly '~dsl' = 'FuncTsDsl';\n\n protected mode?: FuncMode;\n protected name?: Ref<FuncName>;\n\n constructor();\n constructor(fn: (f: ImplFuncTsDsl<'arrow'>) => void);\n constructor(name: FuncName);\n constructor(name: FuncName, fn: (f: ImplFuncTsDsl<'decl'>) => void);\n constructor(\n name?: FuncName | ((f: ImplFuncTsDsl<'arrow'>) => void),\n fn?: (f: ImplFuncTsDsl<'decl'>) => void,\n ) {\n super();\n if (typeof name === 'function') {\n this.mode = 'arrow';\n name(this as unknown as FuncTsDsl<'arrow'>);\n } else if (name) {\n this.mode = 'decl';\n this.name = ref(name);\n if (isSymbol(name)) {\n name.setKind('function');\n name.setNameSanitizer(safeRuntimeName);\n name.setNode(this);\n }\n fn?.(this as unknown as FuncTsDsl<'decl'>);\n }\n }\n\n override analyze(ctx: AnalysisContext): void {\n ctx.pushScope();\n try {\n super.analyze(ctx);\n ctx.analyze(this.name);\n } finally {\n ctx.popScope();\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 // @ts-expect-error --- need to fix types ---\n override toAst(\n ctx: AstContext,\n ): M extends 'decl'\n ? ts.FunctionDeclaration\n : M extends 'expr'\n ? ts.FunctionExpression\n : ts.ArrowFunction {\n const body = this.$node(ctx, new BlockTsDsl(...this._do).pretty());\n\n if (this.mode === 'decl') {\n if (!this.name) throw new Error('Function declaration requires a name');\n const node = ts.factory.createFunctionDeclaration(\n [...this.$decorators(ctx), ...this.modifiers],\n undefined,\n this.$node(ctx, this.name) as ts.Identifier,\n this.$generics(ctx),\n this.$params(ctx),\n this.$returns(ctx),\n body,\n ) as any;\n return this.$docs(ctx, node);\n }\n\n if (this.mode === 'expr') {\n const node = ts.factory.createFunctionExpression(\n this.modifiers,\n undefined,\n this.$node(ctx, this.name) as ts.Identifier,\n this.$generics(ctx),\n this.$params(ctx),\n this.$returns(ctx),\n body,\n ) as any;\n return this.$docs(ctx, node);\n }\n\n const node = ts.factory.createArrowFunction(\n this.modifiers,\n this.$generics(ctx),\n this.$params(ctx),\n this.$returns(ctx),\n undefined,\n body.statements.length === 1 &&\n ts.isReturnStatement(body.statements[0]!) &&\n body.statements[0].expression\n ? body.statements[0].expression\n : body,\n ) as any;\n return this.$docs(ctx, node);\n }\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","import type { AnalysisContext, AstContext } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport { TsDsl } from '../base';\nimport { DecoratorMixin } from '../mixins/decorator';\nimport { DoMixin } from '../mixins/do';\nimport { DocMixin } from '../mixins/doc';\nimport {\n AbstractMixin,\n AsyncMixin,\n PrivateMixin,\n ProtectedMixin,\n PublicMixin,\n StaticMixin,\n} from '../mixins/modifiers';\nimport { ParamMixin } from '../mixins/param';\nimport { TypeReturnsMixin } from '../mixins/type-returns';\nimport { BlockTsDsl } from '../stmt/block';\n\nexport type GetterName = string | ts.PropertyName;\n\nconst Mixed = AbstractMixin(\n AsyncMixin(\n DecoratorMixin(\n DoMixin(\n DocMixin(\n ParamMixin(\n PrivateMixin(\n ProtectedMixin(\n PublicMixin(\n StaticMixin(\n TypeReturnsMixin(TsDsl<ts.GetAccessorDeclaration>),\n ),\n ),\n ),\n ),\n ),\n ),\n ),\n ),\n ),\n);\n\nexport class GetterTsDsl extends Mixed {\n readonly '~dsl' = 'GetterTsDsl';\n\n protected name: GetterName;\n\n constructor(name: GetterName, fn?: (g: GetterTsDsl) => void) {\n super();\n this.name = name;\n fn?.(this);\n }\n\n override analyze(ctx: AnalysisContext): void {\n ctx.pushScope();\n try {\n super.analyze(ctx);\n } finally {\n ctx.popScope();\n }\n }\n\n override toAst(ctx: AstContext) {\n const node = ts.factory.createGetAccessorDeclaration(\n [...this.$decorators(ctx), ...this.modifiers],\n this.name,\n this.$params(ctx),\n this.$returns(ctx),\n this.$node(ctx, new BlockTsDsl(...this._do).pretty()),\n );\n return this.$docs(ctx, node);\n }\n}\n","import type { AnalysisContext, AstContext } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport { TsDsl } from '../base';\nimport { DecoratorMixin } from '../mixins/decorator';\nimport { DoMixin } from '../mixins/do';\nimport { DocMixin } from '../mixins/doc';\nimport {\n AbstractMixin,\n AsyncMixin,\n PrivateMixin,\n ProtectedMixin,\n PublicMixin,\n StaticMixin,\n} from '../mixins/modifiers';\nimport { ParamMixin } from '../mixins/param';\nimport { BlockTsDsl } from '../stmt/block';\n\nexport type SetterName = string | ts.PropertyName;\n\nconst Mixed = AbstractMixin(\n AsyncMixin(\n DecoratorMixin(\n DoMixin(\n DocMixin(\n ParamMixin(\n PrivateMixin(\n ProtectedMixin(\n PublicMixin(StaticMixin(TsDsl<ts.SetAccessorDeclaration>)),\n ),\n ),\n ),\n ),\n ),\n ),\n ),\n);\n\nexport class SetterTsDsl extends Mixed {\n readonly '~dsl' = 'SetterTsDsl';\n\n protected name: SetterName;\n\n constructor(name: SetterName, fn?: (s: SetterTsDsl) => void) {\n super();\n this.name = name;\n fn?.(this);\n }\n\n override analyze(ctx: AnalysisContext): void {\n ctx.pushScope();\n try {\n super.analyze(ctx);\n } finally {\n ctx.popScope();\n }\n }\n\n override toAst(ctx: AstContext) {\n const node = ts.factory.createSetAccessorDeclaration(\n [...this.$decorators(ctx), ...this.modifiers],\n this.name,\n this.$params(ctx),\n this.$node(ctx, new BlockTsDsl(...this._do).pretty()),\n );\n return this.$docs(ctx, node);\n }\n}\n","import type { AnalysisContext, AstContext } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport { AsMixin } from '../mixins/as';\nimport { LayoutMixin } from '../mixins/layout';\nimport { LiteralTsDsl } from './literal';\n\nconst Mixed = AsMixin(LayoutMixin(TsDsl<ts.ArrayLiteralExpression>));\n\nexport class ArrayTsDsl extends Mixed {\n readonly '~dsl' = 'ArrayTsDsl';\n\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 override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n for (const item of this._elements) {\n ctx.analyze(item.expr);\n }\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 override toAst(ctx: AstContext) {\n const elements = this._elements.map((item) => {\n const node = this.$node(ctx, 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","import type { AnalysisContext, Node } from '@hey-api/codegen-core';\nimport type ts from 'typescript';\n\nimport { f } from '../utils/factories';\nimport type { BaseCtor, DropFirst, MixinCtor } from './types';\n\nexport interface ExprMethods extends Node {\n /** Accesses a property on the current expression (e.g. `this.foo`). */\n attr(\n ...args: DropFirst<Parameters<typeof f.attr>>\n ): ReturnType<typeof f.attr>;\n /** Awaits the current expression (e.g. `await expr`). */\n await(): ReturnType<typeof f.await>;\n /** Calls the current expression (e.g. `fn(arg1, arg2)`). */\n call(\n ...args: DropFirst<Parameters<typeof f.call>>\n ): ReturnType<typeof f.call>;\n /** Produces a `return` statement returning the current expression. */\n return(): ReturnType<typeof f.return>;\n}\n\nexport function ExprMixin<T extends ts.Expression, TBase extends BaseCtor<T>>(\n Base: TBase,\n) {\n abstract class Expr extends Base {\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n }\n\n protected attr(\n ...args: DropFirst<Parameters<typeof f.attr>>\n ): ReturnType<typeof f.attr> {\n return f.attr(this, ...args);\n }\n\n protected await(): ReturnType<typeof f.await> {\n return f.await(this);\n }\n\n protected call(\n ...args: DropFirst<Parameters<typeof f.call>>\n ): ReturnType<typeof f.call> {\n return f.call(this, ...args);\n }\n\n protected return(): ReturnType<typeof f.return> {\n return f.return(this);\n }\n }\n\n return Expr as unknown as MixinCtor<TBase, ExprMethods>;\n}\n","import type {\n AnalysisContext,\n AstContext,\n Ref,\n Symbol,\n} from '@hey-api/codegen-core';\nimport { ref } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl, TypeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport { AsMixin } from '../mixins/as';\nimport { ExprMixin } from '../mixins/expr';\nimport { f } from '../utils/factories';\n\nexport type AsExpr = Symbol | string | MaybeTsDsl<ts.Expression>;\nexport type AsType = Symbol | string | TypeTsDsl;\nexport type AsCtor = (expr: AsExpr, type: AsType) => AsTsDsl;\n\nconst Mixed = AsMixin(ExprMixin(TsDsl<ts.AsExpression>));\n\nexport class AsTsDsl extends Mixed {\n readonly '~dsl' = 'AsTsDsl';\n\n protected expr: Ref<AsExpr>;\n protected type: Ref<AsType>;\n\n constructor(expr: AsExpr, type: AsType) {\n super();\n this.expr = ref(expr);\n this.type = ref(type);\n }\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n ctx.analyze(this.expr);\n ctx.analyze(this.type);\n }\n\n override toAst(ctx: AstContext) {\n return ts.factory.createAsExpression(\n this.$node(ctx, this.expr),\n this.$type(ctx, this.type),\n );\n }\n}\n\nf.as.set((...args) => new AsTsDsl(...args));\n","import type {\n AnalysisContext,\n AstContext,\n Ref,\n Symbol,\n} from '@hey-api/codegen-core';\nimport { ref } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport { AsMixin } from '../mixins/as';\nimport { ExprMixin } from '../mixins/expr';\n\ntype Expr = Symbol | 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 | '||';\n\nconst Mixed = AsMixin(ExprMixin(TsDsl<ts.BinaryExpression>));\n\nexport class BinaryTsDsl extends Mixed {\n readonly '~dsl' = 'BinaryTsDsl';\n\n protected _base: Ref<Expr>;\n protected _expr?: Ref<Expr>;\n protected _op?: Op;\n\n constructor(base: Expr, op?: Op, expr?: Expr) {\n super();\n this._base = ref(base);\n this._op = op;\n if (expr) this._expr = ref(expr);\n }\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n ctx.analyze(this._base);\n ctx.analyze(this._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 /** Nullish assignment — `this ??= expr` */\n nullishAssign(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 override toAst(ctx: AstContext) {\n if (!this._op) {\n throw new Error('BinaryTsDsl: missing operator');\n }\n const expr = this.$node(ctx, this._expr);\n if (!expr) {\n throw new Error('BinaryTsDsl: missing right-hand expression');\n }\n const base = this.$node(ctx, this._base);\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 = ref(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.QuestionQuestionEqualsToken,\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","import type { AnalysisContext, Node, Symbol } from '@hey-api/codegen-core';\nimport type ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { BinaryTsDsl } from '../expr/binary';\nimport type { BaseCtor, MixinCtor } from './types';\n\ntype Expr = Symbol | string | MaybeTsDsl<ts.Expression>;\n\nexport interface OperatorMethods extends Node {\n /** Logical AND — `this && expr` */\n and(expr: Expr): BinaryTsDsl;\n /** Creates an assignment expression (e.g. `this = expr`). */\n assign(expr: Expr): BinaryTsDsl;\n /** Nullish coalescing — `this ?? expr` */\n coalesce(expr: Expr): BinaryTsDsl;\n /** Division — `this / expr` */\n div(expr: Expr): BinaryTsDsl;\n /** Strict equality — `this === expr` */\n eq(expr: Expr): BinaryTsDsl;\n /** Greater than — `this > expr` */\n gt(expr: Expr): BinaryTsDsl;\n /** Greater than or equal — `this >= expr` */\n gte(expr: Expr): BinaryTsDsl;\n /** Loose equality — `this == expr` */\n looseEq(expr: Expr): BinaryTsDsl;\n /** Loose inequality — `this != expr` */\n looseNeq(expr: Expr): BinaryTsDsl;\n /** Less than — `this < expr` */\n lt(expr: Expr): BinaryTsDsl;\n /** Less than or equal — `this <= expr` */\n lte(expr: Expr): BinaryTsDsl;\n /** Subtraction — `this - expr` */\n minus(expr: Expr): BinaryTsDsl;\n /** Strict inequality — `this !== expr` */\n neq(expr: Expr): BinaryTsDsl;\n /** Nullish assignment — `this ??= expr` */\n nullishAssign(expr: Expr): BinaryTsDsl;\n /** Logical OR — `this || expr` */\n or(expr: Expr): BinaryTsDsl;\n /** Addition — `this + expr` */\n plus(expr: Expr): BinaryTsDsl;\n /** Multiplication — `this * expr` */\n times(expr: Expr): BinaryTsDsl;\n}\n\nexport function OperatorMixin<\n T extends ts.Expression,\n TBase extends BaseCtor<T>,\n>(Base: TBase) {\n abstract class Operator extends Base {\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n }\n\n protected and(expr: Expr): BinaryTsDsl {\n return new BinaryTsDsl(this).and(expr);\n }\n\n protected assign(expr: Expr): BinaryTsDsl {\n return new BinaryTsDsl(this, '=', expr);\n }\n\n protected coalesce(expr: Expr): BinaryTsDsl {\n return new BinaryTsDsl(this).coalesce(expr);\n }\n\n protected div(expr: Expr): BinaryTsDsl {\n return new BinaryTsDsl(this).div(expr);\n }\n\n protected eq(expr: Expr): BinaryTsDsl {\n return new BinaryTsDsl(this).eq(expr);\n }\n\n protected gt(expr: Expr): BinaryTsDsl {\n return new BinaryTsDsl(this).gt(expr);\n }\n\n protected gte(expr: Expr): BinaryTsDsl {\n return new BinaryTsDsl(this).gte(expr);\n }\n\n protected looseEq(expr: Expr): BinaryTsDsl {\n return new BinaryTsDsl(this).looseEq(expr);\n }\n\n protected looseNeq(expr: Expr): BinaryTsDsl {\n return new BinaryTsDsl(this).looseNeq(expr);\n }\n\n protected lt(expr: Expr): BinaryTsDsl {\n return new BinaryTsDsl(this).lt(expr);\n }\n\n protected lte(expr: Expr): BinaryTsDsl {\n return new BinaryTsDsl(this).lte(expr);\n }\n\n protected minus(expr: Expr): BinaryTsDsl {\n return new BinaryTsDsl(this).minus(expr);\n }\n\n protected neq(expr: Expr): BinaryTsDsl {\n return new BinaryTsDsl(this).neq(expr);\n }\n\n protected nullishAssign(expr: Expr): BinaryTsDsl {\n return new BinaryTsDsl(this).nullishAssign(expr);\n }\n\n protected or(expr: Expr): BinaryTsDsl {\n return new BinaryTsDsl(this).or(expr);\n }\n\n protected plus(expr: Expr): BinaryTsDsl {\n return new BinaryTsDsl(this).plus(expr);\n }\n\n protected times(expr: Expr): BinaryTsDsl {\n return new BinaryTsDsl(this).times(expr);\n }\n }\n\n return Operator as unknown as MixinCtor<TBase, OperatorMethods>;\n}\n","import type {\n AnalysisContext,\n AstContext,\n Ref,\n Symbol,\n} from '@hey-api/codegen-core';\nimport { fromRef, ref } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport { AsMixin } from '../mixins/as';\nimport { ExprMixin } from '../mixins/expr';\nimport { OperatorMixin } from '../mixins/operator';\nimport { OptionalMixin } from '../mixins/optional';\nimport { TokenTsDsl } from '../token';\nimport { f } from '../utils/factories';\nimport { regexp } from '../utils/regexp';\nimport { LiteralTsDsl } from './literal';\n\nexport type AttrLeft = Symbol | string | MaybeTsDsl<ts.Expression>;\nexport type AttrRight = Symbol | string | ts.MemberName | number;\nexport type AttrCtor = (left: AttrLeft, right: AttrRight) => AttrTsDsl;\n\nconst Mixed = AsMixin(\n ExprMixin(\n OperatorMixin(\n OptionalMixin(\n TsDsl<ts.PropertyAccessExpression | ts.ElementAccessExpression>,\n ),\n ),\n ),\n);\n\nexport class AttrTsDsl extends Mixed {\n readonly '~dsl' = 'AttrTsDsl';\n\n protected left: Ref<AttrLeft>;\n protected right: Ref<AttrRight>;\n\n constructor(left: AttrLeft, right: AttrRight) {\n super();\n this.left = ref(left);\n this.right = ref(right);\n }\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n ctx.analyze(this.left);\n ctx.analyze(this.right);\n }\n\n override toAst(ctx: AstContext) {\n const leftNode = this.$node(ctx, this.left);\n regexp.typeScriptIdentifier.lastIndex = 0;\n if (\n typeof fromRef(this.right) === 'number' ||\n (typeof fromRef(this.right) === 'string' &&\n !regexp.typeScriptIdentifier.test(fromRef(this.right) as string))\n ) {\n if (this._optional) {\n return ts.factory.createElementAccessChain(\n leftNode,\n this.$node(ctx, new TokenTsDsl().questionDot()),\n this.$node(ctx, new LiteralTsDsl(fromRef(this.right) as string)),\n );\n }\n return ts.factory.createElementAccessExpression(\n leftNode,\n this.$node(ctx, new LiteralTsDsl(fromRef(this.right) as string)),\n );\n }\n if (this._optional) {\n return ts.factory.createPropertyAccessChain(\n leftNode,\n this.$node(ctx, new TokenTsDsl().questionDot()),\n this.$node(ctx, this.right) as ts.MemberName,\n );\n }\n return ts.factory.createPropertyAccessExpression(\n leftNode,\n this.$node(ctx, this.right) as ts.MemberName,\n );\n }\n}\n\nf.attr.set((...args) => new AttrTsDsl(...args));\n","import type {\n AnalysisContext,\n AstContext,\n Ref,\n Symbol,\n} from '@hey-api/codegen-core';\nimport { ref } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport { ExprMixin } from '../mixins/expr';\nimport { f } from '../utils/factories';\n\nexport type AwaitExpr = Symbol | string | MaybeTsDsl<ts.Expression>;\nexport type AwaitCtor = (expr: AwaitExpr) => AwaitTsDsl;\n\nconst Mixed = ExprMixin(TsDsl<ts.AwaitExpression>);\n\nexport class AwaitTsDsl extends Mixed {\n readonly '~dsl' = 'AwaitTsDsl';\n\n protected _awaitExpr: Ref<AwaitExpr>;\n\n constructor(expr: AwaitExpr) {\n super();\n this._awaitExpr = ref(expr);\n }\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n ctx.analyze(this._awaitExpr);\n }\n\n override toAst(ctx: AstContext) {\n return ts.factory.createAwaitExpression(this.$node(ctx, this._awaitExpr));\n }\n}\n\nf.await.set((...args) => new AwaitTsDsl(...args));\n","import type {\n AnalysisContext,\n AstContext,\n Symbol,\n} from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport { ArgsMixin } from '../mixins/args';\nimport { AsMixin } from '../mixins/as';\nimport { ExprMixin } from '../mixins/expr';\nimport { TypeArgsMixin } from '../mixins/type-args';\nimport { f } from '../utils/factories';\n\nexport type CallCallee = string | MaybeTsDsl<ts.Expression>;\nexport type CallArg = Symbol | string | MaybeTsDsl<ts.Expression>;\nexport type CallArgs = ReadonlyArray<CallArg | undefined>;\nexport type CallCtor = (callee: CallCallee, ...args: CallArgs) => CallTsDsl;\n\nconst Mixed = ArgsMixin(\n AsMixin(ExprMixin(TypeArgsMixin(TsDsl<ts.CallExpression>))),\n);\n\nexport class CallTsDsl extends Mixed {\n readonly '~dsl' = 'CallTsDsl';\n\n protected _callee: CallCallee;\n\n constructor(callee: CallCallee, ...args: CallArgs) {\n super();\n this._callee = callee;\n this.args(...args);\n }\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n ctx.analyze(this._callee);\n }\n\n override toAst(ctx: AstContext) {\n return ts.factory.createCallExpression(\n this.$node(ctx, this._callee),\n this.$generics(ctx),\n this.$args(ctx),\n );\n }\n}\n\nf.call.set((...args) => new CallTsDsl(...args));\n","import type {\n AnalysisContext,\n AstContext,\n Ref,\n Symbol,\n} from '@hey-api/codegen-core';\nimport { ref } from '@hey-api/codegen-core';\nimport type ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport { AsMixin } from '../mixins/as';\nimport { ExprMixin } from '../mixins/expr';\nimport { OperatorMixin } from '../mixins/operator';\nimport { TypeExprMixin } from '../mixins/type-expr';\n\ntype Id = Symbol | string | MaybeTsDsl<ts.Expression>;\n\nconst Mixed = AsMixin(\n ExprMixin(OperatorMixin(TypeExprMixin(TsDsl<ts.Expression>))),\n);\n\nexport class ExprTsDsl extends Mixed {\n readonly '~dsl' = 'ExprTsDsl';\n\n protected _exprInput: Ref<Id>;\n\n constructor(id: Id) {\n super();\n this._exprInput = ref(id);\n }\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n ctx.analyze(this._exprInput);\n }\n\n override toAst(ctx: AstContext) {\n return this.$node(ctx, this._exprInput);\n }\n}\n","import type { AnalysisContext, AstContext } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport type { MaybeArray } from '../base';\nimport { TsDsl } from '../base';\nimport { IdTsDsl } from '../expr/id';\n\ntype HintMaybeLazy<T> = ((ctx: AstContext) => T) | T;\nexport type HintFn = (d: HintTsDsl) => void;\nexport type HintLines = HintMaybeLazy<MaybeArray<string>>;\n\nexport class HintTsDsl extends TsDsl<ts.Node> {\n readonly '~dsl' = 'HintTsDsl';\n\n protected _lines: Array<HintLines> = [];\n\n constructor(lines?: HintLines, fn?: HintFn) {\n super();\n if (lines) this.add(lines);\n fn?.(this);\n }\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n }\n\n add(lines: HintLines): this {\n this._lines.push(lines);\n return this;\n }\n\n apply<T extends ts.Node>(ctx: AstContext, node: T): T {\n const lines = this._lines.reduce(\n (lines: Array<string>, line: HintLines) => {\n if (typeof line === 'function') line = line(ctx);\n for (const l of typeof line === 'string' ? [line] : line) {\n if (l || l === '') lines.push(l);\n }\n return lines;\n },\n [],\n );\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 override toAst(ctx: AstContext): 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(ctx, new IdTsDsl(''));\n }\n}\n","import type { AnalysisContext, AstContext, Node } from '@hey-api/codegen-core';\nimport type ts from 'typescript';\n\nimport type { HintFn, HintLines } from '../layout/hint';\nimport { HintTsDsl } from '../layout/hint';\nimport type { BaseCtor, MixinCtor } from './types';\n\nexport interface HintMethods extends Node {\n $hint<T extends ts.Node>(ctx: AstContext, node: T): T;\n hint(lines?: HintLines, fn?: HintFn): this;\n}\n\nexport function HintMixin<T extends ts.Node, TBase extends BaseCtor<T>>(\n Base: TBase,\n) {\n abstract class Hint extends Base {\n private _hint?: HintTsDsl;\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n }\n\n protected hint(lines?: HintLines, fn?: HintFn): this {\n this._hint = new HintTsDsl(lines, fn);\n return this;\n }\n\n protected $hint<T extends ts.Node>(ctx: AstContext, node: T): T {\n return this._hint ? this._hint.apply(ctx, node) : node;\n }\n }\n\n return Hint as unknown as MixinCtor<TBase, HintMethods>;\n}\n","import type {\n AnalysisContext,\n AstContext,\n Ref,\n Symbol,\n} from '@hey-api/codegen-core';\nimport { ref } from '@hey-api/codegen-core';\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 { DocMixin } from '../mixins/doc';\nimport { safePropName } from '../utils/name';\nimport { IdTsDsl } from './id';\n\ntype Expr = Symbol | string | MaybeTsDsl<ts.Expression>;\ntype Stmt = Symbol | 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\nconst Mixed = DocMixin(TsDsl<ts.ObjectLiteralElementLike>);\n\nexport class ObjectPropTsDsl extends Mixed {\n readonly '~dsl' = 'ObjectPropTsDsl';\n\n protected _value?: Ref<Expr | Stmt>;\n protected meta: Meta;\n\n constructor(meta: Meta) {\n super();\n this.meta = meta;\n }\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n ctx.analyze(this._value);\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 = ref(value);\n }\n return this;\n }\n\n override toAst(ctx: AstContext) {\n this.$validate();\n const node = this.$node(ctx, 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 const result = ts.factory.createSpreadAssignment(node);\n return this.$docs(ctx, result);\n }\n if (this.meta.kind === 'getter') {\n const getter = new GetterTsDsl(\n this.$node(ctx, safePropName(this.meta.name)),\n ).do(node);\n const result = this.$node(ctx, getter);\n return this.$docs(ctx, result);\n }\n if (this.meta.kind === 'setter') {\n const setter = new SetterTsDsl(\n this.$node(ctx, safePropName(this.meta.name)),\n ).do(node);\n const result = this.$node(ctx, setter);\n return this.$docs(ctx, result);\n }\n if (ts.isIdentifier(node) && node.text === this.meta.name) {\n const result = ts.factory.createShorthandPropertyAssignment(\n this.meta.name,\n );\n return this.$docs(ctx, result);\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 const result = ts.factory.createPropertyAssignment(\n this.meta.kind === 'computed'\n ? ts.factory.createComputedPropertyName(\n this.$node(ctx, new IdTsDsl(this.meta.name)),\n )\n : this.$node(ctx, safePropName(this.meta.name)),\n node,\n );\n return this.$docs(ctx, result);\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","import type {\n AnalysisContext,\n AstContext,\n Symbol,\n} from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\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 = Symbol | string | MaybeTsDsl<ts.Expression>;\ntype Stmt = Symbol | string | MaybeTsDsl<ts.Statement>;\ntype ExprFn = Expr | ((p: ObjectPropTsDsl) => void);\ntype StmtFn = Stmt | ((p: ObjectPropTsDsl) => void);\n\nconst Mixed = AsMixin(\n ExprMixin(HintMixin(LayoutMixin(TsDsl<ts.ObjectLiteralExpression>))),\n);\n\nexport class ObjectTsDsl extends Mixed {\n readonly '~dsl' = 'ObjectTsDsl';\n\n protected _props: Array<ObjectPropTsDsl> = [];\n\n constructor(...props: Array<ObjectPropTsDsl>) {\n super();\n this.props(...props);\n }\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n for (const prop of this._props) {\n ctx.analyze(prop);\n }\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 override toAst(ctx: AstContext) {\n const node = ts.factory.createObjectLiteralExpression(\n this.$node(ctx, this._props),\n this.$multiline(this._props.length),\n );\n return this.$hint(ctx, node);\n }\n}\n","import { isNode } from '@hey-api/codegen-core';\nimport type ts from 'typescript';\n\nimport type { 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 (isNode(input)) {\n return input as TsDsl<ts.Expression>;\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","import type {\n AnalysisContext,\n AstContext,\n Ref,\n Symbol,\n} from '@hey-api/codegen-core';\nimport { ref } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport { ArgsMixin } from '../mixins/args';\nimport { ExprMixin } from '../mixins/expr';\nimport { TypeArgsMixin } from '../mixins/type-args';\n\nexport type NewExpr = Symbol | string | MaybeTsDsl<ts.Expression>;\n\nconst Mixed = ArgsMixin(ExprMixin(TypeArgsMixin(TsDsl<ts.NewExpression>)));\n\nexport class NewTsDsl extends Mixed {\n readonly '~dsl' = 'NewTsDsl';\n\n protected classExpr: Ref<NewExpr>;\n\n constructor(classExpr: NewExpr, ...args: ReadonlyArray<NewExpr>) {\n super();\n this.classExpr = ref(classExpr);\n this.args(...args);\n }\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n ctx.analyze(this.classExpr);\n }\n\n override toAst(ctx: AstContext) {\n return ts.factory.createNewExpression(\n this.$node(ctx, this.classExpr),\n this.$generics(ctx),\n this.$args(ctx),\n );\n }\n}\n","import type { AnalysisContext } from '@hey-api/codegen-core';\nimport 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\nconst Mixed = TsDsl<ts.RegularExpressionLiteral>;\n\nexport class RegExpTsDsl extends Mixed {\n readonly '~dsl' = 'RegExpTsDsl';\n\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 override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n }\n\n override toAst() {\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 type {\n AnalysisContext,\n AstContext,\n Ref,\n Symbol,\n} from '@hey-api/codegen-core';\nimport { fromRef, isSymbol, ref } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\n\nexport type TemplatePart = Symbol | string | MaybeTsDsl<ts.Expression>;\n\nconst Mixed = TsDsl<ts.TemplateExpression | ts.NoSubstitutionTemplateLiteral>;\n\nexport class TemplateTsDsl extends Mixed {\n readonly '~dsl' = 'TemplateTsDsl';\n\n protected parts: Array<Ref<TemplatePart>> = [];\n\n constructor(value?: TemplatePart) {\n super();\n if (value !== undefined) this.add(value);\n }\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n for (const part of this.parts) {\n ctx.analyze(part);\n }\n }\n\n add(value: TemplatePart): this {\n this.parts.push(ref(value));\n return this;\n }\n\n override toAst(ctx: AstContext) {\n const parts = this.$node(\n ctx,\n this.parts.map((p) => {\n const part = fromRef(p);\n return isSymbol(part) ? part.finalName : part;\n }),\n );\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 type { AnalysisContext, AstContext } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\n\nconst Mixed = TsDsl<ts.ConditionalExpression>;\n\nexport class TernaryTsDsl extends Mixed {\n readonly '~dsl' = 'TernaryTsDsl';\n\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 override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n ctx.analyze(this._condition);\n ctx.analyze(this._then);\n ctx.analyze(this._else);\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 override toAst(ctx: AstContext) {\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(ctx, this._condition),\n undefined,\n this.$node(ctx, this._then),\n undefined,\n this.$node(ctx, this._else),\n );\n }\n}\n","import type { AnalysisContext, AstContext } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport { OperatorMixin } from '../mixins/operator';\nimport { f } from '../utils/factories';\n\nexport type TypeOfExpr = string | MaybeTsDsl<ts.Expression>;\nexport type TypeOfExprCtor = (expr: TypeOfExpr) => TypeOfExprTsDsl;\n\nconst Mixed = OperatorMixin(TsDsl<ts.TypeOfExpression>);\n\nexport class TypeOfExprTsDsl extends Mixed {\n readonly '~dsl' = 'TypeOfExprTsDsl';\n\n protected _expr: TypeOfExpr;\n\n constructor(expr: TypeOfExpr) {\n super();\n this._expr = expr;\n }\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n ctx.analyze(this._expr);\n }\n\n override toAst(ctx: AstContext) {\n return ts.factory.createTypeOfExpression(this.$node(ctx, this._expr));\n }\n}\n\nf.typeofExpr.set((...args) => new TypeOfExprTsDsl(...args));\n","import type { AnalysisContext, AstContext } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport type { MaybeArray } from '../base';\nimport { TsDsl } from '../base';\nimport { IdTsDsl } from '../expr/id';\n\ntype NoteMaybeLazy<T> = ((ctx: AstContext) => T) | T;\nexport type NoteFn = (d: NoteTsDsl) => void;\nexport type NoteLines = NoteMaybeLazy<MaybeArray<string>>;\n\nexport class NoteTsDsl extends TsDsl<ts.Node> {\n readonly '~dsl' = 'NoteTsDsl';\n\n protected _lines: Array<NoteLines> = [];\n\n constructor(lines?: NoteLines, fn?: NoteFn) {\n super();\n if (lines) this.add(lines);\n fn?.(this);\n }\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n }\n\n add(lines: NoteLines): this {\n this._lines.push(lines);\n return this;\n }\n\n apply<T extends ts.Node>(ctx: AstContext, node: T): T {\n const lines = this._lines.reduce(\n (lines: Array<string>, line: NoteLines) => {\n if (typeof line === 'function') line = line(ctx);\n for (const l of typeof line === 'string' ? [line] : line) {\n if (l || l === '') lines.push(l);\n }\n return lines;\n },\n [],\n );\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 override toAst(ctx: AstContext): 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(ctx, new IdTsDsl(''));\n }\n}\n","import type { AnalysisContext, AstContext } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport type { DoExpr } from '../mixins/do';\nimport { DoMixin } from '../mixins/do';\nimport { BlockTsDsl } from './block';\n\nexport type IfCondition = string | MaybeTsDsl<ts.Expression>;\n\nconst Mixed = DoMixin(TsDsl<ts.IfStatement>);\n\nexport class IfTsDsl extends Mixed {\n readonly '~dsl' = 'IfTsDsl';\n\n protected _condition?: IfCondition;\n protected _else?: Array<DoExpr>;\n\n constructor(condition?: IfCondition) {\n super();\n if (condition) this.condition(condition);\n }\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n ctx.analyze(this._condition);\n if (this._else) {\n ctx.pushScope();\n try {\n for (const stmt of this._else) {\n ctx.analyze(stmt);\n }\n } finally {\n ctx.popScope();\n }\n }\n }\n\n condition(condition: IfCondition): this {\n this._condition = condition;\n return this;\n }\n\n otherwise(...items: Array<DoExpr>): this {\n this._else = items;\n return this;\n }\n\n override toAst(ctx: AstContext) {\n if (!this._condition) throw new Error('Missing condition in if');\n if (!this._do) throw new Error('Missing then block in if');\n\n return ts.factory.createIfStatement(\n this.$node(ctx, this._condition),\n this.$node(ctx, new BlockTsDsl(...this._do).pretty()),\n this._else\n ? this.$node(ctx, new BlockTsDsl(...this._else).pretty())\n : undefined,\n );\n }\n}\n","import type {\n AnalysisContext,\n AstContext,\n Ref,\n Symbol,\n} from '@hey-api/codegen-core';\nimport { ref } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport { f } from '../utils/factories';\n\nexport type ReturnExpr = Symbol | string | MaybeTsDsl<ts.Expression>;\nexport type ReturnCtor = (expr?: ReturnExpr) => ReturnTsDsl;\n\nconst Mixed = TsDsl<ts.ReturnStatement>;\n\nexport class ReturnTsDsl extends Mixed {\n readonly '~dsl' = 'ReturnTsDsl';\n\n protected _returnExpr?: Ref<ReturnExpr>;\n\n constructor(expr?: ReturnExpr) {\n super();\n if (expr) this._returnExpr = ref(expr);\n }\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n ctx.analyze(this._returnExpr);\n }\n\n override toAst(ctx: AstContext) {\n return ts.factory.createReturnStatement(this.$node(ctx, this._returnExpr));\n }\n}\n\nf.return.set((...args) => new ReturnTsDsl(...args));\n","import type { AnalysisContext, AstContext } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport { LiteralTsDsl } from '../expr/literal';\n\nconst Mixed = TsDsl<ts.ThrowStatement>;\n\nexport class ThrowTsDsl extends Mixed {\n readonly '~dsl' = 'ThrowTsDsl';\n\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 override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n ctx.analyze(this.error);\n ctx.analyze(this.msg);\n }\n\n message(value: string | MaybeTsDsl<ts.Expression>): this {\n this.msg = value;\n return this;\n }\n\n override toAst(ctx: AstContext) {\n const errorNode = this.$node(ctx, this.error);\n const messageNode = this.$node(ctx, this.msg ? [this.msg] : []).map(\n (expr) =>\n typeof expr === 'string'\n ? this.$node(ctx, new LiteralTsDsl(expr))\n : 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","import type {\n AnalysisContext,\n AstContext,\n Symbol,\n} from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport { TsDsl } from '../base';\nimport type { DoExpr } from '../mixins/do';\nimport { BlockTsDsl } from './block';\n\nconst Mixed = TsDsl<ts.TryStatement>;\n\ntype CatchParam = Symbol | string;\n\nexport class TryTsDsl extends Mixed {\n readonly '~dsl' = 'TryTsDsl';\n\n protected _catch?: Array<DoExpr>;\n protected _catchArg?: CatchParam;\n protected _finally?: Array<DoExpr>;\n protected _try?: Array<DoExpr>;\n\n constructor(...tryBlock: Array<DoExpr>) {\n super();\n this.try(...tryBlock);\n }\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n\n if (this._try) {\n ctx.pushScope();\n try {\n for (const stmt of this._try) ctx.analyze(stmt);\n } finally {\n ctx.popScope();\n }\n }\n\n if (this._catch || this._catchArg) {\n ctx.pushScope();\n try {\n ctx.analyze(this._catchArg);\n if (this._catch) {\n for (const stmt of this._catch) ctx.analyze(stmt);\n }\n } finally {\n ctx.popScope();\n }\n }\n\n if (this._finally) {\n ctx.pushScope();\n try {\n for (const stmt of this._finally) ctx.analyze(stmt);\n } finally {\n ctx.popScope();\n }\n }\n }\n\n catch(...items: Array<DoExpr>): this {\n this._catch = items;\n return this;\n }\n\n catchArg(arg: CatchParam): this {\n this._catchArg = arg;\n return this;\n }\n\n finally(...items: Array<DoExpr>): this {\n this._finally = items;\n return this;\n }\n\n try(...items: Array<DoExpr>): this {\n this._try = items;\n return this;\n }\n\n override toAst(ctx: AstContext) {\n if (!this._try?.length) throw new Error('Missing try block');\n\n const catchParam = this._catchArg\n ? (this.$node(ctx, this._catchArg) as ts.BindingName)\n : undefined;\n\n return ts.factory.createTryStatement(\n this.$node(ctx, new BlockTsDsl(...this._try).pretty()),\n ts.factory.createCatchClause(\n catchParam\n ? ts.factory.createVariableDeclaration(catchParam)\n : undefined,\n this.$node(ctx, new BlockTsDsl(...(this._catch ?? [])).pretty()),\n ),\n this._finally\n ? this.$node(ctx, new BlockTsDsl(...this._finally).pretty())\n : undefined,\n );\n }\n}\n","import type {\n AnalysisContext,\n AstContext,\n Ref,\n Symbol,\n} from '@hey-api/codegen-core';\nimport { isSymbol, ref } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport { TsDsl, TypeTsDsl } from '../base';\nimport { DocMixin } from '../mixins/doc';\nimport { HintMixin } from '../mixins/hint';\nimport { DefaultMixin, ExportMixin } from '../mixins/modifiers';\nimport { PatternMixin } from '../mixins/pattern';\nimport { ValueMixin } from '../mixins/value';\nimport { TypeExprTsDsl } from '../type/expr';\nimport { safeRuntimeName } from '../utils/name';\n\nexport type VarName = Symbol | string;\n\nconst Mixed = DefaultMixin(\n DocMixin(\n ExportMixin(\n HintMixin(PatternMixin(ValueMixin(TsDsl<ts.VariableStatement>))),\n ),\n ),\n);\n\nexport class VarTsDsl extends Mixed {\n readonly '~dsl' = 'VarTsDsl';\n\n protected kind: ts.NodeFlags = ts.NodeFlags.None;\n protected name?: Ref<VarName>;\n protected _type?: TypeTsDsl;\n\n constructor(name?: VarName) {\n super();\n if (name) this.name = ref(name);\n if (isSymbol(name)) {\n name.setKind('var');\n name.setNameSanitizer(safeRuntimeName);\n name.setNode(this);\n }\n }\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n ctx.analyze(this.name);\n ctx.analyze(this._type);\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 override toAst(ctx: AstContext) {\n const name = this.$pattern(ctx) ?? this.$node(ctx, this.name);\n if (!name)\n throw new Error('Var must have either a name or a destructuring pattern');\n const node = ts.factory.createVariableStatement(\n this.modifiers,\n ts.factory.createVariableDeclarationList(\n [\n ts.factory.createVariableDeclaration(\n name as ts.BindingName,\n undefined,\n this.$type(ctx, this._type),\n this.$value(ctx),\n ),\n ],\n this.kind,\n ),\n );\n return this.$docs(ctx, this.$hint(ctx, node));\n }\n}\n","import type {\n AnalysisContext,\n AstContext,\n Ref,\n Symbol,\n} from '@hey-api/codegen-core';\nimport { fromRef, isSymbol, ref } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport { DocMixin } from '../mixins/doc';\nimport { ExportMixin } from '../mixins/modifiers';\nimport { TypeParamsMixin } from '../mixins/type-params';\nimport { safeTypeName } from '../utils/name';\n\ntype Name = Symbol | string;\ntype Value = MaybeTsDsl<ts.TypeNode>;\n\nconst Mixed = DocMixin(\n ExportMixin(TypeParamsMixin(TsDsl<ts.TypeAliasDeclaration>)),\n);\n\nexport class TypeAliasTsDsl extends Mixed {\n readonly '~dsl' = 'TypeAliasTsDsl';\n\n protected name: Ref<Name>;\n protected value?: Value;\n\n constructor(name: Name, fn?: (t: TypeAliasTsDsl) => void) {\n super();\n this.name = ref(name);\n if (isSymbol(name)) {\n name.setKind('type');\n name.setNameSanitizer(safeTypeName);\n name.setNode(this);\n }\n fn?.(this);\n }\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n ctx.analyze(this.name);\n ctx.analyze(this.value);\n }\n\n /** Sets the type expression on the right-hand side of `= ...`. */\n type(node: Value): this {\n this.value = node;\n return this;\n }\n\n override toAst(ctx: AstContext) {\n if (!this.value)\n throw new Error(\n `Type alias '${fromRef(this.name)}' is missing a type definition`,\n );\n const node = ts.factory.createTypeAliasDeclaration(\n this.modifiers,\n this.$node(ctx, this.name) as ts.Identifier,\n this.$generics(ctx),\n this.$type(ctx, this.value),\n );\n return this.$docs(ctx, node);\n }\n}\n","import type {\n AnalysisContext,\n AstContext,\n Ref,\n Symbol,\n} from '@hey-api/codegen-core';\nimport { ref } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport type { TypeTsDsl } from '../base';\nimport { TsDsl } from '../base';\n\ntype Type = Symbol | string | ts.TypeNode | TypeTsDsl;\n\nconst Mixed = TsDsl<ts.IntersectionTypeNode>;\n\nexport class TypeAndTsDsl extends Mixed {\n readonly '~dsl' = 'TypeAndTsDsl';\n\n protected _types: Array<Ref<Type>> = [];\n\n constructor(...nodes: Array<Type>) {\n super();\n this.types(...nodes);\n }\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n for (const type of this._types) {\n ctx.analyze(type);\n }\n }\n\n types(...nodes: Array<Type>): this {\n this._types.push(...nodes.map((n) => ref(n)));\n return this;\n }\n\n override toAst(ctx: AstContext) {\n const flat: Array<ts.TypeNode> = [];\n\n for (const node of this._types) {\n const type = this.$type(ctx, node);\n if (ts.isIntersectionTypeNode(type)) {\n flat.push(...type.types);\n } else {\n flat.push(type);\n }\n }\n\n return ts.factory.createIntersectionTypeNode(flat);\n }\n}\n","import type { AnalysisContext, AstContext } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport { TsDsl } from '../base';\nimport { LiteralTsDsl } from '../expr/literal';\n\nconst Mixed = TsDsl<ts.LiteralTypeNode>;\n\nexport class TypeLiteralTsDsl extends Mixed {\n readonly '~dsl' = 'TypeLiteralTsDsl';\n\n protected value: string | number | boolean | null;\n\n constructor(value: string | number | boolean | null) {\n super();\n this.value = value;\n }\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n }\n\n override toAst(ctx: AstContext) {\n return ts.factory.createLiteralTypeNode(\n this.$node(ctx, new LiteralTsDsl(this.value)),\n );\n }\n}\n","import type { AnalysisContext, AstContext } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport { DocMixin } from '../mixins/doc';\nimport { ReadonlyMixin } from '../mixins/modifiers';\n\nexport type TypeIdxSigName = string;\nexport type TypeIdxSigType = string | MaybeTsDsl<ts.TypeNode>;\n\nconst Mixed = DocMixin(ReadonlyMixin(TsDsl<ts.IndexSignatureDeclaration>));\n\nexport class TypeIdxSigTsDsl extends Mixed {\n readonly '~dsl' = 'TypeIdxSigTsDsl';\n\n protected _key?: TypeIdxSigType;\n protected _name: TypeIdxSigName;\n protected _type?: TypeIdxSigType;\n\n constructor(name: TypeIdxSigName, fn?: (i: TypeIdxSigTsDsl) => void) {\n super();\n this._name = name;\n fn?.(this);\n }\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n ctx.analyze(this._key);\n ctx.analyze(this._type);\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: TypeIdxSigType): this {\n this._key = type;\n return this;\n }\n\n /** Sets the property type. */\n type(type: TypeIdxSigType): this {\n this._type = type;\n return this;\n }\n\n override toAst(ctx: AstContext) {\n this.$validate();\n const node = ts.factory.createIndexSignature(\n this.modifiers,\n [\n ts.factory.createParameterDeclaration(\n undefined,\n undefined,\n this._name,\n undefined,\n this.$type(ctx, this._key),\n ),\n ],\n this.$type(ctx, this._type),\n );\n return this.$docs(ctx, node);\n }\n\n $validate(): asserts this is this & {\n _key: TypeIdxSigType;\n _name: TypeIdxSigName;\n _type: TypeIdxSigType;\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","import type {\n AnalysisContext,\n AstContext,\n Ref,\n Symbol,\n} from '@hey-api/codegen-core';\nimport { ref } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport { DocMixin } from '../mixins/doc';\nimport { ReadonlyMixin } from '../mixins/modifiers';\nimport { OptionalMixin } from '../mixins/optional';\nimport { TokenTsDsl } from '../token';\nimport { safePropName } from '../utils/name';\n\nexport type TypePropName = string;\nexport type TypePropType = Symbol | string | MaybeTsDsl<ts.TypeNode>;\n\nconst Mixed = DocMixin(OptionalMixin(ReadonlyMixin(TsDsl<ts.TypeElement>)));\n\nexport class TypePropTsDsl extends Mixed {\n readonly '~dsl' = 'TypePropTsDsl';\n\n protected name: TypePropName;\n protected _type?: Ref<TypePropType>;\n\n constructor(name: TypePropName, fn: (p: TypePropTsDsl) => void) {\n super();\n this.name = name;\n fn(this);\n }\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n ctx.analyze(this._type);\n }\n\n /** Sets the property type. */\n type(type: TypePropType): this {\n this._type = ref(type);\n return this;\n }\n\n override toAst(ctx: AstContext) {\n if (!this._type) {\n throw new Error(`Type not specified for property '${this.name}'`);\n }\n const node = ts.factory.createPropertySignature(\n this.modifiers,\n this.$node(ctx, safePropName(this.name)),\n this._optional ? this.$node(ctx, new TokenTsDsl().optional()) : undefined,\n this.$type(ctx, this._type),\n );\n return this.$docs(ctx, node);\n }\n}\n","import type { AnalysisContext, AstContext } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport { TsDsl } from '../base';\nimport { TypeIdxSigTsDsl } from './idx-sig';\nimport { TypePropTsDsl } from './prop';\n\nconst Mixed = TsDsl<ts.TypeNode>;\n\nexport class TypeObjectTsDsl extends Mixed {\n readonly '~dsl' = 'TypeObjectTsDsl';\n\n protected props: Array<TypePropTsDsl | TypeIdxSigTsDsl> = [];\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n for (const prop of this.props) {\n ctx.analyze(prop);\n }\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 /** 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 override toAst(ctx: AstContext) {\n return ts.factory.createTypeLiteralNode(this.$node(ctx, this.props));\n }\n}\n","import type { AnalysisContext, AstContext } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport type { TypeTsDsl } from '../base';\nimport { TsDsl } from '../base';\n\nconst Mixed = TsDsl<ts.TupleTypeNode>;\n\nexport class TypeTupleTsDsl extends Mixed {\n readonly '~dsl' = 'TypeTupleTsDsl';\n\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 override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n for (const type of this._elements) {\n ctx.analyze(type);\n }\n }\n\n elements(...types: Array<string | ts.TypeNode | TypeTsDsl>): this {\n this._elements.push(...types);\n return this;\n }\n\n override toAst(ctx: AstContext) {\n return ts.factory.createTupleTypeNode(\n this._elements.map((t) => this.$type(ctx, t)),\n );\n }\n}\n","import { isNode } from '@hey-api/codegen-core';\nimport type ts from 'typescript';\n\nimport type { 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 (isNode(input)) {\n return input as TsDsl<ts.TypeNode>;\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","import type { AnalysisContext, AstContext } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport { TsDsl } from '../base';\nimport { DocMixin } from '../mixins/doc';\nimport { ParamMixin } from '../mixins/param';\nimport { TypeParamsMixin } from '../mixins/type-params';\nimport { TypeReturnsMixin } from '../mixins/type-returns';\n\nconst Mixed = DocMixin(\n ParamMixin(TypeParamsMixin(TypeReturnsMixin(TsDsl<ts.FunctionTypeNode>))),\n);\n\nexport class TypeFuncTsDsl extends Mixed {\n readonly '~dsl' = 'TypeFuncTsDsl';\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n }\n\n override toAst(ctx: AstContext) {\n const returns = this.$returns(ctx);\n if (returns === undefined) {\n throw new Error('Missing return type in function type DSL');\n }\n const node = ts.factory.createFunctionTypeNode(\n this.$generics(ctx),\n this.$params(ctx),\n returns,\n );\n return this.$docs(ctx, node);\n }\n}\n","import type { AnalysisContext, AstContext } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport { TypeExprMixin } from '../mixins/type-expr';\nimport { f } from '../utils/factories';\n\ntype Base = string | MaybeTsDsl<ts.TypeNode>;\ntype Index = string | number | MaybeTsDsl<ts.TypeNode>;\nexport type TypeIdxCtor = (base: Base, index: Index) => TypeIdxTsDsl;\n\nconst Mixed = TypeExprMixin(TsDsl<ts.IndexedAccessTypeNode>);\n\nexport class TypeIdxTsDsl extends Mixed {\n readonly '~dsl' = 'TypeIdxTsDsl';\n\n protected _base!: Base;\n protected _index!: Index;\n\n constructor(base: Base, index: Index) {\n super();\n this.base(base);\n this.index(index);\n }\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n ctx.analyze(this._base);\n ctx.analyze(this._index);\n }\n\n base(base: Base): this {\n this._base = base;\n return this;\n }\n\n index(index: Index): this {\n this._index = index;\n return this;\n }\n\n override toAst(ctx: AstContext) {\n return ts.factory.createIndexedAccessTypeNode(\n this.$type(ctx, this._base),\n this.$type(ctx, this._index),\n );\n }\n}\n\nf.type.idx.set((...args) => new TypeIdxTsDsl(...args));\n","import type { AnalysisContext, AstContext } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport { TokenTsDsl } from '../token';\n\nconst Mixed = TsDsl<ts.MappedTypeNode>;\n\nexport class TypeMappedTsDsl extends Mixed {\n readonly '~dsl' = 'TypeMappedTsDsl';\n\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 override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n ctx.analyze(this.questionToken);\n ctx.analyze(this.readonlyToken);\n ctx.analyze(this._key);\n ctx.analyze(this._type);\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 override toAst(ctx: AstContext) {\n this.$validate();\n return ts.factory.createMappedTypeNode(\n this.$node(ctx, this.readonlyToken),\n ts.factory.createTypeParameterDeclaration(\n undefined,\n this._name,\n this.$type(ctx, this._key),\n undefined,\n ),\n undefined,\n this.$node(ctx, this.questionToken),\n this.$type(ctx, 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 type { AnalysisContext, AstContext } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport { f } from '../utils/factories';\n\ntype Op =\n | ts.SyntaxKind.KeyOfKeyword\n | ts.SyntaxKind.ReadonlyKeyword\n | ts.SyntaxKind.UniqueKeyword;\ntype Type = string | MaybeTsDsl<ts.TypeNode>;\nexport type TypeOperatorCtor = () => TypeOperatorTsDsl;\n\nconst Mixed = TsDsl<ts.TypeOperatorNode>;\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 Mixed {\n readonly '~dsl' = 'TypeOperatorTsDsl';\n\n protected _op?: Op;\n protected _type?: Type;\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n ctx.analyze(this._type);\n }\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 override toAst(ctx: AstContext) {\n this.$validate();\n return ts.factory.createTypeOperatorNode(\n this._op,\n this.$type(ctx, this._type),\n );\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\nf.type.operator.set((...args) => new TypeOperatorTsDsl(...args));\n","import type {\n AnalysisContext,\n AstContext,\n Ref,\n Symbol,\n} from '@hey-api/codegen-core';\nimport { ref } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport type { TypeTsDsl } from '../base';\nimport { TsDsl } from '../base';\n\ntype Type = Symbol | string | ts.TypeNode | TypeTsDsl;\n\nconst Mixed = TsDsl<ts.UnionTypeNode>;\n\nexport class TypeOrTsDsl extends Mixed {\n readonly '~dsl' = 'TypeOrTsDsl';\n\n protected _types: Array<Ref<Type>> = [];\n\n constructor(...nodes: Array<Type>) {\n super();\n this.types(...nodes);\n }\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n for (const type of this._types) {\n ctx.analyze(type);\n }\n }\n\n types(...nodes: Array<Type>): this {\n this._types.push(...nodes.map((n) => ref(n)));\n return this;\n }\n\n override toAst(ctx: AstContext) {\n const flat: Array<ts.TypeNode> = [];\n\n for (const node of this._types) {\n const type = this.$type(ctx, node);\n if (ts.isUnionTypeNode(type)) {\n flat.push(...type.types);\n } else {\n flat.push(type);\n }\n }\n\n return ts.factory.createUnionTypeNode(flat);\n }\n}\n","import type { AnalysisContext, AstContext } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl, TypeTsDsl } from '../base';\nimport { TsDsl } from '../base';\nimport { TypeExprMixin } from '../mixins/type-expr';\nimport { f } from '../utils/factories';\n\nexport type TypeQueryExpr = string | MaybeTsDsl<TypeTsDsl | ts.Expression>;\nexport type TypeQueryCtor = (expr: TypeQueryExpr) => TypeQueryTsDsl;\n\nconst Mixed = TypeExprMixin(TsDsl<ts.TypeQueryNode>);\n\nexport class TypeQueryTsDsl extends Mixed {\n readonly '~dsl' = 'TypeQueryTsDsl';\n\n protected _expr: TypeQueryExpr;\n\n constructor(expr: TypeQueryExpr) {\n super();\n this._expr = expr;\n }\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n ctx.analyze(this._expr);\n }\n\n override toAst(ctx: AstContext) {\n const expr = this.$node(ctx, this._expr);\n return ts.factory.createTypeQueryNode(expr as unknown as ts.EntityName);\n }\n}\n\nf.type.query.set((...args) => new TypeQueryTsDsl(...args));\n","import type { AnalysisContext, AstContext } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport type { MaybeTsDsl } from '../base';\nimport { TsDsl } from '../base';\n\nconst Mixed = TsDsl<ts.TemplateLiteralTypeNode>;\n\nexport class TypeTemplateTsDsl extends Mixed {\n readonly '~dsl' = 'TypeTemplateTsDsl';\n\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 override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n for (const part of this.parts) {\n ctx.analyze(part);\n }\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 override toAst(ctx: AstContext) {\n const parts = this.$node(ctx, 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 type { AnalysisContext, AstContext } from '@hey-api/codegen-core';\nimport type ts from 'typescript';\n\nimport { TsDsl } from '../base';\n\nexport type LazyThunk<T extends ts.Node> = (ctx: AstContext) => TsDsl<T>;\n\nexport class LazyTsDsl<T extends ts.Node = ts.Node> extends TsDsl<T> {\n readonly '~dsl' = 'LazyTsDsl';\n\n private _thunk: LazyThunk<T>;\n\n constructor(thunk: LazyThunk<T>) {\n super();\n this._thunk = thunk;\n }\n\n override analyze(ctx: AnalysisContext): void {\n super.analyze(ctx);\n const astContext: AstContext = {\n getAccess(node) {\n return node;\n },\n };\n ctx.analyze(this._thunk(astContext));\n }\n\n override toAst(ctx: AstContext) {\n return this._thunk(ctx).toAst(ctx);\n }\n}\n","import path from 'node:path';\n\nimport type { ExportModule, File, ImportModule } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nconst printer = ts.createPrinter({\n newLine: ts.NewLineKind.LineFeed,\n removeComments: false,\n});\n\nconst blankFile = ts.createSourceFile(\n '',\n '',\n ts.ScriptTarget.ESNext,\n false,\n ts.ScriptKind.TS,\n);\n\n/** Print a TypeScript node to a string. */\nexport function nodeToString(node: ts.Node): string {\n const result = printer.printNode(ts.EmitHint.Unspecified, node, blankFile);\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 result.replace(/\\\\u([0-9a-fA-F]{4})/g, (_, hex: string) =>\n String.fromCharCode(Number.parseInt(hex, 16)),\n );\n } catch {\n return result;\n }\n}\n\nexport const 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 type SortGroup = number;\nexport type SortDistance = number;\nexport type SortModule = string;\nexport type SortKey = [SortGroup, SortDistance, SortModule];\n\nexport type ModuleExport = Omit<ExportModule, 'from'> & {\n /** Module specifier for re-exports, e.g. `./foo`. */\n modulePath: string;\n};\n\nexport type ModuleImport = Omit<ImportModule, 'from'> & {\n /** Module specifier for imports, e.g. `./foo`. */\n modulePath: string;\n};\n\nexport const moduleSortKey = ({\n file,\n fromFile,\n preferFileExtension,\n root,\n}: {\n file: File;\n fromFile: File;\n preferFileExtension: string;\n root: string;\n}): SortKey => {\n const filePath = file.finalPath!.split(path.sep).join('/');\n let modulePath = fromFile.finalPath!.split(path.sep).join('/');\n\n // built-ins\n // TODO: based on nodeBuiltins set\n\n // external\n if (fromFile.external && !path.isAbsolute(modulePath)) {\n return [0, 0, modulePath];\n }\n\n // outside project root\n if (!modulePath.startsWith(root.split(path.sep).join('/'))) {\n return [1, 0, modulePath];\n }\n\n // local\n const rel = path\n .relative(path.dirname(filePath), path.dirname(modulePath))\n .split(path.sep)\n .join('/');\n\n let parentCount: number;\n // same folder\n if (!rel.startsWith('..')) {\n modulePath = `./${rel ? `${rel}/` : ''}${fromFile.name}${fromFile.extension ?? ''}`;\n parentCount = 0;\n } else {\n modulePath = `${rel}/${fromFile.name}${fromFile.extension ?? ''}`;\n parentCount = rel\n .split(path.sep)\n .filter((segment) => segment === '..').length;\n }\n\n if (modulePath.endsWith('.ts')) {\n modulePath = modulePath.slice(0, -'.ts'.length);\n }\n if (preferFileExtension) {\n modulePath += preferFileExtension;\n } else if (modulePath.endsWith('/index')) {\n modulePath = modulePath.slice(0, -'/index'.length);\n }\n\n return [2, parentCount, modulePath];\n};\n","import type { RenderContext, Renderer } from '@hey-api/codegen-core';\nimport ts from 'typescript';\n\nimport { $ } from '~/ts-dsl';\n\nimport type {\n ModuleExport,\n ModuleImport,\n SortGroup,\n SortKey,\n SortModule,\n} from './utils';\nimport { moduleSortKey, nodeToString } from './utils';\n\nexport class TypeScriptRenderer implements Renderer {\n /**\n * Whether `export * from 'module'` should be used when possible instead of named exports.\n *\n * @private\n */\n private preferExportAll: boolean;\n /**\n * Controls whether imports/exports include a file extension (e.g., '.ts' or '.js').\n *\n * @private\n */\n private preferFileExtension: string;\n /**\n * Optional function to transform module specifiers.\n *\n * @private\n */\n private resolveModuleName?: (moduleName: string) => string | undefined;\n\n constructor(\n args: {\n preferExportAll?: boolean;\n preferFileExtension?: string;\n resolveModuleName?: (moduleName: string) => string | undefined;\n } = {},\n ) {\n this.preferExportAll = args.preferExportAll ?? false;\n this.preferFileExtension = args.preferFileExtension ?? '';\n this.resolveModuleName = args.resolveModuleName;\n }\n\n render(ctx: RenderContext): string {\n let text = '';\n const header = '// This file is auto-generated by @hey-api/openapi-ts';\n text += `${header}\\n`;\n\n let imports = '';\n for (const group of this.getImports(ctx)) {\n if (imports) imports += '\\n';\n for (const imp of group) {\n imports += `${nodeToString(this.renderImport(ctx, imp))}\\n`;\n }\n }\n text = `${text}${text && imports ? '\\n' : ''}${imports}`;\n\n let nodes = '';\n for (const node of ctx.file.nodes) {\n if (nodes) nodes += '\\n';\n // @ts-expect-error\n nodes += `${nodeToString(node.toAst(ctx.astContext))}\\n`;\n }\n text = `${text}${text && nodes ? '\\n' : ''}${nodes}`;\n\n let exports = '';\n for (const group of this.getExports(ctx)) {\n if ((!exports && nodes) || exports) exports += '\\n';\n for (const exp of group) {\n exports += `${nodeToString(this.renderExport(ctx, exp))}\\n`;\n }\n }\n text = `${text}${text && exports ? '\\n' : ''}${exports}`;\n\n return text;\n }\n\n supports(ctx: RenderContext): boolean {\n return ctx.file.language === 'typescript';\n }\n\n private getExports(\n ctx: RenderContext,\n ): ReadonlyArray<ReadonlyArray<ModuleExport>> {\n type ModuleEntry = {\n group: ModuleExport;\n sortKey: SortKey;\n };\n\n const groups = new Map<SortGroup, Map<SortModule, ModuleEntry>>();\n\n for (const exp of ctx.file.exports) {\n const sortKey = moduleSortKey({\n file: ctx.file,\n fromFile: exp.from,\n preferFileExtension: this.preferFileExtension,\n root: ctx.project.root,\n });\n const modulePath = this.resolveModuleName?.(sortKey[2]) ?? sortKey[2];\n const [groupIndex] = sortKey;\n\n if (!groups.has(groupIndex)) groups.set(groupIndex, new Map());\n const moduleMap = groups.get(groupIndex)!;\n\n if (!moduleMap.has(modulePath)) {\n moduleMap.set(modulePath, {\n group: {\n canExportAll: exp.canExportAll,\n exports: exp.exports,\n isTypeOnly: exp.isTypeOnly,\n modulePath,\n namespaceExport: exp.namespaceExport,\n },\n sortKey,\n });\n }\n }\n\n const exports: Array<Array<ModuleExport>> = Array.from(groups.entries())\n .sort((a, b) => a[0] - b[0])\n .map(([, moduleMap]) => {\n const entries = Array.from(moduleMap.values());\n\n entries.sort((a, b) => {\n const d = a.sortKey[1] - b.sortKey[1];\n return d !== 0\n ? d\n : a.group.modulePath.localeCompare(b.group.modulePath);\n });\n\n return entries.map((e) => {\n const group = e.group;\n if (group.namespaceExport) {\n group.exports = [];\n } else {\n const isTypeOnly = !group.exports.find((exp) => !exp.isTypeOnly);\n if (isTypeOnly) {\n group.isTypeOnly = true;\n for (const exp of group.exports) {\n exp.isTypeOnly = false;\n }\n }\n group.exports.sort((a, b) =>\n a.exportedName.localeCompare(b.exportedName),\n );\n }\n return group;\n });\n });\n\n return exports;\n }\n\n private getImports(\n ctx: RenderContext,\n ): ReadonlyArray<ReadonlyArray<ModuleImport>> {\n type ModuleEntry = {\n group: ModuleImport;\n sortKey: SortKey;\n };\n\n const groups = new Map<SortGroup, Map<SortModule, ModuleEntry>>();\n\n for (const imp of ctx.file.imports) {\n const sortKey = moduleSortKey({\n file: ctx.file,\n fromFile: imp.from,\n preferFileExtension: this.preferFileExtension,\n root: ctx.project.root,\n });\n const modulePath = this.resolveModuleName?.(sortKey[2]) ?? sortKey[2];\n const [groupIndex] = sortKey;\n\n if (!groups.has(groupIndex)) groups.set(groupIndex, new Map());\n const moduleMap = groups.get(groupIndex)!;\n\n if (!moduleMap.has(modulePath)) {\n moduleMap.set(modulePath, {\n group: {\n imports: [],\n isTypeOnly: false,\n modulePath,\n },\n sortKey,\n });\n }\n\n const entry = moduleMap.get(modulePath)!;\n const group = entry.group;\n\n if (imp.namespaceImport) {\n group.isTypeOnly = imp.isTypeOnly;\n group.namespaceImport = imp.namespaceImport;\n } else {\n group.imports.push(...imp.imports);\n }\n }\n\n const imports: Array<Array<ModuleImport>> = Array.from(groups.entries())\n .sort((a, b) => a[0] - b[0])\n .map(([, moduleMap]) => {\n const entries = Array.from(moduleMap.values());\n\n entries.sort((a, b) => {\n const d = a.sortKey[1] - b.sortKey[1];\n return d !== 0\n ? d\n : a.group.modulePath.localeCompare(b.group.modulePath);\n });\n\n return entries.map((e) => {\n const group = e.group;\n if (group.namespaceImport) {\n group.imports = [];\n } else {\n const isTypeOnly = !group.imports.find((imp) => !imp.isTypeOnly);\n if (isTypeOnly) {\n group.isTypeOnly = true;\n for (const imp of group.imports) {\n imp.isTypeOnly = false;\n }\n }\n group.imports.sort((a, b) =>\n a.localName.localeCompare(b.localName),\n );\n }\n return group;\n });\n });\n\n return imports;\n }\n\n private renderExport(\n ctx: RenderContext,\n group: ModuleExport,\n ): ts.ExportDeclaration {\n const specifiers = group.exports.map((exp) => {\n const specifier = ts.factory.createExportSpecifier(\n exp.isTypeOnly,\n exp.sourceName !== exp.exportedName\n ? $.id(exp.sourceName).toAst()\n : undefined,\n $.id(exp.exportedName).toAst(),\n );\n return specifier;\n });\n const exportClause = group.namespaceExport\n ? ts.factory.createNamespaceExport($.id(group.namespaceExport).toAst())\n : (!group.canExportAll || !this.preferExportAll) && specifiers.length\n ? ts.factory.createNamedExports(specifiers)\n : undefined;\n return ts.factory.createExportDeclaration(\n undefined,\n group.isTypeOnly,\n exportClause,\n $.literal(group.modulePath).toAst(ctx.astContext),\n );\n }\n\n private renderImport(\n ctx: RenderContext,\n group: ModuleImport,\n ): ts.ImportDeclaration {\n const specifiers = group.imports.map((imp) => {\n const specifier = ts.factory.createImportSpecifier(\n imp.isTypeOnly,\n imp.sourceName !== imp.localName\n ? $.id(imp.sourceName).toAst()\n : undefined,\n $.id(imp.localName).toAst(),\n );\n return specifier;\n });\n const importClause = ts.factory.createImportClause(\n group.isTypeOnly,\n undefined, // TODO: default imports\n group.namespaceImport\n ? ts.factory.createNamespaceImport($.id(group.namespaceImport).toAst())\n : ts.factory.createNamedImports(specifiers),\n );\n return ts.factory.createImportDeclaration(\n undefined,\n importClause,\n $.literal(group.modulePath).toAst(ctx.astContext),\n );\n }\n}\n","import type ts from 'typescript';\n\nimport { 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 { BlockTsDsl } from './stmt/block';\nimport { IfTsDsl } from './stmt/if';\nimport { ReturnTsDsl } from './stmt/return';\nimport { StmtTsDsl } from './stmt/stmt';\nimport { ThrowTsDsl } from './stmt/throw';\nimport { TryTsDsl } from './stmt/try';\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';\nimport { LazyTsDsl } from './utils/lazy';\n\nconst tsDsl = {\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 statement block (`{ ... }`). */\n block: (...args: ConstructorParameters<typeof BlockTsDsl>) =>\n new BlockTsDsl(...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 lazy, context-aware node with deferred evaluation. */\n lazy: <T extends ts.Node>(\n ...args: ConstructorParameters<typeof LazyTsDsl<T>>\n ) => new LazyTsDsl<T>(...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 try/catch/finally statement. */\n try: (...args: ConstructorParameters<typeof TryTsDsl>) =>\n new TryTsDsl(...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 `typeof` expression (e.g. `typeof value`). */\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 tsDsl,\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 `tsDsl` object for constructing more specific nodes.\n */\n $: typeof $;\n};\n\nexport type { MaybeTsDsl, TypeTsDsl } from './base';\nexport { TsDsl } from './base';\nexport { TypeScriptRenderer } from './render/typescript';\nexport { keywords } from './utils/keywords';\nexport { regexp } from './utils/regexp';\nexport { reserved } from './utils/reserved';\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';\nimport { refs } from '@hey-api/codegen-core';\n\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 { $ } from '~/ts-dsl';\nimport { stringCase } from '~/utils/stringCase';\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 plugin,\n value,\n}: {\n plugin: HeyApiSdkPlugin['Instance'];\n value: string;\n}) => {\n const name = stringCase({ case: 'PascalCase', value });\n return (\n (typeof plugin.config.classNameBuilder === 'string'\n ? plugin.config.classNameBuilder.replace('{{name}}', name)\n : plugin.config.classNameBuilder(name)) || name\n );\n};\n\nexport const operationMethodName = ({\n operation,\n plugin,\n}: {\n operation: IR.OperationObject;\n plugin: HeyApiSdkPlugin['Instance'];\n}) => plugin.config.methodNameBuilder?.(operation) || operation.id;\n\n/**\n * Returns a list of classes where this operation appears in the generated SDK.\n */\nexport const operationClasses = ({\n operation,\n plugin,\n}: {\n operation: IR.OperationObject;\n plugin: HeyApiSdkPlugin['Instance'];\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 >= 2) {\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]\n : (operation.tags ?? ['default']);\n\n for (const rootClass of rootClasses) {\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: operationClassName({ plugin, value: className || rootClass }),\n methodName: methodName || operationMethodName({ operation, plugin }),\n path: path.map((value) => operationClassName({ plugin, value })),\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}): ReturnType<typeof $.type> => {\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 return $.type(symbolOptions)\n .generic(nuxtTypeComposable)\n .generic(isDataAllowed ? (symbolDataType ?? 'unknown') : 'never')\n .generic(symbolResponseType ?? 'unknown')\n .generic(nuxtTypeDefault);\n }\n\n // TODO: refactor this to be more generic, works for now\n if (throwOnError) {\n return $.type(symbolOptions)\n .generic(isDataAllowed ? (symbolDataType ?? 'unknown') : 'never')\n .generic(throwOnError);\n }\n return $.type(symbolOptions).$if(!isDataAllowed || symbolDataType, (t) =>\n t.generic(isDataAllowed ? symbolDataType! : 'never'),\n );\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: refs({\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\n const symbolErrorType = plugin.querySymbol({\n category: 'type',\n resource: 'operation',\n resourceId: operation.id,\n role: isNuxtClient ? 'error' : 'errors',\n });\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);\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);\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));\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).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);\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(\n $.type.or(symbolResponseType ?? 'unknown', nuxtTypeDefault),\n )\n .generic(symbolErrorType ?? 'unknown')\n .generic(nuxtTypeDefault),\n (f) =>\n f\n .generic(symbolResponseType ?? 'unknown')\n .generic(symbolErrorType ?? 'unknown')\n .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\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({ operation, plugin: sdkPlugin });\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 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)\n .export()\n .$if(currentClass.root, (c) =>\n c.decorator(\n symbolInjectable,\n $.object().prop('providedIn', $.literal('root')),\n ),\n )\n .do(...currentClass.nodes);\n plugin.node(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 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.node(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));\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\n return $.method(methodName)\n .public()\n .$if(createOperationComment(operation), (c, v) => c.doc(v))\n .param('options', (p) =>\n p.required(isRequiredOptions).type(\n $.type(symbolOptions)\n .generic(symbolDataType ?? 'unknown')\n .generic('ThrowOnError'),\n ),\n )\n .generic('ThrowOnError', (g) => g.extends('boolean').default(false))\n .returns($.type(symbolHttpRequest).generic('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\n return $.const(symbol)\n .export()\n .$if(createOperationComment(operation), (c, v) => c.doc(v))\n .assign(\n $.func()\n .param('options', (p) =>\n p.required(isRequiredOptions).type(\n $.type(symbolOptions)\n .generic(symbolDataType ?? 'unknown')\n .generic('ThrowOnError'),\n ),\n )\n .generic('ThrowOnError', (g) => g.extends('boolean').default(false))\n .returns($.type(symbolHttpRequest).generic('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({ operation, plugin: sdkPlugin });\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 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)\n .export()\n .$if(currentClass.root, (c) =>\n c.decorator(\n symbolInjectable,\n $.object().prop('providedIn', $.literal('root')),\n ),\n )\n .do(...currentClass.nodes);\n plugin.node(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 name: plugin.config.httpResources.methodNameBuilder(operation),\n });\n const node = generateAngularResourceFunction({\n isRequiredOptions,\n operation,\n plugin,\n symbol,\n });\n plugin.node(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\n if (plugin.config.httpRequests.asClass) {\n // For class-based request methods, use inject and class hierarchy\n const classes = operationClasses({ operation, plugin: sdkPlugin });\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).call(symbolClass);\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)\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(symbolResponseType ?? 'unknown');\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)\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).call('opts'))\n .otherwise($.id('undefined')),\n ),\n ),\n )\n .generic(symbolResponseType ?? 'unknown');\n }\n\n // Fallback return (should not reach here)\n return $(symbolHttpResource).call(\n $.func()\n .do($.return($.id('undefined')))\n .generic(symbolResponseType ?? 'unknown'),\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\n return $.method(methodName)\n .public()\n .$if(createOperationComment(operation), (c, v) => c.doc(v))\n .param('options', (p) =>\n p.required(isRequiredOptions).type(\n $.type.func().returns(\n $.type.or(\n $.type(symbolOptions)\n .generic(symbolDataType ?? 'unknown')\n .generic('ThrowOnError'),\n $.type('undefined'),\n ),\n ),\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\n return $.const(symbol)\n .export()\n .$if(createOperationComment(operation), (c, v) => c.doc(v))\n .assign(\n $.func()\n .param('options', (p) =>\n p.required(isRequiredOptions).type(\n $.type.func().returns(\n $.type.or(\n $.type(symbolOptions)\n .generic(symbolDataType ?? 'unknown')\n .generic('ThrowOnError'),\n $.type('undefined'),\n ),\n ),\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)\n .call(defaultVals.hasProps() ? defaultVals : undefined)\n .generic(symbolClientOptions),\n ];\n\n const symbolClient = plugin.registerSymbol({\n meta: {\n category: 'client',\n },\n name: 'client',\n });\n const statement = $.const(symbolClient)\n .export()\n .assign(\n $(symbolCreateClient).$if(\n symbolCreateClientConfig,\n (c, s) => c.call($(s).call(...createConfigParameters)),\n (c) => c.call(...createConfigParameters),\n ),\n );\n plugin.node(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 name: 'CreateClientConfig',\n });\n\n const typeCreateClientConfig = $.type\n .alias(symbolCreateClientConfig)\n .export()\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.extends(symbolDefaultClientOptions).default(symbolClientOptions),\n )\n .type(\n $.type\n .func()\n .param('override', (p) =>\n p\n .optional()\n .type(\n $.type(symbolConfig).generic(\n $.type.and(symbolDefaultClientOptions, 'T'),\n ),\n ),\n )\n .returns(\n $.type(symbolConfig).generic(\n $.type.and(\n $.type('Required').generic(symbolDefaultClientOptions),\n 'T',\n ),\n ),\n ),\n );\n plugin.node(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 { 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 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 unknown 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 unknown 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 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 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)\n .export()\n .assign(\n $(\n $.fromValue(obj, {\n layout: 'pretty',\n }),\n ).as('const'),\n );\n plugin.node(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 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)\n .export()\n .assign(\n $(\n $.fromValue(obj, {\n layout: 'pretty',\n }),\n ).as('const'),\n );\n plugin.node(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 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)\n .export()\n .assign(\n $(\n $.fromValue(obj, {\n layout: 'pretty',\n }),\n ).as('const'),\n );\n plugin.node(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 plugin,\n sdkSymbol,\n symbol,\n}: {\n plugin: HeyApiSdkPlugin['Instance'];\n sdkSymbol: Symbol;\n symbol: Symbol;\n}): TsDsl => {\n const symbolDefaultKey = plugin.symbol('defaultKey');\n const symbolInstances = plugin.symbol('instances');\n return $.class(symbol)\n .generic('T')\n .field(symbolDefaultKey, (f) =>\n f.private().readonly().assign($.literal('default')),\n )\n .newline()\n .field(symbolInstances, (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(symbolInstances)\n .attr('get')\n .call($('key').coalesce($('this').attr(symbolDefaultKey))),\n ),\n $.if($.not('instance')).do(\n $.throw('Error').message(\n $.template('No SDK client found. Create one with \"new ')\n .add(sdkSymbol)\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(symbolInstances)\n .attr('set')\n .call($('key').coalesce($('this').attr(symbolDefaultKey)), '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)\n .field('client', (f) => f.protected().type(symbolClient))\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),\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!)),\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({ operation, plugin });\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 const methodName = entry.methodName;\n if (currentClass.methods.has(methodName)) return;\n currentClass.methods.add(methodName);\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(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 }),\n )\n .default($.type.literal('$fetch')),\n )\n .generic(nuxtTypeDefault, (t) =>\n t.$if(symbolResponse, (t, s) => t.extends(s).default(s)),\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 sdkClasses.set(symbolCurrentClass.meta!.resourceId!, currentClass);\n });\n }\n },\n {\n order: 'declarations',\n },\n );\n\n const clientIndex = plugin.config.instance ? plugin.node(null) : undefined;\n const symbolClient =\n clientIndex !== undefined\n ? plugin.symbol('HeyApiClient', {\n meta: {\n category: 'utility',\n resource: 'class',\n resourceId: 'HeyApiClient',\n tool: 'sdk',\n },\n })\n : undefined;\n const registryIndex = plugin.config.instance ? plugin.node(null) : undefined;\n\n const generateClass = (currentClass: SdkClassEntry) => {\n const resourceId = currentClass.className;\n\n if (generatedClasses.has(resourceId)) return;\n generatedClasses.add(resourceId);\n\n if (clientIndex !== undefined && symbolClient && !symbolClient.node) {\n const node = createClientClass({ plugin, symbol: symbolClient });\n plugin.node(node, clientIndex);\n }\n\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 if (currentClass.nodes.length > 0) {\n currentClass.nodes.push($.newline());\n }\n\n if (plugin.config.instance) {\n const privateName = plugin.symbol(`_${memberName}`);\n const privateNode = $.field(privateName, (f) =>\n f.private().optional().type(refChildClass),\n );\n currentClass.nodes.push(privateNode);\n const getterNode = $.getter(memberName, (g) =>\n g.returns(refChildClass).do(\n $('this')\n .attr(privateName)\n .nullishAssign(\n $.new(refChildClass).args(\n $.object().prop('client', $('this').attr('client')),\n ),\n )\n .return(),\n ),\n );\n currentClass.nodes.push(getterNode);\n } else {\n const subClassReferenceNode = plugin.isSymbolRegistered(\n refChildClass.id,\n )\n ? $.field(memberName, (f) => f.static().assign($(refChildClass)))\n : $.getter(memberName, (g) =>\n g.public().static().do($.return(refChildClass)),\n );\n currentClass.nodes.push(subClassReferenceNode);\n }\n }\n\n const symbol = plugin.symbol(resourceId, {\n meta: {\n category: 'utility',\n resource: 'class',\n resourceId,\n tool: 'sdk',\n },\n });\n\n if (currentClass.root && registryIndex !== undefined) {\n const symClient = plugin.getSymbol({ category: 'client' });\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),\n )\n .prop('key', (p) => p.optional().type('string')),\n ),\n )\n .do(\n $('super').call('args'),\n $(symbol)\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 symbolRegistry = plugin.symbol('HeyApiRegistry', {\n meta: {\n category: 'utility',\n resource: 'class',\n resourceId: 'HeyApiRegistry',\n tool: 'sdk',\n },\n });\n const node = createRegistryClass({\n plugin,\n sdkSymbol: symbol,\n symbol: symbolRegistry,\n });\n plugin.node(node, registryIndex);\n const registryNode = $.field(registryName, (f) =>\n f\n .public()\n .static()\n .readonly()\n .assign($.new(symbolRegistry).generic(symbol)),\n );\n currentClass.nodes.unshift(registryNode, $.newline());\n }\n\n const node = $.class(symbol)\n .export()\n .extends(symbolClient)\n .$if(isAngularClient && currentClass.root, (c) =>\n c.decorator(\n plugin.referenceSymbol({\n category: 'external',\n resource: '@angular/core.Injectable',\n }),\n $.object().prop('providedIn', $.literal('root')),\n ),\n )\n .do(...currentClass.nodes);\n plugin.node(node);\n };\n\n for (const sdkClass of sdkClasses.values()) {\n generateClass(sdkClass);\n }\n};\n","import { getClientPlugin } from '~/plugins/@hey-api/client-core/utils';\nimport {\n createOperationComment,\n isOperationOptionsRequired,\n} from '~/plugins/shared/utils/operation';\nimport { $ } from '~/ts-dsl';\n\nimport type { HeyApiSdkPlugin } from '../types';\nimport { nuxtTypeComposable, nuxtTypeDefault } from './constants';\nimport {\n operationMethodName,\n operationParameters,\n operationStatements,\n} from './operation';\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.symbol(operationMethodName({ operation, plugin }), {\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 });\n const node = $.const(symbol)\n .export()\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 }),\n )\n .default($.type.literal('$fetch')),\n )\n .generic(nuxtTypeDefault, (g) =>\n g.$if(\n symbolResponse,\n (t, s) => t.extends(s).default(s),\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.node(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 meta: {\n category: 'type',\n resource: 'client-options',\n tool: 'sdk',\n },\n name: 'Options',\n });\n\n const typeOptions = $.type\n .alias(symbolOptions)\n .export()\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 }),\n )\n .default($.type.literal('$fetch')),\n )\n .generic('TData', (g) =>\n g.extends(symbolTDataShape).default(symbolTDataShape),\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.extends(symbolTDataShape).default(symbolTDataShape),\n )\n .generic('ThrowOnError', (g) =>\n g.extends('boolean').default('boolean'),\n ),\n )\n .type(\n $.type.and(\n $.type(symbolClientOptions).$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),\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.node(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: '',\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 = '';\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 type 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 { 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 isNodeReturnStatement = (node: Expr) => node['~dsl'] === 'ReturnTsDsl';\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(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> => {\n if (schema.$ref) {\n const query: SymbolMeta = {\n category: 'transform',\n resource: 'definition',\n resourceId: schema.$ref,\n };\n const symbol =\n plugin.getSymbol(query) ??\n plugin.symbol(\n buildName({\n config: {\n case: 'camelCase',\n name: '{{name}}SchemaResponseTransformer',\n },\n name: refToName(schema.$ref),\n }),\n {\n meta: query,\n },\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 if (!symbol.node && !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).assign(\n // TODO: parser - add types, generate types without transforms\n $.func()\n .param(dataVariableName, (p) => p.type('any'))\n .do(...nodes),\n );\n plugin.node(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 if (symbol.node || buildingSymbols.has(symbol.id)) {\n const ref = plugin.referenceSymbol(query);\n const callExpression = $(ref).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 // TODO: remove\n // Ensure the map callback has a return statement for the item\n const mapCallbackStatements: Array<Expr> = nodes;\n const hasReturnStatement = mapCallbackStatements.some((stmt) =>\n isNodeReturnStatement(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<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(...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<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($.if('item').do(...nodes), $.return('item'));\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 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)\n .export()\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))\n .do(...nodes),\n );\n plugin.node(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 { IR } from '~/ir/types';\nimport { buildName } from '~/openApi/shared/utils/name';\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 nodeIndex,\n plugin,\n servers,\n}: {\n nodeIndex: number;\n plugin: HeyApiTypeScriptPlugin['Instance'];\n servers: ReadonlyArray<IR.ServerObject>;\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 symbol = plugin.symbol(\n buildName({\n config: {\n case: plugin.config.case,\n },\n name: 'ClientOptions',\n }),\n {\n meta: {\n category: 'type',\n resource: 'client',\n role: 'options',\n tool: 'typescript',\n },\n },\n );\n\n const node = $.type\n .alias(symbol)\n .export()\n .type(\n $.type\n .object()\n .prop(getClientBaseUrlKey(plugin.context.config), (p) =>\n p.type($.type.or(...types)),\n ),\n );\n plugin.node(node, nodeIndex);\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 { fromRef } from '@hey-api/codegen-core';\n\nimport type { IR } from '~/ir/types';\nimport { buildName } from '~/openApi/shared/utils/name';\nimport { createSchemaComment } from '~/plugins/shared/utils/schema';\nimport type { MaybeTsDsl, TypeTsDsl } from '~/ts-dsl';\nimport { $, regexp } from '~/ts-dsl';\nimport { pathToJsonPointer, refToName } from '~/utils/ref';\nimport { stringCase } from '~/utils/stringCase';\n\nimport type { HeyApiTypeScriptPlugin } from '../types';\nimport type { IrSchemaToAstOptions } 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 regexp.number.lastIndex = 0;\n // TypeScript enum keys cannot be numbers\n if (\n regexp.number.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 state,\n type,\n}: IrSchemaToAstOptions & {\n schema: IR.SchemaObject;\n type: MaybeTsDsl<TypeTsDsl>;\n}) => {\n const $ref = pathToJsonPointer(fromRef(state.path));\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 symbolObject = plugin.registerSymbol({\n meta: {\n category: 'utility',\n path: fromRef(state.path),\n resource: 'definition',\n resourceId: $ref,\n tags: fromRef(state.tags),\n tool: 'typescript',\n },\n name: buildName({\n config: plugin.config.definitions,\n name: refToName($ref),\n }),\n });\n const objectNode = $.const(symbolObject)\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 plugin.node(objectNode);\n\n const symbol = plugin.registerSymbol({\n meta: {\n category: 'type',\n path: fromRef(state.path),\n resource: 'definition',\n resourceId: $ref,\n tags: fromRef(state.tags),\n tool: 'typescript',\n },\n name: buildName({\n config: plugin.config.definitions,\n name: refToName($ref),\n }),\n });\n const node = $.type\n .alias(symbol)\n .export()\n .$if(createSchemaComment(schema), (t, v) => t.doc(v))\n .type(\n $.type(symbol).idx($.type(symbol).typeofType().keyof()).typeofType(),\n );\n plugin.node(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 symbol = plugin.registerSymbol({\n meta: {\n category: 'type',\n path: fromRef(state.path),\n resource: 'definition',\n resourceId: $ref,\n tags: fromRef(state.tags),\n tool: 'typescript',\n },\n name: buildName({\n config: plugin.config.definitions,\n name: refToName($ref),\n }),\n });\n const enumNode = $.enum(symbol)\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.node(enumNode);\n return;\n }\n }\n }\n\n const symbol = plugin.registerSymbol({\n meta: {\n category: 'type',\n path: fromRef(state.path),\n resource: 'definition',\n resourceId: $ref,\n tags: fromRef(state.tags),\n tool: 'typescript',\n },\n name: buildName({\n config: plugin.config.definitions,\n name: refToName($ref),\n }),\n });\n const node = $.type\n .alias(symbol)\n .export()\n .$if(createSchemaComment(schema), (t, v) => t.doc(v))\n .type(type);\n plugin.node(node);\n};\n","import { fromRef } from '@hey-api/codegen-core';\n\nimport { 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 meta: {\n category: 'type',\n path: fromRef(state.path),\n resource: 'operation',\n resourceId: operation.id,\n role: 'data',\n tags: fromRef(state.tags),\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)\n .export()\n .type(\n irSchemaToAst({\n plugin,\n schema: data,\n state,\n }),\n );\n plugin.node(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 meta: {\n category: 'type',\n path: fromRef(state.path),\n resource: 'operation',\n resourceId: operation.id,\n role: 'errors',\n tags: fromRef(state.tags),\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)\n .export()\n .type(\n irSchemaToAst({\n plugin,\n schema: errors,\n state,\n }),\n );\n plugin.node(node);\n\n if (error) {\n const symbol = plugin.registerSymbol({\n meta: {\n category: 'type',\n path: fromRef(state.path),\n resource: 'operation',\n resourceId: operation.id,\n role: 'error',\n tags: fromRef(state.tags),\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)\n .export()\n .type($.type(symbolErrors).idx($.type(symbolErrors).keyof()));\n plugin.node(node);\n }\n }\n\n if (responses) {\n const symbolResponses = plugin.registerSymbol({\n meta: {\n category: 'type',\n path: fromRef(state.path),\n resource: 'operation',\n resourceId: operation.id,\n role: 'responses',\n tags: fromRef(state.tags),\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)\n .export()\n .type(\n irSchemaToAst({\n plugin,\n schema: responses,\n state,\n }),\n );\n plugin.node(node);\n\n if (response) {\n const symbol = plugin.registerSymbol({\n meta: {\n category: 'type',\n path: fromRef(state.path),\n resource: 'operation',\n resourceId: operation.id,\n role: 'response',\n tags: fromRef(state.tags),\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)\n .export()\n .type($.type(symbolResponses).idx($.type(symbolResponses).keyof()));\n plugin.node(node);\n }\n }\n};\n","import type { Symbol } from '@hey-api/codegen-core';\nimport { fromRef } from '@hey-api/codegen-core';\n\nimport 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}): Symbol => {\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 meta: {\n category: 'type',\n path: fromRef(state.path),\n resource: 'webhook',\n resourceId: operation.id,\n role: 'data',\n tags: fromRef(state.tags),\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)\n .export()\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.node(node);\n\n data.properties.body = { symbolRef: symbolWebhookPayload };\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 meta: {\n category: 'type',\n path: fromRef(state.path),\n resource: 'webhook',\n resourceId: operation.id,\n role: 'data',\n tags: fromRef(state.tags),\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)\n .export()\n .type(\n irSchemaToAst({\n plugin,\n schema: data,\n state,\n }),\n );\n plugin.node(node);\n\n return symbolWebhookRequest;\n};\n\nexport const webhookToType = ({\n operation,\n plugin,\n state,\n}: IrSchemaToAstOptions & {\n operation: IR.OperationObject;\n}): Symbol => {\n const symbol = operationToDataType({ operation, plugin, state });\n return symbol;\n\n // don't handle webhook responses for now, users only need requestBody\n};\n","import { fromRef, ref } from '@hey-api/codegen-core';\n\nimport { deduplicateSchema } from '~/ir/schema';\nimport type { SchemaWithType } from '~/plugins';\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: ref([...fromRef(state.path), '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 { fromRef, ref } from '@hey-api/codegen-core';\n\nimport type { IR } from '~/ir/types';\nimport type { SchemaWithType } from '~/plugins';\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: ref([...fromRef(state.path), '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 meta: queryTypeId,\n name: 'TypeID',\n });\n const nodeTypeId = $.type\n .alias(symbolTypeId)\n .export()\n .generic('T', (g) => g.extends('string'))\n .type(\n $.type.template().add($.type('T')).add('_').add($.type('string')),\n );\n plugin.node(nodeTypeId);\n }\n\n const symbolTypeId = plugin.referenceSymbol(queryTypeId);\n const symbolTypeName = plugin.registerSymbol({\n meta: query,\n name: stringCase({\n case: plugin.config.case,\n value: `${type}_id`,\n }),\n });\n const node = $.type\n .alias(symbolTypeName)\n .export()\n .type($.type(symbolTypeId).generic($.type.literal(type)));\n plugin.node(node);\n }\n const symbol = plugin.referenceSymbol(query);\n return $.type(symbol);\n }\n }\n\n return $.type('string');\n};\n","import { fromRef, ref } from '@hey-api/codegen-core';\n\nimport type { SchemaWithType } from '~/plugins';\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: ref([...fromRef(state.path), '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 type { Symbol } from '@hey-api/codegen-core';\nimport { refs } 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 type { MaybeTsDsl, TypeTsDsl } from '~/ts-dsl';\nimport { $ } from '~/ts-dsl';\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 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.symbolRef) {\n const baseType = $.type(schema.symbolRef);\n if (schema.omit && schema.omit.length > 0) {\n // Render as Omit<Type, 'prop1' | 'prop2'>\n const omittedKeys =\n schema.omit.length === 1\n ? $.type.literal(schema.omit[0]!)\n : $.type.or(...schema.omit.map((key) => $.type.literal(key)));\n return $.type('Omit').generics(baseType, omittedKeys);\n }\n return baseType;\n }\n\n if (schema.$ref) {\n const symbol = plugin.referenceSymbol({\n category: 'type',\n resource: 'definition',\n resourceId: schema.$ref,\n });\n const baseType = $.type(symbol);\n if (schema.omit && schema.omit.length > 0) {\n // Render as Omit<Type, 'prop1' | 'prop2'>\n const omittedKeys =\n schema.omit.length === 1\n ? $.type.literal(schema.omit[0]!)\n : $.type.or(...schema.omit.map((key) => $.type.literal(key)));\n return $.type('Omit').generics(baseType, omittedKeys);\n }\n return baseType;\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 exportType({\n plugin,\n schema,\n state,\n type,\n });\n};\n\nexport const handlerV1: HeyApiTypeScriptPlugin['Handler'] = ({ plugin }) => {\n // reserve node for ClientOptions\n const nodeClientIndex = plugin.node(null);\n // reserve node for Webhooks\n const nodeWebhooksIndex = plugin.node(null);\n\n const servers: Array<IR.ServerObject> = [];\n const webhooks: Array<Symbol> = [];\n\n plugin.forEach(\n 'operation',\n 'parameter',\n 'requestBody',\n 'schema',\n 'server',\n 'webhook',\n (event) => {\n const state = refs<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 webhooks.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({ nodeIndex: nodeClientIndex, plugin, servers });\n\n if (webhooks.length > 0) {\n const symbol = plugin.symbol(\n buildName({\n config: {\n case: plugin.config.case,\n },\n name: 'Webhooks',\n }),\n {\n meta: {\n category: 'type',\n resource: 'webhook',\n tool: 'typescript',\n variant: 'container',\n },\n },\n );\n const node = $.type\n .alias(symbol)\n .export()\n .type($.type.or(...webhooks));\n plugin.node(node, nodeWebhooksIndex);\n }\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';\nimport { $ } from '~/ts-dsl';\n\nimport type { PiniaColadaPlugin } from './types';\n\nexport const useTypeData = ({\n operation,\n plugin,\n}: {\n operation: IR.OperationObject;\n plugin: PiniaColadaPlugin['Instance'];\n}): ReturnType<typeof $.type> => {\n const pluginSdk = plugin.getPluginOrThrow('@hey-api/sdk');\n return operationOptionsType({ operation, plugin: pluginSdk });\n};\n\nexport const useTypeError = ({\n operation,\n plugin,\n}: {\n operation: IR.OperationObject;\n plugin: PiniaColadaPlugin['Instance'];\n}): ReturnType<typeof $.type> => {\n const client = getClientPlugin(plugin.context.config);\n const symbolErrorType = plugin.querySymbol({\n category: 'type',\n resource: 'operation',\n resourceId: operation.id,\n role: 'error',\n });\n const symbolError = symbolErrorType || 'Error';\n if (client.name === '@hey-api/client-axios') {\n const symbol = plugin.referenceSymbol({\n category: 'external',\n resource: 'axios.AxiosError',\n });\n return $.type(symbol).generic(symbolError);\n }\n return $.type(symbolError);\n};\n\nexport const useTypeResponse = ({\n operation,\n plugin,\n}: {\n operation: IR.OperationObject;\n plugin: PiniaColadaPlugin['Instance'];\n}): ReturnType<typeof $.type> => {\n const symbolResponseType = plugin.querySymbol({\n category: 'type',\n resource: 'operation',\n resourceId: operation.id,\n role: 'response',\n });\n return $.type(symbolResponseType ?? 'unknown');\n};\n","import type { IR } from '~/ir/types';\nimport { $ } from '~/ts-dsl';\n\nimport type { PiniaColadaPlugin } from './types';\nimport { useTypeData } from './useType';\n\nexport const getPublicTypeData = ({\n isNuxtClient,\n operation,\n plugin,\n}: {\n isNuxtClient: boolean;\n operation: IR.OperationObject;\n plugin: PiniaColadaPlugin['Instance'];\n}) => {\n const typeData = useTypeData({ operation, plugin });\n return isNuxtClient\n ? $.type('Omit').generic(typeData).generic('composable')\n : typeData;\n};\n","import type { IR } from '~/ir/types';\nimport { buildName } from '~/openApi/shared/utils/name';\nimport { getClientPlugin } from '~/plugins/@hey-api/client-core/utils';\nimport { createOperationComment } from '~/plugins/shared/utils/operation';\nimport { $ } from '~/ts-dsl';\n\nimport { handleMeta } from './meta';\nimport type { PiniaColadaPlugin } from './types';\nimport { 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: ReturnType<typeof $.expr | typeof $.call | typeof $.attr>;\n}): void => {\n const symbolMutationOptionsType = plugin.referenceSymbol({\n category: 'external',\n resource: `${plugin.name}.UseMutationOptions`,\n });\n\n const client = getClientPlugin(plugin.context.config);\n const isNuxtClient = client.name === '@hey-api/client-nuxt';\n\n const typeData = getPublicTypeData({ isNuxtClient, operation, plugin });\n\n const options = plugin.symbol('options');\n const fnOptions = plugin.symbol('vars');\n\n const awaitSdkFn = $.lazy(() =>\n $(queryFn)\n .call(\n $.object()\n .pretty()\n .spread(options)\n .spread(fnOptions)\n .prop('throwOnError', $.literal(true)),\n )\n .await(),\n );\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) =>\n f.type($.type('Partial').generic(typeData)),\n ),\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 name: buildName({\n config: plugin.config.mutationOptions,\n name: operation.id,\n }),\n });\n const statement = $.const(symbolMutationOptions)\n .export()\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($.type('Partial').generic(typeData)),\n )\n .returns(\n $.type(symbolMutationOptionsType)\n .generic(useTypeResponse({ operation, plugin }))\n .generic(typeData)\n .generic(useTypeError({ operation, plugin })),\n )\n .do($.return(mutationOpts)),\n );\n plugin.node(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 {\n getClientBaseUrlKey,\n getClientPlugin,\n} from '~/plugins/@hey-api/client-core/utils';\nimport { $ } from '~/ts-dsl';\n\nimport type { PiniaColadaPlugin } from './types';\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).generic(TOptionsType).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).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))\n .do(\n $.const('params')\n .type(returnType)\n .assign(\n $.object()\n .prop('_id', 'id')\n .prop(\n baseUrlKey,\n $('options')\n .attr(baseUrlKey)\n .optional()\n .or(\n $('options')\n .attr('client')\n .optional()\n .$if(symbolClient, (a, v) => a.coalesce(v))\n .attr('getConfig')\n .call()\n .attr(baseUrlKey),\n ),\n )\n .as(returnType),\n ),\n $.if('tags').do(\n $('params')\n .attr('tags')\n .assign($('tags').as('unknown').as(symbolJsonValue)),\n ),\n $.if($('options').attr('body').optional().neq($.id('undefined'))).do(\n $.const('normalizedBody').assign(\n $(symbolSerializeQueryValue).call($('options').attr('body')),\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).call($('options').attr('query')),\n ),\n $.if($('normalizedQuery').neq($.id('undefined'))).do(\n $('params').attr('query').assign('normalizedQuery'),\n ),\n ),\n $.return($.array($('params'))),\n ),\n );\n plugin.node(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).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 meta: {\n category: 'type',\n resource: 'QueryKey',\n tool: plugin.name,\n },\n name: 'QueryKey',\n });\n const queryKeyType = $.type\n .alias(symbolQueryKeyType)\n .export()\n .generic(TOptionsType, (g) => g.extends($.type(symbolOptions)))\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),\n )\n .prop('body', (p) => p.optional().type(symbolJsonValue))\n .prop('query', (p) => p.optional().type(symbolJsonValue))\n .prop('tags', (p) => p.optional().type(symbolJsonValue)),\n ),\n ),\n );\n plugin.node(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 client = getClientPlugin(plugin.context.config);\n const isNuxtClient = client.name === '@hey-api/client-nuxt';\n const statement = $.const(symbol)\n .export()\n .assign(\n $.func()\n .param('options', (p) =>\n p\n .required(hasOperationDataRequired(operation))\n .type(getPublicTypeData({ isNuxtClient, operation, plugin })),\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 { getClientPlugin } from '~/plugins/@hey-api/client-core/utils';\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 { 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: ReturnType<typeof $.expr | typeof $.call | typeof $.attr>;\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 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.node(node);\n keyExpression = $(symbolQueryKey).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).call(\n $.literal(operation.id),\n optionsParamName,\n tagsExpr,\n );\n }\n\n const client = getClientPlugin(plugin.context.config);\n const isNuxtClient = client.name === '@hey-api/client-nuxt';\n const typeData = getPublicTypeData({ isNuxtClient, operation, plugin });\n const awaitSdkFn = $.lazy(() =>\n $(queryFn)\n .call(\n $.object()\n .spread(optionsParamName)\n .spread(fnOptions)\n .prop('throwOnError', $.literal(true)),\n )\n .await(),\n );\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 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)\n .export()\n .$if(plugin.config.comments && createOperationComment(operation), (c, v) =>\n c.doc(v),\n )\n .assign(\n $(symbolDefineQueryOptions).call(\n $.func()\n .param(optionsParamName, (p) =>\n p.required(isRequiredOptions).type(typeData),\n )\n .do($.return(queryOpts)),\n ),\n );\n plugin.node(statement);\n};\n","import { registryName } from '~/plugins/@hey-api/sdk/shared/class';\nimport { operationClasses } from '~/plugins/@hey-api/sdk/shared/operation';\nimport { $ } from '~/ts-dsl';\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({ operation, plugin: sdkPlugin })\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: ReturnType<typeof $.expr | typeof $.call | typeof $.attr>;\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 = $(symbolClass).$if(sdkPlugin.config.instance, (e) =>\n e.attr(registryName).attr('get').call(),\n );\n for (const className of entry.path.slice(1)) {\n const cls = stringCase({\n case: 'camelCase',\n value: className,\n });\n queryFn = queryFn.attr(cls);\n }\n queryFn = queryFn.attr(entry.methodName);\n } else {\n const symbol = plugin.referenceSymbol({\n category: 'sdk',\n resource: 'operation',\n resourceId: operation.id,\n });\n queryFn = $(symbol);\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';\nimport { $ } from '~/ts-dsl';\n\nimport type { PluginInstance } from '../types';\n\nexport const useTypeData = ({\n operation,\n plugin,\n}: {\n operation: IR.OperationObject;\n plugin: PluginInstance;\n}): ReturnType<typeof $.type> => {\n const pluginSdk = plugin.getPluginOrThrow('@hey-api/sdk');\n return operationOptionsType({ operation, plugin: pluginSdk });\n};\n\nexport const useTypeError = ({\n operation,\n plugin,\n}: {\n operation: IR.OperationObject;\n plugin: PluginInstance;\n}): ReturnType<typeof $.type> => {\n const client = getClientPlugin(plugin.context.config);\n const symbolErrorType = plugin.querySymbol({\n category: 'type',\n resource: 'operation',\n resourceId: operation.id,\n role: 'error',\n });\n const symbolError =\n symbolErrorType ||\n plugin.referenceSymbol({\n category: 'external',\n resource: `${plugin.name}.DefaultError`,\n });\n if (client.name === '@hey-api/client-axios') {\n const symbol = plugin.referenceSymbol({\n category: 'external',\n resource: 'axios.AxiosError',\n });\n return $.type(symbol).generic(symbolError);\n }\n return $.type(symbolError);\n};\n\nexport const useTypeResponse = ({\n operation,\n plugin,\n}: {\n operation: IR.OperationObject;\n plugin: PluginInstance;\n}): ReturnType<typeof $.type> => {\n const symbolResponseType = plugin.querySymbol({\n category: 'type',\n resource: 'operation',\n resourceId: operation.id,\n role: 'response',\n });\n return $.type(symbolResponseType ?? '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).generic(TOptionsType).idx(0);\n\n const fn = $.const(symbolCreateQueryKey).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))\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')\n .attr(baseUrlKey)\n .optional()\n .or(\n $('options')\n .attr('client')\n .optional()\n .$if(symbolClient, (a, v) => a.coalesce(v))\n .attr('getConfig')\n .call()\n .attr(baseUrlKey),\n ),\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.node(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).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 meta: {\n category: 'type',\n resource: 'QueryKey',\n tool: plugin.name,\n },\n name: 'QueryKey',\n });\n const queryKeyType = $.type\n .alias(symbolQueryKeyType)\n .export()\n .generic(TOptionsType, (g) => g.extends(symbolOptions))\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.node(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?: ReturnType<typeof $.type>;\n}) => {\n const typeData = useTypeData({ operation, plugin });\n const statement = $.const(symbol)\n .export()\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 { ref } from '@hey-api/codegen-core';\n\nimport { 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).assign(\n $.func()\n .generic('K', (g) =>\n g.extends(\n $.type('Pick').generics(\n $.type('QueryKey').generic('Options').idx(0),\n $.type.or(\n $.type.literal('body'),\n $.type.literal('headers'),\n $.type.literal('path'),\n $.type.literal('query'),\n ),\n ),\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.node(fn);\n};\n\nexport const createInfiniteQueryOptions = ({\n operation,\n plugin,\n queryFn,\n}: {\n operation: IR.OperationObject;\n plugin: PluginInstance;\n queryFn: ReturnType<typeof $.expr | typeof $.call | typeof $.attr>;\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 typeResponse = useTypeResponse({ operation, plugin });\n\n const symbolQueryKeyType = plugin.referenceSymbol({\n category: 'type',\n resource: 'QueryKey',\n tool: plugin.name,\n });\n const typeQueryKey = $.type(symbolQueryKeyType).generic(typeData);\n const typePageObjectParam = $.type('Pick').generics(\n typeQueryKey.idx(0),\n $.type.or(\n $.type.literal('body'),\n $.type.literal('headers'),\n $.type.literal('path'),\n $.type.literal('query'),\n ),\n );\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: ref([]),\n },\n });\n\n const symbolInfiniteQueryKey = plugin.registerSymbol({\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.node(node);\n\n const awaitSdkFn = $.lazy(() =>\n $(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\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').typeofExpr().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).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 name: buildName({\n config: plugin.config.infiniteQueryOptions,\n name: operation.id,\n }),\n });\n const statement = $.const(symbolInfiniteQueryOptionsFn)\n .export()\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)\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('queryKey', $(symbolInfiniteQueryKey).call('options'))\n .$if(\n handleMeta(plugin, operation, 'infiniteQueryOptions'),\n (o, v) => o.prop('meta', v),\n ),\n )\n .generics(\n typeResponse,\n useTypeError({ operation, plugin }),\n $.type(symbolInfiniteDataType).generic(typeResponse),\n typeQueryKey,\n $.type.or(type, typePageObjectParam),\n ),\n ),\n ),\n );\n plugin.node(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: ReturnType<typeof $.expr | typeof $.call | typeof $.attr>;\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 mutationType = $.type(symbolMutationOptionsType)\n .generic(useTypeResponse({ operation, plugin }))\n .generic(useTypeError({ operation, plugin }))\n .generic(typeData);\n\n const fnOptions = 'fnOptions';\n\n const awaitSdkFn = $.lazy(() =>\n $(queryFn)\n .call(\n $.object()\n .spread('options')\n .spread(fnOptions)\n .prop('throwOnError', $.literal(true)),\n )\n .await(),\n );\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 name: buildName({\n config: plugin.config.mutationOptions,\n name: operation.id,\n }),\n });\n const statement = $.const(symbolMutationOptions)\n .export()\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($.type('Partial').generic(typeData)),\n )\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.node(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: ReturnType<typeof $.expr | typeof $.call | typeof $.attr>;\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 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.node(node);\n\n const typeResponse = useTypeResponse({ operation, plugin });\n\n const awaitSdkFn = $.lazy(() =>\n $(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\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).call(optionsParamName))\n .$if(handleMeta(plugin, operation, 'queryOptions'), (o, v) =>\n o.prop('meta', v),\n );\n\n const symbolQueryOptionsFn = plugin.registerSymbol({\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)\n .export(plugin.config.queryOptions.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\n .required(isRequiredOptions)\n .type(useTypeData({ operation, plugin })),\n )\n .do(\n $(symbolQueryOptions)\n .call(queryOptionsObj)\n .generics(\n typeResponse,\n useTypeError({ operation, plugin }),\n typeResponse,\n $(symbolQueryKey).returnType(),\n )\n .return(),\n ),\n );\n plugin.node(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 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)\n .export()\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)\n .call($(symbolQueryOptionsFn).call(optionsParamName))\n .return(),\n ),\n );\n plugin.node(statement);\n};\n","import { registryName } from '~/plugins/@hey-api/sdk/shared/class';\nimport { operationClasses } from '~/plugins/@hey-api/sdk/shared/operation';\nimport { $ } from '~/ts-dsl';\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({ operation, plugin: sdkPlugin })\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: ReturnType<typeof $.expr | typeof $.call | typeof $.attr>;\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 = $(symbolClass).$if(sdkPlugin.config.instance, (e) =>\n e.attr(registryName).attr('get').call(),\n );\n for (const className of entry.path.slice(1)) {\n const cls = stringCase({\n case: 'camelCase',\n value: className,\n });\n queryFn = queryFn.attr(cls);\n }\n queryFn = queryFn.attr(entry.methodName);\n } else {\n const symbol = plugin.referenceSymbol({\n category: 'sdk',\n resource: 'operation',\n resourceId: operation.id,\n });\n queryFn = $(symbol);\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($(symbol).attr('parseAsync').call(dataParameterName).await().return());\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($(symbol).attr('parseAsync').call(dataParameterName).await().return());\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)\n .export()\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,\n // name: ast.typeName,\n // }) as unknown as ts.TypeNode)\n // : undefined,\n // )\n .assign($(type).call(ast.def ? $.literal(ast.def) : ast.expression));\n plugin.node(statement);\n\n if (typeInferSymbol) {\n const inferType = $.type\n .alias(typeInferSymbol)\n .export()\n .type($.type(symbol).attr(identifiers.type.infer).typeofType());\n plugin.node(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 { fromRef, ref } from '@hey-api/codegen-core';\n\nimport type { SchemaWithType } from '~/plugins/shared/types/schema';\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: ref([...fromRef(state.path), '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: ref([...fromRef(state.path), '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).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';\nimport { fromRef, refs } 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 { $ } 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);\n ast.expression = ref;\n } else {\n // expression: z,\n // name: identifiers.lazy,\n const lazyExpression = $('TODO')\n .attr('TODO')\n .call($.func().returns('any').do($.return(refSymbol)));\n ast.expression = lazyExpression;\n ast.hasLazyExpression = true;\n state.hasLazyExpression['~ref'] = 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,\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,\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,\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,\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,\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(fromRef(state.path));\n const ast = irSchemaToAst({ plugin, schema, state });\n const baseName = refToName($ref);\n const symbol = plugin.registerSymbol({\n meta: {\n category: 'schema',\n path: fromRef(state.path),\n resource: 'definition',\n resourceId: $ref,\n tags: fromRef(state.tags),\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 meta: {\n category: 'type',\n path: fromRef(state.path),\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 = refs<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).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($.type(symbolDataType).idx($.type.literal('headers'))),\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($.type(symbolDataType).idx($.type.literal('path'))),\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($.type(symbolDataType).idx($.type.literal('query'))),\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);\n } else if (keys.length > 1) {\n errorsTypeReference = $.type('Omit', (t) =>\n t.generics($.type(symbolErrorType), $.type.literal('default')),\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);\n } else if (keys.length > 1) {\n responsesTypeReference = $.type('Omit', (t) =>\n t.generics($.type(symbolResponseType), $.type.literal('default')),\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, (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 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.alias(symbolRouteHandlers).export().type(type);\n plugin.node(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: ReturnType<typeof $.expr | typeof $.call | typeof $.attr>;\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 name: buildName({\n config: plugin.config.useSwr,\n name: operation.id,\n }),\n });\n\n const awaitSdkFn = $.lazy(() =>\n $(queryFn)\n .call($.object().prop('throwOnError', $.literal(true)))\n .await(),\n );\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)\n .export()\n .$if(plugin.config.comments && createOperationComment(operation), (c, v) =>\n c.doc(v),\n )\n .assign(\n $.func().do(\n $(symbolUseSwr)\n .call(\n $.literal(operation.path),\n $.func()\n .async()\n .do(...statements),\n )\n .return(),\n ),\n );\n plugin.node(statement);\n};\n","import { registryName } from '~/plugins/@hey-api/sdk/shared/class';\nimport { operationClasses } from '~/plugins/@hey-api/sdk/shared/operation';\nimport { $ } from '~/ts-dsl';\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({ operation, plugin: sdkPlugin })\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: ReturnType<typeof $.expr | typeof $.call | typeof $.attr>;\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 = $(symbolClass).$if(sdkPlugin.config.instance, (e) =>\n e.attr(registryName).attr('get').call(),\n );\n for (const className of entry.path.slice(1)) {\n const cls = stringCase({\n case: 'camelCase',\n value: className,\n });\n queryFn = queryFn.attr(cls);\n }\n queryFn = queryFn.attr(entry.methodName);\n } else {\n const symbol = plugin.referenceSymbol({\n category: 'sdk',\n resource: 'operation',\n resourceId: operation.id,\n });\n queryFn = $(symbol);\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).attr(identifiers.async.parseAsync).call(schema, 'data').await().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)\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)\n .export()\n .$if(plugin.config.comments && createSchemaComment(schema), (c, v) =>\n c.doc(v),\n )\n .$if(state.hasLazyExpression['~ref'], (c) =>\n c.type($.type(v).attr(ast.typeName || identifiers.types.GenericSchema)),\n )\n .assign(pipesToAst({ pipes: ast.pipes, plugin }));\n plugin.node(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 { fromRef } from '@hey-api/codegen-core';\n\nimport { 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, fromRef(state.path));\n const symbol = plugin.registerSymbol({\n meta: {\n category: 'schema',\n path: fromRef(state.path),\n resource: 'operation',\n resourceId: operation.id,\n role: 'data',\n tags: fromRef(state.tags),\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 = [...fromRef(state.path), 'responses'];\n const ast = getAst(response, path);\n const symbol = plugin.registerSymbol({\n meta: {\n category: 'schema',\n path,\n resource: 'operation',\n resourceId: operation.id,\n role: 'responses',\n tags: fromRef(state.tags),\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 { fromRef } from '@hey-api/codegen-core';\n\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 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, fromRef(state.path));\n const symbol = plugin.registerSymbol({\n meta: {\n category: 'schema',\n path: fromRef(state.path),\n resource: 'webhook',\n resourceId: operation.id,\n role: 'data',\n tags: fromRef(state.tags),\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).attr(identifiers.schemas.unknown).call();\n return expression;\n};\n","import { fromRef, ref } from '@hey-api/codegen-core';\n\nimport { deduplicateSchema } from '~/ir/schema';\nimport type { SchemaWithType } from '~/plugins';\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).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: ref([...fromRef(state.path), '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)\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)\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)\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).attr(identifiers.schemas.literal).call($.literal(schema.const)),\n );\n return pipesToAst({ pipes, plugin });\n }\n\n pipes.push($(v).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)\n .attr(identifiers.schemas.picklist)\n .call($.array(...enumMembers));\n\n if (isNullable) {\n resultExpression = $(v)\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).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).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).attr(identifiers.schemas.literal).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)\n .attr(identifiers.schemas.union)\n .call(\n $.array(\n $(v).attr(identifiers.schemas.number).call(),\n $(v).attr(identifiers.schemas.string).call(),\n $(v).attr(identifiers.schemas.bigInt).call(),\n ),\n );\n pipes.push(unionExpression);\n\n // Add transform to convert to BigInt\n const transformExpression = $(v)\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).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).attr(identifiers.actions.integer).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)\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)\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)\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)\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)\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)\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 { fromRef, ref } from '@hey-api/codegen-core';\n\nimport type { SchemaWithType } from '~/plugins';\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($(v).attr(identifiers.schemas.strictObject).call(shape));\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)\n .attr(identifiers.schemas.record)\n .call($(v).attr(identifiers.schemas.string).call(), additional),\n );\n }\n\n // If there are named properties, use v.objectWithRest() to validate both\n return pipes.push(\n $(v).attr(identifiers.schemas.objectWithRest).call(shape, additional),\n );\n }\n\n // Default case → v.object()\n return pipes.push($(v).attr(identifiers.schemas.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 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: ref([...fromRef(state.path), '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: ref([...fromRef(state.path), '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($(v).attr(identifiers.actions.isoDate).call());\n case 'date-time':\n return pipes.push($(v).attr(identifiers.actions.isoTimestamp).call());\n case 'email':\n return pipes.push($(v).attr(identifiers.actions.email).call());\n case 'ipv4':\n case 'ipv6':\n return pipes.push($(v).attr(identifiers.actions.ip).call());\n case 'time':\n return pipes.push($(v).attr(identifiers.actions.isoTimeSecond).call());\n case 'uri':\n return pipes.push($(v).attr(identifiers.actions.url).call());\n case 'uuid':\n return pipes.push($(v).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).attr(identifiers.schemas.literal).call($.literal(schema.const)),\n );\n return pipesToAst({ pipes, plugin });\n }\n\n pipes.push($(v).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).attr(identifiers.actions.length).call($.literal(schema.minLength)),\n );\n } else {\n if (schema.minLength !== undefined) {\n pipes.push(\n $(v)\n .attr(identifiers.actions.minLength)\n .call($.literal(schema.minLength)),\n );\n }\n\n if (schema.maxLength !== undefined) {\n pipes.push(\n $(v)\n .attr(identifiers.actions.maxLength)\n .call($.literal(schema.maxLength)),\n );\n }\n }\n\n if (schema.pattern) {\n pipes.push(\n $(v).attr(identifiers.actions.regex).call($.regexp(schema.pattern)),\n );\n }\n\n return pipesToAst({ pipes, plugin });\n};\n","import { fromRef, ref } from '@hey-api/codegen-core';\n\nimport type { SchemaWithType } from '~/plugins';\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).attr(identifiers.schemas.literal).call($.fromValue(value)),\n );\n result.pipes = [\n $(v)\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: ref([...fromRef(state.path), '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)\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).attr(identifiers.schemas.undefined).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).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';\nimport { fromRef, ref, refs } 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 { $ } 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);\n ast.pipes.push(ref);\n } else {\n const lazyExpression = $(v)\n .attr(identifiers.schemas.lazy)\n .call($.func().do($(refSymbol).return()));\n ast.pipes.push(lazyExpression);\n state.hasLazyExpression['~ref'] = 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)\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: ref([...fromRef(state.path), 'items', index]),\n },\n });\n return pipesToAst({ pipes: itemAst.pipes, plugin });\n });\n\n if (schema.logicalOperator === 'and') {\n const intersectExpression = $(v)\n .attr(identifiers.schemas.intersect)\n .call($.array(...itemsAst));\n ast.pipes.push(intersectExpression);\n } else {\n const unionExpression = $(v)\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).attr(identifiers.actions.readonly).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)\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)\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(fromRef(state.path));\n const ast = irSchemaToAst({ plugin, schema, state });\n const baseName = refToName($ref);\n const symbol = plugin.registerSymbol({\n meta: {\n category: 'schema',\n path: fromRef(state.path),\n resource: 'definition',\n resourceId: $ref,\n tags: fromRef(state.tags),\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 = refs<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 = refs<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 = refs<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).attr(identifiers.parseAsync).call('data').await().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).attr(identifiers.parseAsync).call('data').await().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).attr(identifiers.parseAsync).call('data').await().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)\n .export()\n .$if(plugin.config.comments && createSchemaComment(schema), (c, v) =>\n c.doc(v),\n )\n .$if(ast.typeName, (c, v) => c.type($.type(z).attr(v)))\n .assign(ast.expression);\n plugin.node(statement);\n\n if (typeInferSymbol) {\n const inferType = $.type\n .alias(typeInferSymbol)\n .export()\n .type($.type(z).attr(identifiers.infer).generic($(symbol).typeofType()));\n plugin.node(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 { fromRef } from '@hey-api/codegen-core';\n\nimport { 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, fromRef(state.path));\n const symbol = plugin.symbol(\n buildName({\n config: plugin.config.requests,\n name: operation.id,\n }),\n {\n meta: {\n category: 'schema',\n path: fromRef(state.path),\n resource: 'operation',\n resourceId: operation.id,\n role: 'data',\n tags: fromRef(state.tags),\n tool: 'zod',\n },\n },\n );\n const typeInferSymbol = plugin.config.requests.types.infer.enabled\n ? plugin.symbol(\n buildName({\n config: plugin.config.requests.types.infer,\n name: operation.id,\n }),\n {\n meta: {\n category: 'type',\n path: fromRef(state.path),\n resource: 'operation',\n resourceId: operation.id,\n role: 'data',\n tags: fromRef(state.tags),\n tool: 'zod',\n variant: 'infer',\n },\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 = [...fromRef(state.path), 'responses'];\n const ast = getAst(response, path);\n const symbol = plugin.symbol(\n buildName({\n config: plugin.config.responses,\n name: operation.id,\n }),\n {\n meta: {\n category: 'schema',\n path,\n resource: 'operation',\n resourceId: operation.id,\n role: 'responses',\n tags: fromRef(state.tags),\n tool: 'zod',\n },\n },\n );\n const typeInferSymbol = plugin.config.responses.types.infer.enabled\n ? plugin.symbol(\n buildName({\n config: plugin.config.responses.types.infer,\n name: operation.id,\n }),\n {\n meta: {\n category: 'type',\n path,\n resource: 'operation',\n resourceId: operation.id,\n role: 'responses',\n tags: fromRef(state.tags),\n tool: 'zod',\n variant: 'infer',\n },\n },\n )\n : undefined;\n exportAst({\n ast,\n plugin,\n schema: response,\n symbol,\n typeInferSymbol,\n });\n }\n }\n }\n};\n","import { fromRef } from '@hey-api/codegen-core';\n\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 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, fromRef(state.path));\n const symbol = plugin.registerSymbol({\n meta: {\n category: 'schema',\n path: fromRef(state.path),\n resource: 'webhook',\n resourceId: operation.id,\n role: 'data',\n tags: fromRef(state.tags),\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 meta: {\n category: 'type',\n path: fromRef(state.path),\n resource: 'webhook',\n resourceId: operation.id,\n role: 'data',\n tags: fromRef(state.tags),\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).attr(identifiers.unknown).call();\n return result as Omit<Ast, 'typeName'>;\n};\n","import { fromRef, ref } from '@hey-api/codegen-core';\n\nimport { deduplicateSchema } from '~/ir/schema';\nimport type { SchemaWithType } from '~/plugins';\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).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: ref([...fromRef(state.path), '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)\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)\n .attr(identifiers.intersection)\n .call(intersectionExpression, itemExpressions[i]);\n }\n }\n\n result.expression = functionName.call(intersectionExpression);\n } else {\n result.expression = $(z)\n .attr(identifiers.array)\n .call(\n $(z)\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).attr(identifiers.length).call($.fromValue(schema.minItems)),\n );\n } else {\n if (schema.minItems !== undefined) {\n checks.push(\n $(z).attr(identifiers.minLength).call($.fromValue(schema.minItems)),\n );\n }\n\n if (schema.maxItems !== undefined) {\n checks.push(\n $(z).attr(identifiers.maxLength).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).attr(identifiers.literal).call($.literal(schema.const));\n result.expression = chain;\n return result as Omit<Ast, 'typeName'>;\n }\n\n chain = $(z).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($(z).attr(identifiers.literal).call(literal));\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($(z).attr(identifiers.literal).call(literal));\n } else if (item.type === 'boolean' && typeof item.const === 'boolean') {\n allStrings = false;\n const literal = $.literal(item.const);\n literalMembers.push($(z).attr(identifiers.literal).call(literal));\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)\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)\n .attr(identifiers.union)\n .call($.array(...literalMembers));\n }\n\n if (isNullable) {\n result.expression = $(z).attr(identifiers.nullable).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).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).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)\n .attr(identifiers.literal)\n .call($.literal(schema.const));\n return result as Omit<Ast, 'typeName'>;\n }\n\n result.expression = isBigInt\n ? $(z).attr(identifiers.coerce).attr(identifiers.bigint).call()\n : $(z).attr(identifiers.number).call();\n\n if (!isBigInt && schema.type === 'integer') {\n result.expression = $(z).attr(identifiers.int).call();\n }\n\n const checks: Array<ReturnType<typeof $.call>> = [];\n\n if (schema.exclusiveMinimum !== undefined) {\n checks.push(\n $(z)\n .attr(identifiers.gt)\n .call(numberParameter({ isBigInt, value: schema.exclusiveMinimum })),\n );\n } else if (schema.minimum !== undefined) {\n checks.push(\n $(z)\n .attr(identifiers.gte)\n .call(numberParameter({ isBigInt, value: schema.minimum })),\n );\n }\n\n if (schema.exclusiveMaximum !== undefined) {\n checks.push(\n $(z)\n .attr(identifiers.lt)\n .call(numberParameter({ isBigInt, value: schema.exclusiveMaximum })),\n );\n } else if (schema.maximum !== undefined) {\n checks.push(\n $(z)\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 { fromRef, ref } from '@hey-api/codegen-core';\n\nimport type { SchemaWithType } from '~/plugins';\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)\n .attr(identifiers.record)\n .call($(z).attr(identifiers.string).call(), additional);\n }\n\n return $(z).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: ref([...fromRef(state.path), '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: ref([...fromRef(state.path), '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).attr(identifiers.iso).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 $(z)\n .attr(identifiers.iso)\n .attr(identifiers.datetime)\n .call(obj.hasProps() ? obj : undefined);\n }\n case 'email':\n return $(z).attr(identifiers.email).call();\n case 'ipv4':\n return $(z).attr(identifiers.ipv4).call();\n case 'ipv6':\n return $(z).attr(identifiers.ipv6).call();\n case 'time':\n return $(z).attr(identifiers.iso).attr(identifiers.time).call();\n case 'uri':\n return $(z).attr(identifiers.url).call();\n case 'uuid':\n return $(z).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).attr(identifiers.literal).call($.literal(schema.const));\n result.expression = chain;\n return result as Omit<Ast, 'typeName'>;\n }\n\n chain = $(z).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).attr(identifiers.length).call($.literal(schema.minLength)),\n );\n } else {\n if (schema.minLength !== undefined) {\n checks.push(\n $(z).attr(identifiers.minLength).call($.literal(schema.minLength)),\n );\n }\n\n if (schema.maxLength !== undefined) {\n checks.push(\n $(z).attr(identifiers.maxLength).call($.literal(schema.maxLength)),\n );\n }\n }\n\n if (schema.pattern) {\n checks.push($(z).attr(identifiers.regex).call($.regexp(schema.pattern)));\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 { fromRef, ref } from '@hey-api/codegen-core';\n\nimport type { SchemaWithType } from '~/plugins';\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).attr(identifiers.literal).call($.fromValue(value)),\n );\n result.expression = $(z)\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: ref([...fromRef(state.path), '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)\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).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).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';\nimport { fromRef, ref, refs } 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 { $ } 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);\n } else {\n ast.expression = $(z)\n .attr(identifiers.lazy)\n .call($.func().returns('any').do($(refSymbol).return()));\n ast.hasLazyExpression = true;\n state.hasLazyExpression['~ref'] = 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).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: ref([...fromRef(state.path), '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)\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)\n .attr(identifiers.intersection)\n .call(\n ast.expression,\n schema.hasLazyExpression\n ? $(z)\n .attr(identifiers.lazy)\n .call($.func().do(schema.expression.return()))\n : schema.expression,\n );\n });\n }\n } else {\n ast.expression = $(z)\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).attr(identifiers.readonly).call(ast.expression);\n }\n\n if (optional) {\n ast.expression = $(z).attr(identifiers.optional).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)\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(fromRef(state.path));\n const ast = irSchemaToAst({ plugin, schema, state });\n const baseName = refToName($ref);\n const symbol = plugin.registerSymbol({\n meta: {\n category: 'schema',\n path: fromRef(state.path),\n resource: 'definition',\n resourceId: $ref,\n tags: fromRef(state.tags),\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 meta: {\n category: 'type',\n path: fromRef(state.path),\n resource: 'definition',\n resourceId: $ref,\n tags: fromRef(state.tags),\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 = refs<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 = refs<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 = refs<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).attr(identifiers.unknown).call();\n return expression;\n};\n","import { fromRef, ref } from '@hey-api/codegen-core';\n\nimport { deduplicateSchema } from '~/ir/schema';\nimport type { SchemaWithType } from '~/plugins';\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).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: ref([...fromRef(state.path), '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)\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)\n .attr(identifiers.array)\n .call(\n $(z)\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).attr(identifiers.literal).call($.literal(schema.const));\n return chain;\n }\n\n chain = $(z).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($(z).attr(identifiers.literal).call(literal));\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($(z).attr(identifiers.literal).call(literal));\n } else if (item.type === 'boolean' && typeof item.const === 'boolean') {\n allStrings = false;\n const literal = $.literal(item.const);\n literalMembers.push($(z).attr(identifiers.literal).call(literal));\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)\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)\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).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).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)\n .attr(identifiers.literal)\n .call($.literal(schema.const));\n return expression;\n }\n\n let numberExpression = isBigInt\n ? $(z).attr(identifiers.coerce).attr(identifiers.bigint).call()\n : $(z).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 { fromRef, ref } from '@hey-api/codegen-core';\n\nimport type { SchemaWithType } from '~/plugins';\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).attr(identifiers.record).call(additional);\n }\n\n return $(z).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: ref([...fromRef(state.path), '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: ref([...fromRef(state.path), '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).attr(identifiers.literal).call($.literal(schema.const));\n return chain;\n }\n\n chain = $(z).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 { fromRef, ref } from '@hey-api/codegen-core';\n\nimport type { SchemaWithType } from '~/plugins';\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).attr(identifiers.literal).call($.fromValue(value)),\n );\n const expression = $(z)\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: ref([...fromRef(state.path), 'items', index]),\n },\n });\n tupleElements.push(itemSchema.expression);\n if (itemSchema.hasLazyExpression) {\n hasLazyExpression = true;\n }\n });\n }\n\n const expression = $(z)\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).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).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';\nimport { fromRef, ref, refs } 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 { $ } 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);\n } else {\n ast.expression = $(z)\n .attr(identifiers.lazy)\n .call($.func().do($(refSymbol).return()));\n ast.hasLazyExpression = true;\n state.hasLazyExpression['~ref'] = 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: ref([...fromRef(state.path), '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)\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)\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['~ref']) {\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(fromRef(state.path));\n const ast = irSchemaToAst({ plugin, schema, state });\n const baseName = refToName($ref);\n const symbol = plugin.registerSymbol({\n meta: {\n category: 'schema',\n path: fromRef(state.path),\n resource: 'definition',\n resourceId: $ref,\n tags: fromRef(state.tags),\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 meta: {\n category: 'type',\n path: fromRef(state.path),\n resource: 'definition',\n resourceId: $ref,\n tags: fromRef(state.tags),\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 = refs<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 = refs<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 = refs<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).attr(identifiers.unknown).call();\n return result as Omit<Ast, 'typeName'>;\n};\n","import { fromRef, ref } from '@hey-api/codegen-core';\n\nimport { deduplicateSchema } from '~/ir/schema';\nimport type { SchemaWithType } from '~/plugins';\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).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: ref([...fromRef(state.path), '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)\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)\n .attr(identifiers.array)\n .call(\n $(z)\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).attr(identifiers.literal).call($.literal(schema.const));\n result.expression = chain;\n return result as Omit<Ast, 'typeName'>;\n }\n\n chain = $(z).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($(z).attr(identifiers.literal).call(literal));\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($(z).attr(identifiers.literal).call(literal));\n } else if (item.type === 'boolean' && typeof item.const === 'boolean') {\n allStrings = false;\n const literal = $.literal(item.const);\n literalMembers.push($(z).attr(identifiers.literal).call(literal));\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)\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)\n .attr(identifiers.union)\n .call($.array(...literalMembers));\n }\n\n if (isNullable) {\n result.expression = $(z).attr(identifiers.nullable).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).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).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)\n .attr(identifiers.literal)\n .call($.literal(schema.const));\n return result as Omit<Ast, 'typeName'>;\n }\n\n result.expression = isBigInt\n ? $(z).attr(identifiers.coerce).attr(identifiers.bigint).call()\n : $(z).attr(identifiers.number).call();\n\n if (!isBigInt && schema.type === 'integer') {\n result.expression = $(z).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 { fromRef, ref } from '@hey-api/codegen-core';\n\nimport type { SchemaWithType } from '~/plugins';\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)\n .attr(identifiers.record)\n .call($(z).attr(identifiers.string).call(), additional);\n }\n\n return $(z).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: ref([...fromRef(state.path), '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: ref([...fromRef(state.path), '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).attr(identifiers.iso).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 $(z)\n .attr(identifiers.iso)\n .attr(identifiers.datetime)\n .call(obj.hasProps() ? obj : undefined);\n }\n case 'email':\n return $(z).attr(identifiers.email).call();\n case 'ipv4':\n return $(z).attr(identifiers.ipv4).call();\n case 'ipv6':\n return $(z).attr(identifiers.ipv6).call();\n case 'time':\n return $(z).attr(identifiers.iso).attr(identifiers.time).call();\n case 'uri':\n return $(z).attr(identifiers.url).call();\n case 'uuid':\n return $(z).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).attr(identifiers.literal).call($.literal(schema.const));\n result.expression = chain;\n return result as Omit<Ast, 'typeName'>;\n }\n\n chain = $(z).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 { fromRef, ref } from '@hey-api/codegen-core';\n\nimport type { SchemaWithType } from '~/plugins';\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).attr(identifiers.literal).call($.fromValue(value)),\n );\n result.expression = $(z)\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: ref([...fromRef(state.path), '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)\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).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).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';\nimport { fromRef, ref, refs } 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 { $ } 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);\n } else {\n ast.expression = $(z)\n .attr(identifiers.lazy)\n .call($.func().returns('any').do($(refSymbol).return()));\n ast.hasLazyExpression = true;\n state.hasLazyExpression['~ref'] = 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).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: ref([...fromRef(state.path), '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)\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)\n .attr(identifiers.lazy)\n .call($.func().do(schema.expression.return()))\n : schema.expression,\n );\n });\n }\n } else {\n ast.expression = $(z)\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).attr(identifiers.optional).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(fromRef(state.path));\n const ast = irSchemaToAst({ plugin, schema, state });\n const baseName = refToName($ref);\n const symbol = plugin.registerSymbol({\n meta: {\n category: 'schema',\n path: fromRef(state.path),\n resource: 'definition',\n resourceId: $ref,\n tags: fromRef(state.tags),\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 meta: {\n category: 'type',\n path: fromRef(state.path),\n resource: 'definition',\n resourceId: $ref,\n tags: fromRef(state.tags),\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 = refs<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 = refs<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 = refs<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","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 Node,\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 /**\n * Sets or adds a node to the project graph.\n *\n * @param node The node to be added or updated in the project graph.\n * @param index The index at which to update the node. If undefined, the node will be added.\n * @returns The index of the added node or void if updated.\n */\n node<T extends number | undefined = undefined>(\n node: Node | null,\n index?: T,\n ): T extends number ? void : number {\n for (const hook of this.eventHooks['node:set:before']) {\n hook({ node, plugin: this });\n }\n const result =\n index !== undefined\n ? this.gen.nodes.update(index, node)\n : this.gen.nodes.add(node);\n for (const hook of this.eventHooks['node:set:after']) {\n hook({ node, plugin: this });\n }\n return result as T extends number ? void : number;\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 /**\n * @deprecated use `plugin.symbol()` instead\n */\n registerSymbol(symbol: SymbolIn): Symbol {\n return this.symbol(symbol.name, symbol);\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 symbol(name: SymbolIn['name'], symbol?: Omit<SymbolIn, 'name'>): 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 name,\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 private buildEventHooks(): EventHooks {\n const result: EventHooks = {\n 'node:set:after': [],\n 'node:set:before': [],\n 'plugin:handler:after': [],\n 'plugin:handler:before': [],\n 'symbol:register:after': [],\n 'symbol:register: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 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 { TypeScriptRenderer } from '~/ts-dsl';\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 // TODO: allow overriding via 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 nameConflictResolvers: config.output.nameConflictResolver\n ? {\n typescript: config.output.nameConflictResolver,\n }\n : undefined,\n renderers: [\n new TypeScriptRenderer({\n preferExportAll: config.output.preferExportAll,\n preferFileExtension: config.output.importFileExtension || undefined,\n resolveModuleName: config.output.resolveModuleName,\n }),\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\nexport const parseExtensions = ({\n source,\n target,\n}: {\n source: object;\n target: object;\n}) => {\n for (const key in source) {\n if (key.startsWith('x-')) {\n (target as Record<string, unknown>)[key] = (\n source as Record<string, unknown>\n )[key];\n }\n }\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 parseExtensions({\n source: schema,\n target: irSchema,\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 { parseExtensions, 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 parseExtensions({\n source: operation,\n target: irOperation,\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 { parseExtensions, 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 parseExtensions({\n source: parameter,\n target: irParameter,\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-')) continue;\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\n/**\n * Recursively finds discriminators in a schema, including nested allOf compositions.\n * This is needed when a schema extends another schema via allOf, and that parent\n * schema is itself an allOf composition with discriminators in inline schemas.\n */\nconst findDiscriminatorsInSchema = ({\n context,\n discriminators = [],\n schema,\n}: {\n context: Context;\n discriminators?: Array<{\n discriminator: NonNullable<SchemaObject['discriminator']>;\n oneOf?: SchemaObject['oneOf'];\n }>;\n schema: SchemaObject;\n}): Array<{\n discriminator: NonNullable<SchemaObject['discriminator']>;\n oneOf?: SchemaObject['oneOf'];\n}> => {\n // Check if this schema has a discriminator\n if (schema.discriminator) {\n discriminators.push({\n discriminator: schema.discriminator,\n oneOf: schema.oneOf,\n });\n }\n\n // If this schema is an allOf composition, recursively search in its components\n if (schema.allOf) {\n for (const compositionSchema of schema.allOf) {\n let resolvedSchema: SchemaObject;\n if ('$ref' in compositionSchema) {\n resolvedSchema = context.resolveRef<SchemaObject>(\n compositionSchema.$ref,\n );\n } else {\n resolvedSchema = compositionSchema;\n }\n\n findDiscriminatorsInSchema({\n context,\n discriminators,\n schema: resolvedSchema,\n });\n }\n }\n\n return discriminators;\n};\n\n/**\n * Gets the discriminator value for a schema.\n * Returns only the schema's own discriminator value, not child values.\n */\nconst getAllDiscriminatorValues = ({\n discriminator,\n schemaRef,\n}: {\n discriminator: NonNullable<SchemaObject['discriminator']>;\n schemaRef: string;\n}): Array<string> => {\n const values: Array<string> = [];\n\n // Check each entry in the discriminator mapping\n for (const [value, mappedSchemaRef] of Object.entries(\n discriminator.mapping || {},\n )) {\n if (mappedSchemaRef === schemaRef) {\n // This is the current schema's own value\n values.push(value);\n }\n }\n\n return values;\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\nexport const parseExtensions = ({\n source,\n target,\n}: {\n source: object;\n target: object;\n}) => {\n for (const key in source) {\n if (key.startsWith('x-')) {\n (target as Record<string, unknown>)[key] = (\n source as Record<string, unknown>\n )[key];\n }\n }\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 parseExtensions({\n source: schema,\n target: irSchema,\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 // Collect discriminator information to add after all compositions are processed\n type DiscriminatorInfo = {\n discriminator: NonNullable<SchemaObject['discriminator']>;\n isRequired: boolean;\n values: ReadonlyArray<string>;\n };\n const discriminatorsToAdd: Array<DiscriminatorInfo> = [];\n const addedDiscriminators = new Set<string>();\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 (state.$ref) {\n // Find all discriminators in the referenced schema, including nested allOf compositions\n const discriminators = findDiscriminatorsInSchema({\n context,\n schema: ref,\n });\n\n // Process each discriminator found\n for (const { discriminator, oneOf } of discriminators) {\n // Skip if we've already collected this discriminator property\n if (addedDiscriminators.has(discriminator.propertyName)) {\n continue;\n }\n\n const values = discriminatorValues(\n state.$ref,\n 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 oneOf\n ? () => oneOf.some((o) => '$ref' in o && o.$ref === state.$ref)\n : undefined,\n );\n\n if (values.length > 0) {\n // Check if the discriminator property is required in any of the discriminator schemas\n const isRequired = discriminators.some(\n (d) =>\n d.discriminator.propertyName === discriminator.propertyName &&\n // Check in the ref's required array or in the allOf components\n (ref.required?.includes(d.discriminator.propertyName) ||\n (ref.allOf &&\n ref.allOf.some((item) => {\n const resolvedItem =\n '$ref' in item\n ? context.resolveRef<SchemaObject>(item.$ref)\n : item;\n return resolvedItem.required?.includes(\n d.discriminator.propertyName,\n );\n }))),\n );\n\n discriminatorsToAdd.push({\n discriminator,\n isRequired,\n values,\n });\n addedDiscriminators.add(discriminator.propertyName);\n }\n }\n }\n }\n }\n\n // Now add discriminators after all compositions have been processed\n for (const { discriminator, isRequired, values } of discriminatorsToAdd) {\n // Get all discriminator values including children for union types\n const allValues = getAllDiscriminatorValues({\n discriminator,\n schemaRef: state.$ref!,\n });\n\n // Use allValues if we found children, otherwise use the original values\n const finalValues = allValues.length > 0 ? allValues : values;\n\n const valueSchemas: ReadonlyArray<IR.SchemaObject> = finalValues.map(\n (value) => ({\n const: value,\n type: 'string',\n }),\n );\n\n const discriminatorProperty: IR.SchemaObject =\n valueSchemas.length > 1\n ? {\n items: valueSchemas,\n logicalOperator: 'or',\n }\n : valueSchemas[0]!;\n\n // Check if any $ref schemas in schemaItems have this discriminator property\n // If yes, mark them to omit it to avoid conflicts\n for (const item of schemaItems) {\n if (item.$ref || item.symbolRef) {\n // Check if the referenced schema has this property\n const hasProperty = (() => {\n if (!item.$ref) return false;\n try {\n const refSchema = context.resolveRef<SchemaObject>(item.$ref);\n // Check if the discriminator property exists in the ref schema\n return (\n refSchema.properties?.[discriminator.propertyName] !==\n undefined ||\n (refSchema.allOf &&\n refSchema.allOf.some((allOfItem) => {\n const resolved =\n '$ref' in allOfItem\n ? context.resolveRef<SchemaObject>(allOfItem.$ref)\n : allOfItem;\n return (\n resolved.properties?.[discriminator.propertyName] !==\n undefined\n );\n }))\n );\n } catch {\n return false;\n }\n })();\n\n if (hasProperty) {\n // Mark this ref to omit the discriminator property\n if (!item.omit) {\n item.omit = [discriminator.propertyName];\n } else if (!item.omit.includes(discriminator.propertyName)) {\n item.omit = [...item.omit, discriminator.propertyName];\n }\n }\n }\n }\n\n // Find the inline schema (non-$ref) to merge the discriminator property into\n // The inline schema should be the last non-$ref item in schemaItems\n let inlineSchema: IR.SchemaObject | undefined;\n for (let i = schemaItems.length - 1; i >= 0; i--) {\n const item = schemaItems[i]!;\n // Check if this is not a $ref schema by looking for properties or checking if it came from an inline schema\n if (item.type === 'object' || item.properties) {\n inlineSchema = item;\n break;\n }\n }\n\n // If we found an inline schema, add the discriminator property to it\n if (inlineSchema) {\n if (!inlineSchema.properties) {\n inlineSchema.properties = {};\n }\n inlineSchema.properties[discriminator.propertyName] =\n discriminatorProperty;\n\n if (isRequired) {\n if (!inlineSchema.required) {\n inlineSchema.required = [];\n }\n if (!inlineSchema.required.includes(discriminator.propertyName)) {\n inlineSchema.required = [\n ...inlineSchema.required,\n discriminator.propertyName,\n ];\n }\n }\n } else {\n // Fallback: create a separate discriminator schema if no inline schema found\n const irDiscriminatorSchema: IR.SchemaObject = {\n properties: {\n [discriminator.propertyName]: discriminatorProperty,\n },\n type: 'object',\n };\n\n if (isRequired) {\n irDiscriminatorSchema.required = [discriminator.propertyName];\n }\n schemaItems.push(irDiscriminatorSchema);\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 ReferenceObject,\n RequestBodyObject,\n ResponseObject,\n SecuritySchemeObject,\n} from '../types/spec';\nimport { contentToSchema, mediaTypeObjects } from './mediaType';\nimport { paginationField } from './pagination';\nimport { parseExtensions, 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 parseExtensions({\n source: operation,\n target: irOperation,\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 (name.startsWith('x-')) continue;\n\n if (!irOperation.responses) {\n irOperation.responses = {};\n }\n\n const response = operation.responses[name]! as\n | ResponseObject\n | ReferenceObject;\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 { parseExtensions, 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 parseExtensions({\n source: parameter,\n target: irParameter,\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 if (path.startsWith('x-')) continue;\n const pathItem = context.spec.paths[\n path as keyof PathsObject\n ]! as PathItemObject;\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 `/${string}`,\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\n/**\n * Recursively finds discriminators in a schema, including nested allOf compositions.\n * This is needed when a schema extends another schema via allOf, and that parent\n * schema is itself an allOf composition with discriminators in inline schemas.\n */\nconst findDiscriminatorsInSchema = ({\n context,\n discriminators = [],\n schema,\n}: {\n context: Context;\n discriminators?: Array<{\n discriminator: NonNullable<SchemaObject['discriminator']>;\n oneOf?: SchemaObject['oneOf'];\n }>;\n schema: SchemaObject;\n}): Array<{\n discriminator: NonNullable<SchemaObject['discriminator']>;\n oneOf?: SchemaObject['oneOf'];\n}> => {\n // Check if this schema has a discriminator\n if (schema.discriminator) {\n discriminators.push({\n discriminator: schema.discriminator,\n oneOf: schema.oneOf,\n });\n }\n\n // If this schema is an allOf composition, recursively search in its components\n if (schema.allOf) {\n for (const compositionSchema of schema.allOf) {\n let resolvedSchema: SchemaObject;\n if (compositionSchema.$ref) {\n resolvedSchema = context.resolveRef<SchemaObject>(\n compositionSchema.$ref,\n );\n } else {\n resolvedSchema = compositionSchema;\n }\n\n findDiscriminatorsInSchema({\n context,\n discriminators,\n schema: resolvedSchema,\n });\n }\n }\n\n return discriminators;\n};\n\n/**\n * Gets the discriminator value for a schema.\n * Returns only the schema's own discriminator value, not child values.\n */\nconst getAllDiscriminatorValues = ({\n discriminator,\n schemaRef,\n}: {\n discriminator: NonNullable<SchemaObject['discriminator']>;\n schemaRef: string;\n}): Array<string> => {\n const values: Array<string> = [];\n\n // Check each entry in the discriminator mapping\n for (const [value, mappedSchemaRef] of Object.entries(\n discriminator.mapping || {},\n )) {\n if (mappedSchemaRef === schemaRef) {\n // This is the current schema's own value\n values.push(value);\n }\n }\n\n return values;\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\nexport const parseExtensions = ({\n source,\n target,\n}: {\n source: object;\n target: object;\n}) => {\n for (const key in source) {\n if (key.startsWith('x-')) {\n (target as Record<string, unknown>)[key] = (\n source as Record<string, unknown>\n )[key];\n }\n }\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 parseExtensions({\n source: schema,\n target: irSchema,\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 // Collect discriminator information to add after all compositions are processed\n type DiscriminatorInfo = {\n discriminator: NonNullable<SchemaObject['discriminator']>;\n isRequired: boolean;\n values: ReadonlyArray<string>;\n };\n const discriminatorsToAdd: Array<DiscriminatorInfo> = [];\n const addedDiscriminators = new Set<string>();\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 (state.$ref) {\n // Find all discriminators in the referenced schema, including nested allOf compositions\n const discriminators = findDiscriminatorsInSchema({\n context,\n schema: ref,\n });\n\n // Process each discriminator found\n for (const { discriminator, oneOf } of discriminators) {\n // Skip if we've already collected this discriminator property\n if (addedDiscriminators.has(discriminator.propertyName)) {\n continue;\n }\n\n const values = discriminatorValues(\n state.$ref,\n 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 oneOf\n ? () => oneOf.some((o) => '$ref' in o && o.$ref === state.$ref)\n : undefined,\n );\n\n if (values.length > 0) {\n // Check if the discriminator property is required in any of the discriminator schemas\n const isRequired = discriminators.some(\n (d) =>\n d.discriminator.propertyName === discriminator.propertyName &&\n // Check in the ref's required array or in the allOf components\n (ref.required?.includes(d.discriminator.propertyName) ||\n (ref.allOf &&\n ref.allOf.some((item) => {\n const resolvedItem = item.$ref\n ? context.resolveRef<SchemaObject>(item.$ref)\n : item;\n return resolvedItem.required?.includes(\n d.discriminator.propertyName,\n );\n }))),\n );\n\n discriminatorsToAdd.push({\n discriminator,\n isRequired,\n values,\n });\n addedDiscriminators.add(discriminator.propertyName);\n }\n }\n }\n }\n }\n\n // Now add discriminators after all compositions have been processed\n for (const { discriminator, isRequired, values } of discriminatorsToAdd) {\n // Get all discriminator values including children for union types\n const allValues = getAllDiscriminatorValues({\n discriminator,\n schemaRef: state.$ref!,\n });\n\n // Use allValues if we found children, otherwise use the original values\n const finalValues = allValues.length > 0 ? allValues : values;\n\n const valueSchemas: ReadonlyArray<IR.SchemaObject> = finalValues.map(\n (value) => ({\n const: value,\n type: 'string',\n }),\n );\n\n const discriminatorProperty: IR.SchemaObject =\n valueSchemas.length > 1\n ? {\n items: valueSchemas,\n logicalOperator: 'or',\n }\n : valueSchemas[0]!;\n\n // Check if any $ref schemas in schemaItems have this discriminator property\n // If yes, mark them to omit it to avoid conflicts\n for (const item of schemaItems) {\n if (item.$ref || item.symbolRef) {\n // Check if the referenced schema has this property\n const hasProperty = (() => {\n if (!item.$ref) return false;\n try {\n const refSchema = context.resolveRef<SchemaObject>(item.$ref);\n // Check if the discriminator property exists in the ref schema\n return (\n refSchema.properties?.[discriminator.propertyName] !==\n undefined ||\n (refSchema.allOf &&\n refSchema.allOf.some((allOfItem) => {\n const resolved = allOfItem.$ref\n ? context.resolveRef<SchemaObject>(allOfItem.$ref)\n : allOfItem;\n return (\n resolved.properties?.[discriminator.propertyName] !==\n undefined\n );\n }))\n );\n } catch {\n return false;\n }\n })();\n\n if (hasProperty) {\n // Mark this ref to omit the discriminator property\n if (!item.omit) {\n item.omit = [discriminator.propertyName];\n } else if (!item.omit.includes(discriminator.propertyName)) {\n item.omit = [...item.omit, discriminator.propertyName];\n }\n }\n }\n }\n\n // Find the inline schema (non-$ref) to merge the discriminator property into\n // The inline schema should be the last non-$ref item in schemaItems\n let inlineSchema: IR.SchemaObject | undefined;\n for (let i = schemaItems.length - 1; i >= 0; i--) {\n const item = schemaItems[i]!;\n // Check if this is not a $ref schema by looking for properties or checking if it came from an inline schema\n if (item.type === 'object' || item.properties) {\n inlineSchema = item;\n break;\n }\n }\n\n // If we found an inline schema, add the discriminator property to it\n if (inlineSchema) {\n if (!inlineSchema.properties) {\n inlineSchema.properties = {};\n }\n inlineSchema.properties[discriminator.propertyName] =\n discriminatorProperty;\n\n if (isRequired) {\n if (!inlineSchema.required) {\n inlineSchema.required = [];\n }\n if (!inlineSchema.required.includes(discriminator.propertyName)) {\n inlineSchema.required = [\n ...inlineSchema.required,\n discriminator.propertyName,\n ];\n }\n }\n } else {\n // Fallback: create a separate discriminator schema if no inline schema found\n const irDiscriminatorSchema: IR.SchemaObject = {\n properties: {\n [discriminator.propertyName]: discriminatorProperty,\n },\n type: 'object',\n };\n\n if (isRequired) {\n irDiscriminatorSchema.required = [discriminator.propertyName];\n }\n schemaItems.push(irDiscriminatorSchema);\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 ReferenceObject,\n RequestBodyObject,\n ResponseObject,\n SecuritySchemeObject,\n} from '../types/spec';\nimport { contentToSchema, mediaTypeObjects } from './mediaType';\nimport { paginationField } from './pagination';\nimport { parseExtensions, 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 parseExtensions({\n source: operation,\n target: irOperation,\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 (name.startsWith('x-')) continue;\n\n if (!irOperation.responses) {\n irOperation.responses = {};\n }\n\n const response = operation.responses[name]! as\n | ResponseObject\n | ReferenceObject;\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 { parseExtensions, 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 parseExtensions({\n source: parameter,\n target: irParameter,\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 if (path.startsWith('x-')) continue;\n const pathItem = context.spec.paths[\n path as keyof PathsObject\n ]! as PathItemObject;\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 `/${string}`,\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":"ijBAQA,MAAMA,GAAa,EAAc,OAAO,KAAK,IAAI,CAC3CC,GAAY,EAAK,QAAQD,GAAW,CAE7B,OAA6C,CACxD,IAAI,EAAMC,GACV,KAAO,IAAQ,EAAK,QAAQ,EAAI,EAAE,CAEhC,IAAM,EADQ,EAAG,YAAY,EAAI,CACR,OAAQ,GAAS,IAAS,eAAe,CAElE,GAAI,EAAW,GAAI,CACjB,IAAM,EAAkB,EAAK,KAAK,EAAK,EAAW,GAAG,CACrD,OAAO,KAAK,MACV,EAAG,aAAa,EAAiB,CAC/B,SAAU,OACX,CAAC,CACH,CAGH,EAAM,EAAK,QAAQ,EAAI,GAMd,OAAwB,CACnC,IAAM,EAAc,IAAiB,CAE/B,EAAc,CAClB,KAAM,CACJ,IAAK,GACN,CACD,KAAM,GACN,QAAS,GACV,CA4BD,OA1BI,GAAe,OAAO,GAAgB,WACpC,SAAU,GAAe,OAAO,EAAY,MAAS,WACvD,EAAY,KAAO,EAAY,MAG7B,YAAa,GAAe,OAAO,EAAY,SAAY,WAC7D,EAAY,QAAU,EAAY,SAIlC,SAAU,GACV,EAAY,MACZ,OAAO,EAAY,MAAS,UAG1B,QAAS,EAAY,MACrB,OAAO,EAAY,KAAK,KAAQ,WAEhC,EAAY,KAAK,IAAM,EAAY,KAAK,IACpC,EAAY,KAAK,KAAO,CAAC,EAAY,KAAK,IAAI,SAAS,IAAI,GAC7D,EAAY,KAAK,KAAO,OAMzB,GAGI,GACX,GACkB,CAClB,GAAI,IAAiB,KACnB,OAAO,KAGT,GAAI,EAAc,CAChB,IAAM,EAAW,EAAK,WAAW,EAAa,CAC1C,EACA,EAAK,QAAQA,GAAW,EAAa,CACzC,OAAO,EAAG,WAAW,EAAS,CAAG,EAAW,KAG9C,IAAI,EA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