@fluidframework/runtime-utils 1.4.0-121020 → 2.0.0-dev-rc.1.0.0.224419

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 (187) hide show
  1. package/.eslintrc.js +5 -7
  2. package/.mocharc.js +12 -0
  3. package/CHANGELOG.md +191 -0
  4. package/README.md +68 -1
  5. package/api-extractor-lint.json +4 -0
  6. package/api-extractor.json +2 -2
  7. package/api-report/runtime-utils.api.md +201 -0
  8. package/dist/{dataStoreHandleContextUtils.js → dataStoreHandleContextUtils.cjs} +5 -2
  9. package/dist/dataStoreHandleContextUtils.cjs.map +1 -0
  10. package/dist/dataStoreHandleContextUtils.d.ts +1 -0
  11. package/dist/dataStoreHandleContextUtils.d.ts.map +1 -1
  12. package/dist/{dataStoreHelpers.js → dataStoreHelpers.cjs} +44 -25
  13. package/dist/dataStoreHelpers.cjs.map +1 -0
  14. package/dist/dataStoreHelpers.d.ts +23 -4
  15. package/dist/dataStoreHelpers.d.ts.map +1 -1
  16. package/dist/index.cjs +44 -0
  17. package/dist/index.cjs.map +1 -0
  18. package/dist/index.d.ts +9 -9
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/{objectstoragepartition.js → objectstoragepartition.cjs} +4 -3
  21. package/dist/objectstoragepartition.cjs.map +1 -0
  22. package/dist/objectstoragepartition.d.ts +1 -0
  23. package/dist/objectstoragepartition.d.ts.map +1 -1
  24. package/dist/{objectstorageutils.js → objectstorageutils.cjs} +11 -15
  25. package/dist/objectstorageutils.cjs.map +1 -0
  26. package/dist/objectstorageutils.d.ts +6 -0
  27. package/dist/objectstorageutils.d.ts.map +1 -1
  28. package/dist/{requestParser.js → requestParser.cjs} +7 -11
  29. package/dist/requestParser.cjs.map +1 -0
  30. package/dist/requestParser.d.ts +1 -0
  31. package/dist/requestParser.d.ts.map +1 -1
  32. package/dist/runtime-utils-alpha.d.ts +155 -0
  33. package/dist/runtime-utils-beta.d.ts +103 -0
  34. package/dist/runtime-utils-public.d.ts +103 -0
  35. package/dist/runtime-utils-untrimmed.d.ts +306 -0
  36. package/dist/{runtimeFactoryHelper.js → runtimeFactoryHelper.cjs} +11 -12
  37. package/dist/runtimeFactoryHelper.cjs.map +1 -0
  38. package/dist/runtimeFactoryHelper.d.ts +4 -1
  39. package/dist/runtimeFactoryHelper.d.ts.map +1 -1
  40. package/dist/{summaryUtils.js → summaryUtils.cjs} +138 -34
  41. package/dist/summaryUtils.cjs.map +1 -0
  42. package/dist/summaryUtils.d.ts +66 -4
  43. package/dist/summaryUtils.d.ts.map +1 -1
  44. package/dist/tsdoc-metadata.json +11 -0
  45. package/dist/unpackUsedRoutes.cjs +34 -0
  46. package/dist/unpackUsedRoutes.cjs.map +1 -0
  47. package/dist/unpackUsedRoutes.d.ts +12 -0
  48. package/dist/unpackUsedRoutes.d.ts.map +1 -0
  49. package/dist/{utils.js → utils.cjs} +2 -1
  50. package/dist/utils.cjs.map +1 -0
  51. package/dist/utils.d.ts +7 -2
  52. package/dist/utils.d.ts.map +1 -1
  53. package/lib/{dataStoreHandleContextUtils.d.ts → dataStoreHandleContextUtils.d.mts} +1 -0
  54. package/lib/dataStoreHandleContextUtils.d.mts.map +1 -0
  55. package/lib/{dataStoreHandleContextUtils.js → dataStoreHandleContextUtils.mjs} +5 -2
  56. package/lib/dataStoreHandleContextUtils.mjs.map +1 -0
  57. package/lib/{dataStoreHelpers.d.ts → dataStoreHelpers.d.mts} +23 -4
  58. package/lib/dataStoreHelpers.d.mts.map +1 -0
  59. package/lib/{dataStoreHelpers.js → dataStoreHelpers.mjs} +42 -22
  60. package/lib/dataStoreHelpers.mjs.map +1 -0
  61. package/lib/index.d.mts +14 -0
  62. package/lib/index.d.mts.map +1 -0
  63. package/lib/index.mjs +14 -0
  64. package/lib/index.mjs.map +1 -0
  65. package/lib/{objectstoragepartition.d.ts → objectstoragepartition.d.mts} +1 -0
  66. package/lib/objectstoragepartition.d.mts.map +1 -0
  67. package/lib/{objectstoragepartition.js → objectstoragepartition.mjs} +3 -2
  68. package/lib/objectstoragepartition.mjs.map +1 -0
  69. package/lib/{objectstorageutils.d.ts → objectstorageutils.d.mts} +6 -0
  70. package/lib/objectstorageutils.d.mts.map +1 -0
  71. package/lib/{objectstorageutils.js → objectstorageutils.mjs} +11 -15
  72. package/lib/objectstorageutils.mjs.map +1 -0
  73. package/lib/{requestParser.d.ts → requestParser.d.mts} +1 -4
  74. package/lib/requestParser.d.mts.map +1 -0
  75. package/lib/{requestParser.js → requestParser.mjs} +7 -11
  76. package/lib/requestParser.mjs.map +1 -0
  77. package/lib/runtime-utils-alpha.d.mts +155 -0
  78. package/lib/runtime-utils-beta.d.mts +103 -0
  79. package/lib/runtime-utils-public.d.mts +103 -0
  80. package/lib/runtime-utils-untrimmed.d.mts +306 -0
  81. package/lib/{runtimeFactoryHelper.d.ts → runtimeFactoryHelper.d.mts} +4 -1
  82. package/lib/runtimeFactoryHelper.d.mts.map +1 -0
  83. package/lib/runtimeFactoryHelper.mjs +24 -0
  84. package/lib/runtimeFactoryHelper.mjs.map +1 -0
  85. package/lib/{summaryUtils.d.ts → summaryUtils.d.mts} +66 -4
  86. package/lib/summaryUtils.d.mts.map +1 -0
  87. package/lib/{summaryUtils.js → summaryUtils.mjs} +129 -26
  88. package/lib/summaryUtils.mjs.map +1 -0
  89. package/lib/unpackUsedRoutes.d.mts +12 -0
  90. package/lib/unpackUsedRoutes.d.mts.map +1 -0
  91. package/lib/unpackUsedRoutes.mjs +30 -0
  92. package/lib/unpackUsedRoutes.mjs.map +1 -0
  93. package/lib/{utils.d.ts → utils.d.mts} +7 -2
  94. package/lib/utils.d.mts.map +1 -0
  95. package/lib/{utils.js → utils.mjs} +2 -1
  96. package/lib/utils.mjs.map +1 -0
  97. package/package.json +102 -66
  98. package/prettier.config.cjs +8 -0
  99. package/src/dataStoreHandleContextUtils.ts +24 -16
  100. package/src/dataStoreHelpers.ts +106 -83
  101. package/src/index.ts +31 -9
  102. package/src/objectstoragepartition.ts +18 -14
  103. package/src/objectstorageutils.ts +37 -36
  104. package/src/requestParser.ts +81 -86
  105. package/src/runtimeFactoryHelper.ts +27 -26
  106. package/src/summaryUtils.ts +425 -299
  107. package/src/unpackUsedRoutes.ts +31 -0
  108. package/src/utils.ts +12 -7
  109. package/tsc-multi.test.json +4 -0
  110. package/tsconfig.json +10 -12
  111. package/dist/dataStoreHandleContextUtils.js.map +0 -1
  112. package/dist/dataStoreHelpers.js.map +0 -1
  113. package/dist/index.js +0 -26
  114. package/dist/index.js.map +0 -1
  115. package/dist/objectstoragepartition.js.map +0 -1
  116. package/dist/objectstorageutils.js.map +0 -1
  117. package/dist/packageVersion.d.ts +0 -9
  118. package/dist/packageVersion.d.ts.map +0 -1
  119. package/dist/packageVersion.js +0 -12
  120. package/dist/packageVersion.js.map +0 -1
  121. package/dist/requestParser.js.map +0 -1
  122. package/dist/runtimeFactoryHelper.js.map +0 -1
  123. package/dist/summarizerNode/index.d.ts +0 -8
  124. package/dist/summarizerNode/index.d.ts.map +0 -1
  125. package/dist/summarizerNode/index.js +0 -12
  126. package/dist/summarizerNode/index.js.map +0 -1
  127. package/dist/summarizerNode/summarizerNode.d.ts +0 -139
  128. package/dist/summarizerNode/summarizerNode.d.ts.map +0 -1
  129. package/dist/summarizerNode/summarizerNode.js +0 -480
  130. package/dist/summarizerNode/summarizerNode.js.map +0 -1
  131. package/dist/summarizerNode/summarizerNodeUtils.d.ts +0 -161
  132. package/dist/summarizerNode/summarizerNodeUtils.d.ts.map +0 -1
  133. package/dist/summarizerNode/summarizerNodeUtils.js +0 -225
  134. package/dist/summarizerNode/summarizerNodeUtils.js.map +0 -1
  135. package/dist/summarizerNode/summarizerNodeWithGc.d.ts +0 -133
  136. package/dist/summarizerNode/summarizerNodeWithGc.d.ts.map +0 -1
  137. package/dist/summarizerNode/summarizerNodeWithGc.js +0 -294
  138. package/dist/summarizerNode/summarizerNodeWithGc.js.map +0 -1
  139. package/dist/summaryUtils.js.map +0 -1
  140. package/dist/utils.js.map +0 -1
  141. package/lib/dataStoreHandleContextUtils.d.ts.map +0 -1
  142. package/lib/dataStoreHandleContextUtils.js.map +0 -1
  143. package/lib/dataStoreHelpers.d.ts.map +0 -1
  144. package/lib/dataStoreHelpers.js.map +0 -1
  145. package/lib/index.d.ts +0 -14
  146. package/lib/index.d.ts.map +0 -1
  147. package/lib/index.js +0 -14
  148. package/lib/index.js.map +0 -1
  149. package/lib/objectstoragepartition.d.ts.map +0 -1
  150. package/lib/objectstoragepartition.js.map +0 -1
  151. package/lib/objectstorageutils.d.ts.map +0 -1
  152. package/lib/objectstorageutils.js.map +0 -1
  153. package/lib/packageVersion.d.ts +0 -9
  154. package/lib/packageVersion.d.ts.map +0 -1
  155. package/lib/packageVersion.js +0 -9
  156. package/lib/packageVersion.js.map +0 -1
  157. package/lib/requestParser.d.ts.map +0 -1
  158. package/lib/requestParser.js.map +0 -1
  159. package/lib/runtimeFactoryHelper.d.ts.map +0 -1
  160. package/lib/runtimeFactoryHelper.js +0 -25
  161. package/lib/runtimeFactoryHelper.js.map +0 -1
  162. package/lib/summarizerNode/index.d.ts +0 -8
  163. package/lib/summarizerNode/index.d.ts.map +0 -1
  164. package/lib/summarizerNode/index.js +0 -7
  165. package/lib/summarizerNode/index.js.map +0 -1
  166. package/lib/summarizerNode/summarizerNode.d.ts +0 -139
  167. package/lib/summarizerNode/summarizerNode.d.ts.map +0 -1
  168. package/lib/summarizerNode/summarizerNode.js +0 -475
  169. package/lib/summarizerNode/summarizerNode.js.map +0 -1
  170. package/lib/summarizerNode/summarizerNodeUtils.d.ts +0 -161
  171. package/lib/summarizerNode/summarizerNodeUtils.d.ts.map +0 -1
  172. package/lib/summarizerNode/summarizerNodeUtils.js +0 -216
  173. package/lib/summarizerNode/summarizerNodeUtils.js.map +0 -1
  174. package/lib/summarizerNode/summarizerNodeWithGc.d.ts +0 -133
  175. package/lib/summarizerNode/summarizerNodeWithGc.d.ts.map +0 -1
  176. package/lib/summarizerNode/summarizerNodeWithGc.js +0 -289
  177. package/lib/summarizerNode/summarizerNodeWithGc.js.map +0 -1
  178. package/lib/summaryUtils.d.ts.map +0 -1
  179. package/lib/summaryUtils.js.map +0 -1
  180. package/lib/utils.d.ts.map +0 -1
  181. package/lib/utils.js.map +0 -1
  182. package/src/packageVersion.ts +0 -9
  183. package/src/summarizerNode/index.ts +0 -8
  184. package/src/summarizerNode/summarizerNode.ts +0 -662
  185. package/src/summarizerNode/summarizerNodeUtils.ts +0 -339
  186. package/src/summarizerNode/summarizerNodeWithGc.ts +0 -459
  187. package/tsconfig.esnext.json +0 -7
@@ -0,0 +1,31 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import { assert } from "@fluidframework/core-utils";
7
+
8
+ /**
9
+ * Helper function that unpacks the used routes of children from a given node's used routes.
10
+ * @param usedRoutes - The used routes of a node.
11
+ * @returns A map of used routes of each children of the the given node.
12
+ * @internal
13
+ */
14
+ export function unpackChildNodesUsedRoutes(usedRoutes: readonly string[]) {
15
+ // Remove the node's self used route, if any, and generate the children used routes.
16
+ const filteredUsedRoutes = usedRoutes.filter((route) => route !== "" && route !== "/");
17
+ const childUsedRoutesMap: Map<string, string[]> = new Map();
18
+ for (const route of filteredUsedRoutes) {
19
+ assert(route.startsWith("/"), 0x5e0 /* Used route should always be an absolute route */);
20
+ const childId = route.split("/")[1];
21
+ const childUsedRoute = route.slice(childId.length + 1);
22
+
23
+ const childUsedRoutes = childUsedRoutesMap.get(childId);
24
+ if (childUsedRoutes !== undefined) {
25
+ childUsedRoutes.push(childUsedRoute);
26
+ } else {
27
+ childUsedRoutesMap.set(childId, [childUsedRoute]);
28
+ }
29
+ }
30
+ return childUsedRoutesMap;
31
+ }
package/src/utils.ts CHANGED
@@ -5,7 +5,11 @@
5
5
 
6
6
  import { IDocumentAttributes, ISnapshotTree } from "@fluidframework/protocol-definitions";
7
7
 
8
- /** Reads a blob from storage and parses it from JSON. */
8
+ /**
9
+ * Reads a blob from storage and parses it from JSON.
10
+ *
11
+ * @internal
12
+ */
9
13
  export type ReadAndParseBlob = <T>(id: string) => Promise<T>;
10
14
 
11
15
  /**
@@ -13,12 +17,13 @@ export type ReadAndParseBlob = <T>(id: string) => Promise<T>;
13
17
  * @param tree - snapshot tree to examine
14
18
  * @param readAndParseBlob - function to read blob contents from storage
15
19
  * and parse the result from JSON.
20
+ * @internal
16
21
  */
17
- export async function seqFromTree(
18
- tree: ISnapshotTree,
19
- readAndParseBlob: ReadAndParseBlob,
22
+ export async function seqFromTree(
23
+ tree: ISnapshotTree,
24
+ readAndParseBlob: ReadAndParseBlob,
20
25
  ): Promise<number> {
21
- const attributesHash = tree.trees[".protocol"].blobs.attributes;
22
- const attrib = await readAndParseBlob<IDocumentAttributes>(attributesHash);
23
- return attrib.sequenceNumber;
26
+ const attributesHash = tree.trees[".protocol"].blobs.attributes;
27
+ const attrib = await readAndParseBlob<IDocumentAttributes>(attributesHash);
28
+ return attrib.sequenceNumber;
24
29
  }
@@ -0,0 +1,4 @@
1
+ {
2
+ "targets": [{ "extname": ".cjs", "module": "CommonJS", "moduleResolution": "Node16" }],
3
+ "projects": ["./tsconfig.json", "./src/test/tsconfig.json"]
4
+ }
package/tsconfig.json CHANGED
@@ -1,14 +1,12 @@
1
1
  {
2
- "extends": "@fluidframework/build-common/ts-common-config.json",
3
- "exclude": [
4
- "src/test/**/*"
5
- ],
6
- "compilerOptions": {
7
- "rootDir": "./src",
8
- "outDir": "./dist",
9
- "composite": true
10
- },
11
- "include": [
12
- "src/**/*"
13
- ]
2
+ "extends": [
3
+ "../../../common/build/build-common/tsconfig.base.json",
4
+ "../../../common/build/build-common/tsconfig.cjs.json",
5
+ ],
6
+ "include": ["src/**/*"],
7
+ "exclude": ["src/test/**/*"],
8
+ "compilerOptions": {
9
+ "rootDir": "./src",
10
+ "outDir": "./dist",
11
+ },
14
12
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"dataStoreHandleContextUtils.js","sourceRoot":"","sources":["../src/dataStoreHandleContextUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH;;;;;GAKG;AACH,SAAgB,yBAAyB,CAAC,IAAY,EAAE,YAAkC;IACtF,IAAI,IAAI,KAAK,EAAE,EAAE;QACb,uBAAuB;QACvB,wDAAwD;QACxD,yFAAyF;QACzF,OAAO,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,YAAY,CAAC;KACtE;SAAM;QACH,gEAAgE;QAChE,IAAI,cAAc,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACjE,cAAc,GAAG,cAAc,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC;QAE7F,iEAAiE;QACjE,2FAA2F;QAC3F,OAAO,YAAY,KAAK,SAAS;YAC7B,CAAC,CAAC,IAAI,cAAc,EAAE;YACtB,CAAC,CAAC,GAAG,YAAY,CAAC,YAAY,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,YAAY,IAAI,cAAc,EAAE,CAAC;KACnG;AACL,CAAC;AAjBD,8DAiBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IFluidHandleContext } from \"@fluidframework/core-interfaces\";\n\n/**\n * Generates the absolute path for a Fluid object given its path and its parent routeContext.\n * @param path - The path to the Fluid object relative to the route context.\n * @param routeContext - The route context that contains the Fluid object.\n * @returns The absolute path to the Fluid object from the root of the Container.\n */\nexport function generateHandleContextPath(path: string, routeContext?: IFluidHandleContext): string {\n if (path === \"\") {\n // The `path` is empty.\n // If the routeContext does not exist, this is the root.\n // If the routeContext exists, the absolute path is the same as that of the routeContext.\n return routeContext === undefined ? \"\" : routeContext.absolutePath;\n } else {\n // Remove beginning and trailing slashes, if any, from the path.\n let normalizedPath = path.startsWith(\"/\") ? path.slice(1) : path;\n normalizedPath = normalizedPath.endsWith(\"/\") ? normalizedPath.slice(0, -1) : normalizedPath;\n\n // If the routeContext does not exist, path is the absolute path.\n // If the routeContext exists, absolute path is routeContext's absolute path plus the path.\n return routeContext === undefined\n ? `/${normalizedPath}`\n : `${routeContext.absolutePath === \"/\" ? \"\" : routeContext.absolutePath}/${normalizedPath}`;\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"dataStoreHelpers.js","sourceRoot":"","sources":["../src/dataStoreHelpers.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;AAYtD,qEAAyE;AASzE,SAAgB,mBAAmB,CAAC,GAAQ;IACxC,MAAM,MAAM,GAAG,GAAG,CAAC;IACnB,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,2BAA2B,KAAK,IAAI,EAAE;QACrF,MAAM,WAAW,GAAuB,GAAG,CAAC;QAC5C,OAAO;YACH,QAAQ,EAAE,YAAY;YACtB,MAAM,EAAE,WAAW,CAAC,IAAI;YACxB,KAAK,EAAE,WAAW,CAAC,OAAO;YAC1B,IAAI,KAAK,KAAK,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;SAC5C,CAAC;KACL;IAED,0GAA0G;IAC1G,MAAM,YAAY,GAAG,IAAA,wCAAsB,GAAE,CAAC;IAE9C,OAAO;QACH,QAAQ,EAAE,YAAY;QACtB,MAAM;QACN,KAAK,EAAE,GAAG,GAAG,EAAE;QACf,IAAI,KAAK,aAAK,OAAO,MAAC,CAAC,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,KAAK,CAA0B,mCAAI,YAAY,CAAC,KAAK,CAAC,CA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F,IAAA,qBAAM,EAAC,MAAM,KAAK,GAAG,EAAE,KAAK,CAAC,sDAAsD,CAAC,CAAC;IACrF,kEAAkE;IAClE,MAAM,UAAU,GAAG,MAAA,OAAO,CAAC,GAAG,0CAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IAE9C,0GAA0G;IAC1G,MAAM,YAAY,GAAG,IAAA,wCAAsB,GAAE,CAAC;IAE9C,OAAO;QACH,QAAQ,EAAE,YAAY;QACtB,MAAM;QACN,KAAK,EAAE,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,KAAK,UAAU,EAAE;QACnE,IAAI,KAAK,KAAK,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;KAC7C,CAAC;AACN,CAAC;AAdD,kDAcC;AAID,SAAgB,sBAAsB,CAClC,IAAY,EACZ,OAAmC;IAEnC,OAAO;QACH,IAAI;QACJ,IAAI,sBAAsB,KAAK,OAAO,IAAI,CAAC,CAAC,CAAC;QAC7C,IAAI,uBAAuB,KAAK,OAAO,IAAI,CAAC,CAAC,CAAC;QAC9C,oBAAoB,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC,MAAM,OAAO,CAAC,CAAC,oBAAoB,CAAC,OAAO,EAAE,QAAQ,CAAC;QAC1G,GAAG,EAAE,KAAK,EAAE,IAAY,EAAE,EAAE,WAAC,OAAA,MAAA,CAAC,MAAM,OAAO,CAAC,CAAC,uBAAuB,0CAAE,GAAG,CAAC,IAAI,CAAC,CAAA,EAAA;KAClF,CAAC;AACN,CAAC;AAXD,wDAWC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport {\n FluidObject,\n IFluidRouter,\n IRequest,\n IResponse,\n} from \"@fluidframework/core-interfaces\";\nimport {\n IFluidDataStoreFactory,\n IFluidDataStoreRegistry,\n IProvideFluidDataStoreRegistry,\n} from \"@fluidframework/runtime-definitions\";\nimport { generateErrorWithStack } from \"@fluidframework/telemetry-utils\";\n\ninterface IResponseException extends Error {\n errorFromRequestFluidObject: true;\n message: string;\n code: number;\n stack?: string;\n}\n\nexport function exceptionToResponse(err: any): IResponse {\n const status = 500;\n if (err !== null && typeof err === \"object\" && err.errorFromRequestFluidObject === true) {\n const responseErr: IResponseException = err;\n return {\n mimeType: \"text/plain\",\n status: responseErr.code,\n value: responseErr.message,\n get stack() { return responseErr.stack; },\n };\n }\n\n // Capture error objects, not stack itself, as stack retrieval is very expensive operation, so we delay it\n const errWithStack = generateErrorWithStack();\n\n return {\n mimeType: \"text/plain\",\n status,\n value: `${err}`,\n get stack() { return ((err?.stack) as (string | undefined)) ?? errWithStack.stack; },\n };\n}\n\nexport function responseToException(response: IResponse, request: IRequest): Error {\n const message = response.value;\n const errWithStack = generateErrorWithStack();\n const responseErr: Error & IResponseException = {\n errorFromRequestFluidObject: true,\n message,\n name: \"Error\",\n code: response.status,\n get stack() { return response.stack ?? errWithStack.stack; },\n };\n\n return responseErr;\n}\n\nexport async function requestFluidObject<T = FluidObject>(\n router: IFluidRouter, url: string | IRequest): Promise<T> {\n const request = typeof url === \"string\" ? { url } : url;\n const response = await router.request(request);\n\n if (response.status !== 200 || response.mimeType !== \"fluid/object\") {\n throw responseToException(response, request);\n }\n\n assert(response.value, 0x19a /* \"Invalid response value for Fluid object request\" */);\n return response.value as T;\n}\n\nexport const create404Response = (request: IRequest) => createResponseError(404, \"not found\", request);\n\nexport function createResponseError(status: number, value: string, request: IRequest): IResponse {\n assert(status !== 200, 0x19b /* \"Cannot not create response error on 200 status\" */);\n // Omit query string which could contain personal data (aka \"PII\")\n const urlNoQuery = request.url?.split(\"?\")[0];\n\n // Capture error objects, not stack itself, as stack retrieval is very expensive operation, so we delay it\n const errWithStack = generateErrorWithStack();\n\n return {\n mimeType: \"text/plain\",\n status,\n value: urlNoQuery === undefined ? value : `${value}: ${urlNoQuery}`,\n get stack() { return errWithStack.stack; },\n };\n}\n\nexport type Factory = IFluidDataStoreFactory & Partial<IProvideFluidDataStoreRegistry>;\n\nexport function createDataStoreFactory(\n type: string,\n factory: Factory | Promise<Factory>,\n ): IFluidDataStoreFactory & IFluidDataStoreRegistry {\n return {\n type,\n get IFluidDataStoreFactory() { return this; },\n get IFluidDataStoreRegistry() { return this; },\n instantiateDataStore: async (context, existing) => (await factory).instantiateDataStore(context, existing),\n get: async (name: string) => (await factory).IFluidDataStoreRegistry?.get(name),\n };\n}\n"]}
package/dist/index.js DELETED
@@ -1,26 +0,0 @@
1
- "use strict";
2
- /*!
3
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
- * Licensed under the MIT License.
5
- */
6
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
- if (k2 === undefined) k2 = k;
8
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./dataStoreHandleContextUtils"), exports);
18
- __exportStar(require("./dataStoreHelpers"), exports);
19
- __exportStar(require("./objectstoragepartition"), exports);
20
- __exportStar(require("./objectstorageutils"), exports);
21
- __exportStar(require("./requestParser"), exports);
22
- __exportStar(require("./runtimeFactoryHelper"), exports);
23
- __exportStar(require("./summarizerNode"), exports);
24
- __exportStar(require("./summaryUtils"), exports);
25
- __exportStar(require("./utils"), exports);
26
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;AAEH,gEAA8C;AAC9C,qDAAmC;AACnC,2DAAyC;AACzC,uDAAqC;AACrC,kDAAgC;AAChC,yDAAuC;AACvC,mDAAiC;AACjC,iDAA+B;AAC/B,0CAAwB","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport * from \"./dataStoreHandleContextUtils\";\nexport * from \"./dataStoreHelpers\";\nexport * from \"./objectstoragepartition\";\nexport * from \"./objectstorageutils\";\nexport * from \"./requestParser\";\nexport * from \"./runtimeFactoryHelper\";\nexport * from \"./summarizerNode\";\nexport * from \"./summaryUtils\";\nexport * from \"./utils\";\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"objectstoragepartition.js","sourceRoot":"","sources":["../src/objectstoragepartition.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;AAGtD;;GAEG;AACH,MAAa,sBAAsB;IAC/B,YAA6B,OAA+B,EAAmB,IAAY;QAA9D,YAAO,GAAP,OAAO,CAAwB;QAAmB,SAAI,GAAJ,IAAI,CAAQ;QACvF,kDAAkD;QAClD,IAAA,qBAAM,EAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,mDAAmD,CAAC,CAAC;IAC3F,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAC,IAAY;QAC9B,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC;IACzD,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAC,IAAY;QAC9B,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC;IACzD,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,IAAY;QAC1B,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC;IACrD,CAAC;CACJ;AAjBD,wDAiBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { IChannelStorageService } from \"@fluidframework/datastore-definitions\";\n\n/**\n * Returns a new IChannelStorageService that resolves the given `path` as root.\n */\nexport class ObjectStoragePartition implements IChannelStorageService {\n constructor(private readonly storage: IChannelStorageService, private readonly path: string) {\n // `path` must not include the trailing separator.\n assert(!path.endsWith(\"/\"), 0x19c /* \"storage service path has trailing separator\" */);\n }\n\n public async readBlob(path: string): Promise<ArrayBufferLike> {\n return this.storage.readBlob(`${this.path}/${path}`);\n }\n\n public async contains(path: string): Promise<boolean> {\n return this.storage.contains(`${this.path}/${path}`);\n }\n\n public async list(path: string): Promise<string[]> {\n return this.storage.list(`${this.path}/${path}`);\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"objectstorageutils.js","sourceRoot":"","sources":["../src/objectstorageutils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,SAAgB,mCAAmC,CAAC,IAAY;IAC5D,IAAI,aAAa,GAAG,IAAI,CAAC;IACzB,IAAI,aAAa,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;QAC/B,aAAa,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;KAC3C;IACD,IAAI,aAAa,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QAC7B,aAAa,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC,EAAE,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;KACrE;IACD,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE;QAC1B,OAAO,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;KACnC;IACD,OAAO,EAAE,CAAC;AACd,CAAC;AAZD,kFAYC;AAEM,KAAK,UAAU,mBAAmB,CAAC,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n */\n\nimport { ITree } from \"@fluidframework/protocol-definitions\";\n\nexport function getNormalizedObjectStoragePathParts(path: string) {\n let normalizePath = path;\n if (normalizePath.startsWith(\"/\")) {\n normalizePath = normalizePath.substr(1);\n }\n if (normalizePath.endsWith(\"/\")) {\n normalizePath = normalizePath.substr(0, normalizePath.length - 1);\n }\n if (normalizePath.length > 0) {\n return normalizePath.split(\"/\");\n }\n return [];\n}\n\nexport async function listBlobsAtTreePath(inputTree: ITree | undefined, path: string): Promise<string[]> {\n const pathParts = getNormalizedObjectStoragePathParts(path);\n let tree: ITree | undefined = inputTree;\n while (tree?.entries !== undefined && pathParts.length > 0) {\n const part = pathParts.shift();\n const treeEntry = tree.entries.find((value) => {\n if (value.type === \"Tree\" && value.path === part) {\n return true;\n } else {\n return false;\n }\n });\n\n // this check is largely superfluous due to the same check being done\n // immediately above. the type system, however, is not aware of this.\n // so we must redundantly determine that the entry's type is \"Tree\"\n if (treeEntry?.type === \"Tree\") {\n tree = treeEntry.value;\n } else {\n tree = undefined;\n }\n }\n if (tree?.entries === undefined || pathParts.length !== 0) {\n throw new Error(\"path does not exist\");\n }\n return tree.entries.filter((e) => e.type === \"Blob\").map((e) => e.path);\n}\n"]}
@@ -1,9 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- *
5
- * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
- */
7
- export declare const pkgName = "@fluidframework/runtime-utils";
8
- export declare const pkgVersion = "1.4.0-121020";
9
- //# sourceMappingURL=packageVersion.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,kCAAkC,CAAC;AACvD,eAAO,MAAM,UAAU,iBAAiB,CAAC"}
@@ -1,12 +0,0 @@
1
- "use strict";
2
- /*!
3
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
- * Licensed under the MIT License.
5
- *
6
- * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.pkgVersion = exports.pkgName = void 0;
10
- exports.pkgName = "@fluidframework/runtime-utils";
11
- exports.pkgVersion = "1.4.0-121020";
12
- //# sourceMappingURL=packageVersion.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,+BAA+B,CAAC;AAC1C,QAAA,UAAU,GAAG,cAAc,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/runtime-utils\";\nexport const pkgVersion = \"1.4.0-121020\";\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"requestParser.js","sourceRoot":"","sources":["../src/requestParser.ts"],"names":[],"mappings":";;;AAMA;;GAEG;AACH,MAAa,aAAa;IA+BtB,YAAuC,OAA2B;QAA3B,YAAO,GAAP,OAAO,CAAoB;QAC9D,MAAM,eAAe,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACtD,IAAI,eAAe,IAAI,CAAC,EAAE;YACtB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;SAC5D;aAAM;YACH,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;SACnB;IACL,CAAC;IArCD;;;OAGG;IACI,MAAM,CAAC,YAAY,CAAC,GAAW;QAClC,MAAM,eAAe,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAA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CAAC,MAAM,CAAC;QACtC,IAAI,iBAAiB,GAAG,CAAC,IAAI,iBAAiB,GAAG,OAAO,EAAE;YACtD,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;SAC5C;QACD,IAAI,iBAAiB,KAAK,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YACzD,OAAO;gBACH,GAAG,EAAE,IAAI,IAAI,CAAC,KAAK,EAAE;gBACrB,OAAO,EAAE,IAAI,CAAC,OAAO;aACxB,CAAC;SACL;QACD,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACrE,OAAO;YACH,GAAG,EAAE,IAAI,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE;YACvD,OAAO,EAAE,IAAI,CAAC,OAAO;SACxB,CAAC;IACN,CAAC;CACJ;AA/FD,sCA+FC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { IRequest, IRequestHeader } from \"@fluidframework/core-interfaces\";\n\n/**\n * The Request Parser takes an IRequest provides parsing and sub request creation\n */\nexport class RequestParser implements IRequest {\n /**\n * Splits the path of the url and decodes each path part\n * @param url - the url to get path parts of\n */\n public static getPathParts(url: string): readonly string[] {\n const queryStartIndex = url.indexOf(\"?\");\n return url\n .substring(0, queryStartIndex < 0 ? url.length : queryStartIndex)\n .split(\"/\")\n .reduce<string[]>(\n (pv, cv) => {\n if (cv !== undefined && cv.length > 0) {\n pv.push(decodeURIComponent(cv));\n }\n return pv;\n },\n []);\n }\n\n private requestPathParts: readonly string[] | undefined;\n public readonly query: string;\n\n public static create(request: Readonly<IRequest>) {\n // Perf optimizations.\n if (request instanceof RequestParser) {\n return request;\n }\n return new RequestParser(request);\n }\n\n protected constructor(private readonly request: Readonly<IRequest>) {\n const queryStartIndex = this.request.url.indexOf(\"?\");\n if (queryStartIndex >= 0) {\n this.query = this.request.url.substring(queryStartIndex);\n } else {\n this.query = \"\";\n }\n }\n\n public get url(): string {\n return this.request.url;\n }\n\n public get headers(): IRequestHeader | undefined {\n return this.request.headers;\n }\n\n /**\n * Returns the decoded path parts of the request's url\n */\n public get pathParts(): readonly string[] {\n if (this.requestPathParts === undefined) {\n this.requestPathParts = RequestParser.getPathParts(this.url);\n }\n return this.requestPathParts;\n }\n\n /**\n * Returns true if it's a terminating path, i.e. no more elements after `elements` entries and empty query.\n * @param elements - number of elements in path\n */\n public isLeaf(elements: number) {\n return this.query === \"\" && this.pathParts.length === elements;\n }\n\n /**\n * Creates a sub request starting at a specific path part of this request's url\n * The sub request url always has a leading slash, and always include query params if original url has any\n * e.g. original url is /a/b/?queryParams, createSubRequest(0) is /a/b/?queryParams\n * createSubRequest(1) is /b/?queryParams\n * createSubRequest(2) is /?queryParams\n * createSubRequest(n) where n is bigger than parts length, e.g. 2, or n is less than 0 will throw an exception\n *\n * note: query params are not counted towards path parts.\n *\n * @param startingPathIndex - The index of the first path part of the sub request\n */\n public createSubRequest(startingPathIndex: number): IRequest {\n const pathLen = this.pathParts.length;\n if (startingPathIndex < 0 || startingPathIndex > pathLen) {\n throw new Error(\"incorrect sub-request\");\n }\n if (startingPathIndex === pathLen && this.url.includes(\"?\")) {\n return {\n url: `/${this.query}`,\n headers: this.headers,\n };\n }\n const path = `/${this.pathParts.slice(startingPathIndex).join(\"/\")}`;\n return {\n url: this.query === \"\" ? path : `${path}/${this.query}`,\n headers: this.headers,\n };\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"runtimeFactoryHelper.js","sourceRoot":"","sources":["../src/runtimeFactoryHelper.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AASH,MAAsB,oBAAoB;IACtC,IAAW,eAAe,KAAK,OAAO,IAAI,CAAC,CAAC,CAAC;IAEtC,KAAK,CAAC,kBAAkB,CAC3B,OAA0B,EAC1B,QAAkB;QAElB,MAAM,YAAY,GAAG,QAAQ,KAAK,SAAS;YACvC,CAAC,CAAC,OAAO,CAAC,QAAQ,KAAK,IAAI;YAC3B,CAAC,CAAC,QAAQ,CAAC;QACf,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;QAEhE,IAAI,YAAY,EAAE;YACd,MAAM,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;SAC/C;aAAM;YACH,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;SAC5C;QAED,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QACnC,OAAO,OAAO,CAAC;IACnB,CAAC;IAGM,KAAK,CAAC,oBAAoB,CAAC,QAAW,IAAkB,CAAC;IACzD,KAAK,CAAC,uBAAuB,CAAC,QAAW,IAAkB,CAAC;IAC5D,KAAK,CAAC,cAAc,CAAC,QAAW,IAAkB,CAAC;CAC7D;AA1BD,oDA0BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n IContainerContext,\n IRuntime,\n IRuntimeFactory,\n} from \"@fluidframework/container-definitions\";\nimport { IContainerRuntime } from \"@fluidframework/container-runtime-definitions\";\n\nexport abstract class RuntimeFactoryHelper<T = IContainerRuntime> implements IRuntimeFactory {\n public get IRuntimeFactory() { return this; }\n\n public async instantiateRuntime(\n context: IContainerContext,\n existing?: boolean,\n ): Promise<IRuntime> {\n const fromExisting = existing === undefined\n ? context.existing === true\n : existing;\n const runtime = await this.preInitialize(context, fromExisting);\n\n if (fromExisting) {\n await this.instantiateFromExisting(runtime);\n } else {\n await this.instantiateFirstTime(runtime);\n }\n\n await this.hasInitialized(runtime);\n return runtime;\n }\n\n public abstract preInitialize(context: IContainerContext, existing: boolean): Promise<IRuntime & T>;\n public async instantiateFirstTime(_runtime: T): Promise<void> {}\n public async instantiateFromExisting(_runtime: T): Promise<void> {}\n public async hasInitialized(_runtime: T): Promise<void> {}\n}\n"]}
@@ -1,8 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- export { ISummarizerNodeRootContract, RefreshSummaryResult } from "./summarizerNodeUtils";
6
- export { IRootSummarizerNode, createRootSummarizerNode } from "./summarizerNode";
7
- export { IRootSummarizerNodeWithGC, createRootSummarizerNodeWithGC } from "./summarizerNodeWithGc";
8
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/summarizerNode/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,2BAA2B,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC1F,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAAE,yBAAyB,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC"}
@@ -1,12 +0,0 @@
1
- "use strict";
2
- /*!
3
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
- * Licensed under the MIT License.
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.createRootSummarizerNodeWithGC = exports.createRootSummarizerNode = void 0;
8
- var summarizerNode_1 = require("./summarizerNode");
9
- Object.defineProperty(exports, "createRootSummarizerNode", { enumerable: true, get: function () { return summarizerNode_1.createRootSummarizerNode; } });
10
- var summarizerNodeWithGc_1 = require("./summarizerNodeWithGc");
11
- Object.defineProperty(exports, "createRootSummarizerNodeWithGC", { enumerable: true, get: function () { return summarizerNodeWithGc_1.createRootSummarizerNodeWithGC; } });
12
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/summarizerNode/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,mDAAiF;AAAnD,0HAAA,wBAAwB,OAAA;AACtD,+DAAmG;AAA/D,sIAAA,8BAA8B,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { ISummarizerNodeRootContract, RefreshSummaryResult } from \"./summarizerNodeUtils\";\nexport { IRootSummarizerNode, createRootSummarizerNode } from \"./summarizerNode\";\nexport { IRootSummarizerNodeWithGC, createRootSummarizerNodeWithGC } from \"./summarizerNodeWithGc\";\n"]}
@@ -1,139 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import { ISummarizerNode, ISummarizerNodeConfig, ISummarizeResult, CreateChildSummarizerNodeParam, SummarizeInternalFn, ITelemetryContext } from "@fluidframework/runtime-definitions";
6
- import { ISequencedDocumentMessage, ISnapshotTree } from "@fluidframework/protocol-definitions";
7
- import { ITelemetryLogger } from "@fluidframework/common-definitions";
8
- import { ReadAndParseBlob } from "../utils";
9
- import { EscapedPath, ICreateChildDetails, IInitialSummary, ISummarizerNodeRootContract, RefreshSummaryResult, SummaryNode } from "./summarizerNodeUtils";
10
- export interface IRootSummarizerNode extends ISummarizerNode, ISummarizerNodeRootContract {
11
- }
12
- /**
13
- * Encapsulates the summarizing work and state of an individual tree node in the
14
- * summary tree. It tracks changes and allows for optimizations when unchanged, or
15
- * can allow for fallback summaries to be generated when an error is encountered.
16
- * Usage is for the root node to call startSummary first to begin tracking a WIP
17
- * (work in progress) summary. Then all nodes will call summarize to summaries their
18
- * individual parts. Once completed and uploaded to storage, the root node will call
19
- * completeSummary or clearSummary to clear the WIP summary tracking state if something
20
- * went wrong. The SummarizerNodes will track all pending summaries that have been
21
- * recorded by the completeSummary call. When one of them is acked, the root node should
22
- * call refreshLatestSummary to inform the tree of SummarizerNodes of the new baseline
23
- * latest successful summary.
24
- */
25
- export declare class SummarizerNode implements IRootSummarizerNode {
26
- protected readonly defaultLogger: ITelemetryLogger;
27
- private readonly summarizeInternalFn;
28
- private _changeSequenceNumber;
29
- /** Undefined means created without summary */
30
- private _latestSummary?;
31
- private readonly initialSummary?;
32
- protected wipSummaryLogger?: ITelemetryLogger | undefined;
33
- /**
34
- * The reference sequence number of the most recent acked summary.
35
- * Returns 0 if there is not yet an acked summary.
36
- */
37
- get referenceSequenceNumber(): number;
38
- protected readonly children: Map<string, SummarizerNode>;
39
- protected readonly pendingSummaries: Map<string, SummaryNode>;
40
- private readonly outstandingOps;
41
- private wipReferenceSequenceNumber;
42
- private wipLocalPaths;
43
- private wipSkipRecursion;
44
- startSummary(referenceSequenceNumber: number, summaryLogger: ITelemetryLogger): void;
45
- summarize(fullTree: boolean, trackState?: boolean, telemetryContext?: ITelemetryContext): Promise<ISummarizeResult>;
46
- /**
47
- * Complete the WIP summary for the given proposalHandle
48
- */
49
- completeSummary(proposalHandle: string): void;
50
- /**
51
- * Recursive implementation for completeSummary, with additional internal-only parameters
52
- */
53
- protected completeSummaryCore(proposalHandle: string, parentPath: EscapedPath | undefined, parentSkipRecursion: boolean): void;
54
- clearSummary(): void;
55
- /**
56
- * Refreshes the latest summary tracked by this node. If we have a pending summary for the given proposal handle,
57
- * it becomes the latest summary. If the current summary is already ahead (e.g., loaded from a service summary),
58
- * we skip the update. Otherwise, we get the snapshot by calling `getSnapshot` and update latest
59
- * summary based off of that.
60
- * @returns A RefreshSummaryResult type which returns information based on the following three scenarios:
61
- * 1. The latest summary was not udpated.
62
- * 2. The latest summary was updated and the summary corresponding to the params was being tracked.
63
- * 3. The latest summary was updated but the summary corresponding to the params was not tracked. In this
64
- * case, the latest summary is updated based on the downloaded snapshot which is also returned.
65
- */
66
- refreshLatestSummary(proposalHandle: string | undefined, summaryRefSeq: number, getSnapshot: () => Promise<ISnapshotTree>, readAndParseBlob: ReadAndParseBlob, correlatedSummaryLogger: ITelemetryLogger): Promise<RefreshSummaryResult>;
67
- protected refreshLatestSummaryFromPending(proposalHandle: string, referenceSequenceNumber: number): void;
68
- protected refreshLatestSummaryFromSnapshot(referenceSequenceNumber: number, snapshotTree: ISnapshotTree, basePath: EscapedPath | undefined, localPath: EscapedPath, correlatedSummaryLogger: ITelemetryLogger, readAndParseBlob: ReadAndParseBlob): Promise<void>;
69
- private refreshLatestSummaryCore;
70
- loadBaseSummaryWithoutDifferential(snapshot: ISnapshotTree): void;
71
- loadBaseSummary(snapshot: ISnapshotTree, readAndParseBlob: ReadAndParseBlob): Promise<{
72
- baseSummary: ISnapshotTree;
73
- outstandingOps: ISequencedDocumentMessage[];
74
- }>;
75
- recordChange(op: ISequencedDocumentMessage): void;
76
- invalidate(sequenceNumber: number): void;
77
- /**
78
- * True if a change has been recorded with sequence number exceeding
79
- * the latest successfully acked summary reference sequence number.
80
- * False implies that the previous summary can be reused.
81
- */
82
- protected hasChanged(): boolean;
83
- get latestSummary(): Readonly<SummaryNode> | undefined;
84
- private readonly canReuseHandle;
85
- private readonly throwOnError;
86
- /**
87
- * Sequence number of latest tracked op. This updates during recordChange,
88
- * but not for invalidate since we don't have the op. If this drifts from
89
- * changeSequenceNumber and we try to create a differential summary we assert.
90
- */
91
- private trackingSequenceNumber;
92
- /**
93
- * Do not call constructor directly.
94
- * Use createRootSummarizerNode to create root node, or createChild to create child nodes.
95
- */
96
- constructor(defaultLogger: ITelemetryLogger, summarizeInternalFn: SummarizeInternalFn, config: ISummarizerNodeConfig, _changeSequenceNumber: number,
97
- /** Undefined means created without summary */
98
- _latestSummary?: SummaryNode | undefined, initialSummary?: IInitialSummary | undefined, wipSummaryLogger?: ITelemetryLogger | undefined);
99
- createChild(
100
- /** Summarize function */
101
- summarizeInternalFn: SummarizeInternalFn,
102
- /** Initial id or path part of this node */
103
- id: string,
104
- /**
105
- * Information needed to create the node.
106
- * If it is from a base summary, it will assert that a summary has been seen.
107
- * Attach information if it is created from an attach op.
108
- */
109
- createParam: CreateChildSummarizerNodeParam, config?: ISummarizerNodeConfig): ISummarizerNode;
110
- getChild(id: string): ISummarizerNode | undefined;
111
- /**
112
- * Returns the details needed to create a child node.
113
- * @param id - Initial id or path part of the child node.
114
- * @param createParam - Information needed to create the node.
115
- * @returns the details needed to create the child node.
116
- */
117
- protected getCreateDetailsForChild(id: string, createParam: CreateChildSummarizerNodeParam): ICreateChildDetails;
118
- /**
119
- * Updates the state of the child if required. For example, if a summary is currently being tracked, the child's
120
- * summary tracking state needs to be updated too.
121
- * @param child - The child node whose state is to be updated.
122
- */
123
- protected maybeUpdateChildState(child: SummarizerNode): void;
124
- /**
125
- * Tells whether summary tracking is in progress. True if "startSummary" API is called before summarize.
126
- */
127
- protected isTrackingInProgress(): boolean;
128
- }
129
- /**
130
- * Creates a root summarizer node.
131
- * @param logger - Logger to use within SummarizerNode
132
- * @param summarizeInternalFn - Function to generate summary
133
- * @param changeSequenceNumber - Sequence number of latest change to new node/subtree
134
- * @param referenceSequenceNumber - Reference sequence number of last acked summary,
135
- * or undefined if not loaded from summary
136
- * @param config - Configure behavior of summarizer node
137
- */
138
- export declare const createRootSummarizerNode: (logger: ITelemetryLogger, summarizeInternalFn: SummarizeInternalFn, changeSequenceNumber: number, referenceSequenceNumber: number | undefined, config?: ISummarizerNodeConfig) => IRootSummarizerNode;
139
- //# sourceMappingURL=summarizerNode.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"summarizerNode.d.ts","sourceRoot":"","sources":["../../src/summarizerNode/summarizerNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,eAAe,EACf,qBAAqB,EACrB,gBAAgB,EAEhB,8BAA8B,EAE9B,mBAAmB,EACnB,iBAAiB,EACpB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACH,yBAAyB,EAEzB,aAAa,EAEhB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAGtE,OAAO,EAAE,gBAA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