@forklaunch/implementation-worker-bullmq 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.
@@ -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/bullMqWorker.schema.ts
463
20
  import { serviceSchemaResolver } from "@forklaunch/internal";
464
21
 
465
- // ../../../node_modules/.pnpm/@forklaunch+validator@0.7.5_openapi3-ts@4.5.0/node_modules/@forklaunch/validator/lib/src/typebox/index.mjs
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.3/node_modules/@forklaunch/common/lib/index.mjs
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.5_openapi3-ts@4.5.0/node_modules/@forklaunch/validator/lib/src/typebox/index.mjs
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,
@@ -1028,50 +585,672 @@ var BullMqWorkerOptionsSchema = {
1028
585
  interval: number
1029
586
  };
1030
587
 
1031
- // ../../../node_modules/.pnpm/@forklaunch+validator@0.7.5_openapi3-ts@4.5.0/node_modules/@forklaunch/validator/lib/src/zod/index.mjs
1032
- var import_zod_openapi = __toESM(require_src(), 1);
588
+ // ../../../node_modules/.pnpm/@forklaunch+validator@0.7.7/node_modules/@forklaunch/validator/lib/src/zod/index.mjs
1033
589
  import {
1034
- z,
590
+ z as z2,
1035
591
  ZodType
1036
592
  } from "zod/v3";
1037
- (0, import_zod_openapi.extendZodWithOpenApi)(z);
593
+
594
+ // ../../../node_modules/.pnpm/ts-deepmerge@7.0.3/node_modules/ts-deepmerge/esm/index.js
595
+ var isObject = (obj) => {
596
+ if (typeof obj === "object" && obj !== null) {
597
+ if (typeof Object.getPrototypeOf === "function") {
598
+ const prototype = Object.getPrototypeOf(obj);
599
+ return prototype === Object.prototype || prototype === null;
600
+ }
601
+ return Object.prototype.toString.call(obj) === "[object Object]";
602
+ }
603
+ return false;
604
+ };
605
+ var merge = (...objects) => objects.reduce((result, current) => {
606
+ if (current === void 0) {
607
+ return result;
608
+ }
609
+ if (Array.isArray(current)) {
610
+ throw new TypeError("Arguments provided to ts-deepmerge must be objects, not arrays.");
611
+ }
612
+ Object.keys(current).forEach((key) => {
613
+ if (["__proto__", "constructor", "prototype"].includes(key)) {
614
+ return;
615
+ }
616
+ if (Array.isArray(result[key]) && Array.isArray(current[key])) {
617
+ result[key] = merge.options.mergeArrays ? merge.options.uniqueArrayItems ? Array.from(new Set(result[key].concat(current[key]))) : [...result[key], ...current[key]] : current[key];
618
+ } else if (isObject(result[key]) && isObject(current[key])) {
619
+ result[key] = merge(result[key], current[key]);
620
+ } else if (!isObject(result[key]) && isObject(current[key])) {
621
+ result[key] = merge(current[key], void 0);
622
+ } else {
623
+ result[key] = current[key] === void 0 ? merge.options.allowUndefinedOverrides ? current[key] : result[key] : current[key];
624
+ }
625
+ });
626
+ return result;
627
+ }, {});
628
+ var defaultOptions = {
629
+ allowUndefinedOverrides: true,
630
+ mergeArrays: true,
631
+ uniqueArrayItems: true
632
+ };
633
+ merge.options = defaultOptions;
634
+ merge.withOptions = (options, ...objects) => {
635
+ merge.options = Object.assign(Object.assign({}, defaultOptions), options);
636
+ const result = merge(...objects);
637
+ merge.options = defaultOptions;
638
+ return result;
639
+ };
640
+
641
+ // ../../../node_modules/.pnpm/@forklaunch+validator@0.7.7/node_modules/@forklaunch/validator/lib/src/zod/index.mjs
642
+ import { z } from "zod/v3";
643
+ function extendApi(schema, schemaObject = {}) {
644
+ const This = schema.constructor;
645
+ const newSchema = new This(schema._def);
646
+ newSchema.metaOpenApi = Object.assign(
647
+ {},
648
+ schema.metaOpenApi || {},
649
+ schemaObject
650
+ );
651
+ return newSchema;
652
+ }
653
+ function iterateZodObject({
654
+ zodRef,
655
+ useOutput,
656
+ hideDefinitions,
657
+ openApiVersion
658
+ }) {
659
+ const reduced = Object.keys(zodRef.shape).filter((key) => hideDefinitions?.includes(key) === false).reduce(
660
+ (carry, key) => ({
661
+ ...carry,
662
+ [key]: generateSchema(zodRef.shape[key], useOutput, openApiVersion)
663
+ }),
664
+ {}
665
+ );
666
+ return reduced;
667
+ }
668
+ function typeFormat(type22, openApiVersion) {
669
+ return openApiVersion === "3.0" ? type22 : [type22];
670
+ }
671
+ function parseTransformation({
672
+ zodRef,
673
+ schemas,
674
+ useOutput,
675
+ openApiVersion
676
+ }) {
677
+ const input = generateSchema(zodRef._def.schema, useOutput, openApiVersion);
678
+ let output = "undefined";
679
+ if (useOutput && zodRef._def.effect) {
680
+ const effect = zodRef._def.effect.type === "transform" ? zodRef._def.effect : null;
681
+ if (effect && "transform" in effect) {
682
+ try {
683
+ const type22 = Array.isArray(input.type) ? input.type[0] : input.type;
684
+ output = typeof effect.transform(
685
+ ["integer", "number"].includes(`${type22}`) ? 0 : "string" === type22 ? "" : "boolean" === type22 ? false : "object" === type22 ? {} : "null" === type22 ? null : "array" === type22 ? [] : void 0,
686
+ { addIssue: () => void 0, path: [] }
687
+ // TODO: Discover if context is necessary here
688
+ );
689
+ } catch {
690
+ }
691
+ }
692
+ }
693
+ const outputType = output;
694
+ return merge(
695
+ {
696
+ ...zodRef.description ? { description: zodRef.description } : {},
697
+ ...input,
698
+ ...["number", "string", "boolean", "null"].includes(output) ? {
699
+ type: typeFormat(outputType, openApiVersion)
700
+ } : {}
701
+ },
702
+ ...schemas
703
+ );
704
+ }
705
+ function parseString({
706
+ zodRef,
707
+ schemas,
708
+ openApiVersion
709
+ }) {
710
+ const baseSchema = {
711
+ type: typeFormat("string", openApiVersion)
712
+ };
713
+ const { checks = [] } = zodRef._def;
714
+ checks.forEach((item) => {
715
+ switch (item.kind) {
716
+ case "email":
717
+ baseSchema.format = "email";
718
+ break;
719
+ case "uuid":
720
+ baseSchema.format = "uuid";
721
+ break;
722
+ case "cuid":
723
+ baseSchema.format = "cuid";
724
+ break;
725
+ case "url":
726
+ baseSchema.format = "uri";
727
+ break;
728
+ case "datetime":
729
+ baseSchema.format = "date-time";
730
+ break;
731
+ case "length":
732
+ baseSchema.minLength = item.value;
733
+ baseSchema.maxLength = item.value;
734
+ break;
735
+ case "max":
736
+ baseSchema.maxLength = item.value;
737
+ break;
738
+ case "min":
739
+ baseSchema.minLength = item.value;
740
+ break;
741
+ case "regex":
742
+ baseSchema.pattern = item.regex.source;
743
+ break;
744
+ }
745
+ });
746
+ return merge(
747
+ baseSchema,
748
+ zodRef.description ? { description: zodRef.description } : {},
749
+ ...schemas
750
+ );
751
+ }
752
+ function parseNumber({
753
+ zodRef,
754
+ schemas,
755
+ openApiVersion
756
+ }) {
757
+ const baseSchema = {
758
+ type: typeFormat("number", openApiVersion)
759
+ };
760
+ const { checks = [] } = zodRef._def;
761
+ checks.forEach((item) => {
762
+ switch (item.kind) {
763
+ case "max":
764
+ if (item.inclusive || openApiVersion === "3.0") {
765
+ baseSchema.maximum = item.value;
766
+ }
767
+ if (!item.inclusive) {
768
+ if (openApiVersion === "3.0") {
769
+ baseSchema.exclusiveMaximum = true;
770
+ } else {
771
+ baseSchema.exclusiveMaximum = item.value;
772
+ }
773
+ }
774
+ break;
775
+ case "min":
776
+ if (item.inclusive || openApiVersion === "3.0") {
777
+ baseSchema.minimum = item.value;
778
+ }
779
+ if (!item.inclusive) {
780
+ if (openApiVersion === "3.0") {
781
+ baseSchema.exclusiveMinimum = true;
782
+ } else {
783
+ baseSchema.exclusiveMinimum = item.value;
784
+ }
785
+ }
786
+ break;
787
+ case "int":
788
+ baseSchema.type = typeFormat("integer", openApiVersion);
789
+ break;
790
+ case "multipleOf":
791
+ baseSchema.multipleOf = item.value;
792
+ break;
793
+ }
794
+ });
795
+ return merge(
796
+ baseSchema,
797
+ zodRef.description ? { description: zodRef.description } : {},
798
+ ...schemas
799
+ );
800
+ }
801
+ function getExcludedDefinitionsFromSchema(schemas) {
802
+ const excludedDefinitions = [];
803
+ for (const schema of schemas) {
804
+ if (Array.isArray(schema.hideDefinitions)) {
805
+ excludedDefinitions.push(...schema.hideDefinitions);
806
+ }
807
+ }
808
+ return excludedDefinitions;
809
+ }
810
+ function parseObject({
811
+ zodRef,
812
+ schemas,
813
+ useOutput,
814
+ hideDefinitions,
815
+ openApiVersion
816
+ }) {
817
+ let additionalProperties;
818
+ if (!(zodRef._def.catchall instanceof z.ZodNever || zodRef._def.catchall?._def.typeName === "ZodNever"))
819
+ additionalProperties = generateSchema(
820
+ zodRef._def.catchall,
821
+ useOutput,
822
+ openApiVersion
823
+ );
824
+ else if (zodRef._def.unknownKeys === "passthrough")
825
+ additionalProperties = true;
826
+ else if (zodRef._def.unknownKeys === "strict") additionalProperties = false;
827
+ additionalProperties = additionalProperties != null ? { additionalProperties } : {};
828
+ const requiredProperties = Object.keys(
829
+ zodRef.shape
830
+ ).filter((key) => {
831
+ const item = zodRef.shape[key];
832
+ return !(item.isOptional() || item instanceof z.ZodDefault || item._def.typeName === "ZodDefault") && !(item instanceof z.ZodNever || item._def.typeName === "ZodDefault");
833
+ });
834
+ const required = requiredProperties.length > 0 ? { required: requiredProperties } : {};
835
+ return merge(
836
+ {
837
+ type: typeFormat("object", openApiVersion),
838
+ properties: iterateZodObject({
839
+ zodRef,
840
+ schemas,
841
+ useOutput,
842
+ hideDefinitions: getExcludedDefinitionsFromSchema(schemas),
843
+ openApiVersion
844
+ }),
845
+ ...required,
846
+ ...additionalProperties,
847
+ ...hideDefinitions
848
+ },
849
+ zodRef.description ? { description: zodRef.description, hideDefinitions } : {},
850
+ ...schemas
851
+ );
852
+ }
853
+ function parseRecord({
854
+ zodRef,
855
+ schemas,
856
+ useOutput,
857
+ openApiVersion
858
+ }) {
859
+ return merge(
860
+ {
861
+ type: typeFormat("object", openApiVersion),
862
+ additionalProperties: zodRef._def.valueType instanceof z.ZodUnknown ? {} : generateSchema(zodRef._def.valueType, useOutput, openApiVersion)
863
+ },
864
+ zodRef.description ? { description: zodRef.description } : {},
865
+ ...schemas
866
+ );
867
+ }
868
+ function parseBigInt({
869
+ zodRef,
870
+ schemas,
871
+ openApiVersion
872
+ }) {
873
+ return merge(
874
+ {
875
+ type: typeFormat("integer", openApiVersion),
876
+ format: "int64"
877
+ },
878
+ zodRef.description ? { description: zodRef.description } : {},
879
+ ...schemas
880
+ );
881
+ }
882
+ function parseBoolean({
883
+ zodRef,
884
+ schemas,
885
+ openApiVersion
886
+ }) {
887
+ return merge(
888
+ { type: typeFormat("boolean", openApiVersion) },
889
+ zodRef.description ? { description: zodRef.description } : {},
890
+ ...schemas
891
+ );
892
+ }
893
+ function parseDate({
894
+ zodRef,
895
+ schemas,
896
+ openApiVersion
897
+ }) {
898
+ return merge(
899
+ {
900
+ type: typeFormat("string", openApiVersion),
901
+ format: "date-time"
902
+ },
903
+ zodRef.description ? { description: zodRef.description } : {},
904
+ ...schemas
905
+ );
906
+ }
907
+ function parseNull({
908
+ zodRef,
909
+ schemas,
910
+ openApiVersion
911
+ }) {
912
+ return merge(
913
+ openApiVersion === "3.0" ? { type: "null" } : {
914
+ type: ["string", "null"],
915
+ enum: ["null"]
916
+ },
917
+ zodRef.description ? { description: zodRef.description } : {},
918
+ ...schemas
919
+ );
920
+ }
921
+ function parseOptional({
922
+ schemas,
923
+ zodRef,
924
+ useOutput,
925
+ openApiVersion
926
+ }) {
927
+ return merge(
928
+ generateSchema(zodRef.unwrap(), useOutput, openApiVersion),
929
+ zodRef.description ? { description: zodRef.description } : {},
930
+ ...schemas
931
+ );
932
+ }
933
+ function parseNullable({
934
+ schemas,
935
+ zodRef,
936
+ useOutput,
937
+ openApiVersion
938
+ }) {
939
+ const schema = generateSchema(zodRef.unwrap(), useOutput, openApiVersion);
940
+ return merge(
941
+ schema,
942
+ openApiVersion === "3.0" ? { nullable: true } : { type: typeFormat("null", openApiVersion) },
943
+ zodRef.description ? { description: zodRef.description } : {},
944
+ ...schemas
945
+ );
946
+ }
947
+ function parseDefault({
948
+ schemas,
949
+ zodRef,
950
+ useOutput,
951
+ openApiVersion
952
+ }) {
953
+ return merge(
954
+ {
955
+ default: zodRef._def.defaultValue(),
956
+ ...generateSchema(zodRef._def.innerType, useOutput, openApiVersion)
957
+ },
958
+ zodRef.description ? { description: zodRef.description } : {},
959
+ ...schemas
960
+ );
961
+ }
962
+ function parseArray({
963
+ schemas,
964
+ zodRef,
965
+ useOutput,
966
+ openApiVersion
967
+ }) {
968
+ const constraints = {};
969
+ if (zodRef._def.exactLength != null) {
970
+ constraints.minItems = zodRef._def.exactLength.value;
971
+ constraints.maxItems = zodRef._def.exactLength.value;
972
+ }
973
+ if (zodRef._def.minLength != null)
974
+ constraints.minItems = zodRef._def.minLength.value;
975
+ if (zodRef._def.maxLength != null)
976
+ constraints.maxItems = zodRef._def.maxLength.value;
977
+ return merge(
978
+ {
979
+ type: typeFormat("array", openApiVersion),
980
+ items: generateSchema(zodRef.element, useOutput, openApiVersion),
981
+ ...constraints
982
+ },
983
+ zodRef.description ? { description: zodRef.description } : {},
984
+ ...schemas
985
+ );
986
+ }
987
+ function parseLiteral({
988
+ schemas,
989
+ zodRef,
990
+ openApiVersion
991
+ }) {
992
+ const type22 = typeof zodRef._def.value;
993
+ return merge(
994
+ {
995
+ type: typeFormat(type22, openApiVersion),
996
+ enum: [zodRef._def.value]
997
+ },
998
+ zodRef.description ? { description: zodRef.description } : {},
999
+ ...schemas
1000
+ );
1001
+ }
1002
+ function parseEnum({
1003
+ schemas,
1004
+ zodRef,
1005
+ openApiVersion
1006
+ }) {
1007
+ const type22 = typeof Object.values(zodRef._def.values)[0];
1008
+ return merge(
1009
+ {
1010
+ type: typeFormat(type22, openApiVersion),
1011
+ enum: Object.values(zodRef._def.values)
1012
+ },
1013
+ zodRef.description ? { description: zodRef.description } : {},
1014
+ ...schemas
1015
+ );
1016
+ }
1017
+ function parseIntersection({
1018
+ schemas,
1019
+ zodRef,
1020
+ useOutput,
1021
+ openApiVersion
1022
+ }) {
1023
+ return merge(
1024
+ {
1025
+ allOf: [
1026
+ generateSchema(zodRef._def.left, useOutput, openApiVersion),
1027
+ generateSchema(zodRef._def.right, useOutput, openApiVersion)
1028
+ ]
1029
+ },
1030
+ zodRef.description ? { description: zodRef.description } : {},
1031
+ ...schemas
1032
+ );
1033
+ }
1034
+ function parseUnion({
1035
+ schemas,
1036
+ zodRef,
1037
+ useOutput,
1038
+ openApiVersion
1039
+ }) {
1040
+ const contents = zodRef._def.options;
1041
+ if (contents.reduce(
1042
+ (prev, content) => prev && content._def.typeName === "ZodLiteral",
1043
+ true
1044
+ )) {
1045
+ const literals = contents;
1046
+ const type22 = literals.reduce(
1047
+ (prev, content) => !prev || prev === typeof content._def.value ? typeof content._def.value : null,
1048
+ null
1049
+ );
1050
+ if (type22) {
1051
+ return merge(
1052
+ {
1053
+ type: typeFormat(type22, openApiVersion),
1054
+ enum: literals.map((literal22) => literal22._def.value)
1055
+ },
1056
+ zodRef.description ? { description: zodRef.description } : {},
1057
+ ...schemas
1058
+ );
1059
+ }
1060
+ }
1061
+ const oneOfContents = openApiVersion === "3.0" ? contents.filter((content) => content._def.typeName !== "ZodNull") : contents;
1062
+ const contentsHasNull = contents.length != oneOfContents.length;
1063
+ return merge(
1064
+ {
1065
+ oneOf: oneOfContents.map(
1066
+ (schema) => generateSchema(schema, useOutput, openApiVersion)
1067
+ )
1068
+ },
1069
+ contentsHasNull ? { nullable: true } : {},
1070
+ zodRef.description ? { description: zodRef.description } : {},
1071
+ ...schemas
1072
+ );
1073
+ }
1074
+ function parseDiscriminatedUnion({
1075
+ schemas,
1076
+ zodRef,
1077
+ useOutput,
1078
+ openApiVersion
1079
+ }) {
1080
+ return merge(
1081
+ {
1082
+ discriminator: {
1083
+ propertyName: zodRef._def.discriminator
1084
+ },
1085
+ oneOf: Array.from(
1086
+ zodRef._def.options.values()
1087
+ ).map((schema) => generateSchema(schema, useOutput, openApiVersion))
1088
+ },
1089
+ zodRef.description ? { description: zodRef.description } : {},
1090
+ ...schemas
1091
+ );
1092
+ }
1093
+ function parseNever({
1094
+ zodRef,
1095
+ schemas
1096
+ }) {
1097
+ return merge(
1098
+ { readOnly: true },
1099
+ zodRef.description ? { description: zodRef.description } : {},
1100
+ ...schemas
1101
+ );
1102
+ }
1103
+ function parseBranded({
1104
+ schemas,
1105
+ zodRef,
1106
+ useOutput,
1107
+ openApiVersion
1108
+ }) {
1109
+ return merge(
1110
+ generateSchema(zodRef._def.type, useOutput, openApiVersion),
1111
+ ...schemas
1112
+ );
1113
+ }
1114
+ function catchAllParser({
1115
+ zodRef,
1116
+ schemas
1117
+ }) {
1118
+ return merge(
1119
+ zodRef.description ? { description: zodRef.description } : {},
1120
+ ...schemas
1121
+ );
1122
+ }
1123
+ function parsePipeline({
1124
+ schemas,
1125
+ zodRef,
1126
+ useOutput,
1127
+ openApiVersion
1128
+ }) {
1129
+ return merge(
1130
+ generateSchema(
1131
+ useOutput ? zodRef._def.out : zodRef._def.in,
1132
+ useOutput,
1133
+ openApiVersion
1134
+ ),
1135
+ ...schemas
1136
+ );
1137
+ }
1138
+ function parseReadonly({
1139
+ zodRef,
1140
+ useOutput,
1141
+ schemas,
1142
+ openApiVersion
1143
+ }) {
1144
+ return merge(
1145
+ generateSchema(zodRef._def.innerType, useOutput, openApiVersion),
1146
+ zodRef.description ? { description: zodRef.description } : {},
1147
+ ...schemas
1148
+ );
1149
+ }
1150
+ var workerMap = {
1151
+ ZodObject: parseObject,
1152
+ ZodRecord: parseRecord,
1153
+ ZodString: parseString,
1154
+ ZodNumber: parseNumber,
1155
+ ZodBigInt: parseBigInt,
1156
+ ZodBoolean: parseBoolean,
1157
+ ZodDate: parseDate,
1158
+ ZodNull: parseNull,
1159
+ ZodOptional: parseOptional,
1160
+ ZodNullable: parseNullable,
1161
+ ZodDefault: parseDefault,
1162
+ ZodArray: parseArray,
1163
+ ZodLiteral: parseLiteral,
1164
+ ZodEnum: parseEnum,
1165
+ ZodNativeEnum: parseEnum,
1166
+ ZodTransformer: parseTransformation,
1167
+ ZodEffects: parseTransformation,
1168
+ ZodIntersection: parseIntersection,
1169
+ ZodUnion: parseUnion,
1170
+ ZodDiscriminatedUnion: parseDiscriminatedUnion,
1171
+ ZodNever: parseNever,
1172
+ ZodBranded: parseBranded,
1173
+ // TODO Transform the rest to schemas
1174
+ ZodUndefined: catchAllParser,
1175
+ // TODO: `prefixItems` is allowed in OpenAPI 3.1 which can be used to create tuples
1176
+ ZodTuple: catchAllParser,
1177
+ ZodMap: catchAllParser,
1178
+ ZodFunction: catchAllParser,
1179
+ ZodLazy: catchAllParser,
1180
+ ZodPromise: catchAllParser,
1181
+ ZodAny: catchAllParser,
1182
+ ZodUnknown: catchAllParser,
1183
+ ZodVoid: catchAllParser,
1184
+ ZodPipeline: parsePipeline,
1185
+ ZodReadonly: parseReadonly
1186
+ };
1187
+ function generateSchema(zodRef, useOutput = false, openApiVersion = "3.1") {
1188
+ const { metaOpenApi = {} } = zodRef;
1189
+ const schemas = [
1190
+ ...Array.isArray(metaOpenApi) ? metaOpenApi : [metaOpenApi]
1191
+ ];
1192
+ try {
1193
+ const typeName = zodRef._def.typeName;
1194
+ if (typeName in workerMap) {
1195
+ return workerMap[typeName]({
1196
+ zodRef,
1197
+ schemas,
1198
+ useOutput,
1199
+ openApiVersion
1200
+ });
1201
+ }
1202
+ return catchAllParser({ zodRef, schemas, openApiVersion });
1203
+ } catch (err) {
1204
+ console.error(err);
1205
+ return catchAllParser({ zodRef, schemas, openApiVersion });
1206
+ }
1207
+ }
1208
+ function extendZodWithOpenApi(zod, forceOverride = false) {
1209
+ if (!forceOverride && typeof zod.ZodSchema.prototype.openapi !== "undefined") {
1210
+ return;
1211
+ }
1212
+ zod.ZodSchema.prototype.openapi = function(metadata) {
1213
+ return extendApi(this, metadata);
1214
+ };
1215
+ }
1216
+ extendZodWithOpenApi(z2);
1038
1217
  var ZodSchemaValidator = class {
1039
1218
  _Type = "Zod";
1040
1219
  _SchemaCatchall;
1041
1220
  _ValidSchemaObject;
1042
- string = z.string().openapi({
1221
+ string = z2.string().openapi({
1043
1222
  title: "String",
1044
1223
  example: "a string"
1045
1224
  });
1046
- uuid = z.string().uuid().openapi({
1225
+ uuid = z2.string().uuid().openapi({
1047
1226
  title: "UUID",
1048
1227
  format: "uuid",
1049
1228
  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}$",
1050
1229
  example: "a8b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6"
1051
1230
  });
1052
- email = z.string().email().openapi({
1231
+ email = z2.string().email().openapi({
1053
1232
  title: "Email",
1054
1233
  format: "email",
1055
1234
  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])+)])`,
1056
1235
  example: "a@b.com"
1057
1236
  });
1058
- uri = z.string().url().openapi({
1237
+ uri = z2.string().url().openapi({
1059
1238
  title: "URI",
1060
1239
  format: "uri",
1061
1240
  pattern: "^[a-zA-Z][a-zA-Z\\d+-.]*:[^\\s]*$",
1062
1241
  example: "https://forklaunch.com"
1063
1242
  });
1064
- number = z.preprocess((value) => {
1243
+ number = z2.preprocess((value) => {
1065
1244
  try {
1066
1245
  return Number(value);
1067
1246
  } catch {
1068
1247
  return value;
1069
1248
  }
1070
- }, z.number()).openapi({
1249
+ }, z2.number()).openapi({
1071
1250
  title: "Number",
1072
1251
  example: 123
1073
1252
  });
1074
- bigint = z.preprocess((value) => {
1253
+ bigint = z2.preprocess((value) => {
1075
1254
  try {
1076
1255
  if (value instanceof Date) {
1077
1256
  return BigInt(value.getTime());
@@ -1088,23 +1267,23 @@ var ZodSchemaValidator = class {
1088
1267
  } catch {
1089
1268
  return value;
1090
1269
  }
1091
- }, z.bigint()).openapi({
1270
+ }, z2.bigint()).openapi({
1092
1271
  title: "BigInt",
1093
1272
  type: "integer",
1094
1273
  format: "int64",
1095
1274
  example: 123n
1096
1275
  });
1097
- boolean = z.preprocess((val) => {
1276
+ boolean = z2.preprocess((val) => {
1098
1277
  if (typeof val === "string") {
1099
1278
  if (val.toLowerCase() === "true") return true;
1100
1279
  if (val.toLowerCase() === "false") return false;
1101
1280
  }
1102
1281
  return val;
1103
- }, z.boolean()).openapi({
1282
+ }, z2.boolean()).openapi({
1104
1283
  title: "Boolean",
1105
1284
  example: true
1106
1285
  });
1107
- date = z.preprocess((value) => {
1286
+ date = z2.preprocess((value) => {
1108
1287
  try {
1109
1288
  switch (typeof value) {
1110
1289
  case "string":
@@ -1117,58 +1296,58 @@ var ZodSchemaValidator = class {
1117
1296
  } catch {
1118
1297
  return value;
1119
1298
  }
1120
- }, z.date()).openapi({
1299
+ }, z2.date()).openapi({
1121
1300
  title: "Date",
1122
1301
  type: "string",
1123
1302
  format: "date-time",
1124
1303
  example: "2025-05-16T21:13:04.123Z"
1125
1304
  });
1126
- symbol = z.symbol().openapi({
1305
+ symbol = z2.symbol().openapi({
1127
1306
  title: "Symbol",
1128
1307
  example: Symbol("symbol")
1129
1308
  });
1130
- nullish = z.union([z.void(), z.null(), z.undefined()]).openapi({
1309
+ nullish = z2.union([z2.void(), z2.null(), z2.undefined()]).openapi({
1131
1310
  title: "Nullish",
1132
1311
  type: "null",
1133
1312
  example: null
1134
1313
  });
1135
- void = z.void().openapi({
1314
+ void = z2.void().openapi({
1136
1315
  title: "Void",
1137
1316
  type: "null",
1138
1317
  example: void 0
1139
1318
  });
1140
- null = z.null().openapi({
1319
+ null = z2.null().openapi({
1141
1320
  title: "Null",
1142
1321
  type: "null",
1143
1322
  example: null
1144
1323
  });
1145
- undefined = z.undefined().openapi({
1324
+ undefined = z2.undefined().openapi({
1146
1325
  title: "Undefined",
1147
1326
  type: "null",
1148
1327
  example: void 0
1149
1328
  });
1150
- any = z.any().openapi({
1329
+ any = z2.any().openapi({
1151
1330
  title: "Any",
1152
1331
  type: "object",
1153
1332
  example: "any"
1154
1333
  });
1155
- unknown = z.unknown().openapi({
1334
+ unknown = z2.unknown().openapi({
1156
1335
  title: "Unknown",
1157
1336
  type: "object",
1158
1337
  example: "unknown"
1159
1338
  });
1160
- never = z.never().openapi({
1339
+ never = z2.never().openapi({
1161
1340
  title: "Never",
1162
1341
  type: "null",
1163
1342
  example: "never"
1164
1343
  });
1165
- binary = z.string().transform((v) => new TextEncoder().encode(v)).openapi({
1344
+ binary = z2.string().transform((v) => new TextEncoder().encode(v)).openapi({
1166
1345
  title: "Binary",
1167
1346
  type: "string",
1168
1347
  format: "binary",
1169
1348
  example: "a utf-8 encodable string"
1170
1349
  });
1171
- file = z.string().transform((val) => {
1350
+ file = z2.string().transform((val) => {
1172
1351
  return new Blob([val]);
1173
1352
  }).openapi({
1174
1353
  title: "File",
@@ -1193,7 +1372,7 @@ var ZodSchemaValidator = class {
1193
1372
  */
1194
1373
  schemify(schema) {
1195
1374
  if (typeof schema === "string" || typeof schema === "number" || typeof schema === "boolean") {
1196
- return z.literal(schema);
1375
+ return z2.literal(schema);
1197
1376
  }
1198
1377
  if (schema instanceof ZodType) {
1199
1378
  return schema;
@@ -1206,7 +1385,7 @@ var ZodSchemaValidator = class {
1206
1385
  newSchema[key] = this.schemify(schema[key]);
1207
1386
  }
1208
1387
  });
1209
- return z.object(newSchema);
1388
+ return z2.object(newSchema);
1210
1389
  }
1211
1390
  /**
1212
1391
  * Make a schema optional.
@@ -1233,7 +1412,7 @@ var ZodSchemaValidator = class {
1233
1412
  */
1234
1413
  union(schemas) {
1235
1414
  const resolvedSchemas = schemas.map((schema) => this.schemify(schema));
1236
- return z.union(
1415
+ return z2.union(
1237
1416
  resolvedSchemas
1238
1417
  );
1239
1418
  }
@@ -1243,7 +1422,7 @@ var ZodSchemaValidator = class {
1243
1422
  * @returns {ZodLiteral<ZodResolve<T>>} The literal schema.
1244
1423
  */
1245
1424
  literal(value) {
1246
- return z.literal(value);
1425
+ return z2.literal(value);
1247
1426
  }
1248
1427
  /**
1249
1428
  * Create an enum schema.
@@ -1264,7 +1443,7 @@ var ZodSchemaValidator = class {
1264
1443
  function_(args, returnType) {
1265
1444
  const schemaArgs = args.map((schema) => this.schemify(schema));
1266
1445
  const schemaReturnType = this.schemify(returnType);
1267
- return z.function(z.tuple(schemaArgs), schemaReturnType);
1446
+ return z2.function(z2.tuple(schemaArgs), schemaReturnType);
1268
1447
  }
1269
1448
  /**
1270
1449
  * Create a record schema.
@@ -1275,7 +1454,7 @@ var ZodSchemaValidator = class {
1275
1454
  record(key, value) {
1276
1455
  const keySchema = this.schemify(key);
1277
1456
  const valueSchema = this.schemify(value);
1278
- return z.record(keySchema, valueSchema);
1457
+ return z2.record(keySchema, valueSchema);
1279
1458
  }
1280
1459
  /**
1281
1460
  * Create a promise schema.
@@ -1283,7 +1462,7 @@ var ZodSchemaValidator = class {
1283
1462
  * @returns {ZodPromise<ZodResolve<T>>} The promise schema.
1284
1463
  */
1285
1464
  promise(schema) {
1286
- return z.promise(this.schemify(schema));
1465
+ return z2.promise(this.schemify(schema));
1287
1466
  }
1288
1467
  /**
1289
1468
  * Checks if a value is a Zod schema.
@@ -1354,7 +1533,7 @@ var ZodSchemaValidator = class {
1354
1533
  * @returns {SchemaObject} The OpenAPI schema object.
1355
1534
  */
1356
1535
  openapi(schema) {
1357
- return (0, import_zod_openapi.generateSchema)(this.schemify(schema));
1536
+ return generateSchema(this.schemify(schema));
1358
1537
  }
1359
1538
  };
1360
1539
  var SchemaValidator2 = () => new ZodSchemaValidator();