@procedures/store 0.6.0 → 0.8.0
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/CHANGELOG.md +40 -0
- package/README.md +10 -1
- package/dist/.tsbuildinfo +1 -1
- package/dist/storage/api.d.ts +10 -0
- package/dist/storage/api.d.ts.map +1 -1
- package/dist/storage/api.js +30 -0
- package/dist/storage/api.js.map +1 -1
- package/dist/storage/file-queue.d.ts.map +1 -1
- package/dist/storage/file-queue.js +2 -1
- package/dist/storage/file-queue.js.map +1 -1
- package/dist/storage/hybrid.d.ts +50 -2
- package/dist/storage/hybrid.d.ts.map +1 -1
- package/dist/storage/hybrid.js +146 -26
- package/dist/storage/hybrid.js.map +1 -1
- package/package.json +3 -3
- package/src/storage/api.ts +31 -0
- package/src/storage/file-queue.ts +2 -1
- package/src/storage/hybrid.ts +156 -26
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,45 @@
|
|
|
1
1
|
# @procedures/store
|
|
2
2
|
|
|
3
|
+
## 0.8.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- aa6e3aa: `ApiStorage` has `getIds()`. A full pull through it does not read each entry for the ids.
|
|
8
|
+
|
|
9
|
+
- The collections have the procedure `collections.<name>.ids`. It gives the ids in the order of the entries, without the values. Its effects read the collection and write nothing. A storage without `getIds()` gives the ids of its entries.
|
|
10
|
+
- The `CollectionStorage` of the core has the optional method `getIds()`, as the `CollectionStorage` of `@procedures/collections` has.
|
|
11
|
+
- `ApiStorage.getIds()` uses the procedure `ids`. An older server without it answers `NOT_FOUND`. Then the storage reads the ids from the entries, and it does not ask for `ids` again.
|
|
12
|
+
- `ApiStorageOptions.operations` takes `ids`, the name of the operation. The default is `ids`.
|
|
13
|
+
- 9380ba0: `FileQueueStore.load` names the right line in its "not JSON (line N)" error when blank lines come before the bad line. Before, it counted the lines after it had removed the blank ones.
|
|
14
|
+
- 276b93c: A pull of `HybridStorage` reads a local item only when the result depends on it. Before, the pull read each local item. The results do not change.
|
|
15
|
+
|
|
16
|
+
- A pull does not read the item of a queued write that wins: without versions, or when the remote version did not change after the last sync.
|
|
17
|
+
- With `versionOf`, the storage keeps the version of each local item that it wrote or read. A pull then reads a local item only for a conflict, or when it does not know the version. A full pull of a collection without a change reads no local item.
|
|
18
|
+
- Without versions, a pull reads each local item without a queued write. It compares the JSON of the two items, as before.
|
|
19
|
+
- Only the storage writes to its local copy: with `versionOf`, a pull does not see a write from outside.
|
|
20
|
+
- Updated dependencies [4b09a03]
|
|
21
|
+
- Updated dependencies [4b09a03]
|
|
22
|
+
- Updated dependencies [aa6e3aa]
|
|
23
|
+
- Updated dependencies [698e24d]
|
|
24
|
+
- Updated dependencies [4b09a03]
|
|
25
|
+
- Updated dependencies [600c497]
|
|
26
|
+
- Updated dependencies [7c2e7f7]
|
|
27
|
+
- Updated dependencies [90ea741]
|
|
28
|
+
- Updated dependencies [c4cfa34]
|
|
29
|
+
- Updated dependencies [d25805a]
|
|
30
|
+
- @procedures/client@0.8.0
|
|
31
|
+
- @procedures/collections@0.8.0
|
|
32
|
+
|
|
33
|
+
## 0.7.0
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- Updated dependencies [5837c2d]
|
|
38
|
+
- Updated dependencies [841d083]
|
|
39
|
+
- Updated dependencies [389b054]
|
|
40
|
+
- @procedures/collections@0.7.0
|
|
41
|
+
- @procedures/client@0.7.0
|
|
42
|
+
|
|
3
43
|
## 0.6.0
|
|
4
44
|
|
|
5
45
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -88,13 +88,14 @@ The contract suite of `@procedures/collections/testing` tests `ApiStorage`, and
|
|
|
88
88
|
- **Copies.** A change of a written or a read value does not change the stored item. `HybridStorage` takes a copy of each written value for the local copy, the queue and the remote. The values that `ApiStorage` sends and reads go through the transport.
|
|
89
89
|
- **`null`.** A stored `null` reads back as `null`. `ApiStorage.get()` sends `{ id, found: true }` to the procedure `collections.<name>.get`. The procedure then gives `{ found, value }` in one call.
|
|
90
90
|
- **The order of a delta.** `getChangesSince()` follows the order of the last change of each id.
|
|
91
|
-
- **The ids.** `
|
|
91
|
+
- **The ids.** `getIds()` gives the ids in the order of the entries. `ApiStorage.getIds()` uses the procedure `collections.<name>.ids`, so the values stay on the server.
|
|
92
92
|
- **After `close()`.** Each operation rejects with an error whose message says "closed". A second `close()` does nothing.
|
|
93
93
|
|
|
94
94
|
Notes:
|
|
95
95
|
|
|
96
96
|
- A custom `service` or a custom `get` operation gets the input `{ id }`, as before. Its `null` reads back as `undefined`.
|
|
97
97
|
- A server before `found` ignores it and gives the item. Then a stored `null` reads back as `undefined`, as before.
|
|
98
|
+
- A server before the procedure `ids` answers `NOT_FOUND`. Then `ApiStorage.getIds()` reads the ids from the entries, and it does not ask for `ids` again.
|
|
98
99
|
- `HybridStorage.close()` waits for the operations, the switch and the syncs that run. Then it sends the queue, and it closes the remote and the local copy.
|
|
99
100
|
- `SyncedProcedureRegistry.close()` closes its storage. After it, `register()` and `unregister()` change only the registry in memory.
|
|
100
101
|
|
|
@@ -177,12 +178,20 @@ const users = new HybridStorage(new ApiStorage(client, { collection: "users" }),
|
|
|
177
178
|
- With versions, a conflict is a queued local write of an id whose remote version changed. The option `conflictResolution` gives the result.
|
|
178
179
|
- The values of `conflictResolution` are `local`, `remote`, `merge` with `mergeFn`, and `error`. With `error`, the sync throws `ConflictError`.
|
|
179
180
|
- Without versions, a queued write always wins. A local value that differs from the remote value is a conflict.
|
|
181
|
+
- 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.
|
|
182
|
+
- 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.
|
|
183
|
+
- Without versions, a pull reads each local item without a queued write. It compares the JSON of the local item and the remote item.
|
|
180
184
|
- The option `pullInterval` starts a periodic pull in the modes `write-through` and `write-back`. `close()` stops it.
|
|
181
185
|
|
|
182
186
|
### The change of a storage in a server
|
|
183
187
|
|
|
184
188
|
`ProcedureServer.useStorage(name, storage, { drain: true, close: true })` first starts `flush()` of the old storage. Then it uses the new storage and closes the old one. When the flush fails, the old storage stays.
|
|
185
189
|
|
|
190
|
+
- The new calls use the new storage at once.
|
|
191
|
+
- Before the close, the server waits for the calls that took the old storage. A stream holds its storage until its end.
|
|
192
|
+
- The option `grace` gives the longest wait, for example `seconds(5)`. The default is 30 seconds. A plain number is a `TypeError`.
|
|
193
|
+
- When the time ends, the server closes the old storage. A call that still uses it then fails with the error of a closed storage.
|
|
194
|
+
|
|
186
195
|
`ProcedureServer.stop()` closes each storage one time and removes the storages from the server. A closed storage rejects each operation. Before the server starts again, give it new storages with `useStorage()`.
|
|
187
196
|
|
|
188
197
|
### The mode of a synced registry
|