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