@fluidframework/routerlicious-driver 2.0.0-internal.4.0.5 → 2.0.0-internal.4.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 (139) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/README.md +38 -0
  3. package/dist/deltaStorageService.d.ts +1 -1
  4. package/dist/deltaStorageService.d.ts.map +1 -1
  5. package/dist/deltaStorageService.js +7 -4
  6. package/dist/deltaStorageService.js.map +1 -1
  7. package/dist/documentService.d.ts.map +1 -1
  8. package/dist/documentService.js +6 -5
  9. package/dist/documentService.js.map +1 -1
  10. package/dist/documentServiceFactory.d.ts.map +1 -1
  11. package/dist/documentServiceFactory.js +7 -4
  12. package/dist/documentServiceFactory.js.map +1 -1
  13. package/dist/documentStorageService.d.ts +1 -1
  14. package/dist/documentStorageService.d.ts.map +1 -1
  15. package/dist/documentStorageService.js.map +1 -1
  16. package/dist/gitManager.d.ts +30 -0
  17. package/dist/gitManager.d.ts.map +1 -0
  18. package/dist/gitManager.js +89 -0
  19. package/dist/gitManager.js.map +1 -0
  20. package/dist/historian.d.ts +33 -0
  21. package/dist/historian.d.ts.map +1 -0
  22. package/dist/historian.js +65 -0
  23. package/dist/historian.js.map +1 -0
  24. package/dist/packageVersion.d.ts +1 -1
  25. package/dist/packageVersion.js +1 -1
  26. package/dist/packageVersion.js.map +1 -1
  27. package/dist/restWrapper.d.ts +19 -6
  28. package/dist/restWrapper.d.ts.map +1 -1
  29. package/dist/restWrapper.js +74 -10
  30. package/dist/restWrapper.js.map +1 -1
  31. package/dist/restWrapperBase.d.ts +26 -0
  32. package/dist/restWrapperBase.d.ts.map +1 -0
  33. package/dist/restWrapperBase.js +55 -0
  34. package/dist/restWrapperBase.js.map +1 -0
  35. package/dist/retriableGitManager.d.ts +10 -21
  36. package/dist/retriableGitManager.d.ts.map +1 -1
  37. package/dist/retriableGitManager.js +0 -36
  38. package/dist/retriableGitManager.js.map +1 -1
  39. package/dist/shreddedSummaryDocumentStorageService.d.ts +1 -1
  40. package/dist/shreddedSummaryDocumentStorageService.d.ts.map +1 -1
  41. package/dist/shreddedSummaryDocumentStorageService.js +6 -6
  42. package/dist/shreddedSummaryDocumentStorageService.js.map +1 -1
  43. package/dist/storageContracts.d.ts +44 -0
  44. package/dist/storageContracts.d.ts.map +1 -0
  45. package/dist/storageContracts.js +7 -0
  46. package/dist/storageContracts.js.map +1 -0
  47. package/dist/summaryTreeUploadManager.d.ts +23 -0
  48. package/dist/summaryTreeUploadManager.d.ts.map +1 -0
  49. package/dist/summaryTreeUploadManager.js +110 -0
  50. package/dist/summaryTreeUploadManager.js.map +1 -0
  51. package/dist/treeUtils.d.ts +7 -0
  52. package/dist/treeUtils.d.ts.map +1 -1
  53. package/dist/treeUtils.js +23 -1
  54. package/dist/treeUtils.js.map +1 -1
  55. package/dist/wholeSummaryDocumentStorageService.d.ts +1 -1
  56. package/dist/wholeSummaryDocumentStorageService.d.ts.map +1 -1
  57. package/dist/wholeSummaryDocumentStorageService.js +17 -13
  58. package/dist/wholeSummaryDocumentStorageService.js.map +1 -1
  59. package/dist/wholeSummaryUploadManager.d.ts +16 -0
  60. package/dist/wholeSummaryUploadManager.d.ts.map +1 -0
  61. package/dist/wholeSummaryUploadManager.js +38 -0
  62. package/dist/wholeSummaryUploadManager.js.map +1 -0
  63. package/lib/deltaStorageService.d.ts +1 -1
  64. package/lib/deltaStorageService.d.ts.map +1 -1
  65. package/lib/deltaStorageService.js +7 -4
  66. package/lib/deltaStorageService.js.map +1 -1
  67. package/lib/documentService.d.ts.map +1 -1
  68. package/lib/documentService.js +4 -3
  69. package/lib/documentService.js.map +1 -1
  70. package/lib/documentServiceFactory.d.ts.map +1 -1
  71. package/lib/documentServiceFactory.js +7 -4
  72. package/lib/documentServiceFactory.js.map +1 -1
  73. package/lib/documentStorageService.d.ts +1 -1
  74. package/lib/documentStorageService.d.ts.map +1 -1
  75. package/lib/documentStorageService.js.map +1 -1
  76. package/lib/gitManager.d.ts +30 -0
  77. package/lib/gitManager.d.ts.map +1 -0
  78. package/lib/gitManager.js +85 -0
  79. package/lib/gitManager.js.map +1 -0
  80. package/lib/historian.d.ts +33 -0
  81. package/lib/historian.d.ts.map +1 -0
  82. package/lib/historian.js +60 -0
  83. package/lib/historian.js.map +1 -0
  84. package/lib/packageVersion.d.ts +1 -1
  85. package/lib/packageVersion.js +1 -1
  86. package/lib/packageVersion.js.map +1 -1
  87. package/lib/restWrapper.d.ts +19 -6
  88. package/lib/restWrapper.d.ts.map +1 -1
  89. package/lib/restWrapper.js +73 -11
  90. package/lib/restWrapper.js.map +1 -1
  91. package/lib/restWrapperBase.d.ts +26 -0
  92. package/lib/restWrapperBase.d.ts.map +1 -0
  93. package/lib/restWrapperBase.js +50 -0
  94. package/lib/restWrapperBase.js.map +1 -0
  95. package/lib/retriableGitManager.d.ts +10 -21
  96. package/lib/retriableGitManager.d.ts.map +1 -1
  97. package/lib/retriableGitManager.js +0 -36
  98. package/lib/retriableGitManager.js.map +1 -1
  99. package/lib/shreddedSummaryDocumentStorageService.d.ts +1 -1
  100. package/lib/shreddedSummaryDocumentStorageService.d.ts.map +1 -1
  101. package/lib/shreddedSummaryDocumentStorageService.js +5 -5
  102. package/lib/shreddedSummaryDocumentStorageService.js.map +1 -1
  103. package/lib/storageContracts.d.ts +44 -0
  104. package/lib/storageContracts.d.ts.map +1 -0
  105. package/lib/storageContracts.js +6 -0
  106. package/lib/storageContracts.js.map +1 -0
  107. package/lib/summaryTreeUploadManager.d.ts +23 -0
  108. package/lib/summaryTreeUploadManager.d.ts.map +1 -0
  109. package/lib/summaryTreeUploadManager.js +106 -0
  110. package/lib/summaryTreeUploadManager.js.map +1 -0
  111. package/lib/treeUtils.d.ts +7 -0
  112. package/lib/treeUtils.d.ts.map +1 -1
  113. package/lib/treeUtils.js +20 -0
  114. package/lib/treeUtils.js.map +1 -1
  115. package/lib/wholeSummaryDocumentStorageService.d.ts +1 -1
  116. package/lib/wholeSummaryDocumentStorageService.d.ts.map +1 -1
  117. package/lib/wholeSummaryDocumentStorageService.js +19 -15
  118. package/lib/wholeSummaryDocumentStorageService.js.map +1 -1
  119. package/lib/wholeSummaryUploadManager.d.ts +16 -0
  120. package/lib/wholeSummaryUploadManager.d.ts.map +1 -0
  121. package/lib/wholeSummaryUploadManager.js +34 -0
  122. package/lib/wholeSummaryUploadManager.js.map +1 -0
  123. package/package.json +15 -12
  124. package/src/deltaStorageService.ts +11 -3
  125. package/src/documentService.ts +5 -8
  126. package/src/documentServiceFactory.ts +19 -11
  127. package/src/documentStorageService.ts +1 -1
  128. package/src/gitManager.ts +116 -0
  129. package/src/historian.ts +121 -0
  130. package/src/packageVersion.ts +1 -1
  131. package/src/restWrapper.ts +100 -21
  132. package/src/restWrapperBase.ts +146 -0
  133. package/src/retriableGitManager.ts +17 -95
  134. package/src/shreddedSummaryDocumentStorageService.ts +7 -9
  135. package/src/storageContracts.ts +63 -0
  136. package/src/summaryTreeUploadManager.ts +160 -0
  137. package/src/treeUtils.ts +30 -0
  138. package/src/wholeSummaryDocumentStorageService.ts +44 -17
  139. package/src/wholeSummaryUploadManager.ts +64 -0
@@ -0,0 +1,106 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { assert, gitHashFile, IsoBuffer, Uint8ArrayToString, unreachableCase, } from "@fluidframework/common-utils";
6
+ import { getGitMode, getGitType } from "@fluidframework/protocol-base";
7
+ import { SummaryType, } from "@fluidframework/protocol-definitions";
8
+ /**
9
+ * Recursively writes summary tree as individual summary blobs.
10
+ */
11
+ export class SummaryTreeUploadManager {
12
+ constructor(manager, blobsShaCache, getPreviousFullSnapshot) {
13
+ this.manager = manager;
14
+ this.blobsShaCache = blobsShaCache;
15
+ this.getPreviousFullSnapshot = getPreviousFullSnapshot;
16
+ }
17
+ async writeSummaryTree(summaryTree, parentHandle, summaryType, sequenceNumber, initial) {
18
+ const previousFullSnapshot = await this.getPreviousFullSnapshot(parentHandle);
19
+ return this.writeSummaryTreeCore(summaryTree, previousFullSnapshot !== null && previousFullSnapshot !== void 0 ? previousFullSnapshot : undefined);
20
+ }
21
+ async writeSummaryTreeCore(summaryTree, previousFullSnapshot) {
22
+ const entries = await Promise.all(Object.keys(summaryTree.tree).map(async (key) => {
23
+ const entry = summaryTree.tree[key];
24
+ const pathHandle = await this.writeSummaryTreeObject(entry, previousFullSnapshot);
25
+ const treeEntry = {
26
+ mode: getGitMode(entry),
27
+ path: encodeURIComponent(key),
28
+ sha: pathHandle,
29
+ type: getGitType(entry),
30
+ };
31
+ return treeEntry;
32
+ }));
33
+ const treeHandle = (await this.manager.createGitTree({ tree: entries })).content;
34
+ return treeHandle.sha;
35
+ }
36
+ async writeSummaryTreeObject(object, previousFullSnapshot) {
37
+ switch (object.type) {
38
+ case SummaryType.Blob: {
39
+ return this.writeSummaryBlob(object.content);
40
+ }
41
+ case SummaryType.Handle: {
42
+ if (previousFullSnapshot === undefined) {
43
+ throw Error("Parent summary does not exist to reference by handle.");
44
+ }
45
+ return this.getIdFromPath(object.handleType, object.handle, previousFullSnapshot);
46
+ }
47
+ case SummaryType.Tree: {
48
+ return this.writeSummaryTreeCore(object, previousFullSnapshot);
49
+ }
50
+ case SummaryType.Attachment: {
51
+ return object.id;
52
+ }
53
+ default:
54
+ unreachableCase(object, `Unknown type: ${object.type}`);
55
+ }
56
+ }
57
+ async writeSummaryBlob(content) {
58
+ const { parsedContent, encoding } = typeof content === "string"
59
+ ? { parsedContent: content, encoding: "utf-8" }
60
+ : { parsedContent: Uint8ArrayToString(content, "base64"), encoding: "base64" };
61
+ // The gitHashFile would return the same hash as returned by the server as blob.sha
62
+ const hash = await gitHashFile(IsoBuffer.from(parsedContent, encoding));
63
+ if (!this.blobsShaCache.has(hash)) {
64
+ this.blobsShaCache.set(hash, "");
65
+ const blob = (await this.manager.createBlob(parsedContent, encoding)).content;
66
+ assert(hash === blob.sha, 0x0b6 /* "Blob.sha and hash do not match!!" */);
67
+ }
68
+ return hash;
69
+ }
70
+ getIdFromPath(handleType, handlePath, previousFullSnapshot) {
71
+ const path = handlePath.split("/").map((part) => decodeURIComponent(part));
72
+ if (path[0] === "") {
73
+ // root of tree should be unnamed
74
+ path.shift();
75
+ }
76
+ if (path.length === 0) {
77
+ return previousFullSnapshot.id;
78
+ }
79
+ return this.getIdFromPathCore(handleType, path, previousFullSnapshot);
80
+ }
81
+ getIdFromPathCore(handleType, path,
82
+ /** Previous snapshot, subtree relative to this path part */
83
+ previousSnapshot) {
84
+ var _a;
85
+ assert(path.length > 0, 0x0b3 /* "Expected at least 1 path part" */);
86
+ const key = path[0];
87
+ if (path.length === 1) {
88
+ switch (handleType) {
89
+ case SummaryType.Blob: {
90
+ const tryId = previousSnapshot.blobs[key];
91
+ assert(!!tryId, 0x0b4 /* "Parent summary does not have blob handle for specified path." */);
92
+ return tryId;
93
+ }
94
+ case SummaryType.Tree: {
95
+ const tryId = (_a = previousSnapshot.trees[key]) === null || _a === void 0 ? void 0 : _a.id;
96
+ assert(!!tryId, 0x0b5 /* "Parent summary does not have tree handle for specified path." */);
97
+ return tryId;
98
+ }
99
+ default:
100
+ throw Error(`Unexpected handle summary object type: "${handleType}".`);
101
+ }
102
+ }
103
+ return this.getIdFromPathCore(handleType, path.slice(1), previousSnapshot.trees[key]);
104
+ }
105
+ }
106
+ //# sourceMappingURL=summaryTreeUploadManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"summaryTreeUploadManager.js","sourceRoot":"","sources":["../src/summaryTreeUploadManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,MAAM,EACN,WAAW,EACX,SAAS,EACT,kBAAkB,EAClB,eAAe,GACf,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAIN,WAAW,GACX,MAAM,sCAAsC,CAAC;AAI9C;;GAEG;AACH,M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gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;oBAC1C,MAAM,CACL,CAAC,CAAC,KAAK,EACP,KAAK,CAAC,oEAAoE,CAC1E,CAAC;oBACF,OAAO,KAAK,CAAC;iBACb;gBACD,KAAK,WAAW,CAAC,IAAI,CAAC,CAAC;oBACtB,MAAM,KAAK,GAAG,MAAA,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,0CAAE,EAAE,CAAC;oBAC9C,MAAM,CACL,CAAC,CAAC,KAAK,EACP,KAAK,CAAC,oEAAoE,CAC1E,CAAC;oBACF,OAAO,KAAK,CAAC;iBACb;gBACD;oBACC,MAAM,KAAK,CAAC,2CAA2C,UAAU,IAAI,CAAC,CAAC;aACxE;SACD;QACD,OAAO,IAAI,CAAC,iBAAiB,CAAC,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IACvF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tassert,\n\tgitHashFile,\n\tIsoBuffer,\n\tUint8ArrayToString,\n\tunreachableCase,\n} from \"@fluidframework/common-utils\";\nimport { ICreateTreeEntry } from \"@fluidframework/gitresources\";\nimport { getGitMode, getGitType } from \"@fluidframework/protocol-base\";\nimport {\n\tISnapshotTreeEx,\n\tISummaryTree,\n\tSummaryObject,\n\tSummaryType,\n} from \"@fluidframework/protocol-definitions\";\nimport { IWholeSummaryPayloadType } from \"@fluidframework/server-services-client\";\nimport { IGitManager, ISummaryUploadManager } from \"./storageContracts\";\n\n/**\n * Recursively writes summary tree as individual summary blobs.\n */\nexport class SummaryTreeUploadManager implements ISummaryUploadManager {\n\tconstructor(\n\t\tprivate readonly manager: IGitManager,\n\t\tprivate readonly blobsShaCache: Map<string, string>,\n\t\tprivate readonly getPreviousFullSnapshot: (\n\t\t\tparentHandle: string,\n\t\t) => Promise<ISnapshotTreeEx | null | undefined>,\n\t) {}\n\n\tpublic async writeSummaryTree(\n\t\tsummaryTree: ISummaryTree,\n\t\tparentHandle: string,\n\t\tsummaryType: IWholeSummaryPayloadType,\n\t\tsequenceNumber?: number,\n\t\tinitial?: boolean,\n\t): Promise<string> {\n\t\tconst previousFullSnapshot = await this.getPreviousFullSnapshot(parentHandle);\n\t\treturn this.writeSummaryTreeCore(summaryTree, previousFullSnapshot ?? undefined);\n\t}\n\n\tprivate async writeSummaryTreeCore(\n\t\tsummaryTree: ISummaryTree,\n\t\tpreviousFullSnapshot: ISnapshotTreeEx | undefined,\n\t): Promise<string> {\n\t\tconst entries = await Promise.all(\n\t\t\tObject.keys(summaryTree.tree).map(async (key) => {\n\t\t\t\tconst entry = summaryTree.tree[key];\n\t\t\t\tconst pathHandle = await this.writeSummaryTreeObject(entry, previousFullSnapshot);\n\t\t\t\tconst treeEntry: ICreateTreeEntry = {\n\t\t\t\t\tmode: getGitMode(entry),\n\t\t\t\t\tpath: encodeURIComponent(key),\n\t\t\t\t\tsha: pathHandle,\n\t\t\t\t\ttype: getGitType(entry),\n\t\t\t\t};\n\t\t\t\treturn treeEntry;\n\t\t\t}),\n\t\t);\n\n\t\tconst treeHandle = (await this.manager.createGitTree({ tree: entries })).content;\n\t\treturn treeHandle.sha;\n\t}\n\n\tprivate async writeSummaryTreeObject(\n\t\tobject: SummaryObject,\n\t\tpreviousFullSnapshot: ISnapshotTreeEx | undefined,\n\t): Promise<string> {\n\t\tswitch (object.type) {\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\treturn this.writeSummaryBlob(object.content);\n\t\t\t}\n\t\t\tcase SummaryType.Handle: {\n\t\t\t\tif (previousFullSnapshot === undefined) {\n\t\t\t\t\tthrow Error(\"Parent summary does not exist to reference by handle.\");\n\t\t\t\t}\n\t\t\t\treturn this.getIdFromPath(object.handleType, object.handle, previousFullSnapshot);\n\t\t\t}\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\treturn this.writeSummaryTreeCore(object, previousFullSnapshot);\n\t\t\t}\n\t\t\tcase SummaryType.Attachment: {\n\t\t\t\treturn object.id;\n\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\tunreachableCase(object, `Unknown type: ${(object as any).type}`);\n\t\t}\n\t}\n\n\tprivate async writeSummaryBlob(content: string | Uint8Array): Promise<string> {\n\t\tconst { parsedContent, encoding } =\n\t\t\ttypeof content === \"string\"\n\t\t\t\t? { parsedContent: content, encoding: \"utf-8\" }\n\t\t\t\t: { parsedContent: Uint8ArrayToString(content, \"base64\"), encoding: \"base64\" };\n\n\t\t// The gitHashFile would return the same hash as returned by the server as blob.sha\n\t\tconst hash = await gitHashFile(IsoBuffer.from(parsedContent, encoding));\n\t\tif (!this.blobsShaCache.has(hash)) {\n\t\t\tthis.blobsShaCache.set(hash, \"\");\n\t\t\tconst blob = (await this.manager.createBlob(parsedContent, encoding)).content;\n\t\t\tassert(hash === blob.sha, 0x0b6 /* \"Blob.sha and hash do not match!!\" */);\n\t\t}\n\t\treturn hash;\n\t}\n\n\tprivate getIdFromPath(\n\t\thandleType: SummaryType,\n\t\thandlePath: string,\n\t\tpreviousFullSnapshot: ISnapshotTreeEx,\n\t): string {\n\t\tconst path = handlePath.split(\"/\").map((part) => decodeURIComponent(part));\n\t\tif (path[0] === \"\") {\n\t\t\t// root of tree should be unnamed\n\t\t\tpath.shift();\n\t\t}\n\t\tif (path.length === 0) {\n\t\t\treturn previousFullSnapshot.id;\n\t\t}\n\n\t\treturn this.getIdFromPathCore(handleType, path, previousFullSnapshot);\n\t}\n\n\tprivate getIdFromPathCore(\n\t\thandleType: SummaryType,\n\t\tpath: string[],\n\t\t/** Previous snapshot, subtree relative to this path part */\n\t\tpreviousSnapshot: ISnapshotTreeEx,\n\t): string {\n\t\tassert(path.length > 0, 0x0b3 /* \"Expected at least 1 path part\" */);\n\t\tconst key = path[0];\n\t\tif (path.length === 1) {\n\t\t\tswitch (handleType) {\n\t\t\t\tcase SummaryType.Blob: {\n\t\t\t\t\tconst tryId = previousSnapshot.blobs[key];\n\t\t\t\t\tassert(\n\t\t\t\t\t\t!!tryId,\n\t\t\t\t\t\t0x0b4 /* \"Parent summary does not have blob handle for specified path.\" */,\n\t\t\t\t\t);\n\t\t\t\t\treturn tryId;\n\t\t\t\t}\n\t\t\t\tcase SummaryType.Tree: {\n\t\t\t\t\tconst tryId = previousSnapshot.trees[key]?.id;\n\t\t\t\t\tassert(\n\t\t\t\t\t\t!!tryId,\n\t\t\t\t\t\t0x0b5 /* \"Parent summary does not have tree handle for specified path.\" */,\n\t\t\t\t\t);\n\t\t\t\t\treturn tryId;\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\tthrow Error(`Unexpected handle summary object type: \"${handleType}\".`);\n\t\t\t}\n\t\t}\n\t\treturn this.getIdFromPathCore(handleType, path.slice(1), previousSnapshot.trees[key]);\n\t}\n}\n"]}
@@ -3,6 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { SummaryType, ISnapshotTree, ISummaryTree } from "@fluidframework/protocol-definitions";
6
+ import { INormalizedWholeSummary } from "@fluidframework/server-services-client";
6
7
  /**
7
8
  * Summary tree assembler props
8
9
  */
@@ -48,4 +49,10 @@ export declare class SummaryTreeAssembler {
48
49
  * @returns Converted snapshot in ISummaryTree format
49
50
  */
50
51
  export declare function convertSnapshotAndBlobsToSummaryTree(snapshot: ISnapshotTree, blobs: Map<string, ArrayBuffer>): ISummaryTree;
52
+ export declare function evalBlobsAndTrees(snapshot: INormalizedWholeSummary): {
53
+ trees: number;
54
+ numBlobs: number;
55
+ encodedBlobsSize: number;
56
+ };
57
+ export declare function validateBlobsAndTrees(snapshot: ISnapshotTree): void;
51
58
  //# sourceMappingURL=treeUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"treeUtils.d.ts","sourceRoot":"","sources":["../src/treeUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,WAAW,EAC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;GAEG;AACH,qBAAa,oBAAoB;IAIpB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC;IAHnC,OAAO,CAAC,iBAAiB,CAAa;IACtC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAyC;gBAExC,KAAK,CAAC,wCAA4B;IAE/D;;OAEG;IACH,IAAW,OAAO,IAAI,YAAY,CAMjC;IAED;;OAEG;IACI,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI;IAO/D;;OAEG;IACI,SAAS,CACf,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,WAAW,CAAC,IAAI,GAAG,WAAW,CAAC,IAAI,GAAG,WAAW,CAAC,UAAU,EACxE,MAAM,EAAE,MAAM,GACZ,IAAI;IAQP;;OAEG;IACI,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,IAAI;IAIxD;;OAEG;IACI,aAAa,CAAC,EAAE,EAAE,MAAM;CAG/B;AAED;;;;;GAKG;AACH,wBAAgB,oCAAoC,CACnD,QAAQ,EAAE,aAAa,EACvB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,GAC7B,YAAY,CAcd;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,uBAAuB;;;;EAQlE;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,aAAa,QAS5D"}
package/lib/treeUtils.js CHANGED
@@ -77,4 +77,24 @@ export function convertSnapshotAndBlobsToSummaryTree(snapshot, blobs) {
77
77
  }
78
78
  return assembler.summary;
79
79
  }
80
+ export function evalBlobsAndTrees(snapshot) {
81
+ const trees = countTreesInSnapshotTree(snapshot.snapshotTree);
82
+ const numBlobs = snapshot.blobs.size;
83
+ let encodedBlobsSize = 0;
84
+ for (const [_, blobContent] of snapshot.blobs) {
85
+ encodedBlobsSize += blobContent.byteLength;
86
+ }
87
+ return { trees, numBlobs, encodedBlobsSize };
88
+ }
89
+ export function validateBlobsAndTrees(snapshot) {
90
+ assert(snapshot.trees !== undefined, 0x5d0 /* Returned r11s snapshot is malformed. No trees! */);
91
+ assert(snapshot.blobs !== undefined, 0x5d1 /* Returned r11s snapshot is malformed. No blobs! */);
92
+ }
93
+ function countTreesInSnapshotTree(snapshotTree) {
94
+ let numTrees = 0;
95
+ for (const [_, tree] of Object.entries(snapshotTree.trees)) {
96
+ numTrees += 1 + countTreesInSnapshotTree(tree);
97
+ }
98
+ return numTrees;
99
+ }
80
100
  //# sourceMappingURL=treeUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"treeUtils.js","sourceRoot":"","sources":["../src/treeUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EACN,WAAW,GAIX,MAAM,sCAAsC,CAAC;AAY9C;;GAEG;AACH,MAAM,OAAO,oBAAoB;IAIhC,YAA6B,KAAkC;QAAlC,UAAK,GAAL,KAAK,CAA6B;QAHvD,sBAAiB,GAAW,CAAC,CAAC;QACrB,gBAAW,GAAsC,EAAE,CAAC;IAEH,CAAC;IAEnE;;OAEG;IACH,IAAW,OAAO;;QACjB,OAAO;YACN,IAAI,EAAE,WAAW,CAAC,IAAI;YACtB,IAAI,oBAAO,IAAI,CAAC,WAAW,CAAE;YAC7B,YAAY,EAAE,MAAA,IAAI,CAAC,KAAK,0CAAE,YAAY;SACtC,CAAC;IACH,CAAC;IAED;;OAEG;IACI,OAAO,CAAC,GAAW,EAAE,OAA4B;QACvD,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG;YACvB,IAAI,EAAE,WAAW,CAAC,IAAI;YACtB,OAAO;SACP,CAAC;IACH,CAAC;IAED;;OAEG;IACI,SAAS,CACf,GAAW,EACX,UAAwE,EACxE,MAAc;QAEd,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG;YACvB,IAAI,EAAE,WAAW,CAAC,M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. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, IsoBuffer } from \"@fluidframework/common-utils\";\nimport {\n\tSummaryType,\n\tISnapshotTree,\n\tISummaryTree,\n\tSummaryObject,\n} from \"@fluidframework/protocol-definitions\";\n\n/**\n * Summary tree assembler props\n */\nexport interface ISummaryTreeAssemblerProps {\n\t/**\n\t * Indicates that this tree is unreferenced. If this is not present, the tree is considered referenced.\n\t */\n\tunreferenced?: true;\n}\n\n/**\n * Summary tree assembler (without stats collection).\n */\nexport class SummaryTreeAssembler {\n\tprivate attachmentCounter: number = 0;\n\tprivate readonly summaryTree: { [path: string]: SummaryObject } = {};\n\n\tconstructor(private readonly props?: ISummaryTreeAssemblerProps) {}\n\n\t/**\n\t * Get final summary\n\t */\n\tpublic get summary(): ISummaryTree {\n\t\treturn {\n\t\t\ttype: SummaryType.Tree,\n\t\t\ttree: { ...this.summaryTree },\n\t\t\tunreferenced: this.props?.unreferenced,\n\t\t};\n\t}\n\n\t/**\n\t * Add blob to summary\n\t */\n\tpublic addBlob(key: string, content: string | Uint8Array): void {\n\t\tthis.summaryTree[key] = {\n\t\t\ttype: SummaryType.Blob,\n\t\t\tcontent,\n\t\t};\n\t}\n\n\t/**\n\t * Add handle to summary\n\t */\n\tpublic addHandle(\n\t\tkey: string,\n\t\thandleType: SummaryType.Tree | SummaryType.Blob | SummaryType.Attachment,\n\t\thandle: string,\n\t): void {\n\t\tthis.summaryTree[key] = {\n\t\t\ttype: SummaryType.Handle,\n\t\t\thandleType,\n\t\t\thandle,\n\t\t};\n\t}\n\n\t/**\n\t * Add tree to summary\n\t */\n\tpublic addTree(key: string, summary: ISummaryTree): void {\n\t\tthis.summaryTree[key] = summary;\n\t}\n\n\t/**\n\t * Add attachment to summary\n\t */\n\tpublic addAttachment(id: string) {\n\t\tthis.summaryTree[this.attachmentCounter++] = { id, type: SummaryType.Attachment };\n\t}\n}\n\n/**\n * Helper function that converts ISnapshotTree and blobs to ISummaryTree\n * @param snapshot - Source snapshot tree\n * @param blobs - Blobs cache\n * @returns Converted snapshot in ISummaryTree format\n */\nexport function convertSnapshotAndBlobsToSummaryTree(\n\tsnapshot: ISnapshotTree,\n\tblobs: Map<string, ArrayBuffer>,\n): ISummaryTree {\n\tconst assembler = new SummaryTreeAssembler({\n\t\tunreferenced: snapshot.unreferenced,\n\t});\n\tfor (const [path, id] of Object.entries(snapshot.blobs)) {\n\t\tconst blob = blobs.get(id);\n\t\tassert(blob !== undefined, 0x2dd /* \"Cannot find blob for a given id\" */);\n\t\tassembler.addBlob(path, IsoBuffer.from(blob).toString(\"utf-8\"));\n\t}\n\tfor (const [key, tree] of Object.entries(snapshot.trees)) {\n\t\tconst subtree = convertSnapshotAndBlobsToSummaryTree(tree, blobs);\n\t\tassembler.addTree(key, subtree);\n\t}\n\treturn assembler.summary;\n}\n"]}
1
+ {"version":3,"file":"treeUtils.js","sourceRoot":"","sources":["../src/treeUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EACN,WAAW,GAIX,MAAM,sCAAsC,CAAC;AAa9C;;GAEG;AACH,MAAM,OAAO,oBAAoB;IAIhC,YAA6B,KAAkC;QAAlC,UAAK,GAAL,KAAK,CAA6B;QAHvD,sBAAiB,GAAW,CAAC,CAAC;QACrB,gBAAW,GAAsC,EAAE,CAAC;IAEH,CAAC;IAEnE;;OAEG;IACH,IAAW,OAAO;;QACjB,OAAO;YACN,IAAI,EAAE,WAAW,CAAC,IAAI;YACtB,IAAI,oBAAO,IAAI,CAAC,WAAW,CAAE;YAC7B,YAAY,EAAE,MAAA,IAAI,CAAC,KAAK,0CAAE,YAAY;SACtC,CAAC;IACH,CAAC;IAED;;OAEG;IACI,OAAO,CAAC,GAAW,EAAE,OAA4B;QACvD,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG;YACvB,IAAI,EAAE,WAAW,CAAC,IAAI;YACtB,OA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,CAAC;QAClE,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;KAChC;IACD,OAAO,SAAS,CAAC,OAAO,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,QAAiC;IAClE,MAAM,KAAK,GAAG,wBAAwB,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IAC9D,MAAM,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC;IACrC,IAAI,gBAAgB,GAAG,CAAC,CAAC;IACzB,KAAK,MAAM,CAAC,CAAC,EAAE,WAAW,CAAC,IAAI,QAAQ,CAAC,KAAK,EAAE;QAC9C,gBAAgB,IAAI,WAAW,CAAC,UAAU,CAAC;KAC3C;IACD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,CAAC;AAC9C,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,QAAuB;IAC5D,MAAM,CACL,QAAQ,CAAC,KAAK,KAAK,SAAS,EAC5B,KAAK,CAAC,oDAAoD,CAC1D,CAAC;IACF,MAAM,CACL,QAAQ,CAAC,KAAK,KAAK,SAAS,EAC5B,KAAK,CAAC,oDAAoD,CAC1D,CAAC;AACH,CAAC;AAED,SAAS,wBAAwB,CAAC,YAA2B;IAC5D,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,KAAK,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE;QAC3D,QAAQ,IAAI,CAAC,GAAG,wBAAwB,CAAC,IAAI,CAAC,CAAC;KAC/C;IACD,OAAO,QAAQ,CAAC;AACjB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, IsoBuffer } from \"@fluidframework/common-utils\";\nimport {\n\tSummaryType,\n\tISnapshotTree,\n\tISummaryTree,\n\tSummaryObject,\n} from \"@fluidframework/protocol-definitions\";\nimport { INormalizedWholeSummary } from \"@fluidframework/server-services-client\";\n\n/**\n * Summary tree assembler props\n */\nexport interface ISummaryTreeAssemblerProps {\n\t/**\n\t * Indicates that this tree is unreferenced. If this is not present, the tree is considered referenced.\n\t */\n\tunreferenced?: true;\n}\n\n/**\n * Summary tree assembler (without stats collection).\n */\nexport class SummaryTreeAssembler {\n\tprivate attachmentCounter: number = 0;\n\tprivate readonly summaryTree: { [path: string]: SummaryObject } = {};\n\n\tconstructor(private readonly props?: ISummaryTreeAssemblerProps) {}\n\n\t/**\n\t * Get final summary\n\t */\n\tpublic get summary(): ISummaryTree {\n\t\treturn {\n\t\t\ttype: SummaryType.Tree,\n\t\t\ttree: { ...this.summaryTree },\n\t\t\tunreferenced: this.props?.unreferenced,\n\t\t};\n\t}\n\n\t/**\n\t * Add blob to summary\n\t */\n\tpublic addBlob(key: string, content: string | Uint8Array): void {\n\t\tthis.summaryTree[key] = {\n\t\t\ttype: SummaryType.Blob,\n\t\t\tcontent,\n\t\t};\n\t}\n\n\t/**\n\t * Add handle to summary\n\t */\n\tpublic addHandle(\n\t\tkey: string,\n\t\thandleType: SummaryType.Tree | SummaryType.Blob | SummaryType.Attachment,\n\t\thandle: string,\n\t): void {\n\t\tthis.summaryTree[key] = {\n\t\t\ttype: SummaryType.Handle,\n\t\t\thandleType,\n\t\t\thandle,\n\t\t};\n\t}\n\n\t/**\n\t * Add tree to summary\n\t */\n\tpublic addTree(key: string, summary: ISummaryTree): void {\n\t\tthis.summaryTree[key] = summary;\n\t}\n\n\t/**\n\t * Add attachment to summary\n\t */\n\tpublic addAttachment(id: string) {\n\t\tthis.summaryTree[this.attachmentCounter++] = { id, type: SummaryType.Attachment };\n\t}\n}\n\n/**\n * Helper function that converts ISnapshotTree and blobs to ISummaryTree\n * @param snapshot - Source snapshot tree\n * @param blobs - Blobs cache\n * @returns Converted snapshot in ISummaryTree format\n */\nexport function convertSnapshotAndBlobsToSummaryTree(\n\tsnapshot: ISnapshotTree,\n\tblobs: Map<string, ArrayBuffer>,\n): ISummaryTree {\n\tconst assembler = new SummaryTreeAssembler({\n\t\tunreferenced: snapshot.unreferenced,\n\t});\n\tfor (const [path, id] of Object.entries(snapshot.blobs)) {\n\t\tconst blob = blobs.get(id);\n\t\tassert(blob !== undefined, 0x2dd /* \"Cannot find blob for a given id\" */);\n\t\tassembler.addBlob(path, IsoBuffer.from(blob).toString(\"utf-8\"));\n\t}\n\tfor (const [key, tree] of Object.entries(snapshot.trees)) {\n\t\tconst subtree = convertSnapshotAndBlobsToSummaryTree(tree, blobs);\n\t\tassembler.addTree(key, subtree);\n\t}\n\treturn assembler.summary;\n}\n\nexport function evalBlobsAndTrees(snapshot: INormalizedWholeSummary) {\n\tconst trees = countTreesInSnapshotTree(snapshot.snapshotTree);\n\tconst numBlobs = snapshot.blobs.size;\n\tlet encodedBlobsSize = 0;\n\tfor (const [_, blobContent] of snapshot.blobs) {\n\t\tencodedBlobsSize += blobContent.byteLength;\n\t}\n\treturn { trees, numBlobs, encodedBlobsSize };\n}\n\nexport function validateBlobsAndTrees(snapshot: ISnapshotTree) {\n\tassert(\n\t\tsnapshot.trees !== undefined,\n\t\t0x5d0 /* Returned r11s snapshot is malformed. No trees! */,\n\t);\n\tassert(\n\t\tsnapshot.blobs !== undefined,\n\t\t0x5d1 /* Returned r11s snapshot is malformed. No blobs! */,\n\t);\n}\n\nfunction countTreesInSnapshotTree(snapshotTree: ISnapshotTree): number {\n\tlet numTrees = 0;\n\tfor (const [_, tree] of Object.entries(snapshotTree.trees)) {\n\t\tnumTrees += 1 + countTreesInSnapshotTree(tree);\n\t}\n\treturn numTrees;\n}\n"]}
@@ -5,10 +5,10 @@
5
5
  import type { ITelemetryLogger } from "@fluidframework/common-definitions";
6
6
  import { IDocumentStorageService, ISummaryContext, IDocumentStorageServicePolicies } from "@fluidframework/driver-definitions";
7
7
  import { ICreateBlobResponse, ISnapshotTree, ISummaryHandle, ISummaryTree, IVersion } from "@fluidframework/protocol-definitions";
8
- import { GitManager } from "@fluidframework/server-services-client";
9
8
  import { ICache } from "./cache";
10
9
  import { ISnapshotTreeVersion } from "./definitions";
11
10
  import { IRouterliciousDriverPolicies } from "./policies";
11
+ import { GitManager } from "./gitManager";
12
12
  export declare class WholeSummaryDocumentStorageService implements IDocumentStorageService {
13
13
  protected readonly id: string;
14
14
  protected readonly manager: GitManager;
@@ -1 +1 @@
1
- {"version":3,"file":"wholeSummaryDocumentStorageService.d.ts","sourceRoot":"","sources":["../src/wholeSummaryDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAE3E,OAAO,EACN,uBAAuB,EACvB,eAAe,EACf,+BAA+B,EAC/B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACN,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAEN,UAAU,EAGV,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAiB,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAC;AAK1D,qBAAa,kCAAmC,YAAW,uBAAuB;IAahF,SAAS,CAAC,QAAQ,CAAC,EAAE,EAAE,MAAM;IAC7B,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,UAAU;IACtC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,gBAAgB;aAC3B,QAAQ,EAAE,+BAA+B;IACzD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC;IAChC,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAClC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAC;IACnC,OAAO,CAAC,QAAQ,CAAC,iBA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AAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IA8CzE,eAAe,CAAC,OAAO,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAclE,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IA4BlD,wBAAwB,CACpC,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,eAAe,GACtB,OAAO,CAAC,MAAM,CAAC;IAqBL,eAAe,CAAC,aAAa,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC;IAwBrE,UAAU,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,mBAAmB,CAAC;YAqB9D,yBAAyB;YA0EzB,aAAa;IAS3B,OAAO,CAAC,WAAW;CAGnB"}
@@ -2,11 +2,13 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { assert, stringToBuffer, Uint8ArrayToString } from "@fluidframework/common-utils";
6
- import { convertWholeFlatSummaryToSnapshotTreeAndBlobs, WholeSummaryUploadManager, } from "@fluidframework/server-services-client";
5
+ import { assert, performance, stringToBuffer, Uint8ArrayToString, } from "@fluidframework/common-utils";
6
+ import { getW3CData } from "@fluidframework/driver-base";
7
+ import { convertWholeFlatSummaryToSnapshotTreeAndBlobs, } from "@fluidframework/server-services-client";
7
8
  import { PerformanceEvent } from "@fluidframework/telemetry-utils";
8
9
  import { InMemoryCache } from "./cache";
9
- import { convertSnapshotAndBlobsToSummaryTree } from "./treeUtils";
10
+ import { convertSnapshotAndBlobsToSummaryTree, evalBlobsAndTrees, validateBlobsAndTrees, } from "./treeUtils";
11
+ import { WholeSummaryUploadManager } from "./wholeSummaryUploadManager";
10
12
  const latestSnapshotId = "latest";
11
13
  export class WholeSummaryDocumentStorageService {
12
14
  constructor(id, manager, logger, policies, driverPolicies, blobCache = new InMemoryCache(), snapshotTreeCache = new InMemoryCache(), noCacheGitManager, getStorageManager = async (disableCache) => disableCache && this.noCacheGitManager !== undefined
@@ -63,7 +65,7 @@ export class WholeSummaryDocumentStorageService {
63
65
  count,
64
66
  }, async () => {
65
67
  const manager = await this.getStorageManager();
66
- return manager.getCommits(id, count);
68
+ return (await manager.getCommits(id, count)).content;
67
69
  });
68
70
  return commits.map((commit) => ({
69
71
  date: commit.commit.author.date,
@@ -92,7 +94,7 @@ export class WholeSummaryDocumentStorageService {
92
94
  blobId,
93
95
  }, async (event) => {
94
96
  const manager = await this.getStorageManager();
95
- const response = await manager.getBlob(blobId);
97
+ const response = (await manager.getBlob(blobId)).content;
96
98
  event.end({
97
99
  size: response.size,
98
100
  });
@@ -124,9 +126,9 @@ export class WholeSummaryDocumentStorageService {
124
126
  const manager = await this.getStorageManager();
125
127
  const response = await manager.getSummary(summaryHandle.handle);
126
128
  event.end({
127
- size: (_a = response.trees[0]) === null || _a === void 0 ? void 0 : _a.entries.length,
129
+ size: (_a = response.content.trees[0]) === null || _a === void 0 ? void 0 : _a.entries.length,
128
130
  });
129
- return response;
131
+ return response.content;
130
132
  });
131
133
  const { blobs, snapshotTree } = convertWholeFlatSummaryToSnapshotTreeAndBlobs(wholeFlatSummary, "");
132
134
  return convertSnapshotAndBlobsToSummaryTree(snapshotTree, blobs);
@@ -140,7 +142,7 @@ export class WholeSummaryDocumentStorageService {
140
142
  const manager = await this.getStorageManager();
141
143
  const response = await manager
142
144
  .createBlob(Uint8ArrayToString(uint8ArrayFile, "base64"), "base64")
143
- .then((r) => ({ id: r.sha, url: r.url }));
145
+ .then((r) => ({ id: r.content.sha, url: r.content.url }));
144
146
  event.end({
145
147
  blobId: response.id,
146
148
  });
@@ -155,21 +157,23 @@ export class WholeSummaryDocumentStorageService {
155
157
  snapshotTree: cachedSnapshotTreeVersion.snapshotTree,
156
158
  };
157
159
  }
158
- const wholeFlatSummary = await PerformanceEvent.timedExecAsync(this.logger, {
160
+ const normalizedWholeSummary = await PerformanceEvent.timedExecAsync(this.logger, {
159
161
  eventName: "getWholeFlatSummary",
160
162
  treeId: versionId,
161
163
  }, async (event) => {
162
164
  var _a;
163
165
  const manager = await this.getStorageManager(disableCache);
164
166
  const response = await manager.getSummary(versionId);
165
- event.end({
166
- size: (_a = response.trees[0]) === null || _a === void 0 ? void 0 : _a.entries.length,
167
- });
168
- return response;
167
+ const start = performance.now();
168
+ const snapshot = convertWholeFlatSummaryToSnapshotTreeAndBlobs(response.content);
169
+ const snapshotConversionTime = performance.now() - start;
170
+ validateBlobsAndTrees(snapshot.snapshotTree);
171
+ const { trees, numBlobs, encodedBlobsSize } = evalBlobsAndTrees(snapshot);
172
+ event.end(Object.assign(Object.assign(Object.assign({ size: (_a = response.content.trees[0]) === null || _a === void 0 ? void 0 : _a.entries.length, trees, blobs: numBlobs, encodedBlobsSize }, response.propsToLog), { snapshotConversionTime }), getW3CData(response.requestUrl, "xmlhttprequest")));
173
+ return snapshot;
169
174
  });
170
- const normalizedWholeSummary = convertWholeFlatSummaryToSnapshotTreeAndBlobs(wholeFlatSummary);
171
175
  assert(normalizedWholeSummary.snapshotTree.id !== undefined, 0x275 /* "Root tree should contain the id" */);
172
- const wholeFlatSummaryId = wholeFlatSummary.id;
176
+ const wholeFlatSummaryId = normalizedWholeSummary.snapshotTree.id;
173
177
  const snapshotTreeVersion = {
174
178
  id: wholeFlatSummaryId,
175
179
  snapshotTree: normalizedWholeSummary.snapshotTree,
@@ -1 +1 @@
1
- {"version":3,"file":"wholeSummaryDocumentStorageService.js","sourceRoot":"","sources":["../src/wholeSummaryDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAa1F,OAAO,EACN,6CAA6C,EAG7C,yBAAyB,GACzB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAU,aAAa,EAAE,MAAM,SAAS,CAAC;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O,CAAC,CAAC;QAE3B,OAAO,mBAAmB,CAAC;IAC5B,CAAC;IAEO,KAAK,CAAC,aAAa,CAAC,KAA+B;QAC1D,MAAM,cAAc,GAAoB,EAAE,CAAC;QAC3C,KAAK,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE;YAC3B,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;YACtC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;QAC1D,CAAC,CAAC,CAAC;QACH,MAAM,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IACnC,CAAC;IAEO,WAAW,CAAC,MAAc;QACjC,OAAO,GAAG,IAAI,CAAC,EAAE,IAAI,MAAM,EAAE,CAAC;IAC/B,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, stringToBuffer, Uint8ArrayToString } from \"@fluidframework/common-utils\";\nimport {\n\tIDocumentStorageService,\n\tISummaryContext,\n\tIDocumentStorageServicePolicies,\n} from \"@fluidframework/driver-definitions\";\nimport {\n\tICreateBlobResponse,\n\tISnapshotTree,\n\tISummaryHandle,\n\tISummaryTree,\n\tIVersion,\n} from \"@fluidframework/protocol-definitions\";\nimport {\n\tconvertWholeFlatSummaryToSnapshotTreeAndBlobs,\n\tGitManager,\n\tISummaryUploadManager,\n\tWholeSummaryUploadManager,\n} from \"@fluidframework/server-services-client\";\nimport { PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { ICache, InMemoryCache } from \"./cache\";\nimport { ISnapshotTreeVersion } from \"./definitions\";\nimport { IRouterliciousDriverPolicies } from \"./policies\";\nimport { convertSnapshotAndBlobsToSummaryTree } from \"./treeUtils\";\n\nconst latestSnapshotId: string = \"latest\";\n\nexport class WholeSummaryDocumentStorageService implements IDocumentStorageService {\n\tprivate firstVersionsCall: boolean = true;\n\n\tpublic get repositoryUrl(): string {\n\t\treturn \"\";\n\t}\n\n\tprivate async getSummaryUploadManager(): Promise<ISummaryUploadManager> {\n\t\tconst manager = await this.getStorageManager();\n\t\treturn new WholeSummaryUploadManager(manager);\n\t}\n\n\tconstructor(\n\t\tprotected readonly id: string,\n\t\tprotected readonly manager: GitManager,\n\t\tprotected readonly logger: ITelemetryLogger,\n\t\tpublic readonly policies: IDocumentStorageServicePolicies,\n\t\tprivate readonly driverPolicies?: IRouterliciousDriverPolicies,\n\t\tprivate readonly blobCache: ICache<ArrayBufferLike> = new InMemoryCache(),\n\t\tprivate readonly snapshotTreeCache: ICache<ISnapshotTreeVersion> = new InMemoryCache(),\n\t\tprivate readonly noCacheGitManager?: GitManager,\n\t\tprivate readonly getStorageManager: (\n\t\t\tdisableCache?: boolean,\n\t\t) => Promise<GitManager> = async (disableCache) =>\n\t\t\tdisableCache && this.noCacheGitManager !== undefined\n\t\t\t\t? this.noCacheGitManager\n\t\t\t\t: this.manager,\n\t) {}\n\n\tpublic async getVersions(versionId: string | null, count: number): Promise<IVersion[]> {\n\t\tif (versionId !== this.id && versionId !== null) {\n\t\t\t// Blobs/Trees in this scenario will never have multiple versions, so return versionId as is\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tid: versionId,\n\t\t\t\t\ttreeId: undefined!,\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\t\t// If this is the first versions call for the document, we know we will want the latest summary.\n\t\t// Fetch latest summary, cache it, and return its id.\n\t\tif (this.firstVersionsCall && count === 1) {\n\t\t\tthis.firstVersionsCall = false;\n\t\t\tconst { id: _id, snapshotTree } = !this.driverPolicies?.enableDiscovery\n\t\t\t\t? await this.fetchAndCacheSnapshotTree(latestSnapshotId, false)\n\t\t\t\t: await this.fetchAndCacheSnapshotTree(latestSnapshotId, true);\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tid: _id,\n\t\t\t\t\ttreeId: snapshotTree.id!,\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\t// Otherwise, get the latest version of the document as normal.\n\t\tconst id = versionId ? versionId : this.id;\n\t\tconst commits = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"getVersions\",\n\t\t\t\tversionId: id,\n\t\t\t\tcount,\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\tconst manager = await this.getStorageManager();\n\t\t\t\treturn manager.getCommits(id, count);\n\t\t\t},\n\t\t);\n\t\treturn commits.map((commit) => ({\n\t\t\tdate: commit.commit.author.date,\n\t\t\tid: commit.sha,\n\t\t\ttreeId: commit.commit.tree.sha,\n\t\t}));\n\t}\n\n\tpublic async getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null> {\n\t\tlet requestVersion = version;\n\t\tif (!requestVersion) {\n\t\t\tconst versions = await this.getVersions(this.id, 1);\n\t\t\tif (versions.length === 0) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\trequestVersion = versions[0];\n\t\t}\n\n\t\treturn (await this.fetchAndCacheSnapshotTree(requestVersion.id)).snapshotTree;\n\t}\n\n\tpublic async readBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\tconst cachedBlob = await this.blobCache.get(this.getCacheKey(blobId));\n\t\tif (cachedBlob !== undefined) {\n\t\t\treturn cachedBlob;\n\t\t}\n\n\t\tconst blob = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"readBlob\",\n\t\t\t\tblobId,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst manager = await this.getStorageManager();\n\t\t\t\tconst response = await manager.getBlob(blobId);\n\t\t\t\tevent.end({\n\t\t\t\t\tsize: response.size,\n\t\t\t\t});\n\t\t\t\treturn response;\n\t\t\t},\n\t\t);\n\t\tconst bufferValue = stringToBuffer(blob.content, blob.encoding);\n\n\t\tawait this.blobCache.put(this.getCacheKey(blob.sha), bufferValue);\n\n\t\treturn bufferValue;\n\t}\n\n\tpublic async uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\tconst summaryHandle = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"uploadSummaryWithContext\",\n\t\t\t\tproposalHandle: context.proposalHandle,\n\t\t\t\tackHandle: context.ackHandle,\n\t\t\t\treferenceSequenceNumber: context.referenceSequenceNumber,\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\tconst summaryUploadManager = await this.getSummaryUploadManager();\n\t\t\t\treturn summaryUploadManager.writeSummaryTree(\n\t\t\t\t\tsummary,\n\t\t\t\t\tcontext.ackHandle ?? \"\",\n\t\t\t\t\t\"channel\",\n\t\t\t\t);\n\t\t\t},\n\t\t);\n\t\treturn summaryHandle;\n\t}\n\n\tpublic async downloadSummary(summaryHandle: ISummaryHandle): Promise<ISummaryTree> {\n\t\tconst wholeFlatSummary = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"getWholeFlatSummary\",\n\t\t\t\ttreeId: summaryHandle.handle,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst manager = await this.getStorageManager();\n\t\t\t\tconst response = await manager.getSummary(summaryHandle.handle);\n\t\t\t\tevent.end({\n\t\t\t\t\tsize: response.trees[0]?.entries.length,\n\t\t\t\t});\n\t\t\t\treturn response;\n\t\t\t},\n\t\t);\n\n\t\tconst { blobs, snapshotTree } = convertWholeFlatSummaryToSnapshotTreeAndBlobs(\n\t\t\twholeFlatSummary,\n\t\t\t\"\",\n\t\t);\n\t\treturn convertSnapshotAndBlobsToSummaryTree(snapshotTree, blobs);\n\t}\n\n\tpublic async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\tconst uint8ArrayFile = new Uint8Array(file);\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"createBlob\",\n\t\t\t\tsize: uint8ArrayFile.length,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst manager = await this.getStorageManager();\n\t\t\t\tconst response = await manager\n\t\t\t\t\t.createBlob(Uint8ArrayToString(uint8ArrayFile, \"base64\"), \"base64\")\n\t\t\t\t\t.then((r) => ({ id: r.sha, url: r.url }));\n\t\t\t\tevent.end({\n\t\t\t\t\tblobId: response.id,\n\t\t\t\t});\n\t\t\t\treturn response;\n\t\t\t},\n\t\t);\n\t}\n\n\tprivate async fetchAndCacheSnapshotTree(\n\t\tversionId: string,\n\t\tdisableCache?: boolean,\n\t): Promise<ISnapshotTreeVersion> {\n\t\tconst cachedSnapshotTreeVersion = await this.snapshotTreeCache.get(\n\t\t\tthis.getCacheKey(versionId),\n\t\t);\n\t\tif (cachedSnapshotTreeVersion !== undefined) {\n\t\t\treturn {\n\t\t\t\tid: cachedSnapshotTreeVersion.id,\n\t\t\t\tsnapshotTree: cachedSnapshotTreeVersion.snapshotTree,\n\t\t\t};\n\t\t}\n\n\t\tconst wholeFlatSummary = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"getWholeFlatSummary\",\n\t\t\t\ttreeId: versionId,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst manager = await this.getStorageManager(disableCache);\n\t\t\t\tconst response = await manager.getSummary(versionId);\n\t\t\t\tevent.end({\n\t\t\t\t\tsize: response.trees[0]?.entries.length,\n\t\t\t\t});\n\t\t\t\treturn response;\n\t\t\t},\n\t\t);\n\t\tconst normalizedWholeSummary =\n\t\t\tconvertWholeFlatSummaryToSnapshotTreeAndBlobs(wholeFlatSummary);\n\t\tassert(\n\t\t\tnormalizedWholeSummary.snapshotTree.id !== undefined,\n\t\t\t0x275 /* \"Root tree should contain the id\" */,\n\t\t);\n\t\tconst wholeFlatSummaryId: string = wholeFlatSummary.id;\n\t\tconst snapshotTreeVersion = {\n\t\t\tid: wholeFlatSummaryId,\n\t\t\tsnapshotTree: normalizedWholeSummary.snapshotTree,\n\t\t};\n\n\t\tconst cachePs: Promise<any>[] = [\n\t\t\tthis.snapshotTreeCache.put(this.getCacheKey(wholeFlatSummaryId), snapshotTreeVersion),\n\t\t\tthis.initBlobCache(normalizedWholeSummary.blobs),\n\t\t];\n\t\tif (wholeFlatSummaryId !== versionId) {\n\t\t\t// versionId could be \"latest\". When summarizer checks cache for \"latest\", we want it to be available.\n\t\t\t// TODO: For in-memory cache, <latest,snapshotTree> will be a shared pointer with <snapshotId,snapshotTree>,\n\t\t\t// However, for something like Redis, this will cache the same value twice. Alternatively, could we simply\n\t\t\t// cache with versionId?\n\t\t\tcachePs.push(\n\t\t\t\tthis.snapshotTreeCache.put(this.getCacheKey(versionId), snapshotTreeVersion),\n\t\t\t);\n\t\t}\n\n\t\tawait Promise.all(cachePs);\n\n\t\treturn snapshotTreeVersion;\n\t}\n\n\tprivate async initBlobCache(blobs: Map<string, ArrayBuffer>): Promise<void> {\n\t\tconst blobCachePutPs: Promise<void>[] = [];\n\t\tblobs.forEach((value, id) => {\n\t\t\tconst cacheKey = this.getCacheKey(id);\n\t\t\tblobCachePutPs.push(this.blobCache.put(cacheKey, value));\n\t\t});\n\t\tawait Promise.all(blobCachePutPs);\n\t}\n\n\tprivate getCacheKey(blobId: string): string {\n\t\treturn `${this.id}:${blobId}`;\n\t}\n}\n"]}
1
+ {"version":3,"file":"wholeSummaryDocumentStorageService.js","sourceRoot":"","sources":["../src/wholeSummaryDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,MAAM,EACN,WAAW,EACX,cAAc,EACd,kBAAkB,GAClB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAazD,OAAO,EACN,6CAA6C,GAG7C,MAAM,wCAAwC,CAAC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AI,CAAC,EAAE,IAAI,MAAM,EAAE,CAAC;IAC/B,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport {\n\tassert,\n\tperformance,\n\tstringToBuffer,\n\tUint8ArrayToString,\n} from \"@fluidframework/common-utils\";\nimport { getW3CData } from \"@fluidframework/driver-base\";\nimport {\n\tIDocumentStorageService,\n\tISummaryContext,\n\tIDocumentStorageServicePolicies,\n} from \"@fluidframework/driver-definitions\";\nimport {\n\tICreateBlobResponse,\n\tISnapshotTree,\n\tISummaryHandle,\n\tISummaryTree,\n\tIVersion,\n} from \"@fluidframework/protocol-definitions\";\nimport {\n\tconvertWholeFlatSummaryToSnapshotTreeAndBlobs,\n\tINormalizedWholeSummary,\n\tIWholeFlatSummary,\n} from \"@fluidframework/server-services-client\";\nimport { PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { ICache, InMemoryCache } from \"./cache\";\nimport { ISnapshotTreeVersion } from \"./definitions\";\nimport { IRouterliciousDriverPolicies } from \"./policies\";\nimport {\n\tconvertSnapshotAndBlobsToSummaryTree,\n\tevalBlobsAndTrees,\n\tvalidateBlobsAndTrees,\n} from \"./treeUtils\";\nimport { GitManager } from \"./gitManager\";\nimport { WholeSummaryUploadManager } from \"./wholeSummaryUploadManager\";\nimport { ISummaryUploadManager } from \"./storageContracts\";\nimport { IR11sResponse } from \"./restWrapper\";\n\nconst latestSnapshotId: string = \"latest\";\n\nexport class WholeSummaryDocumentStorageService implements IDocumentStorageService {\n\tprivate firstVersionsCall: boolean = true;\n\n\tpublic get repositoryUrl(): string {\n\t\treturn \"\";\n\t}\n\n\tprivate async getSummaryUploadManager(): Promise<ISummaryUploadManager> {\n\t\tconst manager = await this.getStorageManager();\n\t\treturn new WholeSummaryUploadManager(manager);\n\t}\n\n\tconstructor(\n\t\tprotected readonly id: string,\n\t\tprotected readonly manager: GitManager,\n\t\tprotected readonly logger: ITelemetryLogger,\n\t\tpublic readonly policies: IDocumentStorageServicePolicies,\n\t\tprivate readonly driverPolicies?: IRouterliciousDriverPolicies,\n\t\tprivate readonly blobCache: ICache<ArrayBufferLike> = new InMemoryCache(),\n\t\tprivate readonly snapshotTreeCache: ICache<ISnapshotTreeVersion> = new InMemoryCache(),\n\t\tprivate readonly noCacheGitManager?: GitManager,\n\t\tprivate readonly getStorageManager: (\n\t\t\tdisableCache?: boolean,\n\t\t) => Promise<GitManager> = async (disableCache) =>\n\t\t\tdisableCache && this.noCacheGitManager !== undefined\n\t\t\t\t? this.noCacheGitManager\n\t\t\t\t: this.manager,\n\t) {}\n\n\tpublic async getVersions(versionId: string | null, count: number): Promise<IVersion[]> {\n\t\tif (versionId !== this.id && versionId !== null) {\n\t\t\t// Blobs/Trees in this scenario will never have multiple versions, so return versionId as is\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tid: versionId,\n\t\t\t\t\ttreeId: undefined!,\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\t\t// If this is the first versions call for the document, we know we will want the latest summary.\n\t\t// Fetch latest summary, cache it, and return its id.\n\t\tif (this.firstVersionsCall && count === 1) {\n\t\t\tthis.firstVersionsCall = false;\n\t\t\tconst { id: _id, snapshotTree } = !this.driverPolicies?.enableDiscovery\n\t\t\t\t? await this.fetchAndCacheSnapshotTree(latestSnapshotId, false)\n\t\t\t\t: await this.fetchAndCacheSnapshotTree(latestSnapshotId, true);\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tid: _id,\n\t\t\t\t\ttreeId: snapshotTree.id!,\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\t// Otherwise, get the latest version of the document as normal.\n\t\tconst id = versionId ? versionId : this.id;\n\t\tconst commits = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"getVersions\",\n\t\t\t\tversionId: id,\n\t\t\t\tcount,\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\tconst manager = await this.getStorageManager();\n\t\t\t\treturn (await manager.getCommits(id, count)).content;\n\t\t\t},\n\t\t);\n\t\treturn commits.map((commit) => ({\n\t\t\tdate: commit.commit.author.date,\n\t\t\tid: commit.sha,\n\t\t\ttreeId: commit.commit.tree.sha,\n\t\t}));\n\t}\n\n\tpublic async getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null> {\n\t\tlet requestVersion = version;\n\t\tif (!requestVersion) {\n\t\t\tconst versions = await this.getVersions(this.id, 1);\n\t\t\tif (versions.length === 0) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\trequestVersion = versions[0];\n\t\t}\n\n\t\treturn (await this.fetchAndCacheSnapshotTree(requestVersion.id)).snapshotTree;\n\t}\n\n\tpublic async readBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\tconst cachedBlob = await this.blobCache.get(this.getCacheKey(blobId));\n\t\tif (cachedBlob !== undefined) {\n\t\t\treturn cachedBlob;\n\t\t}\n\n\t\tconst blob = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"readBlob\",\n\t\t\t\tblobId,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst manager = await this.getStorageManager();\n\t\t\t\tconst response = (await manager.getBlob(blobId)).content;\n\t\t\t\tevent.end({\n\t\t\t\t\tsize: response.size,\n\t\t\t\t});\n\t\t\t\treturn response;\n\t\t\t},\n\t\t);\n\t\tconst bufferValue = stringToBuffer(blob.content, blob.encoding);\n\n\t\tawait this.blobCache.put(this.getCacheKey(blob.sha), bufferValue);\n\n\t\treturn bufferValue;\n\t}\n\n\tpublic async uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\tconst summaryHandle = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"uploadSummaryWithContext\",\n\t\t\t\tproposalHandle: context.proposalHandle,\n\t\t\t\tackHandle: context.ackHandle,\n\t\t\t\treferenceSequenceNumber: context.referenceSequenceNumber,\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\tconst summaryUploadManager = await this.getSummaryUploadManager();\n\t\t\t\treturn summaryUploadManager.writeSummaryTree(\n\t\t\t\t\tsummary,\n\t\t\t\t\tcontext.ackHandle ?? \"\",\n\t\t\t\t\t\"channel\",\n\t\t\t\t);\n\t\t\t},\n\t\t);\n\t\treturn summaryHandle;\n\t}\n\n\tpublic async downloadSummary(summaryHandle: ISummaryHandle): Promise<ISummaryTree> {\n\t\tconst wholeFlatSummary = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"getWholeFlatSummary\",\n\t\t\t\ttreeId: summaryHandle.handle,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst manager = await this.getStorageManager();\n\t\t\t\tconst response = await manager.getSummary(summaryHandle.handle);\n\t\t\t\tevent.end({\n\t\t\t\t\tsize: response.content.trees[0]?.entries.length,\n\t\t\t\t});\n\t\t\t\treturn response.content;\n\t\t\t},\n\t\t);\n\n\t\tconst { blobs, snapshotTree } = convertWholeFlatSummaryToSnapshotTreeAndBlobs(\n\t\t\twholeFlatSummary,\n\t\t\t\"\",\n\t\t);\n\t\treturn convertSnapshotAndBlobsToSummaryTree(snapshotTree, blobs);\n\t}\n\n\tpublic async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\tconst uint8ArrayFile = new Uint8Array(file);\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"createBlob\",\n\t\t\t\tsize: uint8ArrayFile.length,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst manager = await this.getStorageManager();\n\t\t\t\tconst response = await manager\n\t\t\t\t\t.createBlob(Uint8ArrayToString(uint8ArrayFile, \"base64\"), \"base64\")\n\t\t\t\t\t.then((r) => ({ id: r.content.sha, url: r.content.url }));\n\t\t\t\tevent.end({\n\t\t\t\t\tblobId: response.id,\n\t\t\t\t});\n\t\t\t\treturn response;\n\t\t\t},\n\t\t);\n\t}\n\n\tprivate async fetchAndCacheSnapshotTree(\n\t\tversionId: string,\n\t\tdisableCache?: boolean,\n\t): Promise<ISnapshotTreeVersion> {\n\t\tconst cachedSnapshotTreeVersion = await this.snapshotTreeCache.get(\n\t\t\tthis.getCacheKey(versionId),\n\t\t);\n\t\tif (cachedSnapshotTreeVersion !== undefined) {\n\t\t\treturn {\n\t\t\t\tid: cachedSnapshotTreeVersion.id,\n\t\t\t\tsnapshotTree: cachedSnapshotTreeVersion.snapshotTree,\n\t\t\t};\n\t\t}\n\n\t\tconst normalizedWholeSummary = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"getWholeFlatSummary\",\n\t\t\t\ttreeId: versionId,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst manager = await this.getStorageManager(disableCache);\n\t\t\t\tconst response: IR11sResponse<IWholeFlatSummary> = await manager.getSummary(\n\t\t\t\t\tversionId,\n\t\t\t\t);\n\t\t\t\tconst start = performance.now();\n\t\t\t\tconst snapshot: INormalizedWholeSummary =\n\t\t\t\t\tconvertWholeFlatSummaryToSnapshotTreeAndBlobs(response.content);\n\t\t\t\tconst snapshotConversionTime = performance.now() - start;\n\t\t\t\tvalidateBlobsAndTrees(snapshot.snapshotTree);\n\t\t\t\tconst { trees, numBlobs, encodedBlobsSize } = evalBlobsAndTrees(snapshot);\n\n\t\t\t\tevent.end({\n\t\t\t\t\tsize: response.content.trees[0]?.entries.length,\n\t\t\t\t\ttrees,\n\t\t\t\t\tblobs: numBlobs,\n\t\t\t\t\tencodedBlobsSize,\n\t\t\t\t\t...response.propsToLog,\n\t\t\t\t\tsnapshotConversionTime,\n\t\t\t\t\t...getW3CData(response.requestUrl, \"xmlhttprequest\"),\n\t\t\t\t});\n\t\t\t\treturn snapshot;\n\t\t\t},\n\t\t);\n\n\t\tassert(\n\t\t\tnormalizedWholeSummary.snapshotTree.id !== undefined,\n\t\t\t0x275 /* \"Root tree should contain the id\" */,\n\t\t);\n\t\tconst wholeFlatSummaryId: string = normalizedWholeSummary.snapshotTree.id;\n\t\tconst snapshotTreeVersion = {\n\t\t\tid: wholeFlatSummaryId,\n\t\t\tsnapshotTree: normalizedWholeSummary.snapshotTree,\n\t\t};\n\n\t\tconst cachePs: Promise<any>[] = [\n\t\t\tthis.snapshotTreeCache.put(this.getCacheKey(wholeFlatSummaryId), snapshotTreeVersion),\n\t\t\tthis.initBlobCache(normalizedWholeSummary.blobs),\n\t\t];\n\t\tif (wholeFlatSummaryId !== versionId) {\n\t\t\t// versionId could be \"latest\". When summarizer checks cache for \"latest\", we want it to be available.\n\t\t\t// TODO: For in-memory cache, <latest,snapshotTree> will be a shared pointer with <snapshotId,snapshotTree>,\n\t\t\t// However, for something like Redis, this will cache the same value twice. Alternatively, could we simply\n\t\t\t// cache with versionId?\n\t\t\tcachePs.push(\n\t\t\t\tthis.snapshotTreeCache.put(this.getCacheKey(versionId), snapshotTreeVersion),\n\t\t\t);\n\t\t}\n\n\t\tawait Promise.all(cachePs);\n\n\t\treturn snapshotTreeVersion;\n\t}\n\n\tprivate async initBlobCache(blobs: Map<string, ArrayBuffer>): Promise<void> {\n\t\tconst blobCachePutPs: Promise<void>[] = [];\n\t\tblobs.forEach((value, id) => {\n\t\t\tconst cacheKey = this.getCacheKey(id);\n\t\t\tblobCachePutPs.push(this.blobCache.put(cacheKey, value));\n\t\t});\n\t\tawait Promise.all(blobCachePutPs);\n\t}\n\n\tprivate getCacheKey(blobId: string): string {\n\t\treturn `${this.id}:${blobId}`;\n\t}\n}\n"]}
@@ -0,0 +1,16 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { ISummaryTree, IWholeSummaryPayloadType } from "@fluidframework/server-services-client";
6
+ import { IGitManager, ISummaryUploadManager } from "./storageContracts";
7
+ /**
8
+ * Converts summary to snapshot tree and uploads with single snaphot tree payload.
9
+ */
10
+ export declare class WholeSummaryUploadManager implements ISummaryUploadManager {
11
+ private readonly manager;
12
+ constructor(manager: IGitManager);
13
+ writeSummaryTree(summaryTree: ISummaryTree, parentHandle: string | undefined, summaryType: IWholeSummaryPayloadType, sequenceNumber?: number, initial?: boolean): Promise<string>;
14
+ private writeSummaryTreeCore;
15
+ }
16
+ //# sourceMappingURL=wholeSummaryUploadManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wholeSummaryUploadManager.d.ts","sourceRoot":"","sources":["../src/wholeSummaryUploadManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,YAAY,EAEZ,wBAAwB,EAExB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAExE;;GAEG;AACH,qBAAa,yBAA0B,YAAW,qBAAqB;IAC1D,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,WAAW;IAEpC,gBAAgB,CAC5B,WAAW,EAAE,YAAY,EACzB,YAAY,EAAE,MAAM,GAAG,SAAS,EAChC,WAAW,EAAE,wBAAwB,EACrC,cAAc,GAAE,MAAU,EAC1B,OAAO,GAAE,OAAe,GACtB,OAAO,CAAC,MAAM,CAAC;YAcJ,oBAAoB;CAwBlC"}
@@ -0,0 +1,34 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { convertSummaryTreeToWholeSummaryTree, } from "@fluidframework/server-services-client";
6
+ /**
7
+ * Converts summary to snapshot tree and uploads with single snaphot tree payload.
8
+ */
9
+ export class WholeSummaryUploadManager {
10
+ constructor(manager) {
11
+ this.manager = manager;
12
+ }
13
+ async writeSummaryTree(summaryTree, parentHandle, summaryType, sequenceNumber = 0, initial = false) {
14
+ const id = await this.writeSummaryTreeCore(parentHandle, summaryTree, summaryType, sequenceNumber, initial);
15
+ if (!id) {
16
+ throw new Error(`Failed to write summary tree`);
17
+ }
18
+ return id;
19
+ }
20
+ async writeSummaryTreeCore(parentHandle, tree, type, sequenceNumber, initial) {
21
+ var _a;
22
+ const snapshotTree = convertSummaryTreeToWholeSummaryTree(parentHandle, tree, "", type === "channel" ? ".app" : "");
23
+ const snapshotPayload = {
24
+ entries: (_a = snapshotTree.entries) !== null && _a !== void 0 ? _a : [],
25
+ message: "",
26
+ sequenceNumber,
27
+ type,
28
+ };
29
+ return this.manager
30
+ .createSummary(snapshotPayload, initial)
31
+ .then((response) => response.content.id);
32
+ }
33
+ }
34
+ //# sourceMappingURL=wholeSummaryUploadManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wholeSummaryUploadManager.js","sourceRoot":"","sources":["../src/wholeSummaryUploadManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAIN,oCAAoC,GACpC,MAAM,wCAAwC,CAAC;AAGhD;;GAEG;AACH,MAAM,OAAO,yBAAyB;IACrC,YAA6B,OAAoB;QAApB,YAAO,GAAP,OAAO,CAAa;IAAG,CAAC;IAE9C,KAAK,CAAC,gBAAgB,CAC5B,WAAyB,EACzB,YAAgC,EAChC,WAAqC,EACrC,iBAAyB,CAAC,EAC1B,UAAmB,KAAK;QAExB,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,oBAAoB,CACzC,YAAY,EACZ,WAAW,EACX,WAAW,EACX,cAAc,EACd,OAAO,CACP,CAAC;QACF,IAAI,CAAC,EAAE,EAAE;YACR,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;SAChD;QACD,OAAO,EAAE,CAAC;IACX,CAAC;IAEO,KAAK,CAAC,oBAAoB,CACjC,YAAgC,EAChC,IAAkB,EAClB,IAA8B,EAC9B,cAAsB,EACtB,OAAgB;;QAEhB,MAAM,YAAY,GAAG,oCAAoC,CACxD,YAAY,EACZ,IAAI,EACJ,EAAE,EACF,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAChC,CAAC;QACF,MAAM,eAAe,GAAyB;YAC7C,OAAO,EAAE,MAAA,YAAY,CAAC,OAAO,mCAAI,EAAE;YACnC,OAAO,EAAE,EAAE;YACX,cAAc;YACd,IAAI;SACJ,CAAC;QAEF,OAAO,IAAI,CAAC,OAAO;aACjB,aAAa,CAAC,eAAe,EAAE,OAAO,CAAC;aACvC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC3C,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tISummaryTree,\n\tIWholeSummaryPayload,\n\tIWholeSummaryPayloadType,\n\tconvertSummaryTreeToWholeSummaryTree,\n} from \"@fluidframework/server-services-client\";\nimport { IGitManager, ISummaryUploadManager } from \"./storageContracts\";\n\n/**\n * Converts summary to snapshot tree and uploads with single snaphot tree payload.\n */\nexport class WholeSummaryUploadManager implements ISummaryUploadManager {\n\tconstructor(private readonly manager: IGitManager) {}\n\n\tpublic async writeSummaryTree(\n\t\tsummaryTree: ISummaryTree,\n\t\tparentHandle: string | undefined,\n\t\tsummaryType: IWholeSummaryPayloadType,\n\t\tsequenceNumber: number = 0,\n\t\tinitial: boolean = false,\n\t): Promise<string> {\n\t\tconst id = await this.writeSummaryTreeCore(\n\t\t\tparentHandle,\n\t\t\tsummaryTree,\n\t\t\tsummaryType,\n\t\t\tsequenceNumber,\n\t\t\tinitial,\n\t\t);\n\t\tif (!id) {\n\t\t\tthrow new Error(`Failed to write summary tree`);\n\t\t}\n\t\treturn id;\n\t}\n\n\tprivate async writeSummaryTreeCore(\n\t\tparentHandle: string | undefined,\n\t\ttree: ISummaryTree,\n\t\ttype: IWholeSummaryPayloadType,\n\t\tsequenceNumber: number,\n\t\tinitial: boolean,\n\t): Promise<string> {\n\t\tconst snapshotTree = convertSummaryTreeToWholeSummaryTree(\n\t\t\tparentHandle,\n\t\t\ttree,\n\t\t\t\"\",\n\t\t\ttype === \"channel\" ? \".app\" : \"\",\n\t\t);\n\t\tconst snapshotPayload: IWholeSummaryPayload = {\n\t\t\tentries: snapshotTree.entries ?? [],\n\t\t\tmessage: \"\",\n\t\t\tsequenceNumber,\n\t\t\ttype,\n\t\t};\n\n\t\treturn this.manager\n\t\t\t.createSummary(snapshotPayload, initial)\n\t\t\t.then((response) => response.content.id);\n\t}\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/routerlicious-driver",
3
- "version": "2.0.0-internal.4.0.5",
3
+ "version": "2.0.0-internal.4.1.0",
4
4
  "description": "Socket.IO + Git implementation of Fluid service API",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -37,27 +37,26 @@
37
37
  "dependencies": {
38
38
  "@fluidframework/common-definitions": "^0.20.1",
39
39
  "@fluidframework/common-utils": "^1.1.1",
40
- "@fluidframework/driver-base": ">=2.0.0-internal.4.0.5 <2.0.0-internal.5.0.0",
41
- "@fluidframework/driver-definitions": ">=2.0.0-internal.4.0.5 <2.0.0-internal.5.0.0",
42
- "@fluidframework/driver-utils": ">=2.0.0-internal.4.0.5 <2.0.0-internal.5.0.0",
43
- "@fluidframework/gitresources": "^0.1038.4000",
44
- "@fluidframework/protocol-base": "^0.1038.4000",
40
+ "@fluidframework/driver-base": ">=2.0.0-internal.4.1.0 <2.0.0-internal.4.2.0",
41
+ "@fluidframework/driver-definitions": ">=2.0.0-internal.4.1.0 <2.0.0-internal.4.2.0",
42
+ "@fluidframework/driver-utils": ">=2.0.0-internal.4.1.0 <2.0.0-internal.4.2.0",
43
+ "@fluidframework/gitresources": "^0.1039.1000",
44
+ "@fluidframework/protocol-base": "^0.1039.1000",
45
45
  "@fluidframework/protocol-definitions": "^1.1.0",
46
- "@fluidframework/server-services-client": "^0.1038.4000",
47
- "@fluidframework/telemetry-utils": ">=2.0.0-internal.4.0.5 <2.0.0-internal.5.0.0",
46
+ "@fluidframework/server-services-client": "^0.1039.1000",
47
+ "@fluidframework/telemetry-utils": ">=2.0.0-internal.4.1.0 <2.0.0-internal.4.2.0",
48
48
  "cross-fetch": "^3.1.5",
49
49
  "json-stringify-safe": "5.0.1",
50
- "querystring": "^0.2.0",
51
50
  "socket.io-client": "^4.4.1",
52
51
  "url-parse": "^1.5.8",
53
52
  "uuid": "^8.3.1"
54
53
  },
55
54
  "devDependencies": {
56
- "@fluid-tools/build-cli": "^0.13.0",
55
+ "@fluid-tools/build-cli": "^0.15.0",
57
56
  "@fluidframework/build-common": "^1.1.0",
58
- "@fluidframework/build-tools": "^0.13.0",
57
+ "@fluidframework/build-tools": "^0.15.0",
59
58
  "@fluidframework/eslint-config-fluid": "^2.0.0",
60
- "@fluidframework/mocha-test-setup": ">=2.0.0-internal.4.0.5 <2.0.0-internal.5.0.0",
59
+ "@fluidframework/mocha-test-setup": ">=2.0.0-internal.4.1.0 <2.0.0-internal.4.2.0",
61
60
  "@fluidframework/routerlicious-driver-previous": "npm:@fluidframework/routerlicious-driver@2.0.0-internal.4.0.0",
62
61
  "@microsoft/api-extractor": "^7.34.4",
63
62
  "@types/mocha": "^9.1.1",
@@ -72,6 +71,9 @@
72
71
  "cross-env": "^7.0.3",
73
72
  "eslint": "~8.6.0",
74
73
  "mocha": "^10.2.0",
74
+ "mocha-json-output-reporter": "^2.0.1",
75
+ "mocha-multi-reporters": "^1.5.1",
76
+ "moment": "^2.21.0",
75
77
  "nock": "^10.0.1",
76
78
  "nyc": "^15.1.0",
77
79
  "prettier": "~2.6.2",
@@ -104,6 +106,7 @@
104
106
  "test": "npm run test:mocha",
105
107
  "test:coverage": "nyc npm test -- --reporter xunit --reporter-option output=nyc/junit-report.xml",
106
108
  "test:mocha": "mocha --ignore 'dist/test/types/*' --recursive dist/test -r node_modules/@fluidframework/mocha-test-setup --unhandled-rejections=strict",
109
+ "test:mocha:multireport": "cross-env FLUID_TEST_MULTIREPORT=1 npm run test:mocha",
107
110
  "test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
108
111
  "tsc": "tsc",
109
112
  "typetests:gen": "fluid-type-test-generator",
@@ -3,6 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
+ import { getW3CData } from "@fluidframework/driver-base";
6
7
  import {
7
8
  IDeltaStorageService,
8
9
  IDocumentDeltaStorageService,
@@ -13,8 +14,8 @@ import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions"
13
14
  import { readAndParse, requestOps, emptyMessageStream } from "@fluidframework/driver-utils";
14
15
  import { ITelemetryLogger } from "@fluidframework/common-definitions";
15
16
  import { PerformanceEvent, TelemetryNullLogger } from "@fluidframework/telemetry-utils";
16
- import { RestWrapper } from "@fluidframework/server-services-client";
17
17
  import { DocumentStorageService } from "./documentStorageService";
18
+ import { RestWrapper } from "./restWrapperBase";
18
19
 
19
20
  const MaxBatchDeltas = 2000; // Maximum number of ops we can fetch at a time
20
21
 
@@ -120,9 +121,16 @@ export class DeltaStorageService implements IDeltaStorageService {
120
121
  to,
121
122
  });
122
123
  event.end({
123
- count: response.length,
124
+ length: response.content.length,
125
+ details: JSON.stringify({
126
+ firstOpSeqNumber: response.content[0]?.sequenceNumber,
127
+ lastOpSeqNumber:
128
+ response.content[response.content.length - 1]?.sequenceNumber,
129
+ }),
130
+ ...response.propsToLog,
131
+ ...getW3CData(response.requestUrl, "xmlhttprequest"),
124
132
  });
125
- return response;
133
+ return response.content;
126
134
  },
127
135
  );
128
136
 
@@ -8,7 +8,6 @@ import * as api from "@fluidframework/driver-definitions";
8
8
  import { DriverErrorType } from "@fluidframework/driver-definitions";
9
9
  import { RateLimiter, NetworkErrorBasic, canRetryOnError } from "@fluidframework/driver-utils";
10
10
  import { IClient } from "@fluidframework/protocol-definitions";
11
- import { GitManager, Historian, RestWrapper } from "@fluidframework/server-services-client";
12
11
  import io from "socket.io-client";
13
12
  import { PerformanceEvent, wrapError } from "@fluidframework/telemetry-utils";
14
13
  import { ITelemetryLogger } from "@fluidframework/common-definitions";
@@ -22,6 +21,9 @@ import { IRouterliciousDriverPolicies } from "./policies";
22
21
  import { ICache } from "./cache";
23
22
  import { ISnapshotTreeVersion } from "./definitions";
24
23
  import { pkgVersion as driverVersion } from "./packageVersion";
24
+ import { GitManager } from "./gitManager";
25
+ import { Historian } from "./historian";
26
+ import { RestWrapper } from "./restWrapperBase";
25
27
 
26
28
  /**
27
29
  * Amount of time between discoveries within which we don't need to rediscover on re-connect.
@@ -105,14 +107,9 @@ export class DocumentService implements api.IDocumentService {
105
107
  this.driverPolicies.enableRestLess,
106
108
  this.storageUrl,
107
109
  );
108
- const historian = new Historian(this.storageUrl, true, false, storageRestWrapper);
110
+ const historian = new Historian(true, false, storageRestWrapper);
109
111
  this.storageManager = new GitManager(historian);
110
- const noCacheHistorian = new Historian(
111
- this.storageUrl,
112
- true,
113
- true,
114
- storageRestWrapper,
115
- );
112
+ const noCacheHistorian = new Historian(true, true, storageRestWrapper);
116
113
  this.noCacheStorageManager = new GitManager(noCacheHistorian);
117
114
  }
118
115