@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
|
@@ -133,6 +133,8 @@ interface PublicListOptions {
|
|
|
133
133
|
* Include field-level `_view`/`_edit` maps. Defaults to `includePermissions`
|
|
134
134
|
* when omitted. `includePermissions: true` + `includeFieldPermissions: false`
|
|
135
135
|
* keeps `docPermissions`-hook keys but omits `_view`/`_edit` entirely.
|
|
136
|
+
* Requires model `disableFieldPermissions: false`; otherwise ignored (the
|
|
137
|
+
* model option defaults to `true`).
|
|
136
138
|
* Full internal document grants resolve independently of both metadata flags
|
|
137
139
|
* and skim. These maps describe request-user permissions, never backend grants.
|
|
138
140
|
*/
|
|
@@ -354,6 +356,25 @@ interface SubPopulate {
|
|
|
354
356
|
/** Request-only operation guard: one permissions argument and original-request `this`, never document facts. */
|
|
355
357
|
type GuardHook<TRequest extends AccessRouterRequest = AccessRouterRequest> = (this: TRequest, permissions: AccessRouterPermissions) => boolean | Promise<boolean>;
|
|
356
358
|
type Validation = boolean | string | string[] | GuardHook;
|
|
359
|
+
/** Server-owned entry context, never a wire operation or populate selector. Secondary checks omit context. */
|
|
360
|
+
type OperationAccessContext = 'basic' | 'advanced' | 'root';
|
|
361
|
+
/**
|
|
362
|
+
* One operation's independent request guards. Only undefined inherits; a selected
|
|
363
|
+
* member replaces (never ANDs/ORs with) its default. Exact same-runtime context
|
|
364
|
+
* defaults precede scalar/default fallback; operation objects are not deep-merged.
|
|
365
|
+
*/
|
|
366
|
+
interface OperationAccessVariants {
|
|
367
|
+
/** Context-free base checks and entry fallback; then the applicable outer default, or deny for closed fields. */
|
|
368
|
+
default?: Validation;
|
|
369
|
+
/** Basic direct route (including HEAD for GET); unpaired new/delete/subdocument mutations also use basic. */
|
|
370
|
+
basic?: Validation;
|
|
371
|
+
/** Advanced direct route, including both POST reads; does not create endpoints for unpaired operations. */
|
|
372
|
+
advanced?: Validation;
|
|
373
|
+
/** Root/batch target entry only; independent of the root router's own scalar outer guard. */
|
|
374
|
+
root?: Validation;
|
|
375
|
+
}
|
|
376
|
+
/** A scalar guard, or independent entry guards with a context-free default. */
|
|
377
|
+
type OperationAccessRule = Validation | OperationAccessVariants;
|
|
357
378
|
/**
|
|
358
379
|
* Immutable literal-boolean facts normalized once per owning document stage.
|
|
359
380
|
* Return a plain own enumerable string-keyed record (at most 19,999 keys), not rich,
|
|
@@ -381,10 +402,8 @@ type PairedRouteAccess = 'list' | 'read' | 'create' | 'update' | 'upsert' | 'cou
|
|
|
381
402
|
type RouteBaseAccess = PairedRouteAccess | 'new' | 'delete' | 'subs';
|
|
382
403
|
/** Server-owned transport variant for a paired generated route. */
|
|
383
404
|
type RouteVariant = 'basic' | 'advanced';
|
|
384
|
-
/** The fourteen route-only keys, or the two keys for a specified paired base operation. */
|
|
385
|
-
type RouteVariantAccess<TAccess extends PairedRouteAccess = PairedRouteAccess> = `${RouteVariant}${Capitalize<TAccess>}`;
|
|
386
405
|
/** Known route guards with the existing trusted custom access-string compatibility. */
|
|
387
|
-
type RouteGuardAccess = RouteBaseAccess |
|
|
406
|
+
type RouteGuardAccess = RouteBaseAccess | (string & {});
|
|
388
407
|
type DocPermissionsAccess = 'list' | 'create' | 'read' | 'update' | string;
|
|
389
408
|
type BaseFilterAccess = 'list' | 'read' | 'update' | 'delete' | string;
|
|
390
409
|
type DecorateAccess = 'list' | 'create' | 'read' | 'update' | string;
|
|
@@ -418,7 +437,7 @@ type DataIdentifierHook<TValue = unknown> = IdentifierHook<TValue, DataRequest>;
|
|
|
418
437
|
type ModelValidateHook = ValidateHook<ModelRequest>;
|
|
419
438
|
/**
|
|
420
439
|
* Request-user grants from untrimmed projected input. Declare private persisted inputs
|
|
421
|
-
*
|
|
440
|
+
* on a {@link ModelDocPermissionsDescriptor}. Integrated output resolves once per document/access stage,
|
|
422
441
|
* independently of skim or metadata serialization. Returned DTOs carry no authority;
|
|
423
442
|
* use a fresh normal query for current document-dependent authorization.
|
|
424
443
|
* Return a plain record of literal booleans. The library owns a frozen detached
|
|
@@ -432,6 +451,41 @@ type ModelValidateHook = ValidateHook<ModelRequest>;
|
|
|
432
451
|
* external caches and database state are neither sandboxed nor kept fresh after await.
|
|
433
452
|
*/
|
|
434
453
|
type ModelDocPermissionsHook = DocPermissionsHook<ModelRequest>;
|
|
454
|
+
/**
|
|
455
|
+
* A document-permission calculation and its private persisted inputs. `dependsOn`
|
|
456
|
+
* uses model-local top-level persisted keys, like virtuals (declare the whole
|
|
457
|
+
* container for nested data). Dotted, unsafe, unknown and virtual names reject.
|
|
458
|
+
* Absent/empty dependencies add no fetch inputs; missing/undefined input values
|
|
459
|
+
* NEVER skip `get`. `get` keeps ModelDocPermissionsHook's arguments, request `this`,
|
|
460
|
+
* sync/async boolean-map result and once-per-stage semantics.
|
|
461
|
+
*
|
|
462
|
+
* Only the applicable docPermissions access (exact, then default) supplies inputs,
|
|
463
|
+
* independently of output/virtual access. Fetching a dependency grants no output;
|
|
464
|
+
* it remains hidden unless independently selected AND authorized. Embedded scopes
|
|
465
|
+
* share owning-document facts; related targets and pre/post-write stages resolve anew.
|
|
466
|
+
*/
|
|
467
|
+
interface ModelDocPermissionsDescriptor<TModel = unknown> {
|
|
468
|
+
/** Calculation with the original request `this`; runs even when declared inputs are missing. */
|
|
469
|
+
get: ModelDocPermissionsHook;
|
|
470
|
+
/** Private top-level persisted keys; no output grant. Use the whole container for nested data. */
|
|
471
|
+
dependsOn?: readonly AccessRouterFieldKey<NoInfer<TModel>>[];
|
|
472
|
+
}
|
|
473
|
+
/** One callable calculation or a descriptor; usable directly or as an access/default entry. */
|
|
474
|
+
type ModelDocPermissionsDefinition<TModel = unknown> = ModelDocPermissionsHook | ModelDocPermissionsDescriptor<TModel>;
|
|
475
|
+
/**
|
|
476
|
+
* Per-access definitions, including `default` fallback and trusted custom accesses.
|
|
477
|
+
* An undefined entry inherits default; an absent exact/default entry runs no hook.
|
|
478
|
+
* `get` and `dependsOn` are reserved descriptor members, not custom access names.
|
|
479
|
+
* Entries replace whole definitions: dependencies never inherit from another access.
|
|
480
|
+
*/
|
|
481
|
+
interface ModelDocPermissionsAccessRecord<TModel = unknown> {
|
|
482
|
+
default?: ModelDocPermissionsDefinition<TModel>;
|
|
483
|
+
list?: ModelDocPermissionsDefinition<TModel>;
|
|
484
|
+
create?: ModelDocPermissionsDefinition<TModel>;
|
|
485
|
+
read?: ModelDocPermissionsDefinition<TModel>;
|
|
486
|
+
update?: ModelDocPermissionsDefinition<TModel>;
|
|
487
|
+
[access: string]: ModelDocPermissionsDefinition<TModel> | undefined;
|
|
488
|
+
}
|
|
435
489
|
type ModelChangeHook = ChangeHook<ModelRequest>;
|
|
436
490
|
type ModelDocumentHook<TValue = unknown> = DocumentHookChain<TValue, ModelRequest>;
|
|
437
491
|
type ModelDeleteHook<TValue = unknown> = DeleteHook<ModelDocument<TValue>, ModelRequest>;
|
|
@@ -825,11 +879,12 @@ declare class AccessRuntime {
|
|
|
825
879
|
/**
|
|
826
880
|
* Generic stored exact → parent.default → parent lookup; only undefined falls through.
|
|
827
881
|
* The exact runtime-model-default path is the final fallback if the stored parent is
|
|
828
|
-
* absent. This is not the
|
|
829
|
-
*
|
|
882
|
+
* absent. This raw generic lookup is not the final nested operation-entry resolver;
|
|
883
|
+
* it may return an operation object. getExactModelOption inspects a member including
|
|
884
|
+
* its same-owner exact model-default fallback, without resolving entry policy.
|
|
830
885
|
*/
|
|
831
886
|
getModelOption<K extends keyof ExtendedModelRouterOptions<TModel, TVirtuals>, TModel = unknown, TVirtuals extends object = Record<never, never>>(modelName: string, key: K | string, defaultValue?: ExtendedModelRouterOptions<TModel, TVirtuals>[K]): ExtendedModelRouterOptions<TModel, TVirtuals>[K];
|
|
832
|
-
/** Exact stored path, then the same runtime-model-default path; no parent/default or
|
|
887
|
+
/** Exact stored path, then the same runtime-model-default path; no parent/default or final entry resolution. */
|
|
833
888
|
getExactModelOption<K extends keyof ExtendedModelRouterOptions<TModel, TVirtuals>, TModel = unknown, TVirtuals extends object = Record<never, never>>(modelName: string, key: K | string): ExtendedModelRouterOptions<TModel, TVirtuals>[K];
|
|
834
889
|
/**
|
|
835
890
|
* List registered virtual leaf names for a scope (VIRT-01).
|
|
@@ -906,8 +961,10 @@ declare class DataCore {
|
|
|
906
961
|
setPermissions(): Promise<void>;
|
|
907
962
|
canActivate(routeGuard: Validation): Promise<boolean>;
|
|
908
963
|
isAllowed(dataName: string, access: RouteGuardAccess | string): Promise<boolean>;
|
|
909
|
-
/** Authorize
|
|
910
|
-
isAllowedRoute(dataName: string, baseAccess: RouteGuardAccess | string,
|
|
964
|
+
/** Authorize entry using explicit server-owned basic/advanced/root metadata. */
|
|
965
|
+
isAllowedRoute(dataName: string, baseAccess: RouteGuardAccess | string, context: OperationAccessContext): Promise<boolean>;
|
|
966
|
+
/** Data policy has no model-default reader; base calls never select entry members. */
|
|
967
|
+
private resolveOperationAccess;
|
|
911
968
|
getService<TData = unknown>(dataName: string): DataService<TData>;
|
|
912
969
|
service<TData = unknown>(dataName: string): DataService<TData>;
|
|
913
970
|
svc<TData = unknown>(dataName: string): DataService<TData>;
|
|
@@ -1126,7 +1183,7 @@ type ServiceOutputDecorator = (doc: unknown, context: ServiceOutputContext) => u
|
|
|
1126
1183
|
* resolves a fresh policy and returns persisted fetch inputs, including private
|
|
1127
1184
|
* dependencies/identity, not an output allowlist. Document rules are deferred;
|
|
1128
1185
|
* planning invokes no permission functions or virtual getters. Declare additional
|
|
1129
|
-
* projected document-hook inputs
|
|
1186
|
+
* projected document-hook inputs on docPermissions descriptors' dependsOn. No rows/baseFields/skip flags.
|
|
1130
1187
|
* Omitted/undefined options equal {} (canonical request-mode output planning).
|
|
1131
1188
|
* Positional booleans, scope arrays and extra arguments have been removed and reject.
|
|
1132
1189
|
*/
|
|
@@ -1562,6 +1619,8 @@ interface PublicCreateOptions {
|
|
|
1562
1619
|
* Include field-level `_view`/`_edit` maps. Defaults to `includePermissions`
|
|
1563
1620
|
* when omitted. `includePermissions: true` + `includeFieldPermissions: false`
|
|
1564
1621
|
* keeps `docPermissions`-hook keys but omits `_view`/`_edit` entirely.
|
|
1622
|
+
* Requires model `disableFieldPermissions: false`; otherwise ignored (the
|
|
1623
|
+
* model option defaults to `true`).
|
|
1565
1624
|
* Internal document grants are computed independently of both metadata flags
|
|
1566
1625
|
* and skim. These maps describe request-user permissions, never backend grants.
|
|
1567
1626
|
*/
|
|
@@ -1596,6 +1655,8 @@ interface PublicUpdateOptions {
|
|
|
1596
1655
|
* Include field-level `_view`/`_edit` maps. Defaults to `includePermissions`
|
|
1597
1656
|
* when omitted. `includePermissions: true` + `includeFieldPermissions: false`
|
|
1598
1657
|
* keeps `docPermissions`-hook keys but omits `_view`/`_edit` entirely.
|
|
1658
|
+
* Requires model `disableFieldPermissions: false`; otherwise ignored (the
|
|
1659
|
+
* model option defaults to `true`).
|
|
1599
1660
|
* Internal document grants are computed independently of both metadata flags
|
|
1600
1661
|
* and skim. These maps describe request-user permissions, never backend grants.
|
|
1601
1662
|
*/
|
|
@@ -1632,6 +1693,8 @@ interface PublicReadOptions {
|
|
|
1632
1693
|
* Include field-level `_view`/`_edit` maps. Defaults to `includePermissions`
|
|
1633
1694
|
* when omitted. `includePermissions: true` + `includeFieldPermissions: false`
|
|
1634
1695
|
* keeps `docPermissions`-hook keys but omits `_view`/`_edit` entirely.
|
|
1696
|
+
* Requires model `disableFieldPermissions: false`; otherwise ignored (the
|
|
1697
|
+
* model option defaults to `true`).
|
|
1635
1698
|
* Full internal document grants resolve independently of both metadata flags
|
|
1636
1699
|
* and skim. These maps describe request-user permissions, never backend grants.
|
|
1637
1700
|
*/
|
|
@@ -1663,6 +1726,8 @@ interface FindOptions<TModel = unknown, TVirtuals extends object = Record<never,
|
|
|
1663
1726
|
* Include field-level `_view`/`_edit` maps. Defaults to `includePermissions`
|
|
1664
1727
|
* when omitted. `includePermissions: true` + `includeFieldPermissions: false`
|
|
1665
1728
|
* keeps `docPermissions`-hook keys but omits `_view`/`_edit` entirely.
|
|
1729
|
+
* Requires model `disableFieldPermissions: false`; otherwise ignored (the
|
|
1730
|
+
* model option defaults to `true`).
|
|
1666
1731
|
* Internal document grants are computed independently of both metadata flags
|
|
1667
1732
|
* and skim. These maps describe request-user permissions, never backend grants.
|
|
1668
1733
|
*/
|
|
@@ -1690,6 +1755,8 @@ interface FindOneOptions<TModel = unknown, TVirtuals extends object = Record<nev
|
|
|
1690
1755
|
* Include field-level `_view`/`_edit` maps. Defaults to `includePermissions`
|
|
1691
1756
|
* when omitted. `includePermissions: true` + `includeFieldPermissions: false`
|
|
1692
1757
|
* keeps `docPermissions`-hook keys but omits `_view`/`_edit` entirely.
|
|
1758
|
+
* Requires model `disableFieldPermissions: false`; otherwise ignored (the
|
|
1759
|
+
* model option defaults to `true`).
|
|
1693
1760
|
* Internal document grants are computed independently of both metadata flags
|
|
1694
1761
|
* and skim. These maps describe request-user permissions, never backend grants.
|
|
1695
1762
|
*/
|
|
@@ -1716,9 +1783,13 @@ type RequestSchema = RequestSchemaLike;
|
|
|
1716
1783
|
/**
|
|
1717
1784
|
* One engine, two source-isolation modes. `isolated` (default) owns bounded detached
|
|
1718
1785
|
* projected source and disposable doc-hook views; `trusted` may borrow admitted ordinary
|
|
1719
|
-
* source/doc-hook input.
|
|
1786
|
+
* source/doc-hook input. CREATE/UPDATE output, including write-origin related targets,
|
|
1787
|
+
* always acquires a bounded detached source first; trusted omits only the subsequent
|
|
1788
|
+
* disposable doc-hook view copy. Actor, policy, normalized boolean facts and selected/native
|
|
1720
1789
|
* output bounds remain owned/enforced in BOTH. No callback sandbox, transaction,
|
|
1721
1790
|
* external-cache/database freshness or blanket security-equivalence promise.
|
|
1791
|
+
* Captured independently for READ/LIST output and CREATE/UPDATE post-write output;
|
|
1792
|
+
* these settings never relax write-input admission or pre-write hooks.
|
|
1722
1793
|
* See the installed MIGRATION.md before choosing trusted.
|
|
1723
1794
|
*/
|
|
1724
1795
|
type AuthorizationMode = 'isolated' | 'trusted';
|
|
@@ -1726,29 +1797,24 @@ type NestedRequestSchema = {
|
|
|
1726
1797
|
default?: RequestSchema;
|
|
1727
1798
|
data?: RequestSchema;
|
|
1728
1799
|
};
|
|
1800
|
+
type RemovedOperationAccessKeys = `${'basic' | 'advanced'}${Capitalize<PairedRouteAccess>}`;
|
|
1729
1801
|
/**
|
|
1730
|
-
*
|
|
1731
|
-
*
|
|
1732
|
-
*
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
create?:
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
/**
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
advancedList?: Validation;
|
|
1747
|
-
/** GET /:id/<field>/:subId (and HEAD); undefined inherits this field's `read` rule. */
|
|
1748
|
-
basicRead?: Validation;
|
|
1749
|
-
/** POST /:id/<field>/:subId/__query; undefined inherits this field's `read` rule. */
|
|
1750
|
-
advancedRead?: Validation;
|
|
1751
|
-
[access: string]: Validation | undefined;
|
|
1802
|
+
* A defined field is a closed object: missing operations/defaults deny, never inherit
|
|
1803
|
+
* the outer operationAccess.default. Only an absent field uses top-level rules.
|
|
1804
|
+
* Exact same-owner runtime context defaults precede operation/scalar field fallback.
|
|
1805
|
+
*/
|
|
1806
|
+
interface SubOperationAccess extends Partial<Record<RemovedOperationAccessKeys, never>> {
|
|
1807
|
+
/** GET /:id/<sub> selects basic; POST /:id/<sub>/__query selects advanced; root subList selects root. */
|
|
1808
|
+
list?: OperationAccessRule;
|
|
1809
|
+
/** GET /:id/<sub>/:subId selects basic; POST /:id/<sub>/:subId/__query selects advanced; root subRead selects root. */
|
|
1810
|
+
read?: OperationAccessRule;
|
|
1811
|
+
/** Direct POST selects basic; root subCreate selects root. */
|
|
1812
|
+
create?: OperationAccessRule;
|
|
1813
|
+
/** Both direct PATCH paths select basic; root subUpdate/subBulkUpdate select root. */
|
|
1814
|
+
update?: OperationAccessRule;
|
|
1815
|
+
/** Direct DELETE selects basic; root subDelete selects root. */
|
|
1816
|
+
delete?: OperationAccessRule;
|
|
1817
|
+
[access: string]: OperationAccessRule | undefined;
|
|
1752
1818
|
}
|
|
1753
1819
|
/** Per-field subdocument route objects or scalar guards; field names remain dynamic. */
|
|
1754
1820
|
type SubRouteGuardOptions = Record<string, Validation | SubOperationAccess>;
|
|
@@ -1852,7 +1918,7 @@ interface GlobalOptions {
|
|
|
1852
1918
|
interface RootRouterOptions {
|
|
1853
1919
|
/** Mount path of the batch POST endpoint; mount the returned router.routes in Express. */
|
|
1854
1920
|
basePath: string;
|
|
1855
|
-
/**
|
|
1921
|
+
/** Independent scalar outer batch guard. Entries keep base op names but select each target operation's root member. */
|
|
1856
1922
|
operationAccess?: Validation;
|
|
1857
1923
|
/** Maximum entries per batch (default 100). Invalid/non-positive/unsafe constructor values use the default. */
|
|
1858
1924
|
maxBatchEntries?: number;
|
|
@@ -1884,70 +1950,58 @@ interface FieldOperationAccess {
|
|
|
1884
1950
|
subs?: FieldValidation | SubFieldPermissionOptions;
|
|
1885
1951
|
}
|
|
1886
1952
|
/**
|
|
1887
|
-
*
|
|
1888
|
-
*
|
|
1889
|
-
*
|
|
1890
|
-
*
|
|
1891
|
-
*
|
|
1892
|
-
*
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
*/
|
|
1896
|
-
|
|
1897
|
-
/** GET /
|
|
1898
|
-
|
|
1899
|
-
/**
|
|
1900
|
-
|
|
1901
|
-
/**
|
|
1902
|
-
|
|
1903
|
-
/**
|
|
1904
|
-
|
|
1905
|
-
/**
|
|
1906
|
-
|
|
1907
|
-
/**
|
|
1908
|
-
|
|
1909
|
-
/**
|
|
1910
|
-
|
|
1911
|
-
/**
|
|
1912
|
-
|
|
1913
|
-
/**
|
|
1914
|
-
count?: Validation;
|
|
1915
|
-
/** Fallback for a base operation without an exact rule; explicit base/variant guards take precedence. */
|
|
1953
|
+
* Request entry guards, separate from field grants. Direct denial is HTTP 401;
|
|
1954
|
+
* root denial is per-entry unauthorized. Exact basic/advanced/root member → operation
|
|
1955
|
+
* scalar/default → outer default/shorthand → deny; only undefined inherits.
|
|
1956
|
+
* Same-owner runtime exact context defaults precede operation fallback. Objects replace
|
|
1957
|
+
* shallowly, not recursively. Base/secondary checks omit context and use scalar/default.
|
|
1958
|
+
* Retired flat keys reject with migration diagnostics, never compatibility aliases.
|
|
1959
|
+
*/
|
|
1960
|
+
interface OperationAccess extends Partial<Record<RemovedOperationAccessKeys, never>> {
|
|
1961
|
+
/** GET /new selects basic; root new selects root. Advanced does not add a route. */
|
|
1962
|
+
new?: OperationAccessRule;
|
|
1963
|
+
/** GET / selects basic; POST /__query selects advanced; root list selects root. Base read-to-list retries use scalar/default. */
|
|
1964
|
+
list?: OperationAccessRule;
|
|
1965
|
+
/** POST / selects basic; POST /__mutation selects advanced; root create selects root. Only undefined inherits. */
|
|
1966
|
+
create?: OperationAccessRule;
|
|
1967
|
+
/** GET /:id selects basic; both POST read routes (/__query/:id and /__query/__filter) select advanced; root read selects root. */
|
|
1968
|
+
read?: OperationAccessRule;
|
|
1969
|
+
/** PATCH /:id selects basic; PATCH /__mutation/:id selects advanced; root update selects root. Only undefined inherits. */
|
|
1970
|
+
update?: OperationAccessRule;
|
|
1971
|
+
/** PUT / selects basic; PUT /__mutation selects advanced; root upsert selects root. Branch policy is unchanged. */
|
|
1972
|
+
upsert?: OperationAccessRule;
|
|
1973
|
+
/** DELETE /:id selects basic; root delete selects root. Advanced does not add a route. */
|
|
1974
|
+
delete?: OperationAccessRule;
|
|
1975
|
+
/** GET /distinct/:field selects basic; POST /distinct/:field selects advanced; root distinct selects root. */
|
|
1976
|
+
distinct?: OperationAccessRule;
|
|
1977
|
+
/** GET /count selects basic; POST /count selects advanced; root count selects root. */
|
|
1978
|
+
count?: OperationAccessRule;
|
|
1979
|
+
/** Outer scalar fallback, never a nested operation rule. */
|
|
1916
1980
|
default?: Validation;
|
|
1917
|
-
/**
|
|
1918
|
-
|
|
1919
|
-
/** POST /__query override for model/data list; undefined inherits `list`. */
|
|
1920
|
-
advancedList?: Validation;
|
|
1921
|
-
/** GET /:id (and HEAD) override for model/data read; undefined inherits `read`. */
|
|
1922
|
-
basicRead?: Validation;
|
|
1923
|
-
/** POST /__query/:id and /__query/__filter override for model/data read; undefined inherits `read`. */
|
|
1924
|
-
advancedRead?: Validation;
|
|
1925
|
-
/** POST / model create override; undefined inherits `create`. */
|
|
1926
|
-
basicCreate?: Validation;
|
|
1927
|
-
/** POST /__mutation model create override; undefined inherits `create`. */
|
|
1928
|
-
advancedCreate?: Validation;
|
|
1929
|
-
/** PATCH /:id model update override; undefined inherits `update`. */
|
|
1930
|
-
basicUpdate?: Validation;
|
|
1931
|
-
/** PATCH /__mutation/:id model update override; undefined inherits `update`. */
|
|
1932
|
-
advancedUpdate?: Validation;
|
|
1933
|
-
/** PUT / model upsert override; undefined inherits `upsert`. */
|
|
1934
|
-
basicUpsert?: Validation;
|
|
1935
|
-
/** PUT /__mutation model upsert override; undefined inherits `upsert`. */
|
|
1936
|
-
advancedUpsert?: Validation;
|
|
1937
|
-
/** GET /count model count override; undefined inherits `count`. */
|
|
1938
|
-
basicCount?: Validation;
|
|
1939
|
-
/** POST /count model filtered-count override; undefined inherits `count`. */
|
|
1940
|
-
advancedCount?: Validation;
|
|
1941
|
-
/** GET /distinct/:field model distinct override; undefined inherits `distinct`. */
|
|
1942
|
-
basicDistinct?: Validation;
|
|
1943
|
-
/** POST /distinct/:field model filtered-distinct override; undefined inherits `distinct`. */
|
|
1944
|
-
advancedDistinct?: Validation;
|
|
1945
|
-
/**
|
|
1946
|
-
* Per-field scalar or closed-object guards, with list/read variants. Legacy scalar
|
|
1981
|
+
/**
|
|
1982
|
+
* Per-field scalar or closed-object guards, with nested operation rules. Legacy scalar
|
|
1947
1983
|
* `subs` is accepted but is not an umbrella guard for absent fields; they use top-level rules.
|
|
1948
1984
|
*/
|
|
1949
1985
|
subs?: Validation | SubRouteGuardOptions;
|
|
1950
1986
|
}
|
|
1987
|
+
/** Typed relative operationAccess setter paths, including dynamic subdocument fields. */
|
|
1988
|
+
type OperationAccessPaths = {
|
|
1989
|
+
default?: Validation;
|
|
1990
|
+
subs?: Validation | SubRouteGuardOptions;
|
|
1991
|
+
} & Partial<Record<PairedRouteAccess | 'new' | 'delete', OperationAccessRule>> & Partial<Record<`${PairedRouteAccess | 'new' | 'delete'}.${keyof OperationAccessVariants}`, Validation>> & {
|
|
1992
|
+
[key: `subs.${string}`]: OperationAccessRule | SubOperationAccess | undefined;
|
|
1993
|
+
[key: `subs.${string}.${'list' | 'read' | 'create' | 'update' | 'delete'}`]: OperationAccessRule | undefined;
|
|
1994
|
+
[key: `subs.${string}.${'list' | 'read' | 'create' | 'update' | 'delete'}.${keyof OperationAccessVariants}`]: Validation | undefined;
|
|
1995
|
+
};
|
|
1996
|
+
type OperationAccessOptionPaths = {
|
|
1997
|
+
[K in keyof OperationAccessPaths as `operationAccess.${K & string}`]: OperationAccessPaths[K];
|
|
1998
|
+
};
|
|
1999
|
+
/** Fluent guards retain a trusted custom-string escape hatch; retired keys still throw at runtime. */
|
|
2000
|
+
type OperationAccessSetter<TRouter> = {
|
|
2001
|
+
(options: Validation | OperationAccess | undefined): TRouter;
|
|
2002
|
+
<K extends keyof OperationAccessPaths>(key: K, value: OperationAccessPaths[K]): TRouter;
|
|
2003
|
+
(key: string, value: unknown): TRouter;
|
|
2004
|
+
};
|
|
1951
2005
|
type PermissionRule = FieldValidation | (FieldOperationAccess & {
|
|
1952
2006
|
sub?: PermissionSchema;
|
|
1953
2007
|
});
|
|
@@ -1958,12 +2012,6 @@ type PermissionRule = FieldValidation | (FieldOperationAccess & {
|
|
|
1958
2012
|
* Data helpers keep whole-container picks at root; a scoped child pick applies sub rules.
|
|
1959
2013
|
*/
|
|
1960
2014
|
type PermissionSchema<TField extends string = string> = Partial<Record<TField, PermissionRule>>;
|
|
1961
|
-
interface DocPermissions {
|
|
1962
|
-
list?: ModelDocPermissionsHook;
|
|
1963
|
-
create?: ModelDocPermissionsHook;
|
|
1964
|
-
read?: ModelDocPermissionsHook;
|
|
1965
|
-
update?: ModelDocPermissionsHook;
|
|
1966
|
-
}
|
|
1967
2015
|
/**
|
|
1968
2016
|
* Mongoose fetch mode, not an output type. Both modes finalize plain objects;
|
|
1969
2017
|
* schema defaults, getters, transforms and init hooks can still change values.
|
|
@@ -2118,12 +2166,15 @@ interface DefaultModelRouterOptions<TModel = unknown> {
|
|
|
2118
2166
|
queryRouteSegment?: string;
|
|
2119
2167
|
mutationRouteSegment?: string;
|
|
2120
2168
|
/**
|
|
2121
|
-
* Live model
|
|
2122
|
-
* `{ list: true, read: true,
|
|
2169
|
+
* Live model entry guards: scalar Validation shorthand or nested operation rules.
|
|
2170
|
+
* `{ list: true, read: { default: true, basic: false } }` denies only GET /:id (and HEAD)
|
|
2123
2171
|
* among top-level routes, retaining both advanced read POSTs subject to ordinary
|
|
2124
2172
|
* field/row policy. Subdocument reads follow their field-rule precedence.
|
|
2125
|
-
*
|
|
2173
|
+
* Root selects read.root, independently of direct entries. Same-owner exact runtime
|
|
2174
|
+
* context defaults precede operation fallback; option objects replace
|
|
2126
2175
|
* top-level keys shallowly, rather than recursively merging operationAccess.
|
|
2176
|
+
* Omission inherits model defaults; explicit whole undefined permits exact-operation
|
|
2177
|
+
* fallback but not a runtime bare/outer catch-all. Without a grant, deny.
|
|
2127
2178
|
*/
|
|
2128
2179
|
operationAccess?: Validation | OperationAccess;
|
|
2129
2180
|
modelPermissionPrefix?: string;
|
|
@@ -2168,16 +2219,23 @@ interface DefaultModelRouterOptions<TModel = unknown> {
|
|
|
2168
2219
|
* When `true`, client `includeFieldPermissions` input (query params,
|
|
2169
2220
|
* body/root-batch options and service-direct options) as well as
|
|
2170
2221
|
* per-operation `defaults` are ignored and field maps (`_view`/`_edit`)
|
|
2171
|
-
* are
|
|
2172
|
-
* `
|
|
2222
|
+
* are neither computed nor emitted, including empty placeholders.
|
|
2223
|
+
* `docPermissions`-hook keys still follow `includePermissions`; when none
|
|
2224
|
+
* are included, the permissions field is an empty object. Use
|
|
2225
|
+
* `stripPermissionsField` to remove the field entirely. Defaults to `true`;
|
|
2226
|
+
* set `false` on the model or runtime model defaults to allow field maps.
|
|
2227
|
+
* Permission enforcement is unaffected.
|
|
2173
2228
|
*/
|
|
2174
2229
|
disableFieldPermissions?: boolean;
|
|
2175
2230
|
/**
|
|
2176
|
-
* Server model/default-model READ source isolation; default `isolated`.
|
|
2231
|
+
* Server model/default-model READ output source isolation; default `isolated`.
|
|
2177
2232
|
* Only literal `isolated` / `trusted`; undefined restores inheritance. Captured
|
|
2178
2233
|
* before hooks/awaits; READ-to-LIST retries keep the initiating READ mode but use a
|
|
2179
2234
|
* fresh stage. Embedded scopes inherit their genuine owner; related targets capture
|
|
2180
|
-
* their own model/access mode and policy
|
|
2235
|
+
* their own model/access mode and policy, including genuine write-origin populate.
|
|
2236
|
+
* This setting never selects the root CREATE/UPDATE mode. Write-origin targets
|
|
2237
|
+
* still require full bounded source detachment before trusted hook-view borrowing.
|
|
2238
|
+
* Independent service calls capture anew.
|
|
2181
2239
|
* No per-call, helper, method-default, HTTP/root/include/populate/subquery selector.
|
|
2182
2240
|
* Retired unsafe controls reject by presence, even false/undefined or inherited.
|
|
2183
2241
|
* Warns once per effective owner/access transition into trusted; logger failures
|
|
@@ -2197,11 +2255,14 @@ interface DefaultModelRouterOptions<TModel = unknown> {
|
|
|
2197
2255
|
* Independent server model/default-model LIST source isolation; default `isolated`.
|
|
2198
2256
|
* Literal `isolated` / `trusted` only; undefined restores inheritance. Both modes
|
|
2199
2257
|
* capture actor/policy before hooks/awaits and normalize facts once per stage. Only source
|
|
2200
|
-
* borrowing changes: trusted doc-hook mutations can affect values/calculated facts
|
|
2201
|
-
* no whole-document bounds on hidden unvisited
|
|
2258
|
+
* borrowing changes: trusted doc-hook mutations can affect values/calculated facts.
|
|
2259
|
+
* Query-origin trusted output has no whole-document bounds on hidden unvisited
|
|
2260
|
+
* graphs; write-origin targets always acquire a fully bounded detached source first.
|
|
2261
|
+
* Selected 20,000-slot/depth 100
|
|
2202
2262
|
* bounds, original actor, rows/fields/targets, getter views and private argument-four
|
|
2203
2263
|
* isolation remain. Related targets use their own captured mode; embedded scopes
|
|
2204
|
-
* inherit their owner.
|
|
2264
|
+
* inherit their owner. Target-local READ/LIST modes also select genuine write-origin
|
|
2265
|
+
* populate, never the root write mode. NEW/helpers/dedicated origins remain excluded.
|
|
2205
2266
|
* Atomic setters and new-call-only rollback follow readAuthorizationMode. There is
|
|
2206
2267
|
* no one-to-one mapping from old mixed flags and no reusable output handle.
|
|
2207
2268
|
*
|
|
@@ -2217,38 +2278,59 @@ interface DefaultModelRouterOptions<TModel = unknown> {
|
|
|
2217
2278
|
* ```
|
|
2218
2279
|
*/
|
|
2219
2280
|
listAuthorizationMode?: AuthorizationMode;
|
|
2281
|
+
/**
|
|
2282
|
+
* Independent server model/default-model CREATE post-write output isolation;
|
|
2283
|
+
* default `isolated`. Literal `isolated` / `trusted` only; undefined restores
|
|
2284
|
+
* inheritance. Captured before hooks/awaits, including both UPSERT branch modes.
|
|
2285
|
+
* Selects CREATE output (including bulk rows and the executed UPSERT-create branch),
|
|
2286
|
+
* never input admission, validation, preparation, persistence or lifecycle hooks.
|
|
2287
|
+
* Both modes first acquire a full bounded detached source, including mutable native
|
|
2288
|
+
* leaves, never live write documents, payloads or lifecycle snapshots. Trusted may
|
|
2289
|
+
* omit the subsequent disposable document-hook view copy. Hook mutations may affect response
|
|
2290
|
+
* values/facts, not input authority. Output failure does not roll back a stored write.
|
|
2291
|
+
* Embedded output inherits its owner; related targets retain their own READ/LIST
|
|
2292
|
+
* mode/policy. Atomic setters, warnings and server-only placement follow readAuthorizationMode.
|
|
2293
|
+
*
|
|
2294
|
+
* @example
|
|
2295
|
+
* ```ts
|
|
2296
|
+
* import { createAccessRuntime } from '@web-ts-toolkit/access-router';
|
|
2297
|
+
* const api = createAccessRuntime();
|
|
2298
|
+
* api.setDefaultModelOptions({ createAuthorizationMode: 'isolated', updateAuthorizationMode: 'isolated' });
|
|
2299
|
+
* api.setModelOption('Employee', 'createAuthorizationMode', 'trusted'); // post-write output only
|
|
2300
|
+
* api.setModelOption('Employee', 'createAuthorizationMode', undefined); // inherit
|
|
2301
|
+
* ```
|
|
2302
|
+
*/
|
|
2303
|
+
createAuthorizationMode?: AuthorizationMode;
|
|
2304
|
+
/**
|
|
2305
|
+
* Independent server model/default-model UPDATE post-write output isolation;
|
|
2306
|
+
* default `isolated`. Literal `isolated` / `trusted` only; undefined restores
|
|
2307
|
+
* inheritance. Captured before hooks/awaits; the executed UPSERT-update branch uses
|
|
2308
|
+
* this capture, not live settings after saving. No separate UPSERT mode exists.
|
|
2309
|
+
* Applies only after persistence/lifecycle processing. Pre-write grants, hydrated
|
|
2310
|
+
* input-hook arguments, input fields, validation, transform/save and lifecycle
|
|
2311
|
+
* behavior are unchanged. Trusted output still requires detachment from live write
|
|
2312
|
+
* storage, payloads and snapshots; output failure may follow a successful write.
|
|
2313
|
+
* Embedded/related ownership, atomic setters, warnings and server-only placement
|
|
2314
|
+
* follow createAuthorizationMode. Changing modes affects new calls only.
|
|
2315
|
+
* No implicit saves, re-fetches or rollback; arbitrary callback closures are not sandboxed.
|
|
2316
|
+
*
|
|
2317
|
+
* @example
|
|
2318
|
+
* ```ts
|
|
2319
|
+
* import { createAccessRuntime } from '@web-ts-toolkit/access-router';
|
|
2320
|
+
* const api = createAccessRuntime();
|
|
2321
|
+
* api.setModelOptions('Employee', { createAuthorizationMode: 'isolated', updateAuthorizationMode: 'trusted' });
|
|
2322
|
+
* // UPSERT selects the captured CREATE or UPDATE setting for its executed branch.
|
|
2323
|
+
* api.setModelOption('Employee', 'updateAuthorizationMode', 'isolated'); // new calls only
|
|
2324
|
+
* ```
|
|
2325
|
+
*/
|
|
2326
|
+
updateAuthorizationMode?: AuthorizationMode;
|
|
2220
2327
|
}
|
|
2221
|
-
interface ExtendedDefaultModelRouterOptions<TModel = unknown> extends DefaultModelRouterOptions<TModel
|
|
2328
|
+
interface ExtendedDefaultModelRouterOptions<TModel = unknown> extends DefaultModelRouterOptions<TModel>, OperationAccessOptionPaths {
|
|
2222
2329
|
'hydration.publicList'?: HydrationMode;
|
|
2223
2330
|
'hydration.publicRead'?: HydrationMode;
|
|
2224
2331
|
'hydration.find'?: HydrationMode;
|
|
2225
2332
|
'hydration.findOne'?: HydrationMode;
|
|
2226
2333
|
'hydration.findById'?: HydrationMode;
|
|
2227
|
-
'operationAccess.default'?: Validation;
|
|
2228
|
-
'operationAccess.new'?: Validation;
|
|
2229
|
-
'operationAccess.list'?: Validation;
|
|
2230
|
-
'operationAccess.read'?: Validation;
|
|
2231
|
-
'operationAccess.update'?: Validation;
|
|
2232
|
-
'operationAccess.upsert'?: Validation;
|
|
2233
|
-
'operationAccess.delete'?: Validation;
|
|
2234
|
-
'operationAccess.create'?: Validation;
|
|
2235
|
-
'operationAccess.distinct'?: Validation;
|
|
2236
|
-
'operationAccess.count'?: Validation;
|
|
2237
|
-
'operationAccess.basicList'?: Validation;
|
|
2238
|
-
'operationAccess.advancedList'?: Validation;
|
|
2239
|
-
'operationAccess.basicRead'?: Validation;
|
|
2240
|
-
'operationAccess.advancedRead'?: Validation;
|
|
2241
|
-
'operationAccess.basicCreate'?: Validation;
|
|
2242
|
-
'operationAccess.advancedCreate'?: Validation;
|
|
2243
|
-
'operationAccess.basicUpdate'?: Validation;
|
|
2244
|
-
'operationAccess.advancedUpdate'?: Validation;
|
|
2245
|
-
'operationAccess.basicUpsert'?: Validation;
|
|
2246
|
-
'operationAccess.advancedUpsert'?: Validation;
|
|
2247
|
-
'operationAccess.basicCount'?: Validation;
|
|
2248
|
-
'operationAccess.advancedCount'?: Validation;
|
|
2249
|
-
'operationAccess.basicDistinct'?: Validation;
|
|
2250
|
-
'operationAccess.advancedDistinct'?: Validation;
|
|
2251
|
-
'operationAccess.subs'?: Validation | SubRouteGuardOptions;
|
|
2252
2334
|
}
|
|
2253
2335
|
/**
|
|
2254
2336
|
* Per-registered-model configuration for api.createRouter(model, options).
|
|
@@ -2330,20 +2412,17 @@ interface ModelRouterOptions<TModel = unknown, TVirtuals extends object = Record
|
|
|
2330
2412
|
* ```
|
|
2331
2413
|
*/
|
|
2332
2414
|
virtuals?: ModelVirtuals<TModel, TVirtuals>;
|
|
2333
|
-
/**
|
|
2334
|
-
* Private persisted fetch inputs for projected document hooks (for example ownerId).
|
|
2335
|
-
* An array applies to every access; a per-access record uses its exact entry, then
|
|
2336
|
-
* default. These fields do not grant output. Integrated output captures the inputs
|
|
2337
|
-
* for both output and document-permission access, independently of metadata flags.
|
|
2338
|
-
*/
|
|
2339
|
-
alwaysSelectFields?: string[] | Record<string, string[]>;
|
|
2340
2415
|
/**
|
|
2341
2416
|
* Once-per-root/target projected document grants, independently of skim/metadata.
|
|
2342
2417
|
* Both source modes own one immutable boolean map. Genuine embedded scopes share
|
|
2343
2418
|
* owning facts; related targets and independent pre/post-write stages resolve anew.
|
|
2344
2419
|
* Output contexts are immutable diagnostics, never source or reusable authority.
|
|
2420
|
+
* Accepts a callable or { get, dependsOn? }, directly or in an exact/default/custom
|
|
2421
|
+
* access record. Only the active document-permission definition adds private inputs;
|
|
2422
|
+
* top-level persisted dependencies confer no output permission. Missing inputs never
|
|
2423
|
+
* skip the hook. See ModelDocPermissionsDescriptor for the dependency contract.
|
|
2345
2424
|
*/
|
|
2346
|
-
docPermissions?:
|
|
2425
|
+
docPermissions?: ModelDocPermissionsDefinition<TModel> | ModelDocPermissionsAccessRecord<TModel>;
|
|
2347
2426
|
/**
|
|
2348
2427
|
* Allowlist of `docPermissions`-hook keys exposed in API responses.
|
|
2349
2428
|
* Enforcement always uses the full hook map; only serialization is reduced,
|
|
@@ -2417,8 +2496,8 @@ interface DataRouterOptions<TData = unknown> {
|
|
|
2417
2496
|
parentPath?: string;
|
|
2418
2497
|
queryRouteSegment?: string;
|
|
2419
2498
|
/**
|
|
2420
|
-
* Live
|
|
2421
|
-
* Only undefined
|
|
2499
|
+
* Live list/read entry guards: scalar or { default, basic, advanced, root } per operation.
|
|
2500
|
+
* Only undefined members inherit scalar/default then outer fallback; false denies with HTTP 401 while
|
|
2422
2501
|
* routes remain registered. Data never inherits model defaults. The broader
|
|
2423
2502
|
* legacy operation-rule object and scalar Validation shorthand remain accepted.
|
|
2424
2503
|
*/
|
|
@@ -2434,16 +2513,13 @@ interface DataRouterOptions<TData = unknown> {
|
|
|
2434
2513
|
requestSchemas?: DataRequestSchemas;
|
|
2435
2514
|
}
|
|
2436
2515
|
interface ExtendedModelRouterOptions<TModel = unknown, TVirtuals extends object = Record<never, never>> extends ModelRouterOptions<TModel, TVirtuals>, Omit<ExtendedDefaultModelRouterOptions<TModel>, 'permissionSchema'> {
|
|
2437
|
-
'
|
|
2438
|
-
'
|
|
2439
|
-
'
|
|
2440
|
-
'
|
|
2441
|
-
'
|
|
2442
|
-
'
|
|
2443
|
-
|
|
2444
|
-
'docPermissions.create'?: ModelDocPermissionsHook;
|
|
2445
|
-
'docPermissions.read'?: ModelDocPermissionsHook;
|
|
2446
|
-
'docPermissions.update'?: ModelDocPermissionsHook;
|
|
2516
|
+
'docPermissions.default'?: ModelDocPermissionsDefinition<TModel>;
|
|
2517
|
+
'docPermissions.list'?: ModelDocPermissionsDefinition<TModel>;
|
|
2518
|
+
'docPermissions.create'?: ModelDocPermissionsDefinition<TModel>;
|
|
2519
|
+
'docPermissions.read'?: ModelDocPermissionsDefinition<TModel>;
|
|
2520
|
+
'docPermissions.update'?: ModelDocPermissionsDefinition<TModel>;
|
|
2521
|
+
/** Replace a custom access's entire definition; get/dependsOn are reserved leaf members. */
|
|
2522
|
+
[key: `docPermissions.${string}`]: ModelDocPermissionsDefinition<TModel> | undefined;
|
|
2447
2523
|
'baseFilter.default'?: ModelBaseFilterHook;
|
|
2448
2524
|
'baseFilter.list'?: ModelBaseFilterHook;
|
|
2449
2525
|
'baseFilter.read'?: ModelBaseFilterHook;
|
|
@@ -2531,14 +2607,7 @@ interface ExtendedModelRouterOptions<TModel = unknown, TVirtuals extends object
|
|
|
2531
2607
|
sub?: unknown;
|
|
2532
2608
|
}>;
|
|
2533
2609
|
}
|
|
2534
|
-
interface ExtendedDataRouterOptions<TData = unknown> extends DataRouterOptions<TData
|
|
2535
|
-
'operationAccess.default'?: Validation;
|
|
2536
|
-
'operationAccess.list'?: Validation;
|
|
2537
|
-
'operationAccess.read'?: Validation;
|
|
2538
|
-
'operationAccess.basicList'?: Validation;
|
|
2539
|
-
'operationAccess.advancedList'?: Validation;
|
|
2540
|
-
'operationAccess.basicRead'?: Validation;
|
|
2541
|
-
'operationAccess.advancedRead'?: Validation;
|
|
2610
|
+
interface ExtendedDataRouterOptions<TData = unknown> extends DataRouterOptions<TData>, OperationAccessOptionPaths {
|
|
2542
2611
|
'requestSchemas.advancedList'?: RequestSchema;
|
|
2543
2612
|
'requestSchemas.advancedReadFilter'?: RequestSchema;
|
|
2544
2613
|
'requestSchemas.advancedRead'?: RequestSchema;
|
|
@@ -2567,6 +2636,8 @@ interface AuthorizationConfiguration {
|
|
|
2567
2636
|
readonly catalog: AuthorizationFieldCatalog;
|
|
2568
2637
|
readonly readAuthorizationMode?: AuthorizationMode;
|
|
2569
2638
|
readonly listAuthorizationMode?: AuthorizationMode;
|
|
2639
|
+
readonly createAuthorizationMode?: AuthorizationMode;
|
|
2640
|
+
readonly updateAuthorizationMode?: AuthorizationMode;
|
|
2570
2641
|
/** Opaque terminal private-input capture. Never related authority or public document metadata. */
|
|
2571
2642
|
readonly virtualPopulateSnapshot?: VirtualPopulateSnapshotToken;
|
|
2572
2643
|
/** Held runtime model defaults, distinct from this model's resolved flags. */
|
|
@@ -2576,7 +2647,7 @@ interface AuthorizationConfiguration {
|
|
|
2576
2647
|
/** Independent target-owned ordinary-populate operation admission. */
|
|
2577
2648
|
readonly requireOperationAccessForPopulateQueries?: boolean;
|
|
2578
2649
|
readonly documentPermissionField?: string;
|
|
2579
|
-
/** Captured permission schema, virtual
|
|
2650
|
+
/** Captured permission schema, virtual/document-permission definitions and metadata posture. */
|
|
2580
2651
|
readonly [key: string]: unknown;
|
|
2581
2652
|
}
|
|
2582
2653
|
/** Package-resolved requested descriptors, not a user-declared model registry. */
|
|
@@ -2637,8 +2708,8 @@ interface VirtualProjectionSnapshot {
|
|
|
2637
2708
|
catalog?: AuthorizationFieldCatalog;
|
|
2638
2709
|
permissionSchema?: Record<string, unknown> | null;
|
|
2639
2710
|
virtuals?: Record<string, unknown> | null;
|
|
2640
|
-
/**
|
|
2641
|
-
|
|
2711
|
+
/** Captured callable/descriptor/access record; only docPermissionsAccess contributes private inputs. */
|
|
2712
|
+
docPermissions?: unknown;
|
|
2642
2713
|
modelPermissionPrefix?: string;
|
|
2643
2714
|
requireExplicitSelect?: boolean;
|
|
2644
2715
|
documentPermissionField?: string;
|
|
@@ -3103,6 +3174,7 @@ interface NewOptions<TModel = unknown, TVirtuals extends object = Record<never,
|
|
|
3103
3174
|
/** @deprecated Compatibility no-op. Authorization, document grants, virtuals and decoration always run. */
|
|
3104
3175
|
skim?: boolean;
|
|
3105
3176
|
includePermissions?: boolean;
|
|
3177
|
+
/** Ignored unless the model opts into field maps with disableFieldPermissions: false. */
|
|
3106
3178
|
includeFieldPermissions?: boolean;
|
|
3107
3179
|
/** Trusted server-only output authority; no persistence or target dispatch is authorized. */
|
|
3108
3180
|
readonly authorization?: OutputAuthorization<TModel, TVirtuals>;
|
|
@@ -3212,7 +3284,7 @@ declare class Base<TModel = unknown, TVirtuals extends object = Record<never, ne
|
|
|
3212
3284
|
* Fresh output-only planner: selection stays independent of additive server authority.
|
|
3213
3285
|
* Returns persisted fetch inputs including private identity/dependencies, not an output
|
|
3214
3286
|
* allowlist. Document-dependent rules are deferred; no permission functions/getters run.
|
|
3215
|
-
*
|
|
3287
|
+
* Declare private hook inputs on docPermissions descriptors' dependsOn. Omitted/undefined
|
|
3216
3288
|
* options equal {} (request-mode output); positional skipChecks/subPaths are removed.
|
|
3217
3289
|
*/
|
|
3218
3290
|
genSelect(access: SelectAccess, targetFields?: Projection, options?: OutputPlanningOptions<TModel, TVirtuals>): Promise<string[]>;
|
|
@@ -3473,8 +3545,10 @@ declare class Core {
|
|
|
3473
3545
|
setPermissions(): Promise<void>;
|
|
3474
3546
|
canActivate(routeGuard: Validation): Promise<boolean>;
|
|
3475
3547
|
isAllowed(modelName: string, access: RouteGuardAccess | string): Promise<boolean>;
|
|
3476
|
-
/** Authorize
|
|
3477
|
-
isAllowedRoute(modelName: string, baseAccess: RouteGuardAccess | string,
|
|
3548
|
+
/** Authorize entry using explicit server-owned basic/advanced/root metadata. */
|
|
3549
|
+
isAllowedRoute(modelName: string, baseAccess: RouteGuardAccess | string, context: OperationAccessContext): Promise<boolean>;
|
|
3550
|
+
/** Fresh live reads; omitted context is a base check, never an ambient entry context. */
|
|
3551
|
+
private resolveOperationAccess;
|
|
3478
3552
|
/** Acquire a model service for trusted server calls; authorization belongs to each call's options, never defaults. */
|
|
3479
3553
|
getService<TModel = unknown, TVirtuals extends object = Record<never, never>>(modelName: string): Service<TModel, TVirtuals>;
|
|
3480
3554
|
getPublicService<TModel = unknown, TVirtuals extends object = Record<never, never>>(modelName: string): PublicService<TModel, TVirtuals>;
|
|
@@ -3634,6 +3708,7 @@ interface RootModelNewQueryEntry extends RootQueryEntryBase<'model', 'new'> {
|
|
|
3634
3708
|
/** @deprecated Compatibility no-op. Authorization, document grants, virtuals and decoration always run. */
|
|
3635
3709
|
skim?: boolean;
|
|
3636
3710
|
includePermissions?: boolean;
|
|
3711
|
+
/** Ignored unless the model opts into field maps with disableFieldPermissions: false. */
|
|
3637
3712
|
includeFieldPermissions?: boolean;
|
|
3638
3713
|
};
|
|
3639
3714
|
}
|
|
@@ -3906,4 +3981,4 @@ declare function fromIoTs<TValue = unknown>(decoder: IoTsDecoderLike<TValue>): R
|
|
|
3906
3981
|
declare function fromSuperstruct<TStruct, TOutput = unknown>(struct: TStruct, validate: SuperstructValidateLike): RequestSchemaValidator<TOutput>;
|
|
3907
3982
|
declare function fromVine<TValue = unknown>(validator: VineValidatorLike<TValue>): RequestSchemaValidator<TValue>;
|
|
3908
3983
|
|
|
3909
|
-
export { type DataRouterOptions as $, type AccessRouterBaseRequest as A, type BaseFilterAccess as B, type Change as C, type CorrelatedListInclude as D, type CorrelatedReadByFilterInclude as E, type CorrelatedReadByIdInclude as F, type CountBody as G, type CreateArgs as H, type CreateAuthorization as I, type CreateOptions as J, type CreateQueryInput as K, CustomHeaders as L, DATA_MIDDLEWARE as M, type DataBaseFilterHook as N, type DataFieldOptions as O, type DataFilter as P, type DataFindArgs as Q, type DataFindOneArgs as R, type DataFindOneOptions as S, type DataFindOptions as T, type DataHook as U, type DataHookContext as V, type DataIdentifierHook as W, type DataListHook as X, type DataOverrideFilterHook as Y, type DataRequest as Z, type DataRequestSchemas as _, type AccessRouterFieldKey as a, type
|
|
3984
|
+
export { type DataRouterOptions as $, type AccessRouterBaseRequest as A, type BaseFilterAccess as B, type Change as C, type CorrelatedListInclude as D, type CorrelatedReadByFilterInclude as E, type CorrelatedReadByIdInclude as F, type CountBody as G, type CreateArgs as H, type CreateAuthorization as I, type CreateOptions as J, type CreateQueryInput as K, CustomHeaders as L, DATA_MIDDLEWARE as M, type DataBaseFilterHook as N, type DataFieldOptions as O, type DataFilter as P, type DataFindArgs as Q, type DataFindOneArgs as R, type DataFindOneOptions as S, type DataFindOptions as T, type DataHook as U, type DataHookContext as V, type DataIdentifierHook as W, type DataListHook as X, type DataOverrideFilterHook as Y, type DataRequest as Z, type DataRequestSchemas as _, type AccessRouterFieldKey as a, type ModelOutputListHook as a$, type DecorateAccess as a0, type DecorateAllAccess as a1, type DeepFieldPath as a2, type DefaultModelRouterOptions as a3, type Defaults as a4, type DistinctArgs as a5, type DistinctBody as a6, type DocPermissionsAccess as a7, type DocumentGrants as a8, type ErrorResult as a9, type IoTsContextEntryLike as aA, type IoTsDecodeErrorLike as aB, type IoTsDecoderLike as aC, type JoiSchemaLike as aD, type JoiValidationErrorDetailLike as aE, type KeyValueProjection as aF, type LegacyInclude as aG, type ListQueryInput as aH, type ListResult as aI, MIDDLEWARE as aJ, type MaybePromise as aK, type ModelBaseFilterHook as aL, type ModelChangeHook as aM, type ModelDeleteHook as aN, type ModelDocPermissionsAccessRecord as aO, type ModelDocPermissionsDefinition as aP, type ModelDocPermissionsDescriptor as aQ, type ModelDocPermissionsHook as aR, type ModelDocument as aS, type ModelDocumentHook as aT, type ModelHook as aU, type ModelHookContext as aV, type ModelHydrationOptions as aW, type ModelIdentifierHook as aX, type ModelListHook as aY, type ModelOutputContext as aZ, type ModelOutputHook as a_, type ExistsOptions as aa, type ExtendedDataRouterOptions as ab, type ExtendedDefaultModelRouterOptions as ac, type ExtendedModelRouterOptions as ad, type FieldAuthorization as ae, type FieldOperationAccess as af, type FieldPermissionHook as ag, type FieldValidation as ah, type Filter as ai, FilterOperator as aj, type FilteredOutput as ak, type FindAccess as al, type FindArgs as am, type FindByIdArgs as an, type FindByIdOptions as ao, type FindOneArgs as ap, type FindOneOptions as aq, type FindOptions as ar, type GlobalOptions as as, type GlobalPermissionValue as at, type GuardHook as au, type HydrationMode as av, type IdentifierHook as aw, type Include as ax, type InputFieldAuthorization as ay, type InputFieldPath as az, type AccessRouterLogger as b, type RequestSchemaFailure as b$, type ModelOverrideFilterHook as b0, type ModelRequest as b1, type ModelRouterOptions as b2, type ModelValidateHook as b3, type ModelVirtualAccess as b4, type ModelVirtualAccessRecord as b5, type ModelVirtualContext as b6, type ModelVirtualDescriptor as b7, type ModelVirtualDoc as b8, type ModelVirtualGetter as b9, type PopulateAccess as bA, type PopulatePlanningOptions as bB, type PrepareAccess as bC, type Projection as bD, type PublicCreateArgs as bE, type PublicCreateOptions as bF, type PublicErrorResult as bG, type PublicListArgs as bH, type PublicListOptions as bI, type PublicListResult as bJ, type PublicOutput as bK, type PublicReadArgs as bL, type PublicReadOptions as bM, type PublicServiceResult as bN, type PublicSingleResult as bO, type PublicSubdocumentCreateOptions as bP, type PublicSubdocumentListOptions as bQ, type PublicSubdocumentMutationOptions as bR, type PublicSubdocumentReadOptions as bS, type PublicUpdateArgs as bT, type PublicUpdateOptions as bU, type PublicUpsertArgs as bV, type PublicUpsertOptions as bW, type ReadQueryInput as bX, type RelatedAuthorization as bY, type Request as bZ, type RequestSchemaAdapter as b_, type ModelVirtualLeaf as ba, type ModelVirtualPopulateDependency as bb, type ModelVirtualPopulateInputs as bc, type ModelVirtualRecordAccess as bd, type ModelVirtuals as be, type MutationAuthorization as bf, type NewArgs as bg, type NewOptions as bh, type OperationAccess as bi, type OperationAccessContext as bj, type OperationAccessPaths as bk, type OperationAccessRule as bl, type OperationAccessSetter as bm, type OperationAccessVariants as bn, type OperationAuthorization as bo, type OutputAuthorization as bp, type OutputFieldOptions as bq, type OutputFieldPath as br, type OutputPlanningOptions as bs, PERMISSIONS as bt, PERMISSION_KEYS as bu, type PairedRouteAccess as bv, type ParentRef as bw, type PathValue as bx, type PermissionSchema as by, type Populate as bz, type AccessRouterRequest as c, type SubdocumentCreateAuthorization as c$, type RequestSchemaIssue as c0, type RequestSchemaLike as c1, type RequestSchemaOptions as c2, type RequestSchemaResult as c3, type RequestSchemaSuccess as c4, type RequestSchemaValidator as c5, type RequestSchemas as c6, type RootDataListQueryEntry as c7, type RootDataOperation as c8, type RootDataReadByFilterQueryEntry as c9, type RowAuthorization as cA, type SelectAccess as cB, type SelectedPopulatedPublicOutput as cC, type SelectedPublicOutput as cD, type ServiceAuthorization as cE, type ServiceOutputContext as cF, type ServiceOutputDecorator as cG, type ServiceResult as cH, type SingleResult as cI, type Sort as cJ, type SortOrder as cK, type StandardSchemaFailure as cL, type StandardSchemaInferOutput as cM, type StandardSchemaIssue as cN, type StandardSchemaPathSegment as cO, type StandardSchemaResult as cP, type StandardSchemaSuccess as cQ, type StandardSchemaV1 as cR, StatusCodes as cS, type SubListBody as cT, type SubOperationAccess as cU, type SubPopulate as cV, type SubQueryEntry as cW, type SubReadBody as cX, type SubRouteGuardOptions as cY, type SubdocumentBulkRecord as cZ, type SubdocumentBulkUpdateInput as c_, type RootDataReadByIdQueryEntry as ca, type RootModelCountQueryEntry as cb, type RootModelCreateQueryEntry as cc, type RootModelDeleteQueryEntry as cd, type RootModelDistinctQueryEntry as ce, type RootModelListQueryEntry as cf, type RootModelNewQueryEntry as cg, type RootModelOperation as ch, type RootModelReadByFilterQueryEntry as ci, type RootModelReadByIdQueryEntry as cj, type RootModelSubBulkUpdateQueryEntry as ck, type RootModelSubCreateQueryEntry as cl, type RootModelSubDeleteQueryEntry as cm, type RootModelSubListQueryEntry as cn, type RootModelSubReadQueryEntry as co, type RootModelSubUpdateQueryEntry as cp, type RootModelUpdateQueryEntry as cq, type RootModelUpsertQueryEntry as cr, type RootOperationResult as cs, type RootQueryEntry as ct, type RootRouterOptions as cu, type RootSubOperation as cv, type RootTarget as cw, type RouteBaseAccess as cx, type RouteGuardAccess as cy, type RouteVariant as cz, type AccessRouterRequestExtensions as d, parseBodyWithSchema as d$, type SubdocumentCreateInput as d0, type SubdocumentCreateOptions as d1, type SubdocumentCreateVisibilityAuthorization as d2, type SubdocumentDeleteAuthorization as d3, type SubdocumentDeleteOptions as d4, type SubdocumentGateAuthorization as d5, type SubdocumentId as d6, type SubdocumentInputAuthorization as d7, type SubdocumentListOptions as d8, type SubdocumentModel as d9, type ValibotIssueLike as dA, type ValibotPathItemLike as dB, type ValibotSafeParseLike as dC, type ValibotSafeParseResult as dD, type ValidateAccess as dE, type ValidateRule as dF, type Validation as dG, type ValidationError as dH, type VineValidationErrorLike as dI, type VineValidationMessageLike as dJ, type VineValidatorLike as dK, type VirtualSubModel as dL, type WithVirtuals as dM, type YupSchemaLike as dN, type YupValidationErrorLike as dO, defineRequestSchema as dP, fromAjv as dQ, fromArkType as dR, fromIoTs as dS, fromJoi as dT, fromStandardSchema as dU, fromSuperstruct as dV, fromValibot as dW, fromVine as dX, fromYup as dY, fromZod as dZ, parseBody as d_, type SubdocumentMutationAuthorization as da, type SubdocumentName as db, type SubdocumentOutputAuthorization as dc, type SubdocumentParentArgs as dd, type SubdocumentParentOptions as de, type SubdocumentReadAuthorization as df, type SubdocumentReadOptions as dg, type SubdocumentRecord as dh, type SubdocumentUpdateOptions as di, type SubdocumentVirtuals as dj, type SubdocumentVisibilityAuthorization as dk, type SuperstructFailureLike as dl, type SuperstructValidateLike as dm, type Task as dn, type TaskType as dp, type TransformAccess as dq, type TypedFilter as dr, type UpdateByIdArgs as ds, type UpdateByIdOptions as dt, type UpdateOneArgs as du, type UpdateOneOptions as dv, type UpdateQueryInput as dw, type UpsertArgs as dx, type UpsertOptions as dy, type UpsertQueryInput as dz, type AdvancedCreateBody as e, parseNestedBodyWithSchema as e0, parsePathParam as e1, parseQuery as e2, AccessRuntime as e3, DataService as e4, Service as e5, PublicService as e6, type OpenApiRouterOptions as e7, type OpenApiRegistryOptions as e8, type OpenApiRouteDescriptor as e9, type OpenApiDocumentOptions as ea, type OpenApiParameter as eb, type OpenApiSchema as ec, type OpenApiResponses as ed, type AccessRouterPermissionMap as ee, type AccessRouterPermissions as ef, type OpenApiMethod as eg, type Permissions as eh, defaultRuntime as ei, type AdvancedListBody as f, type AdvancedReadBody as g, type AdvancedReadFilterBody as h, type AdvancedUpdateBody as i, type AdvancedUpsertBody as j, type AfterPersistAccess as k, type AjvErrorObjectLike as l, type AjvValidationErrorLike as m, type AjvValidatorLike as n, type AllowedOutputFieldOptions as o, type ArkTypeErrorsLike as p, type ArkTypeLike as q, type ArkTypeProblemLike as r, type AuthorizationMode as s, type AuthorizedListResult as t, type AuthorizedSingleResult as u, Codes as v, type CorrelatedCountInclude as w, type CorrelatedFilter as x, type CorrelatedInclude as y, type CorrelatedIncludeArgs as z };
|