curtain-web-api 1.0.4 → 1.0.5

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.
@@ -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
- getDataFilterList(id: number): Promise<import("axios").AxiosResponse<any, any>>;
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
- getDataFilterList(id) {
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";
Binary file
package/curtainuser/LOG CHANGED
@@ -1 +1 @@
1
- 2023/04/15-17:56:07.976 99c Delete type=3 #1
1
+ 2023/04/16-14:57:22.789 353c Delete type=3 #1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "curtain-web-api",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -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
- getDataFilterList(id: number) {
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";
@@ -100,11 +100,22 @@ describe("Session data", () => {
100
100
  })
101
101
  it('should login and then retrieve session data', async () => {
102
102
  const curtainLogin = new CurtainWebAPI();
103
- await curtainLogin.login("testroot", "testpassword")
103
+ await curtainLogin.login("root", "21021992pkqtoaN")
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("root", "21021992pkqtoaN")
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