@forklaunch/implementation-worker-database 0.6.4 → 0.7.0

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