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