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