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