pmcf 2.32.2 → 2.33.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": "2.32.2",
3
+ "version": "2.33.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -39,7 +39,7 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "ip-utilties": "^1.3.1",
42
- "npm-pkgbuild": "^18.0.1",
42
+ "npm-pkgbuild": "^18.1.0",
43
43
  "pacc": "^3.4.0",
44
44
  "pkg-dir": "^8.0.0"
45
45
  },
package/src/base.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { join } from "node:path";
2
2
  import { allOutputs } from "npm-pkgbuild";
3
3
  import { getAttribute } from "pacc";
4
- import { addType, primitives } from "./types.mjs";
4
+ import { addType, primitives, typeFactory } from "./types.mjs";
5
5
 
6
6
  const BaseTypeDefinition = {
7
7
  name: "base",
@@ -201,12 +201,13 @@ export class Base {
201
201
  if (value instanceof property.type[0].clazz) {
202
202
  assign(property, value);
203
203
  } else {
204
- const factory =
205
- property.type[0].factoryFor?.(this, value) || property.type[0].clazz;
206
-
207
204
  assign(
208
205
  property,
209
- new factory(this.ownerFor(property, value), value)
206
+ typeFactory(
207
+ property.type[0],
208
+ this.ownerFor(property, value),
209
+ value
210
+ )
210
211
  );
211
212
  }
212
213
  break;
package/src/host.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { readFile } from "node:fs/promises";
2
2
  import { join } from "node:path";
3
3
  import { FileContentProvider } from "npm-pkgbuild";
4
- import { Base } from "./base.mjs";
4
+ import { ServiceOwner, Base } from "pmcf";
5
5
  import { networkAddressProperties, addresses } from "./network-support.mjs";
6
6
  import { domainFromDominName, domainName } from "./utils.mjs";
7
7
  import { objectFilter } from "./filter.mjs";
@@ -75,8 +75,7 @@ const HostTypeDefinition = {
75
75
  }
76
76
  };
77
77
 
78
- export class Host extends Base {
79
- _services = [];
78
+ export class Host extends ServiceOwner {
80
79
  _extends = [];
81
80
  _aliases = new Set();
82
81
  _networkInterfaces = new Map();
@@ -143,10 +142,6 @@ export class Host extends Base {
143
142
  for (const ni of this.networkInterfaces.values()) {
144
143
  ni._traverse(...args);
145
144
  }
146
- for (const service of this._services) {
147
- service._traverse(...args);
148
- }
149
-
150
145
  return true;
151
146
  }
152
147
  return false;
@@ -208,7 +203,6 @@ export class Host extends Base {
208
203
  return this.extends.find(h => h.isModel);
209
204
  }
210
205
 
211
-
212
206
  set aliases(value) {
213
207
  if (value instanceof Set) {
214
208
  this._aliases = this._aliases.union(value);
@@ -359,22 +353,6 @@ export class Host extends Base {
359
353
  yield this;
360
354
  }
361
355
 
362
- get services() {
363
- return this._services;
364
- }
365
-
366
- set services(service) {
367
- const present = this._services.find(s => s.name === service.name);
368
-
369
- if (!present) {
370
- this._services.push(service);
371
- }
372
- }
373
-
374
- *findServices(filter) {
375
- yield* objectFilter(types.service, this._services, filter);
376
- }
377
-
378
356
  typeNamed(typeName, name) {
379
357
  if (typeName === NetworkInterfaceTypeDefinition.name) {
380
358
  const ni = this._networkInterfaces.get(name);
@@ -382,13 +360,6 @@ export class Host extends Base {
382
360
  return ni;
383
361
  }
384
362
  }
385
- if (typeName === "service") {
386
- const service = this.services.find(s => s.name === name);
387
- if (service) {
388
- return service;
389
- }
390
- }
391
-
392
363
  return super.typeNamed(typeName, name);
393
364
  }
394
365
 
@@ -397,10 +368,8 @@ export class Host extends Base {
397
368
  if (ni) {
398
369
  return ni;
399
370
  }
400
- const service = this.services.find(s => s.name === name);
401
- if (service) {
402
- return service;
403
- }
371
+
372
+ return super.named(name);
404
373
  }
405
374
 
406
375
  get network() {
package/src/module.mjs CHANGED
@@ -4,6 +4,7 @@ export * from "./owner.mjs";
4
4
  export * from "./location.mjs";
5
5
  export * from "./root.mjs";
6
6
  export * from "./subnet.mjs";
7
+ export * from "./service-owner.mjs";
7
8
  export * from "./network.mjs";
8
9
  export * from "./network-address.mjs";
9
10
  export * from "./network-support.mjs";
@@ -26,6 +26,11 @@ export class LoopbackNetworkInterface extends SkeletonNetworkInterface {
26
26
  return LoopbackNetworkInterfaceTypeDefinition;
27
27
  }
28
28
 
29
+ constructor(owner, data) {
30
+ super(owner, data);
31
+ this.read(data, NetworkInterfaceTypeDefinition);
32
+ }
33
+
29
34
  get kind() {
30
35
  return LoopbackNetworkInterfaceTypeDefinition.name;
31
36
  }
@@ -34,6 +34,8 @@ export const NetworkInterfaceTypeDefinition = {
34
34
  properties: {
35
35
  ...networkProperties,
36
36
  ...networkAddressProperties,
37
+
38
+ services: { type: "service", collection: true, writeable: true },
37
39
  hostName: { type: "string", collection: false, writeable: true },
38
40
  ipAddresses: { type: "string", collection: true, writeable: true },
39
41
 
@@ -1,9 +1,10 @@
1
1
  import { join } from "node:path";
2
- import { NetworkAddress, Base } from "pmcf";
3
2
  import { writeLines, sectionLines } from "../utils.mjs";
3
+ import { NetworkAddress } from "pmcf";
4
+ import { ServiceOwner } from "../service-owner.mjs";
4
5
  import { cidrAddresses } from "../network-support.mjs";
5
6
 
6
- export class SkeletonNetworkInterface extends Base {
7
+ export class SkeletonNetworkInterface extends ServiceOwner {
7
8
  _extends = [];
8
9
  _network;
9
10
 
@@ -31,6 +32,10 @@ export class SkeletonNetworkInterface extends Base {
31
32
  return this.owner;
32
33
  }
33
34
 
35
+ *hosts() {
36
+ yield* this.owner.hosts();
37
+ }
38
+
34
39
  get network_interface() {
35
40
  return this;
36
41
  }
@@ -56,9 +61,8 @@ export class SkeletonNetworkInterface extends Base {
56
61
  this._network = network;
57
62
  }
58
63
 
59
- *subnets ()
60
- {
61
- yield *this.ipAddresses.values();
64
+ *subnets() {
65
+ yield* this.ipAddresses.values();
62
66
  }
63
67
 
64
68
  get ipAddresses() {
package/src/root.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { readFile, glob } from "node:fs/promises";
2
2
  import { join } from "node:path";
3
3
  import { Location } from "./location.mjs";
4
- import { addType, types, resolveTypeLinks } from "./types.mjs";
4
+ import { addType, types, resolveTypeLinks, typeFactory } from "./types.mjs";
5
5
 
6
6
  const RootTypeDefinition = {
7
7
  name: "root",
@@ -49,8 +49,7 @@ export class Root extends Location {
49
49
  const fullName = this.fullName + "/" + name;
50
50
  data.name = fullName.substring(owner.fullName.length + 1);
51
51
 
52
- const object = new type.clazz(owner, data);
53
-
52
+ const object = typeFactory(type, owner, data);
54
53
  this.addTypeObject(type.clazz.typeName, name, object);
55
54
  return object;
56
55
  }
@@ -0,0 +1,53 @@
1
+ import { Base } from "pmcf";
2
+ import { objectFilter } from "./filter.mjs";
3
+ import { types } from "./types.mjs";
4
+
5
+ export class ServiceOwner extends Base {
6
+ _services = [];
7
+
8
+ get services() {
9
+ return this._services;
10
+ }
11
+
12
+ set services(service) {
13
+ const present = this._services.find(s => s.name === service.name);
14
+
15
+ // console.log("SET SERVICE", service.name);
16
+ if (!present) {
17
+ this._services.push(service);
18
+ }
19
+ }
20
+
21
+ *findServices(filter) {
22
+ yield* objectFilter(types.service, this._services, filter);
23
+ }
24
+
25
+ _traverse(...args) {
26
+ if (super._traverse(...args)) {
27
+ for (const service of this._services) {
28
+ service._traverse(...args);
29
+ }
30
+
31
+ return true;
32
+ }
33
+ return false;
34
+ }
35
+
36
+ typeNamed(typeName, name) {
37
+ if (typeName === "service") {
38
+ const service = this.services.find(s => s.name === name);
39
+ if (service) {
40
+ return service;
41
+ }
42
+ }
43
+
44
+ return super.typeNamed(typeName, name);
45
+ }
46
+
47
+ named(name) {
48
+ const service = this.services.find(s => s.name === name);
49
+ if (service) {
50
+ return service;
51
+ }
52
+ }
53
+ }
package/src/service.mjs CHANGED
@@ -81,7 +81,7 @@ export const endpointProperties = {
81
81
 
82
82
  export const EndpointTypeDefinition = {
83
83
  name: "endpoint",
84
- owners: ["service"],
84
+ owners: ["service", "network-interface"],
85
85
  priority: 0.4,
86
86
  specializations: {},
87
87
  properties: endpointProperties
@@ -152,6 +152,10 @@ export class Service extends Base {
152
152
  return this.owner;
153
153
  }
154
154
 
155
+ *hosts() {
156
+ yield* this.owner.hosts();
157
+ }
158
+
155
159
  get domainName() {
156
160
  return this.host.domainName;
157
161
  }
@@ -367,7 +367,9 @@ async function generateZoneDefs(dns, location, packageData) {
367
367
  );
368
368
  }
369
369
 
370
- for (const domain of dns.localDomains) {
370
+ console.log("LOCAL DOMAINS", location.localDomains, location.domain, location.toString());
371
+
372
+ for (const domain of location.localDomains) {
371
373
  const locationName = location.name;
372
374
  const reverseZones = new Map();
373
375
 
@@ -408,6 +410,7 @@ async function generateZoneDefs(dns, location, packageData) {
408
410
  const hosts = new Set();
409
411
  const addresses = new Set();
410
412
 
413
+ console.log("LIST", location.toString());
411
414
  for await (const {
412
415
  address,
413
416
  subnet,
@@ -415,6 +418,8 @@ async function generateZoneDefs(dns, location, packageData) {
415
418
  domainNames,
416
419
  family
417
420
  } of location.networkAddresses()) {
421
+ console.log("ADDRESS",address);
422
+
418
423
  if (
419
424
  !dns.exclude.has(networkInterface.network) &&
420
425
  !dns.excludeInterfaceKinds.has(networkInterface.kind)
package/src/types.mjs CHANGED
@@ -83,3 +83,8 @@ export function resolveTypeLinks() {
83
83
  }
84
84
  }
85
85
  }
86
+
87
+ export function typeFactory(type, owner, data) {
88
+ const factory = type.factoryFor?.(owner, data) || type.clazz;
89
+ return new factory(owner, data);
90
+ }
package/types/host.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- export class Host extends Base {
1
+ export class Host extends ServiceOwner {
2
2
  static get typeDefinition(): {
3
3
  name: string;
4
4
  priority: number;
@@ -172,7 +172,6 @@ export class Host extends Base {
172
172
  };
173
173
  };
174
174
  };
175
- _services: any[];
176
175
  _extends: any[];
177
176
  _aliases: Set<any>;
178
177
  _networkInterfaces: Map<any, any>;
@@ -187,9 +186,6 @@ export class Host extends Base {
187
186
  _architecture: any;
188
187
  _serial: any;
189
188
  _applyExtends(host: any): void;
190
- set services(service: any[]);
191
- get services(): any[];
192
- _traverse(...args: any[]): boolean;
193
189
  set serial(value: any);
194
190
  get serial(): any;
195
191
  set deployment(value: any);
@@ -229,7 +225,6 @@ export class Host extends Base {
229
225
  get clusters(): Set<any>;
230
226
  get host(): this;
231
227
  hosts(): Generator<this, void, unknown>;
232
- named(name: any): any;
233
228
  get networks(): Set<any>;
234
229
  findNetworkInterfaces(filter: any): Generator<any, void, any>;
235
230
  findNetworkInterface(filter: any): any;
@@ -256,5 +251,5 @@ export class Host extends Base {
256
251
  };
257
252
  }, void, unknown>;
258
253
  }
259
- import { Base } from "./base.mjs";
254
+ import { ServiceOwner } from "pmcf";
260
255
  import { FileContentProvider } from "npm-pkgbuild";
@@ -4,6 +4,7 @@ export * from "./owner.mjs";
4
4
  export * from "./location.mjs";
5
5
  export * from "./root.mjs";
6
6
  export * from "./subnet.mjs";
7
+ export * from "./service-owner.mjs";
7
8
  export * from "./network.mjs";
8
9
  export * from "./network-address.mjs";
9
10
  export * from "./network-support.mjs";
@@ -69,6 +69,11 @@ export class EthernetNetworkInterface extends NetworkInterface {
69
69
  specializations: {};
70
70
  factoryFor(owner: any, value: any): any;
71
71
  properties: {
72
+ services: {
73
+ type: string;
74
+ collection: boolean;
75
+ writeable: boolean;
76
+ };
72
77
  hostName: {
73
78
  type: string;
74
79
  collection: boolean;
@@ -223,6 +228,11 @@ export class EthernetNetworkInterface extends NetworkInterface {
223
228
  specializations: {};
224
229
  factoryFor(owner: any, value: any): any;
225
230
  properties: {
231
+ services: {
232
+ type: string;
233
+ collection: boolean;
234
+ writeable: boolean;
235
+ };
226
236
  hostName: {
227
237
  type: string;
228
238
  collection: boolean;
@@ -55,6 +55,11 @@ export class LoopbackNetworkInterface extends SkeletonNetworkInterface {
55
55
  specializations: {};
56
56
  factoryFor(owner: any, value: any): any;
57
57
  properties: {
58
+ services: {
59
+ type: string;
60
+ collection: boolean;
61
+ writeable: boolean;
62
+ };
58
63
  hostName: {
59
64
  type: string;
60
65
  collection: boolean;
@@ -209,6 +214,11 @@ export class LoopbackNetworkInterface extends SkeletonNetworkInterface {
209
214
  specializations: {};
210
215
  factoryFor(owner: any, value: any): any;
211
216
  properties: {
217
+ services: {
218
+ type: string;
219
+ collection: boolean;
220
+ writeable: boolean;
221
+ };
212
222
  hostName: {
213
223
  type: string;
214
224
  collection: boolean;
@@ -53,6 +53,11 @@ export namespace NetworkInterfaceTypeDefinition {
53
53
  export let specializations: {};
54
54
  export function factoryFor(owner: any, value: any): any;
55
55
  export let properties: {
56
+ services: {
57
+ type: string;
58
+ collection: boolean;
59
+ writeable: boolean;
60
+ };
56
61
  hostName: {
57
62
  type: string;
58
63
  collection: boolean;
@@ -207,6 +212,11 @@ export class NetworkInterface extends SkeletonNetworkInterface {
207
212
  specializations: {};
208
213
  factoryFor(owner: any, value: any): any;
209
214
  properties: {
215
+ services: {
216
+ type: string;
217
+ collection: boolean;
218
+ writeable: boolean;
219
+ };
210
220
  hostName: {
211
221
  type: string;
212
222
  collection: boolean;
@@ -1,9 +1,10 @@
1
- export class SkeletonNetworkInterface extends Base {
1
+ export class SkeletonNetworkInterface extends ServiceOwner {
2
2
  _extends: any[];
3
3
  _network: any;
4
4
  get typeName(): string;
5
5
  set extends(value: any[]);
6
6
  get extends(): any[];
7
+ hosts(): Generator<any, void, any>;
7
8
  get network_interface(): this;
8
9
  get domainNames(): Set<any>;
9
10
  matches(other: any): boolean;
@@ -22,5 +23,5 @@ export class SkeletonNetworkInterface extends Base {
22
23
  get addresses(): any[];
23
24
  systemdDefinitions(packageData: any): Promise<void>;
24
25
  }
25
- import { Base } from "pmcf";
26
+ import { ServiceOwner } from "../service-owner.mjs";
26
27
  import { NetworkAddress } from "pmcf";
@@ -55,6 +55,11 @@ export class WireguardNetworkInterface extends SkeletonNetworkInterface {
55
55
  specializations: {};
56
56
  factoryFor(owner: any, value: any): any;
57
57
  properties: {
58
+ services: {
59
+ type: string;
60
+ collection: boolean;
61
+ writeable: boolean;
62
+ };
58
63
  hostName: {
59
64
  type: string;
60
65
  collection: boolean;
@@ -209,6 +214,11 @@ export class WireguardNetworkInterface extends SkeletonNetworkInterface {
209
214
  specializations: {};
210
215
  factoryFor(owner: any, value: any): any;
211
216
  properties: {
217
+ services: {
218
+ type: string;
219
+ collection: boolean;
220
+ writeable: boolean;
221
+ };
212
222
  hostName: {
213
223
  type: string;
214
224
  collection: boolean;
@@ -55,6 +55,11 @@ export class WLANNetworkInterface extends EthernetNetworkInterface {
55
55
  specializations: {};
56
56
  factoryFor(owner: any, value: any): any;
57
57
  properties: {
58
+ services: {
59
+ type: string;
60
+ collection: boolean;
61
+ writeable: boolean;
62
+ };
58
63
  hostName: {
59
64
  type: string;
60
65
  collection: boolean;
@@ -211,6 +216,11 @@ export class WLANNetworkInterface extends EthernetNetworkInterface {
211
216
  specializations: {};
212
217
  factoryFor(owner: any, value: any): any;
213
218
  properties: {
219
+ services: {
220
+ type: string;
221
+ collection: boolean;
222
+ writeable: boolean;
223
+ };
214
224
  hostName: {
215
225
  type: string;
216
226
  collection: boolean;
@@ -365,6 +375,11 @@ export class WLANNetworkInterface extends EthernetNetworkInterface {
365
375
  specializations: {};
366
376
  factoryFor(owner: any, value: any): any;
367
377
  properties: {
378
+ services: {
379
+ type: string;
380
+ collection: boolean;
381
+ writeable: boolean;
382
+ };
368
383
  hostName: {
369
384
  type: string;
370
385
  collection: boolean;
package/types/root.d.mts CHANGED
@@ -283,7 +283,7 @@ export class Root extends Location {
283
283
  constructor(directory: any);
284
284
  get fullName(): string;
285
285
  get root(): this;
286
- _load(name: any, type: any): any;
286
+ _load(name: any, type: any): Promise<any>;
287
287
  load(name: any, options: any): any;
288
288
  loadAll(): Promise<void>;
289
289
  }
@@ -0,0 +1,8 @@
1
+ export class ServiceOwner extends Base {
2
+ _services: any[];
3
+ set services(service: any[]);
4
+ get services(): any[];
5
+ _traverse(...args: any[]): boolean;
6
+ named(name: any): any;
7
+ }
8
+ import { Base } from "pmcf";
@@ -305,6 +305,7 @@ export class Service extends Base {
305
305
  _extends: any[];
306
306
  set extends(value: any[]);
307
307
  get extends(): any[];
308
+ hosts(): Generator<any, void, any>;
308
309
  get domainName(): any;
309
310
  get ipAddressOrDomainName(): any;
310
311
  get addresses(): any;
package/types/types.d.mts CHANGED
@@ -1,4 +1,5 @@
1
1
  export function addType(clazz: any): void;
2
2
  export function resolveTypeLinks(): void;
3
+ export function typeFactory(type: any, owner: any, data: any): any;
3
4
  export const types: {};
4
5
  export const primitives: Set<string>;