@web-ts-toolkit/access-router 0.66.0 → 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 +342 -30
- package/README.md +273 -137
- package/advanced.d.mts +1 -1
- package/advanced.d.ts +1 -1
- package/advanced.js +291 -59
- package/advanced.mjs +291 -59
- package/index.d.mts +26 -23
- package/index.d.ts +26 -23
- package/index.js +755 -409
- package/index.mjs +784 -441
- package/llms.txt +3 -1
- package/package.json +4 -4
- package/{parsers-BiFHfrNd.d.mts → parsers-fSBARZSn.d.mts} +245 -170
- package/{parsers-BiFHfrNd.d.ts → parsers-fSBARZSn.d.ts} +245 -170
package/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import mongoose__default, { Schema } from 'mongoose';
|
|
2
2
|
import { Response, NextFunction, RequestHandler, Router } from 'express';
|
|
3
|
-
import { A as AccessRouterBaseRequest, au as GuardHook,
|
|
4
|
-
export {
|
|
3
|
+
import { A as AccessRouterBaseRequest, au as GuardHook, b1 as ModelRequest, e3 as AccessRuntime, $ as DataRouterOptions, Z as DataRequest, e4 as DataService, ab as ExtendedDataRouterOptions, bm as OperationAccessSetter, ai as Filter, bD as Projection, cJ as Sort, bz as Populate, b2 as ModelRouterOptions, e5 as Service, e6 as PublicService, bd as ModelVirtualRecordAccess, b7 as ModelVirtualDescriptor, b9 as ModelVirtualGetter, ba as ModelVirtualLeaf, ad as ExtendedModelRouterOptions, aP as ModelDocPermissionsDefinition, dG as Validation, cu as RootRouterOptions, e7 as OpenApiRouterOptions, e8 as OpenApiRegistryOptions, e9 as OpenApiRouteDescriptor, ea as OpenApiDocumentOptions, eb as OpenApiParameter, ec as OpenApiSchema, ed as OpenApiResponses, as as GlobalOptions, a3 as DefaultModelRouterOptions, ac as ExtendedDefaultModelRouterOptions } from './parsers-fSBARZSn.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
7
|
import 'node:buffer';
|
|
@@ -49,12 +49,12 @@ declare class DataRouter<TData = unknown> {
|
|
|
49
49
|
private setDocumentRoutes;
|
|
50
50
|
/**
|
|
51
51
|
* Update live behavior with a typed key/path or an options object. Dotted paths
|
|
52
|
-
* such as `operationAccess.
|
|
52
|
+
* such as `operationAccess.read.basic` update one key; object assignment replaces
|
|
53
53
|
* supplied top-level values shallowly. The construction-time options snapshot stays fixed.
|
|
54
54
|
*/
|
|
55
55
|
set<K extends keyof ExtendedDataRouterOptions<TData>>(key: K, value: ExtendedDataRouterOptions<TData>[K]): this;
|
|
56
56
|
set(options: DataRouterOptions<TData>): this;
|
|
57
|
-
/** Set one live option/path; `setOption('operationAccess.
|
|
57
|
+
/** Set one live option/path; `setOption('operationAccess.read.basic', undefined)` restores fallback. */
|
|
58
58
|
setOption<K extends keyof ExtendedDataRouterOptions<TData>>(key: K, option: ExtendedDataRouterOptions<TData>[K]): this;
|
|
59
59
|
/** Shallowly replace supplied top-level options; an operationAccess object replaces that entire rule object. */
|
|
60
60
|
setOptions(options: DataRouterOptions<TData>): this;
|
|
@@ -63,13 +63,14 @@ declare class DataRouter<TData = unknown> {
|
|
|
63
63
|
/** Base-operation field grants; basic/advanced route guards belong to operationAccess. */
|
|
64
64
|
permissionSchema: SetTargetOption$1<DataRouter<TData>, DataRouterOptions<TData>['permissionSchema']>;
|
|
65
65
|
/**
|
|
66
|
-
* Live
|
|
67
|
-
* `operationAccess('
|
|
68
|
-
* (and HEAD) with HTTP 401; registered POST reads
|
|
66
|
+
* Live scalar/default and independent basic/advanced/root list/read entry guards.
|
|
67
|
+
* `operationAccess('read.basic', false)` updates one member and denies GET /:id
|
|
68
|
+
* (and HEAD) with HTTP 401; registered POST reads use read.advanced then read.default.
|
|
69
69
|
* `operationAccess({ list: true, read: true })` replaces the whole rule object,
|
|
70
|
-
* not a deep merge.
|
|
70
|
+
* not a deep merge. Two-argument member setters accept undefined to restore fallback.
|
|
71
|
+
* Data never inherits model defaults; updating beneath a scalar starts an object.
|
|
71
72
|
*/
|
|
72
|
-
operationAccess:
|
|
73
|
+
operationAccess: OperationAccessSetter<DataRouter<TData>>;
|
|
73
74
|
baseFilter: SetTargetOption$1<DataRouter<TData>, DataRouterOptions<TData>['baseFilter']>;
|
|
74
75
|
/**
|
|
75
76
|
* Trusted filter replacements applied before base-filter composition.
|
|
@@ -150,14 +151,14 @@ declare class ModelRouter<TModel = unknown, TVirtuals extends object = Record<ne
|
|
|
150
151
|
private logEndpoints;
|
|
151
152
|
/**
|
|
152
153
|
* Update live behavior with a typed key/path or an options object. Dotted paths
|
|
153
|
-
* such as `operationAccess.
|
|
154
|
+
* such as `operationAccess.read.basic` update one key; object assignment replaces
|
|
154
155
|
* supplied top-level values shallowly. The construction-time options snapshot stays fixed.
|
|
155
156
|
*/
|
|
156
157
|
set<K extends Extract<keyof TVirtuals, string> & string, A extends ModelVirtualRecordAccess>(key: `virtuals.${K}.${A}`, value: ModelVirtualDescriptor<TModel, K extends keyof TVirtuals ? TVirtuals[K] : unknown> | ModelVirtualGetter<TModel, K extends keyof TVirtuals ? TVirtuals[K] : unknown>): this;
|
|
157
158
|
set<K extends Extract<keyof TVirtuals, string> & string>(key: `virtuals.${K}`, value: ModelVirtualLeaf<TModel, K extends keyof TVirtuals ? TVirtuals[K] : unknown>): this;
|
|
158
159
|
set<K extends keyof ExtendedModelRouterOptions<TModel, TVirtuals>>(key: K, value: ExtendedModelRouterOptions<TModel, TVirtuals>[K]): this;
|
|
159
160
|
set(options: ModelRouterOptions<TModel, TVirtuals>): this;
|
|
160
|
-
/** Set one live option/path; `setOption('operationAccess.
|
|
161
|
+
/** Set one live option/path; `setOption('operationAccess.read.basic', undefined)` restores fallback. */
|
|
161
162
|
setOption<K extends keyof ExtendedModelRouterOptions<TModel, TVirtuals>>(key: K, option: ExtendedModelRouterOptions<TModel, TVirtuals>[K]): this;
|
|
162
163
|
/** Shallowly replace supplied top-level options; an operationAccess object replaces that entire rule object. */
|
|
163
164
|
setOptions(options: ModelRouterOptions<TModel, TVirtuals>): this;
|
|
@@ -236,22 +237,24 @@ declare class ModelRouter<TModel = unknown, TVirtuals extends object = Record<ne
|
|
|
236
237
|
*/
|
|
237
238
|
documentPermissionField: SetTargetOption<ModelRouter<TModel, TVirtuals>, ModelRouterOptions<TModel, TVirtuals>['documentPermissionField']>;
|
|
238
239
|
/**
|
|
239
|
-
*
|
|
240
|
+
* Configure a callable/descriptor directly, or replace one exact/default/custom
|
|
241
|
+
* access definition. Descriptor dependsOn adds private persisted inputs, not output grants.
|
|
242
|
+
* An undefined access restores default fallback; pass undefined alone to clear the option.
|
|
240
243
|
*/
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
docPermissions: SetTargetOption<ModelRouter<TModel, TVirtuals>, ModelRouterOptions<TModel, TVirtuals>['docPermissions']>;
|
|
244
|
+
docPermissions: {
|
|
245
|
+
(option: ModelRouterOptions<TModel, TVirtuals>['docPermissions']): ModelRouter<TModel, TVirtuals>;
|
|
246
|
+
(access: string, option: ModelDocPermissionsDefinition<TModel> | undefined): ModelRouter<TModel, TVirtuals>;
|
|
247
|
+
};
|
|
246
248
|
/**
|
|
247
|
-
* Configure live
|
|
249
|
+
* Configure live scalar/default and independent basic/advanced/root entry guards. Only undefined inherits;
|
|
248
250
|
* selected false denies with HTTP 401 without removing routes or OpenAPI entries.
|
|
249
|
-
* `operationAccess('
|
|
250
|
-
* `operationAccess('subs.comments.
|
|
251
|
+
* `operationAccess('read.basic', false)` updates one member, and
|
|
252
|
+
* `operationAccess('subs.comments.read.basic', false)` updates a field-specific member.
|
|
251
253
|
* `operationAccess({ list: true, read: true })` replaces the whole rule object,
|
|
252
|
-
* not a deep merge.
|
|
254
|
+
* not a deep merge. Two-argument member setters accept undefined to restore fallback.
|
|
255
|
+
* Updating beneath a scalar starts an object; retain the old guard in operation.default.
|
|
253
256
|
*/
|
|
254
|
-
operationAccess:
|
|
257
|
+
operationAccess: OperationAccessSetter<ModelRouter<TModel, TVirtuals>>;
|
|
255
258
|
/**
|
|
256
259
|
* The base filter definitions applied in every query transaction.
|
|
257
260
|
* @operation `list`, `read`, `update`, `delete`
|
|
@@ -623,4 +626,4 @@ declare function createAccessRuntime(): AccessRuntimeApi;
|
|
|
623
626
|
*/
|
|
624
627
|
declare const acl: AccessRuntimeApi;
|
|
625
628
|
|
|
626
|
-
export { AccessRuntime, type AccessRuntimeApi, type CombinedRouteInput, DataRouter, DataRouterOptions, DefaultModelRouterOptions, ExtendedDataRouterOptions, ExtendedDefaultModelRouterOptions, ExtendedModelRouterOptions, GlobalOptions, GuardHook, type GuardModelCondition, type GuardModelConditionID, ModelRouter, ModelRouterOptions, ModelVirtualDescriptor, ModelVirtualGetter, ModelVirtualLeaf, ModelVirtualRecordAccess, type OpLogContext, OpenApiCollisionError, OpenApiDocumentOptions, OpenApiRegistry, OpenApiRegistryOptions, OpenApiRouteDescriptor, OpenApiRouterOptions, RootRouter, RootRouterOptions, Validation, acl, combineRoutes, createAccessRuntime, createOpenApiRouter, acl as default, getDefaultModelOption, getDefaultModelOptions, getGlobalOption, getGlobalOptions, getModelInstance, getModelJsonSchema, getModelNames, getModelOption, getModelOptions, guard, hasModelInstance, isLevelEnabled, permissionsPlugin, redactFilter, redactPayload, registerModelInstance, safeStringify, setDefaultModelOption, setDefaultModelOptions, setGlobalOption, setGlobalOptions, setModelOption, setModelOptions };
|
|
629
|
+
export { AccessRuntime, type AccessRuntimeApi, type CombinedRouteInput, DataRouter, DataRouterOptions, DefaultModelRouterOptions, ExtendedDataRouterOptions, ExtendedDefaultModelRouterOptions, ExtendedModelRouterOptions, GlobalOptions, GuardHook, type GuardModelCondition, type GuardModelConditionID, ModelDocPermissionsDefinition, ModelRouter, ModelRouterOptions, ModelVirtualDescriptor, ModelVirtualGetter, ModelVirtualLeaf, ModelVirtualRecordAccess, type OpLogContext, OpenApiCollisionError, OpenApiDocumentOptions, OpenApiRegistry, OpenApiRegistryOptions, OpenApiRouteDescriptor, OpenApiRouterOptions, OperationAccessSetter, RootRouter, RootRouterOptions, Validation, acl, combineRoutes, createAccessRuntime, createOpenApiRouter, acl as default, getDefaultModelOption, getDefaultModelOptions, getGlobalOption, getGlobalOptions, getModelInstance, getModelJsonSchema, getModelNames, getModelOption, getModelOptions, guard, hasModelInstance, isLevelEnabled, permissionsPlugin, redactFilter, redactPayload, registerModelInstance, safeStringify, setDefaultModelOption, setDefaultModelOptions, setGlobalOption, setGlobalOptions, setModelOption, setModelOptions };
|