un-cli 0.0.80 → 0.0.82

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/README.md CHANGED
@@ -14,12 +14,14 @@ npm install -g un-cli
14
14
  ## Once installed here is how you connect
15
15
 
16
16
  ```bash
17
- > uncli --portal https://utilitynetwork.esri.com/portal --service NapervilleElectric_SQLServer --user tester --password tester.108
17
+ > uncli --portal https://utilitynetwork.esri.com/portal --service NapervilleElectric_SQLServer --user tester --password tester.108 --verify true
18
18
  ```
19
+ If this fails with a verification error it means you are using a self-signed certificate you can use use --verify false to disable verification but don't use this in production.
19
20
 
20
21
  ```bash
21
22
 
22
23
  uncli> help
24
+
23
25
  ┌───────────────────────────────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
24
26
  │ (index) │ Values │
25
27
  ├───────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
@@ -40,10 +42,15 @@ uncli> help
40
42
  │ update subnetworks --all │ 'Update all dirty subnetworks synchronously' │
41
43
  │ update subnetworks --deleted │ 'Update all deleted dirty subnetworks synchronously' │
42
44
  │ update subnetworks --all --async │ 'Update all dirty subnetworks asynchronously' │
43
- export subnetworks --all 'Export all subnetworks with ACK '
44
- export subnetworks --new "Export all subnetworks with ACK that haven't been exported "
45
+ export subnetworks --all [--folder] 'Export all subnetworks with ACK --folder where exported files are saved'
46
+ export subnetworks --new [--folder] "Export all subnetworks with ACK that haven't been exported --folder where exported files are saved"
45
47
  │ export subnetworks --deleted │ 'Export all subnetworks with ACK that are deleted ' │
46
- count 'Lists the number of rows in all feature layers.'
48
+ updateisconnected 'Run update is connected '
49
+ │ versions │ 'List all versions available to the current logged in user.' │
50
+ │ reconcile --version <version name> │ 'Reconcile the input version synchronously' │
51
+ │ reconcile --all │ 'Reconcile all versions available to the current user synchronously' │
52
+ │ reconcile --all --async │ 'Reconcile all versions available to the current user asynchronously' │
53
+ │ count │ 'Lists the number of rows in all feature layers and tables.' │
47
54
  │ count --system │ 'Lists the number of rows in system layers.' │
48
55
  │ connect --service │ 'Connects to the another service' │
49
56
  │ tracelogs --age <minutes> │ 'Lists utility network trace summary logs for the last x minutes (requires admin)' │
package/adminlog.mjs CHANGED
@@ -20,6 +20,8 @@ export class AdminLog {
20
20
  return fetch;
21
21
  }
22
22
  }
23
+
24
+
23
25
  async query (codes, serviceName ="*", pageSize = 100000, startTime = null, endTime = null, logLevel = "DEBUG")
24
26
  {
25
27
  const url = this.adminServerUrl + "/logs/query?f=pjson"
package/cmd.txt CHANGED
@@ -1,2 +1,2 @@
1
- reconcile --version U136967.MigrateTransm
1
+ arlogs --age 10
2
2
  exit
package/index.html CHANGED
@@ -2144,6 +2144,11 @@ function numberWithCommas(x) {
2144
2144
  })
2145
2145
  }
2146
2146
 
2147
+ function decodeHTMLEntities (x) {
2148
+ const decodedString = document.createElement('div');
2149
+ decodedString.innerHTML = x;
2150
+ return decodedString.innerHTML;
2151
+ }
2147
2152
 
2148
2153
  //paging works from newer message walking to the oldest message
2149
2154
  //start time must be less than end time
@@ -2190,7 +2195,11 @@ function numberWithCommas(x) {
2190
2195
  let jsonRes = await result.json()
2191
2196
  let allMessages = [].concat(jsonRes.logMessages)
2192
2197
  allMessages = allMessages.filter(m => m.message.indexOf(messageFilter) > -1 && m.methodName.indexOf(methodFilter) > -1)
2193
-
2198
+ //add decode html
2199
+ allMessages = allMessages.map(m=> {
2200
+ m.message = decodeHTMLEntities(m.message)
2201
+ return m
2202
+ })
2194
2203
  let oldStart = undefined;
2195
2204
  let newStartTime = undefined;
2196
2205
  while (jsonRes.hasMore && !stop)
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.80";
10
+ let version = "0.0.82";
11
11
  const GENERATE_TOKEN_TIME_MIN = 30;
12
12
 
13
13
  let rl = null;
@@ -27,7 +27,8 @@ function parseInput(){
27
27
  "--gdbversion",
28
28
  "--file",
29
29
  "--verify",
30
- "--server"
30
+ "--server",
31
+ "--proxy"
31
32
  ]
32
33
 
33
34
  //null marked parmaters are required
@@ -40,7 +41,8 @@ function parseInput(){
40
41
  "gdbversion": "SDE.DEFAULT",
41
42
  "file": "",
42
43
  "verify": "true",
43
- "server": undefined
44
+ "server": undefined,
45
+ "proxy": undefined
44
46
  }
45
47
 
46
48
  for (let i = 0; i < process.argv.length ; i++){
@@ -53,7 +55,7 @@ function parseInput(){
53
55
 
54
56
  if (Object.values(params).includes(null))
55
57
  {
56
- logger.info ("HELP: uncli --portal https://unportal.domain.com/portal --service servicename --user username --password password [--gdbversion* user.version --server https://federatedserver.domain.com/server --file commandfile* --verify true|false]")
58
+ logger.info ("HELP: uncli --portal https://unportal.domain.com/portal --service servicename --user username --password password [--gdbversion* user.version --server https://federatedserver.domain.com/server --file commandfile* --verify true|false] --proxy http://proxyurl:port")
57
59
  logger.info("--file commandfile is optional and you can pass a path to a file with a list of command to execute. ")
58
60
  logger.info("--gdbversion is optional and allows the UN to be opened in that version. When not specified sde.DEFAULT is used.")
59
61
  logger.info("--server is optional except when there are more than one federated server sites to the portal. If the portal only has one server it will be selected.")
@@ -176,6 +178,9 @@ const inputs = {
176
178
  "export subnetworks --deleted": "Export all subnetworks with ACK that are deleted ",
177
179
  "updateisconnected": "Run update is connected ",
178
180
  "versions": "List all versions available to the current logged in user.",
181
+ "reconcile --version <version name>": "Reconcile the input version synchronously",
182
+ "reconcile --all": "Reconcile all versions available to the current user synchronously",
183
+ "reconcile --all --async": "Reconcile all versions available to the current user asynchronously",
179
184
  "count": "Lists the number of rows in all feature layers and tables.",
180
185
  "count --system": "Lists the number of rows in system layers.",
181
186
  "connect --service": "Connects to the another service",
@@ -926,7 +931,7 @@ const inputs = {
926
931
 
927
932
  const arMessages = allMessages
928
933
  .filter(m => m.message.indexOf("Attribute rule execution complete:") > -1)
929
- .map (m => JSON.parse(m.message.replace("Attribute rule execution complete:", "")))
934
+ .map (m => JSON.parse(decodeHTMLEntities(m.message.replace("Attribute rule execution complete:", ""))))
930
935
  .map( m => {
931
936
  m["Elapsed Time (ms)"] = Math.round(m["Elapsed Time"]*1000000)/1000
932
937
  // m["Arcade Evaluation Time:"] = Math.round(m["Arcade Evaluation Time:"]*1000,6)
@@ -1274,7 +1279,7 @@ const inputs = {
1274
1279
 
1275
1280
  const arMessages = allMessages
1276
1281
  .filter(m => m.message.indexOf("Attribute rule execution complete:") > -1)
1277
- .map (m => JSON.parse(m.message.replace("Attribute rule execution complete:", "")))
1282
+ .map (m => JSON.parse(decodeHTMLEntities(m.message.replace("Attribute rule execution complete:", ""))))
1278
1283
  .map( m => {
1279
1284
  m["Elapsed Time (ms)"] = Math.round(m["Elapsed Time"]*1000000)/1000
1280
1285
  // m["Arcade Evaluation Time:"] = Math.round(m["Arcade Evaluation Time:"]*1000,6)
@@ -1519,12 +1524,34 @@ export async function run (){
1519
1524
  parameters = await parseInput( )
1520
1525
  //set certificate verification
1521
1526
  const verifyCert = parameters["verify"] === 'true' ? 1 : 0;
1527
+ const proxy = parameters["proxy"]
1522
1528
  process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = verifyCert;
1529
+
1530
+ if (proxy){
1531
+ logger.info(`Using proxy ${proxy}`);
1532
+ process.env['HTTPS_PROXY'] = proxy;
1533
+ }
1534
+
1535
+
1536
+
1523
1537
  setTimeout( async ()=> await regenerateToken(parameters) , 1000*60*GENERATE_TOKEN_TIME_MIN)
1524
1538
  await connect(parameters)
1525
1539
  }
1526
1540
 
1527
1541
 
1542
+ function decodeHTMLEntities (x) {
1543
+ const entities = {
1544
+ '&lt;': '<',
1545
+ '&gt;': '>',
1546
+ '&amp;': '&',
1547
+ '&quot;': '"',
1548
+ '&apos;': "'"
1549
+ };
1550
+
1551
+ const y = x.replace(/&[a-zA-Z0-9#]+;/g, (match) => entities[match] || match);
1552
+ return y
1553
+ }
1554
+
1528
1555
 
1529
1556
  function printFishnet(fishnet) {
1530
1557
 
package/makerequest.mjs CHANGED
@@ -1,6 +1,5 @@
1
-
2
-
3
1
 
2
+
4
3
  export function makeRequest (opts) {
5
4
 
6
5
  return new Promise(async function (resolve, reject) {
@@ -23,26 +22,44 @@ export function makeRequest (opts) {
23
22
 
24
23
  if (opts.headers)
25
24
  Object.keys(opts.headers).forEach( key => headers[key] = opts.headers[key] )
26
-
27
- //console.log(opts)
28
-
25
+
26
+ let jsonRes
27
+ let agent;
29
28
  let f;
29
+
30
30
  try {
31
-
31
+
32
32
  let nodeFetch = await import ("node-fetch");
33
33
  f = nodeFetch.default;
34
+
35
+ //set a proxy if one exists
36
+
37
+ if (process?.env['HTTPS_PROXY'])
38
+ {
39
+ try {
40
+ const HttpsProxyAgent = await import ('https-proxy-agent')
41
+ agent = new HttpsProxyAgent.HttpsProxyAgent(process.env['HTTPS_PROXY'])
42
+ }
43
+ catch (ex){
44
+ agent = undefined;
45
+ }
46
+
47
+ }
34
48
  }
35
49
  catch(ex) {
36
50
  f = fetch;
37
- }
38
-
39
- let jsonRes
51
+ }
40
52
 
41
- const result = await f(opts.url, {
42
- "method" : opts.method,
43
- "headers": headers,
44
- "body": params
45
- });
53
+ const options = {
54
+ "method" : opts.method,
55
+ "headers": headers,
56
+ "body": params
57
+ }
58
+
59
+ if (agent)
60
+ options.agent = agent;
61
+
62
+ const result = await f(opts.url,options);
46
63
 
47
64
  jsonRes = await result.json();
48
65
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "un-cli",
3
- "version": "0.0.80",
3
+ "version": "0.0.82",
4
4
  "description": "Command line interface for working with ArcGIS Utility Network Extension",
5
5
  "main": "index.mjs",
6
6
  "bin": {
@@ -17,6 +17,7 @@
17
17
  "author": "Hussein Nasser",
18
18
  "license": "ISC",
19
19
  "dependencies": {
20
+ "https-proxy-agent": "^7.0.6",
20
21
  "node-fetch": "^2.6.0"
21
22
  }
22
23
  }
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();