@procedures/collections 0.47.1 → 0.48.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 +32 -8
- package/README.md +3 -1
- package/dist/.tsbuildinfo +1 -1
- package/dist/index.d.ts +1 -59
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -95
- package/dist/index.js.map +1 -1
- package/dist/storage/index.d.ts +2 -2
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +1 -1
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/memory.d.ts +1 -1
- package/dist/storage/memory.d.ts.map +1 -1
- package/dist/storage/memory.js +1 -1
- package/dist/storage/memory.js.map +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +1 -1
- package/dist/testing/index.js.map +1 -1
- package/dist/testing/storage-contract.js +1 -1
- package/dist/testing/storage-contract.js.map +1 -1
- package/dist/undo/index.d.ts +1 -1
- package/dist/undo/index.js +1 -1
- package/dist/undo/undo-log.d.ts +1 -1
- package/dist/undo/undo-log.js +1 -1
- package/package.json +5 -5
- package/src/index.ts +338 -214
- package/src/storage/index.ts +2 -2
- package/src/storage/memory.ts +1 -1
- package/src/testing/index.ts +1 -1
- package/src/testing/storage-contract.ts +1 -1
- package/src/undo/index.ts +1 -1
- package/src/undo/undo-log.ts +1 -1
- package/dist/async/async-queue.d.ts +0 -170
- package/dist/async/async-queue.d.ts.map +0 -1
- package/dist/async/async-queue.js +0 -404
- package/dist/async/async-queue.js.map +0 -1
- package/dist/async/channels.d.ts +0 -211
- package/dist/async/channels.d.ts.map +0 -1
- package/dist/async/channels.js +0 -393
- package/dist/async/channels.js.map +0 -1
- package/dist/async/settled.d.ts +0 -23
- package/dist/async/settled.d.ts.map +0 -1
- package/dist/async/settled.js +0 -32
- package/dist/async/settled.js.map +0 -1
- package/dist/behaviors/bounded.d.ts +0 -79
- package/dist/behaviors/bounded.d.ts.map +0 -1
- package/dist/behaviors/bounded.js +0 -393
- package/dist/behaviors/bounded.js.map +0 -1
- package/dist/behaviors/composite.d.ts +0 -17
- package/dist/behaviors/composite.d.ts.map +0 -1
- package/dist/behaviors/composite.js +0 -93
- package/dist/behaviors/composite.js.map +0 -1
- package/dist/behaviors/evented.d.ts +0 -154
- package/dist/behaviors/evented.d.ts.map +0 -1
- package/dist/behaviors/evented.js +0 -299
- package/dist/behaviors/evented.js.map +0 -1
- package/dist/behaviors/lru.d.ts +0 -84
- package/dist/behaviors/lru.d.ts.map +0 -1
- package/dist/behaviors/lru.js +0 -376
- package/dist/behaviors/lru.js.map +0 -1
- package/dist/behaviors/readonly.d.ts +0 -73
- package/dist/behaviors/readonly.d.ts.map +0 -1
- package/dist/behaviors/readonly.js +0 -189
- package/dist/behaviors/readonly.js.map +0 -1
- package/dist/behaviors/safe.d.ts +0 -163
- package/dist/behaviors/safe.d.ts.map +0 -1
- package/dist/behaviors/safe.js +0 -176
- package/dist/behaviors/safe.js.map +0 -1
- package/dist/behaviors/synchronized.d.ts +0 -88
- package/dist/behaviors/synchronized.d.ts.map +0 -1
- package/dist/behaviors/synchronized.js +0 -285
- package/dist/behaviors/synchronized.js.map +0 -1
- package/dist/behaviors/ttl.d.ts +0 -118
- package/dist/behaviors/ttl.d.ts.map +0 -1
- package/dist/behaviors/ttl.js +0 -354
- package/dist/behaviors/ttl.js.map +0 -1
- package/dist/contracts/model.d.ts +0 -29
- package/dist/contracts/model.d.ts.map +0 -1
- package/dist/contracts/model.js +0 -26
- package/dist/contracts/model.js.map +0 -1
- package/dist/core/effects.d.ts +0 -176
- package/dist/core/effects.d.ts.map +0 -1
- package/dist/core/effects.js +0 -180
- package/dist/core/effects.js.map +0 -1
- package/dist/core/events.d.ts +0 -192
- package/dist/core/events.d.ts.map +0 -1
- package/dist/core/events.js +0 -291
- package/dist/core/events.js.map +0 -1
- package/dist/core/middleware.d.ts +0 -231
- package/dist/core/middleware.d.ts.map +0 -1
- package/dist/core/middleware.js +0 -161
- package/dist/core/middleware.js.map +0 -1
- package/dist/core/policies.d.ts +0 -220
- package/dist/core/policies.d.ts.map +0 -1
- package/dist/core/policies.js +0 -48
- package/dist/core/policies.js.map +0 -1
- package/dist/core/traits.d.ts +0 -142
- package/dist/core/traits.d.ts.map +0 -1
- package/dist/core/traits.js +0 -8
- package/dist/core/traits.js.map +0 -1
- package/dist/fx/collectors.d.ts +0 -193
- package/dist/fx/collectors.d.ts.map +0 -1
- package/dist/fx/collectors.js +0 -375
- package/dist/fx/collectors.js.map +0 -1
- package/dist/fx/iter.d.ts +0 -166
- package/dist/fx/iter.d.ts.map +0 -1
- package/dist/fx/iter.js +0 -421
- package/dist/fx/iter.js.map +0 -1
- package/dist/impl/array-deque.d.ts +0 -112
- package/dist/impl/array-deque.d.ts.map +0 -1
- package/dist/impl/array-deque.js +0 -380
- package/dist/impl/array-deque.js.map +0 -1
- package/dist/impl/array-list.d.ts +0 -101
- package/dist/impl/array-list.d.ts.map +0 -1
- package/dist/impl/array-list.js +0 -387
- package/dist/impl/array-list.js.map +0 -1
- package/dist/impl/hash-map.d.ts +0 -149
- package/dist/impl/hash-map.d.ts.map +0 -1
- package/dist/impl/hash-map.js +0 -473
- package/dist/impl/hash-map.js.map +0 -1
- package/dist/impl/hash-set.d.ts +0 -125
- package/dist/impl/hash-set.d.ts.map +0 -1
- package/dist/impl/hash-set.js +0 -264
- package/dist/impl/hash-set.js.map +0 -1
- package/dist/impl/linked-hash-map.d.ts +0 -141
- package/dist/impl/linked-hash-map.d.ts.map +0 -1
- package/dist/impl/linked-hash-map.js +0 -442
- package/dist/impl/linked-hash-map.js.map +0 -1
- package/dist/impl/linked-list.d.ts +0 -109
- package/dist/impl/linked-list.d.ts.map +0 -1
- package/dist/impl/linked-list.js +0 -494
- package/dist/impl/linked-list.js.map +0 -1
- package/dist/impl/priority-queue.d.ts +0 -139
- package/dist/impl/priority-queue.d.ts.map +0 -1
- package/dist/impl/priority-queue.js +0 -343
- package/dist/impl/priority-queue.js.map +0 -1
- package/dist/impl/summary-tree.d.ts +0 -146
- package/dist/impl/summary-tree.d.ts.map +0 -1
- package/dist/impl/summary-tree.js +0 -524
- package/dist/impl/summary-tree.js.map +0 -1
- package/dist/impl/tree-map.d.ts +0 -153
- package/dist/impl/tree-map.d.ts.map +0 -1
- package/dist/impl/tree-map.js +0 -788
- package/dist/impl/tree-map.js.map +0 -1
- package/dist/impl/tree-set.d.ts +0 -112
- package/dist/impl/tree-set.d.ts.map +0 -1
- package/dist/impl/tree-set.js +0 -374
- package/dist/impl/tree-set.js.map +0 -1
- package/dist/interfaces/collection.d.ts +0 -119
- package/dist/interfaces/collection.d.ts.map +0 -1
- package/dist/interfaces/collection.js +0 -8
- package/dist/interfaces/collection.js.map +0 -1
- package/dist/interfaces/list.d.ts +0 -247
- package/dist/interfaces/list.d.ts.map +0 -1
- package/dist/interfaces/list.js +0 -8
- package/dist/interfaces/list.js.map +0 -1
- package/dist/interfaces/map.d.ts +0 -344
- package/dist/interfaces/map.d.ts.map +0 -1
- package/dist/interfaces/map.js +0 -8
- package/dist/interfaces/map.js.map +0 -1
- package/dist/interfaces/queue.d.ts +0 -304
- package/dist/interfaces/queue.d.ts.map +0 -1
- package/dist/interfaces/queue.js +0 -8
- package/dist/interfaces/queue.js.map +0 -1
- package/dist/interfaces/set.d.ts +0 -137
- package/dist/interfaces/set.d.ts.map +0 -1
- package/dist/interfaces/set.js +0 -8
- package/dist/interfaces/set.js.map +0 -1
- package/dist/order/index.d.ts +0 -7
- package/dist/order/index.d.ts.map +0 -1
- package/dist/order/index.js +0 -7
- package/dist/order/index.js.map +0 -1
- package/dist/order/rank.d.ts +0 -100
- package/dist/order/rank.d.ts.map +0 -1
- package/dist/order/rank.js +0 -286
- package/dist/order/rank.js.map +0 -1
- package/dist/storage/listeners.d.ts +0 -39
- package/dist/storage/listeners.d.ts.map +0 -1
- package/dist/storage/listeners.js +0 -65
- package/dist/storage/listeners.js.map +0 -1
- package/dist/testing/check.d.ts +0 -25
- package/dist/testing/check.d.ts.map +0 -1
- package/dist/testing/check.js +0 -85
- package/dist/testing/check.js.map +0 -1
- package/dist/utils/defaults.d.ts +0 -135
- package/dist/utils/defaults.d.ts.map +0 -1
- package/dist/utils/defaults.js +0 -322
- package/dist/utils/defaults.js.map +0 -1
- package/dist/utils/factories.d.ts +0 -144
- package/dist/utils/factories.d.ts.map +0 -1
- package/dist/utils/factories.js +0 -293
- package/dist/utils/factories.js.map +0 -1
- package/dist/utils/helpers.d.ts +0 -137
- package/dist/utils/helpers.d.ts.map +0 -1
- package/dist/utils/helpers.js +0 -221
- package/dist/utils/helpers.js.map +0 -1
- package/src/async/async-queue.ts +0 -481
- package/src/async/channels.ts +0 -450
- package/src/async/settled.ts +0 -41
- package/src/behaviors/bounded.ts +0 -485
- package/src/behaviors/composite.ts +0 -99
- package/src/behaviors/evented.ts +0 -464
- package/src/behaviors/lru.ts +0 -447
- package/src/behaviors/readonly.ts +0 -236
- package/src/behaviors/safe.ts +0 -372
- package/src/behaviors/synchronized.ts +0 -316
- package/src/behaviors/ttl.ts +0 -462
- package/src/contracts/model.ts +0 -44
- package/src/core/effects.ts +0 -323
- package/src/core/events.ts +0 -356
- package/src/core/middleware.ts +0 -415
- package/src/core/policies.ts +0 -316
- package/src/core/traits.ts +0 -164
- package/src/fx/collectors.ts +0 -500
- package/src/fx/iter.ts +0 -536
- package/src/impl/array-deque.ts +0 -463
- package/src/impl/array-list.ts +0 -490
- package/src/impl/hash-map.ts +0 -623
- package/src/impl/hash-set.ts +0 -342
- package/src/impl/linked-hash-map.ts +0 -572
- package/src/impl/linked-list.ts +0 -606
- package/src/impl/priority-queue.ts +0 -448
- package/src/impl/summary-tree.ts +0 -586
- package/src/impl/tree-map.ts +0 -912
- package/src/impl/tree-set.ts +0 -469
- package/src/interfaces/collection.ts +0 -141
- package/src/interfaces/list.ts +0 -281
- package/src/interfaces/map.ts +0 -405
- package/src/interfaces/queue.ts +0 -353
- package/src/interfaces/set.ts +0 -158
- package/src/order/index.ts +0 -6
- package/src/order/rank.ts +0 -271
- package/src/storage/listeners.ts +0 -72
- package/src/testing/check.ts +0 -81
- package/src/utils/defaults.ts +0 -345
- package/src/utils/factories.ts +0 -357
- package/src/utils/helpers.ts +0 -248
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @procedures/collections
|
|
2
2
|
|
|
3
|
+
## 0.48.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- c839add: The release train: the ranges of @mark1russell7/coeval, @mark1russell7/quantity, @mark1russell7/collections, @mark1russell7/cue change to a version outside the old range.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [17a18ec]
|
|
12
|
+
- Updated dependencies [06088f9]
|
|
13
|
+
- Updated dependencies [71f9c6e]
|
|
14
|
+
- Updated dependencies [c839add]
|
|
15
|
+
- @procedures/client@0.48.0
|
|
16
|
+
|
|
17
|
+
## 0.47.2
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- 2684531: The pure collection and graph code moved to `@mark1russell7/collections`. Both packages re-export the same names, and the signatures stay the same.
|
|
22
|
+
- Updated dependencies [0650616]
|
|
23
|
+
- Updated dependencies [ae1e3fd]
|
|
24
|
+
- Updated dependencies [f1ece74]
|
|
25
|
+
- @procedures/client@0.47.2
|
|
26
|
+
|
|
3
27
|
## 0.47.1
|
|
4
28
|
|
|
5
29
|
### Patch Changes
|
|
@@ -430,9 +454,9 @@
|
|
|
430
454
|
Migration:
|
|
431
455
|
|
|
432
456
|
- **Site.** No change. The site does not write collections.
|
|
433
|
-
- **
|
|
434
|
-
- **
|
|
435
|
-
- **
|
|
457
|
+
- **An app with `HybridStorage`.** No change for a storage or a `HybridStorage` without `versionOf`. A `HybridStorage` with `versionOf` over `ApiStorage` needs a server storage with the same `versionOf` (for example `new InMemoryStorage({ versionOf })`), or the option `sendBaseVersions: false`.
|
|
458
|
+
- **An app with last-write-wins.** It gives no expected version, so nothing changes. Its own storage must refuse a write with an expected version until it tests one. Add the guard to its `set`, `delete` and `setBatch`, and run the contract suite: its first case tests the refusal. To adopt the version later, stamp a version field on the server, give the storage a `versionOf` that tests it in the write, and give the same `versionOf` to the `HybridStorage` of the client. Then add `createWithVersions` to the contract run.
|
|
459
|
+
- **An app without versions.** No change: it gives no expected version. A storage of the app that implements `CollectionStorage` must refuse a write with an expected version, as above.
|
|
436
460
|
- **Other storages.** Each class that implements `CollectionStorage` reads the new options of `set`, `delete` and `setBatch`. It tests them in the write, or it rejects the write with `preconditionNotSupported()`. It never ignores them.
|
|
437
461
|
|
|
438
462
|
### Patch Changes
|
|
@@ -466,8 +490,8 @@
|
|
|
466
490
|
|
|
467
491
|
### Patch Changes
|
|
468
492
|
|
|
469
|
-
- 3a235b9: New: the patch operations `$remove` and `$insert
|
|
470
|
-
- 50d4818: New: `inversePatch` and `UndoLog
|
|
493
|
+
- 3a235b9: New: the patch operations `$remove` and `$insert`. `$remove` takes an element out of an array, and the next elements move down by one, as the operation `remove` of JSON Patch (RFC 6902). For a field of an object, it is the same as `$unset`. `$insert` adds an element to an array at an index, as the operation `add` of JSON Patch. Each index of one patch refers to the item before the patch. A patch that removes and inserts elements of the same array is refused, and so is an `$insert` past the end of an array. `$unset` keeps the rule of MongoDB: an element of an array becomes `null`. The storage contract has a case for the two operations, so each storage gets them through `applyPatch`.
|
|
494
|
+
- 50d4818: New: `inversePatch` and `UndoLog`. `inversePatch(before, patch)` gives the patch that undoes a patch. The inverse of a removal of an element is an insertion, and the inverse of an insertion is a removal, so an undo does not keep the whole array. The function applies the inverse to check it, and gives `undefined` when no patch undoes the change exactly. `UndoLog` keeps the undo of each change in a collection storage, with a cap, and the fingerprint of the item after the change (`fingerprintOf`). `undo()` undoes the newest change and the other changes of its group. It reads each item first, and refuses the whole group with an `UndoConflictError` when another writer changed an item. Then each item gets one write.
|
|
471
495
|
- Updated dependencies [3a235b9]
|
|
472
496
|
- @procedures/client@0.13.2
|
|
473
497
|
|
|
@@ -488,7 +512,7 @@
|
|
|
488
512
|
|
|
489
513
|
### Patch Changes
|
|
490
514
|
|
|
491
|
-
- b6782c0: New: the order of a list as data
|
|
515
|
+
- b6782c0: New: the order of a list as data. `keyBetween(prev, next)` gives a string key between two neighbors, so a move writes one item and no other. The keys use fractional indexing with 62 digits: they do not run out, and the list needs no rebalance. `keysForDrop` gives all the writes of a move, also when two writers gave two items the same key. `keysBetween` gives several keys, `compareKeys` sorts them, `isValidKey` examines a key that a client writes, and `dropIndex(point, centers)` gives the index of a point among the items on the screen, in reading order.
|
|
492
516
|
- @procedures/client@0.12.2
|
|
493
517
|
|
|
494
518
|
## 0.12.1
|
|
@@ -540,7 +564,7 @@
|
|
|
540
564
|
|
|
541
565
|
- 0dd1c86: The overlay: one logical document read through a stack of layers. `mergeCopies` merges the copies field by field (`UNSET` hides a field, `_deleted` hides the document) or takes the top copy whole. `copyAsPatch` gives a copy as the patch operations of `applyPatch`.
|
|
542
566
|
|
|
543
|
-
`resolveStacks` and `stackOf` give the read stack, the write targets and the merge mode of each collection and document. The rules name the layers with variables, and the app resolves them. Each change is additive.
|
|
567
|
+
`resolveStacks` and `stackOf` give the read stack, the write targets and the merge mode of each collection and document. The rules name the layers with variables, and the app resolves them. Each change is additive.
|
|
544
568
|
- Updated dependencies [8bb469c]
|
|
545
569
|
- Updated dependencies [dc03903]
|
|
546
570
|
- Updated dependencies [dca28c1]
|
|
@@ -590,7 +614,7 @@
|
|
|
590
614
|
|
|
591
615
|
### Minor Changes
|
|
592
616
|
|
|
593
|
-
- 5837c2d: `asSettled(promises)` gives the result of each promise when it settles, in settle order, with the index of its promise. A rejection is a result, not an error.
|
|
617
|
+
- 5837c2d: `asSettled(promises)` gives the result of each promise when it settles, in settle order, with the index of its promise. A rejection is a result, not an error. An app used the same `Promise.race` loop in two places.
|
|
594
618
|
|
|
595
619
|
## 0.6.0
|
|
596
620
|
|
package/README.md
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
A comprehensive, transport-agnostic collections framework for TypeScript. Provides unified abstractions for data structures with pluggable storage backends, enabling seamless switching between local and remote storage.
|
|
6
6
|
|
|
7
|
+
The pure data structures and graphs are in the general package [`@mark1russell7/collections`](https://www.npmjs.com/package/@mark1russell7/collections), which has no runtime dependencies. This package re-exports them and adds storage, overlay and undo.
|
|
8
|
+
|
|
7
9
|
## Architecture Overview
|
|
8
10
|
|
|
9
11
|
```
|
|
@@ -358,7 +360,7 @@ const user = await storage.get("user-1");
|
|
|
358
360
|
These two storages need a `Client`, so they are in [`@procedures/store`](../client-store/README.md), not in this package.
|
|
359
361
|
|
|
360
362
|
- `ApiStorage` sends each operation to the collection procedures of a server: `collections.<collection>.<operation>`. The server registers them with `createCollectionProcedures(collection)`.
|
|
361
|
-
- `HybridStorage` keeps a local copy of a remote storage. It has
|
|
363
|
+
- `HybridStorage` keeps a local copy of a remote storage. It has five modes: `local-only`, `write-through`, `write-back`, `remote-only` and `read-only`. `setMode()` changes the mode while the storage operates.
|
|
362
364
|
|
|
363
365
|
```typescript
|
|
364
366
|
import { ApiStorage, HybridStorage } from "@procedures/store";
|