@web-ts-toolkit/access-router 0.51.0 → 0.53.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/README.md +1744 -118
- package/advanced.d.mts +1 -4
- package/advanced.d.ts +1 -4
- package/advanced.js +774 -307
- package/advanced.mjs +722 -255
- package/index.d.mts +88 -2
- package/index.d.ts +88 -2
- package/index.js +11011 -7572
- package/index.mjs +11043 -7606
- package/llms.txt +39 -314
- package/package.json +3 -3
- package/{parsers-DhUuvj9B.d.mts → parsers-ZSrF7SNu.d.mts} +2661 -1929
- package/{parsers-DhUuvj9B.d.ts → parsers-ZSrF7SNu.d.ts} +2661 -1929
- package/processors.js +86 -47
- package/processors.mjs +49 -10
package/advanced.mjs
CHANGED
|
@@ -41,10 +41,142 @@ var FilterOperator = /* @__PURE__ */ ((FilterOperator2) => {
|
|
|
41
41
|
})(FilterOperator || {});
|
|
42
42
|
|
|
43
43
|
// src/validation/parsers.ts
|
|
44
|
-
import
|
|
44
|
+
import JsonRouter2 from "@web-ts-toolkit/express-json-router";
|
|
45
45
|
|
|
46
46
|
// src/runtime.ts
|
|
47
47
|
import mongoose from "mongoose";
|
|
48
|
+
|
|
49
|
+
// src/validation/public-admission.ts
|
|
50
|
+
import JsonRouter from "@web-ts-toolkit/express-json-router";
|
|
51
|
+
import { isPlainObject } from "@web-ts-toolkit/utils";
|
|
52
|
+
var privateControls = [
|
|
53
|
+
"authorization",
|
|
54
|
+
"overrides",
|
|
55
|
+
"documentAuthorization",
|
|
56
|
+
"documentAuthorizationStage",
|
|
57
|
+
"execution",
|
|
58
|
+
"executionContext",
|
|
59
|
+
"serviceExecutionContext",
|
|
60
|
+
"resolvedAuthorization",
|
|
61
|
+
"preparedQuery",
|
|
62
|
+
"preparedFilter",
|
|
63
|
+
"preparedModelQuery",
|
|
64
|
+
"resolvedIdentifier",
|
|
65
|
+
"skipParsing",
|
|
66
|
+
"skipAuthorization",
|
|
67
|
+
"alreadyAuthorized",
|
|
68
|
+
"operation"
|
|
69
|
+
];
|
|
70
|
+
var PublicAdmissionError = class extends JsonRouter.clientErrors.BadRequestError {
|
|
71
|
+
constructor(detail) {
|
|
72
|
+
const errors = [{ detail }];
|
|
73
|
+
super("Bad Request", { errors });
|
|
74
|
+
this.result = { success: false, kind: "error", code: "bad_request" /* BadRequest */, errors };
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
function assertPublicAdmission(input, kind = "envelope") {
|
|
78
|
+
const pending = [{ value: input, kind, path: "request" }];
|
|
79
|
+
const seen = /* @__PURE__ */ new WeakMap();
|
|
80
|
+
while (pending.length) {
|
|
81
|
+
const { value, kind: slot, path } = pending.pop();
|
|
82
|
+
if (!value || typeof value !== "object" && typeof value !== "function") continue;
|
|
83
|
+
const kinds = seen.get(value) ?? /* @__PURE__ */ new Set();
|
|
84
|
+
if (kinds.has(slot)) continue;
|
|
85
|
+
kinds.add(slot);
|
|
86
|
+
seen.set(value, kinds);
|
|
87
|
+
const add = (child, childKind, key) => {
|
|
88
|
+
pending.push({ value: child, kind: childKind, path: `${path}.${key}` });
|
|
89
|
+
};
|
|
90
|
+
const record = value;
|
|
91
|
+
if (slot !== "data") {
|
|
92
|
+
for (const key of privateControls) {
|
|
93
|
+
if (key in record) {
|
|
94
|
+
throw new PublicAdmissionError(
|
|
95
|
+
`Unsupported public control ${path}.${key}; use explicit per-call internal service options for backend authorization`
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (Array.isArray(value)) {
|
|
101
|
+
value.forEach((child, index) => add(child, slot, String(index)));
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
if (slot === "data") {
|
|
105
|
+
if (!isPlainObject(value)) continue;
|
|
106
|
+
for (const [key, child] of Object.entries(value)) add(child, key === "$$sq" ? "envelope" : "data", key);
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
for (const key of ["args", "options", "sqOptions"]) add(record[key], "envelope", key);
|
|
110
|
+
add(record.include, "include", "include");
|
|
111
|
+
add(record.populate, "populate", "populate");
|
|
112
|
+
for (const key of ["filter", "match", "data"]) add(record[key], "data", key);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
function assertHydrationDefaults(defaults) {
|
|
116
|
+
if (defaults && typeof defaults === "object") {
|
|
117
|
+
const record = defaults;
|
|
118
|
+
if ("hydration" in record)
|
|
119
|
+
throw new TypeError("defaults.hydration is unsupported; use model hydration configuration");
|
|
120
|
+
for (const bucket of [
|
|
121
|
+
"publicListOptions",
|
|
122
|
+
"publicReadOptions",
|
|
123
|
+
"findOptions",
|
|
124
|
+
"findOneOptions",
|
|
125
|
+
"findByIdOptions",
|
|
126
|
+
"createOptions",
|
|
127
|
+
"updateOneOptions",
|
|
128
|
+
"updateByIdOptions",
|
|
129
|
+
"upsertOptions",
|
|
130
|
+
"existsOptions",
|
|
131
|
+
"publicCreateOptions",
|
|
132
|
+
"publicUpdateOptions"
|
|
133
|
+
]) {
|
|
134
|
+
const options = record[bucket];
|
|
135
|
+
if (!options || typeof options !== "object" && typeof options !== "function") continue;
|
|
136
|
+
for (const key of ["lean", "hydration"]) {
|
|
137
|
+
if (!(key in options)) continue;
|
|
138
|
+
const method = bucket.slice(0, -"Options".length);
|
|
139
|
+
const migration = ["publicList", "publicRead", "find", "findOne", "findById"].includes(method) ? `use model hydration.${method} ('lean' or 'hydrated')` : "this method has a fixed fetch mode";
|
|
140
|
+
throw new TypeError(`defaults.${bucket}.${key} is unsupported; ${migration}`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
function assertPublicDefaults(defaults) {
|
|
146
|
+
assertHydrationDefaults(defaults);
|
|
147
|
+
assertPublicAdmission(defaults);
|
|
148
|
+
if (defaults && typeof defaults === "object") {
|
|
149
|
+
for (const value of Object.values(defaults)) assertPublicAdmission(value);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
var requestAuthorization = Object.freeze({ outputFields: Object.freeze({ mode: "request" }) });
|
|
153
|
+
|
|
154
|
+
// src/options/hydration.ts
|
|
155
|
+
var methods = ["publicList", "publicRead", "find", "findOne", "findById"];
|
|
156
|
+
function normalizeHydration(value, path = "hydration") {
|
|
157
|
+
if (value === void 0) return void 0;
|
|
158
|
+
if (value === null || typeof value !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(value)))
|
|
159
|
+
throw new TypeError(`${path} must be a plain record of model hydration modes`);
|
|
160
|
+
const result = {};
|
|
161
|
+
for (const key of Reflect.ownKeys(value)) {
|
|
162
|
+
if (typeof key !== "string" || !methods.includes(key))
|
|
163
|
+
throw new TypeError(`${path}.${String(key)} is not a supported hydration method`);
|
|
164
|
+
const mode = value[key];
|
|
165
|
+
if (mode !== void 0 && mode !== "lean" && mode !== "hydrated")
|
|
166
|
+
throw new TypeError(`${path}.${key} must be 'lean', 'hydrated', or undefined`);
|
|
167
|
+
result[key] = mode;
|
|
168
|
+
}
|
|
169
|
+
return Object.freeze(result);
|
|
170
|
+
}
|
|
171
|
+
function normalizeHydrationUpdate(current, key, value) {
|
|
172
|
+
if (key === "hydration") return normalizeHydration(value);
|
|
173
|
+
const method = key.slice("hydration.".length);
|
|
174
|
+
if (!methods.includes(method))
|
|
175
|
+
throw new TypeError(`${key} is not a supported hydration method`);
|
|
176
|
+
return normalizeHydration({ ...normalizeHydration(current), [method]: value });
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// src/runtime.ts
|
|
48
180
|
import mschema2Jsonschema from "mongoose-schema-jsonschema";
|
|
49
181
|
import {
|
|
50
182
|
addLeadingSlash,
|
|
@@ -54,15 +186,15 @@ import {
|
|
|
54
186
|
isBoolean,
|
|
55
187
|
isFunction,
|
|
56
188
|
isNil as isNil2,
|
|
57
|
-
isPlainObject as
|
|
189
|
+
isPlainObject as isPlainObject10,
|
|
58
190
|
isString as isString3,
|
|
59
191
|
keys,
|
|
60
192
|
normalizeUrlPath,
|
|
61
|
-
set as
|
|
193
|
+
set as set3
|
|
62
194
|
} from "@web-ts-toolkit/utils";
|
|
63
195
|
|
|
64
196
|
// src/helpers/query.ts
|
|
65
|
-
import { flattenDeep, isNil, isPlainObject, isString, reduce } from "@web-ts-toolkit/utils";
|
|
197
|
+
import { flattenDeep, isNil, isPlainObject as isPlainObject2, isString, reduce } from "@web-ts-toolkit/utils";
|
|
66
198
|
var DEFAULT_LIST_HARD_LIMIT = 1e3;
|
|
67
199
|
|
|
68
200
|
// src/helpers/sort-policy.ts
|
|
@@ -72,14 +204,14 @@ function isValidFieldPath(field) {
|
|
|
72
204
|
}
|
|
73
205
|
|
|
74
206
|
// src/helpers/index.ts
|
|
75
|
-
import { forEach, isArray, isEmpty, isObject, isPlainObject as
|
|
207
|
+
import { forEach, isArray, isEmpty, isObject, isPlainObject as isPlainObject4, isString as isString2 } from "@web-ts-toolkit/utils";
|
|
76
208
|
|
|
77
209
|
// src/lib.ts
|
|
78
210
|
import { Document, Schema } from "mongoose";
|
|
79
|
-
import { isPlainObject as
|
|
211
|
+
import { isPlainObject as isPlainObject3 } from "@web-ts-toolkit/utils";
|
|
80
212
|
var isSchema = (val) => val instanceof Schema;
|
|
81
213
|
var isObjectIdType = (val) => val === "ObjectId" || val === Schema.Types.ObjectId;
|
|
82
|
-
var isReference = (val) =>
|
|
214
|
+
var isReference = (val) => isPlainObject3(val) && !!val.ref && isObjectIdType(val.type);
|
|
83
215
|
|
|
84
216
|
// src/helpers/index.ts
|
|
85
217
|
function recurseObject(obj) {
|
|
@@ -109,7 +241,7 @@ function buildRefs(schema) {
|
|
|
109
241
|
}
|
|
110
242
|
const target = isObject(val) && "type" in val ? val.type ?? val : val;
|
|
111
243
|
if (isArray(target) && target.length > 0) {
|
|
112
|
-
if (isSchema(target[0]) ||
|
|
244
|
+
if (isSchema(target[0]) || isPlainObject4(target[0])) {
|
|
113
245
|
return;
|
|
114
246
|
}
|
|
115
247
|
}
|
|
@@ -122,7 +254,7 @@ function buildSubPaths(schema) {
|
|
|
122
254
|
forEach(schema, (val, key) => {
|
|
123
255
|
const target = isObject(val) && "type" in val ? val.type ?? val : val;
|
|
124
256
|
if (isArray(target) && target.length > 0) {
|
|
125
|
-
if (isSchema(target[0]) ||
|
|
257
|
+
if (isSchema(target[0]) || isPlainObject4(target[0]) && !isReference(target[0])) {
|
|
126
258
|
subPaths.push(key);
|
|
127
259
|
}
|
|
128
260
|
}
|
|
@@ -131,7 +263,7 @@ function buildSubPaths(schema) {
|
|
|
131
263
|
}
|
|
132
264
|
|
|
133
265
|
// src/openapi/build-spec.ts
|
|
134
|
-
import { isArray as isArray2, isPlainObject as
|
|
266
|
+
import { isArray as isArray2, isPlainObject as isPlainObject6 } from "@web-ts-toolkit/utils";
|
|
135
267
|
|
|
136
268
|
// src/openapi/responses.ts
|
|
137
269
|
var json = (schema) => ({
|
|
@@ -202,19 +334,19 @@ var openApiResponses = {
|
|
|
202
334
|
|
|
203
335
|
// src/openapi/schemas.ts
|
|
204
336
|
import { z } from "zod";
|
|
205
|
-
import { isPlainObject as
|
|
337
|
+
import { isPlainObject as isPlainObject5 } from "@web-ts-toolkit/utils";
|
|
206
338
|
var fallbackObjectSchema = { type: "object", additionalProperties: true };
|
|
207
339
|
function isOpenApiSchemaPatch(source) {
|
|
208
|
-
return
|
|
340
|
+
return isPlainObject5(source) && source.kind === "objectProperties";
|
|
209
341
|
}
|
|
210
342
|
function isOpenApiSchemaResolver(source) {
|
|
211
|
-
return
|
|
343
|
+
return isPlainObject5(source) && source.kind === "schemaResolver" && typeof source.resolve === "function";
|
|
212
344
|
}
|
|
213
345
|
function isJsonSchemaLike(source) {
|
|
214
|
-
return
|
|
346
|
+
return isPlainObject5(source) && ("type" in source || "properties" in source || "$ref" in source || "anyOf" in source);
|
|
215
347
|
}
|
|
216
348
|
function hasOpenApiSchema(source) {
|
|
217
|
-
return
|
|
349
|
+
return isPlainObject5(source) && isJsonSchemaLike(source.openapi);
|
|
218
350
|
}
|
|
219
351
|
function toOpenApiSchema(source) {
|
|
220
352
|
if (!source) return void 0;
|
|
@@ -222,7 +354,7 @@ function toOpenApiSchema(source) {
|
|
|
222
354
|
if (!resolvedSource) return void 0;
|
|
223
355
|
if (isOpenApiSchemaPatch(resolvedSource)) {
|
|
224
356
|
const schema = toOpenApiSchema(resolvedSource.source) ?? { ...fallbackObjectSchema };
|
|
225
|
-
const properties =
|
|
357
|
+
const properties = isPlainObject5(schema.properties) ? { ...schema.properties } : {};
|
|
226
358
|
for (const [key, value] of Object.entries(resolvedSource.properties)) {
|
|
227
359
|
properties[key] = toOpenApiSchema(value) ?? fallbackObjectSchema;
|
|
228
360
|
}
|
|
@@ -255,7 +387,7 @@ var toOpenApiPath = (path) => normalizePath(path).replace(/:([A-Za-z0-9_]+)/g, "
|
|
|
255
387
|
var schemaToQueryParameters = (schema) => {
|
|
256
388
|
const jsonSchema = toOpenApiSchema(schema);
|
|
257
389
|
if (!jsonSchema || jsonSchema.type !== "object") return [];
|
|
258
|
-
const properties =
|
|
390
|
+
const properties = isPlainObject6(jsonSchema.properties) ? jsonSchema.properties : {};
|
|
259
391
|
const required = new Set(
|
|
260
392
|
isArray2(jsonSchema.required) ? jsonSchema.required.filter((item) => typeof item === "string") : []
|
|
261
393
|
);
|
|
@@ -348,7 +480,7 @@ var OpenApiCollisionError = class extends Error {
|
|
|
348
480
|
};
|
|
349
481
|
|
|
350
482
|
// src/openapi/registry.ts
|
|
351
|
-
var
|
|
483
|
+
var isPlainObject7 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
352
484
|
var stableKey = (value) => {
|
|
353
485
|
if (value === null || typeof value === "undefined") return "null";
|
|
354
486
|
if (typeof value === "function") return "[Function]";
|
|
@@ -383,7 +515,7 @@ var OpenApiRegistry = class {
|
|
|
383
515
|
this.routes[existingIndex] = route;
|
|
384
516
|
return;
|
|
385
517
|
}
|
|
386
|
-
if (descriptorsEqual(existing, route) && (route.idempotent ||
|
|
518
|
+
if (descriptorsEqual(existing, route) && (route.idempotent || isPlainObject7(existing) && existing.idempotent)) {
|
|
387
519
|
return;
|
|
388
520
|
}
|
|
389
521
|
if (this.options.rejectConflicts) {
|
|
@@ -472,7 +604,7 @@ var defaultLogger = createLogger({
|
|
|
472
604
|
});
|
|
473
605
|
|
|
474
606
|
// src/options/manager.ts
|
|
475
|
-
import { assign, get, isPlainObject as
|
|
607
|
+
import { assign, get, isPlainObject as isPlainObject8, set } from "@web-ts-toolkit/utils";
|
|
476
608
|
var toPath = (key) => {
|
|
477
609
|
if (Array.isArray(key)) return key;
|
|
478
610
|
return typeof key === "string" ? key.split(".") : [key];
|
|
@@ -533,19 +665,20 @@ var freezeConfigValue = (value) => {
|
|
|
533
665
|
return value;
|
|
534
666
|
};
|
|
535
667
|
var cloneAndFreezeForStore = (value) => freezeConfigValue(cloneForRead(value));
|
|
536
|
-
var getNestedOption = (manager, key, defaultValue) =>
|
|
537
|
-
|
|
668
|
+
var getNestedOption = (manager, key, defaultValue) => resolveNestedOption((path, fallback) => manager.get(path, fallback), String(key), defaultValue);
|
|
669
|
+
var resolveNestedOption = (read, key, defaultValue) => {
|
|
670
|
+
const keys2 = key.split(".");
|
|
538
671
|
if (keys2.length === 1) {
|
|
539
|
-
return
|
|
672
|
+
return read(key, defaultValue);
|
|
540
673
|
}
|
|
541
|
-
let option =
|
|
674
|
+
let option = read(key);
|
|
542
675
|
if (option !== void 0) {
|
|
543
676
|
return option;
|
|
544
677
|
}
|
|
545
678
|
const parentKey = keys2.slice(0, -1).join(".");
|
|
546
|
-
option =
|
|
679
|
+
option = read(`${parentKey}.default`);
|
|
547
680
|
if (option === void 0) {
|
|
548
|
-
option =
|
|
681
|
+
option = read(parentKey, defaultValue);
|
|
549
682
|
}
|
|
550
683
|
return option;
|
|
551
684
|
};
|
|
@@ -588,7 +721,7 @@ var OptionsManager = class {
|
|
|
588
721
|
}
|
|
589
722
|
const [rootKey, ...nestedPath] = path;
|
|
590
723
|
const currentRoot = get(this.currentOptions, [rootKey], void 0);
|
|
591
|
-
const baseRoot =
|
|
724
|
+
const baseRoot = isPlainObject8(currentRoot) ? currentRoot : {};
|
|
592
725
|
const nextRoot = cloneConfigValue(baseRoot);
|
|
593
726
|
set(nextRoot, nestedPath, cloneForRead(value));
|
|
594
727
|
set(this.currentOptions, [rootKey], freezeConfigValue(nextRoot));
|
|
@@ -642,8 +775,226 @@ var OptionsManager = class {
|
|
|
642
775
|
}
|
|
643
776
|
};
|
|
644
777
|
|
|
778
|
+
// src/options/data-manager.ts
|
|
779
|
+
import { set as set2 } from "@web-ts-toolkit/utils";
|
|
780
|
+
|
|
781
|
+
// src/options/data-values.ts
|
|
782
|
+
import { types } from "util";
|
|
783
|
+
var typedArrays = [
|
|
784
|
+
Int8Array,
|
|
785
|
+
Uint8Array,
|
|
786
|
+
Uint8ClampedArray,
|
|
787
|
+
Int16Array,
|
|
788
|
+
Uint16Array,
|
|
789
|
+
Int32Array,
|
|
790
|
+
Uint32Array,
|
|
791
|
+
Float32Array,
|
|
792
|
+
Float64Array,
|
|
793
|
+
BigInt64Array,
|
|
794
|
+
BigUint64Array
|
|
795
|
+
];
|
|
796
|
+
var unsupported = (path, reason) => {
|
|
797
|
+
throw new TypeError(`Unsupported data value at ${path}: ${reason}`);
|
|
798
|
+
};
|
|
799
|
+
var isPlainContainer = (value) => {
|
|
800
|
+
const prototype = Object.getPrototypeOf(value);
|
|
801
|
+
return prototype === Object.prototype || prototype === null || prototype === Array.prototype;
|
|
802
|
+
};
|
|
803
|
+
var defineValue = (target, key, value) => {
|
|
804
|
+
Object.defineProperty(target, key, { value, enumerable: true, configurable: true, writable: true });
|
|
805
|
+
};
|
|
806
|
+
var assertNativeProperties = (value, path, allowed = () => false) => {
|
|
807
|
+
for (const key of Reflect.ownKeys(value)) {
|
|
808
|
+
if (typeof key !== "string" || !allowed(key)) unsupported(path, "custom native properties are not supported");
|
|
809
|
+
}
|
|
810
|
+
};
|
|
811
|
+
var copyBytes = (buffer, path, start = 0, end) => {
|
|
812
|
+
if (!types.isArrayBuffer(buffer) || Object.getPrototypeOf(buffer) !== ArrayBuffer.prototype) {
|
|
813
|
+
return unsupported(path, "binary storage must be a fixed, non-shared ArrayBuffer");
|
|
814
|
+
}
|
|
815
|
+
assertNativeProperties(buffer, path);
|
|
816
|
+
if (buffer.resizable) {
|
|
817
|
+
return unsupported(path, "resizable binary storage is not supported");
|
|
818
|
+
}
|
|
819
|
+
try {
|
|
820
|
+
return ArrayBuffer.prototype.slice.call(buffer, start, end);
|
|
821
|
+
} catch {
|
|
822
|
+
return unsupported(path, "detached binary storage is not supported");
|
|
823
|
+
}
|
|
824
|
+
};
|
|
825
|
+
function copyValue(input, freezePlain, rootPath) {
|
|
826
|
+
const copies = /* @__PURE__ */ new WeakMap();
|
|
827
|
+
const active = /* @__PURE__ */ new WeakSet();
|
|
828
|
+
const visit = (value, path) => {
|
|
829
|
+
if (typeof value === "function" || typeof value === "symbol") {
|
|
830
|
+
return unsupported(path, `${typeof value} values are not supported`);
|
|
831
|
+
}
|
|
832
|
+
if (value === null || typeof value !== "object") return value;
|
|
833
|
+
if (types.isProxy(value)) return unsupported(path, "proxies are not supported");
|
|
834
|
+
if (active.has(value)) return unsupported(path, "cycles are not supported");
|
|
835
|
+
const previous = copies.get(value);
|
|
836
|
+
if (previous) return previous;
|
|
837
|
+
active.add(value);
|
|
838
|
+
try {
|
|
839
|
+
const prototype = Object.getPrototypeOf(value);
|
|
840
|
+
if (isPlainContainer(value)) {
|
|
841
|
+
const array = Array.isArray(value);
|
|
842
|
+
if (array && prototype !== Array.prototype) return unsupported(path, "unsupported array prototype");
|
|
843
|
+
if (prototype === Array.prototype && !array) return unsupported(path, "unsupported object prototype");
|
|
844
|
+
if (Object.getOwnPropertySymbols(value).length) return unsupported(path, "symbol keys are not supported");
|
|
845
|
+
const output2 = array ? new Array(value.length) : Object.create(prototype);
|
|
846
|
+
copies.set(value, output2);
|
|
847
|
+
for (const key of Object.keys(value)) {
|
|
848
|
+
const childPath = array ? `${path}[${key}]` : `${path}.${key}`;
|
|
849
|
+
defineValue(output2, key, visit(value[key], childPath));
|
|
850
|
+
}
|
|
851
|
+
return freezePlain ? Object.freeze(output2) : output2;
|
|
852
|
+
}
|
|
853
|
+
let output;
|
|
854
|
+
if (prototype === Date.prototype && types.isDate(value)) {
|
|
855
|
+
assertNativeProperties(value, path);
|
|
856
|
+
output = new Date(Date.prototype.getTime.call(value));
|
|
857
|
+
} else if (prototype === Map.prototype && types.isMap(value)) {
|
|
858
|
+
assertNativeProperties(value, path);
|
|
859
|
+
const map = /* @__PURE__ */ new Map();
|
|
860
|
+
copies.set(value, map);
|
|
861
|
+
let index = 0;
|
|
862
|
+
for (const [key, entry] of Map.prototype.entries.call(value)) {
|
|
863
|
+
map.set(visit(key, `${path}.<key:${index}>`), visit(entry, `${path}.<value:${index}>`));
|
|
864
|
+
index += 1;
|
|
865
|
+
}
|
|
866
|
+
output = map;
|
|
867
|
+
} else if (prototype === Set.prototype && types.isSet(value)) {
|
|
868
|
+
assertNativeProperties(value, path);
|
|
869
|
+
const set4 = /* @__PURE__ */ new Set();
|
|
870
|
+
copies.set(value, set4);
|
|
871
|
+
let index = 0;
|
|
872
|
+
for (const entry of Set.prototype.values.call(value)) {
|
|
873
|
+
set4.add(visit(entry, `${path}.<entry:${index}>`));
|
|
874
|
+
index += 1;
|
|
875
|
+
}
|
|
876
|
+
output = set4;
|
|
877
|
+
} else if (prototype === RegExp.prototype && types.isRegExp(value)) {
|
|
878
|
+
assertNativeProperties(value, path, (key) => key === "lastIndex");
|
|
879
|
+
const regexp = value;
|
|
880
|
+
if (typeof regexp.lastIndex !== "number") return unsupported(path, "RegExp.lastIndex must be a number");
|
|
881
|
+
const copy = new RegExp(regexp.source, regexp.flags);
|
|
882
|
+
copy.lastIndex = regexp.lastIndex;
|
|
883
|
+
output = copy;
|
|
884
|
+
} else if (prototype === ArrayBuffer.prototype) {
|
|
885
|
+
output = copyBytes(value, path);
|
|
886
|
+
} else if (ArrayBuffer.isView(value)) {
|
|
887
|
+
const Type = typedArrays.find((candidate) => candidate.prototype === prototype);
|
|
888
|
+
const buffer = prototype === Buffer.prototype && Buffer.isBuffer(value);
|
|
889
|
+
const dataView = prototype === DataView.prototype;
|
|
890
|
+
if (!Type && !buffer && !dataView) return unsupported(path, "unsupported binary view prototype");
|
|
891
|
+
assertNativeProperties(
|
|
892
|
+
value,
|
|
893
|
+
path,
|
|
894
|
+
(key) => !dataView && /^(0|[1-9]\d*)$/.test(key) && Number(key) < value.length
|
|
895
|
+
);
|
|
896
|
+
let bytes;
|
|
897
|
+
try {
|
|
898
|
+
bytes = copyBytes(value.buffer, path, value.byteOffset, value.byteOffset + value.byteLength);
|
|
899
|
+
} catch (error) {
|
|
900
|
+
if (error instanceof TypeError && error.message.startsWith("Unsupported data value at ")) throw error;
|
|
901
|
+
return unsupported(path, "detached binary storage is not supported");
|
|
902
|
+
}
|
|
903
|
+
output = buffer ? Buffer.from(bytes) : dataView ? new DataView(bytes) : new Type(bytes);
|
|
904
|
+
} else {
|
|
905
|
+
return unsupported(path, "unsupported object prototype");
|
|
906
|
+
}
|
|
907
|
+
copies.set(value, output);
|
|
908
|
+
return output;
|
|
909
|
+
} finally {
|
|
910
|
+
active.delete(value);
|
|
911
|
+
}
|
|
912
|
+
};
|
|
913
|
+
return visit(input, rootPath);
|
|
914
|
+
}
|
|
915
|
+
var copyDataValue = (value) => copyValue(value, false, "data");
|
|
916
|
+
function exposeSnapshot(root) {
|
|
917
|
+
const views = /* @__PURE__ */ new WeakMap();
|
|
918
|
+
const visit = (value) => {
|
|
919
|
+
const previous = views.get(value);
|
|
920
|
+
if (previous) return previous;
|
|
921
|
+
let exposed;
|
|
922
|
+
const keys2 = Object.keys(value);
|
|
923
|
+
const mutableView = () => {
|
|
924
|
+
if (!exposed) {
|
|
925
|
+
exposed = Array.isArray(value) ? new Array(value.length) : Object.create(Object.getPrototypeOf(value));
|
|
926
|
+
for (const key of keys2) defineValue(exposed, key, value[key]);
|
|
927
|
+
}
|
|
928
|
+
return exposed;
|
|
929
|
+
};
|
|
930
|
+
for (const key of keys2) {
|
|
931
|
+
const child = value[key];
|
|
932
|
+
if (child === null || typeof child !== "object") continue;
|
|
933
|
+
if (isPlainContainer(child)) {
|
|
934
|
+
const view2 = visit(child);
|
|
935
|
+
if (view2 !== child) defineValue(mutableView(), key, view2);
|
|
936
|
+
} else {
|
|
937
|
+
Object.defineProperty(mutableView(), key, {
|
|
938
|
+
enumerable: true,
|
|
939
|
+
configurable: true,
|
|
940
|
+
get: () => copyDataValue(child)
|
|
941
|
+
});
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
const view = exposed ? Object.freeze(exposed) : value;
|
|
945
|
+
views.set(value, view);
|
|
946
|
+
return view;
|
|
947
|
+
};
|
|
948
|
+
return visit(root);
|
|
949
|
+
}
|
|
950
|
+
var emptyDataSnapshot = Object.freeze([]);
|
|
951
|
+
var ownedSnapshots = new WeakMap([[emptyDataSnapshot, emptyDataSnapshot]]);
|
|
952
|
+
function createDataSnapshot(data) {
|
|
953
|
+
if (data === void 0) return void 0;
|
|
954
|
+
if (!Array.isArray(data) || types.isProxy(data) || Object.getPrototypeOf(data) !== Array.prototype) {
|
|
955
|
+
return unsupported("data", "expected an ordinary array or undefined");
|
|
956
|
+
}
|
|
957
|
+
if (ownedSnapshots.has(data)) return data;
|
|
958
|
+
const owned = copyValue(data, true, "data");
|
|
959
|
+
const exposed = exposeSnapshot(owned);
|
|
960
|
+
ownedSnapshots.set(exposed, owned);
|
|
961
|
+
return exposed;
|
|
962
|
+
}
|
|
963
|
+
function getOwnedDataSnapshot(snapshot = emptyDataSnapshot) {
|
|
964
|
+
const owned = ownedSnapshots.get(snapshot);
|
|
965
|
+
if (!owned) throw new TypeError("DataService requires an admitted data snapshot");
|
|
966
|
+
return owned;
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
// src/options/data-manager.ts
|
|
970
|
+
var admitData = (options) => {
|
|
971
|
+
if (!Object.hasOwn(options, "data")) return options;
|
|
972
|
+
const { data, ...otherOptions } = options;
|
|
973
|
+
return { ...otherOptions, data: createDataSnapshot(data) };
|
|
974
|
+
};
|
|
975
|
+
var DataOptionsManager = class extends OptionsManager {
|
|
976
|
+
assign(options) {
|
|
977
|
+
super.assign(admitData(options));
|
|
978
|
+
}
|
|
979
|
+
set(key, value) {
|
|
980
|
+
const path = String(key);
|
|
981
|
+
if (path === "data") {
|
|
982
|
+
super.set("data", createDataSnapshot(value));
|
|
983
|
+
} else if (path.startsWith("data.")) {
|
|
984
|
+
const next = copyDataValue(getOwnedDataSnapshot(super.get("data")));
|
|
985
|
+
set2(next, path.slice("data.".length), value);
|
|
986
|
+
super.set("data", createDataSnapshot(next));
|
|
987
|
+
} else {
|
|
988
|
+
super.set(key, value);
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
restore(snapshot) {
|
|
992
|
+
super.restore(admitData(snapshot));
|
|
993
|
+
}
|
|
994
|
+
};
|
|
995
|
+
|
|
645
996
|
// src/request-complexity.ts
|
|
646
|
-
import { isArray as isArray3, isPlainObject as
|
|
997
|
+
import { isArray as isArray3, isPlainObject as isPlainObject9 } from "@web-ts-toolkit/utils";
|
|
647
998
|
var defaultRequestComplexity = {
|
|
648
999
|
maxDepth: 8,
|
|
649
1000
|
maxNodes: 500,
|
|
@@ -729,7 +1080,7 @@ function validateRequestComplexity(value, options, scope = "request") {
|
|
|
729
1080
|
}
|
|
730
1081
|
return;
|
|
731
1082
|
}
|
|
732
|
-
if (!
|
|
1083
|
+
if (!isPlainObject9(current)) return;
|
|
733
1084
|
for (const [key, child] of Object.entries(current)) {
|
|
734
1085
|
if (key === "__proto__" || key === "prototype" || key === "constructor") {
|
|
735
1086
|
pushError(`Unsupported key: ${key}`, path.concat(key));
|
|
@@ -808,7 +1159,7 @@ var classifyPermissionSchema = (permissionSchema, modelPermissionPrefix) => {
|
|
|
808
1159
|
const modelPermissionKeys = {};
|
|
809
1160
|
forEach2(schemaKeys, (schemaKey) => {
|
|
810
1161
|
const schemaRule = permissionSchema[schemaKey];
|
|
811
|
-
const ruleEntries =
|
|
1162
|
+
const ruleEntries = isPlainObject10(schemaRule) ? Object.entries(schemaRule) : FIELD_ACCESS_KEYS.map((accessKey) => [accessKey, schemaRule]);
|
|
812
1163
|
for (let x = 0; x < ruleEntries.length; x++) {
|
|
813
1164
|
const [accessKey, value] = ruleEntries[x];
|
|
814
1165
|
if (!isArray4(globalPermissionKeys[accessKey])) {
|
|
@@ -849,13 +1200,13 @@ var VIRTUAL_UNSUPPORTED_ACCESSES = ["delete", "distinct", "count"];
|
|
|
849
1200
|
var VIRTUAL_RESERVED_NAMES = /* @__PURE__ */ new Set(["_id", "__v", "id"]);
|
|
850
1201
|
var VIRTUAL_DANGEROUS_SEGMENTS = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
|
|
851
1202
|
var VIRTUAL_NAME_PATTERN = /^[A-Za-z_][A-Za-z0-9_$]*$/;
|
|
852
|
-
var isVirtualContainerValue = (value) =>
|
|
1203
|
+
var isVirtualContainerValue = (value) => isPlainObject10(value) && "sub" in value;
|
|
853
1204
|
var virtualFullPath = (prefix, name) => prefix ? `${prefix}.${name}` : name;
|
|
854
1205
|
var virtualPathsOverlap = (virtualPath, permissionField) => {
|
|
855
1206
|
if (!virtualPath || !permissionField) return false;
|
|
856
1207
|
try {
|
|
857
|
-
if (get2(
|
|
858
|
-
if (get2(
|
|
1208
|
+
if (get2(set3({}, virtualPath, true), permissionField) !== void 0) return true;
|
|
1209
|
+
if (get2(set3({}, permissionField, true), virtualPath) !== void 0) return true;
|
|
859
1210
|
} catch {
|
|
860
1211
|
return false;
|
|
861
1212
|
}
|
|
@@ -944,7 +1295,7 @@ var validateVirtualDependsOn = (dependsOn, entryLabel, storedFields, siblingVirt
|
|
|
944
1295
|
};
|
|
945
1296
|
var validateVirtualLeafValue = (value, entryLabel, storedFields, siblingVirtualNames, sharedDependsOn) => {
|
|
946
1297
|
if (isFunction(value)) return;
|
|
947
|
-
if (!
|
|
1298
|
+
if (!isPlainObject10(value)) {
|
|
948
1299
|
throw new Error(`Virtual ${entryLabel}: descriptor must be a getter function or { get, dependsOn }`);
|
|
949
1300
|
}
|
|
950
1301
|
const record = value;
|
|
@@ -988,7 +1339,7 @@ var validateVirtualsScope = (scope, documentPermissionField) => {
|
|
|
988
1339
|
`Virtual ${scopeLabel}${name}: scope-container must only hold "sub" (embedded container "${name}" is not a virtual-leaf collision)`
|
|
989
1340
|
);
|
|
990
1341
|
}
|
|
991
|
-
if (!
|
|
1342
|
+
if (!isPlainObject10(record2.sub)) {
|
|
992
1343
|
throw new Error(`Virtual ${scopeLabel}${name}: scope-container "sub" must be a plain object`);
|
|
993
1344
|
}
|
|
994
1345
|
continue;
|
|
@@ -999,7 +1350,7 @@ var validateVirtualsScope = (scope, documentPermissionField) => {
|
|
|
999
1350
|
);
|
|
1000
1351
|
}
|
|
1001
1352
|
if (isFunction(raw)) continue;
|
|
1002
|
-
if (!
|
|
1353
|
+
if (!isPlainObject10(raw)) {
|
|
1003
1354
|
throw new Error(
|
|
1004
1355
|
`Virtual ${scopeLabel}${name}: malformed descriptor (expected getter, { get, dependsOn }, or per-access record)`
|
|
1005
1356
|
);
|
|
@@ -1007,7 +1358,7 @@ var validateVirtualsScope = (scope, documentPermissionField) => {
|
|
|
1007
1358
|
const record = raw;
|
|
1008
1359
|
const hasGet = "get" in record;
|
|
1009
1360
|
const accessKeys = Object.keys(record).filter((k) => VIRTUAL_SUPPORTED_ACCESSES.includes(k));
|
|
1010
|
-
const
|
|
1361
|
+
const unsupported2 = Object.keys(record).filter(
|
|
1011
1362
|
(k) => k !== "get" && k !== "dependsOn" && k !== "sub" && !VIRTUAL_SUPPORTED_ACCESSES.includes(k)
|
|
1012
1363
|
);
|
|
1013
1364
|
for (const key of Object.keys(record)) {
|
|
@@ -1017,9 +1368,9 @@ var validateVirtualsScope = (scope, documentPermissionField) => {
|
|
|
1017
1368
|
);
|
|
1018
1369
|
}
|
|
1019
1370
|
}
|
|
1020
|
-
if (
|
|
1371
|
+
if (unsupported2.length > 0) {
|
|
1021
1372
|
throw new Error(
|
|
1022
|
-
`Virtual ${scopeLabel}${name}: unsupported access/key "${
|
|
1373
|
+
`Virtual ${scopeLabel}${name}: unsupported access/key "${unsupported2[0]}" (supported: default + list/create/read/update)`
|
|
1023
1374
|
);
|
|
1024
1375
|
}
|
|
1025
1376
|
if (hasGet) {
|
|
@@ -1053,7 +1404,7 @@ var validateVirtualsScope = (scope, documentPermissionField) => {
|
|
|
1053
1404
|
};
|
|
1054
1405
|
var validateVirtualsTree = (model, virtuals, documentPermissionField, modelName) => {
|
|
1055
1406
|
if (virtuals === void 0 || virtuals === null) return;
|
|
1056
|
-
if (!
|
|
1407
|
+
if (!isPlainObject10(virtuals)) {
|
|
1057
1408
|
throw new Error(`Virtuals for model "${modelName}": virtuals must be a plain object mapping names to descriptors`);
|
|
1058
1409
|
}
|
|
1059
1410
|
const rootSchema = model?.schema ?? null;
|
|
@@ -1100,25 +1451,25 @@ var validateVirtualsTree = (model, virtuals, documentPermissionField, modelName)
|
|
|
1100
1451
|
visitContainers(rootVirtuals, rootSchema, "");
|
|
1101
1452
|
};
|
|
1102
1453
|
var getScopeVirtualsObject = (rootVirtuals, scopePath) => {
|
|
1103
|
-
if (!rootVirtuals || !
|
|
1454
|
+
if (!rootVirtuals || !isPlainObject10(rootVirtuals)) return null;
|
|
1104
1455
|
if (!scopePath || scopePath.length === 0) return rootVirtuals;
|
|
1105
1456
|
let current = rootVirtuals;
|
|
1106
1457
|
for (let i = 0; i < scopePath.length; i += 2) {
|
|
1107
1458
|
const field = scopePath[i];
|
|
1108
1459
|
const subMarker = scopePath[i + 1];
|
|
1109
1460
|
if (!field || subMarker !== "sub") return null;
|
|
1110
|
-
if (!
|
|
1461
|
+
if (!isPlainObject10(current)) return null;
|
|
1111
1462
|
const container = current[field];
|
|
1112
1463
|
if (!isVirtualContainerValue(container)) return null;
|
|
1113
1464
|
current = container.sub;
|
|
1114
|
-
if (!
|
|
1465
|
+
if (!isPlainObject10(current)) return null;
|
|
1115
1466
|
}
|
|
1116
1467
|
return current;
|
|
1117
1468
|
};
|
|
1118
1469
|
var toVirtualDescriptor = (leaf, sharedDependsOn) => {
|
|
1119
1470
|
if (isFunction(leaf))
|
|
1120
1471
|
return { get: leaf, dependsOn: sharedDependsOn ?? [] };
|
|
1121
|
-
if (!
|
|
1472
|
+
if (!isPlainObject10(leaf)) return null;
|
|
1122
1473
|
const record = leaf;
|
|
1123
1474
|
if (!isFunction(record.get)) return null;
|
|
1124
1475
|
const dependsOn = record.dependsOn ?? sharedDependsOn ?? [];
|
|
@@ -1301,6 +1652,7 @@ var AccessRuntime = class {
|
|
|
1301
1652
|
Object.assign(this.modelAtts, snapshot.modelAtts);
|
|
1302
1653
|
this.openApiRegistry.restore(snapshot.openApi);
|
|
1303
1654
|
}
|
|
1655
|
+
/** Shallowly replace supplied global values; nested objects such as requestComplexity are not deep-merged. */
|
|
1304
1656
|
setGlobalOptions(options) {
|
|
1305
1657
|
this.globalOptions.assign(options);
|
|
1306
1658
|
}
|
|
@@ -1313,10 +1665,27 @@ var AccessRuntime = class {
|
|
|
1313
1665
|
getGlobalOption(key, defaultValue) {
|
|
1314
1666
|
return this.globalOptions.get(key, defaultValue);
|
|
1315
1667
|
}
|
|
1668
|
+
/** Update model starting defaults shallowly; already-stored model values are not broadcast-replaced. */
|
|
1316
1669
|
setDefaultModelOptions(options) {
|
|
1670
|
+
assertPublicDefaults(options.defaults);
|
|
1671
|
+
if ("hydration" in options) options = { ...options, hydration: normalizeHydration(options.hydration) };
|
|
1317
1672
|
this.defaultModelOptions.assign(options);
|
|
1318
1673
|
}
|
|
1319
1674
|
setDefaultModelOption(key, value) {
|
|
1675
|
+
const keyStr = String(key);
|
|
1676
|
+
if (keyStr === "hydration" || keyStr.startsWith("hydration.")) {
|
|
1677
|
+
this.defaultModelOptions.set(
|
|
1678
|
+
"hydration",
|
|
1679
|
+
normalizeHydrationUpdate(this.getDefaultModelOptions().hydration, keyStr, value)
|
|
1680
|
+
);
|
|
1681
|
+
return;
|
|
1682
|
+
}
|
|
1683
|
+
if (keyStr === "defaults") assertPublicDefaults(value);
|
|
1684
|
+
else if (keyStr.startsWith("defaults.")) {
|
|
1685
|
+
const proposed = {};
|
|
1686
|
+
set3(proposed, keyStr.slice("defaults.".length), value);
|
|
1687
|
+
assertPublicDefaults(proposed);
|
|
1688
|
+
}
|
|
1320
1689
|
this.defaultModelOptions.set(key, value);
|
|
1321
1690
|
}
|
|
1322
1691
|
getDefaultModelOptions() {
|
|
@@ -1357,7 +1726,16 @@ var AccessRuntime = class {
|
|
|
1357
1726
|
}
|
|
1358
1727
|
return manager;
|
|
1359
1728
|
}
|
|
1729
|
+
/**
|
|
1730
|
+
* Assign `{ ...modelDefaults, ...storedOptions, ...options }` shallowly. A supplied
|
|
1731
|
+
* operationAccess/defaults object replaces that whole value. Defaults accept only
|
|
1732
|
+
* query/presentation settings; virtual configuration is validated before assignment.
|
|
1733
|
+
* Existing router.options remains its construction-time snapshot. Fresh model-service
|
|
1734
|
+
* calls capture the owner's current options/defaults; in-flight calls retain their snapshot.
|
|
1735
|
+
*/
|
|
1360
1736
|
setModelOptions(modelName, options) {
|
|
1737
|
+
assertPublicDefaults(options.defaults);
|
|
1738
|
+
if ("hydration" in options) options = { ...options, hydration: normalizeHydration(options.hydration) };
|
|
1361
1739
|
const manager = this.getOrCreateModelOptions(modelName);
|
|
1362
1740
|
const defaultOptions = this.getDefaultModelOptions();
|
|
1363
1741
|
const currentModelOptions = manager.fetch();
|
|
@@ -1368,8 +1746,19 @@ var AccessRuntime = class {
|
|
|
1368
1746
|
manager.assign({ ...defaultOptions, ...currentModelOptions, ...options });
|
|
1369
1747
|
}
|
|
1370
1748
|
setModelOption(modelName, key, value) {
|
|
1371
|
-
const manager = this.getOrCreateModelOptions(modelName);
|
|
1372
1749
|
const keyStr = String(key);
|
|
1750
|
+
if (keyStr === "hydration" || keyStr.startsWith("hydration.")) {
|
|
1751
|
+
const hydration = normalizeHydrationUpdate(this.modelOptions[modelName]?.get("hydration"), keyStr, value);
|
|
1752
|
+
this.getOrCreateModelOptions(modelName).set("hydration", hydration);
|
|
1753
|
+
return;
|
|
1754
|
+
}
|
|
1755
|
+
if (keyStr === "defaults") assertPublicDefaults(value);
|
|
1756
|
+
else if (keyStr.startsWith("defaults.")) {
|
|
1757
|
+
const proposed = {};
|
|
1758
|
+
set3(proposed, keyStr.slice("defaults.".length), value);
|
|
1759
|
+
assertPublicDefaults(proposed);
|
|
1760
|
+
}
|
|
1761
|
+
const manager = this.getOrCreateModelOptions(modelName);
|
|
1373
1762
|
if (keyStr === "virtuals" || keyStr.startsWith("virtuals.") || keyStr === "documentPermissionField") {
|
|
1374
1763
|
const model = this.getModelInstance(modelName);
|
|
1375
1764
|
const currentVirtuals = manager.get("virtuals");
|
|
@@ -1387,15 +1776,15 @@ var AccessRuntime = class {
|
|
|
1387
1776
|
const segments = nestedPath.split(".");
|
|
1388
1777
|
let cursor = cloned;
|
|
1389
1778
|
for (let i = 0; i < segments.length - 1; i++) {
|
|
1390
|
-
if (!
|
|
1779
|
+
if (!isPlainObject10(cursor)) break;
|
|
1391
1780
|
cursor = cursor[segments[i]];
|
|
1392
1781
|
}
|
|
1393
|
-
if (
|
|
1782
|
+
if (isPlainObject10(cursor)) {
|
|
1394
1783
|
delete cursor[segments[segments.length - 1]];
|
|
1395
1784
|
}
|
|
1396
1785
|
proposedVirtuals = cloned;
|
|
1397
1786
|
} else {
|
|
1398
|
-
|
|
1787
|
+
set3(cloned, nestedPath, value);
|
|
1399
1788
|
proposedVirtuals = cloned;
|
|
1400
1789
|
}
|
|
1401
1790
|
}
|
|
@@ -1403,10 +1792,17 @@ var AccessRuntime = class {
|
|
|
1403
1792
|
}
|
|
1404
1793
|
manager.set(key, value);
|
|
1405
1794
|
}
|
|
1795
|
+
/** Frozen stored snapshot, not fully resolved per-path defaults. Read again for current configuration. */
|
|
1406
1796
|
getModelOptions(modelName) {
|
|
1407
1797
|
const manager = this.getOrCreateModelOptions(modelName);
|
|
1408
1798
|
return manager.fetch();
|
|
1409
1799
|
}
|
|
1800
|
+
/**
|
|
1801
|
+
* Generic stored exact → parent.default → parent lookup; only undefined falls through.
|
|
1802
|
+
* The exact runtime-model-default path is the final fallback if the stored parent is
|
|
1803
|
+
* absent. This is not the route-specific variant-to-base resolver; use
|
|
1804
|
+
* getExactModelOption to inspect a variant including its exact model-default fallback.
|
|
1805
|
+
*/
|
|
1410
1806
|
getModelOption(modelName, key, defaultValue) {
|
|
1411
1807
|
const manager = this.getOrCreateModelOptions(modelName);
|
|
1412
1808
|
const defaultModelValue = this.getDefaultModelOption(
|
|
@@ -1415,6 +1811,7 @@ var AccessRuntime = class {
|
|
|
1415
1811
|
);
|
|
1416
1812
|
return getNestedOption(manager, key, defaultModelValue);
|
|
1417
1813
|
}
|
|
1814
|
+
/** Exact stored path, then the same runtime-model-default path; no parent/default or variant-to-base lookup. */
|
|
1418
1815
|
getExactModelOption(modelName, key) {
|
|
1419
1816
|
const manager = this.getOrCreateModelOptions(modelName);
|
|
1420
1817
|
const defaultModelValue = this.getDefaultModelOption(key);
|
|
@@ -1466,7 +1863,7 @@ var AccessRuntime = class {
|
|
|
1466
1863
|
const entry = scopeVirtuals[virtualName];
|
|
1467
1864
|
if (entry === void 0 || isVirtualContainerValue(entry)) return void 0;
|
|
1468
1865
|
if (isFunction(entry)) return { get: entry, dependsOn: [] };
|
|
1469
|
-
if (!
|
|
1866
|
+
if (!isPlainObject10(entry)) return void 0;
|
|
1470
1867
|
const record = entry;
|
|
1471
1868
|
if ("get" in record) {
|
|
1472
1869
|
const descriptor = toVirtualDescriptor(entry, void 0);
|
|
@@ -1495,7 +1892,7 @@ var AccessRuntime = class {
|
|
|
1495
1892
|
return this.modelJsonSchemas[modelName];
|
|
1496
1893
|
}
|
|
1497
1894
|
createDataOptions(dataName) {
|
|
1498
|
-
const manager = new
|
|
1895
|
+
const manager = new DataOptionsManager({
|
|
1499
1896
|
...defaultDataOptions,
|
|
1500
1897
|
dataName
|
|
1501
1898
|
});
|
|
@@ -1527,10 +1924,15 @@ var AccessRuntime = class {
|
|
|
1527
1924
|
const manager = this.getOrCreateDataOptions(dataName);
|
|
1528
1925
|
return manager.fetch();
|
|
1529
1926
|
}
|
|
1927
|
+
/**
|
|
1928
|
+
* Reusable configured data view: plain containers are frozen; native properties
|
|
1929
|
+
* return detached mutable copies on access. Native identity is not stable.
|
|
1930
|
+
* Replacement leaves previously captured views on their original data version.
|
|
1931
|
+
*/
|
|
1530
1932
|
getDataSnapshot(dataName) {
|
|
1531
1933
|
const manager = this.getOrCreateDataOptions(dataName);
|
|
1532
1934
|
const snapshot = manager.get("data");
|
|
1533
|
-
return snapshot ??
|
|
1935
|
+
return snapshot ?? emptyDataSnapshot;
|
|
1534
1936
|
}
|
|
1535
1937
|
getDataOption(dataName, key, defaultValue) {
|
|
1536
1938
|
const manager = this.getOrCreateDataOptions(dataName);
|
|
@@ -1590,10 +1992,29 @@ var getGlobalOption = (key, defaultValue) => {
|
|
|
1590
1992
|
|
|
1591
1993
|
// src/validation/common.ts
|
|
1592
1994
|
import { z as z2 } from "zod";
|
|
1593
|
-
import { isPlainObject as
|
|
1995
|
+
import { isPlainObject as isPlainObject12 } from "@web-ts-toolkit/utils";
|
|
1996
|
+
|
|
1997
|
+
// src/validation/public-admission-schema.ts
|
|
1998
|
+
var admissions = /* @__PURE__ */ new WeakMap();
|
|
1999
|
+
function publicBoundarySchema(schema, kind = "envelope") {
|
|
2000
|
+
const checked = schema.superRefine((value, ctx) => {
|
|
2001
|
+
try {
|
|
2002
|
+
assertPublicAdmission(value, kind);
|
|
2003
|
+
} catch (error) {
|
|
2004
|
+
if (!(error instanceof PublicAdmissionError)) throw error;
|
|
2005
|
+
ctx.addIssue({ code: "custom", message: error.result.errors[0].detail });
|
|
2006
|
+
}
|
|
2007
|
+
});
|
|
2008
|
+
admissions.set(checked, kind);
|
|
2009
|
+
return checked;
|
|
2010
|
+
}
|
|
2011
|
+
function assertTransformedPublicAdmission(schema, value) {
|
|
2012
|
+
const kind = admissions.get(schema);
|
|
2013
|
+
if (kind) assertPublicAdmission(value, kind);
|
|
2014
|
+
}
|
|
1594
2015
|
|
|
1595
2016
|
// src/correlated-includes.ts
|
|
1596
|
-
import { cloneDeep, isArray as isArray5, isPlainObject as
|
|
2017
|
+
import { cloneDeep, isArray as isArray5, isPlainObject as isPlainObject11 } from "@web-ts-toolkit/utils";
|
|
1597
2018
|
var PARENT_MARKER_KEY = "$parent";
|
|
1598
2019
|
var ESCAPE_WRAPPER_KEY = "$escape";
|
|
1599
2020
|
var SUBQUERY_PAYLOAD_KEYS = /* @__PURE__ */ new Set(["$$sq", "$$date"]);
|
|
@@ -1604,10 +2025,10 @@ var FIELD_SEGMENT_PATTERN = /^[A-Za-z_][A-Za-z0-9_$]*$/;
|
|
|
1604
2025
|
var ARRAY_INDEX_SEGMENT_PATTERN = /^(0|[1-9]\d*)$/;
|
|
1605
2026
|
var ownKeys = (value) => Object.keys(value);
|
|
1606
2027
|
function isParentRefMarker(value) {
|
|
1607
|
-
return
|
|
2028
|
+
return isPlainObject11(value) && ownKeys(value).length === 1 && ownKeys(value)[0] === PARENT_MARKER_KEY;
|
|
1608
2029
|
}
|
|
1609
2030
|
function isEscapedParentRef(value) {
|
|
1610
|
-
return
|
|
2031
|
+
return isPlainObject11(value) && ownKeys(value).length === 1 && ownKeys(value)[0] === ESCAPE_WRAPPER_KEY;
|
|
1611
2032
|
}
|
|
1612
2033
|
function hasMarkerKey(value) {
|
|
1613
2034
|
return ownKeys(value).includes(PARENT_MARKER_KEY) || ownKeys(value).includes(ESCAPE_WRAPPER_KEY);
|
|
@@ -1631,7 +2052,7 @@ function containsParentMarkerShape(value) {
|
|
|
1631
2052
|
seen.add(current);
|
|
1632
2053
|
return current.some(visit);
|
|
1633
2054
|
}
|
|
1634
|
-
if (
|
|
2055
|
+
if (isPlainObject11(current)) {
|
|
1635
2056
|
if (seen.has(current)) return false;
|
|
1636
2057
|
seen.add(current);
|
|
1637
2058
|
if (hasMarkerKey(current)) return true;
|
|
@@ -1661,7 +2082,7 @@ function scanTemplateValueNode(value, path, issues) {
|
|
|
1661
2082
|
}
|
|
1662
2083
|
return;
|
|
1663
2084
|
}
|
|
1664
|
-
if (
|
|
2085
|
+
if (isPlainObject11(value)) {
|
|
1665
2086
|
if (hasMarkerKey(value)) {
|
|
1666
2087
|
issues.push({
|
|
1667
2088
|
message: 'Malformed $parent reference: objects carrying $parent must be exactly { "$parent": "<field>" }',
|
|
@@ -1726,7 +2147,7 @@ function scanTemplateObjectEntries(obj, basePath, issues) {
|
|
|
1726
2147
|
});
|
|
1727
2148
|
return;
|
|
1728
2149
|
}
|
|
1729
|
-
if (
|
|
2150
|
+
if (isPlainObject11(clause)) {
|
|
1730
2151
|
scanTemplateObjectEntries(clause, clausePath, issues);
|
|
1731
2152
|
}
|
|
1732
2153
|
});
|
|
@@ -1737,7 +2158,7 @@ function scanTemplateObjectEntries(obj, basePath, issues) {
|
|
|
1737
2158
|
}
|
|
1738
2159
|
function validateCorrelatedFilterTemplate(filter) {
|
|
1739
2160
|
const issues = [];
|
|
1740
|
-
if (!
|
|
2161
|
+
if (!isPlainObject11(filter)) {
|
|
1741
2162
|
issues.push({ message: "Correlated include filter must be an object", path: [] });
|
|
1742
2163
|
return issues;
|
|
1743
2164
|
}
|
|
@@ -1784,42 +2205,48 @@ var sortSchema = z2.union([
|
|
|
1784
2205
|
z2.null()
|
|
1785
2206
|
]);
|
|
1786
2207
|
var populateAccessSchema = z2.enum(["list", "read"]);
|
|
1787
|
-
var populateSchema =
|
|
1788
|
-
z2.
|
|
1789
|
-
|
|
1790
|
-
z2.
|
|
1791
|
-
z2.
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
2208
|
+
var populateSchema = publicBoundarySchema(
|
|
2209
|
+
z2.union([
|
|
2210
|
+
z2.string(),
|
|
2211
|
+
z2.array(
|
|
2212
|
+
z2.union([
|
|
2213
|
+
z2.string(),
|
|
2214
|
+
z2.object({
|
|
2215
|
+
path: z2.string().min(1),
|
|
2216
|
+
select: projectionSchema.optional(),
|
|
2217
|
+
match: z2.unknown().optional(),
|
|
2218
|
+
access: populateAccessSchema.optional()
|
|
2219
|
+
}).passthrough()
|
|
2220
|
+
])
|
|
2221
|
+
),
|
|
2222
|
+
z2.object({
|
|
2223
|
+
path: z2.string().min(1),
|
|
2224
|
+
select: projectionSchema.optional(),
|
|
2225
|
+
match: z2.unknown().optional(),
|
|
2226
|
+
access: populateAccessSchema.optional()
|
|
2227
|
+
}).passthrough()
|
|
2228
|
+
]),
|
|
2229
|
+
"populate"
|
|
2230
|
+
);
|
|
2231
|
+
var subPopulateSchema = publicBoundarySchema(
|
|
2232
|
+
z2.union([
|
|
2233
|
+
z2.string(),
|
|
2234
|
+
z2.array(
|
|
2235
|
+
z2.union([
|
|
2236
|
+
z2.string(),
|
|
2237
|
+
z2.object({
|
|
2238
|
+
path: z2.string().min(1),
|
|
2239
|
+
select: projectionSchema.optional()
|
|
2240
|
+
}).passthrough()
|
|
2241
|
+
])
|
|
2242
|
+
),
|
|
2243
|
+
z2.object({
|
|
2244
|
+
path: z2.string().min(1),
|
|
2245
|
+
select: projectionSchema.optional()
|
|
2246
|
+
}).passthrough()
|
|
2247
|
+
]),
|
|
2248
|
+
"populate"
|
|
2249
|
+
);
|
|
1823
2250
|
var legacyIncludeItemSchema = z2.object({
|
|
1824
2251
|
mode: z2.enum(["legacy"]).optional(),
|
|
1825
2252
|
model: z2.string().min(1),
|
|
@@ -1859,7 +2286,7 @@ var correlatedFilterSchema = z2.record(z2.string(), z2.unknown()).superRefine((f
|
|
|
1859
2286
|
}
|
|
1860
2287
|
});
|
|
1861
2288
|
var correlatedEmptyOptionsSchema = z2.unknown().refine(
|
|
1862
|
-
(value) => value === void 0 ||
|
|
2289
|
+
(value) => value === void 0 || isPlainObject12(value) && Object.keys(value).length === 0,
|
|
1863
2290
|
"Correlated include options must be absent or empty"
|
|
1864
2291
|
).optional();
|
|
1865
2292
|
var correlatedPathSchema = z2.string().min(1).superRefine((path, ctx) => {
|
|
@@ -1896,7 +2323,7 @@ var correlatedListArgsSchema = z2.object({
|
|
|
1896
2323
|
include: z2.lazy(() => correlatedNestedIncludeSchema).optional()
|
|
1897
2324
|
}).strict().superRefine((args, ctx) => checkArgsMarkers(args.select, args.sort, ctx));
|
|
1898
2325
|
var correlatedCountArgsSchema = z2.unknown().refine(
|
|
1899
|
-
(value) => value === void 0 ||
|
|
2326
|
+
(value) => value === void 0 || isPlainObject12(value) && Object.keys(value).length === 0,
|
|
1900
2327
|
"Count includes accept no args"
|
|
1901
2328
|
).optional();
|
|
1902
2329
|
var correlatedReadByIdSchema = z2.object({
|
|
@@ -1935,18 +2362,21 @@ var correlatedCountSchema = z2.object({
|
|
|
1935
2362
|
args: correlatedCountArgsSchema,
|
|
1936
2363
|
options: correlatedEmptyOptionsSchema
|
|
1937
2364
|
}).strict();
|
|
1938
|
-
var includeItemSchema =
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
2365
|
+
var includeItemSchema = publicBoundarySchema(
|
|
2366
|
+
z2.union([
|
|
2367
|
+
legacyIncludeItemSchema,
|
|
2368
|
+
correlatedReadByIdSchema,
|
|
2369
|
+
correlatedReadByFilterSchema,
|
|
2370
|
+
correlatedListSchema,
|
|
2371
|
+
correlatedCountSchema
|
|
2372
|
+
]),
|
|
2373
|
+
"include"
|
|
2374
|
+
);
|
|
1945
2375
|
var correlatedNestedIncludeSchema = z2.union([includeItemSchema, z2.array(includeItemSchema)]);
|
|
1946
2376
|
var rejectDuplicateCorrelatedPaths = (items, ctx) => {
|
|
1947
2377
|
const seen = /* @__PURE__ */ new Set();
|
|
1948
2378
|
items.forEach((item, index) => {
|
|
1949
|
-
if (
|
|
2379
|
+
if (isPlainObject12(item) && item.mode === "correlated" && typeof item.path === "string") {
|
|
1950
2380
|
if (seen.has(item.path)) {
|
|
1951
2381
|
ctx.addIssue({
|
|
1952
2382
|
code: z2.ZodIssueCode.custom,
|
|
@@ -1984,7 +2414,7 @@ function rejectKeys(body, ctx, keys2) {
|
|
|
1984
2414
|
}
|
|
1985
2415
|
|
|
1986
2416
|
// src/validation/parsers.ts
|
|
1987
|
-
var clientErrors =
|
|
2417
|
+
var clientErrors = JsonRouter2.clientErrors;
|
|
1988
2418
|
function parsePathParam(value, parameter) {
|
|
1989
2419
|
const result = stringOrStringArray.safeParse(value);
|
|
1990
2420
|
if (!result.success) {
|
|
@@ -1999,6 +2429,7 @@ function parsePathParam(value, parameter) {
|
|
|
1999
2429
|
return param;
|
|
2000
2430
|
}
|
|
2001
2431
|
function parseQuery(schema, value) {
|
|
2432
|
+
assertTransformedPublicAdmission(schema, value);
|
|
2002
2433
|
const complexityErrors = validateRequestComplexity(value, getGlobalOption("requestComplexity"), "request");
|
|
2003
2434
|
if (complexityErrors.length > 0) {
|
|
2004
2435
|
throw new clientErrors.BadRequestError("Bad Request", { errors: complexityErrors });
|
|
@@ -2010,6 +2441,7 @@ function parseQuery(schema, value) {
|
|
|
2010
2441
|
return result.data;
|
|
2011
2442
|
}
|
|
2012
2443
|
function parseBody(schema, value) {
|
|
2444
|
+
assertTransformedPublicAdmission(schema, value);
|
|
2013
2445
|
const complexityErrors = validateRequestComplexity(value ?? {}, getGlobalOption("requestComplexity"), "request");
|
|
2014
2446
|
if (complexityErrors.length > 0) {
|
|
2015
2447
|
throw new clientErrors.BadRequestError("Bad Request", { errors: complexityErrors });
|
|
@@ -2020,17 +2452,22 @@ function parseBody(schema, value) {
|
|
|
2020
2452
|
}
|
|
2021
2453
|
return result.data;
|
|
2022
2454
|
}
|
|
2023
|
-
function parseBodyWithSchema(schema, value, userSchema) {
|
|
2455
|
+
async function parseBodyWithSchema(schema, value, userSchema) {
|
|
2024
2456
|
const body = parseBody(schema, value);
|
|
2025
|
-
|
|
2457
|
+
if (!isRequestSchema(userSchema)) return body;
|
|
2458
|
+
const transformed = await parseUserSchema(userSchema, body);
|
|
2459
|
+
assertTransformedPublicAdmission(schema, transformed);
|
|
2460
|
+
return transformed;
|
|
2026
2461
|
}
|
|
2027
2462
|
async function parseNestedBodyWithSchema(schema, value, nestedKey, userSchema) {
|
|
2028
2463
|
const body = parseBody(schema, value);
|
|
2029
2464
|
if (!isRequestSchema(userSchema)) return body;
|
|
2030
|
-
|
|
2465
|
+
const transformed = {
|
|
2031
2466
|
...body,
|
|
2032
2467
|
[nestedKey]: await parseUserSchema(userSchema, body?.[nestedKey], [nestedKey])
|
|
2033
2468
|
};
|
|
2469
|
+
assertTransformedPublicAdmission(schema, transformed);
|
|
2470
|
+
return transformed;
|
|
2034
2471
|
}
|
|
2035
2472
|
function throwValidationError(issues, key, location = "pointer") {
|
|
2036
2473
|
const errors = issues.map((issue) => formatIssue(issue, key, location));
|
|
@@ -2458,147 +2895,177 @@ function buildPointer(path) {
|
|
|
2458
2895
|
|
|
2459
2896
|
// src/validation/model-router.ts
|
|
2460
2897
|
import { z as z3 } from "zod";
|
|
2461
|
-
var listQuerySchema =
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
var
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
}).passthrough().
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2898
|
+
var listQuerySchema = publicBoundarySchema(
|
|
2899
|
+
z3.object({
|
|
2900
|
+
skip: nonNegativeIntegerString.optional(),
|
|
2901
|
+
limit: positiveIntegerString.optional(),
|
|
2902
|
+
page: nonNegativeIntegerString.optional(),
|
|
2903
|
+
page_size: positiveIntegerString.optional(),
|
|
2904
|
+
skim: queryBooleanString.optional(),
|
|
2905
|
+
include_permissions: queryBooleanString.optional(),
|
|
2906
|
+
include_field_permissions: queryBooleanString.optional(),
|
|
2907
|
+
include_count: queryBooleanString.optional(),
|
|
2908
|
+
include_extra_headers: queryBooleanString.optional(),
|
|
2909
|
+
select: stringOrStringArray.optional(),
|
|
2910
|
+
sort: z3.string().optional().describe("Space-separated sort fields; prefix a field with - for descending order.")
|
|
2911
|
+
}).passthrough()
|
|
2912
|
+
);
|
|
2913
|
+
var createQuerySchema = publicBoundarySchema(
|
|
2914
|
+
z3.object({
|
|
2915
|
+
include_permissions: queryBooleanString.optional(),
|
|
2916
|
+
include_field_permissions: queryBooleanString.optional()
|
|
2917
|
+
}).passthrough()
|
|
2918
|
+
);
|
|
2919
|
+
var readQuerySchema = publicBoundarySchema(
|
|
2920
|
+
z3.object({
|
|
2921
|
+
include_permissions: queryBooleanString.optional(),
|
|
2922
|
+
include_field_permissions: queryBooleanString.optional(),
|
|
2923
|
+
try_list: queryBooleanString.optional(),
|
|
2924
|
+
select: stringOrStringArray.optional()
|
|
2925
|
+
}).passthrough()
|
|
2926
|
+
);
|
|
2927
|
+
var updateQuerySchema = publicBoundarySchema(
|
|
2928
|
+
z3.object({
|
|
2929
|
+
returning_all: queryBooleanString.optional(),
|
|
2930
|
+
include_permissions: queryBooleanString.optional(),
|
|
2931
|
+
include_field_permissions: queryBooleanString.optional(),
|
|
2932
|
+
select: stringOrStringArray.optional()
|
|
2933
|
+
}).passthrough()
|
|
2934
|
+
);
|
|
2935
|
+
var upsertQuerySchema = publicBoundarySchema(
|
|
2936
|
+
z3.object({
|
|
2937
|
+
returning_all: queryBooleanString.optional(),
|
|
2938
|
+
include_permissions: queryBooleanString.optional(),
|
|
2939
|
+
include_field_permissions: queryBooleanString.optional()
|
|
2940
|
+
}).passthrough()
|
|
2941
|
+
);
|
|
2942
|
+
var listBodySchema = publicBoundarySchema(
|
|
2943
|
+
z3.object({
|
|
2944
|
+
filter: objectOrArraySchema.optional(),
|
|
2945
|
+
select: projectionSchema.optional(),
|
|
2946
|
+
sort: sortSchema.optional(),
|
|
2947
|
+
populate: populateSchema.optional(),
|
|
2948
|
+
include: includeSchema.optional(),
|
|
2949
|
+
tasks: tasksSchema.optional(),
|
|
2950
|
+
skip: z3.union([nonNegativeIntegerSchema, nonNegativeIntegerString]).optional(),
|
|
2951
|
+
limit: z3.union([positiveIntegerSchema, positiveIntegerString]).optional(),
|
|
2952
|
+
page: z3.union([nonNegativeIntegerSchema, nonNegativeIntegerString]).optional(),
|
|
2953
|
+
pageSize: z3.union([positiveIntegerSchema, positiveIntegerString]).optional(),
|
|
2954
|
+
options: z3.object({
|
|
2955
|
+
skim: z3.boolean().optional(),
|
|
2956
|
+
includePermissions: z3.boolean().optional(),
|
|
2957
|
+
includeFieldPermissions: z3.boolean().optional(),
|
|
2958
|
+
includeCount: z3.boolean().optional(),
|
|
2959
|
+
includeExtraHeaders: z3.boolean().optional(),
|
|
2960
|
+
populateAccess: populateAccessSchema.optional()
|
|
2961
|
+
}).passthrough().optional()
|
|
2962
|
+
}).passthrough().superRefine((body, ctx) => rejectKeys(body, ctx, ["query"]))
|
|
2963
|
+
);
|
|
2964
|
+
var countBodySchema = publicBoundarySchema(
|
|
2965
|
+
z3.object({
|
|
2966
|
+
filter: objectOrArraySchema.optional()
|
|
2967
|
+
}).passthrough().superRefine((body, ctx) => rejectKeys(body, ctx, ["query", "access", "options", "include"]))
|
|
2968
|
+
);
|
|
2969
|
+
var readFilterBodySchema = publicBoundarySchema(
|
|
2970
|
+
z3.object({
|
|
2971
|
+
filter: objectOrArraySchema.optional(),
|
|
2972
|
+
select: projectionSchema.optional(),
|
|
2973
|
+
sort: sortSchema.optional(),
|
|
2974
|
+
populate: populateSchema.optional(),
|
|
2975
|
+
include: includeSchema.optional(),
|
|
2976
|
+
tasks: tasksSchema.optional(),
|
|
2977
|
+
options: z3.object({
|
|
2978
|
+
skim: z3.boolean().optional(),
|
|
2979
|
+
includePermissions: z3.boolean().optional(),
|
|
2980
|
+
includeFieldPermissions: z3.boolean().optional(),
|
|
2981
|
+
tryList: z3.boolean().optional(),
|
|
2982
|
+
populateAccess: populateAccessSchema.optional()
|
|
2983
|
+
}).passthrough().optional()
|
|
2984
|
+
}).passthrough()
|
|
2985
|
+
);
|
|
2986
|
+
var readByIdBodySchema = publicBoundarySchema(
|
|
2987
|
+
z3.object({
|
|
2988
|
+
select: projectionSchema.optional(),
|
|
2989
|
+
populate: populateSchema.optional(),
|
|
2990
|
+
include: includeSchema.optional(),
|
|
2991
|
+
tasks: tasksSchema.optional(),
|
|
2992
|
+
options: z3.object({
|
|
2993
|
+
skim: z3.boolean().optional(),
|
|
2994
|
+
includePermissions: z3.boolean().optional(),
|
|
2995
|
+
includeFieldPermissions: z3.boolean().optional(),
|
|
2996
|
+
tryList: z3.boolean().optional(),
|
|
2997
|
+
populateAccess: populateAccessSchema.optional()
|
|
2998
|
+
}).passthrough().optional()
|
|
2999
|
+
}).passthrough()
|
|
3000
|
+
);
|
|
3001
|
+
var advancedCreateBodySchema = publicBoundarySchema(
|
|
3002
|
+
z3.object({
|
|
3003
|
+
data: z3.unknown(),
|
|
3004
|
+
select: projectionSchema.optional(),
|
|
3005
|
+
populate: populateSchema.optional(),
|
|
3006
|
+
tasks: tasksSchema.optional(),
|
|
3007
|
+
options: z3.object({
|
|
3008
|
+
includePermissions: z3.boolean().optional(),
|
|
3009
|
+
includeFieldPermissions: z3.boolean().optional(),
|
|
3010
|
+
populateAccess: populateAccessSchema.optional()
|
|
3011
|
+
}).passthrough().optional()
|
|
3012
|
+
}).passthrough()
|
|
3013
|
+
);
|
|
3014
|
+
var createBodySchema = publicBoundarySchema(
|
|
3015
|
+
z3.union([z3.record(z3.string(), z3.unknown()), z3.array(z3.record(z3.string(), z3.unknown()))]),
|
|
3016
|
+
"data"
|
|
3017
|
+
);
|
|
3018
|
+
var updateBodySchema = publicBoundarySchema(z3.record(z3.string(), z3.unknown()), "data");
|
|
3019
|
+
var advancedUpdateBodySchema = publicBoundarySchema(
|
|
3020
|
+
z3.object({
|
|
3021
|
+
data: z3.unknown(),
|
|
3022
|
+
select: projectionSchema.optional(),
|
|
3023
|
+
populate: populateSchema.optional(),
|
|
3024
|
+
tasks: tasksSchema.optional(),
|
|
3025
|
+
options: z3.object({
|
|
3026
|
+
returningAll: z3.boolean().optional(),
|
|
3027
|
+
includePermissions: z3.boolean().optional(),
|
|
3028
|
+
includeFieldPermissions: z3.boolean().optional(),
|
|
3029
|
+
populateAccess: populateAccessSchema.optional()
|
|
3030
|
+
}).passthrough().optional()
|
|
3031
|
+
}).passthrough()
|
|
3032
|
+
);
|
|
3033
|
+
var upsertBodySchema = publicBoundarySchema(z3.record(z3.string(), z3.unknown()), "data");
|
|
3034
|
+
var advancedUpsertBodySchema = publicBoundarySchema(
|
|
3035
|
+
z3.object({
|
|
3036
|
+
data: z3.record(z3.string(), z3.unknown()),
|
|
3037
|
+
select: projectionSchema.optional(),
|
|
3038
|
+
populate: populateSchema.optional(),
|
|
3039
|
+
tasks: tasksSchema.optional(),
|
|
3040
|
+
options: z3.object({
|
|
3041
|
+
returningAll: z3.boolean().optional(),
|
|
3042
|
+
includePermissions: z3.boolean().optional(),
|
|
3043
|
+
includeFieldPermissions: z3.boolean().optional(),
|
|
3044
|
+
populateAccess: populateAccessSchema.optional()
|
|
3045
|
+
}).passthrough().optional()
|
|
3046
|
+
}).passthrough()
|
|
3047
|
+
);
|
|
3048
|
+
var distinctBodySchema = publicBoundarySchema(
|
|
3049
|
+
z3.object({
|
|
3050
|
+
filter: objectOrArraySchema.optional()
|
|
3051
|
+
}).passthrough().superRefine((body, ctx) => rejectKeys(body, ctx, ["query"]))
|
|
3052
|
+
);
|
|
3053
|
+
var subListBodySchema = publicBoundarySchema(
|
|
3054
|
+
z3.object({
|
|
3055
|
+
filter: z3.record(z3.string(), z3.unknown()).optional(),
|
|
3056
|
+
select: fieldsSchema.optional()
|
|
3057
|
+
}).passthrough().superRefine((body, ctx) => rejectKeys(body, ctx, ["fields"]))
|
|
3058
|
+
);
|
|
3059
|
+
var subMutationBodySchema = publicBoundarySchema(
|
|
3060
|
+
z3.union([z3.record(z3.string(), z3.unknown()), z3.array(z3.record(z3.string(), z3.unknown()))]),
|
|
3061
|
+
"data"
|
|
3062
|
+
);
|
|
3063
|
+
var subReadBodySchema = publicBoundarySchema(
|
|
3064
|
+
z3.object({
|
|
3065
|
+
select: fieldsSchema.optional(),
|
|
3066
|
+
populate: subPopulateSchema.optional()
|
|
3067
|
+
}).passthrough().superRefine((body, ctx) => rejectKeys(body, ctx, ["fields"]))
|
|
3068
|
+
);
|
|
2602
3069
|
var requestSchemas = {
|
|
2603
3070
|
listQuery: listQuerySchema,
|
|
2604
3071
|
createQuery: createQuerySchema,
|
|
@@ -2653,8 +3120,7 @@ var rootModelListOptionsSchema = z5.object({
|
|
|
2653
3120
|
includePermissions: z5.boolean().optional(),
|
|
2654
3121
|
includeFieldPermissions: z5.boolean().optional(),
|
|
2655
3122
|
includeCount: z5.boolean().optional(),
|
|
2656
|
-
populateAccess: populateAccessSchema.optional()
|
|
2657
|
-
lean: z5.boolean().optional()
|
|
3123
|
+
populateAccess: populateAccessSchema.optional()
|
|
2658
3124
|
}).passthrough();
|
|
2659
3125
|
var rootModelReadArgsSchema = z5.object({
|
|
2660
3126
|
select: projectionSchema.optional(),
|
|
@@ -2670,8 +3136,7 @@ var rootModelReadOptionsSchema = z5.object({
|
|
|
2670
3136
|
includePermissions: z5.boolean().optional(),
|
|
2671
3137
|
includeFieldPermissions: z5.boolean().optional(),
|
|
2672
3138
|
tryList: z5.boolean().optional(),
|
|
2673
|
-
populateAccess: populateAccessSchema.optional()
|
|
2674
|
-
lean: z5.boolean().optional()
|
|
3139
|
+
populateAccess: populateAccessSchema.optional()
|
|
2675
3140
|
}).passthrough();
|
|
2676
3141
|
var rootModelCreateArgsSchema = z5.object({
|
|
2677
3142
|
select: projectionSchema.optional(),
|
|
@@ -2876,7 +3341,9 @@ var rootDataQueryEntrySchema = z5.union([
|
|
|
2876
3341
|
args: rootDataReadArgsSchema.optional()
|
|
2877
3342
|
}).passthrough()
|
|
2878
3343
|
]);
|
|
2879
|
-
var rootQuerySchema =
|
|
3344
|
+
var rootQuerySchema = publicBoundarySchema(
|
|
3345
|
+
z5.array(z5.union([rootModelQueryEntrySchema, rootDataQueryEntrySchema]))
|
|
3346
|
+
);
|
|
2880
3347
|
export {
|
|
2881
3348
|
Codes,
|
|
2882
3349
|
CustomHeaders,
|