pmcf 1.30.6 → 1.31.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.30.6",
3
+ "version": "1.31.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/base.mjs CHANGED
@@ -112,7 +112,7 @@ export class Base {
112
112
  return new Set([...object].map(e => this.expand(e)));
113
113
  }
114
114
 
115
- /*return Object.fromEntries(
115
+ /*return Object.fromEntries(
116
116
  Object.entries(object).map(([k, v]) => [k, this.expand(v)])
117
117
  );*/
118
118
  }
@@ -180,21 +180,33 @@ export class Base {
180
180
  }
181
181
 
182
182
  toJSON() {
183
- return extractFrom(this, this.propertyNames);
183
+ return extractFrom(this);
184
184
  }
185
185
  }
186
186
 
187
- export function extractFrom(object, propertyNames) {
187
+ export function extractFrom(object) {
188
188
  const json = {};
189
- for (const p of propertyNames) {
189
+
190
+ for (const p of object?.propertyNames || Object.keys(object)) {
190
191
  const value = object[p];
191
192
 
192
- if (value !== undefined) {
193
- if (value instanceof Base && value.name !== undefined) {
194
- json[p] = { name: value.name, type: value.typeName };
195
- } else {
193
+ switch (typeof value) {
194
+ case "undefined":
195
+ break;
196
+ case "object":
197
+ if (value instanceof Base) {
198
+ json[p] = { type: value.typeName };
199
+ if (value.name) {
200
+ json[p].name = value.name;
201
+ }
202
+ } else {
203
+ json[p] = Object.fromEntries(
204
+ Object.entries(value).map(([k, v]) => [k, extractFrom(v)])
205
+ );
206
+ }
207
+ break;
208
+ default:
196
209
  json[p] = value;
197
- }
198
210
  }
199
211
  }
200
212
  return json;
package/src/model.mjs CHANGED
@@ -538,6 +538,7 @@ export class NetworkInterface extends Base {
538
538
  }
539
539
 
540
540
  const _types = [
541
+ Owner,
541
542
  Location,
542
543
  Network,
543
544
  Subnet,
package/src/owner.mjs CHANGED
@@ -10,6 +10,10 @@ export class Owner extends Base {
10
10
  domain;
11
11
  ntp = { servers: [] };
12
12
 
13
+ static get typeName() {
14
+ return "owner";
15
+ }
16
+
13
17
  constructor(owner, data) {
14
18
  super(owner, data);
15
19
 
@@ -84,8 +88,6 @@ export class Owner extends Base {
84
88
  this.#membersByType.set(typeName, typeSlot);
85
89
  }
86
90
  typeSlot.set(fullName, object);
87
-
88
- //console.log(this.toString(),"ADD", typeName, fullName, object.name, this.named(fullName)?.toString());
89
91
  }
90
92
 
91
93
  addObject(object) {
@@ -190,7 +192,7 @@ export class Owner extends Base {
190
192
 
191
193
  _resolveBridges() {
192
194
  for (const bridge of this.#bridges) {
193
- this.info(bridgeToJSON(bridge));
195
+ //this.info(bridgeToJSON(bridge));
194
196
  for (const network of bridge) {
195
197
  if (typeof network === "string") {
196
198
  const other = this.networkNamed(network);
package/types/base.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- export function extractFrom(object: any, propertyNames: any): {};
1
+ export function extractFrom(object: any): {};
2
2
  export class Base {
3
3
  static get typeName(): string;
4
4
  static get pluralTypeName(): string;
package/types/model.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  export class Root extends Owner {
2
2
  static get types(): {
3
- [k: string]: typeof DNSService | typeof Subnet | typeof Cluster | typeof Service | typeof Host | typeof NetworkInterface;
3
+ [k: string]: typeof DNSService | typeof Owner | typeof Subnet | typeof Service | typeof Host | typeof NetworkInterface;
4
4
  };
5
5
  constructor(directory: any);
6
6
  get fullName(): string;
@@ -69,6 +69,5 @@ export class NetworkInterface extends Base {
69
69
  import { Owner } from "./owner.mjs";
70
70
  import { DNSService } from "./dns.mjs";
71
71
  import { Subnet } from "./owner.mjs";
72
- import { Cluster } from "./cluster.mjs";
73
72
  import { Service } from "./service.mjs";
74
73
  import { Base } from "./base.mjs";