pmcf 4.24.5 → 4.25.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmcf",
3
- "version": "4.24.5",
3
+ "version": "4.25.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/base.mjs CHANGED
@@ -29,7 +29,7 @@ import { union } from "./utils.mjs";
29
29
 
30
30
  /**
31
31
  *
32
- * attributes: essential values
32
+ * attributes: as declared in the types
33
33
  * properties: use defined values to support attribute value definitions
34
34
  */
35
35
  export class Base {
@@ -65,12 +65,12 @@ export class Base {
65
65
  owner;
66
66
  description;
67
67
  name;
68
+ properties = {};
68
69
  extends = new Set();
69
70
  _tags = new Set();
70
71
  _packaging = new Set();
71
72
  _directory;
72
73
  _finalize;
73
- _properties = {};
74
74
 
75
75
  /**
76
76
  *
@@ -222,7 +222,7 @@ export class Base {
222
222
  * @param {string} name
223
223
  * @returns {any}
224
224
  */
225
- extendedAttribute(name) {
225
+ attribute(name) {
226
226
  for (const node of this.walkDirections(["this", "extends"])) {
227
227
  const value = getAttribute(node, name);
228
228
  if (value !== undefined) {
@@ -236,7 +236,7 @@ export class Base {
236
236
  * @param {Function} [filter]
237
237
  * @return {Iterable<[string,any]>} values
238
238
  */
239
- *propertyIterator(filter) {
239
+ *attributeIterator(filter) {
240
240
  for (
241
241
  let typeDefinition = this.constructor.typeDefinition;
242
242
  typeDefinition;
@@ -247,7 +247,7 @@ export class Base {
247
247
  filter
248
248
  )) {
249
249
  const name = path.join(".");
250
- const value = this.extendedAttribute(name);
250
+ const value = this.attribute(name);
251
251
 
252
252
  if (value !== undefined) {
253
253
  yield [def.externalName ?? name, toExternal(value, def), path, def];
@@ -261,12 +261,16 @@ export class Base {
261
261
  * @param {Function} [filter]
262
262
  * @return {Object} values
263
263
  */
264
- getProperties(filter = filterPublic) {
265
- return Object.fromEntries(this.propertyIterator(filter));
264
+ getAttributes(filter = filterPublic) {
265
+ return Object.fromEntries(this.attributeIterator(filter));
266
266
  }
267
267
 
268
- get properties() {
269
- return this._properties;
268
+ valueFor(name, at) {
269
+ if (at !== undefined) {
270
+ return this.attribute(name) ?? this.property(name);
271
+ }
272
+
273
+ return globals[name];
270
274
  }
271
275
 
272
276
  /**
@@ -275,8 +279,8 @@ export class Base {
275
279
  * @returns {any}
276
280
  */
277
281
  property(name) {
278
- for (const node of this.walkDirections(["this", "extends", "owner"])) {
279
- const value = node._properties?.[name];
282
+ for (const node of this.walkDirections()) {
283
+ const value = node.properties[name];
280
284
 
281
285
  if (value !== undefined) {
282
286
  return this.expand(value);
@@ -470,14 +474,6 @@ export class Base {
470
474
  return this.name?.indexOf("*") >= 0 || this.owner?.isTemplate || false;
471
475
  }
472
476
 
473
- valueFor(name, at) {
474
- if (at !== undefined) {
475
- return this.extendedAttribute(name) ?? this.property(name);
476
- }
477
-
478
- return globals[name];
479
- }
480
-
481
477
  /**
482
478
  *
483
479
  * @param {any} object
package/src/host.mjs CHANGED
@@ -157,7 +157,7 @@ export class Host extends ServiceOwner {
157
157
  }
158
158
 
159
159
  get serial() {
160
- return this.extendedAttribute("_serial");
160
+ return this.attribute("_serial");
161
161
  }
162
162
 
163
163
  set deployment(value) {
@@ -165,7 +165,7 @@ export class Host extends ServiceOwner {
165
165
  }
166
166
 
167
167
  get deployment() {
168
- return this.extendedAttribute("_deployment");
168
+ return this.attribute("_deployment");
169
169
  }
170
170
 
171
171
  set chassis(value) {
@@ -173,7 +173,7 @@ export class Host extends ServiceOwner {
173
173
  }
174
174
 
175
175
  get chassis() {
176
- return this.extendedAttribute("_chassis");
176
+ return this.attribute("_chassis");
177
177
  }
178
178
 
179
179
  set vendor(value) {
@@ -181,7 +181,7 @@ export class Host extends ServiceOwner {
181
181
  }
182
182
 
183
183
  get vendor() {
184
- return this.extendedAttribute("_vendor");
184
+ return this.attribute("_vendor");
185
185
  }
186
186
 
187
187
  /**
@@ -196,7 +196,7 @@ export class Host extends ServiceOwner {
196
196
  }
197
197
 
198
198
  get keymap() {
199
- return this.extendedAttribute("_keymap");
199
+ return this.attribute("_keymap");
200
200
  }
201
201
 
202
202
  set architecture(value) {
@@ -204,7 +204,7 @@ export class Host extends ServiceOwner {
204
204
  }
205
205
 
206
206
  get architecture() {
207
- return this.extendedAttribute("_architecture");
207
+ return this.attribute("_architecture");
208
208
  }
209
209
 
210
210
  get derivedPackaging() {
@@ -284,7 +284,7 @@ export class Host extends ServiceOwner {
284
284
  }
285
285
 
286
286
  get os() {
287
- return this.extendedAttribute("_os");
287
+ return this.attribute("_os");
288
288
  }
289
289
 
290
290
  set distribution(value) {
@@ -292,7 +292,7 @@ export class Host extends ServiceOwner {
292
292
  }
293
293
 
294
294
  get distribution() {
295
- return this.extendedAttribute("_distribution");
295
+ return this.attribute("_distribution");
296
296
  }
297
297
 
298
298
  get modelName() {
@@ -188,7 +188,7 @@ export class InitializationContext {
188
188
 
189
189
  read(object, data, type = object.constructor.typeDefinition) {
190
190
  if (data?.properties) {
191
- Object.assign(object._properties, data.properties);
191
+ Object.assign(object.properties, data.properties);
192
192
  }
193
193
 
194
194
  this._read(object, data, type);
@@ -309,7 +309,7 @@ export class InitializationContext {
309
309
  const data = JSON.parse(
310
310
  await readFile(join(this.directory, name), "utf8")
311
311
  );
312
- this.root._properties = data.properties;
312
+ this.root.properties = data.properties;
313
313
  } else {
314
314
  await this.load("/" + name, { type });
315
315
  }
@@ -124,7 +124,7 @@ export class NetworkInterface extends SkeletonNetworkInterface {
124
124
  }
125
125
 
126
126
  get hostName() {
127
- return this.extendedAttribute("_hostName") ?? this.host.hostName;
127
+ return this.attribute("_hostName") ?? this.host.hostName;
128
128
  }
129
129
 
130
130
  set hostName(value) {
@@ -145,7 +145,7 @@ export class NetworkInterface extends SkeletonNetworkInterface {
145
145
 
146
146
  get scope() {
147
147
  return (
148
- this.extendedAttribute("_scope") ??
148
+ this.attribute("_scope") ??
149
149
  this.network?.scope ??
150
150
  networkAttributes.scope.default
151
151
  );
@@ -156,7 +156,7 @@ export class NetworkInterface extends SkeletonNetworkInterface {
156
156
  }
157
157
 
158
158
  get hwaddr() {
159
- return this.extendedAttribute("_hwaddr");
159
+ return this.attribute("_hwaddr");
160
160
  }
161
161
 
162
162
  set metric(value) {
@@ -165,7 +165,7 @@ export class NetworkInterface extends SkeletonNetworkInterface {
165
165
 
166
166
  get metric() {
167
167
  return (
168
- this.extendedAttribute("_metric") ??
168
+ this.attribute("_metric") ??
169
169
  this.network?.metric ??
170
170
  networkAttributes.metric.default
171
171
  );
@@ -176,7 +176,7 @@ export class NetworkInterface extends SkeletonNetworkInterface {
176
176
  }
177
177
 
178
178
  get mtu() {
179
- return this.extendedAttribute("_mtu");
179
+ return this.attribute("_mtu");
180
180
  }
181
181
 
182
182
  set class(value) {
@@ -184,7 +184,7 @@ export class NetworkInterface extends SkeletonNetworkInterface {
184
184
  }
185
185
 
186
186
  get class() {
187
- return this.extendedAttribute("_class") ?? this.network?.class;
187
+ return this.attribute("_class") ?? this.network?.class;
188
188
  }
189
189
 
190
190
  set kind(value) {
@@ -192,7 +192,7 @@ export class NetworkInterface extends SkeletonNetworkInterface {
192
192
  }
193
193
 
194
194
  get kind() {
195
- return this.extendedAttribute("_kind") ?? this.network?.kind;
195
+ return this.attribute("_kind") ?? this.network?.kind;
196
196
  }
197
197
 
198
198
  async systemdDefinitions(dir, packageData) {
@@ -59,7 +59,7 @@ export class SkeletonNetworkInterface extends ServiceOwner {
59
59
  }
60
60
 
61
61
  get network() {
62
- return this.extendedAttribute("_network") ?? this.host?.network;
62
+ return this.attribute("_network") ?? this.host?.network;
63
63
  }
64
64
 
65
65
  set network(network) {
@@ -50,7 +50,7 @@ export class WLANNetworkInterface extends EthernetNetworkInterface {
50
50
 
51
51
  get secretName() {
52
52
  return (
53
- this.extendedAttribute("_secretName") ??
53
+ this.attribute("_secretName") ??
54
54
  this.network?.secretName ??
55
55
  `${this.network.name}.password`
56
56
  );
@@ -61,7 +61,7 @@ export class WLANNetworkInterface extends EthernetNetworkInterface {
61
61
  }
62
62
 
63
63
  get ssid() {
64
- return this.extendedAttribute("_ssid") ?? this.network?.ssid;
64
+ return this.attribute("_ssid") ?? this.network?.ssid;
65
65
  }
66
66
 
67
67
  set psk(value) {
@@ -69,7 +69,7 @@ export class WLANNetworkInterface extends EthernetNetworkInterface {
69
69
  }
70
70
 
71
71
  get psk() {
72
- return this.extendedAttribute("_psk") ?? this.network?.psk;
72
+ return this.attribute("_psk") ?? this.network?.psk;
73
73
  }
74
74
 
75
75
  async systemdDefinitions(dir, packageData) {
package/src/service.mjs CHANGED
@@ -213,7 +213,7 @@ export class Service extends Base {
213
213
  }
214
214
 
215
215
  get alias() {
216
- return this.extendedAttribute("_alias");
216
+ return this.attribute("_alias");
217
217
  }
218
218
 
219
219
  set port(value) {
@@ -221,7 +221,7 @@ export class Service extends Base {
221
221
  }
222
222
 
223
223
  get port() {
224
- return this.extendedAttribute("_port") ?? serviceTypeEndpoints(ServiceTypes[this.type])[0]?.port;
224
+ return this.attribute("_port") ?? serviceTypeEndpoints(ServiceTypes[this.type])[0]?.port;
225
225
  }
226
226
 
227
227
  set weight(value) {
@@ -229,7 +229,7 @@ export class Service extends Base {
229
229
  }
230
230
 
231
231
  get weight() {
232
- return this.extendedAttribute("_weight") ?? this.owner.weight ?? 1;
232
+ return this.attribute("_weight") ?? this.owner.weight ?? 1;
233
233
  }
234
234
 
235
235
  set type(value) {
@@ -237,7 +237,7 @@ export class Service extends Base {
237
237
  }
238
238
 
239
239
  get type() {
240
- return this.extendedAttribute("_type") ?? this.name;
240
+ return this.attribute("_type") ?? this.name;
241
241
  }
242
242
 
243
243
  get types() {
@@ -246,7 +246,7 @@ export class Service extends Base {
246
246
 
247
247
  get systemdService() {
248
248
  return (
249
- this.extendedAttribute("_systemdService") ??
249
+ this.attribute("_systemdService") ??
250
250
  ServiceTypes[this.type]?.systemdService
251
251
  );
252
252
  }
@@ -62,7 +62,7 @@ export class InfluxdbService extends Service {
62
62
  await writeLines(
63
63
  join(dir, "etc", "influxdb"),
64
64
  "config.yml",
65
- setionLinesFromPropertyIterator(this.propertyIterator(filterConfigurable))
65
+ setionLinesFromPropertyIterator(this.attributeIterator(filterConfigurable))
66
66
  );
67
67
 
68
68
  yield packageData;
@@ -40,7 +40,7 @@ export class OpenLDAPService extends Service {
40
40
  }
41
41
 
42
42
  get base() {
43
- return this.extendedAttribute("_base");
43
+ return this.attribute("_base");
44
44
  }
45
45
 
46
46
  set base(value) {
@@ -48,7 +48,7 @@ export class OpenLDAPService extends Service {
48
48
  }
49
49
 
50
50
  get uri() {
51
- return this.extendedAttribute("_uri");
51
+ return this.attribute("_uri");
52
52
  }
53
53
 
54
54
  set uri(value) {
@@ -107,7 +107,7 @@ export class SystemdJournalRemoteService extends Service {
107
107
  return {
108
108
  serviceName: this.systemdService,
109
109
  configFileName: `etc/systemd/journal-remote.conf.d/${name}.conf`,
110
- content: sectionLines("Remote", this.getProperties(filterConfigurable))
110
+ content: sectionLines("Remote", this.getAttributes(filterConfigurable))
111
111
  };
112
112
  }
113
113
  }
@@ -69,11 +69,11 @@ export class SystemdJournalUploadService extends Service {
69
69
  * @returns {Object}
70
70
  */
71
71
  systemdConfigs(name) {
72
- console.log("PROPS",this.expand(this.getProperties(filterConfigurable)));
72
+ console.log("PROPS",this.expand(this.getAttributes(filterConfigurable)));
73
73
  return {
74
74
  serviceName: this.systemdService,
75
75
  configFileName: `etc/systemd/journal-upload.conf.d/${name}.conf`,
76
- content: sectionLines("Upload", this.getProperties(filterConfigurable))
76
+ content: sectionLines("Upload", this.getAttributes(filterConfigurable))
77
77
  };
78
78
  }
79
79
  }
@@ -127,7 +127,7 @@ export class SystemdJournaldService extends Service {
127
127
  return {
128
128
  serviceName: this.systemdService,
129
129
  configFileName: `etc/systemd/journal.conf.d/${name}.conf`,
130
- content: sectionLines("Journal", this.getProperties(filterConfigurable))
130
+ content: sectionLines("Journal", this.getAttributes(filterConfigurable))
131
131
  };
132
132
  }
133
133
  }
@@ -107,12 +107,12 @@ export class SystemdResolvedService extends ExtraSourceService {
107
107
  return {
108
108
  serviceName: this.systemdService,
109
109
  configFileName: `etc/systemd/resolved.conf.d/${name}.conf`,
110
- //content: [...setionLinesFromPropertyIterator(this.propertyIterator( filterConfigurable)), "A=1"]
110
+ //content: [...setionLinesFromPropertyIterator(this.attributeIterator( filterConfigurable)), "A=1"]
111
111
  content: sectionLines("Resolve", {
112
112
  DNS: serviceEndpoints(this, options(300, 399, 4)),
113
113
  FallbackDNS: serviceEndpoints(this, options(100, 199, 4)),
114
114
  MulticastDNS: yesno(this.network.multicastDNS),
115
- ...this.getProperties(filterConfigurable)
115
+ ...this.getAttributes(filterConfigurable)
116
116
  })
117
117
  };
118
118
  }
@@ -63,7 +63,7 @@ export class SystemdTimesyncdService extends ExtraSourceService {
63
63
  content: sectionLines("Time", {
64
64
  NTP: serviceEndpoints(this, options(300, 399)),
65
65
  FallbackNTP: serviceEndpoints(this, options(100, 199)),
66
- ...this.getProperties(filterConfigurable)
66
+ ...this.getAttributes(filterConfigurable)
67
67
  })
68
68
  };
69
69
  }