-
Notifications
You must be signed in to change notification settings - Fork 4
add object storage #76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, apart for some small improvements
lib/minimal-package.ts
Outdated
| @@ -1 +1 @@ | |||
| export default { name: '@mondaycom/apps-sdk', version: '3.2.1' }; | |||
| export default { name: '@mondaycom/apps-sdk', version: '3.3.0-beta.3' }; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this also needed here?
| describe('listFiles', () => { | ||
| it('should list files with default options', async () => { | ||
| const result = await objectStorage.listFiles(); | ||
|
|
||
| expect(result.success).toBe(true); | ||
| expect(Array.isArray(result.files)).toBe(true); | ||
| }); | ||
|
|
||
| it('should list files with prefix filter', async () => { | ||
| const result = await objectStorage.listFiles({ prefix: 'test-' }); | ||
|
|
||
| expect(result.success).toBe(true); | ||
| expect(Array.isArray(result.files)).toBe(true); | ||
| }); | ||
|
|
||
| it('should list files with pagination', async () => { | ||
| const result = await objectStorage.listFiles({ maxResults: 10 }); | ||
|
|
||
| expect(result.success).toBe(true); | ||
| expect(Array.isArray(result.files)).toBe(true); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all the tests here are the same, they last 2 cases dont actually check the prefix filter and the limit.
| export type UploadFileOptions = { | ||
| contentType?: string; | ||
| metadata?: Record<string, string>; | ||
| } | ||
|
|
||
| export type UploadFileResponse = { | ||
| success: boolean; | ||
| fileName?: string; | ||
| fileUrl?: string; | ||
| error?: string; | ||
| } | ||
|
|
||
| export type DownloadFileResponse = { | ||
| success: boolean; | ||
| content?: Buffer; | ||
| contentType?: string; | ||
| error?: string; | ||
| } | ||
|
|
||
| export type DeleteFileResponse = { | ||
| success: boolean; | ||
| error?: string; | ||
| } | ||
|
|
||
| export type ListFilesOptions = { | ||
| prefix?: string; | ||
| maxResults?: number; | ||
| pageToken?: string; | ||
| } | ||
|
|
||
| export type FileInfo = { | ||
| name: string; | ||
| size: number; | ||
| contentType: string; | ||
| lastModified: Date; | ||
| etag: string; | ||
| metadata: Record<string, string>; | ||
| } | ||
|
|
||
| export type ListFilesResponse = { | ||
| success: boolean; | ||
| files?: Array<FileInfo>; | ||
| nextPageToken?: string; | ||
| error?: string; | ||
| } | ||
|
|
||
| export type GetFileInfoResponse = { | ||
| success: boolean; | ||
| fileInfo?: FileInfo; | ||
| error?: string; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's extract { success; boolean, error?: string } into a shared base response
lib/object-storage/object-storage.ts
Outdated
| /** | ||
| * Upload a file to the object storage bucket | ||
| */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all of these method comments are redundant
lib/object-storage/object-storage.ts
Outdated
| */ | ||
| async getFileInfo(fileName: string): Promise<GetFileInfoResponse> { | ||
| try { | ||
| const bucket: Bucket = this.storage.bucket(this.bucketName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be extracted to the class
| } catch (error) { | ||
| const errorMessage = error instanceof Error ? error.message : String(error); | ||
| const errorObj = error instanceof Error ? error : new Error(String(error)); | ||
| logger.error('Failed to get file info:', { error: errorObj }); | ||
| return { | ||
| success: false, | ||
| error: `Failed to get file info: ${errorMessage}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
most of this can be extracted as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀
| logger.error(`Failed to ${operation}:`, { error: errorObj }); | ||
| return { errorMessage, errorObj }; | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maorb-dev add another method that will provide the dev with a pre-signed url for uploading
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
once added, also expose it with the mcode-sdk-api, simlar to this: https://github.com/DaPulse/mcode-sdk-api/pull/35/files
and also generate the python + PHP clients
No description provided.