import express, { Response, NextFunction } from 'express'; import mongoose, { Document, FilterQuery } from 'mongoose'; import { Diff } from 'deep-diff'; import JsonRouter from 'express-json-router'; declare class PermissionDoc extends Document { _doc: any; constructor(...args: any[]); } interface BooleanObject { [key: string]: boolean; } declare class Permission { $_permissions: BooleanObject; $_permissionKeys: string[]; constructor(permissions: BooleanObject); prop(permission: any): boolean; has(permission: any): boolean; hasAny(permissions: any): any; hasAll(permissions: any): any; any(permissions: any): any; all(permissions: any): any; } interface Permissions extends Permission { [key: string]: any; } declare class Base { req: Request; modelName: string; constructor(req: Request, modelName: string); decorate(doc: any, access: DecorateAccess, context: MiddlewareContext): Promise; decorateAll(docs: any[], access: DecorateAllAccess, context: MiddlewareContext): Promise; genAllowedFields(doc: any, access: SelectAccess, baseFields?: string[]): Promise; genDocPermissions(doc: any, access: DocPermissionsAccess, context: MiddlewareContext): Promise<{}>; genFilter(access?: BaseFilterAccess, filter?: any): Promise; getIdentifier(): string | null; genIDFilter(id: string): Promise; genPopulate(access?: SelectAccess, populate?: any): Promise; genSelect(access: SelectAccess, targetFields?: Projection, skipChecks?: boolean, subPaths?: string[]): Promise; addEmptyPermissions(doc: any): any; addDocPermissions(doc: any, access: DocPermissionsAccess, context: MiddlewareContext): Promise; addFieldPermissions(doc: any, access: DocPermissionsAccess, context: MiddlewareContext): Promise; pickAllowedFields(doc: any, access: SelectAccess, baseFields?: string[]): Promise; prepare(allowedData: any, access: PrepareAccess, context: MiddlewareContext): Promise; runTasks(docObject: any, tasks: Task | Task[]): any; transform(doc: any, access: TransformAccess, context: MiddlewareContext): Promise; finalize(doc: any, access: FinalizeAccess, context: MiddlewareContext): Promise; changes(doc: any, context: MiddlewareContext): Promise; validate(allowedData: any, access: ValidateAccess, context: MiddlewareContext): Promise; checkIfModelPermissionExists(accesses: DocPermissionsAccess[]): boolean; protected processInclude(include: Include | Include[]): { includes: Include[]; includeLocalFields: any[]; includePaths: any[]; }; protected includeDocs(docs: any, include: Include | Include[]): Promise; private includeDocsList; private includeDocsCount; protected parseClientData(filter: any): Promise; private handleSubQuery; private handleDate; } interface FindProps { filter: Filter; select?: any; sort?: Sort; populate?: any; limit?: any; skip?: any; lean?: boolean; } interface FindOneProps { filter: Filter; select?: any; sort?: Sort; populate?: any; lean?: boolean; } type SortValue = 1 | -1 | 'asc' | 'desc'; type SortType = string | [string, SortValue][] | { [key: string]: SortValue; } | Map | null | undefined; declare class Model { modelName: string; model: mongoose.Model; jsonSchema: Record; indexKeys: string[]; indexMap: any; modelAttrs: string[]; constructor(modelName: string); new(): any; create(data: any): Promise; find({ filter, select, sort, populate, limit, skip, lean }: FindProps): mongoose.Query; validateSort(sort: SortType, logError?: (msg: string, ...args: any[]) => void): boolean; pruneSort(sort?: {}): {}; findOne({ filter, select, sort, populate, lean }: FindOneProps): mongoose.Query; findOneAndDelete(filter: any): mongoose.Query; exists(filter: any): mongoose.Query<(mongoose.FlattenMaps & Required<{ _id: unknown; }> & { __v: number; })[] | (mongoose.FlattenMaps & Required<{ _id: unknown; }> & { __v: number; }), any, {}, any, "findOne", {}>; countDocuments(filter?: {}): mongoose.Query; estimatedDocumentCount(): mongoose.Query; distinct(field: string, conditions?: {}): mongoose.Query; } declare class Service extends Base { model: Model; options: ModelRouterOptions; defaults: Defaults; baseFields: string[]; baseFieldsExt: string[]; constructor(req: Request, modelName: string); findOne(filter: Filter, args?: FindOneArgs, options?: FindOneOptions): Promise; findById(id: string, args?: FindByIdArgs, options?: FindByIdOptions): Promise; find(filter: Filter, args?: FindArgs, options?: FindOptions, decorate?: Function): Promise; create(data: any, args?: CreateArgs, options?: CreateOptions, decorate?: Function): Promise; new(): Promise; updateOne(filter: Filter, data: any, args?: UpdateOneArgs, options?: UpdateOneOptions, decorate?: Function): Promise; updateById(id: string, data: any, { populate, overrides }?: UpdateByIdArgs, { skim, includePermissions, populateAccess, }?: UpdateByIdOptions, decorate?: Function): Promise; upsert(filter: Filter, data: any, args?: UpsertArgs, options?: UpsertOptions, decorate?: Function): Promise; delete(id: string): Promise; exists(filter: Filter, options?: ExistsOptions): Promise; distinct(field: string, args?: DistinctArgs): Promise; count(filter: any, access?: BaseFilterAccess): Promise; getDocPermissions(doc: any): any; listSub(id: any, sub: any, options?: { filter: any; fields: string[]; }): Promise; readSub(id: any, sub: any, subId: any, options?: { fields: string[]; populate: any; }): Promise; updateSub(id: any, sub: any, subId: any, data: any): Promise; bulkUpdateSub(id: any, sub: any, data: any): Promise; createSub(id: any, sub: any, data: any, options?: { addFirst: boolean; }): Promise; deleteSub(id: any, sub: any, subId: any): Promise; getParentDoc(id: any, sub: any, args?: { populate?: SubPopulate | SubPopulate[]; }, options?: { access?: any; lean?: boolean; }): Promise; } declare class PublicService extends Service { _list(filter: Filter, args?: PublicListArgs, options?: PublicListOptions): Promise; _create(data: any, args?: PublicCreateArgs, options?: PublicCreateOptions): Promise; _new(): Promise; _read(id: string, args?: PublicReadArgs, options?: PublicReadOptions): Promise; _readFilter(filter: Filter, args?: PublicReadArgs & { sort?: Sort; }, options?: PublicReadOptions): Promise; _update(id: string, data: any, args?: PublicUpdateArgs, options?: PublicUpdateOptions): Promise; _delete(id: string): Promise; _distinct(field: string, options?: DistinctArgs): Promise; _count(filter: any, access?: BaseFilterAccess): Promise; } declare class DataService { req: Request; dataName: string; options: DataRouterOptions; data: T[]; constructor(req: Request, dataName: string); findOne(filter: DataFilter, args?: DataFindOneArgs, options?: DataFindOneOptions): Promise; findById(id: string, args?: DataFindOneArgs, options?: DataFindOneOptions): Promise; find(filter: DataFilter, args?: DataFindArgs, options?: DataFindOptions): Promise; decorate(doc: any, access: DecorateAccess, context?: DataMiddlewareContext): Promise; decorateAll(docs: any[], access: DecorateAllAccess): Promise; genAllowedFields(doc: any, access: SelectAccess, baseFields?: string[]): Promise; genFilter(access?: BaseFilterAccess, filter?: any): Promise; genIDFilter(id: string): Promise; genSelect(access: SelectAccess, targetFields?: Projection, skipChecks?: boolean, subPaths?: string[]): Promise; pickAllowedFields(doc: any, access: SelectAccess, baseFields?: string[]): Promise; } declare class Core { private req; private caches; constructor(req: Request); getIdentifier(modelName: string): string; genIDFilter(modelName: string, id: string): Promise; genFilter(modelName: string, access?: BaseFilterAccess, _filter?: Filter): Promise; private removePrefix; genAllowedFields(modelName: string, doc: any, access: SelectAccess, baseFields?: any[]): Promise; pickAllowedFields(modelName: string, doc: any, access: SelectAccess, baseFields?: any[]): Promise>; genSelect(modelName: string, access: SelectAccess, targetFields?: Projection, skipChecks?: boolean, subPaths?: any[]): Promise; genPopulate(modelName: string, access?: SelectAccess | BaseFilterAccess, _populate?: any): Promise; validate(modelName: string, allowedData: any, access: ValidateAccess, context: MiddlewareContext): Promise; prepare(modelName: string, allowedData: any, access: PrepareAccess, context: MiddlewareContext): Promise; transform(modelName: string, doc: any, access: TransformAccess, context: MiddlewareContext): Promise; finalize(modelName: string, doc: any, access: FinalizeAccess, context: MiddlewareContext): Promise; changes(modelName: string, doc: any, context: MiddlewareContext): Promise; genDocPermissions(modelName: string, doc: any, access: DocPermissionsAccess, context: MiddlewareContext): Promise<{}>; addEmptyPermissions(modelName: string, doc: any): any; addDocPermissions(modelName: string, doc: any, access: DocPermissionsAccess, context: MiddlewareContext): Promise; addFieldPermissions(modelName: string, doc: any, access: DocPermissionsAccess, context: MiddlewareContext): Promise; decorate(modelName: string, doc: any, access: DecorateAccess, context: MiddlewareContext): Promise; decorateAll(modelName: string, docs: any[], access: DecorateAllAccess, context: MiddlewareContext): Promise; runTasks(modelName: string, docObject: any, task: Task | Task[]): any; getPermissions(): Permission; setPermissions(): Promise; canActivate(routeGuard: Validation): Promise; isAllowed(modelName: string, access: RouteGuardAccess | string): Promise; getService(modelName: string): Service; getPublicService(modelName: string): PublicService; service(modelName: string): PublicService; svc(modelName: string): PublicService; private getGlobalPermissions; private callMiddleware; } declare class DataCore { private req; private caches; constructor(req: Request); genIDFilter(dataName: string, id: string): Promise; genFilter(dataName: string, access?: BaseFilterAccess, _filter?: Filter): Promise; genAllowedFields(dataName: string, doc: any, access: SelectAccess, baseFields?: any[]): Promise; pickAllowedFields(dataName: string, doc: any, access: SelectAccess, baseFields?: any[]): Promise>; genSelect(dataName: string, access: SelectAccess, targetFields?: Projection, skipChecks?: boolean, subPaths?: any[]): Promise; decorate(dataName: string, doc: any, access: DecorateAccess, context?: DataMiddlewareContext): Promise; decorateAll(dataName: string, docs: any[], access: DecorateAllAccess): Promise; getPermissions(): Permission; setPermissions(): Promise; canActivate(routeGuard: Validation): Promise; isAllowed(dataName: string, access: RouteGuardAccess | string): Promise; getService(dataName: string): DataService; service(dataName: string): DataService; svc(dataName: string): DataService; private getGlobalPermissions; private callMiddleware; } type Validation = boolean | string | string[] | Function; interface KeyValueProjection { [key: string]: 1 | -1; } type Projection = string[] | string | KeyValueProjection; type SortOrder = -1 | 1 | 'asc' | 'ascending' | 'desc' | 'descending'; type Sort = string | { [key: string]: SortOrder; } | [string, SortOrder][] | undefined | null; type Filter = false | FilterQuery; interface Include { model: string; op: 'list' | 'read' | 'count'; path: string; filter?: Filter; localField: string; foreignField: string; args?: any; options?: any; } type FindAccess = 'list' | 'read'; type PopulateAccess = 'list' | 'read'; interface Populate { path: string; select?: Projection; match?: any; access?: PopulateAccess; } interface SubPopulate { path: string; select?: Projection; } interface keyValue { [key: string]: any; } interface MiddlewareContext { modelName: string; model: mongoose.Model; originalDocObject?: Record; finalDocObject?: Record; diff?(doc: Document): void; currentDoc?: keyValue; originalData?: Record; preparedData?: Record; modifiedPaths?: string[]; changes?: Diff[]; docPermissions?: keyValue; } interface DataMiddlewareContext { } interface RootQueryEntry { model: string; op: string; id?: string; field?: string; filter?: Filter; data?: any; args?: any; options?: any; order?: number; } interface SubQueryEntry extends RootQueryEntry { sqOptions?: { path?: string; compact?: boolean; }; } interface Task { type: string; args: any; options: { [key: string]: any; }; } interface Request extends express.Request { query: Record<'skip' | 'limit' | 'page' | 'page_size' | 'try_list' | 'skim' | 'include_permissions' | 'include_count' | 'include_extra_headers' | 'returning_all', string>; macl: Core; dacl: DataCore; } interface ServiceResult { success: boolean; code: string; data: any; count?: number; totalCount?: number; input?: any; query?: any; errors?: any[]; context?: MiddlewareContext; contexts?: MiddlewareContext[]; } interface PublicCreateArgs { select?: Projection; populate?: Populate[] | string; tasks?: Task | Task[]; } interface CreateArgs extends Omit { } interface PublicCreateOptions { skim?: boolean; includePermissions?: boolean; populateAccess?: PopulateAccess; } interface CreateOptions extends PublicCreateOptions { } interface PublicUpdateArgs { select?: Projection; populate?: Populate[] | string; tasks?: Task | Task[]; } interface UpdateOneArgs extends Omit { overrides?: { filter?: Filter; populate?: Populate[] | string; }; } interface UpdateByIdArgs extends Omit { overrides?: { populate?: Populate[] | string; idFilter?: any; }; } interface UpsertArgs extends UpdateOneArgs { } interface PublicUpdateOptions { skim?: boolean; returningAll?: boolean; includePermissions?: boolean; populateAccess?: PopulateAccess; } interface UpdateOneOptions extends Omit { } interface UpdateByIdOptions extends UpdateOneOptions { } interface UpsertOptions extends UpdateOneOptions { } interface PublicListArgs { select?: Projection; populate?: Populate[] | string; include?: Include | Include[]; sort?: Sort; skip?: string | number; limit?: string | number; page?: string | number; pageSize?: string | number; tasks?: Task | Task[]; } interface PublicListOptions { skim?: boolean; includePermissions?: boolean; includeCount?: boolean; populateAccess?: PopulateAccess; lean?: boolean; } interface PublicReadArgs { select?: Projection; populate?: Populate[] | string; include?: Include | Include[]; tasks?: Task | Task[]; } interface PublicReadOptions { skim?: boolean; populateAccess?: PopulateAccess; lean?: boolean; includePermissions?: boolean; tryList?: boolean; } interface FindArgs { select?: Projection; populate?: Populate[] | string; include?: Include | Include[]; sort?: Sort; skip?: string | number; limit?: string | number; page?: string | number; pageSize?: string | number; overrides?: { filter?: Filter; select?: Projection; populate?: Populate[] | string; }; } interface FindOptions { skim?: boolean; includePermissions?: boolean; includeCount?: boolean; populateAccess?: PopulateAccess; lean?: boolean; } interface FindOneArgs { select?: Projection; sort?: Sort; populate?: Populate[] | string; include?: Include | Include[]; overrides?: { filter?: Filter; select?: Projection; populate?: Populate[] | string; }; } interface FindOneOptions { access?: FindAccess; populateAccess?: PopulateAccess; skim?: boolean; lean?: boolean; includePermissions?: boolean; } interface FindByIdArgs { select?: Projection; populate?: Populate[] | string; include?: Include | Include[]; overrides?: { select?: Projection; populate?: Populate[] | string; idFilter?: any; }; } interface FindByIdOptions extends FindOneOptions { } interface ExistsOptions { access?: BaseFilterAccess; includeId?: boolean; } interface DefaultFindOneArgs extends Omit { } interface DefaultFindByIdArgs extends Omit { } interface DefaultFindArgs extends Omit { } interface Defaults { findOneArgs?: DefaultFindOneArgs; findOneOptions?: FindOneOptions; findByIdArgs?: DefaultFindByIdArgs; findByIdOptions?: FindByIdOptions; findArgs?: DefaultFindArgs; findOptions?: FindOptions; createArgs?: CreateArgs; createOptions?: CreateOptions; updateOneArgs?: UpdateOneArgs; updateOneOptions?: UpdateOneOptions; upsertOptions?: UpsertOptions; updateByIdArgs?: UpdateByIdArgs; upsertArgs?: UpsertArgs; updateByIdOptions?: UpdateByIdOptions; existsOptions?: ExistsOptions; publicListArgs?: PublicListArgs; publicListOptions?: PublicListOptions; publicCreateArgs?: PublicCreateArgs; publicCreateOptions?: PublicCreateOptions; publicReadArgs?: PublicReadArgs; publicReadOptions?: PublicReadOptions; publicUpdateArgs?: PublicUpdateArgs; publicUpdateOptions?: PublicUpdateOptions; } interface GlobalOptions { permissionField?: string; globalPermissions?: (req: express.Request) => any; } interface RootRouterOptions { basePath: string; routeGuard?: Validation; } interface Access { list?: Validation; create?: Validation; read?: Validation; update?: Validation; delete?: Validation; distinct?: Validation; count?: Validation; sub?: any; } interface PermissionSchema { [key: string]: Access; } interface DocPermissions { list?: Function; create?: Function; read?: Function; update?: Function; } interface DefaultModelRouterOptions { listHardLimit?: number; permissionField?: string; idParam?: string; identifier?: string | Function; parentPath?: string; queryPath?: string; mutationPath?: string; routeGuard?: Validation | Access; modelPermissionPrefix?: string; } interface ExtendedDefaultModelRouterOptions extends DefaultModelRouterOptions { 'routeGuard.default'?: Validation; 'routeGuard.new'?: Validation; 'routeGuard.list'?: Validation; 'routeGuard.read'?: Validation; 'routeGuard.update'?: Validation; 'routeGuard.delete'?: Validation; 'routeGuard.create'?: Validation; 'routeGuard.distinct'?: Validation; 'routeGuard.count'?: Validation; 'routeGuard.subs'?: any; } interface ModelRouterOptions extends DefaultModelRouterOptions { modelName?: string; basePath?: string; permissionSchema?: PermissionSchema; _permissionSchemaKeys?: string[]; _globalPermissionKeys?: string[]; _modelPermissionKeys?: string[]; mandatoryFields?: string[]; docPermissions?: DocPermissions | Function; baseFilter?: any; overrideFilter?: any; decorate?: any; decorateAll?: any; validate?: any; prepare?: any; transform?: any; change?: Record; defaults?: Defaults; } interface DataRouterOptions { data?: any[]; listHardLimit?: number; idParam?: string; identifier?: string | Function; parentPath?: string; queryPath?: string; routeGuard?: Validation | Access; dataName?: string; basePath?: string; permissionSchema?: PermissionSchema; baseFilter?: any; overrideFilter?: any; decorate?: any; decorateAll?: any; } interface ExtendedModelRouterOptions extends ModelRouterOptions, ExtendedDefaultModelRouterOptions { 'mandatoryFields.default'?: string[]; 'mandatoryFields.list'?: string[]; 'mandatoryFields.create'?: string[]; 'mandatoryFields.read'?: string[]; 'mandatoryFields.update'?: string[]; 'docPermissions.default'?: Function; 'docPermissions.list'?: Function; 'docPermissions.create'?: Function; 'docPermissions.read'?: Function; 'docPermissions.update'?: Function; 'baseFilter.default'?: any; 'baseFilter.list'?: any; 'baseFilter.read'?: any; 'baseFilter.update'?: any; 'baseFilter.delete'?: any; 'overrideFilter.default'?: any; 'overrideFilter.list'?: any; 'overrideFilter.read'?: any; 'overrideFilter.update'?: any; 'overrideFilter.delete'?: any; 'decorate.default'?: any; 'decorate.list'?: any; 'decorate.create'?: any; 'decorate.read'?: any; 'decorate.update'?: any; 'decorateAll.default'?: any; 'decorateAll.list'?: any; 'validate.default'?: any; 'validate.create'?: any; 'validate.update'?: any; 'prepare.default'?: any; 'prepare.create'?: any; 'prepare.update'?: any; 'transform.default'?: any; 'transform.update'?: any; 'finalize.default'?: any; 'finalize.create'?: any; 'finalize.update'?: any; 'defaults.findOneArgs'?: DefaultFindOneArgs; 'defaults.findOneOptions'?: FindOneOptions; 'defaults.findByIdArgs'?: DefaultFindByIdArgs; 'defaults.findByIdOptions'?: FindByIdOptions; 'defaults.findArgs'?: DefaultFindArgs; 'defaults.findOptions'?: FindOptions; 'defaults.createArgs'?: CreateArgs; 'defaults.createOptions'?: CreateOptions; 'defaults.updateOneArgs'?: UpdateOneArgs; 'defaults.updateOneOptions'?: UpdateOneOptions; 'defaults.updateByIdArgs'?: UpdateByIdArgs; 'defaults.updateByIdOptions'?: UpdateByIdOptions; 'defaults.existsOptions'?: ExistsOptions; 'defaults.publicListArgs'?: PublicListArgs; 'defaults.publicListOptions'?: PublicListOptions; 'defaults.publicCreateArgs'?: PublicCreateArgs; 'defaults.publicCreateOptions'?: PublicCreateOptions; 'defaults.publicReadArgs'?: PublicReadArgs; 'defaults.publicReadOptions'?: PublicReadOptions; 'defaults.publicUpdateArgs'?: PublicUpdateArgs; 'defaults.publicUpdateOptions'?: PublicUpdateOptions; } type SelectAccess = 'list' | 'create' | 'read' | 'update' | string; type RouteGuardAccess = 'new' | 'list' | 'read' | 'update' | 'delete' | 'create' | 'distinct' | 'count' | 'subs' | string; type DocPermissionsAccess = 'list' | 'create' | 'read' | 'update' | string; type BaseFilterAccess = 'list' | 'read' | 'update' | 'delete' | string; type DecorateAccess = 'list' | 'create' | 'read' | 'update' | string; type DecorateAllAccess = 'list' | string; type ValidateAccess = 'create' | 'update' | string; type PrepareAccess = 'create' | 'update' | string; type TransformAccess = 'update' | string; type FinalizeAccess = 'create' | 'update' | string; interface DistinctArgs { filter?: Filter; } type DataFilter = any; interface DataFindOneArgs { select?: Projection; } interface DataFindOneOptions { access?: FindAccess; } interface DataFindArgs { select?: Projection; sort?: string; skip?: string | number; limit?: string | number; page?: string | number; pageSize?: string | number; } interface DataFindOptions { } declare function macl(): (req: Request, res: Response, next: NextFunction) => Promise; interface GuardModelConditionID { type: string; key: string; } interface GuardModelCondition { modelName: string; id: string | GuardModelConditionID; condition: string | string[]; } declare function guard(condition: string): any; declare function guard(conditions: string[]): any; declare function guard(conditionFunc: Function): any; declare function guard(modelCondition: GuardModelCondition): any; type SetTargetOption$1 = { (option: any): ModelRouter; (key: string, option: any): ModelRouter; }; declare class ModelRouter { readonly modelName: string; readonly router: JsonRouter; readonly model: Model; readonly options: ModelRouterOptions; readonly fullBasePath: string; constructor(modelName: string, initialOptions: ModelRouterOptions); private setCollectionRoutes; private setDocumentRoutes; private setSubDocumentRoutes; private logEndpoints; set(keyOrOptions: K | ModelRouterOptions, value?: unknown): this; setOption(key: K, option: ExtendedModelRouterOptions[K]): this; setOptions(options: ModelRouterOptions): this; /** * The maximum limit of the number of documents returned from the `list` operation. */ listHardLimit: SetTargetOption$1; /** * The object schema to define the access control policy for each model field. */ permissionSchema: SetTargetOption$1; /** * The object field to store the document permissions. */ permissionField: SetTargetOption$1; /** * The essential model fields involved in generating document permissions. */ mandatoryFields: SetTargetOption$1; /** * The function called in the process of generating document permissions. */ docPermissions: SetTargetOption$1; /** * The access control policy for CRUDL endpoints. * @operation `create`, `list`, `read`, `update`, `delete` */ routeGuard: SetTargetOption$1; /** * The base filter definitions applied in every query transaction. * @operation `list`, `read`, `update`, `delete` */ baseFilter: SetTargetOption$1; /** * The override filter definitions applied in every query transaction. * @operation `list`, `read`, `update`, `delete` */ overrideFilter: SetTargetOption$1; /** * Middleware * * The function called before a new/update document data is processed in `prepare` hooks. This method is used to validate `write data` and throw an error if not valid. * @operation `create`, `update` */ validate: SetTargetOption$1; /** * Middleware * * The function called before a new document is created or an existing document is updated. This method is used to process raw data passed into the API endpoints. * @operation `create`, `update` */ prepare: SetTargetOption$1; /** * Middleware * * The function called before an updated document is saved. * @operation `update` */ transform: SetTargetOption$1; /** * Middleware * * The function called after a new document is created or an updated document is saved. * @operation `create`, `update` */ finalize: SetTargetOption$1; /** * Middleware * * The function called after a updated document finalized * @operation `update` */ change: SetTargetOption$1; /** * Middleware * * The function called before response data is sent. This method is used to process raw data to apply custom logic before sending the result. * @operation `list`, `read`, `create`, `update` */ decorate: SetTargetOption$1; /** * Middleware * * The function are called before response data is sent and after `decorate` middleware runs. This method is used to process and filter multiple document objects before sending the result. * @operation `list` */ decorateAll: SetTargetOption$1; /** * The document selector definition with the `id` param. * @option `string` | `Function` * @operation `read`, `update`, `delete` */ identifier: SetTargetOption$1; /** * The default values used when missing in the operations. */ defaults: SetTargetOption$1; get routes(): any; } declare class RootRouter { router: JsonRouter; basename: string; routeGuard: Validation; constructor(options?: RootRouterOptions); private processResult; private processOp; private groupItemsByOrder; private setRoutes; get routes(): any; } declare const setGlobalOptions: (options: GlobalOptions) => void; declare const setGlobalOption: (key: K, value: GlobalOptions[K]) => void; declare const getGlobalOptions: () => GlobalOptions; declare const getGlobalOption: (key: K, defaultValue?: GlobalOptions[K]) => any; declare const setModelOptions: (modelName: string, options: ModelRouterOptions) => void; declare const setModelOption: (modelName: string, key: K, value: ExtendedModelRouterOptions[K]) => void; declare const getModelOptions: (modelName: string) => ModelRouterOptions; declare const getModelOption: (modelName: string, key: K | string, defaultValue?: ExtendedModelRouterOptions[K]) => any; declare const getModelNames: () => string[]; declare const getModelJsonSchema: (modelName: string) => any; declare const setDefaultModelOptions: (options: DefaultModelRouterOptions) => void; declare const setDefaultModelOption: (key: K, value: ExtendedDefaultModelRouterOptions[K]) => void; declare const getDefaultModelOptions: () => DefaultModelRouterOptions; declare const getDefaultModelOption: (key: K, defaultValue?: ExtendedDefaultModelRouterOptions[K]) => any; type SetTargetOption = { (option: any): DataRouter; (key: string, option: any): DataRouter; }; declare class DataRouter { readonly dataName: string; readonly router: JsonRouter; readonly options: DataRouterOptions; readonly fullBasePath: string; constructor(dataName: string, initialOptions: DataRouterOptions); private setCollectionRoutes; private setDocumentRoutes; set(keyOrOptions: K | DataRouterOptions, value?: unknown): this; setOption(key: K, option: DataRouterOptions[K]): this; setOptions(options: DataRouterOptions): this; data: SetTargetOption; listHardLimit: SetTargetOption; permissionSchema: SetTargetOption; routeGuard: SetTargetOption; baseFilter: SetTargetOption; overrideFilter: SetTargetOption; decorate: SetTargetOption; decorateAll: SetTargetOption; identifier: SetTargetOption; get routes(): any; } interface Options { permissionField?: string; modelName: string; } declare function permissionsPlugin(schema: any, options: Options): void; declare const MIDDLEWARE: unique symbol; declare const DATA_MIDDLEWARE: unique symbol; declare const CORE: unique symbol; declare const PERMISSIONS: unique symbol; declare const PERMISSION_KEYS: unique symbol; declare enum StatusCodes { OK = 200, Created = 201, BadRequest = 400, Unauthorized = 401, Forbidden = 403, NotFound = 404, UnprocessableContent = 422 } declare enum Codes { Success = "success", Created = "created", BadRequest = "bad_request", Unauthorized = "unauthorized", Forbidden = "forbidden", NotFound = "not_found" } declare enum CustomHeaders { TotalCount = "egose-total-count" } declare enum FilterOperator { SubQuery = 0, Date = 1 } type CreateRouter = { (modelName: string, options: ModelRouterOptions): ModelRouter; (options: RootRouterOptions): RootRouter; }; type CreateDataRouter = { (dataName: string, options: DataRouterOptions): DataRouter; }; type EgoseSet = { (key: K, value: GlobalOptions[K]): void; (options: { [K in keyof GlobalOptions]: GlobalOptions[K]; }): void; }; interface Egose { createRouter: CreateRouter; createDataRouter: CreateDataRouter; set: EgoseSet; setGlobalOptions: typeof setGlobalOptions; setGlobalOption: typeof setGlobalOption; getGlobalOptions: typeof getGlobalOptions; getGlobalOption: typeof getGlobalOption; setModelOptions: typeof setModelOptions; setModelOption: typeof setModelOption; getModelOptions: typeof getModelOptions; getModelOption: typeof getModelOption; getModelNames: typeof getModelNames; getModelJsonSchema: typeof getModelJsonSchema; setDefaultModelOptions: typeof setDefaultModelOptions; setDefaultModelOption: typeof setDefaultModelOption; getDefaultModelOptions: typeof getDefaultModelOptions; getDefaultModelOption: typeof getDefaultModelOption; RootRouter: typeof RootRouter; ModelRouter: typeof ModelRouter; DataRouter: typeof DataRouter; } declare const egose: typeof macl & Egose; export { type BaseFilterAccess, CORE, Codes, type CreateArgs, type CreateOptions, CustomHeaders, DATA_MIDDLEWARE, type DataFilter, type DataFindArgs, type DataFindOneArgs, type DataFindOneOptions, type DataFindOptions, type DataMiddlewareContext, type DataRouterOptions, type DecorateAccess, type DecorateAllAccess, type DefaultModelRouterOptions, type Defaults, type DistinctArgs, type DocPermissionsAccess, type ExistsOptions, type ExtendedDefaultModelRouterOptions, type ExtendedModelRouterOptions, type Filter, FilterOperator, type FinalizeAccess, type FindAccess, type FindArgs, type FindByIdArgs, type FindByIdOptions, type FindOneArgs, type FindOneOptions, type FindOptions, type GlobalOptions, type Include, type KeyValueProjection, MIDDLEWARE, type MiddlewareContext, ModelRouter, type ModelRouterOptions, PERMISSIONS, PERMISSION_KEYS, type Permissions, type Populate, type PopulateAccess, type PrepareAccess, type Projection, type PublicCreateArgs, type PublicCreateOptions, type PublicListArgs, type PublicListOptions, type PublicReadArgs, type PublicReadOptions, type PublicUpdateArgs, type PublicUpdateOptions, type Request, type RootQueryEntry, RootRouter, type RootRouterOptions, type RouteGuardAccess, type SelectAccess, type ServiceResult, type Sort, type SortOrder, StatusCodes, type SubPopulate, type SubQueryEntry, type Task, type TransformAccess, type UpdateByIdArgs, type UpdateByIdOptions, type UpdateOneArgs, type UpdateOneOptions, type UpsertArgs, type UpsertOptions, type ValidateAccess, type Validation, egose as default, getDefaultModelOption, getDefaultModelOptions, getGlobalOption, getGlobalOptions, getModelJsonSchema, getModelNames, getModelOption, getModelOptions, guard, permissionsPlugin, setDefaultModelOption, setDefaultModelOptions, setGlobalOption, setGlobalOptions, setModelOption, setModelOptions };