pmcf 4.22.6 → 4.23.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/README.md +11 -11
- package/package.json +1 -1
- package/src/base.mjs +25 -10
- package/src/cluster.mjs +1 -1
- package/src/host.mjs +15 -0
- package/src/initialization-context.mjs +5 -5
- package/src/network-interfaces/skeleton.mjs +4 -4
- package/src/owner.mjs +1 -1
- package/src/service-owner.mjs +22 -18
package/README.md
CHANGED
|
@@ -71,11 +71,11 @@ generates config packages for:
|
|
|
71
71
|
* [Parameters](#parameters-11)
|
|
72
72
|
* [port](#port-1)
|
|
73
73
|
* [id](#id)
|
|
74
|
-
* [InitializationContext](#initializationcontext)
|
|
75
|
-
* [Parameters](#parameters-12)
|
|
76
74
|
* [SkeletonNetworkInterface](#skeletonnetworkinterface)
|
|
77
75
|
* [networkAddresses](#networkaddresses)
|
|
78
|
-
* [Parameters](#parameters-
|
|
76
|
+
* [Parameters](#parameters-12)
|
|
77
|
+
* [InitializationContext](#initializationcontext)
|
|
78
|
+
* [Parameters](#parameters-13)
|
|
79
79
|
* [SystemdJournalRemoteService](#systemdjournalremoteservice)
|
|
80
80
|
* [Properties](#properties)
|
|
81
81
|
* [systemdConfigs](#systemdconfigs)
|
|
@@ -250,14 +250,6 @@ Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/G
|
|
|
250
250
|
|
|
251
251
|
Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** 
|
|
252
252
|
|
|
253
|
-
## InitializationContext
|
|
254
|
-
|
|
255
|
-
Keeps track of all in flight object creations and loose ends during config initialization.
|
|
256
|
-
|
|
257
|
-
### Parameters
|
|
258
|
-
|
|
259
|
-
* `directory` (optional, default `"/"`)
|
|
260
|
-
|
|
261
253
|
## SkeletonNetworkInterface
|
|
262
254
|
|
|
263
255
|
**Extends ServiceOwner**
|
|
@@ -270,6 +262,14 @@ Keeps track of all in flight object creations and loose ends during config initi
|
|
|
270
262
|
|
|
271
263
|
Returns **Iterable<[NetworkAddress](#networkaddress)>** 
|
|
272
264
|
|
|
265
|
+
## InitializationContext
|
|
266
|
+
|
|
267
|
+
Keeps track of all in flight object creations and loose ends during config initialization.
|
|
268
|
+
|
|
269
|
+
### Parameters
|
|
270
|
+
|
|
271
|
+
* `directory` (optional, default `"/"`)
|
|
272
|
+
|
|
273
273
|
## SystemdJournalRemoteService
|
|
274
274
|
|
|
275
275
|
**Extends Service**
|
package/package.json
CHANGED
package/src/base.mjs
CHANGED
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
description_attribute_writable,
|
|
25
25
|
boolean_attribute_writable
|
|
26
26
|
} from "pacc";
|
|
27
|
+
import { AggregatedMap } from "aggregated-map";
|
|
27
28
|
import { union } from "./utils.mjs";
|
|
28
29
|
|
|
29
30
|
/**
|
|
@@ -36,15 +37,15 @@ export class Base {
|
|
|
36
37
|
static key = "name";
|
|
37
38
|
static priority = 0;
|
|
38
39
|
static attributes = {
|
|
39
|
-
owner: { ...default_attribute, type: "base" },
|
|
40
|
-
type: string_attribute,
|
|
41
40
|
name: name_attribute_writable,
|
|
42
41
|
description: description_attribute_writable,
|
|
43
42
|
priority: number_attribute_writable,
|
|
44
43
|
directory: string_attribute_writable,
|
|
45
44
|
packaging: string_attribute_writable,
|
|
46
45
|
disabled: boolean_attribute_writable,
|
|
47
|
-
tags: string_set_attribute_writable
|
|
46
|
+
tags: string_set_attribute_writable,
|
|
47
|
+
owner: { ...default_attribute, type: "base" },
|
|
48
|
+
type: string_attribute
|
|
48
49
|
};
|
|
49
50
|
|
|
50
51
|
static typeDefinition = this;
|
|
@@ -127,6 +128,18 @@ export class Base {
|
|
|
127
128
|
return this.owner.addObject(object);
|
|
128
129
|
}
|
|
129
130
|
|
|
131
|
+
/**
|
|
132
|
+
* Deliver AggregatedMap of all property Maps.
|
|
133
|
+
* @param {string[]} directions
|
|
134
|
+
* @param {string} property
|
|
135
|
+
* @returns {Map<any,any>}
|
|
136
|
+
*/
|
|
137
|
+
mapFromDirections(directions, property) {
|
|
138
|
+
return new AggregatedMap(
|
|
139
|
+
[...this.walkDirections(directions)].map(node => node[property])
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
|
|
130
143
|
/**
|
|
131
144
|
* Deliver union set of all property values.
|
|
132
145
|
* @param {string[]} directions
|
|
@@ -142,6 +155,11 @@ export class Base {
|
|
|
142
155
|
return collected;
|
|
143
156
|
}
|
|
144
157
|
|
|
158
|
+
/*get this()
|
|
159
|
+
{
|
|
160
|
+
return [this];
|
|
161
|
+
}*/
|
|
162
|
+
|
|
145
163
|
/**
|
|
146
164
|
* Walk the object graph in some directions and deliver seen nodes.
|
|
147
165
|
* @param {string[]} directions
|
|
@@ -168,10 +186,12 @@ export class Base {
|
|
|
168
186
|
if (value) {
|
|
169
187
|
if (value[Symbol.iterator]) {
|
|
170
188
|
for (const node of value) {
|
|
171
|
-
yield
|
|
189
|
+
yield node;
|
|
190
|
+
yield* node._walkDirections(directions, false, seen);
|
|
172
191
|
}
|
|
173
192
|
} else {
|
|
174
|
-
yield
|
|
193
|
+
yield value;
|
|
194
|
+
yield* value._walkDirections(directions, false, seen);
|
|
175
195
|
}
|
|
176
196
|
}
|
|
177
197
|
}
|
|
@@ -329,11 +349,6 @@ export class Base {
|
|
|
329
349
|
return this.owner?.services || [];
|
|
330
350
|
}
|
|
331
351
|
|
|
332
|
-
// TODO get rid of
|
|
333
|
-
get aggregatedServices() {
|
|
334
|
-
return this.services;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
352
|
set directory(directory) {
|
|
338
353
|
this._directory = directory;
|
|
339
354
|
}
|
package/src/cluster.mjs
CHANGED
package/src/host.mjs
CHANGED
|
@@ -113,6 +113,21 @@ export class Host extends ServiceOwner {
|
|
|
113
113
|
super.materializeExtends();
|
|
114
114
|
|
|
115
115
|
for (const host of this.walkDirections(["extends"])) {
|
|
116
|
+
for (const [name, service] of host.services) {
|
|
117
|
+
const present = this._services.get(name);
|
|
118
|
+
if (present) {
|
|
119
|
+
/* console.log(
|
|
120
|
+
"LINK",
|
|
121
|
+
present.fullName,
|
|
122
|
+
service.fullName,
|
|
123
|
+
present.extends
|
|
124
|
+
);*/
|
|
125
|
+
present.extends.add(service);
|
|
126
|
+
} else {
|
|
127
|
+
this._services.set(name, service.forOwner(this));
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
116
131
|
for (const [name, ni] of host.networkInterfaces) {
|
|
117
132
|
const present = this._networkInterfaces.get(name);
|
|
118
133
|
|
|
@@ -194,7 +194,7 @@ export class InitializationContext {
|
|
|
194
194
|
this._read(object, data, type);
|
|
195
195
|
|
|
196
196
|
if (data.extends) {
|
|
197
|
-
|
|
197
|
+
console.log("EXTENDS", type.name, object.fullName); // data.extends);
|
|
198
198
|
object.materializeExtends();
|
|
199
199
|
}
|
|
200
200
|
}
|
|
@@ -237,6 +237,10 @@ export class InitializationContext {
|
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
239
|
this.instantiateAndAssign(object, name, attribute, value);
|
|
240
|
+
|
|
241
|
+
/*if (name === "alias" && value) {
|
|
242
|
+
console.log("READ ALIAS", object.fullName, object.alias, value);
|
|
243
|
+
}*/
|
|
240
244
|
}
|
|
241
245
|
}
|
|
242
246
|
}
|
|
@@ -265,10 +269,6 @@ export class InitializationContext {
|
|
|
265
269
|
const object = this.typeFactory(type, owner, data);
|
|
266
270
|
this.root.addTypeObject(type.clazz.typeName, name, object);
|
|
267
271
|
|
|
268
|
-
/*if(object.name === undefined || object.name.length === 0) {
|
|
269
|
-
throw "NO name";
|
|
270
|
-
}*/
|
|
271
|
-
|
|
272
272
|
return object;
|
|
273
273
|
}
|
|
274
274
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
|
+
import { AggregatedMap } from "aggregated-map";
|
|
2
3
|
import { writeLines, sectionLines } from "../utils.mjs";
|
|
3
4
|
import { NetworkAddress, Host, cidrAddresses } from "pmcf";
|
|
4
5
|
import { ServiceOwner } from "../service-owner.mjs";
|
|
@@ -23,10 +24,9 @@ export class SkeletonNetworkInterface extends ServiceOwner {
|
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
get
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
: this.services;
|
|
27
|
+
get services()
|
|
28
|
+
{
|
|
29
|
+
return new AggregatedMap([super.services, this.owner.services]);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
get hosts() {
|
package/src/owner.mjs
CHANGED
package/src/service-owner.mjs
CHANGED
|
@@ -1,20 +1,26 @@
|
|
|
1
1
|
import { Base, Service } from "pmcf";
|
|
2
2
|
|
|
3
3
|
export class ServiceOwner extends Base {
|
|
4
|
-
|
|
4
|
+
_services = new Map();
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
set services(service) {
|
|
7
|
+
this._services.set(service.name, service);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
get services() {
|
|
11
|
+
return this.mapFromDirections(["this", "extends"], "_services");
|
|
9
12
|
}
|
|
10
13
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
addObject(object)
|
|
15
|
+
{
|
|
16
|
+
if(object instanceof Service) {
|
|
17
|
+
this._services.set(object.name, object);
|
|
14
18
|
}
|
|
19
|
+
|
|
20
|
+
super.addObject(object);
|
|
15
21
|
}
|
|
16
22
|
|
|
17
|
-
|
|
23
|
+
_materializeExtends() {
|
|
18
24
|
super.materializeExtends();
|
|
19
25
|
|
|
20
26
|
for (const serviceOwner of this.walkDirections(["extends"])) {
|
|
@@ -24,27 +30,25 @@ export class ServiceOwner extends Base {
|
|
|
24
30
|
serviceOwner.fullName
|
|
25
31
|
);*/
|
|
26
32
|
|
|
27
|
-
for (const service of serviceOwner.services) {
|
|
28
|
-
const present = this.services.
|
|
33
|
+
for (const service of serviceOwner.services.values()) {
|
|
34
|
+
const present = this.services.get(service.name);
|
|
29
35
|
|
|
30
36
|
if (present) {
|
|
31
37
|
//console.log("LINK SERVICE", this.fullName, present.fullName, service.fullName);
|
|
32
38
|
present.extends.add(service);
|
|
33
39
|
} else {
|
|
34
40
|
//console.log("ADD SERVICE", this.fullName, service.fullName);
|
|
35
|
-
|
|
41
|
+
|
|
42
|
+
const s = service.forOwner(this);
|
|
43
|
+
this._services.set(s.name, s);
|
|
36
44
|
}
|
|
37
45
|
}
|
|
38
|
-
|
|
39
|
-
/*for (const service of this.services) {
|
|
40
|
-
service.materializeExtends();
|
|
41
|
-
}*/
|
|
42
46
|
}
|
|
43
47
|
}
|
|
44
48
|
|
|
45
49
|
_traverse(...args) {
|
|
46
50
|
if (super._traverse(...args)) {
|
|
47
|
-
for (const service of this.
|
|
51
|
+
for (const service of this._services.values()) {
|
|
48
52
|
service._traverse(...args);
|
|
49
53
|
}
|
|
50
54
|
|
|
@@ -55,7 +59,7 @@ export class ServiceOwner extends Base {
|
|
|
55
59
|
|
|
56
60
|
typeNamed(typeName, name) {
|
|
57
61
|
if (typeName === "service") {
|
|
58
|
-
const service = this.services.
|
|
62
|
+
const service = this.services.get(name);
|
|
59
63
|
if (service) {
|
|
60
64
|
return service;
|
|
61
65
|
}
|
|
@@ -73,6 +77,6 @@ export class ServiceOwner extends Base {
|
|
|
73
77
|
* @returns {Service|undefined}
|
|
74
78
|
*/
|
|
75
79
|
named(name) {
|
|
76
|
-
return this.services.
|
|
80
|
+
return this.services.get(name);
|
|
77
81
|
}
|
|
78
82
|
}
|