@temporary-name/json-schema 1.9.3-alpha.8dcf0da5d97e7b89ab5ce50c8d1733c158e629a8 → 1.9.3-alpha.907c7c78d0193d34752279de92d699e50d6bc3a1
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.mts +2 -17
- package/dist/index.d.ts +2 -17
- package/dist/index.mjs +1 -33
- package/dist/zod4/index.d.mts +2 -13
- package/dist/zod4/index.d.ts +2 -13
- package/dist/zod4/index.mjs +374 -387
- package/package.json +6 -5
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import * as Draft07 from '@temporary-name/interop/json-schema-typed/draft-07';
|
|
2
2
|
import * as Draft2019 from '@temporary-name/interop/json-schema-typed/draft-2019-09';
|
|
3
3
|
import * as Draft2020 from '@temporary-name/interop/json-schema-typed/draft-2020-12';
|
|
4
|
-
import { Context } from '@temporary-name/server';
|
|
5
|
-
import { ConditionalSchemaConverter } from '@temporary-name/server/openapi';
|
|
6
|
-
import { StandardHandlerPlugin, StandardHandlerOptions } from '@temporary-name/server/standard';
|
|
7
4
|
|
|
8
5
|
type JsonSchema = Draft2020.JSONSchema | Draft2019.JSONSchema | Draft07.JSONSchema;
|
|
9
6
|
declare enum JsonSchemaXNativeType {
|
|
@@ -23,17 +20,5 @@ declare class experimental_JsonSchemaCoercer {
|
|
|
23
20
|
coerce(schema: JsonSchema, value: unknown, options?: experimental_JsonSchemaCoerceOptions): unknown;
|
|
24
21
|
}
|
|
25
22
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
declare class experimental_SmartCoercionPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
|
30
|
-
#private;
|
|
31
|
-
private readonly converter;
|
|
32
|
-
private readonly coercer;
|
|
33
|
-
private readonly cache;
|
|
34
|
-
constructor(options?: experimental_SmartCoercionPluginOptions);
|
|
35
|
-
init(options: StandardHandlerOptions<T>): void;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export { JsonSchemaXNativeType, experimental_JsonSchemaCoercer, experimental_SmartCoercionPlugin };
|
|
39
|
-
export type { JsonSchema, experimental_JsonSchemaCoerceOptions, experimental_SmartCoercionPluginOptions };
|
|
23
|
+
export { JsonSchemaXNativeType, experimental_JsonSchemaCoercer };
|
|
24
|
+
export type { JsonSchema, experimental_JsonSchemaCoerceOptions };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import * as Draft07 from '@temporary-name/interop/json-schema-typed/draft-07';
|
|
2
2
|
import * as Draft2019 from '@temporary-name/interop/json-schema-typed/draft-2019-09';
|
|
3
3
|
import * as Draft2020 from '@temporary-name/interop/json-schema-typed/draft-2020-12';
|
|
4
|
-
import { Context } from '@temporary-name/server';
|
|
5
|
-
import { ConditionalSchemaConverter } from '@temporary-name/server/openapi';
|
|
6
|
-
import { StandardHandlerPlugin, StandardHandlerOptions } from '@temporary-name/server/standard';
|
|
7
4
|
|
|
8
5
|
type JsonSchema = Draft2020.JSONSchema | Draft2019.JSONSchema | Draft07.JSONSchema;
|
|
9
6
|
declare enum JsonSchemaXNativeType {
|
|
@@ -23,17 +20,5 @@ declare class experimental_JsonSchemaCoercer {
|
|
|
23
20
|
coerce(schema: JsonSchema, value: unknown, options?: experimental_JsonSchemaCoerceOptions): unknown;
|
|
24
21
|
}
|
|
25
22
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
declare class experimental_SmartCoercionPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
|
30
|
-
#private;
|
|
31
|
-
private readonly converter;
|
|
32
|
-
private readonly coercer;
|
|
33
|
-
private readonly cache;
|
|
34
|
-
constructor(options?: experimental_SmartCoercionPluginOptions);
|
|
35
|
-
init(options: StandardHandlerOptions<T>): void;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export { JsonSchemaXNativeType, experimental_JsonSchemaCoercer, experimental_SmartCoercionPlugin };
|
|
39
|
-
export type { JsonSchema, experimental_JsonSchemaCoerceOptions, experimental_SmartCoercionPluginOptions };
|
|
23
|
+
export { JsonSchemaXNativeType, experimental_JsonSchemaCoercer };
|
|
24
|
+
export type { JsonSchema, experimental_JsonSchemaCoerceOptions };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { isObject, toArray, guard } from '@temporary-name/shared';
|
|
2
|
-
import { CompositeSchemaConverter } from '@temporary-name/server/openapi';
|
|
3
2
|
|
|
4
3
|
var JsonSchemaXNativeType = /* @__PURE__ */ ((JsonSchemaXNativeType2) => {
|
|
5
4
|
JsonSchemaXNativeType2["BigInt"] = "bigint";
|
|
@@ -337,35 +336,4 @@ class experimental_JsonSchemaCoercer {
|
|
|
337
336
|
}
|
|
338
337
|
}
|
|
339
338
|
|
|
340
|
-
|
|
341
|
-
converter;
|
|
342
|
-
coercer;
|
|
343
|
-
cache = /* @__PURE__ */ new WeakMap();
|
|
344
|
-
constructor(options = {}) {
|
|
345
|
-
this.converter = new CompositeSchemaConverter(toArray(options.schemaConverters));
|
|
346
|
-
this.coercer = new experimental_JsonSchemaCoercer();
|
|
347
|
-
}
|
|
348
|
-
init(options) {
|
|
349
|
-
options.clientInterceptors ??= [];
|
|
350
|
-
options.clientInterceptors.unshift(async (options2) => {
|
|
351
|
-
const { bodySchema, pathSchema, querySchema } = options2.procedure["~orpc"].schemas;
|
|
352
|
-
const coercedBody = await this.#coerce(bodySchema, options2.input.body);
|
|
353
|
-
const coercedPath = await this.#coerce(pathSchema, options2.input.path);
|
|
354
|
-
const coercedQuery = await this.#coerce(querySchema, options2.input.query);
|
|
355
|
-
return options2.next({
|
|
356
|
-
...options2,
|
|
357
|
-
input: { body: coercedBody, path: coercedPath, query: coercedQuery }
|
|
358
|
-
});
|
|
359
|
-
});
|
|
360
|
-
}
|
|
361
|
-
async #coerce(schema, value) {
|
|
362
|
-
let jsonSchema = this.cache.get(schema);
|
|
363
|
-
if (!jsonSchema) {
|
|
364
|
-
jsonSchema = (await this.converter.convert(schema, { strategy: "input" }))[1];
|
|
365
|
-
this.cache.set(schema, jsonSchema);
|
|
366
|
-
}
|
|
367
|
-
return this.coercer.coerce(jsonSchema, value);
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
export { JsonSchemaXNativeType, experimental_JsonSchemaCoercer, experimental_SmartCoercionPlugin };
|
|
339
|
+
export { JsonSchemaXNativeType, experimental_JsonSchemaCoercer };
|
package/dist/zod4/index.d.mts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { JSONSchema,
|
|
2
|
-
import { Interceptor } from '@temporary-name/shared';
|
|
1
|
+
import { JSONSchema, ConditionalSchemaConverter, SchemaConvertOptions } from '@temporary-name/server/openapi';
|
|
3
2
|
import { core } from '@temporary-name/zod';
|
|
4
3
|
import * as zod_v4_core from 'zod/v4/core';
|
|
5
|
-
import { $
|
|
4
|
+
import { $input, $output } from 'zod/v4/core';
|
|
6
5
|
|
|
7
6
|
interface ZodToJsonSchemaConverterOptions {
|
|
8
7
|
/**
|
|
@@ -39,15 +38,6 @@ interface ZodToJsonSchemaConverterOptions {
|
|
|
39
38
|
* @default { not: {} }
|
|
40
39
|
*/
|
|
41
40
|
undefinedJsonSchema?: Exclude<JSONSchema, boolean>;
|
|
42
|
-
interceptors?: Interceptor<{
|
|
43
|
-
schema: $ZodType;
|
|
44
|
-
options: SchemaConvertOptions;
|
|
45
|
-
lazyDepth: number;
|
|
46
|
-
isHandledCustomJSONSchema: boolean;
|
|
47
|
-
}, [
|
|
48
|
-
required: boolean,
|
|
49
|
-
jsonSchema: Exclude<JSONSchema, boolean>
|
|
50
|
-
]>[];
|
|
51
41
|
}
|
|
52
42
|
declare class ZodToJsonSchemaConverter implements ConditionalSchemaConverter {
|
|
53
43
|
#private;
|
|
@@ -56,7 +46,6 @@ declare class ZodToJsonSchemaConverter implements ConditionalSchemaConverter {
|
|
|
56
46
|
private readonly anyJsonSchema;
|
|
57
47
|
private readonly unsupportedJsonSchema;
|
|
58
48
|
private readonly undefinedJsonSchema;
|
|
59
|
-
private readonly interceptors;
|
|
60
49
|
constructor(options?: ZodToJsonSchemaConverterOptions);
|
|
61
50
|
condition(schema: core.$ZodType | undefined): boolean;
|
|
62
51
|
convert(schema: core.$ZodType | undefined, options: SchemaConvertOptions): [required: boolean, jsonSchema: Exclude<JSONSchema, boolean>];
|
package/dist/zod4/index.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { JSONSchema,
|
|
2
|
-
import { Interceptor } from '@temporary-name/shared';
|
|
1
|
+
import { JSONSchema, ConditionalSchemaConverter, SchemaConvertOptions } from '@temporary-name/server/openapi';
|
|
3
2
|
import { core } from '@temporary-name/zod';
|
|
4
3
|
import * as zod_v4_core from 'zod/v4/core';
|
|
5
|
-
import { $
|
|
4
|
+
import { $input, $output } from 'zod/v4/core';
|
|
6
5
|
|
|
7
6
|
interface ZodToJsonSchemaConverterOptions {
|
|
8
7
|
/**
|
|
@@ -39,15 +38,6 @@ interface ZodToJsonSchemaConverterOptions {
|
|
|
39
38
|
* @default { not: {} }
|
|
40
39
|
*/
|
|
41
40
|
undefinedJsonSchema?: Exclude<JSONSchema, boolean>;
|
|
42
|
-
interceptors?: Interceptor<{
|
|
43
|
-
schema: $ZodType;
|
|
44
|
-
options: SchemaConvertOptions;
|
|
45
|
-
lazyDepth: number;
|
|
46
|
-
isHandledCustomJSONSchema: boolean;
|
|
47
|
-
}, [
|
|
48
|
-
required: boolean,
|
|
49
|
-
jsonSchema: Exclude<JSONSchema, boolean>
|
|
50
|
-
]>[];
|
|
51
41
|
}
|
|
52
42
|
declare class ZodToJsonSchemaConverter implements ConditionalSchemaConverter {
|
|
53
43
|
#private;
|
|
@@ -56,7 +46,6 @@ declare class ZodToJsonSchemaConverter implements ConditionalSchemaConverter {
|
|
|
56
46
|
private readonly anyJsonSchema;
|
|
57
47
|
private readonly unsupportedJsonSchema;
|
|
58
48
|
private readonly undefinedJsonSchema;
|
|
59
|
-
private readonly interceptors;
|
|
60
49
|
constructor(options?: ZodToJsonSchemaConverterOptions);
|
|
61
50
|
condition(schema: core.$ZodType | undefined): boolean;
|
|
62
51
|
convert(schema: core.$ZodType | undefined, options: SchemaConvertOptions): [required: boolean, jsonSchema: Exclude<JSONSchema, boolean>];
|
package/dist/zod4/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { JsonSchemaXNativeType } from '@temporary-name/json-schema';
|
|
2
2
|
import { JSONSchemaFormat, JSONSchemaContentEncoding } from '@temporary-name/server/openapi';
|
|
3
|
-
import {
|
|
3
|
+
import { toArray } from '@temporary-name/shared';
|
|
4
4
|
import { registry, globalRegistry } from 'zod/v4/core';
|
|
5
5
|
|
|
6
6
|
const JSON_SCHEMA_REGISTRY = registry();
|
|
@@ -13,14 +13,12 @@ class ZodToJsonSchemaConverter {
|
|
|
13
13
|
anyJsonSchema;
|
|
14
14
|
unsupportedJsonSchema;
|
|
15
15
|
undefinedJsonSchema;
|
|
16
|
-
interceptors;
|
|
17
16
|
constructor(options = {}) {
|
|
18
17
|
this.maxLazyDepth = options.maxLazyDepth ?? 2;
|
|
19
18
|
this.maxStructureDepth = options.maxStructureDepth ?? 10;
|
|
20
19
|
this.anyJsonSchema = options.anyJsonSchema ?? {};
|
|
21
20
|
this.unsupportedJsonSchema = options.unsupportedJsonSchema ?? { not: {} };
|
|
22
21
|
this.undefinedJsonSchema = options.undefinedJsonSchema ?? { not: {} };
|
|
23
|
-
this.interceptors = options.interceptors ?? [];
|
|
24
22
|
}
|
|
25
23
|
condition(schema) {
|
|
26
24
|
return schema !== void 0 && schema["~standard"].vendor === "zod" && "_zod" in schema;
|
|
@@ -29,409 +27,398 @@ class ZodToJsonSchemaConverter {
|
|
|
29
27
|
return this.#convert(schema, options, 0, 0);
|
|
30
28
|
}
|
|
31
29
|
#convert(schema, options, lazyDepth, structureDepth, isHandledCustomJSONSchema = false) {
|
|
32
|
-
|
|
33
|
-
this.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
if (structureDepth > this.maxStructureDepth) {
|
|
31
|
+
return [false, this.anyJsonSchema];
|
|
32
|
+
}
|
|
33
|
+
if (!options.minStructureDepthForRef || options.minStructureDepthForRef <= structureDepth) {
|
|
34
|
+
const components = toArray(options.components);
|
|
35
|
+
for (const component of components) {
|
|
36
|
+
if (component.schema === schema && component.allowedStrategies.includes(options.strategy)) {
|
|
37
|
+
return [component.required, { $ref: component.ref }];
|
|
38
38
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (!isHandledCustomJSONSchema) {
|
|
42
|
+
const customJSONSchema = this.#getCustomJsonSchema(schema, options);
|
|
43
|
+
if (customJSONSchema) {
|
|
44
|
+
const [required, json] = this.#convert(schema, options, lazyDepth, structureDepth, true);
|
|
45
|
+
return [required, { ...json, ...customJSONSchema }];
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
switch (schema._zod.def.type) {
|
|
49
|
+
case "string": {
|
|
50
|
+
const string = schema;
|
|
51
|
+
const json = { type: "string" };
|
|
52
|
+
const { minimum, maximum, format, patterns, contentEncoding } = string._zod.bag;
|
|
53
|
+
if (typeof minimum === "number") {
|
|
54
|
+
json.minLength = minimum;
|
|
46
55
|
}
|
|
47
|
-
if (
|
|
48
|
-
|
|
49
|
-
if (customJSONSchema) {
|
|
50
|
-
const [required, json] = this.#convert(schema2, options2, lazyDepth2, structureDepth, true);
|
|
51
|
-
return [required, { ...json, ...customJSONSchema }];
|
|
52
|
-
}
|
|
56
|
+
if (typeof maximum === "number") {
|
|
57
|
+
json.maxLength = maximum;
|
|
53
58
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
if (
|
|
63
|
-
json.
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
json.
|
|
67
|
-
}
|
|
68
|
-
if (typeof format === "string" && format !== "regex" && json.contentEncoding === void 0) {
|
|
69
|
-
json.format = this.#handleStringFormat(format);
|
|
70
|
-
}
|
|
71
|
-
if (patterns instanceof Set && json.contentEncoding === void 0 && json.format === void 0) {
|
|
72
|
-
for (const pattern of patterns) {
|
|
73
|
-
if (json.pattern === void 0) {
|
|
74
|
-
json.pattern = pattern.source;
|
|
75
|
-
} else {
|
|
76
|
-
json.allOf ??= [];
|
|
77
|
-
json.allOf.push({ pattern: pattern.source });
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
if (format === "jwt" && json.contentEncoding === void 0 && json.format === void 0 && json.pattern === void 0) {
|
|
82
|
-
json.pattern = /^[\w-]+\.[\w-]+\.[\w-]+$/.source;
|
|
83
|
-
}
|
|
84
|
-
return [true, json];
|
|
85
|
-
}
|
|
86
|
-
case "number": {
|
|
87
|
-
const number = schema2;
|
|
88
|
-
const json = { type: "number" };
|
|
89
|
-
const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = number._zod.bag;
|
|
90
|
-
if (typeof format === "string" && format?.includes("int")) {
|
|
91
|
-
json.type = "integer";
|
|
92
|
-
}
|
|
93
|
-
if (typeof minimum === "number") {
|
|
94
|
-
json.minimum = minimum;
|
|
95
|
-
}
|
|
96
|
-
if (typeof maximum === "number") {
|
|
97
|
-
json.maximum = maximum;
|
|
98
|
-
}
|
|
99
|
-
if (typeof exclusiveMinimum === "number") {
|
|
100
|
-
json.exclusiveMinimum = exclusiveMinimum;
|
|
101
|
-
}
|
|
102
|
-
if (typeof exclusiveMaximum === "number") {
|
|
103
|
-
json.exclusiveMaximum = exclusiveMaximum;
|
|
104
|
-
}
|
|
105
|
-
if (typeof multipleOf === "number") {
|
|
106
|
-
json.multipleOf = multipleOf;
|
|
59
|
+
if (typeof contentEncoding === "string") {
|
|
60
|
+
json.contentEncoding = this.#handleContentEncoding(contentEncoding);
|
|
61
|
+
}
|
|
62
|
+
if (typeof format === "string" && format !== "regex" && json.contentEncoding === void 0) {
|
|
63
|
+
json.format = this.#handleStringFormat(format);
|
|
64
|
+
}
|
|
65
|
+
if (patterns instanceof Set && json.contentEncoding === void 0 && json.format === void 0) {
|
|
66
|
+
for (const pattern of patterns) {
|
|
67
|
+
if (json.pattern === void 0) {
|
|
68
|
+
json.pattern = pattern.source;
|
|
69
|
+
} else {
|
|
70
|
+
json.allOf ??= [];
|
|
71
|
+
json.allOf.push({ pattern: pattern.source });
|
|
107
72
|
}
|
|
108
|
-
return [true, json];
|
|
109
|
-
}
|
|
110
|
-
case "boolean": {
|
|
111
|
-
return [true, { type: "boolean" }];
|
|
112
73
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
74
|
+
}
|
|
75
|
+
if (format === "jwt" && json.contentEncoding === void 0 && json.format === void 0 && json.pattern === void 0) {
|
|
76
|
+
json.pattern = /^[\w-]+\.[\w-]+\.[\w-]+$/.source;
|
|
77
|
+
}
|
|
78
|
+
return [true, json];
|
|
79
|
+
}
|
|
80
|
+
case "number": {
|
|
81
|
+
const number = schema;
|
|
82
|
+
const json = { type: "number" };
|
|
83
|
+
const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = number._zod.bag;
|
|
84
|
+
if (typeof format === "string" && format?.includes("int")) {
|
|
85
|
+
json.type = "integer";
|
|
86
|
+
}
|
|
87
|
+
if (typeof minimum === "number") {
|
|
88
|
+
json.minimum = minimum;
|
|
89
|
+
}
|
|
90
|
+
if (typeof maximum === "number") {
|
|
91
|
+
json.maximum = maximum;
|
|
92
|
+
}
|
|
93
|
+
if (typeof exclusiveMinimum === "number") {
|
|
94
|
+
json.exclusiveMinimum = exclusiveMinimum;
|
|
95
|
+
}
|
|
96
|
+
if (typeof exclusiveMaximum === "number") {
|
|
97
|
+
json.exclusiveMaximum = exclusiveMaximum;
|
|
98
|
+
}
|
|
99
|
+
if (typeof multipleOf === "number") {
|
|
100
|
+
json.multipleOf = multipleOf;
|
|
101
|
+
}
|
|
102
|
+
return [true, json];
|
|
103
|
+
}
|
|
104
|
+
case "boolean": {
|
|
105
|
+
return [true, { type: "boolean" }];
|
|
106
|
+
}
|
|
107
|
+
case "bigint": {
|
|
108
|
+
return [
|
|
109
|
+
true,
|
|
110
|
+
{
|
|
111
|
+
type: "string",
|
|
112
|
+
pattern: "^-?[0-9]+$",
|
|
113
|
+
"x-native-type": JsonSchemaXNativeType.BigInt
|
|
114
|
+
}
|
|
115
|
+
];
|
|
116
|
+
}
|
|
117
|
+
case "date": {
|
|
118
|
+
return [
|
|
119
|
+
true,
|
|
120
|
+
{
|
|
121
|
+
type: "string",
|
|
122
|
+
format: JSONSchemaFormat.DateTime,
|
|
123
|
+
"x-native-type": JsonSchemaXNativeType.Date
|
|
124
|
+
}
|
|
125
|
+
];
|
|
126
|
+
}
|
|
127
|
+
case "null": {
|
|
128
|
+
return [true, { type: "null" }];
|
|
129
|
+
}
|
|
130
|
+
case "undefined":
|
|
131
|
+
case "void": {
|
|
132
|
+
return [false, this.undefinedJsonSchema];
|
|
133
|
+
}
|
|
134
|
+
case "any": {
|
|
135
|
+
return [false, this.anyJsonSchema];
|
|
136
|
+
}
|
|
137
|
+
case "unknown": {
|
|
138
|
+
return [false, this.anyJsonSchema];
|
|
139
|
+
}
|
|
140
|
+
case "never": {
|
|
141
|
+
return [true, this.unsupportedJsonSchema];
|
|
142
|
+
}
|
|
143
|
+
case "array": {
|
|
144
|
+
const array = schema;
|
|
145
|
+
const json = { type: "array" };
|
|
146
|
+
const { minimum, maximum } = array._zod.bag;
|
|
147
|
+
if (typeof minimum === "number") {
|
|
148
|
+
json.minItems = minimum;
|
|
149
|
+
}
|
|
150
|
+
if (typeof maximum === "number") {
|
|
151
|
+
json.maxItems = maximum;
|
|
152
|
+
}
|
|
153
|
+
json.items = this.#handleArrayItemJsonSchema(
|
|
154
|
+
this.#convert(array._zod.def.element, options, lazyDepth, structureDepth + 1),
|
|
155
|
+
options
|
|
156
|
+
);
|
|
157
|
+
return [true, json];
|
|
158
|
+
}
|
|
159
|
+
case "object": {
|
|
160
|
+
const object = schema;
|
|
161
|
+
const json = { type: "object" };
|
|
162
|
+
for (const [key, value] of Object.entries(object._zod.def.shape)) {
|
|
163
|
+
const [itemRequired, itemJson] = this.#convert(value, options, lazyDepth, structureDepth + 1);
|
|
164
|
+
json.properties ??= {};
|
|
165
|
+
json.properties[key] = itemJson;
|
|
166
|
+
if (itemRequired) {
|
|
167
|
+
json.required ??= [];
|
|
168
|
+
json.required.push(key);
|
|
148
169
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
json.items = this.#handleArrayItemJsonSchema(
|
|
160
|
-
this.#convert(array._zod.def.element, options2, lazyDepth2, structureDepth + 1),
|
|
161
|
-
options2
|
|
170
|
+
}
|
|
171
|
+
if (object._zod.def.catchall) {
|
|
172
|
+
if (object._zod.def.catchall._zod.def.type === "never") {
|
|
173
|
+
json.additionalProperties = false;
|
|
174
|
+
} else {
|
|
175
|
+
const [_, addJson] = this.#convert(
|
|
176
|
+
object._zod.def.catchall,
|
|
177
|
+
options,
|
|
178
|
+
lazyDepth,
|
|
179
|
+
structureDepth + 1
|
|
162
180
|
);
|
|
163
|
-
|
|
181
|
+
json.additionalProperties = addJson;
|
|
164
182
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
} else {
|
|
181
|
-
const [_, addJson] = this.#convert(
|
|
182
|
-
object._zod.def.catchall,
|
|
183
|
-
options2,
|
|
184
|
-
lazyDepth2,
|
|
185
|
-
structureDepth + 1
|
|
186
|
-
);
|
|
187
|
-
json.additionalProperties = addJson;
|
|
188
|
-
}
|
|
183
|
+
}
|
|
184
|
+
return [true, json];
|
|
185
|
+
}
|
|
186
|
+
case "union": {
|
|
187
|
+
const union = schema;
|
|
188
|
+
const anyOf = [];
|
|
189
|
+
let required = true;
|
|
190
|
+
for (const item of union._zod.def.options) {
|
|
191
|
+
const [itemRequired, itemJson] = this.#convert(item, options, lazyDepth, structureDepth);
|
|
192
|
+
if (!itemRequired) {
|
|
193
|
+
required = false;
|
|
194
|
+
}
|
|
195
|
+
if (options.strategy === "input") {
|
|
196
|
+
if (itemJson !== this.undefinedJsonSchema && itemJson !== this.unsupportedJsonSchema) {
|
|
197
|
+
anyOf.push(itemJson);
|
|
189
198
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
const union = schema2;
|
|
194
|
-
const anyOf = [];
|
|
195
|
-
let required = true;
|
|
196
|
-
for (const item of union._zod.def.options) {
|
|
197
|
-
const [itemRequired, itemJson] = this.#convert(item, options2, lazyDepth2, structureDepth);
|
|
198
|
-
if (!itemRequired) {
|
|
199
|
-
required = false;
|
|
200
|
-
}
|
|
201
|
-
if (options2.strategy === "input") {
|
|
202
|
-
if (itemJson !== this.undefinedJsonSchema && itemJson !== this.unsupportedJsonSchema) {
|
|
203
|
-
anyOf.push(itemJson);
|
|
204
|
-
}
|
|
205
|
-
} else {
|
|
206
|
-
if (itemJson !== this.undefinedJsonSchema) {
|
|
207
|
-
anyOf.push(itemJson);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
199
|
+
} else {
|
|
200
|
+
if (itemJson !== this.undefinedJsonSchema) {
|
|
201
|
+
anyOf.push(itemJson);
|
|
210
202
|
}
|
|
211
|
-
return [required, anyOf.length === 1 ? anyOf[0] : { anyOf }];
|
|
212
203
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
204
|
+
}
|
|
205
|
+
return [required, anyOf.length === 1 ? anyOf[0] : { anyOf }];
|
|
206
|
+
}
|
|
207
|
+
case "intersection": {
|
|
208
|
+
const intersection = schema;
|
|
209
|
+
const json = { allOf: [] };
|
|
210
|
+
let required = false;
|
|
211
|
+
for (const item of [intersection._zod.def.left, intersection._zod.def.right]) {
|
|
212
|
+
const [itemRequired, itemJson] = this.#convert(item, options, lazyDepth, structureDepth);
|
|
213
|
+
json.allOf.push(itemJson);
|
|
214
|
+
if (itemRequired) {
|
|
215
|
+
required = true;
|
|
225
216
|
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
217
|
+
}
|
|
218
|
+
return [required, json];
|
|
219
|
+
}
|
|
220
|
+
case "tuple": {
|
|
221
|
+
const tuple = schema;
|
|
222
|
+
const json = { type: "array", prefixItems: [] };
|
|
223
|
+
for (const item of tuple._zod.def.items) {
|
|
224
|
+
json.prefixItems.push(
|
|
225
|
+
this.#handleArrayItemJsonSchema(
|
|
226
|
+
this.#convert(item, options, lazyDepth, structureDepth + 1),
|
|
227
|
+
options
|
|
228
|
+
)
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
if (tuple._zod.def.rest) {
|
|
232
|
+
json.items = this.#handleArrayItemJsonSchema(
|
|
233
|
+
this.#convert(tuple._zod.def.rest, options, lazyDepth, structureDepth + 1),
|
|
234
|
+
options
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
const { minimum, maximum } = tuple._zod.bag;
|
|
238
|
+
if (typeof minimum === "number") {
|
|
239
|
+
json.minItems = minimum;
|
|
240
|
+
}
|
|
241
|
+
if (typeof maximum === "number") {
|
|
242
|
+
json.maxItems = maximum;
|
|
243
|
+
}
|
|
244
|
+
return [true, json];
|
|
245
|
+
}
|
|
246
|
+
case "record": {
|
|
247
|
+
const record = schema;
|
|
248
|
+
const json = { type: "object" };
|
|
249
|
+
json.propertyNames = this.#convert(
|
|
250
|
+
record._zod.def.keyType,
|
|
251
|
+
options,
|
|
252
|
+
lazyDepth,
|
|
253
|
+
structureDepth + 1
|
|
254
|
+
)[1];
|
|
255
|
+
json.additionalProperties = this.#convert(
|
|
256
|
+
record._zod.def.valueType,
|
|
257
|
+
options,
|
|
258
|
+
lazyDepth,
|
|
259
|
+
structureDepth + 1
|
|
260
|
+
)[1];
|
|
261
|
+
return [true, json];
|
|
262
|
+
}
|
|
263
|
+
case "map": {
|
|
264
|
+
const map = schema;
|
|
265
|
+
return [
|
|
266
|
+
true,
|
|
267
|
+
{
|
|
268
|
+
type: "array",
|
|
269
|
+
items: {
|
|
270
|
+
type: "array",
|
|
271
|
+
prefixItems: [
|
|
231
272
|
this.#handleArrayItemJsonSchema(
|
|
232
|
-
this.#convert(
|
|
233
|
-
|
|
234
|
-
)
|
|
235
|
-
);
|
|
236
|
-
}
|
|
237
|
-
if (tuple._zod.def.rest) {
|
|
238
|
-
json.items = this.#handleArrayItemJsonSchema(
|
|
239
|
-
this.#convert(tuple._zod.def.rest, options2, lazyDepth2, structureDepth + 1),
|
|
240
|
-
options2
|
|
241
|
-
);
|
|
242
|
-
}
|
|
243
|
-
const { minimum, maximum } = tuple._zod.bag;
|
|
244
|
-
if (typeof minimum === "number") {
|
|
245
|
-
json.minItems = minimum;
|
|
246
|
-
}
|
|
247
|
-
if (typeof maximum === "number") {
|
|
248
|
-
json.maxItems = maximum;
|
|
249
|
-
}
|
|
250
|
-
return [true, json];
|
|
251
|
-
}
|
|
252
|
-
case "record": {
|
|
253
|
-
const record = schema2;
|
|
254
|
-
const json = { type: "object" };
|
|
255
|
-
json.propertyNames = this.#convert(
|
|
256
|
-
record._zod.def.keyType,
|
|
257
|
-
options2,
|
|
258
|
-
lazyDepth2,
|
|
259
|
-
structureDepth + 1
|
|
260
|
-
)[1];
|
|
261
|
-
json.additionalProperties = this.#convert(
|
|
262
|
-
record._zod.def.valueType,
|
|
263
|
-
options2,
|
|
264
|
-
lazyDepth2,
|
|
265
|
-
structureDepth + 1
|
|
266
|
-
)[1];
|
|
267
|
-
return [true, json];
|
|
268
|
-
}
|
|
269
|
-
case "map": {
|
|
270
|
-
const map = schema2;
|
|
271
|
-
return [
|
|
272
|
-
true,
|
|
273
|
-
{
|
|
274
|
-
type: "array",
|
|
275
|
-
items: {
|
|
276
|
-
type: "array",
|
|
277
|
-
prefixItems: [
|
|
278
|
-
this.#handleArrayItemJsonSchema(
|
|
279
|
-
this.#convert(map._zod.def.keyType, options2, lazyDepth2, structureDepth + 1),
|
|
280
|
-
options2
|
|
281
|
-
),
|
|
282
|
-
this.#handleArrayItemJsonSchema(
|
|
283
|
-
this.#convert(map._zod.def.valueType, options2, lazyDepth2, structureDepth + 1),
|
|
284
|
-
options2
|
|
285
|
-
)
|
|
286
|
-
],
|
|
287
|
-
maxItems: 2,
|
|
288
|
-
minItems: 2
|
|
289
|
-
},
|
|
290
|
-
"x-native-type": JsonSchemaXNativeType.Map
|
|
291
|
-
}
|
|
292
|
-
];
|
|
293
|
-
}
|
|
294
|
-
case "set": {
|
|
295
|
-
const set = schema2;
|
|
296
|
-
return [
|
|
297
|
-
true,
|
|
298
|
-
{
|
|
299
|
-
type: "array",
|
|
300
|
-
uniqueItems: true,
|
|
301
|
-
items: this.#handleArrayItemJsonSchema(
|
|
302
|
-
this.#convert(set._zod.def.valueType, options2, lazyDepth2, structureDepth + 1),
|
|
303
|
-
options2
|
|
273
|
+
this.#convert(map._zod.def.keyType, options, lazyDepth, structureDepth + 1),
|
|
274
|
+
options
|
|
304
275
|
),
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
const literal = schema2;
|
|
315
|
-
let required = true;
|
|
316
|
-
const values = /* @__PURE__ */ new Set();
|
|
317
|
-
for (const value of literal._zod.def.values) {
|
|
318
|
-
if (value === void 0) {
|
|
319
|
-
required = false;
|
|
320
|
-
} else {
|
|
321
|
-
values.add(typeof value === "bigint" ? value.toString() : value);
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
const json = values.size === 0 ? this.undefinedJsonSchema : values.size === 1 ? { const: values.values().next().value } : { enum: Array.from(values) };
|
|
325
|
-
return [required, json];
|
|
326
|
-
}
|
|
327
|
-
case "file": {
|
|
328
|
-
const file = schema2;
|
|
329
|
-
const oneOf = [];
|
|
330
|
-
const { mime } = file._zod.bag;
|
|
331
|
-
if (mime === void 0 || Array.isArray(mime) && mime.every((m) => typeof m === "string")) {
|
|
332
|
-
for (const type of mime ?? ["*/*"]) {
|
|
333
|
-
oneOf.push({
|
|
334
|
-
type: "string",
|
|
335
|
-
contentMediaType: type
|
|
336
|
-
});
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
return [true, oneOf.length === 1 ? oneOf[0] : { anyOf: oneOf }];
|
|
340
|
-
}
|
|
341
|
-
case "transform": {
|
|
342
|
-
return [false, this.anyJsonSchema];
|
|
343
|
-
}
|
|
344
|
-
case "nullable": {
|
|
345
|
-
const nullable = schema2;
|
|
346
|
-
const [required, json] = this.#convert(
|
|
347
|
-
nullable._zod.def.innerType,
|
|
348
|
-
options2,
|
|
349
|
-
lazyDepth2,
|
|
350
|
-
structureDepth
|
|
351
|
-
);
|
|
352
|
-
return [required, { anyOf: [json, { type: "null" }] }];
|
|
353
|
-
}
|
|
354
|
-
case "nonoptional": {
|
|
355
|
-
const nonoptional = schema2;
|
|
356
|
-
const [, json] = this.#convert(
|
|
357
|
-
nonoptional._zod.def.innerType,
|
|
358
|
-
options2,
|
|
359
|
-
lazyDepth2,
|
|
360
|
-
structureDepth
|
|
361
|
-
);
|
|
362
|
-
return [true, json];
|
|
363
|
-
}
|
|
364
|
-
case "success": {
|
|
365
|
-
return [true, { type: "boolean" }];
|
|
366
|
-
}
|
|
367
|
-
case "default":
|
|
368
|
-
case "prefault": {
|
|
369
|
-
const default_ = schema2;
|
|
370
|
-
const [, json] = this.#convert(default_._zod.def.innerType, options2, lazyDepth2, structureDepth);
|
|
371
|
-
return [
|
|
372
|
-
false,
|
|
373
|
-
{
|
|
374
|
-
...json,
|
|
375
|
-
default: default_._zod.def.defaultValue
|
|
376
|
-
}
|
|
377
|
-
];
|
|
378
|
-
}
|
|
379
|
-
case "catch": {
|
|
380
|
-
const catch_ = schema2;
|
|
381
|
-
return this.#convert(catch_._zod.def.innerType, options2, lazyDepth2, structureDepth);
|
|
382
|
-
}
|
|
383
|
-
case "nan": {
|
|
384
|
-
return [true, options2.strategy === "input" ? this.unsupportedJsonSchema : { type: "null" }];
|
|
385
|
-
}
|
|
386
|
-
case "pipe": {
|
|
387
|
-
const pipe = schema2;
|
|
388
|
-
return this.#convert(
|
|
389
|
-
options2.strategy === "input" ? pipe._zod.def.in : pipe._zod.def.out,
|
|
390
|
-
options2,
|
|
391
|
-
lazyDepth2,
|
|
392
|
-
structureDepth
|
|
393
|
-
);
|
|
394
|
-
}
|
|
395
|
-
case "readonly": {
|
|
396
|
-
const readonly_ = schema2;
|
|
397
|
-
const [required, json] = this.#convert(
|
|
398
|
-
readonly_._zod.def.innerType,
|
|
399
|
-
options2,
|
|
400
|
-
lazyDepth2,
|
|
401
|
-
structureDepth
|
|
402
|
-
);
|
|
403
|
-
return [required, { ...json, readOnly: true }];
|
|
404
|
-
}
|
|
405
|
-
case "template_literal": {
|
|
406
|
-
const templateLiteral = schema2;
|
|
407
|
-
return [
|
|
408
|
-
true,
|
|
409
|
-
{
|
|
410
|
-
type: "string",
|
|
411
|
-
pattern: templateLiteral._zod.pattern.source
|
|
412
|
-
}
|
|
413
|
-
];
|
|
414
|
-
}
|
|
415
|
-
case "optional": {
|
|
416
|
-
const optional = schema2;
|
|
417
|
-
const [, json] = this.#convert(optional._zod.def.innerType, options2, lazyDepth2, structureDepth);
|
|
418
|
-
return [false, json];
|
|
276
|
+
this.#handleArrayItemJsonSchema(
|
|
277
|
+
this.#convert(map._zod.def.valueType, options, lazyDepth, structureDepth + 1),
|
|
278
|
+
options
|
|
279
|
+
)
|
|
280
|
+
],
|
|
281
|
+
maxItems: 2,
|
|
282
|
+
minItems: 2
|
|
283
|
+
},
|
|
284
|
+
"x-native-type": JsonSchemaXNativeType.Map
|
|
419
285
|
}
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
286
|
+
];
|
|
287
|
+
}
|
|
288
|
+
case "set": {
|
|
289
|
+
const set = schema;
|
|
290
|
+
return [
|
|
291
|
+
true,
|
|
292
|
+
{
|
|
293
|
+
type: "array",
|
|
294
|
+
uniqueItems: true,
|
|
295
|
+
items: this.#handleArrayItemJsonSchema(
|
|
296
|
+
this.#convert(set._zod.def.valueType, options, lazyDepth, structureDepth + 1),
|
|
297
|
+
options
|
|
298
|
+
),
|
|
299
|
+
"x-native-type": JsonSchemaXNativeType.Set
|
|
300
|
+
}
|
|
301
|
+
];
|
|
302
|
+
}
|
|
303
|
+
case "enum": {
|
|
304
|
+
const enum_ = schema;
|
|
305
|
+
return [true, { enum: Object.values(enum_._zod.def.entries) }];
|
|
306
|
+
}
|
|
307
|
+
case "literal": {
|
|
308
|
+
const literal = schema;
|
|
309
|
+
let required = true;
|
|
310
|
+
const values = /* @__PURE__ */ new Set();
|
|
311
|
+
for (const value of literal._zod.def.values) {
|
|
312
|
+
if (value === void 0) {
|
|
313
|
+
required = false;
|
|
314
|
+
} else {
|
|
315
|
+
values.add(typeof value === "bigint" ? value.toString() : value);
|
|
427
316
|
}
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
317
|
+
}
|
|
318
|
+
const json = values.size === 0 ? this.undefinedJsonSchema : values.size === 1 ? { const: values.values().next().value } : { enum: Array.from(values) };
|
|
319
|
+
return [required, json];
|
|
320
|
+
}
|
|
321
|
+
case "file": {
|
|
322
|
+
const file = schema;
|
|
323
|
+
const oneOf = [];
|
|
324
|
+
const { mime } = file._zod.bag;
|
|
325
|
+
if (mime === void 0 || Array.isArray(mime) && mime.every((m) => typeof m === "string")) {
|
|
326
|
+
for (const type of mime ?? ["*/*"]) {
|
|
327
|
+
oneOf.push({
|
|
328
|
+
type: "string",
|
|
329
|
+
contentMediaType: type
|
|
330
|
+
});
|
|
431
331
|
}
|
|
432
332
|
}
|
|
333
|
+
return [true, oneOf.length === 1 ? oneOf[0] : { anyOf: oneOf }];
|
|
334
|
+
}
|
|
335
|
+
case "transform": {
|
|
336
|
+
return [false, this.anyJsonSchema];
|
|
433
337
|
}
|
|
434
|
-
|
|
338
|
+
case "nullable": {
|
|
339
|
+
const nullable = schema;
|
|
340
|
+
const [required, json] = this.#convert(
|
|
341
|
+
nullable._zod.def.innerType,
|
|
342
|
+
options,
|
|
343
|
+
lazyDepth,
|
|
344
|
+
structureDepth
|
|
345
|
+
);
|
|
346
|
+
return [required, { anyOf: [json, { type: "null" }] }];
|
|
347
|
+
}
|
|
348
|
+
case "nonoptional": {
|
|
349
|
+
const nonoptional = schema;
|
|
350
|
+
const [, json] = this.#convert(nonoptional._zod.def.innerType, options, lazyDepth, structureDepth);
|
|
351
|
+
return [true, json];
|
|
352
|
+
}
|
|
353
|
+
case "success": {
|
|
354
|
+
return [true, { type: "boolean" }];
|
|
355
|
+
}
|
|
356
|
+
case "default":
|
|
357
|
+
case "prefault": {
|
|
358
|
+
const default_ = schema;
|
|
359
|
+
const [, json] = this.#convert(default_._zod.def.innerType, options, lazyDepth, structureDepth);
|
|
360
|
+
return [
|
|
361
|
+
false,
|
|
362
|
+
{
|
|
363
|
+
...json,
|
|
364
|
+
default: default_._zod.def.defaultValue
|
|
365
|
+
}
|
|
366
|
+
];
|
|
367
|
+
}
|
|
368
|
+
case "catch": {
|
|
369
|
+
const catch_ = schema;
|
|
370
|
+
return this.#convert(catch_._zod.def.innerType, options, lazyDepth, structureDepth);
|
|
371
|
+
}
|
|
372
|
+
case "nan": {
|
|
373
|
+
return [true, options.strategy === "input" ? this.unsupportedJsonSchema : { type: "null" }];
|
|
374
|
+
}
|
|
375
|
+
case "pipe": {
|
|
376
|
+
const pipe = schema;
|
|
377
|
+
return this.#convert(
|
|
378
|
+
options.strategy === "input" ? pipe._zod.def.in : pipe._zod.def.out,
|
|
379
|
+
options,
|
|
380
|
+
lazyDepth,
|
|
381
|
+
structureDepth
|
|
382
|
+
);
|
|
383
|
+
}
|
|
384
|
+
case "readonly": {
|
|
385
|
+
const readonly_ = schema;
|
|
386
|
+
const [required, json] = this.#convert(
|
|
387
|
+
readonly_._zod.def.innerType,
|
|
388
|
+
options,
|
|
389
|
+
lazyDepth,
|
|
390
|
+
structureDepth
|
|
391
|
+
);
|
|
392
|
+
return [required, { ...json, readOnly: true }];
|
|
393
|
+
}
|
|
394
|
+
case "template_literal": {
|
|
395
|
+
const templateLiteral = schema;
|
|
396
|
+
return [
|
|
397
|
+
true,
|
|
398
|
+
{
|
|
399
|
+
type: "string",
|
|
400
|
+
pattern: templateLiteral._zod.pattern.source
|
|
401
|
+
}
|
|
402
|
+
];
|
|
403
|
+
}
|
|
404
|
+
case "optional": {
|
|
405
|
+
const optional = schema;
|
|
406
|
+
const [, json] = this.#convert(optional._zod.def.innerType, options, lazyDepth, structureDepth);
|
|
407
|
+
return [false, json];
|
|
408
|
+
}
|
|
409
|
+
case "lazy": {
|
|
410
|
+
const lazy = schema;
|
|
411
|
+
const currentLazyDepth = lazyDepth + 1;
|
|
412
|
+
if (currentLazyDepth > this.maxLazyDepth) {
|
|
413
|
+
return [false, this.anyJsonSchema];
|
|
414
|
+
}
|
|
415
|
+
return this.#convert(lazy._zod.def.getter(), options, currentLazyDepth, structureDepth);
|
|
416
|
+
}
|
|
417
|
+
default: {
|
|
418
|
+
schema._zod.def.type;
|
|
419
|
+
return [true, this.unsupportedJsonSchema];
|
|
420
|
+
}
|
|
421
|
+
}
|
|
435
422
|
}
|
|
436
423
|
#getCustomJsonSchema(schema, options) {
|
|
437
424
|
if (options.strategy === "input" && JSON_SCHEMA_INPUT_REGISTRY.has(schema)) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temporary-name/json-schema",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.9.3-alpha.
|
|
4
|
+
"version": "1.9.3-alpha.907c7c78d0193d34752279de92d699e50d6bc3a1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://www.stainless.com/",
|
|
7
7
|
"repository": {
|
|
@@ -29,15 +29,16 @@
|
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"zod": "^4.1.11",
|
|
32
|
-
"@temporary-name/interop": "1.9.3-alpha.
|
|
33
|
-
"@temporary-name/server": "1.9.3-alpha.
|
|
34
|
-
"@temporary-name/shared": "1.9.3-alpha.
|
|
35
|
-
"@temporary-name/zod": "1.9.3-alpha.
|
|
32
|
+
"@temporary-name/interop": "1.9.3-alpha.907c7c78d0193d34752279de92d699e50d6bc3a1",
|
|
33
|
+
"@temporary-name/server": "1.9.3-alpha.907c7c78d0193d34752279de92d699e50d6bc3a1",
|
|
34
|
+
"@temporary-name/shared": "1.9.3-alpha.907c7c78d0193d34752279de92d699e50d6bc3a1",
|
|
35
|
+
"@temporary-name/zod": "1.9.3-alpha.907c7c78d0193d34752279de92d699e50d6bc3a1"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"build": "unbuild",
|
|
40
40
|
"build:watch": "pnpm run build --watch",
|
|
41
|
+
"clean": "tsc -b --clean",
|
|
41
42
|
"type:check": "tsc -b"
|
|
42
43
|
}
|
|
43
44
|
}
|