pmcf 2.61.0 → 2.62.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": "2.61.0",
3
+ "version": "2.62.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/base.mjs CHANGED
@@ -31,7 +31,7 @@ const BaseTypeDefinition = {
31
31
  };
32
32
 
33
33
  /**
34
- *
34
+ *
35
35
  */
36
36
  export class Base {
37
37
  owner;
@@ -41,6 +41,7 @@ export class Base {
41
41
  _packaging = new Set();
42
42
  _directory;
43
43
  _finalize;
44
+ _properties;
44
45
 
45
46
  static {
46
47
  addType(this);
@@ -141,7 +142,11 @@ export class Base {
141
142
 
142
143
  const instantiateAndAssign = (property, value) => {
143
144
  if (primitives.has(property.type[0])) {
144
- assign(property, value);
145
+ if (value !== undefined) {
146
+ value = this.expand(value);
147
+ assign(property, value);
148
+ //console.log("A1",property.name,value);
149
+ }
145
150
  return;
146
151
  }
147
152
 
@@ -221,6 +226,10 @@ export class Base {
221
226
  }
222
227
  };
223
228
 
229
+ if (data?.properties) {
230
+ this._properties = data.properties;
231
+ }
232
+
224
233
  for (const property of Object.values(type.properties)) {
225
234
  if (property.writeable) {
226
235
  const value = data[property.name];
@@ -377,8 +386,8 @@ export class Base {
377
386
  }
378
387
 
379
388
  /**
380
- *
381
- * @param {any} filter
389
+ *
390
+ * @param {any} filter
382
391
  * @returns service with the highest priority
383
392
  */
384
393
  findService(filter) {
@@ -452,6 +461,15 @@ export class Base {
452
461
  return false;
453
462
  }
454
463
 
464
+ property(name) {
465
+ const value = this._properties?.[name];
466
+ if (value === undefined && this.owner) {
467
+ return this.owner.property(name);
468
+ }
469
+
470
+ return value;
471
+ }
472
+
455
473
  expand(object) {
456
474
  if (this.isTemplate) {
457
475
  return object;
@@ -460,7 +478,7 @@ export class Base {
460
478
  switch (typeof object) {
461
479
  case "string":
462
480
  return object.replaceAll(/\$\{([^\}]*)\}/g, (match, m1) => {
463
- return getAttribute(this, m1) ?? "${" + m1 + "}";
481
+ return this.property(m1) ?? getAttribute(this, m1) ?? "${" + m1 + "}";
464
482
  });
465
483
 
466
484
  case "object":
package/src/host.mjs CHANGED
@@ -211,7 +211,7 @@ export class Host extends ServiceOwner {
211
211
  }
212
212
 
213
213
  get isTemplate() {
214
- return this.isModel || this.name.match(/services\//); // TODO
214
+ return this.isModel || this.name?.match(/services\//); // TODO
215
215
  }
216
216
 
217
217
  get isModel() {
@@ -27,7 +27,7 @@ export class SkeletonNetworkInterface extends ServiceOwner {
27
27
  }
28
28
 
29
29
  get isTemplate() {
30
- return this.name.indexOf("*") >= 0;
30
+ return this.name?.indexOf("*") >= 0;
31
31
  }
32
32
 
33
33
  get host() {
package/types/base.d.mts CHANGED
@@ -61,6 +61,7 @@ export class Base {
61
61
  _packaging: Set<any>;
62
62
  _directory: any;
63
63
  _finalize: any;
64
+ _properties: any;
64
65
  ownerFor(property: any, data: any): any;
65
66
  read(data: any, type: any): void;
66
67
  named(name: any): void;
@@ -106,6 +107,7 @@ export class Base {
106
107
  set tags(value: Set<any>);
107
108
  get tags(): Set<any>;
108
109
  get isTemplate(): boolean;
110
+ property(name: any): any;
109
111
  expand(object: any): any;
110
112
  finalize(action: any): void;
111
113
  execFinalize(): void;