@quadnix/octo 0.0.21 → 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 (131) hide show
  1. package/dist/app.type.d.ts +3 -1
  2. package/dist/app.type.js +7 -7
  3. package/dist/app.type.js.map +1 -1
  4. package/dist/decorators/action.decorator.d.ts +6 -6
  5. package/dist/decorators/action.decorator.js +9 -9
  6. package/dist/decorators/action.decorator.js.map +1 -1
  7. package/dist/decorators/anchor.decorator.js +1 -1
  8. package/dist/decorators/anchor.decorator.js.map +1 -1
  9. package/dist/decorators/factory.decorator.d.ts +34 -15
  10. package/dist/decorators/factory.decorator.js +36 -13
  11. package/dist/decorators/factory.decorator.js.map +1 -1
  12. package/dist/decorators/model.decorator.js +1 -1
  13. package/dist/decorators/model.decorator.js.map +1 -1
  14. package/dist/decorators/module.decorator.d.ts +36 -32
  15. package/dist/decorators/module.decorator.js +2 -2
  16. package/dist/decorators/module.decorator.js.map +1 -1
  17. package/dist/decorators/overlay.decorator.js +1 -1
  18. package/dist/decorators/overlay.decorator.js.map +1 -1
  19. package/dist/decorators/resource.decorator.js +1 -1
  20. package/dist/decorators/resource.decorator.js.map +1 -1
  21. package/dist/{decorators → functions/container}/container.d.ts +2 -33
  22. package/dist/{decorators → functions/container}/container.js +8 -63
  23. package/dist/functions/container/container.js.map +1 -0
  24. package/dist/{decorators → functions/container}/test-container.d.ts +2 -6
  25. package/dist/{decorators → functions/container}/test-container.js +7 -14
  26. package/dist/functions/container/test-container.js.map +1 -0
  27. package/dist/functions/dependency/dependency.d.ts +6 -6
  28. package/dist/functions/dependency/dependency.js.map +1 -1
  29. package/dist/functions/diff/diff-metadata.d.ts +2 -2
  30. package/dist/functions/diff/diff-metadata.js +1 -1
  31. package/dist/functions/diff/diff-metadata.js.map +1 -1
  32. package/dist/functions/diff/diff.d.ts +4 -4
  33. package/dist/functions/diff/diff.js +6 -10
  34. package/dist/functions/diff/diff.js.map +1 -1
  35. package/dist/functions/diff/diff.utility.d.ts +23 -23
  36. package/dist/functions/diff/diff.utility.js +23 -23
  37. package/dist/functions/diff/diff.utility.js.map +1 -1
  38. package/dist/functions/hook/commit.hook.js.map +1 -1
  39. package/dist/functions/hook/model-action.hook.js +1 -1
  40. package/dist/functions/hook/model-action.hook.js.map +1 -1
  41. package/dist/functions/node/node.abstract.d.ts +84 -0
  42. package/dist/functions/node/node.abstract.js +275 -0
  43. package/dist/functions/node/node.abstract.js.map +1 -0
  44. package/dist/functions/node/node.interface.d.ts +176 -0
  45. package/dist/functions/node/node.interface.js +2 -0
  46. package/dist/functions/node/node.interface.js.map +1 -0
  47. package/dist/index.d.ts +11 -12
  48. package/dist/index.js +10 -11
  49. package/dist/index.js.map +1 -1
  50. package/dist/main.d.ts +7 -9
  51. package/dist/main.js +51 -24
  52. package/dist/main.js.map +1 -1
  53. package/dist/models/app/app.model.d.ts +1 -3
  54. package/dist/models/app/app.model.js +5 -8
  55. package/dist/models/app/app.model.js.map +1 -1
  56. package/dist/models/deployment/deployment.model.d.ts +1 -3
  57. package/dist/models/deployment/deployment.model.js +5 -8
  58. package/dist/models/deployment/deployment.model.js.map +1 -1
  59. package/dist/models/environment/environment.model.d.ts +1 -3
  60. package/dist/models/environment/environment.model.js +5 -9
  61. package/dist/models/environment/environment.model.js.map +1 -1
  62. package/dist/models/execution/execution.model.d.ts +1 -3
  63. package/dist/models/execution/execution.model.js +2 -6
  64. package/dist/models/execution/execution.model.js.map +1 -1
  65. package/dist/models/image/image.model.d.ts +1 -3
  66. package/dist/models/image/image.model.js +5 -8
  67. package/dist/models/image/image.model.js.map +1 -1
  68. package/dist/models/model-action.interface.d.ts +2 -6
  69. package/dist/models/model.abstract.d.ts +7 -307
  70. package/dist/models/model.abstract.js +20 -560
  71. package/dist/models/model.abstract.js.map +1 -1
  72. package/dist/models/model.interface.d.ts +36 -21
  73. package/dist/models/pipeline/pipeline.model.d.ts +1 -3
  74. package/dist/models/pipeline/pipeline.model.js +5 -9
  75. package/dist/models/pipeline/pipeline.model.js.map +1 -1
  76. package/dist/models/region/region.model.d.ts +1 -3
  77. package/dist/models/region/region.model.js +5 -8
  78. package/dist/models/region/region.model.js.map +1 -1
  79. package/dist/models/server/server.model.d.ts +1 -3
  80. package/dist/models/server/server.model.js +5 -8
  81. package/dist/models/server/server.model.js.map +1 -1
  82. package/dist/models/service/service.model.d.ts +1 -3
  83. package/dist/models/service/service.model.js +3 -7
  84. package/dist/models/service/service.model.js.map +1 -1
  85. package/dist/models/subnet/subnet.model.d.ts +3 -4
  86. package/dist/models/subnet/subnet.model.js +9 -18
  87. package/dist/models/subnet/subnet.model.js.map +1 -1
  88. package/dist/modules/module.container.d.ts +2 -2
  89. package/dist/modules/module.container.js.map +1 -1
  90. package/dist/modules/test-module.container.d.ts +2 -2
  91. package/dist/modules/test-module.container.js +8 -10
  92. package/dist/modules/test-module.container.js.map +1 -1
  93. package/dist/overlays/overlay-data.repository.d.ts +2 -4
  94. package/dist/overlays/overlay-data.repository.js +8 -33
  95. package/dist/overlays/overlay-data.repository.js.map +1 -1
  96. package/dist/overlays/overlay.abstract.d.ts +6 -7
  97. package/dist/overlays/overlay.abstract.js +20 -42
  98. package/dist/overlays/overlay.abstract.js.map +1 -1
  99. package/dist/overlays/overlay.service.d.ts +0 -1
  100. package/dist/overlays/overlay.service.js +1 -5
  101. package/dist/overlays/overlay.service.js.map +1 -1
  102. package/dist/resources/resource-data.repository.d.ts +16 -6
  103. package/dist/resources/resource-data.repository.js +115 -15
  104. package/dist/resources/resource-data.repository.js.map +1 -1
  105. package/dist/resources/resource.abstract.d.ts +23 -6
  106. package/dist/resources/resource.abstract.js +144 -10
  107. package/dist/resources/resource.abstract.js.map +1 -1
  108. package/dist/resources/shared-resource.abstract.d.ts +2 -2
  109. package/dist/resources/shared-resource.abstract.js +2 -2
  110. package/dist/resources/shared-resource.abstract.js.map +1 -1
  111. package/dist/services/capture/capture.service.d.ts +1 -2
  112. package/dist/services/capture/capture.service.js +2 -2
  113. package/dist/services/capture/capture.service.js.map +1 -1
  114. package/dist/services/event/event.service.js +1 -1
  115. package/dist/services/event/event.service.js.map +1 -1
  116. package/dist/services/input/input.service.js +2 -2
  117. package/dist/services/input/input.service.js.map +1 -1
  118. package/dist/services/serialization/model/model-serialization.service.js +4 -11
  119. package/dist/services/serialization/model/model-serialization.service.js.map +1 -1
  120. package/dist/services/serialization/resource/resource-serialization.service.d.ts +4 -4
  121. package/dist/services/serialization/resource/resource-serialization.service.js +15 -18
  122. package/dist/services/serialization/resource/resource-serialization.service.js.map +1 -1
  123. package/dist/services/state-management/state-management.service.d.ts +1 -1
  124. package/dist/services/state-management/state-management.service.js +6 -7
  125. package/dist/services/state-management/state-management.service.js.map +1 -1
  126. package/dist/services/transaction/transaction.service.d.ts +2 -3
  127. package/dist/services/transaction/transaction.service.js +88 -90
  128. package/dist/services/transaction/transaction.service.js.map +1 -1
  129. package/package.json +1 -1
  130. package/dist/decorators/container.js.map +0 -1
  131. 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,7 +8,7 @@ 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",
@@ -68,6 +69,7 @@ export type TransactionOptions = {
68
69
  };
69
70
  export type IUnknownModel = IModel<unknown, unknown>;
70
71
  export type UnknownModel = AModel<unknown, unknown>;
72
+ export type UnknownNode = ANode<unknown, unknown>;
71
73
  export type UnknownOverlay = AOverlay<unknown>;
72
74
  export type UnknownResource = AResource<unknown>;
73
75
  export type UnknownSharedResource = ASharedResource<unknown>;
package/dist/app.type.js CHANGED
@@ -1,10 +1,10 @@
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
8
  export var ValidationType;
9
9
  (function (ValidationType) {
10
10
  ValidationType["MAX_LENGTH"] = "maxLength";
@@ -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;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
+ {"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,10 +1,10 @@
1
- import { ModelType } from '../app.type.js';
1
+ import { NodeType } from '../app.type.js';
2
2
  /**
3
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 ModelType.MODEL action must implement the {@link IModelAction} interface.
5
- * - A ModelType.OVERLAY action must implement the {@link IModelAction} interface.
6
- * - A ModelType.RESOURCE action must implement the {@link IResourceAction} interface.
7
- * - A ModelType.SHARED_RESOURCE action must implement the {@link IResourceAction} interface.
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
8
  *
9
9
  * @example
10
10
  * ```ts
@@ -16,4 +16,4 @@ import { ModelType } from '../app.type.js';
16
16
  * @returns The decorated class.
17
17
  * @see Definition of [Actions](/docs/fundamentals/actions).
18
18
  */
19
- export declare function Action(type: ModelType): (constructor: any) => void;
19
+ export declare function Action(type: NodeType): (constructor: any) => void;
@@ -1,16 +1,16 @@
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
8
  /**
9
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 ModelType.MODEL action must implement the {@link IModelAction} interface.
11
- * - A ModelType.OVERLAY action must implement the {@link IModelAction} interface.
12
- * - A ModelType.RESOURCE action must implement the {@link IResourceAction} interface.
13
- * - A ModelType.SHARED_RESOURCE action must implement the {@link IResourceAction} interface.
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
14
  *
15
15
  * @example
16
16
  * ```ts
@@ -27,7 +27,7 @@ export function Action(type) {
27
27
  Container.get(TransactionService)
28
28
  .then(async (transactionService) => {
29
29
  switch (type) {
30
- case ModelType.MODEL: {
30
+ case NodeType.MODEL: {
31
31
  // Register model action.
32
32
  const modelAction = await Container.get(constructor.name);
33
33
  transactionService.registerModelActions([modelAction]);
@@ -35,7 +35,7 @@ export function Action(type) {
35
35
  ModelActionHook.getInstance().registrar(modelAction);
36
36
  break;
37
37
  }
38
- case ModelType.OVERLAY: {
38
+ case NodeType.OVERLAY: {
39
39
  // Register overlay action.
40
40
  const modelAction = await Container.get(constructor.name);
41
41
  transactionService.registerOverlayActions([modelAction]);
@@ -43,7 +43,7 @@ export function Action(type) {
43
43
  ModelActionHook.getInstance().registrar(modelAction);
44
44
  break;
45
45
  }
46
- case ModelType.RESOURCE: {
46
+ case NodeType.RESOURCE: {
47
47
  // Register resource action.
48
48
  const resourceAction = await Container.get(constructor.name);
49
49
  transactionService.registerResourceActions([resourceAction]);
@@ -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,MA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,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,7 +1,7 @@
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
5
  /**
6
6
  * An `@Anchor` is a class decorator to be placed on top of a class that represents an anchor.
7
7
  * - An anchor must extend the {@link AAnchor} class.
@@ -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;;;;;;;;;;;;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
+ {"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"}
@@ -3,36 +3,55 @@ import type { Constructable } from '../app.type.js';
3
3
  * A `@Factory` is a class decorator to be placed on top of a class that represents a factory.
4
4
  * A factory is responsible for creating instances of a class.
5
5
  *
6
- * It is possible to generate multiple factories for the same class
7
- * by assigning a unique set of metadata to the factory.
8
- * Of all registered factories, only one can be the default factory.
9
- *
10
6
  * @example
11
7
  * ```ts
12
8
  * // Factory definition.
13
- * @Factory<MyService>(MyService, { metadata: { key: 'value' } })
9
+ * @Factory<MyService>(MyService)
14
10
  * export class MyServiceFactory {
15
- * static async create(arg1, arg2, ...): Promise<MyService> { ... }>
11
+ * static async create(arg1, arg2, ...): Promise<MyService> { ... }
16
12
  * }
17
13
  *
18
14
  * // Get instance using default factory.
19
15
  * const myService = await Container.get(MyService);
20
16
  *
21
- * // Get instance using specific factory.
22
- * const myService = await Container.get(MyService, { metadata: { key: 'value' } });
23
- *
24
17
  * // Pass args to factory.
25
18
  * const myService = await Container.get(MyService, { args: [arg1, arg2, ...] });
26
19
  * ```
27
20
  * @group Decorators
28
21
  * @param type The type of class that the factory creates.
29
- * @param options Allows registering multiple factories for the same class that differ by metadata.
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
+ * ```
30
53
  * @returns The decorated class.
31
54
  */
32
- export declare function Factory<T>(type: Constructable<T> | string, options?: {
33
- metadata?: {
34
- [key: string]: string;
35
- };
36
- }): (constructor: {
55
+ export declare function Factory<T>(type: Constructable<T> | string): (constructor: {
37
56
  create: (...args: unknown[]) => Promise<T>;
38
57
  }) => void;
@@ -1,37 +1,60 @@
1
- import { Container } from './container.js';
1
+ import { Container } from '../functions/container/container.js';
2
2
  /**
3
3
  * A `@Factory` is a class decorator to be placed on top of a class that represents a factory.
4
4
  * A factory is responsible for creating instances of a class.
5
5
  *
6
- * It is possible to generate multiple factories for the same class
7
- * by assigning a unique set of metadata to the factory.
8
- * Of all registered factories, only one can be the default factory.
9
- *
10
6
  * @example
11
7
  * ```ts
12
8
  * // Factory definition.
13
- * @Factory<MyService>(MyService, { metadata: { key: 'value' } })
9
+ * @Factory<MyService>(MyService)
14
10
  * export class MyServiceFactory {
15
- * static async create(arg1, arg2, ...): Promise<MyService> { ... }>
11
+ * static async create(arg1, arg2, ...): Promise<MyService> { ... }
16
12
  * }
17
13
  *
18
14
  * // Get instance using default factory.
19
15
  * const myService = await Container.get(MyService);
20
16
  *
21
- * // Get instance using specific factory.
22
- * const myService = await Container.get(MyService, { metadata: { key: 'value' } });
23
- *
24
17
  * // Pass args to factory.
25
18
  * const myService = await Container.get(MyService, { args: [arg1, arg2, ...] });
26
19
  * ```
27
20
  * @group Decorators
28
21
  * @param type The type of class that the factory creates.
29
- * @param options Allows registering multiple factories for the same class that differ by metadata.
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
+ * ```
30
53
  * @returns The decorated class.
31
54
  */
32
- export function Factory(type, options) {
55
+ export function Factory(type) {
33
56
  return function (constructor) {
34
- Container.registerFactory(type, constructor, options);
57
+ Container.registerFactory(type, constructor);
35
58
  };
36
59
  }
37
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,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,7 +1,7 @@
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
5
  /**
6
6
  * A `@Model` is a class decorator to be placed on top of a class that represents a model.
7
7
  * - A model must extend the {@link AModel} class.
@@ -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;;;;;;;;;;;;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
+ {"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,8 +1,41 @@
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';
7
+ type CommitHooksCallback = (app: App, modelTransaction: DiffMetadata[][], resourceTransaction: DiffMetadata[][]) => Promise<void>;
8
+ export interface IModuleOptions {
9
+ args?: {
10
+ isArg: (arg: unknown) => boolean;
11
+ name: string;
12
+ }[];
13
+ imports?: (Constructable<IModule<unknown>> | string)[];
14
+ postCommitHooks?: {
15
+ callback: CommitHooksCallback;
16
+ }[];
17
+ postModelActionHooks?: {
18
+ ACTION_NAME: string;
19
+ collectInput?: IModelAction['collectInput'];
20
+ handle: IModelAction['handle'];
21
+ }[];
22
+ postResourceActionHooks?: {
23
+ ACTION_NAME: string;
24
+ handle: IResourceAction['handle'];
25
+ }[];
26
+ preCommitHooks?: {
27
+ callback: CommitHooksCallback;
28
+ }[];
29
+ preModelActionHooks?: {
30
+ ACTION_NAME: string;
31
+ collectInput?: IModelAction['collectInput'];
32
+ handle: IModelAction['handle'];
33
+ }[];
34
+ preResourceActionHooks?: {
35
+ ACTION_NAME: string;
36
+ handle: IResourceAction['handle'];
37
+ }[];
38
+ }
6
39
  /**
7
40
  * A `@Module` is a class decorator to be placed on top of a class that represents a module.
8
41
  * - A Module class must implement the {@link IModule} interface.
@@ -55,34 +88,5 @@ import type { IResourceAction } from '../resources/resource-action.interface.js'
55
88
  * @returns The decorated class.
56
89
  * @see Definition of [Modules](/docs/fundamentals/modules).
57
90
  */
58
- export declare function Module({ args, imports, postCommitHooks, postModelActionHooks, postResourceActionHooks, preCommitHooks, preModelActionHooks, preResourceActionHooks, }: {
59
- args?: {
60
- isArg: (arg: unknown) => boolean;
61
- name: string;
62
- }[];
63
- imports?: (Constructable<IModule<unknown>> | string)[];
64
- postCommitHooks?: {
65
- callback: Octo['commitTransaction'];
66
- }[];
67
- postModelActionHooks?: {
68
- ACTION_NAME: string;
69
- collectInput?: IModelAction['collectInput'];
70
- handle: IModelAction['handle'];
71
- }[];
72
- postResourceActionHooks?: {
73
- ACTION_NAME: string;
74
- handle: IResourceAction['handle'];
75
- }[];
76
- preCommitHooks?: {
77
- callback: Octo['commitTransaction'];
78
- }[];
79
- preModelActionHooks?: {
80
- ACTION_NAME: string;
81
- collectInput?: IModelAction['collectInput'];
82
- handle: IModelAction['handle'];
83
- }[];
84
- preResourceActionHooks?: {
85
- ACTION_NAME: string;
86
- handle: IResourceAction['handle'];
87
- }[];
88
- }): (constructor: any) => void;
91
+ export declare function Module({ args, imports, postCommitHooks, postModelActionHooks, postResourceActionHooks, preCommitHooks, preModelActionHooks, preResourceActionHooks, }?: IModuleOptions): (constructor: any) => void;
92
+ export {};
@@ -1,7 +1,7 @@
1
1
  import { RegistrationErrorEvent } from '../events/error.event.js';
2
2
  import { ModuleContainer } from '../modules/module.container.js';
3
3
  import { EventService } from '../services/event/event.service.js';
4
- import { Container } from './container.js';
4
+ import { Container } from '../functions/container/container.js';
5
5
  /**
6
6
  * A `@Module` is a class decorator to be placed on top of a class that represents a module.
7
7
  * - A Module class must implement the {@link IModule} interface.
@@ -54,7 +54,7 @@ import { Container } from './container.js';
54
54
  * @returns The decorated class.
55
55
  * @see Definition of [Modules](/docs/fundamentals/modules).
56
56
  */
57
- export function Module({ args = [], imports = [], postCommitHooks = [], postModelActionHooks = [], postResourceActionHooks = [], preCommitHooks = [], preModelActionHooks = [], preResourceActionHooks = [], }) {
57
+ export function Module({ args = [], imports = [], postCommitHooks = [], postModelActionHooks = [], postResourceActionHooks = [], preCommitHooks = [], preModelActionHooks = [], preResourceActionHooks = [], } = {}) {
58
58
  return function (constructor) {
59
59
  Container.get(ModuleContainer)
60
60
  .then((moduleContainer) => {
@@ -1 +1 @@
1
- {"version":3,"file":"module.decorator.js","sourceRoot":"","sources":["../../src/decorators/module.decorator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAGlE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;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e,EAAE,MAAM,gCAAgC,CAAC;AAGjE,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAiChE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,MAAM,UAAU,MAAM,CAAC,EACrB,IAAI,GAAG,EAAE,EACT,OAAO,GAAG,EAAE,EACZ,eAAe,GAAG,EAAE,EACpB,oBAAoB,GAAG,EAAE,EACzB,uBAAuB,GAAG,EAAE,EAC5B,cAAc,GAAG,EAAE,EACnB,mBAAmB,GAAG,EAAE,EACxB,sBAAsB,GAAG,EAAE,MACT,EAAE;IACpB,OAAO,UAAU,WAA4C;QAC3D,SAAS,CAAC,GAAG,CAAC,eAAe,CAAC;aAC3B,IAAI,CAAC,CAAC,eAAe,EAAE,EAAE;YACxB,kDAAkD;YAClD,IAAI,CAAC,CAAC,QAAQ,IAAI,WAAW,CAAC,SAAS,CAAC,EAAE,CAAC;gBACzC,MAAM,IAAI,KAAK,CAAC,UAAU,WAAW,CAAC,IAAI,+BAA+B,CAAC,CAAC;YAC7E,CAAC;YAED,eAAe,CAAC,QAAQ,CAAC,WAAW,EAAE;gBACpC,IAAI;gBACJ,OAAO;gBACP,eAAe;gBACf,oBAAoB;gBACpB,uBAAuB;gBACvB,cAAc;gBACd,mBAAmB;gBACnB,sBAAsB;aACvB,CAAC,CAAC;QACL,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,7 +1,7 @@
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
5
  /**
6
6
  * An `@Overlay` is a class decorator to be placed on top of a class that represents an overlay.
7
7
  * - An overlay must extend the {@link AOverlay} class.
@@ -1 +1 @@
1
- {"version":3,"file":"overlay.decorator.js","sourceRoot":"","sources":["../../src/decorators/overlay.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;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,OAAO;IACrB,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":"overlay.decorator.js","sourceRoot":"","sources":["../../src/decorators/overlay.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,OAAO;IACrB,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,7 +1,7 @@
1
1
  import { RegistrationErrorEvent } from '../events/error.event.js';
2
2
  import { EventService } from '../services/event/event.service.js';
3
3
  import { ResourceSerializationService } from '../services/serialization/resource/resource-serialization.service.js';
4
- import { Container } from './container.js';
4
+ import { Container } from '../functions/container/container.js';
5
5
  /**
6
6
  * A `@Resource` is a class decorator to be placed on top of a class that represents a resource.
7
7
  * - A resource must extend the {@link AResource} class.
@@ -1 +1 @@
1
- {"version":3,"file":"resource.decorator.js","sourceRoot":"","sources":["../../src/decorators/resource.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,4BAA4B,EAAE,MAAM,sEAAsE,CAAC;AACpH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,QAAQ;IACtB,OAAO,UAAU,WAAgB;QAC/B,SAAS,CAAC,GAAG,CAAC,4BAA4B,CAAC;aACxC,IAAI,CAAC,CAAC,4BAA4B,EAAE,EAAE;YACrC,4BAA4B,CAAC,aAAa,CAAC,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;QAC5E,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":"resource.decorator.js","sourceRoot":"","sources":["../../src/decorators/resource.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,4BAA4B,EAAE,MAAM,sEAAsE,CAAC;AACpH,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAEhE;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,QAAQ;IACtB,OAAO,UAAU,WAAgB;QAC/B,SAAS,CAAC,GAAG,CAAC,4BAA4B,CAAC;aACxC,IAAI,CAAC,CAAC,4BAA4B,EAAE,EAAE;YACrC,4BAA4B,CAAC,aAAa,CAAC,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;QAC5E,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,4 +1,4 @@
1
- import type { Constructable } from '../app.type.js';
1
+ import type { Constructable } from '../../app.type.js';
2
2
  type Factory<T> = {
3
3
  create: (...args: unknown[]) => Promise<T>;
4
4
  };
@@ -20,53 +20,22 @@ export declare class Container {
20
20
  * @param type The type or name of the class to get.
21
21
  * @param options Allows selection of a specific factory to use to get the instance.
22
22
  * - The `args` option supplies arguments to the factory.
23
- * - The `metadata` option identifies the factory.
24
23
  * @returns The instance of the class.
25
24
  */
26
25
  static get<T>(type: Constructable<T> | string, options?: {
27
26
  args?: unknown[];
28
- metadata?: {
29
- [key: string]: string;
30
- };
31
27
  }): Promise<T>;
32
28
  /**
33
29
  * `Container.registerFactory()` allows to register a factory for a class.
34
30
  *
35
31
  * @param type The type or name of the class for which the factory is registered.
36
32
  * @param factory The factory class being registered.
37
- * @param options Distinguishes between different factories of the same class.
38
- * - The `metadata` attaches custom metadata to the factory.
39
33
  */
40
- static registerFactory<T>(type: Constructable<T> | string, factory: Factory<T>, options?: {
41
- metadata?: {
42
- [key: string]: string;
43
- };
44
- }): void;
34
+ static registerFactory<T>(type: Constructable<T> | string, factory: Factory<T>): void;
45
35
  /**
46
36
  * `Container.reset()` clears all registered factories and empties the container. This is mostly used in testing.
47
37
  */
48
38
  static reset(): void;
49
- /**
50
- * `Container.setDefault()` sets a default factory for the class.
51
- *
52
- * @example
53
- * ```ts
54
- * // Register a factory.
55
- * Container.registerFactory(MyClass, MyClassFactory, { metadata: { key: 'value' } });
56
- *
57
- * // Without default.
58
- * Container.get(MyClass, { metadata: { key: 'value' } });
59
- *
60
- * // Set default.
61
- * Container.setDefault(MyClass, MyClassFactory);
62
- *
63
- * // With default.
64
- * Container.get(MyClass);
65
- * ```
66
- * @param type The type or name of the class for which the default factory is set.
67
- * @param factory The factory class being set as default.
68
- */
69
- static setDefault<T>(type: Constructable<T> | string, factory: Factory<T>): void;
70
39
  /**
71
40
  * The Container, by default, will wait a maximum of 5 seconds for a factory to resolve and provide an instance.
72
41
  * This method allows to change that timeout.
@@ -16,27 +16,12 @@ export class Container {
16
16
  * @param type The type or name of the class to get.
17
17
  * @param options Allows selection of a specific factory to use to get the instance.
18
18
  * - The `args` option supplies arguments to the factory.
19
- * - The `metadata` option identifies the factory.
20
19
  * @returns The instance of the class.
21
20
  */
22
21
  static async get(type, options) {
23
22
  const args = options?.args || [];
24
- const metadata = options?.metadata;
25
23
  const name = typeof type === 'string' ? type : type.name;
26
- if (!(name in this.factories)) {
27
- this.factories[name] = [];
28
- }
29
- let factoryContainer;
30
- if (!metadata) {
31
- factoryContainer = this.factories[name].find((f) => f.default);
32
- }
33
- else {
34
- const filters = [];
35
- for (const key in metadata) {
36
- filters.push({ key, value: metadata[key] });
37
- }
38
- factoryContainer = this.factories[name].find((f) => filters.every((c) => f.metadata[c.key] === c.value));
39
- }
24
+ const factoryContainer = this.factories[name];
40
25
  if (factoryContainer?.factory) {
41
26
  if (!Array.isArray(factoryContainer.factory)) {
42
27
  return factoryContainer.factory.create(...args);
@@ -46,11 +31,8 @@ export class Container {
46
31
  return factory.create(...args);
47
32
  }
48
33
  }
49
- const newFactoryContainer = {
50
- default: true,
51
- metadata,
52
- };
53
- this.factories[name].push(newFactoryContainer);
34
+ const newFactoryContainer = {};
35
+ this.factories[name] = newFactoryContainer;
54
36
  let promiseResolver;
55
37
  let promiseTimeout;
56
38
  const promise = new Promise((resolve, reject) => {
@@ -71,34 +53,23 @@ export class Container {
71
53
  *
72
54
  * @param type The type or name of the class for which the factory is registered.
73
55
  * @param factory The factory class being registered.
74
- * @param options Distinguishes between different factories of the same class.
75
- * - The `metadata` attaches custom metadata to the factory.
76
56
  */
77
- static registerFactory(type, factory, options) {
78
- const metadata = options?.metadata || {};
57
+ static registerFactory(type, factory) {
79
58
  const name = typeof type === 'string' ? type : type.name;
80
- if (!(name in this.factories)) {
81
- this.factories[name] = [];
82
- }
83
- const filters = [];
84
- for (const key in metadata) {
85
- filters.push({ key, value: metadata[key] });
86
- }
87
- const factoryContainer = this.factories[name].find((f) => filters.every((c) => f.metadata[c.key] === c.value));
59
+ const factoryContainer = this.factories[name];
88
60
  if (factoryContainer?.factory) {
89
61
  // If factory is not a promise set by get() above, it has already been registered.
90
62
  if (!Array.isArray(factoryContainer.factory)) {
91
63
  return;
92
64
  }
93
- factoryContainer.metadata = metadata;
94
65
  const resolve = factoryContainer.factory[1];
95
66
  resolve(factory);
96
67
  factoryContainer.factory = factory;
97
- this.setDefault(type, factory);
98
68
  return;
99
69
  }
100
- this.factories[name].push({ default: false, factory, metadata });
101
- this.setDefault(type, factory);
70
+ else {
71
+ this.factories[name] = { factory };
72
+ }
102
73
  }
103
74
  /**
104
75
  * `Container.reset()` clears all registered factories and empties the container. This is mostly used in testing.
@@ -109,32 +80,6 @@ export class Container {
109
80
  delete this.factories[name];
110
81
  }
111
82
  }
112
- /**
113
- * `Container.setDefault()` sets a default factory for the class.
114
- *
115
- * @example
116
- * ```ts
117
- * // Register a factory.
118
- * Container.registerFactory(MyClass, MyClassFactory, { metadata: { key: 'value' } });
119
- *
120
- * // Without default.
121
- * Container.get(MyClass, { metadata: { key: 'value' } });
122
- *
123
- * // Set default.
124
- * Container.setDefault(MyClass, MyClassFactory);
125
- *
126
- * // With default.
127
- * Container.get(MyClass);
128
- * ```
129
- * @param type The type or name of the class for which the default factory is set.
130
- * @param factory The factory class being set as default.
131
- */
132
- static setDefault(type, factory) {
133
- const name = typeof type === 'string' ? type : type.name;
134
- this.factories[name]?.forEach((f) => {
135
- f.default = f.factory.name === factory.name;
136
- });
137
- }
138
83
  /**
139
84
  * The Container, by default, will wait a maximum of 5 seconds for a factory to resolve and provide an instance.
140
85
  * This method allows to change that timeout.