@optimystic/db-core 1.19.0 → 1.20.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.
- package/dist/src/cluster/structs.d.ts +41 -8
- package/dist/src/cluster/structs.d.ts.map +1 -1
- package/dist/src/cluster/structs.js +18 -7
- package/dist/src/cluster/structs.js.map +1 -1
- package/dist/src/collection/action.d.ts +29 -0
- package/dist/src/collection/action.d.ts.map +1 -1
- package/dist/src/collection/action.js +6 -0
- package/dist/src/collection/action.js.map +1 -1
- package/dist/src/collection/collection.d.ts +533 -120
- package/dist/src/collection/collection.d.ts.map +1 -1
- package/dist/src/collection/collection.js +974 -500
- package/dist/src/collection/collection.js.map +1 -1
- package/dist/src/collection/head-commit.d.ts +110 -0
- package/dist/src/collection/head-commit.d.ts.map +1 -0
- package/dist/src/collection/head-commit.js +65 -0
- package/dist/src/collection/head-commit.js.map +1 -0
- package/dist/src/collection/index.d.ts +2 -0
- package/dist/src/collection/index.d.ts.map +1 -1
- package/dist/src/collection/index.js +2 -0
- package/dist/src/collection/index.js.map +1 -1
- package/dist/src/collection/segments.d.ts +77 -0
- package/dist/src/collection/segments.d.ts.map +1 -0
- package/dist/src/collection/segments.js +110 -0
- package/dist/src/collection/segments.js.map +1 -0
- package/dist/src/collection/struct.d.ts +156 -1
- package/dist/src/collection/struct.d.ts.map +1 -1
- package/dist/src/collection/struct.js +70 -0
- package/dist/src/collection/struct.js.map +1 -1
- package/dist/src/collection/write-attempts.d.ts +245 -0
- package/dist/src/collection/write-attempts.d.ts.map +1 -0
- package/dist/src/collection/write-attempts.js +439 -0
- package/dist/src/collection/write-attempts.js.map +1 -0
- package/dist/src/collections/tree/struct.d.ts +100 -17
- package/dist/src/collections/tree/struct.d.ts.map +1 -1
- package/dist/src/collections/tree/struct.js +38 -7
- package/dist/src/collections/tree/struct.js.map +1 -1
- package/dist/src/collections/tree/tree.d.ts +17 -5
- package/dist/src/collections/tree/tree.d.ts.map +1 -1
- package/dist/src/collections/tree/tree.js +112 -26
- package/dist/src/collections/tree/tree.js.map +1 -1
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/network/i-repo.d.ts +3 -0
- package/dist/src/network/i-repo.d.ts.map +1 -1
- package/dist/src/network/index.d.ts +3 -0
- package/dist/src/network/index.d.ts.map +1 -1
- package/dist/src/network/index.js +3 -0
- package/dist/src/network/index.js.map +1 -1
- package/dist/src/network/promise-shortfall-error.d.ts +40 -0
- package/dist/src/network/promise-shortfall-error.d.ts.map +1 -0
- package/dist/src/network/promise-shortfall-error.js +67 -0
- package/dist/src/network/promise-shortfall-error.js.map +1 -0
- package/dist/src/network/refuse-solo.d.ts +8 -0
- package/dist/src/network/refuse-solo.d.ts.map +1 -0
- package/dist/src/network/refuse-solo.js +8 -0
- package/dist/src/network/refuse-solo.js.map +1 -0
- package/dist/src/network/stale-failure.d.ts +20 -3
- package/dist/src/network/stale-failure.d.ts.map +1 -1
- package/dist/src/network/stale-failure.js +24 -3
- package/dist/src/network/stale-failure.js.map +1 -1
- package/dist/src/network/struct.d.ts +148 -2
- package/dist/src/network/struct.d.ts.map +1 -1
- package/dist/src/network/struct.js.map +1 -1
- package/dist/src/network/validity-rejected-error.d.ts +28 -0
- package/dist/src/network/validity-rejected-error.d.ts.map +1 -0
- package/dist/src/network/validity-rejected-error.js +51 -0
- package/dist/src/network/validity-rejected-error.js.map +1 -0
- package/dist/src/offline/entry.d.ts +72 -0
- package/dist/src/offline/entry.d.ts.map +1 -0
- package/dist/src/offline/entry.js +73 -0
- package/dist/src/offline/entry.js.map +1 -0
- package/dist/src/offline/index.d.ts +5 -0
- package/dist/src/offline/index.d.ts.map +1 -0
- package/dist/src/offline/index.js +5 -0
- package/dist/src/offline/index.js.map +1 -0
- package/dist/src/offline/journal.d.ts +61 -0
- package/dist/src/offline/journal.d.ts.map +1 -0
- package/dist/src/offline/journal.js +2 -0
- package/dist/src/offline/journal.js.map +1 -0
- package/dist/src/offline/queue.d.ts +484 -0
- package/dist/src/offline/queue.d.ts.map +1 -0
- package/dist/src/offline/queue.js +1236 -0
- package/dist/src/offline/queue.js.map +1 -0
- package/dist/src/offline/reachability.d.ts +25 -0
- package/dist/src/offline/reachability.d.ts.map +1 -0
- package/dist/src/offline/reachability.js +13 -0
- package/dist/src/offline/reachability.js.map +1 -0
- package/dist/src/offline/status.d.ts +148 -0
- package/dist/src/offline/status.d.ts.map +1 -0
- package/dist/src/offline/status.js +63 -0
- package/dist/src/offline/status.js.map +1 -0
- package/dist/src/offline/wake.d.ts +30 -0
- package/dist/src/offline/wake.d.ts.map +1 -0
- package/dist/src/offline/wake.js +68 -0
- package/dist/src/offline/wake.js.map +1 -0
- package/dist/src/testing/test-transactor.d.ts +29 -0
- package/dist/src/testing/test-transactor.d.ts.map +1 -1
- package/dist/src/testing/test-transactor.js +50 -0
- package/dist/src/testing/test-transactor.js.map +1 -1
- package/dist/src/transaction/commit-failure-class.d.ts +103 -0
- package/dist/src/transaction/commit-failure-class.d.ts.map +1 -0
- package/dist/src/transaction/commit-failure-class.js +96 -0
- package/dist/src/transaction/commit-failure-class.js.map +1 -0
- package/dist/src/transaction/coordinator.d.ts +165 -41
- package/dist/src/transaction/coordinator.d.ts.map +1 -1
- package/dist/src/transaction/coordinator.js +605 -300
- package/dist/src/transaction/coordinator.js.map +1 -1
- package/dist/src/transaction/entry-commit.d.ts +139 -0
- package/dist/src/transaction/entry-commit.d.ts.map +1 -0
- package/dist/src/transaction/entry-commit.js +199 -0
- package/dist/src/transaction/entry-commit.js.map +1 -0
- package/dist/src/transaction/index.d.ts +4 -1
- package/dist/src/transaction/index.d.ts.map +1 -1
- package/dist/src/transaction/index.js +1 -0
- package/dist/src/transaction/index.js.map +1 -1
- package/dist/src/transaction/transaction.d.ts +20 -0
- package/dist/src/transaction/transaction.d.ts.map +1 -1
- package/dist/src/transaction/validator.d.ts +7 -0
- package/dist/src/transaction/validator.d.ts.map +1 -1
- package/dist/src/transaction/validator.js +21 -12
- package/dist/src/transaction/validator.js.map +1 -1
- package/dist/src/transactor/network-transactor.d.ts +1 -0
- package/dist/src/transactor/network-transactor.d.ts.map +1 -1
- package/dist/src/transactor/network-transactor.js +61 -28
- package/dist/src/transactor/network-transactor.js.map +1 -1
- package/dist/src/transactor/transactor-source.d.ts +22 -11
- package/dist/src/transactor/transactor-source.d.ts.map +1 -1
- package/dist/src/transactor/transactor-source.js +9 -13
- package/dist/src/transactor/transactor-source.js.map +1 -1
- package/dist/src/utility/visit-every.d.ts +14 -0
- package/dist/src/utility/visit-every.d.ts.map +1 -0
- package/dist/src/utility/visit-every.js +27 -0
- package/dist/src/utility/visit-every.js.map +1 -0
- package/package.json +1 -1
- package/src/cluster/structs.ts +42 -7
- package/src/collection/action.ts +34 -0
- package/src/collection/collection.ts +1048 -543
- package/src/collection/head-commit.ts +148 -0
- package/src/collection/index.ts +2 -0
- package/src/collection/segments.ts +149 -0
- package/src/collection/struct.ts +183 -1
- package/src/collection/write-attempts.ts +506 -0
- package/src/collections/tree/struct.ts +97 -17
- package/src/collections/tree/tree.ts +125 -29
- package/src/index.ts +2 -0
- package/src/network/i-repo.ts +3 -0
- package/src/network/index.ts +3 -0
- package/src/network/promise-shortfall-error.ts +69 -0
- package/src/network/refuse-solo.ts +7 -0
- package/src/network/stale-failure.ts +27 -4
- package/src/network/struct.ts +154 -2
- package/src/network/validity-rejected-error.ts +55 -0
- package/src/offline/entry.ts +127 -0
- package/src/offline/index.ts +4 -0
- package/src/offline/journal.ts +60 -0
- package/src/offline/queue.ts +1342 -0
- package/src/offline/reachability.ts +32 -0
- package/src/offline/status.ts +183 -0
- package/src/offline/wake.ts +67 -0
- package/src/testing/test-transactor.ts +53 -0
- package/src/transaction/commit-failure-class.ts +133 -0
- package/src/transaction/coordinator.ts +696 -349
- package/src/transaction/entry-commit.ts +285 -0
- package/src/transaction/index.ts +4 -0
- package/src/transaction/transaction.ts +21 -0
- package/src/transaction/validator.ts +22 -12
- package/src/transactor/network-transactor.ts +62 -28
- package/src/transactor/transactor-source.ts +29 -13
- package/src/utility/visit-every.ts +25 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { RepoMessage } from "../network/repo-protocol.js";
|
|
2
2
|
import type { CommitResult, PendResult } from "../network/struct.js";
|
|
3
|
+
import type { ValidityRejection } from "../transaction/transaction.js";
|
|
3
4
|
/**
|
|
4
5
|
* One member's vote on a cluster transaction, in either the promise or the commit map.
|
|
5
6
|
*
|
|
@@ -11,7 +12,12 @@ import type { CommitResult, PendResult } from "../network/struct.js";
|
|
|
11
12
|
export type Signature = {
|
|
12
13
|
type: 'approve';
|
|
13
14
|
signature: string;
|
|
14
|
-
}
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A plain reject, or an **expiry vote**. Never a validity vote: `validity` belongs to the other
|
|
18
|
+
* reject arm, so one vote cannot claim both a clock disagreement and a validity judgement.
|
|
19
|
+
*/
|
|
20
|
+
| {
|
|
15
21
|
type: 'reject';
|
|
16
22
|
signature: string;
|
|
17
23
|
rejectReason?: string;
|
|
@@ -23,6 +29,25 @@ export type Signature = {
|
|
|
23
29
|
* Still a `reject` in every count — the record really is dead for this member.
|
|
24
30
|
*/
|
|
25
31
|
expiredAt?: number;
|
|
32
|
+
validity?: never;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* A **validity vote**: the member re-checked the transaction and judged it wrong in a way that holds
|
|
36
|
+
* on every retry and at every honest validator (see {@link ValidityRejection} for which refusals
|
|
37
|
+
* qualify). `validity.computedHash` is the operations hash the member computed, when re-execution got
|
|
38
|
+
* that far. Signed like `expiredAt`, so a coordinator can tell "refused for good" from "try again"
|
|
39
|
+
* without reading `rejectReason`.
|
|
40
|
+
*
|
|
41
|
+
* Absent means "not known to be a validity judgement" — a stale revision, a reservation, a refusal the
|
|
42
|
+
* member could not judge, or a member on a build that predates the field — so a reader must never
|
|
43
|
+
* treat an unmarked reject as final. Still a `reject` in every count.
|
|
44
|
+
*/
|
|
45
|
+
| {
|
|
46
|
+
type: 'reject';
|
|
47
|
+
signature: string;
|
|
48
|
+
rejectReason?: string;
|
|
49
|
+
validity: ValidityRejection;
|
|
50
|
+
expiredAt?: never;
|
|
26
51
|
}
|
|
27
52
|
/**
|
|
28
53
|
* This member refuses the transaction *for now*: it holds a conflicting transaction that won
|
|
@@ -73,13 +98,21 @@ export type ClusterVote = Unsigned<Signature>;
|
|
|
73
98
|
* held's `heldBy`, nothing for an approve. Folding the extra in is what makes it integrity-protected in
|
|
74
99
|
* transit rather than free-floating prose.
|
|
75
100
|
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
101
|
+
* Two reject variants carry two fields each, and each has its own tag:
|
|
102
|
+
* - an expiry vote, a `reject` with {@link Signature} `expiredAt`, is encoded
|
|
103
|
+
* `<hash>:reject-expired:<json>`, where `<json>` is `JSON.stringify([expiredAt, rejectReason ?? null])`;
|
|
104
|
+
* - a validity vote, a `reject` with {@link Signature} `validity`, is encoded
|
|
105
|
+
* `<hash>:reject-invalid:<json>`, where `<json>` is `JSON.stringify([computedHash ?? null,
|
|
106
|
+
* rejectReason ?? null])`.
|
|
107
|
+
*
|
|
108
|
+
* Two properties make that unambiguous. The tag is decided character by character after the hash (a
|
|
109
|
+
* hash is base64url, so the first `:` always ends it): a plain reject continues `reject` with `:` or
|
|
110
|
+
* nothing, the two marked ones with `-`, and those two differ at the next character (`e` and `i`); every
|
|
111
|
+
* other vote's tag differs from all three at its first character. And a JSON array cannot be read as a
|
|
112
|
+
* different pair of values. A reason that itself contains `:` — `"x:5"` — can therefore never verify as
|
|
113
|
+
* reason `"x"` with `expiredAt: 5`, a string smuggled into `expiredAt` changes the bytes, and adding,
|
|
114
|
+
* removing or altering a vote's `validity` changes them too. The type keeps the two marked forms apart
|
|
115
|
+
* (no vote carries both). Every vote with neither field encodes exactly as before either existed.
|
|
83
116
|
*
|
|
84
117
|
* Producers and verifiers must both build the preimage here. It lives beside {@link Signature}
|
|
85
118
|
* rather than in either consumer because a second copy that forgets a variant does not fail loudly:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"structs.d.ts","sourceRoot":"","sources":["../../../src/cluster/structs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"structs.d.ts","sourceRoot":"","sources":["../../../src/cluster/structs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAEvE;;;;;;;GAOG;AACH,MAAM,MAAM,SAAS,GAClB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE;AACxC;;;GAGG;GACD;IACD,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC;CACjB;AACD;;;;;;;;;;GAUG;GACD;IACD,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,SAAS,CAAC,EAAE,KAAK,CAAC;CAClB;AACD;;;;;GAKG;GACD;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,SAAS,EAAE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IACnL,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,gIAAgI;IAChI,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B;;;;;;;;;;;OAWG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;;OAKG;IACH,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC;;;OAGG;IACH,uBAAuB,CAAC,EAAE,uBAAuB,CAAC;CAClD;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,uBAAuB,GAAG,QAAQ,GAAG,QAAQ,CAAC"}
|
|
@@ -4,13 +4,21 @@
|
|
|
4
4
|
* held's `heldBy`, nothing for an approve. Folding the extra in is what makes it integrity-protected in
|
|
5
5
|
* transit rather than free-floating prose.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
7
|
+
* Two reject variants carry two fields each, and each has its own tag:
|
|
8
|
+
* - an expiry vote, a `reject` with {@link Signature} `expiredAt`, is encoded
|
|
9
|
+
* `<hash>:reject-expired:<json>`, where `<json>` is `JSON.stringify([expiredAt, rejectReason ?? null])`;
|
|
10
|
+
* - a validity vote, a `reject` with {@link Signature} `validity`, is encoded
|
|
11
|
+
* `<hash>:reject-invalid:<json>`, where `<json>` is `JSON.stringify([computedHash ?? null,
|
|
12
|
+
* rejectReason ?? null])`.
|
|
13
|
+
*
|
|
14
|
+
* Two properties make that unambiguous. The tag is decided character by character after the hash (a
|
|
15
|
+
* hash is base64url, so the first `:` always ends it): a plain reject continues `reject` with `:` or
|
|
16
|
+
* nothing, the two marked ones with `-`, and those two differ at the next character (`e` and `i`); every
|
|
17
|
+
* other vote's tag differs from all three at its first character. And a JSON array cannot be read as a
|
|
18
|
+
* different pair of values. A reason that itself contains `:` — `"x:5"` — can therefore never verify as
|
|
19
|
+
* reason `"x"` with `expiredAt: 5`, a string smuggled into `expiredAt` changes the bytes, and adding,
|
|
20
|
+
* removing or altering a vote's `validity` changes them too. The type keeps the two marked forms apart
|
|
21
|
+
* (no vote carries both). Every vote with neither field encodes exactly as before either existed.
|
|
14
22
|
*
|
|
15
23
|
* Producers and verifiers must both build the preimage here. It lives beside {@link Signature}
|
|
16
24
|
* rather than in either consumer because a second copy that forgets a variant does not fail loudly:
|
|
@@ -32,6 +40,9 @@ export function clusterVoteVerificationPayload(hash, signature) {
|
|
|
32
40
|
function voteTagAndExtra(vote) {
|
|
33
41
|
switch (vote.type) {
|
|
34
42
|
case 'reject':
|
|
43
|
+
if (vote.validity !== undefined) {
|
|
44
|
+
return 'reject-invalid:' + JSON.stringify([vote.validity.computedHash ?? null, vote.rejectReason ?? null]);
|
|
45
|
+
}
|
|
35
46
|
return vote.expiredAt === undefined
|
|
36
47
|
? withExtra('reject', vote.rejectReason)
|
|
37
48
|
: 'reject-expired:' + JSON.stringify([vote.expiredAt, vote.rejectReason ?? null]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"structs.js","sourceRoot":"","sources":["../../../src/cluster/structs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"structs.js","sourceRoot":"","sources":["../../../src/cluster/structs.ts"],"names":[],"mappings":"AAwFA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,yBAAyB,CAAC,IAAY,EAAE,IAAiB;IACxE,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,GAAG,GAAG,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;AACrE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,8BAA8B,CAAC,IAAY,EAAE,SAAoB;IAChF,OAAO,yBAAyB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;AACnD,CAAC;AAED,SAAS,eAAe,CAAC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
10
10
|
transaction?: TransactionRef;
|
|
11
11
|
};
|
|
12
12
|
export type ActionHandler<T, TResult = void> = (action: Action<T>, store: BlockStore<IBlock>) => Promise<TResult>;
|
|
13
|
+
/**
|
|
14
|
+
* What one run of a collection's action handler accepted as ALREADY APPLIED — the answer a handler may
|
|
15
|
+
* give (`CollectionInitOptions.modules` types every handler as returning one or nothing), summed by
|
|
16
|
+
* `Collection.stageInto` over the actions it stages and recorded on the sealed segment they belong to
|
|
17
|
+
* (`SealedSegment.applied`). Today only the tree's `replace` handler counts anything: for each element
|
|
18
|
+
* whose guard is one of the three already-applied kinds (`TreeAlreadyAppliedGuard` in
|
|
19
|
+
* `packages/db-core/src/collections/tree/struct.ts`), `alreadyApplied` when the element was skipped
|
|
20
|
+
* because a rival had made exactly its change, `applied` when it was written or deleted; and `applied`
|
|
21
|
+
* for each element written under `absent` or `unchanged`, the exact-key base kinds that write whenever
|
|
22
|
+
* they do not refuse and that the SQL layer stages on every main-table element, so a plain insert
|
|
23
|
+
* beside an already-applied update keeps the entry `applied`. Elements with no guard, or with
|
|
24
|
+
* `keepExisting` (a skip that says nothing about equality) or `absentRange` — the shapes an index
|
|
25
|
+
* tree's entries take — are not counted, so {@link ZeroTally} is the tally of an action with no counted
|
|
26
|
+
* element, and of a handler that returns nothing (`Diary`'s).
|
|
27
|
+
*
|
|
28
|
+
* The offline queue sums an entry's tallies over every collection it wrote and reports
|
|
29
|
+
* `effect: 'already-applied'` on its `committed` status exactly when `alreadyApplied > 0` and
|
|
30
|
+
* `applied === 0`: every element that could have been already applied was, and at least one was
|
|
31
|
+
* (docs/offline-sync.md §Guards that make idempotent writes assured). "All, not any", because a host
|
|
32
|
+
* reading `already-applied` as "none of my guarded changes landed" must be right.
|
|
33
|
+
*/
|
|
34
|
+
export type AlreadyAppliedTally = {
|
|
35
|
+
readonly alreadyApplied: number;
|
|
36
|
+
readonly applied: number;
|
|
37
|
+
};
|
|
38
|
+
/** The tally of a handler that counted nothing. */
|
|
39
|
+
export declare const ZeroTally: AlreadyAppliedTally;
|
|
40
|
+
/** `a + b`, field by field. */
|
|
41
|
+
export declare function addTallies(a: AlreadyAppliedTally, b: AlreadyAppliedTally): AlreadyAppliedTally;
|
|
13
42
|
export type ActionRev = {
|
|
14
43
|
actionId: ActionId;
|
|
15
44
|
rev: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../../src/collection/action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAE9D,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAE9B,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAEhC,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI;IACvB,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,CAAC,CAAC;IACR,kEAAkE;IAClE,WAAW,CAAC,EAAE,cAAc,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,aAAa,CAAC,CAAC,EAAE,OAAO,GAAG,IAAI,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAElH,MAAM,MAAM,SAAS,GAAG;IACvB,QAAQ,EAAE,QAAQ,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF,gDAAgD;AAChD,MAAM,MAAM,aAAa,GAAG;IAC3B,kDAAkD;IAClD,SAAS,EAAE,SAAS,EAAE,CAAC;IACvB,uCAAuC;IACvC,GAAG,EAAE,MAAM,CAAC;IACZ;;;;;;;;;;;;;;gCAc4B;IAC5B,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACpB,CAA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AE,MAAM,CAAC;CACZ,CAAC;AAEF,gDAAgD;AAChD,MAAM,MAAM,aAAa,GAAG;IAC3B,kDAAkD;IAClD,SAAS,EAAE,SAAS,EAAE,CAAC;IACvB,uCAAuC;IACvC,GAAG,EAAE,MAAM,CAAC;IACZ;;;;;;;;;;;;;;gCAc4B;IAC5B,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACpB,CAAC;AAEF;;;;;;;;;;;;oDAYoD;AACpD,wBAAgB,UAAU,CAAC,OAAO,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAEpF"}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/** The tally of a handler that counted nothing. */
|
|
2
|
+
export const ZeroTally = Object.freeze({ alreadyApplied: 0, applied: 0 });
|
|
3
|
+
/** `a + b`, field by field. */
|
|
4
|
+
export function addTallies(a, b) {
|
|
5
|
+
return { alreadyApplied: a.alreadyApplied + b.alreadyApplied, applied: a.applied + b.applied };
|
|
6
|
+
}
|
|
1
7
|
/** The id of the action that produced `rev` within `context`'s uncheckpointed committed list,
|
|
2
8
|
* or `undefined` when the list names no action at that revision.
|
|
3
9
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action.js","sourceRoot":"","sources":["../../../src/collection/action.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"action.js","sourceRoot":"","sources":["../../../src/collection/action.ts"],"names":[],"mappings":"AA2CA,mDAAmD;AACnD,MAAM,CAAC,MAAM,SAAS,GAAwB,MAAM,CAAC,MAAM,CAAC,EAAE,cAAc,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;AAE/F,+BAA+B;AAC/B,MAAM,UAAU,UAAU,CAAC,CAAsB,EAAE,CAAsB;IACxE,OAAO,EAAE,cAAc,EAAE,CAAC,CAAC,cAAc,GAAG,CAAC,CAAC,cAAc,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC;AAChG,CAAC;AA+BD;;;;;;;;;;;;oDAYoD;AACpD,MAAM,UAAU,UAAU,CAAC,OAAsB,EAAE,GAAW;IAC7D,OAAO,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,KAAK,GAAG,CAAC,EAAE,QAAQ,CAAC;AACrE,CAAC"}
|