-
Notifications
You must be signed in to change notification settings - Fork 51
Export AsyncDatabaseConnection types in @powersync/web
#655
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
Export AsyncDatabaseConnection types in @powersync/web
#655
Conversation
🦋 Changeset detectedLatest commit: 6ec3066 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 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 |
Hey @LucDeCaf, that file contains internal members which we might have not exposed intentionally so that we might be able to drop it in the future without being a breaking change - in which case I might suggest making your own copies of the types on your side. Any thoughts @stevensJourney? |
Indeed these are currently internals. I do see that devs might want access to these internals in order to build custom database workers - e.g. if custom SQLite functions are desired. I quite like having the freedom to change these interfaces without making breaking changes. If users really have a pressing need for this - one potential workaround might be to mark these exports as |
@Chriztiaan @stevensJourney I think it would be useful to have access to these functions - right now I just modify the powersync/web folder in node_modules, but that doesn't feel like a very robust solution. My reasoning for why it might make sense to expose these APIs is that the port returned by the public facing shareConnection API proxies into OpenAsyncDatabaseConnection. Example: this snippet uses only public APIs except for those in AsyncDatabaseConnection: const powersync = new PowerSyncDatabase({ /* ... */ });
// Obtain a port for use elsewhere (eg. in a custom worker)
const db = powersync.database; // Will be of type WebDBAdapter unless using SSR
const { port } = await db.shareConnection();
const resolvedOptions = db.getConfiguration();
// my_worker.ts
const remote = Comlink.wrap<OpenAsyncDatabaseConnection>(port);
const connection: AsyncDatabaseConnection = await remote(resolvedOptions); It's worth noting that WebDBAdapter isn't public either, but the method is still publicly available via If we don't want to expose the API that's fine too, like I said it would just be nice 👍 |
Hey @LucDeCaf two things from my side:
|
Thanks for the suggestion and contribution :) |
The entire change is adding one more file's types to
packages/web/src/index.ts
.Long story short, I need access to these types in my codebase :)