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