-
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
Open
joshua-journey-apps
wants to merge
39
commits into
main
Choose a base branch
from
attachment-package-refactor
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+13,650
−7,921
Open
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
01070e1
initial implementation
joshua-journey-apps 23dc8e4
Add make, remove and get uri endpoints to local storage
joshua-journey-apps ecb71cb
Fix exporting node and index db storage adapters
joshua-journey-apps 029df9d
Wip add sync throttle & cache limiting
joshua-journey-apps 958675a
Add downloading attachment test
joshua-journey-apps 45773aa
Add user defined storage adapter path
joshuabrink 533dfab
Refactor watch active observer into dedicated service
joshuabrink 643289d
Add temporal units to variable name
joshuabrink 6840fb0
Rename storage -> syncing service
joshuabrink d8d4ad9
Add updateHook to save file
joshuabrink 9509aeb
Use async onUpdate callback
joshuabrink 9ac685c
Improve comments
joshuabrink ce33bab
Fix closing the watch active attachments listener
joshuabrink 704c2a8
tests(WIP:) initial node setup and few bug fixes
ff25b2b
tests: fixed SyncService to rely on LocalStorage and be agnostic to f…
fae7f27
test: workflow tests working and passing
eedd224
feat: introduce AttachmentErrorHandler for custom error handling in a…
ec1a733
feat: added archival management to AttachmentQueue via AttachmentCon…
f6b2343
docs: update README.md to document usage
4cb5753
feat: added ExpoFileSystemAdapter to the attachments package
7e40d26
refactor: refactored react native demo to use new attachments API
206bd5f
fix: expo blob compatability and attachment row mapping
joshuabrink e42ae45
fix: node exclusive exports
joshuabrink 4d5a1bc
fix: linting, dead code and move active watch into start sync
joshuabrink 8db8f2a
refactor: move attachments to common package
joshuabrink be856e9
refactor: moved readme to attachments folder
c3fd550
refactor: add ExpoFileSystemAdapter for local storage management in R…
26722fb
fix: export IndexDBFileSystemAdapter from web package
3eba6f0
chore: add helper script to clean up node_modules directories in the …
de9130e
docs: fixed README to properly point to React Native web demo
20bb3a3
refactor: demos now use attachments functionality from the core libra…
b8dea39
refactor: migrate to using @powersync/common for shared functionality…
62b0bdc
fix: exclude expo file system from bundle
d514ef8
Merge branch 'main' into attachment-package-refactor
649290c
Merge branch 'main' into attachment-package-refactor
khawarizmus eb0a93a
fix: add missing comma in package.json dependencies
d179b9c
chore: update dependencies in pnpm-lock.yaml to latest versions
f401bc0
fix: update import paths in attachment-related files to use local mod…
d86799a
chore: add changeset
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| --- | ||
| '@powersync/react-native': minor | ||
| '@powersync/common': minor | ||
| '@powersync/node': minor | ||
| '@powersync/web': minor | ||
| '@powersync/attachments': patch | ||
| --- | ||
|
|
||
| Deprecated @powersync/attachments in favor of enhanced and consistent attachment functionality built into @powersync/common and platform-specific SDKs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,3 +9,5 @@ dist | |
| # Useful if running repository in VSCode dev container | ||
| .pnpm-store | ||
| __screenshots__ | ||
| testing.db | ||
| testing.db-* | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 0 additions & 50 deletions
50
demos/react-native-supabase-todolist/library/powersync/PhotoAttachmentQueue.ts
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
demos/react-native-supabase-todolist/library/storage/SupabaseRemoteStorageAdapter.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| import { SupabaseClient } from '@supabase/supabase-js'; | ||
| import { AttachmentRecord, RemoteStorageAdapter } from '@powersync/react-native'; | ||
|
|
||
| export interface SupabaseRemoteStorageAdapterOptions { | ||
| client: SupabaseClient; | ||
| bucket: string; | ||
| } | ||
|
|
||
| /** | ||
| * SupabaseRemoteStorageAdapter implements RemoteStorageAdapter for Supabase Storage. | ||
| * Handles upload, download, and deletion of files from Supabase Storage buckets. | ||
| */ | ||
| export class SupabaseRemoteStorageAdapter implements RemoteStorageAdapter { | ||
| constructor(private options: SupabaseRemoteStorageAdapterOptions) {} | ||
|
|
||
| async uploadFile(fileData: ArrayBuffer, attachment: AttachmentRecord): Promise<void> { | ||
| const mediaType = attachment.mediaType ?? 'application/octet-stream'; | ||
|
|
||
| const { error } = await this.options.client.storage | ||
| .from(this.options.bucket) | ||
| .upload(attachment.filename, fileData, { contentType: mediaType }); | ||
|
|
||
| if (error) { | ||
| throw error; | ||
| } | ||
| } | ||
|
|
||
| async downloadFile(attachment: AttachmentRecord): Promise<ArrayBuffer> { | ||
| const { data, error } = await this.options.client.storage.from(this.options.bucket).download(attachment.filename); | ||
|
|
||
| if (error) { | ||
| throw error; | ||
| } | ||
|
|
||
| return new Promise((resolve, reject) => { | ||
| const reader = new FileReader(); | ||
| reader.onloadend = () => { | ||
| resolve(reader.result as ArrayBuffer); | ||
| }; | ||
| reader.onerror = reject; | ||
| reader.readAsArrayBuffer(data); | ||
| }); | ||
| } | ||
|
|
||
| async deleteFile(attachment: AttachmentRecord): Promise<void> { | ||
| const { error } = await this.options.client.storage.from(this.options.bucket).remove([attachment.filename]); | ||
|
|
||
| if (error) { | ||
| console.debug('Failed to delete file from Supabase Storage', error); | ||
| throw error; | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.