@web-ts-toolkit/access-router 0.66.0 → 0.68.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/MIGRATION.md +342 -30
- package/README.md +273 -137
- package/advanced.d.mts +1 -1
- package/advanced.d.ts +1 -1
- package/advanced.js +291 -59
- package/advanced.mjs +291 -59
- package/index.d.mts +26 -23
- package/index.d.ts +26 -23
- package/index.js +755 -409
- package/index.mjs +784 -441
- package/llms.txt +3 -1
- package/package.json +4 -4
- package/{parsers-BiFHfrNd.d.mts → parsers-fSBARZSn.d.mts} +245 -170
- package/{parsers-BiFHfrNd.d.ts → parsers-fSBARZSn.d.ts} +245 -170
package/advanced.mjs
CHANGED
|
@@ -973,7 +973,18 @@ var retiredAuthorizationOptions = [
|
|
|
973
973
|
"unsafeUseListAuthorizationFastPath",
|
|
974
974
|
"unsafeUseReadAuthorizationFastPath"
|
|
975
975
|
];
|
|
976
|
-
var authorizationModeKeys = [
|
|
976
|
+
var authorizationModeKeys = [
|
|
977
|
+
"readAuthorizationMode",
|
|
978
|
+
"listAuthorizationMode",
|
|
979
|
+
"createAuthorizationMode",
|
|
980
|
+
"updateAuthorizationMode"
|
|
981
|
+
];
|
|
982
|
+
var authorizationModeOperations = {
|
|
983
|
+
readAuthorizationMode: "read",
|
|
984
|
+
listAuthorizationMode: "list",
|
|
985
|
+
createAuthorizationMode: "create",
|
|
986
|
+
updateAuthorizationMode: "update"
|
|
987
|
+
};
|
|
977
988
|
var serverAuthorizationControls = [...retiredAuthorizationOptions, ...authorizationModeKeys];
|
|
978
989
|
function authorizationControlError(key) {
|
|
979
990
|
return retiredAuthorizationOptions.includes(key) ? `${key} was removed; migrate to readAuthorizationMode/listAuthorizationMode on server model/default-model options` : `${key} is server model/default-model configuration only`;
|
|
@@ -2135,6 +2146,146 @@ var DataOptionsManager = class extends OptionsManager {
|
|
|
2135
2146
|
}
|
|
2136
2147
|
};
|
|
2137
2148
|
|
|
2149
|
+
// src/operation-access.ts
|
|
2150
|
+
var operations = /* @__PURE__ */ new Set(["new", "list", "read", "create", "update", "upsert", "delete", "count", "distinct"]);
|
|
2151
|
+
var subOperations = /* @__PURE__ */ new Set(["list", "read", "create", "update", "delete"]);
|
|
2152
|
+
var members = /* @__PURE__ */ new Set(["default", "basic", "advanced", "root"]);
|
|
2153
|
+
var removedAccesses = new Set(
|
|
2154
|
+
["List", "Read", "Create", "Update", "Upsert", "Count", "Distinct"].flatMap((operation) => [
|
|
2155
|
+
`basic${operation}`,
|
|
2156
|
+
`advanced${operation}`
|
|
2157
|
+
])
|
|
2158
|
+
);
|
|
2159
|
+
var isRemovedOperationAccess = (access) => typeof access === "string" && removedAccesses.has(access);
|
|
2160
|
+
function isOperationAccessMemberPath(access) {
|
|
2161
|
+
const keys2 = access.split(".");
|
|
2162
|
+
if (operations.has(keys2[0]) && members.has(keys2[1])) return true;
|
|
2163
|
+
return keys2[0] === "subs" && keys2[1] !== "" && subOperations.has(keys2[2]) && members.has(keys2[3]);
|
|
2164
|
+
}
|
|
2165
|
+
var isRecord = (value) => value !== null && typeof value === "object" && (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null);
|
|
2166
|
+
function readOwnOption(root, key) {
|
|
2167
|
+
let value = root;
|
|
2168
|
+
for (const part of key.split(".")) {
|
|
2169
|
+
if (value === null || typeof value !== "object") return void 0;
|
|
2170
|
+
const slot = Object.getOwnPropertyDescriptor(value, part);
|
|
2171
|
+
if (!slot || !("value" in slot)) return void 0;
|
|
2172
|
+
value = slot.value;
|
|
2173
|
+
}
|
|
2174
|
+
return value;
|
|
2175
|
+
}
|
|
2176
|
+
function createOperationAccessReaders(options, defaults2) {
|
|
2177
|
+
return {
|
|
2178
|
+
readOption: (key) => readOwnOption(options, key),
|
|
2179
|
+
readDefaultOption: defaults2 === void 0 ? void 0 : (key) => readOwnOption(defaults2, key)
|
|
2180
|
+
};
|
|
2181
|
+
}
|
|
2182
|
+
var scalarGuard = (value) => {
|
|
2183
|
+
if (value === void 0) return void 0;
|
|
2184
|
+
if (typeof value === "boolean" || typeof value === "string" || typeof value === "function")
|
|
2185
|
+
return value;
|
|
2186
|
+
if (Array.isArray(value) && value.every((entry) => typeof entry === "string")) return value;
|
|
2187
|
+
return false;
|
|
2188
|
+
};
|
|
2189
|
+
function operationDefault(value) {
|
|
2190
|
+
if (!isRecord(value)) return scalarGuard(value);
|
|
2191
|
+
if (Reflect.ownKeys(value).some((key) => typeof key !== "string" || !members.has(key))) return false;
|
|
2192
|
+
return scalarGuard(readOwnOption(value, "default"));
|
|
2193
|
+
}
|
|
2194
|
+
function selectOperationAccessGuard({
|
|
2195
|
+
baseAccess,
|
|
2196
|
+
context,
|
|
2197
|
+
readOption,
|
|
2198
|
+
readDefaultOption,
|
|
2199
|
+
subdocuments = false
|
|
2200
|
+
}) {
|
|
2201
|
+
const keys2 = baseAccess.split(".");
|
|
2202
|
+
if (isRemovedOperationAccess(baseAccess) || isOperationAccessMemberPath(baseAccess) || keys2[0] === "subs" && isRemovedOperationAccess(keys2[2]))
|
|
2203
|
+
return false;
|
|
2204
|
+
if (context !== void 0 && !["basic", "advanced", "root"].includes(context)) return false;
|
|
2205
|
+
const exact = (key) => {
|
|
2206
|
+
const value = readOption(key);
|
|
2207
|
+
return value === void 0 ? readDefaultOption?.(key) : value;
|
|
2208
|
+
};
|
|
2209
|
+
const contextGuard = (key, supported) => context === void 0 || !supported ? void 0 : scalarGuard(exact(`${key}.${context}`));
|
|
2210
|
+
let access = baseAccess;
|
|
2211
|
+
if (subdocuments && keys2[0] === "subs") {
|
|
2212
|
+
if (keys2.length < 3 || keys2[1] === "") return false;
|
|
2213
|
+
const fieldKey = `operationAccess.subs.${keys2[1]}`;
|
|
2214
|
+
const operationKey2 = `operationAccess.${baseAccess}`;
|
|
2215
|
+
const selected2 = contextGuard(operationKey2, keys2.length === 3 && subOperations.has(keys2[2]));
|
|
2216
|
+
if (selected2 !== void 0) return selected2;
|
|
2217
|
+
const operation2 = exact(operationKey2);
|
|
2218
|
+
if (operation2 !== void 0) {
|
|
2219
|
+
const guard = keys2.length === 3 && subOperations.has(keys2[2]) ? operationDefault(operation2) : scalarGuard(operation2);
|
|
2220
|
+
if (guard !== void 0) return guard;
|
|
2221
|
+
}
|
|
2222
|
+
const field = exact(fieldKey);
|
|
2223
|
+
if (field !== void 0) return scalarGuard(field);
|
|
2224
|
+
access = keys2[2];
|
|
2225
|
+
}
|
|
2226
|
+
const operationKey = `operationAccess.${access}`;
|
|
2227
|
+
const selected = contextGuard(operationKey, operations.has(access));
|
|
2228
|
+
if (selected !== void 0) return selected;
|
|
2229
|
+
const operation = readOption(operationKey);
|
|
2230
|
+
if (operation !== void 0) {
|
|
2231
|
+
const guard = operations.has(access) ? operationDefault(operation) : scalarGuard(operation);
|
|
2232
|
+
if (guard !== void 0) return guard;
|
|
2233
|
+
}
|
|
2234
|
+
const outerDefault = readOption("operationAccess.default");
|
|
2235
|
+
if (outerDefault !== void 0) return scalarGuard(outerDefault);
|
|
2236
|
+
const outer = readOption("operationAccess");
|
|
2237
|
+
if (outer !== void 0) return scalarGuard(outer);
|
|
2238
|
+
const inherited = readDefaultOption?.(operationKey);
|
|
2239
|
+
return operations.has(access) ? operationDefault(inherited) : scalarGuard(inherited);
|
|
2240
|
+
}
|
|
2241
|
+
function rejectRemovedKey(key, prefix) {
|
|
2242
|
+
const context = key.startsWith("basic") ? "basic" : "advanced";
|
|
2243
|
+
const operation = key.slice(context.length);
|
|
2244
|
+
const replacement = `${operation[0].toLowerCase()}${operation.slice(1)}.${context}`;
|
|
2245
|
+
throw new TypeError(
|
|
2246
|
+
`Removed operation-access key "${prefix}${key}"; use "${prefix}${replacement}" instead. Move the operation's former scalar guard to its "default" member when using an object.`
|
|
2247
|
+
);
|
|
2248
|
+
}
|
|
2249
|
+
function assertOperationNode(node, prefix) {
|
|
2250
|
+
if (!node || typeof node !== "object" || Array.isArray(node)) return;
|
|
2251
|
+
for (const key of removedAccesses) if (key in node) rejectRemovedKey(key, prefix);
|
|
2252
|
+
for (const key of Object.getOwnPropertyNames(node)) {
|
|
2253
|
+
const [operation] = key.split(".");
|
|
2254
|
+
if (isRemovedOperationAccess(operation)) rejectRemovedKey(operation, prefix);
|
|
2255
|
+
}
|
|
2256
|
+
}
|
|
2257
|
+
function assertOperationAccessOptions(options) {
|
|
2258
|
+
if (!options || typeof options !== "object") return;
|
|
2259
|
+
for (const key of Object.getOwnPropertyNames(options)) {
|
|
2260
|
+
if (key === "operationAccess" || key.startsWith("operationAccess.")) {
|
|
2261
|
+
assertOperationAccessUpdate(key, options[key]);
|
|
2262
|
+
}
|
|
2263
|
+
}
|
|
2264
|
+
}
|
|
2265
|
+
function assertOperationAccessUpdate(key, value) {
|
|
2266
|
+
const path = key.split(".");
|
|
2267
|
+
if (path[0] !== "operationAccess") return;
|
|
2268
|
+
if (isRemovedOperationAccess(path[1])) rejectRemovedKey(path[1], "operationAccess.");
|
|
2269
|
+
if (path[1] === "subs" && path.length >= 4 && isRemovedOperationAccess(path[3]))
|
|
2270
|
+
rejectRemovedKey(path[3], `operationAccess.subs.${path[2]}.`);
|
|
2271
|
+
if (path.length === 1) {
|
|
2272
|
+
assertOperationNode(value, "operationAccess.");
|
|
2273
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
2274
|
+
for (const property of Object.getOwnPropertyNames(value)) {
|
|
2275
|
+
if (property === "subs" || property.startsWith("subs."))
|
|
2276
|
+
assertOperationAccessUpdate(`operationAccess.${property}`, value[property]);
|
|
2277
|
+
}
|
|
2278
|
+
}
|
|
2279
|
+
} else if (path.length === 2 && path[1] === "subs") {
|
|
2280
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
2281
|
+
for (const field of Object.getOwnPropertyNames(value))
|
|
2282
|
+
assertOperationAccessUpdate(`operationAccess.subs.${field}`, value[field]);
|
|
2283
|
+
}
|
|
2284
|
+
} else if (path.length === 3 && path[1] === "subs") {
|
|
2285
|
+
assertOperationNode(value, `${key}.`);
|
|
2286
|
+
}
|
|
2287
|
+
}
|
|
2288
|
+
|
|
2138
2289
|
// src/request-complexity.ts
|
|
2139
2290
|
import { isArray as isArray3, isPlainObject as isPlainObject9 } from "@web-ts-toolkit/utils";
|
|
2140
2291
|
var defaultRequestComplexity = {
|
|
@@ -2505,7 +2656,12 @@ function captureVirtualPopulateDependencies(runtime, modelName, options, populat
|
|
|
2505
2656
|
populatePolicyDefaults,
|
|
2506
2657
|
...resolvePopulatePolicy(targetOptions, populatePolicyDefaults),
|
|
2507
2658
|
permissionSchema: targetOptions.permissionSchema,
|
|
2508
|
-
operationAccess: {
|
|
2659
|
+
operationAccess: {
|
|
2660
|
+
read: selectOperationAccessGuard({
|
|
2661
|
+
...createOperationAccessReaders(targetOptions, defaults2),
|
|
2662
|
+
baseAccess: "read"
|
|
2663
|
+
})
|
|
2664
|
+
},
|
|
2509
2665
|
baseFilter: { read: readOption("baseFilter.read") },
|
|
2510
2666
|
overrideFilter: { read: readOption("overrideFilter.read") },
|
|
2511
2667
|
hydration: targetOptions.hydration
|
|
@@ -2585,6 +2741,86 @@ function captureVirtualPopulateDependencies(runtime, modelName, options, populat
|
|
|
2585
2741
|
return Object.freeze({ scopes: Object.freeze(scopes) });
|
|
2586
2742
|
}
|
|
2587
2743
|
|
|
2744
|
+
// src/acl/document-permissions-definition.ts
|
|
2745
|
+
import { types as types9 } from "util";
|
|
2746
|
+
|
|
2747
|
+
// src/acl/persisted-dependencies.ts
|
|
2748
|
+
import { types as types8 } from "util";
|
|
2749
|
+
function collectPersistedTopLevel(schema) {
|
|
2750
|
+
return /* @__PURE__ */ new Set([
|
|
2751
|
+
...Object.keys(schema?.paths ?? {}).map((path) => path.split(".")[0]),
|
|
2752
|
+
...Object.keys(schema?.obj ?? {})
|
|
2753
|
+
]);
|
|
2754
|
+
}
|
|
2755
|
+
function capturePersistedDependencies(value, label, storedFields, virtualNames = /* @__PURE__ */ new Set()) {
|
|
2756
|
+
if (value === void 0) return Object.freeze([]);
|
|
2757
|
+
if (!Array.isArray(value) || types8.isProxy(value) || Object.getPrototypeOf(value) !== Array.prototype)
|
|
2758
|
+
throw new TypeError(`${label}: dependsOn must be an array of top-level persisted field names`);
|
|
2759
|
+
const length = Object.getOwnPropertyDescriptor(value, "length").value;
|
|
2760
|
+
if (length > 2e4 || Reflect.ownKeys(value).length !== length + 1)
|
|
2761
|
+
throw new TypeError(`${label}: dependsOn must be a dense array of persisted field names`);
|
|
2762
|
+
const result = [];
|
|
2763
|
+
for (let index = 0; index < length; index++) {
|
|
2764
|
+
const slot = Object.getOwnPropertyDescriptor(value, String(index));
|
|
2765
|
+
if (!slot || !("value" in slot) || typeof slot.value !== "string" || !slot.value)
|
|
2766
|
+
throw new TypeError(`${label}: dependsOn entries must be non-empty strings`);
|
|
2767
|
+
const dep = slot.value;
|
|
2768
|
+
if (dep.includes("."))
|
|
2769
|
+
throw new TypeError(`${label}: dependsOn "${dep}" must be a top-level persisted name (dotted paths rejected)`);
|
|
2770
|
+
if (!isSafeOutputPath(dep)) throw new TypeError(`${label}: unsafe dependsOn field "${dep}"`);
|
|
2771
|
+
if (virtualNames.has(dep)) throw new TypeError(`${label}: dependsOn "${dep}" must not reference another virtual`);
|
|
2772
|
+
if (storedFields && !storedFields.has(dep))
|
|
2773
|
+
throw new TypeError(`${label}: dependsOn "${dep}" is not a persisted field in its scope`);
|
|
2774
|
+
result.push(dep);
|
|
2775
|
+
}
|
|
2776
|
+
return Object.freeze([...new Set(result)]);
|
|
2777
|
+
}
|
|
2778
|
+
|
|
2779
|
+
// src/acl/document-permissions-definition.ts
|
|
2780
|
+
function dataRecord(value, label) {
|
|
2781
|
+
if (!value || typeof value !== "object" || types9.isProxy(value))
|
|
2782
|
+
throw new TypeError(`${label}: expected a function, { get, dependsOn? }, or per-access record`);
|
|
2783
|
+
const prototype = Object.getPrototypeOf(value);
|
|
2784
|
+
if (prototype !== Object.prototype && prototype !== null)
|
|
2785
|
+
throw new TypeError(`${label}: definition must be a plain object`);
|
|
2786
|
+
const result = /* @__PURE__ */ Object.create(null);
|
|
2787
|
+
const keys2 = Reflect.ownKeys(value);
|
|
2788
|
+
if (keys2.length > 2e4) throw new TypeError(`${label}: too many definition entries`);
|
|
2789
|
+
for (const key of keys2) {
|
|
2790
|
+
if (typeof key !== "string" || ["__proto__", "constructor", "prototype"].includes(key))
|
|
2791
|
+
throw new TypeError(`${label}: unsafe definition key`);
|
|
2792
|
+
const slot = Object.getOwnPropertyDescriptor(value, key);
|
|
2793
|
+
if (!slot.enumerable || !("value" in slot))
|
|
2794
|
+
throw new TypeError(`${label}: definition entries must be enumerable data properties`);
|
|
2795
|
+
Object.defineProperty(result, key, { value: slot.value, enumerable: true });
|
|
2796
|
+
}
|
|
2797
|
+
return result;
|
|
2798
|
+
}
|
|
2799
|
+
function captureLeaf(value, label, scope) {
|
|
2800
|
+
if (typeof value === "function") return value;
|
|
2801
|
+
const record2 = dataRecord(value, label);
|
|
2802
|
+
if (typeof record2.get !== "function") throw new TypeError(`${label}: descriptor.get must be callable`);
|
|
2803
|
+
if (Object.keys(record2).some((key) => key !== "get" && key !== "dependsOn"))
|
|
2804
|
+
throw new TypeError(`${label}: descriptor accepts only get/dependsOn; cannot mix per-access keys`);
|
|
2805
|
+
return Object.freeze({
|
|
2806
|
+
get: record2.get,
|
|
2807
|
+
dependsOn: capturePersistedDependencies(record2.dependsOn, label, scope.storedFields, scope.virtualNames)
|
|
2808
|
+
});
|
|
2809
|
+
}
|
|
2810
|
+
function captureDocumentPermissionsDefinition(value, scope = {}) {
|
|
2811
|
+
if (value === void 0) return void 0;
|
|
2812
|
+
if (typeof value === "function") return value;
|
|
2813
|
+
const record2 = dataRecord(value, "docPermissions");
|
|
2814
|
+
if (Object.hasOwn(record2, "get") || Object.hasOwn(record2, "dependsOn"))
|
|
2815
|
+
return captureLeaf(record2, "docPermissions", scope);
|
|
2816
|
+
const entries = Object.entries(record2).map(([access, leaf]) => {
|
|
2817
|
+
if (!/^[A-Za-z_][A-Za-z0-9_$]*$/.test(access))
|
|
2818
|
+
throw new TypeError(`docPermissions: unsafe or dotted access "${access}"`);
|
|
2819
|
+
return [access, leaf === void 0 ? void 0 : captureLeaf(leaf, `docPermissions.${access}`, scope)];
|
|
2820
|
+
});
|
|
2821
|
+
return Object.freeze(Object.fromEntries(entries));
|
|
2822
|
+
}
|
|
2823
|
+
|
|
2588
2824
|
// src/runtime.ts
|
|
2589
2825
|
var mongooseJsonSchemaInitialized = false;
|
|
2590
2826
|
var ensureMongooseJsonSchemaInitialized = () => {
|
|
@@ -2595,8 +2831,7 @@ var ensureMongooseJsonSchemaInitialized = () => {
|
|
|
2595
2831
|
var pluralize = mongoose.pluralize();
|
|
2596
2832
|
var FIELD_ACCESS_KEYS = ["list", "create", "read", "update"];
|
|
2597
2833
|
var defaultModelOptions = {
|
|
2598
|
-
basePath: null
|
|
2599
|
-
alwaysSelectFields: []
|
|
2834
|
+
basePath: null
|
|
2600
2835
|
};
|
|
2601
2836
|
var modelOverrides = (options) => {
|
|
2602
2837
|
const result = Object.fromEntries(
|
|
@@ -2694,22 +2929,7 @@ var virtualPathsOverlap = (virtualPath, permissionField) => {
|
|
|
2694
2929
|
}
|
|
2695
2930
|
return false;
|
|
2696
2931
|
};
|
|
2697
|
-
var collectStoredTopLevel =
|
|
2698
|
-
const fields = /* @__PURE__ */ new Set();
|
|
2699
|
-
if (!schema) return fields;
|
|
2700
|
-
const paths = schema.paths;
|
|
2701
|
-
if (paths) {
|
|
2702
|
-
for (const p of Object.keys(paths)) {
|
|
2703
|
-
const top = p.split(".")[0];
|
|
2704
|
-
if (top) fields.add(top);
|
|
2705
|
-
}
|
|
2706
|
-
}
|
|
2707
|
-
const obj = schema.obj;
|
|
2708
|
-
if (obj) {
|
|
2709
|
-
for (const k of Object.keys(obj)) fields.add(k);
|
|
2710
|
-
}
|
|
2711
|
-
return fields;
|
|
2712
|
-
};
|
|
2932
|
+
var collectStoredTopLevel = collectPersistedTopLevel;
|
|
2713
2933
|
var getChildSchemaForField = (parentSchema, fieldName) => {
|
|
2714
2934
|
if (!parentSchema) return null;
|
|
2715
2935
|
try {
|
|
@@ -2748,32 +2968,7 @@ var cloneModelOptionForUpdate = (value) => {
|
|
|
2748
2968
|
);
|
|
2749
2969
|
};
|
|
2750
2970
|
var validateVirtualDependsOn = (dependsOn, entryLabel, storedFields, siblingVirtualNames) => {
|
|
2751
|
-
|
|
2752
|
-
if (!isArray4(dependsOn)) {
|
|
2753
|
-
throw new Error(`Virtual ${entryLabel}: dependsOn must be an array of top-level persisted field names`);
|
|
2754
|
-
}
|
|
2755
|
-
const list = dependsOn;
|
|
2756
|
-
for (const dep of list) {
|
|
2757
|
-
if (!isString3(dep) || dep.length === 0) {
|
|
2758
|
-
throw new Error(`Virtual ${entryLabel}: dependsOn entries must be non-empty strings`);
|
|
2759
|
-
}
|
|
2760
|
-
if (dep.includes(".")) {
|
|
2761
|
-
throw new Error(
|
|
2762
|
-
`Virtual ${entryLabel}: dependsOn "${dep}" must be a top-level persisted name relative to its scope (dotted paths rejected)`
|
|
2763
|
-
);
|
|
2764
|
-
}
|
|
2765
|
-
if (siblingVirtualNames.has(dep)) {
|
|
2766
|
-
throw new Error(
|
|
2767
|
-
`Virtual ${entryLabel}: dependsOn "${dep}" must not reference another virtual (virtual-to-virtual rejected)`
|
|
2768
|
-
);
|
|
2769
|
-
}
|
|
2770
|
-
if (!storedFields.has(dep)) {
|
|
2771
|
-
throw new Error(
|
|
2772
|
-
`Virtual ${entryLabel}: dependsOn "${dep}" is not a persisted field in its scope (validated against the receiving Mongoose schema/child scope)`
|
|
2773
|
-
);
|
|
2774
|
-
}
|
|
2775
|
-
}
|
|
2776
|
-
return list;
|
|
2971
|
+
return [...capturePersistedDependencies(dependsOn, `Virtual ${entryLabel}`, storedFields, siblingVirtualNames)];
|
|
2777
2972
|
};
|
|
2778
2973
|
var validateVirtualLeafValue = (value, entryLabel, storedFields, siblingVirtualNames, sharedDependsOn) => {
|
|
2779
2974
|
if (isFunction2(value)) return;
|
|
@@ -2948,6 +3143,7 @@ var AccessRuntime = class {
|
|
|
2948
3143
|
this.defaultModelOptions = new OptionsManager({
|
|
2949
3144
|
listHardLimit: DEFAULT_LIST_HARD_LIMIT,
|
|
2950
3145
|
documentPermissionField: "_permissions",
|
|
3146
|
+
disableFieldPermissions: true,
|
|
2951
3147
|
idParam: "id",
|
|
2952
3148
|
idField: "_id",
|
|
2953
3149
|
parentPath: "/",
|
|
@@ -2958,7 +3154,9 @@ var AccessRuntime = class {
|
|
|
2958
3154
|
requireOperationAccessForPopulateDependencies: true,
|
|
2959
3155
|
modelPermissionPrefix: "",
|
|
2960
3156
|
readAuthorizationMode: "isolated",
|
|
2961
|
-
listAuthorizationMode: "isolated"
|
|
3157
|
+
listAuthorizationMode: "isolated",
|
|
3158
|
+
createAuthorizationMode: "isolated",
|
|
3159
|
+
updateAuthorizationMode: "isolated"
|
|
2962
3160
|
}).build();
|
|
2963
3161
|
this.modelOptions = {};
|
|
2964
3162
|
this.modelOptionOverrides = {};
|
|
@@ -3099,15 +3297,18 @@ var AccessRuntime = class {
|
|
|
3099
3297
|
assertAuthorizationModeOptions(snapshot.globalOptions, false);
|
|
3100
3298
|
assertNoServerModelControls(snapshot.globalOptions, reject);
|
|
3101
3299
|
assertAuthorizationModeOptions(snapshot.defaultModelOptions, true);
|
|
3300
|
+
assertOperationAccessOptions(snapshot.defaultModelOptions);
|
|
3102
3301
|
assertNoServerModelControls(snapshot.defaultModelOptions, reject, "model-options");
|
|
3103
3302
|
assertPublicDefaults(snapshot.defaultModelOptions.defaults);
|
|
3104
3303
|
for (const options of [...Object.values(snapshot.modelOptions), ...Object.values(snapshot.modelOptionOverrides)]) {
|
|
3105
3304
|
assertAuthorizationModeOptions(options, true);
|
|
3305
|
+
assertOperationAccessOptions(options);
|
|
3106
3306
|
assertNoServerModelControls(options, reject, "model-options");
|
|
3107
3307
|
assertPublicDefaults(options.defaults);
|
|
3108
3308
|
}
|
|
3109
3309
|
for (const options of Object.values(snapshot.dataOptions)) {
|
|
3110
3310
|
assertAuthorizationModeOptions(options, false);
|
|
3311
|
+
assertOperationAccessOptions(options);
|
|
3111
3312
|
assertNoServerModelControls(options, reject, "data-options");
|
|
3112
3313
|
}
|
|
3113
3314
|
this.globalOptions.restore(snapshot.globalOptions);
|
|
@@ -3195,6 +3396,7 @@ var AccessRuntime = class {
|
|
|
3195
3396
|
/** Update inherited model defaults shallowly. Explicit model values and captured calls are unchanged. */
|
|
3196
3397
|
setDefaultModelOptions(options) {
|
|
3197
3398
|
assertAuthorizationModeOptions(options, true);
|
|
3399
|
+
assertOperationAccessOptions(options);
|
|
3198
3400
|
assertNoServerModelControls(
|
|
3199
3401
|
options,
|
|
3200
3402
|
(detail) => {
|
|
@@ -3216,6 +3418,7 @@ var AccessRuntime = class {
|
|
|
3216
3418
|
setDefaultModelOption(key, value) {
|
|
3217
3419
|
assertAuthorizationModeKey(key, true);
|
|
3218
3420
|
const keyStr = key;
|
|
3421
|
+
assertOperationAccessUpdate(keyStr, value);
|
|
3219
3422
|
if (authorizationModeKeys.includes(keyStr)) {
|
|
3220
3423
|
this.setDefaultModelOptions({ [keyStr]: value });
|
|
3221
3424
|
return;
|
|
@@ -3269,15 +3472,20 @@ var AccessRuntime = class {
|
|
|
3269
3472
|
return cloneOptionsSnapshot(effective);
|
|
3270
3473
|
}
|
|
3271
3474
|
validateModelOptions(modelName, options, proposed) {
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3475
|
+
assertOperationAccessOptions(options);
|
|
3476
|
+
const model = this.getModelInstance(modelName);
|
|
3477
|
+
validateVirtualsTree(model, options.virtuals, options.documentPermissionField ?? "_permissions", modelName);
|
|
3478
|
+
captureDocumentPermissionsDefinition(options.docPermissions, {
|
|
3479
|
+
storedFields: collectPersistedTopLevel(model?.schema),
|
|
3480
|
+
virtualNames: /* @__PURE__ */ new Set([
|
|
3481
|
+
...Object.keys(model?.schema.virtuals ?? {}),
|
|
3482
|
+
...Object.entries(options.virtuals ?? {}).filter(([, value]) => value !== void 0 && !isVirtualContainerValue2(value)).map(([name]) => name)
|
|
3483
|
+
])
|
|
3484
|
+
});
|
|
3278
3485
|
captureVirtualPopulateDependencies(this, modelName, options, void 0, proposed);
|
|
3279
3486
|
}
|
|
3280
3487
|
publishDefaultModelOptions(options) {
|
|
3488
|
+
assertOperationAccessOptions(options);
|
|
3281
3489
|
const next = { ...options };
|
|
3282
3490
|
const defaults2 = cloneOptionsSnapshot(next);
|
|
3283
3491
|
const models = new Map(
|
|
@@ -3310,10 +3518,10 @@ var AccessRuntime = class {
|
|
|
3310
3518
|
if (options[key] !== "trusted" || before.get(modelName)?.[key] === "trusted") continue;
|
|
3311
3519
|
try {
|
|
3312
3520
|
this.getGlobalOption("logger")?.warn?.(
|
|
3313
|
-
"Trusted authorization source mode enabled;
|
|
3521
|
+
"Trusted authorization output source mode enabled; admitted source/document-hook input may be borrowed. Write input is unchanged. Actor, policy, facts, getter views and selected output bounds remain owned.",
|
|
3314
3522
|
{
|
|
3315
3523
|
modelName,
|
|
3316
|
-
access: key
|
|
3524
|
+
access: authorizationModeOperations[key],
|
|
3317
3525
|
category: "trustedAuthorizationSource"
|
|
3318
3526
|
}
|
|
3319
3527
|
);
|
|
@@ -3365,6 +3573,7 @@ var AccessRuntime = class {
|
|
|
3365
3573
|
*/
|
|
3366
3574
|
setModelOptions(modelName, options) {
|
|
3367
3575
|
assertAuthorizationModeOptions(options, true);
|
|
3576
|
+
assertOperationAccessOptions(options);
|
|
3368
3577
|
assertNoServerModelControls(
|
|
3369
3578
|
options,
|
|
3370
3579
|
(detail) => {
|
|
@@ -3373,6 +3582,12 @@ var AccessRuntime = class {
|
|
|
3373
3582
|
"model-options"
|
|
3374
3583
|
);
|
|
3375
3584
|
assertPublicDefaults(options.defaults);
|
|
3585
|
+
if ("docPermissions" in options) {
|
|
3586
|
+
const slot = Object.getOwnPropertyDescriptor(options, "docPermissions");
|
|
3587
|
+
if (!slot || !("value" in slot) || !slot.enumerable)
|
|
3588
|
+
throw new TypeError("docPermissions must be an enumerable data property");
|
|
3589
|
+
options = { ...options, docPermissions: captureDocumentPermissionsDefinition(slot.value) };
|
|
3590
|
+
}
|
|
3376
3591
|
options = normalizePopulatePolicyOptions(options);
|
|
3377
3592
|
if ("hydration" in options) options = { ...options, hydration: normalizeHydration(options.hydration) };
|
|
3378
3593
|
const overrides = modelOverrides({ ...this.modelOptionOverrides[modelName], ...options });
|
|
@@ -3388,6 +3603,17 @@ var AccessRuntime = class {
|
|
|
3388
3603
|
setModelOption(modelName, key, value) {
|
|
3389
3604
|
assertAuthorizationModeKey(key, true);
|
|
3390
3605
|
const keyStr = key;
|
|
3606
|
+
assertOperationAccessUpdate(keyStr, value);
|
|
3607
|
+
if (keyStr === "docPermissions") {
|
|
3608
|
+
value = captureDocumentPermissionsDefinition(value);
|
|
3609
|
+
} else if (keyStr.startsWith("docPermissions.")) {
|
|
3610
|
+
const path2 = keyStr.slice("docPermissions.".length);
|
|
3611
|
+
if (path2.includes(".") || path2 === "get" || path2 === "dependsOn")
|
|
3612
|
+
throw new TypeError(
|
|
3613
|
+
"docPermissions dotted setters replace an access definition; set { get, dependsOn? } together"
|
|
3614
|
+
);
|
|
3615
|
+
captureDocumentPermissionsDefinition({ [path2]: value });
|
|
3616
|
+
}
|
|
3391
3617
|
if (keyStr === "hydration" || keyStr.startsWith("hydration.")) {
|
|
3392
3618
|
const hydration = normalizeHydrationUpdate(this.resolveModelOptions(modelName).hydration, keyStr, value);
|
|
3393
3619
|
this.setModelOptions(modelName, { hydration });
|
|
@@ -3420,7 +3646,10 @@ var AccessRuntime = class {
|
|
|
3420
3646
|
return;
|
|
3421
3647
|
}
|
|
3422
3648
|
const current = this.resolveModelOptions(modelName);
|
|
3423
|
-
const
|
|
3649
|
+
const directDocumentPermissions = root === "docPermissions" && current[root] && typeof current[root] === "object" && Object.hasOwn(current[root], "get");
|
|
3650
|
+
const nested = cloneModelOptionForUpdate(
|
|
3651
|
+
isPlainObject13(current[root]) && !directDocumentPermissions ? current[root] : {}
|
|
3652
|
+
);
|
|
3424
3653
|
if (root === "virtuals" && value === void 0) {
|
|
3425
3654
|
const parent = path.length === 1 ? nested : get4(nested, path.slice(0, -1));
|
|
3426
3655
|
if (isPlainObject13(parent)) delete parent[path[path.length - 1]];
|
|
@@ -3435,8 +3664,9 @@ var AccessRuntime = class {
|
|
|
3435
3664
|
/**
|
|
3436
3665
|
* Generic stored exact → parent.default → parent lookup; only undefined falls through.
|
|
3437
3666
|
* The exact runtime-model-default path is the final fallback if the stored parent is
|
|
3438
|
-
* absent. This is not the
|
|
3439
|
-
*
|
|
3667
|
+
* absent. This raw generic lookup is not the final nested operation-entry resolver;
|
|
3668
|
+
* it may return an operation object. getExactModelOption inspects a member including
|
|
3669
|
+
* its same-owner exact model-default fallback, without resolving entry policy.
|
|
3440
3670
|
*/
|
|
3441
3671
|
getModelOption(modelName, key, defaultValue) {
|
|
3442
3672
|
const manager = this.getOrCreateModelOptions(modelName);
|
|
@@ -3446,7 +3676,7 @@ var AccessRuntime = class {
|
|
|
3446
3676
|
);
|
|
3447
3677
|
return getNestedOption(manager, key, defaultModelValue);
|
|
3448
3678
|
}
|
|
3449
|
-
/** Exact stored path, then the same runtime-model-default path; no parent/default or
|
|
3679
|
+
/** Exact stored path, then the same runtime-model-default path; no parent/default or final entry resolution. */
|
|
3450
3680
|
getExactModelOption(modelName, key) {
|
|
3451
3681
|
const manager = this.getOrCreateModelOptions(modelName);
|
|
3452
3682
|
const defaultModelValue = this.getDefaultModelOption(key);
|
|
@@ -3529,6 +3759,7 @@ var AccessRuntime = class {
|
|
|
3529
3759
|
}
|
|
3530
3760
|
setDataOptions(dataName, options) {
|
|
3531
3761
|
assertAuthorizationModeOptions(options, false);
|
|
3762
|
+
assertOperationAccessOptions(options);
|
|
3532
3763
|
assertNoServerModelControls(
|
|
3533
3764
|
options,
|
|
3534
3765
|
(detail) => {
|
|
@@ -3541,6 +3772,7 @@ var AccessRuntime = class {
|
|
|
3541
3772
|
}
|
|
3542
3773
|
setDataOption(dataName, key, value) {
|
|
3543
3774
|
assertAuthorizationModeKey(key, false);
|
|
3775
|
+
assertOperationAccessUpdate(key, value);
|
|
3544
3776
|
const proposed = {};
|
|
3545
3777
|
set3(proposed, key, value);
|
|
3546
3778
|
assertNoServerModelControls(
|
package/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import mongoose__default, { Schema } from 'mongoose';
|
|
2
2
|
import { Response, NextFunction, RequestHandler, Router } from 'express';
|
|
3
|
-
import { A as AccessRouterBaseRequest, au as GuardHook,
|
|
4
|
-
export {
|
|
3
|
+
import { A as AccessRouterBaseRequest, au as GuardHook, b1 as ModelRequest, e3 as AccessRuntime, $ as DataRouterOptions, Z as DataRequest, e4 as DataService, ab as ExtendedDataRouterOptions, bm as OperationAccessSetter, ai as Filter, bD as Projection, cJ as Sort, bz as Populate, b2 as ModelRouterOptions, e5 as Service, e6 as PublicService, bd as ModelVirtualRecordAccess, b7 as ModelVirtualDescriptor, b9 as ModelVirtualGetter, ba as ModelVirtualLeaf, ad as ExtendedModelRouterOptions, aP as ModelDocPermissionsDefinition, dG as Validation, cu as RootRouterOptions, e7 as OpenApiRouterOptions, e8 as OpenApiRegistryOptions, e9 as OpenApiRouteDescriptor, ea as OpenApiDocumentOptions, eb as OpenApiParameter, ec as OpenApiSchema, ed as OpenApiResponses, as as GlobalOptions, a3 as DefaultModelRouterOptions, ac as ExtendedDefaultModelRouterOptions } from './parsers-fSBARZSn.mjs';
|
|
4
|
+
export { ee as AccessRouterPermissionMap, ef as AccessRouterPermissions, c as AccessRouterRequest, d as AccessRouterRequestExtensions, l as AjvErrorObjectLike, n as AjvValidatorLike, o as AllowedOutputFieldOptions, p as ArkTypeErrorsLike, q as ArkTypeLike, s as AuthorizationMode, t as AuthorizedListResult, u as AuthorizedSingleResult, I as CreateAuthorization, O as DataFieldOptions, a8 as DocumentGrants, ae as FieldAuthorization, af as FieldOperationAccess, ag as FieldPermissionHook, ah as FieldValidation, ak as FilteredOutput, at as GlobalPermissionValue, av as HydrationMode, ay as InputFieldAuthorization, az as InputFieldPath, aA as IoTsContextEntryLike, aB as IoTsDecodeErrorLike, aC as IoTsDecoderLike, aD as JoiSchemaLike, aE as JoiValidationErrorDetailLike, aK as MaybePromise, aL as ModelBaseFilterHook, aN as ModelDeleteHook, aO as ModelDocPermissionsAccessRecord, aQ as ModelDocPermissionsDescriptor, aR as ModelDocPermissionsHook, aT as ModelDocumentHook, aU as ModelHook, aW as ModelHydrationOptions, aX as ModelIdentifierHook, aY as ModelListHook, aZ as ModelOutputContext, a_ as ModelOutputHook, a$ as ModelOutputListHook, b0 as ModelOverrideFilterHook, b3 as ModelValidateHook, b4 as ModelVirtualAccess, b5 as ModelVirtualAccessRecord, b6 as ModelVirtualContext, b8 as ModelVirtualDoc, bb as ModelVirtualPopulateDependency, bc as ModelVirtualPopulateInputs, be as ModelVirtuals, bf as MutationAuthorization, bg as NewArgs, bh as NewOptions, eg as OpenApiMethod, bi as OperationAccess, bj as OperationAccessContext, bk as OperationAccessPaths, bl as OperationAccessRule, bn as OperationAccessVariants, bo as OperationAuthorization, bp as OutputAuthorization, bq as OutputFieldOptions, br as OutputFieldPath, bs as OutputPlanningOptions, bv as PairedRouteAccess, by as PermissionSchema, eh as Permissions, bB as PopulatePlanningOptions, bP as PublicSubdocumentCreateOptions, bQ as PublicSubdocumentListOptions, bR as PublicSubdocumentMutationOptions, bS as PublicSubdocumentReadOptions, bY as RelatedAuthorization, b_ as RequestSchemaAdapter, b$ as RequestSchemaFailure, c0 as RequestSchemaIssue, c1 as RequestSchemaLike, c2 as RequestSchemaOptions, c3 as RequestSchemaResult, c4 as RequestSchemaSuccess, c5 as RequestSchemaValidator, cx as RouteBaseAccess, cy as RouteGuardAccess, cz as RouteVariant, cA as RowAuthorization, cE as ServiceAuthorization, cF as ServiceOutputContext, cG as ServiceOutputDecorator, cL as StandardSchemaFailure, cM as StandardSchemaInferOutput, cN as StandardSchemaIssue, cO as StandardSchemaPathSegment, cP as StandardSchemaResult, cQ as StandardSchemaSuccess, cR as StandardSchemaV1, cU as SubOperationAccess, cY as SubRouteGuardOptions, c$ as SubdocumentCreateAuthorization, d1 as SubdocumentCreateOptions, d2 as SubdocumentCreateVisibilityAuthorization, d3 as SubdocumentDeleteAuthorization, d4 as SubdocumentDeleteOptions, d5 as SubdocumentGateAuthorization, d7 as SubdocumentInputAuthorization, d8 as SubdocumentListOptions, d9 as SubdocumentModel, da as SubdocumentMutationAuthorization, db as SubdocumentName, dc as SubdocumentOutputAuthorization, df as SubdocumentReadAuthorization, dg as SubdocumentReadOptions, di as SubdocumentUpdateOptions, dj as SubdocumentVirtuals, dk as SubdocumentVisibilityAuthorization, dl as SuperstructFailureLike, dm as SuperstructValidateLike, dA as ValibotIssueLike, dB as ValibotPathItemLike, dC as ValibotSafeParseLike, dD as ValibotSafeParseResult, dI as VineValidationErrorLike, dJ as VineValidationMessageLike, dK as VineValidatorLike, dL as VirtualSubModel, dM as WithVirtuals, dN as YupSchemaLike, dO as YupValidationErrorLike, ei as defaultRuntime, dP as defineRequestSchema, dQ as fromAjv, dR as fromArkType, dS as fromIoTs, dT as fromJoi, dU as fromStandardSchema, dV as fromSuperstruct, dW as fromValibot, dX as fromVine, dY as fromYup, dZ as fromZod } from './parsers-fSBARZSn.mjs';
|
|
5
5
|
import JsonRouter from '@web-ts-toolkit/express-json-router';
|
|
6
6
|
import 'zod';
|
|
7
7
|
import 'node:buffer';
|
|
@@ -49,12 +49,12 @@ declare class DataRouter<TData = unknown> {
|
|
|
49
49
|
private setDocumentRoutes;
|
|
50
50
|
/**
|
|
51
51
|
* Update live behavior with a typed key/path or an options object. Dotted paths
|
|
52
|
-
* such as `operationAccess.
|
|
52
|
+
* such as `operationAccess.read.basic` update one key; object assignment replaces
|
|
53
53
|
* supplied top-level values shallowly. The construction-time options snapshot stays fixed.
|
|
54
54
|
*/
|
|
55
55
|
set<K extends keyof ExtendedDataRouterOptions<TData>>(key: K, value: ExtendedDataRouterOptions<TData>[K]): this;
|
|
56
56
|
set(options: DataRouterOptions<TData>): this;
|
|
57
|
-
/** Set one live option/path; `setOption('operationAccess.
|
|
57
|
+
/** Set one live option/path; `setOption('operationAccess.read.basic', undefined)` restores fallback. */
|
|
58
58
|
setOption<K extends keyof ExtendedDataRouterOptions<TData>>(key: K, option: ExtendedDataRouterOptions<TData>[K]): this;
|
|
59
59
|
/** Shallowly replace supplied top-level options; an operationAccess object replaces that entire rule object. */
|
|
60
60
|
setOptions(options: DataRouterOptions<TData>): this;
|
|
@@ -63,13 +63,14 @@ declare class DataRouter<TData = unknown> {
|
|
|
63
63
|
/** Base-operation field grants; basic/advanced route guards belong to operationAccess. */
|
|
64
64
|
permissionSchema: SetTargetOption$1<DataRouter<TData>, DataRouterOptions<TData>['permissionSchema']>;
|
|
65
65
|
/**
|
|
66
|
-
* Live
|
|
67
|
-
* `operationAccess('
|
|
68
|
-
* (and HEAD) with HTTP 401; registered POST reads
|
|
66
|
+
* Live scalar/default and independent basic/advanced/root list/read entry guards.
|
|
67
|
+
* `operationAccess('read.basic', false)` updates one member and denies GET /:id
|
|
68
|
+
* (and HEAD) with HTTP 401; registered POST reads use read.advanced then read.default.
|
|
69
69
|
* `operationAccess({ list: true, read: true })` replaces the whole rule object,
|
|
70
|
-
* not a deep merge.
|
|
70
|
+
* not a deep merge. Two-argument member setters accept undefined to restore fallback.
|
|
71
|
+
* Data never inherits model defaults; updating beneath a scalar starts an object.
|
|
71
72
|
*/
|
|
72
|
-
operationAccess:
|
|
73
|
+
operationAccess: OperationAccessSetter<DataRouter<TData>>;
|
|
73
74
|
baseFilter: SetTargetOption$1<DataRouter<TData>, DataRouterOptions<TData>['baseFilter']>;
|
|
74
75
|
/**
|
|
75
76
|
* Trusted filter replacements applied before base-filter composition.
|
|
@@ -150,14 +151,14 @@ declare class ModelRouter<TModel = unknown, TVirtuals extends object = Record<ne
|
|
|
150
151
|
private logEndpoints;
|
|
151
152
|
/**
|
|
152
153
|
* Update live behavior with a typed key/path or an options object. Dotted paths
|
|
153
|
-
* such as `operationAccess.
|
|
154
|
+
* such as `operationAccess.read.basic` update one key; object assignment replaces
|
|
154
155
|
* supplied top-level values shallowly. The construction-time options snapshot stays fixed.
|
|
155
156
|
*/
|
|
156
157
|
set<K extends Extract<keyof TVirtuals, string> & string, A extends ModelVirtualRecordAccess>(key: `virtuals.${K}.${A}`, value: ModelVirtualDescriptor<TModel, K extends keyof TVirtuals ? TVirtuals[K] : unknown> | ModelVirtualGetter<TModel, K extends keyof TVirtuals ? TVirtuals[K] : unknown>): this;
|
|
157
158
|
set<K extends Extract<keyof TVirtuals, string> & string>(key: `virtuals.${K}`, value: ModelVirtualLeaf<TModel, K extends keyof TVirtuals ? TVirtuals[K] : unknown>): this;
|
|
158
159
|
set<K extends keyof ExtendedModelRouterOptions<TModel, TVirtuals>>(key: K, value: ExtendedModelRouterOptions<TModel, TVirtuals>[K]): this;
|
|
159
160
|
set(options: ModelRouterOptions<TModel, TVirtuals>): this;
|
|
160
|
-
/** Set one live option/path; `setOption('operationAccess.
|
|
161
|
+
/** Set one live option/path; `setOption('operationAccess.read.basic', undefined)` restores fallback. */
|
|
161
162
|
setOption<K extends keyof ExtendedModelRouterOptions<TModel, TVirtuals>>(key: K, option: ExtendedModelRouterOptions<TModel, TVirtuals>[K]): this;
|
|
162
163
|
/** Shallowly replace supplied top-level options; an operationAccess object replaces that entire rule object. */
|
|
163
164
|
setOptions(options: ModelRouterOptions<TModel, TVirtuals>): this;
|
|
@@ -236,22 +237,24 @@ declare class ModelRouter<TModel = unknown, TVirtuals extends object = Record<ne
|
|
|
236
237
|
*/
|
|
237
238
|
documentPermissionField: SetTargetOption<ModelRouter<TModel, TVirtuals>, ModelRouterOptions<TModel, TVirtuals>['documentPermissionField']>;
|
|
238
239
|
/**
|
|
239
|
-
*
|
|
240
|
+
* Configure a callable/descriptor directly, or replace one exact/default/custom
|
|
241
|
+
* access definition. Descriptor dependsOn adds private persisted inputs, not output grants.
|
|
242
|
+
* An undefined access restores default fallback; pass undefined alone to clear the option.
|
|
240
243
|
*/
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
docPermissions: SetTargetOption<ModelRouter<TModel, TVirtuals>, ModelRouterOptions<TModel, TVirtuals>['docPermissions']>;
|
|
244
|
+
docPermissions: {
|
|
245
|
+
(option: ModelRouterOptions<TModel, TVirtuals>['docPermissions']): ModelRouter<TModel, TVirtuals>;
|
|
246
|
+
(access: string, option: ModelDocPermissionsDefinition<TModel> | undefined): ModelRouter<TModel, TVirtuals>;
|
|
247
|
+
};
|
|
246
248
|
/**
|
|
247
|
-
* Configure live
|
|
249
|
+
* Configure live scalar/default and independent basic/advanced/root entry guards. Only undefined inherits;
|
|
248
250
|
* selected false denies with HTTP 401 without removing routes or OpenAPI entries.
|
|
249
|
-
* `operationAccess('
|
|
250
|
-
* `operationAccess('subs.comments.
|
|
251
|
+
* `operationAccess('read.basic', false)` updates one member, and
|
|
252
|
+
* `operationAccess('subs.comments.read.basic', false)` updates a field-specific member.
|
|
251
253
|
* `operationAccess({ list: true, read: true })` replaces the whole rule object,
|
|
252
|
-
* not a deep merge.
|
|
254
|
+
* not a deep merge. Two-argument member setters accept undefined to restore fallback.
|
|
255
|
+
* Updating beneath a scalar starts an object; retain the old guard in operation.default.
|
|
253
256
|
*/
|
|
254
|
-
operationAccess:
|
|
257
|
+
operationAccess: OperationAccessSetter<ModelRouter<TModel, TVirtuals>>;
|
|
255
258
|
/**
|
|
256
259
|
* The base filter definitions applied in every query transaction.
|
|
257
260
|
* @operation `list`, `read`, `update`, `delete`
|
|
@@ -623,4 +626,4 @@ declare function createAccessRuntime(): AccessRuntimeApi;
|
|
|
623
626
|
*/
|
|
624
627
|
declare const acl: AccessRuntimeApi;
|
|
625
628
|
|
|
626
|
-
export { AccessRuntime, type AccessRuntimeApi, type CombinedRouteInput, DataRouter, DataRouterOptions, DefaultModelRouterOptions, ExtendedDataRouterOptions, ExtendedDefaultModelRouterOptions, ExtendedModelRouterOptions, GlobalOptions, GuardHook, type GuardModelCondition, type GuardModelConditionID, ModelRouter, ModelRouterOptions, ModelVirtualDescriptor, ModelVirtualGetter, ModelVirtualLeaf, ModelVirtualRecordAccess, type OpLogContext, OpenApiCollisionError, OpenApiDocumentOptions, OpenApiRegistry, OpenApiRegistryOptions, OpenApiRouteDescriptor, OpenApiRouterOptions, RootRouter, RootRouterOptions, Validation, acl, combineRoutes, createAccessRuntime, createOpenApiRouter, acl as default, getDefaultModelOption, getDefaultModelOptions, getGlobalOption, getGlobalOptions, getModelInstance, getModelJsonSchema, getModelNames, getModelOption, getModelOptions, guard, hasModelInstance, isLevelEnabled, permissionsPlugin, redactFilter, redactPayload, registerModelInstance, safeStringify, setDefaultModelOption, setDefaultModelOptions, setGlobalOption, setGlobalOptions, setModelOption, setModelOptions };
|
|
629
|
+
export { AccessRuntime, type AccessRuntimeApi, type CombinedRouteInput, DataRouter, DataRouterOptions, DefaultModelRouterOptions, ExtendedDataRouterOptions, ExtendedDefaultModelRouterOptions, ExtendedModelRouterOptions, GlobalOptions, GuardHook, type GuardModelCondition, type GuardModelConditionID, ModelDocPermissionsDefinition, ModelRouter, ModelRouterOptions, ModelVirtualDescriptor, ModelVirtualGetter, ModelVirtualLeaf, ModelVirtualRecordAccess, type OpLogContext, OpenApiCollisionError, OpenApiDocumentOptions, OpenApiRegistry, OpenApiRegistryOptions, OpenApiRouteDescriptor, OpenApiRouterOptions, OperationAccessSetter, RootRouter, RootRouterOptions, Validation, acl, combineRoutes, createAccessRuntime, createOpenApiRouter, acl as default, getDefaultModelOption, getDefaultModelOptions, getGlobalOption, getGlobalOptions, getModelInstance, getModelJsonSchema, getModelNames, getModelOption, getModelOptions, guard, hasModelInstance, isLevelEnabled, permissionsPlugin, redactFilter, redactPayload, registerModelInstance, safeStringify, setDefaultModelOption, setDefaultModelOptions, setGlobalOption, setGlobalOptions, setModelOption, setModelOptions };
|