@kubb/ast 5.16.0 → 5.17.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.cts CHANGED
@@ -788,6 +788,114 @@ type CreateSchemaOutput<T extends CreateSchemaInput> = SchemaNodeByType[T['type'
788
788
  */
789
789
  declare function createSchema<T extends CreateSchemaInput>(props: T): CreateSchemaOutput<T>;
790
790
  declare function createSchema(props: CreateSchemaInput): SchemaNode;
791
+ /**
792
+ * A variable declared by a server URL template.
793
+ */
794
+ type InputServerVariable = {
795
+ default?: string;
796
+ enum?: Array<string>;
797
+ description?: string;
798
+ };
799
+ /**
800
+ * A server from the source document, with `{variable}` placeholders filled from their defaults.
801
+ */
802
+ type InputServer = {
803
+ url: string;
804
+ description?: string;
805
+ /**
806
+ * Variables of the source URL template, copied as-is. `url` already has their defaults filled in, so
807
+ * this tells a templated server apart from a literal one. Absent when the server declares none.
808
+ */
809
+ variables?: Record<string, InputServerVariable>;
810
+ };
811
+ /**
812
+ * An authentication scheme from the source document, keyed by `name`. `parameterName` is the header, query, or cookie name of an `apiKey`.
813
+ */
814
+ type InputSecurityScheme = {
815
+ name: string;
816
+ type: string;
817
+ description?: string;
818
+ scheme?: string;
819
+ bearerFormat?: string;
820
+ in?: string;
821
+ parameterName?: string;
822
+ };
823
+ /**
824
+ * Metadata for an API document, populated by the adapter and available to every generator.
825
+ * Every field is a plain JSON value.
826
+ *
827
+ * @example
828
+ * ```ts
829
+ * const meta: InputMeta = { title: 'Pet Store', version: '1.0.0', baseURL: 'https://api.example.com/v2' }
830
+ * ```
831
+ */
832
+ type InputMeta = {
833
+ /**
834
+ * API title from `info.title` in the source document.
835
+ */
836
+ title?: string;
837
+ /**
838
+ * API description from `info.description` in the source document.
839
+ */
840
+ description?: string;
841
+ /**
842
+ * API version string from `info.version` in the source document.
843
+ */
844
+ version?: string;
845
+ /**
846
+ * Resolved base URL from the first matching server entry in the source document.
847
+ */
848
+ baseURL?: string | null;
849
+ servers?: Array<InputServer>;
850
+ securitySchemes?: Array<InputSecurityScheme>;
851
+ /**
852
+ * Vendor extensions (`x-*` keys) from the document root, copied as-is. Absent when the root has none.
853
+ */
854
+ extensions?: Record<string, unknown>;
855
+ };
856
+ /**
857
+ * Input AST node that contains all schemas and operations for one API document.
858
+ * Produced by the adapter and consumed by all Kubb plugins.
859
+ *
860
+ * @example
861
+ * ```ts
862
+ * const input: InputNode = {
863
+ * kind: 'Input',
864
+ * schemas: [],
865
+ * operations: [],
866
+ * meta: {},
867
+ * }
868
+ * ```
869
+ */
870
+ type InputNode = BaseNode & {
871
+ /**
872
+ * Node kind.
873
+ */
874
+ kind: 'Input';
875
+ /**
876
+ * All schema nodes in the document.
877
+ */
878
+ schemas: Array<SchemaNode>;
879
+ /**
880
+ * All operation nodes in the document.
881
+ */
882
+ operations: Array<OperationNode>;
883
+ /**
884
+ * Document metadata populated by the adapter.
885
+ */
886
+ meta: InputMeta;
887
+ };
888
+ /**
889
+ * Creates an `InputNode`, defaulting `schemas`/`operations` to empty arrays and `meta` to an empty
890
+ * object. Every call allocates fresh defaults so no two inputs share them.
891
+ *
892
+ * @example
893
+ * ```ts
894
+ * const input = createInput()
895
+ * // { kind: 'Input', schemas: [], operations: [] }
896
+ * ```
897
+ */
898
+ declare function createInput(overrides?: Partial<Omit<InputNode, 'kind'>>): InputNode;
791
899
  /**
792
900
  * Where a parameter is sent. `querystring` carries the whole query string as one value, serialized per `contentType`.
793
901
  */
@@ -1111,6 +1219,8 @@ type OperationNodeBase = BaseNode & {
1111
1219
  * Vendor extensions (`x-*` keys) from the source operation, copied as-is. Absent when the source has none.
1112
1220
  */
1113
1221
  extensions?: Record<string, unknown>;
1222
+ /** The operation's own `servers`, else its path item's, such as an upload host. Absent when neither declares any. */
1223
+ servers?: Array<InputServer>;
1114
1224
  };
1115
1225
  /**
1116
1226
  * Operation served over HTTP. `method` and `path` are guaranteed.
@@ -1819,114 +1929,6 @@ type UserFileNode<TMeta extends object = object> = Omit<FileNode<TMeta>, 'kind'
1819
1929
  * ```
1820
1930
  */
1821
1931
  declare function createFile<TMeta extends object = object>(input: UserFileNode<TMeta>): FileNode<TMeta>;
1822
- /**
1823
- * A variable declared by a server URL template.
1824
- */
1825
- type InputServerVariable = {
1826
- default?: string;
1827
- enum?: Array<string>;
1828
- description?: string;
1829
- };
1830
- /**
1831
- * A server from the source document, with `{variable}` placeholders filled from their defaults.
1832
- */
1833
- type InputServer = {
1834
- url: string;
1835
- description?: string;
1836
- /**
1837
- * Variables of the source URL template, copied as-is. `url` already has their defaults filled in, so
1838
- * this tells a templated server apart from a literal one. Absent when the server declares none.
1839
- */
1840
- variables?: Record<string, InputServerVariable>;
1841
- };
1842
- /**
1843
- * An authentication scheme from the source document, keyed by `name`. `parameterName` is the header, query, or cookie name of an `apiKey`.
1844
- */
1845
- type InputSecurityScheme = {
1846
- name: string;
1847
- type: string;
1848
- description?: string;
1849
- scheme?: string;
1850
- bearerFormat?: string;
1851
- in?: string;
1852
- parameterName?: string;
1853
- };
1854
- /**
1855
- * Metadata for an API document, populated by the adapter and available to every generator.
1856
- * Every field is a plain JSON value.
1857
- *
1858
- * @example
1859
- * ```ts
1860
- * const meta: InputMeta = { title: 'Pet Store', version: '1.0.0', baseURL: 'https://api.example.com/v2' }
1861
- * ```
1862
- */
1863
- type InputMeta = {
1864
- /**
1865
- * API title from `info.title` in the source document.
1866
- */
1867
- title?: string;
1868
- /**
1869
- * API description from `info.description` in the source document.
1870
- */
1871
- description?: string;
1872
- /**
1873
- * API version string from `info.version` in the source document.
1874
- */
1875
- version?: string;
1876
- /**
1877
- * Resolved base URL from the first matching server entry in the source document.
1878
- */
1879
- baseURL?: string | null;
1880
- servers?: Array<InputServer>;
1881
- securitySchemes?: Array<InputSecurityScheme>;
1882
- /**
1883
- * Vendor extensions (`x-*` keys) from the document root, copied as-is. Absent when the root has none.
1884
- */
1885
- extensions?: Record<string, unknown>;
1886
- };
1887
- /**
1888
- * Input AST node that contains all schemas and operations for one API document.
1889
- * Produced by the adapter and consumed by all Kubb plugins.
1890
- *
1891
- * @example
1892
- * ```ts
1893
- * const input: InputNode = {
1894
- * kind: 'Input',
1895
- * schemas: [],
1896
- * operations: [],
1897
- * meta: {},
1898
- * }
1899
- * ```
1900
- */
1901
- type InputNode = BaseNode & {
1902
- /**
1903
- * Node kind.
1904
- */
1905
- kind: 'Input';
1906
- /**
1907
- * All schema nodes in the document.
1908
- */
1909
- schemas: Array<SchemaNode>;
1910
- /**
1911
- * All operation nodes in the document.
1912
- */
1913
- operations: Array<OperationNode>;
1914
- /**
1915
- * Document metadata populated by the adapter.
1916
- */
1917
- meta: InputMeta;
1918
- };
1919
- /**
1920
- * Creates an `InputNode`, defaulting `schemas`/`operations` to empty arrays and `meta` to an empty
1921
- * object. Every call allocates fresh defaults so no two inputs share them.
1922
- *
1923
- * @example
1924
- * ```ts
1925
- * const input = createInput()
1926
- * // { kind: 'Input', schemas: [], operations: [] }
1927
- * ```
1928
- */
1929
- declare function createInput(overrides?: Partial<Omit<InputNode, 'kind'>>): InputNode;
1930
1932
  declare namespace index_d_exports$1 {
1931
1933
  export { Node, UserFileNode, createArrowFunction, createBreak, createConst, createContent, createExport, createFile, createFunction, createImport, createInput, createJsx, createOperation, createParameter, createProperty, createRequestBody, createResponse, createSchema, createSource, createText, createType };
1932
1934
  }
package/dist/index.d.ts CHANGED
@@ -788,6 +788,114 @@ type CreateSchemaOutput<T extends CreateSchemaInput> = SchemaNodeByType[T['type'
788
788
  */
789
789
  declare function createSchema<T extends CreateSchemaInput>(props: T): CreateSchemaOutput<T>;
790
790
  declare function createSchema(props: CreateSchemaInput): SchemaNode;
791
+ /**
792
+ * A variable declared by a server URL template.
793
+ */
794
+ type InputServerVariable = {
795
+ default?: string;
796
+ enum?: Array<string>;
797
+ description?: string;
798
+ };
799
+ /**
800
+ * A server from the source document, with `{variable}` placeholders filled from their defaults.
801
+ */
802
+ type InputServer = {
803
+ url: string;
804
+ description?: string;
805
+ /**
806
+ * Variables of the source URL template, copied as-is. `url` already has their defaults filled in, so
807
+ * this tells a templated server apart from a literal one. Absent when the server declares none.
808
+ */
809
+ variables?: Record<string, InputServerVariable>;
810
+ };
811
+ /**
812
+ * An authentication scheme from the source document, keyed by `name`. `parameterName` is the header, query, or cookie name of an `apiKey`.
813
+ */
814
+ type InputSecurityScheme = {
815
+ name: string;
816
+ type: string;
817
+ description?: string;
818
+ scheme?: string;
819
+ bearerFormat?: string;
820
+ in?: string;
821
+ parameterName?: string;
822
+ };
823
+ /**
824
+ * Metadata for an API document, populated by the adapter and available to every generator.
825
+ * Every field is a plain JSON value.
826
+ *
827
+ * @example
828
+ * ```ts
829
+ * const meta: InputMeta = { title: 'Pet Store', version: '1.0.0', baseURL: 'https://api.example.com/v2' }
830
+ * ```
831
+ */
832
+ type InputMeta = {
833
+ /**
834
+ * API title from `info.title` in the source document.
835
+ */
836
+ title?: string;
837
+ /**
838
+ * API description from `info.description` in the source document.
839
+ */
840
+ description?: string;
841
+ /**
842
+ * API version string from `info.version` in the source document.
843
+ */
844
+ version?: string;
845
+ /**
846
+ * Resolved base URL from the first matching server entry in the source document.
847
+ */
848
+ baseURL?: string | null;
849
+ servers?: Array<InputServer>;
850
+ securitySchemes?: Array<InputSecurityScheme>;
851
+ /**
852
+ * Vendor extensions (`x-*` keys) from the document root, copied as-is. Absent when the root has none.
853
+ */
854
+ extensions?: Record<string, unknown>;
855
+ };
856
+ /**
857
+ * Input AST node that contains all schemas and operations for one API document.
858
+ * Produced by the adapter and consumed by all Kubb plugins.
859
+ *
860
+ * @example
861
+ * ```ts
862
+ * const input: InputNode = {
863
+ * kind: 'Input',
864
+ * schemas: [],
865
+ * operations: [],
866
+ * meta: {},
867
+ * }
868
+ * ```
869
+ */
870
+ type InputNode = BaseNode & {
871
+ /**
872
+ * Node kind.
873
+ */
874
+ kind: 'Input';
875
+ /**
876
+ * All schema nodes in the document.
877
+ */
878
+ schemas: Array<SchemaNode>;
879
+ /**
880
+ * All operation nodes in the document.
881
+ */
882
+ operations: Array<OperationNode>;
883
+ /**
884
+ * Document metadata populated by the adapter.
885
+ */
886
+ meta: InputMeta;
887
+ };
888
+ /**
889
+ * Creates an `InputNode`, defaulting `schemas`/`operations` to empty arrays and `meta` to an empty
890
+ * object. Every call allocates fresh defaults so no two inputs share them.
891
+ *
892
+ * @example
893
+ * ```ts
894
+ * const input = createInput()
895
+ * // { kind: 'Input', schemas: [], operations: [] }
896
+ * ```
897
+ */
898
+ declare function createInput(overrides?: Partial<Omit<InputNode, 'kind'>>): InputNode;
791
899
  /**
792
900
  * Where a parameter is sent. `querystring` carries the whole query string as one value, serialized per `contentType`.
793
901
  */
@@ -1111,6 +1219,8 @@ type OperationNodeBase = BaseNode & {
1111
1219
  * Vendor extensions (`x-*` keys) from the source operation, copied as-is. Absent when the source has none.
1112
1220
  */
1113
1221
  extensions?: Record<string, unknown>;
1222
+ /** The operation's own `servers`, else its path item's, such as an upload host. Absent when neither declares any. */
1223
+ servers?: Array<InputServer>;
1114
1224
  };
1115
1225
  /**
1116
1226
  * Operation served over HTTP. `method` and `path` are guaranteed.
@@ -1819,114 +1929,6 @@ type UserFileNode<TMeta extends object = object> = Omit<FileNode<TMeta>, 'kind'
1819
1929
  * ```
1820
1930
  */
1821
1931
  declare function createFile<TMeta extends object = object>(input: UserFileNode<TMeta>): FileNode<TMeta>;
1822
- /**
1823
- * A variable declared by a server URL template.
1824
- */
1825
- type InputServerVariable = {
1826
- default?: string;
1827
- enum?: Array<string>;
1828
- description?: string;
1829
- };
1830
- /**
1831
- * A server from the source document, with `{variable}` placeholders filled from their defaults.
1832
- */
1833
- type InputServer = {
1834
- url: string;
1835
- description?: string;
1836
- /**
1837
- * Variables of the source URL template, copied as-is. `url` already has their defaults filled in, so
1838
- * this tells a templated server apart from a literal one. Absent when the server declares none.
1839
- */
1840
- variables?: Record<string, InputServerVariable>;
1841
- };
1842
- /**
1843
- * An authentication scheme from the source document, keyed by `name`. `parameterName` is the header, query, or cookie name of an `apiKey`.
1844
- */
1845
- type InputSecurityScheme = {
1846
- name: string;
1847
- type: string;
1848
- description?: string;
1849
- scheme?: string;
1850
- bearerFormat?: string;
1851
- in?: string;
1852
- parameterName?: string;
1853
- };
1854
- /**
1855
- * Metadata for an API document, populated by the adapter and available to every generator.
1856
- * Every field is a plain JSON value.
1857
- *
1858
- * @example
1859
- * ```ts
1860
- * const meta: InputMeta = { title: 'Pet Store', version: '1.0.0', baseURL: 'https://api.example.com/v2' }
1861
- * ```
1862
- */
1863
- type InputMeta = {
1864
- /**
1865
- * API title from `info.title` in the source document.
1866
- */
1867
- title?: string;
1868
- /**
1869
- * API description from `info.description` in the source document.
1870
- */
1871
- description?: string;
1872
- /**
1873
- * API version string from `info.version` in the source document.
1874
- */
1875
- version?: string;
1876
- /**
1877
- * Resolved base URL from the first matching server entry in the source document.
1878
- */
1879
- baseURL?: string | null;
1880
- servers?: Array<InputServer>;
1881
- securitySchemes?: Array<InputSecurityScheme>;
1882
- /**
1883
- * Vendor extensions (`x-*` keys) from the document root, copied as-is. Absent when the root has none.
1884
- */
1885
- extensions?: Record<string, unknown>;
1886
- };
1887
- /**
1888
- * Input AST node that contains all schemas and operations for one API document.
1889
- * Produced by the adapter and consumed by all Kubb plugins.
1890
- *
1891
- * @example
1892
- * ```ts
1893
- * const input: InputNode = {
1894
- * kind: 'Input',
1895
- * schemas: [],
1896
- * operations: [],
1897
- * meta: {},
1898
- * }
1899
- * ```
1900
- */
1901
- type InputNode = BaseNode & {
1902
- /**
1903
- * Node kind.
1904
- */
1905
- kind: 'Input';
1906
- /**
1907
- * All schema nodes in the document.
1908
- */
1909
- schemas: Array<SchemaNode>;
1910
- /**
1911
- * All operation nodes in the document.
1912
- */
1913
- operations: Array<OperationNode>;
1914
- /**
1915
- * Document metadata populated by the adapter.
1916
- */
1917
- meta: InputMeta;
1918
- };
1919
- /**
1920
- * Creates an `InputNode`, defaulting `schemas`/`operations` to empty arrays and `meta` to an empty
1921
- * object. Every call allocates fresh defaults so no two inputs share them.
1922
- *
1923
- * @example
1924
- * ```ts
1925
- * const input = createInput()
1926
- * // { kind: 'Input', schemas: [], operations: [] }
1927
- * ```
1928
- */
1929
- declare function createInput(overrides?: Partial<Omit<InputNode, 'kind'>>): InputNode;
1930
1932
  declare namespace index_d_exports$1 {
1931
1933
  export { Node, UserFileNode, createArrowFunction, createBreak, createConst, createContent, createExport, createFile, createFunction, createImport, createInput, createJsx, createOperation, createParameter, createProperty, createRequestBody, createResponse, createSchema, createSource, createText, createType };
1932
1934
  }