pmcf 2.8.0 → 2.9.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": "2.8.0",
3
+ "version": "2.9.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/base.mjs CHANGED
@@ -274,6 +274,32 @@ export class Base {
274
274
  return this.constructor.typeDefinition.name;
275
275
  }
276
276
 
277
+ get extends() {
278
+ return [];
279
+ }
280
+
281
+ _extendedProperty(propertyName, seen) {
282
+ if (!seen.has(this)) {
283
+ seen.add(this);
284
+ for (const e of this.extends) {
285
+ const value =
286
+ e[propertyName] ?? e._extendedProperty(propertyName, seen);
287
+ if (value !== undefined) {
288
+ return value;
289
+ }
290
+ }
291
+ }
292
+ }
293
+
294
+ extendedProperty(propertyName) {
295
+ const value = this[propertyName];
296
+ if (value !== undefined) {
297
+ return value;
298
+ }
299
+
300
+ return this._extendedProperty(propertyName, new Set());
301
+ }
302
+
277
303
  get root() {
278
304
  return this.owner.root;
279
305
  }
package/src/host.mjs CHANGED
@@ -107,9 +107,6 @@ export class Host extends Base {
107
107
  if (data.extends) {
108
108
  this.finalize(() => {
109
109
  for (const host of this.extends) {
110
- if (host === this) {
111
- this.error("Cant extend myself");
112
- }
113
110
  host.execFinalize();
114
111
  this._applyExtends(host);
115
112
  }
@@ -156,7 +153,7 @@ export class Host extends Base {
156
153
  }
157
154
 
158
155
  get serial() {
159
- return this._serial ?? this.extends.find(e => e.serial)?.serial;
156
+ return this.extendedProperty("_serial");
160
157
  }
161
158
 
162
159
  set deployment(value) {
@@ -164,7 +161,7 @@ export class Host extends Base {
164
161
  }
165
162
 
166
163
  get deployment() {
167
- return this._deployment ?? this.extends.find(e => e.deployment)?.deployment;
164
+ return this.extendedProperty("_deployment");
168
165
  }
169
166
 
170
167
  set chassis(value) {
@@ -172,7 +169,7 @@ export class Host extends Base {
172
169
  }
173
170
 
174
171
  get chassis() {
175
- return this._chassis ?? this.extends.find(e => e.chassis)?.chassis;
172
+ return this.extendedProperty("_chassis");
176
173
  }
177
174
 
178
175
  set vendor(value) {
@@ -180,7 +177,7 @@ export class Host extends Base {
180
177
  }
181
178
 
182
179
  get vendor() {
183
- return this._vendor ?? this.extends.find(e => e.vendor)?.vendor;
180
+ return this.extendedProperty("_vendor");
184
181
  }
185
182
 
186
183
  set architecture(value) {
@@ -188,9 +185,7 @@ export class Host extends Base {
188
185
  }
189
186
 
190
187
  get architecture() {
191
- return (
192
- this._architecture ?? this.extends.find(e => e.architecture)?.architecture
193
- );
188
+ return this.extendedProperty("_architecture");
194
189
  }
195
190
 
196
191
  get derivedPackaging() {
@@ -276,7 +271,7 @@ export class Host extends Base {
276
271
  }
277
272
 
278
273
  get os() {
279
- return this._os ?? this.extends.find(e => e.os)?.os;
274
+ return this.extendedProperty("_os");
280
275
  }
281
276
 
282
277
  set distribution(value) {
@@ -284,9 +279,7 @@ export class Host extends Base {
284
279
  }
285
280
 
286
281
  get distribution() {
287
- return (
288
- this._distribution ?? this.extends.find(e => e.distribution)?.distribution
289
- );
282
+ return this.extendedProperty("_distribution");
290
283
  }
291
284
 
292
285
  get modelName() {
@@ -522,7 +515,8 @@ export class NetworkInterface extends Base {
522
515
  _kind;
523
516
  _hostName;
524
517
  _hwaddr;
525
- extends = [];
518
+ _class;
519
+ _extends = [];
526
520
  arpbridge;
527
521
 
528
522
  constructor(owner, data) {
@@ -616,7 +610,7 @@ export class NetworkInterface extends Base {
616
610
  }
617
611
 
618
612
  get hostName() {
619
- return this._hostName ?? this.host.hostName;
613
+ return this.extendedProperty("_hostName") ?? this.host.hostName;
620
614
  }
621
615
 
622
616
  set hostName(value) {
@@ -637,14 +631,16 @@ export class NetworkInterface extends Base {
637
631
  return this;
638
632
  }
639
633
 
640
- extendedProperty(name) {
641
- return this.extends.find(i => i[name])?.[name];
634
+ set extends(value) {
635
+ this._extends.push(value);
636
+ }
637
+
638
+ get extends() {
639
+ return this._extends;
642
640
  }
643
641
 
644
642
  get network() {
645
- return (
646
- this._network ?? this.extendedProperty("_network") ?? this.host.network
647
- );
643
+ return this.extendedProperty("_network") ?? this.host.network;
648
644
  }
649
645
 
650
646
  set network(network) {
@@ -656,12 +652,7 @@ export class NetworkInterface extends Base {
656
652
  }
657
653
 
658
654
  get scope() {
659
- return (
660
- this._scope ??
661
- this.extendedProperty("_scope") ??
662
- this.network?.scope ??
663
- "global"
664
- );
655
+ return this.extendedProperty("_scope") ?? this.network?.scope ?? "global";
665
656
  }
666
657
 
667
658
  set hwaddr(value) {
@@ -669,7 +660,7 @@ export class NetworkInterface extends Base {
669
660
  }
670
661
 
671
662
  get hwaddr() {
672
- return this._hwaddr ?? this.extendedProperty("_hwaddr");
663
+ return this.extendedProperty("_hwaddr");
673
664
  }
674
665
 
675
666
  set metric(value) {
@@ -677,12 +668,15 @@ export class NetworkInterface extends Base {
677
668
  }
678
669
 
679
670
  get metric() {
680
- return (
681
- this._metric ??
682
- this.extendedProperty("_metric") ??
683
- this.network?.metric ??
684
- 1004
685
- );
671
+ return this.extendedProperty("_metric") ?? this.network?.metric ?? 1004;
672
+ }
673
+
674
+ set class(value) {
675
+ this._class = value;
676
+ }
677
+
678
+ get class() {
679
+ return this.extendedProperty("_class") ?? this.network?.class;
686
680
  }
687
681
 
688
682
  set ssid(value) {
@@ -690,7 +684,7 @@ export class NetworkInterface extends Base {
690
684
  }
691
685
 
692
686
  get ssid() {
693
- return this._ssid ?? this.extendedProperty("_ssid") ?? this.network?.ssid;
687
+ return this.extendedProperty("_ssid") ?? this.network?.ssid;
694
688
  }
695
689
 
696
690
  set psk(value) {
@@ -698,7 +692,7 @@ export class NetworkInterface extends Base {
698
692
  }
699
693
 
700
694
  get psk() {
701
- return this._psk ?? this.extendedProperty("_psk") ?? this.network?.psk;
695
+ return this.extendedProperty("_psk") ?? this.network?.psk;
702
696
  }
703
697
 
704
698
  set kind(value) {
@@ -706,8 +700,6 @@ export class NetworkInterface extends Base {
706
700
  }
707
701
 
708
702
  get kind() {
709
- return (
710
- this._kind ?? this.extendedProperty("_kind") ?? this.network?.kind
711
- );
703
+ return this.extendedProperty("_kind") ?? this.network?.kind;
712
704
  }
713
705
  }
@@ -5,6 +5,12 @@ export const networkProperties = {
5
5
  writeable: true,
6
6
  values: ["global", "site", "link", "host"]
7
7
  },
8
+ class: {
9
+ type: "string",
10
+ collection: false,
11
+ writeable: true,
12
+ values: ["10GBASE-T", "1000BASE-T", "100BASE-T", "10BASE-T"]
13
+ },
8
14
  kind: {
9
15
  type: "string",
10
16
  collection: false,
package/types/base.d.mts CHANGED
@@ -67,6 +67,9 @@ export class Base {
67
67
  isNamed(name: any): boolean;
68
68
  relativeName(name: any): any;
69
69
  get typeName(): any;
70
+ get extends(): any[];
71
+ _extendedProperty(propertyName: any, seen: any): any;
72
+ extendedProperty(propertyName: any): any;
70
73
  get root(): any;
71
74
  get location(): any;
72
75
  get host(): any;
package/types/host.d.mts CHANGED
@@ -366,6 +366,12 @@ export class NetworkInterface extends Base {
366
366
  writeable: boolean;
367
367
  values: string[];
368
368
  };
369
+ class: {
370
+ type: string;
371
+ collection: boolean;
372
+ writeable: boolean;
373
+ values: string[];
374
+ };
369
375
  kind: {
370
376
  type: string;
371
377
  collection: boolean;
@@ -413,7 +419,8 @@ export class NetworkInterface extends Base {
413
419
  _kind: any;
414
420
  _hostName: any;
415
421
  _hwaddr: any;
416
- extends: any[];
422
+ _class: any;
423
+ _extends: any[];
417
424
  arpbridge: any;
418
425
  matches(other: any): boolean;
419
426
  addSubnet(address: any): any;
@@ -432,7 +439,8 @@ export class NetworkInterface extends Base {
432
439
  get hostName(): any;
433
440
  get domainNames(): any;
434
441
  get network_interface(): this;
435
- extendedProperty(name: any): any;
442
+ set extends(value: any[]);
443
+ get extends(): any[];
436
444
  set network(network: any);
437
445
  get network(): any;
438
446
  set scope(value: any);
@@ -441,6 +449,8 @@ export class NetworkInterface extends Base {
441
449
  get hwaddr(): any;
442
450
  set metric(value: any);
443
451
  get metric(): any;
452
+ set class(value: any);
453
+ get class(): any;
444
454
  set ssid(value: any);
445
455
  get ssid(): any;
446
456
  set psk(value: any);
@@ -1,11 +1,11 @@
1
1
  export namespace networkProperties {
2
- namespace scope {
2
+ export namespace scope {
3
3
  let type: string;
4
4
  let collection: boolean;
5
5
  let writeable: boolean;
6
6
  let values: string[];
7
7
  }
8
- namespace kind {
8
+ export namespace _class {
9
9
  let type_1: string;
10
10
  export { type_1 as type };
11
11
  let collection_1: boolean;
@@ -15,15 +15,18 @@ export namespace networkProperties {
15
15
  let values_1: string[];
16
16
  export { values_1 as values };
17
17
  }
18
- namespace ssid {
18
+ export { _class as class };
19
+ export namespace kind {
19
20
  let type_2: string;
20
21
  export { type_2 as type };
21
22
  let collection_2: boolean;
22
23
  export { collection_2 as collection };
23
24
  let writeable_2: boolean;
24
25
  export { writeable_2 as writeable };
26
+ let values_2: string[];
27
+ export { values_2 as values };
25
28
  }
26
- namespace psk {
29
+ export namespace ssid {
27
30
  let type_3: string;
28
31
  export { type_3 as type };
29
32
  let collection_3: boolean;
@@ -31,7 +34,7 @@ export namespace networkProperties {
31
34
  let writeable_3: boolean;
32
35
  export { writeable_3 as writeable };
33
36
  }
34
- namespace metric {
37
+ export namespace psk {
35
38
  let type_4: string;
36
39
  export { type_4 as type };
37
40
  let collection_4: boolean;
@@ -39,7 +42,7 @@ export namespace networkProperties {
39
42
  let writeable_4: boolean;
40
43
  export { writeable_4 as writeable };
41
44
  }
42
- namespace MTU {
45
+ export namespace metric {
43
46
  let type_5: string;
44
47
  export { type_5 as type };
45
48
  let collection_5: boolean;
@@ -47,7 +50,7 @@ export namespace networkProperties {
47
50
  let writeable_5: boolean;
48
51
  export { writeable_5 as writeable };
49
52
  }
50
- namespace gateway {
53
+ export namespace MTU {
51
54
  let type_6: string;
52
55
  export { type_6 as type };
53
56
  let collection_6: boolean;
@@ -55,7 +58,7 @@ export namespace networkProperties {
55
58
  let writeable_6: boolean;
56
59
  export { writeable_6 as writeable };
57
60
  }
58
- namespace multicastDNS {
61
+ export namespace gateway {
59
62
  let type_7: string;
60
63
  export { type_7 as type };
61
64
  let collection_7: boolean;
@@ -63,9 +66,7 @@ export namespace networkProperties {
63
66
  let writeable_7: boolean;
64
67
  export { writeable_7 as writeable };
65
68
  }
66
- }
67
- export namespace networkAddressProperties {
68
- namespace hostName {
69
+ export namespace multicastDNS {
69
70
  let type_8: string;
70
71
  export { type_8 as type };
71
72
  let collection_8: boolean;
@@ -73,7 +74,9 @@ export namespace networkAddressProperties {
73
74
  let writeable_8: boolean;
74
75
  export { writeable_8 as writeable };
75
76
  }
76
- namespace cidrAddresses {
77
+ }
78
+ export namespace networkAddressProperties {
79
+ namespace hostName {
77
80
  let type_9: string;
78
81
  export { type_9 as type };
79
82
  let collection_9: boolean;
@@ -81,7 +84,7 @@ export namespace networkAddressProperties {
81
84
  let writeable_9: boolean;
82
85
  export { writeable_9 as writeable };
83
86
  }
84
- namespace cidrAddress {
87
+ namespace cidrAddresses {
85
88
  let type_10: string;
86
89
  export { type_10 as type };
87
90
  let collection_10: boolean;
@@ -89,7 +92,7 @@ export namespace networkAddressProperties {
89
92
  let writeable_10: boolean;
90
93
  export { writeable_10 as writeable };
91
94
  }
92
- namespace rawAddresses {
95
+ namespace cidrAddress {
93
96
  let type_11: string;
94
97
  export { type_11 as type };
95
98
  let collection_11: boolean;
@@ -97,7 +100,7 @@ export namespace networkAddressProperties {
97
100
  let writeable_11: boolean;
98
101
  export { writeable_11 as writeable };
99
102
  }
100
- namespace rawAddress {
103
+ namespace rawAddresses {
101
104
  let type_12: string;
102
105
  export { type_12 as type };
103
106
  let collection_12: boolean;
@@ -105,4 +108,12 @@ export namespace networkAddressProperties {
105
108
  let writeable_12: boolean;
106
109
  export { writeable_12 as writeable };
107
110
  }
111
+ namespace rawAddress {
112
+ let type_13: string;
113
+ export { type_13 as type };
114
+ let collection_13: boolean;
115
+ export { collection_13 as collection };
116
+ let writeable_13: boolean;
117
+ export { writeable_13 as writeable };
118
+ }
108
119
  }
@@ -152,6 +152,12 @@ export class Network extends Owner {
152
152
  writeable: boolean;
153
153
  values: string[];
154
154
  };
155
+ class: {
156
+ type: string;
157
+ collection: boolean;
158
+ writeable: boolean;
159
+ values: string[];
160
+ };
155
161
  kind: {
156
162
  type: string;
157
163
  collection: boolean;