schema-truth 0.0.0-stage → 0.7.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/README.md +143 -2
- package/dist/ajv-DTP2FXRr.js +105 -0
- package/dist/ajv.d.ts +24 -0
- package/dist/ajv.js +1 -0
- package/dist/arktype-BdvvaBQX.js +746 -0
- package/dist/arktype.d.ts +10 -0
- package/dist/arktype.js +1 -0
- package/dist/cli/ajv.d.ts +1 -0
- package/dist/cli/ajv.js +15 -0
- package/dist/cli/arktype.d.ts +1 -0
- package/dist/cli/arktype.js +15 -0
- package/dist/cli/effect.d.ts +1 -0
- package/dist/cli/effect.js +15 -0
- package/dist/cli/typebox.d.ts +1 -0
- package/dist/cli/typebox.js +15 -0
- package/dist/cli/valibot.d.ts +1 -0
- package/dist/cli/valibot.js +15 -0
- package/dist/cli/yup.d.ts +1 -0
- package/dist/cli/yup.js +15 -0
- package/dist/cli/zod.d.ts +1 -0
- package/dist/cli/zod.js +15 -0
- package/dist/cli-CL2mSark.js +124 -0
- package/dist/effect-mUknRPv_.js +645 -0
- package/dist/effect.d.ts +12 -0
- package/dist/effect.js +1 -0
- package/dist/helper-Cfvb5UDq.js +1115 -0
- package/dist/index-C2L8Ty0-.d.ts +65 -0
- package/dist/index-DbV3dEmN.d.ts +551 -0
- package/dist/index.d.ts +303 -0
- package/dist/index.js +10 -0
- package/dist/parser-CyJ2auea.js +36 -0
- package/dist/typebox-BdWJv3ND.js +544 -0
- package/dist/typebox.d.ts +21 -0
- package/dist/typebox.js +1 -0
- package/dist/utils-WNBq1HR0.js +1017 -0
- package/dist/valibot-CaJIynCH.js +664 -0
- package/dist/valibot.d.ts +9 -0
- package/dist/valibot.js +1 -0
- package/dist/yup-CM2TSFig.js +92 -0
- package/dist/yup.d.ts +17 -0
- package/dist/yup.js +1 -0
- package/dist/zod-BsXLZfwK.js +777 -0
- package/dist/zod.d.ts +9 -0
- package/dist/zod.js +1 -0
- package/package.json +112 -4
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
import { $ as STRING_KEYWORDS, A as IDENTIFIER_PATTERN, B as NUMBER_RANGES, C as DATE_PATTERN_SOURCE, D as DEFINITION_REF_PREFIXES, E as DEFINITION_POINTER_PATTERN, F as JSON_SCHEMA_TYPES, G as OUTPUT_EXTENSION, H as OBJECT_PROTOTYPE_PROPERTIES, I as MISSING_DEFINITION_PREFIX, J as QUOTE_OR_BACKSLASH_PATTERN, K as PARAM_LOCATIONS, L as NON_IDENTIFIER_CHARACTER_PATTERN, M as INPUT_EXTENSIONS, N as INTEGER_TEXT_PATTERN, O as EFFECT_CODE_EXTENSION_KEYS, P as ISO_4217_CURRENCY_CODES, Q as STRING_FORMATS, R as NOT_KEYWORD_UNSUPPORTED_MARKER, S as CONTENT_ENCODINGS, T as DEFINITION_KEYWORDS, U as OFFSET_PATTERN_SOURCE, V as NUMERIC_KEYWORDS, W as OPENAPI_COMPONENT_SUFFIX_MAP, X as STRINGBOOL_PATTERN, Y as ROOT_REFS, Z as STRINGBOOL_TRUTHY_PATTERN, _ as ALL_CODE_EXTENSION_KEYS, a as JSONSchemaNumberFormat, at as ZOD_CODE_EXTENSION_KEYS, b as ARROW_FUNCTION_PATTERN, c as JSONSchemaTypes, d as Ref, et as STRING_WIRE_LOCATIONS, f as parseSchemaFile, g as JSONValue, h as XExtCode, i as JSONSchemaFormat, it as WIRE_PRIMITIVE_ORDER, j as IF_THEN_ELSE_UNSUPPORTED_MARKER, k as FORMAT_PATTERNS, l as LocalRef, m as XExtMessages, n as ExternalRef, nt as UNSAFE_GENERATED_MARKER, o as JSONSchemaStringFormat, p as XExtTransform, q as PARAM_STYLES, r as JSONSchema, rt as VALIBOT_CODE_EXTENSION_KEYS, s as JSONSchemaType, t as ContentEncoding, tt as UNICODE_ESCAPE_PATTERN, u as ParseError, v as ANCHOR_REF_PATTERN, w as DEFAULT_ROOT_NAME, x as COMPONENT_SCHEMA_REF_PREFIX, y as ARKTYPE_CODE_EXTENSION_KEYS, z as NUMBER_FORMATS } from "./index-DbV3dEmN.js";
|
|
2
|
+
import { i as ParamStyle, n as GenerateOptions, r as ParamIn, t as EmitOptions } from "./index-C2L8Ty0-.js";
|
|
3
|
+
import { schemaToAjv } from "./ajv.js";
|
|
4
|
+
import { schemaToArktype } from "./arktype.js";
|
|
5
|
+
import { schemaToEffect } from "./effect.js";
|
|
6
|
+
import { TypeboxGenerateOptions, schemaToTypebox } from "./typebox.js";
|
|
7
|
+
import { schemaToValibot } from "./valibot.js";
|
|
8
|
+
import { schemaToYup } from "./yup.js";
|
|
9
|
+
import { schemaToZod } from "./zod.js";
|
|
10
|
+
import * as Effect from "effect/Effect";
|
|
11
|
+
//#region src/format/index.d.ts
|
|
12
|
+
declare const FormatError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
13
|
+
readonly _tag: "FormatError";
|
|
14
|
+
} & Readonly<A>;
|
|
15
|
+
/** oxfmt rejected the source it was handed. */
|
|
16
|
+
export declare class FormatError extends FormatError_base<{
|
|
17
|
+
readonly message: string;
|
|
18
|
+
}> {}
|
|
19
|
+
/** Formats generated TypeScript. Failures land in the error channel. */
|
|
20
|
+
export declare function fmt(input: string): Effect.Effect<string, FormatError, never>;
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/generator/ajv/ajv.d.ts
|
|
23
|
+
/**
|
|
24
|
+
* One schema node to one Ajv draft-07 schema-object expression.
|
|
25
|
+
*
|
|
26
|
+
* Unsupported keywords, combinators, `$ref` and `x-*` extensions are silent
|
|
27
|
+
* no-ops: the node still becomes a balanced object literal (`{}` when nothing
|
|
28
|
+
* in this slice applies).
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* ajv({ type: 'string', format: 'email' }) // "{type:'string',format:'email'}"
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare function ajv(schema: JSONSchema): string;
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region src/generator/arktype/arktype.d.ts
|
|
38
|
+
/**
|
|
39
|
+
* Generate ArkType schema code from JSON Schema.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* arktype({ type: 'string' }, 'MySchema') // '"string"'
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare function arktype(schema: JSONSchema, rootName?: string, isArktype?: boolean, options?: EmitOptions): string;
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src/generator/effect/effect.d.ts
|
|
49
|
+
/**
|
|
50
|
+
* Replace every decoding failure of `inner` with a single message.
|
|
51
|
+
*
|
|
52
|
+
* v4 annotates a node with a plain `message` string, but that only covers
|
|
53
|
+
* issues the node itself reports — a missing or mistyped key is reported
|
|
54
|
+
* deeper and keeps its own message. Validating the whole value through one
|
|
55
|
+
* filter and then decoding restores the v3 `transformOrFail` behaviour of
|
|
56
|
+
* collapsing any failure into the given message, and `decodeTo` carries the
|
|
57
|
+
* inner schema's type through.
|
|
58
|
+
*/
|
|
59
|
+
export declare function wholeValueMessage(inner: string, message: string): string;
|
|
60
|
+
/**
|
|
61
|
+
* Generate Effect Schema code from a JSON Schema.
|
|
62
|
+
*
|
|
63
|
+
* The `options.readonly` flag is accepted for API symmetry with the other
|
|
64
|
+
* generators but is a no-op for Effect Schema: fields produced by
|
|
65
|
+
* `Schema.Struct({...})` are already `readonly` at the TypeScript type level,
|
|
66
|
+
* and `Schema.Array(...)` returns `ReadonlyArray<T>` by default. Effect Schema
|
|
67
|
+
* has no separate runtime "readonly" wrapper.
|
|
68
|
+
*/
|
|
69
|
+
export declare function effect(schema: JSONSchema, rootName?: string, isEffect?: boolean, options?: EmitOptions): string;
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/generator/typebox/typebox.d.ts
|
|
72
|
+
/**
|
|
73
|
+
* Generation options threaded through every TypeBox emitter.
|
|
74
|
+
*
|
|
75
|
+
* `cyclicRefs` holds the PascalCase names that `schemaToTypebox` is emitting
|
|
76
|
+
* inside a single `Type.Cyclic($defs, root)` map. References to those names
|
|
77
|
+
* become `Type.Ref('Name')` instead of a bare identifier, because a `const`
|
|
78
|
+
* cannot reference a peer that is declared later in the cycle.
|
|
79
|
+
*
|
|
80
|
+
* `ref` is a host `$ref` name for the **current** node only (the outermost
|
|
81
|
+
* `Type.*` factory). Nested calls drop it so properties and `$defs` members
|
|
82
|
+
* do not inherit the root's name.
|
|
83
|
+
*/
|
|
84
|
+
export type TypeboxOptions = {
|
|
85
|
+
readonly openapi?: boolean;
|
|
86
|
+
readonly readonly?: boolean;
|
|
87
|
+
readonly paramIn?: ParamIn;
|
|
88
|
+
readonly cyclicRefs?: ReadonlySet<string>;
|
|
89
|
+
readonly ref?: string;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Options for a nested TypeBox node: the same as `options` but without a
|
|
93
|
+
* host `ref`, so only the outermost factory of a declaration receives it.
|
|
94
|
+
*/
|
|
95
|
+
export declare function nestedTypeboxOptions(options?: TypeboxOptions): TypeboxOptions | undefined;
|
|
96
|
+
export declare function typebox(schema: JSONSchema, rootName?: string, isTypebox?: boolean, options?: TypeboxOptions): string;
|
|
97
|
+
//#endregion
|
|
98
|
+
//#region src/generator/valibot/valibot.d.ts
|
|
99
|
+
/**
|
|
100
|
+
* Generate Valibot schema code from JSON Schema.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```ts
|
|
104
|
+
* valibot({ type: 'string' }, 'MySchema') // 'v.string()'
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
export declare function valibot(schema: JSONSchema, rootName?: string, isValibot?: boolean, options?: EmitOptions): string;
|
|
108
|
+
//#endregion
|
|
109
|
+
//#region src/generator/yup/yup.d.ts
|
|
110
|
+
/**
|
|
111
|
+
* Generate a Yup expression from one JSON Schema node.
|
|
112
|
+
*
|
|
113
|
+
* Unsupported keywords, combinators, `$ref` and `x-*` extensions are silent
|
|
114
|
+
* no-ops. Unknown nodes fall back to `yup.mixed()`.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```ts
|
|
118
|
+
* yup({ type: 'string' }) // 'yup.string()'
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
export declare function yup(schema: JSONSchema): string;
|
|
122
|
+
//#endregion
|
|
123
|
+
//#region src/generator/zod/zod.d.ts
|
|
124
|
+
/**
|
|
125
|
+
* Generate Zod schema code from JSON Schema.
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```ts
|
|
129
|
+
* zod({ type: 'string' }, 'MySchema') // 'z.string()'
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
export declare function zod(schema: JSONSchema, rootName?: string, isZod?: boolean, options?: EmitOptions): string;
|
|
133
|
+
//#endregion
|
|
134
|
+
//#region src/utils/index.d.ts
|
|
135
|
+
/**
|
|
136
|
+
* Convert string to PascalCase (first character uppercase).
|
|
137
|
+
*
|
|
138
|
+
* When the input contains characters that are not valid in a TypeScript
|
|
139
|
+
* identifier (whitespace, dots, slashes, etc.) the input is routed through
|
|
140
|
+
* {@link toIdentifierPascalCase} so the generated variable name remains
|
|
141
|
+
* parseable. Hyphens and underscores are preserved for back-compat with
|
|
142
|
+
* upstream titles that already generated working code.
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* ```ts
|
|
146
|
+
* toPascalCase('animal') // 'Animal'
|
|
147
|
+
* toPascalCase('userProfile') // 'UserProfile'
|
|
148
|
+
* toPascalCase('Self-Referencing Entities') // 'SelfReferencingEntities'
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
export declare function toPascalCase(name: string): string;
|
|
152
|
+
/**
|
|
153
|
+
* Encode non-ASCII characters as `u<hex codepoint>` so they survive identifier
|
|
154
|
+
* normalization instead of being stripped (which collapses every non-ASCII name
|
|
155
|
+
* to the same `Schema`, producing duplicate declarations). Pure-ASCII input is
|
|
156
|
+
* returned unchanged, so identifier generation stays byte-for-byte identical for
|
|
157
|
+
* the overwhelming majority of specs.
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* ```ts
|
|
161
|
+
* encodeNonAscii('User') // 'User'
|
|
162
|
+
* encodeNonAscii('日本語') // 'u65e5u672cu8a9e'
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
|
+
export declare function encodeNonAscii(name: string): string;
|
|
166
|
+
/**
|
|
167
|
+
* Convert string to a valid PascalCase identifier.
|
|
168
|
+
*
|
|
169
|
+
* Splits by non-alphanumeric characters and capitalizes each segment.
|
|
170
|
+
* Handles hyphens, underscores, dots, spaces, leading numbers, and non-ASCII characters.
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* ```ts
|
|
174
|
+
* toIdentifierPascalCase('user-name') // 'UserName'
|
|
175
|
+
* toIdentifierPascalCase('hello_world') // 'HelloWorld'
|
|
176
|
+
* toIdentifierPascalCase('123value') // '_123Value'
|
|
177
|
+
* toIdentifierPascalCase('user') // 'User'
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
180
|
+
export declare function toIdentifierPascalCase(name: string): string;
|
|
181
|
+
export declare function normalizeTypes(t?: string | readonly string[]): string[];
|
|
182
|
+
/**
|
|
183
|
+
* Reconcile a schema's `default` value with the type the schema actually emits
|
|
184
|
+
* so the generated `.default(...)` stays assignable.
|
|
185
|
+
*
|
|
186
|
+
* - `null` on a non-nullable schema is unusable as a default → `keep: false`
|
|
187
|
+
* (the caller omits `.default`).
|
|
188
|
+
* - a string `'true'`/`'false'` on a boolean schema denotes the boolean it
|
|
189
|
+
* spells → coerced to the boolean value (covers `z.stringbool()` query coercion).
|
|
190
|
+
* - everything else is returned unchanged (byte-for-byte identical output).
|
|
191
|
+
*
|
|
192
|
+
* The mismatch check is deliberately shallow and only crosses the
|
|
193
|
+
* composite (array/object) ↔ scalar category boundary; scalar↔scalar
|
|
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.
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* ```ts
|
|
201
|
+
* coerceDefault({ type: 'boolean' }, 'true') // { keep: true, value: true }
|
|
202
|
+
* coerceDefault({ type: 'object' }, null) // { keep: false, value: null }
|
|
203
|
+
* coerceDefault({ type: 'object', nullable: true }, null) // { keep: true, value: null }
|
|
204
|
+
* coerceDefault({ type: 'array' }, 'eval') // { keep: false, value: 'eval' }
|
|
205
|
+
* ```
|
|
206
|
+
*/
|
|
207
|
+
export declare function coerceDefault(schema: {
|
|
208
|
+
readonly type?: string | readonly string[];
|
|
209
|
+
readonly nullable?: boolean;
|
|
210
|
+
}, value: unknown): {
|
|
211
|
+
readonly keep: boolean;
|
|
212
|
+
readonly value: unknown;
|
|
213
|
+
};
|
|
214
|
+
/**
|
|
215
|
+
* A message as the expression an emitted check evaluates for each issue: an arrow source
|
|
216
|
+
* is applied to the issue, a sentence becomes a string literal.
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
* ```ts
|
|
220
|
+
* issueMessageExpression('Invalid') // '"Invalid"'
|
|
221
|
+
* issueMessageExpression('(issue) => issue.path[0]') // '((issue) => issue.path[0])(issue)'
|
|
222
|
+
* ```
|
|
223
|
+
*/
|
|
224
|
+
export declare function issueMessageExpression(message: string): string;
|
|
225
|
+
/**
|
|
226
|
+
* Format an error message argument using the Zod v4 unified `error` parameter.
|
|
227
|
+
*
|
|
228
|
+
* @example
|
|
229
|
+
* ```ts
|
|
230
|
+
* zodError('Name must be 3-20 characters') // '{error:"Name must be 3-20 characters"}'
|
|
231
|
+
* zodError('(val) => `Expected ${val}`') // '{error:(val) => `Expected ${val}`}'
|
|
232
|
+
* ```
|
|
233
|
+
*/
|
|
234
|
+
export declare function zodError(message: string): string;
|
|
235
|
+
/** `zodError(message)` as a trailing argument, or nothing when there is no message. */
|
|
236
|
+
export declare function zodErrorPart(message: string | undefined): string;
|
|
237
|
+
/**
|
|
238
|
+
* Build the base `{error:...}` argument for a Zod v4 schema constructor when
|
|
239
|
+
* `x-error-message` (type / generic) and/or `x-required-message`
|
|
240
|
+
* (`issue.input === undefined`) are present.
|
|
241
|
+
*/
|
|
242
|
+
export declare function zodBaseError(typeMessage: string | undefined, requiredMessage: string | undefined): string;
|
|
243
|
+
/**
|
|
244
|
+
* Format an error message argument for Valibot.
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
* ```ts
|
|
248
|
+
* valibotError('Must be valid') // '"Must be valid"'
|
|
249
|
+
* valibotError('(issue) => issue.input') // '(issue) => issue.input'
|
|
250
|
+
* ```
|
|
251
|
+
*/
|
|
252
|
+
export declare function valibotError(message: string): string;
|
|
253
|
+
/** `valibotError(message)` as a trailing argument, or nothing when there is no message. */
|
|
254
|
+
export declare function valibotErrorPart(message: string | undefined): string;
|
|
255
|
+
/**
|
|
256
|
+
* Format an error message annotation for Effect Schema.
|
|
257
|
+
*
|
|
258
|
+
* Effect Schema v4 types the `message` annotation as a plain `string` (v3 took
|
|
259
|
+
* a `() => string` thunk), so an arrow-expression message has no place to go
|
|
260
|
+
* and is emitted as its source text — see {@link effectMessage}.
|
|
261
|
+
*
|
|
262
|
+
* @example
|
|
263
|
+
* ```ts
|
|
264
|
+
* effectError('Required') // '{message:"Required"}'
|
|
265
|
+
* ```
|
|
266
|
+
*/
|
|
267
|
+
export declare function effectError(message: string): string;
|
|
268
|
+
/** `effectError(message)` as a trailing argument, or nothing when there is no message. */
|
|
269
|
+
export declare function effectErrorPart(message: string | undefined): string;
|
|
270
|
+
/**
|
|
271
|
+
* The `message` annotation value for Effect Schema v4: a string literal.
|
|
272
|
+
*
|
|
273
|
+
* @example
|
|
274
|
+
* ```ts
|
|
275
|
+
* effectMessage('Required') // '"Required"'
|
|
276
|
+
* ```
|
|
277
|
+
*/
|
|
278
|
+
export declare function effectMessage(message: string): string;
|
|
279
|
+
/**
|
|
280
|
+
* Resolve an OpenAPI $ref string to a variable name with the appropriate suffix
|
|
281
|
+
*
|
|
282
|
+
* @example
|
|
283
|
+
* ```ts
|
|
284
|
+
* resolveOpenAPIRef('#/components/schemas/User') // 'UserSchema'
|
|
285
|
+
* resolveOpenAPIRef('#/components/parameters/UserId') // 'UserIdParamsSchema'
|
|
286
|
+
* resolveOpenAPIRef('#/definitions/Address') // null
|
|
287
|
+
* ```
|
|
288
|
+
*/
|
|
289
|
+
export declare function resolveOpenAPIRef($ref: string): string | null;
|
|
290
|
+
/**
|
|
291
|
+
* Encode a property key safely for object literal output.
|
|
292
|
+
* Bare identifiers stay unquoted; everything else is JSON-encoded.
|
|
293
|
+
*
|
|
294
|
+
* @example
|
|
295
|
+
* ```ts
|
|
296
|
+
* makeSafeKey('foo') // 'foo'
|
|
297
|
+
* makeSafeKey('foo-bar') // '"foo-bar"'
|
|
298
|
+
* makeSafeKey('123') // '"123"'
|
|
299
|
+
* ```
|
|
300
|
+
*/
|
|
301
|
+
export declare function makeSafeKey(key: string): string;
|
|
302
|
+
//#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 };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { $ as DEFINITION_REF_PREFIXES, At as WIRE_PRIMITIVE_ORDER, Ct as STRINGBOOL_TRUTHY_PATTERN, Dt as UNICODE_ESCAPE_PATTERN, Et as STRING_WIRE_LOCATIONS, G as ARKTYPE_CODE_EXTENSION_KEYS, J as CONTENT_ENCODINGS, K as ARROW_FUNCTION_PATTERN, Ot as UNSAFE_GENERATED_MARKER, Q as DEFINITION_POINTER_PATTERN, St as STRINGBOOL_PATTERN, Tt as STRING_KEYWORDS, 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 OUTPUT_EXTENSION, a as encodeNonAscii, at as INTEGER_TEXT_PATTERN, bt as QUOTE_OR_BACKSLASH_PATTERN, c as normalizeTypes, ct as MISSING_DEFINITION_PREFIX, d as toPascalCase, dt as NUMBER_FORMATS, et as EFFECT_CODE_EXTENSION_KEYS, f as valibotError, ft as NUMBER_RANGES, g as zodErrorPart, gt as OPENAPI_COMPONENT_SUFFIX_MAP, h as zodError, ht as OFFSET_PATTERN_SOURCE, i as effectMessage, it as INPUT_EXTENSIONS, jt as ZOD_CODE_EXTENSION_KEYS, kt as VALIBOT_CODE_EXTENSION_KEYS, l as resolveOpenAPIRef, lt as NON_IDENTIFIER_CHARACTER_PATTERN, m as zodBaseError, mt as OBJECT_PROTOTYPE_PROPERTIES, n as effectError, nt as IDENTIFIER_PATTERN, o as issueMessageExpression, ot as ISO_4217_CURRENCY_CODES, p as valibotErrorPart, pt as NUMERIC_KEYWORDS, q as COMPONENT_SCHEMA_REF_PREFIX, r as effectErrorPart, rt as IF_THEN_ELSE_UNSUPPORTED_MARKER, s as makeSafeKey, st as JSON_SCHEMA_TYPES, t as coerceDefault, tt as FORMAT_PATTERNS, u as toIdentifierPascalCase, ut as NOT_KEYWORD_UNSUPPORTED_MARKER, vt as PARAM_LOCATIONS, wt as STRING_FORMATS, xt as ROOT_REFS, yt as PARAM_STYLES } from "./utils-WNBq1HR0.js";
|
|
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-DTP2FXRr.js";
|
|
4
|
+
import { n as arktype, t as schemaToArktype } from "./arktype-BdvvaBQX.js";
|
|
5
|
+
import { n as effect, r as wholeValueMessage, t as schemaToEffect } from "./effect-mUknRPv_.js";
|
|
6
|
+
import { n as nestedTypeboxOptions, r as typebox, t as schemaToTypebox } from "./typebox-BdWJv3ND.js";
|
|
7
|
+
import { n as valibot, t as schemaToValibot } from "./valibot-CaJIynCH.js";
|
|
8
|
+
import { n as yup, t as schemaToYup } from "./yup-CM2TSFig.js";
|
|
9
|
+
import { n as zod, t as schemaToZod } from "./zod-BsXLZfwK.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, 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 };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as Data from "effect/Data";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import { format } from "oxfmt";
|
|
4
|
+
import { bundle } from "@apidevtools/json-schema-ref-parser";
|
|
5
|
+
//#region src/format/index.ts
|
|
6
|
+
/** oxfmt rejected the source it was handed. */
|
|
7
|
+
var FormatError = class extends Data.TaggedError("FormatError") {};
|
|
8
|
+
const FMT_OPTIONS = {
|
|
9
|
+
printWidth: 100,
|
|
10
|
+
singleQuote: true,
|
|
11
|
+
semi: false
|
|
12
|
+
};
|
|
13
|
+
/** Formats generated TypeScript. Failures land in the error channel. */
|
|
14
|
+
function fmt(input) {
|
|
15
|
+
return Effect.gen(function* () {
|
|
16
|
+
const { code, errors } = yield* Effect.tryPromise({
|
|
17
|
+
try: () => format("<stdin>.ts", input, FMT_OPTIONS),
|
|
18
|
+
catch: (cause) => new FormatError({ message: cause instanceof Error ? cause.message : String(cause) })
|
|
19
|
+
});
|
|
20
|
+
if (errors.length > 0) return yield* new FormatError({ message: errors.map((error) => error.message).join("\n") });
|
|
21
|
+
return code;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/parser/index.ts
|
|
26
|
+
/** The document could not be bundled as a JSON Schema. */
|
|
27
|
+
var ParseError = class extends Data.TaggedError("ParseError") {};
|
|
28
|
+
/** The bundled document at `input`. Failures land in the error channel. */
|
|
29
|
+
function parseSchemaFile(input) {
|
|
30
|
+
return Effect.tryPromise({
|
|
31
|
+
try: () => bundle(input),
|
|
32
|
+
catch: (error) => new ParseError({ message: `Failed to parse schema: ${error instanceof Error ? error.message : String(error)}` })
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
export { fmt as i, parseSchemaFile as n, FormatError as r, ParseError as t };
|