diskio-api 1.0.1 → 1.2.0

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 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,4 +49,81 @@ export declare class DiskioAPIClient {
49
49
  };
50
50
  };
51
51
  }> | undefined, `${string}/${string}`>>;
52
+ upload(files: File[]): Promise<import("openapi-fetch").FetchResponse<{
53
+ parameters: {
54
+ query?: never;
55
+ header?: never;
56
+ path?: never;
57
+ cookie?: never;
58
+ };
59
+ requestBody: {
60
+ content: {
61
+ "multipart/form-data": {
62
+ files: string[];
63
+ };
64
+ };
65
+ };
66
+ responses: {
67
+ 200: {
68
+ headers: {
69
+ [name: string]: unknown;
70
+ };
71
+ content: {
72
+ "application/json": components["schemas"]["response.model"] & {
73
+ response: string[];
74
+ };
75
+ };
76
+ };
77
+ };
78
+ }, {
79
+ body: {
80
+ files: any;
81
+ };
82
+ }, `${string}/${string}`>>;
83
+ download(name: string, type?: 'arrayBuffer' | 'stream'): Promise<ArrayBuffer | ReadableStream<Uint8Array> | null | undefined>;
84
+ delete(name: string): Promise<import("openapi-fetch").FetchResponse<{
85
+ parameters: {
86
+ query?: never;
87
+ header?: never;
88
+ path: {
89
+ name: string;
90
+ };
91
+ cookie?: never;
92
+ };
93
+ requestBody?: never;
94
+ responses: {
95
+ 200: {
96
+ headers: {
97
+ [name: string]: unknown;
98
+ };
99
+ content?: never;
100
+ };
101
+ 404: {
102
+ headers: {
103
+ [name: string]: unknown;
104
+ };
105
+ content: {
106
+ "application/json": components["schemas"]["not-found-response.model"] & {
107
+ response: string;
108
+ };
109
+ };
110
+ };
111
+ 500: {
112
+ headers: {
113
+ [name: string]: unknown;
114
+ };
115
+ content: {
116
+ "application/json": components["schemas"]["internal-server-error-response.model"] & {
117
+ response: string;
118
+ };
119
+ };
120
+ };
121
+ };
122
+ }, {
123
+ params: {
124
+ path: {
125
+ name: string;
126
+ };
127
+ };
128
+ }, `${string}/${string}`>>;
52
129
  }
package/cjs/index.js CHANGED
@@ -29,5 +29,15 @@ class DiskioAPIClient {
29
29
  healthCheck() {
30
30
  return this.client.GET('/health-check');
31
31
  }
32
+ upload(files) {
33
+ return this.client.POST('/diskio', { body: { files: files } });
34
+ }
35
+ async download(name, type = 'arrayBuffer') {
36
+ const response = this.client.GET('/diskio/{name}', { params: { path: { name } }, parseAs: type });
37
+ return response.data;
38
+ }
39
+ delete(name) {
40
+ return this.client.DELETE('/diskio/{name}', { params: { path: { name } } });
41
+ }
32
42
  }
33
43
  exports.DiskioAPIClient = DiskioAPIClient;
package/mjs/index.d.ts CHANGED
@@ -49,4 +49,81 @@ export declare class DiskioAPIClient {
49
49
  };
50
50
  };
51
51
  }> | undefined, `${string}/${string}`>>;
52
+ upload(files: File[]): Promise<import("openapi-fetch").FetchResponse<{
53
+ parameters: {
54
+ query?: never;
55
+ header?: never;
56
+ path?: never;
57
+ cookie?: never;
58
+ };
59
+ requestBody: {
60
+ content: {
61
+ "multipart/form-data": {
62
+ files: string[];
63
+ };
64
+ };
65
+ };
66
+ responses: {
67
+ 200: {
68
+ headers: {
69
+ [name: string]: unknown;
70
+ };
71
+ content: {
72
+ "application/json": components["schemas"]["response.model"] & {
73
+ response: string[];
74
+ };
75
+ };
76
+ };
77
+ };
78
+ }, {
79
+ body: {
80
+ files: any;
81
+ };
82
+ }, `${string}/${string}`>>;
83
+ download(name: string, type?: 'arrayBuffer' | 'stream'): Promise<ArrayBuffer | ReadableStream<Uint8Array> | null | undefined>;
84
+ delete(name: string): Promise<import("openapi-fetch").FetchResponse<{
85
+ parameters: {
86
+ query?: never;
87
+ header?: never;
88
+ path: {
89
+ name: string;
90
+ };
91
+ cookie?: never;
92
+ };
93
+ requestBody?: never;
94
+ responses: {
95
+ 200: {
96
+ headers: {
97
+ [name: string]: unknown;
98
+ };
99
+ content?: never;
100
+ };
101
+ 404: {
102
+ headers: {
103
+ [name: string]: unknown;
104
+ };
105
+ content: {
106
+ "application/json": components["schemas"]["not-found-response.model"] & {
107
+ response: string;
108
+ };
109
+ };
110
+ };
111
+ 500: {
112
+ headers: {
113
+ [name: string]: unknown;
114
+ };
115
+ content: {
116
+ "application/json": components["schemas"]["internal-server-error-response.model"] & {
117
+ response: string;
118
+ };
119
+ };
120
+ };
121
+ };
122
+ }, {
123
+ params: {
124
+ path: {
125
+ name: string;
126
+ };
127
+ };
128
+ }, `${string}/${string}`>>;
52
129
  }
package/mjs/index.js CHANGED
@@ -23,4 +23,14 @@ export class DiskioAPIClient {
23
23
  healthCheck() {
24
24
  return this.client.GET('/health-check');
25
25
  }
26
+ upload(files) {
27
+ return this.client.POST('/diskio', { body: { files: files } });
28
+ }
29
+ async download(name, type = 'arrayBuffer') {
30
+ const response = await this.client.GET('/diskio/{name}', { params: { path: { name } }, parseAs: type });
31
+ return response.data;
32
+ }
33
+ delete(name) {
34
+ return this.client.DELETE('/diskio/{name}', { params: { path: { name } } });
35
+ }
26
36
  }
@@ -42,6 +42,156 @@ export interface paths {
42
42
  patch?: never;
43
43
  trace?: never;
44
44
  };
45
+ "/diskio": {
46
+ parameters: {
47
+ query?: never;
48
+ header?: never;
49
+ path?: never;
50
+ cookie?: never;
51
+ };
52
+ get?: never;
53
+ put?: never;
54
+ /** Upload a file */
55
+ post: {
56
+ parameters: {
57
+ query?: never;
58
+ header?: never;
59
+ path?: never;
60
+ cookie?: never;
61
+ };
62
+ requestBody: {
63
+ content: {
64
+ "multipart/form-data": {
65
+ files: string[];
66
+ };
67
+ };
68
+ };
69
+ responses: {
70
+ /** @description File names */
71
+ 200: {
72
+ headers: {
73
+ [name: string]: unknown;
74
+ };
75
+ content: {
76
+ "application/json": components["schemas"]["response.model"] & {
77
+ response: string[];
78
+ };
79
+ };
80
+ };
81
+ };
82
+ };
83
+ delete?: never;
84
+ options?: never;
85
+ head?: never;
86
+ patch?: never;
87
+ trace?: never;
88
+ };
89
+ "/diskio/{name}": {
90
+ parameters: {
91
+ query?: never;
92
+ header?: never;
93
+ path?: never;
94
+ cookie?: never;
95
+ };
96
+ /** Download a file */
97
+ get: {
98
+ parameters: {
99
+ query?: never;
100
+ header?: never;
101
+ path: {
102
+ name: string;
103
+ };
104
+ cookie?: never;
105
+ };
106
+ requestBody?: never;
107
+ responses: {
108
+ /** @description File */
109
+ 200: {
110
+ headers: {
111
+ [name: string]: unknown;
112
+ };
113
+ content: {
114
+ "application/octet-stream": string;
115
+ };
116
+ };
117
+ /** @description Folder not found */
118
+ 404: {
119
+ headers: {
120
+ [name: string]: unknown;
121
+ };
122
+ content: {
123
+ "application/json": components["schemas"]["not-found-response.model"] & {
124
+ /** @example Not found: File not found */
125
+ response: string;
126
+ };
127
+ };
128
+ };
129
+ /** @description Internal server error */
130
+ 500: {
131
+ headers: {
132
+ [name: string]: unknown;
133
+ };
134
+ content: {
135
+ "application/json": components["schemas"]["internal-server-error-response.model"] & {
136
+ /** @example Internal server error: Unknown error */
137
+ response: string;
138
+ };
139
+ };
140
+ };
141
+ };
142
+ };
143
+ put?: never;
144
+ post?: never;
145
+ /** Delete a file */
146
+ delete: {
147
+ parameters: {
148
+ query?: never;
149
+ header?: never;
150
+ path: {
151
+ name: string;
152
+ };
153
+ cookie?: never;
154
+ };
155
+ requestBody?: never;
156
+ responses: {
157
+ /** @description File deleted */
158
+ 200: {
159
+ headers: {
160
+ [name: string]: unknown;
161
+ };
162
+ content?: never;
163
+ };
164
+ /** @description Folder not found */
165
+ 404: {
166
+ headers: {
167
+ [name: string]: unknown;
168
+ };
169
+ content: {
170
+ "application/json": components["schemas"]["not-found-response.model"] & {
171
+ /** @example Not found: File not found */
172
+ response: string;
173
+ };
174
+ };
175
+ };
176
+ /** @description Internal server error */
177
+ 500: {
178
+ headers: {
179
+ [name: string]: unknown;
180
+ };
181
+ content: {
182
+ "application/json": components["schemas"]["internal-server-error-response.model"] & {
183
+ /** @example Internal server error: Unknown error */
184
+ response: string;
185
+ };
186
+ };
187
+ };
188
+ };
189
+ };
190
+ options?: never;
191
+ head?: never;
192
+ patch?: never;
193
+ trace?: never;
194
+ };
45
195
  }
46
196
  export type webhooks = Record<string, never>;
47
197
  export interface components {
@@ -56,6 +206,18 @@ export interface components {
56
206
  /** @example 1707947871721 */
57
207
  timestamp: number;
58
208
  };
209
+ "not-found-response.model": components["schemas"]["response.model"] & {
210
+ /** @example Not found: Authorization header not found */
211
+ response: string;
212
+ /** @example 404 */
213
+ code?: number;
214
+ };
215
+ "internal-server-error-response.model": components["schemas"]["response.model"] & {
216
+ /** @example Internal server error */
217
+ response: string;
218
+ /** @example 500 */
219
+ code?: number;
220
+ };
59
221
  };
60
222
  responses: never;
61
223
  parameters: never;
@@ -15,6 +15,10 @@
15
15
  {
16
16
  "name": "Crosscutting",
17
17
  "description": "Operation related to a crosscutting actions"
18
+ },
19
+ {
20
+ "name": "DiskIO",
21
+ "description": "Operation related to the diskio-core API"
18
22
  }
19
23
  ],
20
24
  "paths": {
@@ -57,6 +61,224 @@
57
61
  }
58
62
  }
59
63
  }
64
+ },
65
+ "/diskio": {
66
+ "post": {
67
+ "tags": [
68
+ "DiskIO"
69
+ ],
70
+ "summary": "Upload a file",
71
+ "requestBody": {
72
+ "required": true,
73
+ "content": {
74
+ "multipart/form-data": {
75
+ "schema": {
76
+ "type": "object",
77
+ "properties": {
78
+ "files": {
79
+ "type": "array",
80
+ "items": {
81
+ "type": "string",
82
+ "format": "binary"
83
+ }
84
+ }
85
+ },
86
+ "required": [
87
+ "files"
88
+ ]
89
+ }
90
+ }
91
+ }
92
+ },
93
+ "responses": {
94
+ "200": {
95
+ "description": "File names",
96
+ "content": {
97
+ "application/json": {
98
+ "schema": {
99
+ "allOf": [
100
+ {
101
+ "$ref": "#/components/schemas/response.model"
102
+ },
103
+ {
104
+ "type": "object",
105
+ "required": [
106
+ "response"
107
+ ],
108
+ "properties": {
109
+ "response": {
110
+ "type": "array",
111
+ "items": {
112
+ "type": "string"
113
+ }
114
+ }
115
+ }
116
+ }
117
+ ]
118
+ }
119
+ }
120
+ }
121
+ }
122
+ }
123
+ }
124
+ },
125
+ "/diskio/{name}": {
126
+ "get": {
127
+ "tags": [
128
+ "DiskIO"
129
+ ],
130
+ "summary": "Download a file",
131
+ "parameters": [
132
+ {
133
+ "name": "name",
134
+ "in": "path",
135
+ "required": true,
136
+ "schema": {
137
+ "type": "string",
138
+ "example": "7b1d2a45/1211/4517/b968/dbb6799aef6b/meme.mp4"
139
+ }
140
+ }
141
+ ],
142
+ "responses": {
143
+ "200": {
144
+ "description": "File",
145
+ "content": {
146
+ "application/octet-stream": {
147
+ "schema": {
148
+ "type": "string",
149
+ "format": "binary"
150
+ }
151
+ }
152
+ }
153
+ },
154
+ "404": {
155
+ "description": "Folder not found",
156
+ "content": {
157
+ "application/json": {
158
+ "schema": {
159
+ "allOf": [
160
+ {
161
+ "$ref": "#/components/schemas/not-found-response.model"
162
+ },
163
+ {
164
+ "type": "object",
165
+ "required": [
166
+ "response"
167
+ ],
168
+ "properties": {
169
+ "response": {
170
+ "type": "string",
171
+ "example": "Not found: File not found"
172
+ }
173
+ }
174
+ }
175
+ ]
176
+ }
177
+ }
178
+ }
179
+ },
180
+ "500": {
181
+ "description": "Internal server error",
182
+ "content": {
183
+ "application/json": {
184
+ "schema": {
185
+ "allOf": [
186
+ {
187
+ "$ref": "#/components/schemas/internal-server-error-response.model"
188
+ },
189
+ {
190
+ "type": "object",
191
+ "required": [
192
+ "response"
193
+ ],
194
+ "properties": {
195
+ "response": {
196
+ "type": "string",
197
+ "example": "Internal server error: Unknown error"
198
+ }
199
+ }
200
+ }
201
+ ]
202
+ }
203
+ }
204
+ }
205
+ }
206
+ }
207
+ },
208
+ "delete": {
209
+ "tags": [
210
+ "DiskIO"
211
+ ],
212
+ "summary": "Delete a file",
213
+ "parameters": [
214
+ {
215
+ "name": "name",
216
+ "in": "path",
217
+ "required": true,
218
+ "schema": {
219
+ "type": "string",
220
+ "example": "7b1d2a45/1211/4517/b968/dbb6799aef6b/meme.mp4"
221
+ }
222
+ }
223
+ ],
224
+ "responses": {
225
+ "200": {
226
+ "description": "File deleted"
227
+ },
228
+ "404": {
229
+ "description": "Folder not found",
230
+ "content": {
231
+ "application/json": {
232
+ "schema": {
233
+ "allOf": [
234
+ {
235
+ "$ref": "#/components/schemas/not-found-response.model"
236
+ },
237
+ {
238
+ "type": "object",
239
+ "required": [
240
+ "response"
241
+ ],
242
+ "properties": {
243
+ "response": {
244
+ "type": "string",
245
+ "example": "Not found: File not found"
246
+ }
247
+ }
248
+ }
249
+ ]
250
+ }
251
+ }
252
+ }
253
+ },
254
+ "500": {
255
+ "description": "Internal server error",
256
+ "content": {
257
+ "application/json": {
258
+ "schema": {
259
+ "allOf": [
260
+ {
261
+ "$ref": "#/components/schemas/internal-server-error-response.model"
262
+ },
263
+ {
264
+ "type": "object",
265
+ "required": [
266
+ "response"
267
+ ],
268
+ "properties": {
269
+ "response": {
270
+ "type": "string",
271
+ "example": "Internal server error: Unknown error"
272
+ }
273
+ }
274
+ }
275
+ ]
276
+ }
277
+ }
278
+ }
279
+ }
280
+ }
281
+ }
60
282
  }
61
283
  },
62
284
  "components": {
@@ -89,6 +311,52 @@
89
311
  "example": "1707947871721"
90
312
  }
91
313
  }
314
+ },
315
+ "not-found-response.model": {
316
+ "allOf": [
317
+ {
318
+ "$ref": "#/components/schemas/response.model"
319
+ },
320
+ {
321
+ "type": "object",
322
+ "required": [
323
+ "response"
324
+ ],
325
+ "properties": {
326
+ "response": {
327
+ "type": "string",
328
+ "example": "Not found: Authorization header not found"
329
+ },
330
+ "code": {
331
+ "type": "number",
332
+ "example": 404
333
+ }
334
+ }
335
+ }
336
+ ]
337
+ },
338
+ "internal-server-error-response.model": {
339
+ "allOf": [
340
+ {
341
+ "$ref": "#/components/schemas/response.model"
342
+ },
343
+ {
344
+ "type": "object",
345
+ "required": [
346
+ "response"
347
+ ],
348
+ "properties": {
349
+ "response": {
350
+ "type": "string",
351
+ "example": "Internal server error"
352
+ },
353
+ "code": {
354
+ "type": "number",
355
+ "example": 500
356
+ }
357
+ }
358
+ }
359
+ ]
92
360
  }
93
361
  }
94
362
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diskio-api",
3
- "version": "1.0.1",
3
+ "version": "1.2.0",
4
4
  "description": "An API Client for diskio-server",
5
5
  "type": "module",
6
6
  "main": "cjs/index.js",