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