@web-ts-toolkit/access-router 0.2.0 → 0.4.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/advanced.js ADDED
@@ -0,0 +1,1025 @@
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 __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/advanced.ts
30
+ var advanced_exports = {};
31
+ __export(advanced_exports, {
32
+ CORE: () => CORE,
33
+ Codes: () => Codes,
34
+ CustomHeaders: () => CustomHeaders,
35
+ DATA_MIDDLEWARE: () => DATA_MIDDLEWARE,
36
+ FilterOperator: () => FilterOperator,
37
+ MIDDLEWARE: () => MIDDLEWARE,
38
+ PERMISSIONS: () => PERMISSIONS,
39
+ PERMISSION_KEYS: () => PERMISSION_KEYS,
40
+ StatusCodes: () => StatusCodes,
41
+ advancedCreateBodySchema: () => advancedCreateBodySchema,
42
+ advancedUpdateBodySchema: () => advancedUpdateBodySchema,
43
+ advancedUpsertBodySchema: () => advancedUpsertBodySchema,
44
+ countBodySchema: () => countBodySchema,
45
+ createBodySchema: () => createBodySchema,
46
+ createQuerySchema: () => createQuerySchema,
47
+ dataListBodySchema: () => dataListBodySchema,
48
+ dataReadByIdBodySchema: () => dataReadByIdBodySchema,
49
+ dataReadFilterBodySchema: () => dataReadFilterBodySchema,
50
+ defineRequestSchema: () => defineRequestSchema,
51
+ distinctBodySchema: () => distinctBodySchema,
52
+ fromAjv: () => fromAjv,
53
+ fromArkType: () => fromArkType,
54
+ fromIoTs: () => fromIoTs,
55
+ fromJoi: () => fromJoi,
56
+ fromStandardSchema: () => fromStandardSchema,
57
+ fromSuperstruct: () => fromSuperstruct,
58
+ fromValibot: () => fromValibot,
59
+ fromVine: () => fromVine,
60
+ fromYup: () => fromYup,
61
+ fromZod: () => fromZod,
62
+ listBodySchema: () => listBodySchema,
63
+ listQuerySchema: () => listQuerySchema,
64
+ parseBody: () => parseBody,
65
+ parseBodyWithSchema: () => parseBodyWithSchema,
66
+ parseNestedBodyWithSchema: () => parseNestedBodyWithSchema,
67
+ parsePathParam: () => parsePathParam,
68
+ parseQuery: () => parseQuery,
69
+ readByIdBodySchema: () => readByIdBodySchema,
70
+ readFilterBodySchema: () => readFilterBodySchema,
71
+ readQuerySchema: () => readQuerySchema,
72
+ requestSchemas: () => requestSchemas,
73
+ rootQuerySchema: () => rootQuerySchema,
74
+ subListBodySchema: () => subListBodySchema,
75
+ subMutationBodySchema: () => subMutationBodySchema,
76
+ subReadBodySchema: () => subReadBodySchema,
77
+ updateBodySchema: () => updateBodySchema,
78
+ updateQuerySchema: () => updateQuerySchema,
79
+ upsertBodySchema: () => upsertBodySchema,
80
+ upsertQuerySchema: () => upsertQuerySchema
81
+ });
82
+ module.exports = __toCommonJS(advanced_exports);
83
+
84
+ // src/symbols.ts
85
+ var MIDDLEWARE = /* @__PURE__ */ Symbol.for("@web-ts-toolkit/access-router/middleware");
86
+ var DATA_MIDDLEWARE = /* @__PURE__ */ Symbol.for("@web-ts-toolkit/access-router/data-middleware");
87
+ var CORE = /* @__PURE__ */ Symbol.for("@web-ts-toolkit/access-router/core");
88
+ var PERMISSIONS = /* @__PURE__ */ Symbol.for("@web-ts-toolkit/access-router/permissions");
89
+ var PERMISSION_KEYS = /* @__PURE__ */ Symbol.for("@web-ts-toolkit/access-router/permission-keys");
90
+
91
+ // src/enums.ts
92
+ var StatusCodes = /* @__PURE__ */ ((StatusCodes2) => {
93
+ StatusCodes2[StatusCodes2["OK"] = 200] = "OK";
94
+ StatusCodes2[StatusCodes2["Created"] = 201] = "Created";
95
+ StatusCodes2[StatusCodes2["BadRequest"] = 400] = "BadRequest";
96
+ StatusCodes2[StatusCodes2["Unauthorized"] = 401] = "Unauthorized";
97
+ StatusCodes2[StatusCodes2["Forbidden"] = 403] = "Forbidden";
98
+ StatusCodes2[StatusCodes2["NotFound"] = 404] = "NotFound";
99
+ StatusCodes2[StatusCodes2["UnprocessableContent"] = 422] = "UnprocessableContent";
100
+ return StatusCodes2;
101
+ })(StatusCodes || {});
102
+ var Codes = /* @__PURE__ */ ((Codes2) => {
103
+ Codes2["Success"] = "success";
104
+ Codes2["Created"] = "created";
105
+ Codes2["BadRequest"] = "bad_request";
106
+ Codes2["Unauthorized"] = "unauthorized";
107
+ Codes2["Forbidden"] = "forbidden";
108
+ Codes2["NotFound"] = "not_found";
109
+ return Codes2;
110
+ })(Codes || {});
111
+ var CustomHeaders = /* @__PURE__ */ ((CustomHeaders2) => {
112
+ CustomHeaders2["TotalCount"] = "wtt-total-count";
113
+ CustomHeaders2["ReturnedCount"] = "wtt-returned-count";
114
+ CustomHeaders2["Page"] = "wtt-page";
115
+ CustomHeaders2["PageSize"] = "wtt-page-size";
116
+ CustomHeaders2["TotalPages"] = "wtt-total-pages";
117
+ CustomHeaders2["HasNextPage"] = "wtt-has-next-page";
118
+ CustomHeaders2["HasPreviousPage"] = "wtt-has-previous-page";
119
+ return CustomHeaders2;
120
+ })(CustomHeaders || {});
121
+ var FilterOperator = /* @__PURE__ */ ((FilterOperator2) => {
122
+ FilterOperator2[FilterOperator2["SubQuery"] = 0] = "SubQuery";
123
+ FilterOperator2[FilterOperator2["Date"] = 1] = "Date";
124
+ return FilterOperator2;
125
+ })(FilterOperator || {});
126
+
127
+ // src/validation/parsers.ts
128
+ var import_express_json_router = __toESM(require("@web-ts-toolkit/express-json-router"));
129
+
130
+ // src/validation/common.ts
131
+ var import_zod = require("zod");
132
+ var stringOrStringArray = import_zod.z.union([import_zod.z.string(), import_zod.z.array(import_zod.z.string())]);
133
+ var queryBooleanString = import_zod.z.enum(["true", "false"]);
134
+ var positiveIntegerString = import_zod.z.string().regex(/^\d+$/, "Expected a non-negative integer");
135
+ var nonNegativeIntegerSchema = import_zod.z.number().int().min(0);
136
+ var unknownRecord = import_zod.z.record(import_zod.z.string(), import_zod.z.unknown());
137
+ var projectionObjectSchema = import_zod.z.record(import_zod.z.string(), import_zod.z.union([import_zod.z.literal(1), import_zod.z.literal(-1)]));
138
+ var projectionSchema = import_zod.z.union([import_zod.z.string(), import_zod.z.array(import_zod.z.string()), projectionObjectSchema]);
139
+ var sortOrderSchema = import_zod.z.union([
140
+ import_zod.z.literal(-1),
141
+ import_zod.z.literal(1),
142
+ import_zod.z.literal("asc"),
143
+ import_zod.z.literal("ascending"),
144
+ import_zod.z.literal("desc"),
145
+ import_zod.z.literal("descending")
146
+ ]);
147
+ var sortSchema = import_zod.z.union([
148
+ import_zod.z.string(),
149
+ import_zod.z.record(import_zod.z.string(), sortOrderSchema),
150
+ import_zod.z.array(import_zod.z.tuple([import_zod.z.string(), sortOrderSchema])),
151
+ import_zod.z.null()
152
+ ]);
153
+ var populateSchema = import_zod.z.union([
154
+ import_zod.z.string(),
155
+ import_zod.z.array(
156
+ import_zod.z.union([
157
+ import_zod.z.string(),
158
+ import_zod.z.object({
159
+ path: import_zod.z.string().min(1),
160
+ select: projectionSchema.optional(),
161
+ match: import_zod.z.unknown().optional(),
162
+ access: import_zod.z.enum(["list", "read"]).optional()
163
+ }).passthrough()
164
+ ])
165
+ ),
166
+ import_zod.z.object({
167
+ path: import_zod.z.string().min(1),
168
+ select: projectionSchema.optional(),
169
+ match: import_zod.z.unknown().optional(),
170
+ access: import_zod.z.enum(["list", "read"]).optional()
171
+ }).passthrough()
172
+ ]);
173
+ var subPopulateSchema = import_zod.z.union([
174
+ import_zod.z.string(),
175
+ import_zod.z.array(
176
+ import_zod.z.union([
177
+ import_zod.z.string(),
178
+ import_zod.z.object({
179
+ path: import_zod.z.string().min(1),
180
+ select: projectionSchema.optional()
181
+ }).passthrough()
182
+ ])
183
+ ),
184
+ import_zod.z.object({
185
+ path: import_zod.z.string().min(1),
186
+ select: projectionSchema.optional()
187
+ }).passthrough()
188
+ ]);
189
+ var includeItemSchema = import_zod.z.object({
190
+ model: import_zod.z.string().min(1),
191
+ op: import_zod.z.enum(["list", "read", "count"]),
192
+ path: import_zod.z.string().min(1),
193
+ filter: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).optional(),
194
+ localField: import_zod.z.string().min(1),
195
+ foreignField: import_zod.z.string().min(1),
196
+ args: import_zod.z.unknown().optional(),
197
+ options: import_zod.z.unknown().optional()
198
+ }).passthrough();
199
+ var includeSchema = import_zod.z.union([includeItemSchema, import_zod.z.array(includeItemSchema)]);
200
+ var fieldsSchema = import_zod.z.array(import_zod.z.string().min(1));
201
+ var taskSchema = import_zod.z.object({
202
+ type: import_zod.z.string().min(1),
203
+ args: import_zod.z.unknown(),
204
+ options: unknownRecord.optional()
205
+ });
206
+ var tasksSchema = import_zod.z.union([taskSchema, import_zod.z.array(taskSchema)]);
207
+ var objectOrArraySchema = import_zod.z.union([import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()), import_zod.z.array(import_zod.z.unknown())]);
208
+ function rejectKeys(body, ctx, keys) {
209
+ for (const key of keys) {
210
+ if (key in body) {
211
+ ctx.addIssue({
212
+ code: import_zod.z.ZodIssueCode.custom,
213
+ message: `Unsupported field: ${key}`,
214
+ path: [key]
215
+ });
216
+ }
217
+ }
218
+ }
219
+
220
+ // src/validation/parsers.ts
221
+ var clientErrors = import_express_json_router.default.clientErrors;
222
+ function parsePathParam(value, parameter) {
223
+ const result = stringOrStringArray.safeParse(value);
224
+ if (!result.success) {
225
+ throwValidationError(normalizeIssues(result.error.issues), parameter, "parameter");
226
+ }
227
+ const param = Array.isArray(result.data) ? result.data[0] : result.data;
228
+ if (!param) {
229
+ throw new clientErrors.BadRequestError("Bad Request", {
230
+ errors: [{ detail: "Required", parameter }]
231
+ });
232
+ }
233
+ return param;
234
+ }
235
+ function parseQuery(schema, value) {
236
+ const result = schema.safeParse(value);
237
+ if (!result.success) {
238
+ throwValidationError(normalizeIssues(result.error.issues), void 0, "parameter");
239
+ }
240
+ return result.data;
241
+ }
242
+ function parseBody(schema, value) {
243
+ const result = schema.safeParse(value ?? {});
244
+ if (!result.success) {
245
+ throwValidationError(normalizeIssues(result.error.issues), void 0, "pointer");
246
+ }
247
+ return result.data;
248
+ }
249
+ function parseBodyWithSchema(schema, value, userSchema) {
250
+ const body = parseBody(schema, value);
251
+ return isRequestSchema(userSchema) ? parseUserSchema(userSchema, body) : Promise.resolve(body);
252
+ }
253
+ async function parseNestedBodyWithSchema(schema, value, nestedKey, userSchema) {
254
+ const body = parseBody(schema, value);
255
+ if (!isRequestSchema(userSchema)) return body;
256
+ return {
257
+ ...body,
258
+ [nestedKey]: await parseUserSchema(userSchema, body?.[nestedKey], [nestedKey])
259
+ };
260
+ }
261
+ function throwValidationError(issues, key, location = "pointer") {
262
+ const errors = issues.map((issue) => formatIssue(issue, key, location));
263
+ throw new clientErrors.BadRequestError("Bad Request", { errors });
264
+ }
265
+ async function parseUserSchema(schema, value, prefix = []) {
266
+ const validator = toRequestSchemaValidator(schema);
267
+ const result = await validator(value);
268
+ if (!isRequestSchemaFailure(result)) {
269
+ return result.data;
270
+ }
271
+ const issues = result.issues.map((issue) => ({
272
+ ...issue,
273
+ path: prefix.concat((issue.path ?? []).map(String))
274
+ }));
275
+ throwValidationError(issues, void 0, "pointer");
276
+ }
277
+ function isZodSchema(schema) {
278
+ return typeof schema === "object" && schema !== null && "safeParse" in schema && typeof schema.safeParse === "function";
279
+ }
280
+ function isRequestSchema(schema) {
281
+ return isZodSchema(schema) || isStandardSchema(schema) || isRequestSchemaValidator(schema) || isRequestSchemaAdapter(schema);
282
+ }
283
+ function isRequestSchemaValidator(schema) {
284
+ return typeof schema === "function";
285
+ }
286
+ function isRequestSchemaAdapter(schema) {
287
+ return typeof schema === "object" && schema !== null && "validate" in schema && typeof schema.validate === "function";
288
+ }
289
+ function isStandardSchema(schema) {
290
+ return typeof schema === "object" && schema !== null && "~standard" in schema && typeof schema["~standard"] === "object" && schema["~standard"] !== null && "validate" in schema["~standard"] && typeof schema["~standard"].validate === "function";
291
+ }
292
+ function isRequestSchemaFailure(result) {
293
+ return result.success === false;
294
+ }
295
+ function toRequestSchemaValidator(schema) {
296
+ if (isZodSchema(schema)) return fromZod(schema);
297
+ if (isStandardSchema(schema)) return fromStandardSchema(schema);
298
+ if (isRequestSchemaValidator(schema)) return schema;
299
+ return schema.validate;
300
+ }
301
+ function defineRequestSchema(validator) {
302
+ return validator;
303
+ }
304
+ function fromZod(schema) {
305
+ return (value) => {
306
+ const result = schema.safeParse(value);
307
+ if (result.success) {
308
+ return {
309
+ success: true,
310
+ data: result.data
311
+ };
312
+ }
313
+ return {
314
+ success: false,
315
+ issues: normalizeIssues(result.error.issues)
316
+ };
317
+ };
318
+ }
319
+ function fromStandardSchema(schema) {
320
+ return async (value) => {
321
+ const result = await schema["~standard"].validate(value);
322
+ if (!isStandardSchemaFailure(result)) {
323
+ return {
324
+ success: true,
325
+ data: result.value
326
+ };
327
+ }
328
+ return {
329
+ success: false,
330
+ issues: normalizeIssues(result.issues)
331
+ };
332
+ };
333
+ }
334
+ function fromYup(schema) {
335
+ return async (value) => {
336
+ try {
337
+ const data = await schema.validate(value, { abortEarly: false });
338
+ return {
339
+ success: true,
340
+ data
341
+ };
342
+ } catch (error) {
343
+ return {
344
+ success: false,
345
+ issues: normalizeYupIssues(error)
346
+ };
347
+ }
348
+ };
349
+ }
350
+ function fromJoi(schema) {
351
+ return async (value) => {
352
+ const result = await schema.validate(value, { abortEarly: false });
353
+ if (!result.error?.details?.length) {
354
+ return {
355
+ success: true,
356
+ data: result.value
357
+ };
358
+ }
359
+ return {
360
+ success: false,
361
+ issues: normalizeJoiIssues(result.error.details)
362
+ };
363
+ };
364
+ }
365
+ function fromAjv(validator) {
366
+ return async (value) => {
367
+ const valid = await validator(value);
368
+ if (valid) {
369
+ return {
370
+ success: true,
371
+ data: value
372
+ };
373
+ }
374
+ return {
375
+ success: false,
376
+ issues: normalizeAjvIssues(validator.errors ?? [])
377
+ };
378
+ };
379
+ }
380
+ function fromValibot(schema, safeParse) {
381
+ return async (value) => {
382
+ const result = await safeParse(schema, value, { abortEarly: false });
383
+ if (result.success) {
384
+ return {
385
+ success: true,
386
+ data: result.output
387
+ };
388
+ }
389
+ return {
390
+ success: false,
391
+ issues: normalizeValibotIssues(result.issues)
392
+ };
393
+ };
394
+ }
395
+ function fromArkType(type) {
396
+ return async (value) => {
397
+ const result = await type(value);
398
+ if (!isArkTypeErrors(result)) {
399
+ return {
400
+ success: true,
401
+ data: result
402
+ };
403
+ }
404
+ return {
405
+ success: false,
406
+ issues: normalizeArkTypeIssues(result)
407
+ };
408
+ };
409
+ }
410
+ function fromIoTs(decoder) {
411
+ return async (value) => {
412
+ const result = decoder.decode(value);
413
+ if (result._tag === "Right") {
414
+ return {
415
+ success: true,
416
+ data: result.right
417
+ };
418
+ }
419
+ return {
420
+ success: false,
421
+ issues: normalizeIoTsIssues(result.left)
422
+ };
423
+ };
424
+ }
425
+ function fromSuperstruct(struct, validate) {
426
+ return async (value) => {
427
+ const [failure, output] = await validate(value, struct);
428
+ if (!failure) {
429
+ return {
430
+ success: true,
431
+ data: output
432
+ };
433
+ }
434
+ return {
435
+ success: false,
436
+ issues: normalizeSuperstructFailure(failure)
437
+ };
438
+ };
439
+ }
440
+ function fromVine(validator) {
441
+ return async (value) => {
442
+ try {
443
+ const output = await validator.validate(value);
444
+ return {
445
+ success: true,
446
+ data: output
447
+ };
448
+ } catch (error) {
449
+ return {
450
+ success: false,
451
+ issues: normalizeVineError(error)
452
+ };
453
+ }
454
+ };
455
+ }
456
+ function isStandardSchemaFailure(result) {
457
+ return Array.isArray(result.issues);
458
+ }
459
+ function normalizeIssues(issues) {
460
+ return issues.map((issue) => ({
461
+ message: issue.message,
462
+ path: issue.path?.flatMap((segment) => normalizePathSegment(segment))
463
+ }));
464
+ }
465
+ function normalizePathSegment(segment) {
466
+ const key = isStandardSchemaPathSegment(segment) ? segment.key : segment;
467
+ return typeof key === "string" || typeof key === "number" ? [key] : [];
468
+ }
469
+ function isStandardSchemaPathSegment(segment) {
470
+ return typeof segment === "object" && segment !== null && "key" in segment;
471
+ }
472
+ function normalizeYupIssues(error) {
473
+ if (!isYupValidationError(error)) {
474
+ return [{ message: "Validation failed" }];
475
+ }
476
+ const issues = error.inner?.length ? error.inner : [error];
477
+ return issues.map((issue) => ({
478
+ message: issue.message,
479
+ path: parsePathString(issue.path)
480
+ }));
481
+ }
482
+ function normalizeJoiIssues(issues) {
483
+ return issues.map((issue) => ({
484
+ message: issue.message,
485
+ path: issue.path ? [...issue.path] : void 0
486
+ }));
487
+ }
488
+ function normalizeAjvIssues(issues) {
489
+ return issues.map((issue) => ({
490
+ message: issue.message ?? "Validation failed",
491
+ path: parseAjvPath(issue)
492
+ }));
493
+ }
494
+ function normalizeValibotIssues(issues) {
495
+ return issues.map((issue) => ({
496
+ message: issue.message,
497
+ path: issue.path?.flatMap(
498
+ (item) => typeof item.key === "string" || typeof item.key === "number" ? [item.key] : []
499
+ )
500
+ }));
501
+ }
502
+ function normalizeArkTypeIssues(issues) {
503
+ const normalized = issues.map((issue) => ({
504
+ message: issue.message ?? issue.problem ?? issues.summary ?? "Validation failed",
505
+ path: issue.path ? [...issue.path] : void 0
506
+ }));
507
+ return normalized.length ? normalized : [{ message: issues.summary ?? "Validation failed" }];
508
+ }
509
+ function normalizeIoTsIssues(issues) {
510
+ return issues.map((issue) => ({
511
+ message: issue.message ?? "Validation failed",
512
+ path: issue.context.map((entry) => entry.key).filter(Boolean)
513
+ }));
514
+ }
515
+ function normalizeSuperstructFailure(failure) {
516
+ const failures = failure.failures?.() ?? [failure];
517
+ return failures.map((entry) => ({
518
+ message: entry.message ?? "Validation failed",
519
+ path: normalizeSuperstructPath(entry)
520
+ }));
521
+ }
522
+ function normalizeSuperstructPath(failure) {
523
+ if (failure.path?.length) return [...failure.path];
524
+ if (typeof failure.key === "string" || typeof failure.key === "number") return [failure.key];
525
+ return void 0;
526
+ }
527
+ function normalizeVineError(error) {
528
+ if (!isVineValidationError(error)) {
529
+ return [{ message: "Validation failed" }];
530
+ }
531
+ return error.messages.map((message) => ({
532
+ message: message.message,
533
+ path: normalizeVineField(message)
534
+ }));
535
+ }
536
+ function normalizeVineField(message) {
537
+ const path = message.field.replace(/\[(\d+)\]/g, ".$1").split(".").filter(Boolean).map((segment) => /^\d+$/.test(segment) ? Number(segment) : segment);
538
+ if (typeof message.index === "number" && path.length === 0) {
539
+ return [message.index];
540
+ }
541
+ return path.length ? path : void 0;
542
+ }
543
+ function parseAjvPath(issue) {
544
+ const path = issue.instancePath?.split("/").filter(Boolean).map((segment) => /^\d+$/.test(segment) ? Number(segment) : segment);
545
+ if (issue.params?.missingProperty) {
546
+ return (path ?? []).concat(issue.params.missingProperty);
547
+ }
548
+ return path;
549
+ }
550
+ function parsePathString(path) {
551
+ if (!path) return void 0;
552
+ return path.replace(/\[(\d+)\]/g, ".$1").split(".").filter(Boolean).map((segment) => /^\d+$/.test(segment) ? Number(segment) : segment);
553
+ }
554
+ function isYupValidationError(error) {
555
+ return typeof error === "object" && error !== null && "message" in error;
556
+ }
557
+ function isArkTypeErrors(value) {
558
+ return Array.isArray(value);
559
+ }
560
+ function isVineValidationError(error) {
561
+ return typeof error === "object" && error !== null && "messages" in error && Array.isArray(error.messages);
562
+ }
563
+ function formatIssue(issue, key, location = "pointer") {
564
+ const path = (issue.path ?? []).map(String);
565
+ const joinedPath = path.join(".");
566
+ if (location === "parameter") {
567
+ return {
568
+ detail: issue.message,
569
+ parameter: (key ?? joinedPath) || void 0
570
+ };
571
+ }
572
+ return {
573
+ detail: issue.message,
574
+ pointer: buildPointer(path)
575
+ };
576
+ }
577
+ function buildPointer(path) {
578
+ return path.length === 0 ? "#" : `#/${path.join("/")}`;
579
+ }
580
+
581
+ // src/validation/model-router.ts
582
+ var import_zod2 = require("zod");
583
+ var listQuerySchema = import_zod2.z.object({
584
+ skip: positiveIntegerString.optional(),
585
+ limit: positiveIntegerString.optional(),
586
+ page: positiveIntegerString.optional(),
587
+ page_size: positiveIntegerString.optional(),
588
+ skim: queryBooleanString.optional(),
589
+ include_permissions: queryBooleanString.optional(),
590
+ include_count: queryBooleanString.optional(),
591
+ include_extra_headers: queryBooleanString.optional()
592
+ }).passthrough();
593
+ var createQuerySchema = import_zod2.z.object({
594
+ include_permissions: queryBooleanString.optional()
595
+ }).passthrough();
596
+ var readQuerySchema = import_zod2.z.object({
597
+ include_permissions: queryBooleanString.optional(),
598
+ try_list: queryBooleanString.optional()
599
+ }).passthrough();
600
+ var updateQuerySchema = import_zod2.z.object({
601
+ returning_all: queryBooleanString.optional(),
602
+ include_permissions: queryBooleanString.optional()
603
+ }).passthrough();
604
+ var upsertQuerySchema = import_zod2.z.object({
605
+ returning_all: queryBooleanString.optional(),
606
+ include_permissions: queryBooleanString.optional()
607
+ }).passthrough();
608
+ var listBodySchema = import_zod2.z.object({
609
+ filter: objectOrArraySchema.optional(),
610
+ select: projectionSchema.optional(),
611
+ sort: sortSchema.optional(),
612
+ populate: populateSchema.optional(),
613
+ include: includeSchema.optional(),
614
+ tasks: tasksSchema.optional(),
615
+ skip: import_zod2.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
616
+ limit: import_zod2.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
617
+ page: import_zod2.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
618
+ pageSize: import_zod2.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
619
+ options: import_zod2.z.object({
620
+ skim: import_zod2.z.boolean().optional(),
621
+ includePermissions: import_zod2.z.boolean().optional(),
622
+ includeCount: import_zod2.z.boolean().optional(),
623
+ includeExtraHeaders: import_zod2.z.boolean().optional(),
624
+ populateAccess: import_zod2.z.unknown().optional()
625
+ }).passthrough().optional()
626
+ }).passthrough().superRefine((body, ctx) => rejectKeys(body, ctx, ["query"]));
627
+ var countBodySchema = import_zod2.z.object({
628
+ filter: objectOrArraySchema.optional(),
629
+ options: import_zod2.z.object({
630
+ access: import_zod2.z.unknown().optional()
631
+ }).passthrough().optional()
632
+ }).passthrough().superRefine((body, ctx) => rejectKeys(body, ctx, ["query", "access"]));
633
+ var readFilterBodySchema = import_zod2.z.object({
634
+ filter: objectOrArraySchema.optional(),
635
+ select: projectionSchema.optional(),
636
+ sort: sortSchema.optional(),
637
+ populate: populateSchema.optional(),
638
+ include: includeSchema.optional(),
639
+ tasks: tasksSchema.optional(),
640
+ options: import_zod2.z.object({
641
+ skim: import_zod2.z.boolean().optional(),
642
+ includePermissions: import_zod2.z.boolean().optional(),
643
+ tryList: import_zod2.z.boolean().optional(),
644
+ populateAccess: import_zod2.z.unknown().optional()
645
+ }).passthrough().optional()
646
+ }).passthrough();
647
+ var readByIdBodySchema = import_zod2.z.object({
648
+ select: projectionSchema.optional(),
649
+ populate: populateSchema.optional(),
650
+ include: includeSchema.optional(),
651
+ tasks: tasksSchema.optional(),
652
+ options: import_zod2.z.object({
653
+ skim: import_zod2.z.boolean().optional(),
654
+ includePermissions: import_zod2.z.boolean().optional(),
655
+ tryList: import_zod2.z.boolean().optional(),
656
+ populateAccess: import_zod2.z.unknown().optional()
657
+ }).passthrough().optional()
658
+ }).passthrough();
659
+ var advancedCreateBodySchema = import_zod2.z.object({
660
+ data: import_zod2.z.unknown(),
661
+ select: projectionSchema.optional(),
662
+ populate: populateSchema.optional(),
663
+ tasks: tasksSchema.optional(),
664
+ options: import_zod2.z.object({
665
+ includePermissions: import_zod2.z.boolean().optional(),
666
+ populateAccess: import_zod2.z.unknown().optional()
667
+ }).passthrough().optional()
668
+ }).passthrough();
669
+ var createBodySchema = import_zod2.z.union([
670
+ import_zod2.z.record(import_zod2.z.string(), import_zod2.z.unknown()),
671
+ import_zod2.z.array(import_zod2.z.record(import_zod2.z.string(), import_zod2.z.unknown()))
672
+ ]);
673
+ var updateBodySchema = import_zod2.z.record(import_zod2.z.string(), import_zod2.z.unknown());
674
+ var advancedUpdateBodySchema = import_zod2.z.object({
675
+ data: import_zod2.z.unknown(),
676
+ select: projectionSchema.optional(),
677
+ populate: populateSchema.optional(),
678
+ tasks: tasksSchema.optional(),
679
+ options: import_zod2.z.object({
680
+ returningAll: import_zod2.z.boolean().optional(),
681
+ includePermissions: import_zod2.z.boolean().optional(),
682
+ populateAccess: import_zod2.z.unknown().optional()
683
+ }).passthrough().optional()
684
+ }).passthrough();
685
+ var upsertBodySchema = import_zod2.z.record(import_zod2.z.string(), import_zod2.z.unknown());
686
+ var advancedUpsertBodySchema = import_zod2.z.object({
687
+ data: import_zod2.z.record(import_zod2.z.string(), import_zod2.z.unknown()),
688
+ select: projectionSchema.optional(),
689
+ populate: populateSchema.optional(),
690
+ tasks: tasksSchema.optional(),
691
+ options: import_zod2.z.object({
692
+ returningAll: import_zod2.z.boolean().optional(),
693
+ includePermissions: import_zod2.z.boolean().optional(),
694
+ populateAccess: import_zod2.z.unknown().optional()
695
+ }).passthrough().optional()
696
+ }).passthrough();
697
+ var distinctBodySchema = import_zod2.z.object({
698
+ filter: objectOrArraySchema.optional()
699
+ }).passthrough().superRefine((body, ctx) => rejectKeys(body, ctx, ["query"]));
700
+ var subListBodySchema = import_zod2.z.object({
701
+ filter: import_zod2.z.record(import_zod2.z.string(), import_zod2.z.unknown()).optional(),
702
+ select: fieldsSchema.optional()
703
+ }).passthrough().superRefine((body, ctx) => rejectKeys(body, ctx, ["fields"]));
704
+ var subMutationBodySchema = import_zod2.z.union([
705
+ import_zod2.z.record(import_zod2.z.string(), import_zod2.z.unknown()),
706
+ import_zod2.z.array(import_zod2.z.record(import_zod2.z.string(), import_zod2.z.unknown()))
707
+ ]);
708
+ var subReadBodySchema = import_zod2.z.object({
709
+ select: fieldsSchema.optional(),
710
+ populate: subPopulateSchema.optional()
711
+ }).passthrough().superRefine((body, ctx) => rejectKeys(body, ctx, ["fields"]));
712
+ var requestSchemas = {
713
+ listQuery: listQuerySchema,
714
+ createQuery: createQuerySchema,
715
+ readQuery: readQuerySchema,
716
+ updateQuery: updateQuerySchema,
717
+ upsertQuery: upsertQuerySchema
718
+ };
719
+
720
+ // src/validation/data-router.ts
721
+ var import_zod3 = require("zod");
722
+ var dataListBodySchema = import_zod3.z.object({
723
+ filter: objectOrArraySchema.optional(),
724
+ select: projectionSchema.optional(),
725
+ sort: import_zod3.z.string().optional(),
726
+ skip: import_zod3.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
727
+ limit: import_zod3.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
728
+ page: import_zod3.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
729
+ pageSize: import_zod3.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
730
+ options: import_zod3.z.object({
731
+ includeCount: import_zod3.z.boolean().optional(),
732
+ includeExtraHeaders: import_zod3.z.boolean().optional()
733
+ }).passthrough().optional()
734
+ }).passthrough();
735
+ var dataReadFilterBodySchema = import_zod3.z.object({
736
+ filter: objectOrArraySchema.optional(),
737
+ select: projectionSchema.optional()
738
+ }).passthrough().superRefine((body, ctx) => rejectKeys(body, ctx, ["options"]));
739
+ var dataReadByIdBodySchema = import_zod3.z.object({
740
+ select: projectionSchema.optional()
741
+ }).passthrough().superRefine((body, ctx) => rejectKeys(body, ctx, ["options"]));
742
+
743
+ // src/validation/root-router.ts
744
+ var import_zod4 = require("zod");
745
+ var rootEntryBaseSchema = {
746
+ target: import_zod4.z.enum(["model", "data"]),
747
+ name: import_zod4.z.string().min(1),
748
+ order: import_zod4.z.number().int().optional()
749
+ };
750
+ var rootModelListArgsSchema = import_zod4.z.object({
751
+ select: projectionSchema.optional(),
752
+ populate: populateSchema.optional(),
753
+ include: includeSchema.optional(),
754
+ sort: sortSchema.optional(),
755
+ skip: import_zod4.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
756
+ limit: import_zod4.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
757
+ page: import_zod4.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
758
+ pageSize: import_zod4.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
759
+ tasks: tasksSchema.optional()
760
+ }).passthrough();
761
+ var rootModelListOptionsSchema = import_zod4.z.object({
762
+ skim: import_zod4.z.boolean().optional(),
763
+ includePermissions: import_zod4.z.boolean().optional(),
764
+ includeCount: import_zod4.z.boolean().optional(),
765
+ populateAccess: import_zod4.z.unknown().optional(),
766
+ lean: import_zod4.z.boolean().optional()
767
+ }).passthrough();
768
+ var rootModelReadArgsSchema = import_zod4.z.object({
769
+ select: projectionSchema.optional(),
770
+ populate: populateSchema.optional(),
771
+ include: includeSchema.optional(),
772
+ tasks: tasksSchema.optional()
773
+ }).passthrough();
774
+ var rootModelReadFilterArgsSchema = rootModelReadArgsSchema.extend({
775
+ sort: sortSchema.optional()
776
+ });
777
+ var rootModelReadOptionsSchema = import_zod4.z.object({
778
+ skim: import_zod4.z.boolean().optional(),
779
+ includePermissions: import_zod4.z.boolean().optional(),
780
+ tryList: import_zod4.z.boolean().optional(),
781
+ populateAccess: import_zod4.z.unknown().optional(),
782
+ lean: import_zod4.z.boolean().optional()
783
+ }).passthrough();
784
+ var rootModelCreateArgsSchema = import_zod4.z.object({
785
+ select: projectionSchema.optional(),
786
+ populate: populateSchema.optional(),
787
+ tasks: tasksSchema.optional()
788
+ }).passthrough();
789
+ var rootModelCreateOptionsSchema = import_zod4.z.object({
790
+ skim: import_zod4.z.boolean().optional(),
791
+ includePermissions: import_zod4.z.boolean().optional(),
792
+ populateAccess: import_zod4.z.unknown().optional()
793
+ }).passthrough();
794
+ var rootModelUpdateArgsSchema = import_zod4.z.object({
795
+ select: projectionSchema.optional(),
796
+ populate: populateSchema.optional(),
797
+ tasks: tasksSchema.optional()
798
+ }).passthrough();
799
+ var rootModelUpdateOptionsSchema = import_zod4.z.object({
800
+ skim: import_zod4.z.boolean().optional(),
801
+ returningAll: import_zod4.z.boolean().optional(),
802
+ includePermissions: import_zod4.z.boolean().optional(),
803
+ populateAccess: import_zod4.z.unknown().optional()
804
+ }).passthrough();
805
+ var rootModelUpsertArgsSchema = rootModelUpdateArgsSchema;
806
+ var rootModelUpsertOptionsSchema = rootModelUpdateOptionsSchema;
807
+ var rootModelSubListArgsSchema = import_zod4.z.object({
808
+ select: fieldsSchema.optional()
809
+ }).passthrough();
810
+ var rootModelSubReadArgsSchema = import_zod4.z.object({
811
+ select: fieldsSchema.optional(),
812
+ populate: subPopulateSchema.optional()
813
+ }).passthrough();
814
+ var rootModelCountOptionsSchema = import_zod4.z.object({
815
+ access: import_zod4.z.unknown().optional()
816
+ }).passthrough();
817
+ var rootDataListArgsSchema = import_zod4.z.object({
818
+ select: projectionSchema.optional(),
819
+ sort: import_zod4.z.string().optional(),
820
+ skip: import_zod4.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
821
+ limit: import_zod4.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
822
+ page: import_zod4.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
823
+ pageSize: import_zod4.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional()
824
+ }).passthrough();
825
+ var rootDataListOptionsSchema = import_zod4.z.object({
826
+ includeCount: import_zod4.z.boolean().optional()
827
+ }).passthrough();
828
+ var rootDataReadArgsSchema = import_zod4.z.object({
829
+ select: projectionSchema.optional()
830
+ }).passthrough();
831
+ var rootModelQueryEntrySchema = import_zod4.z.union([
832
+ import_zod4.z.object({ ...rootEntryBaseSchema, target: import_zod4.z.literal("model"), op: import_zod4.z.literal("new") }).passthrough(),
833
+ import_zod4.z.object({
834
+ ...rootEntryBaseSchema,
835
+ target: import_zod4.z.literal("model"),
836
+ op: import_zod4.z.literal("list"),
837
+ filter: objectOrArraySchema.optional(),
838
+ args: rootModelListArgsSchema.optional(),
839
+ options: rootModelListOptionsSchema.optional()
840
+ }).passthrough(),
841
+ import_zod4.z.object({
842
+ ...rootEntryBaseSchema,
843
+ target: import_zod4.z.literal("model"),
844
+ op: import_zod4.z.literal("read"),
845
+ id: import_zod4.z.string().min(1),
846
+ args: rootModelReadArgsSchema.optional(),
847
+ options: rootModelReadOptionsSchema.optional()
848
+ }).passthrough(),
849
+ import_zod4.z.object({
850
+ ...rootEntryBaseSchema,
851
+ target: import_zod4.z.literal("model"),
852
+ op: import_zod4.z.literal("read"),
853
+ filter: objectOrArraySchema,
854
+ args: rootModelReadFilterArgsSchema.optional(),
855
+ options: rootModelReadOptionsSchema.optional()
856
+ }).passthrough(),
857
+ import_zod4.z.object({
858
+ ...rootEntryBaseSchema,
859
+ target: import_zod4.z.literal("model"),
860
+ op: import_zod4.z.literal("create"),
861
+ data: import_zod4.z.unknown(),
862
+ args: rootModelCreateArgsSchema.optional(),
863
+ options: rootModelCreateOptionsSchema.optional()
864
+ }).passthrough(),
865
+ import_zod4.z.object({
866
+ ...rootEntryBaseSchema,
867
+ target: import_zod4.z.literal("model"),
868
+ op: import_zod4.z.literal("update"),
869
+ id: import_zod4.z.string().min(1),
870
+ data: import_zod4.z.unknown(),
871
+ args: rootModelUpdateArgsSchema.optional(),
872
+ options: rootModelUpdateOptionsSchema.optional()
873
+ }).passthrough(),
874
+ import_zod4.z.object({
875
+ ...rootEntryBaseSchema,
876
+ target: import_zod4.z.literal("model"),
877
+ op: import_zod4.z.literal("upsert"),
878
+ data: import_zod4.z.record(import_zod4.z.string(), import_zod4.z.unknown()),
879
+ args: rootModelUpsertArgsSchema.optional(),
880
+ options: rootModelUpsertOptionsSchema.optional()
881
+ }).passthrough(),
882
+ import_zod4.z.object({ ...rootEntryBaseSchema, target: import_zod4.z.literal("model"), op: import_zod4.z.literal("delete"), id: import_zod4.z.string().min(1) }).passthrough(),
883
+ import_zod4.z.object({
884
+ ...rootEntryBaseSchema,
885
+ target: import_zod4.z.literal("model"),
886
+ op: import_zod4.z.literal("subList"),
887
+ id: import_zod4.z.string().min(1),
888
+ sub: import_zod4.z.string().min(1),
889
+ filter: import_zod4.z.record(import_zod4.z.string(), import_zod4.z.unknown()).optional(),
890
+ args: rootModelSubListArgsSchema.optional()
891
+ }).passthrough(),
892
+ import_zod4.z.object({
893
+ ...rootEntryBaseSchema,
894
+ target: import_zod4.z.literal("model"),
895
+ op: import_zod4.z.literal("subRead"),
896
+ id: import_zod4.z.string().min(1),
897
+ sub: import_zod4.z.string().min(1),
898
+ subId: import_zod4.z.string().min(1),
899
+ args: rootModelSubReadArgsSchema.optional()
900
+ }).passthrough(),
901
+ import_zod4.z.object({
902
+ ...rootEntryBaseSchema,
903
+ target: import_zod4.z.literal("model"),
904
+ op: import_zod4.z.literal("subCreate"),
905
+ id: import_zod4.z.string().min(1),
906
+ sub: import_zod4.z.string().min(1),
907
+ data: import_zod4.z.union([import_zod4.z.record(import_zod4.z.string(), import_zod4.z.unknown()), import_zod4.z.array(import_zod4.z.record(import_zod4.z.string(), import_zod4.z.unknown()))])
908
+ }).passthrough(),
909
+ import_zod4.z.object({
910
+ ...rootEntryBaseSchema,
911
+ target: import_zod4.z.literal("model"),
912
+ op: import_zod4.z.literal("subUpdate"),
913
+ id: import_zod4.z.string().min(1),
914
+ sub: import_zod4.z.string().min(1),
915
+ subId: import_zod4.z.string().min(1),
916
+ data: import_zod4.z.union([import_zod4.z.record(import_zod4.z.string(), import_zod4.z.unknown()), import_zod4.z.array(import_zod4.z.record(import_zod4.z.string(), import_zod4.z.unknown()))])
917
+ }).passthrough(),
918
+ import_zod4.z.object({
919
+ ...rootEntryBaseSchema,
920
+ target: import_zod4.z.literal("model"),
921
+ op: import_zod4.z.literal("subBulkUpdate"),
922
+ id: import_zod4.z.string().min(1),
923
+ sub: import_zod4.z.string().min(1),
924
+ data: import_zod4.z.union([import_zod4.z.record(import_zod4.z.string(), import_zod4.z.unknown()), import_zod4.z.array(import_zod4.z.record(import_zod4.z.string(), import_zod4.z.unknown()))])
925
+ }).passthrough(),
926
+ import_zod4.z.object({
927
+ ...rootEntryBaseSchema,
928
+ target: import_zod4.z.literal("model"),
929
+ op: import_zod4.z.literal("subDelete"),
930
+ id: import_zod4.z.string().min(1),
931
+ sub: import_zod4.z.string().min(1),
932
+ subId: import_zod4.z.string().min(1)
933
+ }).passthrough(),
934
+ import_zod4.z.object({
935
+ ...rootEntryBaseSchema,
936
+ target: import_zod4.z.literal("model"),
937
+ op: import_zod4.z.literal("distinct"),
938
+ field: import_zod4.z.string().min(1),
939
+ filter: objectOrArraySchema.optional()
940
+ }).passthrough(),
941
+ import_zod4.z.object({
942
+ ...rootEntryBaseSchema,
943
+ target: import_zod4.z.literal("model"),
944
+ op: import_zod4.z.literal("count"),
945
+ filter: objectOrArraySchema.optional(),
946
+ options: rootModelCountOptionsSchema.optional()
947
+ }).passthrough()
948
+ ]);
949
+ var rootDataQueryEntrySchema = import_zod4.z.union([
950
+ import_zod4.z.object({
951
+ ...rootEntryBaseSchema,
952
+ target: import_zod4.z.literal("data"),
953
+ op: import_zod4.z.literal("list"),
954
+ filter: objectOrArraySchema.optional(),
955
+ args: rootDataListArgsSchema.optional(),
956
+ options: rootDataListOptionsSchema.optional()
957
+ }).passthrough(),
958
+ import_zod4.z.object({
959
+ ...rootEntryBaseSchema,
960
+ target: import_zod4.z.literal("data"),
961
+ op: import_zod4.z.literal("read"),
962
+ id: import_zod4.z.string().min(1),
963
+ args: rootDataReadArgsSchema.optional()
964
+ }).passthrough(),
965
+ import_zod4.z.object({
966
+ ...rootEntryBaseSchema,
967
+ target: import_zod4.z.literal("data"),
968
+ op: import_zod4.z.literal("read"),
969
+ filter: objectOrArraySchema,
970
+ args: rootDataReadArgsSchema.optional()
971
+ }).passthrough()
972
+ ]);
973
+ var rootQuerySchema = import_zod4.z.array(import_zod4.z.union([rootModelQueryEntrySchema, rootDataQueryEntrySchema]));
974
+ // Annotate the CommonJS export names for ESM import in node:
975
+ 0 && (module.exports = {
976
+ CORE,
977
+ Codes,
978
+ CustomHeaders,
979
+ DATA_MIDDLEWARE,
980
+ FilterOperator,
981
+ MIDDLEWARE,
982
+ PERMISSIONS,
983
+ PERMISSION_KEYS,
984
+ StatusCodes,
985
+ advancedCreateBodySchema,
986
+ advancedUpdateBodySchema,
987
+ advancedUpsertBodySchema,
988
+ countBodySchema,
989
+ createBodySchema,
990
+ createQuerySchema,
991
+ dataListBodySchema,
992
+ dataReadByIdBodySchema,
993
+ dataReadFilterBodySchema,
994
+ defineRequestSchema,
995
+ distinctBodySchema,
996
+ fromAjv,
997
+ fromArkType,
998
+ fromIoTs,
999
+ fromJoi,
1000
+ fromStandardSchema,
1001
+ fromSuperstruct,
1002
+ fromValibot,
1003
+ fromVine,
1004
+ fromYup,
1005
+ fromZod,
1006
+ listBodySchema,
1007
+ listQuerySchema,
1008
+ parseBody,
1009
+ parseBodyWithSchema,
1010
+ parseNestedBodyWithSchema,
1011
+ parsePathParam,
1012
+ parseQuery,
1013
+ readByIdBodySchema,
1014
+ readFilterBodySchema,
1015
+ readQuerySchema,
1016
+ requestSchemas,
1017
+ rootQuerySchema,
1018
+ subListBodySchema,
1019
+ subMutationBodySchema,
1020
+ subReadBodySchema,
1021
+ updateBodySchema,
1022
+ updateQuerySchema,
1023
+ upsertBodySchema,
1024
+ upsertQuerySchema
1025
+ });