@kubb/ast 5.0.0-beta.61 → 5.0.0-beta.63

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/dist/{defineMacro-BLIR6k-j.d.ts → defineMacro-BATi7xoC.d.ts} +11 -20
  2. package/dist/{defineMacro-Bv9R_9a2.cjs → defineMacro-CEZHaCXE.cjs} +13 -21
  3. package/dist/defineMacro-CEZHaCXE.cjs.map +1 -0
  4. package/dist/{defineMacro-BTXvS8nI.js → defineMacro-Shz8f6SG.js} +12 -19
  5. package/dist/defineMacro-Shz8f6SG.js.map +1 -0
  6. package/dist/factory.cjs +88 -28
  7. package/dist/factory.cjs.map +1 -0
  8. package/dist/factory.d.ts +6 -41
  9. package/dist/factory.js +58 -3
  10. package/dist/factory.js.map +1 -0
  11. package/dist/{index-BzjwdK2M.d.ts → index-B9cc8MBS.d.ts} +164 -194
  12. package/dist/index.cjs +144 -274
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.ts +43 -37
  15. package/dist/index.js +109 -235
  16. package/dist/index.js.map +1 -1
  17. package/dist/macros.cjs +41 -28
  18. package/dist/macros.cjs.map +1 -1
  19. package/dist/macros.d.ts +14 -12
  20. package/dist/macros.js +34 -21
  21. package/dist/macros.js.map +1 -1
  22. package/dist/{operationParams-BZ07xDm0.d.ts → operationParams-k5CKwSWZ.d.ts} +9 -2
  23. package/dist/{visitor-DJ6ZEJvq.js → refs-BjNDuCBD.js} +116 -159
  24. package/dist/refs-BjNDuCBD.js.map +1 -0
  25. package/dist/{visitor-DpKZ9Tk0.cjs → refs-u5SDdyV7.cjs} +140 -195
  26. package/dist/refs-u5SDdyV7.cjs.map +1 -0
  27. package/dist/{response-hnSw2NKE.cjs → schema-BkvrrOAr.cjs} +496 -231
  28. package/dist/schema-BkvrrOAr.cjs.map +1 -0
  29. package/dist/{response-KUdWiDWw.js → schema-Cbnxmz4b.js} +472 -220
  30. package/dist/schema-Cbnxmz4b.js.map +1 -0
  31. package/dist/{types-DyDzizSf.d.ts → types-BB_xgRJ3.d.ts} +49 -123
  32. package/dist/types.d.ts +5 -6
  33. package/dist/{utils-BLJwyza-.cjs → utils-CEepwqmb.cjs} +76 -69
  34. package/dist/utils-CEepwqmb.cjs.map +1 -0
  35. package/dist/{utils-CF_-Pn_c.js → utils-DaXkewb1.js} +58 -51
  36. package/dist/utils-DaXkewb1.js.map +1 -0
  37. package/dist/utils.cjs +11 -11
  38. package/dist/utils.d.ts +53 -30
  39. package/dist/utils.js +3 -3
  40. package/package.json +1 -1
  41. package/src/constants.ts +3 -36
  42. package/src/defineMacro.ts +20 -13
  43. package/src/{node.ts → defineNode.ts} +12 -38
  44. package/src/{printer.ts → definePrinter.ts} +5 -3
  45. package/src/dialect.ts +52 -19
  46. package/src/factory.ts +7 -94
  47. package/src/index.ts +7 -9
  48. package/src/infer.ts +1 -1
  49. package/src/macros/macroDiscriminatorEnum.ts +7 -1
  50. package/src/macros/macroEnumName.ts +10 -2
  51. package/src/macros/macroSimplifyUnion.ts +29 -19
  52. package/src/nodes/code.ts +40 -80
  53. package/src/nodes/content.ts +2 -7
  54. package/src/nodes/file.ts +107 -18
  55. package/src/nodes/function.ts +46 -46
  56. package/src/nodes/index.ts +2 -3
  57. package/src/nodes/input.ts +13 -9
  58. package/src/nodes/operation.ts +8 -5
  59. package/src/nodes/output.ts +1 -1
  60. package/src/nodes/parameter.ts +5 -5
  61. package/src/nodes/property.ts +5 -5
  62. package/src/nodes/requestBody.ts +6 -13
  63. package/src/nodes/response.ts +93 -8
  64. package/src/nodes/schema.ts +5 -5
  65. package/src/optionality.ts +15 -0
  66. package/src/registry.ts +1 -1
  67. package/src/types.ts +4 -6
  68. package/src/utils/codegen.ts +6 -7
  69. package/src/utils/extractStringsFromNodes.ts +1 -0
  70. package/src/utils/fileMerge.ts +7 -8
  71. package/src/utils/operationParams.ts +9 -9
  72. package/src/utils/refs.ts +14 -18
  73. package/src/utils/schemaGraph.ts +41 -33
  74. package/src/utils/schemaMerge.ts +2 -2
  75. package/src/visitor.ts +3 -14
  76. package/dist/defineMacro-BTXvS8nI.js.map +0 -1
  77. package/dist/defineMacro-Bv9R_9a2.cjs.map +0 -1
  78. package/dist/extractStringsFromNodes-Cja-xxx5.js +0 -29
  79. package/dist/extractStringsFromNodes-Cja-xxx5.js.map +0 -1
  80. package/dist/extractStringsFromNodes-DKgDjFO0.cjs +0 -34
  81. package/dist/extractStringsFromNodes-DKgDjFO0.cjs.map +0 -1
  82. package/dist/extractStringsFromNodes-p4mX1TQD.d.ts +0 -14
  83. package/dist/factory-CZNOGI-N.js +0 -283
  84. package/dist/factory-CZNOGI-N.js.map +0 -1
  85. package/dist/factory-DG1CVkEb.cjs +0 -300
  86. package/dist/factory-DG1CVkEb.cjs.map +0 -1
  87. package/dist/response-KUdWiDWw.js.map +0 -1
  88. package/dist/response-hnSw2NKE.cjs.map +0 -1
  89. package/dist/utils-BLJwyza-.cjs.map +0 -1
  90. package/dist/utils-CF_-Pn_c.js.map +0 -1
  91. package/dist/visitor-DJ6ZEJvq.js.map +0 -1
  92. package/dist/visitor-DpKZ9Tk0.cjs.map +0 -1
  93. package/src/dedupe.ts +0 -239
  94. package/src/mocks.ts +0 -56
  95. package/src/nodes/http.ts +0 -85
package/dist/macros.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_response = require("./response-hnSw2NKE.cjs");
3
- const require_visitor = require("./visitor-DpKZ9Tk0.cjs");
4
- const require_defineMacro = require("./defineMacro-Bv9R_9a2.cjs");
2
+ const require_schema = require("./schema-BkvrrOAr.cjs");
3
+ const require_refs = require("./refs-u5SDdyV7.cjs");
4
+ const require_defineMacro = require("./defineMacro-CEZHaCXE.cjs");
5
5
  //#region src/macros/macroDiscriminatorEnum.ts
6
6
  /**
7
7
  * Builds a macro that replaces a discriminator property's schema with a string enum of the given
@@ -17,16 +17,16 @@ function macroDiscriminatorEnum({ propertyName, values, enumName }) {
17
17
  return require_defineMacro.defineMacro({
18
18
  name: "discriminator-enum",
19
19
  schema(node) {
20
- const objectNode = require_visitor.narrowSchema(node, "object");
20
+ const objectNode = require_refs.narrowSchema(node, "object");
21
21
  if (!objectNode?.properties?.length) return void 0;
22
22
  if (!objectNode.properties.some((prop) => prop.name === propertyName)) return void 0;
23
- return require_response.createSchema({
23
+ return require_schema.createSchema({
24
24
  ...objectNode,
25
25
  properties: objectNode.properties.map((prop) => {
26
26
  if (prop.name !== propertyName) return prop;
27
- return require_response.createProperty({
27
+ return require_schema.createProperty({
28
28
  ...prop,
29
- schema: require_response.createSchema({
29
+ schema: require_schema.createSchema({
30
30
  type: "enum",
31
31
  primitive: "string",
32
32
  enumValues: values,
@@ -44,7 +44,7 @@ function macroDiscriminatorEnum({ propertyName, values, enumName }) {
44
44
  //#region src/macros/macroEnumName.ts
45
45
  /**
46
46
  * Builds a macro that names an inline enum schema from its parent and property name. Boolean enums
47
- * are left anonymous; non-enum nodes are returned unchanged.
47
+ * are left anonymous. Non-enum nodes are returned unchanged.
48
48
  *
49
49
  * @example
50
50
  * ```ts
@@ -56,14 +56,14 @@ function macroEnumName({ parentName, propName, enumSuffix }) {
56
56
  return require_defineMacro.defineMacro({
57
57
  name: "enum-name",
58
58
  schema(node) {
59
- const enumNode = require_visitor.narrowSchema(node, "enum");
59
+ const enumNode = require_refs.narrowSchema(node, "enum");
60
60
  if (enumNode?.primitive === "boolean") return {
61
61
  ...node,
62
62
  name: null
63
63
  };
64
64
  if (enumNode) return {
65
65
  ...node,
66
- name: require_visitor.enumPropName(parentName, propName, enumSuffix)
66
+ name: require_refs.enumPropName(parentName, propName, enumSuffix)
67
67
  };
68
68
  }
69
69
  });
@@ -71,6 +71,36 @@ function macroEnumName({ parentName, propName, enumSuffix }) {
71
71
  //#endregion
72
72
  //#region src/macros/macroSimplifyUnion.ts
73
73
  /**
74
+ * Scalar primitive schema types used for union simplification and type narrowing.
75
+ */
76
+ const SCALAR_PRIMITIVE_TYPES = new Set([
77
+ "string",
78
+ "number",
79
+ "integer",
80
+ "bigint",
81
+ "boolean"
82
+ ]);
83
+ function isScalarPrimitive(type) {
84
+ return SCALAR_PRIMITIVE_TYPES.has(type);
85
+ }
86
+ /**
87
+ * Filters union members, dropping enum members that a broader scalar primitive already covers.
88
+ */
89
+ function simplifyUnionMembers(members) {
90
+ const scalarPrimitives = new Set(members.filter((member) => isScalarPrimitive(member.type)).map((m) => m.type));
91
+ if (!scalarPrimitives.size) return members;
92
+ return members.filter((member) => {
93
+ const enumNode = require_refs.narrowSchema(member, "enum");
94
+ if (!enumNode) return true;
95
+ const primitive = enumNode.primitive;
96
+ if (!primitive) return true;
97
+ if ((enumNode.namedEnumValues?.length ?? enumNode.enumValues?.length ?? 0) <= 1) return true;
98
+ if (scalarPrimitives.has(primitive)) return false;
99
+ if ((primitive === "integer" || primitive === "number") && (scalarPrimitives.has("integer") || scalarPrimitives.has("number"))) return false;
100
+ return true;
101
+ });
102
+ }
103
+ /**
74
104
  * Removes union members a broader scalar primitive already covers, such as a multi-value string enum
75
105
  * sitting next to a plain `string`. Single-value enums are kept.
76
106
  *
@@ -82,7 +112,7 @@ function macroEnumName({ parentName, propName, enumSuffix }) {
82
112
  const macroSimplifyUnion = require_defineMacro.defineMacro({
83
113
  name: "simplify-union",
84
114
  schema(node) {
85
- const unionNode = require_visitor.narrowSchema(node, "union");
115
+ const unionNode = require_refs.narrowSchema(node, "union");
86
116
  if (!unionNode?.members?.length) return void 0;
87
117
  const simplified = simplifyUnionMembers(unionNode.members);
88
118
  if (simplified.length === unionNode.members.length) return void 0;
@@ -92,23 +122,6 @@ const macroSimplifyUnion = require_defineMacro.defineMacro({
92
122
  };
93
123
  }
94
124
  });
95
- /**
96
- * Filters union members, dropping enum members that a broader scalar primitive already covers.
97
- */
98
- function simplifyUnionMembers(members) {
99
- const scalarPrimitives = new Set(members.filter((member) => require_visitor.isScalarPrimitive(member.type)).map((m) => m.type));
100
- if (!scalarPrimitives.size) return members;
101
- return members.filter((member) => {
102
- const enumNode = require_visitor.narrowSchema(member, "enum");
103
- if (!enumNode) return true;
104
- const primitive = enumNode.primitive;
105
- if (!primitive) return true;
106
- if ((enumNode.namedEnumValues?.length ?? enumNode.enumValues?.length ?? 0) <= 1) return true;
107
- if (scalarPrimitives.has(primitive)) return false;
108
- if ((primitive === "integer" || primitive === "number") && (scalarPrimitives.has("integer") || scalarPrimitives.has("number"))) return false;
109
- return true;
110
- });
111
- }
112
125
  //#endregion
113
126
  exports.macroDiscriminatorEnum = macroDiscriminatorEnum;
114
127
  exports.macroEnumName = macroEnumName;
@@ -1 +1 @@
1
- {"version":3,"file":"macros.cjs","names":["defineMacro","narrowSchema","createSchema","createProperty","defineMacro","narrowSchema","enumPropName","defineMacro","narrowSchema","isScalarPrimitive"],"sources":["../src/macros/macroDiscriminatorEnum.ts","../src/macros/macroEnumName.ts","../src/macros/macroSimplifyUnion.ts"],"sourcesContent":["import { defineMacro } from '../defineMacro.ts'\nimport { narrowSchema } from '../guards.ts'\nimport { createProperty } from '../nodes/property.ts'\nimport { createSchema } from '../nodes/schema.ts'\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 }: { propertyName: string; values: Array<string>; enumName?: string }) {\n return defineMacro({\n name: 'discriminator-enum',\n schema(node) {\n const objectNode = narrowSchema(node, 'object')\n if (!objectNode?.properties?.length) return undefined\n if (!objectNode.properties.some((prop) => prop.name === propertyName)) return undefined\n\n return createSchema({\n ...objectNode,\n properties: objectNode.properties.map((prop) => {\n if (prop.name !== propertyName) return prop\n\n return createProperty({\n ...prop,\n schema: 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 { defineMacro } from '../defineMacro.ts'\nimport { narrowSchema } from '../guards.ts'\nimport { enumPropName } from '../utils/refs.ts'\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 }: { parentName: string | null | undefined; propName: string; enumSuffix: string }) {\n return defineMacro({\n name: 'enum-name',\n schema(node) {\n const enumNode = narrowSchema(node, 'enum')\n if (enumNode?.primitive === 'boolean') return { ...node, name: null }\n if (enumNode) return { ...node, name: enumPropName(parentName, propName, enumSuffix) }\n return undefined\n },\n })\n}\n","import { isScalarPrimitive } from '../constants.ts'\nimport { defineMacro } from '../defineMacro.ts'\nimport { narrowSchema } from '../guards.ts'\nimport type { SchemaNode } from '../nodes/schema.ts'\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 = defineMacro({\n name: 'simplify-union',\n schema(node) {\n const unionNode = 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\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 = 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"],"mappings":";;;;;;;;;;;;;;;AAeA,SAAgB,uBAAuB,EAAE,cAAc,QAAQ,YAAgF;CAC7I,OAAOA,oBAAAA,YAAY;EACjB,MAAM;EACN,OAAO,MAAM;GACX,MAAM,aAAaC,gBAAAA,aAAa,MAAM,QAAQ;GAC9C,IAAI,CAAC,YAAY,YAAY,QAAQ,OAAO,KAAA;GAC5C,IAAI,CAAC,WAAW,WAAW,MAAM,SAAS,KAAK,SAAS,YAAY,GAAG,OAAO,KAAA;GAE9E,OAAOC,iBAAAA,aAAa;IAClB,GAAG;IACH,YAAY,WAAW,WAAW,KAAK,SAAS;KAC9C,IAAI,KAAK,SAAS,cAAc,OAAO;KAEvC,OAAOC,iBAAAA,eAAe;MACpB,GAAG;MACH,QAAQD,iBAAAA,aAAa;OACnB,MAAM;OACN,WAAW;OACX,YAAY;OACZ,MAAM;OACN,UAAU,KAAK,OAAO;OACtB,WAAW,KAAK,OAAO;MACzB,CAAC;KACH,CAAC;IACH,CAAC;GACH,CAAC;EACH;CACF,CAAC;AACH;;;;;;;;;;;;;AC7BA,SAAgB,cAAc,EAAE,YAAY,UAAU,cAA+F;CACnJ,OAAOE,oBAAAA,YAAY;EACjB,MAAM;EACN,OAAO,MAAM;GACX,MAAM,WAAWC,gBAAAA,aAAa,MAAM,MAAM;GAC1C,IAAI,UAAU,cAAc,WAAW,OAAO;IAAE,GAAG;IAAM,MAAM;GAAK;GACpE,IAAI,UAAU,OAAO;IAAE,GAAG;IAAM,MAAMC,gBAAAA,aAAa,YAAY,UAAU,UAAU;GAAE;EAEvF;CACF,CAAC;AACH;;;;;;;;;;;;ACVA,MAAa,qBAAqBC,oBAAAA,YAAY;CAC5C,MAAM;CACN,OAAO,MAAM;EACX,MAAM,YAAYC,gBAAAA,aAAa,MAAM,OAAO;EAC5C,IAAI,CAAC,WAAW,SAAS,QAAQ,OAAO,KAAA;EAExC,MAAM,aAAa,qBAAqB,UAAU,OAAO;EACzD,IAAI,WAAW,WAAW,UAAU,QAAQ,QAAQ,OAAO,KAAA;EAE3D,OAAO;GAAE,GAAG;GAAW,SAAS;EAAW;CAC7C;AACF,CAAC;;;;AAKD,SAAS,qBAAqB,SAA+C;CAC3E,MAAM,mBAAmB,IAAI,IAAI,QAAQ,QAAQ,WAAWC,gBAAAA,kBAAkB,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,MAAM,EAAE,IAAI,CAAC;CAC9G,IAAI,CAAC,iBAAiB,MAAM,OAAO;CAEnC,OAAO,QAAQ,QAAQ,WAAW;EAChC,MAAM,WAAWD,gBAAAA,aAAa,QAAQ,MAAM;EAC5C,IAAI,CAAC,UAAU,OAAO;EAEtB,MAAM,YAAY,SAAS;EAC3B,IAAI,CAAC,WAAW,OAAO;EAGvB,KADuB,SAAS,iBAAiB,UAAU,SAAS,YAAY,UAAU,MACpE,GAAG,OAAO;EAEhC,IAAI,iBAAiB,IAAI,SAAS,GAAG,OAAO;EAC5C,KAAK,cAAc,aAAa,cAAc,cAAc,iBAAiB,IAAI,SAAS,KAAK,iBAAiB,IAAI,QAAQ,IAAI,OAAO;EAEvI,OAAO;CACT,CAAC;AACH"}
1
+ {"version":3,"file":"macros.cjs","names":["defineMacro","narrowSchema","createSchema","createProperty","defineMacro","narrowSchema","enumPropName","narrowSchema","defineMacro"],"sources":["../src/macros/macroDiscriminatorEnum.ts","../src/macros/macroEnumName.ts","../src/macros/macroSimplifyUnion.ts"],"sourcesContent":["import { defineMacro } from '../defineMacro.ts'\nimport { narrowSchema } from '../guards.ts'\nimport { createProperty } from '../nodes/property.ts'\nimport { createSchema } from '../nodes/schema.ts'\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 defineMacro({\n name: 'discriminator-enum',\n schema(node) {\n const objectNode = narrowSchema(node, 'object')\n if (!objectNode?.properties?.length) return undefined\n if (!objectNode.properties.some((prop) => prop.name === propertyName)) return undefined\n\n return createSchema({\n ...objectNode,\n properties: objectNode.properties.map((prop) => {\n if (prop.name !== propertyName) return prop\n\n return createProperty({\n ...prop,\n schema: 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 { defineMacro } from '../defineMacro.ts'\nimport { narrowSchema } from '../guards.ts'\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 defineMacro({\n name: 'enum-name',\n schema(node) {\n const enumNode = 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 { defineMacro } from '../defineMacro.ts'\nimport { narrowSchema } from '../guards.ts'\nimport type { SchemaNode } from '../nodes/schema.ts'\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 = 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 = defineMacro({\n name: 'simplify-union',\n schema(node) {\n const unionNode = 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"],"mappings":";;;;;;;;;;;;;;;AAqBA,SAAgB,uBAAuB,EAAE,cAAc,QAAQ,YAAmB;CAChF,OAAOA,oBAAAA,YAAY;EACjB,MAAM;EACN,OAAO,MAAM;GACX,MAAM,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C,aAAAA,aAAa,QAAQ,MAAM;EAC5C,IAAI,CAAC,UAAU,OAAO;EAEtB,MAAM,YAAY,SAAS;EAC3B,IAAI,CAAC,WAAW,OAAO;EAGvB,KADuB,SAAS,iBAAiB,UAAU,SAAS,YAAY,UAAU,MACpE,GAAG,OAAO;EAEhC,IAAI,iBAAiB,IAAI,SAAS,GAAG,OAAO;EAC5C,KAAK,cAAc,aAAa,cAAc,cAAc,iBAAiB,IAAI,SAAS,KAAK,iBAAiB,IAAI,QAAQ,IAAI,OAAO;EAEvI,OAAO;CACT,CAAC;AACH;;;;;;;;;;AAWA,MAAa,qBAAqBC,oBAAAA,YAAY;CAC5C,MAAM;CACN,OAAO,MAAM;EACX,MAAM,YAAYD,aAAAA,aAAa,MAAM,OAAO;EAC5C,IAAI,CAAC,WAAW,SAAS,QAAQ,OAAO,KAAA;EAExC,MAAM,aAAa,qBAAqB,UAAU,OAAO;EACzD,IAAI,WAAW,WAAW,UAAU,QAAQ,QAAQ,OAAO,KAAA;EAE3D,OAAO;GAAE,GAAG;GAAW,SAAS;EAAW;CAC7C;AACF,CAAC"}
package/dist/macros.d.ts CHANGED
@@ -1,7 +1,12 @@
1
1
  import { n as __name } from "./chunk-CNktS9qV.js";
2
- import { t as Macro } from "./defineMacro-BLIR6k-j.js";
2
+ import { n as Macro } from "./defineMacro-BATi7xoC.js";
3
3
 
4
4
  //#region src/macros/macroDiscriminatorEnum.d.ts
5
+ type Props$1 = {
6
+ propertyName: string;
7
+ values: Array<string>;
8
+ enumName?: string;
9
+ };
5
10
  /**
6
11
  * Builds a macro that replaces a discriminator property's schema with a string enum of the given
7
12
  * values. Object schemas that lack the property are returned unchanged.
@@ -16,16 +21,17 @@ declare function macroDiscriminatorEnum({
16
21
  propertyName,
17
22
  values,
18
23
  enumName
19
- }: {
20
- propertyName: string;
21
- values: Array<string>;
22
- enumName?: string;
23
- }): Macro;
24
+ }: Props$1): Macro;
24
25
  //#endregion
25
26
  //#region src/macros/macroEnumName.d.ts
27
+ type Props = {
28
+ parentName: string | null | undefined;
29
+ propName: string;
30
+ enumSuffix: string;
31
+ };
26
32
  /**
27
33
  * Builds a macro that names an inline enum schema from its parent and property name. Boolean enums
28
- * are left anonymous; non-enum nodes are returned unchanged.
34
+ * are left anonymous. Non-enum nodes are returned unchanged.
29
35
  *
30
36
  * @example
31
37
  * ```ts
@@ -37,11 +43,7 @@ declare function macroEnumName({
37
43
  parentName,
38
44
  propName,
39
45
  enumSuffix
40
- }: {
41
- parentName: string | null | undefined;
42
- propName: string;
43
- enumSuffix: string;
44
- }): Macro;
46
+ }: Props): Macro;
45
47
  //#endregion
46
48
  //#region src/macros/macroSimplifyUnion.d.ts
47
49
  /**
package/dist/macros.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import "./chunk-CNktS9qV.js";
2
- import { _ as isScalarPrimitive, m as narrowSchema, s as enumPropName } from "./visitor-DJ6ZEJvq.js";
3
- import { X as createSchema, r as createProperty } from "./response-KUdWiDWw.js";
4
- import { r as defineMacro } from "./defineMacro-BTXvS8nI.js";
2
+ import { m as narrowSchema, n as enumPropName } from "./refs-BjNDuCBD.js";
3
+ import { a as createProperty, t as createSchema } from "./schema-Cbnxmz4b.js";
4
+ import { r as defineMacro } from "./defineMacro-Shz8f6SG.js";
5
5
  //#region src/macros/macroDiscriminatorEnum.ts
6
6
  /**
7
7
  * Builds a macro that replaces a discriminator property's schema with a string enum of the given
@@ -44,7 +44,7 @@ function macroDiscriminatorEnum({ propertyName, values, enumName }) {
44
44
  //#region src/macros/macroEnumName.ts
45
45
  /**
46
46
  * Builds a macro that names an inline enum schema from its parent and property name. Boolean enums
47
- * are left anonymous; non-enum nodes are returned unchanged.
47
+ * are left anonymous. Non-enum nodes are returned unchanged.
48
48
  *
49
49
  * @example
50
50
  * ```ts
@@ -71,6 +71,36 @@ function macroEnumName({ parentName, propName, enumSuffix }) {
71
71
  //#endregion
72
72
  //#region src/macros/macroSimplifyUnion.ts
73
73
  /**
74
+ * Scalar primitive schema types used for union simplification and type narrowing.
75
+ */
76
+ const SCALAR_PRIMITIVE_TYPES = new Set([
77
+ "string",
78
+ "number",
79
+ "integer",
80
+ "bigint",
81
+ "boolean"
82
+ ]);
83
+ function isScalarPrimitive(type) {
84
+ return SCALAR_PRIMITIVE_TYPES.has(type);
85
+ }
86
+ /**
87
+ * Filters union members, dropping enum members that a broader scalar primitive already covers.
88
+ */
89
+ function simplifyUnionMembers(members) {
90
+ const scalarPrimitives = new Set(members.filter((member) => isScalarPrimitive(member.type)).map((m) => m.type));
91
+ if (!scalarPrimitives.size) return members;
92
+ return members.filter((member) => {
93
+ const enumNode = narrowSchema(member, "enum");
94
+ if (!enumNode) return true;
95
+ const primitive = enumNode.primitive;
96
+ if (!primitive) return true;
97
+ if ((enumNode.namedEnumValues?.length ?? enumNode.enumValues?.length ?? 0) <= 1) return true;
98
+ if (scalarPrimitives.has(primitive)) return false;
99
+ if ((primitive === "integer" || primitive === "number") && (scalarPrimitives.has("integer") || scalarPrimitives.has("number"))) return false;
100
+ return true;
101
+ });
102
+ }
103
+ /**
74
104
  * Removes union members a broader scalar primitive already covers, such as a multi-value string enum
75
105
  * sitting next to a plain `string`. Single-value enums are kept.
76
106
  *
@@ -92,23 +122,6 @@ const macroSimplifyUnion = defineMacro({
92
122
  };
93
123
  }
94
124
  });
95
- /**
96
- * Filters union members, dropping enum members that a broader scalar primitive already covers.
97
- */
98
- function simplifyUnionMembers(members) {
99
- const scalarPrimitives = new Set(members.filter((member) => isScalarPrimitive(member.type)).map((m) => m.type));
100
- if (!scalarPrimitives.size) return members;
101
- return members.filter((member) => {
102
- const enumNode = narrowSchema(member, "enum");
103
- if (!enumNode) return true;
104
- const primitive = enumNode.primitive;
105
- if (!primitive) return true;
106
- if ((enumNode.namedEnumValues?.length ?? enumNode.enumValues?.length ?? 0) <= 1) return true;
107
- if (scalarPrimitives.has(primitive)) return false;
108
- if ((primitive === "integer" || primitive === "number") && (scalarPrimitives.has("integer") || scalarPrimitives.has("number"))) return false;
109
- return true;
110
- });
111
- }
112
125
  //#endregion
113
126
  export { macroDiscriminatorEnum, macroEnumName, macroSimplifyUnion };
114
127
 
@@ -1 +1 @@
1
- {"version":3,"file":"macros.js","names":[],"sources":["../src/macros/macroDiscriminatorEnum.ts","../src/macros/macroEnumName.ts","../src/macros/macroSimplifyUnion.ts"],"sourcesContent":["import { defineMacro } from '../defineMacro.ts'\nimport { narrowSchema } from '../guards.ts'\nimport { createProperty } from '../nodes/property.ts'\nimport { createSchema } from '../nodes/schema.ts'\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 }: { propertyName: string; values: Array<string>; enumName?: string }) {\n return defineMacro({\n name: 'discriminator-enum',\n schema(node) {\n const objectNode = narrowSchema(node, 'object')\n if (!objectNode?.properties?.length) return undefined\n if (!objectNode.properties.some((prop) => prop.name === propertyName)) return undefined\n\n return createSchema({\n ...objectNode,\n properties: objectNode.properties.map((prop) => {\n if (prop.name !== propertyName) return prop\n\n return createProperty({\n ...prop,\n schema: 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 { defineMacro } from '../defineMacro.ts'\nimport { narrowSchema } from '../guards.ts'\nimport { enumPropName } from '../utils/refs.ts'\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 }: { parentName: string | null | undefined; propName: string; enumSuffix: string }) {\n return defineMacro({\n name: 'enum-name',\n schema(node) {\n const enumNode = narrowSchema(node, 'enum')\n if (enumNode?.primitive === 'boolean') return { ...node, name: null }\n if (enumNode) return { ...node, name: enumPropName(parentName, propName, enumSuffix) }\n return undefined\n },\n })\n}\n","import { isScalarPrimitive } from '../constants.ts'\nimport { defineMacro } from '../defineMacro.ts'\nimport { narrowSchema } from '../guards.ts'\nimport type { SchemaNode } from '../nodes/schema.ts'\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 = defineMacro({\n name: 'simplify-union',\n schema(node) {\n const unionNode = 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\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 = 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"],"mappings":";;;;;;;;;;;;;;;AAeA,SAAgB,uBAAuB,EAAE,cAAc,QAAQ,YAAgF;CAC7I,OAAO,YAAY;EACjB,MAAM;EACN,OAAO,MA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,MAAM,EAAE,IAAI,CAAC;CAC9G,IAAI,CAAC,iBAAiB,MAAM,OAAO;CAEnC,OAAO,QAAQ,QAAQ,WAAW;EAChC,MAAM,WAAW,aAAa,QAAQ,MAAM;EAC5C,IAAI,CAAC,UAAU,OAAO;EAEtB,MAAM,YAAY,SAAS;EAC3B,IAAI,CAAC,WAAW,OAAO;EAGvB,KADuB,SAAS,iBAAiB,UAAU,SAAS,YAAY,UAAU,MACpE,GAAG,OAAO;EAEhC,IAAI,iBAAiB,IAAI,SAAS,GAAG,OAAO;EAC5C,KAAK,cAAc,aAAa,cAAc,cAAc,iBAAiB,IAAI,SAAS,KAAK,iBAAiB,IAAI,QAAQ,IAAI,OAAO;EAEvI,OAAO;CACT,CAAC;AACH"}
1
+ {"version":3,"file":"macros.js","names":[],"sources":["../src/macros/macroDiscriminatorEnum.ts","../src/macros/macroEnumName.ts","../src/macros/macroSimplifyUnion.ts"],"sourcesContent":["import { defineMacro } from '../defineMacro.ts'\nimport { narrowSchema } from '../guards.ts'\nimport { createProperty } from '../nodes/property.ts'\nimport { createSchema } from '../nodes/schema.ts'\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 defineMacro({\n name: 'discriminator-enum',\n schema(node) {\n const objectNode = narrowSchema(node, 'object')\n if (!objectNode?.properties?.length) return undefined\n if (!objectNode.properties.some((prop) => prop.name === propertyName)) return undefined\n\n return createSchema({\n ...objectNode,\n properties: objectNode.properties.map((prop) => {\n if (prop.name !== propertyName) return prop\n\n return createProperty({\n ...prop,\n schema: 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 { defineMacro } from '../defineMacro.ts'\nimport { narrowSchema } from '../guards.ts'\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 defineMacro({\n name: 'enum-name',\n schema(node) {\n const enumNode = 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 { defineMacro } from '../defineMacro.ts'\nimport { narrowSchema } from '../guards.ts'\nimport type { SchemaNode } from '../nodes/schema.ts'\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 = 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 = defineMacro({\n name: 'simplify-union',\n schema(node) {\n const unionNode = 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"],"mappings":";;;;;;;;;;;;;;;AAqBA,SAAgB,uBAAuB,EAAE,cAAc,QAAQ,YAAmB;CAChF,OAAO,YAAY;EACjB,MAAM;EACN,OAAO,MAAM;GACX,MAAM,aAAa,aAAa,MAAM,QAAQ;GAC9C,IAAI,CAAC,YAAY,YAAY,QAAQ,OAAO,KAAA;GAC5C,IAAI,CAAC,WAAW,WAAW,MAAM,SAAS,KAAK,SAAS,YAAY,GAAG,OAAO,KAAA;GAE9E,OAAO,aAAa;IAClB,GAAG;IACH,YAAY,WAAW,WAAW,KAAK,SAAS;KAC9C,IAAI,KAAK,SAAS,cAAc,OAAO;KAEvC,OAAO,eAAe;MACpB,GAAG;MACH,QAAQ,aAAa;OACnB,MAAM;OACN,WAAW;OACX,YAAY;OACZ,MAAM;OACN,UAAU,KAAK,OAAO;OACtB,WAAW,KAAK,OAAO;MACzB,CAAC;KACH,CAAC;IACH,CAAC;GACH,CAAC;EACH;CACF,CAAC;AACH;;;;;;;;;;;;;AC7BA,SAAgB,cAAc,EAAE,YAAY,UAAU,cAAqB;CACzE,OAAO,YAAY;EACjB,MAAM;EACN,OAAO,MAAM;GAC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;EAAW;CAC7C;AACF,CAAC"}
@@ -1,7 +1,14 @@
1
1
  import { n as __name } from "./chunk-CNktS9qV.js";
2
- import { A as FunctionParametersNode, N as TypeExpression, P as TypeLiteralNode, f as OperationNode, k as FunctionParameterNode, w as ParameterNode } from "./index-BzjwdK2M.js";
2
+ import { C as ParameterNode, M as TypeExpression, N as TypeLiteralNode, O as FunctionParameterNode, f as OperationNode, k as FunctionParametersNode } from "./index-B9cc8MBS.js";
3
3
 
4
4
  //#region src/utils/operationParams.d.ts
5
+ /**
6
+ * Applies casing rules to parameter names and returns a new array without mutating the input.
7
+ *
8
+ * Run it before handing parameters to schema builders so output property keys get the right casing
9
+ * while `OperationNode.parameters` stays intact for other consumers. When `casing` is unset, the
10
+ * original array is returned unchanged.
11
+ */
5
12
  declare function caseParams(params: Array<ParameterNode>, casing: 'camelcase' | undefined): Array<ParameterNode>;
6
13
  /**
7
14
  * Named type for a group of parameters (query or header) emitted as a single typed parameter.
@@ -201,4 +208,4 @@ declare function buildTypeLiteral({
201
208
  }): TypeLiteralNode;
202
209
  //#endregion
203
210
  export { buildTypeLiteral as a, resolveParamType as c, buildGroupParam as i, OperationParamsResolver as n, caseParams as o, ParamGroupType as r, createOperationParams as s, BuildGroupArgs as t };
204
- //# sourceMappingURL=operationParams-BZ07xDm0.d.ts.map
211
+ //# sourceMappingURL=operationParams-k5CKwSWZ.d.ts.map