@fluidframework/routerlicious-driver 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.
Files changed (138) hide show
  1. package/.eslintrc.js +10 -12
  2. package/.mocharc.js +2 -2
  3. package/README.md +1 -1
  4. package/api-extractor.json +2 -2
  5. package/dist/cache.d.ts.map +1 -1
  6. package/dist/cache.js +2 -5
  7. package/dist/cache.js.map +1 -1
  8. package/dist/createNewUtils.d.ts.map +1 -1
  9. package/dist/createNewUtils.js +4 -2
  10. package/dist/createNewUtils.js.map +1 -1
  11. package/dist/defaultTokenProvider.d.ts.map +1 -1
  12. package/dist/defaultTokenProvider.js.map +1 -1
  13. package/dist/definitions.d.ts.map +1 -1
  14. package/dist/definitions.js.map +1 -1
  15. package/dist/deltaStorageService.d.ts.map +1 -1
  16. package/dist/deltaStorageService.js +4 -1
  17. package/dist/deltaStorageService.js.map +1 -1
  18. package/dist/documentDeltaConnection.d.ts.map +1 -1
  19. package/dist/documentDeltaConnection.js.map +1 -1
  20. package/dist/documentService.d.ts.map +1 -1
  21. package/dist/documentService.js +13 -5
  22. package/dist/documentService.js.map +1 -1
  23. package/dist/documentServiceFactory.d.ts.map +1 -1
  24. package/dist/documentServiceFactory.js +7 -4
  25. package/dist/documentServiceFactory.js.map +1 -1
  26. package/dist/documentStorageService.d.ts.map +1 -1
  27. package/dist/documentStorageService.js +7 -5
  28. package/dist/documentStorageService.js.map +1 -1
  29. package/dist/errorUtils.d.ts +9 -2
  30. package/dist/errorUtils.d.ts.map +1 -1
  31. package/dist/errorUtils.js +15 -8
  32. package/dist/errorUtils.js.map +1 -1
  33. package/dist/index.d.ts +2 -1
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +4 -1
  36. package/dist/index.js.map +1 -1
  37. package/dist/nullBlobStorageService.d.ts.map +1 -1
  38. package/dist/nullBlobStorageService.js.map +1 -1
  39. package/dist/packageVersion.d.ts +1 -1
  40. package/dist/packageVersion.js +1 -1
  41. package/dist/packageVersion.js.map +1 -1
  42. package/dist/policies.d.ts.map +1 -1
  43. package/dist/policies.js.map +1 -1
  44. package/dist/restWrapper.d.ts.map +1 -1
  45. package/dist/restWrapper.js +5 -6
  46. package/dist/restWrapper.js.map +1 -1
  47. package/dist/retriableGitManager.d.ts.map +1 -1
  48. package/dist/retriableGitManager.js.map +1 -1
  49. package/dist/shreddedSummaryDocumentStorageService.d.ts.map +1 -1
  50. package/dist/shreddedSummaryDocumentStorageService.js +8 -4
  51. package/dist/shreddedSummaryDocumentStorageService.js.map +1 -1
  52. package/dist/tokens.d.ts +24 -7
  53. package/dist/tokens.d.ts.map +1 -1
  54. package/dist/tokens.js.map +1 -1
  55. package/dist/urlUtils.d.ts.map +1 -1
  56. package/dist/urlUtils.js.map +1 -1
  57. package/dist/wholeSummaryDocumentStorageService.d.ts.map +1 -1
  58. package/dist/wholeSummaryDocumentStorageService.js +25 -11
  59. package/dist/wholeSummaryDocumentStorageService.js.map +1 -1
  60. package/lib/cache.d.ts.map +1 -1
  61. package/lib/cache.js +2 -5
  62. package/lib/cache.js.map +1 -1
  63. package/lib/createNewUtils.d.ts.map +1 -1
  64. package/lib/createNewUtils.js +4 -2
  65. package/lib/createNewUtils.js.map +1 -1
  66. package/lib/defaultTokenProvider.d.ts.map +1 -1
  67. package/lib/defaultTokenProvider.js.map +1 -1
  68. package/lib/definitions.d.ts.map +1 -1
  69. package/lib/definitions.js.map +1 -1
  70. package/lib/deltaStorageService.d.ts.map +1 -1
  71. package/lib/deltaStorageService.js +4 -1
  72. package/lib/deltaStorageService.js.map +1 -1
  73. package/lib/documentDeltaConnection.d.ts.map +1 -1
  74. package/lib/documentDeltaConnection.js.map +1 -1
  75. package/lib/documentService.d.ts.map +1 -1
  76. package/lib/documentService.js +15 -7
  77. package/lib/documentService.js.map +1 -1
  78. package/lib/documentServiceFactory.d.ts.map +1 -1
  79. package/lib/documentServiceFactory.js +7 -4
  80. package/lib/documentServiceFactory.js.map +1 -1
  81. package/lib/documentStorageService.d.ts.map +1 -1
  82. package/lib/documentStorageService.js +8 -6
  83. package/lib/documentStorageService.js.map +1 -1
  84. package/lib/errorUtils.d.ts +9 -2
  85. package/lib/errorUtils.d.ts.map +1 -1
  86. package/lib/errorUtils.js +14 -7
  87. package/lib/errorUtils.js.map +1 -1
  88. package/lib/index.d.ts +2 -1
  89. package/lib/index.d.ts.map +1 -1
  90. package/lib/index.js +3 -1
  91. package/lib/index.js.map +1 -1
  92. package/lib/nullBlobStorageService.d.ts.map +1 -1
  93. package/lib/nullBlobStorageService.js.map +1 -1
  94. package/lib/packageVersion.d.ts +1 -1
  95. package/lib/packageVersion.js +1 -1
  96. package/lib/packageVersion.js.map +1 -1
  97. package/lib/policies.d.ts.map +1 -1
  98. package/lib/policies.js.map +1 -1
  99. package/lib/restWrapper.d.ts.map +1 -1
  100. package/lib/restWrapper.js +5 -6
  101. package/lib/restWrapper.js.map +1 -1
  102. package/lib/retriableGitManager.d.ts.map +1 -1
  103. package/lib/retriableGitManager.js.map +1 -1
  104. package/lib/shreddedSummaryDocumentStorageService.d.ts.map +1 -1
  105. package/lib/shreddedSummaryDocumentStorageService.js +9 -5
  106. package/lib/shreddedSummaryDocumentStorageService.js.map +1 -1
  107. package/lib/tokens.d.ts +24 -7
  108. package/lib/tokens.d.ts.map +1 -1
  109. package/lib/tokens.js.map +1 -1
  110. package/lib/urlUtils.d.ts.map +1 -1
  111. package/lib/urlUtils.js.map +1 -1
  112. package/lib/wholeSummaryDocumentStorageService.d.ts.map +1 -1
  113. package/lib/wholeSummaryDocumentStorageService.js +27 -13
  114. package/lib/wholeSummaryDocumentStorageService.js.map +1 -1
  115. package/package.json +115 -114
  116. package/prettier.config.cjs +1 -1
  117. package/src/cache.ts +16 -19
  118. package/src/createNewUtils.ts +24 -22
  119. package/src/defaultTokenProvider.ts +13 -15
  120. package/src/definitions.ts +2 -2
  121. package/src/deltaStorageService.ts +99 -95
  122. package/src/documentDeltaConnection.ts +53 -47
  123. package/src/documentService.ts +260 -239
  124. package/src/documentServiceFactory.ts +263 -250
  125. package/src/documentStorageService.ts +87 -83
  126. package/src/errorUtils.ts +91 -81
  127. package/src/index.ts +7 -1
  128. package/src/nullBlobStorageService.ts +24 -21
  129. package/src/packageVersion.ts +1 -1
  130. package/src/policies.ts +44 -44
  131. package/src/restWrapper.ts +266 -216
  132. package/src/retriableGitManager.ts +152 -151
  133. package/src/shreddedSummaryDocumentStorageService.ts +202 -194
  134. package/src/tokens.ts +69 -44
  135. package/src/urlUtils.ts +26 -23
  136. package/src/wholeSummaryDocumentStorageService.ts +246 -228
  137. package/tsconfig.esnext.json +6 -6
  138. package/tsconfig.json +9 -13
@@ -4,31 +4,25 @@
4
4
  */
5
5
 
6
6
  import type { ITelemetryLogger } from "@fluidframework/common-definitions";
7
+ import { assert, stringToBuffer, Uint8ArrayToString } from "@fluidframework/common-utils";
7
8
  import {
8
- assert,
9
- stringToBuffer,
10
- Uint8ArrayToString,
11
- } from "@fluidframework/common-utils";
12
- import {
13
- IDocumentStorageService,
14
- ISummaryContext,
15
- IDocumentStorageServicePolicies,
9
+ IDocumentStorageService,
10
+ ISummaryContext,
11
+ IDocumentStorageServicePolicies,
16
12
  } from "@fluidframework/driver-definitions";
13
+ import { convertSnapshotAndBlobsToSummaryTree } from "@fluidframework/driver-utils";
17
14
  import {
18
- convertSnapshotAndBlobsToSummaryTree,
19
- } from "@fluidframework/driver-utils";
20
- import {
21
- ICreateBlobResponse,
22
- ISnapshotTree,
23
- ISummaryHandle,
24
- ISummaryTree,
25
- IVersion,
15
+ ICreateBlobResponse,
16
+ ISnapshotTree,
17
+ ISummaryHandle,
18
+ ISummaryTree,
19
+ IVersion,
26
20
  } from "@fluidframework/protocol-definitions";
27
21
  import {
28
- convertWholeFlatSummaryToSnapshotTreeAndBlobs,
29
- GitManager,
30
- ISummaryUploadManager,
31
- WholeSummaryUploadManager,
22
+ convertWholeFlatSummaryToSnapshotTreeAndBlobs,
23
+ GitManager,
24
+ ISummaryUploadManager,
25
+ WholeSummaryUploadManager,
32
26
  } from "@fluidframework/server-services-client";
33
27
  import { PerformanceEvent } from "@fluidframework/telemetry-utils";
34
28
  import { ICache, InMemoryCache } from "./cache";
@@ -38,235 +32,259 @@ import { IRouterliciousDriverPolicies } from "./policies";
38
32
  const latestSnapshotId: string = "latest";
39
33
 
40
34
  export class WholeSummaryDocumentStorageService implements IDocumentStorageService {
41
- private firstVersionsCall: boolean = true;
35
+ private firstVersionsCall: boolean = true;
42
36
 
43
- public get repositoryUrl(): string {
44
- return "";
45
- }
37
+ public get repositoryUrl(): string {
38
+ return "";
39
+ }
46
40
 
47
- private async getSummaryUploadManager(): Promise<ISummaryUploadManager> {
48
- const manager = await this.getStorageManager();
49
- return new WholeSummaryUploadManager(manager);
50
- }
41
+ private async getSummaryUploadManager(): Promise<ISummaryUploadManager> {
42
+ const manager = await this.getStorageManager();
43
+ return new WholeSummaryUploadManager(manager);
44
+ }
51
45
 
52
- constructor(
53
- protected readonly id: string,
54
- protected readonly manager: GitManager,
55
- protected readonly logger: ITelemetryLogger,
56
- public readonly policies: IDocumentStorageServicePolicies,
57
- private readonly driverPolicies?: IRouterliciousDriverPolicies,
58
- private readonly blobCache: ICache<ArrayBufferLike> = new InMemoryCache(),
59
- private readonly snapshotTreeCache: ICache<ISnapshotTreeVersion> = new InMemoryCache(),
60
- private readonly noCacheGitManager?: GitManager,
61
- private readonly getStorageManager: (disableCache?: boolean) => Promise<GitManager> = async (disableCache) =>
62
- disableCache && this.noCacheGitManager !== undefined ? this.noCacheGitManager : this.manager,
63
- ) {
64
- }
46
+ constructor(
47
+ protected readonly id: string,
48
+ protected readonly manager: GitManager,
49
+ protected readonly logger: ITelemetryLogger,
50
+ public readonly policies: IDocumentStorageServicePolicies,
51
+ private readonly driverPolicies?: IRouterliciousDriverPolicies,
52
+ private readonly blobCache: ICache<ArrayBufferLike> = new InMemoryCache(),
53
+ private readonly snapshotTreeCache: ICache<ISnapshotTreeVersion> = new InMemoryCache(),
54
+ private readonly noCacheGitManager?: GitManager,
55
+ private readonly getStorageManager: (
56
+ disableCache?: boolean,
57
+ ) => Promise<GitManager> = async (disableCache) =>
58
+ disableCache && this.noCacheGitManager !== undefined
59
+ ? this.noCacheGitManager
60
+ : this.manager,
61
+ ) {}
65
62
 
66
- public async getVersions(versionId: string | null, count: number): Promise<IVersion[]> {
67
- if (versionId !== this.id && versionId !== null) {
68
- // Blobs/Trees in this scenario will never have multiple versions, so return versionId as is
69
- return [{
70
- id: versionId,
71
- treeId: undefined!,
72
- }];
73
- }
74
- // If this is the first versions call for the document, we know we will want the latest summary.
75
- // Fetch latest summary, cache it, and return its id.
76
- if (this.firstVersionsCall && count === 1) {
77
- this.firstVersionsCall = false;
78
- const { id: _id, snapshotTree } = !this.driverPolicies?.enableDiscovery ?
79
- await this.fetchAndCacheSnapshotTree(latestSnapshotId, false) :
80
- await this.fetchAndCacheSnapshotTree(latestSnapshotId, true);
81
- return [{
82
- id: _id,
83
- treeId: snapshotTree.id!,
84
- }];
85
- }
63
+ public async getVersions(versionId: string | null, count: number): Promise<IVersion[]> {
64
+ if (versionId !== this.id && versionId !== null) {
65
+ // Blobs/Trees in this scenario will never have multiple versions, so return versionId as is
66
+ return [
67
+ {
68
+ id: versionId,
69
+ treeId: undefined!,
70
+ },
71
+ ];
72
+ }
73
+ // If this is the first versions call for the document, we know we will want the latest summary.
74
+ // Fetch latest summary, cache it, and return its id.
75
+ if (this.firstVersionsCall && count === 1) {
76
+ this.firstVersionsCall = false;
77
+ const { id: _id, snapshotTree } = !this.driverPolicies?.enableDiscovery
78
+ ? await this.fetchAndCacheSnapshotTree(latestSnapshotId, false)
79
+ : await this.fetchAndCacheSnapshotTree(latestSnapshotId, true);
80
+ return [
81
+ {
82
+ id: _id,
83
+ treeId: snapshotTree.id!,
84
+ },
85
+ ];
86
+ }
86
87
 
87
- // Otherwise, get the latest version of the document as normal.
88
- const id = versionId ? versionId : this.id;
89
- const commits = await PerformanceEvent.timedExecAsync(
90
- this.logger,
91
- {
92
- eventName: "getVersions",
93
- versionId: id,
94
- count,
95
- },
96
- async () => {
97
- const manager = await this.getStorageManager();
98
- return manager.getCommits(id, count);
99
- },
100
- );
101
- return commits.map((commit) => ({
102
- date: commit.commit.author.date,
103
- id: commit.sha,
104
- treeId: commit.commit.tree.sha,
105
- }));
106
- }
88
+ // Otherwise, get the latest version of the document as normal.
89
+ const id = versionId ? versionId : this.id;
90
+ const commits = await PerformanceEvent.timedExecAsync(
91
+ this.logger,
92
+ {
93
+ eventName: "getVersions",
94
+ versionId: id,
95
+ count,
96
+ },
97
+ async () => {
98
+ const manager = await this.getStorageManager();
99
+ return manager.getCommits(id, count);
100
+ },
101
+ );
102
+ return commits.map((commit) => ({
103
+ date: commit.commit.author.date,
104
+ id: commit.sha,
105
+ treeId: commit.commit.tree.sha,
106
+ }));
107
+ }
107
108
 
108
- public async getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null> {
109
- let requestVersion = version;
110
- if (!requestVersion) {
111
- const versions = await this.getVersions(this.id, 1);
112
- if (versions.length === 0) {
113
- return null;
114
- }
109
+ public async getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null> {
110
+ let requestVersion = version;
111
+ if (!requestVersion) {
112
+ const versions = await this.getVersions(this.id, 1);
113
+ if (versions.length === 0) {
114
+ return null;
115
+ }
115
116
 
116
- requestVersion = versions[0];
117
- }
117
+ requestVersion = versions[0];
118
+ }
118
119
 
119
- return (await this.fetchAndCacheSnapshotTree(requestVersion.id)).snapshotTree;
120
- }
120
+ return (await this.fetchAndCacheSnapshotTree(requestVersion.id)).snapshotTree;
121
+ }
121
122
 
122
- public async readBlob(blobId: string): Promise<ArrayBufferLike> {
123
- const cachedBlob = await this.blobCache.get(this.getCacheKey(blobId));
124
- if (cachedBlob !== undefined) {
125
- return cachedBlob;
126
- }
123
+ public async readBlob(blobId: string): Promise<ArrayBufferLike> {
124
+ const cachedBlob = await this.blobCache.get(this.getCacheKey(blobId));
125
+ if (cachedBlob !== undefined) {
126
+ return cachedBlob;
127
+ }
127
128
 
128
- const blob = await PerformanceEvent.timedExecAsync(
129
- this.logger,
130
- {
131
- eventName: "readBlob",
132
- blobId,
133
- },
134
- async (event) => {
135
- const manager = await this.getStorageManager();
136
- const response = await manager.getBlob(blobId);
137
- event.end({
138
- size: response.size,
139
- });
140
- return response;
141
- },
142
- );
143
- const bufferValue = stringToBuffer(blob.content, blob.encoding);
129
+ const blob = await PerformanceEvent.timedExecAsync(
130
+ this.logger,
131
+ {
132
+ eventName: "readBlob",
133
+ blobId,
134
+ },
135
+ async (event) => {
136
+ const manager = await this.getStorageManager();
137
+ const response = await manager.getBlob(blobId);
138
+ event.end({
139
+ size: response.size,
140
+ });
141
+ return response;
142
+ },
143
+ );
144
+ const bufferValue = stringToBuffer(blob.content, blob.encoding);
144
145
 
145
- await this.blobCache.put(this.getCacheKey(blob.sha), bufferValue);
146
+ await this.blobCache.put(this.getCacheKey(blob.sha), bufferValue);
146
147
 
147
- return bufferValue;
148
- }
148
+ return bufferValue;
149
+ }
149
150
 
150
- public async uploadSummaryWithContext(summary: ISummaryTree, context: ISummaryContext): Promise<string> {
151
- const summaryHandle = await PerformanceEvent.timedExecAsync(
152
- this.logger,
153
- {
154
- eventName: "uploadSummaryWithContext",
155
- proposalHandle: context.proposalHandle,
156
- ackHandle: context.ackHandle,
157
- referenceSequenceNumber: context.referenceSequenceNumber,
158
- },
159
- async () => {
160
- const summaryUploadManager = await this.getSummaryUploadManager();
161
- return summaryUploadManager.writeSummaryTree(summary, context.ackHandle ?? "", "channel");
162
- },
163
- );
164
- return summaryHandle;
165
- }
151
+ public async uploadSummaryWithContext(
152
+ summary: ISummaryTree,
153
+ context: ISummaryContext,
154
+ ): Promise<string> {
155
+ const summaryHandle = await PerformanceEvent.timedExecAsync(
156
+ this.logger,
157
+ {
158
+ eventName: "uploadSummaryWithContext",
159
+ proposalHandle: context.proposalHandle,
160
+ ackHandle: context.ackHandle,
161
+ referenceSequenceNumber: context.referenceSequenceNumber,
162
+ },
163
+ async () => {
164
+ const summaryUploadManager = await this.getSummaryUploadManager();
165
+ return summaryUploadManager.writeSummaryTree(
166
+ summary,
167
+ context.ackHandle ?? "",
168
+ "channel",
169
+ );
170
+ },
171
+ );
172
+ return summaryHandle;
173
+ }
166
174
 
167
- public async downloadSummary(summaryHandle: ISummaryHandle): Promise<ISummaryTree> {
168
- const wholeFlatSummary = await PerformanceEvent.timedExecAsync(
169
- this.logger,
170
- {
171
- eventName: "getWholeFlatSummary",
172
- treeId: summaryHandle.handle,
173
- },
174
- async (event) => {
175
- const manager = await this.getStorageManager();
176
- const response = await manager.getSummary(summaryHandle.handle);
177
- event.end({
178
- size: response.trees[0]?.entries.length,
179
- });
180
- return response;
181
- },
182
- );
175
+ public async downloadSummary(summaryHandle: ISummaryHandle): Promise<ISummaryTree> {
176
+ const wholeFlatSummary = await PerformanceEvent.timedExecAsync(
177
+ this.logger,
178
+ {
179
+ eventName: "getWholeFlatSummary",
180
+ treeId: summaryHandle.handle,
181
+ },
182
+ async (event) => {
183
+ const manager = await this.getStorageManager();
184
+ const response = await manager.getSummary(summaryHandle.handle);
185
+ event.end({
186
+ size: response.trees[0]?.entries.length,
187
+ });
188
+ return response;
189
+ },
190
+ );
183
191
 
184
- const { blobs, snapshotTree } = convertWholeFlatSummaryToSnapshotTreeAndBlobs(wholeFlatSummary, "");
185
- return convertSnapshotAndBlobsToSummaryTree(snapshotTree, blobs);
186
- }
192
+ const { blobs, snapshotTree } = convertWholeFlatSummaryToSnapshotTreeAndBlobs(
193
+ wholeFlatSummary,
194
+ "",
195
+ );
196
+ return convertSnapshotAndBlobsToSummaryTree(snapshotTree, blobs);
197
+ }
187
198
 
188
- public async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {
189
- const uint8ArrayFile = new Uint8Array(file);
190
- return PerformanceEvent.timedExecAsync(
191
- this.logger,
192
- {
193
- eventName: "createBlob",
194
- size: uint8ArrayFile.length,
195
- },
196
- async (event) => {
197
- const manager = await this.getStorageManager();
198
- const response = await manager.createBlob(
199
- Uint8ArrayToString(
200
- uint8ArrayFile, "base64"),
201
- "base64").then((r) => ({ id: r.sha, url: r.url }));
202
- event.end({
203
- blobId: response.id,
204
- });
205
- return response;
206
- },
207
- );
208
- }
199
+ public async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {
200
+ const uint8ArrayFile = new Uint8Array(file);
201
+ return PerformanceEvent.timedExecAsync(
202
+ this.logger,
203
+ {
204
+ eventName: "createBlob",
205
+ size: uint8ArrayFile.length,
206
+ },
207
+ async (event) => {
208
+ const manager = await this.getStorageManager();
209
+ const response = await manager
210
+ .createBlob(Uint8ArrayToString(uint8ArrayFile, "base64"), "base64")
211
+ .then((r) => ({ id: r.sha, url: r.url }));
212
+ event.end({
213
+ blobId: response.id,
214
+ });
215
+ return response;
216
+ },
217
+ );
218
+ }
209
219
 
210
- private async fetchAndCacheSnapshotTree(versionId: string, disableCache?: boolean): Promise<ISnapshotTreeVersion> {
211
- const cachedSnapshotTreeVersion = await this.snapshotTreeCache.get(this.getCacheKey(versionId));
212
- if (cachedSnapshotTreeVersion !== undefined) {
213
- return { id: cachedSnapshotTreeVersion.id, snapshotTree: cachedSnapshotTreeVersion.snapshotTree };
214
- }
220
+ private async fetchAndCacheSnapshotTree(
221
+ versionId: string,
222
+ disableCache?: boolean,
223
+ ): Promise<ISnapshotTreeVersion> {
224
+ const cachedSnapshotTreeVersion = await this.snapshotTreeCache.get(
225
+ this.getCacheKey(versionId),
226
+ );
227
+ if (cachedSnapshotTreeVersion !== undefined) {
228
+ return {
229
+ id: cachedSnapshotTreeVersion.id,
230
+ snapshotTree: cachedSnapshotTreeVersion.snapshotTree,
231
+ };
232
+ }
215
233
 
216
- const wholeFlatSummary = await PerformanceEvent.timedExecAsync(
217
- this.logger,
218
- {
219
- eventName: "getWholeFlatSummary",
220
- treeId: versionId,
221
- },
222
- async (event) => {
223
- const manager = await this.getStorageManager(disableCache);
224
- const response = await manager.getSummary(versionId);
225
- event.end({
226
- size: response.trees[0]?.entries.length,
227
- });
228
- return response;
229
- },
230
- );
231
- const normalizedWholeSummary = convertWholeFlatSummaryToSnapshotTreeAndBlobs(wholeFlatSummary);
232
- const wholeFlatSummaryId: string = wholeFlatSummary.id;
233
- const snapshotTreeId = normalizedWholeSummary.snapshotTree.id;
234
- assert(snapshotTreeId !== undefined, 0x275 /* "Root tree should contain the id" */);
235
- const snapshotTreeVersion = { id: wholeFlatSummaryId, snapshotTree: normalizedWholeSummary.snapshotTree };
234
+ const wholeFlatSummary = await PerformanceEvent.timedExecAsync(
235
+ this.logger,
236
+ {
237
+ eventName: "getWholeFlatSummary",
238
+ treeId: versionId,
239
+ },
240
+ async (event) => {
241
+ const manager = await this.getStorageManager(disableCache);
242
+ const response = await manager.getSummary(versionId);
243
+ event.end({
244
+ size: response.trees[0]?.entries.length,
245
+ });
246
+ return response;
247
+ },
248
+ );
249
+ const normalizedWholeSummary =
250
+ convertWholeFlatSummaryToSnapshotTreeAndBlobs(wholeFlatSummary);
251
+ const wholeFlatSummaryId: string = wholeFlatSummary.id;
252
+ const snapshotTreeId = normalizedWholeSummary.snapshotTree.id;
253
+ assert(snapshotTreeId !== undefined, 0x275 /* "Root tree should contain the id" */);
254
+ const snapshotTreeVersion = {
255
+ id: wholeFlatSummaryId,
256
+ snapshotTree: normalizedWholeSummary.snapshotTree,
257
+ };
236
258
 
237
- const cachePs: Promise<any>[] = [
238
- this.snapshotTreeCache.put(
239
- this.getCacheKey(snapshotTreeId),
240
- snapshotTreeVersion,
241
- ),
242
- this.initBlobCache(normalizedWholeSummary.blobs),
243
- ];
244
- if (snapshotTreeId !== versionId) {
245
- // versionId could be "latest". When summarizer checks cache for "latest", we want it to be available.
246
- // TODO: For in-memory cache, <latest,snapshotTree> will be a shared pointer with <snapshotId,snapshotTree>,
247
- // However, for something like Redis, this will cache the same value twice. Alternatively, could we simply
248
- // cache with versionId?
249
- cachePs.push(this.snapshotTreeCache.put(
250
- this.getCacheKey(versionId),
251
- snapshotTreeVersion,
252
- ));
253
- }
259
+ const cachePs: Promise<any>[] = [
260
+ this.snapshotTreeCache.put(this.getCacheKey(snapshotTreeId), snapshotTreeVersion),
261
+ this.initBlobCache(normalizedWholeSummary.blobs),
262
+ ];
263
+ if (snapshotTreeId !== versionId) {
264
+ // versionId could be "latest". When summarizer checks cache for "latest", we want it to be available.
265
+ // TODO: For in-memory cache, <latest,snapshotTree> will be a shared pointer with <snapshotId,snapshotTree>,
266
+ // However, for something like Redis, this will cache the same value twice. Alternatively, could we simply
267
+ // cache with versionId?
268
+ cachePs.push(
269
+ this.snapshotTreeCache.put(this.getCacheKey(versionId), snapshotTreeVersion),
270
+ );
271
+ }
254
272
 
255
- await Promise.all(cachePs);
273
+ await Promise.all(cachePs);
256
274
 
257
- return snapshotTreeVersion;
258
- }
275
+ return snapshotTreeVersion;
276
+ }
259
277
 
260
- private async initBlobCache(blobs: Map<string, ArrayBuffer>): Promise<void> {
261
- const blobCachePutPs: Promise<void>[] = [];
262
- blobs.forEach((value, id) => {
263
- const cacheKey = this.getCacheKey(id);
264
- blobCachePutPs.push(this.blobCache.put(cacheKey, value));
265
- });
266
- await Promise.all(blobCachePutPs);
267
- }
278
+ private async initBlobCache(blobs: Map<string, ArrayBuffer>): Promise<void> {
279
+ const blobCachePutPs: Promise<void>[] = [];
280
+ blobs.forEach((value, id) => {
281
+ const cacheKey = this.getCacheKey(id);
282
+ blobCachePutPs.push(this.blobCache.put(cacheKey, value));
283
+ });
284
+ await Promise.all(blobCachePutPs);
285
+ }
268
286
 
269
- private getCacheKey(blobId: string): string {
270
- return `${this.id}:${blobId}`;
271
- }
287
+ private getCacheKey(blobId: string): string {
288
+ return `${this.id}:${blobId}`;
289
+ }
272
290
  }
@@ -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,15 +1,11 @@
1
1
  {
2
- "extends": "@fluidframework/build-common/ts-common-config.json",
3
- "exclude": [
4
- "src/test/**/*"
5
- ],
6
- "compilerOptions": {
7
- "rootDir": "./src",
8
- "outDir": "./dist",
9
- "composite": true,
10
- "types": ["node"]
11
- },
12
- "include": [
13
- "src/**/*"
14
- ]
2
+ "extends": "@fluidframework/build-common/ts-common-config.json",
3
+ "exclude": ["src/test/**/*"],
4
+ "compilerOptions": {
5
+ "rootDir": "./src",
6
+ "outDir": "./dist",
7
+ "composite": true,
8
+ "types": ["node"],
9
+ },
10
+ "include": ["src/**/*"],
15
11
  }