@tsed/core 7.0.0-beta.9 → 7.0.0-rc.3

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.
Files changed (33) hide show
  1. package/coverage.json +6 -0
  2. package/jest.config.js +1 -6
  3. package/lib/cjs/domain/AnyToPromise.js +17 -19
  4. package/lib/cjs/domain/AnyToPromise.js.map +1 -1
  5. package/lib/cjs/domain/Hooks.js +22 -18
  6. package/lib/cjs/domain/Hooks.js.map +1 -1
  7. package/lib/cjs/domain/Metadata.js +5 -5
  8. package/lib/cjs/domain/Metadata.js.map +1 -1
  9. package/lib/cjs/domain/Store.js +1 -3
  10. package/lib/cjs/domain/Store.js.map +1 -1
  11. package/lib/cjs/errors/UnsupportedDecoratorType.js +1 -0
  12. package/lib/cjs/errors/UnsupportedDecoratorType.js.map +1 -1
  13. package/lib/cjs/utils/decorators/decorateMethodsOf.js +9 -4
  14. package/lib/cjs/utils/decorators/decorateMethodsOf.js.map +1 -1
  15. package/lib/cjs/utils/objects/descriptorOf.js +1 -2
  16. package/lib/cjs/utils/objects/descriptorOf.js.map +1 -1
  17. package/lib/esm/domain/AnyToPromise.js +17 -19
  18. package/lib/esm/domain/AnyToPromise.js.map +1 -1
  19. package/lib/esm/domain/Hooks.js +22 -18
  20. package/lib/esm/domain/Hooks.js.map +1 -1
  21. package/lib/esm/domain/Metadata.js +5 -5
  22. package/lib/esm/domain/Metadata.js.map +1 -1
  23. package/lib/esm/domain/Store.js +1 -3
  24. package/lib/esm/domain/Store.js.map +1 -1
  25. package/lib/esm/errors/UnsupportedDecoratorType.js +1 -0
  26. package/lib/esm/errors/UnsupportedDecoratorType.js.map +1 -1
  27. package/lib/esm/utils/decorators/decorateMethodsOf.js +9 -4
  28. package/lib/esm/utils/decorators/decorateMethodsOf.js.map +1 -1
  29. package/lib/esm/utils/objects/descriptorOf.js +1 -2
  30. package/lib/esm/utils/objects/descriptorOf.js.map +1 -1
  31. package/lib/types/domain/Hooks.d.ts +3 -2
  32. package/package.json +7 -4
  33. package/readme.md +3 -2
package/coverage.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "statements": 98.43,
3
+ "branches": 90.67,
4
+ "functions": 96.92,
5
+ "lines": 98.68
6
+ }
package/jest.config.js CHANGED
@@ -4,11 +4,6 @@
4
4
  module.exports = {
5
5
  ...require("@tsed/jest-config")(__dirname, "core"),
6
6
  coverageThreshold: {
7
- global: {
8
- statements: 97.95,
9
- branches: 89.59,
10
- functions: 96.04,
11
- lines: 98.17
12
- }
7
+ global: require("./coverage.json")
13
8
  }
14
9
  };
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
- var _AnyToPromise_resolves, _AnyToPromise_rejects, _AnyToPromise_hasNextFunction, _AnyToPromise_promise;
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.AnyToPromise = exports.AnyToPromiseResponseTypes = exports.AnyToPromiseStatus = void 0;
5
- const tslib_1 = require("tslib");
6
4
  const isObservable_1 = require("../utils/objects/isObservable");
7
5
  const isPromise_1 = require("../utils/objects/isPromise");
8
6
  const isStream_1 = require("../utils/objects/isStream");
@@ -29,23 +27,24 @@ var AnyToPromiseResponseTypes;
29
27
  AnyToPromiseResponseTypes["DATA"] = "DATA";
30
28
  })(AnyToPromiseResponseTypes = exports.AnyToPromiseResponseTypes || (exports.AnyToPromiseResponseTypes = {}));
31
29
  class AnyToPromise {
30
+ status = AnyToPromiseStatus.PENDING;
31
+ args;
32
+ #resolves;
33
+ #rejects;
34
+ #hasNextFunction = false;
35
+ #promise;
32
36
  constructor({ hasNextFunction = false } = {}) {
33
- this.status = AnyToPromiseStatus.PENDING;
34
- _AnyToPromise_resolves.set(this, void 0);
35
- _AnyToPromise_rejects.set(this, void 0);
36
- _AnyToPromise_hasNextFunction.set(this, false);
37
- _AnyToPromise_promise.set(this, void 0);
38
- tslib_1.__classPrivateFieldSet(this, _AnyToPromise_hasNextFunction, hasNextFunction, "f");
39
- tslib_1.__classPrivateFieldSet(this, _AnyToPromise_promise, new Promise((resolve, reject) => {
40
- tslib_1.__classPrivateFieldSet(this, _AnyToPromise_resolves, resolve, "f");
41
- tslib_1.__classPrivateFieldSet(this, _AnyToPromise_rejects, reject, "f");
42
- }), "f");
37
+ this.#hasNextFunction = hasNextFunction;
38
+ this.#promise = new Promise((resolve, reject) => {
39
+ this.#resolves = resolve;
40
+ this.#rejects = reject;
41
+ });
43
42
  }
44
43
  isDone() {
45
44
  return this.status !== AnyToPromiseStatus.PENDING;
46
45
  }
47
46
  get next() {
48
- tslib_1.__classPrivateFieldSet(this, _AnyToPromise_hasNextFunction, true, "f");
47
+ this.#hasNextFunction = true;
49
48
  return (error) => {
50
49
  if (this.isDone()) {
51
50
  return;
@@ -66,21 +65,21 @@ class AnyToPromise {
66
65
  catch (er) {
67
66
  this.reject(er);
68
67
  }
69
- return tslib_1.__classPrivateFieldGet(this, _AnyToPromise_promise, "f");
68
+ return this.#promise;
70
69
  }
71
70
  reject(er) {
72
71
  if (this.isDone()) {
73
72
  return;
74
73
  }
75
74
  this.done(AnyToPromiseStatus.REJECTED);
76
- tslib_1.__classPrivateFieldGet(this, _AnyToPromise_rejects, "f").call(this, er);
75
+ this.#rejects(er);
77
76
  }
78
77
  resolve(response = {}) {
79
78
  if (this.isDone()) {
80
79
  return;
81
80
  }
82
81
  this.done(AnyToPromiseStatus.RESOLVED);
83
- tslib_1.__classPrivateFieldGet(this, _AnyToPromise_resolves, "f").call(this, { ...response, state: AnyToPromiseStatus.RESOLVED });
82
+ this.#resolves({ ...response, state: AnyToPromiseStatus.RESOLVED });
84
83
  }
85
84
  destroy() { }
86
85
  cancel() {
@@ -88,7 +87,7 @@ class AnyToPromise {
88
87
  return;
89
88
  }
90
89
  this.done(AnyToPromiseStatus.CANCELED);
91
- return tslib_1.__classPrivateFieldGet(this, _AnyToPromise_resolves, "f").call(this, { state: AnyToPromiseStatus.CANCELED });
90
+ return this.#resolves({ state: AnyToPromiseStatus.CANCELED });
92
91
  }
93
92
  done(status) {
94
93
  this.destroy();
@@ -130,7 +129,7 @@ class AnyToPromise {
130
129
  });
131
130
  }
132
131
  }
133
- if (!tslib_1.__classPrivateFieldGet(this, _AnyToPromise_hasNextFunction, "f")) {
132
+ if (!this.#hasNextFunction) {
134
133
  // no next function and empty response
135
134
  return this.resolve({
136
135
  ...additionalProps,
@@ -144,5 +143,4 @@ class AnyToPromise {
144
143
  }
145
144
  }
146
145
  exports.AnyToPromise = AnyToPromise;
147
- _AnyToPromise_resolves = new WeakMap(), _AnyToPromise_rejects = new WeakMap(), _AnyToPromise_hasNextFunction = new WeakMap(), _AnyToPromise_promise = new WeakMap();
148
146
  //# sourceMappingURL=AnyToPromise.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AnyToPromise.js","sourceRoot":"","sources":["../../../src/domain/AnyToPromise.ts"],"names":[],"mappings":";;;;;AAAA,gEAA2D;AAC3D,0DAAqD;AACrD,wDAAmD;AAEnD;;GAEG;AACH,SAAS,UAAU,CAAC,GAAQ;IAC1B,OAAO,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,UAAU,CAAC;AACjE,CAAC;AAED;;GAEG;AACH,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC5B,yCAAmB,CAAA;IACnB,2CAAqB,CAAA;IACrB,2CAAqB,CAAA;IACrB,2CAAqB,CAAA;AACvB,CAAC,EALW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAK7B;AAED,IAAY,yBAIX;AAJD,WAAY,yBAAyB;IACnC,8CAAiB,CAAA;IACjB,8CAAiB,CAAA;IACjB,0CAAa,CAAA;AACf,CAAC,EAJW,yBAAyB,GAAzB,iCAAyB,KAAzB,iCAAyB,QAIpC;AAUD,MAAa,YAAY;IAUvB,YAAY,EAAC,eAAe,GAAG,KAAK,KAAiC,EAAE;QAThE,WAAM,GAAG,kBAAkB,CAAC,OAAO,CAAC;QAG3C,yCAAe;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kBAAkB,CAAC,QAAQ,CAAC;IACjD,CAAC;CACF;AAhJD,oCAgJC","sourcesContent":["import {isObservable} from \"../utils/objects/isObservable\";\nimport {isPromise} from \"../utils/objects/isPromise\";\nimport {isStream} from \"../utils/objects/isStream\";\n\n/**\n * @ignore\n */\nfunction isResponse(obj: any) {\n return obj.data && obj.headers && obj.status && obj.statusText;\n}\n\n/**\n * @ignore\n */\nexport enum AnyToPromiseStatus {\n PENDING = \"PENDING\",\n CANCELED = \"CANCELED\",\n RESOLVED = \"RESOLVED\",\n REJECTED = \"REJECTED\"\n}\n\nexport enum AnyToPromiseResponseTypes {\n STREAM = \"STREAM\",\n BUFFER = \"BUFFER\",\n DATA = \"DATA\"\n}\n\nexport interface AnyPromiseResult<T = any> {\n state: AnyToPromiseStatus;\n type: AnyToPromiseResponseTypes;\n status?: number;\n headers?: Record<string, any>;\n data: T;\n}\n\nexport class AnyToPromise<T = any> {\n public status = AnyToPromiseStatus.PENDING;\n public args: any[];\n\n #resolves: any;\n #rejects: any;\n #hasNextFunction = false;\n\n readonly #promise: Promise<AnyPromiseResult<T>>;\n\n constructor({hasNextFunction = false}: {hasNextFunction?: boolean} = {}) {\n this.#hasNextFunction = hasNextFunction;\n\n this.#promise = new Promise((resolve: any, reject: any) => {\n this.#resolves = resolve;\n this.#rejects = reject;\n });\n }\n\n isDone(): boolean {\n return this.status !== AnyToPromiseStatus.PENDING;\n }\n\n get next() {\n this.#hasNextFunction = true;\n\n return (error?: any) => {\n if (this.isDone()) {\n return;\n }\n\n return error ? this.reject(error) : this.resolve({type: AnyToPromiseResponseTypes.DATA});\n };\n }\n\n /**\n *\n */\n async call(cb: Function): Promise<AnyPromiseResult<T>> {\n if (this.isDone()) {\n return this as any;\n }\n\n try {\n this.handle(cb());\n } catch (er) {\n this.reject(er);\n }\n\n return this.#promise;\n }\n\n reject(er: any) {\n if (this.isDone()) {\n return;\n }\n\n this.done(AnyToPromiseStatus.REJECTED);\n\n this.#rejects(er);\n }\n\n resolve(response: any = {}) {\n if (this.isDone()) {\n return;\n }\n\n this.done(AnyToPromiseStatus.RESOLVED);\n\n this.#resolves({...response, state: AnyToPromiseStatus.RESOLVED});\n }\n\n destroy() {}\n\n cancel() {\n if (this.isDone()) {\n return;\n }\n\n this.done(AnyToPromiseStatus.CANCELED);\n\n return this.#resolves({state: AnyToPromiseStatus.CANCELED});\n }\n\n done(status: AnyToPromiseStatus) {\n this.destroy();\n this.status = status;\n }\n\n handle(process: any, additionalProps = {}): any {\n if (this.isDone()) {\n return;\n }\n\n if (process) {\n if (this.isCanceledResponse(process)) {\n // ABANDON\n return this.cancel();\n }\n\n if (isObservable(process)) {\n process = process.toPromise();\n }\n\n if (isResponse(process)) {\n return this.handle(process.data, {\n ...additionalProps,\n status: process.status,\n headers: process.headers\n });\n }\n\n if (isStream(process)) {\n return this.resolve({...additionalProps, type: AnyToPromiseResponseTypes.STREAM, data: process});\n }\n if (isStream(process) || Buffer.isBuffer(process)) {\n return this.resolve({...additionalProps, type: AnyToPromiseResponseTypes.BUFFER, data: process});\n }\n\n if (isPromise(process)) {\n return process\n .then((result: any) => this.handle(result, additionalProps))\n .catch((error: any) => {\n if (error.response && isResponse(error.response)) {\n return this.handle(error.response);\n }\n return this.reject(error);\n });\n }\n }\n\n if (!this.#hasNextFunction) {\n // no next function and empty response\n return this.resolve({\n ...additionalProps,\n data: process,\n type: AnyToPromiseResponseTypes.DATA\n });\n }\n }\n\n protected isCanceledResponse(process: any) {\n return process === AnyToPromiseStatus.CANCELED;\n }\n}\n"]}
1
+ {"version":3,"file":"AnyToPromise.js","sourceRoot":"","sources":["../../../src/domain/AnyToPromise.ts"],"names":[],"mappings":";;;AAAA,gEAA2D;AAC3D,0DAAqD;AACrD,wDAAmD;AAEnD;;GAEG;AACH,SAAS,UAAU,CAAC,GAAQ;IAC1B,OAAO,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,UAAU,CAAC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AC,QAAQ,IAAI,UAAU,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE;wBAChD,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;qBACpC;oBACD,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBAC5B,CAAC,CAAC,CAAC;aACN;SACF;QAED,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE;YAC1B,sCAAsC;YACtC,OAAO,IAAI,CAAC,OAAO,CAAC;gBAClB,GAAG,eAAe;gBAClB,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,yBAAyB,CAAC,IAAI;aACrC,CAAC,CAAC;SACJ;IACH,CAAC;IAES,kBAAkB,CAAC,OAAY;QACvC,OAAO,OAAO,KAAK,kBAAkB,CAAC,QAAQ,CAAC;IACjD,CAAC;CACF;AAhJD,oCAgJC","sourcesContent":["import {isObservable} from \"../utils/objects/isObservable\";\nimport {isPromise} from \"../utils/objects/isPromise\";\nimport {isStream} from \"../utils/objects/isStream\";\n\n/**\n * @ignore\n */\nfunction isResponse(obj: any) {\n return obj.data && obj.headers && obj.status && obj.statusText;\n}\n\n/**\n * @ignore\n */\nexport enum AnyToPromiseStatus {\n PENDING = \"PENDING\",\n CANCELED = \"CANCELED\",\n RESOLVED = \"RESOLVED\",\n REJECTED = \"REJECTED\"\n}\n\nexport enum AnyToPromiseResponseTypes {\n STREAM = \"STREAM\",\n BUFFER = \"BUFFER\",\n DATA = \"DATA\"\n}\n\nexport interface AnyPromiseResult<T = any> {\n state: AnyToPromiseStatus;\n type: AnyToPromiseResponseTypes;\n status?: number;\n headers?: Record<string, any>;\n data: T;\n}\n\nexport class AnyToPromise<T = any> {\n public status = AnyToPromiseStatus.PENDING;\n public args: any[];\n\n #resolves: any;\n #rejects: any;\n #hasNextFunction = false;\n\n readonly #promise: Promise<AnyPromiseResult<T>>;\n\n constructor({hasNextFunction = false}: {hasNextFunction?: boolean} = {}) {\n this.#hasNextFunction = hasNextFunction;\n\n this.#promise = new Promise((resolve: any, reject: any) => {\n this.#resolves = resolve;\n this.#rejects = reject;\n });\n }\n\n isDone(): boolean {\n return this.status !== AnyToPromiseStatus.PENDING;\n }\n\n get next() {\n this.#hasNextFunction = true;\n\n return (error?: any) => {\n if (this.isDone()) {\n return;\n }\n\n return error ? this.reject(error) : this.resolve({type: AnyToPromiseResponseTypes.DATA});\n };\n }\n\n /**\n *\n */\n async call(cb: Function): Promise<AnyPromiseResult<T>> {\n if (this.isDone()) {\n return this as any;\n }\n\n try {\n this.handle(cb());\n } catch (er) {\n this.reject(er);\n }\n\n return this.#promise;\n }\n\n reject(er: any) {\n if (this.isDone()) {\n return;\n }\n\n this.done(AnyToPromiseStatus.REJECTED);\n\n this.#rejects(er);\n }\n\n resolve(response: any = {}) {\n if (this.isDone()) {\n return;\n }\n\n this.done(AnyToPromiseStatus.RESOLVED);\n\n this.#resolves({...response, state: AnyToPromiseStatus.RESOLVED});\n }\n\n destroy() {}\n\n cancel() {\n if (this.isDone()) {\n return;\n }\n\n this.done(AnyToPromiseStatus.CANCELED);\n\n return this.#resolves({state: AnyToPromiseStatus.CANCELED});\n }\n\n done(status: AnyToPromiseStatus) {\n this.destroy();\n this.status = status;\n }\n\n handle(process: any, additionalProps = {}): any {\n if (this.isDone()) {\n return;\n }\n\n if (process) {\n if (this.isCanceledResponse(process)) {\n // ABANDON\n return this.cancel();\n }\n\n if (isObservable(process)) {\n process = process.toPromise();\n }\n\n if (isResponse(process)) {\n return this.handle(process.data, {\n ...additionalProps,\n status: process.status,\n headers: process.headers\n });\n }\n\n if (isStream(process)) {\n return this.resolve({...additionalProps, type: AnyToPromiseResponseTypes.STREAM, data: process});\n }\n if (isStream(process) || Buffer.isBuffer(process)) {\n return this.resolve({...additionalProps, type: AnyToPromiseResponseTypes.BUFFER, data: process});\n }\n\n if (isPromise(process)) {\n return process\n .then((result: any) => this.handle(result, additionalProps))\n .catch((error: any) => {\n if (error.response && isResponse(error.response)) {\n return this.handle(error.response);\n }\n return this.reject(error);\n });\n }\n }\n\n if (!this.#hasNextFunction) {\n // no next function and empty response\n return this.resolve({\n ...additionalProps,\n data: process,\n type: AnyToPromiseResponseTypes.DATA\n });\n }\n }\n\n protected isCanceledResponse(process: any) {\n return process === AnyToPromiseStatus.CANCELED;\n }\n}\n"]}
@@ -2,19 +2,17 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Hooks = void 0;
4
4
  class Hooks {
5
- constructor() {
6
- this.listeners = new Map();
7
- }
5
+ #listeners = {};
8
6
  /**
9
7
  * Listen a hook event
10
8
  * @param event
11
9
  * @param cb
12
10
  */
13
11
  on(event, cb) {
14
- if (!this.listeners.has(event)) {
15
- this.listeners.set(event, []);
12
+ if (!this.#listeners[event]) {
13
+ this.#listeners[event] = [];
16
14
  }
17
- this.listeners.get(event).push(cb);
15
+ this.#listeners[event].push(cb);
18
16
  return this;
19
17
  }
20
18
  /**
@@ -23,8 +21,8 @@ class Hooks {
23
21
  * @param cb
24
22
  */
25
23
  off(event, cb) {
26
- if (this.listeners.has(event)) {
27
- this.listeners.set(event, this.listeners.get(event).filter((item) => item === cb));
24
+ if (this.#listeners[event]) {
25
+ this.#listeners[event] = this.#listeners[event].filter((item) => item === cb);
28
26
  }
29
27
  return this;
30
28
  }
@@ -35,8 +33,9 @@ class Hooks {
35
33
  * @param callThis
36
34
  */
37
35
  emit(event, args = [], callThis = null) {
38
- if (this.listeners.has(event)) {
39
- for (const cb of this.listeners.get(event)) {
36
+ const listeners = this.#listeners[event];
37
+ if (listeners?.length) {
38
+ for (const cb of listeners) {
40
39
  cb.call(callThis, ...args);
41
40
  }
42
41
  }
@@ -49,8 +48,9 @@ class Hooks {
49
48
  * @param callThis
50
49
  */
51
50
  alter(event, value, args = [], callThis = null) {
52
- if (this.listeners.has(event)) {
53
- for (const cb of this.listeners.get(event)) {
51
+ const listeners = this.#listeners[event];
52
+ if (listeners?.length) {
53
+ for (const cb of listeners) {
54
54
  value = cb.call(callThis, value, ...args);
55
55
  }
56
56
  }
@@ -63,10 +63,10 @@ class Hooks {
63
63
  * @param callThis
64
64
  */
65
65
  async asyncEmit(event, args = [], callThis = null) {
66
- if (this.listeners.has(event)) {
67
- for (const cb of this.listeners.get(event)) {
68
- await cb.call(callThis, ...args);
69
- }
66
+ const listeners = this.#listeners[event];
67
+ if (listeners?.length) {
68
+ const promises = listeners.map((cb) => cb.call(callThis, ...args));
69
+ await Promise.all(promises);
70
70
  }
71
71
  }
72
72
  /**
@@ -77,13 +77,17 @@ class Hooks {
77
77
  * @param callThis
78
78
  */
79
79
  async asyncAlter(event, value, args = [], callThis = null) {
80
- if (this.listeners.has(event)) {
81
- for (const cb of this.listeners.get(event)) {
80
+ const listeners = this.#listeners[event];
81
+ if (listeners?.length) {
82
+ for (const cb of listeners) {
82
83
  value = await cb.call(callThis, value, ...args);
83
84
  }
84
85
  }
85
86
  return value;
86
87
  }
88
+ destroy() {
89
+ this.#listeners = {};
90
+ }
87
91
  }
88
92
  exports.Hooks = Hooks;
89
93
  //# sourceMappingURL=Hooks.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Hooks.js","sourceRoot":"","sources":["../../../src/domain/Hooks.ts"],"names":[],"mappings":";;;AAAA,MAAa,KAAK;IAAlB;QACU,cAAS,GAA4B,IAAI,GAAG,EAAE,CAAC;IA8FzD,CAAC;IA5FC;;;;OAIG;IACH,EAAE,CAAC,KAAa,EAAE,EAAY;QAC5B,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;YAC9B,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;SAC/B;QAED,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAEpC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;OAIG;IACH,GAAG,CAAC,KAAa,EAAE,EAAY;QAC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C3C,MAAM,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,CAAC;aAClC;SACF;IACH,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,UAAU,CAAC,KAAa,EAAE,KAAU,EAAE,OAAiB,EAAE,EAAE,WAAgB,IAAI;QACnF,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;YAC7B,KAAK,MAAM,EAAE,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAE,EAAE;gBAC3C,KAAK,GAAG,MAAM,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC;aACjD;SACF;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AA/FD,sBA+FC","sourcesContent":["export class Hooks {\n private listeners: Map<string, Function[]> = new Map();\n\n /**\n * Listen a hook event\n * @param event\n * @param cb\n */\n on(event: string, cb: Function) {\n if (!this.listeners.has(event)) {\n this.listeners.set(event, []);\n }\n\n this.listeners.get(event)!.push(cb);\n\n return this;\n }\n\n /**\n * Remove a listener attached to an event\n * @param event\n * @param cb\n */\n off(event: string, cb: Function) {\n if (this.listeners.has(event)) {\n this.listeners.set(\n event,\n this.listeners.get(event)!.filter((item) => item === cb)\n );\n }\n\n return this;\n }\n\n /**\n * Trigger an event and call listener.\n * @param event\n * @param args\n * @param callThis\n */\n emit(event: string, args: any[] = [], callThis: any = null): void {\n if (this.listeners.has(event)) {\n for (const cb of this.listeners.get(event)!) {\n cb.call(callThis, ...args);\n }\n }\n }\n\n /**\n * Trigger an event, listener alter given value and return it.\n * @param event\n * @param value\n * @param args\n * @param callThis\n */\n alter(event: string, value: any, args: any[] = [], callThis: any = null): any {\n if (this.listeners.has(event)) {\n for (const cb of this.listeners.get(event)!) {\n value = cb.call(callThis, value, ...args);\n }\n }\n\n return value;\n }\n\n /**\n * Trigger an event and call async listener.\n * @param event\n * @param args\n * @param callThis\n */\n async asyncEmit(event: string, args: any[] = [], callThis: any = null): Promise<void> {\n if (this.listeners.has(event)) {\n for (const cb of this.listeners.get(event)!) {\n await cb.call(callThis, ...args);\n }\n }\n }\n\n /**\n * Trigger an event, async listener alter given value and return it.\n * @param event\n * @param value\n * @param args\n * @param callThis\n */\n async asyncAlter(event: string, value: any, args: string[] = [], callThis: any = null): Promise<any> {\n if (this.listeners.has(event)) {\n for (const cb of this.listeners.get(event)!) {\n value = await cb.call(callThis, value, ...args);\n }\n }\n\n return value;\n }\n}\n"]}
1
+ {"version":3,"file":"Hooks.js","sourceRoot":"","sources":["../../../src/domain/Hooks.ts"],"names":[],"mappings":";;;AAAA,MAAa,KAAK;IAChB,UAAU,GAA+B,EAAE,CAAC;IAE5C;;;;OAIG;IACH,EAAE,CAAC,KAAa,EAAE,EAAY;QAC5B,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE;YAC3B,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;SAC7B;QAED,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAEhC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;OAIG;IACH,GAAG,CAAC,KAAa,EAAE,EAAY;QAC7B,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE;YAC1B,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC;SAC/E;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;OAKG;IACH,IAAI,CAAC,KAAa,EAAE,OAAc,EAAE,EAAE,WAAgB,IAAI;QACxD,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAEzC,IAAI,SAAS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CAAC,QAAQ,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC;aACjD;SACF;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO;QACL,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;IACvB,CAAC;CACF;AAxGD,sBAwGC","sourcesContent":["export class Hooks {\n #listeners: Record<string, Function[]> = {};\n\n /**\n * Listen a hook event\n * @param event\n * @param cb\n */\n on(event: string, cb: Function) {\n if (!this.#listeners[event]) {\n this.#listeners[event] = [];\n }\n\n this.#listeners[event].push(cb);\n\n return this;\n }\n\n /**\n * Remove a listener attached to an event\n * @param event\n * @param cb\n */\n off(event: string, cb: Function) {\n if (this.#listeners[event]) {\n this.#listeners[event] = this.#listeners[event].filter((item) => item === cb);\n }\n\n return this;\n }\n\n /**\n * Trigger an event and call listener.\n * @param event\n * @param args\n * @param callThis\n */\n emit(event: string, args: any[] = [], callThis: any = null): void {\n const listeners = this.#listeners[event];\n\n if (listeners?.length) {\n for (const cb of listeners) {\n cb.call(callThis, ...args);\n }\n }\n }\n\n /**\n * Trigger an event, listener alter given value and return it.\n * @param event\n * @param value\n * @param args\n * @param callThis\n */\n alter(event: string, value: any, args: any[] = [], callThis: any = null): any {\n const listeners = this.#listeners[event];\n\n if (listeners?.length) {\n for (const cb of listeners) {\n value = cb.call(callThis, value, ...args);\n }\n }\n\n return value;\n }\n\n /**\n * Trigger an event and call async listener.\n * @param event\n * @param args\n * @param callThis\n */\n async asyncEmit(event: string, args: any[] = [], callThis: any = null): Promise<void> {\n const listeners = this.#listeners[event];\n\n if (listeners?.length) {\n const promises = listeners.map((cb) => cb.call(callThis, ...args));\n\n await Promise.all(promises);\n }\n }\n\n /**\n * Trigger an event, async listener alter given value and return it.\n * @param event\n * @param value\n * @param args\n * @param callThis\n */\n async asyncAlter(event: string, value: any, args: any[] = [], callThis: any = null): Promise<any> {\n const listeners = this.#listeners[event];\n\n if (listeners?.length) {\n for (const cb of listeners) {\n value = await cb.call(callThis, value, ...args);\n }\n }\n\n return value;\n }\n\n destroy() {\n this.#listeners = {};\n }\n}\n"]}
@@ -387,6 +387,11 @@ class Metadata {
387
387
  static setParamTypes(target, propertyKey, value) {
388
388
  return this.set(DESIGN_PARAM_TYPES, value, target.prototype, propertyKey);
389
389
  }
390
+ /**
391
+ * Get all metadata for a metadataKey.
392
+ * @param metadataKey
393
+ */
394
+ static getTargetsFromPropertyKey = (metadataKey) => PROPERTIES.has(metadataKey) ? PROPERTIES.get(metadataKey) || [] : [];
390
395
  /**
391
396
  * Define a unique metadata entry on the target.
392
397
  * @param key A key used to store and retrieve metadata.
@@ -500,9 +505,4 @@ class Metadata {
500
505
  }
501
506
  }
502
507
  exports.Metadata = Metadata;
503
- /**
504
- * Get all metadata for a metadataKey.
505
- * @param metadataKey
506
- */
507
- Metadata.getTargetsFromPropertyKey = (metadataKey) => PROPERTIES.has(metadataKey) ? PROPERTIES.get(metadataKey) || [] : [];
508
508
  //# sourceMappingURL=Metadata.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Metadata.js","sourceRoot":"","sources":["../../../src/domain/Metadata.ts"],"names":[],"mappings":";;;AAAA,4BAA0B;AAC1B,sDAAiD;AAEjD;;;;GAIG;AACH,MAAM,kBAAkB,GAAG,mBAAmB,CAAC;AAC/C;;;;GAIG;AACH,MAAM,WAAW,GAAG,aAAa,CAAC;AAClC;;;;GAIG;AACH,MAAM,kBAAkB,GAAG,mBAAmB,CAAC;AAE/C;;;;GAIG;AACH,MAAM,UAAU,GAAgC,IAAI,GAAG,EAA0B,CAAC;AAElF;;GAEG;AACH,MAAa,QAAQ;IACnB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkCG;IACH,MAAM,CAAC,GAAG,CAAC,GAAW,EAAE,MAAW,EAAE,WAA6B;QAChE,OAAO,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,IAAA,iBAAO,EAAC,MAAM,CAAC,EAAE,WAAY,CAAC,CAAC;IACjE,CAAC;IAED;;;;;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O,CAAC,CAAC;SAC9B;QAED,OAAO,CAAC,cAAc,CAAC,GAAG,EAAE,KAAK,EAAE,IAAA,iBAAO,EAAC,MAAM,CAAC,EAAE,WAAY,CAAC,CAAC;IACpE,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,MAAM,CAAC,aAAa,CAAC,eAAoB,EAAE,WAA6B;QACtE,OAAO,OAAO,CAAC,WAAW,CAAC,kBAAkB,EAAE,eAAe,EAAE,WAAY,CAAC,IAAI,EAAE,CAAC;IACtF,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,MAAM,CAAC,gBAAgB,CAAC,MAAW,EAAE,WAA6B;QAChE,OAAO,OAAO,CAAC,cAAc,CAAC,kBAAkB,EAAE,MAAM,EAAE,WAAY,CAAC,IAAI,EAAE,CAAC;IAChF,CAAC;;AAxeH,4BAyeC;AA1HC;;;GAGG;AACI,kCAAyB,GAAG,CAAC,WAA4B,EAAS,EAAE,CACzE,UAAU,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC","sourcesContent":["import \"reflect-metadata\";\nimport {classOf} from \"../utils/objects/classOf\";\n\n/**\n * Metadata key\n * @private\n * @type {string}\n */\nconst DESIGN_PARAM_TYPES = \"design:paramtypes\";\n/**\n * Metadata key\n * @private\n * @type {string}\n */\nconst DESIGN_TYPE = \"design:type\";\n/**\n * Metadata key\n * @private\n * @type {string}\n */\nconst DESIGN_RETURN_TYPE = \"design:returntype\";\n\n/**\n * Properties collections\n * @private\n * @type {string}\n */\nconst PROPERTIES: Map<string | symbol, any[]> = new Map<string | symbol, any[]>();\n\n/**\n * @stable\n */\nexport class Metadata {\n /**\n * Gets the metadata value for the provided metadata key on the target object or its prototype chain.\n * @param key A key used to store and retrieve metadata.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey The property key for the target.\n * @returns The metadata value for the metadata key if found; otherwise, `undefined`.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Metadata.get(\"custom:annotation\", Example);\n *\n * // property (on constructor)\n * result = Metadata.get(\"custom:annotation\", Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Metadata.get(\"custom:annotation\", Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Metadata.get(\"custom:annotation\", Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Metadata.get(\"custom:annotation\", Example.prototype, \"method\");\n * ```\n *\n */\n static get(key: string, target: any, propertyKey?: string | symbol): any {\n return Reflect.getMetadata(key, classOf(target), propertyKey!);\n }\n\n /**\n * Gets the metadata value for the provided metadata key on the target object or its prototype chain.\n * @param key A key used to store and retrieve metadata.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey The property key for the target.\n * @returns The metadata value for the metadata key if found; otherwise, `undefined`.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Metadata.getOwn(\"custom:annotation\", Example);\n *\n * // property (on constructor)\n * result = Metadata.getOwn(\"custom:annotation\", Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Metadata.getOwn(\"custom:annotation\", Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Metadata.getOwn(\"custom:annotation\", Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Metadata.getOwn(\"custom:annotation\", Example.prototype, \"method\");\n * ```\n *\n */\n static getOwn(key: string, target: any, propertyKey?: string | symbol): any {\n return Reflect.getOwnMetadata(key, classOf(target), propertyKey!);\n }\n\n /**\n * Gets the metadata value for the provided metadata DESIGN_TYPE on the target object or its prototype chain.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey The property key for the target.\n * @returns The metadata value for the metadata key if found; otherwise, `undefined`.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // on contructor\n * result = Metadata.getType(Example);\n *\n * // property (on constructor)\n * result = Metadata.getType(Example, \"staticProperty\");\n *\n * // method (on constructor)\n * result = Metadata.getType(Example, \"staticMethod\");\n * ```\n *\n */\n static getType(target: any, propertyKey?: string | symbol): any {\n return Reflect.getMetadata(DESIGN_TYPE, target, propertyKey!);\n }\n\n /**\n * Gets the metadata value for the provided metadata DESIGN_TYPE on the target object or its prototype chain.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey The property key for the target.\n * @returns The metadata value for the metadata key if found; otherwise, `undefined`.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // on contructor\n * result = Metadata.getOwnType(Example);\n *\n * // property (on constructor)\n * result = Metadata.getOwnType(Example, \"staticProperty\");\n *\n * // method (on constructor)\n * result = Metadata.getOwnType(Example, \"staticMethod\");\n * ```\n *\n */\n static getOwnType(target: any, propertyKey?: string | symbol): any {\n return Reflect.getMetadata(DESIGN_TYPE, target, propertyKey!);\n }\n\n /**\n * Gets the metadata value for the provided metadata DESIGN_RETURN_TYPE on the target object or its prototype chain.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey The property key for the target.\n * @returns The metadata value for the metadata key if found; otherwise, `undefined`.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // on contructor\n * result = Metadata.getReturnType(Example);\n *\n * // property (on constructor)\n * result = Metadata.getReturnType(Example, \"staticProperty\");\n *\n * // method (on constructor)\n * result = Metadata.getReturnType(Example, \"staticMethod\");\n * ```\n *\n */\n static getReturnType(target: any, propertyKey?: string | symbol): any {\n return Reflect.getMetadata(DESIGN_RETURN_TYPE, target, propertyKey!);\n }\n\n /**\n * Gets the metadata value for the provided metadata DESIGN_RETURN_TYPE on the target object or its prototype chain.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey The property key for the target.\n * @returns The metadata value for the metadata key if found; otherwise, `undefined`.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // on contructor\n * result = Metadata.getOwnReturnType(Example);\n *\n * // property (on constructor)\n * result = Metadata.getOwnReturnType(Example, \"staticProperty\");\n *\n * // method (on constructor)\n * result = Metadata.getOwnReturnType(Example, \"staticMethod\");\n * ```\n *\n */\n static getOwnReturnType(target: any, propertyKey?: string | symbol): any {\n return Reflect.getOwnMetadata(DESIGN_RETURN_TYPE, target, propertyKey!);\n }\n\n /**\n * Gets a value indicating whether the target object or its prototype chain has the provided metadata key defined.\n * @param key A key used to store and retrieve metadata.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey The property key for the target.\n * @returns `true` if the metadata key was defined on the target object or its prototype chain; otherwise, `false`.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Metadata.has(\"custom:annotation\", Example);\n *\n * // property (on constructor)\n * result = Metadata.has(\"custom:annotation\", Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Metadata.has(\"custom:annotation\", Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Metadata.has(\"custom:annotation\", Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Metadata.has(\"custom:annotation\", Example.prototype, \"method\");\n * ```\n *\n */\n static has(key: string, target: any, propertyKey?: string | symbol): boolean {\n try {\n return Reflect.hasMetadata(key, classOf(target), propertyKey!);\n } catch (er) {}\n\n return false;\n }\n\n /**\n * Gets a value indicating whether the target object or its prototype chain has the provided metadata key defined.\n * @param key A key used to store and retrieve metadata.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey The property key for the target.\n * @returns `true` if the metadata key was defined on the target object or its prototype chain; otherwise, `false`.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Metadata.has(\"custom:annotation\", Example);\n *\n * // property (on constructor)\n * result = Metadata.hasOwn(\"custom:annotation\", Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Metadata.hasOwn(\"custom:annotation\", Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Metadata.hasOwn(\"custom:annotation\", Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Metadata.hasOwn(\"custom:annotation\", Example.prototype, \"method\");\n * ```\n *\n */\n static hasOwn(key: string, target: any, propertyKey?: string | symbol): boolean {\n return Reflect.hasOwnMetadata(key, classOf(target), propertyKey!);\n }\n\n /**\n * Deletes the metadata entry from the target object with the provided key.\n * @param key A key used to store and retrieve metadata.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey The property key for the target.\n * @returns `true` if the metadata entry was found and deleted; otherwise, false.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Metadata.delete(\"custom:annotation\", Example);\n *\n * // property (on constructor)\n * result = Metadata.delete(\"custom:annotation\", Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Metadata.delete(\"custom:annotation\", Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Metadata.delete(\"custom:annotation\", Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Metadata.delete(\"custom:annotation\", Example.prototype, \"method\");\n * ```\n *\n */\n static delete(key: string, target: any, propertyKey?: string | symbol): boolean {\n return Reflect.deleteMetadata(key, classOf(target), propertyKey!);\n }\n\n /**\n * Set the metadata value for the provided metadata DESIGN_PARAM_TYPES on the target object or its prototype chain.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey The property key for the target.\n * @param value A value that contains attached metadata.\n * @returns The metadata value for the metadata key if found; otherwise, `undefined`.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // on contructor\n * result = Metadata.setParamTypes(Example, undefined, [Object]);\n *\n * // property (on constructor)\n * result = Metadata.setParamTypes(Example, \"staticProperty\", [Object]);\n *\n * // property (on prototype)\n * result = Metadata.setParamTypes(Example.prototype, \"property\", [Object]);\n *\n * // method (on constructor)\n * result = Metadata.setParamTypes(Example, \"staticMethod\", [Object]);\n *\n * // method (on prototype)\n * result = Metadata.setParamTypes(Example.prototype, \"method\", [Object]);\n * ```\n *\n */\n static setParamTypes(target: any, propertyKey: string | symbol, value: any): void {\n return this.set(DESIGN_PARAM_TYPES, value, target.prototype, propertyKey);\n }\n\n /**\n * Get all metadata for a metadataKey.\n * @param metadataKey\n */\n static getTargetsFromPropertyKey = (metadataKey: string | symbol): any[] =>\n PROPERTIES.has(metadataKey) ? PROPERTIES.get(metadataKey) || [] : [];\n\n /**\n * Define a unique metadata entry on the target.\n * @param key A key used to store and retrieve metadata.\n * @param value A value that contains attached metadata.\n * @param target The target object on which to define metadata.\n * @param propertyKey The property key for the target.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * Reflect.defineMetadata(\"custom:annotation\", options, Example);\n *\n * // property (on constructor)\n * Reflect.defineMetadata(\"custom:annotation\", Number, Example, \"staticProperty\");\n *\n * // property (on prototype)\n * Reflect.defineMetadata(\"custom:annotation\", Number, Example.prototype, \"property\");\n *\n * // method (on constructor)\n * Reflect.defineMetadata(\"custom:annotation\", Number, Example, \"staticMethod\");\n *\n * // method (on prototype)\n * Reflect.defineMetadata(\"custom:annotation\", Number, Example.prototype, \"method\");\n *\n * // decorator factory as metadata-producing annotation.\n * function MyAnnotation(options): PropertyDecorator {\n * return (target, key) => Reflect.defineMetadata(\"custom:annotation\", options, target, key);\n * }\n * ```\n *\n */\n static set(key: string, value: any, target: any, propertyKey?: string | symbol): void {\n const targets: any[] = PROPERTIES.has(key) ? PROPERTIES.get(key) || [] : [];\n const classConstructor = classOf(target);\n\n if (targets.indexOf(classConstructor) === -1) {\n targets.push(classConstructor);\n PROPERTIES.set(key, targets);\n }\n\n Reflect.defineMetadata(key, value, classOf(target), propertyKey!);\n }\n\n /**\n * Gets the metadata value for the provided metadata DESIGN_PARAM_TYPES on the target object or its prototype chain.\n * @param targetPrototype\n * @param propertyKey The property key for the target.\n * @returns The metadata value for the metadata key if found; otherwise, `undefined`.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // on contructor\n * result = Metadata.getParamTypes(Example.prototype);\n *\n * // property (on constructor)\n * result = Metadata.getParamTypes(Example.prototype, \"staticProperty\");\n *\n * // method (on constructor)\n * result = Metadata.getParamTypes(Example.prototype, \"staticMethod\");\n * ```\n *\n */\n static getParamTypes(targetPrototype: any, propertyKey?: string | symbol): any[] {\n return Reflect.getMetadata(DESIGN_PARAM_TYPES, targetPrototype, propertyKey!) || [];\n }\n\n /**\n * Gets the metadata value for the provided metadata DESIGN_PARAM_TYPES on the target object or its prototype chain.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey The property key for the target.\n * @returns The metadata value for the metadata key if found; otherwise, `undefined`.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // on contructor\n * result = Metadata.getParamTypes(Example);\n *\n * // property (on constructor)\n * result = Metadata.getParamTypes(Example, \"staticProperty\");\n *\n * // method (on constructor)\n * result = Metadata.getParamTypes(Example, \"staticMethod\");\n * ```\n *\n */\n static getOwnParamTypes(target: any, propertyKey?: string | symbol): any[] {\n return Reflect.getOwnMetadata(DESIGN_PARAM_TYPES, target, propertyKey!) || [];\n }\n}\n"]}
1
+ {"version":3,"file":"Metadata.js","sourceRoot":"","sources":["../../../src/domain/Metadata.ts"],"names":[],"mappings":";;;AAAA,4BAA0B;AAC1B,sDAAiD;AAEjD;;;;GAIG;AACH,MAAM,kBAAkB,GAAG,mBAAmB,CAAC;AAC/C;;;;GAIG;AACH,MAAM,WAAW,GAAG,aAAa,CAAC;AAClC;;;;GAIG;AACH,MAAM,kBAAkB,GAAG,mBAAmB,CAAC;AAE/C;;;;GAIG;AACH,MAAM,UAAU,GAAgC,IAAI,GAAG,EAA0B,CAAC;AAElF;;GAEG;AACH,MAAa,QAAQ;IACnB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkCG;IACH,MAAM,CAAC,GAAG,CAAC,GAAW,EAAE,MAAW,EAAE,WAA6B;QAChE,OAAO,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,IAAA,iBAAO,EAAC,MAAM,CAAC,EAAE,WAAY,CAAC,CAAC;IACjE,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkCG;IACH,MAAM,CAAC,MAAM,CAAC,GAAW,EAAE,MAAW,EAAE,WAA6B;QACnE,OAAO,OAAO,CAAC,cAAc,CAAC,GAAG,EAAE,IAAA,iBAAO,EAAC,MAAM,CAAC,EAAE,WAAY,CAAC,CAAC;IACpE,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,CAAC,CAAC;SAC9B;QAED,OAAO,CAAC,cAAc,CAAC,GAAG,EAAE,KAAK,EAAE,IAAA,iBAAO,EAAC,MAAM,CAAC,EAAE,WAAY,CAAC,CAAC;IACpE,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,MAAM,CAAC,aAAa,CAAC,eAAoB,EAAE,WAA6B;QACtE,OAAO,OAAO,CAAC,WAAW,CAAC,kBAAkB,EAAE,eAAe,EAAE,WAAY,CAAC,IAAI,EAAE,CAAC;IACtF,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,MAAM,CAAC,gBAAgB,CAAC,MAAW,EAAE,WAA6B;QAChE,OAAO,OAAO,CAAC,cAAc,CAAC,kBAAkB,EAAE,MAAM,EAAE,WAAY,CAAC,IAAI,EAAE,CAAC;IAChF,CAAC;;AAxeH,4BAyeC","sourcesContent":["import \"reflect-metadata\";\nimport {classOf} from \"../utils/objects/classOf\";\n\n/**\n * Metadata key\n * @private\n * @type {string}\n */\nconst DESIGN_PARAM_TYPES = \"design:paramtypes\";\n/**\n * Metadata key\n * @private\n * @type {string}\n */\nconst DESIGN_TYPE = \"design:type\";\n/**\n * Metadata key\n * @private\n * @type {string}\n */\nconst DESIGN_RETURN_TYPE = \"design:returntype\";\n\n/**\n * Properties collections\n * @private\n * @type {string}\n */\nconst PROPERTIES: Map<string | symbol, any[]> = new Map<string | symbol, any[]>();\n\n/**\n * @stable\n */\nexport class Metadata {\n /**\n * Gets the metadata value for the provided metadata key on the target object or its prototype chain.\n * @param key A key used to store and retrieve metadata.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey The property key for the target.\n * @returns The metadata value for the metadata key if found; otherwise, `undefined`.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Metadata.get(\"custom:annotation\", Example);\n *\n * // property (on constructor)\n * result = Metadata.get(\"custom:annotation\", Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Metadata.get(\"custom:annotation\", Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Metadata.get(\"custom:annotation\", Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Metadata.get(\"custom:annotation\", Example.prototype, \"method\");\n * ```\n *\n */\n static get(key: string, target: any, propertyKey?: string | symbol): any {\n return Reflect.getMetadata(key, classOf(target), propertyKey!);\n }\n\n /**\n * Gets the metadata value for the provided metadata key on the target object or its prototype chain.\n * @param key A key used to store and retrieve metadata.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey The property key for the target.\n * @returns The metadata value for the metadata key if found; otherwise, `undefined`.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Metadata.getOwn(\"custom:annotation\", Example);\n *\n * // property (on constructor)\n * result = Metadata.getOwn(\"custom:annotation\", Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Metadata.getOwn(\"custom:annotation\", Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Metadata.getOwn(\"custom:annotation\", Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Metadata.getOwn(\"custom:annotation\", Example.prototype, \"method\");\n * ```\n *\n */\n static getOwn(key: string, target: any, propertyKey?: string | symbol): any {\n return Reflect.getOwnMetadata(key, classOf(target), propertyKey!);\n }\n\n /**\n * Gets the metadata value for the provided metadata DESIGN_TYPE on the target object or its prototype chain.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey The property key for the target.\n * @returns The metadata value for the metadata key if found; otherwise, `undefined`.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // on contructor\n * result = Metadata.getType(Example);\n *\n * // property (on constructor)\n * result = Metadata.getType(Example, \"staticProperty\");\n *\n * // method (on constructor)\n * result = Metadata.getType(Example, \"staticMethod\");\n * ```\n *\n */\n static getType(target: any, propertyKey?: string | symbol): any {\n return Reflect.getMetadata(DESIGN_TYPE, target, propertyKey!);\n }\n\n /**\n * Gets the metadata value for the provided metadata DESIGN_TYPE on the target object or its prototype chain.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey The property key for the target.\n * @returns The metadata value for the metadata key if found; otherwise, `undefined`.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // on contructor\n * result = Metadata.getOwnType(Example);\n *\n * // property (on constructor)\n * result = Metadata.getOwnType(Example, \"staticProperty\");\n *\n * // method (on constructor)\n * result = Metadata.getOwnType(Example, \"staticMethod\");\n * ```\n *\n */\n static getOwnType(target: any, propertyKey?: string | symbol): any {\n return Reflect.getMetadata(DESIGN_TYPE, target, propertyKey!);\n }\n\n /**\n * Gets the metadata value for the provided metadata DESIGN_RETURN_TYPE on the target object or its prototype chain.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey The property key for the target.\n * @returns The metadata value for the metadata key if found; otherwise, `undefined`.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // on contructor\n * result = Metadata.getReturnType(Example);\n *\n * // property (on constructor)\n * result = Metadata.getReturnType(Example, \"staticProperty\");\n *\n * // method (on constructor)\n * result = Metadata.getReturnType(Example, \"staticMethod\");\n * ```\n *\n */\n static getReturnType(target: any, propertyKey?: string | symbol): any {\n return Reflect.getMetadata(DESIGN_RETURN_TYPE, target, propertyKey!);\n }\n\n /**\n * Gets the metadata value for the provided metadata DESIGN_RETURN_TYPE on the target object or its prototype chain.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey The property key for the target.\n * @returns The metadata value for the metadata key if found; otherwise, `undefined`.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // on contructor\n * result = Metadata.getOwnReturnType(Example);\n *\n * // property (on constructor)\n * result = Metadata.getOwnReturnType(Example, \"staticProperty\");\n *\n * // method (on constructor)\n * result = Metadata.getOwnReturnType(Example, \"staticMethod\");\n * ```\n *\n */\n static getOwnReturnType(target: any, propertyKey?: string | symbol): any {\n return Reflect.getOwnMetadata(DESIGN_RETURN_TYPE, target, propertyKey!);\n }\n\n /**\n * Gets a value indicating whether the target object or its prototype chain has the provided metadata key defined.\n * @param key A key used to store and retrieve metadata.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey The property key for the target.\n * @returns `true` if the metadata key was defined on the target object or its prototype chain; otherwise, `false`.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Metadata.has(\"custom:annotation\", Example);\n *\n * // property (on constructor)\n * result = Metadata.has(\"custom:annotation\", Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Metadata.has(\"custom:annotation\", Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Metadata.has(\"custom:annotation\", Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Metadata.has(\"custom:annotation\", Example.prototype, \"method\");\n * ```\n *\n */\n static has(key: string, target: any, propertyKey?: string | symbol): boolean {\n try {\n return Reflect.hasMetadata(key, classOf(target), propertyKey!);\n } catch (er) {}\n\n return false;\n }\n\n /**\n * Gets a value indicating whether the target object or its prototype chain has the provided metadata key defined.\n * @param key A key used to store and retrieve metadata.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey The property key for the target.\n * @returns `true` if the metadata key was defined on the target object or its prototype chain; otherwise, `false`.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Metadata.has(\"custom:annotation\", Example);\n *\n * // property (on constructor)\n * result = Metadata.hasOwn(\"custom:annotation\", Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Metadata.hasOwn(\"custom:annotation\", Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Metadata.hasOwn(\"custom:annotation\", Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Metadata.hasOwn(\"custom:annotation\", Example.prototype, \"method\");\n * ```\n *\n */\n static hasOwn(key: string, target: any, propertyKey?: string | symbol): boolean {\n return Reflect.hasOwnMetadata(key, classOf(target), propertyKey!);\n }\n\n /**\n * Deletes the metadata entry from the target object with the provided key.\n * @param key A key used to store and retrieve metadata.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey The property key for the target.\n * @returns `true` if the metadata entry was found and deleted; otherwise, false.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Metadata.delete(\"custom:annotation\", Example);\n *\n * // property (on constructor)\n * result = Metadata.delete(\"custom:annotation\", Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Metadata.delete(\"custom:annotation\", Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Metadata.delete(\"custom:annotation\", Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Metadata.delete(\"custom:annotation\", Example.prototype, \"method\");\n * ```\n *\n */\n static delete(key: string, target: any, propertyKey?: string | symbol): boolean {\n return Reflect.deleteMetadata(key, classOf(target), propertyKey!);\n }\n\n /**\n * Set the metadata value for the provided metadata DESIGN_PARAM_TYPES on the target object or its prototype chain.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey The property key for the target.\n * @param value A value that contains attached metadata.\n * @returns The metadata value for the metadata key if found; otherwise, `undefined`.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // on contructor\n * result = Metadata.setParamTypes(Example, undefined, [Object]);\n *\n * // property (on constructor)\n * result = Metadata.setParamTypes(Example, \"staticProperty\", [Object]);\n *\n * // property (on prototype)\n * result = Metadata.setParamTypes(Example.prototype, \"property\", [Object]);\n *\n * // method (on constructor)\n * result = Metadata.setParamTypes(Example, \"staticMethod\", [Object]);\n *\n * // method (on prototype)\n * result = Metadata.setParamTypes(Example.prototype, \"method\", [Object]);\n * ```\n *\n */\n static setParamTypes(target: any, propertyKey: string | symbol, value: any): void {\n return this.set(DESIGN_PARAM_TYPES, value, target.prototype, propertyKey);\n }\n\n /**\n * Get all metadata for a metadataKey.\n * @param metadataKey\n */\n static getTargetsFromPropertyKey = (metadataKey: string | symbol): any[] =>\n PROPERTIES.has(metadataKey) ? PROPERTIES.get(metadataKey) || [] : [];\n\n /**\n * Define a unique metadata entry on the target.\n * @param key A key used to store and retrieve metadata.\n * @param value A value that contains attached metadata.\n * @param target The target object on which to define metadata.\n * @param propertyKey The property key for the target.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * Reflect.defineMetadata(\"custom:annotation\", options, Example);\n *\n * // property (on constructor)\n * Reflect.defineMetadata(\"custom:annotation\", Number, Example, \"staticProperty\");\n *\n * // property (on prototype)\n * Reflect.defineMetadata(\"custom:annotation\", Number, Example.prototype, \"property\");\n *\n * // method (on constructor)\n * Reflect.defineMetadata(\"custom:annotation\", Number, Example, \"staticMethod\");\n *\n * // method (on prototype)\n * Reflect.defineMetadata(\"custom:annotation\", Number, Example.prototype, \"method\");\n *\n * // decorator factory as metadata-producing annotation.\n * function MyAnnotation(options): PropertyDecorator {\n * return (target, key) => Reflect.defineMetadata(\"custom:annotation\", options, target, key);\n * }\n * ```\n *\n */\n static set(key: string, value: any, target: any, propertyKey?: string | symbol): void {\n const targets: any[] = PROPERTIES.has(key) ? PROPERTIES.get(key) || [] : [];\n const classConstructor = classOf(target);\n\n if (targets.indexOf(classConstructor) === -1) {\n targets.push(classConstructor);\n PROPERTIES.set(key, targets);\n }\n\n Reflect.defineMetadata(key, value, classOf(target), propertyKey!);\n }\n\n /**\n * Gets the metadata value for the provided metadata DESIGN_PARAM_TYPES on the target object or its prototype chain.\n * @param targetPrototype\n * @param propertyKey The property key for the target.\n * @returns The metadata value for the metadata key if found; otherwise, `undefined`.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // on contructor\n * result = Metadata.getParamTypes(Example.prototype);\n *\n * // property (on constructor)\n * result = Metadata.getParamTypes(Example.prototype, \"staticProperty\");\n *\n * // method (on constructor)\n * result = Metadata.getParamTypes(Example.prototype, \"staticMethod\");\n * ```\n *\n */\n static getParamTypes(targetPrototype: any, propertyKey?: string | symbol): any[] {\n return Reflect.getMetadata(DESIGN_PARAM_TYPES, targetPrototype, propertyKey!) || [];\n }\n\n /**\n * Gets the metadata value for the provided metadata DESIGN_PARAM_TYPES on the target object or its prototype chain.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey The property key for the target.\n * @returns The metadata value for the metadata key if found; otherwise, `undefined`.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // on contructor\n * result = Metadata.getParamTypes(Example);\n *\n * // property (on constructor)\n * result = Metadata.getParamTypes(Example, \"staticProperty\");\n *\n * // method (on constructor)\n * result = Metadata.getParamTypes(Example, \"staticMethod\");\n * ```\n *\n */\n static getOwnParamTypes(target: any, propertyKey?: string | symbol): any[] {\n return Reflect.getOwnMetadata(DESIGN_PARAM_TYPES, target, propertyKey!) || [];\n }\n}\n"]}
@@ -63,9 +63,7 @@ function defineStore(args) {
63
63
  }
64
64
  }
65
65
  class Store {
66
- constructor() {
67
- this._entries = new Map();
68
- }
66
+ _entries = new Map();
69
67
  /**
70
68
  * Create or get a Store from args {target + methodName + descriptor}
71
69
  * @param args
@@ -1 +1 @@
1
- {"version":3,"file":"Store.js","sourceRoot":"","sources":["../../../src/domain/Store.ts"],"names":[],"mappings":";;;AAAA,6DAAwD;AACxD,yEAAoE;AACpE,0DAAqD;AACrD,0DAAqD;AACrD,gEAA2D;AAC3D,wDAAmD;AACnD,oDAA+C;AAC/C,yCAAoC;AAGpC;;GAEG;AACU,QAAA,WAAW,GAAG,kBAAkB,CAAC;AAC9C;;GAEG;AACU,QAAA,YAAY,GAAG,mBAAmB,CAAC;AAChD;;GAEG;AACU,QAAA,cAAc,GAAG,qBAAqB,CAAC;AACpD;;GAEG;AACU,QAAA,WAAW,GAAG,kBAAkB,CAAC;AAE9C,MAAM,MAAM,GAAG,IAAI,GAAG,EAAiB,CAAC;AAExC,SAAS,QAAQ,CAAC,GAAW,EAAE,GAAG,IAAW;IAC3C,IAAI,IAAA,mBAAQ,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;QACrB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;YACxB,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,KAAK,EAAE,CAAC,CAAC;SAClC;QAED,OAAO,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAE,CAAC;KAC7B;SAAM;QACL,MAAM,QAAQ,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BAuGC","sourcesContent":["import {DecoratorTypes} from \"../domain/DecoratorTypes\";\nimport {decoratorTypeOf} from \"../utils/decorators/decoratorTypeOf\";\nimport {deepClone} from \"../utils/objects/deepClone\";\nimport {deepMerge} from \"../utils/objects/deepMerge\";\nimport {descriptorOf} from \"../utils/objects/descriptorOf\";\nimport {isSymbol} from \"../utils/objects/isSymbol\";\nimport {nameOf} from \"../utils/objects/nameOf\";\nimport {Metadata} from \"./Metadata\";\nimport type {Type} from \"./Type\";\n\n/**\n * @ignore\n */\nexport const CLASS_STORE = \"tsed:class:store\";\n/**\n * @ignore\n */\nexport const METHOD_STORE = \"tsed:method:store\";\n/**\n * @ignore\n */\nexport const PROPERTY_STORE = \"tsed:property:store\";\n/**\n * @ignore\n */\nexport const PARAM_STORE = \"tsed:param:store\";\n\nconst stores = new Map<symbol, Store>();\n\nfunction storeGet(key: string, ...args: any[]): Store {\n if (isSymbol(args[0])) {\n if (!stores.has(args[0])) {\n stores.set(args[0], new Store());\n }\n\n return stores.get(args[0])!;\n } else {\n const registry = Metadata as any;\n\n if (!registry.hasOwn(key, ...args)) {\n registry.set(key, new Store(), ...args);\n }\n\n return registry.getOwn(key, ...args);\n }\n}\n\nfunction defineStore(args: any[]): Store {\n const [target, propertyKey, descriptor] = args;\n\n switch (decoratorTypeOf(args)) {\n case DecoratorTypes.PARAM_CTOR:\n case DecoratorTypes.PARAM_STC:\n case DecoratorTypes.PARAM:\n const store = storeGet(PARAM_STORE, target, propertyKey);\n if (!store.has(\"\" + descriptor)) {\n store.set(\"\" + descriptor, new Store());\n }\n\n return store.get(\"\" + descriptor);\n case DecoratorTypes.PROP:\n case DecoratorTypes.PROP_STC:\n return storeGet(PROPERTY_STORE, target, propertyKey);\n case DecoratorTypes.METHOD:\n case DecoratorTypes.METHOD_STC:\n return storeGet(METHOD_STORE, target, propertyKey);\n case DecoratorTypes.CLASS:\n return storeGet(CLASS_STORE, target);\n }\n}\n\nexport class Store {\n private _entries = new Map<string, any>();\n /**\n * Create or get a Store from args {target + methodName + descriptor}\n * @param args\n * @returns {Store}\n */\n static from(...args: any[]): Store {\n return defineStore(args);\n }\n\n /**\n * Create store on the method.\n * @param target\n * @param {string} propertyKey\n * @returns {Store}\n */\n static fromMethod(target: any, propertyKey: string | symbol): Store {\n return Store.from(target, propertyKey, descriptorOf(target, propertyKey));\n }\n\n static mergeStoreFrom(target: Type<any>, source: Type<any>, ...args: any[]) {\n const store = Store.from(target, ...args);\n\n Store.from(source, ...args)._entries.forEach((value, key) => {\n store.merge(key, value);\n });\n\n return store;\n }\n\n static mergeStoreMethodFrom(target: Type<any>, source: Type<any>, propertyKey: string | symbol) {\n return this.mergeStoreFrom(target, source, propertyKey, descriptorOf(target, propertyKey));\n }\n\n /**\n * The get() method returns a specified element from a Map object.\n * @param key Required. The key of the element to return from the Map object.\n * @param defaultValue\n * @returns {T} Returns the element associated with the specified key or undefined if the key can't be found in the Map object.\n */\n get<T = any>(key: any, defaultValue?: any): T {\n return this._entries.get(nameOf(key)) || defaultValue;\n }\n\n /**\n * The has() method returns a boolean indicating whether an element with the specified key exists or not.\n * @param key\n * @returns {boolean}\n */\n has(key: any): boolean {\n return this._entries.has(nameOf(key));\n }\n\n /**\n * The set() method adds or updates an element with a specified key and value to a Map object.\n * @param key Required. The key of the element to add to the Map object.\n * @param metadata Required. The value of the element to add to the Map object.\n */\n set(key: any, metadata: any): Store {\n this._entries.set(nameOf(key), metadata);\n\n return this;\n }\n\n /**\n * The delete() method removes the specified element from a Map object.\n * @param key Required. The key of the element to remove from the Map object.\n * @returns {boolean} Returns true if an element in the Map object existed and has been removed, or false if the element does not exist.\n */\n delete(key: string): boolean {\n return this._entries.delete(nameOf(key));\n }\n\n /**\n * Merge given value with existing value.\n * @param key\n * @param value\n * @param inverse Change the merge order. Get the existing value and apply over given value\n * @returns {Store}\n */\n merge(key: any, value: any, inverse: boolean = false): Store {\n let _value_ = this.get(key);\n\n if (_value_) {\n value = deepClone(value);\n _value_ = deepClone(_value_);\n value = inverse ? deepMerge(value, _value_) : deepMerge(_value_, value);\n }\n\n this.set(key, value);\n\n return this;\n }\n\n toJson() {\n return [...this._entries.entries()].reduce((obj, [key, value]) => {\n return {\n ...obj,\n [key]: value\n };\n }, {});\n }\n}\n"]}
1
+ {"version":3,"file":"Store.js","sourceRoot":"","sources":["../../../src/domain/Store.ts"],"names":[],"mappings":";;;AAAA,6DAAwD;AACxD,yEAAoE;AACpE,0DAAqD;AACrD,0DAAqD;AACrD,gEAA2D;AAC3D,wDAAmD;AACnD,oDAA+C;AAC/C,yCAAoC;AAGpC;;GAEG;AACU,QAAA,WAAW,GAAG,kBAAkB,CAAC;AAC9C;;GAEG;AACU,QAAA,YAAY,GAAG,mBAAmB,CAAC;AAChD;;GAEG;AACU,QAAA,cAAc,GAAG,qBAAqB,CAAC;AACpD;;GAEG;AACU,QAAA,WAAW,GAAG,kBAAkB,CAAC;AAE9C,MAAM,MAAM,GAAG,IAAI,GAAG,EAAiB,CAAC;AAExC,SAAS,QAAQ,CAAC,GAAW,EAAE,GAAG,IAAW;IAC3C,IAAI,IAAA,mBAAQ,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;QACrB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;YACxB,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,KAAK,EAAE,CAAC,CAAC;SAClC;QAED,OAAO,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAE,CAAC;KAC7B;SAAM;QACL,MAAM,QAAQ,GAAG,mBAAe,CAAC;QAEjC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,EAAE;YAClC,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,KAAK,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;SACzC;QAED,OAAO,QAAQ,CAAC,MAAM,CA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,CAAC;IACd,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,GAAW;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAA,eAAM,EAAC,GAAG,CAAC,CAAC,CAAC;IAC3C,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,GAAQ,EAAE,KAAU,EAAE,UAAmB,KAAK;QAClD,IAAI,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAE5B,IAAI,OAAO,EAAE;YACX,KAAK,GAAG,IAAA,qBAAS,EAAC,KAAK,CAAC,CAAC;YACzB,OAAO,GAAG,IAAA,qBAAS,EAAC,OAAO,CAAC,CAAC;YAC7B,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,IAAA,qBAAS,EAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,IAAA,qBAAS,EAAC,OAAO,EAAE,KAAK,CAAC,CAAC;SACzE;QAED,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAErB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM;QACJ,OAAO,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;YAC/D,OAAO;gBACL,GAAG,GAAG;gBACN,CAAC,GAAG,CAAC,EAAE,KAAK;aACb,CAAC;QACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IACT,CAAC;CACF;AAvGD,sBAuGC","sourcesContent":["import {DecoratorTypes} from \"../domain/DecoratorTypes\";\nimport {decoratorTypeOf} from \"../utils/decorators/decoratorTypeOf\";\nimport {deepClone} from \"../utils/objects/deepClone\";\nimport {deepMerge} from \"../utils/objects/deepMerge\";\nimport {descriptorOf} from \"../utils/objects/descriptorOf\";\nimport {isSymbol} from \"../utils/objects/isSymbol\";\nimport {nameOf} from \"../utils/objects/nameOf\";\nimport {Metadata} from \"./Metadata\";\nimport type {Type} from \"./Type\";\n\n/**\n * @ignore\n */\nexport const CLASS_STORE = \"tsed:class:store\";\n/**\n * @ignore\n */\nexport const METHOD_STORE = \"tsed:method:store\";\n/**\n * @ignore\n */\nexport const PROPERTY_STORE = \"tsed:property:store\";\n/**\n * @ignore\n */\nexport const PARAM_STORE = \"tsed:param:store\";\n\nconst stores = new Map<symbol, Store>();\n\nfunction storeGet(key: string, ...args: any[]): Store {\n if (isSymbol(args[0])) {\n if (!stores.has(args[0])) {\n stores.set(args[0], new Store());\n }\n\n return stores.get(args[0])!;\n } else {\n const registry = Metadata as any;\n\n if (!registry.hasOwn(key, ...args)) {\n registry.set(key, new Store(), ...args);\n }\n\n return registry.getOwn(key, ...args);\n }\n}\n\nfunction defineStore(args: any[]): Store {\n const [target, propertyKey, descriptor] = args;\n\n switch (decoratorTypeOf(args)) {\n case DecoratorTypes.PARAM_CTOR:\n case DecoratorTypes.PARAM_STC:\n case DecoratorTypes.PARAM:\n const store = storeGet(PARAM_STORE, target, propertyKey);\n if (!store.has(\"\" + descriptor)) {\n store.set(\"\" + descriptor, new Store());\n }\n\n return store.get(\"\" + descriptor);\n case DecoratorTypes.PROP:\n case DecoratorTypes.PROP_STC:\n return storeGet(PROPERTY_STORE, target, propertyKey);\n case DecoratorTypes.METHOD:\n case DecoratorTypes.METHOD_STC:\n return storeGet(METHOD_STORE, target, propertyKey);\n case DecoratorTypes.CLASS:\n return storeGet(CLASS_STORE, target);\n }\n}\n\nexport class Store {\n private _entries = new Map<string, any>();\n /**\n * Create or get a Store from args {target + methodName + descriptor}\n * @param args\n * @returns {Store}\n */\n static from(...args: any[]): Store {\n return defineStore(args);\n }\n\n /**\n * Create store on the method.\n * @param target\n * @param {string} propertyKey\n * @returns {Store}\n */\n static fromMethod(target: any, propertyKey: string | symbol): Store {\n return Store.from(target, propertyKey, descriptorOf(target, propertyKey));\n }\n\n static mergeStoreFrom(target: Type<any>, source: Type<any>, ...args: any[]) {\n const store = Store.from(target, ...args);\n\n Store.from(source, ...args)._entries.forEach((value, key) => {\n store.merge(key, value);\n });\n\n return store;\n }\n\n static mergeStoreMethodFrom(target: Type<any>, source: Type<any>, propertyKey: string | symbol) {\n return this.mergeStoreFrom(target, source, propertyKey, descriptorOf(target, propertyKey));\n }\n\n /**\n * The get() method returns a specified element from a Map object.\n * @param key Required. The key of the element to return from the Map object.\n * @param defaultValue\n * @returns {T} Returns the element associated with the specified key or undefined if the key can't be found in the Map object.\n */\n get<T = any>(key: any, defaultValue?: any): T {\n return this._entries.get(nameOf(key)) || defaultValue;\n }\n\n /**\n * The has() method returns a boolean indicating whether an element with the specified key exists or not.\n * @param key\n * @returns {boolean}\n */\n has(key: any): boolean {\n return this._entries.has(nameOf(key));\n }\n\n /**\n * The set() method adds or updates an element with a specified key and value to a Map object.\n * @param key Required. The key of the element to add to the Map object.\n * @param metadata Required. The value of the element to add to the Map object.\n */\n set(key: any, metadata: any): Store {\n this._entries.set(nameOf(key), metadata);\n\n return this;\n }\n\n /**\n * The delete() method removes the specified element from a Map object.\n * @param key Required. The key of the element to remove from the Map object.\n * @returns {boolean} Returns true if an element in the Map object existed and has been removed, or false if the element does not exist.\n */\n delete(key: string): boolean {\n return this._entries.delete(nameOf(key));\n }\n\n /**\n * Merge given value with existing value.\n * @param key\n * @param value\n * @param inverse Change the merge order. Get the existing value and apply over given value\n * @returns {Store}\n */\n merge(key: any, value: any, inverse: boolean = false): Store {\n let _value_ = this.get(key);\n\n if (_value_) {\n value = deepClone(value);\n _value_ = deepClone(_value_);\n value = inverse ? deepMerge(value, _value_) : deepMerge(_value_, value);\n }\n\n this.set(key, value);\n\n return this;\n }\n\n toJson() {\n return [...this._entries.entries()].reduce((obj, [key, value]) => {\n return {\n ...obj,\n [key]: value\n };\n }, {});\n }\n}\n"]}
@@ -5,6 +5,7 @@ const decoratorTypeOf_1 = require("../utils/decorators/decoratorTypeOf");
5
5
  const classOf_1 = require("../utils/objects/classOf");
6
6
  const nameOf_1 = require("../utils/objects/nameOf");
7
7
  class UnsupportedDecoratorType extends Error {
8
+ name;
8
9
  constructor(decorator, args) {
9
10
  super(UnsupportedDecoratorType.buildMessage(decorator, args));
10
11
  }
@@ -1 +1 @@
1
- {"version":3,"file":"UnsupportedDecoratorType.js","sourceRoot":"","sources":["../../../src/errors/UnsupportedDecoratorType.ts"],"names":[],"mappings":";;;AAAA,yEAAoE;AACpE,sDAAiD;AACjD,oDAA+C;AAE/C,MAAa,wBAAyB,SAAQ,KAAK;IAGjD,YAAY,SAAc,EAAE,IAAW;QACrC,KAAK,CAAC,wBAAwB,CAAC,YAAY,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC;IAChE,CAAC;IAEO,MAAM,CAAC,YAAY,CAAC,SAAc,EAAE,IAAW;QACrD,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC;QAE1C,MAAM,WAAW,GAAG,IAAA,iCAAe,EAAC,IAAI,CAAC,CAAC;QAC1C,MAAM,YAAY,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/C,MAAM,KAAK,GAAG,YAAY,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,GAAG,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QACrE,MAAM,IAAI,GAAG,YAAY,KAAK,WAAW,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC;QAChE,MAAM,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,GAAG,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC;QAEtD,MAAM,IAAI,GAAG,IAAA,eAAM,EAAC,IAAA,iBAAO,EAAC,MAAM,CAAC,CAAC,GAAG,MAAM,GAAG,KAAK,CAAC;QAEtD,OAAO,GAAG,SAAS,CAAC,IAAI,sBAAsB,WAAW,iBAAiB,IAAI,EAAE,CAAC;IACnF,CAAC;CACF;AApBD,4DAoBC","sourcesContent":["import {decoratorTypeOf} from \"../utils/decorators/decoratorTypeOf\";\nimport {classOf} from \"../utils/objects/classOf\";\nimport {nameOf} from \"../utils/objects/nameOf\";\n\nexport class UnsupportedDecoratorType extends Error {\n name: \"UNSUPPORTED_DECORATOR_TYPE\";\n\n constructor(decorator: any, args: any[]) {\n super(UnsupportedDecoratorType.buildMessage(decorator, args));\n }\n\n private static buildMessage(decorator: any, args: any[]): string {\n const [target, propertyKey, index] = args;\n\n const bindingType = decoratorTypeOf(args);\n const shortBinding = bindingType.split(\"/\")[0];\n const param = shortBinding === \"parameter\" ? \".[\" + index + \"]\" : \"\";\n const cstr = shortBinding === \"parameter\" ? \".constructor\" : \"\";\n const method = propertyKey ? \".\" + propertyKey : cstr;\n\n const path = nameOf(classOf(target)) + method + param;\n\n return `${decorator.name} cannot be used as ${bindingType} decorator on ${path}`;\n }\n}\n"]}
1
+ {"version":3,"file":"UnsupportedDecoratorType.js","sourceRoot":"","sources":["../../../src/errors/UnsupportedDecoratorType.ts"],"names":[],"mappings":";;;AAAA,yEAAoE;AACpE,sDAAiD;AACjD,oDAA+C;AAE/C,MAAa,wBAAyB,SAAQ,KAAK;IACjD,IAAI,CAA+B;IAEnC,YAAY,SAAc,EAAE,IAAW;QACrC,KAAK,CAAC,wBAAwB,CAAC,YAAY,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC;IAChE,CAAC;IAEO,MAAM,CAAC,YAAY,CAAC,SAAc,EAAE,IAAW;QACrD,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC;QAE1C,MAAM,WAAW,GAAG,IAAA,iCAAe,EAAC,IAAI,CAAC,CAAC;QAC1C,MAAM,YAAY,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/C,MAAM,KAAK,GAAG,YAAY,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,GAAG,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QACrE,MAAM,IAAI,GAAG,YAAY,KAAK,WAAW,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC;QAChE,MAAM,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,GAAG,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC;QAEtD,MAAM,IAAI,GAAG,IAAA,eAAM,EAAC,IAAA,iBAAO,EAAC,MAAM,CAAC,CAAC,GAAG,MAAM,GAAG,KAAK,CAAC;QAEtD,OAAO,GAAG,SAAS,CAAC,IAAI,sBAAsB,WAAW,iBAAiB,IAAI,EAAE,CAAC;IACnF,CAAC;CACF;AApBD,4DAoBC","sourcesContent":["import {decoratorTypeOf} from \"../utils/decorators/decoratorTypeOf\";\nimport {classOf} from \"../utils/objects/classOf\";\nimport {nameOf} from \"../utils/objects/nameOf\";\n\nexport class UnsupportedDecoratorType extends Error {\n name: \"UNSUPPORTED_DECORATOR_TYPE\";\n\n constructor(decorator: any, args: any[]) {\n super(UnsupportedDecoratorType.buildMessage(decorator, args));\n }\n\n private static buildMessage(decorator: any, args: any[]): string {\n const [target, propertyKey, index] = args;\n\n const bindingType = decoratorTypeOf(args);\n const shortBinding = bindingType.split(\"/\")[0];\n const param = shortBinding === \"parameter\" ? \".[\" + index + \"]\" : \"\";\n const cstr = shortBinding === \"parameter\" ? \".constructor\" : \"\";\n const method = propertyKey ? \".\" + propertyKey : cstr;\n\n const path = nameOf(classOf(target)) + method + param;\n\n return `${decorator.name} cannot be used as ${bindingType} decorator on ${path}`;\n }\n}\n"]}
@@ -1,23 +1,28 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.decorateMethodsOf = void 0;
4
+ const Store_1 = require("../../domain/Store");
4
5
  const classOf_1 = require("../objects/classOf");
6
+ const descriptorOf_1 = require("../objects/descriptorOf");
5
7
  const methodsOf_1 = require("../objects/methodsOf");
6
8
  const prototypeOf_1 = require("../objects/prototypeOf");
7
- const descriptorOf_1 = require("../objects/descriptorOf");
8
- const Store_1 = require("../../domain/Store");
9
9
  function decorateMethodsOf(klass, decorator) {
10
10
  (0, methodsOf_1.methodsOf)(klass).forEach(({ target, propertyKey }) => {
11
+ const proto = (0, prototypeOf_1.prototypeOf)(klass);
11
12
  if (target !== (0, classOf_1.classOf)(klass)) {
12
- Object.defineProperty((0, prototypeOf_1.prototypeOf)(klass), propertyKey, {
13
+ Object.defineProperty(proto, propertyKey, {
13
14
  writable: true,
15
+ configurable: true,
14
16
  value(...args) {
15
17
  return (0, prototypeOf_1.prototypeOf)(target)[propertyKey].apply(this, args);
16
18
  }
17
19
  });
18
20
  Store_1.Store.mergeStoreMethodFrom(klass, target, propertyKey);
19
21
  }
20
- decorator((0, prototypeOf_1.prototypeOf)(klass), propertyKey, (0, descriptorOf_1.descriptorOf)(klass, propertyKey));
22
+ const newDescriptor = decorator(proto, propertyKey, (0, descriptorOf_1.descriptorOf)(klass, propertyKey));
23
+ if (newDescriptor) {
24
+ Object.defineProperty(proto, propertyKey, newDescriptor);
25
+ }
21
26
  });
22
27
  }
23
28
  exports.decorateMethodsOf = decorateMethodsOf;
@@ -1 +1 @@
1
- {"version":3,"file":"decorateMethodsOf.js","sourceRoot":"","sources":["../../../../src/utils/decorators/decorateMethodsOf.ts"],"names":[],"mappings":";;;AAAA,gDAA2C;AAC3C,oDAA+C;AAC/C,wDAAmD;AACnD,0DAAqD;AACrD,8CAAyC;AAEzC,SAAgB,iBAAiB,CAAC,KAAU,EAAE,SAAc;IAC1D,IAAA,qBAAS,EAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,EAAC,MAAM,EAAE,WAAW,EAAC,EAAE,EAAE;QACjD,IAAI,MAAM,KAAK,IAAA,iBAAO,EAAC,KAAK,CAAC,EAAE;YAC7B,MAAM,CAAC,cAAc,CAAC,IAAA,yBAAW,EAAC,KAAK,CAAC,EAAE,WAAW,EAAE;gBACrD,QAAQ,EAAE,IAAI;gBACd,KAAK,CAAC,GAAG,IAAW;oBAClB,OAAO,IAAA,yBAAW,EAAC,MAAM,CAAC,CAAC,WAAW,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;gBAC5D,CAAC;aACF,CAAC,CAAC;YAEH,aAAK,CAAC,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;SACxD;QAED,SAAS,CAAC,IAAA,yBAAW,EAAC,KAAK,CAAC,EAAE,WAAW,EAAE,IAAA,2BAAY,EAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC;IAC/E,CAAC,CAAC,CAAC;AACL,CAAC;AAfD,8CAeC","sourcesContent":["import {classOf} from \"../objects/classOf\";\nimport {methodsOf} from \"../objects/methodsOf\";\nimport {prototypeOf} from \"../objects/prototypeOf\";\nimport {descriptorOf} from \"../objects/descriptorOf\";\nimport {Store} from \"../../domain/Store\";\n\nexport function decorateMethodsOf(klass: any, decorator: any) {\n methodsOf(klass).forEach(({target, propertyKey}) => {\n if (target !== classOf(klass)) {\n Object.defineProperty(prototypeOf(klass), propertyKey, {\n writable: true,\n value(...args: any[]) {\n return prototypeOf(target)[propertyKey].apply(this, args);\n }\n });\n\n Store.mergeStoreMethodFrom(klass, target, propertyKey);\n }\n\n decorator(prototypeOf(klass), propertyKey, descriptorOf(klass, propertyKey));\n });\n}\n"]}
1
+ {"version":3,"file":"decorateMethodsOf.js","sourceRoot":"","sources":["../../../../src/utils/decorators/decorateMethodsOf.ts"],"names":[],"mappings":";;;AAAA,8CAAyC;AACzC,gDAA2C;AAC3C,0DAAqD;AACrD,oDAA+C;AAC/C,wDAAmD;AAEnD,SAAgB,iBAAiB,CAAC,KAAU,EAAE,SAAc;IAC1D,IAAA,qBAAS,EAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,EAAC,MAAM,EAAE,WAAW,EAAC,EAAE,EAAE;QACjD,MAAM,KAAK,GAAG,IAAA,yBAAW,EAAC,KAAK,CAAC,CAAC;QAEjC,IAAI,MAAM,KAAK,IAAA,iBAAO,EAAC,KAAK,CAAC,EAAE;YAC7B,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,WAAW,EAAE;gBACxC,QAAQ,EAAE,IAAI;gBACd,YAAY,EAAE,IAAI;gBAClB,KAAK,CAAC,GAAG,IAAW;oBAClB,OAAO,IAAA,yBAAW,EAAC,MAAM,CAAC,CAAC,WAAW,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;gBAC5D,CAAC;aACF,CAAC,CAAC;YAEH,aAAK,CAAC,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;SACxD;QAED,MAAM,aAAa,GAAG,SAAS,CAAC,KAAK,EAAE,WAAW,EAAE,IAAA,2BAAY,EAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC;QAEtF,IAAI,aAAa,EAAE;YACjB,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC;SAC1D;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAtBD,8CAsBC","sourcesContent":["import {Store} from \"../../domain/Store\";\nimport {classOf} from \"../objects/classOf\";\nimport {descriptorOf} from \"../objects/descriptorOf\";\nimport {methodsOf} from \"../objects/methodsOf\";\nimport {prototypeOf} from \"../objects/prototypeOf\";\n\nexport function decorateMethodsOf(klass: any, decorator: any) {\n methodsOf(klass).forEach(({target, propertyKey}) => {\n const proto = prototypeOf(klass);\n\n if (target !== classOf(klass)) {\n Object.defineProperty(proto, propertyKey, {\n writable: true,\n configurable: true,\n value(...args: any[]) {\n return prototypeOf(target)[propertyKey].apply(this, args);\n }\n });\n\n Store.mergeStoreMethodFrom(klass, target, propertyKey);\n }\n\n const newDescriptor = decorator(proto, propertyKey, descriptorOf(klass, propertyKey));\n\n if (newDescriptor) {\n Object.defineProperty(proto, propertyKey, newDescriptor);\n }\n });\n}\n"]}
@@ -12,8 +12,7 @@ function descriptorOf(target, propertyKey) {
12
12
  }
13
13
  exports.descriptorOf = descriptorOf;
14
14
  function isMethodDescriptor(target, propertyKey) {
15
- var _a;
16
- return (_a = descriptorOf(target, propertyKey)) === null || _a === void 0 ? void 0 : _a.value;
15
+ return descriptorOf(target, propertyKey)?.value;
17
16
  }
18
17
  exports.isMethodDescriptor = isMethodDescriptor;
19
18
  //# sourceMappingURL=descriptorOf.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"descriptorOf.js","sourceRoot":"","sources":["../../../../src/utils/objects/descriptorOf.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,SAAgB,YAAY,CAAC,MAAW,EAAE,WAA4B;IACpE,OAAO,MAAM,CAAC,wBAAwB,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,SAAS,CAAC,IAAI,MAAM,EAAE,WAAW,CAAE,CAAC;AAC/F,CAAC;AAFD,oCAEC;AAED,SAAgB,kBAAkB,CAAC,MAAW,EAAE,WAA4B;;IAC1E,OAAO,MAAA,YAAY,CAAC,MAAM,EAAE,WAAW,CAAC,0CAAE,KAAK,CAAC;AAClD,CAAC;AAFD,gDAEC","sourcesContent":["/**\n * Return the descriptor for a given class and propertyKey\n * @param target\n * @param {string} propertyKey\n * @returns {PropertyDescriptor}\n */\nexport function descriptorOf(target: any, propertyKey: string | symbol): PropertyDescriptor {\n return Object.getOwnPropertyDescriptor((target && target.prototype) || target, propertyKey)!;\n}\n\nexport function isMethodDescriptor(target: any, propertyKey: string | symbol) {\n return descriptorOf(target, propertyKey)?.value;\n}\n"]}
1
+ {"version":3,"file":"descriptorOf.js","sourceRoot":"","sources":["../../../../src/utils/objects/descriptorOf.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,SAAgB,YAAY,CAAC,MAAW,EAAE,WAA4B;IACpE,OAAO,MAAM,CAAC,wBAAwB,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,SAAS,CAAC,IAAI,MAAM,EAAE,WAAW,CAAE,CAAC;AAC/F,CAAC;AAFD,oCAEC;AAED,SAAgB,kBAAkB,CAAC,MAAW,EAAE,WAA4B;IAC1E,OAAO,YAAY,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE,KAAK,CAAC;AAClD,CAAC;AAFD,gDAEC","sourcesContent":["/**\n * Return the descriptor for a given class and propertyKey\n * @param target\n * @param {string} propertyKey\n * @returns {PropertyDescriptor}\n */\nexport function descriptorOf(target: any, propertyKey: string | symbol): PropertyDescriptor {\n return Object.getOwnPropertyDescriptor((target && target.prototype) || target, propertyKey)!;\n}\n\nexport function isMethodDescriptor(target: any, propertyKey: string | symbol) {\n return descriptorOf(target, propertyKey)?.value;\n}\n"]}
@@ -1,5 +1,3 @@
1
- var _AnyToPromise_resolves, _AnyToPromise_rejects, _AnyToPromise_hasNextFunction, _AnyToPromise_promise;
2
- import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
3
1
  import { isObservable } from "../utils/objects/isObservable.js";
4
2
  import { isPromise } from "../utils/objects/isPromise.js";
5
3
  import { isStream } from "../utils/objects/isStream.js";
@@ -26,23 +24,24 @@ export var AnyToPromiseResponseTypes;
26
24
  AnyToPromiseResponseTypes["DATA"] = "DATA";
27
25
  })(AnyToPromiseResponseTypes || (AnyToPromiseResponseTypes = {}));
28
26
  export class AnyToPromise {
27
+ status = AnyToPromiseStatus.PENDING;
28
+ args;
29
+ #resolves;
30
+ #rejects;
31
+ #hasNextFunction = false;
32
+ #promise;
29
33
  constructor({ hasNextFunction = false } = {}) {
30
- this.status = AnyToPromiseStatus.PENDING;
31
- _AnyToPromise_resolves.set(this, void 0);
32
- _AnyToPromise_rejects.set(this, void 0);
33
- _AnyToPromise_hasNextFunction.set(this, false);
34
- _AnyToPromise_promise.set(this, void 0);
35
- __classPrivateFieldSet(this, _AnyToPromise_hasNextFunction, hasNextFunction, "f");
36
- __classPrivateFieldSet(this, _AnyToPromise_promise, new Promise((resolve, reject) => {
37
- __classPrivateFieldSet(this, _AnyToPromise_resolves, resolve, "f");
38
- __classPrivateFieldSet(this, _AnyToPromise_rejects, reject, "f");
39
- }), "f");
34
+ this.#hasNextFunction = hasNextFunction;
35
+ this.#promise = new Promise((resolve, reject) => {
36
+ this.#resolves = resolve;
37
+ this.#rejects = reject;
38
+ });
40
39
  }
41
40
  isDone() {
42
41
  return this.status !== AnyToPromiseStatus.PENDING;
43
42
  }
44
43
  get next() {
45
- __classPrivateFieldSet(this, _AnyToPromise_hasNextFunction, true, "f");
44
+ this.#hasNextFunction = true;
46
45
  return (error) => {
47
46
  if (this.isDone()) {
48
47
  return;
@@ -63,21 +62,21 @@ export class AnyToPromise {
63
62
  catch (er) {
64
63
  this.reject(er);
65
64
  }
66
- return __classPrivateFieldGet(this, _AnyToPromise_promise, "f");
65
+ return this.#promise;
67
66
  }
68
67
  reject(er) {
69
68
  if (this.isDone()) {
70
69
  return;
71
70
  }
72
71
  this.done(AnyToPromiseStatus.REJECTED);
73
- __classPrivateFieldGet(this, _AnyToPromise_rejects, "f").call(this, er);
72
+ this.#rejects(er);
74
73
  }
75
74
  resolve(response = {}) {
76
75
  if (this.isDone()) {
77
76
  return;
78
77
  }
79
78
  this.done(AnyToPromiseStatus.RESOLVED);
80
- __classPrivateFieldGet(this, _AnyToPromise_resolves, "f").call(this, { ...response, state: AnyToPromiseStatus.RESOLVED });
79
+ this.#resolves({ ...response, state: AnyToPromiseStatus.RESOLVED });
81
80
  }
82
81
  destroy() { }
83
82
  cancel() {
@@ -85,7 +84,7 @@ export class AnyToPromise {
85
84
  return;
86
85
  }
87
86
  this.done(AnyToPromiseStatus.CANCELED);
88
- return __classPrivateFieldGet(this, _AnyToPromise_resolves, "f").call(this, { state: AnyToPromiseStatus.CANCELED });
87
+ return this.#resolves({ state: AnyToPromiseStatus.CANCELED });
89
88
  }
90
89
  done(status) {
91
90
  this.destroy();
@@ -127,7 +126,7 @@ export class AnyToPromise {
127
126
  });
128
127
  }
129
128
  }
130
- if (!__classPrivateFieldGet(this, _AnyToPromise_hasNextFunction, "f")) {
129
+ if (!this.#hasNextFunction) {
131
130
  // no next function and empty response
132
131
  return this.resolve({
133
132
  ...additionalProps,
@@ -140,5 +139,4 @@ export class AnyToPromise {
140
139
  return process === AnyToPromiseStatus.CANCELED;
141
140
  }
142
141
  }
143
- _AnyToPromise_resolves = new WeakMap(), _AnyToPromise_rejects = new WeakMap(), _AnyToPromise_hasNextFunction = new WeakMap(), _AnyToPromise_promise = new WeakMap();
144
142
  //# sourceMappingURL=AnyToPromise.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AnyToPromise.js","sourceRoot":"","sources":["../../../src/domain/AnyToPromise.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAC,SAAS,EAAC,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAC,QAAQ,EAAC,MAAM,2BAA2B,CAAC;AAEnD;;GAEG;AACH,SAAS,UAAU,CAAC,GAAQ;IAC1B,OAAO,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,UAAU,CAAC;AACjE,CAAC;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC5B,yCAAmB,CAAA;IACnB,2CAAqB,CAAA;IACrB,2CAAqB,CAAA;IACrB,2CAAqB,CAAA;AACvB,CAAC,EALW,kBAAkB,KAAlB,kBAAkB,QAK7B;AAED,MAAM,CAAN,IAAY,yBAIX;AAJD,WAAY,yBAAyB;IACnC,8CAAiB,CAAA;IACjB,8CAAiB,CAAA;IACjB,0CAAa,CAAA;AACf,CAAC,EAJW,yBAAyB,KAAzB,yBAAyB,QAIpC;AAUD,MAAM,OAAO,YAAY;IAUvB,YAAY,EAAC,eAAe,GAAG,KAAK,KAAiC,EAAE;QAThE,WAAM,GAAG,kBAAkB,CAAC,OAAO,CAAC;QAG3C,yCA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C;IACjD,CAAC;CACF","sourcesContent":["import {isObservable} from \"../utils/objects/isObservable\";\nimport {isPromise} from \"../utils/objects/isPromise\";\nimport {isStream} from \"../utils/objects/isStream\";\n\n/**\n * @ignore\n */\nfunction isResponse(obj: any) {\n return obj.data && obj.headers && obj.status && obj.statusText;\n}\n\n/**\n * @ignore\n */\nexport enum AnyToPromiseStatus {\n PENDING = \"PENDING\",\n CANCELED = \"CANCELED\",\n RESOLVED = \"RESOLVED\",\n REJECTED = \"REJECTED\"\n}\n\nexport enum AnyToPromiseResponseTypes {\n STREAM = \"STREAM\",\n BUFFER = \"BUFFER\",\n DATA = \"DATA\"\n}\n\nexport interface AnyPromiseResult<T = any> {\n state: AnyToPromiseStatus;\n type: AnyToPromiseResponseTypes;\n status?: number;\n headers?: Record<string, any>;\n data: T;\n}\n\nexport class AnyToPromise<T = any> {\n public status = AnyToPromiseStatus.PENDING;\n public args: any[];\n\n #resolves: any;\n #rejects: any;\n #hasNextFunction = false;\n\n readonly #promise: Promise<AnyPromiseResult<T>>;\n\n constructor({hasNextFunction = false}: {hasNextFunction?: boolean} = {}) {\n this.#hasNextFunction = hasNextFunction;\n\n this.#promise = new Promise((resolve: any, reject: any) => {\n this.#resolves = resolve;\n this.#rejects = reject;\n });\n }\n\n isDone(): boolean {\n return this.status !== AnyToPromiseStatus.PENDING;\n }\n\n get next() {\n this.#hasNextFunction = true;\n\n return (error?: any) => {\n if (this.isDone()) {\n return;\n }\n\n return error ? this.reject(error) : this.resolve({type: AnyToPromiseResponseTypes.DATA});\n };\n }\n\n /**\n *\n */\n async call(cb: Function): Promise<AnyPromiseResult<T>> {\n if (this.isDone()) {\n return this as any;\n }\n\n try {\n this.handle(cb());\n } catch (er) {\n this.reject(er);\n }\n\n return this.#promise;\n }\n\n reject(er: any) {\n if (this.isDone()) {\n return;\n }\n\n this.done(AnyToPromiseStatus.REJECTED);\n\n this.#rejects(er);\n }\n\n resolve(response: any = {}) {\n if (this.isDone()) {\n return;\n }\n\n this.done(AnyToPromiseStatus.RESOLVED);\n\n this.#resolves({...response, state: AnyToPromiseStatus.RESOLVED});\n }\n\n destroy() {}\n\n cancel() {\n if (this.isDone()) {\n return;\n }\n\n this.done(AnyToPromiseStatus.CANCELED);\n\n return this.#resolves({state: AnyToPromiseStatus.CANCELED});\n }\n\n done(status: AnyToPromiseStatus) {\n this.destroy();\n this.status = status;\n }\n\n handle(process: any, additionalProps = {}): any {\n if (this.isDone()) {\n return;\n }\n\n if (process) {\n if (this.isCanceledResponse(process)) {\n // ABANDON\n return this.cancel();\n }\n\n if (isObservable(process)) {\n process = process.toPromise();\n }\n\n if (isResponse(process)) {\n return this.handle(process.data, {\n ...additionalProps,\n status: process.status,\n headers: process.headers\n });\n }\n\n if (isStream(process)) {\n return this.resolve({...additionalProps, type: AnyToPromiseResponseTypes.STREAM, data: process});\n }\n if (isStream(process) || Buffer.isBuffer(process)) {\n return this.resolve({...additionalProps, type: AnyToPromiseResponseTypes.BUFFER, data: process});\n }\n\n if (isPromise(process)) {\n return process\n .then((result: any) => this.handle(result, additionalProps))\n .catch((error: any) => {\n if (error.response && isResponse(error.response)) {\n return this.handle(error.response);\n }\n return this.reject(error);\n });\n }\n }\n\n if (!this.#hasNextFunction) {\n // no next function and empty response\n return this.resolve({\n ...additionalProps,\n data: process,\n type: AnyToPromiseResponseTypes.DATA\n });\n }\n }\n\n protected isCanceledResponse(process: any) {\n return process === AnyToPromiseStatus.CANCELED;\n }\n}\n"]}
1
+ {"version":3,"file":"AnyToPromise.js","sourceRoot":"","sources":["../../../src/domain/AnyToPromise.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAC,SAAS,EAAC,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAC,QAAQ,EAAC,MAAM,2BAA2B,CAAC;AAEnD;;GAEG;AACH,SAAS,UAAU,CAAC,GAAQ;IAC1B,OAAO,GAAG,CAAC,IAAI,IAAI,GAAG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U,EAAE,EAAE;oBACpB,IAAI,KAAK,CAAC,QAAQ,IAAI,UAAU,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE;wBAChD,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;qBACpC;oBACD,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBAC5B,CAAC,CAAC,CAAC;aACN;SACF;QAED,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE;YAC1B,sCAAsC;YACtC,OAAO,IAAI,CAAC,OAAO,CAAC;gBAClB,GAAG,eAAe;gBAClB,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,yBAAyB,CAAC,IAAI;aACrC,CAAC,CAAC;SACJ;IACH,CAAC;IAES,kBAAkB,CAAC,OAAY;QACvC,OAAO,OAAO,KAAK,kBAAkB,CAAC,QAAQ,CAAC;IACjD,CAAC;CACF","sourcesContent":["import {isObservable} from \"../utils/objects/isObservable\";\nimport {isPromise} from \"../utils/objects/isPromise\";\nimport {isStream} from \"../utils/objects/isStream\";\n\n/**\n * @ignore\n */\nfunction isResponse(obj: any) {\n return obj.data && obj.headers && obj.status && obj.statusText;\n}\n\n/**\n * @ignore\n */\nexport enum AnyToPromiseStatus {\n PENDING = \"PENDING\",\n CANCELED = \"CANCELED\",\n RESOLVED = \"RESOLVED\",\n REJECTED = \"REJECTED\"\n}\n\nexport enum AnyToPromiseResponseTypes {\n STREAM = \"STREAM\",\n BUFFER = \"BUFFER\",\n DATA = \"DATA\"\n}\n\nexport interface AnyPromiseResult<T = any> {\n state: AnyToPromiseStatus;\n type: AnyToPromiseResponseTypes;\n status?: number;\n headers?: Record<string, any>;\n data: T;\n}\n\nexport class AnyToPromise<T = any> {\n public status = AnyToPromiseStatus.PENDING;\n public args: any[];\n\n #resolves: any;\n #rejects: any;\n #hasNextFunction = false;\n\n readonly #promise: Promise<AnyPromiseResult<T>>;\n\n constructor({hasNextFunction = false}: {hasNextFunction?: boolean} = {}) {\n this.#hasNextFunction = hasNextFunction;\n\n this.#promise = new Promise((resolve: any, reject: any) => {\n this.#resolves = resolve;\n this.#rejects = reject;\n });\n }\n\n isDone(): boolean {\n return this.status !== AnyToPromiseStatus.PENDING;\n }\n\n get next() {\n this.#hasNextFunction = true;\n\n return (error?: any) => {\n if (this.isDone()) {\n return;\n }\n\n return error ? this.reject(error) : this.resolve({type: AnyToPromiseResponseTypes.DATA});\n };\n }\n\n /**\n *\n */\n async call(cb: Function): Promise<AnyPromiseResult<T>> {\n if (this.isDone()) {\n return this as any;\n }\n\n try {\n this.handle(cb());\n } catch (er) {\n this.reject(er);\n }\n\n return this.#promise;\n }\n\n reject(er: any) {\n if (this.isDone()) {\n return;\n }\n\n this.done(AnyToPromiseStatus.REJECTED);\n\n this.#rejects(er);\n }\n\n resolve(response: any = {}) {\n if (this.isDone()) {\n return;\n }\n\n this.done(AnyToPromiseStatus.RESOLVED);\n\n this.#resolves({...response, state: AnyToPromiseStatus.RESOLVED});\n }\n\n destroy() {}\n\n cancel() {\n if (this.isDone()) {\n return;\n }\n\n this.done(AnyToPromiseStatus.CANCELED);\n\n return this.#resolves({state: AnyToPromiseStatus.CANCELED});\n }\n\n done(status: AnyToPromiseStatus) {\n this.destroy();\n this.status = status;\n }\n\n handle(process: any, additionalProps = {}): any {\n if (this.isDone()) {\n return;\n }\n\n if (process) {\n if (this.isCanceledResponse(process)) {\n // ABANDON\n return this.cancel();\n }\n\n if (isObservable(process)) {\n process = process.toPromise();\n }\n\n if (isResponse(process)) {\n return this.handle(process.data, {\n ...additionalProps,\n status: process.status,\n headers: process.headers\n });\n }\n\n if (isStream(process)) {\n return this.resolve({...additionalProps, type: AnyToPromiseResponseTypes.STREAM, data: process});\n }\n if (isStream(process) || Buffer.isBuffer(process)) {\n return this.resolve({...additionalProps, type: AnyToPromiseResponseTypes.BUFFER, data: process});\n }\n\n if (isPromise(process)) {\n return process\n .then((result: any) => this.handle(result, additionalProps))\n .catch((error: any) => {\n if (error.response && isResponse(error.response)) {\n return this.handle(error.response);\n }\n return this.reject(error);\n });\n }\n }\n\n if (!this.#hasNextFunction) {\n // no next function and empty response\n return this.resolve({\n ...additionalProps,\n data: process,\n type: AnyToPromiseResponseTypes.DATA\n });\n }\n }\n\n protected isCanceledResponse(process: any) {\n return process === AnyToPromiseStatus.CANCELED;\n }\n}\n"]}
@@ -1,17 +1,15 @@
1
1
  export class Hooks {
2
- constructor() {
3
- this.listeners = new Map();
4
- }
2
+ #listeners = {};
5
3
  /**
6
4
  * Listen a hook event
7
5
  * @param event
8
6
  * @param cb
9
7
  */
10
8
  on(event, cb) {
11
- if (!this.listeners.has(event)) {
12
- this.listeners.set(event, []);
9
+ if (!this.#listeners[event]) {
10
+ this.#listeners[event] = [];
13
11
  }
14
- this.listeners.get(event).push(cb);
12
+ this.#listeners[event].push(cb);
15
13
  return this;
16
14
  }
17
15
  /**
@@ -20,8 +18,8 @@ export class Hooks {
20
18
  * @param cb
21
19
  */
22
20
  off(event, cb) {
23
- if (this.listeners.has(event)) {
24
- this.listeners.set(event, this.listeners.get(event).filter((item) => item === cb));
21
+ if (this.#listeners[event]) {
22
+ this.#listeners[event] = this.#listeners[event].filter((item) => item === cb);
25
23
  }
26
24
  return this;
27
25
  }
@@ -32,8 +30,9 @@ export class Hooks {
32
30
  * @param callThis
33
31
  */
34
32
  emit(event, args = [], callThis = null) {
35
- if (this.listeners.has(event)) {
36
- for (const cb of this.listeners.get(event)) {
33
+ const listeners = this.#listeners[event];
34
+ if (listeners?.length) {
35
+ for (const cb of listeners) {
37
36
  cb.call(callThis, ...args);
38
37
  }
39
38
  }
@@ -46,8 +45,9 @@ export class Hooks {
46
45
  * @param callThis
47
46
  */
48
47
  alter(event, value, args = [], callThis = null) {
49
- if (this.listeners.has(event)) {
50
- for (const cb of this.listeners.get(event)) {
48
+ const listeners = this.#listeners[event];
49
+ if (listeners?.length) {
50
+ for (const cb of listeners) {
51
51
  value = cb.call(callThis, value, ...args);
52
52
  }
53
53
  }
@@ -60,10 +60,10 @@ export class Hooks {
60
60
  * @param callThis
61
61
  */
62
62
  async asyncEmit(event, args = [], callThis = null) {
63
- if (this.listeners.has(event)) {
64
- for (const cb of this.listeners.get(event)) {
65
- await cb.call(callThis, ...args);
66
- }
63
+ const listeners = this.#listeners[event];
64
+ if (listeners?.length) {
65
+ const promises = listeners.map((cb) => cb.call(callThis, ...args));
66
+ await Promise.all(promises);
67
67
  }
68
68
  }
69
69
  /**
@@ -74,12 +74,16 @@ export class Hooks {
74
74
  * @param callThis
75
75
  */
76
76
  async asyncAlter(event, value, args = [], callThis = null) {
77
- if (this.listeners.has(event)) {
78
- for (const cb of this.listeners.get(event)) {
77
+ const listeners = this.#listeners[event];
78
+ if (listeners?.length) {
79
+ for (const cb of listeners) {
79
80
  value = await cb.call(callThis, value, ...args);
80
81
  }
81
82
  }
82
83
  return value;
83
84
  }
85
+ destroy() {
86
+ this.#listeners = {};
87
+ }
84
88
  }
85
89
  //# sourceMappingURL=Hooks.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Hooks.js","sourceRoot":"","sources":["../../../src/domain/Hooks.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,KAAK;IAAlB;QACU,cAAS,GAA4B,IAAI,GAAG,EAAE,CAAC;IA8FzD,CAAC;IA5FC;;;;OAIG;IACH,EAAE,CAAC,KAAa,EAAE,EAAY;QAC5B,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;YAC9B,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;SAC/B;QAED,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAEpC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;OAIG;IACH,GAAG,CAAC,KAAa,EAAE,EAAY;QAC7B,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KA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GAAG,IAAI,CAAC,CAAC;aAClC;SACF;IACH,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,UAAU,CAAC,KAAa,EAAE,KAAU,EAAE,OAAiB,EAAE,EAAE,WAAgB,IAAI;QACnF,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;YAC7B,KAAK,MAAM,EAAE,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAE,EAAE;gBAC3C,KAAK,GAAG,MAAM,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC;aACjD;SACF;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF","sourcesContent":["export class Hooks {\n private listeners: Map<string, Function[]> = new Map();\n\n /**\n * Listen a hook event\n * @param event\n * @param cb\n */\n on(event: string, cb: Function) {\n if (!this.listeners.has(event)) {\n this.listeners.set(event, []);\n }\n\n this.listeners.get(event)!.push(cb);\n\n return this;\n }\n\n /**\n * Remove a listener attached to an event\n * @param event\n * @param cb\n */\n off(event: string, cb: Function) {\n if (this.listeners.has(event)) {\n this.listeners.set(\n event,\n this.listeners.get(event)!.filter((item) => item === cb)\n );\n }\n\n return this;\n }\n\n /**\n * Trigger an event and call listener.\n * @param event\n * @param args\n * @param callThis\n */\n emit(event: string, args: any[] = [], callThis: any = null): void {\n if (this.listeners.has(event)) {\n for (const cb of this.listeners.get(event)!) {\n cb.call(callThis, ...args);\n }\n }\n }\n\n /**\n * Trigger an event, listener alter given value and return it.\n * @param event\n * @param value\n * @param args\n * @param callThis\n */\n alter(event: string, value: any, args: any[] = [], callThis: any = null): any {\n if (this.listeners.has(event)) {\n for (const cb of this.listeners.get(event)!) {\n value = cb.call(callThis, value, ...args);\n }\n }\n\n return value;\n }\n\n /**\n * Trigger an event and call async listener.\n * @param event\n * @param args\n * @param callThis\n */\n async asyncEmit(event: string, args: any[] = [], callThis: any = null): Promise<void> {\n if (this.listeners.has(event)) {\n for (const cb of this.listeners.get(event)!) {\n await cb.call(callThis, ...args);\n }\n }\n }\n\n /**\n * Trigger an event, async listener alter given value and return it.\n * @param event\n * @param value\n * @param args\n * @param callThis\n */\n async asyncAlter(event: string, value: any, args: string[] = [], callThis: any = null): Promise<any> {\n if (this.listeners.has(event)) {\n for (const cb of this.listeners.get(event)!) {\n value = await cb.call(callThis, value, ...args);\n }\n }\n\n return value;\n }\n}\n"]}
1
+ {"version":3,"file":"Hooks.js","sourceRoot":"","sources":["../../../src/domain/Hooks.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,KAAK;IAChB,UAAU,GAA+B,EAAE,CAAC;IAE5C;;;;OAIG;IACH,EAAE,CAAC,KAAa,EAAE,EAAY;QAC5B,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE;YAC3B,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;SAC7B;QAED,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAEhC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;OAIG;IACH,GAAG,CAAC,KAAa,EAAE,EAAY;QAC7B,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE;YAC1B,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC;SAC/E;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;OAKG;IACH,IAAI,CAAC,KAAa,EAAE,OAAc,EAAE,EAAE,WAAgB,IAAI;QACxD,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAEzC,IAAI,SAAS,EAAE,MAAM,EAAE;YACrB,KAAK,MAAM,EAAE,IAAI,SAAS,EAAE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;SACF;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO;QACL,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;IACvB,CAAC;CACF","sourcesContent":["export class Hooks {\n #listeners: Record<string, Function[]> = {};\n\n /**\n * Listen a hook event\n * @param event\n * @param cb\n */\n on(event: string, cb: Function) {\n if (!this.#listeners[event]) {\n this.#listeners[event] = [];\n }\n\n this.#listeners[event].push(cb);\n\n return this;\n }\n\n /**\n * Remove a listener attached to an event\n * @param event\n * @param cb\n */\n off(event: string, cb: Function) {\n if (this.#listeners[event]) {\n this.#listeners[event] = this.#listeners[event].filter((item) => item === cb);\n }\n\n return this;\n }\n\n /**\n * Trigger an event and call listener.\n * @param event\n * @param args\n * @param callThis\n */\n emit(event: string, args: any[] = [], callThis: any = null): void {\n const listeners = this.#listeners[event];\n\n if (listeners?.length) {\n for (const cb of listeners) {\n cb.call(callThis, ...args);\n }\n }\n }\n\n /**\n * Trigger an event, listener alter given value and return it.\n * @param event\n * @param value\n * @param args\n * @param callThis\n */\n alter(event: string, value: any, args: any[] = [], callThis: any = null): any {\n const listeners = this.#listeners[event];\n\n if (listeners?.length) {\n for (const cb of listeners) {\n value = cb.call(callThis, value, ...args);\n }\n }\n\n return value;\n }\n\n /**\n * Trigger an event and call async listener.\n * @param event\n * @param args\n * @param callThis\n */\n async asyncEmit(event: string, args: any[] = [], callThis: any = null): Promise<void> {\n const listeners = this.#listeners[event];\n\n if (listeners?.length) {\n const promises = listeners.map((cb) => cb.call(callThis, ...args));\n\n await Promise.all(promises);\n }\n }\n\n /**\n * Trigger an event, async listener alter given value and return it.\n * @param event\n * @param value\n * @param args\n * @param callThis\n */\n async asyncAlter(event: string, value: any, args: any[] = [], callThis: any = null): Promise<any> {\n const listeners = this.#listeners[event];\n\n if (listeners?.length) {\n for (const cb of listeners) {\n value = await cb.call(callThis, value, ...args);\n }\n }\n\n return value;\n }\n\n destroy() {\n this.#listeners = {};\n }\n}\n"]}
@@ -384,6 +384,11 @@ export class Metadata {
384
384
  static setParamTypes(target, propertyKey, value) {
385
385
  return this.set(DESIGN_PARAM_TYPES, value, target.prototype, propertyKey);
386
386
  }
387
+ /**
388
+ * Get all metadata for a metadataKey.
389
+ * @param metadataKey
390
+ */
391
+ static getTargetsFromPropertyKey = (metadataKey) => PROPERTIES.has(metadataKey) ? PROPERTIES.get(metadataKey) || [] : [];
387
392
  /**
388
393
  * Define a unique metadata entry on the target.
389
394
  * @param key A key used to store and retrieve metadata.
@@ -496,9 +501,4 @@ export class Metadata {
496
501
  return Reflect.getOwnMetadata(DESIGN_PARAM_TYPES, target, propertyKey) || [];
497
502
  }
498
503
  }
499
- /**
500
- * Get all metadata for a metadataKey.
501
- * @param metadataKey
502
- */
503
- Metadata.getTargetsFromPropertyKey = (metadataKey) => PROPERTIES.has(metadataKey) ? PROPERTIES.get(metadataKey) || [] : [];
504
504
  //# sourceMappingURL=Metadata.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Metadata.js","sourceRoot":"","sources":["../../../src/domain/Metadata.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAC,OAAO,EAAC,MAAM,0BAA0B,CAAC;AAEjD;;;;GAIG;AACH,MAAM,kBAAkB,GAAG,mBAAmB,CAAC;AAC/C;;;;GAIG;AACH,MAAM,WAAW,GAAG,aAAa,CAAC;AAClC;;;;GAIG;AACH,MAAM,kBAAkB,GAAG,mBAAmB,CAAC;AAE/C;;;;GAIG;AACH,MAAM,UAAU,GAAgC,IAAI,GAAG,EAA0B,CAAC;AAElF;;GAEG;AACH,MAAM,OAAO,QAAQ;IACnB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkCG;IACH,MAAM,CAAC,GAAG,CAAC,GAAW,EAAE,MAAW,EAAE,WAA6B;QAChE,OAAO,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,WAAY,CAAC,CAAC;IACjE,CAAC;IAED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O,CAAC,cAAc,CAAC,GAAG,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,WAAY,CAAC,CAAC;IACpE,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,MAAM,CAAC,aAAa,CAAC,eAAoB,EAAE,WAA6B;QACtE,OAAO,OAAO,CAAC,WAAW,CAAC,kBAAkB,EAAE,eAAe,EAAE,WAAY,CAAC,IAAI,EAAE,CAAC;IACtF,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,MAAM,CAAC,gBAAgB,CAAC,MAAW,EAAE,WAA6B;QAChE,OAAO,OAAO,CAAC,cAAc,CAAC,kBAAkB,EAAE,MAAM,EAAE,WAAY,CAAC,IAAI,EAAE,CAAC;IAChF,CAAC;;AAzHD;;;GAGG;AACI,kCAAyB,GAAG,CAAC,WAA4B,EAAS,EAAE,CACzE,UAAU,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC","sourcesContent":["import \"reflect-metadata\";\nimport {classOf} from \"../utils/objects/classOf\";\n\n/**\n * Metadata key\n * @private\n * @type {string}\n */\nconst DESIGN_PARAM_TYPES = \"design:paramtypes\";\n/**\n * Metadata key\n * @private\n * @type {string}\n */\nconst DESIGN_TYPE = \"design:type\";\n/**\n * Metadata key\n * @private\n * @type {string}\n */\nconst DESIGN_RETURN_TYPE = \"design:returntype\";\n\n/**\n * Properties collections\n * @private\n * @type {string}\n */\nconst PROPERTIES: Map<string | symbol, any[]> = new Map<string | symbol, any[]>();\n\n/**\n * @stable\n */\nexport class Metadata {\n /**\n * Gets the metadata value for the provided metadata key on the target object or its prototype chain.\n * @param key A key used to store and retrieve metadata.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey The property key for the target.\n * @returns The metadata value for the metadata key if found; otherwise, `undefined`.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Metadata.get(\"custom:annotation\", Example);\n *\n * // property (on constructor)\n * result = Metadata.get(\"custom:annotation\", Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Metadata.get(\"custom:annotation\", Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Metadata.get(\"custom:annotation\", Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Metadata.get(\"custom:annotation\", Example.prototype, \"method\");\n * ```\n *\n */\n static get(key: string, target: any, propertyKey?: string | symbol): any {\n return Reflect.getMetadata(key, classOf(target), propertyKey!);\n }\n\n /**\n * Gets the metadata value for the provided metadata key on the target object or its prototype chain.\n * @param key A key used to store and retrieve metadata.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey The property key for the target.\n * @returns The metadata value for the metadata key if found; otherwise, `undefined`.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Metadata.getOwn(\"custom:annotation\", Example);\n *\n * // property (on constructor)\n * result = Metadata.getOwn(\"custom:annotation\", Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Metadata.getOwn(\"custom:annotation\", Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Metadata.getOwn(\"custom:annotation\", Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Metadata.getOwn(\"custom:annotation\", Example.prototype, \"method\");\n * ```\n *\n */\n static getOwn(key: string, target: any, propertyKey?: string | symbol): any {\n return Reflect.getOwnMetadata(key, classOf(target), propertyKey!);\n }\n\n /**\n * Gets the metadata value for the provided metadata DESIGN_TYPE on the target object or its prototype chain.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey The property key for the target.\n * @returns The metadata value for the metadata key if found; otherwise, `undefined`.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // on contructor\n * result = Metadata.getType(Example);\n *\n * // property (on constructor)\n * result = Metadata.getType(Example, \"staticProperty\");\n *\n * // method (on constructor)\n * result = Metadata.getType(Example, \"staticMethod\");\n * ```\n *\n */\n static getType(target: any, propertyKey?: string | symbol): any {\n return Reflect.getMetadata(DESIGN_TYPE, target, propertyKey!);\n }\n\n /**\n * Gets the metadata value for the provided metadata DESIGN_TYPE on the target object or its prototype chain.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey The property key for the target.\n * @returns The metadata value for the metadata key if found; otherwise, `undefined`.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // on contructor\n * result = Metadata.getOwnType(Example);\n *\n * // property (on constructor)\n * result = Metadata.getOwnType(Example, \"staticProperty\");\n *\n * // method (on constructor)\n * result = Metadata.getOwnType(Example, \"staticMethod\");\n * ```\n *\n */\n static getOwnType(target: any, propertyKey?: string | symbol): any {\n return Reflect.getMetadata(DESIGN_TYPE, target, propertyKey!);\n }\n\n /**\n * Gets the metadata value for the provided metadata DESIGN_RETURN_TYPE on the target object or its prototype chain.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey The property key for the target.\n * @returns The metadata value for the metadata key if found; otherwise, `undefined`.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // on contructor\n * result = Metadata.getReturnType(Example);\n *\n * // property (on constructor)\n * result = Metadata.getReturnType(Example, \"staticProperty\");\n *\n * // method (on constructor)\n * result = Metadata.getReturnType(Example, \"staticMethod\");\n * ```\n *\n */\n static getReturnType(target: any, propertyKey?: string | symbol): any {\n return Reflect.getMetadata(DESIGN_RETURN_TYPE, target, propertyKey!);\n }\n\n /**\n * Gets the metadata value for the provided metadata DESIGN_RETURN_TYPE on the target object or its prototype chain.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey The property key for the target.\n * @returns The metadata value for the metadata key if found; otherwise, `undefined`.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // on contructor\n * result = Metadata.getOwnReturnType(Example);\n *\n * // property (on constructor)\n * result = Metadata.getOwnReturnType(Example, \"staticProperty\");\n *\n * // method (on constructor)\n * result = Metadata.getOwnReturnType(Example, \"staticMethod\");\n * ```\n *\n */\n static getOwnReturnType(target: any, propertyKey?: string | symbol): any {\n return Reflect.getOwnMetadata(DESIGN_RETURN_TYPE, target, propertyKey!);\n }\n\n /**\n * Gets a value indicating whether the target object or its prototype chain has the provided metadata key defined.\n * @param key A key used to store and retrieve metadata.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey The property key for the target.\n * @returns `true` if the metadata key was defined on the target object or its prototype chain; otherwise, `false`.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Metadata.has(\"custom:annotation\", Example);\n *\n * // property (on constructor)\n * result = Metadata.has(\"custom:annotation\", Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Metadata.has(\"custom:annotation\", Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Metadata.has(\"custom:annotation\", Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Metadata.has(\"custom:annotation\", Example.prototype, \"method\");\n * ```\n *\n */\n static has(key: string, target: any, propertyKey?: string | symbol): boolean {\n try {\n return Reflect.hasMetadata(key, classOf(target), propertyKey!);\n } catch (er) {}\n\n return false;\n }\n\n /**\n * Gets a value indicating whether the target object or its prototype chain has the provided metadata key defined.\n * @param key A key used to store and retrieve metadata.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey The property key for the target.\n * @returns `true` if the metadata key was defined on the target object or its prototype chain; otherwise, `false`.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Metadata.has(\"custom:annotation\", Example);\n *\n * // property (on constructor)\n * result = Metadata.hasOwn(\"custom:annotation\", Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Metadata.hasOwn(\"custom:annotation\", Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Metadata.hasOwn(\"custom:annotation\", Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Metadata.hasOwn(\"custom:annotation\", Example.prototype, \"method\");\n * ```\n *\n */\n static hasOwn(key: string, target: any, propertyKey?: string | symbol): boolean {\n return Reflect.hasOwnMetadata(key, classOf(target), propertyKey!);\n }\n\n /**\n * Deletes the metadata entry from the target object with the provided key.\n * @param key A key used to store and retrieve metadata.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey The property key for the target.\n * @returns `true` if the metadata entry was found and deleted; otherwise, false.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Metadata.delete(\"custom:annotation\", Example);\n *\n * // property (on constructor)\n * result = Metadata.delete(\"custom:annotation\", Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Metadata.delete(\"custom:annotation\", Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Metadata.delete(\"custom:annotation\", Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Metadata.delete(\"custom:annotation\", Example.prototype, \"method\");\n * ```\n *\n */\n static delete(key: string, target: any, propertyKey?: string | symbol): boolean {\n return Reflect.deleteMetadata(key, classOf(target), propertyKey!);\n }\n\n /**\n * Set the metadata value for the provided metadata DESIGN_PARAM_TYPES on the target object or its prototype chain.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey The property key for the target.\n * @param value A value that contains attached metadata.\n * @returns The metadata value for the metadata key if found; otherwise, `undefined`.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // on contructor\n * result = Metadata.setParamTypes(Example, undefined, [Object]);\n *\n * // property (on constructor)\n * result = Metadata.setParamTypes(Example, \"staticProperty\", [Object]);\n *\n * // property (on prototype)\n * result = Metadata.setParamTypes(Example.prototype, \"property\", [Object]);\n *\n * // method (on constructor)\n * result = Metadata.setParamTypes(Example, \"staticMethod\", [Object]);\n *\n * // method (on prototype)\n * result = Metadata.setParamTypes(Example.prototype, \"method\", [Object]);\n * ```\n *\n */\n static setParamTypes(target: any, propertyKey: string | symbol, value: any): void {\n return this.set(DESIGN_PARAM_TYPES, value, target.prototype, propertyKey);\n }\n\n /**\n * Get all metadata for a metadataKey.\n * @param metadataKey\n */\n static getTargetsFromPropertyKey = (metadataKey: string | symbol): any[] =>\n PROPERTIES.has(metadataKey) ? PROPERTIES.get(metadataKey) || [] : [];\n\n /**\n * Define a unique metadata entry on the target.\n * @param key A key used to store and retrieve metadata.\n * @param value A value that contains attached metadata.\n * @param target The target object on which to define metadata.\n * @param propertyKey The property key for the target.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * Reflect.defineMetadata(\"custom:annotation\", options, Example);\n *\n * // property (on constructor)\n * Reflect.defineMetadata(\"custom:annotation\", Number, Example, \"staticProperty\");\n *\n * // property (on prototype)\n * Reflect.defineMetadata(\"custom:annotation\", Number, Example.prototype, \"property\");\n *\n * // method (on constructor)\n * Reflect.defineMetadata(\"custom:annotation\", Number, Example, \"staticMethod\");\n *\n * // method (on prototype)\n * Reflect.defineMetadata(\"custom:annotation\", Number, Example.prototype, \"method\");\n *\n * // decorator factory as metadata-producing annotation.\n * function MyAnnotation(options): PropertyDecorator {\n * return (target, key) => Reflect.defineMetadata(\"custom:annotation\", options, target, key);\n * }\n * ```\n *\n */\n static set(key: string, value: any, target: any, propertyKey?: string | symbol): void {\n const targets: any[] = PROPERTIES.has(key) ? PROPERTIES.get(key) || [] : [];\n const classConstructor = classOf(target);\n\n if (targets.indexOf(classConstructor) === -1) {\n targets.push(classConstructor);\n PROPERTIES.set(key, targets);\n }\n\n Reflect.defineMetadata(key, value, classOf(target), propertyKey!);\n }\n\n /**\n * Gets the metadata value for the provided metadata DESIGN_PARAM_TYPES on the target object or its prototype chain.\n * @param targetPrototype\n * @param propertyKey The property key for the target.\n * @returns The metadata value for the metadata key if found; otherwise, `undefined`.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // on contructor\n * result = Metadata.getParamTypes(Example.prototype);\n *\n * // property (on constructor)\n * result = Metadata.getParamTypes(Example.prototype, \"staticProperty\");\n *\n * // method (on constructor)\n * result = Metadata.getParamTypes(Example.prototype, \"staticMethod\");\n * ```\n *\n */\n static getParamTypes(targetPrototype: any, propertyKey?: string | symbol): any[] {\n return Reflect.getMetadata(DESIGN_PARAM_TYPES, targetPrototype, propertyKey!) || [];\n }\n\n /**\n * Gets the metadata value for the provided metadata DESIGN_PARAM_TYPES on the target object or its prototype chain.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey The property key for the target.\n * @returns The metadata value for the metadata key if found; otherwise, `undefined`.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // on contructor\n * result = Metadata.getParamTypes(Example);\n *\n * // property (on constructor)\n * result = Metadata.getParamTypes(Example, \"staticProperty\");\n *\n * // method (on constructor)\n * result = Metadata.getParamTypes(Example, \"staticMethod\");\n * ```\n *\n */\n static getOwnParamTypes(target: any, propertyKey?: string | symbol): any[] {\n return Reflect.getOwnMetadata(DESIGN_PARAM_TYPES, target, propertyKey!) || [];\n }\n}\n"]}
1
+ {"version":3,"file":"Metadata.js","sourceRoot":"","sources":["../../../src/domain/Metadata.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAC,OAAO,EAAC,MAAM,0BAA0B,CAAC;AAEjD;;;;GAIG;AACH,MAAM,kBAAkB,GAAG,mBAAmB,CAAC;AAC/C;;;;GAIG;AACH,MAAM,WAAW,GAAG,aAAa,CAAC;AAClC;;;;GAIG;AACH,MAAM,kBAAkB,GAAG,mBAAmB,CAAC;AAE/C;;;;GAIG;AACH,MAAM,UAAU,GAAgC,IAAI,GAAG,EAA0B,CAAC;AAElF;;GAEG;AACH,MAAM,OAAO,QAAQ;IACnB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkCG;IACH,MAAM,CAAC,GAAG,CAAC,GAAW,EAAE,MAAW,EAAE,WAA6B;QAChE,OAAO,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,WAAY,CAAC,CAAC;IACjE,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkCG;IACH,MAAM,CAAC,MAAM,CAAC,GAAW,EAAE,MAAW,EAAE,WAA6B;QACnE,OAAO,OAAO,CAAC,cAAc,CAAC,GAAG,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,WAAY,CAAC,CAAC;IACpE,CAAC;IAED;;;;;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AAC,GAAG,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,WAAY,CAAC,CAAC;IACpE,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,MAAM,CAAC,aAAa,CAAC,eAAoB,EAAE,WAA6B;QACtE,OAAO,OAAO,CAAC,WAAW,CAAC,kBAAkB,EAAE,eAAe,EAAE,WAAY,CAAC,IAAI,EAAE,CAAC;IACtF,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,MAAM,CAAC,gBAAgB,CAAC,MAAW,EAAE,WAA6B;QAChE,OAAO,OAAO,CAAC,cAAc,CAAC,kBAAkB,EAAE,MAAM,EAAE,WAAY,CAAC,IAAI,EAAE,CAAC;IAChF,CAAC","sourcesContent":["import \"reflect-metadata\";\nimport {classOf} from \"../utils/objects/classOf\";\n\n/**\n * Metadata key\n * @private\n * @type {string}\n */\nconst DESIGN_PARAM_TYPES = \"design:paramtypes\";\n/**\n * Metadata key\n * @private\n * @type {string}\n */\nconst DESIGN_TYPE = \"design:type\";\n/**\n * Metadata key\n * @private\n * @type {string}\n */\nconst DESIGN_RETURN_TYPE = \"design:returntype\";\n\n/**\n * Properties collections\n * @private\n * @type {string}\n */\nconst PROPERTIES: Map<string | symbol, any[]> = new Map<string | symbol, any[]>();\n\n/**\n * @stable\n */\nexport class Metadata {\n /**\n * Gets the metadata value for the provided metadata key on the target object or its prototype chain.\n * @param key A key used to store and retrieve metadata.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey The property key for the target.\n * @returns The metadata value for the metadata key if found; otherwise, `undefined`.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Metadata.get(\"custom:annotation\", Example);\n *\n * // property (on constructor)\n * result = Metadata.get(\"custom:annotation\", Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Metadata.get(\"custom:annotation\", Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Metadata.get(\"custom:annotation\", Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Metadata.get(\"custom:annotation\", Example.prototype, \"method\");\n * ```\n *\n */\n static get(key: string, target: any, propertyKey?: string | symbol): any {\n return Reflect.getMetadata(key, classOf(target), propertyKey!);\n }\n\n /**\n * Gets the metadata value for the provided metadata key on the target object or its prototype chain.\n * @param key A key used to store and retrieve metadata.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey The property key for the target.\n * @returns The metadata value for the metadata key if found; otherwise, `undefined`.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Metadata.getOwn(\"custom:annotation\", Example);\n *\n * // property (on constructor)\n * result = Metadata.getOwn(\"custom:annotation\", Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Metadata.getOwn(\"custom:annotation\", Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Metadata.getOwn(\"custom:annotation\", Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Metadata.getOwn(\"custom:annotation\", Example.prototype, \"method\");\n * ```\n *\n */\n static getOwn(key: string, target: any, propertyKey?: string | symbol): any {\n return Reflect.getOwnMetadata(key, classOf(target), propertyKey!);\n }\n\n /**\n * Gets the metadata value for the provided metadata DESIGN_TYPE on the target object or its prototype chain.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey The property key for the target.\n * @returns The metadata value for the metadata key if found; otherwise, `undefined`.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // on contructor\n * result = Metadata.getType(Example);\n *\n * // property (on constructor)\n * result = Metadata.getType(Example, \"staticProperty\");\n *\n * // method (on constructor)\n * result = Metadata.getType(Example, \"staticMethod\");\n * ```\n *\n */\n static getType(target: any, propertyKey?: string | symbol): any {\n return Reflect.getMetadata(DESIGN_TYPE, target, propertyKey!);\n }\n\n /**\n * Gets the metadata value for the provided metadata DESIGN_TYPE on the target object or its prototype chain.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey The property key for the target.\n * @returns The metadata value for the metadata key if found; otherwise, `undefined`.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // on contructor\n * result = Metadata.getOwnType(Example);\n *\n * // property (on constructor)\n * result = Metadata.getOwnType(Example, \"staticProperty\");\n *\n * // method (on constructor)\n * result = Metadata.getOwnType(Example, \"staticMethod\");\n * ```\n *\n */\n static getOwnType(target: any, propertyKey?: string | symbol): any {\n return Reflect.getMetadata(DESIGN_TYPE, target, propertyKey!);\n }\n\n /**\n * Gets the metadata value for the provided metadata DESIGN_RETURN_TYPE on the target object or its prototype chain.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey The property key for the target.\n * @returns The metadata value for the metadata key if found; otherwise, `undefined`.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // on contructor\n * result = Metadata.getReturnType(Example);\n *\n * // property (on constructor)\n * result = Metadata.getReturnType(Example, \"staticProperty\");\n *\n * // method (on constructor)\n * result = Metadata.getReturnType(Example, \"staticMethod\");\n * ```\n *\n */\n static getReturnType(target: any, propertyKey?: string | symbol): any {\n return Reflect.getMetadata(DESIGN_RETURN_TYPE, target, propertyKey!);\n }\n\n /**\n * Gets the metadata value for the provided metadata DESIGN_RETURN_TYPE on the target object or its prototype chain.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey The property key for the target.\n * @returns The metadata value for the metadata key if found; otherwise, `undefined`.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // on contructor\n * result = Metadata.getOwnReturnType(Example);\n *\n * // property (on constructor)\n * result = Metadata.getOwnReturnType(Example, \"staticProperty\");\n *\n * // method (on constructor)\n * result = Metadata.getOwnReturnType(Example, \"staticMethod\");\n * ```\n *\n */\n static getOwnReturnType(target: any, propertyKey?: string | symbol): any {\n return Reflect.getOwnMetadata(DESIGN_RETURN_TYPE, target, propertyKey!);\n }\n\n /**\n * Gets a value indicating whether the target object or its prototype chain has the provided metadata key defined.\n * @param key A key used to store and retrieve metadata.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey The property key for the target.\n * @returns `true` if the metadata key was defined on the target object or its prototype chain; otherwise, `false`.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Metadata.has(\"custom:annotation\", Example);\n *\n * // property (on constructor)\n * result = Metadata.has(\"custom:annotation\", Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Metadata.has(\"custom:annotation\", Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Metadata.has(\"custom:annotation\", Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Metadata.has(\"custom:annotation\", Example.prototype, \"method\");\n * ```\n *\n */\n static has(key: string, target: any, propertyKey?: string | symbol): boolean {\n try {\n return Reflect.hasMetadata(key, classOf(target), propertyKey!);\n } catch (er) {}\n\n return false;\n }\n\n /**\n * Gets a value indicating whether the target object or its prototype chain has the provided metadata key defined.\n * @param key A key used to store and retrieve metadata.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey The property key for the target.\n * @returns `true` if the metadata key was defined on the target object or its prototype chain; otherwise, `false`.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Metadata.has(\"custom:annotation\", Example);\n *\n * // property (on constructor)\n * result = Metadata.hasOwn(\"custom:annotation\", Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Metadata.hasOwn(\"custom:annotation\", Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Metadata.hasOwn(\"custom:annotation\", Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Metadata.hasOwn(\"custom:annotation\", Example.prototype, \"method\");\n * ```\n *\n */\n static hasOwn(key: string, target: any, propertyKey?: string | symbol): boolean {\n return Reflect.hasOwnMetadata(key, classOf(target), propertyKey!);\n }\n\n /**\n * Deletes the metadata entry from the target object with the provided key.\n * @param key A key used to store and retrieve metadata.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey The property key for the target.\n * @returns `true` if the metadata entry was found and deleted; otherwise, false.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Metadata.delete(\"custom:annotation\", Example);\n *\n * // property (on constructor)\n * result = Metadata.delete(\"custom:annotation\", Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Metadata.delete(\"custom:annotation\", Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Metadata.delete(\"custom:annotation\", Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Metadata.delete(\"custom:annotation\", Example.prototype, \"method\");\n * ```\n *\n */\n static delete(key: string, target: any, propertyKey?: string | symbol): boolean {\n return Reflect.deleteMetadata(key, classOf(target), propertyKey!);\n }\n\n /**\n * Set the metadata value for the provided metadata DESIGN_PARAM_TYPES on the target object or its prototype chain.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey The property key for the target.\n * @param value A value that contains attached metadata.\n * @returns The metadata value for the metadata key if found; otherwise, `undefined`.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // on contructor\n * result = Metadata.setParamTypes(Example, undefined, [Object]);\n *\n * // property (on constructor)\n * result = Metadata.setParamTypes(Example, \"staticProperty\", [Object]);\n *\n * // property (on prototype)\n * result = Metadata.setParamTypes(Example.prototype, \"property\", [Object]);\n *\n * // method (on constructor)\n * result = Metadata.setParamTypes(Example, \"staticMethod\", [Object]);\n *\n * // method (on prototype)\n * result = Metadata.setParamTypes(Example.prototype, \"method\", [Object]);\n * ```\n *\n */\n static setParamTypes(target: any, propertyKey: string | symbol, value: any): void {\n return this.set(DESIGN_PARAM_TYPES, value, target.prototype, propertyKey);\n }\n\n /**\n * Get all metadata for a metadataKey.\n * @param metadataKey\n */\n static getTargetsFromPropertyKey = (metadataKey: string | symbol): any[] =>\n PROPERTIES.has(metadataKey) ? PROPERTIES.get(metadataKey) || [] : [];\n\n /**\n * Define a unique metadata entry on the target.\n * @param key A key used to store and retrieve metadata.\n * @param value A value that contains attached metadata.\n * @param target The target object on which to define metadata.\n * @param propertyKey The property key for the target.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * Reflect.defineMetadata(\"custom:annotation\", options, Example);\n *\n * // property (on constructor)\n * Reflect.defineMetadata(\"custom:annotation\", Number, Example, \"staticProperty\");\n *\n * // property (on prototype)\n * Reflect.defineMetadata(\"custom:annotation\", Number, Example.prototype, \"property\");\n *\n * // method (on constructor)\n * Reflect.defineMetadata(\"custom:annotation\", Number, Example, \"staticMethod\");\n *\n * // method (on prototype)\n * Reflect.defineMetadata(\"custom:annotation\", Number, Example.prototype, \"method\");\n *\n * // decorator factory as metadata-producing annotation.\n * function MyAnnotation(options): PropertyDecorator {\n * return (target, key) => Reflect.defineMetadata(\"custom:annotation\", options, target, key);\n * }\n * ```\n *\n */\n static set(key: string, value: any, target: any, propertyKey?: string | symbol): void {\n const targets: any[] = PROPERTIES.has(key) ? PROPERTIES.get(key) || [] : [];\n const classConstructor = classOf(target);\n\n if (targets.indexOf(classConstructor) === -1) {\n targets.push(classConstructor);\n PROPERTIES.set(key, targets);\n }\n\n Reflect.defineMetadata(key, value, classOf(target), propertyKey!);\n }\n\n /**\n * Gets the metadata value for the provided metadata DESIGN_PARAM_TYPES on the target object or its prototype chain.\n * @param targetPrototype\n * @param propertyKey The property key for the target.\n * @returns The metadata value for the metadata key if found; otherwise, `undefined`.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // on contructor\n * result = Metadata.getParamTypes(Example.prototype);\n *\n * // property (on constructor)\n * result = Metadata.getParamTypes(Example.prototype, \"staticProperty\");\n *\n * // method (on constructor)\n * result = Metadata.getParamTypes(Example.prototype, \"staticMethod\");\n * ```\n *\n */\n static getParamTypes(targetPrototype: any, propertyKey?: string | symbol): any[] {\n return Reflect.getMetadata(DESIGN_PARAM_TYPES, targetPrototype, propertyKey!) || [];\n }\n\n /**\n * Gets the metadata value for the provided metadata DESIGN_PARAM_TYPES on the target object or its prototype chain.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey The property key for the target.\n * @returns The metadata value for the metadata key if found; otherwise, `undefined`.\n * @example\n *\n * ```typescript\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // on contructor\n * result = Metadata.getParamTypes(Example);\n *\n * // property (on constructor)\n * result = Metadata.getParamTypes(Example, \"staticProperty\");\n *\n * // method (on constructor)\n * result = Metadata.getParamTypes(Example, \"staticMethod\");\n * ```\n *\n */\n static getOwnParamTypes(target: any, propertyKey?: string | symbol): any[] {\n return Reflect.getOwnMetadata(DESIGN_PARAM_TYPES, target, propertyKey!) || [];\n }\n}\n"]}
@@ -60,9 +60,7 @@ function defineStore(args) {
60
60
  }
61
61
  }
62
62
  export class Store {
63
- constructor() {
64
- this._entries = new Map();
65
- }
63
+ _entries = new Map();
66
64
  /**
67
65
  * Create or get a Store from args {target + methodName + descriptor}
68
66
  * @param args
@@ -1 +1 @@
1
- {"version":3,"file":"Store.js","sourceRoot":"","sources":["../../../src/domain/Store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAC,eAAe,EAAC,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAC,SAAS,EAAC,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAC,SAAS,EAAC,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAC,YAAY,EAAC,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAC,QAAQ,EAAC,MAAM,2BAA2B,CAAC;AACnD,OAAO,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AAGpC;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,kBAAkB,CAAC;AAC9C;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,mBAAmB,CAAC;AAChD;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,qBAAqB,CAAC;AACpD;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,kBAAkB,CAAC;AAE9C,MAAM,MAAM,GAAG,IAAI,GAAG,EAAiB,CAAC;AAExC,SAAS,QAAQ,CAAC,GAAW,EAAE,GAAG,IAAW;IAC3C,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;QACrB,IAAI,CAAC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,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;YAC/D,OAAO;gBACL,GAAG,GAAG;gBACN,CAAC,GAAG,CAAC,EAAE,KAAK;aACb,CAAC;QACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IACT,CAAC;CACF","sourcesContent":["import {DecoratorTypes} from \"../domain/DecoratorTypes\";\nimport {decoratorTypeOf} from \"../utils/decorators/decoratorTypeOf\";\nimport {deepClone} from \"../utils/objects/deepClone\";\nimport {deepMerge} from \"../utils/objects/deepMerge\";\nimport {descriptorOf} from \"../utils/objects/descriptorOf\";\nimport {isSymbol} from \"../utils/objects/isSymbol\";\nimport {nameOf} from \"../utils/objects/nameOf\";\nimport {Metadata} from \"./Metadata\";\nimport type {Type} from \"./Type\";\n\n/**\n * @ignore\n */\nexport const CLASS_STORE = \"tsed:class:store\";\n/**\n * @ignore\n */\nexport const METHOD_STORE = \"tsed:method:store\";\n/**\n * @ignore\n */\nexport const PROPERTY_STORE = \"tsed:property:store\";\n/**\n * @ignore\n */\nexport const PARAM_STORE = \"tsed:param:store\";\n\nconst stores = new Map<symbol, Store>();\n\nfunction storeGet(key: string, ...args: any[]): Store {\n if (isSymbol(args[0])) {\n if (!stores.has(args[0])) {\n stores.set(args[0], new Store());\n }\n\n return stores.get(args[0])!;\n } else {\n const registry = Metadata as any;\n\n if (!registry.hasOwn(key, ...args)) {\n registry.set(key, new Store(), ...args);\n }\n\n return registry.getOwn(key, ...args);\n }\n}\n\nfunction defineStore(args: any[]): Store {\n const [target, propertyKey, descriptor] = args;\n\n switch (decoratorTypeOf(args)) {\n case DecoratorTypes.PARAM_CTOR:\n case DecoratorTypes.PARAM_STC:\n case DecoratorTypes.PARAM:\n const store = storeGet(PARAM_STORE, target, propertyKey);\n if (!store.has(\"\" + descriptor)) {\n store.set(\"\" + descriptor, new Store());\n }\n\n return store.get(\"\" + descriptor);\n case DecoratorTypes.PROP:\n case DecoratorTypes.PROP_STC:\n return storeGet(PROPERTY_STORE, target, propertyKey);\n case DecoratorTypes.METHOD:\n case DecoratorTypes.METHOD_STC:\n return storeGet(METHOD_STORE, target, propertyKey);\n case DecoratorTypes.CLASS:\n return storeGet(CLASS_STORE, target);\n }\n}\n\nexport class Store {\n private _entries = new Map<string, any>();\n /**\n * Create or get a Store from args {target + methodName + descriptor}\n * @param args\n * @returns {Store}\n */\n static from(...args: any[]): Store {\n return defineStore(args);\n }\n\n /**\n * Create store on the method.\n * @param target\n * @param {string} propertyKey\n * @returns {Store}\n */\n static fromMethod(target: any, propertyKey: string | symbol): Store {\n return Store.from(target, propertyKey, descriptorOf(target, propertyKey));\n }\n\n static mergeStoreFrom(target: Type<any>, source: Type<any>, ...args: any[]) {\n const store = Store.from(target, ...args);\n\n Store.from(source, ...args)._entries.forEach((value, key) => {\n store.merge(key, value);\n });\n\n return store;\n }\n\n static mergeStoreMethodFrom(target: Type<any>, source: Type<any>, propertyKey: string | symbol) {\n return this.mergeStoreFrom(target, source, propertyKey, descriptorOf(target, propertyKey));\n }\n\n /**\n * The get() method returns a specified element from a Map object.\n * @param key Required. The key of the element to return from the Map object.\n * @param defaultValue\n * @returns {T} Returns the element associated with the specified key or undefined if the key can't be found in the Map object.\n */\n get<T = any>(key: any, defaultValue?: any): T {\n return this._entries.get(nameOf(key)) || defaultValue;\n }\n\n /**\n * The has() method returns a boolean indicating whether an element with the specified key exists or not.\n * @param key\n * @returns {boolean}\n */\n has(key: any): boolean {\n return this._entries.has(nameOf(key));\n }\n\n /**\n * The set() method adds or updates an element with a specified key and value to a Map object.\n * @param key Required. The key of the element to add to the Map object.\n * @param metadata Required. The value of the element to add to the Map object.\n */\n set(key: any, metadata: any): Store {\n this._entries.set(nameOf(key), metadata);\n\n return this;\n }\n\n /**\n * The delete() method removes the specified element from a Map object.\n * @param key Required. The key of the element to remove from the Map object.\n * @returns {boolean} Returns true if an element in the Map object existed and has been removed, or false if the element does not exist.\n */\n delete(key: string): boolean {\n return this._entries.delete(nameOf(key));\n }\n\n /**\n * Merge given value with existing value.\n * @param key\n * @param value\n * @param inverse Change the merge order. Get the existing value and apply over given value\n * @returns {Store}\n */\n merge(key: any, value: any, inverse: boolean = false): Store {\n let _value_ = this.get(key);\n\n if (_value_) {\n value = deepClone(value);\n _value_ = deepClone(_value_);\n value = inverse ? deepMerge(value, _value_) : deepMerge(_value_, value);\n }\n\n this.set(key, value);\n\n return this;\n }\n\n toJson() {\n return [...this._entries.entries()].reduce((obj, [key, value]) => {\n return {\n ...obj,\n [key]: value\n };\n }, {});\n }\n}\n"]}
1
+ {"version":3,"file":"Store.js","sourceRoot":"","sources":["../../../src/domain/Store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAC,eAAe,EAAC,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAC,SAAS,EAAC,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAC,SAAS,EAAC,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAC,YAAY,EAAC,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAC,QAAQ,EAAC,MAAM,2BAA2B,CAAC;AACnD,OAAO,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AAGpC;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,kBAAkB,CAAC;AAC9C;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,mBAAmB,CAAC;AAChD;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,qBAAqB,CAAC;AACpD;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,kBAAkB,CAAC;AAE9C,MAAM,MAAM,GAAG,IAAI,GAAG,EAAiB,CAAC;AAExC,SAAS,QAAQ,CAAC,GAAW,EAAE,GAAG,IAAW;IAC3C,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;QACrB,IAAI,CAAC,M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C,EAAE,EAAE;YAC/D,OAAO;gBACL,GAAG,GAAG;gBACN,CAAC,GAAG,CAAC,EAAE,KAAK;aACb,CAAC;QACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IACT,CAAC;CACF","sourcesContent":["import {DecoratorTypes} from \"../domain/DecoratorTypes\";\nimport {decoratorTypeOf} from \"../utils/decorators/decoratorTypeOf\";\nimport {deepClone} from \"../utils/objects/deepClone\";\nimport {deepMerge} from \"../utils/objects/deepMerge\";\nimport {descriptorOf} from \"../utils/objects/descriptorOf\";\nimport {isSymbol} from \"../utils/objects/isSymbol\";\nimport {nameOf} from \"../utils/objects/nameOf\";\nimport {Metadata} from \"./Metadata\";\nimport type {Type} from \"./Type\";\n\n/**\n * @ignore\n */\nexport const CLASS_STORE = \"tsed:class:store\";\n/**\n * @ignore\n */\nexport const METHOD_STORE = \"tsed:method:store\";\n/**\n * @ignore\n */\nexport const PROPERTY_STORE = \"tsed:property:store\";\n/**\n * @ignore\n */\nexport const PARAM_STORE = \"tsed:param:store\";\n\nconst stores = new Map<symbol, Store>();\n\nfunction storeGet(key: string, ...args: any[]): Store {\n if (isSymbol(args[0])) {\n if (!stores.has(args[0])) {\n stores.set(args[0], new Store());\n }\n\n return stores.get(args[0])!;\n } else {\n const registry = Metadata as any;\n\n if (!registry.hasOwn(key, ...args)) {\n registry.set(key, new Store(), ...args);\n }\n\n return registry.getOwn(key, ...args);\n }\n}\n\nfunction defineStore(args: any[]): Store {\n const [target, propertyKey, descriptor] = args;\n\n switch (decoratorTypeOf(args)) {\n case DecoratorTypes.PARAM_CTOR:\n case DecoratorTypes.PARAM_STC:\n case DecoratorTypes.PARAM:\n const store = storeGet(PARAM_STORE, target, propertyKey);\n if (!store.has(\"\" + descriptor)) {\n store.set(\"\" + descriptor, new Store());\n }\n\n return store.get(\"\" + descriptor);\n case DecoratorTypes.PROP:\n case DecoratorTypes.PROP_STC:\n return storeGet(PROPERTY_STORE, target, propertyKey);\n case DecoratorTypes.METHOD:\n case DecoratorTypes.METHOD_STC:\n return storeGet(METHOD_STORE, target, propertyKey);\n case DecoratorTypes.CLASS:\n return storeGet(CLASS_STORE, target);\n }\n}\n\nexport class Store {\n private _entries = new Map<string, any>();\n /**\n * Create or get a Store from args {target + methodName + descriptor}\n * @param args\n * @returns {Store}\n */\n static from(...args: any[]): Store {\n return defineStore(args);\n }\n\n /**\n * Create store on the method.\n * @param target\n * @param {string} propertyKey\n * @returns {Store}\n */\n static fromMethod(target: any, propertyKey: string | symbol): Store {\n return Store.from(target, propertyKey, descriptorOf(target, propertyKey));\n }\n\n static mergeStoreFrom(target: Type<any>, source: Type<any>, ...args: any[]) {\n const store = Store.from(target, ...args);\n\n Store.from(source, ...args)._entries.forEach((value, key) => {\n store.merge(key, value);\n });\n\n return store;\n }\n\n static mergeStoreMethodFrom(target: Type<any>, source: Type<any>, propertyKey: string | symbol) {\n return this.mergeStoreFrom(target, source, propertyKey, descriptorOf(target, propertyKey));\n }\n\n /**\n * The get() method returns a specified element from a Map object.\n * @param key Required. The key of the element to return from the Map object.\n * @param defaultValue\n * @returns {T} Returns the element associated with the specified key or undefined if the key can't be found in the Map object.\n */\n get<T = any>(key: any, defaultValue?: any): T {\n return this._entries.get(nameOf(key)) || defaultValue;\n }\n\n /**\n * The has() method returns a boolean indicating whether an element with the specified key exists or not.\n * @param key\n * @returns {boolean}\n */\n has(key: any): boolean {\n return this._entries.has(nameOf(key));\n }\n\n /**\n * The set() method adds or updates an element with a specified key and value to a Map object.\n * @param key Required. The key of the element to add to the Map object.\n * @param metadata Required. The value of the element to add to the Map object.\n */\n set(key: any, metadata: any): Store {\n this._entries.set(nameOf(key), metadata);\n\n return this;\n }\n\n /**\n * The delete() method removes the specified element from a Map object.\n * @param key Required. The key of the element to remove from the Map object.\n * @returns {boolean} Returns true if an element in the Map object existed and has been removed, or false if the element does not exist.\n */\n delete(key: string): boolean {\n return this._entries.delete(nameOf(key));\n }\n\n /**\n * Merge given value with existing value.\n * @param key\n * @param value\n * @param inverse Change the merge order. Get the existing value and apply over given value\n * @returns {Store}\n */\n merge(key: any, value: any, inverse: boolean = false): Store {\n let _value_ = this.get(key);\n\n if (_value_) {\n value = deepClone(value);\n _value_ = deepClone(_value_);\n value = inverse ? deepMerge(value, _value_) : deepMerge(_value_, value);\n }\n\n this.set(key, value);\n\n return this;\n }\n\n toJson() {\n return [...this._entries.entries()].reduce((obj, [key, value]) => {\n return {\n ...obj,\n [key]: value\n };\n }, {});\n }\n}\n"]}
@@ -2,6 +2,7 @@ import { decoratorTypeOf } from "../utils/decorators/decoratorTypeOf.js";
2
2
  import { classOf } from "../utils/objects/classOf.js";
3
3
  import { nameOf } from "../utils/objects/nameOf.js";
4
4
  export class UnsupportedDecoratorType extends Error {
5
+ name;
5
6
  constructor(decorator, args) {
6
7
  super(UnsupportedDecoratorType.buildMessage(decorator, args));
7
8
  }
@@ -1 +1 @@
1
- {"version":3,"file":"UnsupportedDecoratorType.js","sourceRoot":"","sources":["../../../src/errors/UnsupportedDecoratorType.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAC,OAAO,EAAC,MAAM,0BAA0B,CAAC;AACjD,OAAO,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AAE/C,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IAGjD,YAAY,SAAc,EAAE,IAAW;QACrC,KAAK,CAAC,wBAAwB,CAAC,YAAY,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC;IAChE,CAAC;IAEO,MAAM,CAAC,YAAY,CAAC,SAAc,EAAE,IAAW;QACrD,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC;QAE1C,MAAM,WAAW,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;QAC1C,MAAM,YAAY,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/C,MAAM,KAAK,GAAG,YAAY,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,GAAG,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QACrE,MAAM,IAAI,GAAG,YAAY,KAAK,WAAW,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC;QAChE,MAAM,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,GAAG,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC;QAEtD,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM,GAAG,KAAK,CAAC;QAEtD,OAAO,GAAG,SAAS,CAAC,IAAI,sBAAsB,WAAW,iBAAiB,IAAI,EAAE,CAAC;IACnF,CAAC;CACF","sourcesContent":["import {decoratorTypeOf} from \"../utils/decorators/decoratorTypeOf\";\nimport {classOf} from \"../utils/objects/classOf\";\nimport {nameOf} from \"../utils/objects/nameOf\";\n\nexport class UnsupportedDecoratorType extends Error {\n name: \"UNSUPPORTED_DECORATOR_TYPE\";\n\n constructor(decorator: any, args: any[]) {\n super(UnsupportedDecoratorType.buildMessage(decorator, args));\n }\n\n private static buildMessage(decorator: any, args: any[]): string {\n const [target, propertyKey, index] = args;\n\n const bindingType = decoratorTypeOf(args);\n const shortBinding = bindingType.split(\"/\")[0];\n const param = shortBinding === \"parameter\" ? \".[\" + index + \"]\" : \"\";\n const cstr = shortBinding === \"parameter\" ? \".constructor\" : \"\";\n const method = propertyKey ? \".\" + propertyKey : cstr;\n\n const path = nameOf(classOf(target)) + method + param;\n\n return `${decorator.name} cannot be used as ${bindingType} decorator on ${path}`;\n }\n}\n"]}
1
+ {"version":3,"file":"UnsupportedDecoratorType.js","sourceRoot":"","sources":["../../../src/errors/UnsupportedDecoratorType.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAC,OAAO,EAAC,MAAM,0BAA0B,CAAC;AACjD,OAAO,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AAE/C,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IACjD,IAAI,CAA+B;IAEnC,YAAY,SAAc,EAAE,IAAW;QACrC,KAAK,CAAC,wBAAwB,CAAC,YAAY,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC;IAChE,CAAC;IAEO,MAAM,CAAC,YAAY,CAAC,SAAc,EAAE,IAAW;QACrD,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC;QAE1C,MAAM,WAAW,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;QAC1C,MAAM,YAAY,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/C,MAAM,KAAK,GAAG,YAAY,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,GAAG,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QACrE,MAAM,IAAI,GAAG,YAAY,KAAK,WAAW,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC;QAChE,MAAM,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,GAAG,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC;QAEtD,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM,GAAG,KAAK,CAAC;QAEtD,OAAO,GAAG,SAAS,CAAC,IAAI,sBAAsB,WAAW,iBAAiB,IAAI,EAAE,CAAC;IACnF,CAAC;CACF","sourcesContent":["import {decoratorTypeOf} from \"../utils/decorators/decoratorTypeOf\";\nimport {classOf} from \"../utils/objects/classOf\";\nimport {nameOf} from \"../utils/objects/nameOf\";\n\nexport class UnsupportedDecoratorType extends Error {\n name: \"UNSUPPORTED_DECORATOR_TYPE\";\n\n constructor(decorator: any, args: any[]) {\n super(UnsupportedDecoratorType.buildMessage(decorator, args));\n }\n\n private static buildMessage(decorator: any, args: any[]): string {\n const [target, propertyKey, index] = args;\n\n const bindingType = decoratorTypeOf(args);\n const shortBinding = bindingType.split(\"/\")[0];\n const param = shortBinding === \"parameter\" ? \".[\" + index + \"]\" : \"\";\n const cstr = shortBinding === \"parameter\" ? \".constructor\" : \"\";\n const method = propertyKey ? \".\" + propertyKey : cstr;\n\n const path = nameOf(classOf(target)) + method + param;\n\n return `${decorator.name} cannot be used as ${bindingType} decorator on ${path}`;\n }\n}\n"]}
@@ -1,20 +1,25 @@
1
+ import { Store } from "../../domain/Store.js";
1
2
  import { classOf } from "../objects/classOf.js";
3
+ import { descriptorOf } from "../objects/descriptorOf.js";
2
4
  import { methodsOf } from "../objects/methodsOf.js";
3
5
  import { prototypeOf } from "../objects/prototypeOf.js";
4
- import { descriptorOf } from "../objects/descriptorOf.js";
5
- import { Store } from "../../domain/Store.js";
6
6
  export function decorateMethodsOf(klass, decorator) {
7
7
  methodsOf(klass).forEach(({ target, propertyKey }) => {
8
+ const proto = prototypeOf(klass);
8
9
  if (target !== classOf(klass)) {
9
- Object.defineProperty(prototypeOf(klass), propertyKey, {
10
+ Object.defineProperty(proto, propertyKey, {
10
11
  writable: true,
12
+ configurable: true,
11
13
  value(...args) {
12
14
  return prototypeOf(target)[propertyKey].apply(this, args);
13
15
  }
14
16
  });
15
17
  Store.mergeStoreMethodFrom(klass, target, propertyKey);
16
18
  }
17
- decorator(prototypeOf(klass), propertyKey, descriptorOf(klass, propertyKey));
19
+ const newDescriptor = decorator(proto, propertyKey, descriptorOf(klass, propertyKey));
20
+ if (newDescriptor) {
21
+ Object.defineProperty(proto, propertyKey, newDescriptor);
22
+ }
18
23
  });
19
24
  }
20
25
  //# sourceMappingURL=decorateMethodsOf.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"decorateMethodsOf.js","sourceRoot":"","sources":["../../../../src/utils/decorators/decorateMethodsOf.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAC,SAAS,EAAC,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAC,WAAW,EAAC,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAC,YAAY,EAAC,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAC,KAAK,EAAC,MAAM,oBAAoB,CAAC;AAEzC,MAAM,UAAU,iBAAiB,CAAC,KAAU,EAAE,SAAc;IAC1D,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,EAAC,MAAM,EAAE,WAAW,EAAC,EAAE,EAAE;QACjD,IAAI,MAAM,KAAK,OAAO,CAAC,KAAK,CAAC,EAAE;YAC7B,MAAM,CAAC,cAAc,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,WAAW,EAAE;gBACrD,QAAQ,EAAE,IAAI;gBACd,KAAK,CAAC,GAAG,IAAW;oBAClB,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;gBAC5D,CAAC;aACF,CAAC,CAAC;YAEH,KAAK,CAAC,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;SACxD;QAED,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,WAAW,EAAE,YAAY,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC;IAC/E,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {classOf} from \"../objects/classOf\";\nimport {methodsOf} from \"../objects/methodsOf\";\nimport {prototypeOf} from \"../objects/prototypeOf\";\nimport {descriptorOf} from \"../objects/descriptorOf\";\nimport {Store} from \"../../domain/Store\";\n\nexport function decorateMethodsOf(klass: any, decorator: any) {\n methodsOf(klass).forEach(({target, propertyKey}) => {\n if (target !== classOf(klass)) {\n Object.defineProperty(prototypeOf(klass), propertyKey, {\n writable: true,\n value(...args: any[]) {\n return prototypeOf(target)[propertyKey].apply(this, args);\n }\n });\n\n Store.mergeStoreMethodFrom(klass, target, propertyKey);\n }\n\n decorator(prototypeOf(klass), propertyKey, descriptorOf(klass, propertyKey));\n });\n}\n"]}
1
+ {"version":3,"file":"decorateMethodsOf.js","sourceRoot":"","sources":["../../../../src/utils/decorators/decorateMethodsOf.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAC,OAAO,EAAC,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAC,YAAY,EAAC,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAC,SAAS,EAAC,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAC,WAAW,EAAC,MAAM,wBAAwB,CAAC;AAEnD,MAAM,UAAU,iBAAiB,CAAC,KAAU,EAAE,SAAc;IAC1D,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,EAAC,MAAM,EAAE,WAAW,EAAC,EAAE,EAAE;QACjD,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;QAEjC,IAAI,MAAM,KAAK,OAAO,CAAC,KAAK,CAAC,EAAE;YAC7B,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,WAAW,EAAE;gBACxC,QAAQ,EAAE,IAAI;gBACd,YAAY,EAAE,IAAI;gBAClB,KAAK,CAAC,GAAG,IAAW;oBAClB,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;gBAC5D,CAAC;aACF,CAAC,CAAC;YAEH,KAAK,CAAC,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;SACxD;QAED,MAAM,aAAa,GAAG,SAAS,CAAC,KAAK,EAAE,WAAW,EAAE,YAAY,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC;QAEtF,IAAI,aAAa,EAAE;YACjB,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC;SAC1D;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {Store} from \"../../domain/Store\";\nimport {classOf} from \"../objects/classOf\";\nimport {descriptorOf} from \"../objects/descriptorOf\";\nimport {methodsOf} from \"../objects/methodsOf\";\nimport {prototypeOf} from \"../objects/prototypeOf\";\n\nexport function decorateMethodsOf(klass: any, decorator: any) {\n methodsOf(klass).forEach(({target, propertyKey}) => {\n const proto = prototypeOf(klass);\n\n if (target !== classOf(klass)) {\n Object.defineProperty(proto, propertyKey, {\n writable: true,\n configurable: true,\n value(...args: any[]) {\n return prototypeOf(target)[propertyKey].apply(this, args);\n }\n });\n\n Store.mergeStoreMethodFrom(klass, target, propertyKey);\n }\n\n const newDescriptor = decorator(proto, propertyKey, descriptorOf(klass, propertyKey));\n\n if (newDescriptor) {\n Object.defineProperty(proto, propertyKey, newDescriptor);\n }\n });\n}\n"]}
@@ -8,7 +8,6 @@ export function descriptorOf(target, propertyKey) {
8
8
  return Object.getOwnPropertyDescriptor((target && target.prototype) || target, propertyKey);
9
9
  }
10
10
  export function isMethodDescriptor(target, propertyKey) {
11
- var _a;
12
- return (_a = descriptorOf(target, propertyKey)) === null || _a === void 0 ? void 0 : _a.value;
11
+ return descriptorOf(target, propertyKey)?.value;
13
12
  }
14
13
  //# sourceMappingURL=descriptorOf.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"descriptorOf.js","sourceRoot":"","sources":["../../../../src/utils/objects/descriptorOf.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,MAAW,EAAE,WAA4B;IACpE,OAAO,MAAM,CAAC,wBAAwB,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,SAAS,CAAC,IAAI,MAAM,EAAE,WAAW,CAAE,CAAC;AAC/F,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,MAAW,EAAE,WAA4B;;IAC1E,OAAO,MAAA,YAAY,CAAC,MAAM,EAAE,WAAW,CAAC,0CAAE,KAAK,CAAC;AAClD,CAAC","sourcesContent":["/**\n * Return the descriptor for a given class and propertyKey\n * @param target\n * @param {string} propertyKey\n * @returns {PropertyDescriptor}\n */\nexport function descriptorOf(target: any, propertyKey: string | symbol): PropertyDescriptor {\n return Object.getOwnPropertyDescriptor((target && target.prototype) || target, propertyKey)!;\n}\n\nexport function isMethodDescriptor(target: any, propertyKey: string | symbol) {\n return descriptorOf(target, propertyKey)?.value;\n}\n"]}
1
+ {"version":3,"file":"descriptorOf.js","sourceRoot":"","sources":["../../../../src/utils/objects/descriptorOf.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,MAAW,EAAE,WAA4B;IACpE,OAAO,MAAM,CAAC,wBAAwB,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,SAAS,CAAC,IAAI,MAAM,EAAE,WAAW,CAAE,CAAC;AAC/F,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,MAAW,EAAE,WAA4B;IAC1E,OAAO,YAAY,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE,KAAK,CAAC;AAClD,CAAC","sourcesContent":["/**\n * Return the descriptor for a given class and propertyKey\n * @param target\n * @param {string} propertyKey\n * @returns {PropertyDescriptor}\n */\nexport function descriptorOf(target: any, propertyKey: string | symbol): PropertyDescriptor {\n return Object.getOwnPropertyDescriptor((target && target.prototype) || target, propertyKey)!;\n}\n\nexport function isMethodDescriptor(target: any, propertyKey: string | symbol) {\n return descriptorOf(target, propertyKey)?.value;\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  export declare class Hooks {
2
- private listeners;
2
+ #private;
3
3
  /**
4
4
  * Listen a hook event
5
5
  * @param event
@@ -41,5 +41,6 @@ export declare class Hooks {
41
41
  * @param args
42
42
  * @param callThis
43
43
  */
44
- asyncAlter(event: string, value: any, args?: string[], callThis?: any): Promise<any>;
44
+ asyncAlter(event: string, value: any, args?: any[], callThis?: any): Promise<any>;
45
+ destroy(): void;
45
46
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsed/core",
3
- "version": "7.0.0-beta.9",
3
+ "version": "7.0.0-rc.3",
4
4
  "description": "Core module for Ts.ED Framework",
5
5
  "private": false,
6
6
  "source": "./src/index.ts",
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "reflect-metadata": "^0.1.13",
25
- "tslib": "2.3.1"
25
+ "tslib": "2.4.0"
26
26
  },
27
27
  "devDependencies": {},
28
28
  "peerDependencies": {},
@@ -30,7 +30,10 @@
30
30
  "bugs": {
31
31
  "url": "https://github.com/tsedio/tsed/issues"
32
32
  },
33
- "homepage": "https://github.com/tsedio/tsed/tree/beta/packages/core",
33
+ "homepage": "https://github.com/tsedio/tsed/tree/rc/packages/core",
34
34
  "author": "Romain Lenzotti",
35
- "license": "MIT"
35
+ "license": "MIT",
36
+ "publishConfig": {
37
+ "tag": "rc"
38
+ }
36
39
  }
package/readme.md CHANGED
@@ -11,7 +11,8 @@
11
11
  [![npm version](https://badge.fury.io/js/%40tsed%2Fcommon.svg)](https://badge.fury.io/js/%40tsed%2Fcommon)
12
12
  [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
13
13
  [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
14
- [![backers](https://opencollective.com/tsed/tiers/badge.svg)](https://opencollective.com/tsed)
14
+ [![github](https://img.shields.io/static/v1?label=Github%20sponsor&message=%E2%9D%A4&logo=GitHub&color=%23fe8e86)](https://github.com/sponsors/romakita)
15
+ [![opencollective](https://img.shields.io/static/v1?label=OpenCollective%20sponsor&message=%E2%9D%A4&logo=OpenCollective&color=%23fe8e86)](https://opencollective.com/tsed)
15
16
 
16
17
  </div>
17
18
 
@@ -55,7 +56,7 @@ Support this project by becoming a sponsor. Your logo will show up here with a l
55
56
 
56
57
  The MIT License (MIT)
57
58
 
58
- Copyright (c) 2016 - 2018 Romain Lenzotti
59
+ Copyright (c) 2016 - 2022 Romain Lenzotti
59
60
 
60
61
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
61
62