@forklaunch/implementation-worker-redis 1.0.19 → 1.0.21
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.js +24 -15
- package/lib/consumers/index.mjs +13 -11
- package/lib/domain/schemas/index.js +641 -588
- package/lib/domain/schemas/index.mjs +599 -587
- package/lib/domain/types/index.js +8 -4
- package/lib/producers/index.js +12 -7
- package/lib/producers/index.mjs +1 -3
- package/package.json +6 -6
|
@@ -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/redisWorker.schema.ts
|
|
29
|
-
var import_internal = require(
|
|
36
|
+
var import_internal = require('@forklaunch/internal');
|
|
30
37
|
|
|
31
|
-
// ../../../node_modules/.pnpm/@forklaunch+validator@1.2.
|
|
38
|
+
// ../../../node_modules/.pnpm/@forklaunch+validator@1.2.12/node_modules/@forklaunch/validator/lib/src/typebox/index.mjs
|
|
32
39
|
var typebox_exports = {};
|
|
33
40
|
__export(typebox_exports, {
|
|
34
41
|
SchemaValidator: () => SchemaValidator,
|
|
@@ -66,14 +73,14 @@ __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@1.2.
|
|
78
|
+
// ../../../node_modules/.pnpm/@forklaunch+common@1.2.12/node_modules/@forklaunch/common/lib/index.mjs
|
|
72
79
|
function deepCloneWithoutUndefined(obj, seen = /* @__PURE__ */ new WeakMap()) {
|
|
73
80
|
if (obj === null || obj === void 0) {
|
|
74
81
|
return obj;
|
|
75
82
|
}
|
|
76
|
-
if (typeof obj !==
|
|
83
|
+
if (typeof obj !== 'object' && typeof obj !== 'function') {
|
|
77
84
|
return obj;
|
|
78
85
|
}
|
|
79
86
|
if (seen.has(obj)) {
|
|
@@ -115,7 +122,7 @@ function deepCloneWithoutUndefined(obj, seen = /* @__PURE__ */ new WeakMap()) {
|
|
|
115
122
|
}
|
|
116
123
|
return clonedArray;
|
|
117
124
|
}
|
|
118
|
-
if (typeof obj ===
|
|
125
|
+
if (typeof obj === 'function') {
|
|
119
126
|
return obj;
|
|
120
127
|
}
|
|
121
128
|
const proto = Object.getPrototypeOf(obj);
|
|
@@ -128,7 +135,7 @@ function deepCloneWithoutUndefined(obj, seen = /* @__PURE__ */ new WeakMap()) {
|
|
|
128
135
|
for (const key of allKeys) {
|
|
129
136
|
const descriptor = Object.getOwnPropertyDescriptor(obj, key);
|
|
130
137
|
if (!descriptor) continue;
|
|
131
|
-
if (
|
|
138
|
+
if ('value' in descriptor) {
|
|
132
139
|
if (descriptor.value !== void 0) {
|
|
133
140
|
Object.defineProperty(cloned, key, {
|
|
134
141
|
...descriptor,
|
|
@@ -148,253 +155,282 @@ var InMemoryBlob = class extends Blob {
|
|
|
148
155
|
}
|
|
149
156
|
};
|
|
150
157
|
|
|
151
|
-
// ../../../node_modules/.pnpm/@forklaunch+validator@1.2.
|
|
152
|
-
var import_typebox = require(
|
|
153
|
-
var import_compiler = require(
|
|
154
|
-
var import_errors = require(
|
|
155
|
-
var import_value = require(
|
|
156
|
-
import_typebox.FormatRegistry.Set(
|
|
157
|
-
|
|
158
|
+
// ../../../node_modules/.pnpm/@forklaunch+validator@1.2.12/node_modules/@forklaunch/validator/lib/src/typebox/index.mjs
|
|
159
|
+
var import_typebox = require('@sinclair/typebox');
|
|
160
|
+
var import_compiler = require('@sinclair/typebox/compiler');
|
|
161
|
+
var import_errors = require('@sinclair/typebox/errors');
|
|
162
|
+
var import_value = require('@sinclair/typebox/value');
|
|
163
|
+
import_typebox.FormatRegistry.Set(
|
|
164
|
+
'binary',
|
|
165
|
+
(value) => typeof value === 'string'
|
|
166
|
+
);
|
|
167
|
+
import_typebox.TypeRegistry.Set(
|
|
168
|
+
'Blob',
|
|
169
|
+
(_schema, value) => value instanceof Blob
|
|
170
|
+
);
|
|
158
171
|
import_typebox.TypeRegistry.Set(
|
|
159
|
-
|
|
172
|
+
'ArrayBuffer',
|
|
160
173
|
(_schema, value) => value instanceof ArrayBuffer
|
|
161
174
|
);
|
|
162
|
-
import_typebox.TypeRegistry.Set(
|
|
175
|
+
import_typebox.TypeRegistry.Set(
|
|
176
|
+
'Buffer',
|
|
177
|
+
(_schema, value) => value instanceof Buffer
|
|
178
|
+
);
|
|
163
179
|
(0, import_errors.SetErrorFunction)((params) => {
|
|
164
180
|
switch (params.errorType) {
|
|
165
181
|
case import_errors.ValueErrorType.Union:
|
|
166
182
|
case import_errors.ValueErrorType.Array:
|
|
167
183
|
case import_errors.ValueErrorType.String:
|
|
168
184
|
case import_errors.ValueErrorType.Number:
|
|
169
|
-
return params.schema.errorType
|
|
185
|
+
return params.schema.errorType
|
|
186
|
+
? `Expected ${params.schema.errorType} value${params.schema.errorSuffix ? 's' : ''}`
|
|
187
|
+
: (0, import_errors.DefaultErrorFunction)(params);
|
|
170
188
|
default:
|
|
171
189
|
return (0, import_errors.DefaultErrorFunction)(params);
|
|
172
190
|
}
|
|
173
191
|
});
|
|
174
192
|
var TypeboxSchemaValidator = class {
|
|
175
|
-
_Type =
|
|
193
|
+
_Type = 'TypeBox';
|
|
176
194
|
_SchemaCatchall;
|
|
177
195
|
_ValidSchemaObject;
|
|
178
196
|
string = import_typebox.Type.String({
|
|
179
|
-
example:
|
|
180
|
-
title:
|
|
197
|
+
example: 'a string',
|
|
198
|
+
title: 'String'
|
|
181
199
|
});
|
|
182
200
|
uuid = import_typebox.Type.String({
|
|
183
|
-
pattern:
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
201
|
+
pattern:
|
|
202
|
+
'^[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}$',
|
|
203
|
+
errorType: 'uuid',
|
|
204
|
+
example: 'a8b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6',
|
|
205
|
+
title: 'UUID'
|
|
187
206
|
});
|
|
188
207
|
email = import_typebox.Type.String({
|
|
189
|
-
pattern:
|
|
190
|
-
errorType:
|
|
191
|
-
example:
|
|
192
|
-
title:
|
|
208
|
+
pattern: '^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$',
|
|
209
|
+
errorType: 'email',
|
|
210
|
+
example: 'a@b.com',
|
|
211
|
+
title: 'Email'
|
|
193
212
|
});
|
|
194
213
|
uri = import_typebox.Type.String({
|
|
195
|
-
pattern:
|
|
196
|
-
errorType:
|
|
197
|
-
example:
|
|
198
|
-
title:
|
|
214
|
+
pattern: '^[a-zA-Z][a-zA-Z\\d+-.]*:[^\\s]*$',
|
|
215
|
+
errorType: 'uri',
|
|
216
|
+
example: 'https://forklaunch.com',
|
|
217
|
+
title: 'URI'
|
|
199
218
|
});
|
|
200
219
|
number = import_typebox.Type.Transform(
|
|
201
220
|
import_typebox.Type.Union(
|
|
202
221
|
[
|
|
203
222
|
import_typebox.Type.Number(),
|
|
204
|
-
import_typebox.Type.String({ pattern:
|
|
223
|
+
import_typebox.Type.String({ pattern: '^[0-9]+$' }),
|
|
205
224
|
import_typebox.Type.Boolean(),
|
|
206
225
|
import_typebox.Type.Null(),
|
|
207
226
|
import_typebox.Type.BigInt(),
|
|
208
227
|
import_typebox.Type.Date()
|
|
209
228
|
],
|
|
210
229
|
{
|
|
211
|
-
errorType:
|
|
230
|
+
errorType: 'number-like',
|
|
212
231
|
example: 123,
|
|
213
|
-
title:
|
|
232
|
+
title: 'Number'
|
|
214
233
|
}
|
|
215
234
|
)
|
|
216
|
-
)
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
235
|
+
)
|
|
236
|
+
.Decode((value) => {
|
|
237
|
+
if (typeof value !== 'number') {
|
|
238
|
+
const num = Number(value);
|
|
239
|
+
if (isNaN(num)) {
|
|
240
|
+
throw new Error('Invalid number');
|
|
241
|
+
} else {
|
|
242
|
+
return num;
|
|
243
|
+
}
|
|
223
244
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
245
|
+
return value;
|
|
246
|
+
})
|
|
247
|
+
.Encode(Number);
|
|
227
248
|
bigint = import_typebox.Type.Transform(
|
|
228
249
|
import_typebox.Type.Union(
|
|
229
250
|
[
|
|
230
251
|
import_typebox.Type.BigInt(),
|
|
231
252
|
import_typebox.Type.Number(),
|
|
232
|
-
import_typebox.Type.String({ pattern:
|
|
253
|
+
import_typebox.Type.String({ pattern: '^[0-9]+n?$' }),
|
|
233
254
|
import_typebox.Type.Boolean(),
|
|
234
255
|
import_typebox.Type.Date()
|
|
235
256
|
],
|
|
236
257
|
{
|
|
237
|
-
errorType:
|
|
258
|
+
errorType: 'BigInt-like',
|
|
238
259
|
example: 123n,
|
|
239
|
-
title:
|
|
260
|
+
title: 'BigInt'
|
|
240
261
|
}
|
|
241
262
|
)
|
|
242
|
-
)
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
263
|
+
)
|
|
264
|
+
.Decode((value) => {
|
|
265
|
+
if (typeof value !== 'bigint') {
|
|
266
|
+
try {
|
|
267
|
+
if (value instanceof Date) {
|
|
268
|
+
return BigInt(value.getTime());
|
|
269
|
+
}
|
|
270
|
+
return BigInt(value);
|
|
271
|
+
} catch {
|
|
272
|
+
throw new Error('Invalid bigint');
|
|
247
273
|
}
|
|
248
|
-
return BigInt(value);
|
|
249
|
-
} catch {
|
|
250
|
-
throw new Error("Invalid bigint");
|
|
251
274
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
275
|
+
return value;
|
|
276
|
+
})
|
|
277
|
+
.Encode(BigInt);
|
|
255
278
|
boolean = import_typebox.Type.Transform(
|
|
256
279
|
import_typebox.Type.Union(
|
|
257
280
|
[
|
|
258
281
|
import_typebox.Type.Boolean(),
|
|
259
282
|
import_typebox.Type.String({
|
|
260
|
-
pattern:
|
|
283
|
+
pattern: '^(t|T)(r|R)(u|U)(e|E)$|^(f|F)(a|A)(l|L)(s|S)(e|E)$'
|
|
261
284
|
})
|
|
262
285
|
],
|
|
263
286
|
{
|
|
264
|
-
errorType:
|
|
287
|
+
errorType: 'boolean-like',
|
|
265
288
|
example: true,
|
|
266
|
-
title:
|
|
289
|
+
title: 'Boolean'
|
|
267
290
|
}
|
|
268
291
|
)
|
|
269
|
-
)
|
|
270
|
-
|
|
271
|
-
if (value
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
292
|
+
)
|
|
293
|
+
.Decode((value) => {
|
|
294
|
+
if (typeof value === 'string') {
|
|
295
|
+
if (value.toLowerCase() === 'true') return true;
|
|
296
|
+
return false;
|
|
297
|
+
} else {
|
|
298
|
+
return value;
|
|
299
|
+
}
|
|
300
|
+
})
|
|
301
|
+
.Encode(Boolean);
|
|
277
302
|
date = import_typebox.Type.Transform(
|
|
278
303
|
import_typebox.Type.Union(
|
|
279
304
|
[
|
|
280
305
|
import_typebox.Type.String({
|
|
281
|
-
pattern:
|
|
306
|
+
pattern:
|
|
307
|
+
'^\\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+$'
|
|
282
308
|
}),
|
|
283
309
|
import_typebox.Type.Number(),
|
|
284
310
|
import_typebox.Type.Date()
|
|
285
311
|
],
|
|
286
312
|
{
|
|
287
|
-
errorType:
|
|
288
|
-
example:
|
|
289
|
-
title:
|
|
313
|
+
errorType: 'date',
|
|
314
|
+
example: '2025-05-16T21:13:04.123Z',
|
|
315
|
+
title: 'Date'
|
|
290
316
|
}
|
|
291
317
|
)
|
|
292
|
-
)
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
318
|
+
)
|
|
319
|
+
.Decode((value) => {
|
|
320
|
+
if (value === null || typeof value === 'boolean') {
|
|
321
|
+
return /* @__PURE__ */ new Date(value ? 1 : 0);
|
|
322
|
+
}
|
|
323
|
+
return new Date(value);
|
|
324
|
+
})
|
|
325
|
+
.Encode((value) => new Date(value).toISOString());
|
|
298
326
|
symbol = import_typebox.Type.Symbol({
|
|
299
|
-
title:
|
|
327
|
+
title: 'Symbol'
|
|
300
328
|
});
|
|
301
329
|
nullish = import_typebox.Type.Union(
|
|
302
|
-
[
|
|
330
|
+
[
|
|
331
|
+
import_typebox.Type.Void(),
|
|
332
|
+
import_typebox.Type.Null(),
|
|
333
|
+
import_typebox.Type.Undefined()
|
|
334
|
+
],
|
|
303
335
|
{
|
|
304
|
-
errorType:
|
|
305
|
-
type:
|
|
306
|
-
example:
|
|
307
|
-
title:
|
|
336
|
+
errorType: 'nullish',
|
|
337
|
+
type: 'null',
|
|
338
|
+
example: 'null',
|
|
339
|
+
title: 'Nullish'
|
|
308
340
|
}
|
|
309
341
|
);
|
|
310
342
|
void = import_typebox.Type.Void({
|
|
311
|
-
type:
|
|
312
|
-
example:
|
|
313
|
-
title:
|
|
343
|
+
type: 'null',
|
|
344
|
+
example: 'void',
|
|
345
|
+
title: 'Void'
|
|
314
346
|
});
|
|
315
347
|
null = import_typebox.Type.Null({
|
|
316
|
-
type:
|
|
317
|
-
example:
|
|
318
|
-
title:
|
|
348
|
+
type: 'null',
|
|
349
|
+
example: 'null',
|
|
350
|
+
title: 'Null'
|
|
319
351
|
});
|
|
320
352
|
undefined = import_typebox.Type.Undefined({
|
|
321
|
-
type:
|
|
322
|
-
example:
|
|
323
|
-
title:
|
|
353
|
+
type: 'null',
|
|
354
|
+
example: 'undefined',
|
|
355
|
+
title: 'Undefined'
|
|
324
356
|
});
|
|
325
357
|
any = import_typebox.Type.Any({
|
|
326
|
-
type:
|
|
327
|
-
example:
|
|
328
|
-
title:
|
|
358
|
+
type: 'object',
|
|
359
|
+
example: 'any',
|
|
360
|
+
title: 'Any'
|
|
329
361
|
});
|
|
330
362
|
unknown = import_typebox.Type.Unknown({
|
|
331
|
-
type:
|
|
332
|
-
example:
|
|
333
|
-
title:
|
|
363
|
+
type: 'object',
|
|
364
|
+
example: 'unknown',
|
|
365
|
+
title: 'Unknown'
|
|
334
366
|
});
|
|
335
367
|
never = import_typebox.Type.Never({
|
|
336
|
-
type:
|
|
337
|
-
example:
|
|
338
|
-
title:
|
|
368
|
+
type: 'null',
|
|
369
|
+
example: 'never',
|
|
370
|
+
title: 'Never'
|
|
339
371
|
});
|
|
340
372
|
binary = import_typebox.Type.Transform(
|
|
341
373
|
import_typebox.Type.String({
|
|
342
|
-
errorType:
|
|
343
|
-
format:
|
|
344
|
-
example:
|
|
345
|
-
title:
|
|
374
|
+
errorType: 'binary',
|
|
375
|
+
format: 'binary',
|
|
376
|
+
example: 'a base-64 encodable string',
|
|
377
|
+
title: 'Binary'
|
|
346
378
|
})
|
|
347
|
-
)
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
379
|
+
)
|
|
380
|
+
.Decode((value) => new Uint8Array(Buffer.from(value, 'base64')))
|
|
381
|
+
.Encode((value) => {
|
|
382
|
+
if (value instanceof Buffer) {
|
|
383
|
+
return String.fromCharCode(...new Uint8Array(value));
|
|
384
|
+
}
|
|
385
|
+
return '';
|
|
386
|
+
});
|
|
353
387
|
file = import_typebox.Type.Transform(
|
|
354
388
|
import_typebox.Type.Union([
|
|
355
389
|
import_typebox.Type.Unsafe({
|
|
356
|
-
[import_typebox.Kind]:
|
|
357
|
-
errorType:
|
|
358
|
-
format:
|
|
359
|
-
example:
|
|
360
|
-
title:
|
|
390
|
+
[import_typebox.Kind]: 'Buffer',
|
|
391
|
+
errorType: 'binary',
|
|
392
|
+
format: 'binary',
|
|
393
|
+
example: 'a raw buffer or file stream',
|
|
394
|
+
title: 'File'
|
|
361
395
|
}),
|
|
362
396
|
import_typebox.Type.Unsafe({
|
|
363
|
-
[import_typebox.Kind]:
|
|
364
|
-
errorType:
|
|
365
|
-
format:
|
|
366
|
-
example:
|
|
367
|
-
title:
|
|
397
|
+
[import_typebox.Kind]: 'ArrayBuffer',
|
|
398
|
+
errorType: 'binary',
|
|
399
|
+
format: 'binary',
|
|
400
|
+
example: 'an array buffer',
|
|
401
|
+
title: 'File'
|
|
368
402
|
}),
|
|
369
403
|
import_typebox.Type.Unsafe({
|
|
370
|
-
[import_typebox.Kind]:
|
|
371
|
-
errorType:
|
|
372
|
-
format:
|
|
373
|
-
example:
|
|
374
|
-
title:
|
|
404
|
+
[import_typebox.Kind]: 'Blob',
|
|
405
|
+
errorType: 'binary',
|
|
406
|
+
format: 'binary',
|
|
407
|
+
example: 'a blob object',
|
|
408
|
+
title: 'File'
|
|
375
409
|
}),
|
|
376
410
|
import_typebox.Type.String({
|
|
377
|
-
errorType:
|
|
378
|
-
format:
|
|
379
|
-
example:
|
|
380
|
-
title:
|
|
411
|
+
errorType: 'binary',
|
|
412
|
+
format: 'binary',
|
|
413
|
+
example: 'a string content',
|
|
414
|
+
title: 'File'
|
|
381
415
|
})
|
|
382
416
|
])
|
|
383
|
-
)
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
417
|
+
)
|
|
418
|
+
.Decode((value) => {
|
|
419
|
+
if (value instanceof Buffer) {
|
|
420
|
+
return new InMemoryBlob(value);
|
|
421
|
+
}
|
|
422
|
+
if (value instanceof ArrayBuffer) {
|
|
423
|
+
return new InMemoryBlob(Buffer.from(value));
|
|
424
|
+
}
|
|
425
|
+
if (value instanceof Blob) {
|
|
426
|
+
return value;
|
|
427
|
+
}
|
|
428
|
+
if (typeof value === 'string') {
|
|
429
|
+
return new InMemoryBlob(Buffer.from(value));
|
|
430
|
+
}
|
|
394
431
|
return new InMemoryBlob(Buffer.from(value));
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
}).Encode((value) => value.content);
|
|
432
|
+
})
|
|
433
|
+
.Encode((value) => value.content);
|
|
398
434
|
type = () => this.any;
|
|
399
435
|
/**
|
|
400
436
|
* Extracts the error type of a schema for error messages.
|
|
@@ -403,7 +439,10 @@ var TypeboxSchemaValidator = class {
|
|
|
403
439
|
* @returns The type of the schema for error messages.
|
|
404
440
|
*/
|
|
405
441
|
errorType(schema) {
|
|
406
|
-
if (
|
|
442
|
+
if (
|
|
443
|
+
import_typebox.KindGuard.IsSchema(schema) &&
|
|
444
|
+
Object.hasOwn(schema, 'errorType')
|
|
445
|
+
) {
|
|
407
446
|
return schema.errorType;
|
|
408
447
|
} else if (import_typebox.KindGuard.IsLiteral(schema)) {
|
|
409
448
|
return schema.const;
|
|
@@ -425,15 +464,25 @@ var TypeboxSchemaValidator = class {
|
|
|
425
464
|
* @returns {TResolve<T>} The resolved schema.
|
|
426
465
|
*/
|
|
427
466
|
schemify(schema) {
|
|
428
|
-
if (
|
|
467
|
+
if (
|
|
468
|
+
typeof schema === 'string' ||
|
|
469
|
+
typeof schema === 'number' ||
|
|
470
|
+
typeof schema === 'boolean'
|
|
471
|
+
) {
|
|
429
472
|
return import_typebox.Type.Literal(schema);
|
|
430
473
|
}
|
|
431
|
-
if (
|
|
474
|
+
if (
|
|
475
|
+
import_typebox.KindGuard.IsSchema(schema) ||
|
|
476
|
+
schema instanceof import_compiler.TypeCheck
|
|
477
|
+
) {
|
|
432
478
|
return schema;
|
|
433
479
|
}
|
|
434
480
|
const newSchema = {};
|
|
435
481
|
Object.getOwnPropertyNames(schema).forEach((key) => {
|
|
436
|
-
if (
|
|
482
|
+
if (
|
|
483
|
+
import_typebox.KindGuard.IsSchema(schema[key]) ||
|
|
484
|
+
import_typebox.KindGuard.IsTransform(schema[key])
|
|
485
|
+
) {
|
|
437
486
|
newSchema[key] = schema[key];
|
|
438
487
|
} else {
|
|
439
488
|
const schemified = this.schemify(schema[key]);
|
|
@@ -475,7 +524,7 @@ var TypeboxSchemaValidator = class {
|
|
|
475
524
|
return this.schemify(schema);
|
|
476
525
|
});
|
|
477
526
|
return import_typebox.Type.Union(unionTypes, {
|
|
478
|
-
errorType: `any of ${unionTypes.map((s) => this.errorType(s)).join(
|
|
527
|
+
errorType: `any of ${unionTypes.map((s) => this.errorType(s)).join(', ')}`,
|
|
479
528
|
errorSuffix: true
|
|
480
529
|
});
|
|
481
530
|
}
|
|
@@ -546,7 +595,12 @@ var TypeboxSchemaValidator = class {
|
|
|
546
595
|
* @returns {boolean} True if the value is an instance of the schema.
|
|
547
596
|
*/
|
|
548
597
|
isInstanceOf(value, type22) {
|
|
549
|
-
return
|
|
598
|
+
return (
|
|
599
|
+
typeof value === 'object' &&
|
|
600
|
+
value != null &&
|
|
601
|
+
import_typebox.Kind in value &&
|
|
602
|
+
value[import_typebox.Kind] === type22[import_typebox.Kind]
|
|
603
|
+
);
|
|
550
604
|
}
|
|
551
605
|
/**
|
|
552
606
|
* Validate a value against a schema.
|
|
@@ -581,7 +635,7 @@ var TypeboxSchemaValidator = class {
|
|
|
581
635
|
}
|
|
582
636
|
} else {
|
|
583
637
|
const schemified = this.schemify(schema);
|
|
584
|
-
if (schemified[import_typebox.Kind] ===
|
|
638
|
+
if (schemified[import_typebox.Kind] === 'Unsafe') {
|
|
585
639
|
try {
|
|
586
640
|
if (value instanceof Buffer) {
|
|
587
641
|
conversion = new InMemoryBlob(value);
|
|
@@ -590,7 +644,7 @@ var TypeboxSchemaValidator = class {
|
|
|
590
644
|
{
|
|
591
645
|
type: import_errors.ValueErrorType.String,
|
|
592
646
|
schema: schemified,
|
|
593
|
-
path:
|
|
647
|
+
path: '',
|
|
594
648
|
message: `Invalid file type: expected Buffer or string, got ${typeof value}`,
|
|
595
649
|
value,
|
|
596
650
|
errors: []
|
|
@@ -602,8 +656,8 @@ var TypeboxSchemaValidator = class {
|
|
|
602
656
|
{
|
|
603
657
|
type: import_errors.ValueErrorType.String,
|
|
604
658
|
schema: schemified,
|
|
605
|
-
path:
|
|
606
|
-
message: err instanceof Error ? err.message :
|
|
659
|
+
path: '',
|
|
660
|
+
message: err instanceof Error ? err.message : 'Invalid file type',
|
|
607
661
|
value,
|
|
608
662
|
errors: []
|
|
609
663
|
}
|
|
@@ -617,33 +671,38 @@ var TypeboxSchemaValidator = class {
|
|
|
617
671
|
}
|
|
618
672
|
}
|
|
619
673
|
}
|
|
620
|
-
return errors != null && errors.length === 0
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
ok: false,
|
|
625
|
-
errors: errors.flatMap((error) => {
|
|
626
|
-
if (error.type === import_errors.ValueErrorType.Union && error.schema.errorType?.includes("any of")) {
|
|
627
|
-
return error.errors.flatMap(
|
|
628
|
-
(e, idx) => Array.from(e).map((e2) => ({
|
|
629
|
-
path: [
|
|
630
|
-
`Union Schema Variant ${idx}`,
|
|
631
|
-
...error.path.split("/").slice(1),
|
|
632
|
-
...e2.path.split("/").slice(1)
|
|
633
|
-
],
|
|
634
|
-
message: e2.message
|
|
635
|
-
}))
|
|
636
|
-
);
|
|
637
|
-
} else {
|
|
638
|
-
return [
|
|
639
|
-
{
|
|
640
|
-
path: error.path.split("/").slice(1),
|
|
641
|
-
message: error.message
|
|
642
|
-
}
|
|
643
|
-
];
|
|
674
|
+
return errors != null && errors.length === 0
|
|
675
|
+
? {
|
|
676
|
+
ok: true,
|
|
677
|
+
value: conversion
|
|
644
678
|
}
|
|
645
|
-
|
|
646
|
-
|
|
679
|
+
: {
|
|
680
|
+
ok: false,
|
|
681
|
+
errors: errors.flatMap((error) => {
|
|
682
|
+
if (
|
|
683
|
+
error.type === import_errors.ValueErrorType.Union &&
|
|
684
|
+
error.schema.errorType?.includes('any of')
|
|
685
|
+
) {
|
|
686
|
+
return error.errors.flatMap((e, idx) =>
|
|
687
|
+
Array.from(e).map((e2) => ({
|
|
688
|
+
path: [
|
|
689
|
+
`Union Schema Variant ${idx}`,
|
|
690
|
+
...error.path.split('/').slice(1),
|
|
691
|
+
...e2.path.split('/').slice(1)
|
|
692
|
+
],
|
|
693
|
+
message: e2.message
|
|
694
|
+
}))
|
|
695
|
+
);
|
|
696
|
+
} else {
|
|
697
|
+
return [
|
|
698
|
+
{
|
|
699
|
+
path: error.path.split('/').slice(1),
|
|
700
|
+
message: error.message
|
|
701
|
+
}
|
|
702
|
+
];
|
|
703
|
+
}
|
|
704
|
+
})
|
|
705
|
+
};
|
|
647
706
|
}
|
|
648
707
|
/**
|
|
649
708
|
* Convert a schema to an OpenAPI schema object.
|
|
@@ -655,38 +714,37 @@ var TypeboxSchemaValidator = class {
|
|
|
655
714
|
let processedSchema;
|
|
656
715
|
if (import_typebox.KindGuard.IsDate(schemified)) {
|
|
657
716
|
processedSchema = import_typebox.Type.String({
|
|
658
|
-
format:
|
|
717
|
+
format: 'date-time'
|
|
659
718
|
});
|
|
660
719
|
} else {
|
|
661
720
|
processedSchema = deepCloneWithoutUndefined(schemified);
|
|
662
721
|
}
|
|
663
722
|
const newSchema = Object.assign({}, processedSchema);
|
|
664
|
-
if (Object.hasOwn(newSchema,
|
|
723
|
+
if (Object.hasOwn(newSchema, 'properties')) {
|
|
665
724
|
if (newSchema.properties) {
|
|
666
725
|
Object.entries({ ...processedSchema.properties }).forEach(
|
|
667
726
|
([key, value]) => {
|
|
668
|
-
if (
|
|
727
|
+
if (
|
|
728
|
+
import_typebox.KindGuard.IsSchema(value) &&
|
|
729
|
+
newSchema.properties
|
|
730
|
+
) {
|
|
669
731
|
newSchema.properties[key] = this.openapi(value);
|
|
670
732
|
}
|
|
671
733
|
}
|
|
672
734
|
);
|
|
673
735
|
}
|
|
674
736
|
}
|
|
675
|
-
if (Object.hasOwn(newSchema,
|
|
737
|
+
if (Object.hasOwn(newSchema, 'items')) {
|
|
676
738
|
newSchema.items = this.openapi(newSchema.items);
|
|
677
739
|
}
|
|
678
740
|
if (Array.isArray(newSchema.anyOf)) {
|
|
679
|
-
newSchema.anyOf = newSchema.anyOf.map(
|
|
680
|
-
(item) => this.openapi(item)
|
|
681
|
-
);
|
|
741
|
+
newSchema.anyOf = newSchema.anyOf.map((item) => this.openapi(item));
|
|
682
742
|
}
|
|
683
743
|
if (Array.isArray(newSchema.oneOf)) {
|
|
684
|
-
newSchema.oneOf = newSchema.oneOf.map(
|
|
685
|
-
(item) => this.openapi(item)
|
|
686
|
-
);
|
|
744
|
+
newSchema.oneOf = newSchema.oneOf.map((item) => this.openapi(item));
|
|
687
745
|
}
|
|
688
|
-
if (
|
|
689
|
-
delete newSchema[
|
|
746
|
+
if ('errorType' in newSchema) {
|
|
747
|
+
delete newSchema['errorType'];
|
|
690
748
|
}
|
|
691
749
|
return newSchema;
|
|
692
750
|
}
|
|
@@ -733,43 +791,55 @@ var RedisWorkerOptionsSchema = {
|
|
|
733
791
|
interval: number
|
|
734
792
|
};
|
|
735
793
|
|
|
736
|
-
// ../../../node_modules/.pnpm/@forklaunch+validator@1.2.
|
|
737
|
-
var import_v3 = require(
|
|
794
|
+
// ../../../node_modules/.pnpm/@forklaunch+validator@1.2.12/node_modules/@forklaunch/validator/lib/src/zod/index.mjs
|
|
795
|
+
var import_v3 = require('zod/v3');
|
|
738
796
|
|
|
739
797
|
// ../../../node_modules/.pnpm/ts-deepmerge@7.0.3/node_modules/ts-deepmerge/esm/index.js
|
|
740
798
|
var isObject = (obj) => {
|
|
741
|
-
if (typeof obj ===
|
|
742
|
-
if (typeof Object.getPrototypeOf ===
|
|
799
|
+
if (typeof obj === 'object' && obj !== null) {
|
|
800
|
+
if (typeof Object.getPrototypeOf === 'function') {
|
|
743
801
|
const prototype = Object.getPrototypeOf(obj);
|
|
744
802
|
return prototype === Object.prototype || prototype === null;
|
|
745
803
|
}
|
|
746
|
-
return Object.prototype.toString.call(obj) ===
|
|
804
|
+
return Object.prototype.toString.call(obj) === '[object Object]';
|
|
747
805
|
}
|
|
748
806
|
return false;
|
|
749
807
|
};
|
|
750
|
-
var merge = (...objects) =>
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
if (Array.isArray(current)) {
|
|
755
|
-
throw new TypeError("Arguments provided to ts-deepmerge must be objects, not arrays.");
|
|
756
|
-
}
|
|
757
|
-
Object.keys(current).forEach((key) => {
|
|
758
|
-
if (["__proto__", "constructor", "prototype"].includes(key)) {
|
|
759
|
-
return;
|
|
808
|
+
var merge = (...objects) =>
|
|
809
|
+
objects.reduce((result, current) => {
|
|
810
|
+
if (current === void 0) {
|
|
811
|
+
return result;
|
|
760
812
|
}
|
|
761
|
-
if (Array.isArray(
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
} else if (!isObject(result[key]) && isObject(current[key])) {
|
|
766
|
-
result[key] = merge(current[key], void 0);
|
|
767
|
-
} else {
|
|
768
|
-
result[key] = current[key] === void 0 ? merge.options.allowUndefinedOverrides ? current[key] : result[key] : current[key];
|
|
813
|
+
if (Array.isArray(current)) {
|
|
814
|
+
throw new TypeError(
|
|
815
|
+
'Arguments provided to ts-deepmerge must be objects, not arrays.'
|
|
816
|
+
);
|
|
769
817
|
}
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
818
|
+
Object.keys(current).forEach((key) => {
|
|
819
|
+
if (['__proto__', 'constructor', 'prototype'].includes(key)) {
|
|
820
|
+
return;
|
|
821
|
+
}
|
|
822
|
+
if (Array.isArray(result[key]) && Array.isArray(current[key])) {
|
|
823
|
+
result[key] = merge.options.mergeArrays
|
|
824
|
+
? merge.options.uniqueArrayItems
|
|
825
|
+
? Array.from(new Set(result[key].concat(current[key])))
|
|
826
|
+
: [...result[key], ...current[key]]
|
|
827
|
+
: current[key];
|
|
828
|
+
} else if (isObject(result[key]) && isObject(current[key])) {
|
|
829
|
+
result[key] = merge(result[key], current[key]);
|
|
830
|
+
} else if (!isObject(result[key]) && isObject(current[key])) {
|
|
831
|
+
result[key] = merge(current[key], void 0);
|
|
832
|
+
} else {
|
|
833
|
+
result[key] =
|
|
834
|
+
current[key] === void 0
|
|
835
|
+
? merge.options.allowUndefinedOverrides
|
|
836
|
+
? current[key]
|
|
837
|
+
: result[key]
|
|
838
|
+
: current[key];
|
|
839
|
+
}
|
|
840
|
+
});
|
|
841
|
+
return result;
|
|
842
|
+
}, {});
|
|
773
843
|
var defaultOptions = {
|
|
774
844
|
allowUndefinedOverrides: true,
|
|
775
845
|
mergeArrays: true,
|
|
@@ -783,8 +853,8 @@ merge.withOptions = (options, ...objects) => {
|
|
|
783
853
|
return result;
|
|
784
854
|
};
|
|
785
855
|
|
|
786
|
-
// ../../../node_modules/.pnpm/@forklaunch+validator@1.2.
|
|
787
|
-
var import_v32 = require(
|
|
856
|
+
// ../../../node_modules/.pnpm/@forklaunch+validator@1.2.12/node_modules/@forklaunch/validator/lib/src/zod/index.mjs
|
|
857
|
+
var import_v32 = require('zod/v3');
|
|
788
858
|
function extendApi(schema, schemaObject = {}) {
|
|
789
859
|
const This = schema.constructor;
|
|
790
860
|
const newSchema = new This(schema._def);
|
|
@@ -801,89 +871,96 @@ function iterateZodObject({
|
|
|
801
871
|
hideDefinitions,
|
|
802
872
|
openApiVersion
|
|
803
873
|
}) {
|
|
804
|
-
const reduced = Object.keys(zodRef.shape)
|
|
805
|
-
(
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
874
|
+
const reduced = Object.keys(zodRef.shape)
|
|
875
|
+
.filter((key) => hideDefinitions?.includes(key) === false)
|
|
876
|
+
.reduce(
|
|
877
|
+
(carry, key) => ({
|
|
878
|
+
...carry,
|
|
879
|
+
[key]: generateSchema(zodRef.shape[key], useOutput, openApiVersion)
|
|
880
|
+
}),
|
|
881
|
+
{}
|
|
882
|
+
);
|
|
811
883
|
return reduced;
|
|
812
884
|
}
|
|
813
885
|
function typeFormat(type22, openApiVersion) {
|
|
814
|
-
return openApiVersion ===
|
|
886
|
+
return openApiVersion === '3.0' ? type22 : [type22];
|
|
815
887
|
}
|
|
816
|
-
function parseTransformation({
|
|
817
|
-
zodRef,
|
|
818
|
-
schemas,
|
|
819
|
-
useOutput,
|
|
820
|
-
openApiVersion
|
|
821
|
-
}) {
|
|
888
|
+
function parseTransformation({ zodRef, schemas, useOutput, openApiVersion }) {
|
|
822
889
|
const input = generateSchema(zodRef._def.schema, useOutput, openApiVersion);
|
|
823
|
-
let output =
|
|
890
|
+
let output = 'undefined';
|
|
824
891
|
if (useOutput && zodRef._def.effect) {
|
|
825
|
-
const effect =
|
|
826
|
-
|
|
892
|
+
const effect =
|
|
893
|
+
zodRef._def.effect.type === 'transform' ? zodRef._def.effect : null;
|
|
894
|
+
if (effect && 'transform' in effect) {
|
|
827
895
|
try {
|
|
828
896
|
const type22 = Array.isArray(input.type) ? input.type[0] : input.type;
|
|
829
897
|
output = typeof effect.transform(
|
|
830
|
-
[
|
|
898
|
+
['integer', 'number'].includes(`${type22}`)
|
|
899
|
+
? 0
|
|
900
|
+
: 'string' === type22
|
|
901
|
+
? ''
|
|
902
|
+
: 'boolean' === type22
|
|
903
|
+
? false
|
|
904
|
+
: 'object' === type22
|
|
905
|
+
? {}
|
|
906
|
+
: 'null' === type22
|
|
907
|
+
? null
|
|
908
|
+
: 'array' === type22
|
|
909
|
+
? []
|
|
910
|
+
: void 0,
|
|
831
911
|
{ addIssue: () => void 0, path: [] }
|
|
832
912
|
// TODO: Discover if context is necessary here
|
|
833
913
|
);
|
|
834
|
-
} catch {
|
|
835
|
-
}
|
|
914
|
+
} catch {}
|
|
836
915
|
}
|
|
837
916
|
}
|
|
838
917
|
const outputType = output;
|
|
839
918
|
return merge(
|
|
840
919
|
{
|
|
841
|
-
...zodRef.description ? { description: zodRef.description } : {},
|
|
920
|
+
...(zodRef.description ? { description: zodRef.description } : {}),
|
|
842
921
|
...input,
|
|
843
|
-
...[
|
|
844
|
-
|
|
845
|
-
|
|
922
|
+
...(['number', 'string', 'boolean', 'null'].includes(output)
|
|
923
|
+
? {
|
|
924
|
+
type: typeFormat(outputType, openApiVersion)
|
|
925
|
+
}
|
|
926
|
+
: {})
|
|
846
927
|
},
|
|
847
928
|
...schemas
|
|
848
929
|
);
|
|
849
930
|
}
|
|
850
|
-
function parseString({
|
|
851
|
-
zodRef,
|
|
852
|
-
schemas,
|
|
853
|
-
openApiVersion
|
|
854
|
-
}) {
|
|
931
|
+
function parseString({ zodRef, schemas, openApiVersion }) {
|
|
855
932
|
const baseSchema = {
|
|
856
|
-
type: typeFormat(
|
|
933
|
+
type: typeFormat('string', openApiVersion)
|
|
857
934
|
};
|
|
858
935
|
const { checks = [] } = zodRef._def;
|
|
859
936
|
checks.forEach((item) => {
|
|
860
937
|
switch (item.kind) {
|
|
861
|
-
case
|
|
862
|
-
baseSchema.format =
|
|
938
|
+
case 'email':
|
|
939
|
+
baseSchema.format = 'email';
|
|
863
940
|
break;
|
|
864
|
-
case
|
|
865
|
-
baseSchema.format =
|
|
941
|
+
case 'uuid':
|
|
942
|
+
baseSchema.format = 'uuid';
|
|
866
943
|
break;
|
|
867
|
-
case
|
|
868
|
-
baseSchema.format =
|
|
944
|
+
case 'cuid':
|
|
945
|
+
baseSchema.format = 'cuid';
|
|
869
946
|
break;
|
|
870
|
-
case
|
|
871
|
-
baseSchema.format =
|
|
947
|
+
case 'url':
|
|
948
|
+
baseSchema.format = 'uri';
|
|
872
949
|
break;
|
|
873
|
-
case
|
|
874
|
-
baseSchema.format =
|
|
950
|
+
case 'datetime':
|
|
951
|
+
baseSchema.format = 'date-time';
|
|
875
952
|
break;
|
|
876
|
-
case
|
|
953
|
+
case 'length':
|
|
877
954
|
baseSchema.minLength = item.value;
|
|
878
955
|
baseSchema.maxLength = item.value;
|
|
879
956
|
break;
|
|
880
|
-
case
|
|
957
|
+
case 'max':
|
|
881
958
|
baseSchema.maxLength = item.value;
|
|
882
959
|
break;
|
|
883
|
-
case
|
|
960
|
+
case 'min':
|
|
884
961
|
baseSchema.minLength = item.value;
|
|
885
962
|
break;
|
|
886
|
-
case
|
|
963
|
+
case 'regex':
|
|
887
964
|
baseSchema.pattern = item.regex.source;
|
|
888
965
|
break;
|
|
889
966
|
}
|
|
@@ -894,45 +971,41 @@ function parseString({
|
|
|
894
971
|
...schemas
|
|
895
972
|
);
|
|
896
973
|
}
|
|
897
|
-
function parseNumber({
|
|
898
|
-
zodRef,
|
|
899
|
-
schemas,
|
|
900
|
-
openApiVersion
|
|
901
|
-
}) {
|
|
974
|
+
function parseNumber({ zodRef, schemas, openApiVersion }) {
|
|
902
975
|
const baseSchema = {
|
|
903
|
-
type: typeFormat(
|
|
976
|
+
type: typeFormat('number', openApiVersion)
|
|
904
977
|
};
|
|
905
978
|
const { checks = [] } = zodRef._def;
|
|
906
979
|
checks.forEach((item) => {
|
|
907
980
|
switch (item.kind) {
|
|
908
|
-
case
|
|
909
|
-
if (item.inclusive || openApiVersion ===
|
|
981
|
+
case 'max':
|
|
982
|
+
if (item.inclusive || openApiVersion === '3.0') {
|
|
910
983
|
baseSchema.maximum = item.value;
|
|
911
984
|
}
|
|
912
985
|
if (!item.inclusive) {
|
|
913
|
-
if (openApiVersion ===
|
|
986
|
+
if (openApiVersion === '3.0') {
|
|
914
987
|
baseSchema.exclusiveMaximum = true;
|
|
915
988
|
} else {
|
|
916
989
|
baseSchema.exclusiveMaximum = item.value;
|
|
917
990
|
}
|
|
918
991
|
}
|
|
919
992
|
break;
|
|
920
|
-
case
|
|
921
|
-
if (item.inclusive || openApiVersion ===
|
|
993
|
+
case 'min':
|
|
994
|
+
if (item.inclusive || openApiVersion === '3.0') {
|
|
922
995
|
baseSchema.minimum = item.value;
|
|
923
996
|
}
|
|
924
997
|
if (!item.inclusive) {
|
|
925
|
-
if (openApiVersion ===
|
|
998
|
+
if (openApiVersion === '3.0') {
|
|
926
999
|
baseSchema.exclusiveMinimum = true;
|
|
927
1000
|
} else {
|
|
928
1001
|
baseSchema.exclusiveMinimum = item.value;
|
|
929
1002
|
}
|
|
930
1003
|
}
|
|
931
1004
|
break;
|
|
932
|
-
case
|
|
933
|
-
baseSchema.type = typeFormat(
|
|
1005
|
+
case 'int':
|
|
1006
|
+
baseSchema.type = typeFormat('integer', openApiVersion);
|
|
934
1007
|
break;
|
|
935
|
-
case
|
|
1008
|
+
case 'multipleOf':
|
|
936
1009
|
baseSchema.multipleOf = item.value;
|
|
937
1010
|
break;
|
|
938
1011
|
}
|
|
@@ -960,26 +1033,41 @@ function parseObject({
|
|
|
960
1033
|
openApiVersion
|
|
961
1034
|
}) {
|
|
962
1035
|
let additionalProperties;
|
|
963
|
-
if (
|
|
1036
|
+
if (
|
|
1037
|
+
!(
|
|
1038
|
+
zodRef._def.catchall instanceof import_v32.z.ZodNever ||
|
|
1039
|
+
zodRef._def.catchall?._def.typeName === 'ZodNever'
|
|
1040
|
+
)
|
|
1041
|
+
)
|
|
964
1042
|
additionalProperties = generateSchema(
|
|
965
1043
|
zodRef._def.catchall,
|
|
966
1044
|
useOutput,
|
|
967
1045
|
openApiVersion
|
|
968
1046
|
);
|
|
969
|
-
else if (zodRef._def.unknownKeys ===
|
|
1047
|
+
else if (zodRef._def.unknownKeys === 'passthrough')
|
|
970
1048
|
additionalProperties = true;
|
|
971
|
-
else if (zodRef._def.unknownKeys ===
|
|
972
|
-
additionalProperties =
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
).filter((key) => {
|
|
1049
|
+
else if (zodRef._def.unknownKeys === 'strict') additionalProperties = false;
|
|
1050
|
+
additionalProperties =
|
|
1051
|
+
additionalProperties != null ? { additionalProperties } : {};
|
|
1052
|
+
const requiredProperties = Object.keys(zodRef.shape).filter((key) => {
|
|
976
1053
|
const item = zodRef.shape[key];
|
|
977
|
-
return
|
|
1054
|
+
return (
|
|
1055
|
+
!(
|
|
1056
|
+
item.isOptional() ||
|
|
1057
|
+
item instanceof import_v32.z.ZodDefault ||
|
|
1058
|
+
item._def.typeName === 'ZodDefault'
|
|
1059
|
+
) &&
|
|
1060
|
+
!(
|
|
1061
|
+
item instanceof import_v32.z.ZodNever ||
|
|
1062
|
+
item._def.typeName === 'ZodDefault'
|
|
1063
|
+
)
|
|
1064
|
+
);
|
|
978
1065
|
});
|
|
979
|
-
const required =
|
|
1066
|
+
const required =
|
|
1067
|
+
requiredProperties.length > 0 ? { required: requiredProperties } : {};
|
|
980
1068
|
return merge(
|
|
981
1069
|
{
|
|
982
|
-
type: typeFormat(
|
|
1070
|
+
type: typeFormat('object', openApiVersion),
|
|
983
1071
|
properties: iterateZodObject({
|
|
984
1072
|
zodRef,
|
|
985
1073
|
schemas,
|
|
@@ -991,110 +1079,83 @@ function parseObject({
|
|
|
991
1079
|
...additionalProperties,
|
|
992
1080
|
...hideDefinitions
|
|
993
1081
|
},
|
|
994
|
-
zodRef.description
|
|
1082
|
+
zodRef.description
|
|
1083
|
+
? { description: zodRef.description, hideDefinitions }
|
|
1084
|
+
: {},
|
|
995
1085
|
...schemas
|
|
996
1086
|
);
|
|
997
1087
|
}
|
|
998
|
-
function parseRecord({
|
|
999
|
-
zodRef,
|
|
1000
|
-
schemas,
|
|
1001
|
-
useOutput,
|
|
1002
|
-
openApiVersion
|
|
1003
|
-
}) {
|
|
1088
|
+
function parseRecord({ zodRef, schemas, useOutput, openApiVersion }) {
|
|
1004
1089
|
return merge(
|
|
1005
1090
|
{
|
|
1006
|
-
type: typeFormat(
|
|
1007
|
-
additionalProperties:
|
|
1091
|
+
type: typeFormat('object', openApiVersion),
|
|
1092
|
+
additionalProperties:
|
|
1093
|
+
zodRef._def.valueType instanceof import_v32.z.ZodUnknown
|
|
1094
|
+
? {}
|
|
1095
|
+
: generateSchema(zodRef._def.valueType, useOutput, openApiVersion)
|
|
1008
1096
|
},
|
|
1009
1097
|
zodRef.description ? { description: zodRef.description } : {},
|
|
1010
1098
|
...schemas
|
|
1011
1099
|
);
|
|
1012
1100
|
}
|
|
1013
|
-
function parseBigInt({
|
|
1014
|
-
zodRef,
|
|
1015
|
-
schemas,
|
|
1016
|
-
openApiVersion
|
|
1017
|
-
}) {
|
|
1101
|
+
function parseBigInt({ zodRef, schemas, openApiVersion }) {
|
|
1018
1102
|
return merge(
|
|
1019
1103
|
{
|
|
1020
|
-
type: typeFormat(
|
|
1021
|
-
format:
|
|
1104
|
+
type: typeFormat('integer', openApiVersion),
|
|
1105
|
+
format: 'int64'
|
|
1022
1106
|
},
|
|
1023
1107
|
zodRef.description ? { description: zodRef.description } : {},
|
|
1024
1108
|
...schemas
|
|
1025
1109
|
);
|
|
1026
1110
|
}
|
|
1027
|
-
function parseBoolean({
|
|
1028
|
-
zodRef,
|
|
1029
|
-
schemas,
|
|
1030
|
-
openApiVersion
|
|
1031
|
-
}) {
|
|
1111
|
+
function parseBoolean({ zodRef, schemas, openApiVersion }) {
|
|
1032
1112
|
return merge(
|
|
1033
|
-
{ type: typeFormat(
|
|
1113
|
+
{ type: typeFormat('boolean', openApiVersion) },
|
|
1034
1114
|
zodRef.description ? { description: zodRef.description } : {},
|
|
1035
1115
|
...schemas
|
|
1036
1116
|
);
|
|
1037
1117
|
}
|
|
1038
|
-
function parseDate({
|
|
1039
|
-
zodRef,
|
|
1040
|
-
schemas,
|
|
1041
|
-
openApiVersion
|
|
1042
|
-
}) {
|
|
1118
|
+
function parseDate({ zodRef, schemas, openApiVersion }) {
|
|
1043
1119
|
return merge(
|
|
1044
1120
|
{
|
|
1045
|
-
type: typeFormat(
|
|
1046
|
-
format:
|
|
1121
|
+
type: typeFormat('string', openApiVersion),
|
|
1122
|
+
format: 'date-time'
|
|
1047
1123
|
},
|
|
1048
1124
|
zodRef.description ? { description: zodRef.description } : {},
|
|
1049
1125
|
...schemas
|
|
1050
1126
|
);
|
|
1051
1127
|
}
|
|
1052
|
-
function parseNull({
|
|
1053
|
-
zodRef,
|
|
1054
|
-
schemas,
|
|
1055
|
-
openApiVersion
|
|
1056
|
-
}) {
|
|
1128
|
+
function parseNull({ zodRef, schemas, openApiVersion }) {
|
|
1057
1129
|
return merge(
|
|
1058
|
-
openApiVersion ===
|
|
1059
|
-
type:
|
|
1060
|
-
|
|
1061
|
-
|
|
1130
|
+
openApiVersion === '3.0'
|
|
1131
|
+
? { type: 'null' }
|
|
1132
|
+
: {
|
|
1133
|
+
type: ['string', 'null'],
|
|
1134
|
+
enum: ['null']
|
|
1135
|
+
},
|
|
1062
1136
|
zodRef.description ? { description: zodRef.description } : {},
|
|
1063
1137
|
...schemas
|
|
1064
1138
|
);
|
|
1065
1139
|
}
|
|
1066
|
-
function parseOptional({
|
|
1067
|
-
schemas,
|
|
1068
|
-
zodRef,
|
|
1069
|
-
useOutput,
|
|
1070
|
-
openApiVersion
|
|
1071
|
-
}) {
|
|
1140
|
+
function parseOptional({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
1072
1141
|
return merge(
|
|
1073
1142
|
generateSchema(zodRef.unwrap(), useOutput, openApiVersion),
|
|
1074
1143
|
zodRef.description ? { description: zodRef.description } : {},
|
|
1075
1144
|
...schemas
|
|
1076
1145
|
);
|
|
1077
1146
|
}
|
|
1078
|
-
function parseNullable({
|
|
1079
|
-
schemas,
|
|
1080
|
-
zodRef,
|
|
1081
|
-
useOutput,
|
|
1082
|
-
openApiVersion
|
|
1083
|
-
}) {
|
|
1147
|
+
function parseNullable({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
1084
1148
|
const schema = generateSchema(zodRef.unwrap(), useOutput, openApiVersion);
|
|
1085
1149
|
return merge(
|
|
1086
1150
|
schema,
|
|
1087
|
-
openApiVersion ===
|
|
1151
|
+
openApiVersion === '3.0'
|
|
1152
|
+
? { nullable: true }
|
|
1153
|
+
: { type: typeFormat('null', openApiVersion) },
|
|
1088
1154
|
zodRef.description ? { description: zodRef.description } : {},
|
|
1089
1155
|
...schemas
|
|
1090
1156
|
);
|
|
1091
1157
|
}
|
|
1092
|
-
function parseDefault({
|
|
1093
|
-
schemas,
|
|
1094
|
-
zodRef,
|
|
1095
|
-
useOutput,
|
|
1096
|
-
openApiVersion
|
|
1097
|
-
}) {
|
|
1158
|
+
function parseDefault({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
1098
1159
|
return merge(
|
|
1099
1160
|
{
|
|
1100
1161
|
default: zodRef._def.defaultValue(),
|
|
@@ -1104,12 +1165,7 @@ function parseDefault({
|
|
|
1104
1165
|
...schemas
|
|
1105
1166
|
);
|
|
1106
1167
|
}
|
|
1107
|
-
function parseArray({
|
|
1108
|
-
schemas,
|
|
1109
|
-
zodRef,
|
|
1110
|
-
useOutput,
|
|
1111
|
-
openApiVersion
|
|
1112
|
-
}) {
|
|
1168
|
+
function parseArray({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
1113
1169
|
const constraints = {};
|
|
1114
1170
|
if (zodRef._def.exactLength != null) {
|
|
1115
1171
|
constraints.minItems = zodRef._def.exactLength.value;
|
|
@@ -1121,7 +1177,7 @@ function parseArray({
|
|
|
1121
1177
|
constraints.maxItems = zodRef._def.maxLength.value;
|
|
1122
1178
|
return merge(
|
|
1123
1179
|
{
|
|
1124
|
-
type: typeFormat(
|
|
1180
|
+
type: typeFormat('array', openApiVersion),
|
|
1125
1181
|
items: generateSchema(zodRef.element, useOutput, openApiVersion),
|
|
1126
1182
|
...constraints
|
|
1127
1183
|
},
|
|
@@ -1129,11 +1185,7 @@ function parseArray({
|
|
|
1129
1185
|
...schemas
|
|
1130
1186
|
);
|
|
1131
1187
|
}
|
|
1132
|
-
function parseLiteral({
|
|
1133
|
-
schemas,
|
|
1134
|
-
zodRef,
|
|
1135
|
-
openApiVersion
|
|
1136
|
-
}) {
|
|
1188
|
+
function parseLiteral({ schemas, zodRef, openApiVersion }) {
|
|
1137
1189
|
const type22 = typeof zodRef._def.value;
|
|
1138
1190
|
return merge(
|
|
1139
1191
|
{
|
|
@@ -1144,11 +1196,7 @@ function parseLiteral({
|
|
|
1144
1196
|
...schemas
|
|
1145
1197
|
);
|
|
1146
1198
|
}
|
|
1147
|
-
function parseEnum({
|
|
1148
|
-
schemas,
|
|
1149
|
-
zodRef,
|
|
1150
|
-
openApiVersion
|
|
1151
|
-
}) {
|
|
1199
|
+
function parseEnum({ schemas, zodRef, openApiVersion }) {
|
|
1152
1200
|
const type22 = typeof Object.values(zodRef._def.values)[0];
|
|
1153
1201
|
return merge(
|
|
1154
1202
|
{
|
|
@@ -1159,12 +1207,7 @@ function parseEnum({
|
|
|
1159
1207
|
...schemas
|
|
1160
1208
|
);
|
|
1161
1209
|
}
|
|
1162
|
-
function parseIntersection({
|
|
1163
|
-
schemas,
|
|
1164
|
-
zodRef,
|
|
1165
|
-
useOutput,
|
|
1166
|
-
openApiVersion
|
|
1167
|
-
}) {
|
|
1210
|
+
function parseIntersection({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
1168
1211
|
return merge(
|
|
1169
1212
|
{
|
|
1170
1213
|
allOf: [
|
|
@@ -1176,20 +1219,20 @@ function parseIntersection({
|
|
|
1176
1219
|
...schemas
|
|
1177
1220
|
);
|
|
1178
1221
|
}
|
|
1179
|
-
function parseUnion({
|
|
1180
|
-
schemas,
|
|
1181
|
-
zodRef,
|
|
1182
|
-
useOutput,
|
|
1183
|
-
openApiVersion
|
|
1184
|
-
}) {
|
|
1222
|
+
function parseUnion({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
1185
1223
|
const contents = zodRef._def.options;
|
|
1186
|
-
if (
|
|
1187
|
-
(
|
|
1188
|
-
|
|
1189
|
-
|
|
1224
|
+
if (
|
|
1225
|
+
contents.reduce(
|
|
1226
|
+
(prev, content) => prev && content._def.typeName === 'ZodLiteral',
|
|
1227
|
+
true
|
|
1228
|
+
)
|
|
1229
|
+
) {
|
|
1190
1230
|
const literals = contents;
|
|
1191
1231
|
const type22 = literals.reduce(
|
|
1192
|
-
(prev, content) =>
|
|
1232
|
+
(prev, content) =>
|
|
1233
|
+
!prev || prev === typeof content._def.value
|
|
1234
|
+
? typeof content._def.value
|
|
1235
|
+
: null,
|
|
1193
1236
|
null
|
|
1194
1237
|
);
|
|
1195
1238
|
if (type22) {
|
|
@@ -1203,12 +1246,15 @@ function parseUnion({
|
|
|
1203
1246
|
);
|
|
1204
1247
|
}
|
|
1205
1248
|
}
|
|
1206
|
-
const oneOfContents =
|
|
1249
|
+
const oneOfContents =
|
|
1250
|
+
openApiVersion === '3.0'
|
|
1251
|
+
? contents.filter((content) => content._def.typeName !== 'ZodNull')
|
|
1252
|
+
: contents;
|
|
1207
1253
|
const contentsHasNull = contents.length != oneOfContents.length;
|
|
1208
1254
|
return merge(
|
|
1209
1255
|
{
|
|
1210
|
-
oneOf: oneOfContents.map(
|
|
1211
|
-
|
|
1256
|
+
oneOf: oneOfContents.map((schema) =>
|
|
1257
|
+
generateSchema(schema, useOutput, openApiVersion)
|
|
1212
1258
|
)
|
|
1213
1259
|
},
|
|
1214
1260
|
contentsHasNull ? { nullable: true } : {},
|
|
@@ -1227,50 +1273,34 @@ function parseDiscriminatedUnion({
|
|
|
1227
1273
|
discriminator: {
|
|
1228
1274
|
propertyName: zodRef._def.discriminator
|
|
1229
1275
|
},
|
|
1230
|
-
oneOf: Array.from(
|
|
1231
|
-
|
|
1232
|
-
)
|
|
1276
|
+
oneOf: Array.from(zodRef._def.options.values()).map((schema) =>
|
|
1277
|
+
generateSchema(schema, useOutput, openApiVersion)
|
|
1278
|
+
)
|
|
1233
1279
|
},
|
|
1234
1280
|
zodRef.description ? { description: zodRef.description } : {},
|
|
1235
1281
|
...schemas
|
|
1236
1282
|
);
|
|
1237
1283
|
}
|
|
1238
|
-
function parseNever({
|
|
1239
|
-
zodRef,
|
|
1240
|
-
schemas
|
|
1241
|
-
}) {
|
|
1284
|
+
function parseNever({ zodRef, schemas }) {
|
|
1242
1285
|
return merge(
|
|
1243
1286
|
{ readOnly: true },
|
|
1244
1287
|
zodRef.description ? { description: zodRef.description } : {},
|
|
1245
1288
|
...schemas
|
|
1246
1289
|
);
|
|
1247
1290
|
}
|
|
1248
|
-
function parseBranded({
|
|
1249
|
-
schemas,
|
|
1250
|
-
zodRef,
|
|
1251
|
-
useOutput,
|
|
1252
|
-
openApiVersion
|
|
1253
|
-
}) {
|
|
1291
|
+
function parseBranded({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
1254
1292
|
return merge(
|
|
1255
1293
|
generateSchema(zodRef._def.type, useOutput, openApiVersion),
|
|
1256
1294
|
...schemas
|
|
1257
1295
|
);
|
|
1258
1296
|
}
|
|
1259
|
-
function catchAllParser({
|
|
1260
|
-
zodRef,
|
|
1261
|
-
schemas
|
|
1262
|
-
}) {
|
|
1297
|
+
function catchAllParser({ zodRef, schemas }) {
|
|
1263
1298
|
return merge(
|
|
1264
1299
|
zodRef.description ? { description: zodRef.description } : {},
|
|
1265
1300
|
...schemas
|
|
1266
1301
|
);
|
|
1267
1302
|
}
|
|
1268
|
-
function parsePipeline({
|
|
1269
|
-
schemas,
|
|
1270
|
-
zodRef,
|
|
1271
|
-
useOutput,
|
|
1272
|
-
openApiVersion
|
|
1273
|
-
}) {
|
|
1303
|
+
function parsePipeline({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
1274
1304
|
return merge(
|
|
1275
1305
|
generateSchema(
|
|
1276
1306
|
useOutput ? zodRef._def.out : zodRef._def.in,
|
|
@@ -1280,12 +1310,7 @@ function parsePipeline({
|
|
|
1280
1310
|
...schemas
|
|
1281
1311
|
);
|
|
1282
1312
|
}
|
|
1283
|
-
function parseReadonly({
|
|
1284
|
-
zodRef,
|
|
1285
|
-
useOutput,
|
|
1286
|
-
schemas,
|
|
1287
|
-
openApiVersion
|
|
1288
|
-
}) {
|
|
1313
|
+
function parseReadonly({ zodRef, useOutput, schemas, openApiVersion }) {
|
|
1289
1314
|
return merge(
|
|
1290
1315
|
generateSchema(zodRef._def.innerType, useOutput, openApiVersion),
|
|
1291
1316
|
zodRef.description ? { description: zodRef.description } : {},
|
|
@@ -1329,10 +1354,10 @@ var workerMap = {
|
|
|
1329
1354
|
ZodPipeline: parsePipeline,
|
|
1330
1355
|
ZodReadonly: parseReadonly
|
|
1331
1356
|
};
|
|
1332
|
-
function generateSchema(zodRef, useOutput = false, openApiVersion =
|
|
1357
|
+
function generateSchema(zodRef, useOutput = false, openApiVersion = '3.1') {
|
|
1333
1358
|
const { metaOpenApi = {} } = zodRef;
|
|
1334
1359
|
const schemas = [
|
|
1335
|
-
...Array.isArray(metaOpenApi) ? metaOpenApi : [metaOpenApi]
|
|
1360
|
+
...(Array.isArray(metaOpenApi) ? metaOpenApi : [metaOpenApi])
|
|
1336
1361
|
];
|
|
1337
1362
|
try {
|
|
1338
1363
|
const typeName = zodRef._def.typeName;
|
|
@@ -1351,174 +1376,196 @@ function generateSchema(zodRef, useOutput = false, openApiVersion = "3.1") {
|
|
|
1351
1376
|
}
|
|
1352
1377
|
}
|
|
1353
1378
|
function extendZodWithOpenApi(zod, forceOverride = false) {
|
|
1354
|
-
if (
|
|
1379
|
+
if (
|
|
1380
|
+
!forceOverride &&
|
|
1381
|
+
typeof zod.ZodSchema.prototype.openapi !== 'undefined'
|
|
1382
|
+
) {
|
|
1355
1383
|
return;
|
|
1356
1384
|
}
|
|
1357
|
-
zod.ZodSchema.prototype.openapi = function(metadata) {
|
|
1385
|
+
zod.ZodSchema.prototype.openapi = function (metadata) {
|
|
1358
1386
|
return extendApi(this, metadata);
|
|
1359
1387
|
};
|
|
1360
1388
|
}
|
|
1361
1389
|
extendZodWithOpenApi(import_v3.z);
|
|
1362
1390
|
var ZodSchemaValidator = class {
|
|
1363
|
-
_Type =
|
|
1391
|
+
_Type = 'Zod';
|
|
1364
1392
|
_SchemaCatchall;
|
|
1365
1393
|
_ValidSchemaObject;
|
|
1366
1394
|
string = import_v3.z.string().openapi({
|
|
1367
|
-
title:
|
|
1368
|
-
example:
|
|
1395
|
+
title: 'String',
|
|
1396
|
+
example: 'a string'
|
|
1369
1397
|
});
|
|
1370
1398
|
uuid = import_v3.z.string().uuid().openapi({
|
|
1371
|
-
title:
|
|
1372
|
-
format:
|
|
1373
|
-
pattern:
|
|
1374
|
-
|
|
1399
|
+
title: 'UUID',
|
|
1400
|
+
format: 'uuid',
|
|
1401
|
+
pattern:
|
|
1402
|
+
'^[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}$',
|
|
1403
|
+
example: 'a8b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6'
|
|
1375
1404
|
});
|
|
1376
1405
|
email = import_v3.z.string().email().openapi({
|
|
1377
|
-
title:
|
|
1378
|
-
format:
|
|
1379
|
-
pattern:
|
|
1380
|
-
example:
|
|
1406
|
+
title: 'Email',
|
|
1407
|
+
format: 'email',
|
|
1408
|
+
pattern: '^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$',
|
|
1409
|
+
example: 'a@b.com'
|
|
1381
1410
|
});
|
|
1382
1411
|
uri = import_v3.z.string().url().openapi({
|
|
1383
|
-
title:
|
|
1384
|
-
format:
|
|
1385
|
-
pattern:
|
|
1386
|
-
example:
|
|
1387
|
-
});
|
|
1388
|
-
number = import_v3.z.preprocess((value) => {
|
|
1389
|
-
try {
|
|
1390
|
-
return Number(value);
|
|
1391
|
-
} catch {
|
|
1392
|
-
return value;
|
|
1393
|
-
}
|
|
1394
|
-
}, import_v3.z.number()).openapi({
|
|
1395
|
-
title: "Number",
|
|
1396
|
-
example: 123
|
|
1412
|
+
title: 'URI',
|
|
1413
|
+
format: 'uri',
|
|
1414
|
+
pattern: '^[a-zA-Z][a-zA-Z\\d+-.]*:[^\\s]*$',
|
|
1415
|
+
example: 'https://forklaunch.com'
|
|
1397
1416
|
});
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
return
|
|
1417
|
+
number = import_v3.z
|
|
1418
|
+
.preprocess((value) => {
|
|
1419
|
+
try {
|
|
1420
|
+
return Number(value);
|
|
1421
|
+
} catch {
|
|
1422
|
+
return value;
|
|
1402
1423
|
}
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1424
|
+
}, import_v3.z.number())
|
|
1425
|
+
.openapi({
|
|
1426
|
+
title: 'Number',
|
|
1427
|
+
example: 123
|
|
1428
|
+
});
|
|
1429
|
+
bigint = import_v3.z
|
|
1430
|
+
.preprocess((value) => {
|
|
1431
|
+
try {
|
|
1432
|
+
if (value instanceof Date) {
|
|
1433
|
+
return BigInt(value.getTime());
|
|
1434
|
+
}
|
|
1435
|
+
switch (typeof value) {
|
|
1436
|
+
case 'number':
|
|
1437
|
+
case 'string':
|
|
1438
|
+
return BigInt(value);
|
|
1439
|
+
case 'boolean':
|
|
1440
|
+
return BigInt(value ? 1 : 0);
|
|
1441
|
+
default:
|
|
1442
|
+
return value;
|
|
1443
|
+
}
|
|
1444
|
+
} catch {
|
|
1445
|
+
return value;
|
|
1411
1446
|
}
|
|
1412
|
-
}
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
if (val.toLowerCase() === "false") return false;
|
|
1425
|
-
}
|
|
1426
|
-
return val;
|
|
1427
|
-
}, import_v3.z.boolean()).openapi({
|
|
1428
|
-
title: "Boolean",
|
|
1429
|
-
example: true
|
|
1430
|
-
});
|
|
1431
|
-
date = import_v3.z.preprocess((value) => {
|
|
1432
|
-
try {
|
|
1433
|
-
switch (typeof value) {
|
|
1434
|
-
case "string":
|
|
1435
|
-
return new Date(value);
|
|
1436
|
-
case "number":
|
|
1437
|
-
return new Date(value);
|
|
1438
|
-
default:
|
|
1439
|
-
return value;
|
|
1447
|
+
}, import_v3.z.bigint())
|
|
1448
|
+
.openapi({
|
|
1449
|
+
title: 'BigInt',
|
|
1450
|
+
type: 'integer',
|
|
1451
|
+
format: 'int64',
|
|
1452
|
+
example: 123n
|
|
1453
|
+
});
|
|
1454
|
+
boolean = import_v3.z
|
|
1455
|
+
.preprocess((val) => {
|
|
1456
|
+
if (typeof val === 'string') {
|
|
1457
|
+
if (val.toLowerCase() === 'true') return true;
|
|
1458
|
+
if (val.toLowerCase() === 'false') return false;
|
|
1440
1459
|
}
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1460
|
+
return val;
|
|
1461
|
+
}, import_v3.z.boolean())
|
|
1462
|
+
.openapi({
|
|
1463
|
+
title: 'Boolean',
|
|
1464
|
+
example: true
|
|
1465
|
+
});
|
|
1466
|
+
date = import_v3.z
|
|
1467
|
+
.preprocess((value) => {
|
|
1468
|
+
try {
|
|
1469
|
+
switch (typeof value) {
|
|
1470
|
+
case 'string':
|
|
1471
|
+
return new Date(value);
|
|
1472
|
+
case 'number':
|
|
1473
|
+
return new Date(value);
|
|
1474
|
+
default:
|
|
1475
|
+
return value;
|
|
1476
|
+
}
|
|
1477
|
+
} catch {
|
|
1478
|
+
return value;
|
|
1479
|
+
}
|
|
1480
|
+
}, import_v3.z.date())
|
|
1481
|
+
.openapi({
|
|
1482
|
+
title: 'Date',
|
|
1483
|
+
type: 'string',
|
|
1484
|
+
format: 'date-time',
|
|
1485
|
+
example: '2025-05-16T21:13:04.123Z'
|
|
1486
|
+
});
|
|
1450
1487
|
symbol = import_v3.z.symbol().openapi({
|
|
1451
|
-
title:
|
|
1452
|
-
example: /* @__PURE__ */ Symbol(
|
|
1453
|
-
});
|
|
1454
|
-
nullish = import_v3.z.union([import_v3.z.void(), import_v3.z.null(), import_v3.z.undefined()]).openapi({
|
|
1455
|
-
title: "Nullish",
|
|
1456
|
-
type: "null",
|
|
1457
|
-
example: null
|
|
1488
|
+
title: 'Symbol',
|
|
1489
|
+
example: /* @__PURE__ */ Symbol('symbol')
|
|
1458
1490
|
});
|
|
1491
|
+
nullish = import_v3.z
|
|
1492
|
+
.union([import_v3.z.void(), import_v3.z.null(), import_v3.z.undefined()])
|
|
1493
|
+
.openapi({
|
|
1494
|
+
title: 'Nullish',
|
|
1495
|
+
type: 'null',
|
|
1496
|
+
example: null
|
|
1497
|
+
});
|
|
1459
1498
|
void = import_v3.z.void().openapi({
|
|
1460
|
-
title:
|
|
1461
|
-
type:
|
|
1499
|
+
title: 'Void',
|
|
1500
|
+
type: 'null',
|
|
1462
1501
|
example: void 0
|
|
1463
1502
|
});
|
|
1464
1503
|
null = import_v3.z.null().openapi({
|
|
1465
|
-
title:
|
|
1466
|
-
type:
|
|
1504
|
+
title: 'Null',
|
|
1505
|
+
type: 'null',
|
|
1467
1506
|
example: null
|
|
1468
1507
|
});
|
|
1469
1508
|
undefined = import_v3.z.undefined().openapi({
|
|
1470
|
-
title:
|
|
1471
|
-
type:
|
|
1509
|
+
title: 'Undefined',
|
|
1510
|
+
type: 'null',
|
|
1472
1511
|
example: void 0
|
|
1473
1512
|
});
|
|
1474
1513
|
any = import_v3.z.any().openapi({
|
|
1475
|
-
title:
|
|
1476
|
-
type:
|
|
1477
|
-
example:
|
|
1514
|
+
title: 'Any',
|
|
1515
|
+
type: 'object',
|
|
1516
|
+
example: 'any'
|
|
1478
1517
|
});
|
|
1479
1518
|
unknown = import_v3.z.unknown().openapi({
|
|
1480
|
-
title:
|
|
1481
|
-
type:
|
|
1482
|
-
example:
|
|
1519
|
+
title: 'Unknown',
|
|
1520
|
+
type: 'object',
|
|
1521
|
+
example: 'unknown'
|
|
1483
1522
|
});
|
|
1484
1523
|
never = import_v3.z.never().openapi({
|
|
1485
|
-
title:
|
|
1486
|
-
type:
|
|
1487
|
-
example:
|
|
1488
|
-
});
|
|
1489
|
-
binary = import_v3.z.string().transform((val) => new Uint8Array(Buffer.from(val, "base64"))).openapi({
|
|
1490
|
-
title: "Binary",
|
|
1491
|
-
type: "string",
|
|
1492
|
-
format: "binary",
|
|
1493
|
-
example: "a base-64 encodable string"
|
|
1524
|
+
title: 'Never',
|
|
1525
|
+
type: 'null',
|
|
1526
|
+
example: 'never'
|
|
1494
1527
|
});
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
}
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1528
|
+
binary = import_v3.z
|
|
1529
|
+
.string()
|
|
1530
|
+
.transform((val) => new Uint8Array(Buffer.from(val, 'base64')))
|
|
1531
|
+
.openapi({
|
|
1532
|
+
title: 'Binary',
|
|
1533
|
+
type: 'string',
|
|
1534
|
+
format: 'binary',
|
|
1535
|
+
example: 'a base-64 encodable string'
|
|
1536
|
+
});
|
|
1537
|
+
file = import_v3.z
|
|
1538
|
+
.union([
|
|
1539
|
+
import_v3.z.instanceof(Buffer),
|
|
1540
|
+
import_v3.z.instanceof(ArrayBuffer),
|
|
1541
|
+
import_v3.z.instanceof(Blob),
|
|
1542
|
+
import_v3.z.string()
|
|
1543
|
+
])
|
|
1544
|
+
.transform((val) => {
|
|
1545
|
+
if (val instanceof Buffer) {
|
|
1546
|
+
return new Blob([val]);
|
|
1547
|
+
}
|
|
1548
|
+
if (val instanceof ArrayBuffer) {
|
|
1549
|
+
return new Blob([val]);
|
|
1550
|
+
}
|
|
1551
|
+
if (val instanceof Blob) {
|
|
1552
|
+
return val;
|
|
1553
|
+
}
|
|
1554
|
+
if (typeof val === 'string') {
|
|
1555
|
+
return new Blob([val]);
|
|
1556
|
+
}
|
|
1511
1557
|
return new Blob([val]);
|
|
1512
|
-
}
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1558
|
+
})
|
|
1559
|
+
.refine((val) => val instanceof Blob, {
|
|
1560
|
+
message:
|
|
1561
|
+
'Invalid file type: expected Buffer, ArrayBuffer, Blob, or string'
|
|
1562
|
+
})
|
|
1563
|
+
.openapi({
|
|
1564
|
+
title: 'File',
|
|
1565
|
+
type: 'string',
|
|
1566
|
+
format: 'binary',
|
|
1567
|
+
example: 'a base-64 encodable blob or file'
|
|
1568
|
+
});
|
|
1522
1569
|
type = () => this.any;
|
|
1523
1570
|
/**
|
|
1524
1571
|
* Compiles schema if this exists, for optimal performance.
|
|
@@ -1535,7 +1582,11 @@ var ZodSchemaValidator = class {
|
|
|
1535
1582
|
* @returns {ZodResolve<T>} The resolved schema.
|
|
1536
1583
|
*/
|
|
1537
1584
|
schemify(schema) {
|
|
1538
|
-
if (
|
|
1585
|
+
if (
|
|
1586
|
+
typeof schema === 'string' ||
|
|
1587
|
+
typeof schema === 'number' ||
|
|
1588
|
+
typeof schema === 'boolean'
|
|
1589
|
+
) {
|
|
1539
1590
|
return import_v3.z.literal(schema);
|
|
1540
1591
|
}
|
|
1541
1592
|
if (schema instanceof import_v3.ZodType) {
|
|
@@ -1576,9 +1627,7 @@ var ZodSchemaValidator = class {
|
|
|
1576
1627
|
*/
|
|
1577
1628
|
union(schemas) {
|
|
1578
1629
|
const resolvedSchemas = schemas.map((schema) => this.schemify(schema));
|
|
1579
|
-
return import_v3.z.union(
|
|
1580
|
-
resolvedSchemas
|
|
1581
|
-
);
|
|
1630
|
+
return import_v3.z.union(resolvedSchemas);
|
|
1582
1631
|
}
|
|
1583
1632
|
/**
|
|
1584
1633
|
* Create a literal schema.
|
|
@@ -1594,9 +1643,7 @@ var ZodSchemaValidator = class {
|
|
|
1594
1643
|
* @returns {ZodUnion<UnionZodResolve<[T, T, ...T[]]>>} The enum schema.
|
|
1595
1644
|
*/
|
|
1596
1645
|
enum_(schemaEnum) {
|
|
1597
|
-
return this.union(
|
|
1598
|
-
Object.values(schemaEnum)
|
|
1599
|
-
);
|
|
1646
|
+
return this.union(Object.values(schemaEnum));
|
|
1600
1647
|
}
|
|
1601
1648
|
/**
|
|
1602
1649
|
* Create a function schema.
|
|
@@ -1607,7 +1654,10 @@ var ZodSchemaValidator = class {
|
|
|
1607
1654
|
function_(args, returnType) {
|
|
1608
1655
|
const schemaArgs = args.map((schema) => this.schemify(schema));
|
|
1609
1656
|
const schemaReturnType = this.schemify(returnType);
|
|
1610
|
-
return import_v3.z.function(
|
|
1657
|
+
return import_v3.z.function(
|
|
1658
|
+
import_v3.z.tuple(schemaArgs),
|
|
1659
|
+
schemaReturnType
|
|
1660
|
+
);
|
|
1611
1661
|
}
|
|
1612
1662
|
/**
|
|
1613
1663
|
* Create a record schema.
|
|
@@ -1665,31 +1715,33 @@ var ZodSchemaValidator = class {
|
|
|
1665
1715
|
parse(schema, value) {
|
|
1666
1716
|
const resolvedSchema = this.schemify(schema);
|
|
1667
1717
|
const result = resolvedSchema.safeParse(value);
|
|
1668
|
-
return result.success
|
|
1669
|
-
ok:
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1718
|
+
return result.success
|
|
1719
|
+
? { ok: true, value: result.data }
|
|
1720
|
+
: {
|
|
1721
|
+
ok: false,
|
|
1722
|
+
errors: result.error.errors.flatMap((error) => {
|
|
1723
|
+
switch (error.code) {
|
|
1724
|
+
case 'invalid_union':
|
|
1725
|
+
return error.unionErrors.flatMap((unionError, idx) =>
|
|
1726
|
+
unionError.errors.map((e) => ({
|
|
1727
|
+
path: [
|
|
1728
|
+
`Union Schema Variant ${idx}`,
|
|
1729
|
+
...error.path.map((p) => p.toString()),
|
|
1730
|
+
...e.path.map((p) => p.toString())
|
|
1731
|
+
],
|
|
1732
|
+
message: e.message
|
|
1733
|
+
}))
|
|
1734
|
+
);
|
|
1735
|
+
default:
|
|
1736
|
+
return [
|
|
1737
|
+
{
|
|
1738
|
+
path: error.path.map((p) => p.toString()),
|
|
1739
|
+
message: error.message
|
|
1740
|
+
}
|
|
1741
|
+
];
|
|
1742
|
+
}
|
|
1743
|
+
})
|
|
1744
|
+
};
|
|
1693
1745
|
}
|
|
1694
1746
|
/**
|
|
1695
1747
|
* Convert a schema to an OpenAPI schema object.
|
|
@@ -1749,6 +1801,7 @@ var RedisWorkerSchemas = (0, import_internal.serviceSchemaResolver)(
|
|
|
1749
1801
|
() => RedisWorkerOptionsSchema2
|
|
1750
1802
|
);
|
|
1751
1803
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1752
|
-
0 &&
|
|
1753
|
-
|
|
1754
|
-
|
|
1804
|
+
0 &&
|
|
1805
|
+
(module.exports = {
|
|
1806
|
+
RedisWorkerSchemas
|
|
1807
|
+
});
|