pmcf 6.54.4 → 6.54.5

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/README.md CHANGED
@@ -81,30 +81,30 @@ generates config packages for:
81
81
  * [domainNames](#domainnames)
82
82
  * [InitializationContext](#initializationcontext)
83
83
  * [Parameters](#parameters-14)
84
+ * [SkeletonNetworkInterface](#skeletonnetworkinterface)
85
+ * [networkAddresses](#networkaddresses)
86
+ * [Parameters](#parameters-15)
84
87
  * [Interface](#interface)
85
88
  * [zones](#zones)
86
89
  * [addressesStatement](#addressesstatement)
87
- * [Parameters](#parameters-15)
90
+ * [Parameters](#parameters-16)
88
91
  * [SystemdJournalRemoteService](#systemdjournalremoteservice)
89
92
  * [Properties](#properties)
90
93
  * [systemdConfigs](#systemdconfigs)
91
- * [Parameters](#parameters-16)
94
+ * [Parameters](#parameters-17)
92
95
  * [SystemdJournalUploadService](#systemdjournaluploadservice)
93
96
  * [Properties](#properties-1)
94
97
  * [systemdConfigs](#systemdconfigs-1)
95
- * [Parameters](#parameters-17)
98
+ * [Parameters](#parameters-18)
96
99
  * [NetworkAddress](#networkaddress)
97
- * [Parameters](#parameters-18)
100
+ * [Parameters](#parameters-19)
98
101
  * [subnet](#subnet)
99
102
  * [networkInterface](#networkinterface)
100
103
  * [address](#address)
101
104
  * [addresses](#addresses)
102
- * [Parameters](#parameters-19)
103
- * [cidrAddresses](#cidraddresses)
104
105
  * [Parameters](#parameters-20)
105
- * [SkeletonNetworkInterface](#skeletonnetworkinterface)
106
- * [networkAddresses](#networkaddresses)
107
- * [Parameters](#parameters-21)
106
+ * [cidrAddresses](#cidraddresses)
107
+ * [Parameters](#parameters-21)
108
108
  * [families](#families)
109
109
  * [secretName](#secretname)
110
110
  * [directHosts](#directhosts)
@@ -308,6 +308,18 @@ Keeps track of all in flight object creations and loose ends during config initi
308
308
 
309
309
  * `directory` (optional, default `"/"`)
310
310
 
311
+ ## SkeletonNetworkInterface
312
+
313
+ **Extends Interface**
314
+
315
+ ### networkAddresses
316
+
317
+ #### Parameters
318
+
319
+ * `filter` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** (optional, default `n=>true`)
320
+
321
+ Returns **Iterable<[NetworkAddress](#networkaddress)>**&#x20;
322
+
311
323
  ## Interface
312
324
 
313
325
  **Extends ServiceOwner**
@@ -402,18 +414,6 @@ Returns **Iterable<[string](https://developer.mozilla.org/docs/Web/JavaScript/Re
402
414
 
403
415
  Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>**&#x20;
404
416
 
405
- ## SkeletonNetworkInterface
406
-
407
- **Extends Interface**
408
-
409
- ### networkAddresses
410
-
411
- #### Parameters
412
-
413
- * `filter` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** (optional, default `n=>true`)
414
-
415
- Returns **Iterable<[NetworkAddress](#networkaddress)>**&#x20;
416
-
417
417
  ## families
418
418
 
419
419
  Returns **[Set](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>**&#x20;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmcf",
3
- "version": "6.54.4",
3
+ "version": "6.54.5",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -1,4 +1,10 @@
1
- import { default_attribute, type_attribute, getAttribute, asArray } from "pacc";
1
+ import {
2
+ default_attribute,
3
+ type_attribute,
4
+ getAttribute,
5
+ asArray,
6
+ leafValues
7
+ } from "pacc";
2
8
  import { familyIP, formatCIDR, decodeIP, addressType } from "ip-utilties";
3
9
  import { Subnet } from "./subnet.mjs";
4
10
  import { owner } from "./owner.mjs";
@@ -10,6 +16,7 @@ import {
10
16
  address_attribute,
11
17
  cidr_address_attribute
12
18
  } from "./common-attributes.mjs";
19
+
13
20
  /**
14
21
  *
15
22
  */
@@ -96,31 +103,30 @@ export class NetworkAddress {
96
103
  * @param {Iterable<owner|string>} sources
97
104
  * @param {Object} options
98
105
  * @param {boolean} options.aggregate
99
- * @param {Object} options.filter
100
106
  * @returns {Iterable<string>} addresses
101
107
  */
102
108
  export function addresses(sources, options) {
103
109
  return [
104
- ...new Set(
105
- asArray(sources)
106
- .map(s => {
107
- if (typeof s === "string") {
108
- return s;
110
+ ...[...leafValues(sources)].reduce((all, source) => {
111
+ if (typeof source === "string") {
112
+ all.add(source);
113
+ } else {
114
+ if (source.subnets?.size && options?.aggregate) {
115
+ for (const address of source.subnets.keys()) {
116
+ all.add(address);
109
117
  }
110
- if (options?.aggregate && s instanceof owner && s.subnets.size > 0) {
111
- return [...s.subnets.keys()];
118
+ } else if (source.networkAddresses) {
119
+ for (const na of source.networkAddresses()) {
120
+ all.add(decodeIP(na.address));
112
121
  }
113
-
114
- return s.networkAddresses
115
- ? [...s.networkAddresses(options?.filter)]
116
- : s;
117
- })
118
- .flat()
119
- .map(object =>
120
- typeof object === "string" ? object : decodeIP(object.address)
121
- )
122
- )
123
- ].filter(e => e !== "");
122
+ } else {
123
+ all.add(decodeIP(source.address));
124
+ }
125
+ }
126
+
127
+ return all;
128
+ }, new Set())
129
+ ];
124
130
  }
125
131
 
126
132
  /**