@dxos/echo-pipeline 0.8.4-main.dedc0f3 → 0.8.4-main.e00bdcdb52
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-I4JBIZSN.mjs → neutral/chunk-VIHYDCCC.mjs} +406 -965
- package/dist/lib/neutral/chunk-VIHYDCCC.mjs.map +7 -0
- package/dist/lib/{browser/chunk-MBMJB3V7.mjs → neutral/chunk-YBC6ONBZ.mjs} +78 -13
- package/dist/lib/neutral/chunk-YBC6ONBZ.mjs.map +7 -0
- package/dist/lib/{browser → neutral}/filter/index.mjs +1 -2
- package/dist/lib/{browser → neutral}/index.mjs +2929 -2187
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/{browser → neutral}/testing/index.mjs +103 -395
- package/dist/lib/neutral/testing/index.mjs.map +7 -0
- package/dist/types/src/automerge/automerge-host.d.ts +43 -23
- package/dist/types/src/automerge/automerge-host.d.ts.map +1 -1
- package/dist/types/src/automerge/automerge-repo.test.d.ts +1 -1
- package/dist/types/src/automerge/automerge-repo.test.d.ts.map +1 -1
- package/dist/types/src/automerge/collection-synchronizer.d.ts +5 -3
- package/dist/types/src/automerge/collection-synchronizer.d.ts.map +1 -1
- package/dist/types/src/automerge/echo-data-monitor.d.ts.map +1 -1
- package/dist/types/src/automerge/echo-network-adapter.d.ts +17 -11
- package/dist/types/src/automerge/echo-network-adapter.d.ts.map +1 -1
- package/dist/types/src/automerge/echo-replicator.d.ts +20 -16
- package/dist/types/src/automerge/echo-replicator.d.ts.map +1 -1
- package/dist/types/src/automerge/heads-store.d.ts +9 -2
- package/dist/types/src/automerge/heads-store.d.ts.map +1 -1
- package/dist/types/src/automerge/leveldb-storage-adapter.d.ts +4 -4
- package/dist/types/src/automerge/leveldb-storage-adapter.d.ts.map +1 -1
- package/dist/types/src/automerge/mesh-echo-replicator-connection.d.ts +8 -8
- package/dist/types/src/automerge/mesh-echo-replicator-connection.d.ts.map +1 -1
- package/dist/types/src/automerge/mesh-echo-replicator.d.ts +6 -5
- package/dist/types/src/automerge/mesh-echo-replicator.d.ts.map +1 -1
- package/dist/types/src/automerge/network-protocol.d.ts.map +1 -1
- package/dist/types/src/automerge/space-collection.d.ts.map +1 -1
- package/dist/types/src/common/feeds.d.ts.map +1 -1
- package/dist/types/src/common/space-id.d.ts.map +1 -1
- package/dist/types/src/db-host/automerge-data-source.d.ts +35 -0
- package/dist/types/src/db-host/automerge-data-source.d.ts.map +1 -0
- package/dist/types/src/db-host/automerge-data-source.test.d.ts +2 -0
- package/dist/types/src/db-host/automerge-data-source.test.d.ts.map +1 -0
- package/dist/types/src/db-host/automerge-metrics.d.ts.map +1 -1
- package/dist/types/src/db-host/data-service.d.ts +7 -6
- package/dist/types/src/db-host/data-service.d.ts.map +1 -1
- package/dist/types/src/db-host/database-root.d.ts.map +1 -1
- package/dist/types/src/db-host/documents-synchronizer.d.ts +8 -7
- package/dist/types/src/db-host/documents-synchronizer.d.ts.map +1 -1
- package/dist/types/src/db-host/echo-host.d.ts +58 -28
- package/dist/types/src/db-host/echo-host.d.ts.map +1 -1
- package/dist/types/src/db-host/index.d.ts +1 -0
- package/dist/types/src/db-host/index.d.ts.map +1 -1
- package/dist/types/src/db-host/local-queue-service.d.ts +19 -0
- package/dist/types/src/db-host/local-queue-service.d.ts.map +1 -0
- package/dist/types/src/db-host/query-service.d.ts +13 -8
- package/dist/types/src/db-host/query-service.d.ts.map +1 -1
- package/dist/types/src/db-host/queue-data-source.d.ts +38 -0
- package/dist/types/src/db-host/queue-data-source.d.ts.map +1 -0
- package/dist/types/src/db-host/queue-service.test.d.ts +2 -0
- package/dist/types/src/db-host/queue-service.test.d.ts.map +1 -0
- package/dist/types/src/db-host/space-state-manager.d.ts +1 -0
- package/dist/types/src/db-host/space-state-manager.d.ts.map +1 -1
- package/dist/types/src/db-host/stub.d.ts +11 -0
- package/dist/types/src/db-host/stub.d.ts.map +1 -0
- package/dist/types/src/edge/echo-edge-replicator.d.ts +7 -6
- package/dist/types/src/edge/echo-edge-replicator.d.ts.map +1 -1
- package/dist/types/src/edge/inflight-request-limiter.d.ts.map +1 -1
- package/dist/types/src/filter/filter-match.d.ts +2 -2
- package/dist/types/src/filter/filter-match.d.ts.map +1 -1
- package/dist/types/src/metadata/metadata-store.d.ts.map +1 -1
- package/dist/types/src/pipeline/message-selector.d.ts.map +1 -1
- package/dist/types/src/pipeline/pipeline.d.ts +2 -2
- package/dist/types/src/pipeline/pipeline.d.ts.map +1 -1
- package/dist/types/src/pipeline/timeframe-clock.d.ts.map +1 -1
- package/dist/types/src/query/errors.d.ts +20 -21
- package/dist/types/src/query/errors.d.ts.map +1 -1
- package/dist/types/src/query/plan.d.ts +59 -8
- package/dist/types/src/query/plan.d.ts.map +1 -1
- package/dist/types/src/query/query-executor.d.ts +51 -9
- package/dist/types/src/query/query-executor.d.ts.map +1 -1
- package/dist/types/src/query/query-planner.d.ts +10 -1
- package/dist/types/src/query/query-planner.d.ts.map +1 -1
- package/dist/types/src/space/admission-discovery-extension.d.ts.map +1 -1
- package/dist/types/src/space/auth.d.ts +3 -3
- package/dist/types/src/space/auth.d.ts.map +1 -1
- package/dist/types/src/space/control-pipeline.d.ts +4 -3
- package/dist/types/src/space/control-pipeline.d.ts.map +1 -1
- package/dist/types/src/space/space-manager.d.ts +7 -7
- package/dist/types/src/space/space-manager.d.ts.map +1 -1
- package/dist/types/src/space/space-protocol.d.ts +9 -8
- package/dist/types/src/space/space-protocol.d.ts.map +1 -1
- package/dist/types/src/space/space.d.ts +5 -5
- package/dist/types/src/space/space.d.ts.map +1 -1
- package/dist/types/src/testing/change-metadata.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +0 -2
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/test-agent-builder.d.ts.map +1 -1
- package/dist/types/src/testing/test-feed-builder.d.ts.map +1 -1
- package/dist/types/src/testing/test-network-adapter.d.ts +1 -1
- package/dist/types/src/testing/test-network-adapter.d.ts.map +1 -1
- package/dist/types/src/testing/test-replicator.d.ts +13 -13
- package/dist/types/src/testing/test-replicator.d.ts.map +1 -1
- package/dist/types/src/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +51 -55
- package/src/automerge/automerge-host.test.ts +42 -23
- package/src/automerge/automerge-host.ts +187 -102
- package/src/automerge/automerge-repo.test.ts +149 -32
- package/src/automerge/collection-synchronizer.test.ts +19 -13
- package/src/automerge/collection-synchronizer.ts +69 -28
- package/src/automerge/echo-network-adapter.test.ts +2 -1
- package/src/automerge/echo-network-adapter.ts +40 -29
- package/src/automerge/echo-replicator.ts +21 -16
- package/src/automerge/heads-store.ts +42 -3
- package/src/automerge/leveldb-storage-adapter.ts +4 -4
- package/src/automerge/mesh-echo-replicator-connection.ts +8 -8
- package/src/automerge/mesh-echo-replicator.ts +14 -11
- package/src/db-host/automerge-data-source.test.ts +299 -0
- package/src/db-host/automerge-data-source.ts +186 -0
- package/src/db-host/data-service.ts +17 -10
- package/src/db-host/documents-synchronizer.test.ts +143 -14
- package/src/db-host/documents-synchronizer.ts +54 -51
- package/src/db-host/echo-host.ts +267 -84
- package/src/db-host/index.ts +1 -0
- package/src/db-host/local-queue-service.ts +127 -0
- package/src/db-host/query-service.ts +29 -104
- package/src/db-host/queue-data-source.ts +159 -0
- package/src/db-host/queue-service.test.ts +145 -0
- package/src/db-host/space-state-manager.ts +5 -1
- package/src/db-host/stub.ts +33 -0
- package/src/edge/echo-edge-replicator.test.ts +9 -9
- package/src/edge/echo-edge-replicator.ts +76 -47
- package/src/filter/filter-match.test.ts +67 -31
- package/src/filter/filter-match.ts +114 -27
- package/src/metadata/metadata-store.ts +8 -5
- package/src/pipeline/pipeline-stress.test.ts +1 -3
- package/src/pipeline/pipeline.test.ts +0 -1
- package/src/pipeline/pipeline.ts +2 -3
- package/src/query/errors.ts +3 -1
- package/src/query/plan.ts +71 -8
- package/src/query/query-executor.ts +1005 -196
- package/src/query/query-planner.test.ts +854 -86
- package/src/query/query-planner.ts +440 -39
- package/src/space/admission-discovery-extension.ts +1 -1
- package/src/space/auth.ts +6 -6
- package/src/space/control-pipeline.test.ts +2 -2
- package/src/space/control-pipeline.ts +7 -7
- package/src/space/space-manager.ts +12 -17
- package/src/space/space-protocol.browser.test.ts +13 -12
- package/src/space/space-protocol.test.ts +13 -13
- package/src/space/space-protocol.ts +16 -15
- package/src/space/space.test.ts +2 -2
- package/src/space/space.ts +9 -10
- package/src/testing/index.ts +0 -2
- package/src/testing/test-agent-builder.ts +0 -1
- package/src/testing/test-network-adapter.ts +16 -3
- package/src/testing/test-replicator.ts +19 -18
- package/src/util.ts +7 -3
- package/dist/lib/browser/chunk-CGS2ULMK.mjs +0 -11
- package/dist/lib/browser/chunk-CGS2ULMK.mjs.map +0 -7
- package/dist/lib/browser/chunk-I4JBIZSN.mjs.map +0 -7
- package/dist/lib/browser/chunk-MBMJB3V7.mjs.map +0 -7
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/testing/index.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +0 -11
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-XJZTCD4G.mjs +0 -182
- package/dist/lib/node-esm/chunk-XJZTCD4G.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-YOL7JY5W.mjs +0 -2230
- package/dist/lib/node-esm/chunk-YOL7JY5W.mjs.map +0 -7
- package/dist/lib/node-esm/filter/index.mjs +0 -13
- package/dist/lib/node-esm/filter/index.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -5503
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/testing/index.mjs +0 -805
- package/dist/lib/node-esm/testing/index.mjs.map +0 -7
- package/dist/types/src/db-host/documents-iterator.d.ts +0 -7
- package/dist/types/src/db-host/documents-iterator.d.ts.map +0 -1
- package/dist/types/src/testing/test-data.d.ts +0 -18
- package/dist/types/src/testing/test-data.d.ts.map +0 -1
- package/dist/types/src/testing/test-schema.d.ts +0 -37
- package/dist/types/src/testing/test-schema.d.ts.map +0 -1
- package/src/db-host/documents-iterator.ts +0 -74
- package/src/testing/test-data.ts +0 -127
- package/src/testing/test-schema.ts +0 -53
- /package/dist/lib/{browser → neutral}/filter/index.mjs.map +0 -0
|
@@ -10,24 +10,8 @@ var valueEncoding = createCodecEncoding(codec);
|
|
|
10
10
|
import { invariant } from "@dxos/invariant";
|
|
11
11
|
var __dxlog_file = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/common/feeds.ts";
|
|
12
12
|
var createMappedFeedWriter = (mapper, writer) => {
|
|
13
|
-
invariant(mapper, void 0, {
|
|
14
|
-
|
|
15
|
-
L: 16,
|
|
16
|
-
S: void 0,
|
|
17
|
-
A: [
|
|
18
|
-
"mapper",
|
|
19
|
-
""
|
|
20
|
-
]
|
|
21
|
-
});
|
|
22
|
-
invariant(writer, void 0, {
|
|
23
|
-
F: __dxlog_file,
|
|
24
|
-
L: 17,
|
|
25
|
-
S: void 0,
|
|
26
|
-
A: [
|
|
27
|
-
"writer",
|
|
28
|
-
""
|
|
29
|
-
]
|
|
30
|
-
});
|
|
13
|
+
invariant(mapper, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 8, S: void 0, A: ["mapper", ""] });
|
|
14
|
+
invariant(writer, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 9, S: void 0, A: ["writer", ""] });
|
|
31
15
|
return {
|
|
32
16
|
write: async (data, options) => await writer.write(await mapper(data), options)
|
|
33
17
|
};
|
|
@@ -61,26 +45,13 @@ import { DataCorruptionError, STORAGE_VERSION } from "@dxos/protocols";
|
|
|
61
45
|
import { schema as schema2 } from "@dxos/protocols/proto";
|
|
62
46
|
import { Invitation, SpaceState } from "@dxos/protocols/proto/dxos/client/services";
|
|
63
47
|
import { ComplexMap as ComplexMap2, arrayToBuffer, forEachAsync, isNonNullable } from "@dxos/util";
|
|
64
|
-
|
|
65
|
-
if (key in obj) {
|
|
66
|
-
Object.defineProperty(obj, key, {
|
|
67
|
-
value,
|
|
68
|
-
enumerable: true,
|
|
69
|
-
configurable: true,
|
|
70
|
-
writable: true
|
|
71
|
-
});
|
|
72
|
-
} else {
|
|
73
|
-
obj[key] = value;
|
|
74
|
-
}
|
|
75
|
-
return obj;
|
|
76
|
-
}
|
|
48
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/metadata/metadata-store.ts";
|
|
77
49
|
function _ts_decorate(decorators, target, key, desc) {
|
|
78
50
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
79
51
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
80
52
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
81
53
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
82
54
|
}
|
|
83
|
-
var __dxlog_file2 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/metadata/metadata-store.ts";
|
|
84
55
|
var EXPIRED_INVITATION_CLEANUP_INTERVAL = 60 * 60 * 1e3;
|
|
85
56
|
var emptyEchoMetadata = () => ({
|
|
86
57
|
version: STORAGE_VERSION,
|
|
@@ -92,6 +63,18 @@ var emptyLargeSpaceMetadata = () => ({});
|
|
|
92
63
|
var EchoMetadata = schema2.getCodecForType("dxos.echo.metadata.EchoMetadata");
|
|
93
64
|
var LargeSpaceMetadata = schema2.getCodecForType("dxos.echo.metadata.LargeSpaceMetadata");
|
|
94
65
|
var MetadataStore = class {
|
|
66
|
+
_metadata = emptyEchoMetadata();
|
|
67
|
+
_spaceLargeMetadata = new ComplexMap2(PublicKey2.hash);
|
|
68
|
+
_metadataFile = void 0;
|
|
69
|
+
update = new Event();
|
|
70
|
+
_invitationCleanupCtx = new Context(void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 35 });
|
|
71
|
+
/**
|
|
72
|
+
* @internal
|
|
73
|
+
*/
|
|
74
|
+
_directory;
|
|
75
|
+
constructor(directory) {
|
|
76
|
+
this._directory = directory;
|
|
77
|
+
}
|
|
95
78
|
get metadata() {
|
|
96
79
|
return this._metadata;
|
|
97
80
|
}
|
|
@@ -117,22 +100,22 @@ var MetadataStore = class {
|
|
|
117
100
|
size: dataSize,
|
|
118
101
|
checksum,
|
|
119
102
|
name: file.filename
|
|
120
|
-
}, {
|
|
121
|
-
F: __dxlog_file2,
|
|
122
|
-
L: 91,
|
|
123
|
-
S: this,
|
|
124
|
-
C: (f, a) => f(...a)
|
|
125
|
-
});
|
|
103
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 63, S: this });
|
|
126
104
|
if (fileLength < dataSize + 8) {
|
|
127
|
-
throw new DataCorruptionError(
|
|
128
|
-
|
|
129
|
-
|
|
105
|
+
throw new DataCorruptionError({
|
|
106
|
+
message: "Metadata size is smaller than expected.",
|
|
107
|
+
context: {
|
|
108
|
+
fileLength,
|
|
109
|
+
dataSize
|
|
110
|
+
}
|
|
130
111
|
});
|
|
131
112
|
}
|
|
132
113
|
const data = await file.read(8, dataSize);
|
|
133
114
|
const calculatedChecksum = CRC32.buf(data);
|
|
134
115
|
if (calculatedChecksum !== checksum) {
|
|
135
|
-
throw new DataCorruptionError(
|
|
116
|
+
throw new DataCorruptionError({
|
|
117
|
+
message: "Metadata checksum is invalid."
|
|
118
|
+
});
|
|
136
119
|
}
|
|
137
120
|
return codec2.decode(data);
|
|
138
121
|
} finally {
|
|
@@ -153,12 +136,7 @@ var MetadataStore = class {
|
|
|
153
136
|
log("saved", {
|
|
154
137
|
size: encoded.length,
|
|
155
138
|
checksum
|
|
156
|
-
}, {
|
|
157
|
-
F: __dxlog_file2,
|
|
158
|
-
L: 126,
|
|
159
|
-
S: this,
|
|
160
|
-
C: (f, a) => f(...a)
|
|
161
|
-
});
|
|
139
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 100, S: this });
|
|
162
140
|
}
|
|
163
141
|
async close() {
|
|
164
142
|
await this._invitationCleanupCtx.dispose();
|
|
@@ -181,18 +159,12 @@ var MetadataStore = class {
|
|
|
181
159
|
this._metadata = metadata;
|
|
182
160
|
}
|
|
183
161
|
this._metadata.spaces?.forEach((space) => {
|
|
184
|
-
|
|
185
|
-
(_space = space).state ?? (_space.state = SpaceState.SPACE_ACTIVE);
|
|
162
|
+
space.state ??= SpaceState.SPACE_ACTIVE;
|
|
186
163
|
});
|
|
187
164
|
} catch (err) {
|
|
188
165
|
log.error("failed to load metadata", {
|
|
189
166
|
err
|
|
190
|
-
}, {
|
|
191
|
-
F: __dxlog_file2,
|
|
192
|
-
L: 158,
|
|
193
|
-
S: this,
|
|
194
|
-
C: (f, a) => f(...a)
|
|
195
|
-
});
|
|
167
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 129, S: this });
|
|
196
168
|
this._metadata = emptyEchoMetadata();
|
|
197
169
|
}
|
|
198
170
|
await forEachAsync([
|
|
@@ -204,12 +176,7 @@ var MetadataStore = class {
|
|
|
204
176
|
} catch (err) {
|
|
205
177
|
log.error("failed to load space large metadata", {
|
|
206
178
|
err
|
|
207
|
-
}, {
|
|
208
|
-
F: __dxlog_file2,
|
|
209
|
-
L: 170,
|
|
210
|
-
S: this,
|
|
211
|
-
C: (f, a) => f(...a)
|
|
212
|
-
});
|
|
179
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 141, S: this });
|
|
213
180
|
}
|
|
214
181
|
});
|
|
215
182
|
scheduleTaskInterval(this._invitationCleanupCtx, async () => {
|
|
@@ -241,12 +208,7 @@ var MetadataStore = class {
|
|
|
241
208
|
} catch (err) {
|
|
242
209
|
log.error("failed to load space large metadata", {
|
|
243
210
|
err
|
|
244
|
-
}, {
|
|
245
|
-
F: __dxlog_file2,
|
|
246
|
-
L: 212,
|
|
247
|
-
S: this,
|
|
248
|
-
C: (f, a) => f(...a)
|
|
249
|
-
});
|
|
211
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 174, S: this });
|
|
250
212
|
}
|
|
251
213
|
}
|
|
252
214
|
async _saveSpaceLargeMetadata(key) {
|
|
@@ -262,15 +224,7 @@ var MetadataStore = class {
|
|
|
262
224
|
return this._metadata.identity.haloSpace;
|
|
263
225
|
}
|
|
264
226
|
const space = this.spaces.find((space2) => space2.key.equals(spaceKey));
|
|
265
|
-
invariant2(space, "Space not found", {
|
|
266
|
-
F: __dxlog_file2,
|
|
267
|
-
L: 234,
|
|
268
|
-
S: this,
|
|
269
|
-
A: [
|
|
270
|
-
"space",
|
|
271
|
-
"'Space not found'"
|
|
272
|
-
]
|
|
273
|
-
});
|
|
227
|
+
invariant2(space, "Space not found", { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 193, S: this, A: ["space", "'Space not found'"] });
|
|
274
228
|
return space;
|
|
275
229
|
}
|
|
276
230
|
hasSpace(spaceKey) {
|
|
@@ -292,12 +246,7 @@ var MetadataStore = class {
|
|
|
292
246
|
* Clears storage - doesn't work for now.
|
|
293
247
|
*/
|
|
294
248
|
async clear() {
|
|
295
|
-
log("clearing all metadata", void 0, {
|
|
296
|
-
F: __dxlog_file2,
|
|
297
|
-
L: 262,
|
|
298
|
-
S: this,
|
|
299
|
-
C: (f, a) => f(...a)
|
|
300
|
-
});
|
|
249
|
+
log("clearing all metadata", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 215, S: this });
|
|
301
250
|
await this._directory.delete();
|
|
302
251
|
this._metadata = emptyEchoMetadata();
|
|
303
252
|
}
|
|
@@ -305,15 +254,7 @@ var MetadataStore = class {
|
|
|
305
254
|
return this._metadata.identity;
|
|
306
255
|
}
|
|
307
256
|
async setIdentityRecord(record) {
|
|
308
|
-
invariant2(!this._metadata.identity, "Cannot overwrite existing identity in metadata", {
|
|
309
|
-
F: __dxlog_file2,
|
|
310
|
-
L: 272,
|
|
311
|
-
S: this,
|
|
312
|
-
A: [
|
|
313
|
-
"!this._metadata.identity",
|
|
314
|
-
"'Cannot overwrite existing identity in metadata'"
|
|
315
|
-
]
|
|
316
|
-
});
|
|
257
|
+
invariant2(!this._metadata.identity, "Cannot overwrite existing identity in metadata", { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 223, S: this, A: ["!this._metadata.identity", "'Cannot overwrite existing identity in metadata'"] });
|
|
317
258
|
this._metadata.identity = record;
|
|
318
259
|
await this._save();
|
|
319
260
|
await this.flush();
|
|
@@ -322,11 +263,10 @@ var MetadataStore = class {
|
|
|
322
263
|
return this._metadata.invitations ?? [];
|
|
323
264
|
}
|
|
324
265
|
async addInvitation(invitation) {
|
|
325
|
-
var _this__metadata;
|
|
326
266
|
if (this._metadata.invitations?.find((i) => i.invitationId === invitation.invitationId)) {
|
|
327
267
|
return;
|
|
328
268
|
}
|
|
329
|
-
(
|
|
269
|
+
(this._metadata.invitations ??= []).push(invitation);
|
|
330
270
|
await this._save();
|
|
331
271
|
await this.flush();
|
|
332
272
|
}
|
|
@@ -336,17 +276,8 @@ var MetadataStore = class {
|
|
|
336
276
|
await this.flush();
|
|
337
277
|
}
|
|
338
278
|
async addSpace(record) {
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
F: __dxlog_file2,
|
|
342
|
-
L: 300,
|
|
343
|
-
S: this,
|
|
344
|
-
A: [
|
|
345
|
-
"!(this._metadata.spaces ?? []).find((space) => space.key.equals(record.key))",
|
|
346
|
-
"'Cannot overwrite existing space in metadata'"
|
|
347
|
-
]
|
|
348
|
-
});
|
|
349
|
-
((_this__metadata = this._metadata).spaces ?? (_this__metadata.spaces = [])).push(record);
|
|
279
|
+
invariant2(!(this._metadata.spaces ?? []).find((space) => space.key.equals(record.key)), "Cannot overwrite existing space in metadata", { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 245, S: this, A: ["!(this._metadata.spaces ?? []).find((space)=>space.key.equals(record.key))", "'Cannot overwrite existing space in metadata'"] });
|
|
280
|
+
(this._metadata.spaces ??= []).push(record);
|
|
350
281
|
await this._save();
|
|
351
282
|
await this.flush();
|
|
352
283
|
}
|
|
@@ -391,18 +322,6 @@ var MetadataStore = class {
|
|
|
391
322
|
await this._save();
|
|
392
323
|
await this.flush();
|
|
393
324
|
}
|
|
394
|
-
constructor(directory) {
|
|
395
|
-
_define_property(this, "_metadata", emptyEchoMetadata());
|
|
396
|
-
_define_property(this, "_spaceLargeMetadata", new ComplexMap2(PublicKey2.hash));
|
|
397
|
-
_define_property(this, "_metadataFile", void 0);
|
|
398
|
-
_define_property(this, "update", new Event());
|
|
399
|
-
_define_property(this, "_invitationCleanupCtx", new Context(void 0, {
|
|
400
|
-
F: __dxlog_file2,
|
|
401
|
-
L: 55
|
|
402
|
-
}));
|
|
403
|
-
_define_property(this, "_directory", void 0);
|
|
404
|
-
this._directory = directory;
|
|
405
|
-
}
|
|
406
325
|
};
|
|
407
326
|
_ts_decorate([
|
|
408
327
|
synchronized
|
|
@@ -426,26 +345,13 @@ import { Event as Event2 } from "@dxos/async";
|
|
|
426
345
|
import { timed } from "@dxos/debug";
|
|
427
346
|
import { log as log2 } from "@dxos/log";
|
|
428
347
|
import { Timeframe } from "@dxos/timeframe";
|
|
429
|
-
|
|
430
|
-
if (key in obj) {
|
|
431
|
-
Object.defineProperty(obj, key, {
|
|
432
|
-
value,
|
|
433
|
-
enumerable: true,
|
|
434
|
-
configurable: true,
|
|
435
|
-
writable: true
|
|
436
|
-
});
|
|
437
|
-
} else {
|
|
438
|
-
obj[key] = value;
|
|
439
|
-
}
|
|
440
|
-
return obj;
|
|
441
|
-
}
|
|
348
|
+
var __dxlog_file3 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/timeframe-clock.ts";
|
|
442
349
|
function _ts_decorate2(decorators, target, key, desc) {
|
|
443
350
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
444
351
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
445
352
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
446
353
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
447
354
|
}
|
|
448
|
-
var __dxlog_file3 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/timeframe-clock.ts";
|
|
449
355
|
var mapTimeframeToFeedIndexes = (timeframe) => timeframe.frames().map(([feedKey, index]) => ({
|
|
450
356
|
feedKey,
|
|
451
357
|
index
|
|
@@ -459,6 +365,13 @@ var startAfter = (timeframe) => timeframe.frames().map(([feedKey, index]) => ({
|
|
|
459
365
|
index: index + 1
|
|
460
366
|
}));
|
|
461
367
|
var TimeframeClock = class {
|
|
368
|
+
_timeframe;
|
|
369
|
+
update = new Event2();
|
|
370
|
+
_pendingTimeframe;
|
|
371
|
+
constructor(_timeframe = new Timeframe()) {
|
|
372
|
+
this._timeframe = _timeframe;
|
|
373
|
+
this._pendingTimeframe = _timeframe;
|
|
374
|
+
}
|
|
462
375
|
/**
|
|
463
376
|
* Timeframe that was processed by ECHO.
|
|
464
377
|
*/
|
|
@@ -497,34 +410,16 @@ var TimeframeClock = class {
|
|
|
497
410
|
log2("waitUntilReached", {
|
|
498
411
|
target,
|
|
499
412
|
current: this._timeframe
|
|
500
|
-
}, {
|
|
501
|
-
F: __dxlog_file3,
|
|
502
|
-
L: 70,
|
|
503
|
-
S: this,
|
|
504
|
-
C: (f, a) => f(...a)
|
|
505
|
-
});
|
|
413
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 69, S: this });
|
|
506
414
|
await this.update.waitForCondition(() => {
|
|
507
415
|
log2("check if reached", {
|
|
508
416
|
target,
|
|
509
417
|
current: this._timeframe,
|
|
510
418
|
deps: Timeframe.dependencies(target, this._timeframe)
|
|
511
|
-
}, {
|
|
512
|
-
F: __dxlog_file3,
|
|
513
|
-
L: 72,
|
|
514
|
-
S: this,
|
|
515
|
-
C: (f, a) => f(...a)
|
|
516
|
-
});
|
|
419
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 74, S: this });
|
|
517
420
|
return Timeframe.dependencies(target, this._timeframe).isEmpty();
|
|
518
421
|
});
|
|
519
422
|
}
|
|
520
|
-
constructor(_timeframe = new Timeframe()) {
|
|
521
|
-
_define_property2(this, "_timeframe", void 0);
|
|
522
|
-
_define_property2(this, "update", void 0);
|
|
523
|
-
_define_property2(this, "_pendingTimeframe", void 0);
|
|
524
|
-
this._timeframe = _timeframe;
|
|
525
|
-
this.update = new Event2();
|
|
526
|
-
this._pendingTimeframe = _timeframe;
|
|
527
|
-
}
|
|
528
423
|
};
|
|
529
424
|
_ts_decorate2([
|
|
530
425
|
timed(5e3)
|
|
@@ -549,54 +444,55 @@ var createMessageSelector = (timeframeClock) => {
|
|
|
549
444
|
return (messages) => {
|
|
550
445
|
for (let i = 0; i < messages.length; i++) {
|
|
551
446
|
const { data: { timeframe } } = messages[i];
|
|
552
|
-
invariant3(timeframe, void 0, {
|
|
553
|
-
F: __dxlog_file4,
|
|
554
|
-
L: 25,
|
|
555
|
-
S: void 0,
|
|
556
|
-
A: [
|
|
557
|
-
"timeframe",
|
|
558
|
-
""
|
|
559
|
-
]
|
|
560
|
-
});
|
|
447
|
+
invariant3(timeframe, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 16, S: void 0, A: ["timeframe", ""] });
|
|
561
448
|
if (!timeframeClock.hasGaps(timeframe)) {
|
|
562
449
|
return i;
|
|
563
450
|
}
|
|
564
451
|
}
|
|
565
|
-
log3("Skipping...", void 0, {
|
|
566
|
-
F: __dxlog_file4,
|
|
567
|
-
L: 33,
|
|
568
|
-
S: void 0,
|
|
569
|
-
C: (f, a) => f(...a)
|
|
570
|
-
});
|
|
452
|
+
log3("Skipping...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 22, S: void 0 });
|
|
571
453
|
};
|
|
572
454
|
};
|
|
573
455
|
|
|
574
456
|
// src/pipeline/pipeline.ts
|
|
575
|
-
|
|
576
|
-
if (key in obj) {
|
|
577
|
-
Object.defineProperty(obj, key, {
|
|
578
|
-
value,
|
|
579
|
-
enumerable: true,
|
|
580
|
-
configurable: true,
|
|
581
|
-
writable: true
|
|
582
|
-
});
|
|
583
|
-
} else {
|
|
584
|
-
obj[key] = value;
|
|
585
|
-
}
|
|
586
|
-
return obj;
|
|
587
|
-
}
|
|
457
|
+
var __dxlog_file5 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts";
|
|
588
458
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
589
459
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
590
460
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
591
461
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
592
462
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
593
463
|
}
|
|
594
|
-
var __dxlog_file5 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts";
|
|
595
464
|
var PipelineState = class {
|
|
465
|
+
_feeds;
|
|
466
|
+
_timeframeClock;
|
|
467
|
+
/**
|
|
468
|
+
* @internal
|
|
469
|
+
*/
|
|
470
|
+
_ctx = new Context2(void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 29 });
|
|
596
471
|
// TODO(dmaretskyi): Remove?. Avoid accessing `_timeframeClock` before constructor initialization.
|
|
597
472
|
get timeframeUpdate() {
|
|
598
473
|
return this._timeframeClock.update;
|
|
599
474
|
}
|
|
475
|
+
stalled = new Event3();
|
|
476
|
+
/**
|
|
477
|
+
* @internal
|
|
478
|
+
*/
|
|
479
|
+
_startTimeframe = new Timeframe2();
|
|
480
|
+
/**
|
|
481
|
+
* Target timeframe we are waiting to reach.
|
|
482
|
+
*/
|
|
483
|
+
_targetTimeframe;
|
|
484
|
+
/**
|
|
485
|
+
* @internal
|
|
486
|
+
*/
|
|
487
|
+
_reachedTargetPromise;
|
|
488
|
+
/**
|
|
489
|
+
* @internal
|
|
490
|
+
*/
|
|
491
|
+
_reachedTarget = false;
|
|
492
|
+
constructor(_feeds, _timeframeClock) {
|
|
493
|
+
this._feeds = _feeds;
|
|
494
|
+
this._timeframeClock = _timeframeClock;
|
|
495
|
+
}
|
|
600
496
|
/**
|
|
601
497
|
* Latest theoretical timeframe based on the last mutation in each feed.
|
|
602
498
|
* NOTE: This might never be reached if the mutation dependencies
|
|
@@ -639,28 +535,20 @@ var PipelineState = class {
|
|
|
639
535
|
*
|
|
640
536
|
* @param timeout Timeout in milliseconds to specify the maximum wait time.
|
|
641
537
|
*/
|
|
642
|
-
async waitUntilReachedTargetTimeframe({ ctx = new Context2(void 0, {
|
|
643
|
-
F: __dxlog_file5,
|
|
644
|
-
L: 132
|
|
645
|
-
}), timeout, breakOnStall = true } = {}) {
|
|
538
|
+
async waitUntilReachedTargetTimeframe({ ctx = new Context2(void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 91 }), timeout, breakOnStall = true } = {}) {
|
|
646
539
|
log4("waitUntilReachedTargetTimeframe", {
|
|
647
540
|
timeout,
|
|
648
541
|
current: this.timeframe,
|
|
649
542
|
target: this.targetTimeframe
|
|
650
|
-
}, {
|
|
651
|
-
|
|
652
|
-
L: 136,
|
|
653
|
-
S: this,
|
|
654
|
-
C: (f, a) => f(...a)
|
|
655
|
-
});
|
|
656
|
-
this._reachedTargetPromise ?? (this._reachedTargetPromise = Promise.race([
|
|
543
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 92, S: this });
|
|
544
|
+
this._reachedTargetPromise ??= Promise.race([
|
|
657
545
|
this._timeframeClock.update.waitForCondition(() => {
|
|
658
546
|
return Timeframe2.dependencies(this.targetTimeframe, this.timeframe).isEmpty();
|
|
659
547
|
}),
|
|
660
548
|
...breakOnStall ? [
|
|
661
549
|
this.stalled.discardParameter().waitForCount(1)
|
|
662
550
|
] : []
|
|
663
|
-
])
|
|
551
|
+
]);
|
|
664
552
|
let done = false;
|
|
665
553
|
if (timeout) {
|
|
666
554
|
return Promise.race([
|
|
@@ -679,52 +567,37 @@ var PipelineState = class {
|
|
|
679
567
|
current: this.timeframe,
|
|
680
568
|
target: this.targetTimeframe,
|
|
681
569
|
dependencies: Timeframe2.dependencies(this.targetTimeframe, this.timeframe)
|
|
682
|
-
}, {
|
|
683
|
-
F: __dxlog_file5,
|
|
684
|
-
L: 164,
|
|
685
|
-
S: this,
|
|
686
|
-
C: (f, a) => f(...a)
|
|
687
|
-
});
|
|
570
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 118, S: this });
|
|
688
571
|
})
|
|
689
572
|
]);
|
|
690
573
|
} else {
|
|
691
574
|
return this._reachedTargetPromise;
|
|
692
575
|
}
|
|
693
576
|
}
|
|
694
|
-
constructor(_feeds, _timeframeClock) {
|
|
695
|
-
_define_property3(this, "_feeds", void 0);
|
|
696
|
-
_define_property3(this, "_timeframeClock", void 0);
|
|
697
|
-
_define_property3(this, "_ctx", void 0);
|
|
698
|
-
_define_property3(this, "stalled", void 0);
|
|
699
|
-
_define_property3(this, "_startTimeframe", void 0);
|
|
700
|
-
_define_property3(this, "_targetTimeframe", void 0);
|
|
701
|
-
_define_property3(this, "_reachedTargetPromise", void 0);
|
|
702
|
-
_define_property3(this, "_reachedTarget", void 0);
|
|
703
|
-
this._feeds = _feeds;
|
|
704
|
-
this._timeframeClock = _timeframeClock;
|
|
705
|
-
this._ctx = new Context2(void 0, {
|
|
706
|
-
F: __dxlog_file5,
|
|
707
|
-
L: 42
|
|
708
|
-
});
|
|
709
|
-
this.stalled = new Event3();
|
|
710
|
-
this._startTimeframe = new Timeframe2();
|
|
711
|
-
this._reachedTarget = false;
|
|
712
|
-
}
|
|
713
577
|
};
|
|
714
578
|
var Pipeline = class {
|
|
579
|
+
_timeframeClock = new TimeframeClock(new Timeframe2());
|
|
580
|
+
_feeds = new ComplexMap3(PublicKey3.hash);
|
|
581
|
+
// External state accessor.
|
|
582
|
+
_state = new PipelineState(this._feeds, this._timeframeClock);
|
|
583
|
+
// Waits for the message consumer to process the message and yield control back to the pipeline.
|
|
584
|
+
_processingTrigger = new Trigger().wake();
|
|
585
|
+
_pauseTrigger = new Trigger().wake();
|
|
586
|
+
// Pending downloads.
|
|
587
|
+
_downloads = new ComplexMap3((value) => PublicKey3.hash(value.key));
|
|
588
|
+
// Inbound feed stream.
|
|
589
|
+
_feedSetIterator;
|
|
590
|
+
// Outbound feed writer.
|
|
591
|
+
_writer;
|
|
592
|
+
_isStopping = false;
|
|
593
|
+
_isStarted = false;
|
|
594
|
+
_isBeingConsumed = false;
|
|
595
|
+
_isPaused = false;
|
|
715
596
|
get state() {
|
|
716
597
|
return this._state;
|
|
717
598
|
}
|
|
718
599
|
get writer() {
|
|
719
|
-
invariant4(this._writer, "Writer not set.", {
|
|
720
|
-
F: __dxlog_file5,
|
|
721
|
-
L: 246,
|
|
722
|
-
S: this,
|
|
723
|
-
A: [
|
|
724
|
-
"this._writer",
|
|
725
|
-
"'Writer not set.'"
|
|
726
|
-
]
|
|
727
|
-
});
|
|
600
|
+
invariant4(this._writer, "Writer not set.", { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 184, S: this, A: ["this._writer", "'Writer not set.'"] });
|
|
728
601
|
return this._writer;
|
|
729
602
|
}
|
|
730
603
|
hasFeed(feedKey) {
|
|
@@ -745,54 +618,20 @@ var Pipeline = class {
|
|
|
745
618
|
}
|
|
746
619
|
}
|
|
747
620
|
setWriteFeed(feed) {
|
|
748
|
-
invariant4(!this._writer, "Writer already set.", {
|
|
749
|
-
|
|
750
|
-
L: 273,
|
|
751
|
-
S: this,
|
|
752
|
-
A: [
|
|
753
|
-
"!this._writer",
|
|
754
|
-
"'Writer already set.'"
|
|
755
|
-
]
|
|
756
|
-
});
|
|
757
|
-
invariant4(feed.properties.writable, "Feed must be writable.", {
|
|
758
|
-
F: __dxlog_file5,
|
|
759
|
-
L: 274,
|
|
760
|
-
S: this,
|
|
761
|
-
A: [
|
|
762
|
-
"feed.properties.writable",
|
|
763
|
-
"'Feed must be writable.'"
|
|
764
|
-
]
|
|
765
|
-
});
|
|
621
|
+
invariant4(!this._writer, "Writer already set.", { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 205, S: this, A: ["!this._writer", "'Writer already set.'"] });
|
|
622
|
+
invariant4(feed.properties.writable, "Feed must be writable.", { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 206, S: this, A: ["feed.properties.writable", "'Feed must be writable.'"] });
|
|
766
623
|
this._writer = createMappedFeedWriter((payload) => ({
|
|
767
624
|
timeframe: this._timeframeClock.timeframe,
|
|
768
625
|
payload
|
|
769
626
|
}), feed.createFeedWriter());
|
|
770
627
|
}
|
|
771
628
|
async start() {
|
|
772
|
-
invariant4(!this._isStarted, "Pipeline is already started.", {
|
|
773
|
-
|
|
774
|
-
L: 287,
|
|
775
|
-
S: this,
|
|
776
|
-
A: [
|
|
777
|
-
"!this._isStarted",
|
|
778
|
-
"'Pipeline is already started.'"
|
|
779
|
-
]
|
|
780
|
-
});
|
|
781
|
-
log4("starting...", void 0, {
|
|
782
|
-
F: __dxlog_file5,
|
|
783
|
-
L: 288,
|
|
784
|
-
S: this,
|
|
785
|
-
C: (f, a) => f(...a)
|
|
786
|
-
});
|
|
629
|
+
invariant4(!this._isStarted, "Pipeline is already started.", { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 213, S: this, A: ["!this._isStarted", "'Pipeline is already started.'"] });
|
|
630
|
+
log4("starting...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 214, S: this });
|
|
787
631
|
await this._initIterator();
|
|
788
632
|
await this._feedSetIterator.open();
|
|
789
633
|
this._isStarted = true;
|
|
790
|
-
log4("started", void 0, {
|
|
791
|
-
F: __dxlog_file5,
|
|
792
|
-
L: 292,
|
|
793
|
-
S: this,
|
|
794
|
-
C: (f, a) => f(...a)
|
|
795
|
-
});
|
|
634
|
+
log4("started", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 218, S: this });
|
|
796
635
|
if (!this._isPaused) {
|
|
797
636
|
for (const feed of this._feeds.values()) {
|
|
798
637
|
this._setFeedDownloadState(feed);
|
|
@@ -800,12 +639,7 @@ var Pipeline = class {
|
|
|
800
639
|
}
|
|
801
640
|
}
|
|
802
641
|
async stop() {
|
|
803
|
-
log4("stopping...", void 0, {
|
|
804
|
-
F: __dxlog_file5,
|
|
805
|
-
L: 303,
|
|
806
|
-
S: this,
|
|
807
|
-
C: (f, a) => f(...a)
|
|
808
|
-
});
|
|
642
|
+
log4("stopping...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 226, S: this });
|
|
809
643
|
this._isStopping = true;
|
|
810
644
|
for (const [feed, handle] of this._downloads.entries()) {
|
|
811
645
|
feed.undownload(handle);
|
|
@@ -814,34 +648,18 @@ var Pipeline = class {
|
|
|
814
648
|
await this._feedSetIterator?.close();
|
|
815
649
|
await this._processingTrigger.wait();
|
|
816
650
|
await this._state._ctx.dispose();
|
|
817
|
-
this._state._ctx = new Context2(void 0, {
|
|
818
|
-
F: __dxlog_file5,
|
|
819
|
-
L: 312
|
|
820
|
-
});
|
|
651
|
+
this._state._ctx = new Context2(void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 235 });
|
|
821
652
|
this._state._reachedTargetPromise = void 0;
|
|
822
653
|
this._state._reachedTarget = false;
|
|
823
654
|
this._isStarted = false;
|
|
824
|
-
log4("stopped", void 0, {
|
|
825
|
-
F: __dxlog_file5,
|
|
826
|
-
L: 316,
|
|
827
|
-
S: this,
|
|
828
|
-
C: (f, a) => f(...a)
|
|
829
|
-
});
|
|
655
|
+
log4("stopped", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 239, S: this });
|
|
830
656
|
}
|
|
831
657
|
/**
|
|
832
658
|
* @param timeframe Timeframe of already processed messages.
|
|
833
659
|
* The pipeline will start processing messages AFTER this timeframe.
|
|
834
660
|
*/
|
|
835
661
|
async setCursor(timeframe) {
|
|
836
|
-
invariant4(!this._isStarted || this._isPaused, "Invalid state.", {
|
|
837
|
-
F: __dxlog_file5,
|
|
838
|
-
L: 325,
|
|
839
|
-
S: this,
|
|
840
|
-
A: [
|
|
841
|
-
"!this._isStarted || this._isPaused",
|
|
842
|
-
"'Invalid state.'"
|
|
843
|
-
]
|
|
844
|
-
});
|
|
662
|
+
invariant4(!this._isStarted || this._isPaused, "Invalid state.", { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 245, S: this, A: ["!this._isStarted || this._isPaused", "'Invalid state.'"] });
|
|
845
663
|
this._state._startTimeframe = timeframe;
|
|
846
664
|
this._timeframeClock.setTimeframe(timeframe);
|
|
847
665
|
if (this._feedSetIterator) {
|
|
@@ -862,15 +680,7 @@ var Pipeline = class {
|
|
|
862
680
|
this._isPaused = true;
|
|
863
681
|
}
|
|
864
682
|
async unpause() {
|
|
865
|
-
invariant4(this._isPaused, "Pipeline is not paused.", {
|
|
866
|
-
F: __dxlog_file5,
|
|
867
|
-
L: 354,
|
|
868
|
-
S: this,
|
|
869
|
-
A: [
|
|
870
|
-
"this._isPaused",
|
|
871
|
-
"'Pipeline is not paused.'"
|
|
872
|
-
]
|
|
873
|
-
});
|
|
683
|
+
invariant4(this._isPaused, "Pipeline is not paused.", { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 266, S: this, A: ["this._isPaused", "'Pipeline is not paused.'"] });
|
|
874
684
|
this._pauseTrigger.wake();
|
|
875
685
|
this._isPaused = false;
|
|
876
686
|
for (const feed of this._feeds.values()) {
|
|
@@ -882,39 +692,15 @@ var Pipeline = class {
|
|
|
882
692
|
* Updates the timeframe clock after the message has bee processed.
|
|
883
693
|
*/
|
|
884
694
|
async *consume() {
|
|
885
|
-
invariant4(!this._isBeingConsumed, "Pipeline is already being consumed.", {
|
|
886
|
-
F: __dxlog_file5,
|
|
887
|
-
L: 369,
|
|
888
|
-
S: this,
|
|
889
|
-
A: [
|
|
890
|
-
"!this._isBeingConsumed",
|
|
891
|
-
"'Pipeline is already being consumed.'"
|
|
892
|
-
]
|
|
893
|
-
});
|
|
695
|
+
invariant4(!this._isBeingConsumed, "Pipeline is already being consumed.", { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 277, S: this, A: ["!this._isBeingConsumed", "'Pipeline is already being consumed.'"] });
|
|
894
696
|
this._isBeingConsumed = true;
|
|
895
|
-
invariant4(this._feedSetIterator, "Iterator not initialized.", {
|
|
896
|
-
F: __dxlog_file5,
|
|
897
|
-
L: 372,
|
|
898
|
-
S: this,
|
|
899
|
-
A: [
|
|
900
|
-
"this._feedSetIterator",
|
|
901
|
-
"'Iterator not initialized.'"
|
|
902
|
-
]
|
|
903
|
-
});
|
|
697
|
+
invariant4(this._feedSetIterator, "Iterator not initialized.", { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 279, S: this, A: ["this._feedSetIterator", "'Iterator not initialized.'"] });
|
|
904
698
|
let lastFeedSetIterator = this._feedSetIterator;
|
|
905
699
|
let iterable = lastFeedSetIterator[Symbol.asyncIterator]();
|
|
906
700
|
while (!this._isStopping) {
|
|
907
701
|
await this._pauseTrigger.wait();
|
|
908
702
|
if (lastFeedSetIterator !== this._feedSetIterator) {
|
|
909
|
-
invariant4(this._feedSetIterator, "Iterator not initialized.", {
|
|
910
|
-
F: __dxlog_file5,
|
|
911
|
-
L: 381,
|
|
912
|
-
S: this,
|
|
913
|
-
A: [
|
|
914
|
-
"this._feedSetIterator",
|
|
915
|
-
"'Iterator not initialized.'"
|
|
916
|
-
]
|
|
917
|
-
});
|
|
703
|
+
invariant4(this._feedSetIterator, "Iterator not initialized.", { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 286, S: this, A: ["this._feedSetIterator", "'Iterator not initialized.'"] });
|
|
918
704
|
lastFeedSetIterator = this._feedSetIterator;
|
|
919
705
|
iterable = lastFeedSetIterator[Symbol.asyncIterator]();
|
|
920
706
|
}
|
|
@@ -941,12 +727,7 @@ var Pipeline = class {
|
|
|
941
727
|
feed: feed.key.truncate(),
|
|
942
728
|
seq,
|
|
943
729
|
length: feed.length
|
|
944
|
-
}, {
|
|
945
|
-
F: __dxlog_file5,
|
|
946
|
-
L: 410,
|
|
947
|
-
S: this,
|
|
948
|
-
C: (f, a) => f(...a)
|
|
949
|
-
});
|
|
730
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 311, S: this });
|
|
950
731
|
handle = feed.download({
|
|
951
732
|
start: seq + 1,
|
|
952
733
|
linear: true
|
|
@@ -955,12 +736,7 @@ var Pipeline = class {
|
|
|
955
736
|
} else {
|
|
956
737
|
log4("downloaded", {
|
|
957
738
|
data
|
|
958
|
-
}, {
|
|
959
|
-
F: __dxlog_file5,
|
|
960
|
-
L: 415,
|
|
961
|
-
S: this,
|
|
962
|
-
C: (f, a) => f(...a)
|
|
963
|
-
});
|
|
739
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 323, S: this });
|
|
964
740
|
}
|
|
965
741
|
});
|
|
966
742
|
this._downloads.set(feed, handle);
|
|
@@ -974,32 +750,13 @@ var Pipeline = class {
|
|
|
974
750
|
log4.warn(`Stalled after ${iterator.options.stallTimeout}ms with ${iterator.size} feeds.`, {
|
|
975
751
|
currentTimeframe: this._timeframeClock.timeframe,
|
|
976
752
|
targetTimeframe: this._state.targetTimeframe
|
|
977
|
-
}, {
|
|
978
|
-
F: __dxlog_file5,
|
|
979
|
-
L: 429,
|
|
980
|
-
S: this,
|
|
981
|
-
C: (f, a) => f(...a)
|
|
982
|
-
});
|
|
753
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 336, S: this });
|
|
983
754
|
this._state.stalled.emit();
|
|
984
755
|
});
|
|
985
756
|
for (const feed of this._feeds.values()) {
|
|
986
757
|
await this._feedSetIterator.addFeed(feed);
|
|
987
758
|
}
|
|
988
759
|
}
|
|
989
|
-
constructor() {
|
|
990
|
-
_define_property3(this, "_timeframeClock", new TimeframeClock(new Timeframe2()));
|
|
991
|
-
_define_property3(this, "_feeds", new ComplexMap3(PublicKey3.hash));
|
|
992
|
-
_define_property3(this, "_state", new PipelineState(this._feeds, this._timeframeClock));
|
|
993
|
-
_define_property3(this, "_processingTrigger", new Trigger().wake());
|
|
994
|
-
_define_property3(this, "_pauseTrigger", new Trigger().wake());
|
|
995
|
-
_define_property3(this, "_downloads", new ComplexMap3((value) => PublicKey3.hash(value.key)));
|
|
996
|
-
_define_property3(this, "_feedSetIterator", void 0);
|
|
997
|
-
_define_property3(this, "_writer", void 0);
|
|
998
|
-
_define_property3(this, "_isStopping", false);
|
|
999
|
-
_define_property3(this, "_isStarted", false);
|
|
1000
|
-
_define_property3(this, "_isBeingConsumed", false);
|
|
1001
|
-
_define_property3(this, "_isPaused", false);
|
|
1002
|
-
}
|
|
1003
760
|
};
|
|
1004
761
|
_ts_decorate3([
|
|
1005
762
|
synchronized2
|
|
@@ -1025,27 +782,31 @@ import { invariant as invariant5 } from "@dxos/invariant";
|
|
|
1025
782
|
import { log as log5 } from "@dxos/log";
|
|
1026
783
|
import { schema as schema3 } from "@dxos/protocols/proto";
|
|
1027
784
|
import { RpcExtension } from "@dxos/teleport";
|
|
1028
|
-
function _define_property4(obj, key, value) {
|
|
1029
|
-
if (key in obj) {
|
|
1030
|
-
Object.defineProperty(obj, key, {
|
|
1031
|
-
value,
|
|
1032
|
-
enumerable: true,
|
|
1033
|
-
configurable: true,
|
|
1034
|
-
writable: true
|
|
1035
|
-
});
|
|
1036
|
-
} else {
|
|
1037
|
-
obj[key] = value;
|
|
1038
|
-
}
|
|
1039
|
-
return obj;
|
|
1040
|
-
}
|
|
1041
785
|
var __dxlog_file6 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/space/auth.ts";
|
|
1042
786
|
var AuthExtension = class extends RpcExtension {
|
|
787
|
+
_authProps;
|
|
788
|
+
_ctx = new Context3({
|
|
789
|
+
onError: (err) => {
|
|
790
|
+
log5.catch(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 15, S: this });
|
|
791
|
+
}
|
|
792
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 13 });
|
|
793
|
+
constructor(_authProps) {
|
|
794
|
+
super({
|
|
795
|
+
requested: {
|
|
796
|
+
AuthService: schema3.getService("dxos.mesh.teleport.auth.AuthService")
|
|
797
|
+
},
|
|
798
|
+
exposed: {
|
|
799
|
+
AuthService: schema3.getService("dxos.mesh.teleport.auth.AuthService")
|
|
800
|
+
},
|
|
801
|
+
timeout: 60 * 1e3
|
|
802
|
+
}), this._authProps = _authProps;
|
|
803
|
+
}
|
|
1043
804
|
async getHandlers() {
|
|
1044
805
|
return {
|
|
1045
806
|
AuthService: {
|
|
1046
807
|
authenticate: async ({ challenge }) => {
|
|
1047
808
|
try {
|
|
1048
|
-
const credential = await this.
|
|
809
|
+
const credential = await this._authProps.provider(challenge);
|
|
1049
810
|
if (!credential) {
|
|
1050
811
|
throw new Error("auth rejected");
|
|
1051
812
|
}
|
|
@@ -1053,12 +814,7 @@ var AuthExtension = class extends RpcExtension {
|
|
|
1053
814
|
credential
|
|
1054
815
|
};
|
|
1055
816
|
} catch (err) {
|
|
1056
|
-
log5.error("failed to generate auth credentials", err, {
|
|
1057
|
-
F: __dxlog_file6,
|
|
1058
|
-
L: 55,
|
|
1059
|
-
S: this,
|
|
1060
|
-
C: (f, a) => f(...a)
|
|
1061
|
-
});
|
|
817
|
+
log5.error("failed to generate auth credentials", err, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 42, S: this });
|
|
1062
818
|
throw new Error("auth rejected");
|
|
1063
819
|
}
|
|
1064
820
|
}
|
|
@@ -1073,35 +829,14 @@ var AuthExtension = class extends RpcExtension {
|
|
|
1073
829
|
const { credential } = await this.rpc.AuthService.authenticate({
|
|
1074
830
|
challenge
|
|
1075
831
|
});
|
|
1076
|
-
invariant5(credential?.length > 0, "invalid credential", {
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
A: [
|
|
1081
|
-
"credential?.length > 0",
|
|
1082
|
-
"'invalid credential'"
|
|
1083
|
-
]
|
|
1084
|
-
});
|
|
1085
|
-
const success = await this._authParams.verifier(challenge, credential);
|
|
1086
|
-
invariant5(success, "credential not verified", {
|
|
1087
|
-
F: __dxlog_file6,
|
|
1088
|
-
L: 71,
|
|
1089
|
-
S: this,
|
|
1090
|
-
A: [
|
|
1091
|
-
"success",
|
|
1092
|
-
"'credential not verified'"
|
|
1093
|
-
]
|
|
1094
|
-
});
|
|
1095
|
-
runInContext(this._ctx, () => this._authParams.onAuthSuccess());
|
|
832
|
+
invariant5(credential?.length > 0, "invalid credential", { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 57, S: this, A: ["credential?.length > 0", "'invalid credential'"] });
|
|
833
|
+
const success = await this._authProps.verifier(challenge, credential);
|
|
834
|
+
invariant5(success, "credential not verified", { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 59, S: this, A: ["success", "'credential not verified'"] });
|
|
835
|
+
runInContext(this._ctx, () => this._authProps.onAuthSuccess());
|
|
1096
836
|
} catch (err) {
|
|
1097
|
-
log5("auth failed", err, {
|
|
1098
|
-
F: __dxlog_file6,
|
|
1099
|
-
L: 74,
|
|
1100
|
-
S: this,
|
|
1101
|
-
C: (f, a) => f(...a)
|
|
1102
|
-
});
|
|
837
|
+
log5("auth failed", err, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 62, S: this });
|
|
1103
838
|
this.close();
|
|
1104
|
-
this.
|
|
839
|
+
this._authProps.onAuthFailure();
|
|
1105
840
|
}
|
|
1106
841
|
});
|
|
1107
842
|
}
|
|
@@ -1113,29 +848,6 @@ var AuthExtension = class extends RpcExtension {
|
|
|
1113
848
|
await this._ctx.dispose();
|
|
1114
849
|
await super.onAbort();
|
|
1115
850
|
}
|
|
1116
|
-
constructor(_authParams) {
|
|
1117
|
-
super({
|
|
1118
|
-
requested: {
|
|
1119
|
-
AuthService: schema3.getService("dxos.mesh.teleport.auth.AuthService")
|
|
1120
|
-
},
|
|
1121
|
-
exposed: {
|
|
1122
|
-
AuthService: schema3.getService("dxos.mesh.teleport.auth.AuthService")
|
|
1123
|
-
},
|
|
1124
|
-
timeout: 60 * 1e3
|
|
1125
|
-
}), _define_property4(this, "_authParams", void 0), _define_property4(this, "_ctx", void 0), this._authParams = _authParams, this._ctx = new Context3({
|
|
1126
|
-
onError: (err) => {
|
|
1127
|
-
log5.catch(err, void 0, {
|
|
1128
|
-
F: __dxlog_file6,
|
|
1129
|
-
L: 28,
|
|
1130
|
-
S: this,
|
|
1131
|
-
C: (f, a) => f(...a)
|
|
1132
|
-
});
|
|
1133
|
-
}
|
|
1134
|
-
}, {
|
|
1135
|
-
F: __dxlog_file6,
|
|
1136
|
-
L: 26
|
|
1137
|
-
});
|
|
1138
|
-
}
|
|
1139
851
|
};
|
|
1140
852
|
|
|
1141
853
|
// src/space/space.ts
|
|
@@ -1157,30 +869,67 @@ import { AdmittedFeed } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
|
1157
869
|
import { Timeframe as Timeframe3 } from "@dxos/timeframe";
|
|
1158
870
|
import { TimeSeriesCounter, TimeUsageCounter, trace } from "@dxos/tracing";
|
|
1159
871
|
import { Callback, tracer } from "@dxos/util";
|
|
1160
|
-
|
|
1161
|
-
if (key in obj) {
|
|
1162
|
-
Object.defineProperty(obj, key, {
|
|
1163
|
-
value,
|
|
1164
|
-
enumerable: true,
|
|
1165
|
-
configurable: true,
|
|
1166
|
-
writable: true
|
|
1167
|
-
});
|
|
1168
|
-
} else {
|
|
1169
|
-
obj[key] = value;
|
|
1170
|
-
}
|
|
1171
|
-
return obj;
|
|
1172
|
-
}
|
|
872
|
+
var __dxlog_file7 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/space/control-pipeline.ts";
|
|
1173
873
|
function _ts_decorate4(decorators, target, key, desc) {
|
|
1174
874
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1175
875
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1176
876
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1177
877
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1178
878
|
}
|
|
1179
|
-
var __dxlog_file7 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/space/control-pipeline.ts";
|
|
1180
879
|
var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL = 500;
|
|
1181
880
|
var CONTROL_PIPELINE_SNAPSHOT_DELAY = 1e4;
|
|
1182
881
|
var USE_SNAPSHOTS = true;
|
|
1183
882
|
var ControlPipeline = class {
|
|
883
|
+
_ctx = new Context4(void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file7, L: 24 });
|
|
884
|
+
_pipeline;
|
|
885
|
+
_spaceStateMachine;
|
|
886
|
+
_spaceKey;
|
|
887
|
+
_metadata;
|
|
888
|
+
_targetTimeframe;
|
|
889
|
+
_lastTimeframeSaveTime = Date.now();
|
|
890
|
+
onFeedAdmitted = new Callback();
|
|
891
|
+
onMemberRoleChanged;
|
|
892
|
+
onCredentialProcessed;
|
|
893
|
+
onDelegatedInvitation;
|
|
894
|
+
onDelegatedInvitationRemoved;
|
|
895
|
+
_usage = new TimeUsageCounter();
|
|
896
|
+
_mutations = new TimeSeriesCounter();
|
|
897
|
+
_snapshotTask = new DeferredTask(this._ctx, async () => {
|
|
898
|
+
await sleepWithContext2(this._ctx, CONTROL_PIPELINE_SNAPSHOT_DELAY);
|
|
899
|
+
await this._saveSnapshot();
|
|
900
|
+
});
|
|
901
|
+
constructor({ spaceKey, genesisFeed, feedProvider, metadataStore }) {
|
|
902
|
+
this._spaceKey = spaceKey;
|
|
903
|
+
this._metadata = metadataStore;
|
|
904
|
+
this._pipeline = new Pipeline();
|
|
905
|
+
void this._pipeline.addFeed(genesisFeed);
|
|
906
|
+
this._spaceStateMachine = new SpaceStateMachine(spaceKey);
|
|
907
|
+
this._spaceStateMachine.onFeedAdmitted.set(async (info) => {
|
|
908
|
+
log6("feed admitted", {
|
|
909
|
+
key: info.key
|
|
910
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file7, L: 50, S: this });
|
|
911
|
+
if (info.assertion.designation === AdmittedFeed.Designation.CONTROL && !info.key.equals(genesisFeed.key)) {
|
|
912
|
+
scheduleMicroTask(this._ctx, async () => {
|
|
913
|
+
try {
|
|
914
|
+
const feed = await feedProvider(info.key);
|
|
915
|
+
if (this._ctx.disposed) {
|
|
916
|
+
return;
|
|
917
|
+
}
|
|
918
|
+
if (!this._pipeline.hasFeed(feed.key)) {
|
|
919
|
+
await this._pipeline.addFeed(feed);
|
|
920
|
+
}
|
|
921
|
+
} catch (err) {
|
|
922
|
+
log6.catch(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file7, L: 65, S: this });
|
|
923
|
+
}
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
await this.onFeedAdmitted.callIfSet(info);
|
|
927
|
+
});
|
|
928
|
+
this.onMemberRoleChanged = this._spaceStateMachine.onMemberRoleChanged;
|
|
929
|
+
this.onCredentialProcessed = this._spaceStateMachine.onCredentialProcessed;
|
|
930
|
+
this.onDelegatedInvitation = this._spaceStateMachine.onDelegatedInvitation;
|
|
931
|
+
this.onDelegatedInvitationRemoved = this._spaceStateMachine.onDelegatedInvitationRemoved;
|
|
932
|
+
}
|
|
1184
933
|
get spaceState() {
|
|
1185
934
|
return this._spaceStateMachine;
|
|
1186
935
|
}
|
|
@@ -1191,40 +940,22 @@ var ControlPipeline = class {
|
|
|
1191
940
|
await this._pipeline.addFeed(feed);
|
|
1192
941
|
this._pipeline.setWriteFeed(feed);
|
|
1193
942
|
}
|
|
1194
|
-
async start() {
|
|
943
|
+
async start(ctx) {
|
|
1195
944
|
const snapshot = this._metadata.getSpaceControlPipelineSnapshot(this._spaceKey);
|
|
1196
945
|
log6("load snapshot", {
|
|
1197
946
|
key: this._spaceKey,
|
|
1198
947
|
present: !!snapshot,
|
|
1199
948
|
tf: snapshot?.timeframe
|
|
1200
|
-
}, {
|
|
1201
|
-
F: __dxlog_file7,
|
|
1202
|
-
L: 126,
|
|
1203
|
-
S: this,
|
|
1204
|
-
C: (f, a) => f(...a)
|
|
1205
|
-
});
|
|
949
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file7, L: 88, S: this });
|
|
1206
950
|
if (USE_SNAPSHOTS && snapshot) {
|
|
1207
951
|
await this._processSnapshot(snapshot);
|
|
1208
952
|
}
|
|
1209
|
-
log6("starting...", void 0, {
|
|
1210
|
-
F: __dxlog_file7,
|
|
1211
|
-
L: 131,
|
|
1212
|
-
S: this,
|
|
1213
|
-
C: (f, a) => f(...a)
|
|
1214
|
-
});
|
|
953
|
+
log6("starting...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file7, L: 96, S: this });
|
|
1215
954
|
setTimeout(async () => {
|
|
1216
|
-
void this._consumePipeline(
|
|
1217
|
-
F: __dxlog_file7,
|
|
1218
|
-
L: 133
|
|
1219
|
-
}));
|
|
955
|
+
void this._consumePipeline(ctx);
|
|
1220
956
|
});
|
|
1221
957
|
await this._pipeline.start();
|
|
1222
|
-
log6("started", void 0, {
|
|
1223
|
-
F: __dxlog_file7,
|
|
1224
|
-
L: 137,
|
|
1225
|
-
S: this,
|
|
1226
|
-
C: (f, a) => f(...a)
|
|
1227
|
-
});
|
|
958
|
+
log6("started", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file7, L: 101, S: this });
|
|
1228
959
|
}
|
|
1229
960
|
async _processSnapshot(snapshot) {
|
|
1230
961
|
await this._pipeline.setCursor(snapshot.timeframe);
|
|
@@ -1236,12 +967,7 @@ var ControlPipeline = class {
|
|
|
1236
967
|
if (!result) {
|
|
1237
968
|
log6.warn("credential processing failed from snapshot", {
|
|
1238
969
|
message
|
|
1239
|
-
}, {
|
|
1240
|
-
F: __dxlog_file7,
|
|
1241
|
-
L: 150,
|
|
1242
|
-
S: this,
|
|
1243
|
-
C: (f, a) => f(...a)
|
|
1244
|
-
});
|
|
970
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file7, L: 111, S: this });
|
|
1245
971
|
}
|
|
1246
972
|
}
|
|
1247
973
|
}
|
|
@@ -1258,12 +984,7 @@ var ControlPipeline = class {
|
|
|
1258
984
|
log6("save snapshot", {
|
|
1259
985
|
key: this._spaceKey,
|
|
1260
986
|
snapshot: getSnapshotLoggerContext(snapshot)
|
|
1261
|
-
}, {
|
|
1262
|
-
F: __dxlog_file7,
|
|
1263
|
-
L: 166,
|
|
1264
|
-
S: this,
|
|
1265
|
-
C: (f, a) => f(...a)
|
|
1266
|
-
});
|
|
987
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file7, L: 127, S: this });
|
|
1267
988
|
await this._metadata.setSpaceControlPipelineSnapshot(this._spaceKey, snapshot);
|
|
1268
989
|
}
|
|
1269
990
|
async _consumePipeline(ctx) {
|
|
@@ -1273,12 +994,7 @@ var ControlPipeline = class {
|
|
|
1273
994
|
try {
|
|
1274
995
|
await this._processMessage(ctx, msg);
|
|
1275
996
|
} catch (err) {
|
|
1276
|
-
log6.catch(err, void 0, {
|
|
1277
|
-
F: __dxlog_file7,
|
|
1278
|
-
L: 179,
|
|
1279
|
-
S: this,
|
|
1280
|
-
C: (f, a) => f(...a)
|
|
1281
|
-
});
|
|
997
|
+
log6.catch(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file7, L: 140, S: this });
|
|
1282
998
|
}
|
|
1283
999
|
span.end();
|
|
1284
1000
|
}
|
|
@@ -1287,12 +1003,7 @@ var ControlPipeline = class {
|
|
|
1287
1003
|
log6("processing", {
|
|
1288
1004
|
key: msg.feedKey,
|
|
1289
1005
|
seq: msg.seq
|
|
1290
|
-
}, {
|
|
1291
|
-
F: __dxlog_file7,
|
|
1292
|
-
L: 188,
|
|
1293
|
-
S: this,
|
|
1294
|
-
C: (f, a) => f(...a)
|
|
1295
|
-
});
|
|
1006
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file7, L: 146, S: this });
|
|
1296
1007
|
if (msg.data.payload.credential) {
|
|
1297
1008
|
const timer = tracer.mark("dxos.echo.pipeline.control");
|
|
1298
1009
|
const result = await this._spaceStateMachine.process(msg.data.payload.credential.credential, {
|
|
@@ -1302,12 +1013,7 @@ var ControlPipeline = class {
|
|
|
1302
1013
|
if (!result) {
|
|
1303
1014
|
log6.warn("processing failed", {
|
|
1304
1015
|
msg
|
|
1305
|
-
}, {
|
|
1306
|
-
F: __dxlog_file7,
|
|
1307
|
-
L: 197,
|
|
1308
|
-
S: this,
|
|
1309
|
-
C: (f, a) => f(...a)
|
|
1310
|
-
});
|
|
1016
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file7, L: 157, S: this });
|
|
1311
1017
|
} else {
|
|
1312
1018
|
await this._noteTargetStateIfNeeded(this._pipeline.state.pendingTimeframe);
|
|
1313
1019
|
}
|
|
@@ -1321,21 +1027,11 @@ var ControlPipeline = class {
|
|
|
1321
1027
|
}
|
|
1322
1028
|
}
|
|
1323
1029
|
async stop() {
|
|
1324
|
-
log6("stopping...", void 0, {
|
|
1325
|
-
F: __dxlog_file7,
|
|
1326
|
-
L: 217,
|
|
1327
|
-
S: this,
|
|
1328
|
-
C: (f, a) => f(...a)
|
|
1329
|
-
});
|
|
1030
|
+
log6("stopping...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file7, L: 174, S: this });
|
|
1330
1031
|
await this._ctx.dispose();
|
|
1331
1032
|
await this._pipeline.stop();
|
|
1332
1033
|
await this._saveTargetTimeframe(this._pipeline.state.timeframe);
|
|
1333
|
-
log6("stopped", void 0, {
|
|
1334
|
-
F: __dxlog_file7,
|
|
1335
|
-
L: 221,
|
|
1336
|
-
S: this,
|
|
1337
|
-
C: (f, a) => f(...a)
|
|
1338
|
-
});
|
|
1034
|
+
log6("stopped", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file7, L: 178, S: this });
|
|
1339
1035
|
}
|
|
1340
1036
|
async _saveTargetTimeframe(timeframe) {
|
|
1341
1037
|
try {
|
|
@@ -1343,78 +1039,15 @@ var ControlPipeline = class {
|
|
|
1343
1039
|
await this._metadata.setSpaceControlLatestTimeframe(this._spaceKey, newTimeframe);
|
|
1344
1040
|
this._targetTimeframe = newTimeframe;
|
|
1345
1041
|
} catch (err) {
|
|
1346
|
-
log6(err, void 0, {
|
|
1347
|
-
F: __dxlog_file7,
|
|
1348
|
-
L: 230,
|
|
1349
|
-
S: this,
|
|
1350
|
-
C: (f, a) => f(...a)
|
|
1351
|
-
});
|
|
1042
|
+
log6(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file7, L: 186, S: this });
|
|
1352
1043
|
}
|
|
1353
1044
|
}
|
|
1354
|
-
constructor({ spaceKey, genesisFeed, feedProvider, metadataStore }) {
|
|
1355
|
-
_define_property5(this, "_ctx", new Context4(void 0, {
|
|
1356
|
-
F: __dxlog_file7,
|
|
1357
|
-
L: 47
|
|
1358
|
-
}));
|
|
1359
|
-
_define_property5(this, "_pipeline", void 0);
|
|
1360
|
-
_define_property5(this, "_spaceStateMachine", void 0);
|
|
1361
|
-
_define_property5(this, "_spaceKey", void 0);
|
|
1362
|
-
_define_property5(this, "_metadata", void 0);
|
|
1363
|
-
_define_property5(this, "_targetTimeframe", void 0);
|
|
1364
|
-
_define_property5(this, "_lastTimeframeSaveTime", Date.now());
|
|
1365
|
-
_define_property5(this, "onFeedAdmitted", new Callback());
|
|
1366
|
-
_define_property5(this, "onMemberRoleChanged", void 0);
|
|
1367
|
-
_define_property5(this, "onCredentialProcessed", void 0);
|
|
1368
|
-
_define_property5(this, "onDelegatedInvitation", void 0);
|
|
1369
|
-
_define_property5(this, "onDelegatedInvitationRemoved", void 0);
|
|
1370
|
-
_define_property5(this, "_usage", new TimeUsageCounter());
|
|
1371
|
-
_define_property5(this, "_mutations", new TimeSeriesCounter());
|
|
1372
|
-
_define_property5(this, "_snapshotTask", new DeferredTask(this._ctx, async () => {
|
|
1373
|
-
await sleepWithContext2(this._ctx, CONTROL_PIPELINE_SNAPSHOT_DELAY);
|
|
1374
|
-
await this._saveSnapshot();
|
|
1375
|
-
}));
|
|
1376
|
-
this._spaceKey = spaceKey;
|
|
1377
|
-
this._metadata = metadataStore;
|
|
1378
|
-
this._pipeline = new Pipeline();
|
|
1379
|
-
void this._pipeline.addFeed(genesisFeed);
|
|
1380
|
-
this._spaceStateMachine = new SpaceStateMachine(spaceKey);
|
|
1381
|
-
this._spaceStateMachine.onFeedAdmitted.set(async (info) => {
|
|
1382
|
-
log6("feed admitted", {
|
|
1383
|
-
key: info.key
|
|
1384
|
-
}, {
|
|
1385
|
-
F: __dxlog_file7,
|
|
1386
|
-
L: 82,
|
|
1387
|
-
S: this,
|
|
1388
|
-
C: (f, a) => f(...a)
|
|
1389
|
-
});
|
|
1390
|
-
if (info.assertion.designation === AdmittedFeed.Designation.CONTROL && !info.key.equals(genesisFeed.key)) {
|
|
1391
|
-
scheduleMicroTask(this._ctx, async () => {
|
|
1392
|
-
try {
|
|
1393
|
-
const feed = await feedProvider(info.key);
|
|
1394
|
-
if (this._ctx.disposed) {
|
|
1395
|
-
return;
|
|
1396
|
-
}
|
|
1397
|
-
if (!this._pipeline.hasFeed(feed.key)) {
|
|
1398
|
-
await this._pipeline.addFeed(feed);
|
|
1399
|
-
}
|
|
1400
|
-
} catch (err) {
|
|
1401
|
-
log6.catch(err, void 0, {
|
|
1402
|
-
F: __dxlog_file7,
|
|
1403
|
-
L: 96,
|
|
1404
|
-
S: this,
|
|
1405
|
-
C: (f, a) => f(...a)
|
|
1406
|
-
});
|
|
1407
|
-
}
|
|
1408
|
-
});
|
|
1409
|
-
}
|
|
1410
|
-
await this.onFeedAdmitted.callIfSet(info);
|
|
1411
|
-
});
|
|
1412
|
-
this.onMemberRoleChanged = this._spaceStateMachine.onMemberRoleChanged;
|
|
1413
|
-
this.onCredentialProcessed = this._spaceStateMachine.onCredentialProcessed;
|
|
1414
|
-
this.onDelegatedInvitation = this._spaceStateMachine.onDelegatedInvitation;
|
|
1415
|
-
this.onDelegatedInvitationRemoved = this._spaceStateMachine.onDelegatedInvitationRemoved;
|
|
1416
|
-
}
|
|
1417
1045
|
};
|
|
1046
|
+
_ts_decorate4([
|
|
1047
|
+
trace.info({
|
|
1048
|
+
spanAttribute: true
|
|
1049
|
+
})
|
|
1050
|
+
], ControlPipeline.prototype, "_spaceKey", void 0);
|
|
1418
1051
|
_ts_decorate4([
|
|
1419
1052
|
trace.metricsCounter()
|
|
1420
1053
|
], ControlPipeline.prototype, "_usage", void 0);
|
|
@@ -1423,14 +1056,15 @@ _ts_decorate4([
|
|
|
1423
1056
|
], ControlPipeline.prototype, "_mutations", void 0);
|
|
1424
1057
|
_ts_decorate4([
|
|
1425
1058
|
trace.span({
|
|
1426
|
-
showInBrowserTimeline: true
|
|
1059
|
+
showInBrowserTimeline: true,
|
|
1060
|
+
op: "lifecycle"
|
|
1427
1061
|
})
|
|
1428
1062
|
], ControlPipeline.prototype, "start", null);
|
|
1429
1063
|
_ts_decorate4([
|
|
1430
|
-
trace.span(
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1064
|
+
trace.span({
|
|
1065
|
+
showInBrowserTimeline: true,
|
|
1066
|
+
showInRemoteTracing: false
|
|
1067
|
+
})
|
|
1434
1068
|
], ControlPipeline.prototype, "_processMessage", null);
|
|
1435
1069
|
ControlPipeline = _ts_decorate4([
|
|
1436
1070
|
trace.resource(),
|
|
@@ -1450,141 +1084,27 @@ var getSnapshotLoggerContext = (snapshot) => {
|
|
|
1450
1084
|
};
|
|
1451
1085
|
|
|
1452
1086
|
// src/space/space.ts
|
|
1453
|
-
|
|
1454
|
-
if (key in obj) {
|
|
1455
|
-
Object.defineProperty(obj, key, {
|
|
1456
|
-
value,
|
|
1457
|
-
enumerable: true,
|
|
1458
|
-
configurable: true,
|
|
1459
|
-
writable: true
|
|
1460
|
-
});
|
|
1461
|
-
} else {
|
|
1462
|
-
obj[key] = value;
|
|
1463
|
-
}
|
|
1464
|
-
return obj;
|
|
1465
|
-
}
|
|
1087
|
+
var __dxlog_file8 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space.ts";
|
|
1466
1088
|
function _ts_decorate5(decorators, target, key, desc) {
|
|
1467
1089
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1468
1090
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1469
1091
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1470
1092
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1471
1093
|
}
|
|
1472
|
-
var __dxlog_file8 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space.ts";
|
|
1473
1094
|
var Space = class extends Resource {
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
return this._controlFeed?.key;
|
|
1485
|
-
}
|
|
1486
|
-
get dataFeedKey() {
|
|
1487
|
-
return this._dataFeed?.key;
|
|
1488
|
-
}
|
|
1489
|
-
get spaceState() {
|
|
1490
|
-
return this._controlPipeline.spaceState;
|
|
1491
|
-
}
|
|
1492
|
-
/**
|
|
1493
|
-
* @test-only
|
|
1494
|
-
*/
|
|
1495
|
-
get controlPipeline() {
|
|
1496
|
-
return this._controlPipeline.pipeline;
|
|
1497
|
-
}
|
|
1498
|
-
async setControlFeed(feed) {
|
|
1499
|
-
invariant6(!this._controlFeed, "Control feed already set.", {
|
|
1500
|
-
F: __dxlog_file8,
|
|
1501
|
-
L: 156,
|
|
1502
|
-
S: this,
|
|
1503
|
-
A: [
|
|
1504
|
-
"!this._controlFeed",
|
|
1505
|
-
"'Control feed already set.'"
|
|
1506
|
-
]
|
|
1507
|
-
});
|
|
1508
|
-
this._controlFeed = feed;
|
|
1509
|
-
await this._controlPipeline.setWriteFeed(feed);
|
|
1510
|
-
return this;
|
|
1511
|
-
}
|
|
1512
|
-
async setDataFeed(feed) {
|
|
1513
|
-
invariant6(!this._dataFeed, "Data feed already set.", {
|
|
1514
|
-
F: __dxlog_file8,
|
|
1515
|
-
L: 163,
|
|
1516
|
-
S: this,
|
|
1517
|
-
A: [
|
|
1518
|
-
"!this._dataFeed",
|
|
1519
|
-
"'Data feed already set.'"
|
|
1520
|
-
]
|
|
1521
|
-
});
|
|
1522
|
-
this._dataFeed = feed;
|
|
1523
|
-
return this;
|
|
1524
|
-
}
|
|
1525
|
-
/**
|
|
1526
|
-
* Use for diagnostics.
|
|
1527
|
-
*/
|
|
1528
|
-
getControlFeeds() {
|
|
1529
|
-
return Array.from(this._controlPipeline.spaceState.feeds.values());
|
|
1530
|
-
}
|
|
1531
|
-
async _open(ctx) {
|
|
1532
|
-
log7("opening...", void 0, {
|
|
1533
|
-
F: __dxlog_file8,
|
|
1534
|
-
L: 177,
|
|
1535
|
-
S: this,
|
|
1536
|
-
C: (f, a) => f(...a)
|
|
1537
|
-
});
|
|
1538
|
-
await this._controlPipeline.start();
|
|
1539
|
-
log7("opened", void 0, {
|
|
1540
|
-
F: __dxlog_file8,
|
|
1541
|
-
L: 182,
|
|
1542
|
-
S: this,
|
|
1543
|
-
C: (f, a) => f(...a)
|
|
1544
|
-
});
|
|
1545
|
-
}
|
|
1546
|
-
async startProtocol() {
|
|
1547
|
-
invariant6(this.isOpen, void 0, {
|
|
1548
|
-
F: __dxlog_file8,
|
|
1549
|
-
L: 187,
|
|
1550
|
-
S: this,
|
|
1551
|
-
A: [
|
|
1552
|
-
"this.isOpen",
|
|
1553
|
-
""
|
|
1554
|
-
]
|
|
1555
|
-
});
|
|
1556
|
-
await this.protocol.start();
|
|
1557
|
-
await this.protocol.addFeed(await this._feedProvider(this._genesisFeedKey));
|
|
1558
|
-
}
|
|
1559
|
-
async _close() {
|
|
1560
|
-
log7("closing...", {
|
|
1561
|
-
key: this._key
|
|
1562
|
-
}, {
|
|
1563
|
-
F: __dxlog_file8,
|
|
1564
|
-
L: 194,
|
|
1565
|
-
S: this,
|
|
1566
|
-
C: (f, a) => f(...a)
|
|
1567
|
-
});
|
|
1568
|
-
await this.protocol.stop();
|
|
1569
|
-
await this._controlPipeline.stop();
|
|
1570
|
-
log7("closed", void 0, {
|
|
1571
|
-
F: __dxlog_file8,
|
|
1572
|
-
L: 200,
|
|
1573
|
-
S: this,
|
|
1574
|
-
C: (f, a) => f(...a)
|
|
1575
|
-
});
|
|
1576
|
-
}
|
|
1095
|
+
onCredentialProcessed = new Callback2();
|
|
1096
|
+
stateUpdate = new Event4();
|
|
1097
|
+
protocol;
|
|
1098
|
+
_id;
|
|
1099
|
+
_key;
|
|
1100
|
+
_genesisFeedKey;
|
|
1101
|
+
_feedProvider;
|
|
1102
|
+
_controlPipeline;
|
|
1103
|
+
_controlFeed;
|
|
1104
|
+
_dataFeed;
|
|
1577
1105
|
constructor(params) {
|
|
1578
|
-
super()
|
|
1579
|
-
invariant6(params.spaceKey && params.feedProvider, void 0, {
|
|
1580
|
-
F: __dxlog_file8,
|
|
1581
|
-
L: 73,
|
|
1582
|
-
S: this,
|
|
1583
|
-
A: [
|
|
1584
|
-
"params.spaceKey && params.feedProvider",
|
|
1585
|
-
""
|
|
1586
|
-
]
|
|
1587
|
-
});
|
|
1106
|
+
super();
|
|
1107
|
+
invariant6(params.spaceKey && params.feedProvider, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file8, L: 31, S: this, A: ["params.spaceKey && params.feedProvider", ""] });
|
|
1588
1108
|
this._id = params.id;
|
|
1589
1109
|
this._key = params.spaceKey;
|
|
1590
1110
|
this._genesisFeedKey = params.genesisFeed.key;
|
|
@@ -1609,34 +1129,19 @@ var Space = class extends Resource {
|
|
|
1609
1129
|
await this.onCredentialProcessed.callIfSet(credential);
|
|
1610
1130
|
log7("onCredentialProcessed", {
|
|
1611
1131
|
credential
|
|
1612
|
-
}, {
|
|
1613
|
-
F: __dxlog_file8,
|
|
1614
|
-
L: 100,
|
|
1615
|
-
S: this,
|
|
1616
|
-
C: (f, a) => f(...a)
|
|
1617
|
-
});
|
|
1132
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file8, L: 56, S: this });
|
|
1618
1133
|
this.stateUpdate.emit();
|
|
1619
1134
|
});
|
|
1620
1135
|
this._controlPipeline.onDelegatedInvitation.set(async (invitation) => {
|
|
1621
1136
|
log7("onDelegatedInvitation", {
|
|
1622
1137
|
invitation
|
|
1623
|
-
}, {
|
|
1624
|
-
F: __dxlog_file8,
|
|
1625
|
-
L: 104,
|
|
1626
|
-
S: this,
|
|
1627
|
-
C: (f, a) => f(...a)
|
|
1628
|
-
});
|
|
1138
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file8, L: 62, S: this });
|
|
1629
1139
|
await params.onDelegatedInvitationStatusChange(invitation, true);
|
|
1630
1140
|
});
|
|
1631
1141
|
this._controlPipeline.onDelegatedInvitationRemoved.set(async (invitation) => {
|
|
1632
1142
|
log7("onDelegatedInvitationRemoved", {
|
|
1633
1143
|
invitation
|
|
1634
|
-
}, {
|
|
1635
|
-
F: __dxlog_file8,
|
|
1636
|
-
L: 108,
|
|
1637
|
-
S: this,
|
|
1638
|
-
C: (f, a) => f(...a)
|
|
1639
|
-
});
|
|
1144
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file8, L: 68, S: this });
|
|
1640
1145
|
await params.onDelegatedInvitationStatusChange(invitation, false);
|
|
1641
1146
|
});
|
|
1642
1147
|
this._controlPipeline.onMemberRoleChanged.set(async (changedMembers) => {
|
|
@@ -1645,16 +1150,70 @@ var Space = class extends Resource {
|
|
|
1645
1150
|
m.key,
|
|
1646
1151
|
m.role
|
|
1647
1152
|
])
|
|
1648
|
-
}), {
|
|
1649
|
-
F: __dxlog_file8,
|
|
1650
|
-
L: 112,
|
|
1651
|
-
S: this,
|
|
1652
|
-
C: (f, a) => f(...a)
|
|
1653
|
-
});
|
|
1153
|
+
}), { "~LogMeta": "~LogMeta", F: __dxlog_file8, L: 74, S: this });
|
|
1654
1154
|
await params.onMemberRolesChanged(changedMembers);
|
|
1655
1155
|
});
|
|
1656
1156
|
this.protocol = params.protocol;
|
|
1657
1157
|
}
|
|
1158
|
+
get id() {
|
|
1159
|
+
return this._id;
|
|
1160
|
+
}
|
|
1161
|
+
get key() {
|
|
1162
|
+
return this._key;
|
|
1163
|
+
}
|
|
1164
|
+
get genesisFeedKey() {
|
|
1165
|
+
return this._genesisFeedKey;
|
|
1166
|
+
}
|
|
1167
|
+
get controlFeedKey() {
|
|
1168
|
+
return this._controlFeed?.key;
|
|
1169
|
+
}
|
|
1170
|
+
get dataFeedKey() {
|
|
1171
|
+
return this._dataFeed?.key;
|
|
1172
|
+
}
|
|
1173
|
+
get spaceState() {
|
|
1174
|
+
return this._controlPipeline.spaceState;
|
|
1175
|
+
}
|
|
1176
|
+
/**
|
|
1177
|
+
* @test-only
|
|
1178
|
+
*/
|
|
1179
|
+
get controlPipeline() {
|
|
1180
|
+
return this._controlPipeline.pipeline;
|
|
1181
|
+
}
|
|
1182
|
+
async setControlFeed(feed) {
|
|
1183
|
+
invariant6(!this._controlFeed, "Control feed already set.", { "~LogMeta": "~LogMeta", F: __dxlog_file8, L: 109, S: this, A: ["!this._controlFeed", "'Control feed already set.'"] });
|
|
1184
|
+
this._controlFeed = feed;
|
|
1185
|
+
await this._controlPipeline.setWriteFeed(feed);
|
|
1186
|
+
return this;
|
|
1187
|
+
}
|
|
1188
|
+
async setDataFeed(feed) {
|
|
1189
|
+
invariant6(!this._dataFeed, "Data feed already set.", { "~LogMeta": "~LogMeta", F: __dxlog_file8, L: 115, S: this, A: ["!this._dataFeed", "'Data feed already set.'"] });
|
|
1190
|
+
this._dataFeed = feed;
|
|
1191
|
+
return this;
|
|
1192
|
+
}
|
|
1193
|
+
/**
|
|
1194
|
+
* Use for diagnostics.
|
|
1195
|
+
*/
|
|
1196
|
+
getControlFeeds() {
|
|
1197
|
+
return Array.from(this._controlPipeline.spaceState.feeds.values());
|
|
1198
|
+
}
|
|
1199
|
+
async _open(ctx) {
|
|
1200
|
+
log7("opening...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file8, L: 125, S: this });
|
|
1201
|
+
await this._controlPipeline.start(ctx);
|
|
1202
|
+
log7("opened", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file8, L: 128, S: this });
|
|
1203
|
+
}
|
|
1204
|
+
async startProtocol(ctx) {
|
|
1205
|
+
invariant6(this.isOpen, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file8, L: 131, S: this, A: ["this.isOpen", ""] });
|
|
1206
|
+
await this.protocol.start(ctx);
|
|
1207
|
+
await this.protocol.addFeed(await this._feedProvider(this._genesisFeedKey));
|
|
1208
|
+
}
|
|
1209
|
+
async _close(ctx) {
|
|
1210
|
+
log7("closing...", {
|
|
1211
|
+
key: this._key
|
|
1212
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file8, L: 136, S: this });
|
|
1213
|
+
await this.protocol.stop(ctx);
|
|
1214
|
+
await this._controlPipeline.stop();
|
|
1215
|
+
log7("closed", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file8, L: 142, S: this });
|
|
1216
|
+
}
|
|
1658
1217
|
};
|
|
1659
1218
|
_ts_decorate5([
|
|
1660
1219
|
trace2.info()
|
|
@@ -1671,7 +1230,9 @@ _ts_decorate5([
|
|
|
1671
1230
|
trace2.info()
|
|
1672
1231
|
], Space.prototype, "key", null);
|
|
1673
1232
|
_ts_decorate5([
|
|
1674
|
-
trace2.span(
|
|
1233
|
+
trace2.span({
|
|
1234
|
+
op: "lifecycle"
|
|
1235
|
+
})
|
|
1675
1236
|
], Space.prototype, "_open", null);
|
|
1676
1237
|
_ts_decorate5([
|
|
1677
1238
|
synchronized3
|
|
@@ -1690,21 +1251,18 @@ import { Context as Context5 } from "@dxos/context";
|
|
|
1690
1251
|
import { ProtocolError } from "@dxos/protocols";
|
|
1691
1252
|
import { schema as schema4 } from "@dxos/protocols/proto";
|
|
1692
1253
|
import { RpcExtension as RpcExtension2 } from "@dxos/teleport";
|
|
1693
|
-
function _define_property7(obj, key, value) {
|
|
1694
|
-
if (key in obj) {
|
|
1695
|
-
Object.defineProperty(obj, key, {
|
|
1696
|
-
value,
|
|
1697
|
-
enumerable: true,
|
|
1698
|
-
configurable: true,
|
|
1699
|
-
writable: true
|
|
1700
|
-
});
|
|
1701
|
-
} else {
|
|
1702
|
-
obj[key] = value;
|
|
1703
|
-
}
|
|
1704
|
-
return obj;
|
|
1705
|
-
}
|
|
1706
1254
|
var __dxlog_file9 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/space/admission-discovery-extension.ts";
|
|
1707
1255
|
var CredentialRetrieverExtension = class extends RpcExtension2 {
|
|
1256
|
+
_request;
|
|
1257
|
+
_onResult;
|
|
1258
|
+
_ctx = new Context5(void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file9, L: 14 });
|
|
1259
|
+
constructor(_request, _onResult) {
|
|
1260
|
+
super({
|
|
1261
|
+
requested: {
|
|
1262
|
+
AdmissionDiscoveryService: schema4.getService("dxos.mesh.teleport.AdmissionDiscoveryService")
|
|
1263
|
+
}
|
|
1264
|
+
}), this._request = _request, this._onResult = _onResult;
|
|
1265
|
+
}
|
|
1708
1266
|
async getHandlers() {
|
|
1709
1267
|
return {};
|
|
1710
1268
|
}
|
|
@@ -1725,25 +1283,28 @@ var CredentialRetrieverExtension = class extends RpcExtension2 {
|
|
|
1725
1283
|
async onAbort() {
|
|
1726
1284
|
await this._ctx.dispose();
|
|
1727
1285
|
}
|
|
1728
|
-
|
|
1286
|
+
};
|
|
1287
|
+
var CredentialServerExtension = class extends RpcExtension2 {
|
|
1288
|
+
_space;
|
|
1289
|
+
constructor(_space) {
|
|
1729
1290
|
super({
|
|
1730
|
-
|
|
1291
|
+
exposed: {
|
|
1731
1292
|
AdmissionDiscoveryService: schema4.getService("dxos.mesh.teleport.AdmissionDiscoveryService")
|
|
1732
1293
|
}
|
|
1733
|
-
}),
|
|
1734
|
-
F: __dxlog_file9,
|
|
1735
|
-
L: 26
|
|
1736
|
-
});
|
|
1294
|
+
}), this._space = _space;
|
|
1737
1295
|
}
|
|
1738
|
-
};
|
|
1739
|
-
var CredentialServerExtension = class extends RpcExtension2 {
|
|
1740
1296
|
async getHandlers() {
|
|
1741
1297
|
return {
|
|
1742
1298
|
AdmissionDiscoveryService: {
|
|
1743
1299
|
getAdmissionCredential: async (request) => {
|
|
1744
1300
|
const memberInfo = this._space.spaceState.members.get(request.memberKey);
|
|
1745
1301
|
if (!memberInfo?.credential) {
|
|
1746
|
-
throw new ProtocolError(
|
|
1302
|
+
throw new ProtocolError({
|
|
1303
|
+
message: "Space member not found.",
|
|
1304
|
+
context: {
|
|
1305
|
+
...request
|
|
1306
|
+
}
|
|
1307
|
+
});
|
|
1747
1308
|
}
|
|
1748
1309
|
return {
|
|
1749
1310
|
admissionCredential: memberInfo.credential
|
|
@@ -1752,13 +1313,6 @@ var CredentialServerExtension = class extends RpcExtension2 {
|
|
|
1752
1313
|
}
|
|
1753
1314
|
};
|
|
1754
1315
|
}
|
|
1755
|
-
constructor(_space) {
|
|
1756
|
-
super({
|
|
1757
|
-
exposed: {
|
|
1758
|
-
AdmissionDiscoveryService: schema4.getService("dxos.mesh.teleport.AdmissionDiscoveryService")
|
|
1759
|
-
}
|
|
1760
|
-
}), _define_property7(this, "_space", void 0), this._space = _space;
|
|
1761
|
-
}
|
|
1762
1316
|
};
|
|
1763
1317
|
|
|
1764
1318
|
// src/space/space-protocol.ts
|
|
@@ -1771,29 +1325,34 @@ import { BlobSync } from "@dxos/teleport-extension-object-sync";
|
|
|
1771
1325
|
import { ReplicatorExtension } from "@dxos/teleport-extension-replicator";
|
|
1772
1326
|
import { trace as trace3 } from "@dxos/tracing";
|
|
1773
1327
|
import { CallbackCollection, ComplexMap as ComplexMap4 } from "@dxos/util";
|
|
1774
|
-
|
|
1775
|
-
if (key in obj) {
|
|
1776
|
-
Object.defineProperty(obj, key, {
|
|
1777
|
-
value,
|
|
1778
|
-
enumerable: true,
|
|
1779
|
-
configurable: true,
|
|
1780
|
-
writable: true
|
|
1781
|
-
});
|
|
1782
|
-
} else {
|
|
1783
|
-
obj[key] = value;
|
|
1784
|
-
}
|
|
1785
|
-
return obj;
|
|
1786
|
-
}
|
|
1328
|
+
var __dxlog_file10 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-protocol.ts";
|
|
1787
1329
|
function _ts_decorate6(decorators, target, key, desc) {
|
|
1788
1330
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1789
1331
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1790
1332
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1791
1333
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1792
1334
|
}
|
|
1793
|
-
var __dxlog_file10 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-protocol.ts";
|
|
1794
1335
|
var MOCK_AUTH_PROVIDER = async (nonce) => Buffer.from("mock");
|
|
1795
1336
|
var MOCK_AUTH_VERIFIER = async (nonce, credential) => true;
|
|
1796
1337
|
var SpaceProtocol = class {
|
|
1338
|
+
_networkManager;
|
|
1339
|
+
_swarmIdentity;
|
|
1340
|
+
_onSessionAuth;
|
|
1341
|
+
_onAuthFailure;
|
|
1342
|
+
blobSync;
|
|
1343
|
+
_disableP2pReplication;
|
|
1344
|
+
_topic;
|
|
1345
|
+
_spaceKey;
|
|
1346
|
+
_feeds = /* @__PURE__ */ new Set();
|
|
1347
|
+
_sessions = new ComplexMap4(PublicKey5.hash);
|
|
1348
|
+
// TODO(burdon): Move to config (with sensible defaults).
|
|
1349
|
+
_topology = new MMSTTopology({
|
|
1350
|
+
originateConnections: 4,
|
|
1351
|
+
maxPeers: 10,
|
|
1352
|
+
sampleSize: 20
|
|
1353
|
+
});
|
|
1354
|
+
_connection;
|
|
1355
|
+
feedAdded = new CallbackCollection();
|
|
1797
1356
|
get sessions() {
|
|
1798
1357
|
return this._sessions;
|
|
1799
1358
|
}
|
|
@@ -1803,16 +1362,23 @@ var SpaceProtocol = class {
|
|
|
1803
1362
|
get _ownPeerKey() {
|
|
1804
1363
|
return this._swarmIdentity.peerKey;
|
|
1805
1364
|
}
|
|
1365
|
+
constructor({ topic, swarmIdentity, networkManager, onSessionAuth, onAuthFailure, blobStore, disableP2pReplication }) {
|
|
1366
|
+
this._spaceKey = topic;
|
|
1367
|
+
this._networkManager = networkManager;
|
|
1368
|
+
this._swarmIdentity = swarmIdentity;
|
|
1369
|
+
this._onSessionAuth = onSessionAuth;
|
|
1370
|
+
this._onAuthFailure = onAuthFailure;
|
|
1371
|
+
this.blobSync = new BlobSync({
|
|
1372
|
+
blobStore
|
|
1373
|
+
});
|
|
1374
|
+
this._topic = subtleCrypto2.digest("SHA-256", topic.asBuffer()).then(discoveryKey).then(PublicKey5.from);
|
|
1375
|
+
this._disableP2pReplication = disableP2pReplication ?? false;
|
|
1376
|
+
}
|
|
1806
1377
|
// TODO(burdon): Create abstraction for Space (e.g., add keys and have provider).
|
|
1807
1378
|
async addFeed(feed) {
|
|
1808
1379
|
log8("addFeed", {
|
|
1809
1380
|
key: feed.key
|
|
1810
|
-
}, {
|
|
1811
|
-
F: __dxlog_file10,
|
|
1812
|
-
L: 131,
|
|
1813
|
-
S: this,
|
|
1814
|
-
C: (f, a) => f(...a)
|
|
1815
|
-
});
|
|
1381
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file10, L: 65, S: this });
|
|
1816
1382
|
this._feeds.add(feed);
|
|
1817
1383
|
for (const session of this._sessions.values()) {
|
|
1818
1384
|
session.replicator.addFeed(feed);
|
|
@@ -1820,99 +1386,50 @@ var SpaceProtocol = class {
|
|
|
1820
1386
|
await this.feedAdded.callSerial(feed);
|
|
1821
1387
|
}
|
|
1822
1388
|
// TODO(burdon): Rename open? Common open/close interfaces for all services?
|
|
1823
|
-
async start() {
|
|
1389
|
+
async start(ctx) {
|
|
1824
1390
|
if (this._connection) {
|
|
1825
1391
|
return;
|
|
1826
1392
|
}
|
|
1827
1393
|
const credentials = await this._swarmIdentity.credentialProvider(Buffer.from(""));
|
|
1828
1394
|
await this.blobSync.open();
|
|
1829
|
-
log8("starting...", void 0, {
|
|
1830
|
-
F: __dxlog_file10,
|
|
1831
|
-
L: 152,
|
|
1832
|
-
S: this,
|
|
1833
|
-
C: (f, a) => f(...a)
|
|
1834
|
-
});
|
|
1395
|
+
log8("starting...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file10, L: 82, S: this });
|
|
1835
1396
|
const topic = await this._topic;
|
|
1836
|
-
this._connection = await this._networkManager.joinSwarm({
|
|
1397
|
+
this._connection = await this._networkManager.joinSwarm(ctx, {
|
|
1837
1398
|
protocolProvider: this._createProtocolProvider(credentials),
|
|
1838
1399
|
topic,
|
|
1839
1400
|
topology: this._topology,
|
|
1840
1401
|
label: `swarm ${topic.truncate()} for space ${this._spaceKey.truncate()}`
|
|
1841
1402
|
});
|
|
1842
|
-
log8("started", void 0, {
|
|
1843
|
-
F: __dxlog_file10,
|
|
1844
|
-
L: 161,
|
|
1845
|
-
S: this,
|
|
1846
|
-
C: (f, a) => f(...a)
|
|
1847
|
-
});
|
|
1403
|
+
log8("started", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file10, L: 90, S: this });
|
|
1848
1404
|
}
|
|
1849
1405
|
updateTopology() {
|
|
1850
1406
|
this._topology.forceUpdate();
|
|
1851
1407
|
}
|
|
1852
|
-
async stop() {
|
|
1408
|
+
async stop(ctx) {
|
|
1853
1409
|
await this.blobSync.close();
|
|
1854
1410
|
if (this._connection) {
|
|
1855
|
-
log8("stopping...", void 0, {
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
S: this,
|
|
1859
|
-
C: (f, a) => f(...a)
|
|
1860
|
-
});
|
|
1861
|
-
await this._connection.close();
|
|
1862
|
-
log8("stopped", void 0, {
|
|
1863
|
-
F: __dxlog_file10,
|
|
1864
|
-
L: 174,
|
|
1865
|
-
S: this,
|
|
1866
|
-
C: (f, a) => f(...a)
|
|
1867
|
-
});
|
|
1411
|
+
log8("stopping...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file10, L: 98, S: this });
|
|
1412
|
+
await this._connection.close(ctx);
|
|
1413
|
+
log8("stopped", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file10, L: 100, S: this });
|
|
1868
1414
|
}
|
|
1869
1415
|
}
|
|
1870
1416
|
_createProtocolProvider(credentials) {
|
|
1871
|
-
return (
|
|
1417
|
+
return (wireProps) => {
|
|
1872
1418
|
const session = new SpaceProtocolSession({
|
|
1873
|
-
|
|
1419
|
+
wireProps,
|
|
1874
1420
|
swarmIdentity: this._swarmIdentity,
|
|
1875
1421
|
onSessionAuth: this._onSessionAuth,
|
|
1876
1422
|
onAuthFailure: this._onAuthFailure,
|
|
1877
1423
|
blobSync: this.blobSync,
|
|
1878
1424
|
disableP2pReplication: this._disableP2pReplication
|
|
1879
1425
|
});
|
|
1880
|
-
this._sessions.set(
|
|
1426
|
+
this._sessions.set(wireProps.remotePeerId, session);
|
|
1881
1427
|
for (const feed of this._feeds) {
|
|
1882
1428
|
session.replicator.addFeed(feed);
|
|
1883
1429
|
}
|
|
1884
1430
|
return session;
|
|
1885
1431
|
};
|
|
1886
1432
|
}
|
|
1887
|
-
constructor({ topic, swarmIdentity, networkManager, onSessionAuth, onAuthFailure, blobStore, disableP2pReplication }) {
|
|
1888
|
-
_define_property8(this, "_networkManager", void 0);
|
|
1889
|
-
_define_property8(this, "_swarmIdentity", void 0);
|
|
1890
|
-
_define_property8(this, "_onSessionAuth", void 0);
|
|
1891
|
-
_define_property8(this, "_onAuthFailure", void 0);
|
|
1892
|
-
_define_property8(this, "blobSync", void 0);
|
|
1893
|
-
_define_property8(this, "_disableP2pReplication", void 0);
|
|
1894
|
-
_define_property8(this, "_topic", void 0);
|
|
1895
|
-
_define_property8(this, "_spaceKey", void 0);
|
|
1896
|
-
_define_property8(this, "_feeds", /* @__PURE__ */ new Set());
|
|
1897
|
-
_define_property8(this, "_sessions", new ComplexMap4(PublicKey5.hash));
|
|
1898
|
-
_define_property8(this, "_topology", new MMSTTopology({
|
|
1899
|
-
originateConnections: 4,
|
|
1900
|
-
maxPeers: 10,
|
|
1901
|
-
sampleSize: 20
|
|
1902
|
-
}));
|
|
1903
|
-
_define_property8(this, "_connection", void 0);
|
|
1904
|
-
_define_property8(this, "feedAdded", new CallbackCollection());
|
|
1905
|
-
this._spaceKey = topic;
|
|
1906
|
-
this._networkManager = networkManager;
|
|
1907
|
-
this._swarmIdentity = swarmIdentity;
|
|
1908
|
-
this._onSessionAuth = onSessionAuth;
|
|
1909
|
-
this._onAuthFailure = onAuthFailure;
|
|
1910
|
-
this.blobSync = new BlobSync({
|
|
1911
|
-
blobStore
|
|
1912
|
-
});
|
|
1913
|
-
this._topic = subtleCrypto2.digest("SHA-256", topic.asBuffer()).then(discoveryKey).then(PublicKey5.from);
|
|
1914
|
-
this._disableP2pReplication = disableP2pReplication ?? false;
|
|
1915
|
-
}
|
|
1916
1433
|
};
|
|
1917
1434
|
_ts_decorate6([
|
|
1918
1435
|
logInfo2,
|
|
@@ -1927,19 +1444,41 @@ _ts_decorate6([
|
|
|
1927
1444
|
SpaceProtocol = _ts_decorate6([
|
|
1928
1445
|
trace3.resource()
|
|
1929
1446
|
], SpaceProtocol);
|
|
1930
|
-
var AuthStatus = /* @__PURE__ */ function(AuthStatus2) {
|
|
1447
|
+
var AuthStatus = /* @__PURE__ */ (function(AuthStatus2) {
|
|
1931
1448
|
AuthStatus2["INITIAL"] = "INITIAL";
|
|
1932
1449
|
AuthStatus2["SUCCESS"] = "SUCCESS";
|
|
1933
1450
|
AuthStatus2["FAILURE"] = "FAILURE";
|
|
1934
1451
|
return AuthStatus2;
|
|
1935
|
-
}({});
|
|
1452
|
+
})({});
|
|
1936
1453
|
var SpaceProtocolSession = class {
|
|
1454
|
+
_wireProps;
|
|
1455
|
+
_disableP2pReplication;
|
|
1456
|
+
_onSessionAuth;
|
|
1457
|
+
_onAuthFailure;
|
|
1458
|
+
_swarmIdentity;
|
|
1459
|
+
_blobSync;
|
|
1460
|
+
_teleport;
|
|
1461
|
+
// TODO(dmaretskyi): Start with upload=false when switching it on the fly works.
|
|
1462
|
+
replicator = new ReplicatorExtension().setOptions({
|
|
1463
|
+
upload: true
|
|
1464
|
+
});
|
|
1465
|
+
_authStatus = "INITIAL";
|
|
1937
1466
|
get authStatus() {
|
|
1938
1467
|
return this._authStatus;
|
|
1939
1468
|
}
|
|
1940
1469
|
get stats() {
|
|
1941
1470
|
return this._teleport.stats;
|
|
1942
1471
|
}
|
|
1472
|
+
// TODO(dmaretskyi): Allow to pass in extra extensions.
|
|
1473
|
+
constructor({ wireProps, swarmIdentity, onSessionAuth, onAuthFailure, blobSync, disableP2pReplication }) {
|
|
1474
|
+
this._wireProps = wireProps;
|
|
1475
|
+
this._swarmIdentity = swarmIdentity;
|
|
1476
|
+
this._onSessionAuth = onSessionAuth;
|
|
1477
|
+
this._onAuthFailure = onAuthFailure;
|
|
1478
|
+
this._blobSync = blobSync;
|
|
1479
|
+
this._teleport = new Teleport(wireProps);
|
|
1480
|
+
this._disableP2pReplication = disableP2pReplication ?? false;
|
|
1481
|
+
}
|
|
1943
1482
|
get stream() {
|
|
1944
1483
|
return this._teleport.stream;
|
|
1945
1484
|
}
|
|
@@ -1949,12 +1488,7 @@ var SpaceProtocolSession = class {
|
|
|
1949
1488
|
provider: this._swarmIdentity.credentialProvider,
|
|
1950
1489
|
verifier: this._swarmIdentity.credentialAuthenticator,
|
|
1951
1490
|
onAuthSuccess: () => {
|
|
1952
|
-
log8("Peer authenticated", void 0, {
|
|
1953
|
-
F: __dxlog_file10,
|
|
1954
|
-
L: 285,
|
|
1955
|
-
S: this,
|
|
1956
|
-
C: (f, a) => f(...a)
|
|
1957
|
-
});
|
|
1491
|
+
log8("Peer authenticated", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file10, L: 181, S: this });
|
|
1958
1492
|
this._authStatus = "SUCCESS";
|
|
1959
1493
|
this._onSessionAuth?.(this._teleport);
|
|
1960
1494
|
},
|
|
@@ -1969,42 +1503,16 @@ var SpaceProtocolSession = class {
|
|
|
1969
1503
|
this._teleport.addExtension("dxos.mesh.teleport.blobsync", this._blobSync.createExtension());
|
|
1970
1504
|
}
|
|
1971
1505
|
async close() {
|
|
1972
|
-
log8("close", void 0, {
|
|
1973
|
-
F: __dxlog_file10,
|
|
1974
|
-
L: 304,
|
|
1975
|
-
S: this,
|
|
1976
|
-
C: (f, a) => f(...a)
|
|
1977
|
-
});
|
|
1506
|
+
log8("close", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file10, L: 197, S: this });
|
|
1978
1507
|
await this._teleport.close();
|
|
1979
1508
|
}
|
|
1980
1509
|
async abort() {
|
|
1981
1510
|
await this._teleport.abort();
|
|
1982
1511
|
}
|
|
1983
|
-
// TODO(dmaretskyi): Allow to pass in extra extensions.
|
|
1984
|
-
constructor({ wireParams, swarmIdentity, onSessionAuth, onAuthFailure, blobSync, disableP2pReplication }) {
|
|
1985
|
-
_define_property8(this, "_wireParams", void 0);
|
|
1986
|
-
_define_property8(this, "_disableP2pReplication", void 0);
|
|
1987
|
-
_define_property8(this, "_onSessionAuth", void 0);
|
|
1988
|
-
_define_property8(this, "_onAuthFailure", void 0);
|
|
1989
|
-
_define_property8(this, "_swarmIdentity", void 0);
|
|
1990
|
-
_define_property8(this, "_blobSync", void 0);
|
|
1991
|
-
_define_property8(this, "_teleport", void 0);
|
|
1992
|
-
_define_property8(this, "replicator", new ReplicatorExtension().setOptions({
|
|
1993
|
-
upload: true
|
|
1994
|
-
}));
|
|
1995
|
-
_define_property8(this, "_authStatus", "INITIAL");
|
|
1996
|
-
this._wireParams = wireParams;
|
|
1997
|
-
this._swarmIdentity = swarmIdentity;
|
|
1998
|
-
this._onSessionAuth = onSessionAuth;
|
|
1999
|
-
this._onAuthFailure = onAuthFailure;
|
|
2000
|
-
this._blobSync = blobSync;
|
|
2001
|
-
this._teleport = new Teleport(wireParams);
|
|
2002
|
-
this._disableP2pReplication = disableP2pReplication ?? false;
|
|
2003
|
-
}
|
|
2004
1512
|
};
|
|
2005
1513
|
_ts_decorate6([
|
|
2006
1514
|
logInfo2
|
|
2007
|
-
], SpaceProtocolSession.prototype, "
|
|
1515
|
+
], SpaceProtocolSession.prototype, "_wireProps", void 0);
|
|
2008
1516
|
_ts_decorate6([
|
|
2009
1517
|
logInfo2
|
|
2010
1518
|
], SpaceProtocolSession.prototype, "authStatus", null);
|
|
@@ -2016,29 +1524,28 @@ import { getCredentialAssertion } from "@dxos/credentials";
|
|
|
2016
1524
|
import { failUndefined as failUndefined2 } from "@dxos/debug";
|
|
2017
1525
|
import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
2018
1526
|
import { log as log9 } from "@dxos/log";
|
|
2019
|
-
import { trace as trace4 } from "@dxos/protocols";
|
|
2020
1527
|
import { ComplexMap as ComplexMap5 } from "@dxos/util";
|
|
2021
|
-
|
|
2022
|
-
if (key in obj) {
|
|
2023
|
-
Object.defineProperty(obj, key, {
|
|
2024
|
-
value,
|
|
2025
|
-
enumerable: true,
|
|
2026
|
-
configurable: true,
|
|
2027
|
-
writable: true
|
|
2028
|
-
});
|
|
2029
|
-
} else {
|
|
2030
|
-
obj[key] = value;
|
|
2031
|
-
}
|
|
2032
|
-
return obj;
|
|
2033
|
-
}
|
|
1528
|
+
var __dxlog_file11 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-manager.ts";
|
|
2034
1529
|
function _ts_decorate7(decorators, target, key, desc) {
|
|
2035
1530
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2036
1531
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2037
1532
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2038
1533
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2039
1534
|
}
|
|
2040
|
-
var __dxlog_file11 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-manager.ts";
|
|
2041
1535
|
var SpaceManager = class {
|
|
1536
|
+
_spaces = new ComplexMap5(PublicKey6.hash);
|
|
1537
|
+
_feedStore;
|
|
1538
|
+
_networkManager;
|
|
1539
|
+
_metadataStore;
|
|
1540
|
+
_blobStore;
|
|
1541
|
+
_disableP2pReplication;
|
|
1542
|
+
constructor({ feedStore, networkManager, metadataStore, blobStore, disableP2pReplication }) {
|
|
1543
|
+
this._feedStore = feedStore;
|
|
1544
|
+
this._networkManager = networkManager;
|
|
1545
|
+
this._metadataStore = metadataStore;
|
|
1546
|
+
this._blobStore = blobStore;
|
|
1547
|
+
this._disableP2pReplication = disableP2pReplication ?? false;
|
|
1548
|
+
}
|
|
2042
1549
|
// TODO(burdon): Remove.
|
|
2043
1550
|
get spaces() {
|
|
2044
1551
|
return this._spaces;
|
|
@@ -2051,22 +1558,9 @@ var SpaceManager = class {
|
|
|
2051
1558
|
].map((space) => space.close()));
|
|
2052
1559
|
}
|
|
2053
1560
|
async constructSpace({ metadata, swarmIdentity, onAuthorizedConnection, onAuthFailure, onDelegatedInvitationStatusChange, onMemberRolesChanged, memberKey }) {
|
|
2054
|
-
log9.trace("dxos.echo.space-manager.construct-space", trace4.begin({
|
|
2055
|
-
id: this._instanceId
|
|
2056
|
-
}), {
|
|
2057
|
-
F: __dxlog_file11,
|
|
2058
|
-
L: 103,
|
|
2059
|
-
S: this,
|
|
2060
|
-
C: (f, a) => f(...a)
|
|
2061
|
-
});
|
|
2062
1561
|
log9("constructing space...", {
|
|
2063
1562
|
spaceKey: metadata.genesisFeedKey
|
|
2064
|
-
}, {
|
|
2065
|
-
F: __dxlog_file11,
|
|
2066
|
-
L: 104,
|
|
2067
|
-
S: this,
|
|
2068
|
-
C: (f, a) => f(...a)
|
|
2069
|
-
});
|
|
1563
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file11, L: 47, S: this });
|
|
2070
1564
|
const genesisFeed = await this._feedStore.openFeed(metadata.genesisFeedKey ?? failUndefined2());
|
|
2071
1565
|
const spaceKey = metadata.key;
|
|
2072
1566
|
const spaceId = await createIdFromSpaceKey(spaceKey);
|
|
@@ -2091,34 +1585,12 @@ var SpaceManager = class {
|
|
|
2091
1585
|
onMemberRolesChanged
|
|
2092
1586
|
});
|
|
2093
1587
|
this._spaces.set(space.key, space);
|
|
2094
|
-
log9.trace("dxos.echo.space-manager.construct-space", trace4.end({
|
|
2095
|
-
id: this._instanceId
|
|
2096
|
-
}), {
|
|
2097
|
-
F: __dxlog_file11,
|
|
2098
|
-
L: 134,
|
|
2099
|
-
S: this,
|
|
2100
|
-
C: (f, a) => f(...a)
|
|
2101
|
-
});
|
|
2102
1588
|
return space;
|
|
2103
1589
|
}
|
|
2104
|
-
async requestSpaceAdmissionCredential(params) {
|
|
2105
|
-
const traceKey = "dxos.echo.space-manager.request-space-admission";
|
|
2106
|
-
log9.trace(traceKey, trace4.begin({
|
|
2107
|
-
id: this._instanceId
|
|
2108
|
-
}), {
|
|
2109
|
-
F: __dxlog_file11,
|
|
2110
|
-
L: 140,
|
|
2111
|
-
S: this,
|
|
2112
|
-
C: (f, a) => f(...a)
|
|
2113
|
-
});
|
|
1590
|
+
async requestSpaceAdmissionCredential(ctx, params) {
|
|
2114
1591
|
log9("requesting space admission credential...", {
|
|
2115
1592
|
spaceKey: params.spaceKey
|
|
2116
|
-
}, {
|
|
2117
|
-
F: __dxlog_file11,
|
|
2118
|
-
L: 141,
|
|
2119
|
-
S: this,
|
|
2120
|
-
C: (f, a) => f(...a)
|
|
2121
|
-
});
|
|
1593
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file11, L: 78, S: this });
|
|
2122
1594
|
const onCredentialResolved = new Trigger2();
|
|
2123
1595
|
const protocol = new SpaceProtocol({
|
|
2124
1596
|
topic: params.spaceKey,
|
|
@@ -2135,32 +1607,15 @@ var SpaceManager = class {
|
|
|
2135
1607
|
disableP2pReplication: this._disableP2pReplication
|
|
2136
1608
|
});
|
|
2137
1609
|
try {
|
|
2138
|
-
await protocol.start();
|
|
1610
|
+
await protocol.start(ctx);
|
|
2139
1611
|
const credential = await onCredentialResolved.wait({
|
|
2140
1612
|
timeout: params.timeout
|
|
2141
1613
|
});
|
|
2142
|
-
log9.trace(traceKey, trace4.end({
|
|
2143
|
-
id: this._instanceId
|
|
2144
|
-
}), {
|
|
2145
|
-
F: __dxlog_file11,
|
|
2146
|
-
L: 165,
|
|
2147
|
-
S: this,
|
|
2148
|
-
C: (f, a) => f(...a)
|
|
2149
|
-
});
|
|
2150
1614
|
return credential;
|
|
2151
1615
|
} catch (err) {
|
|
2152
|
-
log9.trace(traceKey, trace4.error({
|
|
2153
|
-
id: this._instanceId,
|
|
2154
|
-
error: err
|
|
2155
|
-
}), {
|
|
2156
|
-
F: __dxlog_file11,
|
|
2157
|
-
L: 168,
|
|
2158
|
-
S: this,
|
|
2159
|
-
C: (f, a) => f(...a)
|
|
2160
|
-
});
|
|
2161
1616
|
throw err;
|
|
2162
1617
|
} finally {
|
|
2163
|
-
await protocol.stop();
|
|
1618
|
+
await protocol.stop(ctx);
|
|
2164
1619
|
}
|
|
2165
1620
|
}
|
|
2166
1621
|
findSpaceByRootDocumentId(documentId) {
|
|
@@ -2179,20 +1634,6 @@ var SpaceManager = class {
|
|
|
2179
1634
|
});
|
|
2180
1635
|
});
|
|
2181
1636
|
}
|
|
2182
|
-
constructor({ feedStore, networkManager, metadataStore, blobStore, disableP2pReplication }) {
|
|
2183
|
-
_define_property9(this, "_spaces", new ComplexMap5(PublicKey6.hash));
|
|
2184
|
-
_define_property9(this, "_feedStore", void 0);
|
|
2185
|
-
_define_property9(this, "_networkManager", void 0);
|
|
2186
|
-
_define_property9(this, "_metadataStore", void 0);
|
|
2187
|
-
_define_property9(this, "_blobStore", void 0);
|
|
2188
|
-
_define_property9(this, "_instanceId", PublicKey6.random().toHex());
|
|
2189
|
-
_define_property9(this, "_disableP2pReplication", void 0);
|
|
2190
|
-
this._feedStore = feedStore;
|
|
2191
|
-
this._networkManager = networkManager;
|
|
2192
|
-
this._metadataStore = metadataStore;
|
|
2193
|
-
this._blobStore = blobStore;
|
|
2194
|
-
this._disableP2pReplication = disableP2pReplication ?? false;
|
|
2195
|
-
}
|
|
2196
1637
|
};
|
|
2197
1638
|
_ts_decorate7([
|
|
2198
1639
|
synchronized4
|
|
@@ -2227,4 +1668,4 @@ export {
|
|
|
2227
1668
|
SpaceProtocolSession,
|
|
2228
1669
|
SpaceManager
|
|
2229
1670
|
};
|
|
2230
|
-
//# sourceMappingURL=chunk-
|
|
1671
|
+
//# sourceMappingURL=chunk-VIHYDCCC.mjs.map
|