@js4cytoscape/ndex-client 0.3.2 → 0.4.3-alpha.1
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/dist/ndexClient.common.js +195 -296
- package/dist/ndexClient.js +18 -311
- package/package.json +2 -2
- package/src/CyNDEx.js +5 -1
- package/src/NDEx.js +62 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@js4cytoscape/ndex-client",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.4.3-alpha.1",
|
|
4
4
|
"description": "NDEx client library",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -28,6 +28,6 @@
|
|
|
28
28
|
"node": ">=12.16.1"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"axios": "^
|
|
31
|
+
"axios": "^1.3.4"
|
|
32
32
|
}
|
|
33
33
|
}
|
package/src/CyNDEx.js
CHANGED
|
@@ -20,7 +20,7 @@ class CyNDEx {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
getNDExServer() {
|
|
23
|
-
return this._ndexServer ? this._ndexServer : '
|
|
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
|
@@ -9,7 +9,7 @@ const CX1_HEADER = {
|
|
|
9
9
|
class NDEx {
|
|
10
10
|
constructor(hostprefix) {
|
|
11
11
|
if (hostprefix === undefined || hostprefix === null || hostprefix === '') {
|
|
12
|
-
throw new Error('NDEx server endpoint base URL is required in client constructor.');
|
|
12
|
+
throw new Error('NDEx server host name or endpoint base URL is required in client constructor.');
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
// axios needs http to be at the front of the url.
|
|
@@ -17,7 +17,11 @@ class NDEx {
|
|
|
17
17
|
// with an ambiguous reason
|
|
18
18
|
let httpRegex = new RegExp("^(http|https)://", "i");
|
|
19
19
|
if (!httpRegex.test(hostprefix)) {
|
|
20
|
-
throw new Error(`"http://" or "https://" must be prefixed to the input url: ${hostprefix}`);
|
|
20
|
+
// throw new Error(`"http://" or "https://" must be prefixed to the input url: ${hostprefix}`);
|
|
21
|
+
// we assume it is a host name
|
|
22
|
+
if ( hostprefix.indexOf('/') > -1 )
|
|
23
|
+
throw new Error ('"/" are not allowed in host name.');
|
|
24
|
+
hostprefix = "https://"+ hostprefix + "/v2";
|
|
21
25
|
}
|
|
22
26
|
|
|
23
27
|
this._host = hostprefix;
|
|
@@ -176,11 +180,11 @@ class NDEx {
|
|
|
176
180
|
return this._httpPostProtectedObjAux(this._v3baseURL,URL,parameters, data);
|
|
177
181
|
}
|
|
178
182
|
|
|
179
|
-
|
|
183
|
+
_httpPutObjAux(prefix, URL, parameters, data) {
|
|
180
184
|
let config = {
|
|
181
185
|
method: 'put',
|
|
182
186
|
url: URL,
|
|
183
|
-
baseURL:
|
|
187
|
+
baseURL: prefix
|
|
184
188
|
};
|
|
185
189
|
|
|
186
190
|
this._setAuthHeader(config);
|
|
@@ -204,11 +208,28 @@ class NDEx {
|
|
|
204
208
|
});
|
|
205
209
|
}
|
|
206
210
|
|
|
211
|
+
_httpPutObj(URL,parameters, data) {
|
|
212
|
+
return this._httpPutObjAux(this.host,URL, parameters, data);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
_httpPutV3Obj(URL,parameters,data) {
|
|
216
|
+
return this._httpPutObjAux(this._v3baseURL,URL,parameters,data);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
|
|
207
220
|
_httpDeleteObj(URL, parameters, data) {
|
|
221
|
+
return this._httpDeleteObjAux(this.host,URL,parameters, data);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
_httpDeleteV3Obj(URL, parameters) {
|
|
225
|
+
return this._httpDeleteObjAux(this._v3baseURL, URL, parameters, undefined);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
_httpDeleteObjAux(prefix, URL, parameters, data) {
|
|
208
229
|
let config = {
|
|
209
230
|
method: 'delete',
|
|
210
231
|
url: URL,
|
|
211
|
-
baseURL:
|
|
232
|
+
baseURL: prefix
|
|
212
233
|
};
|
|
213
234
|
|
|
214
235
|
this._setAuthHeader(config);
|
|
@@ -733,5 +754,41 @@ class NDEx {
|
|
|
733
754
|
});
|
|
734
755
|
}
|
|
735
756
|
|
|
757
|
+
createCyWebWorkspace(workspace) {
|
|
758
|
+
return new Promise((resolve, reject)=> {
|
|
759
|
+
this._httpPostV3ProtectedObj('workspaces', undefined, workspace).then(
|
|
760
|
+
(response) => {
|
|
761
|
+
let uuidr = response.split('/');
|
|
762
|
+
|
|
763
|
+
let uuid = uuidr[uuidr.length - 1];
|
|
764
|
+
|
|
765
|
+
return resolve(uuid);
|
|
766
|
+
},
|
|
767
|
+
(err) => {reject(err);}
|
|
768
|
+
);
|
|
769
|
+
});
|
|
770
|
+
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
getCyWebWorkspace(workspaceId) {
|
|
774
|
+
return this._httpGetV3ProtectedObj('workspaces/'+ workspaceId, {});
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
deleteCyWebWorkspace(workspaceId) {
|
|
778
|
+
return this._httpDeleteV3Obj('workspaces/'+ workspaceId, undefined);
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
updateCyWebWorkspace(workspaceId, workspaceObj) {
|
|
782
|
+
return this._httpPutV3Obj('workspaces/'+workspaceId, undefined, workspaceObj);
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
updateCyWebWorkspaceName(workspaceId, newName) {
|
|
786
|
+
return this._httpPutV3Obj('workspaces/'+workspaceId+'/name', undefined, {'name': newName});
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
updateCyWebWorkspaceNetworks(workspaceId, networkIds) {
|
|
790
|
+
return this._httpPutV3Obj('workspaces/'+workspaceId+'/networkids', undefined, networkIds);
|
|
791
|
+
}
|
|
792
|
+
|
|
736
793
|
}
|
|
737
794
|
module.exports = { NDEx };
|