@metarisc/metarisc-js 0.0.1-alpha.74 → 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.js CHANGED
@@ -53,16 +53,10 @@ class Tus extends core_1.Core {
53
53
  async download(url) {
54
54
  return this.request({
55
55
  method: "GET",
56
- endpoint: url
56
+ endpoint: url,
57
+ responseType: "blob"
57
58
  }).then((response) => {
58
- //Récupérer le type de fichier
59
- const fileType = response.headers["content-type"] ||
60
- "application/octet-stream";
61
- // Créer un tableau de bytes à partir de la réponse
62
- const encoder = new TextEncoder();
63
- const byteArray = encoder.encode(response.data);
64
- // Créer et retourner un Blob à partir du tableau de bytes
65
- return new Blob([byteArray], { type: fileType });
59
+ return response.data;
66
60
  });
67
61
  }
68
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.74",
5
+ "version": "0.0.1-alpha.75",
6
6
  "scripts": {
7
7
  "lint": "eslint . --ext .ts --fix",
8
8
  "compile": "tsc",
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
@@ -61,20 +61,10 @@ export class Tus extends Core
61
61
  async download(url: string): Promise<Blob> {
62
62
  return this.request({
63
63
  method: "GET",
64
- endpoint: url
64
+ endpoint: url,
65
+ responseType: "blob"
65
66
  }).then((response) => {
66
-
67
- //Récupérer le type de fichier
68
- const fileType =
69
- (response.headers["content-type"] as string) ||
70
- "application/octet-stream";
71
-
72
- // Créer un tableau de bytes à partir de la réponse
73
- const encoder = new TextEncoder();
74
- const byteArray = encoder.encode(response.data as string);
75
-
76
- // Créer et retourner un Blob à partir du tableau de bytes
77
- return new Blob([byteArray], { type: fileType });
67
+ return response.data as Blob;
78
68
  });
79
69
  }
80
70
  }