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