@kubb/ast 5.9.5 → 5.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -70,6 +70,8 @@ export declare const schemaTypes: {
70
70
  * "All of" multiple schema members.
71
71
  */
72
72
  readonly intersection: "intersection";
73
+ /** "Not" a single schema member. */
74
+ readonly not: "not";
73
75
  /**
74
76
  * Enum schema.
75
77
  */
@@ -462,6 +464,11 @@ type IntersectionSchemaNode = CompositeSchemaNodeBase & {
462
464
  */
463
465
  type: 'intersection';
464
466
  };
467
+ /** Negation from `not`: the value must not match its single member. Printers that cannot express it return `null`. */
468
+ type NotSchemaNode = CompositeSchemaNodeBase & {
469
+ /** Schema type discriminator. */
470
+ type: 'not';
471
+ };
465
472
  /**
466
473
  * One named enum item.
467
474
  */
@@ -744,6 +751,7 @@ type SchemaNodeByType = {
744
751
  tuple: ArraySchemaNode;
745
752
  union: UnionSchemaNode;
746
753
  intersection: IntersectionSchemaNode;
754
+ not: NotSchemaNode;
747
755
  enum: EnumSchemaNode;
748
756
  ref: RefSchemaNode;
749
757
  datetime: DatetimeSchemaNode;
@@ -769,7 +777,7 @@ type SchemaNodeByType = {
769
777
  /**
770
778
  * Union of all schema node types.
771
779
  */
772
- type SchemaNode = ObjectSchemaNode | ArraySchemaNode | UnionSchemaNode | IntersectionSchemaNode | EnumSchemaNode | RefSchemaNode | DatetimeSchemaNode | DateSchemaNode | TimeSchemaNode | StringSchemaNode | NumberSchemaNode | UrlSchemaNode | FormatStringSchemaNode | ScalarSchemaNode;
780
+ type SchemaNode = ObjectSchemaNode | ArraySchemaNode | UnionSchemaNode | IntersectionSchemaNode | NotSchemaNode | EnumSchemaNode | RefSchemaNode | DatetimeSchemaNode | DateSchemaNode | TimeSchemaNode | StringSchemaNode | NumberSchemaNode | UrlSchemaNode | FormatStringSchemaNode | ScalarSchemaNode;
773
781
  type CreateSchemaObjectInput = Omit<ObjectSchemaNode, 'kind' | 'properties' | 'primitive'> & {
774
782
  properties?: Array<PropertyNode>;
775
783
  primitive?: 'object';
@@ -845,6 +853,11 @@ type ParameterNode = BaseNode & {
845
853
  * leaving consumers to apply the default for the style.
846
854
  */
847
855
  explode?: boolean;
856
+ /**
857
+ * Whether reserved characters (RFC 3986 `:/?#[]@!$&'()*+,;=`) are sent as-is instead of
858
+ * percent-encoded. Only applies to query parameters. Absent when the source omits it.
859
+ */
860
+ allowReserved?: boolean;
848
861
  };
849
862
  type UserParameterNode = Pick<ParameterNode, 'name' | 'in' | 'schema'> & Partial<Omit<ParameterNode, 'kind' | 'name' | 'in' | 'schema'>>;
850
863
  /**
@@ -1071,6 +1084,10 @@ type OperationNodeBase = BaseNode & {
1071
1084
  * Operation responses.
1072
1085
  */
1073
1086
  responses: Array<ResponseNode>;
1087
+ /**
1088
+ * Vendor extensions (`x-*` keys) from the source operation, copied as-is. Absent when the source has none.
1089
+ */
1090
+ extensions?: Record<string, unknown>;
1074
1091
  };
1075
1092
  /**
1076
1093
  * Operation served over HTTP. `method` and `path` are guaranteed.
@@ -1783,9 +1800,22 @@ declare function createFile<TMeta extends object = object>(input: UserFileNode<T
1783
1800
  /**
1784
1801
  * A server from the source document, with `{variable}` placeholders filled from their defaults.
1785
1802
  */
1803
+ /**
1804
+ * A variable declared by a server URL template.
1805
+ */
1806
+ type InputServerVariable = {
1807
+ default?: string;
1808
+ enum?: Array<string>;
1809
+ description?: string;
1810
+ };
1786
1811
  type InputServer = {
1787
1812
  url: string;
1788
1813
  description?: string;
1814
+ /**
1815
+ * Variables of the source URL template, copied as-is. `url` already has their defaults filled in, so
1816
+ * this tells a templated server apart from a literal one. Absent when the server declares none.
1817
+ */
1818
+ variables?: Record<string, InputServerVariable>;
1789
1819
  };
1790
1820
  /**
1791
1821
  * An authentication scheme from the source document, keyed by `name`. `parameterName` is the header, query, or cookie name of an `apiKey`.
@@ -1830,6 +1860,10 @@ type InputMeta = {
1830
1860
  baseURL?: string | null;
1831
1861
  servers?: Array<InputServer>;
1832
1862
  securitySchemes?: Array<InputSecurityScheme>;
1863
+ /**
1864
+ * Vendor extensions (`x-*` keys) from the document root, copied as-is. Absent when the root has none.
1865
+ */
1866
+ extensions?: Record<string, unknown>;
1833
1867
  /**
1834
1868
  * Names of schemas that participate in a circular reference chain.
1835
1869
  * Computed once during the adapter pre-scan, so a generator never has to
@@ -2645,8 +2679,8 @@ type ParserOptions = {
2645
2679
  enumSuffix: 'enum' | (string & {});
2646
2680
  };
2647
2681
  declare namespace index_d_exports {
2648
- export { ArraySchemaNode, ArrowFunctionNode, BreakNode, CodeNode, ConstNode, ContentNode, DateOnlyTypeValue, DateSchemaNode, DateTimeTypeValue, DateTypeOptions, DatetimeSchemaNode, DistributiveOmit, Enforce, EnumSchemaNode, ExportNode, FileNode, FunctionNode, GenericOperationNode, HttpMethod, HttpOperationNode, ImportNode, InputMeta, InputNode, InputSecurityScheme, InputServer, IntersectionSchemaNode, JSDocNode, JsxNode, Macro, Node, NodeKind, NumberSchemaNode, ObjectSchemaNode, OperationNode, ParameterLocation, ParameterNode, ParameterStyle, ParentOf, ParserOptions, PrimitiveSchemaType, Printer, PrinterFactoryOptions, PrinterPartial, PropertyNode, RefSchemaNode, RequestBodyNode, ResponseNode, ScalarSchemaNode, ScalarSchemaType, SchemaNode, SchemaNodeByType, SchemaType, SourceNode, StatusCode, StringSchemaNode, TextNode, TimeSchemaNode, TypeNode, UnionSchemaNode, UrlSchemaNode, UserFileNode, Visitor, VisitorContext, applyMacros, index_d_exports as ast, collect, collectImportedRefNames, collectSchemaRefs, collectSync, collectUsedSchemaNames, composeMacros, createPrinter, defineMacro, extractStringsFromNodes, index_d_exports$1 as factory, findCircularSchemas, findCircularSchemasFromGraph, getSchemaLiteralValues, inferDiscriminatorPropertyName, isBareRef, isHttpOperationNode, mergeRefWithSchema, narrowSchema, optionality, refName, resolveRefName, resolveSchemaProperties, schemaTypes, transform };
2682
+ export { ArraySchemaNode, ArrowFunctionNode, BreakNode, CodeNode, ConstNode, ContentNode, DateOnlyTypeValue, DateSchemaNode, DateTimeTypeValue, DateTypeOptions, DatetimeSchemaNode, DistributiveOmit, Enforce, EnumSchemaNode, ExportNode, FileNode, FunctionNode, GenericOperationNode, HttpMethod, HttpOperationNode, ImportNode, InputMeta, InputNode, InputSecurityScheme, InputServer, IntersectionSchemaNode, JSDocNode, JsxNode, Macro, Node, NodeKind, NotSchemaNode, NumberSchemaNode, ObjectSchemaNode, OperationNode, ParameterLocation, ParameterNode, ParameterStyle, ParentOf, ParserOptions, PrimitiveSchemaType, Printer, PrinterFactoryOptions, PrinterPartial, PropertyNode, RefSchemaNode, RequestBodyNode, ResponseNode, ScalarSchemaNode, ScalarSchemaType, SchemaNode, SchemaNodeByType, SchemaType, SourceNode, StatusCode, StringSchemaNode, TextNode, TimeSchemaNode, TypeNode, UnionSchemaNode, UrlSchemaNode, UserFileNode, Visitor, VisitorContext, applyMacros, index_d_exports as ast, collect, collectImportedRefNames, collectSchemaRefs, collectSync, collectUsedSchemaNames, composeMacros, createPrinter, defineMacro, extractStringsFromNodes, index_d_exports$1 as factory, findCircularSchemas, findCircularSchemasFromGraph, getSchemaLiteralValues, inferDiscriminatorPropertyName, isBareRef, isHttpOperationNode, mergeRefWithSchema, narrowSchema, optionality, refName, resolveRefName, resolveSchemaProperties, schemaTypes, transform };
2649
2683
  }
2650
2684
  //#endregion
2651
- export { type ArraySchemaNode, type ArrowFunctionNode, type BreakNode, type CodeNode, type ConstNode, type ContentNode, type DateOnlyTypeValue, type DateSchemaNode, type DateTimeTypeValue, type DateTypeOptions, type DatetimeSchemaNode, type DistributiveOmit, type Enforce, type EnumSchemaNode, type ExportNode, type FileNode, type FunctionNode, type GenericOperationNode, type HttpMethod, type HttpOperationNode, type ImportNode, type InputMeta, type InputNode, type InputSecurityScheme, type InputServer, type IntersectionSchemaNode, type JSDocNode, type JsxNode, type Macro, type Node, type NodeKind, type NumberSchemaNode, type ObjectSchemaNode, type OperationNode, type ParameterLocation, type ParameterNode, type ParameterStyle, type ParentOf, type ParserOptions, type PrimitiveSchemaType, type Printer, type PrinterFactoryOptions, type PrinterPartial, type PropertyNode, type RefSchemaNode, type RequestBodyNode, type ResponseNode, type ScalarSchemaNode, type ScalarSchemaType, type SchemaNode, type SchemaNodeByType, type SchemaType, type SourceNode, type StatusCode, type StringSchemaNode, type TextNode, type TimeSchemaNode, type TypeNode, type UnionSchemaNode, type UrlSchemaNode, type UserFileNode, type Visitor, type VisitorContext, index_d_exports as ast, index_d_exports$1 as factory };
2685
+ export { type ArraySchemaNode, type ArrowFunctionNode, type BreakNode, type CodeNode, type ConstNode, type ContentNode, type DateOnlyTypeValue, type DateSchemaNode, type DateTimeTypeValue, type DateTypeOptions, type DatetimeSchemaNode, type DistributiveOmit, type Enforce, type EnumSchemaNode, type ExportNode, type FileNode, type FunctionNode, type GenericOperationNode, type HttpMethod, type HttpOperationNode, type ImportNode, type InputMeta, type InputNode, type InputSecurityScheme, type InputServer, type IntersectionSchemaNode, type JSDocNode, type JsxNode, type Macro, type Node, type NodeKind, type NotSchemaNode, type NumberSchemaNode, type ObjectSchemaNode, type OperationNode, type ParameterLocation, type ParameterNode, type ParameterStyle, type ParentOf, type ParserOptions, type PrimitiveSchemaType, type Printer, type PrinterFactoryOptions, type PrinterPartial, type PropertyNode, type RefSchemaNode, type RequestBodyNode, type ResponseNode, type ScalarSchemaNode, type ScalarSchemaType, type SchemaNode, type SchemaNodeByType, type SchemaType, type SourceNode, type StatusCode, type StringSchemaNode, type TextNode, type TimeSchemaNode, type TypeNode, type UnionSchemaNode, type UrlSchemaNode, type UserFileNode, type Visitor, type VisitorContext, index_d_exports as ast, index_d_exports$1 as factory };
2652
2686
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -64,6 +64,8 @@ const schemaTypes = {
64
64
  * "All of" multiple schema members.
65
65
  */
66
66
  intersection: "intersection",
67
+ /** "Not" a single schema member. */
68
+ not: "not",
67
69
  /**
68
70
  * Enum schema.
69
71
  */
@@ -1089,16 +1091,17 @@ function mergeByPath(result) {
1089
1091
  }
1090
1092
  /**
1091
1093
  * Deduplicates `SourceNode` objects by `name + isExportable + isTypeOnly`, keeping the first of each
1092
- * key. Unnamed sources fall back to their extracted node strings as the name part of the key. Returns
1093
- * the deduplicated array in original order.
1094
+ * key. An unnamed source only drops when the same node appears twice, so markdown can repeat a
1095
+ * paragraph or a table. Returns the deduplicated array in original order.
1094
1096
  */
1095
1097
  function combineSources(sources) {
1096
- const seen = /* @__PURE__ */ new Map();
1097
- for (const source of sources) {
1098
- const key = `${source.name ?? extractStringsFromNodes(source.nodes)}:${source.isExportable ?? false}:${source.isTypeOnly ?? false}`;
1099
- if (!seen.has(key)) seen.set(key, source);
1100
- }
1101
- return [...seen.values()];
1098
+ const seen = /* @__PURE__ */ new Set();
1099
+ return sources.filter((source) => {
1100
+ const key = source.name != null ? `${source.name}:${source.isExportable ?? false}:${source.isTypeOnly ?? false}` : source;
1101
+ if (seen.has(key)) return false;
1102
+ seen.add(key);
1103
+ return true;
1104
+ });
1102
1105
  }
1103
1106
  /**
1104
1107
  * Deduplicates and merges `ExportNode` objects by path and type.
@@ -1403,7 +1406,7 @@ function createResponse(props) {
1403
1406
  /**
1404
1407
  * Maps schema `type` to its underlying `primitive`.
1405
1408
  * Primitive types map to themselves and special string formats map to `'string'`.
1406
- * Any type not listed here (such as `ref`, `enum`, `union`, `intersection`, `tuple`, `ipv4`, `ipv6`, `blob`) has no `primitive`.
1409
+ * Any type not listed here (such as `ref`, `enum`, `union`, `intersection`, `not`, `tuple`, `ipv4`, `ipv6`, `blob`) has no `primitive`.
1407
1410
  */
1408
1411
  const TYPE_TO_PRIMITIVE = {
1409
1412
  string: "string",