@fluidframework/driver-utils 0.59.2001 → 0.59.3000
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/blobAggregationStorage.d.ts.map +1 -1
- package/dist/blobAggregationStorage.js +20 -20
- package/dist/blobAggregationStorage.js.map +1 -1
- package/dist/buildSnapshotTree.js +4 -4
- package/dist/buildSnapshotTree.js.map +1 -1
- package/dist/documentStorageServiceProxy.js.map +1 -1
- package/dist/fluidResolvedUrl.js +1 -1
- package/dist/fluidResolvedUrl.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/insecureUrlResolver.js +2 -2
- package/dist/insecureUrlResolver.js.map +1 -1
- package/dist/multiDocumentServiceFactory.js +4 -4
- package/dist/multiDocumentServiceFactory.js.map +1 -1
- package/dist/network.d.ts.map +1 -1
- package/dist/network.js.map +1 -1
- package/dist/networkUtils.js +3 -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 +28 -28
- package/dist/parallelRequests.js.map +1 -1
- package/dist/prefetchDocumentStorageService.js +1 -1
- package/dist/prefetchDocumentStorageService.js.map +1 -1
- package/dist/rateLimiter.js +1 -1
- package/dist/rateLimiter.js.map +1 -1
- package/dist/readAndParse.js +1 -1
- package/dist/readAndParse.js.map +1 -1
- package/dist/runWithRetry.js +3 -3
- package/dist/runWithRetry.js.map +1 -1
- package/dist/summaryForCreateNew.js.map +1 -1
- package/dist/treeConversions.js +2 -2
- package/dist/treeConversions.js.map +1 -1
- package/dist/treeUtils.d.ts +51 -0
- package/dist/treeUtils.d.ts.map +1 -0
- package/dist/treeUtils.js +85 -0
- package/dist/treeUtils.js.map +1 -0
- package/lib/blobAggregationStorage.d.ts.map +1 -1
- package/lib/blobAggregationStorage.js.map +1 -1
- package/lib/documentStorageServiceProxy.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/insecureUrlResolver.js.map +1 -1
- package/lib/network.d.ts.map +1 -1
- package/lib/network.js.map +1 -1
- 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.map +1 -1
- package/lib/runWithRetry.js.map +1 -1
- package/lib/summaryForCreateNew.js.map +1 -1
- package/lib/treeUtils.d.ts +51 -0
- package/lib/treeUtils.d.ts.map +1 -0
- package/lib/treeUtils.js +80 -0
- package/lib/treeUtils.js.map +1 -0
- package/package.json +11 -10
- package/src/blobAggregationStorage.ts +5 -7
- package/src/index.ts +1 -0
- package/src/network.ts +2 -2
- package/src/packageVersion.ts +1 -1
- package/src/parallelRequests.ts +9 -12
- package/src/treeUtils.ts +111 -0
package/src/treeUtils.ts
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
assert,
|
|
8
|
+
IsoBuffer,
|
|
9
|
+
} from "@fluidframework/common-utils";
|
|
10
|
+
import {
|
|
11
|
+
SummaryType,
|
|
12
|
+
ISnapshotTree,
|
|
13
|
+
ISummaryTree,
|
|
14
|
+
SummaryObject,
|
|
15
|
+
} from "@fluidframework/protocol-definitions";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Summary tree assembler props
|
|
19
|
+
*/
|
|
20
|
+
export interface ISummaryTreeAssemblerProps {
|
|
21
|
+
/**
|
|
22
|
+
* Indicates that this tree is unreferenced. If this is not present, the tree is considered referenced.
|
|
23
|
+
*/
|
|
24
|
+
unreferenced?: true;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Summary tree assembler (without stats collection).
|
|
29
|
+
*/
|
|
30
|
+
export class SummaryTreeAssembler {
|
|
31
|
+
private attachmentCounter: number = 0;
|
|
32
|
+
private readonly summaryTree: { [path: string]: SummaryObject; } = {};
|
|
33
|
+
|
|
34
|
+
constructor(
|
|
35
|
+
private readonly props?: ISummaryTreeAssemblerProps,
|
|
36
|
+
) { }
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Get final summary
|
|
40
|
+
*/
|
|
41
|
+
public get summary(): ISummaryTree {
|
|
42
|
+
return {
|
|
43
|
+
type: SummaryType.Tree,
|
|
44
|
+
tree: { ...this.summaryTree },
|
|
45
|
+
unreferenced: this.props?.unreferenced,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Add blob to summary
|
|
51
|
+
*/
|
|
52
|
+
public addBlob(key: string, content: string | Uint8Array): void {
|
|
53
|
+
this.summaryTree[key] = {
|
|
54
|
+
type: SummaryType.Blob,
|
|
55
|
+
content,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Add handle to summary
|
|
61
|
+
*/
|
|
62
|
+
public addHandle(
|
|
63
|
+
key: string,
|
|
64
|
+
handleType: SummaryType.Tree | SummaryType.Blob | SummaryType.Attachment,
|
|
65
|
+
handle: string): void {
|
|
66
|
+
this.summaryTree[key] = {
|
|
67
|
+
type: SummaryType.Handle,
|
|
68
|
+
handleType,
|
|
69
|
+
handle,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Add tree to summary
|
|
75
|
+
*/
|
|
76
|
+
public addTree(key: string, summary: ISummaryTree): void {
|
|
77
|
+
this.summaryTree[key] = summary;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Add attachment to summary
|
|
82
|
+
*/
|
|
83
|
+
public addAttachment(id: string) {
|
|
84
|
+
this.summaryTree[this.attachmentCounter++] = { id, type: SummaryType.Attachment };
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Helper function that converts ISnapshotTree and blobs to ISummaryTree
|
|
90
|
+
* @param snapshot - Source snapshot tree
|
|
91
|
+
* @param blobs - Blobs cache
|
|
92
|
+
* @returns Converted snapshot in ISummaryTree format
|
|
93
|
+
*/
|
|
94
|
+
export function convertSnapshotAndBlobsToSummaryTree(
|
|
95
|
+
snapshot: ISnapshotTree,
|
|
96
|
+
blobs: Map<string, ArrayBuffer>,
|
|
97
|
+
): ISummaryTree {
|
|
98
|
+
const assembler = new SummaryTreeAssembler({
|
|
99
|
+
unreferenced: snapshot.unreferenced,
|
|
100
|
+
});
|
|
101
|
+
for (const [path, id] of Object.entries(snapshot.blobs)) {
|
|
102
|
+
const blob = blobs.get(id);
|
|
103
|
+
assert(blob !== undefined, 0x2dd /* "Cannot find blob for a given id" */);
|
|
104
|
+
assembler.addBlob(path, IsoBuffer.from(blob).toString("utf-8"));
|
|
105
|
+
}
|
|
106
|
+
for (const [key, tree] of Object.entries(snapshot.trees)) {
|
|
107
|
+
const subtree = convertSnapshotAndBlobsToSummaryTree(tree, blobs);
|
|
108
|
+
assembler.addTree(key, subtree);
|
|
109
|
+
}
|
|
110
|
+
return assembler.summary;
|
|
111
|
+
}
|