@epilot/file-client 0.1.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 +43 -0
- package/dist/client.d.ts +1 -0
- package/dist/client.js +14 -0
- package/dist/definition.d.ts +3 -0
- package/dist/definition.js +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +14 -0
- package/dist/openapi.d.ts +257 -0
- package/package.json +57 -0
- package/src/openapi.d.ts +257 -0
package/README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# `@epilot/file-client`
|
|
2
|
+
|
|
3
|
+
API Client for epilot File API.
|
|
4
|
+
|
|
5
|
+
Uses [`openapi-client-axios`](https://github.com/anttiviljami/openapi-client-axios)
|
|
6
|
+
|
|
7
|
+
## Getting Started
|
|
8
|
+
|
|
9
|
+
Install the package:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install --save-dev @epilot/file-client
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Import the package:
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { getClient } from '@epilot/file-api-client';
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Use the client:
|
|
22
|
+
```typescript
|
|
23
|
+
// get typed client
|
|
24
|
+
const client = await getClient();
|
|
25
|
+
|
|
26
|
+
// call an operation
|
|
27
|
+
const res = await client.testS3();
|
|
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}`;
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## API Docs:
|
|
42
|
+
|
|
43
|
+
https://docs.api.epilot.io/file
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getClient: () => import("openapi-client-axios").OpenAPIClient<import("./openapi").OperationMethods, import("./openapi").PathsDictionary>;
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getClient = void 0;
|
|
7
|
+
var openapi_client_axios_1 = __importDefault(require("openapi-client-axios"));
|
|
8
|
+
var definition_1 = __importDefault(require("./definition"));
|
|
9
|
+
var getClient = function () {
|
|
10
|
+
var api = new openapi_client_axios_1.default({ definition: definition_1.default, quick: true });
|
|
11
|
+
return api.initSync();
|
|
12
|
+
};
|
|
13
|
+
exports.getClient = getClient;
|
|
14
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +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 r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var n=r(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":[]}],"paths":{"/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"],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"filename":{"type":"string","example":"document.pdf"}},"required":["filename"]}}}},"responses":{"201":{"description":"Pre-signed URL for POST / PUT upload","content":{"application/json":{"schema":{"type":"object","properties":{"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"},"s3ref":{"allOf":[{"$ref":"#/components/schemas/S3Reference"},{"example":{"bucket":"epilot-files-prod","key":"123/temp/4d689aeb-1497-4410-a9fe-b36ca9ac4389/document.pdf"}}]}}}}}}}}},"/v1/files":{"post":{"operationId":"createFile","summary":"createFile","description":"Create a permanent File entity","tags":["files"],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FileEntityPayload"}}}},"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}}],"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":{}}}}}}},"components":{"securitySchemes":{"EpilotAuth":{"type":"http","scheme":"bearer","description":"Epilot Bearer Token"}},"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"]},"versions":{"type":"array","items":{"type":"object","properties":{"s3ref":{"$ref":"#/components/schemas/S3Reference"}}}}}},"FileEntityPayload":{"type":"object","properties":{"filename":{"type":"string","example":"document.pdf"},"access_control":{"type":"string","default":"private","enum":["private","public"]},"versions":{"type":"array","items":{"$ref":"#/components/schemas/FileItem"}}}},"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}}}]}}}}')}},t={};return function i(r){if(t[r])return t[r].exports;var n=t[r]={exports:{}};return e[r].call(n.exports,n,n.exports,i),n.exports}(914)})());
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./client"), exports);
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import {
|
|
3
|
+
OpenAPIClient,
|
|
4
|
+
Parameters,
|
|
5
|
+
UnknownParamsObject,
|
|
6
|
+
OperationResponse,
|
|
7
|
+
AxiosRequestConfig,
|
|
8
|
+
} from 'openapi-client-axios';
|
|
9
|
+
|
|
10
|
+
declare namespace Components {
|
|
11
|
+
namespace Schemas {
|
|
12
|
+
export interface FileEntity {
|
|
13
|
+
_id?: FileEntityId;
|
|
14
|
+
/**
|
|
15
|
+
* example:
|
|
16
|
+
* document.pdf
|
|
17
|
+
*/
|
|
18
|
+
filename?: string;
|
|
19
|
+
access_control?: "private" | "public";
|
|
20
|
+
versions?: {
|
|
21
|
+
s3ref?: S3Reference;
|
|
22
|
+
}[];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* example:
|
|
26
|
+
* ef7d985c-2385-44f4-9c71-ae06a52264f8
|
|
27
|
+
*/
|
|
28
|
+
export type FileEntityId = string;
|
|
29
|
+
export interface FileEntityPayload {
|
|
30
|
+
/**
|
|
31
|
+
* example:
|
|
32
|
+
* document.pdf
|
|
33
|
+
*/
|
|
34
|
+
filename?: string;
|
|
35
|
+
access_control?: "private" | "public";
|
|
36
|
+
versions?: FileItem[];
|
|
37
|
+
}
|
|
38
|
+
export interface FileItem {
|
|
39
|
+
/**
|
|
40
|
+
* example:
|
|
41
|
+
* epilot-files-prod
|
|
42
|
+
*/
|
|
43
|
+
bucket: string;
|
|
44
|
+
/**
|
|
45
|
+
* example:
|
|
46
|
+
* 123/4d689aeb-1497-4410-a9fe-b36ca9ac4389/document.pdf
|
|
47
|
+
*/
|
|
48
|
+
key: string;
|
|
49
|
+
/**
|
|
50
|
+
* example:
|
|
51
|
+
* document.pdf
|
|
52
|
+
*/
|
|
53
|
+
filename?: string;
|
|
54
|
+
/**
|
|
55
|
+
* example:
|
|
56
|
+
* 1234
|
|
57
|
+
*/
|
|
58
|
+
size_bytes?: number;
|
|
59
|
+
}
|
|
60
|
+
export interface S3Reference {
|
|
61
|
+
/**
|
|
62
|
+
* example:
|
|
63
|
+
* epilot-files-prod
|
|
64
|
+
*/
|
|
65
|
+
bucket: string;
|
|
66
|
+
/**
|
|
67
|
+
* example:
|
|
68
|
+
* 123/4d689aeb-1497-4410-a9fe-b36ca9ac4389/document.pdf
|
|
69
|
+
*/
|
|
70
|
+
key: string;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
declare namespace Paths {
|
|
75
|
+
namespace CreateFile {
|
|
76
|
+
export type RequestBody = Components.Schemas.FileEntityPayload;
|
|
77
|
+
namespace Responses {
|
|
78
|
+
export type $201 = Components.Schemas.FileEntity;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
namespace DownloadFile {
|
|
82
|
+
namespace Parameters {
|
|
83
|
+
export type Id = Components.Schemas.FileEntityId;
|
|
84
|
+
export type Version = number;
|
|
85
|
+
}
|
|
86
|
+
export interface PathParameters {
|
|
87
|
+
id: Parameters.Id;
|
|
88
|
+
}
|
|
89
|
+
export interface QueryParameters {
|
|
90
|
+
version?: Parameters.Version;
|
|
91
|
+
}
|
|
92
|
+
namespace Responses {
|
|
93
|
+
export interface $200 {
|
|
94
|
+
/**
|
|
95
|
+
* example:
|
|
96
|
+
* https://epilot-files-prod.s3.eu-central-1.amazonaws.com/123/temp/4d689aeb-1497-4410-a9fe-b36ca9ac4389/document.pdf?AWSParams=123
|
|
97
|
+
*/
|
|
98
|
+
download_url?: string; // uri
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
namespace PreviewFile {
|
|
103
|
+
namespace Parameters {
|
|
104
|
+
export type H = number;
|
|
105
|
+
export type Id = Components.Schemas.FileEntityId;
|
|
106
|
+
export type Version = number;
|
|
107
|
+
export type W = number;
|
|
108
|
+
}
|
|
109
|
+
export interface PathParameters {
|
|
110
|
+
id: Parameters.Id;
|
|
111
|
+
}
|
|
112
|
+
export interface QueryParameters {
|
|
113
|
+
version?: Parameters.Version;
|
|
114
|
+
w?: Parameters.W;
|
|
115
|
+
h?: Parameters.H;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
namespace UploadFile {
|
|
119
|
+
export interface RequestBody {
|
|
120
|
+
/**
|
|
121
|
+
* example:
|
|
122
|
+
* document.pdf
|
|
123
|
+
*/
|
|
124
|
+
filename: string;
|
|
125
|
+
}
|
|
126
|
+
namespace Responses {
|
|
127
|
+
export interface $201 {
|
|
128
|
+
/**
|
|
129
|
+
* example:
|
|
130
|
+
* https://epilot-files-prod.s3.eu-central-1.amazonaws.com/123/temp/4d689aeb-1497-4410-a9fe-b36ca9ac4389/document.pdf?AWSParams=123
|
|
131
|
+
*/
|
|
132
|
+
upload_url?: string; // url
|
|
133
|
+
/**
|
|
134
|
+
* example:
|
|
135
|
+
* {
|
|
136
|
+
* "bucket": "epilot-files-prod",
|
|
137
|
+
* "key": "123/temp/4d689aeb-1497-4410-a9fe-b36ca9ac4389/document.pdf"
|
|
138
|
+
* }
|
|
139
|
+
*/
|
|
140
|
+
s3ref?: {
|
|
141
|
+
/**
|
|
142
|
+
* example:
|
|
143
|
+
* epilot-files-prod
|
|
144
|
+
*/
|
|
145
|
+
bucket: string;
|
|
146
|
+
/**
|
|
147
|
+
* example:
|
|
148
|
+
* 123/4d689aeb-1497-4410-a9fe-b36ca9ac4389/document.pdf
|
|
149
|
+
*/
|
|
150
|
+
key: string;
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export interface OperationMethods {
|
|
158
|
+
/**
|
|
159
|
+
* uploadFile - uploadFile
|
|
160
|
+
*
|
|
161
|
+
* Create pre-signed S3 URL to upload a file to keep temporarily (one week).
|
|
162
|
+
*
|
|
163
|
+
* Use the createFile operation to store file file permanently.
|
|
164
|
+
*
|
|
165
|
+
*/
|
|
166
|
+
'uploadFile'(
|
|
167
|
+
parameters?: Parameters<UnknownParamsObject> | null,
|
|
168
|
+
data?: Paths.UploadFile.RequestBody,
|
|
169
|
+
config?: AxiosRequestConfig
|
|
170
|
+
): OperationResponse<Paths.UploadFile.Responses.$201>
|
|
171
|
+
/**
|
|
172
|
+
* createFile - createFile
|
|
173
|
+
*
|
|
174
|
+
* Create a permanent File entity
|
|
175
|
+
*/
|
|
176
|
+
'createFile'(
|
|
177
|
+
parameters?: Parameters<UnknownParamsObject> | null,
|
|
178
|
+
data?: Paths.CreateFile.RequestBody,
|
|
179
|
+
config?: AxiosRequestConfig
|
|
180
|
+
): OperationResponse<Paths.CreateFile.Responses.$201>
|
|
181
|
+
/**
|
|
182
|
+
* downloadFile - downloadFile
|
|
183
|
+
*
|
|
184
|
+
* Generate pre-signed download S3 url for a file
|
|
185
|
+
*/
|
|
186
|
+
'downloadFile'(
|
|
187
|
+
parameters?: Parameters<Paths.DownloadFile.PathParameters & Paths.DownloadFile.QueryParameters> | null,
|
|
188
|
+
data?: any,
|
|
189
|
+
config?: AxiosRequestConfig
|
|
190
|
+
): OperationResponse<Paths.DownloadFile.Responses.$200>
|
|
191
|
+
/**
|
|
192
|
+
* previewFile - previewFile
|
|
193
|
+
*
|
|
194
|
+
* Generate thumbnail preview for a file entity
|
|
195
|
+
*/
|
|
196
|
+
'previewFile'(
|
|
197
|
+
parameters?: Parameters<Paths.PreviewFile.PathParameters & Paths.PreviewFile.QueryParameters> | null,
|
|
198
|
+
data?: any,
|
|
199
|
+
config?: AxiosRequestConfig
|
|
200
|
+
): OperationResponse<any>
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export interface PathsDictionary {
|
|
204
|
+
['/v1/files:upload']: {
|
|
205
|
+
/**
|
|
206
|
+
* uploadFile - uploadFile
|
|
207
|
+
*
|
|
208
|
+
* Create pre-signed S3 URL to upload a file to keep temporarily (one week).
|
|
209
|
+
*
|
|
210
|
+
* Use the createFile operation to store file file permanently.
|
|
211
|
+
*
|
|
212
|
+
*/
|
|
213
|
+
'post'(
|
|
214
|
+
parameters?: Parameters<UnknownParamsObject> | null,
|
|
215
|
+
data?: Paths.UploadFile.RequestBody,
|
|
216
|
+
config?: AxiosRequestConfig
|
|
217
|
+
): OperationResponse<Paths.UploadFile.Responses.$201>
|
|
218
|
+
}
|
|
219
|
+
['/v1/files']: {
|
|
220
|
+
/**
|
|
221
|
+
* createFile - createFile
|
|
222
|
+
*
|
|
223
|
+
* Create a permanent File entity
|
|
224
|
+
*/
|
|
225
|
+
'post'(
|
|
226
|
+
parameters?: Parameters<UnknownParamsObject> | null,
|
|
227
|
+
data?: Paths.CreateFile.RequestBody,
|
|
228
|
+
config?: AxiosRequestConfig
|
|
229
|
+
): OperationResponse<Paths.CreateFile.Responses.$201>
|
|
230
|
+
}
|
|
231
|
+
['/v1/files/{id}:download']: {
|
|
232
|
+
/**
|
|
233
|
+
* downloadFile - downloadFile
|
|
234
|
+
*
|
|
235
|
+
* Generate pre-signed download S3 url for a file
|
|
236
|
+
*/
|
|
237
|
+
'get'(
|
|
238
|
+
parameters?: Parameters<Paths.DownloadFile.PathParameters & Paths.DownloadFile.QueryParameters> | null,
|
|
239
|
+
data?: any,
|
|
240
|
+
config?: AxiosRequestConfig
|
|
241
|
+
): OperationResponse<Paths.DownloadFile.Responses.$200>
|
|
242
|
+
}
|
|
243
|
+
['/v1/files/{id}:preview']: {
|
|
244
|
+
/**
|
|
245
|
+
* previewFile - previewFile
|
|
246
|
+
*
|
|
247
|
+
* Generate thumbnail preview for a file entity
|
|
248
|
+
*/
|
|
249
|
+
'get'(
|
|
250
|
+
parameters?: Parameters<Paths.PreviewFile.PathParameters & Paths.PreviewFile.QueryParameters> | null,
|
|
251
|
+
data?: any,
|
|
252
|
+
config?: AxiosRequestConfig
|
|
253
|
+
): OperationResponse<any>
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export type Client = OpenAPIClient<OperationMethods, PathsDictionary>
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@epilot/file-client",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "API client for epilot File API",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "jest",
|
|
9
|
+
"typescript": "tsc",
|
|
10
|
+
"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"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"*.js",
|
|
19
|
+
"*.d.ts",
|
|
20
|
+
"**/*.js",
|
|
21
|
+
"**/*.d.ts",
|
|
22
|
+
"!*.test.*",
|
|
23
|
+
"!**/*.test.*",
|
|
24
|
+
"!node_modules",
|
|
25
|
+
"!src",
|
|
26
|
+
"!*.config.js"
|
|
27
|
+
],
|
|
28
|
+
"keywords": [],
|
|
29
|
+
"author": "epilot GmbH",
|
|
30
|
+
"license": "UNLICENSED",
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"axios": "^0.21.1"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"buffer": "^6.0.3",
|
|
36
|
+
"https-browserify": "^1.0.0",
|
|
37
|
+
"openapi-client-axios": "^3.13.1",
|
|
38
|
+
"stream-http": "^3.1.1",
|
|
39
|
+
"url": "^0.11.0",
|
|
40
|
+
"util": "^0.12.3"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@types/jest": "^26.0.20",
|
|
44
|
+
"axios": "^0.21.1",
|
|
45
|
+
"copy-webpack-plugin": "^7.0.0",
|
|
46
|
+
"jest": "^26.6.3",
|
|
47
|
+
"json-loader": "^0.5.7",
|
|
48
|
+
"openapi-client-axios-typegen": "^3.13.1",
|
|
49
|
+
"openapicmd": "^1.6.2",
|
|
50
|
+
"ts-jest": "^26.5.0",
|
|
51
|
+
"ts-loader": "^8.0.14",
|
|
52
|
+
"ts-node": "^9.1.1",
|
|
53
|
+
"typescript": "^4.1.3",
|
|
54
|
+
"webpack": "^5.18.0",
|
|
55
|
+
"webpack-cli": "^4.4.0"
|
|
56
|
+
}
|
|
57
|
+
}
|
package/src/openapi.d.ts
ADDED
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import {
|
|
3
|
+
OpenAPIClient,
|
|
4
|
+
Parameters,
|
|
5
|
+
UnknownParamsObject,
|
|
6
|
+
OperationResponse,
|
|
7
|
+
AxiosRequestConfig,
|
|
8
|
+
} from 'openapi-client-axios';
|
|
9
|
+
|
|
10
|
+
declare namespace Components {
|
|
11
|
+
namespace Schemas {
|
|
12
|
+
export interface FileEntity {
|
|
13
|
+
_id?: FileEntityId;
|
|
14
|
+
/**
|
|
15
|
+
* example:
|
|
16
|
+
* document.pdf
|
|
17
|
+
*/
|
|
18
|
+
filename?: string;
|
|
19
|
+
access_control?: "private" | "public";
|
|
20
|
+
versions?: {
|
|
21
|
+
s3ref?: S3Reference;
|
|
22
|
+
}[];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* example:
|
|
26
|
+
* ef7d985c-2385-44f4-9c71-ae06a52264f8
|
|
27
|
+
*/
|
|
28
|
+
export type FileEntityId = string;
|
|
29
|
+
export interface FileEntityPayload {
|
|
30
|
+
/**
|
|
31
|
+
* example:
|
|
32
|
+
* document.pdf
|
|
33
|
+
*/
|
|
34
|
+
filename?: string;
|
|
35
|
+
access_control?: "private" | "public";
|
|
36
|
+
versions?: FileItem[];
|
|
37
|
+
}
|
|
38
|
+
export interface FileItem {
|
|
39
|
+
/**
|
|
40
|
+
* example:
|
|
41
|
+
* epilot-files-prod
|
|
42
|
+
*/
|
|
43
|
+
bucket: string;
|
|
44
|
+
/**
|
|
45
|
+
* example:
|
|
46
|
+
* 123/4d689aeb-1497-4410-a9fe-b36ca9ac4389/document.pdf
|
|
47
|
+
*/
|
|
48
|
+
key: string;
|
|
49
|
+
/**
|
|
50
|
+
* example:
|
|
51
|
+
* document.pdf
|
|
52
|
+
*/
|
|
53
|
+
filename?: string;
|
|
54
|
+
/**
|
|
55
|
+
* example:
|
|
56
|
+
* 1234
|
|
57
|
+
*/
|
|
58
|
+
size_bytes?: number;
|
|
59
|
+
}
|
|
60
|
+
export interface S3Reference {
|
|
61
|
+
/**
|
|
62
|
+
* example:
|
|
63
|
+
* epilot-files-prod
|
|
64
|
+
*/
|
|
65
|
+
bucket: string;
|
|
66
|
+
/**
|
|
67
|
+
* example:
|
|
68
|
+
* 123/4d689aeb-1497-4410-a9fe-b36ca9ac4389/document.pdf
|
|
69
|
+
*/
|
|
70
|
+
key: string;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
declare namespace Paths {
|
|
75
|
+
namespace CreateFile {
|
|
76
|
+
export type RequestBody = Components.Schemas.FileEntityPayload;
|
|
77
|
+
namespace Responses {
|
|
78
|
+
export type $201 = Components.Schemas.FileEntity;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
namespace DownloadFile {
|
|
82
|
+
namespace Parameters {
|
|
83
|
+
export type Id = Components.Schemas.FileEntityId;
|
|
84
|
+
export type Version = number;
|
|
85
|
+
}
|
|
86
|
+
export interface PathParameters {
|
|
87
|
+
id: Parameters.Id;
|
|
88
|
+
}
|
|
89
|
+
export interface QueryParameters {
|
|
90
|
+
version?: Parameters.Version;
|
|
91
|
+
}
|
|
92
|
+
namespace Responses {
|
|
93
|
+
export interface $200 {
|
|
94
|
+
/**
|
|
95
|
+
* example:
|
|
96
|
+
* https://epilot-files-prod.s3.eu-central-1.amazonaws.com/123/temp/4d689aeb-1497-4410-a9fe-b36ca9ac4389/document.pdf?AWSParams=123
|
|
97
|
+
*/
|
|
98
|
+
download_url?: string; // uri
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
namespace PreviewFile {
|
|
103
|
+
namespace Parameters {
|
|
104
|
+
export type H = number;
|
|
105
|
+
export type Id = Components.Schemas.FileEntityId;
|
|
106
|
+
export type Version = number;
|
|
107
|
+
export type W = number;
|
|
108
|
+
}
|
|
109
|
+
export interface PathParameters {
|
|
110
|
+
id: Parameters.Id;
|
|
111
|
+
}
|
|
112
|
+
export interface QueryParameters {
|
|
113
|
+
version?: Parameters.Version;
|
|
114
|
+
w?: Parameters.W;
|
|
115
|
+
h?: Parameters.H;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
namespace UploadFile {
|
|
119
|
+
export interface RequestBody {
|
|
120
|
+
/**
|
|
121
|
+
* example:
|
|
122
|
+
* document.pdf
|
|
123
|
+
*/
|
|
124
|
+
filename: string;
|
|
125
|
+
}
|
|
126
|
+
namespace Responses {
|
|
127
|
+
export interface $201 {
|
|
128
|
+
/**
|
|
129
|
+
* example:
|
|
130
|
+
* https://epilot-files-prod.s3.eu-central-1.amazonaws.com/123/temp/4d689aeb-1497-4410-a9fe-b36ca9ac4389/document.pdf?AWSParams=123
|
|
131
|
+
*/
|
|
132
|
+
upload_url?: string; // url
|
|
133
|
+
/**
|
|
134
|
+
* example:
|
|
135
|
+
* {
|
|
136
|
+
* "bucket": "epilot-files-prod",
|
|
137
|
+
* "key": "123/temp/4d689aeb-1497-4410-a9fe-b36ca9ac4389/document.pdf"
|
|
138
|
+
* }
|
|
139
|
+
*/
|
|
140
|
+
s3ref?: {
|
|
141
|
+
/**
|
|
142
|
+
* example:
|
|
143
|
+
* epilot-files-prod
|
|
144
|
+
*/
|
|
145
|
+
bucket: string;
|
|
146
|
+
/**
|
|
147
|
+
* example:
|
|
148
|
+
* 123/4d689aeb-1497-4410-a9fe-b36ca9ac4389/document.pdf
|
|
149
|
+
*/
|
|
150
|
+
key: string;
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export interface OperationMethods {
|
|
158
|
+
/**
|
|
159
|
+
* uploadFile - uploadFile
|
|
160
|
+
*
|
|
161
|
+
* Create pre-signed S3 URL to upload a file to keep temporarily (one week).
|
|
162
|
+
*
|
|
163
|
+
* Use the createFile operation to store file file permanently.
|
|
164
|
+
*
|
|
165
|
+
*/
|
|
166
|
+
'uploadFile'(
|
|
167
|
+
parameters?: Parameters<UnknownParamsObject> | null,
|
|
168
|
+
data?: Paths.UploadFile.RequestBody,
|
|
169
|
+
config?: AxiosRequestConfig
|
|
170
|
+
): OperationResponse<Paths.UploadFile.Responses.$201>
|
|
171
|
+
/**
|
|
172
|
+
* createFile - createFile
|
|
173
|
+
*
|
|
174
|
+
* Create a permanent File entity
|
|
175
|
+
*/
|
|
176
|
+
'createFile'(
|
|
177
|
+
parameters?: Parameters<UnknownParamsObject> | null,
|
|
178
|
+
data?: Paths.CreateFile.RequestBody,
|
|
179
|
+
config?: AxiosRequestConfig
|
|
180
|
+
): OperationResponse<Paths.CreateFile.Responses.$201>
|
|
181
|
+
/**
|
|
182
|
+
* downloadFile - downloadFile
|
|
183
|
+
*
|
|
184
|
+
* Generate pre-signed download S3 url for a file
|
|
185
|
+
*/
|
|
186
|
+
'downloadFile'(
|
|
187
|
+
parameters?: Parameters<Paths.DownloadFile.PathParameters & Paths.DownloadFile.QueryParameters> | null,
|
|
188
|
+
data?: any,
|
|
189
|
+
config?: AxiosRequestConfig
|
|
190
|
+
): OperationResponse<Paths.DownloadFile.Responses.$200>
|
|
191
|
+
/**
|
|
192
|
+
* previewFile - previewFile
|
|
193
|
+
*
|
|
194
|
+
* Generate thumbnail preview for a file entity
|
|
195
|
+
*/
|
|
196
|
+
'previewFile'(
|
|
197
|
+
parameters?: Parameters<Paths.PreviewFile.PathParameters & Paths.PreviewFile.QueryParameters> | null,
|
|
198
|
+
data?: any,
|
|
199
|
+
config?: AxiosRequestConfig
|
|
200
|
+
): OperationResponse<any>
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export interface PathsDictionary {
|
|
204
|
+
['/v1/files:upload']: {
|
|
205
|
+
/**
|
|
206
|
+
* uploadFile - uploadFile
|
|
207
|
+
*
|
|
208
|
+
* Create pre-signed S3 URL to upload a file to keep temporarily (one week).
|
|
209
|
+
*
|
|
210
|
+
* Use the createFile operation to store file file permanently.
|
|
211
|
+
*
|
|
212
|
+
*/
|
|
213
|
+
'post'(
|
|
214
|
+
parameters?: Parameters<UnknownParamsObject> | null,
|
|
215
|
+
data?: Paths.UploadFile.RequestBody,
|
|
216
|
+
config?: AxiosRequestConfig
|
|
217
|
+
): OperationResponse<Paths.UploadFile.Responses.$201>
|
|
218
|
+
}
|
|
219
|
+
['/v1/files']: {
|
|
220
|
+
/**
|
|
221
|
+
* createFile - createFile
|
|
222
|
+
*
|
|
223
|
+
* Create a permanent File entity
|
|
224
|
+
*/
|
|
225
|
+
'post'(
|
|
226
|
+
parameters?: Parameters<UnknownParamsObject> | null,
|
|
227
|
+
data?: Paths.CreateFile.RequestBody,
|
|
228
|
+
config?: AxiosRequestConfig
|
|
229
|
+
): OperationResponse<Paths.CreateFile.Responses.$201>
|
|
230
|
+
}
|
|
231
|
+
['/v1/files/{id}:download']: {
|
|
232
|
+
/**
|
|
233
|
+
* downloadFile - downloadFile
|
|
234
|
+
*
|
|
235
|
+
* Generate pre-signed download S3 url for a file
|
|
236
|
+
*/
|
|
237
|
+
'get'(
|
|
238
|
+
parameters?: Parameters<Paths.DownloadFile.PathParameters & Paths.DownloadFile.QueryParameters> | null,
|
|
239
|
+
data?: any,
|
|
240
|
+
config?: AxiosRequestConfig
|
|
241
|
+
): OperationResponse<Paths.DownloadFile.Responses.$200>
|
|
242
|
+
}
|
|
243
|
+
['/v1/files/{id}:preview']: {
|
|
244
|
+
/**
|
|
245
|
+
* previewFile - previewFile
|
|
246
|
+
*
|
|
247
|
+
* Generate thumbnail preview for a file entity
|
|
248
|
+
*/
|
|
249
|
+
'get'(
|
|
250
|
+
parameters?: Parameters<Paths.PreviewFile.PathParameters & Paths.PreviewFile.QueryParameters> | null,
|
|
251
|
+
data?: any,
|
|
252
|
+
config?: AxiosRequestConfig
|
|
253
|
+
): OperationResponse<any>
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export type Client = OpenAPIClient<OperationMethods, PathsDictionary>
|