diskio-api 1.1.0 → 1.2.1
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/README.md +31 -0
- package/cjs/index.d.ts +40 -114
- package/cjs/index.js +13 -11
- package/mjs/index.d.ts +40 -114
- package/mjs/index.js +13 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -43,6 +43,37 @@ import { DiskioAPIClient } from 'diskio-api';
|
|
|
43
43
|
import { DiskioAPIClient } from 'diskio-api';
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
+
## Instance
|
|
47
|
+
```js
|
|
48
|
+
const client = new DiskioAPIClient('http://localhost:8080');
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Health Check
|
|
52
|
+
Get information about the server
|
|
53
|
+
```js
|
|
54
|
+
const response = await client.healthCheck();
|
|
55
|
+
console.log(response.data.response.diskio.size); // 10737418240
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Upload
|
|
59
|
+
```ts
|
|
60
|
+
const file: File = new File(['Hello world!'], 'hello.txt');
|
|
61
|
+
const response = await client.upload([ file ]);
|
|
62
|
+
const path = response.data.response[0];
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Download
|
|
66
|
+
```js
|
|
67
|
+
const file = await client.download(path, type: 'arrayBuffer' | 'stream') // default download is 'arrayBuffer'
|
|
68
|
+
// Work with the file
|
|
69
|
+
console.log(typeof file) // 'arraybuffer' | 'stream'
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Delete
|
|
73
|
+
```js
|
|
74
|
+
await client.delete('/path/to/file');
|
|
75
|
+
```
|
|
76
|
+
|
|
46
77
|
## 📝 License
|
|
47
78
|
|
|
48
79
|
This project is licensed under the `GNU AFFERO GENERAL PUBLIC LICENSE` - see the [LICENSE](LICENSE) file for details
|
package/cjs/index.d.ts
CHANGED
|
@@ -49,130 +49,56 @@ export declare class DiskioAPIClient {
|
|
|
49
49
|
};
|
|
50
50
|
};
|
|
51
51
|
}> | undefined, `${string}/${string}`>>;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
responses: {
|
|
68
|
-
200: {
|
|
69
|
-
headers: {
|
|
70
|
-
[name: string]: unknown;
|
|
71
|
-
};
|
|
72
|
-
content: {
|
|
73
|
-
"application/json": components["schemas"]["response.model"] & {
|
|
74
|
-
response: string[];
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
}, {
|
|
80
|
-
body: {
|
|
81
|
-
files: any;
|
|
52
|
+
upload(files: (File | Blob)[]): Promise<({
|
|
53
|
+
code: number;
|
|
54
|
+
timestamp: number;
|
|
55
|
+
} & {
|
|
56
|
+
response: string[];
|
|
57
|
+
}) | undefined>;
|
|
58
|
+
download(name: string, type?: 'arrayBuffer' | 'stream'): Promise<ArrayBuffer | ReadableStream<Uint8Array> | null | undefined>;
|
|
59
|
+
delete(name: string): Promise<import("openapi-fetch").FetchResponse<{
|
|
60
|
+
parameters: {
|
|
61
|
+
query?: never;
|
|
62
|
+
header?: never;
|
|
63
|
+
path: {
|
|
64
|
+
name: string;
|
|
82
65
|
};
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
name: string;
|
|
66
|
+
cookie?: never;
|
|
67
|
+
};
|
|
68
|
+
requestBody?: never;
|
|
69
|
+
responses: {
|
|
70
|
+
200: {
|
|
71
|
+
headers: {
|
|
72
|
+
[name: string]: unknown;
|
|
90
73
|
};
|
|
91
|
-
|
|
74
|
+
content?: never;
|
|
92
75
|
};
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
headers: {
|
|
97
|
-
[name: string]: unknown;
|
|
98
|
-
};
|
|
99
|
-
content: {
|
|
100
|
-
"application/octet-stream": string;
|
|
101
|
-
};
|
|
102
|
-
};
|
|
103
|
-
404: {
|
|
104
|
-
headers: {
|
|
105
|
-
[name: string]: unknown;
|
|
106
|
-
};
|
|
107
|
-
content: {
|
|
108
|
-
"application/json": components["schemas"]["not-found-response.model"] & {
|
|
109
|
-
response: string;
|
|
110
|
-
};
|
|
111
|
-
};
|
|
76
|
+
404: {
|
|
77
|
+
headers: {
|
|
78
|
+
[name: string]: unknown;
|
|
112
79
|
};
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
};
|
|
117
|
-
content: {
|
|
118
|
-
"application/json": components["schemas"]["internal-server-error-response.model"] & {
|
|
119
|
-
response: string;
|
|
120
|
-
};
|
|
80
|
+
content: {
|
|
81
|
+
"application/json": components["schemas"]["not-found-response.model"] & {
|
|
82
|
+
response: string;
|
|
121
83
|
};
|
|
122
84
|
};
|
|
123
85
|
};
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
name: string;
|
|
128
|
-
};
|
|
129
|
-
};
|
|
130
|
-
responseType: string;
|
|
131
|
-
}, `${string}/${string}`>>;
|
|
132
|
-
delete: (name: string) => Promise<import("openapi-fetch").FetchResponse<{
|
|
133
|
-
parameters: {
|
|
134
|
-
query?: never;
|
|
135
|
-
header?: never;
|
|
136
|
-
path: {
|
|
137
|
-
name: string;
|
|
138
|
-
};
|
|
139
|
-
cookie?: never;
|
|
140
|
-
};
|
|
141
|
-
requestBody?: never;
|
|
142
|
-
responses: {
|
|
143
|
-
200: {
|
|
144
|
-
headers: {
|
|
145
|
-
[name: string]: unknown;
|
|
146
|
-
};
|
|
147
|
-
content?: never;
|
|
148
|
-
};
|
|
149
|
-
404: {
|
|
150
|
-
headers: {
|
|
151
|
-
[name: string]: unknown;
|
|
152
|
-
};
|
|
153
|
-
content: {
|
|
154
|
-
"application/json": components["schemas"]["not-found-response.model"] & {
|
|
155
|
-
response: string;
|
|
156
|
-
};
|
|
157
|
-
};
|
|
86
|
+
500: {
|
|
87
|
+
headers: {
|
|
88
|
+
[name: string]: unknown;
|
|
158
89
|
};
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
};
|
|
163
|
-
content: {
|
|
164
|
-
"application/json": components["schemas"]["internal-server-error-response.model"] & {
|
|
165
|
-
response: string;
|
|
166
|
-
};
|
|
90
|
+
content: {
|
|
91
|
+
"application/json": components["schemas"]["internal-server-error-response.model"] & {
|
|
92
|
+
response: string;
|
|
167
93
|
};
|
|
168
94
|
};
|
|
169
95
|
};
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
96
|
+
};
|
|
97
|
+
}, {
|
|
98
|
+
params: {
|
|
99
|
+
path: {
|
|
100
|
+
name: string;
|
|
175
101
|
};
|
|
176
|
-
}
|
|
177
|
-
}
|
|
102
|
+
};
|
|
103
|
+
}, `${string}/${string}`>>;
|
|
178
104
|
}
|
package/cjs/index.js
CHANGED
|
@@ -23,22 +23,24 @@ class DiskioAPIClient {
|
|
|
23
23
|
return this.authentication;
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
|
-
this.diskio = {
|
|
27
|
-
upload: (files) => {
|
|
28
|
-
return this.client.POST('/diskio', { body: { files: files } });
|
|
29
|
-
},
|
|
30
|
-
download: (name) => {
|
|
31
|
-
return this.client.GET('/diskio/{name}', { params: { path: { name } }, responseType: 'arraybuffer' });
|
|
32
|
-
},
|
|
33
|
-
delete: (name) => {
|
|
34
|
-
return this.client.DELETE('/diskio/{name}', { params: { path: { name } } });
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
26
|
this.client = (0, openapi_fetch_1.default)({ baseUrl, headers: { Bearer: 'access_token' } });
|
|
38
27
|
this.client.use(this.authenticate);
|
|
39
28
|
}
|
|
40
29
|
healthCheck() {
|
|
41
30
|
return this.client.GET('/health-check');
|
|
42
31
|
}
|
|
32
|
+
async upload(files) {
|
|
33
|
+
const formData = new FormData();
|
|
34
|
+
files.forEach((file) => formData.append('files', file));
|
|
35
|
+
const response = this.client.POST('/diskio', { body: formData });
|
|
36
|
+
return response.data;
|
|
37
|
+
}
|
|
38
|
+
async download(name, type = 'arrayBuffer') {
|
|
39
|
+
const response = this.client.GET('/diskio/{name}', { params: { path: { name } }, parseAs: type });
|
|
40
|
+
return response.data;
|
|
41
|
+
}
|
|
42
|
+
delete(name) {
|
|
43
|
+
return this.client.DELETE('/diskio/{name}', { params: { path: { name } } });
|
|
44
|
+
}
|
|
43
45
|
}
|
|
44
46
|
exports.DiskioAPIClient = DiskioAPIClient;
|
package/mjs/index.d.ts
CHANGED
|
@@ -49,130 +49,56 @@ export declare class DiskioAPIClient {
|
|
|
49
49
|
};
|
|
50
50
|
};
|
|
51
51
|
}> | undefined, `${string}/${string}`>>;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
responses: {
|
|
68
|
-
200: {
|
|
69
|
-
headers: {
|
|
70
|
-
[name: string]: unknown;
|
|
71
|
-
};
|
|
72
|
-
content: {
|
|
73
|
-
"application/json": components["schemas"]["response.model"] & {
|
|
74
|
-
response: string[];
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
}, {
|
|
80
|
-
body: {
|
|
81
|
-
files: any;
|
|
52
|
+
upload(files: (File | Blob)[]): Promise<({
|
|
53
|
+
code: number;
|
|
54
|
+
timestamp: number;
|
|
55
|
+
} & {
|
|
56
|
+
response: string[];
|
|
57
|
+
}) | undefined>;
|
|
58
|
+
download(name: string, type?: 'arrayBuffer' | 'stream'): Promise<ArrayBuffer | ReadableStream<Uint8Array> | null | undefined>;
|
|
59
|
+
delete(name: string): Promise<import("openapi-fetch").FetchResponse<{
|
|
60
|
+
parameters: {
|
|
61
|
+
query?: never;
|
|
62
|
+
header?: never;
|
|
63
|
+
path: {
|
|
64
|
+
name: string;
|
|
82
65
|
};
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
name: string;
|
|
66
|
+
cookie?: never;
|
|
67
|
+
};
|
|
68
|
+
requestBody?: never;
|
|
69
|
+
responses: {
|
|
70
|
+
200: {
|
|
71
|
+
headers: {
|
|
72
|
+
[name: string]: unknown;
|
|
90
73
|
};
|
|
91
|
-
|
|
74
|
+
content?: never;
|
|
92
75
|
};
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
headers: {
|
|
97
|
-
[name: string]: unknown;
|
|
98
|
-
};
|
|
99
|
-
content: {
|
|
100
|
-
"application/octet-stream": string;
|
|
101
|
-
};
|
|
102
|
-
};
|
|
103
|
-
404: {
|
|
104
|
-
headers: {
|
|
105
|
-
[name: string]: unknown;
|
|
106
|
-
};
|
|
107
|
-
content: {
|
|
108
|
-
"application/json": components["schemas"]["not-found-response.model"] & {
|
|
109
|
-
response: string;
|
|
110
|
-
};
|
|
111
|
-
};
|
|
76
|
+
404: {
|
|
77
|
+
headers: {
|
|
78
|
+
[name: string]: unknown;
|
|
112
79
|
};
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
};
|
|
117
|
-
content: {
|
|
118
|
-
"application/json": components["schemas"]["internal-server-error-response.model"] & {
|
|
119
|
-
response: string;
|
|
120
|
-
};
|
|
80
|
+
content: {
|
|
81
|
+
"application/json": components["schemas"]["not-found-response.model"] & {
|
|
82
|
+
response: string;
|
|
121
83
|
};
|
|
122
84
|
};
|
|
123
85
|
};
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
name: string;
|
|
128
|
-
};
|
|
129
|
-
};
|
|
130
|
-
responseType: string;
|
|
131
|
-
}, `${string}/${string}`>>;
|
|
132
|
-
delete: (name: string) => Promise<import("openapi-fetch").FetchResponse<{
|
|
133
|
-
parameters: {
|
|
134
|
-
query?: never;
|
|
135
|
-
header?: never;
|
|
136
|
-
path: {
|
|
137
|
-
name: string;
|
|
138
|
-
};
|
|
139
|
-
cookie?: never;
|
|
140
|
-
};
|
|
141
|
-
requestBody?: never;
|
|
142
|
-
responses: {
|
|
143
|
-
200: {
|
|
144
|
-
headers: {
|
|
145
|
-
[name: string]: unknown;
|
|
146
|
-
};
|
|
147
|
-
content?: never;
|
|
148
|
-
};
|
|
149
|
-
404: {
|
|
150
|
-
headers: {
|
|
151
|
-
[name: string]: unknown;
|
|
152
|
-
};
|
|
153
|
-
content: {
|
|
154
|
-
"application/json": components["schemas"]["not-found-response.model"] & {
|
|
155
|
-
response: string;
|
|
156
|
-
};
|
|
157
|
-
};
|
|
86
|
+
500: {
|
|
87
|
+
headers: {
|
|
88
|
+
[name: string]: unknown;
|
|
158
89
|
};
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
};
|
|
163
|
-
content: {
|
|
164
|
-
"application/json": components["schemas"]["internal-server-error-response.model"] & {
|
|
165
|
-
response: string;
|
|
166
|
-
};
|
|
90
|
+
content: {
|
|
91
|
+
"application/json": components["schemas"]["internal-server-error-response.model"] & {
|
|
92
|
+
response: string;
|
|
167
93
|
};
|
|
168
94
|
};
|
|
169
95
|
};
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
96
|
+
};
|
|
97
|
+
}, {
|
|
98
|
+
params: {
|
|
99
|
+
path: {
|
|
100
|
+
name: string;
|
|
175
101
|
};
|
|
176
|
-
}
|
|
177
|
-
}
|
|
102
|
+
};
|
|
103
|
+
}, `${string}/${string}`>>;
|
|
178
104
|
}
|
package/mjs/index.js
CHANGED
|
@@ -17,21 +17,23 @@ export class DiskioAPIClient {
|
|
|
17
17
|
return this.authentication;
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
|
-
this.diskio = {
|
|
21
|
-
upload: (files) => {
|
|
22
|
-
return this.client.POST('/diskio', { body: { files: files } });
|
|
23
|
-
},
|
|
24
|
-
download: (name) => {
|
|
25
|
-
return this.client.GET('/diskio/{name}', { params: { path: { name } }, responseType: 'arraybuffer' });
|
|
26
|
-
},
|
|
27
|
-
delete: (name) => {
|
|
28
|
-
return this.client.DELETE('/diskio/{name}', { params: { path: { name } } });
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
20
|
this.client = createClient({ baseUrl, headers: { Bearer: 'access_token' } });
|
|
32
21
|
this.client.use(this.authenticate);
|
|
33
22
|
}
|
|
34
23
|
healthCheck() {
|
|
35
24
|
return this.client.GET('/health-check');
|
|
36
25
|
}
|
|
26
|
+
async upload(files) {
|
|
27
|
+
const formData = new FormData();
|
|
28
|
+
files.forEach((file) => formData.append('files', file));
|
|
29
|
+
const response = await this.client.POST('/diskio', { body: formData });
|
|
30
|
+
return response.data;
|
|
31
|
+
}
|
|
32
|
+
async download(name, type = 'arrayBuffer') {
|
|
33
|
+
const response = await this.client.GET('/diskio/{name}', { params: { path: { name } }, parseAs: type });
|
|
34
|
+
return response.data;
|
|
35
|
+
}
|
|
36
|
+
delete(name) {
|
|
37
|
+
return this.client.DELETE('/diskio/{name}', { params: { path: { name } } });
|
|
38
|
+
}
|
|
37
39
|
}
|