@forklaunch/implementation-worker-kafka 1.0.33 → 1.0.35

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.
@@ -15,7 +15,6 @@ var __copyProps = (to, from, except, desc) => {
15
15
  }
16
16
  return to;
17
17
  };
18
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
19
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
19
 
21
20
  // domain/schemas/index.ts
@@ -28,1737 +27,26 @@ module.exports = __toCommonJS(schemas_exports);
28
27
  // domain/schemas/kafka.schema.ts
29
28
  var import_internal = require("@forklaunch/internal");
30
29
 
31
- // ../../../node_modules/.pnpm/@forklaunch+validator@1.2.26/node_modules/@forklaunch/validator/lib/src/typebox/index.mjs
32
- var typebox_exports = {};
33
- __export(typebox_exports, {
34
- SchemaValidator: () => SchemaValidator,
35
- TypeboxSchemaValidator: () => TypeboxSchemaValidator,
36
- any: () => any,
37
- array: () => array,
38
- bigint: () => bigint,
39
- binary: () => binary,
40
- boolean: () => boolean,
41
- date: () => date,
42
- email: () => email,
43
- enum_: () => enum_,
44
- file: () => file,
45
- function_: () => function_,
46
- isSchema: () => isSchema,
47
- literal: () => literal,
48
- never: () => never,
49
- null_: () => null_,
50
- nullish: () => nullish,
51
- number: () => number,
52
- openapi: () => openapi,
53
- optional: () => optional,
54
- parse: () => parse,
55
- promise: () => promise,
56
- record: () => record,
57
- schemify: () => schemify,
58
- string: () => string,
59
- symbol: () => symbol,
60
- type: () => type,
61
- undefined_: () => undefined_,
62
- union: () => union,
63
- unknown: () => unknown,
64
- uri: () => uri,
65
- uuid: () => uuid,
66
- validate: () => validate,
67
- void_: () => void_
68
- });
69
- __reExport(typebox_exports, require("@sinclair/typebox"));
70
-
71
- // ../../../node_modules/.pnpm/@forklaunch+common@1.2.25/node_modules/@forklaunch/common/lib/index.mjs
72
- function deepCloneWithoutUndefined(obj, seen = /* @__PURE__ */ new WeakMap()) {
73
- if (obj === null || obj === void 0) {
74
- return obj;
75
- }
76
- if (typeof obj !== "object" && typeof obj !== "function") {
77
- return obj;
78
- }
79
- if (seen.has(obj)) {
80
- return seen.get(obj);
81
- }
82
- if (obj instanceof Date) {
83
- return new Date(obj.getTime());
84
- }
85
- if (obj instanceof RegExp) {
86
- return new RegExp(obj.source, obj.flags);
87
- }
88
- if (obj instanceof Map) {
89
- const clonedMap = /* @__PURE__ */ new Map();
90
- seen.set(obj, clonedMap);
91
- obj.forEach((value, key) => {
92
- if (value !== void 0) {
93
- clonedMap.set(key, deepCloneWithoutUndefined(value, seen));
94
- }
95
- });
96
- return clonedMap;
97
- }
98
- if (obj instanceof Set) {
99
- const clonedSet = /* @__PURE__ */ new Set();
100
- seen.set(obj, clonedSet);
101
- obj.forEach((value) => {
102
- if (value !== void 0) {
103
- clonedSet.add(deepCloneWithoutUndefined(value, seen));
104
- }
105
- });
106
- return clonedSet;
107
- }
108
- if (Array.isArray(obj)) {
109
- const clonedArray = [];
110
- seen.set(obj, clonedArray);
111
- for (const item of obj) {
112
- if (item !== void 0) {
113
- clonedArray.push(deepCloneWithoutUndefined(item, seen));
114
- }
115
- }
116
- return clonedArray;
117
- }
118
- if (typeof obj === "function") {
119
- return obj;
120
- }
121
- const proto = Object.getPrototypeOf(obj);
122
- const cloned = Object.create(proto);
123
- seen.set(obj, cloned);
124
- const allKeys = [
125
- ...Object.getOwnPropertyNames(obj),
126
- ...Object.getOwnPropertySymbols(obj)
127
- ];
128
- for (const key of allKeys) {
129
- const descriptor = Object.getOwnPropertyDescriptor(obj, key);
130
- if (!descriptor) continue;
131
- if ("value" in descriptor) {
132
- if (descriptor.value !== void 0) {
133
- Object.defineProperty(cloned, key, {
134
- ...descriptor,
135
- value: deepCloneWithoutUndefined(descriptor.value, seen)
136
- });
137
- }
138
- } else {
139
- Object.defineProperty(cloned, key, descriptor);
140
- }
141
- }
142
- return cloned;
143
- }
144
- var InMemoryBlob = class extends Blob {
145
- constructor(content) {
146
- super([content]);
147
- this.content = content;
148
- }
149
- content;
150
- };
151
-
152
- // ../../../node_modules/.pnpm/@forklaunch+validator@1.2.26/node_modules/@forklaunch/validator/lib/src/typebox/index.mjs
153
- var import_typebox = require("@sinclair/typebox");
154
- var import_compiler = require("@sinclair/typebox/compiler");
155
- var import_errors = require("@sinclair/typebox/errors");
156
- var import_value = require("@sinclair/typebox/value");
157
- import_typebox.FormatRegistry.Set("binary", (value) => typeof value === "string");
158
- import_typebox.TypeRegistry.Set("Blob", (_schema, value) => value instanceof Blob);
159
- import_typebox.TypeRegistry.Set(
160
- "ArrayBuffer",
161
- (_schema, value) => value instanceof ArrayBuffer
162
- );
163
- import_typebox.TypeRegistry.Set("Buffer", (_schema, value) => value instanceof Buffer);
164
- (0, import_errors.SetErrorFunction)((params) => {
165
- switch (params.errorType) {
166
- case import_errors.ValueErrorType.Union:
167
- case import_errors.ValueErrorType.Array:
168
- case import_errors.ValueErrorType.String:
169
- case import_errors.ValueErrorType.Number:
170
- return params.schema.errorType ? `Expected ${params.schema.errorType} value${params.schema.errorSuffix ? "s" : ""}` : (0, import_errors.DefaultErrorFunction)(params);
171
- default:
172
- return (0, import_errors.DefaultErrorFunction)(params);
173
- }
174
- });
175
- var TypeboxSchemaValidator = class {
176
- _Type = "TypeBox";
177
- _SchemaCatchall;
178
- _ValidSchemaObject;
179
- string = import_typebox.Type.String({
180
- example: "a string",
181
- title: "String"
182
- });
183
- uuid = import_typebox.Type.String({
184
- 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}$",
185
- errorType: "uuid",
186
- example: "a8b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6",
187
- title: "UUID"
188
- });
189
- email = import_typebox.Type.String({
190
- pattern: "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$",
191
- errorType: "email",
192
- example: "a@b.com",
193
- title: "Email"
194
- });
195
- uri = import_typebox.Type.String({
196
- pattern: "^[a-zA-Z][a-zA-Z\\d+-.]*:[^\\s]*$",
197
- errorType: "uri",
198
- example: "https://forklaunch.com",
199
- title: "URI"
200
- });
201
- number = import_typebox.Type.Transform(
202
- import_typebox.Type.Union(
203
- [
204
- import_typebox.Type.Number(),
205
- import_typebox.Type.String({ pattern: "^[0-9]+$" }),
206
- import_typebox.Type.Boolean(),
207
- import_typebox.Type.Null(),
208
- import_typebox.Type.BigInt(),
209
- import_typebox.Type.Date()
210
- ],
211
- {
212
- errorType: "number-like",
213
- example: 123,
214
- title: "Number"
215
- }
216
- )
217
- ).Decode((value) => {
218
- if (typeof value !== "number") {
219
- const num = Number(value);
220
- if (isNaN(num)) {
221
- throw new Error("Invalid number");
222
- } else {
223
- return num;
224
- }
225
- }
226
- return value;
227
- }).Encode(Number);
228
- bigint = import_typebox.Type.Transform(
229
- import_typebox.Type.Union(
230
- [
231
- import_typebox.Type.BigInt(),
232
- import_typebox.Type.Number(),
233
- import_typebox.Type.String({ pattern: "^[0-9]+n?$" }),
234
- import_typebox.Type.Boolean(),
235
- import_typebox.Type.Date()
236
- ],
237
- {
238
- errorType: "BigInt-like",
239
- example: 123n,
240
- title: "BigInt"
241
- }
242
- )
243
- ).Decode((value) => {
244
- if (typeof value !== "bigint") {
245
- try {
246
- if (value instanceof Date) {
247
- return BigInt(value.getTime());
248
- }
249
- return BigInt(value);
250
- } catch {
251
- throw new Error("Invalid bigint");
252
- }
253
- }
254
- return value;
255
- }).Encode(BigInt);
256
- boolean = import_typebox.Type.Transform(
257
- import_typebox.Type.Union(
258
- [
259
- import_typebox.Type.Boolean(),
260
- import_typebox.Type.String({
261
- pattern: "^(t|T)(r|R)(u|U)(e|E)$|^(f|F)(a|A)(l|L)(s|S)(e|E)$"
262
- })
263
- ],
264
- {
265
- errorType: "boolean-like",
266
- example: true,
267
- title: "Boolean"
268
- }
269
- )
270
- ).Decode((value) => {
271
- if (typeof value === "string") {
272
- if (value.toLowerCase() === "true") return true;
273
- return false;
274
- } else {
275
- return value;
276
- }
277
- }).Encode(Boolean);
278
- date = import_typebox.Type.Transform(
279
- import_typebox.Type.Union(
280
- [
281
- import_typebox.Type.String({
282
- 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+$"
283
- }),
284
- import_typebox.Type.Number(),
285
- import_typebox.Type.Date()
286
- ],
287
- {
288
- errorType: "date",
289
- example: "2025-05-16T21:13:04.123Z",
290
- title: "Date"
291
- }
292
- )
293
- ).Decode((value) => {
294
- if (value === null || typeof value === "boolean") {
295
- return /* @__PURE__ */ new Date(value ? 1 : 0);
296
- }
297
- return new Date(value);
298
- }).Encode((value) => new Date(value).toISOString());
299
- symbol = import_typebox.Type.Symbol({
300
- title: "Symbol"
301
- });
302
- nullish = import_typebox.Type.Union(
303
- [import_typebox.Type.Void(), import_typebox.Type.Null(), import_typebox.Type.Undefined()],
304
- {
305
- errorType: "nullish",
306
- type: "null",
307
- example: "null",
308
- title: "Nullish"
309
- }
310
- );
311
- void = import_typebox.Type.Void({
312
- type: "null",
313
- example: "void",
314
- title: "Void"
315
- });
316
- null = import_typebox.Type.Null({
317
- type: "null",
318
- example: "null",
319
- title: "Null"
320
- });
321
- undefined = import_typebox.Type.Undefined({
322
- type: "null",
323
- example: "undefined",
324
- title: "Undefined"
325
- });
326
- any = import_typebox.Type.Any({
327
- type: "object",
328
- example: "any",
329
- title: "Any"
330
- });
331
- unknown = import_typebox.Type.Unknown({
332
- type: "object",
333
- example: "unknown",
334
- title: "Unknown"
335
- });
336
- never = import_typebox.Type.Never({
337
- type: "null",
338
- example: "never",
339
- title: "Never"
340
- });
341
- binary = import_typebox.Type.Transform(
342
- import_typebox.Type.String({
343
- errorType: "binary",
344
- format: "binary",
345
- example: "a base-64 encodable string",
346
- title: "Binary"
347
- })
348
- ).Decode((value) => new Uint8Array(Buffer.from(value, "base64"))).Encode((value) => {
349
- if (value instanceof Buffer) {
350
- return String.fromCharCode(...new Uint8Array(value));
351
- }
352
- return "";
353
- });
354
- file = import_typebox.Type.Transform(
355
- import_typebox.Type.Union([
356
- import_typebox.Type.Unsafe({
357
- [import_typebox.Kind]: "Buffer",
358
- errorType: "binary",
359
- format: "binary",
360
- example: "a raw buffer or file stream",
361
- title: "File"
362
- }),
363
- import_typebox.Type.Unsafe({
364
- [import_typebox.Kind]: "ArrayBuffer",
365
- errorType: "binary",
366
- format: "binary",
367
- example: "an array buffer",
368
- title: "File"
369
- }),
370
- import_typebox.Type.Unsafe({
371
- [import_typebox.Kind]: "Blob",
372
- errorType: "binary",
373
- format: "binary",
374
- example: "a blob object",
375
- title: "File"
376
- }),
377
- import_typebox.Type.String({
378
- errorType: "binary",
379
- format: "binary",
380
- example: "a string content",
381
- title: "File"
382
- })
383
- ])
384
- ).Decode((value) => {
385
- if (value instanceof Buffer) {
386
- return new InMemoryBlob(value);
387
- }
388
- if (value instanceof ArrayBuffer) {
389
- return new InMemoryBlob(Buffer.from(value));
390
- }
391
- if (value instanceof Blob) {
392
- return value;
393
- }
394
- if (typeof value === "string") {
395
- return new InMemoryBlob(Buffer.from(value));
396
- }
397
- return new InMemoryBlob(Buffer.from(value));
398
- }).Encode((value) => value.content);
399
- type = () => this.any;
400
- /**
401
- * Extracts the error type of a schema for error messages.
402
- *
403
- * @param {TCatchall} schema - A schema that contains some type information.
404
- * @returns The type of the schema for error messages.
405
- */
406
- errorType(schema) {
407
- if (import_typebox.KindGuard.IsSchema(schema) && Object.hasOwn(schema, "errorType")) {
408
- return schema.errorType;
409
- } else if (import_typebox.KindGuard.IsLiteral(schema)) {
410
- return schema.const;
411
- }
412
- return schema[import_typebox.Kind].toLowerCase();
413
- }
414
- /**
415
- * Compiles schema if this exists, for optimal performance.
416
- *
417
- * @param {TObject<TProperties>} schema - The schema to compile.
418
- * @returns {TypeCheck<T>} - The compiled schema.
419
- */
420
- compile(schema) {
421
- return import_compiler.TypeCompiler.Compile(schema);
422
- }
423
- /**
424
- * Convert a schema to a TypeBox schema.
425
- * @param {TIdiomaticSchema} schema - The schema to convert.
426
- * @returns {TResolve<T>} The resolved schema.
427
- */
428
- schemify(schema) {
429
- if (typeof schema === "string" || typeof schema === "number" || typeof schema === "boolean") {
430
- return import_typebox.Type.Literal(schema);
431
- }
432
- if (import_typebox.KindGuard.IsSchema(schema) || schema instanceof import_compiler.TypeCheck) {
433
- return schema;
434
- }
435
- const newSchema = {};
436
- Object.getOwnPropertyNames(schema).forEach((key) => {
437
- if (import_typebox.KindGuard.IsSchema(schema[key]) || import_typebox.KindGuard.IsTransform(schema[key])) {
438
- newSchema[key] = schema[key];
439
- } else {
440
- const schemified = this.schemify(schema[key]);
441
- newSchema[key] = schemified;
442
- }
443
- });
444
- return import_typebox.Type.Object(newSchema);
445
- }
446
- /**
447
- * Make a schema optional.
448
- * @param {TIdiomaticSchema} schema - The schema to make optional.
449
- * @returns {TOptional<TResolve<T>>} The optional schema.
450
- */
451
- optional(schema) {
452
- const schemified = this.schemify(schema);
453
- return import_typebox.Type.Optional(schemified);
454
- }
455
- /**
456
- * Create an array schema.
457
- * @param {TIdiomaticSchema} schema - The schema to use for array items.
458
- * @returns {TArray<TResolve<T>>} The array schema.
459
- */
460
- array(schema) {
461
- const schemified = this.schemify(schema);
462
- return import_typebox.Type.Array(schemified, {
463
- errorType: `array of ${this.errorType(schemified)}`
464
- });
465
- }
466
- /**
467
- * Create a union schema.
468
- * @param {TUnionTupleContainer} schemas - The schemas to union.
469
- * @returns {TUnion<UnionTupleTResolve<T>>} The union schema.
470
- *
471
- * WARNING: If "nullish" or TUndefined is included in the union, the key will still be expected.
472
- * This is a limitation of TypeBox. Consider using "optional" instead.
473
- */
474
- union(schemas) {
475
- const unionTypes = schemas.map((schema) => {
476
- return this.schemify(schema);
477
- });
478
- return import_typebox.Type.Union(unionTypes, {
479
- errorType: `any of ${unionTypes.map((s) => this.errorType(s)).join(", ")}`,
480
- errorSuffix: true
481
- });
482
- }
483
- /**
484
- * Create a literal schema.
485
- * @param {LiteralSchema} value - The literal value.
486
- * @returns {TLiteral<T>} The literal schema.
487
- */
488
- literal(value) {
489
- return import_typebox.Type.Literal(value, {
490
- errorType: value
491
- });
492
- }
493
- /**
494
- * Create an enum schema.
495
- * @param {Record<string, LiteralSchema>} schemaEnum - The enum schema.
496
- * @returns {TUnion<UnionTupleTResolve<T[]>>} The enum schema.
497
- */
498
- enum_(schemaEnum) {
499
- return this.union(
500
- Object.values(schemaEnum).map((value) => this.literal(value))
501
- );
502
- }
503
- /**
504
- * Create a function schema.
505
- * @param {TSchema[]} args - The arguments of the function.
506
- * @param {TAny} returnType - The return type of the function.
507
- * @returns {TFunction<Args, ReturnType>} The function schema.
508
- */
509
- function_(args, returnType) {
510
- const schemaArgs = args.map((schema) => {
511
- return this.schemify(schema);
512
- });
513
- const schemaReturnType = this.schemify(returnType);
514
- return import_typebox.Type.Function(schemaArgs, schemaReturnType);
515
- }
516
- /**
517
- * Create a record schema.
518
- * @param {TIdiomaticSchema} key - The key schema.
519
- * @param {TIdiomaticSchema} value - The value schema.
520
- * @returns {TRecord<TResolve<Key>, TResolve<Value>>} The record schema.
521
- */
522
- record(key, value) {
523
- const keySchema = this.schemify(key);
524
- const valueSchema = this.schemify(value);
525
- return import_typebox.Type.Record(keySchema, valueSchema);
526
- }
527
- /**
528
- * Create a promise schema.
529
- * @param {TIdiomaticSchema} schema - The schema to use for the promise.
530
- * @returns {TPromise<TResolve<T>>} The promise schema.
531
- */
532
- promise(schema) {
533
- return import_typebox.Type.Promise(this.schemify(schema));
534
- }
535
- /**
536
- * Check if a value is a TypeBox object schema.
537
- * @param {unknown} value - The value to check.
538
- * @returns {boolean} True if the value is a TypeBox object schema.
539
- */
540
- isSchema(value) {
541
- return import_typebox.KindGuard.IsSchema(value);
542
- }
543
- /**
544
- * Check if a value is an instance of a TypeBox schema.
545
- * @param {object} value - The value to check.
546
- * @param {TCatchall} type - The schema to check against.
547
- * @returns {boolean} True if the value is an instance of the schema.
548
- */
549
- isInstanceOf(value, type22) {
550
- return typeof value === "object" && value != null && import_typebox.Kind in value && value[import_typebox.Kind] === type22[import_typebox.Kind];
551
- }
552
- /**
553
- * Validate a value against a schema.
554
- *
555
- * @param {TSchema} schema - The schema to validate against.
556
- * @param {unknown} value - The value to validate.
557
- * @returns {boolean} True if valid, otherwise false.
558
- */
559
- validate(schema, value) {
560
- if (schema instanceof import_compiler.TypeCheck) {
561
- return schema.Check(value);
562
- } else {
563
- const schemified = this.schemify(schema);
564
- return import_value.Value.Check(schemified, value);
565
- }
566
- }
567
- /**
568
- * Parse a value against a schema.
569
- *
570
- * @param {TSchema} schema - The schema to validate against.
571
- * @param {unknown} value - The value to validate.
572
- * @returns {ParseResult<TResolve<T>>} The parsing result.
573
- */
574
- parse(schema, value) {
575
- let errors = [];
576
- let conversion;
577
- if (schema instanceof import_compiler.TypeCheck) {
578
- if (schema.Check(value)) {
579
- conversion = schema.Decode(value);
580
- } else {
581
- errors = Array.from(schema.Errors(value));
582
- }
583
- } else {
584
- const schemified = this.schemify(schema);
585
- if (schemified[import_typebox.Kind] === "Unsafe") {
586
- try {
587
- if (value instanceof Buffer) {
588
- conversion = new InMemoryBlob(value);
589
- } else {
590
- errors = [
591
- {
592
- type: import_errors.ValueErrorType.String,
593
- schema: schemified,
594
- path: "",
595
- message: `Invalid file type: expected Buffer or string, got ${typeof value}`,
596
- value,
597
- errors: []
598
- }
599
- ];
600
- }
601
- } catch (err) {
602
- errors = [
603
- {
604
- type: import_errors.ValueErrorType.String,
605
- schema: schemified,
606
- path: "",
607
- message: err instanceof Error ? err.message : "Invalid file type",
608
- value,
609
- errors: []
610
- }
611
- ];
612
- }
613
- } else {
614
- if (import_value.Value.Check(schemified, value)) {
615
- conversion = import_value.Value.Decode(schemified, value);
616
- } else {
617
- errors = Array.from(import_value.Value.Errors(schemified, value));
618
- }
619
- }
620
- }
621
- return errors != null && errors.length === 0 ? {
622
- ok: true,
623
- value: conversion
624
- } : {
625
- ok: false,
626
- errors: errors.flatMap((error) => {
627
- if (error.type === import_errors.ValueErrorType.Union && error.schema.errorType?.includes("any of")) {
628
- return error.errors.flatMap(
629
- (e, idx) => Array.from(e).map((e2) => ({
630
- path: [
631
- `Union Schema Variant ${idx}`,
632
- ...error.path.split("/").slice(1),
633
- ...e2.path.split("/").slice(1)
634
- ],
635
- message: e2.message
636
- }))
637
- );
638
- } else {
639
- return [
640
- {
641
- path: error.path.split("/").slice(1),
642
- message: error.message
643
- }
644
- ];
645
- }
646
- })
647
- };
648
- }
649
- /**
650
- * Convert a schema to an OpenAPI schema object.
651
- * @param {TIdiomaticSchema | TCatchall} schema - The schema to convert.
652
- * @returns {SchemaObject} The OpenAPI schema object.
653
- */
654
- openapi(schema) {
655
- const schemified = this.schemify(schema);
656
- let processedSchema;
657
- if (import_typebox.KindGuard.IsDate(schemified)) {
658
- processedSchema = import_typebox.Type.String({
659
- format: "date-time"
660
- });
661
- } else {
662
- processedSchema = deepCloneWithoutUndefined(schemified);
663
- }
664
- const newSchema = Object.assign({}, processedSchema);
665
- if (Object.hasOwn(newSchema, "properties")) {
666
- if (newSchema.properties) {
667
- Object.entries({ ...processedSchema.properties }).forEach(
668
- ([key, value]) => {
669
- if (import_typebox.KindGuard.IsSchema(value) && newSchema.properties) {
670
- newSchema.properties[key] = this.openapi(value);
671
- }
672
- }
673
- );
674
- }
675
- }
676
- if (Object.hasOwn(newSchema, "items")) {
677
- newSchema.items = this.openapi(newSchema.items);
678
- }
679
- if (Array.isArray(newSchema.anyOf)) {
680
- newSchema.anyOf = newSchema.anyOf.map(
681
- (item) => this.openapi(item)
682
- );
683
- }
684
- if (Array.isArray(newSchema.oneOf)) {
685
- newSchema.oneOf = newSchema.oneOf.map(
686
- (item) => this.openapi(item)
687
- );
688
- }
689
- if ("errorType" in newSchema) {
690
- delete newSchema["errorType"];
691
- }
692
- return newSchema;
693
- }
694
- };
695
- var SchemaValidator = () => new TypeboxSchemaValidator();
696
- var StaticSchemaValidator = SchemaValidator();
697
- var string = StaticSchemaValidator.string;
698
- var uuid = StaticSchemaValidator.uuid;
699
- var uri = StaticSchemaValidator.uri;
700
- var email = StaticSchemaValidator.email;
701
- var number = StaticSchemaValidator.number;
702
- var bigint = StaticSchemaValidator.bigint;
703
- var boolean = StaticSchemaValidator.boolean;
704
- var date = StaticSchemaValidator.date;
705
- var symbol = StaticSchemaValidator.symbol;
706
- var nullish = StaticSchemaValidator.nullish;
707
- var void_ = StaticSchemaValidator.void;
708
- var null_ = StaticSchemaValidator.null;
709
- var undefined_ = StaticSchemaValidator.undefined;
710
- var any = StaticSchemaValidator.any;
711
- var unknown = StaticSchemaValidator.unknown;
712
- var never = StaticSchemaValidator.never;
713
- var binary = StaticSchemaValidator.binary;
714
- var file = StaticSchemaValidator.file;
715
- var type = StaticSchemaValidator.type;
716
- var schemify = StaticSchemaValidator.schemify.bind(StaticSchemaValidator);
717
- var optional = StaticSchemaValidator.optional.bind(StaticSchemaValidator);
718
- var array = StaticSchemaValidator.array.bind(StaticSchemaValidator);
719
- var union = StaticSchemaValidator.union.bind(StaticSchemaValidator);
720
- var literal = StaticSchemaValidator.literal.bind(StaticSchemaValidator);
721
- var enum_ = StaticSchemaValidator.enum_.bind(StaticSchemaValidator);
722
- var function_ = StaticSchemaValidator.function_.bind(StaticSchemaValidator);
723
- var record = StaticSchemaValidator.record.bind(StaticSchemaValidator);
724
- var promise = StaticSchemaValidator.promise.bind(StaticSchemaValidator);
725
- var isSchema = StaticSchemaValidator.isSchema.bind(StaticSchemaValidator);
726
- var validate = StaticSchemaValidator.validate.bind(StaticSchemaValidator);
727
- var parse = StaticSchemaValidator.parse.bind(StaticSchemaValidator);
728
- var openapi = StaticSchemaValidator.openapi.bind(StaticSchemaValidator);
729
-
730
30
  // domain/schemas/typebox/kafkaWorker.schema.ts
31
+ var import_typebox = require("@forklaunch/validator/typebox");
731
32
  var KafkaWorkerOptionsSchema = {
732
- brokers: array(string),
733
- clientId: string,
734
- groupId: string,
735
- retries: number,
736
- interval: number,
737
- peekCount: number
738
- };
739
-
740
- // ../../../node_modules/.pnpm/@forklaunch+validator@1.2.26/node_modules/@forklaunch/validator/lib/src/zod/index.mjs
741
- var import_v3 = require("zod/v3");
742
-
743
- // ../../../node_modules/.pnpm/ts-deepmerge@8.0.0/node_modules/ts-deepmerge/esm/index.js
744
- var isObject = (obj) => {
745
- if (typeof obj === "object" && obj !== null) {
746
- if (typeof Object.getPrototypeOf === "function") {
747
- const prototype = Object.getPrototypeOf(obj);
748
- return prototype === Object.prototype || prototype === null;
749
- }
750
- return Object.prototype.toString.call(obj) === "[object Object]";
751
- }
752
- return false;
753
- };
754
- var UNSAFE_KEYS = /* @__PURE__ */ new Set([
755
- "__proto__",
756
- "constructor",
757
- "prototype",
758
- "toString",
759
- "valueOf",
760
- "hasOwnProperty",
761
- "isPrototypeOf",
762
- "propertyIsEnumerable",
763
- "toLocaleString"
764
- ]);
765
- var merge = (...objects) => objects.reduce((result, current) => {
766
- if (current === void 0) {
767
- return result;
768
- }
769
- if (Array.isArray(current)) {
770
- throw new TypeError("Arguments provided to ts-deepmerge must be objects, not arrays.");
771
- }
772
- Object.keys(current).forEach((key) => {
773
- if (UNSAFE_KEYS.has(key)) {
774
- return;
775
- }
776
- if (Array.isArray(result[key]) && Array.isArray(current[key])) {
777
- result[key] = merge.options.mergeArrays ? merge.options.uniqueArrayItems ? Array.from(new Set(result[key].concat(current[key]))) : [...result[key], ...current[key]] : current[key];
778
- } else if (isObject(result[key]) && isObject(current[key])) {
779
- result[key] = merge(result[key], current[key]);
780
- } else if (!isObject(result[key]) && isObject(current[key])) {
781
- result[key] = merge(current[key], void 0);
782
- } else {
783
- result[key] = current[key] === void 0 ? merge.options.allowUndefinedOverrides ? current[key] : result[key] : current[key];
784
- }
785
- });
786
- return result;
787
- }, {});
788
- var defaultOptions = {
789
- allowUndefinedOverrides: true,
790
- mergeArrays: true,
791
- uniqueArrayItems: true
792
- };
793
- merge.options = defaultOptions;
794
- merge.withOptions = (options, ...objects) => {
795
- merge.options = Object.assign(Object.assign({}, defaultOptions), options);
796
- const result = merge(...objects);
797
- merge.options = defaultOptions;
798
- return result;
799
- };
800
-
801
- // ../../../node_modules/.pnpm/@forklaunch+validator@1.2.26/node_modules/@forklaunch/validator/lib/src/zod/index.mjs
802
- var import_v32 = require("zod/v3");
803
- function extendApi(schema, schemaObject = {}) {
804
- const This = schema.constructor;
805
- const newSchema = new This(schema._def);
806
- newSchema.metaOpenApi = Object.assign(
807
- {},
808
- schema.metaOpenApi || {},
809
- schemaObject
810
- );
811
- return newSchema;
812
- }
813
- function iterateZodObject({
814
- zodRef,
815
- useOutput,
816
- hideDefinitions,
817
- openApiVersion
818
- }) {
819
- const reduced = Object.keys(zodRef.shape).filter((key) => hideDefinitions?.includes(key) === false).reduce(
820
- (carry, key) => ({
821
- ...carry,
822
- [key]: generateSchema(zodRef.shape[key], useOutput, openApiVersion)
823
- }),
824
- {}
825
- );
826
- return reduced;
827
- }
828
- function typeFormat(type22, openApiVersion) {
829
- return openApiVersion === "3.0" ? type22 : [type22];
830
- }
831
- function parseTransformation({
832
- zodRef,
833
- schemas,
834
- useOutput,
835
- openApiVersion
836
- }) {
837
- const input = generateSchema(zodRef._def.schema, useOutput, openApiVersion);
838
- let output = "undefined";
839
- if (useOutput && zodRef._def.effect) {
840
- const effect = zodRef._def.effect.type === "transform" ? zodRef._def.effect : null;
841
- if (effect && "transform" in effect) {
842
- try {
843
- const type22 = Array.isArray(input.type) ? input.type[0] : input.type;
844
- output = typeof effect.transform(
845
- ["integer", "number"].includes(`${type22}`) ? 0 : "string" === type22 ? "" : "boolean" === type22 ? false : "object" === type22 ? {} : "null" === type22 ? null : "array" === type22 ? [] : void 0,
846
- { addIssue: () => void 0, path: [] }
847
- // TODO: Discover if context is necessary here
848
- );
849
- } catch {
850
- }
851
- }
852
- }
853
- const outputType = output;
854
- return merge(
855
- {
856
- ...zodRef.description ? { description: zodRef.description } : {},
857
- ...input,
858
- ...["number", "string", "boolean", "null"].includes(output) ? {
859
- type: typeFormat(outputType, openApiVersion)
860
- } : {}
861
- },
862
- ...schemas
863
- );
864
- }
865
- function parseString({
866
- zodRef,
867
- schemas,
868
- openApiVersion
869
- }) {
870
- const baseSchema = {
871
- type: typeFormat("string", openApiVersion)
872
- };
873
- const { checks = [] } = zodRef._def;
874
- checks.forEach((item) => {
875
- switch (item.kind) {
876
- case "email":
877
- baseSchema.format = "email";
878
- break;
879
- case "uuid":
880
- baseSchema.format = "uuid";
881
- break;
882
- case "cuid":
883
- baseSchema.format = "cuid";
884
- break;
885
- case "url":
886
- baseSchema.format = "uri";
887
- break;
888
- case "datetime":
889
- baseSchema.format = "date-time";
890
- break;
891
- case "length":
892
- baseSchema.minLength = item.value;
893
- baseSchema.maxLength = item.value;
894
- break;
895
- case "max":
896
- baseSchema.maxLength = item.value;
897
- break;
898
- case "min":
899
- baseSchema.minLength = item.value;
900
- break;
901
- case "regex":
902
- baseSchema.pattern = item.regex.source;
903
- break;
904
- }
905
- });
906
- return merge(
907
- baseSchema,
908
- zodRef.description ? { description: zodRef.description } : {},
909
- ...schemas
910
- );
911
- }
912
- function parseNumber({
913
- zodRef,
914
- schemas,
915
- openApiVersion
916
- }) {
917
- const baseSchema = {
918
- type: typeFormat("number", openApiVersion)
919
- };
920
- const { checks = [] } = zodRef._def;
921
- checks.forEach((item) => {
922
- switch (item.kind) {
923
- case "max":
924
- if (item.inclusive || openApiVersion === "3.0") {
925
- baseSchema.maximum = item.value;
926
- }
927
- if (!item.inclusive) {
928
- if (openApiVersion === "3.0") {
929
- baseSchema.exclusiveMaximum = true;
930
- } else {
931
- baseSchema.exclusiveMaximum = item.value;
932
- }
933
- }
934
- break;
935
- case "min":
936
- if (item.inclusive || openApiVersion === "3.0") {
937
- baseSchema.minimum = item.value;
938
- }
939
- if (!item.inclusive) {
940
- if (openApiVersion === "3.0") {
941
- baseSchema.exclusiveMinimum = true;
942
- } else {
943
- baseSchema.exclusiveMinimum = item.value;
944
- }
945
- }
946
- break;
947
- case "int":
948
- baseSchema.type = typeFormat("integer", openApiVersion);
949
- break;
950
- case "multipleOf":
951
- baseSchema.multipleOf = item.value;
952
- break;
953
- }
954
- });
955
- return merge(
956
- baseSchema,
957
- zodRef.description ? { description: zodRef.description } : {},
958
- ...schemas
959
- );
960
- }
961
- function getExcludedDefinitionsFromSchema(schemas) {
962
- const excludedDefinitions = [];
963
- for (const schema of schemas) {
964
- if (Array.isArray(schema.hideDefinitions)) {
965
- excludedDefinitions.push(...schema.hideDefinitions);
966
- }
967
- }
968
- return excludedDefinitions;
969
- }
970
- function parseObject({
971
- zodRef,
972
- schemas,
973
- useOutput,
974
- hideDefinitions,
975
- openApiVersion
976
- }) {
977
- let additionalProperties;
978
- if (!(zodRef._def.catchall instanceof import_v32.z.ZodNever || zodRef._def.catchall?._def.typeName === "ZodNever"))
979
- additionalProperties = generateSchema(
980
- zodRef._def.catchall,
981
- useOutput,
982
- openApiVersion
983
- );
984
- else if (zodRef._def.unknownKeys === "passthrough")
985
- additionalProperties = true;
986
- else if (zodRef._def.unknownKeys === "strict") additionalProperties = false;
987
- additionalProperties = additionalProperties != null ? { additionalProperties } : {};
988
- const requiredProperties = Object.keys(
989
- zodRef.shape
990
- ).filter((key) => {
991
- const item = zodRef.shape[key];
992
- return !(item.isOptional() || item instanceof import_v32.z.ZodDefault || item._def.typeName === "ZodDefault") && !(item instanceof import_v32.z.ZodNever || item._def.typeName === "ZodDefault");
993
- });
994
- const required = requiredProperties.length > 0 ? { required: requiredProperties } : {};
995
- return merge(
996
- {
997
- type: typeFormat("object", openApiVersion),
998
- properties: iterateZodObject({
999
- zodRef,
1000
- schemas,
1001
- useOutput,
1002
- hideDefinitions: getExcludedDefinitionsFromSchema(schemas),
1003
- openApiVersion
1004
- }),
1005
- ...required,
1006
- ...additionalProperties,
1007
- ...hideDefinitions
1008
- },
1009
- zodRef.description ? { description: zodRef.description, hideDefinitions } : {},
1010
- ...schemas
1011
- );
1012
- }
1013
- function parseRecord({
1014
- zodRef,
1015
- schemas,
1016
- useOutput,
1017
- openApiVersion
1018
- }) {
1019
- return merge(
1020
- {
1021
- type: typeFormat("object", openApiVersion),
1022
- additionalProperties: zodRef._def.valueType instanceof import_v32.z.ZodUnknown ? {} : generateSchema(zodRef._def.valueType, useOutput, openApiVersion)
1023
- },
1024
- zodRef.description ? { description: zodRef.description } : {},
1025
- ...schemas
1026
- );
1027
- }
1028
- function parseBigInt({
1029
- zodRef,
1030
- schemas,
1031
- openApiVersion
1032
- }) {
1033
- return merge(
1034
- {
1035
- type: typeFormat("integer", openApiVersion),
1036
- format: "int64"
1037
- },
1038
- zodRef.description ? { description: zodRef.description } : {},
1039
- ...schemas
1040
- );
1041
- }
1042
- function parseBoolean({
1043
- zodRef,
1044
- schemas,
1045
- openApiVersion
1046
- }) {
1047
- return merge(
1048
- { type: typeFormat("boolean", openApiVersion) },
1049
- zodRef.description ? { description: zodRef.description } : {},
1050
- ...schemas
1051
- );
1052
- }
1053
- function parseDate({
1054
- zodRef,
1055
- schemas,
1056
- openApiVersion
1057
- }) {
1058
- return merge(
1059
- {
1060
- type: typeFormat("string", openApiVersion),
1061
- format: "date-time"
1062
- },
1063
- zodRef.description ? { description: zodRef.description } : {},
1064
- ...schemas
1065
- );
1066
- }
1067
- function parseNull({
1068
- zodRef,
1069
- schemas,
1070
- openApiVersion
1071
- }) {
1072
- return merge(
1073
- openApiVersion === "3.0" ? { type: "null" } : {
1074
- type: ["string", "null"],
1075
- enum: ["null"]
1076
- },
1077
- zodRef.description ? { description: zodRef.description } : {},
1078
- ...schemas
1079
- );
1080
- }
1081
- function parseOptional({
1082
- schemas,
1083
- zodRef,
1084
- useOutput,
1085
- openApiVersion
1086
- }) {
1087
- return merge(
1088
- generateSchema(zodRef.unwrap(), useOutput, openApiVersion),
1089
- zodRef.description ? { description: zodRef.description } : {},
1090
- ...schemas
1091
- );
1092
- }
1093
- function parseNullable({
1094
- schemas,
1095
- zodRef,
1096
- useOutput,
1097
- openApiVersion
1098
- }) {
1099
- const schema = generateSchema(zodRef.unwrap(), useOutput, openApiVersion);
1100
- return merge(
1101
- schema,
1102
- openApiVersion === "3.0" ? { nullable: true } : { type: typeFormat("null", openApiVersion) },
1103
- zodRef.description ? { description: zodRef.description } : {},
1104
- ...schemas
1105
- );
1106
- }
1107
- function parseDefault({
1108
- schemas,
1109
- zodRef,
1110
- useOutput,
1111
- openApiVersion
1112
- }) {
1113
- return merge(
1114
- {
1115
- default: zodRef._def.defaultValue(),
1116
- ...generateSchema(zodRef._def.innerType, useOutput, openApiVersion)
1117
- },
1118
- zodRef.description ? { description: zodRef.description } : {},
1119
- ...schemas
1120
- );
1121
- }
1122
- function parseArray({
1123
- schemas,
1124
- zodRef,
1125
- useOutput,
1126
- openApiVersion
1127
- }) {
1128
- const constraints = {};
1129
- if (zodRef._def.exactLength != null) {
1130
- constraints.minItems = zodRef._def.exactLength.value;
1131
- constraints.maxItems = zodRef._def.exactLength.value;
1132
- }
1133
- if (zodRef._def.minLength != null)
1134
- constraints.minItems = zodRef._def.minLength.value;
1135
- if (zodRef._def.maxLength != null)
1136
- constraints.maxItems = zodRef._def.maxLength.value;
1137
- return merge(
1138
- {
1139
- type: typeFormat("array", openApiVersion),
1140
- items: generateSchema(zodRef.element, useOutput, openApiVersion),
1141
- ...constraints
1142
- },
1143
- zodRef.description ? { description: zodRef.description } : {},
1144
- ...schemas
1145
- );
1146
- }
1147
- function parseLiteral({
1148
- schemas,
1149
- zodRef,
1150
- openApiVersion
1151
- }) {
1152
- const type22 = typeof zodRef._def.value;
1153
- return merge(
1154
- {
1155
- type: typeFormat(type22, openApiVersion),
1156
- enum: [zodRef._def.value]
1157
- },
1158
- zodRef.description ? { description: zodRef.description } : {},
1159
- ...schemas
1160
- );
1161
- }
1162
- function parseEnum({
1163
- schemas,
1164
- zodRef,
1165
- openApiVersion
1166
- }) {
1167
- const type22 = typeof Object.values(zodRef._def.values)[0];
1168
- return merge(
1169
- {
1170
- type: typeFormat(type22, openApiVersion),
1171
- enum: Object.values(zodRef._def.values)
1172
- },
1173
- zodRef.description ? { description: zodRef.description } : {},
1174
- ...schemas
1175
- );
1176
- }
1177
- function parseIntersection({
1178
- schemas,
1179
- zodRef,
1180
- useOutput,
1181
- openApiVersion
1182
- }) {
1183
- return merge(
1184
- {
1185
- allOf: [
1186
- generateSchema(zodRef._def.left, useOutput, openApiVersion),
1187
- generateSchema(zodRef._def.right, useOutput, openApiVersion)
1188
- ]
1189
- },
1190
- zodRef.description ? { description: zodRef.description } : {},
1191
- ...schemas
1192
- );
1193
- }
1194
- function parseUnion({
1195
- schemas,
1196
- zodRef,
1197
- useOutput,
1198
- openApiVersion
1199
- }) {
1200
- const contents = zodRef._def.options;
1201
- if (contents.reduce(
1202
- (prev, content) => prev && content._def.typeName === "ZodLiteral",
1203
- true
1204
- )) {
1205
- const literals = contents;
1206
- const type22 = literals.reduce(
1207
- (prev, content) => !prev || prev === typeof content._def.value ? typeof content._def.value : null,
1208
- null
1209
- );
1210
- if (type22) {
1211
- return merge(
1212
- {
1213
- type: typeFormat(type22, openApiVersion),
1214
- enum: literals.map((literal22) => literal22._def.value)
1215
- },
1216
- zodRef.description ? { description: zodRef.description } : {},
1217
- ...schemas
1218
- );
1219
- }
1220
- }
1221
- const oneOfContents = openApiVersion === "3.0" ? contents.filter((content) => content._def.typeName !== "ZodNull") : contents;
1222
- const contentsHasNull = contents.length != oneOfContents.length;
1223
- return merge(
1224
- {
1225
- oneOf: oneOfContents.map(
1226
- (schema) => generateSchema(schema, useOutput, openApiVersion)
1227
- )
1228
- },
1229
- contentsHasNull ? { nullable: true } : {},
1230
- zodRef.description ? { description: zodRef.description } : {},
1231
- ...schemas
1232
- );
1233
- }
1234
- function parseDiscriminatedUnion({
1235
- schemas,
1236
- zodRef,
1237
- useOutput,
1238
- openApiVersion
1239
- }) {
1240
- return merge(
1241
- {
1242
- discriminator: {
1243
- propertyName: zodRef._def.discriminator
1244
- },
1245
- oneOf: Array.from(
1246
- zodRef._def.options.values()
1247
- ).map((schema) => generateSchema(schema, useOutput, openApiVersion))
1248
- },
1249
- zodRef.description ? { description: zodRef.description } : {},
1250
- ...schemas
1251
- );
1252
- }
1253
- function parseNever({
1254
- zodRef,
1255
- schemas
1256
- }) {
1257
- return merge(
1258
- { readOnly: true },
1259
- zodRef.description ? { description: zodRef.description } : {},
1260
- ...schemas
1261
- );
1262
- }
1263
- function parseBranded({
1264
- schemas,
1265
- zodRef,
1266
- useOutput,
1267
- openApiVersion
1268
- }) {
1269
- return merge(
1270
- generateSchema(zodRef._def.type, useOutput, openApiVersion),
1271
- ...schemas
1272
- );
1273
- }
1274
- function catchAllParser({
1275
- zodRef,
1276
- schemas
1277
- }) {
1278
- return merge(
1279
- zodRef.description ? { description: zodRef.description } : {},
1280
- ...schemas
1281
- );
1282
- }
1283
- function parsePipeline({
1284
- schemas,
1285
- zodRef,
1286
- useOutput,
1287
- openApiVersion
1288
- }) {
1289
- return merge(
1290
- generateSchema(
1291
- useOutput ? zodRef._def.out : zodRef._def.in,
1292
- useOutput,
1293
- openApiVersion
1294
- ),
1295
- ...schemas
1296
- );
1297
- }
1298
- function parseReadonly({
1299
- zodRef,
1300
- useOutput,
1301
- schemas,
1302
- openApiVersion
1303
- }) {
1304
- return merge(
1305
- generateSchema(zodRef._def.innerType, useOutput, openApiVersion),
1306
- zodRef.description ? { description: zodRef.description } : {},
1307
- ...schemas
1308
- );
1309
- }
1310
- var workerMap = {
1311
- ZodObject: parseObject,
1312
- ZodRecord: parseRecord,
1313
- ZodString: parseString,
1314
- ZodNumber: parseNumber,
1315
- ZodBigInt: parseBigInt,
1316
- ZodBoolean: parseBoolean,
1317
- ZodDate: parseDate,
1318
- ZodNull: parseNull,
1319
- ZodOptional: parseOptional,
1320
- ZodNullable: parseNullable,
1321
- ZodDefault: parseDefault,
1322
- ZodArray: parseArray,
1323
- ZodLiteral: parseLiteral,
1324
- ZodEnum: parseEnum,
1325
- ZodNativeEnum: parseEnum,
1326
- ZodTransformer: parseTransformation,
1327
- ZodEffects: parseTransformation,
1328
- ZodIntersection: parseIntersection,
1329
- ZodUnion: parseUnion,
1330
- ZodDiscriminatedUnion: parseDiscriminatedUnion,
1331
- ZodNever: parseNever,
1332
- ZodBranded: parseBranded,
1333
- // TODO Transform the rest to schemas
1334
- ZodUndefined: catchAllParser,
1335
- // TODO: `prefixItems` is allowed in OpenAPI 3.1 which can be used to create tuples
1336
- ZodTuple: catchAllParser,
1337
- ZodMap: catchAllParser,
1338
- ZodFunction: catchAllParser,
1339
- ZodLazy: catchAllParser,
1340
- ZodPromise: catchAllParser,
1341
- ZodAny: catchAllParser,
1342
- ZodUnknown: catchAllParser,
1343
- ZodVoid: catchAllParser,
1344
- ZodPipeline: parsePipeline,
1345
- ZodReadonly: parseReadonly
1346
- };
1347
- function generateSchema(zodRef, useOutput = false, openApiVersion = "3.1") {
1348
- const { metaOpenApi = {} } = zodRef;
1349
- const schemas = [
1350
- ...Array.isArray(metaOpenApi) ? metaOpenApi : [metaOpenApi]
1351
- ];
1352
- try {
1353
- const typeName = zodRef._def.typeName;
1354
- if (typeName in workerMap) {
1355
- return workerMap[typeName]({
1356
- zodRef,
1357
- schemas,
1358
- useOutput,
1359
- openApiVersion
1360
- });
1361
- }
1362
- return catchAllParser({ zodRef, schemas, openApiVersion });
1363
- } catch (err) {
1364
- console.error(err);
1365
- return catchAllParser({ zodRef, schemas, openApiVersion });
1366
- }
1367
- }
1368
- function extendZodWithOpenApi(zod, forceOverride = false) {
1369
- if (!forceOverride && typeof zod.ZodSchema.prototype.openapi !== "undefined") {
1370
- return;
1371
- }
1372
- zod.ZodSchema.prototype.openapi = function(metadata) {
1373
- return extendApi(this, metadata);
1374
- };
1375
- }
1376
- extendZodWithOpenApi(import_v3.z);
1377
- var ZodSchemaValidator = class {
1378
- _Type = "Zod";
1379
- _SchemaCatchall;
1380
- _ValidSchemaObject;
1381
- string = import_v3.z.string().openapi({
1382
- title: "String",
1383
- example: "a string"
1384
- });
1385
- uuid = import_v3.z.string().uuid().openapi({
1386
- title: "UUID",
1387
- format: "uuid",
1388
- 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}$",
1389
- example: "a8b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6"
1390
- });
1391
- email = import_v3.z.string().email().openapi({
1392
- title: "Email",
1393
- format: "email",
1394
- pattern: "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$",
1395
- example: "a@b.com"
1396
- });
1397
- uri = import_v3.z.string().url().openapi({
1398
- title: "URI",
1399
- format: "uri",
1400
- pattern: "^[a-zA-Z][a-zA-Z\\d+-.]*:[^\\s]*$",
1401
- example: "https://forklaunch.com"
1402
- });
1403
- number = import_v3.z.preprocess((value) => {
1404
- try {
1405
- return Number(value);
1406
- } catch {
1407
- return value;
1408
- }
1409
- }, import_v3.z.number()).openapi({
1410
- title: "Number",
1411
- example: 123
1412
- });
1413
- bigint = import_v3.z.preprocess((value) => {
1414
- try {
1415
- if (value instanceof Date) {
1416
- return BigInt(value.getTime());
1417
- }
1418
- switch (typeof value) {
1419
- case "number":
1420
- case "string":
1421
- return BigInt(value);
1422
- case "boolean":
1423
- return BigInt(value ? 1 : 0);
1424
- default:
1425
- return value;
1426
- }
1427
- } catch {
1428
- return value;
1429
- }
1430
- }, import_v3.z.bigint()).openapi({
1431
- title: "BigInt",
1432
- type: "integer",
1433
- format: "int64",
1434
- example: 123n
1435
- });
1436
- boolean = import_v3.z.preprocess((val) => {
1437
- if (typeof val === "string") {
1438
- if (val.toLowerCase() === "true") return true;
1439
- if (val.toLowerCase() === "false") return false;
1440
- }
1441
- return val;
1442
- }, import_v3.z.boolean()).openapi({
1443
- title: "Boolean",
1444
- example: true
1445
- });
1446
- date = import_v3.z.preprocess((value) => {
1447
- try {
1448
- switch (typeof value) {
1449
- case "string":
1450
- return new Date(value);
1451
- case "number":
1452
- return new Date(value);
1453
- default:
1454
- return value;
1455
- }
1456
- } catch {
1457
- return value;
1458
- }
1459
- }, import_v3.z.date()).openapi({
1460
- title: "Date",
1461
- type: "string",
1462
- format: "date-time",
1463
- example: "2025-05-16T21:13:04.123Z"
1464
- });
1465
- symbol = import_v3.z.symbol().openapi({
1466
- title: "Symbol",
1467
- example: /* @__PURE__ */ Symbol("symbol")
1468
- });
1469
- nullish = import_v3.z.union([import_v3.z.void(), import_v3.z.null(), import_v3.z.undefined()]).openapi({
1470
- title: "Nullish",
1471
- type: "null",
1472
- example: null
1473
- });
1474
- void = import_v3.z.void().openapi({
1475
- title: "Void",
1476
- type: "null",
1477
- example: void 0
1478
- });
1479
- null = import_v3.z.null().openapi({
1480
- title: "Null",
1481
- type: "null",
1482
- example: null
1483
- });
1484
- undefined = import_v3.z.undefined().openapi({
1485
- title: "Undefined",
1486
- type: "null",
1487
- example: void 0
1488
- });
1489
- any = import_v3.z.any().openapi({
1490
- title: "Any",
1491
- type: "object",
1492
- example: "any"
1493
- });
1494
- unknown = import_v3.z.unknown().openapi({
1495
- title: "Unknown",
1496
- type: "object",
1497
- example: "unknown"
1498
- });
1499
- never = import_v3.z.never().openapi({
1500
- title: "Never",
1501
- type: "null",
1502
- example: "never"
1503
- });
1504
- binary = import_v3.z.string().transform((val) => new Uint8Array(Buffer.from(val, "base64"))).openapi({
1505
- title: "Binary",
1506
- type: "string",
1507
- format: "binary",
1508
- example: "a base-64 encodable string"
1509
- });
1510
- file = import_v3.z.union([
1511
- import_v3.z.instanceof(Buffer),
1512
- import_v3.z.instanceof(ArrayBuffer),
1513
- import_v3.z.instanceof(Blob),
1514
- import_v3.z.string()
1515
- ]).transform((val) => {
1516
- if (val instanceof Buffer) {
1517
- return new Blob([val]);
1518
- }
1519
- if (val instanceof ArrayBuffer) {
1520
- return new Blob([val]);
1521
- }
1522
- if (val instanceof Blob) {
1523
- return val;
1524
- }
1525
- if (typeof val === "string") {
1526
- return new Blob([val]);
1527
- }
1528
- return new Blob([val]);
1529
- }).refine((val) => val instanceof Blob, {
1530
- message: "Invalid file type: expected Buffer, ArrayBuffer, Blob, or string"
1531
- }).openapi({
1532
- title: "File",
1533
- type: "string",
1534
- format: "binary",
1535
- example: "a base-64 encodable blob or file"
1536
- });
1537
- type = () => this.any;
1538
- /**
1539
- * Compiles schema if this exists, for optimal performance.
1540
- *
1541
- * @param {ZodObject<ZodRawShape>} schema - The schema to compile.
1542
- * @returns {ZodResolve<T>} - The compiled schema.
1543
- */
1544
- compile(schema) {
1545
- return schema;
1546
- }
1547
- /**
1548
- * Convert a schema to a Zod schema.
1549
- * @param {ZodIdiomaticSchema} schema - The schema to convert.
1550
- * @returns {ZodResolve<T>} The resolved schema.
1551
- */
1552
- schemify(schema) {
1553
- if (typeof schema === "string" || typeof schema === "number" || typeof schema === "boolean") {
1554
- return import_v3.z.literal(schema);
1555
- }
1556
- if (schema instanceof import_v3.ZodType) {
1557
- return schema;
1558
- }
1559
- const newSchema = {};
1560
- Object.getOwnPropertyNames(schema).forEach((key) => {
1561
- if (schema[key] instanceof import_v3.ZodType) {
1562
- newSchema[key] = schema[key];
1563
- } else {
1564
- newSchema[key] = this.schemify(schema[key]);
1565
- }
1566
- });
1567
- return import_v3.z.object(newSchema);
1568
- }
1569
- /**
1570
- * Make a schema optional.
1571
- * @param {ZodIdiomaticSchema} schema - The schema to make optional.
1572
- * @returns {ZodOptional<ZodResolve<T>>} The optional schema.
1573
- */
1574
- optional(schema) {
1575
- const resolvedSchema = this.schemify(schema);
1576
- return resolvedSchema.optional();
1577
- }
1578
- /**
1579
- * Create an array schema.
1580
- * @param {ZodIdiomaticSchema} schema - The schema to use for array items.
1581
- * @returns {ZodArray<ZodResolve<T>>} The array schema.
1582
- */
1583
- array(schema) {
1584
- const resolvedSchema = this.schemify(schema);
1585
- return resolvedSchema.array();
1586
- }
1587
- /**
1588
- * Create a union schema.
1589
- * @param {ZodUnionContainer} schemas - The schemas to union.
1590
- * @returns {ZodUnion<UnionZodResolve<T>>} The union schema.
1591
- */
1592
- union(schemas) {
1593
- const resolvedSchemas = schemas.map((schema) => this.schemify(schema));
1594
- return import_v3.z.union(
1595
- resolvedSchemas
1596
- );
1597
- }
1598
- /**
1599
- * Create a literal schema.
1600
- * @param {LiteralSchema} value - The literal value.
1601
- * @returns {ZodLiteral<ZodResolve<T>>} The literal schema.
1602
- */
1603
- literal(value) {
1604
- return import_v3.z.literal(value);
1605
- }
1606
- /**
1607
- * Create an enum schema.
1608
- * @param {Record<string, LiteralSchema>} schemaEnum - The enum schema.
1609
- * @returns {ZodUnion<UnionZodResolve<[T, T, ...T[]]>>} The enum schema.
1610
- */
1611
- enum_(schemaEnum) {
1612
- return this.union(
1613
- Object.values(schemaEnum)
1614
- );
1615
- }
1616
- /**
1617
- * Create a function schema.
1618
- * @param {ZodTuple} args - The arguments of the function.
1619
- * @param {ZodAny} returnType - The return type of the function.
1620
- * @returns {ZodFunction<Args, ReturnType>} The function schema.
1621
- */
1622
- function_(args, returnType) {
1623
- const schemaArgs = args.map((schema) => this.schemify(schema));
1624
- const schemaReturnType = this.schemify(returnType);
1625
- return import_v3.z.function(import_v3.z.tuple(schemaArgs), schemaReturnType);
1626
- }
1627
- /**
1628
- * Create a record schema.
1629
- * @param {ZodIdiomaticSchema} key - The key schema.
1630
- * @param {ZodIdiomaticSchema} value - The value schema.
1631
- * @returns {ZodRecord<ZodResolve<Key>, ZodResolve<Value>>} The record schema.
1632
- */
1633
- record(key, value) {
1634
- const keySchema = this.schemify(key);
1635
- const valueSchema = this.schemify(value);
1636
- return import_v3.z.record(keySchema, valueSchema);
1637
- }
1638
- /**
1639
- * Create a promise schema.
1640
- * @param {ZodIdiomaticSchema} schema - The schema to use for the promise.
1641
- * @returns {ZodPromise<ZodResolve<T>>} The promise schema.
1642
- */
1643
- promise(schema) {
1644
- return import_v3.z.promise(this.schemify(schema));
1645
- }
1646
- /**
1647
- * Checks if a value is a Zod schema.
1648
- * @param {unknown} value - The value to check.
1649
- * @returns {boolean} True if the value is a Zod schema.
1650
- */
1651
- isSchema(value) {
1652
- return value instanceof import_v3.ZodType;
1653
- }
1654
- /**
1655
- * Checks if a value is an instance of a Zod schema.
1656
- * @param {object} value - The value to check.
1657
- * @param {ZodType} type - The schema to check against.
1658
- * @returns {boolean} True if the value is an instance of the schema.
1659
- */
1660
- isInstanceOf(value, type22) {
1661
- return this.isSchema(value) && type22._def.typeName === value._def.typeName;
1662
- }
1663
- /**
1664
- * Validate a value against a schema.
1665
- * @param {ZodCatchall} schema - The schema to validate against.
1666
- * @param {unknown} value - The value to validate.
1667
- * @returns {boolean} True if valid, otherwise false.
1668
- */
1669
- validate(schema, value) {
1670
- const resolvedSchema = this.schemify(schema);
1671
- return resolvedSchema.safeParse(value).success;
1672
- }
1673
- /**
1674
- * Parses a value to a schema validation.
1675
- *
1676
- * @param {ZodCatchall} schema - The schema to validate against.
1677
- * @param {unknown} value - The value to validate.
1678
- * @returns {ParseResult} - The discrimintated parsed value if successful, the error if unsuccessful.
1679
- */
1680
- parse(schema, value) {
1681
- const resolvedSchema = this.schemify(schema);
1682
- const result = resolvedSchema.safeParse(value);
1683
- return result.success ? { ok: true, value: result.data } : {
1684
- ok: false,
1685
- errors: result.error.errors.flatMap((error) => {
1686
- switch (error.code) {
1687
- case "invalid_union":
1688
- return error.unionErrors.flatMap(
1689
- (unionError, idx) => unionError.errors.map((e) => ({
1690
- path: [
1691
- `Union Schema Variant ${idx}`,
1692
- ...error.path.map((p) => p.toString()),
1693
- ...e.path.map((p) => p.toString())
1694
- ],
1695
- message: e.message
1696
- }))
1697
- );
1698
- default:
1699
- return [
1700
- {
1701
- path: error.path.map((p) => p.toString()),
1702
- message: error.message
1703
- }
1704
- ];
1705
- }
1706
- })
1707
- };
1708
- }
1709
- /**
1710
- * Convert a schema to an OpenAPI schema object.
1711
- * @param {ZodIdiomaticSchema} schema - The schema to convert.
1712
- * @returns {SchemaObject} The OpenAPI schema object.
1713
- */
1714
- openapi(schema) {
1715
- const schemified = this.schemify(schema);
1716
- return generateSchema(deepCloneWithoutUndefined(schemified));
1717
- }
33
+ brokers: (0, import_typebox.array)(import_typebox.string),
34
+ clientId: import_typebox.string,
35
+ groupId: import_typebox.string,
36
+ retries: import_typebox.number,
37
+ interval: import_typebox.number,
38
+ peekCount: import_typebox.number
1718
39
  };
1719
- var SchemaValidator2 = () => new ZodSchemaValidator();
1720
- var StaticSchemaValidator2 = SchemaValidator2();
1721
- var string2 = StaticSchemaValidator2.string;
1722
- var uuid2 = StaticSchemaValidator2.uuid;
1723
- var email2 = StaticSchemaValidator2.email;
1724
- var uri2 = StaticSchemaValidator2.uri;
1725
- var number2 = StaticSchemaValidator2.number;
1726
- var bigint2 = StaticSchemaValidator2.bigint;
1727
- var boolean2 = StaticSchemaValidator2.boolean;
1728
- var date2 = StaticSchemaValidator2.date;
1729
- var symbol2 = StaticSchemaValidator2.symbol;
1730
- var nullish2 = StaticSchemaValidator2.nullish;
1731
- var void_2 = StaticSchemaValidator2.void;
1732
- var null_2 = StaticSchemaValidator2.null;
1733
- var undefined_2 = StaticSchemaValidator2.undefined;
1734
- var any2 = StaticSchemaValidator2.any;
1735
- var unknown2 = StaticSchemaValidator2.unknown;
1736
- var never2 = StaticSchemaValidator2.never;
1737
- var binary2 = StaticSchemaValidator2.binary;
1738
- var file2 = StaticSchemaValidator2.file;
1739
- var type2 = StaticSchemaValidator2.type;
1740
- var schemify2 = StaticSchemaValidator2.schemify.bind(StaticSchemaValidator2);
1741
- var optional2 = StaticSchemaValidator2.optional.bind(StaticSchemaValidator2);
1742
- var array2 = StaticSchemaValidator2.array.bind(StaticSchemaValidator2);
1743
- var union2 = StaticSchemaValidator2.union.bind(StaticSchemaValidator2);
1744
- var literal2 = StaticSchemaValidator2.literal.bind(StaticSchemaValidator2);
1745
- var enum_2 = StaticSchemaValidator2.enum_.bind(StaticSchemaValidator2);
1746
- var function_2 = StaticSchemaValidator2.function_.bind(StaticSchemaValidator2);
1747
- var record2 = StaticSchemaValidator2.record.bind(StaticSchemaValidator2);
1748
- var promise2 = StaticSchemaValidator2.promise.bind(StaticSchemaValidator2);
1749
- var isSchema2 = StaticSchemaValidator2.isSchema.bind(StaticSchemaValidator2);
1750
- var validate2 = StaticSchemaValidator2.validate.bind(StaticSchemaValidator2);
1751
- var parse2 = StaticSchemaValidator2.parse.bind(StaticSchemaValidator2);
1752
- var openapi2 = StaticSchemaValidator2.openapi.bind(StaticSchemaValidator2);
1753
40
 
1754
41
  // domain/schemas/zod/kafkaWorker.schema.ts
42
+ var import_zod = require("@forklaunch/validator/zod");
1755
43
  var KafkaWorkerOptionsSchema2 = {
1756
- brokers: array2(string2),
1757
- clientId: string2,
1758
- groupId: string2,
1759
- retries: number2,
1760
- interval: number2,
1761
- peekCount: number2
44
+ brokers: (0, import_zod.array)(import_zod.string),
45
+ clientId: import_zod.string,
46
+ groupId: import_zod.string,
47
+ retries: import_zod.number,
48
+ interval: import_zod.number,
49
+ peekCount: import_zod.number
1762
50
  };
1763
51
 
1764
52
  // domain/schemas/kafka.schema.ts