pmcf 4.25.25 → 4.27.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 +2 -2
- package/src/base.mjs +68 -55
- package/src/endpoint.mjs +21 -10
- package/src/host.mjs +1 -1
- package/src/initialization-context.mjs +3 -2
- package/src/location.mjs +1 -2
- package/src/network.mjs +3 -2
- package/src/service.mjs +3 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmcf",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.27.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"content-entry-transform": "^1.6.9",
|
|
55
55
|
"ip-utilties": "^3.0.4",
|
|
56
56
|
"npm-pkgbuild": "^20.7.3",
|
|
57
|
-
"pacc": "^9.
|
|
57
|
+
"pacc": "^9.3.1",
|
|
58
58
|
"package-directory": "^8.2.0"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
package/src/base.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
2
|
import { stat } from "node:fs/promises";
|
|
3
|
+
import { AggregatedMap } from "aggregated-map";
|
|
3
4
|
import { allOutputs } from "npm-pkgbuild";
|
|
4
5
|
import {
|
|
5
6
|
createExpressionTransformer,
|
|
@@ -14,7 +15,7 @@ import {
|
|
|
14
15
|
expand,
|
|
15
16
|
toExternal,
|
|
16
17
|
filterPublic,
|
|
17
|
-
|
|
18
|
+
extendingAttributeIterator,
|
|
18
19
|
default_attribute,
|
|
19
20
|
name_attribute_writable,
|
|
20
21
|
string_attribute,
|
|
@@ -24,7 +25,6 @@ import {
|
|
|
24
25
|
description_attribute_writable,
|
|
25
26
|
boolean_attribute_writable
|
|
26
27
|
} from "pacc";
|
|
27
|
-
import { AggregatedMap } from "aggregated-map";
|
|
28
28
|
import { union } from "./utils.mjs";
|
|
29
29
|
|
|
30
30
|
/**
|
|
@@ -44,7 +44,7 @@ export class Base {
|
|
|
44
44
|
packaging: string_attribute_writable,
|
|
45
45
|
disabled: boolean_attribute_writable,
|
|
46
46
|
tags: string_set_attribute_writable,
|
|
47
|
-
owner: { ...default_attribute, type: "base" },
|
|
47
|
+
owner: { ...default_attribute, type: "base", owner: false },
|
|
48
48
|
type: string_attribute
|
|
49
49
|
};
|
|
50
50
|
|
|
@@ -149,6 +149,23 @@ export class Base {
|
|
|
149
149
|
return collected;
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
+
get children() {
|
|
153
|
+
const all = [];
|
|
154
|
+
|
|
155
|
+
for (const [path, attribute] of extendingAttributeIterator(
|
|
156
|
+
this.constructor,
|
|
157
|
+
(name, attribute) => attribute.owner && !attribute.type.primitive
|
|
158
|
+
)) {
|
|
159
|
+
if (attribute.collection) {
|
|
160
|
+
all.push(...this[path].values());
|
|
161
|
+
} else {
|
|
162
|
+
all.push(this[path]);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return all;
|
|
167
|
+
}
|
|
168
|
+
|
|
152
169
|
/**
|
|
153
170
|
* Walk the object graph in some directions and deliver seen nodes.
|
|
154
171
|
* @param {string[]} directions
|
|
@@ -229,14 +246,15 @@ export class Base {
|
|
|
229
246
|
* @return {Iterable<[string,any]>} values
|
|
230
247
|
*/
|
|
231
248
|
*attributeIterator(filter) {
|
|
232
|
-
for (
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
249
|
+
for (const [path, def] of extendingAttributeIterator(
|
|
250
|
+
this.constructor,
|
|
251
|
+
filter
|
|
252
|
+
)) {
|
|
253
|
+
const name = path.join(".");
|
|
254
|
+
const value = this.attribute(name);
|
|
236
255
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
}
|
|
256
|
+
if (value !== undefined) {
|
|
257
|
+
yield [def.externalName ?? name, toExternal(value, def), path, def];
|
|
240
258
|
}
|
|
241
259
|
}
|
|
242
260
|
}
|
|
@@ -571,61 +589,56 @@ export function extractFrom(object, type = object?.constructor) {
|
|
|
571
589
|
|
|
572
590
|
const json = {};
|
|
573
591
|
|
|
574
|
-
for (
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
filterPublic
|
|
578
|
-
)) {
|
|
579
|
-
const name = path.join(".");
|
|
580
|
-
let value = object[name];
|
|
592
|
+
for (const [path, def] of extendingAttributeIterator(type, filterPublic)) {
|
|
593
|
+
const name = path.join(".");
|
|
594
|
+
let value = object[name];
|
|
581
595
|
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
596
|
+
switch (typeof value) {
|
|
597
|
+
case "function":
|
|
598
|
+
{
|
|
599
|
+
value = object[name]();
|
|
586
600
|
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
601
|
+
if (typeof value?.next === "function") {
|
|
602
|
+
value = [...value];
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
value = extractFrom(value, def.type);
|
|
606
|
+
if (value !== undefined) {
|
|
607
|
+
json[name] = value;
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
break;
|
|
611
|
+
case "object":
|
|
612
|
+
if (value instanceof Base) {
|
|
613
|
+
json[name] = { type: value.typeName };
|
|
614
|
+
if (value.name) {
|
|
615
|
+
json[name].name = value.name;
|
|
616
|
+
}
|
|
617
|
+
} else {
|
|
618
|
+
if (typeof value[Symbol.iterator] === "function") {
|
|
619
|
+
value = extractFrom(value);
|
|
590
620
|
|
|
591
|
-
value = extractFrom(value, def.type);
|
|
592
621
|
if (value !== undefined) {
|
|
593
622
|
json[name] = value;
|
|
594
623
|
}
|
|
595
|
-
}
|
|
596
|
-
break;
|
|
597
|
-
case "object":
|
|
598
|
-
if (value instanceof Base) {
|
|
599
|
-
json[name] = { type: value.typeName };
|
|
600
|
-
if (value.name) {
|
|
601
|
-
json[name].name = value.name;
|
|
602
|
-
}
|
|
603
624
|
} else {
|
|
604
|
-
|
|
605
|
-
value
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
Object.entries(value).map(([k, v]) => [
|
|
613
|
-
k,
|
|
614
|
-
v // extractFrom(v, def.type)
|
|
615
|
-
])
|
|
616
|
-
);
|
|
617
|
-
if (Object.keys(resultObject).length > 0) {
|
|
618
|
-
json[name] = resultObject;
|
|
619
|
-
}
|
|
625
|
+
const resultObject = Object.fromEntries(
|
|
626
|
+
Object.entries(value).map(([k, v]) => [
|
|
627
|
+
k,
|
|
628
|
+
v // extractFrom(v, def.type)
|
|
629
|
+
])
|
|
630
|
+
);
|
|
631
|
+
if (Object.keys(resultObject).length > 0) {
|
|
632
|
+
json[name] = resultObject;
|
|
620
633
|
}
|
|
621
634
|
}
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
635
|
+
}
|
|
636
|
+
break;
|
|
637
|
+
case "undefined":
|
|
638
|
+
break;
|
|
625
639
|
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
}
|
|
640
|
+
default:
|
|
641
|
+
json[name] = value;
|
|
629
642
|
}
|
|
630
643
|
}
|
|
631
644
|
|
package/src/endpoint.mjs
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
|
+
import { addType } from "pacc";
|
|
2
|
+
import { endpointAttributes, Service } from "./service.mjs";
|
|
3
|
+
|
|
1
4
|
class BaseEndpoint {
|
|
5
|
+
static name = "endpoint";
|
|
6
|
+
static priority = 1.1;
|
|
7
|
+
static owners = [Service, "network_interface"];
|
|
8
|
+
static specializations = {};
|
|
9
|
+
static key = "type";
|
|
10
|
+
attributes = endpointAttributes;
|
|
11
|
+
|
|
12
|
+
static {
|
|
13
|
+
addType(this);
|
|
14
|
+
}
|
|
15
|
+
|
|
2
16
|
_type;
|
|
3
17
|
|
|
4
18
|
constructor(service, data) {
|
|
@@ -13,8 +27,7 @@ class BaseEndpoint {
|
|
|
13
27
|
return this._type?.name ?? this.service.type;
|
|
14
28
|
}
|
|
15
29
|
|
|
16
|
-
get priority()
|
|
17
|
-
{
|
|
30
|
+
get priority() {
|
|
18
31
|
return this.service.priority;
|
|
19
32
|
}
|
|
20
33
|
|
|
@@ -115,12 +128,11 @@ export class DomainNameEndpoint extends PortEndpoint {
|
|
|
115
128
|
* Endpoint based on http
|
|
116
129
|
*/
|
|
117
130
|
export class HTTPEndpoint extends BaseEndpoint {
|
|
118
|
-
|
|
119
131
|
/**
|
|
120
|
-
*
|
|
121
|
-
* @param {Service} service
|
|
122
|
-
* @param {*} address
|
|
123
|
-
* @param {object} data
|
|
132
|
+
*
|
|
133
|
+
* @param {Service} service
|
|
134
|
+
* @param {*} address
|
|
135
|
+
* @param {object} data
|
|
124
136
|
* @param {number} data.port
|
|
125
137
|
* @param {string} data.pathname
|
|
126
138
|
*/
|
|
@@ -197,9 +209,8 @@ export class UnixEndpoint extends BaseEndpoint {
|
|
|
197
209
|
return this.path;
|
|
198
210
|
}
|
|
199
211
|
|
|
200
|
-
get url()
|
|
201
|
-
|
|
202
|
-
if(this.scheme) {
|
|
212
|
+
get url() {
|
|
213
|
+
if (this.scheme) {
|
|
203
214
|
return `${this.scheme}://${this.path}`;
|
|
204
215
|
}
|
|
205
216
|
}
|
package/src/host.mjs
CHANGED
|
@@ -82,7 +82,7 @@ export class Host extends ServiceOwner {
|
|
|
82
82
|
replaces: string_set_attribute_writable,
|
|
83
83
|
depends: string_set_attribute_writable,
|
|
84
84
|
provides: string_set_attribute_writable,
|
|
85
|
-
extends: { ...default_attribute_writable, type: "host", collection: true },
|
|
85
|
+
extends: { ...default_attribute_writable, type: "host", collection: true, owner: false },
|
|
86
86
|
model: string_attribute,
|
|
87
87
|
isModel: boolean_attribute_false
|
|
88
88
|
};
|
|
@@ -259,9 +259,10 @@ export class InitializationContext {
|
|
|
259
259
|
data.name = name;
|
|
260
260
|
}
|
|
261
261
|
|
|
262
|
-
//console.log("LOAD", [name, owner.fullName, data.name]);
|
|
263
|
-
|
|
264
262
|
const object = this.typeFactory(type, owner, data);
|
|
263
|
+
|
|
264
|
+
//console.log("LOAD", [name, type.name, owner.fullName, data.name, object.fullName]);
|
|
265
|
+
|
|
265
266
|
this.root.addTypeObject(type.name, name, object);
|
|
266
267
|
|
|
267
268
|
return object;
|
package/src/location.mjs
CHANGED
|
@@ -6,12 +6,11 @@ import { loadHooks } from "./hooks.mjs";
|
|
|
6
6
|
export class Location extends Owner {
|
|
7
7
|
static name = "location";
|
|
8
8
|
static priority = 2;
|
|
9
|
-
static owners = [Owner,
|
|
9
|
+
static owners = [Owner, Location, "root"];
|
|
10
10
|
static extends = Owner;
|
|
11
11
|
static key = "name";
|
|
12
12
|
static attributes = {};
|
|
13
13
|
|
|
14
|
-
|
|
15
14
|
static {
|
|
16
15
|
addType(this);
|
|
17
16
|
}
|
package/src/network.mjs
CHANGED
|
@@ -14,9 +14,10 @@ export class Network extends Owner {
|
|
|
14
14
|
bridge: {
|
|
15
15
|
...default_attribute_writable,
|
|
16
16
|
type: "network",
|
|
17
|
-
collection: true
|
|
17
|
+
collection: true,
|
|
18
|
+
owner: false
|
|
18
19
|
},
|
|
19
|
-
gateway: { ...default_attribute_writable, type: "host" }
|
|
20
|
+
gateway: { ...default_attribute_writable, type: "host", owner: false }
|
|
20
21
|
};
|
|
21
22
|
|
|
22
23
|
|
package/src/service.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
string_attribute_writable,
|
|
3
|
-
string_set_attribute,
|
|
4
3
|
number_attribute_writable,
|
|
5
|
-
|
|
4
|
+
string_set_attribute,
|
|
6
5
|
default_attribute_writable,
|
|
6
|
+
boolean_attribute_false,
|
|
7
7
|
addType
|
|
8
8
|
} from "pacc";
|
|
9
9
|
import {
|
|
@@ -40,15 +40,6 @@ export const endpointAttributes = {
|
|
|
40
40
|
tls: boolean_attribute_false
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
export const EndpointTypeDefinition = {
|
|
44
|
-
name: "endpoint",
|
|
45
|
-
priority: 1.1,
|
|
46
|
-
owners: ["service", "network_interface"],
|
|
47
|
-
specializations: {},
|
|
48
|
-
key: "type",
|
|
49
|
-
attributes: endpointAttributes
|
|
50
|
-
};
|
|
51
|
-
|
|
52
43
|
export class Service extends Base {
|
|
53
44
|
static name = "service";
|
|
54
45
|
static priority = 1.1;
|
|
@@ -70,7 +61,7 @@ export class Service extends Base {
|
|
|
70
61
|
static attributes = {
|
|
71
62
|
...networkAddressAttributes,
|
|
72
63
|
...endpointAttributes,
|
|
73
|
-
extends: { ...default_attribute_writable, type: Service, collection: true },
|
|
64
|
+
extends: { ...default_attribute_writable, type: Service, collection: true, owner: false },
|
|
74
65
|
alias: string_attribute_writable,
|
|
75
66
|
weight: { ...number_attribute_writable /*default: 1*/ },
|
|
76
67
|
systemdService: string_attribute_writable
|