pmcf 2.64.6 → 2.65.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.64.6",
3
+ "version": "2.65.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -46,7 +46,7 @@
46
46
  "lint:typescript": "tsc --allowJs --checkJs --noEmit --resolveJsonModule --target esnext -m esnext --module nodenext --moduleResolution nodenext ./src**/*.mjs"
47
47
  },
48
48
  "dependencies": {
49
- "ip-utilties": "^1.4.6",
49
+ "ip-utilties": "^1.4.7",
50
50
  "npm-pkgbuild": "^18.2.10",
51
51
  "pacc": "^3.4.5",
52
52
  "pkg-dir": "^8.0.0"
package/src/base.mjs CHANGED
@@ -300,10 +300,28 @@ export class Base {
300
300
  return this.constructor.typeDefinition.name;
301
301
  }
302
302
 
303
+ /**
304
+ * @return {Iterable<Base>}
305
+ */
303
306
  get extends() {
304
307
  return [];
305
308
  }
306
309
 
310
+ *_extendedPropertyIterator(propertyName, seen) {
311
+ if (!seen.has(this)) {
312
+ seen.add(this);
313
+
314
+ const value = this[propertyName];
315
+ if (value !== undefined) {
316
+ yield value;
317
+ }
318
+
319
+ for (const e of this.extends) {
320
+ yield* e._extendedPropertyIterator(propertyName, seen);
321
+ }
322
+ }
323
+ }
324
+
307
325
  _extendedProperty(propertyName, seen) {
308
326
  if (!seen.has(this)) {
309
327
  seen.add(this);
package/src/filter.mjs CHANGED
@@ -20,10 +20,7 @@ export function* objectFilter(type, objects, filter) {
20
20
  };
21
21
 
22
22
  const filterString = key => {
23
- if (filter[key] === undefined) {
24
- return true;
25
- }
26
- if (filter[key] === object[key]) {
23
+ if (filter[key] === undefined || filter[key] === object[key]) {
27
24
  return true;
28
25
  }
29
26
 
@@ -75,7 +72,14 @@ export function* objectFilter(type, objects, filter) {
75
72
  }
76
73
  break;
77
74
  case "string":
78
- if (!filterString(property.name)) {
75
+ if (property.collection && filter[property.name] !== undefined) {
76
+ const value = object[property.name];
77
+
78
+ if (value instanceof Set && value.has(filter[property.name])) {
79
+ break;
80
+ }
81
+ continue advance;
82
+ } else if (!filterString(property.name)) {
79
83
  continue advance;
80
84
  }
81
85
  break;
@@ -26,6 +26,10 @@ export class EthernetNetworkInterface extends NetworkInterface {
26
26
  return EthernetNetworkInterfaceTypeDefinition;
27
27
  }
28
28
 
29
+ static isCommonName(name) {
30
+ return name.match(/eth\d+$/);
31
+ }
32
+
29
33
  constructor(owner, data) {
30
34
  super(owner, data);
31
35
  this.read(data, EthernetNetworkInterfaceTypeDefinition);
@@ -28,6 +28,11 @@ export class LoopbackNetworkInterface extends SkeletonNetworkInterface {
28
28
  return LoopbackNetworkInterfaceTypeDefinition;
29
29
  }
30
30
 
31
+ static isCommonName(name)
32
+ {
33
+ return name.match(/lo\d+$/);
34
+ }
35
+
31
36
  constructor(owner, data) {
32
37
  super(owner, data);
33
38
  this.read(data, NetworkInterfaceTypeDefinition);
@@ -16,12 +16,16 @@ export const NetworkInterfaceTypeDefinition = {
16
16
  extends: Base.typeDefinition,
17
17
  specializations: {},
18
18
  factoryFor(owner, value) {
19
- const kind = value.kind;
20
- const t = NetworkInterfaceTypeDefinition.specializations[kind];
19
+ let t = NetworkInterfaceTypeDefinition.specializations[value.kind];
20
+
21
+ if (!t) {
22
+ for (t of Object.values(NetworkInterfaceTypeDefinition.specializations)) {
23
+ if (t.clazz.isCommonName && t.clazz.isCommonName(value.name)) {
24
+ break;
25
+ }
26
+ }
27
+ }
21
28
 
22
- /*if (!t) {
23
- console.warn("FACTORY", owner.name, value, t?.name);
24
- }*/
25
29
  if (t) {
26
30
  delete value.type;
27
31
  delete value.kind;
@@ -53,6 +57,10 @@ export class NetworkInterface extends SkeletonNetworkInterface {
53
57
  return NetworkInterfaceTypeDefinition;
54
58
  }
55
59
 
60
+ static isCommonName(name) {
61
+ false;
62
+ }
63
+
56
64
  _ipAddresses = new Map();
57
65
  _scope;
58
66
  _metric;
package/src/service.mjs CHANGED
@@ -63,7 +63,7 @@ const ServiceTypes = {
63
63
  }
64
64
  };
65
65
 
66
- function serviceTypeEndpoints(type) {
66
+ export function serviceTypeEndpoints(type) {
67
67
  let st = ServiceTypes[type];
68
68
  if (st) {
69
69
  if (st.extends) {
@@ -92,6 +92,7 @@ export const endpointProperties = {
92
92
  values: ["tcp", "udp"]
93
93
  },
94
94
  type: { type: "string", collection: false, writeable: true },
95
+ types: { type: "string", collection: true, writeable: false },
95
96
  tls: {
96
97
  type: "boolean",
97
98
  collection: false,
@@ -193,6 +194,11 @@ export class Service extends Base {
193
194
  return this.host.subnets;
194
195
  }
195
196
 
197
+ get serviceTypeEndpoints()
198
+ {
199
+ return serviceTypeEndpoints(this.type);
200
+ }
201
+
196
202
  endpoints(filter) {
197
203
  const data = serviceTypeEndpoints(this.type);
198
204
 
@@ -264,6 +270,10 @@ export class Service extends Base {
264
270
  return this._type ?? this.name;
265
271
  }
266
272
 
273
+ get types() {
274
+ return new Set([...this._extendedPropertyIterator("type", new Set())]);
275
+ }
276
+
267
277
  get systemdServices() {
268
278
  return this.extendedProperty("_systemd");
269
279
  }
@@ -16,7 +16,11 @@ import {
16
16
  addresses
17
17
  } from "pmcf";
18
18
  import { addType } from "../types.mjs";
19
- import { ServiceTypeDefinition } from "../service.mjs";
19
+ import {
20
+ ServiceTypeDefinition,
21
+ Service,
22
+ serviceTypeEndpoints
23
+ } from "../service.mjs";
20
24
  import { ExtraSourceServiceTypeDefinition } from "../extra-source-service.mjs";
21
25
  import { addHook } from "../hooks.mjs";
22
26
 
@@ -143,6 +147,7 @@ export class BindService extends ExtraSourceService {
143
147
  constructor(owner, data) {
144
148
  super(owner, data);
145
149
 
150
+ this._extends.push(new Service(owner, { name: this.name, type: "dns" }));
146
151
  this.views = {};
147
152
 
148
153
  for (const name of ["internal", "protected"]) {
@@ -159,7 +164,11 @@ export class BindService extends ExtraSourceService {
159
164
  }
160
165
 
161
166
  get type() {
162
- return "dns";
167
+ return "bind";
168
+ }
169
+
170
+ get serviceTypeEndpoints() {
171
+ return serviceTypeEndpoints("dns");
163
172
  }
164
173
 
165
174
  endpoints(filter) {
@@ -247,7 +256,7 @@ export class BindService extends ExtraSourceService {
247
256
  };
248
257
 
249
258
  const forwarders = serviceEndpoints(this.source, {
250
- services: { type: "dns", priority: ">=300" },
259
+ services: { types: "dns", priority: ">=300" },
251
260
  select: e => e.address,
252
261
  limit: 5
253
262
  });
@@ -552,7 +561,7 @@ export class BindService extends ExtraSourceService {
552
561
  }
553
562
 
554
563
  get defaultRecords() {
555
- const nameService = this.findService({ type: "dns", priority: ">=300" });
564
+ const nameService = this.findService({ types: "dns", priority: ">=300" });
556
565
 
557
566
  const SOARecord = DNSRecord(
558
567
  "@",
@@ -39,7 +39,7 @@ export class SystemdResolvedService extends ExtraSourceService {
39
39
  systemdConfigs(name) {
40
40
  const options = (priority, limit) => {
41
41
  return {
42
- services: { type: "dns", priority },
42
+ services: { types: "dns", priority },
43
43
  endpoints: e => e.networkInterface.kind !== "loopback",
44
44
  select: endpoint => endpoint.address,
45
45
  join: " ",
package/types/base.d.mts CHANGED
@@ -71,7 +71,11 @@ export class Base {
71
71
  isNamed(name: any): boolean;
72
72
  relativeName(name: any): any;
73
73
  get typeName(): any;
74
- get extends(): any[];
74
+ /**
75
+ * @return {Iterable<Base>}
76
+ */
77
+ get extends(): Iterable<Base>;
78
+ _extendedPropertyIterator(propertyName: any, seen: any): any;
75
79
  _extendedProperty(propertyName: any, seen: any): any;
76
80
  extendedProperty(propertyName: any): any;
77
81
  get root(): any;
@@ -101,6 +101,11 @@ export class ExtraSourceService extends Service {
101
101
  collection: boolean;
102
102
  writeable: boolean;
103
103
  };
104
+ types: {
105
+ type: string;
106
+ collection: boolean;
107
+ writeable: boolean;
108
+ };
104
109
  tls: {
105
110
  type: string;
106
111
  collection: boolean;
@@ -341,6 +341,7 @@ export class EthernetNetworkInterface extends NetworkInterface {
341
341
  };
342
342
  };
343
343
  };
344
+ static isCommonName(name: any): any;
344
345
  arpbridge: any;
345
346
  get kind(): string;
346
347
  }
@@ -321,6 +321,7 @@ export class LoopbackNetworkInterface extends SkeletonNetworkInterface {
321
321
  priority: number;
322
322
  properties: {};
323
323
  };
324
+ static isCommonName(name: any): any;
324
325
  get kind(): string;
325
326
  get scope(): string;
326
327
  get localDomains(): Set<string>;
@@ -316,6 +316,7 @@ export class NetworkInterface extends SkeletonNetworkInterface {
316
316
  };
317
317
  };
318
318
  };
319
+ static isCommonName(name: any): void;
319
320
  _ipAddresses: Map<any, any>;
320
321
  _scope: any;
321
322
  _metric: any;
@@ -1,3 +1,4 @@
1
+ export function serviceTypeEndpoints(type: any): any;
1
2
  /**
2
3
  *
3
4
  * @param {*} sources
@@ -40,13 +41,21 @@ export namespace endpointProperties {
40
41
  export { writeable_2 as writeable };
41
42
  }
42
43
  export { type_2 as type };
43
- export namespace tls {
44
+ export namespace types {
44
45
  let type_4: string;
45
46
  export { type_4 as type };
46
47
  let collection_3: boolean;
47
48
  export { collection_3 as collection };
48
49
  let writeable_3: boolean;
49
50
  export { writeable_3 as writeable };
51
+ }
52
+ export namespace tls {
53
+ let type_5: string;
54
+ export { type_5 as type };
55
+ let collection_4: boolean;
56
+ export { collection_4 as collection };
57
+ let writeable_4: boolean;
58
+ export { writeable_4 as writeable };
50
59
  let _default: boolean;
51
60
  export { _default as default };
52
61
  }
@@ -149,6 +158,11 @@ export namespace ServiceTypeDefinition {
149
158
  collection: boolean;
150
159
  writeable: boolean;
151
160
  };
161
+ types: {
162
+ type: string;
163
+ collection: boolean;
164
+ writeable: boolean;
165
+ };
152
166
  tls: {
153
167
  type: string;
154
168
  collection: boolean;
@@ -269,6 +283,11 @@ export class Service extends Base {
269
283
  collection: boolean;
270
284
  writeable: boolean;
271
285
  };
286
+ types: {
287
+ type: string;
288
+ collection: boolean;
289
+ writeable: boolean;
290
+ };
272
291
  tls: {
273
292
  type: string;
274
293
  collection: boolean;
@@ -315,6 +334,7 @@ export class Service extends Base {
315
334
  get domainName(): any;
316
335
  get networks(): Set<any>;
317
336
  get subnets(): Set<any>;
337
+ get serviceTypeEndpoints(): any;
318
338
  endpoints(filter: any): any[];
319
339
  endpoint(filter: any): any;
320
340
  address(options?: {
@@ -331,6 +351,7 @@ export class Service extends Base {
331
351
  get weight(): any;
332
352
  set type(value: any);
333
353
  get type(): any;
354
+ get types(): Set<any>;
334
355
  get systemdServices(): any;
335
356
  dnsRecordsForDomainName(domainName: any, hasSVRRecords: any): {
336
357
  type: any;
@@ -87,6 +87,11 @@ export class BindService extends ExtraSourceService {
87
87
  collection: boolean;
88
88
  writeable: boolean;
89
89
  };
90
+ types: {
91
+ type: string;
92
+ collection: boolean;
93
+ writeable: boolean;
94
+ };
90
95
  tls: {
91
96
  type: string;
92
97
  collection: boolean;
@@ -210,6 +215,11 @@ export class BindService extends ExtraSourceService {
210
215
  collection: boolean;
211
216
  writeable: boolean;
212
217
  };
218
+ types: {
219
+ type: string;
220
+ collection: boolean;
221
+ writeable: boolean;
222
+ };
213
223
  tls: {
214
224
  type: string;
215
225
  collection: boolean;
@@ -87,6 +87,11 @@ export class ChronyService extends ExtraSourceService {
87
87
  collection: boolean;
88
88
  writeable: boolean;
89
89
  };
90
+ types: {
91
+ type: string;
92
+ collection: boolean;
93
+ writeable: boolean;
94
+ };
90
95
  tls: {
91
96
  type: string;
92
97
  collection: boolean;
@@ -210,6 +215,11 @@ export class ChronyService extends ExtraSourceService {
210
215
  collection: boolean;
211
216
  writeable: boolean;
212
217
  };
218
+ types: {
219
+ type: string;
220
+ collection: boolean;
221
+ writeable: boolean;
222
+ };
213
223
  tls: {
214
224
  type: string;
215
225
  collection: boolean;
@@ -88,6 +88,11 @@ export class KeaService extends Service {
88
88
  collection: boolean;
89
89
  writeable: boolean;
90
90
  };
91
+ types: {
92
+ type: string;
93
+ collection: boolean;
94
+ writeable: boolean;
95
+ };
91
96
  tls: {
92
97
  type: string;
93
98
  collection: boolean;
@@ -208,6 +213,11 @@ export class KeaService extends Service {
208
213
  collection: boolean;
209
214
  writeable: boolean;
210
215
  };
216
+ types: {
217
+ type: string;
218
+ collection: boolean;
219
+ writeable: boolean;
220
+ };
211
221
  tls: {
212
222
  type: string;
213
223
  collection: boolean;
@@ -87,6 +87,11 @@ export class OpenLDAPService extends Service {
87
87
  collection: boolean;
88
88
  writeable: boolean;
89
89
  };
90
+ types: {
91
+ type: string;
92
+ collection: boolean;
93
+ writeable: boolean;
94
+ };
90
95
  tls: {
91
96
  type: string;
92
97
  collection: boolean;
@@ -207,6 +212,11 @@ export class OpenLDAPService extends Service {
207
212
  collection: boolean;
208
213
  writeable: boolean;
209
214
  };
215
+ types: {
216
+ type: string;
217
+ collection: boolean;
218
+ writeable: boolean;
219
+ };
210
220
  tls: {
211
221
  type: string;
212
222
  collection: boolean;
@@ -87,6 +87,11 @@ export class SystemdJournalRemoteService extends Service {
87
87
  collection: boolean;
88
88
  writeable: boolean;
89
89
  };
90
+ types: {
91
+ type: string;
92
+ collection: boolean;
93
+ writeable: boolean;
94
+ };
90
95
  tls: {
91
96
  type: string;
92
97
  collection: boolean;
@@ -207,6 +212,11 @@ export class SystemdJournalRemoteService extends Service {
207
212
  collection: boolean;
208
213
  writeable: boolean;
209
214
  };
215
+ types: {
216
+ type: string;
217
+ collection: boolean;
218
+ writeable: boolean;
219
+ };
210
220
  tls: {
211
221
  type: string;
212
222
  collection: boolean;
@@ -87,6 +87,11 @@ export class SystemdJournalUploadService extends Service {
87
87
  collection: boolean;
88
88
  writeable: boolean;
89
89
  };
90
+ types: {
91
+ type: string;
92
+ collection: boolean;
93
+ writeable: boolean;
94
+ };
90
95
  tls: {
91
96
  type: string;
92
97
  collection: boolean;
@@ -207,6 +212,11 @@ export class SystemdJournalUploadService extends Service {
207
212
  collection: boolean;
208
213
  writeable: boolean;
209
214
  };
215
+ types: {
216
+ type: string;
217
+ collection: boolean;
218
+ writeable: boolean;
219
+ };
210
220
  tls: {
211
221
  type: string;
212
222
  collection: boolean;
@@ -87,6 +87,11 @@ export class SystemdJournalService extends Service {
87
87
  collection: boolean;
88
88
  writeable: boolean;
89
89
  };
90
+ types: {
91
+ type: string;
92
+ collection: boolean;
93
+ writeable: boolean;
94
+ };
90
95
  tls: {
91
96
  type: string;
92
97
  collection: boolean;
@@ -207,6 +212,11 @@ export class SystemdJournalService extends Service {
207
212
  collection: boolean;
208
213
  writeable: boolean;
209
214
  };
215
+ types: {
216
+ type: string;
217
+ collection: boolean;
218
+ writeable: boolean;
219
+ };
210
220
  tls: {
211
221
  type: string;
212
222
  collection: boolean;
@@ -87,6 +87,11 @@ export class SystemdResolvedService extends ExtraSourceService {
87
87
  collection: boolean;
88
88
  writeable: boolean;
89
89
  };
90
+ types: {
91
+ type: string;
92
+ collection: boolean;
93
+ writeable: boolean;
94
+ };
90
95
  tls: {
91
96
  type: string;
92
97
  collection: boolean;
@@ -207,6 +212,11 @@ export class SystemdResolvedService extends ExtraSourceService {
207
212
  collection: boolean;
208
213
  writeable: boolean;
209
214
  };
215
+ types: {
216
+ type: string;
217
+ collection: boolean;
218
+ writeable: boolean;
219
+ };
210
220
  tls: {
211
221
  type: string;
212
222
  collection: boolean;
@@ -87,6 +87,11 @@ export class SystemdTimesyncdService extends ExtraSourceService {
87
87
  collection: boolean;
88
88
  writeable: boolean;
89
89
  };
90
+ types: {
91
+ type: string;
92
+ collection: boolean;
93
+ writeable: boolean;
94
+ };
90
95
  tls: {
91
96
  type: string;
92
97
  collection: boolean;
@@ -207,6 +212,11 @@ export class SystemdTimesyncdService extends ExtraSourceService {
207
212
  collection: boolean;
208
213
  writeable: boolean;
209
214
  };
215
+ types: {
216
+ type: string;
217
+ collection: boolean;
218
+ writeable: boolean;
219
+ };
210
220
  tls: {
211
221
  type: string;
212
222
  collection: boolean;