pmcf 4.20.0 → 4.21.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmcf",
3
- "version": "4.20.0",
3
+ "version": "4.21.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/base.mjs CHANGED
@@ -64,7 +64,7 @@ export class Base {
64
64
  owner;
65
65
  description;
66
66
  name;
67
- extends = [];
67
+ extends = new Set();
68
68
  _tags = new Set();
69
69
  _packaging = new Set();
70
70
  _directory;
@@ -127,6 +127,15 @@ export class Base {
127
127
  return this.owner.addObject(object);
128
128
  }
129
129
 
130
+ collectFromDirections(directions = ["this", "extends", "owner"], property) {
131
+ let collected = new Set();
132
+ for (const node of this.walkDirections(directions)) {
133
+ collected = collected.union(node[property]);
134
+ }
135
+
136
+ return collected;
137
+ }
138
+
130
139
  /**
131
140
  * Walk the object graph in some directions and deliver seen nodes.
132
141
  * @param {string[]} directions
@@ -166,7 +175,7 @@ export class Base {
166
175
  forOwner(owner) {
167
176
  if (this.owner !== owner) {
168
177
  const newObject = Object.create(this);
169
- newObject.extends = [...this.extends];
178
+ newObject.extends = new Set([...this.extends]);
170
179
  newObject.owner = owner;
171
180
  return newObject;
172
181
  }
@@ -414,7 +423,7 @@ export class Base {
414
423
  }
415
424
 
416
425
  get tags() {
417
- return this.extends.reduce((a, c) => a.union(c.tags), this._tags);
426
+ return this.collectFromDirections(["this", "extends"], "_tags");
418
427
  }
419
428
 
420
429
  set tags(value) {
package/src/host.mjs CHANGED
@@ -117,8 +117,8 @@ export class Host extends ServiceOwner {
117
117
  const present = this._networkInterfaces.get(name);
118
118
 
119
119
  if (present) {
120
- //console.log("LINK", present.fullName, ni.fullName);
121
- present.extends.push(ni);
120
+ //console.log("LINK", present.fullName, ni.fullName,present.extends);
121
+ present.extends.add(ni);
122
122
  } else {
123
123
  this._networkInterfaces.set(name, ni.forOwner(this));
124
124
  }
@@ -192,7 +192,9 @@ export class Host extends ServiceOwner {
192
192
  }
193
193
 
194
194
  get derivedPackaging() {
195
- return this.extends.reduce((a, c) => a.union(c.packaging), new Set());
195
+ return this.expand(
196
+ this.collectFromDirections(["this", "extends"], "_packaging")
197
+ );
196
198
  }
197
199
 
198
200
  get isTemplate() {
@@ -204,7 +206,11 @@ export class Host extends ServiceOwner {
204
206
  }
205
207
 
206
208
  get model() {
207
- return this.extends.find(h => h.isModel);
209
+ for (const node of this.walkDirections(["this", "extends"])) {
210
+ if (node.isModel) {
211
+ return node;
212
+ }
213
+ }
208
214
  }
209
215
 
210
216
  set aliases(value) {
@@ -212,7 +218,9 @@ export class Host extends ServiceOwner {
212
218
  }
213
219
 
214
220
  get aliases() {
215
- return this.extends.reduce((a, c) => a.union(c.aliases), this._aliases);
221
+ return this.expand(
222
+ this.collectFromDirections(["this", "extends"], "_aliases")
223
+ );
216
224
  }
217
225
 
218
226
  set provides(value) {
@@ -221,7 +229,7 @@ export class Host extends ServiceOwner {
221
229
 
222
230
  get provides() {
223
231
  return this.expand(
224
- this.extends.reduce((a, c) => a.union(c.provides), this._provides)
232
+ this.collectFromDirections(["this", "extends"], "_provides")
225
233
  );
226
234
  }
227
235
 
@@ -231,7 +239,7 @@ export class Host extends ServiceOwner {
231
239
 
232
240
  get replaces() {
233
241
  return this.expand(
234
- this.extends.reduce((a, c) => a.union(c.replaces), this._replaces)
242
+ this.collectFromDirections(["this", "extends"], "_replaces")
235
243
  );
236
244
  }
237
245
 
@@ -241,7 +249,7 @@ export class Host extends ServiceOwner {
241
249
 
242
250
  get depends() {
243
251
  return this.expand(
244
- this.extends.reduce((a, c) => a.union(c.depends), this._depends)
252
+ this.collectFromDirections(["this", "extends"], "_depends")
245
253
  );
246
254
  }
247
255
 
@@ -18,7 +18,7 @@ export class ServiceOwner extends Base {
18
18
 
19
19
  if (present) {
20
20
  //console.log("LINK", present.fullName, service.fullName);
21
- present.extends.push(service);
21
+ present.extends.add(service);
22
22
  } else {
23
23
  this.services.push(service.forOwner(this));
24
24
  }