@tsed/di 6.103.2 → 6.105.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.
@@ -12,16 +12,25 @@ const InjectablePropertyType_1 = require("../domain/InjectablePropertyType");
12
12
  * @decorator
13
13
  */
14
14
  function Intercept(interceptor, options) {
15
- return (target, propertyKey, descriptor) => {
16
- core_1.Store.from(target).merge(constants_1.INJECTABLE_PROP, {
17
- [propertyKey]: {
18
- bindingType: InjectablePropertyType_1.InjectablePropertyType.INTERCEPTOR,
19
- propertyKey,
20
- useType: interceptor,
21
- options
22
- }
23
- });
24
- return descriptor;
15
+ return (...args) => {
16
+ const type = (0, core_1.decoratorTypeOf)(args);
17
+ console.log("===", args);
18
+ switch (type) {
19
+ case core_1.DecoratorTypes.CLASS:
20
+ console.log("===");
21
+ (0, core_1.decorateMethodsOf)(args[0], Intercept(interceptor, options));
22
+ break;
23
+ case core_1.DecoratorTypes.METHOD:
24
+ core_1.Store.from(args[0]).merge(constants_1.INJECTABLE_PROP, {
25
+ [args[1]]: {
26
+ bindingType: InjectablePropertyType_1.InjectablePropertyType.INTERCEPTOR,
27
+ propertyKey: args[1],
28
+ useType: interceptor,
29
+ options
30
+ }
31
+ });
32
+ return args[2];
33
+ }
25
34
  };
26
35
  }
27
36
  exports.Intercept = Intercept;
@@ -1 +1 @@
1
- {"version":3,"file":"intercept.js","sourceRoot":"","sources":["../../../src/decorators/intercept.ts"],"names":[],"mappings":";;;AAAA,qCAAuC;AACvC,sDAAuD;AACvD,6EAAwE;AAIxE;;;;;;GAMG;AACH,SAAgB,SAAS,CAA+B,WAAoB,EAAE,OAAa;IACzF,OAAO,CAAC,MAAW,EAAE,WAAmB,EAAE,UAA8B,EAAE,EAAE;QAC1E,YAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,2BAAe,EAAE;YACxC,CAAC,WAAW,CAAC,EAAE;gBACb,WAAW,EAAE,+CAAsB,CAAC,WAAW;gBAC/C,WAAW;gBACX,OAAO,EAAE,WAAW;gBACpB,OAAO;aACR;SACsB,CAAC,CAAC;QAE3B,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC;AAbD,8BAaC","sourcesContent":["import {Store, Type} from \"@tsed/core\";\nimport {INJECTABLE_PROP} from \"../constants/constants\";\nimport {InjectablePropertyType} from \"../domain/InjectablePropertyType\";\nimport type {InterceptorMethods} from \"../interfaces/InterceptorMethods\";\nimport type {InjectableProperties} from \"../interfaces/InjectableProperties\";\n\n/**\n * Attaches interceptor to method call and executes the before and after methods\n *\n * @param interceptor\n * @param options\n * @decorator\n */\nexport function Intercept<T extends InterceptorMethods>(interceptor: Type<T>, options?: any): MethodDecorator {\n return (target: any, propertyKey: string, descriptor: PropertyDescriptor) => {\n Store.from(target).merge(INJECTABLE_PROP, {\n [propertyKey]: {\n bindingType: InjectablePropertyType.INTERCEPTOR,\n propertyKey,\n useType: interceptor,\n options\n }\n } as InjectableProperties);\n\n return descriptor;\n };\n}\n"]}
1
+ {"version":3,"file":"intercept.js","sourceRoot":"","sources":["../../../src/decorators/intercept.ts"],"names":[],"mappings":";;;AAAA,qCAAgH;AAChH,sDAAuD;AACvD,6EAAwE;AAIxE;;;;;;GAMG;AACH,SAAgB,SAAS,CAA+B,WAAoB,EAAE,OAAa;IACzF,OAAO,CAAC,GAAG,IAAyB,EAAE,EAAE;QACtC,MAAM,IAAI,GAAG,IAAA,sBAAe,EAAC,IAAI,CAAC,CAAC;QACnC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACzB,QAAQ,IAAI,EAAE;YACZ,KAAK,qBAAc,CAAC,KAAK;gBACvB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;gBACnB,IAAA,wBAAiB,EAAC,IAAI,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC;gBAC5D,MAAM;YACR,KAAK,qBAAc,CAAC,MAAM;gBACxB,YAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,2BAAe,EAAE;oBACzC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;wBACT,WAAW,EAAE,+CAAsB,CAAC,WAAW;wBAC/C,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC;wBACpB,OAAO,EAAE,WAAW;wBACpB,OAAO;qBACR;iBACsB,CAAC,CAAC;gBAE3B,OAAO,IAAI,CAAC,CAAC,CAAQ,CAAC;SACzB;IACH,CAAC,CAAC;AACJ,CAAC;AAtBD,8BAsBC","sourcesContent":["import {decorateMethodsOf, DecoratorParameters, decoratorTypeOf, DecoratorTypes, Store, Type} from \"@tsed/core\";\nimport {INJECTABLE_PROP} from \"../constants/constants\";\nimport {InjectablePropertyType} from \"../domain/InjectablePropertyType\";\nimport type {InterceptorMethods} from \"../interfaces/InterceptorMethods\";\nimport type {InjectableProperties} from \"../interfaces/InjectableProperties\";\n\n/**\n * Attaches interceptor to method call and executes the before and after methods\n *\n * @param interceptor\n * @param options\n * @decorator\n */\nexport function Intercept<T extends InterceptorMethods>(interceptor: Type<T>, options?: any): any {\n return (...args: DecoratorParameters) => {\n const type = decoratorTypeOf(args);\n console.log(\"===\", args);\n switch (type) {\n case DecoratorTypes.CLASS:\n console.log(\"===\");\n decorateMethodsOf(args[0], Intercept(interceptor, options));\n break;\n case DecoratorTypes.METHOD:\n Store.from(args[0]).merge(INJECTABLE_PROP, {\n [args[1]]: {\n bindingType: InjectablePropertyType.INTERCEPTOR,\n propertyKey: args[1],\n useType: interceptor,\n options\n }\n } as InjectableProperties);\n\n return args[2] as any;\n }\n };\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { Store } from "@tsed/core";
1
+ import { decorateMethodsOf, decoratorTypeOf, DecoratorTypes, Store } from "@tsed/core";
2
2
  import { INJECTABLE_PROP } from "../constants/constants.js";
3
3
  import { InjectablePropertyType } from "../domain/InjectablePropertyType.js";
4
4
  /**
@@ -9,16 +9,25 @@ import { InjectablePropertyType } from "../domain/InjectablePropertyType.js";
9
9
  * @decorator
10
10
  */
11
11
  export function Intercept(interceptor, options) {
12
- return (target, propertyKey, descriptor) => {
13
- Store.from(target).merge(INJECTABLE_PROP, {
14
- [propertyKey]: {
15
- bindingType: InjectablePropertyType.INTERCEPTOR,
16
- propertyKey,
17
- useType: interceptor,
18
- options
19
- }
20
- });
21
- return descriptor;
12
+ return (...args) => {
13
+ const type = decoratorTypeOf(args);
14
+ console.log("===", args);
15
+ switch (type) {
16
+ case DecoratorTypes.CLASS:
17
+ console.log("===");
18
+ decorateMethodsOf(args[0], Intercept(interceptor, options));
19
+ break;
20
+ case DecoratorTypes.METHOD:
21
+ Store.from(args[0]).merge(INJECTABLE_PROP, {
22
+ [args[1]]: {
23
+ bindingType: InjectablePropertyType.INTERCEPTOR,
24
+ propertyKey: args[1],
25
+ useType: interceptor,
26
+ options
27
+ }
28
+ });
29
+ return args[2];
30
+ }
22
31
  };
23
32
  }
24
33
  //# sourceMappingURL=intercept.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"intercept.js","sourceRoot":"","sources":["../../../src/decorators/intercept.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAO,MAAM,YAAY,CAAC;AACvC,OAAO,EAAC,eAAe,EAAC,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAC,sBAAsB,EAAC,MAAM,kCAAkC,CAAC;AAIxE;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAA+B,WAAoB,EAAE,OAAa;IACzF,OAAO,CAAC,MAAW,EAAE,WAAmB,EAAE,UAA8B,EAAE,EAAE;QAC1E,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,eAAe,EAAE;YACxC,CAAC,WAAW,CAAC,EAAE;gBACb,WAAW,EAAE,sBAAsB,CAAC,WAAW;gBAC/C,WAAW;gBACX,OAAO,EAAE,WAAW;gBACpB,OAAO;aACR;SACsB,CAAC,CAAC;QAE3B,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {Store, Type} from \"@tsed/core\";\nimport {INJECTABLE_PROP} from \"../constants/constants\";\nimport {InjectablePropertyType} from \"../domain/InjectablePropertyType\";\nimport type {InterceptorMethods} from \"../interfaces/InterceptorMethods\";\nimport type {InjectableProperties} from \"../interfaces/InjectableProperties\";\n\n/**\n * Attaches interceptor to method call and executes the before and after methods\n *\n * @param interceptor\n * @param options\n * @decorator\n */\nexport function Intercept<T extends InterceptorMethods>(interceptor: Type<T>, options?: any): MethodDecorator {\n return (target: any, propertyKey: string, descriptor: PropertyDescriptor) => {\n Store.from(target).merge(INJECTABLE_PROP, {\n [propertyKey]: {\n bindingType: InjectablePropertyType.INTERCEPTOR,\n propertyKey,\n useType: interceptor,\n options\n }\n } as InjectableProperties);\n\n return descriptor;\n };\n}\n"]}
1
+ {"version":3,"file":"intercept.js","sourceRoot":"","sources":["../../../src/decorators/intercept.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAuB,eAAe,EAAE,cAAc,EAAE,KAAK,EAAO,MAAM,YAAY,CAAC;AAChH,OAAO,EAAC,eAAe,EAAC,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAC,sBAAsB,EAAC,MAAM,kCAAkC,CAAC;AAIxE;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAA+B,WAAoB,EAAE,OAAa;IACzF,OAAO,CAAC,GAAG,IAAyB,EAAE,EAAE;QACtC,MAAM,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;QACnC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACzB,QAAQ,IAAI,EAAE;YACZ,KAAK,cAAc,CAAC,KAAK;gBACvB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;gBACnB,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC;gBAC5D,MAAM;YACR,KAAK,cAAc,CAAC,MAAM;gBACxB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,eAAe,EAAE;oBACzC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;wBACT,WAAW,EAAE,sBAAsB,CAAC,WAAW;wBAC/C,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC;wBACpB,OAAO,EAAE,WAAW;wBACpB,OAAO;qBACR;iBACsB,CAAC,CAAC;gBAE3B,OAAO,IAAI,CAAC,CAAC,CAAQ,CAAC;SACzB;IACH,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {decorateMethodsOf, DecoratorParameters, decoratorTypeOf, DecoratorTypes, Store, Type} from \"@tsed/core\";\nimport {INJECTABLE_PROP} from \"../constants/constants\";\nimport {InjectablePropertyType} from \"../domain/InjectablePropertyType\";\nimport type {InterceptorMethods} from \"../interfaces/InterceptorMethods\";\nimport type {InjectableProperties} from \"../interfaces/InjectableProperties\";\n\n/**\n * Attaches interceptor to method call and executes the before and after methods\n *\n * @param interceptor\n * @param options\n * @decorator\n */\nexport function Intercept<T extends InterceptorMethods>(interceptor: Type<T>, options?: any): any {\n return (...args: DecoratorParameters) => {\n const type = decoratorTypeOf(args);\n console.log(\"===\", args);\n switch (type) {\n case DecoratorTypes.CLASS:\n console.log(\"===\");\n decorateMethodsOf(args[0], Intercept(interceptor, options));\n break;\n case DecoratorTypes.METHOD:\n Store.from(args[0]).merge(INJECTABLE_PROP, {\n [args[1]]: {\n bindingType: InjectablePropertyType.INTERCEPTOR,\n propertyKey: args[1],\n useType: interceptor,\n options\n }\n } as InjectableProperties);\n\n return args[2] as any;\n }\n };\n}\n"]}
@@ -7,4 +7,4 @@ import type { InterceptorMethods } from "../interfaces/InterceptorMethods";
7
7
  * @param options
8
8
  * @decorator
9
9
  */
10
- export declare function Intercept<T extends InterceptorMethods>(interceptor: Type<T>, options?: any): MethodDecorator;
10
+ export declare function Intercept<T extends InterceptorMethods>(interceptor: Type<T>, options?: any): any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsed/di",
3
- "version": "6.103.2",
3
+ "version": "6.105.0",
4
4
  "description": "DI module for Ts.ED Framework",
5
5
  "private": false,
6
6
  "source": "./src/index.ts",
@@ -23,14 +23,14 @@
23
23
  "tslib": "2.2.0"
24
24
  },
25
25
  "devDependencies": {
26
- "@tsed/core": "6.103.2",
26
+ "@tsed/core": "6.105.0",
27
27
  "@tsed/logger": ">=6.1.0",
28
- "@tsed/schema": "6.103.2"
28
+ "@tsed/schema": "6.105.0"
29
29
  },
30
30
  "peerDependencies": {
31
- "@tsed/core": "^6.103.2",
31
+ "@tsed/core": "^6.105.0",
32
32
  "@tsed/logger": ">=6.1.0",
33
- "@tsed/schema": "^6.103.2"
33
+ "@tsed/schema": "^6.105.0"
34
34
  },
35
35
  "repository": "https://github.com/tsedio/tsed",
36
36
  "bugs": {