pmcf 4.19.2 → 4.21.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 +93 -72
- package/package.json +19 -19
- package/src/base.mjs +34 -243
- package/src/cli.mjs +4 -4
- package/src/cluster.mjs +13 -11
- package/src/extra-source-service.mjs +7 -10
- package/src/host.mjs +44 -50
- package/src/initialization-context.mjs +324 -0
- package/src/location.mjs +4 -14
- package/src/module.mjs +1 -0
- package/src/network-interfaces/ethernet.mjs +3 -5
- package/src/network-interfaces/loopback.mjs +2 -4
- package/src/network-interfaces/network-interface.mjs +3 -5
- package/src/network-interfaces/skeleton.mjs +9 -3
- package/src/network-interfaces/tun.mjs +2 -4
- package/src/network-interfaces/wireguard.mjs +3 -5
- package/src/network-interfaces/wlan.mjs +4 -7
- package/src/network.mjs +10 -8
- package/src/owner.mjs +7 -31
- package/src/root.mjs +4 -73
- package/src/service-owner.mjs +20 -19
- package/src/service.mjs +13 -18
- package/src/services/alpm.mjs +4 -9
- package/src/services/bind.mjs +424 -388
- package/src/services/chrony.mjs +3 -5
- package/src/services/headscale.mjs +2 -4
- package/src/services/influxdb.mjs +2 -4
- package/src/services/kea.mjs +6 -10
- package/src/services/mosquitto.mjs +2 -4
- package/src/services/openldap.mjs +2 -4
- package/src/services/postfix.mjs +2 -4
- package/src/services/systemd-journal-remote.mjs +2 -4
- package/src/services/systemd-journal-upload.mjs +9 -10
- package/src/services/systemd-journald.mjs +2 -4
- package/src/services/systemd-resolved.mjs +42 -42
- package/src/services/systemd-timesyncd.mjs +9 -13
- package/src/services/tailscale.mjs +5 -2
- package/src/subnet.mjs +9 -5
- package/types/base.d.mts +0 -180
- package/types/cli.d.mts +0 -10
- package/types/cluster.d.mts +0 -507
- package/types/dns-utils.d.mts +0 -14
- package/types/endpoint.d.mts +0 -79
- package/types/extra-source-service.d.mts +0 -1033
- package/types/hooks.d.mts +0 -2
- package/types/host-utils.d.mts +0 -1
- package/types/host.d.mts +0 -285
- package/types/location.d.mts +0 -379
- package/types/module.d.mts +0 -36
- package/types/network-address.d.mts +0 -41
- package/types/network-interfaces/ethernet.d.mts +0 -1189
- package/types/network-interfaces/loopback.d.mts +0 -1140
- package/types/network-interfaces/network-interface.d.mts +0 -1158
- package/types/network-interfaces/skeleton.d.mts +0 -30
- package/types/network-interfaces/tun.d.mts +0 -1131
- package/types/network-interfaces/wireguard.d.mts +0 -1131
- package/types/network-interfaces/wlan.d.mts +0 -1734
- package/types/network-support.d.mts +0 -193
- package/types/network.d.mts +0 -702
- package/types/owner.d.mts +0 -235
- package/types/root.d.mts +0 -10
- package/types/service-owner.d.mts +0 -14
- package/types/service-types.d.mts +0 -246
- package/types/service.d.mts +0 -689
- package/types/services/alpm.d.mts +0 -805
- package/types/services/bind.d.mts +0 -1574
- package/types/services/chrony.d.mts +0 -1310
- package/types/services/headscale.d.mts +0 -801
- package/types/services/influxdb.d.mts +0 -812
- package/types/services/kea.d.mts +0 -945
- package/types/services/mosquitto.d.mts +0 -876
- package/types/services/openldap.d.mts +0 -793
- package/types/services/postfix.d.mts +0 -784
- package/types/services/systemd-journal-remote.d.mts +0 -1030
- package/types/services/systemd-journal-upload.d.mts +0 -932
- package/types/services/systemd-journald.d.mts +0 -1317
- package/types/services/systemd-resolved.d.mts +0 -1644
- package/types/services/systemd-timesyncd.d.mts +0 -1459
- package/types/services/tailscale.d.mts +0 -781
- package/types/subnet.d.mts +0 -57
- package/types/utils.d.mts +0 -37
package/README.md
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
[](https://www.npmjs.com/package/pmcf)
|
|
2
2
|
[](https://spdx.org/licenses/0BSD.html)
|
|
3
|
-
[](https://typescriptlang.org)
|
|
4
3
|
[](https://bundlejs.com/?q=pmcf)
|
|
5
4
|
[](https://npmjs.org/package/pmcf)
|
|
6
5
|
[](https://github.com/arlac77/pmcf/issues)
|
|
@@ -27,12 +26,14 @@ generates config packages for:
|
|
|
27
26
|
* networkd
|
|
28
27
|
* timesyncd
|
|
29
28
|
* resolverd
|
|
29
|
+
* journald
|
|
30
30
|
* kea
|
|
31
31
|
* bind
|
|
32
32
|
* mosquitto
|
|
33
33
|
* influxdb
|
|
34
34
|
* iwd
|
|
35
35
|
* chrony
|
|
36
|
+
* openldap
|
|
36
37
|
|
|
37
38
|
# API
|
|
38
39
|
|
|
@@ -40,69 +41,77 @@ generates config packages for:
|
|
|
40
41
|
|
|
41
42
|
### Table of Contents
|
|
42
43
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
44
|
+
- [pmcf](#pmcf)
|
|
45
|
+
- [Poor mans configuration management](#poor-mans-configuration-management)
|
|
46
|
+
- [API](#api)
|
|
47
|
+
- [Table of Contents](#table-of-contents)
|
|
48
|
+
- [Base](#base)
|
|
49
|
+
- [Parameters](#parameters)
|
|
50
|
+
- [walkDirections](#walkdirections)
|
|
51
|
+
- [Parameters](#parameters-1)
|
|
52
|
+
- [extendedAttribute](#extendedattribute)
|
|
53
|
+
- [Parameters](#parameters-2)
|
|
54
|
+
- [propertyIterator](#propertyiterator)
|
|
55
|
+
- [Parameters](#parameters-3)
|
|
56
|
+
- [getProperties](#getproperties)
|
|
57
|
+
- [Parameters](#parameters-4)
|
|
58
|
+
- [priority](#priority)
|
|
59
|
+
- [expression](#expression)
|
|
60
|
+
- [Parameters](#parameters-5)
|
|
61
|
+
- [templateContent](#templatecontent)
|
|
62
|
+
- [Parameters](#parameters-6)
|
|
63
|
+
- [isTemplate](#istemplate)
|
|
64
|
+
- [property](#property)
|
|
65
|
+
- [Parameters](#parameters-7)
|
|
66
|
+
- [expand](#expand)
|
|
67
|
+
- [Parameters](#parameters-8)
|
|
68
|
+
- [PortEndpoint](#portendpoint)
|
|
69
|
+
- [Parameters](#parameters-9)
|
|
70
|
+
- [port](#port)
|
|
71
|
+
- [socketAddress](#socketaddress)
|
|
72
|
+
- [HTTPEndpoint](#httpendpoint)
|
|
73
|
+
- [Parameters](#parameters-10)
|
|
74
|
+
- [port](#port-1)
|
|
75
|
+
- [id](#id)
|
|
76
|
+
- [SkeletonNetworkInterface](#skeletonnetworkinterface)
|
|
77
|
+
- [networkAddresses](#networkaddresses)
|
|
78
|
+
- [Parameters](#parameters-11)
|
|
79
|
+
- [InitializationContext](#initializationcontext)
|
|
80
|
+
- [Parameters](#parameters-12)
|
|
81
|
+
- [SystemdJournalRemoteService](#systemdjournalremoteservice)
|
|
82
|
+
- [Properties](#properties)
|
|
83
|
+
- [systemdConfigs](#systemdconfigs)
|
|
84
|
+
- [Parameters](#parameters-13)
|
|
85
|
+
- [SystemdJournalUploadService](#systemdjournaluploadservice)
|
|
86
|
+
- [Properties](#properties-1)
|
|
87
|
+
- [systemdConfigs](#systemdconfigs-1)
|
|
88
|
+
- [Parameters](#parameters-14)
|
|
89
|
+
- [NetworkAddress](#networkaddress)
|
|
90
|
+
- [Parameters](#parameters-15)
|
|
91
|
+
- [subnet](#subnet)
|
|
92
|
+
- [networkInterface](#networkinterface)
|
|
93
|
+
- [address](#address)
|
|
94
|
+
- [addresses](#addresses)
|
|
95
|
+
- [Parameters](#parameters-16)
|
|
96
|
+
- [cidrAddresses](#cidraddresses)
|
|
97
|
+
- [Parameters](#parameters-17)
|
|
98
|
+
- [secretName](#secretname)
|
|
99
|
+
- [isTemplate](#istemplate-1)
|
|
100
|
+
- [named](#named)
|
|
101
|
+
- [Parameters](#parameters-18)
|
|
102
|
+
- [serviceEndpoints](#serviceendpoints)
|
|
103
|
+
- [Parameters](#parameters-19)
|
|
104
|
+
- [domainName](#domainname)
|
|
105
|
+
- [Parameters](#parameters-20)
|
|
106
|
+
- [domainFromDominName](#domainfromdominname)
|
|
107
|
+
- [Parameters](#parameters-21)
|
|
108
|
+
- [sectionLines](#sectionlines)
|
|
109
|
+
- [Parameters](#parameters-22)
|
|
110
|
+
- [asArray](#asarray)
|
|
111
|
+
- [Parameters](#parameters-23)
|
|
112
|
+
- [asIterator](#asiterator)
|
|
113
|
+
- [Parameters](#parameters-24)
|
|
114
|
+
- [install](#install)
|
|
106
115
|
|
|
107
116
|
## Base
|
|
108
117
|
|
|
@@ -165,14 +174,6 @@ Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/G
|
|
|
165
174
|
|
|
166
175
|
Returns **any** 
|
|
167
176
|
|
|
168
|
-
### findService
|
|
169
|
-
|
|
170
|
-
#### Parameters
|
|
171
|
-
|
|
172
|
-
* `filter` **any** 
|
|
173
|
-
|
|
174
|
-
Returns **any** service with the highest priority
|
|
175
|
-
|
|
176
177
|
### templateContent
|
|
177
178
|
|
|
178
179
|
#### Parameters
|
|
@@ -182,6 +183,10 @@ Returns **any** service with the highest priority
|
|
|
182
183
|
|
|
183
184
|
Returns **AsyncIterable\<ContentProvider>** 
|
|
184
185
|
|
|
186
|
+
### isTemplate
|
|
187
|
+
|
|
188
|
+
Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** 
|
|
189
|
+
|
|
185
190
|
### property
|
|
186
191
|
|
|
187
192
|
#### Parameters
|
|
@@ -233,6 +238,10 @@ Endpoint based on http
|
|
|
233
238
|
|
|
234
239
|
Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** 
|
|
235
240
|
|
|
241
|
+
## id
|
|
242
|
+
|
|
243
|
+
Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** 
|
|
244
|
+
|
|
236
245
|
## SkeletonNetworkInterface
|
|
237
246
|
|
|
238
247
|
**Extends ServiceOwner**
|
|
@@ -245,6 +254,14 @@ Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/G
|
|
|
245
254
|
|
|
246
255
|
Returns **Iterable<[NetworkAddress](#networkaddress)>** 
|
|
247
256
|
|
|
257
|
+
## InitializationContext
|
|
258
|
+
|
|
259
|
+
Keeps track of all in flight object creations and loose ends during config initialization.
|
|
260
|
+
|
|
261
|
+
### Parameters
|
|
262
|
+
|
|
263
|
+
* `directory` (optional, default `"/"`)
|
|
264
|
+
|
|
248
265
|
## SystemdJournalRemoteService
|
|
249
266
|
|
|
250
267
|
**Extends Service**
|
|
@@ -320,6 +337,10 @@ Returns **Iterable<[string](https://developer.mozilla.org/docs/Web/JavaScript/Re
|
|
|
320
337
|
|
|
321
338
|
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)>** 
|
|
322
339
|
|
|
340
|
+
## secretName
|
|
341
|
+
|
|
342
|
+
Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** 
|
|
343
|
+
|
|
323
344
|
## isTemplate
|
|
324
345
|
|
|
325
346
|
Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** 
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmcf",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.21.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"packageManager": "npm@11.
|
|
7
|
+
"packageManager": "npm@11.13.0",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
10
|
"default": "./src/module.mjs"
|
|
@@ -42,33 +42,34 @@
|
|
|
42
42
|
"pmcf-package": "./bin/pmcf-package"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
|
-
"prepare": "node --run prepare:typescript",
|
|
46
|
-
"prepare:typescript": "tsc --allowJs --declaration --emitDeclarationOnly --declarationDir types --resolveJsonModule --target esnext -m esnext --module nodenext --moduleResolution nodenext --rootDir src ./src**/*.mjs",
|
|
47
45
|
"test": "node --run test:ava",
|
|
48
46
|
"test:ava": "ava --timeout 4m tests/*-ava.mjs tests/*-ava-node.mjs",
|
|
49
47
|
"cover": "c8 -x 'tests/**/*' --temp-directory build/tmp ava --timeout 4m tests/*-ava.mjs tests/*-ava-node.mjs && c8 report -r lcov -o build/coverage --temp-directory build/tmp",
|
|
50
48
|
"docs": "documentation readme --section=API ./src**/*.mjs",
|
|
51
|
-
"lint": "node --run lint:docs
|
|
52
|
-
"lint:docs": "documentation lint ./src**/*.mjs"
|
|
53
|
-
"lint:typescript": "tsc --allowJs --checkJs --noEmit --resolveJsonModule --target esnext -m esnext --module nodenext --moduleResolution nodenext ./src**/*.mjs"
|
|
49
|
+
"lint": "node --run lint:docs",
|
|
50
|
+
"lint:docs": "documentation lint ./src**/*.mjs"
|
|
54
51
|
},
|
|
55
52
|
"dependencies": {
|
|
56
|
-
"content-entry-transform": "^1.6.
|
|
57
|
-
"ip-utilties": "^3.0.
|
|
58
|
-
"npm-pkgbuild": "^20.6.
|
|
59
|
-
"pacc": "^9.
|
|
53
|
+
"content-entry-transform": "^1.6.9",
|
|
54
|
+
"ip-utilties": "^3.0.4",
|
|
55
|
+
"npm-pkgbuild": "^20.6.4",
|
|
56
|
+
"pacc": "^9.2.9",
|
|
60
57
|
"package-directory": "^8.2.0"
|
|
61
58
|
},
|
|
62
59
|
"devDependencies": {
|
|
63
|
-
"@types/node": "^25.
|
|
64
|
-
"ava": "^
|
|
65
|
-
"c8": "^
|
|
60
|
+
"@types/node": "^25.9.1",
|
|
61
|
+
"ava": "^8.0.1",
|
|
62
|
+
"c8": "^11.0.0",
|
|
66
63
|
"documentation": "^14.0.3",
|
|
67
|
-
"semantic-release": "^25.0.3"
|
|
68
|
-
|
|
64
|
+
"semantic-release": "^25.0.3"
|
|
65
|
+
},
|
|
66
|
+
"overrides": {
|
|
67
|
+
"c8": {
|
|
68
|
+
"yargs": "^18.0.0"
|
|
69
|
+
}
|
|
69
70
|
},
|
|
70
71
|
"engines": {
|
|
71
|
-
"node": ">=
|
|
72
|
+
"node": ">=26.2.0"
|
|
72
73
|
},
|
|
73
74
|
"repository": {
|
|
74
75
|
"type": "git",
|
|
@@ -81,8 +82,7 @@
|
|
|
81
82
|
"template": {
|
|
82
83
|
"inheritFrom": [
|
|
83
84
|
"arlac77/template-arlac77-github",
|
|
84
|
-
"arlac77/template-node-app"
|
|
85
|
-
"arlac77/template-typescript"
|
|
85
|
+
"arlac77/template-node-app"
|
|
86
86
|
]
|
|
87
87
|
}
|
|
88
88
|
}
|
package/src/base.mjs
CHANGED
|
@@ -8,8 +8,6 @@ import {
|
|
|
8
8
|
import { FileContentProvider } from "npm-pkgbuild";
|
|
9
9
|
import {
|
|
10
10
|
getAttribute,
|
|
11
|
-
toInternal,
|
|
12
|
-
typeFactory,
|
|
13
11
|
addType,
|
|
14
12
|
parse,
|
|
15
13
|
globals,
|
|
@@ -26,7 +24,7 @@ import {
|
|
|
26
24
|
description_attribute_writable,
|
|
27
25
|
boolean_attribute_writable
|
|
28
26
|
} from "pacc";
|
|
29
|
-
import {
|
|
27
|
+
import { union } from "./utils.mjs";
|
|
30
28
|
|
|
31
29
|
/**
|
|
32
30
|
*
|
|
@@ -36,6 +34,7 @@ import { asArray, union } from "./utils.mjs";
|
|
|
36
34
|
export class Base {
|
|
37
35
|
static name = "base";
|
|
38
36
|
static key = "name";
|
|
37
|
+
static priority = 0;
|
|
39
38
|
static attributes = {
|
|
40
39
|
owner: { ...default_attribute, type: "base" },
|
|
41
40
|
type: string_attribute,
|
|
@@ -48,15 +47,7 @@ export class Base {
|
|
|
48
47
|
tags: string_set_attribute_writable
|
|
49
48
|
};
|
|
50
49
|
|
|
51
|
-
|
|
52
|
-
description;
|
|
53
|
-
name;
|
|
54
|
-
extends = [];
|
|
55
|
-
_tags = new Set();
|
|
56
|
-
_packaging = new Set();
|
|
57
|
-
_directory;
|
|
58
|
-
_finalize;
|
|
59
|
-
_properties;
|
|
50
|
+
static typeDefinition = this;
|
|
60
51
|
|
|
61
52
|
static {
|
|
62
53
|
addType(this);
|
|
@@ -66,14 +57,20 @@ export class Base {
|
|
|
66
57
|
return this.typeDefinition.name;
|
|
67
58
|
}
|
|
68
59
|
|
|
69
|
-
static get typeDefinition() {
|
|
70
|
-
return this;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
60
|
static get typeFileName() {
|
|
74
61
|
return this.typeName + ".json";
|
|
75
62
|
}
|
|
76
63
|
|
|
64
|
+
owner;
|
|
65
|
+
description;
|
|
66
|
+
name;
|
|
67
|
+
extends = new Set();
|
|
68
|
+
_tags = new Set();
|
|
69
|
+
_packaging = new Set();
|
|
70
|
+
_directory;
|
|
71
|
+
_finalize;
|
|
72
|
+
_properties = {};
|
|
73
|
+
|
|
77
74
|
/**
|
|
78
75
|
*
|
|
79
76
|
* @param {Base} owner
|
|
@@ -86,8 +83,6 @@ export class Base {
|
|
|
86
83
|
case "string":
|
|
87
84
|
this.name = data;
|
|
88
85
|
break;
|
|
89
|
-
case "object":
|
|
90
|
-
this.read(data, this.constructor);
|
|
91
86
|
}
|
|
92
87
|
}
|
|
93
88
|
|
|
@@ -110,207 +105,7 @@ export class Base {
|
|
|
110
105
|
return this;
|
|
111
106
|
}
|
|
112
107
|
|
|
113
|
-
|
|
114
|
-
if (type.extends) {
|
|
115
|
-
this.read(data, type.extends);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const assign = (name, attribute, value) => {
|
|
119
|
-
value = toInternal(value, attribute);
|
|
120
|
-
value ??= attribute.default;
|
|
121
|
-
|
|
122
|
-
if (value !== undefined) {
|
|
123
|
-
if (attribute.values) {
|
|
124
|
-
if (attribute.values.indexOf(value) < 0) {
|
|
125
|
-
this.error(name, "unknown value", value, attribute.values);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
if (attribute.collection) {
|
|
130
|
-
const current = this[name];
|
|
131
|
-
|
|
132
|
-
switch (typeof current) {
|
|
133
|
-
case "undefined":
|
|
134
|
-
if (attribute.constructor === value.constructor) {
|
|
135
|
-
this[name] = value;
|
|
136
|
-
} else {
|
|
137
|
-
this[name] = asArray(value);
|
|
138
|
-
}
|
|
139
|
-
break;
|
|
140
|
-
case "object":
|
|
141
|
-
if (Array.isArray(current)) {
|
|
142
|
-
if (Array.isArray(value)) {
|
|
143
|
-
current.push(...value);
|
|
144
|
-
} else {
|
|
145
|
-
current.push(value);
|
|
146
|
-
}
|
|
147
|
-
} else {
|
|
148
|
-
if (current instanceof Set) {
|
|
149
|
-
if (value instanceof Set) {
|
|
150
|
-
this[name] = current.union(value);
|
|
151
|
-
} else {
|
|
152
|
-
this[name].add(value);
|
|
153
|
-
}
|
|
154
|
-
} else if (current instanceof Map) {
|
|
155
|
-
const keyName = attribute.type.key;
|
|
156
|
-
if (keyName) {
|
|
157
|
-
current.set(value[keyName], value);
|
|
158
|
-
} else {
|
|
159
|
-
// TODO
|
|
160
|
-
this[name] = value;
|
|
161
|
-
}
|
|
162
|
-
} else {
|
|
163
|
-
const keyName = attribute.type.key;
|
|
164
|
-
this[name][value[keyName]] = value;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
break;
|
|
168
|
-
case "function":
|
|
169
|
-
if (value instanceof Base) {
|
|
170
|
-
this.addObject(value);
|
|
171
|
-
} else {
|
|
172
|
-
this.error("Unknown collection type", name, current);
|
|
173
|
-
}
|
|
174
|
-
break;
|
|
175
|
-
}
|
|
176
|
-
} else {
|
|
177
|
-
this[name] = value;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
const instantiateAndAssign = (name, attribute, value) => {
|
|
183
|
-
if (attribute.type.primitive) {
|
|
184
|
-
assign(name, attribute, value);
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
switch (typeof value) {
|
|
189
|
-
case "undefined":
|
|
190
|
-
return;
|
|
191
|
-
case "function":
|
|
192
|
-
this.error("Invalid value", name, value);
|
|
193
|
-
break;
|
|
194
|
-
|
|
195
|
-
case "boolean":
|
|
196
|
-
case "bigint":
|
|
197
|
-
case "number":
|
|
198
|
-
case "string":
|
|
199
|
-
{
|
|
200
|
-
let object;
|
|
201
|
-
|
|
202
|
-
for (const type of attribute.type.members || [attribute.type]) {
|
|
203
|
-
object = this.typeNamed(type.name, value);
|
|
204
|
-
if (object) {
|
|
205
|
-
break;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
if (object) {
|
|
210
|
-
assign(name, attribute, object);
|
|
211
|
-
} else {
|
|
212
|
-
if (attribute.type.constructWithIdentifierOnly) {
|
|
213
|
-
object = new attribute.type.clazz(
|
|
214
|
-
this.ownerFor(attribute, value),
|
|
215
|
-
value
|
|
216
|
-
);
|
|
217
|
-
object.read(value);
|
|
218
|
-
this.addObject(object);
|
|
219
|
-
} else {
|
|
220
|
-
this.finalize(() => {
|
|
221
|
-
value = this.expand(value);
|
|
222
|
-
|
|
223
|
-
for (const type of attribute.type.members || [
|
|
224
|
-
attribute.type
|
|
225
|
-
]) {
|
|
226
|
-
const object =
|
|
227
|
-
this.typeNamed(type.name, value) ||
|
|
228
|
-
this.owner.typeNamed(type.name, value) ||
|
|
229
|
-
this.root.typeNamed(type.name, value); // TODO
|
|
230
|
-
|
|
231
|
-
if (object) {
|
|
232
|
-
assign(name, attribute, object);
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
this.error(
|
|
238
|
-
`No such object "${value}" (${attribute.type.name}) for attribute ${name}`,
|
|
239
|
-
this.root.named(value)?.toString()
|
|
240
|
-
);
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
break;
|
|
246
|
-
case "object":
|
|
247
|
-
if (attribute.type.clazz && value instanceof attribute.type.clazz) {
|
|
248
|
-
assign(name, attribute, value);
|
|
249
|
-
} else {
|
|
250
|
-
assign(
|
|
251
|
-
name,
|
|
252
|
-
attribute,
|
|
253
|
-
typeFactory(
|
|
254
|
-
attribute.type,
|
|
255
|
-
this.ownerFor(attribute, value),
|
|
256
|
-
value
|
|
257
|
-
)
|
|
258
|
-
);
|
|
259
|
-
}
|
|
260
|
-
break;
|
|
261
|
-
}
|
|
262
|
-
};
|
|
263
|
-
|
|
264
|
-
if (data?.properties) {
|
|
265
|
-
this._properties = data.properties;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
for (const [path, attribute] of attributeIterator(type.attributes)) {
|
|
269
|
-
if (attribute.writable) {
|
|
270
|
-
const name = path.join(".");
|
|
271
|
-
const value = this.expand(data[name]);
|
|
272
|
-
|
|
273
|
-
if (attribute.collection) {
|
|
274
|
-
if (typeof value === "object") {
|
|
275
|
-
if (Array.isArray(value)) {
|
|
276
|
-
for (const v of value) {
|
|
277
|
-
instantiateAndAssign(name, attribute, v);
|
|
278
|
-
}
|
|
279
|
-
} else {
|
|
280
|
-
if (value instanceof Base) {
|
|
281
|
-
assign(name, attribute, value);
|
|
282
|
-
} else {
|
|
283
|
-
for (const [objectName, objectData] of Object.entries(value)) {
|
|
284
|
-
if (typeof objectData === "object") {
|
|
285
|
-
//console.log("KEY", objectName, type.name, type.key);
|
|
286
|
-
objectData[attribute.type.key] = objectName;
|
|
287
|
-
}
|
|
288
|
-
instantiateAndAssign(name, attribute, objectData);
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
continue;
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
instantiateAndAssign(name, attribute, value);
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
if (data?.extends) {
|
|
300
|
-
this.finalize(() => {
|
|
301
|
-
for (const object of this.extends) {
|
|
302
|
-
object.execFinalize();
|
|
303
|
-
this._applyExtends(object);
|
|
304
|
-
}
|
|
305
|
-
});
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
/*if(this.type) {
|
|
309
|
-
console.log(this.toString(),this.name,this.fullName);
|
|
310
|
-
}*/
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
_applyExtends() {}
|
|
108
|
+
materializeExtends() {}
|
|
314
109
|
|
|
315
110
|
named(name) {}
|
|
316
111
|
|
|
@@ -332,6 +127,15 @@ export class Base {
|
|
|
332
127
|
return this.owner.addObject(object);
|
|
333
128
|
}
|
|
334
129
|
|
|
130
|
+
collectFromDirections(directions = ["this", "extends", "owner"], property) {
|
|
131
|
+
let collected = new Set();
|
|
132
|
+
for (const node of this.walkDirections(directions)) {
|
|
133
|
+
collected = collected.union(node[property]);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return collected;
|
|
137
|
+
}
|
|
138
|
+
|
|
335
139
|
/**
|
|
336
140
|
* Walk the object graph in some directions and deliver seen nodes.
|
|
337
141
|
* @param {string[]} directions
|
|
@@ -371,7 +175,7 @@ export class Base {
|
|
|
371
175
|
forOwner(owner) {
|
|
372
176
|
if (this.owner !== owner) {
|
|
373
177
|
const newObject = Object.create(this);
|
|
374
|
-
newObject.extends = [...this.extends];
|
|
178
|
+
newObject.extends = new Set([...this.extends]);
|
|
375
179
|
newObject.owner = owner;
|
|
376
180
|
return newObject;
|
|
377
181
|
}
|
|
@@ -498,7 +302,7 @@ export class Base {
|
|
|
498
302
|
}
|
|
499
303
|
|
|
500
304
|
get smtp() {
|
|
501
|
-
return this.
|
|
305
|
+
return this.expression("services[types[smtp]][0]");
|
|
502
306
|
}
|
|
503
307
|
|
|
504
308
|
/**
|
|
@@ -515,29 +319,13 @@ export class Base {
|
|
|
515
319
|
});
|
|
516
320
|
}
|
|
517
321
|
|
|
518
|
-
get services()
|
|
519
|
-
|
|
520
|
-
return this.owner?.services;
|
|
322
|
+
get services() {
|
|
323
|
+
return this.owner?.services || [];
|
|
521
324
|
}
|
|
522
325
|
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
* @returns service with the highest priority
|
|
527
|
-
*/
|
|
528
|
-
findService(filter) {
|
|
529
|
-
let best;
|
|
530
|
-
for (const service of this.findServices(filter)) {
|
|
531
|
-
if (!best || service.priority > best.priority) {
|
|
532
|
-
best = service;
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
return best;
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
*findServices(filter) {
|
|
540
|
-
yield* this.owner?.findServices(filter);
|
|
326
|
+
// TODO get rid of
|
|
327
|
+
get aggregatedServices() {
|
|
328
|
+
return this.services;
|
|
541
329
|
}
|
|
542
330
|
|
|
543
331
|
set directory(directory) {
|
|
@@ -635,13 +423,16 @@ export class Base {
|
|
|
635
423
|
}
|
|
636
424
|
|
|
637
425
|
get tags() {
|
|
638
|
-
return this.
|
|
426
|
+
return this.collectFromDirections(["this", "extends"], "_tags");
|
|
639
427
|
}
|
|
640
428
|
|
|
641
429
|
set tags(value) {
|
|
642
430
|
this._tags = union(value, this._tags);
|
|
643
431
|
}
|
|
644
432
|
|
|
433
|
+
/**
|
|
434
|
+
* @return {boolean}
|
|
435
|
+
*/
|
|
645
436
|
get isTemplate() {
|
|
646
437
|
return this.name?.indexOf("*") >= 0 || this.owner?.isTemplate || false;
|
|
647
438
|
}
|
package/src/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { parseArgs } from "node:util";
|
|
2
2
|
import { argv, cwd, env } from "node:process";
|
|
3
|
-
import {
|
|
3
|
+
import { InitializationContext } from "./module.mjs";
|
|
4
4
|
|
|
5
5
|
export async function prepare(options = {}) {
|
|
6
6
|
const { values, positionals } = parseArgs({
|
|
@@ -25,9 +25,9 @@ export async function prepare(options = {}) {
|
|
|
25
25
|
allowPositionals: true
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
-
const
|
|
28
|
+
const ic = new InitializationContext(values.root);
|
|
29
29
|
|
|
30
|
-
await
|
|
30
|
+
await ic.loadAll();
|
|
31
31
|
|
|
32
|
-
return { root, options: values, args: positionals };
|
|
32
|
+
return { ic, root: ic.root, options: values, args: positionals };
|
|
33
33
|
}
|