@aptly-as/express-scope 1.0.0 → 1.0.1

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/lib/Scope.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { NextFunction, Request, Response } from 'express';
1
+ import type { NextFunction, Request, Response } from 'express';
2
2
  import { ScopeAccess, ScopeFn, ScopeRolesSchema, ScopeModuleSchema, ScopeRequest, ScopeRequestItem, ScopeRequestValidate } from './types.js';
3
3
  export default class Scope<R extends Request, SCOPE extends string, MODULE extends ScopeModuleSchema<string, SCOPE>, USER extends ScopeRolesSchema<string, SCOPE>, ORG extends ScopeRolesSchema<string, SCOPE>> {
4
4
  private _modules;
@@ -14,13 +14,13 @@ export default class Scope<R extends Request, SCOPE extends string, MODULE exten
14
14
  /**
15
15
  * @deprecated use access instead
16
16
  */
17
- crud(scope: SCOPE | SCOPE[], access: ScopeAccess, validate?: ScopeRequestValidate<R>): (req: R, res: Response, next?: NextFunction | undefined) => boolean | void | Response;
18
- access(scope: SCOPE | SCOPE[], access: ScopeAccess, validate?: ScopeRequestValidate<R>): (req: R, res: Response, next?: NextFunction) => boolean | void | Response;
17
+ crud(scope: SCOPE | SCOPE[], access: ScopeAccess, validate?: ScopeRequestValidate<R>): (req: R, res: Response<any, Record<string, any>>, next?: NextFunction | undefined) => boolean | void | Response<any, Record<string, any>>;
18
+ access(scope: SCOPE | SCOPE[], access: ScopeAccess, validate?: ScopeRequestValidate<R>): (req: R, res: Response, next?: NextFunction) => boolean | void | Response<any, Record<string, any>>;
19
19
  /**
20
20
  * @deprecated use list instead
21
21
  */
22
- validate(crudArray: ScopeRequestItem<R, SCOPE> | Array<ScopeRequestItem<R, SCOPE>>): (req: R, res: Response, next?: NextFunction | undefined) => boolean | void | Response;
23
- list(crudArray: ScopeRequestItem<R, SCOPE> | Array<ScopeRequestItem<R, SCOPE>>): (req: R, res: Response, next?: NextFunction) => boolean | void | Response;
22
+ validate(crudArray: ScopeRequestItem<R, SCOPE> | Array<ScopeRequestItem<R, SCOPE>>): (req: R, res: Response<any, Record<string, any>>, next?: NextFunction | undefined) => boolean | void | Response<any, Record<string, any>>;
23
+ list(crudArray: ScopeRequestItem<R, SCOPE> | Array<ScopeRequestItem<R, SCOPE>>): (req: R, res: Response, next?: NextFunction) => boolean | void | Response<any, Record<string, any>>;
24
24
  get<K extends 'json' | 'next' | 'return' = 'json'>(action?: K, key?: K extends 'next' ? keyof R : undefined): (req: R, res: Response, next: NextFunction) => any;
25
25
  req(req: R, res: Response): ScopeRequest<R, SCOPE>;
26
26
  private _getScopeArray;
@@ -1,4 +1,4 @@
1
- import { Request } from 'express';
1
+ import type { Request } from 'express';
2
2
  import Scope from './Scope.js';
3
3
  import { ScopeMiddleware } from './ScopeMiddleware.js';
4
4
  export declare class ScopeHandler<R extends Request, S extends string> {
@@ -1,4 +1,4 @@
1
- import { Request } from 'express';
1
+ import type { Request } from 'express';
2
2
  import Scope from './Scope.js';
3
3
  import { ScopeValidateFn } from './types.js';
4
4
  export declare class ScopeMiddleware<R extends Request, S extends string> {
@@ -9,6 +9,6 @@ export declare class ScopeMiddleware<R extends Request, S extends string> {
9
9
  readonly DELETE: ScopeValidateFn<R>;
10
10
  constructor(_scope: Scope<R, S, any, any, any>, scope: S | S[]);
11
11
  get scope(): Scope<R, S, any, any, any>;
12
- get list(): (crudArray: import("./types.js").ScopeRequestItem<R, S> | import("./types.js").ScopeRequestItem<R, S>[]) => (req: R, res: import("express").Response, next?: import("express").NextFunction | undefined) => boolean | void | import("express").Response;
13
- get validate(): (crudArray: import("./types.js").ScopeRequestItem<R, S> | import("./types.js").ScopeRequestItem<R, S>[]) => (req: R, res: import("express").Response, next?: import("express").NextFunction | undefined) => boolean | void | import("express").Response;
12
+ get list(): (crudArray: import("./types.js").ScopeRequestItem<R, S> | import("./types.js").ScopeRequestItem<R, S>[]) => (req: R, res: import("express").Response<any, Record<string, any>>, next?: import("express").NextFunction | undefined) => boolean | void | import("express").Response<any, Record<string, any>>;
13
+ get validate(): (crudArray: import("./types.js").ScopeRequestItem<R, S> | import("./types.js").ScopeRequestItem<R, S>[]) => (req: R, res: import("express").Response<any, Record<string, any>>, next?: import("express").NextFunction | undefined) => boolean | void | import("express").Response<any, Record<string, any>>;
14
14
  }
package/lib/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { NextFunction, Request, Response } from 'express';
1
+ import type { NextFunction, Request, Response } from 'express';
2
2
  export type ScopeAccessValue = 'C' | 'CR' | 'CRU' | 'CRUD' | 'R' | 'RU' | 'RUD' | 'U' | 'UD' | 'D';
3
3
  export type ScopeAccess = 'C' | 'R' | 'U' | 'D';
4
4
  export type ScopeAccessSchema<SCOPE extends string> = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aptly-as/express-scope",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -23,7 +23,7 @@
23
23
  "author": "Emil A Olsen (EmilsWebbod)",
24
24
  "license": "ISC",
25
25
  "devDependencies": {
26
- "@types/express": "^4.17.2",
26
+ "@types/express": "^4.17.17",
27
27
  "@types/sinon": "^10.0.15",
28
28
  "@vitest/ui": "^0.31.1",
29
29
  "coveralls": "^3.0.7",
@@ -39,6 +39,9 @@
39
39
  "typescript": "^5.0.4",
40
40
  "vitest": "^0.31.1"
41
41
  },
42
+ "peerDependencies": {
43
+ "express": "*"
44
+ },
42
45
  "files": [
43
46
  "lib"
44
47
  ],