@forklaunch/implementation-worker-database 0.5.4 → 0.5.6

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