@kubb/adapter-oas 5.21.2 → 5.23.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
@@ -1,4 +1,4 @@
1
- import { AdapterFactoryOptions, ast } from "@kubb/kit";
1
+ import { AdapterFactoryOptions } from "@kubb/kit";
2
2
  // ==================================================================================================
3
3
  // JSON Schema Draft 04
4
4
  // ==================================================================================================
@@ -1050,6 +1050,72 @@ declare namespace OpenAPIV3 {
1050
1050
  externalDocs?: ExternalDocumentationObject;
1051
1051
  }
1052
1052
  }
1053
+ /**
1054
+ * How `format: 'date-time'` schemas are represented downstream.
1055
+ * - `false` falls through to a plain `string` (no validation).
1056
+ * - `'string'` emits a datetime string node.
1057
+ * - `'stringOffset'` emits a datetime node with timezone offset.
1058
+ * - `'stringLocal'` emits a local datetime node.
1059
+ * - `'date'` emits a `date` node (JavaScript `Date` object).
1060
+ */
1061
+ type DateTimeTypeValue = false | 'string' | 'stringOffset' | 'stringLocal' | 'date';
1062
+ /**
1063
+ * How `format: 'date'` or `format: 'time'` schemas are represented downstream.
1064
+ * - `false` falls through to a plain `string` (no validation).
1065
+ * - `'string'` (default) emits a date or time string node.
1066
+ * - `'date'` emits a `date`/`time` node (JavaScript `Date` object).
1067
+ */
1068
+ type DateOnlyTypeValue = false | 'string' | 'date';
1069
+ /**
1070
+ * Per-format override of `dateType`, so `date-time`, `date`, and `time` schemas can each
1071
+ * resolve to a different representation. A key left out defaults to `'string'`, the same
1072
+ * default as the scalar form of `dateType`.
1073
+ */
1074
+ type DateTypeOptions = {
1075
+ dateTime?: DateTimeTypeValue;
1076
+ date?: DateOnlyTypeValue;
1077
+ time?: DateOnlyTypeValue;
1078
+ };
1079
+ /**
1080
+ * Options that control how the adapter parser maps source schemas to AST nodes.
1081
+ */
1082
+ type ParserOptions = {
1083
+ /**
1084
+ * How `date-time`, `date`, and `time` formatted schemas are represented downstream.
1085
+ * A scalar value ({@link DateTimeTypeValue}) applies to all three formats, matching
1086
+ * the pre-5.1 behavior. Pass a {@link DateTypeOptions} object to set `dateTime`,
1087
+ * `date`, and `time` independently.
1088
+ *
1089
+ * @example Represent `date-time` as a JS `Date`, keep `date` and `time` as strings
1090
+ * ```ts
1091
+ * dateType: { dateTime: 'date' }
1092
+ * ```
1093
+ */
1094
+ dateType: DateTimeTypeValue | DateTypeOptions;
1095
+ /**
1096
+ * How a schema with `format: 'int64'` or `format: 'uint64'` maps to TypeScript. Other
1097
+ * integers always map to `number`.
1098
+ * - `'bigint'` is exact for 64-bit IDs, but does not round-trip through JSON.
1099
+ * - `'number'` fits most JSON APIs. Loses precision above `Number.MAX_SAFE_INTEGER`.
1100
+ *
1101
+ * @default 'bigint'
1102
+ */
1103
+ integerType?: 'number' | 'bigint';
1104
+ /**
1105
+ * AST type used when a schema's type cannot be inferred from the spec
1106
+ * (`additionalProperties: true`, missing `type`, ...).
1107
+ */
1108
+ unknownType: 'any' | 'unknown' | 'void';
1109
+ /**
1110
+ * AST type used for completely empty schemas (`{}`).
1111
+ */
1112
+ emptySchemaType: 'any' | 'unknown' | 'void';
1113
+ /**
1114
+ * Suffix appended to derived enum names when Kubb has to invent one
1115
+ * (typically for inline enums on object properties).
1116
+ */
1117
+ enumSuffix: 'enum' | (string & {});
1118
+ };
1053
1119
  /**
1054
1120
  * Media type used to pick a schema from an operation's request or response.
1055
1121
  *
@@ -1262,7 +1328,7 @@ type AdapterOasOptions = {
1262
1328
  * `{pet_id}` to `petId`). The HTTP request stays the same. Omit to keep the names from the spec.
1263
1329
  */
1264
1330
  pathParamsCasing?: 'camelcase';
1265
- } & Partial<ast.ParserOptions>;
1331
+ } & Partial<ParserOptions>;
1266
1332
  /**
1267
1333
  * Adapter options after defaults have been applied.
1268
1334
  */
@@ -1324,4 +1390,4 @@ type Operation = {
1324
1390
  schema: OperationObject$1;
1325
1391
  pathItem: PathItemObject$1;
1326
1392
  };
1327
- export type { AdapterOas, AdapterOasOptions, AdapterOasResolvedOptions, ContentType, DiscriminatorObject$1 as DiscriminatorObject, Document, MediaTypeObject$1 as MediaTypeObject, Operation, ReferenceObject$1 as ReferenceObject, ResponseObject$1 as ResponseObject, SchemaObject$1 as SchemaObject };
1393
+ export type { AdapterOas, AdapterOasOptions, AdapterOasResolvedOptions, ContentType, DateOnlyTypeValue, DateTimeTypeValue, DateTypeOptions, DiscriminatorObject$1 as DiscriminatorObject, Document, MediaTypeObject$1 as MediaTypeObject, Operation, ParserOptions, ReferenceObject$1 as ReferenceObject, ResponseObject$1 as ResponseObject, SchemaObject$1 as SchemaObject };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AdapterFactoryOptions, ast } from "@kubb/kit";
1
+ import { AdapterFactoryOptions } from "@kubb/kit";
2
2
  // ==================================================================================================
3
3
  // JSON Schema Draft 04
4
4
  // ==================================================================================================
@@ -1050,6 +1050,72 @@ declare namespace OpenAPIV3 {
1050
1050
  externalDocs?: ExternalDocumentationObject;
1051
1051
  }
1052
1052
  }
1053
+ /**
1054
+ * How `format: 'date-time'` schemas are represented downstream.
1055
+ * - `false` falls through to a plain `string` (no validation).
1056
+ * - `'string'` emits a datetime string node.
1057
+ * - `'stringOffset'` emits a datetime node with timezone offset.
1058
+ * - `'stringLocal'` emits a local datetime node.
1059
+ * - `'date'` emits a `date` node (JavaScript `Date` object).
1060
+ */
1061
+ type DateTimeTypeValue = false | 'string' | 'stringOffset' | 'stringLocal' | 'date';
1062
+ /**
1063
+ * How `format: 'date'` or `format: 'time'` schemas are represented downstream.
1064
+ * - `false` falls through to a plain `string` (no validation).
1065
+ * - `'string'` (default) emits a date or time string node.
1066
+ * - `'date'` emits a `date`/`time` node (JavaScript `Date` object).
1067
+ */
1068
+ type DateOnlyTypeValue = false | 'string' | 'date';
1069
+ /**
1070
+ * Per-format override of `dateType`, so `date-time`, `date`, and `time` schemas can each
1071
+ * resolve to a different representation. A key left out defaults to `'string'`, the same
1072
+ * default as the scalar form of `dateType`.
1073
+ */
1074
+ type DateTypeOptions = {
1075
+ dateTime?: DateTimeTypeValue;
1076
+ date?: DateOnlyTypeValue;
1077
+ time?: DateOnlyTypeValue;
1078
+ };
1079
+ /**
1080
+ * Options that control how the adapter parser maps source schemas to AST nodes.
1081
+ */
1082
+ type ParserOptions = {
1083
+ /**
1084
+ * How `date-time`, `date`, and `time` formatted schemas are represented downstream.
1085
+ * A scalar value ({@link DateTimeTypeValue}) applies to all three formats, matching
1086
+ * the pre-5.1 behavior. Pass a {@link DateTypeOptions} object to set `dateTime`,
1087
+ * `date`, and `time` independently.
1088
+ *
1089
+ * @example Represent `date-time` as a JS `Date`, keep `date` and `time` as strings
1090
+ * ```ts
1091
+ * dateType: { dateTime: 'date' }
1092
+ * ```
1093
+ */
1094
+ dateType: DateTimeTypeValue | DateTypeOptions;
1095
+ /**
1096
+ * How a schema with `format: 'int64'` or `format: 'uint64'` maps to TypeScript. Other
1097
+ * integers always map to `number`.
1098
+ * - `'bigint'` is exact for 64-bit IDs, but does not round-trip through JSON.
1099
+ * - `'number'` fits most JSON APIs. Loses precision above `Number.MAX_SAFE_INTEGER`.
1100
+ *
1101
+ * @default 'bigint'
1102
+ */
1103
+ integerType?: 'number' | 'bigint';
1104
+ /**
1105
+ * AST type used when a schema's type cannot be inferred from the spec
1106
+ * (`additionalProperties: true`, missing `type`, ...).
1107
+ */
1108
+ unknownType: 'any' | 'unknown' | 'void';
1109
+ /**
1110
+ * AST type used for completely empty schemas (`{}`).
1111
+ */
1112
+ emptySchemaType: 'any' | 'unknown' | 'void';
1113
+ /**
1114
+ * Suffix appended to derived enum names when Kubb has to invent one
1115
+ * (typically for inline enums on object properties).
1116
+ */
1117
+ enumSuffix: 'enum' | (string & {});
1118
+ };
1053
1119
  /**
1054
1120
  * Media type used to pick a schema from an operation's request or response.
1055
1121
  *
@@ -1262,7 +1328,7 @@ type AdapterOasOptions = {
1262
1328
  * `{pet_id}` to `petId`). The HTTP request stays the same. Omit to keep the names from the spec.
1263
1329
  */
1264
1330
  pathParamsCasing?: 'camelcase';
1265
- } & Partial<ast.ParserOptions>;
1331
+ } & Partial<ParserOptions>;
1266
1332
  /**
1267
1333
  * Adapter options after defaults have been applied.
1268
1334
  */
@@ -1324,4 +1390,4 @@ type Operation = {
1324
1390
  schema: OperationObject$1;
1325
1391
  pathItem: PathItemObject$1;
1326
1392
  };
1327
- export type { AdapterOas, AdapterOasOptions, AdapterOasResolvedOptions, ContentType, DiscriminatorObject$1 as DiscriminatorObject, Document, MediaTypeObject$1 as MediaTypeObject, Operation, ReferenceObject$1 as ReferenceObject, ResponseObject$1 as ResponseObject, SchemaObject$1 as SchemaObject };
1393
+ export type { AdapterOas, AdapterOasOptions, AdapterOasResolvedOptions, ContentType, DateOnlyTypeValue, DateTimeTypeValue, DateTypeOptions, DiscriminatorObject$1 as DiscriminatorObject, Document, MediaTypeObject$1 as MediaTypeObject, Operation, ParserOptions, ReferenceObject$1 as ReferenceObject, ResponseObject$1 as ResponseObject, SchemaObject$1 as SchemaObject };
package/dist/index.js CHANGED
@@ -15,7 +15,7 @@ var compatibility = {
15
15
  "node": ">=22.22"
16
16
  };
17
17
  // package.json
18
- var version = "5.21.2";
18
+ var version = "5.23.0";
19
19
  // src/constants.ts
20
20
  /**
21
21
  * Default parser options applied when no explicit options are provided.
@@ -1736,11 +1736,18 @@ function toInputTags(tags) {
1736
1736
  });
1737
1737
  }
1738
1738
  // src/model/mediaType.ts
1739
+ const streamMediaTypes = /* @__PURE__ */ new Set([
1740
+ "application/jsonl",
1741
+ "application/x-ndjson",
1742
+ "application/json-seq",
1743
+ "text/event-stream"
1744
+ ]);
1739
1745
  /**
1740
- * Returns `true` for a media type read as a stream of items: one `ast.mediaType.isStream` accepts, or any that declares `itemSchema`.
1746
+ * Returns `true` for a media type read as a stream of items: SSE, JSON Lines, a `+json-seq` sequence, or any media type that declares `itemSchema`.
1741
1747
  */
1742
1748
  function isStream(contentType, mediaType) {
1743
- return ast.mediaType.isStream(contentType) || mediaType?.itemSchema !== void 0;
1749
+ const baseType = ast.mediaType.getBase(contentType);
1750
+ return streamMediaTypes.has(baseType) || baseType.startsWith("application/") && baseType.endsWith("+json-seq") || mediaType?.itemSchema !== void 0;
1744
1751
  }
1745
1752
  /**
1746
1753
  * Whether the media type is `text/event-stream`, with or without parameters.