pmcf 4.0.2 → 4.0.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.0.2",
3
+ "version": "4.0.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -55,7 +55,7 @@
55
55
  "dependencies": {
56
56
  "ip-utilties": "^2.0.2",
57
57
  "npm-pkgbuild": "^19.1.3",
58
- "pacc": "^7.1.0",
58
+ "pacc": "^7.2.0",
59
59
  "package-directory": "^8.1.0"
60
60
  },
61
61
  "devDependencies": {
package/src/base.mjs CHANGED
@@ -208,11 +208,8 @@ export class Base {
208
208
  }
209
209
 
210
210
  this.error(
211
- "Not found",
212
- name,
213
- value, "of", attribute.type.name,
214
- this.root.named(value)?.type,
215
- attribute.type?.map && attribute.type.map(t => t.name)
211
+ `No such object "${value}" (${attribute.type.name}) for attribute ${name}`,
212
+ this.root.named(value)?.toString()
216
213
  );
217
214
  });
218
215
  }
@@ -316,6 +313,17 @@ export class Base {
316
313
  return this.owner.addObject(object);
317
314
  }
318
315
 
316
+ *owners() {
317
+ if (this.owner) {
318
+ yield* this.owner.thisAndOwners();
319
+ }
320
+ }
321
+
322
+ *thisAndOwners() {
323
+ yield this;
324
+ yield* this.owners();
325
+ }
326
+
319
327
  forOwner(owner) {
320
328
  if (this.owner !== owner) {
321
329
  const newObject = Object.create(this);
@@ -551,27 +559,31 @@ export class Base {
551
559
  return this.name?.indexOf("*") >= 0 || this.owner?.isTemplate || false;
552
560
  }
553
561
 
554
- get properties() {
555
- return this._properties;
556
- }
557
-
558
562
  get globals() {
559
563
  return Object.assign(
560
564
  {},
561
565
  this.properties,
562
- this.owner?.properties,
563
- this.owner?.owner?.properties,
564
- this.owner?.owner?.owner?.properties,
566
+ ...[...this.owners()].map(o => o.properties),
565
567
  globals
566
568
  );
567
569
  }
568
570
 
571
+ get properties() {
572
+ return this._properties;
573
+ }
574
+
569
575
  property(name) {
570
- return (
571
- this._properties?.[name] ??
572
- this.owner?.property(name) ??
573
- this.owner?.owner?.property(name)
574
- );
576
+ let value = this._properties?.[name];
577
+ if (value !== undefined) {
578
+ return value;
579
+ }
580
+
581
+ for (const o of this.owners()) {
582
+ const value = o.property(name);
583
+ if (value !== undefined) {
584
+ return value;
585
+ }
586
+ }
575
587
  }
576
588
 
577
589
  /**
@@ -685,7 +697,7 @@ export function extractFrom(
685
697
 
686
698
  const json = {};
687
699
 
688
- do {
700
+ for (; typeDefinition; typeDefinition = typeDefinition.extends) {
689
701
  for (const [path, def] of attributeIterator(
690
702
  typeDefinition.attributes,
691
703
  filterPublic
@@ -740,8 +752,7 @@ export function extractFrom(
740
752
  json[name] = value;
741
753
  }
742
754
  }
743
- typeDefinition = typeDefinition?.extends;
744
- } while (typeDefinition);
755
+ }
745
756
 
746
757
  return json;
747
758
  }
@@ -31,7 +31,7 @@ export class EthernetNetworkInterface extends NetworkInterface {
31
31
  }
32
32
 
33
33
  static isCommonName(name) {
34
- return name.match(/eth\d+$/);
34
+ return name.match(/^eth\d+$/);
35
35
  }
36
36
 
37
37
  get kind() {
@@ -28,7 +28,7 @@ export class LoopbackNetworkInterface extends SkeletonNetworkInterface {
28
28
  }
29
29
 
30
30
  static isCommonName(name) {
31
- return name.match(/lo\d*$/);
31
+ return name.match(/^lo\d*$/);
32
32
  }
33
33
 
34
34
  get kind() {
@@ -1,6 +1,10 @@
1
1
  import { mkdir } from "node:fs/promises";
2
2
  import { join } from "node:path";
3
- import { string_attribute_writable, secret_attribute, addType } from "pacc";
3
+ import {
4
+ string_attribute_writable,
5
+ secret_attribute_writable,
6
+ addType
7
+ } from "pacc";
4
8
  import { writeLines, sectionLines } from "../utils.mjs";
5
9
  import { NetworkInterfaceTypeDefinition } from "./network-interface.mjs";
6
10
  import {
@@ -16,7 +20,7 @@ const WLANNetworkInterfaceTypeDefinition = {
16
20
  key: "name",
17
21
  attributes: {
18
22
  ssid: string_attribute_writable,
19
- psk: { ...secret_attribute, writable: true },
23
+ psk: secret_attribute_writable,
20
24
  secretName: string_attribute_writable
21
25
  }
22
26
  };
@@ -31,7 +35,7 @@ export class WLANNetworkInterface extends EthernetNetworkInterface {
31
35
  }
32
36
 
33
37
  static isCommonName(name) {
34
- return name.match(/wlan\d+$/);
38
+ return name.match(/^wlan\d+$/);
35
39
  }
36
40
 
37
41
  static get typeDefinition() {
package/src/owner.mjs CHANGED
@@ -3,10 +3,10 @@ import {
3
3
  default_attribute_writable,
4
4
  string_collection_attribute_writable,
5
5
  string_attribute_writable,
6
+ boolean_attribute_writable_false,
6
7
  email_attribute,
7
8
  addType,
8
- types,
9
- boolean_attribute_writable_false
9
+ types
10
10
  } from "pacc";
11
11
  import { asIterator } from "./utils.mjs";
12
12
  import { Base } from "./base.mjs";
@@ -147,6 +147,15 @@ export class Owner extends Base {
147
147
  }
148
148
 
149
149
  addObject(object) {
150
+ if (object.owner && object.owner !== this) {
151
+ this.addTypeObject(
152
+ object.typeName,
153
+ object.owner.name + "/" + object.name,
154
+ object
155
+ );
156
+
157
+ return;
158
+ }
150
159
  this.addTypeObject(object.typeName, object.name, object);
151
160
  }
152
161
 
package/types/base.d.mts CHANGED
@@ -62,6 +62,8 @@ export class Base {
62
62
  named(name: any): void;
63
63
  typeNamed(typeName: any, name: any): any;
64
64
  addObject(object: any): any;
65
+ owners(): any;
66
+ thisAndOwners(): any;
65
67
  forOwner(owner: any): any;
66
68
  isNamed(name: any): boolean;
67
69
  relativeName(name: any): any;
@@ -117,8 +119,8 @@ export class Base {
117
119
  set tags(value: Set<any>);
118
120
  get tags(): Set<any>;
119
121
  get isTemplate(): any;
120
- get properties(): any;
121
122
  get globals(): any;
123
+ get properties(): any;
122
124
  property(name: any): any;
123
125
  /**
124
126
  *
@@ -1647,27 +1647,7 @@ export class WLANNetworkInterface extends EthernetNetworkInterface {
1647
1647
  key: string;
1648
1648
  attributes: {
1649
1649
  ssid: import("pacc").AttributeDefinition;
1650
- psk: {
1651
- writable: boolean;
1652
- type: object;
1653
- isKey: boolean;
1654
- mandatory: boolean;
1655
- collection: boolean;
1656
- private?: boolean;
1657
- credential?: boolean;
1658
- persistent?: boolean;
1659
- depends?: string;
1660
- description?: string;
1661
- default?: any;
1662
- set?: Function;
1663
- get?: Function;
1664
- toInternal?: Function;
1665
- toExternal?: Function;
1666
- values?: Set<any>;
1667
- externalName?: string;
1668
- env?: string[] | string;
1669
- additionalValues?: object;
1670
- };
1650
+ psk: import("pacc").AttributeDefinition;
1671
1651
  secretName: import("pacc").AttributeDefinition;
1672
1652
  };
1673
1653
  };