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