@fluidframework/runtime-utils 2.0.0-internal.3.0.0 → 2.0.0-internal.3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/.eslintrc.js +5 -7
  2. package/.mocharc.js +2 -2
  3. package/api-extractor.json +2 -2
  4. package/dist/dataStoreHandleContextUtils.d.ts.map +1 -1
  5. package/dist/dataStoreHandleContextUtils.js +3 -1
  6. package/dist/dataStoreHandleContextUtils.js.map +1 -1
  7. package/dist/dataStoreHelpers.d.ts.map +1 -1
  8. package/dist/dataStoreHelpers.js +23 -7
  9. package/dist/dataStoreHelpers.js.map +1 -1
  10. package/dist/index.d.ts +1 -1
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js.map +1 -1
  13. package/dist/objectstoragepartition.d.ts.map +1 -1
  14. package/dist/objectstoragepartition.js.map +1 -1
  15. package/dist/objectstorageutils.d.ts.map +1 -1
  16. package/dist/objectstorageutils.js.map +1 -1
  17. package/dist/packageVersion.d.ts +1 -1
  18. package/dist/packageVersion.js +1 -1
  19. package/dist/packageVersion.js.map +1 -1
  20. package/dist/requestParser.d.ts.map +1 -1
  21. package/dist/requestParser.js.map +1 -1
  22. package/dist/runtimeFactoryHelper.d.ts.map +1 -1
  23. package/dist/runtimeFactoryHelper.js +6 -2
  24. package/dist/runtimeFactoryHelper.js.map +1 -1
  25. package/dist/summarizerNode/index.d.ts +1 -1
  26. package/dist/summarizerNode/index.d.ts.map +1 -1
  27. package/dist/summarizerNode/index.js.map +1 -1
  28. package/dist/summarizerNode/summarizerNode.d.ts +4 -5
  29. package/dist/summarizerNode/summarizerNode.d.ts.map +1 -1
  30. package/dist/summarizerNode/summarizerNode.js +33 -13
  31. package/dist/summarizerNode/summarizerNode.js.map +1 -1
  32. package/dist/summarizerNode/summarizerNodeUtils.d.ts +14 -5
  33. package/dist/summarizerNode/summarizerNodeUtils.d.ts.map +1 -1
  34. package/dist/summarizerNode/summarizerNodeUtils.js.map +1 -1
  35. package/dist/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
  36. package/dist/summarizerNode/summarizerNodeWithGc.js +23 -13
  37. package/dist/summarizerNode/summarizerNodeWithGc.js.map +1 -1
  38. package/dist/summaryUtils.d.ts.map +1 -1
  39. package/dist/summaryUtils.js +3 -2
  40. package/dist/summaryUtils.js.map +1 -1
  41. package/dist/utils.d.ts.map +1 -1
  42. package/dist/utils.js.map +1 -1
  43. package/lib/dataStoreHandleContextUtils.d.ts.map +1 -1
  44. package/lib/dataStoreHandleContextUtils.js +3 -1
  45. package/lib/dataStoreHandleContextUtils.js.map +1 -1
  46. package/lib/dataStoreHelpers.d.ts.map +1 -1
  47. package/lib/dataStoreHelpers.js +23 -7
  48. package/lib/dataStoreHelpers.js.map +1 -1
  49. package/lib/index.d.ts +1 -1
  50. package/lib/index.d.ts.map +1 -1
  51. package/lib/index.js.map +1 -1
  52. package/lib/objectstoragepartition.d.ts.map +1 -1
  53. package/lib/objectstoragepartition.js.map +1 -1
  54. package/lib/objectstorageutils.d.ts.map +1 -1
  55. package/lib/objectstorageutils.js.map +1 -1
  56. package/lib/packageVersion.d.ts +1 -1
  57. package/lib/packageVersion.js +1 -1
  58. package/lib/packageVersion.js.map +1 -1
  59. package/lib/requestParser.d.ts.map +1 -1
  60. package/lib/requestParser.js.map +1 -1
  61. package/lib/runtimeFactoryHelper.d.ts.map +1 -1
  62. package/lib/runtimeFactoryHelper.js +6 -2
  63. package/lib/runtimeFactoryHelper.js.map +1 -1
  64. package/lib/summarizerNode/index.d.ts +1 -1
  65. package/lib/summarizerNode/index.d.ts.map +1 -1
  66. package/lib/summarizerNode/index.js.map +1 -1
  67. package/lib/summarizerNode/summarizerNode.d.ts +4 -5
  68. package/lib/summarizerNode/summarizerNode.d.ts.map +1 -1
  69. package/lib/summarizerNode/summarizerNode.js +33 -13
  70. package/lib/summarizerNode/summarizerNode.js.map +1 -1
  71. package/lib/summarizerNode/summarizerNodeUtils.d.ts +14 -5
  72. package/lib/summarizerNode/summarizerNodeUtils.d.ts.map +1 -1
  73. package/lib/summarizerNode/summarizerNodeUtils.js.map +1 -1
  74. package/lib/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
  75. package/lib/summarizerNode/summarizerNodeWithGc.js +24 -14
  76. package/lib/summarizerNode/summarizerNodeWithGc.js.map +1 -1
  77. package/lib/summaryUtils.d.ts.map +1 -1
  78. package/lib/summaryUtils.js +3 -2
  79. package/lib/summaryUtils.js.map +1 -1
  80. package/lib/utils.d.ts.map +1 -1
  81. package/lib/utils.js.map +1 -1
  82. package/package.json +110 -104
  83. package/prettier.config.cjs +1 -1
  84. package/src/dataStoreHandleContextUtils.ts +23 -16
  85. package/src/dataStoreHelpers.ts +104 -86
  86. package/src/index.ts +2 -1
  87. package/src/objectstoragepartition.ts +13 -13
  88. package/src/objectstorageutils.ts +31 -28
  89. package/src/packageVersion.ts +1 -1
  90. package/src/requestParser.ts +80 -82
  91. package/src/runtimeFactoryHelper.ts +24 -17
  92. package/src/summarizerNode/index.ts +5 -1
  93. package/src/summarizerNode/summarizerNode.ts +602 -549
  94. package/src/summarizerNode/summarizerNodeUtils.ts +163 -150
  95. package/src/summarizerNode/summarizerNodeWithGc.ts +508 -470
  96. package/src/summaryUtils.ts +299 -291
  97. package/src/utils.ts +6 -6
  98. package/tsconfig.esnext.json +6 -6
  99. package/tsconfig.json +8 -12
@@ -1 +1 @@
1
- {"version":3,"file":"summarizerNodeWithGc.js","sourceRoot":"","sources":["../../src/summarizerNode/summarizerNodeWithGc.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAExI,OAAO,EAEH,SAAS,GASZ,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAAE,c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C,mBAAmB,CAAC,CAAC;IACrF,CAAC;CACJ;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAC1C,MAAwB,EACxB,mBAAwC,EACxC,oBAA4B,EAC5B,uBAA2C,EAC3C,SAAsC,EAAE,EACxC,WAAmE,EACnE,kBAAiE,EACxC,EAAE,CAAC,IAAI,oBAAoB,CACpD,MAAM,EACN,mBAAmB,EACnB,MAAM,EACN,oBAAoB,EACpB,uBAAuB,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,aAAa,CAAC,uBAAuB,CAAC,EACtG,SAAS,CAAC,oBAAoB,EAC9B,SAAS,CAAC,sBAAsB,EAChC,WAAW,EACX,kBAAkB,CACrB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, LazyPromise } from \"@fluidframework/common-utils\";\nimport { cloneGCData, getGCDataFromSnapshot, runGarbageCollection, unpackChildNodesGCDetails } from \"@fluidframework/garbage-collector\";\nimport { ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport {\n CreateChildSummarizerNodeParam,\n gcTreeKey,\n IGarbageCollectionData,\n IGarbageCollectionDetailsBase,\n ISummarizeInternalResult,\n ISummarizeResult,\n ISummarizerNodeConfigWithGC,\n ISummarizerNodeWithGC,\n SummarizeInternalFn,\n ITelemetryContext,\n} from \"@fluidframework/runtime-definitions\";\nimport { ReadAndParseBlob } from \"../utils\";\nimport { SummarizerNode } from \"./summarizerNode\";\nimport {\n EscapedPath,\n ICreateChildDetails,\n IInitialSummary,\n ISummarizerNodeRootContract,\n parseSummaryForSubtrees,\n SummaryNode,\n} from \"./summarizerNodeUtils\";\n\nexport interface IRootSummarizerNodeWithGC extends ISummarizerNodeWithGC, ISummarizerNodeRootContract {}\n\n// Extend SummaryNode to add used routes tracking to it.\nclass SummaryNodeWithGC extends SummaryNode {\n constructor(\n public readonly serializedUsedRoutes: string,\n summary: {\n readonly referenceSequenceNumber: number;\n readonly basePath: EscapedPath | undefined;\n readonly localPath: EscapedPath;\n additionalPath?: EscapedPath;\n },\n ) {\n super(summary);\n }\n}\n\n/**\n * Extends the functionality of SummarizerNode to manage this node's garbage collection data:\n *\n * - Adds a new API `getGCData` to return GC data of this node.\n *\n * - Caches the result of `getGCData` to be used if nothing changes between summaries.\n *\n * - Manages the used routes of this node. These are used to identify if this node is referenced in the document\n * and to determine if the node's used state changed since last summary.\n *\n * - Adds trackState param to summarize. If trackState is false, it bypasses the SummarizerNode and calls\n * directly into summarizeInternal method.\n */\nexport class SummarizerNodeWithGC extends SummarizerNode implements IRootSummarizerNodeWithGC {\n // Tracks the work-in-progress used routes during summary.\n private wipSerializedUsedRoutes: string | undefined;\n\n // This is the last known used routes of this node as seen by the server as part of a summary.\n private referenceUsedRoutes: string[] | undefined;\n\n // The base GC details of this node used to initialize the GC state.\n private readonly baseGCDetailsP: LazyPromise<IGarbageCollectionDetailsBase>;\n\n // Keeps track of whether we have loaded the base details to ensure that we on;y do it once.\n private baseGCDetailsLoaded: boolean = false;\n\n private gcData: IGarbageCollectionData | undefined;\n\n // Set used routes to have self route by default. This makes the node referenced by default. This is done to ensure\n // that this node is not marked as collected when running GC has been disabled. Once, the option to disable GC is\n // removed (from runGC flag in IContainerRuntimeOptions), this should be changed to be have no routes by default.\n private usedRoutes: string[] = [\"\"];\n\n // True if GC is disabled for this node. If so, do not track GC specific state for a summary.\n private readonly gcDisabled: boolean;\n\n /**\n * Do not call constructor directly.\n * Use createRootSummarizerNodeWithGC to create root node, or createChild to create child nodes.\n */\n public constructor(\n logger: ITelemetryLogger,\n private readonly summarizeFn: (\n fullTree: boolean,\n trackState: boolean,\n telemetryContext?: ITelemetryContext,\n ) => Promise<ISummarizeInternalResult>,\n config: ISummarizerNodeConfigWithGC,\n changeSequenceNumber: number,\n /** Undefined means created without summary */\n latestSummary?: SummaryNode,\n initialSummary?: IInitialSummary,\n wipSummaryLogger?: ITelemetryLogger,\n private readonly getGCDataFn?: (fullGC?: boolean) => Promise<IGarbageCollectionData>,\n getBaseGCDetailsFn?: () => Promise<IGarbageCollectionDetailsBase>,\n ) {\n super(\n logger,\n async (fullTree: boolean, _trackState: boolean, telemetryContext?: ITelemetryContext) =>\n summarizeFn(fullTree, true /* trackState */, telemetryContext),\n config,\n changeSequenceNumber,\n latestSummary,\n initialSummary,\n wipSummaryLogger,\n );\n\n this.gcDisabled = config.gcDisabled === true;\n\n this.baseGCDetailsP = new LazyPromise(async () => {\n return (await getBaseGCDetailsFn?.()) ?? { usedRoutes: [] };\n });\n }\n\n /**\n * Loads state from this node's initial GC summary details. This contains the following data from the last summary\n * seen by the server for this client:\n * - usedRoutes: This is used to figure out if the used state of this node changed since last summary.\n * - gcData: The garbage collection data of this node that is required for running GC.\n */\n private async loadBaseGCDetails() {\n if (this.baseGCDetailsLoaded) {\n return;\n }\n const baseGCDetails = await this.baseGCDetailsP;\n\n // Possible race - If there were parallel calls to loadBaseGCDetails, we want to make sure that we update\n // the state from the base details only once.\n if (this.baseGCDetailsLoaded) {\n return;\n }\n this.baseGCDetailsLoaded = true;\n\n // Update GC data, used routes and reference used routes. The used routes are sorted because they are compared\n // across GC runs to check if they changed. Sorting ensures that the elements are in the same order.\n // If the GC details has GC data, initialize our GC data from it.\n if (baseGCDetails.gcData !== undefined) {\n this.gcData = cloneGCData(baseGCDetails.gcData);\n }\n if (baseGCDetails.usedRoutes !== undefined) {\n this.usedRoutes = Array.from(baseGCDetails.usedRoutes).sort();\n this.referenceUsedRoutes = Array.from(baseGCDetails.usedRoutes).sort()\n }\n }\n\n public async summarize(\n fullTree: boolean,\n trackState: boolean = true,\n telemetryContext?: ITelemetryContext,\n ): Promise<ISummarizeResult> {\n // If GC is not disabled and we are tracking a summary, GC should have run and updated the used routes for this\n // summary by calling updateUsedRoutes which sets wipSerializedUsedRoutes.\n if (!this.gcDisabled && this.isTrackingInProgress()) {\n assert(this.wipSerializedUsedRoutes !== undefined,\n 0x1b1 /* \"wip used routes should be set if tracking a summary\" */);\n }\n\n // If trackState is true, get summary from base summarizer node which tracks summary state.\n // If trackState is false, get summary from summarizeInternal.\n return trackState\n ? super.summarize(fullTree, true /* trackState */, telemetryContext)\n : this.summarizeFn(fullTree, trackState, telemetryContext);\n }\n\n /**\n * Returns the GC data of this node. If nothing has changed since last summary, it tries to reuse the data from\n * the previous summary. Else, it gets new GC data from the underlying Fluid object.\n * @param fullGC - true to bypass optimizations and force full generation of GC data.\n */\n public async getGCData(fullGC: boolean = false): Promise<IGarbageCollectionData> {\n assert(!this.gcDisabled, 0x1b2 /* \"Getting GC data should not be called when GC is disabled!\" */);\n assert(this.getGCDataFn !== undefined, 0x1b3 /* \"GC data cannot be retrieved without getGCDataFn\" */);\n\n // Load GC details from the initial summary, if not already loaded. If this is the first time this function is\n // called and the node's data has not changed since last summary, the GC data in initial details is returned.\n await this.loadBaseGCDetails();\n\n // If there is no new data since last summary and we have GC data from the previous run, return it. The previous\n // GC data may not be available if loaded from a snapshot with either GC disabled or before GC was added.\n // Note - canReuseHandle is checked to be consistent with summarize - generate GC data for nodes for which\n // summary must be generated.\n if (this.canReuseHandle && !fullGC && !this.hasDataChanged() && this.gcData !== undefined) {\n return cloneGCData(this.gcData);\n }\n\n const gcData = await this.getGCDataFn(fullGC);\n this.gcData = cloneGCData(gcData);\n return gcData;\n }\n\n /**\n * Called during the start of a summary. Updates the work-in-progress used routes.\n */\n public startSummary(referenceSequenceNumber: number, summaryLogger: ITelemetryLogger) {\n // If GC is disabled, skip setting wip used routes since we should not track GC state.\n if (!this.gcDisabled) {\n assert(\n this.wipSerializedUsedRoutes === undefined,\n 0x1b4 /* \"We should not already be tracking used routes when to track a new summary\" */);\n }\n super.startSummary(referenceSequenceNumber, summaryLogger);\n }\n\n /**\n * Called after summary has been uploaded to the server. Add the work-in-progress state to the pending\n * summary queue. We track this until we get an ack from the server for this summary.\n */\n protected completeSummaryCore(\n proposalHandle: string,\n parentPath: EscapedPath | undefined,\n parentSkipRecursion: boolean,\n ) {\n let wipSerializedUsedRoutes: string | undefined;\n // If GC is disabled, don't set wip used routes.\n if (!this.gcDisabled) {\n wipSerializedUsedRoutes = this.wipSerializedUsedRoutes;\n assert(wipSerializedUsedRoutes !== undefined, 0x1b5 /* \"We should have been tracking used routes\" */);\n }\n\n super.completeSummaryCore(proposalHandle, parentPath, parentSkipRecursion);\n\n // If GC is disabled, skip setting pending summary with GC state.\n if (!this.gcDisabled) {\n const summaryNode = this.pendingSummaries.get(proposalHandle);\n if (summaryNode !== undefined) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const summaryNodeWithGC = new SummaryNodeWithGC(wipSerializedUsedRoutes!, summaryNode);\n this.pendingSummaries.set(proposalHandle, summaryNodeWithGC);\n }\n }\n }\n\n /**\n * Clears the work-in-progress state.\n */\n public clearSummary() {\n this.wipSerializedUsedRoutes = undefined;\n super.clearSummary();\n }\n\n /**\n * Called when we get an ack from the server for a summary we sent. Update the reference state of this node\n * from the state in the pending summary queue.\n */\n protected refreshLatestSummaryFromPending(\n proposalHandle: string,\n referenceSequenceNumber: number,\n ): void {\n // If GC is disabled, skip setting referenced used routes since we are not tracking GC state.\n if (!this.gcDisabled) {\n const summaryNode = this.pendingSummaries.get(proposalHandle) as SummaryNodeWithGC;\n if (summaryNode?.serializedUsedRoutes !== undefined) {\n this.referenceUsedRoutes = JSON.parse(summaryNode.serializedUsedRoutes);\n }\n }\n\n return super.refreshLatestSummaryFromPending(proposalHandle, referenceSequenceNumber);\n }\n\n /**\n * Called when we need to upload the reference state from the given summary.\n */\n protected async refreshLatestSummaryFromSnapshot(\n referenceSequenceNumber: number,\n snapshotTree: ISnapshotTree,\n basePath: EscapedPath | undefined,\n localPath: EscapedPath,\n correlatedSummaryLogger: ITelemetryLogger,\n readAndParseBlob: ReadAndParseBlob,\n ): Promise<void> {\n await this.refreshGCStateFromSnapshot(referenceSequenceNumber, snapshotTree, readAndParseBlob);\n return super.refreshLatestSummaryFromSnapshot(\n referenceSequenceNumber,\n snapshotTree,\n basePath,\n localPath,\n correlatedSummaryLogger,\n readAndParseBlob,\n );\n }\n\n /**\n * Updates GC state from the given snapshot if GC is enabled and the snapshot is newer than the one this node\n * is tracking.\n */\n private async refreshGCStateFromSnapshot(\n referenceSequenceNumber: number,\n snapshotTree: ISnapshotTree,\n readAndParseBlob: ReadAndParseBlob,\n ): Promise<void> {\n // If GC is disabled or we have seen a newer summary, skip updating GC state.\n if (this.gcDisabled || this.referenceSequenceNumber >= referenceSequenceNumber) {\n return;\n }\n\n // Load the base GC details before proceeding because if that happens later it can overwrite the GC details\n // written by the following code.\n await this.loadBaseGCDetails();\n\n // Possible re-entrancy. We may already have processed this while loading base GC details.\n if (this.referenceSequenceNumber >= referenceSequenceNumber) {\n return;\n }\n\n /**\n * GC data is written at root of the snapshot tree under \"gc\" sub-tree. This data needs to be propagated to\n * all the nodes in the container.\n * The root summarizer node reads the GC data from the \"gc\" sub-tree, runs GC on it to get used routes in\n * the container and updates its GC data and referenced used routes. It then gets the GC data and used\n * routes of all its children and adds it to their snapshot tree.\n * All the other nodes gets the GC data and used routes from their snapshot tree and updates their state.\n * They get the GC data and used routes of their children and add it to their snapshot tree and so on.\n *\n * Note that if the snapshot does not have GC tree, GC data will be set to undefined and used routes will be\n * set to self-route (meaning referenced) for all nodes. This is important because the GC data needs to be\n * regenerated in the next summary.\n */\n let gcDetails: IGarbageCollectionDetailsBase | undefined;\n const gcSnapshotTree = snapshotTree.trees[gcTreeKey];\n if (gcSnapshotTree !== undefined) {\n // If there is a GC tree in the snapshot, this is the root summarizer node. Read GC data from the tree\n // process it as explained above.\n const gcSnapshotData = await getGCDataFromSnapshot(gcSnapshotTree, readAndParseBlob);\n\n const gcNodes: { [id: string]: string[]; } = {};\n for (const [nodeId, nodeData] of Object.entries(gcSnapshotData.gcState.gcNodes)) {\n gcNodes[nodeId] = Array.from(nodeData.outboundRoutes);\n }\n // Run GC on the nodes in the snapshot to get the used routes for each node in the container.\n const usedRoutes = runGarbageCollection(gcNodes, [\"/\"]).referencedNodeIds;\n gcDetails = { gcData: { gcNodes }, usedRoutes };\n } else {\n // If there is a GC blob in the snapshot, it's a non-root summarizer nodes - The root summarizer node\n // writes GC blob in the snapshot of child nodes. Get GC data and used routes from the blob.\n const gcDetailsBlob = snapshotTree.blobs[gcTreeKey];\n if (gcDetailsBlob !== undefined) {\n gcDetails = JSON.parse(gcDetailsBlob) as IGarbageCollectionDetailsBase;\n }\n }\n\n // Update this node to the same GC state it was when the ack corresponding to this summary was processed.\n this.gcData = gcDetails?.gcData !== undefined ? cloneGCData(gcDetails.gcData) : undefined;\n this.referenceUsedRoutes = gcDetails?.usedRoutes !== undefined ? Array.from(gcDetails.usedRoutes) : undefined;\n // If there are no used routes in the GC details, set it to have self route which will make the node\n // referenced. This scenario can only happen if the snapshot is from a client where GC was not run or\n // disabled. In both the cases, the node should be referenced.\n this.usedRoutes = gcDetails?.usedRoutes !== undefined ? Array.from(gcDetails.usedRoutes) : [\"\"];\n\n if (gcDetails === undefined) {\n return;\n }\n\n // Generate the GC data and used routes of children GC nodes and add it to their snapshot tree.\n const gcDetailsMap = unpackChildNodesGCDetails(gcDetails);\n const { childrenTree } = parseSummaryForSubtrees(snapshotTree);\n gcDetailsMap.forEach((childGCDetails: IGarbageCollectionDetailsBase, childId: string) => {\n childrenTree.trees[childId].blobs[gcTreeKey] = JSON.stringify(childGCDetails);\n });\n }\n\n /**\n * Override the createChild method to return an instance of SummarizerNodeWithGC.\n */\n public createChild(\n /** Summarize function */\n summarizeInternalFn: SummarizeInternalFn,\n /** Initial id or path part of this node */\n id: string,\n /**\n * Information needed to create the node.\n * If it is from a base summary, it will assert that a summary has been seen.\n * Attach information if it is created from an attach op.\n */\n createParam: CreateChildSummarizerNodeParam,\n config: ISummarizerNodeConfigWithGC = {},\n getGCDataFn?: (fullGC?: boolean) => Promise<IGarbageCollectionData>,\n getBaseGCDetailsFn?: () => Promise<IGarbageCollectionDetailsBase>,\n ): ISummarizerNodeWithGC {\n assert(!this.children.has(id), 0x1b6 /* \"Create SummarizerNode child already exists\" */);\n\n /**\n * Update the child node's base GC details from this node's current GC details instead of updating from the base\n * GC details of this node. This will handle scenarios where the GC details was updated during refresh from\n * snapshot and the child node wasn't created then. If a child is created after that, its GC details should be\n * the one from the downloaded snapshot and not the base GC details.\n */\n const getChildBaseGCDetailsP = new LazyPromise<IGarbageCollectionDetailsBase>(async () => {\n // Ensure that the base GC details is loaded because a child can be created before GC runs which is when\n // base GC details is usually loaded.\n await this.loadBaseGCDetails();\n const childBaseGCDetails = unpackChildNodesGCDetails({ gcData: this.gcData, usedRoutes: this.usedRoutes });\n return childBaseGCDetails.get(id) ?? {};\n });\n\n const createDetails: ICreateChildDetails = this.getCreateDetailsForChild(id, createParam);\n const child = new SummarizerNodeWithGC(\n this.defaultLogger,\n summarizeInternalFn,\n {\n ...config,\n // Propagate our gcDisabled state to the child if its not explicity specified in child's config.\n gcDisabled: config.gcDisabled ?? this.gcDisabled,\n },\n createDetails.changeSequenceNumber,\n createDetails.latestSummary,\n createDetails.initialSummary,\n this.wipSummaryLogger,\n getGCDataFn,\n async () => getChildBaseGCDetailsP,\n );\n\n // There may be additional state that has to be updated in this child. For example, if a summary is being\n // tracked, the child's summary tracking state needs to be updated too.\n this.maybeUpdateChildState(child);\n\n this.children.set(id, child);\n return child;\n }\n\n /**\n * Deletes the child node with the given id.\n */\n public deleteChild(id: string): void {\n this.children.delete(id);\n }\n\n /**\n * Override the getChild method to return an instance of SummarizerNodeWithGC.\n */\n public getChild(id: string): ISummarizerNodeWithGC | undefined {\n return this.children.get(id) as SummarizerNodeWithGC;\n }\n\n public isReferenced(): boolean {\n return this.usedRoutes.includes(\"\") || this.usedRoutes.includes(\"/\");\n }\n\n public updateUsedRoutes(usedRoutes: string[]) {\n // Sort the given routes before updating. This will ensure that the routes compared in hasUsedStateChanged()\n // are in the same order.\n this.usedRoutes = usedRoutes.sort();\n\n // If GC is not disabled and we are tracking a summary, update the work-in-progress used routes so that it can\n // be tracked for this summary.\n if (!this.gcDisabled && this.isTrackingInProgress()) {\n this.wipSerializedUsedRoutes = JSON.stringify(this.usedRoutes);\n }\n }\n\n /**\n * Override the hasChanged method. If this node data or its used state changed, the node is considered changed.\n */\n protected hasChanged(): boolean {\n return this.hasDataChanged() || this.hasUsedStateChanged();\n }\n\n /**\n * This tells whether the data in this node has changed or not.\n */\n private hasDataChanged(): boolean {\n return super.hasChanged();\n }\n\n /**\n * This tells whether the used state of this node has changed since last successful summary. If the used routes\n * of this node changed, its used state is considered changed. Basically, if this node or any of its child nodes\n * was previously used and became unused (or vice versa), its used state has changed.\n */\n private hasUsedStateChanged(): boolean {\n // If GC is disabled, we are not tracking used state, return false.\n if (this.gcDisabled) {\n return false;\n }\n\n return this.referenceUsedRoutes === undefined ||\n JSON.stringify(this.usedRoutes) !== JSON.stringify(this.referenceUsedRoutes);\n }\n}\n\n/**\n * Creates a root summarizer node with GC functionality built-in.\n * @param logger - Logger to use within SummarizerNode\n * @param summarizeInternalFn - Function to generate summary\n * @param changeSequenceNumber - Sequence number of latest change to new node/subtree\n * @param referenceSequenceNumber - Reference sequence number of last acked summary,\n * or undefined if not loaded from summary\n * @param config - Configure behavior of summarizer node\n * @param getGCDataFn - Function to get the GC data of this node\n * @param baseGCDetailsP - Function to get the initial GC details of this node\n */\nexport const createRootSummarizerNodeWithGC = (\n logger: ITelemetryLogger,\n summarizeInternalFn: SummarizeInternalFn,\n changeSequenceNumber: number,\n referenceSequenceNumber: number | undefined,\n config: ISummarizerNodeConfigWithGC = {},\n getGCDataFn?: (fullGC?: boolean) => Promise<IGarbageCollectionData>,\n getBaseGCDetailsFn?: () => Promise<IGarbageCollectionDetailsBase>,\n): IRootSummarizerNodeWithGC => new SummarizerNodeWithGC(\n logger,\n summarizeInternalFn,\n config,\n changeSequenceNumber,\n referenceSequenceNumber === undefined ? undefined : SummaryNode.createForRoot(referenceSequenceNumber),\n undefined /* initialSummary */,\n undefined /* wipSummaryLogger */,\n getGCDataFn,\n getBaseGCDetailsFn,\n);\n"]}
1
+ {"version":3,"file":"summarizerNodeWithGc.js","sourceRoot":"","sources":["../../src/summarizerNode/summarizerNodeWithGc.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EACN,WAAW,EACX,qBAAqB,EACrB,oBAAoB,EACpB,yBAAyB,GACzB,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EAEN,SAAS,GAST,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAKN,uBAAuB,EACvB,WAAW,GACX,MAAM,uBAAuB,CAAC;AAM/B,wDAAwD;AACxD,MAAM,iBAAkB,SAAQ,WAAW;IAC1C,YACiB,oBAA4B,EAC5C,OAKC;QAED,KAAK,CAAC,OAAO,CAAC,CAAC;QARC,yBAAoB,GAApB,oBAAoB,CAAQ;IAS7C,CAAC;CACD;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,oBAAqB,SAAQ,cAAc;IAuBvD;;;OAGG;IACH,YACC,MAAwB,EACP,WAIqB,EACtC,MAAmC,EACnC,oBAA4B;IAC5B,8CAA8C;IAC9C,aAA2B,EAC3B,cAAgC,EAChC,gBAAmC,EAClB,WAAmE,EACpF,kBAAiE;QAEjE,KAAK,CACJ,MAAM,EACN,KAAK,EAAE,QAAiB,EAAE,WAAoB,EAAE,gBAAoC,EAAE,EAAE,CACvF,WAAW,CAAC,QAAQ,EAAE,IAAI,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,EAC/D,MAAM,EACN,oBAAoB,EACpB,aAAa,EACb,cAAc,EACd,gBAAgB,CAChB,CAAC;QAvBe,gBAAW,GAAX,WAAW,CAIU;QAOrB,gBAAW,GAAX,WAAW,CAAwD;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AAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;SAC/D;IACF,CAAC;IAED;;OAEG;IACO,UAAU;QACnB,OAAO,IAAI,CAAC,cAAc,EAAE,IAAI,IAAI,CAAC,mBAAmB,EAAE,CAAC;IAC5D,CAAC;IAED;;OAEG;IACK,cAAc;QACrB,OAAO,KAAK,CAAC,UAAU,EAAE,CAAC;IAC3B,CAAC;IAED;;;;OAIG;IACK,mBAAmB;QAC1B,mEAAmE;QACnE,IAAI,IAAI,CAAC,UAAU,EAAE;YACpB,OAAO,KAAK,CAAC;SACb;QAED,OAAO,CACN,IAAI,CAAC,mBAAmB,KAAK,SAAS;YACtC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAC5E,CAAC;IACH,CAAC;CACD;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAC7C,MAAwB,EACxB,mBAAwC,EACxC,oBAA4B,EAC5B,uBAA2C,EAC3C,SAAsC,EAAE,EACxC,WAAmE,EACnE,kBAAiE,EACrC,EAAE,CAC9B,IAAI,oBAAoB,CACvB,MAAM,EACN,mBAAmB,EACnB,MAAM,EACN,oBAAoB,EACpB,uBAAuB,KAAK,SAAS;IACpC,CAAC,CAAC,SAAS;IACX,CAAC,CAAC,WAAW,CAAC,aAAa,CAAC,uBAAuB,CAAC,EACrD,SAAS,CAAC,oBAAoB,EAC9B,SAAS,CAAC,sBAAsB,EAChC,WAAW,EACX,kBAAkB,CAClB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, LazyPromise } from \"@fluidframework/common-utils\";\nimport {\n\tcloneGCData,\n\tgetGCDataFromSnapshot,\n\trunGarbageCollection,\n\tunpackChildNodesGCDetails,\n} from \"@fluidframework/garbage-collector\";\nimport { ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport {\n\tCreateChildSummarizerNodeParam,\n\tgcTreeKey,\n\tIGarbageCollectionData,\n\tIGarbageCollectionDetailsBase,\n\tISummarizeInternalResult,\n\tISummarizeResult,\n\tISummarizerNodeConfigWithGC,\n\tISummarizerNodeWithGC,\n\tSummarizeInternalFn,\n\tITelemetryContext,\n} from \"@fluidframework/runtime-definitions\";\nimport { ReadAndParseBlob } from \"../utils\";\nimport { SummarizerNode } from \"./summarizerNode\";\nimport {\n\tEscapedPath,\n\tICreateChildDetails,\n\tIInitialSummary,\n\tISummarizerNodeRootContract,\n\tparseSummaryForSubtrees,\n\tSummaryNode,\n} from \"./summarizerNodeUtils\";\n\nexport interface IRootSummarizerNodeWithGC\n\textends ISummarizerNodeWithGC,\n\t\tISummarizerNodeRootContract {}\n\n// Extend SummaryNode to add used routes tracking to it.\nclass SummaryNodeWithGC extends SummaryNode {\n\tconstructor(\n\t\tpublic readonly serializedUsedRoutes: string,\n\t\tsummary: {\n\t\t\treadonly referenceSequenceNumber: number;\n\t\t\treadonly basePath: EscapedPath | undefined;\n\t\t\treadonly localPath: EscapedPath;\n\t\t\tadditionalPath?: EscapedPath;\n\t\t},\n\t) {\n\t\tsuper(summary);\n\t}\n}\n\n/**\n * Extends the functionality of SummarizerNode to manage this node's garbage collection data:\n *\n * - Adds a new API `getGCData` to return GC data of this node.\n *\n * - Caches the result of `getGCData` to be used if nothing changes between summaries.\n *\n * - Manages the used routes of this node. These are used to identify if this node is referenced in the document\n * and to determine if the node's used state changed since last summary.\n *\n * - Adds trackState param to summarize. If trackState is false, it bypasses the SummarizerNode and calls\n * directly into summarizeInternal method.\n */\nexport class SummarizerNodeWithGC extends SummarizerNode implements IRootSummarizerNodeWithGC {\n\t// Tracks the work-in-progress used routes during summary.\n\tprivate wipSerializedUsedRoutes: string | undefined;\n\n\t// This is the last known used routes of this node as seen by the server as part of a summary.\n\tprivate referenceUsedRoutes: string[] | undefined;\n\n\t// The base GC details of this node used to initialize the GC state.\n\tprivate readonly baseGCDetailsP: LazyPromise<IGarbageCollectionDetailsBase>;\n\n\t// Keeps track of whether we have loaded the base details to ensure that we on;y do it once.\n\tprivate baseGCDetailsLoaded: boolean = false;\n\n\tprivate gcData: IGarbageCollectionData | undefined;\n\n\t// Set used routes to have self route by default. This makes the node referenced by default. This is done to ensure\n\t// that this node is not marked as collected when running GC has been disabled. Once, the option to disable GC is\n\t// removed (from runGC flag in IContainerRuntimeOptions), this should be changed to be have no routes by default.\n\tprivate usedRoutes: string[] = [\"\"];\n\n\t// True if GC is disabled for this node. If so, do not track GC specific state for a summary.\n\tprivate readonly gcDisabled: boolean;\n\n\t/**\n\t * Do not call constructor directly.\n\t * Use createRootSummarizerNodeWithGC to create root node, or createChild to create child nodes.\n\t */\n\tpublic constructor(\n\t\tlogger: ITelemetryLogger,\n\t\tprivate readonly summarizeFn: (\n\t\t\tfullTree: boolean,\n\t\t\ttrackState: boolean,\n\t\t\ttelemetryContext?: ITelemetryContext,\n\t\t) => Promise<ISummarizeInternalResult>,\n\t\tconfig: ISummarizerNodeConfigWithGC,\n\t\tchangeSequenceNumber: number,\n\t\t/** Undefined means created without summary */\n\t\tlatestSummary?: SummaryNode,\n\t\tinitialSummary?: IInitialSummary,\n\t\twipSummaryLogger?: ITelemetryLogger,\n\t\tprivate readonly getGCDataFn?: (fullGC?: boolean) => Promise<IGarbageCollectionData>,\n\t\tgetBaseGCDetailsFn?: () => Promise<IGarbageCollectionDetailsBase>,\n\t) {\n\t\tsuper(\n\t\t\tlogger,\n\t\t\tasync (fullTree: boolean, _trackState: boolean, telemetryContext?: ITelemetryContext) =>\n\t\t\t\tsummarizeFn(fullTree, true /* trackState */, telemetryContext),\n\t\t\tconfig,\n\t\t\tchangeSequenceNumber,\n\t\t\tlatestSummary,\n\t\t\tinitialSummary,\n\t\t\twipSummaryLogger,\n\t\t);\n\n\t\tthis.gcDisabled = config.gcDisabled === true;\n\n\t\tthis.baseGCDetailsP = new LazyPromise(async () => {\n\t\t\treturn (await getBaseGCDetailsFn?.()) ?? { usedRoutes: [] };\n\t\t});\n\t}\n\n\t/**\n\t * Loads state from this node's initial GC summary details. This contains the following data from the last summary\n\t * seen by the server for this client:\n\t * - usedRoutes: This is used to figure out if the used state of this node changed since last summary.\n\t * - gcData: The garbage collection data of this node that is required for running GC.\n\t */\n\tprivate async loadBaseGCDetails() {\n\t\tif (this.baseGCDetailsLoaded) {\n\t\t\treturn;\n\t\t}\n\t\tconst baseGCDetails = await this.baseGCDetailsP;\n\n\t\t// Possible race - If there were parallel calls to loadBaseGCDetails, we want to make sure that we update\n\t\t// the state from the base details only once.\n\t\tif (this.baseGCDetailsLoaded) {\n\t\t\treturn;\n\t\t}\n\t\tthis.baseGCDetailsLoaded = true;\n\n\t\t// Update GC data, used routes and reference used routes. The used routes are sorted because they are compared\n\t\t// across GC runs to check if they changed. Sorting ensures that the elements are in the same order.\n\t\t// If the GC details has GC data, initialize our GC data from it.\n\t\tif (baseGCDetails.gcData !== undefined) {\n\t\t\tthis.gcData = cloneGCData(baseGCDetails.gcData);\n\t\t}\n\t\tif (baseGCDetails.usedRoutes !== undefined) {\n\t\t\tthis.usedRoutes = Array.from(baseGCDetails.usedRoutes).sort();\n\t\t\tthis.referenceUsedRoutes = Array.from(baseGCDetails.usedRoutes).sort();\n\t\t}\n\t}\n\n\tpublic async summarize(\n\t\tfullTree: boolean,\n\t\ttrackState: boolean = true,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): Promise<ISummarizeResult> {\n\t\t// If GC is not disabled and we are tracking a summary, GC should have run and updated the used routes for this\n\t\t// summary by calling updateUsedRoutes which sets wipSerializedUsedRoutes.\n\t\tif (!this.gcDisabled && this.isTrackingInProgress()) {\n\t\t\tassert(\n\t\t\t\tthis.wipSerializedUsedRoutes !== undefined,\n\t\t\t\t0x1b1 /* \"wip used routes should be set if tracking a summary\" */,\n\t\t\t);\n\t\t}\n\n\t\t// If trackState is true, get summary from base summarizer node which tracks summary state.\n\t\t// If trackState is false, get summary from summarizeInternal.\n\t\treturn trackState\n\t\t\t? super.summarize(fullTree, true /* trackState */, telemetryContext)\n\t\t\t: this.summarizeFn(fullTree, trackState, telemetryContext);\n\t}\n\n\t/**\n\t * Returns the GC data of this node. If nothing has changed since last summary, it tries to reuse the data from\n\t * the previous summary. Else, it gets new GC data from the underlying Fluid object.\n\t * @param fullGC - true to bypass optimizations and force full generation of GC data.\n\t */\n\tpublic async getGCData(fullGC: boolean = false): Promise<IGarbageCollectionData> {\n\t\tassert(\n\t\t\t!this.gcDisabled,\n\t\t\t0x1b2 /* \"Getting GC data should not be called when GC is disabled!\" */,\n\t\t);\n\t\tassert(\n\t\t\tthis.getGCDataFn !== undefined,\n\t\t\t0x1b3 /* \"GC data cannot be retrieved without getGCDataFn\" */,\n\t\t);\n\n\t\t// Load GC details from the initial summary, if not already loaded. If this is the first time this function is\n\t\t// called and the node's data has not changed since last summary, the GC data in initial details is returned.\n\t\tawait this.loadBaseGCDetails();\n\n\t\t// If there is no new data since last summary and we have GC data from the previous run, return it. The previous\n\t\t// GC data may not be available if loaded from a snapshot with either GC disabled or before GC was added.\n\t\t// Note - canReuseHandle is checked to be consistent with summarize - generate GC data for nodes for which\n\t\t// summary must be generated.\n\t\tif (this.canReuseHandle && !fullGC && !this.hasDataChanged() && this.gcData !== undefined) {\n\t\t\treturn cloneGCData(this.gcData);\n\t\t}\n\n\t\tconst gcData = await this.getGCDataFn(fullGC);\n\t\tthis.gcData = cloneGCData(gcData);\n\t\treturn gcData;\n\t}\n\n\t/**\n\t * Called during the start of a summary. Updates the work-in-progress used routes.\n\t */\n\tpublic startSummary(referenceSequenceNumber: number, summaryLogger: ITelemetryLogger) {\n\t\t// If GC is disabled, skip setting wip used routes since we should not track GC state.\n\t\tif (!this.gcDisabled) {\n\t\t\tassert(\n\t\t\t\tthis.wipSerializedUsedRoutes === undefined,\n\t\t\t\t0x1b4 /* \"We should not already be tracking used routes when to track a new summary\" */,\n\t\t\t);\n\t\t}\n\t\tsuper.startSummary(referenceSequenceNumber, summaryLogger);\n\t}\n\n\t/**\n\t * Called after summary has been uploaded to the server. Add the work-in-progress state to the pending\n\t * summary queue. We track this until we get an ack from the server for this summary.\n\t */\n\tprotected completeSummaryCore(\n\t\tproposalHandle: string,\n\t\tparentPath: EscapedPath | undefined,\n\t\tparentSkipRecursion: boolean,\n\t) {\n\t\tlet wipSerializedUsedRoutes: string | undefined;\n\t\t// If GC is disabled, don't set wip used routes.\n\t\tif (!this.gcDisabled) {\n\t\t\twipSerializedUsedRoutes = this.wipSerializedUsedRoutes;\n\t\t\tassert(\n\t\t\t\twipSerializedUsedRoutes !== undefined,\n\t\t\t\t0x1b5 /* \"We should have been tracking used routes\" */,\n\t\t\t);\n\t\t}\n\n\t\tsuper.completeSummaryCore(proposalHandle, parentPath, parentSkipRecursion);\n\n\t\t// If GC is disabled, skip setting pending summary with GC state.\n\t\tif (!this.gcDisabled) {\n\t\t\tconst summaryNode = this.pendingSummaries.get(proposalHandle);\n\t\t\tif (summaryNode !== undefined) {\n\t\t\t\tconst summaryNodeWithGC = new SummaryNodeWithGC(\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\twipSerializedUsedRoutes!,\n\t\t\t\t\tsummaryNode,\n\t\t\t\t);\n\t\t\t\tthis.pendingSummaries.set(proposalHandle, summaryNodeWithGC);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Clears the work-in-progress state.\n\t */\n\tpublic clearSummary() {\n\t\tthis.wipSerializedUsedRoutes = undefined;\n\t\tsuper.clearSummary();\n\t}\n\n\t/**\n\t * Called when we get an ack from the server for a summary we sent. Update the reference state of this node\n\t * from the state in the pending summary queue.\n\t */\n\tprotected refreshLatestSummaryFromPending(\n\t\tproposalHandle: string,\n\t\treferenceSequenceNumber: number,\n\t): void {\n\t\t// If GC is disabled, skip setting referenced used routes since we are not tracking GC state.\n\t\tif (!this.gcDisabled) {\n\t\t\tconst summaryNode = this.pendingSummaries.get(proposalHandle) as SummaryNodeWithGC;\n\t\t\tif (summaryNode?.serializedUsedRoutes !== undefined) {\n\t\t\t\tthis.referenceUsedRoutes = JSON.parse(summaryNode.serializedUsedRoutes);\n\t\t\t}\n\t\t}\n\n\t\treturn super.refreshLatestSummaryFromPending(proposalHandle, referenceSequenceNumber);\n\t}\n\n\t/**\n\t * Called when we need to upload the reference state from the given summary.\n\t */\n\tprotected async refreshLatestSummaryFromSnapshot(\n\t\treferenceSequenceNumber: number,\n\t\tsnapshotTree: ISnapshotTree,\n\t\tbasePath: EscapedPath | undefined,\n\t\tlocalPath: EscapedPath,\n\t\tcorrelatedSummaryLogger: ITelemetryLogger,\n\t\treadAndParseBlob: ReadAndParseBlob,\n\t): Promise<void> {\n\t\tawait this.refreshGCStateFromSnapshot(\n\t\t\treferenceSequenceNumber,\n\t\t\tsnapshotTree,\n\t\t\treadAndParseBlob,\n\t\t);\n\t\treturn super.refreshLatestSummaryFromSnapshot(\n\t\t\treferenceSequenceNumber,\n\t\t\tsnapshotTree,\n\t\t\tbasePath,\n\t\t\tlocalPath,\n\t\t\tcorrelatedSummaryLogger,\n\t\t\treadAndParseBlob,\n\t\t);\n\t}\n\n\t/**\n\t * Updates GC state from the given snapshot if GC is enabled and the snapshot is newer than the one this node\n\t * is tracking.\n\t */\n\tprivate async refreshGCStateFromSnapshot(\n\t\treferenceSequenceNumber: number,\n\t\tsnapshotTree: ISnapshotTree,\n\t\treadAndParseBlob: ReadAndParseBlob,\n\t): Promise<void> {\n\t\t// If GC is disabled or we have seen a newer summary, skip updating GC state.\n\t\tif (this.gcDisabled || this.referenceSequenceNumber >= referenceSequenceNumber) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Load the base GC details before proceeding because if that happens later it can overwrite the GC details\n\t\t// written by the following code.\n\t\tawait this.loadBaseGCDetails();\n\n\t\t// Possible re-entrancy. We may already have processed this while loading base GC details.\n\t\tif (this.referenceSequenceNumber >= referenceSequenceNumber) {\n\t\t\treturn;\n\t\t}\n\n\t\t/**\n\t\t * GC data is written at root of the snapshot tree under \"gc\" sub-tree. This data needs to be propagated to\n\t\t * all the nodes in the container.\n\t\t * The root summarizer node reads the GC data from the \"gc\" sub-tree, runs GC on it to get used routes in\n\t\t * the container and updates its GC data and referenced used routes. It then gets the GC data and used\n\t\t * routes of all its children and adds it to their snapshot tree.\n\t\t * All the other nodes gets the GC data and used routes from their snapshot tree and updates their state.\n\t\t * They get the GC data and used routes of their children and add it to their snapshot tree and so on.\n\t\t *\n\t\t * Note that if the snapshot does not have GC tree, GC data will be set to undefined and used routes will be\n\t\t * set to self-route (meaning referenced) for all nodes. This is important because the GC data needs to be\n\t\t * regenerated in the next summary.\n\t\t */\n\t\tlet gcDetails: IGarbageCollectionDetailsBase | undefined;\n\t\tconst gcSnapshotTree = snapshotTree.trees[gcTreeKey];\n\t\tif (gcSnapshotTree !== undefined) {\n\t\t\t// If there is a GC tree in the snapshot, this is the root summarizer node. Read GC data from the tree\n\t\t\t// process it as explained above.\n\t\t\tconst gcSnapshotData = await getGCDataFromSnapshot(gcSnapshotTree, readAndParseBlob);\n\n\t\t\tconst gcNodes: { [id: string]: string[] } = {};\n\t\t\tfor (const [nodeId, nodeData] of Object.entries(gcSnapshotData.gcState.gcNodes)) {\n\t\t\t\tgcNodes[nodeId] = Array.from(nodeData.outboundRoutes);\n\t\t\t}\n\t\t\t// Run GC on the nodes in the snapshot to get the used routes for each node in the container.\n\t\t\tconst usedRoutes = runGarbageCollection(gcNodes, [\"/\"]).referencedNodeIds;\n\t\t\tgcDetails = { gcData: { gcNodes }, usedRoutes };\n\t\t} else {\n\t\t\t// If there is a GC blob in the snapshot, it's a non-root summarizer nodes - The root summarizer node\n\t\t\t// writes GC blob in the snapshot of child nodes. Get GC data and used routes from the blob.\n\t\t\tconst gcDetailsBlob = snapshotTree.blobs[gcTreeKey];\n\t\t\tif (gcDetailsBlob !== undefined) {\n\t\t\t\tgcDetails = JSON.parse(gcDetailsBlob) as IGarbageCollectionDetailsBase;\n\t\t\t}\n\t\t}\n\n\t\t// Update this node to the same GC state it was when the ack corresponding to this summary was processed.\n\t\tthis.gcData = gcDetails?.gcData !== undefined ? cloneGCData(gcDetails.gcData) : undefined;\n\t\tthis.referenceUsedRoutes =\n\t\t\tgcDetails?.usedRoutes !== undefined ? Array.from(gcDetails.usedRoutes) : undefined;\n\t\t// If there are no used routes in the GC details, set it to have self route which will make the node\n\t\t// referenced. This scenario can only happen if the snapshot is from a client where GC was not run or\n\t\t// disabled. In both the cases, the node should be referenced.\n\t\tthis.usedRoutes =\n\t\t\tgcDetails?.usedRoutes !== undefined ? Array.from(gcDetails.usedRoutes) : [\"\"];\n\n\t\tif (gcDetails === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Generate the GC data and used routes of children GC nodes and add it to their snapshot tree.\n\t\tconst gcDetailsMap = unpackChildNodesGCDetails(gcDetails);\n\t\tconst { childrenTree } = parseSummaryForSubtrees(snapshotTree);\n\t\tgcDetailsMap.forEach((childGCDetails: IGarbageCollectionDetailsBase, childId: string) => {\n\t\t\tif (childrenTree.trees[childId] !== undefined) {\n\t\t\t\tchildrenTree.trees[childId].blobs[gcTreeKey] = JSON.stringify(childGCDetails);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Override the createChild method to return an instance of SummarizerNodeWithGC.\n\t */\n\tpublic createChild(\n\t\t/** Summarize function */\n\t\tsummarizeInternalFn: SummarizeInternalFn,\n\t\t/** Initial id or path part of this node */\n\t\tid: string,\n\t\t/**\n\t\t * Information needed to create the node.\n\t\t * If it is from a base summary, it will assert that a summary has been seen.\n\t\t * Attach information if it is created from an attach op.\n\t\t */\n\t\tcreateParam: CreateChildSummarizerNodeParam,\n\t\tconfig: ISummarizerNodeConfigWithGC = {},\n\t\tgetGCDataFn?: (fullGC?: boolean) => Promise<IGarbageCollectionData>,\n\t\tgetBaseGCDetailsFn?: () => Promise<IGarbageCollectionDetailsBase>,\n\t): ISummarizerNodeWithGC {\n\t\tassert(!this.children.has(id), 0x1b6 /* \"Create SummarizerNode child already exists\" */);\n\n\t\t/**\n\t\t * Update the child node's base GC details from this node's current GC details instead of updating from the base\n\t\t * GC details of this node. This will handle scenarios where the GC details was updated during refresh from\n\t\t * snapshot and the child node wasn't created then. If a child is created after that, its GC details should be\n\t\t * the one from the downloaded snapshot and not the base GC details.\n\t\t */\n\t\tconst getChildBaseGCDetailsP = new LazyPromise<IGarbageCollectionDetailsBase>(async () => {\n\t\t\t// Ensure that the base GC details is loaded because a child can be created before GC runs which is when\n\t\t\t// base GC details is usually loaded.\n\t\t\tawait this.loadBaseGCDetails();\n\t\t\tconst childBaseGCDetails = unpackChildNodesGCDetails({\n\t\t\t\tgcData: this.gcData,\n\t\t\t\tusedRoutes: this.usedRoutes,\n\t\t\t});\n\t\t\treturn childBaseGCDetails.get(id) ?? {};\n\t\t});\n\n\t\tconst createDetails: ICreateChildDetails = this.getCreateDetailsForChild(id, createParam);\n\t\tconst child = new SummarizerNodeWithGC(\n\t\t\tthis.defaultLogger,\n\t\t\tsummarizeInternalFn,\n\t\t\t{\n\t\t\t\t...config,\n\t\t\t\t// Propagate our gcDisabled state to the child if its not explicity specified in child's config.\n\t\t\t\tgcDisabled: config.gcDisabled ?? this.gcDisabled,\n\t\t\t},\n\t\t\tcreateDetails.changeSequenceNumber,\n\t\t\tcreateDetails.latestSummary,\n\t\t\tcreateDetails.initialSummary,\n\t\t\tthis.wipSummaryLogger,\n\t\t\tgetGCDataFn,\n\t\t\tasync () => getChildBaseGCDetailsP,\n\t\t);\n\n\t\t// There may be additional state that has to be updated in this child. For example, if a summary is being\n\t\t// tracked, the child's summary tracking state needs to be updated too.\n\t\tthis.maybeUpdateChildState(child);\n\n\t\tthis.children.set(id, child);\n\t\treturn child;\n\t}\n\n\t/**\n\t * Deletes the child node with the given id.\n\t */\n\tpublic deleteChild(id: string): void {\n\t\tthis.children.delete(id);\n\t}\n\n\t/**\n\t * Override the getChild method to return an instance of SummarizerNodeWithGC.\n\t */\n\tpublic getChild(id: string): ISummarizerNodeWithGC | undefined {\n\t\treturn this.children.get(id) as SummarizerNodeWithGC;\n\t}\n\n\tpublic isReferenced(): boolean {\n\t\treturn this.usedRoutes.includes(\"\") || this.usedRoutes.includes(\"/\");\n\t}\n\n\tpublic updateUsedRoutes(usedRoutes: string[]) {\n\t\t// Sort the given routes before updating. This will ensure that the routes compared in hasUsedStateChanged()\n\t\t// are in the same order.\n\t\tthis.usedRoutes = usedRoutes.sort();\n\n\t\t// If GC is not disabled and we are tracking a summary, update the work-in-progress used routes so that it can\n\t\t// be tracked for this summary.\n\t\tif (!this.gcDisabled && this.isTrackingInProgress()) {\n\t\t\tthis.wipSerializedUsedRoutes = JSON.stringify(this.usedRoutes);\n\t\t}\n\t}\n\n\t/**\n\t * Override the hasChanged method. If this node data or its used state changed, the node is considered changed.\n\t */\n\tprotected hasChanged(): boolean {\n\t\treturn this.hasDataChanged() || this.hasUsedStateChanged();\n\t}\n\n\t/**\n\t * This tells whether the data in this node has changed or not.\n\t */\n\tprivate hasDataChanged(): boolean {\n\t\treturn super.hasChanged();\n\t}\n\n\t/**\n\t * This tells whether the used state of this node has changed since last successful summary. If the used routes\n\t * of this node changed, its used state is considered changed. Basically, if this node or any of its child nodes\n\t * was previously used and became unused (or vice versa), its used state has changed.\n\t */\n\tprivate hasUsedStateChanged(): boolean {\n\t\t// If GC is disabled, we are not tracking used state, return false.\n\t\tif (this.gcDisabled) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn (\n\t\t\tthis.referenceUsedRoutes === undefined ||\n\t\t\tJSON.stringify(this.usedRoutes) !== JSON.stringify(this.referenceUsedRoutes)\n\t\t);\n\t}\n}\n\n/**\n * Creates a root summarizer node with GC functionality built-in.\n * @param logger - Logger to use within SummarizerNode\n * @param summarizeInternalFn - Function to generate summary\n * @param changeSequenceNumber - Sequence number of latest change to new node/subtree\n * @param referenceSequenceNumber - Reference sequence number of last acked summary,\n * or undefined if not loaded from summary\n * @param config - Configure behavior of summarizer node\n * @param getGCDataFn - Function to get the GC data of this node\n * @param baseGCDetailsP - Function to get the initial GC details of this node\n */\nexport const createRootSummarizerNodeWithGC = (\n\tlogger: ITelemetryLogger,\n\tsummarizeInternalFn: SummarizeInternalFn,\n\tchangeSequenceNumber: number,\n\treferenceSequenceNumber: number | undefined,\n\tconfig: ISummarizerNodeConfigWithGC = {},\n\tgetGCDataFn?: (fullGC?: boolean) => Promise<IGarbageCollectionData>,\n\tgetBaseGCDetailsFn?: () => Promise<IGarbageCollectionDetailsBase>,\n): IRootSummarizerNodeWithGC =>\n\tnew SummarizerNodeWithGC(\n\t\tlogger,\n\t\tsummarizeInternalFn,\n\t\tconfig,\n\t\tchangeSequenceNumber,\n\t\treferenceSequenceNumber === undefined\n\t\t\t? undefined\n\t\t\t: SummaryNode.createForRoot(referenceSequenceNumber),\n\t\tundefined /* initialSummary */,\n\t\tundefined /* wipSummaryLogger */,\n\t\tgetGCDataFn,\n\t\tgetBaseGCDetailsFn,\n\t);\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"summaryUtils.d.ts","sourceRoot":"","sources":["../src/summaryUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAShF,OAAO,EACH,KAAK,EACL,WAAW,EACX,YAAY,EACZ,aAAa,EACb,YAAY,EAGZ,aAAa,EAChB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACH,aAAa,EACb,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACpB,MAAM,qCAAqC,CAAC;AAE7C;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,KAAK,EAAE,aAAa,EAAE,GAAG,aAAa,CAgBnE;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAelD;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,YAAY,CAAC,SA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,EAAE,aAAa,GAAG,qBAAqB,CA2B/F;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,YAAY,GAAG,KAAK,CAuC1E;AAED,qBAAa,gBAAiB,YAAW,iBAAiB;IACzD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAiD;IAE3E;;OAEG;IACH,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,0BAA0B,GAAG,IAAI;IAI9E;;OAEG;IACH,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,0BAA0B;IAIjE;;OAEG;IACH,SAAS,IAAI,MAAM;CAOnB"}
@@ -38,7 +38,7 @@ export function utf8ByteLength(str) {
38
38
  else if (code > 0x7ff && code <= 0xffff) {
39
39
  s += 2;
40
40
  }
41
- if (code >= 0xDC00 && code <= 0xDFFF) {
41
+ if (code >= 0xdc00 && code <= 0xdfff) {
42
42
  i--; // trail surrogate
43
43
  }
44
44
  }
@@ -65,7 +65,8 @@ function calculateStatsCore(summaryObject, stats) {
65
65
  stats.totalBlobSize += getBlobSize(summaryObject.content);
66
66
  return;
67
67
  }
68
- default: return;
68
+ default:
69
+ return;
69
70
  }
70
71
  }
71
72
  export function calculateStats(summary) {
@@ -1 +1 @@
1
- {"version":3,"file":"summaryUtils.js","sourceRoot":"","sources":["../src/summaryUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACH,cAAc,EACd,gBAAgB,EAChB,SAAS,EACT,kBAAkB,EAClB,eAAe,GAClB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAClG,OAAO,EAEH,WAAW,EAIX,SAAS,GAGZ,MAAM,sCAAsC,CAAC;AAQ9C;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,GAAG,KAAsB;IAChD,MAAM,OAAO,GA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G,MAAM,GAAG,QAAQ,EAAE,EAAE,KAAK,CAAC,CAAC;IACtD,CAAC;IAED;;OAEG;IACH,GAAG,CAAC,MAAc,EAAE,QAAgB;QAChC,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,MAAM,GAAG,QAAQ,EAAE,CAAC,CAAC;IACtD,CAAC;IAED;;OAEG;IACH,SAAS;QACL,MAAM,UAAU,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;YAClC,UAAU,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QAC5B,CAAC,CAAC,CAAC;QACH,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IACtC,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TelemetryEventPropertyType } from \"@fluidframework/common-definitions\";\nimport {\n bufferToString,\n fromBase64ToUtf8,\n IsoBuffer,\n Uint8ArrayToString,\n unreachableCase,\n} from \"@fluidframework/common-utils\";\nimport { AttachmentTreeEntry, BlobTreeEntry, TreeTreeEntry } from \"@fluidframework/protocol-base\";\nimport {\n ITree,\n SummaryType,\n ISummaryTree,\n SummaryObject,\n ISummaryBlob,\n TreeEntry,\n ITreeEntry,\n ISnapshotTree,\n} from \"@fluidframework/protocol-definitions\";\nimport {\n ISummaryStats,\n ISummarizeResult,\n ISummaryTreeWithStats,\n ITelemetryContext,\n} from \"@fluidframework/runtime-definitions\";\n\n/**\n * Combines summary stats by adding their totals together.\n * Returns empty stats if called without args.\n * @param stats - stats to merge\n */\nexport function mergeStats(...stats: ISummaryStats[]): ISummaryStats {\n const results = {\n treeNodeCount: 0,\n blobNodeCount: 0,\n handleNodeCount: 0,\n totalBlobSize: 0,\n unreferencedBlobSize: 0,\n };\n for (const stat of stats) {\n results.treeNodeCount += stat.treeNodeCount;\n results.blobNodeCount += stat.blobNodeCount;\n results.handleNodeCount += stat.handleNodeCount;\n results.totalBlobSize += stat.totalBlobSize;\n results.unreferencedBlobSize += stat.unreferencedBlobSize;\n }\n return results;\n}\n\nexport function utf8ByteLength(str: string): number {\n // returns the byte length of an utf8 string\n let s = str.length;\n for (let i = str.length - 1; i >= 0; i--) {\n const code = str.charCodeAt(i);\n if (code > 0x7f && code <= 0x7ff) {\n s++;\n } else if (code > 0x7ff && code <= 0xffff) {\n s += 2;\n }\n if (code >= 0xDC00 && code <= 0xDFFF) {\n i--; // trail surrogate\n }\n }\n return s;\n}\n\nexport function getBlobSize(content: ISummaryBlob[\"content\"]): number {\n return typeof content === \"string\" ? utf8ByteLength(content) : content.byteLength;\n}\n\nfunction calculateStatsCore(summaryObject: SummaryObject, stats: ISummaryStats): void {\n switch (summaryObject.type) {\n case SummaryType.Tree: {\n stats.treeNodeCount++;\n for (const value of Object.values(summaryObject.tree)) {\n calculateStatsCore(value, stats);\n }\n return;\n }\n case SummaryType.Handle: {\n stats.handleNodeCount++;\n return;\n }\n case SummaryType.Blob: {\n stats.blobNodeCount++;\n stats.totalBlobSize += getBlobSize(summaryObject.content);\n return;\n }\n default: return;\n }\n}\n\nexport function calculateStats(summary: SummaryObject): ISummaryStats {\n const stats = mergeStats();\n calculateStatsCore(summary, stats);\n return stats;\n}\n\nexport function addBlobToSummary(summary: ISummaryTreeWithStats, key: string, content: string | Uint8Array): void {\n const blob: ISummaryBlob = {\n type: SummaryType.Blob,\n content,\n };\n summary.summary.tree[key] = blob;\n summary.stats.blobNodeCount++;\n summary.stats.totalBlobSize += getBlobSize(content);\n}\n\nexport function addTreeToSummary(summary: ISummaryTreeWithStats, key: string, summarizeResult: ISummarizeResult): void {\n summary.summary.tree[key] = summarizeResult.summary;\n summary.stats = mergeStats(summary.stats, summarizeResult.stats);\n}\n\nexport function addSummarizeResultToSummary(\n summary: ISummaryTreeWithStats,\n key: string,\n summarizeResult: ISummarizeResult,\n): void {\n summary.summary.tree[key] = summarizeResult.summary;\n summary.stats = mergeStats(summary.stats, summarizeResult.stats);\n}\n\nexport class SummaryTreeBuilder implements ISummaryTreeWithStats {\n private attachmentCounter: number = 0;\n\n public get summary(): ISummaryTree {\n return {\n type: SummaryType.Tree,\n tree: { ...this.summaryTree },\n };\n }\n\n public get stats(): Readonly<ISummaryStats> {\n return { ...this.summaryStats };\n }\n\n constructor() {\n this.summaryStats = mergeStats();\n this.summaryStats.treeNodeCount++;\n }\n\n private readonly summaryTree: { [path: string]: SummaryObject; } = {};\n private summaryStats: ISummaryStats;\n\n public addBlob(key: string, content: string | Uint8Array): void {\n // Prevent cloning by directly referencing underlying private properties\n addBlobToSummary({\n summary: {\n type: SummaryType.Tree,\n tree: this.summaryTree,\n },\n stats: this.summaryStats,\n }, key, content);\n }\n\n public addHandle(\n key: string,\n handleType: SummaryType.Tree | SummaryType.Blob | SummaryType.Attachment,\n handle: string): void {\n this.summaryTree[key] = {\n type: SummaryType.Handle,\n handleType,\n handle,\n };\n this.summaryStats.handleNodeCount++;\n }\n\n public addWithStats(key: string, summarizeResult: ISummarizeResult): void {\n this.summaryTree[key] = summarizeResult.summary;\n this.summaryStats = mergeStats(this.summaryStats, summarizeResult.stats);\n }\n\n public addAttachment(id: string) {\n this.summaryTree[this.attachmentCounter++] = { id, type: SummaryType.Attachment };\n }\n\n public getSummaryTree(): ISummaryTreeWithStats {\n return { summary: this.summary, stats: this.stats };\n }\n}\n\n/**\n * Converts snapshot ITree to ISummaryTree format and tracks stats.\n * @param snapshot - snapshot in ITree format\n * @param fullTree - true to never use handles, even if id is specified\n */\nexport function convertToSummaryTreeWithStats(\n snapshot: ITree,\n fullTree: boolean = false,\n): ISummaryTreeWithStats {\n const builder = new SummaryTreeBuilder();\n for (const entry of snapshot.entries) {\n switch (entry.type) {\n case TreeEntry.Blob: {\n const blob = entry.value;\n const content = blob.encoding === \"base64\"\n ? IsoBuffer.from(blob.contents, \"base64\")\n : blob.contents;\n builder.addBlob(entry.path, content);\n break;\n }\n\n case TreeEntry.Tree: {\n const subtree = convertToSummaryTree(\n entry.value,\n fullTree);\n builder.addWithStats(entry.path, subtree);\n\n break;\n }\n\n case TreeEntry.Attachment: {\n const id = entry.value.id;\n builder.addAttachment(id);\n\n break;\n }\n\n default:\n throw new Error(\"Unexpected TreeEntry type\");\n }\n }\n\n const summaryTree = builder.getSummaryTree();\n summaryTree.summary.unreferenced = snapshot.unreferenced;\n return summaryTree;\n}\n\n/**\n * Converts snapshot ITree to ISummaryTree format and tracks stats.\n * @param snapshot - snapshot in ITree format\n * @param fullTree - true to never use handles, even if id is specified\n */\nexport function convertToSummaryTree(\n snapshot: ITree,\n fullTree: boolean = false,\n): ISummarizeResult {\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n if (snapshot.id && !fullTree) {\n const stats = mergeStats();\n stats.handleNodeCount++;\n return {\n summary: {\n handle: snapshot.id,\n handleType: SummaryType.Tree,\n type: SummaryType.Handle,\n },\n stats,\n };\n } else {\n return convertToSummaryTreeWithStats(snapshot, fullTree);\n }\n}\n\n/**\n * Converts ISnapshotTree to ISummaryTree format and tracks stats. This snapshot tree was\n * was taken by serialize api in detached container.\n * @param snapshot - snapshot in ISnapshotTree format\n */\nexport function convertSnapshotTreeToSummaryTree(\n snapshot: ISnapshotTree,\n): ISummaryTreeWithStats {\n const builder = new SummaryTreeBuilder();\n for (const [path, id] of Object.entries(snapshot.blobs)) {\n let decoded: string | undefined;\n if ((snapshot as any).blobsContents !== undefined) {\n const content: ArrayBufferLike = (snapshot as any).blobsContents[id];\n if (content !== undefined) {\n decoded = bufferToString(content, \"utf-8\");\n }\n // 0.44 back-compat We still put contents in same blob for back-compat so need to add blob\n // only for blobPath -> blobId mapping and not for blobId -> blob value contents.\n } else if (snapshot.blobs[id] !== undefined) {\n decoded = fromBase64ToUtf8(snapshot.blobs[id]);\n }\n if (decoded !== undefined) {\n builder.addBlob(path, decoded);\n }\n }\n\n for (const [key, tree] of Object.entries(snapshot.trees)) {\n const subtree = convertSnapshotTreeToSummaryTree(tree);\n builder.addWithStats(key, subtree);\n }\n\n const summaryTree = builder.getSummaryTree();\n summaryTree.summary.unreferenced = snapshot.unreferenced;\n return summaryTree;\n}\n\n/**\n * Converts ISummaryTree to ITree format. This is needed for back-compat while we get rid of snapshot.\n * @param summaryTree - summary tree in ISummaryTree format\n */\nexport function convertSummaryTreeToITree(summaryTree: ISummaryTree): ITree {\n const entries: ITreeEntry[] = [];\n for (const [key, value] of Object.entries(summaryTree.tree)) {\n switch (value.type) {\n case SummaryType.Blob: {\n let parsedContent: string;\n let encoding: \"utf-8\" | \"base64\" = \"utf-8\";\n if (typeof value.content === \"string\") {\n parsedContent = value.content;\n } else {\n parsedContent = Uint8ArrayToString(value.content, \"base64\");\n encoding = \"base64\";\n }\n entries.push(new BlobTreeEntry(key, parsedContent, encoding));\n break;\n }\n\n case SummaryType.Tree: {\n entries.push(new TreeTreeEntry(key, convertSummaryTreeToITree(value)));\n break;\n }\n\n case SummaryType.Attachment: {\n entries.push(new AttachmentTreeEntry(key, value.id));\n break;\n }\n\n case SummaryType.Handle: {\n throw new Error(\"Should not have Handle type in summary tree\");\n }\n\n default:\n unreachableCase(value, \"Unexpected summary tree type\");\n }\n }\n return {\n entries,\n unreferenced: summaryTree.unreferenced,\n };\n}\n\nexport class TelemetryContext implements ITelemetryContext {\n private readonly telemetry = new Map<string, TelemetryEventPropertyType>();\n\n /**\n * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.set}\n */\n set(prefix: string, property: string, value: TelemetryEventPropertyType): void {\n this.telemetry.set(`${prefix}${property}`, value);\n }\n\n /**\n * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.get}\n */\n get(prefix: string, property: string): TelemetryEventPropertyType {\n return this.telemetry.get(`${prefix}${property}`);\n }\n\n /**\n * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.serialize}\n */\n serialize(): string {\n const jsonObject = {};\n this.telemetry.forEach((value, key) => {\n jsonObject[key] = value;\n });\n return JSON.stringify(jsonObject);\n }\n}\n"]}
1
+ {"version":3,"file":"summaryUtils.js","sourceRoot":"","sources":["../src/summaryUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,cAAc,EACd,gBAAgB,EAChB,SAAS,EACT,kBAAkB,EAClB,eAAe,GACf,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAClG,OAAO,EAEN,WAAW,EAIX,SAAS,GAGT,MAAM,sCAAsC,CAAC;AAQ9C;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,GAAG,KAAsB;IACnD,MAAM,OAAO,GAAG;QACf,aAAa,EAAE,CAAC;QAChB,aAAa,EAAE,CAAC;QAChB,eAAe,EAAE,CAAC;QAClB,aAAa,EAAE,CAAC;QAChB,oBAAoB,EAAE,CAAC;KACvB,CAAC;IACF,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACzB,OAAO,CAAC,aAAa,IAAI,IAAI,CAAC,aAAa,CAAC;QAC5C,OAAO,CAAC,aAAa,IAAI,IAAI,CAAC,aAAa,CAAC;QAC5C,OAAO,CAAC,eAAe,IAAI,IAAI,CAAC,eAAe,CAAC;QAChD,OAAO,CAAC,aAAa,IAAI,IAAI,CAAC,aAAa,CAAC;QAC5C,OAAO,CAAC,oBAAoB,IAAI,IAAI,CAAC,oBAAoB,CAAC;KAC1D;IACD,OAAO,OAAO,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,GAAW;IACzC,4CAA4C;IAC5C,IAAI,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC;IACnB,KAAK,IAAI,CAAC,GAAG,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;QACzC,MAAM,IAAI,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAC/B,IAAI,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,WAAW,CAAC,MAAM,CAAC,CAAC;gBACxB,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;aAC/D;YAED;gBACC,eAAe,CAAC,KAAK,EAAE,8BAA8B,CAAC,CAAC;SACxD;KACD;IACD,OAAO;QACN,OAAO;QACP,YAAY,EAAE,WAAW,CAAC,YAAY;KACtC,CAAC;AACH,CAAC;AAED,MAAM,OAAO,gBAAgB;IAA7B;QACkB,cAAS,GAAG,IAAI,GAAG,EAAsC,CAAC;IA0B5E,CAAC;IAxBA;;OAEG;IACH,GAAG,CAAC,MAAc,EAAE,QAAgB,EAAE,KAAiC;QACtE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,MAAM,GAAG,QAAQ,EAAE,EAAE,KAAK,CAAC,CAAC;IACnD,CAAC;IAED;;OAEG;IACH,GAAG,CAAC,MAAc,EAAE,QAAgB;QACnC,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,MAAM,GAAG,QAAQ,EAAE,CAAC,CAAC;IACnD,CAAC;IAED;;OAEG;IACH,SAAS;QACR,MAAM,UAAU,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;YACrC,UAAU,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACzB,CAAC,CAAC,CAAC;QACH,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IACnC,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TelemetryEventPropertyType } from \"@fluidframework/common-definitions\";\nimport {\n\tbufferToString,\n\tfromBase64ToUtf8,\n\tIsoBuffer,\n\tUint8ArrayToString,\n\tunreachableCase,\n} from \"@fluidframework/common-utils\";\nimport { AttachmentTreeEntry, BlobTreeEntry, TreeTreeEntry } from \"@fluidframework/protocol-base\";\nimport {\n\tITree,\n\tSummaryType,\n\tISummaryTree,\n\tSummaryObject,\n\tISummaryBlob,\n\tTreeEntry,\n\tITreeEntry,\n\tISnapshotTree,\n} from \"@fluidframework/protocol-definitions\";\nimport {\n\tISummaryStats,\n\tISummarizeResult,\n\tISummaryTreeWithStats,\n\tITelemetryContext,\n} from \"@fluidframework/runtime-definitions\";\n\n/**\n * Combines summary stats by adding their totals together.\n * Returns empty stats if called without args.\n * @param stats - stats to merge\n */\nexport function mergeStats(...stats: ISummaryStats[]): ISummaryStats {\n\tconst results = {\n\t\ttreeNodeCount: 0,\n\t\tblobNodeCount: 0,\n\t\thandleNodeCount: 0,\n\t\ttotalBlobSize: 0,\n\t\tunreferencedBlobSize: 0,\n\t};\n\tfor (const stat of stats) {\n\t\tresults.treeNodeCount += stat.treeNodeCount;\n\t\tresults.blobNodeCount += stat.blobNodeCount;\n\t\tresults.handleNodeCount += stat.handleNodeCount;\n\t\tresults.totalBlobSize += stat.totalBlobSize;\n\t\tresults.unreferencedBlobSize += stat.unreferencedBlobSize;\n\t}\n\treturn results;\n}\n\nexport function utf8ByteLength(str: string): number {\n\t// returns the byte length of an utf8 string\n\tlet s = str.length;\n\tfor (let i = str.length - 1; i >= 0; i--) {\n\t\tconst code = str.charCodeAt(i);\n\t\tif (code > 0x7f && code <= 0x7ff) {\n\t\t\ts++;\n\t\t} else if (code > 0x7ff && code <= 0xffff) {\n\t\t\ts += 2;\n\t\t}\n\t\tif (code >= 0xdc00 && code <= 0xdfff) {\n\t\t\ti--; // trail surrogate\n\t\t}\n\t}\n\treturn s;\n}\n\nexport function getBlobSize(content: ISummaryBlob[\"content\"]): number {\n\treturn typeof content === \"string\" ? utf8ByteLength(content) : content.byteLength;\n}\n\nfunction calculateStatsCore(summaryObject: SummaryObject, stats: ISummaryStats): void {\n\tswitch (summaryObject.type) {\n\t\tcase SummaryType.Tree: {\n\t\t\tstats.treeNodeCount++;\n\t\t\tfor (const value of Object.values(summaryObject.tree)) {\n\t\t\t\tcalculateStatsCore(value, stats);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tcase SummaryType.Handle: {\n\t\t\tstats.handleNodeCount++;\n\t\t\treturn;\n\t\t}\n\t\tcase SummaryType.Blob: {\n\t\t\tstats.blobNodeCount++;\n\t\t\tstats.totalBlobSize += getBlobSize(summaryObject.content);\n\t\t\treturn;\n\t\t}\n\t\tdefault:\n\t\t\treturn;\n\t}\n}\n\nexport function calculateStats(summary: SummaryObject): ISummaryStats {\n\tconst stats = mergeStats();\n\tcalculateStatsCore(summary, stats);\n\treturn stats;\n}\n\nexport function addBlobToSummary(\n\tsummary: ISummaryTreeWithStats,\n\tkey: string,\n\tcontent: string | Uint8Array,\n): void {\n\tconst blob: ISummaryBlob = {\n\t\ttype: SummaryType.Blob,\n\t\tcontent,\n\t};\n\tsummary.summary.tree[key] = blob;\n\tsummary.stats.blobNodeCount++;\n\tsummary.stats.totalBlobSize += getBlobSize(content);\n}\n\nexport function addTreeToSummary(\n\tsummary: ISummaryTreeWithStats,\n\tkey: string,\n\tsummarizeResult: ISummarizeResult,\n): void {\n\tsummary.summary.tree[key] = summarizeResult.summary;\n\tsummary.stats = mergeStats(summary.stats, summarizeResult.stats);\n}\n\nexport function addSummarizeResultToSummary(\n\tsummary: ISummaryTreeWithStats,\n\tkey: string,\n\tsummarizeResult: ISummarizeResult,\n): void {\n\tsummary.summary.tree[key] = summarizeResult.summary;\n\tsummary.stats = mergeStats(summary.stats, summarizeResult.stats);\n}\n\nexport class SummaryTreeBuilder implements ISummaryTreeWithStats {\n\tprivate attachmentCounter: number = 0;\n\n\tpublic get summary(): ISummaryTree {\n\t\treturn {\n\t\t\ttype: SummaryType.Tree,\n\t\t\ttree: { ...this.summaryTree },\n\t\t};\n\t}\n\n\tpublic get stats(): Readonly<ISummaryStats> {\n\t\treturn { ...this.summaryStats };\n\t}\n\n\tconstructor() {\n\t\tthis.summaryStats = mergeStats();\n\t\tthis.summaryStats.treeNodeCount++;\n\t}\n\n\tprivate readonly summaryTree: { [path: string]: SummaryObject } = {};\n\tprivate summaryStats: ISummaryStats;\n\n\tpublic addBlob(key: string, content: string | Uint8Array): void {\n\t\t// Prevent cloning by directly referencing underlying private properties\n\t\taddBlobToSummary(\n\t\t\t{\n\t\t\t\tsummary: {\n\t\t\t\t\ttype: SummaryType.Tree,\n\t\t\t\t\ttree: this.summaryTree,\n\t\t\t\t},\n\t\t\t\tstats: this.summaryStats,\n\t\t\t},\n\t\t\tkey,\n\t\t\tcontent,\n\t\t);\n\t}\n\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\tthis.summaryStats.handleNodeCount++;\n\t}\n\n\tpublic addWithStats(key: string, summarizeResult: ISummarizeResult): void {\n\t\tthis.summaryTree[key] = summarizeResult.summary;\n\t\tthis.summaryStats = mergeStats(this.summaryStats, summarizeResult.stats);\n\t}\n\n\tpublic addAttachment(id: string) {\n\t\tthis.summaryTree[this.attachmentCounter++] = { id, type: SummaryType.Attachment };\n\t}\n\n\tpublic getSummaryTree(): ISummaryTreeWithStats {\n\t\treturn { summary: this.summary, stats: this.stats };\n\t}\n}\n\n/**\n * Converts snapshot ITree to ISummaryTree format and tracks stats.\n * @param snapshot - snapshot in ITree format\n * @param fullTree - true to never use handles, even if id is specified\n */\nexport function convertToSummaryTreeWithStats(\n\tsnapshot: ITree,\n\tfullTree: boolean = false,\n): ISummaryTreeWithStats {\n\tconst builder = new SummaryTreeBuilder();\n\tfor (const entry of snapshot.entries) {\n\t\tswitch (entry.type) {\n\t\t\tcase TreeEntry.Blob: {\n\t\t\t\tconst blob = entry.value;\n\t\t\t\tconst content =\n\t\t\t\t\tblob.encoding === \"base64\"\n\t\t\t\t\t\t? IsoBuffer.from(blob.contents, \"base64\")\n\t\t\t\t\t\t: blob.contents;\n\t\t\t\tbuilder.addBlob(entry.path, content);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase TreeEntry.Tree: {\n\t\t\t\tconst subtree = convertToSummaryTree(entry.value, fullTree);\n\t\t\t\tbuilder.addWithStats(entry.path, subtree);\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase TreeEntry.Attachment: {\n\t\t\t\tconst id = entry.value.id;\n\t\t\t\tbuilder.addAttachment(id);\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\tthrow new Error(\"Unexpected TreeEntry type\");\n\t\t}\n\t}\n\n\tconst summaryTree = builder.getSummaryTree();\n\tsummaryTree.summary.unreferenced = snapshot.unreferenced;\n\treturn summaryTree;\n}\n\n/**\n * Converts snapshot ITree to ISummaryTree format and tracks stats.\n * @param snapshot - snapshot in ITree format\n * @param fullTree - true to never use handles, even if id is specified\n */\nexport function convertToSummaryTree(snapshot: ITree, fullTree: boolean = false): ISummarizeResult {\n\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\tif (snapshot.id && !fullTree) {\n\t\tconst stats = mergeStats();\n\t\tstats.handleNodeCount++;\n\t\treturn {\n\t\t\tsummary: {\n\t\t\t\thandle: snapshot.id,\n\t\t\t\thandleType: SummaryType.Tree,\n\t\t\t\ttype: SummaryType.Handle,\n\t\t\t},\n\t\t\tstats,\n\t\t};\n\t} else {\n\t\treturn convertToSummaryTreeWithStats(snapshot, fullTree);\n\t}\n}\n\n/**\n * Converts ISnapshotTree to ISummaryTree format and tracks stats. This snapshot tree was\n * was taken by serialize api in detached container.\n * @param snapshot - snapshot in ISnapshotTree format\n */\nexport function convertSnapshotTreeToSummaryTree(snapshot: ISnapshotTree): ISummaryTreeWithStats {\n\tconst builder = new SummaryTreeBuilder();\n\tfor (const [path, id] of Object.entries(snapshot.blobs)) {\n\t\tlet decoded: string | undefined;\n\t\tif ((snapshot as any).blobsContents !== undefined) {\n\t\t\tconst content: ArrayBufferLike = (snapshot as any).blobsContents[id];\n\t\t\tif (content !== undefined) {\n\t\t\t\tdecoded = bufferToString(content, \"utf-8\");\n\t\t\t}\n\t\t\t// 0.44 back-compat We still put contents in same blob for back-compat so need to add blob\n\t\t\t// only for blobPath -> blobId mapping and not for blobId -> blob value contents.\n\t\t} else if (snapshot.blobs[id] !== undefined) {\n\t\t\tdecoded = fromBase64ToUtf8(snapshot.blobs[id]);\n\t\t}\n\t\tif (decoded !== undefined) {\n\t\t\tbuilder.addBlob(path, decoded);\n\t\t}\n\t}\n\n\tfor (const [key, tree] of Object.entries(snapshot.trees)) {\n\t\tconst subtree = convertSnapshotTreeToSummaryTree(tree);\n\t\tbuilder.addWithStats(key, subtree);\n\t}\n\n\tconst summaryTree = builder.getSummaryTree();\n\tsummaryTree.summary.unreferenced = snapshot.unreferenced;\n\treturn summaryTree;\n}\n\n/**\n * Converts ISummaryTree to ITree format. This is needed for back-compat while we get rid of snapshot.\n * @param summaryTree - summary tree in ISummaryTree format\n */\nexport function convertSummaryTreeToITree(summaryTree: ISummaryTree): ITree {\n\tconst entries: ITreeEntry[] = [];\n\tfor (const [key, value] of Object.entries(summaryTree.tree)) {\n\t\tswitch (value.type) {\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\tlet parsedContent: string;\n\t\t\t\tlet encoding: \"utf-8\" | \"base64\" = \"utf-8\";\n\t\t\t\tif (typeof value.content === \"string\") {\n\t\t\t\t\tparsedContent = value.content;\n\t\t\t\t} else {\n\t\t\t\t\tparsedContent = Uint8ArrayToString(value.content, \"base64\");\n\t\t\t\t\tencoding = \"base64\";\n\t\t\t\t}\n\t\t\t\tentries.push(new BlobTreeEntry(key, parsedContent, encoding));\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\tentries.push(new TreeTreeEntry(key, convertSummaryTreeToITree(value)));\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase SummaryType.Attachment: {\n\t\t\t\tentries.push(new AttachmentTreeEntry(key, value.id));\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase SummaryType.Handle: {\n\t\t\t\tthrow new Error(\"Should not have Handle type in summary tree\");\n\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\tunreachableCase(value, \"Unexpected summary tree type\");\n\t\t}\n\t}\n\treturn {\n\t\tentries,\n\t\tunreferenced: summaryTree.unreferenced,\n\t};\n}\n\nexport class TelemetryContext implements ITelemetryContext {\n\tprivate readonly telemetry = new Map<string, TelemetryEventPropertyType>();\n\n\t/**\n\t * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.set}\n\t */\n\tset(prefix: string, property: string, value: TelemetryEventPropertyType): void {\n\t\tthis.telemetry.set(`${prefix}${property}`, value);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.get}\n\t */\n\tget(prefix: string, property: string): TelemetryEventPropertyType {\n\t\treturn this.telemetry.get(`${prefix}${property}`);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.serialize}\n\t */\n\tserialize(): string {\n\t\tconst jsonObject = {};\n\t\tthis.telemetry.forEach((value, key) => {\n\t\t\tjsonObject[key] = value;\n\t\t});\n\t\treturn JSON.stringify(jsonObject);\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAuB,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAE1F,yDAAyD;AACzD,oBAAY,gBAAgB,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;AAE7D;;;;;GAKG;AACF,wBAAsB,WAAW,CAC9B,IAAI,EAAE,aAAa,EACnB,gBAAgB,EAAE,gBAAgB,GACnC,OAAO,CAAC,MAAM,CAAC,CAIjB"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAuB,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAE1F,yDAAyD;AACzD,oBAAY,gBAAgB,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;AAE7D;;;;;GAKG;AACH,wBAAsB,WAAW,CAChC,IAAI,EAAE,aAAa,EACnB,gBAAgB,EAAE,gBAAgB,GAChC,OAAO,CAAC,MAAM,CAAC,CAIjB"}
package/lib/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH;;;;;GAKG;AACF,MAAM,CAAC,KAAK,UAAU,WAAW,CAC9B,IAAmB,EACnB,gBAAkC;IAElC,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC;IAChE,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAsB,cAAc,CAAC,CAAC;IAC3E,OAAO,MAAM,CAAC,cAAc,CAAC;AACjC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDocumentAttributes, ISnapshotTree } from \"@fluidframework/protocol-definitions\";\n\n/** Reads a blob from storage and parses it from JSON. */\nexport type ReadAndParseBlob = <T>(id: string) => Promise<T>;\n\n/**\n * Fetches the sequence number of the snapshot tree by examining the protocol.\n * @param tree - snapshot tree to examine\n * @param readAndParseBlob - function to read blob contents from storage\n * and parse the result from JSON.\n */\n export async function seqFromTree(\n tree: ISnapshotTree,\n readAndParseBlob: ReadAndParseBlob,\n): Promise<number> {\n const attributesHash = tree.trees[\".protocol\"].blobs.attributes;\n const attrib = await readAndParseBlob<IDocumentAttributes>(attributesHash);\n return attrib.sequenceNumber;\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAChC,IAAmB,EACnB,gBAAkC;IAElC,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC;IAChE,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAsB,cAAc,CAAC,CAAC;IAC3E,OAAO,MAAM,CAAC,cAAc,CAAC;AAC9B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDocumentAttributes, ISnapshotTree } from \"@fluidframework/protocol-definitions\";\n\n/** Reads a blob from storage and parses it from JSON. */\nexport type ReadAndParseBlob = <T>(id: string) => Promise<T>;\n\n/**\n * Fetches the sequence number of the snapshot tree by examining the protocol.\n * @param tree - snapshot tree to examine\n * @param readAndParseBlob - function to read blob contents from storage\n * and parse the result from JSON.\n */\nexport async function seqFromTree(\n\ttree: ISnapshotTree,\n\treadAndParseBlob: ReadAndParseBlob,\n): Promise<number> {\n\tconst attributesHash = tree.trees[\".protocol\"].blobs.attributes;\n\tconst attrib = await readAndParseBlob<IDocumentAttributes>(attributesHash);\n\treturn attrib.sequenceNumber;\n}\n"]}
package/package.json CHANGED
@@ -1,106 +1,112 @@
1
1
  {
2
- "name": "@fluidframework/runtime-utils",
3
- "version": "2.0.0-internal.3.0.0",
4
- "description": "Collection of utility functions for Fluid Runtime",
5
- "homepage": "https://fluidframework.com",
6
- "repository": {
7
- "type": "git",
8
- "url": "https://github.com/microsoft/FluidFramework.git",
9
- "directory": "packages/runtime/runtime-utils"
10
- },
11
- "license": "MIT",
12
- "author": "Microsoft and contributors",
13
- "sideEffects": false,
14
- "main": "dist/index.js",
15
- "module": "lib/index.js",
16
- "types": "dist/index.d.ts",
17
- "scripts": {
18
- "build": "npm run build:genver && concurrently npm:build:compile npm:lint && npm run build:docs",
19
- "build:commonjs": "npm run tsc && npm run typetests:gen && npm run build:test",
20
- "build:compile": "concurrently npm:build:commonjs npm:build:esnext",
21
- "build:docs": "api-extractor run --local --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/doc-models/* ../../../_api-extractor-temp/",
22
- "build:esnext": "tsc --project ./tsconfig.esnext.json",
23
- "build:full": "npm run build",
24
- "build:full:compile": "npm run build:compile",
25
- "build:genver": "gen-version",
26
- "build:test": "tsc --project ./src/test/tsconfig.json",
27
- "ci:build:docs": "api-extractor run --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/* ../../../_api-extractor-temp/",
28
- "clean": "rimraf dist lib *.tsbuildinfo *.build.log",
29
- "eslint": "eslint --format stylish src",
30
- "eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
31
- "format": "npm run prettier:fix",
32
- "lint": "npm run eslint",
33
- "lint:fix": "npm run eslint:fix",
34
- "prettier": "prettier --check . --ignore-path ../../../.prettierignore",
35
- "prettier:fix": "prettier --write . --ignore-path ../../../.prettierignore",
36
- "test": "npm run test:mocha",
37
- "test:coverage": "nyc npm test -- --reporter xunit --reporter-option output=nyc/junit-report.xml",
38
- "test:mocha": "mocha --ignore 'dist/test/types/*' --recursive dist/test -r node_modules/@fluidframework/mocha-test-setup --unhandled-rejections=strict",
39
- "test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
40
- "tsc": "tsc",
41
- "typetests:gen": "flub generate typetests --generate --dir .",
42
- "typetests:prepare": "flub generate typetests --prepare --dir . --pin"
43
- },
44
- "nyc": {
45
- "all": true,
46
- "cache-dir": "nyc/.cache",
47
- "exclude": [
48
- "src/test/**/*.ts",
49
- "dist/test/**/*.js"
50
- ],
51
- "exclude-after-remap": false,
52
- "include": [
53
- "src/**/*.ts",
54
- "dist/**/*.js"
55
- ],
56
- "report-dir": "nyc/report",
57
- "reporter": [
58
- "cobertura",
59
- "html",
60
- "text"
61
- ],
62
- "temp-directory": "nyc/.nyc_output"
63
- },
64
- "dependencies": {
65
- "@fluidframework/common-definitions": "^0.20.1",
66
- "@fluidframework/common-utils": "^1.0.0",
67
- "@fluidframework/container-definitions": ">=2.0.0-internal.3.0.0 <2.0.0-internal.4.0.0",
68
- "@fluidframework/container-runtime-definitions": ">=2.0.0-internal.3.0.0 <2.0.0-internal.4.0.0",
69
- "@fluidframework/core-interfaces": ">=2.0.0-internal.3.0.0 <2.0.0-internal.4.0.0",
70
- "@fluidframework/datastore-definitions": ">=2.0.0-internal.3.0.0 <2.0.0-internal.4.0.0",
71
- "@fluidframework/garbage-collector": ">=2.0.0-internal.3.0.0 <2.0.0-internal.4.0.0",
72
- "@fluidframework/protocol-base": "^0.1038.2000",
73
- "@fluidframework/protocol-definitions": "^1.1.0",
74
- "@fluidframework/runtime-definitions": ">=2.0.0-internal.3.0.0 <2.0.0-internal.4.0.0",
75
- "@fluidframework/telemetry-utils": ">=2.0.0-internal.3.0.0 <2.0.0-internal.4.0.0"
76
- },
77
- "devDependencies": {
78
- "@fluid-tools/build-cli": "^0.8.0",
79
- "@fluidframework/build-common": "^1.1.0",
80
- "@fluidframework/build-tools": "^0.8.0",
81
- "@fluidframework/eslint-config-fluid": "^2.0.0",
82
- "@fluidframework/mocha-test-setup": ">=2.0.0-internal.3.0.0 <2.0.0-internal.4.0.0",
83
- "@fluidframework/runtime-utils-previous": "npm:@fluidframework/runtime-utils@2.0.0-internal.2.2.0",
84
- "@microsoft/api-extractor": "^7.22.2",
85
- "@rushstack/eslint-config": "^2.5.1",
86
- "@types/mocha": "^9.1.1",
87
- "@types/node": "^14.18.36",
88
- "concurrently": "^6.2.0",
89
- "copyfiles": "^2.4.1",
90
- "cross-env": "^7.0.2",
91
- "eslint": "~8.6.0",
92
- "mocha": "^10.0.0",
93
- "nyc": "^15.0.0",
94
- "prettier": "~2.6.2",
95
- "rimraf": "^2.6.2",
96
- "sinon": "^7.4.2",
97
- "ts-node": "^7.0.1",
98
- "typescript": "~4.5.5"
99
- },
100
- "typeValidation": {
101
- "version": "2.0.0-internal.3.0.0",
102
- "baselineRange": ">=2.0.0-internal.2.0.0 <2.0.0-internal.3.0.0",
103
- "baselineVersion": "2.0.0-internal.2.2.0",
104
- "broken": {}
105
- }
2
+ "name": "@fluidframework/runtime-utils",
3
+ "version": "2.0.0-internal.3.1.0",
4
+ "description": "Collection of utility functions for Fluid Runtime",
5
+ "homepage": "https://fluidframework.com",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/microsoft/FluidFramework.git",
9
+ "directory": "packages/runtime/runtime-utils"
10
+ },
11
+ "license": "MIT",
12
+ "author": "Microsoft and contributors",
13
+ "sideEffects": false,
14
+ "main": "dist/index.js",
15
+ "module": "lib/index.js",
16
+ "types": "dist/index.d.ts",
17
+ "scripts": {
18
+ "build": "npm run build:genver && concurrently npm:build:compile npm:lint && npm run build:docs",
19
+ "build:commonjs": "npm run tsc && npm run typetests:gen && npm run build:test",
20
+ "build:compile": "concurrently npm:build:commonjs npm:build:esnext",
21
+ "build:docs": "api-extractor run --local --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/doc-models/* ../../../_api-extractor-temp/",
22
+ "build:esnext": "tsc --project ./tsconfig.esnext.json",
23
+ "build:full": "npm run build",
24
+ "build:full:compile": "npm run build:compile",
25
+ "build:genver": "gen-version",
26
+ "build:test": "tsc --project ./src/test/tsconfig.json",
27
+ "ci:build:docs": "api-extractor run --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/* ../../../_api-extractor-temp/",
28
+ "clean": "rimraf dist lib *.tsbuildinfo *.build.log",
29
+ "eslint": "eslint --format stylish src",
30
+ "eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
31
+ "format": "npm run prettier:fix",
32
+ "lint": "npm run prettier && npm run eslint",
33
+ "lint:fix": "npm run prettier:fix && npm run eslint:fix",
34
+ "prettier": "prettier --check . --ignore-path ../../../.prettierignore",
35
+ "prettier:fix": "prettier --write . --ignore-path ../../../.prettierignore",
36
+ "test": "npm run test:mocha",
37
+ "test:coverage": "nyc npm test -- --reporter xunit --reporter-option output=nyc/junit-report.xml",
38
+ "test:mocha": "mocha --ignore 'dist/test/types/*' --recursive dist/test -r node_modules/@fluidframework/mocha-test-setup --unhandled-rejections=strict",
39
+ "test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
40
+ "tsc": "tsc",
41
+ "typetests:gen": "flub generate typetests --generate --dir .",
42
+ "typetests:prepare": "flub generate typetests --prepare --dir . --pin"
43
+ },
44
+ "nyc": {
45
+ "all": true,
46
+ "cache-dir": "nyc/.cache",
47
+ "exclude": [
48
+ "src/test/**/*.ts",
49
+ "dist/test/**/*.js"
50
+ ],
51
+ "exclude-after-remap": false,
52
+ "include": [
53
+ "src/**/*.ts",
54
+ "dist/**/*.js"
55
+ ],
56
+ "report-dir": "nyc/report",
57
+ "reporter": [
58
+ "cobertura",
59
+ "html",
60
+ "text"
61
+ ],
62
+ "temp-directory": "nyc/.nyc_output"
63
+ },
64
+ "dependencies": {
65
+ "@fluidframework/common-definitions": "^0.20.1",
66
+ "@fluidframework/common-utils": "^1.0.0",
67
+ "@fluidframework/container-definitions": ">=2.0.0-internal.3.1.0 <2.0.0-internal.4.0.0",
68
+ "@fluidframework/container-runtime-definitions": ">=2.0.0-internal.3.1.0 <2.0.0-internal.4.0.0",
69
+ "@fluidframework/core-interfaces": ">=2.0.0-internal.3.1.0 <2.0.0-internal.4.0.0",
70
+ "@fluidframework/datastore-definitions": ">=2.0.0-internal.3.1.0 <2.0.0-internal.4.0.0",
71
+ "@fluidframework/garbage-collector": ">=2.0.0-internal.3.1.0 <2.0.0-internal.4.0.0",
72
+ "@fluidframework/protocol-base": "^0.1038.2000",
73
+ "@fluidframework/protocol-definitions": "^1.1.0",
74
+ "@fluidframework/runtime-definitions": ">=2.0.0-internal.3.1.0 <2.0.0-internal.4.0.0",
75
+ "@fluidframework/telemetry-utils": ">=2.0.0-internal.3.1.0 <2.0.0-internal.4.0.0"
76
+ },
77
+ "devDependencies": {
78
+ "@fluid-tools/build-cli": "^0.9.0",
79
+ "@fluidframework/build-common": "^1.1.0",
80
+ "@fluidframework/build-tools": "^0.9.0",
81
+ "@fluidframework/eslint-config-fluid": "^2.0.0",
82
+ "@fluidframework/mocha-test-setup": ">=2.0.0-internal.3.1.0 <2.0.0-internal.4.0.0",
83
+ "@fluidframework/runtime-utils-previous": "npm:@fluidframework/runtime-utils@2.0.0-internal.3.0.0",
84
+ "@microsoft/api-extractor": "^7.22.2",
85
+ "@rushstack/eslint-config": "^2.5.1",
86
+ "@types/mocha": "^9.1.1",
87
+ "@types/node": "^14.18.36",
88
+ "concurrently": "^6.2.0",
89
+ "copyfiles": "^2.4.1",
90
+ "cross-env": "^7.0.2",
91
+ "eslint": "~8.6.0",
92
+ "mocha": "^10.0.0",
93
+ "nyc": "^15.0.0",
94
+ "prettier": "~2.6.2",
95
+ "rimraf": "^2.6.2",
96
+ "sinon": "^7.4.2",
97
+ "ts-node": "^7.0.1",
98
+ "typescript": "~4.5.5"
99
+ },
100
+ "typeValidation": {
101
+ "version": "2.0.0-internal.3.1.0",
102
+ "previousVersionStyle": "~previousMinor",
103
+ "baselineRange": ">=2.0.0-internal.3.0.0 <2.0.0-internal.3.1.0",
104
+ "baselineVersion": "2.0.0-internal.3.0.0",
105
+ "broken": {
106
+ "TypeAliasDeclaration_RefreshSummaryResult": {
107
+ "forwardCompat": false,
108
+ "backCompat": false
109
+ }
110
+ }
111
+ }
106
112
  }
@@ -4,5 +4,5 @@
4
4
  */
5
5
 
6
6
  module.exports = {
7
- ...require("@fluidframework/build-common/prettier.config.cjs"),
7
+ ...require("@fluidframework/build-common/prettier.config.cjs"),
8
8
  };
@@ -11,21 +11,28 @@ import { IFluidHandleContext } from "@fluidframework/core-interfaces";
11
11
  * @param routeContext - The route context that contains the Fluid object.
12
12
  * @returns The absolute path to the Fluid object from the root of the Container.
13
13
  */
14
- export function generateHandleContextPath(path: string, routeContext?: IFluidHandleContext): string {
15
- if (path === "") {
16
- // The `path` is empty.
17
- // If the routeContext does not exist, this is the root.
18
- // If the routeContext exists, the absolute path is the same as that of the routeContext.
19
- return routeContext === undefined ? "" : routeContext.absolutePath;
20
- } else {
21
- // Remove beginning and trailing slashes, if any, from the path.
22
- let normalizedPath = path.startsWith("/") ? path.slice(1) : path;
23
- normalizedPath = normalizedPath.endsWith("/") ? normalizedPath.slice(0, -1) : normalizedPath;
14
+ export function generateHandleContextPath(
15
+ path: string,
16
+ routeContext?: IFluidHandleContext,
17
+ ): string {
18
+ if (path === "") {
19
+ // The `path` is empty.
20
+ // If the routeContext does not exist, this is the root.
21
+ // If the routeContext exists, the absolute path is the same as that of the routeContext.
22
+ return routeContext === undefined ? "" : routeContext.absolutePath;
23
+ } else {
24
+ // Remove beginning and trailing slashes, if any, from the path.
25
+ let normalizedPath = path.startsWith("/") ? path.slice(1) : path;
26
+ normalizedPath = normalizedPath.endsWith("/")
27
+ ? normalizedPath.slice(0, -1)
28
+ : normalizedPath;
24
29
 
25
- // If the routeContext does not exist, path is the absolute path.
26
- // If the routeContext exists, absolute path is routeContext's absolute path plus the path.
27
- return routeContext === undefined
28
- ? `/${normalizedPath}`
29
- : `${routeContext.absolutePath === "/" ? "" : routeContext.absolutePath}/${normalizedPath}`;
30
- }
30
+ // If the routeContext does not exist, path is the absolute path.
31
+ // If the routeContext exists, absolute path is routeContext's absolute path plus the path.
32
+ return routeContext === undefined
33
+ ? `/${normalizedPath}`
34
+ : `${
35
+ routeContext.absolutePath === "/" ? "" : routeContext.absolutePath
36
+ }/${normalizedPath}`;
37
+ }
31
38
  }