pmcf 4.27.2 → 4.28.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.27.2",
3
+ "version": "4.28.0",
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
 
@@ -222,6 +236,17 @@ export class Base {
222
236
  : name;
223
237
  }
224
238
 
239
+ *find(pattern) {
240
+ for (const node of this.walkDirections(["children"])) {
241
+ for (const p of pattern) {
242
+ if (node.fullName.match(p)) {
243
+ yield node;
244
+ break;
245
+ }
246
+ }
247
+ }
248
+ }
249
+
225
250
  get typeName() {
226
251
  return this.constructor.name;
227
252
  }
@@ -502,7 +527,9 @@ export class Base {
502
527
  }
503
528
 
504
529
  execFinalize() {
505
- this.traverse(object => object._execFinalize());
530
+ for (const node of this.walkDirections(["children"])) {
531
+ node._execFinalize();
532
+ }
506
533
  }
507
534
 
508
535
  _execFinalize() {
@@ -518,24 +545,6 @@ export class Base {
518
545
  }
519
546
  }
520
547
 
521
- traverse(visitor, ...args) {
522
- const visited = new Set();
523
- this._traverse(visited, visitor, ...args);
524
- return visited;
525
- }
526
-
527
- _traverse(visited, visitor, ...args) {
528
- if (visited.has(this)) {
529
- return false;
530
- }
531
-
532
- visited.add(this);
533
-
534
- visitor(this, ...args);
535
-
536
- return true;
537
- }
538
-
539
548
  error(...args) {
540
549
  console.error(`${this.toString()}:`, ...args);
541
550
  }
package/src/host.mjs CHANGED
@@ -117,16 +117,6 @@ export class Host extends ServiceOwner {
117
117
  }
118
118
  }
119
119
 
120
- _traverse(...args) {
121
- if (super._traverse(...args)) {
122
- for (const ni of this.networkInterfaces.values()) {
123
- ni._traverse(...args);
124
- }
125
- return true;
126
- }
127
- return false;
128
- }
129
-
130
120
  set serial(value) {
131
121
  this._serial = value;
132
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,31 +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
- *find(pattern) {
79
- for (const node of this.traverse(() => {})) {
80
- for (const p of pattern) {
81
- if (node.fullName.match(p)) {
82
- yield node;
83
- break;
84
- }
85
- }
86
- }
87
- }
88
-
89
68
  named(name) {
90
69
  if (name[0] === "/") {
91
70
  name = name.substring(this.fullName.length + 1);
@@ -195,6 +174,7 @@ export class Owner extends Base {
195
174
  }
196
175
 
197
176
  get networks() {
177
+ //return this._membersByType.get("network") || new Map();
198
178
  return this.typeList("network");
199
179
  }
200
180
 
@@ -234,6 +214,7 @@ export class Owner extends Base {
234
214
  }
235
215
 
236
216
  get clusters() {
217
+ //return this._membersByType.get("cluster") || new Map();
237
218
  return this.typeList("cluster");
238
219
  }
239
220
 
@@ -54,17 +54,6 @@ export class ServiceOwner extends Base {
54
54
  }
55
55
  }
56
56
 
57
- _traverse(...args) {
58
- if (super._traverse(...args)) {
59
- for (const service of this._services.values()) {
60
- service._traverse(...args);
61
- }
62
-
63
- return true;
64
- }
65
- return false;
66
- }
67
-
68
57
  typeNamed(typeName, name) {
69
58
  if (typeName === "service") {
70
59
  const service = this.services.get(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() {} };