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