@forklaunch/implementation-worker-bullmq 0.6.0 → 0.6.2
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/consumers/index.d.mts +12 -25
- package/lib/consumers/index.d.ts +12 -25
- package/lib/consumers/index.js +10 -15
- package/lib/consumers/index.mjs +6 -4
- package/lib/domain/schemas/index.d.mts +10 -56
- package/lib/domain/schemas/index.d.ts +10 -56
- package/lib/domain/schemas/index.js +539 -581
- package/lib/domain/schemas/index.mjs +543 -545
- package/lib/domain/types/index.d.mts +4 -4
- package/lib/domain/types/index.d.ts +4 -4
- package/lib/domain/types/index.js +4 -8
- package/lib/producers/index.d.mts +7 -11
- package/lib/producers/index.d.ts +7 -11
- package/lib/producers/index.js +8 -13
- package/lib/producers/index.mjs +4 -2
- package/package.json +7 -7
|
@@ -7,25 +7,19 @@ var __export = (target, all) => {
|
|
|
7
7
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
8
|
};
|
|
9
9
|
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
11
|
for (let key of __getOwnPropNames(from))
|
|
12
12
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, {
|
|
14
|
-
get: () => from[key],
|
|
15
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
-
});
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
14
|
}
|
|
18
15
|
return to;
|
|
19
16
|
};
|
|
20
|
-
var __reExport = (target, mod, secondTarget) => (
|
|
21
|
-
__copyProps(target, mod, 'default'),
|
|
22
|
-
secondTarget && __copyProps(secondTarget, mod, 'default')
|
|
23
|
-
);
|
|
17
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
24
18
|
|
|
25
19
|
// domain/schemas/bullMqWorker.schema.ts
|
|
26
|
-
import { serviceSchemaResolver } from
|
|
20
|
+
import { serviceSchemaResolver } from "@forklaunch/internal";
|
|
27
21
|
|
|
28
|
-
// ../../../node_modules/.pnpm/@forklaunch+validator@0.10.
|
|
22
|
+
// ../../../node_modules/.pnpm/@forklaunch+validator@0.10.5/node_modules/@forklaunch/validator/lib/src/typebox/index.mjs
|
|
29
23
|
var typebox_exports = {};
|
|
30
24
|
__export(typebox_exports, {
|
|
31
25
|
SchemaValidator: () => SchemaValidator,
|
|
@@ -64,9 +58,9 @@ __export(typebox_exports, {
|
|
|
64
58
|
void_: () => void_
|
|
65
59
|
});
|
|
66
60
|
__reExport(typebox_exports, typebox_star);
|
|
67
|
-
import * as typebox_star from
|
|
61
|
+
import * as typebox_star from "@sinclair/typebox";
|
|
68
62
|
|
|
69
|
-
// ../../../node_modules/.pnpm/@forklaunch+common@0.6.
|
|
63
|
+
// ../../../node_modules/.pnpm/@forklaunch+common@0.6.5/node_modules/@forklaunch/common/lib/index.mjs
|
|
70
64
|
var InMemoryBlob = class extends Blob {
|
|
71
65
|
constructor(content) {
|
|
72
66
|
super([content]);
|
|
@@ -74,229 +68,221 @@ var InMemoryBlob = class extends Blob {
|
|
|
74
68
|
}
|
|
75
69
|
};
|
|
76
70
|
|
|
77
|
-
// ../../../node_modules/.pnpm/@forklaunch+validator@0.10.
|
|
78
|
-
import {
|
|
79
|
-
|
|
71
|
+
// ../../../node_modules/.pnpm/@forklaunch+validator@0.10.5/node_modules/@forklaunch/validator/lib/src/typebox/index.mjs
|
|
72
|
+
import {
|
|
73
|
+
FormatRegistry,
|
|
74
|
+
Kind,
|
|
75
|
+
KindGuard,
|
|
76
|
+
Type
|
|
77
|
+
} from "@sinclair/typebox";
|
|
78
|
+
import { TypeCheck, TypeCompiler } from "@sinclair/typebox/compiler";
|
|
80
79
|
import {
|
|
81
80
|
DefaultErrorFunction,
|
|
82
81
|
SetErrorFunction,
|
|
83
82
|
ValueErrorType
|
|
84
|
-
} from
|
|
85
|
-
import { Value } from
|
|
86
|
-
FormatRegistry.Set(
|
|
83
|
+
} from "@sinclair/typebox/errors";
|
|
84
|
+
import { Value } from "@sinclair/typebox/value";
|
|
85
|
+
FormatRegistry.Set("binary", (value) => typeof value === "string");
|
|
87
86
|
SetErrorFunction((params) => {
|
|
88
87
|
switch (params.errorType) {
|
|
89
88
|
case ValueErrorType.Union:
|
|
90
89
|
case ValueErrorType.Array:
|
|
91
90
|
case ValueErrorType.String:
|
|
92
91
|
case ValueErrorType.Number:
|
|
93
|
-
return params.schema.errorType
|
|
94
|
-
? `Expected ${params.schema.errorType} value${params.schema.errorSuffix ? 's' : ''}`
|
|
95
|
-
: DefaultErrorFunction(params);
|
|
92
|
+
return params.schema.errorType ? `Expected ${params.schema.errorType} value${params.schema.errorSuffix ? "s" : ""}` : DefaultErrorFunction(params);
|
|
96
93
|
default:
|
|
97
94
|
return DefaultErrorFunction(params);
|
|
98
95
|
}
|
|
99
96
|
});
|
|
100
97
|
var TypeboxSchemaValidator = class {
|
|
101
|
-
_Type =
|
|
98
|
+
_Type = "TypeBox";
|
|
102
99
|
_SchemaCatchall;
|
|
103
100
|
_ValidSchemaObject;
|
|
104
101
|
string = Type.String({
|
|
105
|
-
example:
|
|
106
|
-
title:
|
|
102
|
+
example: "a string",
|
|
103
|
+
title: "String"
|
|
107
104
|
});
|
|
108
105
|
uuid = Type.String({
|
|
109
|
-
pattern:
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
title: 'UUID'
|
|
106
|
+
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}$",
|
|
107
|
+
errorType: "uuid",
|
|
108
|
+
example: "a8b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6",
|
|
109
|
+
title: "UUID"
|
|
114
110
|
});
|
|
115
111
|
email = Type.String({
|
|
116
|
-
pattern:
|
|
117
|
-
errorType:
|
|
118
|
-
example:
|
|
119
|
-
title:
|
|
112
|
+
pattern: "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$",
|
|
113
|
+
errorType: "email",
|
|
114
|
+
example: "a@b.com",
|
|
115
|
+
title: "Email"
|
|
120
116
|
});
|
|
121
117
|
uri = Type.String({
|
|
122
|
-
pattern:
|
|
123
|
-
errorType:
|
|
124
|
-
example:
|
|
125
|
-
title:
|
|
118
|
+
pattern: "^[a-zA-Z][a-zA-Z\\d+-.]*:[^\\s]*$",
|
|
119
|
+
errorType: "uri",
|
|
120
|
+
example: "https://forklaunch.com",
|
|
121
|
+
title: "URI"
|
|
126
122
|
});
|
|
127
123
|
number = Type.Transform(
|
|
128
124
|
Type.Union(
|
|
129
125
|
[
|
|
130
126
|
Type.Number(),
|
|
131
|
-
Type.String({ pattern:
|
|
127
|
+
Type.String({ pattern: "^[0-9]+$" }),
|
|
132
128
|
Type.Boolean(),
|
|
133
129
|
Type.Null(),
|
|
134
130
|
Type.BigInt(),
|
|
135
131
|
Type.Date()
|
|
136
132
|
],
|
|
137
133
|
{
|
|
138
|
-
errorType:
|
|
134
|
+
errorType: "number-like",
|
|
139
135
|
example: 123,
|
|
140
|
-
title:
|
|
136
|
+
title: "Number"
|
|
141
137
|
}
|
|
142
138
|
)
|
|
143
|
-
)
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
return num;
|
|
151
|
-
}
|
|
139
|
+
).Decode((value) => {
|
|
140
|
+
if (typeof value !== "number") {
|
|
141
|
+
const num = Number(value);
|
|
142
|
+
if (isNaN(num)) {
|
|
143
|
+
throw new Error("Invalid number");
|
|
144
|
+
} else {
|
|
145
|
+
return num;
|
|
152
146
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
147
|
+
}
|
|
148
|
+
return value;
|
|
149
|
+
}).Encode(Number);
|
|
156
150
|
bigint = Type.Transform(
|
|
157
151
|
Type.Union(
|
|
158
152
|
[
|
|
159
153
|
Type.BigInt(),
|
|
160
154
|
Type.Number(),
|
|
161
|
-
Type.String({ pattern:
|
|
155
|
+
Type.String({ pattern: "^[0-9]+n?$" }),
|
|
162
156
|
Type.Boolean(),
|
|
163
157
|
Type.Date()
|
|
164
158
|
],
|
|
165
159
|
{
|
|
166
|
-
errorType:
|
|
160
|
+
errorType: "BigInt-like",
|
|
167
161
|
example: 123n,
|
|
168
|
-
title:
|
|
162
|
+
title: "BigInt"
|
|
169
163
|
}
|
|
170
164
|
)
|
|
171
|
-
)
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
return BigInt(value.getTime());
|
|
177
|
-
}
|
|
178
|
-
return BigInt(value);
|
|
179
|
-
} catch {
|
|
180
|
-
throw new Error('Invalid bigint');
|
|
165
|
+
).Decode((value) => {
|
|
166
|
+
if (typeof value !== "bigint") {
|
|
167
|
+
try {
|
|
168
|
+
if (value instanceof Date) {
|
|
169
|
+
return BigInt(value.getTime());
|
|
181
170
|
}
|
|
171
|
+
return BigInt(value);
|
|
172
|
+
} catch {
|
|
173
|
+
throw new Error("Invalid bigint");
|
|
182
174
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
175
|
+
}
|
|
176
|
+
return value;
|
|
177
|
+
}).Encode(BigInt);
|
|
186
178
|
boolean = Type.Transform(
|
|
187
179
|
Type.Union(
|
|
188
180
|
[
|
|
189
181
|
Type.Boolean(),
|
|
190
182
|
Type.String({
|
|
191
|
-
pattern:
|
|
183
|
+
pattern: "^(t|T)(r|R)(u|U)(e|E)$|^(f|F)(a|A)(l|L)(s|S)(e|E)$"
|
|
192
184
|
})
|
|
193
185
|
],
|
|
194
186
|
{
|
|
195
|
-
errorType:
|
|
187
|
+
errorType: "boolean-like",
|
|
196
188
|
example: true,
|
|
197
|
-
title:
|
|
189
|
+
title: "Boolean"
|
|
198
190
|
}
|
|
199
191
|
)
|
|
200
|
-
)
|
|
201
|
-
|
|
202
|
-
if (
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
})
|
|
209
|
-
.Encode(Boolean);
|
|
192
|
+
).Decode((value) => {
|
|
193
|
+
if (typeof value === "string") {
|
|
194
|
+
if (value.toLowerCase() === "true") return true;
|
|
195
|
+
return false;
|
|
196
|
+
} else {
|
|
197
|
+
return value;
|
|
198
|
+
}
|
|
199
|
+
}).Encode(Boolean);
|
|
210
200
|
date = Type.Transform(
|
|
211
201
|
Type.Union(
|
|
212
202
|
[
|
|
213
203
|
Type.String({
|
|
214
|
-
pattern:
|
|
215
|
-
'^\\d{4}(-\\d{2}){0,2}(T\\d{2}:\\d{2}(:\\d{2}(\\.\\d{1,3})?)?(Z|([+-]\\d{2}:\\d{2}))?)?$|^\\d{1,2}\\/\\d{1,2}\\/\\d{4}$|^\\d{4}\\/\\d{1,2}\\/\\d{1,2}$|^\\d+$'
|
|
204
|
+
pattern: "^\\d{4}(-\\d{2}){0,2}(T\\d{2}:\\d{2}(:\\d{2}(\\.\\d{1,3})?)?(Z|([+-]\\d{2}:\\d{2}))?)?$|^\\d{1,2}\\/\\d{1,2}\\/\\d{4}$|^\\d{4}\\/\\d{1,2}\\/\\d{1,2}$|^\\d+$"
|
|
216
205
|
}),
|
|
217
206
|
Type.Number(),
|
|
218
207
|
Type.Date()
|
|
219
208
|
],
|
|
220
209
|
{
|
|
221
|
-
errorType:
|
|
222
|
-
example:
|
|
223
|
-
title:
|
|
210
|
+
errorType: "date",
|
|
211
|
+
example: "2025-05-16T21:13:04.123Z",
|
|
212
|
+
title: "Date"
|
|
224
213
|
}
|
|
225
214
|
)
|
|
226
|
-
)
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
})
|
|
233
|
-
.Encode((value) => new Date(value).toISOString());
|
|
215
|
+
).Decode((value) => {
|
|
216
|
+
if (value === null || typeof value === "boolean") {
|
|
217
|
+
return /* @__PURE__ */ new Date(value ? 1 : 0);
|
|
218
|
+
}
|
|
219
|
+
return new Date(value);
|
|
220
|
+
}).Encode((value) => new Date(value).toISOString());
|
|
234
221
|
symbol = Type.Symbol({
|
|
235
|
-
title:
|
|
236
|
-
});
|
|
237
|
-
nullish = Type.Union([Type.Void(), Type.Null(), Type.Undefined()], {
|
|
238
|
-
errorType: 'nullish',
|
|
239
|
-
type: 'null',
|
|
240
|
-
example: 'null',
|
|
241
|
-
title: 'Nullish'
|
|
222
|
+
title: "Symbol"
|
|
242
223
|
});
|
|
224
|
+
nullish = Type.Union(
|
|
225
|
+
[Type.Void(), Type.Null(), Type.Undefined()],
|
|
226
|
+
{
|
|
227
|
+
errorType: "nullish",
|
|
228
|
+
type: "null",
|
|
229
|
+
example: "null",
|
|
230
|
+
title: "Nullish"
|
|
231
|
+
}
|
|
232
|
+
);
|
|
243
233
|
void = Type.Void({
|
|
244
|
-
type:
|
|
245
|
-
example:
|
|
246
|
-
title:
|
|
234
|
+
type: "null",
|
|
235
|
+
example: "void",
|
|
236
|
+
title: "Void"
|
|
247
237
|
});
|
|
248
238
|
null = Type.Null({
|
|
249
|
-
type:
|
|
250
|
-
example:
|
|
251
|
-
title:
|
|
239
|
+
type: "null",
|
|
240
|
+
example: "null",
|
|
241
|
+
title: "Null"
|
|
252
242
|
});
|
|
253
243
|
undefined = Type.Undefined({
|
|
254
|
-
type:
|
|
255
|
-
example:
|
|
256
|
-
title:
|
|
244
|
+
type: "null",
|
|
245
|
+
example: "undefined",
|
|
246
|
+
title: "Undefined"
|
|
257
247
|
});
|
|
258
248
|
any = Type.Any({
|
|
259
|
-
type:
|
|
260
|
-
example:
|
|
261
|
-
title:
|
|
249
|
+
type: "object",
|
|
250
|
+
example: "any",
|
|
251
|
+
title: "Any"
|
|
262
252
|
});
|
|
263
253
|
unknown = Type.Unknown({
|
|
264
|
-
type:
|
|
265
|
-
example:
|
|
266
|
-
title:
|
|
254
|
+
type: "object",
|
|
255
|
+
example: "unknown",
|
|
256
|
+
title: "Unknown"
|
|
267
257
|
});
|
|
268
258
|
never = Type.Never({
|
|
269
|
-
type:
|
|
270
|
-
example:
|
|
271
|
-
title:
|
|
259
|
+
type: "null",
|
|
260
|
+
example: "never",
|
|
261
|
+
title: "Never"
|
|
272
262
|
});
|
|
273
263
|
binary = Type.Transform(
|
|
274
264
|
Type.String({
|
|
275
|
-
errorType:
|
|
276
|
-
format:
|
|
277
|
-
example:
|
|
278
|
-
title:
|
|
265
|
+
errorType: "binary",
|
|
266
|
+
format: "binary",
|
|
267
|
+
example: "a base-64 encodable string",
|
|
268
|
+
title: "Binary"
|
|
279
269
|
})
|
|
280
|
-
)
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
return '';
|
|
287
|
-
});
|
|
270
|
+
).Decode((value) => new Uint8Array(Buffer.from(value, "base64"))).Encode((value) => {
|
|
271
|
+
if (value instanceof Buffer) {
|
|
272
|
+
return String.fromCharCode(...new Uint8Array(value));
|
|
273
|
+
}
|
|
274
|
+
return "";
|
|
275
|
+
});
|
|
288
276
|
file = Type.Transform(
|
|
289
277
|
Type.Unsafe({
|
|
290
|
-
errorType:
|
|
291
|
-
format:
|
|
292
|
-
example:
|
|
293
|
-
title:
|
|
278
|
+
errorType: "binary",
|
|
279
|
+
format: "binary",
|
|
280
|
+
example: "a raw buffer or file stream",
|
|
281
|
+
title: "File"
|
|
294
282
|
})
|
|
295
|
-
)
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
})
|
|
299
|
-
.Encode((value) => value.content);
|
|
283
|
+
).Decode((value) => {
|
|
284
|
+
return new InMemoryBlob(value);
|
|
285
|
+
}).Encode((value) => value.content);
|
|
300
286
|
type = () => this.any;
|
|
301
287
|
/**
|
|
302
288
|
* Extracts the error type of a schema for error messages.
|
|
@@ -305,7 +291,7 @@ var TypeboxSchemaValidator = class {
|
|
|
305
291
|
* @returns The type of the schema for error messages.
|
|
306
292
|
*/
|
|
307
293
|
errorType(schema) {
|
|
308
|
-
if (KindGuard.IsSchema(schema) && Object.hasOwn(schema,
|
|
294
|
+
if (KindGuard.IsSchema(schema) && Object.hasOwn(schema, "errorType")) {
|
|
309
295
|
return schema.errorType;
|
|
310
296
|
} else if (KindGuard.IsLiteral(schema)) {
|
|
311
297
|
return schema.const;
|
|
@@ -327,11 +313,7 @@ var TypeboxSchemaValidator = class {
|
|
|
327
313
|
* @returns {TResolve<T>} The resolved schema.
|
|
328
314
|
*/
|
|
329
315
|
schemify(schema) {
|
|
330
|
-
if (
|
|
331
|
-
typeof schema === 'string' ||
|
|
332
|
-
typeof schema === 'number' ||
|
|
333
|
-
typeof schema === 'boolean'
|
|
334
|
-
) {
|
|
316
|
+
if (typeof schema === "string" || typeof schema === "number" || typeof schema === "boolean") {
|
|
335
317
|
return Type.Literal(schema);
|
|
336
318
|
}
|
|
337
319
|
if (KindGuard.IsSchema(schema) || schema instanceof TypeCheck) {
|
|
@@ -381,7 +363,7 @@ var TypeboxSchemaValidator = class {
|
|
|
381
363
|
return this.schemify(schema);
|
|
382
364
|
});
|
|
383
365
|
return Type.Union(unionTypes, {
|
|
384
|
-
errorType: `any of ${unionTypes.map((s) => this.errorType(s)).join(
|
|
366
|
+
errorType: `any of ${unionTypes.map((s) => this.errorType(s)).join(", ")}`,
|
|
385
367
|
errorSuffix: true
|
|
386
368
|
});
|
|
387
369
|
}
|
|
@@ -452,12 +434,7 @@ var TypeboxSchemaValidator = class {
|
|
|
452
434
|
* @returns {boolean} True if the value is an instance of the schema.
|
|
453
435
|
*/
|
|
454
436
|
isInstanceOf(value, type22) {
|
|
455
|
-
return
|
|
456
|
-
typeof value === 'object' &&
|
|
457
|
-
value != null &&
|
|
458
|
-
Kind in value &&
|
|
459
|
-
value[Kind] === type22[Kind]
|
|
460
|
-
);
|
|
437
|
+
return typeof value === "object" && value != null && Kind in value && value[Kind] === type22[Kind];
|
|
461
438
|
}
|
|
462
439
|
/**
|
|
463
440
|
* Validate a value against a schema.
|
|
@@ -492,7 +469,7 @@ var TypeboxSchemaValidator = class {
|
|
|
492
469
|
}
|
|
493
470
|
} else {
|
|
494
471
|
const schemified = this.schemify(schema);
|
|
495
|
-
if (schemified[Kind] ===
|
|
472
|
+
if (schemified[Kind] === "Unsafe") {
|
|
496
473
|
try {
|
|
497
474
|
if (value instanceof Buffer) {
|
|
498
475
|
conversion = new InMemoryBlob(value);
|
|
@@ -501,7 +478,7 @@ var TypeboxSchemaValidator = class {
|
|
|
501
478
|
{
|
|
502
479
|
type: ValueErrorType.String,
|
|
503
480
|
schema: schemified,
|
|
504
|
-
path:
|
|
481
|
+
path: "",
|
|
505
482
|
message: `Invalid file type: expected Buffer or string, got ${typeof value}`,
|
|
506
483
|
value,
|
|
507
484
|
errors: []
|
|
@@ -513,8 +490,8 @@ var TypeboxSchemaValidator = class {
|
|
|
513
490
|
{
|
|
514
491
|
type: ValueErrorType.String,
|
|
515
492
|
schema: schemified,
|
|
516
|
-
path:
|
|
517
|
-
message: err instanceof Error ? err.message :
|
|
493
|
+
path: "",
|
|
494
|
+
message: err instanceof Error ? err.message : "Invalid file type",
|
|
518
495
|
value,
|
|
519
496
|
errors: []
|
|
520
497
|
}
|
|
@@ -528,38 +505,33 @@ var TypeboxSchemaValidator = class {
|
|
|
528
505
|
}
|
|
529
506
|
}
|
|
530
507
|
}
|
|
531
|
-
return errors != null && errors.length === 0
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
: {
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
} else {
|
|
554
|
-
return [
|
|
555
|
-
{
|
|
556
|
-
path: error.path.split('/').slice(1),
|
|
557
|
-
message: error.message
|
|
558
|
-
}
|
|
559
|
-
];
|
|
508
|
+
return errors != null && errors.length === 0 ? {
|
|
509
|
+
ok: true,
|
|
510
|
+
value: conversion
|
|
511
|
+
} : {
|
|
512
|
+
ok: false,
|
|
513
|
+
errors: errors.flatMap((error) => {
|
|
514
|
+
if (error.type === ValueErrorType.Union && error.schema.errorType.includes("any of")) {
|
|
515
|
+
return error.errors.flatMap(
|
|
516
|
+
(e, idx) => Array.from(e).map((e2) => ({
|
|
517
|
+
path: [
|
|
518
|
+
`Union Schema Variant ${idx}`,
|
|
519
|
+
...error.path.split("/").slice(1),
|
|
520
|
+
...e2.path.split("/").slice(1)
|
|
521
|
+
],
|
|
522
|
+
message: e2.message
|
|
523
|
+
}))
|
|
524
|
+
);
|
|
525
|
+
} else {
|
|
526
|
+
return [
|
|
527
|
+
{
|
|
528
|
+
path: error.path.split("/").slice(1),
|
|
529
|
+
message: error.message
|
|
560
530
|
}
|
|
561
|
-
|
|
562
|
-
}
|
|
531
|
+
];
|
|
532
|
+
}
|
|
533
|
+
})
|
|
534
|
+
};
|
|
563
535
|
}
|
|
564
536
|
/**
|
|
565
537
|
* Convert a schema to an OpenAPI schema object.
|
|
@@ -570,11 +542,11 @@ var TypeboxSchemaValidator = class {
|
|
|
570
542
|
let schemified = this.schemify(schema);
|
|
571
543
|
if (KindGuard.IsDate(schemified)) {
|
|
572
544
|
schemified = Type.String({
|
|
573
|
-
format:
|
|
545
|
+
format: "date-time"
|
|
574
546
|
});
|
|
575
547
|
}
|
|
576
548
|
const newSchema = Object.assign({}, schemified);
|
|
577
|
-
if (Object.hasOwn(newSchema,
|
|
549
|
+
if (Object.hasOwn(newSchema, "properties")) {
|
|
578
550
|
if (newSchema.properties) {
|
|
579
551
|
Object.entries({ ...schemified.properties }).forEach(([key, value]) => {
|
|
580
552
|
if (KindGuard.IsSchema(value) && newSchema.properties) {
|
|
@@ -583,17 +555,21 @@ var TypeboxSchemaValidator = class {
|
|
|
583
555
|
});
|
|
584
556
|
}
|
|
585
557
|
}
|
|
586
|
-
if (Object.hasOwn(newSchema,
|
|
558
|
+
if (Object.hasOwn(newSchema, "items")) {
|
|
587
559
|
newSchema.items = this.openapi(newSchema.items);
|
|
588
560
|
}
|
|
589
561
|
if (Array.isArray(newSchema.anyOf)) {
|
|
590
|
-
newSchema.anyOf = newSchema.anyOf.map(
|
|
562
|
+
newSchema.anyOf = newSchema.anyOf.map(
|
|
563
|
+
(item) => this.openapi(item)
|
|
564
|
+
);
|
|
591
565
|
}
|
|
592
566
|
if (Array.isArray(newSchema.oneOf)) {
|
|
593
|
-
newSchema.oneOf = newSchema.oneOf.map(
|
|
567
|
+
newSchema.oneOf = newSchema.oneOf.map(
|
|
568
|
+
(item) => this.openapi(item)
|
|
569
|
+
);
|
|
594
570
|
}
|
|
595
|
-
if (
|
|
596
|
-
delete newSchema[
|
|
571
|
+
if ("errorType" in newSchema) {
|
|
572
|
+
delete newSchema["errorType"];
|
|
597
573
|
}
|
|
598
574
|
return newSchema;
|
|
599
575
|
}
|
|
@@ -636,60 +612,51 @@ var openapi = StaticSchemaValidator.openapi.bind(StaticSchemaValidator);
|
|
|
636
612
|
// domain/schemas/typebox/bullMqWorker.schema.ts
|
|
637
613
|
var BullMqWorkerOptionsSchema = {
|
|
638
614
|
queueOptions: type(),
|
|
639
|
-
backoffType: union([literal(
|
|
615
|
+
backoffType: union([literal("exponential"), literal("fixed")]),
|
|
640
616
|
retries: number,
|
|
641
617
|
interval: number
|
|
642
618
|
};
|
|
643
619
|
|
|
644
|
-
// ../../../node_modules/.pnpm/@forklaunch+validator@0.10.
|
|
645
|
-
import {
|
|
620
|
+
// ../../../node_modules/.pnpm/@forklaunch+validator@0.10.5/node_modules/@forklaunch/validator/lib/src/zod/index.mjs
|
|
621
|
+
import {
|
|
622
|
+
z as z2,
|
|
623
|
+
ZodType
|
|
624
|
+
} from "zod/v3";
|
|
646
625
|
|
|
647
626
|
// ../../../node_modules/.pnpm/ts-deepmerge@7.0.3/node_modules/ts-deepmerge/esm/index.js
|
|
648
627
|
var isObject = (obj) => {
|
|
649
|
-
if (typeof obj ===
|
|
650
|
-
if (typeof Object.getPrototypeOf ===
|
|
628
|
+
if (typeof obj === "object" && obj !== null) {
|
|
629
|
+
if (typeof Object.getPrototypeOf === "function") {
|
|
651
630
|
const prototype = Object.getPrototypeOf(obj);
|
|
652
631
|
return prototype === Object.prototype || prototype === null;
|
|
653
632
|
}
|
|
654
|
-
return Object.prototype.toString.call(obj) ===
|
|
633
|
+
return Object.prototype.toString.call(obj) === "[object Object]";
|
|
655
634
|
}
|
|
656
635
|
return false;
|
|
657
636
|
};
|
|
658
|
-
var merge = (...objects) =>
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
637
|
+
var merge = (...objects) => objects.reduce((result, current) => {
|
|
638
|
+
if (current === void 0) {
|
|
639
|
+
return result;
|
|
640
|
+
}
|
|
641
|
+
if (Array.isArray(current)) {
|
|
642
|
+
throw new TypeError("Arguments provided to ts-deepmerge must be objects, not arrays.");
|
|
643
|
+
}
|
|
644
|
+
Object.keys(current).forEach((key) => {
|
|
645
|
+
if (["__proto__", "constructor", "prototype"].includes(key)) {
|
|
646
|
+
return;
|
|
662
647
|
}
|
|
663
|
-
if (Array.isArray(current)) {
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
);
|
|
648
|
+
if (Array.isArray(result[key]) && Array.isArray(current[key])) {
|
|
649
|
+
result[key] = merge.options.mergeArrays ? merge.options.uniqueArrayItems ? Array.from(new Set(result[key].concat(current[key]))) : [...result[key], ...current[key]] : current[key];
|
|
650
|
+
} else if (isObject(result[key]) && isObject(current[key])) {
|
|
651
|
+
result[key] = merge(result[key], current[key]);
|
|
652
|
+
} else if (!isObject(result[key]) && isObject(current[key])) {
|
|
653
|
+
result[key] = merge(current[key], void 0);
|
|
654
|
+
} else {
|
|
655
|
+
result[key] = current[key] === void 0 ? merge.options.allowUndefinedOverrides ? current[key] : result[key] : current[key];
|
|
667
656
|
}
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
}
|
|
672
|
-
if (Array.isArray(result[key]) && Array.isArray(current[key])) {
|
|
673
|
-
result[key] = merge.options.mergeArrays
|
|
674
|
-
? merge.options.uniqueArrayItems
|
|
675
|
-
? Array.from(new Set(result[key].concat(current[key])))
|
|
676
|
-
: [...result[key], ...current[key]]
|
|
677
|
-
: current[key];
|
|
678
|
-
} else if (isObject(result[key]) && isObject(current[key])) {
|
|
679
|
-
result[key] = merge(result[key], current[key]);
|
|
680
|
-
} else if (!isObject(result[key]) && isObject(current[key])) {
|
|
681
|
-
result[key] = merge(current[key], void 0);
|
|
682
|
-
} else {
|
|
683
|
-
result[key] =
|
|
684
|
-
current[key] === void 0
|
|
685
|
-
? merge.options.allowUndefinedOverrides
|
|
686
|
-
? current[key]
|
|
687
|
-
: result[key]
|
|
688
|
-
: current[key];
|
|
689
|
-
}
|
|
690
|
-
});
|
|
691
|
-
return result;
|
|
692
|
-
}, {});
|
|
657
|
+
});
|
|
658
|
+
return result;
|
|
659
|
+
}, {});
|
|
693
660
|
var defaultOptions = {
|
|
694
661
|
allowUndefinedOverrides: true,
|
|
695
662
|
mergeArrays: true,
|
|
@@ -703,8 +670,8 @@ merge.withOptions = (options, ...objects) => {
|
|
|
703
670
|
return result;
|
|
704
671
|
};
|
|
705
672
|
|
|
706
|
-
// ../../../node_modules/.pnpm/@forklaunch+validator@0.10.
|
|
707
|
-
import { z } from
|
|
673
|
+
// ../../../node_modules/.pnpm/@forklaunch+validator@0.10.5/node_modules/@forklaunch/validator/lib/src/zod/index.mjs
|
|
674
|
+
import { z } from "zod/v3";
|
|
708
675
|
function extendApi(schema, schemaObject = {}) {
|
|
709
676
|
const This = schema.constructor;
|
|
710
677
|
const newSchema = new This(schema._def);
|
|
@@ -721,96 +688,89 @@ function iterateZodObject({
|
|
|
721
688
|
hideDefinitions,
|
|
722
689
|
openApiVersion
|
|
723
690
|
}) {
|
|
724
|
-
const reduced = Object.keys(zodRef.shape)
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
(
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
{}
|
|
732
|
-
);
|
|
691
|
+
const reduced = Object.keys(zodRef.shape).filter((key) => hideDefinitions?.includes(key) === false).reduce(
|
|
692
|
+
(carry, key) => ({
|
|
693
|
+
...carry,
|
|
694
|
+
[key]: generateSchema(zodRef.shape[key], useOutput, openApiVersion)
|
|
695
|
+
}),
|
|
696
|
+
{}
|
|
697
|
+
);
|
|
733
698
|
return reduced;
|
|
734
699
|
}
|
|
735
700
|
function typeFormat(type22, openApiVersion) {
|
|
736
|
-
return openApiVersion ===
|
|
701
|
+
return openApiVersion === "3.0" ? type22 : [type22];
|
|
737
702
|
}
|
|
738
|
-
function parseTransformation({
|
|
703
|
+
function parseTransformation({
|
|
704
|
+
zodRef,
|
|
705
|
+
schemas,
|
|
706
|
+
useOutput,
|
|
707
|
+
openApiVersion
|
|
708
|
+
}) {
|
|
739
709
|
const input = generateSchema(zodRef._def.schema, useOutput, openApiVersion);
|
|
740
|
-
let output =
|
|
710
|
+
let output = "undefined";
|
|
741
711
|
if (useOutput && zodRef._def.effect) {
|
|
742
|
-
const effect =
|
|
743
|
-
|
|
744
|
-
if (effect && 'transform' in effect) {
|
|
712
|
+
const effect = zodRef._def.effect.type === "transform" ? zodRef._def.effect : null;
|
|
713
|
+
if (effect && "transform" in effect) {
|
|
745
714
|
try {
|
|
746
715
|
const type22 = Array.isArray(input.type) ? input.type[0] : input.type;
|
|
747
716
|
output = typeof effect.transform(
|
|
748
|
-
[
|
|
749
|
-
? 0
|
|
750
|
-
: 'string' === type22
|
|
751
|
-
? ''
|
|
752
|
-
: 'boolean' === type22
|
|
753
|
-
? false
|
|
754
|
-
: 'object' === type22
|
|
755
|
-
? {}
|
|
756
|
-
: 'null' === type22
|
|
757
|
-
? null
|
|
758
|
-
: 'array' === type22
|
|
759
|
-
? []
|
|
760
|
-
: void 0,
|
|
717
|
+
["integer", "number"].includes(`${type22}`) ? 0 : "string" === type22 ? "" : "boolean" === type22 ? false : "object" === type22 ? {} : "null" === type22 ? null : "array" === type22 ? [] : void 0,
|
|
761
718
|
{ addIssue: () => void 0, path: [] }
|
|
762
719
|
// TODO: Discover if context is necessary here
|
|
763
720
|
);
|
|
764
|
-
} catch {
|
|
721
|
+
} catch {
|
|
722
|
+
}
|
|
765
723
|
}
|
|
766
724
|
}
|
|
767
725
|
const outputType = output;
|
|
768
726
|
return merge(
|
|
769
727
|
{
|
|
770
|
-
...
|
|
728
|
+
...zodRef.description ? { description: zodRef.description } : {},
|
|
771
729
|
...input,
|
|
772
|
-
...
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
}
|
|
776
|
-
: {})
|
|
730
|
+
...["number", "string", "boolean", "null"].includes(output) ? {
|
|
731
|
+
type: typeFormat(outputType, openApiVersion)
|
|
732
|
+
} : {}
|
|
777
733
|
},
|
|
778
734
|
...schemas
|
|
779
735
|
);
|
|
780
736
|
}
|
|
781
|
-
function parseString({
|
|
737
|
+
function parseString({
|
|
738
|
+
zodRef,
|
|
739
|
+
schemas,
|
|
740
|
+
openApiVersion
|
|
741
|
+
}) {
|
|
782
742
|
const baseSchema = {
|
|
783
|
-
type: typeFormat(
|
|
743
|
+
type: typeFormat("string", openApiVersion)
|
|
784
744
|
};
|
|
785
745
|
const { checks = [] } = zodRef._def;
|
|
786
746
|
checks.forEach((item) => {
|
|
787
747
|
switch (item.kind) {
|
|
788
|
-
case
|
|
789
|
-
baseSchema.format =
|
|
748
|
+
case "email":
|
|
749
|
+
baseSchema.format = "email";
|
|
790
750
|
break;
|
|
791
|
-
case
|
|
792
|
-
baseSchema.format =
|
|
751
|
+
case "uuid":
|
|
752
|
+
baseSchema.format = "uuid";
|
|
793
753
|
break;
|
|
794
|
-
case
|
|
795
|
-
baseSchema.format =
|
|
754
|
+
case "cuid":
|
|
755
|
+
baseSchema.format = "cuid";
|
|
796
756
|
break;
|
|
797
|
-
case
|
|
798
|
-
baseSchema.format =
|
|
757
|
+
case "url":
|
|
758
|
+
baseSchema.format = "uri";
|
|
799
759
|
break;
|
|
800
|
-
case
|
|
801
|
-
baseSchema.format =
|
|
760
|
+
case "datetime":
|
|
761
|
+
baseSchema.format = "date-time";
|
|
802
762
|
break;
|
|
803
|
-
case
|
|
763
|
+
case "length":
|
|
804
764
|
baseSchema.minLength = item.value;
|
|
805
765
|
baseSchema.maxLength = item.value;
|
|
806
766
|
break;
|
|
807
|
-
case
|
|
767
|
+
case "max":
|
|
808
768
|
baseSchema.maxLength = item.value;
|
|
809
769
|
break;
|
|
810
|
-
case
|
|
770
|
+
case "min":
|
|
811
771
|
baseSchema.minLength = item.value;
|
|
812
772
|
break;
|
|
813
|
-
case
|
|
773
|
+
case "regex":
|
|
814
774
|
baseSchema.pattern = item.regex.source;
|
|
815
775
|
break;
|
|
816
776
|
}
|
|
@@ -821,41 +781,45 @@ function parseString({ zodRef, schemas, openApiVersion }) {
|
|
|
821
781
|
...schemas
|
|
822
782
|
);
|
|
823
783
|
}
|
|
824
|
-
function parseNumber({
|
|
784
|
+
function parseNumber({
|
|
785
|
+
zodRef,
|
|
786
|
+
schemas,
|
|
787
|
+
openApiVersion
|
|
788
|
+
}) {
|
|
825
789
|
const baseSchema = {
|
|
826
|
-
type: typeFormat(
|
|
790
|
+
type: typeFormat("number", openApiVersion)
|
|
827
791
|
};
|
|
828
792
|
const { checks = [] } = zodRef._def;
|
|
829
793
|
checks.forEach((item) => {
|
|
830
794
|
switch (item.kind) {
|
|
831
|
-
case
|
|
832
|
-
if (item.inclusive || openApiVersion ===
|
|
795
|
+
case "max":
|
|
796
|
+
if (item.inclusive || openApiVersion === "3.0") {
|
|
833
797
|
baseSchema.maximum = item.value;
|
|
834
798
|
}
|
|
835
799
|
if (!item.inclusive) {
|
|
836
|
-
if (openApiVersion ===
|
|
800
|
+
if (openApiVersion === "3.0") {
|
|
837
801
|
baseSchema.exclusiveMaximum = true;
|
|
838
802
|
} else {
|
|
839
803
|
baseSchema.exclusiveMaximum = item.value;
|
|
840
804
|
}
|
|
841
805
|
}
|
|
842
806
|
break;
|
|
843
|
-
case
|
|
844
|
-
if (item.inclusive || openApiVersion ===
|
|
807
|
+
case "min":
|
|
808
|
+
if (item.inclusive || openApiVersion === "3.0") {
|
|
845
809
|
baseSchema.minimum = item.value;
|
|
846
810
|
}
|
|
847
811
|
if (!item.inclusive) {
|
|
848
|
-
if (openApiVersion ===
|
|
812
|
+
if (openApiVersion === "3.0") {
|
|
849
813
|
baseSchema.exclusiveMinimum = true;
|
|
850
814
|
} else {
|
|
851
815
|
baseSchema.exclusiveMinimum = item.value;
|
|
852
816
|
}
|
|
853
817
|
}
|
|
854
818
|
break;
|
|
855
|
-
case
|
|
856
|
-
baseSchema.type = typeFormat(
|
|
819
|
+
case "int":
|
|
820
|
+
baseSchema.type = typeFormat("integer", openApiVersion);
|
|
857
821
|
break;
|
|
858
|
-
case
|
|
822
|
+
case "multipleOf":
|
|
859
823
|
baseSchema.multipleOf = item.value;
|
|
860
824
|
break;
|
|
861
825
|
}
|
|
@@ -883,37 +847,26 @@ function parseObject({
|
|
|
883
847
|
openApiVersion
|
|
884
848
|
}) {
|
|
885
849
|
let additionalProperties;
|
|
886
|
-
if (
|
|
887
|
-
!(
|
|
888
|
-
zodRef._def.catchall instanceof z.ZodNever ||
|
|
889
|
-
zodRef._def.catchall?._def.typeName === 'ZodNever'
|
|
890
|
-
)
|
|
891
|
-
)
|
|
850
|
+
if (!(zodRef._def.catchall instanceof z.ZodNever || zodRef._def.catchall?._def.typeName === "ZodNever"))
|
|
892
851
|
additionalProperties = generateSchema(
|
|
893
852
|
zodRef._def.catchall,
|
|
894
853
|
useOutput,
|
|
895
854
|
openApiVersion
|
|
896
855
|
);
|
|
897
|
-
else if (zodRef._def.unknownKeys ===
|
|
856
|
+
else if (zodRef._def.unknownKeys === "passthrough")
|
|
898
857
|
additionalProperties = true;
|
|
899
|
-
else if (zodRef._def.unknownKeys ===
|
|
900
|
-
additionalProperties =
|
|
901
|
-
|
|
902
|
-
|
|
858
|
+
else if (zodRef._def.unknownKeys === "strict") additionalProperties = false;
|
|
859
|
+
additionalProperties = additionalProperties != null ? { additionalProperties } : {};
|
|
860
|
+
const requiredProperties = Object.keys(
|
|
861
|
+
zodRef.shape
|
|
862
|
+
).filter((key) => {
|
|
903
863
|
const item = zodRef.shape[key];
|
|
904
|
-
return (
|
|
905
|
-
!(
|
|
906
|
-
item.isOptional() ||
|
|
907
|
-
item instanceof z.ZodDefault ||
|
|
908
|
-
item._def.typeName === 'ZodDefault'
|
|
909
|
-
) && !(item instanceof z.ZodNever || item._def.typeName === 'ZodDefault')
|
|
910
|
-
);
|
|
864
|
+
return !(item.isOptional() || item instanceof z.ZodDefault || item._def.typeName === "ZodDefault") && !(item instanceof z.ZodNever || item._def.typeName === "ZodDefault");
|
|
911
865
|
});
|
|
912
|
-
const required =
|
|
913
|
-
requiredProperties.length > 0 ? { required: requiredProperties } : {};
|
|
866
|
+
const required = requiredProperties.length > 0 ? { required: requiredProperties } : {};
|
|
914
867
|
return merge(
|
|
915
868
|
{
|
|
916
|
-
type: typeFormat(
|
|
869
|
+
type: typeFormat("object", openApiVersion),
|
|
917
870
|
properties: iterateZodObject({
|
|
918
871
|
zodRef,
|
|
919
872
|
schemas,
|
|
@@ -925,83 +878,110 @@ function parseObject({
|
|
|
925
878
|
...additionalProperties,
|
|
926
879
|
...hideDefinitions
|
|
927
880
|
},
|
|
928
|
-
zodRef.description
|
|
929
|
-
? { description: zodRef.description, hideDefinitions }
|
|
930
|
-
: {},
|
|
881
|
+
zodRef.description ? { description: zodRef.description, hideDefinitions } : {},
|
|
931
882
|
...schemas
|
|
932
883
|
);
|
|
933
884
|
}
|
|
934
|
-
function parseRecord({
|
|
885
|
+
function parseRecord({
|
|
886
|
+
zodRef,
|
|
887
|
+
schemas,
|
|
888
|
+
useOutput,
|
|
889
|
+
openApiVersion
|
|
890
|
+
}) {
|
|
935
891
|
return merge(
|
|
936
892
|
{
|
|
937
|
-
type: typeFormat(
|
|
938
|
-
additionalProperties:
|
|
939
|
-
zodRef._def.valueType instanceof z.ZodUnknown
|
|
940
|
-
? {}
|
|
941
|
-
: generateSchema(zodRef._def.valueType, useOutput, openApiVersion)
|
|
893
|
+
type: typeFormat("object", openApiVersion),
|
|
894
|
+
additionalProperties: zodRef._def.valueType instanceof z.ZodUnknown ? {} : generateSchema(zodRef._def.valueType, useOutput, openApiVersion)
|
|
942
895
|
},
|
|
943
896
|
zodRef.description ? { description: zodRef.description } : {},
|
|
944
897
|
...schemas
|
|
945
898
|
);
|
|
946
899
|
}
|
|
947
|
-
function parseBigInt({
|
|
900
|
+
function parseBigInt({
|
|
901
|
+
zodRef,
|
|
902
|
+
schemas,
|
|
903
|
+
openApiVersion
|
|
904
|
+
}) {
|
|
948
905
|
return merge(
|
|
949
906
|
{
|
|
950
|
-
type: typeFormat(
|
|
951
|
-
format:
|
|
907
|
+
type: typeFormat("integer", openApiVersion),
|
|
908
|
+
format: "int64"
|
|
952
909
|
},
|
|
953
910
|
zodRef.description ? { description: zodRef.description } : {},
|
|
954
911
|
...schemas
|
|
955
912
|
);
|
|
956
913
|
}
|
|
957
|
-
function parseBoolean({
|
|
914
|
+
function parseBoolean({
|
|
915
|
+
zodRef,
|
|
916
|
+
schemas,
|
|
917
|
+
openApiVersion
|
|
918
|
+
}) {
|
|
958
919
|
return merge(
|
|
959
|
-
{ type: typeFormat(
|
|
920
|
+
{ type: typeFormat("boolean", openApiVersion) },
|
|
960
921
|
zodRef.description ? { description: zodRef.description } : {},
|
|
961
922
|
...schemas
|
|
962
923
|
);
|
|
963
924
|
}
|
|
964
|
-
function parseDate({
|
|
925
|
+
function parseDate({
|
|
926
|
+
zodRef,
|
|
927
|
+
schemas,
|
|
928
|
+
openApiVersion
|
|
929
|
+
}) {
|
|
965
930
|
return merge(
|
|
966
931
|
{
|
|
967
|
-
type: typeFormat(
|
|
968
|
-
format:
|
|
932
|
+
type: typeFormat("string", openApiVersion),
|
|
933
|
+
format: "date-time"
|
|
969
934
|
},
|
|
970
935
|
zodRef.description ? { description: zodRef.description } : {},
|
|
971
936
|
...schemas
|
|
972
937
|
);
|
|
973
938
|
}
|
|
974
|
-
function parseNull({
|
|
939
|
+
function parseNull({
|
|
940
|
+
zodRef,
|
|
941
|
+
schemas,
|
|
942
|
+
openApiVersion
|
|
943
|
+
}) {
|
|
975
944
|
return merge(
|
|
976
|
-
openApiVersion ===
|
|
977
|
-
|
|
978
|
-
:
|
|
979
|
-
|
|
980
|
-
enum: ['null']
|
|
981
|
-
},
|
|
945
|
+
openApiVersion === "3.0" ? { type: "null" } : {
|
|
946
|
+
type: ["string", "null"],
|
|
947
|
+
enum: ["null"]
|
|
948
|
+
},
|
|
982
949
|
zodRef.description ? { description: zodRef.description } : {},
|
|
983
950
|
...schemas
|
|
984
951
|
);
|
|
985
952
|
}
|
|
986
|
-
function parseOptional({
|
|
953
|
+
function parseOptional({
|
|
954
|
+
schemas,
|
|
955
|
+
zodRef,
|
|
956
|
+
useOutput,
|
|
957
|
+
openApiVersion
|
|
958
|
+
}) {
|
|
987
959
|
return merge(
|
|
988
960
|
generateSchema(zodRef.unwrap(), useOutput, openApiVersion),
|
|
989
961
|
zodRef.description ? { description: zodRef.description } : {},
|
|
990
962
|
...schemas
|
|
991
963
|
);
|
|
992
964
|
}
|
|
993
|
-
function parseNullable({
|
|
965
|
+
function parseNullable({
|
|
966
|
+
schemas,
|
|
967
|
+
zodRef,
|
|
968
|
+
useOutput,
|
|
969
|
+
openApiVersion
|
|
970
|
+
}) {
|
|
994
971
|
const schema = generateSchema(zodRef.unwrap(), useOutput, openApiVersion);
|
|
995
972
|
return merge(
|
|
996
973
|
schema,
|
|
997
|
-
openApiVersion ===
|
|
998
|
-
? { nullable: true }
|
|
999
|
-
: { type: typeFormat('null', openApiVersion) },
|
|
974
|
+
openApiVersion === "3.0" ? { nullable: true } : { type: typeFormat("null", openApiVersion) },
|
|
1000
975
|
zodRef.description ? { description: zodRef.description } : {},
|
|
1001
976
|
...schemas
|
|
1002
977
|
);
|
|
1003
978
|
}
|
|
1004
|
-
function parseDefault({
|
|
979
|
+
function parseDefault({
|
|
980
|
+
schemas,
|
|
981
|
+
zodRef,
|
|
982
|
+
useOutput,
|
|
983
|
+
openApiVersion
|
|
984
|
+
}) {
|
|
1005
985
|
return merge(
|
|
1006
986
|
{
|
|
1007
987
|
default: zodRef._def.defaultValue(),
|
|
@@ -1011,7 +991,12 @@ function parseDefault({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
|
1011
991
|
...schemas
|
|
1012
992
|
);
|
|
1013
993
|
}
|
|
1014
|
-
function parseArray({
|
|
994
|
+
function parseArray({
|
|
995
|
+
schemas,
|
|
996
|
+
zodRef,
|
|
997
|
+
useOutput,
|
|
998
|
+
openApiVersion
|
|
999
|
+
}) {
|
|
1015
1000
|
const constraints = {};
|
|
1016
1001
|
if (zodRef._def.exactLength != null) {
|
|
1017
1002
|
constraints.minItems = zodRef._def.exactLength.value;
|
|
@@ -1023,7 +1008,7 @@ function parseArray({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
|
1023
1008
|
constraints.maxItems = zodRef._def.maxLength.value;
|
|
1024
1009
|
return merge(
|
|
1025
1010
|
{
|
|
1026
|
-
type: typeFormat(
|
|
1011
|
+
type: typeFormat("array", openApiVersion),
|
|
1027
1012
|
items: generateSchema(zodRef.element, useOutput, openApiVersion),
|
|
1028
1013
|
...constraints
|
|
1029
1014
|
},
|
|
@@ -1031,7 +1016,11 @@ function parseArray({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
|
1031
1016
|
...schemas
|
|
1032
1017
|
);
|
|
1033
1018
|
}
|
|
1034
|
-
function parseLiteral({
|
|
1019
|
+
function parseLiteral({
|
|
1020
|
+
schemas,
|
|
1021
|
+
zodRef,
|
|
1022
|
+
openApiVersion
|
|
1023
|
+
}) {
|
|
1035
1024
|
const type22 = typeof zodRef._def.value;
|
|
1036
1025
|
return merge(
|
|
1037
1026
|
{
|
|
@@ -1042,7 +1031,11 @@ function parseLiteral({ schemas, zodRef, openApiVersion }) {
|
|
|
1042
1031
|
...schemas
|
|
1043
1032
|
);
|
|
1044
1033
|
}
|
|
1045
|
-
function parseEnum({
|
|
1034
|
+
function parseEnum({
|
|
1035
|
+
schemas,
|
|
1036
|
+
zodRef,
|
|
1037
|
+
openApiVersion
|
|
1038
|
+
}) {
|
|
1046
1039
|
const type22 = typeof Object.values(zodRef._def.values)[0];
|
|
1047
1040
|
return merge(
|
|
1048
1041
|
{
|
|
@@ -1053,7 +1046,12 @@ function parseEnum({ schemas, zodRef, openApiVersion }) {
|
|
|
1053
1046
|
...schemas
|
|
1054
1047
|
);
|
|
1055
1048
|
}
|
|
1056
|
-
function parseIntersection({
|
|
1049
|
+
function parseIntersection({
|
|
1050
|
+
schemas,
|
|
1051
|
+
zodRef,
|
|
1052
|
+
useOutput,
|
|
1053
|
+
openApiVersion
|
|
1054
|
+
}) {
|
|
1057
1055
|
return merge(
|
|
1058
1056
|
{
|
|
1059
1057
|
allOf: [
|
|
@@ -1065,20 +1063,20 @@ function parseIntersection({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
|
1065
1063
|
...schemas
|
|
1066
1064
|
);
|
|
1067
1065
|
}
|
|
1068
|
-
function parseUnion({
|
|
1066
|
+
function parseUnion({
|
|
1067
|
+
schemas,
|
|
1068
|
+
zodRef,
|
|
1069
|
+
useOutput,
|
|
1070
|
+
openApiVersion
|
|
1071
|
+
}) {
|
|
1069
1072
|
const contents = zodRef._def.options;
|
|
1070
|
-
if (
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
)
|
|
1075
|
-
) {
|
|
1073
|
+
if (contents.reduce(
|
|
1074
|
+
(prev, content) => prev && content._def.typeName === "ZodLiteral",
|
|
1075
|
+
true
|
|
1076
|
+
)) {
|
|
1076
1077
|
const literals = contents;
|
|
1077
1078
|
const type22 = literals.reduce(
|
|
1078
|
-
(prev, content) =>
|
|
1079
|
-
!prev || prev === typeof content._def.value
|
|
1080
|
-
? typeof content._def.value
|
|
1081
|
-
: null,
|
|
1079
|
+
(prev, content) => !prev || prev === typeof content._def.value ? typeof content._def.value : null,
|
|
1082
1080
|
null
|
|
1083
1081
|
);
|
|
1084
1082
|
if (type22) {
|
|
@@ -1092,15 +1090,12 @@ function parseUnion({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
|
1092
1090
|
);
|
|
1093
1091
|
}
|
|
1094
1092
|
}
|
|
1095
|
-
const oneOfContents =
|
|
1096
|
-
openApiVersion === '3.0'
|
|
1097
|
-
? contents.filter((content) => content._def.typeName !== 'ZodNull')
|
|
1098
|
-
: contents;
|
|
1093
|
+
const oneOfContents = openApiVersion === "3.0" ? contents.filter((content) => content._def.typeName !== "ZodNull") : contents;
|
|
1099
1094
|
const contentsHasNull = contents.length != oneOfContents.length;
|
|
1100
1095
|
return merge(
|
|
1101
1096
|
{
|
|
1102
|
-
oneOf: oneOfContents.map(
|
|
1103
|
-
generateSchema(schema, useOutput, openApiVersion)
|
|
1097
|
+
oneOf: oneOfContents.map(
|
|
1098
|
+
(schema) => generateSchema(schema, useOutput, openApiVersion)
|
|
1104
1099
|
)
|
|
1105
1100
|
},
|
|
1106
1101
|
contentsHasNull ? { nullable: true } : {},
|
|
@@ -1119,34 +1114,50 @@ function parseDiscriminatedUnion({
|
|
|
1119
1114
|
discriminator: {
|
|
1120
1115
|
propertyName: zodRef._def.discriminator
|
|
1121
1116
|
},
|
|
1122
|
-
oneOf: Array.from(
|
|
1123
|
-
|
|
1124
|
-
)
|
|
1117
|
+
oneOf: Array.from(
|
|
1118
|
+
zodRef._def.options.values()
|
|
1119
|
+
).map((schema) => generateSchema(schema, useOutput, openApiVersion))
|
|
1125
1120
|
},
|
|
1126
1121
|
zodRef.description ? { description: zodRef.description } : {},
|
|
1127
1122
|
...schemas
|
|
1128
1123
|
);
|
|
1129
1124
|
}
|
|
1130
|
-
function parseNever({
|
|
1125
|
+
function parseNever({
|
|
1126
|
+
zodRef,
|
|
1127
|
+
schemas
|
|
1128
|
+
}) {
|
|
1131
1129
|
return merge(
|
|
1132
1130
|
{ readOnly: true },
|
|
1133
1131
|
zodRef.description ? { description: zodRef.description } : {},
|
|
1134
1132
|
...schemas
|
|
1135
1133
|
);
|
|
1136
1134
|
}
|
|
1137
|
-
function parseBranded({
|
|
1135
|
+
function parseBranded({
|
|
1136
|
+
schemas,
|
|
1137
|
+
zodRef,
|
|
1138
|
+
useOutput,
|
|
1139
|
+
openApiVersion
|
|
1140
|
+
}) {
|
|
1138
1141
|
return merge(
|
|
1139
1142
|
generateSchema(zodRef._def.type, useOutput, openApiVersion),
|
|
1140
1143
|
...schemas
|
|
1141
1144
|
);
|
|
1142
1145
|
}
|
|
1143
|
-
function catchAllParser({
|
|
1146
|
+
function catchAllParser({
|
|
1147
|
+
zodRef,
|
|
1148
|
+
schemas
|
|
1149
|
+
}) {
|
|
1144
1150
|
return merge(
|
|
1145
1151
|
zodRef.description ? { description: zodRef.description } : {},
|
|
1146
1152
|
...schemas
|
|
1147
1153
|
);
|
|
1148
1154
|
}
|
|
1149
|
-
function parsePipeline({
|
|
1155
|
+
function parsePipeline({
|
|
1156
|
+
schemas,
|
|
1157
|
+
zodRef,
|
|
1158
|
+
useOutput,
|
|
1159
|
+
openApiVersion
|
|
1160
|
+
}) {
|
|
1150
1161
|
return merge(
|
|
1151
1162
|
generateSchema(
|
|
1152
1163
|
useOutput ? zodRef._def.out : zodRef._def.in,
|
|
@@ -1156,7 +1167,12 @@ function parsePipeline({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
|
1156
1167
|
...schemas
|
|
1157
1168
|
);
|
|
1158
1169
|
}
|
|
1159
|
-
function parseReadonly({
|
|
1170
|
+
function parseReadonly({
|
|
1171
|
+
zodRef,
|
|
1172
|
+
useOutput,
|
|
1173
|
+
schemas,
|
|
1174
|
+
openApiVersion
|
|
1175
|
+
}) {
|
|
1160
1176
|
return merge(
|
|
1161
1177
|
generateSchema(zodRef._def.innerType, useOutput, openApiVersion),
|
|
1162
1178
|
zodRef.description ? { description: zodRef.description } : {},
|
|
@@ -1200,10 +1216,10 @@ var workerMap = {
|
|
|
1200
1216
|
ZodPipeline: parsePipeline,
|
|
1201
1217
|
ZodReadonly: parseReadonly
|
|
1202
1218
|
};
|
|
1203
|
-
function generateSchema(zodRef, useOutput = false, openApiVersion =
|
|
1219
|
+
function generateSchema(zodRef, useOutput = false, openApiVersion = "3.1") {
|
|
1204
1220
|
const { metaOpenApi = {} } = zodRef;
|
|
1205
1221
|
const schemas = [
|
|
1206
|
-
...
|
|
1222
|
+
...Array.isArray(metaOpenApi) ? metaOpenApi : [metaOpenApi]
|
|
1207
1223
|
];
|
|
1208
1224
|
try {
|
|
1209
1225
|
const typeName = zodRef._def.typeName;
|
|
@@ -1222,173 +1238,155 @@ function generateSchema(zodRef, useOutput = false, openApiVersion = '3.1') {
|
|
|
1222
1238
|
}
|
|
1223
1239
|
}
|
|
1224
1240
|
function extendZodWithOpenApi(zod, forceOverride = false) {
|
|
1225
|
-
if (
|
|
1226
|
-
!forceOverride &&
|
|
1227
|
-
typeof zod.ZodSchema.prototype.openapi !== 'undefined'
|
|
1228
|
-
) {
|
|
1241
|
+
if (!forceOverride && typeof zod.ZodSchema.prototype.openapi !== "undefined") {
|
|
1229
1242
|
return;
|
|
1230
1243
|
}
|
|
1231
|
-
zod.ZodSchema.prototype.openapi = function
|
|
1244
|
+
zod.ZodSchema.prototype.openapi = function(metadata) {
|
|
1232
1245
|
return extendApi(this, metadata);
|
|
1233
1246
|
};
|
|
1234
1247
|
}
|
|
1235
1248
|
extendZodWithOpenApi(z2);
|
|
1236
1249
|
var ZodSchemaValidator = class {
|
|
1237
|
-
_Type =
|
|
1250
|
+
_Type = "Zod";
|
|
1238
1251
|
_SchemaCatchall;
|
|
1239
1252
|
_ValidSchemaObject;
|
|
1240
1253
|
string = z2.string().openapi({
|
|
1241
|
-
title:
|
|
1242
|
-
example:
|
|
1254
|
+
title: "String",
|
|
1255
|
+
example: "a string"
|
|
1243
1256
|
});
|
|
1244
1257
|
uuid = z2.string().uuid().openapi({
|
|
1245
|
-
title:
|
|
1246
|
-
format:
|
|
1247
|
-
pattern:
|
|
1248
|
-
|
|
1249
|
-
example: 'a8b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6'
|
|
1258
|
+
title: "UUID",
|
|
1259
|
+
format: "uuid",
|
|
1260
|
+
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}$",
|
|
1261
|
+
example: "a8b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6"
|
|
1250
1262
|
});
|
|
1251
1263
|
email = z2.string().email().openapi({
|
|
1252
|
-
title:
|
|
1253
|
-
format:
|
|
1254
|
-
pattern:
|
|
1255
|
-
example:
|
|
1264
|
+
title: "Email",
|
|
1265
|
+
format: "email",
|
|
1266
|
+
pattern: "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$",
|
|
1267
|
+
example: "a@b.com"
|
|
1256
1268
|
});
|
|
1257
1269
|
uri = z2.string().url().openapi({
|
|
1258
|
-
title:
|
|
1259
|
-
format:
|
|
1260
|
-
pattern:
|
|
1261
|
-
example:
|
|
1270
|
+
title: "URI",
|
|
1271
|
+
format: "uri",
|
|
1272
|
+
pattern: "^[a-zA-Z][a-zA-Z\\d+-.]*:[^\\s]*$",
|
|
1273
|
+
example: "https://forklaunch.com"
|
|
1262
1274
|
});
|
|
1263
|
-
number = z2
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
try {
|
|
1278
|
-
if (value instanceof Date) {
|
|
1279
|
-
return BigInt(value.getTime());
|
|
1280
|
-
}
|
|
1281
|
-
switch (typeof value) {
|
|
1282
|
-
case 'number':
|
|
1283
|
-
case 'string':
|
|
1284
|
-
return BigInt(value);
|
|
1285
|
-
case 'boolean':
|
|
1286
|
-
return BigInt(value ? 1 : 0);
|
|
1287
|
-
default:
|
|
1288
|
-
return value;
|
|
1289
|
-
}
|
|
1290
|
-
} catch {
|
|
1291
|
-
return value;
|
|
1275
|
+
number = z2.preprocess((value) => {
|
|
1276
|
+
try {
|
|
1277
|
+
return Number(value);
|
|
1278
|
+
} catch {
|
|
1279
|
+
return value;
|
|
1280
|
+
}
|
|
1281
|
+
}, z2.number()).openapi({
|
|
1282
|
+
title: "Number",
|
|
1283
|
+
example: 123
|
|
1284
|
+
});
|
|
1285
|
+
bigint = z2.preprocess((value) => {
|
|
1286
|
+
try {
|
|
1287
|
+
if (value instanceof Date) {
|
|
1288
|
+
return BigInt(value.getTime());
|
|
1292
1289
|
}
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
.preprocess((val) => {
|
|
1302
|
-
if (typeof val === 'string') {
|
|
1303
|
-
if (val.toLowerCase() === 'true') return true;
|
|
1304
|
-
if (val.toLowerCase() === 'false') return false;
|
|
1290
|
+
switch (typeof value) {
|
|
1291
|
+
case "number":
|
|
1292
|
+
case "string":
|
|
1293
|
+
return BigInt(value);
|
|
1294
|
+
case "boolean":
|
|
1295
|
+
return BigInt(value ? 1 : 0);
|
|
1296
|
+
default:
|
|
1297
|
+
return value;
|
|
1305
1298
|
}
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1299
|
+
} catch {
|
|
1300
|
+
return value;
|
|
1301
|
+
}
|
|
1302
|
+
}, z2.bigint()).openapi({
|
|
1303
|
+
title: "BigInt",
|
|
1304
|
+
type: "integer",
|
|
1305
|
+
format: "int64",
|
|
1306
|
+
example: 123n
|
|
1307
|
+
});
|
|
1308
|
+
boolean = z2.preprocess((val) => {
|
|
1309
|
+
if (typeof val === "string") {
|
|
1310
|
+
if (val.toLowerCase() === "true") return true;
|
|
1311
|
+
if (val.toLowerCase() === "false") return false;
|
|
1312
|
+
}
|
|
1313
|
+
return val;
|
|
1314
|
+
}, z2.boolean()).openapi({
|
|
1315
|
+
title: "Boolean",
|
|
1316
|
+
example: true
|
|
1317
|
+
});
|
|
1318
|
+
date = z2.preprocess((value) => {
|
|
1319
|
+
try {
|
|
1320
|
+
switch (typeof value) {
|
|
1321
|
+
case "string":
|
|
1322
|
+
return new Date(value);
|
|
1323
|
+
case "number":
|
|
1324
|
+
return new Date(value);
|
|
1325
|
+
default:
|
|
1326
|
+
return value;
|
|
1325
1327
|
}
|
|
1326
|
-
}
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1328
|
+
} catch {
|
|
1329
|
+
return value;
|
|
1330
|
+
}
|
|
1331
|
+
}, z2.date()).openapi({
|
|
1332
|
+
title: "Date",
|
|
1333
|
+
type: "string",
|
|
1334
|
+
format: "date-time",
|
|
1335
|
+
example: "2025-05-16T21:13:04.123Z"
|
|
1336
|
+
});
|
|
1333
1337
|
symbol = z2.symbol().openapi({
|
|
1334
|
-
title:
|
|
1335
|
-
example: Symbol(
|
|
1338
|
+
title: "Symbol",
|
|
1339
|
+
example: Symbol("symbol")
|
|
1336
1340
|
});
|
|
1337
1341
|
nullish = z2.union([z2.void(), z2.null(), z2.undefined()]).openapi({
|
|
1338
|
-
title:
|
|
1339
|
-
type:
|
|
1342
|
+
title: "Nullish",
|
|
1343
|
+
type: "null",
|
|
1340
1344
|
example: null
|
|
1341
1345
|
});
|
|
1342
1346
|
void = z2.void().openapi({
|
|
1343
|
-
title:
|
|
1344
|
-
type:
|
|
1347
|
+
title: "Void",
|
|
1348
|
+
type: "null",
|
|
1345
1349
|
example: void 0
|
|
1346
1350
|
});
|
|
1347
1351
|
null = z2.null().openapi({
|
|
1348
|
-
title:
|
|
1349
|
-
type:
|
|
1352
|
+
title: "Null",
|
|
1353
|
+
type: "null",
|
|
1350
1354
|
example: null
|
|
1351
1355
|
});
|
|
1352
1356
|
undefined = z2.undefined().openapi({
|
|
1353
|
-
title:
|
|
1354
|
-
type:
|
|
1357
|
+
title: "Undefined",
|
|
1358
|
+
type: "null",
|
|
1355
1359
|
example: void 0
|
|
1356
1360
|
});
|
|
1357
1361
|
any = z2.any().openapi({
|
|
1358
|
-
title:
|
|
1359
|
-
type:
|
|
1360
|
-
example:
|
|
1362
|
+
title: "Any",
|
|
1363
|
+
type: "object",
|
|
1364
|
+
example: "any"
|
|
1361
1365
|
});
|
|
1362
1366
|
unknown = z2.unknown().openapi({
|
|
1363
|
-
title:
|
|
1364
|
-
type:
|
|
1365
|
-
example:
|
|
1367
|
+
title: "Unknown",
|
|
1368
|
+
type: "object",
|
|
1369
|
+
example: "unknown"
|
|
1366
1370
|
});
|
|
1367
1371
|
never = z2.never().openapi({
|
|
1368
|
-
title:
|
|
1369
|
-
type:
|
|
1370
|
-
example:
|
|
1372
|
+
title: "Never",
|
|
1373
|
+
type: "null",
|
|
1374
|
+
example: "never"
|
|
1375
|
+
});
|
|
1376
|
+
binary = z2.string().transform((val) => new Uint8Array(Buffer.from(val, "base64"))).openapi({
|
|
1377
|
+
title: "Binary",
|
|
1378
|
+
type: "string",
|
|
1379
|
+
format: "binary",
|
|
1380
|
+
example: "a base-64 encodable string"
|
|
1381
|
+
});
|
|
1382
|
+
file = z2.instanceof(Buffer).transform((val) => {
|
|
1383
|
+
return new Blob([val]);
|
|
1384
|
+
}).openapi({
|
|
1385
|
+
title: "File",
|
|
1386
|
+
type: "string",
|
|
1387
|
+
format: "binary",
|
|
1388
|
+
example: "a base-64 encodable blob or file"
|
|
1371
1389
|
});
|
|
1372
|
-
binary = z2
|
|
1373
|
-
.string()
|
|
1374
|
-
.transform((val) => new Uint8Array(Buffer.from(val, 'base64')))
|
|
1375
|
-
.openapi({
|
|
1376
|
-
title: 'Binary',
|
|
1377
|
-
type: 'string',
|
|
1378
|
-
format: 'binary',
|
|
1379
|
-
example: 'a base-64 encodable string'
|
|
1380
|
-
});
|
|
1381
|
-
file = z2
|
|
1382
|
-
.instanceof(Buffer)
|
|
1383
|
-
.transform((val) => {
|
|
1384
|
-
return new Blob([val]);
|
|
1385
|
-
})
|
|
1386
|
-
.openapi({
|
|
1387
|
-
title: 'File',
|
|
1388
|
-
type: 'string',
|
|
1389
|
-
format: 'binary',
|
|
1390
|
-
example: 'a base-64 encodable blob or file'
|
|
1391
|
-
});
|
|
1392
1390
|
type = () => this.any;
|
|
1393
1391
|
/**
|
|
1394
1392
|
* Compiles schema if this exists, for optimal performance.
|
|
@@ -1405,11 +1403,7 @@ var ZodSchemaValidator = class {
|
|
|
1405
1403
|
* @returns {ZodResolve<T>} The resolved schema.
|
|
1406
1404
|
*/
|
|
1407
1405
|
schemify(schema) {
|
|
1408
|
-
if (
|
|
1409
|
-
typeof schema === 'string' ||
|
|
1410
|
-
typeof schema === 'number' ||
|
|
1411
|
-
typeof schema === 'boolean'
|
|
1412
|
-
) {
|
|
1406
|
+
if (typeof schema === "string" || typeof schema === "number" || typeof schema === "boolean") {
|
|
1413
1407
|
return z2.literal(schema);
|
|
1414
1408
|
}
|
|
1415
1409
|
if (schema instanceof ZodType) {
|
|
@@ -1450,7 +1444,9 @@ var ZodSchemaValidator = class {
|
|
|
1450
1444
|
*/
|
|
1451
1445
|
union(schemas) {
|
|
1452
1446
|
const resolvedSchemas = schemas.map((schema) => this.schemify(schema));
|
|
1453
|
-
return z2.union(
|
|
1447
|
+
return z2.union(
|
|
1448
|
+
resolvedSchemas
|
|
1449
|
+
);
|
|
1454
1450
|
}
|
|
1455
1451
|
/**
|
|
1456
1452
|
* Create a literal schema.
|
|
@@ -1466,7 +1462,9 @@ var ZodSchemaValidator = class {
|
|
|
1466
1462
|
* @returns {ZodUnion<UnionZodResolve<[T, T, ...T[]]>>} The enum schema.
|
|
1467
1463
|
*/
|
|
1468
1464
|
enum_(schemaEnum) {
|
|
1469
|
-
return this.union(
|
|
1465
|
+
return this.union(
|
|
1466
|
+
Object.values(schemaEnum)
|
|
1467
|
+
);
|
|
1470
1468
|
}
|
|
1471
1469
|
/**
|
|
1472
1470
|
* Create a function schema.
|
|
@@ -1535,33 +1533,31 @@ var ZodSchemaValidator = class {
|
|
|
1535
1533
|
parse(schema, value) {
|
|
1536
1534
|
const resolvedSchema = this.schemify(schema);
|
|
1537
1535
|
const result = resolvedSchema.safeParse(value);
|
|
1538
|
-
return result.success
|
|
1539
|
-
|
|
1540
|
-
: {
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
})
|
|
1564
|
-
};
|
|
1536
|
+
return result.success ? { ok: true, value: result.data } : {
|
|
1537
|
+
ok: false,
|
|
1538
|
+
errors: result.error.errors.flatMap((error) => {
|
|
1539
|
+
switch (error.code) {
|
|
1540
|
+
case "invalid_union":
|
|
1541
|
+
return error.unionErrors.flatMap(
|
|
1542
|
+
(unionError, idx) => unionError.errors.map((e) => ({
|
|
1543
|
+
path: [
|
|
1544
|
+
`Union Schema Variant ${idx}`,
|
|
1545
|
+
...error.path.map((p) => p.toString()),
|
|
1546
|
+
...e.path.map((p) => p.toString())
|
|
1547
|
+
],
|
|
1548
|
+
message: e.message
|
|
1549
|
+
}))
|
|
1550
|
+
);
|
|
1551
|
+
default:
|
|
1552
|
+
return [
|
|
1553
|
+
{
|
|
1554
|
+
path: error.path.map((p) => p.toString()),
|
|
1555
|
+
message: error.message
|
|
1556
|
+
}
|
|
1557
|
+
];
|
|
1558
|
+
}
|
|
1559
|
+
})
|
|
1560
|
+
};
|
|
1565
1561
|
}
|
|
1566
1562
|
/**
|
|
1567
1563
|
* Convert a schema to an OpenAPI schema object.
|
|
@@ -1610,7 +1606,7 @@ var openapi2 = StaticSchemaValidator2.openapi.bind(StaticSchemaValidator2);
|
|
|
1610
1606
|
// domain/schemas/zod/bullMqWorker.schema.ts
|
|
1611
1607
|
var BullMqWorkerOptionsSchema2 = {
|
|
1612
1608
|
queueOptions: type2(),
|
|
1613
|
-
backoffType: union2([literal2(
|
|
1609
|
+
backoffType: union2([literal2("exponential"), literal2("fixed")]),
|
|
1614
1610
|
retries: number2,
|
|
1615
1611
|
interval: number2
|
|
1616
1612
|
};
|
|
@@ -1620,4 +1616,6 @@ var BullMqWorkerSchemas = serviceSchemaResolver(
|
|
|
1620
1616
|
() => BullMqWorkerOptionsSchema,
|
|
1621
1617
|
() => BullMqWorkerOptionsSchema2
|
|
1622
1618
|
);
|
|
1623
|
-
export {
|
|
1619
|
+
export {
|
|
1620
|
+
BullMqWorkerSchemas
|
|
1621
|
+
};
|