@epilot/file-client 1.3.0 → 1.3.3

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.
@@ -0,0 +1,618 @@
1
+ {
2
+ "openapi": "3.0.3",
3
+ "info": {
4
+ "title": "File API",
5
+ "version": "0.1.0",
6
+ "description": "Upload and manage all files stored in epilot"
7
+ },
8
+ "tags": [
9
+ {
10
+ "name": "files",
11
+ "description": "Files"
12
+ }
13
+ ],
14
+ "security": [
15
+ {
16
+ "EpilotAuth": []
17
+ }
18
+ ],
19
+ "paths": {
20
+ "/v1/files/public/upload": {
21
+ "post": {
22
+ "operationId": "uploadFilePublic",
23
+ "summary": "uploadFilePublic",
24
+ "security": [],
25
+ "description": "Create pre-signed S3 URL to upload a file to keep temporarily (one week).\n\nUse the createFile operation to store file file permanently.\n",
26
+ "tags": [
27
+ "files"
28
+ ],
29
+ "requestBody": {
30
+ "content": {
31
+ "application/json": {
32
+ "schema": {
33
+ "$ref": "#/components/schemas/UploadFilePayload"
34
+ }
35
+ }
36
+ }
37
+ },
38
+ "responses": {
39
+ "201": {
40
+ "description": "Pre-signed URL for POST / PUT upload",
41
+ "content": {
42
+ "application/json": {
43
+ "schema": {
44
+ "type": "object",
45
+ "properties": {
46
+ "s3ref": {
47
+ "allOf": [
48
+ {
49
+ "$ref": "#/components/schemas/S3Reference"
50
+ },
51
+ {
52
+ "example": {
53
+ "bucket": "epilot-files-prod",
54
+ "key": "123/temp/4d689aeb-1497-4410-a9fe-b36ca9ac4389/document.pdf"
55
+ }
56
+ }
57
+ ]
58
+ },
59
+ "upload_url": {
60
+ "type": "string",
61
+ "format": "url",
62
+ "example": "https://epilot-files-prod.s3.eu-central-1.amazonaws.com/123/temp/4d689aeb-1497-4410-a9fe-b36ca9ac4389/document.pdf?AWSParams=123"
63
+ }
64
+ }
65
+ }
66
+ }
67
+ }
68
+ }
69
+ }
70
+ }
71
+ },
72
+ "/v1/files/upload": {
73
+ "post": {
74
+ "operationId": "uploadFile",
75
+ "summary": "uploadFile",
76
+ "description": "Create pre-signed S3 URL to upload a file to keep temporarily (one week).\n\nUse the createFile operation to store file file permanently.\n",
77
+ "tags": [
78
+ "files"
79
+ ],
80
+ "parameters": [
81
+ {
82
+ "name": "file_entity_id",
83
+ "in": "query",
84
+ "description": "file entity id",
85
+ "schema": {
86
+ "$ref": "#/components/schemas/FileEntityId"
87
+ }
88
+ }
89
+ ],
90
+ "requestBody": {
91
+ "content": {
92
+ "application/json": {
93
+ "schema": {
94
+ "$ref": "#/components/schemas/UploadFilePayload",
95
+ "type": "object"
96
+ }
97
+ }
98
+ }
99
+ },
100
+ "responses": {
101
+ "201": {
102
+ "description": "Pre-signed URL for POST / PUT upload",
103
+ "content": {
104
+ "application/json": {
105
+ "schema": {
106
+ "type": "object",
107
+ "properties": {
108
+ "s3ref": {
109
+ "allOf": [
110
+ {
111
+ "$ref": "#/components/schemas/S3Reference"
112
+ },
113
+ {
114
+ "example": {
115
+ "bucket": "epilot-files-prod",
116
+ "key": "123/temp/4d689aeb-1497-4410-a9fe-b36ca9ac4389/document.pdf"
117
+ }
118
+ }
119
+ ]
120
+ },
121
+ "upload_url": {
122
+ "type": "string",
123
+ "format": "url",
124
+ "example": "https://epilot-files-prod.s3.eu-central-1.amazonaws.com/123/temp/4d689aeb-1497-4410-a9fe-b36ca9ac4389/document.pdf?AWSParams=123"
125
+ },
126
+ "public_url": {
127
+ "description": "Returned only if file is permanent i.e. file_entity_id is passed",
128
+ "type": "string",
129
+ "format": "url",
130
+ "example": "https://epilot-files-prod.s3.eu-central-1.amazonaws.com/123/4d689aeb-1497-4410-a9fe-b36ca9ac4389/document.pdf"
131
+ }
132
+ }
133
+ }
134
+ }
135
+ }
136
+ }
137
+ }
138
+ }
139
+ },
140
+ "/v1/files": {
141
+ "post": {
142
+ "operationId": "saveFile",
143
+ "summary": "saveFile",
144
+ "description": "Create / Update a permanent File entity\n\nMakes file object permanent\n\nSaves metadata to file entity\n",
145
+ "tags": [
146
+ "files"
147
+ ],
148
+ "requestBody": {
149
+ "content": {
150
+ "application/json": {
151
+ "schema": {
152
+ "$ref": "#/components/schemas/SaveFilePayload"
153
+ }
154
+ }
155
+ }
156
+ },
157
+ "responses": {
158
+ "201": {
159
+ "description": "Created File Entity",
160
+ "content": {
161
+ "application/json": {
162
+ "schema": {
163
+ "$ref": "#/components/schemas/FileEntity"
164
+ }
165
+ }
166
+ }
167
+ }
168
+ }
169
+ }
170
+ },
171
+ "/v1/files/{id}/download": {
172
+ "get": {
173
+ "operationId": "downloadFile",
174
+ "summary": "downloadFile",
175
+ "description": "Generate pre-signed download S3 url for a file",
176
+ "tags": [
177
+ "files"
178
+ ],
179
+ "parameters": [
180
+ {
181
+ "name": "id",
182
+ "in": "path",
183
+ "required": true,
184
+ "schema": {
185
+ "$ref": "#/components/schemas/FileEntityId"
186
+ }
187
+ },
188
+ {
189
+ "name": "version",
190
+ "in": "query",
191
+ "description": "index of file version",
192
+ "schema": {
193
+ "type": "integer",
194
+ "default": 0
195
+ }
196
+ },
197
+ {
198
+ "name": "attachment",
199
+ "in": "query",
200
+ "description": "Controls the Content-Disposition header to control browser behaviour. Set to true to trigger download.",
201
+ "schema": {
202
+ "type": "boolean",
203
+ "default": true
204
+ }
205
+ }
206
+ ],
207
+ "responses": {
208
+ "200": {
209
+ "description": "Generated thumbnail image",
210
+ "content": {
211
+ "application/json": {
212
+ "schema": {
213
+ "type": "object",
214
+ "properties": {
215
+ "download_url": {
216
+ "type": "string",
217
+ "format": "uri",
218
+ "example": "https://epilot-files-prod.s3.eu-central-1.amazonaws.com/123/temp/4d689aeb-1497-4410-a9fe-b36ca9ac4389/document.pdf?AWSParams=123"
219
+ }
220
+ }
221
+ }
222
+ }
223
+ }
224
+ }
225
+ }
226
+ }
227
+ },
228
+ "/v1/files:downloadS3": {
229
+ "post": {
230
+ "operationId": "downloadS3File",
231
+ "summary": "downloadS3File",
232
+ "description": "Generate pre-signed download S3 url for a file",
233
+ "tags": [
234
+ "files"
235
+ ],
236
+ "parameters": [
237
+ {
238
+ "name": "s3_key",
239
+ "in": "query",
240
+ "required": true,
241
+ "schema": {
242
+ "type": "string"
243
+ }
244
+ },
245
+ {
246
+ "name": "s3_bucket",
247
+ "in": "query",
248
+ "required": true,
249
+ "schema": {
250
+ "type": "string"
251
+ }
252
+ },
253
+ {
254
+ "name": "attachment",
255
+ "in": "query",
256
+ "description": "Controls the Content-Disposition header to control browser behaviour. Set to true to trigger download.",
257
+ "schema": {
258
+ "type": "boolean",
259
+ "default": true
260
+ }
261
+ }
262
+ ],
263
+ "responses": {
264
+ "200": {
265
+ "description": "Generated thumbnail image",
266
+ "content": {
267
+ "application/json": {
268
+ "schema": {
269
+ "type": "object",
270
+ "properties": {
271
+ "download_url": {
272
+ "type": "string",
273
+ "format": "uri",
274
+ "example": "https://epilot-files-prod.s3.eu-central-1.amazonaws.com/123/temp/4d689aeb-1497-4410-a9fe-b36ca9ac4389/document.pdf?AWSParams=123"
275
+ }
276
+ }
277
+ }
278
+ }
279
+ }
280
+ }
281
+ }
282
+ }
283
+ },
284
+ "/v1/files/{id}/preview": {
285
+ "get": {
286
+ "operationId": "previewFile",
287
+ "summary": "previewFile",
288
+ "description": "Generate thumbnail preview for a file entity",
289
+ "tags": [
290
+ "files"
291
+ ],
292
+ "parameters": [
293
+ {
294
+ "name": "id",
295
+ "in": "path",
296
+ "required": true,
297
+ "schema": {
298
+ "$ref": "#/components/schemas/FileEntityId"
299
+ }
300
+ },
301
+ {
302
+ "name": "version",
303
+ "in": "query",
304
+ "description": "index of file version",
305
+ "schema": {
306
+ "type": "integer",
307
+ "default": 0
308
+ }
309
+ },
310
+ {
311
+ "name": "w",
312
+ "in": "query",
313
+ "description": "width",
314
+ "schema": {
315
+ "type": "integer"
316
+ }
317
+ },
318
+ {
319
+ "name": "h",
320
+ "in": "query",
321
+ "description": "height",
322
+ "schema": {
323
+ "type": "integer"
324
+ }
325
+ }
326
+ ],
327
+ "responses": {
328
+ "200": {
329
+ "description": "Generated thumbnail image",
330
+ "content": {
331
+ "image/png": {},
332
+ "image/jpeg": {}
333
+ }
334
+ }
335
+ }
336
+ }
337
+ },
338
+ "/v1/files:previewS3": {
339
+ "post": {
340
+ "operationId": "previewS3File",
341
+ "summary": "previewS3File",
342
+ "description": "Generate thumbnail preview from an s3 reference for a file entity",
343
+ "tags": [
344
+ "files"
345
+ ],
346
+ "parameters": [
347
+ {
348
+ "name": "w",
349
+ "in": "query",
350
+ "description": "width",
351
+ "schema": {
352
+ "type": "integer"
353
+ }
354
+ },
355
+ {
356
+ "name": "h",
357
+ "in": "query",
358
+ "description": "height",
359
+ "schema": {
360
+ "type": "integer"
361
+ }
362
+ }
363
+ ],
364
+ "requestBody": {
365
+ "content": {
366
+ "application/json": {
367
+ "schema": {
368
+ "$ref": "#/components/schemas/S3Reference"
369
+ }
370
+ }
371
+ }
372
+ },
373
+ "responses": {
374
+ "200": {
375
+ "description": "Generated thumbnail image",
376
+ "content": {
377
+ "image/png": {},
378
+ "image/jpeg": {}
379
+ }
380
+ }
381
+ }
382
+ }
383
+ },
384
+ "/v1/files/delete": {
385
+ "delete": {
386
+ "operationId": "deleteFile",
387
+ "summary": "deleteFile",
388
+ "description": "Delete file entity",
389
+ "tags": [
390
+ "files"
391
+ ],
392
+ "requestBody": {
393
+ "content": {
394
+ "application/json": {
395
+ "schema": {
396
+ "$ref": "#/components/schemas/DeleteFilePayload"
397
+ }
398
+ }
399
+ }
400
+ },
401
+ "responses": {
402
+ "200": {
403
+ "description": "File delete response"
404
+ }
405
+ }
406
+ }
407
+ }
408
+ },
409
+ "components": {
410
+ "securitySchemes": {
411
+ "EpilotAuth": {
412
+ "type": "http",
413
+ "scheme": "bearer",
414
+ "description": "Authorization header with epilot OAuth2 bearer token",
415
+ "bearerFormat": "JWT"
416
+ }
417
+ },
418
+ "schemas": {
419
+ "FileEntityId": {
420
+ "type": "string",
421
+ "example": "ef7d985c-2385-44f4-9c71-ae06a52264f8"
422
+ },
423
+ "FileEntity": {
424
+ "type": "object",
425
+ "properties": {
426
+ "_id": {
427
+ "$ref": "#/components/schemas/FileEntityId"
428
+ },
429
+ "filename": {
430
+ "type": "string",
431
+ "example": "document.pdf"
432
+ },
433
+ "access_control": {
434
+ "type": "string",
435
+ "default": "private",
436
+ "enum": [
437
+ "private",
438
+ "public-read"
439
+ ]
440
+ },
441
+ "public_url": {
442
+ "description": "Direct URL for file (public only if file access control is public-read)",
443
+ "type": "string",
444
+ "format": "url",
445
+ "example": "https://epilot-files-prod.s3.eu-central-1.amazonaws.com/123/4d689aeb-1497-4410-a9fe-b36ca9ac4389/document.pdf"
446
+ },
447
+ "type": {
448
+ "description": "Human readable type for file",
449
+ "type": "string",
450
+ "enum": [
451
+ "document",
452
+ "document_template",
453
+ "text",
454
+ "image",
455
+ "video",
456
+ "audio",
457
+ "spreadsheet",
458
+ "presentation",
459
+ "font",
460
+ "archive",
461
+ "application",
462
+ "unknown"
463
+ ]
464
+ },
465
+ "mime_type": {
466
+ "type": "string",
467
+ "description": "MIME type of the file",
468
+ "example": "application/pdf"
469
+ },
470
+ "size_bytes": {
471
+ "type": "integer",
472
+ "minimum": 0,
473
+ "description": "File size in bytes"
474
+ },
475
+ "versions": {
476
+ "type": "array",
477
+ "items": {
478
+ "type": "object",
479
+ "properties": {
480
+ "s3ref": {
481
+ "$ref": "#/components/schemas/S3Reference"
482
+ }
483
+ }
484
+ }
485
+ }
486
+ }
487
+ },
488
+ "UploadFilePayload": {
489
+ "type": "object",
490
+ "properties": {
491
+ "filename": {
492
+ "type": "string",
493
+ "example": "document.pdf"
494
+ },
495
+ "mime_type": {
496
+ "description": "MIME type of file",
497
+ "type": "string",
498
+ "example": "application/pdf",
499
+ "default": "application/octet-stream"
500
+ }
501
+ },
502
+ "required": [
503
+ "filename"
504
+ ]
505
+ },
506
+ "SaveFilePayload": {
507
+ "type": "object",
508
+ "properties": {
509
+ "s3ref": {
510
+ "$ref": "#/components/schemas/S3Reference"
511
+ },
512
+ "file_entity_id": {
513
+ "type": "string",
514
+ "description": "if passed, adds a new version to existing file entity"
515
+ },
516
+ "document_type": {
517
+ "type": "string",
518
+ "enum": [
519
+ "document",
520
+ "document_template",
521
+ "text",
522
+ "image",
523
+ "video",
524
+ "audio",
525
+ "spreadsheet",
526
+ "presentation",
527
+ "font",
528
+ "archive",
529
+ "application",
530
+ "unknown"
531
+ ]
532
+ },
533
+ "filename": {
534
+ "type": "string",
535
+ "example": "document.pdf"
536
+ },
537
+ "_tags": {
538
+ "type": "array",
539
+ "items": {
540
+ "type": "string"
541
+ }
542
+ },
543
+ "access_control": {
544
+ "type": "string",
545
+ "default": "private",
546
+ "enum": [
547
+ "private",
548
+ "public-read"
549
+ ]
550
+ }
551
+ },
552
+ "required": [
553
+ "s3ref"
554
+ ]
555
+ },
556
+ "DeleteFilePayload": {
557
+ "type": "object",
558
+ "properties": {
559
+ "s3ref": {
560
+ "$ref": "#/components/schemas/S3Reference"
561
+ }
562
+ },
563
+ "required": [
564
+ "s3ref"
565
+ ]
566
+ },
567
+ "S3Reference": {
568
+ "type": "object",
569
+ "properties": {
570
+ "bucket": {
571
+ "type": "string",
572
+ "example": "epilot-files-prod"
573
+ },
574
+ "key": {
575
+ "type": "string",
576
+ "example": "123/4d689aeb-1497-4410-a9fe-b36ca9ac4389/document.pdf"
577
+ }
578
+ },
579
+ "required": [
580
+ "bucket",
581
+ "key"
582
+ ]
583
+ },
584
+ "FileItem": {
585
+ "allOf": [
586
+ {
587
+ "$ref": "#/components/schemas/S3Reference"
588
+ },
589
+ {
590
+ "type": "object",
591
+ "properties": {
592
+ "filename": {
593
+ "type": "string",
594
+ "example": "document.pdf"
595
+ },
596
+ "size_bytes": {
597
+ "type": "integer",
598
+ "example": 1234
599
+ },
600
+ "mime_type": {
601
+ "type": "string",
602
+ "example": "image/jpeg"
603
+ }
604
+ }
605
+ }
606
+ ]
607
+ }
608
+ }
609
+ },
610
+ "servers": [
611
+ {
612
+ "url": "https://file.sls.epilot.io"
613
+ },
614
+ {
615
+ "url": "https://file.sls.epilot.io"
616
+ }
617
+ ]
618
+ }