pmcf 1.13.0 → 1.15.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": "1.13.0",
3
+ "version": "1.15.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -64,5 +64,8 @@
64
64
  "arlac77/template-node-app",
65
65
  "arlac77/template-typescript"
66
66
  ]
67
+ },
68
+ "dependencies": {
69
+ "pacc": "^3.1.9"
67
70
  }
68
71
  }
package/src/model.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import { readFile, writeFile, mkdir, glob } from "node:fs/promises";
2
2
  import { join } from "node:path";
3
+ import { getAttribute } from "pacc";
3
4
 
4
5
  export class Base {
5
6
  owner;
@@ -89,18 +90,24 @@ export class Base {
89
90
  }
90
91
 
91
92
  expand(object) {
92
- if (typeof object === "string") {
93
- return object.replaceAll(/\$\{([^\}]*)\}/g, (match, m1) => {
94
- return this[m1] || "${" + m1 + "}";
95
- });
96
- }
93
+ switch (typeof object) {
94
+ case "string":
95
+ return object.replaceAll(/\$\{([^\}]*)\}/g, (match, m1) => {
96
+ return getAttribute(this, m1) || "${" + m1 + "}";
97
+ });
98
+
99
+ case "object":
100
+ if (Array.isArray(object)) {
101
+ return object.map(e => this.expand(e));
102
+ }
97
103
 
98
- if (Array.isArray(object)) {
99
- return object.map(e => this.expand(e));
100
- }
104
+ if (object instanceof Set) {
105
+ return new Set([...object].map(e => this.expand(e)));
106
+ }
101
107
 
102
- if (object instanceof Set) {
103
- return new Set([...object].map(e => this.expand(e)));
108
+ /*return Object.fromEntries(
109
+ Object.entries(object).map(([k, v]) => [k, this.expand(v)])
110
+ );*/
104
111
  }
105
112
 
106
113
  return object;
@@ -413,15 +420,13 @@ export class World extends Owner {
413
420
  }
414
421
  }
415
422
 
416
- class DNSService {
417
- owner;
418
-
423
+ class DNSService extends Base {
419
424
  allowedUpdates = [];
420
425
  recordTTL = "1W";
421
426
  forwardsTo = [];
422
427
 
423
428
  constructor(owner, data) {
424
- this.owner = owner;
429
+ super(owner, data);
425
430
  Object.assign(this, data);
426
431
  }
427
432
 
@@ -435,6 +440,10 @@ class DNSService {
435
440
  yield* owner.services(filter);
436
441
  }
437
442
  }
443
+
444
+ get propertyNames() {
445
+ return ["recordTTL", "forwardsTo", "allowedUpdates"];
446
+ }
438
447
  }
439
448
 
440
449
  export class Location extends Owner {
@@ -494,7 +503,7 @@ export class Location extends Owner {
494
503
  }
495
504
 
496
505
  get propertyNames() {
497
- return [...super.propertyNames, "domain" /*, "hosts"*/];
506
+ return [...super.propertyNames, "domain", "administratorEmail", "dns"];
498
507
  }
499
508
  }
500
509
 
@@ -780,6 +789,10 @@ export class Host extends Base {
780
789
  }
781
790
  }
782
791
 
792
+ get ipAddresses() {
793
+ return [...this.networkAddresses()].map(na => na.address);
794
+ }
795
+
783
796
  get ipAddress() {
784
797
  for (const a of this.networkAddresses()) {
785
798
  return a.address;
@@ -882,7 +895,7 @@ export class Service extends Base {
882
895
  #priority;
883
896
  #type;
884
897
  #port;
885
- #ipAddress;
898
+ #ipAddresses;
886
899
 
887
900
  static get typeName() {
888
901
  return "service";
@@ -906,9 +919,9 @@ export class Service extends Base {
906
919
  this.#port = data.port;
907
920
  delete data.port;
908
921
  }
909
- if (data.ipAddress) {
910
- this.#ipAddress = data.ipAddress;
911
- delete data.ipAddress;
922
+ if (data.ipAddresses) {
923
+ this.#ipAddresses = data.ipAddresses;
924
+ delete data.ipAddresses;
912
925
  }
913
926
 
914
927
  Object.assign(this, data);
@@ -933,8 +946,8 @@ export class Service extends Base {
933
946
  if (this.#port) {
934
947
  data.port = this.#port;
935
948
  }
936
- if (this.#ipAddress) {
937
- data.ipAddress = this.#ipAddress;
949
+ if (this.#ipAddresses) {
950
+ data.ipAddresses = this.#ipAddresses;
938
951
  }
939
952
  return new this.constructor(owner, data);
940
953
  }
@@ -953,8 +966,8 @@ export class Service extends Base {
953
966
  }
954
967
  }
955
968
 
956
- get ipAddress() {
957
- return this.#ipAddress || this.owner.ipAddress;
969
+ get ipAddresses() {
970
+ return this.#ipAddresses || this.owner.ipAddresses;
958
971
  }
959
972
 
960
973
  get port() {
@@ -980,7 +993,7 @@ export class Service extends Base {
980
993
  get propertyNames() {
981
994
  return [
982
995
  ...super.propertyNames,
983
- "ipAddress",
996
+ "ipAddresses",
984
997
  "port",
985
998
  "protocol",
986
999
  "alias",
package/types/model.d.mts CHANGED
@@ -119,6 +119,7 @@ export class Host extends Base {
119
119
  address: any;
120
120
  networkInterface: any;
121
121
  }, void, unknown>;
122
+ get ipAddresses(): any[];
122
123
  get ipAddress(): any;
123
124
  publicKey(type?: string): Promise<string>;
124
125
  toJSON(): {
@@ -137,7 +138,7 @@ export class Service extends Base {
137
138
  alias: any;
138
139
  get protocol(): any;
139
140
  get srvPrefix(): string;
140
- get ipAddress(): any;
141
+ get ipAddresses(): any;
141
142
  get port(): any;
142
143
  get priority(): any;
143
144
  get weight(): any;
@@ -145,9 +146,7 @@ export class Service extends Base {
145
146
  get type(): any;
146
147
  #private;
147
148
  }
148
- declare class DNSService {
149
- constructor(owner: any, data: any);
150
- owner: any;
149
+ declare class DNSService extends Base {
151
150
  allowedUpdates: any[];
152
151
  recordTTL: string;
153
152
  forwardsTo: any[];