sqlite-wasm
sqlite-wasm copied to clipboard
Add `sqlite3Worker1Promiser` type declarations
Fixes #53
This is going to need lots of overloads:
A Promiser object is a function with two call signatures:
( messageType, messageArguments ) is equivalent to: ( {type: messageType, args: type-specific value} )where the type is always a string and the args value is message-type specific. It always returns a Promise object which resolves to an object:
{ type: messageType, result: type-specific result value, ... possibly other metadata ... }
https://sqlite.org/wasm/doc/tip/api-worker1.md#promiser
Hi, I wanted to let you know that I am currently working on writing the types. I expect to be in a position to share my work with you in the next few days.
Hey, I just added some partial types to a project recently. They are not comprehensive by any means, but maybe they can serve to get started or to get some ideas: https://github.com/moodlehq/moodleapp/blob/main/src/types/sqlite-wasm.d.ts
Hi,
Still working on it, fine-tuning messageId to unlock its full potential
Note that the messageId is an internal-use property used for dispatching messages between the worker and callbacks. It is hypothetically conceivable for clients to tinker with but no actual use for that comes to mind. FWIW, IMO messageId should be flagged as an opaque type of no interest to clients.
Hi, I made a PR to merge with this adding most of the Sqlite3Worker1Promiser related types https://github.com/sqlite/sqlite-wasm/pull/76. Still have a few things left to do mainly with PromiserMethods, but would appreciate a second look from anyone interested
Also copying over my progress comment avoid splitting overall progress discussion:
Progress:
- [ ] Mostly done with
Sqlite3Worker1PromiserConfig. Not sure what goes in for the args ofgenerateMessageId- [ ] Need clearer documentation for
PromiserMethodopen'sfilenameandvfs- [ ]
execneeds to add a full list of arguments, js eqivalent for sqlVALUEvalue used in row and bind- [ ] There is additional metadata returned by
Promiser. Described as "// possibly other metadata ..." on sqlite docs. Not sure how stable these are / if they should be documented here.- [ ] Need to add type for
Promiserresponse error stack trace arrayAs the methods are very similar to worker1, I'm hoping I can reduce what is specified here and reuse the existing types where possible.