@zenofolio/hyper-decor 1.0.59 → 1.0.60
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/dist/__internals/creators/request.creator.d.ts +2 -3
- package/dist/__internals/creators/routes.creator.d.ts +1 -3
- package/dist/__internals/creators/routes.creator.js +1 -2
- package/dist/__internals/helpers/prepare.helper.js +4 -4
- package/dist/__internals/stores/metadata.store.d.ts +15 -0
- package/dist/__internals/stores/metadata.store.js +37 -0
- package/dist/decorators/File.d.ts +1 -1
- package/dist/decorators/HyperService.d.ts +14 -0
- package/dist/decorators/HyperService.js +27 -0
- package/dist/decorators/Middleware.d.ts +3 -3
- package/dist/decorators/Middleware.js +33 -19
- package/dist/decorators/Pass.d.ts +6 -3
- package/dist/decorators/Pass.js +6 -3
- package/dist/decorators/Role.js +5 -5
- package/dist/decorators/Scope.js +2 -2
- package/dist/decorators/index.d.ts +1 -1
- package/dist/decorators/index.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/stores/index.d.ts +1 -0
- package/dist/stores/index.js +17 -0
- package/dist/stores/scope.store.d.ts +14 -0
- package/dist/stores/scope.store.js +29 -0
- package/package.json +1 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import "reflect-metadata";
|
|
2
|
-
import { Request } from "hyper-express";
|
|
3
|
-
import { ByPassKeys } from "../stores/params.store";
|
|
2
|
+
import { Request } from "hyper-express/types";
|
|
4
3
|
import { ParameterResolver } from "../../decorators";
|
|
5
4
|
/**
|
|
6
5
|
* Creates a parameter decorator for handling request data.
|
|
@@ -9,4 +8,4 @@ import { ParameterResolver } from "../../decorators";
|
|
|
9
8
|
* @param {IParamsResolver} resolver - Resolver function to handle the parameter.
|
|
10
9
|
* @returns {ParameterDecorator} - The parameter decorator function.
|
|
11
10
|
*/
|
|
12
|
-
export default function createParamDecorator(key: keyof Request |
|
|
11
|
+
export default function createParamDecorator(key: keyof Request | "req" | "res", decoratorName: string, resolver: ParameterResolver): ParameterDecorator;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import "reflect-metadata";
|
|
2
|
-
import { Request, Response } from "hyper-express";
|
|
3
2
|
/**
|
|
4
3
|
* Helper function to create route decorators for HTTP methods.
|
|
5
4
|
*
|
|
6
5
|
* @param {string} method - The HTTP method (e.g., GET, POST).
|
|
7
|
-
* @param {(req: Request, res: Response) => any} [resolver] - Optional resolver for the route.
|
|
8
6
|
* @returns {(path?: string) => MethodDecorator} - A method decorator for defining routes.
|
|
9
7
|
*
|
|
10
8
|
*/
|
|
11
|
-
export default function createRouteDecorator<T extends any = undefined>(method: string
|
|
9
|
+
export default function createRouteDecorator<T extends any = undefined>(method: string): (path?: string, options?: T) => MethodDecorator & ClassDecorator;
|
|
@@ -8,11 +8,10 @@ const decorator_base_1 = require("../decorator-base");
|
|
|
8
8
|
* Helper function to create route decorators for HTTP methods.
|
|
9
9
|
*
|
|
10
10
|
* @param {string} method - The HTTP method (e.g., GET, POST).
|
|
11
|
-
* @param {(req: Request, res: Response) => any} [resolver] - Optional resolver for the route.
|
|
12
11
|
* @returns {(path?: string) => MethodDecorator} - A method decorator for defining routes.
|
|
13
12
|
*
|
|
14
13
|
*/
|
|
15
|
-
function createRouteDecorator(method
|
|
14
|
+
function createRouteDecorator(method) {
|
|
16
15
|
return (path = "/", options) => (0, decorator_base_1.DecoratorHelper)({
|
|
17
16
|
type: constants_1.KEY_TYPE_CONTROLLER,
|
|
18
17
|
key: constants_1.KEY_PARAMS_ROUTE,
|
|
@@ -14,7 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.prepareApplication = prepareApplication;
|
|
16
16
|
const hyper_express_1 = require("hyper-express");
|
|
17
|
-
const
|
|
17
|
+
const stores_1 = require("../../stores");
|
|
18
18
|
const role_transform_1 = __importDefault(require("../transform/role.transform"));
|
|
19
19
|
const scope_transfrom_1 = __importDefault(require("../transform/scope.transfrom"));
|
|
20
20
|
const object_util_1 = require("../utils/object.util");
|
|
@@ -84,7 +84,7 @@ function prepareApplication(options, Target, app, log) {
|
|
|
84
84
|
.join(", ")}`);
|
|
85
85
|
}
|
|
86
86
|
(0, scope_transfrom_1.default)(data.scopes, (middleware, scopes) => {
|
|
87
|
-
|
|
87
|
+
stores_1.ScopeStore.addAll(scopes);
|
|
88
88
|
app.use(middleware);
|
|
89
89
|
log("middleware", `${Target.name} with scopes: ${data.scopes.join(", ")}`);
|
|
90
90
|
});
|
|
@@ -139,7 +139,7 @@ function prepareTarget(_a) {
|
|
|
139
139
|
////////////////////////////////
|
|
140
140
|
_router.use(...middlewares);
|
|
141
141
|
(0, scope_transfrom_1.default)(scopes, (middleware, scopes) => {
|
|
142
|
-
|
|
142
|
+
stores_1.ScopeStore.addAll(scopes);
|
|
143
143
|
_router.use(middleware);
|
|
144
144
|
});
|
|
145
145
|
(0, role_transform_1.default)(roles, (middleware) => _router.use(middleware));
|
|
@@ -220,7 +220,7 @@ function prepareRoutes(_a) {
|
|
|
220
220
|
(0, role_transform_1.default)(metadata.roles, (middleware) => middlewares.push(middleware));
|
|
221
221
|
(0, scope_transfrom_1.default)(metadata.scopes, (middleware, scopes) => {
|
|
222
222
|
middlewares.push(middleware);
|
|
223
|
-
|
|
223
|
+
stores_1.ScopeStore.addAll(scopes);
|
|
224
224
|
});
|
|
225
225
|
log("routes", `${namespace}/${propertyKey} ${method.toUpperCase()} { ${path} }`);
|
|
226
226
|
if (!hasParams) {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
interface MetadataStoreOptions {
|
|
2
|
+
target: any;
|
|
3
|
+
propertyKey?: string | symbol;
|
|
4
|
+
descriptorOrIndex?: any;
|
|
5
|
+
}
|
|
6
|
+
declare class MetadatStore {
|
|
7
|
+
static define(key: string | symbol, value: any, { target, propertyKey }: MetadataStoreOptions): void;
|
|
8
|
+
static get<T>(key: string | symbol, { target, propertyKey }: MetadataStoreOptions, def: T): T;
|
|
9
|
+
static list<T extends any = any>(key: string | symbol, { target, propertyKey }: MetadataStoreOptions): {
|
|
10
|
+
has: () => boolean;
|
|
11
|
+
get: () => never[];
|
|
12
|
+
set: (...value: T[]) => void;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export default MetadatStore;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const object_util_1 = require("../utils/object.util");
|
|
4
|
+
class MetadatStore {
|
|
5
|
+
static define(key, value, { target, propertyKey }) {
|
|
6
|
+
if (target && typeof propertyKey === "string") {
|
|
7
|
+
Reflect.defineMetadata(key, value, Reflect.get(target, propertyKey));
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
Reflect.defineMetadata(key, value, (0, object_util_1.$constructor)(target));
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
static get(key, { target, propertyKey }, def) {
|
|
14
|
+
if (target && typeof propertyKey === "string") {
|
|
15
|
+
return Reflect.getMetadata(key, Reflect.get(target, propertyKey)) || def;
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
return Reflect.getMetadata(key, (0, object_util_1.$constructor)(target)) || def;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
static list(key, { target, propertyKey }) {
|
|
22
|
+
return {
|
|
23
|
+
has: () => {
|
|
24
|
+
return this.get(key, { target, propertyKey }, []).length > 0;
|
|
25
|
+
},
|
|
26
|
+
get: () => {
|
|
27
|
+
return this.get(key, { target, propertyKey }, []);
|
|
28
|
+
},
|
|
29
|
+
set: (...value) => {
|
|
30
|
+
const list = this.get(key, { target, propertyKey }, []);
|
|
31
|
+
list.push(...value);
|
|
32
|
+
this.define(key, list, { target, propertyKey });
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.default = MetadatStore;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Constructor } from "./types";
|
|
2
|
+
interface ServiceDecoratorOptions {
|
|
3
|
+
singleton?: boolean;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* HyperService decorator is used to register a class as a service in the tsyringe container.
|
|
7
|
+
*
|
|
8
|
+
* No matter where this decorator is applied, the class will be registered in the tsyringe container
|
|
9
|
+
* and included in the service store to be launched when the application starts.
|
|
10
|
+
*
|
|
11
|
+
* @param options.singleton - Whether to register as a singleton (default: true)
|
|
12
|
+
*/
|
|
13
|
+
export declare const HyperService: ({ singleton, }?: ServiceDecoratorOptions) => (target: Constructor) => void;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HyperService = void 0;
|
|
4
|
+
const tsyringe_1 = require("tsyringe");
|
|
5
|
+
const service_store_1 = require("../__internals/stores/service.store");
|
|
6
|
+
/**
|
|
7
|
+
* HyperService decorator is used to register a class as a service in the tsyringe container.
|
|
8
|
+
*
|
|
9
|
+
* No matter where this decorator is applied, the class will be registered in the tsyringe container
|
|
10
|
+
* and included in the service store to be launched when the application starts.
|
|
11
|
+
*
|
|
12
|
+
* @param options.singleton - Whether to register as a singleton (default: true)
|
|
13
|
+
*/
|
|
14
|
+
const HyperService = ({ singleton = true, } = {}) => {
|
|
15
|
+
return (target) => {
|
|
16
|
+
if (!tsyringe_1.container.isRegistered(target)) {
|
|
17
|
+
if (singleton) {
|
|
18
|
+
tsyringe_1.container.registerSingleton(target);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
tsyringe_1.container.register(target, { useClass: target });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
service_store_1.serviceStore.add(target);
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
exports.HyperService = HyperService;
|
|
@@ -9,11 +9,11 @@ export declare const Middleware: {
|
|
|
9
9
|
/**
|
|
10
10
|
* Exclude middleware from matching paths.
|
|
11
11
|
*
|
|
12
|
-
* @param
|
|
12
|
+
* @param expressions
|
|
13
13
|
* @param middleware
|
|
14
14
|
* @returns
|
|
15
15
|
*/
|
|
16
|
-
exclude(
|
|
16
|
+
exclude(expressions: RegExp | RegExp[], middleware: MiddlewareHandler): ClassDecorator & MethodDecorator;
|
|
17
17
|
/**
|
|
18
18
|
* Only run middleware on matching paths.
|
|
19
19
|
*
|
|
@@ -21,5 +21,5 @@ export declare const Middleware: {
|
|
|
21
21
|
* @param middleware
|
|
22
22
|
* @returns
|
|
23
23
|
*/
|
|
24
|
-
only(
|
|
24
|
+
only(expressions: RegExp | RegExp[], middleware: MiddlewareHandler): (Target: any, propertyKey?: any) => void;
|
|
25
25
|
};
|
|
@@ -6,12 +6,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.Middleware = void 0;
|
|
7
7
|
require("reflect-metadata");
|
|
8
8
|
const constants_1 = require("../__internals/constants");
|
|
9
|
-
const
|
|
9
|
+
const metadata_store_1 = __importDefault(require("../__internals/stores/metadata.store"));
|
|
10
10
|
/**
|
|
11
11
|
* Middleware decorator to attach middleware to controllers, modules, and routes.
|
|
12
12
|
*/
|
|
13
|
-
const Middleware = (...middleware) => (Target, propertyKey
|
|
14
|
-
|
|
13
|
+
const Middleware = (...middleware) => (Target, propertyKey) => {
|
|
14
|
+
metadata_store_1.default.define(constants_1.KEY_PARAMS_MIDDLEWARES, middleware, {
|
|
15
15
|
target: Target,
|
|
16
16
|
propertyKey,
|
|
17
17
|
});
|
|
@@ -20,19 +20,17 @@ exports.Middleware = Middleware;
|
|
|
20
20
|
/**
|
|
21
21
|
* Exclude middleware from matching paths.
|
|
22
22
|
*
|
|
23
|
-
* @param
|
|
23
|
+
* @param expressions
|
|
24
24
|
* @param middleware
|
|
25
25
|
* @returns
|
|
26
26
|
*/
|
|
27
|
-
exports.Middleware.exclude =
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
});
|
|
35
|
-
};
|
|
27
|
+
exports.Middleware.exclude =
|
|
28
|
+
(expressions, middleware) => (Target, propertyKey) => {
|
|
29
|
+
metadata_store_1.default.define(constants_1.KEY_PARAMS_MIDDLEWARES, buildHandler("exclude", expressions, middleware), {
|
|
30
|
+
target: Target,
|
|
31
|
+
propertyKey,
|
|
32
|
+
});
|
|
33
|
+
};
|
|
36
34
|
/**
|
|
37
35
|
* Only run middleware on matching paths.
|
|
38
36
|
*
|
|
@@ -40,12 +38,28 @@ exports.Middleware.exclude = (expresiosn, middleware) => {
|
|
|
40
38
|
* @param middleware
|
|
41
39
|
* @returns
|
|
42
40
|
*/
|
|
43
|
-
exports.Middleware.only =
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
41
|
+
exports.Middleware.only =
|
|
42
|
+
(expressions, middleware) => (Target, propertyKey) => {
|
|
43
|
+
metadata_store_1.default.define(constants_1.KEY_PARAMS_MIDDLEWARES, buildHandler("only", expressions, middleware), {
|
|
44
|
+
target: Target,
|
|
45
|
+
propertyKey,
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
*
|
|
50
|
+
* Helper function to build middleware handlers for "only" and "exclude" modes.
|
|
51
|
+
*
|
|
52
|
+
* @param mode
|
|
53
|
+
* @param expresions
|
|
54
|
+
* @returns
|
|
55
|
+
*/
|
|
56
|
+
const buildHandler = (mode, expressions, middleware) => {
|
|
57
|
+
const matchers = Array.isArray(expressions) ? expressions : [expressions];
|
|
58
|
+
return (req, res, next) => {
|
|
59
|
+
const matches = matchers.some((rx) => rx.test(req.path));
|
|
60
|
+
if ((mode === "only" && !matches) || (mode === "exclude" && matches)) {
|
|
48
61
|
return next();
|
|
62
|
+
}
|
|
49
63
|
return middleware(req, res, next);
|
|
50
|
-
}
|
|
64
|
+
};
|
|
51
65
|
};
|
|
@@ -3,10 +3,13 @@ interface PassOptions {
|
|
|
3
3
|
(req: Request, res: Response): boolean | Promise<boolean>;
|
|
4
4
|
}
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Pass decorator
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
8
|
+
* This decorator allows bypassing checks when the provided function returns `true`.
|
|
9
|
+
* It can be applied to classes or methods, but not to properties.
|
|
10
|
+
*
|
|
11
|
+
* @param options - A function that returns true to allow bypassing
|
|
12
|
+
* @returns A class or method decorator
|
|
10
13
|
*/
|
|
11
14
|
export declare const Pass: (options: PassOptions) => ClassDecorator & MethodDecorator;
|
|
12
15
|
export {};
|
package/dist/decorators/Pass.js
CHANGED
|
@@ -8,10 +8,13 @@ const who_helper_1 = __importDefault(require("../__internals/helpers/who.helper"
|
|
|
8
8
|
const NotPropertyException_1 = __importDefault(require("../exeptions/NotPropertyException"));
|
|
9
9
|
const constants_1 = require("../__internals/constants");
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* Pass decorator
|
|
12
12
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
13
|
+
* This decorator allows bypassing checks when the provided function returns `true`.
|
|
14
|
+
* It can be applied to classes or methods, but not to properties.
|
|
15
|
+
*
|
|
16
|
+
* @param options - A function that returns true to allow bypassing
|
|
17
|
+
* @returns A class or method decorator
|
|
15
18
|
*/
|
|
16
19
|
const Pass = (options) => (target, propertyKey, descriptorOrIndex) => {
|
|
17
20
|
const { isProperty, isMethod } = (0, who_helper_1.default)(target, propertyKey, descriptorOrIndex);
|
package/dist/decorators/Role.js
CHANGED
|
@@ -5,10 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Role = void 0;
|
|
7
7
|
require("reflect-metadata");
|
|
8
|
-
const constants_1 = require("../__internals/constants");
|
|
9
|
-
const who_helper_1 = __importDefault(require("../__internals/helpers/who.helper"));
|
|
10
|
-
const stores_1 = __importDefault(require("../__internals/stores"));
|
|
11
8
|
const exeptions_1 = require("../exeptions");
|
|
9
|
+
const who_helper_1 = __importDefault(require("../__internals/helpers/who.helper"));
|
|
10
|
+
const constants_1 = require("../__internals/constants");
|
|
11
|
+
const metadata_store_1 = __importDefault(require("../__internals/stores/metadata.store"));
|
|
12
12
|
/**
|
|
13
13
|
* Role decorator for setting role-based access control.
|
|
14
14
|
*/
|
|
@@ -21,11 +21,11 @@ const Role = (roles) => (target, propertyKey, descriptorOrIndex) => {
|
|
|
21
21
|
descriptorOrIndex,
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
|
-
const { isProperty
|
|
24
|
+
const { isProperty } = (0, who_helper_1.default)(target, propertyKey, descriptorOrIndex);
|
|
25
25
|
if (isProperty) {
|
|
26
26
|
throw new Error(`Scope decorator cannot be used as parameter decorator in ${target.constructor.name}.${propertyKey}`);
|
|
27
27
|
}
|
|
28
|
-
const list =
|
|
28
|
+
const list = metadata_store_1.default.list(constants_1.KEY_PARAMS_ROLE, {
|
|
29
29
|
target,
|
|
30
30
|
propertyKey,
|
|
31
31
|
});
|
package/dist/decorators/Scope.js
CHANGED
|
@@ -7,7 +7,7 @@ exports.Scope = void 0;
|
|
|
7
7
|
require("reflect-metadata");
|
|
8
8
|
const constants_1 = require("../__internals/constants");
|
|
9
9
|
const who_helper_1 = __importDefault(require("../__internals/helpers/who.helper"));
|
|
10
|
-
const
|
|
10
|
+
const metadata_store_1 = __importDefault(require("../__internals/stores/metadata.store"));
|
|
11
11
|
/**
|
|
12
12
|
* Scope decorator for defining access scopes.
|
|
13
13
|
*/
|
|
@@ -16,7 +16,7 @@ const Scope = (scopes) => (target, propertyKey, descriptorOrIndex) => {
|
|
|
16
16
|
if (isProperty) {
|
|
17
17
|
throw new Error(`Scope decorator cannot be used as parameter decorator in ${target.constructor.name}.${propertyKey}`);
|
|
18
18
|
}
|
|
19
|
-
const list =
|
|
19
|
+
const list = metadata_store_1.default.list(constants_1.KEY_PARAMS_SCOPE, {
|
|
20
20
|
target,
|
|
21
21
|
propertyKey,
|
|
22
22
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from "./HyperApp";
|
|
2
2
|
export * from "./HyperModule";
|
|
3
3
|
export * from "./HyperController";
|
|
4
|
+
export * from "./HyperService";
|
|
4
5
|
export * from "./Middleware";
|
|
5
6
|
export * from "./Scope";
|
|
6
7
|
export * from "./Role";
|
|
@@ -9,4 +10,3 @@ export * from "./types";
|
|
|
9
10
|
export * from "./Http";
|
|
10
11
|
export * from "./Pass";
|
|
11
12
|
export * from "./File";
|
|
12
|
-
export * from "./Service";
|
package/dist/decorators/index.js
CHANGED
|
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./HyperApp"), exports);
|
|
18
18
|
__exportStar(require("./HyperModule"), exports);
|
|
19
19
|
__exportStar(require("./HyperController"), exports);
|
|
20
|
+
__exportStar(require("./HyperService"), exports);
|
|
20
21
|
__exportStar(require("./Middleware"), exports);
|
|
21
22
|
__exportStar(require("./Scope"), exports);
|
|
22
23
|
__exportStar(require("./Role"), exports);
|
|
@@ -25,4 +26,3 @@ __exportStar(require("./types"), exports);
|
|
|
25
26
|
__exportStar(require("./Http"), exports);
|
|
26
27
|
__exportStar(require("./Pass"), exports);
|
|
27
28
|
__exportStar(require("./File"), exports);
|
|
28
|
-
__exportStar(require("./Service"), exports);
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -22,5 +22,5 @@ __exportStar(require("./common/helpers"), exports);
|
|
|
22
22
|
__exportStar(require("./common/bootstrap"), exports);
|
|
23
23
|
__exportStar(require("hyper-express"), exports);
|
|
24
24
|
__exportStar(require("tsyringe"), exports);
|
|
25
|
-
__exportStar(require("./
|
|
25
|
+
__exportStar(require("./stores"), exports);
|
|
26
26
|
__exportStar(require("./type"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./scope.store";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./scope.store"), exports);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ScopeMap } from "../decorators";
|
|
2
|
+
/**
|
|
3
|
+
* This class is a store for the scopes that are defined in the application.
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
export declare class ScopeStore {
|
|
7
|
+
private static scopes;
|
|
8
|
+
static add(scope: ScopeMap): void;
|
|
9
|
+
static addAll(scopes: ScopeMap[]): void;
|
|
10
|
+
static getScopes(): ScopeMap[];
|
|
11
|
+
static getScopeNames(): string[];
|
|
12
|
+
static isEmpty(): boolean;
|
|
13
|
+
static clear(): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ScopeStore = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* This class is a store for the scopes that are defined in the application.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
class ScopeStore {
|
|
9
|
+
static add(scope) {
|
|
10
|
+
this.scopes.set(scope.scope, scope); // Evita duplicados basados en el nombre del scope
|
|
11
|
+
}
|
|
12
|
+
static addAll(scopes) {
|
|
13
|
+
scopes.forEach((scope) => this.add(scope));
|
|
14
|
+
}
|
|
15
|
+
static getScopes() {
|
|
16
|
+
return Array.from(this.scopes.values());
|
|
17
|
+
}
|
|
18
|
+
static getScopeNames() {
|
|
19
|
+
return Array.from(this.scopes.keys());
|
|
20
|
+
}
|
|
21
|
+
static isEmpty() {
|
|
22
|
+
return this.scopes.size === 0;
|
|
23
|
+
}
|
|
24
|
+
static clear() {
|
|
25
|
+
this.scopes.clear();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.ScopeStore = ScopeStore;
|
|
29
|
+
ScopeStore.scopes = new Map();
|