Relax fileExtension requirement in attachmentQueue
Hello powersync team 👋
This PR fixes #268 and updates the watchIds method in the Attachments helper to make the fileExtension parameter optional. This enables support for storing files with different extensions in the same attachmentQueue, which is useful in cases where:
- The extension is already part of the filename (e.g., managed directly in the storage bucket like Supabase).
- The developer wants more flexibility in handling mixed file types under a unified queue.
Motivation: Currently, the API assumes a single extension per queue, which limits use cases that involve multiple file types. Making fileExtension optional opens up broader usage while maintaining backward compatibility.
⚠️ This includes a breaking change. And along that, I'm wondering if it shouldn't be pushed further to be able to specify a Map<String, String?> for <filename, extension?> in the whatchIds to allow even more flexibility and usecases.
This change was inspired by this Discord thread.
WDYT? Looking forward to feedback!
PS: There is also a change about ensuring directory creation. In my usecase, I'm using Teams' ids as subdirectory so it's fully dynamic and my filename is like the following:
{teamId}/{attachmentType}/{attachmentId}.{attachmentExtension}.
Hi @stevensJourney, thanks for the feedback! It's interesting to see that the question raised in other technos as well and that a common ground has been found to tackle this issue. Of course, I think consistency is key as Powersync users expect it when using the library from one stack to another.
I'll have a deeper look in your changes and try to adapt my PR asap 🤓
Hey @simolus3, First of all, thanks a lot for the review 🙏
Regarding this PR, I'll do the changes anyway, mainly from a learning perspective 🤓 But no worries if it doesn't get merged or if the new version you're working on guys is better 🤗 I'm glad this is reworked on your side and really am impatient to test it! I'll update this as soon as I can and leave you the choice to merge or not 👍
I think that you're progressing much faster than me on the #311 😅 Sorry, I had lot of work and didn't manage to progress on this one. I'll close it if that's fine for you 🤓
Sure 👍 Also, thanks for pushing on this and taking the time to contribute! We'll do our best to release the other PR soon 🫡