@quadnix/octo 0.0.20 → 0.0.22

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 (201) hide show
  1. package/dist/app.type.d.ts +8 -1
  2. package/dist/app.type.js +13 -7
  3. package/dist/app.type.js.map +1 -1
  4. package/dist/decorators/action.decorator.d.ts +19 -2
  5. package/dist/decorators/action.decorator.js +28 -5
  6. package/dist/decorators/action.decorator.js.map +1 -1
  7. package/dist/decorators/anchor.decorator.d.ts +13 -0
  8. package/dist/decorators/anchor.decorator.js +14 -1
  9. package/dist/decorators/anchor.decorator.js.map +1 -1
  10. package/dist/decorators/enable-hook.decorator.d.ts +14 -0
  11. package/dist/decorators/enable-hook.decorator.js +14 -0
  12. package/dist/decorators/enable-hook.decorator.js.map +1 -1
  13. package/dist/decorators/event-source.decorator.d.ts +15 -0
  14. package/dist/decorators/event-source.decorator.js +15 -0
  15. package/dist/decorators/event-source.decorator.js.map +1 -1
  16. package/dist/decorators/factory.decorator.d.ts +54 -5
  17. package/dist/decorators/factory.decorator.js +56 -3
  18. package/dist/decorators/factory.decorator.js.map +1 -1
  19. package/dist/decorators/model.decorator.d.ts +13 -0
  20. package/dist/decorators/model.decorator.js +14 -1
  21. package/dist/decorators/model.decorator.js.map +1 -1
  22. package/dist/decorators/module.decorator.d.ts +61 -5
  23. package/dist/decorators/module.decorator.js +62 -3
  24. package/dist/decorators/module.decorator.js.map +1 -1
  25. package/dist/decorators/on-event.decorator.d.ts +17 -0
  26. package/dist/decorators/on-event.decorator.js +17 -0
  27. package/dist/decorators/on-event.decorator.js.map +1 -1
  28. package/dist/decorators/overlay.decorator.d.ts +13 -0
  29. package/dist/decorators/overlay.decorator.js +14 -1
  30. package/dist/decorators/overlay.decorator.js.map +1 -1
  31. package/dist/decorators/resource.decorator.d.ts +13 -0
  32. package/dist/decorators/resource.decorator.js +14 -1
  33. package/dist/decorators/resource.decorator.js.map +1 -1
  34. package/dist/decorators/validate.decorator.d.ts +9 -0
  35. package/dist/decorators/validate.decorator.js +23 -0
  36. package/dist/decorators/validate.decorator.js.map +1 -0
  37. package/dist/events/error.event.d.ts +30 -0
  38. package/dist/events/error.event.js +30 -0
  39. package/dist/events/error.event.js.map +1 -1
  40. package/dist/events/event.model.d.ts +27 -0
  41. package/dist/events/event.model.js +27 -3
  42. package/dist/events/event.model.js.map +1 -1
  43. package/dist/events/hook.event.d.ts +167 -0
  44. package/dist/events/hook.event.js +167 -0
  45. package/dist/events/hook.event.js.map +1 -1
  46. package/dist/events/module.event.d.ts +12 -0
  47. package/dist/events/module.event.js +12 -0
  48. package/dist/events/module.event.js.map +1 -1
  49. package/dist/events/registration.event.d.ts +90 -0
  50. package/dist/events/registration.event.js +90 -0
  51. package/dist/events/registration.event.js.map +1 -1
  52. package/dist/events/serialization.event.d.ts +61 -0
  53. package/dist/events/serialization.event.js +61 -0
  54. package/dist/events/serialization.event.js.map +1 -1
  55. package/dist/events/transaction.event.d.ts +41 -0
  56. package/dist/events/transaction.event.js +41 -0
  57. package/dist/events/transaction.event.js.map +1 -1
  58. package/dist/functions/container/container.d.ts +53 -0
  59. package/dist/functions/container/container.js +102 -0
  60. package/dist/functions/container/container.js.map +1 -0
  61. package/dist/functions/container/test-container.d.ts +75 -0
  62. package/dist/functions/container/test-container.js +97 -0
  63. package/dist/functions/container/test-container.js.map +1 -0
  64. package/dist/functions/dependency/dependency.d.ts +6 -6
  65. package/dist/functions/dependency/dependency.js +1 -8
  66. package/dist/functions/dependency/dependency.js.map +1 -1
  67. package/dist/functions/diff/diff-metadata.d.ts +5 -2
  68. package/dist/functions/diff/diff-metadata.js +6 -11
  69. package/dist/functions/diff/diff-metadata.js.map +1 -1
  70. package/dist/functions/diff/diff.d.ts +6 -3
  71. package/dist/functions/diff/diff.js +8 -13
  72. package/dist/functions/diff/diff.js.map +1 -1
  73. package/dist/functions/diff/diff.utility.d.ts +38 -6
  74. package/dist/functions/diff/diff.utility.js +55 -6
  75. package/dist/functions/diff/diff.utility.js.map +1 -1
  76. package/dist/functions/hook/commit.hook.js +6 -3
  77. package/dist/functions/hook/commit.hook.js.map +1 -1
  78. package/dist/functions/hook/model-action.hook.js +7 -4
  79. package/dist/functions/hook/model-action.hook.js.map +1 -1
  80. package/dist/functions/hook/resource-action.hook.js +6 -3
  81. package/dist/functions/hook/resource-action.hook.js.map +1 -1
  82. package/dist/functions/node/node.abstract.d.ts +84 -0
  83. package/dist/functions/node/node.abstract.js +275 -0
  84. package/dist/functions/node/node.abstract.js.map +1 -0
  85. package/dist/functions/node/node.interface.d.ts +176 -0
  86. package/dist/functions/node/node.interface.js +2 -0
  87. package/dist/functions/node/node.interface.js.map +1 -0
  88. package/dist/index.d.ts +12 -12
  89. package/dist/index.js +11 -11
  90. package/dist/index.js.map +1 -1
  91. package/dist/main.d.ts +11 -10
  92. package/dist/main.js +76 -37
  93. package/dist/main.js.map +1 -1
  94. package/dist/models/app/app.interface.d.ts +5 -0
  95. package/dist/models/app/app.model.d.ts +30 -3
  96. package/dist/models/app/app.model.js +40 -6
  97. package/dist/models/app/app.model.js.map +1 -1
  98. package/dist/models/deployment/deployment.interface.d.ts +5 -0
  99. package/dist/models/deployment/deployment.model.d.ts +16 -3
  100. package/dist/models/deployment/deployment.model.js +20 -6
  101. package/dist/models/deployment/deployment.model.js.map +1 -1
  102. package/dist/models/environment/environment.interface.d.ts +5 -0
  103. package/dist/models/environment/environment.model.d.ts +19 -3
  104. package/dist/models/environment/environment.model.js +33 -8
  105. package/dist/models/environment/environment.model.js.map +1 -1
  106. package/dist/models/execution/execution.interface.d.ts +5 -0
  107. package/dist/models/execution/execution.model.d.ts +24 -3
  108. package/dist/models/execution/execution.model.js +40 -7
  109. package/dist/models/execution/execution.model.js.map +1 -1
  110. package/dist/models/image/image.interface.d.ts +5 -0
  111. package/dist/models/image/image.model.d.ts +36 -3
  112. package/dist/models/image/image.model.js +25 -9
  113. package/dist/models/image/image.model.js.map +1 -1
  114. package/dist/models/model-action.interface.d.ts +18 -1
  115. package/dist/models/model.abstract.d.ts +7 -42
  116. package/dist/models/model.abstract.js +24 -295
  117. package/dist/models/model.abstract.js.map +1 -1
  118. package/dist/models/model.interface.d.ts +51 -11
  119. package/dist/models/pipeline/pipeline.interface.d.ts +5 -0
  120. package/dist/models/pipeline/pipeline.model.d.ts +16 -3
  121. package/dist/models/pipeline/pipeline.model.js +25 -8
  122. package/dist/models/pipeline/pipeline.model.js.map +1 -1
  123. package/dist/models/region/region.interface.d.ts +5 -0
  124. package/dist/models/region/region.model.d.ts +19 -3
  125. package/dist/models/region/region.model.js +29 -6
  126. package/dist/models/region/region.model.js.map +1 -1
  127. package/dist/models/server/server.interface.d.ts +5 -0
  128. package/dist/models/server/server.model.d.ts +18 -3
  129. package/dist/models/server/server.model.js +24 -6
  130. package/dist/models/server/server.model.js.map +1 -1
  131. package/dist/models/service/service.interface.d.ts +5 -0
  132. package/dist/models/service/service.model.d.ts +16 -3
  133. package/dist/models/service/service.model.js +19 -6
  134. package/dist/models/service/service.model.js.map +1 -1
  135. package/dist/models/subnet/subnet.interface.d.ts +5 -0
  136. package/dist/models/subnet/subnet.model.d.ts +50 -3
  137. package/dist/models/subnet/subnet.model.js +58 -22
  138. package/dist/models/subnet/subnet.model.js.map +1 -1
  139. package/dist/modules/module.container.d.ts +4 -2
  140. package/dist/modules/module.container.js +17 -8
  141. package/dist/modules/module.container.js.map +1 -1
  142. package/dist/modules/test-module.container.d.ts +4 -4
  143. package/dist/modules/test-module.container.js +18 -17
  144. package/dist/modules/test-module.container.js.map +1 -1
  145. package/dist/overlays/anchor.abstract.js +0 -3
  146. package/dist/overlays/anchor.abstract.js.map +1 -1
  147. package/dist/overlays/overlay-data.repository.d.ts +2 -4
  148. package/dist/overlays/overlay-data.repository.js +8 -36
  149. package/dist/overlays/overlay-data.repository.js.map +1 -1
  150. package/dist/overlays/overlay.abstract.d.ts +6 -7
  151. package/dist/overlays/overlay.abstract.js +20 -42
  152. package/dist/overlays/overlay.abstract.js.map +1 -1
  153. package/dist/overlays/overlay.service.d.ts +0 -1
  154. package/dist/overlays/overlay.service.js +1 -7
  155. package/dist/overlays/overlay.service.js.map +1 -1
  156. package/dist/resources/resource-data.repository.d.ts +16 -6
  157. package/dist/resources/resource-data.repository.js +121 -18
  158. package/dist/resources/resource-data.repository.js.map +1 -1
  159. package/dist/resources/resource.abstract.d.ts +23 -6
  160. package/dist/resources/resource.abstract.js +147 -13
  161. package/dist/resources/resource.abstract.js.map +1 -1
  162. package/dist/resources/shared-resource.abstract.d.ts +2 -2
  163. package/dist/resources/shared-resource.abstract.js +5 -2
  164. package/dist/resources/shared-resource.abstract.js.map +1 -1
  165. package/dist/services/capture/capture.service.d.ts +1 -2
  166. package/dist/services/capture/capture.service.js +5 -4
  167. package/dist/services/capture/capture.service.js.map +1 -1
  168. package/dist/services/event/event.service.js +9 -6
  169. package/dist/services/event/event.service.js.map +1 -1
  170. package/dist/services/input/input.service.js +3 -5
  171. package/dist/services/input/input.service.js.map +1 -1
  172. package/dist/services/serialization/model/model-serialization.service.js +13 -14
  173. package/dist/services/serialization/model/model-serialization.service.js.map +1 -1
  174. package/dist/services/serialization/resource/resource-serialization.service.d.ts +4 -4
  175. package/dist/services/serialization/resource/resource-serialization.service.js +23 -13
  176. package/dist/services/serialization/resource/resource-serialization.service.js.map +1 -1
  177. package/dist/services/state-management/local.state-provider.js +0 -1
  178. package/dist/services/state-management/local.state-provider.js.map +1 -1
  179. package/dist/services/state-management/state-management.service.d.ts +1 -1
  180. package/dist/services/state-management/state-management.service.js +6 -9
  181. package/dist/services/state-management/state-management.service.js.map +1 -1
  182. package/dist/services/state-management/test.state-provider.js +3 -1
  183. package/dist/services/state-management/test.state-provider.js.map +1 -1
  184. package/dist/services/transaction/transaction.service.d.ts +5 -2
  185. package/dist/services/transaction/transaction.service.js +117 -87
  186. package/dist/services/transaction/transaction.service.js.map +1 -1
  187. package/dist/services/validation/validation.service.d.ts +19 -0
  188. package/dist/services/validation/validation.service.js +66 -0
  189. package/dist/services/validation/validation.service.js.map +1 -0
  190. package/dist/utilities/object/object.utility.js +1 -0
  191. package/dist/utilities/object/object.utility.js.map +1 -1
  192. package/dist/utilities/validation/validation.utility.d.ts +5 -0
  193. package/dist/utilities/validation/validation.utility.js +12 -0
  194. package/dist/utilities/validation/validation.utility.js.map +1 -0
  195. package/package.json +1 -1
  196. package/dist/decorators/container.d.ts +0 -24
  197. package/dist/decorators/container.js +0 -96
  198. package/dist/decorators/container.js.map +0 -1
  199. package/dist/decorators/test-container.d.ts +0 -27
  200. package/dist/decorators/test-container.js +0 -52
  201. package/dist/decorators/test-container.js.map +0 -1
@@ -1,4 +1,5 @@
1
1
  import type { IDependency } from './functions/dependency/dependency.js';
2
+ import type { ANode } from './functions/node/node.abstract.js';
2
3
  import type { IAnchor } from './overlays/anchor.interface.js';
3
4
  import type { AOverlay } from './overlays/overlay.abstract.js';
4
5
  import type { AModel } from './models/model.abstract.js';
@@ -7,12 +8,17 @@ import type { IOverlay } from './overlays/overlay.interface.js';
7
8
  import type { AResource } from './resources/resource.abstract.js';
8
9
  import type { IResource } from './resources/resource.interface.js';
9
10
  import type { ASharedResource } from './resources/shared-resource.abstract.js';
10
- export declare enum ModelType {
11
+ export declare enum NodeType {
11
12
  MODEL = "model",
12
13
  OVERLAY = "overlay",
13
14
  RESOURCE = "resource",
14
15
  SHARED_RESOURCE = "shared-resource"
15
16
  }
17
+ export declare enum ValidationType {
18
+ MAX_LENGTH = "maxLength",
19
+ MIN_LENGTH = "minLength",
20
+ REGEX = "regex"
21
+ }
16
22
  export type ActionInputs = {
17
23
  [key: string]: string | UnknownResource;
18
24
  };
@@ -63,6 +69,7 @@ export type TransactionOptions = {
63
69
  };
64
70
  export type IUnknownModel = IModel<unknown, unknown>;
65
71
  export type UnknownModel = AModel<unknown, unknown>;
72
+ export type UnknownNode = ANode<unknown, unknown>;
66
73
  export type UnknownOverlay = AOverlay<unknown>;
67
74
  export type UnknownResource = AResource<unknown>;
68
75
  export type UnknownSharedResource = ASharedResource<unknown>;
package/dist/app.type.js CHANGED
@@ -1,8 +1,14 @@
1
- export var ModelType;
2
- (function (ModelType) {
3
- ModelType["MODEL"] = "model";
4
- ModelType["OVERLAY"] = "overlay";
5
- ModelType["RESOURCE"] = "resource";
6
- ModelType["SHARED_RESOURCE"] = "shared-resource";
7
- })(ModelType || (ModelType = {}));
1
+ export var NodeType;
2
+ (function (NodeType) {
3
+ NodeType["MODEL"] = "model";
4
+ NodeType["OVERLAY"] = "overlay";
5
+ NodeType["RESOURCE"] = "resource";
6
+ NodeType["SHARED_RESOURCE"] = "shared-resource";
7
+ })(NodeType || (NodeType = {}));
8
+ export var ValidationType;
9
+ (function (ValidationType) {
10
+ ValidationType["MAX_LENGTH"] = "maxLength";
11
+ ValidationType["MIN_LENGTH"] = "minLength";
12
+ ValidationType["REGEX"] = "regex";
13
+ })(ValidationType || (ValidationType = {}));
8
14
  //# sourceMappingURL=app.type.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"app.type.js","sourceRoot":"","sources":["../src/app.type.ts"],"names":[],"mappings":"AAUA,MAAM,CAAN,IAAY,SAKX;AALD,WAAY,SAAS;IACnB,4BAAe,CAAA;IACf,gCAAmB,CAAA;IACnB,kCAAqB,CAAA;IACrB,gDAAmC,CAAA;AACrC,CAAC,EALW,SAAS,KAAT,SAAS,QAKpB"}
1
+ {"version":3,"file":"app.type.js","sourceRoot":"","sources":["../src/app.type.ts"],"names":[],"mappings":"AAWA,MAAM,CAAN,IAAY,QAKX;AALD,WAAY,QAAQ;IAClB,2BAAe,CAAA;IACf,+BAAmB,CAAA;IACnB,iCAAqB,CAAA;IACrB,+CAAmC,CAAA;AACrC,CAAC,EALW,QAAQ,KAAR,QAAQ,QAKnB;AAED,MAAM,CAAN,IAAY,cAIX;AAJD,WAAY,cAAc;IACxB,0CAAwB,CAAA;IACxB,0CAAwB,CAAA;IACxB,iCAAe,CAAA;AACjB,CAAC,EAJW,cAAc,KAAd,cAAc,QAIzB"}
@@ -1,2 +1,19 @@
1
- import { ModelType } from '../app.type.js';
2
- export declare function Action(type: ModelType): (constructor: any) => void;
1
+ import { NodeType } from '../app.type.js';
2
+ /**
3
+ * An `@Action` is a class decorator to be placed on top of a class that represents an action of one of ModelType.
4
+ * - A NodeType.MODEL action must implement the {@link IModelAction} interface.
5
+ * - A NodeType.OVERLAY action must implement the {@link IModelAction} interface.
6
+ * - A NodeType.RESOURCE action must implement the {@link IResourceAction} interface.
7
+ * - A NodeType.SHARED_RESOURCE action must implement the {@link IResourceAction} interface.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * @Action(ModelType.MODEL)
12
+ * export class MyModelAction implements IModelAction { ... }
13
+ * ```
14
+ * @group Decorators
15
+ * @param type The type of Model being decorated.
16
+ * @returns The decorated class.
17
+ * @see Definition of [Actions](/docs/fundamentals/actions).
18
+ */
19
+ export declare function Action(type: NodeType): (constructor: any) => void;
@@ -1,30 +1,53 @@
1
- import { ModelType } from '../app.type.js';
1
+ import { NodeType } from '../app.type.js';
2
2
  import { RegistrationErrorEvent } from '../events/error.event.js';
3
3
  import { ModelActionHook } from '../functions/hook/model-action.hook.js';
4
4
  import { ResourceActionHook } from '../functions/hook/resource-action.hook.js';
5
5
  import { EventService } from '../services/event/event.service.js';
6
6
  import { TransactionService } from '../services/transaction/transaction.service.js';
7
- import { Container } from './container.js';
7
+ import { Container } from '../functions/container/container.js';
8
+ /**
9
+ * An `@Action` is a class decorator to be placed on top of a class that represents an action of one of ModelType.
10
+ * - A NodeType.MODEL action must implement the {@link IModelAction} interface.
11
+ * - A NodeType.OVERLAY action must implement the {@link IModelAction} interface.
12
+ * - A NodeType.RESOURCE action must implement the {@link IResourceAction} interface.
13
+ * - A NodeType.SHARED_RESOURCE action must implement the {@link IResourceAction} interface.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * @Action(ModelType.MODEL)
18
+ * export class MyModelAction implements IModelAction { ... }
19
+ * ```
20
+ * @group Decorators
21
+ * @param type The type of Model being decorated.
22
+ * @returns The decorated class.
23
+ * @see Definition of [Actions](/docs/fundamentals/actions).
24
+ */
8
25
  export function Action(type) {
9
26
  return function (constructor) {
10
27
  Container.get(TransactionService)
11
28
  .then(async (transactionService) => {
12
29
  switch (type) {
13
- case ModelType.MODEL: {
30
+ case NodeType.MODEL: {
31
+ // Register model action.
14
32
  const modelAction = await Container.get(constructor.name);
15
33
  transactionService.registerModelActions([modelAction]);
34
+ // Wrap model action with hooks.
16
35
  ModelActionHook.getInstance().registrar(modelAction);
17
36
  break;
18
37
  }
19
- case ModelType.OVERLAY: {
38
+ case NodeType.OVERLAY: {
39
+ // Register overlay action.
20
40
  const modelAction = await Container.get(constructor.name);
21
41
  transactionService.registerOverlayActions([modelAction]);
42
+ // Wrap overlay action with hooks.
22
43
  ModelActionHook.getInstance().registrar(modelAction);
23
44
  break;
24
45
  }
25
- case ModelType.RESOURCE: {
46
+ case NodeType.RESOURCE: {
47
+ // Register resource action.
26
48
  const resourceAction = await Container.get(constructor.name);
27
49
  transactionService.registerResourceActions([resourceAction]);
50
+ // Wrap resource action with hooks.
28
51
  ResourceActionHook.getInstance().registrar(resourceAction);
29
52
  break;
30
53
  }
@@ -1 +1 @@
1
- {"version":3,"file":"action.decorator.js","sourceRoot":"","sources":["../../src/decorators/action.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAG/E,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gDAAgD,CAAC;AACpF,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,MAAM,UAAU,MAAM,CAAC,IAAe;IACpC,OAAO,UAAU,WAAgB;QAC/B,SAAS,CAAC,GAAG,CAAC,kBAAkB,CAAC;aAC9B,IAAI,CAAC,KAAK,EAAE,kBAAkB,EAAE,EAAE;YACjC,QAAQ,IAAI,EAAE,CAAC;gBACb,KAAK,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;oBAErB,MAAM,WAAW,GAAG,MAAM,SAAS,CAAC,GAAG,CAAe,WAAW,CAAC,IAAI,CAAC,CAAC;oBACxE,kBAAkB,CAAC,oBAAoB,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;oBAGvD,eAAe,CAAC,WAAW,EAAE,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;oBACrD,MAAM;gBACR,CAAC;gBACD,KAAK,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;oBAEvB,MAAM,WAAW,GAAG,MAAM,SAAS,CAAC,GAAG,CAAe,WAAW,CAAC,IAAI,CAAC,CAAC;oBACxE,kBAAkB,CAAC,sBAAsB,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;oBAGzD,eAAe,CAAC,WAAW,EAAE,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;oBACrD,MAAM;gBACR,CAAC;gBACD,KAAK,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;oBAExB,MAAM,cAAc,GAAG,MAAM,SAAS,CAAC,GAAG,CAAkB,WAAW,CAAC,IAAI,CAAC,CAAC;oBAC9E,kBAAkB,CAAC,uBAAuB,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC;oBAG7D,kBAAkB,CAAC,WAAW,EAAE,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;oBAC3D,MAAM;gBACR,CAAC;gBACD,OAAO,CAAC,CAAC,CAAC;oBACR,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;gBACpE,CAAC;YACH,CAAC;QACH,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YACf,YAAY,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,IAAI,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAAC;QACrE,CAAC,CAAC,CAAC;IACP,CAAC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"action.decorator.js","sourceRoot":"","sources":["../../src/decorators/action.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAG/E,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gDAAgD,CAAC;AACpF,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAEhE;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,MAAM,CAAC,IAAc;IACnC,OAAO,UAAU,WAAgB;QAC/B,SAAS,CAAC,GAAG,CAAC,kBAAkB,CAAC;aAC9B,IAAI,CAAC,KAAK,EAAE,kBAAkB,EAAE,EAAE;YACjC,QAAQ,IAAI,EAAE,CAAC;gBACb,KAAK,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;oBACpB,yBAAyB;oBACzB,MAAM,WAAW,GAAG,MAAM,SAAS,CAAC,GAAG,CAAe,WAAW,CAAC,IAAI,CAAC,CAAC;oBACxE,kBAAkB,CAAC,oBAAoB,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;oBAEvD,gCAAgC;oBAChC,eAAe,CAAC,WAAW,EAAE,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;oBACrD,MAAM;gBACR,CAAC;gBACD,KAAK,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;oBACtB,2BAA2B;oBAC3B,MAAM,WAAW,GAAG,MAAM,SAAS,CAAC,GAAG,CAAe,WAAW,CAAC,IAAI,CAAC,CAAC;oBACxE,kBAAkB,CAAC,sBAAsB,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;oBAEzD,kCAAkC;oBAClC,eAAe,CAAC,WAAW,EAAE,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;oBACrD,MAAM;gBACR,CAAC;gBACD,KAAK,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;oBACvB,4BAA4B;oBAC5B,MAAM,cAAc,GAAG,MAAM,SAAS,CAAC,GAAG,CAAkB,WAAW,CAAC,IAAI,CAAC,CAAC;oBAC9E,kBAAkB,CAAC,uBAAuB,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC;oBAE7D,mCAAmC;oBACnC,kBAAkB,CAAC,WAAW,EAAE,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;oBAC3D,MAAM;gBACR,CAAC;gBACD,OAAO,CAAC,CAAC,CAAC;oBACR,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;gBACpE,CAAC;YACH,CAAC;QACH,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YACf,YAAY,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,IAAI,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAAC;QACrE,CAAC,CAAC,CAAC;IACP,CAAC,CAAC;AACJ,CAAC"}
@@ -1 +1,14 @@
1
+ /**
2
+ * An `@Anchor` is a class decorator to be placed on top of a class that represents an anchor.
3
+ * - An anchor must extend the {@link AAnchor} class.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * @Anchor()
8
+ * export class MyAnchor extends AAnchor { ... }
9
+ * ```
10
+ * @group Decorators
11
+ * @returns The decorated class.
12
+ * @see Definition of [Anchors](/docs/fundamentals/overlay-and-anchor).
13
+ */
1
14
  export declare function Anchor(): (constructor: any) => void;
@@ -1,7 +1,20 @@
1
1
  import { RegistrationErrorEvent } from '../events/error.event.js';
2
2
  import { EventService } from '../services/event/event.service.js';
3
3
  import { ModelSerializationService } from '../services/serialization/model/model-serialization.service.js';
4
- import { Container } from './container.js';
4
+ import { Container } from '../functions/container/container.js';
5
+ /**
6
+ * An `@Anchor` is a class decorator to be placed on top of a class that represents an anchor.
7
+ * - An anchor must extend the {@link AAnchor} class.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * @Anchor()
12
+ * export class MyAnchor extends AAnchor { ... }
13
+ * ```
14
+ * @group Decorators
15
+ * @returns The decorated class.
16
+ * @see Definition of [Anchors](/docs/fundamentals/overlay-and-anchor).
17
+ */
5
18
  export function Anchor() {
6
19
  return function (constructor) {
7
20
  Container.get(ModelSerializationService)
@@ -1 +1 @@
1
- {"version":3,"file":"anchor.decorator.js","sourceRoot":"","sources":["../../src/decorators/anchor.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,yBAAyB,EAAE,MAAM,gEAAgE,CAAC;AAC3G,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,MAAM,UAAU,MAAM;IACpB,OAAO,UAAU,WAAgB;QAC/B,SAAS,CAAC,GAAG,CAAC,yBAAyB,CAAC;aACrC,IAAI,CAAC,CAAC,yBAAyB,EAAE,EAAE;YAClC,yBAAyB,CAAC,aAAa,CAAC,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;QACzE,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YACf,YAAY,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,IAAI,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAAC;QACrE,CAAC,CAAC,CAAC;IACP,CAAC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"anchor.decorator.js","sourceRoot":"","sources":["../../src/decorators/anchor.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,yBAAyB,EAAE,MAAM,gEAAgE,CAAC;AAC3G,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAEhE;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,MAAM;IACpB,OAAO,UAAU,WAAgB;QAC/B,SAAS,CAAC,GAAG,CAAC,yBAAyB,CAAC;aACrC,IAAI,CAAC,CAAC,yBAAyB,EAAE,EAAE;YAClC,yBAAyB,CAAC,aAAa,CAAC,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;QACzE,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YACf,YAAY,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,IAAI,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAAC;QACrE,CAAC,CAAC,CAAC;IACP,CAAC,CAAC;AACJ,CAAC"}
@@ -1,3 +1,17 @@
1
1
  type Hook = 'CommitHook';
2
+ /**
3
+ * A `@EnableHook` is a method decorator to enable registration of hooks.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * @EnableHook('CommitHook')
8
+ * async commitTransaction(): Promise<void> { ... }
9
+ * ```
10
+ * @group Decorators
11
+ * @internal
12
+ * @param hook The only values supported are `CommitHook`.
13
+ * @returns The decorated method.
14
+ * @see Definition of [Hooks](/docs/fundamentals/modules#hooks).
15
+ */
2
16
  export declare function EnableHook(hook: Hook): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
3
17
  export {};
@@ -1,4 +1,18 @@
1
1
  import { CommitHook } from '../functions/hook/commit.hook.js';
2
+ /**
3
+ * A `@EnableHook` is a method decorator to enable registration of hooks.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * @EnableHook('CommitHook')
8
+ * async commitTransaction(): Promise<void> { ... }
9
+ * ```
10
+ * @group Decorators
11
+ * @internal
12
+ * @param hook The only values supported are `CommitHook`.
13
+ * @returns The decorated method.
14
+ * @see Definition of [Hooks](/docs/fundamentals/modules#hooks).
15
+ */
2
16
  export function EnableHook(hook) {
3
17
  return function (target, propertyKey, descriptor) {
4
18
  switch (hook) {
@@ -1 +1 @@
1
- {"version":3,"file":"enable-hook.decorator.js","sourceRoot":"","sources":["../../src/decorators/enable-hook.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAI9D,MAAM,UAAU,UAAU,CAAC,IAAU;IACnC,OAAO,UAAU,MAAW,EAAE,WAAmB,EAAE,UAA8B;QAC/E,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,YAAY;gBACf,UAAU,CAAC,WAAW,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;gBAC/C,MAAM;YACR;gBACE,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;QACrC,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"enable-hook.decorator.js","sourceRoot":"","sources":["../../src/decorators/enable-hook.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAI9D;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,UAAU,CAAC,IAAU;IACnC,OAAO,UAAU,MAAW,EAAE,WAAmB,EAAE,UAA8B;QAC/E,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,YAAY;gBACf,UAAU,CAAC,WAAW,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;gBAC/C,MAAM;YACR;gBACE,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;QACrC,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
@@ -1,3 +1,18 @@
1
1
  import type { Constructable } from '../app.type.js';
2
2
  import type { Event } from '../events/event.model.js';
3
+ /**
4
+ * An `@EventSource` is a method decorator to enable automatic event emission.
5
+ * The `registrar()` method of the Event class is used to decorate the method to auto-emit events.
6
+ * - All event types must extend the {@link Event} class.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * @EventSource(MyEvent)
11
+ * myMethod(): void { ... }
12
+ * ```
13
+ * @group Decorators
14
+ * @internal
15
+ * @param ofType The type of event being emitted.
16
+ * @returns The decorated method.
17
+ */
3
18
  export declare function EventSource(ofType: Constructable<Event<unknown>>): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
@@ -1,4 +1,19 @@
1
1
  import { EventService } from '../services/event/event.service.js';
2
+ /**
3
+ * An `@EventSource` is a method decorator to enable automatic event emission.
4
+ * The `registrar()` method of the Event class is used to decorate the method to auto-emit events.
5
+ * - All event types must extend the {@link Event} class.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * @EventSource(MyEvent)
10
+ * myMethod(): void { ... }
11
+ * ```
12
+ * @group Decorators
13
+ * @internal
14
+ * @param ofType The type of event being emitted.
15
+ * @returns The decorated method.
16
+ */
2
17
  export function EventSource(ofType) {
3
18
  return function (target, propertyKey, descriptor) {
4
19
  ofType.registrar(EventService.getInstance(), descriptor);
@@ -1 +1 @@
1
- {"version":3,"file":"event-source.decorator.js","sourceRoot":"","sources":["../../src/decorators/event-source.decorator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAElE,MAAM,UAAU,WAAW,CACzB,MAAqC;IAErC,OAAO,UAAU,MAAW,EAAE,WAAmB,EAAE,UAA8B;QAC9E,MAAc,CAAC,SAAS,CAAC,YAAY,CAAC,WAAW,EAAE,EAAE,UAAU,CAAC,CAAC;IACpE,CAAC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"event-source.decorator.js","sourceRoot":"","sources":["../../src/decorators/event-source.decorator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAElE;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,WAAW,CACzB,MAAqC;IAErC,OAAO,UAAU,MAAW,EAAE,WAAmB,EAAE,UAA8B;QAC9E,MAAc,CAAC,SAAS,CAAC,YAAY,CAAC,WAAW,EAAE,EAAE,UAAU,CAAC,CAAC;IACpE,CAAC,CAAC;AACJ,CAAC"}
@@ -1,8 +1,57 @@
1
1
  import type { Constructable } from '../app.type.js';
2
- export declare function Factory<T>(type: Constructable<T> | string, options?: {
3
- metadata?: {
4
- [key: string]: string;
5
- };
6
- }): (constructor: {
2
+ /**
3
+ * A `@Factory` is a class decorator to be placed on top of a class that represents a factory.
4
+ * A factory is responsible for creating instances of a class.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * // Factory definition.
9
+ * @Factory<MyService>(MyService)
10
+ * export class MyServiceFactory {
11
+ * static async create(arg1, arg2, ...): Promise<MyService> { ... }
12
+ * }
13
+ *
14
+ * // Get instance using default factory.
15
+ * const myService = await Container.get(MyService);
16
+ *
17
+ * // Pass args to factory.
18
+ * const myService = await Container.get(MyService, { args: [arg1, arg2, ...] });
19
+ * ```
20
+ * @group Decorators
21
+ * @param type The type of class that the factory creates.
22
+ * @remarks
23
+ * If the factory is dependent on other factories, it should not block creation of its instance.
24
+ * ```ts
25
+ * // Correct, since creation of instance is not blocked.
26
+ * // In this case, when multiple code paths are trying to get Container.get(MyService) at the same time,
27
+ * // each of them will `await` for OtherService to get resolved,
28
+ * // and the first to resolve will be able to create the instance, that the rest will re-use.
29
+ * export class MyServiceFactory {
30
+ * private static instance: MyService;
31
+ * static async create(): Promise<MyService> {
32
+ * const otherInstance = await Container.get(OtherService);
33
+ * if (!this.instance) {
34
+ * this.instance = new MyService(otherInstance);
35
+ * }
36
+ * }
37
+ * }
38
+ * ```
39
+ * ```ts
40
+ * // Wrong, since creation of instance is blocked.
41
+ * // In this case, when multiple code paths are trying to get Container.get(MyService) at the same time,
42
+ * // each of them will get a new instance since during `await` there is race condition.
43
+ * export class MyServiceFactory {
44
+ * private static instance: MyService;
45
+ * static async create(): Promise<MyService> {
46
+ * if (!this.instance) {
47
+ * const otherInstance = await Container.get(OtherService);
48
+ * this.instance = new MyService(otherInstance);
49
+ * }
50
+ * }
51
+ * }
52
+ * ```
53
+ * @returns The decorated class.
54
+ */
55
+ export declare function Factory<T>(type: Constructable<T> | string): (constructor: {
7
56
  create: (...args: unknown[]) => Promise<T>;
8
57
  }) => void;
@@ -1,7 +1,60 @@
1
- import { Container } from './container.js';
2
- export function Factory(type, options) {
1
+ import { Container } from '../functions/container/container.js';
2
+ /**
3
+ * A `@Factory` is a class decorator to be placed on top of a class that represents a factory.
4
+ * A factory is responsible for creating instances of a class.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * // Factory definition.
9
+ * @Factory<MyService>(MyService)
10
+ * export class MyServiceFactory {
11
+ * static async create(arg1, arg2, ...): Promise<MyService> { ... }
12
+ * }
13
+ *
14
+ * // Get instance using default factory.
15
+ * const myService = await Container.get(MyService);
16
+ *
17
+ * // Pass args to factory.
18
+ * const myService = await Container.get(MyService, { args: [arg1, arg2, ...] });
19
+ * ```
20
+ * @group Decorators
21
+ * @param type The type of class that the factory creates.
22
+ * @remarks
23
+ * If the factory is dependent on other factories, it should not block creation of its instance.
24
+ * ```ts
25
+ * // Correct, since creation of instance is not blocked.
26
+ * // In this case, when multiple code paths are trying to get Container.get(MyService) at the same time,
27
+ * // each of them will `await` for OtherService to get resolved,
28
+ * // and the first to resolve will be able to create the instance, that the rest will re-use.
29
+ * export class MyServiceFactory {
30
+ * private static instance: MyService;
31
+ * static async create(): Promise<MyService> {
32
+ * const otherInstance = await Container.get(OtherService);
33
+ * if (!this.instance) {
34
+ * this.instance = new MyService(otherInstance);
35
+ * }
36
+ * }
37
+ * }
38
+ * ```
39
+ * ```ts
40
+ * // Wrong, since creation of instance is blocked.
41
+ * // In this case, when multiple code paths are trying to get Container.get(MyService) at the same time,
42
+ * // each of them will get a new instance since during `await` there is race condition.
43
+ * export class MyServiceFactory {
44
+ * private static instance: MyService;
45
+ * static async create(): Promise<MyService> {
46
+ * if (!this.instance) {
47
+ * const otherInstance = await Container.get(OtherService);
48
+ * this.instance = new MyService(otherInstance);
49
+ * }
50
+ * }
51
+ * }
52
+ * ```
53
+ * @returns The decorated class.
54
+ */
55
+ export function Factory(type) {
3
56
  return function (constructor) {
4
- Container.registerFactory(type, constructor, options);
57
+ Container.registerFactory(type, constructor);
5
58
  };
6
59
  }
7
60
  //# sourceMappingURL=factory.decorator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"factory.decorator.js","sourceRoot":"","sources":["../../src/decorators/factory.decorator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,MAAM,UAAU,OAAO,CACrB,IAA+B,EAC/B,OAEC;IAED,OAAO,UAAU,WAA2D;QAC1E,SAAS,CAAC,eAAe,CAAI,IAAI,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;IAC3D,CAAC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"factory.decorator.js","sourceRoot":"","sources":["../../src/decorators/factory.decorator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,MAAM,UAAU,OAAO,CACrB,IAA+B;IAE/B,OAAO,UAAU,WAA2D;QAC1E,SAAS,CAAC,eAAe,CAAI,IAAI,EAAE,WAAW,CAAC,CAAC;IAClD,CAAC,CAAC;AACJ,CAAC"}
@@ -1 +1,14 @@
1
+ /**
2
+ * A `@Model` is a class decorator to be placed on top of a class that represents a model.
3
+ * - A model must extend the {@link AModel} class.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * @Model()
8
+ * export class MyModel extends AModel<IMyModel, MyModel> { ... }
9
+ * ```
10
+ * @group Decorators
11
+ * @returns The decorated class.
12
+ * @see Definition of [Models](/docs/fundamentals/models).
13
+ */
1
14
  export declare function Model(): (constructor: any) => void;
@@ -1,7 +1,20 @@
1
1
  import { RegistrationErrorEvent } from '../events/error.event.js';
2
2
  import { EventService } from '../services/event/event.service.js';
3
3
  import { ModelSerializationService } from '../services/serialization/model/model-serialization.service.js';
4
- import { Container } from './container.js';
4
+ import { Container } from '../functions/container/container.js';
5
+ /**
6
+ * A `@Model` is a class decorator to be placed on top of a class that represents a model.
7
+ * - A model must extend the {@link AModel} class.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * @Model()
12
+ * export class MyModel extends AModel<IMyModel, MyModel> { ... }
13
+ * ```
14
+ * @group Decorators
15
+ * @returns The decorated class.
16
+ * @see Definition of [Models](/docs/fundamentals/models).
17
+ */
5
18
  export function Model() {
6
19
  return function (constructor) {
7
20
  Container.get(ModelSerializationService)
@@ -1 +1 @@
1
- {"version":3,"file":"model.decorator.js","sourceRoot":"","sources":["../../src/decorators/model.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,yBAAyB,EAAE,MAAM,gEAAgE,CAAC;AAC3G,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,MAAM,UAAU,KAAK;IACnB,OAAO,UAAU,WAAgB;QAC/B,SAAS,CAAC,GAAG,CAAC,yBAAyB,CAAC;aACrC,IAAI,CAAC,CAAC,yBAAyB,EAAE,EAAE;YAClC,yBAAyB,CAAC,aAAa,CAAC,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;QACzE,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YACf,YAAY,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,IAAI,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAAC;QACrE,CAAC,CAAC,CAAC;IACP,CAAC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"model.decorator.js","sourceRoot":"","sources":["../../src/decorators/model.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,yBAAyB,EAAE,MAAM,gEAAgE,CAAC;AAC3G,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAEhE;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,KAAK;IACnB,OAAO,UAAU,WAAgB;QAC/B,SAAS,CAAC,GAAG,CAAC,yBAAyB,CAAC;aACrC,IAAI,CAAC,CAAC,yBAAyB,EAAE,EAAE;YAClC,yBAAyB,CAAC,aAAa,CAAC,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;QACzE,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YACf,YAAY,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,IAAI,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAAC;QACrE,CAAC,CAAC,CAAC;IACP,CAAC,CAAC;AACJ,CAAC"}
@@ -1,16 +1,18 @@
1
1
  import type { Constructable } from '../app.type.js';
2
- import type { Octo } from '../main.js';
2
+ import type { DiffMetadata } from '../functions/diff/diff-metadata.js';
3
+ import type { App } from '../models/app/app.model.js';
3
4
  import type { IModelAction } from '../models/model-action.interface.js';
4
5
  import { type IModule } from '../modules/module.interface.js';
5
6
  import type { IResourceAction } from '../resources/resource-action.interface.js';
6
- export declare function Module({ args, imports, postCommitHooks, postModelActionHooks, postResourceActionHooks, preCommitHooks, preModelActionHooks, preResourceActionHooks, }: {
7
+ type CommitHooksCallback = (app: App, modelTransaction: DiffMetadata[][], resourceTransaction: DiffMetadata[][]) => Promise<void>;
8
+ export interface IModuleOptions {
7
9
  args?: {
8
10
  isArg: (arg: unknown) => boolean;
9
11
  name: string;
10
12
  }[];
11
13
  imports?: (Constructable<IModule<unknown>> | string)[];
12
14
  postCommitHooks?: {
13
- callback: Octo['commitTransaction'];
15
+ callback: CommitHooksCallback;
14
16
  }[];
15
17
  postModelActionHooks?: {
16
18
  ACTION_NAME: string;
@@ -22,7 +24,7 @@ export declare function Module({ args, imports, postCommitHooks, postModelAction
22
24
  handle: IResourceAction['handle'];
23
25
  }[];
24
26
  preCommitHooks?: {
25
- callback: Octo['commitTransaction'];
27
+ callback: CommitHooksCallback;
26
28
  }[];
27
29
  preModelActionHooks?: {
28
30
  ACTION_NAME: string;
@@ -33,4 +35,58 @@ export declare function Module({ args, imports, postCommitHooks, postModelAction
33
35
  ACTION_NAME: string;
34
36
  handle: IResourceAction['handle'];
35
37
  }[];
36
- }): (constructor: any) => void;
38
+ }
39
+ /**
40
+ * A `@Module` is a class decorator to be placed on top of a class that represents a module.
41
+ * - A Module class must implement the {@link IModule} interface.
42
+ * - A Module class constructor is injected with the outputs of the modules it imports.
43
+ * - The {@link IModule.onInit} method is called to initialize the module,
44
+ * and is where you will *define* your infrastructure.
45
+ *
46
+ * @example
47
+ * ```ts
48
+ * @Module({
49
+ * args: [{ isArg: (app: App) => app instanceof App, name: 'app' }],
50
+ * imports: [OtherModule],
51
+ * postModelActionHooks: [{ ACTION_NAME: 'SomeAction', collectInput: () => { ... }, handle: () => { ... } }],
52
+ * })
53
+ * export class MyModule implements IModule<Region> {
54
+ * constructor(app: App) { ... }
55
+ *
56
+ * async onInit(): Promise<Region> { ... }
57
+ * }
58
+ * ```
59
+ * @group Decorators
60
+ * @param options - Options to the module.
61
+ * @param options.args - (optional) An array of arg validators to verify the args passed to the module's constructor.
62
+ * - The `isArg` method receives an argument, and you must do your own type checking and return a boolean.
63
+ * - The `name` property is the name of the argument.
64
+ * @param options.imports - (optional) An array of modules to import.
65
+ * @param options.postCommitHooks - (optional) An array of post-commit hooks.
66
+ * - The `callback` method will be called after the transaction is committed.
67
+ * This method receives the same arguments as {@link Octo.commitTransaction}.
68
+ * @param options.postModelActionHooks - (optional) An array of post-model action hooks.
69
+ * - The `ACTION_NAME` identifies the action on which this hook is registered.
70
+ * - The `collectInput` method can be used to enrich the action inputs. It works the same as in {@link IModelAction}.
71
+ * - The `handle` method will be called after the action is executed.
72
+ * This method receives the same arguments as {@link IModelAction.handle}.
73
+ * @param options.postResourceActionHooks - (optional) An array of post-resource action hooks.
74
+ * - The `ACTION_NAME` identifies the action on which this hook is registered.
75
+ * - The `handle` method will be called after the action is executed.
76
+ * This method receives the same arguments as {@link IResourceAction.handle}.
77
+ * @param options.preCommitHooks - (optional) An array of pre-commit hooks.
78
+ * - The `callback` method will be called before the transaction is committed.
79
+ * This method receives the same arguments as {@link Octo.commitTransaction}.
80
+ * @param options.preModelActionHooks - (optional) An array of pre-model action hooks.
81
+ * - The `ACTION_NAME` identifies the action on which this hook is registered.
82
+ * - The `collectInput` method can be used to enrich the action inputs. It works the same as in {@link IModelAction}.
83
+ * - The `handle` method will be called before the action is executed.
84
+ * This method receives the same arguments as {@link IModelAction.handle}.
85
+ * @param options.preResourceActionHooks - (optional) An array of pre-resource action hooks.
86
+ * - The `ACTION_NAME` identifies the action on which this hook is registered.
87
+ * - The `handle` method will be called before the action is executed.
88
+ * @returns The decorated class.
89
+ * @see Definition of [Modules](/docs/fundamentals/modules).
90
+ */
91
+ export declare function Module({ args, imports, postCommitHooks, postModelActionHooks, postResourceActionHooks, preCommitHooks, preModelActionHooks, preResourceActionHooks, }?: IModuleOptions): (constructor: any) => void;
92
+ export {};
@@ -1,8 +1,64 @@
1
+ import { RegistrationErrorEvent } from '../events/error.event.js';
1
2
  import { ModuleContainer } from '../modules/module.container.js';
2
- import { Container } from './container.js';
3
- export function Module({ args = [], imports = [], postCommitHooks = [], postModelActionHooks = [], postResourceActionHooks = [], preCommitHooks = [], preModelActionHooks = [], preResourceActionHooks = [], }) {
3
+ import { EventService } from '../services/event/event.service.js';
4
+ import { Container } from '../functions/container/container.js';
5
+ /**
6
+ * A `@Module` is a class decorator to be placed on top of a class that represents a module.
7
+ * - A Module class must implement the {@link IModule} interface.
8
+ * - A Module class constructor is injected with the outputs of the modules it imports.
9
+ * - The {@link IModule.onInit} method is called to initialize the module,
10
+ * and is where you will *define* your infrastructure.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * @Module({
15
+ * args: [{ isArg: (app: App) => app instanceof App, name: 'app' }],
16
+ * imports: [OtherModule],
17
+ * postModelActionHooks: [{ ACTION_NAME: 'SomeAction', collectInput: () => { ... }, handle: () => { ... } }],
18
+ * })
19
+ * export class MyModule implements IModule<Region> {
20
+ * constructor(app: App) { ... }
21
+ *
22
+ * async onInit(): Promise<Region> { ... }
23
+ * }
24
+ * ```
25
+ * @group Decorators
26
+ * @param options - Options to the module.
27
+ * @param options.args - (optional) An array of arg validators to verify the args passed to the module's constructor.
28
+ * - The `isArg` method receives an argument, and you must do your own type checking and return a boolean.
29
+ * - The `name` property is the name of the argument.
30
+ * @param options.imports - (optional) An array of modules to import.
31
+ * @param options.postCommitHooks - (optional) An array of post-commit hooks.
32
+ * - The `callback` method will be called after the transaction is committed.
33
+ * This method receives the same arguments as {@link Octo.commitTransaction}.
34
+ * @param options.postModelActionHooks - (optional) An array of post-model action hooks.
35
+ * - The `ACTION_NAME` identifies the action on which this hook is registered.
36
+ * - The `collectInput` method can be used to enrich the action inputs. It works the same as in {@link IModelAction}.
37
+ * - The `handle` method will be called after the action is executed.
38
+ * This method receives the same arguments as {@link IModelAction.handle}.
39
+ * @param options.postResourceActionHooks - (optional) An array of post-resource action hooks.
40
+ * - The `ACTION_NAME` identifies the action on which this hook is registered.
41
+ * - The `handle` method will be called after the action is executed.
42
+ * This method receives the same arguments as {@link IResourceAction.handle}.
43
+ * @param options.preCommitHooks - (optional) An array of pre-commit hooks.
44
+ * - The `callback` method will be called before the transaction is committed.
45
+ * This method receives the same arguments as {@link Octo.commitTransaction}.
46
+ * @param options.preModelActionHooks - (optional) An array of pre-model action hooks.
47
+ * - The `ACTION_NAME` identifies the action on which this hook is registered.
48
+ * - The `collectInput` method can be used to enrich the action inputs. It works the same as in {@link IModelAction}.
49
+ * - The `handle` method will be called before the action is executed.
50
+ * This method receives the same arguments as {@link IModelAction.handle}.
51
+ * @param options.preResourceActionHooks - (optional) An array of pre-resource action hooks.
52
+ * - The `ACTION_NAME` identifies the action on which this hook is registered.
53
+ * - The `handle` method will be called before the action is executed.
54
+ * @returns The decorated class.
55
+ * @see Definition of [Modules](/docs/fundamentals/modules).
56
+ */
57
+ export function Module({ args = [], imports = [], postCommitHooks = [], postModelActionHooks = [], postResourceActionHooks = [], preCommitHooks = [], preModelActionHooks = [], preResourceActionHooks = [], } = {}) {
4
58
  return function (constructor) {
5
- Container.get(ModuleContainer).then((moduleContainer) => {
59
+ Container.get(ModuleContainer)
60
+ .then((moduleContainer) => {
61
+ // Verify classes with @Module implements IModule.
6
62
  if (!('onInit' in constructor.prototype)) {
7
63
  throw new Error(`Class "${constructor.name}" does not implement IModule!`);
8
64
  }
@@ -16,6 +72,9 @@ export function Module({ args = [], imports = [], postCommitHooks = [], postMode
16
72
  preModelActionHooks,
17
73
  preResourceActionHooks,
18
74
  });
75
+ })
76
+ .catch((error) => {
77
+ EventService.getInstance().emit(new RegistrationErrorEvent(error));
19
78
  });
20
79
  };
21
80
  }