@fluidframework/driver-utils 2.0.0-internal.3.0.1 → 2.0.0-internal.3.1.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 +17 -19
- package/.mocharc.js +2 -2
- package/api-extractor.json +2 -2
- package/dist/blobAggregationStorage.d.ts +2 -2
- package/dist/blobAggregationStorage.d.ts.map +1 -1
- package/dist/blobAggregationStorage.js +11 -6
- package/dist/blobAggregationStorage.js.map +1 -1
- package/dist/blobCacheStorageService.d.ts.map +1 -1
- package/dist/blobCacheStorageService.js.map +1 -1
- package/dist/buildSnapshotTree.d.ts.map +1 -1
- package/dist/buildSnapshotTree.js.map +1 -1
- package/dist/documentStorageServiceProxy.d.ts.map +1 -1
- package/dist/documentStorageServiceProxy.js.map +1 -1
- package/dist/emptyDocumentDeltaStorageService.d.ts.map +1 -1
- package/dist/emptyDocumentDeltaStorageService.js.map +1 -1
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js.map +1 -1
- package/dist/fluidResolvedUrl.d.ts.map +1 -1
- package/dist/fluidResolvedUrl.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/insecureUrlResolver.d.ts.map +1 -1
- package/dist/insecureUrlResolver.js +2 -1
- package/dist/insecureUrlResolver.js.map +1 -1
- package/dist/mapWithExpiration.d.ts.map +1 -1
- package/dist/mapWithExpiration.js +5 -3
- package/dist/mapWithExpiration.js.map +1 -1
- package/dist/messageRecognition.d.ts.map +1 -1
- package/dist/messageRecognition.js.map +1 -1
- package/dist/multiDocumentServiceFactory.d.ts.map +1 -1
- package/dist/multiDocumentServiceFactory.js.map +1 -1
- package/dist/multiUrlResolver.d.ts.map +1 -1
- package/dist/multiUrlResolver.js.map +1 -1
- package/dist/network.d.ts +1 -1
- package/dist/network.d.ts.map +1 -1
- package/dist/network.js +4 -3
- package/dist/network.js.map +1 -1
- package/dist/networkUtils.d.ts.map +1 -1
- package/dist/networkUtils.js +2 -3
- package/dist/networkUtils.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/parallelRequests.d.ts.map +1 -1
- package/dist/parallelRequests.js +19 -9
- package/dist/parallelRequests.js.map +1 -1
- package/dist/prefetchDocumentStorageService.d.ts.map +1 -1
- package/dist/prefetchDocumentStorageService.js.map +1 -1
- package/dist/rateLimiter.d.ts.map +1 -1
- package/dist/rateLimiter.js.map +1 -1
- package/dist/readAndParse.d.ts.map +1 -1
- package/dist/readAndParse.js.map +1 -1
- package/dist/runWithRetry.d.ts.map +1 -1
- package/dist/runWithRetry.js.map +1 -1
- package/dist/summaryForCreateNew.d.ts.map +1 -1
- package/dist/summaryForCreateNew.js.map +1 -1
- package/dist/treeConversions.d.ts.map +1 -1
- package/dist/treeConversions.js +1 -4
- package/dist/treeConversions.js.map +1 -1
- package/dist/treeUtils.d.ts +10 -10
- package/dist/treeUtils.d.ts.map +1 -1
- package/dist/treeUtils.js +10 -10
- package/dist/treeUtils.js.map +1 -1
- package/lib/blobAggregationStorage.d.ts +2 -2
- package/lib/blobAggregationStorage.d.ts.map +1 -1
- package/lib/blobAggregationStorage.js +11 -6
- package/lib/blobAggregationStorage.js.map +1 -1
- package/lib/blobCacheStorageService.d.ts.map +1 -1
- package/lib/blobCacheStorageService.js.map +1 -1
- package/lib/buildSnapshotTree.d.ts.map +1 -1
- package/lib/buildSnapshotTree.js.map +1 -1
- package/lib/documentStorageServiceProxy.d.ts.map +1 -1
- package/lib/documentStorageServiceProxy.js.map +1 -1
- package/lib/emptyDocumentDeltaStorageService.d.ts.map +1 -1
- package/lib/emptyDocumentDeltaStorageService.js.map +1 -1
- package/lib/error.d.ts.map +1 -1
- package/lib/error.js.map +1 -1
- package/lib/fluidResolvedUrl.d.ts.map +1 -1
- package/lib/fluidResolvedUrl.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/insecureUrlResolver.d.ts.map +1 -1
- package/lib/insecureUrlResolver.js +2 -1
- package/lib/insecureUrlResolver.js.map +1 -1
- package/lib/mapWithExpiration.d.ts.map +1 -1
- package/lib/mapWithExpiration.js +5 -3
- package/lib/mapWithExpiration.js.map +1 -1
- package/lib/messageRecognition.d.ts.map +1 -1
- package/lib/messageRecognition.js +1 -1
- package/lib/messageRecognition.js.map +1 -1
- package/lib/multiDocumentServiceFactory.d.ts.map +1 -1
- package/lib/multiDocumentServiceFactory.js.map +1 -1
- package/lib/multiUrlResolver.d.ts.map +1 -1
- package/lib/multiUrlResolver.js.map +1 -1
- package/lib/network.d.ts +1 -1
- package/lib/network.d.ts.map +1 -1
- package/lib/network.js +4 -3
- package/lib/network.js.map +1 -1
- package/lib/networkUtils.d.ts.map +1 -1
- package/lib/networkUtils.js +2 -3
- package/lib/networkUtils.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/parallelRequests.d.ts.map +1 -1
- package/lib/parallelRequests.js +19 -9
- package/lib/parallelRequests.js.map +1 -1
- package/lib/prefetchDocumentStorageService.d.ts.map +1 -1
- package/lib/prefetchDocumentStorageService.js.map +1 -1
- package/lib/rateLimiter.d.ts.map +1 -1
- package/lib/rateLimiter.js.map +1 -1
- package/lib/readAndParse.d.ts.map +1 -1
- package/lib/readAndParse.js.map +1 -1
- package/lib/runWithRetry.d.ts.map +1 -1
- package/lib/runWithRetry.js.map +1 -1
- package/lib/summaryForCreateNew.d.ts.map +1 -1
- package/lib/summaryForCreateNew.js.map +1 -1
- package/lib/treeConversions.d.ts.map +1 -1
- package/lib/treeConversions.js +4 -7
- package/lib/treeConversions.js.map +1 -1
- package/lib/treeUtils.d.ts +10 -10
- package/lib/treeUtils.d.ts.map +1 -1
- package/lib/treeUtils.js +11 -11
- package/lib/treeUtils.js.map +1 -1
- package/package.json +128 -105
- package/prettier.config.cjs +1 -1
- package/src/blobAggregationStorage.ts +374 -322
- package/src/blobCacheStorageService.ts +20 -17
- package/src/buildSnapshotTree.ts +54 -51
- package/src/documentStorageServiceProxy.ts +49 -43
- package/src/emptyDocumentDeltaStorageService.ts +11 -10
- package/src/error.ts +5 -7
- package/src/fluidResolvedUrl.ts +9 -6
- package/src/index.ts +5 -1
- package/src/insecureUrlResolver.ts +127 -116
- package/src/mapWithExpiration.ts +111 -104
- package/src/messageRecognition.ts +25 -19
- package/src/multiDocumentServiceFactory.ts +73 -62
- package/src/multiUrlResolver.ts +26 -29
- package/src/network.ts +114 -112
- package/src/networkUtils.ts +37 -34
- package/src/packageVersion.ts +1 -1
- package/src/parallelRequests.ts +571 -509
- package/src/prefetchDocumentStorageService.ts +76 -74
- package/src/rateLimiter.ts +29 -29
- package/src/readAndParse.ts +7 -4
- package/src/runWithRetry.ts +105 -94
- package/src/summaryForCreateNew.ts +27 -24
- package/src/treeConversions.ts +48 -70
- package/src/treeUtils.ts +70 -74
- package/tsconfig.esnext.json +6 -6
- package/tsconfig.json +8 -12
package/src/treeConversions.ts
CHANGED
|
@@ -3,84 +3,62 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
} from "@fluidframework/common-utils";
|
|
10
|
-
import {
|
|
11
|
-
AttachmentTreeEntry,
|
|
12
|
-
BlobTreeEntry,
|
|
13
|
-
TreeTreeEntry,
|
|
14
|
-
} from "@fluidframework/protocol-base";
|
|
15
|
-
import {
|
|
16
|
-
ISummaryTree,
|
|
17
|
-
ITree,
|
|
18
|
-
ITreeEntry,
|
|
19
|
-
SummaryType,
|
|
20
|
-
} from "@fluidframework/protocol-definitions";
|
|
6
|
+
import { Uint8ArrayToString, unreachableCase } from "@fluidframework/common-utils";
|
|
7
|
+
import { AttachmentTreeEntry, BlobTreeEntry, TreeTreeEntry } from "@fluidframework/protocol-base";
|
|
8
|
+
import { ISummaryTree, ITree, ITreeEntry, SummaryType } from "@fluidframework/protocol-definitions";
|
|
21
9
|
|
|
22
10
|
/**
|
|
23
11
|
* Converts ISummaryTree to ITree format.
|
|
24
12
|
* @param summaryTree - summary tree in ISummaryTree format
|
|
25
13
|
*/
|
|
26
|
-
export function convertSummaryTreeToSnapshotITree(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
? [
|
|
37
|
-
...Object.entries(protocolSummary.tree),
|
|
38
|
-
...Object.entries(appSummary.tree),
|
|
39
|
-
]
|
|
40
|
-
: Object.entries(summaryTree.tree);
|
|
14
|
+
export function convertSummaryTreeToSnapshotITree(summaryTree: ISummaryTree): ITree {
|
|
15
|
+
const entries: ITreeEntry[] = [];
|
|
16
|
+
const protocolSummary = summaryTree.tree[".protocol"] as ISummaryTree;
|
|
17
|
+
const appSummary = summaryTree.tree[".app"] as ISummaryTree;
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
19
|
+
const adaptSumaryTree = protocolSummary && appSummary;
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
21
|
+
const allSummaryEntries = adaptSumaryTree
|
|
22
|
+
? [...Object.entries(protocolSummary.tree), ...Object.entries(appSummary.tree)]
|
|
23
|
+
: Object.entries(summaryTree.tree);
|
|
41
24
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
25
|
+
for (const [key, value] of allSummaryEntries) {
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
27
|
+
const k = adaptSumaryTree && ["attributes"].includes(key) ? `.${key}` : key;
|
|
28
|
+
switch (value.type) {
|
|
29
|
+
case SummaryType.Blob: {
|
|
30
|
+
let parsedContent: string;
|
|
31
|
+
let encoding: "utf-8" | "base64" = "utf-8";
|
|
32
|
+
if (typeof value.content === "string") {
|
|
33
|
+
parsedContent = value.content;
|
|
34
|
+
} else {
|
|
35
|
+
parsedContent = Uint8ArrayToString(value.content, "base64");
|
|
36
|
+
encoding = "base64";
|
|
37
|
+
}
|
|
38
|
+
entries.push(new BlobTreeEntry(k, parsedContent, encoding));
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
58
41
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
convertSummaryTreeToSnapshotITree(value),
|
|
64
|
-
),
|
|
65
|
-
);
|
|
66
|
-
break;
|
|
67
|
-
}
|
|
42
|
+
case SummaryType.Tree: {
|
|
43
|
+
entries.push(new TreeTreeEntry(k, convertSummaryTreeToSnapshotITree(value)));
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
68
46
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
47
|
+
case SummaryType.Attachment: {
|
|
48
|
+
entries.push(new AttachmentTreeEntry(k, value.id));
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
73
51
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
52
|
+
case SummaryType.Handle: {
|
|
53
|
+
throw new Error("Should not have Handle type in summary tree");
|
|
54
|
+
}
|
|
77
55
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
56
|
+
default:
|
|
57
|
+
unreachableCase(value, "Unexpected summary tree type");
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
entries,
|
|
62
|
+
unreferenced: summaryTree.unreferenced,
|
|
63
|
+
};
|
|
86
64
|
}
|
package/src/treeUtils.ts
CHANGED
|
@@ -3,86 +3,82 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import { assert, IsoBuffer } from "@fluidframework/common-utils";
|
|
6
7
|
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
SummaryType,
|
|
12
|
-
ISnapshotTree,
|
|
13
|
-
ISummaryTree,
|
|
14
|
-
SummaryObject,
|
|
8
|
+
SummaryType,
|
|
9
|
+
ISnapshotTree,
|
|
10
|
+
ISummaryTree,
|
|
11
|
+
SummaryObject,
|
|
15
12
|
} from "@fluidframework/protocol-definitions";
|
|
16
13
|
|
|
17
14
|
/**
|
|
18
15
|
* Summary tree assembler props
|
|
19
16
|
*/
|
|
20
17
|
export interface ISummaryTreeAssemblerProps {
|
|
21
|
-
|
|
18
|
+
/**
|
|
22
19
|
* Indicates that this tree is unreferenced. If this is not present, the tree is considered referenced.
|
|
23
20
|
*/
|
|
24
|
-
|
|
21
|
+
unreferenced?: true;
|
|
25
22
|
}
|
|
26
23
|
|
|
27
24
|
/**
|
|
28
25
|
* Summary tree assembler (without stats collection).
|
|
29
26
|
*/
|
|
30
27
|
export class SummaryTreeAssembler {
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
private attachmentCounter: number = 0;
|
|
29
|
+
private readonly summaryTree: { [path: string]: SummaryObject } = {};
|
|
33
30
|
|
|
34
|
-
|
|
35
|
-
private readonly props?: ISummaryTreeAssemblerProps,
|
|
36
|
-
) { }
|
|
31
|
+
constructor(private readonly props?: ISummaryTreeAssemblerProps) {}
|
|
37
32
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Get final summary
|
|
35
|
+
*/
|
|
36
|
+
public get summary(): ISummaryTree {
|
|
37
|
+
return {
|
|
38
|
+
type: SummaryType.Tree,
|
|
39
|
+
tree: { ...this.summaryTree },
|
|
40
|
+
unreferenced: this.props?.unreferenced,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
48
43
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Add blob to summary
|
|
46
|
+
*/
|
|
47
|
+
public addBlob(key: string, content: string | Uint8Array): void {
|
|
48
|
+
this.summaryTree[key] = {
|
|
49
|
+
type: SummaryType.Blob,
|
|
50
|
+
content,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
58
53
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Add handle to summary
|
|
56
|
+
*/
|
|
57
|
+
public addHandle(
|
|
58
|
+
key: string,
|
|
59
|
+
handleType: SummaryType.Tree | SummaryType.Blob | SummaryType.Attachment,
|
|
60
|
+
handle: string,
|
|
61
|
+
): void {
|
|
62
|
+
this.summaryTree[key] = {
|
|
63
|
+
type: SummaryType.Handle,
|
|
64
|
+
handleType,
|
|
65
|
+
handle,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
72
68
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
69
|
+
/**
|
|
70
|
+
* Add tree to summary
|
|
71
|
+
*/
|
|
72
|
+
public addTree(key: string, summary: ISummaryTree): void {
|
|
73
|
+
this.summaryTree[key] = summary;
|
|
74
|
+
}
|
|
79
75
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Add attachment to summary
|
|
78
|
+
*/
|
|
79
|
+
public addAttachment(id: string) {
|
|
80
|
+
this.summaryTree[this.attachmentCounter++] = { id, type: SummaryType.Attachment };
|
|
81
|
+
}
|
|
86
82
|
}
|
|
87
83
|
|
|
88
84
|
/**
|
|
@@ -92,20 +88,20 @@ export class SummaryTreeAssembler {
|
|
|
92
88
|
* @returns Converted snapshot in ISummaryTree format
|
|
93
89
|
*/
|
|
94
90
|
export function convertSnapshotAndBlobsToSummaryTree(
|
|
95
|
-
|
|
96
|
-
|
|
91
|
+
snapshot: ISnapshotTree,
|
|
92
|
+
blobs: Map<string, ArrayBuffer>,
|
|
97
93
|
): ISummaryTree {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
94
|
+
const assembler = new SummaryTreeAssembler({
|
|
95
|
+
unreferenced: snapshot.unreferenced,
|
|
96
|
+
});
|
|
97
|
+
for (const [path, id] of Object.entries(snapshot.blobs)) {
|
|
98
|
+
const blob = blobs.get(id);
|
|
99
|
+
assert(blob !== undefined, 0x2dd /* "Cannot find blob for a given id" */);
|
|
100
|
+
assembler.addBlob(path, IsoBuffer.from(blob).toString("utf-8"));
|
|
101
|
+
}
|
|
102
|
+
for (const [key, tree] of Object.entries(snapshot.trees)) {
|
|
103
|
+
const subtree = convertSnapshotAndBlobsToSummaryTree(tree, blobs);
|
|
104
|
+
assembler.addTree(key, subtree);
|
|
105
|
+
}
|
|
106
|
+
return assembler.summary;
|
|
111
107
|
}
|
package/tsconfig.esnext.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "./lib",
|
|
5
|
+
"module": "esnext",
|
|
6
|
+
},
|
|
7
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
],
|
|
11
|
-
"exclude": [
|
|
12
|
-
"src/test/**/*",
|
|
13
|
-
]
|
|
2
|
+
"extends": "@fluidframework/build-common/ts-common-config.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"composite": true,
|
|
5
|
+
"rootDir": "./src",
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
},
|
|
8
|
+
"include": ["src/**/*"],
|
|
9
|
+
"exclude": ["src/test/**/*"],
|
|
14
10
|
}
|