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