-
Notifications
You must be signed in to change notification settings - Fork 60
Update attachment package #735
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: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: d86799a The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
stevensJourney
left a comment
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 looks like a good improvement so far. I've added some comments for some items I spotted.
packages/attachments/src/storageAdapters/NodeFileSystemAdapter.ts
Outdated
Show resolved
Hide resolved
- Added `getAttachment` method to retrieve an attachment by ID in AttachmentContext. - Updated `upsertAttachment` to handle null values for optional fields. - Introduced `generateAttachmentId` method in AttachmentQueue for generating unique IDs. - Modified `watchActiveAttachments` to accept a throttle parameter. - Added `deleteFile` method to have attachment deletion. - Updated tests to cover new functionality and ensure reliability.
…ttachment sync operations - Added AttachmentErrorHandler interface to manage download, upload, and delete errors for attachments. - Updated AttachmentQueue and SyncingService to utilize the new error handler. - Enhanced tests to verify error handling behavior during attachment sync processes.
671e23a to
bea28d9
Compare
bea28d9 to
e42ae45
Compare
… across the react-native-web demo
# Conflicts: # pnpm-lock.yaml
stevensJourney
left a comment
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.
Left some comments. Overall the APIs and code looks good so far.
| localStorage, | ||
| remoteStorage, | ||
| watchAttachments: (onUpdate) => { | ||
| this.powersync.watch( |
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.
It looks like we would need a way to dispose of the watched queries here. e.g. if the AttachmentsQueue was to be closed (or sync stopped), we'd need to stop these queries.
| "type": "git", | ||
| "url": "git+https://github.com/powersync-ja/powersync-js.git" | ||
| }, | ||
| "deprecated": "This package has been merged into @powersync/common. Please use @powersync/common instead.", |
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.
Maybe we should recommend using the various SDK packages directly instead? We typically don't require users to install @powersync/common directly for most cases.
| state: AttachmentState.SYNCED | ||
| }); | ||
| } else { | ||
| // The localURI should be set if the record was meant to be downloaded |
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.
| // The localURI should be set if the record was meant to be downloaded | |
| // The localURI should be set if the record was meant to be uploaded |
| * - Archives attachments with missing local files that haven't been uploaded | ||
| * - Requeues synced attachments for download if their local files are missing | ||
| */ | ||
| verifyAttachments = async (): Promise<void> => { |
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.
For my curiosity, whats the reason for this being an arrow function?
| hasSynced: true | ||
| }; | ||
| } catch (error) { | ||
| const shouldRetry = this.errorHandler?.onUploadError(attachment, error) ?? false; |
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.
I think the default here should be true. We only want to skip retries if the errorHandler explicitly says to do so.
| @@ -0,0 +1,481 @@ | |||
| import { describe, expect, it, vi } from 'vitest'; | |||
| import { vol } from 'memfs'; | |||
| import { PowerSyncDatabase, Schema, Table, column, NodeFileSystemAdapter } from '../../node'; | |||
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.
It might be easier to just have these tests in the node package's unit tests.
| "dependencies": { | ||
| "@powersync/common": "workspace:*", | ||
| "@powersync/react": "workspace:*", | ||
| "expo-file-system": "18.0.12", |
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.
I assume this would not work on non-Expo React Native projects? One would need to confirm this dependency does not cause any issues on bare React native projects.
This a port of the Swift, Dart and Kotlin attachment's API to the JS SDK.
This addresses the following issues #715 and #714 by adding the
meta_datacolumn to the table and persisting it in the attachments table.It is currently still a work-in-progress so there are a couple things that still needs to be done: