curtain-web-api 1.0.19 → 1.0.21

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.
@@ -7,6 +7,7 @@ export declare class CurtainWebAPI {
7
7
  refereshURL: string;
8
8
  orcidLoginURL: string;
9
9
  userInfoURL: string;
10
+ curtainURL: string;
10
11
  user: User;
11
12
  isRefreshing: boolean;
12
13
  axiosInstance: import("axios").AxiosInstance;
@@ -55,6 +55,7 @@ class CurtainWebAPI {
55
55
  this.refereshURL = "";
56
56
  this.orcidLoginURL = "";
57
57
  this.userInfoURL = "";
58
+ this.curtainURL = "";
58
59
  this.user = new curtain_user_1.User();
59
60
  this.isRefreshing = false;
60
61
  this.axiosInstance = axios_1.default.create();
@@ -65,6 +66,7 @@ class CurtainWebAPI {
65
66
  this.refereshURL = baseURL + "token/refresh/";
66
67
  this.orcidLoginURL = baseURL + "rest-auth/orcid/";
67
68
  this.userInfoURL = baseURL + "user/";
69
+ this.curtainURL = baseURL + "curtain/";
68
70
  this.axiosInstance.interceptors.request.use((config) => {
69
71
  if (config.url) {
70
72
  /*if (!this.checkIfRefreshTokenExpired() && this.user.loginStatus) {
@@ -92,7 +94,7 @@ class CurtainWebAPI {
92
94
  //config.url === this.refereshURL ||
93
95
  config.url === this.logoutURL ||
94
96
  config.url === this.userInfoURL ||
95
- config.url.startsWith(this.baseURL + "curtain/") ||
97
+ config.url.startsWith(this.curtainURL) ||
96
98
  config.url.startsWith(this.baseURL + "data_filter_list/")) {
97
99
  if (this.user.loginStatus) {
98
100
  config.headers["Authorization"] = "Bearer " + this.user.access_token;
@@ -231,8 +233,15 @@ class CurtainWebAPI {
231
233
  let headers = new axios_1.AxiosHeaders();
232
234
  headers["Accept"] = "application/json";
233
235
  if (onDownloadProgress !== undefined) {
234
- return this.axiosInstance.get(this.baseURL + "curtain/" + id + "/download/token=" + token + "/", { responseType: "json", onDownloadProgress: onDownloadProgress }).then((response) => {
235
- return response;
236
+ return this.axiosInstance.get(this.baseURL + "curtain/" + id + "/download/token=" + token + "/", { responseType: "json" }).then((response) => {
237
+ if ("url" in response.data) {
238
+ return this.axiosInstance.get(response.data.url, { responseType: "json", onDownloadProgress: onDownloadProgress }).then((response) => {
239
+ return response;
240
+ });
241
+ }
242
+ else {
243
+ return response;
244
+ }
236
245
  });
237
246
  }
238
247
  return this.axiosInstance.get(this.baseURL + "curtain/" + id + "/download/token=" + token + "/", { responseType: "json" }).then((response) => {
@@ -396,7 +405,7 @@ class CurtainWebAPI {
396
405
  let headers = new axios_1.AxiosHeaders();
397
406
  headers["Accept"] = "application/json";
398
407
  headers["Content-Type"] = "application/json";
399
- return axios_1.default.post(this.baseURL + "primitive-stats-test/", { data, type }, { headers: headers, responseType: "json" }).then((response) => {
408
+ return axios_1.default.post(this.baseURL + "primitive-stats-test/", { data, type }).then((response) => {
400
409
  return response;
401
410
  });
402
411
  }
Binary file
package/curtainuser/LOG CHANGED
@@ -1 +1 @@
1
- 2023/04/16-14:57:22.789 353c Delete type=3 #1
1
+ 2023/07/26-14:29:40.802 c4f4 Delete type=3 #1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "curtain-web-api",
3
- "version": "1.0.19",
3
+ "version": "1.0.21",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -29,6 +29,7 @@ export class CurtainWebAPI {
29
29
  refereshURL: string = "";
30
30
  orcidLoginURL: string = "";
31
31
  userInfoURL: string = "";
32
+ curtainURL: string = "";
32
33
  user: User = new User();
33
34
  isRefreshing: boolean = false;
34
35
  axiosInstance = axios.create()
@@ -41,6 +42,7 @@ export class CurtainWebAPI {
41
42
  this.refereshURL = baseURL + "token/refresh/";
42
43
  this.orcidLoginURL = baseURL + "rest-auth/orcid/";
43
44
  this.userInfoURL = baseURL + "user/";
45
+ this.curtainURL = baseURL + "curtain/"
44
46
  this.axiosInstance.interceptors.request.use((config) => {
45
47
  if (config.url) {
46
48
  /*if (!this.checkIfRefreshTokenExpired() && this.user.loginStatus) {
@@ -68,7 +70,7 @@ export class CurtainWebAPI {
68
70
  //config.url === this.refereshURL ||
69
71
  config.url === this.logoutURL ||
70
72
  config.url === this.userInfoURL ||
71
- config.url.startsWith(this.baseURL + "curtain/") ||
73
+ config.url.startsWith(this.curtainURL) ||
72
74
  config.url.startsWith(this.baseURL + "data_filter_list/")) {
73
75
  if (this.user.loginStatus) {
74
76
  config.headers["Authorization"] = "Bearer " + this.user.access_token;
@@ -219,8 +221,14 @@ export class CurtainWebAPI {
219
221
  let headers = new AxiosHeaders();
220
222
  headers["Accept"] = "application/json";
221
223
  if (onDownloadProgress !== undefined) {
222
- return this.axiosInstance.get(this.baseURL + "curtain/" + id + "/download/token=" + token + "/", {responseType:"json", onDownloadProgress: onDownloadProgress}).then((response) => {
223
- return response;
224
+ return this.axiosInstance.get(this.baseURL + "curtain/" + id + "/download/token=" + token + "/", {responseType:"json"}).then((response) => {
225
+ if ("url" in response.data) {
226
+ return this.axiosInstance.get(response.data.url, {responseType: "json", onDownloadProgress: onDownloadProgress}).then((response) => {
227
+ return response;
228
+ })
229
+ } else {
230
+ return response;
231
+ }
224
232
  })
225
233
  }
226
234
  return this.axiosInstance.get(this.baseURL + "curtain/" + id + "/download/token=" + token + "/", {responseType:"json"}).then((response) => {
@@ -411,7 +419,7 @@ export class CurtainWebAPI {
411
419
  let headers = new AxiosHeaders();
412
420
  headers["Accept"] = "application/json";
413
421
  headers["Content-Type"] = "application/json";
414
- return axios.post(this.baseURL + "primitive-stats-test/", {data,type}, {headers: headers, responseType: "json"}).then((response) => {
422
+ return axios.post(this.baseURL + "primitive-stats-test/", {data,type}, ).then((response) => {
415
423
  return response;
416
424
  });
417
425
  }