pmcf 1.30.7 → 1.31.1
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/bin/pmcf-named-defs +1 -9
- package/package.json +1 -1
- package/src/base.mjs +13 -6
- package/src/dns.mjs +3 -1
- package/src/model.mjs +4 -1
- package/src/owner.mjs +4 -0
- package/types/base.d.mts +1 -1
- package/types/dns.d.mts +1 -0
- package/types/model.d.mts +2 -3
package/bin/pmcf-named-defs
CHANGED
|
@@ -12,13 +12,6 @@ import { prepare } from "../src/cmd.mjs";
|
|
|
12
12
|
const { root, args, options } = await prepare();
|
|
13
13
|
|
|
14
14
|
const owner = await root.load(args[0]);
|
|
15
|
-
const updates = [
|
|
16
|
-
Math.ceil(Date.now() / 1000),
|
|
17
|
-
36000,
|
|
18
|
-
72000,
|
|
19
|
-
600000,
|
|
20
|
-
60000
|
|
21
|
-
].join(" ");
|
|
22
15
|
|
|
23
16
|
await generateNamedDefs(owner, options.output);
|
|
24
17
|
|
|
@@ -29,6 +22,7 @@ console.log("description", `named defintions for ${owner.name}`);
|
|
|
29
22
|
async function generateNamedDefs(owner, targetDir) {
|
|
30
23
|
const dns = owner.dns;
|
|
31
24
|
const ttl = dns.recordTTL;
|
|
25
|
+
const updates = [Math.ceil(Date.now() / 1000), ...dns.soaUpdates].join(" ");
|
|
32
26
|
|
|
33
27
|
for (const domain of dns.domains) {
|
|
34
28
|
const zones = [];
|
|
@@ -42,8 +36,6 @@ async function generateNamedDefs(owner, targetDir) {
|
|
|
42
36
|
const createRecord = (key, type, value) => {
|
|
43
37
|
return {
|
|
44
38
|
key,
|
|
45
|
-
/*type,
|
|
46
|
-
value,*/
|
|
47
39
|
toString: () =>
|
|
48
40
|
`${key.padEnd(maxKeyLength, " ")} ${ttl} IN ${type.padEnd(
|
|
49
41
|
5,
|
package/package.json
CHANGED
package/src/base.mjs
CHANGED
|
@@ -180,23 +180,30 @@ export class Base {
|
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
toJSON() {
|
|
183
|
-
return extractFrom(this
|
|
183
|
+
return extractFrom(this);
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
-
export function extractFrom(object
|
|
187
|
+
export function extractFrom(object) {
|
|
188
188
|
const json = {};
|
|
189
|
-
|
|
189
|
+
|
|
190
|
+
for (const p of object?.propertyNames || Object.keys(object)) {
|
|
190
191
|
const value = object[p];
|
|
191
192
|
|
|
192
193
|
switch (typeof value) {
|
|
193
194
|
case "undefined":
|
|
194
195
|
break;
|
|
195
196
|
case "object":
|
|
196
|
-
if (value instanceof Base
|
|
197
|
-
json[p] = {
|
|
197
|
+
if (value instanceof Base) {
|
|
198
|
+
json[p] = { type: value.typeName };
|
|
199
|
+
if (value.name) {
|
|
200
|
+
json[p].name = value.name;
|
|
201
|
+
}
|
|
202
|
+
} else {
|
|
203
|
+
json[p] = Object.fromEntries(
|
|
204
|
+
Object.entries(value).map(([k, v]) => [k, extractFrom(v)])
|
|
205
|
+
);
|
|
198
206
|
}
|
|
199
|
-
|
|
200
207
|
break;
|
|
201
208
|
default:
|
|
202
209
|
json[p] = value;
|
package/src/dns.mjs
CHANGED
|
@@ -4,6 +4,8 @@ import { asArray } from "./utils.mjs";
|
|
|
4
4
|
export class DNSService extends Base {
|
|
5
5
|
allowedUpdates = [];
|
|
6
6
|
recordTTL = "1W";
|
|
7
|
+
soaUpdates = [36000, 72000, 600000, 60000];
|
|
8
|
+
|
|
7
9
|
forwardsTo = [];
|
|
8
10
|
|
|
9
11
|
static get typeName() {
|
|
@@ -32,7 +34,7 @@ export class DNSService extends Base {
|
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
get propertyNames() {
|
|
35
|
-
return ["recordTTL", "forwardsTo", "allowedUpdates"];
|
|
37
|
+
return ["recordTTL", "soaUpdates", "forwardsTo", "allowedUpdates"];
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
async resolvedConfig() {
|
package/src/model.mjs
CHANGED
|
@@ -305,7 +305,9 @@ export class Host extends Base {
|
|
|
305
305
|
}
|
|
306
306
|
|
|
307
307
|
get domainName() {
|
|
308
|
-
|
|
308
|
+
const domain = this.domain;
|
|
309
|
+
const hostName = this.hostName;
|
|
310
|
+
return domain ? hostName + "." + domain : hostName;
|
|
309
311
|
}
|
|
310
312
|
|
|
311
313
|
get host() {
|
|
@@ -538,6 +540,7 @@ export class NetworkInterface extends Base {
|
|
|
538
540
|
}
|
|
539
541
|
|
|
540
542
|
const _types = [
|
|
543
|
+
Owner,
|
|
541
544
|
Location,
|
|
542
545
|
Network,
|
|
543
546
|
Subnet,
|
package/src/owner.mjs
CHANGED
package/types/base.d.mts
CHANGED
package/types/dns.d.mts
CHANGED
package/types/model.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export class Root extends Owner {
|
|
2
2
|
static get types(): {
|
|
3
|
-
[k: string]: typeof DNSService | typeof
|
|
3
|
+
[k: string]: typeof DNSService | typeof Owner | typeof Subnet | typeof Service | typeof Host | typeof NetworkInterface;
|
|
4
4
|
};
|
|
5
5
|
constructor(directory: any);
|
|
6
6
|
get fullName(): string;
|
|
@@ -32,7 +32,7 @@ export class Host extends Base {
|
|
|
32
32
|
get domain(): any;
|
|
33
33
|
get modelName(): any;
|
|
34
34
|
get hostName(): any;
|
|
35
|
-
get domainName():
|
|
35
|
+
get domainName(): any;
|
|
36
36
|
get host(): this;
|
|
37
37
|
addService(service: any): void;
|
|
38
38
|
services(filter: any): Generator<any, void, unknown>;
|
|
@@ -69,6 +69,5 @@ export class NetworkInterface extends Base {
|
|
|
69
69
|
import { Owner } from "./owner.mjs";
|
|
70
70
|
import { DNSService } from "./dns.mjs";
|
|
71
71
|
import { Subnet } from "./owner.mjs";
|
|
72
|
-
import { Cluster } from "./cluster.mjs";
|
|
73
72
|
import { Service } from "./service.mjs";
|
|
74
73
|
import { Base } from "./base.mjs";
|