pmcf 4.0.8 → 4.1.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": "4.0.8",
3
+ "version": "4.1.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/base.mjs CHANGED
@@ -381,11 +381,10 @@ export class Base {
381
381
 
382
382
  /**
383
383
  * Retrive attribute values from an object.
384
- * @return {Object} values
384
+ * @param {Function} [filter]
385
+ * @return {Iterable<[string,any]>} values
385
386
  */
386
- getProperties(filter = filterPublic) {
387
- const result = {};
388
-
387
+ *propertyIterator(filter) {
389
388
  for (
390
389
  let typeDefinition = this.constructor.typeDefinition;
391
390
  typeDefinition;
@@ -396,16 +395,22 @@ export class Base {
396
395
  filter
397
396
  )) {
398
397
  const name = path.join(".");
399
-
400
- let value = this.extendedProperty(name);
398
+ const value = this.extendedProperty(name);
401
399
 
402
400
  if (value !== undefined) {
403
- result[def.externalName ?? name] = toExternal(value, def);
401
+ yield [def.externalName ?? name, toExternal(value, def), path, def];
404
402
  }
405
403
  }
406
404
  }
405
+ }
407
406
 
408
- return result;
407
+ /**
408
+ * Retrive attribute values from an object.
409
+ * @param {Function} [filter]
410
+ * @return {Object} values
411
+ */
412
+ getProperties(filter = filterPublic) {
413
+ return Object.fromEntries(this.propertyIterator(filter));
409
414
  }
410
415
 
411
416
  get root() {
package/src/host.mjs CHANGED
@@ -425,6 +425,7 @@ export class Host extends ServiceOwner {
425
425
  }
426
426
 
427
427
  async *preparePackages(dir) {
428
+ const pkgName = `${this.typeName}-${this.owner.name}-${this.name}`;
428
429
  let packageData = {
429
430
  dir,
430
431
  sources: [
@@ -440,7 +441,7 @@ export class Host extends ServiceOwner {
440
441
  ],
441
442
  outputs: this.outputs,
442
443
  properties: {
443
- name: `${this.typeName}-${this.owner.name}-${this.name}`,
444
+ name: pkgName,
444
445
  description: `${this.typeName} definitions for ${this.fullName}`,
445
446
  access: "private",
446
447
  dependencies: [
@@ -448,7 +449,7 @@ export class Host extends ServiceOwner {
448
449
  ...this.depends
449
450
  ],
450
451
  provides: [...this.provides],
451
- replaces: [`mf-${this.hostName}`, ...this.replaces],
452
+ replaces: [...this.replaces],
452
453
  requires: [],
453
454
  backup: "root/.ssh/known_hosts",
454
455
  hooks: await loadHooks(
@@ -496,7 +497,7 @@ export class Host extends ServiceOwner {
496
497
  name: `${this.typeName}-extra-${this.owner.name}-${this.name}`,
497
498
  description: `additional files for ${this.fullName}`,
498
499
  access: "private",
499
- dependencies: [`${this.typeName}-${this.owner.name}-${this.name}`]
500
+ dependencies: [pkgName]
500
501
  }
501
502
  };
502
503
 
package/types/base.d.mts CHANGED
@@ -71,9 +71,16 @@ export class Base {
71
71
  extendedProperty(propertyName: any): any;
72
72
  /**
73
73
  * Retrive attribute values from an object.
74
+ * @param {Function} [filter]
75
+ * @return {Iterable<[string,any]>} values
76
+ */
77
+ propertyIterator(filter?: Function): Iterable<[string, any]>;
78
+ /**
79
+ * Retrive attribute values from an object.
80
+ * @param {Function} [filter]
74
81
  * @return {Object} values
75
82
  */
76
- getProperties(filter?: typeof filterPublic): any;
83
+ getProperties(filter?: Function): any;
77
84
  get root(): any;
78
85
  get location(): any;
79
86
  get host(): any;
@@ -136,4 +143,3 @@ export class Base {
136
143
  toString(): string;
137
144
  toJSON(): any;
138
145
  }
139
- import { filterPublic } from "pacc";