@evolu/common 8.12.0 → 8.13.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/dist/src/Callbacks.d.ts +12 -1
- package/dist/src/Callbacks.d.ts.map +1 -1
- package/dist/src/Callbacks.js +3 -0
- package/dist/src/Error.d.ts +10 -4
- package/dist/src/Error.d.ts.map +1 -1
- package/dist/src/Error.js +10 -4
- package/dist/src/Object.d.ts +65 -0
- package/dist/src/Object.d.ts.map +1 -1
- package/dist/src/Object.js +142 -0
- package/dist/src/Resource.d.ts +0 -5
- package/dist/src/Resource.d.ts.map +1 -1
- package/dist/src/Resource.js +6 -13
- package/dist/src/Sqlite.d.ts.map +1 -1
- package/dist/src/Sqlite.js +7 -0
- package/dist/src/Task.d.ts +10 -8
- package/dist/src/Task.d.ts.map +1 -1
- package/dist/src/Task.js +41 -5
- package/dist/src/Worker.d.ts +3 -3
- package/dist/src/local-first/Db.d.ts +8 -3
- package/dist/src/local-first/Db.d.ts.map +1 -1
- package/dist/src/local-first/Db.js +56 -19
- package/dist/src/local-first/Evolu.d.ts +81 -37
- package/dist/src/local-first/Evolu.d.ts.map +1 -1
- package/dist/src/local-first/Evolu.js +31 -6
- package/dist/src/local-first/Owner.d.ts +9 -0
- package/dist/src/local-first/Owner.d.ts.map +1 -1
- package/dist/src/local-first/Owner.js +9 -0
- package/dist/src/local-first/Protocol.d.ts +6 -4
- package/dist/src/local-first/Protocol.d.ts.map +1 -1
- package/dist/src/local-first/Protocol.js +1 -6
- package/dist/src/local-first/Schema.d.ts +7 -1
- package/dist/src/local-first/Schema.d.ts.map +1 -1
- package/dist/src/local-first/Shared.d.ts +523 -133
- package/dist/src/local-first/Shared.d.ts.map +1 -1
- package/dist/src/local-first/Shared.js +696 -256
- package/dist/src/local-first/Storage.d.ts +16 -12
- package/dist/src/local-first/Storage.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/Callbacks.test.ts +20 -0
- package/src/Callbacks.ts +17 -1
- package/src/Error.ts +10 -4
- package/src/Object.test.ts +296 -0
- package/src/Object.ts +163 -0
- package/src/Resource.test.ts +20 -16
- package/src/Resource.ts +6 -20
- package/src/Sqlite.ts +7 -0
- package/src/Task.test.ts +233 -62
- package/src/Task.ts +47 -13
- package/src/Worker.ts +3 -3
- package/src/local-first/Db.ts +88 -18
- package/src/local-first/Evolu.test.ts +281 -1
- package/src/local-first/Evolu.ts +124 -46
- package/src/local-first/Owner.ts +9 -0
- package/src/local-first/Protocol.test.ts +42 -60
- package/src/local-first/Protocol.ts +7 -9
- package/src/local-first/Schema.ts +8 -2
- package/src/local-first/Shared.test.ts +2633 -646
- package/src/local-first/Shared.ts +1192 -364
- package/src/local-first/Storage.ts +18 -19
|
@@ -10,7 +10,6 @@ import { firstInArray, isNonEmptyArray } from "../Array.ts";
|
|
|
10
10
|
import { assert, assertNonNullable } from "../Assert.ts";
|
|
11
11
|
import type { Brand } from "../Brand.ts";
|
|
12
12
|
import { concatByteArrays } from "../Bytes.ts";
|
|
13
|
-
import type { DecryptWithXChaCha20Poly1305Error } from "../Crypto.ts";
|
|
14
13
|
import { decrement } from "../Number.ts";
|
|
15
14
|
import type { RandomDep } from "../Random.ts";
|
|
16
15
|
import { err, ok } from "../Result.ts";
|
|
@@ -39,11 +38,9 @@ import {
|
|
|
39
38
|
import type { Awaitable } from "../Types.ts";
|
|
40
39
|
import type { Owner, OwnerError, OwnerIdBytes } from "./Owner.ts";
|
|
41
40
|
import { OwnerId, OwnerWriteKey } from "./Owner.ts";
|
|
42
|
-
import type {
|
|
43
|
-
ProtocolInvalidDataError,
|
|
44
|
-
ProtocolTimestampMismatchError,
|
|
45
|
-
} from "./Protocol.ts";
|
|
41
|
+
import type { ProtocolQuotaError } from "./Protocol.ts";
|
|
46
42
|
import { systemColumnsWithId } from "./Schema.ts";
|
|
43
|
+
import type { syncStateToOwnerSyncStatus } from "./Shared.ts";
|
|
47
44
|
import {
|
|
48
45
|
createTimestamp,
|
|
49
46
|
orderTimestampBytes,
|
|
@@ -72,9 +69,10 @@ export interface StorageConfig {
|
|
|
72
69
|
* The callback returns a boolean rather than an error because error handling
|
|
73
70
|
* and logging are the responsibility of the callback implementation.
|
|
74
71
|
*
|
|
75
|
-
* Relay deployments configure this callback. Client applications
|
|
76
|
-
*
|
|
77
|
-
*
|
|
72
|
+
* Relay deployments configure this callback. Client applications observe a
|
|
73
|
+
* denied relay write as a {@link ProtocolQuotaError} in the `failure` of that
|
|
74
|
+
* relay's route, which {@link syncStateToOwnerSyncStatus} reports as the
|
|
75
|
+
* owner's `Error` status.
|
|
78
76
|
*
|
|
79
77
|
* ### Example
|
|
80
78
|
*
|
|
@@ -194,7 +192,10 @@ export interface Storage {
|
|
|
194
192
|
* Write encrypted {@link CrdtMessage}s to storage.
|
|
195
193
|
*
|
|
196
194
|
* Stores none of the messages and returns the cause when the batch cannot be
|
|
197
|
-
* accepted.
|
|
195
|
+
* accepted. A client storage that cannot decrypt, verify, or decode a message
|
|
196
|
+
* skips it and stores the rest, as the built-in client storage does, because
|
|
197
|
+
* the peer offers the message again in every round, and rejecting the batch
|
|
198
|
+
* would end each round.
|
|
198
199
|
*
|
|
199
200
|
* Must use a mutex per ownerId to ensure sequential processing and proper
|
|
200
201
|
* protocol logic handling during sync operations.
|
|
@@ -234,19 +235,17 @@ export interface StorageQuotaError
|
|
|
234
235
|
/**
|
|
235
236
|
* Expected reasons why {@link Storage.writeMessages} stored none of a batch.
|
|
236
237
|
*
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
-
*
|
|
238
|
+
* The built-in relay storage stores opaque encrypted messages and rejects
|
|
239
|
+
* batches over quota. The built-in client storage decrypts and validates
|
|
240
|
+
* incoming messages before updating its clock and database tables. It skips a
|
|
241
|
+
* message that fails instead of rejecting its batch, and sync state shows it as
|
|
242
|
+
* the route's `skippedError` without ending the sync round, so a message is
|
|
243
|
+
* never a reason to reject a batch. The contract permits quota checks on either
|
|
244
|
+
* side.
|
|
242
245
|
*
|
|
243
246
|
* @group Core
|
|
244
247
|
*/
|
|
245
|
-
export type StorageWriteMessagesError =
|
|
246
|
-
| DecryptWithXChaCha20Poly1305Error
|
|
247
|
-
| ProtocolInvalidDataError
|
|
248
|
-
| ProtocolTimestampMismatchError
|
|
249
|
-
| StorageQuotaError;
|
|
248
|
+
export type StorageWriteMessagesError = StorageQuotaError;
|
|
250
249
|
|
|
251
250
|
/**
|
|
252
251
|
* A cryptographic hash used for efficiently comparing collections of
|