@web-ts-toolkit/access-router 0.32.0 → 0.33.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 CHANGED
@@ -125,89 +125,971 @@ var FilterOperator = /* @__PURE__ */ ((FilterOperator2) => {
125
125
  // src/validation/parsers.ts
126
126
  var import_express_json_router = __toESM(require("@web-ts-toolkit/express-json-router"));
127
127
 
128
- // src/validation/common.ts
128
+ // src/runtime.ts
129
+ var import_mongoose2 = __toESM(require("mongoose"));
130
+ var import_mongoose_schema_jsonschema = __toESM(require("mongoose-schema-jsonschema"));
131
+ var import_utils7 = require("@web-ts-toolkit/utils");
132
+
133
+ // src/helpers/index.ts
134
+ var import_utils2 = require("@web-ts-toolkit/utils");
135
+
136
+ // src/lib.ts
137
+ var import_mongoose = require("mongoose");
138
+ var import_utils = require("@web-ts-toolkit/utils");
139
+ var isSchema = (val) => val instanceof import_mongoose.Schema;
140
+ var isObjectIdType = (val) => val === "ObjectId" || val === import_mongoose.Schema.Types.ObjectId;
141
+ var isReference = (val) => (0, import_utils.isPlainObject)(val) && !!val.ref && isObjectIdType(val.type);
142
+
143
+ // src/helpers/index.ts
144
+ function recurseObject(obj) {
145
+ if (isSchema(obj)) {
146
+ return buildRefs(obj.tree);
147
+ }
148
+ if (!(0, import_utils2.isObject)(obj)) return null;
149
+ if (isReference(obj)) {
150
+ return obj.ref;
151
+ }
152
+ let ret = null;
153
+ (0, import_utils2.forEach)(obj, (val) => {
154
+ ret = recurseObject(val);
155
+ if (!(0, import_utils2.isEmpty)(ret)) {
156
+ return false;
157
+ }
158
+ });
159
+ return ret;
160
+ }
161
+ function buildRefs(schema) {
162
+ if (!(0, import_utils2.isObject)(schema)) return {};
163
+ const references = {};
164
+ (0, import_utils2.forEach)(schema, (val, key) => {
165
+ const paths = recurseObject(val);
166
+ if (!(0, import_utils2.isEmpty)(paths)) {
167
+ references[key] = paths;
168
+ }
169
+ const target = (0, import_utils2.isObject)(val) && "type" in val ? val.type ?? val : val;
170
+ if ((0, import_utils2.isArray)(target) && target.length > 0) {
171
+ if (isSchema(target[0]) || (0, import_utils2.isPlainObject)(target[0])) {
172
+ return;
173
+ }
174
+ }
175
+ });
176
+ return references;
177
+ }
178
+ function buildSubPaths(schema) {
179
+ if (!(0, import_utils2.isObject)(schema)) return [];
180
+ const subPaths = [];
181
+ (0, import_utils2.forEach)(schema, (val, key) => {
182
+ const target = (0, import_utils2.isObject)(val) && "type" in val ? val.type ?? val : val;
183
+ if ((0, import_utils2.isArray)(target) && target.length > 0) {
184
+ if (isSchema(target[0]) || (0, import_utils2.isPlainObject)(target[0]) && !isReference(target[0])) {
185
+ subPaths.push(key);
186
+ }
187
+ }
188
+ });
189
+ return subPaths;
190
+ }
191
+
192
+ // src/openapi/build-spec.ts
193
+ var import_utils4 = require("@web-ts-toolkit/utils");
194
+
195
+ // src/openapi/responses.ts
196
+ var json = (schema) => ({
197
+ content: {
198
+ "application/json": {
199
+ schema
200
+ }
201
+ }
202
+ });
203
+ var problemJson = {
204
+ content: {
205
+ "application/problem+json": {
206
+ schema: {
207
+ type: "object",
208
+ properties: {
209
+ type: { type: "string" },
210
+ title: { type: "string" },
211
+ status: { type: "number" },
212
+ detail: { type: "string" },
213
+ errors: { type: "array", items: {} }
214
+ },
215
+ additionalProperties: true
216
+ }
217
+ }
218
+ }
219
+ };
220
+ var genericDataSchema = { type: "object", additionalProperties: true };
221
+ var genericListSchema = { type: "array", items: genericDataSchema };
222
+ var openApiResponses = {
223
+ single(description = "Success") {
224
+ return {
225
+ 200: { description, ...json(genericDataSchema) },
226
+ 400: { description: "Bad Request", ...problemJson },
227
+ 401: { description: "Unauthorized", ...problemJson },
228
+ 404: { description: "Not Found", ...problemJson }
229
+ };
230
+ },
231
+ list(description = "Success") {
232
+ return {
233
+ 200: { description, ...json(genericListSchema) },
234
+ 400: { description: "Bad Request", ...problemJson },
235
+ 401: { description: "Unauthorized", ...problemJson }
236
+ };
237
+ },
238
+ create(description = "Created") {
239
+ return {
240
+ 201: { description, ...json(genericDataSchema) },
241
+ 400: { description: "Bad Request", ...problemJson },
242
+ 401: { description: "Unauthorized", ...problemJson }
243
+ };
244
+ },
245
+ delete(description = "Deleted") {
246
+ return {
247
+ 200: { description, ...json(genericDataSchema) },
248
+ 400: { description: "Bad Request", ...problemJson },
249
+ 401: { description: "Unauthorized", ...problemJson },
250
+ 404: { description: "Not Found", ...problemJson }
251
+ };
252
+ },
253
+ batch(description = "Success") {
254
+ return {
255
+ 200: { description, ...json(genericListSchema) },
256
+ 400: { description: "Bad Request", ...problemJson },
257
+ 401: { description: "Unauthorized", ...problemJson }
258
+ };
259
+ }
260
+ };
261
+
262
+ // src/openapi/schemas.ts
129
263
  var import_zod = require("zod");
130
- var stringOrStringArray = import_zod.z.union([import_zod.z.string(), import_zod.z.array(import_zod.z.string())]);
131
- var queryBooleanString = import_zod.z.enum(["true", "false"]);
132
- var positiveIntegerString = import_zod.z.string().regex(/^\d+$/, "Expected a non-negative integer");
133
- var nonNegativeIntegerSchema = import_zod.z.number().int().min(0);
134
- var unknownRecord = import_zod.z.record(import_zod.z.string(), import_zod.z.unknown());
135
- var projectionObjectSchema = import_zod.z.record(import_zod.z.string(), import_zod.z.union([import_zod.z.literal(1), import_zod.z.literal(-1)]));
136
- var projectionSchema = import_zod.z.union([import_zod.z.string(), import_zod.z.array(import_zod.z.string()), projectionObjectSchema]);
137
- var sortOrderSchema = import_zod.z.union([
138
- import_zod.z.literal(-1),
139
- import_zod.z.literal(1),
140
- import_zod.z.literal("asc"),
141
- import_zod.z.literal("ascending"),
142
- import_zod.z.literal("desc"),
143
- import_zod.z.literal("descending")
264
+ var import_utils3 = require("@web-ts-toolkit/utils");
265
+ var fallbackObjectSchema = { type: "object", additionalProperties: true };
266
+ function isOpenApiSchemaPatch(source) {
267
+ return (0, import_utils3.isPlainObject)(source) && source.kind === "objectProperties";
268
+ }
269
+ function isOpenApiSchemaResolver(source) {
270
+ return (0, import_utils3.isPlainObject)(source) && source.kind === "schemaResolver" && typeof source.resolve === "function";
271
+ }
272
+ function isJsonSchemaLike(source) {
273
+ return (0, import_utils3.isPlainObject)(source) && ("type" in source || "properties" in source || "$ref" in source || "anyOf" in source);
274
+ }
275
+ function hasOpenApiSchema(source) {
276
+ return (0, import_utils3.isPlainObject)(source) && isJsonSchemaLike(source.openapi);
277
+ }
278
+ function toOpenApiSchema(source) {
279
+ if (!source) return void 0;
280
+ const resolvedSource = isOpenApiSchemaResolver(source) ? source.resolve() : source;
281
+ if (!resolvedSource) return void 0;
282
+ if (isOpenApiSchemaPatch(resolvedSource)) {
283
+ const schema = toOpenApiSchema(resolvedSource.source) ?? { ...fallbackObjectSchema };
284
+ const properties = (0, import_utils3.isPlainObject)(schema.properties) ? { ...schema.properties } : {};
285
+ for (const [key, value] of Object.entries(resolvedSource.properties)) {
286
+ properties[key] = toOpenApiSchema(value) ?? fallbackObjectSchema;
287
+ }
288
+ return {
289
+ ...schema,
290
+ type: schema.type ?? "object",
291
+ properties
292
+ };
293
+ }
294
+ if (hasOpenApiSchema(resolvedSource)) {
295
+ return resolvedSource.openapi;
296
+ }
297
+ if (isJsonSchemaLike(resolvedSource)) {
298
+ return resolvedSource;
299
+ }
300
+ try {
301
+ return import_zod.z.toJSONSchema(resolvedSource);
302
+ } catch {
303
+ return fallbackObjectSchema;
304
+ }
305
+ }
306
+
307
+ // src/openapi/build-spec.ts
308
+ var openApiMediaType = "application/json";
309
+ var normalizePath = (path) => {
310
+ if (!path) return "/";
311
+ return path.startsWith("/") ? path : `/${path}`;
312
+ };
313
+ var toOpenApiPath = (path) => normalizePath(path).replace(/:([A-Za-z0-9_]+)/g, "{$1}");
314
+ var schemaToQueryParameters = (schema) => {
315
+ const jsonSchema = toOpenApiSchema(schema);
316
+ if (!jsonSchema || jsonSchema.type !== "object") return [];
317
+ const properties = (0, import_utils4.isPlainObject)(jsonSchema.properties) ? jsonSchema.properties : {};
318
+ const required = new Set(
319
+ (0, import_utils4.isArray)(jsonSchema.required) ? jsonSchema.required.filter((item) => typeof item === "string") : []
320
+ );
321
+ return Object.entries(properties).map(([name, value]) => ({
322
+ name,
323
+ in: "query",
324
+ required: required.has(name),
325
+ schema: value
326
+ }));
327
+ };
328
+ var schemaToPathParameters = (path, pathParams) => {
329
+ const names = [...toOpenApiPath(path).matchAll(/\{([^}]+)\}/g)].map((item) => item[1]);
330
+ return names.map((name) => ({
331
+ name,
332
+ in: "path",
333
+ required: true,
334
+ schema: (pathParams && name in pathParams ? toOpenApiSchema(pathParams[name]) : void 0) ?? { type: "string" }
335
+ }));
336
+ };
337
+ var getDefaultResponses = (route) => {
338
+ if (route.operationId === "root.query") return openApiResponses.batch();
339
+ if (route.method === "delete") return openApiResponses.delete();
340
+ if (route.operationId?.toLowerCase().includes("create")) return openApiResponses.create();
341
+ if (route.operationId?.toLowerCase().includes("list")) return openApiResponses.list();
342
+ if (route.operationId?.toLowerCase().includes("distinct")) return openApiResponses.list();
343
+ return openApiResponses.single();
344
+ };
345
+ var buildOperation = (route) => {
346
+ const queryParameters = schemaToQueryParameters(route.query);
347
+ const pathParameters = schemaToPathParameters(route.path, route.pathParams);
348
+ const bodySchema = toOpenApiSchema(route.body);
349
+ const responses = route.responses ?? getDefaultResponses(route);
350
+ const operation = {
351
+ operationId: route.operationId,
352
+ summary: route.summary,
353
+ description: route.description,
354
+ tags: route.tags,
355
+ deprecated: route.deprecated,
356
+ responses
357
+ };
358
+ const parameters = [...pathParameters, ...queryParameters];
359
+ if (parameters.length) {
360
+ operation.parameters = parameters;
361
+ }
362
+ if (bodySchema) {
363
+ operation.requestBody = {
364
+ required: true,
365
+ content: {
366
+ [openApiMediaType]: {
367
+ schema: bodySchema
368
+ }
369
+ }
370
+ };
371
+ }
372
+ if (route.acl) {
373
+ operation["x-access-router-acl"] = route.acl;
374
+ }
375
+ return operation;
376
+ };
377
+ function buildOpenApiSpec(routes, options) {
378
+ const paths = {};
379
+ const { servers, ...info } = options;
380
+ for (const route of routes) {
381
+ const path = toOpenApiPath(route.path);
382
+ if (!paths[path]) {
383
+ paths[path] = {};
384
+ }
385
+ paths[path][route.method] = buildOperation(route);
386
+ }
387
+ return {
388
+ openapi: "3.1.0",
389
+ info,
390
+ servers,
391
+ paths
392
+ };
393
+ }
394
+
395
+ // src/openapi/errors.ts
396
+ var OpenApiCollisionError = class extends Error {
397
+ constructor(message, details) {
398
+ super(message);
399
+ this.name = "OpenApiCollisionError";
400
+ this.collisionKind = details.collisionKind;
401
+ this.method = details.method;
402
+ this.path = details.path;
403
+ this.operationId = details.operationId;
404
+ this.existing = details.existing;
405
+ this.incoming = details.incoming;
406
+ }
407
+ };
408
+
409
+ // src/openapi/registry.ts
410
+ var isPlainObject5 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
411
+ var stableKey = (value) => {
412
+ if (value === null || typeof value === "undefined") return "null";
413
+ if (typeof value === "function") return "[Function]";
414
+ if (typeof value !== "object") return JSON.stringify(value);
415
+ if (Array.isArray(value)) {
416
+ return `[${value.map(stableKey).join(",")}]`;
417
+ }
418
+ const obj = value;
419
+ return `{${Object.keys(obj).sort().map((k) => `${JSON.stringify(k)}:${stableKey(obj[k])}`).join(",")}}`;
420
+ };
421
+ var descriptorsEqual = (a, b) => {
422
+ return a.method === b.method && a.path === b.path && (a.operationId ?? "") === (b.operationId ?? "") && (a.acl ?? "") === (b.acl ?? "") && stableKey(a.query) === stableKey(b.query) && stableKey(a.body) === stableKey(b.body) && stableKey(a.pathParams) === stableKey(b.pathParams) && stableKey(a.responses) === stableKey(b.responses) && stableKey(a.tags) === stableKey(b.tags) && (a.summary ?? "") === (b.summary ?? "") && (a.description ?? "") === (b.description ?? "") && Boolean(a.deprecated) === Boolean(b.deprecated);
423
+ };
424
+ var OpenApiRegistry = class {
425
+ constructor(options = {}) {
426
+ this.routes = [];
427
+ this.options = {
428
+ rejectConflicts: options.rejectConflicts ?? true,
429
+ rejectDuplicateOperationIds: options.rejectDuplicateOperationIds ?? true
430
+ };
431
+ }
432
+ register(route) {
433
+ const existingIndex = this.routes.findIndex((item) => item.method === route.method && item.path === route.path);
434
+ if (existingIndex === -1) {
435
+ this.assertOperationIdAvailable(route);
436
+ this.routes.push(route);
437
+ return;
438
+ }
439
+ const existing = this.routes[existingIndex];
440
+ if (route.allowReplace) {
441
+ this.assertOperationIdAvailable(route, existing);
442
+ this.routes[existingIndex] = route;
443
+ return;
444
+ }
445
+ if (descriptorsEqual(existing, route) && (route.idempotent || isPlainObject5(existing) && existing.idempotent)) {
446
+ return;
447
+ }
448
+ if (this.options.rejectConflicts) {
449
+ throw new OpenApiCollisionError(
450
+ `OpenAPI route collision: ${route.method.toUpperCase()} ${route.path} is already registered` + (existing.operationId ? ` as operationId="${existing.operationId}"` : "") + (route.operationId ? `; new registration uses operationId="${route.operationId}"` : "") + ". Set allowReplace:true on the new descriptor to override, or fix the duplicate registration.",
451
+ {
452
+ collisionKind: "path",
453
+ method: route.method,
454
+ path: route.path,
455
+ existing,
456
+ incoming: route
457
+ }
458
+ );
459
+ }
460
+ this.routes[existingIndex] = route;
461
+ }
462
+ assertOperationIdAvailable(route, replacing) {
463
+ if (!this.options.rejectDuplicateOperationIds) return;
464
+ if (!route.operationId) return;
465
+ const clash = this.routes.find(
466
+ (item) => item.operationId && item.operationId === route.operationId && item !== replacing
467
+ );
468
+ if (clash) {
469
+ if (route.idempotent && clash.idempotent) return;
470
+ throw new OpenApiCollisionError(
471
+ `OpenAPI operationId collision: "${route.operationId}" is already bound to ${clash.method.toUpperCase()} ${clash.path}. Each operationId must be unique across the spec.`,
472
+ {
473
+ collisionKind: "operationId",
474
+ operationId: route.operationId,
475
+ existing: clash,
476
+ incoming: route
477
+ }
478
+ );
479
+ }
480
+ }
481
+ getRoutes() {
482
+ return [...this.routes];
483
+ }
484
+ clear() {
485
+ this.routes.length = 0;
486
+ }
487
+ setStrictMode(enabled) {
488
+ this.options.rejectConflicts = enabled;
489
+ this.options.rejectDuplicateOperationIds = enabled;
490
+ }
491
+ getSpec(info) {
492
+ return buildOpenApiSpec(this.routes, info);
493
+ }
494
+ };
495
+
496
+ // src/logger-default.ts
497
+ var import_node_util = __toESM(require("util"));
498
+ var import_winston = require("winston");
499
+ var colorizer = import_winston.format.colorize();
500
+ var defaultLogLevel = process.env.WTT_LOG_LEVEL || "silent";
501
+ var inspectValue = (value) => {
502
+ return typeof value === "string" ? value : import_node_util.default.inspect(value, { depth: 5, colors: false });
503
+ };
504
+ var defaultLogger = (0, import_winston.createLogger)({
505
+ level: defaultLogLevel,
506
+ format: import_winston.format.combine(
507
+ import_winston.format.errors({ stack: true }),
508
+ import_winston.format.splat(),
509
+ import_winston.format.label({ label: "[WTT]" }),
510
+ import_winston.format.timestamp(),
511
+ import_winston.format.printf(({ level, label, message, timestamp, stack, ...meta }) => {
512
+ const formattedLabel = colorizer.colorize(level, String(label));
513
+ const formattedLevel = colorizer.colorize(level, `[${String(level).toUpperCase()}]`);
514
+ const formattedMessage = colorizer.colorize(level, inspectValue(stack ?? message));
515
+ const formattedMeta = Object.keys(meta).length > 0 ? ` ${inspectValue(meta)}` : "";
516
+ return `${formattedLabel} ${timestamp} ${formattedLevel} ${formattedMessage}${formattedMeta}`;
517
+ })
518
+ ),
519
+ transports: [new import_winston.transports.Console()]
520
+ });
521
+
522
+ // src/options/manager.ts
523
+ var import_utils5 = require("@web-ts-toolkit/utils");
524
+ var getNestedOption = (manager, key, defaultValue) => {
525
+ const keys2 = String(key).split(".");
526
+ if (keys2.length === 1) {
527
+ return manager.get(key, defaultValue);
528
+ }
529
+ let option = manager.get(key, void 0);
530
+ if (option !== void 0) {
531
+ return option;
532
+ }
533
+ const parentKey = keys2.slice(0, -1).join(".");
534
+ option = manager.get(`${parentKey}.default`, void 0);
535
+ if (option === void 0) {
536
+ option = manager.get(parentKey, defaultValue);
537
+ }
538
+ return option;
539
+ };
540
+ var OptionsManager = class {
541
+ constructor(defaultOptions) {
542
+ this.defaultOptions = defaultOptions;
543
+ this.listeners = {};
544
+ const _this = this;
545
+ this.currentOptions = new Proxy({}, {
546
+ set(target, key, value) {
547
+ const keystr = String(key);
548
+ const oldvalue = target[keystr];
549
+ target[keystr] = value;
550
+ _this.listeners[keystr] && _this.listeners[keystr].call(_this, value, keystr, target, oldvalue);
551
+ return true;
552
+ }
553
+ });
554
+ }
555
+ build() {
556
+ this.assign(this.defaultOptions);
557
+ return this;
558
+ }
559
+ get(key, defaultValue) {
560
+ return (0, import_utils5.get)(this.currentOptions, key, defaultValue);
561
+ }
562
+ set(key, value) {
563
+ (0, import_utils5.set)(this.currentOptions, key, value);
564
+ }
565
+ fetch() {
566
+ return { ...this.currentOptions };
567
+ }
568
+ assign(options) {
569
+ (0, import_utils5.assign)(this.currentOptions, options);
570
+ }
571
+ onchange(key, func) {
572
+ (0, import_utils5.set)(this.listeners, key, func);
573
+ return this;
574
+ }
575
+ };
576
+
577
+ // src/request-complexity.ts
578
+ var import_utils6 = require("@web-ts-toolkit/utils");
579
+ var defaultRequestComplexity = {
580
+ maxDepth: 8,
581
+ maxNodes: 500,
582
+ maxLogicalClauses: 50,
583
+ maxInValues: 100,
584
+ maxBulkItems: 100,
585
+ maxIncludeCount: 10,
586
+ maxSubQueryCount: 10,
587
+ maxBulkConcurrency: 10
588
+ };
589
+ var normalizePositiveInteger = (value, fallback) => {
590
+ return Number.isSafeInteger(value) && Number(value) > 0 ? Number(value) : fallback;
591
+ };
592
+ var resolveRequestComplexity = (options) => ({
593
+ maxDepth: normalizePositiveInteger(options?.maxDepth, defaultRequestComplexity.maxDepth),
594
+ maxNodes: normalizePositiveInteger(options?.maxNodes, defaultRequestComplexity.maxNodes),
595
+ maxLogicalClauses: normalizePositiveInteger(options?.maxLogicalClauses, defaultRequestComplexity.maxLogicalClauses),
596
+ maxInValues: normalizePositiveInteger(options?.maxInValues, defaultRequestComplexity.maxInValues),
597
+ maxBulkItems: normalizePositiveInteger(options?.maxBulkItems, defaultRequestComplexity.maxBulkItems),
598
+ maxIncludeCount: normalizePositiveInteger(options?.maxIncludeCount, defaultRequestComplexity.maxIncludeCount),
599
+ maxSubQueryCount: normalizePositiveInteger(options?.maxSubQueryCount, defaultRequestComplexity.maxSubQueryCount),
600
+ maxBulkConcurrency: normalizePositiveInteger(
601
+ options?.maxBulkConcurrency,
602
+ defaultRequestComplexity.maxBulkConcurrency
603
+ )
604
+ });
605
+ function validateRequestComplexity(value, options, scope = "request") {
606
+ const limits = resolveRequestComplexity(options);
607
+ const errors = [];
608
+ let nodes = 0;
609
+ let logicalClauses = 0;
610
+ let includeCount = 0;
611
+ let subQueryCount = 0;
612
+ const pointer = (path) => path.length === 0 ? "#" : `#/${path.join("/")}`;
613
+ const pushError = (detail, path) => {
614
+ if (errors.length === 0) {
615
+ errors.push({ detail, pointer: pointer(path) });
616
+ }
617
+ };
618
+ const visit = (current, path, depth, parentKey) => {
619
+ if (errors.length > 0) return;
620
+ nodes += 1;
621
+ if (nodes > limits.maxNodes) {
622
+ pushError(`Request exceeds maximum node budget of ${limits.maxNodes}`, path);
623
+ return;
624
+ }
625
+ if (depth > limits.maxDepth) {
626
+ pushError(`Request exceeds maximum depth of ${limits.maxDepth}`, path);
627
+ return;
628
+ }
629
+ if ((0, import_utils6.isArray)(current)) {
630
+ if (parentKey === "$and" || parentKey === "$or" || parentKey === "$nor") {
631
+ logicalClauses += current.length;
632
+ if (logicalClauses > limits.maxLogicalClauses) {
633
+ pushError(`Filter exceeds maximum logical clause budget of ${limits.maxLogicalClauses}`, path);
634
+ return;
635
+ }
636
+ }
637
+ if (parentKey === "$in") {
638
+ if (current.length > limits.maxInValues) {
639
+ pushError(`Filter exceeds maximum $in values of ${limits.maxInValues}`, path);
640
+ return;
641
+ }
642
+ }
643
+ for (let index = 0; index < current.length; index++) {
644
+ visit(current[index], path.concat(index), depth + 1, parentKey);
645
+ if (errors.length > 0) return;
646
+ }
647
+ return;
648
+ }
649
+ if (!(0, import_utils6.isPlainObject)(current)) return;
650
+ for (const [key, child] of Object.entries(current)) {
651
+ if (key === "__proto__" || key === "prototype" || key === "constructor") {
652
+ pushError(`Unsupported key: ${key}`, path.concat(key));
653
+ return;
654
+ }
655
+ if (scope === "request" && key === "include") {
656
+ includeCount += (0, import_utils6.isArray)(child) ? child.length : 1;
657
+ if (includeCount > limits.maxIncludeCount) {
658
+ pushError(`Request exceeds maximum include count of ${limits.maxIncludeCount}`, path.concat(key));
659
+ return;
660
+ }
661
+ }
662
+ if (key === "$$sq") {
663
+ subQueryCount += 1;
664
+ if (subQueryCount > limits.maxSubQueryCount) {
665
+ pushError(`Request exceeds maximum subquery count of ${limits.maxSubQueryCount}`, path.concat(key));
666
+ return;
667
+ }
668
+ visit(child, path.concat(key), depth + 1, key);
669
+ if (errors.length > 0) return;
670
+ continue;
671
+ }
672
+ visit(child, path.concat(key), depth + 1, key);
673
+ if (errors.length > 0) return;
674
+ }
675
+ };
676
+ visit(value, [], 0);
677
+ return errors;
678
+ }
679
+
680
+ // src/runtime.ts
681
+ var mongooseJsonSchemaInitialized = false;
682
+ var ensureMongooseJsonSchemaInitialized = () => {
683
+ if (mongooseJsonSchemaInitialized) return;
684
+ (0, import_mongoose_schema_jsonschema.default)(import_mongoose2.default);
685
+ mongooseJsonSchemaInitialized = true;
686
+ };
687
+ var pluralize = import_mongoose2.default.pluralize();
688
+ var FIELD_ACCESS_KEYS = ["list", "create", "read", "update"];
689
+ var defaultModelOptions = {
690
+ basePath: null,
691
+ alwaysSelectFields: []
692
+ };
693
+ var defaultDataOptions = {
694
+ basePath: null,
695
+ parentPath: "/",
696
+ queryRouteSegment: "__query"
697
+ };
698
+ var normalizeBasePath = (name, value) => {
699
+ if ((0, import_utils7.isNil)(value)) {
700
+ return `/${pluralize(name)}`;
701
+ }
702
+ return (0, import_utils7.isString)(value) ? (0, import_utils7.addLeadingSlash)(value) : "";
703
+ };
704
+ var hasModelPermission = (value, modelPermissionPrefix) => {
705
+ if (!modelPermissionPrefix) {
706
+ return true;
707
+ }
708
+ if ((0, import_utils7.isString)(value)) {
709
+ return value.trim().split(" ").some((item) => item.startsWith(modelPermissionPrefix));
710
+ }
711
+ if ((0, import_utils7.isArray)(value)) {
712
+ return value.some((item) => {
713
+ if ((0, import_utils7.isString)(item) || (0, import_utils7.isArray)(item)) {
714
+ return hasModelPermission(item, modelPermissionPrefix);
715
+ }
716
+ return true;
717
+ });
718
+ }
719
+ return (0, import_utils7.isFunction)(value);
720
+ };
721
+ var classifyPermissionSchema = (permissionSchema, modelPermissionPrefix) => {
722
+ const schemaKeys = Object.keys(permissionSchema);
723
+ const globalPermissionKeys = {};
724
+ const modelPermissionKeys = {};
725
+ (0, import_utils7.forEach)(schemaKeys, (schemaKey) => {
726
+ const schemaRule = permissionSchema[schemaKey];
727
+ const ruleEntries = (0, import_utils7.isPlainObject)(schemaRule) ? Object.entries(schemaRule) : FIELD_ACCESS_KEYS.map((accessKey) => [accessKey, schemaRule]);
728
+ for (let x = 0; x < ruleEntries.length; x++) {
729
+ const [accessKey, value] = ruleEntries[x];
730
+ if (!(0, import_utils7.isArray)(globalPermissionKeys[accessKey])) {
731
+ globalPermissionKeys[accessKey] = [];
732
+ }
733
+ if (!(0, import_utils7.isArray)(modelPermissionKeys[accessKey])) {
734
+ modelPermissionKeys[accessKey] = [];
735
+ }
736
+ if ((0, import_utils7.isBoolean)(value)) {
737
+ globalPermissionKeys[accessKey].push(schemaKey);
738
+ return;
739
+ }
740
+ if (hasModelPermission(value, modelPermissionPrefix)) {
741
+ modelPermissionKeys[accessKey].push(schemaKey);
742
+ return;
743
+ }
744
+ globalPermissionKeys[accessKey].push(schemaKey);
745
+ }
746
+ });
747
+ return {
748
+ schemaKeys,
749
+ globalPermissionKeys,
750
+ modelPermissionKeys
751
+ };
752
+ };
753
+ var AccessRuntime = class {
754
+ constructor() {
755
+ this.globalOptions = new OptionsManager({
756
+ requestPermissionField: "_permissions",
757
+ globalPermissions: () => ({}),
758
+ logger: defaultLogger,
759
+ requestComplexity: defaultRequestComplexity
760
+ }).build();
761
+ this.defaultModelOptions = new OptionsManager({
762
+ listHardLimit: 1e3,
763
+ documentPermissionField: "_permissions",
764
+ idParam: "id",
765
+ idField: "_id",
766
+ parentPath: "/",
767
+ queryRouteSegment: "__query",
768
+ mutationRouteSegment: "__mutation",
769
+ operationAccess: false,
770
+ modelPermissionPrefix: ""
771
+ }).build();
772
+ this.modelOptions = {};
773
+ this.modelJsonSchemas = {};
774
+ this.dataOptions = {};
775
+ this.modelRefs = {};
776
+ this.modelSubs = {};
777
+ this.modelAtts = {};
778
+ this.modelInstances = {};
779
+ this.openApiRegistry = new OpenApiRegistry();
780
+ ensureMongooseJsonSchemaInitialized();
781
+ }
782
+ registerModelInstance(modelName, model) {
783
+ if (!modelName || typeof modelName !== "string") {
784
+ throw new TypeError(`registerModelInstance: modelName must be a non-empty string, received ${typeof modelName}`);
785
+ }
786
+ const existing = this.modelInstances[modelName];
787
+ if (existing && existing !== model) {
788
+ throw new Error(
789
+ `Runtime model registry conflict: model "${modelName}" is already registered to a different mongoose.Model instance on this runtime. Use a distinct model name or a separate runtime.`
790
+ );
791
+ }
792
+ this.modelInstances[modelName] = model;
793
+ }
794
+ hasModelInstance(modelName) {
795
+ return modelName in this.modelInstances;
796
+ }
797
+ getModelInstance(modelName) {
798
+ const registered = this.modelInstances[modelName];
799
+ if (registered) return registered;
800
+ const global = import_mongoose2.default.models[modelName];
801
+ return global ?? null;
802
+ }
803
+ registerOpenApiRoute(route) {
804
+ this.openApiRegistry.register(route);
805
+ }
806
+ /**
807
+ * Enable strict OpenAPI collision detection for the remainder of this
808
+ * runtime's lifetime. After this call, conflicting method/path
809
+ * registrations and duplicate operationIds throw {@link OpenApiCollisionError}
810
+ * instead of silently replacing. Existing already-registered routes are
811
+ * not retroactively re-validated.
812
+ */
813
+ enableOpenApiCollisionDetection() {
814
+ this.openApiRegistry.setStrictMode(true);
815
+ }
816
+ getOpenApiRoutes() {
817
+ return this.openApiRegistry.getRoutes();
818
+ }
819
+ clearOpenApiRoutes() {
820
+ this.openApiRegistry.clear();
821
+ }
822
+ getOpenApiSpec(info) {
823
+ return this.openApiRegistry.getSpec(info);
824
+ }
825
+ setGlobalOptions(options) {
826
+ this.globalOptions.assign(options);
827
+ }
828
+ setGlobalOption(key, value) {
829
+ this.globalOptions.set(key, value);
830
+ }
831
+ getGlobalOptions() {
832
+ return this.globalOptions.fetch();
833
+ }
834
+ getGlobalOption(key, defaultValue) {
835
+ return this.globalOptions.get(key, defaultValue);
836
+ }
837
+ setDefaultModelOptions(options) {
838
+ this.defaultModelOptions.assign(options);
839
+ }
840
+ setDefaultModelOption(key, value) {
841
+ this.defaultModelOptions.set(key, value);
842
+ }
843
+ getDefaultModelOptions() {
844
+ return this.defaultModelOptions.fetch();
845
+ }
846
+ getDefaultModelOption(key, defaultValue) {
847
+ return this.defaultModelOptions.get(key, defaultValue);
848
+ }
849
+ createModelOptions(modelName) {
850
+ const model = this.getModelInstance(modelName) ?? import_mongoose2.default.model(modelName);
851
+ const manager = new OptionsManager({
852
+ ...defaultModelOptions,
853
+ modelName
854
+ });
855
+ manager.onchange("permissionSchema", function(newval, key, target) {
856
+ const permissionSchema = newval ?? {};
857
+ const { schemaKeys, globalPermissionKeys, modelPermissionKeys } = classifyPermissionSchema(
858
+ permissionSchema,
859
+ target.modelPermissionPrefix ?? ""
860
+ );
861
+ target._permissionSchemaKeys = schemaKeys;
862
+ target._globalPermissionKeys = globalPermissionKeys;
863
+ target._modelPermissionKeys = modelPermissionKeys;
864
+ }).onchange("basePath", function(newval, key, target) {
865
+ target[key] = normalizeBasePath(
866
+ modelName,
867
+ (0, import_utils7.isString)(newval) || (0, import_utils7.isNil)(newval) ? newval : void 0
868
+ );
869
+ }).build();
870
+ this.modelJsonSchemas[modelName] = model.jsonSchema();
871
+ return manager;
872
+ }
873
+ getOrCreateModelOptions(modelName) {
874
+ let manager = this.modelOptions[modelName];
875
+ if (!manager) {
876
+ manager = this.createModelOptions(modelName);
877
+ this.modelOptions[modelName] = manager;
878
+ }
879
+ return manager;
880
+ }
881
+ setModelOptions(modelName, options) {
882
+ const manager = this.getOrCreateModelOptions(modelName);
883
+ const defaultOptions = this.getDefaultModelOptions();
884
+ const currentModelOptions = manager.fetch();
885
+ manager.assign({ ...defaultOptions, ...currentModelOptions, ...options });
886
+ }
887
+ setModelOption(modelName, key, value) {
888
+ const manager = this.getOrCreateModelOptions(modelName);
889
+ manager.set(key, value);
890
+ }
891
+ getModelOptions(modelName) {
892
+ const manager = this.getOrCreateModelOptions(modelName);
893
+ return manager.fetch();
894
+ }
895
+ getModelOption(modelName, key, defaultValue) {
896
+ const manager = this.getOrCreateModelOptions(modelName);
897
+ const defaultModelValue = this.getDefaultModelOption(
898
+ key,
899
+ defaultValue
900
+ );
901
+ return getNestedOption(manager, key, defaultModelValue);
902
+ }
903
+ getExactModelOption(modelName, key) {
904
+ const manager = this.getOrCreateModelOptions(modelName);
905
+ const defaultModelValue = this.getDefaultModelOption(key);
906
+ return manager.get(key, defaultModelValue);
907
+ }
908
+ getModelNames() {
909
+ return Object.keys(this.modelOptions);
910
+ }
911
+ hasModel(modelName) {
912
+ return modelName in this.modelOptions;
913
+ }
914
+ getModelJsonSchema(modelName) {
915
+ return this.modelJsonSchemas[modelName];
916
+ }
917
+ createDataOptions(dataName) {
918
+ const manager = new OptionsManager({
919
+ ...defaultDataOptions,
920
+ dataName
921
+ });
922
+ manager.onchange("basePath", function(newval, key, target) {
923
+ target[key] = normalizeBasePath(
924
+ dataName,
925
+ (0, import_utils7.isString)(newval) || (0, import_utils7.isNil)(newval) ? newval : void 0
926
+ );
927
+ }).build();
928
+ return manager;
929
+ }
930
+ getOrCreateDataOptions(dataName) {
931
+ let manager = this.dataOptions[dataName];
932
+ if (!manager) {
933
+ manager = this.createDataOptions(dataName);
934
+ this.dataOptions[dataName] = manager;
935
+ }
936
+ return manager;
937
+ }
938
+ setDataOptions(dataName, options) {
939
+ const manager = this.getOrCreateDataOptions(dataName);
940
+ const currentDataOptions = manager.fetch();
941
+ manager.assign({ ...currentDataOptions, ...options });
942
+ }
943
+ setDataOption(dataName, key, value) {
944
+ const manager = this.getOrCreateDataOptions(dataName);
945
+ manager.set(key, value);
946
+ }
947
+ getDataOptions(dataName) {
948
+ const manager = this.getOrCreateDataOptions(dataName);
949
+ return manager.fetch();
950
+ }
951
+ getDataOption(dataName, key, defaultValue) {
952
+ const manager = this.getOrCreateDataOptions(dataName);
953
+ return getNestedOption(manager, key, defaultValue);
954
+ }
955
+ getExactDataOption(dataName, key) {
956
+ const manager = this.getOrCreateDataOptions(dataName);
957
+ return manager.get(key);
958
+ }
959
+ getDataNames() {
960
+ return Object.keys(this.dataOptions);
961
+ }
962
+ ensureModelMeta(modelName) {
963
+ if (modelName in this.modelRefs && modelName in this.modelSubs && modelName in this.modelAtts) {
964
+ return;
965
+ }
966
+ const model = this.getModelInstance(modelName);
967
+ if (!model) {
968
+ this.modelRefs[modelName] = this.modelRefs[modelName] ?? {};
969
+ this.modelSubs[modelName] = this.modelSubs[modelName] ?? [];
970
+ this.modelAtts[modelName] = this.modelAtts[modelName] ?? [];
971
+ return;
972
+ }
973
+ const schema = model.schema;
974
+ this.modelRefs[modelName] = buildRefs(schema.tree);
975
+ this.modelSubs[modelName] = buildSubPaths(schema.tree);
976
+ this.modelAtts[modelName] = (0, import_utils7.keys)(schema.obj);
977
+ }
978
+ getModelRef(modelName, refPath) {
979
+ this.ensureModelMeta(modelName);
980
+ const value = (0, import_utils7.get)(this.modelRefs, `${modelName}.${refPath}`, null);
981
+ return (0, import_utils7.isString)(value) ? value : null;
982
+ }
983
+ getModelSub(modelName) {
984
+ this.ensureModelMeta(modelName);
985
+ return (0, import_utils7.get)(this.modelSubs, modelName, []);
986
+ }
987
+ getModelAtt(modelName) {
988
+ this.ensureModelMeta(modelName);
989
+ return (0, import_utils7.get)(this.modelAtts, modelName, []);
990
+ }
991
+ };
992
+ var defaultRuntime = new AccessRuntime();
993
+
994
+ // src/runtime-context.ts
995
+ var import_node_async_hooks = require("async_hooks");
996
+ var runtimeStorage = new import_node_async_hooks.AsyncLocalStorage();
997
+ function getActiveRuntime() {
998
+ return runtimeStorage.getStore() ?? null;
999
+ }
1000
+
1001
+ // src/options/global-options.ts
1002
+ var getRuntime = () => getActiveRuntime() ?? defaultRuntime;
1003
+ var getGlobalOption = (key, defaultValue) => {
1004
+ return getRuntime().getGlobalOption(key, defaultValue);
1005
+ };
1006
+
1007
+ // src/validation/common.ts
1008
+ var import_zod2 = require("zod");
1009
+ var stringOrStringArray = import_zod2.z.union([import_zod2.z.string(), import_zod2.z.array(import_zod2.z.string())]);
1010
+ var safeIntegerString = (min, message) => import_zod2.z.string().regex(/^\d+$/, message).refine((value) => Number.isSafeInteger(Number(value)), "Expected a safe integer").refine((value) => Number(value) >= min, message);
1011
+ var queryBooleanString = import_zod2.z.enum(["true", "false"]);
1012
+ var nonNegativeIntegerString = safeIntegerString(0, "Expected a non-negative integer");
1013
+ var positiveIntegerString = safeIntegerString(1, "Expected a positive integer");
1014
+ var nonNegativeIntegerSchema = import_zod2.z.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
1015
+ var positiveIntegerSchema = import_zod2.z.number().int().min(1).max(Number.MAX_SAFE_INTEGER);
1016
+ var unknownRecord = import_zod2.z.record(import_zod2.z.string(), import_zod2.z.unknown());
1017
+ var projectionObjectSchema = import_zod2.z.record(import_zod2.z.string(), import_zod2.z.union([import_zod2.z.literal(1), import_zod2.z.literal(-1)]));
1018
+ var projectionSchema = import_zod2.z.union([import_zod2.z.string(), import_zod2.z.array(import_zod2.z.string()), projectionObjectSchema]);
1019
+ var sortOrderSchema = import_zod2.z.union([
1020
+ import_zod2.z.literal(-1),
1021
+ import_zod2.z.literal(1),
1022
+ import_zod2.z.literal("asc"),
1023
+ import_zod2.z.literal("ascending"),
1024
+ import_zod2.z.literal("desc"),
1025
+ import_zod2.z.literal("descending")
144
1026
  ]);
145
- var sortSchema = import_zod.z.union([
146
- import_zod.z.string(),
147
- import_zod.z.record(import_zod.z.string(), sortOrderSchema),
148
- import_zod.z.array(import_zod.z.tuple([import_zod.z.string(), sortOrderSchema])),
149
- import_zod.z.null()
1027
+ var sortSchema = import_zod2.z.union([
1028
+ import_zod2.z.string(),
1029
+ import_zod2.z.record(import_zod2.z.string(), sortOrderSchema),
1030
+ import_zod2.z.array(import_zod2.z.tuple([import_zod2.z.string(), sortOrderSchema])),
1031
+ import_zod2.z.null()
150
1032
  ]);
151
- var populateSchema = import_zod.z.union([
152
- import_zod.z.string(),
153
- import_zod.z.array(
154
- import_zod.z.union([
155
- import_zod.z.string(),
156
- import_zod.z.object({
157
- path: import_zod.z.string().min(1),
1033
+ var populateSchema = import_zod2.z.union([
1034
+ import_zod2.z.string(),
1035
+ import_zod2.z.array(
1036
+ import_zod2.z.union([
1037
+ import_zod2.z.string(),
1038
+ import_zod2.z.object({
1039
+ path: import_zod2.z.string().min(1),
158
1040
  select: projectionSchema.optional(),
159
- match: import_zod.z.unknown().optional(),
160
- access: import_zod.z.enum(["list", "read"]).optional()
1041
+ match: import_zod2.z.unknown().optional(),
1042
+ access: import_zod2.z.enum(["list", "read"]).optional()
161
1043
  }).passthrough()
162
1044
  ])
163
1045
  ),
164
- import_zod.z.object({
165
- path: import_zod.z.string().min(1),
1046
+ import_zod2.z.object({
1047
+ path: import_zod2.z.string().min(1),
166
1048
  select: projectionSchema.optional(),
167
- match: import_zod.z.unknown().optional(),
168
- access: import_zod.z.enum(["list", "read"]).optional()
1049
+ match: import_zod2.z.unknown().optional(),
1050
+ access: import_zod2.z.enum(["list", "read"]).optional()
169
1051
  }).passthrough()
170
1052
  ]);
171
- var subPopulateSchema = import_zod.z.union([
172
- import_zod.z.string(),
173
- import_zod.z.array(
174
- import_zod.z.union([
175
- import_zod.z.string(),
176
- import_zod.z.object({
177
- path: import_zod.z.string().min(1),
1053
+ var subPopulateSchema = import_zod2.z.union([
1054
+ import_zod2.z.string(),
1055
+ import_zod2.z.array(
1056
+ import_zod2.z.union([
1057
+ import_zod2.z.string(),
1058
+ import_zod2.z.object({
1059
+ path: import_zod2.z.string().min(1),
178
1060
  select: projectionSchema.optional()
179
1061
  }).passthrough()
180
1062
  ])
181
1063
  ),
182
- import_zod.z.object({
183
- path: import_zod.z.string().min(1),
1064
+ import_zod2.z.object({
1065
+ path: import_zod2.z.string().min(1),
184
1066
  select: projectionSchema.optional()
185
1067
  }).passthrough()
186
1068
  ]);
187
- var includeItemSchema = import_zod.z.object({
188
- model: import_zod.z.string().min(1),
189
- op: import_zod.z.enum(["list", "read", "count"]),
190
- path: import_zod.z.string().min(1),
191
- filter: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).optional(),
192
- localField: import_zod.z.string().min(1),
193
- foreignField: import_zod.z.string().min(1),
194
- args: import_zod.z.unknown().optional(),
195
- options: import_zod.z.unknown().optional()
1069
+ var includeItemSchema = import_zod2.z.object({
1070
+ model: import_zod2.z.string().min(1),
1071
+ op: import_zod2.z.enum(["list", "read", "count"]),
1072
+ path: import_zod2.z.string().min(1),
1073
+ filter: import_zod2.z.record(import_zod2.z.string(), import_zod2.z.unknown()).optional(),
1074
+ localField: import_zod2.z.string().min(1),
1075
+ foreignField: import_zod2.z.string().min(1),
1076
+ args: import_zod2.z.unknown().optional(),
1077
+ options: import_zod2.z.unknown().optional()
196
1078
  }).passthrough();
197
- var includeSchema = import_zod.z.union([includeItemSchema, import_zod.z.array(includeItemSchema)]);
198
- var fieldsSchema = import_zod.z.array(import_zod.z.string().min(1));
199
- var taskSchema = import_zod.z.object({
200
- type: import_zod.z.string().min(1),
201
- args: import_zod.z.unknown(),
1079
+ var includeSchema = import_zod2.z.union([includeItemSchema, import_zod2.z.array(includeItemSchema)]);
1080
+ var fieldsSchema = import_zod2.z.array(import_zod2.z.string().min(1));
1081
+ var taskSchema = import_zod2.z.object({
1082
+ type: import_zod2.z.string().min(1),
1083
+ args: import_zod2.z.unknown(),
202
1084
  options: unknownRecord.optional()
203
1085
  });
204
- var tasksSchema = import_zod.z.union([taskSchema, import_zod.z.array(taskSchema)]);
205
- 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())]);
206
- function rejectKeys(body, ctx, keys) {
207
- for (const key of keys) {
1086
+ var tasksSchema = import_zod2.z.union([taskSchema, import_zod2.z.array(taskSchema)]);
1087
+ var objectOrArraySchema = import_zod2.z.union([import_zod2.z.record(import_zod2.z.string(), import_zod2.z.unknown()), import_zod2.z.array(import_zod2.z.unknown())]);
1088
+ function rejectKeys(body, ctx, keys2) {
1089
+ for (const key of keys2) {
208
1090
  if (key in body) {
209
1091
  ctx.addIssue({
210
- code: import_zod.z.ZodIssueCode.custom,
1092
+ code: import_zod2.z.ZodIssueCode.custom,
211
1093
  message: `Unsupported field: ${key}`,
212
1094
  path: [key]
213
1095
  });
@@ -231,6 +1113,10 @@ function parsePathParam(value, parameter) {
231
1113
  return param;
232
1114
  }
233
1115
  function parseQuery(schema, value) {
1116
+ const complexityErrors = validateRequestComplexity(value, getGlobalOption("requestComplexity"), "request");
1117
+ if (complexityErrors.length > 0) {
1118
+ throw new clientErrors.BadRequestError("Bad Request", { errors: complexityErrors });
1119
+ }
234
1120
  const result = schema.safeParse(value);
235
1121
  if (!result.success) {
236
1122
  throwValidationError(normalizeIssues(result.error.issues), void 0, "parameter");
@@ -238,6 +1124,10 @@ function parseQuery(schema, value) {
238
1124
  return result.data;
239
1125
  }
240
1126
  function parseBody(schema, value) {
1127
+ const complexityErrors = validateRequestComplexity(value ?? {}, getGlobalOption("requestComplexity"), "request");
1128
+ if (complexityErrors.length > 0) {
1129
+ throw new clientErrors.BadRequestError("Bad Request", { errors: complexityErrors });
1130
+ }
241
1131
  const result = schema.safeParse(value ?? {});
242
1132
  if (!result.success) {
243
1133
  throwValidationError(normalizeIssues(result.error.issues), void 0, "pointer");
@@ -580,133 +1470,130 @@ function buildPointer(path) {
580
1470
  }
581
1471
 
582
1472
  // src/validation/model-router.ts
583
- var import_zod2 = require("zod");
584
- var listQuerySchema = import_zod2.z.object({
585
- skip: positiveIntegerString.optional(),
1473
+ var import_zod3 = require("zod");
1474
+ var listQuerySchema = import_zod3.z.object({
1475
+ skip: nonNegativeIntegerString.optional(),
586
1476
  limit: positiveIntegerString.optional(),
587
- page: positiveIntegerString.optional(),
1477
+ page: nonNegativeIntegerString.optional(),
588
1478
  page_size: positiveIntegerString.optional(),
589
1479
  skim: queryBooleanString.optional(),
590
1480
  include_permissions: queryBooleanString.optional(),
591
1481
  include_count: queryBooleanString.optional(),
592
1482
  include_extra_headers: queryBooleanString.optional()
593
1483
  }).passthrough();
594
- var createQuerySchema = import_zod2.z.object({
1484
+ var createQuerySchema = import_zod3.z.object({
595
1485
  include_permissions: queryBooleanString.optional()
596
1486
  }).passthrough();
597
- var readQuerySchema = import_zod2.z.object({
1487
+ var readQuerySchema = import_zod3.z.object({
598
1488
  include_permissions: queryBooleanString.optional(),
599
1489
  try_list: queryBooleanString.optional()
600
1490
  }).passthrough();
601
- var updateQuerySchema = import_zod2.z.object({
1491
+ var updateQuerySchema = import_zod3.z.object({
602
1492
  returning_all: queryBooleanString.optional(),
603
1493
  include_permissions: queryBooleanString.optional()
604
1494
  }).passthrough();
605
- var upsertQuerySchema = import_zod2.z.object({
1495
+ var upsertQuerySchema = import_zod3.z.object({
606
1496
  returning_all: queryBooleanString.optional(),
607
1497
  include_permissions: queryBooleanString.optional()
608
1498
  }).passthrough();
609
- var listBodySchema = import_zod2.z.object({
1499
+ var listBodySchema = import_zod3.z.object({
610
1500
  filter: objectOrArraySchema.optional(),
611
1501
  select: projectionSchema.optional(),
612
1502
  sort: sortSchema.optional(),
613
1503
  populate: populateSchema.optional(),
614
1504
  include: includeSchema.optional(),
615
1505
  tasks: tasksSchema.optional(),
616
- skip: import_zod2.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
617
- limit: import_zod2.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
618
- page: import_zod2.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
619
- pageSize: import_zod2.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
620
- options: import_zod2.z.object({
621
- skim: import_zod2.z.boolean().optional(),
622
- includePermissions: import_zod2.z.boolean().optional(),
623
- includeCount: import_zod2.z.boolean().optional(),
624
- includeExtraHeaders: import_zod2.z.boolean().optional(),
625
- populateAccess: import_zod2.z.unknown().optional()
1506
+ skip: import_zod3.z.union([nonNegativeIntegerSchema, nonNegativeIntegerString]).optional(),
1507
+ limit: import_zod3.z.union([positiveIntegerSchema, positiveIntegerString]).optional(),
1508
+ page: import_zod3.z.union([nonNegativeIntegerSchema, nonNegativeIntegerString]).optional(),
1509
+ pageSize: import_zod3.z.union([positiveIntegerSchema, positiveIntegerString]).optional(),
1510
+ options: import_zod3.z.object({
1511
+ skim: import_zod3.z.boolean().optional(),
1512
+ includePermissions: import_zod3.z.boolean().optional(),
1513
+ includeCount: import_zod3.z.boolean().optional(),
1514
+ includeExtraHeaders: import_zod3.z.boolean().optional(),
1515
+ populateAccess: import_zod3.z.unknown().optional()
626
1516
  }).passthrough().optional()
627
1517
  }).passthrough().superRefine((body, ctx) => rejectKeys(body, ctx, ["query"]));
628
- var countBodySchema = import_zod2.z.object({
629
- filter: objectOrArraySchema.optional(),
630
- options: import_zod2.z.object({
631
- access: import_zod2.z.unknown().optional()
632
- }).passthrough().optional()
633
- }).passthrough().superRefine((body, ctx) => rejectKeys(body, ctx, ["query", "access"]));
634
- var readFilterBodySchema = import_zod2.z.object({
1518
+ var countBodySchema = import_zod3.z.object({
1519
+ filter: objectOrArraySchema.optional()
1520
+ }).passthrough().superRefine((body, ctx) => rejectKeys(body, ctx, ["query", "access", "options"]));
1521
+ var readFilterBodySchema = import_zod3.z.object({
635
1522
  filter: objectOrArraySchema.optional(),
636
1523
  select: projectionSchema.optional(),
637
1524
  sort: sortSchema.optional(),
638
1525
  populate: populateSchema.optional(),
639
1526
  include: includeSchema.optional(),
640
1527
  tasks: tasksSchema.optional(),
641
- options: import_zod2.z.object({
642
- skim: import_zod2.z.boolean().optional(),
643
- includePermissions: import_zod2.z.boolean().optional(),
644
- tryList: import_zod2.z.boolean().optional(),
645
- populateAccess: import_zod2.z.unknown().optional()
1528
+ options: import_zod3.z.object({
1529
+ skim: import_zod3.z.boolean().optional(),
1530
+ includePermissions: import_zod3.z.boolean().optional(),
1531
+ tryList: import_zod3.z.boolean().optional(),
1532
+ populateAccess: import_zod3.z.unknown().optional()
646
1533
  }).passthrough().optional()
647
1534
  }).passthrough();
648
- var readByIdBodySchema = import_zod2.z.object({
1535
+ var readByIdBodySchema = import_zod3.z.object({
649
1536
  select: projectionSchema.optional(),
650
1537
  populate: populateSchema.optional(),
651
1538
  include: includeSchema.optional(),
652
1539
  tasks: tasksSchema.optional(),
653
- options: import_zod2.z.object({
654
- skim: import_zod2.z.boolean().optional(),
655
- includePermissions: import_zod2.z.boolean().optional(),
656
- tryList: import_zod2.z.boolean().optional(),
657
- populateAccess: import_zod2.z.unknown().optional()
1540
+ options: import_zod3.z.object({
1541
+ skim: import_zod3.z.boolean().optional(),
1542
+ includePermissions: import_zod3.z.boolean().optional(),
1543
+ tryList: import_zod3.z.boolean().optional(),
1544
+ populateAccess: import_zod3.z.unknown().optional()
658
1545
  }).passthrough().optional()
659
1546
  }).passthrough();
660
- var advancedCreateBodySchema = import_zod2.z.object({
661
- data: import_zod2.z.unknown(),
1547
+ var advancedCreateBodySchema = import_zod3.z.object({
1548
+ data: import_zod3.z.unknown(),
662
1549
  select: projectionSchema.optional(),
663
1550
  populate: populateSchema.optional(),
664
1551
  tasks: tasksSchema.optional(),
665
- options: import_zod2.z.object({
666
- includePermissions: import_zod2.z.boolean().optional(),
667
- populateAccess: import_zod2.z.unknown().optional()
1552
+ options: import_zod3.z.object({
1553
+ includePermissions: import_zod3.z.boolean().optional(),
1554
+ populateAccess: import_zod3.z.unknown().optional()
668
1555
  }).passthrough().optional()
669
1556
  }).passthrough();
670
- var createBodySchema = import_zod2.z.union([
671
- import_zod2.z.record(import_zod2.z.string(), import_zod2.z.unknown()),
672
- import_zod2.z.array(import_zod2.z.record(import_zod2.z.string(), import_zod2.z.unknown()))
1557
+ var createBodySchema = import_zod3.z.union([
1558
+ import_zod3.z.record(import_zod3.z.string(), import_zod3.z.unknown()),
1559
+ import_zod3.z.array(import_zod3.z.record(import_zod3.z.string(), import_zod3.z.unknown()))
673
1560
  ]);
674
- var updateBodySchema = import_zod2.z.record(import_zod2.z.string(), import_zod2.z.unknown());
675
- var advancedUpdateBodySchema = import_zod2.z.object({
676
- data: import_zod2.z.unknown(),
1561
+ var updateBodySchema = import_zod3.z.record(import_zod3.z.string(), import_zod3.z.unknown());
1562
+ var advancedUpdateBodySchema = import_zod3.z.object({
1563
+ data: import_zod3.z.unknown(),
677
1564
  select: projectionSchema.optional(),
678
1565
  populate: populateSchema.optional(),
679
1566
  tasks: tasksSchema.optional(),
680
- options: import_zod2.z.object({
681
- returningAll: import_zod2.z.boolean().optional(),
682
- includePermissions: import_zod2.z.boolean().optional(),
683
- populateAccess: import_zod2.z.unknown().optional()
1567
+ options: import_zod3.z.object({
1568
+ returningAll: import_zod3.z.boolean().optional(),
1569
+ includePermissions: import_zod3.z.boolean().optional(),
1570
+ populateAccess: import_zod3.z.unknown().optional()
684
1571
  }).passthrough().optional()
685
1572
  }).passthrough();
686
- var upsertBodySchema = import_zod2.z.record(import_zod2.z.string(), import_zod2.z.unknown());
687
- var advancedUpsertBodySchema = import_zod2.z.object({
688
- data: import_zod2.z.record(import_zod2.z.string(), import_zod2.z.unknown()),
1573
+ var upsertBodySchema = import_zod3.z.record(import_zod3.z.string(), import_zod3.z.unknown());
1574
+ var advancedUpsertBodySchema = import_zod3.z.object({
1575
+ data: import_zod3.z.record(import_zod3.z.string(), import_zod3.z.unknown()),
689
1576
  select: projectionSchema.optional(),
690
1577
  populate: populateSchema.optional(),
691
1578
  tasks: tasksSchema.optional(),
692
- options: import_zod2.z.object({
693
- returningAll: import_zod2.z.boolean().optional(),
694
- includePermissions: import_zod2.z.boolean().optional(),
695
- populateAccess: import_zod2.z.unknown().optional()
1579
+ options: import_zod3.z.object({
1580
+ returningAll: import_zod3.z.boolean().optional(),
1581
+ includePermissions: import_zod3.z.boolean().optional(),
1582
+ populateAccess: import_zod3.z.unknown().optional()
696
1583
  }).passthrough().optional()
697
1584
  }).passthrough();
698
- var distinctBodySchema = import_zod2.z.object({
1585
+ var distinctBodySchema = import_zod3.z.object({
699
1586
  filter: objectOrArraySchema.optional()
700
1587
  }).passthrough().superRefine((body, ctx) => rejectKeys(body, ctx, ["query"]));
701
- var subListBodySchema = import_zod2.z.object({
702
- filter: import_zod2.z.record(import_zod2.z.string(), import_zod2.z.unknown()).optional(),
1588
+ var subListBodySchema = import_zod3.z.object({
1589
+ filter: import_zod3.z.record(import_zod3.z.string(), import_zod3.z.unknown()).optional(),
703
1590
  select: fieldsSchema.optional()
704
1591
  }).passthrough().superRefine((body, ctx) => rejectKeys(body, ctx, ["fields"]));
705
- var subMutationBodySchema = import_zod2.z.union([
706
- import_zod2.z.record(import_zod2.z.string(), import_zod2.z.unknown()),
707
- import_zod2.z.array(import_zod2.z.record(import_zod2.z.string(), import_zod2.z.unknown()))
1592
+ var subMutationBodySchema = import_zod3.z.union([
1593
+ import_zod3.z.record(import_zod3.z.string(), import_zod3.z.unknown()),
1594
+ import_zod3.z.array(import_zod3.z.record(import_zod3.z.string(), import_zod3.z.unknown()))
708
1595
  ]);
709
- var subReadBodySchema = import_zod2.z.object({
1596
+ var subReadBodySchema = import_zod3.z.object({
710
1597
  select: fieldsSchema.optional(),
711
1598
  populate: subPopulateSchema.optional()
712
1599
  }).passthrough().superRefine((body, ctx) => rejectKeys(body, ctx, ["fields"]));
@@ -719,54 +1606,54 @@ var requestSchemas = {
719
1606
  };
720
1607
 
721
1608
  // src/validation/data-router.ts
722
- var import_zod3 = require("zod");
723
- var dataListBodySchema = import_zod3.z.object({
1609
+ var import_zod4 = require("zod");
1610
+ var dataListBodySchema = import_zod4.z.object({
724
1611
  filter: objectOrArraySchema.optional(),
725
1612
  select: projectionSchema.optional(),
726
- sort: import_zod3.z.string().optional(),
727
- skip: import_zod3.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
728
- limit: import_zod3.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
729
- page: import_zod3.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
730
- pageSize: import_zod3.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
731
- options: import_zod3.z.object({
732
- includeCount: import_zod3.z.boolean().optional(),
733
- includeExtraHeaders: import_zod3.z.boolean().optional()
1613
+ sort: import_zod4.z.string().optional(),
1614
+ skip: import_zod4.z.union([nonNegativeIntegerSchema, nonNegativeIntegerString]).optional(),
1615
+ limit: import_zod4.z.union([positiveIntegerSchema, positiveIntegerString]).optional(),
1616
+ page: import_zod4.z.union([nonNegativeIntegerSchema, nonNegativeIntegerString]).optional(),
1617
+ pageSize: import_zod4.z.union([positiveIntegerSchema, positiveIntegerString]).optional(),
1618
+ options: import_zod4.z.object({
1619
+ includeCount: import_zod4.z.boolean().optional(),
1620
+ includeExtraHeaders: import_zod4.z.boolean().optional()
734
1621
  }).passthrough().optional()
735
1622
  }).passthrough();
736
- var dataReadFilterBodySchema = import_zod3.z.object({
1623
+ var dataReadFilterBodySchema = import_zod4.z.object({
737
1624
  filter: objectOrArraySchema.optional(),
738
1625
  select: projectionSchema.optional()
739
1626
  }).passthrough().superRefine((body, ctx) => rejectKeys(body, ctx, ["options"]));
740
- var dataReadByIdBodySchema = import_zod3.z.object({
1627
+ var dataReadByIdBodySchema = import_zod4.z.object({
741
1628
  select: projectionSchema.optional()
742
1629
  }).passthrough().superRefine((body, ctx) => rejectKeys(body, ctx, ["options"]));
743
1630
 
744
1631
  // src/validation/root-router.ts
745
- var import_zod4 = require("zod");
1632
+ var import_zod5 = require("zod");
746
1633
  var rootEntryBaseSchema = {
747
- target: import_zod4.z.enum(["model", "data"]),
748
- name: import_zod4.z.string().min(1),
749
- order: import_zod4.z.number().int().optional()
1634
+ target: import_zod5.z.enum(["model", "data"]),
1635
+ name: import_zod5.z.string().min(1),
1636
+ order: nonNegativeIntegerSchema.optional()
750
1637
  };
751
- var rootModelListArgsSchema = import_zod4.z.object({
1638
+ var rootModelListArgsSchema = import_zod5.z.object({
752
1639
  select: projectionSchema.optional(),
753
1640
  populate: populateSchema.optional(),
754
1641
  include: includeSchema.optional(),
755
1642
  sort: sortSchema.optional(),
756
- skip: import_zod4.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
757
- limit: import_zod4.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
758
- page: import_zod4.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
759
- pageSize: import_zod4.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
1643
+ skip: import_zod5.z.union([nonNegativeIntegerSchema, nonNegativeIntegerString]).optional(),
1644
+ limit: import_zod5.z.union([positiveIntegerSchema, positiveIntegerString]).optional(),
1645
+ page: import_zod5.z.union([nonNegativeIntegerSchema, nonNegativeIntegerString]).optional(),
1646
+ pageSize: import_zod5.z.union([positiveIntegerSchema, positiveIntegerString]).optional(),
760
1647
  tasks: tasksSchema.optional()
761
1648
  }).passthrough();
762
- var rootModelListOptionsSchema = import_zod4.z.object({
763
- skim: import_zod4.z.boolean().optional(),
764
- includePermissions: import_zod4.z.boolean().optional(),
765
- includeCount: import_zod4.z.boolean().optional(),
766
- populateAccess: import_zod4.z.unknown().optional(),
767
- lean: import_zod4.z.boolean().optional()
1649
+ var rootModelListOptionsSchema = import_zod5.z.object({
1650
+ skim: import_zod5.z.boolean().optional(),
1651
+ includePermissions: import_zod5.z.boolean().optional(),
1652
+ includeCount: import_zod5.z.boolean().optional(),
1653
+ populateAccess: import_zod5.z.unknown().optional(),
1654
+ lean: import_zod5.z.boolean().optional()
768
1655
  }).passthrough();
769
- var rootModelReadArgsSchema = import_zod4.z.object({
1656
+ var rootModelReadArgsSchema = import_zod5.z.object({
770
1657
  select: projectionSchema.optional(),
771
1658
  populate: populateSchema.optional(),
772
1659
  include: includeSchema.optional(),
@@ -775,203 +1662,214 @@ var rootModelReadArgsSchema = import_zod4.z.object({
775
1662
  var rootModelReadFilterArgsSchema = rootModelReadArgsSchema.extend({
776
1663
  sort: sortSchema.optional()
777
1664
  });
778
- var rootModelReadOptionsSchema = import_zod4.z.object({
779
- skim: import_zod4.z.boolean().optional(),
780
- includePermissions: import_zod4.z.boolean().optional(),
781
- tryList: import_zod4.z.boolean().optional(),
782
- populateAccess: import_zod4.z.unknown().optional(),
783
- lean: import_zod4.z.boolean().optional()
1665
+ var rootModelReadOptionsSchema = import_zod5.z.object({
1666
+ skim: import_zod5.z.boolean().optional(),
1667
+ includePermissions: import_zod5.z.boolean().optional(),
1668
+ tryList: import_zod5.z.boolean().optional(),
1669
+ populateAccess: import_zod5.z.unknown().optional(),
1670
+ lean: import_zod5.z.boolean().optional()
784
1671
  }).passthrough();
785
- var rootModelCreateArgsSchema = import_zod4.z.object({
1672
+ var rootModelCreateArgsSchema = import_zod5.z.object({
786
1673
  select: projectionSchema.optional(),
787
1674
  populate: populateSchema.optional(),
788
1675
  tasks: tasksSchema.optional()
789
1676
  }).passthrough();
790
- var rootModelCreateOptionsSchema = import_zod4.z.object({
791
- skim: import_zod4.z.boolean().optional(),
792
- includePermissions: import_zod4.z.boolean().optional(),
793
- populateAccess: import_zod4.z.unknown().optional()
1677
+ var rootModelCreateOptionsSchema = import_zod5.z.object({
1678
+ skim: import_zod5.z.boolean().optional(),
1679
+ includePermissions: import_zod5.z.boolean().optional(),
1680
+ populateAccess: import_zod5.z.unknown().optional()
794
1681
  }).passthrough();
795
- var rootModelUpdateArgsSchema = import_zod4.z.object({
1682
+ var rootModelUpdateArgsSchema = import_zod5.z.object({
796
1683
  select: projectionSchema.optional(),
797
1684
  populate: populateSchema.optional(),
798
1685
  tasks: tasksSchema.optional()
799
1686
  }).passthrough();
800
- var rootModelUpdateOptionsSchema = import_zod4.z.object({
801
- skim: import_zod4.z.boolean().optional(),
802
- returningAll: import_zod4.z.boolean().optional(),
803
- includePermissions: import_zod4.z.boolean().optional(),
804
- populateAccess: import_zod4.z.unknown().optional()
1687
+ var rootModelUpdateOptionsSchema = import_zod5.z.object({
1688
+ skim: import_zod5.z.boolean().optional(),
1689
+ returningAll: import_zod5.z.boolean().optional(),
1690
+ includePermissions: import_zod5.z.boolean().optional(),
1691
+ populateAccess: import_zod5.z.unknown().optional()
805
1692
  }).passthrough();
806
1693
  var rootModelUpsertArgsSchema = rootModelUpdateArgsSchema;
807
1694
  var rootModelUpsertOptionsSchema = rootModelUpdateOptionsSchema;
808
- var rootModelSubListArgsSchema = import_zod4.z.object({
1695
+ var rootModelSubListArgsSchema = import_zod5.z.object({
809
1696
  select: fieldsSchema.optional()
810
1697
  }).passthrough();
811
- var rootModelSubReadArgsSchema = import_zod4.z.object({
1698
+ var rootModelSubReadArgsSchema = import_zod5.z.object({
812
1699
  select: fieldsSchema.optional(),
813
1700
  populate: subPopulateSchema.optional()
814
1701
  }).passthrough();
815
- var rootModelCountOptionsSchema = import_zod4.z.object({
816
- access: import_zod4.z.unknown().optional()
817
- }).passthrough();
818
- var rootDataListArgsSchema = import_zod4.z.object({
1702
+ var rootModelCountOptionsSchema = import_zod5.z.object({}).strict().optional();
1703
+ var rootDataListArgsSchema = import_zod5.z.object({
819
1704
  select: projectionSchema.optional(),
820
- sort: import_zod4.z.string().optional(),
821
- skip: import_zod4.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
822
- limit: import_zod4.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
823
- page: import_zod4.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
824
- pageSize: import_zod4.z.union([nonNegativeIntegerSchema, positiveIntegerString]).optional()
1705
+ sort: import_zod5.z.string().optional(),
1706
+ skip: import_zod5.z.union([nonNegativeIntegerSchema, nonNegativeIntegerString]).optional(),
1707
+ limit: import_zod5.z.union([positiveIntegerSchema, positiveIntegerString]).optional(),
1708
+ page: import_zod5.z.union([nonNegativeIntegerSchema, nonNegativeIntegerString]).optional(),
1709
+ pageSize: import_zod5.z.union([positiveIntegerSchema, positiveIntegerString]).optional()
825
1710
  }).passthrough();
826
- var rootDataListOptionsSchema = import_zod4.z.object({
827
- includeCount: import_zod4.z.boolean().optional()
1711
+ var rootDataListOptionsSchema = import_zod5.z.object({
1712
+ includeCount: import_zod5.z.boolean().optional()
828
1713
  }).passthrough();
829
- var rootDataReadArgsSchema = import_zod4.z.object({
1714
+ var rootDataReadArgsSchema = import_zod5.z.object({
830
1715
  select: projectionSchema.optional()
831
1716
  }).passthrough();
832
- var rootModelQueryEntrySchema = import_zod4.z.union([
833
- import_zod4.z.object({ ...rootEntryBaseSchema, target: import_zod4.z.literal("model"), op: import_zod4.z.literal("new") }).passthrough(),
834
- import_zod4.z.object({
1717
+ var rootModelNewArgsSchema = import_zod5.z.object({
1718
+ select: projectionSchema.optional()
1719
+ }).passthrough();
1720
+ var rootModelNewOptionsSchema = import_zod5.z.object({
1721
+ skim: import_zod5.z.boolean().optional(),
1722
+ includePermissions: import_zod5.z.boolean().optional()
1723
+ }).passthrough();
1724
+ var rootModelQueryEntrySchema = import_zod5.z.union([
1725
+ import_zod5.z.object({
835
1726
  ...rootEntryBaseSchema,
836
- target: import_zod4.z.literal("model"),
837
- op: import_zod4.z.literal("list"),
1727
+ target: import_zod5.z.literal("model"),
1728
+ op: import_zod5.z.literal("new"),
1729
+ args: rootModelNewArgsSchema.optional(),
1730
+ options: rootModelNewOptionsSchema.optional()
1731
+ }).passthrough(),
1732
+ import_zod5.z.object({
1733
+ ...rootEntryBaseSchema,
1734
+ target: import_zod5.z.literal("model"),
1735
+ op: import_zod5.z.literal("list"),
838
1736
  filter: objectOrArraySchema.optional(),
839
1737
  args: rootModelListArgsSchema.optional(),
840
1738
  options: rootModelListOptionsSchema.optional()
841
1739
  }).passthrough(),
842
- import_zod4.z.object({
1740
+ import_zod5.z.object({
843
1741
  ...rootEntryBaseSchema,
844
- target: import_zod4.z.literal("model"),
845
- op: import_zod4.z.literal("read"),
846
- id: import_zod4.z.string().min(1),
1742
+ target: import_zod5.z.literal("model"),
1743
+ op: import_zod5.z.literal("read"),
1744
+ id: import_zod5.z.string().min(1),
847
1745
  args: rootModelReadArgsSchema.optional(),
848
1746
  options: rootModelReadOptionsSchema.optional()
849
1747
  }).passthrough(),
850
- import_zod4.z.object({
1748
+ import_zod5.z.object({
851
1749
  ...rootEntryBaseSchema,
852
- target: import_zod4.z.literal("model"),
853
- op: import_zod4.z.literal("read"),
1750
+ target: import_zod5.z.literal("model"),
1751
+ op: import_zod5.z.literal("read"),
854
1752
  filter: objectOrArraySchema,
855
1753
  args: rootModelReadFilterArgsSchema.optional(),
856
1754
  options: rootModelReadOptionsSchema.optional()
857
1755
  }).passthrough(),
858
- import_zod4.z.object({
1756
+ import_zod5.z.object({
859
1757
  ...rootEntryBaseSchema,
860
- target: import_zod4.z.literal("model"),
861
- op: import_zod4.z.literal("create"),
862
- data: import_zod4.z.unknown(),
1758
+ target: import_zod5.z.literal("model"),
1759
+ op: import_zod5.z.literal("create"),
1760
+ data: import_zod5.z.unknown(),
863
1761
  args: rootModelCreateArgsSchema.optional(),
864
1762
  options: rootModelCreateOptionsSchema.optional()
865
1763
  }).passthrough(),
866
- import_zod4.z.object({
1764
+ import_zod5.z.object({
867
1765
  ...rootEntryBaseSchema,
868
- target: import_zod4.z.literal("model"),
869
- op: import_zod4.z.literal("update"),
870
- id: import_zod4.z.string().min(1),
871
- data: import_zod4.z.unknown(),
1766
+ target: import_zod5.z.literal("model"),
1767
+ op: import_zod5.z.literal("update"),
1768
+ id: import_zod5.z.string().min(1),
1769
+ data: import_zod5.z.unknown(),
872
1770
  args: rootModelUpdateArgsSchema.optional(),
873
1771
  options: rootModelUpdateOptionsSchema.optional()
874
1772
  }).passthrough(),
875
- import_zod4.z.object({
1773
+ import_zod5.z.object({
876
1774
  ...rootEntryBaseSchema,
877
- target: import_zod4.z.literal("model"),
878
- op: import_zod4.z.literal("upsert"),
879
- data: import_zod4.z.record(import_zod4.z.string(), import_zod4.z.unknown()),
1775
+ target: import_zod5.z.literal("model"),
1776
+ op: import_zod5.z.literal("upsert"),
1777
+ data: import_zod5.z.record(import_zod5.z.string(), import_zod5.z.unknown()),
880
1778
  args: rootModelUpsertArgsSchema.optional(),
881
1779
  options: rootModelUpsertOptionsSchema.optional()
882
1780
  }).passthrough(),
883
- 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(),
884
- import_zod4.z.object({
1781
+ import_zod5.z.object({ ...rootEntryBaseSchema, target: import_zod5.z.literal("model"), op: import_zod5.z.literal("delete"), id: import_zod5.z.string().min(1) }).passthrough(),
1782
+ import_zod5.z.object({
885
1783
  ...rootEntryBaseSchema,
886
- target: import_zod4.z.literal("model"),
887
- op: import_zod4.z.literal("subList"),
888
- id: import_zod4.z.string().min(1),
889
- sub: import_zod4.z.string().min(1),
890
- filter: import_zod4.z.record(import_zod4.z.string(), import_zod4.z.unknown()).optional(),
1784
+ target: import_zod5.z.literal("model"),
1785
+ op: import_zod5.z.literal("subList"),
1786
+ id: import_zod5.z.string().min(1),
1787
+ sub: import_zod5.z.string().min(1),
1788
+ filter: import_zod5.z.record(import_zod5.z.string(), import_zod5.z.unknown()).optional(),
891
1789
  args: rootModelSubListArgsSchema.optional()
892
1790
  }).passthrough(),
893
- import_zod4.z.object({
1791
+ import_zod5.z.object({
894
1792
  ...rootEntryBaseSchema,
895
- target: import_zod4.z.literal("model"),
896
- op: import_zod4.z.literal("subRead"),
897
- id: import_zod4.z.string().min(1),
898
- sub: import_zod4.z.string().min(1),
899
- subId: import_zod4.z.string().min(1),
1793
+ target: import_zod5.z.literal("model"),
1794
+ op: import_zod5.z.literal("subRead"),
1795
+ id: import_zod5.z.string().min(1),
1796
+ sub: import_zod5.z.string().min(1),
1797
+ subId: import_zod5.z.string().min(1),
900
1798
  args: rootModelSubReadArgsSchema.optional()
901
1799
  }).passthrough(),
902
- import_zod4.z.object({
1800
+ import_zod5.z.object({
903
1801
  ...rootEntryBaseSchema,
904
- target: import_zod4.z.literal("model"),
905
- op: import_zod4.z.literal("subCreate"),
906
- id: import_zod4.z.string().min(1),
907
- sub: import_zod4.z.string().min(1),
908
- 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()))])
1802
+ target: import_zod5.z.literal("model"),
1803
+ op: import_zod5.z.literal("subCreate"),
1804
+ id: import_zod5.z.string().min(1),
1805
+ sub: import_zod5.z.string().min(1),
1806
+ data: import_zod5.z.union([import_zod5.z.record(import_zod5.z.string(), import_zod5.z.unknown()), import_zod5.z.array(import_zod5.z.record(import_zod5.z.string(), import_zod5.z.unknown()))])
909
1807
  }).passthrough(),
910
- import_zod4.z.object({
1808
+ import_zod5.z.object({
911
1809
  ...rootEntryBaseSchema,
912
- target: import_zod4.z.literal("model"),
913
- op: import_zod4.z.literal("subUpdate"),
914
- id: import_zod4.z.string().min(1),
915
- sub: import_zod4.z.string().min(1),
916
- subId: import_zod4.z.string().min(1),
917
- 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()))])
1810
+ target: import_zod5.z.literal("model"),
1811
+ op: import_zod5.z.literal("subUpdate"),
1812
+ id: import_zod5.z.string().min(1),
1813
+ sub: import_zod5.z.string().min(1),
1814
+ subId: import_zod5.z.string().min(1),
1815
+ data: import_zod5.z.union([import_zod5.z.record(import_zod5.z.string(), import_zod5.z.unknown()), import_zod5.z.array(import_zod5.z.record(import_zod5.z.string(), import_zod5.z.unknown()))])
918
1816
  }).passthrough(),
919
- import_zod4.z.object({
1817
+ import_zod5.z.object({
920
1818
  ...rootEntryBaseSchema,
921
- target: import_zod4.z.literal("model"),
922
- op: import_zod4.z.literal("subBulkUpdate"),
923
- id: import_zod4.z.string().min(1),
924
- sub: import_zod4.z.string().min(1),
925
- 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()))])
1819
+ target: import_zod5.z.literal("model"),
1820
+ op: import_zod5.z.literal("subBulkUpdate"),
1821
+ id: import_zod5.z.string().min(1),
1822
+ sub: import_zod5.z.string().min(1),
1823
+ data: import_zod5.z.union([import_zod5.z.record(import_zod5.z.string(), import_zod5.z.unknown()), import_zod5.z.array(import_zod5.z.record(import_zod5.z.string(), import_zod5.z.unknown()))])
926
1824
  }).passthrough(),
927
- import_zod4.z.object({
1825
+ import_zod5.z.object({
928
1826
  ...rootEntryBaseSchema,
929
- target: import_zod4.z.literal("model"),
930
- op: import_zod4.z.literal("subDelete"),
931
- id: import_zod4.z.string().min(1),
932
- sub: import_zod4.z.string().min(1),
933
- subId: import_zod4.z.string().min(1)
1827
+ target: import_zod5.z.literal("model"),
1828
+ op: import_zod5.z.literal("subDelete"),
1829
+ id: import_zod5.z.string().min(1),
1830
+ sub: import_zod5.z.string().min(1),
1831
+ subId: import_zod5.z.string().min(1)
934
1832
  }).passthrough(),
935
- import_zod4.z.object({
1833
+ import_zod5.z.object({
936
1834
  ...rootEntryBaseSchema,
937
- target: import_zod4.z.literal("model"),
938
- op: import_zod4.z.literal("distinct"),
939
- field: import_zod4.z.string().min(1),
1835
+ target: import_zod5.z.literal("model"),
1836
+ op: import_zod5.z.literal("distinct"),
1837
+ field: import_zod5.z.string().min(1),
940
1838
  filter: objectOrArraySchema.optional()
941
1839
  }).passthrough(),
942
- import_zod4.z.object({
1840
+ import_zod5.z.object({
943
1841
  ...rootEntryBaseSchema,
944
- target: import_zod4.z.literal("model"),
945
- op: import_zod4.z.literal("count"),
1842
+ target: import_zod5.z.literal("model"),
1843
+ op: import_zod5.z.literal("count"),
946
1844
  filter: objectOrArraySchema.optional(),
947
1845
  options: rootModelCountOptionsSchema.optional()
948
- }).passthrough()
1846
+ }).passthrough().superRefine((body, ctx) => rejectKeys(body, ctx, ["access"]))
949
1847
  ]);
950
- var rootDataQueryEntrySchema = import_zod4.z.union([
951
- import_zod4.z.object({
1848
+ var rootDataQueryEntrySchema = import_zod5.z.union([
1849
+ import_zod5.z.object({
952
1850
  ...rootEntryBaseSchema,
953
- target: import_zod4.z.literal("data"),
954
- op: import_zod4.z.literal("list"),
1851
+ target: import_zod5.z.literal("data"),
1852
+ op: import_zod5.z.literal("list"),
955
1853
  filter: objectOrArraySchema.optional(),
956
1854
  args: rootDataListArgsSchema.optional(),
957
1855
  options: rootDataListOptionsSchema.optional()
958
1856
  }).passthrough(),
959
- import_zod4.z.object({
1857
+ import_zod5.z.object({
960
1858
  ...rootEntryBaseSchema,
961
- target: import_zod4.z.literal("data"),
962
- op: import_zod4.z.literal("read"),
963
- id: import_zod4.z.string().min(1),
1859
+ target: import_zod5.z.literal("data"),
1860
+ op: import_zod5.z.literal("read"),
1861
+ id: import_zod5.z.string().min(1),
964
1862
  args: rootDataReadArgsSchema.optional()
965
1863
  }).passthrough(),
966
- import_zod4.z.object({
1864
+ import_zod5.z.object({
967
1865
  ...rootEntryBaseSchema,
968
- target: import_zod4.z.literal("data"),
969
- op: import_zod4.z.literal("read"),
1866
+ target: import_zod5.z.literal("data"),
1867
+ op: import_zod5.z.literal("read"),
970
1868
  filter: objectOrArraySchema,
971
1869
  args: rootDataReadArgsSchema.optional()
972
1870
  }).passthrough()
973
1871
  ]);
974
- var rootQuerySchema = import_zod4.z.array(import_zod4.z.union([rootModelQueryEntrySchema, rootDataQueryEntrySchema]));
1872
+ var rootQuerySchema = import_zod5.z.array(import_zod5.z.union([rootModelQueryEntrySchema, rootDataQueryEntrySchema]));
975
1873
  // Annotate the CommonJS export names for ESM import in node:
976
1874
  0 && (module.exports = {
977
1875
  Codes,