@hackfed/toolbox 0.1.5 → 0.2.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/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hackfed/toolbox",
|
|
3
3
|
"description": "Tools for Hackfed Registry",
|
|
4
|
-
"version": "0.1
|
|
4
|
+
"version": "0.2.1",
|
|
5
5
|
"bin": {
|
|
6
6
|
"hackfed-toolbox": "src/index.ts"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@hackfed/schemas": "^0.
|
|
9
|
+
"@hackfed/schemas": "^0.8.0",
|
|
10
10
|
"commander": "^14.0.2",
|
|
11
11
|
"ipaddr.js": "^2.3.0",
|
|
12
12
|
"tslog": "^4.10.2",
|
|
@@ -36,6 +36,6 @@
|
|
|
36
36
|
},
|
|
37
37
|
"type": "module",
|
|
38
38
|
"scripts": {
|
|
39
|
-
"
|
|
39
|
+
"check": "tsc --noEmit && eslint ."
|
|
40
40
|
}
|
|
41
41
|
}
|
|
@@ -167,7 +167,6 @@ async function checkTelephonyService (context: CheckServiceContext): Promise<voi
|
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
const orgExchanges = new Set<string>()
|
|
170
|
-
const orgPrefixes = new Set<string>()
|
|
171
170
|
|
|
172
171
|
if (org.spec.services.telephony.exchanges) {
|
|
173
172
|
for (const exchange of org.spec.services.telephony.exchanges) {
|
|
@@ -189,32 +188,14 @@ async function checkTelephonyService (context: CheckServiceContext): Promise<voi
|
|
|
189
188
|
process.exit(1)
|
|
190
189
|
}
|
|
191
190
|
|
|
192
|
-
orgExchanges.add(exchange.id)
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
if (org.spec.services.telephony.prefixes) {
|
|
197
|
-
for (const prefix of org.spec.services.telephony.prefixes) {
|
|
198
191
|
// Check for duplicate prefixes across organizations
|
|
199
|
-
if (prefixes.has(
|
|
200
|
-
context.logger.error('(%s) duplicate Telephony prefix found: %s', org.spec.id,
|
|
192
|
+
if (prefixes.has(exchange.prefix)) {
|
|
193
|
+
context.logger.error('(%s) duplicate Telephony prefix found: %s', org.spec.id, exchange.prefix)
|
|
201
194
|
process.exit(1)
|
|
202
195
|
}
|
|
203
196
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
context.logger.error('(%s) duplicate Telephony prefix found within organization: %s', org.spec.id, prefix.prefix)
|
|
207
|
-
process.exit(1)
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
// Verify that referenced exchange exists
|
|
211
|
-
if (!orgExchanges.has(prefix.exchange)) {
|
|
212
|
-
context.logger.error('(%s) Telephony prefix references unknown exchange: %s', org.spec.id, prefix.exchange)
|
|
213
|
-
process.exit(1)
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
prefixes.add(prefix.prefix)
|
|
217
|
-
orgPrefixes.add(prefix.prefix)
|
|
197
|
+
prefixes.add(exchange.prefix)
|
|
198
|
+
orgExchanges.add(exchange.id)
|
|
218
199
|
}
|
|
219
200
|
}
|
|
220
201
|
}
|
|
@@ -50,14 +50,6 @@ async function generateTelephonyDirectory (
|
|
|
50
50
|
continue
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
// Map prefixes to exchanges
|
|
54
|
-
const exchangePrefixes = new Map<string, Set<string>>()
|
|
55
|
-
for (const prefix of org.spec.services.telephony.prefixes ?? []) {
|
|
56
|
-
const prefixes = exchangePrefixes.get(prefix.exchange) ?? new Set<string>()
|
|
57
|
-
prefixes.add(prefix.prefix)
|
|
58
|
-
exchangePrefixes.set(prefix.exchange, prefixes)
|
|
59
|
-
}
|
|
60
|
-
|
|
61
53
|
// Map exchanges
|
|
62
54
|
const exchanges = new Map<string, TelephonyDirectoryExchange>()
|
|
63
55
|
for (const exchange of org.spec.services.telephony.exchanges ?? []) {
|
|
@@ -65,7 +57,7 @@ async function generateTelephonyDirectory (
|
|
|
65
57
|
codecs: exchange.codecs,
|
|
66
58
|
endpoint: exchange.address,
|
|
67
59
|
id: exchange.id,
|
|
68
|
-
|
|
60
|
+
prefix: exchange.prefix,
|
|
69
61
|
protocol: exchange.protocol
|
|
70
62
|
})
|
|
71
63
|
}
|
|
@@ -74,7 +66,7 @@ async function generateTelephonyDirectory (
|
|
|
74
66
|
exchanges: [...exchanges.values()],
|
|
75
67
|
name: org.spec.name,
|
|
76
68
|
orgId: org.spec.id,
|
|
77
|
-
|
|
69
|
+
phonebook: org.spec.services.telephony.phonebook,
|
|
78
70
|
})
|
|
79
71
|
|
|
80
72
|
logger.debug('Added organization: %s (%s)', org.spec.name, org.spec.id)
|