pmcf 3.20.3 → 3.21.1

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/README.md CHANGED
@@ -42,23 +42,22 @@ generates config packages for:
42
42
 
43
43
  * [Base](#base)
44
44
  * [Parameters](#parameters)
45
+ * [getProperties](#getproperties)
46
+ * [Parameters](#parameters-1)
45
47
  * [priority](#priority)
46
48
  * [expression](#expression)
47
- * [Parameters](#parameters-1)
48
- * [findService](#findservice)
49
49
  * [Parameters](#parameters-2)
50
- * [expand](#expand)
50
+ * [findService](#findservice)
51
51
  * [Parameters](#parameters-3)
52
+ * [expand](#expand)
53
+ * [Parameters](#parameters-4)
52
54
  * [PortEndpoint](#portendpoint)
53
- * [Parameters](#parameters-4)
55
+ * [Parameters](#parameters-5)
54
56
  * [port](#port)
55
57
  * [socketAddress](#socketaddress)
56
58
  * [HTTPEndpoint](#httpendpoint)
57
- * [Parameters](#parameters-5)
59
+ * [Parameters](#parameters-6)
58
60
  * [port](#port-1)
59
- * [SkeletonNetworkInterface](#skeletonnetworkinterface)
60
- * [networkAddresses](#networkaddresses)
61
- * [Parameters](#parameters-6)
62
61
  * [SystemdJournalRemoteService](#systemdjournalremoteservice)
63
62
  * [Properties](#properties)
64
63
  * [systemdConfigs](#systemdconfigs)
@@ -76,23 +75,26 @@ generates config packages for:
76
75
  * [Parameters](#parameters-10)
77
76
  * [cidrAddresses](#cidraddresses)
78
77
  * [Parameters](#parameters-11)
78
+ * [SkeletonNetworkInterface](#skeletonnetworkinterface)
79
+ * [networkAddresses](#networkaddresses)
80
+ * [Parameters](#parameters-12)
79
81
  * [isTemplate](#istemplate)
80
82
  * [services](#services)
81
- * [Parameters](#parameters-12)
82
- * [named](#named)
83
83
  * [Parameters](#parameters-13)
84
- * [serviceEndpoints](#serviceendpoints)
84
+ * [named](#named)
85
85
  * [Parameters](#parameters-14)
86
- * [domainName](#domainname)
86
+ * [serviceEndpoints](#serviceendpoints)
87
87
  * [Parameters](#parameters-15)
88
- * [domainFromDominName](#domainfromdominname)
88
+ * [domainName](#domainname)
89
89
  * [Parameters](#parameters-16)
90
- * [sectionLines](#sectionlines)
90
+ * [domainFromDominName](#domainfromdominname)
91
91
  * [Parameters](#parameters-17)
92
- * [asArray](#asarray)
92
+ * [sectionLines](#sectionlines)
93
93
  * [Parameters](#parameters-18)
94
- * [asIterator](#asiterator)
94
+ * [asArray](#asarray)
95
95
  * [Parameters](#parameters-19)
96
+ * [asIterator](#asiterator)
97
+ * [Parameters](#parameters-20)
96
98
 
97
99
  ## Base
98
100
 
@@ -101,6 +103,16 @@ generates config packages for:
101
103
  * `owner` **[Base](#base)** 
102
104
  * `data` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** 
103
105
 
106
+ ### getProperties
107
+
108
+ Retrive attribute values from an object.
109
+
110
+ #### Parameters
111
+
112
+ * `filter` (optional, default `filterPublic`)
113
+
114
+ Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** values
115
+
104
116
  ### priority
105
117
 
106
118
  Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** 
@@ -165,18 +177,6 @@ Endpoint based on http
165
177
 
166
178
  Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** 
167
179
 
168
- ## SkeletonNetworkInterface
169
-
170
- **Extends ServiceOwner**
171
-
172
- ### networkAddresses
173
-
174
- #### Parameters
175
-
176
- * `filter` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** (optional, default `n=>true`)
177
-
178
- Returns **Iterable<[NetworkAddress](#networkaddress)>**&#x20;
179
-
180
180
  ## SystemdJournalRemoteService
181
181
 
182
182
  **Extends Service**
@@ -252,6 +252,18 @@ Returns **Iterable<[string](https://developer.mozilla.org/docs/Web/JavaScript/Re
252
252
 
253
253
  Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>**&#x20;
254
254
 
255
+ ## SkeletonNetworkInterface
256
+
257
+ **Extends ServiceOwner**
258
+
259
+ ### networkAddresses
260
+
261
+ #### Parameters
262
+
263
+ * `filter` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** (optional, default `n=>true`)
264
+
265
+ Returns **Iterable<[NetworkAddress](#networkaddress)>**&#x20;
266
+
255
267
  ## isTemplate
256
268
 
257
269
  Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**&#x20;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmcf",
3
- "version": "3.20.3",
3
+ "version": "3.21.1",
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.0.3",
58
+ "pacc": "^7.1.0",
59
59
  "package-directory": "^8.1.0"
60
60
  },
61
61
  "devDependencies": {
package/src/base.mjs CHANGED
@@ -6,6 +6,8 @@ import {
6
6
  parse,
7
7
  globals,
8
8
  expand,
9
+ toExternal,
10
+ filterPublic,
9
11
  attributeIterator,
10
12
  default_attribute,
11
13
  name_attribute_writable,
@@ -16,6 +18,7 @@ import {
16
18
  description_attribute_writable,
17
19
  boolean_attribute_writable
18
20
  } from "pacc";
21
+
19
22
  import { asArray } from "./utils.mjs";
20
23
 
21
24
  /**
@@ -282,8 +285,7 @@ export class Base {
282
285
  }*/
283
286
  }
284
287
 
285
- _applyExtends() {
286
- }
288
+ _applyExtends() {}
287
289
 
288
290
  set extends(value) {
289
291
  this._extends.push(value);
@@ -376,6 +378,35 @@ export class Base {
376
378
  return this._extendedProperty(propertyName, new Set());
377
379
  }
378
380
 
381
+ /**
382
+ * Retrive attribute values from an object.
383
+ * @return {Object} values
384
+ */
385
+ getProperties(filter = filterPublic) {
386
+ const result = {};
387
+
388
+ for (
389
+ let typeDefinition = this.constructor.typeDefinition;
390
+ typeDefinition;
391
+ typeDefinition = typeDefinition.extends
392
+ ) {
393
+ for (const [path, def] of attributeIterator(
394
+ typeDefinition.attributes,
395
+ filter
396
+ )) {
397
+ const name = path.join(".");
398
+
399
+ let value = this.extendedProperty(name);
400
+
401
+ if (value !== undefined) {
402
+ result[def.externalName ?? name] = toExternal(value, def);
403
+ }
404
+ }
405
+ }
406
+
407
+ return result;
408
+ }
409
+
379
410
  get root() {
380
411
  return this.owner.root;
381
412
  }
@@ -516,7 +547,7 @@ export class Base {
516
547
  }
517
548
 
518
549
  get isTemplate() {
519
- return this.name?.indexOf("*") >= 0 || this.owner?.isTemplate || false;
550
+ return this.name?.indexOf("*") >= 0 || this.owner?.isTemplate || false;
520
551
  }
521
552
 
522
553
  get properties() {
@@ -654,10 +685,10 @@ export function extractFrom(
654
685
  const json = {};
655
686
 
656
687
  do {
657
- for (const [path, def] of attributeIterator(typeDefinition.attributes)) {
658
- if (def.private) {
659
- continue;
660
- }
688
+ for (const [path, def] of attributeIterator(
689
+ typeDefinition.attributes,
690
+ filterPublic
691
+ )) {
661
692
  const name = path.join(".");
662
693
  let value = object[name];
663
694
 
package/src/host.mjs CHANGED
@@ -119,15 +119,12 @@ export class Host extends ServiceOwner {
119
119
  _applyExtends(host) {
120
120
  super._applyExtends(host);
121
121
  for (const [name, ni] of host.networkInterfaces) {
122
- if (!ni.isTemplate) {
123
- let present = this._networkInterfaces.get(name);
124
-
125
- if (!present) {
126
- present = ni.forOwner(this);
127
- this._networkInterfaces.set(name, present);
128
- }
122
+ const present = this._networkInterfaces.get(name);
129
123
 
124
+ if (present) {
130
125
  present.extends.push(ni);
126
+ } else {
127
+ this._networkInterfaces.set(name, ni.forOwner(this));
131
128
  }
132
129
  }
133
130
  }
@@ -1,10 +1,10 @@
1
1
  import {
2
- getAttributesJSON,
3
2
  addType,
4
3
  string_attribute_writable,
5
4
  boolean_attribute_writable
6
5
  } from "pacc";
7
6
  import { Service, ServiceTypeDefinition, addServiceType } from "pmcf";
7
+ import { filterConfigurable } from "../utils.mjs";
8
8
 
9
9
  const SystemdJournalRemoteServiceTypeDefinition = {
10
10
  name: "systemd-journal-remote",
@@ -14,59 +14,66 @@ const SystemdJournalRemoteServiceTypeDefinition = {
14
14
  key: "name",
15
15
  attributes: {
16
16
  Seal: {
17
- ...boolean_attribute_writable
17
+ ...boolean_attribute_writable,
18
+ configurable: true
18
19
  },
19
20
  SplitMode: {
20
21
  ...string_attribute_writable,
21
- values: [false, "host"]
22
+ values: [false, "host"],
23
+ configurable: true
22
24
  },
23
25
  ServerKeyFile: {
24
- ...string_attribute_writable
26
+ ...string_attribute_writable,
27
+ configurable: true
25
28
  // default: "/etc/ssl/private/journal-upload.pem"
26
29
  },
27
30
  ServerCertificateFile: {
28
- ...string_attribute_writable
31
+ ...string_attribute_writable,
32
+ configurable: true
29
33
  // default: "/etc/ssl/certs/journal-upload.pem"
30
34
  },
31
35
  TrustedCertificateFile: {
32
- ...string_attribute_writable
36
+ ...string_attribute_writable,
37
+ configurable: true
33
38
  // default: "/etc/ssl/ca/trusted.pem"
34
39
  },
35
40
  MaxUse: {
36
- ...string_attribute_writable
41
+ ...string_attribute_writable,
42
+ configurable: true
37
43
  },
38
44
  KeepFree: {
39
- ...string_attribute_writable
45
+ ...string_attribute_writable,
46
+ configurable: true
40
47
  },
41
48
  MaxFileSize: {
42
- ...string_attribute_writable
49
+ ...string_attribute_writable,
50
+ configurable: true
43
51
  },
44
52
  MaxFiles: {
45
- ...string_attribute_writable
53
+ ...string_attribute_writable,
54
+ configurable: true
46
55
  },
47
56
  Compression: {
48
- ...string_attribute_writable
57
+ ...string_attribute_writable,
58
+ configurable: true
49
59
  // default: "zstd lz4 xz"
50
60
  }
51
61
  },
52
-
53
62
  service: {
54
- services: {
55
- endpoints: [
56
- {
57
- family: "IPv4",
58
- port: 19532,
59
- protocol: "tcp",
60
- tls: false
61
- },
62
- {
63
- family: "IPv6",
64
- port: 19532,
65
- protocol: "tcp",
66
- tls: false
67
- }
68
- ]
69
- }
63
+ endpoints: [
64
+ {
65
+ family: "IPv4",
66
+ port: 19532,
67
+ protocol: "tcp",
68
+ tls: false
69
+ },
70
+ {
71
+ family: "IPv6",
72
+ port: 19532,
73
+ protocol: "tcp",
74
+ tls: false
75
+ }
76
+ ]
70
77
  }
71
78
  };
72
79
 
@@ -102,23 +109,7 @@ export class SystemdJournalRemoteService extends Service {
102
109
  {
103
110
  serviceName: "systemd-journal-remote.service",
104
111
  configFileName: `etc/systemd/journal-remote.conf.d/${name}.conf`,
105
- content: [
106
- "Remote",
107
- {
108
- ...getAttributesJSON(
109
- this,
110
- SystemdJournalRemoteServiceTypeDefinition.attributes
111
- ),
112
- // TODO extendet properties with getAttribute()
113
- ...Object.fromEntries(
114
- Object.entries(
115
- SystemdJournalRemoteServiceTypeDefinition.attributes
116
- )
117
- .map(([k, v]) => [k, this.extendedProperty(k)])
118
- .filter(([k, v]) => v !== undefined)
119
- )
120
- }
121
- ]
112
+ content: ["Remote", this.getProperties(filterConfigurable)]
122
113
  }
123
114
  ];
124
115
  }
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  string_attribute_writable,
3
3
  boolean_attribute_writable,
4
- addType,
5
- getAttributesJSON
4
+ addType
6
5
  } from "pacc";
7
6
  import { Service, ServiceTypeDefinition, addServiceType } from "pmcf";
7
+ import { filterConfigurable } from "../utils.mjs";
8
8
 
9
9
  const SystemdJournalUploadServiceTypeDefinition = {
10
10
  name: "systemd-journal-upload",
@@ -13,28 +13,34 @@ const SystemdJournalUploadServiceTypeDefinition = {
13
13
  owners: ServiceTypeDefinition.owners,
14
14
  key: "name",
15
15
  attributes: {
16
- URL: string_attribute_writable,
16
+ URL: { ...string_attribute_writable, configurable: true },
17
17
  ServerKeyFile: {
18
- ...string_attribute_writable
18
+ ...string_attribute_writable,
19
+ configurable: true
19
20
  // default: "/etc/ssl/private/journal-upload.pem"
20
21
  },
21
22
  ServerCertificateFile: {
22
- ...string_attribute_writable
23
+ ...string_attribute_writable,
24
+ configurable: true
23
25
  // default: "/etc/ssl/certs/journal-upload.pem"
24
26
  },
25
27
  TrustedCertificateFile: {
26
- ...string_attribute_writable
28
+ ...string_attribute_writable,
29
+ configurable: true
27
30
  // default: "/etc/ssl/ca/trusted.pem"
28
31
  },
29
32
  Compression: {
30
- ...string_attribute_writable
33
+ ...string_attribute_writable,
34
+ configurable: true
31
35
  // default: "zstd lz4 xz"
32
36
  },
33
37
  ForceCompression: {
34
- ...boolean_attribute_writable
38
+ ...boolean_attribute_writable,
39
+ configurable: true
35
40
  // default: false
36
41
  }
37
- }
42
+ },
43
+ service: {}
38
44
  };
39
45
 
40
46
  /**
@@ -69,21 +75,7 @@ export class SystemdJournalUploadService extends Service {
69
75
  return {
70
76
  serviceName: "systemd-journal-upload.service",
71
77
  configFileName: `etc/systemd/journal-upload.conf.d/${name}.conf`,
72
- content: [
73
- "Upload",
74
- {
75
- ...getAttributesJSON(
76
- this,
77
- SystemdJournalUploadServiceTypeDefinition.attributes
78
- ),
79
- // TODO extendet properties with getAttribute()
80
- ...Object.fromEntries(
81
- Object.entries(SystemdJournalUploadServiceTypeDefinition.attributes)
82
- .map(([k, v]) => [k, this.extendedProperty(k)])
83
- .filter(([k, v]) => v !== undefined)
84
- )
85
- }
86
- ]
78
+ content: ["Upload", this.getProperties(filterConfigurable)]
87
79
  };
88
80
  }
89
81
  }
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  addType,
3
- getAttributesJSON,
4
3
  string_attribute_writable,
5
4
  duration_attribute_writable
6
5
  } from "pacc";
7
- import { Service, ServiceTypeDefinition } from "pmcf";
6
+ import { Service, ServiceTypeDefinition, addServiceType } from "pmcf";
7
+ import { filterConfigurable } from "../utils.mjs";
8
8
 
9
9
  const SystemdJournalServiceTypeDefinition = {
10
10
  name: "systemd-journal",
@@ -14,80 +14,105 @@ const SystemdJournalServiceTypeDefinition = {
14
14
  key: "name",
15
15
  attributes: {
16
16
  Storage: {
17
- ...string_attribute_writable
17
+ ...string_attribute_writable,
18
+ configurable: true
18
19
  },
19
20
  Seal: {
20
- ...string_attribute_writable
21
+ ...string_attribute_writable,
22
+ configurable: true
21
23
  },
22
24
  SplitMode: {
23
- ...string_attribute_writable
25
+ ...string_attribute_writable,
26
+ configurable: true
24
27
  },
25
28
  SyncIntervalSec: {
26
- ...duration_attribute_writable
29
+ ...duration_attribute_writable,
30
+ configurable: true
27
31
  },
28
32
  RateLimitIntervalSec: {
29
- ...duration_attribute_writable
33
+ ...duration_attribute_writable,
34
+ configurable: true
30
35
  },
31
36
  RateLimitBurst: {
32
- ...string_attribute_writable
37
+ ...string_attribute_writable,
38
+ configurable: true
33
39
  },
34
40
  SystemMaxUse: {
35
- ...string_attribute_writable
41
+ ...string_attribute_writable,
42
+ configurable: true
36
43
  },
37
44
  SystemKeepFree: {
38
- ...string_attribute_writable
45
+ ...string_attribute_writable,
46
+ configurable: true
39
47
  },
40
48
  SystemMaxFileSize: {
41
- ...string_attribute_writable
49
+ ...string_attribute_writable,
50
+ configurable: true
42
51
  },
43
52
  SystemMaxFiles: {
44
- ...string_attribute_writable
53
+ ...string_attribute_writable,
54
+ configurable: true
45
55
  },
46
56
  RuntimeMaxUse: {
47
- ...string_attribute_writable
57
+ ...string_attribute_writable,
58
+ configurable: true
48
59
  },
49
60
  RuntimeKeepFree: {
50
- ...string_attribute_writable
61
+ ...string_attribute_writable,
62
+ configurable: true
51
63
  },
52
64
  RuntimeMaxFileSize: {
53
- ...string_attribute_writable
65
+ ...string_attribute_writable,
66
+ configurable: true
54
67
  },
55
68
  RuntimeMaxFiles: {
56
- ...string_attribute_writable
69
+ ...string_attribute_writable,
70
+ configurable: true
57
71
  },
58
72
  MaxRetentionSec: {
59
- ...duration_attribute_writable
73
+ ...duration_attribute_writable,
74
+ configurable: true
60
75
  },
61
76
  MaxFileSec: {
62
- ...duration_attribute_writable
77
+ ...duration_attribute_writable,
78
+ configurable: true
63
79
  },
64
80
  ForwardToSyslog: {
65
- ...string_attribute_writable
81
+ ...string_attribute_writable,
82
+ configurable: true
66
83
  },
67
84
  ForwardToKMsg: {
68
- ...string_attribute_writable
85
+ ...string_attribute_writable,
86
+ configurable: true
69
87
  },
70
88
  ForwardToConsole: {
71
- ...string_attribute_writable
89
+ ...string_attribute_writable,
90
+ configurable: true
72
91
  },
73
92
  ForwardToWall: {
74
- ...string_attribute_writable
93
+ ...string_attribute_writable,
94
+ configurable: true
75
95
  },
76
96
  TTYPath: {
77
- ...string_attribute_writable
97
+ ...string_attribute_writable,
98
+ configurable: true
78
99
  },
79
100
  MaxLevelStore: {
80
- ...string_attribute_writable
101
+ ...string_attribute_writable,
102
+ configurable: true
81
103
  },
82
104
  Compress: {
83
- ...string_attribute_writable
105
+ ...string_attribute_writable,
106
+ configurable: true
84
107
  }
85
- }
108
+ },
109
+ service: {}
86
110
  };
87
111
 
88
112
  export class SystemdJournalService extends Service {
89
113
  static {
90
114
  addType(this);
115
+ addServiceType(this.typeDefinition.service, this.typeDefinition.name);
91
116
  }
92
117
 
93
118
  static get typeDefinition() {
@@ -104,22 +129,9 @@ export class SystemdJournalService extends Service {
104
129
 
105
130
  systemdConfigs(name) {
106
131
  return {
107
- serviceName: "systemd-journald",
132
+ serviceName: "systemd-journald.service",
108
133
  configFileName: `etc/systemd/journal.conf.d/${name}.conf`,
109
- content: [
110
- "Journal",
111
- {
112
- ...getAttributesJSON(
113
- this,
114
- SystemdJournalServiceTypeDefinition.attributes
115
- ),
116
- ...Object.fromEntries(
117
- Object.entries(SystemdJournalServiceTypeDefinition.attributes)
118
- .map(([k, v]) => [k, this.extendedProperty(k)])
119
- .filter(([k, v]) => v !== undefined)
120
- )
121
- }
122
- ]
134
+ content: ["Journal", this.getProperties(filterConfigurable)]
123
135
  };
124
136
  }
125
137
  }