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