@forklaunch/implementation-worker-redis 0.3.7 → 0.4.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/lib/domain/schemas/index.d.mts +4 -4
- package/lib/domain/schemas/index.d.ts +4 -4
- package/lib/domain/schemas/index.js +629 -444
- package/lib/domain/schemas/index.mjs +659 -480
- package/package.json +7 -7
|
@@ -1,18 +1,7 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
8
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
9
|
-
}) : x)(function(x) {
|
|
10
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
11
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
12
|
-
});
|
|
13
|
-
var __commonJS = (cb, mod) => function __require2() {
|
|
14
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
15
|
-
};
|
|
16
5
|
var __export = (target, all) => {
|
|
17
6
|
for (var name in all)
|
|
18
7
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -26,443 +15,11 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
26
15
|
return to;
|
|
27
16
|
};
|
|
28
17
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
29
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
30
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
31
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
32
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
33
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
34
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
35
|
-
mod
|
|
36
|
-
));
|
|
37
|
-
|
|
38
|
-
// ../../../node_modules/.pnpm/ts-deepmerge@6.2.1/node_modules/ts-deepmerge/cjs/index.js
|
|
39
|
-
var require_cjs = __commonJS({
|
|
40
|
-
"../../../node_modules/.pnpm/ts-deepmerge@6.2.1/node_modules/ts-deepmerge/cjs/index.js"(exports) {
|
|
41
|
-
"use strict";
|
|
42
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
-
var isObject = (obj) => {
|
|
44
|
-
if (typeof obj === "object" && obj !== null) {
|
|
45
|
-
if (typeof Object.getPrototypeOf === "function") {
|
|
46
|
-
const prototype = Object.getPrototypeOf(obj);
|
|
47
|
-
return prototype === Object.prototype || prototype === null;
|
|
48
|
-
}
|
|
49
|
-
return Object.prototype.toString.call(obj) === "[object Object]";
|
|
50
|
-
}
|
|
51
|
-
return false;
|
|
52
|
-
};
|
|
53
|
-
var merge = (...objects) => objects.reduce((result, current) => {
|
|
54
|
-
if (Array.isArray(current)) {
|
|
55
|
-
throw new TypeError("Arguments provided to ts-deepmerge must be objects, not arrays.");
|
|
56
|
-
}
|
|
57
|
-
Object.keys(current).forEach((key) => {
|
|
58
|
-
if (["__proto__", "constructor", "prototype"].includes(key)) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
if (Array.isArray(result[key]) && Array.isArray(current[key])) {
|
|
62
|
-
result[key] = merge.options.mergeArrays ? merge.options.uniqueArrayItems ? Array.from(new Set(result[key].concat(current[key]))) : [...result[key], ...current[key]] : current[key];
|
|
63
|
-
} else if (isObject(result[key]) && isObject(current[key])) {
|
|
64
|
-
result[key] = merge(result[key], current[key]);
|
|
65
|
-
} else {
|
|
66
|
-
result[key] = current[key] === void 0 ? merge.options.allowUndefinedOverrides ? current[key] : result[key] : current[key];
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
return result;
|
|
70
|
-
}, {});
|
|
71
|
-
var defaultOptions = {
|
|
72
|
-
allowUndefinedOverrides: true,
|
|
73
|
-
mergeArrays: true,
|
|
74
|
-
uniqueArrayItems: true
|
|
75
|
-
};
|
|
76
|
-
merge.options = defaultOptions;
|
|
77
|
-
merge.withOptions = (options, ...objects) => {
|
|
78
|
-
merge.options = Object.assign(Object.assign({}, defaultOptions), options);
|
|
79
|
-
const result = merge(...objects);
|
|
80
|
-
merge.options = defaultOptions;
|
|
81
|
-
return result;
|
|
82
|
-
};
|
|
83
|
-
exports.default = merge;
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
// ../../../node_modules/.pnpm/@anatine+zod-openapi@2.2.8_openapi3-ts@4.5.0_zod@3.25.76/node_modules/@anatine/zod-openapi/src/lib/zod-openapi.js
|
|
88
|
-
var require_zod_openapi = __commonJS({
|
|
89
|
-
"../../../node_modules/.pnpm/@anatine+zod-openapi@2.2.8_openapi3-ts@4.5.0_zod@3.25.76/node_modules/@anatine/zod-openapi/src/lib/zod-openapi.js"(exports) {
|
|
90
|
-
"use strict";
|
|
91
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
92
|
-
exports.generateSchema = exports.extendApi = void 0;
|
|
93
|
-
var ts_deepmerge_1 = require_cjs();
|
|
94
|
-
var zod_1 = __require("zod");
|
|
95
|
-
function extendApi(schema, schemaObject = {}) {
|
|
96
|
-
const This = schema.constructor;
|
|
97
|
-
const newSchema = new This(schema._def);
|
|
98
|
-
newSchema.metaOpenApi = Object.assign({}, schema.metaOpenApi || {}, schemaObject);
|
|
99
|
-
return newSchema;
|
|
100
|
-
}
|
|
101
|
-
exports.extendApi = extendApi;
|
|
102
|
-
function iterateZodObject({ zodRef, useOutput, hideDefinitions, openApiVersion }) {
|
|
103
|
-
const reduced = Object.keys(zodRef.shape).filter((key) => (hideDefinitions === null || hideDefinitions === void 0 ? void 0 : hideDefinitions.includes(key)) === false).reduce((carry, key) => Object.assign(Object.assign({}, carry), { [key]: generateSchema2(zodRef.shape[key], useOutput, openApiVersion) }), {});
|
|
104
|
-
return reduced;
|
|
105
|
-
}
|
|
106
|
-
function typeFormat(type3, openApiVersion) {
|
|
107
|
-
return openApiVersion === "3.0" ? type3 : [type3];
|
|
108
|
-
}
|
|
109
|
-
function parseTransformation({ zodRef, schemas, useOutput, openApiVersion }) {
|
|
110
|
-
const input = generateSchema2(zodRef._def.schema, useOutput, openApiVersion);
|
|
111
|
-
let output = "undefined";
|
|
112
|
-
if (useOutput && zodRef._def.effect) {
|
|
113
|
-
const effect = zodRef._def.effect.type === "transform" ? zodRef._def.effect : null;
|
|
114
|
-
if (effect && "transform" in effect) {
|
|
115
|
-
try {
|
|
116
|
-
const type3 = Array.isArray(input.type) ? input.type[0] : input.type;
|
|
117
|
-
output = typeof effect.transform(
|
|
118
|
-
["integer", "number"].includes(`${type3}`) ? 0 : "string" === type3 ? "" : "boolean" === type3 ? false : "object" === type3 ? {} : "null" === type3 ? null : "array" === type3 ? [] : void 0,
|
|
119
|
-
{ addIssue: () => void 0, path: [] }
|
|
120
|
-
// TODO: Discover if context is necessary here
|
|
121
|
-
);
|
|
122
|
-
} catch (e) {
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
const outputType = output;
|
|
127
|
-
return (0, ts_deepmerge_1.default)(Object.assign(Object.assign(Object.assign({}, zodRef.description ? { description: zodRef.description } : {}), input), ["number", "string", "boolean", "null"].includes(output) ? {
|
|
128
|
-
type: typeFormat(outputType, openApiVersion)
|
|
129
|
-
} : {}), ...schemas);
|
|
130
|
-
}
|
|
131
|
-
function parseString({ zodRef, schemas, openApiVersion }) {
|
|
132
|
-
const baseSchema = {
|
|
133
|
-
type: typeFormat("string", openApiVersion)
|
|
134
|
-
};
|
|
135
|
-
const { checks = [] } = zodRef._def;
|
|
136
|
-
checks.forEach((item) => {
|
|
137
|
-
switch (item.kind) {
|
|
138
|
-
case "email":
|
|
139
|
-
baseSchema.format = "email";
|
|
140
|
-
break;
|
|
141
|
-
case "uuid":
|
|
142
|
-
baseSchema.format = "uuid";
|
|
143
|
-
break;
|
|
144
|
-
case "cuid":
|
|
145
|
-
baseSchema.format = "cuid";
|
|
146
|
-
break;
|
|
147
|
-
case "url":
|
|
148
|
-
baseSchema.format = "uri";
|
|
149
|
-
break;
|
|
150
|
-
case "datetime":
|
|
151
|
-
baseSchema.format = "date-time";
|
|
152
|
-
break;
|
|
153
|
-
case "length":
|
|
154
|
-
baseSchema.minLength = item.value;
|
|
155
|
-
baseSchema.maxLength = item.value;
|
|
156
|
-
break;
|
|
157
|
-
case "max":
|
|
158
|
-
baseSchema.maxLength = item.value;
|
|
159
|
-
break;
|
|
160
|
-
case "min":
|
|
161
|
-
baseSchema.minLength = item.value;
|
|
162
|
-
break;
|
|
163
|
-
case "regex":
|
|
164
|
-
baseSchema.pattern = item.regex.source;
|
|
165
|
-
break;
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
return (0, ts_deepmerge_1.default)(baseSchema, zodRef.description ? { description: zodRef.description } : {}, ...schemas);
|
|
169
|
-
}
|
|
170
|
-
function parseNumber({ zodRef, schemas, openApiVersion }) {
|
|
171
|
-
const baseSchema = {
|
|
172
|
-
type: typeFormat("number", openApiVersion)
|
|
173
|
-
};
|
|
174
|
-
const { checks = [] } = zodRef._def;
|
|
175
|
-
checks.forEach((item) => {
|
|
176
|
-
switch (item.kind) {
|
|
177
|
-
case "max":
|
|
178
|
-
if (item.inclusive || openApiVersion === "3.0") {
|
|
179
|
-
baseSchema.maximum = item.value;
|
|
180
|
-
}
|
|
181
|
-
if (!item.inclusive) {
|
|
182
|
-
if (openApiVersion === "3.0") {
|
|
183
|
-
baseSchema.exclusiveMaximum = true;
|
|
184
|
-
} else {
|
|
185
|
-
baseSchema.exclusiveMaximum = item.value;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
break;
|
|
189
|
-
case "min":
|
|
190
|
-
if (item.inclusive || openApiVersion === "3.0") {
|
|
191
|
-
baseSchema.minimum = item.value;
|
|
192
|
-
}
|
|
193
|
-
if (!item.inclusive) {
|
|
194
|
-
if (openApiVersion === "3.0") {
|
|
195
|
-
baseSchema.exclusiveMinimum = true;
|
|
196
|
-
} else {
|
|
197
|
-
baseSchema.exclusiveMinimum = item.value;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
break;
|
|
201
|
-
case "int":
|
|
202
|
-
baseSchema.type = typeFormat("integer", openApiVersion);
|
|
203
|
-
break;
|
|
204
|
-
case "multipleOf":
|
|
205
|
-
baseSchema.multipleOf = item.value;
|
|
206
|
-
break;
|
|
207
|
-
}
|
|
208
|
-
});
|
|
209
|
-
return (0, ts_deepmerge_1.default)(baseSchema, zodRef.description ? { description: zodRef.description } : {}, ...schemas);
|
|
210
|
-
}
|
|
211
|
-
function getExcludedDefinitionsFromSchema(schemas) {
|
|
212
|
-
const excludedDefinitions = [];
|
|
213
|
-
for (const schema of schemas) {
|
|
214
|
-
if (Array.isArray(schema.hideDefinitions)) {
|
|
215
|
-
excludedDefinitions.push(...schema.hideDefinitions);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
return excludedDefinitions;
|
|
219
|
-
}
|
|
220
|
-
function parseObject({ zodRef, schemas, useOutput, hideDefinitions, openApiVersion }) {
|
|
221
|
-
var _a;
|
|
222
|
-
let additionalProperties;
|
|
223
|
-
if (!(zodRef._def.catchall instanceof zod_1.z.ZodNever || ((_a = zodRef._def.catchall) === null || _a === void 0 ? void 0 : _a._def.typeName) === "ZodNever"))
|
|
224
|
-
additionalProperties = generateSchema2(zodRef._def.catchall, useOutput, openApiVersion);
|
|
225
|
-
else if (zodRef._def.unknownKeys === "passthrough")
|
|
226
|
-
additionalProperties = true;
|
|
227
|
-
else if (zodRef._def.unknownKeys === "strict")
|
|
228
|
-
additionalProperties = false;
|
|
229
|
-
additionalProperties = additionalProperties != null ? { additionalProperties } : {};
|
|
230
|
-
const requiredProperties = Object.keys(zodRef.shape).filter((key) => {
|
|
231
|
-
const item = zodRef.shape[key];
|
|
232
|
-
return !(item.isOptional() || item instanceof zod_1.z.ZodDefault || item._def.typeName === "ZodDefault") && !(item instanceof zod_1.z.ZodNever || item._def.typeName === "ZodDefault");
|
|
233
|
-
});
|
|
234
|
-
const required = requiredProperties.length > 0 ? { required: requiredProperties } : {};
|
|
235
|
-
return (0, ts_deepmerge_1.default)(Object.assign(Object.assign(Object.assign({ type: typeFormat("object", openApiVersion), properties: iterateZodObject({
|
|
236
|
-
zodRef,
|
|
237
|
-
schemas,
|
|
238
|
-
useOutput,
|
|
239
|
-
hideDefinitions: getExcludedDefinitionsFromSchema(schemas),
|
|
240
|
-
openApiVersion
|
|
241
|
-
}) }, required), additionalProperties), hideDefinitions), zodRef.description ? { description: zodRef.description, hideDefinitions } : {}, ...schemas);
|
|
242
|
-
}
|
|
243
|
-
function parseRecord({ zodRef, schemas, useOutput, openApiVersion }) {
|
|
244
|
-
return (0, ts_deepmerge_1.default)({
|
|
245
|
-
type: typeFormat("object", openApiVersion),
|
|
246
|
-
additionalProperties: zodRef._def.valueType instanceof zod_1.z.ZodUnknown ? {} : generateSchema2(zodRef._def.valueType, useOutput, openApiVersion)
|
|
247
|
-
}, zodRef.description ? { description: zodRef.description } : {}, ...schemas);
|
|
248
|
-
}
|
|
249
|
-
function parseBigInt({ zodRef, schemas, openApiVersion }) {
|
|
250
|
-
return (0, ts_deepmerge_1.default)({
|
|
251
|
-
type: typeFormat("integer", openApiVersion),
|
|
252
|
-
format: "int64"
|
|
253
|
-
}, zodRef.description ? { description: zodRef.description } : {}, ...schemas);
|
|
254
|
-
}
|
|
255
|
-
function parseBoolean({ zodRef, schemas, openApiVersion }) {
|
|
256
|
-
return (0, ts_deepmerge_1.default)({ type: typeFormat("boolean", openApiVersion) }, zodRef.description ? { description: zodRef.description } : {}, ...schemas);
|
|
257
|
-
}
|
|
258
|
-
function parseDate({ zodRef, schemas, openApiVersion }) {
|
|
259
|
-
return (0, ts_deepmerge_1.default)({
|
|
260
|
-
type: typeFormat("string", openApiVersion),
|
|
261
|
-
format: "date-time"
|
|
262
|
-
}, zodRef.description ? { description: zodRef.description } : {}, ...schemas);
|
|
263
|
-
}
|
|
264
|
-
function parseNull({ zodRef, schemas, openApiVersion }) {
|
|
265
|
-
return (0, ts_deepmerge_1.default)(openApiVersion === "3.0" ? { type: "null" } : {
|
|
266
|
-
type: ["string", "null"],
|
|
267
|
-
enum: ["null"]
|
|
268
|
-
}, zodRef.description ? { description: zodRef.description } : {}, ...schemas);
|
|
269
|
-
}
|
|
270
|
-
function parseOptional({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
271
|
-
return (0, ts_deepmerge_1.default)(generateSchema2(zodRef.unwrap(), useOutput, openApiVersion), zodRef.description ? { description: zodRef.description } : {}, ...schemas);
|
|
272
|
-
}
|
|
273
|
-
function parseNullable({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
274
|
-
const schema = generateSchema2(zodRef.unwrap(), useOutput, openApiVersion);
|
|
275
|
-
return (0, ts_deepmerge_1.default)(schema, openApiVersion === "3.0" ? { nullable: true } : { type: typeFormat("null", openApiVersion) }, zodRef.description ? { description: zodRef.description } : {}, ...schemas);
|
|
276
|
-
}
|
|
277
|
-
function parseDefault({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
278
|
-
return (0, ts_deepmerge_1.default)(Object.assign({ default: zodRef._def.defaultValue() }, generateSchema2(zodRef._def.innerType, useOutput, openApiVersion)), zodRef.description ? { description: zodRef.description } : {}, ...schemas);
|
|
279
|
-
}
|
|
280
|
-
function parseArray({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
281
|
-
const constraints = {};
|
|
282
|
-
if (zodRef._def.exactLength != null) {
|
|
283
|
-
constraints.minItems = zodRef._def.exactLength.value;
|
|
284
|
-
constraints.maxItems = zodRef._def.exactLength.value;
|
|
285
|
-
}
|
|
286
|
-
if (zodRef._def.minLength != null)
|
|
287
|
-
constraints.minItems = zodRef._def.minLength.value;
|
|
288
|
-
if (zodRef._def.maxLength != null)
|
|
289
|
-
constraints.maxItems = zodRef._def.maxLength.value;
|
|
290
|
-
return (0, ts_deepmerge_1.default)(Object.assign({ type: typeFormat("array", openApiVersion), items: generateSchema2(zodRef.element, useOutput, openApiVersion) }, constraints), zodRef.description ? { description: zodRef.description } : {}, ...schemas);
|
|
291
|
-
}
|
|
292
|
-
function parseLiteral({ schemas, zodRef, openApiVersion }) {
|
|
293
|
-
const type3 = typeof zodRef._def.value;
|
|
294
|
-
return (0, ts_deepmerge_1.default)({
|
|
295
|
-
type: typeFormat(type3, openApiVersion),
|
|
296
|
-
enum: [zodRef._def.value]
|
|
297
|
-
}, zodRef.description ? { description: zodRef.description } : {}, ...schemas);
|
|
298
|
-
}
|
|
299
|
-
function parseEnum({ schemas, zodRef, openApiVersion }) {
|
|
300
|
-
const type3 = typeof Object.values(zodRef._def.values)[0];
|
|
301
|
-
return (0, ts_deepmerge_1.default)({
|
|
302
|
-
type: typeFormat(type3, openApiVersion),
|
|
303
|
-
enum: Object.values(zodRef._def.values)
|
|
304
|
-
}, zodRef.description ? { description: zodRef.description } : {}, ...schemas);
|
|
305
|
-
}
|
|
306
|
-
function parseIntersection({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
307
|
-
return (0, ts_deepmerge_1.default)({
|
|
308
|
-
allOf: [
|
|
309
|
-
generateSchema2(zodRef._def.left, useOutput, openApiVersion),
|
|
310
|
-
generateSchema2(zodRef._def.right, useOutput, openApiVersion)
|
|
311
|
-
]
|
|
312
|
-
}, zodRef.description ? { description: zodRef.description } : {}, ...schemas);
|
|
313
|
-
}
|
|
314
|
-
function parseUnion({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
315
|
-
const contents = zodRef._def.options;
|
|
316
|
-
if (contents.reduce((prev, content) => prev && content._def.typeName === "ZodLiteral", true)) {
|
|
317
|
-
const literals = contents;
|
|
318
|
-
const type3 = literals.reduce((prev, content) => !prev || prev === typeof content._def.value ? typeof content._def.value : null, null);
|
|
319
|
-
if (type3) {
|
|
320
|
-
return (0, ts_deepmerge_1.default)({
|
|
321
|
-
type: typeFormat(type3, openApiVersion),
|
|
322
|
-
enum: literals.map((literal3) => literal3._def.value)
|
|
323
|
-
}, zodRef.description ? { description: zodRef.description } : {}, ...schemas);
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
const oneOfContents = openApiVersion === "3.0" ? contents.filter((content) => content._def.typeName !== "ZodNull") : contents;
|
|
327
|
-
const contentsHasNull = contents.length != oneOfContents.length;
|
|
328
|
-
return (0, ts_deepmerge_1.default)({
|
|
329
|
-
oneOf: oneOfContents.map((schema) => generateSchema2(schema, useOutput, openApiVersion))
|
|
330
|
-
}, contentsHasNull ? { nullable: true } : {}, zodRef.description ? { description: zodRef.description } : {}, ...schemas);
|
|
331
|
-
}
|
|
332
|
-
function parseDiscriminatedUnion({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
333
|
-
return (0, ts_deepmerge_1.default)({
|
|
334
|
-
discriminator: {
|
|
335
|
-
propertyName: zodRef._def.discriminator
|
|
336
|
-
},
|
|
337
|
-
oneOf: Array.from(zodRef._def.options.values()).map((schema) => generateSchema2(schema, useOutput, openApiVersion))
|
|
338
|
-
}, zodRef.description ? { description: zodRef.description } : {}, ...schemas);
|
|
339
|
-
}
|
|
340
|
-
function parseNever({ zodRef, schemas }) {
|
|
341
|
-
return (0, ts_deepmerge_1.default)({ readOnly: true }, zodRef.description ? { description: zodRef.description } : {}, ...schemas);
|
|
342
|
-
}
|
|
343
|
-
function parseBranded({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
344
|
-
return (0, ts_deepmerge_1.default)(generateSchema2(zodRef._def.type, useOutput, openApiVersion), ...schemas);
|
|
345
|
-
}
|
|
346
|
-
function catchAllParser({ zodRef, schemas }) {
|
|
347
|
-
return (0, ts_deepmerge_1.default)(zodRef.description ? { description: zodRef.description } : {}, ...schemas);
|
|
348
|
-
}
|
|
349
|
-
function parsePipeline({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
350
|
-
return (0, ts_deepmerge_1.default)(generateSchema2(useOutput ? zodRef._def.out : zodRef._def.in, useOutput, openApiVersion), ...schemas);
|
|
351
|
-
}
|
|
352
|
-
function parseReadonly({ zodRef, useOutput, schemas, openApiVersion }) {
|
|
353
|
-
return (0, ts_deepmerge_1.default)(generateSchema2(zodRef._def.innerType, useOutput, openApiVersion), zodRef.description ? { description: zodRef.description } : {}, ...schemas);
|
|
354
|
-
}
|
|
355
|
-
var workerMap = {
|
|
356
|
-
ZodObject: parseObject,
|
|
357
|
-
ZodRecord: parseRecord,
|
|
358
|
-
ZodString: parseString,
|
|
359
|
-
ZodNumber: parseNumber,
|
|
360
|
-
ZodBigInt: parseBigInt,
|
|
361
|
-
ZodBoolean: parseBoolean,
|
|
362
|
-
ZodDate: parseDate,
|
|
363
|
-
ZodNull: parseNull,
|
|
364
|
-
ZodOptional: parseOptional,
|
|
365
|
-
ZodNullable: parseNullable,
|
|
366
|
-
ZodDefault: parseDefault,
|
|
367
|
-
ZodArray: parseArray,
|
|
368
|
-
ZodLiteral: parseLiteral,
|
|
369
|
-
ZodEnum: parseEnum,
|
|
370
|
-
ZodNativeEnum: parseEnum,
|
|
371
|
-
ZodTransformer: parseTransformation,
|
|
372
|
-
ZodEffects: parseTransformation,
|
|
373
|
-
ZodIntersection: parseIntersection,
|
|
374
|
-
ZodUnion: parseUnion,
|
|
375
|
-
ZodDiscriminatedUnion: parseDiscriminatedUnion,
|
|
376
|
-
ZodNever: parseNever,
|
|
377
|
-
ZodBranded: parseBranded,
|
|
378
|
-
// TODO Transform the rest to schemas
|
|
379
|
-
ZodUndefined: catchAllParser,
|
|
380
|
-
// TODO: `prefixItems` is allowed in OpenAPI 3.1 which can be used to create tuples
|
|
381
|
-
ZodTuple: catchAllParser,
|
|
382
|
-
ZodMap: catchAllParser,
|
|
383
|
-
ZodFunction: catchAllParser,
|
|
384
|
-
ZodLazy: catchAllParser,
|
|
385
|
-
ZodPromise: catchAllParser,
|
|
386
|
-
ZodAny: catchAllParser,
|
|
387
|
-
ZodUnknown: catchAllParser,
|
|
388
|
-
ZodVoid: catchAllParser,
|
|
389
|
-
ZodPipeline: parsePipeline,
|
|
390
|
-
ZodReadonly: parseReadonly
|
|
391
|
-
};
|
|
392
|
-
function generateSchema2(zodRef, useOutput = false, openApiVersion = "3.1") {
|
|
393
|
-
const { metaOpenApi = {} } = zodRef;
|
|
394
|
-
const schemas = [
|
|
395
|
-
...Array.isArray(metaOpenApi) ? metaOpenApi : [metaOpenApi]
|
|
396
|
-
];
|
|
397
|
-
try {
|
|
398
|
-
const typeName = zodRef._def.typeName;
|
|
399
|
-
if (typeName in workerMap) {
|
|
400
|
-
return workerMap[typeName]({
|
|
401
|
-
zodRef,
|
|
402
|
-
schemas,
|
|
403
|
-
useOutput,
|
|
404
|
-
openApiVersion
|
|
405
|
-
});
|
|
406
|
-
}
|
|
407
|
-
return catchAllParser({ zodRef, schemas, openApiVersion });
|
|
408
|
-
} catch (err) {
|
|
409
|
-
console.error(err);
|
|
410
|
-
return catchAllParser({ zodRef, schemas, openApiVersion });
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
exports.generateSchema = generateSchema2;
|
|
414
|
-
}
|
|
415
|
-
});
|
|
416
|
-
|
|
417
|
-
// ../../../node_modules/.pnpm/@anatine+zod-openapi@2.2.8_openapi3-ts@4.5.0_zod@3.25.76/node_modules/@anatine/zod-openapi/src/lib/zod-extensions.js
|
|
418
|
-
var require_zod_extensions = __commonJS({
|
|
419
|
-
"../../../node_modules/.pnpm/@anatine+zod-openapi@2.2.8_openapi3-ts@4.5.0_zod@3.25.76/node_modules/@anatine/zod-openapi/src/lib/zod-extensions.js"(exports) {
|
|
420
|
-
"use strict";
|
|
421
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
422
|
-
exports.extendZodWithOpenApi = void 0;
|
|
423
|
-
var zod_openapi_1 = require_zod_openapi();
|
|
424
|
-
function extendZodWithOpenApi2(zod, forceOverride = false) {
|
|
425
|
-
if (!forceOverride && typeof zod.ZodSchema.prototype.openapi !== "undefined") {
|
|
426
|
-
return;
|
|
427
|
-
}
|
|
428
|
-
zod.ZodSchema.prototype.openapi = function(metadata) {
|
|
429
|
-
return (0, zod_openapi_1.extendApi)(this, metadata);
|
|
430
|
-
};
|
|
431
|
-
}
|
|
432
|
-
exports.extendZodWithOpenApi = extendZodWithOpenApi2;
|
|
433
|
-
}
|
|
434
|
-
});
|
|
435
|
-
|
|
436
|
-
// ../../../node_modules/.pnpm/@anatine+zod-openapi@2.2.8_openapi3-ts@4.5.0_zod@3.25.76/node_modules/@anatine/zod-openapi/src/index.js
|
|
437
|
-
var require_src = __commonJS({
|
|
438
|
-
"../../../node_modules/.pnpm/@anatine+zod-openapi@2.2.8_openapi3-ts@4.5.0_zod@3.25.76/node_modules/@anatine/zod-openapi/src/index.js"(exports) {
|
|
439
|
-
"use strict";
|
|
440
|
-
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
441
|
-
if (k2 === void 0) k2 = k;
|
|
442
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
443
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
444
|
-
desc = { enumerable: true, get: function() {
|
|
445
|
-
return m[k];
|
|
446
|
-
} };
|
|
447
|
-
}
|
|
448
|
-
Object.defineProperty(o, k2, desc);
|
|
449
|
-
} : function(o, m, k, k2) {
|
|
450
|
-
if (k2 === void 0) k2 = k;
|
|
451
|
-
o[k2] = m[k];
|
|
452
|
-
});
|
|
453
|
-
var __exportStar = exports && exports.__exportStar || function(m, exports2) {
|
|
454
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p)) __createBinding(exports2, m, p);
|
|
455
|
-
};
|
|
456
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
457
|
-
__exportStar(require_zod_openapi(), exports);
|
|
458
|
-
__exportStar(require_zod_extensions(), exports);
|
|
459
|
-
}
|
|
460
|
-
});
|
|
461
18
|
|
|
462
19
|
// domain/schemas/redisWorker.schema.ts
|
|
463
20
|
import { serviceSchemaResolver } from "@forklaunch/internal";
|
|
464
21
|
|
|
465
|
-
// ../../../node_modules/.pnpm/@forklaunch+validator@0.7.
|
|
22
|
+
// ../../../node_modules/.pnpm/@forklaunch+validator@0.7.7/node_modules/@forklaunch/validator/lib/src/typebox/index.mjs
|
|
466
23
|
var typebox_exports = {};
|
|
467
24
|
__export(typebox_exports, {
|
|
468
25
|
SchemaValidator: () => SchemaValidator,
|
|
@@ -503,7 +60,7 @@ __export(typebox_exports, {
|
|
|
503
60
|
__reExport(typebox_exports, typebox_star);
|
|
504
61
|
import * as typebox_star from "@sinclair/typebox";
|
|
505
62
|
|
|
506
|
-
// ../../../node_modules/.pnpm/@forklaunch+common@0.4.
|
|
63
|
+
// ../../../node_modules/.pnpm/@forklaunch+common@0.4.5/node_modules/@forklaunch/common/lib/index.mjs
|
|
507
64
|
var InMemoryBlob = class extends Blob {
|
|
508
65
|
constructor(content) {
|
|
509
66
|
super([Buffer.from(content)]);
|
|
@@ -511,7 +68,7 @@ var InMemoryBlob = class extends Blob {
|
|
|
511
68
|
}
|
|
512
69
|
};
|
|
513
70
|
|
|
514
|
-
// ../../../node_modules/.pnpm/@forklaunch+validator@0.7.
|
|
71
|
+
// ../../../node_modules/.pnpm/@forklaunch+validator@0.7.7/node_modules/@forklaunch/validator/lib/src/typebox/index.mjs
|
|
515
72
|
import {
|
|
516
73
|
FormatRegistry,
|
|
517
74
|
Kind,
|
|
@@ -1027,50 +584,672 @@ var RedisWorkerOptionsSchema = {
|
|
|
1027
584
|
interval: number
|
|
1028
585
|
};
|
|
1029
586
|
|
|
1030
|
-
// ../../../node_modules/.pnpm/@forklaunch+validator@0.7.
|
|
1031
|
-
var import_zod_openapi = __toESM(require_src(), 1);
|
|
587
|
+
// ../../../node_modules/.pnpm/@forklaunch+validator@0.7.7/node_modules/@forklaunch/validator/lib/src/zod/index.mjs
|
|
1032
588
|
import {
|
|
1033
|
-
z,
|
|
589
|
+
z as z2,
|
|
1034
590
|
ZodType
|
|
1035
591
|
} from "zod/v3";
|
|
1036
|
-
|
|
592
|
+
|
|
593
|
+
// ../../../node_modules/.pnpm/ts-deepmerge@7.0.3/node_modules/ts-deepmerge/esm/index.js
|
|
594
|
+
var isObject = (obj) => {
|
|
595
|
+
if (typeof obj === "object" && obj !== null) {
|
|
596
|
+
if (typeof Object.getPrototypeOf === "function") {
|
|
597
|
+
const prototype = Object.getPrototypeOf(obj);
|
|
598
|
+
return prototype === Object.prototype || prototype === null;
|
|
599
|
+
}
|
|
600
|
+
return Object.prototype.toString.call(obj) === "[object Object]";
|
|
601
|
+
}
|
|
602
|
+
return false;
|
|
603
|
+
};
|
|
604
|
+
var merge = (...objects) => objects.reduce((result, current) => {
|
|
605
|
+
if (current === void 0) {
|
|
606
|
+
return result;
|
|
607
|
+
}
|
|
608
|
+
if (Array.isArray(current)) {
|
|
609
|
+
throw new TypeError("Arguments provided to ts-deepmerge must be objects, not arrays.");
|
|
610
|
+
}
|
|
611
|
+
Object.keys(current).forEach((key) => {
|
|
612
|
+
if (["__proto__", "constructor", "prototype"].includes(key)) {
|
|
613
|
+
return;
|
|
614
|
+
}
|
|
615
|
+
if (Array.isArray(result[key]) && Array.isArray(current[key])) {
|
|
616
|
+
result[key] = merge.options.mergeArrays ? merge.options.uniqueArrayItems ? Array.from(new Set(result[key].concat(current[key]))) : [...result[key], ...current[key]] : current[key];
|
|
617
|
+
} else if (isObject(result[key]) && isObject(current[key])) {
|
|
618
|
+
result[key] = merge(result[key], current[key]);
|
|
619
|
+
} else if (!isObject(result[key]) && isObject(current[key])) {
|
|
620
|
+
result[key] = merge(current[key], void 0);
|
|
621
|
+
} else {
|
|
622
|
+
result[key] = current[key] === void 0 ? merge.options.allowUndefinedOverrides ? current[key] : result[key] : current[key];
|
|
623
|
+
}
|
|
624
|
+
});
|
|
625
|
+
return result;
|
|
626
|
+
}, {});
|
|
627
|
+
var defaultOptions = {
|
|
628
|
+
allowUndefinedOverrides: true,
|
|
629
|
+
mergeArrays: true,
|
|
630
|
+
uniqueArrayItems: true
|
|
631
|
+
};
|
|
632
|
+
merge.options = defaultOptions;
|
|
633
|
+
merge.withOptions = (options, ...objects) => {
|
|
634
|
+
merge.options = Object.assign(Object.assign({}, defaultOptions), options);
|
|
635
|
+
const result = merge(...objects);
|
|
636
|
+
merge.options = defaultOptions;
|
|
637
|
+
return result;
|
|
638
|
+
};
|
|
639
|
+
|
|
640
|
+
// ../../../node_modules/.pnpm/@forklaunch+validator@0.7.7/node_modules/@forklaunch/validator/lib/src/zod/index.mjs
|
|
641
|
+
import { z } from "zod/v3";
|
|
642
|
+
function extendApi(schema, schemaObject = {}) {
|
|
643
|
+
const This = schema.constructor;
|
|
644
|
+
const newSchema = new This(schema._def);
|
|
645
|
+
newSchema.metaOpenApi = Object.assign(
|
|
646
|
+
{},
|
|
647
|
+
schema.metaOpenApi || {},
|
|
648
|
+
schemaObject
|
|
649
|
+
);
|
|
650
|
+
return newSchema;
|
|
651
|
+
}
|
|
652
|
+
function iterateZodObject({
|
|
653
|
+
zodRef,
|
|
654
|
+
useOutput,
|
|
655
|
+
hideDefinitions,
|
|
656
|
+
openApiVersion
|
|
657
|
+
}) {
|
|
658
|
+
const reduced = Object.keys(zodRef.shape).filter((key) => hideDefinitions?.includes(key) === false).reduce(
|
|
659
|
+
(carry, key) => ({
|
|
660
|
+
...carry,
|
|
661
|
+
[key]: generateSchema(zodRef.shape[key], useOutput, openApiVersion)
|
|
662
|
+
}),
|
|
663
|
+
{}
|
|
664
|
+
);
|
|
665
|
+
return reduced;
|
|
666
|
+
}
|
|
667
|
+
function typeFormat(type22, openApiVersion) {
|
|
668
|
+
return openApiVersion === "3.0" ? type22 : [type22];
|
|
669
|
+
}
|
|
670
|
+
function parseTransformation({
|
|
671
|
+
zodRef,
|
|
672
|
+
schemas,
|
|
673
|
+
useOutput,
|
|
674
|
+
openApiVersion
|
|
675
|
+
}) {
|
|
676
|
+
const input = generateSchema(zodRef._def.schema, useOutput, openApiVersion);
|
|
677
|
+
let output = "undefined";
|
|
678
|
+
if (useOutput && zodRef._def.effect) {
|
|
679
|
+
const effect = zodRef._def.effect.type === "transform" ? zodRef._def.effect : null;
|
|
680
|
+
if (effect && "transform" in effect) {
|
|
681
|
+
try {
|
|
682
|
+
const type22 = Array.isArray(input.type) ? input.type[0] : input.type;
|
|
683
|
+
output = typeof effect.transform(
|
|
684
|
+
["integer", "number"].includes(`${type22}`) ? 0 : "string" === type22 ? "" : "boolean" === type22 ? false : "object" === type22 ? {} : "null" === type22 ? null : "array" === type22 ? [] : void 0,
|
|
685
|
+
{ addIssue: () => void 0, path: [] }
|
|
686
|
+
// TODO: Discover if context is necessary here
|
|
687
|
+
);
|
|
688
|
+
} catch {
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
const outputType = output;
|
|
693
|
+
return merge(
|
|
694
|
+
{
|
|
695
|
+
...zodRef.description ? { description: zodRef.description } : {},
|
|
696
|
+
...input,
|
|
697
|
+
...["number", "string", "boolean", "null"].includes(output) ? {
|
|
698
|
+
type: typeFormat(outputType, openApiVersion)
|
|
699
|
+
} : {}
|
|
700
|
+
},
|
|
701
|
+
...schemas
|
|
702
|
+
);
|
|
703
|
+
}
|
|
704
|
+
function parseString({
|
|
705
|
+
zodRef,
|
|
706
|
+
schemas,
|
|
707
|
+
openApiVersion
|
|
708
|
+
}) {
|
|
709
|
+
const baseSchema = {
|
|
710
|
+
type: typeFormat("string", openApiVersion)
|
|
711
|
+
};
|
|
712
|
+
const { checks = [] } = zodRef._def;
|
|
713
|
+
checks.forEach((item) => {
|
|
714
|
+
switch (item.kind) {
|
|
715
|
+
case "email":
|
|
716
|
+
baseSchema.format = "email";
|
|
717
|
+
break;
|
|
718
|
+
case "uuid":
|
|
719
|
+
baseSchema.format = "uuid";
|
|
720
|
+
break;
|
|
721
|
+
case "cuid":
|
|
722
|
+
baseSchema.format = "cuid";
|
|
723
|
+
break;
|
|
724
|
+
case "url":
|
|
725
|
+
baseSchema.format = "uri";
|
|
726
|
+
break;
|
|
727
|
+
case "datetime":
|
|
728
|
+
baseSchema.format = "date-time";
|
|
729
|
+
break;
|
|
730
|
+
case "length":
|
|
731
|
+
baseSchema.minLength = item.value;
|
|
732
|
+
baseSchema.maxLength = item.value;
|
|
733
|
+
break;
|
|
734
|
+
case "max":
|
|
735
|
+
baseSchema.maxLength = item.value;
|
|
736
|
+
break;
|
|
737
|
+
case "min":
|
|
738
|
+
baseSchema.minLength = item.value;
|
|
739
|
+
break;
|
|
740
|
+
case "regex":
|
|
741
|
+
baseSchema.pattern = item.regex.source;
|
|
742
|
+
break;
|
|
743
|
+
}
|
|
744
|
+
});
|
|
745
|
+
return merge(
|
|
746
|
+
baseSchema,
|
|
747
|
+
zodRef.description ? { description: zodRef.description } : {},
|
|
748
|
+
...schemas
|
|
749
|
+
);
|
|
750
|
+
}
|
|
751
|
+
function parseNumber({
|
|
752
|
+
zodRef,
|
|
753
|
+
schemas,
|
|
754
|
+
openApiVersion
|
|
755
|
+
}) {
|
|
756
|
+
const baseSchema = {
|
|
757
|
+
type: typeFormat("number", openApiVersion)
|
|
758
|
+
};
|
|
759
|
+
const { checks = [] } = zodRef._def;
|
|
760
|
+
checks.forEach((item) => {
|
|
761
|
+
switch (item.kind) {
|
|
762
|
+
case "max":
|
|
763
|
+
if (item.inclusive || openApiVersion === "3.0") {
|
|
764
|
+
baseSchema.maximum = item.value;
|
|
765
|
+
}
|
|
766
|
+
if (!item.inclusive) {
|
|
767
|
+
if (openApiVersion === "3.0") {
|
|
768
|
+
baseSchema.exclusiveMaximum = true;
|
|
769
|
+
} else {
|
|
770
|
+
baseSchema.exclusiveMaximum = item.value;
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
break;
|
|
774
|
+
case "min":
|
|
775
|
+
if (item.inclusive || openApiVersion === "3.0") {
|
|
776
|
+
baseSchema.minimum = item.value;
|
|
777
|
+
}
|
|
778
|
+
if (!item.inclusive) {
|
|
779
|
+
if (openApiVersion === "3.0") {
|
|
780
|
+
baseSchema.exclusiveMinimum = true;
|
|
781
|
+
} else {
|
|
782
|
+
baseSchema.exclusiveMinimum = item.value;
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
break;
|
|
786
|
+
case "int":
|
|
787
|
+
baseSchema.type = typeFormat("integer", openApiVersion);
|
|
788
|
+
break;
|
|
789
|
+
case "multipleOf":
|
|
790
|
+
baseSchema.multipleOf = item.value;
|
|
791
|
+
break;
|
|
792
|
+
}
|
|
793
|
+
});
|
|
794
|
+
return merge(
|
|
795
|
+
baseSchema,
|
|
796
|
+
zodRef.description ? { description: zodRef.description } : {},
|
|
797
|
+
...schemas
|
|
798
|
+
);
|
|
799
|
+
}
|
|
800
|
+
function getExcludedDefinitionsFromSchema(schemas) {
|
|
801
|
+
const excludedDefinitions = [];
|
|
802
|
+
for (const schema of schemas) {
|
|
803
|
+
if (Array.isArray(schema.hideDefinitions)) {
|
|
804
|
+
excludedDefinitions.push(...schema.hideDefinitions);
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
return excludedDefinitions;
|
|
808
|
+
}
|
|
809
|
+
function parseObject({
|
|
810
|
+
zodRef,
|
|
811
|
+
schemas,
|
|
812
|
+
useOutput,
|
|
813
|
+
hideDefinitions,
|
|
814
|
+
openApiVersion
|
|
815
|
+
}) {
|
|
816
|
+
let additionalProperties;
|
|
817
|
+
if (!(zodRef._def.catchall instanceof z.ZodNever || zodRef._def.catchall?._def.typeName === "ZodNever"))
|
|
818
|
+
additionalProperties = generateSchema(
|
|
819
|
+
zodRef._def.catchall,
|
|
820
|
+
useOutput,
|
|
821
|
+
openApiVersion
|
|
822
|
+
);
|
|
823
|
+
else if (zodRef._def.unknownKeys === "passthrough")
|
|
824
|
+
additionalProperties = true;
|
|
825
|
+
else if (zodRef._def.unknownKeys === "strict") additionalProperties = false;
|
|
826
|
+
additionalProperties = additionalProperties != null ? { additionalProperties } : {};
|
|
827
|
+
const requiredProperties = Object.keys(
|
|
828
|
+
zodRef.shape
|
|
829
|
+
).filter((key) => {
|
|
830
|
+
const item = zodRef.shape[key];
|
|
831
|
+
return !(item.isOptional() || item instanceof z.ZodDefault || item._def.typeName === "ZodDefault") && !(item instanceof z.ZodNever || item._def.typeName === "ZodDefault");
|
|
832
|
+
});
|
|
833
|
+
const required = requiredProperties.length > 0 ? { required: requiredProperties } : {};
|
|
834
|
+
return merge(
|
|
835
|
+
{
|
|
836
|
+
type: typeFormat("object", openApiVersion),
|
|
837
|
+
properties: iterateZodObject({
|
|
838
|
+
zodRef,
|
|
839
|
+
schemas,
|
|
840
|
+
useOutput,
|
|
841
|
+
hideDefinitions: getExcludedDefinitionsFromSchema(schemas),
|
|
842
|
+
openApiVersion
|
|
843
|
+
}),
|
|
844
|
+
...required,
|
|
845
|
+
...additionalProperties,
|
|
846
|
+
...hideDefinitions
|
|
847
|
+
},
|
|
848
|
+
zodRef.description ? { description: zodRef.description, hideDefinitions } : {},
|
|
849
|
+
...schemas
|
|
850
|
+
);
|
|
851
|
+
}
|
|
852
|
+
function parseRecord({
|
|
853
|
+
zodRef,
|
|
854
|
+
schemas,
|
|
855
|
+
useOutput,
|
|
856
|
+
openApiVersion
|
|
857
|
+
}) {
|
|
858
|
+
return merge(
|
|
859
|
+
{
|
|
860
|
+
type: typeFormat("object", openApiVersion),
|
|
861
|
+
additionalProperties: zodRef._def.valueType instanceof z.ZodUnknown ? {} : generateSchema(zodRef._def.valueType, useOutput, openApiVersion)
|
|
862
|
+
},
|
|
863
|
+
zodRef.description ? { description: zodRef.description } : {},
|
|
864
|
+
...schemas
|
|
865
|
+
);
|
|
866
|
+
}
|
|
867
|
+
function parseBigInt({
|
|
868
|
+
zodRef,
|
|
869
|
+
schemas,
|
|
870
|
+
openApiVersion
|
|
871
|
+
}) {
|
|
872
|
+
return merge(
|
|
873
|
+
{
|
|
874
|
+
type: typeFormat("integer", openApiVersion),
|
|
875
|
+
format: "int64"
|
|
876
|
+
},
|
|
877
|
+
zodRef.description ? { description: zodRef.description } : {},
|
|
878
|
+
...schemas
|
|
879
|
+
);
|
|
880
|
+
}
|
|
881
|
+
function parseBoolean({
|
|
882
|
+
zodRef,
|
|
883
|
+
schemas,
|
|
884
|
+
openApiVersion
|
|
885
|
+
}) {
|
|
886
|
+
return merge(
|
|
887
|
+
{ type: typeFormat("boolean", openApiVersion) },
|
|
888
|
+
zodRef.description ? { description: zodRef.description } : {},
|
|
889
|
+
...schemas
|
|
890
|
+
);
|
|
891
|
+
}
|
|
892
|
+
function parseDate({
|
|
893
|
+
zodRef,
|
|
894
|
+
schemas,
|
|
895
|
+
openApiVersion
|
|
896
|
+
}) {
|
|
897
|
+
return merge(
|
|
898
|
+
{
|
|
899
|
+
type: typeFormat("string", openApiVersion),
|
|
900
|
+
format: "date-time"
|
|
901
|
+
},
|
|
902
|
+
zodRef.description ? { description: zodRef.description } : {},
|
|
903
|
+
...schemas
|
|
904
|
+
);
|
|
905
|
+
}
|
|
906
|
+
function parseNull({
|
|
907
|
+
zodRef,
|
|
908
|
+
schemas,
|
|
909
|
+
openApiVersion
|
|
910
|
+
}) {
|
|
911
|
+
return merge(
|
|
912
|
+
openApiVersion === "3.0" ? { type: "null" } : {
|
|
913
|
+
type: ["string", "null"],
|
|
914
|
+
enum: ["null"]
|
|
915
|
+
},
|
|
916
|
+
zodRef.description ? { description: zodRef.description } : {},
|
|
917
|
+
...schemas
|
|
918
|
+
);
|
|
919
|
+
}
|
|
920
|
+
function parseOptional({
|
|
921
|
+
schemas,
|
|
922
|
+
zodRef,
|
|
923
|
+
useOutput,
|
|
924
|
+
openApiVersion
|
|
925
|
+
}) {
|
|
926
|
+
return merge(
|
|
927
|
+
generateSchema(zodRef.unwrap(), useOutput, openApiVersion),
|
|
928
|
+
zodRef.description ? { description: zodRef.description } : {},
|
|
929
|
+
...schemas
|
|
930
|
+
);
|
|
931
|
+
}
|
|
932
|
+
function parseNullable({
|
|
933
|
+
schemas,
|
|
934
|
+
zodRef,
|
|
935
|
+
useOutput,
|
|
936
|
+
openApiVersion
|
|
937
|
+
}) {
|
|
938
|
+
const schema = generateSchema(zodRef.unwrap(), useOutput, openApiVersion);
|
|
939
|
+
return merge(
|
|
940
|
+
schema,
|
|
941
|
+
openApiVersion === "3.0" ? { nullable: true } : { type: typeFormat("null", openApiVersion) },
|
|
942
|
+
zodRef.description ? { description: zodRef.description } : {},
|
|
943
|
+
...schemas
|
|
944
|
+
);
|
|
945
|
+
}
|
|
946
|
+
function parseDefault({
|
|
947
|
+
schemas,
|
|
948
|
+
zodRef,
|
|
949
|
+
useOutput,
|
|
950
|
+
openApiVersion
|
|
951
|
+
}) {
|
|
952
|
+
return merge(
|
|
953
|
+
{
|
|
954
|
+
default: zodRef._def.defaultValue(),
|
|
955
|
+
...generateSchema(zodRef._def.innerType, useOutput, openApiVersion)
|
|
956
|
+
},
|
|
957
|
+
zodRef.description ? { description: zodRef.description } : {},
|
|
958
|
+
...schemas
|
|
959
|
+
);
|
|
960
|
+
}
|
|
961
|
+
function parseArray({
|
|
962
|
+
schemas,
|
|
963
|
+
zodRef,
|
|
964
|
+
useOutput,
|
|
965
|
+
openApiVersion
|
|
966
|
+
}) {
|
|
967
|
+
const constraints = {};
|
|
968
|
+
if (zodRef._def.exactLength != null) {
|
|
969
|
+
constraints.minItems = zodRef._def.exactLength.value;
|
|
970
|
+
constraints.maxItems = zodRef._def.exactLength.value;
|
|
971
|
+
}
|
|
972
|
+
if (zodRef._def.minLength != null)
|
|
973
|
+
constraints.minItems = zodRef._def.minLength.value;
|
|
974
|
+
if (zodRef._def.maxLength != null)
|
|
975
|
+
constraints.maxItems = zodRef._def.maxLength.value;
|
|
976
|
+
return merge(
|
|
977
|
+
{
|
|
978
|
+
type: typeFormat("array", openApiVersion),
|
|
979
|
+
items: generateSchema(zodRef.element, useOutput, openApiVersion),
|
|
980
|
+
...constraints
|
|
981
|
+
},
|
|
982
|
+
zodRef.description ? { description: zodRef.description } : {},
|
|
983
|
+
...schemas
|
|
984
|
+
);
|
|
985
|
+
}
|
|
986
|
+
function parseLiteral({
|
|
987
|
+
schemas,
|
|
988
|
+
zodRef,
|
|
989
|
+
openApiVersion
|
|
990
|
+
}) {
|
|
991
|
+
const type22 = typeof zodRef._def.value;
|
|
992
|
+
return merge(
|
|
993
|
+
{
|
|
994
|
+
type: typeFormat(type22, openApiVersion),
|
|
995
|
+
enum: [zodRef._def.value]
|
|
996
|
+
},
|
|
997
|
+
zodRef.description ? { description: zodRef.description } : {},
|
|
998
|
+
...schemas
|
|
999
|
+
);
|
|
1000
|
+
}
|
|
1001
|
+
function parseEnum({
|
|
1002
|
+
schemas,
|
|
1003
|
+
zodRef,
|
|
1004
|
+
openApiVersion
|
|
1005
|
+
}) {
|
|
1006
|
+
const type22 = typeof Object.values(zodRef._def.values)[0];
|
|
1007
|
+
return merge(
|
|
1008
|
+
{
|
|
1009
|
+
type: typeFormat(type22, openApiVersion),
|
|
1010
|
+
enum: Object.values(zodRef._def.values)
|
|
1011
|
+
},
|
|
1012
|
+
zodRef.description ? { description: zodRef.description } : {},
|
|
1013
|
+
...schemas
|
|
1014
|
+
);
|
|
1015
|
+
}
|
|
1016
|
+
function parseIntersection({
|
|
1017
|
+
schemas,
|
|
1018
|
+
zodRef,
|
|
1019
|
+
useOutput,
|
|
1020
|
+
openApiVersion
|
|
1021
|
+
}) {
|
|
1022
|
+
return merge(
|
|
1023
|
+
{
|
|
1024
|
+
allOf: [
|
|
1025
|
+
generateSchema(zodRef._def.left, useOutput, openApiVersion),
|
|
1026
|
+
generateSchema(zodRef._def.right, useOutput, openApiVersion)
|
|
1027
|
+
]
|
|
1028
|
+
},
|
|
1029
|
+
zodRef.description ? { description: zodRef.description } : {},
|
|
1030
|
+
...schemas
|
|
1031
|
+
);
|
|
1032
|
+
}
|
|
1033
|
+
function parseUnion({
|
|
1034
|
+
schemas,
|
|
1035
|
+
zodRef,
|
|
1036
|
+
useOutput,
|
|
1037
|
+
openApiVersion
|
|
1038
|
+
}) {
|
|
1039
|
+
const contents = zodRef._def.options;
|
|
1040
|
+
if (contents.reduce(
|
|
1041
|
+
(prev, content) => prev && content._def.typeName === "ZodLiteral",
|
|
1042
|
+
true
|
|
1043
|
+
)) {
|
|
1044
|
+
const literals = contents;
|
|
1045
|
+
const type22 = literals.reduce(
|
|
1046
|
+
(prev, content) => !prev || prev === typeof content._def.value ? typeof content._def.value : null,
|
|
1047
|
+
null
|
|
1048
|
+
);
|
|
1049
|
+
if (type22) {
|
|
1050
|
+
return merge(
|
|
1051
|
+
{
|
|
1052
|
+
type: typeFormat(type22, openApiVersion),
|
|
1053
|
+
enum: literals.map((literal22) => literal22._def.value)
|
|
1054
|
+
},
|
|
1055
|
+
zodRef.description ? { description: zodRef.description } : {},
|
|
1056
|
+
...schemas
|
|
1057
|
+
);
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
const oneOfContents = openApiVersion === "3.0" ? contents.filter((content) => content._def.typeName !== "ZodNull") : contents;
|
|
1061
|
+
const contentsHasNull = contents.length != oneOfContents.length;
|
|
1062
|
+
return merge(
|
|
1063
|
+
{
|
|
1064
|
+
oneOf: oneOfContents.map(
|
|
1065
|
+
(schema) => generateSchema(schema, useOutput, openApiVersion)
|
|
1066
|
+
)
|
|
1067
|
+
},
|
|
1068
|
+
contentsHasNull ? { nullable: true } : {},
|
|
1069
|
+
zodRef.description ? { description: zodRef.description } : {},
|
|
1070
|
+
...schemas
|
|
1071
|
+
);
|
|
1072
|
+
}
|
|
1073
|
+
function parseDiscriminatedUnion({
|
|
1074
|
+
schemas,
|
|
1075
|
+
zodRef,
|
|
1076
|
+
useOutput,
|
|
1077
|
+
openApiVersion
|
|
1078
|
+
}) {
|
|
1079
|
+
return merge(
|
|
1080
|
+
{
|
|
1081
|
+
discriminator: {
|
|
1082
|
+
propertyName: zodRef._def.discriminator
|
|
1083
|
+
},
|
|
1084
|
+
oneOf: Array.from(
|
|
1085
|
+
zodRef._def.options.values()
|
|
1086
|
+
).map((schema) => generateSchema(schema, useOutput, openApiVersion))
|
|
1087
|
+
},
|
|
1088
|
+
zodRef.description ? { description: zodRef.description } : {},
|
|
1089
|
+
...schemas
|
|
1090
|
+
);
|
|
1091
|
+
}
|
|
1092
|
+
function parseNever({
|
|
1093
|
+
zodRef,
|
|
1094
|
+
schemas
|
|
1095
|
+
}) {
|
|
1096
|
+
return merge(
|
|
1097
|
+
{ readOnly: true },
|
|
1098
|
+
zodRef.description ? { description: zodRef.description } : {},
|
|
1099
|
+
...schemas
|
|
1100
|
+
);
|
|
1101
|
+
}
|
|
1102
|
+
function parseBranded({
|
|
1103
|
+
schemas,
|
|
1104
|
+
zodRef,
|
|
1105
|
+
useOutput,
|
|
1106
|
+
openApiVersion
|
|
1107
|
+
}) {
|
|
1108
|
+
return merge(
|
|
1109
|
+
generateSchema(zodRef._def.type, useOutput, openApiVersion),
|
|
1110
|
+
...schemas
|
|
1111
|
+
);
|
|
1112
|
+
}
|
|
1113
|
+
function catchAllParser({
|
|
1114
|
+
zodRef,
|
|
1115
|
+
schemas
|
|
1116
|
+
}) {
|
|
1117
|
+
return merge(
|
|
1118
|
+
zodRef.description ? { description: zodRef.description } : {},
|
|
1119
|
+
...schemas
|
|
1120
|
+
);
|
|
1121
|
+
}
|
|
1122
|
+
function parsePipeline({
|
|
1123
|
+
schemas,
|
|
1124
|
+
zodRef,
|
|
1125
|
+
useOutput,
|
|
1126
|
+
openApiVersion
|
|
1127
|
+
}) {
|
|
1128
|
+
return merge(
|
|
1129
|
+
generateSchema(
|
|
1130
|
+
useOutput ? zodRef._def.out : zodRef._def.in,
|
|
1131
|
+
useOutput,
|
|
1132
|
+
openApiVersion
|
|
1133
|
+
),
|
|
1134
|
+
...schemas
|
|
1135
|
+
);
|
|
1136
|
+
}
|
|
1137
|
+
function parseReadonly({
|
|
1138
|
+
zodRef,
|
|
1139
|
+
useOutput,
|
|
1140
|
+
schemas,
|
|
1141
|
+
openApiVersion
|
|
1142
|
+
}) {
|
|
1143
|
+
return merge(
|
|
1144
|
+
generateSchema(zodRef._def.innerType, useOutput, openApiVersion),
|
|
1145
|
+
zodRef.description ? { description: zodRef.description } : {},
|
|
1146
|
+
...schemas
|
|
1147
|
+
);
|
|
1148
|
+
}
|
|
1149
|
+
var workerMap = {
|
|
1150
|
+
ZodObject: parseObject,
|
|
1151
|
+
ZodRecord: parseRecord,
|
|
1152
|
+
ZodString: parseString,
|
|
1153
|
+
ZodNumber: parseNumber,
|
|
1154
|
+
ZodBigInt: parseBigInt,
|
|
1155
|
+
ZodBoolean: parseBoolean,
|
|
1156
|
+
ZodDate: parseDate,
|
|
1157
|
+
ZodNull: parseNull,
|
|
1158
|
+
ZodOptional: parseOptional,
|
|
1159
|
+
ZodNullable: parseNullable,
|
|
1160
|
+
ZodDefault: parseDefault,
|
|
1161
|
+
ZodArray: parseArray,
|
|
1162
|
+
ZodLiteral: parseLiteral,
|
|
1163
|
+
ZodEnum: parseEnum,
|
|
1164
|
+
ZodNativeEnum: parseEnum,
|
|
1165
|
+
ZodTransformer: parseTransformation,
|
|
1166
|
+
ZodEffects: parseTransformation,
|
|
1167
|
+
ZodIntersection: parseIntersection,
|
|
1168
|
+
ZodUnion: parseUnion,
|
|
1169
|
+
ZodDiscriminatedUnion: parseDiscriminatedUnion,
|
|
1170
|
+
ZodNever: parseNever,
|
|
1171
|
+
ZodBranded: parseBranded,
|
|
1172
|
+
// TODO Transform the rest to schemas
|
|
1173
|
+
ZodUndefined: catchAllParser,
|
|
1174
|
+
// TODO: `prefixItems` is allowed in OpenAPI 3.1 which can be used to create tuples
|
|
1175
|
+
ZodTuple: catchAllParser,
|
|
1176
|
+
ZodMap: catchAllParser,
|
|
1177
|
+
ZodFunction: catchAllParser,
|
|
1178
|
+
ZodLazy: catchAllParser,
|
|
1179
|
+
ZodPromise: catchAllParser,
|
|
1180
|
+
ZodAny: catchAllParser,
|
|
1181
|
+
ZodUnknown: catchAllParser,
|
|
1182
|
+
ZodVoid: catchAllParser,
|
|
1183
|
+
ZodPipeline: parsePipeline,
|
|
1184
|
+
ZodReadonly: parseReadonly
|
|
1185
|
+
};
|
|
1186
|
+
function generateSchema(zodRef, useOutput = false, openApiVersion = "3.1") {
|
|
1187
|
+
const { metaOpenApi = {} } = zodRef;
|
|
1188
|
+
const schemas = [
|
|
1189
|
+
...Array.isArray(metaOpenApi) ? metaOpenApi : [metaOpenApi]
|
|
1190
|
+
];
|
|
1191
|
+
try {
|
|
1192
|
+
const typeName = zodRef._def.typeName;
|
|
1193
|
+
if (typeName in workerMap) {
|
|
1194
|
+
return workerMap[typeName]({
|
|
1195
|
+
zodRef,
|
|
1196
|
+
schemas,
|
|
1197
|
+
useOutput,
|
|
1198
|
+
openApiVersion
|
|
1199
|
+
});
|
|
1200
|
+
}
|
|
1201
|
+
return catchAllParser({ zodRef, schemas, openApiVersion });
|
|
1202
|
+
} catch (err) {
|
|
1203
|
+
console.error(err);
|
|
1204
|
+
return catchAllParser({ zodRef, schemas, openApiVersion });
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
function extendZodWithOpenApi(zod, forceOverride = false) {
|
|
1208
|
+
if (!forceOverride && typeof zod.ZodSchema.prototype.openapi !== "undefined") {
|
|
1209
|
+
return;
|
|
1210
|
+
}
|
|
1211
|
+
zod.ZodSchema.prototype.openapi = function(metadata) {
|
|
1212
|
+
return extendApi(this, metadata);
|
|
1213
|
+
};
|
|
1214
|
+
}
|
|
1215
|
+
extendZodWithOpenApi(z2);
|
|
1037
1216
|
var ZodSchemaValidator = class {
|
|
1038
1217
|
_Type = "Zod";
|
|
1039
1218
|
_SchemaCatchall;
|
|
1040
1219
|
_ValidSchemaObject;
|
|
1041
|
-
string =
|
|
1220
|
+
string = z2.string().openapi({
|
|
1042
1221
|
title: "String",
|
|
1043
1222
|
example: "a string"
|
|
1044
1223
|
});
|
|
1045
|
-
uuid =
|
|
1224
|
+
uuid = z2.string().uuid().openapi({
|
|
1046
1225
|
title: "UUID",
|
|
1047
1226
|
format: "uuid",
|
|
1048
1227
|
pattern: "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$",
|
|
1049
1228
|
example: "a8b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6"
|
|
1050
1229
|
});
|
|
1051
|
-
email =
|
|
1230
|
+
email = z2.string().email().openapi({
|
|
1052
1231
|
title: "Email",
|
|
1053
1232
|
format: "email",
|
|
1054
1233
|
pattern: `(?:[a-z0-9!#$%&'*+/=?^_{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_{|}~-]+)*|"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)])`,
|
|
1055
1234
|
example: "a@b.com"
|
|
1056
1235
|
});
|
|
1057
|
-
uri =
|
|
1236
|
+
uri = z2.string().url().openapi({
|
|
1058
1237
|
title: "URI",
|
|
1059
1238
|
format: "uri",
|
|
1060
1239
|
pattern: "^[a-zA-Z][a-zA-Z\\d+-.]*:[^\\s]*$",
|
|
1061
1240
|
example: "https://forklaunch.com"
|
|
1062
1241
|
});
|
|
1063
|
-
number =
|
|
1242
|
+
number = z2.preprocess((value) => {
|
|
1064
1243
|
try {
|
|
1065
1244
|
return Number(value);
|
|
1066
1245
|
} catch {
|
|
1067
1246
|
return value;
|
|
1068
1247
|
}
|
|
1069
|
-
},
|
|
1248
|
+
}, z2.number()).openapi({
|
|
1070
1249
|
title: "Number",
|
|
1071
1250
|
example: 123
|
|
1072
1251
|
});
|
|
1073
|
-
bigint =
|
|
1252
|
+
bigint = z2.preprocess((value) => {
|
|
1074
1253
|
try {
|
|
1075
1254
|
if (value instanceof Date) {
|
|
1076
1255
|
return BigInt(value.getTime());
|
|
@@ -1087,23 +1266,23 @@ var ZodSchemaValidator = class {
|
|
|
1087
1266
|
} catch {
|
|
1088
1267
|
return value;
|
|
1089
1268
|
}
|
|
1090
|
-
},
|
|
1269
|
+
}, z2.bigint()).openapi({
|
|
1091
1270
|
title: "BigInt",
|
|
1092
1271
|
type: "integer",
|
|
1093
1272
|
format: "int64",
|
|
1094
1273
|
example: 123n
|
|
1095
1274
|
});
|
|
1096
|
-
boolean =
|
|
1275
|
+
boolean = z2.preprocess((val) => {
|
|
1097
1276
|
if (typeof val === "string") {
|
|
1098
1277
|
if (val.toLowerCase() === "true") return true;
|
|
1099
1278
|
if (val.toLowerCase() === "false") return false;
|
|
1100
1279
|
}
|
|
1101
1280
|
return val;
|
|
1102
|
-
},
|
|
1281
|
+
}, z2.boolean()).openapi({
|
|
1103
1282
|
title: "Boolean",
|
|
1104
1283
|
example: true
|
|
1105
1284
|
});
|
|
1106
|
-
date =
|
|
1285
|
+
date = z2.preprocess((value) => {
|
|
1107
1286
|
try {
|
|
1108
1287
|
switch (typeof value) {
|
|
1109
1288
|
case "string":
|
|
@@ -1116,58 +1295,58 @@ var ZodSchemaValidator = class {
|
|
|
1116
1295
|
} catch {
|
|
1117
1296
|
return value;
|
|
1118
1297
|
}
|
|
1119
|
-
},
|
|
1298
|
+
}, z2.date()).openapi({
|
|
1120
1299
|
title: "Date",
|
|
1121
1300
|
type: "string",
|
|
1122
1301
|
format: "date-time",
|
|
1123
1302
|
example: "2025-05-16T21:13:04.123Z"
|
|
1124
1303
|
});
|
|
1125
|
-
symbol =
|
|
1304
|
+
symbol = z2.symbol().openapi({
|
|
1126
1305
|
title: "Symbol",
|
|
1127
1306
|
example: Symbol("symbol")
|
|
1128
1307
|
});
|
|
1129
|
-
nullish =
|
|
1308
|
+
nullish = z2.union([z2.void(), z2.null(), z2.undefined()]).openapi({
|
|
1130
1309
|
title: "Nullish",
|
|
1131
1310
|
type: "null",
|
|
1132
1311
|
example: null
|
|
1133
1312
|
});
|
|
1134
|
-
void =
|
|
1313
|
+
void = z2.void().openapi({
|
|
1135
1314
|
title: "Void",
|
|
1136
1315
|
type: "null",
|
|
1137
1316
|
example: void 0
|
|
1138
1317
|
});
|
|
1139
|
-
null =
|
|
1318
|
+
null = z2.null().openapi({
|
|
1140
1319
|
title: "Null",
|
|
1141
1320
|
type: "null",
|
|
1142
1321
|
example: null
|
|
1143
1322
|
});
|
|
1144
|
-
undefined =
|
|
1323
|
+
undefined = z2.undefined().openapi({
|
|
1145
1324
|
title: "Undefined",
|
|
1146
1325
|
type: "null",
|
|
1147
1326
|
example: void 0
|
|
1148
1327
|
});
|
|
1149
|
-
any =
|
|
1328
|
+
any = z2.any().openapi({
|
|
1150
1329
|
title: "Any",
|
|
1151
1330
|
type: "object",
|
|
1152
1331
|
example: "any"
|
|
1153
1332
|
});
|
|
1154
|
-
unknown =
|
|
1333
|
+
unknown = z2.unknown().openapi({
|
|
1155
1334
|
title: "Unknown",
|
|
1156
1335
|
type: "object",
|
|
1157
1336
|
example: "unknown"
|
|
1158
1337
|
});
|
|
1159
|
-
never =
|
|
1338
|
+
never = z2.never().openapi({
|
|
1160
1339
|
title: "Never",
|
|
1161
1340
|
type: "null",
|
|
1162
1341
|
example: "never"
|
|
1163
1342
|
});
|
|
1164
|
-
binary =
|
|
1343
|
+
binary = z2.string().transform((v) => new TextEncoder().encode(v)).openapi({
|
|
1165
1344
|
title: "Binary",
|
|
1166
1345
|
type: "string",
|
|
1167
1346
|
format: "binary",
|
|
1168
1347
|
example: "a utf-8 encodable string"
|
|
1169
1348
|
});
|
|
1170
|
-
file =
|
|
1349
|
+
file = z2.string().transform((val) => {
|
|
1171
1350
|
return new Blob([val]);
|
|
1172
1351
|
}).openapi({
|
|
1173
1352
|
title: "File",
|
|
@@ -1192,7 +1371,7 @@ var ZodSchemaValidator = class {
|
|
|
1192
1371
|
*/
|
|
1193
1372
|
schemify(schema) {
|
|
1194
1373
|
if (typeof schema === "string" || typeof schema === "number" || typeof schema === "boolean") {
|
|
1195
|
-
return
|
|
1374
|
+
return z2.literal(schema);
|
|
1196
1375
|
}
|
|
1197
1376
|
if (schema instanceof ZodType) {
|
|
1198
1377
|
return schema;
|
|
@@ -1205,7 +1384,7 @@ var ZodSchemaValidator = class {
|
|
|
1205
1384
|
newSchema[key] = this.schemify(schema[key]);
|
|
1206
1385
|
}
|
|
1207
1386
|
});
|
|
1208
|
-
return
|
|
1387
|
+
return z2.object(newSchema);
|
|
1209
1388
|
}
|
|
1210
1389
|
/**
|
|
1211
1390
|
* Make a schema optional.
|
|
@@ -1232,7 +1411,7 @@ var ZodSchemaValidator = class {
|
|
|
1232
1411
|
*/
|
|
1233
1412
|
union(schemas) {
|
|
1234
1413
|
const resolvedSchemas = schemas.map((schema) => this.schemify(schema));
|
|
1235
|
-
return
|
|
1414
|
+
return z2.union(
|
|
1236
1415
|
resolvedSchemas
|
|
1237
1416
|
);
|
|
1238
1417
|
}
|
|
@@ -1242,7 +1421,7 @@ var ZodSchemaValidator = class {
|
|
|
1242
1421
|
* @returns {ZodLiteral<ZodResolve<T>>} The literal schema.
|
|
1243
1422
|
*/
|
|
1244
1423
|
literal(value) {
|
|
1245
|
-
return
|
|
1424
|
+
return z2.literal(value);
|
|
1246
1425
|
}
|
|
1247
1426
|
/**
|
|
1248
1427
|
* Create an enum schema.
|
|
@@ -1263,7 +1442,7 @@ var ZodSchemaValidator = class {
|
|
|
1263
1442
|
function_(args, returnType) {
|
|
1264
1443
|
const schemaArgs = args.map((schema) => this.schemify(schema));
|
|
1265
1444
|
const schemaReturnType = this.schemify(returnType);
|
|
1266
|
-
return
|
|
1445
|
+
return z2.function(z2.tuple(schemaArgs), schemaReturnType);
|
|
1267
1446
|
}
|
|
1268
1447
|
/**
|
|
1269
1448
|
* Create a record schema.
|
|
@@ -1274,7 +1453,7 @@ var ZodSchemaValidator = class {
|
|
|
1274
1453
|
record(key, value) {
|
|
1275
1454
|
const keySchema = this.schemify(key);
|
|
1276
1455
|
const valueSchema = this.schemify(value);
|
|
1277
|
-
return
|
|
1456
|
+
return z2.record(keySchema, valueSchema);
|
|
1278
1457
|
}
|
|
1279
1458
|
/**
|
|
1280
1459
|
* Create a promise schema.
|
|
@@ -1282,7 +1461,7 @@ var ZodSchemaValidator = class {
|
|
|
1282
1461
|
* @returns {ZodPromise<ZodResolve<T>>} The promise schema.
|
|
1283
1462
|
*/
|
|
1284
1463
|
promise(schema) {
|
|
1285
|
-
return
|
|
1464
|
+
return z2.promise(this.schemify(schema));
|
|
1286
1465
|
}
|
|
1287
1466
|
/**
|
|
1288
1467
|
* Checks if a value is a Zod schema.
|
|
@@ -1353,7 +1532,7 @@ var ZodSchemaValidator = class {
|
|
|
1353
1532
|
* @returns {SchemaObject} The OpenAPI schema object.
|
|
1354
1533
|
*/
|
|
1355
1534
|
openapi(schema) {
|
|
1356
|
-
return
|
|
1535
|
+
return generateSchema(this.schemify(schema));
|
|
1357
1536
|
}
|
|
1358
1537
|
};
|
|
1359
1538
|
var SchemaValidator2 = () => new ZodSchemaValidator();
|