@forklaunch/implementation-worker-kafka 1.0.32 → 1.0.34

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