@procedures/store 0.47.2 → 0.48.1

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.
Files changed (41) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +6 -3
  3. package/dist/.tsbuildinfo +1 -1
  4. package/dist/browser.d.ts +1 -1
  5. package/dist/browser.d.ts.map +1 -1
  6. package/dist/browser.js +1 -1
  7. package/dist/browser.js.map +1 -1
  8. package/dist/indexeddb/document-storage.d.ts.map +1 -1
  9. package/dist/indexeddb/document-storage.js.map +1 -1
  10. package/dist/indexeddb/idb.d.ts +2 -12
  11. package/dist/indexeddb/idb.d.ts.map +1 -1
  12. package/dist/indexeddb/idb.js +7 -12
  13. package/dist/indexeddb/idb.js.map +1 -1
  14. package/dist/program-store/collection.d.ts.map +1 -1
  15. package/dist/program-store/collection.js.map +1 -1
  16. package/dist/program-store/file.d.ts.map +1 -1
  17. package/dist/program-store/file.js.map +1 -1
  18. package/dist/storage/factory.d.ts +1 -1
  19. package/dist/storage/file-queue.d.ts.map +1 -1
  20. package/dist/storage/file-queue.js.map +1 -1
  21. package/dist/storage/hybrid.d.ts +26 -10
  22. package/dist/storage/hybrid.d.ts.map +1 -1
  23. package/dist/storage/hybrid.js +41 -19
  24. package/dist/storage/hybrid.js.map +1 -1
  25. package/dist/storage/index.d.ts +1 -1
  26. package/dist/storage/index.d.ts.map +1 -1
  27. package/dist/storage/index.js +1 -1
  28. package/dist/storage/index.js.map +1 -1
  29. package/dist/storage/types.d.ts +1 -1
  30. package/dist/storage/types.d.ts.map +1 -1
  31. package/package.json +5 -5
  32. package/src/browser.ts +1 -0
  33. package/src/indexeddb/document-storage.ts +18 -6
  34. package/src/indexeddb/idb.ts +27 -12
  35. package/src/program-store/collection.ts +5 -1
  36. package/src/program-store/file.ts +5 -1
  37. package/src/storage/factory.ts +1 -1
  38. package/src/storage/file-queue.ts +5 -1
  39. package/src/storage/hybrid.ts +84 -31
  40. package/src/storage/index.ts +1 -0
  41. package/src/storage/types.ts +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # @procedures/store
2
2
 
3
+ ## 0.48.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [2d7edae]
8
+ - @procedures/client@0.48.1
9
+ - @procedures/collections@0.48.1
10
+
11
+ ## 0.48.0
12
+
13
+ ### Patch Changes
14
+
15
+ - 17a18ec: The source now uses only syntax that a type stripper erases, so the setting `erasableSyntaxOnly` of `@mark1russell7/cue` 2.1.1 stays on. Each enum is now a constant object with a type of the same name. Each parameter property is now a field and an assignment in the constructor.
16
+
17
+ **Breaking.** MINOR before 1.0.0: `ErrorCategory`, `ErrorSeverity` and `WebSocketState` are now constant objects. Their names and values stay the same, and each member stays usable as a type. A member is no longer a constant expression: `enum E { A = ErrorSeverity.WARNING }` gives TS18033, and a `const enum` gives TS2474. Also, a string with the value of a member now fits the type of the set.
18
+
19
+ **Migration.** In an enum initializer, write the value in place of the member, for example `"warning"`, or use a constant object. Other uses need no change. The site and the known apps need no change.
20
+ - c529a36: `HybridStorage` has a new mode `read-only`. It refuses each write with `ReadOnlyError` at once, with no change of the local copy, the queue or the remote. Reads, pulls and the feed work as in `write-through`. `HybridMode` has a new value, so an exhaustive `switch` on it needs a new case.
21
+ - Updated dependencies [17a18ec]
22
+ - Updated dependencies [06088f9]
23
+ - Updated dependencies [71f9c6e]
24
+ - Updated dependencies [c839add]
25
+ - @procedures/client@0.48.0
26
+ - @procedures/collections@0.48.0
27
+
3
28
  ## 0.47.2
4
29
 
5
30
  ### Patch Changes
package/README.md CHANGED
@@ -205,7 +205,7 @@ const users = new HybridStorage(new ApiStorage(client, { collection: "users" }),
205
205
 
206
206
  ## The modes of `HybridStorage`
207
207
 
208
- `HybridStorage` keeps a local copy of a remote collection storage. It has four modes, and `setMode()` changes the mode while the storage operates.
208
+ `HybridStorage` keeps a local copy of a remote collection storage. It has five modes, and `setMode()` changes the mode while the storage operates.
209
209
 
210
210
  | Mode | Reads | Writes | Remote calls |
211
211
  |---|---|---|---|
@@ -213,6 +213,7 @@ const users = new HybridStorage(new ApiStorage(client, { collection: "users" }),
213
213
  | `write-through` | The local copy, and the remote on a miss | The local copy, then the remote | Yes |
214
214
  | `write-back` | The local copy, and the remote on a miss | The local copy and the queue. A timer sends the queue. | Yes |
215
215
  | `remote-only` | The remote | The remote | Yes. The storage keeps no local copy. |
216
+ | `read-only` | The local copy, and the remote on a miss | Refused with `ReadOnlyError` | Reads and pulls only |
216
217
 
217
218
  ```ts
218
219
  import { minutes } from "@procedures/client";
@@ -245,6 +246,8 @@ await users.setMode("write-through"); // The switch sends the queue, then syncs
245
246
  - In the modes `local-only` and `write-back`, each write goes in the queue.
246
247
  - In the mode `write-through`, a write that the remote cannot take goes in the queue, and the write throws `PendingWriteError`.
247
248
  - By default, a write that the remote cannot take is an error with `retryable: true`, an error without a `code`, or a `TIMEOUT`. The option `isUnavailable` changes it.
249
+ - The mode `read-only` refuses each write with `ReadOnlyError` at once. The local copy, the queue and the remote do not change.
250
+ - A switch to `read-only` sends the queue first, and a failed send keeps the old mode. A queue that a store loads or that `capture` adds in this mode waits for a mode that writes.
248
251
  - A full queue refuses the next write with `QueueFullError`. The limit is `maxOfflineOps`, 1000 by default.
249
252
  - A push keeps a write that the remote cannot take at this time (`isUnavailable` gives true). This write and the later writes stay in the queue.
250
253
  - A queued write that the remote refuses leaves the queue, and the push goes on with the next write.
@@ -293,7 +296,7 @@ const users = new HybridStorage(new ApiStorage(client, { collection: "users" }),
293
296
  - A pull reads a local item only when the result depends on it. A pull does not read the item of a queued write that wins.
294
297
  - With versions, the storage knows the version of each local item that it wrote or read. Then a pull reads a local item only for a conflict, or when the version is not known.
295
298
  - Without versions, a pull reads each local item without a queued write. It compares the JSON of the local item and the remote item.
296
- - The option `pullInterval` starts a periodic pull in the modes `write-through` and `write-back`. `close()` stops it.
299
+ - The option `pullInterval` starts a periodic pull in the modes `write-through`, `write-back` and `read-only`. `close()` stops it.
297
300
 
298
301
  ### The base versions on the server
299
302
 
@@ -356,7 +359,7 @@ const stop = users.onStatus((status) => {
356
359
  - The option `syncState` keeps the cursor and the base versions. A new storage with the same store asks only for the changes since the cursor.
357
360
  - `MemorySyncStateStore` keeps the state in memory. `IndexedDbSyncStateStore` of `@procedures/store/indexeddb` keeps it in a browser.
358
361
  - The storage uses a loaded cursor only with the option `local` and a local copy that has items. Give the state store with a durable local copy.
359
- - The option `feed` takes a push feed of the remote changes, for example `EventsChangeFeed`. The storage subscribes in the modes `write-through` and `write-back`.
362
+ - The option `feed` takes a push feed of the remote changes, for example `EventsChangeFeed`. The storage subscribes in the modes `write-through`, `read-only` and `write-back`.
360
363
  - A delta whose `since` is the cursor of the storage applies without a read of the remote.
361
364
  - A gap, a lost event, a new subscription or another delta makes the storage pull the changes since its cursor.
362
365
  - A delta that comes during a pull applies after the pull. Thus a pull does not erase a change that came during it.