@epilot/file-client 1.5.2 → 1.7.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.
@@ -1 +1 @@
1
- !function(e,t){for(var i in t)e[i]=t[i];t.__esModule&&Object.defineProperty(e,"__esModule",{value:!0})}(exports,(()=>{"use strict";var e={914:function(e,t,i){var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var n=a(i(279));t.default=n.default},279:e=>{e.exports=JSON.parse('{"openapi":"3.0.3","info":{"title":"File API","version":"0.1.0","description":"Upload and manage all files stored in epilot"},"tags":[{"name":"files","description":"Files"}],"security":[{"EpilotAuth":[]}],"paths":{"/v1/files/public/upload":{"post":{"operationId":"uploadFilePublic","summary":"uploadFilePublic","security":[],"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","tags":["files"],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UploadFilePayload"}}}},"responses":{"201":{"description":"Pre-signed URL for POST / PUT upload","content":{"application/json":{"schema":{"type":"object","properties":{"s3ref":{"allOf":[{"$ref":"#/components/schemas/S3Reference"},{"example":{"bucket":"epilot-files-prod","key":"123/temp/4d689aeb-1497-4410-a9fe-b36ca9ac4389/document.pdf"}}]},"upload_url":{"type":"string","format":"url","example":"https://epilot-files-prod.s3.eu-central-1.amazonaws.com/123/temp/4d689aeb-1497-4410-a9fe-b36ca9ac4389/document.pdf?AWSParams=123"}}}}}}}}},"/v1/files/upload":{"post":{"operationId":"uploadFile","summary":"uploadFile","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","tags":["files"],"parameters":[{"name":"file_entity_id","in":"query","description":"file entity id","schema":{"$ref":"#/components/schemas/FileEntityId"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UploadFilePayload","type":"object"}}}},"responses":{"201":{"description":"Pre-signed URL for POST / PUT upload","content":{"application/json":{"schema":{"type":"object","properties":{"s3ref":{"allOf":[{"$ref":"#/components/schemas/S3Reference"},{"example":{"bucket":"epilot-files-prod","key":"123/temp/4d689aeb-1497-4410-a9fe-b36ca9ac4389/document.pdf"}}]},"upload_url":{"type":"string","format":"url","example":"https://epilot-files-prod.s3.eu-central-1.amazonaws.com/123/temp/4d689aeb-1497-4410-a9fe-b36ca9ac4389/document.pdf?AWSParams=123"},"public_url":{"description":"Returned only if file is permanent i.e. file_entity_id is passed","type":"string","format":"url","example":"https://epilot-files-prod.s3.eu-central-1.amazonaws.com/123/4d689aeb-1497-4410-a9fe-b36ca9ac4389/document.pdf"}}}}}}}}},"/v1/files":{"post":{"operationId":"saveFile","summary":"saveFile","description":"Create / Update a permanent File entity\\n\\nMakes file object permanent\\n\\nSaves metadata to file entity\\n","tags":["files"],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SaveFilePayload"}}}},"responses":{"201":{"description":"Created File Entity","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FileEntity"}}}}}}},"/v1/files/{id}/download":{"get":{"operationId":"downloadFile","summary":"downloadFile","description":"Generate pre-signed download S3 url for a file","tags":["files"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"$ref":"#/components/schemas/FileEntityId"}},{"name":"version","in":"query","description":"index of file version","schema":{"type":"integer","default":0}},{"name":"attachment","in":"query","description":"Controls the Content-Disposition header to control browser behaviour. Set to true to trigger download.","schema":{"type":"boolean","default":true}}],"responses":{"200":{"description":"Generated thumbnail image","content":{"application/json":{"schema":{"type":"object","properties":{"download_url":{"type":"string","format":"uri","example":"https://epilot-files-prod.s3.eu-central-1.amazonaws.com/123/temp/4d689aeb-1497-4410-a9fe-b36ca9ac4389/document.pdf?AWSParams=123"}}}}}}}}},"/v1/files:downloadS3":{"post":{"operationId":"downloadS3File","summary":"downloadS3File","description":"Generate pre-signed download S3 url for a file","tags":["files"],"parameters":[{"name":"s3_key","in":"query","required":true,"schema":{"type":"string"}},{"name":"s3_bucket","in":"query","required":true,"schema":{"type":"string"}},{"name":"attachment","in":"query","description":"Controls the Content-Disposition header to control browser behaviour. Set to true to trigger download.","schema":{"type":"boolean","default":true}}],"responses":{"200":{"description":"Generated thumbnail image","content":{"application/json":{"schema":{"type":"object","properties":{"download_url":{"type":"string","format":"uri","example":"https://epilot-files-prod.s3.eu-central-1.amazonaws.com/123/temp/4d689aeb-1497-4410-a9fe-b36ca9ac4389/document.pdf?AWSParams=123"}}}}}}}}},"/v1/files/{id}/preview":{"get":{"operationId":"previewFile","summary":"previewFile","description":"Generate thumbnail preview for a file entity","tags":["files"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"$ref":"#/components/schemas/FileEntityId"}},{"name":"version","in":"query","description":"index of file version","schema":{"type":"integer","default":0}},{"name":"w","in":"query","description":"width","schema":{"type":"integer"}},{"name":"h","in":"query","description":"height","schema":{"type":"integer"}}],"responses":{"200":{"description":"Generated thumbnail image","content":{"image/png":{},"image/jpeg":{}}}}}},"/v1/files:previewS3":{"post":{"operationId":"previewS3File","summary":"previewS3File","description":"Generate thumbnail preview from an s3 reference for a file entity","tags":["files"],"parameters":[{"name":"w","in":"query","description":"width","schema":{"type":"integer"}},{"name":"h","in":"query","description":"height","schema":{"type":"integer"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/S3Reference"}}}},"responses":{"200":{"description":"Generated thumbnail image","content":{"image/png":{},"image/jpeg":{}}}}}},"/v1/files/delete":{"delete":{"operationId":"deleteFile","summary":"deleteFile","description":"Delete file entity","tags":["files"],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeleteFilePayload"}}}},"responses":{"200":{"description":"File delete response"}}}}},"components":{"securitySchemes":{"EpilotAuth":{"type":"http","scheme":"bearer","description":"Authorization header with epilot OAuth2 bearer token","bearerFormat":"JWT"}},"schemas":{"FileEntityId":{"type":"string","example":"ef7d985c-2385-44f4-9c71-ae06a52264f8"},"FileEntity":{"type":"object","properties":{"_id":{"$ref":"#/components/schemas/FileEntityId"},"filename":{"type":"string","example":"document.pdf"},"access_control":{"type":"string","default":"private","enum":["private","public-read"]},"public_url":{"description":"Direct URL for file (public only if file access control is public-read)","type":"string","format":"url","example":"https://epilot-files-prod.s3.eu-central-1.amazonaws.com/123/4d689aeb-1497-4410-a9fe-b36ca9ac4389/document.pdf"},"type":{"description":"Human readable type for file","type":"string","enum":["document","document_template","text","image","video","audio","spreadsheet","presentation","font","archive","application","unknown"]},"mime_type":{"type":"string","description":"MIME type of the file","example":"application/pdf"},"size_bytes":{"type":"integer","minimum":0,"description":"File size in bytes"},"versions":{"type":"array","items":{"type":"object","properties":{"s3ref":{"$ref":"#/components/schemas/S3Reference"}}}}}},"UploadFilePayload":{"type":"object","properties":{"filename":{"type":"string","example":"document.pdf"},"mime_type":{"description":"MIME type of file","type":"string","example":"application/pdf","default":"application/octet-stream"}},"required":["filename"]},"SaveFilePayload":{"type":"object","properties":{"s3ref":{"$ref":"#/components/schemas/S3Reference"},"file_entity_id":{"type":"string","description":"if passed, adds a new version to existing file entity"},"document_type":{"type":"string","enum":["document","document_template","text","image","video","audio","spreadsheet","presentation","font","archive","application","unknown"]},"filename":{"type":"string","example":"document.pdf"},"_tags":{"type":"array","items":{"type":"string"}},"access_control":{"type":"string","default":"private","enum":["private","public-read"]}},"additionalProperties":true,"required":["s3ref"]},"DeleteFilePayload":{"type":"object","properties":{"s3ref":{"$ref":"#/components/schemas/S3Reference"}},"required":["s3ref"]},"S3Reference":{"type":"object","properties":{"bucket":{"type":"string","example":"epilot-files-prod"},"key":{"type":"string","example":"123/4d689aeb-1497-4410-a9fe-b36ca9ac4389/document.pdf"}},"required":["bucket","key"]},"FileItem":{"allOf":[{"$ref":"#/components/schemas/S3Reference"},{"type":"object","properties":{"filename":{"type":"string","example":"document.pdf"},"size_bytes":{"type":"integer","example":1234},"mime_type":{"type":"string","example":"image/jpeg"}}}]}}},"servers":[{"url":"https://file.sls.epilot.io"}]}')}},t={};return function i(a){if(t[a])return t[a].exports;var n=t[a]={exports:{}};return e[a].call(n.exports,n,n.exports,i),n.exports}(914)})());
1
+ !function(e,i){for(var t in i)e[t]=i[t];i.__esModule&&Object.defineProperty(e,"__esModule",{value:!0})}(exports,(()=>{"use strict";var e={914:function(e,i,t){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(i,"__esModule",{value:!0});var r=n(t(946));i.default=r.default},946:e=>{e.exports=JSON.parse('{"openapi":"3.0.3","info":{"title":"","version":""},"paths":{"/v1/files/public/upload":{"post":{"operationId":"uploadFilePublic","requestBody":{"content":{"application/json":{}}}}},"/v1/files/upload":{"post":{"operationId":"uploadFile","parameters":[{"name":"file_entity_id","in":"query"}],"requestBody":{"content":{"application/json":{}}}}},"/v1/files":{"post":{"operationId":"saveFile","requestBody":{"content":{"application/json":{}}}}},"/v1/files/{id}/download":{"get":{"operationId":"downloadFile","parameters":[{"name":"id","in":"path","required":true},{"name":"version","in":"query"},{"name":"attachment","in":"query"}]}},"/v1/files/download":{"post":{"operationId":"downloadFiles","requestBody":{"content":{"application/json":{}}}}},"/v1/files:downloadS3":{"post":{"operationId":"downloadS3File","parameters":[{"name":"s3_key","in":"query","required":true},{"name":"s3_bucket","in":"query","required":true},{"name":"attachment","in":"query"}]}},"/v1/files/{id}/preview":{"get":{"operationId":"previewFile","parameters":[{"name":"id","in":"path","required":true},{"name":"version","in":"query"},{"name":"w","in":"query"},{"name":"h","in":"query"}]}},"/v1/files/public/{id}/preview":{"get":{"operationId":"previewPublicFile","parameters":[{"name":"id","in":"path","required":true},{"name":"version","in":"query"},{"name":"w","in":"query"},{"name":"h","in":"query"},{"name":"org_id","in":"query"}]}},"/v1/files:previewS3":{"post":{"operationId":"previewS3File","parameters":[{"name":"w","in":"query"},{"name":"h","in":"query"}],"requestBody":{"content":{"application/json":{}}}}},"/v1/files/delete":{"delete":{"operationId":"deleteFile","requestBody":{"content":{"application/json":{}}}}}},"components":{},"servers":[{"url":"https://file.sls.epilot.io"}]}')}},i={};return function t(n){if(i[n])return i[n].exports;var r=i[n]={exports:{}};return e[n].call(r.exports,r,r.exports,t),r.exports}(914)})());
@@ -0,0 +1,184 @@
1
+ {
2
+ "openapi": "3.0.3",
3
+ "info": {
4
+ "title": "",
5
+ "version": ""
6
+ },
7
+ "paths": {
8
+ "/v1/files/public/upload": {
9
+ "post": {
10
+ "operationId": "uploadFilePublic",
11
+ "requestBody": {
12
+ "content": {
13
+ "application/json": {}
14
+ }
15
+ }
16
+ }
17
+ },
18
+ "/v1/files/upload": {
19
+ "post": {
20
+ "operationId": "uploadFile",
21
+ "parameters": [
22
+ {
23
+ "name": "file_entity_id",
24
+ "in": "query"
25
+ }
26
+ ],
27
+ "requestBody": {
28
+ "content": {
29
+ "application/json": {}
30
+ }
31
+ }
32
+ }
33
+ },
34
+ "/v1/files": {
35
+ "post": {
36
+ "operationId": "saveFile",
37
+ "requestBody": {
38
+ "content": {
39
+ "application/json": {}
40
+ }
41
+ }
42
+ }
43
+ },
44
+ "/v1/files/{id}/download": {
45
+ "get": {
46
+ "operationId": "downloadFile",
47
+ "parameters": [
48
+ {
49
+ "name": "id",
50
+ "in": "path",
51
+ "required": true
52
+ },
53
+ {
54
+ "name": "version",
55
+ "in": "query"
56
+ },
57
+ {
58
+ "name": "attachment",
59
+ "in": "query"
60
+ }
61
+ ]
62
+ }
63
+ },
64
+ "/v1/files/download": {
65
+ "post": {
66
+ "operationId": "downloadFiles",
67
+ "requestBody": {
68
+ "content": {
69
+ "application/json": {}
70
+ }
71
+ }
72
+ }
73
+ },
74
+ "/v1/files:downloadS3": {
75
+ "post": {
76
+ "operationId": "downloadS3File",
77
+ "parameters": [
78
+ {
79
+ "name": "s3_key",
80
+ "in": "query",
81
+ "required": true
82
+ },
83
+ {
84
+ "name": "s3_bucket",
85
+ "in": "query",
86
+ "required": true
87
+ },
88
+ {
89
+ "name": "attachment",
90
+ "in": "query"
91
+ }
92
+ ]
93
+ }
94
+ },
95
+ "/v1/files/{id}/preview": {
96
+ "get": {
97
+ "operationId": "previewFile",
98
+ "parameters": [
99
+ {
100
+ "name": "id",
101
+ "in": "path",
102
+ "required": true
103
+ },
104
+ {
105
+ "name": "version",
106
+ "in": "query"
107
+ },
108
+ {
109
+ "name": "w",
110
+ "in": "query"
111
+ },
112
+ {
113
+ "name": "h",
114
+ "in": "query"
115
+ }
116
+ ]
117
+ }
118
+ },
119
+ "/v1/files/public/{id}/preview": {
120
+ "get": {
121
+ "operationId": "previewPublicFile",
122
+ "parameters": [
123
+ {
124
+ "name": "id",
125
+ "in": "path",
126
+ "required": true
127
+ },
128
+ {
129
+ "name": "version",
130
+ "in": "query"
131
+ },
132
+ {
133
+ "name": "w",
134
+ "in": "query"
135
+ },
136
+ {
137
+ "name": "h",
138
+ "in": "query"
139
+ },
140
+ {
141
+ "name": "org_id",
142
+ "in": "query"
143
+ }
144
+ ]
145
+ }
146
+ },
147
+ "/v1/files:previewS3": {
148
+ "post": {
149
+ "operationId": "previewS3File",
150
+ "parameters": [
151
+ {
152
+ "name": "w",
153
+ "in": "query"
154
+ },
155
+ {
156
+ "name": "h",
157
+ "in": "query"
158
+ }
159
+ ],
160
+ "requestBody": {
161
+ "content": {
162
+ "application/json": {}
163
+ }
164
+ }
165
+ }
166
+ },
167
+ "/v1/files/delete": {
168
+ "delete": {
169
+ "operationId": "deleteFile",
170
+ "requestBody": {
171
+ "content": {
172
+ "application/json": {}
173
+ }
174
+ }
175
+ }
176
+ }
177
+ },
178
+ "components": {},
179
+ "servers": [
180
+ {
181
+ "url": "https://file.sls.epilot.io"
182
+ }
183
+ ]
184
+ }
package/dist/openapi.d.ts CHANGED
@@ -12,6 +12,19 @@ declare namespace Components {
12
12
  export interface DeleteFilePayload {
13
13
  s3ref: S3Reference;
14
14
  }
15
+ export type DownloadFilesPayload = {
16
+ id: /**
17
+ * example:
18
+ * ef7d985c-2385-44f4-9c71-ae06a52264f8
19
+ */
20
+ FileEntityId;
21
+ /**
22
+ * File version
23
+ * example:
24
+ * 0
25
+ */
26
+ version?: number;
27
+ }[];
15
28
  export interface FileEntity {
16
29
  _id?: /**
17
30
  * example:
@@ -158,6 +171,19 @@ declare namespace Paths {
158
171
  }
159
172
  }
160
173
  }
174
+ namespace DownloadFiles {
175
+ export type RequestBody = Components.Schemas.DownloadFilesPayload;
176
+ namespace Responses {
177
+ export type $200 = {
178
+ /**
179
+ * example:
180
+ * https://epilot-files-prod.s3.eu-central-1.amazonaws.com/123/temp/4d689aeb-1497-4410-a9fe-b36ca9ac4389/document.pdf?AWSParams=123
181
+ */
182
+ download_url?: string; // uri
183
+ file_entity_id?: string; // uuid
184
+ }[];
185
+ }
186
+ }
161
187
  namespace DownloadS3File {
162
188
  namespace Parameters {
163
189
  export type Attachment = boolean;
@@ -199,6 +225,28 @@ declare namespace Paths {
199
225
  h?: Parameters.H;
200
226
  }
201
227
  }
228
+ namespace PreviewPublicFile {
229
+ namespace Parameters {
230
+ export type H = number;
231
+ export type Id = /**
232
+ * example:
233
+ * ef7d985c-2385-44f4-9c71-ae06a52264f8
234
+ */
235
+ Components.Schemas.FileEntityId;
236
+ export type OrgId = string;
237
+ export type Version = number;
238
+ export type W = number;
239
+ }
240
+ export interface PathParameters {
241
+ id: Parameters.Id;
242
+ }
243
+ export interface QueryParameters {
244
+ version?: Parameters.Version;
245
+ w?: Parameters.W;
246
+ h?: Parameters.H;
247
+ org_id?: Parameters.OrgId;
248
+ }
249
+ }
202
250
  namespace PreviewS3File {
203
251
  namespace Parameters {
204
252
  export type H = number;
@@ -348,6 +396,16 @@ export interface OperationMethods {
348
396
  data?: any,
349
397
  config?: AxiosRequestConfig
350
398
  ): OperationResponse<Paths.DownloadFile.Responses.$200>
399
+ /**
400
+ * downloadFiles - downloadFiles
401
+ *
402
+ * Generate pre-signed download S3 urls for multiple files
403
+ */
404
+ 'downloadFiles'(
405
+ parameters?: Parameters<UnknownParamsObject> | null,
406
+ data?: Paths.DownloadFiles.RequestBody,
407
+ config?: AxiosRequestConfig
408
+ ): OperationResponse<Paths.DownloadFiles.Responses.$200>
351
409
  /**
352
410
  * downloadS3File - downloadS3File
353
411
  *
@@ -368,6 +426,16 @@ export interface OperationMethods {
368
426
  data?: any,
369
427
  config?: AxiosRequestConfig
370
428
  ): OperationResponse<any>
429
+ /**
430
+ * previewPublicFile - previewPublicFile
431
+ *
432
+ * Generate thumbnail preview for a public file entity
433
+ */
434
+ 'previewPublicFile'(
435
+ parameters?: Parameters<Paths.PreviewPublicFile.PathParameters & Paths.PreviewPublicFile.QueryParameters> | null,
436
+ data?: any,
437
+ config?: AxiosRequestConfig
438
+ ): OperationResponse<any>
371
439
  /**
372
440
  * previewS3File - previewS3File
373
441
  *
@@ -450,6 +518,18 @@ export interface PathsDictionary {
450
518
  config?: AxiosRequestConfig
451
519
  ): OperationResponse<Paths.DownloadFile.Responses.$200>
452
520
  }
521
+ ['/v1/files/download']: {
522
+ /**
523
+ * downloadFiles - downloadFiles
524
+ *
525
+ * Generate pre-signed download S3 urls for multiple files
526
+ */
527
+ 'post'(
528
+ parameters?: Parameters<UnknownParamsObject> | null,
529
+ data?: Paths.DownloadFiles.RequestBody,
530
+ config?: AxiosRequestConfig
531
+ ): OperationResponse<Paths.DownloadFiles.Responses.$200>
532
+ }
453
533
  ['/v1/files:downloadS3']: {
454
534
  /**
455
535
  * downloadS3File - downloadS3File
@@ -474,6 +554,18 @@ export interface PathsDictionary {
474
554
  config?: AxiosRequestConfig
475
555
  ): OperationResponse<any>
476
556
  }
557
+ ['/v1/files/public/{id}/preview']: {
558
+ /**
559
+ * previewPublicFile - previewPublicFile
560
+ *
561
+ * Generate thumbnail preview for a public file entity
562
+ */
563
+ 'get'(
564
+ parameters?: Parameters<Paths.PreviewPublicFile.PathParameters & Paths.PreviewPublicFile.QueryParameters> | null,
565
+ data?: any,
566
+ config?: AxiosRequestConfig
567
+ ): OperationResponse<any>
568
+ }
477
569
  ['/v1/files:previewS3']: {
478
570
  /**
479
571
  * previewS3File - previewS3File