@epilot/file-client 1.1.8 → 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.
- package/README.md +19 -28
- package/dist/client.d.ts +2 -1
- package/dist/definition.js +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +8 -1
- package/dist/openapi.d.ts +256 -240
- package/dist/openapi.json +562 -0
- package/package.json +29 -19
- package/src/openapi.d.ts +0 -443
package/README.md
CHANGED
|
@@ -1,43 +1,34 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @epilot/file-client
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://github.com/epilot-dev/sdk-js/actions?query=workflow%3ACI)
|
|
4
|
+
[](https://www.npmjs.com/package/@epilot/file-client)
|
|
5
|
+
[](https://bundlephobia.com/package/@epilot/file-client)
|
|
6
|
+
[](https://github.com/epilot-dev/sdk-js/blob/main/LICENSE)
|
|
4
7
|
|
|
5
|
-
|
|
8
|
+
Client library for epilot [File API](https://docs.epilot.io/api/file)
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+
Uses [`openapi-client-axios`](https://github.com/anttiviljami/openapi-client-axios)
|
|
8
11
|
|
|
9
|
-
|
|
12
|
+
## Installation
|
|
10
13
|
|
|
11
14
|
```bash
|
|
12
|
-
npm install --save
|
|
15
|
+
npm install --save @epilot/file-client
|
|
13
16
|
```
|
|
14
17
|
|
|
15
|
-
|
|
18
|
+
## Usage
|
|
16
19
|
|
|
17
20
|
```typescript
|
|
18
|
-
import
|
|
19
|
-
```
|
|
21
|
+
import fileClient from '@epilot/file-client';
|
|
20
22
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
// get typed client
|
|
24
|
-
const client = await getClient();
|
|
23
|
+
// get upload params
|
|
24
|
+
const uploadParams = await client.uploadFile(null, { filename: 'my-document.pdf', mime_type: 'application/pdf' });
|
|
25
25
|
|
|
26
|
-
//
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
## BaseURL & Authorization
|
|
31
|
-
|
|
32
|
-
To pass an authorization header and set up the API url, you can use axios
|
|
33
|
-
defaults:
|
|
34
|
-
|
|
35
|
-
```typescript
|
|
36
|
-
const client = getClient();
|
|
37
|
-
client.defaults.baseURL = config.API_URL;
|
|
38
|
-
client.defaults.headers['authorization'] = `Bearer ${token}`;
|
|
26
|
+
// upload file as multipart/form-data
|
|
27
|
+
const form = new FormData();
|
|
28
|
+
formData.append('file', fileToUpload);
|
|
29
|
+
const uploadRes = await fileClient.put(uploadParams.data.upload_url, form, { headers: form.getHeaders() });
|
|
39
30
|
```
|
|
40
31
|
|
|
41
|
-
##
|
|
32
|
+
## Documentation
|
|
42
33
|
|
|
43
|
-
https://docs.
|
|
34
|
+
https://docs.epilot.io/docs/files/file-api
|
package/dist/client.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { Client } from './openapi';
|
|
2
|
+
export declare const getClient: () => Client;
|
package/dist/definition.js
CHANGED
|
@@ -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
|
|
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":"File Upload and Management for epilot SaaS"},"tags":[{"name":"files","description":"Files"}],"security":[{"EpilotAuth":[]},{"AsOrganization":[]}],"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/{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":"Epilot Bearer Token"},"AsOrganization":{"type":"apiKey","in":"header","name":"x-ivy-org-id","description":"Set organization id when using internal auth"}},"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"]}},"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"}}}]}}}}')}},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)})());
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
declare const client: import("./openapi").Client;
|
|
2
|
+
export default client;
|
|
2
3
|
export type { Client, Components, Paths, PathsDictionary, OperationMethods } from './openapi';
|
|
3
4
|
export type { OpenAPIClient, OpenAPIClientAxios, Document } from 'openapi-client-axios';
|
|
5
|
+
export * from './client';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -10,5 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
15
|
};
|
|
12
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
var client_1 = require("./client");
|
|
18
|
+
var client = (0, client_1.getClient)();
|
|
19
|
+
exports.default = client;
|
|
13
20
|
__exportStar(require("./client"), exports);
|
|
14
21
|
//# sourceMappingURL=index.js.map
|