@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
|
@@ -5,10 +5,33 @@ import { Environment } from '../environment/environment.model.js';
|
|
|
5
5
|
import { AModel } from '../model.abstract.js';
|
|
6
6
|
import { Subnet } from '../subnet/subnet.model.js';
|
|
7
7
|
import type { IExecution } from './execution.interface.js';
|
|
8
|
+
/**
|
|
9
|
+
* An Execution model is the combination of a {@link Deployment}, an {@link Environment}, and a {@link Subnet}.
|
|
10
|
+
* It represents a physical server, running the deployment code, in the given environment, placed in the given subnet.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const deployment = new Deployment('v0.0.1');
|
|
15
|
+
* const environment = new Environment('qa');
|
|
16
|
+
* const subnet = new Subnet(region, 'private');
|
|
17
|
+
* const execution = new Execution(deployment, environment, subnet);
|
|
18
|
+
* ```
|
|
19
|
+
* @group Models
|
|
20
|
+
* @see Definition of [Default Models](/docs/fundamentals/models#default-models).
|
|
21
|
+
*/
|
|
8
22
|
export declare class Execution extends AModel<IExecution, Execution> {
|
|
9
23
|
readonly MODEL_NAME: string;
|
|
24
|
+
/**
|
|
25
|
+
* A set of environment variables to be passed to the Docker container.
|
|
26
|
+
* It represents setting the [--env](https://docs.docker.com/compose/environment-variables/set-environment-variables/)
|
|
27
|
+
* option while running a Docker container.
|
|
28
|
+
*/
|
|
10
29
|
readonly environmentVariables: Map<string, string>;
|
|
11
30
|
constructor(deployment: Deployment, environment: Environment, subnet: Subnet);
|
|
31
|
+
/**
|
|
32
|
+
* An `executionId` is a unique identifier for this execution.
|
|
33
|
+
* - Format of executionId is `{serverKey}-{deploymentTag}-{regionId}-{environmentName}-{subnetName}`
|
|
34
|
+
*/
|
|
12
35
|
get executionId(): string;
|
|
13
36
|
diffProperties(previous: Execution): Promise<Diff[]>;
|
|
14
37
|
setContext(): string;
|
|
@@ -9,17 +9,38 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
};
|
|
10
10
|
var Execution_1;
|
|
11
11
|
import { Model } from '../../decorators/model.decorator.js';
|
|
12
|
+
import { Validate } from '../../decorators/validate.decorator.js';
|
|
12
13
|
import { DiffUtility } from '../../functions/diff/diff.utility.js';
|
|
13
14
|
import { ArrayUtility } from '../../utilities/array/array.utility.js';
|
|
14
15
|
import { Deployment } from '../deployment/deployment.model.js';
|
|
15
16
|
import { Environment } from '../environment/environment.model.js';
|
|
16
17
|
import { AModel } from '../model.abstract.js';
|
|
17
18
|
import { Subnet } from '../subnet/subnet.model.js';
|
|
19
|
+
/**
|
|
20
|
+
* An Execution model is the combination of a {@link Deployment}, an {@link Environment}, and a {@link Subnet}.
|
|
21
|
+
* It represents a physical server, running the deployment code, in the given environment, placed in the given subnet.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* const deployment = new Deployment('v0.0.1');
|
|
26
|
+
* const environment = new Environment('qa');
|
|
27
|
+
* const subnet = new Subnet(region, 'private');
|
|
28
|
+
* const execution = new Execution(deployment, environment, subnet);
|
|
29
|
+
* ```
|
|
30
|
+
* @group Models
|
|
31
|
+
* @see Definition of [Default Models](/docs/fundamentals/models#default-models).
|
|
32
|
+
*/
|
|
18
33
|
let Execution = Execution_1 = class Execution extends AModel {
|
|
19
|
-
MODEL_NAME = 'execution';
|
|
20
|
-
environmentVariables = new Map();
|
|
21
34
|
constructor(deployment, environment, subnet) {
|
|
22
35
|
super();
|
|
36
|
+
this.MODEL_NAME = 'execution';
|
|
37
|
+
/**
|
|
38
|
+
* A set of environment variables to be passed to the Docker container.
|
|
39
|
+
* It represents setting the [--env](https://docs.docker.com/compose/environment-variables/set-environment-variables/)
|
|
40
|
+
* option while running a Docker container.
|
|
41
|
+
*/
|
|
42
|
+
this.environmentVariables = new Map();
|
|
43
|
+
// Check if execution can be placed in this subnet.
|
|
23
44
|
const environmentRegions = environment.getParents('region')['region'] || [];
|
|
24
45
|
const subnetRegions = subnet.getParents('region')['region'] || [];
|
|
25
46
|
if (environmentRegions.length > 0 &&
|
|
@@ -27,6 +48,7 @@ let Execution = Execution_1 = class Execution extends AModel {
|
|
|
27
48
|
environmentRegions[0].to.regionId !== subnetRegions[0].to.regionId) {
|
|
28
49
|
throw new Error('Environment and Subnet must be in the same region!');
|
|
29
50
|
}
|
|
51
|
+
// Check for duplicates.
|
|
30
52
|
const deploymentExecutions = (deployment.getChildren('execution')['execution'] || []).map((d) => d.to);
|
|
31
53
|
const environmentExecutions = (environment.getChildren('execution')['execution'] || []).map((d) => d.to);
|
|
32
54
|
const subnetExecutions = (subnet.getChildren('execution')['execution'] || []).map((d) => d.to);
|
|
@@ -35,10 +57,16 @@ let Execution = Execution_1 = class Execution extends AModel {
|
|
|
35
57
|
}, deploymentExecutions, environmentExecutions, subnetExecutions).length > 0) {
|
|
36
58
|
throw new Error('Execution already exists!');
|
|
37
59
|
}
|
|
60
|
+
// In order for this execution to properly have defined its parent-child relationship, all parents
|
|
61
|
+
// must claim it as their child. Doing it here, prevents the confusion.
|
|
38
62
|
deployment.addChild('deploymentTag', this, 'executionId');
|
|
39
63
|
environment.addChild('environmentName', this, 'executionId');
|
|
40
64
|
subnet.addChild('subnetId', this, 'executionId');
|
|
41
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* An `executionId` is a unique identifier for this execution.
|
|
68
|
+
* - Format of executionId is `{serverKey}-{deploymentTag}-{regionId}-{environmentName}-{subnetName}`
|
|
69
|
+
*/
|
|
42
70
|
get executionId() {
|
|
43
71
|
const parents = this.getParents();
|
|
44
72
|
const deployment = parents['deployment'][0].to;
|
|
@@ -94,6 +122,15 @@ let Execution = Execution_1 = class Execution extends AModel {
|
|
|
94
122
|
return newExecution;
|
|
95
123
|
}
|
|
96
124
|
};
|
|
125
|
+
__decorate([
|
|
126
|
+
Validate({
|
|
127
|
+
destruct: (value) => {
|
|
128
|
+
return Array.from(value.keys());
|
|
129
|
+
},
|
|
130
|
+
options: { maxLength: 64, minLength: 2, regex: /^[a-zA-Z][\w-]*[a-zA-Z0-9]$/ },
|
|
131
|
+
}),
|
|
132
|
+
__metadata("design:type", Map)
|
|
133
|
+
], Execution.prototype, "environmentVariables", void 0);
|
|
97
134
|
Execution = Execution_1 = __decorate([
|
|
98
135
|
Model(),
|
|
99
136
|
__metadata("design:paramtypes", [Deployment, Environment, Subnet])
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution.model.js","sourceRoot":"","sources":["../../../src/models/execution/execution.model.ts"],"names":[],"mappings":";;;;;;;;;;AACA,OAAO,EAAE,KAAK,EAAE,MAAM,qCAAqC,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAEnE,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAG9C,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"execution.model.js","sourceRoot":"","sources":["../../../src/models/execution/execution.model.ts"],"names":[],"mappings":";;;;;;;;;;AACA,OAAO,EAAE,KAAK,EAAE,MAAM,qCAAqC,CAAC;AAC5D,OAAO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AAC;QAED,OAAO,YAAY,CAAC;IACtB,CAAC;CACF,CAAA;AAnHU;IANR,QAAQ,CAAC;QACR,QAAQ,EAAE,CAAC,KAA0B,EAAY,EAAE;YACjD,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;QAClC,CAAC;QACD,OAAO,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,6BAA6B,EAAE;KAC/E,CAAC;8BAC6B,GAAG;uDAA6B;AAdpD,SAAS;IADrB,KAAK,EAAE;qCAiBkB,UAAU,EAAe,WAAW,EAAU,MAAM;GAhBjE,SAAS,CAiIrB"}
|
|
@@ -2,18 +2,53 @@ import type { UnknownModel } from '../../app.type.js';
|
|
|
2
2
|
import type { Diff } from '../../functions/diff/diff.js';
|
|
3
3
|
import { AModel } from '../model.abstract.js';
|
|
4
4
|
import type { IImage } from './image.interface.js';
|
|
5
|
+
/**
|
|
6
|
+
* Options passed to the Docker engine while building the image.
|
|
7
|
+
*/
|
|
5
8
|
export interface IImageDockerOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Absolute path of the Dockerfile.
|
|
11
|
+
*/
|
|
6
12
|
dockerfilePath: string;
|
|
13
|
+
/**
|
|
14
|
+
* Build arguments, same as [--build-arg](https://docs.docker.com/build/guide/build-args/) option.
|
|
15
|
+
*/
|
|
7
16
|
buildArgs?: {
|
|
8
17
|
[key: string]: string;
|
|
9
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* To suppress Docker output, same as [--quiet](https://docs.docker.com/reference/cli/docker/container/run/) option.
|
|
21
|
+
*/
|
|
10
22
|
quiet?: boolean;
|
|
11
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* An Image model represents a Docker image, to either build, or run, your microservices.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* const image = new Image('nginx', '2.4', { dockerfilePath: './Dockerfile' });
|
|
30
|
+
*
|
|
31
|
+
* const image = new Image('docker/hello-world', '1.0', { dockerfilePath: './Dockerfile' });
|
|
32
|
+
* ```
|
|
33
|
+
* @group Models
|
|
34
|
+
* @see Definition of [Default Models](/docs/fundamentals/models#default-models).
|
|
35
|
+
*/
|
|
12
36
|
export declare class Image extends AModel<IImage, Image> {
|
|
13
37
|
readonly MODEL_NAME: string;
|
|
14
38
|
readonly dockerOptions: IImageDockerOptions;
|
|
39
|
+
/**
|
|
40
|
+
* An imageId is the unique identifier for this image.
|
|
41
|
+
* - Format of imageId is `{imageName}:{imageTag}`
|
|
42
|
+
*/
|
|
15
43
|
readonly imageId: string;
|
|
44
|
+
/**
|
|
45
|
+
* The name of the image, same as [namespace in Docker](https://docs.docker.com/reference/cli/docker/image/tag/).
|
|
46
|
+
*/
|
|
16
47
|
readonly imageName: string;
|
|
48
|
+
/**
|
|
49
|
+
* The tag of the image, same as [tag in Docker](https://docs.docker.com/reference/cli/docker/image/tag/).
|
|
50
|
+
* - Unlike Docker, `imageTag` is mandatory in Octo.
|
|
51
|
+
*/
|
|
17
52
|
readonly imageTag: string;
|
|
18
53
|
constructor(imageName: string, imageTag: string, options: IImageDockerOptions);
|
|
19
54
|
diffProperties(): Promise<Diff[]>;
|
|
@@ -10,15 +10,24 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
var Image_1;
|
|
11
11
|
import { resolve } from 'path';
|
|
12
12
|
import { Model } from '../../decorators/model.decorator.js';
|
|
13
|
+
import { Validate } from '../../decorators/validate.decorator.js';
|
|
13
14
|
import { AModel } from '../model.abstract.js';
|
|
15
|
+
/**
|
|
16
|
+
* An Image model represents a Docker image, to either build, or run, your microservices.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* const image = new Image('nginx', '2.4', { dockerfilePath: './Dockerfile' });
|
|
21
|
+
*
|
|
22
|
+
* const image = new Image('docker/hello-world', '1.0', { dockerfilePath: './Dockerfile' });
|
|
23
|
+
* ```
|
|
24
|
+
* @group Models
|
|
25
|
+
* @see Definition of [Default Models](/docs/fundamentals/models#default-models).
|
|
26
|
+
*/
|
|
14
27
|
let Image = Image_1 = class Image extends AModel {
|
|
15
|
-
MODEL_NAME = 'image';
|
|
16
|
-
dockerOptions;
|
|
17
|
-
imageId;
|
|
18
|
-
imageName;
|
|
19
|
-
imageTag;
|
|
20
28
|
constructor(imageName, imageTag, options) {
|
|
21
29
|
super();
|
|
30
|
+
this.MODEL_NAME = 'image';
|
|
22
31
|
this.imageId = `${imageName}:${imageTag}`;
|
|
23
32
|
this.imageName = imageName;
|
|
24
33
|
this.imageTag = imageTag;
|
|
@@ -41,12 +50,22 @@ let Image = Image_1 = class Image extends AModel {
|
|
|
41
50
|
imageTag: this.imageTag,
|
|
42
51
|
};
|
|
43
52
|
}
|
|
44
|
-
static async unSynth(image,
|
|
53
|
+
static async unSynth(image,
|
|
54
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
55
|
+
deReferenceContext) {
|
|
45
56
|
return new Image_1(image.imageName, image.imageTag, {
|
|
46
57
|
...image.dockerOptions,
|
|
47
58
|
});
|
|
48
59
|
}
|
|
49
60
|
};
|
|
61
|
+
__decorate([
|
|
62
|
+
Validate({ options: { maxLength: 32, minLength: 2, regex: /^[a-zA-Z@][\w\-\/]*[a-zA-Z0-9]$/ } }),
|
|
63
|
+
__metadata("design:type", String)
|
|
64
|
+
], Image.prototype, "imageName", void 0);
|
|
65
|
+
__decorate([
|
|
66
|
+
Validate({ options: { maxLength: 32, minLength: 2, regex: /^[a-zA-Z0-9][\w.-]*[a-zA-Z0-9]$/ } }),
|
|
67
|
+
__metadata("design:type", String)
|
|
68
|
+
], Image.prototype, "imageTag", void 0);
|
|
50
69
|
Image = Image_1 = __decorate([
|
|
51
70
|
Model(),
|
|
52
71
|
__metadata("design:paramtypes", [String, String, Object])
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image.model.js","sourceRoot":"","sources":["../../../src/models/image/image.model.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE/B,OAAO,EAAE,KAAK,EAAE,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"image.model.js","sourceRoot":"","sources":["../../../src/models/image/image.model.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE/B,OAAO,EAAE,KAAK,EAAE,MAAM,qCAAqC,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAAC;AAElE,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAuB9C;;;;;;;;;;;GAWG;AAEI,IAAM,KAAK,aAAX,MAAM,KAAM,SAAQ,MAAqB;IAwB9C,YAAY,SAAiB,EAAE,QAAgB,EAAE,OAA4B;QAC3E,KAAK,EAAE,CAAC;QAxBD,eAAU,GAAW,OAAO,CAAC;QAyBpC,IAAI,CAAC,OAAO,GAAG,GAAG,SAAS,IAAI,QAAQ,EAAE,CAAC;QAC1C,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAEzB,OAAO,CAAC,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QACzD,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC;IAC/B,CAAC;IAEQ,KAAK,CAAC,cAAc;QAC3B,OAAO,EAAE,CAAC;IACZ,CAAC;IAEQ,UAAU;QACjB,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QAClC,MAAM,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACjC,OAAO,CAAC,GAAG,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC5E,CAAC;IAEQ,KAAK;QACZ,OAAO;YACL,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YAC7D,OAAO,EAAE,IAAI,CAAC,QAAQ;YACtB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAC;IACJ,CAAC;IAED,MAAM,CAAU,KAAK,CAAC,OAAO,CAC3B,KAAa;IACb,6DAA6D;IAC7D,kBAA8D;QAE9D,OAAO,IAAI,OAAK,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,QAAQ,EAAE;YAChD,GAAG,KAAK,CAAC,aAAa;SACvB,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AA/CU;IADR,QAAQ,CAAC,EAAE,OAAO,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,iCAAiC,EAAE,EAAE,CAAC;;wCACtE;AAOlB;IADR,QAAQ,CAAC,EAAE,OAAO,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,iCAAiC,EAAE,EAAE,CAAC;;uCACvE;AAtBf,KAAK;IADjB,KAAK,EAAE;;GACK,KAAK,CA8DjB"}
|
|
@@ -1,9 +1,30 @@
|
|
|
1
1
|
import type { ActionInputs, ActionOutputs } from '../app.type.js';
|
|
2
2
|
import type { Diff } from '../functions/diff/diff.js';
|
|
3
|
+
/**
|
|
4
|
+
* Actions are translation functions between Diff and underlying infrastructure.
|
|
5
|
+
* An action can translate a specific type of Diff into underlying infrastructure, and can revert it back.
|
|
6
|
+
*/
|
|
3
7
|
export interface IModelAction {
|
|
8
|
+
/**
|
|
9
|
+
* The name of the action.
|
|
10
|
+
* It can be used to easily identify an action and its purpose.
|
|
11
|
+
*/
|
|
4
12
|
readonly ACTION_NAME: string;
|
|
13
|
+
/**
|
|
14
|
+
* This function contains the list of inputs to ask before processing the diff.
|
|
15
|
+
* A missing input key will not be populated in the inputs provided to the action.
|
|
16
|
+
*/
|
|
5
17
|
collectInput(diff: Diff): Extract<keyof ActionInputs, string>[];
|
|
18
|
+
/**
|
|
19
|
+
* This function determines if the handle is applicable to the diff.
|
|
20
|
+
*/
|
|
6
21
|
filter(diff: Diff): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* This function contains the logic to apply the diff(s) to the underlying infrastructure.
|
|
24
|
+
*/
|
|
7
25
|
handle(diff: Diff, actionInputs: ActionInputs, actionOutputs: ActionOutputs): Promise<ActionOutputs>;
|
|
26
|
+
/**
|
|
27
|
+
* This function contains the logic to revert the diff(s) from the underlying infrastructure.
|
|
28
|
+
*/
|
|
8
29
|
revert(diff: Diff, actionInputs: ActionInputs, actionOutputs: ActionOutputs): Promise<ActionOutputs>;
|
|
9
30
|
}
|
|
@@ -3,6 +3,21 @@ import { Dependency, type DependencyRelationship } from '../functions/dependency
|
|
|
3
3
|
import { Diff } from '../functions/diff/diff.js';
|
|
4
4
|
import type { AAnchor } from '../overlays/anchor.abstract.js';
|
|
5
5
|
import type { IModel } from './model.interface.js';
|
|
6
|
+
/**
|
|
7
|
+
* This is Octo's base class, and all other classes extend from it.
|
|
8
|
+
* It helps provide a common set of methods and properties that is core to Octo.
|
|
9
|
+
*
|
|
10
|
+
* Octo is built as a graph, and this base class can be considered as a generic node.
|
|
11
|
+
* Nodes can have children, and siblings, but only if connected via an edge, called {@link Dependency} here.
|
|
12
|
+
*
|
|
13
|
+
* From this base class, three more base classes are derived,
|
|
14
|
+
* - [Models](/docs/fundamentals/models)
|
|
15
|
+
* - [Resources](/docs/fundamentals/resources)
|
|
16
|
+
* - [Overlays](/docs/fundamentals/overlay-and-anchor)
|
|
17
|
+
*
|
|
18
|
+
* Each of these derived base classes, using the base methods of this class,
|
|
19
|
+
* define their own specific rules on how their graphs should be constructed.
|
|
20
|
+
*/
|
|
6
21
|
export declare abstract class AModel<I, T> implements IModel<I, T> {
|
|
7
22
|
abstract readonly MODEL_NAME: string;
|
|
8
23
|
readonly MODEL_TYPE: ModelType;
|
|
@@ -10,51 +25,301 @@ export declare abstract class AModel<I, T> implements IModel<I, T> {
|
|
|
10
25
|
private readonly anchors;
|
|
11
26
|
private context;
|
|
12
27
|
private readonly dependencies;
|
|
28
|
+
/**
|
|
29
|
+
* To add an {@link Anchor}.
|
|
30
|
+
*
|
|
31
|
+
* Each node can store multiple anchors for reference.
|
|
32
|
+
* These anchors don't necessarily need to be parented by self, but must be unique,
|
|
33
|
+
* i.e. an anchor, identified by it's parent, cannot be added twice to self's list of anchors.
|
|
34
|
+
*/
|
|
13
35
|
addAnchor(anchor: AAnchor): void;
|
|
36
|
+
/**
|
|
37
|
+
* To add another node as a child of self.
|
|
38
|
+
*
|
|
39
|
+
* Every node must have a unique ID against other nodes of the same {@link MODEL_NAME}.
|
|
40
|
+
* This ID is how Octo differentiates similar nodes, and keeps track of them.
|
|
41
|
+
* But because each node is free to define their own fields,
|
|
42
|
+
* the fields containing the ID are a necessary input to this method.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* const region = new Region('region');
|
|
47
|
+
* const environment = new Environment('qa');
|
|
48
|
+
* region.addChild('regionId', environment, 'environmentName');
|
|
49
|
+
* ```
|
|
50
|
+
* @param onField The field in self which contains the unique ID.
|
|
51
|
+
* @param child The child node.
|
|
52
|
+
* @param toField The field in child which contains the unique ID.
|
|
53
|
+
* @returns
|
|
54
|
+
* - childToParentDependency: The dependency edge from child to self.
|
|
55
|
+
* - parentToChildDependency: The dependency edge from self to child.
|
|
56
|
+
*/
|
|
14
57
|
addChild(onField: keyof T | string, child: UnknownModel, toField: string): {
|
|
15
58
|
childToParentDependency: Dependency;
|
|
16
59
|
parentToChildDependency: Dependency;
|
|
17
60
|
};
|
|
61
|
+
/**
|
|
62
|
+
* To add another node as a sibling of self.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* const region1 = new Region('region-1');
|
|
67
|
+
* const region2 = new Region('region-2');
|
|
68
|
+
* region1.addSibling(region2);
|
|
69
|
+
* ```
|
|
70
|
+
* @param to The sibling node.
|
|
71
|
+
* @returns
|
|
72
|
+
* - thatToThisDependency: The dependency edge from sibling to self.
|
|
73
|
+
* - thisToThatDependency: The dependency edge from self to sibling.
|
|
74
|
+
*/
|
|
18
75
|
addRelationship(to: UnknownModel): {
|
|
19
76
|
thatToThisDependency: Dependency;
|
|
20
77
|
thisToThatDependency: Dependency;
|
|
21
78
|
};
|
|
79
|
+
/**
|
|
80
|
+
* To derive the name of the field in self which contains the ID.
|
|
81
|
+
*
|
|
82
|
+
* @remarks This method does a best attempt search of the field name by traversing all dependencies of self.
|
|
83
|
+
* But if the dependencies lack, or have not been added yet, this method might return `undefined`.
|
|
84
|
+
* That does not mean that such a field does not exist,
|
|
85
|
+
* but rather that it wasn't possible to derive the name at that point.
|
|
86
|
+
* @returns The name of the field in self which contains the ID, or `undefined` if not found.
|
|
87
|
+
*/
|
|
22
88
|
deriveDependencyField(): string | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* Compares and calculates the difference between the current version of self node, and the previous version.
|
|
91
|
+
* - Recursively compares self children too.
|
|
92
|
+
*
|
|
93
|
+
* @param previous The previous version of self.
|
|
94
|
+
*/
|
|
23
95
|
diff(previous?: T): Promise<Diff[]>;
|
|
96
|
+
/**
|
|
97
|
+
* To compare properties of the current version of self node, vs. the previous version.
|
|
98
|
+
* It is a helper method to the `diff()` method.
|
|
99
|
+
* - This method is called by the {@link diff()} method.
|
|
100
|
+
*
|
|
101
|
+
* @param previous The previous version of self.
|
|
102
|
+
*/
|
|
24
103
|
abstract diffProperties(previous: T): Promise<Diff[]>;
|
|
104
|
+
/**
|
|
105
|
+
* To get all ancestors of self.
|
|
106
|
+
* - Includes parent nodes.
|
|
107
|
+
* - Might include sibling nodes, if they are necessary for self node to exist.
|
|
108
|
+
*/
|
|
25
109
|
getAncestors(): UnknownModel[];
|
|
110
|
+
/**
|
|
111
|
+
* To get an anchor with a given ID and parent.
|
|
112
|
+
*
|
|
113
|
+
* @param anchorId The ID of the anchor.
|
|
114
|
+
* @param parent The parent of the anchor.
|
|
115
|
+
* - If parent is not given, then self is considered the parent of this anchor.
|
|
116
|
+
*/
|
|
26
117
|
getAnchor(anchorId: string, parent?: UnknownModel): AAnchor | undefined;
|
|
118
|
+
/**
|
|
119
|
+
* To get the index of an anchor with a given ID and parent.
|
|
120
|
+
*
|
|
121
|
+
* @param anchorId The ID of the anchor.
|
|
122
|
+
* @param parent The parent of the anchor.
|
|
123
|
+
* - If parent is not given, then self is considered the parent of this anchor.
|
|
124
|
+
*/
|
|
27
125
|
getAnchorIndex(anchorId: string, parent?: UnknownModel): number;
|
|
126
|
+
/**
|
|
127
|
+
* To get all anchors, filtered by anchor properties.
|
|
128
|
+
*
|
|
129
|
+
* @param filters A set of filters, where `key` is the property name and `value` is the value to filter by.
|
|
130
|
+
*/
|
|
28
131
|
getAnchors(filters?: {
|
|
29
132
|
key: string;
|
|
30
133
|
value: any;
|
|
31
134
|
}[]): AAnchor[];
|
|
135
|
+
/**
|
|
136
|
+
* To get a boundary (sub graph) of self.
|
|
137
|
+
* A boundary is a group of nodes that must belong together.
|
|
138
|
+
* The boundary consists of all nodes associated with self,
|
|
139
|
+
* which includes parents, grand parents, children, grand children, and siblings.
|
|
140
|
+
*/
|
|
32
141
|
getBoundaryMembers(): UnknownModel[];
|
|
142
|
+
/**
|
|
143
|
+
* To get a child of self that matches the given filters.
|
|
144
|
+
*
|
|
145
|
+
* @param modelName The {@link MODEL_NAME} of the child.
|
|
146
|
+
* @param filters A set of filters, to be applied on children,
|
|
147
|
+
* where `key` is the property name and `value` is the value to filter by.
|
|
148
|
+
* @throws {@link Error} If more than one child is found.
|
|
149
|
+
*/
|
|
33
150
|
getChild(modelName: string, filters?: {
|
|
34
151
|
key: string;
|
|
35
152
|
value: any;
|
|
36
153
|
}[]): UnknownModel | undefined;
|
|
154
|
+
/**
|
|
155
|
+
* To get all children of self.
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```ts
|
|
159
|
+
* const children = region.getChildren('environment');
|
|
160
|
+
* const environments = children['environment'].map((d) => d.to);
|
|
161
|
+
* ```
|
|
162
|
+
* @param modelName The {@link MODEL_NAME} of the children.
|
|
163
|
+
* @returns All children as an object with the {@link MODEL_NAME} as the key,
|
|
164
|
+
* and self's dependency to the child as the value.
|
|
165
|
+
*/
|
|
37
166
|
getChildren(modelName?: string): {
|
|
38
167
|
[key: string]: Dependency[];
|
|
39
168
|
};
|
|
169
|
+
/**
|
|
170
|
+
* To get the context of self.
|
|
171
|
+
* A context is a string representation of self that uniquely identifies self in the graph.
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* ```ts
|
|
175
|
+
* const app = new App('my-app');
|
|
176
|
+
* const region = new Region('my-region');
|
|
177
|
+
* app.addRegion(region);
|
|
178
|
+
* const context = region.getContext(); // "region=my-region,app=my-app"
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
40
181
|
getContext(): string;
|
|
182
|
+
/**
|
|
183
|
+
* To get all dependencies of self.
|
|
184
|
+
* - Can be filtered to just dependencies with a single node.
|
|
185
|
+
*
|
|
186
|
+
* @param to The other node. If present, will only return dependencies of self with this node.
|
|
187
|
+
*/
|
|
41
188
|
getDependencies(to?: UnknownModel): Dependency[];
|
|
189
|
+
/**
|
|
190
|
+
* To get a dependency of self with another node.
|
|
191
|
+
*
|
|
192
|
+
* @param to The other node.
|
|
193
|
+
* @param relationship The relationship between self and the other node.
|
|
194
|
+
* @returns The dependency with the other node having the given relationship, or `undefined` if not found.
|
|
195
|
+
*/
|
|
42
196
|
getDependency(to: UnknownModel, relationship: DependencyRelationship): Dependency | undefined;
|
|
197
|
+
/**
|
|
198
|
+
* To get the index of a dependency of self with another node.
|
|
199
|
+
*
|
|
200
|
+
* @param to The other node.
|
|
201
|
+
* @param relationship The relationship between self and the other node.
|
|
202
|
+
* @returns The index of the dependency with the other node having the given relationship, or `-1` if not found.
|
|
203
|
+
*/
|
|
43
204
|
getDependencyIndex(to: UnknownModel, relationship: DependencyRelationship): number;
|
|
205
|
+
/**
|
|
206
|
+
* To get all parent of self.
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
* ```ts
|
|
210
|
+
* const parents = environment.getParents('region');
|
|
211
|
+
* const regions = parents['region'].map((d) => d.to);
|
|
212
|
+
* ```
|
|
213
|
+
* @param modelName The {@link MODEL_NAME} of the parent.
|
|
214
|
+
* @returns All parents as an object with the {@link MODEL_NAME} as the key,
|
|
215
|
+
* and self's dependency to the parent as the value.
|
|
216
|
+
*/
|
|
44
217
|
getParents(modelName?: string): {
|
|
45
218
|
[key: string]: Dependency[];
|
|
46
219
|
};
|
|
220
|
+
/**
|
|
221
|
+
* To get all siblings of self.
|
|
222
|
+
*
|
|
223
|
+
* :::note Note
|
|
224
|
+
* Two environments, or two regions, etc. are not automatically considered siblings,
|
|
225
|
+
* unless they have a dependency between them.
|
|
226
|
+
*
|
|
227
|
+
* ```ts
|
|
228
|
+
* const environment1 = new Environment('qa');
|
|
229
|
+
* const environment2 = new Environment('prod');
|
|
230
|
+
* const region = new Region('region');
|
|
231
|
+
* region.addEnvironment(environment1);
|
|
232
|
+
* region.addEnvironment(environment2);
|
|
233
|
+
* environment1.getSiblings('environment'); // This won't return a dependency to environment2.
|
|
234
|
+
* ```
|
|
235
|
+
* :::
|
|
236
|
+
*
|
|
237
|
+
* @example
|
|
238
|
+
* ```ts
|
|
239
|
+
* const siblings = environment.getSiblings('image');
|
|
240
|
+
* const images = siblings['image'].map((d) => d.to);
|
|
241
|
+
* ```
|
|
242
|
+
* @param modelName The {@link MODEL_NAME} of the sibling.
|
|
243
|
+
* @returns All siblings as an object with the {@link MODEL_NAME} as the key,
|
|
244
|
+
* and self's dependency to the sibling as the value.
|
|
245
|
+
*/
|
|
47
246
|
getSiblings(modelName?: string): {
|
|
48
247
|
[key: string]: Dependency[];
|
|
49
248
|
};
|
|
249
|
+
/**
|
|
250
|
+
* To check if given node is an ancestor of self.
|
|
251
|
+
*
|
|
252
|
+
* @param model The other node.
|
|
253
|
+
*/
|
|
50
254
|
hasAncestor(model: UnknownModel): boolean;
|
|
255
|
+
/**
|
|
256
|
+
* To check if self is marked as deleted.
|
|
257
|
+
* A deleted node will be removed from the graph after the transaction.
|
|
258
|
+
*/
|
|
51
259
|
isMarkedDeleted(): boolean;
|
|
260
|
+
/**
|
|
261
|
+
* To mark self as deleted.
|
|
262
|
+
* A deleted node will be removed from the graph after the transaction.
|
|
263
|
+
* - A node cannot be deleted if it has dependencies.
|
|
264
|
+
* - Unless the dependency is a sibling dependency and `ignoreDirectRelationships` is `true`.
|
|
265
|
+
*
|
|
266
|
+
* @example
|
|
267
|
+
* ```ts
|
|
268
|
+
* const region1 = new Region('region-1');
|
|
269
|
+
* const environment = new Environment('environment');
|
|
270
|
+
* region1.addEnvironment(environment);
|
|
271
|
+
* const region2 = new Region('region-2');
|
|
272
|
+
* region1.addSibling(region2);
|
|
273
|
+
*
|
|
274
|
+
* // Cannot remove region1 because it has dependencies.
|
|
275
|
+
* region1.remove(); // throws.
|
|
276
|
+
*
|
|
277
|
+
* // Still can't remove region1 because it has a sibling dependency.
|
|
278
|
+
* environment.remove(); // ok.
|
|
279
|
+
* region1.remove(); // throws.
|
|
280
|
+
*
|
|
281
|
+
* // But can remove region1 when sibling relationships are ignored.
|
|
282
|
+
* region1.remove(true); // ok.
|
|
283
|
+
* ```
|
|
284
|
+
* @param ignoreDirectRelationships Whether to ignore sibling relationships.
|
|
285
|
+
* @throws {@link Error} If node contains dependencies to other nodes.
|
|
286
|
+
*/
|
|
52
287
|
remove(ignoreDirectRelationships?: boolean): void;
|
|
288
|
+
/**
|
|
289
|
+
* To remove all anchors from self.
|
|
290
|
+
*/
|
|
53
291
|
removeAllAnchors(): void;
|
|
292
|
+
/**
|
|
293
|
+
* To remove an anchor from self.
|
|
294
|
+
*
|
|
295
|
+
* @param anchor The anchor to remove.
|
|
296
|
+
*/
|
|
54
297
|
removeAnchor(anchor: AAnchor): void;
|
|
298
|
+
/**
|
|
299
|
+
* To remove a dependency from self.
|
|
300
|
+
*
|
|
301
|
+
* @param dependencyIndex The index of the dependency to remove.
|
|
302
|
+
*/
|
|
55
303
|
removeDependency(dependencyIndex: number): void;
|
|
304
|
+
/**
|
|
305
|
+
* To remove ALL dependencies from self for the given node.
|
|
306
|
+
*
|
|
307
|
+
* @param model The other node.
|
|
308
|
+
*/
|
|
56
309
|
removeRelationship(model: UnknownModel): void;
|
|
310
|
+
/**
|
|
311
|
+
* To set the context of self.
|
|
312
|
+
* A context is a string representation of self that uniquely identifies self in the graph.
|
|
313
|
+
*/
|
|
57
314
|
abstract setContext(): string;
|
|
315
|
+
/**
|
|
316
|
+
* Generates a serializable representation of self.
|
|
317
|
+
*/
|
|
58
318
|
abstract synth(): I;
|
|
319
|
+
/**
|
|
320
|
+
* To create self given its serialized representation.
|
|
321
|
+
* - First argument is the serialized representation.
|
|
322
|
+
* - Second argument is the `deReferenceContext()` function to resolve other nodes self depends on.
|
|
323
|
+
*/
|
|
59
324
|
static unSynth(...args: unknown[]): Promise<UnknownModel>;
|
|
60
325
|
}
|