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