@drakkar.software/starfish-client 3.0.0-alpha.31 → 3.0.0-alpha.36
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/README.md +5 -1
- package/dist/bindings/zustand.d.ts +13 -1
- package/dist/bindings/zustand.js +163 -80
- package/dist/bindings/zustand.js.map +2 -2
- package/dist/client.d.ts +44 -6
- package/dist/index.js +144 -80
- package/dist/index.js.map +2 -2
- package/dist/sync.d.ts +22 -0
- package/dist/types.d.ts +13 -7
- package/package.json +3 -3
package/dist/sync.d.ts
CHANGED
|
@@ -106,6 +106,28 @@ export declare class SyncManager {
|
|
|
106
106
|
*/
|
|
107
107
|
seedFromCache(): Promise<boolean>;
|
|
108
108
|
getCheckpoint(): number;
|
|
109
|
+
/**
|
|
110
|
+
* Apply a freshly-fetched `PullResult` to this manager's state WITHOUT
|
|
111
|
+
* firing a network request. Used by the zustand binding's `mergeResult`
|
|
112
|
+
* action to absorb a background revalidation result (delivered via
|
|
113
|
+
* {@link StarfishClientOptions.onRevalidated}) into the store.
|
|
114
|
+
*
|
|
115
|
+
* Like {@link pull}, `ingest` conflict-merges the snapshot against the
|
|
116
|
+
* established baseline via `this.onConflict` when a checkpoint exists — so a
|
|
117
|
+
* union-merge store does not lose array items when a revalidation result
|
|
118
|
+
* (e.g. a stale cache-fallback on 429/5xx) is a shorter snapshot. The first
|
|
119
|
+
* ingest (no checkpoint yet) takes the snapshot wholesale. Sets
|
|
120
|
+
* `lastFromCache = false` (a revalidation is a live response) so the binding
|
|
121
|
+
* can clear its `stale` flag.
|
|
122
|
+
*
|
|
123
|
+
* **Staleness guard**: if a `push()` advanced `lastCheckpoint` between the
|
|
124
|
+
* time the revalidation request was sent and the time it resolves, the
|
|
125
|
+
* result is from an older document version. Ingesting it would clobber the
|
|
126
|
+
* user's just-saved edit and reset `lastHash` to a stale server hash
|
|
127
|
+
* (causing a spurious 409 on the next push). We silently drop the result in
|
|
128
|
+
* that case — the store's post-push state is already correct.
|
|
129
|
+
*/
|
|
130
|
+
ingest(result: PullResult): Promise<void>;
|
|
109
131
|
pull(): Promise<PullResult>;
|
|
110
132
|
push(data: Record<string, unknown>): Promise<{
|
|
111
133
|
hash: string;
|
package/dist/types.d.ts
CHANGED
|
@@ -144,15 +144,21 @@ export interface StarfishClientOptions {
|
|
|
144
144
|
*/
|
|
145
145
|
cacheFallbackStatuses?: number[];
|
|
146
146
|
/**
|
|
147
|
-
* Called after a background revalidation
|
|
148
|
-
*
|
|
149
|
-
* the fresh snapshot has been written through to the cache.
|
|
147
|
+
* Called after a background revalidation delivers a fresh snapshot to the
|
|
148
|
+
* cache. Fires for two revalidation paths:
|
|
150
149
|
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
150
|
+
* 1. **Error-triggered** ({@link cacheFallbackStatuses} hit): the server
|
|
151
|
+
* returned a transient error (429/5xx), `pull()` served the stale cache,
|
|
152
|
+
* and the background retry loop eventually got a live response.
|
|
153
|
+
* 2. **SWR-on-read** ({@link PullOptions.staleWhileRevalidate}): `pull()`
|
|
154
|
+
* served the cache immediately and the background fetch completed.
|
|
153
155
|
*
|
|
154
|
-
* `
|
|
155
|
-
*
|
|
156
|
+
* In both cases `result` is the fresh `PullResult` just written to cache.
|
|
157
|
+
* Use this to signal reachability recovery and/or push the fresh data into
|
|
158
|
+
* any store that is showing the stale snapshot.
|
|
159
|
+
*
|
|
160
|
+
* `path` is the namespaced document path (namespace prefix + path + query
|
|
161
|
+
* string, matching the cache key written by {@link StarfishClient.pull}).
|
|
156
162
|
*/
|
|
157
163
|
onRevalidated?: (path: string, result: PullResult) => void;
|
|
158
164
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drakkar.software/starfish-client",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.36",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/Drakkar-Software/starfish.git",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
}
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@drakkar.software/starfish-protocol": "3.0.0-alpha.
|
|
67
|
+
"@drakkar.software/starfish-protocol": "3.0.0-alpha.36"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@legendapp/state": "^2.0.0",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"react": "^19.2.4",
|
|
79
79
|
"react-dom": "^19.2.4",
|
|
80
80
|
"typescript": "^5.5.0",
|
|
81
|
-
"vitest": "^3.
|
|
81
|
+
"vitest": "^3.2.6",
|
|
82
82
|
"zustand": "^5.0.11"
|
|
83
83
|
},
|
|
84
84
|
"files": [
|