schema-truth 0.7.0 → 0.8.1
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/{ajv-DTP2FXRr.js → ajv-DS9gtNZC.js} +1 -1
- package/dist/ajv.d.ts +1 -1
- package/dist/ajv.js +1 -1
- package/dist/{arktype-BdvvaBQX.js → arktype-CRZ8vXZ5.js} +94 -37
- package/dist/arktype.d.ts +3 -3
- package/dist/arktype.js +1 -1
- package/dist/cli/ajv.js +2 -2
- package/dist/cli/arktype.js +2 -2
- package/dist/cli/effect.js +2 -2
- package/dist/cli/typebox.js +2 -2
- package/dist/cli/valibot.js +2 -2
- package/dist/cli/yup.js +2 -2
- package/dist/cli/zod.js +2 -2
- package/dist/{cli-CL2mSark.js → cli-eAY8LqwP.js} +2 -2
- package/dist/{effect-mUknRPv_.js → effect-BkWovUi3.js} +52 -19
- package/dist/effect.d.ts +3 -3
- package/dist/effect.js +1 -1
- package/dist/{helper-Cfvb5UDq.js → helper-CbeedY35.js} +721 -38
- package/dist/{index-C2L8Ty0-.d.ts → index-DYzAccyT.d.ts} +29 -25
- package/dist/{index-DbV3dEmN.d.ts → index-G7UqNQ4w.d.ts} +54 -2
- package/dist/index.d.ts +54 -25
- package/dist/index.js +9 -9
- package/dist/{typebox-BdWJv3ND.js → typebox-wYeJqy7T.js} +33 -14
- package/dist/typebox.d.ts +3 -3
- package/dist/typebox.js +1 -1
- package/dist/{utils-WNBq1HR0.js → utils-Bky98UmP.js} +160 -31
- package/dist/{valibot-CaJIynCH.js → valibot-DQUEDYKt.js} +64 -23
- package/dist/valibot.d.ts +3 -3
- package/dist/valibot.js +1 -1
- package/dist/{yup-CM2TSFig.js → yup-BMpa9Co1.js} +2 -2
- package/dist/yup.d.ts +2 -2
- package/dist/yup.js +1 -1
- package/dist/{zod-BsXLZfwK.js → zod-Dq9LtqPL.js} +130 -91
- package/dist/zod.d.ts +3 -3
- package/dist/zod.js +1 -1
- package/package.json +1 -1
|
@@ -1,25 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
//#region src/
|
|
3
|
-
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* Every location is string-wire — when a primitive schema is emitted under one of
|
|
8
|
-
* them, generators apply type coercion (e.g. Zod `z.coerce.number()`, Effect
|
|
9
|
-
* `Schema.FiniteFromString`), read a literal, an `enum` and the text `null` from the
|
|
10
|
-
* text, wrap a value sent once into an array of one, and copy an object with an
|
|
11
|
-
* `Object.prototype`-named property onto a null-prototype object before the check.
|
|
12
|
-
*
|
|
13
|
-
* @see https://spec.openapis.org/oas/v3.2.0.html#parameter-object
|
|
14
|
-
*/
|
|
15
|
-
type ParamIn = (typeof PARAM_LOCATIONS)[number];
|
|
16
|
-
/**
|
|
17
|
-
* The `style` of an OpenAPI Parameter Object: how its text is serialised. Defaults to
|
|
18
|
-
* `form` for `query` / `cookie` / `formData` and `simple` for `path` / `header`.
|
|
19
|
-
*
|
|
20
|
-
* @see https://spec.openapis.org/oas/v3.2.0.html#style-values
|
|
21
|
-
*/
|
|
22
|
-
type ParamStyle = (typeof PARAM_STYLES)[number];
|
|
1
|
+
import { h as ParamStyle, m as ParamIn, r as JSONSchema } from "./index-G7UqNQ4w.js";
|
|
2
|
+
//#region src/helper/schema.d.ts
|
|
3
|
+
/** Named schemas a `default` beside a `$ref` is reconciled against. */
|
|
4
|
+
type SchemaDefinitions = {
|
|
5
|
+
readonly [name: string]: JSONSchema;
|
|
6
|
+
};
|
|
23
7
|
//#endregion
|
|
24
8
|
//#region src/options/index.d.ts
|
|
25
9
|
/** The options every `schemaTo<Library>` document generator accepts. */
|
|
@@ -38,8 +22,9 @@ type GenerateOptions = {
|
|
|
38
22
|
* The parameter's `style`, which decides how its text is split into an array or an
|
|
39
23
|
* object (`form` with `explode: false` reads `1,2,3`, `deepObject` gathers `deep[key]`).
|
|
40
24
|
* Defaults to `form` for `query` / `cookie` / `formData` and `simple` for `path` / `header`.
|
|
41
|
-
* Applies to the root schema
|
|
42
|
-
*
|
|
25
|
+
* Applies to the root schema. A property's own serialization is `x-style` / `x-explode` /
|
|
26
|
+
* `x-allowEmptyValue`, or {@link GenerateOptions.properties}. Honoured by Zod, Valibot,
|
|
27
|
+
* Effect Schema and ArkType; a no-op for TypeBox, Ajv and Yup.
|
|
43
28
|
*/
|
|
44
29
|
readonly style?: ParamStyle;
|
|
45
30
|
/**
|
|
@@ -58,8 +43,27 @@ type GenerateOptions = {
|
|
|
58
43
|
* `style` is.
|
|
59
44
|
*/
|
|
60
45
|
readonly contentType?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Per-property serialization for an object schema emitted with `paramIn`: each named
|
|
48
|
+
* property is read with its own `style` / `explode` / `allowEmptyValue` instead of the
|
|
49
|
+
* root's. A keyword on the property (`x-style`, `x-explode`, `x-allowEmptyValue`) fills
|
|
50
|
+
* whatever this map leaves unset, and survives inside `$defs`. Honoured where `style` is.
|
|
51
|
+
*/
|
|
52
|
+
readonly properties?: {
|
|
53
|
+
readonly [name: string]: {
|
|
54
|
+
readonly style?: ParamStyle;
|
|
55
|
+
readonly explode?: boolean;
|
|
56
|
+
readonly allowEmptyValue?: boolean;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Named schemas used to reconcile a `default` written beside a `$ref`. `schemaTo*`
|
|
61
|
+
* fills this from the document's `$defs` / `definitions`. Honoured by Zod, Valibot,
|
|
62
|
+
* Effect Schema and TypeBox.
|
|
63
|
+
*/
|
|
64
|
+
readonly definitions?: SchemaDefinitions;
|
|
61
65
|
};
|
|
62
66
|
/** The options threaded through every node emitter: `GenerateOptions` without `exportType`. */
|
|
63
67
|
type EmitOptions = Omit<GenerateOptions, 'exportType'>;
|
|
64
68
|
//#endregion
|
|
65
|
-
export {
|
|
69
|
+
export { GenerateOptions as n, EmitOptions as t };
|
|
@@ -59,6 +59,17 @@ declare const STRINGBOOL_PATTERN: RegExp;
|
|
|
59
59
|
declare const STRINGBOOL_TRUTHY_PATTERN: RegExp;
|
|
60
60
|
/** The text of a 64-bit integer: a sign and digits, which `BigInt` reads losslessly. */
|
|
61
61
|
declare const INTEGER_TEXT_PATTERN: RegExp;
|
|
62
|
+
/**
|
|
63
|
+
* Integer text on the string wire. A sign and digits, with no leading zero, no exponent
|
|
64
|
+
* and no fraction: `Number` and `parseInt` both accept more than this (`""`, `" "`,
|
|
65
|
+
* `"0x10"`, `"1e3"`, `"1.9xyz"`).
|
|
66
|
+
*/
|
|
67
|
+
declare const INTEGER_WIRE_PATTERN: RegExp;
|
|
68
|
+
/**
|
|
69
|
+
* Number text on the string wire: the JSON number grammar (RFC 8259). An exponent is a
|
|
70
|
+
* number (`1e3`) and is not an integer. Blank, hex and trailing junk are not numbers.
|
|
71
|
+
*/
|
|
72
|
+
declare const NUMBER_WIRE_PATTERN: RegExp;
|
|
62
73
|
/** The range of each fixed-width numeric format, as the literals the generators emit. */
|
|
63
74
|
declare const NUMBER_RANGES: {
|
|
64
75
|
readonly [k: string]: {
|
|
@@ -268,6 +279,47 @@ type XExtMessages = {
|
|
|
268
279
|
readonly 'x-else-message'?: string;
|
|
269
280
|
};
|
|
270
281
|
//#endregion
|
|
282
|
+
//#region src/parser/x-ext/param.d.ts
|
|
283
|
+
/**
|
|
284
|
+
* OpenAPI parameter location, or `formData` for a field of a form body
|
|
285
|
+
* (`application/x-www-form-urlencoded`, `multipart/form-data`).
|
|
286
|
+
*
|
|
287
|
+
* Every location is string-wire — when a primitive schema is emitted under one of
|
|
288
|
+
* them, generators read a number from the JSON number grammar and an integer from
|
|
289
|
+
* digits with no leading zero before converting the text, read a literal, an `enum`
|
|
290
|
+
* and the text `null` from the text, wrap a value sent once into an array of one,
|
|
291
|
+
* and copy an object with an `Object.prototype`-named property onto a null-prototype
|
|
292
|
+
* object before the check. Boolean text is the same set for every target.
|
|
293
|
+
*
|
|
294
|
+
* @see https://spec.openapis.org/oas/v3.2.0.html#parameter-object
|
|
295
|
+
*/
|
|
296
|
+
type ParamIn = (typeof PARAM_LOCATIONS)[number];
|
|
297
|
+
/**
|
|
298
|
+
* Per-property OpenAPI serialization, for one property of an object schema emitted
|
|
299
|
+
* with `paramIn`. The root `style` / `explode` / `allowEmptyValue` options read the
|
|
300
|
+
* object itself; these keywords read that property's own text (`x-ids: 1,2,3` splits
|
|
301
|
+
* on commas before the elements are coerced). They survive inside `$defs`, unlike a
|
|
302
|
+
* generator option keyed by property name.
|
|
303
|
+
*
|
|
304
|
+
* Honoured by Zod, Valibot, Effect Schema and ArkType when the object is emitted with
|
|
305
|
+
* `paramIn`. A no-op for TypeBox, Ajv and Yup, and when `paramIn` is unset.
|
|
306
|
+
*/
|
|
307
|
+
type XExtParam = {
|
|
308
|
+
/** The property's `style`. Defaults to the location's style when unset. */
|
|
309
|
+
readonly 'x-style'?: ParamStyle;
|
|
310
|
+
/** The property's `explode`. Defaults to `true` for `style: form`, otherwise `false`. */
|
|
311
|
+
readonly 'x-explode'?: boolean;
|
|
312
|
+
/** The property's `allowEmptyValue`: an empty value reads as an absent one. */
|
|
313
|
+
readonly 'x-allowEmptyValue'?: boolean;
|
|
314
|
+
};
|
|
315
|
+
/**
|
|
316
|
+
* The `style` of an OpenAPI Parameter Object: how its text is serialised. Defaults to
|
|
317
|
+
* `form` for `query` / `cookie` / `formData` and `simple` for `path` / `header`.
|
|
318
|
+
*
|
|
319
|
+
* @see https://spec.openapis.org/oas/v3.2.0.html#style-values
|
|
320
|
+
*/
|
|
321
|
+
type ParamStyle = (typeof PARAM_STYLES)[number];
|
|
322
|
+
//#endregion
|
|
271
323
|
//#region src/parser/x-ext/transform.d.ts
|
|
272
324
|
/**
|
|
273
325
|
* B 層: 振る舞い・transform 系 vendor extensions.
|
|
@@ -546,6 +598,6 @@ type JSONSchemaCore = {
|
|
|
546
598
|
/** Schema name (non-standard) */
|
|
547
599
|
readonly name?: string;
|
|
548
600
|
};
|
|
549
|
-
type JSONSchema = JSONSchemaCore & XExtMessages & XExtTransform & XExtCode;
|
|
601
|
+
type JSONSchema = JSONSchemaCore & XExtMessages & XExtTransform & XExtCode & XExtParam;
|
|
550
602
|
//#endregion
|
|
551
|
-
export {
|
|
603
|
+
export { QUOTE_OR_BACKSLASH_PATTERN as $, DEFINITION_REF_PREFIXES as A, MISSING_DEFINITION_PREFIX as B, ARROW_FUNCTION_PATTERN as C, DEFAULT_ROOT_NAME as D, DATE_PATTERN_SOURCE as E, INPUT_EXTENSIONS as F, NUMBER_WIRE_PATTERN as G, NOT_KEYWORD_UNSUPPORTED_MARKER as H, INTEGER_TEXT_PATTERN as I, OFFSET_PATTERN_SOURCE as J, NUMERIC_KEYWORDS as K, INTEGER_WIRE_PATTERN as L, FORMAT_PATTERNS as M, IDENTIFIER_PATTERN as N, DEFINITION_KEYWORDS as O, IF_THEN_ELSE_UNSUPPORTED_MARKER as P, PARAM_STYLES as Q, ISO_4217_CURRENCY_CODES as R, ARKTYPE_CODE_EXTENSION_KEYS as S, CONTENT_ENCODINGS as T, NUMBER_FORMATS as U, NON_IDENTIFIER_CHARACTER_PATTERN as V, NUMBER_RANGES as W, OUTPUT_EXTENSION as X, OPENAPI_COMPONENT_SUFFIX_MAP as Y, PARAM_LOCATIONS as Z, XExtMessages as _, JSONSchemaNumberFormat as a, STRING_WIRE_LOCATIONS as at, ALL_CODE_EXTENSION_KEYS as b, JSONSchemaTypes as c, VALIBOT_CODE_EXTENSION_KEYS as ct, Ref as d, ROOT_REFS as et, parseSchemaFile as f, XExtParam as g, ParamStyle as h, JSONSchemaFormat as i, STRING_KEYWORDS as it, EFFECT_CODE_EXTENSION_KEYS as j, DEFINITION_POINTER_PATTERN as k, LocalRef as l, WIRE_PRIMITIVE_ORDER as lt, ParamIn as m, ExternalRef as n, STRINGBOOL_TRUTHY_PATTERN as nt, JSONSchemaStringFormat as o, UNICODE_ESCAPE_PATTERN as ot, XExtTransform as p, OBJECT_PROTOTYPE_PROPERTIES as q, JSONSchema as r, STRING_FORMATS as rt, JSONSchemaType as s, UNSAFE_GENERATED_MARKER as st, ContentEncoding as t, STRINGBOOL_PATTERN as tt, ParseError as u, ZOD_CODE_EXTENSION_KEYS as ut, XExtCode as v, COMPONENT_SCHEMA_REF_PREFIX as w, ANCHOR_REF_PATTERN as x, JSONValue as y, JSON_SCHEMA_TYPES as z };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
import { i as ParamStyle, n as GenerateOptions, r as ParamIn, t as EmitOptions } from "./index-C2L8Ty0-.js";
|
|
1
|
+
import { $ as QUOTE_OR_BACKSLASH_PATTERN, A as DEFINITION_REF_PREFIXES, B as MISSING_DEFINITION_PREFIX, C as ARROW_FUNCTION_PATTERN, D as DEFAULT_ROOT_NAME, E as DATE_PATTERN_SOURCE, F as INPUT_EXTENSIONS, G as NUMBER_WIRE_PATTERN, H as NOT_KEYWORD_UNSUPPORTED_MARKER, I as INTEGER_TEXT_PATTERN, J as OFFSET_PATTERN_SOURCE, K as NUMERIC_KEYWORDS, L as INTEGER_WIRE_PATTERN, M as FORMAT_PATTERNS, N as IDENTIFIER_PATTERN, O as DEFINITION_KEYWORDS, P as IF_THEN_ELSE_UNSUPPORTED_MARKER, Q as PARAM_STYLES, R as ISO_4217_CURRENCY_CODES, S as ARKTYPE_CODE_EXTENSION_KEYS, T as CONTENT_ENCODINGS, U as NUMBER_FORMATS, V as NON_IDENTIFIER_CHARACTER_PATTERN, W as NUMBER_RANGES, X as OUTPUT_EXTENSION, Y as OPENAPI_COMPONENT_SUFFIX_MAP, Z as PARAM_LOCATIONS, _ as XExtMessages, a as JSONSchemaNumberFormat, at as STRING_WIRE_LOCATIONS, b as ALL_CODE_EXTENSION_KEYS, c as JSONSchemaTypes, ct as VALIBOT_CODE_EXTENSION_KEYS, d as Ref, et as ROOT_REFS, f as parseSchemaFile, g as XExtParam, h as ParamStyle, i as JSONSchemaFormat, it as STRING_KEYWORDS, j as EFFECT_CODE_EXTENSION_KEYS, k as DEFINITION_POINTER_PATTERN, l as LocalRef, lt as WIRE_PRIMITIVE_ORDER, m as ParamIn, n as ExternalRef, nt as STRINGBOOL_TRUTHY_PATTERN, o as JSONSchemaStringFormat, ot as UNICODE_ESCAPE_PATTERN, p as XExtTransform, q as OBJECT_PROTOTYPE_PROPERTIES, r as JSONSchema, rt as STRING_FORMATS, s as JSONSchemaType, st as UNSAFE_GENERATED_MARKER, t as ContentEncoding, tt as STRINGBOOL_PATTERN, u as ParseError, ut as ZOD_CODE_EXTENSION_KEYS, v as XExtCode, w as COMPONENT_SCHEMA_REF_PREFIX, x as ANCHOR_REF_PATTERN, y as JSONValue, z as JSON_SCHEMA_TYPES } from "./index-G7UqNQ4w.js";
|
|
3
2
|
import { schemaToAjv } from "./ajv.js";
|
|
3
|
+
import { n as GenerateOptions, t as EmitOptions } from "./index-DYzAccyT.js";
|
|
4
4
|
import { schemaToArktype } from "./arktype.js";
|
|
5
5
|
import { schemaToEffect } from "./effect.js";
|
|
6
6
|
import { TypeboxGenerateOptions, schemaToTypebox } from "./typebox.js";
|
|
@@ -179,38 +179,67 @@ export declare function encodeNonAscii(name: string): string;
|
|
|
179
179
|
*/
|
|
180
180
|
export declare function toIdentifierPascalCase(name: string): string;
|
|
181
181
|
export declare function normalizeTypes(t?: string | readonly string[]): string[];
|
|
182
|
+
/** The keywords of a schema node {@link coerceDefault} reads a `default` against. */
|
|
183
|
+
export type DefaultSchema = {
|
|
184
|
+
readonly $ref?: string;
|
|
185
|
+
readonly type?: string | readonly string[];
|
|
186
|
+
readonly nullable?: boolean;
|
|
187
|
+
readonly enum?: readonly unknown[];
|
|
188
|
+
readonly const?: unknown;
|
|
189
|
+
readonly items?: DefaultSchema | readonly DefaultSchema[] | boolean;
|
|
190
|
+
readonly properties?: {
|
|
191
|
+
readonly [key: string]: DefaultSchema;
|
|
192
|
+
};
|
|
193
|
+
readonly required?: readonly string[];
|
|
194
|
+
readonly additionalProperties?: boolean | object;
|
|
195
|
+
readonly patternProperties?: object;
|
|
196
|
+
readonly unevaluatedProperties?: boolean | object;
|
|
197
|
+
readonly allOf?: readonly DefaultSchema[];
|
|
198
|
+
readonly oneOf?: readonly DefaultSchema[];
|
|
199
|
+
readonly anyOf?: readonly DefaultSchema[];
|
|
200
|
+
};
|
|
201
|
+
type DefaultResult = {
|
|
202
|
+
readonly keep: boolean;
|
|
203
|
+
readonly value: unknown;
|
|
204
|
+
};
|
|
182
205
|
/**
|
|
183
206
|
* Reconcile a schema's `default` value with the type the schema actually emits
|
|
184
|
-
* so the generated `.default(...)` stays assignable.
|
|
207
|
+
* so the generated `.default(...)` stays assignable. The default is kept only
|
|
208
|
+
* when it is a value of the schema, read the way a document usually writes it:
|
|
185
209
|
*
|
|
186
|
-
* - `null` on a
|
|
187
|
-
*
|
|
188
|
-
* - a
|
|
189
|
-
*
|
|
190
|
-
*
|
|
210
|
+
* - `null` is kept only on a nullable schema (or one whose `enum` lists it).
|
|
211
|
+
* - an `enum` / `const` takes only what it lists.
|
|
212
|
+
* - text that spells a value of the schema's type is read as that value: `'true'`
|
|
213
|
+
* for a boolean, `'7'` for a number or an integer; a number or a boolean for a
|
|
214
|
+
* string is written as text. Any other scalar of the wrong type is dropped
|
|
215
|
+
* (`'null'` for an integer, `'strict'` with the quotes for an enum).
|
|
216
|
+
* - an array keeps its items when every one is a value of `items`.
|
|
217
|
+
* - an object default drops keys the schema does not declare, when the emitted
|
|
218
|
+
* object has no index signature (`additionalProperties` is not `true` or a
|
|
219
|
+
* schema, and there are no `patternProperties`), and needs every `required`
|
|
220
|
+
* key. A loose or record schema keeps every key.
|
|
221
|
+
* - a `$ref`, or an `allOf` the node has no type of its own beside, is read as
|
|
222
|
+
* the definition it names when `definitions` has it; a `oneOf` / `anyOf` keeps
|
|
223
|
+
* the default when a member takes it, whatever `type` sits beside it.
|
|
224
|
+
* - a node with nothing to check against (no `type`, an unknown `$ref`) keeps
|
|
225
|
+
* the default as written.
|
|
191
226
|
*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
* mismatches and schemas without an explicit `type` (`oneOf`/`$ref` only)
|
|
195
|
-
* pass through untouched — JSON Schema 2020-12 §9.9.4.1 treats `default` as
|
|
196
|
-
* an annotation with no validity guarantee, so anything finer would need a
|
|
197
|
-
* full validator.
|
|
227
|
+
* JSON Schema 2020-12 §9.9.4.1 treats `default` as an annotation with no
|
|
228
|
+
* validity guarantee, so an invalid one is dropped rather than reported.
|
|
198
229
|
*
|
|
199
230
|
* @example
|
|
200
231
|
* ```ts
|
|
201
|
-
* coerceDefault({ type: 'boolean' }, 'true')
|
|
202
|
-
* coerceDefault({ type: '
|
|
232
|
+
* coerceDefault({ type: 'boolean' }, 'true') // { keep: true, value: true }
|
|
233
|
+
* coerceDefault({ type: 'number' }, '7') // { keep: true, value: 7 }
|
|
234
|
+
* coerceDefault({ type: 'object' }, null) // { keep: false, value: null }
|
|
203
235
|
* coerceDefault({ type: 'object', nullable: true }, null) // { keep: true, value: null }
|
|
204
|
-
* coerceDefault({ type: 'array' }, 'eval')
|
|
236
|
+
* coerceDefault({ type: 'array' }, 'eval') // { keep: false, value: 'eval' }
|
|
237
|
+
* coerceDefault({ enum: ['a', 'b'] }, "'a'") // { keep: false, value: "'a'" }
|
|
205
238
|
* ```
|
|
206
239
|
*/
|
|
207
|
-
export declare function coerceDefault(schema: {
|
|
208
|
-
readonly
|
|
209
|
-
|
|
210
|
-
}, value: unknown): {
|
|
211
|
-
readonly keep: boolean;
|
|
212
|
-
readonly value: unknown;
|
|
213
|
-
};
|
|
240
|
+
export declare function coerceDefault(schema: DefaultSchema, value: unknown, definitions?: {
|
|
241
|
+
readonly [name: string]: DefaultSchema;
|
|
242
|
+
}): DefaultResult;
|
|
214
243
|
/**
|
|
215
244
|
* A message as the expression an emitted check evaluates for each issue: an arrow source
|
|
216
245
|
* is applied to the issue, a sentence becomes a string literal.
|
|
@@ -300,4 +329,4 @@ export declare function resolveOpenAPIRef($ref: string): string | null;
|
|
|
300
329
|
*/
|
|
301
330
|
export declare function makeSafeKey(key: string): string;
|
|
302
331
|
//#endregion
|
|
303
|
-
export { ALL_CODE_EXTENSION_KEYS, ANCHOR_REF_PATTERN, ARKTYPE_CODE_EXTENSION_KEYS, ARROW_FUNCTION_PATTERN, COMPONENT_SCHEMA_REF_PREFIX, CONTENT_ENCODINGS, ContentEncoding, DATE_PATTERN_SOURCE, DEFAULT_ROOT_NAME, DEFINITION_KEYWORDS, DEFINITION_POINTER_PATTERN, DEFINITION_REF_PREFIXES, EFFECT_CODE_EXTENSION_KEYS, type EmitOptions, ExternalRef, FORMAT_PATTERNS, type GenerateOptions, IDENTIFIER_PATTERN, IF_THEN_ELSE_UNSUPPORTED_MARKER, INPUT_EXTENSIONS, INTEGER_TEXT_PATTERN, ISO_4217_CURRENCY_CODES, JSONSchema, JSONSchemaFormat, JSONSchemaNumberFormat, JSONSchemaStringFormat, JSONSchemaType, JSONSchemaTypes, type JSONValue, JSON_SCHEMA_TYPES, LocalRef, MISSING_DEFINITION_PREFIX, NON_IDENTIFIER_CHARACTER_PATTERN, NOT_KEYWORD_UNSUPPORTED_MARKER, NUMBER_FORMATS, NUMBER_RANGES, NUMERIC_KEYWORDS, OBJECT_PROTOTYPE_PROPERTIES, OFFSET_PATTERN_SOURCE, OPENAPI_COMPONENT_SUFFIX_MAP, OUTPUT_EXTENSION, PARAM_LOCATIONS, PARAM_STYLES, type ParamIn, type ParamStyle, ParseError, QUOTE_OR_BACKSLASH_PATTERN, ROOT_REFS, Ref, STRINGBOOL_PATTERN, STRINGBOOL_TRUTHY_PATTERN, STRING_FORMATS, STRING_KEYWORDS, STRING_WIRE_LOCATIONS, TypeboxGenerateOptions, UNICODE_ESCAPE_PATTERN, UNSAFE_GENERATED_MARKER, VALIBOT_CODE_EXTENSION_KEYS, WIRE_PRIMITIVE_ORDER, type XExtCode, type XExtMessages, type XExtTransform, ZOD_CODE_EXTENSION_KEYS, parseSchemaFile, schemaToAjv, schemaToArktype, schemaToEffect, schemaToTypebox, schemaToValibot, schemaToYup, schemaToZod };
|
|
332
|
+
export { ALL_CODE_EXTENSION_KEYS, ANCHOR_REF_PATTERN, ARKTYPE_CODE_EXTENSION_KEYS, ARROW_FUNCTION_PATTERN, COMPONENT_SCHEMA_REF_PREFIX, CONTENT_ENCODINGS, ContentEncoding, DATE_PATTERN_SOURCE, DEFAULT_ROOT_NAME, DEFINITION_KEYWORDS, DEFINITION_POINTER_PATTERN, DEFINITION_REF_PREFIXES, EFFECT_CODE_EXTENSION_KEYS, type EmitOptions, ExternalRef, FORMAT_PATTERNS, type GenerateOptions, IDENTIFIER_PATTERN, IF_THEN_ELSE_UNSUPPORTED_MARKER, INPUT_EXTENSIONS, INTEGER_TEXT_PATTERN, INTEGER_WIRE_PATTERN, ISO_4217_CURRENCY_CODES, JSONSchema, JSONSchemaFormat, JSONSchemaNumberFormat, JSONSchemaStringFormat, JSONSchemaType, JSONSchemaTypes, type JSONValue, JSON_SCHEMA_TYPES, LocalRef, MISSING_DEFINITION_PREFIX, NON_IDENTIFIER_CHARACTER_PATTERN, NOT_KEYWORD_UNSUPPORTED_MARKER, NUMBER_FORMATS, NUMBER_RANGES, NUMBER_WIRE_PATTERN, NUMERIC_KEYWORDS, OBJECT_PROTOTYPE_PROPERTIES, OFFSET_PATTERN_SOURCE, OPENAPI_COMPONENT_SUFFIX_MAP, OUTPUT_EXTENSION, PARAM_LOCATIONS, PARAM_STYLES, type ParamIn, type ParamStyle, ParseError, QUOTE_OR_BACKSLASH_PATTERN, ROOT_REFS, Ref, STRINGBOOL_PATTERN, STRINGBOOL_TRUTHY_PATTERN, STRING_FORMATS, STRING_KEYWORDS, STRING_WIRE_LOCATIONS, TypeboxGenerateOptions, UNICODE_ESCAPE_PATTERN, UNSAFE_GENERATED_MARKER, VALIBOT_CODE_EXTENSION_KEYS, WIRE_PRIMITIVE_ORDER, type XExtCode, type XExtMessages, type XExtParam, type XExtTransform, ZOD_CODE_EXTENSION_KEYS, parseSchemaFile, schemaToAjv, schemaToArktype, schemaToEffect, schemaToTypebox, schemaToValibot, schemaToYup, schemaToZod };
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { $ as DEFINITION_REF_PREFIXES, At as
|
|
1
|
+
import { $ as DEFINITION_REF_PREFIXES, At as UNSAFE_GENERATED_MARKER, Ct as ROOT_REFS, Dt as STRING_KEYWORDS, Et as STRING_FORMATS, G as ARKTYPE_CODE_EXTENSION_KEYS, J as CONTENT_ENCODINGS, K as ARROW_FUNCTION_PATTERN, Mt as WIRE_PRIMITIVE_ORDER, Nt as ZOD_CODE_EXTENSION_KEYS, Ot as STRING_WIRE_LOCATIONS, Q as DEFINITION_POINTER_PATTERN, St as QUOTE_OR_BACKSLASH_PATTERN, Tt as STRINGBOOL_TRUTHY_PATTERN, U as ALL_CODE_EXTENSION_KEYS, W as ANCHOR_REF_PATTERN, X as DEFAULT_ROOT_NAME, Y as DATE_PATTERN_SOURCE, Z as DEFINITION_KEYWORDS, _t as OFFSET_PATTERN_SOURCE, a as encodeNonAscii, at as INTEGER_TEXT_PATTERN, bt as PARAM_LOCATIONS, c as normalizeTypes, ct as JSON_SCHEMA_TYPES, d as toPascalCase, dt as NOT_KEYWORD_UNSUPPORTED_MARKER, et as EFFECT_CODE_EXTENSION_KEYS, f as valibotError, ft as NUMBER_FORMATS, g as zodErrorPart, gt as OBJECT_PROTOTYPE_PROPERTIES, h as zodError, ht as NUMERIC_KEYWORDS, i as effectMessage, it as INPUT_EXTENSIONS, jt as VALIBOT_CODE_EXTENSION_KEYS, kt as UNICODE_ESCAPE_PATTERN, l as resolveOpenAPIRef, lt as MISSING_DEFINITION_PREFIX, m as zodBaseError, mt as NUMBER_WIRE_PATTERN, n as effectError, nt as IDENTIFIER_PATTERN, o as issueMessageExpression, ot as INTEGER_WIRE_PATTERN, p as valibotErrorPart, pt as NUMBER_RANGES, q as COMPONENT_SCHEMA_REF_PREFIX, r as effectErrorPart, rt as IF_THEN_ELSE_UNSUPPORTED_MARKER, s as makeSafeKey, st as ISO_4217_CURRENCY_CODES, t as coerceDefault, tt as FORMAT_PATTERNS, u as toIdentifierPascalCase, ut as NON_IDENTIFIER_CHARACTER_PATTERN, vt as OPENAPI_COMPONENT_SUFFIX_MAP, wt as STRINGBOOL_PATTERN, xt as PARAM_STYLES, yt as OUTPUT_EXTENSION } from "./utils-Bky98UmP.js";
|
|
2
2
|
import { i as fmt, n as parseSchemaFile, r as FormatError, t as ParseError } from "./parser-CyJ2auea.js";
|
|
3
|
-
import { n as ajv, t as schemaToAjv } from "./ajv-
|
|
4
|
-
import { n as arktype, t as schemaToArktype } from "./arktype-
|
|
5
|
-
import { n as effect, r as wholeValueMessage, t as schemaToEffect } from "./effect-
|
|
6
|
-
import { n as nestedTypeboxOptions, r as typebox, t as schemaToTypebox } from "./typebox-
|
|
7
|
-
import { n as valibot, t as schemaToValibot } from "./valibot-
|
|
8
|
-
import { n as yup, t as schemaToYup } from "./yup-
|
|
9
|
-
import { n as zod, t as schemaToZod } from "./zod-
|
|
10
|
-
export { ALL_CODE_EXTENSION_KEYS, ANCHOR_REF_PATTERN, ARKTYPE_CODE_EXTENSION_KEYS, ARROW_FUNCTION_PATTERN, COMPONENT_SCHEMA_REF_PREFIX, CONTENT_ENCODINGS, DATE_PATTERN_SOURCE, DEFAULT_ROOT_NAME, DEFINITION_KEYWORDS, DEFINITION_POINTER_PATTERN, DEFINITION_REF_PREFIXES, EFFECT_CODE_EXTENSION_KEYS, FORMAT_PATTERNS, FormatError, IDENTIFIER_PATTERN, IF_THEN_ELSE_UNSUPPORTED_MARKER, INPUT_EXTENSIONS, INTEGER_TEXT_PATTERN, ISO_4217_CURRENCY_CODES, JSON_SCHEMA_TYPES, MISSING_DEFINITION_PREFIX, NON_IDENTIFIER_CHARACTER_PATTERN, NOT_KEYWORD_UNSUPPORTED_MARKER, NUMBER_FORMATS, NUMBER_RANGES, NUMERIC_KEYWORDS, OBJECT_PROTOTYPE_PROPERTIES, OFFSET_PATTERN_SOURCE, OPENAPI_COMPONENT_SUFFIX_MAP, OUTPUT_EXTENSION, PARAM_LOCATIONS, PARAM_STYLES, ParseError, QUOTE_OR_BACKSLASH_PATTERN, ROOT_REFS, STRINGBOOL_PATTERN, STRINGBOOL_TRUTHY_PATTERN, STRING_FORMATS, STRING_KEYWORDS, STRING_WIRE_LOCATIONS, UNICODE_ESCAPE_PATTERN, UNSAFE_GENERATED_MARKER, VALIBOT_CODE_EXTENSION_KEYS, WIRE_PRIMITIVE_ORDER, ZOD_CODE_EXTENSION_KEYS, ajv, arktype, coerceDefault, effect, effectError, effectErrorPart, effectMessage, encodeNonAscii, fmt, issueMessageExpression, makeSafeKey, nestedTypeboxOptions, normalizeTypes, parseSchemaFile, resolveOpenAPIRef, schemaToAjv, schemaToArktype, schemaToEffect, schemaToTypebox, schemaToValibot, schemaToYup, schemaToZod, toIdentifierPascalCase, toPascalCase, typebox, valibot, valibotError, valibotErrorPart, wholeValueMessage, yup, zod, zodBaseError, zodError, zodErrorPart };
|
|
3
|
+
import { n as ajv, t as schemaToAjv } from "./ajv-DS9gtNZC.js";
|
|
4
|
+
import { n as arktype, t as schemaToArktype } from "./arktype-CRZ8vXZ5.js";
|
|
5
|
+
import { n as effect, r as wholeValueMessage, t as schemaToEffect } from "./effect-BkWovUi3.js";
|
|
6
|
+
import { n as nestedTypeboxOptions, r as typebox, t as schemaToTypebox } from "./typebox-wYeJqy7T.js";
|
|
7
|
+
import { n as valibot, t as schemaToValibot } from "./valibot-DQUEDYKt.js";
|
|
8
|
+
import { n as yup, t as schemaToYup } from "./yup-BMpa9Co1.js";
|
|
9
|
+
import { n as zod, t as schemaToZod } from "./zod-Dq9LtqPL.js";
|
|
10
|
+
export { ALL_CODE_EXTENSION_KEYS, ANCHOR_REF_PATTERN, ARKTYPE_CODE_EXTENSION_KEYS, ARROW_FUNCTION_PATTERN, COMPONENT_SCHEMA_REF_PREFIX, CONTENT_ENCODINGS, DATE_PATTERN_SOURCE, DEFAULT_ROOT_NAME, DEFINITION_KEYWORDS, DEFINITION_POINTER_PATTERN, DEFINITION_REF_PREFIXES, EFFECT_CODE_EXTENSION_KEYS, FORMAT_PATTERNS, FormatError, IDENTIFIER_PATTERN, IF_THEN_ELSE_UNSUPPORTED_MARKER, INPUT_EXTENSIONS, INTEGER_TEXT_PATTERN, INTEGER_WIRE_PATTERN, ISO_4217_CURRENCY_CODES, JSON_SCHEMA_TYPES, MISSING_DEFINITION_PREFIX, NON_IDENTIFIER_CHARACTER_PATTERN, NOT_KEYWORD_UNSUPPORTED_MARKER, NUMBER_FORMATS, NUMBER_RANGES, NUMBER_WIRE_PATTERN, NUMERIC_KEYWORDS, OBJECT_PROTOTYPE_PROPERTIES, OFFSET_PATTERN_SOURCE, OPENAPI_COMPONENT_SUFFIX_MAP, OUTPUT_EXTENSION, PARAM_LOCATIONS, PARAM_STYLES, ParseError, QUOTE_OR_BACKSLASH_PATTERN, ROOT_REFS, STRINGBOOL_PATTERN, STRINGBOOL_TRUTHY_PATTERN, STRING_FORMATS, STRING_KEYWORDS, STRING_WIRE_LOCATIONS, UNICODE_ESCAPE_PATTERN, UNSAFE_GENERATED_MARKER, VALIBOT_CODE_EXTENSION_KEYS, WIRE_PRIMITIVE_ORDER, ZOD_CODE_EXTENSION_KEYS, ajv, arktype, coerceDefault, effect, effectError, effectErrorPart, effectMessage, encodeNonAscii, fmt, issueMessageExpression, makeSafeKey, nestedTypeboxOptions, normalizeTypes, parseSchemaFile, resolveOpenAPIRef, schemaToAjv, schemaToArktype, schemaToEffect, schemaToTypebox, schemaToValibot, schemaToYup, schemaToZod, toIdentifierPascalCase, toPascalCase, typebox, valibot, valibotError, valibotErrorPart, wholeValueMessage, yup, zod, zodBaseError, zodError, zodErrorPart };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { $ as DEFINITION_REF_PREFIXES, D as isComposite, H as isStringWireLocation, M as isNullable, O as isDeepLocalPointer, R as isRootRef, S as hasFixedLength, V as isShapelessMember, X as DEFAULT_ROOT_NAME, c as normalizeTypes, j as isNullTypeMember, k as isDefaultOnlyMember, l as resolveOpenAPIRef, s as makeSafeKey,
|
|
2
|
-
import { D as
|
|
1
|
+
import { $ as DEFINITION_REF_PREFIXES, C as hasNumericKeyword, D as isComposite, H as isStringWireLocation, M as isNullable, O as isDeepLocalPointer, R as isRootRef, S as hasFixedLength, V as isShapelessMember, X as DEFAULT_ROOT_NAME, c as normalizeTypes, dt as NOT_KEYWORD_UNSUPPORTED_MARKER, j as isNullTypeMember, k as isDefaultOnlyMember, l as resolveOpenAPIRef, s as makeSafeKey, w as hasStringKeyword, y as hasCombinator } from "./utils-Bky98UmP.js";
|
|
2
|
+
import { $ as hasNotKeyword, D as stringboolTruthyPattern, E as stringboolPattern, G as schemaNamer, H as planDocument, I as typeboxDefaultOpt, J as isOptionalByDefault, K as cyclicDefinitionNames, L as typeboxMetaOpts, R as typeboxRefOpt, U as renderDefinitions, V as missingDefinitionComment, W as rootNameOf, Y as itemsSchemaOf, a as typeboxWrap, b as integerWirePattern, c as withPolymorphicBases, g as hoistNestedRefs, it as patternSource, nt as foldAllOfMembers, q as hasRootSelfReference, rt as isKeywordOnlyMember, w as numberWirePattern } from "./helper-CbeedY35.js";
|
|
3
3
|
//#region src/generator/typebox/enum.ts
|
|
4
4
|
function lit(v) {
|
|
5
5
|
if (v === null) return "null";
|
|
@@ -260,7 +260,7 @@ function string(schema, ref) {
|
|
|
260
260
|
const opts = [
|
|
261
261
|
...typeboxRefOpt(ref),
|
|
262
262
|
schema.format && FORMAT_MAP[schema.format] ? `format:${JSON.stringify(FORMAT_MAP[schema.format])}` : void 0,
|
|
263
|
-
schema.pattern ? `pattern:${JSON.stringify(schema.pattern)}` : contentPattern ? `pattern:${JSON.stringify(contentPattern)}` : void 0,
|
|
263
|
+
schema.pattern ? `pattern:${JSON.stringify(patternSource(schema.pattern))}` : contentPattern ? `pattern:${JSON.stringify(contentPattern)}` : void 0,
|
|
264
264
|
isFixedLength ? `minLength:${schema.minLength}` : void 0,
|
|
265
265
|
isFixedLength ? `maxLength:${schema.maxLength}` : void 0,
|
|
266
266
|
!isFixedLength && schema.minLength !== void 0 ? `minLength:${schema.minLength}` : void 0,
|
|
@@ -312,10 +312,26 @@ function tbPrim(name, schema, extraOpts = [], ref) {
|
|
|
312
312
|
* Codec decodes from a string. A host `ref` lands on this inner `Type.String`,
|
|
313
313
|
* not on the `Codec(...)` wrapper.
|
|
314
314
|
*/
|
|
315
|
-
function wireString(schema, ref) {
|
|
316
|
-
const opts = [
|
|
315
|
+
function wireString(schema, ref, pattern) {
|
|
316
|
+
const opts = [
|
|
317
|
+
...typeboxRefOpt(ref),
|
|
318
|
+
...pattern === void 0 ? [] : [`pattern:${pattern}`],
|
|
319
|
+
...typeboxDefaultOpt(schema, true)
|
|
320
|
+
];
|
|
317
321
|
return opts.length > 0 ? `Type.String({${opts.join(",")}})` : "Type.String()";
|
|
318
322
|
}
|
|
323
|
+
/** A keyword-only `allOf` member. TypeBox has no type-guarded check, so the keyword's type carries it. */
|
|
324
|
+
function keywordSchema(schema) {
|
|
325
|
+
if (hasStringKeyword(schema) && !hasNumericKeyword(schema)) return string({
|
|
326
|
+
...schema,
|
|
327
|
+
type: "string"
|
|
328
|
+
});
|
|
329
|
+
if (hasNumericKeyword(schema) && !hasStringKeyword(schema)) return number({
|
|
330
|
+
...schema,
|
|
331
|
+
type: "number"
|
|
332
|
+
});
|
|
333
|
+
return "Type.Any()";
|
|
334
|
+
}
|
|
319
335
|
/**
|
|
320
336
|
* Emits a two-argument TypeBox factory call (`Type.X(payload, {opts})`),
|
|
321
337
|
* embedding any meta options from the schema. Returns `Type.X(payload)` when
|
|
@@ -383,12 +399,14 @@ function typebox(schema, rootName = DEFAULT_ROOT_NAME, isTypebox = false, option
|
|
|
383
399
|
if (schema.allOf.length === 0) return typeboxWrap(tbPrim("Type.Any", schema, [], hostRef), schema);
|
|
384
400
|
const nullable = isNullable(schema) || schema.allOf.some(isNullTypeMember);
|
|
385
401
|
const defaultValue = schema.allOf.find(isDefaultOnlyMember)?.default;
|
|
386
|
-
const schemas = schema.allOf.filter((s) => !isShapelessMember(s)).map((s) => typebox(s, rootName, isTypebox, childOptions));
|
|
402
|
+
const schemas = foldAllOfMembers(schema.allOf.filter((s) => !isShapelessMember(s)), isStringWireParam).map((s) => isKeywordOnlyMember(s) ? keywordSchema(s) : typebox(s, rootName, isTypebox, childOptions));
|
|
387
403
|
if (schemas.length === 0) return typeboxWrap(tbPrim("Type.Any", schema, [], hostRef), {
|
|
388
404
|
...schema,
|
|
389
405
|
nullable
|
|
390
406
|
});
|
|
391
|
-
const
|
|
407
|
+
const unevaluated = schema.unevaluatedProperties;
|
|
408
|
+
const unevaluatedOpt = unevaluated === false ? ["unevaluatedProperties:false"] : typeof unevaluated === "object" && unevaluated !== null ? [`unevaluatedProperties:${typebox(unevaluated, rootName, isTypebox, childOptions)}`] : [];
|
|
409
|
+
const baseResult = schemas.length === 1 && unevaluatedOpt.length === 0 ? schemas[0] : tbComp("Type.Intersect", `[${schemas.join(",")}]`, schema, [...messageOpt(schema["x-allOf-message"]), ...unevaluatedOpt], hostRef);
|
|
392
410
|
if (defaultValue !== void 0) {
|
|
393
411
|
const formatLiteral = typeof defaultValue === "boolean" || typeof defaultValue === "number" ? `${defaultValue}` : JSON.stringify(defaultValue);
|
|
394
412
|
const intersectOpts = [
|
|
@@ -418,7 +436,7 @@ function typebox(schema, rootName = DEFAULT_ROOT_NAME, isTypebox = false, option
|
|
|
418
436
|
if (types.includes("number")) {
|
|
419
437
|
const base = number(schema, hostRef);
|
|
420
438
|
if (isStringWireParam) {
|
|
421
|
-
const wire = wireString(schema, hostRef);
|
|
439
|
+
const wire = wireString(schema, hostRef, numberWirePattern());
|
|
422
440
|
return typeboxWrap(`Codec(${wire}).Decode((value)=>Number(value)).Encode((value)=>String(value))`, schema);
|
|
423
441
|
}
|
|
424
442
|
return typeboxWrap(base, schema);
|
|
@@ -426,16 +444,15 @@ function typebox(schema, rootName = DEFAULT_ROOT_NAME, isTypebox = false, option
|
|
|
426
444
|
if (types.includes("integer")) {
|
|
427
445
|
const base = integer(schema, hostRef);
|
|
428
446
|
if (isStringWireParam) {
|
|
429
|
-
const wire = wireString(schema, hostRef);
|
|
430
|
-
return typeboxWrap(`Codec(${wire}).Decode((value)=>Number
|
|
447
|
+
const wire = wireString(schema, hostRef, integerWirePattern());
|
|
448
|
+
return typeboxWrap(`Codec(${wire}).Decode((value)=>Number(value)).Encode((value)=>String(value))`, schema);
|
|
431
449
|
}
|
|
432
450
|
return typeboxWrap(base, schema);
|
|
433
451
|
}
|
|
434
452
|
if (types.includes("boolean")) {
|
|
435
453
|
if (isStringWireParam) {
|
|
436
|
-
const
|
|
437
|
-
|
|
438
|
-
return typeboxWrap(`Codec(${union}).Decode((value)=>value==='true').Encode((value)=>value?'true':'false')`, schema);
|
|
454
|
+
const wire = wireString(schema, hostRef, stringboolPattern());
|
|
455
|
+
return typeboxWrap(`Codec(${wire}).Decode((value)=>${stringboolTruthyPattern()}.test(value)).Encode((value)=>value?'true':'false')`, schema);
|
|
439
456
|
}
|
|
440
457
|
return typeboxWrap(tbPrim("Type.Boolean", schema, [], hostRef), schema);
|
|
441
458
|
}
|
|
@@ -482,6 +499,7 @@ function typebox(schema, rootName = DEFAULT_ROOT_NAME, isTypebox = false, option
|
|
|
482
499
|
return typeboxWrap(`Codec(${wire}).Decode((value)=>new Date(value)).Encode((value)=>value.toISOString())`, schema);
|
|
483
500
|
}
|
|
484
501
|
if (types.length === 1 && types[0] === "null") return typeboxWrap(tbPrim("Type.Null", schema, [], hostRef), schema);
|
|
502
|
+
if (typeof schema.additionalProperties === "object") return readonly(typeboxWrap(object(schema, rootName, isTypebox, options), schema));
|
|
485
503
|
return typeboxWrap(tbPrim("Type.Any", schema, [], hostRef), schema);
|
|
486
504
|
}
|
|
487
505
|
//#endregion
|
|
@@ -495,7 +513,8 @@ function importLine(emitted) {
|
|
|
495
513
|
* with plain `const` declarations, so a cyclic document becomes one
|
|
496
514
|
* `Type.Cyclic($defs, root)` map instead.
|
|
497
515
|
*/
|
|
498
|
-
function schemaToTypebox(
|
|
516
|
+
function schemaToTypebox(input, options) {
|
|
517
|
+
const schema = withPolymorphicBases(hoistNestedRefs(input));
|
|
499
518
|
const exportType = options?.exportType ?? true;
|
|
500
519
|
const openapi = options?.openapi ?? false;
|
|
501
520
|
const hostRef = options?.ref;
|
package/dist/typebox.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as JSONSchema } from "./index-
|
|
2
|
-
import { n as GenerateOptions } from "./index-
|
|
1
|
+
import { r as JSONSchema } from "./index-G7UqNQ4w.js";
|
|
2
|
+
import { n as GenerateOptions } from "./index-DYzAccyT.js";
|
|
3
3
|
//#region src/generator/typebox/index.d.ts
|
|
4
4
|
/** The options of `schemaToTypebox`: the common ones, plus a host `$ref` name. */
|
|
5
5
|
export type TypeboxGenerateOptions = Omit<GenerateOptions, 'unsafeCodeExtensions'> & {
|
|
@@ -17,5 +17,5 @@ export type TypeboxGenerateOptions = Omit<GenerateOptions, 'unsafeCodeExtensions
|
|
|
17
17
|
* with plain `const` declarations, so a cyclic document becomes one
|
|
18
18
|
* `Type.Cyclic($defs, root)` map instead.
|
|
19
19
|
*/
|
|
20
|
-
export declare function schemaToTypebox(
|
|
20
|
+
export declare function schemaToTypebox(input: JSONSchema, options?: TypeboxGenerateOptions): string;
|
|
21
21
|
//#endregion
|
package/dist/typebox.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as schemaToTypebox } from "./typebox-
|
|
1
|
+
export { t as schemaToTypebox } from "./typebox-wYeJqy7T.js";
|