@kubb/ast 5.9.4 → 5.9.6

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
  /**
@@ -1780,6 +1793,25 @@ type UserFileNode<TMeta extends object = object> = Omit<FileNode<TMeta>, 'kind'
1780
1793
  declare function createFile<TMeta extends object = object>(input: UserFileNode<TMeta>): FileNode<TMeta>;
1781
1794
  //#endregion
1782
1795
  //#region src/nodes/input.d.ts
1796
+ /**
1797
+ * A server from the source document, with `{variable}` placeholders filled from their defaults.
1798
+ */
1799
+ type InputServer = {
1800
+ url: string;
1801
+ description?: string;
1802
+ };
1803
+ /**
1804
+ * An authentication scheme from the source document, keyed by `name`. `parameterName` is the header, query, or cookie name of an `apiKey`.
1805
+ */
1806
+ type InputSecurityScheme = {
1807
+ name: string;
1808
+ type: string;
1809
+ description?: string;
1810
+ scheme?: string;
1811
+ bearerFormat?: string;
1812
+ in?: string;
1813
+ parameterName?: string;
1814
+ };
1783
1815
  /**
1784
1816
  * Metadata for an API document, populated by the adapter and available to every generator.
1785
1817
  *
@@ -1809,6 +1841,8 @@ type InputMeta = {
1809
1841
  * Resolved base URL from the first matching server entry in the source document.
1810
1842
  */
1811
1843
  baseURL?: string | null;
1844
+ servers?: Array<InputServer>;
1845
+ securitySchemes?: Array<InputSecurityScheme>;
1812
1846
  /**
1813
1847
  * Names of schemas that participate in a circular reference chain.
1814
1848
  * Computed once during the adapter pre-scan, so a generator never has to
@@ -2624,8 +2658,8 @@ type ParserOptions = {
2624
2658
  enumSuffix: 'enum' | (string & {});
2625
2659
  };
2626
2660
  declare namespace index_d_exports {
2627
- export { ArraySchemaNode, ArrowFunctionNode, BreakNode, CodeNode, ConstNode, ContentNode, DateOnlyTypeValue, DateSchemaNode, DateTimeTypeValue, DateTypeOptions, DatetimeSchemaNode, DistributiveOmit, Enforce, EnumSchemaNode, ExportNode, FileNode, FunctionNode, GenericOperationNode, HttpMethod, HttpOperationNode, ImportNode, InputMeta, InputNode, 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 };
2661
+ 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 };
2628
2662
  }
2629
2663
  //#endregion
2630
- 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 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 };
2664
+ 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 };
2631
2665
  //# 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",