@web-ts-toolkit/access-router 0.43.0 → 0.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +97 -2
- package/advanced.d.mts +655 -19
- package/advanced.d.ts +655 -19
- package/advanced.js +478 -29
- package/advanced.mjs +478 -29
- package/index.d.mts +18 -10
- package/index.d.ts +18 -10
- package/index.js +1699 -262
- package/index.mjs +1576 -137
- package/llms.txt +19 -0
- package/package.json +18 -6
- package/{parsers-PMWujHUV.d.mts → parsers-DppKW-Fd.d.mts} +146 -26
- package/{parsers-PMWujHUV.d.ts → parsers-DppKW-Fd.d.ts} +146 -26
- package/processors.d.mts +151 -1
- package/processors.d.ts +151 -1
- package/processors.js +175 -8
- package/processors.mjs +170 -8
package/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import mongoose, { Schema } from 'mongoose';
|
|
2
2
|
import { Response, NextFunction, RequestHandler, Router } from 'express';
|
|
3
|
-
import {
|
|
4
|
-
export {
|
|
3
|
+
import { ag as GlobalOptions, Z as DefaultModelRouterOptions, aI as ModelRouterOptions, V as DataRouterOptions, a5 as ExtendedDefaultModelRouterOptions, a6 as ExtendedModelRouterOptions, a4 as ExtendedDataRouterOptions, A as AccessRouterBaseRequest, ai as GuardHook, aH as ModelRequest, T as DataRequest, cR as DataService, a7 as Filter, aS as Projection, bN as Sort, aP as Populate, cS as Service, cT as PublicService, cu as Validation, bE as RootRouterOptions } from './parsers-DppKW-Fd.mjs';
|
|
4
|
+
export { cU as AccessRouterPermissionMap, cV as AccessRouterPermissions, c as AccessRouterRequest, d as AccessRouterRequestExtensions, l as AjvErrorObjectLike, n as AjvValidatorLike, o as ArkTypeErrorsLike, p as ArkTypeLike, ah as GlobalPermissionValue, al as IoTsContextEntryLike, am as IoTsDecodeErrorLike, an as IoTsDecoderLike, ao as JoiSchemaLike, ap as JoiValidationErrorDetailLike, av as MaybePromise, aw as ModelBaseFilterHook, ay as ModelDeleteHook, az as ModelDocPermissionsHook, aB as ModelDocumentHook, aC as ModelHook, aE as ModelIdentifierHook, aF as ModelListHook, aG as ModelOverrideFilterHook, aJ as ModelValidateHook, cW as Permissions, b8 as RequestSchemaAdapter, b9 as RequestSchemaFailure, ba as RequestSchemaIssue, bb as RequestSchemaLike, bc as RequestSchemaOptions, bd as RequestSchemaResult, be as RequestSchemaSuccess, bf as RequestSchemaValidator, bH as RouteGuardAccess, bP as StandardSchemaFailure, bQ as StandardSchemaInferOutput, bR as StandardSchemaIssue, bS as StandardSchemaPathSegment, bT as StandardSchemaResult, bU as StandardSchemaSuccess, bV as StandardSchemaV1, ca as SuperstructFailureLike, cb as SuperstructValidateLike, co as ValibotIssueLike, cp as ValibotPathItemLike, cq as ValibotSafeParseLike, cr as ValibotSafeParseResult, cw as VineValidationErrorLike, cx as VineValidationMessageLike, cy as VineValidatorLike, cz as YupSchemaLike, cA as YupValidationErrorLike, cB as defineRequestSchema, cC as fromAjv, cD as fromArkType, cE as fromIoTs, cF as fromJoi, cG as fromStandardSchema, cH as fromSuperstruct, cI as fromValibot, cJ as fromVine, cK as fromYup, cL as fromZod } from './parsers-DppKW-Fd.mjs';
|
|
5
5
|
import JsonRouter from '@web-ts-toolkit/express-json-router';
|
|
6
6
|
import 'zod';
|
|
7
7
|
|
|
@@ -103,9 +103,9 @@ declare class AccessRuntime {
|
|
|
103
103
|
private readonly modelAtts;
|
|
104
104
|
private readonly modelInstances;
|
|
105
105
|
private readonly openApiRegistry;
|
|
106
|
-
registerModelInstance(modelName: string, model: mongoose.Model<
|
|
106
|
+
registerModelInstance<TModel>(modelName: string, model: mongoose.Model<TModel>): void;
|
|
107
107
|
hasModelInstance(modelName: string): boolean;
|
|
108
|
-
getModelInstance(modelName: string): mongoose.Model<
|
|
108
|
+
getModelInstance<TModel = unknown>(modelName: string): mongoose.Model<TModel> | null;
|
|
109
109
|
registerOpenApiRoute(route: OpenApiRouteDescriptor): void;
|
|
110
110
|
/**
|
|
111
111
|
* Enable strict OpenAPI collision detection for the remainder of this
|
|
@@ -177,6 +177,7 @@ declare class AccessRuntime {
|
|
|
177
177
|
setDataOptions<TData = unknown>(dataName: string, options: DataRouterOptions<TData>): void;
|
|
178
178
|
setDataOption<K extends keyof DataRouterOptions<TData>, TData = unknown>(dataName: string, key: K, value: DataRouterOptions<TData>[K]): void;
|
|
179
179
|
getDataOptions<TData = unknown>(dataName: string): DataRouterOptions<TData>;
|
|
180
|
+
getDataSnapshot<TData = unknown>(dataName: string): readonly TData[];
|
|
180
181
|
getDataOption<K extends keyof DataRouterOptions<TData>, TData = unknown>(dataName: string, key: K | string, defaultValue?: DataRouterOptions<TData>[K]): DataRouterOptions<TData>[K];
|
|
181
182
|
getExactDataOption<K extends keyof ExtendedDataRouterOptions<TData>, TData = unknown>(dataName: string, key: K | string): ExtendedDataRouterOptions<TData>[K];
|
|
182
183
|
getDataNames(): string[];
|
|
@@ -228,6 +229,11 @@ declare class DataRouter<TData = unknown> {
|
|
|
228
229
|
permissionSchema: SetTargetOption$1<DataRouter<TData>, DataRouterOptions<TData>['permissionSchema']>;
|
|
229
230
|
operationAccess: SetTargetOption$1<DataRouter<TData>, DataRouterOptions<TData>['operationAccess']>;
|
|
230
231
|
baseFilter: SetTargetOption$1<DataRouter<TData>, DataRouterOptions<TData>['baseFilter']>;
|
|
232
|
+
/**
|
|
233
|
+
* Trusted filter replacements applied before base-filter composition.
|
|
234
|
+
* They may replace ordinary filters, but cannot replace an existing `false` denial.
|
|
235
|
+
* Returning `false` denies the transaction.
|
|
236
|
+
*/
|
|
231
237
|
overrideFilter: SetTargetOption$1<DataRouter<TData>, DataRouterOptions<TData>['overrideFilter']>;
|
|
232
238
|
decorate: SetTargetOption$1<DataRouter<TData>, DataRouterOptions<TData>['decorate']>;
|
|
233
239
|
decorateAll: SetTargetOption$1<DataRouter<TData>, DataRouterOptions<TData>['decorateAll']>;
|
|
@@ -281,7 +287,7 @@ declare class ModelRouter<TModel = unknown> {
|
|
|
281
287
|
readonly options: ModelRouterOptions<TModel>;
|
|
282
288
|
readonly fullBasePath: string;
|
|
283
289
|
constructor(modelName: string, initialOptions: ModelRouterOptions<TModel>, runtime?: AccessRuntime);
|
|
284
|
-
static fromModel<TModel
|
|
290
|
+
static fromModel<TModel>(model: mongoose.Model<TModel>, initialOptions: ModelRouterOptions<TModel>, runtime?: AccessRuntime): ModelRouter<TModel>;
|
|
285
291
|
private getRequestSchema;
|
|
286
292
|
getService(req: ModelRequest): Service<TModel>;
|
|
287
293
|
getPublicService(req: ModelRequest): PublicService<TModel>;
|
|
@@ -326,7 +332,9 @@ declare class ModelRouter<TModel = unknown> {
|
|
|
326
332
|
*/
|
|
327
333
|
baseFilter: SetTargetOption<ModelRouter<TModel>, ModelRouterOptions<TModel>['baseFilter']>;
|
|
328
334
|
/**
|
|
329
|
-
*
|
|
335
|
+
* Trusted filter replacements applied before base-filter composition.
|
|
336
|
+
* They may replace ordinary filters, but cannot replace an existing `false` denial.
|
|
337
|
+
* Returning `false` denies the transaction.
|
|
330
338
|
* @operation `list`, `read`, `update`, `delete`
|
|
331
339
|
*/
|
|
332
340
|
overrideFilter: SetTargetOption<ModelRouter<TModel>, ModelRouterOptions<TModel>['overrideFilter']>;
|
|
@@ -517,9 +525,9 @@ declare const getModelOptions: <TModel = unknown>(modelName: string) => ModelRou
|
|
|
517
525
|
declare const getModelOption: <K extends keyof ExtendedModelRouterOptions<TModel>, TModel = unknown>(modelName: string, key: K | string, defaultValue?: ExtendedModelRouterOptions<TModel>[K]) => ExtendedModelRouterOptions<TModel>[K];
|
|
518
526
|
declare const getModelNames: () => string[];
|
|
519
527
|
declare const getModelJsonSchema: (modelName: string) => Record<string, unknown>;
|
|
520
|
-
declare const registerModelInstance: (modelName: string, model: mongoose.Model<
|
|
528
|
+
declare const registerModelInstance: <TModel>(modelName: string, model: mongoose.Model<TModel>) => void;
|
|
521
529
|
declare const hasModelInstance: (modelName: string) => boolean;
|
|
522
|
-
declare const getModelInstance: (modelName: string) => mongoose.Model<
|
|
530
|
+
declare const getModelInstance: <TModel = unknown>(modelName: string) => mongoose.Model<TModel> | null;
|
|
523
531
|
|
|
524
532
|
declare const setDefaultModelOptions: (options: DefaultModelRouterOptions) => void;
|
|
525
533
|
declare const setDefaultModelOption: <K extends keyof ExtendedDefaultModelRouterOptions>(key: K, value: ExtendedDefaultModelRouterOptions[K]) => void;
|
|
@@ -590,9 +598,9 @@ interface Wtt {
|
|
|
590
598
|
setDefaultModelOption: typeof setDefaultModelOption;
|
|
591
599
|
getDefaultModelOptions: typeof getDefaultModelOptions;
|
|
592
600
|
getDefaultModelOption: typeof getDefaultModelOption;
|
|
593
|
-
registerModelInstance: (modelName: string, model: mongoose.Model<
|
|
601
|
+
registerModelInstance: <TModel>(modelName: string, model: mongoose.Model<TModel>) => void;
|
|
594
602
|
hasModelInstance: (modelName: string) => boolean;
|
|
595
|
-
getModelInstance: (modelName: string) => mongoose.Model<
|
|
603
|
+
getModelInstance: <TModel = unknown>(modelName: string) => mongoose.Model<TModel> | null;
|
|
596
604
|
RootRouter: typeof RootRouter;
|
|
597
605
|
ModelRouter: typeof ModelRouter;
|
|
598
606
|
DataRouter: typeof DataRouter;
|
package/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import mongoose, { Schema } from 'mongoose';
|
|
2
2
|
import { Response, NextFunction, RequestHandler, Router } from 'express';
|
|
3
|
-
import {
|
|
4
|
-
export {
|
|
3
|
+
import { ag as GlobalOptions, Z as DefaultModelRouterOptions, aI as ModelRouterOptions, V as DataRouterOptions, a5 as ExtendedDefaultModelRouterOptions, a6 as ExtendedModelRouterOptions, a4 as ExtendedDataRouterOptions, A as AccessRouterBaseRequest, ai as GuardHook, aH as ModelRequest, T as DataRequest, cR as DataService, a7 as Filter, aS as Projection, bN as Sort, aP as Populate, cS as Service, cT as PublicService, cu as Validation, bE as RootRouterOptions } from './parsers-DppKW-Fd.js';
|
|
4
|
+
export { cU as AccessRouterPermissionMap, cV as AccessRouterPermissions, c as AccessRouterRequest, d as AccessRouterRequestExtensions, l as AjvErrorObjectLike, n as AjvValidatorLike, o as ArkTypeErrorsLike, p as ArkTypeLike, ah as GlobalPermissionValue, al as IoTsContextEntryLike, am as IoTsDecodeErrorLike, an as IoTsDecoderLike, ao as JoiSchemaLike, ap as JoiValidationErrorDetailLike, av as MaybePromise, aw as ModelBaseFilterHook, ay as ModelDeleteHook, az as ModelDocPermissionsHook, aB as ModelDocumentHook, aC as ModelHook, aE as ModelIdentifierHook, aF as ModelListHook, aG as ModelOverrideFilterHook, aJ as ModelValidateHook, cW as Permissions, b8 as RequestSchemaAdapter, b9 as RequestSchemaFailure, ba as RequestSchemaIssue, bb as RequestSchemaLike, bc as RequestSchemaOptions, bd as RequestSchemaResult, be as RequestSchemaSuccess, bf as RequestSchemaValidator, bH as RouteGuardAccess, bP as StandardSchemaFailure, bQ as StandardSchemaInferOutput, bR as StandardSchemaIssue, bS as StandardSchemaPathSegment, bT as StandardSchemaResult, bU as StandardSchemaSuccess, bV as StandardSchemaV1, ca as SuperstructFailureLike, cb as SuperstructValidateLike, co as ValibotIssueLike, cp as ValibotPathItemLike, cq as ValibotSafeParseLike, cr as ValibotSafeParseResult, cw as VineValidationErrorLike, cx as VineValidationMessageLike, cy as VineValidatorLike, cz as YupSchemaLike, cA as YupValidationErrorLike, cB as defineRequestSchema, cC as fromAjv, cD as fromArkType, cE as fromIoTs, cF as fromJoi, cG as fromStandardSchema, cH as fromSuperstruct, cI as fromValibot, cJ as fromVine, cK as fromYup, cL as fromZod } from './parsers-DppKW-Fd.js';
|
|
5
5
|
import JsonRouter from '@web-ts-toolkit/express-json-router';
|
|
6
6
|
import 'zod';
|
|
7
7
|
|
|
@@ -103,9 +103,9 @@ declare class AccessRuntime {
|
|
|
103
103
|
private readonly modelAtts;
|
|
104
104
|
private readonly modelInstances;
|
|
105
105
|
private readonly openApiRegistry;
|
|
106
|
-
registerModelInstance(modelName: string, model: mongoose.Model<
|
|
106
|
+
registerModelInstance<TModel>(modelName: string, model: mongoose.Model<TModel>): void;
|
|
107
107
|
hasModelInstance(modelName: string): boolean;
|
|
108
|
-
getModelInstance(modelName: string): mongoose.Model<
|
|
108
|
+
getModelInstance<TModel = unknown>(modelName: string): mongoose.Model<TModel> | null;
|
|
109
109
|
registerOpenApiRoute(route: OpenApiRouteDescriptor): void;
|
|
110
110
|
/**
|
|
111
111
|
* Enable strict OpenAPI collision detection for the remainder of this
|
|
@@ -177,6 +177,7 @@ declare class AccessRuntime {
|
|
|
177
177
|
setDataOptions<TData = unknown>(dataName: string, options: DataRouterOptions<TData>): void;
|
|
178
178
|
setDataOption<K extends keyof DataRouterOptions<TData>, TData = unknown>(dataName: string, key: K, value: DataRouterOptions<TData>[K]): void;
|
|
179
179
|
getDataOptions<TData = unknown>(dataName: string): DataRouterOptions<TData>;
|
|
180
|
+
getDataSnapshot<TData = unknown>(dataName: string): readonly TData[];
|
|
180
181
|
getDataOption<K extends keyof DataRouterOptions<TData>, TData = unknown>(dataName: string, key: K | string, defaultValue?: DataRouterOptions<TData>[K]): DataRouterOptions<TData>[K];
|
|
181
182
|
getExactDataOption<K extends keyof ExtendedDataRouterOptions<TData>, TData = unknown>(dataName: string, key: K | string): ExtendedDataRouterOptions<TData>[K];
|
|
182
183
|
getDataNames(): string[];
|
|
@@ -228,6 +229,11 @@ declare class DataRouter<TData = unknown> {
|
|
|
228
229
|
permissionSchema: SetTargetOption$1<DataRouter<TData>, DataRouterOptions<TData>['permissionSchema']>;
|
|
229
230
|
operationAccess: SetTargetOption$1<DataRouter<TData>, DataRouterOptions<TData>['operationAccess']>;
|
|
230
231
|
baseFilter: SetTargetOption$1<DataRouter<TData>, DataRouterOptions<TData>['baseFilter']>;
|
|
232
|
+
/**
|
|
233
|
+
* Trusted filter replacements applied before base-filter composition.
|
|
234
|
+
* They may replace ordinary filters, but cannot replace an existing `false` denial.
|
|
235
|
+
* Returning `false` denies the transaction.
|
|
236
|
+
*/
|
|
231
237
|
overrideFilter: SetTargetOption$1<DataRouter<TData>, DataRouterOptions<TData>['overrideFilter']>;
|
|
232
238
|
decorate: SetTargetOption$1<DataRouter<TData>, DataRouterOptions<TData>['decorate']>;
|
|
233
239
|
decorateAll: SetTargetOption$1<DataRouter<TData>, DataRouterOptions<TData>['decorateAll']>;
|
|
@@ -281,7 +287,7 @@ declare class ModelRouter<TModel = unknown> {
|
|
|
281
287
|
readonly options: ModelRouterOptions<TModel>;
|
|
282
288
|
readonly fullBasePath: string;
|
|
283
289
|
constructor(modelName: string, initialOptions: ModelRouterOptions<TModel>, runtime?: AccessRuntime);
|
|
284
|
-
static fromModel<TModel
|
|
290
|
+
static fromModel<TModel>(model: mongoose.Model<TModel>, initialOptions: ModelRouterOptions<TModel>, runtime?: AccessRuntime): ModelRouter<TModel>;
|
|
285
291
|
private getRequestSchema;
|
|
286
292
|
getService(req: ModelRequest): Service<TModel>;
|
|
287
293
|
getPublicService(req: ModelRequest): PublicService<TModel>;
|
|
@@ -326,7 +332,9 @@ declare class ModelRouter<TModel = unknown> {
|
|
|
326
332
|
*/
|
|
327
333
|
baseFilter: SetTargetOption<ModelRouter<TModel>, ModelRouterOptions<TModel>['baseFilter']>;
|
|
328
334
|
/**
|
|
329
|
-
*
|
|
335
|
+
* Trusted filter replacements applied before base-filter composition.
|
|
336
|
+
* They may replace ordinary filters, but cannot replace an existing `false` denial.
|
|
337
|
+
* Returning `false` denies the transaction.
|
|
330
338
|
* @operation `list`, `read`, `update`, `delete`
|
|
331
339
|
*/
|
|
332
340
|
overrideFilter: SetTargetOption<ModelRouter<TModel>, ModelRouterOptions<TModel>['overrideFilter']>;
|
|
@@ -517,9 +525,9 @@ declare const getModelOptions: <TModel = unknown>(modelName: string) => ModelRou
|
|
|
517
525
|
declare const getModelOption: <K extends keyof ExtendedModelRouterOptions<TModel>, TModel = unknown>(modelName: string, key: K | string, defaultValue?: ExtendedModelRouterOptions<TModel>[K]) => ExtendedModelRouterOptions<TModel>[K];
|
|
518
526
|
declare const getModelNames: () => string[];
|
|
519
527
|
declare const getModelJsonSchema: (modelName: string) => Record<string, unknown>;
|
|
520
|
-
declare const registerModelInstance: (modelName: string, model: mongoose.Model<
|
|
528
|
+
declare const registerModelInstance: <TModel>(modelName: string, model: mongoose.Model<TModel>) => void;
|
|
521
529
|
declare const hasModelInstance: (modelName: string) => boolean;
|
|
522
|
-
declare const getModelInstance: (modelName: string) => mongoose.Model<
|
|
530
|
+
declare const getModelInstance: <TModel = unknown>(modelName: string) => mongoose.Model<TModel> | null;
|
|
523
531
|
|
|
524
532
|
declare const setDefaultModelOptions: (options: DefaultModelRouterOptions) => void;
|
|
525
533
|
declare const setDefaultModelOption: <K extends keyof ExtendedDefaultModelRouterOptions>(key: K, value: ExtendedDefaultModelRouterOptions[K]) => void;
|
|
@@ -590,9 +598,9 @@ interface Wtt {
|
|
|
590
598
|
setDefaultModelOption: typeof setDefaultModelOption;
|
|
591
599
|
getDefaultModelOptions: typeof getDefaultModelOptions;
|
|
592
600
|
getDefaultModelOption: typeof getDefaultModelOption;
|
|
593
|
-
registerModelInstance: (modelName: string, model: mongoose.Model<
|
|
601
|
+
registerModelInstance: <TModel>(modelName: string, model: mongoose.Model<TModel>) => void;
|
|
594
602
|
hasModelInstance: (modelName: string) => boolean;
|
|
595
|
-
getModelInstance: (modelName: string) => mongoose.Model<
|
|
603
|
+
getModelInstance: <TModel = unknown>(modelName: string) => mongoose.Model<TModel> | null;
|
|
596
604
|
RootRouter: typeof RootRouter;
|
|
597
605
|
ModelRouter: typeof ModelRouter;
|
|
598
606
|
DataRouter: typeof DataRouter;
|