@forklaunch/implementation-worker-kafka 0.6.0 → 0.6.2
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 +15 -28
- package/lib/consumers/index.d.ts +15 -28
- package/lib/consumers/index.js +11 -14
- package/lib/consumers/index.mjs +7 -3
- package/lib/domain/schemas/index.d.mts +8 -52
- package/lib/domain/schemas/index.d.ts +8 -52
- package/lib/domain/schemas/index.js +537 -579
- package/lib/domain/schemas/index.mjs +541 -543
- package/lib/domain/types/index.d.mts +6 -6
- package/lib/domain/types/index.d.ts +6 -6
- package/lib/domain/types/index.js +4 -8
- package/lib/producers/index.d.mts +7 -10
- package/lib/producers/index.d.ts +7 -10
- package/lib/producers/index.js +8 -13
- package/lib/producers/index.mjs +4 -2
- 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,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/kafka.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.5/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.5/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.5/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
|
}
|
|
@@ -667,55 +618,43 @@ var KafkaWorkerOptionsSchema = {
|
|
|
667
618
|
peekCount: number
|
|
668
619
|
};
|
|
669
620
|
|
|
670
|
-
// ../../../node_modules/.pnpm/@forklaunch+validator@0.10.
|
|
671
|
-
var import_v3 = require(
|
|
621
|
+
// ../../../node_modules/.pnpm/@forklaunch+validator@0.10.5/node_modules/@forklaunch/validator/lib/src/zod/index.mjs
|
|
622
|
+
var import_v3 = require("zod/v3");
|
|
672
623
|
|
|
673
624
|
// ../../../node_modules/.pnpm/ts-deepmerge@7.0.3/node_modules/ts-deepmerge/esm/index.js
|
|
674
625
|
var isObject = (obj) => {
|
|
675
|
-
if (typeof obj ===
|
|
676
|
-
if (typeof Object.getPrototypeOf ===
|
|
626
|
+
if (typeof obj === "object" && obj !== null) {
|
|
627
|
+
if (typeof Object.getPrototypeOf === "function") {
|
|
677
628
|
const prototype = Object.getPrototypeOf(obj);
|
|
678
629
|
return prototype === Object.prototype || prototype === null;
|
|
679
630
|
}
|
|
680
|
-
return Object.prototype.toString.call(obj) ===
|
|
631
|
+
return Object.prototype.toString.call(obj) === "[object Object]";
|
|
681
632
|
}
|
|
682
633
|
return false;
|
|
683
634
|
};
|
|
684
|
-
var merge = (...objects) =>
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
635
|
+
var merge = (...objects) => objects.reduce((result, current) => {
|
|
636
|
+
if (current === void 0) {
|
|
637
|
+
return result;
|
|
638
|
+
}
|
|
639
|
+
if (Array.isArray(current)) {
|
|
640
|
+
throw new TypeError("Arguments provided to ts-deepmerge must be objects, not arrays.");
|
|
641
|
+
}
|
|
642
|
+
Object.keys(current).forEach((key) => {
|
|
643
|
+
if (["__proto__", "constructor", "prototype"].includes(key)) {
|
|
644
|
+
return;
|
|
688
645
|
}
|
|
689
|
-
if (Array.isArray(current)) {
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
);
|
|
646
|
+
if (Array.isArray(result[key]) && Array.isArray(current[key])) {
|
|
647
|
+
result[key] = merge.options.mergeArrays ? merge.options.uniqueArrayItems ? Array.from(new Set(result[key].concat(current[key]))) : [...result[key], ...current[key]] : current[key];
|
|
648
|
+
} else if (isObject(result[key]) && isObject(current[key])) {
|
|
649
|
+
result[key] = merge(result[key], current[key]);
|
|
650
|
+
} else if (!isObject(result[key]) && isObject(current[key])) {
|
|
651
|
+
result[key] = merge(current[key], void 0);
|
|
652
|
+
} else {
|
|
653
|
+
result[key] = current[key] === void 0 ? merge.options.allowUndefinedOverrides ? current[key] : result[key] : current[key];
|
|
693
654
|
}
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
}
|
|
698
|
-
if (Array.isArray(result[key]) && Array.isArray(current[key])) {
|
|
699
|
-
result[key] = merge.options.mergeArrays
|
|
700
|
-
? merge.options.uniqueArrayItems
|
|
701
|
-
? Array.from(new Set(result[key].concat(current[key])))
|
|
702
|
-
: [...result[key], ...current[key]]
|
|
703
|
-
: current[key];
|
|
704
|
-
} else if (isObject(result[key]) && isObject(current[key])) {
|
|
705
|
-
result[key] = merge(result[key], current[key]);
|
|
706
|
-
} else if (!isObject(result[key]) && isObject(current[key])) {
|
|
707
|
-
result[key] = merge(current[key], void 0);
|
|
708
|
-
} else {
|
|
709
|
-
result[key] =
|
|
710
|
-
current[key] === void 0
|
|
711
|
-
? merge.options.allowUndefinedOverrides
|
|
712
|
-
? current[key]
|
|
713
|
-
: result[key]
|
|
714
|
-
: current[key];
|
|
715
|
-
}
|
|
716
|
-
});
|
|
717
|
-
return result;
|
|
718
|
-
}, {});
|
|
655
|
+
});
|
|
656
|
+
return result;
|
|
657
|
+
}, {});
|
|
719
658
|
var defaultOptions = {
|
|
720
659
|
allowUndefinedOverrides: true,
|
|
721
660
|
mergeArrays: true,
|
|
@@ -729,8 +668,8 @@ merge.withOptions = (options, ...objects) => {
|
|
|
729
668
|
return result;
|
|
730
669
|
};
|
|
731
670
|
|
|
732
|
-
// ../../../node_modules/.pnpm/@forklaunch+validator@0.10.
|
|
733
|
-
var import_v32 = require(
|
|
671
|
+
// ../../../node_modules/.pnpm/@forklaunch+validator@0.10.5/node_modules/@forklaunch/validator/lib/src/zod/index.mjs
|
|
672
|
+
var import_v32 = require("zod/v3");
|
|
734
673
|
function extendApi(schema, schemaObject = {}) {
|
|
735
674
|
const This = schema.constructor;
|
|
736
675
|
const newSchema = new This(schema._def);
|
|
@@ -747,96 +686,89 @@ function iterateZodObject({
|
|
|
747
686
|
hideDefinitions,
|
|
748
687
|
openApiVersion
|
|
749
688
|
}) {
|
|
750
|
-
const reduced = Object.keys(zodRef.shape)
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
(
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
{}
|
|
758
|
-
);
|
|
689
|
+
const reduced = Object.keys(zodRef.shape).filter((key) => hideDefinitions?.includes(key) === false).reduce(
|
|
690
|
+
(carry, key) => ({
|
|
691
|
+
...carry,
|
|
692
|
+
[key]: generateSchema(zodRef.shape[key], useOutput, openApiVersion)
|
|
693
|
+
}),
|
|
694
|
+
{}
|
|
695
|
+
);
|
|
759
696
|
return reduced;
|
|
760
697
|
}
|
|
761
698
|
function typeFormat(type22, openApiVersion) {
|
|
762
|
-
return openApiVersion ===
|
|
699
|
+
return openApiVersion === "3.0" ? type22 : [type22];
|
|
763
700
|
}
|
|
764
|
-
function parseTransformation({
|
|
701
|
+
function parseTransformation({
|
|
702
|
+
zodRef,
|
|
703
|
+
schemas,
|
|
704
|
+
useOutput,
|
|
705
|
+
openApiVersion
|
|
706
|
+
}) {
|
|
765
707
|
const input = generateSchema(zodRef._def.schema, useOutput, openApiVersion);
|
|
766
|
-
let output =
|
|
708
|
+
let output = "undefined";
|
|
767
709
|
if (useOutput && zodRef._def.effect) {
|
|
768
|
-
const effect =
|
|
769
|
-
|
|
770
|
-
if (effect && 'transform' in effect) {
|
|
710
|
+
const effect = zodRef._def.effect.type === "transform" ? zodRef._def.effect : null;
|
|
711
|
+
if (effect && "transform" in effect) {
|
|
771
712
|
try {
|
|
772
713
|
const type22 = Array.isArray(input.type) ? input.type[0] : input.type;
|
|
773
714
|
output = typeof effect.transform(
|
|
774
|
-
[
|
|
775
|
-
? 0
|
|
776
|
-
: 'string' === type22
|
|
777
|
-
? ''
|
|
778
|
-
: 'boolean' === type22
|
|
779
|
-
? false
|
|
780
|
-
: 'object' === type22
|
|
781
|
-
? {}
|
|
782
|
-
: 'null' === type22
|
|
783
|
-
? null
|
|
784
|
-
: 'array' === type22
|
|
785
|
-
? []
|
|
786
|
-
: void 0,
|
|
715
|
+
["integer", "number"].includes(`${type22}`) ? 0 : "string" === type22 ? "" : "boolean" === type22 ? false : "object" === type22 ? {} : "null" === type22 ? null : "array" === type22 ? [] : void 0,
|
|
787
716
|
{ addIssue: () => void 0, path: [] }
|
|
788
717
|
// TODO: Discover if context is necessary here
|
|
789
718
|
);
|
|
790
|
-
} catch {
|
|
719
|
+
} catch {
|
|
720
|
+
}
|
|
791
721
|
}
|
|
792
722
|
}
|
|
793
723
|
const outputType = output;
|
|
794
724
|
return merge(
|
|
795
725
|
{
|
|
796
|
-
...
|
|
726
|
+
...zodRef.description ? { description: zodRef.description } : {},
|
|
797
727
|
...input,
|
|
798
|
-
...
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
}
|
|
802
|
-
: {})
|
|
728
|
+
...["number", "string", "boolean", "null"].includes(output) ? {
|
|
729
|
+
type: typeFormat(outputType, openApiVersion)
|
|
730
|
+
} : {}
|
|
803
731
|
},
|
|
804
732
|
...schemas
|
|
805
733
|
);
|
|
806
734
|
}
|
|
807
|
-
function parseString({
|
|
735
|
+
function parseString({
|
|
736
|
+
zodRef,
|
|
737
|
+
schemas,
|
|
738
|
+
openApiVersion
|
|
739
|
+
}) {
|
|
808
740
|
const baseSchema = {
|
|
809
|
-
type: typeFormat(
|
|
741
|
+
type: typeFormat("string", openApiVersion)
|
|
810
742
|
};
|
|
811
743
|
const { checks = [] } = zodRef._def;
|
|
812
744
|
checks.forEach((item) => {
|
|
813
745
|
switch (item.kind) {
|
|
814
|
-
case
|
|
815
|
-
baseSchema.format =
|
|
746
|
+
case "email":
|
|
747
|
+
baseSchema.format = "email";
|
|
816
748
|
break;
|
|
817
|
-
case
|
|
818
|
-
baseSchema.format =
|
|
749
|
+
case "uuid":
|
|
750
|
+
baseSchema.format = "uuid";
|
|
819
751
|
break;
|
|
820
|
-
case
|
|
821
|
-
baseSchema.format =
|
|
752
|
+
case "cuid":
|
|
753
|
+
baseSchema.format = "cuid";
|
|
822
754
|
break;
|
|
823
|
-
case
|
|
824
|
-
baseSchema.format =
|
|
755
|
+
case "url":
|
|
756
|
+
baseSchema.format = "uri";
|
|
825
757
|
break;
|
|
826
|
-
case
|
|
827
|
-
baseSchema.format =
|
|
758
|
+
case "datetime":
|
|
759
|
+
baseSchema.format = "date-time";
|
|
828
760
|
break;
|
|
829
|
-
case
|
|
761
|
+
case "length":
|
|
830
762
|
baseSchema.minLength = item.value;
|
|
831
763
|
baseSchema.maxLength = item.value;
|
|
832
764
|
break;
|
|
833
|
-
case
|
|
765
|
+
case "max":
|
|
834
766
|
baseSchema.maxLength = item.value;
|
|
835
767
|
break;
|
|
836
|
-
case
|
|
768
|
+
case "min":
|
|
837
769
|
baseSchema.minLength = item.value;
|
|
838
770
|
break;
|
|
839
|
-
case
|
|
771
|
+
case "regex":
|
|
840
772
|
baseSchema.pattern = item.regex.source;
|
|
841
773
|
break;
|
|
842
774
|
}
|
|
@@ -847,41 +779,45 @@ function parseString({ zodRef, schemas, openApiVersion }) {
|
|
|
847
779
|
...schemas
|
|
848
780
|
);
|
|
849
781
|
}
|
|
850
|
-
function parseNumber({
|
|
782
|
+
function parseNumber({
|
|
783
|
+
zodRef,
|
|
784
|
+
schemas,
|
|
785
|
+
openApiVersion
|
|
786
|
+
}) {
|
|
851
787
|
const baseSchema = {
|
|
852
|
-
type: typeFormat(
|
|
788
|
+
type: typeFormat("number", openApiVersion)
|
|
853
789
|
};
|
|
854
790
|
const { checks = [] } = zodRef._def;
|
|
855
791
|
checks.forEach((item) => {
|
|
856
792
|
switch (item.kind) {
|
|
857
|
-
case
|
|
858
|
-
if (item.inclusive || openApiVersion ===
|
|
793
|
+
case "max":
|
|
794
|
+
if (item.inclusive || openApiVersion === "3.0") {
|
|
859
795
|
baseSchema.maximum = item.value;
|
|
860
796
|
}
|
|
861
797
|
if (!item.inclusive) {
|
|
862
|
-
if (openApiVersion ===
|
|
798
|
+
if (openApiVersion === "3.0") {
|
|
863
799
|
baseSchema.exclusiveMaximum = true;
|
|
864
800
|
} else {
|
|
865
801
|
baseSchema.exclusiveMaximum = item.value;
|
|
866
802
|
}
|
|
867
803
|
}
|
|
868
804
|
break;
|
|
869
|
-
case
|
|
870
|
-
if (item.inclusive || openApiVersion ===
|
|
805
|
+
case "min":
|
|
806
|
+
if (item.inclusive || openApiVersion === "3.0") {
|
|
871
807
|
baseSchema.minimum = item.value;
|
|
872
808
|
}
|
|
873
809
|
if (!item.inclusive) {
|
|
874
|
-
if (openApiVersion ===
|
|
810
|
+
if (openApiVersion === "3.0") {
|
|
875
811
|
baseSchema.exclusiveMinimum = true;
|
|
876
812
|
} else {
|
|
877
813
|
baseSchema.exclusiveMinimum = item.value;
|
|
878
814
|
}
|
|
879
815
|
}
|
|
880
816
|
break;
|
|
881
|
-
case
|
|
882
|
-
baseSchema.type = typeFormat(
|
|
817
|
+
case "int":
|
|
818
|
+
baseSchema.type = typeFormat("integer", openApiVersion);
|
|
883
819
|
break;
|
|
884
|
-
case
|
|
820
|
+
case "multipleOf":
|
|
885
821
|
baseSchema.multipleOf = item.value;
|
|
886
822
|
break;
|
|
887
823
|
}
|
|
@@ -909,41 +845,26 @@ function parseObject({
|
|
|
909
845
|
openApiVersion
|
|
910
846
|
}) {
|
|
911
847
|
let additionalProperties;
|
|
912
|
-
if (
|
|
913
|
-
!(
|
|
914
|
-
zodRef._def.catchall instanceof import_v32.z.ZodNever ||
|
|
915
|
-
zodRef._def.catchall?._def.typeName === 'ZodNever'
|
|
916
|
-
)
|
|
917
|
-
)
|
|
848
|
+
if (!(zodRef._def.catchall instanceof import_v32.z.ZodNever || zodRef._def.catchall?._def.typeName === "ZodNever"))
|
|
918
849
|
additionalProperties = generateSchema(
|
|
919
850
|
zodRef._def.catchall,
|
|
920
851
|
useOutput,
|
|
921
852
|
openApiVersion
|
|
922
853
|
);
|
|
923
|
-
else if (zodRef._def.unknownKeys ===
|
|
854
|
+
else if (zodRef._def.unknownKeys === "passthrough")
|
|
924
855
|
additionalProperties = true;
|
|
925
|
-
else if (zodRef._def.unknownKeys ===
|
|
926
|
-
additionalProperties =
|
|
927
|
-
|
|
928
|
-
|
|
856
|
+
else if (zodRef._def.unknownKeys === "strict") additionalProperties = false;
|
|
857
|
+
additionalProperties = additionalProperties != null ? { additionalProperties } : {};
|
|
858
|
+
const requiredProperties = Object.keys(
|
|
859
|
+
zodRef.shape
|
|
860
|
+
).filter((key) => {
|
|
929
861
|
const item = zodRef.shape[key];
|
|
930
|
-
return (
|
|
931
|
-
!(
|
|
932
|
-
item.isOptional() ||
|
|
933
|
-
item instanceof import_v32.z.ZodDefault ||
|
|
934
|
-
item._def.typeName === 'ZodDefault'
|
|
935
|
-
) &&
|
|
936
|
-
!(
|
|
937
|
-
item instanceof import_v32.z.ZodNever ||
|
|
938
|
-
item._def.typeName === 'ZodDefault'
|
|
939
|
-
)
|
|
940
|
-
);
|
|
862
|
+
return !(item.isOptional() || item instanceof import_v32.z.ZodDefault || item._def.typeName === "ZodDefault") && !(item instanceof import_v32.z.ZodNever || item._def.typeName === "ZodDefault");
|
|
941
863
|
});
|
|
942
|
-
const required =
|
|
943
|
-
requiredProperties.length > 0 ? { required: requiredProperties } : {};
|
|
864
|
+
const required = requiredProperties.length > 0 ? { required: requiredProperties } : {};
|
|
944
865
|
return merge(
|
|
945
866
|
{
|
|
946
|
-
type: typeFormat(
|
|
867
|
+
type: typeFormat("object", openApiVersion),
|
|
947
868
|
properties: iterateZodObject({
|
|
948
869
|
zodRef,
|
|
949
870
|
schemas,
|
|
@@ -955,83 +876,110 @@ function parseObject({
|
|
|
955
876
|
...additionalProperties,
|
|
956
877
|
...hideDefinitions
|
|
957
878
|
},
|
|
958
|
-
zodRef.description
|
|
959
|
-
? { description: zodRef.description, hideDefinitions }
|
|
960
|
-
: {},
|
|
879
|
+
zodRef.description ? { description: zodRef.description, hideDefinitions } : {},
|
|
961
880
|
...schemas
|
|
962
881
|
);
|
|
963
882
|
}
|
|
964
|
-
function parseRecord({
|
|
883
|
+
function parseRecord({
|
|
884
|
+
zodRef,
|
|
885
|
+
schemas,
|
|
886
|
+
useOutput,
|
|
887
|
+
openApiVersion
|
|
888
|
+
}) {
|
|
965
889
|
return merge(
|
|
966
890
|
{
|
|
967
|
-
type: typeFormat(
|
|
968
|
-
additionalProperties:
|
|
969
|
-
zodRef._def.valueType instanceof import_v32.z.ZodUnknown
|
|
970
|
-
? {}
|
|
971
|
-
: generateSchema(zodRef._def.valueType, useOutput, openApiVersion)
|
|
891
|
+
type: typeFormat("object", openApiVersion),
|
|
892
|
+
additionalProperties: zodRef._def.valueType instanceof import_v32.z.ZodUnknown ? {} : generateSchema(zodRef._def.valueType, useOutput, openApiVersion)
|
|
972
893
|
},
|
|
973
894
|
zodRef.description ? { description: zodRef.description } : {},
|
|
974
895
|
...schemas
|
|
975
896
|
);
|
|
976
897
|
}
|
|
977
|
-
function parseBigInt({
|
|
898
|
+
function parseBigInt({
|
|
899
|
+
zodRef,
|
|
900
|
+
schemas,
|
|
901
|
+
openApiVersion
|
|
902
|
+
}) {
|
|
978
903
|
return merge(
|
|
979
904
|
{
|
|
980
|
-
type: typeFormat(
|
|
981
|
-
format:
|
|
905
|
+
type: typeFormat("integer", openApiVersion),
|
|
906
|
+
format: "int64"
|
|
982
907
|
},
|
|
983
908
|
zodRef.description ? { description: zodRef.description } : {},
|
|
984
909
|
...schemas
|
|
985
910
|
);
|
|
986
911
|
}
|
|
987
|
-
function parseBoolean({
|
|
912
|
+
function parseBoolean({
|
|
913
|
+
zodRef,
|
|
914
|
+
schemas,
|
|
915
|
+
openApiVersion
|
|
916
|
+
}) {
|
|
988
917
|
return merge(
|
|
989
|
-
{ type: typeFormat(
|
|
918
|
+
{ type: typeFormat("boolean", openApiVersion) },
|
|
990
919
|
zodRef.description ? { description: zodRef.description } : {},
|
|
991
920
|
...schemas
|
|
992
921
|
);
|
|
993
922
|
}
|
|
994
|
-
function parseDate({
|
|
923
|
+
function parseDate({
|
|
924
|
+
zodRef,
|
|
925
|
+
schemas,
|
|
926
|
+
openApiVersion
|
|
927
|
+
}) {
|
|
995
928
|
return merge(
|
|
996
929
|
{
|
|
997
|
-
type: typeFormat(
|
|
998
|
-
format:
|
|
930
|
+
type: typeFormat("string", openApiVersion),
|
|
931
|
+
format: "date-time"
|
|
999
932
|
},
|
|
1000
933
|
zodRef.description ? { description: zodRef.description } : {},
|
|
1001
934
|
...schemas
|
|
1002
935
|
);
|
|
1003
936
|
}
|
|
1004
|
-
function parseNull({
|
|
937
|
+
function parseNull({
|
|
938
|
+
zodRef,
|
|
939
|
+
schemas,
|
|
940
|
+
openApiVersion
|
|
941
|
+
}) {
|
|
1005
942
|
return merge(
|
|
1006
|
-
openApiVersion ===
|
|
1007
|
-
|
|
1008
|
-
:
|
|
1009
|
-
|
|
1010
|
-
enum: ['null']
|
|
1011
|
-
},
|
|
943
|
+
openApiVersion === "3.0" ? { type: "null" } : {
|
|
944
|
+
type: ["string", "null"],
|
|
945
|
+
enum: ["null"]
|
|
946
|
+
},
|
|
1012
947
|
zodRef.description ? { description: zodRef.description } : {},
|
|
1013
948
|
...schemas
|
|
1014
949
|
);
|
|
1015
950
|
}
|
|
1016
|
-
function parseOptional({
|
|
951
|
+
function parseOptional({
|
|
952
|
+
schemas,
|
|
953
|
+
zodRef,
|
|
954
|
+
useOutput,
|
|
955
|
+
openApiVersion
|
|
956
|
+
}) {
|
|
1017
957
|
return merge(
|
|
1018
958
|
generateSchema(zodRef.unwrap(), useOutput, openApiVersion),
|
|
1019
959
|
zodRef.description ? { description: zodRef.description } : {},
|
|
1020
960
|
...schemas
|
|
1021
961
|
);
|
|
1022
962
|
}
|
|
1023
|
-
function parseNullable({
|
|
963
|
+
function parseNullable({
|
|
964
|
+
schemas,
|
|
965
|
+
zodRef,
|
|
966
|
+
useOutput,
|
|
967
|
+
openApiVersion
|
|
968
|
+
}) {
|
|
1024
969
|
const schema = generateSchema(zodRef.unwrap(), useOutput, openApiVersion);
|
|
1025
970
|
return merge(
|
|
1026
971
|
schema,
|
|
1027
|
-
openApiVersion ===
|
|
1028
|
-
? { nullable: true }
|
|
1029
|
-
: { type: typeFormat('null', openApiVersion) },
|
|
972
|
+
openApiVersion === "3.0" ? { nullable: true } : { type: typeFormat("null", openApiVersion) },
|
|
1030
973
|
zodRef.description ? { description: zodRef.description } : {},
|
|
1031
974
|
...schemas
|
|
1032
975
|
);
|
|
1033
976
|
}
|
|
1034
|
-
function parseDefault({
|
|
977
|
+
function parseDefault({
|
|
978
|
+
schemas,
|
|
979
|
+
zodRef,
|
|
980
|
+
useOutput,
|
|
981
|
+
openApiVersion
|
|
982
|
+
}) {
|
|
1035
983
|
return merge(
|
|
1036
984
|
{
|
|
1037
985
|
default: zodRef._def.defaultValue(),
|
|
@@ -1041,7 +989,12 @@ function parseDefault({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
|
1041
989
|
...schemas
|
|
1042
990
|
);
|
|
1043
991
|
}
|
|
1044
|
-
function parseArray({
|
|
992
|
+
function parseArray({
|
|
993
|
+
schemas,
|
|
994
|
+
zodRef,
|
|
995
|
+
useOutput,
|
|
996
|
+
openApiVersion
|
|
997
|
+
}) {
|
|
1045
998
|
const constraints = {};
|
|
1046
999
|
if (zodRef._def.exactLength != null) {
|
|
1047
1000
|
constraints.minItems = zodRef._def.exactLength.value;
|
|
@@ -1053,7 +1006,7 @@ function parseArray({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
|
1053
1006
|
constraints.maxItems = zodRef._def.maxLength.value;
|
|
1054
1007
|
return merge(
|
|
1055
1008
|
{
|
|
1056
|
-
type: typeFormat(
|
|
1009
|
+
type: typeFormat("array", openApiVersion),
|
|
1057
1010
|
items: generateSchema(zodRef.element, useOutput, openApiVersion),
|
|
1058
1011
|
...constraints
|
|
1059
1012
|
},
|
|
@@ -1061,7 +1014,11 @@ function parseArray({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
|
1061
1014
|
...schemas
|
|
1062
1015
|
);
|
|
1063
1016
|
}
|
|
1064
|
-
function parseLiteral({
|
|
1017
|
+
function parseLiteral({
|
|
1018
|
+
schemas,
|
|
1019
|
+
zodRef,
|
|
1020
|
+
openApiVersion
|
|
1021
|
+
}) {
|
|
1065
1022
|
const type22 = typeof zodRef._def.value;
|
|
1066
1023
|
return merge(
|
|
1067
1024
|
{
|
|
@@ -1072,7 +1029,11 @@ function parseLiteral({ schemas, zodRef, openApiVersion }) {
|
|
|
1072
1029
|
...schemas
|
|
1073
1030
|
);
|
|
1074
1031
|
}
|
|
1075
|
-
function parseEnum({
|
|
1032
|
+
function parseEnum({
|
|
1033
|
+
schemas,
|
|
1034
|
+
zodRef,
|
|
1035
|
+
openApiVersion
|
|
1036
|
+
}) {
|
|
1076
1037
|
const type22 = typeof Object.values(zodRef._def.values)[0];
|
|
1077
1038
|
return merge(
|
|
1078
1039
|
{
|
|
@@ -1083,7 +1044,12 @@ function parseEnum({ schemas, zodRef, openApiVersion }) {
|
|
|
1083
1044
|
...schemas
|
|
1084
1045
|
);
|
|
1085
1046
|
}
|
|
1086
|
-
function parseIntersection({
|
|
1047
|
+
function parseIntersection({
|
|
1048
|
+
schemas,
|
|
1049
|
+
zodRef,
|
|
1050
|
+
useOutput,
|
|
1051
|
+
openApiVersion
|
|
1052
|
+
}) {
|
|
1087
1053
|
return merge(
|
|
1088
1054
|
{
|
|
1089
1055
|
allOf: [
|
|
@@ -1095,20 +1061,20 @@ function parseIntersection({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
|
1095
1061
|
...schemas
|
|
1096
1062
|
);
|
|
1097
1063
|
}
|
|
1098
|
-
function parseUnion({
|
|
1064
|
+
function parseUnion({
|
|
1065
|
+
schemas,
|
|
1066
|
+
zodRef,
|
|
1067
|
+
useOutput,
|
|
1068
|
+
openApiVersion
|
|
1069
|
+
}) {
|
|
1099
1070
|
const contents = zodRef._def.options;
|
|
1100
|
-
if (
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
)
|
|
1105
|
-
) {
|
|
1071
|
+
if (contents.reduce(
|
|
1072
|
+
(prev, content) => prev && content._def.typeName === "ZodLiteral",
|
|
1073
|
+
true
|
|
1074
|
+
)) {
|
|
1106
1075
|
const literals = contents;
|
|
1107
1076
|
const type22 = literals.reduce(
|
|
1108
|
-
(prev, content) =>
|
|
1109
|
-
!prev || prev === typeof content._def.value
|
|
1110
|
-
? typeof content._def.value
|
|
1111
|
-
: null,
|
|
1077
|
+
(prev, content) => !prev || prev === typeof content._def.value ? typeof content._def.value : null,
|
|
1112
1078
|
null
|
|
1113
1079
|
);
|
|
1114
1080
|
if (type22) {
|
|
@@ -1122,15 +1088,12 @@ function parseUnion({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
|
1122
1088
|
);
|
|
1123
1089
|
}
|
|
1124
1090
|
}
|
|
1125
|
-
const oneOfContents =
|
|
1126
|
-
openApiVersion === '3.0'
|
|
1127
|
-
? contents.filter((content) => content._def.typeName !== 'ZodNull')
|
|
1128
|
-
: contents;
|
|
1091
|
+
const oneOfContents = openApiVersion === "3.0" ? contents.filter((content) => content._def.typeName !== "ZodNull") : contents;
|
|
1129
1092
|
const contentsHasNull = contents.length != oneOfContents.length;
|
|
1130
1093
|
return merge(
|
|
1131
1094
|
{
|
|
1132
|
-
oneOf: oneOfContents.map(
|
|
1133
|
-
generateSchema(schema, useOutput, openApiVersion)
|
|
1095
|
+
oneOf: oneOfContents.map(
|
|
1096
|
+
(schema) => generateSchema(schema, useOutput, openApiVersion)
|
|
1134
1097
|
)
|
|
1135
1098
|
},
|
|
1136
1099
|
contentsHasNull ? { nullable: true } : {},
|
|
@@ -1149,34 +1112,50 @@ function parseDiscriminatedUnion({
|
|
|
1149
1112
|
discriminator: {
|
|
1150
1113
|
propertyName: zodRef._def.discriminator
|
|
1151
1114
|
},
|
|
1152
|
-
oneOf: Array.from(
|
|
1153
|
-
|
|
1154
|
-
)
|
|
1115
|
+
oneOf: Array.from(
|
|
1116
|
+
zodRef._def.options.values()
|
|
1117
|
+
).map((schema) => generateSchema(schema, useOutput, openApiVersion))
|
|
1155
1118
|
},
|
|
1156
1119
|
zodRef.description ? { description: zodRef.description } : {},
|
|
1157
1120
|
...schemas
|
|
1158
1121
|
);
|
|
1159
1122
|
}
|
|
1160
|
-
function parseNever({
|
|
1123
|
+
function parseNever({
|
|
1124
|
+
zodRef,
|
|
1125
|
+
schemas
|
|
1126
|
+
}) {
|
|
1161
1127
|
return merge(
|
|
1162
1128
|
{ readOnly: true },
|
|
1163
1129
|
zodRef.description ? { description: zodRef.description } : {},
|
|
1164
1130
|
...schemas
|
|
1165
1131
|
);
|
|
1166
1132
|
}
|
|
1167
|
-
function parseBranded({
|
|
1133
|
+
function parseBranded({
|
|
1134
|
+
schemas,
|
|
1135
|
+
zodRef,
|
|
1136
|
+
useOutput,
|
|
1137
|
+
openApiVersion
|
|
1138
|
+
}) {
|
|
1168
1139
|
return merge(
|
|
1169
1140
|
generateSchema(zodRef._def.type, useOutput, openApiVersion),
|
|
1170
1141
|
...schemas
|
|
1171
1142
|
);
|
|
1172
1143
|
}
|
|
1173
|
-
function catchAllParser({
|
|
1144
|
+
function catchAllParser({
|
|
1145
|
+
zodRef,
|
|
1146
|
+
schemas
|
|
1147
|
+
}) {
|
|
1174
1148
|
return merge(
|
|
1175
1149
|
zodRef.description ? { description: zodRef.description } : {},
|
|
1176
1150
|
...schemas
|
|
1177
1151
|
);
|
|
1178
1152
|
}
|
|
1179
|
-
function parsePipeline({
|
|
1153
|
+
function parsePipeline({
|
|
1154
|
+
schemas,
|
|
1155
|
+
zodRef,
|
|
1156
|
+
useOutput,
|
|
1157
|
+
openApiVersion
|
|
1158
|
+
}) {
|
|
1180
1159
|
return merge(
|
|
1181
1160
|
generateSchema(
|
|
1182
1161
|
useOutput ? zodRef._def.out : zodRef._def.in,
|
|
@@ -1186,7 +1165,12 @@ function parsePipeline({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
|
1186
1165
|
...schemas
|
|
1187
1166
|
);
|
|
1188
1167
|
}
|
|
1189
|
-
function parseReadonly({
|
|
1168
|
+
function parseReadonly({
|
|
1169
|
+
zodRef,
|
|
1170
|
+
useOutput,
|
|
1171
|
+
schemas,
|
|
1172
|
+
openApiVersion
|
|
1173
|
+
}) {
|
|
1190
1174
|
return merge(
|
|
1191
1175
|
generateSchema(zodRef._def.innerType, useOutput, openApiVersion),
|
|
1192
1176
|
zodRef.description ? { description: zodRef.description } : {},
|
|
@@ -1230,10 +1214,10 @@ var workerMap = {
|
|
|
1230
1214
|
ZodPipeline: parsePipeline,
|
|
1231
1215
|
ZodReadonly: parseReadonly
|
|
1232
1216
|
};
|
|
1233
|
-
function generateSchema(zodRef, useOutput = false, openApiVersion =
|
|
1217
|
+
function generateSchema(zodRef, useOutput = false, openApiVersion = "3.1") {
|
|
1234
1218
|
const { metaOpenApi = {} } = zodRef;
|
|
1235
1219
|
const schemas = [
|
|
1236
|
-
...
|
|
1220
|
+
...Array.isArray(metaOpenApi) ? metaOpenApi : [metaOpenApi]
|
|
1237
1221
|
];
|
|
1238
1222
|
try {
|
|
1239
1223
|
const typeName = zodRef._def.typeName;
|
|
@@ -1252,175 +1236,155 @@ function generateSchema(zodRef, useOutput = false, openApiVersion = '3.1') {
|
|
|
1252
1236
|
}
|
|
1253
1237
|
}
|
|
1254
1238
|
function extendZodWithOpenApi(zod, forceOverride = false) {
|
|
1255
|
-
if (
|
|
1256
|
-
!forceOverride &&
|
|
1257
|
-
typeof zod.ZodSchema.prototype.openapi !== 'undefined'
|
|
1258
|
-
) {
|
|
1239
|
+
if (!forceOverride && typeof zod.ZodSchema.prototype.openapi !== "undefined") {
|
|
1259
1240
|
return;
|
|
1260
1241
|
}
|
|
1261
|
-
zod.ZodSchema.prototype.openapi = function
|
|
1242
|
+
zod.ZodSchema.prototype.openapi = function(metadata) {
|
|
1262
1243
|
return extendApi(this, metadata);
|
|
1263
1244
|
};
|
|
1264
1245
|
}
|
|
1265
1246
|
extendZodWithOpenApi(import_v3.z);
|
|
1266
1247
|
var ZodSchemaValidator = class {
|
|
1267
|
-
_Type =
|
|
1248
|
+
_Type = "Zod";
|
|
1268
1249
|
_SchemaCatchall;
|
|
1269
1250
|
_ValidSchemaObject;
|
|
1270
1251
|
string = import_v3.z.string().openapi({
|
|
1271
|
-
title:
|
|
1272
|
-
example:
|
|
1252
|
+
title: "String",
|
|
1253
|
+
example: "a string"
|
|
1273
1254
|
});
|
|
1274
1255
|
uuid = import_v3.z.string().uuid().openapi({
|
|
1275
|
-
title:
|
|
1276
|
-
format:
|
|
1277
|
-
pattern:
|
|
1278
|
-
|
|
1279
|
-
example: 'a8b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6'
|
|
1256
|
+
title: "UUID",
|
|
1257
|
+
format: "uuid",
|
|
1258
|
+
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}$",
|
|
1259
|
+
example: "a8b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6"
|
|
1280
1260
|
});
|
|
1281
1261
|
email = import_v3.z.string().email().openapi({
|
|
1282
|
-
title:
|
|
1283
|
-
format:
|
|
1284
|
-
pattern:
|
|
1285
|
-
example:
|
|
1262
|
+
title: "Email",
|
|
1263
|
+
format: "email",
|
|
1264
|
+
pattern: "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$",
|
|
1265
|
+
example: "a@b.com"
|
|
1286
1266
|
});
|
|
1287
1267
|
uri = import_v3.z.string().url().openapi({
|
|
1288
|
-
title:
|
|
1289
|
-
format:
|
|
1290
|
-
pattern:
|
|
1291
|
-
example:
|
|
1268
|
+
title: "URI",
|
|
1269
|
+
format: "uri",
|
|
1270
|
+
pattern: "^[a-zA-Z][a-zA-Z\\d+-.]*:[^\\s]*$",
|
|
1271
|
+
example: "https://forklaunch.com"
|
|
1292
1272
|
});
|
|
1293
|
-
number = import_v3.z
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
try {
|
|
1308
|
-
if (value instanceof Date) {
|
|
1309
|
-
return BigInt(value.getTime());
|
|
1310
|
-
}
|
|
1311
|
-
switch (typeof value) {
|
|
1312
|
-
case 'number':
|
|
1313
|
-
case 'string':
|
|
1314
|
-
return BigInt(value);
|
|
1315
|
-
case 'boolean':
|
|
1316
|
-
return BigInt(value ? 1 : 0);
|
|
1317
|
-
default:
|
|
1318
|
-
return value;
|
|
1319
|
-
}
|
|
1320
|
-
} catch {
|
|
1321
|
-
return value;
|
|
1273
|
+
number = import_v3.z.preprocess((value) => {
|
|
1274
|
+
try {
|
|
1275
|
+
return Number(value);
|
|
1276
|
+
} catch {
|
|
1277
|
+
return value;
|
|
1278
|
+
}
|
|
1279
|
+
}, import_v3.z.number()).openapi({
|
|
1280
|
+
title: "Number",
|
|
1281
|
+
example: 123
|
|
1282
|
+
});
|
|
1283
|
+
bigint = import_v3.z.preprocess((value) => {
|
|
1284
|
+
try {
|
|
1285
|
+
if (value instanceof Date) {
|
|
1286
|
+
return BigInt(value.getTime());
|
|
1322
1287
|
}
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
.preprocess((val) => {
|
|
1332
|
-
if (typeof val === 'string') {
|
|
1333
|
-
if (val.toLowerCase() === 'true') return true;
|
|
1334
|
-
if (val.toLowerCase() === 'false') return false;
|
|
1288
|
+
switch (typeof value) {
|
|
1289
|
+
case "number":
|
|
1290
|
+
case "string":
|
|
1291
|
+
return BigInt(value);
|
|
1292
|
+
case "boolean":
|
|
1293
|
+
return BigInt(value ? 1 : 0);
|
|
1294
|
+
default:
|
|
1295
|
+
return value;
|
|
1335
1296
|
}
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1297
|
+
} catch {
|
|
1298
|
+
return value;
|
|
1299
|
+
}
|
|
1300
|
+
}, import_v3.z.bigint()).openapi({
|
|
1301
|
+
title: "BigInt",
|
|
1302
|
+
type: "integer",
|
|
1303
|
+
format: "int64",
|
|
1304
|
+
example: 123n
|
|
1305
|
+
});
|
|
1306
|
+
boolean = import_v3.z.preprocess((val) => {
|
|
1307
|
+
if (typeof val === "string") {
|
|
1308
|
+
if (val.toLowerCase() === "true") return true;
|
|
1309
|
+
if (val.toLowerCase() === "false") return false;
|
|
1310
|
+
}
|
|
1311
|
+
return val;
|
|
1312
|
+
}, import_v3.z.boolean()).openapi({
|
|
1313
|
+
title: "Boolean",
|
|
1314
|
+
example: true
|
|
1315
|
+
});
|
|
1316
|
+
date = import_v3.z.preprocess((value) => {
|
|
1317
|
+
try {
|
|
1318
|
+
switch (typeof value) {
|
|
1319
|
+
case "string":
|
|
1320
|
+
return new Date(value);
|
|
1321
|
+
case "number":
|
|
1322
|
+
return new Date(value);
|
|
1323
|
+
default:
|
|
1324
|
+
return value;
|
|
1355
1325
|
}
|
|
1356
|
-
}
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1326
|
+
} catch {
|
|
1327
|
+
return value;
|
|
1328
|
+
}
|
|
1329
|
+
}, import_v3.z.date()).openapi({
|
|
1330
|
+
title: "Date",
|
|
1331
|
+
type: "string",
|
|
1332
|
+
format: "date-time",
|
|
1333
|
+
example: "2025-05-16T21:13:04.123Z"
|
|
1334
|
+
});
|
|
1363
1335
|
symbol = import_v3.z.symbol().openapi({
|
|
1364
|
-
title:
|
|
1365
|
-
example: Symbol(
|
|
1336
|
+
title: "Symbol",
|
|
1337
|
+
example: Symbol("symbol")
|
|
1338
|
+
});
|
|
1339
|
+
nullish = import_v3.z.union([import_v3.z.void(), import_v3.z.null(), import_v3.z.undefined()]).openapi({
|
|
1340
|
+
title: "Nullish",
|
|
1341
|
+
type: "null",
|
|
1342
|
+
example: null
|
|
1366
1343
|
});
|
|
1367
|
-
nullish = import_v3.z
|
|
1368
|
-
.union([import_v3.z.void(), import_v3.z.null(), import_v3.z.undefined()])
|
|
1369
|
-
.openapi({
|
|
1370
|
-
title: 'Nullish',
|
|
1371
|
-
type: 'null',
|
|
1372
|
-
example: null
|
|
1373
|
-
});
|
|
1374
1344
|
void = import_v3.z.void().openapi({
|
|
1375
|
-
title:
|
|
1376
|
-
type:
|
|
1345
|
+
title: "Void",
|
|
1346
|
+
type: "null",
|
|
1377
1347
|
example: void 0
|
|
1378
1348
|
});
|
|
1379
1349
|
null = import_v3.z.null().openapi({
|
|
1380
|
-
title:
|
|
1381
|
-
type:
|
|
1350
|
+
title: "Null",
|
|
1351
|
+
type: "null",
|
|
1382
1352
|
example: null
|
|
1383
1353
|
});
|
|
1384
1354
|
undefined = import_v3.z.undefined().openapi({
|
|
1385
|
-
title:
|
|
1386
|
-
type:
|
|
1355
|
+
title: "Undefined",
|
|
1356
|
+
type: "null",
|
|
1387
1357
|
example: void 0
|
|
1388
1358
|
});
|
|
1389
1359
|
any = import_v3.z.any().openapi({
|
|
1390
|
-
title:
|
|
1391
|
-
type:
|
|
1392
|
-
example:
|
|
1360
|
+
title: "Any",
|
|
1361
|
+
type: "object",
|
|
1362
|
+
example: "any"
|
|
1393
1363
|
});
|
|
1394
1364
|
unknown = import_v3.z.unknown().openapi({
|
|
1395
|
-
title:
|
|
1396
|
-
type:
|
|
1397
|
-
example:
|
|
1365
|
+
title: "Unknown",
|
|
1366
|
+
type: "object",
|
|
1367
|
+
example: "unknown"
|
|
1398
1368
|
});
|
|
1399
1369
|
never = import_v3.z.never().openapi({
|
|
1400
|
-
title:
|
|
1401
|
-
type:
|
|
1402
|
-
example:
|
|
1370
|
+
title: "Never",
|
|
1371
|
+
type: "null",
|
|
1372
|
+
example: "never"
|
|
1373
|
+
});
|
|
1374
|
+
binary = import_v3.z.string().transform((val) => new Uint8Array(Buffer.from(val, "base64"))).openapi({
|
|
1375
|
+
title: "Binary",
|
|
1376
|
+
type: "string",
|
|
1377
|
+
format: "binary",
|
|
1378
|
+
example: "a base-64 encodable string"
|
|
1379
|
+
});
|
|
1380
|
+
file = import_v3.z.instanceof(Buffer).transform((val) => {
|
|
1381
|
+
return new Blob([val]);
|
|
1382
|
+
}).openapi({
|
|
1383
|
+
title: "File",
|
|
1384
|
+
type: "string",
|
|
1385
|
+
format: "binary",
|
|
1386
|
+
example: "a base-64 encodable blob or file"
|
|
1403
1387
|
});
|
|
1404
|
-
binary = import_v3.z
|
|
1405
|
-
.string()
|
|
1406
|
-
.transform((val) => new Uint8Array(Buffer.from(val, 'base64')))
|
|
1407
|
-
.openapi({
|
|
1408
|
-
title: 'Binary',
|
|
1409
|
-
type: 'string',
|
|
1410
|
-
format: 'binary',
|
|
1411
|
-
example: 'a base-64 encodable string'
|
|
1412
|
-
});
|
|
1413
|
-
file = import_v3.z
|
|
1414
|
-
.instanceof(Buffer)
|
|
1415
|
-
.transform((val) => {
|
|
1416
|
-
return new Blob([val]);
|
|
1417
|
-
})
|
|
1418
|
-
.openapi({
|
|
1419
|
-
title: 'File',
|
|
1420
|
-
type: 'string',
|
|
1421
|
-
format: 'binary',
|
|
1422
|
-
example: 'a base-64 encodable blob or file'
|
|
1423
|
-
});
|
|
1424
1388
|
type = () => this.any;
|
|
1425
1389
|
/**
|
|
1426
1390
|
* Compiles schema if this exists, for optimal performance.
|
|
@@ -1437,11 +1401,7 @@ var ZodSchemaValidator = class {
|
|
|
1437
1401
|
* @returns {ZodResolve<T>} The resolved schema.
|
|
1438
1402
|
*/
|
|
1439
1403
|
schemify(schema) {
|
|
1440
|
-
if (
|
|
1441
|
-
typeof schema === 'string' ||
|
|
1442
|
-
typeof schema === 'number' ||
|
|
1443
|
-
typeof schema === 'boolean'
|
|
1444
|
-
) {
|
|
1404
|
+
if (typeof schema === "string" || typeof schema === "number" || typeof schema === "boolean") {
|
|
1445
1405
|
return import_v3.z.literal(schema);
|
|
1446
1406
|
}
|
|
1447
1407
|
if (schema instanceof import_v3.ZodType) {
|
|
@@ -1482,7 +1442,9 @@ var ZodSchemaValidator = class {
|
|
|
1482
1442
|
*/
|
|
1483
1443
|
union(schemas) {
|
|
1484
1444
|
const resolvedSchemas = schemas.map((schema) => this.schemify(schema));
|
|
1485
|
-
return import_v3.z.union(
|
|
1445
|
+
return import_v3.z.union(
|
|
1446
|
+
resolvedSchemas
|
|
1447
|
+
);
|
|
1486
1448
|
}
|
|
1487
1449
|
/**
|
|
1488
1450
|
* Create a literal schema.
|
|
@@ -1498,7 +1460,9 @@ var ZodSchemaValidator = class {
|
|
|
1498
1460
|
* @returns {ZodUnion<UnionZodResolve<[T, T, ...T[]]>>} The enum schema.
|
|
1499
1461
|
*/
|
|
1500
1462
|
enum_(schemaEnum) {
|
|
1501
|
-
return this.union(
|
|
1463
|
+
return this.union(
|
|
1464
|
+
Object.values(schemaEnum)
|
|
1465
|
+
);
|
|
1502
1466
|
}
|
|
1503
1467
|
/**
|
|
1504
1468
|
* Create a function schema.
|
|
@@ -1509,10 +1473,7 @@ var ZodSchemaValidator = class {
|
|
|
1509
1473
|
function_(args, returnType) {
|
|
1510
1474
|
const schemaArgs = args.map((schema) => this.schemify(schema));
|
|
1511
1475
|
const schemaReturnType = this.schemify(returnType);
|
|
1512
|
-
return import_v3.z.function(
|
|
1513
|
-
import_v3.z.tuple(schemaArgs),
|
|
1514
|
-
schemaReturnType
|
|
1515
|
-
);
|
|
1476
|
+
return import_v3.z.function(import_v3.z.tuple(schemaArgs), schemaReturnType);
|
|
1516
1477
|
}
|
|
1517
1478
|
/**
|
|
1518
1479
|
* Create a record schema.
|
|
@@ -1570,33 +1531,31 @@ var ZodSchemaValidator = class {
|
|
|
1570
1531
|
parse(schema, value) {
|
|
1571
1532
|
const resolvedSchema = this.schemify(schema);
|
|
1572
1533
|
const result = resolvedSchema.safeParse(value);
|
|
1573
|
-
return result.success
|
|
1574
|
-
|
|
1575
|
-
: {
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
})
|
|
1599
|
-
};
|
|
1534
|
+
return result.success ? { ok: true, value: result.data } : {
|
|
1535
|
+
ok: false,
|
|
1536
|
+
errors: result.error.errors.flatMap((error) => {
|
|
1537
|
+
switch (error.code) {
|
|
1538
|
+
case "invalid_union":
|
|
1539
|
+
return error.unionErrors.flatMap(
|
|
1540
|
+
(unionError, idx) => unionError.errors.map((e) => ({
|
|
1541
|
+
path: [
|
|
1542
|
+
`Union Schema Variant ${idx}`,
|
|
1543
|
+
...error.path.map((p) => p.toString()),
|
|
1544
|
+
...e.path.map((p) => p.toString())
|
|
1545
|
+
],
|
|
1546
|
+
message: e.message
|
|
1547
|
+
}))
|
|
1548
|
+
);
|
|
1549
|
+
default:
|
|
1550
|
+
return [
|
|
1551
|
+
{
|
|
1552
|
+
path: error.path.map((p) => p.toString()),
|
|
1553
|
+
message: error.message
|
|
1554
|
+
}
|
|
1555
|
+
];
|
|
1556
|
+
}
|
|
1557
|
+
})
|
|
1558
|
+
};
|
|
1600
1559
|
}
|
|
1601
1560
|
/**
|
|
1602
1561
|
* Convert a schema to an OpenAPI schema object.
|
|
@@ -1658,7 +1617,6 @@ var KafkaWorkerSchemas = (0, import_internal.serviceSchemaResolver)(
|
|
|
1658
1617
|
() => KafkaWorkerOptionsSchema2
|
|
1659
1618
|
);
|
|
1660
1619
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1661
|
-
0 &&
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
});
|
|
1620
|
+
0 && (module.exports = {
|
|
1621
|
+
KafkaWorkerSchemas
|
|
1622
|
+
});
|