un-cli 0.0.74 → 0.0.75
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/cmd.txt +1 -1
- package/index.html +1 -17
- package/index.mjs +58 -4
- package/makerequest.mjs +7 -4
- package/package.json +1 -1
- package/un.mjs +0 -0
- package/utilitynetwork.node.mjs +90 -8
package/cmd.txt
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
updateisconnected
|
|
2
2
|
exit
|
package/index.html
CHANGED
|
@@ -451,8 +451,6 @@ async function loadSQLLogs () {
|
|
|
451
451
|
let i =0;
|
|
452
452
|
|
|
453
453
|
const header = document.createElement("tr");
|
|
454
|
-
const thead = docuemnt.createElement("thead")
|
|
455
|
-
thead.appendChild(header)
|
|
456
454
|
const cService = document.createElement("th");
|
|
457
455
|
cService.textContent = "Source"
|
|
458
456
|
const cTime = document.createElement("th");
|
|
@@ -693,21 +691,7 @@ function numberWithCommas(x) {
|
|
|
693
691
|
}
|
|
694
692
|
|
|
695
693
|
|
|
696
|
-
|
|
697
|
-
function sortTable(table, col, reverse) {
|
|
698
|
-
var tb = table.tBodies[0], // use `<tbody>` to ignore `<thead>` and `<tfoot>` rows
|
|
699
|
-
tr = Array.prototype.slice.call(tb.rows, 0), // put rows into array
|
|
700
|
-
i;
|
|
701
|
-
reverse = -((+reverse) || -1);
|
|
702
|
-
tr = tr.sort(function (a, b) { // sort rows
|
|
703
|
-
return reverse // `-1 *` if want opposite order
|
|
704
|
-
* (a.cells[col].textContent.trim() // using `.textContent.trim()` for test
|
|
705
|
-
.localeCompare(b.cells[col].textContent.trim())
|
|
706
|
-
);
|
|
707
|
-
});
|
|
708
|
-
for(i = 0; i < tr.length; ++i) tb.appendChild(tr[i]); // append each row in order
|
|
709
|
-
}
|
|
710
|
-
|
|
694
|
+
|
|
711
695
|
|
|
712
696
|
</script>
|
|
713
697
|
</body>
|
package/index.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import { AdminLog } from "./adminlog.mjs"
|
|
|
7
7
|
import logger from "./logger.mjs"
|
|
8
8
|
import fetch from "node-fetch"
|
|
9
9
|
//update version
|
|
10
|
-
let version = "0.0.
|
|
10
|
+
let version = "0.0.75";
|
|
11
11
|
const GENERATE_TOKEN_TIME_MIN = 30;
|
|
12
12
|
|
|
13
13
|
let rl = null;
|
|
@@ -175,6 +175,8 @@ const inputs = {
|
|
|
175
175
|
"export subnetworks --all [--folder]": "Export all subnetworks with ACK --folder where exported files are saved",
|
|
176
176
|
"export subnetworks --new [--folder]": "Export all subnetworks with ACK that haven't been exported --folder where exported files are saved",
|
|
177
177
|
"export subnetworks --deleted": "Export all subnetworks with ACK that are deleted ",
|
|
178
|
+
"updateisconnected": "Run update is connected ",
|
|
179
|
+
|
|
178
180
|
"count": "Lists the number of rows in all feature layers.",
|
|
179
181
|
"count --system": "Lists the number of rows in system layers.",
|
|
180
182
|
"connect --service": "Connects to the another service",
|
|
@@ -277,6 +279,16 @@ const inputs = {
|
|
|
277
279
|
result.duration = numberWithCommas(Math.round(timeEnable)) + " ms"
|
|
278
280
|
console.table(result)
|
|
279
281
|
},
|
|
282
|
+
|
|
283
|
+
"^updateisconnected$": async () => {
|
|
284
|
+
const fromDate = new Date();
|
|
285
|
+
logger.info("Updating is connected ...");
|
|
286
|
+
const result = await un.updateIsConnected()
|
|
287
|
+
const toDate = new Date();
|
|
288
|
+
const timeEnable = toDate.getTime() - fromDate.getTime();
|
|
289
|
+
result.duration = numberWithCommas(Math.round(timeEnable)) + " ms"
|
|
290
|
+
console.table(result)
|
|
291
|
+
},
|
|
280
292
|
"^evaluate$": async () => {
|
|
281
293
|
const fromDate = new Date();
|
|
282
294
|
logger.info("Building Evaluation Blocks ...");
|
|
@@ -464,6 +476,8 @@ const inputs = {
|
|
|
464
476
|
"^export subnetworks --all --folder .*$|^export subnetworks --all$" : async input => {
|
|
465
477
|
|
|
466
478
|
let subnetworks
|
|
479
|
+
let sort = "asc";
|
|
480
|
+
if (input.indexOf("--desc") > 0) sort = "desc"
|
|
467
481
|
//create folder
|
|
468
482
|
const file = input.match(/--folder .*/gm)
|
|
469
483
|
let inputDir = "Exported"
|
|
@@ -481,7 +495,7 @@ const inputs = {
|
|
|
481
495
|
exportedSubnetworksWhereClause = " AND SUBNETWORKNAME NOT IN (" + exportedSubnetworks.join(",") + ")"
|
|
482
496
|
|
|
483
497
|
logger.info("Querying all subnetworks that are clean.");
|
|
484
|
-
subnetworks = await un.queryDistinct(500002, "domainnetworkname,tiername,subnetworkname", "isdirty=0 " + exportedSubnetworksWhereClause
|
|
498
|
+
subnetworks = await un.queryDistinct(500002, "domainnetworkname,tiername,subnetworkname", "isdirty=0 " + exportedSubnetworksWhereClause,`domainnetworkname ${sort},tiername ${sort},subnetworkname ${sort}`);
|
|
485
499
|
logger.info(`Discovered ${subnetworks.features.length} subnetworks that can be exported.`);
|
|
486
500
|
for (let i = 0; i < subnetworks.features.length; i++) {
|
|
487
501
|
const f = subnetworks.features[i]
|
|
@@ -572,9 +586,13 @@ const inputs = {
|
|
|
572
586
|
},
|
|
573
587
|
"^trace --subnetwork": async input => {
|
|
574
588
|
//get subnetwork name
|
|
589
|
+
try {
|
|
575
590
|
|
|
591
|
+
|
|
576
592
|
const fromDate = new Date();
|
|
577
|
-
|
|
593
|
+
const inputDir= "Exported"
|
|
594
|
+
let full = true;
|
|
595
|
+
// if (input.indexOf("--full") > 0) full = true
|
|
578
596
|
|
|
579
597
|
const inputParam = input.match(/--subnetwork .*/gm)
|
|
580
598
|
let subnetworkName = null;
|
|
@@ -592,8 +610,44 @@ const inputs = {
|
|
|
592
610
|
const newResult = {}
|
|
593
611
|
newResult.duration = numberWithCommas(Math.round(timeRun)) + " ms"
|
|
594
612
|
newResult.elementsCount = result.traceResults.elements.length;
|
|
595
|
-
|
|
613
|
+
const traceRes = {}
|
|
614
|
+
logger.info("Grouping trace results...")
|
|
615
|
+
result.traceResults.elements.forEach(e => {
|
|
616
|
+
const layerid = un.getLayerIdfromSourceId(e.networkSourceId).layerId
|
|
617
|
+
if (!traceRes["l" + layerid])
|
|
618
|
+
traceRes["l" + layerid] = []
|
|
619
|
+
traceRes["l" + layerid].push(e.objectId)
|
|
620
|
+
|
|
621
|
+
})
|
|
622
|
+
console.table(newResult)
|
|
623
|
+
|
|
624
|
+
//if the trace is full turn around the pull all features
|
|
625
|
+
if (full){
|
|
626
|
+
|
|
627
|
+
//loop through all layers and query
|
|
628
|
+
logger.info("Removing duplicates")
|
|
629
|
+
|
|
630
|
+
console.log(traceRes)
|
|
631
|
+
|
|
632
|
+
//send all queries async
|
|
633
|
+
const allQueries = []
|
|
634
|
+
Object.keys(traceRes).forEach (k => {
|
|
635
|
+
traceRes[k] = [...new Set(traceRes[k])]
|
|
636
|
+
allQueries.push(un.query(k.replace("l",""), "", k, traceRes[k]))
|
|
637
|
+
})
|
|
638
|
+
logger.info(`${Object.keys(traceRes)} queries sent, waiting for response..`)
|
|
639
|
+
const result = await Promise.all(allQueries)
|
|
640
|
+
logger.info("All queries returned.")
|
|
641
|
+
fs.writeFileSync(`${inputDir}/traceout${subnetworkName}.json`, JSON.stringify(result))
|
|
642
|
+
logger.info(`Result written to file ${inputDir}/traceout${subnetworkName}.json`)
|
|
596
643
|
|
|
644
|
+
//logger.info(JSON.stringify(result))
|
|
645
|
+
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
catch(ex){
|
|
649
|
+
logger.error(JSON.stringify(ex))
|
|
650
|
+
}
|
|
597
651
|
},
|
|
598
652
|
"^export subnetworks --deleted$" : async input => {
|
|
599
653
|
|
package/makerequest.mjs
CHANGED
|
@@ -28,25 +28,28 @@ export function makeRequest (opts) {
|
|
|
28
28
|
|
|
29
29
|
let f;
|
|
30
30
|
try {
|
|
31
|
+
|
|
31
32
|
const nodeFetch = await import ("node-fetch");
|
|
32
33
|
f = nodeFetch.default;
|
|
33
34
|
}
|
|
34
35
|
catch(ex) {
|
|
35
36
|
f = fetch;
|
|
36
37
|
}
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
|
|
39
|
+
let jsonRes
|
|
40
|
+
|
|
39
41
|
const result = await f(opts.url, {
|
|
40
42
|
"method" : opts.method,
|
|
41
43
|
"headers": headers,
|
|
42
44
|
"body": params
|
|
43
45
|
});
|
|
44
46
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
jsonRes = await result.json();
|
|
48
|
+
|
|
47
49
|
if (typeof jsonRes !== "object")
|
|
48
50
|
jsonRes = JSON.parse(jsonRes);
|
|
49
51
|
|
|
52
|
+
|
|
50
53
|
resolve(jsonRes);
|
|
51
54
|
|
|
52
55
|
}
|
package/package.json
CHANGED
package/un.mjs
CHANGED
|
File without changes
|
package/utilitynetwork.node.mjs
CHANGED
|
@@ -21,12 +21,14 @@ export class UtilityNetwork {
|
|
|
21
21
|
this.featureServiceUrl = featureServiceUrl;
|
|
22
22
|
this.token = token;
|
|
23
23
|
this.gdbVersion = gdbVersion;
|
|
24
|
+
this.sourceMapping = {}
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
///first function one should call after creating an instance of a utility network
|
|
27
28
|
load ()
|
|
28
29
|
{
|
|
29
30
|
let thisObj = this;
|
|
31
|
+
|
|
30
32
|
return new Promise (function (resolve, reject)
|
|
31
33
|
{
|
|
32
34
|
//run async mode
|
|
@@ -68,7 +70,30 @@ export class UtilityNetwork {
|
|
|
68
70
|
|
|
69
71
|
thisObj.dataElement = undataElement.layerDataElements[0].dataElement;
|
|
70
72
|
thisObj.layerDefinition = unLayerDef
|
|
71
|
-
thisObj.subnetLineLayerId = thisObj.getSubnetLineLayerId();
|
|
73
|
+
thisObj.subnetLineLayerId = thisObj.getSubnetLineLayerId();
|
|
74
|
+
|
|
75
|
+
//build out source mapping hash
|
|
76
|
+
let domainNetworks = thisObj.dataElement.domainNetworks;
|
|
77
|
+
let layerObj = undefined;
|
|
78
|
+
|
|
79
|
+
for (let i = 0; i < domainNetworks.length; i ++)
|
|
80
|
+
{
|
|
81
|
+
let domainNetwork = domainNetworks[i];
|
|
82
|
+
for (let j = 0; j < domainNetwork.junctionSources.length; j ++)
|
|
83
|
+
{
|
|
84
|
+
layerObj = {type: domainNetwork.junctionSources[j].shapeType, layerId: domainNetwork.junctionSources[j].layerId}
|
|
85
|
+
layerObj.type = layerObj.type.replace("esriGeometry", "").toLowerCase();
|
|
86
|
+
thisObj.sourceMapping["s" + domainNetwork.junctionSources[j].sourceId] = layerObj
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
for (let j = 0; j < domainNetwork.edgeSources.length; j ++)
|
|
90
|
+
{
|
|
91
|
+
layerObj = {type: domainNetwork.edgeSources[j].shapeType, layerId: domainNetwork.edgeSources[j].layerId}
|
|
92
|
+
layerObj.type = layerObj.type.replace("esriGeometry", "").toLowerCase();
|
|
93
|
+
thisObj.sourceMapping["s" + domainNetwork.edgeSources[j].sourceId] = layerObj
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
72
97
|
resolve(thisObj);
|
|
73
98
|
}
|
|
74
99
|
else
|
|
@@ -333,16 +358,49 @@ export class UtilityNetwork {
|
|
|
333
358
|
if (objectids != undefined)
|
|
334
359
|
queryJson.objectIds = objectids;
|
|
335
360
|
queryJson.layerId = layerId
|
|
336
|
-
return new Promise((resolve, reject) => {
|
|
361
|
+
return new Promise(async(resolve, reject) => {
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
let rowsJson;
|
|
366
|
+
let allRowsJson;
|
|
367
|
+
let recordOffset = 0;
|
|
368
|
+
|
|
369
|
+
try {
|
|
370
|
+
|
|
371
|
+
do {
|
|
372
|
+
queryJson.resultOffset = recordOffset;
|
|
373
|
+
rowsJson = await makeRequest({method: 'POST', params: queryJson, url: this.featureServiceUrl + "/" + layerId + "/query"}) ;
|
|
374
|
+
recordOffset = recordOffset + resultRecordCount + 1;
|
|
375
|
+
rowsJson.obj = obj;
|
|
376
|
+
|
|
377
|
+
if (!allRowsJson)
|
|
378
|
+
allRowsJson = rowsJson
|
|
379
|
+
else
|
|
380
|
+
allRowsJson?.features.push(...rowsJson?.features)
|
|
381
|
+
//page the result until done
|
|
382
|
+
}
|
|
383
|
+
while(rowsJson?.exceededTransferLimit == true)
|
|
384
|
+
|
|
385
|
+
resolve(allRowsJson);
|
|
386
|
+
}
|
|
387
|
+
catch(ex){
|
|
388
|
+
reject("failed to query" + JSON.stringify(ex))
|
|
389
|
+
}
|
|
337
390
|
|
|
338
|
-
makeRequest({method: 'POST', params: queryJson, url: this.featureServiceUrl + "/" + layerId + "/query"}).then(rowsJson=> {
|
|
339
|
-
rowsJson.obj = obj;
|
|
340
|
-
resolve(rowsJson);
|
|
341
|
-
}).catch(rej => reject("failed to query"));
|
|
342
391
|
|
|
392
|
+
|
|
393
|
+
|
|
343
394
|
});
|
|
344
395
|
|
|
345
|
-
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
// }
|
|
399
|
+
// while(jsonRes?.exceededTransferLimit == true)
|
|
400
|
+
// if (!allJsonRes)
|
|
401
|
+
// allJsonRes = jsonRes
|
|
402
|
+
// else
|
|
403
|
+
// allJsonRes?.features.push(...jsonRes?.features)
|
|
346
404
|
}
|
|
347
405
|
//get the terminal configuration using the id
|
|
348
406
|
getTerminalConfiguration(terminalConfigurationId)
|
|
@@ -538,8 +596,10 @@ export class UtilityNetwork {
|
|
|
538
596
|
//get layer id from Source Id used to map sourceid to layer id
|
|
539
597
|
getLayerIdfromSourceId(sourceId)
|
|
540
598
|
{
|
|
599
|
+
|
|
600
|
+
return this.sourceMapping["s" + sourceId]
|
|
601
|
+
/*
|
|
541
602
|
let domainNetworks = this.dataElement.domainNetworks;
|
|
542
|
-
let layerObj = undefined;
|
|
543
603
|
|
|
544
604
|
for (let i = 0; i < domainNetworks.length; i ++)
|
|
545
605
|
{
|
|
@@ -561,6 +621,7 @@ export class UtilityNetwork {
|
|
|
561
621
|
|
|
562
622
|
if (layerObj != undefined)
|
|
563
623
|
layerObj.type = layerObj.type.replace("esriGeometry", "").toLowerCase();
|
|
624
|
+
*/
|
|
564
625
|
|
|
565
626
|
return layerObj;
|
|
566
627
|
}
|
|
@@ -958,6 +1019,27 @@ export class UtilityNetwork {
|
|
|
958
1019
|
|
|
959
1020
|
|
|
960
1021
|
|
|
1022
|
+
updateIsConnected(async=false) {
|
|
1023
|
+
|
|
1024
|
+
let thisObj = this;
|
|
1025
|
+
let ar = thisObj.featureServiceUrl.split("/");
|
|
1026
|
+
ar[ar.length-1]="UtilityNetworkServer";
|
|
1027
|
+
let updateisconnectedURL = ar.join("/") + "/updateIsConnected"
|
|
1028
|
+
|
|
1029
|
+
let payload = {
|
|
1030
|
+
f: "json",
|
|
1031
|
+
token: this.token,
|
|
1032
|
+
async: async
|
|
1033
|
+
}
|
|
1034
|
+
let un = this;
|
|
1035
|
+
|
|
1036
|
+
return makeRequest({method:'POST', params: payload, url: updateisconnectedURL })
|
|
1037
|
+
|
|
1038
|
+
|
|
1039
|
+
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
|
|
961
1043
|
updateSubnetworks(domainNetworkName, tierName, subnetworkName, async=false) {
|
|
962
1044
|
|
|
963
1045
|
let thisObj = this;
|