@js4cytoscape/ndex-client 0.4.3-alpha.0 → 0.4.3-alpha.10

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.0",
3
+ "version": "0.4.3-alpha.10",
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": "^0.26.0"
31
+ "axios": "^1.4.0"
32
+ },
33
+ "devDependencies": {
34
+ "@microsoft/tsdoc": "^0.14.2"
32
35
  }
33
36
  }
package/src/CyNDEx.js CHANGED
@@ -20,7 +20,7 @@ class CyNDEx {
20
20
  }
21
21
 
22
22
  getNDExServer() {
23
- return this._ndexServer ? this._ndexServer : 'http://public.ndexbio.org';
23
+ return this._ndexServer ? this._ndexServer : 'https://www.ndexbio.org';
24
24
  }
25
25
 
26
26
  setGoogleAuth(googleAuthObj) {
@@ -149,6 +149,10 @@ class CyNDEx {
149
149
  return this._httpPost('/cyndex2/v1/networks/cx', undefined, cx);
150
150
  }
151
151
 
152
+ postCX2NetworkToCytoscape(cx2_string, title, collection_name) {
153
+ return this._httpPost('/v1/networks',{ 'format': 'cx2', 'collection': collection_name, 'title':title}, cx2_string);
154
+ }
155
+
152
156
  postCytoscapeNetworkToNDEx(suid = 'current') {
153
157
  const saveParams = {
154
158
  serverUrl: this.getNDExServer() + '/v2',
package/src/NDEx.js CHANGED
@@ -6,10 +6,13 @@ 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 === '') {
12
- throw new Error('NDEx server endpoint base URL is required in client constructor.');
15
+ throw new Error('NDEx server host name or endpoint base URL is required in client constructor.');
13
16
  }
14
17
 
15
18
  // axios needs http to be at the front of the url.
@@ -17,7 +20,11 @@ class NDEx {
17
20
  // with an ambiguous reason
18
21
  let httpRegex = new RegExp("^(http|https)://", "i");
19
22
  if (!httpRegex.test(hostprefix)) {
20
- throw new Error(`"http://" or "https://" must be prefixed to the input url: ${hostprefix}`);
23
+ // throw new Error(`"http://" or "https://" must be prefixed to the input url: ${hostprefix}`);
24
+ // we assume it is a host name
25
+ if ( hostprefix.indexOf('/') > -1 )
26
+ throw new Error ('"/" are not allowed in host name.');
27
+ hostprefix = "https://"+ hostprefix + "/v2";
21
28
  }
22
29
 
23
30
  this._host = hostprefix;
@@ -94,14 +101,15 @@ class NDEx {
94
101
  }
95
102
 
96
103
  _setAuthHeader(config) {
104
+
105
+ if (config['headers'] === undefined) {config['headers'] = {};}
106
+ config['headers']['setAuthHeader'] = false;
107
+
97
108
  if (this._authType === 'b') {
98
109
  config ['auth'] = { username: this.username,
99
110
  password: this.password};
100
111
  } else if (this.authenticationType === 'g') {
101
- const idToken = this._getIdToken();
102
-
103
- if (config['headers'] === undefined) {config['headers'] = {};}
104
- config['headers']['Authorization'] = 'Bearer ' + idToken;
112
+ config['headers']['Authorization'] = 'Bearer ' + this._getIdToken();
105
113
  }
106
114
  }
107
115
 
@@ -376,6 +384,32 @@ class NDEx {
376
384
  return this._httpGetProtectedObj('network/' + uuid + '/summary', parameters);
377
385
  }
378
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
+
379
413
  createNetworkFromRawCX(rawCX, parameters) {
380
414
  return new Promise((resolve, reject) =>{
381
415
  this._httpPostProtectedObj('network', parameters, rawCX).then(
@@ -459,7 +493,7 @@ class NDEx {
459
493
  return this._httpPostProtectedObj('search/network', params, data);
460
494
  }
461
495
 
462
- neighborhoodQuery(uuid, searchTerms, saveResult, parameters) {
496
+ neighborhoodQuery(uuid, searchTerms, saveResult, parameters, outputCX2 = false) {
463
497
  let params = {};
464
498
 
465
499
  if (saveResult !== undefined && saveResult === true) {params.save = true;}
@@ -480,12 +514,18 @@ class NDEx {
480
514
  if (parameters.directOnly !== undefined) {
481
515
  data.directOnly = parameters.directOnly;
482
516
  }
517
+ if ( parameters.nodeIds !=null) {
518
+ data.nodeIds = parameters.nodeIds;
519
+ }
483
520
  }
521
+ if( outputCX2)
522
+ return this._httpPostV3ProtectedObj('search/network/' + uuid + '/query', params, data);
523
+
484
524
  return this._httpPostProtectedObj('search/network/' + uuid + '/query', params, data);
485
525
 
486
526
  }
487
527
 
488
- interConnectQuery(uuid, searchTerms, saveResult, parameters) {
528
+ interConnectQuery(uuid, searchTerms, saveResult, parameters, outputCX2 = false) {
489
529
  let params = {};
490
530
 
491
531
  if (saveResult !== undefined && saveResult === true) {params.save = true;}
@@ -499,7 +539,13 @@ class NDEx {
499
539
  if (parameters.errorWhenLimitIsOver !== undefined) {
500
540
  data.errorWhenLimitIsOver = parameters.errorWhenLimitIsOver;
501
541
  }
542
+ if ( parameters.nodeIds !=null) {
543
+ data.nodeIds = parameters.nodeIds;
544
+ }
502
545
  }
546
+ if (outputCX2)
547
+ return this._httpPostV3ProtectedObj('search/networks/' + uuid + '/interconnectquery', params, data);
548
+
503
549
  return this._httpPostProtectedObj('search/network/' + uuid + '/interconnectquery', params, data);
504
550
 
505
551
  }
@@ -520,6 +566,16 @@ class NDEx {
520
566
  return this._httpPostProtectedObj('batch/network/summary', parameter, uuidList);
521
567
  }
522
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
+
523
579
  getNetworkPermissionsByUUIDs(uuidList) {
524
580
  return this._httpPostProtectedObj('batch/network/permission', undefined, uuidList);
525
581
  }
@@ -750,15 +806,19 @@ class NDEx {
750
806
  });
751
807
  }
752
808
 
809
+ updateNetworkFromRawCX2(uuid, rawCX2) {
810
+ return this._httpPutV3Obj('networks/'+uuid, undefined, rawCX2);
811
+ }
812
+
753
813
  createCyWebWorkspace(workspace) {
754
814
  return new Promise((resolve, reject)=> {
755
815
  this._httpPostV3ProtectedObj('workspaces', undefined, workspace).then(
756
816
  (response) => {
757
- let uuidr = response.split('/');
817
+ // let uuidr = response.split('/');
758
818
 
759
- let uuid = uuidr[uuidr.length - 1];
819
+ // let uuid = uuidr[uuidr.length - 1];
760
820
 
761
- return resolve(uuid);
821
+ return resolve(response);
762
822
  },
763
823
  (err) => {reject(err);}
764
824
  );
@@ -786,5 +846,19 @@ class NDEx {
786
846
  return this._httpPutV3Obj('workspaces/'+workspaceId+'/networkids', undefined, networkIds);
787
847
  }
788
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
+ }
789
863
  }
790
864
  module.exports = { NDEx };