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