@metarisc/metarisc-js 0.0.1-alpha.73 → 0.0.1-alpha.75

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/lib/client.d.ts CHANGED
@@ -11,6 +11,7 @@ interface RequestConfig {
11
11
  };
12
12
  endpoint?: string;
13
13
  method?: string;
14
+ responseType?: "arraybuffer" | "blob" | "document" | "json" | "text" | "stream";
14
15
  }
15
16
  export declare enum AuthMethod {
16
17
  CLIENT_CREDENTIALS = 0,
package/lib/client.js CHANGED
@@ -120,7 +120,8 @@ class Client {
120
120
  url: config.endpoint || "/",
121
121
  params: config.params,
122
122
  data: config.body,
123
- headers: config.headers
123
+ headers: config.headers,
124
+ responseType: config.responseType
124
125
  }).then((response) => {
125
126
  this.emit(EventEnum.response, response);
126
127
  return response;
package/lib/core.d.ts CHANGED
@@ -12,6 +12,7 @@ interface RequestConfig {
12
12
  };
13
13
  endpoint?: string;
14
14
  method?: string;
15
+ responseType?: "arraybuffer" | "blob" | "document" | "json" | "text" | "stream";
15
16
  }
16
17
  export interface MetariscConfig {
17
18
  metarisc_url?: string;
package/lib/tus.d.ts CHANGED
@@ -3,5 +3,8 @@ import { Client } from './client';
3
3
  export declare class Tus extends Core {
4
4
  constructor(config: MetariscConfig, client: Client);
5
5
  upload(file: File, errorFn: (error: Error) => void, chunckFn: (url: string, progress: number) => void, successFn: () => void): void;
6
- download(fileId: string): Promise<import("axios").AxiosResponse<unknown, any>>;
6
+ /**
7
+ * Récupération d'un fichier stocké sous forme de Blob.
8
+ */
9
+ download(url: string): Promise<Blob>;
7
10
  }
package/lib/tus.js CHANGED
@@ -47,10 +47,16 @@ class Tus extends core_1.Core {
47
47
  });
48
48
  upload.start();
49
49
  }
50
- download(fileId) {
50
+ /**
51
+ * Récupération d'un fichier stocké sous forme de Blob.
52
+ */
53
+ async download(url) {
51
54
  return this.request({
52
55
  method: "GET",
53
- endpoint: "/resumable-file-uploads/files/" + fileId
56
+ endpoint: url,
57
+ responseType: "blob"
58
+ }).then((response) => {
59
+ return response.data;
54
60
  });
55
61
  }
56
62
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@metarisc/metarisc-js",
3
3
  "main": "lib/index.js",
4
4
  "types": "lib/index.d.ts",
5
- "version": "0.0.1-alpha.73",
5
+ "version": "0.0.1-alpha.75",
6
6
  "scripts": {
7
7
  "lint": "eslint . --ext .ts --fix",
8
8
  "compile": "tsc",
@@ -18,7 +18,7 @@
18
18
  "typescript": "^4.9.5"
19
19
  },
20
20
  "dependencies": {
21
- "axios": "^1.4.0",
21
+ "axios": "^1.7.7",
22
22
  "axios-cache-interceptor": "^1.3.2",
23
23
  "axios-oauth-client": "^2.0.4",
24
24
  "axios-retry": "^3.5.0",
package/src/client.ts CHANGED
@@ -16,6 +16,13 @@ interface RequestConfig {
16
16
  params?: { [param: string]: string | string[] };
17
17
  endpoint?: string;
18
18
  method?: string;
19
+ responseType?:
20
+ | "arraybuffer"
21
+ | "blob"
22
+ | "document"
23
+ | "json"
24
+ | "text"
25
+ | "stream";
19
26
  }
20
27
 
21
28
  export enum AuthMethod {
@@ -148,7 +155,8 @@ export class Client {
148
155
  url: config.endpoint || "/",
149
156
  params: config.params,
150
157
  data: config.body,
151
- headers: config.headers
158
+ headers: config.headers,
159
+ responseType: config.responseType
152
160
  }).then((response) => {
153
161
  this.emit(EventEnum.response, response);
154
162
  return response;
package/src/core.ts CHANGED
@@ -9,6 +9,13 @@ interface RequestConfig {
9
9
  params?: { [param: string]: string | string[] };
10
10
  endpoint?: string;
11
11
  method?: string;
12
+ responseType?:
13
+ | "arraybuffer"
14
+ | "blob"
15
+ | "document"
16
+ | "json"
17
+ | "text"
18
+ | "stream";
12
19
  }
13
20
 
14
21
  export interface MetariscConfig {
package/src/tus.ts CHANGED
@@ -55,10 +55,16 @@ export class Tus extends Core
55
55
  upload.start();
56
56
  }
57
57
 
58
- download(fileId: string) {
58
+ /**
59
+ * Récupération d'un fichier stocké sous forme de Blob.
60
+ */
61
+ async download(url: string): Promise<Blob> {
59
62
  return this.request({
60
63
  method: "GET",
61
- endpoint: "/resumable-file-uploads/files/" + fileId
64
+ endpoint: url,
65
+ responseType: "blob"
66
+ }).then((response) => {
67
+ return response.data as Blob;
62
68
  });
63
69
  }
64
70
  }