@zenofolio/hyper-decor 1.0.41 → 1.0.43
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/.mocharc.js +2 -2
- package/README.md +1 -1
- package/dist/__internals/transform/scope.transfrom.d.ts +3 -1
- package/dist/__internals/transform/scope.transfrom.js +4 -3
- package/dist/decorators/HyperApp.js +5 -1
- package/dist/decorators/types.d.ts +3 -1
- package/dist/decorators/types.js +1 -0
- package/dist/extension.js +5 -2
- package/hyper-express-decorators.d.ts +1 -0
- package/package.json +1 -1
package/.mocharc.js
CHANGED
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { MiddlewareHandler } from "hyper-express";
|
|
2
2
|
import { ScopeMap, ScopeType } from "../../decorators";
|
|
3
|
-
|
|
3
|
+
type Callback = (middleware: MiddlewareHandler, scopes: ScopeMap[], names: Set<string>) => void;
|
|
4
|
+
export default function scopeTransfrom(listScopes: ScopeType[], ...callback: Callback[]): MiddlewareHandler;
|
|
5
|
+
export {};
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.default = scopeTransfrom;
|
|
4
4
|
const exeptions_1 = require("../../exeptions");
|
|
5
5
|
const helpers_1 = require("../../common/helpers");
|
|
6
|
-
function scopeTransfrom(listScopes, callback) {
|
|
6
|
+
function scopeTransfrom(listScopes, ...callback) {
|
|
7
7
|
const { scopes, scopeNames, isEmtpy } = resolveScopes(listScopes);
|
|
8
8
|
const middleware = (req, res, next) => {
|
|
9
9
|
var _a;
|
|
@@ -19,8 +19,9 @@ function scopeTransfrom(listScopes, callback) {
|
|
|
19
19
|
}
|
|
20
20
|
return next();
|
|
21
21
|
};
|
|
22
|
-
if (scopeNames.size > 0 && callback) {
|
|
23
|
-
|
|
22
|
+
if (scopeNames.size > 0 && callback && callback.length > 0) {
|
|
23
|
+
for (const cb of callback)
|
|
24
|
+
cb(middleware, scopes, scopeNames);
|
|
24
25
|
}
|
|
25
26
|
return middleware;
|
|
26
27
|
}
|
|
@@ -89,6 +89,7 @@ const HyperApp = (options) => (0, decorator_base_1.DecoratorHelper)({
|
|
|
89
89
|
content.push("");
|
|
90
90
|
});
|
|
91
91
|
(_c = options.logger) === null || _c === void 0 ? void 0 : _c.call(this, content.join("\n"));
|
|
92
|
+
this.storeLogs = {};
|
|
92
93
|
}
|
|
93
94
|
};
|
|
94
95
|
});
|
|
@@ -251,7 +252,10 @@ function prepareRoutes(_a) {
|
|
|
251
252
|
return;
|
|
252
253
|
const middlewares = [...metadata.middlewares];
|
|
253
254
|
(0, role_transform_1.default)(metadata.roles, (middleware) => middlewares.push(middleware));
|
|
254
|
-
(0, scope_transfrom_1.default)(metadata.scopes, (middleware) =>
|
|
255
|
+
(0, scope_transfrom_1.default)(metadata.scopes, (middleware, scopes) => {
|
|
256
|
+
middlewares.push(middleware);
|
|
257
|
+
collectors_1.ScopeStore.addAll(scopes);
|
|
258
|
+
});
|
|
255
259
|
log("routes", `${namespace}/${propertyKey} ${method.toUpperCase()} { ${path} }`);
|
|
256
260
|
if (!hasParams) {
|
|
257
261
|
$fn.call(router, path, ...middlewares, handler.bind(instance));
|
|
@@ -21,7 +21,9 @@ export interface HyperAppMetadata {
|
|
|
21
21
|
imports?: Constructor[];
|
|
22
22
|
options?: ServerConstructorOptions;
|
|
23
23
|
}
|
|
24
|
-
export
|
|
24
|
+
export interface HyperAppDecorator {
|
|
25
|
+
(options?: HyperAppMetadata): (target: Constructor) => Constructor;
|
|
26
|
+
}
|
|
25
27
|
export type HyperModuleMetadata = {
|
|
26
28
|
path: string;
|
|
27
29
|
name?: string;
|
package/dist/decorators/types.js
CHANGED
package/dist/extension.js
CHANGED
|
@@ -18,6 +18,9 @@ const requestMethods = {
|
|
|
18
18
|
setScopes(scopes) {
|
|
19
19
|
(0, helpers_1.setScopes)(this, scopes);
|
|
20
20
|
},
|
|
21
|
+
setFullScopes() {
|
|
22
|
+
(0, helpers_1.setScopes)(this, ["*"]);
|
|
23
|
+
},
|
|
21
24
|
hasScopes(scopes) {
|
|
22
25
|
return (0, helpers_1.hasScopes)(this, scopes);
|
|
23
26
|
},
|
|
@@ -25,8 +28,8 @@ const requestMethods = {
|
|
|
25
28
|
return (0, helpers_1.getScopes)(this);
|
|
26
29
|
},
|
|
27
30
|
setRoleScopes(role, scopes) {
|
|
28
|
-
|
|
29
|
-
|
|
31
|
+
(0, helpers_1.setRole)(this, role);
|
|
32
|
+
(0, helpers_1.setScopes)(this, scopes);
|
|
30
33
|
},
|
|
31
34
|
};
|
|
32
35
|
/////////////////////////////
|