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