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