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