@dxos/echo-pipeline 0.1.51-main.b7fee56 → 0.1.51-main.b9e09c2
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-CSFWTLPD.mjs → chunk-NNHUIDTY.mjs} +100 -42
- package/dist/lib/browser/chunk-NNHUIDTY.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 +1 -1
- package/dist/lib/node/index.cjs +104 -46
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +106 -48
- package/dist/lib/node/testing/index.cjs.map +3 -3
- package/dist/types/src/metadata/metadata-store.d.ts +2 -1
- package/dist/types/src/metadata/metadata-store.d.ts.map +1 -1
- package/dist/types/src/space/control-pipeline.d.ts +9 -1
- package/dist/types/src/space/control-pipeline.d.ts.map +1 -1
- package/dist/types/src/space/data-pipeline.d.ts +1 -0
- package/dist/types/src/space/data-pipeline.d.ts.map +1 -1
- package/dist/types/src/space/space.d.ts.map +1 -1
- package/package.json +30 -30
- package/src/metadata/metadata-store.ts +12 -1
- package/src/space/control-pipeline.test.ts +4 -0
- package/src/space/control-pipeline.ts +36 -1
- package/src/space/data-pipeline.ts +22 -6
- package/src/space/space.ts +3 -2
- package/dist/lib/browser/chunk-CSFWTLPD.mjs.map +0 -7
|
@@ -121,6 +121,10 @@ var MetadataStore = class {
|
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
_getSpace(spaceKey) {
|
|
124
|
+
var _a;
|
|
125
|
+
if ((_a = this._metadata.identity) == null ? void 0 : _a.haloSpace.key.equals(spaceKey)) {
|
|
126
|
+
return this._metadata.identity.haloSpace;
|
|
127
|
+
}
|
|
124
128
|
const space = this.spaces.find((space2) => space2.key === spaceKey);
|
|
125
129
|
assert(space, "Space not found");
|
|
126
130
|
return space;
|
|
@@ -131,7 +135,7 @@ var MetadataStore = class {
|
|
|
131
135
|
async clear() {
|
|
132
136
|
log("clearing all metadata", {}, {
|
|
133
137
|
file: "metadata-store.ts",
|
|
134
|
-
line:
|
|
138
|
+
line: 136,
|
|
135
139
|
scope: this,
|
|
136
140
|
callSite: (f, a) => f(...a)
|
|
137
141
|
});
|
|
@@ -152,10 +156,14 @@ var MetadataStore = class {
|
|
|
152
156
|
((_c = (_b = this._metadata).spaces) != null ? _c : _b.spaces = []).push(record);
|
|
153
157
|
await this._save();
|
|
154
158
|
}
|
|
155
|
-
async
|
|
159
|
+
async setSpaceDataLatestTimeframe(spaceKey, timeframe) {
|
|
156
160
|
this._getSpace(spaceKey).dataTimeframe = timeframe;
|
|
157
161
|
await this._save();
|
|
158
162
|
}
|
|
163
|
+
async setSpaceControlLatestTimeframe(spaceKey, timeframe) {
|
|
164
|
+
this._getSpace(spaceKey).controlTimeframe = timeframe;
|
|
165
|
+
await this._save();
|
|
166
|
+
}
|
|
159
167
|
async setCache(spaceKey, cache) {
|
|
160
168
|
this._getSpace(spaceKey).cache = cache;
|
|
161
169
|
await this._save();
|
|
@@ -1040,6 +1048,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1040
1048
|
this._isOpen = false;
|
|
1041
1049
|
this._lastTimeframeSaveTime = 0;
|
|
1042
1050
|
this._lastSnapshotSaveTime = 0;
|
|
1051
|
+
this._lastProcessedEpoch = -1;
|
|
1043
1052
|
this.onNewEpoch = new Event4();
|
|
1044
1053
|
}
|
|
1045
1054
|
get isOpen() {
|
|
@@ -1063,17 +1072,29 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1063
1072
|
if (!checkCredentialType(credential, "dxos.halo.credentials.Epoch")) {
|
|
1064
1073
|
return;
|
|
1065
1074
|
}
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1075
|
+
if (this._isOpen) {
|
|
1076
|
+
log9("new epoch", {
|
|
1077
|
+
credential
|
|
1078
|
+
}, {
|
|
1079
|
+
file: "data-pipeline.ts",
|
|
1080
|
+
line: 112,
|
|
1081
|
+
scope: this,
|
|
1082
|
+
callSite: (f, a) => f(...a)
|
|
1083
|
+
});
|
|
1084
|
+
this.currentEpoch = credential;
|
|
1085
|
+
await this._processEpoch(credential.subject.assertion);
|
|
1086
|
+
this.onNewEpoch.emit(credential);
|
|
1087
|
+
} else {
|
|
1088
|
+
log9("searching last epoch", {
|
|
1089
|
+
credential
|
|
1090
|
+
}, {
|
|
1091
|
+
file: "data-pipeline.ts",
|
|
1092
|
+
line: 118,
|
|
1093
|
+
scope: this,
|
|
1094
|
+
callSite: (f, a) => f(...a)
|
|
1095
|
+
});
|
|
1096
|
+
this.currentEpoch = credential;
|
|
1097
|
+
}
|
|
1077
1098
|
}
|
|
1078
1099
|
};
|
|
1079
1100
|
}
|
|
@@ -1112,7 +1133,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1112
1133
|
}
|
|
1113
1134
|
log9("close", {}, {
|
|
1114
1135
|
file: "data-pipeline.ts",
|
|
1115
|
-
line:
|
|
1136
|
+
line: 168,
|
|
1116
1137
|
scope: this,
|
|
1117
1138
|
callSite: (f, a) => f(...a)
|
|
1118
1139
|
});
|
|
@@ -1127,7 +1148,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1127
1148
|
} catch (err) {
|
|
1128
1149
|
log9.catch(err, {}, {
|
|
1129
1150
|
file: "data-pipeline.ts",
|
|
1130
|
-
line:
|
|
1151
|
+
line: 181,
|
|
1131
1152
|
scope: this,
|
|
1132
1153
|
callSite: (f, a) => f(...a)
|
|
1133
1154
|
});
|
|
@@ -1137,6 +1158,10 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1137
1158
|
await this._params.snapshotManager.close();
|
|
1138
1159
|
}
|
|
1139
1160
|
async _consumePipeline() {
|
|
1161
|
+
if (this.currentEpoch) {
|
|
1162
|
+
await this._processEpoch(this.currentEpoch.subject.assertion);
|
|
1163
|
+
this.onNewEpoch.emit(this.currentEpoch);
|
|
1164
|
+
}
|
|
1140
1165
|
assert8(this._pipeline, "Pipeline is not initialized.");
|
|
1141
1166
|
for await (const msg of this._pipeline.consume()) {
|
|
1142
1167
|
const { feedKey, seq, data } = msg;
|
|
@@ -1145,7 +1170,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1145
1170
|
seq
|
|
1146
1171
|
}, {
|
|
1147
1172
|
file: "data-pipeline.ts",
|
|
1148
|
-
line:
|
|
1173
|
+
line: 198,
|
|
1149
1174
|
scope: this,
|
|
1150
1175
|
callSite: (f, a) => f(...a)
|
|
1151
1176
|
});
|
|
@@ -1157,7 +1182,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1157
1182
|
feedKey
|
|
1158
1183
|
}, {
|
|
1159
1184
|
file: "data-pipeline.ts",
|
|
1160
|
-
line:
|
|
1185
|
+
line: 204,
|
|
1161
1186
|
scope: this,
|
|
1162
1187
|
callSite: (f, a) => f(...a)
|
|
1163
1188
|
});
|
|
@@ -1177,7 +1202,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1177
1202
|
} catch (err) {
|
|
1178
1203
|
log9.catch(err, {}, {
|
|
1179
1204
|
file: "data-pipeline.ts",
|
|
1180
|
-
line:
|
|
1205
|
+
line: 222,
|
|
1181
1206
|
scope: this,
|
|
1182
1207
|
callSite: (f, a) => f(...a)
|
|
1183
1208
|
});
|
|
@@ -1195,7 +1220,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1195
1220
|
async _saveTargetTimeframe(timeframe) {
|
|
1196
1221
|
var _a;
|
|
1197
1222
|
const newTimeframe = Timeframe3.merge((_a = this._targetTimeframe) != null ? _a : new Timeframe3(), timeframe);
|
|
1198
|
-
await this._params.metadataStore.
|
|
1223
|
+
await this._params.metadataStore.setSpaceDataLatestTimeframe(this._params.spaceKey, newTimeframe);
|
|
1199
1224
|
this._targetTimeframe = newTimeframe;
|
|
1200
1225
|
}
|
|
1201
1226
|
async _saveCache() {
|
|
@@ -1212,7 +1237,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1212
1237
|
} catch (err) {
|
|
1213
1238
|
log9.warn("Failed to cache properties", err, {
|
|
1214
1239
|
file: "data-pipeline.ts",
|
|
1215
|
-
line:
|
|
1240
|
+
line: 256,
|
|
1216
1241
|
scope: this,
|
|
1217
1242
|
callSite: (f, a) => f(...a)
|
|
1218
1243
|
});
|
|
@@ -1229,13 +1254,17 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1229
1254
|
}
|
|
1230
1255
|
}
|
|
1231
1256
|
async _processEpoch(epoch) {
|
|
1257
|
+
if (epoch.number <= this._lastProcessedEpoch) {
|
|
1258
|
+
return;
|
|
1259
|
+
}
|
|
1260
|
+
this._lastProcessedEpoch = epoch.number;
|
|
1232
1261
|
assert8(this._isOpen);
|
|
1233
1262
|
assert8(this._pipeline);
|
|
1234
1263
|
log9("Processing epoch", {
|
|
1235
1264
|
epoch
|
|
1236
1265
|
}, {
|
|
1237
1266
|
file: "data-pipeline.ts",
|
|
1238
|
-
line:
|
|
1267
|
+
line: 289,
|
|
1239
1268
|
scope: this,
|
|
1240
1269
|
callSite: (f, a) => f(...a)
|
|
1241
1270
|
});
|
|
@@ -1245,7 +1274,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1245
1274
|
}
|
|
1246
1275
|
log9("restarting pipeline for epoch", {}, {
|
|
1247
1276
|
file: "data-pipeline.ts",
|
|
1248
|
-
line:
|
|
1277
|
+
line: 297,
|
|
1249
1278
|
scope: this,
|
|
1250
1279
|
callSite: (f, a) => f(...a)
|
|
1251
1280
|
});
|
|
@@ -1304,10 +1333,15 @@ import { SpaceStateMachine } from "@dxos/credentials";
|
|
|
1304
1333
|
import { PublicKey as PublicKey3 } from "@dxos/keys";
|
|
1305
1334
|
import { log as log10 } from "@dxos/log";
|
|
1306
1335
|
import { AdmittedFeed } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
1336
|
+
import { Timeframe as Timeframe4 } from "@dxos/timeframe";
|
|
1307
1337
|
import { Callback } from "@dxos/util";
|
|
1338
|
+
var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL2 = 500;
|
|
1308
1339
|
var ControlPipeline = class {
|
|
1309
|
-
constructor({ spaceKey, genesisFeed, feedProvider }) {
|
|
1340
|
+
constructor({ spaceKey, genesisFeed, feedProvider, metadataStore }) {
|
|
1341
|
+
this._lastTimeframeSaveTime = Date.now();
|
|
1310
1342
|
this.onFeedAdmitted = new Callback();
|
|
1343
|
+
this._spaceKey = spaceKey;
|
|
1344
|
+
this._metadata = metadataStore;
|
|
1311
1345
|
this._pipeline = new Pipeline();
|
|
1312
1346
|
void this._pipeline.addFeed(genesisFeed);
|
|
1313
1347
|
this._spaceStateMachine = new SpaceStateMachine(spaceKey);
|
|
@@ -1316,7 +1350,7 @@ var ControlPipeline = class {
|
|
|
1316
1350
|
key: info.key
|
|
1317
1351
|
}, {
|
|
1318
1352
|
file: "control-pipeline.ts",
|
|
1319
|
-
line:
|
|
1353
|
+
line: 51,
|
|
1320
1354
|
scope: this,
|
|
1321
1355
|
callSite: (f, a) => f(...a)
|
|
1322
1356
|
});
|
|
@@ -1327,7 +1361,7 @@ var ControlPipeline = class {
|
|
|
1327
1361
|
} catch (err) {
|
|
1328
1362
|
log10.catch(err, {}, {
|
|
1329
1363
|
file: "control-pipeline.ts",
|
|
1330
|
-
line:
|
|
1364
|
+
line: 59,
|
|
1331
1365
|
scope: this,
|
|
1332
1366
|
callSite: (f, a) => f(...a)
|
|
1333
1367
|
});
|
|
@@ -1350,7 +1384,7 @@ var ControlPipeline = class {
|
|
|
1350
1384
|
async start() {
|
|
1351
1385
|
log10("starting...", {}, {
|
|
1352
1386
|
file: "control-pipeline.ts",
|
|
1353
|
-
line:
|
|
1387
|
+
line: 83,
|
|
1354
1388
|
scope: this,
|
|
1355
1389
|
callSite: (f, a) => f(...a)
|
|
1356
1390
|
});
|
|
@@ -1362,7 +1396,7 @@ var ControlPipeline = class {
|
|
|
1362
1396
|
seq: msg.seq
|
|
1363
1397
|
}, {
|
|
1364
1398
|
file: "control-pipeline.ts",
|
|
1365
|
-
line:
|
|
1399
|
+
line: 88,
|
|
1366
1400
|
scope: this,
|
|
1367
1401
|
callSite: (f, a) => f(...a)
|
|
1368
1402
|
});
|
|
@@ -1373,16 +1407,18 @@ var ControlPipeline = class {
|
|
|
1373
1407
|
msg
|
|
1374
1408
|
}, {
|
|
1375
1409
|
file: "control-pipeline.ts",
|
|
1376
|
-
line:
|
|
1410
|
+
line: 95,
|
|
1377
1411
|
scope: this,
|
|
1378
1412
|
callSite: (f, a) => f(...a)
|
|
1379
1413
|
});
|
|
1414
|
+
} else {
|
|
1415
|
+
await this._noteTargetStateIfNeeded(this._pipeline.state.pendingTimeframe);
|
|
1380
1416
|
}
|
|
1381
1417
|
}
|
|
1382
1418
|
} catch (err) {
|
|
1383
1419
|
log10.catch(err, {}, {
|
|
1384
1420
|
file: "control-pipeline.ts",
|
|
1385
|
-
line:
|
|
1421
|
+
line: 101,
|
|
1386
1422
|
scope: this,
|
|
1387
1423
|
callSite: (f, a) => f(...a)
|
|
1388
1424
|
});
|
|
@@ -1392,26 +1428,48 @@ var ControlPipeline = class {
|
|
|
1392
1428
|
await this._pipeline.start();
|
|
1393
1429
|
log10("started", {}, {
|
|
1394
1430
|
file: "control-pipeline.ts",
|
|
1395
|
-
line:
|
|
1431
|
+
line: 107,
|
|
1396
1432
|
scope: this,
|
|
1397
1433
|
callSite: (f, a) => f(...a)
|
|
1398
1434
|
});
|
|
1399
1435
|
}
|
|
1436
|
+
async _noteTargetStateIfNeeded(timeframe) {
|
|
1437
|
+
if (Date.now() - this._lastTimeframeSaveTime > TIMEFRAME_SAVE_DEBOUNCE_INTERVAL2) {
|
|
1438
|
+
this._lastTimeframeSaveTime = Date.now();
|
|
1439
|
+
await this._saveTargetTimeframe(timeframe);
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1400
1442
|
async stop() {
|
|
1401
1443
|
log10("stopping...", {}, {
|
|
1402
1444
|
file: "control-pipeline.ts",
|
|
1403
|
-
line:
|
|
1445
|
+
line: 121,
|
|
1404
1446
|
scope: this,
|
|
1405
1447
|
callSite: (f, a) => f(...a)
|
|
1406
1448
|
});
|
|
1407
1449
|
await this._pipeline.stop();
|
|
1450
|
+
await this._saveTargetTimeframe(this._pipeline.state.timeframe);
|
|
1408
1451
|
log10("stopped", {}, {
|
|
1409
1452
|
file: "control-pipeline.ts",
|
|
1410
|
-
line:
|
|
1453
|
+
line: 124,
|
|
1411
1454
|
scope: this,
|
|
1412
1455
|
callSite: (f, a) => f(...a)
|
|
1413
1456
|
});
|
|
1414
1457
|
}
|
|
1458
|
+
async _saveTargetTimeframe(timeframe) {
|
|
1459
|
+
var _a;
|
|
1460
|
+
try {
|
|
1461
|
+
const newTimeframe = Timeframe4.merge((_a = this._targetTimeframe) != null ? _a : new Timeframe4(), timeframe);
|
|
1462
|
+
await this._metadata.setSpaceControlLatestTimeframe(this._spaceKey, newTimeframe);
|
|
1463
|
+
this._targetTimeframe = newTimeframe;
|
|
1464
|
+
} catch (err) {
|
|
1465
|
+
log10(err, {}, {
|
|
1466
|
+
file: "control-pipeline.ts",
|
|
1467
|
+
line: 133,
|
|
1468
|
+
scope: this,
|
|
1469
|
+
callSite: (f, a) => f(...a)
|
|
1470
|
+
});
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1415
1473
|
};
|
|
1416
1474
|
|
|
1417
1475
|
// packages/core/echo/echo-pipeline/src/space/space.ts
|
|
@@ -1441,7 +1499,8 @@ var Space = class Space2 {
|
|
|
1441
1499
|
this._controlPipeline = new ControlPipeline({
|
|
1442
1500
|
spaceKey: params.spaceKey,
|
|
1443
1501
|
genesisFeed: params.genesisFeed,
|
|
1444
|
-
feedProvider: params.feedProvider
|
|
1502
|
+
feedProvider: params.feedProvider,
|
|
1503
|
+
metadataStore: params.metadataStore
|
|
1445
1504
|
});
|
|
1446
1505
|
this._controlPipeline.onFeedAdmitted.set(async (info) => {
|
|
1447
1506
|
if (info.assertion.designation === AdmittedFeed2.Designation.DATA) {
|
|
@@ -1463,7 +1522,7 @@ var Space = class Space2 {
|
|
|
1463
1522
|
credential
|
|
1464
1523
|
}, {
|
|
1465
1524
|
file: "space.ts",
|
|
1466
|
-
line:
|
|
1525
|
+
line: 107,
|
|
1467
1526
|
scope: this,
|
|
1468
1527
|
callSite: (f, a) => f(...a)
|
|
1469
1528
|
});
|
|
@@ -1553,7 +1612,7 @@ var Space = class Space2 {
|
|
|
1553
1612
|
async open() {
|
|
1554
1613
|
log11("opening...", {}, {
|
|
1555
1614
|
file: "space.ts",
|
|
1556
|
-
line:
|
|
1615
|
+
line: 209,
|
|
1557
1616
|
scope: this,
|
|
1558
1617
|
callSite: (f, a) => f(...a)
|
|
1559
1618
|
});
|
|
@@ -1563,10 +1622,11 @@ var Space = class Space2 {
|
|
|
1563
1622
|
await this._controlPipeline.start();
|
|
1564
1623
|
await this.protocol.start();
|
|
1565
1624
|
this._dataPipelineCredentialConsumer = this._controlPipeline.spaceState.registerProcessor(this._dataPipeline.createCredentialProcessor());
|
|
1625
|
+
await this._dataPipelineCredentialConsumer.open();
|
|
1566
1626
|
this._isOpen = true;
|
|
1567
1627
|
log11("opened", {}, {
|
|
1568
1628
|
file: "space.ts",
|
|
1569
|
-
line:
|
|
1629
|
+
line: 225,
|
|
1570
1630
|
scope: this,
|
|
1571
1631
|
callSite: (f, a) => f(...a)
|
|
1572
1632
|
});
|
|
@@ -1577,7 +1637,7 @@ var Space = class Space2 {
|
|
|
1577
1637
|
key: this._key
|
|
1578
1638
|
}, {
|
|
1579
1639
|
file: "space.ts",
|
|
1580
|
-
line:
|
|
1640
|
+
line: 230,
|
|
1581
1641
|
scope: this,
|
|
1582
1642
|
callSite: (f, a) => f(...a)
|
|
1583
1643
|
});
|
|
@@ -1592,7 +1652,7 @@ var Space = class Space2 {
|
|
|
1592
1652
|
this._isOpen = false;
|
|
1593
1653
|
log11("closed", {}, {
|
|
1594
1654
|
file: "space.ts",
|
|
1595
|
-
line:
|
|
1655
|
+
line: 244,
|
|
1596
1656
|
scope: this,
|
|
1597
1657
|
callSite: (f, a) => f(...a)
|
|
1598
1658
|
});
|
|
@@ -1600,14 +1660,12 @@ var Space = class Space2 {
|
|
|
1600
1660
|
async initializeDataPipeline() {
|
|
1601
1661
|
log11("initializeDataPipeline", {}, {
|
|
1602
1662
|
file: "space.ts",
|
|
1603
|
-
line:
|
|
1663
|
+
line: 249,
|
|
1604
1664
|
scope: this,
|
|
1605
1665
|
callSite: (f, a) => f(...a)
|
|
1606
1666
|
});
|
|
1607
1667
|
assert9(this._isOpen, "Space must be open to initialize data pipeline.");
|
|
1608
1668
|
await this._dataPipeline.open();
|
|
1609
|
-
assert9(this._dataPipelineCredentialConsumer);
|
|
1610
|
-
await this._dataPipelineCredentialConsumer.open();
|
|
1611
1669
|
}
|
|
1612
1670
|
};
|
|
1613
1671
|
__decorate6([
|
|
@@ -1934,4 +1992,4 @@ export {
|
|
|
1934
1992
|
SpaceProtocolSession,
|
|
1935
1993
|
SpaceManager
|
|
1936
1994
|
};
|
|
1937
|
-
//# sourceMappingURL=chunk-
|
|
1995
|
+
//# sourceMappingURL=chunk-NNHUIDTY.mjs.map
|