@quadnix/octo 0.0.20 → 0.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.type.d.ts +5 -0
- package/dist/app.type.js +6 -0
- package/dist/app.type.js.map +1 -1
- package/dist/decorators/action.decorator.d.ts +17 -0
- package/dist/decorators/action.decorator.js +23 -0
- package/dist/decorators/action.decorator.js.map +1 -1
- package/dist/decorators/anchor.decorator.d.ts +13 -0
- package/dist/decorators/anchor.decorator.js +13 -0
- package/dist/decorators/anchor.decorator.js.map +1 -1
- package/dist/decorators/container.d.ts +60 -0
- package/dist/decorators/container.js +63 -2
- package/dist/decorators/container.js.map +1 -1
- package/dist/decorators/enable-hook.decorator.d.ts +14 -0
- package/dist/decorators/enable-hook.decorator.js +14 -0
- package/dist/decorators/enable-hook.decorator.js.map +1 -1
- package/dist/decorators/event-source.decorator.d.ts +15 -0
- package/dist/decorators/event-source.decorator.js +15 -0
- package/dist/decorators/event-source.decorator.js.map +1 -1
- package/dist/decorators/factory.decorator.d.ts +30 -0
- package/dist/decorators/factory.decorator.js +30 -0
- package/dist/decorators/factory.decorator.js.map +1 -1
- package/dist/decorators/model.decorator.d.ts +13 -0
- package/dist/decorators/model.decorator.js +13 -0
- package/dist/decorators/model.decorator.js.map +1 -1
- package/dist/decorators/module.decorator.d.ts +52 -0
- package/dist/decorators/module.decorator.js +60 -1
- package/dist/decorators/module.decorator.js.map +1 -1
- package/dist/decorators/on-event.decorator.d.ts +17 -0
- package/dist/decorators/on-event.decorator.js +17 -0
- package/dist/decorators/on-event.decorator.js.map +1 -1
- package/dist/decorators/overlay.decorator.d.ts +13 -0
- package/dist/decorators/overlay.decorator.js +13 -0
- package/dist/decorators/overlay.decorator.js.map +1 -1
- package/dist/decorators/resource.decorator.d.ts +13 -0
- package/dist/decorators/resource.decorator.js +13 -0
- package/dist/decorators/resource.decorator.js.map +1 -1
- package/dist/decorators/test-container.d.ts +52 -0
- package/dist/decorators/test-container.js +54 -2
- package/dist/decorators/test-container.js.map +1 -1
- package/dist/decorators/validate.decorator.d.ts +9 -0
- package/dist/decorators/validate.decorator.js +23 -0
- package/dist/decorators/validate.decorator.js.map +1 -0
- package/dist/events/error.event.d.ts +30 -0
- package/dist/events/error.event.js +30 -0
- package/dist/events/error.event.js.map +1 -1
- package/dist/events/event.model.d.ts +27 -0
- package/dist/events/event.model.js +27 -3
- package/dist/events/event.model.js.map +1 -1
- package/dist/events/hook.event.d.ts +167 -0
- package/dist/events/hook.event.js +167 -0
- package/dist/events/hook.event.js.map +1 -1
- package/dist/events/module.event.d.ts +12 -0
- package/dist/events/module.event.js +12 -0
- package/dist/events/module.event.js.map +1 -1
- package/dist/events/registration.event.d.ts +90 -0
- package/dist/events/registration.event.js +90 -0
- package/dist/events/registration.event.js.map +1 -1
- package/dist/events/serialization.event.d.ts +61 -0
- package/dist/events/serialization.event.js +61 -0
- package/dist/events/serialization.event.js.map +1 -1
- package/dist/events/transaction.event.d.ts +41 -0
- package/dist/events/transaction.event.js +41 -0
- package/dist/events/transaction.event.js.map +1 -1
- package/dist/functions/dependency/dependency.js +1 -8
- package/dist/functions/dependency/dependency.js.map +1 -1
- package/dist/functions/diff/diff-metadata.d.ts +3 -0
- package/dist/functions/diff/diff-metadata.js +5 -10
- package/dist/functions/diff/diff-metadata.js.map +1 -1
- package/dist/functions/diff/diff.d.ts +3 -0
- package/dist/functions/diff/diff.js +3 -4
- package/dist/functions/diff/diff.js.map +1 -1
- package/dist/functions/diff/diff.utility.d.ts +32 -0
- package/dist/functions/diff/diff.utility.js +49 -0
- package/dist/functions/diff/diff.utility.js.map +1 -1
- package/dist/functions/hook/commit.hook.js +6 -3
- package/dist/functions/hook/commit.hook.js.map +1 -1
- package/dist/functions/hook/model-action.hook.js +6 -3
- package/dist/functions/hook/model-action.hook.js.map +1 -1
- package/dist/functions/hook/resource-action.hook.js +6 -3
- package/dist/functions/hook/resource-action.hook.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts +4 -1
- package/dist/main.js +27 -15
- package/dist/main.js.map +1 -1
- package/dist/models/app/app.interface.d.ts +5 -0
- package/dist/models/app/app.model.d.ts +29 -0
- package/dist/models/app/app.model.js +40 -3
- package/dist/models/app/app.model.js.map +1 -1
- package/dist/models/deployment/deployment.interface.d.ts +5 -0
- package/dist/models/deployment/deployment.model.d.ts +15 -0
- package/dist/models/deployment/deployment.model.js +20 -3
- package/dist/models/deployment/deployment.model.js.map +1 -1
- package/dist/models/environment/environment.interface.d.ts +5 -0
- package/dist/models/environment/environment.model.d.ts +18 -0
- package/dist/models/environment/environment.model.js +33 -4
- package/dist/models/environment/environment.model.js.map +1 -1
- package/dist/models/execution/execution.interface.d.ts +5 -0
- package/dist/models/execution/execution.model.d.ts +23 -0
- package/dist/models/execution/execution.model.js +39 -2
- package/dist/models/execution/execution.model.js.map +1 -1
- package/dist/models/image/image.interface.d.ts +5 -0
- package/dist/models/image/image.model.d.ts +35 -0
- package/dist/models/image/image.model.js +25 -6
- package/dist/models/image/image.model.js.map +1 -1
- package/dist/models/model-action.interface.d.ts +21 -0
- package/dist/models/model.abstract.d.ts +265 -0
- package/dist/models/model.abstract.js +274 -5
- package/dist/models/model.abstract.js.map +1 -1
- package/dist/models/model.interface.d.ts +25 -0
- package/dist/models/pipeline/pipeline.interface.d.ts +5 -0
- package/dist/models/pipeline/pipeline.model.d.ts +15 -0
- package/dist/models/pipeline/pipeline.model.js +25 -4
- package/dist/models/pipeline/pipeline.model.js.map +1 -1
- package/dist/models/region/region.interface.d.ts +5 -0
- package/dist/models/region/region.model.d.ts +18 -0
- package/dist/models/region/region.model.js +29 -3
- package/dist/models/region/region.model.js.map +1 -1
- package/dist/models/server/server.interface.d.ts +5 -0
- package/dist/models/server/server.model.d.ts +17 -0
- package/dist/models/server/server.model.js +24 -3
- package/dist/models/server/server.model.js.map +1 -1
- package/dist/models/service/service.interface.d.ts +5 -0
- package/dist/models/service/service.model.d.ts +15 -0
- package/dist/models/service/service.model.js +19 -2
- package/dist/models/service/service.model.js.map +1 -1
- package/dist/models/subnet/subnet.interface.d.ts +5 -0
- package/dist/models/subnet/subnet.model.d.ts +48 -0
- package/dist/models/subnet/subnet.model.js +52 -7
- package/dist/models/subnet/subnet.model.js.map +1 -1
- package/dist/modules/module.container.d.ts +2 -0
- package/dist/modules/module.container.js +17 -8
- package/dist/modules/module.container.js.map +1 -1
- package/dist/modules/test-module.container.d.ts +2 -2
- package/dist/modules/test-module.container.js +10 -7
- package/dist/modules/test-module.container.js.map +1 -1
- package/dist/overlays/anchor.abstract.js +0 -3
- package/dist/overlays/anchor.abstract.js.map +1 -1
- package/dist/overlays/overlay-data.repository.js +0 -3
- package/dist/overlays/overlay-data.repository.js.map +1 -1
- package/dist/overlays/overlay.abstract.js +3 -3
- package/dist/overlays/overlay.abstract.js.map +1 -1
- package/dist/overlays/overlay.service.js +0 -2
- package/dist/overlays/overlay.service.js.map +1 -1
- package/dist/resources/resource-data.repository.js +6 -3
- package/dist/resources/resource-data.repository.js.map +1 -1
- package/dist/resources/resource.abstract.js +4 -4
- package/dist/resources/resource.abstract.js.map +1 -1
- package/dist/resources/shared-resource.abstract.js +4 -1
- package/dist/resources/shared-resource.abstract.js.map +1 -1
- package/dist/services/capture/capture.service.js +3 -2
- package/dist/services/capture/capture.service.js.map +1 -1
- package/dist/services/event/event.service.js +8 -5
- package/dist/services/event/event.service.js.map +1 -1
- package/dist/services/input/input.service.js +1 -3
- package/dist/services/input/input.service.js.map +1 -1
- package/dist/services/serialization/model/model-serialization.service.js +10 -4
- package/dist/services/serialization/model/model-serialization.service.js.map +1 -1
- package/dist/services/serialization/resource/resource-serialization.service.js +17 -4
- package/dist/services/serialization/resource/resource-serialization.service.js.map +1 -1
- package/dist/services/state-management/local.state-provider.js +0 -1
- package/dist/services/state-management/local.state-provider.js.map +1 -1
- package/dist/services/state-management/state-management.service.js +0 -2
- package/dist/services/state-management/state-management.service.js.map +1 -1
- package/dist/services/state-management/test.state-provider.js +3 -1
- package/dist/services/state-management/test.state-provider.js.map +1 -1
- package/dist/services/transaction/transaction.service.d.ts +4 -0
- package/dist/services/transaction/transaction.service.js +40 -8
- package/dist/services/transaction/transaction.service.js.map +1 -1
- package/dist/services/validation/validation.service.d.ts +19 -0
- package/dist/services/validation/validation.service.js +66 -0
- package/dist/services/validation/validation.service.js.map +1 -0
- package/dist/utilities/object/object.utility.js +1 -0
- package/dist/utilities/object/object.utility.js.map +1 -1
- package/dist/utilities/validation/validation.utility.d.ts +5 -0
- package/dist/utilities/validation/validation.utility.js +12 -0
- package/dist/utilities/validation/validation.utility.js.map +1 -0
- package/package.json +1 -1
package/dist/app.type.d.ts
CHANGED
|
@@ -13,6 +13,11 @@ export declare enum ModelType {
|
|
|
13
13
|
RESOURCE = "resource",
|
|
14
14
|
SHARED_RESOURCE = "shared-resource"
|
|
15
15
|
}
|
|
16
|
+
export declare enum ValidationType {
|
|
17
|
+
MAX_LENGTH = "maxLength",
|
|
18
|
+
MIN_LENGTH = "minLength",
|
|
19
|
+
REGEX = "regex"
|
|
20
|
+
}
|
|
16
21
|
export type ActionInputs = {
|
|
17
22
|
[key: string]: string | UnknownResource;
|
|
18
23
|
};
|
package/dist/app.type.js
CHANGED
|
@@ -5,4 +5,10 @@ export var ModelType;
|
|
|
5
5
|
ModelType["RESOURCE"] = "resource";
|
|
6
6
|
ModelType["SHARED_RESOURCE"] = "shared-resource";
|
|
7
7
|
})(ModelType || (ModelType = {}));
|
|
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
|
package/dist/app.type.js.map
CHANGED
|
@@ -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":"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,2 +1,19 @@
|
|
|
1
1
|
import { ModelType } 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 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.
|
|
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
|
+
*/
|
|
2
19
|
export declare function Action(type: ModelType): (constructor: any) => void;
|
|
@@ -5,26 +5,49 @@ 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
7
|
import { Container } from './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 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.
|
|
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
30
|
case ModelType.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
38
|
case ModelType.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
46
|
case ModelType.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;
|
|
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;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S,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;
|
|
@@ -2,6 +2,19 @@ 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
4
|
import { Container } from './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,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"}
|
|
@@ -2,23 +2,83 @@ import type { Constructable } from '../app.type.js';
|
|
|
2
2
|
type Factory<T> = {
|
|
3
3
|
create: (...args: unknown[]) => Promise<T>;
|
|
4
4
|
};
|
|
5
|
+
/**
|
|
6
|
+
* The Container class is a box to hold all registered factories.
|
|
7
|
+
*
|
|
8
|
+
* In Octo, we minimize the use of the `new` keyword and get instance of a class using its factory.
|
|
9
|
+
* The factory has full control over how the instance is created.
|
|
10
|
+
*
|
|
11
|
+
* By using the Container and Factory concepts, it is possible to override internal class definitions at runtime.
|
|
12
|
+
* It is an incredibly powerful tool to customize implementation.
|
|
13
|
+
*/
|
|
5
14
|
export declare class Container {
|
|
6
15
|
private static FACTORY_TIMEOUT_IN_MS;
|
|
7
16
|
private static readonly factories;
|
|
17
|
+
/**
|
|
18
|
+
* `Container.get()` allows to get an instance of a class using its factory.
|
|
19
|
+
*
|
|
20
|
+
* @param type The type or name of the class to get.
|
|
21
|
+
* @param options Allows selection of a specific factory to use to get the instance.
|
|
22
|
+
* - The `args` option supplies arguments to the factory.
|
|
23
|
+
* - The `metadata` option identifies the factory.
|
|
24
|
+
* @returns The instance of the class.
|
|
25
|
+
*/
|
|
8
26
|
static get<T>(type: Constructable<T> | string, options?: {
|
|
9
27
|
args?: unknown[];
|
|
10
28
|
metadata?: {
|
|
11
29
|
[key: string]: string;
|
|
12
30
|
};
|
|
13
31
|
}): Promise<T>;
|
|
32
|
+
/**
|
|
33
|
+
* `Container.registerFactory()` allows to register a factory for a class.
|
|
34
|
+
*
|
|
35
|
+
* @param type The type or name of the class for which the factory is registered.
|
|
36
|
+
* @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
|
+
*/
|
|
14
40
|
static registerFactory<T>(type: Constructable<T> | string, factory: Factory<T>, options?: {
|
|
15
41
|
metadata?: {
|
|
16
42
|
[key: string]: string;
|
|
17
43
|
};
|
|
18
44
|
}): void;
|
|
45
|
+
/**
|
|
46
|
+
* `Container.reset()` clears all registered factories and empties the container. This is mostly used in testing.
|
|
47
|
+
*/
|
|
19
48
|
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
|
+
*/
|
|
20
69
|
static setDefault<T>(type: Constructable<T> | string, factory: Factory<T>): void;
|
|
70
|
+
/**
|
|
71
|
+
* The Container, by default, will wait a maximum of 5 seconds for a factory to resolve and provide an instance.
|
|
72
|
+
* This method allows to change that timeout.
|
|
73
|
+
*
|
|
74
|
+
* @param timeoutInMs The timeout in milliseconds.
|
|
75
|
+
*/
|
|
21
76
|
static setFactoryTimeout(timeoutInMs: number): void;
|
|
77
|
+
/**
|
|
78
|
+
* `Container.unRegisterFactory()` will unregister all factories of a class.
|
|
79
|
+
*
|
|
80
|
+
* @param type The type or name of the class for which all factory is unregistered.
|
|
81
|
+
*/
|
|
22
82
|
static unRegisterFactory<T>(type: Constructable<T> | string): void;
|
|
23
83
|
}
|
|
24
84
|
export {};
|
|
@@ -1,6 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Container class is a box to hold all registered factories.
|
|
3
|
+
*
|
|
4
|
+
* In Octo, we minimize the use of the `new` keyword and get instance of a class using its factory.
|
|
5
|
+
* The factory has full control over how the instance is created.
|
|
6
|
+
*
|
|
7
|
+
* By using the Container and Factory concepts, it is possible to override internal class definitions at runtime.
|
|
8
|
+
* It is an incredibly powerful tool to customize implementation.
|
|
9
|
+
*/
|
|
1
10
|
export class Container {
|
|
2
|
-
static FACTORY_TIMEOUT_IN_MS = 5000;
|
|
3
|
-
static factories = {};
|
|
11
|
+
static { this.FACTORY_TIMEOUT_IN_MS = 5000; }
|
|
12
|
+
static { this.factories = {}; }
|
|
13
|
+
/**
|
|
14
|
+
* `Container.get()` allows to get an instance of a class using its factory.
|
|
15
|
+
*
|
|
16
|
+
* @param type The type or name of the class to get.
|
|
17
|
+
* @param options Allows selection of a specific factory to use to get the instance.
|
|
18
|
+
* - The `args` option supplies arguments to the factory.
|
|
19
|
+
* - The `metadata` option identifies the factory.
|
|
20
|
+
* @returns The instance of the class.
|
|
21
|
+
*/
|
|
4
22
|
static async get(type, options) {
|
|
5
23
|
const args = options?.args || [];
|
|
6
24
|
const metadata = options?.metadata;
|
|
@@ -48,6 +66,14 @@ export class Container {
|
|
|
48
66
|
}
|
|
49
67
|
return factory.create(...args);
|
|
50
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* `Container.registerFactory()` allows to register a factory for a class.
|
|
71
|
+
*
|
|
72
|
+
* @param type The type or name of the class for which the factory is registered.
|
|
73
|
+
* @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
|
+
*/
|
|
51
77
|
static registerFactory(type, factory, options) {
|
|
52
78
|
const metadata = options?.metadata || {};
|
|
53
79
|
const name = typeof type === 'string' ? type : type.name;
|
|
@@ -60,6 +86,7 @@ export class Container {
|
|
|
60
86
|
}
|
|
61
87
|
const factoryContainer = this.factories[name].find((f) => filters.every((c) => f.metadata[c.key] === c.value));
|
|
62
88
|
if (factoryContainer?.factory) {
|
|
89
|
+
// If factory is not a promise set by get() above, it has already been registered.
|
|
63
90
|
if (!Array.isArray(factoryContainer.factory)) {
|
|
64
91
|
return;
|
|
65
92
|
}
|
|
@@ -73,21 +100,55 @@ export class Container {
|
|
|
73
100
|
this.factories[name].push({ default: false, factory, metadata });
|
|
74
101
|
this.setDefault(type, factory);
|
|
75
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* `Container.reset()` clears all registered factories and empties the container. This is mostly used in testing.
|
|
105
|
+
*/
|
|
76
106
|
static reset() {
|
|
77
107
|
this.FACTORY_TIMEOUT_IN_MS = 5000;
|
|
78
108
|
for (const name in this.factories) {
|
|
79
109
|
delete this.factories[name];
|
|
80
110
|
}
|
|
81
111
|
}
|
|
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
|
+
*/
|
|
82
132
|
static setDefault(type, factory) {
|
|
83
133
|
const name = typeof type === 'string' ? type : type.name;
|
|
84
134
|
this.factories[name]?.forEach((f) => {
|
|
85
135
|
f.default = f.factory.name === factory.name;
|
|
86
136
|
});
|
|
87
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* The Container, by default, will wait a maximum of 5 seconds for a factory to resolve and provide an instance.
|
|
140
|
+
* This method allows to change that timeout.
|
|
141
|
+
*
|
|
142
|
+
* @param timeoutInMs The timeout in milliseconds.
|
|
143
|
+
*/
|
|
88
144
|
static setFactoryTimeout(timeoutInMs) {
|
|
89
145
|
this.FACTORY_TIMEOUT_IN_MS = timeoutInMs;
|
|
90
146
|
}
|
|
147
|
+
/**
|
|
148
|
+
* `Container.unRegisterFactory()` will unregister all factories of a class.
|
|
149
|
+
*
|
|
150
|
+
* @param type The type or name of the class for which all factory is unregistered.
|
|
151
|
+
*/
|
|
91
152
|
static unRegisterFactory(type) {
|
|
92
153
|
const name = typeof type === 'string' ? type : type.name;
|
|
93
154
|
delete this.factories[name];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container.js","sourceRoot":"","sources":["../../src/decorators/container.ts"],"names":[],"mappings":"AAKA,MAAM,OAAO,SAAS;
|
|
1
|
+
{"version":3,"file":"container.js","sourceRoot":"","sources":["../../src/decorators/container.ts"],"names":[],"mappings":"AAKA;;;;;;;;GAQG;AACH,MAAM,OAAO,SAAS;aACL,0BAAqB,GAAG,IAAI,CAAC;aAEpB,cAAS,GAM7B,EAAE,CAAC;IAEP;;;;;;;;OAQG;IACH,MAAM,CAAC,KAAK,CAAC,GAAG,CACd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Hook')
|
|
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,4 +1,34 @@
|
|
|
1
1
|
import type { Constructable } from '../app.type.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
|
+
* 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
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* // Factory definition.
|
|
13
|
+
* @Factory<MyService>(MyService, { metadata: { key: 'value' } })
|
|
14
|
+
* export class MyServiceFactory {
|
|
15
|
+
* static async create(arg1, arg2, ...): Promise<MyService> { ... }>
|
|
16
|
+
* }
|
|
17
|
+
*
|
|
18
|
+
* // Get instance using default factory.
|
|
19
|
+
* const myService = await Container.get(MyService);
|
|
20
|
+
*
|
|
21
|
+
* // Get instance using specific factory.
|
|
22
|
+
* const myService = await Container.get(MyService, { metadata: { key: 'value' } });
|
|
23
|
+
*
|
|
24
|
+
* // Pass args to factory.
|
|
25
|
+
* const myService = await Container.get(MyService, { args: [arg1, arg2, ...] });
|
|
26
|
+
* ```
|
|
27
|
+
* @group Decorators
|
|
28
|
+
* @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.
|
|
30
|
+
* @returns The decorated class.
|
|
31
|
+
*/
|
|
2
32
|
export declare function Factory<T>(type: Constructable<T> | string, options?: {
|
|
3
33
|
metadata?: {
|
|
4
34
|
[key: string]: string;
|
|
@@ -1,4 +1,34 @@
|
|
|
1
1
|
import { Container } from './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
|
+
* 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
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* // Factory definition.
|
|
13
|
+
* @Factory<MyService>(MyService, { metadata: { key: 'value' } })
|
|
14
|
+
* export class MyServiceFactory {
|
|
15
|
+
* static async create(arg1, arg2, ...): Promise<MyService> { ... }>
|
|
16
|
+
* }
|
|
17
|
+
*
|
|
18
|
+
* // Get instance using default factory.
|
|
19
|
+
* const myService = await Container.get(MyService);
|
|
20
|
+
*
|
|
21
|
+
* // Get instance using specific factory.
|
|
22
|
+
* const myService = await Container.get(MyService, { metadata: { key: 'value' } });
|
|
23
|
+
*
|
|
24
|
+
* // Pass args to factory.
|
|
25
|
+
* const myService = await Container.get(MyService, { args: [arg1, arg2, ...] });
|
|
26
|
+
* ```
|
|
27
|
+
* @group Decorators
|
|
28
|
+
* @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.
|
|
30
|
+
* @returns The decorated class.
|
|
31
|
+
*/
|
|
2
32
|
export function Factory(type, options) {
|
|
3
33
|
return function (constructor) {
|
|
4
34
|
Container.registerFactory(type, constructor, options);
|
|
@@ -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,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 +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;
|
|
@@ -2,6 +2,19 @@ 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
4
|
import { Container } from './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,MAA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AAI,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAAC;QACrE,CAAC,CAAC,CAAC;IACP,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -3,6 +3,58 @@ import type { Octo } from '../main.js';
|
|
|
3
3
|
import type { IModelAction } from '../models/model-action.interface.js';
|
|
4
4
|
import { type IModule } from '../modules/module.interface.js';
|
|
5
5
|
import type { IResourceAction } from '../resources/resource-action.interface.js';
|
|
6
|
+
/**
|
|
7
|
+
* A `@Module` is a class decorator to be placed on top of a class that represents a module.
|
|
8
|
+
* - A Module class must implement the {@link IModule} interface.
|
|
9
|
+
* - A Module class constructor is injected with the outputs of the modules it imports.
|
|
10
|
+
* - The {@link IModule.onInit} method is called to initialize the module,
|
|
11
|
+
* and is where you will *define* your infrastructure.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* @Module({
|
|
16
|
+
* args: [{ isArg: (app: App) => app instanceof App, name: 'app' }],
|
|
17
|
+
* imports: [OtherModule],
|
|
18
|
+
* postModelActionHooks: [{ ACTION_NAME: 'SomeAction', collectInput: () => { ... }, handle: () => { ... } }],
|
|
19
|
+
* })
|
|
20
|
+
* export class MyModule implements IModule<Region> {
|
|
21
|
+
* constructor(app: App) { ... }
|
|
22
|
+
*
|
|
23
|
+
* async onInit(): Promise<Region> { ... }
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
* @group Decorators
|
|
27
|
+
* @param options - Options to the module.
|
|
28
|
+
* @param options.args - (optional) An array of arg validators to verify the args passed to the module's constructor.
|
|
29
|
+
* - The `isArg` method receives an argument, and you must do your own type checking and return a boolean.
|
|
30
|
+
* - The `name` property is the name of the argument.
|
|
31
|
+
* @param options.imports - (optional) An array of modules to import.
|
|
32
|
+
* @param options.postCommitHooks - (optional) An array of post-commit hooks.
|
|
33
|
+
* - The `callback` method will be called after the transaction is committed.
|
|
34
|
+
* This method receives the same arguments as {@link Octo.commitTransaction}.
|
|
35
|
+
* @param options.postModelActionHooks - (optional) An array of post-model action hooks.
|
|
36
|
+
* - The `ACTION_NAME` identifies the action on which this hook is registered.
|
|
37
|
+
* - The `collectInput` method can be used to enrich the action inputs. It works the same as in {@link IModelAction}.
|
|
38
|
+
* - The `handle` method will be called after the action is executed.
|
|
39
|
+
* This method receives the same arguments as {@link IModelAction.handle}.
|
|
40
|
+
* @param options.postResourceActionHooks - (optional) An array of post-resource action hooks.
|
|
41
|
+
* - The `ACTION_NAME` identifies the action on which this hook is registered.
|
|
42
|
+
* - The `handle` method will be called after the action is executed.
|
|
43
|
+
* This method receives the same arguments as {@link IResourceAction.handle}.
|
|
44
|
+
* @param options.preCommitHooks - (optional) An array of pre-commit hooks.
|
|
45
|
+
* - The `callback` method will be called before the transaction is committed.
|
|
46
|
+
* This method receives the same arguments as {@link Octo.commitTransaction}.
|
|
47
|
+
* @param options.preModelActionHooks - (optional) An array of pre-model action hooks.
|
|
48
|
+
* - The `ACTION_NAME` identifies the action on which this hook is registered.
|
|
49
|
+
* - The `collectInput` method can be used to enrich the action inputs. It works the same as in {@link IModelAction}.
|
|
50
|
+
* - The `handle` method will be called before the action is executed.
|
|
51
|
+
* This method receives the same arguments as {@link IModelAction.handle}.
|
|
52
|
+
* @param options.preResourceActionHooks - (optional) An array of pre-resource action hooks.
|
|
53
|
+
* - The `ACTION_NAME` identifies the action on which this hook is registered.
|
|
54
|
+
* - The `handle` method will be called before the action is executed.
|
|
55
|
+
* @returns The decorated class.
|
|
56
|
+
* @see Definition of [Modules](/docs/fundamentals/modules).
|
|
57
|
+
*/
|
|
6
58
|
export declare function Module({ args, imports, postCommitHooks, postModelActionHooks, postResourceActionHooks, preCommitHooks, preModelActionHooks, preResourceActionHooks, }: {
|
|
7
59
|
args?: {
|
|
8
60
|
isArg: (arg: unknown) => boolean;
|