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