un-cli 0.0.82 → 0.0.83
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/index.mjs +250 -15
- package/package.json +1 -1
- package/un.mjs +3 -3
- package/cmd.txt +0 -2
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.83";
|
|
11
11
|
const GENERATE_TOKEN_TIME_MIN = 30;
|
|
12
12
|
|
|
13
13
|
let rl = null;
|
|
@@ -178,9 +178,14 @@ const inputs = {
|
|
|
178
178
|
"export subnetworks --deleted": "Export all subnetworks with ACK that are deleted ",
|
|
179
179
|
"updateisconnected": "Run update is connected ",
|
|
180
180
|
"versions": "List all versions available to the current logged in user.",
|
|
181
|
+
"versions --summary": "Summary of versions.",
|
|
182
|
+
"versions --unreconciled": "List all versions that haven't been reconciled.",
|
|
183
|
+
"versions --version <version name>": "List the input version info",
|
|
181
184
|
"reconcile --version <version name>": "Reconcile the input version synchronously",
|
|
182
|
-
"reconcile --
|
|
183
|
-
"reconcile --all
|
|
185
|
+
"reconcile --withpost --version <version name>": "Reconcile & Post the input version synchronously, oldest common ancestor first",
|
|
186
|
+
"reconcile --all": "Reconcile all versions available to the current user synchronously, oldest common ancestor first",
|
|
187
|
+
"reconcile --all --withpost --async": "Reconcile and post all versions available to the current user asynchronously, oldest common ancestor first",
|
|
188
|
+
"reconcile --all --async": "Reconcile all versions available to the current user asynchronously, oldest common ancestor first",
|
|
184
189
|
"count": "Lists the number of rows in all feature layers and tables.",
|
|
185
190
|
"count --system": "Lists the number of rows in system layers.",
|
|
186
191
|
"connect --service": "Connects to the another service",
|
|
@@ -233,23 +238,100 @@ const inputs = {
|
|
|
233
238
|
|
|
234
239
|
console.table(serviceDef)
|
|
235
240
|
},
|
|
241
|
+
|
|
242
|
+
|
|
236
243
|
|
|
237
|
-
"^versions
|
|
244
|
+
"^versions --version": async (input) => {
|
|
245
|
+
|
|
238
246
|
|
|
247
|
+
const inputParam = input.match(/--version .*/gm)
|
|
248
|
+
let versionName = null;
|
|
249
|
+
if (inputParam != null && inputParam.length > 0)
|
|
250
|
+
versionName = inputParam[0].replace("--version ", "")
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
let versions = await un.versions();
|
|
254
|
+
versions.versions = versions.versions.filter ( v => v.versionName.toString().toUpperCase() == versionName.toUpperCase())
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
if (versions.versions.length === 0) {
|
|
258
|
+
logger.info("No versions found.")
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
const subs = versions.versions.sort ( (a,b)=> (a?.commonAncestorDate - b?.commonAncestorDate) ). map( (a) => {
|
|
262
|
+
return {"versionName": a.versionName, "Id": a.versionId, "guid" : a.versionGuid, "modified": new Date(a.modifiedDate), "common": a.commonAncestorDate ? new Date( a.commonAncestorDate) : 'N/A' , "reconciled": a.reconcileDate ? new Date(a.reconcileDate) : 'N/A'};
|
|
263
|
+
})
|
|
264
|
+
|
|
265
|
+
console.table(subs)
|
|
266
|
+
const rowCount = subs.length;
|
|
267
|
+
logger.info (`${numberWithCommas(rowCount)} rows returned.`)
|
|
268
|
+
},
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
"^versions --unreconciled$": async () => {
|
|
273
|
+
const versions = await un.versions();
|
|
274
|
+
if (versions.versions.length === 0) {
|
|
275
|
+
logger.info("No versions found.")
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const subs = versions.versions.filter( a => a.reconcileDate != null ).sort ( (a,b)=> (a?.commonAncestorDate - b?.commonAncestorDate) ). map( (a) => {
|
|
280
|
+
return {"versionName": a.versionName, "Id": a.versionId, "guid" : a.versionGuid, "modified": new Date(a.modifiedDate), "common": a.commonAncestorDate ? new Date( a.commonAncestorDate) : 'N/A' , "reconciled": a.reconcileDate ? new Date(a.reconcileDate) : 'N/A'};
|
|
281
|
+
})
|
|
282
|
+
|
|
283
|
+
console.table(subs)
|
|
284
|
+
const rowCount = subs.length;
|
|
285
|
+
logger.info (`${numberWithCommas(rowCount)} rows returned.`)
|
|
286
|
+
},
|
|
287
|
+
|
|
288
|
+
"^versions$": async () => {
|
|
239
289
|
const versions = await un.versions();
|
|
240
290
|
if (versions.versions.length === 0) {
|
|
241
291
|
logger.info("No versions found.")
|
|
242
292
|
return;
|
|
243
293
|
}
|
|
244
|
-
const subs = versions.versions.map( (a) => {
|
|
245
|
-
return {"versionName": a.versionName, "Id": a.versionId, "guid" : a.versionGuid, "
|
|
246
|
-
})
|
|
294
|
+
const subs = versions.versions.sort ( (a,b)=> (a?.commonAncestorDate - b?.commonAncestorDate) ). map( (a) => {
|
|
295
|
+
return {"versionName": a.versionName, "Id": a.versionId, "guid" : a.versionGuid, "modified": new Date(a.modifiedDate), "common": a.commonAncestorDate ? new Date( a.commonAncestorDate) : 'N/A' , "reconciled": a.reconcileDate ? new Date(a.reconcileDate) : 'N/A'};
|
|
296
|
+
})
|
|
247
297
|
|
|
248
298
|
console.table(subs)
|
|
249
299
|
const rowCount = subs.length;
|
|
250
300
|
logger.info (`${numberWithCommas(rowCount)} rows returned.`)
|
|
251
301
|
},
|
|
252
302
|
|
|
303
|
+
|
|
304
|
+
"^versions --summary$": async () => {
|
|
305
|
+
/*
|
|
306
|
+
total versions,
|
|
307
|
+
total unreconciled versions
|
|
308
|
+
total versions behind default
|
|
309
|
+
*/
|
|
310
|
+
const versions = await un.versions();
|
|
311
|
+
if (versions.versions.length === 0) {
|
|
312
|
+
logger.info("No versions found.")
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
const summary = {
|
|
317
|
+
"totalVersions": 0,
|
|
318
|
+
"unreconciledVersions": 0,
|
|
319
|
+
"versionsBehindDefault": 0,
|
|
320
|
+
"defaultMoment": 0
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
const defaultVersion = versions.versions.filter(v => v.versionName.toString().toUpperCase() === "SDE.DEFAULT")[0];
|
|
324
|
+
|
|
325
|
+
summary.totalVersions = versions.versions.length;
|
|
326
|
+
|
|
327
|
+
summary.unreconciledVersions = versions.versions.filter( a => a.reconcileDate != null ).length
|
|
328
|
+
|
|
329
|
+
summary.versionsBehindDefault = versions.versions.filter( a => defaultVersion.modifiedDate > a?.commonAncestorDate ).length
|
|
330
|
+
|
|
331
|
+
summary.defaultMoment = (new Date(defaultVersion.modifiedDate)).toString()
|
|
332
|
+
console.table(summary)
|
|
333
|
+
},
|
|
334
|
+
|
|
253
335
|
|
|
254
336
|
"^reconcile --version": async (input) => {
|
|
255
337
|
|
|
@@ -258,8 +340,14 @@ const inputs = {
|
|
|
258
340
|
if (inputParam != null && inputParam.length > 0)
|
|
259
341
|
versionName = inputParam[0].replace("--version ", "")
|
|
260
342
|
|
|
261
|
-
|
|
343
|
+
let versions = await un.versions();
|
|
344
|
+
versions.versions = versions.versions.filter ( v => v.versionName.toString().toUpperCase() == versionName.toUpperCase())
|
|
262
345
|
|
|
346
|
+
if (versions.versions.length ==0 )
|
|
347
|
+
{
|
|
348
|
+
logger.info (`Version not found ${versionName}`)
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
263
351
|
for (let v = 0; v < versions.versions.length; v++)
|
|
264
352
|
{
|
|
265
353
|
if (versions.versions[v].versionName.toString().toUpperCase() === "SDE.DEFAULT") continue;
|
|
@@ -271,19 +359,55 @@ const inputs = {
|
|
|
271
359
|
break;
|
|
272
360
|
}
|
|
273
361
|
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
logger.info (`Reconciled ${versionName}`)
|
|
365
|
+
},
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
"^reconcile --withpost --version": async (input) => {
|
|
370
|
+
|
|
371
|
+
const inputParam = input.match(/--version .*/gm)
|
|
372
|
+
let versionName = null;
|
|
373
|
+
if (inputParam != null && inputParam.length > 0)
|
|
374
|
+
versionName = inputParam[0].replace("--version ", "")
|
|
375
|
+
|
|
376
|
+
let versions = await un.versions()
|
|
377
|
+
versions.versions = versions.versions.filter ( v => v.versionName.toString().toUpperCase() == versionName.toUpperCase())
|
|
378
|
+
|
|
379
|
+
if (versions.versions.length ==0 )
|
|
380
|
+
{
|
|
381
|
+
logger.info (`Version not found ${versionName}`)
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
for (let v = 0; v < versions.versions.length; v++)
|
|
386
|
+
{
|
|
387
|
+
if (versions.versions[v].versionName.toString().toUpperCase() === "SDE.DEFAULT") continue;
|
|
388
|
+
if (versions.versions[v].versionName.toString().toUpperCase() == versionName.toUpperCase()) {
|
|
389
|
+
logger.info (`Reconciling and Posting version ${versions.versions[v].versionName} Common Ancestor ${new Date(versions.versions[v].commonAncestorDate)} ...`)
|
|
390
|
+
|
|
391
|
+
const result = await un.reconcile(versions.versions[v].versionGuid, true, false, true, false);
|
|
392
|
+
logger.info(JSON.stringify(result))
|
|
393
|
+
break;
|
|
394
|
+
}
|
|
395
|
+
|
|
274
396
|
}
|
|
275
|
-
logger.info (`Reconciled ${versionName}.`)
|
|
397
|
+
logger.info (`Reconciled and Posted ${versionName}.`)
|
|
276
398
|
},
|
|
277
399
|
|
|
400
|
+
|
|
278
401
|
|
|
279
402
|
"^reconcile --all$": async () => {
|
|
280
403
|
|
|
281
|
-
|
|
404
|
+
let versions = await un.versions()
|
|
405
|
+
versions.versions = versions.versions.sort ( (a,b)=> (a?.commonAncestorDate - b?.commonAncestorDate) )
|
|
282
406
|
|
|
283
407
|
for (let v = 0; v < versions.versions.length; v++)
|
|
284
408
|
{
|
|
285
409
|
if (versions.versions[v].versionName.toString().toUpperCase() === "SDE.DEFAULT") continue;
|
|
286
|
-
|
|
410
|
+
logger.info (`Reconciling version ${versions.versions[v].versionName} Common Ancestor ${new Date(versions.versions[v].commonAncestorDate)} ...`)
|
|
287
411
|
|
|
288
412
|
const result = await un.reconcile(versions.versions[v].versionGuid, false, false, true, false);
|
|
289
413
|
logger.info(JSON.stringify(result))
|
|
@@ -294,12 +418,13 @@ const inputs = {
|
|
|
294
418
|
|
|
295
419
|
"^reconcile --all --async$": async () => {
|
|
296
420
|
//async
|
|
297
|
-
|
|
421
|
+
let versions = await un.versions()
|
|
422
|
+
versions.versions = versions.versions.sort ( (a,b)=> (a?.commonAncestorDate - b?.commonAncestorDate) )
|
|
298
423
|
|
|
299
424
|
for (let v = 0; v < versions.versions.length; v++)
|
|
300
425
|
{
|
|
301
426
|
if (versions.versions[v].versionName.toString().toUpperCase() === "SDE.DEFAULT") continue;
|
|
302
|
-
|
|
427
|
+
logger.info (`Reconciling version ${versions.versions[v].versionName} Common Ancestor ${new Date(versions.versions[v].commonAncestorDate)} ...`)
|
|
303
428
|
|
|
304
429
|
const result = await un.reconcile(versions.versions[v].versionGuid, false, false, true, true);
|
|
305
430
|
logger.info(JSON.stringify(result))
|
|
@@ -308,7 +433,23 @@ const inputs = {
|
|
|
308
433
|
logger.info (`Reconciled ${numberWithCommas(rowCount)} versions.`)
|
|
309
434
|
},
|
|
310
435
|
|
|
311
|
-
|
|
436
|
+
"^reconcile --all --withpost --async$": async () => {
|
|
437
|
+
//async
|
|
438
|
+
let versions = await un.versions()
|
|
439
|
+
versions.versions = versions.versions.sort ( (a,b)=> (a?.commonAncestorDate - b?.commonAncestorDate) )
|
|
440
|
+
|
|
441
|
+
for (let v = 0; v < versions.versions.length; v++)
|
|
442
|
+
{
|
|
443
|
+
if (versions.versions[v].versionName.toString().toUpperCase() === "SDE.DEFAULT") continue;
|
|
444
|
+
logger.info (`Reconciling & Posting version ${versions.versions[v].versionName} Common Ancestor ${new Date(versions.versions[v].commonAncestorDate)} ...`)
|
|
445
|
+
|
|
446
|
+
const result = await un.reconcile(versions.versions[v].versionGuid, true, false, true, true);
|
|
447
|
+
logger.info(JSON.stringify(result))
|
|
448
|
+
}
|
|
449
|
+
const rowCount = versions.versions.length;
|
|
450
|
+
logger.info (`Reconciled & Posted ${numberWithCommas(rowCount)} versions.`)
|
|
451
|
+
},
|
|
452
|
+
|
|
312
453
|
"^versions --disconnect$": async () => {
|
|
313
454
|
//disconnect all versions
|
|
314
455
|
const versions = await un.versions();
|
|
@@ -1007,7 +1148,19 @@ const inputs = {
|
|
|
1007
1148
|
},
|
|
1008
1149
|
|
|
1009
1150
|
|
|
1010
|
-
|
|
1151
|
+
"^reconcilelogs --age" : async input => {
|
|
1152
|
+
const topLogCount = 1000;
|
|
1153
|
+
const pageSize = 10000
|
|
1154
|
+
|
|
1155
|
+
const inputParam = input.match(/--age .*/gm)
|
|
1156
|
+
let mins = 30; //query logs for the last 30 minutes
|
|
1157
|
+
if (inputParam != null && inputParam.length > 0)
|
|
1158
|
+
mins = inputParam[0].replace("--age ", "")
|
|
1159
|
+
|
|
1160
|
+
|
|
1161
|
+
reconcileLogs(mins, parameters.service)
|
|
1162
|
+
|
|
1163
|
+
},
|
|
1011
1164
|
"^validatelogs --age": async input => {
|
|
1012
1165
|
|
|
1013
1166
|
const topLogCount = 1000;
|
|
@@ -1553,6 +1706,88 @@ function decodeHTMLEntities (x) {
|
|
|
1553
1706
|
}
|
|
1554
1707
|
|
|
1555
1708
|
|
|
1709
|
+
|
|
1710
|
+
async function reconcileLogs (mins, service) {
|
|
1711
|
+
|
|
1712
|
+
|
|
1713
|
+
parameters.service = service
|
|
1714
|
+
|
|
1715
|
+
|
|
1716
|
+
console.log(`Querying reconcile logs for ${parameters.service} for the last ${mins} minutes ...`)
|
|
1717
|
+
|
|
1718
|
+
//startTime is the most recent
|
|
1719
|
+
//endTime is the oldest
|
|
1720
|
+
|
|
1721
|
+
|
|
1722
|
+
//page query the admin log , search for /applyEdits logs by methodname
|
|
1723
|
+
let allMessages = await adminLog.query(mins, parameters.service, [102003,102024,102023], "", "DEBUG")
|
|
1724
|
+
|
|
1725
|
+
|
|
1726
|
+
|
|
1727
|
+
//build out the dictionary, key is request id, value is another dictionary
|
|
1728
|
+
const queryLogs = {}
|
|
1729
|
+
//sort by time
|
|
1730
|
+
allMessages = allMessages.sort ( (m1, m2) => m2.time - m1.time )
|
|
1731
|
+
allMessages.forEach (m => {
|
|
1732
|
+
|
|
1733
|
+
if (!queryLogs[m.requestID])
|
|
1734
|
+
queryLogs[m.requestID] = {"message": "Time,Method,Elapsed_ms,Message"}
|
|
1735
|
+
|
|
1736
|
+
queryLogs[m.requestID].message += "\r\n" + m.time + "," + m.methodName + "," + Math.round(m.elapsed*1000) + "," + m.message
|
|
1737
|
+
|
|
1738
|
+
//get elapsed
|
|
1739
|
+
//check for async (method GPReconcileVersionAsync::Execute)
|
|
1740
|
+
//sync
|
|
1741
|
+
//VersionManagementServer::HandleREST_ReconcileOperation
|
|
1742
|
+
//message Returned moment:
|
|
1743
|
+
if (m.message.indexOf("Returned moment: ")> -1 &&
|
|
1744
|
+
( m.methodName.indexOf("VersionManagementServer::HandleREST_ReconcileOperation") > -1 ||
|
|
1745
|
+
m.methodName.indexOf("GPReconcileVersionAsync::Execute") > -1
|
|
1746
|
+
)
|
|
1747
|
+
)
|
|
1748
|
+
{
|
|
1749
|
+
queryLogs[m.requestID].elapsed = m.elapsed
|
|
1750
|
+
queryLogs[m.requestID].source = m.source.replace(".MapServer", "")
|
|
1751
|
+
queryLogs[m.requestID].user = m.user
|
|
1752
|
+
queryLogs[m.requestID].time = m.time
|
|
1753
|
+
queryLogs[m.requestID].requestID = m.requestID
|
|
1754
|
+
queryLogs[m.requestID].methodName = m.methodName
|
|
1755
|
+
|
|
1756
|
+
}
|
|
1757
|
+
|
|
1758
|
+
if (m.message.indexOf("EndReconcile;") > -1)
|
|
1759
|
+
{
|
|
1760
|
+
queryLogs[m.requestID].gdbVersion = m.message.replace("EndReconcile;","")
|
|
1761
|
+
|
|
1762
|
+
|
|
1763
|
+
}
|
|
1764
|
+
|
|
1765
|
+
|
|
1766
|
+
|
|
1767
|
+
})
|
|
1768
|
+
|
|
1769
|
+
allMessages = []
|
|
1770
|
+
|
|
1771
|
+
Object.keys(queryLogs).forEach(k =>
|
|
1772
|
+
{
|
|
1773
|
+
const m = queryLogs[k]
|
|
1774
|
+
if (m.methodName)
|
|
1775
|
+
allMessages.push(m)
|
|
1776
|
+
|
|
1777
|
+
})
|
|
1778
|
+
|
|
1779
|
+
|
|
1780
|
+
|
|
1781
|
+
console.log ("Filtering messages...")
|
|
1782
|
+
|
|
1783
|
+
allMessages = filterMessages(allMessages)
|
|
1784
|
+
.sort( (m1,m2) => Math.round(m2.elapsed*1000) -Math.round(m1.elapsed*1000))
|
|
1785
|
+
console.table(allMessages)
|
|
1786
|
+
|
|
1787
|
+
}
|
|
1788
|
+
|
|
1789
|
+
|
|
1790
|
+
|
|
1556
1791
|
function printFishnet(fishnet) {
|
|
1557
1792
|
|
|
1558
1793
|
//y is flipped x is ok
|
package/package.json
CHANGED
package/un.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env node --experimental-modules
|
|
2
|
-
|
|
3
|
-
import {run} from "./index.mjs"
|
|
1
|
+
#!/usr/bin/env node --experimental-modules
|
|
2
|
+
|
|
3
|
+
import {run} from "./index.mjs"
|
|
4
4
|
run();
|
package/cmd.txt
DELETED