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