@muhkoo/connect 0.15.0-alpha.2 → 0.15.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.js +389 -95
- package/dist/browser/index.js.map +1 -1
- package/dist/connect.d.ts +94 -10
- package/dist/server/index.js +389 -95
- package/dist/server/index.js.map +1 -1
- package/package.json +1 -1
package/dist/connect.d.ts
CHANGED
|
@@ -4335,8 +4335,12 @@ declare class KvCache {
|
|
|
4335
4335
|
* state but a fresh local write wins.
|
|
4336
4336
|
*/
|
|
4337
4337
|
mergeRemote(commitment: string, fullKey: string, envelope: unknown | null, op: "set" | "delete", hlc?: string): Promise<void>;
|
|
4338
|
-
/**
|
|
4339
|
-
|
|
4338
|
+
/**
|
|
4339
|
+
* Non-tombstoned full keys for a commitment that start with `prefix` (all
|
|
4340
|
+
* of them by default), for offline `list`. The store scans the key range
|
|
4341
|
+
* `${commitment}|${prefix}`, so other collections are never read.
|
|
4342
|
+
*/
|
|
4343
|
+
liveKeys(commitment: string, prefix?: string): Promise<string[]>;
|
|
4340
4344
|
/** Queue a kv mutation for replay on reconnect. */
|
|
4341
4345
|
enqueue(method: "set" | "delete", args: unknown, hlc: string, clientId: string): Promise<void>;
|
|
4342
4346
|
}
|
|
@@ -4348,6 +4352,7 @@ declare class KvCache {
|
|
|
4348
4352
|
* await client.kv.set('todos', id, { title, completed })
|
|
4349
4353
|
* const todo = await client.kv.get('todos', id)
|
|
4350
4354
|
* const ids = await client.kv.list('todos')
|
|
4355
|
+
* const keys = await client.kv.keys('todos/') // full keys, any prefix
|
|
4351
4356
|
* await client.kv.delete('todos', id)
|
|
4352
4357
|
* const off = client.kv.on('change', e => …) // realtime, cross-device
|
|
4353
4358
|
*
|
|
@@ -4399,8 +4404,23 @@ declare class KvNamespace {
|
|
|
4399
4404
|
get<T = unknown>(collection: string, id: string): Promise<T | null>;
|
|
4400
4405
|
/** Delete `collection`/`id`. Returns whether the key existed. */
|
|
4401
4406
|
delete(collection: string, id: string): Promise<boolean>;
|
|
4402
|
-
/**
|
|
4407
|
+
/**
|
|
4408
|
+
* List the ids present in `collection`. The server filters by
|
|
4409
|
+
* `${collection}/` and pages; values are not fetched.
|
|
4410
|
+
*/
|
|
4403
4411
|
list(collection: string): Promise<string[]>;
|
|
4412
|
+
/**
|
|
4413
|
+
* Every key in the signed-in user's personal space that starts with
|
|
4414
|
+
* `prefix` (all of them when it is ""), as full keys: `todos/t1`, not
|
|
4415
|
+
* `t1`. Values are not fetched. The personal space is shared by every
|
|
4416
|
+
* app the user signs into, so expect keys you did not write: the VFS's
|
|
4417
|
+
* `vfs/…`, version control's `vcs/…`, the SDK's own `chat-keys` and
|
|
4418
|
+
* `space-keys/…`.
|
|
4419
|
+
*
|
|
4420
|
+
* The local `startsWith` filter stays on purpose: a server older than
|
|
4421
|
+
* the key index ignores `prefix` and returns every key.
|
|
4422
|
+
*/
|
|
4423
|
+
keys(prefix?: string): Promise<string[]>;
|
|
4404
4424
|
/** Reserved — server-side query is deferred (see the overhaul plan). */
|
|
4405
4425
|
query(_collection: string, _filter?: unknown): Promise<never>;
|
|
4406
4426
|
/**
|
|
@@ -6664,8 +6684,14 @@ interface VfsStore {
|
|
|
6664
6684
|
get(key: string): Promise<unknown | null>;
|
|
6665
6685
|
put(key: string, value: unknown): Promise<void>;
|
|
6666
6686
|
delete(key: string): Promise<void>;
|
|
6667
|
-
/**
|
|
6668
|
-
|
|
6687
|
+
/**
|
|
6688
|
+
* Keys in the store that start with `prefix`, or every key without one.
|
|
6689
|
+
* The personal space is shared, so this is NOT VFS-only. An implementation
|
|
6690
|
+
* may ignore `prefix` and return more (the parameter is optional so that
|
|
6691
|
+
* a store written for the old no-argument `list()` still fits), so callers
|
|
6692
|
+
* filter what they get back.
|
|
6693
|
+
*/
|
|
6694
|
+
list(prefix?: string): Promise<string[]>;
|
|
6669
6695
|
}
|
|
6670
6696
|
/** Raised when the master seed is not held, so the root key cannot be derived. */
|
|
6671
6697
|
declare class VfsLockedError extends Error {
|
|
@@ -6754,9 +6780,10 @@ declare class VfsLimitError extends Error {
|
|
|
6754
6780
|
*
|
|
6755
6781
|
* Within ONE tab, writes of a record are queued and sent one at a time, in the
|
|
6756
6782
|
* order they were made, and a read that has to fetch a record waits for its
|
|
6757
|
-
* write in flight (see `writing`).
|
|
6758
|
-
*
|
|
6759
|
-
*
|
|
6783
|
+
* write in flight (see `writing`). Every edit of a record is made to one
|
|
6784
|
+
* in-memory copy of it, and that copy is what is written (see `mutate`). All
|
|
6785
|
+
* of this is per namespace instance only; nothing orders writes across tabs
|
|
6786
|
+
* or devices - that would take a compare-and-swap at the server.
|
|
6760
6787
|
*/
|
|
6761
6788
|
|
|
6762
6789
|
/**
|
|
@@ -6832,8 +6859,25 @@ declare class VfsNamespace {
|
|
|
6832
6859
|
* The file tree re-lists constantly while typing, and every miss is a
|
|
6833
6860
|
* network round trip plus a decrypt. Invalidated precisely on write rather
|
|
6834
6861
|
* than by TTL — a stale directory listing shows files that are not there.
|
|
6862
|
+
*
|
|
6863
|
+
* What a cached read resolves to is also THE copy of that record: the one
|
|
6864
|
+
* every edit of it is made to, and the one written. See `mutate`.
|
|
6835
6865
|
*/
|
|
6836
6866
|
private cache;
|
|
6867
|
+
/**
|
|
6868
|
+
* Bumped by `clearCache`, which is for a change of identity.
|
|
6869
|
+
*
|
|
6870
|
+
* A read or write begun before it can finish after it, and what it read
|
|
6871
|
+
* or wrote belongs to whoever was signed in before. So every record
|
|
6872
|
+
* carries the generation it was read under, and none goes into the cache,
|
|
6873
|
+
* or is edited as the cache's copy, under another.
|
|
6874
|
+
*/
|
|
6875
|
+
private generation;
|
|
6876
|
+
/**
|
|
6877
|
+
* The record each promise in `cache` resolved to, and each write in
|
|
6878
|
+
* `writing` is sending: what `editable` finds without waiting.
|
|
6879
|
+
*/
|
|
6880
|
+
private readonly copyOf;
|
|
6837
6881
|
/**
|
|
6838
6882
|
* The write of each directory record still in flight, by id.
|
|
6839
6883
|
*
|
|
@@ -7121,8 +7165,47 @@ declare class VfsNamespace {
|
|
|
7121
7165
|
* aside in `hidden` instead: out of every read, but kept for the write.
|
|
7122
7166
|
*/
|
|
7123
7167
|
private readRecord;
|
|
7124
|
-
/**
|
|
7168
|
+
/**
|
|
7169
|
+
* Apply an edit to a directory record and persist it.
|
|
7170
|
+
*
|
|
7171
|
+
* `dir` says which record - its id, key and path - and nothing more. The
|
|
7172
|
+
* edit is made to THE copy of that record (see `editable`), which `dir`
|
|
7173
|
+
* may no longer be, and that copy is what is written. Editing whichever
|
|
7174
|
+
* copy the caller held let two copies of one record exist at once: an
|
|
7175
|
+
* overwrite held its directory across storing the old version's
|
|
7176
|
+
* history, a write of the directory failed meanwhile and dropped it from
|
|
7177
|
+
* the cache, and a save that then read a second copy and stored it,
|
|
7178
|
+
* successfully, was undone when the overwrite stored the first.
|
|
7179
|
+
*
|
|
7180
|
+
* So `edit` must take what it writes from the record it is given, not
|
|
7181
|
+
* from anything read off `dir` before an await - and re-check whatever it
|
|
7182
|
+
* relies on from then, throwing if another write changed it. Returning
|
|
7183
|
+
* false writes nothing after all.
|
|
7184
|
+
*/
|
|
7125
7185
|
private mutate;
|
|
7186
|
+
/**
|
|
7187
|
+
* The copy of `dir`'s record that edits are made to, if there is one
|
|
7188
|
+
* without waiting: the one the cache holds, once read.
|
|
7189
|
+
*
|
|
7190
|
+
* Failing that, the one a write in flight is sending. The record was
|
|
7191
|
+
* dropped from the cache - a change was reported, our own write's echo
|
|
7192
|
+
* among them - and a read that came in since is waiting for that write,
|
|
7193
|
+
* to answer with this very copy if it lands (see `openDirById`); if it
|
|
7194
|
+
* fails, the write an edit now queues behind it carries the copy instead.
|
|
7195
|
+
*
|
|
7196
|
+
* Undefined when the record is not cached and nothing is writing it, or
|
|
7197
|
+
* it is still being read: `reopen` waits for that. A record read before
|
|
7198
|
+
* `clearCache` is edited as it is, as it always was. It is not the copy of
|
|
7199
|
+
* anything the cache holds now, and must not be handed the next identity's.
|
|
7200
|
+
*/
|
|
7201
|
+
private editable;
|
|
7202
|
+
/**
|
|
7203
|
+
* Read `dir`'s record - the cached read, or a fetch made once any write of
|
|
7204
|
+
* it in flight has settled - and then find the copy edits are made to.
|
|
7205
|
+
*/
|
|
7206
|
+
private reopen;
|
|
7207
|
+
/** Make `dir` the cached copy of its record - unless the cache has been cleared since it was read. */
|
|
7208
|
+
private adopt;
|
|
7126
7209
|
/**
|
|
7127
7210
|
* Seal a directory record as it stands NOW and put it in the store.
|
|
7128
7211
|
*
|
|
@@ -7131,6 +7214,7 @@ declare class VfsNamespace {
|
|
|
7131
7214
|
* then, its own included.
|
|
7132
7215
|
*/
|
|
7133
7216
|
private writeRecord;
|
|
7217
|
+
/** For `mkdir`: name a new, empty directory `path` in the one at `parentPath`. */
|
|
7134
7218
|
private createDir;
|
|
7135
7219
|
/**
|
|
7136
7220
|
* Every directory record in a subtree, each once, opened - and nothing
|
|
@@ -9018,7 +9102,7 @@ declare function getId(row: {
|
|
|
9018
9102
|
* expect (and isn't serving a stale cached bundle). Keep this in sync with
|
|
9019
9103
|
* `package.json` `version`.
|
|
9020
9104
|
*/
|
|
9021
|
-
declare const VERSION = "0.15.0-alpha.
|
|
9105
|
+
declare const VERSION = "0.15.0-alpha.3";
|
|
9022
9106
|
|
|
9023
9107
|
/**
|
|
9024
9108
|
* The SDK's process-global logger.
|