@dxos/echo-pipeline 0.4.7 → 0.4.8-main.05fda5d
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/lib/browser/{chunk-UIMWNUNO.mjs → chunk-LED7X4WK.mjs} +54 -27
- package/dist/lib/browser/chunk-LED7X4WK.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +4 -4
- package/dist/lib/browser/testing/index.mjs.map +2 -2
- package/dist/lib/node/{chunk-Z3IT3GUD.cjs → chunk-UKREXVZX.cjs} +59 -32
- package/dist/lib/node/chunk-UKREXVZX.cjs.map +7 -0
- package/dist/lib/node/index.cjs +29 -29
- package/dist/lib/node/index.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +19 -19
- package/dist/lib/node/testing/index.cjs.map +2 -2
- package/dist/types/src/metadata/metadata-store.d.ts +6 -2
- package/dist/types/src/metadata/metadata-store.d.ts.map +1 -1
- package/dist/types/src/testing/database-test-rig.d.ts.map +1 -1
- package/package.json +33 -33
- package/src/automerge/automerge-host.ts +1 -1
- package/src/metadata/metadata-store.ts +46 -3
- package/src/testing/database-test-rig.ts +2 -0
- package/dist/lib/browser/chunk-UIMWNUNO.mjs.map +0 -7
- package/dist/lib/node/chunk-Z3IT3GUD.cjs.map +0 -7
- package/dist/types/src/tests/database-unit.test.d.ts +0 -2
- package/dist/types/src/tests/database-unit.test.d.ts.map +0 -1
- package/src/tests/database-unit.test.ts +0 -325
|
@@ -26,8 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
29
|
+
var chunk_UKREXVZX_exports = {};
|
|
30
|
+
__export(chunk_UKREXVZX_exports, {
|
|
31
31
|
AuthExtension: () => AuthExtension,
|
|
32
32
|
AuthStatus: () => AuthStatus,
|
|
33
33
|
AutomergeHost: () => AutomergeHost,
|
|
@@ -57,7 +57,7 @@ __export(chunk_Z3IT3GUD_exports, {
|
|
|
57
57
|
startAfter: () => startAfter,
|
|
58
58
|
valueEncoding: () => valueEncoding
|
|
59
59
|
});
|
|
60
|
-
module.exports = __toCommonJS(
|
|
60
|
+
module.exports = __toCommonJS(chunk_UKREXVZX_exports);
|
|
61
61
|
var import_hypercore = require("@dxos/hypercore");
|
|
62
62
|
var import_protocols = require("@dxos/protocols");
|
|
63
63
|
var import_invariant = require("@dxos/invariant");
|
|
@@ -83,6 +83,7 @@ var import_log2 = require("@dxos/log");
|
|
|
83
83
|
var import_util2 = require("@dxos/util");
|
|
84
84
|
var import_crc_32 = __toESM(require("crc-32"));
|
|
85
85
|
var import_async2 = require("@dxos/async");
|
|
86
|
+
var import_context3 = require("@dxos/context");
|
|
86
87
|
var import_invariant4 = require("@dxos/invariant");
|
|
87
88
|
var import_keys3 = require("@dxos/keys");
|
|
88
89
|
var import_log3 = require("@dxos/log");
|
|
@@ -94,7 +95,7 @@ var import_debug2 = require("@dxos/debug");
|
|
|
94
95
|
var import_log4 = require("@dxos/log");
|
|
95
96
|
var import_timeframe = require("@dxos/timeframe");
|
|
96
97
|
var import_async4 = require("@dxos/async");
|
|
97
|
-
var
|
|
98
|
+
var import_context4 = require("@dxos/context");
|
|
98
99
|
var import_debug3 = require("@dxos/debug");
|
|
99
100
|
var import_feed_store = require("@dxos/feed-store");
|
|
100
101
|
var import_invariant5 = require("@dxos/invariant");
|
|
@@ -105,14 +106,14 @@ var import_util4 = require("@dxos/util");
|
|
|
105
106
|
var import_invariant6 = require("@dxos/invariant");
|
|
106
107
|
var import_log6 = require("@dxos/log");
|
|
107
108
|
var import_async5 = require("@dxos/async");
|
|
108
|
-
var
|
|
109
|
+
var import_context5 = require("@dxos/context");
|
|
109
110
|
var import_crypto2 = require("@dxos/crypto");
|
|
110
111
|
var import_invariant7 = require("@dxos/invariant");
|
|
111
112
|
var import_log7 = require("@dxos/log");
|
|
112
113
|
var import_protocols5 = require("@dxos/protocols");
|
|
113
114
|
var import_teleport = require("@dxos/teleport");
|
|
114
115
|
var import_async6 = require("@dxos/async");
|
|
115
|
-
var
|
|
116
|
+
var import_context6 = require("@dxos/context");
|
|
116
117
|
var import_credentials = require("@dxos/credentials");
|
|
117
118
|
var import_echo_db3 = require("@dxos/echo-db");
|
|
118
119
|
var import_invariant8 = require("@dxos/invariant");
|
|
@@ -128,7 +129,7 @@ var import_credentials2 = require("@dxos/protocols/proto/dxos/halo/credentials")
|
|
|
128
129
|
var import_tracing2 = require("@dxos/tracing");
|
|
129
130
|
var import_util6 = require("@dxos/util");
|
|
130
131
|
var import_async8 = require("@dxos/async");
|
|
131
|
-
var
|
|
132
|
+
var import_context7 = require("@dxos/context");
|
|
132
133
|
var import_credentials3 = require("@dxos/credentials");
|
|
133
134
|
var import_keys5 = require("@dxos/keys");
|
|
134
135
|
var import_log10 = require("@dxos/log");
|
|
@@ -166,7 +167,7 @@ var import_teleport_extension_automerge_replicator = require("@dxos/teleport-ext
|
|
|
166
167
|
var import_automerge = require("@dxos/automerge/automerge");
|
|
167
168
|
var import_automerge_repo4 = require("@dxos/automerge/automerge-repo");
|
|
168
169
|
var import_automerge_repo_storage_indexeddb = require("@dxos/automerge/automerge-repo-storage-indexeddb");
|
|
169
|
-
var
|
|
170
|
+
var import_context8 = require("@dxos/context");
|
|
170
171
|
var import_keys8 = require("@dxos/keys");
|
|
171
172
|
var import_log15 = require("@dxos/log");
|
|
172
173
|
var import_protocols8 = require("@dxos/protocols");
|
|
@@ -629,6 +630,7 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
629
630
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
630
631
|
}
|
|
631
632
|
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/metadata/metadata-store.ts";
|
|
633
|
+
var EXPIRED_INVITATION_CLEANUP_INTERVAL = 60 * 60 * 1e3;
|
|
632
634
|
var emptyEchoMetadata = () => ({
|
|
633
635
|
version: import_protocols4.STORAGE_VERSION,
|
|
634
636
|
spaces: [],
|
|
@@ -644,6 +646,7 @@ var MetadataStore = class {
|
|
|
644
646
|
this._spaceLargeMetadata = new import_util3.ComplexMap(import_keys3.PublicKey.hash);
|
|
645
647
|
this._metadataFile = void 0;
|
|
646
648
|
this.update = new import_async2.Event();
|
|
649
|
+
this._invitationCleanupCtx = new import_context3.Context();
|
|
647
650
|
this._directory = directory;
|
|
648
651
|
}
|
|
649
652
|
get metadata() {
|
|
@@ -673,7 +676,7 @@ var MetadataStore = class {
|
|
|
673
676
|
name: file.filename
|
|
674
677
|
}, {
|
|
675
678
|
F: __dxlog_file4,
|
|
676
|
-
L:
|
|
679
|
+
L: 89,
|
|
677
680
|
S: this,
|
|
678
681
|
C: (f, a) => f(...a)
|
|
679
682
|
});
|
|
@@ -709,12 +712,13 @@ var MetadataStore = class {
|
|
|
709
712
|
checksum
|
|
710
713
|
}, {
|
|
711
714
|
F: __dxlog_file4,
|
|
712
|
-
L:
|
|
715
|
+
L: 124,
|
|
713
716
|
S: this,
|
|
714
717
|
C: (f, a) => f(...a)
|
|
715
718
|
});
|
|
716
719
|
}
|
|
717
720
|
async close() {
|
|
721
|
+
await this._invitationCleanupCtx.dispose();
|
|
718
722
|
await this.flush();
|
|
719
723
|
await this._metadataFile?.close();
|
|
720
724
|
this._metadataFile = void 0;
|
|
@@ -741,7 +745,7 @@ var MetadataStore = class {
|
|
|
741
745
|
err
|
|
742
746
|
}, {
|
|
743
747
|
F: __dxlog_file4,
|
|
744
|
-
L:
|
|
748
|
+
L: 156,
|
|
745
749
|
S: this,
|
|
746
750
|
C: (f, a) => f(...a)
|
|
747
751
|
});
|
|
@@ -758,12 +762,19 @@ var MetadataStore = class {
|
|
|
758
762
|
err
|
|
759
763
|
}, {
|
|
760
764
|
F: __dxlog_file4,
|
|
761
|
-
L:
|
|
765
|
+
L: 168,
|
|
762
766
|
S: this,
|
|
763
767
|
C: (f, a) => f(...a)
|
|
764
768
|
});
|
|
765
769
|
}
|
|
766
770
|
});
|
|
771
|
+
(0, import_async2.scheduleTaskInterval)(this._invitationCleanupCtx, async () => {
|
|
772
|
+
for (const invitation of this.getInvitations()) {
|
|
773
|
+
if (invitation.created && invitation.lifetime && invitation.lifetime !== 0 && invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
|
|
774
|
+
await this.removeInvitation(invitation.invitationId);
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
}, EXPIRED_INVITATION_CLEANUP_INTERVAL);
|
|
767
778
|
}
|
|
768
779
|
async _save() {
|
|
769
780
|
const data = {
|
|
@@ -788,7 +799,7 @@ var MetadataStore = class {
|
|
|
788
799
|
err
|
|
789
800
|
}, {
|
|
790
801
|
F: __dxlog_file4,
|
|
791
|
-
L:
|
|
802
|
+
L: 215,
|
|
792
803
|
S: this,
|
|
793
804
|
C: (f, a) => f(...a)
|
|
794
805
|
});
|
|
@@ -809,7 +820,7 @@ var MetadataStore = class {
|
|
|
809
820
|
const space = this.spaces.find((space2) => space2.key === spaceKey);
|
|
810
821
|
(0, import_invariant4.invariant)(space, "Space not found", {
|
|
811
822
|
F: __dxlog_file4,
|
|
812
|
-
L:
|
|
823
|
+
L: 237,
|
|
813
824
|
S: this,
|
|
814
825
|
A: [
|
|
815
826
|
"space",
|
|
@@ -833,7 +844,7 @@ var MetadataStore = class {
|
|
|
833
844
|
async clear() {
|
|
834
845
|
(0, import_log3.log)("clearing all metadata", void 0, {
|
|
835
846
|
F: __dxlog_file4,
|
|
836
|
-
L:
|
|
847
|
+
L: 256,
|
|
837
848
|
S: this,
|
|
838
849
|
C: (f, a) => f(...a)
|
|
839
850
|
});
|
|
@@ -846,7 +857,7 @@ var MetadataStore = class {
|
|
|
846
857
|
async setIdentityRecord(record) {
|
|
847
858
|
(0, import_invariant4.invariant)(!this._metadata.identity, "Cannot overwrite existing identity in metadata", {
|
|
848
859
|
F: __dxlog_file4,
|
|
849
|
-
L:
|
|
860
|
+
L: 266,
|
|
850
861
|
S: this,
|
|
851
862
|
A: [
|
|
852
863
|
"!this._metadata.identity",
|
|
@@ -857,10 +868,26 @@ var MetadataStore = class {
|
|
|
857
868
|
await this._save();
|
|
858
869
|
await this.flush();
|
|
859
870
|
}
|
|
871
|
+
getInvitations() {
|
|
872
|
+
return this._metadata.invitations ?? [];
|
|
873
|
+
}
|
|
874
|
+
async addInvitation(invitation) {
|
|
875
|
+
if (this._metadata.invitations?.find((i) => i.invitationId === invitation.invitationId)) {
|
|
876
|
+
return;
|
|
877
|
+
}
|
|
878
|
+
(this._metadata.invitations ??= []).push(invitation);
|
|
879
|
+
await this._save();
|
|
880
|
+
await this.flush();
|
|
881
|
+
}
|
|
882
|
+
async removeInvitation(invitationId) {
|
|
883
|
+
this._metadata.invitations = (this._metadata.invitations ?? []).filter((i) => i.invitationId !== invitationId);
|
|
884
|
+
await this._save();
|
|
885
|
+
await this.flush();
|
|
886
|
+
}
|
|
860
887
|
async addSpace(record) {
|
|
861
888
|
(0, import_invariant4.invariant)(!(this._metadata.spaces ?? []).find((space) => space.key === record.key), "Cannot overwrite existing space in metadata", {
|
|
862
889
|
F: __dxlog_file4,
|
|
863
|
-
L:
|
|
890
|
+
L: 294,
|
|
864
891
|
S: this,
|
|
865
892
|
A: [
|
|
866
893
|
"!(this._metadata.spaces ?? []).find((space) => space.key === record.key)",
|
|
@@ -1047,7 +1074,7 @@ var PipelineState = class {
|
|
|
1047
1074
|
constructor(_feeds, _timeframeClock) {
|
|
1048
1075
|
this._feeds = _feeds;
|
|
1049
1076
|
this._timeframeClock = _timeframeClock;
|
|
1050
|
-
this._ctx = new
|
|
1077
|
+
this._ctx = new import_context4.Context();
|
|
1051
1078
|
this.timeframeUpdate = this._timeframeClock.update;
|
|
1052
1079
|
this.stalled = new import_async4.Event();
|
|
1053
1080
|
this._startTimeframe = new import_timeframe2.Timeframe();
|
|
@@ -1095,7 +1122,7 @@ var PipelineState = class {
|
|
|
1095
1122
|
*
|
|
1096
1123
|
* @param timeout Timeout in milliseconds to specify the maximum wait time.
|
|
1097
1124
|
*/
|
|
1098
|
-
async waitUntilReachedTargetTimeframe({ ctx = new
|
|
1125
|
+
async waitUntilReachedTargetTimeframe({ ctx = new import_context4.Context(), timeout, breakOnStall = true } = {}) {
|
|
1099
1126
|
(0, import_log5.log)("waitUntilReachedTargetTimeframe", {
|
|
1100
1127
|
timeout,
|
|
1101
1128
|
current: this.timeframe,
|
|
@@ -1117,8 +1144,8 @@ var PipelineState = class {
|
|
|
1117
1144
|
let done = false;
|
|
1118
1145
|
if (timeout) {
|
|
1119
1146
|
return Promise.race([
|
|
1120
|
-
(0,
|
|
1121
|
-
(0,
|
|
1147
|
+
(0, import_context4.rejectOnDispose)(ctx),
|
|
1148
|
+
(0, import_context4.rejectOnDispose)(this._ctx),
|
|
1122
1149
|
this._reachedTargetPromise.then(() => {
|
|
1123
1150
|
done = true;
|
|
1124
1151
|
this._reachedTarget = true;
|
|
@@ -1260,7 +1287,7 @@ var Pipeline = class {
|
|
|
1260
1287
|
await this._feedSetIterator?.close();
|
|
1261
1288
|
await this._processingTrigger.wait();
|
|
1262
1289
|
await this._state._ctx.dispose();
|
|
1263
|
-
this._state._ctx = new
|
|
1290
|
+
this._state._ctx = new import_context4.Context();
|
|
1264
1291
|
this._state._reachedTargetPromise = void 0;
|
|
1265
1292
|
this._state._reachedTarget = false;
|
|
1266
1293
|
this._isStarted = false;
|
|
@@ -1455,7 +1482,7 @@ var AuthExtension = class extends import_teleport.RpcExtension {
|
|
|
1455
1482
|
timeout: 60 * 1e3
|
|
1456
1483
|
});
|
|
1457
1484
|
this._authParams = _authParams;
|
|
1458
|
-
this._ctx = new
|
|
1485
|
+
this._ctx = new import_context5.Context({
|
|
1459
1486
|
onError: (err) => {
|
|
1460
1487
|
import_log7.log.catch(err, void 0, {
|
|
1461
1488
|
F: __dxlog_file8,
|
|
@@ -1557,7 +1584,7 @@ var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL = 5e3;
|
|
|
1557
1584
|
var DataPipeline = class {
|
|
1558
1585
|
constructor(_params) {
|
|
1559
1586
|
this._params = _params;
|
|
1560
|
-
this._ctx = new
|
|
1587
|
+
this._ctx = new import_context6.Context();
|
|
1561
1588
|
this._pipeline = void 0;
|
|
1562
1589
|
this._targetTimeframe = void 0;
|
|
1563
1590
|
this._lastAutomaticSnapshotTimeframe = new import_timeframe3.Timeframe();
|
|
@@ -1665,7 +1692,7 @@ var DataPipeline = class {
|
|
|
1665
1692
|
}
|
|
1666
1693
|
await this.databaseHost?.close();
|
|
1667
1694
|
await this.itemManager?.destroy();
|
|
1668
|
-
this._ctx = new
|
|
1695
|
+
this._ctx = new import_context6.Context();
|
|
1669
1696
|
this._pipeline = void 0;
|
|
1670
1697
|
this._targetTimeframe = void 0;
|
|
1671
1698
|
this._lastAutomaticSnapshotTimeframe = new import_timeframe3.Timeframe();
|
|
@@ -1812,7 +1839,7 @@ var DataPipeline = class {
|
|
|
1812
1839
|
return;
|
|
1813
1840
|
}
|
|
1814
1841
|
await this._epochCtx?.dispose();
|
|
1815
|
-
const ctx = new
|
|
1842
|
+
const ctx = new import_context6.Context({
|
|
1816
1843
|
onError: (err) => {
|
|
1817
1844
|
if (err instanceof import_protocols6.CancelledError) {
|
|
1818
1845
|
(0, import_log8.log)("Epoch processing cancelled.", void 0, {
|
|
@@ -2012,7 +2039,7 @@ var CONTROL_PIPELINE_SNAPSHOT_DELAY = 1e4;
|
|
|
2012
2039
|
var USE_SNAPSHOTS = true;
|
|
2013
2040
|
var ControlPipeline = class {
|
|
2014
2041
|
constructor({ spaceKey, genesisFeed, feedProvider, metadataStore }) {
|
|
2015
|
-
this._ctx = new
|
|
2042
|
+
this._ctx = new import_context7.Context();
|
|
2016
2043
|
this._lastTimeframeSaveTime = Date.now();
|
|
2017
2044
|
this.onFeedAdmitted = new import_util7.Callback();
|
|
2018
2045
|
this._usage = new import_tracing3.TimeUsageCounter();
|
|
@@ -2087,7 +2114,7 @@ var ControlPipeline = class {
|
|
|
2087
2114
|
C: (f, a) => f(...a)
|
|
2088
2115
|
});
|
|
2089
2116
|
setTimeout(async () => {
|
|
2090
|
-
void this._consumePipeline(new
|
|
2117
|
+
void this._consumePipeline(new import_context7.Context());
|
|
2091
2118
|
});
|
|
2092
2119
|
await this._pipeline.start();
|
|
2093
2120
|
(0, import_log10.log)("started", void 0, {
|
|
@@ -3129,7 +3156,7 @@ function _ts_decorate9(decorators, target, key, desc) {
|
|
|
3129
3156
|
var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/automerge-host.ts";
|
|
3130
3157
|
var AutomergeHost = class {
|
|
3131
3158
|
constructor({ directory, metadata }) {
|
|
3132
|
-
this._ctx = new
|
|
3159
|
+
this._ctx = new import_context8.Context();
|
|
3133
3160
|
this._authorizedDevices = new import_util11.ComplexMap(import_keys8.PublicKey.hash);
|
|
3134
3161
|
this._updatingMetadata = /* @__PURE__ */ new Map();
|
|
3135
3162
|
this._requestedDocs = /* @__PURE__ */ new Set();
|
|
@@ -3157,7 +3184,7 @@ var AutomergeHost = class {
|
|
|
3157
3184
|
// Hosts, running in the worker, don't share documents unless requested by other peers.
|
|
3158
3185
|
sharePolicy: async (peerId, documentId) => {
|
|
3159
3186
|
if (peerId.startsWith("client-")) {
|
|
3160
|
-
return
|
|
3187
|
+
return false;
|
|
3161
3188
|
}
|
|
3162
3189
|
if (!documentId) {
|
|
3163
3190
|
return false;
|
|
@@ -3274,7 +3301,7 @@ var AutomergeHost = class {
|
|
|
3274
3301
|
return;
|
|
3275
3302
|
}
|
|
3276
3303
|
const markingDirtyPromise = Promise.all(objectIds.map(async (objectId) => {
|
|
3277
|
-
await (0,
|
|
3304
|
+
await (0, import_context8.cancelWithContext)(this._ctx, this._metadata.markDirty(import_protocols8.idCodec.encode({
|
|
3278
3305
|
documentId: event.handle.documentId,
|
|
3279
3306
|
objectId
|
|
3280
3307
|
}), lastAvailableHash));
|
|
@@ -3416,4 +3443,4 @@ var getInlineChanges = (event) => {
|
|
|
3416
3443
|
startAfter,
|
|
3417
3444
|
valueEncoding
|
|
3418
3445
|
});
|
|
3419
|
-
//# sourceMappingURL=chunk-
|
|
3446
|
+
//# sourceMappingURL=chunk-UKREXVZX.cjs.map
|