@kubb/ast 5.23.3 → 5.23.5

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 (79) hide show
  1. package/dist/factory.cjs +2 -2
  2. package/dist/factory.d.cts +4 -4
  3. package/dist/factory.d.ts +4 -4
  4. package/dist/factory.js +2 -2
  5. package/dist/{file-KunZhFIV.d.cts → file-B269mZh4.d.cts} +67 -33
  6. package/dist/file-Bq2GPaxh.js +427 -0
  7. package/dist/file-Bq2GPaxh.js.map +1 -0
  8. package/dist/file-C4pqV8yl.cjs +469 -0
  9. package/dist/file-C4pqV8yl.cjs.map +1 -0
  10. package/dist/{file-Dj9lsbJu.js → file-D_ih0x7q.js} +15 -11
  11. package/dist/file-D_ih0x7q.js.map +1 -0
  12. package/dist/{file-BAICym_L.cjs → file-DiPZBLSP.cjs} +15 -11
  13. package/dist/file-DiPZBLSP.cjs.map +1 -0
  14. package/dist/{file-DkFGn_Os.d.ts → file-oLlejzZV.d.ts} +67 -33
  15. package/dist/file.cjs +5 -2
  16. package/dist/file.d.cts +2 -2
  17. package/dist/file.d.ts +2 -2
  18. package/dist/file.js +3 -1
  19. package/dist/graph.d.cts +1 -1
  20. package/dist/graph.d.ts +1 -1
  21. package/dist/{guards-C6w6KQSY.d.ts → guards-RCnH6re9.d.ts} +1 -1
  22. package/dist/{guards-COBkDtgu.d.cts → guards-u-dAAtl8.d.cts} +1 -1
  23. package/dist/http.d.cts +2 -2
  24. package/dist/http.d.ts +2 -2
  25. package/dist/{index-CX7yfAGI.d.ts → index-2TMYDLjK.d.ts} +1 -1
  26. package/dist/index-6-ZZCX9W.d.ts +24 -0
  27. package/dist/index-B2nnOQjf.d.cts +24 -0
  28. package/dist/{index-DkThxxxq.d.cts → index-BgFaJtnv.d.ts} +9 -3
  29. package/dist/index-Bj7a0aSM.d.cts +5 -0
  30. package/dist/{index-dgiKWRpD.d.cts → index-Bw2oMIM1.d.cts} +3 -3
  31. package/dist/{index-gDZYBeJw.d.cts → index-C1za72gL.d.cts} +1 -1
  32. package/dist/index-CW-ztJjd.d.ts +5 -0
  33. package/dist/{index-DjThtAn4.d.ts → index-DF7CbpYW.d.ts} +2 -2
  34. package/dist/{index-CPXo4cA8.d.cts → index-D_WLsIMP.d.cts} +2 -2
  35. package/dist/{index-B5w-X5V6.d.ts → index-DbAnYRRM.d.ts} +1 -1
  36. package/dist/{index-jWtEIa7j.d.ts → index-DbQ-J072.d.cts} +9 -3
  37. package/dist/{index-CnY3KmAg.d.ts → index-DfRcRYF2.d.ts} +1 -1
  38. package/dist/{index-DZe5evGM.d.cts → index-DpnCCtXt.d.cts} +1 -1
  39. package/dist/{index-CwFC71XK.d.ts → index-DzHcy3vy.d.ts} +2 -2
  40. package/dist/{index-9l1xMEl_.d.ts → index-UwSVys3m.d.ts} +3 -3
  41. package/dist/{index-Dr81DOsC.d.cts → index-c9FD2S5f.d.cts} +2 -2
  42. package/dist/{index-D-BjRrJo.d.cts → index-sdprVPKQ.d.cts} +1 -1
  43. package/dist/index.cjs +2 -2
  44. package/dist/index.d.cts +15 -15
  45. package/dist/index.d.ts +15 -15
  46. package/dist/index.js +2 -2
  47. package/dist/json.d.cts +1 -1
  48. package/dist/json.d.ts +1 -1
  49. package/dist/macro.d.cts +1 -1
  50. package/dist/macro.d.ts +1 -1
  51. package/dist/node.d.cts +2 -2
  52. package/dist/node.d.ts +2 -2
  53. package/dist/{nodes-CwYIFVt5.js → nodes-ClL1C158.js} +2 -2
  54. package/dist/nodes-ClL1C158.js.map +1 -0
  55. package/dist/{nodes-BT2Ocq0x.cjs → nodes-DEQjVliP.cjs} +2 -2
  56. package/dist/nodes-DEQjVliP.cjs.map +1 -0
  57. package/dist/{operation-BUhPuZMY.d.cts → operation-AFw8tzIN.d.cts} +21 -5
  58. package/dist/{operation-jxEr2No4.d.ts → operation-Cu4XSaJQ.d.ts} +21 -5
  59. package/dist/ref.d.cts +1 -1
  60. package/dist/ref.d.ts +1 -1
  61. package/dist/schema-gSjYgaCl.cjs.map +1 -1
  62. package/dist/schema-tH14gE6i.js.map +1 -1
  63. package/dist/schema.d.cts +3 -3
  64. package/dist/schema.d.ts +3 -3
  65. package/dist/{visitor-CFbuH7BY.d.ts → visitor-CpmsR8o5.d.ts} +2 -2
  66. package/dist/{visitor-DxhkIQyP.d.cts → visitor-DnBK2MNl.d.cts} +2 -2
  67. package/package.json +1 -1
  68. package/dist/file-BAICym_L.cjs.map +0 -1
  69. package/dist/file-DUFttt26.js +0 -293
  70. package/dist/file-DUFttt26.js.map +0 -1
  71. package/dist/file-Dj9lsbJu.js.map +0 -1
  72. package/dist/file-Dz1HPMld.cjs +0 -329
  73. package/dist/file-Dz1HPMld.cjs.map +0 -1
  74. package/dist/index-Be5d4Zcl.d.ts +0 -24
  75. package/dist/index-CI6Tu2c7.d.ts +0 -5
  76. package/dist/index-DuDvNFQ8.d.cts +0 -5
  77. package/dist/index-ss1YqjpW.d.cts +0 -24
  78. package/dist/nodes-BT2Ocq0x.cjs.map +0 -1
  79. package/dist/nodes-CwYIFVt5.js.map +0 -1
@@ -55,7 +55,7 @@ type PrimitiveSchemaType = 'string' | 'number' | 'integer' | 'bigint' | 'boolean
55
55
  */
56
56
  type SchemaType = keyof SchemaNodeByType;
57
57
  /**
58
- * Scalar schema types without extra object/array/ref structure or constraints.
58
+ * Scalar schema types without extra object/array/ref structure or constraints. `blob` stays for compatibility, but a blob node is a `BlobSchemaNode`.
59
59
  */
60
60
  type ScalarSchemaType = 'boolean' | 'null' | 'any' | 'unknown' | 'void' | 'never' | 'blob' | 'ipv4' | 'ipv6';
61
61
  /**
@@ -123,6 +123,8 @@ type SchemaNodeBase = BaseNode & {
123
123
  */
124
124
  format?: string;
125
125
  externalDocs?: ExternalDocs;
126
+ /** Vendor extensions (`x-*` keys) from the source schema, copied as-is. */
127
+ extensions?: Record<string, unknown>;
126
128
  /**
127
129
  * `if`/`then`/`else`, `dependentRequired` and `dependentSchemas`. A required `unknown` property in `if` means "key is present".
128
130
  * Visitors do not walk it.
@@ -544,7 +546,13 @@ type ScalarSchemaNode = SchemaNodeBase & {
544
546
  /**
545
547
  * Schema type discriminator.
546
548
  */
547
- type: ScalarSchemaType;
549
+ type: Exclude<ScalarSchemaType, 'blob'>;
550
+ };
551
+ /** Binary data schema node, such as a `format: binary` string. */
552
+ type BlobSchemaNode = SchemaNodeBase & {
553
+ type: 'blob';
554
+ /** The media type and encoding of the bytes, from `contentMediaType` and `contentEncoding`. */
555
+ content?: StringSchemaNode['content'];
548
556
  };
549
557
  /**
550
558
  * URL schema node.
@@ -626,12 +634,12 @@ type SchemaNodeByType = {
626
634
  url: UrlSchemaNode;
627
635
  ipv4: ScalarSchemaNode;
628
636
  ipv6: ScalarSchemaNode;
629
- blob: ScalarSchemaNode;
637
+ blob: BlobSchemaNode;
630
638
  };
631
639
  /**
632
640
  * Union of all schema node types.
633
641
  */
634
- type SchemaNode = ObjectSchemaNode | ArraySchemaNode | UnionSchemaNode | IntersectionSchemaNode | NotSchemaNode | EnumSchemaNode | RefSchemaNode | DatetimeSchemaNode | DateSchemaNode | TimeSchemaNode | StringSchemaNode | NumberSchemaNode | UrlSchemaNode | FormatStringSchemaNode | ScalarSchemaNode;
642
+ type SchemaNode = ObjectSchemaNode | ArraySchemaNode | UnionSchemaNode | IntersectionSchemaNode | NotSchemaNode | EnumSchemaNode | RefSchemaNode | DatetimeSchemaNode | DateSchemaNode | TimeSchemaNode | StringSchemaNode | NumberSchemaNode | UrlSchemaNode | FormatStringSchemaNode | ScalarSchemaNode | BlobSchemaNode;
635
643
  type CreateSchemaObjectInput = Omit<ObjectSchemaNode, 'kind' | 'properties' | 'primitive'> & {
636
644
  properties?: Array<PropertyNode>;
637
645
  primitive?: 'object';
@@ -921,6 +929,8 @@ type ContentNode = BaseNode & {
921
929
  * Serialization of every part after `prefixEncoding`, for a body sent as an array of parts such as `multipart/mixed`.
922
930
  */
923
931
  itemEncoding?: EncodingNode;
932
+ /** Vendor extensions (`x-*` keys) from the source media type, copied as-is. */
933
+ extensions?: Record<string, unknown>;
924
934
  };
925
935
  /**
926
936
  * Creates a `ContentNode` for a single request-body or response content type.
@@ -994,6 +1004,8 @@ type ParameterNode = BaseNode & {
994
1004
  examples?: Array<ExampleNode>;
995
1005
  deprecated?: boolean;
996
1006
  allowEmptyValue?: boolean;
1007
+ /** Vendor extensions (`x-*` keys) from the source parameter, copied as-is. */
1008
+ extensions?: Record<string, unknown>;
997
1009
  };
998
1010
  type UserParameterNode = Pick<ParameterNode, 'name' | 'in' | 'schema'> & Partial<Omit<ParameterNode, 'kind' | 'name' | 'in' | 'schema'>>;
999
1011
  /**
@@ -1046,6 +1058,8 @@ type RequestBodyNode = BaseNode & {
1046
1058
  * `application/json` and `multipart/form-data`).
1047
1059
  */
1048
1060
  content?: Array<ContentNode>;
1061
+ /** Vendor extensions (`x-*` keys) from the source request body, copied as-is. */
1062
+ extensions?: Record<string, unknown>;
1049
1063
  };
1050
1064
  /**
1051
1065
  * Creates a `RequestBodyNode`.
@@ -1116,6 +1130,8 @@ type ResponseNode = BaseNode & {
1116
1130
  */
1117
1131
  headers?: Array<ParameterNode>;
1118
1132
  links?: Record<string, ResponseLink>;
1133
+ /** Vendor extensions (`x-*` keys) from the source response, copied as-is. */
1134
+ extensions?: Record<string, unknown>;
1119
1135
  };
1120
1136
  /**
1121
1137
  * A link to another operation. `parameters` and `requestBody` hold runtime expressions such as `$response.body#/id`.
@@ -1269,4 +1285,4 @@ declare function createOperation(props: Pick<HttpOperationNode, 'operationId' |
1269
1285
  declare function createOperation(props: Pick<GenericOperationNode, 'operationId'> & Partial<Omit<GenericOperationNode, 'kind' | 'operationId' | 'requestBody'>> & {
1270
1286
  requestBody?: Omit<RequestBodyNode, 'kind'>;
1271
1287
  }): GenericOperationNode;
1272
- export { ArraySchemaNode as A, ScalarSchemaNode as B, ExternalDocs as C, InputTag as D, InputServer as E, NotSchemaNode as F, StringSchemaNode as G, SchemaNode as H, NumberSchemaNode as I, UrlSchemaNode as J, TimeSchemaNode as K, ObjectSchemaNode as L, DatetimeSchemaNode as M, EnumSchemaNode as N, OAuthFlow as O, IntersectionSchemaNode as P, PrimitiveSchemaType as R, AuthScheme as S, InputNode as T, SchemaNodeByType as U, ScalarSchemaType as V, SchemaType as W, PropertyNode as X, createSchema as Y, createProperty as Z, EncodingNode as _, createOperation as a, AuthCredential as b, StatusCode as c, createRequestBody as d, ParameterLocation as f, ContentNode as g, createParameter as h, OperationNode as i, DateSchemaNode as j, createInput as k, createResponse as l, ParameterStyle as m, HttpMethod as n, ResponseLink as o, ParameterNode as p, UnionSchemaNode as q, HttpOperationNode as r, ResponseNode as s, GenericOperationNode as t, RequestBodyNode as u, ExampleNode as v, InputMeta as w, AuthRequirement as x, createContent as y, RefSchemaNode as z };
1288
+ export { ArraySchemaNode as A, RefSchemaNode as B, ExternalDocs as C, InputTag as D, InputServer as E, IntersectionSchemaNode as F, SchemaType as G, ScalarSchemaType as H, NotSchemaNode as I, UnionSchemaNode as J, StringSchemaNode as K, NumberSchemaNode as L, DateSchemaNode as M, DatetimeSchemaNode as N, OAuthFlow as O, EnumSchemaNode as P, createProperty as Q, ObjectSchemaNode as R, AuthScheme as S, InputNode as T, SchemaNode as U, ScalarSchemaNode as V, SchemaNodeByType as W, createSchema as X, UrlSchemaNode as Y, PropertyNode as Z, EncodingNode as _, createOperation as a, AuthCredential as b, StatusCode as c, createRequestBody as d, ParameterLocation as f, ContentNode as g, createParameter as h, OperationNode as i, BlobSchemaNode as j, createInput as k, createResponse as l, ParameterStyle as m, HttpMethod as n, ResponseLink as o, ParameterNode as p, TimeSchemaNode as q, HttpOperationNode as r, ResponseNode as s, GenericOperationNode as t, RequestBodyNode as u, ExampleNode as v, InputMeta as w, AuthRequirement as x, createContent as y, PrimitiveSchemaType as z };
package/dist/ref.d.cts CHANGED
@@ -1,2 +1,2 @@
1
- import { i as isBareRef, o as resolveRef, r as mergeSchema, t as getName } from "./index-DZe5evGM.cjs";
1
+ import { i as isBareRef, o as resolveRef, r as mergeSchema, t as getName } from "./index-DpnCCtXt.cjs";
2
2
  export { getName, resolveRef as getSchema, isBareRef as isAlias, mergeSchema };
package/dist/ref.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { i as isBareRef, o as resolveRef, r as mergeSchema, t as getName } from "./index-CnY3KmAg.js";
1
+ import { i as isBareRef, o as resolveRef, r as mergeSchema, t as getName } from "./index-DfRcRYF2.js";
2
2
  export { getName, resolveRef as getSchema, isBareRef as isAlias, mergeSchema };
@@ -1 +1 @@
1
- {"version":3,"file":"schema-gSjYgaCl.cjs","names":["nodeKinds"],"sources":["../src/nodes/schema.ts"],"sourcesContent":["import { nodeKinds } from '../constants.ts'\nimport type { BaseNode, DistributiveOmit } from './base.ts'\nimport type { ExternalDocs } from './input.ts'\nimport type { PropertyNode } from './property.ts'\n\n/**\n * Subset of {@link SchemaType} covering the primitives plus `object`, `array`, and `date`; `schemaTypes` documents each.\n */\nexport type PrimitiveSchemaType =\n | 'string'\n | 'number'\n | 'integer'\n | 'bigint'\n | 'boolean'\n | 'null'\n | 'any'\n | 'unknown'\n | 'void'\n | 'never'\n | 'object'\n | 'array'\n | 'date'\n\n/**\n * All schema type strings, one per key of {@link SchemaNodeByType}.\n */\nexport type SchemaType = keyof SchemaNodeByType\n\n/**\n * Scalar schema types without extra object/array/ref structure or constraints.\n */\nexport type ScalarSchemaType = 'boolean' | 'null' | 'any' | 'unknown' | 'void' | 'never' | 'blob' | 'ipv4' | 'ipv6'\n\n/**\n * Fields shared by all schema nodes.\n */\ntype SchemaNodeBase = BaseNode & {\n /**\n * Node kind.\n */\n kind: 'Schema'\n /**\n * Schema name for named definitions (for example, `\"Pet\"`).\n * Inline schemas omit this field.\n * `null` means Kubb has processed this and determined there is no applicable name.\n * `undefined` means the name has not been set yet.\n */\n name?: string | null\n /**\n * Short schema title.\n */\n title?: string\n /**\n * Schema description text.\n */\n description?: string\n /**\n * Whether `null` is allowed.\n */\n nullable?: boolean\n /**\n * Whether the field is optional.\n */\n optional?: boolean\n /**\n * Both optional and nullable (`optional` + `nullable`).\n */\n nullish?: boolean\n /**\n * Whether the schema is deprecated.\n */\n deprecated?: boolean\n /**\n * Whether the schema is read-only.\n */\n readOnly?: boolean\n /**\n * Whether the schema is write-only.\n */\n writeOnly?: boolean\n /**\n * Default value.\n */\n default?: unknown\n /**\n * Example values from an `examples` array.\n */\n examples?: Array<unknown>\n /**\n * Base primitive type.\n * For example, this is `'string'` for a `uuid` schema.\n */\n primitive?: PrimitiveSchemaType\n /**\n * Schema `format` value.\n */\n format?: string\n externalDocs?: ExternalDocs\n /**\n * `if`/`then`/`else`, `dependentRequired` and `dependentSchemas`. A required `unknown` property in `if` means \"key is present\".\n * Visitors do not walk it.\n */\n conditionals?: Array<{ if: SchemaNode; then?: SchemaNode; else?: SchemaNode }>\n}\n\n/**\n * Object schema with ordered properties.\n *\n * @example\n * ```ts\n * const objectSchema: ObjectSchemaNode = {\n * kind: 'Schema',\n * type: 'object',\n * properties: [],\n * }\n * ```\n */\nexport type ObjectSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'object'\n /**\n * Primitive type, always `'object'` for object schemas.\n */\n primitive: 'object'\n /**\n * Ordered object properties.\n */\n properties: Array<PropertyNode>\n /**\n * Additional object properties behavior:\n * - `true`: allow any value\n * - `false`: reject unknown properties\n * - `SchemaNode`: allow values that match that schema\n * - `undefined`: no additional properties constraint (open object)\n */\n additionalProperties?: SchemaNode | boolean\n /**\n * Pattern-based property schemas.\n */\n patternProperties?: Record<string, SchemaNode>\n /**\n * Schema that each property name must match.\n *\n * @example\n * ```ts\n * const objectSchema: ObjectSchemaNode = {\n * kind: 'Schema',\n * type: 'object',\n * primitive: 'object',\n * properties: [],\n * propertyNames: { kind: 'Schema', type: 'string', primitive: 'string', pattern: '^[a-z]+$' },\n * }\n * ```\n */\n propertyNames?: SchemaNode\n /**\n * Minimum number of properties allowed.\n */\n min?: number\n /**\n * Maximum number of properties allowed.\n */\n max?: number\n /**\n * @deprecated Use `min`. Removed in Kubb v6.\n */\n minProperties?: number\n /**\n * @deprecated Use `max`. Removed in Kubb v6.\n */\n maxProperties?: number\n}\n\n/**\n * Array-like schema (`array` or `tuple`).\n *\n * @example\n * ```ts\n * const arraySchema: ArraySchemaNode = {\n * kind: 'Schema',\n * type: 'array',\n * items: [],\n * }\n * ```\n */\nexport type ArraySchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator (`array` or `tuple`).\n */\n type: 'array' | 'tuple'\n /**\n * Item schemas.\n */\n items?: Array<SchemaNode>\n /**\n * Tuple rest-item schema for elements beyond positional `items`.\n */\n rest?: SchemaNode\n /**\n * Minimum item count (or tuple length).\n */\n min?: number\n /**\n * Maximum item count (or tuple length).\n */\n max?: number\n /**\n * Whether all items must be unique.\n */\n unique?: boolean\n /**\n * At least `min` (default 1) and at most `max` items match `schema`. Visitors do not walk `schema`.\n */\n contains?: { schema: SchemaNode; min?: number; max?: number }\n}\n\n/**\n * Shared shape for union and intersection schemas.\n */\ntype CompositeSchemaNodeBase = SchemaNodeBase & {\n /**\n * Member schemas.\n */\n members?: Array<SchemaNode>\n}\n\n/**\n * Union schema, often from `oneOf` or `anyOf`.\n *\n * @example\n * ```ts\n * const unionSchema: UnionSchemaNode = {\n * kind: 'Schema',\n * type: 'union',\n * members: [],\n * }\n * ```\n */\nexport type UnionSchemaNode = CompositeSchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'union'\n /**\n * Discriminator property name for a polymorphic union.\n */\n discriminatorPropertyName?: string\n /**\n * How many union members must be valid.\n * - `'one'`: exactly one member, from `oneOf`\n * - `'any'`: any number of members, from `anyOf`\n */\n strategy?: 'one' | 'any'\n}\n\n/**\n * Intersection schema, often from `allOf`.\n *\n * @example\n * ```ts\n * const intersectionSchema: IntersectionSchemaNode = {\n * kind: 'Schema',\n * type: 'intersection',\n * members: [],\n * }\n * ```\n */\nexport type IntersectionSchemaNode = CompositeSchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'intersection'\n}\n\n/** Negation from `not`: the value must not match its single member. Printers that cannot express it return `null`. */\nexport type NotSchemaNode = CompositeSchemaNodeBase & {\n /** Schema type discriminator. */\n type: 'not'\n}\n\n/**\n * One named enum item.\n */\ntype EnumValueNode = {\n /**\n * Enum item name.\n */\n name: string\n /**\n * Enum item value.\n */\n value: string | number | boolean\n /**\n * Primitive type of the enum value.\n */\n primitive: Extract<PrimitiveSchemaType, 'string' | 'number' | 'boolean'>\n /**\n * Label for the enum item, taken from the `x-enumDescriptions` or\n * `x-enum-descriptions` vendor extension. A printer can render it as\n * a comment on the matching enum member.\n */\n description?: string\n}\n\n/**\n * Enum schema node.\n *\n * @example\n * ```ts\n * const enumSchema: EnumSchemaNode = {\n * kind: 'Schema',\n * type: 'enum',\n * enumValues: ['a', 'b'],\n * }\n * ```\n */\nexport type EnumSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'enum'\n /**\n * Enum values in simple form.\n */\n enumValues?: Array<string | number | boolean | null>\n /**\n * Enum values in named form.\n * If present, this is used instead of `enumValues`.\n */\n namedEnumValues?: Array<EnumValueNode>\n}\n\n/**\n * Reference schema that points to another schema definition.\n *\n * @example\n * ```ts\n * const refSchema: RefSchemaNode = {\n * kind: 'Schema',\n * type: 'ref',\n * ref: '#/components/schemas/Pet',\n * }\n * ```\n */\nexport type RefSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'ref'\n /**\n * Referenced schema name.\n * `null` means Kubb has processed this and determined there is no applicable name.\n */\n name?: string | null\n /**\n * Original `$ref` path, for example, `#/components/schemas/Order`.\n * Used to resolve names later.\n */\n ref?: string\n /**\n * Emitted name of the referenced schema when it differs from the pointer's last segment,\n * for example after a collision rename (`Order` becomes `OrderSchema`) or a macro rename.\n * Resolve display and import names through `ast.ref.getName`, which prefers this field and\n * falls back to the pointer segment, then `name`.\n */\n targetName?: string\n /**\n * Pattern copied from a sibling `pattern` field.\n */\n pattern?: string\n /**\n * The fully-parsed schema this ref resolves to, so its structure (`primitive`, `properties`)\n * can be read without following the reference. Populated during parsing when the\n * definition resolves, `null` when it can't or the ref is circular, and `undefined` when\n * resolution has not been attempted.\n */\n schema?: SchemaNode | null\n}\n\n/**\n * Datetime schema.\n *\n * @example\n * ```ts\n * const datetimeSchema: DatetimeSchemaNode = { kind: 'Schema', type: 'datetime' }\n * ```\n */\nexport type DatetimeSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'datetime'\n /**\n * Whether the datetime includes a timezone offset (`dateType: 'stringOffset'`).\n */\n offset?: boolean\n /**\n * Whether the datetime is local (no timezone, `dateType: 'stringLocal'`).\n */\n local?: boolean\n}\n\n/**\n * Shared base for `date` and `time` schemas.\n */\ntype TemporalSchemaNodeBase<T extends 'date' | 'time'> = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: T\n /**\n * Output representation in generated code.\n */\n representation: 'date' | 'string'\n}\n\n/**\n * Date schema node.\n *\n * @example\n * ```ts\n * const dateSchema: DateSchemaNode = { kind: 'Schema', type: 'date', representation: 'string' }\n * ```\n */\nexport type DateSchemaNode = TemporalSchemaNodeBase<'date'>\n\n/**\n * Time schema node.\n *\n * @example\n * ```ts\n * const timeSchema: TimeSchemaNode = { kind: 'Schema', type: 'time', representation: 'string' }\n * ```\n */\nexport type TimeSchemaNode = TemporalSchemaNodeBase<'time'>\n\n/**\n * String schema node.\n *\n * @example\n * ```ts\n * const stringSchema: StringSchemaNode = { kind: 'Schema', type: 'string' }\n * ```\n */\nexport type StringSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'string'\n /**\n * Minimum string length.\n */\n min?: number\n /**\n * Maximum string length.\n */\n max?: number\n /**\n * Regex pattern.\n */\n pattern?: string\n /**\n * The value the string encodes, such as a JSON document or `base64` bytes. Visitors do not walk `schema`.\n */\n content?: {\n mediaType?: string\n encoding?: string\n schema?: SchemaNode\n }\n}\n\n/**\n * Numeric schema (`number`, `integer`, or `bigint`).\n *\n * @example\n * ```ts\n * const numberSchema: NumberSchemaNode = { kind: 'Schema', type: 'number' }\n * ```\n */\nexport type NumberSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'number' | 'integer' | 'bigint'\n /**\n * Minimum value.\n */\n min?: number\n /**\n * Maximum value.\n */\n max?: number\n /**\n * Bounds the value may not equal: it must be greater than `min` and less than `max`.\n */\n exclusive?: { min?: number; max?: number }\n /**\n * @deprecated Use `exclusive.min`. Removed in Kubb v6.\n */\n exclusiveMinimum?: number\n /**\n * @deprecated Use `exclusive.max`. Removed in Kubb v6.\n */\n exclusiveMaximum?: number\n /**\n * The value must be a multiple of this number.\n */\n multipleOf?: number\n}\n\n/**\n * Scalar schema with no extra constraints.\n *\n * @example\n * ```ts\n * const anySchema: ScalarSchemaNode = { kind: 'Schema', type: 'any' }\n * ```\n */\nexport type ScalarSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: ScalarSchemaType\n}\n\n/**\n * URL schema node.\n * Can include a path template for template literal types.\n *\n * @example\n * ```ts\n * const urlSchema: UrlSchemaNode = { kind: 'Schema', type: 'url', path: '/pets/{petId}' }\n * ```\n */\nexport type UrlSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'url'\n /**\n * Path template, for example, `'/pets/{petId}'`.\n */\n path?: string\n /**\n * Minimum string length.\n */\n min?: number\n /**\n * Maximum string length.\n */\n max?: number\n}\n\n/**\n * Format-string schema for string-based formats that support length constraints.\n *\n * @example\n * ```ts\n * const uuidSchema: FormatStringSchemaNode = { kind: 'Schema', type: 'uuid', min: 36, max: 36 }\n * ```\n */\ntype FormatStringSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'uuid' | 'email'\n /**\n * Minimum string length.\n */\n min?: number\n /**\n * Maximum string length.\n */\n max?: number\n}\n\n/**\n * Mapping from schema type literals to concrete schema node types.\n * Used by `narrowSchema`.\n */\nexport type SchemaNodeByType = {\n object: ObjectSchemaNode\n array: ArraySchemaNode\n tuple: ArraySchemaNode\n union: UnionSchemaNode\n intersection: IntersectionSchemaNode\n not: NotSchemaNode\n enum: EnumSchemaNode\n ref: RefSchemaNode\n datetime: DatetimeSchemaNode\n date: DateSchemaNode\n time: TimeSchemaNode\n string: StringSchemaNode\n number: NumberSchemaNode\n integer: NumberSchemaNode\n bigint: NumberSchemaNode\n boolean: ScalarSchemaNode\n null: ScalarSchemaNode\n any: ScalarSchemaNode\n unknown: ScalarSchemaNode\n void: ScalarSchemaNode\n never: ScalarSchemaNode\n uuid: FormatStringSchemaNode\n email: FormatStringSchemaNode\n url: UrlSchemaNode\n ipv4: ScalarSchemaNode\n ipv6: ScalarSchemaNode\n blob: ScalarSchemaNode\n}\n\n/**\n * Union of all schema node types.\n */\nexport type SchemaNode =\n | ObjectSchemaNode\n | ArraySchemaNode\n | UnionSchemaNode\n | IntersectionSchemaNode\n | NotSchemaNode\n | EnumSchemaNode\n | RefSchemaNode\n | DatetimeSchemaNode\n | DateSchemaNode\n | TimeSchemaNode\n | StringSchemaNode\n | NumberSchemaNode\n | UrlSchemaNode\n | FormatStringSchemaNode\n | ScalarSchemaNode\n\ntype CreateSchemaObjectInput = Omit<ObjectSchemaNode, 'kind' | 'properties' | 'primitive'> & { properties?: Array<PropertyNode>; primitive?: 'object' }\ntype CreateSchemaInput = CreateSchemaObjectInput | DistributiveOmit<Exclude<SchemaNode, ObjectSchemaNode>, 'kind'>\ntype CreateSchemaOutput<T extends CreateSchemaInput> = SchemaNodeByType[T['type']] & { kind: 'Schema' }\n\n/**\n * Maps schema `type` to its underlying `primitive`.\n * Primitive types map to themselves and special string formats map to `'string'`.\n * Any type not listed here (such as `ref`, `enum`, `union`, `intersection`, `not`, `tuple`, `ipv4`, `ipv6`, `blob`) has no `primitive`.\n */\nconst TYPE_TO_PRIMITIVE: Partial<Record<SchemaNode['type'], PrimitiveSchemaType>> = {\n string: 'string',\n number: 'number',\n integer: 'integer',\n bigint: 'bigint',\n boolean: 'boolean',\n null: 'null',\n any: 'any',\n unknown: 'unknown',\n void: 'void',\n never: 'never',\n object: 'object',\n array: 'array',\n date: 'date',\n uuid: 'string',\n email: 'string',\n url: 'string',\n datetime: 'string',\n time: 'string',\n}\n\n/**\n * Creates a `SchemaNode`, narrowed to the variant of `props.type`. Object schemas default\n * `properties` to an empty array, and `primitive` is inferred from `type` when not explicitly provided.\n *\n * @example\n * ```ts\n * const scalar = createSchema({ type: 'string' })\n * // { kind: 'Schema', type: 'string', primitive: 'string' }\n * ```\n *\n * @example\n * ```ts\n * const object = createSchema({ type: 'object' })\n * // { kind: 'Schema', type: 'object', primitive: 'object', properties: [] }\n * ```\n */\nexport function createSchema<T extends CreateSchemaInput>(props: T): CreateSchemaOutput<T>\nexport function createSchema(props: CreateSchemaInput): SchemaNode\nexport function createSchema(props: CreateSchemaInput): SchemaNode {\n if (props.type === 'object') {\n return { properties: [], primitive: 'object', ...props, kind: nodeKinds.schema }\n }\n\n return { primitive: TYPE_TO_PRIMITIVE[props.type], ...props, kind: nodeKinds.schema }\n}\n"],"mappings":";;;;;;;;AAioBA,MAAM,oBAA8E;CAClF,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,SAAS;CACT,MAAM;CACN,KAAK;CACL,SAAS;CACT,MAAM;CACN,OAAO;CACP,QAAQ;CACR,OAAO;CACP,MAAM;CACN,MAAM;CACN,OAAO;CACP,KAAK;CACL,UAAU;CACV,MAAM;AACR;AAoBA,SAAgB,aAAa,OAAsC;CACjE,IAAI,MAAM,SAAS,UACjB,OAAO;EAAE,YAAY,CAAC;EAAG,WAAW;EAAU,GAAG;EAAO,MAAMA,kBAAAA,UAAU;CAAO;CAGjF,OAAO;EAAE,WAAW,kBAAkB,MAAM;EAAO,GAAG;EAAO,MAAMA,kBAAAA,UAAU;CAAO;AACtF"}
1
+ {"version":3,"file":"schema-gSjYgaCl.cjs","names":["nodeKinds"],"sources":["../src/nodes/schema.ts"],"sourcesContent":["import { nodeKinds } from '../constants.ts'\nimport type { BaseNode, DistributiveOmit } from './base.ts'\nimport type { ExternalDocs } from './input.ts'\nimport type { PropertyNode } from './property.ts'\n\n/**\n * Subset of {@link SchemaType} covering the primitives plus `object`, `array`, and `date`; `schemaTypes` documents each.\n */\nexport type PrimitiveSchemaType =\n | 'string'\n | 'number'\n | 'integer'\n | 'bigint'\n | 'boolean'\n | 'null'\n | 'any'\n | 'unknown'\n | 'void'\n | 'never'\n | 'object'\n | 'array'\n | 'date'\n\n/**\n * All schema type strings, one per key of {@link SchemaNodeByType}.\n */\nexport type SchemaType = keyof SchemaNodeByType\n\n/**\n * Scalar schema types without extra object/array/ref structure or constraints. `blob` stays for compatibility, but a blob node is a `BlobSchemaNode`.\n */\nexport type ScalarSchemaType = 'boolean' | 'null' | 'any' | 'unknown' | 'void' | 'never' | 'blob' | 'ipv4' | 'ipv6'\n\n/**\n * Fields shared by all schema nodes.\n */\ntype SchemaNodeBase = BaseNode & {\n /**\n * Node kind.\n */\n kind: 'Schema'\n /**\n * Schema name for named definitions (for example, `\"Pet\"`).\n * Inline schemas omit this field.\n * `null` means Kubb has processed this and determined there is no applicable name.\n * `undefined` means the name has not been set yet.\n */\n name?: string | null\n /**\n * Short schema title.\n */\n title?: string\n /**\n * Schema description text.\n */\n description?: string\n /**\n * Whether `null` is allowed.\n */\n nullable?: boolean\n /**\n * Whether the field is optional.\n */\n optional?: boolean\n /**\n * Both optional and nullable (`optional` + `nullable`).\n */\n nullish?: boolean\n /**\n * Whether the schema is deprecated.\n */\n deprecated?: boolean\n /**\n * Whether the schema is read-only.\n */\n readOnly?: boolean\n /**\n * Whether the schema is write-only.\n */\n writeOnly?: boolean\n /**\n * Default value.\n */\n default?: unknown\n /**\n * Example values from an `examples` array.\n */\n examples?: Array<unknown>\n /**\n * Base primitive type.\n * For example, this is `'string'` for a `uuid` schema.\n */\n primitive?: PrimitiveSchemaType\n /**\n * Schema `format` value.\n */\n format?: string\n externalDocs?: ExternalDocs\n /** Vendor extensions (`x-*` keys) from the source schema, copied as-is. */\n extensions?: Record<string, unknown>\n /**\n * `if`/`then`/`else`, `dependentRequired` and `dependentSchemas`. A required `unknown` property in `if` means \"key is present\".\n * Visitors do not walk it.\n */\n conditionals?: Array<{ if: SchemaNode; then?: SchemaNode; else?: SchemaNode }>\n}\n\n/**\n * Object schema with ordered properties.\n *\n * @example\n * ```ts\n * const objectSchema: ObjectSchemaNode = {\n * kind: 'Schema',\n * type: 'object',\n * properties: [],\n * }\n * ```\n */\nexport type ObjectSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'object'\n /**\n * Primitive type, always `'object'` for object schemas.\n */\n primitive: 'object'\n /**\n * Ordered object properties.\n */\n properties: Array<PropertyNode>\n /**\n * Additional object properties behavior:\n * - `true`: allow any value\n * - `false`: reject unknown properties\n * - `SchemaNode`: allow values that match that schema\n * - `undefined`: no additional properties constraint (open object)\n */\n additionalProperties?: SchemaNode | boolean\n /**\n * Pattern-based property schemas.\n */\n patternProperties?: Record<string, SchemaNode>\n /**\n * Schema that each property name must match.\n *\n * @example\n * ```ts\n * const objectSchema: ObjectSchemaNode = {\n * kind: 'Schema',\n * type: 'object',\n * primitive: 'object',\n * properties: [],\n * propertyNames: { kind: 'Schema', type: 'string', primitive: 'string', pattern: '^[a-z]+$' },\n * }\n * ```\n */\n propertyNames?: SchemaNode\n /**\n * Minimum number of properties allowed.\n */\n min?: number\n /**\n * Maximum number of properties allowed.\n */\n max?: number\n /**\n * @deprecated Use `min`. Removed in Kubb v6.\n */\n minProperties?: number\n /**\n * @deprecated Use `max`. Removed in Kubb v6.\n */\n maxProperties?: number\n}\n\n/**\n * Array-like schema (`array` or `tuple`).\n *\n * @example\n * ```ts\n * const arraySchema: ArraySchemaNode = {\n * kind: 'Schema',\n * type: 'array',\n * items: [],\n * }\n * ```\n */\nexport type ArraySchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator (`array` or `tuple`).\n */\n type: 'array' | 'tuple'\n /**\n * Item schemas.\n */\n items?: Array<SchemaNode>\n /**\n * Tuple rest-item schema for elements beyond positional `items`.\n */\n rest?: SchemaNode\n /**\n * Minimum item count (or tuple length).\n */\n min?: number\n /**\n * Maximum item count (or tuple length).\n */\n max?: number\n /**\n * Whether all items must be unique.\n */\n unique?: boolean\n /**\n * At least `min` (default 1) and at most `max` items match `schema`. Visitors do not walk `schema`.\n */\n contains?: { schema: SchemaNode; min?: number; max?: number }\n}\n\n/**\n * Shared shape for union and intersection schemas.\n */\ntype CompositeSchemaNodeBase = SchemaNodeBase & {\n /**\n * Member schemas.\n */\n members?: Array<SchemaNode>\n}\n\n/**\n * Union schema, often from `oneOf` or `anyOf`.\n *\n * @example\n * ```ts\n * const unionSchema: UnionSchemaNode = {\n * kind: 'Schema',\n * type: 'union',\n * members: [],\n * }\n * ```\n */\nexport type UnionSchemaNode = CompositeSchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'union'\n /**\n * Discriminator property name for a polymorphic union.\n */\n discriminatorPropertyName?: string\n /**\n * How many union members must be valid.\n * - `'one'`: exactly one member, from `oneOf`\n * - `'any'`: any number of members, from `anyOf`\n */\n strategy?: 'one' | 'any'\n}\n\n/**\n * Intersection schema, often from `allOf`.\n *\n * @example\n * ```ts\n * const intersectionSchema: IntersectionSchemaNode = {\n * kind: 'Schema',\n * type: 'intersection',\n * members: [],\n * }\n * ```\n */\nexport type IntersectionSchemaNode = CompositeSchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'intersection'\n}\n\n/** Negation from `not`: the value must not match its single member. Printers that cannot express it return `null`. */\nexport type NotSchemaNode = CompositeSchemaNodeBase & {\n /** Schema type discriminator. */\n type: 'not'\n}\n\n/**\n * One named enum item.\n */\ntype EnumValueNode = {\n /**\n * Enum item name.\n */\n name: string\n /**\n * Enum item value.\n */\n value: string | number | boolean\n /**\n * Primitive type of the enum value.\n */\n primitive: Extract<PrimitiveSchemaType, 'string' | 'number' | 'boolean'>\n /**\n * Label for the enum item, taken from the `x-enumDescriptions` or\n * `x-enum-descriptions` vendor extension. A printer can render it as\n * a comment on the matching enum member.\n */\n description?: string\n}\n\n/**\n * Enum schema node.\n *\n * @example\n * ```ts\n * const enumSchema: EnumSchemaNode = {\n * kind: 'Schema',\n * type: 'enum',\n * enumValues: ['a', 'b'],\n * }\n * ```\n */\nexport type EnumSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'enum'\n /**\n * Enum values in simple form.\n */\n enumValues?: Array<string | number | boolean | null>\n /**\n * Enum values in named form.\n * If present, this is used instead of `enumValues`.\n */\n namedEnumValues?: Array<EnumValueNode>\n}\n\n/**\n * Reference schema that points to another schema definition.\n *\n * @example\n * ```ts\n * const refSchema: RefSchemaNode = {\n * kind: 'Schema',\n * type: 'ref',\n * ref: '#/components/schemas/Pet',\n * }\n * ```\n */\nexport type RefSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'ref'\n /**\n * Referenced schema name.\n * `null` means Kubb has processed this and determined there is no applicable name.\n */\n name?: string | null\n /**\n * Original `$ref` path, for example, `#/components/schemas/Order`.\n * Used to resolve names later.\n */\n ref?: string\n /**\n * Emitted name of the referenced schema when it differs from the pointer's last segment,\n * for example after a collision rename (`Order` becomes `OrderSchema`) or a macro rename.\n * Resolve display and import names through `ast.ref.getName`, which prefers this field and\n * falls back to the pointer segment, then `name`.\n */\n targetName?: string\n /**\n * Pattern copied from a sibling `pattern` field.\n */\n pattern?: string\n /**\n * The fully-parsed schema this ref resolves to, so its structure (`primitive`, `properties`)\n * can be read without following the reference. Populated during parsing when the\n * definition resolves, `null` when it can't or the ref is circular, and `undefined` when\n * resolution has not been attempted.\n */\n schema?: SchemaNode | null\n}\n\n/**\n * Datetime schema.\n *\n * @example\n * ```ts\n * const datetimeSchema: DatetimeSchemaNode = { kind: 'Schema', type: 'datetime' }\n * ```\n */\nexport type DatetimeSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'datetime'\n /**\n * Whether the datetime includes a timezone offset (`dateType: 'stringOffset'`).\n */\n offset?: boolean\n /**\n * Whether the datetime is local (no timezone, `dateType: 'stringLocal'`).\n */\n local?: boolean\n}\n\n/**\n * Shared base for `date` and `time` schemas.\n */\ntype TemporalSchemaNodeBase<T extends 'date' | 'time'> = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: T\n /**\n * Output representation in generated code.\n */\n representation: 'date' | 'string'\n}\n\n/**\n * Date schema node.\n *\n * @example\n * ```ts\n * const dateSchema: DateSchemaNode = { kind: 'Schema', type: 'date', representation: 'string' }\n * ```\n */\nexport type DateSchemaNode = TemporalSchemaNodeBase<'date'>\n\n/**\n * Time schema node.\n *\n * @example\n * ```ts\n * const timeSchema: TimeSchemaNode = { kind: 'Schema', type: 'time', representation: 'string' }\n * ```\n */\nexport type TimeSchemaNode = TemporalSchemaNodeBase<'time'>\n\n/**\n * String schema node.\n *\n * @example\n * ```ts\n * const stringSchema: StringSchemaNode = { kind: 'Schema', type: 'string' }\n * ```\n */\nexport type StringSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'string'\n /**\n * Minimum string length.\n */\n min?: number\n /**\n * Maximum string length.\n */\n max?: number\n /**\n * Regex pattern.\n */\n pattern?: string\n /**\n * The value the string encodes, such as a JSON document or `base64` bytes. Visitors do not walk `schema`.\n */\n content?: {\n mediaType?: string\n encoding?: string\n schema?: SchemaNode\n }\n}\n\n/**\n * Numeric schema (`number`, `integer`, or `bigint`).\n *\n * @example\n * ```ts\n * const numberSchema: NumberSchemaNode = { kind: 'Schema', type: 'number' }\n * ```\n */\nexport type NumberSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'number' | 'integer' | 'bigint'\n /**\n * Minimum value.\n */\n min?: number\n /**\n * Maximum value.\n */\n max?: number\n /**\n * Bounds the value may not equal: it must be greater than `min` and less than `max`.\n */\n exclusive?: { min?: number; max?: number }\n /**\n * @deprecated Use `exclusive.min`. Removed in Kubb v6.\n */\n exclusiveMinimum?: number\n /**\n * @deprecated Use `exclusive.max`. Removed in Kubb v6.\n */\n exclusiveMaximum?: number\n /**\n * The value must be a multiple of this number.\n */\n multipleOf?: number\n}\n\n/**\n * Scalar schema with no extra constraints.\n *\n * @example\n * ```ts\n * const anySchema: ScalarSchemaNode = { kind: 'Schema', type: 'any' }\n * ```\n */\nexport type ScalarSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: Exclude<ScalarSchemaType, 'blob'>\n}\n\n/** Binary data schema node, such as a `format: binary` string. */\nexport type BlobSchemaNode = SchemaNodeBase & {\n type: 'blob'\n /** The media type and encoding of the bytes, from `contentMediaType` and `contentEncoding`. */\n content?: StringSchemaNode['content']\n}\n\n/**\n * URL schema node.\n * Can include a path template for template literal types.\n *\n * @example\n * ```ts\n * const urlSchema: UrlSchemaNode = { kind: 'Schema', type: 'url', path: '/pets/{petId}' }\n * ```\n */\nexport type UrlSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'url'\n /**\n * Path template, for example, `'/pets/{petId}'`.\n */\n path?: string\n /**\n * Minimum string length.\n */\n min?: number\n /**\n * Maximum string length.\n */\n max?: number\n}\n\n/**\n * Format-string schema for string-based formats that support length constraints.\n *\n * @example\n * ```ts\n * const uuidSchema: FormatStringSchemaNode = { kind: 'Schema', type: 'uuid', min: 36, max: 36 }\n * ```\n */\ntype FormatStringSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'uuid' | 'email'\n /**\n * Minimum string length.\n */\n min?: number\n /**\n * Maximum string length.\n */\n max?: number\n}\n\n/**\n * Mapping from schema type literals to concrete schema node types.\n * Used by `narrowSchema`.\n */\nexport type SchemaNodeByType = {\n object: ObjectSchemaNode\n array: ArraySchemaNode\n tuple: ArraySchemaNode\n union: UnionSchemaNode\n intersection: IntersectionSchemaNode\n not: NotSchemaNode\n enum: EnumSchemaNode\n ref: RefSchemaNode\n datetime: DatetimeSchemaNode\n date: DateSchemaNode\n time: TimeSchemaNode\n string: StringSchemaNode\n number: NumberSchemaNode\n integer: NumberSchemaNode\n bigint: NumberSchemaNode\n boolean: ScalarSchemaNode\n null: ScalarSchemaNode\n any: ScalarSchemaNode\n unknown: ScalarSchemaNode\n void: ScalarSchemaNode\n never: ScalarSchemaNode\n uuid: FormatStringSchemaNode\n email: FormatStringSchemaNode\n url: UrlSchemaNode\n ipv4: ScalarSchemaNode\n ipv6: ScalarSchemaNode\n blob: BlobSchemaNode\n}\n\n/**\n * Union of all schema node types.\n */\nexport type SchemaNode =\n | ObjectSchemaNode\n | ArraySchemaNode\n | UnionSchemaNode\n | IntersectionSchemaNode\n | NotSchemaNode\n | EnumSchemaNode\n | RefSchemaNode\n | DatetimeSchemaNode\n | DateSchemaNode\n | TimeSchemaNode\n | StringSchemaNode\n | NumberSchemaNode\n | UrlSchemaNode\n | FormatStringSchemaNode\n | ScalarSchemaNode\n | BlobSchemaNode\n\ntype CreateSchemaObjectInput = Omit<ObjectSchemaNode, 'kind' | 'properties' | 'primitive'> & { properties?: Array<PropertyNode>; primitive?: 'object' }\ntype CreateSchemaInput = CreateSchemaObjectInput | DistributiveOmit<Exclude<SchemaNode, ObjectSchemaNode>, 'kind'>\ntype CreateSchemaOutput<T extends CreateSchemaInput> = SchemaNodeByType[T['type']] & { kind: 'Schema' }\n\n/**\n * Maps schema `type` to its underlying `primitive`.\n * Primitive types map to themselves and special string formats map to `'string'`.\n * Any type not listed here (such as `ref`, `enum`, `union`, `intersection`, `not`, `tuple`, `ipv4`, `ipv6`, `blob`) has no `primitive`.\n */\nconst TYPE_TO_PRIMITIVE: Partial<Record<SchemaNode['type'], PrimitiveSchemaType>> = {\n string: 'string',\n number: 'number',\n integer: 'integer',\n bigint: 'bigint',\n boolean: 'boolean',\n null: 'null',\n any: 'any',\n unknown: 'unknown',\n void: 'void',\n never: 'never',\n object: 'object',\n array: 'array',\n date: 'date',\n uuid: 'string',\n email: 'string',\n url: 'string',\n datetime: 'string',\n time: 'string',\n}\n\n/**\n * Creates a `SchemaNode`, narrowed to the variant of `props.type`. Object schemas default\n * `properties` to an empty array, and `primitive` is inferred from `type` when not explicitly provided.\n *\n * @example\n * ```ts\n * const scalar = createSchema({ type: 'string' })\n * // { kind: 'Schema', type: 'string', primitive: 'string' }\n * ```\n *\n * @example\n * ```ts\n * const object = createSchema({ type: 'object' })\n * // { kind: 'Schema', type: 'object', primitive: 'object', properties: [] }\n * ```\n */\nexport function createSchema<T extends CreateSchemaInput>(props: T): CreateSchemaOutput<T>\nexport function createSchema(props: CreateSchemaInput): SchemaNode\nexport function createSchema(props: CreateSchemaInput): SchemaNode {\n if (props.type === 'object') {\n return { properties: [], primitive: 'object', ...props, kind: nodeKinds.schema }\n }\n\n return { primitive: TYPE_TO_PRIMITIVE[props.type], ...props, kind: nodeKinds.schema }\n}\n"],"mappings":";;;;;;;;AA2oBA,MAAM,oBAA8E;CAClF,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,SAAS;CACT,MAAM;CACN,KAAK;CACL,SAAS;CACT,MAAM;CACN,OAAO;CACP,QAAQ;CACR,OAAO;CACP,MAAM;CACN,MAAM;CACN,OAAO;CACP,KAAK;CACL,UAAU;CACV,MAAM;AACR;AAoBA,SAAgB,aAAa,OAAsC;CACjE,IAAI,MAAM,SAAS,UACjB,OAAO;EAAE,YAAY,CAAC;EAAG,WAAW;EAAU,GAAG;EAAO,MAAMA,kBAAAA,UAAU;CAAO;CAGjF,OAAO;EAAE,WAAW,kBAAkB,MAAM;EAAO,GAAG;EAAO,MAAMA,kBAAAA,UAAU;CAAO;AACtF"}
@@ -1 +1 @@
1
- {"version":3,"file":"schema-tH14gE6i.js","names":[],"sources":["../src/nodes/schema.ts"],"sourcesContent":["import { nodeKinds } from '../constants.ts'\nimport type { BaseNode, DistributiveOmit } from './base.ts'\nimport type { ExternalDocs } from './input.ts'\nimport type { PropertyNode } from './property.ts'\n\n/**\n * Subset of {@link SchemaType} covering the primitives plus `object`, `array`, and `date`; `schemaTypes` documents each.\n */\nexport type PrimitiveSchemaType =\n | 'string'\n | 'number'\n | 'integer'\n | 'bigint'\n | 'boolean'\n | 'null'\n | 'any'\n | 'unknown'\n | 'void'\n | 'never'\n | 'object'\n | 'array'\n | 'date'\n\n/**\n * All schema type strings, one per key of {@link SchemaNodeByType}.\n */\nexport type SchemaType = keyof SchemaNodeByType\n\n/**\n * Scalar schema types without extra object/array/ref structure or constraints.\n */\nexport type ScalarSchemaType = 'boolean' | 'null' | 'any' | 'unknown' | 'void' | 'never' | 'blob' | 'ipv4' | 'ipv6'\n\n/**\n * Fields shared by all schema nodes.\n */\ntype SchemaNodeBase = BaseNode & {\n /**\n * Node kind.\n */\n kind: 'Schema'\n /**\n * Schema name for named definitions (for example, `\"Pet\"`).\n * Inline schemas omit this field.\n * `null` means Kubb has processed this and determined there is no applicable name.\n * `undefined` means the name has not been set yet.\n */\n name?: string | null\n /**\n * Short schema title.\n */\n title?: string\n /**\n * Schema description text.\n */\n description?: string\n /**\n * Whether `null` is allowed.\n */\n nullable?: boolean\n /**\n * Whether the field is optional.\n */\n optional?: boolean\n /**\n * Both optional and nullable (`optional` + `nullable`).\n */\n nullish?: boolean\n /**\n * Whether the schema is deprecated.\n */\n deprecated?: boolean\n /**\n * Whether the schema is read-only.\n */\n readOnly?: boolean\n /**\n * Whether the schema is write-only.\n */\n writeOnly?: boolean\n /**\n * Default value.\n */\n default?: unknown\n /**\n * Example values from an `examples` array.\n */\n examples?: Array<unknown>\n /**\n * Base primitive type.\n * For example, this is `'string'` for a `uuid` schema.\n */\n primitive?: PrimitiveSchemaType\n /**\n * Schema `format` value.\n */\n format?: string\n externalDocs?: ExternalDocs\n /**\n * `if`/`then`/`else`, `dependentRequired` and `dependentSchemas`. A required `unknown` property in `if` means \"key is present\".\n * Visitors do not walk it.\n */\n conditionals?: Array<{ if: SchemaNode; then?: SchemaNode; else?: SchemaNode }>\n}\n\n/**\n * Object schema with ordered properties.\n *\n * @example\n * ```ts\n * const objectSchema: ObjectSchemaNode = {\n * kind: 'Schema',\n * type: 'object',\n * properties: [],\n * }\n * ```\n */\nexport type ObjectSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'object'\n /**\n * Primitive type, always `'object'` for object schemas.\n */\n primitive: 'object'\n /**\n * Ordered object properties.\n */\n properties: Array<PropertyNode>\n /**\n * Additional object properties behavior:\n * - `true`: allow any value\n * - `false`: reject unknown properties\n * - `SchemaNode`: allow values that match that schema\n * - `undefined`: no additional properties constraint (open object)\n */\n additionalProperties?: SchemaNode | boolean\n /**\n * Pattern-based property schemas.\n */\n patternProperties?: Record<string, SchemaNode>\n /**\n * Schema that each property name must match.\n *\n * @example\n * ```ts\n * const objectSchema: ObjectSchemaNode = {\n * kind: 'Schema',\n * type: 'object',\n * primitive: 'object',\n * properties: [],\n * propertyNames: { kind: 'Schema', type: 'string', primitive: 'string', pattern: '^[a-z]+$' },\n * }\n * ```\n */\n propertyNames?: SchemaNode\n /**\n * Minimum number of properties allowed.\n */\n min?: number\n /**\n * Maximum number of properties allowed.\n */\n max?: number\n /**\n * @deprecated Use `min`. Removed in Kubb v6.\n */\n minProperties?: number\n /**\n * @deprecated Use `max`. Removed in Kubb v6.\n */\n maxProperties?: number\n}\n\n/**\n * Array-like schema (`array` or `tuple`).\n *\n * @example\n * ```ts\n * const arraySchema: ArraySchemaNode = {\n * kind: 'Schema',\n * type: 'array',\n * items: [],\n * }\n * ```\n */\nexport type ArraySchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator (`array` or `tuple`).\n */\n type: 'array' | 'tuple'\n /**\n * Item schemas.\n */\n items?: Array<SchemaNode>\n /**\n * Tuple rest-item schema for elements beyond positional `items`.\n */\n rest?: SchemaNode\n /**\n * Minimum item count (or tuple length).\n */\n min?: number\n /**\n * Maximum item count (or tuple length).\n */\n max?: number\n /**\n * Whether all items must be unique.\n */\n unique?: boolean\n /**\n * At least `min` (default 1) and at most `max` items match `schema`. Visitors do not walk `schema`.\n */\n contains?: { schema: SchemaNode; min?: number; max?: number }\n}\n\n/**\n * Shared shape for union and intersection schemas.\n */\ntype CompositeSchemaNodeBase = SchemaNodeBase & {\n /**\n * Member schemas.\n */\n members?: Array<SchemaNode>\n}\n\n/**\n * Union schema, often from `oneOf` or `anyOf`.\n *\n * @example\n * ```ts\n * const unionSchema: UnionSchemaNode = {\n * kind: 'Schema',\n * type: 'union',\n * members: [],\n * }\n * ```\n */\nexport type UnionSchemaNode = CompositeSchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'union'\n /**\n * Discriminator property name for a polymorphic union.\n */\n discriminatorPropertyName?: string\n /**\n * How many union members must be valid.\n * - `'one'`: exactly one member, from `oneOf`\n * - `'any'`: any number of members, from `anyOf`\n */\n strategy?: 'one' | 'any'\n}\n\n/**\n * Intersection schema, often from `allOf`.\n *\n * @example\n * ```ts\n * const intersectionSchema: IntersectionSchemaNode = {\n * kind: 'Schema',\n * type: 'intersection',\n * members: [],\n * }\n * ```\n */\nexport type IntersectionSchemaNode = CompositeSchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'intersection'\n}\n\n/** Negation from `not`: the value must not match its single member. Printers that cannot express it return `null`. */\nexport type NotSchemaNode = CompositeSchemaNodeBase & {\n /** Schema type discriminator. */\n type: 'not'\n}\n\n/**\n * One named enum item.\n */\ntype EnumValueNode = {\n /**\n * Enum item name.\n */\n name: string\n /**\n * Enum item value.\n */\n value: string | number | boolean\n /**\n * Primitive type of the enum value.\n */\n primitive: Extract<PrimitiveSchemaType, 'string' | 'number' | 'boolean'>\n /**\n * Label for the enum item, taken from the `x-enumDescriptions` or\n * `x-enum-descriptions` vendor extension. A printer can render it as\n * a comment on the matching enum member.\n */\n description?: string\n}\n\n/**\n * Enum schema node.\n *\n * @example\n * ```ts\n * const enumSchema: EnumSchemaNode = {\n * kind: 'Schema',\n * type: 'enum',\n * enumValues: ['a', 'b'],\n * }\n * ```\n */\nexport type EnumSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'enum'\n /**\n * Enum values in simple form.\n */\n enumValues?: Array<string | number | boolean | null>\n /**\n * Enum values in named form.\n * If present, this is used instead of `enumValues`.\n */\n namedEnumValues?: Array<EnumValueNode>\n}\n\n/**\n * Reference schema that points to another schema definition.\n *\n * @example\n * ```ts\n * const refSchema: RefSchemaNode = {\n * kind: 'Schema',\n * type: 'ref',\n * ref: '#/components/schemas/Pet',\n * }\n * ```\n */\nexport type RefSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'ref'\n /**\n * Referenced schema name.\n * `null` means Kubb has processed this and determined there is no applicable name.\n */\n name?: string | null\n /**\n * Original `$ref` path, for example, `#/components/schemas/Order`.\n * Used to resolve names later.\n */\n ref?: string\n /**\n * Emitted name of the referenced schema when it differs from the pointer's last segment,\n * for example after a collision rename (`Order` becomes `OrderSchema`) or a macro rename.\n * Resolve display and import names through `ast.ref.getName`, which prefers this field and\n * falls back to the pointer segment, then `name`.\n */\n targetName?: string\n /**\n * Pattern copied from a sibling `pattern` field.\n */\n pattern?: string\n /**\n * The fully-parsed schema this ref resolves to, so its structure (`primitive`, `properties`)\n * can be read without following the reference. Populated during parsing when the\n * definition resolves, `null` when it can't or the ref is circular, and `undefined` when\n * resolution has not been attempted.\n */\n schema?: SchemaNode | null\n}\n\n/**\n * Datetime schema.\n *\n * @example\n * ```ts\n * const datetimeSchema: DatetimeSchemaNode = { kind: 'Schema', type: 'datetime' }\n * ```\n */\nexport type DatetimeSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'datetime'\n /**\n * Whether the datetime includes a timezone offset (`dateType: 'stringOffset'`).\n */\n offset?: boolean\n /**\n * Whether the datetime is local (no timezone, `dateType: 'stringLocal'`).\n */\n local?: boolean\n}\n\n/**\n * Shared base for `date` and `time` schemas.\n */\ntype TemporalSchemaNodeBase<T extends 'date' | 'time'> = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: T\n /**\n * Output representation in generated code.\n */\n representation: 'date' | 'string'\n}\n\n/**\n * Date schema node.\n *\n * @example\n * ```ts\n * const dateSchema: DateSchemaNode = { kind: 'Schema', type: 'date', representation: 'string' }\n * ```\n */\nexport type DateSchemaNode = TemporalSchemaNodeBase<'date'>\n\n/**\n * Time schema node.\n *\n * @example\n * ```ts\n * const timeSchema: TimeSchemaNode = { kind: 'Schema', type: 'time', representation: 'string' }\n * ```\n */\nexport type TimeSchemaNode = TemporalSchemaNodeBase<'time'>\n\n/**\n * String schema node.\n *\n * @example\n * ```ts\n * const stringSchema: StringSchemaNode = { kind: 'Schema', type: 'string' }\n * ```\n */\nexport type StringSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'string'\n /**\n * Minimum string length.\n */\n min?: number\n /**\n * Maximum string length.\n */\n max?: number\n /**\n * Regex pattern.\n */\n pattern?: string\n /**\n * The value the string encodes, such as a JSON document or `base64` bytes. Visitors do not walk `schema`.\n */\n content?: {\n mediaType?: string\n encoding?: string\n schema?: SchemaNode\n }\n}\n\n/**\n * Numeric schema (`number`, `integer`, or `bigint`).\n *\n * @example\n * ```ts\n * const numberSchema: NumberSchemaNode = { kind: 'Schema', type: 'number' }\n * ```\n */\nexport type NumberSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'number' | 'integer' | 'bigint'\n /**\n * Minimum value.\n */\n min?: number\n /**\n * Maximum value.\n */\n max?: number\n /**\n * Bounds the value may not equal: it must be greater than `min` and less than `max`.\n */\n exclusive?: { min?: number; max?: number }\n /**\n * @deprecated Use `exclusive.min`. Removed in Kubb v6.\n */\n exclusiveMinimum?: number\n /**\n * @deprecated Use `exclusive.max`. Removed in Kubb v6.\n */\n exclusiveMaximum?: number\n /**\n * The value must be a multiple of this number.\n */\n multipleOf?: number\n}\n\n/**\n * Scalar schema with no extra constraints.\n *\n * @example\n * ```ts\n * const anySchema: ScalarSchemaNode = { kind: 'Schema', type: 'any' }\n * ```\n */\nexport type ScalarSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: ScalarSchemaType\n}\n\n/**\n * URL schema node.\n * Can include a path template for template literal types.\n *\n * @example\n * ```ts\n * const urlSchema: UrlSchemaNode = { kind: 'Schema', type: 'url', path: '/pets/{petId}' }\n * ```\n */\nexport type UrlSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'url'\n /**\n * Path template, for example, `'/pets/{petId}'`.\n */\n path?: string\n /**\n * Minimum string length.\n */\n min?: number\n /**\n * Maximum string length.\n */\n max?: number\n}\n\n/**\n * Format-string schema for string-based formats that support length constraints.\n *\n * @example\n * ```ts\n * const uuidSchema: FormatStringSchemaNode = { kind: 'Schema', type: 'uuid', min: 36, max: 36 }\n * ```\n */\ntype FormatStringSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'uuid' | 'email'\n /**\n * Minimum string length.\n */\n min?: number\n /**\n * Maximum string length.\n */\n max?: number\n}\n\n/**\n * Mapping from schema type literals to concrete schema node types.\n * Used by `narrowSchema`.\n */\nexport type SchemaNodeByType = {\n object: ObjectSchemaNode\n array: ArraySchemaNode\n tuple: ArraySchemaNode\n union: UnionSchemaNode\n intersection: IntersectionSchemaNode\n not: NotSchemaNode\n enum: EnumSchemaNode\n ref: RefSchemaNode\n datetime: DatetimeSchemaNode\n date: DateSchemaNode\n time: TimeSchemaNode\n string: StringSchemaNode\n number: NumberSchemaNode\n integer: NumberSchemaNode\n bigint: NumberSchemaNode\n boolean: ScalarSchemaNode\n null: ScalarSchemaNode\n any: ScalarSchemaNode\n unknown: ScalarSchemaNode\n void: ScalarSchemaNode\n never: ScalarSchemaNode\n uuid: FormatStringSchemaNode\n email: FormatStringSchemaNode\n url: UrlSchemaNode\n ipv4: ScalarSchemaNode\n ipv6: ScalarSchemaNode\n blob: ScalarSchemaNode\n}\n\n/**\n * Union of all schema node types.\n */\nexport type SchemaNode =\n | ObjectSchemaNode\n | ArraySchemaNode\n | UnionSchemaNode\n | IntersectionSchemaNode\n | NotSchemaNode\n | EnumSchemaNode\n | RefSchemaNode\n | DatetimeSchemaNode\n | DateSchemaNode\n | TimeSchemaNode\n | StringSchemaNode\n | NumberSchemaNode\n | UrlSchemaNode\n | FormatStringSchemaNode\n | ScalarSchemaNode\n\ntype CreateSchemaObjectInput = Omit<ObjectSchemaNode, 'kind' | 'properties' | 'primitive'> & { properties?: Array<PropertyNode>; primitive?: 'object' }\ntype CreateSchemaInput = CreateSchemaObjectInput | DistributiveOmit<Exclude<SchemaNode, ObjectSchemaNode>, 'kind'>\ntype CreateSchemaOutput<T extends CreateSchemaInput> = SchemaNodeByType[T['type']] & { kind: 'Schema' }\n\n/**\n * Maps schema `type` to its underlying `primitive`.\n * Primitive types map to themselves and special string formats map to `'string'`.\n * Any type not listed here (such as `ref`, `enum`, `union`, `intersection`, `not`, `tuple`, `ipv4`, `ipv6`, `blob`) has no `primitive`.\n */\nconst TYPE_TO_PRIMITIVE: Partial<Record<SchemaNode['type'], PrimitiveSchemaType>> = {\n string: 'string',\n number: 'number',\n integer: 'integer',\n bigint: 'bigint',\n boolean: 'boolean',\n null: 'null',\n any: 'any',\n unknown: 'unknown',\n void: 'void',\n never: 'never',\n object: 'object',\n array: 'array',\n date: 'date',\n uuid: 'string',\n email: 'string',\n url: 'string',\n datetime: 'string',\n time: 'string',\n}\n\n/**\n * Creates a `SchemaNode`, narrowed to the variant of `props.type`. Object schemas default\n * `properties` to an empty array, and `primitive` is inferred from `type` when not explicitly provided.\n *\n * @example\n * ```ts\n * const scalar = createSchema({ type: 'string' })\n * // { kind: 'Schema', type: 'string', primitive: 'string' }\n * ```\n *\n * @example\n * ```ts\n * const object = createSchema({ type: 'object' })\n * // { kind: 'Schema', type: 'object', primitive: 'object', properties: [] }\n * ```\n */\nexport function createSchema<T extends CreateSchemaInput>(props: T): CreateSchemaOutput<T>\nexport function createSchema(props: CreateSchemaInput): SchemaNode\nexport function createSchema(props: CreateSchemaInput): SchemaNode {\n if (props.type === 'object') {\n return { properties: [], primitive: 'object', ...props, kind: nodeKinds.schema }\n }\n\n return { primitive: TYPE_TO_PRIMITIVE[props.type], ...props, kind: nodeKinds.schema }\n}\n"],"mappings":";;;;;;;;AAioBA,MAAM,oBAA8E;CAClF,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,SAAS;CACT,MAAM;CACN,KAAK;CACL,SAAS;CACT,MAAM;CACN,OAAO;CACP,QAAQ;CACR,OAAO;CACP,MAAM;CACN,MAAM;CACN,OAAO;CACP,KAAK;CACL,UAAU;CACV,MAAM;AACR;AAoBA,SAAgB,aAAa,OAAsC;CACjE,IAAI,MAAM,SAAS,UACjB,OAAO;EAAE,YAAY,CAAC;EAAG,WAAW;EAAU,GAAG;EAAO,MAAM,UAAU;CAAO;CAGjF,OAAO;EAAE,WAAW,kBAAkB,MAAM;EAAO,GAAG;EAAO,MAAM,UAAU;CAAO;AACtF"}
1
+ {"version":3,"file":"schema-tH14gE6i.js","names":[],"sources":["../src/nodes/schema.ts"],"sourcesContent":["import { nodeKinds } from '../constants.ts'\nimport type { BaseNode, DistributiveOmit } from './base.ts'\nimport type { ExternalDocs } from './input.ts'\nimport type { PropertyNode } from './property.ts'\n\n/**\n * Subset of {@link SchemaType} covering the primitives plus `object`, `array`, and `date`; `schemaTypes` documents each.\n */\nexport type PrimitiveSchemaType =\n | 'string'\n | 'number'\n | 'integer'\n | 'bigint'\n | 'boolean'\n | 'null'\n | 'any'\n | 'unknown'\n | 'void'\n | 'never'\n | 'object'\n | 'array'\n | 'date'\n\n/**\n * All schema type strings, one per key of {@link SchemaNodeByType}.\n */\nexport type SchemaType = keyof SchemaNodeByType\n\n/**\n * Scalar schema types without extra object/array/ref structure or constraints. `blob` stays for compatibility, but a blob node is a `BlobSchemaNode`.\n */\nexport type ScalarSchemaType = 'boolean' | 'null' | 'any' | 'unknown' | 'void' | 'never' | 'blob' | 'ipv4' | 'ipv6'\n\n/**\n * Fields shared by all schema nodes.\n */\ntype SchemaNodeBase = BaseNode & {\n /**\n * Node kind.\n */\n kind: 'Schema'\n /**\n * Schema name for named definitions (for example, `\"Pet\"`).\n * Inline schemas omit this field.\n * `null` means Kubb has processed this and determined there is no applicable name.\n * `undefined` means the name has not been set yet.\n */\n name?: string | null\n /**\n * Short schema title.\n */\n title?: string\n /**\n * Schema description text.\n */\n description?: string\n /**\n * Whether `null` is allowed.\n */\n nullable?: boolean\n /**\n * Whether the field is optional.\n */\n optional?: boolean\n /**\n * Both optional and nullable (`optional` + `nullable`).\n */\n nullish?: boolean\n /**\n * Whether the schema is deprecated.\n */\n deprecated?: boolean\n /**\n * Whether the schema is read-only.\n */\n readOnly?: boolean\n /**\n * Whether the schema is write-only.\n */\n writeOnly?: boolean\n /**\n * Default value.\n */\n default?: unknown\n /**\n * Example values from an `examples` array.\n */\n examples?: Array<unknown>\n /**\n * Base primitive type.\n * For example, this is `'string'` for a `uuid` schema.\n */\n primitive?: PrimitiveSchemaType\n /**\n * Schema `format` value.\n */\n format?: string\n externalDocs?: ExternalDocs\n /** Vendor extensions (`x-*` keys) from the source schema, copied as-is. */\n extensions?: Record<string, unknown>\n /**\n * `if`/`then`/`else`, `dependentRequired` and `dependentSchemas`. A required `unknown` property in `if` means \"key is present\".\n * Visitors do not walk it.\n */\n conditionals?: Array<{ if: SchemaNode; then?: SchemaNode; else?: SchemaNode }>\n}\n\n/**\n * Object schema with ordered properties.\n *\n * @example\n * ```ts\n * const objectSchema: ObjectSchemaNode = {\n * kind: 'Schema',\n * type: 'object',\n * properties: [],\n * }\n * ```\n */\nexport type ObjectSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'object'\n /**\n * Primitive type, always `'object'` for object schemas.\n */\n primitive: 'object'\n /**\n * Ordered object properties.\n */\n properties: Array<PropertyNode>\n /**\n * Additional object properties behavior:\n * - `true`: allow any value\n * - `false`: reject unknown properties\n * - `SchemaNode`: allow values that match that schema\n * - `undefined`: no additional properties constraint (open object)\n */\n additionalProperties?: SchemaNode | boolean\n /**\n * Pattern-based property schemas.\n */\n patternProperties?: Record<string, SchemaNode>\n /**\n * Schema that each property name must match.\n *\n * @example\n * ```ts\n * const objectSchema: ObjectSchemaNode = {\n * kind: 'Schema',\n * type: 'object',\n * primitive: 'object',\n * properties: [],\n * propertyNames: { kind: 'Schema', type: 'string', primitive: 'string', pattern: '^[a-z]+$' },\n * }\n * ```\n */\n propertyNames?: SchemaNode\n /**\n * Minimum number of properties allowed.\n */\n min?: number\n /**\n * Maximum number of properties allowed.\n */\n max?: number\n /**\n * @deprecated Use `min`. Removed in Kubb v6.\n */\n minProperties?: number\n /**\n * @deprecated Use `max`. Removed in Kubb v6.\n */\n maxProperties?: number\n}\n\n/**\n * Array-like schema (`array` or `tuple`).\n *\n * @example\n * ```ts\n * const arraySchema: ArraySchemaNode = {\n * kind: 'Schema',\n * type: 'array',\n * items: [],\n * }\n * ```\n */\nexport type ArraySchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator (`array` or `tuple`).\n */\n type: 'array' | 'tuple'\n /**\n * Item schemas.\n */\n items?: Array<SchemaNode>\n /**\n * Tuple rest-item schema for elements beyond positional `items`.\n */\n rest?: SchemaNode\n /**\n * Minimum item count (or tuple length).\n */\n min?: number\n /**\n * Maximum item count (or tuple length).\n */\n max?: number\n /**\n * Whether all items must be unique.\n */\n unique?: boolean\n /**\n * At least `min` (default 1) and at most `max` items match `schema`. Visitors do not walk `schema`.\n */\n contains?: { schema: SchemaNode; min?: number; max?: number }\n}\n\n/**\n * Shared shape for union and intersection schemas.\n */\ntype CompositeSchemaNodeBase = SchemaNodeBase & {\n /**\n * Member schemas.\n */\n members?: Array<SchemaNode>\n}\n\n/**\n * Union schema, often from `oneOf` or `anyOf`.\n *\n * @example\n * ```ts\n * const unionSchema: UnionSchemaNode = {\n * kind: 'Schema',\n * type: 'union',\n * members: [],\n * }\n * ```\n */\nexport type UnionSchemaNode = CompositeSchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'union'\n /**\n * Discriminator property name for a polymorphic union.\n */\n discriminatorPropertyName?: string\n /**\n * How many union members must be valid.\n * - `'one'`: exactly one member, from `oneOf`\n * - `'any'`: any number of members, from `anyOf`\n */\n strategy?: 'one' | 'any'\n}\n\n/**\n * Intersection schema, often from `allOf`.\n *\n * @example\n * ```ts\n * const intersectionSchema: IntersectionSchemaNode = {\n * kind: 'Schema',\n * type: 'intersection',\n * members: [],\n * }\n * ```\n */\nexport type IntersectionSchemaNode = CompositeSchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'intersection'\n}\n\n/** Negation from `not`: the value must not match its single member. Printers that cannot express it return `null`. */\nexport type NotSchemaNode = CompositeSchemaNodeBase & {\n /** Schema type discriminator. */\n type: 'not'\n}\n\n/**\n * One named enum item.\n */\ntype EnumValueNode = {\n /**\n * Enum item name.\n */\n name: string\n /**\n * Enum item value.\n */\n value: string | number | boolean\n /**\n * Primitive type of the enum value.\n */\n primitive: Extract<PrimitiveSchemaType, 'string' | 'number' | 'boolean'>\n /**\n * Label for the enum item, taken from the `x-enumDescriptions` or\n * `x-enum-descriptions` vendor extension. A printer can render it as\n * a comment on the matching enum member.\n */\n description?: string\n}\n\n/**\n * Enum schema node.\n *\n * @example\n * ```ts\n * const enumSchema: EnumSchemaNode = {\n * kind: 'Schema',\n * type: 'enum',\n * enumValues: ['a', 'b'],\n * }\n * ```\n */\nexport type EnumSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'enum'\n /**\n * Enum values in simple form.\n */\n enumValues?: Array<string | number | boolean | null>\n /**\n * Enum values in named form.\n * If present, this is used instead of `enumValues`.\n */\n namedEnumValues?: Array<EnumValueNode>\n}\n\n/**\n * Reference schema that points to another schema definition.\n *\n * @example\n * ```ts\n * const refSchema: RefSchemaNode = {\n * kind: 'Schema',\n * type: 'ref',\n * ref: '#/components/schemas/Pet',\n * }\n * ```\n */\nexport type RefSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'ref'\n /**\n * Referenced schema name.\n * `null` means Kubb has processed this and determined there is no applicable name.\n */\n name?: string | null\n /**\n * Original `$ref` path, for example, `#/components/schemas/Order`.\n * Used to resolve names later.\n */\n ref?: string\n /**\n * Emitted name of the referenced schema when it differs from the pointer's last segment,\n * for example after a collision rename (`Order` becomes `OrderSchema`) or a macro rename.\n * Resolve display and import names through `ast.ref.getName`, which prefers this field and\n * falls back to the pointer segment, then `name`.\n */\n targetName?: string\n /**\n * Pattern copied from a sibling `pattern` field.\n */\n pattern?: string\n /**\n * The fully-parsed schema this ref resolves to, so its structure (`primitive`, `properties`)\n * can be read without following the reference. Populated during parsing when the\n * definition resolves, `null` when it can't or the ref is circular, and `undefined` when\n * resolution has not been attempted.\n */\n schema?: SchemaNode | null\n}\n\n/**\n * Datetime schema.\n *\n * @example\n * ```ts\n * const datetimeSchema: DatetimeSchemaNode = { kind: 'Schema', type: 'datetime' }\n * ```\n */\nexport type DatetimeSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'datetime'\n /**\n * Whether the datetime includes a timezone offset (`dateType: 'stringOffset'`).\n */\n offset?: boolean\n /**\n * Whether the datetime is local (no timezone, `dateType: 'stringLocal'`).\n */\n local?: boolean\n}\n\n/**\n * Shared base for `date` and `time` schemas.\n */\ntype TemporalSchemaNodeBase<T extends 'date' | 'time'> = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: T\n /**\n * Output representation in generated code.\n */\n representation: 'date' | 'string'\n}\n\n/**\n * Date schema node.\n *\n * @example\n * ```ts\n * const dateSchema: DateSchemaNode = { kind: 'Schema', type: 'date', representation: 'string' }\n * ```\n */\nexport type DateSchemaNode = TemporalSchemaNodeBase<'date'>\n\n/**\n * Time schema node.\n *\n * @example\n * ```ts\n * const timeSchema: TimeSchemaNode = { kind: 'Schema', type: 'time', representation: 'string' }\n * ```\n */\nexport type TimeSchemaNode = TemporalSchemaNodeBase<'time'>\n\n/**\n * String schema node.\n *\n * @example\n * ```ts\n * const stringSchema: StringSchemaNode = { kind: 'Schema', type: 'string' }\n * ```\n */\nexport type StringSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'string'\n /**\n * Minimum string length.\n */\n min?: number\n /**\n * Maximum string length.\n */\n max?: number\n /**\n * Regex pattern.\n */\n pattern?: string\n /**\n * The value the string encodes, such as a JSON document or `base64` bytes. Visitors do not walk `schema`.\n */\n content?: {\n mediaType?: string\n encoding?: string\n schema?: SchemaNode\n }\n}\n\n/**\n * Numeric schema (`number`, `integer`, or `bigint`).\n *\n * @example\n * ```ts\n * const numberSchema: NumberSchemaNode = { kind: 'Schema', type: 'number' }\n * ```\n */\nexport type NumberSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'number' | 'integer' | 'bigint'\n /**\n * Minimum value.\n */\n min?: number\n /**\n * Maximum value.\n */\n max?: number\n /**\n * Bounds the value may not equal: it must be greater than `min` and less than `max`.\n */\n exclusive?: { min?: number; max?: number }\n /**\n * @deprecated Use `exclusive.min`. Removed in Kubb v6.\n */\n exclusiveMinimum?: number\n /**\n * @deprecated Use `exclusive.max`. Removed in Kubb v6.\n */\n exclusiveMaximum?: number\n /**\n * The value must be a multiple of this number.\n */\n multipleOf?: number\n}\n\n/**\n * Scalar schema with no extra constraints.\n *\n * @example\n * ```ts\n * const anySchema: ScalarSchemaNode = { kind: 'Schema', type: 'any' }\n * ```\n */\nexport type ScalarSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: Exclude<ScalarSchemaType, 'blob'>\n}\n\n/** Binary data schema node, such as a `format: binary` string. */\nexport type BlobSchemaNode = SchemaNodeBase & {\n type: 'blob'\n /** The media type and encoding of the bytes, from `contentMediaType` and `contentEncoding`. */\n content?: StringSchemaNode['content']\n}\n\n/**\n * URL schema node.\n * Can include a path template for template literal types.\n *\n * @example\n * ```ts\n * const urlSchema: UrlSchemaNode = { kind: 'Schema', type: 'url', path: '/pets/{petId}' }\n * ```\n */\nexport type UrlSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'url'\n /**\n * Path template, for example, `'/pets/{petId}'`.\n */\n path?: string\n /**\n * Minimum string length.\n */\n min?: number\n /**\n * Maximum string length.\n */\n max?: number\n}\n\n/**\n * Format-string schema for string-based formats that support length constraints.\n *\n * @example\n * ```ts\n * const uuidSchema: FormatStringSchemaNode = { kind: 'Schema', type: 'uuid', min: 36, max: 36 }\n * ```\n */\ntype FormatStringSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'uuid' | 'email'\n /**\n * Minimum string length.\n */\n min?: number\n /**\n * Maximum string length.\n */\n max?: number\n}\n\n/**\n * Mapping from schema type literals to concrete schema node types.\n * Used by `narrowSchema`.\n */\nexport type SchemaNodeByType = {\n object: ObjectSchemaNode\n array: ArraySchemaNode\n tuple: ArraySchemaNode\n union: UnionSchemaNode\n intersection: IntersectionSchemaNode\n not: NotSchemaNode\n enum: EnumSchemaNode\n ref: RefSchemaNode\n datetime: DatetimeSchemaNode\n date: DateSchemaNode\n time: TimeSchemaNode\n string: StringSchemaNode\n number: NumberSchemaNode\n integer: NumberSchemaNode\n bigint: NumberSchemaNode\n boolean: ScalarSchemaNode\n null: ScalarSchemaNode\n any: ScalarSchemaNode\n unknown: ScalarSchemaNode\n void: ScalarSchemaNode\n never: ScalarSchemaNode\n uuid: FormatStringSchemaNode\n email: FormatStringSchemaNode\n url: UrlSchemaNode\n ipv4: ScalarSchemaNode\n ipv6: ScalarSchemaNode\n blob: BlobSchemaNode\n}\n\n/**\n * Union of all schema node types.\n */\nexport type SchemaNode =\n | ObjectSchemaNode\n | ArraySchemaNode\n | UnionSchemaNode\n | IntersectionSchemaNode\n | NotSchemaNode\n | EnumSchemaNode\n | RefSchemaNode\n | DatetimeSchemaNode\n | DateSchemaNode\n | TimeSchemaNode\n | StringSchemaNode\n | NumberSchemaNode\n | UrlSchemaNode\n | FormatStringSchemaNode\n | ScalarSchemaNode\n | BlobSchemaNode\n\ntype CreateSchemaObjectInput = Omit<ObjectSchemaNode, 'kind' | 'properties' | 'primitive'> & { properties?: Array<PropertyNode>; primitive?: 'object' }\ntype CreateSchemaInput = CreateSchemaObjectInput | DistributiveOmit<Exclude<SchemaNode, ObjectSchemaNode>, 'kind'>\ntype CreateSchemaOutput<T extends CreateSchemaInput> = SchemaNodeByType[T['type']] & { kind: 'Schema' }\n\n/**\n * Maps schema `type` to its underlying `primitive`.\n * Primitive types map to themselves and special string formats map to `'string'`.\n * Any type not listed here (such as `ref`, `enum`, `union`, `intersection`, `not`, `tuple`, `ipv4`, `ipv6`, `blob`) has no `primitive`.\n */\nconst TYPE_TO_PRIMITIVE: Partial<Record<SchemaNode['type'], PrimitiveSchemaType>> = {\n string: 'string',\n number: 'number',\n integer: 'integer',\n bigint: 'bigint',\n boolean: 'boolean',\n null: 'null',\n any: 'any',\n unknown: 'unknown',\n void: 'void',\n never: 'never',\n object: 'object',\n array: 'array',\n date: 'date',\n uuid: 'string',\n email: 'string',\n url: 'string',\n datetime: 'string',\n time: 'string',\n}\n\n/**\n * Creates a `SchemaNode`, narrowed to the variant of `props.type`. Object schemas default\n * `properties` to an empty array, and `primitive` is inferred from `type` when not explicitly provided.\n *\n * @example\n * ```ts\n * const scalar = createSchema({ type: 'string' })\n * // { kind: 'Schema', type: 'string', primitive: 'string' }\n * ```\n *\n * @example\n * ```ts\n * const object = createSchema({ type: 'object' })\n * // { kind: 'Schema', type: 'object', primitive: 'object', properties: [] }\n * ```\n */\nexport function createSchema<T extends CreateSchemaInput>(props: T): CreateSchemaOutput<T>\nexport function createSchema(props: CreateSchemaInput): SchemaNode\nexport function createSchema(props: CreateSchemaInput): SchemaNode {\n if (props.type === 'object') {\n return { properties: [], primitive: 'object', ...props, kind: nodeKinds.schema }\n }\n\n return { primitive: TYPE_TO_PRIMITIVE[props.type], ...props, kind: nodeKinds.schema }\n}\n"],"mappings":";;;;;;;;AA2oBA,MAAM,oBAA8E;CAClF,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,SAAS;CACT,MAAM;CACN,KAAK;CACL,SAAS;CACT,MAAM;CACN,OAAO;CACP,QAAQ;CACR,OAAO;CACP,MAAM;CACN,MAAM;CACN,OAAO;CACP,KAAK;CACL,UAAU;CACV,MAAM;AACR;AAoBA,SAAgB,aAAa,OAAsC;CACjE,IAAI,MAAM,SAAS,UACjB,OAAO;EAAE,YAAY,CAAC;EAAG,WAAW;EAAU,GAAG;EAAO,MAAM,UAAU;CAAO;CAGjF,OAAO;EAAE,WAAW,kBAAkB,MAAM;EAAO,GAAG;EAAO,MAAM,UAAU;CAAO;AACtF"}
package/dist/schema.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { a as schemaTypes } from "./base-UFBZi-FO.cjs";
2
- import { n as narrowSchema } from "./guards-COBkDtgu.cjs";
3
- import { a as resolveSchemaProperties, c as SchemaKind, d as applyOptionality, i as inferDiscriminatorPropertyName, l as is, n as isString, o as IsOptions, r as getSchemaLiteralValues, s as SchemaFollow, u as getEmbeddedJson } from "./index-dgiKWRpD.cjs";
4
- import { o as findSchema } from "./visitor-DxhkIQyP.cjs";
2
+ import { n as narrowSchema } from "./guards-u-dAAtl8.cjs";
3
+ import { a as resolveSchemaProperties, c as SchemaKind, d as applyOptionality, i as inferDiscriminatorPropertyName, l as is, n as isString, o as IsOptions, r as getSchemaLiteralValues, s as SchemaFollow, u as getEmbeddedJson } from "./index-Bw2oMIM1.cjs";
4
+ import { o as findSchema } from "./visitor-DnBK2MNl.cjs";
5
5
  export { type IsOptions, type SchemaFollow, type SchemaKind, applyOptionality, findSchema as find, resolveSchemaProperties as findProperties, getEmbeddedJson, getSchemaLiteralValues as getLiterals, inferDiscriminatorPropertyName as inferDiscriminator, is, isString, narrowSchema as narrow, schemaTypes as types };
package/dist/schema.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { a as schemaTypes } from "./base-LhsPvVY1.js";
2
- import { n as narrowSchema } from "./guards-C6w6KQSY.js";
3
- import { a as resolveSchemaProperties, c as SchemaKind, d as applyOptionality, i as inferDiscriminatorPropertyName, l as is, n as isString, o as IsOptions, r as getSchemaLiteralValues, s as SchemaFollow, u as getEmbeddedJson } from "./index-9l1xMEl_.js";
4
- import { o as findSchema } from "./visitor-CFbuH7BY.js";
2
+ import { n as narrowSchema } from "./guards-RCnH6re9.js";
3
+ import { a as resolveSchemaProperties, c as SchemaKind, d as applyOptionality, i as inferDiscriminatorPropertyName, l as is, n as isString, o as IsOptions, r as getSchemaLiteralValues, s as SchemaFollow, u as getEmbeddedJson } from "./index-UwSVys3m.js";
4
+ import { o as findSchema } from "./visitor-CpmsR8o5.js";
5
5
  export { type IsOptions, type SchemaFollow, type SchemaKind, applyOptionality, findSchema as find, resolveSchemaProperties as findProperties, getEmbeddedJson, getSchemaLiteralValues as getLiterals, inferDiscriminatorPropertyName as inferDiscriminator, is, isString, narrowSchema as narrow, schemaTypes as types };
@@ -1,5 +1,5 @@
1
- import { t as Node } from "./index-Be5d4Zcl.js";
2
- import { H as SchemaNode, T as InputNode, X as PropertyNode, i as OperationNode, p as ParameterNode, s as ResponseNode } from "./operation-jxEr2No4.js";
1
+ import { t as Node } from "./index-6-ZZCX9W.js";
2
+ import { T as InputNode, U as SchemaNode, Z as PropertyNode, i as OperationNode, p as ParameterNode, s as ResponseNode } from "./operation-Cu4XSaJQ.js";
3
3
  /**
4
4
  * Traversal depth for AST visitor utilities.
5
5
  *
@@ -1,5 +1,5 @@
1
- import { t as Node } from "./index-ss1YqjpW.cjs";
2
- import { H as SchemaNode, T as InputNode, X as PropertyNode, i as OperationNode, p as ParameterNode, s as ResponseNode } from "./operation-BUhPuZMY.cjs";
1
+ import { t as Node } from "./index-B2nnOQjf.cjs";
2
+ import { T as InputNode, U as SchemaNode, Z as PropertyNode, i as OperationNode, p as ParameterNode, s as ResponseNode } from "./operation-AFw8tzIN.cjs";
3
3
  /**
4
4
  * Traversal depth for AST visitor utilities.
5
5
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/ast",
3
- "version": "5.23.3",
3
+ "version": "5.23.5",
4
4
  "description": "Spec-agnostic AST layer for Kubb. Defines the node tree, visitor pattern, factory functions, and type guards used across all code generation plugins.",
5
5
  "keywords": [
6
6
  "ast",
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-BAICym_L.cjs","names":["importLocalName","createFile","nodeKinds","getNodeText","CODE_NODE_TEXT_FIELDS"],"sources":["../src/utils/inline.ts","../src/file/index.ts"],"sourcesContent":["import { nodeKinds } from '../constants.ts'\nimport type { CodeNode } from '../nodes/code.ts'\nimport { createFile } from '../nodes/file.ts'\nimport type { FileNode, ImportNode, SourceNode } from '../nodes/file.ts'\nimport { importLocalName } from './combineFileMembers.ts'\nimport { CODE_NODE_TEXT_FIELDS, getNodeText } from './nodeText.ts'\n\ntype InlineFilesResult = {\n /**\n * Files that imported an inline name, rewritten to hold its definition.\n */\n files: Array<FileNode>\n /**\n * Paths of the virtual files, which are not written.\n */\n virtualPaths: Array<string>\n /**\n * One message per name that could not be inlined.\n */\n problems: Array<{ path: string; message: string }>\n}\n\ntype Definition = { expression: string; imports: Array<ImportNode> }\n\n/**\n * The language-specific half of {@link inlineFiles}, supplied by the parser that prints the file.\n */\nexport type InlineLanguage = {\n /**\n * Swaps in what `replace` returns for every identifier in `text` that references a name, skipping strings and comments.\n */\n replaceIdentifiers(text: string, replace: (name: string) => string | undefined): string\n /**\n * Makes `expression` safe to put where a name was, such as `(A | B)` in TypeScript.\n */\n wrap(expression: string): string\n}\n\ntype InlineFilesOptions = {\n /**\n * The inline support for a file's language, or `undefined` when it has none.\n */\n language: (file: FileNode) => InlineLanguage | undefined\n}\n\n/**\n * Replaces every name a file imports from a virtual file (one marked `inline`, so it is never written) with the body of that name's\n * declaration, until no inline names are left. The definitions' own imports move to the importing file.\n */\nexport function inlineFiles(files: ReadonlyArray<FileNode>, { language }: InlineFilesOptions): InlineFilesResult {\n const virtualFiles = new Map(files.filter(isInlineFile).map((file) => [file.path, file]))\n const result: InlineFilesResult = { files: [], virtualPaths: [...virtualFiles.keys()], problems: [] }\n if (virtualFiles.size === 0) return result\n\n // `null` marks a definition that is being resolved, so a name that reaches itself is a cycle.\n const definitions = new Map<string, Definition | null>()\n\n function define(path: string, name: string, from: string, lang: InlineLanguage): Definition | undefined {\n const key = `${path}\\0${name}`\n if (definitions.has(key)) {\n const definition = definitions.get(key)\n if (definition === null) result.problems.push({ path: from, message: `\"${name}\" from \"${path}\" is defined in terms of itself.` })\n return definition ?? undefined\n }\n\n const file = virtualFiles.get(path)!\n const expression = bodyOf(file.sources.find((source) => source.name === name))\n if (expression === undefined) {\n result.problems.push({ path: from, message: `\"${name}\" is imported from \"${path}\", which never writes it and has no inline definition for it.` })\n return undefined\n }\n\n definitions.set(key, null)\n const imports: Array<ImportNode> = []\n const { text, used } = replaceNames(expression, file, lang, imports)\n imports.push(...file.imports.flatMap((imp) => (virtualFiles.has(imp.path) ? [] : pickNames(imp, used))))\n\n const definition = { expression: text, imports }\n definitions.set(key, definition)\n return definition\n }\n\n // Pushes the imports the replaced definitions need onto `imports`; `used` holds the names left as they are.\n function replaceNames(input: string, file: FileNode, lang: InlineLanguage, imports: Array<ImportNode>) {\n const used = new Set<string>()\n const text = lang.replaceIdentifiers(input, (local) => {\n const target = findTarget(file, local)\n const definition = target && define(target.path, target.name, file.path, lang)\n if (!definition) {\n used.add(local)\n return undefined\n }\n\n imports.push(...definition.imports)\n return lang.wrap(definition.expression)\n })\n\n return { text, used }\n }\n\n function findTarget(file: FileNode, local: string): { path: string; name: string } | undefined {\n if (virtualFiles.has(file.path) && file.sources.some((source) => source.name === local)) return { path: file.path, name: local }\n\n for (const imp of file.imports) {\n const item = virtualFiles.has(imp.path) && [imp.name].flat().find((item) => importLocalName(item) === local)\n if (item) return { path: imp.path, name: typeof item === 'string' ? item : item.propertyName }\n }\n\n return undefined\n }\n\n for (const file of files) {\n if (virtualFiles.has(file.path) || !file.imports.some((imp) => virtualFiles.has(imp.path))) continue\n\n const lang = language(file)\n if (!lang) {\n result.problems.push({ path: file.path, message: `No parser for \"${file.extname}\" files supports inline sources.` })\n continue\n }\n\n const carried: Array<ImportNode> = []\n const sources = file.sources.map((source) => ({ ...source, nodes: rewriteNodes(source.nodes, (text) => replaceNames(text, file, lang, carried).text) }))\n\n // A carried import keeps its target; `root` moves to the importing file so the relative path is computed from there.\n const imports = [...file.imports.filter((imp) => !virtualFiles.has(imp.path)), ...carried.map((imp) => (imp.root ? { ...imp, root: file.path } : imp))]\n\n result.files.push(createFile({ ...file, sources, imports }))\n }\n\n return result\n}\n\n// A file of only deprecated per-source `inline` counts as inline too.\nfunction isInlineFile(file: FileNode): boolean {\n return !!file.inline || (file.sources.length > 0 && file.sources.every((source) => source.inline))\n}\n\n// The right-hand side of a `Const` or `Type`. A function body is not an expression, and printed text such as `Code` has none.\nfunction bodyOf(source: SourceNode | undefined): string | undefined {\n if (source?.inline) return source.inline.expression\n const node = source?.nodes?.length === 1 ? source.nodes[0] : undefined\n if (node?.kind !== nodeKinds.const && node?.kind !== nodeKinds.type) return undefined\n return getNodeText(node.nodes) || undefined\n}\n\nfunction pickNames(imp: ImportNode, used: ReadonlySet<string>): Array<ImportNode> {\n if (!Array.isArray(imp.name)) return used.has(imp.name) ? [imp] : []\n const name = imp.name.filter((item) => used.has(importLocalName(item)))\n return name.length > 0 ? [{ ...imp, name }] : []\n}\n\n// Rewrites the string fields `getNodeText` reads; JSDoc stays as written.\nfunction rewriteNodes(nodes: Array<CodeNode> | undefined, rewrite: (text: string) => string): Array<CodeNode> | undefined {\n return nodes?.map((node): CodeNode => {\n // Backward-compat: compiled plugins may still pass bare strings at runtime\n if (typeof node === 'string') return rewrite(node) as unknown as CodeNode\n if (node.kind === nodeKinds.break) return node\n\n const next = { ...node } as unknown as Record<string, unknown>\n for (const field of CODE_NODE_TEXT_FIELDS[node.kind] ?? []) {\n const value = next[field]\n if (Array.isArray(value)) next[field] = value.map(rewrite)\n if (typeof value === 'string' && value) next[field] = rewrite(value)\n }\n if ('nodes' in node && node.nodes) next.nodes = rewriteNodes(node.nodes, rewrite)\n return next as unknown as CodeNode\n })\n}\n","export { inlineFiles as inline } from '../utils/inline.ts'\n"],"mappings":";;;;;;;;;AAiDA,SAAgB,YAAY,OAAgC,EAAE,YAAmD;CAC/G,MAAM,eAAe,IAAI,IAAI,MAAM,OAAO,YAAY,CAAC,CAAC,KAAK,SAAS,CAAC,KAAK,MAAM,IAAI,CAAC,CAAC;CACxF,MAAM,SAA4B;EAAE,OAAO,CAAC;EAAG,cAAc,CAAC,GAAG,aAAa,KAAK,CAAC;EAAG,UAAU,CAAC;CAAE;CACpG,IAAI,aAAa,SAAS,GAAG,OAAO;CAGpC,MAAM,8BAAc,IAAI,IAA+B;CAEvD,SAAS,OAAO,MAAc,MAAc,MAAc,MAA8C;EACtG,MAAM,MAAM,GAAG,KAAK,IAAI;EACxB,IAAI,YAAY,IAAI,GAAG,GAAG;GACxB,MAAM,aAAa,YAAY,IAAI,GAAG;GACtC,IAAI,eAAe,MAAM,OAAO,SAAS,KAAK;IAAE,MAAM;IAAM,SAAS,IAAI,KAAK,UAAU,KAAK;GAAkC,CAAC;GAChI,OAAO,cAAc,KAAA;EACvB;EAEA,MAAM,OAAO,aAAa,IAAI,IAAI;EAClC,MAAM,aAAa,OAAO,KAAK,QAAQ,MAAM,WAAW,OAAO,SAAS,IAAI,CAAC;EAC7E,IAAI,eAAe,KAAA,GAAW;GAC5B,OAAO,SAAS,KAAK;IAAE,MAAM;IAAM,SAAS,IAAI,KAAK,sBAAsB,KAAK;GAA+D,CAAC;GAChJ;EACF;EAEA,YAAY,IAAI,KAAK,IAAI;EACzB,MAAM,UAA6B,CAAC;EACpC,MAAM,EAAE,MAAM,SAAS,aAAa,YAAY,MAAM,MAAM,OAAO;EACnE,QAAQ,KAAK,GAAG,KAAK,QAAQ,SAAS,QAAS,aAAa,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,UAAU,KAAK,IAAI,CAAE,CAAC;EAEvG,MAAM,aAAa;GAAE,YAAY;GAAM;EAAQ;EAC/C,YAAY,IAAI,KAAK,UAAU;EAC/B,OAAO;CACT;CAGA,SAAS,aAAa,OAAe,MAAgB,MAAsB,SAA4B;EACrG,MAAM,uBAAO,IAAI,IAAY;EAa7B,OAAO;GAAE,MAZI,KAAK,mBAAmB,QAAQ,UAAU;IACrD,MAAM,SAAS,WAAW,MAAM,KAAK;IACrC,MAAM,aAAa,UAAU,OAAO,OAAO,MAAM,OAAO,MAAM,KAAK,MAAM,IAAI;IAC7E,IAAI,CAAC,YAAY;KACf,KAAK,IAAI,KAAK;KACd;IACF;IAEA,QAAQ,KAAK,GAAG,WAAW,OAAO;IAClC,OAAO,KAAK,KAAK,WAAW,UAAU;GACxC,CAEY;GAAG;EAAK;CACtB;CAEA,SAAS,WAAW,MAAgB,OAA2D;EAC7F,IAAI,aAAa,IAAI,KAAK,IAAI,KAAK,KAAK,QAAQ,MAAM,WAAW,OAAO,SAAS,KAAK,GAAG,OAAO;GAAE,MAAM,KAAK;GAAM,MAAM;EAAM;EAE/H,KAAK,MAAM,OAAO,KAAK,SAAS;GAC9B,MAAM,OAAO,aAAa,IAAI,IAAI,IAAI,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,SAASA,aAAAA,gBAAgB,IAAI,MAAM,KAAK;GAC3G,IAAI,MAAM,OAAO;IAAE,MAAM,IAAI;IAAM,MAAM,OAAO,SAAS,WAAW,OAAO,KAAK;GAAa;EAC/F;CAGF;CAEA,KAAK,MAAM,QAAQ,OAAO;EACxB,IAAI,aAAa,IAAI,KAAK,IAAI,KAAK,CAAC,KAAK,QAAQ,MAAM,QAAQ,aAAa,IAAI,IAAI,IAAI,CAAC,GAAG;EAE5F,MAAM,OAAO,SAAS,IAAI;EAC1B,IAAI,CAAC,MAAM;GACT,OAAO,SAAS,KAAK;IAAE,MAAM,KAAK;IAAM,SAAS,kBAAkB,KAAK,QAAQ;GAAkC,CAAC;GACnH;EACF;EAEA,MAAM,UAA6B,CAAC;EACpC,MAAM,UAAU,KAAK,QAAQ,KAAK,YAAY;GAAE,GAAG;GAAQ,OAAO,aAAa,OAAO,QAAQ,SAAS,aAAa,MAAM,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI;EAAE,EAAE;EAGvJ,MAAM,UAAU,CAAC,GAAG,KAAK,QAAQ,QAAQ,QAAQ,CAAC,aAAa,IAAI,IAAI,IAAI,CAAC,GAAG,GAAG,QAAQ,KAAK,QAAS,IAAI,OAAO;GAAE,GAAG;GAAK,MAAM,KAAK;EAAK,IAAI,GAAI,CAAC;EAEtJ,OAAO,MAAM,KAAKC,aAAAA,WAAW;GAAE,GAAG;GAAM;GAAS;EAAQ,CAAC,CAAC;CAC7D;CAEA,OAAO;AACT;AAGA,SAAS,aAAa,MAAyB;CAC7C,OAAO,CAAC,CAAC,KAAK,UAAW,KAAK,QAAQ,SAAS,KAAK,KAAK,QAAQ,OAAO,WAAW,OAAO,MAAM;AAClG;AAGA,SAAS,OAAO,QAAoD;CAClE,IAAI,QAAQ,QAAQ,OAAO,OAAO,OAAO;CACzC,MAAM,OAAO,QAAQ,OAAO,WAAW,IAAI,OAAO,MAAM,KAAK,KAAA;CAC7D,IAAI,MAAM,SAASC,kBAAAA,UAAU,SAAS,MAAM,SAASA,kBAAAA,UAAU,MAAM,OAAO,KAAA;CAC5E,OAAOC,iBAAAA,YAAY,KAAK,KAAK,KAAK,KAAA;AACpC;AAEA,SAAS,UAAU,KAAiB,MAA8C;CAChF,IAAI,CAAC,MAAM,QAAQ,IAAI,IAAI,GAAG,OAAO,KAAK,IAAI,IAAI,IAAI,IAAI,CAAC,GAAG,IAAI,CAAC;CACnE,MAAM,OAAO,IAAI,KAAK,QAAQ,SAAS,KAAK,IAAIH,aAAAA,gBAAgB,IAAI,CAAC,CAAC;CACtE,OAAO,KAAK,SAAS,IAAI,CAAC;EAAE,GAAG;EAAK;CAAK,CAAC,IAAI,CAAC;AACjD;AAGA,SAAS,aAAa,OAAoC,SAAgE;CACxH,OAAO,OAAO,KAAK,SAAmB;EAEpC,IAAI,OAAO,SAAS,UAAU,OAAO,QAAQ,IAAI;EACjD,IAAI,KAAK,SAASE,kBAAAA,UAAU,OAAO,OAAO;EAE1C,MAAM,OAAO,EAAE,GAAG,KAAK;EACvB,KAAK,MAAM,SAASE,iBAAAA,sBAAsB,KAAK,SAAS,CAAC,GAAG;GAC1D,MAAM,QAAQ,KAAK;GACnB,IAAI,MAAM,QAAQ,KAAK,GAAG,KAAK,SAAS,MAAM,IAAI,OAAO;GACzD,IAAI,OAAO,UAAU,YAAY,OAAO,KAAK,SAAS,QAAQ,KAAK;EACrE;EACA,IAAI,WAAW,QAAQ,KAAK,OAAO,KAAK,QAAQ,aAAa,KAAK,OAAO,OAAO;EAChF,OAAO;CACT,CAAC;AACH"}