@js4cytoscape/ndex-client 0.4.3-alpha.1 → 0.4.3-alpha.11

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,10 +1,10 @@
1
1
  {
2
2
  "name": "@js4cytoscape/ndex-client",
3
- "version": "0.4.3-alpha.1",
3
+ "version": "0.4.3-alpha.11",
4
4
  "description": "NDEx client library",
5
5
  "repository": {
6
6
  "type": "git",
7
- "url": "https://github.com/cytoscape/js4cytoscape.git"
7
+ "url": "git+https://github.com/cytoscape/js4cytoscape.git"
8
8
  },
9
9
  "bugs": {
10
10
  "url": "https://github.com/cytoscape/js4cytoscape/issues"
@@ -28,6 +28,9 @@
28
28
  "node": ">=12.16.1"
29
29
  },
30
30
  "dependencies": {
31
- "axios": "^1.3.4"
31
+ "axios": "^1.6.7"
32
+ },
33
+ "devDependencies": {
34
+ "@microsoft/tsdoc": "^0.14.2"
32
35
  }
33
36
  }
package/src/NDEx.js CHANGED
@@ -1,4 +1,4 @@
1
- const axios = require('axios');
1
+ const { default: axios } = require('axios');
2
2
 
3
3
  const CX1_HEADER = {
4
4
  numberVerification: [{
@@ -6,6 +6,9 @@ const CX1_HEADER = {
6
6
  }]
7
7
  };
8
8
 
9
+ /**
10
+ * NDEx client class.
11
+ */
9
12
  class NDEx {
10
13
  constructor(hostprefix) {
11
14
  if (hostprefix === undefined || hostprefix === null || hostprefix === '') {
@@ -98,14 +101,15 @@ class NDEx {
98
101
  }
99
102
 
100
103
  _setAuthHeader(config) {
104
+
105
+ if (config['headers'] === undefined) {config['headers'] = {};}
106
+ config['headers']['setAuthHeader'] = false;
107
+
101
108
  if (this._authType === 'b') {
102
109
  config ['auth'] = { username: this.username,
103
110
  password: this.password};
104
111
  } else if (this.authenticationType === 'g') {
105
- const idToken = this._getIdToken();
106
-
107
- if (config['headers'] === undefined) {config['headers'] = {};}
108
- config['headers']['Authorization'] = 'Bearer ' + idToken;
112
+ config['headers']['Authorization'] = 'Bearer ' + this._getIdToken();
109
113
  }
110
114
  }
111
115
 
@@ -380,6 +384,32 @@ class NDEx {
380
384
  return this._httpGetProtectedObj('network/' + uuid + '/summary', parameters);
381
385
  }
382
386
 
387
+ getNetworkV3Summary(uuid, accessKey,fmt) {
388
+ let parameters = {format: fmt != null? fmt : "FULL"}
389
+
390
+ if (accessKey != null) {
391
+ parameters ['accesskey'] = accessKey;
392
+ }
393
+
394
+ return this._httpGetV3ProtectedObj('networks/' + uuid + '/summary', parameters);
395
+ }
396
+
397
+ getAttributesOfSelectedNodes(uuid, {ids: nodeIds, attributeNames: names},accessKey) {
398
+ let parameters = {
399
+ };
400
+
401
+ if (accessKey != null) {
402
+ parameters ['accesskey'] = accessKey;
403
+ }
404
+
405
+ let data = {
406
+ "ids": nodeIds,
407
+ "attributeNames": names,
408
+ };
409
+
410
+ return this._httpPostV3ProtectedObj('/search/networks/' + uuid + '/nodes', parameters, data);
411
+ }
412
+
383
413
  createNetworkFromRawCX(rawCX, parameters) {
384
414
  return new Promise((resolve, reject) =>{
385
415
  this._httpPostProtectedObj('network', parameters, rawCX).then(
@@ -463,7 +493,7 @@ class NDEx {
463
493
  return this._httpPostProtectedObj('search/network', params, data);
464
494
  }
465
495
 
466
- neighborhoodQuery(uuid, searchTerms, saveResult, parameters) {
496
+ neighborhoodQuery(uuid, searchTerms, saveResult, parameters, outputCX2 = false) {
467
497
  let params = {};
468
498
 
469
499
  if (saveResult !== undefined && saveResult === true) {params.save = true;}
@@ -484,12 +514,18 @@ class NDEx {
484
514
  if (parameters.directOnly !== undefined) {
485
515
  data.directOnly = parameters.directOnly;
486
516
  }
517
+ if ( parameters.nodeIds !=null) {
518
+ data.nodeIds = parameters.nodeIds;
519
+ }
487
520
  }
521
+ if( outputCX2)
522
+ return this._httpPostV3ProtectedObj('search/network/' + uuid + '/query', params, data);
523
+
488
524
  return this._httpPostProtectedObj('search/network/' + uuid + '/query', params, data);
489
525
 
490
526
  }
491
527
 
492
- interConnectQuery(uuid, searchTerms, saveResult, parameters) {
528
+ interConnectQuery(uuid, searchTerms, saveResult, parameters, outputCX2 = false) {
493
529
  let params = {};
494
530
 
495
531
  if (saveResult !== undefined && saveResult === true) {params.save = true;}
@@ -503,7 +539,13 @@ class NDEx {
503
539
  if (parameters.errorWhenLimitIsOver !== undefined) {
504
540
  data.errorWhenLimitIsOver = parameters.errorWhenLimitIsOver;
505
541
  }
542
+ if ( parameters.nodeIds !=null) {
543
+ data.nodeIds = parameters.nodeIds;
544
+ }
506
545
  }
546
+ if (outputCX2)
547
+ return this._httpPostV3ProtectedObj('search/networks/' + uuid + '/interconnectquery', params, data);
548
+
507
549
  return this._httpPostProtectedObj('search/network/' + uuid + '/interconnectquery', params, data);
508
550
 
509
551
  }
@@ -524,6 +566,16 @@ class NDEx {
524
566
  return this._httpPostProtectedObj('batch/network/summary', parameter, uuidList);
525
567
  }
526
568
 
569
+ getNetworkSummariesV3ByUUIDs(uuidList, accessKey,fmt) {
570
+ let parameter = {format: fmt == undefined ? "FULL" : fmt}
571
+
572
+ if(accessKey != null)
573
+ parameter['accesskey']= accessKey;
574
+
575
+ return this._httpPostV3ProtectedObj('batch/networks/summary', parameter, uuidList);
576
+ }
577
+
578
+
527
579
  getNetworkPermissionsByUUIDs(uuidList) {
528
580
  return this._httpPostProtectedObj('batch/network/permission', undefined, uuidList);
529
581
  }
@@ -754,15 +806,19 @@ class NDEx {
754
806
  });
755
807
  }
756
808
 
809
+ updateNetworkFromRawCX2(uuid, rawCX2) {
810
+ return this._httpPutV3Obj('networks/'+uuid, undefined, rawCX2);
811
+ }
812
+
757
813
  createCyWebWorkspace(workspace) {
758
814
  return new Promise((resolve, reject)=> {
759
815
  this._httpPostV3ProtectedObj('workspaces', undefined, workspace).then(
760
816
  (response) => {
761
- let uuidr = response.split('/');
817
+ // let uuidr = response.split('/');
762
818
 
763
- let uuid = uuidr[uuidr.length - 1];
819
+ // let uuid = uuidr[uuidr.length - 1];
764
820
 
765
- return resolve(uuid);
821
+ return resolve(response);
766
822
  },
767
823
  (err) => {reject(err);}
768
824
  );
@@ -790,5 +846,19 @@ class NDEx {
790
846
  return this._httpPutV3Obj('workspaces/'+workspaceId+'/networkids', undefined, networkIds);
791
847
  }
792
848
 
849
+ getUserCyWebWorkspaces() {
850
+ return new Promise((resolve, reject) => {
851
+ this.getSignedInUser().then((user) => {
852
+ this._httpGetV3ProtectedObj('users/'+ user.externalId + '/workspaces', {}).then(
853
+ (workspaceArray) => {resolve(workspaceArray);}, (err) => {reject(err);}
854
+ );
855
+ }, (err) => {reject(err);});
856
+
857
+ });
858
+ }
859
+
860
+ signInFromIdToken(idToken) {
861
+ return this._httpPostV3ProtectedObj('users/signin', undefined, {idToken: idToken});
862
+ }
793
863
  }
794
864
  module.exports = { NDEx };