@quadnix/octo 0.0.19 → 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 +26 -1
- package/dist/decorators/action.decorator.js.map +1 -1
- package/dist/decorators/anchor.decorator.d.ts +13 -0
- package/dist/decorators/anchor.decorator.js +16 -1
- package/dist/decorators/anchor.decorator.js.map +1 -1
- package/dist/decorators/container.d.ts +61 -0
- package/dist/decorators/container.js +68 -3
- 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 +18 -0
- package/dist/decorators/event-source.decorator.js +22 -0
- package/dist/decorators/event-source.decorator.js.map +1 -0
- 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 +16 -1
- 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 +20 -0
- package/dist/decorators/on-event.decorator.js +24 -0
- package/dist/decorators/on-event.decorator.js.map +1 -0
- package/dist/decorators/overlay.decorator.d.ts +13 -0
- package/dist/decorators/overlay.decorator.js +16 -1
- package/dist/decorators/overlay.decorator.js.map +1 -1
- package/dist/decorators/resource.decorator.d.ts +13 -0
- package/dist/decorators/resource.decorator.js +16 -1
- 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 +35 -0
- package/dist/events/error.event.js +36 -0
- package/dist/events/error.event.js.map +1 -0
- package/dist/events/event.model.d.ts +37 -0
- package/dist/events/event.model.js +43 -0
- package/dist/events/event.model.js.map +1 -0
- package/dist/events/hook.event.d.ts +194 -0
- package/dist/events/hook.event.js +195 -0
- package/dist/events/hook.event.js.map +1 -0
- package/dist/events/module.event.d.ts +15 -0
- package/dist/events/module.event.js +16 -0
- package/dist/events/module.event.js.map +1 -0
- package/dist/events/registration.event.d.ts +112 -0
- package/dist/events/registration.event.js +170 -0
- package/dist/events/registration.event.js.map +1 -0
- package/dist/events/serialization.event.d.ts +72 -0
- package/dist/events/serialization.event.js +73 -0
- package/dist/events/serialization.event.js.map +1 -0
- package/dist/events/transaction.event.d.ts +48 -0
- package/dist/events/transaction.event.js +49 -0
- package/dist/events/transaction.event.js.map +1 -0
- 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 +11 -3
- package/dist/functions/hook/commit.hook.js.map +1 -1
- package/dist/functions/hook/model-action.hook.js +11 -3
- package/dist/functions/hook/model-action.hook.js.map +1 -1
- package/dist/functions/hook/resource-action.hook.js +11 -3
- package/dist/functions/hook/resource-action.hook.js.map +1 -1
- package/dist/index.d.ts +9 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts +11 -2
- package/dist/main.js +34 -16
- 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 +22 -10
- package/dist/modules/module.container.js.map +1 -1
- package/dist/modules/test-module.container.d.ts +4 -3
- package/dist/modules/test-module.container.js +13 -10
- 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.d.ts +17 -0
- package/dist/services/event/event.service.js +92 -0
- package/dist/services/event/event.service.js.map +1 -0
- 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.d.ts +1 -1
- package/dist/services/serialization/model/model-serialization.service.js +28 -5
- package/dist/services/serialization/model/model-serialization.service.js.map +1 -1
- package/dist/services/serialization/resource/resource-serialization.service.js +32 -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 +69 -9
- 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
|
@@ -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
|
}
|