@forklaunch/implementation-worker-bullmq 0.6.4 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/consumers/index.d.mts +12 -25
- package/lib/consumers/index.d.ts +12 -25
- package/lib/consumers/index.js +10 -15
- package/lib/consumers/index.mjs +6 -4
- package/lib/domain/schemas/index.d.mts +10 -56
- package/lib/domain/schemas/index.d.ts +10 -56
- package/lib/domain/schemas/index.js +539 -581
- package/lib/domain/schemas/index.mjs +543 -545
- package/lib/domain/types/index.d.mts +4 -4
- package/lib/domain/types/index.d.ts +4 -4
- package/lib/domain/types/index.js +4 -8
- package/lib/producers/index.d.mts +7 -11
- package/lib/producers/index.d.ts +7 -11
- package/lib/producers/index.js +8 -13
- package/lib/producers/index.mjs +4 -2
- package/package.json +10 -10
|
@@ -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/bullMqWorker.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.12/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.12/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.12/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
|
}
|
|
@@ -660,60 +611,48 @@ var openapi = StaticSchemaValidator.openapi.bind(StaticSchemaValidator);
|
|
|
660
611
|
// domain/schemas/typebox/bullMqWorker.schema.ts
|
|
661
612
|
var BullMqWorkerOptionsSchema = {
|
|
662
613
|
queueOptions: type(),
|
|
663
|
-
backoffType: union([literal(
|
|
614
|
+
backoffType: union([literal("exponential"), literal("fixed")]),
|
|
664
615
|
retries: number,
|
|
665
616
|
interval: number
|
|
666
617
|
};
|
|
667
618
|
|
|
668
|
-
// ../../../node_modules/.pnpm/@forklaunch+validator@0.10.
|
|
669
|
-
var import_v3 = require(
|
|
619
|
+
// ../../../node_modules/.pnpm/@forklaunch+validator@0.10.12/node_modules/@forklaunch/validator/lib/src/zod/index.mjs
|
|
620
|
+
var import_v3 = require("zod/v3");
|
|
670
621
|
|
|
671
622
|
// ../../../node_modules/.pnpm/ts-deepmerge@7.0.3/node_modules/ts-deepmerge/esm/index.js
|
|
672
623
|
var isObject = (obj) => {
|
|
673
|
-
if (typeof obj ===
|
|
674
|
-
if (typeof Object.getPrototypeOf ===
|
|
624
|
+
if (typeof obj === "object" && obj !== null) {
|
|
625
|
+
if (typeof Object.getPrototypeOf === "function") {
|
|
675
626
|
const prototype = Object.getPrototypeOf(obj);
|
|
676
627
|
return prototype === Object.prototype || prototype === null;
|
|
677
628
|
}
|
|
678
|
-
return Object.prototype.toString.call(obj) ===
|
|
629
|
+
return Object.prototype.toString.call(obj) === "[object Object]";
|
|
679
630
|
}
|
|
680
631
|
return false;
|
|
681
632
|
};
|
|
682
|
-
var merge = (...objects) =>
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
633
|
+
var merge = (...objects) => objects.reduce((result, current) => {
|
|
634
|
+
if (current === void 0) {
|
|
635
|
+
return result;
|
|
636
|
+
}
|
|
637
|
+
if (Array.isArray(current)) {
|
|
638
|
+
throw new TypeError("Arguments provided to ts-deepmerge must be objects, not arrays.");
|
|
639
|
+
}
|
|
640
|
+
Object.keys(current).forEach((key) => {
|
|
641
|
+
if (["__proto__", "constructor", "prototype"].includes(key)) {
|
|
642
|
+
return;
|
|
686
643
|
}
|
|
687
|
-
if (Array.isArray(current)) {
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
);
|
|
644
|
+
if (Array.isArray(result[key]) && Array.isArray(current[key])) {
|
|
645
|
+
result[key] = merge.options.mergeArrays ? merge.options.uniqueArrayItems ? Array.from(new Set(result[key].concat(current[key]))) : [...result[key], ...current[key]] : current[key];
|
|
646
|
+
} else if (isObject(result[key]) && isObject(current[key])) {
|
|
647
|
+
result[key] = merge(result[key], current[key]);
|
|
648
|
+
} else if (!isObject(result[key]) && isObject(current[key])) {
|
|
649
|
+
result[key] = merge(current[key], void 0);
|
|
650
|
+
} else {
|
|
651
|
+
result[key] = current[key] === void 0 ? merge.options.allowUndefinedOverrides ? current[key] : result[key] : current[key];
|
|
691
652
|
}
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
}
|
|
696
|
-
if (Array.isArray(result[key]) && Array.isArray(current[key])) {
|
|
697
|
-
result[key] = merge.options.mergeArrays
|
|
698
|
-
? merge.options.uniqueArrayItems
|
|
699
|
-
? Array.from(new Set(result[key].concat(current[key])))
|
|
700
|
-
: [...result[key], ...current[key]]
|
|
701
|
-
: current[key];
|
|
702
|
-
} else if (isObject(result[key]) && isObject(current[key])) {
|
|
703
|
-
result[key] = merge(result[key], current[key]);
|
|
704
|
-
} else if (!isObject(result[key]) && isObject(current[key])) {
|
|
705
|
-
result[key] = merge(current[key], void 0);
|
|
706
|
-
} else {
|
|
707
|
-
result[key] =
|
|
708
|
-
current[key] === void 0
|
|
709
|
-
? merge.options.allowUndefinedOverrides
|
|
710
|
-
? current[key]
|
|
711
|
-
: result[key]
|
|
712
|
-
: current[key];
|
|
713
|
-
}
|
|
714
|
-
});
|
|
715
|
-
return result;
|
|
716
|
-
}, {});
|
|
653
|
+
});
|
|
654
|
+
return result;
|
|
655
|
+
}, {});
|
|
717
656
|
var defaultOptions = {
|
|
718
657
|
allowUndefinedOverrides: true,
|
|
719
658
|
mergeArrays: true,
|
|
@@ -727,8 +666,8 @@ merge.withOptions = (options, ...objects) => {
|
|
|
727
666
|
return result;
|
|
728
667
|
};
|
|
729
668
|
|
|
730
|
-
// ../../../node_modules/.pnpm/@forklaunch+validator@0.10.
|
|
731
|
-
var import_v32 = require(
|
|
669
|
+
// ../../../node_modules/.pnpm/@forklaunch+validator@0.10.12/node_modules/@forklaunch/validator/lib/src/zod/index.mjs
|
|
670
|
+
var import_v32 = require("zod/v3");
|
|
732
671
|
function extendApi(schema, schemaObject = {}) {
|
|
733
672
|
const This = schema.constructor;
|
|
734
673
|
const newSchema = new This(schema._def);
|
|
@@ -745,96 +684,89 @@ function iterateZodObject({
|
|
|
745
684
|
hideDefinitions,
|
|
746
685
|
openApiVersion
|
|
747
686
|
}) {
|
|
748
|
-
const reduced = Object.keys(zodRef.shape)
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
(
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
{}
|
|
756
|
-
);
|
|
687
|
+
const reduced = Object.keys(zodRef.shape).filter((key) => hideDefinitions?.includes(key) === false).reduce(
|
|
688
|
+
(carry, key) => ({
|
|
689
|
+
...carry,
|
|
690
|
+
[key]: generateSchema(zodRef.shape[key], useOutput, openApiVersion)
|
|
691
|
+
}),
|
|
692
|
+
{}
|
|
693
|
+
);
|
|
757
694
|
return reduced;
|
|
758
695
|
}
|
|
759
696
|
function typeFormat(type22, openApiVersion) {
|
|
760
|
-
return openApiVersion ===
|
|
697
|
+
return openApiVersion === "3.0" ? type22 : [type22];
|
|
761
698
|
}
|
|
762
|
-
function parseTransformation({
|
|
699
|
+
function parseTransformation({
|
|
700
|
+
zodRef,
|
|
701
|
+
schemas,
|
|
702
|
+
useOutput,
|
|
703
|
+
openApiVersion
|
|
704
|
+
}) {
|
|
763
705
|
const input = generateSchema(zodRef._def.schema, useOutput, openApiVersion);
|
|
764
|
-
let output =
|
|
706
|
+
let output = "undefined";
|
|
765
707
|
if (useOutput && zodRef._def.effect) {
|
|
766
|
-
const effect =
|
|
767
|
-
|
|
768
|
-
if (effect && 'transform' in effect) {
|
|
708
|
+
const effect = zodRef._def.effect.type === "transform" ? zodRef._def.effect : null;
|
|
709
|
+
if (effect && "transform" in effect) {
|
|
769
710
|
try {
|
|
770
711
|
const type22 = Array.isArray(input.type) ? input.type[0] : input.type;
|
|
771
712
|
output = typeof effect.transform(
|
|
772
|
-
[
|
|
773
|
-
? 0
|
|
774
|
-
: 'string' === type22
|
|
775
|
-
? ''
|
|
776
|
-
: 'boolean' === type22
|
|
777
|
-
? false
|
|
778
|
-
: 'object' === type22
|
|
779
|
-
? {}
|
|
780
|
-
: 'null' === type22
|
|
781
|
-
? null
|
|
782
|
-
: 'array' === type22
|
|
783
|
-
? []
|
|
784
|
-
: void 0,
|
|
713
|
+
["integer", "number"].includes(`${type22}`) ? 0 : "string" === type22 ? "" : "boolean" === type22 ? false : "object" === type22 ? {} : "null" === type22 ? null : "array" === type22 ? [] : void 0,
|
|
785
714
|
{ addIssue: () => void 0, path: [] }
|
|
786
715
|
// TODO: Discover if context is necessary here
|
|
787
716
|
);
|
|
788
|
-
} catch {
|
|
717
|
+
} catch {
|
|
718
|
+
}
|
|
789
719
|
}
|
|
790
720
|
}
|
|
791
721
|
const outputType = output;
|
|
792
722
|
return merge(
|
|
793
723
|
{
|
|
794
|
-
...
|
|
724
|
+
...zodRef.description ? { description: zodRef.description } : {},
|
|
795
725
|
...input,
|
|
796
|
-
...
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
}
|
|
800
|
-
: {})
|
|
726
|
+
...["number", "string", "boolean", "null"].includes(output) ? {
|
|
727
|
+
type: typeFormat(outputType, openApiVersion)
|
|
728
|
+
} : {}
|
|
801
729
|
},
|
|
802
730
|
...schemas
|
|
803
731
|
);
|
|
804
732
|
}
|
|
805
|
-
function parseString({
|
|
733
|
+
function parseString({
|
|
734
|
+
zodRef,
|
|
735
|
+
schemas,
|
|
736
|
+
openApiVersion
|
|
737
|
+
}) {
|
|
806
738
|
const baseSchema = {
|
|
807
|
-
type: typeFormat(
|
|
739
|
+
type: typeFormat("string", openApiVersion)
|
|
808
740
|
};
|
|
809
741
|
const { checks = [] } = zodRef._def;
|
|
810
742
|
checks.forEach((item) => {
|
|
811
743
|
switch (item.kind) {
|
|
812
|
-
case
|
|
813
|
-
baseSchema.format =
|
|
744
|
+
case "email":
|
|
745
|
+
baseSchema.format = "email";
|
|
814
746
|
break;
|
|
815
|
-
case
|
|
816
|
-
baseSchema.format =
|
|
747
|
+
case "uuid":
|
|
748
|
+
baseSchema.format = "uuid";
|
|
817
749
|
break;
|
|
818
|
-
case
|
|
819
|
-
baseSchema.format =
|
|
750
|
+
case "cuid":
|
|
751
|
+
baseSchema.format = "cuid";
|
|
820
752
|
break;
|
|
821
|
-
case
|
|
822
|
-
baseSchema.format =
|
|
753
|
+
case "url":
|
|
754
|
+
baseSchema.format = "uri";
|
|
823
755
|
break;
|
|
824
|
-
case
|
|
825
|
-
baseSchema.format =
|
|
756
|
+
case "datetime":
|
|
757
|
+
baseSchema.format = "date-time";
|
|
826
758
|
break;
|
|
827
|
-
case
|
|
759
|
+
case "length":
|
|
828
760
|
baseSchema.minLength = item.value;
|
|
829
761
|
baseSchema.maxLength = item.value;
|
|
830
762
|
break;
|
|
831
|
-
case
|
|
763
|
+
case "max":
|
|
832
764
|
baseSchema.maxLength = item.value;
|
|
833
765
|
break;
|
|
834
|
-
case
|
|
766
|
+
case "min":
|
|
835
767
|
baseSchema.minLength = item.value;
|
|
836
768
|
break;
|
|
837
|
-
case
|
|
769
|
+
case "regex":
|
|
838
770
|
baseSchema.pattern = item.regex.source;
|
|
839
771
|
break;
|
|
840
772
|
}
|
|
@@ -845,41 +777,45 @@ function parseString({ zodRef, schemas, openApiVersion }) {
|
|
|
845
777
|
...schemas
|
|
846
778
|
);
|
|
847
779
|
}
|
|
848
|
-
function parseNumber({
|
|
780
|
+
function parseNumber({
|
|
781
|
+
zodRef,
|
|
782
|
+
schemas,
|
|
783
|
+
openApiVersion
|
|
784
|
+
}) {
|
|
849
785
|
const baseSchema = {
|
|
850
|
-
type: typeFormat(
|
|
786
|
+
type: typeFormat("number", openApiVersion)
|
|
851
787
|
};
|
|
852
788
|
const { checks = [] } = zodRef._def;
|
|
853
789
|
checks.forEach((item) => {
|
|
854
790
|
switch (item.kind) {
|
|
855
|
-
case
|
|
856
|
-
if (item.inclusive || openApiVersion ===
|
|
791
|
+
case "max":
|
|
792
|
+
if (item.inclusive || openApiVersion === "3.0") {
|
|
857
793
|
baseSchema.maximum = item.value;
|
|
858
794
|
}
|
|
859
795
|
if (!item.inclusive) {
|
|
860
|
-
if (openApiVersion ===
|
|
796
|
+
if (openApiVersion === "3.0") {
|
|
861
797
|
baseSchema.exclusiveMaximum = true;
|
|
862
798
|
} else {
|
|
863
799
|
baseSchema.exclusiveMaximum = item.value;
|
|
864
800
|
}
|
|
865
801
|
}
|
|
866
802
|
break;
|
|
867
|
-
case
|
|
868
|
-
if (item.inclusive || openApiVersion ===
|
|
803
|
+
case "min":
|
|
804
|
+
if (item.inclusive || openApiVersion === "3.0") {
|
|
869
805
|
baseSchema.minimum = item.value;
|
|
870
806
|
}
|
|
871
807
|
if (!item.inclusive) {
|
|
872
|
-
if (openApiVersion ===
|
|
808
|
+
if (openApiVersion === "3.0") {
|
|
873
809
|
baseSchema.exclusiveMinimum = true;
|
|
874
810
|
} else {
|
|
875
811
|
baseSchema.exclusiveMinimum = item.value;
|
|
876
812
|
}
|
|
877
813
|
}
|
|
878
814
|
break;
|
|
879
|
-
case
|
|
880
|
-
baseSchema.type = typeFormat(
|
|
815
|
+
case "int":
|
|
816
|
+
baseSchema.type = typeFormat("integer", openApiVersion);
|
|
881
817
|
break;
|
|
882
|
-
case
|
|
818
|
+
case "multipleOf":
|
|
883
819
|
baseSchema.multipleOf = item.value;
|
|
884
820
|
break;
|
|
885
821
|
}
|
|
@@ -907,41 +843,26 @@ function parseObject({
|
|
|
907
843
|
openApiVersion
|
|
908
844
|
}) {
|
|
909
845
|
let additionalProperties;
|
|
910
|
-
if (
|
|
911
|
-
!(
|
|
912
|
-
zodRef._def.catchall instanceof import_v32.z.ZodNever ||
|
|
913
|
-
zodRef._def.catchall?._def.typeName === 'ZodNever'
|
|
914
|
-
)
|
|
915
|
-
)
|
|
846
|
+
if (!(zodRef._def.catchall instanceof import_v32.z.ZodNever || zodRef._def.catchall?._def.typeName === "ZodNever"))
|
|
916
847
|
additionalProperties = generateSchema(
|
|
917
848
|
zodRef._def.catchall,
|
|
918
849
|
useOutput,
|
|
919
850
|
openApiVersion
|
|
920
851
|
);
|
|
921
|
-
else if (zodRef._def.unknownKeys ===
|
|
852
|
+
else if (zodRef._def.unknownKeys === "passthrough")
|
|
922
853
|
additionalProperties = true;
|
|
923
|
-
else if (zodRef._def.unknownKeys ===
|
|
924
|
-
additionalProperties =
|
|
925
|
-
|
|
926
|
-
|
|
854
|
+
else if (zodRef._def.unknownKeys === "strict") additionalProperties = false;
|
|
855
|
+
additionalProperties = additionalProperties != null ? { additionalProperties } : {};
|
|
856
|
+
const requiredProperties = Object.keys(
|
|
857
|
+
zodRef.shape
|
|
858
|
+
).filter((key) => {
|
|
927
859
|
const item = zodRef.shape[key];
|
|
928
|
-
return (
|
|
929
|
-
!(
|
|
930
|
-
item.isOptional() ||
|
|
931
|
-
item instanceof import_v32.z.ZodDefault ||
|
|
932
|
-
item._def.typeName === 'ZodDefault'
|
|
933
|
-
) &&
|
|
934
|
-
!(
|
|
935
|
-
item instanceof import_v32.z.ZodNever ||
|
|
936
|
-
item._def.typeName === 'ZodDefault'
|
|
937
|
-
)
|
|
938
|
-
);
|
|
860
|
+
return !(item.isOptional() || item instanceof import_v32.z.ZodDefault || item._def.typeName === "ZodDefault") && !(item instanceof import_v32.z.ZodNever || item._def.typeName === "ZodDefault");
|
|
939
861
|
});
|
|
940
|
-
const required =
|
|
941
|
-
requiredProperties.length > 0 ? { required: requiredProperties } : {};
|
|
862
|
+
const required = requiredProperties.length > 0 ? { required: requiredProperties } : {};
|
|
942
863
|
return merge(
|
|
943
864
|
{
|
|
944
|
-
type: typeFormat(
|
|
865
|
+
type: typeFormat("object", openApiVersion),
|
|
945
866
|
properties: iterateZodObject({
|
|
946
867
|
zodRef,
|
|
947
868
|
schemas,
|
|
@@ -953,83 +874,110 @@ function parseObject({
|
|
|
953
874
|
...additionalProperties,
|
|
954
875
|
...hideDefinitions
|
|
955
876
|
},
|
|
956
|
-
zodRef.description
|
|
957
|
-
? { description: zodRef.description, hideDefinitions }
|
|
958
|
-
: {},
|
|
877
|
+
zodRef.description ? { description: zodRef.description, hideDefinitions } : {},
|
|
959
878
|
...schemas
|
|
960
879
|
);
|
|
961
880
|
}
|
|
962
|
-
function parseRecord({
|
|
881
|
+
function parseRecord({
|
|
882
|
+
zodRef,
|
|
883
|
+
schemas,
|
|
884
|
+
useOutput,
|
|
885
|
+
openApiVersion
|
|
886
|
+
}) {
|
|
963
887
|
return merge(
|
|
964
888
|
{
|
|
965
|
-
type: typeFormat(
|
|
966
|
-
additionalProperties:
|
|
967
|
-
zodRef._def.valueType instanceof import_v32.z.ZodUnknown
|
|
968
|
-
? {}
|
|
969
|
-
: generateSchema(zodRef._def.valueType, useOutput, openApiVersion)
|
|
889
|
+
type: typeFormat("object", openApiVersion),
|
|
890
|
+
additionalProperties: zodRef._def.valueType instanceof import_v32.z.ZodUnknown ? {} : generateSchema(zodRef._def.valueType, useOutput, openApiVersion)
|
|
970
891
|
},
|
|
971
892
|
zodRef.description ? { description: zodRef.description } : {},
|
|
972
893
|
...schemas
|
|
973
894
|
);
|
|
974
895
|
}
|
|
975
|
-
function parseBigInt({
|
|
896
|
+
function parseBigInt({
|
|
897
|
+
zodRef,
|
|
898
|
+
schemas,
|
|
899
|
+
openApiVersion
|
|
900
|
+
}) {
|
|
976
901
|
return merge(
|
|
977
902
|
{
|
|
978
|
-
type: typeFormat(
|
|
979
|
-
format:
|
|
903
|
+
type: typeFormat("integer", openApiVersion),
|
|
904
|
+
format: "int64"
|
|
980
905
|
},
|
|
981
906
|
zodRef.description ? { description: zodRef.description } : {},
|
|
982
907
|
...schemas
|
|
983
908
|
);
|
|
984
909
|
}
|
|
985
|
-
function parseBoolean({
|
|
910
|
+
function parseBoolean({
|
|
911
|
+
zodRef,
|
|
912
|
+
schemas,
|
|
913
|
+
openApiVersion
|
|
914
|
+
}) {
|
|
986
915
|
return merge(
|
|
987
|
-
{ type: typeFormat(
|
|
916
|
+
{ type: typeFormat("boolean", openApiVersion) },
|
|
988
917
|
zodRef.description ? { description: zodRef.description } : {},
|
|
989
918
|
...schemas
|
|
990
919
|
);
|
|
991
920
|
}
|
|
992
|
-
function parseDate({
|
|
921
|
+
function parseDate({
|
|
922
|
+
zodRef,
|
|
923
|
+
schemas,
|
|
924
|
+
openApiVersion
|
|
925
|
+
}) {
|
|
993
926
|
return merge(
|
|
994
927
|
{
|
|
995
|
-
type: typeFormat(
|
|
996
|
-
format:
|
|
928
|
+
type: typeFormat("string", openApiVersion),
|
|
929
|
+
format: "date-time"
|
|
997
930
|
},
|
|
998
931
|
zodRef.description ? { description: zodRef.description } : {},
|
|
999
932
|
...schemas
|
|
1000
933
|
);
|
|
1001
934
|
}
|
|
1002
|
-
function parseNull({
|
|
935
|
+
function parseNull({
|
|
936
|
+
zodRef,
|
|
937
|
+
schemas,
|
|
938
|
+
openApiVersion
|
|
939
|
+
}) {
|
|
1003
940
|
return merge(
|
|
1004
|
-
openApiVersion ===
|
|
1005
|
-
|
|
1006
|
-
:
|
|
1007
|
-
|
|
1008
|
-
enum: ['null']
|
|
1009
|
-
},
|
|
941
|
+
openApiVersion === "3.0" ? { type: "null" } : {
|
|
942
|
+
type: ["string", "null"],
|
|
943
|
+
enum: ["null"]
|
|
944
|
+
},
|
|
1010
945
|
zodRef.description ? { description: zodRef.description } : {},
|
|
1011
946
|
...schemas
|
|
1012
947
|
);
|
|
1013
948
|
}
|
|
1014
|
-
function parseOptional({
|
|
949
|
+
function parseOptional({
|
|
950
|
+
schemas,
|
|
951
|
+
zodRef,
|
|
952
|
+
useOutput,
|
|
953
|
+
openApiVersion
|
|
954
|
+
}) {
|
|
1015
955
|
return merge(
|
|
1016
956
|
generateSchema(zodRef.unwrap(), useOutput, openApiVersion),
|
|
1017
957
|
zodRef.description ? { description: zodRef.description } : {},
|
|
1018
958
|
...schemas
|
|
1019
959
|
);
|
|
1020
960
|
}
|
|
1021
|
-
function parseNullable({
|
|
961
|
+
function parseNullable({
|
|
962
|
+
schemas,
|
|
963
|
+
zodRef,
|
|
964
|
+
useOutput,
|
|
965
|
+
openApiVersion
|
|
966
|
+
}) {
|
|
1022
967
|
const schema = generateSchema(zodRef.unwrap(), useOutput, openApiVersion);
|
|
1023
968
|
return merge(
|
|
1024
969
|
schema,
|
|
1025
|
-
openApiVersion ===
|
|
1026
|
-
? { nullable: true }
|
|
1027
|
-
: { type: typeFormat('null', openApiVersion) },
|
|
970
|
+
openApiVersion === "3.0" ? { nullable: true } : { type: typeFormat("null", openApiVersion) },
|
|
1028
971
|
zodRef.description ? { description: zodRef.description } : {},
|
|
1029
972
|
...schemas
|
|
1030
973
|
);
|
|
1031
974
|
}
|
|
1032
|
-
function parseDefault({
|
|
975
|
+
function parseDefault({
|
|
976
|
+
schemas,
|
|
977
|
+
zodRef,
|
|
978
|
+
useOutput,
|
|
979
|
+
openApiVersion
|
|
980
|
+
}) {
|
|
1033
981
|
return merge(
|
|
1034
982
|
{
|
|
1035
983
|
default: zodRef._def.defaultValue(),
|
|
@@ -1039,7 +987,12 @@ function parseDefault({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
|
1039
987
|
...schemas
|
|
1040
988
|
);
|
|
1041
989
|
}
|
|
1042
|
-
function parseArray({
|
|
990
|
+
function parseArray({
|
|
991
|
+
schemas,
|
|
992
|
+
zodRef,
|
|
993
|
+
useOutput,
|
|
994
|
+
openApiVersion
|
|
995
|
+
}) {
|
|
1043
996
|
const constraints = {};
|
|
1044
997
|
if (zodRef._def.exactLength != null) {
|
|
1045
998
|
constraints.minItems = zodRef._def.exactLength.value;
|
|
@@ -1051,7 +1004,7 @@ function parseArray({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
|
1051
1004
|
constraints.maxItems = zodRef._def.maxLength.value;
|
|
1052
1005
|
return merge(
|
|
1053
1006
|
{
|
|
1054
|
-
type: typeFormat(
|
|
1007
|
+
type: typeFormat("array", openApiVersion),
|
|
1055
1008
|
items: generateSchema(zodRef.element, useOutput, openApiVersion),
|
|
1056
1009
|
...constraints
|
|
1057
1010
|
},
|
|
@@ -1059,7 +1012,11 @@ function parseArray({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
|
1059
1012
|
...schemas
|
|
1060
1013
|
);
|
|
1061
1014
|
}
|
|
1062
|
-
function parseLiteral({
|
|
1015
|
+
function parseLiteral({
|
|
1016
|
+
schemas,
|
|
1017
|
+
zodRef,
|
|
1018
|
+
openApiVersion
|
|
1019
|
+
}) {
|
|
1063
1020
|
const type22 = typeof zodRef._def.value;
|
|
1064
1021
|
return merge(
|
|
1065
1022
|
{
|
|
@@ -1070,7 +1027,11 @@ function parseLiteral({ schemas, zodRef, openApiVersion }) {
|
|
|
1070
1027
|
...schemas
|
|
1071
1028
|
);
|
|
1072
1029
|
}
|
|
1073
|
-
function parseEnum({
|
|
1030
|
+
function parseEnum({
|
|
1031
|
+
schemas,
|
|
1032
|
+
zodRef,
|
|
1033
|
+
openApiVersion
|
|
1034
|
+
}) {
|
|
1074
1035
|
const type22 = typeof Object.values(zodRef._def.values)[0];
|
|
1075
1036
|
return merge(
|
|
1076
1037
|
{
|
|
@@ -1081,7 +1042,12 @@ function parseEnum({ schemas, zodRef, openApiVersion }) {
|
|
|
1081
1042
|
...schemas
|
|
1082
1043
|
);
|
|
1083
1044
|
}
|
|
1084
|
-
function parseIntersection({
|
|
1045
|
+
function parseIntersection({
|
|
1046
|
+
schemas,
|
|
1047
|
+
zodRef,
|
|
1048
|
+
useOutput,
|
|
1049
|
+
openApiVersion
|
|
1050
|
+
}) {
|
|
1085
1051
|
return merge(
|
|
1086
1052
|
{
|
|
1087
1053
|
allOf: [
|
|
@@ -1093,20 +1059,20 @@ function parseIntersection({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
|
1093
1059
|
...schemas
|
|
1094
1060
|
);
|
|
1095
1061
|
}
|
|
1096
|
-
function parseUnion({
|
|
1062
|
+
function parseUnion({
|
|
1063
|
+
schemas,
|
|
1064
|
+
zodRef,
|
|
1065
|
+
useOutput,
|
|
1066
|
+
openApiVersion
|
|
1067
|
+
}) {
|
|
1097
1068
|
const contents = zodRef._def.options;
|
|
1098
|
-
if (
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
)
|
|
1103
|
-
) {
|
|
1069
|
+
if (contents.reduce(
|
|
1070
|
+
(prev, content) => prev && content._def.typeName === "ZodLiteral",
|
|
1071
|
+
true
|
|
1072
|
+
)) {
|
|
1104
1073
|
const literals = contents;
|
|
1105
1074
|
const type22 = literals.reduce(
|
|
1106
|
-
(prev, content) =>
|
|
1107
|
-
!prev || prev === typeof content._def.value
|
|
1108
|
-
? typeof content._def.value
|
|
1109
|
-
: null,
|
|
1075
|
+
(prev, content) => !prev || prev === typeof content._def.value ? typeof content._def.value : null,
|
|
1110
1076
|
null
|
|
1111
1077
|
);
|
|
1112
1078
|
if (type22) {
|
|
@@ -1120,15 +1086,12 @@ function parseUnion({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
|
1120
1086
|
);
|
|
1121
1087
|
}
|
|
1122
1088
|
}
|
|
1123
|
-
const oneOfContents =
|
|
1124
|
-
openApiVersion === '3.0'
|
|
1125
|
-
? contents.filter((content) => content._def.typeName !== 'ZodNull')
|
|
1126
|
-
: contents;
|
|
1089
|
+
const oneOfContents = openApiVersion === "3.0" ? contents.filter((content) => content._def.typeName !== "ZodNull") : contents;
|
|
1127
1090
|
const contentsHasNull = contents.length != oneOfContents.length;
|
|
1128
1091
|
return merge(
|
|
1129
1092
|
{
|
|
1130
|
-
oneOf: oneOfContents.map(
|
|
1131
|
-
generateSchema(schema, useOutput, openApiVersion)
|
|
1093
|
+
oneOf: oneOfContents.map(
|
|
1094
|
+
(schema) => generateSchema(schema, useOutput, openApiVersion)
|
|
1132
1095
|
)
|
|
1133
1096
|
},
|
|
1134
1097
|
contentsHasNull ? { nullable: true } : {},
|
|
@@ -1147,34 +1110,50 @@ function parseDiscriminatedUnion({
|
|
|
1147
1110
|
discriminator: {
|
|
1148
1111
|
propertyName: zodRef._def.discriminator
|
|
1149
1112
|
},
|
|
1150
|
-
oneOf: Array.from(
|
|
1151
|
-
|
|
1152
|
-
)
|
|
1113
|
+
oneOf: Array.from(
|
|
1114
|
+
zodRef._def.options.values()
|
|
1115
|
+
).map((schema) => generateSchema(schema, useOutput, openApiVersion))
|
|
1153
1116
|
},
|
|
1154
1117
|
zodRef.description ? { description: zodRef.description } : {},
|
|
1155
1118
|
...schemas
|
|
1156
1119
|
);
|
|
1157
1120
|
}
|
|
1158
|
-
function parseNever({
|
|
1121
|
+
function parseNever({
|
|
1122
|
+
zodRef,
|
|
1123
|
+
schemas
|
|
1124
|
+
}) {
|
|
1159
1125
|
return merge(
|
|
1160
1126
|
{ readOnly: true },
|
|
1161
1127
|
zodRef.description ? { description: zodRef.description } : {},
|
|
1162
1128
|
...schemas
|
|
1163
1129
|
);
|
|
1164
1130
|
}
|
|
1165
|
-
function parseBranded({
|
|
1131
|
+
function parseBranded({
|
|
1132
|
+
schemas,
|
|
1133
|
+
zodRef,
|
|
1134
|
+
useOutput,
|
|
1135
|
+
openApiVersion
|
|
1136
|
+
}) {
|
|
1166
1137
|
return merge(
|
|
1167
1138
|
generateSchema(zodRef._def.type, useOutput, openApiVersion),
|
|
1168
1139
|
...schemas
|
|
1169
1140
|
);
|
|
1170
1141
|
}
|
|
1171
|
-
function catchAllParser({
|
|
1142
|
+
function catchAllParser({
|
|
1143
|
+
zodRef,
|
|
1144
|
+
schemas
|
|
1145
|
+
}) {
|
|
1172
1146
|
return merge(
|
|
1173
1147
|
zodRef.description ? { description: zodRef.description } : {},
|
|
1174
1148
|
...schemas
|
|
1175
1149
|
);
|
|
1176
1150
|
}
|
|
1177
|
-
function parsePipeline({
|
|
1151
|
+
function parsePipeline({
|
|
1152
|
+
schemas,
|
|
1153
|
+
zodRef,
|
|
1154
|
+
useOutput,
|
|
1155
|
+
openApiVersion
|
|
1156
|
+
}) {
|
|
1178
1157
|
return merge(
|
|
1179
1158
|
generateSchema(
|
|
1180
1159
|
useOutput ? zodRef._def.out : zodRef._def.in,
|
|
@@ -1184,7 +1163,12 @@ function parsePipeline({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
|
1184
1163
|
...schemas
|
|
1185
1164
|
);
|
|
1186
1165
|
}
|
|
1187
|
-
function parseReadonly({
|
|
1166
|
+
function parseReadonly({
|
|
1167
|
+
zodRef,
|
|
1168
|
+
useOutput,
|
|
1169
|
+
schemas,
|
|
1170
|
+
openApiVersion
|
|
1171
|
+
}) {
|
|
1188
1172
|
return merge(
|
|
1189
1173
|
generateSchema(zodRef._def.innerType, useOutput, openApiVersion),
|
|
1190
1174
|
zodRef.description ? { description: zodRef.description } : {},
|
|
@@ -1228,10 +1212,10 @@ var workerMap = {
|
|
|
1228
1212
|
ZodPipeline: parsePipeline,
|
|
1229
1213
|
ZodReadonly: parseReadonly
|
|
1230
1214
|
};
|
|
1231
|
-
function generateSchema(zodRef, useOutput = false, openApiVersion =
|
|
1215
|
+
function generateSchema(zodRef, useOutput = false, openApiVersion = "3.1") {
|
|
1232
1216
|
const { metaOpenApi = {} } = zodRef;
|
|
1233
1217
|
const schemas = [
|
|
1234
|
-
...
|
|
1218
|
+
...Array.isArray(metaOpenApi) ? metaOpenApi : [metaOpenApi]
|
|
1235
1219
|
];
|
|
1236
1220
|
try {
|
|
1237
1221
|
const typeName = zodRef._def.typeName;
|
|
@@ -1250,175 +1234,155 @@ function generateSchema(zodRef, useOutput = false, openApiVersion = '3.1') {
|
|
|
1250
1234
|
}
|
|
1251
1235
|
}
|
|
1252
1236
|
function extendZodWithOpenApi(zod, forceOverride = false) {
|
|
1253
|
-
if (
|
|
1254
|
-
!forceOverride &&
|
|
1255
|
-
typeof zod.ZodSchema.prototype.openapi !== 'undefined'
|
|
1256
|
-
) {
|
|
1237
|
+
if (!forceOverride && typeof zod.ZodSchema.prototype.openapi !== "undefined") {
|
|
1257
1238
|
return;
|
|
1258
1239
|
}
|
|
1259
|
-
zod.ZodSchema.prototype.openapi = function
|
|
1240
|
+
zod.ZodSchema.prototype.openapi = function(metadata) {
|
|
1260
1241
|
return extendApi(this, metadata);
|
|
1261
1242
|
};
|
|
1262
1243
|
}
|
|
1263
1244
|
extendZodWithOpenApi(import_v3.z);
|
|
1264
1245
|
var ZodSchemaValidator = class {
|
|
1265
|
-
_Type =
|
|
1246
|
+
_Type = "Zod";
|
|
1266
1247
|
_SchemaCatchall;
|
|
1267
1248
|
_ValidSchemaObject;
|
|
1268
1249
|
string = import_v3.z.string().openapi({
|
|
1269
|
-
title:
|
|
1270
|
-
example:
|
|
1250
|
+
title: "String",
|
|
1251
|
+
example: "a string"
|
|
1271
1252
|
});
|
|
1272
1253
|
uuid = import_v3.z.string().uuid().openapi({
|
|
1273
|
-
title:
|
|
1274
|
-
format:
|
|
1275
|
-
pattern:
|
|
1276
|
-
|
|
1277
|
-
example: 'a8b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6'
|
|
1254
|
+
title: "UUID",
|
|
1255
|
+
format: "uuid",
|
|
1256
|
+
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}$",
|
|
1257
|
+
example: "a8b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6"
|
|
1278
1258
|
});
|
|
1279
1259
|
email = import_v3.z.string().email().openapi({
|
|
1280
|
-
title:
|
|
1281
|
-
format:
|
|
1282
|
-
pattern:
|
|
1283
|
-
example:
|
|
1260
|
+
title: "Email",
|
|
1261
|
+
format: "email",
|
|
1262
|
+
pattern: "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$",
|
|
1263
|
+
example: "a@b.com"
|
|
1284
1264
|
});
|
|
1285
1265
|
uri = import_v3.z.string().url().openapi({
|
|
1286
|
-
title:
|
|
1287
|
-
format:
|
|
1288
|
-
pattern:
|
|
1289
|
-
example:
|
|
1266
|
+
title: "URI",
|
|
1267
|
+
format: "uri",
|
|
1268
|
+
pattern: "^[a-zA-Z][a-zA-Z\\d+-.]*:[^\\s]*$",
|
|
1269
|
+
example: "https://forklaunch.com"
|
|
1290
1270
|
});
|
|
1291
|
-
number = import_v3.z
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
try {
|
|
1306
|
-
if (value instanceof Date) {
|
|
1307
|
-
return BigInt(value.getTime());
|
|
1308
|
-
}
|
|
1309
|
-
switch (typeof value) {
|
|
1310
|
-
case 'number':
|
|
1311
|
-
case 'string':
|
|
1312
|
-
return BigInt(value);
|
|
1313
|
-
case 'boolean':
|
|
1314
|
-
return BigInt(value ? 1 : 0);
|
|
1315
|
-
default:
|
|
1316
|
-
return value;
|
|
1317
|
-
}
|
|
1318
|
-
} catch {
|
|
1319
|
-
return value;
|
|
1271
|
+
number = import_v3.z.preprocess((value) => {
|
|
1272
|
+
try {
|
|
1273
|
+
return Number(value);
|
|
1274
|
+
} catch {
|
|
1275
|
+
return value;
|
|
1276
|
+
}
|
|
1277
|
+
}, import_v3.z.number()).openapi({
|
|
1278
|
+
title: "Number",
|
|
1279
|
+
example: 123
|
|
1280
|
+
});
|
|
1281
|
+
bigint = import_v3.z.preprocess((value) => {
|
|
1282
|
+
try {
|
|
1283
|
+
if (value instanceof Date) {
|
|
1284
|
+
return BigInt(value.getTime());
|
|
1320
1285
|
}
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
.preprocess((val) => {
|
|
1330
|
-
if (typeof val === 'string') {
|
|
1331
|
-
if (val.toLowerCase() === 'true') return true;
|
|
1332
|
-
if (val.toLowerCase() === 'false') return false;
|
|
1286
|
+
switch (typeof value) {
|
|
1287
|
+
case "number":
|
|
1288
|
+
case "string":
|
|
1289
|
+
return BigInt(value);
|
|
1290
|
+
case "boolean":
|
|
1291
|
+
return BigInt(value ? 1 : 0);
|
|
1292
|
+
default:
|
|
1293
|
+
return value;
|
|
1333
1294
|
}
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1295
|
+
} catch {
|
|
1296
|
+
return value;
|
|
1297
|
+
}
|
|
1298
|
+
}, import_v3.z.bigint()).openapi({
|
|
1299
|
+
title: "BigInt",
|
|
1300
|
+
type: "integer",
|
|
1301
|
+
format: "int64",
|
|
1302
|
+
example: 123n
|
|
1303
|
+
});
|
|
1304
|
+
boolean = import_v3.z.preprocess((val) => {
|
|
1305
|
+
if (typeof val === "string") {
|
|
1306
|
+
if (val.toLowerCase() === "true") return true;
|
|
1307
|
+
if (val.toLowerCase() === "false") return false;
|
|
1308
|
+
}
|
|
1309
|
+
return val;
|
|
1310
|
+
}, import_v3.z.boolean()).openapi({
|
|
1311
|
+
title: "Boolean",
|
|
1312
|
+
example: true
|
|
1313
|
+
});
|
|
1314
|
+
date = import_v3.z.preprocess((value) => {
|
|
1315
|
+
try {
|
|
1316
|
+
switch (typeof value) {
|
|
1317
|
+
case "string":
|
|
1318
|
+
return new Date(value);
|
|
1319
|
+
case "number":
|
|
1320
|
+
return new Date(value);
|
|
1321
|
+
default:
|
|
1322
|
+
return value;
|
|
1353
1323
|
}
|
|
1354
|
-
}
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1324
|
+
} catch {
|
|
1325
|
+
return value;
|
|
1326
|
+
}
|
|
1327
|
+
}, import_v3.z.date()).openapi({
|
|
1328
|
+
title: "Date",
|
|
1329
|
+
type: "string",
|
|
1330
|
+
format: "date-time",
|
|
1331
|
+
example: "2025-05-16T21:13:04.123Z"
|
|
1332
|
+
});
|
|
1361
1333
|
symbol = import_v3.z.symbol().openapi({
|
|
1362
|
-
title:
|
|
1363
|
-
example: Symbol(
|
|
1334
|
+
title: "Symbol",
|
|
1335
|
+
example: Symbol("symbol")
|
|
1336
|
+
});
|
|
1337
|
+
nullish = import_v3.z.union([import_v3.z.void(), import_v3.z.null(), import_v3.z.undefined()]).openapi({
|
|
1338
|
+
title: "Nullish",
|
|
1339
|
+
type: "null",
|
|
1340
|
+
example: null
|
|
1364
1341
|
});
|
|
1365
|
-
nullish = import_v3.z
|
|
1366
|
-
.union([import_v3.z.void(), import_v3.z.null(), import_v3.z.undefined()])
|
|
1367
|
-
.openapi({
|
|
1368
|
-
title: 'Nullish',
|
|
1369
|
-
type: 'null',
|
|
1370
|
-
example: null
|
|
1371
|
-
});
|
|
1372
1342
|
void = import_v3.z.void().openapi({
|
|
1373
|
-
title:
|
|
1374
|
-
type:
|
|
1343
|
+
title: "Void",
|
|
1344
|
+
type: "null",
|
|
1375
1345
|
example: void 0
|
|
1376
1346
|
});
|
|
1377
1347
|
null = import_v3.z.null().openapi({
|
|
1378
|
-
title:
|
|
1379
|
-
type:
|
|
1348
|
+
title: "Null",
|
|
1349
|
+
type: "null",
|
|
1380
1350
|
example: null
|
|
1381
1351
|
});
|
|
1382
1352
|
undefined = import_v3.z.undefined().openapi({
|
|
1383
|
-
title:
|
|
1384
|
-
type:
|
|
1353
|
+
title: "Undefined",
|
|
1354
|
+
type: "null",
|
|
1385
1355
|
example: void 0
|
|
1386
1356
|
});
|
|
1387
1357
|
any = import_v3.z.any().openapi({
|
|
1388
|
-
title:
|
|
1389
|
-
type:
|
|
1390
|
-
example:
|
|
1358
|
+
title: "Any",
|
|
1359
|
+
type: "object",
|
|
1360
|
+
example: "any"
|
|
1391
1361
|
});
|
|
1392
1362
|
unknown = import_v3.z.unknown().openapi({
|
|
1393
|
-
title:
|
|
1394
|
-
type:
|
|
1395
|
-
example:
|
|
1363
|
+
title: "Unknown",
|
|
1364
|
+
type: "object",
|
|
1365
|
+
example: "unknown"
|
|
1396
1366
|
});
|
|
1397
1367
|
never = import_v3.z.never().openapi({
|
|
1398
|
-
title:
|
|
1399
|
-
type:
|
|
1400
|
-
example:
|
|
1368
|
+
title: "Never",
|
|
1369
|
+
type: "null",
|
|
1370
|
+
example: "never"
|
|
1371
|
+
});
|
|
1372
|
+
binary = import_v3.z.string().transform((val) => new Uint8Array(Buffer.from(val, "base64"))).openapi({
|
|
1373
|
+
title: "Binary",
|
|
1374
|
+
type: "string",
|
|
1375
|
+
format: "binary",
|
|
1376
|
+
example: "a base-64 encodable string"
|
|
1377
|
+
});
|
|
1378
|
+
file = import_v3.z.instanceof(Buffer).transform((val) => {
|
|
1379
|
+
return new Blob([val]);
|
|
1380
|
+
}).openapi({
|
|
1381
|
+
title: "File",
|
|
1382
|
+
type: "string",
|
|
1383
|
+
format: "binary",
|
|
1384
|
+
example: "a base-64 encodable blob or file"
|
|
1401
1385
|
});
|
|
1402
|
-
binary = import_v3.z
|
|
1403
|
-
.string()
|
|
1404
|
-
.transform((val) => new Uint8Array(Buffer.from(val, 'base64')))
|
|
1405
|
-
.openapi({
|
|
1406
|
-
title: 'Binary',
|
|
1407
|
-
type: 'string',
|
|
1408
|
-
format: 'binary',
|
|
1409
|
-
example: 'a base-64 encodable string'
|
|
1410
|
-
});
|
|
1411
|
-
file = import_v3.z
|
|
1412
|
-
.instanceof(Buffer)
|
|
1413
|
-
.transform((val) => {
|
|
1414
|
-
return new Blob([val]);
|
|
1415
|
-
})
|
|
1416
|
-
.openapi({
|
|
1417
|
-
title: 'File',
|
|
1418
|
-
type: 'string',
|
|
1419
|
-
format: 'binary',
|
|
1420
|
-
example: 'a base-64 encodable blob or file'
|
|
1421
|
-
});
|
|
1422
1386
|
type = () => this.any;
|
|
1423
1387
|
/**
|
|
1424
1388
|
* Compiles schema if this exists, for optimal performance.
|
|
@@ -1435,11 +1399,7 @@ var ZodSchemaValidator = class {
|
|
|
1435
1399
|
* @returns {ZodResolve<T>} The resolved schema.
|
|
1436
1400
|
*/
|
|
1437
1401
|
schemify(schema) {
|
|
1438
|
-
if (
|
|
1439
|
-
typeof schema === 'string' ||
|
|
1440
|
-
typeof schema === 'number' ||
|
|
1441
|
-
typeof schema === 'boolean'
|
|
1442
|
-
) {
|
|
1402
|
+
if (typeof schema === "string" || typeof schema === "number" || typeof schema === "boolean") {
|
|
1443
1403
|
return import_v3.z.literal(schema);
|
|
1444
1404
|
}
|
|
1445
1405
|
if (schema instanceof import_v3.ZodType) {
|
|
@@ -1480,7 +1440,9 @@ var ZodSchemaValidator = class {
|
|
|
1480
1440
|
*/
|
|
1481
1441
|
union(schemas) {
|
|
1482
1442
|
const resolvedSchemas = schemas.map((schema) => this.schemify(schema));
|
|
1483
|
-
return import_v3.z.union(
|
|
1443
|
+
return import_v3.z.union(
|
|
1444
|
+
resolvedSchemas
|
|
1445
|
+
);
|
|
1484
1446
|
}
|
|
1485
1447
|
/**
|
|
1486
1448
|
* Create a literal schema.
|
|
@@ -1496,7 +1458,9 @@ var ZodSchemaValidator = class {
|
|
|
1496
1458
|
* @returns {ZodUnion<UnionZodResolve<[T, T, ...T[]]>>} The enum schema.
|
|
1497
1459
|
*/
|
|
1498
1460
|
enum_(schemaEnum) {
|
|
1499
|
-
return this.union(
|
|
1461
|
+
return this.union(
|
|
1462
|
+
Object.values(schemaEnum)
|
|
1463
|
+
);
|
|
1500
1464
|
}
|
|
1501
1465
|
/**
|
|
1502
1466
|
* Create a function schema.
|
|
@@ -1507,10 +1471,7 @@ var ZodSchemaValidator = class {
|
|
|
1507
1471
|
function_(args, returnType) {
|
|
1508
1472
|
const schemaArgs = args.map((schema) => this.schemify(schema));
|
|
1509
1473
|
const schemaReturnType = this.schemify(returnType);
|
|
1510
|
-
return import_v3.z.function(
|
|
1511
|
-
import_v3.z.tuple(schemaArgs),
|
|
1512
|
-
schemaReturnType
|
|
1513
|
-
);
|
|
1474
|
+
return import_v3.z.function(import_v3.z.tuple(schemaArgs), schemaReturnType);
|
|
1514
1475
|
}
|
|
1515
1476
|
/**
|
|
1516
1477
|
* Create a record schema.
|
|
@@ -1568,33 +1529,31 @@ var ZodSchemaValidator = class {
|
|
|
1568
1529
|
parse(schema, value) {
|
|
1569
1530
|
const resolvedSchema = this.schemify(schema);
|
|
1570
1531
|
const result = resolvedSchema.safeParse(value);
|
|
1571
|
-
return result.success
|
|
1572
|
-
|
|
1573
|
-
: {
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
})
|
|
1597
|
-
};
|
|
1532
|
+
return result.success ? { ok: true, value: result.data } : {
|
|
1533
|
+
ok: false,
|
|
1534
|
+
errors: result.error.errors.flatMap((error) => {
|
|
1535
|
+
switch (error.code) {
|
|
1536
|
+
case "invalid_union":
|
|
1537
|
+
return error.unionErrors.flatMap(
|
|
1538
|
+
(unionError, idx) => unionError.errors.map((e) => ({
|
|
1539
|
+
path: [
|
|
1540
|
+
`Union Schema Variant ${idx}`,
|
|
1541
|
+
...error.path.map((p) => p.toString()),
|
|
1542
|
+
...e.path.map((p) => p.toString())
|
|
1543
|
+
],
|
|
1544
|
+
message: e.message
|
|
1545
|
+
}))
|
|
1546
|
+
);
|
|
1547
|
+
default:
|
|
1548
|
+
return [
|
|
1549
|
+
{
|
|
1550
|
+
path: error.path.map((p) => p.toString()),
|
|
1551
|
+
message: error.message
|
|
1552
|
+
}
|
|
1553
|
+
];
|
|
1554
|
+
}
|
|
1555
|
+
})
|
|
1556
|
+
};
|
|
1598
1557
|
}
|
|
1599
1558
|
/**
|
|
1600
1559
|
* Convert a schema to an OpenAPI schema object.
|
|
@@ -1643,7 +1602,7 @@ var openapi2 = StaticSchemaValidator2.openapi.bind(StaticSchemaValidator2);
|
|
|
1643
1602
|
// domain/schemas/zod/bullMqWorker.schema.ts
|
|
1644
1603
|
var BullMqWorkerOptionsSchema2 = {
|
|
1645
1604
|
queueOptions: type2(),
|
|
1646
|
-
backoffType: union2([literal2(
|
|
1605
|
+
backoffType: union2([literal2("exponential"), literal2("fixed")]),
|
|
1647
1606
|
retries: number2,
|
|
1648
1607
|
interval: number2
|
|
1649
1608
|
};
|
|
@@ -1654,7 +1613,6 @@ var BullMqWorkerSchemas = (0, import_internal.serviceSchemaResolver)(
|
|
|
1654
1613
|
() => BullMqWorkerOptionsSchema2
|
|
1655
1614
|
);
|
|
1656
1615
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1657
|
-
0 &&
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
});
|
|
1616
|
+
0 && (module.exports = {
|
|
1617
|
+
BullMqWorkerSchemas
|
|
1618
|
+
});
|