pmcf 3.9.1 → 3.9.3
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 +4 -4
- package/src/base.mjs +33 -34
- package/src/services/bind.mjs +4 -5
- package/src/types.mjs +3 -4
- package/types/services/bind.d.mts +20 -21
- package/types/types.d.mts +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmcf",
|
|
3
|
-
"version": "3.9.
|
|
3
|
+
"version": "3.9.3",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -51,13 +51,13 @@
|
|
|
51
51
|
"lint:typescript": "tsc --allowJs --checkJs --noEmit --resolveJsonModule --target esnext -m esnext --module nodenext --moduleResolution nodenext ./src**/*.mjs"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"ip-utilties": "^1.4.
|
|
54
|
+
"ip-utilties": "^1.4.9",
|
|
55
55
|
"npm-pkgbuild": "^18.2.30",
|
|
56
|
-
"pacc": "^4.
|
|
56
|
+
"pacc": "^4.16.0",
|
|
57
57
|
"package-directory": "^8.1.0"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@types/node": "^24.3.
|
|
60
|
+
"@types/node": "^24.3.3",
|
|
61
61
|
"ava": "^6.4.1",
|
|
62
62
|
"c8": "^10.1.3",
|
|
63
63
|
"documentation": "^14.0.3",
|
package/src/base.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import { join } from "node:path";
|
|
|
2
2
|
import { allOutputs } from "npm-pkgbuild";
|
|
3
3
|
import {
|
|
4
4
|
getAttribute,
|
|
5
|
+
baseTypes,
|
|
5
6
|
name_attribute_writable,
|
|
6
7
|
string_attribute,
|
|
7
8
|
string_attribute_writable,
|
|
@@ -10,7 +11,7 @@ import {
|
|
|
10
11
|
description_attribute,
|
|
11
12
|
boolean_attribute_writable
|
|
12
13
|
} from "pacc";
|
|
13
|
-
import { addType,
|
|
14
|
+
import { addType, typeFactory } from "./types.mjs";
|
|
14
15
|
import { asArray } from "./utils.mjs";
|
|
15
16
|
|
|
16
17
|
const BaseTypeDefinition = {
|
|
@@ -90,24 +91,22 @@ export class Base {
|
|
|
90
91
|
return this;
|
|
91
92
|
}
|
|
92
93
|
|
|
93
|
-
read(data, type=this.constructor.typeDefinition) {
|
|
94
|
-
if(type.extends) {
|
|
94
|
+
read(data, type = this.constructor.typeDefinition) {
|
|
95
|
+
if (type.extends) {
|
|
95
96
|
this.read(data, type.extends);
|
|
96
97
|
}
|
|
97
98
|
|
|
98
|
-
const assign = (name,
|
|
99
|
-
|
|
100
|
-
value = property.default;
|
|
101
|
-
}
|
|
99
|
+
const assign = (name, attribute, value) => {
|
|
100
|
+
value ??= attribute.default;
|
|
102
101
|
|
|
103
102
|
if (value !== undefined) {
|
|
104
|
-
if (
|
|
105
|
-
if (
|
|
106
|
-
this.error(name, "unknown value", value,
|
|
103
|
+
if (attribute.values) {
|
|
104
|
+
if (attribute.values.indexOf(value) < 0) {
|
|
105
|
+
this.error(name, "unknown value", value, attribute.values);
|
|
107
106
|
}
|
|
108
107
|
}
|
|
109
108
|
|
|
110
|
-
if (
|
|
109
|
+
if (attribute.collection) {
|
|
111
110
|
const current = this[name];
|
|
112
111
|
|
|
113
112
|
switch (typeof current) {
|
|
@@ -143,9 +142,9 @@ export class Base {
|
|
|
143
142
|
}
|
|
144
143
|
};
|
|
145
144
|
|
|
146
|
-
const instantiateAndAssign = (name,
|
|
147
|
-
if (
|
|
148
|
-
assign(name,
|
|
145
|
+
const instantiateAndAssign = (name, attribute, value) => {
|
|
146
|
+
if (baseTypes.has(attribute.type[0])) {
|
|
147
|
+
assign(name, attribute, value);
|
|
149
148
|
return;
|
|
150
149
|
}
|
|
151
150
|
|
|
@@ -163,7 +162,7 @@ export class Base {
|
|
|
163
162
|
{
|
|
164
163
|
let object;
|
|
165
164
|
|
|
166
|
-
for (const type of
|
|
165
|
+
for (const type of attribute.type) {
|
|
167
166
|
object = this.typeNamed(type.name, value);
|
|
168
167
|
if (object) {
|
|
169
168
|
break;
|
|
@@ -171,11 +170,11 @@ export class Base {
|
|
|
171
170
|
}
|
|
172
171
|
|
|
173
172
|
if (object) {
|
|
174
|
-
assign(name,
|
|
173
|
+
assign(name, attribute, object);
|
|
175
174
|
} else {
|
|
176
|
-
if (
|
|
177
|
-
object = new
|
|
178
|
-
this.ownerFor(
|
|
175
|
+
if (attribute.type[0].constructWithIdentifierOnly) {
|
|
176
|
+
object = new attribute.type[0].clazz(
|
|
177
|
+
this.ownerFor(attribute, value),
|
|
179
178
|
value
|
|
180
179
|
);
|
|
181
180
|
object.read(value);
|
|
@@ -184,14 +183,14 @@ export class Base {
|
|
|
184
183
|
this.finalize(() => {
|
|
185
184
|
value = this.expand(value);
|
|
186
185
|
|
|
187
|
-
for (const type of
|
|
186
|
+
for (const type of attribute.type) {
|
|
188
187
|
const object =
|
|
189
188
|
this.typeNamed(type.name, value) ||
|
|
190
189
|
this.owner.typeNamed(type.name, value) ||
|
|
191
190
|
this.root.typeNamed(type.name, value); // TODO
|
|
192
191
|
|
|
193
192
|
if (object) {
|
|
194
|
-
assign(name,
|
|
193
|
+
assign(name, attribute, object);
|
|
195
194
|
return;
|
|
196
195
|
}
|
|
197
196
|
}
|
|
@@ -199,7 +198,7 @@ export class Base {
|
|
|
199
198
|
this.error(
|
|
200
199
|
"Not found",
|
|
201
200
|
name,
|
|
202
|
-
|
|
201
|
+
attribute.type.map(t => t.name),
|
|
203
202
|
value
|
|
204
203
|
);
|
|
205
204
|
});
|
|
@@ -208,15 +207,15 @@ export class Base {
|
|
|
208
207
|
}
|
|
209
208
|
break;
|
|
210
209
|
case "object":
|
|
211
|
-
if (value instanceof
|
|
212
|
-
assign(name,
|
|
210
|
+
if (value instanceof attribute.type[0].clazz) {
|
|
211
|
+
assign(name, attribute, value);
|
|
213
212
|
} else {
|
|
214
213
|
assign(
|
|
215
214
|
name,
|
|
216
|
-
|
|
215
|
+
attribute,
|
|
217
216
|
typeFactory(
|
|
218
|
-
|
|
219
|
-
this.ownerFor(
|
|
217
|
+
attribute.type[0],
|
|
218
|
+
this.ownerFor(attribute, value),
|
|
220
219
|
value
|
|
221
220
|
)
|
|
222
221
|
);
|
|
@@ -229,32 +228,32 @@ export class Base {
|
|
|
229
228
|
this._properties = data.properties;
|
|
230
229
|
}
|
|
231
230
|
|
|
232
|
-
for (const [name,
|
|
233
|
-
if (
|
|
231
|
+
for (const [name, attribute] of Object.entries(type.properties)) {
|
|
232
|
+
if (attribute.writable) {
|
|
234
233
|
const value = this.expand(data[name]);
|
|
235
234
|
|
|
236
|
-
if (
|
|
235
|
+
if (attribute.collection) {
|
|
237
236
|
if (typeof value === "object") {
|
|
238
237
|
if (Array.isArray(value)) {
|
|
239
238
|
for (const v of value) {
|
|
240
|
-
instantiateAndAssign(name,
|
|
239
|
+
instantiateAndAssign(name, attribute, v);
|
|
241
240
|
}
|
|
242
241
|
} else {
|
|
243
242
|
if (value instanceof Base) {
|
|
244
|
-
assign(name,
|
|
243
|
+
assign(name, attribute, value);
|
|
245
244
|
} else {
|
|
246
245
|
for (const [objectName, objectData] of Object.entries(value)) {
|
|
247
246
|
if (typeof objectData === "object") {
|
|
248
247
|
objectData[type.identifier.name] = objectName;
|
|
249
248
|
}
|
|
250
|
-
instantiateAndAssign(name,
|
|
249
|
+
instantiateAndAssign(name, attribute, objectData);
|
|
251
250
|
}
|
|
252
251
|
}
|
|
253
252
|
}
|
|
254
253
|
continue;
|
|
255
254
|
}
|
|
256
255
|
}
|
|
257
|
-
instantiateAndAssign(name,
|
|
256
|
+
instantiateAndAssign(name, attribute, value);
|
|
258
257
|
}
|
|
259
258
|
}
|
|
260
259
|
}
|
package/src/services/bind.mjs
CHANGED
|
@@ -4,10 +4,10 @@ import { FileContentProvider } from "npm-pkgbuild";
|
|
|
4
4
|
import { isLinkLocal, reverseArpa } from "ip-utilties";
|
|
5
5
|
import {
|
|
6
6
|
string_attribute_writable,
|
|
7
|
-
string_collection_attribute,
|
|
8
7
|
boolean_attribute_writable_true,
|
|
9
8
|
boolean_attribute_writable_false,
|
|
10
|
-
number_attribute
|
|
9
|
+
number_attribute,
|
|
10
|
+
string_collection_attribute_writable
|
|
11
11
|
} from "pacc";
|
|
12
12
|
import { writeLines, asArray } from "../utils.mjs";
|
|
13
13
|
import {
|
|
@@ -48,8 +48,7 @@ const BindServiceTypeDefinition = {
|
|
|
48
48
|
hasLinkLocalAdresses: boolean_attribute_writable_false,
|
|
49
49
|
hasLocationRecord: boolean_attribute_writable_true,
|
|
50
50
|
excludeInterfaceKinds: {
|
|
51
|
-
...
|
|
52
|
-
writable: true
|
|
51
|
+
...string_collection_attribute_writable
|
|
53
52
|
},
|
|
54
53
|
exclude: { type: address_types, collection: true, writable: true },
|
|
55
54
|
notify: boolean_attribute_writable_false,
|
|
@@ -59,7 +58,7 @@ const BindServiceTypeDefinition = {
|
|
|
59
58
|
retry: { ...string_attribute_writable, default: 72000 },
|
|
60
59
|
expire: { ...string_attribute_writable, default: 600000 },
|
|
61
60
|
minimum: { ...string_attribute_writable, default: 60000 },
|
|
62
|
-
allowedUpdates: { ...
|
|
61
|
+
allowedUpdates: { ...string_collection_attribute_writable }
|
|
63
62
|
},
|
|
64
63
|
|
|
65
64
|
service: {
|
package/src/types.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { baseTypes } from "pacc";
|
|
1
2
|
import { asArray } from "./utils.mjs";
|
|
2
3
|
import { addServiceTypes } from "./service-types.mjs";
|
|
3
4
|
|
|
@@ -19,8 +20,6 @@ export function addType(clazz) {
|
|
|
19
20
|
type.clazz = clazz;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
export const primitives = new Set(["string", "number", "boolean"]);
|
|
23
|
-
|
|
24
23
|
export function resolveTypeLinks() {
|
|
25
24
|
for (const type of Object.values(types)) {
|
|
26
25
|
type.owners = type.owners.map(owner =>
|
|
@@ -37,7 +36,7 @@ export function resolveTypeLinks() {
|
|
|
37
36
|
|
|
38
37
|
for (const type of asArray(property.type)) {
|
|
39
38
|
if (typeof type === "string") {
|
|
40
|
-
if (
|
|
39
|
+
if (baseTypes.has(type)) {
|
|
41
40
|
ts.push(type);
|
|
42
41
|
} else {
|
|
43
42
|
const t = types[type];
|
|
@@ -60,7 +59,7 @@ export function resolveTypeLinks() {
|
|
|
60
59
|
|
|
61
60
|
/*
|
|
62
61
|
if (typeof property.type === "string") {
|
|
63
|
-
if (!
|
|
62
|
+
if (!baseTypes.has(property.type)) {
|
|
64
63
|
const type = types[property.type];
|
|
65
64
|
if (type) {
|
|
66
65
|
property.type = type;
|
|
@@ -125,7 +125,7 @@ export class BindService extends ExtraSourceService {
|
|
|
125
125
|
get?: Function;
|
|
126
126
|
env?: string[] | string;
|
|
127
127
|
};
|
|
128
|
-
types: typeof string_collection_attribute;
|
|
128
|
+
types: typeof import("pacc").string_collection_attribute;
|
|
129
129
|
tls: import("pacc").AttributeDefinition;
|
|
130
130
|
hostName: {
|
|
131
131
|
writable: boolean;
|
|
@@ -327,7 +327,7 @@ export class BindService extends ExtraSourceService {
|
|
|
327
327
|
get?: Function;
|
|
328
328
|
env?: string[] | string;
|
|
329
329
|
};
|
|
330
|
-
types: typeof string_collection_attribute;
|
|
330
|
+
types: typeof import("pacc").string_collection_attribute;
|
|
331
331
|
tls: import("pacc").AttributeDefinition;
|
|
332
332
|
hostName: {
|
|
333
333
|
writable: boolean;
|
|
@@ -437,18 +437,18 @@ export class BindService extends ExtraSourceService {
|
|
|
437
437
|
hasLinkLocalAdresses: import("pacc").AttributeDefinition;
|
|
438
438
|
hasLocationRecord: import("pacc").AttributeDefinition;
|
|
439
439
|
excludeInterfaceKinds: {
|
|
440
|
-
writable: boolean;
|
|
441
|
-
collection: boolean;
|
|
442
440
|
type: string;
|
|
443
441
|
isKey: boolean;
|
|
442
|
+
writable: boolean;
|
|
444
443
|
mandatory: boolean;
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
444
|
+
collection: boolean;
|
|
445
|
+
private?: boolean;
|
|
446
|
+
depends?: string;
|
|
447
|
+
description?: string;
|
|
448
|
+
default?: any;
|
|
449
|
+
set?: Function;
|
|
450
|
+
get?: Function;
|
|
451
|
+
env?: string[] | string;
|
|
452
452
|
};
|
|
453
453
|
exclude: {
|
|
454
454
|
type: string[];
|
|
@@ -541,18 +541,18 @@ export class BindService extends ExtraSourceService {
|
|
|
541
541
|
env?: string[] | string;
|
|
542
542
|
};
|
|
543
543
|
allowedUpdates: {
|
|
544
|
-
writable: boolean;
|
|
545
|
-
collection: boolean;
|
|
546
544
|
type: string;
|
|
547
545
|
isKey: boolean;
|
|
546
|
+
writable: boolean;
|
|
548
547
|
mandatory: boolean;
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
548
|
+
collection: boolean;
|
|
549
|
+
private?: boolean;
|
|
550
|
+
depends?: string;
|
|
551
|
+
description?: string;
|
|
552
|
+
default?: any;
|
|
553
|
+
set?: Function;
|
|
554
|
+
get?: Function;
|
|
555
|
+
env?: string[] | string;
|
|
556
556
|
};
|
|
557
557
|
};
|
|
558
558
|
service: {
|
|
@@ -623,4 +623,3 @@ export class BindService extends ExtraSourceService {
|
|
|
623
623
|
writeZones(packageData: any, configs: any): Promise<void>;
|
|
624
624
|
}
|
|
625
625
|
import { ExtraSourceService } from "pmcf";
|
|
626
|
-
import { string_collection_attribute } from "pacc";
|
package/types/types.d.mts
CHANGED