@fluidframework/driver-utils 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.
Files changed (155) hide show
  1. package/.eslintrc.js +17 -19
  2. package/.mocharc.js +2 -2
  3. package/api-extractor.json +2 -2
  4. package/dist/blobAggregationStorage.d.ts +15 -2
  5. package/dist/blobAggregationStorage.d.ts.map +1 -1
  6. package/dist/blobAggregationStorage.js +22 -13
  7. package/dist/blobAggregationStorage.js.map +1 -1
  8. package/dist/blobCacheStorageService.d.ts.map +1 -1
  9. package/dist/blobCacheStorageService.js.map +1 -1
  10. package/dist/buildSnapshotTree.d.ts.map +1 -1
  11. package/dist/buildSnapshotTree.js.map +1 -1
  12. package/dist/documentStorageServiceProxy.d.ts.map +1 -1
  13. package/dist/documentStorageServiceProxy.js.map +1 -1
  14. package/dist/emptyDocumentDeltaStorageService.d.ts.map +1 -1
  15. package/dist/emptyDocumentDeltaStorageService.js.map +1 -1
  16. package/dist/error.d.ts.map +1 -1
  17. package/dist/error.js.map +1 -1
  18. package/dist/fluidResolvedUrl.d.ts.map +1 -1
  19. package/dist/fluidResolvedUrl.js.map +1 -1
  20. package/dist/index.d.ts +1 -1
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js.map +1 -1
  23. package/dist/insecureUrlResolver.d.ts.map +1 -1
  24. package/dist/insecureUrlResolver.js +2 -1
  25. package/dist/insecureUrlResolver.js.map +1 -1
  26. package/dist/mapWithExpiration.d.ts.map +1 -1
  27. package/dist/mapWithExpiration.js +5 -3
  28. package/dist/mapWithExpiration.js.map +1 -1
  29. package/dist/messageRecognition.d.ts.map +1 -1
  30. package/dist/messageRecognition.js.map +1 -1
  31. package/dist/multiDocumentServiceFactory.d.ts.map +1 -1
  32. package/dist/multiDocumentServiceFactory.js.map +1 -1
  33. package/dist/multiUrlResolver.d.ts.map +1 -1
  34. package/dist/multiUrlResolver.js.map +1 -1
  35. package/dist/network.d.ts +1 -1
  36. package/dist/network.d.ts.map +1 -1
  37. package/dist/network.js +4 -3
  38. package/dist/network.js.map +1 -1
  39. package/dist/networkUtils.d.ts.map +1 -1
  40. package/dist/networkUtils.js +2 -3
  41. package/dist/networkUtils.js.map +1 -1
  42. package/dist/packageVersion.d.ts +1 -1
  43. package/dist/packageVersion.js +1 -1
  44. package/dist/packageVersion.js.map +1 -1
  45. package/dist/parallelRequests.d.ts.map +1 -1
  46. package/dist/parallelRequests.js +19 -9
  47. package/dist/parallelRequests.js.map +1 -1
  48. package/dist/prefetchDocumentStorageService.d.ts.map +1 -1
  49. package/dist/prefetchDocumentStorageService.js.map +1 -1
  50. package/dist/rateLimiter.d.ts.map +1 -1
  51. package/dist/rateLimiter.js.map +1 -1
  52. package/dist/readAndParse.d.ts.map +1 -1
  53. package/dist/readAndParse.js.map +1 -1
  54. package/dist/runWithRetry.d.ts.map +1 -1
  55. package/dist/runWithRetry.js.map +1 -1
  56. package/dist/summaryForCreateNew.d.ts.map +1 -1
  57. package/dist/summaryForCreateNew.js.map +1 -1
  58. package/dist/treeConversions.d.ts.map +1 -1
  59. package/dist/treeConversions.js +1 -4
  60. package/dist/treeConversions.js.map +1 -1
  61. package/dist/treeUtils.d.ts +10 -10
  62. package/dist/treeUtils.d.ts.map +1 -1
  63. package/dist/treeUtils.js +10 -10
  64. package/dist/treeUtils.js.map +1 -1
  65. package/lib/blobAggregationStorage.d.ts +15 -2
  66. package/lib/blobAggregationStorage.d.ts.map +1 -1
  67. package/lib/blobAggregationStorage.js +22 -13
  68. package/lib/blobAggregationStorage.js.map +1 -1
  69. package/lib/blobCacheStorageService.d.ts.map +1 -1
  70. package/lib/blobCacheStorageService.js.map +1 -1
  71. package/lib/buildSnapshotTree.d.ts.map +1 -1
  72. package/lib/buildSnapshotTree.js.map +1 -1
  73. package/lib/documentStorageServiceProxy.d.ts.map +1 -1
  74. package/lib/documentStorageServiceProxy.js.map +1 -1
  75. package/lib/emptyDocumentDeltaStorageService.d.ts.map +1 -1
  76. package/lib/emptyDocumentDeltaStorageService.js.map +1 -1
  77. package/lib/error.d.ts.map +1 -1
  78. package/lib/error.js.map +1 -1
  79. package/lib/fluidResolvedUrl.d.ts.map +1 -1
  80. package/lib/fluidResolvedUrl.js.map +1 -1
  81. package/lib/index.d.ts +1 -1
  82. package/lib/index.d.ts.map +1 -1
  83. package/lib/index.js +1 -1
  84. package/lib/index.js.map +1 -1
  85. package/lib/insecureUrlResolver.d.ts.map +1 -1
  86. package/lib/insecureUrlResolver.js +2 -1
  87. package/lib/insecureUrlResolver.js.map +1 -1
  88. package/lib/mapWithExpiration.d.ts.map +1 -1
  89. package/lib/mapWithExpiration.js +5 -3
  90. package/lib/mapWithExpiration.js.map +1 -1
  91. package/lib/messageRecognition.d.ts.map +1 -1
  92. package/lib/messageRecognition.js +1 -1
  93. package/lib/messageRecognition.js.map +1 -1
  94. package/lib/multiDocumentServiceFactory.d.ts.map +1 -1
  95. package/lib/multiDocumentServiceFactory.js.map +1 -1
  96. package/lib/multiUrlResolver.d.ts.map +1 -1
  97. package/lib/multiUrlResolver.js.map +1 -1
  98. package/lib/network.d.ts +1 -1
  99. package/lib/network.d.ts.map +1 -1
  100. package/lib/network.js +4 -3
  101. package/lib/network.js.map +1 -1
  102. package/lib/networkUtils.d.ts.map +1 -1
  103. package/lib/networkUtils.js +2 -3
  104. package/lib/networkUtils.js.map +1 -1
  105. package/lib/packageVersion.d.ts +1 -1
  106. package/lib/packageVersion.js +1 -1
  107. package/lib/packageVersion.js.map +1 -1
  108. package/lib/parallelRequests.d.ts.map +1 -1
  109. package/lib/parallelRequests.js +19 -9
  110. package/lib/parallelRequests.js.map +1 -1
  111. package/lib/prefetchDocumentStorageService.d.ts.map +1 -1
  112. package/lib/prefetchDocumentStorageService.js.map +1 -1
  113. package/lib/rateLimiter.d.ts.map +1 -1
  114. package/lib/rateLimiter.js.map +1 -1
  115. package/lib/readAndParse.d.ts.map +1 -1
  116. package/lib/readAndParse.js.map +1 -1
  117. package/lib/runWithRetry.d.ts.map +1 -1
  118. package/lib/runWithRetry.js.map +1 -1
  119. package/lib/summaryForCreateNew.d.ts.map +1 -1
  120. package/lib/summaryForCreateNew.js.map +1 -1
  121. package/lib/treeConversions.d.ts.map +1 -1
  122. package/lib/treeConversions.js +4 -7
  123. package/lib/treeConversions.js.map +1 -1
  124. package/lib/treeUtils.d.ts +10 -10
  125. package/lib/treeUtils.d.ts.map +1 -1
  126. package/lib/treeUtils.js +11 -11
  127. package/lib/treeUtils.js.map +1 -1
  128. package/package.json +43 -64
  129. package/prettier.config.cjs +1 -1
  130. package/src/blobAggregationStorage.ts +380 -324
  131. package/src/blobCacheStorageService.ts +20 -17
  132. package/src/buildSnapshotTree.ts +54 -51
  133. package/src/documentStorageServiceProxy.ts +49 -43
  134. package/src/emptyDocumentDeltaStorageService.ts +11 -10
  135. package/src/error.ts +5 -7
  136. package/src/fluidResolvedUrl.ts +9 -6
  137. package/src/index.ts +5 -1
  138. package/src/insecureUrlResolver.ts +127 -116
  139. package/src/mapWithExpiration.ts +111 -104
  140. package/src/messageRecognition.ts +25 -19
  141. package/src/multiDocumentServiceFactory.ts +73 -62
  142. package/src/multiUrlResolver.ts +26 -29
  143. package/src/network.ts +114 -112
  144. package/src/networkUtils.ts +37 -34
  145. package/src/packageVersion.ts +1 -1
  146. package/src/parallelRequests.ts +571 -509
  147. package/src/prefetchDocumentStorageService.ts +76 -74
  148. package/src/rateLimiter.ts +29 -29
  149. package/src/readAndParse.ts +7 -4
  150. package/src/runWithRetry.ts +105 -94
  151. package/src/summaryForCreateNew.ts +27 -24
  152. package/src/treeConversions.ts +48 -70
  153. package/src/treeUtils.ts +70 -74
  154. package/tsconfig.esnext.json +6 -6
  155. package/tsconfig.json +8 -12
@@ -3,84 +3,62 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import {
7
- Uint8ArrayToString,
8
- unreachableCase,
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
- summaryTree: ISummaryTree,
28
- ): ITree {
29
- const entries: ITreeEntry[] = [];
30
- const protocolSummary = summaryTree.tree[".protocol"] as ISummaryTree;
31
- const appSummary = summaryTree.tree[".app"] as ISummaryTree;
32
- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
33
- const adaptSumaryTree = protocolSummary && appSummary;
34
- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
35
- const allSummaryEntries = adaptSumaryTree
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
- for (const [key, value] of allSummaryEntries) {
43
- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
44
- const k = adaptSumaryTree && ["attributes"].includes(key) ? `.${key}` : key;
45
- switch (value.type) {
46
- case SummaryType.Blob: {
47
- let parsedContent: string;
48
- let encoding: "utf-8" | "base64" = "utf-8";
49
- if (typeof value.content === "string") {
50
- parsedContent = value.content;
51
- } else {
52
- parsedContent = Uint8ArrayToString(value.content, "base64");
53
- encoding = "base64";
54
- }
55
- entries.push(new BlobTreeEntry(k, parsedContent, encoding));
56
- break;
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
- case SummaryType.Tree: {
60
- entries.push(
61
- new TreeTreeEntry(
62
- k,
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
- case SummaryType.Attachment: {
70
- entries.push(new AttachmentTreeEntry(k, value.id));
71
- break;
72
- }
47
+ case SummaryType.Attachment: {
48
+ entries.push(new AttachmentTreeEntry(k, value.id));
49
+ break;
50
+ }
73
51
 
74
- case SummaryType.Handle: {
75
- throw new Error("Should not have Handle type in summary tree");
76
- }
52
+ case SummaryType.Handle: {
53
+ throw new Error("Should not have Handle type in summary tree");
54
+ }
77
55
 
78
- default:
79
- unreachableCase(value, "Unexpected summary tree type");
80
- }
81
- }
82
- return {
83
- entries,
84
- unreferenced: summaryTree.unreferenced,
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
- assert,
8
- IsoBuffer,
9
- } from "@fluidframework/common-utils";
10
- import {
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
- unreferenced?: true;
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
- private attachmentCounter: number = 0;
32
- private readonly summaryTree: { [path: string]: SummaryObject; } = {};
28
+ private attachmentCounter: number = 0;
29
+ private readonly summaryTree: { [path: string]: SummaryObject } = {};
33
30
 
34
- constructor(
35
- private readonly props?: ISummaryTreeAssemblerProps,
36
- ) { }
31
+ constructor(private readonly props?: ISummaryTreeAssemblerProps) {}
37
32
 
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
- }
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
- * 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
- }
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
- * 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
- }
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
- * Add tree to summary
75
- */
76
- public addTree(key: string, summary: ISummaryTree): void {
77
- this.summaryTree[key] = summary;
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
- * Add attachment to summary
82
- */
83
- public addAttachment(id: string) {
84
- this.summaryTree[this.attachmentCounter++] = { id, type: SummaryType.Attachment };
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
- snapshot: ISnapshotTree,
96
- blobs: Map<string, ArrayBuffer>,
91
+ snapshot: ISnapshotTree,
92
+ blobs: Map<string, ArrayBuffer>,
97
93
  ): 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;
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
  }
@@ -1,7 +1,7 @@
1
1
  {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "./lib",
5
- "module": "esnext"
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
- "extends": "@fluidframework/build-common/ts-common-config.json",
3
- "compilerOptions": {
4
- "composite": true,
5
- "rootDir": "./src",
6
- "outDir": "./dist"
7
- },
8
- "include": [
9
- "src/**/*"
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
  }