@procedures/collections 0.7.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 +11 -0
- package/README.md +10 -28
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @procedures/collections
|
|
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
|
+
|
|
3
14
|
## 0.7.0
|
|
4
15
|
|
|
5
16
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -147,7 +147,7 @@ describeCollectionStorageContract(
|
|
|
147
147
|
|---|---|---|
|
|
148
148
|
| `InMemoryStorage` | `@procedures/collections` | It copies with `structuredClone`. The run with `copies: false` skips only the case of the copies. |
|
|
149
149
|
| `SqliteStorage` (each engine, in memory and in a file) | `@procedures/sqlite` | It keeps JSON text, so it gives copies. |
|
|
150
|
-
| `ApiStorage` | `@procedures/store` | It reads `{ found, value }` from the procedure `get`, so a stored `null` stays `null`.
|
|
150
|
+
| `ApiStorage` | `@procedures/store` | It reads `{ found, value }` from the procedure `get`, so a stored `null` stays `null`. Its `getIds` uses the procedure `ids`. |
|
|
151
151
|
| `HybridStorage` (each mode, and a queue in IndexedDB) | `@procedures/store` | It has no `getChangesSince`. |
|
|
152
152
|
|
|
153
153
|
## Storage Backends
|
|
@@ -169,40 +169,22 @@ const user = await storage.get("user-1");
|
|
|
169
169
|
- `getIds()` gives the ids without a copy of the values.
|
|
170
170
|
- `close()` drops the items. After it, each operation rejects, and the methods of the `Map` interface (`keys()`, `values()`, `entries()`, `forEach()`) throw.
|
|
171
171
|
|
|
172
|
-
### ApiStorage
|
|
172
|
+
### ApiStorage and HybridStorage
|
|
173
173
|
|
|
174
|
-
|
|
174
|
+
These two storages need a `Client`, so they are in [`@procedures/store`](../client-store/README.md), not in this package.
|
|
175
175
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
import { Client } from "@procedures/client";
|
|
179
|
-
|
|
180
|
-
const client = new Client({ transport });
|
|
181
|
-
const storage = new ApiStorage<User>(client, {
|
|
182
|
-
collection: "users",
|
|
183
|
-
endpoints: {
|
|
184
|
-
get: { service: "users", operation: "get" },
|
|
185
|
-
set: { service: "users", operation: "set" },
|
|
186
|
-
// ... other endpoints
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
### HybridStorage
|
|
192
|
-
|
|
193
|
-
Local cache with remote synchronization:
|
|
176
|
+
- `ApiStorage` sends each operation to the collection procedures of a server: `collections.<collection>.<operation>`. The server registers them with `createCollectionProcedures(collection)`.
|
|
177
|
+
- `HybridStorage` keeps a local copy of a remote storage. It has four modes: `local-only`, `write-through`, `write-back` and `remote-only`. `setMode()` changes the mode while the storage operates.
|
|
194
178
|
|
|
195
179
|
```typescript
|
|
196
|
-
import {
|
|
180
|
+
import { ApiStorage, HybridStorage } from "@procedures/store";
|
|
197
181
|
|
|
198
|
-
const
|
|
199
|
-
|
|
200
|
-
remote: apiStorage,
|
|
201
|
-
syncStrategy: "write-through", // or "write-behind"
|
|
202
|
-
conflictResolver: (local, remote) => remote.updatedAt > local.updatedAt ? remote : local
|
|
203
|
-
});
|
|
182
|
+
const remote = new ApiStorage<User>(client, { collection: "users" });
|
|
183
|
+
const users = new HybridStorage<User>(remote, { mode: "write-through", conflictResolution: "remote" });
|
|
204
184
|
```
|
|
205
185
|
|
|
186
|
+
The README of `@procedures/store` gives the options, the queue of `write-back`, the conflict rules and the contract of the two storages.
|
|
187
|
+
|
|
206
188
|
## Collection Implementations
|
|
207
189
|
|
|
208
190
|
### Lists
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "@procedures/collections",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.8.0",
|
|
5
5
|
"description": "Collections for TypeScript: ArrayList, LinkedList, ArrayDeque, HashMap, LinkedHashMap, TreeMap (red-black), PriorityQueue, LRU and TTL maps, async queues, channels and collectors, tested with fast-check.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"collections",
|