@fluidframework/datastore 2.0.0-internal.3.0.5 → 2.0.0-internal.3.1.1
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/.eslintrc.js +5 -7
- package/.mocharc.js +2 -2
- package/README.md +3 -0
- package/api-extractor.json +2 -2
- package/dist/channelContext.d.ts.map +1 -1
- package/dist/channelContext.js.map +1 -1
- package/dist/channelDeltaConnection.d.ts.map +1 -1
- package/dist/channelDeltaConnection.js.map +1 -1
- package/dist/channelStorageService.d.ts.map +1 -1
- package/dist/channelStorageService.js +1 -3
- package/dist/channelStorageService.js.map +1 -1
- package/dist/dataStoreRuntime.d.ts +11 -24
- package/dist/dataStoreRuntime.d.ts.map +1 -1
- package/dist/dataStoreRuntime.js +68 -86
- package/dist/dataStoreRuntime.js.map +1 -1
- package/dist/fluidHandle.d.ts.map +1 -1
- package/dist/fluidHandle.js.map +1 -1
- package/dist/localChannelContext.d.ts.map +1 -1
- package/dist/localChannelContext.js +9 -5
- package/dist/localChannelContext.js.map +1 -1
- package/dist/localChannelStorageService.d.ts.map +1 -1
- package/dist/localChannelStorageService.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/remoteChannelContext.d.ts.map +1 -1
- package/dist/remoteChannelContext.js +2 -2
- package/dist/remoteChannelContext.js.map +1 -1
- package/lib/channelContext.d.ts.map +1 -1
- package/lib/channelContext.js.map +1 -1
- package/lib/channelDeltaConnection.d.ts.map +1 -1
- package/lib/channelDeltaConnection.js.map +1 -1
- package/lib/channelStorageService.d.ts.map +1 -1
- package/lib/channelStorageService.js +1 -3
- package/lib/channelStorageService.js.map +1 -1
- package/lib/dataStoreRuntime.d.ts +11 -24
- package/lib/dataStoreRuntime.d.ts.map +1 -1
- package/lib/dataStoreRuntime.js +71 -89
- package/lib/dataStoreRuntime.js.map +1 -1
- package/lib/fluidHandle.d.ts.map +1 -1
- package/lib/fluidHandle.js.map +1 -1
- package/lib/localChannelContext.d.ts.map +1 -1
- package/lib/localChannelContext.js +9 -5
- package/lib/localChannelContext.js.map +1 -1
- package/lib/localChannelStorageService.d.ts.map +1 -1
- package/lib/localChannelStorageService.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/remoteChannelContext.d.ts.map +1 -1
- package/lib/remoteChannelContext.js +2 -2
- package/lib/remoteChannelContext.js.map +1 -1
- package/package.json +111 -110
- package/prettier.config.cjs +1 -1
- package/src/channelContext.ts +66 -65
- package/src/channelDeltaConnection.ts +50 -44
- package/src/channelStorageService.ts +58 -54
- package/src/dataStoreRuntime.ts +1122 -1086
- package/src/fluidHandle.ts +87 -91
- package/src/localChannelContext.ts +302 -255
- package/src/localChannelStorageService.ts +47 -45
- package/src/packageVersion.ts +1 -1
- package/src/remoteChannelContext.ts +300 -291
- package/tsconfig.esnext.json +6 -6
- package/tsconfig.json +9 -13
|
@@ -10,56 +10,62 @@ import { DataProcessingError } from "@fluidframework/container-utils";
|
|
|
10
10
|
import { IFluidHandle } from "@fluidframework/core-interfaces";
|
|
11
11
|
|
|
12
12
|
export class ChannelDeltaConnection implements IDeltaConnection {
|
|
13
|
-
|
|
13
|
+
private _handler: IDeltaHandler | undefined;
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
private get handler(): IDeltaHandler {
|
|
16
|
+
assert(!!this._handler, 0x177 /* "Missing delta handler" */);
|
|
17
|
+
return this._handler;
|
|
18
|
+
}
|
|
19
|
+
public get connected(): boolean {
|
|
20
|
+
return this._connected;
|
|
21
|
+
}
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
constructor(
|
|
24
|
+
public objectId: string,
|
|
25
|
+
private _connected: boolean,
|
|
26
|
+
public readonly submit: (message: IDocumentMessage, localOpMetadata: unknown) => void,
|
|
27
|
+
public readonly dirty: () => void,
|
|
28
|
+
public readonly addedGCOutboundReference: (
|
|
29
|
+
srcHandle: IFluidHandle,
|
|
30
|
+
outboundHandle: IFluidHandle,
|
|
31
|
+
) => void,
|
|
32
|
+
) {}
|
|
30
33
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
public attach(handler: IDeltaHandler) {
|
|
35
|
+
assert(this._handler === undefined, 0x178 /* "Missing delta handler on attach" */);
|
|
36
|
+
this._handler = handler;
|
|
37
|
+
}
|
|
35
38
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
public setConnectionState(connected: boolean) {
|
|
40
|
+
this._connected = connected;
|
|
41
|
+
this.handler.setConnectionState(connected);
|
|
42
|
+
}
|
|
40
43
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
public process(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown) {
|
|
45
|
+
try {
|
|
46
|
+
// catches as data processing error whether or not they come from async pending queues
|
|
47
|
+
this.handler.process(message, local, localOpMetadata);
|
|
48
|
+
} catch (error) {
|
|
49
|
+
throw DataProcessingError.wrapIfUnrecognized(
|
|
50
|
+
error,
|
|
51
|
+
"channelDeltaConnectionFailedToProcessMessage",
|
|
52
|
+
message,
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
50
56
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
57
|
+
public reSubmit(content: any, localOpMetadata: unknown) {
|
|
58
|
+
this.handler.reSubmit(content, localOpMetadata);
|
|
59
|
+
}
|
|
54
60
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
+
public rollback(content: any, localOpMetadata: unknown) {
|
|
62
|
+
if (this.handler.rollback === undefined) {
|
|
63
|
+
throw new Error("Handler doesn't support rollback");
|
|
64
|
+
}
|
|
65
|
+
this.handler.rollback(content, localOpMetadata);
|
|
66
|
+
}
|
|
61
67
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
68
|
+
public applyStashedOp(message: ISequencedDocumentMessage): unknown {
|
|
69
|
+
return this.handler.applyStashedOp(message);
|
|
70
|
+
}
|
|
65
71
|
}
|
|
@@ -10,68 +10,72 @@ import { getNormalizedObjectStoragePathParts } from "@fluidframework/runtime-uti
|
|
|
10
10
|
import { ITelemetryLogger } from "@fluidframework/common-definitions";
|
|
11
11
|
|
|
12
12
|
export class ChannelStorageService implements IChannelStorageService {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
private static flattenTree(
|
|
14
|
+
base: string,
|
|
15
|
+
tree: ISnapshotTree,
|
|
16
|
+
results: { [path: string]: string },
|
|
17
|
+
) {
|
|
18
|
+
// eslint-disable-next-line guard-for-in, no-restricted-syntax
|
|
19
|
+
for (const path in tree.trees) {
|
|
20
|
+
ChannelStorageService.flattenTree(`${base}${path}/`, tree.trees[path], results);
|
|
21
|
+
}
|
|
18
22
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
// eslint-disable-next-line guard-for-in, no-restricted-syntax
|
|
24
|
+
for (const blob in tree.blobs) {
|
|
25
|
+
results[`${base}${blob}`] = tree.blobs[blob];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
24
28
|
|
|
25
|
-
|
|
29
|
+
private readonly flattenedTree: { [path: string]: string };
|
|
26
30
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
constructor(
|
|
32
|
+
private readonly tree: ISnapshotTree | undefined,
|
|
33
|
+
private readonly storage: Pick<IDocumentStorageService, "readBlob">,
|
|
34
|
+
private readonly logger: ITelemetryLogger,
|
|
35
|
+
private readonly extraBlobs?: Map<string, ArrayBufferLike>,
|
|
36
|
+
) {
|
|
37
|
+
this.flattenedTree = {};
|
|
38
|
+
// Create a map from paths to blobs
|
|
39
|
+
if (tree !== undefined) {
|
|
40
|
+
ChannelStorageService.flattenTree("", tree, this.flattenedTree);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
39
43
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
public async contains(path: string): Promise<boolean> {
|
|
45
|
+
return this.flattenedTree[path] !== undefined;
|
|
46
|
+
}
|
|
43
47
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
? this.extraBlobs.get(id)
|
|
48
|
-
: undefined;
|
|
48
|
+
public async readBlob(path: string): Promise<ArrayBufferLike> {
|
|
49
|
+
const id = await this.getIdForPath(path);
|
|
50
|
+
const blob = this.extraBlobs !== undefined ? this.extraBlobs.get(id) : undefined;
|
|
49
51
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
if (blob !== undefined) {
|
|
53
|
+
return blob;
|
|
54
|
+
}
|
|
55
|
+
const blobP = this.storage.readBlob(id);
|
|
56
|
+
blobP.catch((error) =>
|
|
57
|
+
this.logger.sendErrorEvent({ eventName: "ChannelStorageBlobError" }, error),
|
|
58
|
+
);
|
|
55
59
|
|
|
56
|
-
|
|
57
|
-
|
|
60
|
+
return blobP;
|
|
61
|
+
}
|
|
58
62
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
63
|
+
public async list(path: string): Promise<string[]> {
|
|
64
|
+
let tree = this.tree;
|
|
65
|
+
const pathParts = getNormalizedObjectStoragePathParts(path);
|
|
66
|
+
while (tree !== undefined && pathParts.length > 0) {
|
|
67
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
68
|
+
const part = pathParts.shift()!;
|
|
69
|
+
tree = tree.trees[part];
|
|
70
|
+
}
|
|
71
|
+
if (tree === undefined || pathParts.length !== 0) {
|
|
72
|
+
throw new Error("path does not exist");
|
|
73
|
+
}
|
|
70
74
|
|
|
71
|
-
|
|
72
|
-
|
|
75
|
+
return Object.keys(tree?.blobs ?? {});
|
|
76
|
+
}
|
|
73
77
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
78
|
+
private async getIdForPath(path: string): Promise<string> {
|
|
79
|
+
return this.flattenedTree[path];
|
|
80
|
+
}
|
|
77
81
|
}
|