pmcf 6.14.0 → 6.16.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/bin/pmcf-info CHANGED
@@ -10,17 +10,23 @@ for (const expression of args) {
10
10
  show(result);
11
11
  }
12
12
 
13
- function show(value, indent = 0) {
13
+ function show(value, indent = 0, short = false) {
14
14
  if (value instanceof Iterator) {
15
15
  for (const v of value) {
16
- show(v);
16
+ show(v, indent);
17
17
  }
18
18
  } else {
19
19
  const type = value.constructor;
20
- console.log(`${" ".repeat(indent)}${value.fullName}(${type.name}):`);
21
-
20
+ const prefix = (l = indent) => " ".repeat(l * 2);
22
21
  const ml = maxNameLength(type);
23
- const name = attribute => " " + attribute.name.padEnd(ml) + ": ";
22
+ const name = (attribute, l = indent + 1) =>
23
+ prefix(l) + attribute.name.padEnd(ml) + ": ";
24
+
25
+ if (short) {
26
+ console.log(`${prefix()}${value[type.key]}:`);
27
+ } else {
28
+ console.log(`${prefix()}${value.fullName}(${type.name}):`);
29
+ }
24
30
 
25
31
  for (const [path, attribute] of extendingAttributeIterator(
26
32
  type,
@@ -30,7 +36,10 @@ function show(value, indent = 0) {
30
36
  const v = value.attribute(attribute.name);
31
37
  if (v !== undefined) {
32
38
  if (attribute.collection) {
33
- console.log(`${name(attribute)}${[...v]}`);
39
+ const l = [...v];
40
+ if (l.length) {
41
+ console.log(`${name(attribute)}${l}`);
42
+ }
34
43
  } else {
35
44
  console.log(`${name(attribute)}${v}`);
36
45
  }
@@ -44,15 +53,22 @@ function show(value, indent = 0) {
44
53
  const v = value[attribute.name];
45
54
  if (v !== undefined) {
46
55
  if (attribute.collection) {
47
- console.log(name(attribute));
48
-
49
56
  if (attribute.backpointer) {
57
+ console.log(name(attribute));
50
58
  for (const o of v.values()) {
51
- show(o, indent + 2);
59
+ show(o, indent + 2, true);
52
60
  }
53
61
  } else {
54
- for (const o of v.values()) {
55
- console.log(" ".repeat(indent + 2) + o.fullName);
62
+ const l = [...v];
63
+
64
+ if (l.length > 1) {
65
+ console.log(name(attribute));
66
+
67
+ for (const o of l) {
68
+ console.log(prefix(indent + 2) + o.fullName);
69
+ }
70
+ } else if (l.length === 1) {
71
+ console.log(name(attribute) + l[0].fullName);
56
72
  }
57
73
  }
58
74
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmcf",
3
- "version": "6.14.0",
3
+ "version": "6.16.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -51,7 +51,7 @@
51
51
  },
52
52
  "dependencies": {
53
53
  "aggregated-map": "^1.0.8",
54
- "content-entry-transform": "^1.6.9",
54
+ "content-entry-transform": "^1.7.0",
55
55
  "ip-utilties": "^3.8.1",
56
56
  "npm-pkgbuild": "^20.8.6",
57
57
  "pacc": "^10.4.1",
@@ -8,13 +8,18 @@ import {
8
8
  FAMILY_IPV6
9
9
  } from "ip-utilties";
10
10
  import {
11
+ default_collection_attribute,
11
12
  default_collection_attribute_writable,
12
13
  default_attribute_writable,
13
14
  duration_attribute_writable,
15
+ name_attribute,
16
+ string_attribute,
14
17
  string_set_attribute_writable,
18
+ string_set_attribute,
15
19
  boolean_attribute_writable_true,
16
20
  boolean_attribute_writable_false,
17
21
  integer_attribute_writable,
22
+ integer_attribute,
18
23
  name_attribute_writable
19
24
  } from "pacc";
20
25
  import {
@@ -38,10 +43,39 @@ import { owner_attribute } from "../common-attributes.mjs";
38
43
 
39
44
  const bindNetworkAddressTypes = networkAddressType + "|bind_group";
40
45
 
46
+ class zone extends Base {
47
+ static priority = 1;
48
+ static key = "id";
49
+ static attributes = {
50
+ id: { ...name_attribute, name: "id" },
51
+ file: { ...string_attribute, name: "file" },
52
+ records: { ...string_set_attribute, name: "records" }
53
+ };
54
+
55
+ static {
56
+ addType(this);
57
+ }
58
+
59
+ records = new Set();
60
+
61
+ get domain() {
62
+ return this.id;
63
+ }
64
+
65
+ get directory() {
66
+ return this.source.name;
67
+ }
68
+
69
+ get file() {
70
+ return `${this.directory}/${this.domain}.zone`;
71
+ }
72
+ }
73
+
41
74
  class bind_group extends Base {
42
75
  static priority = 1;
43
76
  static attributes = {
44
77
  name: name_attribute_writable,
78
+ order: { ...integer_attribute, name: "order" },
45
79
  access: {
46
80
  type: bindNetworkAddressTypes,
47
81
  name: "access",
@@ -62,6 +96,12 @@ class bind_group extends Base {
62
96
  type: networkAddressType + "|owner",
63
97
  name: "entries"
64
98
  },
99
+ zones: {
100
+ ...default_collection_attribute,
101
+ type: zone,
102
+ backpointer: owner_attribute,
103
+ name: "zones"
104
+ },
65
105
  sharedWith: {
66
106
  ...default_attribute_writable,
67
107
  name: "sharedWith",
@@ -148,27 +188,64 @@ class bind_group extends Base {
148
188
  }
149
189
 
150
190
  get defaultRecords() {
151
- const nameService = this.owner;
191
+ const service = this.service;
152
192
 
153
- console.log(
193
+ /*console.log(
154
194
  "nameService",
155
- nameService.fullName,
156
- nameService.domainName,
157
- nameService.address()
158
- );
195
+ service.fullName,
196
+ service.domainName,
197
+ service.address()
198
+ );*/
159
199
 
160
200
  return [
161
201
  DNSRecord(
162
202
  "@",
163
203
  "SOA",
164
- dnsFullName(nameService.domainName),
204
+ dnsFullName(service.domainName),
165
205
  dnsFullName(this.administratorEmail.replace(/@/, ".")),
166
206
  `(${this.soaUpdates.join(" ")})`
167
207
  ),
168
- DNSRecord("@", "NS", dnsFullName(nameService.address()))
208
+ DNSRecord("@", "NS", dnsFullName(service.address()))
169
209
  ];
170
210
  }
171
211
 
212
+ get zones() {
213
+ const zs = new Map();
214
+
215
+ for (const source of this.entries) {
216
+ for (const domain of source.localDomains) {
217
+ const config = {
218
+ name: `${domain}.zone.conf`,
219
+ type: this.service.serverType,
220
+ zones: []
221
+ };
222
+
223
+ const z = new zone();
224
+
225
+ z.id = domain;
226
+ z.source = source;
227
+ z.owner = this;
228
+ z.config = config;
229
+ z.records = new Set(this.defaultRecords);
230
+
231
+ zs.set(z.id, z);
232
+
233
+ config.zones.push(z);
234
+
235
+ for (const {
236
+ address,
237
+ subnet,
238
+ networkInterface,
239
+ domainNames,
240
+ family
241
+ } of source.networkAddresses()) {
242
+ // console.log(address);
243
+ }
244
+ }
245
+ }
246
+ return zs;
247
+ }
248
+
172
249
  async packageContent(outputControl) {
173
250
  outputControl.packageData.sources.push(
174
251
  ...(await Array.fromAsync(
@@ -557,7 +634,7 @@ export class bind extends ExtraSourceService {
557
634
  const present = await this.writeForwarders(outputControl);
558
635
 
559
636
  if (hasContent || present) {
560
- console.log(packageData);
637
+ //console.log(packageData);
561
638
  yield packageData;
562
639
  }
563
640
  }