un-cli 0.0.78 → 0.0.80

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 CHANGED
@@ -1,2 +1,2 @@
1
- topology --validate --fishnet
1
+ reconcile --version U136967.MigrateTransm
2
2
  exit
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.78";
10
+ let version = "0.0.80";
11
11
  const GENERATE_TOKEN_TIME_MIN = 30;
12
12
 
13
13
  let rl = null;
@@ -175,8 +175,8 @@ const inputs = {
175
175
  "export subnetworks --new [--folder]": "Export all subnetworks with ACK that haven't been exported --folder where exported files are saved",
176
176
  "export subnetworks --deleted": "Export all subnetworks with ACK that are deleted ",
177
177
  "updateisconnected": "Run update is connected ",
178
-
179
- "count": "Lists the number of rows in all feature layers.",
178
+ "versions": "List all versions available to the current logged in user.",
179
+ "count": "Lists the number of rows in all feature layers and tables.",
180
180
  "count --system": "Lists the number of rows in system layers.",
181
181
  "connect --service": "Connects to the another service",
182
182
  "tracelogs --age <minutes>": "Lists utility network trace summary logs for the last x minutes (requires admin)",
@@ -228,6 +228,100 @@ const inputs = {
228
228
 
229
229
  console.table(serviceDef)
230
230
  },
231
+
232
+ "^versions$": async () => {
233
+
234
+ const versions = await un.versions();
235
+ if (versions.versions.length === 0) {
236
+ logger.info("No versions found.")
237
+ return;
238
+ }
239
+ const subs = versions.versions.map( (a) => {
240
+ return {"versionName": a.versionName, "Id": a.versionId, "guid" : a.versionGuid, "created": a.creationDate, "modified": a.modifiedDate, "access": a.access};
241
+ })
242
+
243
+ console.table(subs)
244
+ const rowCount = subs.length;
245
+ logger.info (`${numberWithCommas(rowCount)} rows returned.`)
246
+ },
247
+
248
+
249
+ "^reconcile --version": async (input) => {
250
+
251
+ const inputParam = input.match(/--version .*/gm)
252
+ let versionName = null;
253
+ if (inputParam != null && inputParam.length > 0)
254
+ versionName = inputParam[0].replace("--version ", "")
255
+
256
+ const versions = await un.versions();
257
+
258
+ for (let v = 0; v < versions.versions.length; v++)
259
+ {
260
+ if (versions.versions[v].versionName.toString().toUpperCase() === "SDE.DEFAULT") continue;
261
+ if (versions.versions[v].versionName.toString().toUpperCase() == versionName.toUpperCase()) {
262
+ logger.info (`Reconciling version ${versions.versions[v].versionName} ...`)
263
+
264
+ const result = await un.reconcile(versions.versions[v].versionGuid, false, false, true, false);
265
+ logger.info(JSON.stringify(result))
266
+ break;
267
+ }
268
+
269
+ }
270
+ logger.info (`Reconciled ${versionName}.`)
271
+ },
272
+
273
+
274
+ "^reconcile --all$": async () => {
275
+
276
+ const versions = await un.versions();
277
+
278
+ for (let v = 0; v < versions.versions.length; v++)
279
+ {
280
+ if (versions.versions[v].versionName.toString().toUpperCase() === "SDE.DEFAULT") continue;
281
+ logger.info (`Reconciling version ${versions.versions[v].versionName} ...`)
282
+
283
+ const result = await un.reconcile(versions.versions[v].versionGuid, false, false, true, false);
284
+ logger.info(JSON.stringify(result))
285
+ }
286
+ const rowCount = versions.versions.length;
287
+ logger.info (`Reconciled ${numberWithCommas(rowCount)} versions.`)
288
+ },
289
+
290
+ "^reconcile --all --async$": async () => {
291
+ //async
292
+ const versions = await un.versions();
293
+
294
+ for (let v = 0; v < versions.versions.length; v++)
295
+ {
296
+ if (versions.versions[v].versionName.toString().toUpperCase() === "SDE.DEFAULT") continue;
297
+ logger.info (`Reconciling version ${versions.versions[v].versionName} ...`)
298
+
299
+ const result = await un.reconcile(versions.versions[v].versionGuid, false, false, true, true);
300
+ logger.info(JSON.stringify(result))
301
+ }
302
+ const rowCount = versions.versions.length;
303
+ logger.info (`Reconciled ${numberWithCommas(rowCount)} versions.`)
304
+ },
305
+
306
+
307
+ "^versions --disconnect$": async () => {
308
+ //disconnect all versions
309
+ const versions = await un.versions();
310
+
311
+ for (let v = 0; v < versions.versions.length; v++)
312
+ {
313
+ if (versions.versions[v].versionName.toString().toUpperCase() === "SDE.DEFAULT") continue;
314
+ logger.info (`Stopping editing on version ${versions.versions[v].versionName} ...`)
315
+ const g = versions.versions[v].versionGuid
316
+ let result = await un.stopEditing(g,g);
317
+ logger.info(JSON.stringify(result))
318
+ logger.info (`Stopping reading on version ${versions.versions[v].versionName} ...`)
319
+ result = await un.stopReading(g,g);
320
+ logger.info(JSON.stringify(result))
321
+ }
322
+ const rowCount = versions.versions.length;
323
+ logger.info (`Disconnected ${numberWithCommas(rowCount)} versions.`)
324
+ },
231
325
  "^subnetworks$": async () => {
232
326
 
233
327
  const subnetworks = await un.getSubnetworks();
@@ -748,8 +842,8 @@ const inputs = {
748
842
  let totalRows =0;
749
843
  serviceDef.layers.forEach (l=> Object.keys(l).forEach (k => !layerProperties.includes(k) ? delete l[k] : ""))
750
844
  //all layers except system ones
751
- const allLayers = serviceDef.layers.filter(l => l.type === 'Feature Layer' && !systemLayers.find(a=> a.id === l.id ))
752
-
845
+ let allLayers = serviceDef.layers.filter(l => l.type === 'Feature Layer' && !systemLayers.find(a=> a.id === l.id ))
846
+ allLayers = allLayers.concat(serviceDef.tables);
753
847
 
754
848
  for (let i = 0; i < allLayers.length; i++ )
755
849
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "un-cli",
3
- "version": "0.0.78",
3
+ "version": "0.0.80",
4
4
  "description": "Command line interface for working with ArcGIS Utility Network Extension",
5
5
  "main": "index.mjs",
6
6
  "bin": {
@@ -443,6 +443,13 @@ export class UtilityNetwork {
443
443
 
444
444
 
445
445
 
446
+ if (this.layerDefinition.systemLayers.dirtyObjectsTableId)
447
+ systemLayers.push({
448
+ "id": this.layerDefinition.systemLayers.dirtyObjectsTableId,
449
+ "name": "Dirty Objects",
450
+ "type": "Feature Layer",
451
+ "geometryType": "None"
452
+ })
446
453
 
447
454
  if (this.layerDefinition.systemLayers.pointErrorsLayerId)
448
455
  systemLayers.push({
@@ -815,8 +822,109 @@ export class UtilityNetwork {
815
822
 
816
823
  }
817
824
 
825
+ startReading(versionGuid, sessionGuid){
826
+ let thisObj = this;
827
+ let ar = thisObj.featureServiceUrl.split("/");
828
+ ar[ar.length-1]="VersionManagementServer";
829
+
830
+ let url = ar.join("/") + "/versions/" + versionGuid.replace("{","").replace("}", "") + "/startReading"
831
+ let vmsJson = {
832
+ f: "json",
833
+ sessionId: sessionGuid,
834
+ token: this.token
835
+ }
836
+
837
+ return makeRequest({method:'POST', params: vmsJson, url: url })
838
+
839
+ }
840
+
841
+
842
+
843
+ stopReading(versionGuid, sessionGuid){
844
+ let thisObj = this;
845
+ let ar = thisObj.featureServiceUrl.split("/");
846
+ ar[ar.length-1]="VersionManagementServer";
847
+
848
+ let url = ar.join("/") + "/versions/" + versionGuid.replace("{","").replace("}", "") + "/stopReading"
849
+ let vmsJson = {
850
+ f: "json",
851
+ sessionId: sessionGuid,
852
+ token: this.token
853
+ }
854
+
855
+ return makeRequest({method:'POST', params: vmsJson, url: url })
856
+
857
+ }
858
+
859
+
860
+
861
+ startEditing(versionGuid, sessionGuid){
862
+
863
+ let thisObj = this;
864
+ let ar = thisObj.featureServiceUrl.split("/");
865
+ ar[ar.length-1]="VersionManagementServer";
866
+
867
+ let url = ar.join("/") + "/versions/" + versionGuid.replace("{","").replace("}", "") + "/startEditing"
868
+ let vmsJson = {
869
+ f: "json",
870
+ sessionId: sessionGuid,
871
+ token: this.token
872
+ }
873
+
874
+ return makeRequest({method:'POST', params: vmsJson, url: url })
875
+
876
+ }
877
+
878
+
879
+
880
+ stopEditing(versionGuid, sessionGuid,saveEdits=true){
881
+ let thisObj = this;
882
+ let ar = thisObj.featureServiceUrl.split("/");
883
+ ar[ar.length-1]="VersionManagementServer";
884
+
885
+ let url = ar.join("/") + "/versions/" + versionGuid.replace("{","").replace("}", "") + "/stopEditing"
886
+ let vmsJson = {
887
+ f: "json",
888
+ sessionId: sessionGuid,
889
+ saveEdits:saveEdits,
890
+ token: this.token
891
+ }
892
+
893
+ return makeRequest({method:'POST', params: vmsJson, url: url })
894
+
895
+ }
896
+
818
897
 
819
- versions() {
898
+
899
+ async reconcile (versionGuid, withPost = false, abortIfConflicts=false, conflictDetection=true, async = false ) {
900
+
901
+ //startReading use the version guid as a session id
902
+ await this.startReading(versionGuid,versionGuid );
903
+ await this.startEditing(versionGuid,versionGuid );
904
+ let thisObj = this;
905
+ let ar = thisObj.featureServiceUrl.split("/");
906
+ ar[ar.length-1]="VersionManagementServer";
907
+
908
+ let url = ar.join("/") + "/versions/" + versionGuid.replace("{","").replace("}", "") + "/reconcile"
909
+ let vmsJson = {
910
+ f: "json",
911
+ sessionId: versionGuid,
912
+ withPost: withPost,
913
+ async: async,
914
+ token: this.token
915
+ }
916
+
917
+ const result = makeRequest({method:'POST', params: vmsJson, url: url })
918
+
919
+ /* if (async == false){
920
+ await this.stopEditing(versionGuid,versionGuid );
921
+ await this.stopReading(versionGuid,versionGuid );}*/
922
+
923
+ return result;
924
+
925
+ }
926
+
927
+ versions() {
820
928
 
821
929
  let thisObj = this;
822
930
  let ar = thisObj.featureServiceUrl.split("/");