@forklaunch/implementation-worker-kafka 0.2.2 → 0.3.0
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 +21 -0
- package/lib/consumers/index.d.ts +21 -2
- package/lib/consumers/index.js +173 -1
- package/lib/consumers/{kafkaWorker.consumer.js → index.mjs} +16 -17
- package/lib/producers/index.d.mts +13 -0
- package/lib/producers/index.d.ts +13 -2
- package/lib/producers/index.js +57 -1
- package/lib/producers/{kafkaWorker.producer.js → index.mjs} +8 -6
- package/lib/schemas/index.d.mts +24 -0
- package/lib/schemas/index.d.ts +24 -2
- package/lib/schemas/index.js +1377 -1
- package/lib/schemas/index.mjs +1381 -0
- package/lib/types/index.d.mts +10 -0
- package/lib/types/index.d.ts +10 -2
- package/lib/types/index.js +18 -1
- package/lib/types/index.mjs +0 -0
- package/package.json +6 -5
- package/lib/__test__/schemaEquality.test.d.ts +0 -2
- package/lib/__test__/schemaEquality.test.d.ts.map +0 -1
- package/lib/__test__/schemaEquality.test.js +0 -24
- package/lib/consumers/index.d.ts.map +0 -1
- package/lib/consumers/kafkaWorker.consumer.d.ts +0 -32
- package/lib/consumers/kafkaWorker.consumer.d.ts.map +0 -1
- package/lib/jest.config.d.ts +0 -4
- package/lib/jest.config.d.ts.map +0 -1
- package/lib/jest.config.js +0 -19
- package/lib/producers/index.d.ts.map +0 -1
- package/lib/producers/kafkaWorker.producer.d.ts +0 -14
- package/lib/producers/kafkaWorker.producer.d.ts.map +0 -1
- package/lib/schemas/index.d.ts.map +0 -1
- package/lib/schemas/kafka.schema.d.ts +0 -72
- package/lib/schemas/kafka.schema.d.ts.map +0 -1
- package/lib/schemas/kafka.schema.js +0 -7
- package/lib/schemas/typebox/kafkaWorker.schema.d.ts +0 -47
- package/lib/schemas/typebox/kafkaWorker.schema.d.ts.map +0 -1
- package/lib/schemas/typebox/kafkaWorker.schema.js +0 -9
- package/lib/schemas/zod/kafkaWorker.schema.d.ts +0 -9
- package/lib/schemas/zod/kafkaWorker.schema.d.ts.map +0 -1
- package/lib/schemas/zod/kafkaWorker.schema.js +0 -9
- package/lib/tsconfig.tsbuildinfo +0 -1
- package/lib/types/index.d.ts.map +0 -1
- package/lib/types/kafkaWorker.types.d.ts +0 -9
- package/lib/types/kafkaWorker.types.d.ts.map +0 -1
- package/lib/types/kafkaWorker.types.js +0 -1
- package/lib/vitest.config.d.ts +0 -3
- package/lib/vitest.config.d.ts.map +0 -1
- package/lib/vitest.config.js +0 -7
|
@@ -0,0 +1,1381 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
8
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
9
|
+
}) : x)(function(x) {
|
|
10
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
11
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
12
|
+
});
|
|
13
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
14
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
15
|
+
};
|
|
16
|
+
var __copyProps = (to, from, except, desc) => {
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
+
for (let key of __getOwnPropNames(from))
|
|
19
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
20
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
25
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
30
|
+
mod
|
|
31
|
+
));
|
|
32
|
+
|
|
33
|
+
// ../../../node_modules/.pnpm/ts-deepmerge@6.2.1/node_modules/ts-deepmerge/cjs/index.js
|
|
34
|
+
var require_cjs = __commonJS({
|
|
35
|
+
"../../../node_modules/.pnpm/ts-deepmerge@6.2.1/node_modules/ts-deepmerge/cjs/index.js"(exports) {
|
|
36
|
+
"use strict";
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
var isObject = (obj) => {
|
|
39
|
+
if (typeof obj === "object" && obj !== null) {
|
|
40
|
+
if (typeof Object.getPrototypeOf === "function") {
|
|
41
|
+
const prototype = Object.getPrototypeOf(obj);
|
|
42
|
+
return prototype === Object.prototype || prototype === null;
|
|
43
|
+
}
|
|
44
|
+
return Object.prototype.toString.call(obj) === "[object Object]";
|
|
45
|
+
}
|
|
46
|
+
return false;
|
|
47
|
+
};
|
|
48
|
+
var merge = (...objects) => objects.reduce((result, current) => {
|
|
49
|
+
if (Array.isArray(current)) {
|
|
50
|
+
throw new TypeError("Arguments provided to ts-deepmerge must be objects, not arrays.");
|
|
51
|
+
}
|
|
52
|
+
Object.keys(current).forEach((key) => {
|
|
53
|
+
if (["__proto__", "constructor", "prototype"].includes(key)) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (Array.isArray(result[key]) && Array.isArray(current[key])) {
|
|
57
|
+
result[key] = merge.options.mergeArrays ? merge.options.uniqueArrayItems ? Array.from(new Set(result[key].concat(current[key]))) : [...result[key], ...current[key]] : current[key];
|
|
58
|
+
} else if (isObject(result[key]) && isObject(current[key])) {
|
|
59
|
+
result[key] = merge(result[key], current[key]);
|
|
60
|
+
} else {
|
|
61
|
+
result[key] = current[key] === void 0 ? merge.options.allowUndefinedOverrides ? current[key] : result[key] : current[key];
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
return result;
|
|
65
|
+
}, {});
|
|
66
|
+
var defaultOptions = {
|
|
67
|
+
allowUndefinedOverrides: true,
|
|
68
|
+
mergeArrays: true,
|
|
69
|
+
uniqueArrayItems: true
|
|
70
|
+
};
|
|
71
|
+
merge.options = defaultOptions;
|
|
72
|
+
merge.withOptions = (options, ...objects) => {
|
|
73
|
+
merge.options = Object.assign(Object.assign({}, defaultOptions), options);
|
|
74
|
+
const result = merge(...objects);
|
|
75
|
+
merge.options = defaultOptions;
|
|
76
|
+
return result;
|
|
77
|
+
};
|
|
78
|
+
exports.default = merge;
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// ../../../node_modules/.pnpm/@anatine+zod-openapi@2.2.8_openapi3-ts@4.4.0_zod@3.25.62/node_modules/@anatine/zod-openapi/src/lib/zod-openapi.js
|
|
83
|
+
var require_zod_openapi = __commonJS({
|
|
84
|
+
"../../../node_modules/.pnpm/@anatine+zod-openapi@2.2.8_openapi3-ts@4.4.0_zod@3.25.62/node_modules/@anatine/zod-openapi/src/lib/zod-openapi.js"(exports) {
|
|
85
|
+
"use strict";
|
|
86
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
87
|
+
exports.generateSchema = exports.extendApi = void 0;
|
|
88
|
+
var ts_deepmerge_1 = require_cjs();
|
|
89
|
+
var zod_1 = __require("zod");
|
|
90
|
+
function extendApi(schema, schemaObject = {}) {
|
|
91
|
+
const This = schema.constructor;
|
|
92
|
+
const newSchema = new This(schema._def);
|
|
93
|
+
newSchema.metaOpenApi = Object.assign({}, schema.metaOpenApi || {}, schemaObject);
|
|
94
|
+
return newSchema;
|
|
95
|
+
}
|
|
96
|
+
exports.extendApi = extendApi;
|
|
97
|
+
function iterateZodObject({ zodRef, useOutput, hideDefinitions, openApiVersion }) {
|
|
98
|
+
const reduced = Object.keys(zodRef.shape).filter((key) => (hideDefinitions === null || hideDefinitions === void 0 ? void 0 : hideDefinitions.includes(key)) === false).reduce((carry, key) => Object.assign(Object.assign({}, carry), { [key]: generateSchema2(zodRef.shape[key], useOutput, openApiVersion) }), {});
|
|
99
|
+
return reduced;
|
|
100
|
+
}
|
|
101
|
+
function typeFormat(type3, openApiVersion) {
|
|
102
|
+
return openApiVersion === "3.0" ? type3 : [type3];
|
|
103
|
+
}
|
|
104
|
+
function parseTransformation({ zodRef, schemas, useOutput, openApiVersion }) {
|
|
105
|
+
const input = generateSchema2(zodRef._def.schema, useOutput, openApiVersion);
|
|
106
|
+
let output = "undefined";
|
|
107
|
+
if (useOutput && zodRef._def.effect) {
|
|
108
|
+
const effect = zodRef._def.effect.type === "transform" ? zodRef._def.effect : null;
|
|
109
|
+
if (effect && "transform" in effect) {
|
|
110
|
+
try {
|
|
111
|
+
const type3 = Array.isArray(input.type) ? input.type[0] : input.type;
|
|
112
|
+
output = typeof effect.transform(
|
|
113
|
+
["integer", "number"].includes(`${type3}`) ? 0 : "string" === type3 ? "" : "boolean" === type3 ? false : "object" === type3 ? {} : "null" === type3 ? null : "array" === type3 ? [] : void 0,
|
|
114
|
+
{ addIssue: () => void 0, path: [] }
|
|
115
|
+
// TODO: Discover if context is necessary here
|
|
116
|
+
);
|
|
117
|
+
} catch (e) {
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const outputType = output;
|
|
122
|
+
return (0, ts_deepmerge_1.default)(Object.assign(Object.assign(Object.assign({}, zodRef.description ? { description: zodRef.description } : {}), input), ["number", "string", "boolean", "null"].includes(output) ? {
|
|
123
|
+
type: typeFormat(outputType, openApiVersion)
|
|
124
|
+
} : {}), ...schemas);
|
|
125
|
+
}
|
|
126
|
+
function parseString({ zodRef, schemas, openApiVersion }) {
|
|
127
|
+
const baseSchema = {
|
|
128
|
+
type: typeFormat("string", openApiVersion)
|
|
129
|
+
};
|
|
130
|
+
const { checks = [] } = zodRef._def;
|
|
131
|
+
checks.forEach((item) => {
|
|
132
|
+
switch (item.kind) {
|
|
133
|
+
case "email":
|
|
134
|
+
baseSchema.format = "email";
|
|
135
|
+
break;
|
|
136
|
+
case "uuid":
|
|
137
|
+
baseSchema.format = "uuid";
|
|
138
|
+
break;
|
|
139
|
+
case "cuid":
|
|
140
|
+
baseSchema.format = "cuid";
|
|
141
|
+
break;
|
|
142
|
+
case "url":
|
|
143
|
+
baseSchema.format = "uri";
|
|
144
|
+
break;
|
|
145
|
+
case "datetime":
|
|
146
|
+
baseSchema.format = "date-time";
|
|
147
|
+
break;
|
|
148
|
+
case "length":
|
|
149
|
+
baseSchema.minLength = item.value;
|
|
150
|
+
baseSchema.maxLength = item.value;
|
|
151
|
+
break;
|
|
152
|
+
case "max":
|
|
153
|
+
baseSchema.maxLength = item.value;
|
|
154
|
+
break;
|
|
155
|
+
case "min":
|
|
156
|
+
baseSchema.minLength = item.value;
|
|
157
|
+
break;
|
|
158
|
+
case "regex":
|
|
159
|
+
baseSchema.pattern = item.regex.source;
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
return (0, ts_deepmerge_1.default)(baseSchema, zodRef.description ? { description: zodRef.description } : {}, ...schemas);
|
|
164
|
+
}
|
|
165
|
+
function parseNumber({ zodRef, schemas, openApiVersion }) {
|
|
166
|
+
const baseSchema = {
|
|
167
|
+
type: typeFormat("number", openApiVersion)
|
|
168
|
+
};
|
|
169
|
+
const { checks = [] } = zodRef._def;
|
|
170
|
+
checks.forEach((item) => {
|
|
171
|
+
switch (item.kind) {
|
|
172
|
+
case "max":
|
|
173
|
+
if (item.inclusive || openApiVersion === "3.0") {
|
|
174
|
+
baseSchema.maximum = item.value;
|
|
175
|
+
}
|
|
176
|
+
if (!item.inclusive) {
|
|
177
|
+
if (openApiVersion === "3.0") {
|
|
178
|
+
baseSchema.exclusiveMaximum = true;
|
|
179
|
+
} else {
|
|
180
|
+
baseSchema.exclusiveMaximum = item.value;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
break;
|
|
184
|
+
case "min":
|
|
185
|
+
if (item.inclusive || openApiVersion === "3.0") {
|
|
186
|
+
baseSchema.minimum = item.value;
|
|
187
|
+
}
|
|
188
|
+
if (!item.inclusive) {
|
|
189
|
+
if (openApiVersion === "3.0") {
|
|
190
|
+
baseSchema.exclusiveMinimum = true;
|
|
191
|
+
} else {
|
|
192
|
+
baseSchema.exclusiveMinimum = item.value;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
break;
|
|
196
|
+
case "int":
|
|
197
|
+
baseSchema.type = typeFormat("integer", openApiVersion);
|
|
198
|
+
break;
|
|
199
|
+
case "multipleOf":
|
|
200
|
+
baseSchema.multipleOf = item.value;
|
|
201
|
+
break;
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
return (0, ts_deepmerge_1.default)(baseSchema, zodRef.description ? { description: zodRef.description } : {}, ...schemas);
|
|
205
|
+
}
|
|
206
|
+
function getExcludedDefinitionsFromSchema(schemas) {
|
|
207
|
+
const excludedDefinitions = [];
|
|
208
|
+
for (const schema of schemas) {
|
|
209
|
+
if (Array.isArray(schema.hideDefinitions)) {
|
|
210
|
+
excludedDefinitions.push(...schema.hideDefinitions);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return excludedDefinitions;
|
|
214
|
+
}
|
|
215
|
+
function parseObject({ zodRef, schemas, useOutput, hideDefinitions, openApiVersion }) {
|
|
216
|
+
var _a;
|
|
217
|
+
let additionalProperties;
|
|
218
|
+
if (!(zodRef._def.catchall instanceof zod_1.z.ZodNever || ((_a = zodRef._def.catchall) === null || _a === void 0 ? void 0 : _a._def.typeName) === "ZodNever"))
|
|
219
|
+
additionalProperties = generateSchema2(zodRef._def.catchall, useOutput, openApiVersion);
|
|
220
|
+
else if (zodRef._def.unknownKeys === "passthrough")
|
|
221
|
+
additionalProperties = true;
|
|
222
|
+
else if (zodRef._def.unknownKeys === "strict")
|
|
223
|
+
additionalProperties = false;
|
|
224
|
+
additionalProperties = additionalProperties != null ? { additionalProperties } : {};
|
|
225
|
+
const requiredProperties = Object.keys(zodRef.shape).filter((key) => {
|
|
226
|
+
const item = zodRef.shape[key];
|
|
227
|
+
return !(item.isOptional() || item instanceof zod_1.z.ZodDefault || item._def.typeName === "ZodDefault") && !(item instanceof zod_1.z.ZodNever || item._def.typeName === "ZodDefault");
|
|
228
|
+
});
|
|
229
|
+
const required = requiredProperties.length > 0 ? { required: requiredProperties } : {};
|
|
230
|
+
return (0, ts_deepmerge_1.default)(Object.assign(Object.assign(Object.assign({ type: typeFormat("object", openApiVersion), properties: iterateZodObject({
|
|
231
|
+
zodRef,
|
|
232
|
+
schemas,
|
|
233
|
+
useOutput,
|
|
234
|
+
hideDefinitions: getExcludedDefinitionsFromSchema(schemas),
|
|
235
|
+
openApiVersion
|
|
236
|
+
}) }, required), additionalProperties), hideDefinitions), zodRef.description ? { description: zodRef.description, hideDefinitions } : {}, ...schemas);
|
|
237
|
+
}
|
|
238
|
+
function parseRecord({ zodRef, schemas, useOutput, openApiVersion }) {
|
|
239
|
+
return (0, ts_deepmerge_1.default)({
|
|
240
|
+
type: typeFormat("object", openApiVersion),
|
|
241
|
+
additionalProperties: zodRef._def.valueType instanceof zod_1.z.ZodUnknown ? {} : generateSchema2(zodRef._def.valueType, useOutput, openApiVersion)
|
|
242
|
+
}, zodRef.description ? { description: zodRef.description } : {}, ...schemas);
|
|
243
|
+
}
|
|
244
|
+
function parseBigInt({ zodRef, schemas, openApiVersion }) {
|
|
245
|
+
return (0, ts_deepmerge_1.default)({
|
|
246
|
+
type: typeFormat("integer", openApiVersion),
|
|
247
|
+
format: "int64"
|
|
248
|
+
}, zodRef.description ? { description: zodRef.description } : {}, ...schemas);
|
|
249
|
+
}
|
|
250
|
+
function parseBoolean({ zodRef, schemas, openApiVersion }) {
|
|
251
|
+
return (0, ts_deepmerge_1.default)({ type: typeFormat("boolean", openApiVersion) }, zodRef.description ? { description: zodRef.description } : {}, ...schemas);
|
|
252
|
+
}
|
|
253
|
+
function parseDate({ zodRef, schemas, openApiVersion }) {
|
|
254
|
+
return (0, ts_deepmerge_1.default)({
|
|
255
|
+
type: typeFormat("string", openApiVersion),
|
|
256
|
+
format: "date-time"
|
|
257
|
+
}, zodRef.description ? { description: zodRef.description } : {}, ...schemas);
|
|
258
|
+
}
|
|
259
|
+
function parseNull({ zodRef, schemas, openApiVersion }) {
|
|
260
|
+
return (0, ts_deepmerge_1.default)(openApiVersion === "3.0" ? { type: "null" } : {
|
|
261
|
+
type: ["string", "null"],
|
|
262
|
+
enum: ["null"]
|
|
263
|
+
}, zodRef.description ? { description: zodRef.description } : {}, ...schemas);
|
|
264
|
+
}
|
|
265
|
+
function parseOptional({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
266
|
+
return (0, ts_deepmerge_1.default)(generateSchema2(zodRef.unwrap(), useOutput, openApiVersion), zodRef.description ? { description: zodRef.description } : {}, ...schemas);
|
|
267
|
+
}
|
|
268
|
+
function parseNullable({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
269
|
+
const schema = generateSchema2(zodRef.unwrap(), useOutput, openApiVersion);
|
|
270
|
+
return (0, ts_deepmerge_1.default)(schema, openApiVersion === "3.0" ? { nullable: true } : { type: typeFormat("null", openApiVersion) }, zodRef.description ? { description: zodRef.description } : {}, ...schemas);
|
|
271
|
+
}
|
|
272
|
+
function parseDefault({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
273
|
+
return (0, ts_deepmerge_1.default)(Object.assign({ default: zodRef._def.defaultValue() }, generateSchema2(zodRef._def.innerType, useOutput, openApiVersion)), zodRef.description ? { description: zodRef.description } : {}, ...schemas);
|
|
274
|
+
}
|
|
275
|
+
function parseArray({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
276
|
+
const constraints = {};
|
|
277
|
+
if (zodRef._def.exactLength != null) {
|
|
278
|
+
constraints.minItems = zodRef._def.exactLength.value;
|
|
279
|
+
constraints.maxItems = zodRef._def.exactLength.value;
|
|
280
|
+
}
|
|
281
|
+
if (zodRef._def.minLength != null)
|
|
282
|
+
constraints.minItems = zodRef._def.minLength.value;
|
|
283
|
+
if (zodRef._def.maxLength != null)
|
|
284
|
+
constraints.maxItems = zodRef._def.maxLength.value;
|
|
285
|
+
return (0, ts_deepmerge_1.default)(Object.assign({ type: typeFormat("array", openApiVersion), items: generateSchema2(zodRef.element, useOutput, openApiVersion) }, constraints), zodRef.description ? { description: zodRef.description } : {}, ...schemas);
|
|
286
|
+
}
|
|
287
|
+
function parseLiteral({ schemas, zodRef, openApiVersion }) {
|
|
288
|
+
const type3 = typeof zodRef._def.value;
|
|
289
|
+
return (0, ts_deepmerge_1.default)({
|
|
290
|
+
type: typeFormat(type3, openApiVersion),
|
|
291
|
+
enum: [zodRef._def.value]
|
|
292
|
+
}, zodRef.description ? { description: zodRef.description } : {}, ...schemas);
|
|
293
|
+
}
|
|
294
|
+
function parseEnum({ schemas, zodRef, openApiVersion }) {
|
|
295
|
+
const type3 = typeof Object.values(zodRef._def.values)[0];
|
|
296
|
+
return (0, ts_deepmerge_1.default)({
|
|
297
|
+
type: typeFormat(type3, openApiVersion),
|
|
298
|
+
enum: Object.values(zodRef._def.values)
|
|
299
|
+
}, zodRef.description ? { description: zodRef.description } : {}, ...schemas);
|
|
300
|
+
}
|
|
301
|
+
function parseIntersection({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
302
|
+
return (0, ts_deepmerge_1.default)({
|
|
303
|
+
allOf: [
|
|
304
|
+
generateSchema2(zodRef._def.left, useOutput, openApiVersion),
|
|
305
|
+
generateSchema2(zodRef._def.right, useOutput, openApiVersion)
|
|
306
|
+
]
|
|
307
|
+
}, zodRef.description ? { description: zodRef.description } : {}, ...schemas);
|
|
308
|
+
}
|
|
309
|
+
function parseUnion({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
310
|
+
const contents = zodRef._def.options;
|
|
311
|
+
if (contents.reduce((prev, content) => prev && content._def.typeName === "ZodLiteral", true)) {
|
|
312
|
+
const literals = contents;
|
|
313
|
+
const type3 = literals.reduce((prev, content) => !prev || prev === typeof content._def.value ? typeof content._def.value : null, null);
|
|
314
|
+
if (type3) {
|
|
315
|
+
return (0, ts_deepmerge_1.default)({
|
|
316
|
+
type: typeFormat(type3, openApiVersion),
|
|
317
|
+
enum: literals.map((literal3) => literal3._def.value)
|
|
318
|
+
}, zodRef.description ? { description: zodRef.description } : {}, ...schemas);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
const oneOfContents = openApiVersion === "3.0" ? contents.filter((content) => content._def.typeName !== "ZodNull") : contents;
|
|
322
|
+
const contentsHasNull = contents.length != oneOfContents.length;
|
|
323
|
+
return (0, ts_deepmerge_1.default)({
|
|
324
|
+
oneOf: oneOfContents.map((schema) => generateSchema2(schema, useOutput, openApiVersion))
|
|
325
|
+
}, contentsHasNull ? { nullable: true } : {}, zodRef.description ? { description: zodRef.description } : {}, ...schemas);
|
|
326
|
+
}
|
|
327
|
+
function parseDiscriminatedUnion({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
328
|
+
return (0, ts_deepmerge_1.default)({
|
|
329
|
+
discriminator: {
|
|
330
|
+
propertyName: zodRef._def.discriminator
|
|
331
|
+
},
|
|
332
|
+
oneOf: Array.from(zodRef._def.options.values()).map((schema) => generateSchema2(schema, useOutput, openApiVersion))
|
|
333
|
+
}, zodRef.description ? { description: zodRef.description } : {}, ...schemas);
|
|
334
|
+
}
|
|
335
|
+
function parseNever({ zodRef, schemas }) {
|
|
336
|
+
return (0, ts_deepmerge_1.default)({ readOnly: true }, zodRef.description ? { description: zodRef.description } : {}, ...schemas);
|
|
337
|
+
}
|
|
338
|
+
function parseBranded({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
339
|
+
return (0, ts_deepmerge_1.default)(generateSchema2(zodRef._def.type, useOutput, openApiVersion), ...schemas);
|
|
340
|
+
}
|
|
341
|
+
function catchAllParser({ zodRef, schemas }) {
|
|
342
|
+
return (0, ts_deepmerge_1.default)(zodRef.description ? { description: zodRef.description } : {}, ...schemas);
|
|
343
|
+
}
|
|
344
|
+
function parsePipeline({ schemas, zodRef, useOutput, openApiVersion }) {
|
|
345
|
+
return (0, ts_deepmerge_1.default)(generateSchema2(useOutput ? zodRef._def.out : zodRef._def.in, useOutput, openApiVersion), ...schemas);
|
|
346
|
+
}
|
|
347
|
+
function parseReadonly({ zodRef, useOutput, schemas, openApiVersion }) {
|
|
348
|
+
return (0, ts_deepmerge_1.default)(generateSchema2(zodRef._def.innerType, useOutput, openApiVersion), zodRef.description ? { description: zodRef.description } : {}, ...schemas);
|
|
349
|
+
}
|
|
350
|
+
var workerMap = {
|
|
351
|
+
ZodObject: parseObject,
|
|
352
|
+
ZodRecord: parseRecord,
|
|
353
|
+
ZodString: parseString,
|
|
354
|
+
ZodNumber: parseNumber,
|
|
355
|
+
ZodBigInt: parseBigInt,
|
|
356
|
+
ZodBoolean: parseBoolean,
|
|
357
|
+
ZodDate: parseDate,
|
|
358
|
+
ZodNull: parseNull,
|
|
359
|
+
ZodOptional: parseOptional,
|
|
360
|
+
ZodNullable: parseNullable,
|
|
361
|
+
ZodDefault: parseDefault,
|
|
362
|
+
ZodArray: parseArray,
|
|
363
|
+
ZodLiteral: parseLiteral,
|
|
364
|
+
ZodEnum: parseEnum,
|
|
365
|
+
ZodNativeEnum: parseEnum,
|
|
366
|
+
ZodTransformer: parseTransformation,
|
|
367
|
+
ZodEffects: parseTransformation,
|
|
368
|
+
ZodIntersection: parseIntersection,
|
|
369
|
+
ZodUnion: parseUnion,
|
|
370
|
+
ZodDiscriminatedUnion: parseDiscriminatedUnion,
|
|
371
|
+
ZodNever: parseNever,
|
|
372
|
+
ZodBranded: parseBranded,
|
|
373
|
+
// TODO Transform the rest to schemas
|
|
374
|
+
ZodUndefined: catchAllParser,
|
|
375
|
+
// TODO: `prefixItems` is allowed in OpenAPI 3.1 which can be used to create tuples
|
|
376
|
+
ZodTuple: catchAllParser,
|
|
377
|
+
ZodMap: catchAllParser,
|
|
378
|
+
ZodFunction: catchAllParser,
|
|
379
|
+
ZodLazy: catchAllParser,
|
|
380
|
+
ZodPromise: catchAllParser,
|
|
381
|
+
ZodAny: catchAllParser,
|
|
382
|
+
ZodUnknown: catchAllParser,
|
|
383
|
+
ZodVoid: catchAllParser,
|
|
384
|
+
ZodPipeline: parsePipeline,
|
|
385
|
+
ZodReadonly: parseReadonly
|
|
386
|
+
};
|
|
387
|
+
function generateSchema2(zodRef, useOutput = false, openApiVersion = "3.1") {
|
|
388
|
+
const { metaOpenApi = {} } = zodRef;
|
|
389
|
+
const schemas = [
|
|
390
|
+
...Array.isArray(metaOpenApi) ? metaOpenApi : [metaOpenApi]
|
|
391
|
+
];
|
|
392
|
+
try {
|
|
393
|
+
const typeName = zodRef._def.typeName;
|
|
394
|
+
if (typeName in workerMap) {
|
|
395
|
+
return workerMap[typeName]({
|
|
396
|
+
zodRef,
|
|
397
|
+
schemas,
|
|
398
|
+
useOutput,
|
|
399
|
+
openApiVersion
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
return catchAllParser({ zodRef, schemas, openApiVersion });
|
|
403
|
+
} catch (err) {
|
|
404
|
+
console.error(err);
|
|
405
|
+
return catchAllParser({ zodRef, schemas, openApiVersion });
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
exports.generateSchema = generateSchema2;
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
// ../../../node_modules/.pnpm/@anatine+zod-openapi@2.2.8_openapi3-ts@4.4.0_zod@3.25.62/node_modules/@anatine/zod-openapi/src/lib/zod-extensions.js
|
|
413
|
+
var require_zod_extensions = __commonJS({
|
|
414
|
+
"../../../node_modules/.pnpm/@anatine+zod-openapi@2.2.8_openapi3-ts@4.4.0_zod@3.25.62/node_modules/@anatine/zod-openapi/src/lib/zod-extensions.js"(exports) {
|
|
415
|
+
"use strict";
|
|
416
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
417
|
+
exports.extendZodWithOpenApi = void 0;
|
|
418
|
+
var zod_openapi_1 = require_zod_openapi();
|
|
419
|
+
function extendZodWithOpenApi2(zod, forceOverride = false) {
|
|
420
|
+
if (!forceOverride && typeof zod.ZodSchema.prototype.openapi !== "undefined") {
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
zod.ZodSchema.prototype.openapi = function(metadata) {
|
|
424
|
+
return (0, zod_openapi_1.extendApi)(this, metadata);
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
exports.extendZodWithOpenApi = extendZodWithOpenApi2;
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
|
|
431
|
+
// ../../../node_modules/.pnpm/@anatine+zod-openapi@2.2.8_openapi3-ts@4.4.0_zod@3.25.62/node_modules/@anatine/zod-openapi/src/index.js
|
|
432
|
+
var require_src = __commonJS({
|
|
433
|
+
"../../../node_modules/.pnpm/@anatine+zod-openapi@2.2.8_openapi3-ts@4.4.0_zod@3.25.62/node_modules/@anatine/zod-openapi/src/index.js"(exports) {
|
|
434
|
+
"use strict";
|
|
435
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
436
|
+
if (k2 === void 0) k2 = k;
|
|
437
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
438
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
439
|
+
desc = { enumerable: true, get: function() {
|
|
440
|
+
return m[k];
|
|
441
|
+
} };
|
|
442
|
+
}
|
|
443
|
+
Object.defineProperty(o, k2, desc);
|
|
444
|
+
} : function(o, m, k, k2) {
|
|
445
|
+
if (k2 === void 0) k2 = k;
|
|
446
|
+
o[k2] = m[k];
|
|
447
|
+
});
|
|
448
|
+
var __exportStar = exports && exports.__exportStar || function(m, exports2) {
|
|
449
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p)) __createBinding(exports2, m, p);
|
|
450
|
+
};
|
|
451
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
452
|
+
__exportStar(require_zod_openapi(), exports);
|
|
453
|
+
__exportStar(require_zod_extensions(), exports);
|
|
454
|
+
}
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
// schemas/kafka.schema.ts
|
|
458
|
+
import { serviceSchemaResolver } from "@forklaunch/core/mappers";
|
|
459
|
+
|
|
460
|
+
// ../../../node_modules/.pnpm/@forklaunch+common@0.3.11/node_modules/@forklaunch/common/lib/index.mjs
|
|
461
|
+
var InMemoryFile = class extends File {
|
|
462
|
+
constructor(content, name, {
|
|
463
|
+
type: type3,
|
|
464
|
+
endings,
|
|
465
|
+
lastModified
|
|
466
|
+
}) {
|
|
467
|
+
super([Buffer.from(content)], name, {
|
|
468
|
+
type: type3,
|
|
469
|
+
endings,
|
|
470
|
+
lastModified
|
|
471
|
+
});
|
|
472
|
+
this.content = content;
|
|
473
|
+
}
|
|
474
|
+
};
|
|
475
|
+
|
|
476
|
+
// ../../../node_modules/.pnpm/@forklaunch+validator@0.6.12_openapi3-ts@4.4.0/node_modules/@forklaunch/validator/lib/src/typebox/index.mjs
|
|
477
|
+
import {
|
|
478
|
+
FormatRegistry,
|
|
479
|
+
Kind,
|
|
480
|
+
KindGuard,
|
|
481
|
+
Type
|
|
482
|
+
} from "@sinclair/typebox";
|
|
483
|
+
import { TypeCheck, TypeCompiler } from "@sinclair/typebox/compiler";
|
|
484
|
+
import {
|
|
485
|
+
DefaultErrorFunction,
|
|
486
|
+
SetErrorFunction,
|
|
487
|
+
ValueErrorType
|
|
488
|
+
} from "@sinclair/typebox/errors";
|
|
489
|
+
import { Value } from "@sinclair/typebox/value";
|
|
490
|
+
FormatRegistry.Set("binary", (value) => typeof value === "string");
|
|
491
|
+
SetErrorFunction((params) => {
|
|
492
|
+
switch (params.errorType) {
|
|
493
|
+
case ValueErrorType.Union:
|
|
494
|
+
case ValueErrorType.Array:
|
|
495
|
+
case ValueErrorType.String:
|
|
496
|
+
case ValueErrorType.Number:
|
|
497
|
+
return params.schema.errorType ? `Expected ${params.schema.errorType} value${params.schema.errorSuffix ? "s" : ""}` : DefaultErrorFunction(params);
|
|
498
|
+
default:
|
|
499
|
+
return DefaultErrorFunction(params);
|
|
500
|
+
}
|
|
501
|
+
});
|
|
502
|
+
var TypeboxSchemaValidator = class {
|
|
503
|
+
_Type = "TypeBox";
|
|
504
|
+
_SchemaCatchall;
|
|
505
|
+
_ValidSchemaObject;
|
|
506
|
+
string = Type.String({
|
|
507
|
+
example: "a string",
|
|
508
|
+
title: "String"
|
|
509
|
+
});
|
|
510
|
+
uuid = Type.String({
|
|
511
|
+
pattern: "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$",
|
|
512
|
+
errorType: "uuid",
|
|
513
|
+
example: "a8b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6",
|
|
514
|
+
title: "UUID"
|
|
515
|
+
});
|
|
516
|
+
email = Type.String({
|
|
517
|
+
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])+)])`,
|
|
518
|
+
errorType: "email",
|
|
519
|
+
example: "a@b.com",
|
|
520
|
+
title: "Email"
|
|
521
|
+
});
|
|
522
|
+
uri = Type.String({
|
|
523
|
+
pattern: "^[a-zA-Z][a-zA-Z\\d+-.]*:[^\\s]*$",
|
|
524
|
+
errorType: "uri",
|
|
525
|
+
example: "https://forklaunch.com",
|
|
526
|
+
title: "URI"
|
|
527
|
+
});
|
|
528
|
+
number = Type.Transform(
|
|
529
|
+
Type.Union(
|
|
530
|
+
[
|
|
531
|
+
Type.Number(),
|
|
532
|
+
Type.String({ pattern: "^[0-9]+$" }),
|
|
533
|
+
Type.Boolean(),
|
|
534
|
+
Type.Null(),
|
|
535
|
+
Type.BigInt(),
|
|
536
|
+
Type.Date()
|
|
537
|
+
],
|
|
538
|
+
{
|
|
539
|
+
errorType: "number-like",
|
|
540
|
+
example: 123,
|
|
541
|
+
title: "Number"
|
|
542
|
+
}
|
|
543
|
+
)
|
|
544
|
+
).Decode((value) => {
|
|
545
|
+
if (typeof value !== "number") {
|
|
546
|
+
const num = Number(value);
|
|
547
|
+
if (isNaN(num)) {
|
|
548
|
+
throw new Error("Invalid number");
|
|
549
|
+
} else {
|
|
550
|
+
return num;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
return value;
|
|
554
|
+
}).Encode(Number);
|
|
555
|
+
bigint = Type.Transform(
|
|
556
|
+
Type.Union(
|
|
557
|
+
[
|
|
558
|
+
Type.BigInt(),
|
|
559
|
+
Type.Number(),
|
|
560
|
+
Type.String({ pattern: "^[0-9]+n?$" }),
|
|
561
|
+
Type.Boolean(),
|
|
562
|
+
Type.Date()
|
|
563
|
+
],
|
|
564
|
+
{
|
|
565
|
+
errorType: "BigInt-like",
|
|
566
|
+
example: 123n,
|
|
567
|
+
title: "BigInt"
|
|
568
|
+
}
|
|
569
|
+
)
|
|
570
|
+
).Decode((value) => {
|
|
571
|
+
if (typeof value !== "bigint") {
|
|
572
|
+
try {
|
|
573
|
+
if (value instanceof Date) {
|
|
574
|
+
return BigInt(value.getTime());
|
|
575
|
+
}
|
|
576
|
+
return BigInt(value);
|
|
577
|
+
} catch {
|
|
578
|
+
throw new Error("Invalid bigint");
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
return value;
|
|
582
|
+
}).Encode(BigInt);
|
|
583
|
+
boolean = Type.Transform(
|
|
584
|
+
Type.Union(
|
|
585
|
+
[
|
|
586
|
+
Type.Boolean(),
|
|
587
|
+
Type.String({
|
|
588
|
+
pattern: "^(t|T)(r|R)(u|U)(e|E)$|^(f|F)(a|A)(l|L)(s|S)(e|E)$"
|
|
589
|
+
})
|
|
590
|
+
],
|
|
591
|
+
{
|
|
592
|
+
errorType: "boolean-like",
|
|
593
|
+
example: true,
|
|
594
|
+
title: "Boolean"
|
|
595
|
+
}
|
|
596
|
+
)
|
|
597
|
+
).Decode((value) => {
|
|
598
|
+
if (typeof value === "string") {
|
|
599
|
+
if (value.toLowerCase() === "true") return true;
|
|
600
|
+
return false;
|
|
601
|
+
} else {
|
|
602
|
+
return value;
|
|
603
|
+
}
|
|
604
|
+
}).Encode(Boolean);
|
|
605
|
+
date = Type.Transform(
|
|
606
|
+
Type.Union(
|
|
607
|
+
[
|
|
608
|
+
Type.String({
|
|
609
|
+
pattern: "^\\d{4}(-\\d{2}){0,2}(T\\d{2}:\\d{2}(:\\d{2}(\\.\\d{1,3})?)?(Z|([+-]\\d{2}:\\d{2}))?)?$|^\\d{1,2}\\/\\d{1,2}\\/\\d{4}$|^\\d{4}\\/\\d{1,2}\\/\\d{1,2}$|^\\d+$"
|
|
610
|
+
}),
|
|
611
|
+
Type.Number(),
|
|
612
|
+
Type.Date()
|
|
613
|
+
],
|
|
614
|
+
{
|
|
615
|
+
errorType: "date",
|
|
616
|
+
example: "2025-05-16T21:13:04.123Z",
|
|
617
|
+
title: "Date"
|
|
618
|
+
}
|
|
619
|
+
)
|
|
620
|
+
).Decode((value) => {
|
|
621
|
+
if (value === null || typeof value === "boolean") {
|
|
622
|
+
return /* @__PURE__ */ new Date(value ? 1 : 0);
|
|
623
|
+
}
|
|
624
|
+
return new Date(value);
|
|
625
|
+
}).Encode((value) => new Date(value).toISOString());
|
|
626
|
+
symbol = Type.Symbol({
|
|
627
|
+
title: "Symbol"
|
|
628
|
+
});
|
|
629
|
+
nullish = Type.Union(
|
|
630
|
+
[Type.Void(), Type.Null(), Type.Undefined()],
|
|
631
|
+
{
|
|
632
|
+
errorType: "nullish",
|
|
633
|
+
type: "null",
|
|
634
|
+
example: "null",
|
|
635
|
+
title: "Nullish"
|
|
636
|
+
}
|
|
637
|
+
);
|
|
638
|
+
void = Type.Void({
|
|
639
|
+
type: "null",
|
|
640
|
+
example: "void",
|
|
641
|
+
title: "Void"
|
|
642
|
+
});
|
|
643
|
+
null = Type.Null({
|
|
644
|
+
type: "null",
|
|
645
|
+
example: "null",
|
|
646
|
+
title: "Null"
|
|
647
|
+
});
|
|
648
|
+
undefined = Type.Undefined({
|
|
649
|
+
type: "null",
|
|
650
|
+
example: "undefined",
|
|
651
|
+
title: "Undefined"
|
|
652
|
+
});
|
|
653
|
+
any = Type.Any({
|
|
654
|
+
type: "object",
|
|
655
|
+
example: "any",
|
|
656
|
+
title: "Any"
|
|
657
|
+
});
|
|
658
|
+
unknown = Type.Unknown({
|
|
659
|
+
type: "object",
|
|
660
|
+
example: "unknown",
|
|
661
|
+
title: "Unknown"
|
|
662
|
+
});
|
|
663
|
+
never = Type.Never({
|
|
664
|
+
type: "null",
|
|
665
|
+
example: "never",
|
|
666
|
+
title: "Never"
|
|
667
|
+
});
|
|
668
|
+
binary = Type.Transform(
|
|
669
|
+
Type.String({
|
|
670
|
+
errorType: "binary",
|
|
671
|
+
format: "binary",
|
|
672
|
+
example: "a utf-8 encodable string",
|
|
673
|
+
title: "Binary"
|
|
674
|
+
})
|
|
675
|
+
).Decode((value) => new TextEncoder().encode(value)).Encode((value) => {
|
|
676
|
+
if (value instanceof ArrayBuffer) {
|
|
677
|
+
return String.fromCharCode(...new Uint8Array(value));
|
|
678
|
+
}
|
|
679
|
+
return "";
|
|
680
|
+
});
|
|
681
|
+
file = Type.Transform(
|
|
682
|
+
Type.String({
|
|
683
|
+
errorType: "binary",
|
|
684
|
+
format: "binary",
|
|
685
|
+
example: "a utf-8 encodable string",
|
|
686
|
+
title: "File"
|
|
687
|
+
})
|
|
688
|
+
).Decode(
|
|
689
|
+
(value) => (name, type22) => new InMemoryFile(value, name, { type: type22 })
|
|
690
|
+
).Encode((value) => value("name", "type").content);
|
|
691
|
+
type = () => this.any;
|
|
692
|
+
/**
|
|
693
|
+
* Extracts the error type of a schema for error messages.
|
|
694
|
+
*
|
|
695
|
+
* @param {TCatchall} schema - A schema that contains some type information.
|
|
696
|
+
* @returns The type of the schema for error messages.
|
|
697
|
+
*/
|
|
698
|
+
errorType(schema) {
|
|
699
|
+
if (KindGuard.IsSchema(schema) && Object.hasOwn(schema, "errorType")) {
|
|
700
|
+
return schema.errorType;
|
|
701
|
+
} else if (KindGuard.IsLiteral(schema)) {
|
|
702
|
+
return schema.const;
|
|
703
|
+
}
|
|
704
|
+
return schema[Kind].toLowerCase();
|
|
705
|
+
}
|
|
706
|
+
/**
|
|
707
|
+
* Compiles schema if this exists, for optimal performance.
|
|
708
|
+
*
|
|
709
|
+
* @param {TObject<TProperties>} schema - The schema to compile.
|
|
710
|
+
* @returns {TypeCheck<T>} - The compiled schema.
|
|
711
|
+
*/
|
|
712
|
+
compile(schema) {
|
|
713
|
+
return TypeCompiler.Compile(schema);
|
|
714
|
+
}
|
|
715
|
+
/**
|
|
716
|
+
* Convert a schema to a TypeBox schema.
|
|
717
|
+
* @param {TIdiomaticSchema} schema - The schema to convert.
|
|
718
|
+
* @returns {TResolve<T>} The resolved schema.
|
|
719
|
+
*/
|
|
720
|
+
schemify(schema) {
|
|
721
|
+
if (KindGuard.IsSchema(schema) || schema instanceof TypeCheck) {
|
|
722
|
+
return schema;
|
|
723
|
+
}
|
|
724
|
+
if (typeof schema === "string" || typeof schema === "number" || typeof schema === "boolean") {
|
|
725
|
+
return Type.Literal(schema);
|
|
726
|
+
}
|
|
727
|
+
const newSchema = {};
|
|
728
|
+
Object.getOwnPropertyNames(schema).forEach((key) => {
|
|
729
|
+
if (KindGuard.IsSchema(schema[key])) {
|
|
730
|
+
newSchema[key] = schema[key];
|
|
731
|
+
} else {
|
|
732
|
+
const schemified = this.schemify(schema[key]);
|
|
733
|
+
newSchema[key] = schemified;
|
|
734
|
+
}
|
|
735
|
+
});
|
|
736
|
+
return Type.Object(newSchema);
|
|
737
|
+
}
|
|
738
|
+
/**
|
|
739
|
+
* Make a schema optional.
|
|
740
|
+
* @param {TIdiomaticSchema} schema - The schema to make optional.
|
|
741
|
+
* @returns {TOptional<TResolve<T>>} The optional schema.
|
|
742
|
+
*/
|
|
743
|
+
optional(schema) {
|
|
744
|
+
const schemified = this.schemify(schema);
|
|
745
|
+
return Type.Optional(schemified);
|
|
746
|
+
}
|
|
747
|
+
/**
|
|
748
|
+
* Create an array schema.
|
|
749
|
+
* @param {TIdiomaticSchema} schema - The schema to use for array items.
|
|
750
|
+
* @returns {TArray<TResolve<T>>} The array schema.
|
|
751
|
+
*/
|
|
752
|
+
array(schema) {
|
|
753
|
+
const schemified = this.schemify(schema);
|
|
754
|
+
return Type.Array(schemified, {
|
|
755
|
+
errorType: `array of ${this.errorType(schemified)}`
|
|
756
|
+
});
|
|
757
|
+
}
|
|
758
|
+
/**
|
|
759
|
+
* Create a union schema.
|
|
760
|
+
* @param {TUnionTupleContainer} schemas - The schemas to union.
|
|
761
|
+
* @returns {TUnion<UnionTupleTResolve<T>>} The union schema.
|
|
762
|
+
*
|
|
763
|
+
* WARNING: If "nullish" or TUndefined is included in the union, the key will still be expected.
|
|
764
|
+
* This is a limitation of TypeBox. Consider using "optional" instead.
|
|
765
|
+
*/
|
|
766
|
+
union(schemas) {
|
|
767
|
+
const unionTypes = schemas.map((schema) => {
|
|
768
|
+
return this.schemify(schema);
|
|
769
|
+
});
|
|
770
|
+
return Type.Union(unionTypes, {
|
|
771
|
+
errorType: `any of ${unionTypes.map((s) => this.errorType(s)).join(", ")}`,
|
|
772
|
+
errorSuffix: true
|
|
773
|
+
});
|
|
774
|
+
}
|
|
775
|
+
/**
|
|
776
|
+
* Create a literal schema.
|
|
777
|
+
* @param {LiteralSchema} value - The literal value.
|
|
778
|
+
* @returns {TLiteral<T>} The literal schema.
|
|
779
|
+
*/
|
|
780
|
+
literal(value) {
|
|
781
|
+
return Type.Literal(value, {
|
|
782
|
+
errorType: value
|
|
783
|
+
});
|
|
784
|
+
}
|
|
785
|
+
/**
|
|
786
|
+
* Create an enum schema.
|
|
787
|
+
* @param {Record<string, LiteralSchema>} schemaEnum - The enum schema.
|
|
788
|
+
* @returns {TUnion<UnionTupleTResolve<T[]>>} The enum schema.
|
|
789
|
+
*/
|
|
790
|
+
enum_(schemaEnum) {
|
|
791
|
+
return this.union(
|
|
792
|
+
Object.values(schemaEnum).map((value) => this.literal(value))
|
|
793
|
+
);
|
|
794
|
+
}
|
|
795
|
+
/**
|
|
796
|
+
* Create a function schema.
|
|
797
|
+
* @param {TSchema[]} args - The arguments of the function.
|
|
798
|
+
* @param {TAny} returnType - The return type of the function.
|
|
799
|
+
* @returns {TFunction<Args, ReturnType>} The function schema.
|
|
800
|
+
*/
|
|
801
|
+
function_(args, returnType) {
|
|
802
|
+
const schemaArgs = args.map((schema) => {
|
|
803
|
+
return this.schemify(schema);
|
|
804
|
+
});
|
|
805
|
+
const schemaReturnType = this.schemify(returnType);
|
|
806
|
+
return Type.Function(schemaArgs, schemaReturnType);
|
|
807
|
+
}
|
|
808
|
+
/**
|
|
809
|
+
* Create a record schema.
|
|
810
|
+
* @param {TIdiomaticSchema} key - The key schema.
|
|
811
|
+
* @param {TIdiomaticSchema} value - The value schema.
|
|
812
|
+
* @returns {TRecord<TResolve<Key>, TResolve<Value>>} The record schema.
|
|
813
|
+
*/
|
|
814
|
+
record(key, value) {
|
|
815
|
+
const keySchema = this.schemify(key);
|
|
816
|
+
const valueSchema = this.schemify(value);
|
|
817
|
+
return Type.Record(keySchema, valueSchema);
|
|
818
|
+
}
|
|
819
|
+
/**
|
|
820
|
+
* Create a promise schema.
|
|
821
|
+
* @param {TIdiomaticSchema} schema - The schema to use for the promise.
|
|
822
|
+
* @returns {TPromise<TResolve<T>>} The promise schema.
|
|
823
|
+
*/
|
|
824
|
+
promise(schema) {
|
|
825
|
+
return Type.Promise(this.schemify(schema));
|
|
826
|
+
}
|
|
827
|
+
/**
|
|
828
|
+
* Check if a value is a TypeBox object schema.
|
|
829
|
+
* @param {unknown} value - The value to check.
|
|
830
|
+
* @returns {boolean} True if the value is a TypeBox object schema.
|
|
831
|
+
*/
|
|
832
|
+
isSchema(value) {
|
|
833
|
+
return KindGuard.IsSchema(value);
|
|
834
|
+
}
|
|
835
|
+
/**
|
|
836
|
+
* Check if a value is an instance of a TypeBox schema.
|
|
837
|
+
* @param {object} value - The value to check.
|
|
838
|
+
* @param {TCatchall} type - The schema to check against.
|
|
839
|
+
* @returns {boolean} True if the value is an instance of the schema.
|
|
840
|
+
*/
|
|
841
|
+
isInstanceOf(value, type22) {
|
|
842
|
+
return typeof value === "object" && value != null && Kind in value && value[Kind] === type22[Kind];
|
|
843
|
+
}
|
|
844
|
+
/**
|
|
845
|
+
* Validate a value against a schema.
|
|
846
|
+
*
|
|
847
|
+
* @param {TSchema} schema - The schema to validate against.
|
|
848
|
+
* @param {unknown} value - The value to validate.
|
|
849
|
+
* @returns {boolean} True if valid, otherwise false.
|
|
850
|
+
*/
|
|
851
|
+
validate(schema, value) {
|
|
852
|
+
if (schema instanceof TypeCheck) {
|
|
853
|
+
return schema.Check(value);
|
|
854
|
+
} else {
|
|
855
|
+
const schemified = this.schemify(schema);
|
|
856
|
+
return Value.Check(schemified, value);
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
/**
|
|
860
|
+
* Parse a value against a schema.
|
|
861
|
+
*
|
|
862
|
+
* @param {TSchema} schema - The schema to validate against.
|
|
863
|
+
* @param {unknown} value - The value to validate.
|
|
864
|
+
* @returns {ParseResult<TResolve<T>>} The parsing result.
|
|
865
|
+
*/
|
|
866
|
+
parse(schema, value) {
|
|
867
|
+
let errors = [];
|
|
868
|
+
let conversion;
|
|
869
|
+
if (schema instanceof TypeCheck) {
|
|
870
|
+
if (schema.Check(value)) {
|
|
871
|
+
conversion = schema.Decode(value);
|
|
872
|
+
} else {
|
|
873
|
+
errors = Array.from(schema.Errors(value));
|
|
874
|
+
}
|
|
875
|
+
} else {
|
|
876
|
+
const schemified = this.schemify(schema);
|
|
877
|
+
if (Value.Check(schemified, value)) {
|
|
878
|
+
conversion = Value.Decode(schemified, value);
|
|
879
|
+
} else {
|
|
880
|
+
errors = Array.from(Value.Errors(schemified, value));
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
return errors != null && errors.length === 0 ? {
|
|
884
|
+
ok: true,
|
|
885
|
+
value: conversion
|
|
886
|
+
} : {
|
|
887
|
+
ok: false,
|
|
888
|
+
errors: errors.flatMap((error) => {
|
|
889
|
+
if (error.type === ValueErrorType.Union && error.schema.errorType.includes("any of")) {
|
|
890
|
+
return error.errors.flatMap(
|
|
891
|
+
(e, idx) => Array.from(e).map((e2) => ({
|
|
892
|
+
path: [
|
|
893
|
+
`Union Schema Variant ${idx}`,
|
|
894
|
+
...error.path.split("/").slice(1),
|
|
895
|
+
...e2.path.split("/").slice(1)
|
|
896
|
+
],
|
|
897
|
+
message: e2.message
|
|
898
|
+
}))
|
|
899
|
+
);
|
|
900
|
+
} else {
|
|
901
|
+
return [
|
|
902
|
+
{
|
|
903
|
+
path: error.path.split("/").slice(1),
|
|
904
|
+
message: error.message
|
|
905
|
+
}
|
|
906
|
+
];
|
|
907
|
+
}
|
|
908
|
+
})
|
|
909
|
+
};
|
|
910
|
+
}
|
|
911
|
+
/**
|
|
912
|
+
* Convert a schema to an OpenAPI schema object.
|
|
913
|
+
* @param {TIdiomaticSchema | TCatchall} schema - The schema to convert.
|
|
914
|
+
* @returns {SchemaObject} The OpenAPI schema object.
|
|
915
|
+
*/
|
|
916
|
+
openapi(schema) {
|
|
917
|
+
let schemified = this.schemify(schema);
|
|
918
|
+
if (KindGuard.IsDate(schemified)) {
|
|
919
|
+
schemified = Type.String({
|
|
920
|
+
format: "date-time"
|
|
921
|
+
});
|
|
922
|
+
}
|
|
923
|
+
const newSchema = Object.assign({}, schemified);
|
|
924
|
+
if (Object.hasOwn(newSchema, "properties")) {
|
|
925
|
+
if (newSchema.properties) {
|
|
926
|
+
Object.entries({ ...schemified.properties }).forEach(([key, value]) => {
|
|
927
|
+
if (KindGuard.IsSchema(value) && newSchema.properties) {
|
|
928
|
+
newSchema.properties[key] = this.openapi(value);
|
|
929
|
+
}
|
|
930
|
+
});
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
if (Object.hasOwn(newSchema, "items")) {
|
|
934
|
+
newSchema.items = this.openapi(newSchema.items);
|
|
935
|
+
}
|
|
936
|
+
if (Array.isArray(newSchema.anyOf)) {
|
|
937
|
+
newSchema.anyOf = newSchema.anyOf.map(
|
|
938
|
+
(item) => this.openapi(item)
|
|
939
|
+
);
|
|
940
|
+
}
|
|
941
|
+
if (Array.isArray(newSchema.oneOf)) {
|
|
942
|
+
newSchema.oneOf = newSchema.oneOf.map(
|
|
943
|
+
(item) => this.openapi(item)
|
|
944
|
+
);
|
|
945
|
+
}
|
|
946
|
+
if ("errorType" in newSchema) {
|
|
947
|
+
delete newSchema["errorType"];
|
|
948
|
+
}
|
|
949
|
+
return newSchema;
|
|
950
|
+
}
|
|
951
|
+
};
|
|
952
|
+
var SchemaValidator = () => new TypeboxSchemaValidator();
|
|
953
|
+
var StaticSchemaValidator = SchemaValidator();
|
|
954
|
+
var string = StaticSchemaValidator.string;
|
|
955
|
+
var uuid = StaticSchemaValidator.uuid;
|
|
956
|
+
var uri = StaticSchemaValidator.uri;
|
|
957
|
+
var email = StaticSchemaValidator.email;
|
|
958
|
+
var number = StaticSchemaValidator.number;
|
|
959
|
+
var bigint = StaticSchemaValidator.bigint;
|
|
960
|
+
var boolean = StaticSchemaValidator.boolean;
|
|
961
|
+
var date = StaticSchemaValidator.date;
|
|
962
|
+
var symbol = StaticSchemaValidator.symbol;
|
|
963
|
+
var nullish = StaticSchemaValidator.nullish;
|
|
964
|
+
var void_ = StaticSchemaValidator.void;
|
|
965
|
+
var null_ = StaticSchemaValidator.null;
|
|
966
|
+
var undefined_ = StaticSchemaValidator.undefined;
|
|
967
|
+
var any = StaticSchemaValidator.any;
|
|
968
|
+
var unknown = StaticSchemaValidator.unknown;
|
|
969
|
+
var never = StaticSchemaValidator.never;
|
|
970
|
+
var binary = StaticSchemaValidator.binary;
|
|
971
|
+
var file = StaticSchemaValidator.file;
|
|
972
|
+
var type = StaticSchemaValidator.type;
|
|
973
|
+
var schemify = StaticSchemaValidator.schemify.bind(StaticSchemaValidator);
|
|
974
|
+
var optional = StaticSchemaValidator.optional.bind(StaticSchemaValidator);
|
|
975
|
+
var array = StaticSchemaValidator.array.bind(StaticSchemaValidator);
|
|
976
|
+
var union = StaticSchemaValidator.union.bind(StaticSchemaValidator);
|
|
977
|
+
var literal = StaticSchemaValidator.literal.bind(StaticSchemaValidator);
|
|
978
|
+
var enum_ = StaticSchemaValidator.enum_.bind(StaticSchemaValidator);
|
|
979
|
+
var function_ = StaticSchemaValidator.function_.bind(StaticSchemaValidator);
|
|
980
|
+
var record = StaticSchemaValidator.record.bind(StaticSchemaValidator);
|
|
981
|
+
var promise = StaticSchemaValidator.promise.bind(StaticSchemaValidator);
|
|
982
|
+
var isSchema = StaticSchemaValidator.isSchema.bind(StaticSchemaValidator);
|
|
983
|
+
var validate = StaticSchemaValidator.validate.bind(StaticSchemaValidator);
|
|
984
|
+
var parse = StaticSchemaValidator.parse.bind(StaticSchemaValidator);
|
|
985
|
+
var openapi = StaticSchemaValidator.openapi.bind(StaticSchemaValidator);
|
|
986
|
+
|
|
987
|
+
// schemas/typebox/kafkaWorker.schema.ts
|
|
988
|
+
var KafkaWorkerOptionsSchema = {
|
|
989
|
+
brokers: array(string),
|
|
990
|
+
clientId: string,
|
|
991
|
+
groupId: string,
|
|
992
|
+
retries: number,
|
|
993
|
+
interval: number,
|
|
994
|
+
peekCount: number
|
|
995
|
+
};
|
|
996
|
+
|
|
997
|
+
// ../../../node_modules/.pnpm/@forklaunch+validator@0.6.12_openapi3-ts@4.4.0/node_modules/@forklaunch/validator/lib/src/zod/index.mjs
|
|
998
|
+
var import_zod_openapi = __toESM(require_src(), 1);
|
|
999
|
+
import {
|
|
1000
|
+
z,
|
|
1001
|
+
ZodType
|
|
1002
|
+
} from "zod";
|
|
1003
|
+
(0, import_zod_openapi.extendZodWithOpenApi)(z);
|
|
1004
|
+
var ZodSchemaValidator = class {
|
|
1005
|
+
_Type = "Zod";
|
|
1006
|
+
_SchemaCatchall;
|
|
1007
|
+
_ValidSchemaObject;
|
|
1008
|
+
string = z.string().openapi({
|
|
1009
|
+
title: "String",
|
|
1010
|
+
example: "a string"
|
|
1011
|
+
});
|
|
1012
|
+
uuid = z.string().uuid().openapi({
|
|
1013
|
+
title: "UUID",
|
|
1014
|
+
format: "uuid",
|
|
1015
|
+
pattern: "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$",
|
|
1016
|
+
example: "a8b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6"
|
|
1017
|
+
});
|
|
1018
|
+
email = z.string().email().openapi({
|
|
1019
|
+
title: "Email",
|
|
1020
|
+
format: "email",
|
|
1021
|
+
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])+)])`,
|
|
1022
|
+
example: "a@b.com"
|
|
1023
|
+
});
|
|
1024
|
+
uri = z.string().url().openapi({
|
|
1025
|
+
title: "URI",
|
|
1026
|
+
format: "uri",
|
|
1027
|
+
pattern: "^[a-zA-Z][a-zA-Z\\d+-.]*:[^\\s]*$",
|
|
1028
|
+
example: "https://forklaunch.com"
|
|
1029
|
+
});
|
|
1030
|
+
number = z.preprocess((value) => {
|
|
1031
|
+
try {
|
|
1032
|
+
return Number(value);
|
|
1033
|
+
} catch {
|
|
1034
|
+
return value;
|
|
1035
|
+
}
|
|
1036
|
+
}, z.number()).openapi({
|
|
1037
|
+
title: "Number",
|
|
1038
|
+
example: 123
|
|
1039
|
+
});
|
|
1040
|
+
bigint = z.preprocess((value) => {
|
|
1041
|
+
try {
|
|
1042
|
+
if (value instanceof Date) {
|
|
1043
|
+
return BigInt(value.getTime());
|
|
1044
|
+
}
|
|
1045
|
+
switch (typeof value) {
|
|
1046
|
+
case "number":
|
|
1047
|
+
case "string":
|
|
1048
|
+
return BigInt(value);
|
|
1049
|
+
case "boolean":
|
|
1050
|
+
return BigInt(value ? 1 : 0);
|
|
1051
|
+
default:
|
|
1052
|
+
return value;
|
|
1053
|
+
}
|
|
1054
|
+
} catch {
|
|
1055
|
+
return value;
|
|
1056
|
+
}
|
|
1057
|
+
}, z.bigint()).openapi({
|
|
1058
|
+
title: "BigInt",
|
|
1059
|
+
type: "integer",
|
|
1060
|
+
format: "int64",
|
|
1061
|
+
example: 123n
|
|
1062
|
+
});
|
|
1063
|
+
boolean = z.preprocess((val) => {
|
|
1064
|
+
if (typeof val === "string") {
|
|
1065
|
+
if (val.toLowerCase() === "true") return true;
|
|
1066
|
+
if (val.toLowerCase() === "false") return false;
|
|
1067
|
+
}
|
|
1068
|
+
return val;
|
|
1069
|
+
}, z.boolean()).openapi({
|
|
1070
|
+
title: "Boolean",
|
|
1071
|
+
example: true
|
|
1072
|
+
});
|
|
1073
|
+
date = z.preprocess((value) => {
|
|
1074
|
+
try {
|
|
1075
|
+
switch (typeof value) {
|
|
1076
|
+
case "string":
|
|
1077
|
+
return new Date(value);
|
|
1078
|
+
case "number":
|
|
1079
|
+
return new Date(value);
|
|
1080
|
+
default:
|
|
1081
|
+
return value;
|
|
1082
|
+
}
|
|
1083
|
+
} catch {
|
|
1084
|
+
return value;
|
|
1085
|
+
}
|
|
1086
|
+
}, z.date()).openapi({
|
|
1087
|
+
title: "Date",
|
|
1088
|
+
type: "string",
|
|
1089
|
+
format: "date-time",
|
|
1090
|
+
example: "2025-05-16T21:13:04.123Z"
|
|
1091
|
+
});
|
|
1092
|
+
symbol = z.symbol().openapi({
|
|
1093
|
+
title: "Symbol",
|
|
1094
|
+
example: Symbol("symbol")
|
|
1095
|
+
});
|
|
1096
|
+
nullish = z.union([z.void(), z.null(), z.undefined()]).openapi({
|
|
1097
|
+
title: "Nullish",
|
|
1098
|
+
type: "null",
|
|
1099
|
+
example: null
|
|
1100
|
+
});
|
|
1101
|
+
void = z.void().openapi({
|
|
1102
|
+
title: "Void",
|
|
1103
|
+
type: "null",
|
|
1104
|
+
example: void 0
|
|
1105
|
+
});
|
|
1106
|
+
null = z.null().openapi({
|
|
1107
|
+
title: "Null",
|
|
1108
|
+
type: "null",
|
|
1109
|
+
example: null
|
|
1110
|
+
});
|
|
1111
|
+
undefined = z.undefined().openapi({
|
|
1112
|
+
title: "Undefined",
|
|
1113
|
+
type: "null",
|
|
1114
|
+
example: void 0
|
|
1115
|
+
});
|
|
1116
|
+
any = z.any().openapi({
|
|
1117
|
+
title: "Any",
|
|
1118
|
+
type: "object",
|
|
1119
|
+
example: "any"
|
|
1120
|
+
});
|
|
1121
|
+
unknown = z.unknown().openapi({
|
|
1122
|
+
title: "Unknown",
|
|
1123
|
+
type: "object",
|
|
1124
|
+
example: "unknown"
|
|
1125
|
+
});
|
|
1126
|
+
never = z.never().openapi({
|
|
1127
|
+
title: "Never",
|
|
1128
|
+
type: "null",
|
|
1129
|
+
example: "never"
|
|
1130
|
+
});
|
|
1131
|
+
binary = z.string().transform((v) => new TextEncoder().encode(v)).openapi({
|
|
1132
|
+
title: "Binary",
|
|
1133
|
+
type: "string",
|
|
1134
|
+
format: "binary",
|
|
1135
|
+
example: "a utf-8 encodable string"
|
|
1136
|
+
});
|
|
1137
|
+
file = z.string().transform((val) => {
|
|
1138
|
+
return (name, type22) => new File([val], name, {
|
|
1139
|
+
type: type22,
|
|
1140
|
+
lastModified: Date.now()
|
|
1141
|
+
});
|
|
1142
|
+
}).openapi({
|
|
1143
|
+
title: "File",
|
|
1144
|
+
type: "string",
|
|
1145
|
+
format: "binary",
|
|
1146
|
+
example: "a utf-8 encodable string"
|
|
1147
|
+
});
|
|
1148
|
+
type = () => this.any;
|
|
1149
|
+
/**
|
|
1150
|
+
* Compiles schema if this exists, for optimal performance.
|
|
1151
|
+
*
|
|
1152
|
+
* @param {ZodObject<ZodRawShape>} schema - The schema to compile.
|
|
1153
|
+
* @returns {ZodResolve<T>} - The compiled schema.
|
|
1154
|
+
*/
|
|
1155
|
+
compile(schema) {
|
|
1156
|
+
return schema;
|
|
1157
|
+
}
|
|
1158
|
+
/**
|
|
1159
|
+
* Convert a schema to a Zod schema.
|
|
1160
|
+
* @param {ZodIdiomaticSchema} schema - The schema to convert.
|
|
1161
|
+
* @returns {ZodResolve<T>} The resolved schema.
|
|
1162
|
+
*/
|
|
1163
|
+
schemify(schema) {
|
|
1164
|
+
if (typeof schema === "string" || typeof schema === "number" || typeof schema === "boolean") {
|
|
1165
|
+
return z.literal(schema);
|
|
1166
|
+
}
|
|
1167
|
+
if (schema instanceof ZodType) {
|
|
1168
|
+
return schema;
|
|
1169
|
+
}
|
|
1170
|
+
const newSchema = {};
|
|
1171
|
+
Object.getOwnPropertyNames(schema).forEach((key) => {
|
|
1172
|
+
if (schema[key] instanceof ZodType) {
|
|
1173
|
+
newSchema[key] = schema[key];
|
|
1174
|
+
} else {
|
|
1175
|
+
newSchema[key] = this.schemify(schema[key]);
|
|
1176
|
+
}
|
|
1177
|
+
});
|
|
1178
|
+
return z.object(newSchema);
|
|
1179
|
+
}
|
|
1180
|
+
/**
|
|
1181
|
+
* Make a schema optional.
|
|
1182
|
+
* @param {ZodIdiomaticSchema} schema - The schema to make optional.
|
|
1183
|
+
* @returns {ZodOptional<ZodResolve<T>>} The optional schema.
|
|
1184
|
+
*/
|
|
1185
|
+
optional(schema) {
|
|
1186
|
+
const resolvedSchema = this.schemify(schema);
|
|
1187
|
+
return resolvedSchema.optional();
|
|
1188
|
+
}
|
|
1189
|
+
/**
|
|
1190
|
+
* Create an array schema.
|
|
1191
|
+
* @param {ZodIdiomaticSchema} schema - The schema to use for array items.
|
|
1192
|
+
* @returns {ZodArray<ZodResolve<T>>} The array schema.
|
|
1193
|
+
*/
|
|
1194
|
+
array(schema) {
|
|
1195
|
+
const resolvedSchema = this.schemify(schema);
|
|
1196
|
+
return resolvedSchema.array();
|
|
1197
|
+
}
|
|
1198
|
+
/**
|
|
1199
|
+
* Create a union schema.
|
|
1200
|
+
* @param {ZodUnionContainer} schemas - The schemas to union.
|
|
1201
|
+
* @returns {ZodUnion<UnionZodResolve<T>>} The union schema.
|
|
1202
|
+
*/
|
|
1203
|
+
union(schemas) {
|
|
1204
|
+
const resolvedSchemas = schemas.map((schema) => this.schemify(schema));
|
|
1205
|
+
return z.union(
|
|
1206
|
+
resolvedSchemas
|
|
1207
|
+
);
|
|
1208
|
+
}
|
|
1209
|
+
/**
|
|
1210
|
+
* Create a literal schema.
|
|
1211
|
+
* @param {LiteralSchema} value - The literal value.
|
|
1212
|
+
* @returns {ZodLiteral<ZodResolve<T>>} The literal schema.
|
|
1213
|
+
*/
|
|
1214
|
+
literal(value) {
|
|
1215
|
+
return z.literal(value);
|
|
1216
|
+
}
|
|
1217
|
+
/**
|
|
1218
|
+
* Create an enum schema.
|
|
1219
|
+
* @param {Record<string, LiteralSchema>} schemaEnum - The enum schema.
|
|
1220
|
+
* @returns {ZodUnion<UnionZodResolve<[T, T, ...T[]]>>} The enum schema.
|
|
1221
|
+
*/
|
|
1222
|
+
enum_(schemaEnum) {
|
|
1223
|
+
return this.union(
|
|
1224
|
+
Object.values(schemaEnum)
|
|
1225
|
+
);
|
|
1226
|
+
}
|
|
1227
|
+
/**
|
|
1228
|
+
* Create a function schema.
|
|
1229
|
+
* @param {ZodTuple} args - The arguments of the function.
|
|
1230
|
+
* @param {ZodAny} returnType - The return type of the function.
|
|
1231
|
+
* @returns {ZodFunction<Args, ReturnType>} The function schema.
|
|
1232
|
+
*/
|
|
1233
|
+
function_(args, returnType) {
|
|
1234
|
+
const schemaArgs = args.map((schema) => this.schemify(schema));
|
|
1235
|
+
const schemaReturnType = this.schemify(returnType);
|
|
1236
|
+
return z.function(z.tuple(schemaArgs), schemaReturnType);
|
|
1237
|
+
}
|
|
1238
|
+
/**
|
|
1239
|
+
* Create a record schema.
|
|
1240
|
+
* @param {ZodIdiomaticSchema} key - The key schema.
|
|
1241
|
+
* @param {ZodIdiomaticSchema} value - The value schema.
|
|
1242
|
+
* @returns {ZodRecord<ZodResolve<Key>, ZodResolve<Value>>} The record schema.
|
|
1243
|
+
*/
|
|
1244
|
+
record(key, value) {
|
|
1245
|
+
const keySchema = this.schemify(key);
|
|
1246
|
+
const valueSchema = this.schemify(value);
|
|
1247
|
+
return z.record(keySchema, valueSchema);
|
|
1248
|
+
}
|
|
1249
|
+
/**
|
|
1250
|
+
* Create a promise schema.
|
|
1251
|
+
* @param {ZodIdiomaticSchema} schema - The schema to use for the promise.
|
|
1252
|
+
* @returns {ZodPromise<ZodResolve<T>>} The promise schema.
|
|
1253
|
+
*/
|
|
1254
|
+
promise(schema) {
|
|
1255
|
+
return z.promise(this.schemify(schema));
|
|
1256
|
+
}
|
|
1257
|
+
/**
|
|
1258
|
+
* Checks if a value is a Zod schema.
|
|
1259
|
+
* @param {unknown} value - The value to check.
|
|
1260
|
+
* @returns {boolean} True if the value is a Zod schema.
|
|
1261
|
+
*/
|
|
1262
|
+
isSchema(value) {
|
|
1263
|
+
return value instanceof ZodType;
|
|
1264
|
+
}
|
|
1265
|
+
/**
|
|
1266
|
+
* Checks if a value is an instance of a Zod schema.
|
|
1267
|
+
* @param {object} value - The value to check.
|
|
1268
|
+
* @param {ZodType} type - The schema to check against.
|
|
1269
|
+
* @returns {boolean} True if the value is an instance of the schema.
|
|
1270
|
+
*/
|
|
1271
|
+
isInstanceOf(value, type22) {
|
|
1272
|
+
return this.isSchema(value) && type22._def.typeName === value._def.typeName;
|
|
1273
|
+
}
|
|
1274
|
+
/**
|
|
1275
|
+
* Validate a value against a schema.
|
|
1276
|
+
* @param {ZodCatchall} schema - The schema to validate against.
|
|
1277
|
+
* @param {unknown} value - The value to validate.
|
|
1278
|
+
* @returns {boolean} True if valid, otherwise false.
|
|
1279
|
+
*/
|
|
1280
|
+
validate(schema, value) {
|
|
1281
|
+
const resolvedSchema = this.schemify(schema);
|
|
1282
|
+
return resolvedSchema.safeParse(value).success;
|
|
1283
|
+
}
|
|
1284
|
+
/**
|
|
1285
|
+
* Parses a value to a schema validation.
|
|
1286
|
+
*
|
|
1287
|
+
* @param {ZodCatchall} schema - The schema to validate against.
|
|
1288
|
+
* @param {unknown} value - The value to validate.
|
|
1289
|
+
* @returns {ParseResult} - The discrimintated parsed value if successful, the error if unsuccessful.
|
|
1290
|
+
*/
|
|
1291
|
+
parse(schema, value) {
|
|
1292
|
+
const resolvedSchema = this.schemify(schema);
|
|
1293
|
+
const result = resolvedSchema.safeParse(value);
|
|
1294
|
+
return result.success ? { ok: true, value: result.data } : {
|
|
1295
|
+
ok: false,
|
|
1296
|
+
errors: result.error.errors.flatMap((error) => {
|
|
1297
|
+
switch (error.code) {
|
|
1298
|
+
case "invalid_union":
|
|
1299
|
+
return error.unionErrors.flatMap(
|
|
1300
|
+
(unionError, idx) => unionError.errors.map((e) => ({
|
|
1301
|
+
path: [
|
|
1302
|
+
`Union Schema Variant ${idx}`,
|
|
1303
|
+
...error.path.map((p) => p.toString()),
|
|
1304
|
+
...e.path.map((p) => p.toString())
|
|
1305
|
+
],
|
|
1306
|
+
message: e.message
|
|
1307
|
+
}))
|
|
1308
|
+
);
|
|
1309
|
+
default:
|
|
1310
|
+
return [
|
|
1311
|
+
{
|
|
1312
|
+
path: error.path.map((p) => p.toString()),
|
|
1313
|
+
message: error.message
|
|
1314
|
+
}
|
|
1315
|
+
];
|
|
1316
|
+
}
|
|
1317
|
+
})
|
|
1318
|
+
};
|
|
1319
|
+
}
|
|
1320
|
+
/**
|
|
1321
|
+
* Convert a schema to an OpenAPI schema object.
|
|
1322
|
+
* @param {ZodIdiomaticSchema} schema - The schema to convert.
|
|
1323
|
+
* @returns {SchemaObject} The OpenAPI schema object.
|
|
1324
|
+
*/
|
|
1325
|
+
openapi(schema) {
|
|
1326
|
+
return (0, import_zod_openapi.generateSchema)(this.schemify(schema));
|
|
1327
|
+
}
|
|
1328
|
+
};
|
|
1329
|
+
var SchemaValidator2 = () => new ZodSchemaValidator();
|
|
1330
|
+
var StaticSchemaValidator2 = SchemaValidator2();
|
|
1331
|
+
var string2 = StaticSchemaValidator2.string;
|
|
1332
|
+
var uuid2 = StaticSchemaValidator2.uuid;
|
|
1333
|
+
var email2 = StaticSchemaValidator2.email;
|
|
1334
|
+
var uri2 = StaticSchemaValidator2.uri;
|
|
1335
|
+
var number2 = StaticSchemaValidator2.number;
|
|
1336
|
+
var bigint2 = StaticSchemaValidator2.bigint;
|
|
1337
|
+
var boolean2 = StaticSchemaValidator2.boolean;
|
|
1338
|
+
var date2 = StaticSchemaValidator2.date;
|
|
1339
|
+
var symbol2 = StaticSchemaValidator2.symbol;
|
|
1340
|
+
var nullish2 = StaticSchemaValidator2.nullish;
|
|
1341
|
+
var void_2 = StaticSchemaValidator2.void;
|
|
1342
|
+
var null_2 = StaticSchemaValidator2.null;
|
|
1343
|
+
var undefined_2 = StaticSchemaValidator2.undefined;
|
|
1344
|
+
var any2 = StaticSchemaValidator2.any;
|
|
1345
|
+
var unknown2 = StaticSchemaValidator2.unknown;
|
|
1346
|
+
var never2 = StaticSchemaValidator2.never;
|
|
1347
|
+
var binary2 = StaticSchemaValidator2.binary;
|
|
1348
|
+
var file2 = StaticSchemaValidator2.file;
|
|
1349
|
+
var type2 = StaticSchemaValidator2.type;
|
|
1350
|
+
var schemify2 = StaticSchemaValidator2.schemify.bind(StaticSchemaValidator2);
|
|
1351
|
+
var optional2 = StaticSchemaValidator2.optional.bind(StaticSchemaValidator2);
|
|
1352
|
+
var array2 = StaticSchemaValidator2.array.bind(StaticSchemaValidator2);
|
|
1353
|
+
var union2 = StaticSchemaValidator2.union.bind(StaticSchemaValidator2);
|
|
1354
|
+
var literal2 = StaticSchemaValidator2.literal.bind(StaticSchemaValidator2);
|
|
1355
|
+
var enum_2 = StaticSchemaValidator2.enum_.bind(StaticSchemaValidator2);
|
|
1356
|
+
var function_2 = StaticSchemaValidator2.function_.bind(StaticSchemaValidator2);
|
|
1357
|
+
var record2 = StaticSchemaValidator2.record.bind(StaticSchemaValidator2);
|
|
1358
|
+
var promise2 = StaticSchemaValidator2.promise.bind(StaticSchemaValidator2);
|
|
1359
|
+
var isSchema2 = StaticSchemaValidator2.isSchema.bind(StaticSchemaValidator2);
|
|
1360
|
+
var validate2 = StaticSchemaValidator2.validate.bind(StaticSchemaValidator2);
|
|
1361
|
+
var parse2 = StaticSchemaValidator2.parse.bind(StaticSchemaValidator2);
|
|
1362
|
+
var openapi2 = StaticSchemaValidator2.openapi.bind(StaticSchemaValidator2);
|
|
1363
|
+
|
|
1364
|
+
// schemas/zod/kafkaWorker.schema.ts
|
|
1365
|
+
var KafkaWorkerOptionsSchema2 = {
|
|
1366
|
+
brokers: array2(string2),
|
|
1367
|
+
clientId: string2,
|
|
1368
|
+
groupId: string2,
|
|
1369
|
+
retries: number2,
|
|
1370
|
+
interval: number2,
|
|
1371
|
+
peekCount: number2
|
|
1372
|
+
};
|
|
1373
|
+
|
|
1374
|
+
// schemas/kafka.schema.ts
|
|
1375
|
+
var KafkaWorkerSchemas = serviceSchemaResolver(
|
|
1376
|
+
() => KafkaWorkerOptionsSchema,
|
|
1377
|
+
() => KafkaWorkerOptionsSchema2
|
|
1378
|
+
);
|
|
1379
|
+
export {
|
|
1380
|
+
KafkaWorkerSchemas
|
|
1381
|
+
};
|