pmcf 4.27.1 → 4.27.3

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.27.1",
3
+ "version": "4.27.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/base.mjs CHANGED
@@ -156,10 +156,24 @@ export class Base {
156
156
  this.constructor,
157
157
  (name, attribute) => attribute.owner && !attribute.type.primitive
158
158
  )) {
159
- if (attribute.collection) {
160
- all.push(...this[path].values());
161
- } else {
162
- all.push(this[path]);
159
+ const value = this[path];
160
+ if (value) {
161
+ if (attribute.collection) {
162
+ if (typeof value.values !== "function") {
163
+ if (value instanceof Iterator) {
164
+ all.push(...value);
165
+ } else {
166
+ if (typeof value === "object") {
167
+ //console.log("NO F", this.fullName, path, value);
168
+ all.push(...Object.values(value));
169
+ }
170
+ }
171
+ } else {
172
+ all.push(...value.values());
173
+ }
174
+ } else {
175
+ all.push(value);
176
+ }
163
177
  }
164
178
  }
165
179
 
@@ -533,6 +547,10 @@ export class Base {
533
547
 
534
548
  visitor(this, ...args);
535
549
 
550
+ for (const child of this.children) {
551
+ child._traverse(visited, visitor, ...args);
552
+ }
553
+
536
554
  return true;
537
555
  }
538
556
 
package/src/host.mjs CHANGED
@@ -109,25 +109,14 @@ export class Host extends ServiceOwner {
109
109
  const present = this._networkInterfaces.get(ni.name);
110
110
 
111
111
  if (present) {
112
- //console.log("LINK", present.fullName, ni.fullName,present.extends);
113
112
  present.extends.add(ni);
114
113
  } else {
115
- this._networkInterfaces.set(ni.name, ni.forOwner(this));
114
+ this.networkInterfaces = ni.forOwner(this);
116
115
  }
117
116
  }
118
117
  }
119
118
  }
120
119
 
121
- _traverse(...args) {
122
- if (super._traverse(...args)) {
123
- for (const ni of this.networkInterfaces.values()) {
124
- ni._traverse(...args);
125
- }
126
- return true;
127
- }
128
- return false;
129
- }
130
-
131
120
  set serial(value) {
132
121
  this._serial = value;
133
122
  }
package/src/owner.mjs CHANGED
@@ -23,7 +23,12 @@ export class Owner extends Base {
23
23
  static key = "name";
24
24
  static attributes = {
25
25
  networks: networks_attribute,
26
- hosts: { ...default_attribute_writable, type: "host", collection: true, owner: true },
26
+ hosts: {
27
+ ...default_attribute_writable,
28
+ type: "host",
29
+ collection: true,
30
+ owner: true
31
+ },
27
32
  clusters: {
28
33
  ...default_attribute_writable,
29
34
  type: "cluster",
@@ -45,7 +50,6 @@ export class Owner extends Base {
45
50
  template: { ...boolean_attribute_writable, private: true }
46
51
  };
47
52
 
48
-
49
53
  static {
50
54
  addType(this);
51
55
  }
@@ -61,20 +65,6 @@ export class Owner extends Base {
61
65
  return this.template ?? super.isTemplate;
62
66
  }
63
67
 
64
- _traverse(...args) {
65
- if (super._traverse(...args)) {
66
- for (const typeSlot of this._membersByType.values()) {
67
- for (const object of typeSlot.values()) {
68
- object._traverse(...args);
69
- }
70
- }
71
-
72
- return true;
73
- }
74
-
75
- return false;
76
- }
77
-
78
68
  *find(pattern) {
79
69
  for (const node of this.traverse(() => {})) {
80
70
  for (const p of pattern) {
@@ -195,6 +185,7 @@ export class Owner extends Base {
195
185
  }
196
186
 
197
187
  get networks() {
188
+ //return this._membersByType.get("network") || new Map();
198
189
  return this.typeList("network");
199
190
  }
200
191
 
@@ -234,6 +225,7 @@ export class Owner extends Base {
234
225
  }
235
226
 
236
227
  get clusters() {
228
+ //return this._membersByType.get("cluster") || new Map();
237
229
  return this.typeList("cluster");
238
230
  }
239
231
 
@@ -1,7 +1,4 @@
1
- import {
2
- default_attribute_writable,
3
- addType
4
- } from "pacc";
1
+ import { default_attribute_writable, addType } from "pacc";
5
2
  import { Base, Service } from "pmcf";
6
3
 
7
4
  export class ServiceOwner extends Base {
@@ -35,9 +32,9 @@ export class ServiceOwner extends Base {
35
32
  addObject(object) {
36
33
  if (object instanceof Service) {
37
34
  this._services.set(object.name, object);
35
+ } else {
36
+ super.addObject(object);
38
37
  }
39
-
40
- super.addObject(object);
41
38
  }
42
39
 
43
40
  materializeExtends() {
@@ -55,38 +52,6 @@ export class ServiceOwner extends Base {
55
52
  this.services = service.forOwner(this);
56
53
  }
57
54
  }
58
-
59
- /*
60
- if (this.fullName === "/SW/mini1") {
61
- const myServiceNames = new Set([...this.services.keys()]);
62
- const extendingSericeNames = new Set([
63
- ...this.mapFromDirections(["extends"], "_services").keys()
64
- ]);
65
-
66
- console.log("XXX",this.fullName, [...this.extends].map(n=>n.fullName), myServiceNames, extendingSericeNames);
67
-
68
- if (!extendingSericeNames.isSubsetOf(myServiceNames)) {
69
- // const diff = myServiceNames.difference(extendingSericeNames);
70
- console.log(
71
- "DIFF",
72
- this.fullName,
73
- myServiceNames,
74
- extendingSericeNames
75
- );
76
- }
77
- }
78
- */
79
- }
80
-
81
- _traverse(...args) {
82
- if (super._traverse(...args)) {
83
- for (const service of this._services.values()) {
84
- service._traverse(...args);
85
- }
86
-
87
- return true;
88
- }
89
- return false;
90
55
  }
91
56
 
92
57
  typeNamed(typeName, name) {
@@ -407,6 +407,7 @@ export class BindService extends ExtraSourceService {
407
407
  ...default_attribute_writable,
408
408
  type: bind_group,
409
409
  collection: true,
410
+ owner: true,
410
411
  writable: true
411
412
  },
412
413
  primaries: {
@@ -501,17 +502,6 @@ export class BindService extends ExtraSourceService {
501
502
  }
502
503
  }
503
504
 
504
- _traverse(...args) {
505
- if (super._traverse(...args)) {
506
- for (const group of Object.values(this.groups)) {
507
- group._traverse(...args);
508
- }
509
- return true;
510
- }
511
-
512
- return false;
513
- }
514
-
515
505
  typeNamed(type, name) {
516
506
  if (type === bind_group.name) {
517
507
  return this.groups[name];
package/src/subnet.mjs CHANGED
@@ -28,7 +28,6 @@ export class Subnet extends Base {
28
28
  family: string_attribute
29
29
  };
30
30
 
31
-
32
31
  static {
33
32
  addType(this);
34
33
  }
@@ -84,17 +83,6 @@ export class Subnet extends Base {
84
83
  get longAddress() {
85
84
  return `${this.longPrefix}/${this.prefixLength}`;
86
85
  }
87
-
88
- _traverse(...args) {
89
- if (super._traverse(...args)) {
90
- for (const network of this.networks) {
91
- network._traverse(...args);
92
- }
93
- return true;
94
- }
95
-
96
- return false;
97
- }
98
86
  }
99
87
 
100
88
  const _owner = { addObject() {} };