pmcf 1.45.1 → 1.46.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 +1 -1
- package/src/base.mjs +6 -3
- package/src/host.mjs +15 -6
- package/src/location.mjs +10 -5
- package/src/network.mjs +5 -4
- package/src/owner.mjs +3 -2
- package/src/service.mjs +2 -2
- package/src/types.mjs +13 -0
- package/src/utils.mjs +6 -0
- package/types/host.d.mts +23 -3
- package/types/location.d.mts +10 -6
- package/types/network.d.mts +6 -3
- package/types/owner.d.mts +4 -2
- package/types/service.d.mts +8 -2
- package/types/utils.d.mts +1 -0
package/package.json
CHANGED
package/src/base.mjs
CHANGED
|
@@ -70,15 +70,18 @@ export class Base {
|
|
|
70
70
|
const slot = data[slotName];
|
|
71
71
|
if (slot) {
|
|
72
72
|
delete data[slotName];
|
|
73
|
+
|
|
74
|
+
const type = typeof typeDef.type === "string" ? typesByName[typeDef.type] : typeDef.type;
|
|
75
|
+
|
|
73
76
|
if (typeDef.collection) {
|
|
74
77
|
if (Array.isArray(slot) || typeof slot === "string") {
|
|
75
78
|
for (const item of asArray(slot)) {
|
|
76
|
-
new
|
|
79
|
+
new type(this, item);
|
|
77
80
|
}
|
|
78
81
|
} else {
|
|
79
82
|
for (const [objectName, objectData] of Object.entries(slot)) {
|
|
80
83
|
objectData.name = objectName;
|
|
81
|
-
new
|
|
84
|
+
new type(this, objectData);
|
|
82
85
|
}
|
|
83
86
|
}
|
|
84
87
|
} else {
|
|
@@ -92,7 +95,7 @@ export class Base {
|
|
|
92
95
|
break;
|
|
93
96
|
|
|
94
97
|
default:
|
|
95
|
-
this[slotName] = new
|
|
98
|
+
this[slotName] = new type(this, slot);
|
|
96
99
|
}
|
|
97
100
|
}
|
|
98
101
|
}
|
package/src/host.mjs
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { Base } from "./base.mjs";
|
|
2
2
|
import { Network } from "./network.mjs";
|
|
3
|
+
import { Service } from "./service.mjs";
|
|
3
4
|
import {
|
|
4
5
|
asArray,
|
|
5
6
|
isIPv4Address,
|
|
6
7
|
isIPv6Address,
|
|
7
8
|
normalizeIPAddress,
|
|
8
|
-
formatCIDR
|
|
9
|
+
formatCIDR,
|
|
10
|
+
hasWellKnownSubnet
|
|
9
11
|
} from "./utils.mjs";
|
|
10
12
|
import { addType } from "./types.mjs";
|
|
11
13
|
|
|
@@ -34,14 +36,17 @@ export class Host extends Base {
|
|
|
34
36
|
extends: Base,
|
|
35
37
|
properties: {
|
|
36
38
|
networkInterfaces: { type: "network_interface", collection: true },
|
|
37
|
-
services: { type:
|
|
39
|
+
services: { type: Service, collection: true },
|
|
38
40
|
os: { type: "string" },
|
|
39
41
|
distribution: { type: "string" },
|
|
40
42
|
deployment: { type: "string" },
|
|
41
43
|
master: { type: "boolean" },
|
|
42
44
|
model: { type: "string" },
|
|
43
45
|
replaces: { type: "string" },
|
|
44
|
-
depends: { type: "string" }
|
|
46
|
+
depends: { type: "string" },
|
|
47
|
+
cidrAddresses: { type: "string", collection: true, writeable: false },
|
|
48
|
+
rawAddresses: { type: "string", collection: true, writeable: false },
|
|
49
|
+
rawAddress: { type: "string", writeable: false }
|
|
45
50
|
}
|
|
46
51
|
};
|
|
47
52
|
}
|
|
@@ -305,9 +310,9 @@ export class NetworkInterface extends Base {
|
|
|
305
310
|
ssid: { type: "string" },
|
|
306
311
|
psk: { type: "string" },
|
|
307
312
|
metric: { type: "number" },
|
|
308
|
-
cidrAddresses: { type: "string", collection: true },
|
|
309
|
-
|
|
310
|
-
network: {},
|
|
313
|
+
cidrAddresses: { type: "string", collection: true, writeable: false },
|
|
314
|
+
rawAddresses: { type: "string", collection: true, writeable: false },
|
|
315
|
+
network: { type: "network" },
|
|
311
316
|
gateway: {},
|
|
312
317
|
arpbridge: {}
|
|
313
318
|
}
|
|
@@ -371,6 +376,10 @@ export class NetworkInterface extends Base {
|
|
|
371
376
|
}
|
|
372
377
|
|
|
373
378
|
addSubnet(address) {
|
|
379
|
+
if(hasWellKnownSubnet(address)) {
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
|
|
374
383
|
if (!this.network) {
|
|
375
384
|
this.error("Missing network", address);
|
|
376
385
|
} else {
|
package/src/location.mjs
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { Owner } from "./owner.mjs";
|
|
2
|
+
import { Network } from "./network.mjs";
|
|
3
|
+
import { Subnet } from "./subnet.mjs";
|
|
4
|
+
import { Host } from "./host.mjs";
|
|
5
|
+
import { DNSService } from "./dns.mjs";
|
|
6
|
+
import { Cluster } from "./cluster.mjs";
|
|
2
7
|
import { addType } from "./types.mjs";
|
|
3
8
|
|
|
4
9
|
export class Location extends Owner {
|
|
@@ -11,11 +16,11 @@ export class Location extends Owner {
|
|
|
11
16
|
name: "location",
|
|
12
17
|
extends: Owner,
|
|
13
18
|
properties: {
|
|
14
|
-
networks: { type:
|
|
15
|
-
hosts: { type:
|
|
16
|
-
clusters: { type:
|
|
17
|
-
subnets: { type:
|
|
18
|
-
dns: { type:
|
|
19
|
+
networks: { type: Network, collection: true },
|
|
20
|
+
hosts: { type: Host, collection: true },
|
|
21
|
+
clusters: { type: Cluster, collection: true },
|
|
22
|
+
subnets: { type: Subnet, collection: true },
|
|
23
|
+
dns: { type: DNSService },
|
|
19
24
|
country: { type: "string" }
|
|
20
25
|
}
|
|
21
26
|
};
|
package/src/network.mjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Owner } from "./owner.mjs";
|
|
2
2
|
import { Subnet } from "./subnet.mjs";
|
|
3
|
+
import { Host } from "./host.mjs";
|
|
4
|
+
import { DNSService } from "./dns.mjs";
|
|
3
5
|
import { addType } from "./types.mjs";
|
|
4
6
|
|
|
5
7
|
export class Network extends Owner {
|
|
@@ -19,12 +21,11 @@ export class Network extends Owner {
|
|
|
19
21
|
extends: Owner,
|
|
20
22
|
properties: {
|
|
21
23
|
networks: { type: "network", collection: true },
|
|
22
|
-
hosts: { type:
|
|
24
|
+
hosts: { type: Host, collection: true },
|
|
23
25
|
clusters: { type: "cluster", collection: true },
|
|
24
|
-
subnets: { type:
|
|
25
|
-
dns: { type:
|
|
26
|
+
subnets: { type: Subnet, collection: true },
|
|
27
|
+
dns: { type: DNSService, collection: false }
|
|
26
28
|
//metric: { type: "number" }
|
|
27
|
-
|
|
28
29
|
/*kind: { type: "string" },
|
|
29
30
|
scope: { type: "string" },
|
|
30
31
|
/*bridge: {},
|
package/src/owner.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import { asArray, normalizeCIDR } from "./utils.mjs";
|
|
|
2
2
|
import { Base } from "./base.mjs";
|
|
3
3
|
import { Subnet } from "./subnet.mjs";
|
|
4
4
|
import { addType } from "./types.mjs";
|
|
5
|
+
import { DNSService } from "./dns.mjs";
|
|
5
6
|
|
|
6
7
|
export class Owner extends Base {
|
|
7
8
|
#membersByType = new Map();
|
|
@@ -22,8 +23,8 @@ export class Owner extends Base {
|
|
|
22
23
|
networks: { type: "network", collection: true },
|
|
23
24
|
hosts: { type: "host", collection: true },
|
|
24
25
|
clusters: { type: "cluster", collection: true },
|
|
25
|
-
subnets: { type:
|
|
26
|
-
dns: { type:
|
|
26
|
+
subnets: { type: Subnet, collection: true },
|
|
27
|
+
dns: { type: DNSService, collection: false },
|
|
27
28
|
domain: { type: "string" },
|
|
28
29
|
administratorEmail: { type: "string" }
|
|
29
30
|
}
|
package/src/service.mjs
CHANGED
|
@@ -31,8 +31,8 @@ export class Service extends Base {
|
|
|
31
31
|
name: "service",
|
|
32
32
|
extends: Base,
|
|
33
33
|
properties: {
|
|
34
|
-
ipAddresses: {},
|
|
35
|
-
addresses: {},
|
|
34
|
+
ipAddresses: { type: "string", collection: true },
|
|
35
|
+
addresses: { type: "string", collection: true },
|
|
36
36
|
port: { type: "number" },
|
|
37
37
|
protocol: { type: "string" },
|
|
38
38
|
alias: { type: "string" },
|
package/src/types.mjs
CHANGED
|
@@ -5,6 +5,19 @@ export function addType(clazz) {
|
|
|
5
5
|
typeDefinition.clazz = clazz;
|
|
6
6
|
|
|
7
7
|
typesByName[typeDefinition.name] = clazz;
|
|
8
|
+
|
|
9
|
+
for (const type of types) {
|
|
10
|
+
for (const [name, property] of Object.entries(
|
|
11
|
+
type.typeDefinition.properties
|
|
12
|
+
)) {
|
|
13
|
+
if (typeof property.type === "string") {
|
|
14
|
+
const t = typesByName[property.type];
|
|
15
|
+
if (t) {
|
|
16
|
+
property.type = t;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
8
21
|
}
|
|
9
22
|
|
|
10
23
|
export const types = [];
|
package/src/utils.mjs
CHANGED
|
@@ -164,5 +164,11 @@ export function normalizeCIDR(address) {
|
|
|
164
164
|
return { prefix, prefixLength, cidr: `${prefix}/${prefixLength}` };
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
+
export function hasWellKnownSubnet(address)
|
|
168
|
+
{
|
|
169
|
+
const n = encodeIP(address);
|
|
170
|
+
return n === IPV4_LOCALHOST || n === IPV6_LOCALHOST;
|
|
171
|
+
}
|
|
172
|
+
|
|
167
173
|
const IPV4_LOCALHOST = _encode(ipv4, "127.0.0.1");
|
|
168
174
|
const IPV6_LOCALHOST = _encode(ipv6, "::1");
|
package/types/host.d.mts
CHANGED
|
@@ -8,7 +8,7 @@ export class Host extends Base {
|
|
|
8
8
|
collection: boolean;
|
|
9
9
|
};
|
|
10
10
|
services: {
|
|
11
|
-
type:
|
|
11
|
+
type: typeof Service;
|
|
12
12
|
collection: boolean;
|
|
13
13
|
};
|
|
14
14
|
os: {
|
|
@@ -32,6 +32,20 @@ export class Host extends Base {
|
|
|
32
32
|
depends: {
|
|
33
33
|
type: string;
|
|
34
34
|
};
|
|
35
|
+
cidrAddresses: {
|
|
36
|
+
type: string;
|
|
37
|
+
collection: boolean;
|
|
38
|
+
writeable: boolean;
|
|
39
|
+
};
|
|
40
|
+
rawAddresses: {
|
|
41
|
+
type: string;
|
|
42
|
+
collection: boolean;
|
|
43
|
+
writeable: boolean;
|
|
44
|
+
};
|
|
45
|
+
rawAddress: {
|
|
46
|
+
type: string;
|
|
47
|
+
writeable: boolean;
|
|
48
|
+
};
|
|
35
49
|
};
|
|
36
50
|
};
|
|
37
51
|
static prepareData(root: any, data: any): Promise<typeof Host>;
|
|
@@ -97,11 +111,16 @@ export class NetworkInterface extends Base {
|
|
|
97
111
|
cidrAddresses: {
|
|
98
112
|
type: string;
|
|
99
113
|
collection: boolean;
|
|
114
|
+
writeable: boolean;
|
|
100
115
|
};
|
|
101
|
-
|
|
116
|
+
rawAddresses: {
|
|
117
|
+
type: string;
|
|
118
|
+
collection: boolean;
|
|
119
|
+
writeable: boolean;
|
|
120
|
+
};
|
|
121
|
+
network: {
|
|
102
122
|
type: string;
|
|
103
123
|
};
|
|
104
|
-
network: {};
|
|
105
124
|
gateway: {};
|
|
106
125
|
arpbridge: {};
|
|
107
126
|
};
|
|
@@ -128,3 +147,4 @@ export class NetworkInterface extends Base {
|
|
|
128
147
|
#private;
|
|
129
148
|
}
|
|
130
149
|
import { Base } from "./base.mjs";
|
|
150
|
+
import { Service } from "./service.mjs";
|
package/types/location.d.mts
CHANGED
|
@@ -4,24 +4,23 @@ export class Location extends Owner {
|
|
|
4
4
|
extends: typeof Owner;
|
|
5
5
|
properties: {
|
|
6
6
|
networks: {
|
|
7
|
-
type:
|
|
7
|
+
type: typeof Network;
|
|
8
8
|
collection: boolean;
|
|
9
9
|
};
|
|
10
10
|
hosts: {
|
|
11
|
-
type:
|
|
11
|
+
type: typeof Host;
|
|
12
12
|
collection: boolean;
|
|
13
13
|
};
|
|
14
14
|
clusters: {
|
|
15
|
-
type:
|
|
15
|
+
type: typeof Cluster;
|
|
16
16
|
collection: boolean;
|
|
17
17
|
};
|
|
18
18
|
subnets: {
|
|
19
|
-
type:
|
|
19
|
+
type: typeof Subnet;
|
|
20
20
|
collection: boolean;
|
|
21
21
|
};
|
|
22
22
|
dns: {
|
|
23
|
-
type:
|
|
24
|
-
collection: boolean;
|
|
23
|
+
type: typeof DNSService;
|
|
25
24
|
};
|
|
26
25
|
country: {
|
|
27
26
|
type: string;
|
|
@@ -31,3 +30,8 @@ export class Location extends Owner {
|
|
|
31
30
|
get location(): this;
|
|
32
31
|
}
|
|
33
32
|
import { Owner } from "./owner.mjs";
|
|
33
|
+
import { Network } from "./network.mjs";
|
|
34
|
+
import { Host } from "./host.mjs";
|
|
35
|
+
import { Cluster } from "./cluster.mjs";
|
|
36
|
+
import { Subnet } from "./subnet.mjs";
|
|
37
|
+
import { DNSService } from "./dns.mjs";
|
package/types/network.d.mts
CHANGED
|
@@ -8,7 +8,7 @@ export class Network extends Owner {
|
|
|
8
8
|
collection: boolean;
|
|
9
9
|
};
|
|
10
10
|
hosts: {
|
|
11
|
-
type:
|
|
11
|
+
type: typeof Host;
|
|
12
12
|
collection: boolean;
|
|
13
13
|
};
|
|
14
14
|
clusters: {
|
|
@@ -16,11 +16,11 @@ export class Network extends Owner {
|
|
|
16
16
|
collection: boolean;
|
|
17
17
|
};
|
|
18
18
|
subnets: {
|
|
19
|
-
type:
|
|
19
|
+
type: typeof Subnet;
|
|
20
20
|
collection: boolean;
|
|
21
21
|
};
|
|
22
22
|
dns: {
|
|
23
|
-
type:
|
|
23
|
+
type: typeof DNSService;
|
|
24
24
|
collection: boolean;
|
|
25
25
|
};
|
|
26
26
|
};
|
|
@@ -36,3 +36,6 @@ export class Network extends Owner {
|
|
|
36
36
|
#private;
|
|
37
37
|
}
|
|
38
38
|
import { Owner } from "./owner.mjs";
|
|
39
|
+
import { Host } from "./host.mjs";
|
|
40
|
+
import { Subnet } from "./subnet.mjs";
|
|
41
|
+
import { DNSService } from "./dns.mjs";
|
package/types/owner.d.mts
CHANGED
|
@@ -16,11 +16,11 @@ export class Owner extends Base {
|
|
|
16
16
|
collection: boolean;
|
|
17
17
|
};
|
|
18
18
|
subnets: {
|
|
19
|
-
type:
|
|
19
|
+
type: typeof Subnet;
|
|
20
20
|
collection: boolean;
|
|
21
21
|
};
|
|
22
22
|
dns: {
|
|
23
|
-
type:
|
|
23
|
+
type: typeof DNSService;
|
|
24
24
|
collection: boolean;
|
|
25
25
|
};
|
|
26
26
|
domain: {
|
|
@@ -64,3 +64,5 @@ export class Owner extends Base {
|
|
|
64
64
|
#private;
|
|
65
65
|
}
|
|
66
66
|
import { Base } from "./base.mjs";
|
|
67
|
+
import { Subnet } from "./subnet.mjs";
|
|
68
|
+
import { DNSService } from "./dns.mjs";
|
package/types/service.d.mts
CHANGED
|
@@ -3,8 +3,14 @@ export class Service extends Base {
|
|
|
3
3
|
name: string;
|
|
4
4
|
extends: typeof Base;
|
|
5
5
|
properties: {
|
|
6
|
-
ipAddresses: {
|
|
7
|
-
|
|
6
|
+
ipAddresses: {
|
|
7
|
+
type: string;
|
|
8
|
+
collection: boolean;
|
|
9
|
+
};
|
|
10
|
+
addresses: {
|
|
11
|
+
type: string;
|
|
12
|
+
collection: boolean;
|
|
13
|
+
};
|
|
8
14
|
port: {
|
|
9
15
|
type: string;
|
|
10
16
|
};
|
package/types/utils.d.mts
CHANGED