Skip to content

Commit

Permalink
Merge pull request #105 from epilot-dev/update-file-client-with-new-spec
Browse files Browse the repository at this point in the history
Update file client with new spec
  • Loading branch information
JaniPM authored Sep 21, 2023
2 parents 12d25c4 + d526c98 commit 4b09c2a
Show file tree
Hide file tree
Showing 5 changed files with 437 additions and 13 deletions.
4 changes: 2 additions & 2 deletions clients/file-client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion clients/file-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@epilot/file-client",
"version": "1.7.1",
"version": "1.7.2",
"description": "Client library for the epilot File API",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
31 changes: 31 additions & 0 deletions clients/file-client/src/openapi-runtime.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,29 @@
}
},
"/v1/files:previewS3": {
"get": {
"operationId": "previewS3FileGet",
"parameters": [
{
"name": "key",
"in": "query",
"required": true
},
{
"name": "bucket",
"in": "query",
"required": true
},
{
"name": "w",
"in": "query"
},
{
"name": "h",
"in": "query"
}
]
},
"post": {
"operationId": "previewS3File",
"parameters": [
Expand Down Expand Up @@ -173,6 +196,14 @@
}
}
}
},
"/v1/files/session": {
"get": {
"operationId": "getSession"
},
"delete": {
"operationId": "deleteSession"
}
}
},
"components": {},
Expand Down
170 changes: 168 additions & 2 deletions clients/file-client/src/openapi.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,25 @@ import type {

declare namespace Components {
namespace Schemas {
export interface CommonSaveFilePayload {
[name: string]: any;
/**
* if passed, adds a new version to existing file entity
*/
file_entity_id?: string;
document_type?: "document" | "document_template" | "text" | "image" | "video" | "audio" | "spreadsheet" | "presentation" | "font" | "archive" | "application" | "unknown";
/**
* example:
* document.pdf
*/
filename?: string;
_tags?: string[];
access_control?: "private" | "public-read";
/**
* List of entities to relate the file to
*/
relations?: FileRelationItem[];
}
export interface DeleteFilePayload {
s3ref: S3Reference;
}
Expand All @@ -25,6 +44,17 @@ declare namespace Components {
*/
version?: number;
}[];
/**
* example:
* ef7d985c-2385-44f4-9c71-ae06a52264f8
*/
export type EntityId = string;
/**
* URL-friendly identifier for the entity schema
* example:
* contact
*/
export type EntitySlug = string;
export interface FileEntity {
_id?: /**
* example:
Expand Down Expand Up @@ -93,6 +123,20 @@ declare namespace Components {
*/
mime_type?: string;
}
export interface FileRelationItem {
entity_id: /**
* example:
* ef7d985c-2385-44f4-9c71-ae06a52264f8
*/
EntityId;
_schema?: /**
* URL-friendly identifier for the entity schema
* example:
* contact
*/
EntitySlug;
_tags?: string[];
}
export interface S3Reference {
/**
* example:
Expand All @@ -105,9 +149,8 @@ declare namespace Components {
*/
key: string;
}
export interface SaveFilePayload {
export interface SaveCustomFilePayload {
[name: string]: any;
s3ref: S3Reference;
/**
* if passed, adds a new version to existing file entity
*/
Expand All @@ -120,6 +163,35 @@ declare namespace Components {
filename?: string;
_tags?: string[];
access_control?: "private" | "public-read";
/**
* List of entities to relate the file to
*/
relations?: FileRelationItem[];
/**
* Custom external download url used for the file
*/
custom_download_url: string; // url
}
export type SaveFilePayload = SaveS3FilePayload | SaveCustomFilePayload;
export interface SaveS3FilePayload {
[name: string]: any;
/**
* if passed, adds a new version to existing file entity
*/
file_entity_id?: string;
document_type?: "document" | "document_template" | "text" | "image" | "video" | "audio" | "spreadsheet" | "presentation" | "font" | "archive" | "application" | "unknown";
/**
* example:
* document.pdf
*/
filename?: string;
_tags?: string[];
access_control?: "private" | "public-read";
/**
* List of entities to relate the file to
*/
relations?: FileRelationItem[];
s3ref: S3Reference;
}
export interface UploadFilePayload {
/**
Expand All @@ -144,6 +216,12 @@ declare namespace Paths {
}
}
}
namespace DeleteSession {
namespace Responses {
export interface $200 {
}
}
}
namespace DownloadFile {
namespace Parameters {
export type Attachment = boolean;
Expand Down Expand Up @@ -205,6 +283,12 @@ declare namespace Paths {
}
}
}
namespace GetSession {
namespace Responses {
export interface $200 {
}
}
}
namespace PreviewFile {
namespace Parameters {
export type H = number;
Expand Down Expand Up @@ -258,6 +342,20 @@ declare namespace Paths {
}
export type RequestBody = Components.Schemas.S3Reference;
}
namespace PreviewS3FileGet {
namespace Parameters {
export type Bucket = string;
export type H = number;
export type Key = string;
export type W = number;
}
export interface QueryParameters {
key: Parameters.Key;
bucket: Parameters.Bucket;
w?: Parameters.W;
h?: Parameters.H;
}
}
namespace SaveFile {
export type RequestBody = Components.Schemas.SaveFilePayload;
namespace Responses {
Expand Down Expand Up @@ -436,6 +534,16 @@ export interface OperationMethods {
data?: any,
config?: AxiosRequestConfig
): OperationResponse<any>
/**
* previewS3FileGet - previewS3FileGet
*
* Get thumbnail preview from an s3 reference for a file entity
*/
'previewS3FileGet'(
parameters?: Parameters<Paths.PreviewS3FileGet.QueryParameters> | null,
data?: any,
config?: AxiosRequestConfig
): OperationResponse<any>
/**
* previewS3File - previewS3File
*
Expand All @@ -456,6 +564,29 @@ export interface OperationMethods {
data?: Paths.DeleteFile.RequestBody,
config?: AxiosRequestConfig
): OperationResponse<Paths.DeleteFile.Responses.$200>
/**
* getSession - getSession
*
* Start a browser session by setting passed Authorization token in a server side cookie.
*
* Allows using preview urls directly in img src for private files using cookie authentication.
*
*/
'getSession'(
parameters?: Parameters<UnknownParamsObject> | null,
data?: any,
config?: AxiosRequestConfig
): OperationResponse<Paths.GetSession.Responses.$200>
/**
* deleteSession - deleteSession
*
* End browser session by deleting token cookie
*/
'deleteSession'(
parameters?: Parameters<UnknownParamsObject> | null,
data?: any,
config?: AxiosRequestConfig
): OperationResponse<Paths.DeleteSession.Responses.$200>
}

export interface PathsDictionary {
Expand Down Expand Up @@ -567,6 +698,16 @@ export interface PathsDictionary {
): OperationResponse<any>
}
['/v1/files:previewS3']: {
/**
* previewS3FileGet - previewS3FileGet
*
* Get thumbnail preview from an s3 reference for a file entity
*/
'get'(
parameters?: Parameters<Paths.PreviewS3FileGet.QueryParameters> | null,
data?: any,
config?: AxiosRequestConfig
): OperationResponse<any>
/**
* previewS3File - previewS3File
*
Expand All @@ -590,6 +731,31 @@ export interface PathsDictionary {
config?: AxiosRequestConfig
): OperationResponse<Paths.DeleteFile.Responses.$200>
}
['/v1/files/session']: {
/**
* getSession - getSession
*
* Start a browser session by setting passed Authorization token in a server side cookie.
*
* Allows using preview urls directly in img src for private files using cookie authentication.
*
*/
'get'(
parameters?: Parameters<UnknownParamsObject> | null,
data?: any,
config?: AxiosRequestConfig
): OperationResponse<Paths.GetSession.Responses.$200>
/**
* deleteSession - deleteSession
*
* End browser session by deleting token cookie
*/
'delete'(
parameters?: Parameters<UnknownParamsObject> | null,
data?: any,
config?: AxiosRequestConfig
): OperationResponse<Paths.DeleteSession.Responses.$200>
}
}

export type Client = OpenAPIClient<OperationMethods, PathsDictionary>
Loading

0 comments on commit 4b09c2a

Please sign in to comment.