@fluidframework/datastore 2.0.0-internal.3.0.2 → 2.0.0-internal.3.2.0
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 +10 -18
- package/dist/dataStoreRuntime.d.ts.map +1 -1
- package/dist/dataStoreRuntime.js +65 -83
- 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 +2 -2
- package/dist/remoteChannelContext.d.ts.map +1 -1
- package/dist/remoteChannelContext.js +4 -4
- 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 +10 -18
- package/lib/dataStoreRuntime.d.ts.map +1 -1
- package/lib/dataStoreRuntime.js +68 -86
- 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 +2 -2
- package/lib/remoteChannelContext.d.ts.map +1 -1
- package/lib/remoteChannelContext.js +4 -4
- package/lib/remoteChannelContext.js.map +1 -1
- package/package.json +50 -49
- 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 +1131 -1087
- 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 +297 -291
- package/tsconfig.esnext.json +6 -6
- package/tsconfig.json +9 -13
|
@@ -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
|
}
|