@forklaunch/implementation-worker-redis 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 +26 -12
- package/lib/consumers/index.d.ts +26 -12
- package/lib/consumers/index.js +24 -15
- package/lib/consumers/index.mjs +13 -11
- package/lib/domain/schemas/index.d.mts +51 -7
- package/lib/domain/schemas/index.d.ts +51 -7
- package/lib/domain/schemas/index.js +575 -533
- package/lib/domain/schemas/index.mjs +539 -537
- package/lib/domain/types/index.d.mts +3 -3
- package/lib/domain/types/index.d.ts +3 -3
- 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 +12 -7
- package/lib/producers/index.mjs +1 -3
- 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/redisWorker.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
|
}
|
|
@@ -584,46 +608,55 @@ var RedisWorkerOptionsSchema = {
|
|
|
584
608
|
interval: number
|
|
585
609
|
};
|
|
586
610
|
|
|
587
|
-
// ../../../node_modules/.pnpm/@forklaunch+validator@0.9.
|
|
588
|
-
import {
|
|
589
|
-
z as z2,
|
|
590
|
-
ZodType
|
|
591
|
-
} from "zod/v3";
|
|
611
|
+
// ../../../node_modules/.pnpm/@forklaunch+validator@0.9.4/node_modules/@forklaunch/validator/lib/src/zod/index.mjs
|
|
612
|
+
import { z as z2, ZodType } from 'zod/v3';
|
|
592
613
|
|
|
593
614
|
// ../../../node_modules/.pnpm/ts-deepmerge@7.0.3/node_modules/ts-deepmerge/esm/index.js
|
|
594
615
|
var isObject = (obj) => {
|
|
595
|
-
if (typeof obj ===
|
|
596
|
-
if (typeof Object.getPrototypeOf ===
|
|
616
|
+
if (typeof obj === 'object' && obj !== null) {
|
|
617
|
+
if (typeof Object.getPrototypeOf === 'function') {
|
|
597
618
|
const prototype = Object.getPrototypeOf(obj);
|
|
598
619
|
return prototype === Object.prototype || prototype === null;
|
|
599
620
|
}
|
|
600
|
-
return Object.prototype.toString.call(obj) ===
|
|
621
|
+
return Object.prototype.toString.call(obj) === '[object Object]';
|
|
601
622
|
}
|
|
602
623
|
return false;
|
|
603
624
|
};
|
|
604
|
-
var merge = (...objects) =>
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
if (Array.isArray(current)) {
|
|
609
|
-
throw new TypeError("Arguments provided to ts-deepmerge must be objects, not arrays.");
|
|
610
|
-
}
|
|
611
|
-
Object.keys(current).forEach((key) => {
|
|
612
|
-
if (["__proto__", "constructor", "prototype"].includes(key)) {
|
|
613
|
-
return;
|
|
625
|
+
var merge = (...objects) =>
|
|
626
|
+
objects.reduce((result, current) => {
|
|
627
|
+
if (current === void 0) {
|
|
628
|
+
return result;
|
|
614
629
|
}
|
|
615
|
-
if (Array.isArray(
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
} else if (!isObject(result[key]) && isObject(current[key])) {
|
|
620
|
-
result[key] = merge(current[key], void 0);
|
|
621
|
-
} else {
|
|
622
|
-
result[key] = current[key] === void 0 ? merge.options.allowUndefinedOverrides ? current[key] : result[key] : current[key];
|
|
630
|
+
if (Array.isArray(current)) {
|
|
631
|
+
throw new TypeError(
|
|
632
|
+
'Arguments provided to ts-deepmerge must be objects, not arrays.'
|
|
633
|
+
);
|
|
623
634
|
}
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
635
|
+
Object.keys(current).forEach((key) => {
|
|
636
|
+
if (['__proto__', 'constructor', 'prototype'].includes(key)) {
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
639
|
+
if (Array.isArray(result[key]) && Array.isArray(current[key])) {
|
|
640
|
+
result[key] = merge.options.mergeArrays
|
|
641
|
+
? merge.options.uniqueArrayItems
|
|
642
|
+
? Array.from(new Set(result[key].concat(current[key])))
|
|
643
|
+
: [...result[key], ...current[key]]
|
|
644
|
+
: current[key];
|
|
645
|
+
} else if (isObject(result[key]) && isObject(current[key])) {
|
|
646
|
+
result[key] = merge(result[key], current[key]);
|
|
647
|
+
} else if (!isObject(result[key]) && isObject(current[key])) {
|
|
648
|
+
result[key] = merge(current[key], void 0);
|
|
649
|
+
} else {
|
|
650
|
+
result[key] =
|
|
651
|
+
current[key] === void 0
|
|
652
|
+
? merge.options.allowUndefinedOverrides
|
|
653
|
+
? current[key]
|
|
654
|
+
: result[key]
|
|
655
|
+
: current[key];
|
|
656
|
+
}
|
|
657
|
+
});
|
|
658
|
+
return result;
|
|
659
|
+
}, {});
|
|
627
660
|
var defaultOptions = {
|
|
628
661
|
allowUndefinedOverrides: true,
|
|
629
662
|
mergeArrays: true,
|
|
@@ -637,8 +670,8 @@ merge.withOptions = (options, ...objects) => {
|
|
|
637
670
|
return result;
|
|
638
671
|
};
|
|
639
672
|
|
|
640
|
-
// ../../../node_modules/.pnpm/@forklaunch+validator@0.9.
|
|
641
|
-
import { z } from
|
|
673
|
+
// ../../../node_modules/.pnpm/@forklaunch+validator@0.9.4/node_modules/@forklaunch/validator/lib/src/zod/index.mjs
|
|
674
|
+
import { z } from 'zod/v3';
|
|
642
675
|
function extendApi(schema, schemaObject = {}) {
|
|
643
676
|
const This = schema.constructor;
|
|
644
677
|
const newSchema = new This(schema._def);
|
|
@@ -655,89 +688,96 @@ function iterateZodObject({
|
|
|
655
688
|
hideDefinitions,
|
|
656
689
|
openApiVersion
|
|
657
690
|
}) {
|
|
658
|
-
const reduced = Object.keys(zodRef.shape)
|
|
659
|
-
(
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
691
|
+
const reduced = Object.keys(zodRef.shape)
|
|
692
|
+
.filter((key) => hideDefinitions?.includes(key) === false)
|
|
693
|
+
.reduce(
|
|
694
|
+
(carry, key) => ({
|
|
695
|
+
...carry,
|
|
696
|
+
[key]: generateSchema(zodRef.shape[key], useOutput, openApiVersion)
|
|
697
|
+
}),
|
|
698
|
+
{}
|
|
699
|
+
);
|
|
665
700
|
return reduced;
|
|
666
701
|
}
|
|
667
702
|
function typeFormat(type22, openApiVersion) {
|
|
668
|
-
return openApiVersion ===
|
|
703
|
+
return openApiVersion === '3.0' ? type22 : [type22];
|
|
669
704
|
}
|
|
670
|
-
function parseTransformation({
|
|
671
|
-
zodRef,
|
|
672
|
-
schemas,
|
|
673
|
-
useOutput,
|
|
674
|
-
openApiVersion
|
|
675
|
-
}) {
|
|
705
|
+
function parseTransformation({ zodRef, schemas, useOutput, openApiVersion }) {
|
|
676
706
|
const input = generateSchema(zodRef._def.schema, useOutput, openApiVersion);
|
|
677
|
-
let output =
|
|
707
|
+
let output = 'undefined';
|
|
678
708
|
if (useOutput && zodRef._def.effect) {
|
|
679
|
-
const effect =
|
|
680
|
-
|
|
709
|
+
const effect =
|
|
710
|
+
zodRef._def.effect.type === 'transform' ? zodRef._def.effect : null;
|
|
711
|
+
if (effect && 'transform' in effect) {
|
|
681
712
|
try {
|
|
682
713
|
const type22 = Array.isArray(input.type) ? input.type[0] : input.type;
|
|
683
714
|
output = typeof effect.transform(
|
|
684
|
-
[
|
|
715
|
+
['integer', 'number'].includes(`${type22}`)
|
|
716
|
+
? 0
|
|
717
|
+
: 'string' === type22
|
|
718
|
+
? ''
|
|
719
|
+
: 'boolean' === type22
|
|
720
|
+
? false
|
|
721
|
+
: 'object' === type22
|
|
722
|
+
? {}
|
|
723
|
+
: 'null' === type22
|
|
724
|
+
? null
|
|
725
|
+
: 'array' === type22
|
|
726
|
+
? []
|
|
727
|
+
: void 0,
|
|
685
728
|
{ addIssue: () => void 0, path: [] }
|
|
686
729
|
// TODO: Discover if context is necessary here
|
|
687
730
|
);
|
|
688
|
-
} catch {
|
|
689
|
-
}
|
|
731
|
+
} catch {}
|
|
690
732
|
}
|
|
691
733
|
}
|
|
692
734
|
const outputType = output;
|
|
693
735
|
return merge(
|
|
694
736
|
{
|
|
695
|
-
...zodRef.description ? { description: zodRef.description } : {},
|
|
737
|
+
...(zodRef.description ? { description: zodRef.description } : {}),
|
|
696
738
|
...input,
|
|
697
|
-
...[
|
|
698
|
-
|
|
699
|
-
|
|
739
|
+
...(['number', 'string', 'boolean', 'null'].includes(output)
|
|
740
|
+
? {
|
|
741
|
+
type: typeFormat(outputType, openApiVersion)
|
|
742
|
+
}
|
|
743
|
+
: {})
|
|
700
744
|
},
|
|
701
745
|
...schemas
|
|
702
746
|
);
|
|
703
747
|
}
|
|
704
|
-
function parseString({
|
|
705
|
-
zodRef,
|
|
706
|
-
schemas,
|
|
707
|
-
openApiVersion
|
|
708
|
-
}) {
|
|
748
|
+
function parseString({ zodRef, schemas, openApiVersion }) {
|
|
709
749
|
const baseSchema = {
|
|
710
|
-
type: typeFormat(
|
|
750
|
+
type: typeFormat('string', openApiVersion)
|
|
711
751
|
};
|
|
712
752
|
const { checks = [] } = zodRef._def;
|
|
713
753
|
checks.forEach((item) => {
|
|
714
754
|
switch (item.kind) {
|
|
715
|
-
case
|
|
716
|
-
baseSchema.format =
|
|
755
|
+
case 'email':
|
|
756
|
+
baseSchema.format = 'email';
|
|
717
757
|
break;
|
|
718
|
-
case
|
|
719
|
-
baseSchema.format =
|
|
758
|
+
case 'uuid':
|
|
759
|
+
baseSchema.format = 'uuid';
|
|
720
760
|
break;
|
|
721
|
-
case
|
|
722
|
-
baseSchema.format =
|
|
761
|
+
case 'cuid':
|
|
762
|
+
baseSchema.format = 'cuid';
|
|
723
763
|
break;
|
|
724
|
-
case
|
|
725
|
-
baseSchema.format =
|
|
764
|
+
case 'url':
|
|
765
|
+
baseSchema.format = 'uri';
|
|
726
766
|
break;
|
|
727
|
-
case
|
|
728
|
-
baseSchema.format =
|
|
767
|
+
case 'datetime':
|
|
768
|
+
baseSchema.format = 'date-time';
|
|
729
769
|
break;
|
|
730
|
-
case
|
|
770
|
+
case 'length':
|
|
731
771
|
baseSchema.minLength = item.value;
|
|
732
772
|
baseSchema.maxLength = item.value;
|
|
733
773
|
break;
|
|
734
|
-
case
|
|
774
|
+
case 'max':
|
|
735
775
|
baseSchema.maxLength = item.value;
|
|
736
776
|
break;
|
|
737
|
-
case
|
|
777
|
+
case 'min':
|
|
738
778
|
baseSchema.minLength = item.value;
|
|
739
779
|
break;
|
|
740
|
-
case
|
|
780
|
+
case 'regex':
|
|
741
781
|
baseSchema.pattern = item.regex.source;
|
|
742
782
|
break;
|
|
743
783
|
}
|
|
@@ -748,45 +788,41 @@ function parseString({
|
|
|
748
788
|
...schemas
|
|
749
789
|
);
|
|
750
790
|
}
|
|
751
|
-
function parseNumber({
|
|
752
|
-
zodRef,
|
|
753
|
-
schemas,
|
|
754
|
-
openApiVersion
|
|
755
|
-
}) {
|
|
791
|
+
function parseNumber({ zodRef, schemas, openApiVersion }) {
|
|
756
792
|
const baseSchema = {
|
|
757
|
-
type: typeFormat(
|
|
793
|
+
type: typeFormat('number', openApiVersion)
|
|
758
794
|
};
|
|
759
795
|
const { checks = [] } = zodRef._def;
|
|
760
796
|
checks.forEach((item) => {
|
|
761
797
|
switch (item.kind) {
|
|
762
|
-
case
|
|
763
|
-
if (item.inclusive || openApiVersion ===
|
|
798
|
+
case 'max':
|
|
799
|
+
if (item.inclusive || openApiVersion === '3.0') {
|
|
764
800
|
baseSchema.maximum = item.value;
|
|
765
801
|
}
|
|
766
802
|
if (!item.inclusive) {
|
|
767
|
-
if (openApiVersion ===
|
|
803
|
+
if (openApiVersion === '3.0') {
|
|
768
804
|
baseSchema.exclusiveMaximum = true;
|
|
769
805
|
} else {
|
|
770
806
|
baseSchema.exclusiveMaximum = item.value;
|
|
771
807
|
}
|
|
772
808
|
}
|
|
773
809
|
break;
|
|
774
|
-
case
|
|
775
|
-
if (item.inclusive || openApiVersion ===
|
|
810
|
+
case 'min':
|
|
811
|
+
if (item.inclusive || openApiVersion === '3.0') {
|
|
776
812
|
baseSchema.minimum = item.value;
|
|
777
813
|
}
|
|
778
814
|
if (!item.inclusive) {
|
|
779
|
-
if (openApiVersion ===
|
|
815
|
+
if (openApiVersion === '3.0') {
|
|
780
816
|
baseSchema.exclusiveMinimum = true;
|
|
781
817
|
} else {
|
|
782
818
|
baseSchema.exclusiveMinimum = item.value;
|
|
783
819
|
}
|
|
784
820
|
}
|
|
785
821
|
break;
|
|
786
|
-
case
|
|
787
|
-
baseSchema.type = typeFormat(
|
|
822
|
+
case 'int':
|
|
823
|
+
baseSchema.type = typeFormat('integer', openApiVersion);
|
|
788
824
|
break;
|
|
789
|
-
case
|
|
825
|
+
case 'multipleOf':
|
|
790
826
|
baseSchema.multipleOf = item.value;
|
|
791
827
|
break;
|
|
792
828
|
}
|
|
@@ -814,26 +850,37 @@ function parseObject({
|
|
|
814
850
|
openApiVersion
|
|
815
851
|
}) {
|
|
816
852
|
let additionalProperties;
|
|
817
|
-
if (
|
|
853
|
+
if (
|
|
854
|
+
!(
|
|
855
|
+
zodRef._def.catchall instanceof z.ZodNever ||
|
|
856
|
+
zodRef._def.catchall?._def.typeName === 'ZodNever'
|
|
857
|
+
)
|
|
858
|
+
)
|
|
818
859
|
additionalProperties = generateSchema(
|
|
819
860
|
zodRef._def.catchall,
|
|
820
861
|
useOutput,
|
|
821
862
|
openApiVersion
|
|
822
863
|
);
|
|
823
|
-
else if (zodRef._def.unknownKeys ===
|
|
864
|
+
else if (zodRef._def.unknownKeys === 'passthrough')
|
|
824
865
|
additionalProperties = true;
|
|
825
|
-
else if (zodRef._def.unknownKeys ===
|
|
826
|
-
additionalProperties =
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
).filter((key) => {
|
|
866
|
+
else if (zodRef._def.unknownKeys === 'strict') additionalProperties = false;
|
|
867
|
+
additionalProperties =
|
|
868
|
+
additionalProperties != null ? { additionalProperties } : {};
|
|
869
|
+
const requiredProperties = Object.keys(zodRef.shape).filter((key) => {
|
|
830
870
|
const item = zodRef.shape[key];
|
|
831
|
-
return
|
|
871
|
+
return (
|
|
872
|
+
!(
|
|
873
|
+
item.isOptional() ||
|
|
874
|
+
item instanceof z.ZodDefault ||
|
|
875
|
+
item._def.typeName === 'ZodDefault'
|
|
876
|
+
) && !(item instanceof z.ZodNever || item._def.typeName === 'ZodDefault')
|
|
877
|
+
);
|
|
832
878
|
});
|
|
833
|
-
const required =
|
|
879
|
+
const required =
|
|
880
|
+
requiredProperties.length > 0 ? { required: requiredProperties } : {};
|
|
834
881
|
return merge(
|
|
835
882
|
{
|
|
836
|
-
type: typeFormat(
|
|
883
|
+
type: typeFormat('object', openApiVersion),
|
|
837
884
|
properties: iterateZodObject({
|
|
838
885
|
zodRef,
|
|
839
886
|
schemas,
|
|
@@ -845,110 +892,83 @@ function parseObject({
|
|
|
845
892
|
...additionalProperties,
|
|
846
893
|
...hideDefinitions
|
|
847
894
|
},
|
|
848
|
-
zodRef.description
|
|
895
|
+
zodRef.description
|
|
896
|
+
? { description: zodRef.description, hideDefinitions }
|
|
897
|
+
: {},
|
|
849
898
|
...schemas
|
|
850
899
|
);
|
|
851
900
|
}
|
|
852
|
-
function parseRecord({
|
|
853
|
-
zodRef,
|
|
854
|
-
schemas,
|
|
855
|
-
useOutput,
|
|
856
|
-
openApiVersion
|
|
857
|
-
}) {
|
|
901
|
+
function parseRecord({ zodRef, schemas, useOutput, openApiVersion }) {
|
|
858
902
|
return merge(
|
|
859
903
|
{
|
|
860
|
-
type: typeFormat(
|
|
861
|
-
additionalProperties:
|
|
904
|
+
type: typeFormat('object', openApiVersion),
|
|
905
|
+
additionalProperties:
|
|
906
|
+
zodRef._def.valueType instanceof z.ZodUnknown
|
|
907
|
+
? {}
|
|
908
|
+
: generateSchema(zodRef._def.valueType, useOutput, openApiVersion)
|
|
862
909
|
},
|
|
863
910
|
zodRef.description ? { description: zodRef.description } : {},
|
|
864
911
|
...schemas
|
|
865
912
|
);
|
|
866
913
|
}
|
|
867
|
-
function parseBigInt({
|
|
868
|
-
zodRef,
|
|
869
|
-
schemas,
|
|
870
|
-
openApiVersion
|
|
871
|
-
}) {
|
|
914
|
+
function parseBigInt({ zodRef, schemas, openApiVersion }) {
|
|
872
915
|
return merge(
|
|
873
916
|
{
|
|
874
|
-
type: typeFormat(
|
|
875
|
-
format:
|
|
917
|
+
type: typeFormat('integer', openApiVersion),
|
|
918
|
+
format: 'int64'
|
|
876
919
|
},
|
|
877
920
|
zodRef.description ? { description: zodRef.description } : {},
|
|
878
921
|
...schemas
|
|
879
922
|
);
|
|
880
923
|
}
|
|
881
|
-
function parseBoolean({
|
|
882
|
-
zodRef,
|
|
883
|
-
schemas,
|
|
884
|
-
openApiVersion
|
|
885
|
-
}) {
|
|
924
|
+
function parseBoolean({ zodRef, schemas, openApiVersion }) {
|
|
886
925
|
return merge(
|
|
887
|
-
{ type: typeFormat(
|
|
926
|
+
{ type: typeFormat('boolean', openApiVersion) },
|
|
888
927
|
zodRef.description ? { description: zodRef.description } : {},
|
|
889
928
|
...schemas
|
|
890
929
|
);
|
|
891
930
|
}
|
|
892
|
-
function parseDate({
|
|
893
|
-
zodRef,
|
|
894
|
-
schemas,
|
|
895
|
-
openApiVersion
|
|
896
|
-
}) {
|
|
931
|
+
function parseDate({ zodRef, schemas, openApiVersion }) {
|
|
897
932
|
return merge(
|
|
898
933
|
{
|
|
899
|
-
type: typeFormat(
|
|
900
|
-
format:
|
|
934
|
+
type: typeFormat('string', openApiVersion),
|
|
935
|
+
format: 'date-time'
|
|
901
936
|
},
|
|
902
937
|
zodRef.description ? { description: zodRef.description } : {},
|
|
903
938
|
...schemas
|
|
904
939
|
);
|
|
905
940
|
}
|
|
906
|
-
function parseNull({
|
|
907
|
-
zodRef,
|
|
908
|
-
schemas,
|
|
909
|
-
openApiVersion
|
|
910
|
-
}) {
|
|
941
|
+
function parseNull({ zodRef, schemas, openApiVersion }) {
|
|
911
942
|
return merge(
|
|
912
|
-
openApiVersion ===
|
|
913
|
-
type:
|
|
914
|
-
|
|
915
|
-
|
|
943
|
+
openApiVersion === '3.0'
|
|
944
|
+
? { type: 'null' }
|
|
945
|
+
: {
|
|
946
|
+
type: ['string', 'null'],
|
|
947
|
+
enum: ['null']
|
|
948
|
+
},
|
|
916
949
|
zodRef.description ? { description: zodRef.description } : {},
|
|
917
950
|
...schemas
|
|
918
951
|
);
|
|
919
952
|
}
|
|
920
|
-
function parseOptional({
|
|
921
|
-
schemas,
|
|
922
|
-
zodRef,
|
|
923
|
-
useOutput,
|
|
924
|
-
openApiVersion
|
|
925
|
-
}) {
|
|
953
|
+
function parseOptional({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
926
954
|
return merge(
|
|
927
955
|
generateSchema(zodRef.unwrap(), useOutput, openApiVersion),
|
|
928
956
|
zodRef.description ? { description: zodRef.description } : {},
|
|
929
957
|
...schemas
|
|
930
958
|
);
|
|
931
959
|
}
|
|
932
|
-
function parseNullable({
|
|
933
|
-
schemas,
|
|
934
|
-
zodRef,
|
|
935
|
-
useOutput,
|
|
936
|
-
openApiVersion
|
|
937
|
-
}) {
|
|
960
|
+
function parseNullable({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
938
961
|
const schema = generateSchema(zodRef.unwrap(), useOutput, openApiVersion);
|
|
939
962
|
return merge(
|
|
940
963
|
schema,
|
|
941
|
-
openApiVersion ===
|
|
964
|
+
openApiVersion === '3.0'
|
|
965
|
+
? { nullable: true }
|
|
966
|
+
: { type: typeFormat('null', openApiVersion) },
|
|
942
967
|
zodRef.description ? { description: zodRef.description } : {},
|
|
943
968
|
...schemas
|
|
944
969
|
);
|
|
945
970
|
}
|
|
946
|
-
function parseDefault({
|
|
947
|
-
schemas,
|
|
948
|
-
zodRef,
|
|
949
|
-
useOutput,
|
|
950
|
-
openApiVersion
|
|
951
|
-
}) {
|
|
971
|
+
function parseDefault({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
952
972
|
return merge(
|
|
953
973
|
{
|
|
954
974
|
default: zodRef._def.defaultValue(),
|
|
@@ -958,12 +978,7 @@ function parseDefault({
|
|
|
958
978
|
...schemas
|
|
959
979
|
);
|
|
960
980
|
}
|
|
961
|
-
function parseArray({
|
|
962
|
-
schemas,
|
|
963
|
-
zodRef,
|
|
964
|
-
useOutput,
|
|
965
|
-
openApiVersion
|
|
966
|
-
}) {
|
|
981
|
+
function parseArray({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
967
982
|
const constraints = {};
|
|
968
983
|
if (zodRef._def.exactLength != null) {
|
|
969
984
|
constraints.minItems = zodRef._def.exactLength.value;
|
|
@@ -975,7 +990,7 @@ function parseArray({
|
|
|
975
990
|
constraints.maxItems = zodRef._def.maxLength.value;
|
|
976
991
|
return merge(
|
|
977
992
|
{
|
|
978
|
-
type: typeFormat(
|
|
993
|
+
type: typeFormat('array', openApiVersion),
|
|
979
994
|
items: generateSchema(zodRef.element, useOutput, openApiVersion),
|
|
980
995
|
...constraints
|
|
981
996
|
},
|
|
@@ -983,11 +998,7 @@ function parseArray({
|
|
|
983
998
|
...schemas
|
|
984
999
|
);
|
|
985
1000
|
}
|
|
986
|
-
function parseLiteral({
|
|
987
|
-
schemas,
|
|
988
|
-
zodRef,
|
|
989
|
-
openApiVersion
|
|
990
|
-
}) {
|
|
1001
|
+
function parseLiteral({ schemas, zodRef, openApiVersion }) {
|
|
991
1002
|
const type22 = typeof zodRef._def.value;
|
|
992
1003
|
return merge(
|
|
993
1004
|
{
|
|
@@ -998,11 +1009,7 @@ function parseLiteral({
|
|
|
998
1009
|
...schemas
|
|
999
1010
|
);
|
|
1000
1011
|
}
|
|
1001
|
-
function parseEnum({
|
|
1002
|
-
schemas,
|
|
1003
|
-
zodRef,
|
|
1004
|
-
openApiVersion
|
|
1005
|
-
}) {
|
|
1012
|
+
function parseEnum({ schemas, zodRef, openApiVersion }) {
|
|
1006
1013
|
const type22 = typeof Object.values(zodRef._def.values)[0];
|
|
1007
1014
|
return merge(
|
|
1008
1015
|
{
|
|
@@ -1013,12 +1020,7 @@ function parseEnum({
|
|
|
1013
1020
|
...schemas
|
|
1014
1021
|
);
|
|
1015
1022
|
}
|
|
1016
|
-
function parseIntersection({
|
|
1017
|
-
schemas,
|
|
1018
|
-
zodRef,
|
|
1019
|
-
useOutput,
|
|
1020
|
-
openApiVersion
|
|
1021
|
-
}) {
|
|
1023
|
+
function parseIntersection({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
1022
1024
|
return merge(
|
|
1023
1025
|
{
|
|
1024
1026
|
allOf: [
|
|
@@ -1030,20 +1032,20 @@ function parseIntersection({
|
|
|
1030
1032
|
...schemas
|
|
1031
1033
|
);
|
|
1032
1034
|
}
|
|
1033
|
-
function parseUnion({
|
|
1034
|
-
schemas,
|
|
1035
|
-
zodRef,
|
|
1036
|
-
useOutput,
|
|
1037
|
-
openApiVersion
|
|
1038
|
-
}) {
|
|
1035
|
+
function parseUnion({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
1039
1036
|
const contents = zodRef._def.options;
|
|
1040
|
-
if (
|
|
1041
|
-
(
|
|
1042
|
-
|
|
1043
|
-
|
|
1037
|
+
if (
|
|
1038
|
+
contents.reduce(
|
|
1039
|
+
(prev, content) => prev && content._def.typeName === 'ZodLiteral',
|
|
1040
|
+
true
|
|
1041
|
+
)
|
|
1042
|
+
) {
|
|
1044
1043
|
const literals = contents;
|
|
1045
1044
|
const type22 = literals.reduce(
|
|
1046
|
-
(prev, content) =>
|
|
1045
|
+
(prev, content) =>
|
|
1046
|
+
!prev || prev === typeof content._def.value
|
|
1047
|
+
? typeof content._def.value
|
|
1048
|
+
: null,
|
|
1047
1049
|
null
|
|
1048
1050
|
);
|
|
1049
1051
|
if (type22) {
|
|
@@ -1057,12 +1059,15 @@ function parseUnion({
|
|
|
1057
1059
|
);
|
|
1058
1060
|
}
|
|
1059
1061
|
}
|
|
1060
|
-
const oneOfContents =
|
|
1062
|
+
const oneOfContents =
|
|
1063
|
+
openApiVersion === '3.0'
|
|
1064
|
+
? contents.filter((content) => content._def.typeName !== 'ZodNull')
|
|
1065
|
+
: contents;
|
|
1061
1066
|
const contentsHasNull = contents.length != oneOfContents.length;
|
|
1062
1067
|
return merge(
|
|
1063
1068
|
{
|
|
1064
|
-
oneOf: oneOfContents.map(
|
|
1065
|
-
|
|
1069
|
+
oneOf: oneOfContents.map((schema) =>
|
|
1070
|
+
generateSchema(schema, useOutput, openApiVersion)
|
|
1066
1071
|
)
|
|
1067
1072
|
},
|
|
1068
1073
|
contentsHasNull ? { nullable: true } : {},
|
|
@@ -1081,50 +1086,34 @@ function parseDiscriminatedUnion({
|
|
|
1081
1086
|
discriminator: {
|
|
1082
1087
|
propertyName: zodRef._def.discriminator
|
|
1083
1088
|
},
|
|
1084
|
-
oneOf: Array.from(
|
|
1085
|
-
|
|
1086
|
-
)
|
|
1089
|
+
oneOf: Array.from(zodRef._def.options.values()).map((schema) =>
|
|
1090
|
+
generateSchema(schema, useOutput, openApiVersion)
|
|
1091
|
+
)
|
|
1087
1092
|
},
|
|
1088
1093
|
zodRef.description ? { description: zodRef.description } : {},
|
|
1089
1094
|
...schemas
|
|
1090
1095
|
);
|
|
1091
1096
|
}
|
|
1092
|
-
function parseNever({
|
|
1093
|
-
zodRef,
|
|
1094
|
-
schemas
|
|
1095
|
-
}) {
|
|
1097
|
+
function parseNever({ zodRef, schemas }) {
|
|
1096
1098
|
return merge(
|
|
1097
1099
|
{ readOnly: true },
|
|
1098
1100
|
zodRef.description ? { description: zodRef.description } : {},
|
|
1099
1101
|
...schemas
|
|
1100
1102
|
);
|
|
1101
1103
|
}
|
|
1102
|
-
function parseBranded({
|
|
1103
|
-
schemas,
|
|
1104
|
-
zodRef,
|
|
1105
|
-
useOutput,
|
|
1106
|
-
openApiVersion
|
|
1107
|
-
}) {
|
|
1104
|
+
function parseBranded({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
1108
1105
|
return merge(
|
|
1109
1106
|
generateSchema(zodRef._def.type, useOutput, openApiVersion),
|
|
1110
1107
|
...schemas
|
|
1111
1108
|
);
|
|
1112
1109
|
}
|
|
1113
|
-
function catchAllParser({
|
|
1114
|
-
zodRef,
|
|
1115
|
-
schemas
|
|
1116
|
-
}) {
|
|
1110
|
+
function catchAllParser({ zodRef, schemas }) {
|
|
1117
1111
|
return merge(
|
|
1118
1112
|
zodRef.description ? { description: zodRef.description } : {},
|
|
1119
1113
|
...schemas
|
|
1120
1114
|
);
|
|
1121
1115
|
}
|
|
1122
|
-
function parsePipeline({
|
|
1123
|
-
schemas,
|
|
1124
|
-
zodRef,
|
|
1125
|
-
useOutput,
|
|
1126
|
-
openApiVersion
|
|
1127
|
-
}) {
|
|
1116
|
+
function parsePipeline({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
1128
1117
|
return merge(
|
|
1129
1118
|
generateSchema(
|
|
1130
1119
|
useOutput ? zodRef._def.out : zodRef._def.in,
|
|
@@ -1134,12 +1123,7 @@ function parsePipeline({
|
|
|
1134
1123
|
...schemas
|
|
1135
1124
|
);
|
|
1136
1125
|
}
|
|
1137
|
-
function parseReadonly({
|
|
1138
|
-
zodRef,
|
|
1139
|
-
useOutput,
|
|
1140
|
-
schemas,
|
|
1141
|
-
openApiVersion
|
|
1142
|
-
}) {
|
|
1126
|
+
function parseReadonly({ zodRef, useOutput, schemas, openApiVersion }) {
|
|
1143
1127
|
return merge(
|
|
1144
1128
|
generateSchema(zodRef._def.innerType, useOutput, openApiVersion),
|
|
1145
1129
|
zodRef.description ? { description: zodRef.description } : {},
|
|
@@ -1183,10 +1167,10 @@ var workerMap = {
|
|
|
1183
1167
|
ZodPipeline: parsePipeline,
|
|
1184
1168
|
ZodReadonly: parseReadonly
|
|
1185
1169
|
};
|
|
1186
|
-
function generateSchema(zodRef, useOutput = false, openApiVersion =
|
|
1170
|
+
function generateSchema(zodRef, useOutput = false, openApiVersion = '3.1') {
|
|
1187
1171
|
const { metaOpenApi = {} } = zodRef;
|
|
1188
1172
|
const schemas = [
|
|
1189
|
-
...Array.isArray(metaOpenApi) ? metaOpenApi : [metaOpenApi]
|
|
1173
|
+
...(Array.isArray(metaOpenApi) ? metaOpenApi : [metaOpenApi])
|
|
1190
1174
|
];
|
|
1191
1175
|
try {
|
|
1192
1176
|
const typeName = zodRef._def.typeName;
|
|
@@ -1205,155 +1189,173 @@ function generateSchema(zodRef, useOutput = false, openApiVersion = "3.1") {
|
|
|
1205
1189
|
}
|
|
1206
1190
|
}
|
|
1207
1191
|
function extendZodWithOpenApi(zod, forceOverride = false) {
|
|
1208
|
-
if (
|
|
1192
|
+
if (
|
|
1193
|
+
!forceOverride &&
|
|
1194
|
+
typeof zod.ZodSchema.prototype.openapi !== 'undefined'
|
|
1195
|
+
) {
|
|
1209
1196
|
return;
|
|
1210
1197
|
}
|
|
1211
|
-
zod.ZodSchema.prototype.openapi = function(metadata) {
|
|
1198
|
+
zod.ZodSchema.prototype.openapi = function (metadata) {
|
|
1212
1199
|
return extendApi(this, metadata);
|
|
1213
1200
|
};
|
|
1214
1201
|
}
|
|
1215
1202
|
extendZodWithOpenApi(z2);
|
|
1216
1203
|
var ZodSchemaValidator = class {
|
|
1217
|
-
_Type =
|
|
1204
|
+
_Type = 'Zod';
|
|
1218
1205
|
_SchemaCatchall;
|
|
1219
1206
|
_ValidSchemaObject;
|
|
1220
1207
|
string = z2.string().openapi({
|
|
1221
|
-
title:
|
|
1222
|
-
example:
|
|
1208
|
+
title: 'String',
|
|
1209
|
+
example: 'a string'
|
|
1223
1210
|
});
|
|
1224
1211
|
uuid = z2.string().uuid().openapi({
|
|
1225
|
-
title:
|
|
1226
|
-
format:
|
|
1227
|
-
pattern:
|
|
1228
|
-
|
|
1212
|
+
title: 'UUID',
|
|
1213
|
+
format: 'uuid',
|
|
1214
|
+
pattern:
|
|
1215
|
+
'^[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}$',
|
|
1216
|
+
example: 'a8b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6'
|
|
1229
1217
|
});
|
|
1230
1218
|
email = z2.string().email().openapi({
|
|
1231
|
-
title:
|
|
1232
|
-
format:
|
|
1233
|
-
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\\
|
|
1234
|
-
example:
|
|
1219
|
+
title: 'Email',
|
|
1220
|
+
format: 'email',
|
|
1221
|
+
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])+)])`,
|
|
1222
|
+
example: 'a@b.com'
|
|
1235
1223
|
});
|
|
1236
1224
|
uri = z2.string().url().openapi({
|
|
1237
|
-
title:
|
|
1238
|
-
format:
|
|
1239
|
-
pattern:
|
|
1240
|
-
example:
|
|
1241
|
-
});
|
|
1242
|
-
number = z2.preprocess((value) => {
|
|
1243
|
-
try {
|
|
1244
|
-
return Number(value);
|
|
1245
|
-
} catch {
|
|
1246
|
-
return value;
|
|
1247
|
-
}
|
|
1248
|
-
}, z2.number()).openapi({
|
|
1249
|
-
title: "Number",
|
|
1250
|
-
example: 123
|
|
1225
|
+
title: 'URI',
|
|
1226
|
+
format: 'uri',
|
|
1227
|
+
pattern: '^[a-zA-Z][a-zA-Z\\d+-.]*:[^\\s]*$',
|
|
1228
|
+
example: 'https://forklaunch.com'
|
|
1251
1229
|
});
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
return
|
|
1230
|
+
number = z2
|
|
1231
|
+
.preprocess((value) => {
|
|
1232
|
+
try {
|
|
1233
|
+
return Number(value);
|
|
1234
|
+
} catch {
|
|
1235
|
+
return value;
|
|
1256
1236
|
}
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1237
|
+
}, z2.number())
|
|
1238
|
+
.openapi({
|
|
1239
|
+
title: 'Number',
|
|
1240
|
+
example: 123
|
|
1241
|
+
});
|
|
1242
|
+
bigint = z2
|
|
1243
|
+
.preprocess((value) => {
|
|
1244
|
+
try {
|
|
1245
|
+
if (value instanceof Date) {
|
|
1246
|
+
return BigInt(value.getTime());
|
|
1247
|
+
}
|
|
1248
|
+
switch (typeof value) {
|
|
1249
|
+
case 'number':
|
|
1250
|
+
case 'string':
|
|
1251
|
+
return BigInt(value);
|
|
1252
|
+
case 'boolean':
|
|
1253
|
+
return BigInt(value ? 1 : 0);
|
|
1254
|
+
default:
|
|
1255
|
+
return value;
|
|
1256
|
+
}
|
|
1257
|
+
} catch {
|
|
1258
|
+
return value;
|
|
1265
1259
|
}
|
|
1266
|
-
}
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
if (val.toLowerCase() === "false") return false;
|
|
1279
|
-
}
|
|
1280
|
-
return val;
|
|
1281
|
-
}, z2.boolean()).openapi({
|
|
1282
|
-
title: "Boolean",
|
|
1283
|
-
example: true
|
|
1284
|
-
});
|
|
1285
|
-
date = z2.preprocess((value) => {
|
|
1286
|
-
try {
|
|
1287
|
-
switch (typeof value) {
|
|
1288
|
-
case "string":
|
|
1289
|
-
return new Date(value);
|
|
1290
|
-
case "number":
|
|
1291
|
-
return new Date(value);
|
|
1292
|
-
default:
|
|
1293
|
-
return value;
|
|
1260
|
+
}, z2.bigint())
|
|
1261
|
+
.openapi({
|
|
1262
|
+
title: 'BigInt',
|
|
1263
|
+
type: 'integer',
|
|
1264
|
+
format: 'int64',
|
|
1265
|
+
example: 123n
|
|
1266
|
+
});
|
|
1267
|
+
boolean = z2
|
|
1268
|
+
.preprocess((val) => {
|
|
1269
|
+
if (typeof val === 'string') {
|
|
1270
|
+
if (val.toLowerCase() === 'true') return true;
|
|
1271
|
+
if (val.toLowerCase() === 'false') return false;
|
|
1294
1272
|
}
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1273
|
+
return val;
|
|
1274
|
+
}, z2.boolean())
|
|
1275
|
+
.openapi({
|
|
1276
|
+
title: 'Boolean',
|
|
1277
|
+
example: true
|
|
1278
|
+
});
|
|
1279
|
+
date = z2
|
|
1280
|
+
.preprocess((value) => {
|
|
1281
|
+
try {
|
|
1282
|
+
switch (typeof value) {
|
|
1283
|
+
case 'string':
|
|
1284
|
+
return new Date(value);
|
|
1285
|
+
case 'number':
|
|
1286
|
+
return new Date(value);
|
|
1287
|
+
default:
|
|
1288
|
+
return value;
|
|
1289
|
+
}
|
|
1290
|
+
} catch {
|
|
1291
|
+
return value;
|
|
1292
|
+
}
|
|
1293
|
+
}, z2.date())
|
|
1294
|
+
.openapi({
|
|
1295
|
+
title: 'Date',
|
|
1296
|
+
type: 'string',
|
|
1297
|
+
format: 'date-time',
|
|
1298
|
+
example: '2025-05-16T21:13:04.123Z'
|
|
1299
|
+
});
|
|
1304
1300
|
symbol = z2.symbol().openapi({
|
|
1305
|
-
title:
|
|
1306
|
-
example: Symbol(
|
|
1301
|
+
title: 'Symbol',
|
|
1302
|
+
example: Symbol('symbol')
|
|
1307
1303
|
});
|
|
1308
1304
|
nullish = z2.union([z2.void(), z2.null(), z2.undefined()]).openapi({
|
|
1309
|
-
title:
|
|
1310
|
-
type:
|
|
1305
|
+
title: 'Nullish',
|
|
1306
|
+
type: 'null',
|
|
1311
1307
|
example: null
|
|
1312
1308
|
});
|
|
1313
1309
|
void = z2.void().openapi({
|
|
1314
|
-
title:
|
|
1315
|
-
type:
|
|
1310
|
+
title: 'Void',
|
|
1311
|
+
type: 'null',
|
|
1316
1312
|
example: void 0
|
|
1317
1313
|
});
|
|
1318
1314
|
null = z2.null().openapi({
|
|
1319
|
-
title:
|
|
1320
|
-
type:
|
|
1315
|
+
title: 'Null',
|
|
1316
|
+
type: 'null',
|
|
1321
1317
|
example: null
|
|
1322
1318
|
});
|
|
1323
1319
|
undefined = z2.undefined().openapi({
|
|
1324
|
-
title:
|
|
1325
|
-
type:
|
|
1320
|
+
title: 'Undefined',
|
|
1321
|
+
type: 'null',
|
|
1326
1322
|
example: void 0
|
|
1327
1323
|
});
|
|
1328
1324
|
any = z2.any().openapi({
|
|
1329
|
-
title:
|
|
1330
|
-
type:
|
|
1331
|
-
example:
|
|
1325
|
+
title: 'Any',
|
|
1326
|
+
type: 'object',
|
|
1327
|
+
example: 'any'
|
|
1332
1328
|
});
|
|
1333
1329
|
unknown = z2.unknown().openapi({
|
|
1334
|
-
title:
|
|
1335
|
-
type:
|
|
1336
|
-
example:
|
|
1330
|
+
title: 'Unknown',
|
|
1331
|
+
type: 'object',
|
|
1332
|
+
example: 'unknown'
|
|
1337
1333
|
});
|
|
1338
1334
|
never = z2.never().openapi({
|
|
1339
|
-
title:
|
|
1340
|
-
type:
|
|
1341
|
-
example:
|
|
1342
|
-
});
|
|
1343
|
-
binary = z2.string().transform((v) => new TextEncoder().encode(v)).openapi({
|
|
1344
|
-
title: "Binary",
|
|
1345
|
-
type: "string",
|
|
1346
|
-
format: "binary",
|
|
1347
|
-
example: "a utf-8 encodable string"
|
|
1348
|
-
});
|
|
1349
|
-
file = z2.string().transform((val) => {
|
|
1350
|
-
return new Blob([val]);
|
|
1351
|
-
}).openapi({
|
|
1352
|
-
title: "File",
|
|
1353
|
-
type: "string",
|
|
1354
|
-
format: "binary",
|
|
1355
|
-
example: "a utf-8 encodable blob or file"
|
|
1335
|
+
title: 'Never',
|
|
1336
|
+
type: 'null',
|
|
1337
|
+
example: 'never'
|
|
1356
1338
|
});
|
|
1339
|
+
binary = z2
|
|
1340
|
+
.string()
|
|
1341
|
+
.transform((val) => new Uint8Array(Buffer.from(val, 'base64')))
|
|
1342
|
+
.openapi({
|
|
1343
|
+
title: 'Binary',
|
|
1344
|
+
type: 'string',
|
|
1345
|
+
format: 'binary',
|
|
1346
|
+
example: 'a base-64 encodable string'
|
|
1347
|
+
});
|
|
1348
|
+
file = z2
|
|
1349
|
+
.instanceof(Buffer)
|
|
1350
|
+
.transform((val) => {
|
|
1351
|
+
return new Blob([val]);
|
|
1352
|
+
})
|
|
1353
|
+
.openapi({
|
|
1354
|
+
title: 'File',
|
|
1355
|
+
type: 'string',
|
|
1356
|
+
format: 'binary',
|
|
1357
|
+
example: 'a base-64 encodable blob or file'
|
|
1358
|
+
});
|
|
1357
1359
|
type = () => this.any;
|
|
1358
1360
|
/**
|
|
1359
1361
|
* Compiles schema if this exists, for optimal performance.
|
|
@@ -1370,7 +1372,11 @@ var ZodSchemaValidator = class {
|
|
|
1370
1372
|
* @returns {ZodResolve<T>} The resolved schema.
|
|
1371
1373
|
*/
|
|
1372
1374
|
schemify(schema) {
|
|
1373
|
-
if (
|
|
1375
|
+
if (
|
|
1376
|
+
typeof schema === 'string' ||
|
|
1377
|
+
typeof schema === 'number' ||
|
|
1378
|
+
typeof schema === 'boolean'
|
|
1379
|
+
) {
|
|
1374
1380
|
return z2.literal(schema);
|
|
1375
1381
|
}
|
|
1376
1382
|
if (schema instanceof ZodType) {
|
|
@@ -1411,9 +1417,7 @@ var ZodSchemaValidator = class {
|
|
|
1411
1417
|
*/
|
|
1412
1418
|
union(schemas) {
|
|
1413
1419
|
const resolvedSchemas = schemas.map((schema) => this.schemify(schema));
|
|
1414
|
-
return z2.union(
|
|
1415
|
-
resolvedSchemas
|
|
1416
|
-
);
|
|
1420
|
+
return z2.union(resolvedSchemas);
|
|
1417
1421
|
}
|
|
1418
1422
|
/**
|
|
1419
1423
|
* Create a literal schema.
|
|
@@ -1429,9 +1433,7 @@ var ZodSchemaValidator = class {
|
|
|
1429
1433
|
* @returns {ZodUnion<UnionZodResolve<[T, T, ...T[]]>>} The enum schema.
|
|
1430
1434
|
*/
|
|
1431
1435
|
enum_(schemaEnum) {
|
|
1432
|
-
return this.union(
|
|
1433
|
-
Object.values(schemaEnum)
|
|
1434
|
-
);
|
|
1436
|
+
return this.union(Object.values(schemaEnum));
|
|
1435
1437
|
}
|
|
1436
1438
|
/**
|
|
1437
1439
|
* Create a function schema.
|
|
@@ -1500,31 +1502,33 @@ var ZodSchemaValidator = class {
|
|
|
1500
1502
|
parse(schema, value) {
|
|
1501
1503
|
const resolvedSchema = this.schemify(schema);
|
|
1502
1504
|
const result = resolvedSchema.safeParse(value);
|
|
1503
|
-
return result.success
|
|
1504
|
-
ok:
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1505
|
+
return result.success
|
|
1506
|
+
? { ok: true, value: result.data }
|
|
1507
|
+
: {
|
|
1508
|
+
ok: false,
|
|
1509
|
+
errors: result.error.errors.flatMap((error) => {
|
|
1510
|
+
switch (error.code) {
|
|
1511
|
+
case 'invalid_union':
|
|
1512
|
+
return error.unionErrors.flatMap((unionError, idx) =>
|
|
1513
|
+
unionError.errors.map((e) => ({
|
|
1514
|
+
path: [
|
|
1515
|
+
`Union Schema Variant ${idx}`,
|
|
1516
|
+
...error.path.map((p) => p.toString()),
|
|
1517
|
+
...e.path.map((p) => p.toString())
|
|
1518
|
+
],
|
|
1519
|
+
message: e.message
|
|
1520
|
+
}))
|
|
1521
|
+
);
|
|
1522
|
+
default:
|
|
1523
|
+
return [
|
|
1524
|
+
{
|
|
1525
|
+
path: error.path.map((p) => p.toString()),
|
|
1526
|
+
message: error.message
|
|
1527
|
+
}
|
|
1528
|
+
];
|
|
1529
|
+
}
|
|
1530
|
+
})
|
|
1531
|
+
};
|
|
1528
1532
|
}
|
|
1529
1533
|
/**
|
|
1530
1534
|
* Convert a schema to an OpenAPI schema object.
|
|
@@ -1582,6 +1586,4 @@ var RedisWorkerSchemas = serviceSchemaResolver(
|
|
|
1582
1586
|
() => RedisWorkerOptionsSchema,
|
|
1583
1587
|
() => RedisWorkerOptionsSchema2
|
|
1584
1588
|
);
|
|
1585
|
-
export {
|
|
1586
|
-
RedisWorkerSchemas
|
|
1587
|
-
};
|
|
1589
|
+
export { RedisWorkerSchemas };
|