@evolu/common 8.12.0 → 8.14.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.
Files changed (59) hide show
  1. package/dist/src/Callbacks.d.ts +12 -1
  2. package/dist/src/Callbacks.d.ts.map +1 -1
  3. package/dist/src/Callbacks.js +3 -0
  4. package/dist/src/Error.d.ts +10 -4
  5. package/dist/src/Error.d.ts.map +1 -1
  6. package/dist/src/Error.js +10 -4
  7. package/dist/src/Object.d.ts +65 -0
  8. package/dist/src/Object.d.ts.map +1 -1
  9. package/dist/src/Object.js +142 -0
  10. package/dist/src/Resource.d.ts +0 -5
  11. package/dist/src/Resource.d.ts.map +1 -1
  12. package/dist/src/Resource.js +6 -13
  13. package/dist/src/Sqlite.d.ts.map +1 -1
  14. package/dist/src/Sqlite.js +7 -0
  15. package/dist/src/Task.d.ts +10 -8
  16. package/dist/src/Task.d.ts.map +1 -1
  17. package/dist/src/Task.js +41 -5
  18. package/dist/src/Worker.d.ts +3 -3
  19. package/dist/src/local-first/Db.d.ts +8 -3
  20. package/dist/src/local-first/Db.d.ts.map +1 -1
  21. package/dist/src/local-first/Db.js +56 -19
  22. package/dist/src/local-first/Evolu.d.ts +147 -39
  23. package/dist/src/local-first/Evolu.d.ts.map +1 -1
  24. package/dist/src/local-first/Evolu.js +53 -9
  25. package/dist/src/local-first/Owner.d.ts +9 -0
  26. package/dist/src/local-first/Owner.d.ts.map +1 -1
  27. package/dist/src/local-first/Owner.js +9 -0
  28. package/dist/src/local-first/Protocol.d.ts +6 -4
  29. package/dist/src/local-first/Protocol.d.ts.map +1 -1
  30. package/dist/src/local-first/Protocol.js +1 -6
  31. package/dist/src/local-first/Schema.d.ts +7 -1
  32. package/dist/src/local-first/Schema.d.ts.map +1 -1
  33. package/dist/src/local-first/Shared.d.ts +550 -153
  34. package/dist/src/local-first/Shared.d.ts.map +1 -1
  35. package/dist/src/local-first/Shared.js +724 -273
  36. package/dist/src/local-first/Storage.d.ts +16 -12
  37. package/dist/src/local-first/Storage.d.ts.map +1 -1
  38. package/package.json +1 -1
  39. package/src/Callbacks.test.ts +20 -0
  40. package/src/Callbacks.ts +17 -1
  41. package/src/Error.ts +10 -4
  42. package/src/Object.test.ts +296 -0
  43. package/src/Object.ts +163 -0
  44. package/src/Resource.test.ts +20 -16
  45. package/src/Resource.ts +6 -20
  46. package/src/Sqlite.ts +7 -0
  47. package/src/Task.test.ts +233 -62
  48. package/src/Task.ts +47 -13
  49. package/src/Worker.ts +3 -3
  50. package/src/local-first/Db.ts +88 -18
  51. package/src/local-first/Evolu.test.ts +381 -11
  52. package/src/local-first/Evolu.ts +219 -51
  53. package/src/local-first/Owner.ts +9 -0
  54. package/src/local-first/Protocol.test.ts +42 -60
  55. package/src/local-first/Protocol.ts +7 -9
  56. package/src/local-first/Schema.ts +8 -2
  57. package/src/local-first/Shared.test.ts +2714 -644
  58. package/src/local-first/Shared.ts +1245 -401
  59. package/src/local-first/Storage.ts +18 -19
@@ -465,8 +465,9 @@ export interface ProtocolWriteKeyError
465
465
  extends OwnerError, Typed<"ProtocolWriteKeyError"> {}
466
466
 
467
467
  /**
468
- * Error indicating a serious relay-side write failure. Clients should log this
469
- * error and show a generic sync error to the user.
468
+ * Error indicating a serious relay-side write failure. Sync state shows it as
469
+ * the failure of that relay's route; apps show a generic sync error for the
470
+ * owner's `Error` status.
470
471
  */
471
472
  export interface ProtocolWriteError
472
473
  extends OwnerError, Typed<"ProtocolWriteError"> {}
@@ -489,8 +490,9 @@ export interface ProtocolQuotaError
489
490
  extends OwnerError, Typed<"ProtocolQuotaError"> {}
490
491
 
491
492
  /**
492
- * Error indicating a serious relay-side synchronization failure. Clients should
493
- * log this error and show a generic sync error to the user.
493
+ * Error indicating a serious relay-side synchronization failure. Sync state
494
+ * shows it as the failure of that relay's route; apps show a generic sync error
495
+ * for the owner's `Error` status.
494
496
  */
495
497
  export interface ProtocolSyncError
496
498
  extends OwnerError, Typed<"ProtocolSyncError"> {}
@@ -1286,13 +1288,9 @@ export const applyProtocolMessageAsRelay =
1286
1288
  );
1287
1289
 
1288
1290
  if (!result.ok) {
1289
- const isQuotaError = result.error.type === "StorageQuotaError";
1290
- if (!isQuotaError) run.deps.console.error(result.error);
1291
1291
  const message = createProtocolMessageBuffer(ownerId, {
1292
1292
  messageType: MessageType.Response,
1293
- errorCode: isQuotaError
1294
- ? ProtocolErrorCode.QuotaError
1295
- : ProtocolErrorCode.WriteError,
1293
+ errorCode: ProtocolErrorCode.QuotaError,
1296
1294
  }).unwrap();
1297
1295
  return ok({ type: "Response", message });
1298
1296
  }
@@ -43,7 +43,7 @@ import {
43
43
  type withDefault,
44
44
  } from "../Type.ts";
45
45
  import type { CompileTimeError, Simplify } from "../Types.ts";
46
- import type { Evolu, maxMutationSize } from "./Evolu.ts";
46
+ import type { Evolu, EvoluErrorDep, maxMutationSize } from "./Evolu.ts";
47
47
  import type { AppOwner, OwnerIdBytes } from "./Owner.ts";
48
48
  import {
49
49
  OwnerEncryptionKey,
@@ -514,7 +514,13 @@ export interface MutationOptions {
514
514
  * Called after the mutation's changes are stored and subscribed queries
515
515
  * reflect them. Useful for follow-up work (e.g., notifications, navigation)
516
516
  * after insert, update, or upsert. It never runs when the database is
517
- * unavailable.
517
+ * unavailable or the mutation could not be stored, which
518
+ * {@link EvoluErrorDep.evoluError} reports.
519
+ *
520
+ * An Evolu instance stores its mutations in batches, each in one transaction.
521
+ * A batch holds the mutations made before Evolu sends it in a microtask,
522
+ * usually one synchronous block, and {@link Evolu.requestSync} sends it early.
523
+ * When one mutation cannot be stored, none of its batch is.
518
524
  *
519
525
  * Stored does not always mean visible. A change quarantined for
520
526
  * {@link QuarantineReason.TimestampDrift} is stored in