@evolu/common 8.4.0 → 8.5.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 (74) hide show
  1. package/dist/src/Array.d.ts +24 -0
  2. package/dist/src/Array.d.ts.map +1 -1
  3. package/dist/src/Array.js +27 -1
  4. package/dist/src/Assert.d.ts.map +1 -1
  5. package/dist/src/Assert.js +1 -0
  6. package/dist/src/LeakDetector.d.ts.map +1 -1
  7. package/dist/src/LeakDetector.js +4 -1
  8. package/dist/src/Lookup.js +1 -0
  9. package/dist/src/Platform.js +1 -0
  10. package/dist/src/Relation.js +3 -3
  11. package/dist/src/Resource.d.ts.map +1 -1
  12. package/dist/src/Resource.js +9 -3
  13. package/dist/src/Result.d.ts.map +1 -1
  14. package/dist/src/Result.js +3 -5
  15. package/dist/src/Sqlite.d.ts.map +1 -1
  16. package/dist/src/Sqlite.js +9 -7
  17. package/dist/src/Store.d.ts.map +1 -1
  18. package/dist/src/Store.js +3 -1
  19. package/dist/src/String.d.ts.map +1 -1
  20. package/dist/src/String.js +1 -1
  21. package/dist/src/Task.d.ts +122 -60
  22. package/dist/src/Task.d.ts.map +1 -1
  23. package/dist/src/Task.js +40 -53
  24. package/dist/src/Test.d.ts.map +1 -1
  25. package/dist/src/Test.js +1 -0
  26. package/dist/src/Time.d.ts.map +1 -1
  27. package/dist/src/Time.js +9 -2
  28. package/dist/src/Type.d.ts +146 -9
  29. package/dist/src/Type.d.ts.map +1 -1
  30. package/dist/src/Type.js +10 -7
  31. package/dist/src/WebSocket.d.ts.map +1 -1
  32. package/dist/src/WebSocket.js +8 -0
  33. package/dist/src/Worker.js +1 -1
  34. package/dist/src/local-first/Db.js +3 -2
  35. package/dist/src/local-first/Evolu.d.ts.map +1 -1
  36. package/dist/src/local-first/Evolu.js +1 -0
  37. package/dist/src/local-first/Owner.d.ts +8 -7
  38. package/dist/src/local-first/Owner.d.ts.map +1 -1
  39. package/dist/src/local-first/Owner.js +4 -4
  40. package/dist/src/local-first/Protocol.d.ts.map +1 -1
  41. package/dist/src/local-first/Protocol.js +30 -24
  42. package/dist/src/local-first/Query.d.ts.map +1 -1
  43. package/dist/src/local-first/Query.js +2 -1
  44. package/dist/src/local-first/Relay.js +1 -1
  45. package/dist/src/local-first/Shared.d.ts.map +1 -1
  46. package/dist/src/local-first/Shared.js +4 -2
  47. package/dist/src/local-first/Timestamp.d.ts.map +1 -1
  48. package/dist/src/local-first/Timestamp.js +1 -1
  49. package/package.json +1 -1
  50. package/src/Array.ts +28 -1
  51. package/src/Assert.ts +1 -0
  52. package/src/LeakDetector.ts +4 -3
  53. package/src/Lookup.ts +1 -0
  54. package/src/Platform.ts +1 -0
  55. package/src/Relation.ts +3 -3
  56. package/src/Resource.ts +9 -3
  57. package/src/Result.ts +5 -5
  58. package/src/Sqlite.ts +9 -7
  59. package/src/Store.ts +3 -1
  60. package/src/String.ts +1 -1
  61. package/src/Task.ts +133 -82
  62. package/src/Test.ts +1 -0
  63. package/src/Time.ts +9 -2
  64. package/src/Type.ts +173 -29
  65. package/src/WebSocket.ts +8 -0
  66. package/src/Worker.ts +1 -1
  67. package/src/local-first/Db.ts +2 -1
  68. package/src/local-first/Evolu.ts +1 -0
  69. package/src/local-first/Owner.ts +8 -7
  70. package/src/local-first/Protocol.ts +40 -30
  71. package/src/local-first/Query.ts +6 -3
  72. package/src/local-first/Relay.ts +1 -1
  73. package/src/local-first/Shared.ts +4 -2
  74. package/src/local-first/Timestamp.ts +1 -1
package/dist/src/Task.js CHANGED
@@ -55,36 +55,34 @@ var __disposeResources = (this && this.__disposeResources) || (function (Suppres
55
55
  *
56
56
  * JavaScript-native structured concurrency.
57
57
  *
58
- * Structured concurrency makes ownership of asynchronous work explicit.
59
- * Operations form a tree where every child belongs to a parent. A parent waits
60
- * for its children before it completes, and abort follows the tree: aborting a
61
- * parent requests abort of all its descendants. Races and fail-fast operations
62
- * also abort their remaining sibling branches.
58
+ * Structured concurrency organizes running tasks into a tree. Every child
59
+ * belongs to a parent, a parent waits for its children before it completes, and
60
+ * abort propagates from parents to descendants. Races and fail-fast control
61
+ * flow abort siblings that are no longer needed.
63
62
  *
64
63
  * With plain {@link AbortController} code, these guarantees depend on call-site
65
- * discipline: someone must remember the `finally` that aborts started work and
66
- * the await that waits for cleanup. {@link Run} makes both structural:
67
- * `run(task)` registers every child before it starts, and the parent settles
64
+ * discipline: someone must remember the `finally` that aborts started tasks and
65
+ * the await that waits for cleanup. Evolu makes both structural: `run(task)`
66
+ * registers every child before it starts, and the parent {@link Run} settles
68
67
  * only after child cleanup finishes.
69
68
  *
70
- * Evolu models structured concurrency with ordinary JavaScript:
69
+ * Evolu implements structured concurrency with:
71
70
  *
72
- * - A {@link Task} describes an asynchronous operation and its dependencies.
71
+ * - A {@link Task} is a function passed to Run that returns an {@link Awaitable}
72
+ * {@link Result} and declares its dependencies.
73
73
  * - A {@link Run} starts Tasks and owns their lifetimes.
74
74
  * - A {@link Fiber} is the Promise-backed handle returned when a Run starts a
75
75
  * Task.
76
76
  * - An {@link AbortableFiber} adds explicit abort and async disposal.
77
77
  *
78
- * The runtime core is deliberately small: ordinary functions, a callable Run
79
- * with closed-over state, Promise-backed Fibers, {@link AbortSignal}
80
- * propagation, and JavaScript resource management. Together, these primitives
81
- * provide abort, cleanup, defect handling, dependency injection, monitoring,
82
- * concurrency, and resource bracketing.
78
+ * Together, these APIs provide abort, cleanup, defect handling, dependency
79
+ * injection, monitoring, and resource management.
83
80
  *
84
- * Tasks return domain success or failure as {@link Result}. Abort is control
85
- * flow represented by {@link AbortError}. If a Task throws or rejects with
86
- * anything else, that is a defect: the root Run reports it and shuts down its
87
- * tree so code does not continue in a potentially invalid state.
81
+ * Tasks return a {@link Result} containing either success or a domain error.
82
+ * Abort is control flow represented by {@link AbortError}. If a Task throws or
83
+ * rejects with anything else, that is a defect: the root Run reports it and
84
+ * shuts down its tree so code does not continue in a potentially invalid
85
+ * state.
88
86
  *
89
87
  * ```ts
90
88
  * import {
@@ -253,7 +251,7 @@ var __disposeResources = (this && this.__disposeResources) || (function (Suppres
253
251
  *
254
252
  * {@link fetch} with a body mode already returns a plain value, so resilience is
255
253
  * ordinary Task composition. Combine {@link timeout} and {@link retry} to bound
256
- * each attempt and retry recoverable domain failures:
254
+ * each attempt and retry recoverable domain errors:
257
255
  *
258
256
  * ```ts
259
257
  * import {
@@ -476,9 +474,9 @@ var __disposeResources = (this && this.__disposeResources) || (function (Suppres
476
474
  * expect(socketDisposed).toBe(true);
477
475
  * ```
478
476
  *
479
- * Use {@link Run.ok} with `await using` when an infallible Task returns a
480
- * disposable value. Use {@link acquireUseRelease} when acquisition and release
481
- * are separate operations rather than a disposable value.
477
+ * Use {@link Run.ok} with `await using` when a Task whose error type is `never`
478
+ * returns a disposable value. Use {@link acquireUseRelease} when acquisition and
479
+ * release are separate steps rather than a disposable value.
482
480
  *
483
481
  * ## Awaitable
484
482
  *
@@ -491,7 +489,7 @@ var __disposeResources = (this && this.__disposeResources) || (function (Suppres
491
489
  *
492
490
  * A Task is an async ownership boundary, not a general unit of program
493
491
  * decomposition. Calling `run(task)` always creates a child Run by design. Use
494
- * ordinary promises when an async operation does not need its own Run.
492
+ * a plain async function when it does not need its own Run.
495
493
  *
496
494
  * A unified sync/async effect API is technically possible. It can detect
497
495
  * Promise-like values with {@link isPromiseLike}, dispose synchronous resources
@@ -509,7 +507,7 @@ var __disposeResources = (this && this.__disposeResources) || (function (Suppres
509
507
  * code performs effects with the result. For example, a pure function can
510
508
  * accept a {@link RandomNumber} value instead of depending on {@link Random}.
511
509
  *
512
- * Large CPU-bound operations, such as parsing large JSON, sorting millions of
510
+ * Large CPU-bound computations, such as parsing large JSON, sorting millions of
513
511
  * items, or complex cryptography, belong in a worker. Model the asynchronous
514
512
  * call to that worker as a Task so Run can provide timeout, abort, cleanup, and
515
513
  * monitoring.
@@ -569,10 +567,10 @@ var __disposeResources = (this && this.__disposeResources) || (function (Suppres
569
567
  * ### What should Task code do with defects?
570
568
  *
571
569
  * Nothing. Once a defect reaches the {@link Run}, it is too late: the root Run
572
- * panics, running Tasks are aborted, and the Run tree shuts down. If an
573
- * operation can throw or reject for a recoverable reason, wrap that operation
574
- * with {@link trySync} or {@link tryAsync} so the failure becomes a typed
575
- * {@link Result} error. Let unrecoverable failures propagate as defects.
570
+ * panics, running Tasks are aborted, and the Run tree shuts down. Use
571
+ * {@link trySync} or {@link tryAsync} to turn recoverable exceptions and Promise
572
+ * rejections into typed {@link Result} errors. Let unrecoverable failures
573
+ * propagate as defects.
576
574
  *
577
575
  * ### Why does a defect panic the whole Run tree?
578
576
  *
@@ -671,13 +669,6 @@ var __disposeResources = (this && this.__disposeResources) || (function (Suppres
671
669
  * periodically await {@link yieldNow} for cooperative scheduling, and move
672
670
  * CPU-bound work to a worker.
673
671
  *
674
- * ### Should a Task be called directly?
675
- *
676
- * Only inside Task internals that explicitly require same-Run execution. A
677
- * direct call, `task(run)`, uses the current Run instead of creating a child
678
- * Run, so it bypasses child lifetime tracking, scheduling metadata, and child
679
- * disposal boundaries. Application code should use `run(task)`.
680
- *
681
672
  * ### Where are fork and join?
682
673
  *
683
674
  * Calling `run(task)` is fork: it starts a child Task and returns a
@@ -1128,7 +1119,6 @@ const createRunInternal = (deps, parent, rootRun, taskMeta) => {
1128
1119
  if (taskMeta?.priority && scheduler?.postTask) {
1129
1120
  result = await scheduler.postTask(() => {
1130
1121
  startSignal.throwIfAborted();
1131
- // eslint-disable-next-line evolu/no-direct-task-call -- The executor invokes the Task with its child Run.
1132
1122
  return task(taskRun);
1133
1123
  }, {
1134
1124
  priority: taskMeta.priority,
@@ -1137,7 +1127,6 @@ const createRunInternal = (deps, parent, rootRun, taskMeta) => {
1137
1127
  }
1138
1128
  else {
1139
1129
  startSignal.throwIfAborted();
1140
- // eslint-disable-next-line evolu/no-direct-task-call -- The executor invokes the Task with its child Run.
1141
1130
  result = await task(taskRun);
1142
1131
  }
1143
1132
  // Full Result validation is dev-only; production checks only the
@@ -1286,7 +1275,6 @@ const withTaskMeta = (meta) => (task) => {
1286
1275
  const taskInternal = task;
1287
1276
  assert(meta.abortBehavior === undefined ||
1288
1277
  taskInternal[taskMetaSymbol]?.abortBehavior === undefined, "abort behavior helpers cannot wrap the same Task");
1289
- // eslint-disable-next-line evolu/no-direct-task-call -- Preserve the wrapped Task's child Run.
1290
1278
  const wrapped = (run) => task(run);
1291
1279
  const taskMeta = taskInternal[taskMetaSymbol];
1292
1280
  wrapped[taskMetaSymbol] = taskMeta ? { ...taskMeta, ...meta } : meta;
@@ -1358,7 +1346,7 @@ const mapInput = (input, fn) => Array.isArray(input)
1358
1346
  * This helper is a callback bridge. If `reject` forwards an Error created in a
1359
1347
  * separate async chain, V8 cannot reconstruct the caller's zero-cost async
1360
1348
  * stack through this bridge. Prefer native promise APIs and `await` when the
1361
- * wrapped operation already has a promise-shaped API.
1349
+ * wrapped API already returns a Promise.
1362
1350
  *
1363
1351
  * One-shot settlement applies only to `resolve` and `reject`. A synchronous
1364
1352
  * throw from the setup function is a defect that panics the Run tree even after
@@ -2078,7 +2066,7 @@ export const each = (tasks, onResult, options = {}) => async (run) => {
2078
2066
  const index = nextIndex;
2079
2067
  nextIndex += 1;
2080
2068
  const result = await run(tasks[index]);
2081
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- stopped can flip across the await via sibling workers
2069
+ // stopped can flip across the await via sibling workers.
2082
2070
  if (stopped)
2083
2071
  break;
2084
2072
  run.signal.throwIfAborted();
@@ -2097,6 +2085,7 @@ export const each = (tasks, onResult, options = {}) => async (run) => {
2097
2085
  active -= 1;
2098
2086
  if (active === 0)
2099
2087
  wake.resolve();
2088
+ // oxlint-disable-next-line typescript/return-await -- StackTrace.test.ts measures this direct await edge in the worker topology.
2100
2089
  return await parked;
2101
2090
  };
2102
2091
  await Promise.race([
@@ -2197,7 +2186,6 @@ export const yieldNow = async (run) => {
2197
2186
  run.signal.throwIfAborted();
2198
2187
  return ok();
2199
2188
  };
2200
- // Abortability
2201
2189
  /**
2202
2190
  * Waits until the current {@link Run} aborts, then rejects with its
2203
2191
  * {@link AbortError}.
@@ -2281,8 +2269,8 @@ export const waitForAbort = async (run) => {
2281
2269
  * execution. The daemon Task continues under root Run ownership until it
2282
2270
  * settles, observes abort, or the root Run is disposed.
2283
2271
  *
2284
- * This is not a replacement for direct {@link AbortSignal} support in operations
2285
- * that can observe abort, such as {@link fetch}, timers that accept a signal, or
2272
+ * This is not a replacement for direct {@link AbortSignal} support in APIs that
2273
+ * can observe abort, such as {@link fetch}, timers that accept a signal, or
2286
2274
  * callback APIs that accept a signal. Use it as an escape hatch for Tasks that
2287
2275
  * ignore abort when an abort request must stop waiting immediately.
2288
2276
  *
@@ -2343,7 +2331,7 @@ export const waitForAbort = async (run) => {
2343
2331
  * expect(finished).toBe(true);
2344
2332
  * ```
2345
2333
  *
2346
- * Promise-producing operations should start inside the Task, not before it.
2334
+ * Promise-returning functions should be called inside the Task, not before it.
2347
2335
  *
2348
2336
  * ```ts
2349
2337
  * import { createRun, ok, type Result, type Task } from "@evolu/common";
@@ -2460,7 +2448,7 @@ export const unabortable = /*#__PURE__*/ withTaskMeta({
2460
2448
  *
2461
2449
  * An abort request before the mask Task starts prevents entering the mask. Once
2462
2450
  * the body starts, plain child Tasks inherit the mask, so acquire and release
2463
- * can run after abort. Put release operations directly in the original mask's
2451
+ * can run after abort. Start release Tasks directly in the original mask's
2464
2452
  * `finally`; do not wrap release in a nested `unabortableMask`, which is a new
2465
2453
  * critical-section entry and may not start after abort.
2466
2454
  *
@@ -2534,7 +2522,7 @@ export const unabortableMask = (fn) => unabortable((run) => {
2534
2522
  // Only verifies the Run is masked. A direct call inside an already masked
2535
2523
  // Run passes undetected; direct calls bypass Run semantics by design.
2536
2524
  assert(runInternal.abortMask > abortableMask, "unabortableMask requires a masked Run; use run(task), not a direct call");
2537
- const restoreToken = Symbol();
2525
+ const restoreToken = Symbol("restore");
2538
2526
  // The token is local to this Task Run; descendant Runs inherit the token
2539
2527
  // set so helpers can receive restore while the mask Task is alive.
2540
2528
  // Each set is bounded by its Run lifetime and is intentionally not pruned.
@@ -2560,7 +2548,7 @@ export const unabortableMask = (fn) => unabortable((run) => {
2560
2548
  * Prefer native `using`, `await using`, or {@link AsyncDisposableStack} for
2561
2549
  * owned values that implement {@link Disposable} or {@link AsyncDisposable}. Use
2562
2550
  * `acquireUseRelease` when acquisition must be balanced with a separate release
2563
- * operation, such as unlocking, returning a pooled value, releasing a lease, or
2551
+ * step, such as unlocking, returning a pooled value, releasing a lease, or
2564
2552
  * logging out of a session.
2565
2553
  *
2566
2554
  * ### Example
@@ -2618,7 +2606,7 @@ export const acquireUseRelease = (acquire, use, release) => unabortableMask((res
2618
2606
  if (!resourceResult.ok)
2619
2607
  return resourceResult;
2620
2608
  try {
2621
- // eslint-disable-next-line react-hooks/rules-of-hooks -- `use` is an acquireUseRelease callback, not a React Hook.
2609
+ // oxlint-disable-next-line react/rules-of-hooks -- `use` is an acquireUseRelease callback, not a React Hook.
2622
2610
  return await run(restore(use(resourceResult.value)));
2623
2611
  }
2624
2612
  finally {
@@ -2736,7 +2724,6 @@ export const createGate = ({ isOpen = false, } = {}) => {
2736
2724
  deferred.resolve(ok());
2737
2725
  return {
2738
2726
  // Direct same-Run delegation is intentional so wait observes the current deferred.
2739
- // eslint-disable-next-line evolu/no-direct-task-call
2740
2727
  wait: (run) => deferred.task(run),
2741
2728
  open: () => {
2742
2729
  if (isOpen)
@@ -3065,7 +3052,7 @@ export const createMutexRef = (initialValue) => {
3065
3052
  // filtering, and pluggable log sinks.
3066
3053
  // - Tracing spans with names, timing, parent-child relationships, attributes,
3067
3054
  // error status, and helpers for annotating the current or child spans.
3068
- // - Metrics for counters, gauges, histograms, and operation durations.
3055
+ // - Metrics for counters, gauges, histograms, and Task execution durations.
3069
3056
  // - Resource metadata for service name, service version, deployment
3070
3057
  // environment, and user-provided attributes.
3071
3058
  // - Exporters for production telemetry backends, including OTLP-compatible
@@ -3078,5 +3065,5 @@ export const createMutexRef = (initialValue) => {
3078
3065
  // - Run labels and structured annotations for rendering useful snapshot trees
3079
3066
  // instead of anonymous ids.
3080
3067
  // - Snapshot and trace views should preserve ownership boundaries, so reusable
3081
- // resources and long-lived operations appear as labeled subtrees instead of
3082
- // unrelated child operations.
3068
+ // resources and long-lived Runs appear as labeled subtrees instead of
3069
+ // unrelated child Runs.
@@ -1 +1 @@
1
- {"version":3,"file":"Test.d.ts","sourceRoot":"","sources":["../../src/Test.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAGxC,OAAO,EAAY,KAAK,EAAE,EAAE,MAAM,WAAW,CAAC;AAE9C,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,SAAS,MAAM,GAAG,KAAK,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAC1E,EAAE,GACF,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;AAElB;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,YAAY,QAAO,YAM/B,CAAC"}
1
+ {"version":3,"file":"Test.d.ts","sourceRoot":"","sources":["../../src/Test.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAGxC,OAAO,EAAY,KAAK,EAAE,EAAE,MAAM,WAAW,CAAC;AAE9C,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,SAAS,MAAM,GAAG,KAAK,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAC1E,EAAE,GACF,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;AAElB;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,YAAY,QAAO,YAO/B,CAAC"}
package/dist/src/Test.js CHANGED
@@ -42,5 +42,6 @@ export const testCreateId = () => {
42
42
  const randomBytes = testCreateRandomBytes({
43
43
  randomLib: testCreateRandomLib(),
44
44
  });
45
+ // oxlint-disable-next-line typescript/no-unnecessary-type-arguments -- Explicit never resolves createId's conditional brand-validation rest parameter; inference rejects the argument without it.
45
46
  return (() => createId({ randomBytes }));
46
47
  };
@@ -1 +1 @@
1
- {"version":3,"file":"Time.d.ts","sourceRoot":"","sources":["../../src/Time.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,EAEL,KAAK,OAAO,EASZ,KAAK,YAAY,EAKlB,MAAM,WAAW,CAAC;AAEnB,iCAAiC;AACjC,MAAM,WAAW,IAAI;IACnB,QAAQ,CAAC,GAAG,EAAE;QACZ,uDAAuD;QACvD,IAAI,MAAM,CAAC;QAEX,sDAAsD;QACtD,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC;KAC5B,CAAC;IAEF,QAAQ,CAAC,WAAW,EAAE;QACpB,uEAAuE;QACvE,QAAQ,CAAC,UAAU,EAAE,qBAAqB,CAAC;QAE3C;;;;;;;;;WASG;QACH,QAAQ,CAAC,GAAG,EAAE,MAAM,eAAe,CAAC;KACrC,CAAC;IAEF,+DAA+D;IAC/D,QAAQ,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,IAAI,EAAE,KAAK,EAAE,gBAAgB,KAAK,SAAS,CAAC;IAE5E;;;;OAIG;IACH,QAAQ,CAAC,YAAY,EAAE,CAAC,EAAE,EAAE,SAAS,KAAK,IAAI,CAAC;CAChD;AAED,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;CACrB;AAED;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC;AAO3C;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,UAAU,QAAO,IAwB7B,CAAC;AAoEF;;;;GAIG;AACH,MAAM,WAAW,QAAS,SAAQ,IAAI;IACpC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GhC,CAAC;AACF,MAAM,MAAM,oBAAoB,GAAG,OAAO,oBAAoB,CAAC,MAAM,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,eAAe,ggkBAQ3B,CAAC;AACF,MAAM,MAAM,eAAe,GAAG,OAAO,eAAe,CAAC,MAAM,CAAC;AAE5D;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,eAAe,GAAG,cAAc,GACzC,cAAc,CAAC;AAElB,4EAA4E;AAC5E,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAAC;AA0B7D;;;;GAIG;AACH,eAAO,MAAM,OAAO,EAAS,MAAM,CAAC;AAEpC;;;;GAIG;AACH,eAAO,MAAM,QAAQ,EAAQ,MAAM,CAAC;AAEpC;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,EAAS,MAAM,CAAC;AAEvC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,sBAAsB,WAAY,MAAM,KAAG,MAuBvD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,uBAAuB,WAAY,MAAM,KAAG,MAOxD,CAAC"}
package/dist/src/Time.js CHANGED
@@ -4,6 +4,7 @@
4
4
  * @module
5
5
  */
6
6
  import { assert } from "./Assert.js";
7
+ import { exhaustiveCheck } from "./Function.js";
7
8
  import { brand, Digit, Digit1To23, Digit1To51, Digit1To59, Digit1To6, Digit1To9, Digit1To99, lessThan, NonNegativeInt, positive, templateLiteral, union, } from "./Type.js";
8
9
  /**
9
10
  * Creates a {@link Time} using `Date.now()`, `performance`, and
@@ -116,6 +117,10 @@ export const testCreateTime = (options) => {
116
117
  case "microtask":
117
118
  queueMicrotask(incrementNow);
118
119
  break;
120
+ case undefined:
121
+ break;
122
+ default:
123
+ exhaustiveCheck(autoIncrement);
119
124
  }
120
125
  return result;
121
126
  };
@@ -305,8 +310,10 @@ const durationUnits = {
305
310
  m: 60000,
306
311
  h: 3600000,
307
312
  d: 86400000,
308
- w: 604800000, // 7 days
309
- y: 31536000000, // 365 days
313
+ // 7 days
314
+ w: 604800000,
315
+ // 365 days
316
+ y: 31536000000,
310
317
  };
311
318
  /**
312
319
  * Frame budget at 60fps (16ms).
@@ -1,5 +1,5 @@
1
1
  import type { StandardSchemaV1 } from "@standard-schema/spec";
2
- import type { AtLeastTwoReadonlyArray, NonEmptyReadonlyArray } from "./Array.ts";
2
+ import { type AtLeastTwoReadonlyArray, type NonEmptyReadonlyArray } from "./Array.ts";
3
3
  import type { Brand } from "./Brand.ts";
4
4
  import type { RandomBytesDep } from "./Crypto.ts";
5
5
  import { type Thunk } from "./Function.ts";
@@ -779,7 +779,52 @@ export declare function transform<Name extends TypeName, ParentType extends Conc
779
779
  readonly from: (value: ParentType["Output"]) => Result<OutputType["Input"], never>;
780
780
  readonly to: (value: CanonicalInputOf<OutputType>) => ToOutput;
781
781
  }): TransformType<ParentType, OutputType, Name, never, ToOutput>;
782
- /** Creates a fallible transformed Type with its own error formatter. */
782
+ /**
783
+ * Creates a fallible transformed Type with its own error formatter.
784
+ *
785
+ * ### Example
786
+ *
787
+ * ```ts
788
+ * import {
789
+ * Boolean,
790
+ * String,
791
+ * err,
792
+ * ok,
793
+ * transform,
794
+ * type Result,
795
+ * type TypeError,
796
+ * } from "@evolu/common";
797
+ *
798
+ * interface BooleanFromStringError extends TypeError<"BooleanFromString"> {
799
+ * readonly value: string;
800
+ * }
801
+ *
802
+ * const BooleanFromString = transform(
803
+ * "BooleanFromString",
804
+ * String,
805
+ * Boolean,
806
+ * {
807
+ * from: (value): Result<boolean, BooleanFromStringError> =>
808
+ * value === "true"
809
+ * ? ok(true)
810
+ * : value === "false"
811
+ * ? ok(false)
812
+ * : err({ type: "BooleanFromString", value }),
813
+ * to: (value) => (value ? "true" : "false"),
814
+ * },
815
+ * () => 'Expected "true" or "false".',
816
+ * );
817
+ *
818
+ * expectOk(BooleanFromString.fromUnknown("true"), true);
819
+ * expect(BooleanFromString.to(false)).toBe("false");
820
+ *
821
+ * const invalid = BooleanFromString.fromUnknown("yes");
822
+ * expectErr(invalid, { type: "BooleanFromString", value: "yes" });
823
+ * expect(BooleanFromString.formatError(invalid.error)).toBe(
824
+ * 'Expected "true" or "false".',
825
+ * );
826
+ * ```
827
+ */
783
828
  export declare function transform<Name extends TypeName, ParentType extends ConcreteTypeNode, OutputType extends ConcreteTypeNode, ToOutput extends ParentType["Output"], FromError extends {
784
829
  readonly type: Name;
785
830
  readonly outputError?: never;
@@ -1073,7 +1118,30 @@ interface ObjectTagOutputByName {
1073
1118
  * @group Base
1074
1119
  */
1075
1120
  export declare function objectTag<Name extends keyof ObjectTagOutputByName>(name: ValidateConcreteTypeName<Name>): Type<Name, ObjectTagOutputByName[Name], ObjectTagOutputByName[Name], ObjectTagError<Name>, null, ObjectTagError<Name>, never, ObjectTagOutputByName[Name]>;
1076
- /** Creates an object-tag Type by refining an existing object Type. */
1121
+ /**
1122
+ * Creates an object-tag Type by refining an existing object Type.
1123
+ *
1124
+ * ### Example
1125
+ *
1126
+ * ```ts
1127
+ * import { instanceOf, objectTag } from "@evolu/common";
1128
+ *
1129
+ * class TaggedValue {
1130
+ * readonly [globalThis.Symbol.toStringTag] = "TaggedValue";
1131
+ * }
1132
+ *
1133
+ * const TaggedValueType = objectTag(
1134
+ * "TaggedValue",
1135
+ * instanceOf(TaggedValue),
1136
+ * );
1137
+ * const value = new TaggedValue();
1138
+ * const result = TaggedValueType.fromUnknown(value);
1139
+ *
1140
+ * expectOk(result, value);
1141
+ * expectTypeOf(result.value).toExtend<TaggedValue>();
1142
+ * expect(TaggedValueType.expected).toBe("TaggedValue");
1143
+ * ```
1144
+ */
1077
1145
  export declare function objectTag<Name extends TypeName, OutputType extends ConcreteTypeNode & {
1078
1146
  readonly Output: object;
1079
1147
  }>(name: ValidateConcreteTypeName<Name>, outputType: ValidateOutput<OutputType> & ([ChildTypeNameValidationError<"ObjectTag", OutputType>] extends [never] ? unknown : ChildTypeNameValidationError<"ObjectTag", OutputType>)): ObjectTagType<Name, OutputType>;
@@ -4130,7 +4198,32 @@ type ObjectProperty = ObjectProps[string];
4130
4198
  * @group Objects
4131
4199
  */
4132
4200
  export declare function object<const Props extends ObjectProps>(props: Props, ...validation: [ObjectValidationError<Props>] extends [never] ? [] : [ValidationFailure<ObjectValidationError<Props>>]): StrictObjectType<Props>;
4133
- /** Creates an Object Type with additional record properties. */
4201
+ /**
4202
+ * Creates an Object Type with additional record properties.
4203
+ *
4204
+ * ### Example
4205
+ *
4206
+ * ```ts
4207
+ * import { String, object, record } from "@evolu/common";
4208
+ *
4209
+ * const RequestHeaders = object(
4210
+ * { authorization: String },
4211
+ * record(String, String),
4212
+ * );
4213
+ * const result = RequestHeaders.fromUnknown({
4214
+ * authorization: "Bearer token",
4215
+ * "x-request-id": "request-1",
4216
+ * });
4217
+ *
4218
+ * expectOk(result, {
4219
+ * authorization: "Bearer token",
4220
+ * "x-request-id": "request-1",
4221
+ * });
4222
+ * expectTypeOf(result.value["x-request-id"]).toEqualTypeOf<
4223
+ * string | undefined
4224
+ * >();
4225
+ * ```
4226
+ */
4134
4227
  export declare function object<const Props extends ObjectProps, const Rest extends RecordTypeNode & ConcreteTypeNode>(props: Props, record: Rest, ...validation: [
4135
4228
  ObjectValidationError<Props> | ObjectRecordValidationError<Props, Rest>
4136
4229
  ] extends [never] ? [] : [
@@ -4507,6 +4600,32 @@ export type UnknownResult = typeof UnknownResult.Output;
4507
4600
  * ### Example
4508
4601
  *
4509
4602
  * ```ts
4603
+ * import { String, discriminatedUnion, typed } from "@evolu/common";
4604
+ *
4605
+ * const Loading = typed("Loading");
4606
+ * const Loaded = typed("Loaded", { value: String });
4607
+ * const State = discriminatedUnion(Loading, Loaded);
4608
+ *
4609
+ * expectOk(State.fromUnknown({ type: "Loading" }), { type: "Loading" });
4610
+ * expectOk(State.fromUnknown({ type: "Loaded", value: "Evolu" }), {
4611
+ * type: "Loaded",
4612
+ * value: "Evolu",
4613
+ * });
4614
+ * expect(Loading.is({ type: "Loading", progress: 1 })).toBe(false);
4615
+ * expectTypeOf<typeof Loading.Output>().toExtend<{
4616
+ * readonly type: "Loading";
4617
+ * }>();
4618
+ * ```
4619
+ *
4620
+ * @group Discriminated unions
4621
+ */
4622
+ export declare function typed<const Tag extends TypeName>(tag: ValidateTypedTag<Tag>): TypedType<Tag>;
4623
+ /**
4624
+ * Creates a Tagged Object Type with declared properties.
4625
+ *
4626
+ * ### Example
4627
+ *
4628
+ * ```ts
4510
4629
  * import { String, typed } from "@evolu/common";
4511
4630
  *
4512
4631
  * const Pending = typed("Pending", {
@@ -4518,13 +4637,31 @@ export type UnknownResult = typeof UnknownResult.Output;
4518
4637
  * label: "Waiting",
4519
4638
  * });
4520
4639
  * ```
4521
- *
4522
- * @group Discriminated unions
4523
4640
  */
4524
- export declare function typed<const Tag extends TypeName>(tag: ValidateTypedTag<Tag>): TypedType<Tag>;
4525
- /** Creates a Tagged Object Type with declared properties. */
4526
4641
  export declare function typed<const Tag extends TypeName, const Props extends ObjectProps>(tag: ValidateTypedTag<Tag>, props: Props, ...validation: [TypedValidationError<Props>] extends [never] ? [] : [ValidationFailure<TypedValidationError<Props>>]): TypedType<Tag, Props>;
4527
- /** Creates a Tagged Object Type with additional record properties. */
4642
+ /**
4643
+ * Creates a Tagged Object Type with additional record properties.
4644
+ *
4645
+ * ### Example
4646
+ *
4647
+ * ```ts
4648
+ * import { String, record, typed } from "@evolu/common";
4649
+ *
4650
+ * const Open = typed("Open", { label: String }, record(String, String));
4651
+ * const result = Open.fromUnknown({
4652
+ * type: "Open",
4653
+ * label: "Ready",
4654
+ * note: "Connected",
4655
+ * });
4656
+ *
4657
+ * expectOk(result, {
4658
+ * type: "Open",
4659
+ * label: "Ready",
4660
+ * note: "Connected",
4661
+ * });
4662
+ * expectTypeOf(result.value.note).toEqualTypeOf<string | undefined>();
4663
+ * ```
4664
+ */
4528
4665
  export declare function typed<const Tag extends TypeName, const Props extends ObjectProps, const Rest extends RecordTypeNode & ConcreteTypeNode>(tag: ValidateTypedTag<Tag>, props: Props, record: Rest, ...validation: [
4529
4666
  TypedValidationError<Props> | ObjectRecordValidationError<TypedProps<Tag, Props>, Rest>
4530
4667
  ] extends [never] ? [] : [