@kubb/plugin-oas 5.0.0-alpha.21 → 5.0.0-alpha.23

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.
Files changed (37) hide show
  1. package/dist/{SchemaMapper-SneuY1wg.d.ts → SchemaMapper-CLIXrzqv.d.ts} +3 -3
  2. package/dist/SchemaMapper-CeavHZlp.cjs.map +1 -1
  3. package/dist/SchemaMapper-CqMkO2T1.js.map +1 -1
  4. package/dist/{createGenerator-BiZ9IsdY.d.ts → createGenerator-CSxQ1bji.d.ts} +20 -20
  5. package/dist/generators-85sP4GIS.cjs.map +1 -1
  6. package/dist/generators-hPE06pZB.js.map +1 -1
  7. package/dist/generators.d.ts +1 -1
  8. package/dist/hooks.cjs.map +1 -1
  9. package/dist/hooks.d.ts +7 -7
  10. package/dist/hooks.js.map +1 -1
  11. package/dist/index.cjs +1 -1
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/index.d.ts +4 -4
  14. package/dist/index.js +1 -1
  15. package/dist/index.js.map +1 -1
  16. package/dist/mocks.d.ts +1 -1
  17. package/dist/{requestBody-bs_SwfEj.js → requestBody-Ccu5imDC.js} +7 -3
  18. package/dist/requestBody-Ccu5imDC.js.map +1 -0
  19. package/dist/{requestBody-BHEEK1Z3.cjs → requestBody-DRmMq8Ds.cjs} +7 -3
  20. package/dist/requestBody-DRmMq8Ds.cjs.map +1 -0
  21. package/dist/utils.cjs +1 -1
  22. package/dist/utils.cjs.map +1 -1
  23. package/dist/utils.d.ts +4 -4
  24. package/dist/utils.js +1 -1
  25. package/dist/utils.js.map +1 -1
  26. package/package.json +3 -3
  27. package/src/OperationGenerator.ts +5 -5
  28. package/src/SchemaGenerator.ts +12 -8
  29. package/src/SchemaMapper.ts +2 -2
  30. package/src/generators/createGenerator.ts +7 -7
  31. package/src/hooks/useOperationManager.ts +3 -3
  32. package/src/hooks/useSchemaManager.ts +4 -4
  33. package/src/plugin.ts +2 -2
  34. package/src/types.ts +6 -6
  35. package/src/utils/getImports.ts +3 -3
  36. package/dist/requestBody-BHEEK1Z3.cjs.map +0 -1
  37. package/dist/requestBody-bs_SwfEj.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"utils.cjs","names":["#options","camelCase","#transformParam","#eachParam","SchemaGenerator","schemaKeywords","camelCase","camelCase"],"sources":["../../../internals/utils/src/reserved.ts","../../../internals/utils/src/urlPath.ts","../src/utils/getComments.ts","../src/utils/getImports.ts","../src/utils/getParams.ts","../src/utils/getSchemas.ts","../src/utils/paramsCasing.ts"],"sourcesContent":["/**\n * JavaScript and Java reserved words.\n * @link https://github.com/jonschlinkert/reserved/blob/master/index.js\n */\nconst reservedWords = new Set([\n 'abstract',\n 'arguments',\n 'boolean',\n 'break',\n 'byte',\n 'case',\n 'catch',\n 'char',\n 'class',\n 'const',\n 'continue',\n 'debugger',\n 'default',\n 'delete',\n 'do',\n 'double',\n 'else',\n 'enum',\n 'eval',\n 'export',\n 'extends',\n 'false',\n 'final',\n 'finally',\n 'float',\n 'for',\n 'function',\n 'goto',\n 'if',\n 'implements',\n 'import',\n 'in',\n 'instanceof',\n 'int',\n 'interface',\n 'let',\n 'long',\n 'native',\n 'new',\n 'null',\n 'package',\n 'private',\n 'protected',\n 'public',\n 'return',\n 'short',\n 'static',\n 'super',\n 'switch',\n 'synchronized',\n 'this',\n 'throw',\n 'throws',\n 'transient',\n 'true',\n 'try',\n 'typeof',\n 'var',\n 'void',\n 'volatile',\n 'while',\n 'with',\n 'yield',\n 'Array',\n 'Date',\n 'hasOwnProperty',\n 'Infinity',\n 'isFinite',\n 'isNaN',\n 'isPrototypeOf',\n 'length',\n 'Math',\n 'name',\n 'NaN',\n 'Number',\n 'Object',\n 'prototype',\n 'String',\n 'toString',\n 'undefined',\n 'valueOf',\n] as const)\n\n/**\n * Prefixes `word` with `_` when it is a reserved JavaScript/Java identifier or starts with a digit.\n *\n * @example\n * ```ts\n * transformReservedWord('class') // '_class'\n * transformReservedWord('42foo') // '_42foo'\n * transformReservedWord('status') // 'status'\n * ```\n */\nexport function transformReservedWord(word: string): string {\n const firstChar = word.charCodeAt(0)\n if (word && (reservedWords.has(word as 'valueOf') || (firstChar >= 48 && firstChar <= 57))) {\n return `_${word}`\n }\n return word\n}\n\n/**\n * Returns `true` when `name` is a syntactically valid JavaScript variable name.\n *\n * @example\n * ```ts\n * isValidVarName('status') // true\n * isValidVarName('class') // false (reserved word)\n * isValidVarName('42foo') // false (starts with digit)\n * ```\n */\nexport function isValidVarName(name: string): boolean {\n try {\n new Function(`var ${name}`)\n } catch {\n return false\n }\n return true\n}\n","import { camelCase } from './casing.ts'\nimport { isValidVarName } from './reserved.ts'\n\nexport type URLObject = {\n /**\n * The resolved URL string (Express-style or template literal, depending on context).\n */\n url: string\n /**\n * Extracted path parameters as a key-value map, or `undefined` when the path has none.\n */\n params?: Record<string, string>\n}\n\ntype ObjectOptions = {\n /**\n * Controls whether the `url` is rendered as an Express path or a template literal.\n * @default 'path'\n */\n type?: 'path' | 'template'\n /**\n * Optional transform applied to each extracted parameter name.\n */\n replacer?: (pathParam: string) => string\n /**\n * When `true`, the result is serialized to a string expression instead of a plain object.\n */\n stringify?: boolean\n}\n\n/**\n * Supported identifier casing strategies for path parameters.\n */\ntype PathCasing = 'camelcase'\n\ntype Options = {\n /**\n * Casing strategy applied to path parameter names.\n * @default undefined (original identifier preserved)\n */\n casing?: PathCasing\n}\n\n/**\n * Parses and transforms an OpenAPI/Swagger path string into various URL formats.\n *\n * @example\n * const p = new URLPath('/pet/{petId}')\n * p.URL // '/pet/:petId'\n * p.template // '`/pet/${petId}`'\n */\nexport class URLPath {\n /**\n * The raw OpenAPI/Swagger path string, e.g. `/pet/{petId}`.\n */\n path: string\n\n #options: Options\n\n constructor(path: string, options: Options = {}) {\n this.path = path\n this.#options = options\n }\n\n /** Converts the OpenAPI path to Express-style colon syntax, e.g. `/pet/{petId}` → `/pet/:petId`.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}').URL // '/pet/:petId'\n * ```\n */\n get URL(): string {\n return this.toURLPath()\n }\n\n /** Returns `true` when `path` is a fully-qualified URL (e.g. starts with `https://`).\n *\n * @example\n * ```ts\n * new URLPath('https://petstore.swagger.io/v2/pet').isURL // true\n * new URLPath('/pet/{petId}').isURL // false\n * ```\n */\n get isURL(): boolean {\n try {\n return !!new URL(this.path).href\n } catch {\n return false\n }\n }\n\n /**\n * Converts the OpenAPI path to a TypeScript template literal string.\n *\n * @example\n * new URLPath('/pet/{petId}').template // '`/pet/${petId}`'\n * new URLPath('/account/monetary-accountID').template // '`/account/${monetaryAccountId}`'\n */\n get template(): string {\n return this.toTemplateString()\n }\n\n /** Returns the path and its extracted params as a structured `URLObject`, or as a stringified expression when `stringify` is set.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}').object\n * // { url: '/pet/:petId', params: { petId: 'petId' } }\n * ```\n */\n get object(): URLObject | string {\n return this.toObject()\n }\n\n /** Returns a map of path parameter names, or `undefined` when the path has no parameters.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}').params // { petId: 'petId' }\n * new URLPath('/pet').params // undefined\n * ```\n */\n get params(): Record<string, string> | undefined {\n return this.getParams()\n }\n\n #transformParam(raw: string): string {\n const param = isValidVarName(raw) ? raw : camelCase(raw)\n return this.#options.casing === 'camelcase' ? camelCase(param) : param\n }\n\n /**\n * Iterates over every `{param}` token in `path`, calling `fn` with the raw token and transformed name.\n */\n #eachParam(fn: (raw: string, param: string) => void): void {\n for (const match of this.path.matchAll(/\\{([^}]+)\\}/g)) {\n const raw = match[1]!\n fn(raw, this.#transformParam(raw))\n }\n }\n\n toObject({ type = 'path', replacer, stringify }: ObjectOptions = {}): URLObject | string {\n const object = {\n url: type === 'path' ? this.toURLPath() : this.toTemplateString({ replacer }),\n params: this.getParams(),\n }\n\n if (stringify) {\n if (type === 'template') {\n return JSON.stringify(object).replaceAll(\"'\", '').replaceAll(`\"`, '')\n }\n\n if (object.params) {\n return `{ url: '${object.url}', params: ${JSON.stringify(object.params).replaceAll(\"'\", '').replaceAll(`\"`, '')} }`\n }\n\n return `{ url: '${object.url}' }`\n }\n\n return object\n }\n\n /**\n * Converts the OpenAPI path to a TypeScript template literal string.\n * An optional `replacer` can transform each extracted parameter name before interpolation.\n *\n * @example\n * new URLPath('/pet/{petId}').toTemplateString() // '`/pet/${petId}`'\n */\n toTemplateString({ prefix = '', replacer }: { prefix?: string; replacer?: (pathParam: string) => string } = {}): string {\n const parts = this.path.split(/\\{([^}]+)\\}/)\n const result = parts\n .map((part, i) => {\n if (i % 2 === 0) return part\n const param = this.#transformParam(part)\n return `\\${${replacer ? replacer(param) : param}}`\n })\n .join('')\n\n return `\\`${prefix}${result}\\``\n }\n\n /**\n * Extracts all `{param}` segments from the path and returns them as a key-value map.\n * An optional `replacer` transforms each parameter name in both key and value positions.\n * Returns `undefined` when no path parameters are found.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}/tag/{tagId}').getParams()\n * // { petId: 'petId', tagId: 'tagId' }\n * ```\n */\n getParams(replacer?: (pathParam: string) => string): Record<string, string> | undefined {\n const params: Record<string, string> = {}\n\n this.#eachParam((_raw, param) => {\n const key = replacer ? replacer(param) : param\n params[key] = key\n })\n\n return Object.keys(params).length > 0 ? params : undefined\n }\n\n /** Converts the OpenAPI path to Express-style colon syntax.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}').toURLPath() // '/pet/:petId'\n * ```\n */\n toURLPath(): string {\n return this.path.replace(/\\{([^}]+)\\}/g, ':$1')\n }\n}\n","import { URLPath } from '@internals/utils'\nimport type { Operation } from '@kubb/oas'\n\nexport function getComments(operation: Operation): string[] {\n return [\n operation.getDescription() && `@description ${operation.getDescription()}`,\n operation.getSummary() && `@summary ${operation.getSummary()}`,\n operation.path && `{@link ${new URLPath(operation.path).URL}}`,\n operation.isDeprecated() && '@deprecated',\n ]\n .filter((x): x is string => Boolean(x))\n .flatMap((text) => {\n return text.split(/\\r?\\n/).map((line) => line.trim())\n })\n .filter((x): x is string => Boolean(x))\n}\n","import type { KubbFile } from '@kubb/fabric-core/types'\nimport { SchemaGenerator } from '../SchemaGenerator.ts'\nimport type { Schema } from '../SchemaMapper'\nimport { schemaKeywords } from '../SchemaMapper'\n\n/**\n * Get imports from a schema tree by extracting all ref schemas that are importable\n */\nexport function getImports(tree: Array<Schema>): Array<KubbFile.Import> {\n const refs = SchemaGenerator.deepSearch(tree, schemaKeywords.ref)\n\n if (!refs) return []\n\n return refs\n .map((item) => {\n if (!item.args.path || !item.args.isImportable) {\n return undefined\n }\n\n return {\n name: [item.args.name],\n path: item.args.path,\n } satisfies KubbFile.Import\n })\n .filter((x): x is NonNullable<typeof x> => x !== undefined)\n}\n","import { camelCase, isValidVarName } from '@internals/utils'\nimport type { FunctionParamsAST } from '@kubb/core'\nimport type { OasTypes } from '@kubb/oas'\nimport type { Params } from '@kubb/react-fabric/types'\nimport type { OperationSchema } from '../types.ts'\n/**\n *\n * @deprecated\n * TODO move to operationManager hook\n */\nexport function getASTParams(\n operationSchema: OperationSchema | undefined,\n {\n typed = false,\n casing,\n override,\n }: {\n typed?: boolean\n casing?: 'camelcase'\n override?: (data: FunctionParamsAST) => FunctionParamsAST\n } = {},\n): FunctionParamsAST[] {\n if (!operationSchema?.schema.properties || !operationSchema.name) {\n return []\n }\n\n const requiredFields = Array.isArray(operationSchema.schema.required) ? operationSchema.schema.required : []\n\n return Object.entries(operationSchema.schema.properties).map(([name]: [string, OasTypes.SchemaObject]) => {\n // Use camelCase name for indexed access if casing is enabled\n const accessName = casing === 'camelcase' ? camelCase(name) : name\n\n const data: FunctionParamsAST = {\n name,\n enabled: !!name,\n required: requiredFields.includes(name),\n type: typed ? `${operationSchema.name}[\"${accessName}\"]` : undefined,\n }\n\n return override ? override(data) : data\n })\n}\n\nexport function getPathParams(\n operationSchema: OperationSchema | undefined,\n options: {\n typed?: boolean\n casing?: 'camelcase'\n override?: (data: FunctionParamsAST) => FunctionParamsAST\n } = {},\n) {\n return getASTParams(operationSchema, options).reduce((acc, curr) => {\n if (curr.name && curr.enabled) {\n let name = curr.name\n\n // Only transform to camelCase if explicitly requested\n if (options.casing === 'camelcase') {\n name = camelCase(name)\n } else if (!isValidVarName(name)) {\n // If not valid variable name and casing not set, still need to make it valid\n name = camelCase(name)\n }\n\n acc[name] = {\n default: curr.default,\n type: curr.type,\n optional: !curr.required,\n }\n }\n\n return acc\n }, {} as Params)\n}\n\n/**\n * Get a mapping of camelCase parameter names to their original names\n * Used for mapping function parameters to backend parameter names\n */\nexport function getParamsMapping(\n operationSchema: OperationSchema | undefined,\n options: {\n casing?: 'camelcase'\n } = {},\n): Record<string, string> | undefined {\n if (!operationSchema?.schema.properties) {\n return undefined\n }\n\n const allEntries: Array<[string, string]> = []\n let hasTransformation = false\n\n Object.entries(operationSchema.schema.properties).forEach(([originalName]) => {\n let transformedName = originalName\n\n // Only transform to camelCase if explicitly requested\n if (options.casing === 'camelcase') {\n transformedName = camelCase(originalName)\n } else if (!isValidVarName(originalName)) {\n // If not valid variable name and casing not set, still need to make it valid\n transformedName = camelCase(originalName)\n }\n\n allEntries.push([originalName, transformedName])\n\n if (transformedName !== originalName) {\n hasTransformation = true\n }\n })\n\n // When using explicit casing and there are transformations, include ALL params so that\n // mappedParams contains every parameter (not just the ones whose names changed).\n // This prevents params with already-camelCase names (e.g. 'page', 'search') from being\n // silently dropped when other params in the same schema do need transformation.\n if (options.casing === 'camelcase' && hasTransformation) {\n return Object.fromEntries(allEntries)\n }\n\n // When casing is not specified or no transformations are needed, only return changed entries\n const mapping: Record<string, string> = {}\n allEntries.forEach(([originalName, transformedName]) => {\n if (transformedName !== originalName) {\n mapping[originalName] = transformedName\n }\n })\n\n return Object.keys(mapping).length > 0 ? mapping : undefined\n}\n","import type { contentType, Oas, OasTypes } from '@kubb/oas'\n\nexport type GetSchemasResult = {\n schemas: Record<string, OasTypes.SchemaObject>\n /**\n * Mapping from original component name to resolved name after collision handling\n * e.g., { 'Order': 'OrderSchema', 'variant': 'variant2' }\n */\n nameMapping: Map<string, string>\n}\n\ntype Mode = 'schemas' | 'responses' | 'requestBodies'\n\ntype GetSchemasProps = {\n oas: Oas\n contentType?: contentType\n includes?: Mode[]\n /**\n * Whether to resolve name collisions with suffixes.\n * If not provided, uses oas.options.collisionDetection\n * @default false (from oas.options or fallback)\n */\n collisionDetection?: boolean\n}\n\n/**\n * Collect schemas from OpenAPI components (schemas, responses, requestBodies)\n * and return them in dependency order along with name mapping for collision resolution.\n *\n * This function is a wrapper around the oas.getSchemas() method for backward compatibility.\n * New code should use oas.getSchemas() directly.\n *\n * @deprecated Use oas.getSchemas() instead\n */\nexport function getSchemas({ oas, contentType, includes = ['schemas', 'requestBodies', 'responses'], collisionDetection }: GetSchemasProps): GetSchemasResult {\n return oas.getSchemas({\n contentType,\n includes,\n collisionDetection,\n })\n}\n","import { camelCase, isValidVarName } from '@internals/utils'\nimport type { SchemaObject } from '@kubb/oas'\n\n/**\n * Apply casing transformation to schema properties\n * Only transforms property names, not nested schemas\n */\nexport function applyParamsCasing(schema: SchemaObject, casing: 'camelcase' | undefined): SchemaObject {\n if (!casing || !schema.properties) {\n return schema\n }\n\n const transformedProperties: Record<string, any> = {}\n const transformedRequired: string[] = []\n\n // Transform property names\n Object.entries(schema.properties).forEach(([originalName, propertySchema]) => {\n let transformedName = originalName\n\n if (casing === 'camelcase') {\n transformedName = camelCase(originalName)\n } else if (!isValidVarName(originalName)) {\n // If not valid variable name, make it valid\n transformedName = camelCase(originalName)\n }\n\n transformedProperties[transformedName] = propertySchema\n })\n\n // Transform required field names\n if (Array.isArray(schema.required)) {\n schema.required.forEach((originalName) => {\n let transformedName = originalName\n\n if (casing === 'camelcase') {\n transformedName = camelCase(originalName)\n } else if (!isValidVarName(originalName)) {\n transformedName = camelCase(originalName)\n }\n\n transformedRequired.push(transformedName)\n })\n }\n\n // Return a new schema with transformed properties and required fields\n return {\n ...schema,\n properties: transformedProperties,\n ...(transformedRequired.length > 0 && { required: transformedRequired }),\n } as SchemaObject\n}\n\n/**\n * Check if this schema is a parameter schema (pathParams, queryParams, or headerParams)\n * Only these should be transformed, not response/data/body\n */\nexport function isParameterSchema(schemaName: string): boolean {\n const lowerName = schemaName.toLowerCase()\n return lowerName.includes('pathparams') || lowerName.includes('queryparams') || lowerName.includes('headerparams')\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAoHA,SAAgB,eAAe,MAAuB;AACpD,KAAI;AACF,MAAI,SAAS,OAAO,OAAO;SACrB;AACN,SAAO;;AAET,QAAO;;;;;;;;;;;;ACvET,IAAa,UAAb,MAAqB;;;;CAInB;CAEA;CAEA,YAAY,MAAc,UAAmB,EAAE,EAAE;AAC/C,OAAK,OAAO;AACZ,QAAA,UAAgB;;;;;;;;;CAUlB,IAAI,MAAc;AAChB,SAAO,KAAK,WAAW;;;;;;;;;;CAWzB,IAAI,QAAiB;AACnB,MAAI;AACF,UAAO,CAAC,CAAC,IAAI,IAAI,KAAK,KAAK,CAAC;UACtB;AACN,UAAO;;;;;;;;;;CAWX,IAAI,WAAmB;AACrB,SAAO,KAAK,kBAAkB;;;;;;;;;;CAWhC,IAAI,SAA6B;AAC/B,SAAO,KAAK,UAAU;;;;;;;;;;CAWxB,IAAI,SAA6C;AAC/C,SAAO,KAAK,WAAW;;CAGzB,gBAAgB,KAAqB;EACnC,MAAM,QAAQ,eAAe,IAAI,GAAG,MAAMC,kBAAAA,UAAU,IAAI;AACxD,SAAO,MAAA,QAAc,WAAW,cAAcA,kBAAAA,UAAU,MAAM,GAAG;;;;;CAMnE,WAAW,IAAgD;AACzD,OAAK,MAAM,SAAS,KAAK,KAAK,SAAS,eAAe,EAAE;GACtD,MAAM,MAAM,MAAM;AAClB,MAAG,KAAK,MAAA,eAAqB,IAAI,CAAC;;;CAItC,SAAS,EAAE,OAAO,QAAQ,UAAU,cAA6B,EAAE,EAAsB;EACvF,MAAM,SAAS;GACb,KAAK,SAAS,SAAS,KAAK,WAAW,GAAG,KAAK,iBAAiB,EAAE,UAAU,CAAC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,kBAAAA,UAAU,aAAa;WAChC,CAAC,eAAe,aAAa,CAEtC,mBAAkBA,kBAAAA,UAAU,aAAa;AAG3C,wBAAsB,mBAAmB;GACzC;AAGF,KAAI,MAAM,QAAQ,OAAO,SAAS,CAChC,QAAO,SAAS,SAAS,iBAAiB;EACxC,IAAI,kBAAkB;AAEtB,MAAI,WAAW,YACb,mBAAkBA,kBAAAA,UAAU,aAAa;WAChC,CAAC,eAAe,aAAa,CACtC,mBAAkBA,kBAAAA,UAAU,aAAa;AAG3C,sBAAoB,KAAK,gBAAgB;GACzC;AAIJ,QAAO;EACL,GAAG;EACH,YAAY;EACZ,GAAI,oBAAoB,SAAS,KAAK,EAAE,UAAU,qBAAqB;EACxE;;;;;;AAOH,SAAgB,kBAAkB,YAA6B;CAC7D,MAAM,YAAY,WAAW,aAAa;AAC1C,QAAO,UAAU,SAAS,aAAa,IAAI,UAAU,SAAS,cAAc,IAAI,UAAU,SAAS,eAAe"}
1
+ {"version":3,"file":"utils.cjs","names":["#options","camelCase","#transformParam","#eachParam","SchemaGenerator","schemaKeywords","camelCase","camelCase"],"sources":["../../../internals/utils/src/reserved.ts","../../../internals/utils/src/urlPath.ts","../src/utils/getComments.ts","../src/utils/getImports.ts","../src/utils/getParams.ts","../src/utils/getSchemas.ts","../src/utils/paramsCasing.ts"],"sourcesContent":["/**\n * JavaScript and Java reserved words.\n * @link https://github.com/jonschlinkert/reserved/blob/master/index.js\n */\nconst reservedWords = new Set([\n 'abstract',\n 'arguments',\n 'boolean',\n 'break',\n 'byte',\n 'case',\n 'catch',\n 'char',\n 'class',\n 'const',\n 'continue',\n 'debugger',\n 'default',\n 'delete',\n 'do',\n 'double',\n 'else',\n 'enum',\n 'eval',\n 'export',\n 'extends',\n 'false',\n 'final',\n 'finally',\n 'float',\n 'for',\n 'function',\n 'goto',\n 'if',\n 'implements',\n 'import',\n 'in',\n 'instanceof',\n 'int',\n 'interface',\n 'let',\n 'long',\n 'native',\n 'new',\n 'null',\n 'package',\n 'private',\n 'protected',\n 'public',\n 'return',\n 'short',\n 'static',\n 'super',\n 'switch',\n 'synchronized',\n 'this',\n 'throw',\n 'throws',\n 'transient',\n 'true',\n 'try',\n 'typeof',\n 'var',\n 'void',\n 'volatile',\n 'while',\n 'with',\n 'yield',\n 'Array',\n 'Date',\n 'hasOwnProperty',\n 'Infinity',\n 'isFinite',\n 'isNaN',\n 'isPrototypeOf',\n 'length',\n 'Math',\n 'name',\n 'NaN',\n 'Number',\n 'Object',\n 'prototype',\n 'String',\n 'toString',\n 'undefined',\n 'valueOf',\n] as const)\n\n/**\n * Prefixes `word` with `_` when it is a reserved JavaScript/Java identifier or starts with a digit.\n *\n * @example\n * ```ts\n * transformReservedWord('class') // '_class'\n * transformReservedWord('42foo') // '_42foo'\n * transformReservedWord('status') // 'status'\n * ```\n */\nexport function transformReservedWord(word: string): string {\n const firstChar = word.charCodeAt(0)\n if (word && (reservedWords.has(word as 'valueOf') || (firstChar >= 48 && firstChar <= 57))) {\n return `_${word}`\n }\n return word\n}\n\n/**\n * Returns `true` when `name` is a syntactically valid JavaScript variable name.\n *\n * @example\n * ```ts\n * isValidVarName('status') // true\n * isValidVarName('class') // false (reserved word)\n * isValidVarName('42foo') // false (starts with digit)\n * ```\n */\nexport function isValidVarName(name: string): boolean {\n try {\n new Function(`var ${name}`)\n } catch {\n return false\n }\n return true\n}\n","import { camelCase } from './casing.ts'\nimport { isValidVarName } from './reserved.ts'\n\nexport type URLObject = {\n /**\n * The resolved URL string (Express-style or template literal, depending on context).\n */\n url: string\n /**\n * Extracted path parameters as a key-value map, or `undefined` when the path has none.\n */\n params?: Record<string, string>\n}\n\ntype ObjectOptions = {\n /**\n * Controls whether the `url` is rendered as an Express path or a template literal.\n * @default 'path'\n */\n type?: 'path' | 'template'\n /**\n * Optional transform applied to each extracted parameter name.\n */\n replacer?: (pathParam: string) => string\n /**\n * When `true`, the result is serialized to a string expression instead of a plain object.\n */\n stringify?: boolean\n}\n\n/**\n * Supported identifier casing strategies for path parameters.\n */\ntype PathCasing = 'camelcase'\n\ntype Options = {\n /**\n * Casing strategy applied to path parameter names.\n * @default undefined (original identifier preserved)\n */\n casing?: PathCasing\n}\n\n/**\n * Parses and transforms an OpenAPI/Swagger path string into various URL formats.\n *\n * @example\n * const p = new URLPath('/pet/{petId}')\n * p.URL // '/pet/:petId'\n * p.template // '`/pet/${petId}`'\n */\nexport class URLPath {\n /**\n * The raw OpenAPI/Swagger path string, e.g. `/pet/{petId}`.\n */\n path: string\n\n #options: Options\n\n constructor(path: string, options: Options = {}) {\n this.path = path\n this.#options = options\n }\n\n /** Converts the OpenAPI path to Express-style colon syntax, e.g. `/pet/{petId}` → `/pet/:petId`.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}').URL // '/pet/:petId'\n * ```\n */\n get URL(): string {\n return this.toURLPath()\n }\n\n /** Returns `true` when `path` is a fully-qualified URL (e.g. starts with `https://`).\n *\n * @example\n * ```ts\n * new URLPath('https://petstore.swagger.io/v2/pet').isURL // true\n * new URLPath('/pet/{petId}').isURL // false\n * ```\n */\n get isURL(): boolean {\n try {\n return !!new URL(this.path).href\n } catch {\n return false\n }\n }\n\n /**\n * Converts the OpenAPI path to a TypeScript template literal string.\n *\n * @example\n * new URLPath('/pet/{petId}').template // '`/pet/${petId}`'\n * new URLPath('/account/monetary-accountID').template // '`/account/${monetaryAccountId}`'\n */\n get template(): string {\n return this.toTemplateString()\n }\n\n /** Returns the path and its extracted params as a structured `URLObject`, or as a stringified expression when `stringify` is set.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}').object\n * // { url: '/pet/:petId', params: { petId: 'petId' } }\n * ```\n */\n get object(): URLObject | string {\n return this.toObject()\n }\n\n /** Returns a map of path parameter names, or `undefined` when the path has no parameters.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}').params // { petId: 'petId' }\n * new URLPath('/pet').params // undefined\n * ```\n */\n get params(): Record<string, string> | undefined {\n return this.getParams()\n }\n\n #transformParam(raw: string): string {\n const param = isValidVarName(raw) ? raw : camelCase(raw)\n return this.#options.casing === 'camelcase' ? camelCase(param) : param\n }\n\n /**\n * Iterates over every `{param}` token in `path`, calling `fn` with the raw token and transformed name.\n */\n #eachParam(fn: (raw: string, param: string) => void): void {\n for (const match of this.path.matchAll(/\\{([^}]+)\\}/g)) {\n const raw = match[1]!\n fn(raw, this.#transformParam(raw))\n }\n }\n\n toObject({ type = 'path', replacer, stringify }: ObjectOptions = {}): URLObject | string {\n const object = {\n url: type === 'path' ? this.toURLPath() : this.toTemplateString({ replacer }),\n params: this.getParams(),\n }\n\n if (stringify) {\n if (type === 'template') {\n return JSON.stringify(object).replaceAll(\"'\", '').replaceAll(`\"`, '')\n }\n\n if (object.params) {\n return `{ url: '${object.url}', params: ${JSON.stringify(object.params).replaceAll(\"'\", '').replaceAll(`\"`, '')} }`\n }\n\n return `{ url: '${object.url}' }`\n }\n\n return object\n }\n\n /**\n * Converts the OpenAPI path to a TypeScript template literal string.\n * An optional `replacer` can transform each extracted parameter name before interpolation.\n *\n * @example\n * new URLPath('/pet/{petId}').toTemplateString() // '`/pet/${petId}`'\n */\n toTemplateString({ prefix = '', replacer }: { prefix?: string; replacer?: (pathParam: string) => string } = {}): string {\n const parts = this.path.split(/\\{([^}]+)\\}/)\n const result = parts\n .map((part, i) => {\n if (i % 2 === 0) return part\n const param = this.#transformParam(part)\n return `\\${${replacer ? replacer(param) : param}}`\n })\n .join('')\n\n return `\\`${prefix}${result}\\``\n }\n\n /**\n * Extracts all `{param}` segments from the path and returns them as a key-value map.\n * An optional `replacer` transforms each parameter name in both key and value positions.\n * Returns `undefined` when no path parameters are found.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}/tag/{tagId}').getParams()\n * // { petId: 'petId', tagId: 'tagId' }\n * ```\n */\n getParams(replacer?: (pathParam: string) => string): Record<string, string> | undefined {\n const params: Record<string, string> = {}\n\n this.#eachParam((_raw, param) => {\n const key = replacer ? replacer(param) : param\n params[key] = key\n })\n\n return Object.keys(params).length > 0 ? params : undefined\n }\n\n /** Converts the OpenAPI path to Express-style colon syntax.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}').toURLPath() // '/pet/:petId'\n * ```\n */\n toURLPath(): string {\n return this.path.replace(/\\{([^}]+)\\}/g, ':$1')\n }\n}\n","import { URLPath } from '@internals/utils'\nimport type { Operation } from '@kubb/oas'\n\nexport function getComments(operation: Operation): string[] {\n return [\n operation.getDescription() && `@description ${operation.getDescription()}`,\n operation.getSummary() && `@summary ${operation.getSummary()}`,\n operation.path && `{@link ${new URLPath(operation.path).URL}}`,\n operation.isDeprecated() && '@deprecated',\n ]\n .filter((x): x is string => Boolean(x))\n .flatMap((text) => {\n return text.split(/\\r?\\n/).map((line) => line.trim())\n })\n .filter((x): x is string => Boolean(x))\n}\n","import type { FabricFile } from '@kubb/fabric-core/types'\nimport { SchemaGenerator } from '../SchemaGenerator.ts'\nimport type { Schema } from '../SchemaMapper'\nimport { schemaKeywords } from '../SchemaMapper'\n\n/**\n * Get imports from a schema tree by extracting all ref schemas that are importable\n */\nexport function getImports(tree: Array<Schema>): Array<FabricFile.Import> {\n const refs = SchemaGenerator.deepSearch(tree, schemaKeywords.ref)\n\n if (!refs) return []\n\n return refs\n .map((item) => {\n if (!item.args.path || !item.args.isImportable) {\n return undefined\n }\n\n return {\n name: [item.args.name],\n path: item.args.path,\n } satisfies FabricFile.Import\n })\n .filter((x): x is NonNullable<typeof x> => x !== undefined)\n}\n","import { camelCase, isValidVarName } from '@internals/utils'\nimport type { FunctionParamsAST } from '@kubb/core'\nimport type { OasTypes } from '@kubb/oas'\nimport type { Params } from '@kubb/react-fabric/types'\nimport type { OperationSchema } from '../types.ts'\n/**\n *\n * @deprecated\n * TODO move to operationManager hook\n */\nexport function getASTParams(\n operationSchema: OperationSchema | undefined,\n {\n typed = false,\n casing,\n override,\n }: {\n typed?: boolean\n casing?: 'camelcase'\n override?: (data: FunctionParamsAST) => FunctionParamsAST\n } = {},\n): FunctionParamsAST[] {\n if (!operationSchema?.schema.properties || !operationSchema.name) {\n return []\n }\n\n const requiredFields = Array.isArray(operationSchema.schema.required) ? operationSchema.schema.required : []\n\n return Object.entries(operationSchema.schema.properties).map(([name]: [string, OasTypes.SchemaObject]) => {\n // Use camelCase name for indexed access if casing is enabled\n const accessName = casing === 'camelcase' ? camelCase(name) : name\n\n const data: FunctionParamsAST = {\n name,\n enabled: !!name,\n required: requiredFields.includes(name),\n type: typed ? `${operationSchema.name}[\"${accessName}\"]` : undefined,\n }\n\n return override ? override(data) : data\n })\n}\n\nexport function getPathParams(\n operationSchema: OperationSchema | undefined,\n options: {\n typed?: boolean\n casing?: 'camelcase'\n override?: (data: FunctionParamsAST) => FunctionParamsAST\n } = {},\n) {\n return getASTParams(operationSchema, options).reduce((acc, curr) => {\n if (curr.name && curr.enabled) {\n let name = curr.name\n\n // Only transform to camelCase if explicitly requested\n if (options.casing === 'camelcase') {\n name = camelCase(name)\n } else if (!isValidVarName(name)) {\n // If not valid variable name and casing not set, still need to make it valid\n name = camelCase(name)\n }\n\n acc[name] = {\n default: curr.default,\n type: curr.type,\n optional: !curr.required,\n }\n }\n\n return acc\n }, {} as Params)\n}\n\n/**\n * Get a mapping of camelCase parameter names to their original names\n * Used for mapping function parameters to backend parameter names\n */\nexport function getParamsMapping(\n operationSchema: OperationSchema | undefined,\n options: {\n casing?: 'camelcase'\n } = {},\n): Record<string, string> | undefined {\n if (!operationSchema?.schema.properties) {\n return undefined\n }\n\n const allEntries: Array<[string, string]> = []\n let hasTransformation = false\n\n Object.entries(operationSchema.schema.properties).forEach(([originalName]) => {\n let transformedName = originalName\n\n // Only transform to camelCase if explicitly requested\n if (options.casing === 'camelcase') {\n transformedName = camelCase(originalName)\n } else if (!isValidVarName(originalName)) {\n // If not valid variable name and casing not set, still need to make it valid\n transformedName = camelCase(originalName)\n }\n\n allEntries.push([originalName, transformedName])\n\n if (transformedName !== originalName) {\n hasTransformation = true\n }\n })\n\n // When using explicit casing and there are transformations, include ALL params so that\n // mappedParams contains every parameter (not just the ones whose names changed).\n // This prevents params with already-camelCase names (e.g. 'page', 'search') from being\n // silently dropped when other params in the same schema do need transformation.\n if (options.casing === 'camelcase' && hasTransformation) {\n return Object.fromEntries(allEntries)\n }\n\n // When casing is not specified or no transformations are needed, only return changed entries\n const mapping: Record<string, string> = {}\n allEntries.forEach(([originalName, transformedName]) => {\n if (transformedName !== originalName) {\n mapping[originalName] = transformedName\n }\n })\n\n return Object.keys(mapping).length > 0 ? mapping : undefined\n}\n","import type { contentType, Oas, OasTypes } from '@kubb/oas'\n\nexport type GetSchemasResult = {\n schemas: Record<string, OasTypes.SchemaObject>\n /**\n * Mapping from original component name to resolved name after collision handling\n * e.g., { 'Order': 'OrderSchema', 'variant': 'variant2' }\n */\n nameMapping: Map<string, string>\n}\n\ntype Mode = 'schemas' | 'responses' | 'requestBodies'\n\ntype GetSchemasProps = {\n oas: Oas\n contentType?: contentType\n includes?: Mode[]\n /**\n * Whether to resolve name collisions with suffixes.\n * If not provided, uses oas.options.collisionDetection\n * @default false (from oas.options or fallback)\n */\n collisionDetection?: boolean\n}\n\n/**\n * Collect schemas from OpenAPI components (schemas, responses, requestBodies)\n * and return them in dependency order along with name mapping for collision resolution.\n *\n * This function is a wrapper around the oas.getSchemas() method for backward compatibility.\n * New code should use oas.getSchemas() directly.\n *\n * @deprecated Use oas.getSchemas() instead\n */\nexport function getSchemas({ oas, contentType, includes = ['schemas', 'requestBodies', 'responses'], collisionDetection }: GetSchemasProps): GetSchemasResult {\n return oas.getSchemas({\n contentType,\n includes,\n collisionDetection,\n })\n}\n","import { camelCase, isValidVarName } from '@internals/utils'\nimport type { SchemaObject } from '@kubb/oas'\n\n/**\n * Apply casing transformation to schema properties\n * Only transforms property names, not nested schemas\n */\nexport function applyParamsCasing(schema: SchemaObject, casing: 'camelcase' | undefined): SchemaObject {\n if (!casing || !schema.properties) {\n return schema\n }\n\n const transformedProperties: Record<string, any> = {}\n const transformedRequired: string[] = []\n\n // Transform property names\n Object.entries(schema.properties).forEach(([originalName, propertySchema]) => {\n let transformedName = originalName\n\n if (casing === 'camelcase') {\n transformedName = camelCase(originalName)\n } else if (!isValidVarName(originalName)) {\n // If not valid variable name, make it valid\n transformedName = camelCase(originalName)\n }\n\n transformedProperties[transformedName] = propertySchema\n })\n\n // Transform required field names\n if (Array.isArray(schema.required)) {\n schema.required.forEach((originalName) => {\n let transformedName = originalName\n\n if (casing === 'camelcase') {\n transformedName = camelCase(originalName)\n } else if (!isValidVarName(originalName)) {\n transformedName = camelCase(originalName)\n }\n\n transformedRequired.push(transformedName)\n })\n }\n\n // Return a new schema with transformed properties and required fields\n return {\n ...schema,\n properties: transformedProperties,\n ...(transformedRequired.length > 0 && { required: transformedRequired }),\n } as SchemaObject\n}\n\n/**\n * Check if this schema is a parameter schema (pathParams, queryParams, or headerParams)\n * Only these should be transformed, not response/data/body\n */\nexport function isParameterSchema(schemaName: string): boolean {\n const lowerName = schemaName.toLowerCase()\n return lowerName.includes('pathparams') || lowerName.includes('queryparams') || lowerName.includes('headerparams')\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAoHA,SAAgB,eAAe,MAAuB;AACpD,KAAI;AACF,MAAI,SAAS,OAAO,OAAO;SACrB;AACN,SAAO;;AAET,QAAO;;;;;;;;;;;;ACvET,IAAa,UAAb,MAAqB;;;;CAInB;CAEA;CAEA,YAAY,MAAc,UAAmB,EAAE,EAAE;AAC/C,OAAK,OAAO;AACZ,QAAA,UAAgB;;;;;;;;;CAUlB,IAAI,MAAc;AAChB,SAAO,KAAK,WAAW;;;;;;;;;;CAWzB,IAAI,QAAiB;AACnB,MAAI;AACF,UAAO,CAAC,CAAC,IAAI,IAAI,KAAK,KAAK,CAAC;UACtB;AACN,UAAO;;;;;;;;;;CAWX,IAAI,WAAmB;AACrB,SAAO,KAAK,kBAAkB;;;;;;;;;;CAWhC,IAAI,SAA6B;AAC/B,SAAO,KAAK,UAAU;;;;;;;;;;CAWxB,IAAI,SAA6C;A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,QAAO,OAAO,KAAK,QAAQ,CAAC,SAAS,IAAI,UAAU,KAAA;;;;;;;;;;;;;AC3FrD,SAAgB,WAAW,EAAE,KAAK,aAAa,WAAW;CAAC;CAAW;CAAiB;CAAY,EAAE,sBAAyD;AAC5J,QAAO,IAAI,WAAW;EACpB;EACA;EACA;EACD,CAAC;;;;;;;;AChCJ,SAAgB,kBAAkB,QAAsB,QAA+C;AACrG,KAAI,CAAC,UAAU,CAAC,OAAO,WACrB,QAAO;CAGT,MAAM,wBAA6C,EAAE;CACrD,MAAM,sBAAgC,EAAE;AAGxC,QAAO,QAAQ,OAAO,WAAW,CAAC,SAAS,CAAC,cAAc,oBAAoB;EAC5E,IAAI,kBAAkB;AAEtB,MAAI,WAAW,YACb,mBAAkBC,kBAAAA,UAAU,aAAa;WAChC,CAAC,eAAe,aAAa,CAEtC,mBAAkBA,kBAAAA,UAAU,aAAa;AAG3C,wBAAsB,mBAAmB;GACzC;AAGF,KAAI,MAAM,QAAQ,OAAO,SAAS,CAChC,QAAO,SAAS,SAAS,iBAAiB;EACxC,IAAI,kBAAkB;AAEtB,MAAI,WAAW,YACb,mBAAkBA,kBAAAA,UAAU,aAAa;WAChC,CAAC,eAAe,aAAa,CACtC,mBAAkBA,kBAAAA,UAAU,aAAa;AAG3C,sBAAoB,KAAK,gBAAgB;GACzC;AAIJ,QAAO;EACL,GAAG;EACH,YAAY;EACZ,GAAI,oBAAoB,SAAS,KAAK,EAAE,UAAU,qBAAqB;EACxE;;;;;;AAOH,SAAgB,kBAAkB,YAA6B;CAC7D,MAAM,YAAY,WAAW,aAAa;AAC1C,QAAO,UAAU,SAAS,aAAa,IAAI,UAAU,SAAS,cAAc,IAAI,UAAU,SAAS,eAAe"}
package/dist/utils.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { t as __name } from "./chunk--u3MIqq1.js";
2
- import { h as OperationSchema } from "./createGenerator-BiZ9IsdY.js";
3
- import { t as Schema } from "./SchemaMapper-SneuY1wg.js";
2
+ import { h as OperationSchema } from "./createGenerator-CSxQ1bji.js";
3
+ import { t as Schema } from "./SchemaMapper-CLIXrzqv.js";
4
4
  import { Oas, OasTypes, OpenAPIV3, OpenAPIV3_1, Operation, SchemaObject, contentType, isOptional } from "@kubb/oas";
5
5
  import { Config, FunctionParamsAST, Output } from "@kubb/core";
6
- import { KubbFile } from "@kubb/fabric-core/types";
6
+ import { FabricFile } from "@kubb/fabric-core/types";
7
7
  import { Params } from "@kubb/react-fabric/types";
8
8
 
9
9
  //#region src/utils/getBanner.d.ts
@@ -35,7 +35,7 @@ declare function getFooter<TOas extends Oas>({
35
35
  /**
36
36
  * Get imports from a schema tree by extracting all ref schemas that are importable
37
37
  */
38
- declare function getImports(tree: Array<Schema>): Array<KubbFile.Import>;
38
+ declare function getImports(tree: Array<Schema>): Array<FabricFile.Import>;
39
39
  //#endregion
40
40
  //#region src/utils/getParams.d.ts
41
41
  declare function getPathParams(operationSchema: OperationSchema | undefined, options?: {
package/dist/utils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import "./chunk--u3MIqq1.js";
2
2
  import { n as getBanner, r as camelCase, t as getFooter } from "./getFooter-Dz4u5Mg4.js";
3
- import { n as withRequiredRequestBodySchema, r as SchemaGenerator, s as getSchemaFactory, t as isRequestBodyRequired } from "./requestBody-bs_SwfEj.js";
3
+ import { n as withRequiredRequestBodySchema, r as SchemaGenerator, s as getSchemaFactory, t as isRequestBodyRequired } from "./requestBody-Ccu5imDC.js";
4
4
  import { n as schemaKeywords } from "./SchemaMapper-CqMkO2T1.js";
5
5
  import { isOptional } from "@kubb/oas";
6
6
  //#region ../../internals/utils/src/reserved.ts
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","names":["#options","#transformParam","#eachParam"],"sources":["../../../internals/utils/src/reserved.ts","../../../internals/utils/src/urlPath.ts","../src/utils/getComments.ts","../src/utils/getImports.ts","../src/utils/getParams.ts","../src/utils/getSchemas.ts","../src/utils/paramsCasing.ts"],"sourcesContent":["/**\n * JavaScript and Java reserved words.\n * @link https://github.com/jonschlinkert/reserved/blob/master/index.js\n */\nconst reservedWords = new Set([\n 'abstract',\n 'arguments',\n 'boolean',\n 'break',\n 'byte',\n 'case',\n 'catch',\n 'char',\n 'class',\n 'const',\n 'continue',\n 'debugger',\n 'default',\n 'delete',\n 'do',\n 'double',\n 'else',\n 'enum',\n 'eval',\n 'export',\n 'extends',\n 'false',\n 'final',\n 'finally',\n 'float',\n 'for',\n 'function',\n 'goto',\n 'if',\n 'implements',\n 'import',\n 'in',\n 'instanceof',\n 'int',\n 'interface',\n 'let',\n 'long',\n 'native',\n 'new',\n 'null',\n 'package',\n 'private',\n 'protected',\n 'public',\n 'return',\n 'short',\n 'static',\n 'super',\n 'switch',\n 'synchronized',\n 'this',\n 'throw',\n 'throws',\n 'transient',\n 'true',\n 'try',\n 'typeof',\n 'var',\n 'void',\n 'volatile',\n 'while',\n 'with',\n 'yield',\n 'Array',\n 'Date',\n 'hasOwnProperty',\n 'Infinity',\n 'isFinite',\n 'isNaN',\n 'isPrototypeOf',\n 'length',\n 'Math',\n 'name',\n 'NaN',\n 'Number',\n 'Object',\n 'prototype',\n 'String',\n 'toString',\n 'undefined',\n 'valueOf',\n] as const)\n\n/**\n * Prefixes `word` with `_` when it is a reserved JavaScript/Java identifier or starts with a digit.\n *\n * @example\n * ```ts\n * transformReservedWord('class') // '_class'\n * transformReservedWord('42foo') // '_42foo'\n * transformReservedWord('status') // 'status'\n * ```\n */\nexport function transformReservedWord(word: string): string {\n const firstChar = word.charCodeAt(0)\n if (word && (reservedWords.has(word as 'valueOf') || (firstChar >= 48 && firstChar <= 57))) {\n return `_${word}`\n }\n return word\n}\n\n/**\n * Returns `true` when `name` is a syntactically valid JavaScript variable name.\n *\n * @example\n * ```ts\n * isValidVarName('status') // true\n * isValidVarName('class') // false (reserved word)\n * isValidVarName('42foo') // false (starts with digit)\n * ```\n */\nexport function isValidVarName(name: string): boolean {\n try {\n new Function(`var ${name}`)\n } catch {\n return false\n }\n return true\n}\n","import { camelCase } from './casing.ts'\nimport { isValidVarName } from './reserved.ts'\n\nexport type URLObject = {\n /**\n * The resolved URL string (Express-style or template literal, depending on context).\n */\n url: string\n /**\n * Extracted path parameters as a key-value map, or `undefined` when the path has none.\n */\n params?: Record<string, string>\n}\n\ntype ObjectOptions = {\n /**\n * Controls whether the `url` is rendered as an Express path or a template literal.\n * @default 'path'\n */\n type?: 'path' | 'template'\n /**\n * Optional transform applied to each extracted parameter name.\n */\n replacer?: (pathParam: string) => string\n /**\n * When `true`, the result is serialized to a string expression instead of a plain object.\n */\n stringify?: boolean\n}\n\n/**\n * Supported identifier casing strategies for path parameters.\n */\ntype PathCasing = 'camelcase'\n\ntype Options = {\n /**\n * Casing strategy applied to path parameter names.\n * @default undefined (original identifier preserved)\n */\n casing?: PathCasing\n}\n\n/**\n * Parses and transforms an OpenAPI/Swagger path string into various URL formats.\n *\n * @example\n * const p = new URLPath('/pet/{petId}')\n * p.URL // '/pet/:petId'\n * p.template // '`/pet/${petId}`'\n */\nexport class URLPath {\n /**\n * The raw OpenAPI/Swagger path string, e.g. `/pet/{petId}`.\n */\n path: string\n\n #options: Options\n\n constructor(path: string, options: Options = {}) {\n this.path = path\n this.#options = options\n }\n\n /** Converts the OpenAPI path to Express-style colon syntax, e.g. `/pet/{petId}` → `/pet/:petId`.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}').URL // '/pet/:petId'\n * ```\n */\n get URL(): string {\n return this.toURLPath()\n }\n\n /** Returns `true` when `path` is a fully-qualified URL (e.g. starts with `https://`).\n *\n * @example\n * ```ts\n * new URLPath('https://petstore.swagger.io/v2/pet').isURL // true\n * new URLPath('/pet/{petId}').isURL // false\n * ```\n */\n get isURL(): boolean {\n try {\n return !!new URL(this.path).href\n } catch {\n return false\n }\n }\n\n /**\n * Converts the OpenAPI path to a TypeScript template literal string.\n *\n * @example\n * new URLPath('/pet/{petId}').template // '`/pet/${petId}`'\n * new URLPath('/account/monetary-accountID').template // '`/account/${monetaryAccountId}`'\n */\n get template(): string {\n return this.toTemplateString()\n }\n\n /** Returns the path and its extracted params as a structured `URLObject`, or as a stringified expression when `stringify` is set.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}').object\n * // { url: '/pet/:petId', params: { petId: 'petId' } }\n * ```\n */\n get object(): URLObject | string {\n return this.toObject()\n }\n\n /** Returns a map of path parameter names, or `undefined` when the path has no parameters.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}').params // { petId: 'petId' }\n * new URLPath('/pet').params // undefined\n * ```\n */\n get params(): Record<string, string> | undefined {\n return this.getParams()\n }\n\n #transformParam(raw: string): string {\n const param = isValidVarName(raw) ? raw : camelCase(raw)\n return this.#options.casing === 'camelcase' ? camelCase(param) : param\n }\n\n /**\n * Iterates over every `{param}` token in `path`, calling `fn` with the raw token and transformed name.\n */\n #eachParam(fn: (raw: string, param: string) => void): void {\n for (const match of this.path.matchAll(/\\{([^}]+)\\}/g)) {\n const raw = match[1]!\n fn(raw, this.#transformParam(raw))\n }\n }\n\n toObject({ type = 'path', replacer, stringify }: ObjectOptions = {}): URLObject | string {\n const object = {\n url: type === 'path' ? this.toURLPath() : this.toTemplateString({ replacer }),\n params: this.getParams(),\n }\n\n if (stringify) {\n if (type === 'template') {\n return JSON.stringify(object).replaceAll(\"'\", '').replaceAll(`\"`, '')\n }\n\n if (object.params) {\n return `{ url: '${object.url}', params: ${JSON.stringify(object.params).replaceAll(\"'\", '').replaceAll(`\"`, '')} }`\n }\n\n return `{ url: '${object.url}' }`\n }\n\n return object\n }\n\n /**\n * Converts the OpenAPI path to a TypeScript template literal string.\n * An optional `replacer` can transform each extracted parameter name before interpolation.\n *\n * @example\n * new URLPath('/pet/{petId}').toTemplateString() // '`/pet/${petId}`'\n */\n toTemplateString({ prefix = '', replacer }: { prefix?: string; replacer?: (pathParam: string) => string } = {}): string {\n const parts = this.path.split(/\\{([^}]+)\\}/)\n const result = parts\n .map((part, i) => {\n if (i % 2 === 0) return part\n const param = this.#transformParam(part)\n return `\\${${replacer ? replacer(param) : param}}`\n })\n .join('')\n\n return `\\`${prefix}${result}\\``\n }\n\n /**\n * Extracts all `{param}` segments from the path and returns them as a key-value map.\n * An optional `replacer` transforms each parameter name in both key and value positions.\n * Returns `undefined` when no path parameters are found.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}/tag/{tagId}').getParams()\n * // { petId: 'petId', tagId: 'tagId' }\n * ```\n */\n getParams(replacer?: (pathParam: string) => string): Record<string, string> | undefined {\n const params: Record<string, string> = {}\n\n this.#eachParam((_raw, param) => {\n const key = replacer ? replacer(param) : param\n params[key] = key\n })\n\n return Object.keys(params).length > 0 ? params : undefined\n }\n\n /** Converts the OpenAPI path to Express-style colon syntax.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}').toURLPath() // '/pet/:petId'\n * ```\n */\n toURLPath(): string {\n return this.path.replace(/\\{([^}]+)\\}/g, ':$1')\n }\n}\n","import { URLPath } from '@internals/utils'\nimport type { Operation } from '@kubb/oas'\n\nexport function getComments(operation: Operation): string[] {\n return [\n operation.getDescription() && `@description ${operation.getDescription()}`,\n operation.getSummary() && `@summary ${operation.getSummary()}`,\n operation.path && `{@link ${new URLPath(operation.path).URL}}`,\n operation.isDeprecated() && '@deprecated',\n ]\n .filter((x): x is string => Boolean(x))\n .flatMap((text) => {\n return text.split(/\\r?\\n/).map((line) => line.trim())\n })\n .filter((x): x is string => Boolean(x))\n}\n","import type { KubbFile } from '@kubb/fabric-core/types'\nimport { SchemaGenerator } from '../SchemaGenerator.ts'\nimport type { Schema } from '../SchemaMapper'\nimport { schemaKeywords } from '../SchemaMapper'\n\n/**\n * Get imports from a schema tree by extracting all ref schemas that are importable\n */\nexport function getImports(tree: Array<Schema>): Array<KubbFile.Import> {\n const refs = SchemaGenerator.deepSearch(tree, schemaKeywords.ref)\n\n if (!refs) return []\n\n return refs\n .map((item) => {\n if (!item.args.path || !item.args.isImportable) {\n return undefined\n }\n\n return {\n name: [item.args.name],\n path: item.args.path,\n } satisfies KubbFile.Import\n })\n .filter((x): x is NonNullable<typeof x> => x !== undefined)\n}\n","import { camelCase, isValidVarName } from '@internals/utils'\nimport type { FunctionParamsAST } from '@kubb/core'\nimport type { OasTypes } from '@kubb/oas'\nimport type { Params } from '@kubb/react-fabric/types'\nimport type { OperationSchema } from '../types.ts'\n/**\n *\n * @deprecated\n * TODO move to operationManager hook\n */\nexport function getASTParams(\n operationSchema: OperationSchema | undefined,\n {\n typed = false,\n casing,\n override,\n }: {\n typed?: boolean\n casing?: 'camelcase'\n override?: (data: FunctionParamsAST) => FunctionParamsAST\n } = {},\n): FunctionParamsAST[] {\n if (!operationSchema?.schema.properties || !operationSchema.name) {\n return []\n }\n\n const requiredFields = Array.isArray(operationSchema.schema.required) ? operationSchema.schema.required : []\n\n return Object.entries(operationSchema.schema.properties).map(([name]: [string, OasTypes.SchemaObject]) => {\n // Use camelCase name for indexed access if casing is enabled\n const accessName = casing === 'camelcase' ? camelCase(name) : name\n\n const data: FunctionParamsAST = {\n name,\n enabled: !!name,\n required: requiredFields.includes(name),\n type: typed ? `${operationSchema.name}[\"${accessName}\"]` : undefined,\n }\n\n return override ? override(data) : data\n })\n}\n\nexport function getPathParams(\n operationSchema: OperationSchema | undefined,\n options: {\n typed?: boolean\n casing?: 'camelcase'\n override?: (data: FunctionParamsAST) => FunctionParamsAST\n } = {},\n) {\n return getASTParams(operationSchema, options).reduce((acc, curr) => {\n if (curr.name && curr.enabled) {\n let name = curr.name\n\n // Only transform to camelCase if explicitly requested\n if (options.casing === 'camelcase') {\n name = camelCase(name)\n } else if (!isValidVarName(name)) {\n // If not valid variable name and casing not set, still need to make it valid\n name = camelCase(name)\n }\n\n acc[name] = {\n default: curr.default,\n type: curr.type,\n optional: !curr.required,\n }\n }\n\n return acc\n }, {} as Params)\n}\n\n/**\n * Get a mapping of camelCase parameter names to their original names\n * Used for mapping function parameters to backend parameter names\n */\nexport function getParamsMapping(\n operationSchema: OperationSchema | undefined,\n options: {\n casing?: 'camelcase'\n } = {},\n): Record<string, string> | undefined {\n if (!operationSchema?.schema.properties) {\n return undefined\n }\n\n const allEntries: Array<[string, string]> = []\n let hasTransformation = false\n\n Object.entries(operationSchema.schema.properties).forEach(([originalName]) => {\n let transformedName = originalName\n\n // Only transform to camelCase if explicitly requested\n if (options.casing === 'camelcase') {\n transformedName = camelCase(originalName)\n } else if (!isValidVarName(originalName)) {\n // If not valid variable name and casing not set, still need to make it valid\n transformedName = camelCase(originalName)\n }\n\n allEntries.push([originalName, transformedName])\n\n if (transformedName !== originalName) {\n hasTransformation = true\n }\n })\n\n // When using explicit casing and there are transformations, include ALL params so that\n // mappedParams contains every parameter (not just the ones whose names changed).\n // This prevents params with already-camelCase names (e.g. 'page', 'search') from being\n // silently dropped when other params in the same schema do need transformation.\n if (options.casing === 'camelcase' && hasTransformation) {\n return Object.fromEntries(allEntries)\n }\n\n // When casing is not specified or no transformations are needed, only return changed entries\n const mapping: Record<string, string> = {}\n allEntries.forEach(([originalName, transformedName]) => {\n if (transformedName !== originalName) {\n mapping[originalName] = transformedName\n }\n })\n\n return Object.keys(mapping).length > 0 ? mapping : undefined\n}\n","import type { contentType, Oas, OasTypes } from '@kubb/oas'\n\nexport type GetSchemasResult = {\n schemas: Record<string, OasTypes.SchemaObject>\n /**\n * Mapping from original component name to resolved name after collision handling\n * e.g., { 'Order': 'OrderSchema', 'variant': 'variant2' }\n */\n nameMapping: Map<string, string>\n}\n\ntype Mode = 'schemas' | 'responses' | 'requestBodies'\n\ntype GetSchemasProps = {\n oas: Oas\n contentType?: contentType\n includes?: Mode[]\n /**\n * Whether to resolve name collisions with suffixes.\n * If not provided, uses oas.options.collisionDetection\n * @default false (from oas.options or fallback)\n */\n collisionDetection?: boolean\n}\n\n/**\n * Collect schemas from OpenAPI components (schemas, responses, requestBodies)\n * and return them in dependency order along with name mapping for collision resolution.\n *\n * This function is a wrapper around the oas.getSchemas() method for backward compatibility.\n * New code should use oas.getSchemas() directly.\n *\n * @deprecated Use oas.getSchemas() instead\n */\nexport function getSchemas({ oas, contentType, includes = ['schemas', 'requestBodies', 'responses'], collisionDetection }: GetSchemasProps): GetSchemasResult {\n return oas.getSchemas({\n contentType,\n includes,\n collisionDetection,\n })\n}\n","import { camelCase, isValidVarName } from '@internals/utils'\nimport type { SchemaObject } from '@kubb/oas'\n\n/**\n * Apply casing transformation to schema properties\n * Only transforms property names, not nested schemas\n */\nexport function applyParamsCasing(schema: SchemaObject, casing: 'camelcase' | undefined): SchemaObject {\n if (!casing || !schema.properties) {\n return schema\n }\n\n const transformedProperties: Record<string, any> = {}\n const transformedRequired: string[] = []\n\n // Transform property names\n Object.entries(schema.properties).forEach(([originalName, propertySchema]) => {\n let transformedName = originalName\n\n if (casing === 'camelcase') {\n transformedName = camelCase(originalName)\n } else if (!isValidVarName(originalName)) {\n // If not valid variable name, make it valid\n transformedName = camelCase(originalName)\n }\n\n transformedProperties[transformedName] = propertySchema\n })\n\n // Transform required field names\n if (Array.isArray(schema.required)) {\n schema.required.forEach((originalName) => {\n let transformedName = originalName\n\n if (casing === 'camelcase') {\n transformedName = camelCase(originalName)\n } else if (!isValidVarName(originalName)) {\n transformedName = camelCase(originalName)\n }\n\n transformedRequired.push(transformedName)\n })\n }\n\n // Return a new schema with transformed properties and required fields\n return {\n ...schema,\n properties: transformedProperties,\n ...(transformedRequired.length > 0 && { required: transformedRequired }),\n } as SchemaObject\n}\n\n/**\n * Check if this schema is a parameter schema (pathParams, queryParams, or headerParams)\n * Only these should be transformed, not response/data/body\n */\nexport function isParameterSchema(schemaName: string): boolean {\n const lowerName = schemaName.toLowerCase()\n return lowerName.includes('pathparams') || lowerName.includes('queryparams') || lowerName.includes('headerparams')\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAoHA,SAAgB,eAAe,MAAuB;AACpD,KAAI;AACF,MAAI,SAAS,OAAO,OAAO;SACrB;AACN,SAAO;;AAET,QAAO;;;;;;;;;;;;ACvET,IAAa,U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BAAkB,YAA6B;CAC7D,MAAM,YAAY,WAAW,aAAa;AAC1C,QAAO,UAAU,SAAS,aAAa,IAAI,UAAU,SAAS,cAAc,IAAI,UAAU,SAAS,eAAe"}
1
+ {"version":3,"file":"utils.js","names":["#options","#transformParam","#eachParam"],"sources":["../../../internals/utils/src/reserved.ts","../../../internals/utils/src/urlPath.ts","../src/utils/getComments.ts","../src/utils/getImports.ts","../src/utils/getParams.ts","../src/utils/getSchemas.ts","../src/utils/paramsCasing.ts"],"sourcesContent":["/**\n * JavaScript and Java reserved words.\n * @link https://github.com/jonschlinkert/reserved/blob/master/index.js\n */\nconst reservedWords = new Set([\n 'abstract',\n 'arguments',\n 'boolean',\n 'break',\n 'byte',\n 'case',\n 'catch',\n 'char',\n 'class',\n 'const',\n 'continue',\n 'debugger',\n 'default',\n 'delete',\n 'do',\n 'double',\n 'else',\n 'enum',\n 'eval',\n 'export',\n 'extends',\n 'false',\n 'final',\n 'finally',\n 'float',\n 'for',\n 'function',\n 'goto',\n 'if',\n 'implements',\n 'import',\n 'in',\n 'instanceof',\n 'int',\n 'interface',\n 'let',\n 'long',\n 'native',\n 'new',\n 'null',\n 'package',\n 'private',\n 'protected',\n 'public',\n 'return',\n 'short',\n 'static',\n 'super',\n 'switch',\n 'synchronized',\n 'this',\n 'throw',\n 'throws',\n 'transient',\n 'true',\n 'try',\n 'typeof',\n 'var',\n 'void',\n 'volatile',\n 'while',\n 'with',\n 'yield',\n 'Array',\n 'Date',\n 'hasOwnProperty',\n 'Infinity',\n 'isFinite',\n 'isNaN',\n 'isPrototypeOf',\n 'length',\n 'Math',\n 'name',\n 'NaN',\n 'Number',\n 'Object',\n 'prototype',\n 'String',\n 'toString',\n 'undefined',\n 'valueOf',\n] as const)\n\n/**\n * Prefixes `word` with `_` when it is a reserved JavaScript/Java identifier or starts with a digit.\n *\n * @example\n * ```ts\n * transformReservedWord('class') // '_class'\n * transformReservedWord('42foo') // '_42foo'\n * transformReservedWord('status') // 'status'\n * ```\n */\nexport function transformReservedWord(word: string): string {\n const firstChar = word.charCodeAt(0)\n if (word && (reservedWords.has(word as 'valueOf') || (firstChar >= 48 && firstChar <= 57))) {\n return `_${word}`\n }\n return word\n}\n\n/**\n * Returns `true` when `name` is a syntactically valid JavaScript variable name.\n *\n * @example\n * ```ts\n * isValidVarName('status') // true\n * isValidVarName('class') // false (reserved word)\n * isValidVarName('42foo') // false (starts with digit)\n * ```\n */\nexport function isValidVarName(name: string): boolean {\n try {\n new Function(`var ${name}`)\n } catch {\n return false\n }\n return true\n}\n","import { camelCase } from './casing.ts'\nimport { isValidVarName } from './reserved.ts'\n\nexport type URLObject = {\n /**\n * The resolved URL string (Express-style or template literal, depending on context).\n */\n url: string\n /**\n * Extracted path parameters as a key-value map, or `undefined` when the path has none.\n */\n params?: Record<string, string>\n}\n\ntype ObjectOptions = {\n /**\n * Controls whether the `url` is rendered as an Express path or a template literal.\n * @default 'path'\n */\n type?: 'path' | 'template'\n /**\n * Optional transform applied to each extracted parameter name.\n */\n replacer?: (pathParam: string) => string\n /**\n * When `true`, the result is serialized to a string expression instead of a plain object.\n */\n stringify?: boolean\n}\n\n/**\n * Supported identifier casing strategies for path parameters.\n */\ntype PathCasing = 'camelcase'\n\ntype Options = {\n /**\n * Casing strategy applied to path parameter names.\n * @default undefined (original identifier preserved)\n */\n casing?: PathCasing\n}\n\n/**\n * Parses and transforms an OpenAPI/Swagger path string into various URL formats.\n *\n * @example\n * const p = new URLPath('/pet/{petId}')\n * p.URL // '/pet/:petId'\n * p.template // '`/pet/${petId}`'\n */\nexport class URLPath {\n /**\n * The raw OpenAPI/Swagger path string, e.g. `/pet/{petId}`.\n */\n path: string\n\n #options: Options\n\n constructor(path: string, options: Options = {}) {\n this.path = path\n this.#options = options\n }\n\n /** Converts the OpenAPI path to Express-style colon syntax, e.g. `/pet/{petId}` → `/pet/:petId`.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}').URL // '/pet/:petId'\n * ```\n */\n get URL(): string {\n return this.toURLPath()\n }\n\n /** Returns `true` when `path` is a fully-qualified URL (e.g. starts with `https://`).\n *\n * @example\n * ```ts\n * new URLPath('https://petstore.swagger.io/v2/pet').isURL // true\n * new URLPath('/pet/{petId}').isURL // false\n * ```\n */\n get isURL(): boolean {\n try {\n return !!new URL(this.path).href\n } catch {\n return false\n }\n }\n\n /**\n * Converts the OpenAPI path to a TypeScript template literal string.\n *\n * @example\n * new URLPath('/pet/{petId}').template // '`/pet/${petId}`'\n * new URLPath('/account/monetary-accountID').template // '`/account/${monetaryAccountId}`'\n */\n get template(): string {\n return this.toTemplateString()\n }\n\n /** Returns the path and its extracted params as a structured `URLObject`, or as a stringified expression when `stringify` is set.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}').object\n * // { url: '/pet/:petId', params: { petId: 'petId' } }\n * ```\n */\n get object(): URLObject | string {\n return this.toObject()\n }\n\n /** Returns a map of path parameter names, or `undefined` when the path has no parameters.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}').params // { petId: 'petId' }\n * new URLPath('/pet').params // undefined\n * ```\n */\n get params(): Record<string, string> | undefined {\n return this.getParams()\n }\n\n #transformParam(raw: string): string {\n const param = isValidVarName(raw) ? raw : camelCase(raw)\n return this.#options.casing === 'camelcase' ? camelCase(param) : param\n }\n\n /**\n * Iterates over every `{param}` token in `path`, calling `fn` with the raw token and transformed name.\n */\n #eachParam(fn: (raw: string, param: string) => void): void {\n for (const match of this.path.matchAll(/\\{([^}]+)\\}/g)) {\n const raw = match[1]!\n fn(raw, this.#transformParam(raw))\n }\n }\n\n toObject({ type = 'path', replacer, stringify }: ObjectOptions = {}): URLObject | string {\n const object = {\n url: type === 'path' ? this.toURLPath() : this.toTemplateString({ replacer }),\n params: this.getParams(),\n }\n\n if (stringify) {\n if (type === 'template') {\n return JSON.stringify(object).replaceAll(\"'\", '').replaceAll(`\"`, '')\n }\n\n if (object.params) {\n return `{ url: '${object.url}', params: ${JSON.stringify(object.params).replaceAll(\"'\", '').replaceAll(`\"`, '')} }`\n }\n\n return `{ url: '${object.url}' }`\n }\n\n return object\n }\n\n /**\n * Converts the OpenAPI path to a TypeScript template literal string.\n * An optional `replacer` can transform each extracted parameter name before interpolation.\n *\n * @example\n * new URLPath('/pet/{petId}').toTemplateString() // '`/pet/${petId}`'\n */\n toTemplateString({ prefix = '', replacer }: { prefix?: string; replacer?: (pathParam: string) => string } = {}): string {\n const parts = this.path.split(/\\{([^}]+)\\}/)\n const result = parts\n .map((part, i) => {\n if (i % 2 === 0) return part\n const param = this.#transformParam(part)\n return `\\${${replacer ? replacer(param) : param}}`\n })\n .join('')\n\n return `\\`${prefix}${result}\\``\n }\n\n /**\n * Extracts all `{param}` segments from the path and returns them as a key-value map.\n * An optional `replacer` transforms each parameter name in both key and value positions.\n * Returns `undefined` when no path parameters are found.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}/tag/{tagId}').getParams()\n * // { petId: 'petId', tagId: 'tagId' }\n * ```\n */\n getParams(replacer?: (pathParam: string) => string): Record<string, string> | undefined {\n const params: Record<string, string> = {}\n\n this.#eachParam((_raw, param) => {\n const key = replacer ? replacer(param) : param\n params[key] = key\n })\n\n return Object.keys(params).length > 0 ? params : undefined\n }\n\n /** Converts the OpenAPI path to Express-style colon syntax.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}').toURLPath() // '/pet/:petId'\n * ```\n */\n toURLPath(): string {\n return this.path.replace(/\\{([^}]+)\\}/g, ':$1')\n }\n}\n","import { URLPath } from '@internals/utils'\nimport type { Operation } from '@kubb/oas'\n\nexport function getComments(operation: Operation): string[] {\n return [\n operation.getDescription() && `@description ${operation.getDescription()}`,\n operation.getSummary() && `@summary ${operation.getSummary()}`,\n operation.path && `{@link ${new URLPath(operation.path).URL}}`,\n operation.isDeprecated() && '@deprecated',\n ]\n .filter((x): x is string => Boolean(x))\n .flatMap((text) => {\n return text.split(/\\r?\\n/).map((line) => line.trim())\n })\n .filter((x): x is string => Boolean(x))\n}\n","import type { FabricFile } from '@kubb/fabric-core/types'\nimport { SchemaGenerator } from '../SchemaGenerator.ts'\nimport type { Schema } from '../SchemaMapper'\nimport { schemaKeywords } from '../SchemaMapper'\n\n/**\n * Get imports from a schema tree by extracting all ref schemas that are importable\n */\nexport function getImports(tree: Array<Schema>): Array<FabricFile.Import> {\n const refs = SchemaGenerator.deepSearch(tree, schemaKeywords.ref)\n\n if (!refs) return []\n\n return refs\n .map((item) => {\n if (!item.args.path || !item.args.isImportable) {\n return undefined\n }\n\n return {\n name: [item.args.name],\n path: item.args.path,\n } satisfies FabricFile.Import\n })\n .filter((x): x is NonNullable<typeof x> => x !== undefined)\n}\n","import { camelCase, isValidVarName } from '@internals/utils'\nimport type { FunctionParamsAST } from '@kubb/core'\nimport type { OasTypes } from '@kubb/oas'\nimport type { Params } from '@kubb/react-fabric/types'\nimport type { OperationSchema } from '../types.ts'\n/**\n *\n * @deprecated\n * TODO move to operationManager hook\n */\nexport function getASTParams(\n operationSchema: OperationSchema | undefined,\n {\n typed = false,\n casing,\n override,\n }: {\n typed?: boolean\n casing?: 'camelcase'\n override?: (data: FunctionParamsAST) => FunctionParamsAST\n } = {},\n): FunctionParamsAST[] {\n if (!operationSchema?.schema.properties || !operationSchema.name) {\n return []\n }\n\n const requiredFields = Array.isArray(operationSchema.schema.required) ? operationSchema.schema.required : []\n\n return Object.entries(operationSchema.schema.properties).map(([name]: [string, OasTypes.SchemaObject]) => {\n // Use camelCase name for indexed access if casing is enabled\n const accessName = casing === 'camelcase' ? camelCase(name) : name\n\n const data: FunctionParamsAST = {\n name,\n enabled: !!name,\n required: requiredFields.includes(name),\n type: typed ? `${operationSchema.name}[\"${accessName}\"]` : undefined,\n }\n\n return override ? override(data) : data\n })\n}\n\nexport function getPathParams(\n operationSchema: OperationSchema | undefined,\n options: {\n typed?: boolean\n casing?: 'camelcase'\n override?: (data: FunctionParamsAST) => FunctionParamsAST\n } = {},\n) {\n return getASTParams(operationSchema, options).reduce((acc, curr) => {\n if (curr.name && curr.enabled) {\n let name = curr.name\n\n // Only transform to camelCase if explicitly requested\n if (options.casing === 'camelcase') {\n name = camelCase(name)\n } else if (!isValidVarName(name)) {\n // If not valid variable name and casing not set, still need to make it valid\n name = camelCase(name)\n }\n\n acc[name] = {\n default: curr.default,\n type: curr.type,\n optional: !curr.required,\n }\n }\n\n return acc\n }, {} as Params)\n}\n\n/**\n * Get a mapping of camelCase parameter names to their original names\n * Used for mapping function parameters to backend parameter names\n */\nexport function getParamsMapping(\n operationSchema: OperationSchema | undefined,\n options: {\n casing?: 'camelcase'\n } = {},\n): Record<string, string> | undefined {\n if (!operationSchema?.schema.properties) {\n return undefined\n }\n\n const allEntries: Array<[string, string]> = []\n let hasTransformation = false\n\n Object.entries(operationSchema.schema.properties).forEach(([originalName]) => {\n let transformedName = originalName\n\n // Only transform to camelCase if explicitly requested\n if (options.casing === 'camelcase') {\n transformedName = camelCase(originalName)\n } else if (!isValidVarName(originalName)) {\n // If not valid variable name and casing not set, still need to make it valid\n transformedName = camelCase(originalName)\n }\n\n allEntries.push([originalName, transformedName])\n\n if (transformedName !== originalName) {\n hasTransformation = true\n }\n })\n\n // When using explicit casing and there are transformations, include ALL params so that\n // mappedParams contains every parameter (not just the ones whose names changed).\n // This prevents params with already-camelCase names (e.g. 'page', 'search') from being\n // silently dropped when other params in the same schema do need transformation.\n if (options.casing === 'camelcase' && hasTransformation) {\n return Object.fromEntries(allEntries)\n }\n\n // When casing is not specified or no transformations are needed, only return changed entries\n const mapping: Record<string, string> = {}\n allEntries.forEach(([originalName, transformedName]) => {\n if (transformedName !== originalName) {\n mapping[originalName] = transformedName\n }\n })\n\n return Object.keys(mapping).length > 0 ? mapping : undefined\n}\n","import type { contentType, Oas, OasTypes } from '@kubb/oas'\n\nexport type GetSchemasResult = {\n schemas: Record<string, OasTypes.SchemaObject>\n /**\n * Mapping from original component name to resolved name after collision handling\n * e.g., { 'Order': 'OrderSchema', 'variant': 'variant2' }\n */\n nameMapping: Map<string, string>\n}\n\ntype Mode = 'schemas' | 'responses' | 'requestBodies'\n\ntype GetSchemasProps = {\n oas: Oas\n contentType?: contentType\n includes?: Mode[]\n /**\n * Whether to resolve name collisions with suffixes.\n * If not provided, uses oas.options.collisionDetection\n * @default false (from oas.options or fallback)\n */\n collisionDetection?: boolean\n}\n\n/**\n * Collect schemas from OpenAPI components (schemas, responses, requestBodies)\n * and return them in dependency order along with name mapping for collision resolution.\n *\n * This function is a wrapper around the oas.getSchemas() method for backward compatibility.\n * New code should use oas.getSchemas() directly.\n *\n * @deprecated Use oas.getSchemas() instead\n */\nexport function getSchemas({ oas, contentType, includes = ['schemas', 'requestBodies', 'responses'], collisionDetection }: GetSchemasProps): GetSchemasResult {\n return oas.getSchemas({\n contentType,\n includes,\n collisionDetection,\n })\n}\n","import { camelCase, isValidVarName } from '@internals/utils'\nimport type { SchemaObject } from '@kubb/oas'\n\n/**\n * Apply casing transformation to schema properties\n * Only transforms property names, not nested schemas\n */\nexport function applyParamsCasing(schema: SchemaObject, casing: 'camelcase' | undefined): SchemaObject {\n if (!casing || !schema.properties) {\n return schema\n }\n\n const transformedProperties: Record<string, any> = {}\n const transformedRequired: string[] = []\n\n // Transform property names\n Object.entries(schema.properties).forEach(([originalName, propertySchema]) => {\n let transformedName = originalName\n\n if (casing === 'camelcase') {\n transformedName = camelCase(originalName)\n } else if (!isValidVarName(originalName)) {\n // If not valid variable name, make it valid\n transformedName = camelCase(originalName)\n }\n\n transformedProperties[transformedName] = propertySchema\n })\n\n // Transform required field names\n if (Array.isArray(schema.required)) {\n schema.required.forEach((originalName) => {\n let transformedName = originalName\n\n if (casing === 'camelcase') {\n transformedName = camelCase(originalName)\n } else if (!isValidVarName(originalName)) {\n transformedName = camelCase(originalName)\n }\n\n transformedRequired.push(transformedName)\n })\n }\n\n // Return a new schema with transformed properties and required fields\n return {\n ...schema,\n properties: transformedProperties,\n ...(transformedRequired.length > 0 && { required: transformedRequired }),\n } as SchemaObject\n}\n\n/**\n * Check if this schema is a parameter schema (pathParams, queryParams, or headerParams)\n * Only these should be transformed, not response/data/body\n */\nexport function isParameterSchema(schemaName: string): boolean {\n const lowerName = schemaName.toLowerCase()\n return lowerName.includes('pathparams') || lowerName.includes('queryparams') || lowerName.includes('headerparams')\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAoHA,SAAgB,eAAe,MAAuB;AACpD,KAAI;AACF,MAAI,SAAS,OAAO,OAAO;SACrB;AACN,SAAO;;AAET,QAAO;;;;;;;;;;;;ACvET,IAAa,UAAb,MAAqB;;;;CAInB;CAEA;CAEA,YAAY,MAAc,UAAmB,EAAE,EAAE;AAC/C,OAAK,OAAO;AACZ,QAAA,UAAgB;;;;;;;;;CAUlB,IAAI,MAAc;AAChB,SAAO,KAAK,WAAW;;;;;;;;;;CAWzB,IAAI,QAAiB;AACnB,MAAI;AACF,UAAO,CAAC,CAAC,IAAI,IAAI,KAAK,KAAK,CAAC;UACtB;AACN,UAAO;;;;;;;;;;CAWX,IAAI,WAAmB;AACrB,SAAO,KAAK,kBAAkB;;;;;;;;;;CAWhC,IAAI,SAA6B;AAC/B,SAAO,KAAK,UAAU;;;;;;;;;;CAWxB,IAAI,SAA6C;AAC/C,SAAO,KAAK,WAAW;;CAGzB,gBAAgB,KAAqB;EACnC,MAAM,QAAQ,eAAe,IAAI,GAAG,MAAM,UAAU,IAAI;AACxD,SAAO,MAAA,QAAc,WAAW,cAAc,UAAU,MAAM,GAAG;;;;;CAMnE,WAAW,IAAgD;AACzD,OAAK,MAAM,SAAS,KAAK,KAAK,SAAS,eAAe,EAAE;GACtD,MAAM,MAAM,MAAM;AAClB,MAAG,KAAK,MAAA,eAAqB,IAAI,CAAC;;;CAItC,SAAS,EAAE,OAAO,QAAQ,UAAU,cAA6B,EAAE,EAAsB;EACvF,MAAM,SAAS;GACb,KAAK,SAAS,SAAS,KAAK,WAAW,GAAG,KAAK,iBAAiB,EAAE,UAAU,CAAC;GAC7E,QAAQ,KAAK,WAAW;GACzB;AAED,MAAI,WAAW;AACb,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O,SAAS,CAChC,QAAO,SAAS,SAAS,iBAAiB;EACxC,IAAI,kBAAkB;AAEtB,MAAI,WAAW,YACb,mBAAkB,UAAU,aAAa;WAChC,CAAC,eAAe,aAAa,CACtC,mBAAkB,UAAU,aAAa;AAG3C,sBAAoB,KAAK,gBAAgB;GACzC;AAIJ,QAAO;EACL,GAAG;EACH,YAAY;EACZ,GAAI,oBAAoB,SAAS,KAAK,EAAE,UAAU,qBAAqB;EACxE;;;;;;AAOH,SAAgB,kBAAkB,YAA6B;CAC7D,MAAM,YAAY,WAAW,aAAa;AAC1C,QAAO,UAAU,SAAS,aAAa,IAAI,UAAU,SAAS,cAAc,IAAI,UAAU,SAAS,eAAe"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-oas",
3
- "version": "5.0.0-alpha.21",
3
+ "version": "5.0.0-alpha.23",
4
4
  "description": "OpenAPI Specification (OAS) plugin for Kubb, providing core functionality for parsing and processing OpenAPI/Swagger schemas for code generation.",
5
5
  "keywords": [
6
6
  "openapi",
@@ -84,8 +84,8 @@
84
84
  "@kubb/fabric-core": "0.15.1",
85
85
  "@kubb/react-fabric": "0.15.1",
86
86
  "remeda": "^2.33.6",
87
- "@kubb/core": "5.0.0-alpha.21",
88
- "@kubb/oas": "5.0.0-alpha.21"
87
+ "@kubb/core": "5.0.0-alpha.23",
88
+ "@kubb/oas": "5.0.0-alpha.23"
89
89
  },
90
90
  "peerDependencies": {
91
91
  "@kubb/fabric-core": "0.15.1",
@@ -1,7 +1,7 @@
1
1
  import type { AsyncEventEmitter } from '@internals/utils'
2
2
  import { pascalCase } from '@internals/utils'
3
3
  import type { FileMetaBase, KubbEvents, Plugin, PluginDriver, PluginFactoryOptions } from '@kubb/core'
4
- import type { Fabric as FabricType, KubbFile } from '@kubb/fabric-core/types'
4
+ import type { FabricFile, Fabric as FabricType } from '@kubb/fabric-core/types'
5
5
  import type { contentType, HttpMethod, Oas, OasTypes, Operation, SchemaObject } from '@kubb/oas'
6
6
  import pLimit from 'p-limit'
7
7
  import type { CoreGenerator } from './generators/createGenerator.ts'
@@ -11,7 +11,7 @@ import type { Exclude, Include, OperationSchemas, Override } from './types.ts'
11
11
  import { withRequiredRequestBodySchema } from './utils/requestBody.ts'
12
12
  import { renderOperation, renderOperations } from './utils.tsx'
13
13
 
14
- export type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>
14
+ export type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<FabricFile.File<TFileMeta> | Array<FabricFile.File<TFileMeta>> | null>
15
15
 
16
16
  type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
17
17
  fabric: FabricType
@@ -26,7 +26,7 @@ type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
26
26
  * Current plugin
27
27
  */
28
28
  plugin: Plugin<TPluginOptions>
29
- mode: KubbFile.Mode
29
+ mode: FabricFile.Mode
30
30
  UNSTABLE_NAMING?: true
31
31
  }
32
32
 
@@ -206,7 +206,7 @@ export class OperationGenerator<TPluginOptions extends PluginFactoryOptions = Pl
206
206
  )
207
207
  }
208
208
 
209
- async build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>> {
209
+ async build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<FabricFile.File<TFileMeta>>> {
210
210
  const operations = await this.getOperations()
211
211
 
212
212
  // Increased parallelism for better performance
@@ -293,7 +293,7 @@ export class OperationGenerator<TPluginOptions extends PluginFactoryOptions = Pl
293
293
  plugin: this.context.plugin,
294
294
  })
295
295
 
296
- return [...opResultsFlat, ...(operationsResult ?? [])] as unknown as KubbFile.File<TFileMeta>
296
+ return [...opResultsFlat, ...(operationsResult ?? [])] as unknown as FabricFile.File<TFileMeta>
297
297
  }),
298
298
  )
299
299
 
@@ -1,7 +1,7 @@
1
1
  import type { AsyncEventEmitter } from '@internals/utils'
2
2
  import { getUniqueName, pascalCase, stringify } from '@internals/utils'
3
3
  import type { FileMetaBase, KubbEvents, Plugin, PluginDriver, PluginFactoryOptions, ResolveNameParams } from '@kubb/core'
4
- import type { Fabric as FabricType, KubbFile } from '@kubb/fabric-core/types'
4
+ import type { FabricFile, Fabric as FabricType } from '@kubb/fabric-core/types'
5
5
  import type { contentType, Oas, OasTypes, OpenAPIV3, SchemaObject } from '@kubb/oas'
6
6
  import { isDiscriminator, isNullable, isReference, KUBB_INLINE_REF_PREFIX } from '@kubb/oas'
7
7
  import pLimit from 'p-limit'
@@ -16,11 +16,15 @@ import { renderSchema } from './utils.tsx'
16
16
 
17
17
  export type GetSchemaGeneratorOptions<T extends SchemaGenerator<any, any, any>> = T extends SchemaGenerator<infer Options, any, any> ? Options : never
18
18
 
19
- export type SchemaMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>
19
+ export type SchemaMethodResult<TFileMeta extends FileMetaBase> = Promise<FabricFile.File<TFileMeta> | Array<FabricFile.File<TFileMeta>> | null>
20
20
 
21
- /** Max concurrent generator tasks (across generators). */
21
+ /**
22
+ * Max concurrent generator tasks (across generators).
23
+ */
22
24
  const GENERATOR_CONCURRENCY = 3
23
- /** Max concurrent schema parsing tasks (per generator). */
25
+ /**
26
+ * Max concurrent schema parsing tasks (per generator).
27
+ */
24
28
  const SCHEMA_CONCURRENCY = 30
25
29
 
26
30
  type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
@@ -32,7 +36,7 @@ type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
32
36
  * Current plugin
33
37
  */
34
38
  plugin: Plugin<TPluginOptions>
35
- mode: KubbFile.Mode
39
+ mode: FabricFile.Mode
36
40
  include?: Array<'schemas' | 'responses' | 'requestBodies'>
37
41
  override: Array<Override<TOptions>> | undefined
38
42
  contentType?: contentType
@@ -1337,7 +1341,7 @@ export class SchemaGenerator<
1337
1341
  return [{ keyword: emptyType }, ...baseItems]
1338
1342
  }
1339
1343
 
1340
- async build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>> {
1344
+ async build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<FabricFile.File<TFileMeta>>> {
1341
1345
  const { oas, contentType, include } = this.context
1342
1346
 
1343
1347
  // Initialize the name mapping if not already done
@@ -1360,7 +1364,7 @@ export class SchemaGenerator<
1360
1364
  return this.#doBuild(schemas, generators)
1361
1365
  }
1362
1366
 
1363
- async #doBuild(schemas: Record<string, OasTypes.SchemaObject>, generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>> {
1367
+ async #doBuild(schemas: Record<string, OasTypes.SchemaObject>, generators: Array<Generator<TPluginOptions>>): Promise<Array<FabricFile.File<TFileMeta>>> {
1364
1368
  const schemaEntries = Object.entries(schemas)
1365
1369
 
1366
1370
  const generatorLimit = pLimit(GENERATOR_CONCURRENCY)
@@ -1428,7 +1432,7 @@ export class SchemaGenerator<
1428
1432
  )
1429
1433
 
1430
1434
  const schemaResults = await Promise.all(schemaTasks)
1431
- return schemaResults.flat() as unknown as KubbFile.File<TFileMeta>
1435
+ return schemaResults.flat() as unknown as FabricFile.File<TFileMeta>
1432
1436
  }),
1433
1437
  )
1434
1438
 
@@ -1,4 +1,4 @@
1
- import type { KubbFile } from '@kubb/fabric-core/types'
1
+ import type { FabricFile } from '@kubb/fabric-core/types'
2
2
  import type { SchemaObject } from '@kubb/oas'
3
3
 
4
4
  export type SchemaKeywordMapper = {
@@ -59,7 +59,7 @@ export type SchemaKeywordMapper = {
59
59
  /**
60
60
  * Full qualified path.
61
61
  */
62
- path: KubbFile.Path
62
+ path: FabricFile.Path
63
63
  /**
64
64
  * When true `File.Import` is used.
65
65
  * When false a reference is used inside the current file.
@@ -1,21 +1,21 @@
1
1
  import type { PluginFactoryOptions } from '@kubb/core'
2
- import type { KubbFile } from '@kubb/fabric-core/types'
2
+ import type { FabricFile } from '@kubb/fabric-core/types'
3
3
  import type { OperationProps, OperationsProps, SchemaProps } from './types.ts'
4
4
 
5
5
  type UserGenerator<TOptions extends PluginFactoryOptions> = {
6
6
  name: string
7
- operations?: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>
8
- operation?: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>
9
- schema?: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>
7
+ operations?: (props: OperationsProps<TOptions>) => Promise<FabricFile.File[]>
8
+ operation?: (props: OperationProps<TOptions>) => Promise<FabricFile.File[]>
9
+ schema?: (props: SchemaProps<TOptions>) => Promise<FabricFile.File[]>
10
10
  }
11
11
 
12
12
  export type CoreGenerator<TOptions extends PluginFactoryOptions> = {
13
13
  name: string
14
14
  type: 'core'
15
15
  version: '1'
16
- operations: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>
17
- operation: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>
18
- schema: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>
16
+ operations: (props: OperationsProps<TOptions>) => Promise<FabricFile.File[]>
17
+ operation: (props: OperationProps<TOptions>) => Promise<FabricFile.File[]>
18
+ schema: (props: SchemaProps<TOptions>) => Promise<FabricFile.File[]>
19
19
  }
20
20
 
21
21
  export function createGenerator<TOptions extends PluginFactoryOptions>(generator: UserGenerator<TOptions>): CoreGenerator<TOptions> {
@@ -1,6 +1,6 @@
1
1
  import type { FileMetaBase, PluginFactoryOptions, ResolveNameParams } from '@kubb/core'
2
2
  import { useDriver, usePlugin } from '@kubb/core/hooks'
3
- import type { KubbFile } from '@kubb/fabric-core/types'
3
+ import type { FabricFile } from '@kubb/fabric-core/types'
4
4
  import type { Operation, Operation as OperationType } from '@kubb/oas'
5
5
  import type { OperationGenerator } from '../OperationGenerator.ts'
6
6
  import type { OperationSchemas } from '../types.ts'
@@ -41,13 +41,13 @@ type UseOperationManagerResult = {
41
41
  prefix?: string
42
42
  suffix?: string
43
43
  pluginName?: string
44
- extname?: KubbFile.Extname
44
+ extname?: FabricFile.Extname
45
45
  group?: {
46
46
  tag?: string
47
47
  path?: string
48
48
  }
49
49
  },
50
- ) => KubbFile.File<FileMeta>
50
+ ) => FabricFile.File<FileMeta>
51
51
  groupSchemasByName: (
52
52
  operation: OperationType,
53
53
  params: {
@@ -1,6 +1,6 @@
1
1
  import type { FileMetaBase, ResolveNameParams } from '@kubb/core'
2
2
  import { useDriver, usePlugin } from '@kubb/core/hooks'
3
- import type { KubbFile } from '@kubb/fabric-core/types'
3
+ import type { FabricFile } from '@kubb/fabric-core/types'
4
4
 
5
5
  type FileMeta = FileMetaBase & {
6
6
  pluginName: string
@@ -17,14 +17,14 @@ type UseSchemaManagerResult = {
17
17
  name: string,
18
18
  params?: {
19
19
  pluginName?: string
20
- mode?: KubbFile.Mode
21
- extname?: KubbFile.Extname
20
+ mode?: FabricFile.Mode
21
+ extname?: FabricFile.Extname
22
22
  group?: {
23
23
  tag?: string
24
24
  path?: string
25
25
  }
26
26
  },
27
- ) => KubbFile.File<FileMeta>
27
+ ) => FabricFile.File<FileMeta>
28
28
  }
29
29
 
30
30
  /**
package/src/plugin.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import path from 'node:path'
2
2
  import type { AsyncEventEmitter } from '@internals/utils'
3
3
  import { camelCase } from '@internals/utils'
4
- import { type Config, createPlugin, type Group, getMode, type KubbEvents } from '@kubb/core'
4
+ import { type Config, createPlugin, getMode, type KubbEvents, type UserGroup } from '@kubb/core'
5
5
  import type { Oas } from '@kubb/oas'
6
6
  import { parseFromConfig, resolveServerUrl } from '@kubb/oas'
7
7
  import { jsonGenerator } from './generators'
@@ -111,7 +111,7 @@ export const pluginOas = createPlugin<PluginOas>((options) => {
111
111
  }
112
112
 
113
113
  if (group && (options?.group?.path || options?.group?.tag)) {
114
- const groupName: Group['name'] = group?.name
114
+ const groupName: UserGroup['name'] = group?.name
115
115
  ? group.name
116
116
  : (ctx) => {
117
117
  if (group?.type === 'path') {
package/src/types.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { Group, Output, PluginFactoryOptions, ResolveNameParams } from '@kubb/core'
2
- import type { KubbFile } from '@kubb/fabric-core/types'
1
+ import type { Output, PluginFactoryOptions, ResolveNameParams, UserGroup } from '@kubb/core'
2
+ import type { FabricFile } from '@kubb/fabric-core/types'
3
3
 
4
4
  import type { contentType, HttpMethod, Oas, Operation, SchemaObject } from '@kubb/oas'
5
5
  import type { Generator } from './generators/types.ts'
@@ -42,7 +42,7 @@ export type Options = {
42
42
  /**
43
43
  * Group the JSON files based on the provided name.
44
44
  */
45
- group?: Group
45
+ group?: UserGroup
46
46
  /**
47
47
  * Which server to use from the array of `servers.url[serverIndex]`
48
48
  * @example
@@ -142,7 +142,7 @@ export type Options = {
142
142
  export type Ref = {
143
143
  propertyName: string
144
144
  originalName: string
145
- path: KubbFile.Path
145
+ path: FabricFile.Path
146
146
  pluginName?: string
147
147
  }
148
148
  export type Refs = Record<string, Ref>
@@ -152,8 +152,8 @@ export type Resolver = {
152
152
  * Original name or name resolved by `resolveName({ name: operation?.getOperationId() as string, pluginName })`
153
153
  */
154
154
  name: string
155
- baseName: KubbFile.BaseName
156
- path: KubbFile.Path
155
+ baseName: FabricFile.BaseName
156
+ path: FabricFile.Path
157
157
  }
158
158
 
159
159
  export type OperationSchema = {
@@ -1,4 +1,4 @@
1
- import type { KubbFile } from '@kubb/fabric-core/types'
1
+ import type { FabricFile } from '@kubb/fabric-core/types'
2
2
  import { SchemaGenerator } from '../SchemaGenerator.ts'
3
3
  import type { Schema } from '../SchemaMapper'
4
4
  import { schemaKeywords } from '../SchemaMapper'
@@ -6,7 +6,7 @@ import { schemaKeywords } from '../SchemaMapper'
6
6
  /**
7
7
  * Get imports from a schema tree by extracting all ref schemas that are importable
8
8
  */
9
- export function getImports(tree: Array<Schema>): Array<KubbFile.Import> {
9
+ export function getImports(tree: Array<Schema>): Array<FabricFile.Import> {
10
10
  const refs = SchemaGenerator.deepSearch(tree, schemaKeywords.ref)
11
11
 
12
12
  if (!refs) return []
@@ -20,7 +20,7 @@ export function getImports(tree: Array<Schema>): Array<KubbFile.Import> {
20
20
  return {
21
21
  name: [item.args.name],
22
22
  path: item.args.path,
23
- } satisfies KubbFile.Import
23
+ } satisfies FabricFile.Import
24
24
  })
25
25
  .filter((x): x is NonNullable<typeof x> => x !== undefined)
26
26
  }