polfan-server-js-client 0.2.36 → 0.2.37
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/workspace.xml +18 -3
- package/build/index.cjs.js +7 -2
- package/build/index.cjs.js.map +1 -1
- package/build/index.umd.js +1 -1
- package/build/index.umd.js.map +1 -1
- package/build/types/FilesClient.d.ts +6 -5
- package/package.json +1 -1
- package/src/FilesClient.ts +12 -6
|
@@ -2,14 +2,15 @@ import { AbstractRestClient, RestClientResponse } from "./AbstractRestClient";
|
|
|
2
2
|
export interface File {
|
|
3
3
|
id: string;
|
|
4
4
|
url: string;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
mime_type: string;
|
|
5
|
+
name: string;
|
|
6
|
+
mime: string;
|
|
8
7
|
size: number;
|
|
9
|
-
|
|
8
|
+
width?: number;
|
|
9
|
+
height?: number;
|
|
10
10
|
}
|
|
11
11
|
export declare class FilesClient extends AbstractRestClient {
|
|
12
12
|
protected defaultUrl: string;
|
|
13
13
|
uploadFile(file: Parameters<typeof FormData.prototype.append>[1]): Promise<RestClientResponse<File>>;
|
|
14
|
-
|
|
14
|
+
getFileMeta(id: string): Promise<RestClientResponse<File>>;
|
|
15
|
+
getFileMetaBulk(ids: string[]): Promise<RestClientResponse<File[]>>;
|
|
15
16
|
}
|
package/package.json
CHANGED
package/src/FilesClient.ts
CHANGED
|
@@ -3,15 +3,15 @@ import {AbstractRestClient, RestClientResponse} from "./AbstractRestClient";
|
|
|
3
3
|
export interface File {
|
|
4
4
|
id: string;
|
|
5
5
|
url: string;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
mime_type: string;
|
|
6
|
+
name: string;
|
|
7
|
+
mime: string;
|
|
9
8
|
size: number;
|
|
10
|
-
|
|
9
|
+
width?: number;
|
|
10
|
+
height?: number;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export class FilesClient extends AbstractRestClient {
|
|
14
|
-
protected defaultUrl: string = 'https://
|
|
14
|
+
protected defaultUrl: string = 'https://files.devana.pl/files';
|
|
15
15
|
|
|
16
16
|
public async uploadFile(file: Parameters<typeof FormData.prototype.append>[1]): Promise<RestClientResponse<File>> {
|
|
17
17
|
const formData = new FormData();
|
|
@@ -24,7 +24,13 @@ export class FilesClient extends AbstractRestClient {
|
|
|
24
24
|
return this.convertFetchResponse<File>(response);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
public async
|
|
27
|
+
public async getFileMeta(id: string): Promise<RestClientResponse<File>> {
|
|
28
28
|
return this.send('GET', '/' + id);
|
|
29
29
|
}
|
|
30
|
+
|
|
31
|
+
public async getFileMetaBulk(ids: string[]): Promise<RestClientResponse<File[]>> {
|
|
32
|
+
const searchParams = new URLSearchParams();
|
|
33
|
+
ids.forEach(id => searchParams.append('id[]', id));
|
|
34
|
+
return this.send('GET', '?' + searchParams);
|
|
35
|
+
}
|
|
30
36
|
}
|