@dxos/echo-pipeline 0.1.58-main.e4cedde → 0.1.58-main.f5feb2a

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.
@@ -32,16 +32,11 @@ var src_exports = {};
32
32
  __export(src_exports, {
33
33
  AuthExtension: () => AuthExtension,
34
34
  AuthStatus: () => AuthStatus,
35
- DBError: () => DBError,
36
35
  DataPipeline: () => DataPipeline,
37
36
  DataServiceHost: () => DataServiceHost,
38
37
  DataServiceImpl: () => DataServiceImpl,
39
38
  DataServiceSubscriptions: () => DataServiceSubscriptions,
40
39
  DatabaseHost: () => DatabaseHost,
41
- EntityNotFoundError: () => EntityNotFoundError,
42
- IdentityNotInitializedError: () => IdentityNotInitializedError,
43
- InvalidInvitationError: () => InvalidInvitationError,
44
- InvalidStorageVersionError: () => InvalidStorageVersionError,
45
40
  MOCK_AUTH_PROVIDER: () => MOCK_AUTH_PROVIDER,
46
41
  MOCK_AUTH_VERIFIER: () => MOCK_AUTH_VERIFIER,
47
42
  MetadataStore: () => MetadataStore,
@@ -50,11 +45,9 @@ __export(src_exports, {
50
45
  SnapshotStore: () => SnapshotStore,
51
46
  Space: () => Space,
52
47
  SpaceManager: () => SpaceManager,
53
- SpaceNotFoundError: () => SpaceNotFoundError,
54
48
  SpaceProtocol: () => SpaceProtocol,
55
49
  SpaceProtocolSession: () => SpaceProtocolSession,
56
50
  TimeframeClock: () => TimeframeClock,
57
- UnknownModelError: () => UnknownModelError,
58
51
  codec: () => codec,
59
52
  createMappedFeedWriter: () => createMappedFeedWriter,
60
53
  mapFeedIndexesToTimeframe: () => mapFeedIndexesToTimeframe,
@@ -484,59 +477,9 @@ var DataServiceImpl = class {
484
477
  }
485
478
  };
486
479
 
487
- // packages/core/echo/echo-pipeline/src/errors/errors.ts
488
- var DBError = class extends Error {
489
- constructor(code, message, context) {
490
- super(message ? `${code}: ${message}` : code.toString());
491
- this.code = code;
492
- this.context = context;
493
- Object.setPrototypeOf(this, new.target.prototype);
494
- }
495
- };
496
- var IdentityNotInitializedError = class extends DBError {
497
- constructor() {
498
- super("IDENTITY_NOT_INITIALIZED", "Identity not initialized.");
499
- }
500
- };
501
- var InvalidInvitationError = class extends DBError {
502
- constructor() {
503
- super("INVALID_INVITATION", "Invitation is invalid.");
504
- }
505
- };
506
- var InvalidStorageVersionError = class extends DBError {
507
- constructor(expected, actual) {
508
- super("INVALID_STORAGE_VERSION", "Invalid storage version.", {
509
- expected,
510
- actual
511
- });
512
- }
513
- };
514
- var SpaceNotFoundError = class extends DBError {
515
- constructor(spaceKey) {
516
- super("SPACE_NOT_FOUND", "Space not found.", {
517
- spaceKey
518
- });
519
- }
520
- };
521
- var EntityNotFoundError = class extends DBError {
522
- constructor(entityId) {
523
- super("ITEM_NOT_FOUND", "Item not found.", {
524
- entityId
525
- });
526
- }
527
- };
528
- var UnknownModelError = class extends DBError {
529
- constructor(model) {
530
- super("UNKNOWN_MODEL", "Unknown model.", {
531
- model
532
- });
533
- }
534
- };
535
-
536
480
  // packages/core/echo/echo-pipeline/src/metadata/metadata-store.ts
537
481
  var import_crc_32 = __toESM(require("crc-32"));
538
482
  var import_async2 = require("@dxos/async");
539
- var import_errors = require("@dxos/errors");
540
483
  var import_invariant4 = require("@dxos/invariant");
541
484
  var import_keys3 = require("@dxos/keys");
542
485
  var import_log3 = require("@dxos/log");
@@ -599,12 +542,12 @@ var MetadataStore = class {
599
542
  name: file.filename
600
543
  }, {
601
544
  F: __dxlog_file4,
602
- L: 82,
545
+ L: 81,
603
546
  S: this,
604
547
  C: (f, a) => f(...a)
605
548
  });
606
549
  if (fileLength < dataSize + 8) {
607
- throw new import_errors.DataCorruptionError("Metadata size is smaller than expected.", {
550
+ throw new import_protocols4.DataCorruptionError("Metadata size is smaller than expected.", {
608
551
  fileLength,
609
552
  dataSize
610
553
  });
@@ -612,7 +555,7 @@ var MetadataStore = class {
612
555
  const data = await file.read(8, dataSize);
613
556
  const calculatedChecksum = import_crc_32.default.buf(data);
614
557
  if (calculatedChecksum !== checksum) {
615
- throw new import_errors.DataCorruptionError("Metadata checksum is invalid.");
558
+ throw new import_protocols4.DataCorruptionError("Metadata checksum is invalid.");
616
559
  }
617
560
  return codec2.decode(data);
618
561
  } finally {
@@ -632,7 +575,7 @@ var MetadataStore = class {
632
575
  checksum
633
576
  }, {
634
577
  F: __dxlog_file4,
635
- L: 114,
578
+ L: 113,
636
579
  S: this,
637
580
  C: (f, a) => f(...a)
638
581
  });
@@ -664,7 +607,7 @@ var MetadataStore = class {
664
607
  err
665
608
  }, {
666
609
  F: __dxlog_file4,
667
- L: 145,
610
+ L: 144,
668
611
  S: this,
669
612
  C: (f, a) => f(...a)
670
613
  });
@@ -681,7 +624,7 @@ var MetadataStore = class {
681
624
  err
682
625
  }, {
683
626
  F: __dxlog_file4,
684
- L: 157,
627
+ L: 156,
685
628
  S: this,
686
629
  C: (f, a) => f(...a)
687
630
  });
@@ -711,7 +654,7 @@ var MetadataStore = class {
711
654
  err
712
655
  }, {
713
656
  F: __dxlog_file4,
714
- L: 186,
657
+ L: 185,
715
658
  S: this,
716
659
  C: (f, a) => f(...a)
717
660
  });
@@ -732,7 +675,7 @@ var MetadataStore = class {
732
675
  const space = this.spaces.find((space2) => space2.key === spaceKey);
733
676
  (0, import_invariant4.invariant)(space, "Space not found", {
734
677
  F: __dxlog_file4,
735
- L: 208,
678
+ L: 207,
736
679
  S: this,
737
680
  A: [
738
681
  "space",
@@ -756,7 +699,7 @@ var MetadataStore = class {
756
699
  async clear() {
757
700
  (0, import_log3.log)("clearing all metadata", void 0, {
758
701
  F: __dxlog_file4,
759
- L: 227,
702
+ L: 226,
760
703
  S: this,
761
704
  C: (f, a) => f(...a)
762
705
  });
@@ -769,7 +712,7 @@ var MetadataStore = class {
769
712
  async setIdentityRecord(record) {
770
713
  (0, import_invariant4.invariant)(!this._metadata.identity, "Cannot overwrite existing identity in metadata", {
771
714
  F: __dxlog_file4,
772
- L: 237,
715
+ L: 236,
773
716
  S: this,
774
717
  A: [
775
718
  "!this._metadata.identity",
@@ -783,7 +726,7 @@ var MetadataStore = class {
783
726
  async addSpace(record) {
784
727
  (0, import_invariant4.invariant)(!(this._metadata.spaces ?? []).find((space) => space.key === record.key), "Cannot overwrite existing space in metadata", {
785
728
  F: __dxlog_file4,
786
- L: 245,
729
+ L: 244,
787
730
  S: this,
788
731
  A: [
789
732
  "!(this._metadata.spaces ?? []).find((space) => space.key === record.key)",
@@ -1771,9 +1714,9 @@ var import_async7 = require("@dxos/async");
1771
1714
  var import_context6 = require("@dxos/context");
1772
1715
  var import_credentials3 = require("@dxos/credentials");
1773
1716
  var import_echo_db3 = require("@dxos/echo-db");
1774
- var import_errors2 = require("@dxos/errors");
1775
1717
  var import_invariant8 = require("@dxos/invariant");
1776
1718
  var import_log9 = require("@dxos/log");
1719
+ var import_protocols6 = require("@dxos/protocols");
1777
1720
  var import_timeframe4 = require("@dxos/timeframe");
1778
1721
  var import_tracing2 = require("@dxos/tracing");
1779
1722
  var import_util6 = require("@dxos/util");
@@ -1845,7 +1788,7 @@ var DataPipeline = class DataPipeline2 {
1845
1788
  write: (data, options) => {
1846
1789
  (0, import_invariant8.invariant)(this._pipeline, "Pipeline is not initialized.", {
1847
1790
  F: __dxlog_file10,
1848
- L: 154,
1791
+ L: 153,
1849
1792
  S: this,
1850
1793
  A: [
1851
1794
  "this._pipeline",
@@ -1854,7 +1797,7 @@ var DataPipeline = class DataPipeline2 {
1854
1797
  });
1855
1798
  (0, import_invariant8.invariant)(this.currentEpoch, "Epoch is not initialized.", {
1856
1799
  F: __dxlog_file10,
1857
- L: 155,
1800
+ L: 154,
1858
1801
  S: this,
1859
1802
  A: [
1860
1803
  "this.currentEpoch",
@@ -1880,7 +1823,7 @@ var DataPipeline = class DataPipeline2 {
1880
1823
  }
1881
1824
  (0, import_log9.log)("close", void 0, {
1882
1825
  F: __dxlog_file10,
1883
- L: 179,
1826
+ L: 178,
1884
1827
  S: this,
1885
1828
  C: (f, a) => f(...a)
1886
1829
  });
@@ -1895,7 +1838,7 @@ var DataPipeline = class DataPipeline2 {
1895
1838
  } catch (err) {
1896
1839
  import_log9.log.catch(err, void 0, {
1897
1840
  F: __dxlog_file10,
1898
- L: 192,
1841
+ L: 191,
1899
1842
  S: this,
1900
1843
  C: (f, a) => f(...a)
1901
1844
  });
@@ -1920,7 +1863,7 @@ var DataPipeline = class DataPipeline2 {
1920
1863
  let messageCounter = 0;
1921
1864
  (0, import_invariant8.invariant)(this._pipeline, "Pipeline is not initialized.", {
1922
1865
  F: __dxlog_file10,
1923
- L: 217,
1866
+ L: 216,
1924
1867
  S: this,
1925
1868
  A: [
1926
1869
  "this._pipeline",
@@ -1936,7 +1879,7 @@ var DataPipeline = class DataPipeline2 {
1936
1879
  seq
1937
1880
  }, {
1938
1881
  F: __dxlog_file10,
1939
- L: 223,
1882
+ L: 222,
1940
1883
  S: this,
1941
1884
  C: (f, a) => f(...a)
1942
1885
  });
@@ -1948,7 +1891,7 @@ var DataPipeline = class DataPipeline2 {
1948
1891
  feedKey
1949
1892
  }, {
1950
1893
  F: __dxlog_file10,
1951
- L: 229,
1894
+ L: 228,
1952
1895
  S: this,
1953
1896
  C: (f, a) => f(...a)
1954
1897
  });
@@ -1971,7 +1914,7 @@ var DataPipeline = class DataPipeline2 {
1971
1914
  spaceKey: this._params.spaceKey.toHex()
1972
1915
  }, {
1973
1916
  F: __dxlog_file10,
1974
- L: 246,
1917
+ L: 245,
1975
1918
  S: this,
1976
1919
  C: (f, a) => f(...a)
1977
1920
  });
@@ -1980,7 +1923,7 @@ var DataPipeline = class DataPipeline2 {
1980
1923
  } catch (err) {
1981
1924
  import_log9.log.catch(err, void 0, {
1982
1925
  F: __dxlog_file10,
1983
- L: 256,
1926
+ L: 255,
1984
1927
  S: this,
1985
1928
  C: (f, a) => f(...a)
1986
1929
  });
@@ -1995,7 +1938,7 @@ var DataPipeline = class DataPipeline2 {
1995
1938
  _createSnapshot() {
1996
1939
  (0, import_invariant8.invariant)(this.databaseHost, "Database backend is not initialized.", {
1997
1940
  F: __dxlog_file10,
1998
- L: 270,
1941
+ L: 269,
1999
1942
  S: this,
2000
1943
  A: [
2001
1944
  "this.databaseHost",
@@ -2024,7 +1967,7 @@ var DataPipeline = class DataPipeline2 {
2024
1967
  } catch (err) {
2025
1968
  import_log9.log.warn("Failed to cache properties", err, {
2026
1969
  F: __dxlog_file10,
2027
- L: 299,
1970
+ L: 298,
2028
1971
  S: this,
2029
1972
  C: (f, a) => f(...a)
2030
1973
  });
@@ -2050,17 +1993,17 @@ var DataPipeline = class DataPipeline2 {
2050
1993
  await this._epochCtx?.dispose();
2051
1994
  const ctx = new import_context6.Context({
2052
1995
  onError: (err) => {
2053
- if (err instanceof import_errors2.CancelledError) {
1996
+ if (err instanceof import_protocols6.CancelledError) {
2054
1997
  (0, import_log9.log)("Epoch processing cancelled.", void 0, {
2055
1998
  F: __dxlog_file10,
2056
- L: 335,
1999
+ L: 334,
2057
2000
  S: this,
2058
2001
  C: (f, a) => f(...a)
2059
2002
  });
2060
2003
  } else {
2061
2004
  import_log9.log.catch(err, void 0, {
2062
2005
  F: __dxlog_file10,
2063
- L: 337,
2006
+ L: 336,
2064
2007
  S: this,
2065
2008
  C: (f, a) => f(...a)
2066
2009
  });
@@ -2080,7 +2023,7 @@ var DataPipeline = class DataPipeline2 {
2080
2023
  async _processEpoch(ctx, epoch) {
2081
2024
  (0, import_invariant8.invariant)(this._isOpen, "Space is closed.", {
2082
2025
  F: __dxlog_file10,
2083
- L: 356,
2026
+ L: 355,
2084
2027
  S: this,
2085
2028
  A: [
2086
2029
  "this._isOpen",
@@ -2089,7 +2032,7 @@ var DataPipeline = class DataPipeline2 {
2089
2032
  });
2090
2033
  (0, import_invariant8.invariant)(this._pipeline, void 0, {
2091
2034
  F: __dxlog_file10,
2092
- L: 357,
2035
+ L: 356,
2093
2036
  S: this,
2094
2037
  A: [
2095
2038
  "this._pipeline",
@@ -2101,7 +2044,7 @@ var DataPipeline = class DataPipeline2 {
2101
2044
  epoch: (0, import_log9.omit)(epoch, "proof")
2102
2045
  }, {
2103
2046
  F: __dxlog_file10,
2104
- L: 360,
2047
+ L: 359,
2105
2048
  S: this,
2106
2049
  C: (f, a) => f(...a)
2107
2050
  });
@@ -2111,7 +2054,7 @@ var DataPipeline = class DataPipeline2 {
2111
2054
  }
2112
2055
  (0, import_log9.log)("restarting pipeline from epoch", void 0, {
2113
2056
  F: __dxlog_file10,
2114
- L: 366,
2057
+ L: 365,
2115
2058
  S: this,
2116
2059
  C: (f, a) => f(...a)
2117
2060
  });
@@ -2122,7 +2065,7 @@ var DataPipeline = class DataPipeline2 {
2122
2065
  async waitUntilTimeframe(timeframe) {
2123
2066
  (0, import_invariant8.invariant)(this._pipeline, "Pipeline is not initialized.", {
2124
2067
  F: __dxlog_file10,
2125
- L: 373,
2068
+ L: 372,
2126
2069
  S: this,
2127
2070
  A: [
2128
2071
  "this._pipeline",
@@ -2134,7 +2077,7 @@ var DataPipeline = class DataPipeline2 {
2134
2077
  async createEpoch() {
2135
2078
  (0, import_invariant8.invariant)(this._pipeline, void 0, {
2136
2079
  F: __dxlog_file10,
2137
- L: 379,
2080
+ L: 378,
2138
2081
  S: this,
2139
2082
  A: [
2140
2083
  "this._pipeline",
@@ -2143,7 +2086,7 @@ var DataPipeline = class DataPipeline2 {
2143
2086
  });
2144
2087
  (0, import_invariant8.invariant)(this.currentEpoch, void 0, {
2145
2088
  F: __dxlog_file10,
2146
- L: 380,
2089
+ L: 379,
2147
2090
  S: this,
2148
2091
  A: [
2149
2092
  "this.currentEpoch",
@@ -2174,7 +2117,7 @@ var DataPipeline = class DataPipeline2 {
2174
2117
  } catch (err) {
2175
2118
  import_log9.log.catch(err, void 0, {
2176
2119
  F: __dxlog_file10,
2177
- L: 410,
2120
+ L: 409,
2178
2121
  S: this,
2179
2122
  C: (f, a) => f(...a)
2180
2123
  });
@@ -2459,7 +2402,7 @@ var import_async9 = require("@dxos/async");
2459
2402
  var import_debug4 = require("@dxos/debug");
2460
2403
  var import_keys7 = require("@dxos/keys");
2461
2404
  var import_log12 = require("@dxos/log");
2462
- var import_protocols6 = require("@dxos/protocols");
2405
+ var import_protocols7 = require("@dxos/protocols");
2463
2406
  var import_util9 = require("@dxos/util");
2464
2407
 
2465
2408
  // packages/core/echo/echo-pipeline/src/space/space-protocol.ts
@@ -2703,7 +2646,7 @@ var SpaceManager = class SpaceManager2 {
2703
2646
  ].map((space) => space.close()));
2704
2647
  }
2705
2648
  async constructSpace({ metadata, swarmIdentity, onNetworkConnection, onAuthFailure, memberKey }) {
2706
- import_log12.log.trace("dxos.echo.space-manager.construct-space", import_protocols6.trace.begin({
2649
+ import_log12.log.trace("dxos.echo.space-manager.construct-space", import_protocols7.trace.begin({
2707
2650
  id: this._instanceId
2708
2651
  }), {
2709
2652
  F: __dxlog_file13,
@@ -2741,7 +2684,7 @@ var SpaceManager = class SpaceManager2 {
2741
2684
  memberKey
2742
2685
  });
2743
2686
  this._spaces.set(space.key, space);
2744
- import_log12.log.trace("dxos.echo.space-manager.construct-space", import_protocols6.trace.end({
2687
+ import_log12.log.trace("dxos.echo.space-manager.construct-space", import_protocols7.trace.end({
2745
2688
  id: this._instanceId
2746
2689
  }), {
2747
2690
  F: __dxlog_file13,
@@ -2765,16 +2708,11 @@ SpaceManager = _ts_decorate9([
2765
2708
  0 && (module.exports = {
2766
2709
  AuthExtension,
2767
2710
  AuthStatus,
2768
- DBError,
2769
2711
  DataPipeline,
2770
2712
  DataServiceHost,
2771
2713
  DataServiceImpl,
2772
2714
  DataServiceSubscriptions,
2773
2715
  DatabaseHost,
2774
- EntityNotFoundError,
2775
- IdentityNotInitializedError,
2776
- InvalidInvitationError,
2777
- InvalidStorageVersionError,
2778
2716
  MOCK_AUTH_PROVIDER,
2779
2717
  MOCK_AUTH_VERIFIER,
2780
2718
  MetadataStore,
@@ -2783,11 +2721,9 @@ SpaceManager = _ts_decorate9([
2783
2721
  SnapshotStore,
2784
2722
  Space,
2785
2723
  SpaceManager,
2786
- SpaceNotFoundError,
2787
2724
  SpaceProtocol,
2788
2725
  SpaceProtocolSession,
2789
2726
  TimeframeClock,
2790
- UnknownModelError,
2791
2727
  codec,
2792
2728
  createMappedFeedWriter,
2793
2729
  mapFeedIndexesToTimeframe,