@forklaunch/implementation-worker-database 0.5.4 → 0.5.5
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 +571 -529
- package/lib/domain/schemas/index.mjs +535 -533
- 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 +4 -4
|
@@ -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.9.
|
|
38
|
+
// ../../../node_modules/.pnpm/@forklaunch+validator@0.9.3/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.5.
|
|
78
|
+
// ../../../node_modules/.pnpm/@forklaunch+common@0.5.2/node_modules/@forklaunch/common/lib/index.mjs
|
|
72
79
|
var InMemoryBlob = class extends Blob {
|
|
73
80
|
constructor(content) {
|
|
74
81
|
super([Buffer.from(content)]);
|
|
@@ -76,210 +83,233 @@ var InMemoryBlob = class extends Blob {
|
|
|
76
83
|
}
|
|
77
84
|
};
|
|
78
85
|
|
|
79
|
-
// ../../../node_modules/.pnpm/@forklaunch+validator@0.9.
|
|
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.9.3/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
124
|
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])+)])`,
|
|
112
|
-
errorType:
|
|
113
|
-
example:
|
|
114
|
-
title:
|
|
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 utf-8 encodable string',
|
|
293
|
+
title: 'Binary'
|
|
268
294
|
})
|
|
269
|
-
)
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
295
|
+
)
|
|
296
|
+
.Decode((value) => new TextEncoder().encode(value))
|
|
297
|
+
.Encode((value) => {
|
|
298
|
+
if (value instanceof ArrayBuffer) {
|
|
299
|
+
return String.fromCharCode(...new Uint8Array(value));
|
|
300
|
+
}
|
|
301
|
+
return '';
|
|
302
|
+
});
|
|
275
303
|
file = import_typebox.Type.Transform(
|
|
276
304
|
import_typebox.Type.String({
|
|
277
|
-
errorType:
|
|
278
|
-
format:
|
|
279
|
-
example:
|
|
280
|
-
title:
|
|
305
|
+
errorType: 'binary',
|
|
306
|
+
format: 'binary',
|
|
307
|
+
example: 'a utf-8 encodable blob or file',
|
|
308
|
+
title: 'File'
|
|
281
309
|
})
|
|
282
|
-
)
|
|
310
|
+
)
|
|
311
|
+
.Decode((value) => new InMemoryBlob(value))
|
|
312
|
+
.Encode((value) => value.content);
|
|
283
313
|
type = () => this.any;
|
|
284
314
|
/**
|
|
285
315
|
* Extracts the error type of a schema for error messages.
|
|
@@ -288,7 +318,10 @@ var TypeboxSchemaValidator = class {
|
|
|
288
318
|
* @returns The type of the schema for error messages.
|
|
289
319
|
*/
|
|
290
320
|
errorType(schema) {
|
|
291
|
-
if (
|
|
321
|
+
if (
|
|
322
|
+
import_typebox.KindGuard.IsSchema(schema) &&
|
|
323
|
+
Object.hasOwn(schema, 'errorType')
|
|
324
|
+
) {
|
|
292
325
|
return schema.errorType;
|
|
293
326
|
} else if (import_typebox.KindGuard.IsLiteral(schema)) {
|
|
294
327
|
return schema.const;
|
|
@@ -310,10 +343,17 @@ var TypeboxSchemaValidator = class {
|
|
|
310
343
|
* @returns {TResolve<T>} The resolved schema.
|
|
311
344
|
*/
|
|
312
345
|
schemify(schema) {
|
|
313
|
-
if (
|
|
346
|
+
if (
|
|
347
|
+
typeof schema === 'string' ||
|
|
348
|
+
typeof schema === 'number' ||
|
|
349
|
+
typeof schema === 'boolean'
|
|
350
|
+
) {
|
|
314
351
|
return import_typebox.Type.Literal(schema);
|
|
315
352
|
}
|
|
316
|
-
if (
|
|
353
|
+
if (
|
|
354
|
+
import_typebox.KindGuard.IsSchema(schema) ||
|
|
355
|
+
schema instanceof import_compiler.TypeCheck
|
|
356
|
+
) {
|
|
317
357
|
return schema;
|
|
318
358
|
}
|
|
319
359
|
const newSchema = {};
|
|
@@ -360,7 +400,7 @@ var TypeboxSchemaValidator = class {
|
|
|
360
400
|
return this.schemify(schema);
|
|
361
401
|
});
|
|
362
402
|
return import_typebox.Type.Union(unionTypes, {
|
|
363
|
-
errorType: `any of ${unionTypes.map((s) => this.errorType(s)).join(
|
|
403
|
+
errorType: `any of ${unionTypes.map((s) => this.errorType(s)).join(', ')}`,
|
|
364
404
|
errorSuffix: true
|
|
365
405
|
});
|
|
366
406
|
}
|
|
@@ -431,7 +471,12 @@ var TypeboxSchemaValidator = class {
|
|
|
431
471
|
* @returns {boolean} True if the value is an instance of the schema.
|
|
432
472
|
*/
|
|
433
473
|
isInstanceOf(value, type22) {
|
|
434
|
-
return
|
|
474
|
+
return (
|
|
475
|
+
typeof value === 'object' &&
|
|
476
|
+
value != null &&
|
|
477
|
+
import_typebox.Kind in value &&
|
|
478
|
+
value[import_typebox.Kind] === type22[import_typebox.Kind]
|
|
479
|
+
);
|
|
435
480
|
}
|
|
436
481
|
/**
|
|
437
482
|
* Validate a value against a schema.
|
|
@@ -472,33 +517,38 @@ var TypeboxSchemaValidator = class {
|
|
|
472
517
|
errors = Array.from(import_value.Value.Errors(schemified, value));
|
|
473
518
|
}
|
|
474
519
|
}
|
|
475
|
-
return errors != null && errors.length === 0
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
ok: false,
|
|
480
|
-
errors: errors.flatMap((error) => {
|
|
481
|
-
if (error.type === import_errors.ValueErrorType.Union && error.schema.errorType.includes("any of")) {
|
|
482
|
-
return error.errors.flatMap(
|
|
483
|
-
(e, idx) => Array.from(e).map((e2) => ({
|
|
484
|
-
path: [
|
|
485
|
-
`Union Schema Variant ${idx}`,
|
|
486
|
-
...error.path.split("/").slice(1),
|
|
487
|
-
...e2.path.split("/").slice(1)
|
|
488
|
-
],
|
|
489
|
-
message: e2.message
|
|
490
|
-
}))
|
|
491
|
-
);
|
|
492
|
-
} else {
|
|
493
|
-
return [
|
|
494
|
-
{
|
|
495
|
-
path: error.path.split("/").slice(1),
|
|
496
|
-
message: error.message
|
|
497
|
-
}
|
|
498
|
-
];
|
|
520
|
+
return errors != null && errors.length === 0
|
|
521
|
+
? {
|
|
522
|
+
ok: true,
|
|
523
|
+
value: conversion
|
|
499
524
|
}
|
|
500
|
-
|
|
501
|
-
|
|
525
|
+
: {
|
|
526
|
+
ok: false,
|
|
527
|
+
errors: errors.flatMap((error) => {
|
|
528
|
+
if (
|
|
529
|
+
error.type === import_errors.ValueErrorType.Union &&
|
|
530
|
+
error.schema.errorType.includes('any of')
|
|
531
|
+
) {
|
|
532
|
+
return error.errors.flatMap((e, idx) =>
|
|
533
|
+
Array.from(e).map((e2) => ({
|
|
534
|
+
path: [
|
|
535
|
+
`Union Schema Variant ${idx}`,
|
|
536
|
+
...error.path.split('/').slice(1),
|
|
537
|
+
...e2.path.split('/').slice(1)
|
|
538
|
+
],
|
|
539
|
+
message: e2.message
|
|
540
|
+
}))
|
|
541
|
+
);
|
|
542
|
+
} else {
|
|
543
|
+
return [
|
|
544
|
+
{
|
|
545
|
+
path: error.path.split('/').slice(1),
|
|
546
|
+
message: error.message
|
|
547
|
+
}
|
|
548
|
+
];
|
|
549
|
+
}
|
|
550
|
+
})
|
|
551
|
+
};
|
|
502
552
|
}
|
|
503
553
|
/**
|
|
504
554
|
* Convert a schema to an OpenAPI schema object.
|
|
@@ -509,34 +559,33 @@ var TypeboxSchemaValidator = class {
|
|
|
509
559
|
let schemified = this.schemify(schema);
|
|
510
560
|
if (import_typebox.KindGuard.IsDate(schemified)) {
|
|
511
561
|
schemified = import_typebox.Type.String({
|
|
512
|
-
format:
|
|
562
|
+
format: 'date-time'
|
|
513
563
|
});
|
|
514
564
|
}
|
|
515
565
|
const newSchema = Object.assign({}, schemified);
|
|
516
|
-
if (Object.hasOwn(newSchema,
|
|
566
|
+
if (Object.hasOwn(newSchema, 'properties')) {
|
|
517
567
|
if (newSchema.properties) {
|
|
518
568
|
Object.entries({ ...schemified.properties }).forEach(([key, value]) => {
|
|
519
|
-
if (
|
|
569
|
+
if (
|
|
570
|
+
import_typebox.KindGuard.IsSchema(value) &&
|
|
571
|
+
newSchema.properties
|
|
572
|
+
) {
|
|
520
573
|
newSchema.properties[key] = this.openapi(value);
|
|
521
574
|
}
|
|
522
575
|
});
|
|
523
576
|
}
|
|
524
577
|
}
|
|
525
|
-
if (Object.hasOwn(newSchema,
|
|
578
|
+
if (Object.hasOwn(newSchema, 'items')) {
|
|
526
579
|
newSchema.items = this.openapi(newSchema.items);
|
|
527
580
|
}
|
|
528
581
|
if (Array.isArray(newSchema.anyOf)) {
|
|
529
|
-
newSchema.anyOf = newSchema.anyOf.map(
|
|
530
|
-
(item) => this.openapi(item)
|
|
531
|
-
);
|
|
582
|
+
newSchema.anyOf = newSchema.anyOf.map((item) => this.openapi(item));
|
|
532
583
|
}
|
|
533
584
|
if (Array.isArray(newSchema.oneOf)) {
|
|
534
|
-
newSchema.oneOf = newSchema.oneOf.map(
|
|
535
|
-
(item) => this.openapi(item)
|
|
536
|
-
);
|
|
585
|
+
newSchema.oneOf = newSchema.oneOf.map((item) => this.openapi(item));
|
|
537
586
|
}
|
|
538
|
-
if (
|
|
539
|
-
delete newSchema[
|
|
587
|
+
if ('errorType' in newSchema) {
|
|
588
|
+
delete newSchema['errorType'];
|
|
540
589
|
}
|
|
541
590
|
return newSchema;
|
|
542
591
|
}
|
|
@@ -582,43 +631,55 @@ var DatabaseWorkerOptionsSchema = {
|
|
|
582
631
|
interval: number
|
|
583
632
|
};
|
|
584
633
|
|
|
585
|
-
// ../../../node_modules/.pnpm/@forklaunch+validator@0.9.
|
|
586
|
-
var import_v3 = require(
|
|
634
|
+
// ../../../node_modules/.pnpm/@forklaunch+validator@0.9.3/node_modules/@forklaunch/validator/lib/src/zod/index.mjs
|
|
635
|
+
var import_v3 = require('zod/v3');
|
|
587
636
|
|
|
588
637
|
// ../../../node_modules/.pnpm/ts-deepmerge@7.0.3/node_modules/ts-deepmerge/esm/index.js
|
|
589
638
|
var isObject = (obj) => {
|
|
590
|
-
if (typeof obj ===
|
|
591
|
-
if (typeof Object.getPrototypeOf ===
|
|
639
|
+
if (typeof obj === 'object' && obj !== null) {
|
|
640
|
+
if (typeof Object.getPrototypeOf === 'function') {
|
|
592
641
|
const prototype = Object.getPrototypeOf(obj);
|
|
593
642
|
return prototype === Object.prototype || prototype === null;
|
|
594
643
|
}
|
|
595
|
-
return Object.prototype.toString.call(obj) ===
|
|
644
|
+
return Object.prototype.toString.call(obj) === '[object Object]';
|
|
596
645
|
}
|
|
597
646
|
return false;
|
|
598
647
|
};
|
|
599
|
-
var merge = (...objects) =>
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
if (Array.isArray(current)) {
|
|
604
|
-
throw new TypeError("Arguments provided to ts-deepmerge must be objects, not arrays.");
|
|
605
|
-
}
|
|
606
|
-
Object.keys(current).forEach((key) => {
|
|
607
|
-
if (["__proto__", "constructor", "prototype"].includes(key)) {
|
|
608
|
-
return;
|
|
648
|
+
var merge = (...objects) =>
|
|
649
|
+
objects.reduce((result, current) => {
|
|
650
|
+
if (current === void 0) {
|
|
651
|
+
return result;
|
|
609
652
|
}
|
|
610
|
-
if (Array.isArray(
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
} else if (!isObject(result[key]) && isObject(current[key])) {
|
|
615
|
-
result[key] = merge(current[key], void 0);
|
|
616
|
-
} else {
|
|
617
|
-
result[key] = current[key] === void 0 ? merge.options.allowUndefinedOverrides ? current[key] : result[key] : current[key];
|
|
653
|
+
if (Array.isArray(current)) {
|
|
654
|
+
throw new TypeError(
|
|
655
|
+
'Arguments provided to ts-deepmerge must be objects, not arrays.'
|
|
656
|
+
);
|
|
618
657
|
}
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
658
|
+
Object.keys(current).forEach((key) => {
|
|
659
|
+
if (['__proto__', 'constructor', 'prototype'].includes(key)) {
|
|
660
|
+
return;
|
|
661
|
+
}
|
|
662
|
+
if (Array.isArray(result[key]) && Array.isArray(current[key])) {
|
|
663
|
+
result[key] = merge.options.mergeArrays
|
|
664
|
+
? merge.options.uniqueArrayItems
|
|
665
|
+
? Array.from(new Set(result[key].concat(current[key])))
|
|
666
|
+
: [...result[key], ...current[key]]
|
|
667
|
+
: current[key];
|
|
668
|
+
} else if (isObject(result[key]) && isObject(current[key])) {
|
|
669
|
+
result[key] = merge(result[key], current[key]);
|
|
670
|
+
} else if (!isObject(result[key]) && isObject(current[key])) {
|
|
671
|
+
result[key] = merge(current[key], void 0);
|
|
672
|
+
} else {
|
|
673
|
+
result[key] =
|
|
674
|
+
current[key] === void 0
|
|
675
|
+
? merge.options.allowUndefinedOverrides
|
|
676
|
+
? current[key]
|
|
677
|
+
: result[key]
|
|
678
|
+
: current[key];
|
|
679
|
+
}
|
|
680
|
+
});
|
|
681
|
+
return result;
|
|
682
|
+
}, {});
|
|
622
683
|
var defaultOptions = {
|
|
623
684
|
allowUndefinedOverrides: true,
|
|
624
685
|
mergeArrays: true,
|
|
@@ -632,8 +693,8 @@ merge.withOptions = (options, ...objects) => {
|
|
|
632
693
|
return result;
|
|
633
694
|
};
|
|
634
695
|
|
|
635
|
-
// ../../../node_modules/.pnpm/@forklaunch+validator@0.9.
|
|
636
|
-
var import_v32 = require(
|
|
696
|
+
// ../../../node_modules/.pnpm/@forklaunch+validator@0.9.3/node_modules/@forklaunch/validator/lib/src/zod/index.mjs
|
|
697
|
+
var import_v32 = require('zod/v3');
|
|
637
698
|
function extendApi(schema, schemaObject = {}) {
|
|
638
699
|
const This = schema.constructor;
|
|
639
700
|
const newSchema = new This(schema._def);
|
|
@@ -650,89 +711,96 @@ function iterateZodObject({
|
|
|
650
711
|
hideDefinitions,
|
|
651
712
|
openApiVersion
|
|
652
713
|
}) {
|
|
653
|
-
const reduced = Object.keys(zodRef.shape)
|
|
654
|
-
(
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
714
|
+
const reduced = Object.keys(zodRef.shape)
|
|
715
|
+
.filter((key) => hideDefinitions?.includes(key) === false)
|
|
716
|
+
.reduce(
|
|
717
|
+
(carry, key) => ({
|
|
718
|
+
...carry,
|
|
719
|
+
[key]: generateSchema(zodRef.shape[key], useOutput, openApiVersion)
|
|
720
|
+
}),
|
|
721
|
+
{}
|
|
722
|
+
);
|
|
660
723
|
return reduced;
|
|
661
724
|
}
|
|
662
725
|
function typeFormat(type22, openApiVersion) {
|
|
663
|
-
return openApiVersion ===
|
|
726
|
+
return openApiVersion === '3.0' ? type22 : [type22];
|
|
664
727
|
}
|
|
665
|
-
function parseTransformation({
|
|
666
|
-
zodRef,
|
|
667
|
-
schemas,
|
|
668
|
-
useOutput,
|
|
669
|
-
openApiVersion
|
|
670
|
-
}) {
|
|
728
|
+
function parseTransformation({ zodRef, schemas, useOutput, openApiVersion }) {
|
|
671
729
|
const input = generateSchema(zodRef._def.schema, useOutput, openApiVersion);
|
|
672
|
-
let output =
|
|
730
|
+
let output = 'undefined';
|
|
673
731
|
if (useOutput && zodRef._def.effect) {
|
|
674
|
-
const effect =
|
|
675
|
-
|
|
732
|
+
const effect =
|
|
733
|
+
zodRef._def.effect.type === 'transform' ? zodRef._def.effect : null;
|
|
734
|
+
if (effect && 'transform' in effect) {
|
|
676
735
|
try {
|
|
677
736
|
const type22 = Array.isArray(input.type) ? input.type[0] : input.type;
|
|
678
737
|
output = typeof effect.transform(
|
|
679
|
-
[
|
|
738
|
+
['integer', 'number'].includes(`${type22}`)
|
|
739
|
+
? 0
|
|
740
|
+
: 'string' === type22
|
|
741
|
+
? ''
|
|
742
|
+
: 'boolean' === type22
|
|
743
|
+
? false
|
|
744
|
+
: 'object' === type22
|
|
745
|
+
? {}
|
|
746
|
+
: 'null' === type22
|
|
747
|
+
? null
|
|
748
|
+
: 'array' === type22
|
|
749
|
+
? []
|
|
750
|
+
: void 0,
|
|
680
751
|
{ addIssue: () => void 0, path: [] }
|
|
681
752
|
// TODO: Discover if context is necessary here
|
|
682
753
|
);
|
|
683
|
-
} catch {
|
|
684
|
-
}
|
|
754
|
+
} catch {}
|
|
685
755
|
}
|
|
686
756
|
}
|
|
687
757
|
const outputType = output;
|
|
688
758
|
return merge(
|
|
689
759
|
{
|
|
690
|
-
...zodRef.description ? { description: zodRef.description } : {},
|
|
760
|
+
...(zodRef.description ? { description: zodRef.description } : {}),
|
|
691
761
|
...input,
|
|
692
|
-
...[
|
|
693
|
-
|
|
694
|
-
|
|
762
|
+
...(['number', 'string', 'boolean', 'null'].includes(output)
|
|
763
|
+
? {
|
|
764
|
+
type: typeFormat(outputType, openApiVersion)
|
|
765
|
+
}
|
|
766
|
+
: {})
|
|
695
767
|
},
|
|
696
768
|
...schemas
|
|
697
769
|
);
|
|
698
770
|
}
|
|
699
|
-
function parseString({
|
|
700
|
-
zodRef,
|
|
701
|
-
schemas,
|
|
702
|
-
openApiVersion
|
|
703
|
-
}) {
|
|
771
|
+
function parseString({ zodRef, schemas, openApiVersion }) {
|
|
704
772
|
const baseSchema = {
|
|
705
|
-
type: typeFormat(
|
|
773
|
+
type: typeFormat('string', openApiVersion)
|
|
706
774
|
};
|
|
707
775
|
const { checks = [] } = zodRef._def;
|
|
708
776
|
checks.forEach((item) => {
|
|
709
777
|
switch (item.kind) {
|
|
710
|
-
case
|
|
711
|
-
baseSchema.format =
|
|
778
|
+
case 'email':
|
|
779
|
+
baseSchema.format = 'email';
|
|
712
780
|
break;
|
|
713
|
-
case
|
|
714
|
-
baseSchema.format =
|
|
781
|
+
case 'uuid':
|
|
782
|
+
baseSchema.format = 'uuid';
|
|
715
783
|
break;
|
|
716
|
-
case
|
|
717
|
-
baseSchema.format =
|
|
784
|
+
case 'cuid':
|
|
785
|
+
baseSchema.format = 'cuid';
|
|
718
786
|
break;
|
|
719
|
-
case
|
|
720
|
-
baseSchema.format =
|
|
787
|
+
case 'url':
|
|
788
|
+
baseSchema.format = 'uri';
|
|
721
789
|
break;
|
|
722
|
-
case
|
|
723
|
-
baseSchema.format =
|
|
790
|
+
case 'datetime':
|
|
791
|
+
baseSchema.format = 'date-time';
|
|
724
792
|
break;
|
|
725
|
-
case
|
|
793
|
+
case 'length':
|
|
726
794
|
baseSchema.minLength = item.value;
|
|
727
795
|
baseSchema.maxLength = item.value;
|
|
728
796
|
break;
|
|
729
|
-
case
|
|
797
|
+
case 'max':
|
|
730
798
|
baseSchema.maxLength = item.value;
|
|
731
799
|
break;
|
|
732
|
-
case
|
|
800
|
+
case 'min':
|
|
733
801
|
baseSchema.minLength = item.value;
|
|
734
802
|
break;
|
|
735
|
-
case
|
|
803
|
+
case 'regex':
|
|
736
804
|
baseSchema.pattern = item.regex.source;
|
|
737
805
|
break;
|
|
738
806
|
}
|
|
@@ -743,45 +811,41 @@ function parseString({
|
|
|
743
811
|
...schemas
|
|
744
812
|
);
|
|
745
813
|
}
|
|
746
|
-
function parseNumber({
|
|
747
|
-
zodRef,
|
|
748
|
-
schemas,
|
|
749
|
-
openApiVersion
|
|
750
|
-
}) {
|
|
814
|
+
function parseNumber({ zodRef, schemas, openApiVersion }) {
|
|
751
815
|
const baseSchema = {
|
|
752
|
-
type: typeFormat(
|
|
816
|
+
type: typeFormat('number', openApiVersion)
|
|
753
817
|
};
|
|
754
818
|
const { checks = [] } = zodRef._def;
|
|
755
819
|
checks.forEach((item) => {
|
|
756
820
|
switch (item.kind) {
|
|
757
|
-
case
|
|
758
|
-
if (item.inclusive || openApiVersion ===
|
|
821
|
+
case 'max':
|
|
822
|
+
if (item.inclusive || openApiVersion === '3.0') {
|
|
759
823
|
baseSchema.maximum = item.value;
|
|
760
824
|
}
|
|
761
825
|
if (!item.inclusive) {
|
|
762
|
-
if (openApiVersion ===
|
|
826
|
+
if (openApiVersion === '3.0') {
|
|
763
827
|
baseSchema.exclusiveMaximum = true;
|
|
764
828
|
} else {
|
|
765
829
|
baseSchema.exclusiveMaximum = item.value;
|
|
766
830
|
}
|
|
767
831
|
}
|
|
768
832
|
break;
|
|
769
|
-
case
|
|
770
|
-
if (item.inclusive || openApiVersion ===
|
|
833
|
+
case 'min':
|
|
834
|
+
if (item.inclusive || openApiVersion === '3.0') {
|
|
771
835
|
baseSchema.minimum = item.value;
|
|
772
836
|
}
|
|
773
837
|
if (!item.inclusive) {
|
|
774
|
-
if (openApiVersion ===
|
|
838
|
+
if (openApiVersion === '3.0') {
|
|
775
839
|
baseSchema.exclusiveMinimum = true;
|
|
776
840
|
} else {
|
|
777
841
|
baseSchema.exclusiveMinimum = item.value;
|
|
778
842
|
}
|
|
779
843
|
}
|
|
780
844
|
break;
|
|
781
|
-
case
|
|
782
|
-
baseSchema.type = typeFormat(
|
|
845
|
+
case 'int':
|
|
846
|
+
baseSchema.type = typeFormat('integer', openApiVersion);
|
|
783
847
|
break;
|
|
784
|
-
case
|
|
848
|
+
case 'multipleOf':
|
|
785
849
|
baseSchema.multipleOf = item.value;
|
|
786
850
|
break;
|
|
787
851
|
}
|
|
@@ -809,26 +873,41 @@ function parseObject({
|
|
|
809
873
|
openApiVersion
|
|
810
874
|
}) {
|
|
811
875
|
let additionalProperties;
|
|
812
|
-
if (
|
|
876
|
+
if (
|
|
877
|
+
!(
|
|
878
|
+
zodRef._def.catchall instanceof import_v32.z.ZodNever ||
|
|
879
|
+
zodRef._def.catchall?._def.typeName === 'ZodNever'
|
|
880
|
+
)
|
|
881
|
+
)
|
|
813
882
|
additionalProperties = generateSchema(
|
|
814
883
|
zodRef._def.catchall,
|
|
815
884
|
useOutput,
|
|
816
885
|
openApiVersion
|
|
817
886
|
);
|
|
818
|
-
else if (zodRef._def.unknownKeys ===
|
|
887
|
+
else if (zodRef._def.unknownKeys === 'passthrough')
|
|
819
888
|
additionalProperties = true;
|
|
820
|
-
else if (zodRef._def.unknownKeys ===
|
|
821
|
-
additionalProperties =
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
).filter((key) => {
|
|
889
|
+
else if (zodRef._def.unknownKeys === 'strict') additionalProperties = false;
|
|
890
|
+
additionalProperties =
|
|
891
|
+
additionalProperties != null ? { additionalProperties } : {};
|
|
892
|
+
const requiredProperties = Object.keys(zodRef.shape).filter((key) => {
|
|
825
893
|
const item = zodRef.shape[key];
|
|
826
|
-
return
|
|
894
|
+
return (
|
|
895
|
+
!(
|
|
896
|
+
item.isOptional() ||
|
|
897
|
+
item instanceof import_v32.z.ZodDefault ||
|
|
898
|
+
item._def.typeName === 'ZodDefault'
|
|
899
|
+
) &&
|
|
900
|
+
!(
|
|
901
|
+
item instanceof import_v32.z.ZodNever ||
|
|
902
|
+
item._def.typeName === 'ZodDefault'
|
|
903
|
+
)
|
|
904
|
+
);
|
|
827
905
|
});
|
|
828
|
-
const required =
|
|
906
|
+
const required =
|
|
907
|
+
requiredProperties.length > 0 ? { required: requiredProperties } : {};
|
|
829
908
|
return merge(
|
|
830
909
|
{
|
|
831
|
-
type: typeFormat(
|
|
910
|
+
type: typeFormat('object', openApiVersion),
|
|
832
911
|
properties: iterateZodObject({
|
|
833
912
|
zodRef,
|
|
834
913
|
schemas,
|
|
@@ -840,110 +919,83 @@ function parseObject({
|
|
|
840
919
|
...additionalProperties,
|
|
841
920
|
...hideDefinitions
|
|
842
921
|
},
|
|
843
|
-
zodRef.description
|
|
922
|
+
zodRef.description
|
|
923
|
+
? { description: zodRef.description, hideDefinitions }
|
|
924
|
+
: {},
|
|
844
925
|
...schemas
|
|
845
926
|
);
|
|
846
927
|
}
|
|
847
|
-
function parseRecord({
|
|
848
|
-
zodRef,
|
|
849
|
-
schemas,
|
|
850
|
-
useOutput,
|
|
851
|
-
openApiVersion
|
|
852
|
-
}) {
|
|
928
|
+
function parseRecord({ zodRef, schemas, useOutput, openApiVersion }) {
|
|
853
929
|
return merge(
|
|
854
930
|
{
|
|
855
|
-
type: typeFormat(
|
|
856
|
-
additionalProperties:
|
|
931
|
+
type: typeFormat('object', openApiVersion),
|
|
932
|
+
additionalProperties:
|
|
933
|
+
zodRef._def.valueType instanceof import_v32.z.ZodUnknown
|
|
934
|
+
? {}
|
|
935
|
+
: generateSchema(zodRef._def.valueType, useOutput, openApiVersion)
|
|
857
936
|
},
|
|
858
937
|
zodRef.description ? { description: zodRef.description } : {},
|
|
859
938
|
...schemas
|
|
860
939
|
);
|
|
861
940
|
}
|
|
862
|
-
function parseBigInt({
|
|
863
|
-
zodRef,
|
|
864
|
-
schemas,
|
|
865
|
-
openApiVersion
|
|
866
|
-
}) {
|
|
941
|
+
function parseBigInt({ zodRef, schemas, openApiVersion }) {
|
|
867
942
|
return merge(
|
|
868
943
|
{
|
|
869
|
-
type: typeFormat(
|
|
870
|
-
format:
|
|
944
|
+
type: typeFormat('integer', openApiVersion),
|
|
945
|
+
format: 'int64'
|
|
871
946
|
},
|
|
872
947
|
zodRef.description ? { description: zodRef.description } : {},
|
|
873
948
|
...schemas
|
|
874
949
|
);
|
|
875
950
|
}
|
|
876
|
-
function parseBoolean({
|
|
877
|
-
zodRef,
|
|
878
|
-
schemas,
|
|
879
|
-
openApiVersion
|
|
880
|
-
}) {
|
|
951
|
+
function parseBoolean({ zodRef, schemas, openApiVersion }) {
|
|
881
952
|
return merge(
|
|
882
|
-
{ type: typeFormat(
|
|
953
|
+
{ type: typeFormat('boolean', openApiVersion) },
|
|
883
954
|
zodRef.description ? { description: zodRef.description } : {},
|
|
884
955
|
...schemas
|
|
885
956
|
);
|
|
886
957
|
}
|
|
887
|
-
function parseDate({
|
|
888
|
-
zodRef,
|
|
889
|
-
schemas,
|
|
890
|
-
openApiVersion
|
|
891
|
-
}) {
|
|
958
|
+
function parseDate({ zodRef, schemas, openApiVersion }) {
|
|
892
959
|
return merge(
|
|
893
960
|
{
|
|
894
|
-
type: typeFormat(
|
|
895
|
-
format:
|
|
961
|
+
type: typeFormat('string', openApiVersion),
|
|
962
|
+
format: 'date-time'
|
|
896
963
|
},
|
|
897
964
|
zodRef.description ? { description: zodRef.description } : {},
|
|
898
965
|
...schemas
|
|
899
966
|
);
|
|
900
967
|
}
|
|
901
|
-
function parseNull({
|
|
902
|
-
zodRef,
|
|
903
|
-
schemas,
|
|
904
|
-
openApiVersion
|
|
905
|
-
}) {
|
|
968
|
+
function parseNull({ zodRef, schemas, openApiVersion }) {
|
|
906
969
|
return merge(
|
|
907
|
-
openApiVersion ===
|
|
908
|
-
type:
|
|
909
|
-
|
|
910
|
-
|
|
970
|
+
openApiVersion === '3.0'
|
|
971
|
+
? { type: 'null' }
|
|
972
|
+
: {
|
|
973
|
+
type: ['string', 'null'],
|
|
974
|
+
enum: ['null']
|
|
975
|
+
},
|
|
911
976
|
zodRef.description ? { description: zodRef.description } : {},
|
|
912
977
|
...schemas
|
|
913
978
|
);
|
|
914
979
|
}
|
|
915
|
-
function parseOptional({
|
|
916
|
-
schemas,
|
|
917
|
-
zodRef,
|
|
918
|
-
useOutput,
|
|
919
|
-
openApiVersion
|
|
920
|
-
}) {
|
|
980
|
+
function parseOptional({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
921
981
|
return merge(
|
|
922
982
|
generateSchema(zodRef.unwrap(), useOutput, openApiVersion),
|
|
923
983
|
zodRef.description ? { description: zodRef.description } : {},
|
|
924
984
|
...schemas
|
|
925
985
|
);
|
|
926
986
|
}
|
|
927
|
-
function parseNullable({
|
|
928
|
-
schemas,
|
|
929
|
-
zodRef,
|
|
930
|
-
useOutput,
|
|
931
|
-
openApiVersion
|
|
932
|
-
}) {
|
|
987
|
+
function parseNullable({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
933
988
|
const schema = generateSchema(zodRef.unwrap(), useOutput, openApiVersion);
|
|
934
989
|
return merge(
|
|
935
990
|
schema,
|
|
936
|
-
openApiVersion ===
|
|
991
|
+
openApiVersion === '3.0'
|
|
992
|
+
? { nullable: true }
|
|
993
|
+
: { type: typeFormat('null', openApiVersion) },
|
|
937
994
|
zodRef.description ? { description: zodRef.description } : {},
|
|
938
995
|
...schemas
|
|
939
996
|
);
|
|
940
997
|
}
|
|
941
|
-
function parseDefault({
|
|
942
|
-
schemas,
|
|
943
|
-
zodRef,
|
|
944
|
-
useOutput,
|
|
945
|
-
openApiVersion
|
|
946
|
-
}) {
|
|
998
|
+
function parseDefault({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
947
999
|
return merge(
|
|
948
1000
|
{
|
|
949
1001
|
default: zodRef._def.defaultValue(),
|
|
@@ -953,12 +1005,7 @@ function parseDefault({
|
|
|
953
1005
|
...schemas
|
|
954
1006
|
);
|
|
955
1007
|
}
|
|
956
|
-
function parseArray({
|
|
957
|
-
schemas,
|
|
958
|
-
zodRef,
|
|
959
|
-
useOutput,
|
|
960
|
-
openApiVersion
|
|
961
|
-
}) {
|
|
1008
|
+
function parseArray({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
962
1009
|
const constraints = {};
|
|
963
1010
|
if (zodRef._def.exactLength != null) {
|
|
964
1011
|
constraints.minItems = zodRef._def.exactLength.value;
|
|
@@ -970,7 +1017,7 @@ function parseArray({
|
|
|
970
1017
|
constraints.maxItems = zodRef._def.maxLength.value;
|
|
971
1018
|
return merge(
|
|
972
1019
|
{
|
|
973
|
-
type: typeFormat(
|
|
1020
|
+
type: typeFormat('array', openApiVersion),
|
|
974
1021
|
items: generateSchema(zodRef.element, useOutput, openApiVersion),
|
|
975
1022
|
...constraints
|
|
976
1023
|
},
|
|
@@ -978,11 +1025,7 @@ function parseArray({
|
|
|
978
1025
|
...schemas
|
|
979
1026
|
);
|
|
980
1027
|
}
|
|
981
|
-
function parseLiteral({
|
|
982
|
-
schemas,
|
|
983
|
-
zodRef,
|
|
984
|
-
openApiVersion
|
|
985
|
-
}) {
|
|
1028
|
+
function parseLiteral({ schemas, zodRef, openApiVersion }) {
|
|
986
1029
|
const type22 = typeof zodRef._def.value;
|
|
987
1030
|
return merge(
|
|
988
1031
|
{
|
|
@@ -993,11 +1036,7 @@ function parseLiteral({
|
|
|
993
1036
|
...schemas
|
|
994
1037
|
);
|
|
995
1038
|
}
|
|
996
|
-
function parseEnum({
|
|
997
|
-
schemas,
|
|
998
|
-
zodRef,
|
|
999
|
-
openApiVersion
|
|
1000
|
-
}) {
|
|
1039
|
+
function parseEnum({ schemas, zodRef, openApiVersion }) {
|
|
1001
1040
|
const type22 = typeof Object.values(zodRef._def.values)[0];
|
|
1002
1041
|
return merge(
|
|
1003
1042
|
{
|
|
@@ -1008,12 +1047,7 @@ function parseEnum({
|
|
|
1008
1047
|
...schemas
|
|
1009
1048
|
);
|
|
1010
1049
|
}
|
|
1011
|
-
function parseIntersection({
|
|
1012
|
-
schemas,
|
|
1013
|
-
zodRef,
|
|
1014
|
-
useOutput,
|
|
1015
|
-
openApiVersion
|
|
1016
|
-
}) {
|
|
1050
|
+
function parseIntersection({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
1017
1051
|
return merge(
|
|
1018
1052
|
{
|
|
1019
1053
|
allOf: [
|
|
@@ -1025,20 +1059,20 @@ function parseIntersection({
|
|
|
1025
1059
|
...schemas
|
|
1026
1060
|
);
|
|
1027
1061
|
}
|
|
1028
|
-
function parseUnion({
|
|
1029
|
-
schemas,
|
|
1030
|
-
zodRef,
|
|
1031
|
-
useOutput,
|
|
1032
|
-
openApiVersion
|
|
1033
|
-
}) {
|
|
1062
|
+
function parseUnion({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
1034
1063
|
const contents = zodRef._def.options;
|
|
1035
|
-
if (
|
|
1036
|
-
(
|
|
1037
|
-
|
|
1038
|
-
|
|
1064
|
+
if (
|
|
1065
|
+
contents.reduce(
|
|
1066
|
+
(prev, content) => prev && content._def.typeName === 'ZodLiteral',
|
|
1067
|
+
true
|
|
1068
|
+
)
|
|
1069
|
+
) {
|
|
1039
1070
|
const literals = contents;
|
|
1040
1071
|
const type22 = literals.reduce(
|
|
1041
|
-
(prev, content) =>
|
|
1072
|
+
(prev, content) =>
|
|
1073
|
+
!prev || prev === typeof content._def.value
|
|
1074
|
+
? typeof content._def.value
|
|
1075
|
+
: null,
|
|
1042
1076
|
null
|
|
1043
1077
|
);
|
|
1044
1078
|
if (type22) {
|
|
@@ -1052,12 +1086,15 @@ function parseUnion({
|
|
|
1052
1086
|
);
|
|
1053
1087
|
}
|
|
1054
1088
|
}
|
|
1055
|
-
const oneOfContents =
|
|
1089
|
+
const oneOfContents =
|
|
1090
|
+
openApiVersion === '3.0'
|
|
1091
|
+
? contents.filter((content) => content._def.typeName !== 'ZodNull')
|
|
1092
|
+
: contents;
|
|
1056
1093
|
const contentsHasNull = contents.length != oneOfContents.length;
|
|
1057
1094
|
return merge(
|
|
1058
1095
|
{
|
|
1059
|
-
oneOf: oneOfContents.map(
|
|
1060
|
-
|
|
1096
|
+
oneOf: oneOfContents.map((schema) =>
|
|
1097
|
+
generateSchema(schema, useOutput, openApiVersion)
|
|
1061
1098
|
)
|
|
1062
1099
|
},
|
|
1063
1100
|
contentsHasNull ? { nullable: true } : {},
|
|
@@ -1076,50 +1113,34 @@ function parseDiscriminatedUnion({
|
|
|
1076
1113
|
discriminator: {
|
|
1077
1114
|
propertyName: zodRef._def.discriminator
|
|
1078
1115
|
},
|
|
1079
|
-
oneOf: Array.from(
|
|
1080
|
-
|
|
1081
|
-
)
|
|
1116
|
+
oneOf: Array.from(zodRef._def.options.values()).map((schema) =>
|
|
1117
|
+
generateSchema(schema, useOutput, openApiVersion)
|
|
1118
|
+
)
|
|
1082
1119
|
},
|
|
1083
1120
|
zodRef.description ? { description: zodRef.description } : {},
|
|
1084
1121
|
...schemas
|
|
1085
1122
|
);
|
|
1086
1123
|
}
|
|
1087
|
-
function parseNever({
|
|
1088
|
-
zodRef,
|
|
1089
|
-
schemas
|
|
1090
|
-
}) {
|
|
1124
|
+
function parseNever({ zodRef, schemas }) {
|
|
1091
1125
|
return merge(
|
|
1092
1126
|
{ readOnly: true },
|
|
1093
1127
|
zodRef.description ? { description: zodRef.description } : {},
|
|
1094
1128
|
...schemas
|
|
1095
1129
|
);
|
|
1096
1130
|
}
|
|
1097
|
-
function parseBranded({
|
|
1098
|
-
schemas,
|
|
1099
|
-
zodRef,
|
|
1100
|
-
useOutput,
|
|
1101
|
-
openApiVersion
|
|
1102
|
-
}) {
|
|
1131
|
+
function parseBranded({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
1103
1132
|
return merge(
|
|
1104
1133
|
generateSchema(zodRef._def.type, useOutput, openApiVersion),
|
|
1105
1134
|
...schemas
|
|
1106
1135
|
);
|
|
1107
1136
|
}
|
|
1108
|
-
function catchAllParser({
|
|
1109
|
-
zodRef,
|
|
1110
|
-
schemas
|
|
1111
|
-
}) {
|
|
1137
|
+
function catchAllParser({ zodRef, schemas }) {
|
|
1112
1138
|
return merge(
|
|
1113
1139
|
zodRef.description ? { description: zodRef.description } : {},
|
|
1114
1140
|
...schemas
|
|
1115
1141
|
);
|
|
1116
1142
|
}
|
|
1117
|
-
function parsePipeline({
|
|
1118
|
-
schemas,
|
|
1119
|
-
zodRef,
|
|
1120
|
-
useOutput,
|
|
1121
|
-
openApiVersion
|
|
1122
|
-
}) {
|
|
1143
|
+
function parsePipeline({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
1123
1144
|
return merge(
|
|
1124
1145
|
generateSchema(
|
|
1125
1146
|
useOutput ? zodRef._def.out : zodRef._def.in,
|
|
@@ -1129,12 +1150,7 @@ function parsePipeline({
|
|
|
1129
1150
|
...schemas
|
|
1130
1151
|
);
|
|
1131
1152
|
}
|
|
1132
|
-
function parseReadonly({
|
|
1133
|
-
zodRef,
|
|
1134
|
-
useOutput,
|
|
1135
|
-
schemas,
|
|
1136
|
-
openApiVersion
|
|
1137
|
-
}) {
|
|
1153
|
+
function parseReadonly({ zodRef, useOutput, schemas, openApiVersion }) {
|
|
1138
1154
|
return merge(
|
|
1139
1155
|
generateSchema(zodRef._def.innerType, useOutput, openApiVersion),
|
|
1140
1156
|
zodRef.description ? { description: zodRef.description } : {},
|
|
@@ -1178,10 +1194,10 @@ var workerMap = {
|
|
|
1178
1194
|
ZodPipeline: parsePipeline,
|
|
1179
1195
|
ZodReadonly: parseReadonly
|
|
1180
1196
|
};
|
|
1181
|
-
function generateSchema(zodRef, useOutput = false, openApiVersion =
|
|
1197
|
+
function generateSchema(zodRef, useOutput = false, openApiVersion = '3.1') {
|
|
1182
1198
|
const { metaOpenApi = {} } = zodRef;
|
|
1183
1199
|
const schemas = [
|
|
1184
|
-
...Array.isArray(metaOpenApi) ? metaOpenApi : [metaOpenApi]
|
|
1200
|
+
...(Array.isArray(metaOpenApi) ? metaOpenApi : [metaOpenApi])
|
|
1185
1201
|
];
|
|
1186
1202
|
try {
|
|
1187
1203
|
const typeName = zodRef._def.typeName;
|
|
@@ -1200,155 +1216,175 @@ function generateSchema(zodRef, useOutput = false, openApiVersion = "3.1") {
|
|
|
1200
1216
|
}
|
|
1201
1217
|
}
|
|
1202
1218
|
function extendZodWithOpenApi(zod, forceOverride = false) {
|
|
1203
|
-
if (
|
|
1219
|
+
if (
|
|
1220
|
+
!forceOverride &&
|
|
1221
|
+
typeof zod.ZodSchema.prototype.openapi !== 'undefined'
|
|
1222
|
+
) {
|
|
1204
1223
|
return;
|
|
1205
1224
|
}
|
|
1206
|
-
zod.ZodSchema.prototype.openapi = function(metadata) {
|
|
1225
|
+
zod.ZodSchema.prototype.openapi = function (metadata) {
|
|
1207
1226
|
return extendApi(this, metadata);
|
|
1208
1227
|
};
|
|
1209
1228
|
}
|
|
1210
1229
|
extendZodWithOpenApi(import_v3.z);
|
|
1211
1230
|
var ZodSchemaValidator = class {
|
|
1212
|
-
_Type =
|
|
1231
|
+
_Type = 'Zod';
|
|
1213
1232
|
_SchemaCatchall;
|
|
1214
1233
|
_ValidSchemaObject;
|
|
1215
1234
|
string = import_v3.z.string().openapi({
|
|
1216
|
-
title:
|
|
1217
|
-
example:
|
|
1235
|
+
title: 'String',
|
|
1236
|
+
example: 'a string'
|
|
1218
1237
|
});
|
|
1219
1238
|
uuid = import_v3.z.string().uuid().openapi({
|
|
1220
|
-
title:
|
|
1221
|
-
format:
|
|
1222
|
-
pattern:
|
|
1223
|
-
|
|
1239
|
+
title: 'UUID',
|
|
1240
|
+
format: 'uuid',
|
|
1241
|
+
pattern:
|
|
1242
|
+
'^[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}$',
|
|
1243
|
+
example: 'a8b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6'
|
|
1224
1244
|
});
|
|
1225
1245
|
email = import_v3.z.string().email().openapi({
|
|
1226
|
-
title:
|
|
1227
|
-
format:
|
|
1246
|
+
title: 'Email',
|
|
1247
|
+
format: 'email',
|
|
1228
1248
|
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])+)])`,
|
|
1229
|
-
example:
|
|
1249
|
+
example: 'a@b.com'
|
|
1230
1250
|
});
|
|
1231
1251
|
uri = import_v3.z.string().url().openapi({
|
|
1232
|
-
title:
|
|
1233
|
-
format:
|
|
1234
|
-
pattern:
|
|
1235
|
-
example:
|
|
1252
|
+
title: 'URI',
|
|
1253
|
+
format: 'uri',
|
|
1254
|
+
pattern: '^[a-zA-Z][a-zA-Z\\d+-.]*:[^\\s]*$',
|
|
1255
|
+
example: 'https://forklaunch.com'
|
|
1236
1256
|
});
|
|
1237
|
-
number = import_v3.z
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
}, import_v3.z.number()).openapi({
|
|
1244
|
-
title: "Number",
|
|
1245
|
-
example: 123
|
|
1246
|
-
});
|
|
1247
|
-
bigint = import_v3.z.preprocess((value) => {
|
|
1248
|
-
try {
|
|
1249
|
-
if (value instanceof Date) {
|
|
1250
|
-
return BigInt(value.getTime());
|
|
1257
|
+
number = import_v3.z
|
|
1258
|
+
.preprocess((value) => {
|
|
1259
|
+
try {
|
|
1260
|
+
return Number(value);
|
|
1261
|
+
} catch {
|
|
1262
|
+
return value;
|
|
1251
1263
|
}
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1264
|
+
}, import_v3.z.number())
|
|
1265
|
+
.openapi({
|
|
1266
|
+
title: 'Number',
|
|
1267
|
+
example: 123
|
|
1268
|
+
});
|
|
1269
|
+
bigint = import_v3.z
|
|
1270
|
+
.preprocess((value) => {
|
|
1271
|
+
try {
|
|
1272
|
+
if (value instanceof Date) {
|
|
1273
|
+
return BigInt(value.getTime());
|
|
1274
|
+
}
|
|
1275
|
+
switch (typeof value) {
|
|
1276
|
+
case 'number':
|
|
1277
|
+
case 'string':
|
|
1278
|
+
return BigInt(value);
|
|
1279
|
+
case 'boolean':
|
|
1280
|
+
return BigInt(value ? 1 : 0);
|
|
1281
|
+
default:
|
|
1282
|
+
return value;
|
|
1283
|
+
}
|
|
1284
|
+
} catch {
|
|
1285
|
+
return value;
|
|
1260
1286
|
}
|
|
1261
|
-
}
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
if (val.toLowerCase() === "false") return false;
|
|
1274
|
-
}
|
|
1275
|
-
return val;
|
|
1276
|
-
}, import_v3.z.boolean()).openapi({
|
|
1277
|
-
title: "Boolean",
|
|
1278
|
-
example: true
|
|
1279
|
-
});
|
|
1280
|
-
date = import_v3.z.preprocess((value) => {
|
|
1281
|
-
try {
|
|
1282
|
-
switch (typeof value) {
|
|
1283
|
-
case "string":
|
|
1284
|
-
return new Date(value);
|
|
1285
|
-
case "number":
|
|
1286
|
-
return new Date(value);
|
|
1287
|
-
default:
|
|
1288
|
-
return value;
|
|
1287
|
+
}, import_v3.z.bigint())
|
|
1288
|
+
.openapi({
|
|
1289
|
+
title: 'BigInt',
|
|
1290
|
+
type: 'integer',
|
|
1291
|
+
format: 'int64',
|
|
1292
|
+
example: 123n
|
|
1293
|
+
});
|
|
1294
|
+
boolean = import_v3.z
|
|
1295
|
+
.preprocess((val) => {
|
|
1296
|
+
if (typeof val === 'string') {
|
|
1297
|
+
if (val.toLowerCase() === 'true') return true;
|
|
1298
|
+
if (val.toLowerCase() === 'false') return false;
|
|
1289
1299
|
}
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1300
|
+
return val;
|
|
1301
|
+
}, import_v3.z.boolean())
|
|
1302
|
+
.openapi({
|
|
1303
|
+
title: 'Boolean',
|
|
1304
|
+
example: true
|
|
1305
|
+
});
|
|
1306
|
+
date = import_v3.z
|
|
1307
|
+
.preprocess((value) => {
|
|
1308
|
+
try {
|
|
1309
|
+
switch (typeof value) {
|
|
1310
|
+
case 'string':
|
|
1311
|
+
return new Date(value);
|
|
1312
|
+
case 'number':
|
|
1313
|
+
return new Date(value);
|
|
1314
|
+
default:
|
|
1315
|
+
return value;
|
|
1316
|
+
}
|
|
1317
|
+
} catch {
|
|
1318
|
+
return value;
|
|
1319
|
+
}
|
|
1320
|
+
}, import_v3.z.date())
|
|
1321
|
+
.openapi({
|
|
1322
|
+
title: 'Date',
|
|
1323
|
+
type: 'string',
|
|
1324
|
+
format: 'date-time',
|
|
1325
|
+
example: '2025-05-16T21:13:04.123Z'
|
|
1326
|
+
});
|
|
1299
1327
|
symbol = import_v3.z.symbol().openapi({
|
|
1300
|
-
title:
|
|
1301
|
-
example: Symbol(
|
|
1302
|
-
});
|
|
1303
|
-
nullish = import_v3.z.union([import_v3.z.void(), import_v3.z.null(), import_v3.z.undefined()]).openapi({
|
|
1304
|
-
title: "Nullish",
|
|
1305
|
-
type: "null",
|
|
1306
|
-
example: null
|
|
1328
|
+
title: 'Symbol',
|
|
1329
|
+
example: Symbol('symbol')
|
|
1307
1330
|
});
|
|
1331
|
+
nullish = import_v3.z
|
|
1332
|
+
.union([import_v3.z.void(), import_v3.z.null(), import_v3.z.undefined()])
|
|
1333
|
+
.openapi({
|
|
1334
|
+
title: 'Nullish',
|
|
1335
|
+
type: 'null',
|
|
1336
|
+
example: null
|
|
1337
|
+
});
|
|
1308
1338
|
void = import_v3.z.void().openapi({
|
|
1309
|
-
title:
|
|
1310
|
-
type:
|
|
1339
|
+
title: 'Void',
|
|
1340
|
+
type: 'null',
|
|
1311
1341
|
example: void 0
|
|
1312
1342
|
});
|
|
1313
1343
|
null = import_v3.z.null().openapi({
|
|
1314
|
-
title:
|
|
1315
|
-
type:
|
|
1344
|
+
title: 'Null',
|
|
1345
|
+
type: 'null',
|
|
1316
1346
|
example: null
|
|
1317
1347
|
});
|
|
1318
1348
|
undefined = import_v3.z.undefined().openapi({
|
|
1319
|
-
title:
|
|
1320
|
-
type:
|
|
1349
|
+
title: 'Undefined',
|
|
1350
|
+
type: 'null',
|
|
1321
1351
|
example: void 0
|
|
1322
1352
|
});
|
|
1323
1353
|
any = import_v3.z.any().openapi({
|
|
1324
|
-
title:
|
|
1325
|
-
type:
|
|
1326
|
-
example:
|
|
1354
|
+
title: 'Any',
|
|
1355
|
+
type: 'object',
|
|
1356
|
+
example: 'any'
|
|
1327
1357
|
});
|
|
1328
1358
|
unknown = import_v3.z.unknown().openapi({
|
|
1329
|
-
title:
|
|
1330
|
-
type:
|
|
1331
|
-
example:
|
|
1359
|
+
title: 'Unknown',
|
|
1360
|
+
type: 'object',
|
|
1361
|
+
example: 'unknown'
|
|
1332
1362
|
});
|
|
1333
1363
|
never = import_v3.z.never().openapi({
|
|
1334
|
-
title:
|
|
1335
|
-
type:
|
|
1336
|
-
example:
|
|
1337
|
-
});
|
|
1338
|
-
binary = import_v3.z.string().transform((v) => new TextEncoder().encode(v)).openapi({
|
|
1339
|
-
title: "Binary",
|
|
1340
|
-
type: "string",
|
|
1341
|
-
format: "binary",
|
|
1342
|
-
example: "a utf-8 encodable string"
|
|
1343
|
-
});
|
|
1344
|
-
file = import_v3.z.string().transform((val) => {
|
|
1345
|
-
return new Blob([val]);
|
|
1346
|
-
}).openapi({
|
|
1347
|
-
title: "File",
|
|
1348
|
-
type: "string",
|
|
1349
|
-
format: "binary",
|
|
1350
|
-
example: "a utf-8 encodable blob or file"
|
|
1364
|
+
title: 'Never',
|
|
1365
|
+
type: 'null',
|
|
1366
|
+
example: 'never'
|
|
1351
1367
|
});
|
|
1368
|
+
binary = import_v3.z
|
|
1369
|
+
.string()
|
|
1370
|
+
.transform((v) => new TextEncoder().encode(v))
|
|
1371
|
+
.openapi({
|
|
1372
|
+
title: 'Binary',
|
|
1373
|
+
type: 'string',
|
|
1374
|
+
format: 'binary',
|
|
1375
|
+
example: 'a utf-8 encodable string'
|
|
1376
|
+
});
|
|
1377
|
+
file = import_v3.z
|
|
1378
|
+
.string()
|
|
1379
|
+
.transform((val) => {
|
|
1380
|
+
return new Blob([val]);
|
|
1381
|
+
})
|
|
1382
|
+
.openapi({
|
|
1383
|
+
title: 'File',
|
|
1384
|
+
type: 'string',
|
|
1385
|
+
format: 'binary',
|
|
1386
|
+
example: 'a utf-8 encodable blob or file'
|
|
1387
|
+
});
|
|
1352
1388
|
type = () => this.any;
|
|
1353
1389
|
/**
|
|
1354
1390
|
* Compiles schema if this exists, for optimal performance.
|
|
@@ -1365,7 +1401,11 @@ var ZodSchemaValidator = class {
|
|
|
1365
1401
|
* @returns {ZodResolve<T>} The resolved schema.
|
|
1366
1402
|
*/
|
|
1367
1403
|
schemify(schema) {
|
|
1368
|
-
if (
|
|
1404
|
+
if (
|
|
1405
|
+
typeof schema === 'string' ||
|
|
1406
|
+
typeof schema === 'number' ||
|
|
1407
|
+
typeof schema === 'boolean'
|
|
1408
|
+
) {
|
|
1369
1409
|
return import_v3.z.literal(schema);
|
|
1370
1410
|
}
|
|
1371
1411
|
if (schema instanceof import_v3.ZodType) {
|
|
@@ -1406,9 +1446,7 @@ var ZodSchemaValidator = class {
|
|
|
1406
1446
|
*/
|
|
1407
1447
|
union(schemas) {
|
|
1408
1448
|
const resolvedSchemas = schemas.map((schema) => this.schemify(schema));
|
|
1409
|
-
return import_v3.z.union(
|
|
1410
|
-
resolvedSchemas
|
|
1411
|
-
);
|
|
1449
|
+
return import_v3.z.union(resolvedSchemas);
|
|
1412
1450
|
}
|
|
1413
1451
|
/**
|
|
1414
1452
|
* Create a literal schema.
|
|
@@ -1424,9 +1462,7 @@ var ZodSchemaValidator = class {
|
|
|
1424
1462
|
* @returns {ZodUnion<UnionZodResolve<[T, T, ...T[]]>>} The enum schema.
|
|
1425
1463
|
*/
|
|
1426
1464
|
enum_(schemaEnum) {
|
|
1427
|
-
return this.union(
|
|
1428
|
-
Object.values(schemaEnum)
|
|
1429
|
-
);
|
|
1465
|
+
return this.union(Object.values(schemaEnum));
|
|
1430
1466
|
}
|
|
1431
1467
|
/**
|
|
1432
1468
|
* Create a function schema.
|
|
@@ -1437,7 +1473,10 @@ var ZodSchemaValidator = class {
|
|
|
1437
1473
|
function_(args, returnType) {
|
|
1438
1474
|
const schemaArgs = args.map((schema) => this.schemify(schema));
|
|
1439
1475
|
const schemaReturnType = this.schemify(returnType);
|
|
1440
|
-
return import_v3.z.function(
|
|
1476
|
+
return import_v3.z.function(
|
|
1477
|
+
import_v3.z.tuple(schemaArgs),
|
|
1478
|
+
schemaReturnType
|
|
1479
|
+
);
|
|
1441
1480
|
}
|
|
1442
1481
|
/**
|
|
1443
1482
|
* Create a record schema.
|
|
@@ -1495,31 +1534,33 @@ var ZodSchemaValidator = class {
|
|
|
1495
1534
|
parse(schema, value) {
|
|
1496
1535
|
const resolvedSchema = this.schemify(schema);
|
|
1497
1536
|
const result = resolvedSchema.safeParse(value);
|
|
1498
|
-
return result.success
|
|
1499
|
-
ok:
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1537
|
+
return result.success
|
|
1538
|
+
? { ok: true, value: result.data }
|
|
1539
|
+
: {
|
|
1540
|
+
ok: false,
|
|
1541
|
+
errors: result.error.errors.flatMap((error) => {
|
|
1542
|
+
switch (error.code) {
|
|
1543
|
+
case 'invalid_union':
|
|
1544
|
+
return error.unionErrors.flatMap((unionError, idx) =>
|
|
1545
|
+
unionError.errors.map((e) => ({
|
|
1546
|
+
path: [
|
|
1547
|
+
`Union Schema Variant ${idx}`,
|
|
1548
|
+
...error.path.map((p) => p.toString()),
|
|
1549
|
+
...e.path.map((p) => p.toString())
|
|
1550
|
+
],
|
|
1551
|
+
message: e.message
|
|
1552
|
+
}))
|
|
1553
|
+
);
|
|
1554
|
+
default:
|
|
1555
|
+
return [
|
|
1556
|
+
{
|
|
1557
|
+
path: error.path.map((p) => p.toString()),
|
|
1558
|
+
message: error.message
|
|
1559
|
+
}
|
|
1560
|
+
];
|
|
1561
|
+
}
|
|
1562
|
+
})
|
|
1563
|
+
};
|
|
1523
1564
|
}
|
|
1524
1565
|
/**
|
|
1525
1566
|
* Convert a schema to an OpenAPI schema object.
|
|
@@ -1577,6 +1618,7 @@ var DatabaseWorkerSchemas = (0, import_internal.serviceSchemaResolver)(
|
|
|
1577
1618
|
() => DatabaseWorkerOptionsSchema2
|
|
1578
1619
|
);
|
|
1579
1620
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1580
|
-
0 &&
|
|
1581
|
-
|
|
1582
|
-
|
|
1621
|
+
0 &&
|
|
1622
|
+
(module.exports = {
|
|
1623
|
+
DatabaseWorkerSchemas
|
|
1624
|
+
});
|