@kubb/kit 5.0.0-beta.99 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -63,6 +63,10 @@ export const pluginExample = definePlugin(() => {
63
63
 
64
64
  `ast` and `factory` are the node builders a generator calls to construct the file, schema, and operation nodes it returns. `Diagnostics` is the structured error a plugin throws to report a problem with a location and a fix suggestion, and `memoryStorage` and `fsStorage` are the built-in storage backends, useful in tests and custom configs.
65
65
 
66
+ `macroDiscriminatorEnum`, `macroEnumName`, `macroRenameSchema`, and `macroSimplifyUnion` are the built-in macro presets, ready to pass to `ast.applyMacros` or a plugin's `setMacros`. Build a custom macro with `ast.defineMacro` instead.
67
+
68
+ `childName`, `enumPropName`, `extractRefName`, `isStringType`, `mergeAdjacentObjectsLazy`, `syncSchemaRef`, and `containsCircularRef` are schema-name and schema-graph helpers a generator or macro calls while shaping output, complementing the ref and graph helpers (`resolveRefName`, `findCircularSchemas`, `collectUsedSchemaNames`) that stay on `ast`.
69
+
66
70
  Rounding out the package are the option and hook types every plugin, generator, adapter, resolver, and renderer author references, among them `PluginFactoryOptions`, `GeneratorContext`, `ResolveFileOptions`, `AdapterFactoryOptions`, `RendererFactory`, and `KubbHooks`.
67
71
 
68
72
  ## Testing helpers
package/dist/index.cjs CHANGED
@@ -28,6 +28,18 @@ function toCamelOrPascal(text, pascal) {
28
28
  function camelCase(text, { prefix = "", suffix = "" } = {}) {
29
29
  return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
30
30
  }
31
+ /**
32
+ * Converts `text` to PascalCase.
33
+ *
34
+ * @example Word boundaries
35
+ * `pascalCase('hello-world') // 'HelloWorld'`
36
+ *
37
+ * @example With a suffix
38
+ * `pascalCase('tag', { suffix: 'schema' }) // 'TagSchema'`
39
+ */
40
+ function pascalCase(text, { prefix = "", suffix = "" } = {}) {
41
+ return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true);
42
+ }
31
43
  //#endregion
32
44
  //#region ../../internals/utils/src/reserved.ts
33
45
  /**
@@ -177,9 +189,12 @@ var Url = class Url {
177
189
  *
178
190
  * @example
179
191
  * Url.toPath('/pet/{petId}') // '/pet/:petId'
192
+ *
193
+ * @example
194
+ * Url.toPath('/point/{point-id}') // '/point/:pointId'
180
195
  */
181
196
  static toPath(path) {
182
- return path.replace(/\{([^}]+)\}/g, ":$1");
197
+ return path.replace(/\{([^}]+)\}/g, (_match, param) => `:${transformParam(param)}`);
183
198
  }
184
199
  /**
185
200
  * Converts an OpenAPI/Swagger path to a TypeScript template literal string.
@@ -238,6 +253,289 @@ var Url = class Url {
238
253
  }
239
254
  };
240
255
  //#endregion
256
+ //#region src/macros/macroDiscriminatorEnum.ts
257
+ /**
258
+ * Builds a macro that replaces a discriminator property's schema with a string enum of the given
259
+ * values. Object schemas that lack the property are returned unchanged.
260
+ *
261
+ * @example
262
+ * ```ts
263
+ * const macro = macroDiscriminatorEnum({ propertyName: 'type', values: ['dog', 'cat'] })
264
+ * const next = applyMacros(objectSchema, [macro], { depth: 'shallow' })
265
+ * ```
266
+ */
267
+ function macroDiscriminatorEnum({ propertyName, values, enumName }) {
268
+ return _kubb_ast.ast.defineMacro({
269
+ name: "discriminator-enum",
270
+ schema(node) {
271
+ const objectNode = _kubb_ast.ast.narrowSchema(node, "object");
272
+ if (!objectNode?.properties?.length) return void 0;
273
+ if (!objectNode.properties.some((prop) => prop.name === propertyName)) return void 0;
274
+ return _kubb_ast.ast.factory.createSchema({
275
+ ...objectNode,
276
+ properties: objectNode.properties.map((prop) => {
277
+ if (prop.name !== propertyName) return prop;
278
+ return _kubb_ast.ast.factory.createProperty({
279
+ ...prop,
280
+ schema: _kubb_ast.ast.factory.createSchema({
281
+ type: "enum",
282
+ primitive: "string",
283
+ enumValues: values,
284
+ name: enumName,
285
+ readOnly: prop.schema.readOnly,
286
+ writeOnly: prop.schema.writeOnly
287
+ })
288
+ });
289
+ })
290
+ });
291
+ }
292
+ });
293
+ }
294
+ //#endregion
295
+ //#region src/utils/refs.ts
296
+ const plainStringTypes = /* @__PURE__ */ new Set([
297
+ "string",
298
+ "uuid",
299
+ "email",
300
+ "url",
301
+ "datetime"
302
+ ]);
303
+ /**
304
+ * Returns the last path segment of a reference string.
305
+ *
306
+ * @example
307
+ * `extractRefName('#/components/schemas/Pet') // 'Pet'`
308
+ */
309
+ function extractRefName(ref) {
310
+ return ref.split("/").at(-1) ?? ref;
311
+ }
312
+ /**
313
+ * Builds a PascalCase child schema name by joining a parent name and property name.
314
+ * Returns `null` when there is no parent to nest under.
315
+ *
316
+ * @example Nested under a parent
317
+ * `childName('Order', 'shipping_address') // 'OrderShippingAddress'`
318
+ *
319
+ * @example No parent
320
+ * `childName(undefined, 'params') // null`
321
+ */
322
+ function childName(parentName, propName) {
323
+ return parentName ? pascalCase([parentName, propName].join(" ")) : null;
324
+ }
325
+ /**
326
+ * Builds a PascalCase enum name from the parent name, property name, and a suffix, skipping any
327
+ * empty parts.
328
+ *
329
+ * @example
330
+ * `enumPropName('Order', 'status', 'enum') // 'OrderStatusEnum'`
331
+ */
332
+ function enumPropName(parentName, propName, enumSuffix) {
333
+ return pascalCase([
334
+ parentName,
335
+ propName,
336
+ enumSuffix
337
+ ].filter(Boolean).join(" "));
338
+ }
339
+ /**
340
+ * Merges a ref node with its resolved schema, giving usage-site fields precedence.
341
+ *
342
+ * Every field set on the ref node except `kind`, `type`, `name`, `ref`, and `schema` overrides the
343
+ * same field in the resolved `node.schema` (for example `description`, `nullable`, `readOnly`,
344
+ * `deprecated`). Fields left `undefined` on the ref do not shadow the resolved schema. Non-ref
345
+ * nodes and refs without a resolved `schema` are returned unchanged.
346
+ *
347
+ * @example
348
+ * ```ts
349
+ * const ref = ast.factory.createSchema({ type: 'ref', ref: '#/components/schemas/Pet', description: 'A cute pet' })
350
+ * const merged = syncSchemaRef(ref) // merges with resolved Pet schema
351
+ * ```
352
+ */
353
+ function syncSchemaRef(node) {
354
+ const ref = _kubb_ast.ast.narrowSchema(node, "ref");
355
+ if (!ref) return node;
356
+ if (!ref.schema) return node;
357
+ const { kind: _kind, type: _type, name: _name, ref: _ref, schema: _schema, ...overrides } = ref;
358
+ const definedOverrides = Object.fromEntries(Object.entries(overrides).filter(([, v]) => v !== void 0));
359
+ return _kubb_ast.ast.factory.createSchema({
360
+ ...ref.schema,
361
+ ...definedOverrides
362
+ });
363
+ }
364
+ /**
365
+ * Returns `true` when a schema emits as a plain `string` type.
366
+ *
367
+ * Covers `string`, `uuid`, `email`, `url`, and `datetime` types. For `date` and `time`
368
+ * types, returns `true` only when `representation` is `'string'` rather than `'date'`.
369
+ */
370
+ function isStringType(node) {
371
+ if (plainStringTypes.has(node.type)) return true;
372
+ const temporal = _kubb_ast.ast.narrowSchema(node, "date") ?? _kubb_ast.ast.narrowSchema(node, "time");
373
+ if (temporal) return temporal.representation !== "date";
374
+ return false;
375
+ }
376
+ //#endregion
377
+ //#region src/macros/macroEnumName.ts
378
+ /**
379
+ * Builds a macro that names an inline enum schema from its parent and property name. Boolean enums
380
+ * are left anonymous. Non-enum nodes are returned unchanged.
381
+ *
382
+ * @example
383
+ * ```ts
384
+ * const macro = macroEnumName({ parentName: 'Pet', propName: 'status', enumSuffix: 'enum' })
385
+ * const named = applyMacros(propSchema, [macro], { depth: 'shallow' })
386
+ * ```
387
+ */
388
+ function macroEnumName({ parentName, propName, enumSuffix }) {
389
+ return _kubb_ast.ast.defineMacro({
390
+ name: "enum-name",
391
+ schema(node) {
392
+ const enumNode = _kubb_ast.ast.narrowSchema(node, "enum");
393
+ if (enumNode?.primitive === "boolean") return {
394
+ ...node,
395
+ name: null
396
+ };
397
+ if (enumNode) return {
398
+ ...node,
399
+ name: enumPropName(parentName, propName, enumSuffix)
400
+ };
401
+ }
402
+ });
403
+ }
404
+ //#endregion
405
+ //#region src/macros/macroRenameSchema.ts
406
+ /**
407
+ * Builds a macro that renames a schema consistently: the declaration (`name`) and every ref
408
+ * pointing at it (`targetName`) change together, so imports and printed references stay in
409
+ * sync. Renaming only one side by hand produces imports for files that are never generated.
410
+ *
411
+ * @example
412
+ * `const macro = macroRenameSchema({ from: 'Order', to: 'StoreOrder' })`
413
+ */
414
+ function macroRenameSchema({ from, to }) {
415
+ return _kubb_ast.ast.defineMacro({
416
+ name: "rename-schema",
417
+ schema(node) {
418
+ const refNode = _kubb_ast.ast.narrowSchema(node, "ref");
419
+ if (!refNode) return node.name === from ? {
420
+ ...node,
421
+ name: to
422
+ } : void 0;
423
+ const renamesDeclaration = refNode.name === from;
424
+ const renamesTarget = _kubb_ast.ast.resolveRefName(refNode) === from;
425
+ if (!renamesDeclaration && !renamesTarget) return void 0;
426
+ return {
427
+ ...refNode,
428
+ ...renamesDeclaration ? { name: to } : {},
429
+ ...renamesTarget ? { targetName: to } : {}
430
+ };
431
+ }
432
+ });
433
+ }
434
+ //#endregion
435
+ //#region src/macros/macroSimplifyUnion.ts
436
+ /**
437
+ * Scalar primitive schema types used for union simplification and type narrowing.
438
+ */
439
+ const SCALAR_PRIMITIVE_TYPES = /* @__PURE__ */ new Set([
440
+ "string",
441
+ "number",
442
+ "integer",
443
+ "bigint",
444
+ "boolean"
445
+ ]);
446
+ function isScalarPrimitive(type) {
447
+ return SCALAR_PRIMITIVE_TYPES.has(type);
448
+ }
449
+ /**
450
+ * Filters union members, dropping enum members that a broader scalar primitive already covers.
451
+ */
452
+ function simplifyUnionMembers(members) {
453
+ const scalarPrimitives = new Set(members.filter((member) => isScalarPrimitive(member.type)).map((m) => m.type));
454
+ if (!scalarPrimitives.size) return members;
455
+ return members.filter((member) => {
456
+ const enumNode = _kubb_ast.ast.narrowSchema(member, "enum");
457
+ if (!enumNode) return true;
458
+ const primitive = enumNode.primitive;
459
+ if (!primitive) return true;
460
+ if ((enumNode.namedEnumValues?.length ?? enumNode.enumValues?.length ?? 0) <= 1) return true;
461
+ if (scalarPrimitives.has(primitive)) return false;
462
+ if ((primitive === "integer" || primitive === "number") && (scalarPrimitives.has("integer") || scalarPrimitives.has("number"))) return false;
463
+ return true;
464
+ });
465
+ }
466
+ /**
467
+ * Removes union members a broader scalar primitive already covers, such as a multi-value string enum
468
+ * sitting next to a plain `string`. Single-value enums are kept.
469
+ *
470
+ * @example
471
+ * ```ts
472
+ * const next = applyMacros(unionSchema, [macroSimplifyUnion], { depth: 'shallow' })
473
+ * ```
474
+ */
475
+ const macroSimplifyUnion = _kubb_ast.ast.defineMacro({
476
+ name: "simplify-union",
477
+ schema(node) {
478
+ const unionNode = _kubb_ast.ast.narrowSchema(node, "union");
479
+ if (!unionNode?.members?.length) return void 0;
480
+ const simplified = simplifyUnionMembers(unionNode.members);
481
+ if (simplified.length === unionNode.members.length) return void 0;
482
+ return {
483
+ ...unionNode,
484
+ members: simplified
485
+ };
486
+ }
487
+ });
488
+ //#endregion
489
+ //#region src/utils/mergeAdjacentSchemas.ts
490
+ /**
491
+ * Merges a run of adjacent anonymous object members into one. Named or non-object members break the
492
+ * run and pass through unchanged. The merge follows member order, so callers control which members
493
+ * combine by where they place them in the sequence.
494
+ *
495
+ * @example
496
+ * ```ts
497
+ * const merged = [...mergeAdjacentObjectsLazy([objectA, objectB])]
498
+ * ```
499
+ */
500
+ function* mergeAdjacentObjectsLazy(members) {
501
+ let acc;
502
+ for (const member of members) {
503
+ const objectMember = _kubb_ast.ast.narrowSchema(member, "object");
504
+ if (objectMember && !objectMember.name && acc !== void 0) {
505
+ const accObject = _kubb_ast.ast.narrowSchema(acc, "object");
506
+ if (accObject && !accObject.name) {
507
+ acc = _kubb_ast.ast.factory.createSchema({
508
+ ...accObject,
509
+ properties: [...accObject.properties ?? [], ...objectMember.properties ?? []]
510
+ });
511
+ continue;
512
+ }
513
+ }
514
+ if (acc !== void 0) yield acc;
515
+ acc = member;
516
+ }
517
+ if (acc !== void 0) yield acc;
518
+ }
519
+ //#endregion
520
+ //#region src/utils/schemaGraph.ts
521
+ /**
522
+ * Returns `true` when a schema, or anything nested inside it, references a circular schema.
523
+ *
524
+ * Pass `excludeName` to skip refs to a specific schema, which helps when self-references are handled
525
+ * on their own. Pair it with `ast.findCircularSchemas()` to decide where lazy wrappers go.
526
+ *
527
+ * @note Stops at the first matching circular ref.
528
+ */
529
+ function containsCircularRef(node, { circularSchemas, excludeName }) {
530
+ if (!node || circularSchemas.size === 0) return false;
531
+ for (const _ of _kubb_ast.ast.collect(node, { schema(child) {
532
+ if (child.type !== "ref") return null;
533
+ const name = _kubb_ast.ast.resolveRefName(child);
534
+ return name && name !== excludeName && circularSchemas.has(name) ? true : null;
535
+ } })) return true;
536
+ return false;
537
+ }
538
+ //#endregion
241
539
  Object.defineProperty(exports, "Diagnostics", {
242
540
  enumerable: true,
243
541
  get: function() {
@@ -263,6 +561,8 @@ Object.defineProperty(exports, "ast", {
263
561
  return _kubb_ast.ast;
264
562
  }
265
563
  });
564
+ exports.childName = childName;
565
+ exports.containsCircularRef = containsCircularRef;
266
566
  Object.defineProperty(exports, "createAdapter", {
267
567
  enumerable: true,
268
568
  get: function() {
@@ -305,17 +605,26 @@ Object.defineProperty(exports, "definePlugin", {
305
605
  return _kubb_core.definePlugin;
306
606
  }
307
607
  });
608
+ exports.enumPropName = enumPropName;
609
+ exports.extractRefName = extractRefName;
308
610
  Object.defineProperty(exports, "fsStorage", {
309
611
  enumerable: true,
310
612
  get: function() {
311
613
  return _kubb_core.fsStorage;
312
614
  }
313
615
  });
616
+ exports.isStringType = isStringType;
617
+ exports.macroDiscriminatorEnum = macroDiscriminatorEnum;
618
+ exports.macroEnumName = macroEnumName;
619
+ exports.macroRenameSchema = macroRenameSchema;
620
+ exports.macroSimplifyUnion = macroSimplifyUnion;
314
621
  Object.defineProperty(exports, "memoryStorage", {
315
622
  enumerable: true,
316
623
  get: function() {
317
624
  return _kubb_core.memoryStorage;
318
625
  }
319
626
  });
627
+ exports.mergeAdjacentObjectsLazy = mergeAdjacentObjectsLazy;
628
+ exports.syncSchemaRef = syncSchemaRef;
320
629
 
321
630
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":[],"sources":["../../../internals/utils/src/casing.ts","../../../internals/utils/src/reserved.ts","../../../internals/utils/src/Url.ts"],"sourcesContent":["type Options = {\n /**\n * Text prepended before casing is applied.\n */\n prefix?: string\n /**\n * Text appended before casing is applied.\n */\n suffix?: string\n}\n\n/**\n * Shared implementation for camelCase and PascalCase conversion.\n * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)\n * and capitalizes each word according to `pascal`.\n *\n * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.\n */\nfunction toCamelOrPascal(text: string, pascal: boolean): string {\n return text\n .trim()\n .replace(/([a-z\\d])([A-Z])/g, '$1 $2')\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')\n .replace(/(\\d)([a-z])/g, '$1 $2')\n .split(/[\\s\\-_./\\\\:]+/)\n .filter(Boolean)\n .map((word, i) => {\n if (word.length > 1 && word === word.toUpperCase()) return word\n const head = i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()\n return head + word.slice(1)\n })\n .join('')\n .replace(/[^a-zA-Z0-9]/g, '')\n}\n\n/**\n * Converts `text` to camelCase.\n *\n * @example Word boundaries\n * `camelCase('hello-world') // 'helloWorld'`\n *\n * @example With a prefix\n * `camelCase('tag', { prefix: 'create' }) // 'createTag'`\n */\nexport function camelCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false)\n}\n\n/**\n * Converts `text` to PascalCase.\n *\n * @example Word boundaries\n * `pascalCase('hello-world') // 'HelloWorld'`\n *\n * @example With a suffix\n * `pascalCase('tag', { suffix: 'schema' }) // 'TagSchema'`\n */\nexport function pascalCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true)\n}\n","/**\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 * 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 if (!name || reservedWords.has(name as 'valueOf')) {\n return false\n }\n return isIdentifier(name)\n}\n\n/**\n * Returns `true` when `name` is syntactically a valid identifier, ignoring reserved words.\n *\n * Reserved words and globals (`class`, `name`, `Date`, …) are valid as bare object-literal keys\n * even though they are not valid variable names, so use this (not {@link isValidVarName}) when\n * deciding whether an object key needs quoting.\n *\n * @example\n * ```ts\n * isIdentifier('name') // true\n * isIdentifier('x-total')// false\n * ```\n */\nexport function isIdentifier(name: string): boolean {\n return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name)\n}\n","import { camelCase } from './casing.ts'\nimport { isValidVarName } from './reserved.ts'\n\ntype 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 `null` when the path has none.\n */\n params: Record<string, string> | null\n}\n\ntype TemplateOptions = {\n /**\n * Literal text prepended inside the template literal, e.g. a base URL.\n */\n prefix?: string | null\n /**\n * Transform applied to each extracted parameter name before interpolation.\n */\n replacer?: (pathParam: 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 * 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\nfunction transformParam(raw: string): string {\n return isValidVarName(raw) ? raw : camelCase(raw)\n}\n\n/**\n * Renders how a grouped `path` object's member is accessed: dot access for a valid\n * identifier, bracket access with the raw name otherwise.\n */\nfunction groupedAccessor(name: string): string {\n return isValidVarName(name) ? `.${name}` : `[${JSON.stringify(name)}]`\n}\n\nfunction toParamsObject(path: string, { replacer }: { replacer?: (pathParam: string) => string } = {}): Record<string, string> | null {\n const params: Record<string, string> = {}\n\n for (const match of path.matchAll(/\\{([^}]+)\\}/g)) {\n const param = transformParam(match[1]!)\n const key = replacer ? replacer(param) : param\n params[key] = key\n }\n\n return Object.keys(params).length > 0 ? params : null\n}\n\n/**\n * Helpers for OpenAPI/Swagger paths, plus a thin wrapper over the native `URL`.\n */\nexport class Url {\n /**\n * Converts an OpenAPI/Swagger path to Express-style colon syntax.\n *\n * @example\n * Url.toPath('/pet/{petId}') // '/pet/:petId'\n */\n static toPath(path: string): string {\n return path.replace(/\\{([^}]+)\\}/g, ':$1')\n }\n\n /**\n * Converts an OpenAPI/Swagger path to a TypeScript template literal string.\n * `prefix` is prepended inside the literal, and `replacer` transforms each parameter name.\n *\n * @example\n * Url.toTemplateString('/pet/{petId}') // '`/pet/${petId}`'\n *\n * @example\n * Url.toTemplateString('/pet/{petId}', { prefix: 'https://api' }) // '`https://api/pet/${petId}`'\n */\n static toTemplateString(path: string, { prefix, replacer }: TemplateOptions = {}): string {\n const parts = path.split(/\\{([^}]+)\\}/)\n const result = parts\n .map((part, i) => {\n if (i % 2 === 0) return part\n const param = transformParam(part)\n return `\\${${replacer ? replacer(param) : param}}`\n })\n .join('')\n\n return `\\`${prefix ?? ''}${result}\\``\n }\n\n /**\n * Converts an OpenAPI/Swagger path to a template literal that reads each parameter off a\n * grouped `path` request option, e.g. `/pet/{petId}` becomes `` `/pet/${path.petId}` ``.\n * Parameter names are kept exactly as they appear in the OpenAPI path; a name falls back to\n * bracket access (`` path['pet-id'] ``) only when it isn't a valid JS identifier.\n * `prefix` is prepended inside the literal. Shared by generators that pass a grouped `path` object.\n *\n * @example\n * Url.toGroupedTemplateString('/pet/{petId}') // '`/pet/${path.petId}`'\n *\n * @example\n * Url.toGroupedTemplateString('/user/{monetary-account-id}') // '`/user/${path[\"monetary-account-id\"]}`'\n */\n static toGroupedTemplateString(path: string, { prefix }: { prefix?: string | null } = {}): string {\n const parts = path.split(/\\{([^}]+)\\}/)\n const result = parts.map((part, i) => (i % 2 === 0 ? part : `\\${path${groupedAccessor(part)}}`)).join('')\n\n return `\\`${prefix ?? ''}${result}\\``\n }\n\n /**\n * Returns the path and its extracted params as a structured `URLObject`, or as a stringified\n * expression when `stringify` is set.\n *\n * @example\n * Url.toObject('/pet/{petId}')\n * // { url: '/pet/:petId', params: { petId: 'petId' } }\n */\n static toObject(path: string, { type = 'path', replacer, stringify }: ObjectOptions = {}): URLObject | string {\n const object: URLObject = {\n url: type === 'path' ? Url.toPath(path) : Url.toTemplateString(path, { replacer }),\n params: toParamsObject(path, { replacer }),\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"],"mappings":";;;;;;;;;;;;AAkBA,SAAS,gBAAgB,MAAc,QAAyB;CAC9D,OAAO,KACJ,KAAK,CAAC,CACN,QAAQ,qBAAqB,OAAO,CAAC,CACrC,QAAQ,yBAAyB,OAAO,CAAC,CACzC,QAAQ,gBAAgB,OAAO,CAAC,CAChC,MAAM,eAAe,CAAC,CACtB,OAAO,OAAO,CAAC,CACf,KAAK,MAAM,MAAM;EAChB,IAAI,KAAK,SAAS,KAAK,SAAS,KAAK,YAAY,GAAG,OAAO;EAE3D,QADa,MAAM,KAAK,CAAC,SAAS,KAAK,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,YAAY,KAC9E,KAAK,MAAM,CAAC;CAC5B,CAAC,CAAC,CACD,KAAK,EAAE,CAAC,CACR,QAAQ,iBAAiB,EAAE;AAChC;;;;;;;;;;AAWA,SAAgB,UAAU,MAAc,EAAE,SAAS,IAAI,SAAS,OAAgB,CAAC,GAAW;CAC1F,OAAO,gBAAgB,GAAG,OAAO,GAAG,KAAK,GAAG,UAAU,KAAK;AAC7D;;;;;;;AC1CA,MAAM,gCAAgB,IAAI,IAAI;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAU;;;;;;;;;;;AAYV,SAAgB,eAAe,MAAuB;CACpD,IAAI,CA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IAAI,OAAO,UAAU,gBAAgB,IAAI,EAAE,EAAG,CAAC,CAAC,KAAK,EAAE;EAExG,OAAO,KAAK,UAAU,KAAK,OAAO;CACpC;;;;;;;;;CAUA,OAAO,SAAS,MAAc,EAAE,OAAO,QAAQ,UAAU,cAA6B,CAAC,GAAuB;EAC5G,MAAM,SAAoB;GACxB,KAAK,SAAS,SAAS,IAAI,OAAO,IAAI,IAAI,IAAI,iBAAiB,MAAM,EAAE,SAAS,CAAC;GACjF,QAAQ,eAAe,MAAM,EAAE,SAAS,CAAC;EAC3C;EAEA,IAAI,WAAW;GACb,IAAI,SAAS,YACX,OAAO,KAAK,UAAU,MAAM,CAAC,CAAC,WAAW,KAAK,EAAE,CAAC,CAAC,WAAW,KAAK,EAAE;GAGtE,IAAI,OAAO,QACT,OAAO,WAAW,OAAO,IAAI,aAAa,KAAK,UAAU,OAAO,MAAM,CAAC,CAAC,WAAW,KAAK,EAAE,CAAC,CAAC,WAAW,KAAK,EAAE,EAAE;GAGlH,OAAO,WAAW,OAAO,IAAI;EAC/B;EAEA,OAAO;CACT;AACF"}
1
+ {"version":3,"file":"index.cjs","names":["ast","ast","ast","ast","ast","ast","ast"],"sources":["../../../internals/utils/src/casing.ts","../../../internals/utils/src/reserved.ts","../../../internals/utils/src/Url.ts","../src/macros/macroDiscriminatorEnum.ts","../src/utils/refs.ts","../src/macros/macroEnumName.ts","../src/macros/macroRenameSchema.ts","../src/macros/macroSimplifyUnion.ts","../src/utils/mergeAdjacentSchemas.ts","../src/utils/schemaGraph.ts"],"sourcesContent":["type Options = {\n /**\n * Text prepended before casing is applied.\n */\n prefix?: string\n /**\n * Text appended before casing is applied.\n */\n suffix?: string\n}\n\n/**\n * Shared implementation for camelCase and PascalCase conversion.\n * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)\n * and capitalizes each word according to `pascal`.\n *\n * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.\n */\nfunction toCamelOrPascal(text: string, pascal: boolean): string {\n return text\n .trim()\n .replace(/([a-z\\d])([A-Z])/g, '$1 $2')\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')\n .replace(/(\\d)([a-z])/g, '$1 $2')\n .split(/[\\s\\-_./\\\\:]+/)\n .filter(Boolean)\n .map((word, i) => {\n if (word.length > 1 && word === word.toUpperCase()) return word\n const head = i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()\n return head + word.slice(1)\n })\n .join('')\n .replace(/[^a-zA-Z0-9]/g, '')\n}\n\n/**\n * Converts `text` to camelCase.\n *\n * @example Word boundaries\n * `camelCase('hello-world') // 'helloWorld'`\n *\n * @example With a prefix\n * `camelCase('tag', { prefix: 'create' }) // 'createTag'`\n */\nexport function camelCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false)\n}\n\n/**\n * Converts `text` to PascalCase.\n *\n * @example Word boundaries\n * `pascalCase('hello-world') // 'HelloWorld'`\n *\n * @example With a suffix\n * `pascalCase('tag', { suffix: 'schema' }) // 'TagSchema'`\n */\nexport function pascalCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true)\n}\n","/**\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 * 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 if (!name || reservedWords.has(name as 'valueOf')) {\n return false\n }\n return isIdentifier(name)\n}\n\n/**\n * Returns `true` when `name` is syntactically a valid identifier, ignoring reserved words.\n *\n * Reserved words and globals (`class`, `name`, `Date`, …) are valid as bare object-literal keys\n * even though they are not valid variable names, so use this (not {@link isValidVarName}) when\n * deciding whether an object key needs quoting.\n *\n * @example\n * ```ts\n * isIdentifier('name') // true\n * isIdentifier('x-total')// false\n * ```\n */\nexport function isIdentifier(name: string): boolean {\n return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name)\n}\n","import { camelCase } from './casing.ts'\nimport { isValidVarName } from './reserved.ts'\n\ntype 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 `null` when the path has none.\n */\n params: Record<string, string> | null\n}\n\ntype TemplateOptions = {\n /**\n * Literal text prepended inside the template literal, e.g. a base URL.\n */\n prefix?: string | null\n /**\n * Transform applied to each extracted parameter name before interpolation.\n */\n replacer?: (pathParam: 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 * 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\nfunction transformParam(raw: string): string {\n return isValidVarName(raw) ? raw : camelCase(raw)\n}\n\n/**\n * Renders how a grouped `path` object's member is accessed: dot access for a valid\n * identifier, bracket access with the raw name otherwise.\n */\nfunction groupedAccessor(name: string): string {\n return isValidVarName(name) ? `.${name}` : `[${JSON.stringify(name)}]`\n}\n\nfunction toParamsObject(path: string, { replacer }: { replacer?: (pathParam: string) => string } = {}): Record<string, string> | null {\n const params: Record<string, string> = {}\n\n for (const match of path.matchAll(/\\{([^}]+)\\}/g)) {\n const param = transformParam(match[1]!)\n const key = replacer ? replacer(param) : param\n params[key] = key\n }\n\n return Object.keys(params).length > 0 ? params : null\n}\n\n/**\n * Helpers for OpenAPI/Swagger paths, plus a thin wrapper over the native `URL`.\n */\nexport class Url {\n /**\n * Converts an OpenAPI/Swagger path to Express-style colon syntax.\n *\n * @example\n * Url.toPath('/pet/{petId}') // '/pet/:petId'\n *\n * @example\n * Url.toPath('/point/{point-id}') // '/point/:pointId'\n */\n static toPath(path: string): string {\n return path.replace(/\\{([^}]+)\\}/g, (_match, param: string) => `:${transformParam(param)}`)\n }\n\n /**\n * Converts an OpenAPI/Swagger path to a TypeScript template literal string.\n * `prefix` is prepended inside the literal, and `replacer` transforms each parameter name.\n *\n * @example\n * Url.toTemplateString('/pet/{petId}') // '`/pet/${petId}`'\n *\n * @example\n * Url.toTemplateString('/pet/{petId}', { prefix: 'https://api' }) // '`https://api/pet/${petId}`'\n */\n static toTemplateString(path: string, { prefix, replacer }: TemplateOptions = {}): string {\n const parts = path.split(/\\{([^}]+)\\}/)\n const result = parts\n .map((part, i) => {\n if (i % 2 === 0) return part\n const param = transformParam(part)\n return `\\${${replacer ? replacer(param) : param}}`\n })\n .join('')\n\n return `\\`${prefix ?? ''}${result}\\``\n }\n\n /**\n * Converts an OpenAPI/Swagger path to a template literal that reads each parameter off a\n * grouped `path` request option, e.g. `/pet/{petId}` becomes `` `/pet/${path.petId}` ``.\n * Parameter names are kept exactly as they appear in the OpenAPI path; a name falls back to\n * bracket access (`` path['pet-id'] ``) only when it isn't a valid JS identifier.\n * `prefix` is prepended inside the literal. Shared by generators that pass a grouped `path` object.\n *\n * @example\n * Url.toGroupedTemplateString('/pet/{petId}') // '`/pet/${path.petId}`'\n *\n * @example\n * Url.toGroupedTemplateString('/user/{monetary-account-id}') // '`/user/${path[\"monetary-account-id\"]}`'\n */\n static toGroupedTemplateString(path: string, { prefix }: { prefix?: string | null } = {}): string {\n const parts = path.split(/\\{([^}]+)\\}/)\n const result = parts.map((part, i) => (i % 2 === 0 ? part : `\\${path${groupedAccessor(part)}}`)).join('')\n\n return `\\`${prefix ?? ''}${result}\\``\n }\n\n /**\n * Returns the path and its extracted params as a structured `URLObject`, or as a stringified\n * expression when `stringify` is set.\n *\n * @example\n * Url.toObject('/pet/{petId}')\n * // { url: '/pet/:petId', params: { petId: 'petId' } }\n */\n static toObject(path: string, { type = 'path', replacer, stringify }: ObjectOptions = {}): URLObject | string {\n const object: URLObject = {\n url: type === 'path' ? Url.toPath(path) : Url.toTemplateString(path, { replacer }),\n params: toParamsObject(path, { replacer }),\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","import { ast } from '@kubb/ast'\n\ntype Props = {\n propertyName: string\n values: Array<string>\n enumName?: string\n}\n\n/**\n * Builds a macro that replaces a discriminator property's schema with a string enum of the given\n * values. Object schemas that lack the property are returned unchanged.\n *\n * @example\n * ```ts\n * const macro = macroDiscriminatorEnum({ propertyName: 'type', values: ['dog', 'cat'] })\n * const next = applyMacros(objectSchema, [macro], { depth: 'shallow' })\n * ```\n */\nexport function macroDiscriminatorEnum({ propertyName, values, enumName }: Props) {\n return ast.defineMacro({\n name: 'discriminator-enum',\n schema(node) {\n const objectNode = ast.narrowSchema(node, 'object')\n if (!objectNode?.properties?.length) return undefined\n if (!objectNode.properties.some((prop) => prop.name === propertyName)) return undefined\n\n return ast.factory.createSchema({\n ...objectNode,\n properties: objectNode.properties.map((prop) => {\n if (prop.name !== propertyName) return prop\n\n return ast.factory.createProperty({\n ...prop,\n schema: ast.factory.createSchema({\n type: 'enum',\n primitive: 'string',\n enumValues: values,\n name: enumName,\n readOnly: prop.schema.readOnly,\n writeOnly: prop.schema.writeOnly,\n }),\n })\n }),\n })\n },\n })\n}\n","import { ast } from '@kubb/ast'\nimport type { SchemaNode, SchemaType } from '@kubb/ast'\nimport { pascalCase } from '@internals/utils'\n\nconst plainStringTypes = new Set<SchemaType>(['string', 'uuid', 'email', 'url', 'datetime'] as const)\n\n/**\n * Returns the last path segment of a reference string.\n *\n * @example\n * `extractRefName('#/components/schemas/Pet') // 'Pet'`\n */\nexport function extractRefName(ref: string): string {\n return ref.split('/').at(-1) ?? ref\n}\n\n/**\n * Builds a PascalCase child schema name by joining a parent name and property name.\n * Returns `null` when there is no parent to nest under.\n *\n * @example Nested under a parent\n * `childName('Order', 'shipping_address') // 'OrderShippingAddress'`\n *\n * @example No parent\n * `childName(undefined, 'params') // null`\n */\nexport function childName(parentName: string | null | undefined, propName: string): string | null {\n return parentName ? pascalCase([parentName, propName].join(' ')) : null\n}\n\n/**\n * Builds a PascalCase enum name from the parent name, property name, and a suffix, skipping any\n * empty parts.\n *\n * @example\n * `enumPropName('Order', 'status', 'enum') // 'OrderStatusEnum'`\n */\nexport function enumPropName(parentName: string | null | undefined, propName: string, enumSuffix: string): string {\n return pascalCase([parentName, propName, enumSuffix].filter(Boolean).join(' '))\n}\n\n/**\n * Merges a ref node with its resolved schema, giving usage-site fields precedence.\n *\n * Every field set on the ref node except `kind`, `type`, `name`, `ref`, and `schema` overrides the\n * same field in the resolved `node.schema` (for example `description`, `nullable`, `readOnly`,\n * `deprecated`). Fields left `undefined` on the ref do not shadow the resolved schema. Non-ref\n * nodes and refs without a resolved `schema` are returned unchanged.\n *\n * @example\n * ```ts\n * const ref = ast.factory.createSchema({ type: 'ref', ref: '#/components/schemas/Pet', description: 'A cute pet' })\n * const merged = syncSchemaRef(ref) // merges with resolved Pet schema\n * ```\n */\nexport function syncSchemaRef(node: SchemaNode): SchemaNode {\n const ref = ast.narrowSchema(node, 'ref')\n\n if (!ref) return node\n if (!ref.schema) return node\n\n const { kind: _kind, type: _type, name: _name, ref: _ref, schema: _schema, ...overrides } = ref\n\n // Filter out undefined override values so they don't shadow the resolved schema's fields.\n const definedOverrides = Object.fromEntries(Object.entries(overrides).filter(([, v]) => v !== undefined))\n\n return ast.factory.createSchema({ ...ref.schema, ...definedOverrides })\n}\n\n/**\n * Returns `true` when a schema emits as a plain `string` type.\n *\n * Covers `string`, `uuid`, `email`, `url`, and `datetime` types. For `date` and `time`\n * types, returns `true` only when `representation` is `'string'` rather than `'date'`.\n */\nexport function isStringType(node: SchemaNode): boolean {\n if (plainStringTypes.has(node.type)) {\n return true\n }\n\n const temporal = ast.narrowSchema(node, 'date') ?? ast.narrowSchema(node, 'time')\n if (temporal) {\n return temporal.representation !== 'date'\n }\n\n return false\n}\n","import { ast } from '@kubb/ast'\nimport { enumPropName } from '../utils/refs.ts'\n\ntype Props = {\n parentName: string | null | undefined\n propName: string\n enumSuffix: string\n}\n\n/**\n * Builds a macro that names an inline enum schema from its parent and property name. Boolean enums\n * are left anonymous. Non-enum nodes are returned unchanged.\n *\n * @example\n * ```ts\n * const macro = macroEnumName({ parentName: 'Pet', propName: 'status', enumSuffix: 'enum' })\n * const named = applyMacros(propSchema, [macro], { depth: 'shallow' })\n * ```\n */\nexport function macroEnumName({ parentName, propName, enumSuffix }: Props) {\n return ast.defineMacro({\n name: 'enum-name',\n schema(node) {\n const enumNode = ast.narrowSchema(node, 'enum')\n\n if (enumNode?.primitive === 'boolean') return { ...node, name: null }\n if (enumNode) return { ...node, name: enumPropName(parentName, propName, enumSuffix) }\n\n return undefined\n },\n })\n}\n","import { ast } from '@kubb/ast'\n\ntype Props = {\n from: string\n to: string\n}\n\n/**\n * Builds a macro that renames a schema consistently: the declaration (`name`) and every ref\n * pointing at it (`targetName`) change together, so imports and printed references stay in\n * sync. Renaming only one side by hand produces imports for files that are never generated.\n *\n * @example\n * `const macro = macroRenameSchema({ from: 'Order', to: 'StoreOrder' })`\n */\nexport function macroRenameSchema({ from, to }: Props) {\n return ast.defineMacro({\n name: 'rename-schema',\n schema(node) {\n const refNode = ast.narrowSchema(node, 'ref')\n\n if (!refNode) {\n return node.name === from ? { ...node, name: to } : undefined\n }\n\n const renamesDeclaration = refNode.name === from\n const renamesTarget = ast.resolveRefName(refNode) === from\n if (!renamesDeclaration && !renamesTarget) return undefined\n\n return {\n ...refNode,\n ...(renamesDeclaration ? { name: to } : {}),\n ...(renamesTarget ? { targetName: to } : {}),\n }\n },\n })\n}\n","import { ast } from '@kubb/ast'\nimport type { SchemaNode } from '@kubb/ast'\n\ntype ScalarPrimitive = 'string' | 'number' | 'integer' | 'bigint' | 'boolean'\n\n/**\n * Scalar primitive schema types used for union simplification and type narrowing.\n */\nconst SCALAR_PRIMITIVE_TYPES = new Set<ScalarPrimitive>(['string', 'number', 'integer', 'bigint', 'boolean'])\n\nfunction isScalarPrimitive(type: string): type is ScalarPrimitive {\n return SCALAR_PRIMITIVE_TYPES.has(type as ScalarPrimitive)\n}\n\n/**\n * Filters union members, dropping enum members that a broader scalar primitive already covers.\n */\nfunction simplifyUnionMembers(members: Array<SchemaNode>): Array<SchemaNode> {\n const scalarPrimitives = new Set(members.filter((member) => isScalarPrimitive(member.type)).map((m) => m.type))\n if (!scalarPrimitives.size) return members\n\n return members.filter((member) => {\n const enumNode = ast.narrowSchema(member, 'enum')\n if (!enumNode) return true\n\n const primitive = enumNode.primitive\n if (!primitive) return true\n\n const enumValueCount = enumNode.namedEnumValues?.length ?? enumNode.enumValues?.length ?? 0\n if (enumValueCount <= 1) return true\n\n if (scalarPrimitives.has(primitive)) return false\n if ((primitive === 'integer' || primitive === 'number') && (scalarPrimitives.has('integer') || scalarPrimitives.has('number'))) return false\n\n return true\n })\n}\n\n/**\n * Removes union members a broader scalar primitive already covers, such as a multi-value string enum\n * sitting next to a plain `string`. Single-value enums are kept.\n *\n * @example\n * ```ts\n * const next = applyMacros(unionSchema, [macroSimplifyUnion], { depth: 'shallow' })\n * ```\n */\nexport const macroSimplifyUnion = ast.defineMacro({\n name: 'simplify-union',\n schema(node) {\n const unionNode = ast.narrowSchema(node, 'union')\n if (!unionNode?.members?.length) return undefined\n\n const simplified = simplifyUnionMembers(unionNode.members)\n if (simplified.length === unionNode.members.length) return undefined\n\n return { ...unionNode, members: simplified }\n },\n})\n","import { ast } from '@kubb/ast'\nimport type { SchemaNode } from '@kubb/ast'\n\n/**\n * Merges a run of adjacent anonymous object members into one. Named or non-object members break the\n * run and pass through unchanged. The merge follows member order, so callers control which members\n * combine by where they place them in the sequence.\n *\n * @example\n * ```ts\n * const merged = [...mergeAdjacentObjectsLazy([objectA, objectB])]\n * ```\n */\nexport function* mergeAdjacentObjectsLazy(members: Iterable<SchemaNode>): Generator<SchemaNode, void, undefined> {\n let acc: SchemaNode | undefined\n\n for (const member of members) {\n const objectMember = ast.narrowSchema(member, 'object')\n if (objectMember && !objectMember.name && acc !== undefined) {\n const accObject = ast.narrowSchema(acc, 'object')\n if (accObject && !accObject.name) {\n acc = ast.factory.createSchema({\n ...accObject,\n properties: [...(accObject.properties ?? []), ...(objectMember.properties ?? [])],\n })\n continue\n }\n }\n if (acc !== undefined) yield acc\n acc = member\n }\n\n if (acc !== undefined) yield acc\n}\n","import { ast } from '@kubb/ast'\nimport type { SchemaNode } from '@kubb/ast'\n\n/**\n * Returns `true` when a schema, or anything nested inside it, references a circular schema.\n *\n * Pass `excludeName` to skip refs to a specific schema, which helps when self-references are handled\n * on their own. Pair it with `ast.findCircularSchemas()` to decide where lazy wrappers go.\n *\n * @note Stops at the first matching circular ref.\n */\nexport function containsCircularRef(\n node: SchemaNode | undefined,\n { circularSchemas, excludeName }: { circularSchemas: ReadonlySet<string>; excludeName?: string },\n): boolean {\n if (!node || circularSchemas.size === 0) return false\n\n for (const _ of ast.collect<true>(node, {\n schema(child) {\n if (child.type !== 'ref') return null\n const name = ast.resolveRefName(child)\n return name && name !== excludeName && circularSchemas.has(name) ? true : null\n },\n })) {\n return true\n }\n\n return false\n}\n"],"mappings":";;;;;;;;;;;;AAkBA,SAAS,gBAAgB,MAAc,QAAyB;CAC9D,OAAO,KACJ,KAAK,CAAC,CACN,QAAQ,qBAAqB,OAAO,CAAC,CACrC,QAAQ,yBAAyB,OAAO,CAAC,CACzC,QAAQ,gBAAgB,OAAO,CAAC,CAChC,MAAM,eAAe,CAAC,CACtB,OAAO,OAAO,CAAC,CACf,KAAK,MAAM,MAAM;EAChB,IAAI,KAAK,SAAS,KAAK,SAAS,KAAK,YAAY,GAAG,OAAO;EAE3D,QADa,MAAM,KAAK,CAAC,SAAS,KAAK,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,YAAY,KAC9E,KAAK,MAAM,CAAC;CAC5B,CAAC,CAAC,CACD,KAAK,EAAE,CAAC,CACR,QAAQ,iBAAiB,EAAE;AAChC;;;;;;;;;;AAWA,SAAgB,UAAU,MAAc,EAAE,SAAS,IAAI,SAAS,OAAgB,CAAC,GAAW;CAC1F,OAAO,gBAAgB,GAAG,OAAO,GAAG,KAAK,GAAG,UAAU,KAAK;AAC7D;;;;;;;;;;AAWA,SAAgB,WAAW,MAAc,EAAE,SAAS,IAAI,SAAS,OAAgB,CAAC,GAAW;CAC3F,OAAO,gBAAgB,GAAG,OAAO,GAAG,KAAK,GAAG,UAAU,IAAI;AAC5D;;;;;;;ACvDA,MAAM,gCAAgB,IAAI,IAAI;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;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AC;;;;;;;;;;;;;AC7CD,UAAiB,yBAAyB,SAAuE;CAC/G,IAAI;CAEJ,KAAK,MAAM,UAAU,SAAS;EAC5B,MAAM,eAAeC,UAAAA,IAAI,aAAa,QAAQ,QAAQ;EACtD,IAAI,gBAAgB,CAAC,aAAa,QAAQ,QAAQ,KAAA,GAAW;GAC3D,MAAM,YAAYA,UAAAA,IAAI,aAAa,KAAK,QAAQ;GAChD,IAAI,aAAa,CAAC,UAAU,MAAM;IAChC,MAAMA,UAAAA,IAAI,QAAQ,aAAa;KAC7B,GAAG;KACH,YAAY,CAAC,GAAI,UAAU,cAAc,CAAC,GAAI,GAAI,aAAa,cAAc,CAAC,CAAE;IAClF,CAAC;IACD;GACF;EACF;EACA,IAAI,QAAQ,KAAA,GAAW,MAAM;EAC7B,MAAM;CACR;CAEA,IAAI,QAAQ,KAAA,GAAW,MAAM;AAC/B;;;;;;;;;;;ACtBA,SAAgB,oBACd,MACA,EAAE,iBAAiB,eACV;CACT,IAAI,CAAC,QAAQ,gBAAgB,SAAS,GAAG,OAAO;CAEhD,KAAK,MAAM,KAAKC,UAAAA,IAAI,QAAc,MAAM,EACtC,OAAO,OAAO;EACZ,IAAI,MAAM,SAAS,OAAO,OAAO;EACjC,MAAM,OAAOA,UAAAA,IAAI,eAAe,KAAK;EACrC,OAAO,QAAQ,SAAS,eAAe,gBAAgB,IAAI,IAAI,IAAI,OAAO;CAC5E,EACF,CAAC,GACC,OAAO;CAGT,OAAO;AACT"}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
2
- import { ast } from "@kubb/ast";
3
- import { Adapter, AdapterFactoryOptions, AdapterSource, BannerMeta, Config, Diagnostics, Exclude, Generator, GeneratorContext, Group, Hookable, Include, KubbHooks, KubbPluginEndContext, KubbPluginSetupContext, KubbPluginStartContext, Output, OutputOptions, Override, Parser, Plugin, PluginFactoryOptions, Renderer, RendererFactory, ResolveFileOptions, ResolveImportsOptions, ResolvePathOptions, Resolver, ResolverFile, ResolverFileParams, ResolverFilePathParams, ResolverPatch, Storage, createAdapter, createRenderer, createResolver, createStorage, defineGenerator, defineParser, definePlugin, fsStorage, memoryStorage } from "@kubb/core";
2
+ import { SchemaNode, ast, ast as ast$1 } from "@kubb/ast";
3
+ import { Adapter, AdapterFactoryOptions, AdapterSource, BannerMeta, Config, Diagnostics, Exclude, Generator as Generator$1, GeneratorContext, Group, Hookable, Include, KubbHooks, KubbPluginEndContext, KubbPluginSetupContext, KubbPluginStartContext, NodeCache, Output, OutputOptions, Override, Parser, Plugin, PluginFactoryOptions, Renderer, RendererFactory, ResolveFileOptions, ResolveImportsOptions, ResolvePathOptions, Resolver, ResolverFile, ResolverFileParams, ResolverFilePathParams, ResolverPatch, Storage, createAdapter, createRenderer, createResolver, createStorage, defineGenerator, defineParser, definePlugin, fsStorage, memoryStorage } from "@kubb/core";
4
4
  //#region ../../internals/utils/src/Url.d.ts
5
5
  type URLObject = {
6
6
  /**
@@ -46,6 +46,9 @@ declare class Url {
46
46
  *
47
47
  * @example
48
48
  * Url.toPath('/pet/{petId}') // '/pet/:petId'
49
+ *
50
+ * @example
51
+ * Url.toPath('/point/{point-id}') // '/point/:pointId'
49
52
  */
50
53
  static toPath(path: string): string;
51
54
  /**
@@ -86,5 +89,145 @@ declare class Url {
86
89
  static toObject(path: string, { type, replacer, stringify }?: ObjectOptions): URLObject | string;
87
90
  }
88
91
  //#endregion
89
- export { type Adapter, type AdapterFactoryOptions, type AdapterSource, type BannerMeta, type Config, Diagnostics, type Exclude, type Generator, type GeneratorContext, type Group, Hookable, type Include, type KubbHooks, type KubbPluginEndContext, type KubbPluginSetupContext, type KubbPluginStartContext, type Output, type OutputOptions, type Override, type Parser, type Plugin, type PluginFactoryOptions, type Renderer, type RendererFactory, type ResolveFileOptions, type ResolveImportsOptions, type ResolvePathOptions, Resolver, type ResolverFile, type ResolverFileParams, type ResolverFilePathParams, type ResolverPatch, type Storage, Url, ast, createAdapter, createRenderer, createResolver, createStorage, defineGenerator, defineParser, definePlugin, fsStorage, memoryStorage };
92
+ //#region src/macros/macroDiscriminatorEnum.d.ts
93
+ type Props$2 = {
94
+ propertyName: string;
95
+ values: Array<string>;
96
+ enumName?: string;
97
+ };
98
+ /**
99
+ * Builds a macro that replaces a discriminator property's schema with a string enum of the given
100
+ * values. Object schemas that lack the property are returned unchanged.
101
+ *
102
+ * @example
103
+ * ```ts
104
+ * const macro = macroDiscriminatorEnum({ propertyName: 'type', values: ['dog', 'cat'] })
105
+ * const next = applyMacros(objectSchema, [macro], { depth: 'shallow' })
106
+ * ```
107
+ */
108
+ declare function macroDiscriminatorEnum({ propertyName, values, enumName }: Props$2): ast$1.Macro;
109
+ //#endregion
110
+ //#region src/macros/macroEnumName.d.ts
111
+ type Props$1 = {
112
+ parentName: string | null | undefined;
113
+ propName: string;
114
+ enumSuffix: string;
115
+ };
116
+ /**
117
+ * Builds a macro that names an inline enum schema from its parent and property name. Boolean enums
118
+ * are left anonymous. Non-enum nodes are returned unchanged.
119
+ *
120
+ * @example
121
+ * ```ts
122
+ * const macro = macroEnumName({ parentName: 'Pet', propName: 'status', enumSuffix: 'enum' })
123
+ * const named = applyMacros(propSchema, [macro], { depth: 'shallow' })
124
+ * ```
125
+ */
126
+ declare function macroEnumName({ parentName, propName, enumSuffix }: Props$1): ast$1.Macro;
127
+ //#endregion
128
+ //#region src/macros/macroRenameSchema.d.ts
129
+ type Props = {
130
+ from: string;
131
+ to: string;
132
+ };
133
+ /**
134
+ * Builds a macro that renames a schema consistently: the declaration (`name`) and every ref
135
+ * pointing at it (`targetName`) change together, so imports and printed references stay in
136
+ * sync. Renaming only one side by hand produces imports for files that are never generated.
137
+ *
138
+ * @example
139
+ * `const macro = macroRenameSchema({ from: 'Order', to: 'StoreOrder' })`
140
+ */
141
+ declare function macroRenameSchema({ from, to }: Props): ast$1.Macro;
142
+ //#endregion
143
+ //#region src/macros/macroSimplifyUnion.d.ts
144
+ /**
145
+ * Removes union members a broader scalar primitive already covers, such as a multi-value string enum
146
+ * sitting next to a plain `string`. Single-value enums are kept.
147
+ *
148
+ * @example
149
+ * ```ts
150
+ * const next = applyMacros(unionSchema, [macroSimplifyUnion], { depth: 'shallow' })
151
+ * ```
152
+ */
153
+ declare const macroSimplifyUnion: ast$1.Macro;
154
+ //#endregion
155
+ //#region src/utils/mergeAdjacentSchemas.d.ts
156
+ /**
157
+ * Merges a run of adjacent anonymous object members into one. Named or non-object members break the
158
+ * run and pass through unchanged. The merge follows member order, so callers control which members
159
+ * combine by where they place them in the sequence.
160
+ *
161
+ * @example
162
+ * ```ts
163
+ * const merged = [...mergeAdjacentObjectsLazy([objectA, objectB])]
164
+ * ```
165
+ */
166
+ declare function mergeAdjacentObjectsLazy(members: Iterable<SchemaNode>): Generator<SchemaNode, void, undefined>;
167
+ //#endregion
168
+ //#region src/utils/refs.d.ts
169
+ /**
170
+ * Returns the last path segment of a reference string.
171
+ *
172
+ * @example
173
+ * `extractRefName('#/components/schemas/Pet') // 'Pet'`
174
+ */
175
+ declare function extractRefName(ref: string): string;
176
+ /**
177
+ * Builds a PascalCase child schema name by joining a parent name and property name.
178
+ * Returns `null` when there is no parent to nest under.
179
+ *
180
+ * @example Nested under a parent
181
+ * `childName('Order', 'shipping_address') // 'OrderShippingAddress'`
182
+ *
183
+ * @example No parent
184
+ * `childName(undefined, 'params') // null`
185
+ */
186
+ declare function childName(parentName: string | null | undefined, propName: string): string | null;
187
+ /**
188
+ * Builds a PascalCase enum name from the parent name, property name, and a suffix, skipping any
189
+ * empty parts.
190
+ *
191
+ * @example
192
+ * `enumPropName('Order', 'status', 'enum') // 'OrderStatusEnum'`
193
+ */
194
+ declare function enumPropName(parentName: string | null | undefined, propName: string, enumSuffix: string): string;
195
+ /**
196
+ * Merges a ref node with its resolved schema, giving usage-site fields precedence.
197
+ *
198
+ * Every field set on the ref node except `kind`, `type`, `name`, `ref`, and `schema` overrides the
199
+ * same field in the resolved `node.schema` (for example `description`, `nullable`, `readOnly`,
200
+ * `deprecated`). Fields left `undefined` on the ref do not shadow the resolved schema. Non-ref
201
+ * nodes and refs without a resolved `schema` are returned unchanged.
202
+ *
203
+ * @example
204
+ * ```ts
205
+ * const ref = ast.factory.createSchema({ type: 'ref', ref: '#/components/schemas/Pet', description: 'A cute pet' })
206
+ * const merged = syncSchemaRef(ref) // merges with resolved Pet schema
207
+ * ```
208
+ */
209
+ declare function syncSchemaRef(node: SchemaNode): SchemaNode;
210
+ /**
211
+ * Returns `true` when a schema emits as a plain `string` type.
212
+ *
213
+ * Covers `string`, `uuid`, `email`, `url`, and `datetime` types. For `date` and `time`
214
+ * types, returns `true` only when `representation` is `'string'` rather than `'date'`.
215
+ */
216
+ declare function isStringType(node: SchemaNode): boolean;
217
+ //#endregion
218
+ //#region src/utils/schemaGraph.d.ts
219
+ /**
220
+ * Returns `true` when a schema, or anything nested inside it, references a circular schema.
221
+ *
222
+ * Pass `excludeName` to skip refs to a specific schema, which helps when self-references are handled
223
+ * on their own. Pair it with `ast.findCircularSchemas()` to decide where lazy wrappers go.
224
+ *
225
+ * @note Stops at the first matching circular ref.
226
+ */
227
+ declare function containsCircularRef(node: SchemaNode | undefined, { circularSchemas, excludeName }: {
228
+ circularSchemas: ReadonlySet<string>;
229
+ excludeName?: string;
230
+ }): boolean;
231
+ //#endregion
232
+ export { type Adapter, type AdapterFactoryOptions, type AdapterSource, type BannerMeta, type Config, Diagnostics, type Exclude, type Generator$1 as Generator, type GeneratorContext, type Group, Hookable, type Include, type KubbHooks, type KubbPluginEndContext, type KubbPluginSetupContext, type KubbPluginStartContext, type NodeCache, type Output, type OutputOptions, type Override, type Parser, type Plugin, type PluginFactoryOptions, type Renderer, type RendererFactory, type ResolveFileOptions, type ResolveImportsOptions, type ResolvePathOptions, Resolver, type ResolverFile, type ResolverFileParams, type ResolverFilePathParams, type ResolverPatch, type Storage, Url, ast, childName, containsCircularRef, createAdapter, createRenderer, createResolver, createStorage, defineGenerator, defineParser, definePlugin, enumPropName, extractRefName, fsStorage, isStringType, macroDiscriminatorEnum, macroEnumName, macroRenameSchema, macroSimplifyUnion, memoryStorage, mergeAdjacentObjectsLazy, syncSchemaRef };
90
233
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./rolldown-runtime-C0LytTxp.js";
2
- import { ast } from "@kubb/ast";
2
+ import { ast, ast as ast$1 } from "@kubb/ast";
3
3
  import { Diagnostics, Hookable, Resolver, createAdapter, createRenderer, createResolver, createStorage, defineGenerator, defineParser, definePlugin, fsStorage, memoryStorage } from "@kubb/core";
4
4
  //#region ../../internals/utils/src/casing.ts
5
5
  /**
@@ -27,6 +27,18 @@ function toCamelOrPascal(text, pascal) {
27
27
  function camelCase(text, { prefix = "", suffix = "" } = {}) {
28
28
  return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
29
29
  }
30
+ /**
31
+ * Converts `text` to PascalCase.
32
+ *
33
+ * @example Word boundaries
34
+ * `pascalCase('hello-world') // 'HelloWorld'`
35
+ *
36
+ * @example With a suffix
37
+ * `pascalCase('tag', { suffix: 'schema' }) // 'TagSchema'`
38
+ */
39
+ function pascalCase(text, { prefix = "", suffix = "" } = {}) {
40
+ return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true);
41
+ }
30
42
  //#endregion
31
43
  //#region ../../internals/utils/src/reserved.ts
32
44
  /**
@@ -176,9 +188,12 @@ var Url = class Url {
176
188
  *
177
189
  * @example
178
190
  * Url.toPath('/pet/{petId}') // '/pet/:petId'
191
+ *
192
+ * @example
193
+ * Url.toPath('/point/{point-id}') // '/point/:pointId'
179
194
  */
180
195
  static toPath(path) {
181
- return path.replace(/\{([^}]+)\}/g, ":$1");
196
+ return path.replace(/\{([^}]+)\}/g, (_match, param) => `:${transformParam(param)}`);
182
197
  }
183
198
  /**
184
199
  * Converts an OpenAPI/Swagger path to a TypeScript template literal string.
@@ -237,6 +252,289 @@ var Url = class Url {
237
252
  }
238
253
  };
239
254
  //#endregion
240
- export { Diagnostics, Hookable, Resolver, Url, ast, createAdapter, createRenderer, createResolver, createStorage, defineGenerator, defineParser, definePlugin, fsStorage, memoryStorage };
255
+ //#region src/macros/macroDiscriminatorEnum.ts
256
+ /**
257
+ * Builds a macro that replaces a discriminator property's schema with a string enum of the given
258
+ * values. Object schemas that lack the property are returned unchanged.
259
+ *
260
+ * @example
261
+ * ```ts
262
+ * const macro = macroDiscriminatorEnum({ propertyName: 'type', values: ['dog', 'cat'] })
263
+ * const next = applyMacros(objectSchema, [macro], { depth: 'shallow' })
264
+ * ```
265
+ */
266
+ function macroDiscriminatorEnum({ propertyName, values, enumName }) {
267
+ return ast$1.defineMacro({
268
+ name: "discriminator-enum",
269
+ schema(node) {
270
+ const objectNode = ast$1.narrowSchema(node, "object");
271
+ if (!objectNode?.properties?.length) return void 0;
272
+ if (!objectNode.properties.some((prop) => prop.name === propertyName)) return void 0;
273
+ return ast$1.factory.createSchema({
274
+ ...objectNode,
275
+ properties: objectNode.properties.map((prop) => {
276
+ if (prop.name !== propertyName) return prop;
277
+ return ast$1.factory.createProperty({
278
+ ...prop,
279
+ schema: ast$1.factory.createSchema({
280
+ type: "enum",
281
+ primitive: "string",
282
+ enumValues: values,
283
+ name: enumName,
284
+ readOnly: prop.schema.readOnly,
285
+ writeOnly: prop.schema.writeOnly
286
+ })
287
+ });
288
+ })
289
+ });
290
+ }
291
+ });
292
+ }
293
+ //#endregion
294
+ //#region src/utils/refs.ts
295
+ const plainStringTypes = /* @__PURE__ */ new Set([
296
+ "string",
297
+ "uuid",
298
+ "email",
299
+ "url",
300
+ "datetime"
301
+ ]);
302
+ /**
303
+ * Returns the last path segment of a reference string.
304
+ *
305
+ * @example
306
+ * `extractRefName('#/components/schemas/Pet') // 'Pet'`
307
+ */
308
+ function extractRefName(ref) {
309
+ return ref.split("/").at(-1) ?? ref;
310
+ }
311
+ /**
312
+ * Builds a PascalCase child schema name by joining a parent name and property name.
313
+ * Returns `null` when there is no parent to nest under.
314
+ *
315
+ * @example Nested under a parent
316
+ * `childName('Order', 'shipping_address') // 'OrderShippingAddress'`
317
+ *
318
+ * @example No parent
319
+ * `childName(undefined, 'params') // null`
320
+ */
321
+ function childName(parentName, propName) {
322
+ return parentName ? pascalCase([parentName, propName].join(" ")) : null;
323
+ }
324
+ /**
325
+ * Builds a PascalCase enum name from the parent name, property name, and a suffix, skipping any
326
+ * empty parts.
327
+ *
328
+ * @example
329
+ * `enumPropName('Order', 'status', 'enum') // 'OrderStatusEnum'`
330
+ */
331
+ function enumPropName(parentName, propName, enumSuffix) {
332
+ return pascalCase([
333
+ parentName,
334
+ propName,
335
+ enumSuffix
336
+ ].filter(Boolean).join(" "));
337
+ }
338
+ /**
339
+ * Merges a ref node with its resolved schema, giving usage-site fields precedence.
340
+ *
341
+ * Every field set on the ref node except `kind`, `type`, `name`, `ref`, and `schema` overrides the
342
+ * same field in the resolved `node.schema` (for example `description`, `nullable`, `readOnly`,
343
+ * `deprecated`). Fields left `undefined` on the ref do not shadow the resolved schema. Non-ref
344
+ * nodes and refs without a resolved `schema` are returned unchanged.
345
+ *
346
+ * @example
347
+ * ```ts
348
+ * const ref = ast.factory.createSchema({ type: 'ref', ref: '#/components/schemas/Pet', description: 'A cute pet' })
349
+ * const merged = syncSchemaRef(ref) // merges with resolved Pet schema
350
+ * ```
351
+ */
352
+ function syncSchemaRef(node) {
353
+ const ref = ast$1.narrowSchema(node, "ref");
354
+ if (!ref) return node;
355
+ if (!ref.schema) return node;
356
+ const { kind: _kind, type: _type, name: _name, ref: _ref, schema: _schema, ...overrides } = ref;
357
+ const definedOverrides = Object.fromEntries(Object.entries(overrides).filter(([, v]) => v !== void 0));
358
+ return ast$1.factory.createSchema({
359
+ ...ref.schema,
360
+ ...definedOverrides
361
+ });
362
+ }
363
+ /**
364
+ * Returns `true` when a schema emits as a plain `string` type.
365
+ *
366
+ * Covers `string`, `uuid`, `email`, `url`, and `datetime` types. For `date` and `time`
367
+ * types, returns `true` only when `representation` is `'string'` rather than `'date'`.
368
+ */
369
+ function isStringType(node) {
370
+ if (plainStringTypes.has(node.type)) return true;
371
+ const temporal = ast$1.narrowSchema(node, "date") ?? ast$1.narrowSchema(node, "time");
372
+ if (temporal) return temporal.representation !== "date";
373
+ return false;
374
+ }
375
+ //#endregion
376
+ //#region src/macros/macroEnumName.ts
377
+ /**
378
+ * Builds a macro that names an inline enum schema from its parent and property name. Boolean enums
379
+ * are left anonymous. Non-enum nodes are returned unchanged.
380
+ *
381
+ * @example
382
+ * ```ts
383
+ * const macro = macroEnumName({ parentName: 'Pet', propName: 'status', enumSuffix: 'enum' })
384
+ * const named = applyMacros(propSchema, [macro], { depth: 'shallow' })
385
+ * ```
386
+ */
387
+ function macroEnumName({ parentName, propName, enumSuffix }) {
388
+ return ast$1.defineMacro({
389
+ name: "enum-name",
390
+ schema(node) {
391
+ const enumNode = ast$1.narrowSchema(node, "enum");
392
+ if (enumNode?.primitive === "boolean") return {
393
+ ...node,
394
+ name: null
395
+ };
396
+ if (enumNode) return {
397
+ ...node,
398
+ name: enumPropName(parentName, propName, enumSuffix)
399
+ };
400
+ }
401
+ });
402
+ }
403
+ //#endregion
404
+ //#region src/macros/macroRenameSchema.ts
405
+ /**
406
+ * Builds a macro that renames a schema consistently: the declaration (`name`) and every ref
407
+ * pointing at it (`targetName`) change together, so imports and printed references stay in
408
+ * sync. Renaming only one side by hand produces imports for files that are never generated.
409
+ *
410
+ * @example
411
+ * `const macro = macroRenameSchema({ from: 'Order', to: 'StoreOrder' })`
412
+ */
413
+ function macroRenameSchema({ from, to }) {
414
+ return ast$1.defineMacro({
415
+ name: "rename-schema",
416
+ schema(node) {
417
+ const refNode = ast$1.narrowSchema(node, "ref");
418
+ if (!refNode) return node.name === from ? {
419
+ ...node,
420
+ name: to
421
+ } : void 0;
422
+ const renamesDeclaration = refNode.name === from;
423
+ const renamesTarget = ast$1.resolveRefName(refNode) === from;
424
+ if (!renamesDeclaration && !renamesTarget) return void 0;
425
+ return {
426
+ ...refNode,
427
+ ...renamesDeclaration ? { name: to } : {},
428
+ ...renamesTarget ? { targetName: to } : {}
429
+ };
430
+ }
431
+ });
432
+ }
433
+ //#endregion
434
+ //#region src/macros/macroSimplifyUnion.ts
435
+ /**
436
+ * Scalar primitive schema types used for union simplification and type narrowing.
437
+ */
438
+ const SCALAR_PRIMITIVE_TYPES = /* @__PURE__ */ new Set([
439
+ "string",
440
+ "number",
441
+ "integer",
442
+ "bigint",
443
+ "boolean"
444
+ ]);
445
+ function isScalarPrimitive(type) {
446
+ return SCALAR_PRIMITIVE_TYPES.has(type);
447
+ }
448
+ /**
449
+ * Filters union members, dropping enum members that a broader scalar primitive already covers.
450
+ */
451
+ function simplifyUnionMembers(members) {
452
+ const scalarPrimitives = new Set(members.filter((member) => isScalarPrimitive(member.type)).map((m) => m.type));
453
+ if (!scalarPrimitives.size) return members;
454
+ return members.filter((member) => {
455
+ const enumNode = ast$1.narrowSchema(member, "enum");
456
+ if (!enumNode) return true;
457
+ const primitive = enumNode.primitive;
458
+ if (!primitive) return true;
459
+ if ((enumNode.namedEnumValues?.length ?? enumNode.enumValues?.length ?? 0) <= 1) return true;
460
+ if (scalarPrimitives.has(primitive)) return false;
461
+ if ((primitive === "integer" || primitive === "number") && (scalarPrimitives.has("integer") || scalarPrimitives.has("number"))) return false;
462
+ return true;
463
+ });
464
+ }
465
+ /**
466
+ * Removes union members a broader scalar primitive already covers, such as a multi-value string enum
467
+ * sitting next to a plain `string`. Single-value enums are kept.
468
+ *
469
+ * @example
470
+ * ```ts
471
+ * const next = applyMacros(unionSchema, [macroSimplifyUnion], { depth: 'shallow' })
472
+ * ```
473
+ */
474
+ const macroSimplifyUnion = ast$1.defineMacro({
475
+ name: "simplify-union",
476
+ schema(node) {
477
+ const unionNode = ast$1.narrowSchema(node, "union");
478
+ if (!unionNode?.members?.length) return void 0;
479
+ const simplified = simplifyUnionMembers(unionNode.members);
480
+ if (simplified.length === unionNode.members.length) return void 0;
481
+ return {
482
+ ...unionNode,
483
+ members: simplified
484
+ };
485
+ }
486
+ });
487
+ //#endregion
488
+ //#region src/utils/mergeAdjacentSchemas.ts
489
+ /**
490
+ * Merges a run of adjacent anonymous object members into one. Named or non-object members break the
491
+ * run and pass through unchanged. The merge follows member order, so callers control which members
492
+ * combine by where they place them in the sequence.
493
+ *
494
+ * @example
495
+ * ```ts
496
+ * const merged = [...mergeAdjacentObjectsLazy([objectA, objectB])]
497
+ * ```
498
+ */
499
+ function* mergeAdjacentObjectsLazy(members) {
500
+ let acc;
501
+ for (const member of members) {
502
+ const objectMember = ast$1.narrowSchema(member, "object");
503
+ if (objectMember && !objectMember.name && acc !== void 0) {
504
+ const accObject = ast$1.narrowSchema(acc, "object");
505
+ if (accObject && !accObject.name) {
506
+ acc = ast$1.factory.createSchema({
507
+ ...accObject,
508
+ properties: [...accObject.properties ?? [], ...objectMember.properties ?? []]
509
+ });
510
+ continue;
511
+ }
512
+ }
513
+ if (acc !== void 0) yield acc;
514
+ acc = member;
515
+ }
516
+ if (acc !== void 0) yield acc;
517
+ }
518
+ //#endregion
519
+ //#region src/utils/schemaGraph.ts
520
+ /**
521
+ * Returns `true` when a schema, or anything nested inside it, references a circular schema.
522
+ *
523
+ * Pass `excludeName` to skip refs to a specific schema, which helps when self-references are handled
524
+ * on their own. Pair it with `ast.findCircularSchemas()` to decide where lazy wrappers go.
525
+ *
526
+ * @note Stops at the first matching circular ref.
527
+ */
528
+ function containsCircularRef(node, { circularSchemas, excludeName }) {
529
+ if (!node || circularSchemas.size === 0) return false;
530
+ for (const _ of ast$1.collect(node, { schema(child) {
531
+ if (child.type !== "ref") return null;
532
+ const name = ast$1.resolveRefName(child);
533
+ return name && name !== excludeName && circularSchemas.has(name) ? true : null;
534
+ } })) return true;
535
+ return false;
536
+ }
537
+ //#endregion
538
+ export { Diagnostics, Hookable, Resolver, Url, ast, childName, containsCircularRef, createAdapter, createRenderer, createResolver, createStorage, defineGenerator, defineParser, definePlugin, enumPropName, extractRefName, fsStorage, isStringType, macroDiscriminatorEnum, macroEnumName, macroRenameSchema, macroSimplifyUnion, memoryStorage, mergeAdjacentObjectsLazy, syncSchemaRef };
241
539
 
242
540
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../internals/utils/src/casing.ts","../../../internals/utils/src/reserved.ts","../../../internals/utils/src/Url.ts"],"sourcesContent":["type Options = {\n /**\n * Text prepended before casing is applied.\n */\n prefix?: string\n /**\n * Text appended before casing is applied.\n */\n suffix?: string\n}\n\n/**\n * Shared implementation for camelCase and PascalCase conversion.\n * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)\n * and capitalizes each word according to `pascal`.\n *\n * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.\n */\nfunction toCamelOrPascal(text: string, pascal: boolean): string {\n return text\n .trim()\n .replace(/([a-z\\d])([A-Z])/g, '$1 $2')\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')\n .replace(/(\\d)([a-z])/g, '$1 $2')\n .split(/[\\s\\-_./\\\\:]+/)\n .filter(Boolean)\n .map((word, i) => {\n if (word.length > 1 && word === word.toUpperCase()) return word\n const head = i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()\n return head + word.slice(1)\n })\n .join('')\n .replace(/[^a-zA-Z0-9]/g, '')\n}\n\n/**\n * Converts `text` to camelCase.\n *\n * @example Word boundaries\n * `camelCase('hello-world') // 'helloWorld'`\n *\n * @example With a prefix\n * `camelCase('tag', { prefix: 'create' }) // 'createTag'`\n */\nexport function camelCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false)\n}\n\n/**\n * Converts `text` to PascalCase.\n *\n * @example Word boundaries\n * `pascalCase('hello-world') // 'HelloWorld'`\n *\n * @example With a suffix\n * `pascalCase('tag', { suffix: 'schema' }) // 'TagSchema'`\n */\nexport function pascalCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true)\n}\n","/**\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 * 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 if (!name || reservedWords.has(name as 'valueOf')) {\n return false\n }\n return isIdentifier(name)\n}\n\n/**\n * Returns `true` when `name` is syntactically a valid identifier, ignoring reserved words.\n *\n * Reserved words and globals (`class`, `name`, `Date`, …) are valid as bare object-literal keys\n * even though they are not valid variable names, so use this (not {@link isValidVarName}) when\n * deciding whether an object key needs quoting.\n *\n * @example\n * ```ts\n * isIdentifier('name') // true\n * isIdentifier('x-total')// false\n * ```\n */\nexport function isIdentifier(name: string): boolean {\n return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name)\n}\n","import { camelCase } from './casing.ts'\nimport { isValidVarName } from './reserved.ts'\n\ntype 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 `null` when the path has none.\n */\n params: Record<string, string> | null\n}\n\ntype TemplateOptions = {\n /**\n * Literal text prepended inside the template literal, e.g. a base URL.\n */\n prefix?: string | null\n /**\n * Transform applied to each extracted parameter name before interpolation.\n */\n replacer?: (pathParam: 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 * 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\nfunction transformParam(raw: string): string {\n return isValidVarName(raw) ? raw : camelCase(raw)\n}\n\n/**\n * Renders how a grouped `path` object's member is accessed: dot access for a valid\n * identifier, bracket access with the raw name otherwise.\n */\nfunction groupedAccessor(name: string): string {\n return isValidVarName(name) ? `.${name}` : `[${JSON.stringify(name)}]`\n}\n\nfunction toParamsObject(path: string, { replacer }: { replacer?: (pathParam: string) => string } = {}): Record<string, string> | null {\n const params: Record<string, string> = {}\n\n for (const match of path.matchAll(/\\{([^}]+)\\}/g)) {\n const param = transformParam(match[1]!)\n const key = replacer ? replacer(param) : param\n params[key] = key\n }\n\n return Object.keys(params).length > 0 ? params : null\n}\n\n/**\n * Helpers for OpenAPI/Swagger paths, plus a thin wrapper over the native `URL`.\n */\nexport class Url {\n /**\n * Converts an OpenAPI/Swagger path to Express-style colon syntax.\n *\n * @example\n * Url.toPath('/pet/{petId}') // '/pet/:petId'\n */\n static toPath(path: string): string {\n return path.replace(/\\{([^}]+)\\}/g, ':$1')\n }\n\n /**\n * Converts an OpenAPI/Swagger path to a TypeScript template literal string.\n * `prefix` is prepended inside the literal, and `replacer` transforms each parameter name.\n *\n * @example\n * Url.toTemplateString('/pet/{petId}') // '`/pet/${petId}`'\n *\n * @example\n * Url.toTemplateString('/pet/{petId}', { prefix: 'https://api' }) // '`https://api/pet/${petId}`'\n */\n static toTemplateString(path: string, { prefix, replacer }: TemplateOptions = {}): string {\n const parts = path.split(/\\{([^}]+)\\}/)\n const result = parts\n .map((part, i) => {\n if (i % 2 === 0) return part\n const param = transformParam(part)\n return `\\${${replacer ? replacer(param) : param}}`\n })\n .join('')\n\n return `\\`${prefix ?? ''}${result}\\``\n }\n\n /**\n * Converts an OpenAPI/Swagger path to a template literal that reads each parameter off a\n * grouped `path` request option, e.g. `/pet/{petId}` becomes `` `/pet/${path.petId}` ``.\n * Parameter names are kept exactly as they appear in the OpenAPI path; a name falls back to\n * bracket access (`` path['pet-id'] ``) only when it isn't a valid JS identifier.\n * `prefix` is prepended inside the literal. Shared by generators that pass a grouped `path` object.\n *\n * @example\n * Url.toGroupedTemplateString('/pet/{petId}') // '`/pet/${path.petId}`'\n *\n * @example\n * Url.toGroupedTemplateString('/user/{monetary-account-id}') // '`/user/${path[\"monetary-account-id\"]}`'\n */\n static toGroupedTemplateString(path: string, { prefix }: { prefix?: string | null } = {}): string {\n const parts = path.split(/\\{([^}]+)\\}/)\n const result = parts.map((part, i) => (i % 2 === 0 ? part : `\\${path${groupedAccessor(part)}}`)).join('')\n\n return `\\`${prefix ?? ''}${result}\\``\n }\n\n /**\n * Returns the path and its extracted params as a structured `URLObject`, or as a stringified\n * expression when `stringify` is set.\n *\n * @example\n * Url.toObject('/pet/{petId}')\n * // { url: '/pet/:petId', params: { petId: 'petId' } }\n */\n static toObject(path: string, { type = 'path', replacer, stringify }: ObjectOptions = {}): URLObject | string {\n const object: URLObject = {\n url: type === 'path' ? Url.toPath(path) : Url.toTemplateString(path, { replacer }),\n params: toParamsObject(path, { replacer }),\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"],"mappings":";;;;;;;;;;;AAkBA,SAAS,gBAAgB,MAAc,QAAyB;CAC9D,OAAO,KACJ,KAAK,CAAC,CACN,QAAQ,qBAAqB,OAAO,CAAC,CACrC,QAAQ,yBAAyB,OAAO,CAAC,CACzC,QAAQ,gBAAgB,OAAO,CAAC,CAChC,MAAM,eAAe,CAAC,CACtB,OAAO,OAAO,CAAC,CACf,KAAK,MAAM,MAAM;EAChB,IAAI,KAAK,SAAS,KAAK,SAAS,KAAK,YAAY,GAAG,OAAO;EAE3D,QADa,MAAM,KAAK,CAAC,SAAS,KAAK,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,YAAY,KAC9E,KAAK,MAAM,CAAC;CAC5B,CAAC,CAAC,CACD,KAAK,EAAE,CAAC,CACR,QAAQ,iBAAiB,EAAE;AAChC;;;;;;;;;;AAWA,SAAgB,UAAU,MAAc,EAAE,SAAS,IAAI,SAAS,OAAgB,CAAC,GAAW;CAC1F,OAAO,gBAAgB,GAAG,OAAO,GAAG,KAAK,GAAG,UAAU,KAAK;AAC7D;;;;;;;AC1CA,MAAM,gCAAgB,IAAI,IAAI;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;C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,OAAO;CACpC;;;;;;;;;;;;;;CAeA,OAAO,wBAAwB,MAAc,EAAE,WAAuC,CAAC,GAAW;EAEhG,MAAM,SADQ,KAAK,MAAM,aACN,CAAC,CAAC,KAAK,MAAM,MAAO,IAAI,MAAM,IAAI,OAAO,UAAU,gBAAgB,IAAI,EAAE,EAAG,CAAC,CAAC,KAAK,EAAE;EAExG,OAAO,KAAK,UAAU,KAAK,OAAO;CACpC;;;;;;;;;CAUA,OAAO,SAAS,MAAc,EAAE,OAAO,QAAQ,UAAU,cAA6B,CAAC,GAAuB;EAC5G,MAAM,SAAoB;GACxB,KAAK,SAAS,SAAS,IAAI,OAAO,IAAI,IAAI,IAAI,iBAAiB,MAAM,EAAE,SAAS,CAAC;GACjF,QAAQ,eAAe,MAAM,EAAE,SAAS,CAAC;EAC3C;EAEA,IAAI,WAAW;GACb,IAAI,SAAS,YACX,OAAO,KAAK,UAAU,MAAM,CAAC,CAAC,WAAW,KAAK,EAAE,CAAC,CAAC,WAAW,KAAK,EAAE;GAGtE,IAAI,OAAO,QACT,OAAO,WAAW,OAAO,IAAI,aAAa,KAAK,UAAU,OAAO,MAAM,CAAC,CAAC,WAAW,KAAK,EAAE,CAAC,CAAC,WAAW,KAAK,EAAE,EAAE;GAGlH,OAAO,WAAW,OAAO,IAAI;EAC/B;EAEA,OAAO;CACT;AACF"}
1
+ {"version":3,"file":"index.js","names":["ast","ast","ast","ast","ast","ast","ast"],"sources":["../../../internals/utils/src/casing.ts","../../../internals/utils/src/reserved.ts","../../../internals/utils/src/Url.ts","../src/macros/macroDiscriminatorEnum.ts","../src/utils/refs.ts","../src/macros/macroEnumName.ts","../src/macros/macroRenameSchema.ts","../src/macros/macroSimplifyUnion.ts","../src/utils/mergeAdjacentSchemas.ts","../src/utils/schemaGraph.ts"],"sourcesContent":["type Options = {\n /**\n * Text prepended before casing is applied.\n */\n prefix?: string\n /**\n * Text appended before casing is applied.\n */\n suffix?: string\n}\n\n/**\n * Shared implementation for camelCase and PascalCase conversion.\n * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)\n * and capitalizes each word according to `pascal`.\n *\n * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.\n */\nfunction toCamelOrPascal(text: string, pascal: boolean): string {\n return text\n .trim()\n .replace(/([a-z\\d])([A-Z])/g, '$1 $2')\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')\n .replace(/(\\d)([a-z])/g, '$1 $2')\n .split(/[\\s\\-_./\\\\:]+/)\n .filter(Boolean)\n .map((word, i) => {\n if (word.length > 1 && word === word.toUpperCase()) return word\n const head = i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()\n return head + word.slice(1)\n })\n .join('')\n .replace(/[^a-zA-Z0-9]/g, '')\n}\n\n/**\n * Converts `text` to camelCase.\n *\n * @example Word boundaries\n * `camelCase('hello-world') // 'helloWorld'`\n *\n * @example With a prefix\n * `camelCase('tag', { prefix: 'create' }) // 'createTag'`\n */\nexport function camelCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false)\n}\n\n/**\n * Converts `text` to PascalCase.\n *\n * @example Word boundaries\n * `pascalCase('hello-world') // 'HelloWorld'`\n *\n * @example With a suffix\n * `pascalCase('tag', { suffix: 'schema' }) // 'TagSchema'`\n */\nexport function pascalCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true)\n}\n","/**\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 * 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 if (!name || reservedWords.has(name as 'valueOf')) {\n return false\n }\n return isIdentifier(name)\n}\n\n/**\n * Returns `true` when `name` is syntactically a valid identifier, ignoring reserved words.\n *\n * Reserved words and globals (`class`, `name`, `Date`, …) are valid as bare object-literal keys\n * even though they are not valid variable names, so use this (not {@link isValidVarName}) when\n * deciding whether an object key needs quoting.\n *\n * @example\n * ```ts\n * isIdentifier('name') // true\n * isIdentifier('x-total')// false\n * ```\n */\nexport function isIdentifier(name: string): boolean {\n return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name)\n}\n","import { camelCase } from './casing.ts'\nimport { isValidVarName } from './reserved.ts'\n\ntype 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 `null` when the path has none.\n */\n params: Record<string, string> | null\n}\n\ntype TemplateOptions = {\n /**\n * Literal text prepended inside the template literal, e.g. a base URL.\n */\n prefix?: string | null\n /**\n * Transform applied to each extracted parameter name before interpolation.\n */\n replacer?: (pathParam: 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 * 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\nfunction transformParam(raw: string): string {\n return isValidVarName(raw) ? raw : camelCase(raw)\n}\n\n/**\n * Renders how a grouped `path` object's member is accessed: dot access for a valid\n * identifier, bracket access with the raw name otherwise.\n */\nfunction groupedAccessor(name: string): string {\n return isValidVarName(name) ? `.${name}` : `[${JSON.stringify(name)}]`\n}\n\nfunction toParamsObject(path: string, { replacer }: { replacer?: (pathParam: string) => string } = {}): Record<string, string> | null {\n const params: Record<string, string> = {}\n\n for (const match of path.matchAll(/\\{([^}]+)\\}/g)) {\n const param = transformParam(match[1]!)\n const key = replacer ? replacer(param) : param\n params[key] = key\n }\n\n return Object.keys(params).length > 0 ? params : null\n}\n\n/**\n * Helpers for OpenAPI/Swagger paths, plus a thin wrapper over the native `URL`.\n */\nexport class Url {\n /**\n * Converts an OpenAPI/Swagger path to Express-style colon syntax.\n *\n * @example\n * Url.toPath('/pet/{petId}') // '/pet/:petId'\n *\n * @example\n * Url.toPath('/point/{point-id}') // '/point/:pointId'\n */\n static toPath(path: string): string {\n return path.replace(/\\{([^}]+)\\}/g, (_match, param: string) => `:${transformParam(param)}`)\n }\n\n /**\n * Converts an OpenAPI/Swagger path to a TypeScript template literal string.\n * `prefix` is prepended inside the literal, and `replacer` transforms each parameter name.\n *\n * @example\n * Url.toTemplateString('/pet/{petId}') // '`/pet/${petId}`'\n *\n * @example\n * Url.toTemplateString('/pet/{petId}', { prefix: 'https://api' }) // '`https://api/pet/${petId}`'\n */\n static toTemplateString(path: string, { prefix, replacer }: TemplateOptions = {}): string {\n const parts = path.split(/\\{([^}]+)\\}/)\n const result = parts\n .map((part, i) => {\n if (i % 2 === 0) return part\n const param = transformParam(part)\n return `\\${${replacer ? replacer(param) : param}}`\n })\n .join('')\n\n return `\\`${prefix ?? ''}${result}\\``\n }\n\n /**\n * Converts an OpenAPI/Swagger path to a template literal that reads each parameter off a\n * grouped `path` request option, e.g. `/pet/{petId}` becomes `` `/pet/${path.petId}` ``.\n * Parameter names are kept exactly as they appear in the OpenAPI path; a name falls back to\n * bracket access (`` path['pet-id'] ``) only when it isn't a valid JS identifier.\n * `prefix` is prepended inside the literal. Shared by generators that pass a grouped `path` object.\n *\n * @example\n * Url.toGroupedTemplateString('/pet/{petId}') // '`/pet/${path.petId}`'\n *\n * @example\n * Url.toGroupedTemplateString('/user/{monetary-account-id}') // '`/user/${path[\"monetary-account-id\"]}`'\n */\n static toGroupedTemplateString(path: string, { prefix }: { prefix?: string | null } = {}): string {\n const parts = path.split(/\\{([^}]+)\\}/)\n const result = parts.map((part, i) => (i % 2 === 0 ? part : `\\${path${groupedAccessor(part)}}`)).join('')\n\n return `\\`${prefix ?? ''}${result}\\``\n }\n\n /**\n * Returns the path and its extracted params as a structured `URLObject`, or as a stringified\n * expression when `stringify` is set.\n *\n * @example\n * Url.toObject('/pet/{petId}')\n * // { url: '/pet/:petId', params: { petId: 'petId' } }\n */\n static toObject(path: string, { type = 'path', replacer, stringify }: ObjectOptions = {}): URLObject | string {\n const object: URLObject = {\n url: type === 'path' ? Url.toPath(path) : Url.toTemplateString(path, { replacer }),\n params: toParamsObject(path, { replacer }),\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","import { ast } from '@kubb/ast'\n\ntype Props = {\n propertyName: string\n values: Array<string>\n enumName?: string\n}\n\n/**\n * Builds a macro that replaces a discriminator property's schema with a string enum of the given\n * values. Object schemas that lack the property are returned unchanged.\n *\n * @example\n * ```ts\n * const macro = macroDiscriminatorEnum({ propertyName: 'type', values: ['dog', 'cat'] })\n * const next = applyMacros(objectSchema, [macro], { depth: 'shallow' })\n * ```\n */\nexport function macroDiscriminatorEnum({ propertyName, values, enumName }: Props) {\n return ast.defineMacro({\n name: 'discriminator-enum',\n schema(node) {\n const objectNode = ast.narrowSchema(node, 'object')\n if (!objectNode?.properties?.length) return undefined\n if (!objectNode.properties.some((prop) => prop.name === propertyName)) return undefined\n\n return ast.factory.createSchema({\n ...objectNode,\n properties: objectNode.properties.map((prop) => {\n if (prop.name !== propertyName) return prop\n\n return ast.factory.createProperty({\n ...prop,\n schema: ast.factory.createSchema({\n type: 'enum',\n primitive: 'string',\n enumValues: values,\n name: enumName,\n readOnly: prop.schema.readOnly,\n writeOnly: prop.schema.writeOnly,\n }),\n })\n }),\n })\n },\n })\n}\n","import { ast } from '@kubb/ast'\nimport type { SchemaNode, SchemaType } from '@kubb/ast'\nimport { pascalCase } from '@internals/utils'\n\nconst plainStringTypes = new Set<SchemaType>(['string', 'uuid', 'email', 'url', 'datetime'] as const)\n\n/**\n * Returns the last path segment of a reference string.\n *\n * @example\n * `extractRefName('#/components/schemas/Pet') // 'Pet'`\n */\nexport function extractRefName(ref: string): string {\n return ref.split('/').at(-1) ?? ref\n}\n\n/**\n * Builds a PascalCase child schema name by joining a parent name and property name.\n * Returns `null` when there is no parent to nest under.\n *\n * @example Nested under a parent\n * `childName('Order', 'shipping_address') // 'OrderShippingAddress'`\n *\n * @example No parent\n * `childName(undefined, 'params') // null`\n */\nexport function childName(parentName: string | null | undefined, propName: string): string | null {\n return parentName ? pascalCase([parentName, propName].join(' ')) : null\n}\n\n/**\n * Builds a PascalCase enum name from the parent name, property name, and a suffix, skipping any\n * empty parts.\n *\n * @example\n * `enumPropName('Order', 'status', 'enum') // 'OrderStatusEnum'`\n */\nexport function enumPropName(parentName: string | null | undefined, propName: string, enumSuffix: string): string {\n return pascalCase([parentName, propName, enumSuffix].filter(Boolean).join(' '))\n}\n\n/**\n * Merges a ref node with its resolved schema, giving usage-site fields precedence.\n *\n * Every field set on the ref node except `kind`, `type`, `name`, `ref`, and `schema` overrides the\n * same field in the resolved `node.schema` (for example `description`, `nullable`, `readOnly`,\n * `deprecated`). Fields left `undefined` on the ref do not shadow the resolved schema. Non-ref\n * nodes and refs without a resolved `schema` are returned unchanged.\n *\n * @example\n * ```ts\n * const ref = ast.factory.createSchema({ type: 'ref', ref: '#/components/schemas/Pet', description: 'A cute pet' })\n * const merged = syncSchemaRef(ref) // merges with resolved Pet schema\n * ```\n */\nexport function syncSchemaRef(node: SchemaNode): SchemaNode {\n const ref = ast.narrowSchema(node, 'ref')\n\n if (!ref) return node\n if (!ref.schema) return node\n\n const { kind: _kind, type: _type, name: _name, ref: _ref, schema: _schema, ...overrides } = ref\n\n // Filter out undefined override values so they don't shadow the resolved schema's fields.\n const definedOverrides = Object.fromEntries(Object.entries(overrides).filter(([, v]) => v !== undefined))\n\n return ast.factory.createSchema({ ...ref.schema, ...definedOverrides })\n}\n\n/**\n * Returns `true` when a schema emits as a plain `string` type.\n *\n * Covers `string`, `uuid`, `email`, `url`, and `datetime` types. For `date` and `time`\n * types, returns `true` only when `representation` is `'string'` rather than `'date'`.\n */\nexport function isStringType(node: SchemaNode): boolean {\n if (plainStringTypes.has(node.type)) {\n return true\n }\n\n const temporal = ast.narrowSchema(node, 'date') ?? ast.narrowSchema(node, 'time')\n if (temporal) {\n return temporal.representation !== 'date'\n }\n\n return false\n}\n","import { ast } from '@kubb/ast'\nimport { enumPropName } from '../utils/refs.ts'\n\ntype Props = {\n parentName: string | null | undefined\n propName: string\n enumSuffix: string\n}\n\n/**\n * Builds a macro that names an inline enum schema from its parent and property name. Boolean enums\n * are left anonymous. Non-enum nodes are returned unchanged.\n *\n * @example\n * ```ts\n * const macro = macroEnumName({ parentName: 'Pet', propName: 'status', enumSuffix: 'enum' })\n * const named = applyMacros(propSchema, [macro], { depth: 'shallow' })\n * ```\n */\nexport function macroEnumName({ parentName, propName, enumSuffix }: Props) {\n return ast.defineMacro({\n name: 'enum-name',\n schema(node) {\n const enumNode = ast.narrowSchema(node, 'enum')\n\n if (enumNode?.primitive === 'boolean') return { ...node, name: null }\n if (enumNode) return { ...node, name: enumPropName(parentName, propName, enumSuffix) }\n\n return undefined\n },\n })\n}\n","import { ast } from '@kubb/ast'\n\ntype Props = {\n from: string\n to: string\n}\n\n/**\n * Builds a macro that renames a schema consistently: the declaration (`name`) and every ref\n * pointing at it (`targetName`) change together, so imports and printed references stay in\n * sync. Renaming only one side by hand produces imports for files that are never generated.\n *\n * @example\n * `const macro = macroRenameSchema({ from: 'Order', to: 'StoreOrder' })`\n */\nexport function macroRenameSchema({ from, to }: Props) {\n return ast.defineMacro({\n name: 'rename-schema',\n schema(node) {\n const refNode = ast.narrowSchema(node, 'ref')\n\n if (!refNode) {\n return node.name === from ? { ...node, name: to } : undefined\n }\n\n const renamesDeclaration = refNode.name === from\n const renamesTarget = ast.resolveRefName(refNode) === from\n if (!renamesDeclaration && !renamesTarget) return undefined\n\n return {\n ...refNode,\n ...(renamesDeclaration ? { name: to } : {}),\n ...(renamesTarget ? { targetName: to } : {}),\n }\n },\n })\n}\n","import { ast } from '@kubb/ast'\nimport type { SchemaNode } from '@kubb/ast'\n\ntype ScalarPrimitive = 'string' | 'number' | 'integer' | 'bigint' | 'boolean'\n\n/**\n * Scalar primitive schema types used for union simplification and type narrowing.\n */\nconst SCALAR_PRIMITIVE_TYPES = new Set<ScalarPrimitive>(['string', 'number', 'integer', 'bigint', 'boolean'])\n\nfunction isScalarPrimitive(type: string): type is ScalarPrimitive {\n return SCALAR_PRIMITIVE_TYPES.has(type as ScalarPrimitive)\n}\n\n/**\n * Filters union members, dropping enum members that a broader scalar primitive already covers.\n */\nfunction simplifyUnionMembers(members: Array<SchemaNode>): Array<SchemaNode> {\n const scalarPrimitives = new Set(members.filter((member) => isScalarPrimitive(member.type)).map((m) => m.type))\n if (!scalarPrimitives.size) return members\n\n return members.filter((member) => {\n const enumNode = ast.narrowSchema(member, 'enum')\n if (!enumNode) return true\n\n const primitive = enumNode.primitive\n if (!primitive) return true\n\n const enumValueCount = enumNode.namedEnumValues?.length ?? enumNode.enumValues?.length ?? 0\n if (enumValueCount <= 1) return true\n\n if (scalarPrimitives.has(primitive)) return false\n if ((primitive === 'integer' || primitive === 'number') && (scalarPrimitives.has('integer') || scalarPrimitives.has('number'))) return false\n\n return true\n })\n}\n\n/**\n * Removes union members a broader scalar primitive already covers, such as a multi-value string enum\n * sitting next to a plain `string`. Single-value enums are kept.\n *\n * @example\n * ```ts\n * const next = applyMacros(unionSchema, [macroSimplifyUnion], { depth: 'shallow' })\n * ```\n */\nexport const macroSimplifyUnion = ast.defineMacro({\n name: 'simplify-union',\n schema(node) {\n const unionNode = ast.narrowSchema(node, 'union')\n if (!unionNode?.members?.length) return undefined\n\n const simplified = simplifyUnionMembers(unionNode.members)\n if (simplified.length === unionNode.members.length) return undefined\n\n return { ...unionNode, members: simplified }\n },\n})\n","import { ast } from '@kubb/ast'\nimport type { SchemaNode } from '@kubb/ast'\n\n/**\n * Merges a run of adjacent anonymous object members into one. Named or non-object members break the\n * run and pass through unchanged. The merge follows member order, so callers control which members\n * combine by where they place them in the sequence.\n *\n * @example\n * ```ts\n * const merged = [...mergeAdjacentObjectsLazy([objectA, objectB])]\n * ```\n */\nexport function* mergeAdjacentObjectsLazy(members: Iterable<SchemaNode>): Generator<SchemaNode, void, undefined> {\n let acc: SchemaNode | undefined\n\n for (const member of members) {\n const objectMember = ast.narrowSchema(member, 'object')\n if (objectMember && !objectMember.name && acc !== undefined) {\n const accObject = ast.narrowSchema(acc, 'object')\n if (accObject && !accObject.name) {\n acc = ast.factory.createSchema({\n ...accObject,\n properties: [...(accObject.properties ?? []), ...(objectMember.properties ?? [])],\n })\n continue\n }\n }\n if (acc !== undefined) yield acc\n acc = member\n }\n\n if (acc !== undefined) yield acc\n}\n","import { ast } from '@kubb/ast'\nimport type { SchemaNode } from '@kubb/ast'\n\n/**\n * Returns `true` when a schema, or anything nested inside it, references a circular schema.\n *\n * Pass `excludeName` to skip refs to a specific schema, which helps when self-references are handled\n * on their own. Pair it with `ast.findCircularSchemas()` to decide where lazy wrappers go.\n *\n * @note Stops at the first matching circular ref.\n */\nexport function containsCircularRef(\n node: SchemaNode | undefined,\n { circularSchemas, excludeName }: { circularSchemas: ReadonlySet<string>; excludeName?: string },\n): boolean {\n if (!node || circularSchemas.size === 0) return false\n\n for (const _ of ast.collect<true>(node, {\n schema(child) {\n if (child.type !== 'ref') return null\n const name = ast.resolveRefName(child)\n return name && name !== excludeName && circularSchemas.has(name) ? true : null\n },\n })) {\n return true\n }\n\n return false\n}\n"],"mappings":";;;;;;;;;;;AAkBA,SAAS,gBAAgB,MAAc,QAAyB;CAC9D,OAAO,KACJ,KAAK,CAAC,CACN,QAAQ,qBAAqB,OAAO,CAAC,CACrC,QAAQ,yBAAyB,OAAO,CAAC,CACzC,QAAQ,gBAAgB,OAAO,CAAC,CAChC,MAAM,eAAe,CAAC,CACtB,OAAO,OAAO,CAAC,CACf,KAAK,MAAM,MAAM;EAChB,IAAI,KAAK,SAAS,KAAK,SAAS,KAAK,YAAY,GAAG,OAAO;EAE3D,QADa,MAAM,KAAK,CAAC,SAAS,KAAK,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,YAAY,KAC9E,KAAK,MAAM,CAAC;CAC5B,CAAC,CAAC,CACD,KAAK,EAAE,CAAC,CACR,QAAQ,iBAAiB,EAAE;AAChC;;;;;;;;;;AAWA,SAAgB,UAAU,MAAc,EAAE,SAAS,IAAI,SAAS,OAAgB,CAAC,GAAW;CAC1F,OAAO,gBAAgB,GAAG,OAAO,GAAG,KAAK,GAAG,UAAU,KAAK;AAC7D;;;;;;;;;;AAWA,SAAgB,WAAW,MAAc,EAAE,SAAS,IAAI,SAAS,OAAgB,CAAC,GAA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GAAW,SAAS;EAAW;CAC7C;AACF,CAAC;;;;;;;;;;;;;AC7CD,UAAiB,yBAAyB,SAAuE;CAC/G,IAAI;CAEJ,KAAK,MAAM,UAAU,SAAS;EAC5B,MAAM,eAAeC,MAAI,aAAa,QAAQ,QAAQ;EACtD,IAAI,gBAAgB,CAAC,aAAa,QAAQ,QAAQ,KAAA,GAAW;GAC3D,MAAM,YAAYA,MAAI,aAAa,KAAK,QAAQ;GAChD,IAAI,aAAa,CAAC,UAAU,MAAM;IAChC,MAAMA,MAAI,QAAQ,aAAa;KAC7B,GAAG;KACH,YAAY,CAAC,GAAI,UAAU,cAAc,CAAC,GAAI,GAAI,aAAa,cAAc,CAAC,CAAE;IAClF,CAAC;IACD;GACF;EACF;EACA,IAAI,QAAQ,KAAA,GAAW,MAAM;EAC7B,MAAM;CACR;CAEA,IAAI,QAAQ,KAAA,GAAW,MAAM;AAC/B;;;;;;;;;;;ACtBA,SAAgB,oBACd,MACA,EAAE,iBAAiB,eACV;CACT,IAAI,CAAC,QAAQ,gBAAgB,SAAS,GAAG,OAAO;CAEhD,KAAK,MAAM,KAAKC,MAAI,QAAc,MAAM,EACtC,OAAO,OAAO;EACZ,IAAI,MAAM,SAAS,OAAO,OAAO;EACjC,MAAM,OAAOA,MAAI,eAAe,KAAK;EACrC,OAAO,QAAQ,SAAS,eAAe,gBAAgB,IAAI,IAAI,IAAI,OAAO;CAC5E,EACF,CAAC,GACC,OAAO;CAGT,OAAO;AACT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/kit",
3
- "version": "5.0.0-beta.99",
3
+ "version": "5.0.1",
4
4
  "description": "Authoring toolkit for Kubb plugins, generators, adapters, resolvers, and renderers.",
5
5
  "keywords": [
6
6
  "codegen",
@@ -10,6 +10,7 @@
10
10
  "plugin",
11
11
  "typescript"
12
12
  ],
13
+ "homepage": "https://kubb.dev",
13
14
  "license": "MIT",
14
15
  "author": "stijnvanhulle",
15
16
  "repository": {
@@ -17,6 +18,16 @@
17
18
  "url": "git+https://github.com/kubb-labs/kubb.git",
18
19
  "directory": "packages/kit"
19
20
  },
21
+ "funding": [
22
+ {
23
+ "type": "github",
24
+ "url": "https://github.com/sponsors/stijnvanhulle"
25
+ },
26
+ {
27
+ "type": "opencollective",
28
+ "url": "https://opencollective.com/kubb"
29
+ }
30
+ ],
20
31
  "files": [
21
32
  "dist",
22
33
  "*.d.ts",
@@ -46,11 +57,11 @@
46
57
  "registry": "https://registry.npmjs.org/"
47
58
  },
48
59
  "dependencies": {
49
- "@kubb/core": "5.0.0-beta.99",
50
- "@kubb/ast": "5.0.0-beta.99"
60
+ "@kubb/core": "5.0.1",
61
+ "@kubb/ast": "5.0.1"
51
62
  },
52
63
  "devDependencies": {
53
- "@internals/utils": "0.0.0"
64
+ "@internals/utils": "0.0.1"
54
65
  },
55
66
  "engines": {
56
67
  "node": ">=22"