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