@mastra/deployer 1.31.0 → 1.32.0-alpha.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/CHANGELOG.md +16 -0
- package/dist/{arktype-aI7TBD0R-SREJBG7S.cjs → arktype-aI7TBD0R-OMYN7WLS.cjs} +3 -3
- package/dist/{arktype-aI7TBD0R-SREJBG7S.cjs.map → arktype-aI7TBD0R-OMYN7WLS.cjs.map} +1 -1
- package/dist/arktype-aI7TBD0R-QMBQV4AR.js +8 -0
- package/dist/{arktype-aI7TBD0R-EYN2KO7T.js.map → arktype-aI7TBD0R-QMBQV4AR.js.map} +1 -1
- package/dist/chunk-2QB4KRZ2.js +3 -0
- package/dist/{chunk-CVUFDHJI.js.map → chunk-2QB4KRZ2.js.map} +1 -1
- package/dist/{chunk-BDSPB5KS.cjs → chunk-3VBSJXBZ.cjs} +3 -3
- package/dist/{chunk-BDSPB5KS.cjs.map → chunk-3VBSJXBZ.cjs.map} +1 -1
- package/dist/{chunk-42ZJTLTI.cjs → chunk-AW5HL7NI.cjs} +3 -3
- package/dist/{chunk-42ZJTLTI.cjs.map → chunk-AW5HL7NI.cjs.map} +1 -1
- package/dist/chunk-BAZETKRJ.cjs +16 -0
- package/dist/{chunk-VW64CRBN.cjs.map → chunk-BAZETKRJ.cjs.map} +1 -1
- package/dist/chunk-DZCA547Z.js +6 -0
- package/dist/{chunk-CMZ7WIGH.js.map → chunk-DZCA547Z.js.map} +1 -1
- package/dist/chunk-KK7AQ3E6.js +14 -0
- package/dist/{chunk-VKCHPHSC.js.map → chunk-KK7AQ3E6.js.map} +1 -1
- package/dist/{chunk-36D427ZP.js → chunk-RPAZ7M7U.js} +3 -3
- package/dist/{chunk-36D427ZP.js.map → chunk-RPAZ7M7U.js.map} +1 -1
- package/dist/{chunk-VVMCQSYT.cjs → chunk-SLVYHUWE.cjs} +9 -9
- package/dist/{chunk-VVMCQSYT.cjs.map → chunk-SLVYHUWE.cjs.map} +1 -1
- package/dist/chunk-XL2IMSPU.cjs +4 -0
- package/dist/{chunk-FSMECOJS.cjs.map → chunk-XL2IMSPU.cjs.map} +1 -1
- package/dist/{chunk-DPOHWLZ5.js → chunk-Z34VHFWS.js} +9 -9
- package/dist/{chunk-DPOHWLZ5.js.map → chunk-Z34VHFWS.js.map} +1 -1
- package/dist/default-u_dwuiYb-5HOCVF42.cjs +9 -0
- package/dist/{default-u_dwuiYb-DDZNRVPZ.cjs.map → default-u_dwuiYb-5HOCVF42.cjs.map} +1 -1
- package/dist/default-u_dwuiYb-AHUWITSW.js +3 -0
- package/dist/{default-u_dwuiYb-BO4ZO45Y.js.map → default-u_dwuiYb-AHUWITSW.js.map} +1 -1
- package/dist/dist-M5Q4LZIO.js +521 -0
- package/dist/dist-M5Q4LZIO.js.map +1 -0
- package/dist/dist-UMLKEE6J.cjs +527 -0
- package/dist/dist-UMLKEE6J.cjs.map +1 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/{effect-QlVUlMFu-GPRSECAF.js → effect-QlVUlMFu-GE6KSQJR.js} +4 -4
- package/dist/{effect-QlVUlMFu-GPRSECAF.js.map → effect-QlVUlMFu-GE6KSQJR.js.map} +1 -1
- package/dist/effect-QlVUlMFu-LW2RUXNH.cjs +17 -0
- package/dist/{effect-QlVUlMFu-MCJLFGKG.cjs.map → effect-QlVUlMFu-LW2RUXNH.cjs.map} +1 -1
- package/dist/server/index.cjs +1 -1
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.js +1 -1
- package/dist/server/index.js.map +1 -1
- package/dist/{sury-CWZTCd75-FR2KN5FN.js → sury-CWZTCd75-JQJDKHT2.js} +4 -4
- package/dist/{sury-CWZTCd75-FR2KN5FN.js.map → sury-CWZTCd75-JQJDKHT2.js.map} +1 -1
- package/dist/sury-CWZTCd75-TJFDB7YN.cjs +17 -0
- package/dist/{sury-CWZTCd75-6M5N5AE3.cjs.map → sury-CWZTCd75-TJFDB7YN.cjs.map} +1 -1
- package/dist/typebox-Dei93FPO-GYRBKU22.js +8 -0
- package/dist/{typebox-Dei93FPO-2VJBXUNJ.js.map → typebox-Dei93FPO-GYRBKU22.js.map} +1 -1
- package/dist/{typebox-Dei93FPO-RHHO6LN2.cjs → typebox-Dei93FPO-VMOENLRC.cjs} +3 -3
- package/dist/{typebox-Dei93FPO-RHHO6LN2.cjs.map → typebox-Dei93FPO-VMOENLRC.cjs.map} +1 -1
- package/dist/valibot--1zFm7rT-DBL2FAXB.cjs +17 -0
- package/dist/{valibot--1zFm7rT-TZEIZDY4.cjs.map → valibot--1zFm7rT-DBL2FAXB.cjs.map} +1 -1
- package/dist/valibot--1zFm7rT-PDIN22QQ.js +15 -0
- package/dist/{valibot--1zFm7rT-EQW553KW.js.map → valibot--1zFm7rT-PDIN22QQ.js.map} +1 -1
- package/dist/{valibot-D_HTw1Gn-7UHEQ6OU.cjs → valibot-D_HTw1Gn-L3QJICXD.cjs} +7 -7
- package/dist/{valibot-D_HTw1Gn-7UHEQ6OU.cjs.map → valibot-D_HTw1Gn-L3QJICXD.cjs.map} +1 -1
- package/dist/{valibot-D_HTw1Gn-6XJM4G2R.js → valibot-D_HTw1Gn-YGP7CQY7.js} +5 -5
- package/dist/{valibot-D_HTw1Gn-6XJM4G2R.js.map → valibot-D_HTw1Gn-YGP7CQY7.js.map} +1 -1
- package/dist/{zod-Bwrt9trS-MCGMUGSK.cjs → zod-Bwrt9trS-3ZVP7FWM.cjs} +6 -6
- package/dist/{zod-Bwrt9trS-MCGMUGSK.cjs.map → zod-Bwrt9trS-3ZVP7FWM.cjs.map} +1 -1
- package/dist/{zod-Bwrt9trS-KGHMV3R6.js → zod-Bwrt9trS-V2SU2SR3.js} +4 -4
- package/dist/{zod-Bwrt9trS-KGHMV3R6.js.map → zod-Bwrt9trS-V2SU2SR3.js.map} +1 -1
- package/dist/{zod-DSgpEGAE-HWE2ZA6O.cjs → zod-DSgpEGAE-LUDXIT4K.cjs} +7 -7
- package/dist/{zod-DSgpEGAE-HWE2ZA6O.cjs.map → zod-DSgpEGAE-LUDXIT4K.cjs.map} +1 -1
- package/dist/{zod-DSgpEGAE-UI6HO6R3.js → zod-DSgpEGAE-VPH7T364.js} +5 -5
- package/dist/{zod-DSgpEGAE-UI6HO6R3.js.map → zod-DSgpEGAE-VPH7T364.js.map} +1 -1
- package/package.json +7 -7
- package/dist/arktype-aI7TBD0R-EYN2KO7T.js +0 -8
- package/dist/chunk-CMZ7WIGH.js +0 -6
- package/dist/chunk-CVUFDHJI.js +0 -3
- package/dist/chunk-FSMECOJS.cjs +0 -4
- package/dist/chunk-VKCHPHSC.js +0 -14
- package/dist/chunk-VW64CRBN.cjs +0 -16
- package/dist/default-u_dwuiYb-BO4ZO45Y.js +0 -3
- package/dist/default-u_dwuiYb-DDZNRVPZ.cjs +0 -9
- package/dist/effect-QlVUlMFu-MCJLFGKG.cjs +0 -17
- package/dist/sury-CWZTCd75-6M5N5AE3.cjs +0 -17
- package/dist/typebox-Dei93FPO-2VJBXUNJ.js +0 -8
- package/dist/valibot--1zFm7rT-EQW553KW.js +0 -15
- package/dist/valibot--1zFm7rT-TZEIZDY4.cjs +0 -17
|
@@ -0,0 +1,521 @@
|
|
|
1
|
+
// ../../node_modules/.pnpm/valibot@1.2.0_typescript@6.0.3/node_modules/valibot/dist/index.mjs
|
|
2
|
+
// @__NO_SIDE_EFFECTS__
|
|
3
|
+
function getDefault(schema, dataset, config$1) {
|
|
4
|
+
return typeof schema.default === "function" ? schema.default(dataset, config$1) : schema.default;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
// ../../node_modules/.pnpm/@valibot+to-json-schema@1.6.0_valibot@1.2.0_typescript@6.0.3_/node_modules/@valibot/to-json-schema/dist/index.mjs
|
|
8
|
+
function addError(errors, message) {
|
|
9
|
+
if (errors) {
|
|
10
|
+
errors.push(message);
|
|
11
|
+
return errors;
|
|
12
|
+
}
|
|
13
|
+
return [message];
|
|
14
|
+
}
|
|
15
|
+
var ESCAPE_REGEX = /[.*+?^${}()|[\]\\]/g;
|
|
16
|
+
function escapeRegExp(string) {
|
|
17
|
+
return string.replace(ESCAPE_REGEX, "\\$&");
|
|
18
|
+
}
|
|
19
|
+
function handleError(message, config) {
|
|
20
|
+
switch (config?.errorMode) {
|
|
21
|
+
case "ignore":
|
|
22
|
+
break;
|
|
23
|
+
case "warn":
|
|
24
|
+
console.warn(message);
|
|
25
|
+
break;
|
|
26
|
+
default:
|
|
27
|
+
throw new Error(message);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function isJsonConstValue(value) {
|
|
31
|
+
return typeof value === "boolean" || typeof value === "number" && Number.isFinite(value) || typeof value === "string";
|
|
32
|
+
}
|
|
33
|
+
function isJsonEnumValues(values) {
|
|
34
|
+
return values.every(isJsonConstValue);
|
|
35
|
+
}
|
|
36
|
+
function convertAction(jsonSchema, valibotAction, config) {
|
|
37
|
+
if (config?.ignoreActions?.includes(valibotAction.type)) return jsonSchema;
|
|
38
|
+
let errors;
|
|
39
|
+
switch (valibotAction.type) {
|
|
40
|
+
case "base64":
|
|
41
|
+
jsonSchema.contentEncoding = "base64";
|
|
42
|
+
break;
|
|
43
|
+
case "bic":
|
|
44
|
+
case "cuid2":
|
|
45
|
+
case "decimal":
|
|
46
|
+
case "digits":
|
|
47
|
+
case "domain":
|
|
48
|
+
case "emoji":
|
|
49
|
+
case "hash":
|
|
50
|
+
case "hexadecimal":
|
|
51
|
+
case "hex_color":
|
|
52
|
+
case "isrc":
|
|
53
|
+
case "iso_time_second":
|
|
54
|
+
case "iso_week":
|
|
55
|
+
case "mac":
|
|
56
|
+
case "mac48":
|
|
57
|
+
case "mac64":
|
|
58
|
+
case "nanoid":
|
|
59
|
+
case "octal":
|
|
60
|
+
case "slug":
|
|
61
|
+
case "ulid":
|
|
62
|
+
if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
|
|
63
|
+
else jsonSchema.pattern = valibotAction.requirement.source;
|
|
64
|
+
break;
|
|
65
|
+
case "description":
|
|
66
|
+
jsonSchema.description = valibotAction.description;
|
|
67
|
+
break;
|
|
68
|
+
case "email":
|
|
69
|
+
case "rfc_email":
|
|
70
|
+
jsonSchema.format = "email";
|
|
71
|
+
break;
|
|
72
|
+
case "ends_with":
|
|
73
|
+
if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
|
|
74
|
+
else jsonSchema.pattern = `${escapeRegExp(valibotAction.requirement)}$`;
|
|
75
|
+
break;
|
|
76
|
+
case "empty":
|
|
77
|
+
if (jsonSchema.type === "array") jsonSchema.maxItems = 0;
|
|
78
|
+
else {
|
|
79
|
+
if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
|
|
80
|
+
jsonSchema.maxLength = 0;
|
|
81
|
+
}
|
|
82
|
+
break;
|
|
83
|
+
case "entries":
|
|
84
|
+
jsonSchema.minProperties = valibotAction.requirement;
|
|
85
|
+
jsonSchema.maxProperties = valibotAction.requirement;
|
|
86
|
+
break;
|
|
87
|
+
case "examples":
|
|
88
|
+
if (Array.isArray(jsonSchema.examples)) jsonSchema.examples = [...jsonSchema.examples, ...valibotAction.examples];
|
|
89
|
+
else jsonSchema.examples = valibotAction.examples;
|
|
90
|
+
break;
|
|
91
|
+
case "gt_value":
|
|
92
|
+
if (jsonSchema.type !== "number" && jsonSchema.type !== "integer") errors = addError(errors, `The "gt_value" action is not supported on type "${jsonSchema.type}".`);
|
|
93
|
+
if (config?.target === "openapi-3.0") {
|
|
94
|
+
errors = addError(errors, 'The "gt_value" action is not supported for OpenAPI 3.0.');
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
jsonSchema.exclusiveMinimum = valibotAction.requirement;
|
|
98
|
+
break;
|
|
99
|
+
case "includes":
|
|
100
|
+
if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
|
|
101
|
+
else jsonSchema.pattern = escapeRegExp(valibotAction.requirement);
|
|
102
|
+
break;
|
|
103
|
+
case "integer":
|
|
104
|
+
jsonSchema.type = "integer";
|
|
105
|
+
break;
|
|
106
|
+
case "ipv4":
|
|
107
|
+
jsonSchema.format = "ipv4";
|
|
108
|
+
break;
|
|
109
|
+
case "ipv6":
|
|
110
|
+
jsonSchema.format = "ipv6";
|
|
111
|
+
break;
|
|
112
|
+
case "iso_date":
|
|
113
|
+
jsonSchema.format = "date";
|
|
114
|
+
break;
|
|
115
|
+
case "iso_date_time":
|
|
116
|
+
case "iso_timestamp":
|
|
117
|
+
jsonSchema.format = "date-time";
|
|
118
|
+
break;
|
|
119
|
+
case "iso_time":
|
|
120
|
+
jsonSchema.format = "time";
|
|
121
|
+
break;
|
|
122
|
+
case "jws_compact":
|
|
123
|
+
if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
|
|
124
|
+
else jsonSchema.pattern = valibotAction.requirement.source;
|
|
125
|
+
break;
|
|
126
|
+
case "length":
|
|
127
|
+
if (jsonSchema.type === "array") {
|
|
128
|
+
jsonSchema.minItems = valibotAction.requirement;
|
|
129
|
+
jsonSchema.maxItems = valibotAction.requirement;
|
|
130
|
+
} else {
|
|
131
|
+
if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
|
|
132
|
+
jsonSchema.minLength = valibotAction.requirement;
|
|
133
|
+
jsonSchema.maxLength = valibotAction.requirement;
|
|
134
|
+
}
|
|
135
|
+
break;
|
|
136
|
+
case "lt_value":
|
|
137
|
+
if (jsonSchema.type !== "number" && jsonSchema.type !== "integer") errors = addError(errors, `The "lt_value" action is not supported on type "${jsonSchema.type}".`);
|
|
138
|
+
if (config?.target === "openapi-3.0") {
|
|
139
|
+
errors = addError(errors, 'The "lt_value" action is not supported for OpenAPI 3.0.');
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
jsonSchema.exclusiveMaximum = valibotAction.requirement;
|
|
143
|
+
break;
|
|
144
|
+
case "max_entries":
|
|
145
|
+
jsonSchema.maxProperties = valibotAction.requirement;
|
|
146
|
+
break;
|
|
147
|
+
case "max_length":
|
|
148
|
+
if (jsonSchema.type === "array") jsonSchema.maxItems = valibotAction.requirement;
|
|
149
|
+
else {
|
|
150
|
+
if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
|
|
151
|
+
jsonSchema.maxLength = valibotAction.requirement;
|
|
152
|
+
}
|
|
153
|
+
break;
|
|
154
|
+
case "max_value":
|
|
155
|
+
if (jsonSchema.type !== "number" && jsonSchema.type !== "integer") errors = addError(errors, `The "max_value" action is not supported on type "${jsonSchema.type}".`);
|
|
156
|
+
jsonSchema.maximum = valibotAction.requirement;
|
|
157
|
+
break;
|
|
158
|
+
case "metadata":
|
|
159
|
+
if (typeof valibotAction.metadata.title === "string") jsonSchema.title = valibotAction.metadata.title;
|
|
160
|
+
if (typeof valibotAction.metadata.description === "string") jsonSchema.description = valibotAction.metadata.description;
|
|
161
|
+
if (Array.isArray(valibotAction.metadata.examples)) if (Array.isArray(jsonSchema.examples)) jsonSchema.examples = [...jsonSchema.examples, ...valibotAction.metadata.examples];
|
|
162
|
+
else jsonSchema.examples = valibotAction.metadata.examples;
|
|
163
|
+
break;
|
|
164
|
+
case "min_entries":
|
|
165
|
+
jsonSchema.minProperties = valibotAction.requirement;
|
|
166
|
+
break;
|
|
167
|
+
case "min_length":
|
|
168
|
+
if (jsonSchema.type === "array") jsonSchema.minItems = valibotAction.requirement;
|
|
169
|
+
else {
|
|
170
|
+
if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
|
|
171
|
+
jsonSchema.minLength = valibotAction.requirement;
|
|
172
|
+
}
|
|
173
|
+
break;
|
|
174
|
+
case "min_value":
|
|
175
|
+
if (jsonSchema.type !== "number" && jsonSchema.type !== "integer") errors = addError(errors, `The "min_value" action is not supported on type "${jsonSchema.type}".`);
|
|
176
|
+
jsonSchema.minimum = valibotAction.requirement;
|
|
177
|
+
break;
|
|
178
|
+
case "multiple_of":
|
|
179
|
+
jsonSchema.multipleOf = valibotAction.requirement;
|
|
180
|
+
break;
|
|
181
|
+
case "non_empty":
|
|
182
|
+
if (jsonSchema.type === "array") jsonSchema.minItems = 1;
|
|
183
|
+
else {
|
|
184
|
+
if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
|
|
185
|
+
jsonSchema.minLength = 1;
|
|
186
|
+
}
|
|
187
|
+
break;
|
|
188
|
+
case "not_value":
|
|
189
|
+
if (!isJsonConstValue(valibotAction.requirement)) {
|
|
190
|
+
errors = addError(errors, 'The requirement of the "not_value" action is not JSON compatible.');
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
if (config?.target === "openapi-3.0") jsonSchema.not = { enum: [valibotAction.requirement] };
|
|
194
|
+
else jsonSchema.not = { const: valibotAction.requirement };
|
|
195
|
+
break;
|
|
196
|
+
case "not_values":
|
|
197
|
+
if (!isJsonEnumValues(valibotAction.requirement)) {
|
|
198
|
+
errors = addError(errors, 'A requirement of the "not_values" action is not JSON compatible.');
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
jsonSchema.not = { enum: valibotAction.requirement };
|
|
202
|
+
break;
|
|
203
|
+
case "regex":
|
|
204
|
+
if (valibotAction.requirement.flags) errors = addError(errors, "RegExp flags are not supported by JSON Schema.");
|
|
205
|
+
if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
|
|
206
|
+
else jsonSchema.pattern = valibotAction.requirement.source;
|
|
207
|
+
break;
|
|
208
|
+
case "safe_integer":
|
|
209
|
+
jsonSchema.type = "integer";
|
|
210
|
+
if (typeof jsonSchema.minimum !== "number" || jsonSchema.minimum < Number.MIN_SAFE_INTEGER) jsonSchema.minimum = Number.MIN_SAFE_INTEGER;
|
|
211
|
+
if (typeof jsonSchema.maximum !== "number" || jsonSchema.maximum > Number.MAX_SAFE_INTEGER) jsonSchema.maximum = Number.MAX_SAFE_INTEGER;
|
|
212
|
+
break;
|
|
213
|
+
case "starts_with":
|
|
214
|
+
if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
|
|
215
|
+
else jsonSchema.pattern = `^${escapeRegExp(valibotAction.requirement)}`;
|
|
216
|
+
break;
|
|
217
|
+
case "title":
|
|
218
|
+
jsonSchema.title = valibotAction.title;
|
|
219
|
+
break;
|
|
220
|
+
case "url":
|
|
221
|
+
jsonSchema.format = "uri";
|
|
222
|
+
break;
|
|
223
|
+
case "uuid":
|
|
224
|
+
jsonSchema.format = "uuid";
|
|
225
|
+
break;
|
|
226
|
+
case "value":
|
|
227
|
+
if (!isJsonConstValue(valibotAction.requirement)) {
|
|
228
|
+
errors = addError(errors, 'The requirement of the "value" action is not JSON compatible.');
|
|
229
|
+
break;
|
|
230
|
+
}
|
|
231
|
+
if (config?.target === "openapi-3.0") jsonSchema.enum = [valibotAction.requirement];
|
|
232
|
+
else jsonSchema.const = valibotAction.requirement;
|
|
233
|
+
break;
|
|
234
|
+
case "values":
|
|
235
|
+
if (!isJsonEnumValues(valibotAction.requirement)) {
|
|
236
|
+
errors = addError(errors, 'A requirement of the "values" action is not JSON compatible.');
|
|
237
|
+
break;
|
|
238
|
+
}
|
|
239
|
+
jsonSchema.enum = valibotAction.requirement;
|
|
240
|
+
break;
|
|
241
|
+
default:
|
|
242
|
+
errors = addError(errors, `The "${valibotAction.type}" action cannot be converted to JSON Schema.`);
|
|
243
|
+
}
|
|
244
|
+
if (config?.overrideAction) {
|
|
245
|
+
const actionOverride = config.overrideAction({
|
|
246
|
+
valibotAction,
|
|
247
|
+
jsonSchema,
|
|
248
|
+
errors
|
|
249
|
+
});
|
|
250
|
+
if (actionOverride) return { ...actionOverride };
|
|
251
|
+
}
|
|
252
|
+
if (errors) for (const message of errors) handleError(message, config);
|
|
253
|
+
return jsonSchema;
|
|
254
|
+
}
|
|
255
|
+
function flattenPipe(pipe) {
|
|
256
|
+
return pipe.flatMap((item) => "pipe" in item ? flattenPipe(item.pipe) : item);
|
|
257
|
+
}
|
|
258
|
+
var refCount = 0;
|
|
259
|
+
function convertSchema(jsonSchema, valibotSchema, config, context, skipRef = false) {
|
|
260
|
+
if (!skipRef) {
|
|
261
|
+
const referenceId = context.referenceMap.get(valibotSchema);
|
|
262
|
+
if (referenceId) {
|
|
263
|
+
jsonSchema.$ref = `#/$defs/${referenceId}`;
|
|
264
|
+
if (config?.overrideRef) {
|
|
265
|
+
const refOverride = config.overrideRef({
|
|
266
|
+
...context,
|
|
267
|
+
referenceId,
|
|
268
|
+
valibotSchema,
|
|
269
|
+
jsonSchema
|
|
270
|
+
});
|
|
271
|
+
if (refOverride) jsonSchema.$ref = refOverride;
|
|
272
|
+
}
|
|
273
|
+
return jsonSchema;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
if ("pipe" in valibotSchema) {
|
|
277
|
+
const flatPipe = flattenPipe(valibotSchema.pipe);
|
|
278
|
+
let startIndex = 0;
|
|
279
|
+
let stopIndex = flatPipe.length - 1;
|
|
280
|
+
if (config?.typeMode === "input") {
|
|
281
|
+
const inputStopIndex = flatPipe.slice(1).findIndex((item) => item.kind === "schema" || item.kind === "transformation" && (item.type === "find_item" || item.type === "parse_json" || item.type === "raw_transform" || item.type === "reduce_items" || item.type === "stringify_json" || item.type === "to_bigint" || item.type === "to_boolean" || item.type === "to_date" || item.type === "to_number" || item.type === "to_string" || item.type === "transform"));
|
|
282
|
+
if (inputStopIndex !== -1) stopIndex = inputStopIndex;
|
|
283
|
+
} else if (config?.typeMode === "output") {
|
|
284
|
+
const outputStartIndex = flatPipe.findLastIndex((item) => item.kind === "schema");
|
|
285
|
+
if (outputStartIndex !== -1) startIndex = outputStartIndex;
|
|
286
|
+
}
|
|
287
|
+
for (let index = startIndex; index <= stopIndex; index++) {
|
|
288
|
+
const valibotPipeItem = flatPipe[index];
|
|
289
|
+
if (valibotPipeItem.kind === "schema") {
|
|
290
|
+
if (index > startIndex) handleError('Set the "typeMode" config to "input" or "output" to convert pipelines with multiple schemas.', config);
|
|
291
|
+
jsonSchema = convertSchema(jsonSchema, valibotPipeItem, config, context, true);
|
|
292
|
+
} else jsonSchema = convertAction(jsonSchema, valibotPipeItem, config);
|
|
293
|
+
}
|
|
294
|
+
return jsonSchema;
|
|
295
|
+
}
|
|
296
|
+
let errors;
|
|
297
|
+
switch (valibotSchema.type) {
|
|
298
|
+
case "boolean":
|
|
299
|
+
jsonSchema.type = "boolean";
|
|
300
|
+
break;
|
|
301
|
+
case "null":
|
|
302
|
+
if (config?.target === "openapi-3.0") jsonSchema.enum = [null];
|
|
303
|
+
else jsonSchema.type = "null";
|
|
304
|
+
break;
|
|
305
|
+
case "number":
|
|
306
|
+
jsonSchema.type = "number";
|
|
307
|
+
break;
|
|
308
|
+
case "string":
|
|
309
|
+
jsonSchema.type = "string";
|
|
310
|
+
break;
|
|
311
|
+
case "array":
|
|
312
|
+
jsonSchema.type = "array";
|
|
313
|
+
jsonSchema.items = convertSchema({}, valibotSchema.item, config, context);
|
|
314
|
+
break;
|
|
315
|
+
case "tuple":
|
|
316
|
+
case "tuple_with_rest":
|
|
317
|
+
case "loose_tuple":
|
|
318
|
+
case "strict_tuple":
|
|
319
|
+
jsonSchema.type = "array";
|
|
320
|
+
if (config?.target === "openapi-3.0") {
|
|
321
|
+
jsonSchema.items = { anyOf: [] };
|
|
322
|
+
jsonSchema.minItems = valibotSchema.items.length;
|
|
323
|
+
for (const item of valibotSchema.items) jsonSchema.items.anyOf.push(convertSchema({}, item, config, context));
|
|
324
|
+
if (valibotSchema.type === "tuple_with_rest") jsonSchema.items.anyOf.push(convertSchema({}, valibotSchema.rest, config, context));
|
|
325
|
+
else if (valibotSchema.type === "strict_tuple" || valibotSchema.type === "tuple") jsonSchema.maxItems = valibotSchema.items.length;
|
|
326
|
+
} else if (config?.target === "draft-2020-12") {
|
|
327
|
+
jsonSchema.prefixItems = [];
|
|
328
|
+
jsonSchema.minItems = valibotSchema.items.length;
|
|
329
|
+
for (const item of valibotSchema.items) jsonSchema.prefixItems.push(convertSchema({}, item, config, context));
|
|
330
|
+
if (valibotSchema.type === "tuple_with_rest") jsonSchema.items = convertSchema({}, valibotSchema.rest, config, context);
|
|
331
|
+
else if (valibotSchema.type === "strict_tuple") jsonSchema.items = false;
|
|
332
|
+
} else {
|
|
333
|
+
jsonSchema.items = [];
|
|
334
|
+
jsonSchema.minItems = valibotSchema.items.length;
|
|
335
|
+
for (const item of valibotSchema.items) jsonSchema.items.push(convertSchema({}, item, config, context));
|
|
336
|
+
if (valibotSchema.type === "tuple_with_rest") jsonSchema.additionalItems = convertSchema({}, valibotSchema.rest, config, context);
|
|
337
|
+
else if (valibotSchema.type === "strict_tuple") jsonSchema.additionalItems = false;
|
|
338
|
+
}
|
|
339
|
+
break;
|
|
340
|
+
case "object":
|
|
341
|
+
case "object_with_rest":
|
|
342
|
+
case "loose_object":
|
|
343
|
+
case "strict_object":
|
|
344
|
+
jsonSchema.type = "object";
|
|
345
|
+
jsonSchema.properties = {};
|
|
346
|
+
jsonSchema.required = [];
|
|
347
|
+
for (const key in valibotSchema.entries) {
|
|
348
|
+
const entry = valibotSchema.entries[key];
|
|
349
|
+
jsonSchema.properties[key] = convertSchema({}, entry, config, context);
|
|
350
|
+
if (entry.type !== "exact_optional" && entry.type !== "nullish" && entry.type !== "optional") jsonSchema.required.push(key);
|
|
351
|
+
}
|
|
352
|
+
if (valibotSchema.type === "object_with_rest") jsonSchema.additionalProperties = convertSchema({}, valibotSchema.rest, config, context);
|
|
353
|
+
else if (valibotSchema.type === "strict_object") jsonSchema.additionalProperties = false;
|
|
354
|
+
break;
|
|
355
|
+
case "record":
|
|
356
|
+
if (config?.target === "openapi-3.0" && "pipe" in valibotSchema.key) errors = addError(errors, 'The "record" schema with a schema for the key that contains a "pipe" cannot be converted to JSON Schema.');
|
|
357
|
+
if (valibotSchema.key.type !== "string") errors = addError(errors, `The "record" schema with the "${valibotSchema.key.type}" schema for the key cannot be converted to JSON Schema.`);
|
|
358
|
+
jsonSchema.type = "object";
|
|
359
|
+
if (config?.target !== "openapi-3.0") jsonSchema.propertyNames = convertSchema({}, valibotSchema.key, config, context);
|
|
360
|
+
jsonSchema.additionalProperties = convertSchema({}, valibotSchema.value, config, context);
|
|
361
|
+
break;
|
|
362
|
+
case "any":
|
|
363
|
+
case "unknown":
|
|
364
|
+
break;
|
|
365
|
+
case "never":
|
|
366
|
+
jsonSchema.not = {};
|
|
367
|
+
break;
|
|
368
|
+
case "nullable":
|
|
369
|
+
case "nullish":
|
|
370
|
+
if (config?.target === "openapi-3.0") {
|
|
371
|
+
const innerSchema = convertSchema({}, valibotSchema.wrapped, config, context);
|
|
372
|
+
Object.assign(jsonSchema, innerSchema);
|
|
373
|
+
jsonSchema.nullable = true;
|
|
374
|
+
} else jsonSchema.anyOf = [convertSchema({}, valibotSchema.wrapped, config, context), { type: "null" }];
|
|
375
|
+
if (valibotSchema.default !== void 0) jsonSchema.default = getDefault(valibotSchema);
|
|
376
|
+
break;
|
|
377
|
+
case "exact_optional":
|
|
378
|
+
case "optional":
|
|
379
|
+
case "undefinedable":
|
|
380
|
+
jsonSchema = convertSchema(jsonSchema, valibotSchema.wrapped, config, context);
|
|
381
|
+
if (valibotSchema.default !== void 0) jsonSchema.default = getDefault(valibotSchema);
|
|
382
|
+
break;
|
|
383
|
+
case "literal":
|
|
384
|
+
if (typeof valibotSchema.literal !== "boolean" && typeof valibotSchema.literal !== "number" && typeof valibotSchema.literal !== "string") errors = addError(errors, 'The value of the "literal" schema is not JSON compatible.');
|
|
385
|
+
if (config?.target === "openapi-3.0") jsonSchema.enum = [valibotSchema.literal];
|
|
386
|
+
else jsonSchema.const = valibotSchema.literal;
|
|
387
|
+
break;
|
|
388
|
+
case "enum":
|
|
389
|
+
jsonSchema.enum = valibotSchema.options;
|
|
390
|
+
if (valibotSchema.options.every((option) => typeof option === "string")) jsonSchema.type = "string";
|
|
391
|
+
else if (valibotSchema.options.every((option) => typeof option === "number")) jsonSchema.type = "number";
|
|
392
|
+
else if (config?.target !== "openapi-3.0") jsonSchema.type = ["string", "number"];
|
|
393
|
+
break;
|
|
394
|
+
case "picklist": {
|
|
395
|
+
const hasInvalidOption = valibotSchema.options.some((option) => typeof option !== "number" && typeof option !== "string");
|
|
396
|
+
if (hasInvalidOption) errors = addError(errors, 'An option of the "picklist" schema is not JSON compatible.');
|
|
397
|
+
jsonSchema.enum = valibotSchema.options;
|
|
398
|
+
if (valibotSchema.options.every((option) => typeof option === "string")) jsonSchema.type = "string";
|
|
399
|
+
else if (valibotSchema.options.every((option) => typeof option === "number")) jsonSchema.type = "number";
|
|
400
|
+
else if (!hasInvalidOption && config?.target !== "openapi-3.0") jsonSchema.type = ["string", "number"];
|
|
401
|
+
break;
|
|
402
|
+
}
|
|
403
|
+
case "union":
|
|
404
|
+
jsonSchema.anyOf = valibotSchema.options.map((option) => convertSchema({}, option, config, context));
|
|
405
|
+
break;
|
|
406
|
+
case "variant":
|
|
407
|
+
jsonSchema.oneOf = valibotSchema.options.map((option) => convertSchema({}, option, config, context));
|
|
408
|
+
break;
|
|
409
|
+
case "intersect":
|
|
410
|
+
jsonSchema.allOf = valibotSchema.options.map((option) => convertSchema({}, option, config, context));
|
|
411
|
+
break;
|
|
412
|
+
case "lazy": {
|
|
413
|
+
let wrappedValibotSchema = context.getterMap.get(valibotSchema.getter);
|
|
414
|
+
if (!wrappedValibotSchema) {
|
|
415
|
+
wrappedValibotSchema = valibotSchema.getter(void 0);
|
|
416
|
+
context.getterMap.set(valibotSchema.getter, wrappedValibotSchema);
|
|
417
|
+
}
|
|
418
|
+
let referenceId = context.referenceMap.get(wrappedValibotSchema);
|
|
419
|
+
if (!referenceId) {
|
|
420
|
+
referenceId = `${refCount++}`;
|
|
421
|
+
context.referenceMap.set(wrappedValibotSchema, referenceId);
|
|
422
|
+
context.definitions[referenceId] = convertSchema({}, wrappedValibotSchema, config, context, true);
|
|
423
|
+
}
|
|
424
|
+
jsonSchema.$ref = `#/$defs/${referenceId}`;
|
|
425
|
+
if (config?.overrideRef) {
|
|
426
|
+
const refOverride = config.overrideRef({
|
|
427
|
+
...context,
|
|
428
|
+
referenceId,
|
|
429
|
+
valibotSchema: wrappedValibotSchema,
|
|
430
|
+
jsonSchema
|
|
431
|
+
});
|
|
432
|
+
if (refOverride) jsonSchema.$ref = refOverride;
|
|
433
|
+
}
|
|
434
|
+
break;
|
|
435
|
+
}
|
|
436
|
+
default:
|
|
437
|
+
errors = addError(errors, `The "${valibotSchema.type}" schema cannot be converted to JSON Schema.`);
|
|
438
|
+
}
|
|
439
|
+
if (config?.overrideSchema) {
|
|
440
|
+
const schemaOverride = config.overrideSchema({
|
|
441
|
+
...context,
|
|
442
|
+
referenceId: context.referenceMap.get(valibotSchema),
|
|
443
|
+
valibotSchema,
|
|
444
|
+
jsonSchema,
|
|
445
|
+
errors
|
|
446
|
+
});
|
|
447
|
+
if (schemaOverride) return { ...schemaOverride };
|
|
448
|
+
}
|
|
449
|
+
if (errors) for (const message of errors) handleError(message, config);
|
|
450
|
+
return jsonSchema;
|
|
451
|
+
}
|
|
452
|
+
var store;
|
|
453
|
+
function addGlobalDefs(definitions) {
|
|
454
|
+
store = {
|
|
455
|
+
...store ?? {},
|
|
456
|
+
...definitions
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
function getGlobalDefs() {
|
|
460
|
+
return store;
|
|
461
|
+
}
|
|
462
|
+
function toJsonSchema(schema, config) {
|
|
463
|
+
const context = {
|
|
464
|
+
definitions: {},
|
|
465
|
+
referenceMap: /* @__PURE__ */ new Map(),
|
|
466
|
+
getterMap: /* @__PURE__ */ new Map()
|
|
467
|
+
};
|
|
468
|
+
const definitions = config?.definitions ?? getGlobalDefs();
|
|
469
|
+
if (definitions) {
|
|
470
|
+
for (const key in definitions) context.referenceMap.set(definitions[key], key);
|
|
471
|
+
for (const key in definitions) context.definitions[key] = convertSchema({}, definitions[key], config, context, true);
|
|
472
|
+
}
|
|
473
|
+
const jsonSchema = convertSchema({}, schema, config, context);
|
|
474
|
+
const target = config?.target ?? "draft-07";
|
|
475
|
+
if (target === "draft-2020-12") jsonSchema.$schema = "https://json-schema.org/draft/2020-12/schema";
|
|
476
|
+
else if (target === "draft-07") jsonSchema.$schema = "http://json-schema.org/draft-07/schema#";
|
|
477
|
+
if (context.referenceMap.size) jsonSchema.$defs = context.definitions;
|
|
478
|
+
return jsonSchema;
|
|
479
|
+
}
|
|
480
|
+
function toJsonSchemaDefs(definitions, config) {
|
|
481
|
+
const context = {
|
|
482
|
+
definitions: {},
|
|
483
|
+
referenceMap: /* @__PURE__ */ new Map(),
|
|
484
|
+
getterMap: /* @__PURE__ */ new Map()
|
|
485
|
+
};
|
|
486
|
+
for (const key in definitions) context.referenceMap.set(definitions[key], key);
|
|
487
|
+
for (const key in definitions) context.definitions[key] = convertSchema({}, definitions[key], config, context, true);
|
|
488
|
+
return context.definitions;
|
|
489
|
+
}
|
|
490
|
+
var SUPPORTED_TARGETS = [
|
|
491
|
+
"draft-07",
|
|
492
|
+
"draft-2020-12",
|
|
493
|
+
"openapi-3.0"
|
|
494
|
+
];
|
|
495
|
+
function toStandardJsonSchema(schema) {
|
|
496
|
+
return { "~standard": {
|
|
497
|
+
...schema["~standard"],
|
|
498
|
+
jsonSchema: {
|
|
499
|
+
input(options) {
|
|
500
|
+
if (SUPPORTED_TARGETS.includes(options.target)) return toJsonSchema(schema, {
|
|
501
|
+
typeMode: "input",
|
|
502
|
+
target: options.target,
|
|
503
|
+
...options.libraryOptions
|
|
504
|
+
});
|
|
505
|
+
throw new Error(`Unsupported target: ${options.target}`);
|
|
506
|
+
},
|
|
507
|
+
output(options) {
|
|
508
|
+
if (SUPPORTED_TARGETS.includes(options.target)) return toJsonSchema(schema, {
|
|
509
|
+
typeMode: "output",
|
|
510
|
+
target: options.target,
|
|
511
|
+
...options.libraryOptions
|
|
512
|
+
});
|
|
513
|
+
throw new Error(`Unsupported target: ${options.target}`);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
} };
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
export { addGlobalDefs, getGlobalDefs, toJsonSchema, toJsonSchemaDefs, toStandardJsonSchema };
|
|
520
|
+
//# sourceMappingURL=dist-M5Q4LZIO.js.map
|
|
521
|
+
//# sourceMappingURL=dist-M5Q4LZIO.js.map
|