curtain-web-api 1.0.4 → 1.0.6
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/.idea/.name +1 -0
- package/.idea/modules.xml +1 -1
- package/README.md +63 -0
- package/build/classes/curtain-api.d.ts +2 -1
- package/build/classes/curtain-api.js +10 -1
- package/build/index.d.ts +2 -2
- package/build/index.js +3 -1
- package/build/utilities.d.ts +1 -1
- package/build/utilities.js +3 -3
- package/curtainuser/000003.log +0 -0
- package/curtainuser/LOG +1 -1
- package/package.json +1 -1
- package/src/classes/curtain-api.ts +11 -1
- package/src/index.ts +2 -2
- package/src/tests/curtain-login.spec.ts +11 -0
- package/src/utilities.ts +1 -1
- /package/.idea/{curtain-login.iml → curtain-web-api.iml} +0 -0
package/.idea/.name
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
curtain-web-api
|
package/.idea/modules.xml
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<project version="4">
|
|
3
3
|
<component name="ProjectModuleManager">
|
|
4
4
|
<modules>
|
|
5
|
-
<module fileurl="file://$PROJECT_DIR$/.idea/curtain-
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/curtain-web-api.iml" filepath="$PROJECT_DIR$/.idea/curtain-web-api.iml" />
|
|
6
6
|
</modules>
|
|
7
7
|
</component>
|
|
8
8
|
</project>
|
package/README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Curtain Web API
|
|
2
|
+
---
|
|
3
|
+
|
|
4
|
+
This is a node.js package used to interact with the Curtain Web REST API.
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npm install curtain-web-api pouchdb -s
|
|
10
|
+
npm install @types/pouchdb -D
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { CurtainWebApi } from 'curtain-web-api';
|
|
17
|
+
|
|
18
|
+
const curtainAPI = new CurtainWebApi("https://curtain-api-location/")
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
// Login to the API
|
|
22
|
+
|
|
23
|
+
curtainAPI.login("username", "password").then((result) => {
|
|
24
|
+
console.log(result);
|
|
25
|
+
// The result is an object containing the user's information
|
|
26
|
+
}).catch((error) => {
|
|
27
|
+
console.log(error);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// Get the user's information
|
|
31
|
+
curtainAPI.getUser().then((result) => {
|
|
32
|
+
console.log(result);
|
|
33
|
+
// The result is an object containing the user's information similar to the login but can only be performed after login have succeeded
|
|
34
|
+
}).catch((error) => {
|
|
35
|
+
console.log(error);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// Get session information
|
|
39
|
+
curtainAPI.getSessionSettings(sessionId).then((result) => {
|
|
40
|
+
console.log(result);
|
|
41
|
+
// The result is an object containing the session's basic information without any data
|
|
42
|
+
}).catch((error) => {
|
|
43
|
+
console.log(error);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
// Get session data
|
|
48
|
+
curtainAPI.postSettings(sessionId, sessionToken).then((result) => {
|
|
49
|
+
console.log(result);
|
|
50
|
+
// The result is an object containing the session's data
|
|
51
|
+
}).catch((error) => {
|
|
52
|
+
console.log(error);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
// Upload session data
|
|
57
|
+
curtainAPI.putSettings(settings, enableToPublic, description, sessionType).then((result) => {
|
|
58
|
+
console.log(result);
|
|
59
|
+
// The result is an object containing the session's data
|
|
60
|
+
}).catch((error) => {
|
|
61
|
+
console.log(error);
|
|
62
|
+
});
|
|
63
|
+
```
|
|
@@ -31,7 +31,8 @@ export declare class CurtainWebAPI {
|
|
|
31
31
|
getCurtainLinks(username: string, sessionDescription?: string, offset?: number, sessionType?: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
32
32
|
getSiteProperties(): Promise<import("axios").AxiosResponse<any, any>>;
|
|
33
33
|
saveDataFilterList(name: string, data: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
34
|
-
|
|
34
|
+
getDataFilterListByID(id: number): Promise<import("axios").AxiosResponse<any, any>>;
|
|
35
|
+
getDataFilterList(categoryName?: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
35
36
|
deleteDataFilterList(id: number): Promise<import("axios").AxiosResponse<any, any>>;
|
|
36
37
|
downloadStats(): Promise<import("axios").AxiosResponse<any, any>>;
|
|
37
38
|
}
|
|
@@ -90,6 +90,7 @@ class CurtainWebAPI {
|
|
|
90
90
|
error.config.url !== this.loginURL &&
|
|
91
91
|
error.config.url !== this.orcidLoginURL) {
|
|
92
92
|
if (!this.checkIfRefreshTokenExpired() && this.user.loginStatus) {
|
|
93
|
+
console.log("refreshing token");
|
|
93
94
|
if (!this.isRefreshing) {
|
|
94
95
|
return this.refresh().then((response) => {
|
|
95
96
|
this.isRefreshing = false;
|
|
@@ -301,13 +302,21 @@ class CurtainWebAPI {
|
|
|
301
302
|
return response;
|
|
302
303
|
});
|
|
303
304
|
}
|
|
304
|
-
|
|
305
|
+
getDataFilterListByID(id) {
|
|
305
306
|
let headers = new axios_1.AxiosHeaders();
|
|
306
307
|
headers["Accept"] = "application/json";
|
|
307
308
|
return this.axiosInstance.get(this.baseURL + "data_filter_list/" + id + "/", { headers: headers, responseType: "json" }).then((response) => {
|
|
308
309
|
return response;
|
|
309
310
|
});
|
|
310
311
|
}
|
|
312
|
+
getDataFilterList(categoryName = "") {
|
|
313
|
+
let params = new URLSearchParams();
|
|
314
|
+
if (categoryName != "") {
|
|
315
|
+
params.append("name", categoryName);
|
|
316
|
+
}
|
|
317
|
+
params.append("limit", `${99999999}`);
|
|
318
|
+
return this.axiosInstance.get(this.baseURL + "data_filter_list/", { responseType: "json", params });
|
|
319
|
+
}
|
|
311
320
|
deleteDataFilterList(id) {
|
|
312
321
|
let headers = new axios_1.AxiosHeaders();
|
|
313
322
|
headers["Accept"] = "application/json";
|
package/build/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { CurtainWebAPI, replacer, reviver } from "./classes/curtain-api";
|
|
2
2
|
import { User } from "./classes/curtain-user";
|
|
3
|
-
import { getProteomicsData, getPrideData, getEBIAlpha } from "./utilities";
|
|
4
|
-
export { CurtainWebAPI, User, getProteomicsData, getPrideData, getEBIAlpha, replacer, reviver };
|
|
3
|
+
import { getProteomicsData, getPrideData, getEBIAlpha, getInteractomeAtlas, getStringDBInteractions } from "./utilities";
|
|
4
|
+
export { CurtainWebAPI, User, getProteomicsData, getPrideData, getEBIAlpha, getInteractomeAtlas, getStringDBInteractions, replacer, reviver };
|
package/build/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.reviver = exports.replacer = exports.getEBIAlpha = exports.getPrideData = exports.getProteomicsData = exports.User = exports.CurtainWebAPI = void 0;
|
|
3
|
+
exports.reviver = exports.replacer = exports.getStringDBInteractions = exports.getInteractomeAtlas = exports.getEBIAlpha = exports.getPrideData = exports.getProteomicsData = exports.User = exports.CurtainWebAPI = void 0;
|
|
4
4
|
const curtain_api_1 = require("./classes/curtain-api");
|
|
5
5
|
Object.defineProperty(exports, "CurtainWebAPI", { enumerable: true, get: function () { return curtain_api_1.CurtainWebAPI; } });
|
|
6
6
|
Object.defineProperty(exports, "replacer", { enumerable: true, get: function () { return curtain_api_1.replacer; } });
|
|
@@ -11,3 +11,5 @@ const utilities_1 = require("./utilities");
|
|
|
11
11
|
Object.defineProperty(exports, "getProteomicsData", { enumerable: true, get: function () { return utilities_1.getProteomicsData; } });
|
|
12
12
|
Object.defineProperty(exports, "getPrideData", { enumerable: true, get: function () { return utilities_1.getPrideData; } });
|
|
13
13
|
Object.defineProperty(exports, "getEBIAlpha", { enumerable: true, get: function () { return utilities_1.getEBIAlpha; } });
|
|
14
|
+
Object.defineProperty(exports, "getInteractomeAtlas", { enumerable: true, get: function () { return utilities_1.getInteractomeAtlas; } });
|
|
15
|
+
Object.defineProperty(exports, "getStringDBInteractions", { enumerable: true, get: function () { return utilities_1.getStringDBInteractions; } });
|
package/build/utilities.d.ts
CHANGED
|
@@ -2,4 +2,4 @@ export declare function getProteomicsData(acc: string, tissueType: string): Prom
|
|
|
2
2
|
export declare function getPrideData(acc: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
3
3
|
export declare function getEBIAlpha(id: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
4
4
|
export declare function getStringDBInteractions(genes: string[], organism: string, score?: number, networkType?: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
5
|
-
export declare function
|
|
5
|
+
export declare function getInteractomeAtlas(genes: string[], filterParameter?: string): Promise<any>;
|
package/build/utilities.js
CHANGED
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
26
|
+
exports.getInteractomeAtlas = exports.getStringDBInteractions = exports.getEBIAlpha = exports.getPrideData = exports.getProteomicsData = void 0;
|
|
27
27
|
const axios_1 = __importStar(require("axios"));
|
|
28
28
|
function getProteomicsData(acc, tissueType) {
|
|
29
29
|
let headers = new axios_1.AxiosHeaders();
|
|
@@ -52,7 +52,7 @@ function getStringDBInteractions(genes, organism, score = 400, networkType = "fu
|
|
|
52
52
|
return axios_1.default.get("https://string-db.org/api/tsv/network?", { responseType: "text", params: params });
|
|
53
53
|
}
|
|
54
54
|
exports.getStringDBInteractions = getStringDBInteractions;
|
|
55
|
-
function
|
|
55
|
+
function getInteractomeAtlas(genes, filterParameter = "None") {
|
|
56
56
|
let params = new URLSearchParams();
|
|
57
57
|
params.append("query_interactors", "query");
|
|
58
58
|
params.append("query_id_array", genes.join("%2C"));
|
|
@@ -66,4 +66,4 @@ function interactomeAtlas(genes, filterParameter = "None") {
|
|
|
66
66
|
return JSON.parse(res.data);
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
|
-
exports.
|
|
69
|
+
exports.getInteractomeAtlas = getInteractomeAtlas;
|
package/curtainuser/000003.log
CHANGED
|
Binary file
|
package/curtainuser/LOG
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2023/04/
|
|
1
|
+
2023/04/16-14:57:22.789 353c Delete type=3 #1
|
package/package.json
CHANGED
|
@@ -67,6 +67,7 @@ export class CurtainWebAPI {
|
|
|
67
67
|
error.config.url !== this.loginURL &&
|
|
68
68
|
error.config.url !== this.orcidLoginURL) {
|
|
69
69
|
if (!this.checkIfRefreshTokenExpired() && this.user.loginStatus) {
|
|
70
|
+
console.log("refreshing token")
|
|
70
71
|
if (!this.isRefreshing) {
|
|
71
72
|
return this.refresh().then((response) => {
|
|
72
73
|
this.isRefreshing = false;
|
|
@@ -304,7 +305,7 @@ export class CurtainWebAPI {
|
|
|
304
305
|
});
|
|
305
306
|
}
|
|
306
307
|
|
|
307
|
-
|
|
308
|
+
getDataFilterListByID(id: number) {
|
|
308
309
|
let headers = new AxiosHeaders();
|
|
309
310
|
headers["Accept"] = "application/json";
|
|
310
311
|
return this.axiosInstance.get(this.baseURL + "data_filter_list/" + id + "/", {headers: headers, responseType:"json"}).then((response) => {
|
|
@@ -312,6 +313,15 @@ export class CurtainWebAPI {
|
|
|
312
313
|
});
|
|
313
314
|
}
|
|
314
315
|
|
|
316
|
+
getDataFilterList(categoryName: string = "") {
|
|
317
|
+
let params = new URLSearchParams();
|
|
318
|
+
if (categoryName != "") {
|
|
319
|
+
params.append("name", categoryName)
|
|
320
|
+
}
|
|
321
|
+
params.append("limit", `${99999999}`)
|
|
322
|
+
return this.axiosInstance.get(this.baseURL + "data_filter_list/", {responseType:"json", params})
|
|
323
|
+
}
|
|
324
|
+
|
|
315
325
|
deleteDataFilterList(id: number) {
|
|
316
326
|
let headers = new AxiosHeaders();
|
|
317
327
|
headers["Accept"] = "application/json";
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {CurtainWebAPI, replacer, reviver} from "./classes/curtain-api";
|
|
2
2
|
import {User} from "./classes/curtain-user";
|
|
3
|
-
import {getProteomicsData, getPrideData, getEBIAlpha} from "./utilities";
|
|
3
|
+
import {getProteomicsData, getPrideData, getEBIAlpha, getInteractomeAtlas, getStringDBInteractions} from "./utilities";
|
|
4
4
|
|
|
5
|
-
export {CurtainWebAPI, User, getProteomicsData, getPrideData, getEBIAlpha, replacer, reviver};
|
|
5
|
+
export {CurtainWebAPI, User, getProteomicsData, getPrideData, getEBIAlpha, getInteractomeAtlas, getStringDBInteractions, replacer, reviver};
|
|
@@ -102,9 +102,20 @@ describe("Session data", () => {
|
|
|
102
102
|
const curtainLogin = new CurtainWebAPI();
|
|
103
103
|
await curtainLogin.login("testroot", "testpassword")
|
|
104
104
|
const previousAccess = curtainLogin.user.access_token.slice()
|
|
105
|
+
curtainLogin.user.access_token = ""
|
|
106
|
+
expect(previousAccess).to.not.equal(curtainLogin.user.access_token)
|
|
105
107
|
await curtainLogin.refresh()
|
|
106
108
|
expect(previousAccess).to.not.equal(curtainLogin.user.access_token)
|
|
107
109
|
const result = await curtainLogin.postSettings("546c9ed7-30a6-4a0f-aedb-880815eb7051", "")
|
|
110
|
+
});
|
|
111
|
+
it('should login, expire access, then try to retrieve data', async () => {
|
|
112
|
+
const curtainLogin = new CurtainWebAPI();
|
|
113
|
+
await curtainLogin.login("testroot", "testpassword")
|
|
114
|
+
const previousAccess = curtainLogin.user.access_token.slice()
|
|
115
|
+
curtainLogin.user.access_token = ""
|
|
116
|
+
expect(previousAccess).to.not.equal(curtainLogin.user.access_token)
|
|
117
|
+
const result = await curtainLogin.postSettings("546c9ed7-30a6-4a0f-aedb-880815eb7051", "")
|
|
118
|
+
expect(previousAccess).to.not.equal(curtainLogin.user.access_token)
|
|
108
119
|
})
|
|
109
120
|
});
|
|
110
121
|
|
package/src/utilities.ts
CHANGED
|
@@ -39,7 +39,7 @@ export function getStringDBInteractions(genes: string[], organism: string, score
|
|
|
39
39
|
)
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
export function
|
|
42
|
+
export function getInteractomeAtlas(genes: string[], filterParameter: string ="None") {
|
|
43
43
|
let params = new URLSearchParams();
|
|
44
44
|
params.append("query_interactors", "query");
|
|
45
45
|
params.append("query_id_array", genes.join("%2C"));
|
|
File without changes
|