@web-ts-toolkit/access-router 0.65.1 → 0.67.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 +1089 -0
- package/README.md +480 -665
- package/advanced.d.mts +2 -1
- package/advanced.d.ts +2 -1
- package/advanced.js +1873 -816
- package/advanced.mjs +1618 -561
- package/index.d.mts +38 -26
- package/index.d.ts +38 -26
- package/index.js +11981 -11341
- package/index.mjs +11853 -11218
- package/llms.txt +8 -3
- package/package.json +4 -4
- package/{parsers-h_oU4bB0.d.mts → parsers-fSBARZSn.d.mts} +2700 -2946
- package/{parsers-h_oU4bB0.d.ts → parsers-fSBARZSn.d.ts} +2700 -2946
- package/processors.js +13 -1
- package/processors.mjs +13 -1
package/index.d.mts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import mongoose__default, { Schema } from 'mongoose';
|
|
2
2
|
import { Response, NextFunction, RequestHandler, Router } from 'express';
|
|
3
|
-
import { A as AccessRouterBaseRequest,
|
|
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
|
+
import 'node:buffer';
|
|
7
8
|
|
|
8
9
|
declare function macl(): (req: AccessRouterBaseRequest, res: Response, next: NextFunction) => Promise<void>;
|
|
9
10
|
interface GuardModelConditionID {
|
|
@@ -15,6 +16,14 @@ interface GuardModelCondition {
|
|
|
15
16
|
id: string | GuardModelConditionID;
|
|
16
17
|
condition: string | string[];
|
|
17
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Request permission middleware. Model conditions require a visible row and fresh
|
|
21
|
+
* document facts, but publish no DTO: field/virtual/include output, decorate/tasks
|
|
22
|
+
* and `_read` overrides do not run or veto the condition. Source/fact errors remain
|
|
23
|
+
* BadRequest. This request-only read does not imply the generated HTTP READ gate;
|
|
24
|
+
* an admitted miss may retry once under captured LIST admission and READ mode.
|
|
25
|
+
* Put security in operation/row/fact hooks; use a separate normal read for a DTO.
|
|
26
|
+
*/
|
|
18
27
|
declare function guard(condition: string): RequestHandler;
|
|
19
28
|
declare function guard(conditions: string[]): RequestHandler;
|
|
20
29
|
declare function guard(conditionFunc: GuardHook<ModelRequest>): RequestHandler;
|
|
@@ -40,12 +49,12 @@ declare class DataRouter<TData = unknown> {
|
|
|
40
49
|
private setDocumentRoutes;
|
|
41
50
|
/**
|
|
42
51
|
* Update live behavior with a typed key/path or an options object. Dotted paths
|
|
43
|
-
* such as `operationAccess.
|
|
52
|
+
* such as `operationAccess.read.basic` update one key; object assignment replaces
|
|
44
53
|
* supplied top-level values shallowly. The construction-time options snapshot stays fixed.
|
|
45
54
|
*/
|
|
46
55
|
set<K extends keyof ExtendedDataRouterOptions<TData>>(key: K, value: ExtendedDataRouterOptions<TData>[K]): this;
|
|
47
56
|
set(options: DataRouterOptions<TData>): this;
|
|
48
|
-
/** Set one live option/path; `setOption('operationAccess.
|
|
57
|
+
/** Set one live option/path; `setOption('operationAccess.read.basic', undefined)` restores fallback. */
|
|
49
58
|
setOption<K extends keyof ExtendedDataRouterOptions<TData>>(key: K, option: ExtendedDataRouterOptions<TData>[K]): this;
|
|
50
59
|
/** Shallowly replace supplied top-level options; an operationAccess object replaces that entire rule object. */
|
|
51
60
|
setOptions(options: DataRouterOptions<TData>): this;
|
|
@@ -54,13 +63,14 @@ declare class DataRouter<TData = unknown> {
|
|
|
54
63
|
/** Base-operation field grants; basic/advanced route guards belong to operationAccess. */
|
|
55
64
|
permissionSchema: SetTargetOption$1<DataRouter<TData>, DataRouterOptions<TData>['permissionSchema']>;
|
|
56
65
|
/**
|
|
57
|
-
* Live
|
|
58
|
-
* `operationAccess('
|
|
59
|
-
* (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.
|
|
60
69
|
* `operationAccess({ list: true, read: true })` replaces the whole rule object,
|
|
61
|
-
* 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.
|
|
62
72
|
*/
|
|
63
|
-
operationAccess:
|
|
73
|
+
operationAccess: OperationAccessSetter<DataRouter<TData>>;
|
|
64
74
|
baseFilter: SetTargetOption$1<DataRouter<TData>, DataRouterOptions<TData>['baseFilter']>;
|
|
65
75
|
/**
|
|
66
76
|
* Trusted filter replacements applied before base-filter composition.
|
|
@@ -128,8 +138,8 @@ declare class ModelRouter<TModel = unknown, TVirtuals extends object = Record<ne
|
|
|
128
138
|
/**
|
|
129
139
|
* Acquire the model-generic internal service after this runtime's middleware
|
|
130
140
|
* initializes req.macl. Supply trusted per-call authorization in service options;
|
|
131
|
-
* selection/query args stay separate. Successful results carry
|
|
132
|
-
*
|
|
141
|
+
* selection/query args stay separate. Successful results carry immutable diagnostic
|
|
142
|
+
* context(s), never reusable authority on data. Use getPublicService for request-only wrappers.
|
|
133
143
|
*/
|
|
134
144
|
getService(req: ModelRequest): Service<TModel, TVirtuals>;
|
|
135
145
|
getPublicService(req: ModelRequest): PublicService<TModel, TVirtuals>;
|
|
@@ -141,14 +151,14 @@ declare class ModelRouter<TModel = unknown, TVirtuals extends object = Record<ne
|
|
|
141
151
|
private logEndpoints;
|
|
142
152
|
/**
|
|
143
153
|
* Update live behavior with a typed key/path or an options object. Dotted paths
|
|
144
|
-
* such as `operationAccess.
|
|
154
|
+
* such as `operationAccess.read.basic` update one key; object assignment replaces
|
|
145
155
|
* supplied top-level values shallowly. The construction-time options snapshot stays fixed.
|
|
146
156
|
*/
|
|
147
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;
|
|
148
158
|
set<K extends Extract<keyof TVirtuals, string> & string>(key: `virtuals.${K}`, value: ModelVirtualLeaf<TModel, K extends keyof TVirtuals ? TVirtuals[K] : unknown>): this;
|
|
149
159
|
set<K extends keyof ExtendedModelRouterOptions<TModel, TVirtuals>>(key: K, value: ExtendedModelRouterOptions<TModel, TVirtuals>[K]): this;
|
|
150
160
|
set(options: ModelRouterOptions<TModel, TVirtuals>): this;
|
|
151
|
-
/** Set one live option/path; `setOption('operationAccess.
|
|
161
|
+
/** Set one live option/path; `setOption('operationAccess.read.basic', undefined)` restores fallback. */
|
|
152
162
|
setOption<K extends keyof ExtendedModelRouterOptions<TModel, TVirtuals>>(key: K, option: ExtendedModelRouterOptions<TModel, TVirtuals>[K]): this;
|
|
153
163
|
/** Shallowly replace supplied top-level options; an operationAccess object replaces that entire rule object. */
|
|
154
164
|
setOptions(options: ModelRouterOptions<TModel, TVirtuals>): this;
|
|
@@ -227,22 +237,24 @@ declare class ModelRouter<TModel = unknown, TVirtuals extends object = Record<ne
|
|
|
227
237
|
*/
|
|
228
238
|
documentPermissionField: SetTargetOption<ModelRouter<TModel, TVirtuals>, ModelRouterOptions<TModel, TVirtuals>['documentPermissionField']>;
|
|
229
239
|
/**
|
|
230
|
-
*
|
|
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.
|
|
231
243
|
*/
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
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
|
+
};
|
|
237
248
|
/**
|
|
238
|
-
* Configure live
|
|
249
|
+
* Configure live scalar/default and independent basic/advanced/root entry guards. Only undefined inherits;
|
|
239
250
|
* selected false denies with HTTP 401 without removing routes or OpenAPI entries.
|
|
240
|
-
* `operationAccess('
|
|
241
|
-
* `operationAccess('subs.comments.
|
|
251
|
+
* `operationAccess('read.basic', false)` updates one member, and
|
|
252
|
+
* `operationAccess('subs.comments.read.basic', false)` updates a field-specific member.
|
|
242
253
|
* `operationAccess({ list: true, read: true })` replaces the whole rule object,
|
|
243
|
-
* 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.
|
|
244
256
|
*/
|
|
245
|
-
operationAccess:
|
|
257
|
+
operationAccess: OperationAccessSetter<ModelRouter<TModel, TVirtuals>>;
|
|
246
258
|
/**
|
|
247
259
|
* The base filter definitions applied in every query transaction.
|
|
248
260
|
* @operation `list`, `read`, `update`, `delete`
|
|
@@ -450,7 +462,7 @@ declare const getModelInstance: <TModel = unknown>(modelName: string) => mongoos
|
|
|
450
462
|
* Update inherited model defaults shallowly. Unspecified model options follow these
|
|
451
463
|
* updates for new calls, including existing models; explicit model values (even false
|
|
452
464
|
* or empty objects/arrays) win. Model undefined restores inheritance. Existing calls,
|
|
453
|
-
*
|
|
465
|
+
* router.options snapshots and mounted route paths are not rewritten.
|
|
454
466
|
* Explicitly cleared operationAccess keeps its existing exact-key-only default fallback.
|
|
455
467
|
*/
|
|
456
468
|
declare const setDefaultModelOptions: (options: DefaultModelRouterOptions) => void;
|
|
@@ -614,4 +626,4 @@ declare function createAccessRuntime(): AccessRuntimeApi;
|
|
|
614
626
|
*/
|
|
615
627
|
declare const acl: AccessRuntimeApi;
|
|
616
628
|
|
|
617
|
-
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 };
|
package/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import mongoose__default, { Schema } from 'mongoose';
|
|
2
2
|
import { Response, NextFunction, RequestHandler, Router } from 'express';
|
|
3
|
-
import { A as AccessRouterBaseRequest,
|
|
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.js';
|
|
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.js';
|
|
5
5
|
import JsonRouter from '@web-ts-toolkit/express-json-router';
|
|
6
6
|
import 'zod';
|
|
7
|
+
import 'node:buffer';
|
|
7
8
|
|
|
8
9
|
declare function macl(): (req: AccessRouterBaseRequest, res: Response, next: NextFunction) => Promise<void>;
|
|
9
10
|
interface GuardModelConditionID {
|
|
@@ -15,6 +16,14 @@ interface GuardModelCondition {
|
|
|
15
16
|
id: string | GuardModelConditionID;
|
|
16
17
|
condition: string | string[];
|
|
17
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Request permission middleware. Model conditions require a visible row and fresh
|
|
21
|
+
* document facts, but publish no DTO: field/virtual/include output, decorate/tasks
|
|
22
|
+
* and `_read` overrides do not run or veto the condition. Source/fact errors remain
|
|
23
|
+
* BadRequest. This request-only read does not imply the generated HTTP READ gate;
|
|
24
|
+
* an admitted miss may retry once under captured LIST admission and READ mode.
|
|
25
|
+
* Put security in operation/row/fact hooks; use a separate normal read for a DTO.
|
|
26
|
+
*/
|
|
18
27
|
declare function guard(condition: string): RequestHandler;
|
|
19
28
|
declare function guard(conditions: string[]): RequestHandler;
|
|
20
29
|
declare function guard(conditionFunc: GuardHook<ModelRequest>): RequestHandler;
|
|
@@ -40,12 +49,12 @@ declare class DataRouter<TData = unknown> {
|
|
|
40
49
|
private setDocumentRoutes;
|
|
41
50
|
/**
|
|
42
51
|
* Update live behavior with a typed key/path or an options object. Dotted paths
|
|
43
|
-
* such as `operationAccess.
|
|
52
|
+
* such as `operationAccess.read.basic` update one key; object assignment replaces
|
|
44
53
|
* supplied top-level values shallowly. The construction-time options snapshot stays fixed.
|
|
45
54
|
*/
|
|
46
55
|
set<K extends keyof ExtendedDataRouterOptions<TData>>(key: K, value: ExtendedDataRouterOptions<TData>[K]): this;
|
|
47
56
|
set(options: DataRouterOptions<TData>): this;
|
|
48
|
-
/** Set one live option/path; `setOption('operationAccess.
|
|
57
|
+
/** Set one live option/path; `setOption('operationAccess.read.basic', undefined)` restores fallback. */
|
|
49
58
|
setOption<K extends keyof ExtendedDataRouterOptions<TData>>(key: K, option: ExtendedDataRouterOptions<TData>[K]): this;
|
|
50
59
|
/** Shallowly replace supplied top-level options; an operationAccess object replaces that entire rule object. */
|
|
51
60
|
setOptions(options: DataRouterOptions<TData>): this;
|
|
@@ -54,13 +63,14 @@ declare class DataRouter<TData = unknown> {
|
|
|
54
63
|
/** Base-operation field grants; basic/advanced route guards belong to operationAccess. */
|
|
55
64
|
permissionSchema: SetTargetOption$1<DataRouter<TData>, DataRouterOptions<TData>['permissionSchema']>;
|
|
56
65
|
/**
|
|
57
|
-
* Live
|
|
58
|
-
* `operationAccess('
|
|
59
|
-
* (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.
|
|
60
69
|
* `operationAccess({ list: true, read: true })` replaces the whole rule object,
|
|
61
|
-
* 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.
|
|
62
72
|
*/
|
|
63
|
-
operationAccess:
|
|
73
|
+
operationAccess: OperationAccessSetter<DataRouter<TData>>;
|
|
64
74
|
baseFilter: SetTargetOption$1<DataRouter<TData>, DataRouterOptions<TData>['baseFilter']>;
|
|
65
75
|
/**
|
|
66
76
|
* Trusted filter replacements applied before base-filter composition.
|
|
@@ -128,8 +138,8 @@ declare class ModelRouter<TModel = unknown, TVirtuals extends object = Record<ne
|
|
|
128
138
|
/**
|
|
129
139
|
* Acquire the model-generic internal service after this runtime's middleware
|
|
130
140
|
* initializes req.macl. Supply trusted per-call authorization in service options;
|
|
131
|
-
* selection/query args stay separate. Successful results carry
|
|
132
|
-
*
|
|
141
|
+
* selection/query args stay separate. Successful results carry immutable diagnostic
|
|
142
|
+
* context(s), never reusable authority on data. Use getPublicService for request-only wrappers.
|
|
133
143
|
*/
|
|
134
144
|
getService(req: ModelRequest): Service<TModel, TVirtuals>;
|
|
135
145
|
getPublicService(req: ModelRequest): PublicService<TModel, TVirtuals>;
|
|
@@ -141,14 +151,14 @@ declare class ModelRouter<TModel = unknown, TVirtuals extends object = Record<ne
|
|
|
141
151
|
private logEndpoints;
|
|
142
152
|
/**
|
|
143
153
|
* Update live behavior with a typed key/path or an options object. Dotted paths
|
|
144
|
-
* such as `operationAccess.
|
|
154
|
+
* such as `operationAccess.read.basic` update one key; object assignment replaces
|
|
145
155
|
* supplied top-level values shallowly. The construction-time options snapshot stays fixed.
|
|
146
156
|
*/
|
|
147
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;
|
|
148
158
|
set<K extends Extract<keyof TVirtuals, string> & string>(key: `virtuals.${K}`, value: ModelVirtualLeaf<TModel, K extends keyof TVirtuals ? TVirtuals[K] : unknown>): this;
|
|
149
159
|
set<K extends keyof ExtendedModelRouterOptions<TModel, TVirtuals>>(key: K, value: ExtendedModelRouterOptions<TModel, TVirtuals>[K]): this;
|
|
150
160
|
set(options: ModelRouterOptions<TModel, TVirtuals>): this;
|
|
151
|
-
/** Set one live option/path; `setOption('operationAccess.
|
|
161
|
+
/** Set one live option/path; `setOption('operationAccess.read.basic', undefined)` restores fallback. */
|
|
152
162
|
setOption<K extends keyof ExtendedModelRouterOptions<TModel, TVirtuals>>(key: K, option: ExtendedModelRouterOptions<TModel, TVirtuals>[K]): this;
|
|
153
163
|
/** Shallowly replace supplied top-level options; an operationAccess object replaces that entire rule object. */
|
|
154
164
|
setOptions(options: ModelRouterOptions<TModel, TVirtuals>): this;
|
|
@@ -227,22 +237,24 @@ declare class ModelRouter<TModel = unknown, TVirtuals extends object = Record<ne
|
|
|
227
237
|
*/
|
|
228
238
|
documentPermissionField: SetTargetOption<ModelRouter<TModel, TVirtuals>, ModelRouterOptions<TModel, TVirtuals>['documentPermissionField']>;
|
|
229
239
|
/**
|
|
230
|
-
*
|
|
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.
|
|
231
243
|
*/
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
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
|
+
};
|
|
237
248
|
/**
|
|
238
|
-
* Configure live
|
|
249
|
+
* Configure live scalar/default and independent basic/advanced/root entry guards. Only undefined inherits;
|
|
239
250
|
* selected false denies with HTTP 401 without removing routes or OpenAPI entries.
|
|
240
|
-
* `operationAccess('
|
|
241
|
-
* `operationAccess('subs.comments.
|
|
251
|
+
* `operationAccess('read.basic', false)` updates one member, and
|
|
252
|
+
* `operationAccess('subs.comments.read.basic', false)` updates a field-specific member.
|
|
242
253
|
* `operationAccess({ list: true, read: true })` replaces the whole rule object,
|
|
243
|
-
* 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.
|
|
244
256
|
*/
|
|
245
|
-
operationAccess:
|
|
257
|
+
operationAccess: OperationAccessSetter<ModelRouter<TModel, TVirtuals>>;
|
|
246
258
|
/**
|
|
247
259
|
* The base filter definitions applied in every query transaction.
|
|
248
260
|
* @operation `list`, `read`, `update`, `delete`
|
|
@@ -450,7 +462,7 @@ declare const getModelInstance: <TModel = unknown>(modelName: string) => mongoos
|
|
|
450
462
|
* Update inherited model defaults shallowly. Unspecified model options follow these
|
|
451
463
|
* updates for new calls, including existing models; explicit model values (even false
|
|
452
464
|
* or empty objects/arrays) win. Model undefined restores inheritance. Existing calls,
|
|
453
|
-
*
|
|
465
|
+
* router.options snapshots and mounted route paths are not rewritten.
|
|
454
466
|
* Explicitly cleared operationAccess keeps its existing exact-key-only default fallback.
|
|
455
467
|
*/
|
|
456
468
|
declare const setDefaultModelOptions: (options: DefaultModelRouterOptions) => void;
|
|
@@ -614,4 +626,4 @@ declare function createAccessRuntime(): AccessRuntimeApi;
|
|
|
614
626
|
*/
|
|
615
627
|
declare const acl: AccessRuntimeApi;
|
|
616
628
|
|
|
617
|
-
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 };
|