@web-ts-toolkit/access-router 0.2.0 → 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/advanced.js ADDED
@@ -0,0 +1,719 @@
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
+ distinctBodySchema: () => distinctBodySchema,
51
+ listBodySchema: () => listBodySchema,
52
+ listQuerySchema: () => listQuerySchema,
53
+ parseBody: () => parseBody,
54
+ parseBodyWithSchema: () => parseBodyWithSchema,
55
+ parseNestedBodyWithSchema: () => parseNestedBodyWithSchema,
56
+ parsePathParam: () => parsePathParam,
57
+ parseQuery: () => parseQuery,
58
+ readByIdBodySchema: () => readByIdBodySchema,
59
+ readFilterBodySchema: () => readFilterBodySchema,
60
+ readQuerySchema: () => readQuerySchema,
61
+ requestSchemas: () => requestSchemas,
62
+ rootQuerySchema: () => rootQuerySchema,
63
+ subListBodySchema: () => subListBodySchema,
64
+ subMutationBodySchema: () => subMutationBodySchema,
65
+ subReadBodySchema: () => subReadBodySchema,
66
+ updateBodySchema: () => updateBodySchema,
67
+ updateQuerySchema: () => updateQuerySchema,
68
+ upsertBodySchema: () => upsertBodySchema,
69
+ upsertQuerySchema: () => upsertQuerySchema
70
+ });
71
+ module.exports = __toCommonJS(advanced_exports);
72
+
73
+ // src/symbols.ts
74
+ var MIDDLEWARE = /* @__PURE__ */ Symbol.for("@web-ts-toolkit/access-router/middleware");
75
+ var DATA_MIDDLEWARE = /* @__PURE__ */ Symbol.for("@web-ts-toolkit/access-router/data-middleware");
76
+ var CORE = /* @__PURE__ */ Symbol.for("@web-ts-toolkit/access-router/core");
77
+ var PERMISSIONS = /* @__PURE__ */ Symbol.for("@web-ts-toolkit/access-router/permissions");
78
+ var PERMISSION_KEYS = /* @__PURE__ */ Symbol.for("@web-ts-toolkit/access-router/permission-keys");
79
+
80
+ // src/enums.ts
81
+ var StatusCodes = /* @__PURE__ */ ((StatusCodes2) => {
82
+ StatusCodes2[StatusCodes2["OK"] = 200] = "OK";
83
+ StatusCodes2[StatusCodes2["Created"] = 201] = "Created";
84
+ StatusCodes2[StatusCodes2["BadRequest"] = 400] = "BadRequest";
85
+ StatusCodes2[StatusCodes2["Unauthorized"] = 401] = "Unauthorized";
86
+ StatusCodes2[StatusCodes2["Forbidden"] = 403] = "Forbidden";
87
+ StatusCodes2[StatusCodes2["NotFound"] = 404] = "NotFound";
88
+ StatusCodes2[StatusCodes2["UnprocessableContent"] = 422] = "UnprocessableContent";
89
+ return StatusCodes2;
90
+ })(StatusCodes || {});
91
+ var Codes = /* @__PURE__ */ ((Codes2) => {
92
+ Codes2["Success"] = "success";
93
+ Codes2["Created"] = "created";
94
+ Codes2["BadRequest"] = "bad_request";
95
+ Codes2["Unauthorized"] = "unauthorized";
96
+ Codes2["Forbidden"] = "forbidden";
97
+ Codes2["NotFound"] = "not_found";
98
+ return Codes2;
99
+ })(Codes || {});
100
+ var CustomHeaders = /* @__PURE__ */ ((CustomHeaders2) => {
101
+ CustomHeaders2["TotalCount"] = "wtt-total-count";
102
+ CustomHeaders2["ReturnedCount"] = "wtt-returned-count";
103
+ CustomHeaders2["Page"] = "wtt-page";
104
+ CustomHeaders2["PageSize"] = "wtt-page-size";
105
+ CustomHeaders2["TotalPages"] = "wtt-total-pages";
106
+ CustomHeaders2["HasNextPage"] = "wtt-has-next-page";
107
+ CustomHeaders2["HasPreviousPage"] = "wtt-has-previous-page";
108
+ return CustomHeaders2;
109
+ })(CustomHeaders || {});
110
+ var FilterOperator = /* @__PURE__ */ ((FilterOperator2) => {
111
+ FilterOperator2[FilterOperator2["SubQuery"] = 0] = "SubQuery";
112
+ FilterOperator2[FilterOperator2["Date"] = 1] = "Date";
113
+ return FilterOperator2;
114
+ })(FilterOperator || {});
115
+
116
+ // src/validation/parsers.ts
117
+ var import_express_json_router = __toESM(require("@web-ts-toolkit/express-json-router"));
118
+
119
+ // src/validation/common.ts
120
+ var import_zod = require("zod");
121
+ var stringOrStringArray = import_zod.z.union([import_zod.z.string(), import_zod.z.array(import_zod.z.string())]);
122
+ var queryBooleanString = import_zod.z.enum(["true", "false"]);
123
+ var positiveIntegerString = import_zod.z.string().regex(/^\d+$/, "Expected a non-negative integer");
124
+ var nonNegativeIntegerSchema = import_zod.z.number().int().min(0);
125
+ var unknownRecord = import_zod.z.record(import_zod.z.string(), import_zod.z.unknown());
126
+ var projectionObjectSchema = import_zod.z.record(import_zod.z.string(), import_zod.z.union([import_zod.z.literal(1), import_zod.z.literal(-1)]));
127
+ var projectionSchema = import_zod.z.union([import_zod.z.string(), import_zod.z.array(import_zod.z.string()), projectionObjectSchema]);
128
+ var sortOrderSchema = import_zod.z.union([
129
+ import_zod.z.literal(-1),
130
+ import_zod.z.literal(1),
131
+ import_zod.z.literal("asc"),
132
+ import_zod.z.literal("ascending"),
133
+ import_zod.z.literal("desc"),
134
+ import_zod.z.literal("descending")
135
+ ]);
136
+ var sortSchema = import_zod.z.union([
137
+ import_zod.z.string(),
138
+ import_zod.z.record(import_zod.z.string(), sortOrderSchema),
139
+ import_zod.z.array(import_zod.z.tuple([import_zod.z.string(), sortOrderSchema])),
140
+ import_zod.z.null()
141
+ ]);
142
+ var populateSchema = import_zod.z.union([
143
+ import_zod.z.string(),
144
+ import_zod.z.array(
145
+ import_zod.z.union([
146
+ import_zod.z.string(),
147
+ import_zod.z.object({
148
+ path: import_zod.z.string().min(1),
149
+ select: projectionSchema.optional(),
150
+ match: import_zod.z.unknown().optional(),
151
+ access: import_zod.z.enum(["list", "read"]).optional()
152
+ }).passthrough()
153
+ ])
154
+ ),
155
+ import_zod.z.object({
156
+ path: import_zod.z.string().min(1),
157
+ select: projectionSchema.optional(),
158
+ match: import_zod.z.unknown().optional(),
159
+ access: import_zod.z.enum(["list", "read"]).optional()
160
+ }).passthrough()
161
+ ]);
162
+ var subPopulateSchema = import_zod.z.union([
163
+ import_zod.z.string(),
164
+ import_zod.z.array(
165
+ import_zod.z.union([
166
+ import_zod.z.string(),
167
+ import_zod.z.object({
168
+ path: import_zod.z.string().min(1),
169
+ select: projectionSchema.optional()
170
+ }).passthrough()
171
+ ])
172
+ ),
173
+ import_zod.z.object({
174
+ path: import_zod.z.string().min(1),
175
+ select: projectionSchema.optional()
176
+ }).passthrough()
177
+ ]);
178
+ var includeItemSchema = import_zod.z.object({
179
+ model: import_zod.z.string().min(1),
180
+ op: import_zod.z.enum(["list", "read", "count"]),
181
+ path: import_zod.z.string().min(1),
182
+ filter: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).optional(),
183
+ localField: import_zod.z.string().min(1),
184
+ foreignField: import_zod.z.string().min(1),
185
+ args: import_zod.z.unknown().optional(),
186
+ options: import_zod.z.unknown().optional()
187
+ }).passthrough();
188
+ var includeSchema = import_zod.z.union([includeItemSchema, import_zod.z.array(includeItemSchema)]);
189
+ var fieldsSchema = import_zod.z.array(import_zod.z.string().min(1));
190
+ var taskSchema = import_zod.z.object({
191
+ type: import_zod.z.string().min(1),
192
+ args: import_zod.z.unknown(),
193
+ options: unknownRecord.optional()
194
+ });
195
+ var tasksSchema = import_zod.z.union([taskSchema, import_zod.z.array(taskSchema)]);
196
+ 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())]);
197
+ function rejectKeys(body, ctx, keys) {
198
+ for (const key of keys) {
199
+ if (key in body) {
200
+ ctx.addIssue({
201
+ code: import_zod.z.ZodIssueCode.custom,
202
+ message: `Unsupported field: ${key}`,
203
+ path: [key]
204
+ });
205
+ }
206
+ }
207
+ }
208
+
209
+ // src/validation/parsers.ts
210
+ var clientErrors = import_express_json_router.default.clientErrors;
211
+ function parsePathParam(value, parameter) {
212
+ const result = stringOrStringArray.safeParse(value);
213
+ if (!result.success) {
214
+ throwValidationError(result.error.issues, parameter, "parameter");
215
+ }
216
+ const param = Array.isArray(result.data) ? result.data[0] : result.data;
217
+ if (!param) {
218
+ throw new clientErrors.BadRequestError("Bad Request", {
219
+ errors: [{ detail: "Required", parameter }]
220
+ });
221
+ }
222
+ return param;
223
+ }
224
+ function parseQuery(schema, value) {
225
+ const result = schema.safeParse(value);
226
+ if (!result.success) {
227
+ throwValidationError(result.error.issues, void 0, "parameter");
228
+ }
229
+ return result.data;
230
+ }
231
+ function parseBody(schema, value) {
232
+ const result = schema.safeParse(value ?? {});
233
+ if (!result.success) {
234
+ throwValidationError(result.error.issues, void 0, "pointer");
235
+ }
236
+ return result.data;
237
+ }
238
+ function parseBodyWithSchema(schema, value, userSchema) {
239
+ const body = parseBody(schema, value);
240
+ return isZodSchema(userSchema) ? parseUserSchema(userSchema, body) : body;
241
+ }
242
+ function parseNestedBodyWithSchema(schema, value, nestedKey, userSchema) {
243
+ const body = parseBody(schema, value);
244
+ if (!isZodSchema(userSchema)) return body;
245
+ return {
246
+ ...body,
247
+ [nestedKey]: parseUserSchema(userSchema, body?.[nestedKey], [nestedKey])
248
+ };
249
+ }
250
+ function throwValidationError(issues, key, location = "pointer") {
251
+ const errors = issues.map((issue) => formatIssue(issue, key, location));
252
+ throw new clientErrors.BadRequestError("Bad Request", { errors });
253
+ }
254
+ function parseUserSchema(schema, value, prefix = []) {
255
+ const result = schema.safeParse(value);
256
+ if (!result.success) {
257
+ const issues = result.error.issues.map((issue) => ({
258
+ ...issue,
259
+ path: prefix.concat(issue.path.map(String))
260
+ }));
261
+ throwValidationError(issues, void 0, "pointer");
262
+ }
263
+ return result.data;
264
+ }
265
+ function isZodSchema(schema) {
266
+ return typeof schema === "object" && schema !== null && "safeParse" in schema && typeof schema.safeParse === "function";
267
+ }
268
+ function formatIssue(issue, key, location = "pointer") {
269
+ const path = issue.path.map(String);
270
+ const joinedPath = path.join(".");
271
+ if (location === "parameter") {
272
+ return {
273
+ detail: issue.message,
274
+ parameter: (key ?? joinedPath) || void 0
275
+ };
276
+ }
277
+ return {
278
+ detail: issue.message,
279
+ pointer: buildPointer(path)
280
+ };
281
+ }
282
+ function buildPointer(path) {
283
+ return path.length === 0 ? "#" : `#/${path.join("/")}`;
284
+ }
285
+
286
+ // src/validation/model-router.ts
287
+ var import_zod2 = require("zod");
288
+ var listQuerySchema = import_zod2.z.object({
289
+ skip: positiveIntegerString.optional(),
290
+ limit: positiveIntegerString.optional(),
291
+ page: positiveIntegerString.optional(),
292
+ page_size: positiveIntegerString.optional(),
293
+ skim: queryBooleanString.optional(),
294
+ include_permissions: queryBooleanString.optional(),
295
+ include_count: queryBooleanString.optional(),
296
+ include_extra_headers: queryBooleanString.optional()
297
+ }).passthrough();
298
+ var createQuerySchema = import_zod2.z.object({
299
+ include_permissions: queryBooleanString.optional()
300
+ }).passthrough();
301
+ var readQuerySchema = import_zod2.z.object({
302
+ include_permissions: queryBooleanString.optional(),
303
+ try_list: queryBooleanString.optional()
304
+ }).passthrough();
305
+ var updateQuerySchema = import_zod2.z.object({
306
+ returning_all: queryBooleanString.optional(),
307
+ include_permissions: queryBooleanString.optional()
308
+ }).passthrough();
309
+ var upsertQuerySchema = import_zod2.z.object({
310
+ returning_all: queryBooleanString.optional(),
311
+ include_permissions: queryBooleanString.optional()
312
+ }).passthrough();
313
+ var listBodySchema = import_zod2.z.object({
314
+ filter: objectOrArraySchema.optional(),
315
+ select: projectionSchema.optional(),
316
+ sort: sortSchema.optional(),
317
+ populate: populateSchema.optional(),
318
+ include: includeSchema.optional(),
319
+ tasks: tasksSchema.optional(),
320
+ skip: import_zod2.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
321
+ limit: import_zod2.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
322
+ page: import_zod2.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
323
+ pageSize: import_zod2.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
324
+ options: import_zod2.z.object({
325
+ skim: import_zod2.z.boolean().optional(),
326
+ includePermissions: import_zod2.z.boolean().optional(),
327
+ includeCount: import_zod2.z.boolean().optional(),
328
+ includeExtraHeaders: import_zod2.z.boolean().optional(),
329
+ populateAccess: import_zod2.z.unknown().optional()
330
+ }).passthrough().optional()
331
+ }).passthrough().superRefine((body, ctx) => rejectKeys(body, ctx, ["query"]));
332
+ var countBodySchema = import_zod2.z.object({
333
+ filter: objectOrArraySchema.optional(),
334
+ options: import_zod2.z.object({
335
+ access: import_zod2.z.unknown().optional()
336
+ }).passthrough().optional()
337
+ }).passthrough().superRefine((body, ctx) => rejectKeys(body, ctx, ["query", "access"]));
338
+ var readFilterBodySchema = import_zod2.z.object({
339
+ filter: objectOrArraySchema.optional(),
340
+ select: projectionSchema.optional(),
341
+ sort: sortSchema.optional(),
342
+ populate: populateSchema.optional(),
343
+ include: includeSchema.optional(),
344
+ tasks: tasksSchema.optional(),
345
+ options: import_zod2.z.object({
346
+ skim: import_zod2.z.boolean().optional(),
347
+ includePermissions: import_zod2.z.boolean().optional(),
348
+ tryList: import_zod2.z.boolean().optional(),
349
+ populateAccess: import_zod2.z.unknown().optional()
350
+ }).passthrough().optional()
351
+ }).passthrough();
352
+ var readByIdBodySchema = import_zod2.z.object({
353
+ select: projectionSchema.optional(),
354
+ populate: populateSchema.optional(),
355
+ include: includeSchema.optional(),
356
+ tasks: tasksSchema.optional(),
357
+ options: import_zod2.z.object({
358
+ skim: import_zod2.z.boolean().optional(),
359
+ includePermissions: import_zod2.z.boolean().optional(),
360
+ tryList: import_zod2.z.boolean().optional(),
361
+ populateAccess: import_zod2.z.unknown().optional()
362
+ }).passthrough().optional()
363
+ }).passthrough();
364
+ var advancedCreateBodySchema = import_zod2.z.object({
365
+ data: import_zod2.z.unknown(),
366
+ select: projectionSchema.optional(),
367
+ populate: populateSchema.optional(),
368
+ tasks: tasksSchema.optional(),
369
+ options: import_zod2.z.object({
370
+ includePermissions: import_zod2.z.boolean().optional(),
371
+ populateAccess: import_zod2.z.unknown().optional()
372
+ }).passthrough().optional()
373
+ }).passthrough();
374
+ var createBodySchema = import_zod2.z.union([
375
+ import_zod2.z.record(import_zod2.z.string(), import_zod2.z.unknown()),
376
+ import_zod2.z.array(import_zod2.z.record(import_zod2.z.string(), import_zod2.z.unknown()))
377
+ ]);
378
+ var updateBodySchema = import_zod2.z.record(import_zod2.z.string(), import_zod2.z.unknown());
379
+ var advancedUpdateBodySchema = import_zod2.z.object({
380
+ data: import_zod2.z.unknown(),
381
+ select: projectionSchema.optional(),
382
+ populate: populateSchema.optional(),
383
+ tasks: tasksSchema.optional(),
384
+ options: import_zod2.z.object({
385
+ returningAll: import_zod2.z.boolean().optional(),
386
+ includePermissions: import_zod2.z.boolean().optional(),
387
+ populateAccess: import_zod2.z.unknown().optional()
388
+ }).passthrough().optional()
389
+ }).passthrough();
390
+ var upsertBodySchema = import_zod2.z.record(import_zod2.z.string(), import_zod2.z.unknown());
391
+ var advancedUpsertBodySchema = import_zod2.z.object({
392
+ data: import_zod2.z.record(import_zod2.z.string(), import_zod2.z.unknown()),
393
+ select: projectionSchema.optional(),
394
+ populate: populateSchema.optional(),
395
+ tasks: tasksSchema.optional(),
396
+ options: import_zod2.z.object({
397
+ returningAll: import_zod2.z.boolean().optional(),
398
+ includePermissions: import_zod2.z.boolean().optional(),
399
+ populateAccess: import_zod2.z.unknown().optional()
400
+ }).passthrough().optional()
401
+ }).passthrough();
402
+ var distinctBodySchema = import_zod2.z.object({
403
+ filter: objectOrArraySchema.optional()
404
+ }).passthrough().superRefine((body, ctx) => rejectKeys(body, ctx, ["query"]));
405
+ var subListBodySchema = import_zod2.z.object({
406
+ filter: import_zod2.z.record(import_zod2.z.string(), import_zod2.z.unknown()).optional(),
407
+ select: fieldsSchema.optional()
408
+ }).passthrough().superRefine((body, ctx) => rejectKeys(body, ctx, ["fields"]));
409
+ var subMutationBodySchema = import_zod2.z.union([
410
+ import_zod2.z.record(import_zod2.z.string(), import_zod2.z.unknown()),
411
+ import_zod2.z.array(import_zod2.z.record(import_zod2.z.string(), import_zod2.z.unknown()))
412
+ ]);
413
+ var subReadBodySchema = import_zod2.z.object({
414
+ select: fieldsSchema.optional(),
415
+ populate: subPopulateSchema.optional()
416
+ }).passthrough().superRefine((body, ctx) => rejectKeys(body, ctx, ["fields"]));
417
+ var requestSchemas = {
418
+ listQuery: listQuerySchema,
419
+ createQuery: createQuerySchema,
420
+ readQuery: readQuerySchema,
421
+ updateQuery: updateQuerySchema,
422
+ upsertQuery: upsertQuerySchema
423
+ };
424
+
425
+ // src/validation/data-router.ts
426
+ var import_zod3 = require("zod");
427
+ var dataListBodySchema = import_zod3.z.object({
428
+ filter: objectOrArraySchema.optional(),
429
+ select: projectionSchema.optional(),
430
+ sort: import_zod3.z.string().optional(),
431
+ skip: import_zod3.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
432
+ limit: import_zod3.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
433
+ page: import_zod3.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
434
+ pageSize: import_zod3.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
435
+ options: import_zod3.z.object({
436
+ includeCount: import_zod3.z.boolean().optional(),
437
+ includeExtraHeaders: import_zod3.z.boolean().optional()
438
+ }).passthrough().optional()
439
+ }).passthrough();
440
+ var dataReadFilterBodySchema = import_zod3.z.object({
441
+ filter: objectOrArraySchema.optional(),
442
+ select: projectionSchema.optional()
443
+ }).passthrough().superRefine((body, ctx) => rejectKeys(body, ctx, ["options"]));
444
+ var dataReadByIdBodySchema = import_zod3.z.object({
445
+ select: projectionSchema.optional()
446
+ }).passthrough().superRefine((body, ctx) => rejectKeys(body, ctx, ["options"]));
447
+
448
+ // src/validation/root-router.ts
449
+ var import_zod4 = require("zod");
450
+ var rootEntryBaseSchema = {
451
+ target: import_zod4.z.enum(["model", "data"]),
452
+ name: import_zod4.z.string().min(1),
453
+ order: import_zod4.z.number().int().optional()
454
+ };
455
+ var rootModelListArgsSchema = import_zod4.z.object({
456
+ select: projectionSchema.optional(),
457
+ populate: populateSchema.optional(),
458
+ include: includeSchema.optional(),
459
+ sort: sortSchema.optional(),
460
+ skip: import_zod4.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
461
+ limit: import_zod4.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
462
+ page: import_zod4.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
463
+ pageSize: import_zod4.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
464
+ tasks: tasksSchema.optional()
465
+ }).passthrough();
466
+ var rootModelListOptionsSchema = import_zod4.z.object({
467
+ skim: import_zod4.z.boolean().optional(),
468
+ includePermissions: import_zod4.z.boolean().optional(),
469
+ includeCount: import_zod4.z.boolean().optional(),
470
+ populateAccess: import_zod4.z.unknown().optional(),
471
+ lean: import_zod4.z.boolean().optional()
472
+ }).passthrough();
473
+ var rootModelReadArgsSchema = import_zod4.z.object({
474
+ select: projectionSchema.optional(),
475
+ populate: populateSchema.optional(),
476
+ include: includeSchema.optional(),
477
+ tasks: tasksSchema.optional()
478
+ }).passthrough();
479
+ var rootModelReadFilterArgsSchema = rootModelReadArgsSchema.extend({
480
+ sort: sortSchema.optional()
481
+ });
482
+ var rootModelReadOptionsSchema = import_zod4.z.object({
483
+ skim: import_zod4.z.boolean().optional(),
484
+ includePermissions: import_zod4.z.boolean().optional(),
485
+ tryList: import_zod4.z.boolean().optional(),
486
+ populateAccess: import_zod4.z.unknown().optional(),
487
+ lean: import_zod4.z.boolean().optional()
488
+ }).passthrough();
489
+ var rootModelCreateArgsSchema = import_zod4.z.object({
490
+ select: projectionSchema.optional(),
491
+ populate: populateSchema.optional(),
492
+ tasks: tasksSchema.optional()
493
+ }).passthrough();
494
+ var rootModelCreateOptionsSchema = import_zod4.z.object({
495
+ skim: import_zod4.z.boolean().optional(),
496
+ includePermissions: import_zod4.z.boolean().optional(),
497
+ populateAccess: import_zod4.z.unknown().optional()
498
+ }).passthrough();
499
+ var rootModelUpdateArgsSchema = import_zod4.z.object({
500
+ select: projectionSchema.optional(),
501
+ populate: populateSchema.optional(),
502
+ tasks: tasksSchema.optional()
503
+ }).passthrough();
504
+ var rootModelUpdateOptionsSchema = import_zod4.z.object({
505
+ skim: import_zod4.z.boolean().optional(),
506
+ returningAll: import_zod4.z.boolean().optional(),
507
+ includePermissions: import_zod4.z.boolean().optional(),
508
+ populateAccess: import_zod4.z.unknown().optional()
509
+ }).passthrough();
510
+ var rootModelUpsertArgsSchema = rootModelUpdateArgsSchema;
511
+ var rootModelUpsertOptionsSchema = rootModelUpdateOptionsSchema;
512
+ var rootModelSubListArgsSchema = import_zod4.z.object({
513
+ select: fieldsSchema.optional()
514
+ }).passthrough();
515
+ var rootModelSubReadArgsSchema = import_zod4.z.object({
516
+ select: fieldsSchema.optional(),
517
+ populate: subPopulateSchema.optional()
518
+ }).passthrough();
519
+ var rootModelCountOptionsSchema = import_zod4.z.object({
520
+ access: import_zod4.z.unknown().optional()
521
+ }).passthrough();
522
+ var rootDataListArgsSchema = import_zod4.z.object({
523
+ select: projectionSchema.optional(),
524
+ sort: import_zod4.z.string().optional(),
525
+ skip: import_zod4.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
526
+ limit: import_zod4.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
527
+ page: import_zod4.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
528
+ pageSize: import_zod4.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional()
529
+ }).passthrough();
530
+ var rootDataListOptionsSchema = import_zod4.z.object({
531
+ includeCount: import_zod4.z.boolean().optional()
532
+ }).passthrough();
533
+ var rootDataReadArgsSchema = import_zod4.z.object({
534
+ select: projectionSchema.optional()
535
+ }).passthrough();
536
+ var rootModelQueryEntrySchema = import_zod4.z.union([
537
+ import_zod4.z.object({ ...rootEntryBaseSchema, target: import_zod4.z.literal("model"), op: import_zod4.z.literal("new") }).passthrough(),
538
+ import_zod4.z.object({
539
+ ...rootEntryBaseSchema,
540
+ target: import_zod4.z.literal("model"),
541
+ op: import_zod4.z.literal("list"),
542
+ filter: objectOrArraySchema.optional(),
543
+ args: rootModelListArgsSchema.optional(),
544
+ options: rootModelListOptionsSchema.optional()
545
+ }).passthrough(),
546
+ import_zod4.z.object({
547
+ ...rootEntryBaseSchema,
548
+ target: import_zod4.z.literal("model"),
549
+ op: import_zod4.z.literal("read"),
550
+ id: import_zod4.z.string().min(1),
551
+ args: rootModelReadArgsSchema.optional(),
552
+ options: rootModelReadOptionsSchema.optional()
553
+ }).passthrough(),
554
+ import_zod4.z.object({
555
+ ...rootEntryBaseSchema,
556
+ target: import_zod4.z.literal("model"),
557
+ op: import_zod4.z.literal("read"),
558
+ filter: objectOrArraySchema,
559
+ args: rootModelReadFilterArgsSchema.optional(),
560
+ options: rootModelReadOptionsSchema.optional()
561
+ }).passthrough(),
562
+ import_zod4.z.object({
563
+ ...rootEntryBaseSchema,
564
+ target: import_zod4.z.literal("model"),
565
+ op: import_zod4.z.literal("create"),
566
+ data: import_zod4.z.unknown(),
567
+ args: rootModelCreateArgsSchema.optional(),
568
+ options: rootModelCreateOptionsSchema.optional()
569
+ }).passthrough(),
570
+ import_zod4.z.object({
571
+ ...rootEntryBaseSchema,
572
+ target: import_zod4.z.literal("model"),
573
+ op: import_zod4.z.literal("update"),
574
+ id: import_zod4.z.string().min(1),
575
+ data: import_zod4.z.unknown(),
576
+ args: rootModelUpdateArgsSchema.optional(),
577
+ options: rootModelUpdateOptionsSchema.optional()
578
+ }).passthrough(),
579
+ import_zod4.z.object({
580
+ ...rootEntryBaseSchema,
581
+ target: import_zod4.z.literal("model"),
582
+ op: import_zod4.z.literal("upsert"),
583
+ data: import_zod4.z.record(import_zod4.z.string(), import_zod4.z.unknown()),
584
+ args: rootModelUpsertArgsSchema.optional(),
585
+ options: rootModelUpsertOptionsSchema.optional()
586
+ }).passthrough(),
587
+ 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(),
588
+ import_zod4.z.object({
589
+ ...rootEntryBaseSchema,
590
+ target: import_zod4.z.literal("model"),
591
+ op: import_zod4.z.literal("subList"),
592
+ id: import_zod4.z.string().min(1),
593
+ sub: import_zod4.z.string().min(1),
594
+ filter: import_zod4.z.record(import_zod4.z.string(), import_zod4.z.unknown()).optional(),
595
+ args: rootModelSubListArgsSchema.optional()
596
+ }).passthrough(),
597
+ import_zod4.z.object({
598
+ ...rootEntryBaseSchema,
599
+ target: import_zod4.z.literal("model"),
600
+ op: import_zod4.z.literal("subRead"),
601
+ id: import_zod4.z.string().min(1),
602
+ sub: import_zod4.z.string().min(1),
603
+ subId: import_zod4.z.string().min(1),
604
+ args: rootModelSubReadArgsSchema.optional()
605
+ }).passthrough(),
606
+ import_zod4.z.object({
607
+ ...rootEntryBaseSchema,
608
+ target: import_zod4.z.literal("model"),
609
+ op: import_zod4.z.literal("subCreate"),
610
+ id: import_zod4.z.string().min(1),
611
+ sub: import_zod4.z.string().min(1),
612
+ 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()))])
613
+ }).passthrough(),
614
+ import_zod4.z.object({
615
+ ...rootEntryBaseSchema,
616
+ target: import_zod4.z.literal("model"),
617
+ op: import_zod4.z.literal("subUpdate"),
618
+ id: import_zod4.z.string().min(1),
619
+ sub: import_zod4.z.string().min(1),
620
+ subId: import_zod4.z.string().min(1),
621
+ 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()))])
622
+ }).passthrough(),
623
+ import_zod4.z.object({
624
+ ...rootEntryBaseSchema,
625
+ target: import_zod4.z.literal("model"),
626
+ op: import_zod4.z.literal("subBulkUpdate"),
627
+ id: import_zod4.z.string().min(1),
628
+ sub: import_zod4.z.string().min(1),
629
+ 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()))])
630
+ }).passthrough(),
631
+ import_zod4.z.object({
632
+ ...rootEntryBaseSchema,
633
+ target: import_zod4.z.literal("model"),
634
+ op: import_zod4.z.literal("subDelete"),
635
+ id: import_zod4.z.string().min(1),
636
+ sub: import_zod4.z.string().min(1),
637
+ subId: import_zod4.z.string().min(1)
638
+ }).passthrough(),
639
+ import_zod4.z.object({
640
+ ...rootEntryBaseSchema,
641
+ target: import_zod4.z.literal("model"),
642
+ op: import_zod4.z.literal("distinct"),
643
+ field: import_zod4.z.string().min(1),
644
+ filter: objectOrArraySchema.optional()
645
+ }).passthrough(),
646
+ import_zod4.z.object({
647
+ ...rootEntryBaseSchema,
648
+ target: import_zod4.z.literal("model"),
649
+ op: import_zod4.z.literal("count"),
650
+ filter: objectOrArraySchema.optional(),
651
+ options: rootModelCountOptionsSchema.optional()
652
+ }).passthrough()
653
+ ]);
654
+ var rootDataQueryEntrySchema = import_zod4.z.union([
655
+ import_zod4.z.object({
656
+ ...rootEntryBaseSchema,
657
+ target: import_zod4.z.literal("data"),
658
+ op: import_zod4.z.literal("list"),
659
+ filter: objectOrArraySchema.optional(),
660
+ args: rootDataListArgsSchema.optional(),
661
+ options: rootDataListOptionsSchema.optional()
662
+ }).passthrough(),
663
+ import_zod4.z.object({
664
+ ...rootEntryBaseSchema,
665
+ target: import_zod4.z.literal("data"),
666
+ op: import_zod4.z.literal("read"),
667
+ id: import_zod4.z.string().min(1),
668
+ args: rootDataReadArgsSchema.optional()
669
+ }).passthrough(),
670
+ import_zod4.z.object({
671
+ ...rootEntryBaseSchema,
672
+ target: import_zod4.z.literal("data"),
673
+ op: import_zod4.z.literal("read"),
674
+ filter: objectOrArraySchema,
675
+ args: rootDataReadArgsSchema.optional()
676
+ }).passthrough()
677
+ ]);
678
+ var rootQuerySchema = import_zod4.z.array(import_zod4.z.union([rootModelQueryEntrySchema, rootDataQueryEntrySchema]));
679
+ // Annotate the CommonJS export names for ESM import in node:
680
+ 0 && (module.exports = {
681
+ CORE,
682
+ Codes,
683
+ CustomHeaders,
684
+ DATA_MIDDLEWARE,
685
+ FilterOperator,
686
+ MIDDLEWARE,
687
+ PERMISSIONS,
688
+ PERMISSION_KEYS,
689
+ StatusCodes,
690
+ advancedCreateBodySchema,
691
+ advancedUpdateBodySchema,
692
+ advancedUpsertBodySchema,
693
+ countBodySchema,
694
+ createBodySchema,
695
+ createQuerySchema,
696
+ dataListBodySchema,
697
+ dataReadByIdBodySchema,
698
+ dataReadFilterBodySchema,
699
+ distinctBodySchema,
700
+ listBodySchema,
701
+ listQuerySchema,
702
+ parseBody,
703
+ parseBodyWithSchema,
704
+ parseNestedBodyWithSchema,
705
+ parsePathParam,
706
+ parseQuery,
707
+ readByIdBodySchema,
708
+ readFilterBodySchema,
709
+ readQuerySchema,
710
+ requestSchemas,
711
+ rootQuerySchema,
712
+ subListBodySchema,
713
+ subMutationBodySchema,
714
+ subReadBodySchema,
715
+ updateBodySchema,
716
+ updateQuerySchema,
717
+ upsertBodySchema,
718
+ upsertQuerySchema
719
+ });