pmcf 1.30.7 → 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.7",
3
+ "version": "1.31.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/base.mjs CHANGED
@@ -180,23 +180,30 @@ 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
193
  switch (typeof value) {
193
194
  case "undefined":
194
195
  break;
195
196
  case "object":
196
- if (value instanceof Base && value.name !== undefined) {
197
- json[p] = { name: value.name, type: value.typeName };
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
+ );
198
206
  }
199
-
200
207
  break;
201
208
  default:
202
209
  json[p] = value;
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
 
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";