@fluidframework/odsp-driver 2.0.0-internal.2.2.1 → 2.0.0-internal.2.3.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 (149) hide show
  1. package/.eslintrc.js +1 -1
  2. package/dist/WriteBufferUtils.d.ts.map +1 -1
  3. package/dist/WriteBufferUtils.js +0 -1
  4. package/dist/WriteBufferUtils.js.map +1 -1
  5. package/dist/contractsPublic.d.ts.map +1 -1
  6. package/dist/contractsPublic.js.map +1 -1
  7. package/dist/createFile.d.ts +2 -6
  8. package/dist/createFile.d.ts.map +1 -1
  9. package/dist/createFile.js +13 -125
  10. package/dist/createFile.js.map +1 -1
  11. package/dist/createNewUtils.d.ts +16 -0
  12. package/dist/createNewUtils.d.ts.map +1 -1
  13. package/dist/createNewUtils.js +131 -1
  14. package/dist/createNewUtils.js.map +1 -1
  15. package/dist/fetchSnapshot.js +1 -1
  16. package/dist/fetchSnapshot.js.map +1 -1
  17. package/dist/localOdspDriver/localOdspDocumentServiceFactory.d.ts.map +1 -1
  18. package/dist/localOdspDriver/localOdspDocumentServiceFactory.js +1 -1
  19. package/dist/localOdspDriver/localOdspDocumentServiceFactory.js.map +1 -1
  20. package/dist/odspDelayLoadedDeltaStream.d.ts +75 -0
  21. package/dist/odspDelayLoadedDeltaStream.d.ts.map +1 -0
  22. package/dist/odspDelayLoadedDeltaStream.js +259 -0
  23. package/dist/odspDelayLoadedDeltaStream.js.map +1 -0
  24. package/dist/odspDocumentDeltaConnection.d.ts +1 -3
  25. package/dist/odspDocumentDeltaConnection.d.ts.map +1 -1
  26. package/dist/odspDocumentDeltaConnection.js +6 -6
  27. package/dist/odspDocumentDeltaConnection.js.map +1 -1
  28. package/dist/odspDocumentService.d.ts +10 -25
  29. package/dist/odspDocumentService.d.ts.map +1 -1
  30. package/dist/odspDocumentService.js +71 -204
  31. package/dist/odspDocumentService.js.map +1 -1
  32. package/dist/odspDocumentServiceFactory.d.ts.map +1 -1
  33. package/dist/odspDocumentServiceFactory.js +1 -2
  34. package/dist/odspDocumentServiceFactory.js.map +1 -1
  35. package/dist/odspDocumentServiceFactoryCore.d.ts +1 -3
  36. package/dist/odspDocumentServiceFactoryCore.d.ts.map +1 -1
  37. package/dist/odspDocumentServiceFactoryCore.js +3 -3
  38. package/dist/odspDocumentServiceFactoryCore.js.map +1 -1
  39. package/dist/odspDocumentServiceFactoryWithCodeSplit.d.ts +4 -0
  40. package/dist/odspDocumentServiceFactoryWithCodeSplit.d.ts.map +1 -1
  41. package/dist/odspDocumentServiceFactoryWithCodeSplit.js +5 -20
  42. package/dist/odspDocumentServiceFactoryWithCodeSplit.js.map +1 -1
  43. package/dist/odspDocumentStorageManager.d.ts.map +1 -1
  44. package/dist/odspDocumentStorageManager.js +0 -2
  45. package/dist/odspDocumentStorageManager.js.map +1 -1
  46. package/dist/odspDocumentStorageServiceBase.d.ts.map +1 -1
  47. package/dist/odspDocumentStorageServiceBase.js +0 -2
  48. package/dist/odspDocumentStorageServiceBase.js.map +1 -1
  49. package/dist/odspSummaryUploadManager.d.ts.map +1 -1
  50. package/dist/odspSummaryUploadManager.js +0 -2
  51. package/dist/odspSummaryUploadManager.js.map +1 -1
  52. package/dist/odspUtils.d.ts +10 -1
  53. package/dist/odspUtils.d.ts.map +1 -1
  54. package/dist/odspUtils.js +5 -1
  55. package/dist/odspUtils.js.map +1 -1
  56. package/dist/packageVersion.d.ts +1 -1
  57. package/dist/packageVersion.js +1 -1
  58. package/dist/packageVersion.js.map +1 -1
  59. package/dist/zipItDataRepresentationUtils.d.ts.map +1 -1
  60. package/dist/zipItDataRepresentationUtils.js +0 -1
  61. package/dist/zipItDataRepresentationUtils.js.map +1 -1
  62. package/lib/WriteBufferUtils.d.ts.map +1 -1
  63. package/lib/WriteBufferUtils.js +0 -1
  64. package/lib/WriteBufferUtils.js.map +1 -1
  65. package/lib/contractsPublic.d.ts.map +1 -1
  66. package/lib/contractsPublic.js.map +1 -1
  67. package/lib/createFile.d.ts +2 -6
  68. package/lib/createFile.d.ts.map +1 -1
  69. package/lib/createFile.js +15 -126
  70. package/lib/createFile.js.map +1 -1
  71. package/lib/createNewUtils.d.ts +16 -0
  72. package/lib/createNewUtils.d.ts.map +1 -1
  73. package/lib/createNewUtils.js +129 -1
  74. package/lib/createNewUtils.js.map +1 -1
  75. package/lib/fetchSnapshot.js +1 -1
  76. package/lib/fetchSnapshot.js.map +1 -1
  77. package/lib/localOdspDriver/localOdspDocumentServiceFactory.d.ts.map +1 -1
  78. package/lib/localOdspDriver/localOdspDocumentServiceFactory.js +1 -1
  79. package/lib/localOdspDriver/localOdspDocumentServiceFactory.js.map +1 -1
  80. package/lib/odspDelayLoadedDeltaStream.d.ts +75 -0
  81. package/lib/odspDelayLoadedDeltaStream.d.ts.map +1 -0
  82. package/lib/odspDelayLoadedDeltaStream.js +255 -0
  83. package/lib/odspDelayLoadedDeltaStream.js.map +1 -0
  84. package/lib/odspDocumentDeltaConnection.d.ts +1 -3
  85. package/lib/odspDocumentDeltaConnection.d.ts.map +1 -1
  86. package/lib/odspDocumentDeltaConnection.js +6 -6
  87. package/lib/odspDocumentDeltaConnection.js.map +1 -1
  88. package/lib/odspDocumentService.d.ts +10 -25
  89. package/lib/odspDocumentService.d.ts.map +1 -1
  90. package/lib/odspDocumentService.js +56 -207
  91. package/lib/odspDocumentService.js.map +1 -1
  92. package/lib/odspDocumentServiceFactory.d.ts.map +1 -1
  93. package/lib/odspDocumentServiceFactory.js +1 -2
  94. package/lib/odspDocumentServiceFactory.js.map +1 -1
  95. package/lib/odspDocumentServiceFactoryCore.d.ts +1 -3
  96. package/lib/odspDocumentServiceFactoryCore.d.ts.map +1 -1
  97. package/lib/odspDocumentServiceFactoryCore.js +3 -3
  98. package/lib/odspDocumentServiceFactoryCore.js.map +1 -1
  99. package/lib/odspDocumentServiceFactoryWithCodeSplit.d.ts +4 -0
  100. package/lib/odspDocumentServiceFactoryWithCodeSplit.d.ts.map +1 -1
  101. package/lib/odspDocumentServiceFactoryWithCodeSplit.js +5 -1
  102. package/lib/odspDocumentServiceFactoryWithCodeSplit.js.map +1 -1
  103. package/lib/odspDocumentStorageManager.d.ts.map +1 -1
  104. package/lib/odspDocumentStorageManager.js +0 -2
  105. package/lib/odspDocumentStorageManager.js.map +1 -1
  106. package/lib/odspDocumentStorageServiceBase.d.ts.map +1 -1
  107. package/lib/odspDocumentStorageServiceBase.js +0 -2
  108. package/lib/odspDocumentStorageServiceBase.js.map +1 -1
  109. package/lib/odspSummaryUploadManager.d.ts.map +1 -1
  110. package/lib/odspSummaryUploadManager.js +0 -2
  111. package/lib/odspSummaryUploadManager.js.map +1 -1
  112. package/lib/odspUtils.d.ts +10 -1
  113. package/lib/odspUtils.d.ts.map +1 -1
  114. package/lib/odspUtils.js +3 -0
  115. package/lib/odspUtils.js.map +1 -1
  116. package/lib/packageVersion.d.ts +1 -1
  117. package/lib/packageVersion.js +1 -1
  118. package/lib/packageVersion.js.map +1 -1
  119. package/lib/zipItDataRepresentationUtils.d.ts.map +1 -1
  120. package/lib/zipItDataRepresentationUtils.js +0 -1
  121. package/lib/zipItDataRepresentationUtils.js.map +1 -1
  122. package/package.json +13 -12
  123. package/src/WriteBufferUtils.ts +0 -1
  124. package/src/contractsPublic.ts +0 -1
  125. package/src/createFile.ts +23 -168
  126. package/src/createNewUtils.ts +188 -2
  127. package/src/fetchSnapshot.ts +1 -1
  128. package/src/localOdspDriver/localOdspDocumentServiceFactory.ts +0 -1
  129. package/src/odspDelayLoadedDeltaStream.ts +359 -0
  130. package/src/odspDocumentDeltaConnection.ts +4 -7
  131. package/src/odspDocumentService.ts +63 -283
  132. package/src/odspDocumentServiceFactory.ts +0 -2
  133. package/src/odspDocumentServiceFactoryCore.ts +1 -3
  134. package/src/odspDocumentServiceFactoryWithCodeSplit.ts +4 -1
  135. package/src/odspDocumentStorageManager.ts +0 -4
  136. package/src/odspDocumentStorageServiceBase.ts +0 -3
  137. package/src/odspSummaryUploadManager.ts +0 -4
  138. package/src/odspUtils.ts +16 -1
  139. package/src/packageVersion.ts +1 -1
  140. package/src/zipItDataRepresentationUtils.ts +0 -1
  141. package/dist/getSocketIo.d.ts +0 -11
  142. package/dist/getSocketIo.d.ts.map +0 -1
  143. package/dist/getSocketIo.js +0 -20
  144. package/dist/getSocketIo.js.map +0 -1
  145. package/lib/getSocketIo.d.ts +0 -11
  146. package/lib/getSocketIo.d.ts.map +0 -1
  147. package/lib/getSocketIo.js +0 -13
  148. package/lib/getSocketIo.js.map +0 -1
  149. package/src/getSocketIo.ts +0 -14
package/src/createFile.ts CHANGED
@@ -3,29 +3,23 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { v4 as uuid } from "uuid";
7
- import { assert, Uint8ArrayToString } from "@fluidframework/common-utils";
8
- import { getDocAttributesFromProtocolSummary, NonRetryableError } from "@fluidframework/driver-utils";
9
- import { getGitType } from "@fluidframework/protocol-base";
10
- import { SummaryType, ISummaryTree, ISummaryBlob } from "@fluidframework/protocol-definitions";
6
+ import { assert } from "@fluidframework/common-utils";
7
+ import { NonRetryableError } from "@fluidframework/driver-utils";
8
+ import { ISummaryTree } from "@fluidframework/protocol-definitions";
11
9
  import { ITelemetryLogger } from "@fluidframework/common-definitions";
12
10
  import { PerformanceEvent } from "@fluidframework/telemetry-utils";
13
11
  import {
14
- IFileEntry,
15
12
  InstrumentedStorageTokenFetcher,
16
13
  IOdspResolvedUrl,
17
14
  OdspErrorType,
18
15
  ShareLinkInfoType,
19
16
  ISharingLinkKind,
20
17
  ShareLinkTypes,
18
+ IFileEntry,
21
19
  } from "@fluidframework/odsp-driver-definitions";
22
20
  import { DriverErrorType } from "@fluidframework/driver-definitions";
23
21
  import {
24
- IOdspSummaryTree,
25
- OdspSummaryTreeValue,
26
- OdspSummaryTreeEntry,
27
22
  ICreateFileResponse,
28
- IOdspSummaryPayload,
29
23
  } from "./contracts";
30
24
  import { getUrlAndHeadersWithAuth } from "./getUrlAndHeadersWithAuth";
31
25
  import {
@@ -33,15 +27,14 @@ import {
33
27
  createCacheSnapshotKey,
34
28
  getWithRetryForTokenRefresh,
35
29
  INewFileInfo,
36
- getOrigin,
37
- maxUmpPostBodySize,
30
+ getOrigin
38
31
  } from "./odspUtils";
39
32
  import { ISnapshotContents } from "./odspPublicUtils";
40
33
  import { createOdspUrl } from "./createOdspUrl";
41
34
  import { getApiRoot } from "./odspUrlHelper";
42
35
  import { EpochTracker } from "./epochTracker";
43
36
  import { OdspDriverUrlResolver } from "./odspDriverUrlResolver";
44
- import { convertCreateNewSummaryTreeToTreeAndBlobs } from "./createNewUtils";
37
+ import { convertCreateNewSummaryTreeToTreeAndBlobs, convertSummaryIntoContainerSnapshot, createNewFluidContainerCore } from "./createNewUtils";
45
38
  import { runWithRetry } from "./retryUtils";
46
39
  import { pkgVersion as driverVersion } from "./packageVersion";
47
40
  import { ClpCompliantAppHeader } from "./contractsPublic";
@@ -66,7 +59,7 @@ export async function createNewFluidFile(
66
59
  forceAccessTokenViaAuthorizationHeader: boolean,
67
60
  isClpCompliantApp?: boolean,
68
61
  enableSingleRequestForShareLinkWithCreate?: boolean,
69
- enableShareLinkWithCreate?: boolean,
62
+ enableShareLinkWithCreate?: boolean
70
63
  ): Promise<IOdspResolvedUrl> {
71
64
  // Check for valid filename before the request to create file is actually made.
72
65
  if (isInvalidFileName(newFileInfo.filename)) {
@@ -255,160 +248,22 @@ export async function createNewFluidFileFromSummary(
255
248
  const initialUrl =
256
249
  `${baseUrl}:/opStream/snapshots/snapshot${createShareLinkParam ? `?${createShareLinkParam}` : ""}`;
257
250
 
258
- return getWithRetryForTokenRefresh(async (options) => {
259
- const storageToken = await getStorageToken(options, "CreateNewFile");
260
-
261
- return PerformanceEvent.timedExecAsync(
262
- logger,
263
- { eventName: "createNewFile" },
264
- async (event) => {
265
- const snapshotBody = JSON.stringify(containerSnapshot);
266
- let url: string;
267
- let headers: { [index: string]: string; };
268
- let addInBody = false;
269
- const formBoundary = uuid();
270
- let postBody = `--${formBoundary}\r\n`;
271
- postBody += `Authorization: Bearer ${storageToken}\r\n`;
272
- postBody += `X-HTTP-Method-Override: POST\r\n`;
273
- postBody += `Content-Type: application/json\r\n`;
274
- postBody += `_post: 1\r\n`;
275
- postBody += `\r\n${snapshotBody}\r\n`;
276
- postBody += `\r\n--${formBoundary}--`;
277
-
278
- if (postBody.length <= maxUmpPostBodySize) {
279
- const urlObj = new URL(initialUrl);
280
- urlObj.searchParams.set("ump", "1");
281
- url = urlObj.href;
282
- headers = {
283
- "Content-Type": `multipart/form-data;boundary=${formBoundary}`,
284
- };
285
- addInBody = true;
286
- } else {
287
- const parts = getUrlAndHeadersWithAuth(
288
- initialUrl, storageToken, forceAccessTokenViaAuthorizationHeader);
289
- url = parts.url;
290
- headers = {
291
- ...parts.headers,
292
- "Content-Type": "application/json",
293
- };
294
- postBody = snapshotBody;
295
- }
296
-
297
- const fetchResponse = await runWithRetry(
298
- async () => epochTracker.fetchAndParseAsJSON<ICreateFileResponse>(
299
- url,
300
- {
301
- body: postBody,
302
- headers,
303
- method: "POST",
304
- },
305
- "createFile",
306
- addInBody,
307
- ),
308
- "createFile",
309
- logger,
310
- );
311
-
312
- const content = fetchResponse.content;
313
- if (!content || !content.itemId) {
314
- throw new NonRetryableError(
315
- "ODSP CreateFile call returned no item ID",
316
- DriverErrorType.incorrectServerResponse,
317
- { driverVersion });
318
- }
319
- event.end({
320
- headers: Object.keys(headers).length !== 0 ? true : undefined,
321
- attempts: options.refresh ? 2 : 1,
322
- ...fetchResponse.propsToLog,
323
- });
324
- return content;
325
- },
326
- );
327
- });
328
- }
329
-
330
- function convertSummaryIntoContainerSnapshot(createNewSummary: ISummaryTree) {
331
- const appSummary = createNewSummary.tree[".app"] as ISummaryTree;
332
- const protocolSummary = createNewSummary.tree[".protocol"] as ISummaryTree;
333
- if (!(appSummary && protocolSummary)) {
334
- throw new Error("App and protocol summary required for create new path!!");
335
- }
336
- const documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);
337
- const attributesSummaryBlob: ISummaryBlob = {
338
- type: SummaryType.Blob,
339
- content: JSON.stringify(documentAttributes),
340
- };
341
- protocolSummary.tree.attributes = attributesSummaryBlob;
342
- const convertedCreateNewSummary: ISummaryTree = {
343
- type: SummaryType.Tree,
344
- tree: {
345
- ".protocol": protocolSummary,
346
- ".app": appSummary,
347
- },
348
- };
349
- const snapshotTree = convertSummaryToSnapshotTreeForCreateNew(convertedCreateNewSummary);
350
- const snapshot: IOdspSummaryPayload = {
351
- entries: snapshotTree.entries ?? [],
352
- message: "app",
353
- sequenceNumber: documentAttributes.sequenceNumber,
354
- type: "container",
355
- };
356
- return snapshot;
357
- }
358
-
359
- /**
360
- * Converts a summary tree to ODSP tree
361
- */
362
- export function convertSummaryToSnapshotTreeForCreateNew(summary: ISummaryTree): IOdspSummaryTree {
363
- const snapshotTree: IOdspSummaryTree = {
364
- type: "tree",
365
- entries: [],
366
- };
367
-
368
- const keys = Object.keys(summary.tree);
369
- for (const key of keys) {
370
- const summaryObject = summary.tree[key];
371
-
372
- let value: OdspSummaryTreeValue;
373
- // Tracks if an entry is unreferenced. Currently, only tree entries can be marked as unreferenced. If the
374
- // property is not present, the tree entry is considered referenced. If the property is present and is true,
375
- // the tree entry is considered unreferenced.
376
- let unreferenced: true | undefined;
377
-
378
- switch (summaryObject.type) {
379
- case SummaryType.Tree: {
380
- value = convertSummaryToSnapshotTreeForCreateNew(summaryObject);
381
- unreferenced = summaryObject.unreferenced;
382
- break;
383
- }
384
- case SummaryType.Blob: {
385
- const content = typeof summaryObject.content === "string" ?
386
- summaryObject.content : Uint8ArrayToString(summaryObject.content, "base64");
387
- const encoding = typeof summaryObject.content === "string" ? "utf-8" : "base64";
388
-
389
- value = {
390
- type: "blob",
391
- content,
392
- encoding,
393
- };
394
- break;
395
- }
396
- case SummaryType.Handle: {
397
- throw new Error("No handle should be present for first summary!!");
398
- }
399
- default: {
400
- throw new Error(`Unknown tree type ${summaryObject.type}`);
251
+ return createNewFluidContainerCore<ICreateFileResponse>({
252
+ containerSnapshot,
253
+ getStorageToken,
254
+ logger,
255
+ initialUrl,
256
+ forceAccessTokenViaAuthorizationHeader,
257
+ epochTracker,
258
+ telemetryName: "CreateNewFile",
259
+ fetchType: "createFile",
260
+ validateResponseCallback: content => {
261
+ if (!content || !content.itemId) {
262
+ throw new NonRetryableError(
263
+ "ODSP CreateFile call returned no item ID",
264
+ DriverErrorType.incorrectServerResponse,
265
+ { driverVersion });
401
266
  }
402
267
  }
403
-
404
- const entry: OdspSummaryTreeEntry = {
405
- path: encodeURIComponent(key),
406
- type: getGitType(summaryObject),
407
- value,
408
- unreferenced,
409
- };
410
- snapshotTree.entries?.push(entry);
411
- }
412
-
413
- return snapshotTree;
268
+ });
414
269
  }
@@ -4,10 +4,19 @@
4
4
  */
5
5
 
6
6
  import { v4 as uuid } from "uuid";
7
- import { ISummaryTree, SummaryType, ISnapshotTree } from "@fluidframework/protocol-definitions";
7
+ import { ISummaryBlob, ISummaryTree, SummaryType, ISnapshotTree } from "@fluidframework/protocol-definitions";
8
8
  import { getDocAttributesFromProtocolSummary } from "@fluidframework/driver-utils";
9
- import { stringToBuffer, unreachableCase } from "@fluidframework/common-utils";
9
+ import { stringToBuffer, Uint8ArrayToString, unreachableCase } from "@fluidframework/common-utils";
10
+ import { getGitType } from "@fluidframework/protocol-base";
11
+ import { ITelemetryLogger } from "@fluidframework/common-definitions";
12
+ import { InstrumentedStorageTokenFetcher } from "@fluidframework/odsp-driver-definitions";
13
+ import { PerformanceEvent } from "@fluidframework/telemetry-utils";
14
+ import { IOdspSummaryPayload, IOdspSummaryTree, OdspSummaryTreeEntry, OdspSummaryTreeValue } from "./contracts";
15
+ import { getWithRetryForTokenRefresh, maxUmpPostBodySize } from "./odspUtils";
10
16
  import { ISnapshotContents } from "./odspPublicUtils";
17
+ import { EpochTracker, FetchType } from "./epochTracker";
18
+ import { getUrlAndHeadersWithAuth } from "./getUrlAndHeadersWithAuth";
19
+ import { runWithRetry } from "./retryUtils";
11
20
 
12
21
  /**
13
22
  * Converts a summary(ISummaryTree) taken in detached container to snapshot tree and blobs
@@ -68,3 +77,180 @@ function convertCreateNewSummaryTreeToTreeAndBlobsCore(
68
77
  }
69
78
  return treeNode;
70
79
  }
80
+
81
+ export function convertSummaryIntoContainerSnapshot(createNewSummary: ISummaryTree) {
82
+ const appSummary = createNewSummary.tree[".app"] as ISummaryTree;
83
+ const protocolSummary = createNewSummary.tree[".protocol"] as ISummaryTree;
84
+ if (!(appSummary && protocolSummary)) {
85
+ throw new Error("App and protocol summary required for create new path!!");
86
+ }
87
+ const documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);
88
+ const attributesSummaryBlob: ISummaryBlob = {
89
+ type: SummaryType.Blob,
90
+ content: JSON.stringify(documentAttributes),
91
+ };
92
+ protocolSummary.tree.attributes = attributesSummaryBlob;
93
+ const convertedCreateNewSummary: ISummaryTree = {
94
+ type: SummaryType.Tree,
95
+ tree: {
96
+ ".protocol": protocolSummary,
97
+ ".app": appSummary,
98
+ },
99
+ };
100
+ const snapshotTree = convertSummaryToSnapshotTreeForCreateNew(convertedCreateNewSummary);
101
+ const snapshot: IOdspSummaryPayload = {
102
+ entries: snapshotTree.entries ?? [],
103
+ message: "app",
104
+ sequenceNumber: documentAttributes.sequenceNumber,
105
+ type: "container",
106
+ };
107
+ return snapshot;
108
+ }
109
+
110
+ /**
111
+ * Converts a summary tree to ODSP tree
112
+ */
113
+ function convertSummaryToSnapshotTreeForCreateNew(summary: ISummaryTree): IOdspSummaryTree {
114
+ const snapshotTree: IOdspSummaryTree = {
115
+ type: "tree",
116
+ entries: [],
117
+ };
118
+
119
+ const keys = Object.keys(summary.tree);
120
+ for (const key of keys) {
121
+ const summaryObject = summary.tree[key];
122
+
123
+ let value: OdspSummaryTreeValue;
124
+ // Tracks if an entry is unreferenced. Currently, only tree entries can be marked as unreferenced. If the
125
+ // property is not present, the tree entry is considered referenced. If the property is present and is true,
126
+ // the tree entry is considered unreferenced.
127
+ let unreferenced: true | undefined;
128
+
129
+ switch (summaryObject.type) {
130
+ case SummaryType.Tree: {
131
+ value = convertSummaryToSnapshotTreeForCreateNew(summaryObject);
132
+ unreferenced = summaryObject.unreferenced;
133
+ break;
134
+ }
135
+ case SummaryType.Blob: {
136
+ const content = typeof summaryObject.content === "string" ?
137
+ summaryObject.content : Uint8ArrayToString(summaryObject.content, "base64");
138
+ const encoding = typeof summaryObject.content === "string" ? "utf-8" : "base64";
139
+
140
+ value = {
141
+ type: "blob",
142
+ content,
143
+ encoding,
144
+ };
145
+ break;
146
+ }
147
+ case SummaryType.Handle: {
148
+ throw new Error("No handle should be present for first summary!!");
149
+ }
150
+ default: {
151
+ throw new Error(`Unknown tree type ${summaryObject.type}`);
152
+ }
153
+ }
154
+
155
+ const entry: OdspSummaryTreeEntry = {
156
+ path: encodeURIComponent(key),
157
+ type: getGitType(summaryObject),
158
+ value,
159
+ unreferenced,
160
+ };
161
+ snapshotTree.entries?.push(entry);
162
+ }
163
+
164
+ return snapshotTree;
165
+ }
166
+
167
+ export async function createNewFluidContainerCore<T>(args: {
168
+ containerSnapshot: IOdspSummaryPayload;
169
+ getStorageToken: InstrumentedStorageTokenFetcher;
170
+ logger: ITelemetryLogger;
171
+ initialUrl: string;
172
+ forceAccessTokenViaAuthorizationHeader: boolean;
173
+ epochTracker: EpochTracker;
174
+ telemetryName: string;
175
+ fetchType: FetchType;
176
+ validateResponseCallback?: (content: T) => void;
177
+ }): Promise<T> {
178
+ const {
179
+ containerSnapshot,
180
+ getStorageToken,
181
+ logger,
182
+ initialUrl,
183
+ forceAccessTokenViaAuthorizationHeader,
184
+ epochTracker,
185
+ telemetryName,
186
+ fetchType,
187
+ validateResponseCallback
188
+ } = args;
189
+
190
+ return getWithRetryForTokenRefresh(async (options) => {
191
+ const storageToken = await getStorageToken(options, telemetryName);
192
+
193
+ return PerformanceEvent.timedExecAsync(
194
+ logger,
195
+ { eventName: telemetryName },
196
+ async (event) => {
197
+ const snapshotBody = JSON.stringify(containerSnapshot);
198
+ let url: string;
199
+ let headers: { [index: string]: string; };
200
+ let addInBody = false;
201
+ const formBoundary = uuid();
202
+ let postBody = `--${formBoundary}\r\n`;
203
+ postBody += `Authorization: Bearer ${storageToken}\r\n`;
204
+ postBody += `X-HTTP-Method-Override: POST\r\n`;
205
+ postBody += `Content-Type: application/json\r\n`;
206
+ postBody += `_post: 1\r\n`;
207
+ postBody += `\r\n${snapshotBody}\r\n`;
208
+ postBody += `\r\n--${formBoundary}--`;
209
+
210
+ if (postBody.length <= maxUmpPostBodySize) {
211
+ const urlObj = new URL(initialUrl);
212
+ urlObj.searchParams.set("ump", "1");
213
+ url = urlObj.href;
214
+ headers = {
215
+ "Content-Type": `multipart/form-data;boundary=${formBoundary}`,
216
+ };
217
+ addInBody = true;
218
+ } else {
219
+ const parts = getUrlAndHeadersWithAuth(
220
+ initialUrl, storageToken, forceAccessTokenViaAuthorizationHeader);
221
+ url = parts.url;
222
+ headers = {
223
+ ...parts.headers,
224
+ "Content-Type": "application/json",
225
+ };
226
+ postBody = snapshotBody;
227
+ }
228
+
229
+ const fetchResponse = await runWithRetry(
230
+ async () => epochTracker.fetchAndParseAsJSON<T>(
231
+ url,
232
+ {
233
+ body: postBody,
234
+ headers,
235
+ method: "POST",
236
+ },
237
+ fetchType,
238
+ addInBody,
239
+ ),
240
+ telemetryName,
241
+ logger,
242
+ );
243
+
244
+ validateResponseCallback?.(fetchResponse.content);
245
+
246
+ event.end({
247
+ headers: Object.keys(headers).length !== 0 ? true : undefined,
248
+ attempts: options.refresh ? 2 : 1,
249
+ ...fetchResponse.propsToLog,
250
+ });
251
+
252
+ return fetchResponse.content;
253
+ },
254
+ );
255
+ });
256
+ }
@@ -370,7 +370,7 @@ async function fetchLatestSnapshotCore(
370
370
  // Usually the latest fetch call is to the end of resources, so we start from the end.
371
371
  for (let i = resources1.length - 1; i > 0; i--) {
372
372
  const indResTime = resources1[i] as PerformanceResourceTiming;
373
- const resource_name = indResTime.name;
373
+ const resource_name = indResTime.name.toString();
374
374
  const resource_initiatortype = indResTime.initiatorType;
375
375
  if ((resource_initiatortype.localeCompare("fetch") === 0)
376
376
  && (resource_name.localeCompare(response.requestUrl) === 0)) {
@@ -27,7 +27,6 @@ export class LocalOdspDocumentServiceFactory extends OdspDocumentServiceFactoryC
27
27
  super(
28
28
  (_options) => this.throwUnsupportedUsageError("Getting storage token"),
29
29
  (_options) => this.throwUnsupportedUsageError("Getting websocket token"),
30
- () => this.throwUnsupportedUsageError("Getting SocketIO Client"),
31
30
  );
32
31
  }
33
32