@fluidframework/odsp-driver 2.53.0 → 2.60.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 (130) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/api-report/{odsp-driver.legacy.alpha.api.md → odsp-driver.legacy.beta.api.md} +31 -31
  3. package/dist/checkUrl.d.ts +1 -1
  4. package/dist/checkUrl.js +1 -1
  5. package/dist/checkUrl.js.map +1 -1
  6. package/dist/constants.d.ts +2 -2
  7. package/dist/constants.js +2 -2
  8. package/dist/constants.js.map +1 -1
  9. package/dist/contractsPublic.d.ts +1 -1
  10. package/dist/contractsPublic.js.map +1 -1
  11. package/dist/createOdspCreateContainerRequest.d.ts +1 -1
  12. package/dist/createOdspCreateContainerRequest.js +1 -1
  13. package/dist/createOdspCreateContainerRequest.js.map +1 -1
  14. package/dist/createOdspUrl.d.ts +1 -1
  15. package/dist/createOdspUrl.js +1 -1
  16. package/dist/createOdspUrl.js.map +1 -1
  17. package/dist/epochTracker.d.ts +4 -4
  18. package/dist/epochTracker.js +1 -1
  19. package/dist/epochTracker.js.map +1 -1
  20. package/dist/fetchSnapshot.d.ts +1 -1
  21. package/dist/fetchSnapshot.js +1 -1
  22. package/dist/fetchSnapshot.js.map +1 -1
  23. package/dist/getFileLink.js +1 -1
  24. package/dist/getFileLink.js.map +1 -1
  25. package/dist/odspCache.d.ts +4 -4
  26. package/dist/odspCache.js.map +1 -1
  27. package/dist/odspDocumentService.d.ts.map +1 -1
  28. package/dist/odspDocumentService.js +4 -4
  29. package/dist/odspDocumentService.js.map +1 -1
  30. package/dist/odspDocumentServiceFactory.d.ts +2 -2
  31. package/dist/odspDocumentServiceFactory.js +2 -2
  32. package/dist/odspDocumentServiceFactory.js.map +1 -1
  33. package/dist/odspDocumentServiceFactoryCore.d.ts +1 -1
  34. package/dist/odspDocumentServiceFactoryCore.js +1 -1
  35. package/dist/odspDocumentServiceFactoryCore.js.map +1 -1
  36. package/dist/odspDriverUrlResolver.d.ts +1 -1
  37. package/dist/odspDriverUrlResolver.js +1 -1
  38. package/dist/odspDriverUrlResolver.js.map +1 -1
  39. package/dist/odspDriverUrlResolverForShareLink.d.ts +2 -2
  40. package/dist/odspDriverUrlResolverForShareLink.js +1 -1
  41. package/dist/odspDriverUrlResolverForShareLink.js.map +1 -1
  42. package/dist/odspFluidFileLink.d.ts +4 -4
  43. package/dist/odspFluidFileLink.js +4 -4
  44. package/dist/odspFluidFileLink.js.map +1 -1
  45. package/dist/odspPublicUtils.d.ts +2 -2
  46. package/dist/odspPublicUtils.js +1 -1
  47. package/dist/odspPublicUtils.js.map +1 -1
  48. package/dist/odspUtils.d.ts +2 -2
  49. package/dist/odspUtils.js +1 -1
  50. package/dist/odspUtils.js.map +1 -1
  51. package/dist/packageVersion.d.ts +1 -1
  52. package/dist/packageVersion.js +1 -1
  53. package/dist/packageVersion.js.map +1 -1
  54. package/dist/prefetchLatestSnapshot.d.ts +1 -1
  55. package/dist/prefetchLatestSnapshot.js +1 -1
  56. package/dist/prefetchLatestSnapshot.js.map +1 -1
  57. package/lib/checkUrl.d.ts +1 -1
  58. package/lib/checkUrl.js +1 -1
  59. package/lib/checkUrl.js.map +1 -1
  60. package/lib/constants.d.ts +2 -2
  61. package/lib/constants.js +2 -2
  62. package/lib/constants.js.map +1 -1
  63. package/lib/contractsPublic.d.ts +1 -1
  64. package/lib/contractsPublic.js.map +1 -1
  65. package/lib/createOdspCreateContainerRequest.d.ts +1 -1
  66. package/lib/createOdspCreateContainerRequest.js +1 -1
  67. package/lib/createOdspCreateContainerRequest.js.map +1 -1
  68. package/lib/createOdspUrl.d.ts +1 -1
  69. package/lib/createOdspUrl.js +1 -1
  70. package/lib/createOdspUrl.js.map +1 -1
  71. package/lib/epochTracker.d.ts +4 -4
  72. package/lib/epochTracker.js +1 -1
  73. package/lib/epochTracker.js.map +1 -1
  74. package/lib/fetchSnapshot.d.ts +1 -1
  75. package/lib/fetchSnapshot.js +1 -1
  76. package/lib/fetchSnapshot.js.map +1 -1
  77. package/lib/getFileLink.js +1 -1
  78. package/lib/getFileLink.js.map +1 -1
  79. package/lib/odspCache.d.ts +4 -4
  80. package/lib/odspCache.js.map +1 -1
  81. package/lib/odspDocumentService.d.ts.map +1 -1
  82. package/lib/odspDocumentService.js +4 -4
  83. package/lib/odspDocumentService.js.map +1 -1
  84. package/lib/odspDocumentServiceFactory.d.ts +2 -2
  85. package/lib/odspDocumentServiceFactory.js +2 -2
  86. package/lib/odspDocumentServiceFactory.js.map +1 -1
  87. package/lib/odspDocumentServiceFactoryCore.d.ts +1 -1
  88. package/lib/odspDocumentServiceFactoryCore.js +1 -1
  89. package/lib/odspDocumentServiceFactoryCore.js.map +1 -1
  90. package/lib/odspDriverUrlResolver.d.ts +1 -1
  91. package/lib/odspDriverUrlResolver.js +1 -1
  92. package/lib/odspDriverUrlResolver.js.map +1 -1
  93. package/lib/odspDriverUrlResolverForShareLink.d.ts +2 -2
  94. package/lib/odspDriverUrlResolverForShareLink.js +1 -1
  95. package/lib/odspDriverUrlResolverForShareLink.js.map +1 -1
  96. package/lib/odspFluidFileLink.d.ts +4 -4
  97. package/lib/odspFluidFileLink.js +4 -4
  98. package/lib/odspFluidFileLink.js.map +1 -1
  99. package/lib/odspPublicUtils.d.ts +2 -2
  100. package/lib/odspPublicUtils.js +1 -1
  101. package/lib/odspPublicUtils.js.map +1 -1
  102. package/lib/odspUtils.d.ts +2 -2
  103. package/lib/odspUtils.js +1 -1
  104. package/lib/odspUtils.js.map +1 -1
  105. package/lib/packageVersion.d.ts +1 -1
  106. package/lib/packageVersion.js +1 -1
  107. package/lib/packageVersion.js.map +1 -1
  108. package/lib/prefetchLatestSnapshot.d.ts +1 -1
  109. package/lib/prefetchLatestSnapshot.js +1 -1
  110. package/lib/prefetchLatestSnapshot.js.map +1 -1
  111. package/package.json +13 -13
  112. package/src/checkUrl.ts +1 -1
  113. package/src/constants.ts +2 -2
  114. package/src/contractsPublic.ts +1 -1
  115. package/src/createOdspCreateContainerRequest.ts +1 -1
  116. package/src/createOdspUrl.ts +1 -1
  117. package/src/epochTracker.ts +4 -4
  118. package/src/fetchSnapshot.ts +1 -1
  119. package/src/getFileLink.ts +1 -1
  120. package/src/odspCache.ts +4 -4
  121. package/src/odspDocumentService.ts +5 -4
  122. package/src/odspDocumentServiceFactory.ts +2 -2
  123. package/src/odspDocumentServiceFactoryCore.ts +1 -1
  124. package/src/odspDriverUrlResolver.ts +1 -1
  125. package/src/odspDriverUrlResolverForShareLink.ts +2 -2
  126. package/src/odspFluidFileLink.ts +4 -4
  127. package/src/odspPublicUtils.ts +2 -2
  128. package/src/odspUtils.ts +2 -2
  129. package/src/packageVersion.ts +1 -1
  130. package/src/prefetchLatestSnapshot.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"fetchSnapshot.js","sourceRoot":"","sources":["../src/fetchSnapshot.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAgE;AAChE,kEAA6D;AAC7D,mEAAkE;AAElE,oEAI+C;AAC/C,yEAGoD;AACpD,+EAM0D;AAC1D,uEAKkD;AAClD,+BAAkC;AAElC,yEAIoC;AACpC,iDAKwB;AACxB,6DAA6D;AAE7D,2DAAqD;AACrD,+EAAmE;AACnE,6CAAuC;AACvC,mEAAoF;AACpF,yDAAiE;AACjE,iDAWwB;AACxB,2DAAiD;AAEjD;;;;GAIG;AACH,IAAY,yBAIX;AAJD,WAAY,yBAAyB;IACpC,yEAAQ,CAAA;IACR,6EAAU,CAAA;IACV,2FAAiB,CAAA;AAClB,CAAC,EAJW,yBAAyB,yCAAzB,yBAAyB,QAIpC;AAED;;;;;;;;GAQG;AACI,KAAK,UAAU,aAAa,CAClC,WAAmB,EACnB,SAAiB,EACjB,iBAA0B,EAC1B,sCAA+C,EAC/C,MAA2B,EAC3B,kBAAoE;IAEpE,MAAM,IAAI,GAAG,UAAU,SAAS,EAAE,CAAC;IACnC,IAAI,WAAW,GAAqB,EAAE,CAAC;I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kBAAkB,CAAC,GAAW;IACtC;;;OAGG;IACH,IAAI,UAAU,GAAG,IAAA,+BAAgB,EAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;IAClD,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACpF,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACrC,OAAO,UAAU,CAAC;AACnB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { fromUtf8ToBase64 } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { getW3CData } from \"@fluidframework/driver-base/internal\";\nimport type { ISnapshot, ISnapshotTree } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\ttype DriverErrorTelemetryProps,\n\tNonRetryableError,\n\tisRuntimeMessage,\n} from \"@fluidframework/driver-utils/internal\";\nimport {\n\tfetchIncorrectResponse,\n\tthrowOdspNetworkError,\n} from \"@fluidframework/odsp-doclib-utils/internal\";\nimport {\n\ttype IOdspError,\n\ttype IOdspResolvedUrl,\n\ttype ISnapshotOptions,\n\ttype InstrumentedStorageTokenFetcher,\n\tOdspErrorTypes,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\ttype ITelemetryLoggerExt,\n\tPerformanceEvent,\n\tisFluidError,\n\twrapError,\n} from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport {\n\ttype ISnapshotContentsWithProps,\n\tcurrentReadVersion,\n\tparseCompactSnapshotResponse,\n} from \"./compactSnapshotParser.js\";\nimport {\n\ttype IOdspSnapshot,\n\ttype ISnapshotCachedEntry2,\n\ttype IVersionedValueWithEpoch,\n\tpersistedCacheValueVersion,\n} from \"./contracts.js\";\nimport { ClpCompliantAppHeader } from \"./contractsPublic.js\";\nimport type { EpochTracker } from \"./epochTracker.js\";\nimport { getQueryString } from \"./getQueryString.js\";\nimport { getHeadersWithAuth } from \"./getUrlAndHeadersWithAuth.js\";\nimport { mockify } from \"./mockify.js\";\nimport { convertOdspSnapshotToSnapshotTreeAndBlobs } from \"./odspSnapshotParser.js\";\nimport { checkForKnownServerFarmType } from \"./odspUrlHelper.js\";\nimport {\n\ttype IOdspResponse,\n\tfetchAndParseAsJSONHelper,\n\tfetchHelper,\n\tgetWithRetryForTokenRefresh,\n\tgetWithRetryForTokenRefreshRepeat,\n\tisSnapshotFetchForLoadingGroup,\n\tmeasure,\n\tmeasureP,\n\tuseLegacyFlowWithoutGroupsForSnapshotFetch,\n\ttype TokenFetchOptionsEx,\n} from \"./odspUtils.js\";\nimport { pkgVersion } from \"./packageVersion.js\";\n\n/**\n * Enum to support different types of snapshot formats.\n * @legacy\n * @alpha\n */\nexport enum SnapshotFormatSupportType {\n\tJson = 0,\n\tBinary = 1,\n\tJsonAndBinary = 2,\n}\n\n/**\n * Fetches a snapshot from the server with a given version id.\n * @param snapshotUrl - snapshot url from where the odsp snapshot will be fetched\n * @param versionId - id of specific snapshot to be fetched\n * @param fetchFullSnapshot - whether we want to fetch full snapshot(with blobs)\n * @param forceAccessTokenViaAuthorizationHeader - Deprecated and not used, true value always used instead. Whether to force passing given token via authorization header\n * @param snapshotDownloader - Implementation of the get/post methods used to fetch the snapshot. snapshotDownloader is responsible for generating the appropriate headers (including Authorization header) as well as handling any token refreshes before retrying.\n * @returns A promise of the snapshot and the status code of the response\n */\nexport async function fetchSnapshot(\n\tsnapshotUrl: string,\n\tversionId: string,\n\tfetchFullSnapshot: boolean,\n\tforceAccessTokenViaAuthorizationHeader: boolean,\n\tlogger: ITelemetryLoggerExt,\n\tsnapshotDownloader: (url: string) => Promise<IOdspResponse<unknown>>,\n): Promise<ISnapshot> {\n\tconst path = `/trees/${versionId}`;\n\tlet queryParams: ISnapshotOptions = {};\n\n\tif (fetchFullSnapshot) {\n\t\tqueryParams = versionId === \"latest\" ? { deltas: 1, blobs: 2 } : { blobs: 2 };\n\t}\n\n\tconst queryString = getQueryString(queryParams);\n\tconst url = `${snapshotUrl}${path}${queryString}`;\n\tconst response = (await PerformanceEvent.timedExecAsync(\n\t\tlogger,\n\t\t{\n\t\t\teventName: \"fetchSnapshot\",\n\t\t},\n\t\tasync () => snapshotDownloader(url),\n\t)) as IOdspResponse<IOdspSnapshot>;\n\treturn convertOdspSnapshotToSnapshotTreeAndBlobs(response.content);\n}\n\nexport async function fetchSnapshotWithRedeem(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tstorageTokenFetcher: InstrumentedStorageTokenFetcher,\n\tsnapshotOptions: ISnapshotOptions | undefined,\n\tforceAccessTokenViaAuthorizationHeader: boolean,\n\tlogger: ITelemetryLoggerExt,\n\tsnapshotDownloader: (\n\t\tfinalOdspResolvedUrl: IOdspResolvedUrl,\n\t\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\t\ttokenFetchOptions: TokenFetchOptionsEx,\n\t\tloadingGroupIds: string[] | undefined,\n\t\tsnapshotOptions: ISnapshotOptions | undefined,\n\t\tcontroller?: AbortController,\n\t) => Promise<ISnapshotRequestAndResponseOptions>,\n\tputInCache: (valueWithEpoch: IVersionedValueWithEpoch) => Promise<void>,\n\tremoveEntries: () => Promise<void>,\n\tloadingGroupIds: string[] | undefined,\n\tenableRedeemFallback?: boolean,\n): Promise<ISnapshot> {\n\t// back-compat: This block to be removed with #8784 when we only consume/consider odsp resolvers that are >= 0.51\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\tconst sharingLinkToRedeem = (odspResolvedUrl as any).sharingLinkToRedeem;\n\tif (sharingLinkToRedeem) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\todspResolvedUrl.shareLinkInfo = { ...odspResolvedUrl.shareLinkInfo, sharingLinkToRedeem };\n\t}\n\n\treturn fetchLatestSnapshotCore(\n\t\todspResolvedUrl,\n\t\tstorageTokenFetcher,\n\t\tsnapshotOptions,\n\t\tlogger,\n\t\tsnapshotDownloader,\n\t\tputInCache,\n\t\tloadingGroupIds,\n\t\tenableRedeemFallback,\n\t)\n\t\t.catch(async (error) => {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\tif (enableRedeemFallback && isRedeemSharingLinkError(odspResolvedUrl, error)) {\n\t\t\t\t// Execute the redeem fallback\n\t\t\t\tawait redeemSharingLink(odspResolvedUrl, storageTokenFetcher, logger);\n\n\t\t\t\tconst odspResolvedUrlWithoutShareLink: IOdspResolvedUrl = {\n\t\t\t\t\t...odspResolvedUrl,\n\t\t\t\t\tshareLinkInfo: {\n\t\t\t\t\t\t...odspResolvedUrl.shareLinkInfo,\n\t\t\t\t\t\tsharingLinkToRedeem: undefined,\n\t\t\t\t\t},\n\t\t\t\t};\n\n\t\t\t\t// Log initial failure only if redeem succeeded - it points out to some bug somewhere\n\t\t\t\t// If redeem failed, that most likely means user has no permissions to access a file,\n\t\t\t\t// and thus it's not worth it logging extra errors - same error will be logged by end-to-end\n\t\t\t\t// flow (container open) based on a failure above.\n\t\t\t\tlogger.sendTelemetryEvent(\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: \"RedeemFallback\",\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n\t\t\t\t\t\terrorType: error.errorType,\n\t\t\t\t\t},\n\t\t\t\t\terror,\n\t\t\t\t);\n\n\t\t\t\treturn fetchLatestSnapshotCore(\n\t\t\t\t\todspResolvedUrlWithoutShareLink,\n\t\t\t\t\tstorageTokenFetcher,\n\t\t\t\t\tsnapshotOptions,\n\t\t\t\t\tlogger,\n\t\t\t\t\tsnapshotDownloader,\n\t\t\t\t\tputInCache,\n\t\t\t\t\tloadingGroupIds,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t})\n\t\t.catch(async (error) => {\n\t\t\t// Clear the cache on 401/403/404 on snapshot fetch from network because this means either the user doesn't\n\t\t\t// have permissions for the file or it was deleted. So, if we do not clear cache, we will continue fetching\n\t\t\t// snapshot from cache in the future.\n\t\t\tif (\n\t\t\t\t(typeof error === \"object\" &&\n\t\t\t\t\terror !== null &&\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\t\t\terror.errorType === OdspErrorTypes.authorizationError) ||\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\t\terror.errorType === OdspErrorTypes.fileNotFoundOrAccessDeniedError\n\t\t\t) {\n\t\t\t\tawait removeEntries();\n\t\t\t}\n\t\t\tthrow error;\n\t\t});\n}\n\nasync function redeemSharingLink(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\tlogger: ITelemetryLoggerExt,\n): Promise<void> {\n\tawait PerformanceEvent.timedExecAsync(\n\t\tlogger,\n\t\t{\n\t\t\teventName: \"RedeemShareLink\",\n\t\t},\n\t\tasync (event) => {\n\t\t\tassert(\n\t\t\t\t!!odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem,\n\t\t\t\t0x1ed /* \"Share link should be present\" */,\n\t\t\t);\n\n\t\t\tconst encodedShareUrl = getEncodedShareUrl(\n\t\t\t\todspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem,\n\t\t\t);\n\n\t\t\tconst isRedemptionNonDurable: boolean =\n\t\t\t\todspResolvedUrl.shareLinkInfo?.isRedemptionNonDurable === true;\n\n\t\t\tlet redeemUrl: string | undefined;\n\t\t\tasync function callSharesAPI(baseUrl: string): Promise<void> {\n\t\t\t\tawait getWithRetryForTokenRefresh(async (tokenFetchOptions) => {\n\t\t\t\t\t// IMPORTANT: Note that redeemUrl has '/driveItem' in it. Technically it is not required for executing redeem operation.\n\t\t\t\t\t// However, we have other cases that use '/shares' API and do require to specify '/driveItem' in order to get specific\n\t\t\t\t\t// drive item properties. The reason this matters is when caller of this API must possess logical permissions to call\n\t\t\t\t\t// this API (for instance, this will be the case when call is made with app-only token) then two separate logical\n\t\t\t\t\t// permissions are needed for the '/shares' call with and without '/driveItem'.\n\t\t\t\t\tredeemUrl = `${baseUrl}/_api/v2.0/shares/${encodedShareUrl}/driveItem`;\n\t\t\t\t\tconst url = redeemUrl;\n\t\t\t\t\tconst method = \"GET\";\n\t\t\t\t\tconst authHeader = await getAuthHeader(\n\t\t\t\t\t\t{ ...tokenFetchOptions, request: { url, method } },\n\t\t\t\t\t\t\"RedeemShareLink\",\n\t\t\t\t\t);\n\t\t\t\t\tconst headers = getHeadersWithAuth(authHeader);\n\t\t\t\t\theaders.prefer = isRedemptionNonDurable ? \"nonDurableRedeem\" : \"redeemSharingLink\";\n\t\t\t\t\tawait fetchAndParseAsJSONHelper(url, { headers, method });\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst details = JSON.stringify({\n\t\t\t\tlength: redeemUrl?.length,\n\t\t\t\tshareLinkUrlLength: odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem.length,\n\t\t\t\tqueryParamsLength: new URL(odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem).search\n\t\t\t\t\t.length,\n\t\t\t\tuseHeaders: true,\n\t\t\t\tisRedemptionNonDurable,\n\t\t\t});\n\t\t\t// There is an issue where if we use the siteUrl in /shares, then the allowed length of url is just a few hundred characters(300-400)\n\t\t\t// and we fail to do the redeem. But if we use the tenant domain in the url, then the allowed length becomes 2048. So,\n\t\t\t// construct the url for /shares using tenant domain. We get tenant domain by getting origin of the siteUrl.\n\t\t\ttry {\n\t\t\t\tawait callSharesAPI(new URL(odspResolvedUrl.siteUrl).origin);\n\t\t\t\tevent.end({ details });\n\t\t\t} catch (error) {\n\t\t\t\tevent.cancel({ details }, error);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\t);\n}\n\nasync function fetchLatestSnapshotCore(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\tsnapshotOptions: ISnapshotOptions | undefined,\n\tlogger: ITelemetryLoggerExt,\n\tsnapshotDownloader: (\n\t\tfinalOdspResolvedUrl: IOdspResolvedUrl,\n\t\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\t\ttokenFetchOptions: TokenFetchOptionsEx,\n\t\tloadingGroupIds: string[] | undefined,\n\t\tsnapshotOptions: ISnapshotOptions | undefined,\n\t\tcontroller?: AbortController,\n\t) => Promise<ISnapshotRequestAndResponseOptions>,\n\tputInCache: (valueWithEpoch: IVersionedValueWithEpoch) => Promise<void>,\n\tloadingGroupIds: string[] | undefined,\n\tenableRedeemFallback?: boolean,\n): Promise<ISnapshot> {\n\treturn getWithRetryForTokenRefresh(async (tokenFetchOptions) => {\n\t\tconst fetchSnapshotForLoadingGroup = isSnapshotFetchForLoadingGroup(loadingGroupIds);\n\t\tconst eventName = fetchSnapshotForLoadingGroup ? \"TreesLatestForGroup\" : \"TreesLatest\";\n\t\tconst internalFarmType = checkForKnownServerFarmType(odspResolvedUrl.siteUrl);\n\t\tconst isRedemptionNonDurable: boolean =\n\t\t\todspResolvedUrl.shareLinkInfo?.isRedemptionNonDurable === true;\n\n\t\tconst perfEvent = {\n\t\t\teventName,\n\t\t\tattempts: tokenFetchOptions.refresh ? 2 : 1,\n\t\t\tshareLinkPresent: odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem !== undefined,\n\t\t\tisSummarizer: odspResolvedUrl.summarizer,\n\t\t\tredeemFallbackEnabled: enableRedeemFallback,\n\t\t\tdetails: {\n\t\t\t\tinternalFarmType,\n\t\t\t\t// Whether the redemption used is non-durable or not.\n\t\t\t\tisRedemptionNonDurable,\n\t\t\t},\n\t\t};\n\t\tif (snapshotOptions !== undefined) {\n\t\t\tfor (const [key, value] of Object.entries(snapshotOptions)) {\n\t\t\t\tif (value !== undefined) {\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\t\tperfEvent[`snapshotOption_${key}`] = value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// This event measures only successful cases of getLatest call (no tokens, no retries).\n\t\treturn PerformanceEvent.timedExecAsync(logger, perfEvent, async (event) => {\n\t\t\tlet controller: AbortController | undefined;\n\t\t\tlet fetchTimeout: ReturnType<typeof setTimeout> | undefined;\n\t\t\tif (snapshotOptions?.timeout !== undefined) {\n\t\t\t\tcontroller = new AbortController();\n\t\t\t\tfetchTimeout = setTimeout(() => controller!.abort(), snapshotOptions.timeout);\n\t\t\t}\n\n\t\t\tconst [response, fetchTime] = await measureP(async () =>\n\t\t\t\tsnapshotDownloader(\n\t\t\t\t\todspResolvedUrl,\n\t\t\t\t\tgetAuthHeader,\n\t\t\t\t\ttokenFetchOptions,\n\t\t\t\t\tloadingGroupIds,\n\t\t\t\t\tsnapshotOptions,\n\t\t\t\t\tcontroller,\n\t\t\t\t),\n\t\t\t).finally(() => {\n\t\t\t\t// Clear the fetchTimeout once the response is fetched.\n\t\t\t\tif (fetchTimeout !== undefined) {\n\t\t\t\t\tclearTimeout(fetchTimeout);\n\t\t\t\t\tfetchTimeout = undefined;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tconst odspResponse = response.odspResponse;\n\t\t\tconst contentType = odspResponse.headers.get(\"content-type\");\n\n\t\t\tconst propsToLog: DriverErrorTelemetryProps = {\n\t\t\t\t...odspResponse.propsToLog,\n\t\t\t\tcontentType,\n\t\t\t\taccept: response.requestHeaders.accept,\n\t\t\t\tdriverVersion: pkgVersion,\n\t\t\t};\n\n\t\t\tlet parsedSnapshotContents: IOdspResponse<ISnapshotContentsWithProps> | undefined;\n\t\t\tlet contentTypeToRead: string | undefined;\n\t\t\tif (contentType?.includes(\"application/ms-fluid\")) {\n\t\t\t\tcontentTypeToRead = \"application/ms-fluid\";\n\t\t\t} else if (contentType?.includes(\"application/json\")) {\n\t\t\t\tcontentTypeToRead = \"application/json\";\n\t\t\t}\n\n\t\t\tlet parseTime: number;\n\t\t\tlet receiveContentTime: number;\n\t\t\ttry {\n\t\t\t\tswitch (contentTypeToRead) {\n\t\t\t\t\tcase \"application/json\": {\n\t\t\t\t\t\tlet text: string;\n\t\t\t\t\t\t[text, receiveContentTime] = await measureP(async () =>\n\t\t\t\t\t\t\todspResponse.content\n\t\t\t\t\t\t\t\t.text()\n\t\t\t\t\t\t\t\t.then((res) => {\n\t\t\t\t\t\t\t\t\tif (res.length === 0) {\n\t\t\t\t\t\t\t\t\t\tthrowOdspNetworkError(\n\t\t\t\t\t\t\t\t\t\t\t\"Response from browser is empty\",\n\t\t\t\t\t\t\t\t\t\t\tfetchIncorrectResponse,\n\t\t\t\t\t\t\t\t\t\t\todspResponse.content, // response\n\t\t\t\t\t\t\t\t\t\t\tundefined, // response text\n\t\t\t\t\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn res;\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t.catch((error) =>\n\t\t\t\t\t\t\t\t\t// Parsing can fail and message could contain full request URI, including\n\t\t\t\t\t\t\t\t\t// tokens, etc. So do not log error object itself.\n\t\t\t\t\t\t\t\t\tthrowOdspNetworkError(\n\t\t\t\t\t\t\t\t\t\t\"Error while parsing fetch response\",\n\t\t\t\t\t\t\t\t\t\tfetchIncorrectResponse,\n\t\t\t\t\t\t\t\t\t\todspResponse.content, // response\n\t\t\t\t\t\t\t\t\t\tundefined, // response text\n\t\t\t\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tpropsToLog.bodySize = text.length;\n\t\t\t\t\t\tlet content: IOdspSnapshot;\n\t\t\t\t\t\t[content, parseTime] = measure(() => JSON.parse(text) as IOdspSnapshot);\n\t\t\t\t\t\tvalidateBlobsAndTrees(content);\n\t\t\t\t\t\tconst snapshotContents: ISnapshot =\n\t\t\t\t\t\t\tconvertOdspSnapshotToSnapshotTreeAndBlobs(content);\n\t\t\t\t\t\tparsedSnapshotContents = {\n\t\t\t\t\t\t\t...odspResponse,\n\t\t\t\t\t\t\tcontent: {\n\t\t\t\t\t\t\t\t...snapshotContents,\n\t\t\t\t\t\t\t\ttelemetryProps: {},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"application/ms-fluid\": {\n\t\t\t\t\t\tlet content: ArrayBuffer;\n\t\t\t\t\t\t[content, receiveContentTime] = await measureP(async () =>\n\t\t\t\t\t\t\todspResponse.content\n\t\t\t\t\t\t\t\t.arrayBuffer()\n\t\t\t\t\t\t\t\t.then((res) => {\n\t\t\t\t\t\t\t\t\tif (res.byteLength === 0) {\n\t\t\t\t\t\t\t\t\t\tthrowOdspNetworkError(\n\t\t\t\t\t\t\t\t\t\t\t\"Response from browser is empty\",\n\t\t\t\t\t\t\t\t\t\t\tfetchIncorrectResponse,\n\t\t\t\t\t\t\t\t\t\t\todspResponse.content, // response\n\t\t\t\t\t\t\t\t\t\t\tundefined, // response text\n\t\t\t\t\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn res;\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t.catch((error) =>\n\t\t\t\t\t\t\t\t\t// Parsing can fail and message could contain full request URI, including\n\t\t\t\t\t\t\t\t\t// tokens, etc. So do not log error object itself.\n\t\t\t\t\t\t\t\t\tthrowOdspNetworkError(\n\t\t\t\t\t\t\t\t\t\t\"Error while parsing fetch response\",\n\t\t\t\t\t\t\t\t\t\tfetchIncorrectResponse,\n\t\t\t\t\t\t\t\t\t\todspResponse.content, // response\n\t\t\t\t\t\t\t\t\t\tundefined, // response text\n\t\t\t\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tpropsToLog.bodySize = content.byteLength;\n\t\t\t\t\t\tlet snapshotContents: ISnapshotContentsWithProps;\n\t\t\t\t\t\t[snapshotContents, parseTime] = measure(() =>\n\t\t\t\t\t\t\tparseCompactSnapshotResponse(new Uint8Array(content), logger),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tsnapshotContents.snapshotTree.trees === undefined ||\n\t\t\t\t\t\t\tsnapshotContents.snapshotTree.blobs === undefined\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\t\t\t\"Returned odsp snapshot is malformed. No trees or blobs!\",\n\t\t\t\t\t\t\t\tOdspErrorTypes.incorrectServerResponse,\n\t\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst props = snapshotContents.telemetryProps;\n\t\t\t\t\t\tconst slowTreeParseCodePaths = props.slowTreeStructureCount ?? 0;\n\t\t\t\t\t\tconst slowBlobParseCodePaths = props.slowBlobStructureCount ?? 0;\n\t\t\t\t\t\tconst treeStructureCountWithGroupId = props.treeStructureCountWithGroupId ?? 0;\n\t\t\t\t\t\t// As trees with groupId go through normal parsing, so exclude them.\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tslowTreeParseCodePaths - treeStructureCountWithGroupId > 10 ||\n\t\t\t\t\t\t\tslowBlobParseCodePaths > 10\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tlogger.sendErrorEvent({\n\t\t\t\t\t\t\t\teventName: \"SlowSnapshotParseCodePaths\",\n\t\t\t\t\t\t\t\tslowTreeStructureCount: slowTreeParseCodePaths,\n\t\t\t\t\t\t\t\tslowBlobStructureCount: slowBlobParseCodePaths,\n\t\t\t\t\t\t\t\ttreeStructureCountWithGroupId,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\tparsedSnapshotContents = { ...odspResponse, content: snapshotContents };\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tdefault: {\n\t\t\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\t\t\"Unknown snapshot content type\",\n\t\t\t\t\t\t\tOdspErrorTypes.incorrectServerResponse,\n\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tif (isFluidError(error)) {\n\t\t\t\t\terror.addTelemetryProperties(propsToLog);\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t\tconst enhancedError = wrapError(\n\t\t\t\t\terror,\n\t\t\t\t\t(errorMessage) =>\n\t\t\t\t\t\tnew NonRetryableError(\n\t\t\t\t\t\t\t`Error parsing snapshot response: ${errorMessage}`,\n\t\t\t\t\t\t\tOdspErrorTypes.genericError,\n\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\tthrow enhancedError;\n\t\t\t}\n\n\t\t\tassert(parsedSnapshotContents !== undefined, 0x312 /* snapshot should be parsed */);\n\t\t\tconst snapshot = parsedSnapshotContents.content;\n\n\t\t\t// There are some scenarios in ODSP where we cannot cache, trees/latest will explicitly tell us when we\n\t\t\t// cannot cache using an HTTP response header. Only cache snapshot if it is not for a loading group.\n\t\t\tconst canCache =\n\t\t\t\todspResponse.headers.get(\"disablebrowsercachingofusercontent\") !== \"true\" &&\n\t\t\t\t!fetchSnapshotForLoadingGroup;\n\t\t\tconst sequenceNumber: number = snapshot.sequenceNumber ?? 0;\n\t\t\tconst seqNumberFromOps =\n\t\t\t\tsnapshot.ops && snapshot.ops.length > 0\n\t\t\t\t\t? snapshot.ops[0].sequenceNumber - 1\n\t\t\t\t\t: undefined;\n\n\t\t\tif (\n\t\t\t\t!Number.isInteger(sequenceNumber) ||\n\t\t\t\t(seqNumberFromOps !== undefined && seqNumberFromOps !== sequenceNumber)\n\t\t\t) {\n\t\t\t\tlogger.sendErrorEvent({\n\t\t\t\t\teventName: \"fetchSnapshotError\",\n\t\t\t\t\tsequenceNumber,\n\t\t\t\t\tseqNumberFromOps,\n\t\t\t\t});\n\t\t\t\tsnapshot.sequenceNumber = undefined;\n\t\t\t} else if (canCache) {\n\t\t\t\tconst fluidEpoch = odspResponse.headers.get(\"x-fluid-epoch\");\n\t\t\t\tassert(fluidEpoch !== undefined, 0x1e6 /* \"Epoch should be present in response\" */);\n\t\t\t\tconst value: ISnapshotCachedEntry2 = {\n\t\t\t\t\t...snapshot,\n\t\t\t\t\tcacheEntryTime: Date.now(),\n\t\t\t\t};\n\t\t\t\tconst valueWithEpoch: IVersionedValueWithEpoch = {\n\t\t\t\t\tvalue,\n\t\t\t\t\tfluidEpoch,\n\t\t\t\t\tversion: persistedCacheValueVersion,\n\t\t\t\t};\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-floating-promises\n\t\t\t\tputInCache(valueWithEpoch);\n\t\t\t}\n\n\t\t\tevent.end({\n\t\t\t\t// trees, leafTrees, blobNodes, encodedBlobsSize,\n\t\t\t\t// blobNodes - blobs tells us (roughly) how many blobs are deduped by service.\n\t\t\t\t...getTreeStats(snapshot),\n\t\t\t\tblobs: snapshot.blobContents?.size ?? 0,\n\t\t\t\tsequenceNumber,\n\t\t\t\tops: snapshot.ops?.length ?? 0,\n\t\t\t\tfetchSnapshotForLoadingGroup,\n\t\t\t\tuseLegacyFlowWithoutGroups:\n\t\t\t\t\tuseLegacyFlowWithoutGroupsForSnapshotFetch(loadingGroupIds),\n\t\t\t\tuserOps: snapshot.ops?.filter((op) => isRuntimeMessage(op)).length ?? 0,\n\t\t\t\t// Measures time to make fetch call. Should be similar to\n\t\t\t\t// fetchStartToResponseEndTime - receiveContentTime, i.e. it looks like it's time till first byte /\n\t\t\t\t// end of response headers\n\t\t\t\tfetchTime,\n\t\t\t\t// time it takes client to parse payload. Same payload as in \"SnapshotParse\" event, here for\n\t\t\t\t// easier analyzes.\n\t\t\t\tparseTime,\n\t\t\t\t// Time it takes to receive content (text of buffer) from Response object.\n\t\t\t\t// This time likely is very closely correlated with networkTime, i.e. time it takes to receive\n\t\t\t\t// actual content (starting measuring from first bite / end of response header)\n\t\t\t\treceiveContentTime,\n\t\t\t\t...getW3CData(response.requestUrl, \"fetch\"),\n\t\t\t\t// Sharing link telemetry regarding sharing link redeem status and performance. Ex: FRL; dur=100,\n\t\t\t\t// Azure Fluid Relay service; desc=S, FRP; desc=False. Here, FRL is the duration taken for redeem,\n\t\t\t\t// Azure Fluid Relay service is the redeem status (S means success), and FRP is a flag to indicate\n\t\t\t\t// if the permission has changed.\n\t\t\t\tsltelemetry: odspResponse.headers.get(\"x-fluid-sltelemetry\"),\n\t\t\t\t// All other props\n\t\t\t\t...propsToLog,\n\t\t\t\t// Various perf counters and measures collected by binary parsing code:\n\t\t\t\t// slowTreeStructureCount, slowBlobStructureCount, durationStructure, durationStrings,\n\t\t\t\t// durationSnapshotTree, durationBlobs, etc.\n\t\t\t\t...parsedSnapshotContents.content.telemetryProps,\n\t\t\t});\n\t\t\treturn snapshot;\n\t\t}).catch((error) => {\n\t\t\t// We hit these errors in stress tests, under load\n\t\t\t// It's useful to try one more time in such case.\n\t\t\tif (\n\t\t\t\ttypeof error === \"object\" &&\n\t\t\t\terror !== null &&\n\t\t\t\t((error as Partial<IOdspError>).errorType === OdspErrorTypes.fetchFailure ||\n\t\t\t\t\t(error as Partial<IOdspError>).errorType === OdspErrorTypes.fetchTimeout)\n\t\t\t) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\t\terror[getWithRetryForTokenRefreshRepeat] = true;\n\t\t\t}\n\t\t\tthrow error;\n\t\t});\n\t});\n}\n\nexport interface ISnapshotRequestAndResponseOptions {\n\todspResponse: IOdspResponse<Response>;\n\trequestUrl: string;\n\trequestHeaders: { [index: string]: string };\n}\n\nfunction getFormBodyAndHeaders(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tauthHeader: string,\n\theaders?: { [index: string]: string },\n): {\n\tbody: string;\n\theaders: {\n\t\t[index: string]: string;\n\t};\n} {\n\tconst formBoundary = uuid();\n\tconst formParams: string[] = [];\n\tformParams.push(\n\t\t`--${formBoundary}`,\n\t\t`Authorization: ${authHeader}`,\n\t\t`X-HTTP-Method-Override: GET`,\n\t);\n\n\tif (headers !== undefined) {\n\t\tfor (const [key, value] of Object.entries(headers)) {\n\t\t\tif (value !== undefined) {\n\t\t\t\tformParams.push(`${key}: ${value}`);\n\t\t\t}\n\t\t}\n\t}\n\tif (odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem) {\n\t\tformParams.push(`sl: ${odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem}`);\n\t}\n\tformParams.push(`_post: 1`, `\\r\\n--${formBoundary}--`);\n\tconst postBody = formParams.join(\"\\r\\n\");\n\tconst header: { [index: string]: string } = {\n\t\t\"Content-Type\": `multipart/form-data;boundary=${formBoundary}`,\n\t};\n\treturn { body: postBody, headers: header };\n}\n\ninterface ITreeStats {\n\ttrees: number;\n\tleafTrees: number;\n\tblobNodes: number;\n}\n\nexport function getTreeStats(snapshot: ISnapshot): ITreeStats & { encodedBlobsSize: number } {\n\tconst stats: ITreeStats = {\n\t\ttrees: 0,\n\t\tleafTrees: 0,\n\t\tblobNodes: 0,\n\t};\n\tgetTreeStatsCore(snapshot.snapshotTree, stats);\n\tlet encodedBlobsSize = 0;\n\tfor (const [_, blobContent] of snapshot.blobContents) {\n\t\tencodedBlobsSize += blobContent.byteLength;\n\t}\n\treturn { ...stats, encodedBlobsSize };\n}\n\nexport function validateBlobsAndTrees(snapshot: IOdspSnapshot): void {\n\tassert(\n\t\tsnapshot.trees !== undefined,\n\t\t0x200 /* \"Returned odsp snapshot is malformed. No trees!\" */,\n\t);\n\tassert(\n\t\tsnapshot.blobs !== undefined,\n\t\t0x201 /* \"Returned odsp snapshot is malformed. No blobs!\" */,\n\t);\n}\n\nfunction getTreeStatsCore(snapshotTree: ISnapshotTree, stats: ITreeStats): void {\n\tstats.blobNodes += Object.entries(snapshotTree.blobs).length;\n\tstats.trees++;\n\n\tconst entries = Object.entries(snapshotTree.trees);\n\tif (entries.length === 0) {\n\t\tstats.leafTrees++;\n\t} else {\n\t\tfor (const [_, tree] of entries) {\n\t\t\tstats.trees++;\n\t\t\tgetTreeStatsCore(tree, stats);\n\t\t}\n\t}\n}\n\n/**\n * This function fetches the snapshot and parse it according to what is mentioned in response headers.\n * @param odspResolvedUrl - resolved odsp url.\n * @param storageToken - token to do the auth for network request.\n * @param snapshotOptions - Options used to specify how and what to fetch in the snapshot.\n * @param loadingGroupIds - loadingGroupIds for which snapshot needs to be downloaded. Note:\n * 1.) If undefined, then legacy trees latest call will be used where no groupId query param would be specified.\n * 2.) If [] is passed, then snapshot with all ungrouped data will be fetched.\n * 3.) If any groupId is specified like [\"g1\"], then snapshot for g1 group will be fetched.\n * @param snapshotFormatFetchType - Snapshot format to fetch.\n * @param controller - abort controller if caller needs to abort the network call.\n * @param epochTracker - epoch tracker used to add/validate epoch in the network call.\n * @returns fetched snapshot.\n */\nexport const downloadSnapshot = mockify(\n\tasync (\n\t\todspResolvedUrl: IOdspResolvedUrl,\n\t\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\t\ttokenFetchOptions: TokenFetchOptionsEx,\n\t\tloadingGroupIds: string[] | undefined,\n\t\tsnapshotOptions: ISnapshotOptions | undefined,\n\t\tsnapshotFormatFetchType?: SnapshotFormatSupportType,\n\t\tcontroller?: AbortController,\n\t\tepochTracker?: EpochTracker,\n\t\tscenarioName?: string,\n\t): Promise<ISnapshotRequestAndResponseOptions> => {\n\t\t// back-compat: This block to be removed with #8784 when we only consume/consider odsp resolvers that are >= 0.51\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\t\tconst sharingLinkToRedeem = (odspResolvedUrl as any).sharingLinkToRedeem;\n\t\tif (sharingLinkToRedeem) {\n\t\t\todspResolvedUrl.shareLinkInfo = {\n\t\t\t\t...odspResolvedUrl.shareLinkInfo,\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\tsharingLinkToRedeem,\n\t\t\t};\n\t\t}\n\n\t\tconst snapshotUrl = odspResolvedUrl.endpoints.snapshotStorageUrl;\n\n\t\tconst queryParams: Record<string, unknown> = { ump: 1 };\n\t\tif (snapshotOptions !== undefined) {\n\t\t\tfor (const [key, value] of Object.entries(snapshotOptions)) {\n\t\t\t\t// Exclude \"timeout\" from query string\n\t\t\t\tif (value !== undefined && key !== \"timeout\") {\n\t\t\t\t\tqueryParams[key] = value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (loadingGroupIds !== undefined) {\n\t\t\tqueryParams.groupId = loadingGroupIds.join(\",\");\n\t\t}\n\n\t\tconst queryString = getQueryString(queryParams);\n\t\tconst url = `${snapshotUrl}/trees/latest${queryString}`;\n\t\tconst method = \"POST\";\n\t\tconst isRedemptionNonDurable: boolean =\n\t\t\todspResolvedUrl.shareLinkInfo?.isRedemptionNonDurable === true;\n\t\t// The location of file can move on Spo in which case server returns 308(Permanent Redirect) error.\n\t\t// Adding below header will make VROOM API return 404 instead of 308 and browser can intercept it.\n\t\t// This error thrown by server will contain the new redirect location. Look at the 404 error parsing\n\t\t// for further reference here: \\packages\\utils\\odsp-doclib-utils\\src\\odspErrorUtils.ts\n\t\t// If the share link is non-durable, we will add the nonDurableRedeem header to the header.prefer.\n\t\tconst header: { [key: string]: string } = isRedemptionNonDurable\n\t\t\t? { prefer: \"manualredirect, nonDurableRedeem\" }\n\t\t\t: { prefer: \"manualredirect\" };\n\t\t// Epoch tracker is handling adding the CLP Compliant App header, so only when a flow does not\n\t\t// use epoch tracker, we add the header.\n\t\tif (epochTracker === undefined && odspResolvedUrl.isClpCompliantApp !== undefined) {\n\t\t\theader[ClpCompliantAppHeader.isClpCompliantApp] =\n\t\t\t\todspResolvedUrl.isClpCompliantApp.toString();\n\t\t}\n\t\tconst authHeader = await getAuthHeader(\n\t\t\t{ ...tokenFetchOptions, request: { url, method } },\n\t\t\t\"downloadSnapshot\",\n\t\t);\n\t\tassert(authHeader !== null, 0x1e5 /* \"Storage token should not be null\" */);\n\t\tconst { body, headers } = getFormBodyAndHeaders(odspResolvedUrl, authHeader, header);\n\t\tconst fetchOptions = {\n\t\t\tbody,\n\t\t\theaders,\n\t\t\tsignal: controller?.signal,\n\t\t\tmethod,\n\t\t};\n\t\t// Decide what snapshot format to fetch as per the feature gate.\n\t\tswitch (snapshotFormatFetchType) {\n\t\t\tcase SnapshotFormatSupportType.Binary: {\n\t\t\t\theaders.accept = `application/ms-fluid; v=${currentReadVersion}`;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\t// By default ask both versions and let the server decide the format.\n\t\t\t\theaders.accept = `application/json, application/ms-fluid; v=${currentReadVersion}`;\n\t\t\t}\n\t\t}\n\n\t\tconst odspResponse = await (epochTracker?.fetch(\n\t\t\turl,\n\t\t\tfetchOptions,\n\t\t\t\"treesLatest\",\n\t\t\ttrue,\n\t\t\tscenarioName,\n\t\t) ?? fetchHelper(url, fetchOptions));\n\n\t\treturn {\n\t\t\todspResponse,\n\t\t\trequestHeaders: headers,\n\t\t\trequestUrl: url,\n\t\t};\n\t},\n);\n\nfunction isRedeemSharingLinkError(\n\todspResolvedUrl: IOdspResolvedUrl,\n\terror: Partial<IOdspError>,\n): boolean {\n\tif (\n\t\todspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem !== undefined &&\n\t\ttypeof error === \"object\" &&\n\t\terror !== null &&\n\t\t(error.errorType === OdspErrorTypes.authorizationError ||\n\t\t\terror.errorType === OdspErrorTypes.fileNotFoundOrAccessDeniedError)\n\t) {\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nfunction getEncodedShareUrl(url: string): string {\n\t/**\n\t * Encode the url to accepted format by Sharepoint\n\t * https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/shares_get\n\t */\n\tlet encodedUrl = fromUtf8ToBase64(encodeURI(url));\n\tencodedUrl = encodedUrl.replace(/=+$/g, \"\").replace(/\\//g, \"_\").replace(/\\+/g, \"-\");\n\tencodedUrl = \"u!\".concat(encodedUrl);\n\treturn encodedUrl;\n}\n"]}
1
+ {"version":3,"file":"fetchSnapshot.js","sourceRoot":"","sources":["../src/fetchSnapshot.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAgE;AAChE,kEAA6D;AAC7D,mEAAkE;AAElE,oEAI+C;AAC/C,yEAGoD;AACpD,+EAM0D;AAC1D,uEAKkD;AAClD,+BAAkC;AAElC,yEAIoC;AACpC,iDAKwB;AACxB,6DAA6D;AAE7D,2DAAqD;AACrD,+EAAmE;AACnE,6CAAuC;AACvC,mEAAoF;AACpF,yDAAiE;AACjE,iDAWwB;AACxB,2DAAiD;AAEjD;;;;GAIG;AACH,IAAY,yBAIX;AAJD,WAAY,yBAAyB;IACpC,yEAAQ,CAAA;IACR,6EAAU,CAAA;IACV,2FAAiB,CAAA;AAClB,CAAC,EAJW,yBAAyB,yCAAzB,yBAAyB,QAIpC;AAED;;;;;;;;GAQG;AACI,KAAK,UAAU,aAAa,CAClC,WAAmB,EACnB,SAAiB,EACjB,iBAA0B,EAC1B,sCAA+C,EAC/C,MAA2B,EAC3B,kBAAoE;IAEpE,MAAM,IAAI,GAAG,UAAU,SAAS,EAAE,CAAC;IACnC,IAAI,WAAW,GAAqB,EAAE,CAAC;IAEvC,IAAI,iBAAiB,EAAE,CAAC;QACvB,WAAW,GAAG,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EA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EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACpF,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACrC,OAAO,UAAU,CAAC;AACnB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { fromUtf8ToBase64 } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { getW3CData } from \"@fluidframework/driver-base/internal\";\nimport type { ISnapshot, ISnapshotTree } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\ttype DriverErrorTelemetryProps,\n\tNonRetryableError,\n\tisRuntimeMessage,\n} from \"@fluidframework/driver-utils/internal\";\nimport {\n\tfetchIncorrectResponse,\n\tthrowOdspNetworkError,\n} from \"@fluidframework/odsp-doclib-utils/internal\";\nimport {\n\ttype IOdspError,\n\ttype IOdspResolvedUrl,\n\ttype ISnapshotOptions,\n\ttype InstrumentedStorageTokenFetcher,\n\tOdspErrorTypes,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\ttype ITelemetryLoggerExt,\n\tPerformanceEvent,\n\tisFluidError,\n\twrapError,\n} from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport {\n\ttype ISnapshotContentsWithProps,\n\tcurrentReadVersion,\n\tparseCompactSnapshotResponse,\n} from \"./compactSnapshotParser.js\";\nimport {\n\ttype IOdspSnapshot,\n\ttype ISnapshotCachedEntry2,\n\ttype IVersionedValueWithEpoch,\n\tpersistedCacheValueVersion,\n} from \"./contracts.js\";\nimport { ClpCompliantAppHeader } from \"./contractsPublic.js\";\nimport type { EpochTracker } from \"./epochTracker.js\";\nimport { getQueryString } from \"./getQueryString.js\";\nimport { getHeadersWithAuth } from \"./getUrlAndHeadersWithAuth.js\";\nimport { mockify } from \"./mockify.js\";\nimport { convertOdspSnapshotToSnapshotTreeAndBlobs } from \"./odspSnapshotParser.js\";\nimport { checkForKnownServerFarmType } from \"./odspUrlHelper.js\";\nimport {\n\ttype IOdspResponse,\n\tfetchAndParseAsJSONHelper,\n\tfetchHelper,\n\tgetWithRetryForTokenRefresh,\n\tgetWithRetryForTokenRefreshRepeat,\n\tisSnapshotFetchForLoadingGroup,\n\tmeasure,\n\tmeasureP,\n\tuseLegacyFlowWithoutGroupsForSnapshotFetch,\n\ttype TokenFetchOptionsEx,\n} from \"./odspUtils.js\";\nimport { pkgVersion } from \"./packageVersion.js\";\n\n/**\n * Enum to support different types of snapshot formats.\n * @legacy\n * @beta\n */\nexport enum SnapshotFormatSupportType {\n\tJson = 0,\n\tBinary = 1,\n\tJsonAndBinary = 2,\n}\n\n/**\n * Fetches a snapshot from the server with a given version id.\n * @param snapshotUrl - snapshot url from where the odsp snapshot will be fetched\n * @param versionId - id of specific snapshot to be fetched\n * @param fetchFullSnapshot - whether we want to fetch full snapshot(with blobs)\n * @param forceAccessTokenViaAuthorizationHeader - Deprecated and not used, true value always used instead. Whether to force passing given token via authorization header\n * @param snapshotDownloader - Implementation of the get/post methods used to fetch the snapshot. snapshotDownloader is responsible for generating the appropriate headers (including Authorization header) as well as handling any token refreshes before retrying.\n * @returns A promise of the snapshot and the status code of the response\n */\nexport async function fetchSnapshot(\n\tsnapshotUrl: string,\n\tversionId: string,\n\tfetchFullSnapshot: boolean,\n\tforceAccessTokenViaAuthorizationHeader: boolean,\n\tlogger: ITelemetryLoggerExt,\n\tsnapshotDownloader: (url: string) => Promise<IOdspResponse<unknown>>,\n): Promise<ISnapshot> {\n\tconst path = `/trees/${versionId}`;\n\tlet queryParams: ISnapshotOptions = {};\n\n\tif (fetchFullSnapshot) {\n\t\tqueryParams = versionId === \"latest\" ? { deltas: 1, blobs: 2 } : { blobs: 2 };\n\t}\n\n\tconst queryString = getQueryString(queryParams);\n\tconst url = `${snapshotUrl}${path}${queryString}`;\n\tconst response = (await PerformanceEvent.timedExecAsync(\n\t\tlogger,\n\t\t{\n\t\t\teventName: \"fetchSnapshot\",\n\t\t},\n\t\tasync () => snapshotDownloader(url),\n\t)) as IOdspResponse<IOdspSnapshot>;\n\treturn convertOdspSnapshotToSnapshotTreeAndBlobs(response.content);\n}\n\nexport async function fetchSnapshotWithRedeem(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tstorageTokenFetcher: InstrumentedStorageTokenFetcher,\n\tsnapshotOptions: ISnapshotOptions | undefined,\n\tforceAccessTokenViaAuthorizationHeader: boolean,\n\tlogger: ITelemetryLoggerExt,\n\tsnapshotDownloader: (\n\t\tfinalOdspResolvedUrl: IOdspResolvedUrl,\n\t\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\t\ttokenFetchOptions: TokenFetchOptionsEx,\n\t\tloadingGroupIds: string[] | undefined,\n\t\tsnapshotOptions: ISnapshotOptions | undefined,\n\t\tcontroller?: AbortController,\n\t) => Promise<ISnapshotRequestAndResponseOptions>,\n\tputInCache: (valueWithEpoch: IVersionedValueWithEpoch) => Promise<void>,\n\tremoveEntries: () => Promise<void>,\n\tloadingGroupIds: string[] | undefined,\n\tenableRedeemFallback?: boolean,\n): Promise<ISnapshot> {\n\t// back-compat: This block to be removed with #8784 when we only consume/consider odsp resolvers that are >= 0.51\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\tconst sharingLinkToRedeem = (odspResolvedUrl as any).sharingLinkToRedeem;\n\tif (sharingLinkToRedeem) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\todspResolvedUrl.shareLinkInfo = { ...odspResolvedUrl.shareLinkInfo, sharingLinkToRedeem };\n\t}\n\n\treturn fetchLatestSnapshotCore(\n\t\todspResolvedUrl,\n\t\tstorageTokenFetcher,\n\t\tsnapshotOptions,\n\t\tlogger,\n\t\tsnapshotDownloader,\n\t\tputInCache,\n\t\tloadingGroupIds,\n\t\tenableRedeemFallback,\n\t)\n\t\t.catch(async (error) => {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\tif (enableRedeemFallback && isRedeemSharingLinkError(odspResolvedUrl, error)) {\n\t\t\t\t// Execute the redeem fallback\n\t\t\t\tawait redeemSharingLink(odspResolvedUrl, storageTokenFetcher, logger);\n\n\t\t\t\tconst odspResolvedUrlWithoutShareLink: IOdspResolvedUrl = {\n\t\t\t\t\t...odspResolvedUrl,\n\t\t\t\t\tshareLinkInfo: {\n\t\t\t\t\t\t...odspResolvedUrl.shareLinkInfo,\n\t\t\t\t\t\tsharingLinkToRedeem: undefined,\n\t\t\t\t\t},\n\t\t\t\t};\n\n\t\t\t\t// Log initial failure only if redeem succeeded - it points out to some bug somewhere\n\t\t\t\t// If redeem failed, that most likely means user has no permissions to access a file,\n\t\t\t\t// and thus it's not worth it logging extra errors - same error will be logged by end-to-end\n\t\t\t\t// flow (container open) based on a failure above.\n\t\t\t\tlogger.sendTelemetryEvent(\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: \"RedeemFallback\",\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n\t\t\t\t\t\terrorType: error.errorType,\n\t\t\t\t\t},\n\t\t\t\t\terror,\n\t\t\t\t);\n\n\t\t\t\treturn fetchLatestSnapshotCore(\n\t\t\t\t\todspResolvedUrlWithoutShareLink,\n\t\t\t\t\tstorageTokenFetcher,\n\t\t\t\t\tsnapshotOptions,\n\t\t\t\t\tlogger,\n\t\t\t\t\tsnapshotDownloader,\n\t\t\t\t\tputInCache,\n\t\t\t\t\tloadingGroupIds,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t})\n\t\t.catch(async (error) => {\n\t\t\t// Clear the cache on 401/403/404 on snapshot fetch from network because this means either the user doesn't\n\t\t\t// have permissions for the file or it was deleted. So, if we do not clear cache, we will continue fetching\n\t\t\t// snapshot from cache in the future.\n\t\t\tif (\n\t\t\t\t(typeof error === \"object\" &&\n\t\t\t\t\terror !== null &&\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\t\t\terror.errorType === OdspErrorTypes.authorizationError) ||\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\t\terror.errorType === OdspErrorTypes.fileNotFoundOrAccessDeniedError\n\t\t\t) {\n\t\t\t\tawait removeEntries();\n\t\t\t}\n\t\t\tthrow error;\n\t\t});\n}\n\nasync function redeemSharingLink(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\tlogger: ITelemetryLoggerExt,\n): Promise<void> {\n\tawait PerformanceEvent.timedExecAsync(\n\t\tlogger,\n\t\t{\n\t\t\teventName: \"RedeemShareLink\",\n\t\t},\n\t\tasync (event) => {\n\t\t\tassert(\n\t\t\t\t!!odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem,\n\t\t\t\t0x1ed /* \"Share link should be present\" */,\n\t\t\t);\n\n\t\t\tconst encodedShareUrl = getEncodedShareUrl(\n\t\t\t\todspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem,\n\t\t\t);\n\n\t\t\tconst isRedemptionNonDurable: boolean =\n\t\t\t\todspResolvedUrl.shareLinkInfo?.isRedemptionNonDurable === true;\n\n\t\t\tlet redeemUrl: string | undefined;\n\t\t\tasync function callSharesAPI(baseUrl: string): Promise<void> {\n\t\t\t\tawait getWithRetryForTokenRefresh(async (tokenFetchOptions) => {\n\t\t\t\t\t// IMPORTANT: Note that redeemUrl has '/driveItem' in it. Technically it is not required for executing redeem operation.\n\t\t\t\t\t// However, we have other cases that use '/shares' API and do require to specify '/driveItem' in order to get specific\n\t\t\t\t\t// drive item properties. The reason this matters is when caller of this API must possess logical permissions to call\n\t\t\t\t\t// this API (for instance, this will be the case when call is made with app-only token) then two separate logical\n\t\t\t\t\t// permissions are needed for the '/shares' call with and without '/driveItem'.\n\t\t\t\t\tredeemUrl = `${baseUrl}/_api/v2.0/shares/${encodedShareUrl}/driveItem`;\n\t\t\t\t\tconst url = redeemUrl;\n\t\t\t\t\tconst method = \"GET\";\n\t\t\t\t\tconst authHeader = await getAuthHeader(\n\t\t\t\t\t\t{ ...tokenFetchOptions, request: { url, method } },\n\t\t\t\t\t\t\"RedeemShareLink\",\n\t\t\t\t\t);\n\t\t\t\t\tconst headers = getHeadersWithAuth(authHeader);\n\t\t\t\t\theaders.prefer = isRedemptionNonDurable ? \"nonDurableRedeem\" : \"redeemSharingLink\";\n\t\t\t\t\tawait fetchAndParseAsJSONHelper(url, { headers, method });\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst details = JSON.stringify({\n\t\t\t\tlength: redeemUrl?.length,\n\t\t\t\tshareLinkUrlLength: odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem.length,\n\t\t\t\tqueryParamsLength: new URL(odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem).search\n\t\t\t\t\t.length,\n\t\t\t\tuseHeaders: true,\n\t\t\t\tisRedemptionNonDurable,\n\t\t\t});\n\t\t\t// There is an issue where if we use the siteUrl in /shares, then the allowed length of url is just a few hundred characters(300-400)\n\t\t\t// and we fail to do the redeem. But if we use the tenant domain in the url, then the allowed length becomes 2048. So,\n\t\t\t// construct the url for /shares using tenant domain. We get tenant domain by getting origin of the siteUrl.\n\t\t\ttry {\n\t\t\t\tawait callSharesAPI(new URL(odspResolvedUrl.siteUrl).origin);\n\t\t\t\tevent.end({ details });\n\t\t\t} catch (error) {\n\t\t\t\tevent.cancel({ details }, error);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\t);\n}\n\nasync function fetchLatestSnapshotCore(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\tsnapshotOptions: ISnapshotOptions | undefined,\n\tlogger: ITelemetryLoggerExt,\n\tsnapshotDownloader: (\n\t\tfinalOdspResolvedUrl: IOdspResolvedUrl,\n\t\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\t\ttokenFetchOptions: TokenFetchOptionsEx,\n\t\tloadingGroupIds: string[] | undefined,\n\t\tsnapshotOptions: ISnapshotOptions | undefined,\n\t\tcontroller?: AbortController,\n\t) => Promise<ISnapshotRequestAndResponseOptions>,\n\tputInCache: (valueWithEpoch: IVersionedValueWithEpoch) => Promise<void>,\n\tloadingGroupIds: string[] | undefined,\n\tenableRedeemFallback?: boolean,\n): Promise<ISnapshot> {\n\treturn getWithRetryForTokenRefresh(async (tokenFetchOptions) => {\n\t\tconst fetchSnapshotForLoadingGroup = isSnapshotFetchForLoadingGroup(loadingGroupIds);\n\t\tconst eventName = fetchSnapshotForLoadingGroup ? \"TreesLatestForGroup\" : \"TreesLatest\";\n\t\tconst internalFarmType = checkForKnownServerFarmType(odspResolvedUrl.siteUrl);\n\t\tconst isRedemptionNonDurable: boolean =\n\t\t\todspResolvedUrl.shareLinkInfo?.isRedemptionNonDurable === true;\n\n\t\tconst perfEvent = {\n\t\t\teventName,\n\t\t\tattempts: tokenFetchOptions.refresh ? 2 : 1,\n\t\t\tshareLinkPresent: odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem !== undefined,\n\t\t\tisSummarizer: odspResolvedUrl.summarizer,\n\t\t\tredeemFallbackEnabled: enableRedeemFallback,\n\t\t\tdetails: {\n\t\t\t\tinternalFarmType,\n\t\t\t\t// Whether the redemption used is non-durable or not.\n\t\t\t\tisRedemptionNonDurable,\n\t\t\t},\n\t\t};\n\t\tif (snapshotOptions !== undefined) {\n\t\t\tfor (const [key, value] of Object.entries(snapshotOptions)) {\n\t\t\t\tif (value !== undefined) {\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\t\tperfEvent[`snapshotOption_${key}`] = value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// This event measures only successful cases of getLatest call (no tokens, no retries).\n\t\treturn PerformanceEvent.timedExecAsync(logger, perfEvent, async (event) => {\n\t\t\tlet controller: AbortController | undefined;\n\t\t\tlet fetchTimeout: ReturnType<typeof setTimeout> | undefined;\n\t\t\tif (snapshotOptions?.timeout !== undefined) {\n\t\t\t\tcontroller = new AbortController();\n\t\t\t\tfetchTimeout = setTimeout(() => controller!.abort(), snapshotOptions.timeout);\n\t\t\t}\n\n\t\t\tconst [response, fetchTime] = await measureP(async () =>\n\t\t\t\tsnapshotDownloader(\n\t\t\t\t\todspResolvedUrl,\n\t\t\t\t\tgetAuthHeader,\n\t\t\t\t\ttokenFetchOptions,\n\t\t\t\t\tloadingGroupIds,\n\t\t\t\t\tsnapshotOptions,\n\t\t\t\t\tcontroller,\n\t\t\t\t),\n\t\t\t).finally(() => {\n\t\t\t\t// Clear the fetchTimeout once the response is fetched.\n\t\t\t\tif (fetchTimeout !== undefined) {\n\t\t\t\t\tclearTimeout(fetchTimeout);\n\t\t\t\t\tfetchTimeout = undefined;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tconst odspResponse = response.odspResponse;\n\t\t\tconst contentType = odspResponse.headers.get(\"content-type\");\n\n\t\t\tconst propsToLog: DriverErrorTelemetryProps = {\n\t\t\t\t...odspResponse.propsToLog,\n\t\t\t\tcontentType,\n\t\t\t\taccept: response.requestHeaders.accept,\n\t\t\t\tdriverVersion: pkgVersion,\n\t\t\t};\n\n\t\t\tlet parsedSnapshotContents: IOdspResponse<ISnapshotContentsWithProps> | undefined;\n\t\t\tlet contentTypeToRead: string | undefined;\n\t\t\tif (contentType?.includes(\"application/ms-fluid\")) {\n\t\t\t\tcontentTypeToRead = \"application/ms-fluid\";\n\t\t\t} else if (contentType?.includes(\"application/json\")) {\n\t\t\t\tcontentTypeToRead = \"application/json\";\n\t\t\t}\n\n\t\t\tlet parseTime: number;\n\t\t\tlet receiveContentTime: number;\n\t\t\ttry {\n\t\t\t\tswitch (contentTypeToRead) {\n\t\t\t\t\tcase \"application/json\": {\n\t\t\t\t\t\tlet text: string;\n\t\t\t\t\t\t[text, receiveContentTime] = await measureP(async () =>\n\t\t\t\t\t\t\todspResponse.content\n\t\t\t\t\t\t\t\t.text()\n\t\t\t\t\t\t\t\t.then((res) => {\n\t\t\t\t\t\t\t\t\tif (res.length === 0) {\n\t\t\t\t\t\t\t\t\t\tthrowOdspNetworkError(\n\t\t\t\t\t\t\t\t\t\t\t\"Response from browser is empty\",\n\t\t\t\t\t\t\t\t\t\t\tfetchIncorrectResponse,\n\t\t\t\t\t\t\t\t\t\t\todspResponse.content, // response\n\t\t\t\t\t\t\t\t\t\t\tundefined, // response text\n\t\t\t\t\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn res;\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t.catch((error) =>\n\t\t\t\t\t\t\t\t\t// Parsing can fail and message could contain full request URI, including\n\t\t\t\t\t\t\t\t\t// tokens, etc. So do not log error object itself.\n\t\t\t\t\t\t\t\t\tthrowOdspNetworkError(\n\t\t\t\t\t\t\t\t\t\t\"Error while parsing fetch response\",\n\t\t\t\t\t\t\t\t\t\tfetchIncorrectResponse,\n\t\t\t\t\t\t\t\t\t\todspResponse.content, // response\n\t\t\t\t\t\t\t\t\t\tundefined, // response text\n\t\t\t\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tpropsToLog.bodySize = text.length;\n\t\t\t\t\t\tlet content: IOdspSnapshot;\n\t\t\t\t\t\t[content, parseTime] = measure(() => JSON.parse(text) as IOdspSnapshot);\n\t\t\t\t\t\tvalidateBlobsAndTrees(content);\n\t\t\t\t\t\tconst snapshotContents: ISnapshot =\n\t\t\t\t\t\t\tconvertOdspSnapshotToSnapshotTreeAndBlobs(content);\n\t\t\t\t\t\tparsedSnapshotContents = {\n\t\t\t\t\t\t\t...odspResponse,\n\t\t\t\t\t\t\tcontent: {\n\t\t\t\t\t\t\t\t...snapshotContents,\n\t\t\t\t\t\t\t\ttelemetryProps: {},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"application/ms-fluid\": {\n\t\t\t\t\t\tlet content: ArrayBuffer;\n\t\t\t\t\t\t[content, receiveContentTime] = await measureP(async () =>\n\t\t\t\t\t\t\todspResponse.content\n\t\t\t\t\t\t\t\t.arrayBuffer()\n\t\t\t\t\t\t\t\t.then((res) => {\n\t\t\t\t\t\t\t\t\tif (res.byteLength === 0) {\n\t\t\t\t\t\t\t\t\t\tthrowOdspNetworkError(\n\t\t\t\t\t\t\t\t\t\t\t\"Response from browser is empty\",\n\t\t\t\t\t\t\t\t\t\t\tfetchIncorrectResponse,\n\t\t\t\t\t\t\t\t\t\t\todspResponse.content, // response\n\t\t\t\t\t\t\t\t\t\t\tundefined, // response text\n\t\t\t\t\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn res;\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t.catch((error) =>\n\t\t\t\t\t\t\t\t\t// Parsing can fail and message could contain full request URI, including\n\t\t\t\t\t\t\t\t\t// tokens, etc. So do not log error object itself.\n\t\t\t\t\t\t\t\t\tthrowOdspNetworkError(\n\t\t\t\t\t\t\t\t\t\t\"Error while parsing fetch response\",\n\t\t\t\t\t\t\t\t\t\tfetchIncorrectResponse,\n\t\t\t\t\t\t\t\t\t\todspResponse.content, // response\n\t\t\t\t\t\t\t\t\t\tundefined, // response text\n\t\t\t\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tpropsToLog.bodySize = content.byteLength;\n\t\t\t\t\t\tlet snapshotContents: ISnapshotContentsWithProps;\n\t\t\t\t\t\t[snapshotContents, parseTime] = measure(() =>\n\t\t\t\t\t\t\tparseCompactSnapshotResponse(new Uint8Array(content), logger),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tsnapshotContents.snapshotTree.trees === undefined ||\n\t\t\t\t\t\t\tsnapshotContents.snapshotTree.blobs === undefined\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\t\t\t\"Returned odsp snapshot is malformed. No trees or blobs!\",\n\t\t\t\t\t\t\t\tOdspErrorTypes.incorrectServerResponse,\n\t\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst props = snapshotContents.telemetryProps;\n\t\t\t\t\t\tconst slowTreeParseCodePaths = props.slowTreeStructureCount ?? 0;\n\t\t\t\t\t\tconst slowBlobParseCodePaths = props.slowBlobStructureCount ?? 0;\n\t\t\t\t\t\tconst treeStructureCountWithGroupId = props.treeStructureCountWithGroupId ?? 0;\n\t\t\t\t\t\t// As trees with groupId go through normal parsing, so exclude them.\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tslowTreeParseCodePaths - treeStructureCountWithGroupId > 10 ||\n\t\t\t\t\t\t\tslowBlobParseCodePaths > 10\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tlogger.sendErrorEvent({\n\t\t\t\t\t\t\t\teventName: \"SlowSnapshotParseCodePaths\",\n\t\t\t\t\t\t\t\tslowTreeStructureCount: slowTreeParseCodePaths,\n\t\t\t\t\t\t\t\tslowBlobStructureCount: slowBlobParseCodePaths,\n\t\t\t\t\t\t\t\ttreeStructureCountWithGroupId,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\tparsedSnapshotContents = { ...odspResponse, content: snapshotContents };\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tdefault: {\n\t\t\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\t\t\"Unknown snapshot content type\",\n\t\t\t\t\t\t\tOdspErrorTypes.incorrectServerResponse,\n\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tif (isFluidError(error)) {\n\t\t\t\t\terror.addTelemetryProperties(propsToLog);\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t\tconst enhancedError = wrapError(\n\t\t\t\t\terror,\n\t\t\t\t\t(errorMessage) =>\n\t\t\t\t\t\tnew NonRetryableError(\n\t\t\t\t\t\t\t`Error parsing snapshot response: ${errorMessage}`,\n\t\t\t\t\t\t\tOdspErrorTypes.genericError,\n\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\tthrow enhancedError;\n\t\t\t}\n\n\t\t\tassert(parsedSnapshotContents !== undefined, 0x312 /* snapshot should be parsed */);\n\t\t\tconst snapshot = parsedSnapshotContents.content;\n\n\t\t\t// There are some scenarios in ODSP where we cannot cache, trees/latest will explicitly tell us when we\n\t\t\t// cannot cache using an HTTP response header. Only cache snapshot if it is not for a loading group.\n\t\t\tconst canCache =\n\t\t\t\todspResponse.headers.get(\"disablebrowsercachingofusercontent\") !== \"true\" &&\n\t\t\t\t!fetchSnapshotForLoadingGroup;\n\t\t\tconst sequenceNumber: number = snapshot.sequenceNumber ?? 0;\n\t\t\tconst seqNumberFromOps =\n\t\t\t\tsnapshot.ops && snapshot.ops.length > 0\n\t\t\t\t\t? snapshot.ops[0].sequenceNumber - 1\n\t\t\t\t\t: undefined;\n\n\t\t\tif (\n\t\t\t\t!Number.isInteger(sequenceNumber) ||\n\t\t\t\t(seqNumberFromOps !== undefined && seqNumberFromOps !== sequenceNumber)\n\t\t\t) {\n\t\t\t\tlogger.sendErrorEvent({\n\t\t\t\t\teventName: \"fetchSnapshotError\",\n\t\t\t\t\tsequenceNumber,\n\t\t\t\t\tseqNumberFromOps,\n\t\t\t\t});\n\t\t\t\tsnapshot.sequenceNumber = undefined;\n\t\t\t} else if (canCache) {\n\t\t\t\tconst fluidEpoch = odspResponse.headers.get(\"x-fluid-epoch\");\n\t\t\t\tassert(fluidEpoch !== undefined, 0x1e6 /* \"Epoch should be present in response\" */);\n\t\t\t\tconst value: ISnapshotCachedEntry2 = {\n\t\t\t\t\t...snapshot,\n\t\t\t\t\tcacheEntryTime: Date.now(),\n\t\t\t\t};\n\t\t\t\tconst valueWithEpoch: IVersionedValueWithEpoch = {\n\t\t\t\t\tvalue,\n\t\t\t\t\tfluidEpoch,\n\t\t\t\t\tversion: persistedCacheValueVersion,\n\t\t\t\t};\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-floating-promises\n\t\t\t\tputInCache(valueWithEpoch);\n\t\t\t}\n\n\t\t\tevent.end({\n\t\t\t\t// trees, leafTrees, blobNodes, encodedBlobsSize,\n\t\t\t\t// blobNodes - blobs tells us (roughly) how many blobs are deduped by service.\n\t\t\t\t...getTreeStats(snapshot),\n\t\t\t\tblobs: snapshot.blobContents?.size ?? 0,\n\t\t\t\tsequenceNumber,\n\t\t\t\tops: snapshot.ops?.length ?? 0,\n\t\t\t\tfetchSnapshotForLoadingGroup,\n\t\t\t\tuseLegacyFlowWithoutGroups:\n\t\t\t\t\tuseLegacyFlowWithoutGroupsForSnapshotFetch(loadingGroupIds),\n\t\t\t\tuserOps: snapshot.ops?.filter((op) => isRuntimeMessage(op)).length ?? 0,\n\t\t\t\t// Measures time to make fetch call. Should be similar to\n\t\t\t\t// fetchStartToResponseEndTime - receiveContentTime, i.e. it looks like it's time till first byte /\n\t\t\t\t// end of response headers\n\t\t\t\tfetchTime,\n\t\t\t\t// time it takes client to parse payload. Same payload as in \"SnapshotParse\" event, here for\n\t\t\t\t// easier analyzes.\n\t\t\t\tparseTime,\n\t\t\t\t// Time it takes to receive content (text of buffer) from Response object.\n\t\t\t\t// This time likely is very closely correlated with networkTime, i.e. time it takes to receive\n\t\t\t\t// actual content (starting measuring from first bite / end of response header)\n\t\t\t\treceiveContentTime,\n\t\t\t\t...getW3CData(response.requestUrl, \"fetch\"),\n\t\t\t\t// Sharing link telemetry regarding sharing link redeem status and performance. Ex: FRL; dur=100,\n\t\t\t\t// Azure Fluid Relay service; desc=S, FRP; desc=False. Here, FRL is the duration taken for redeem,\n\t\t\t\t// Azure Fluid Relay service is the redeem status (S means success), and FRP is a flag to indicate\n\t\t\t\t// if the permission has changed.\n\t\t\t\tsltelemetry: odspResponse.headers.get(\"x-fluid-sltelemetry\"),\n\t\t\t\t// All other props\n\t\t\t\t...propsToLog,\n\t\t\t\t// Various perf counters and measures collected by binary parsing code:\n\t\t\t\t// slowTreeStructureCount, slowBlobStructureCount, durationStructure, durationStrings,\n\t\t\t\t// durationSnapshotTree, durationBlobs, etc.\n\t\t\t\t...parsedSnapshotContents.content.telemetryProps,\n\t\t\t});\n\t\t\treturn snapshot;\n\t\t}).catch((error) => {\n\t\t\t// We hit these errors in stress tests, under load\n\t\t\t// It's useful to try one more time in such case.\n\t\t\tif (\n\t\t\t\ttypeof error === \"object\" &&\n\t\t\t\terror !== null &&\n\t\t\t\t((error as Partial<IOdspError>).errorType === OdspErrorTypes.fetchFailure ||\n\t\t\t\t\t(error as Partial<IOdspError>).errorType === OdspErrorTypes.fetchTimeout)\n\t\t\t) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\t\terror[getWithRetryForTokenRefreshRepeat] = true;\n\t\t\t}\n\t\t\tthrow error;\n\t\t});\n\t});\n}\n\nexport interface ISnapshotRequestAndResponseOptions {\n\todspResponse: IOdspResponse<Response>;\n\trequestUrl: string;\n\trequestHeaders: { [index: string]: string };\n}\n\nfunction getFormBodyAndHeaders(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tauthHeader: string,\n\theaders?: { [index: string]: string },\n): {\n\tbody: string;\n\theaders: {\n\t\t[index: string]: string;\n\t};\n} {\n\tconst formBoundary = uuid();\n\tconst formParams: string[] = [];\n\tformParams.push(\n\t\t`--${formBoundary}`,\n\t\t`Authorization: ${authHeader}`,\n\t\t`X-HTTP-Method-Override: GET`,\n\t);\n\n\tif (headers !== undefined) {\n\t\tfor (const [key, value] of Object.entries(headers)) {\n\t\t\tif (value !== undefined) {\n\t\t\t\tformParams.push(`${key}: ${value}`);\n\t\t\t}\n\t\t}\n\t}\n\tif (odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem) {\n\t\tformParams.push(`sl: ${odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem}`);\n\t}\n\tformParams.push(`_post: 1`, `\\r\\n--${formBoundary}--`);\n\tconst postBody = formParams.join(\"\\r\\n\");\n\tconst header: { [index: string]: string } = {\n\t\t\"Content-Type\": `multipart/form-data;boundary=${formBoundary}`,\n\t};\n\treturn { body: postBody, headers: header };\n}\n\ninterface ITreeStats {\n\ttrees: number;\n\tleafTrees: number;\n\tblobNodes: number;\n}\n\nexport function getTreeStats(snapshot: ISnapshot): ITreeStats & { encodedBlobsSize: number } {\n\tconst stats: ITreeStats = {\n\t\ttrees: 0,\n\t\tleafTrees: 0,\n\t\tblobNodes: 0,\n\t};\n\tgetTreeStatsCore(snapshot.snapshotTree, stats);\n\tlet encodedBlobsSize = 0;\n\tfor (const [_, blobContent] of snapshot.blobContents) {\n\t\tencodedBlobsSize += blobContent.byteLength;\n\t}\n\treturn { ...stats, encodedBlobsSize };\n}\n\nexport function validateBlobsAndTrees(snapshot: IOdspSnapshot): void {\n\tassert(\n\t\tsnapshot.trees !== undefined,\n\t\t0x200 /* \"Returned odsp snapshot is malformed. No trees!\" */,\n\t);\n\tassert(\n\t\tsnapshot.blobs !== undefined,\n\t\t0x201 /* \"Returned odsp snapshot is malformed. No blobs!\" */,\n\t);\n}\n\nfunction getTreeStatsCore(snapshotTree: ISnapshotTree, stats: ITreeStats): void {\n\tstats.blobNodes += Object.entries(snapshotTree.blobs).length;\n\tstats.trees++;\n\n\tconst entries = Object.entries(snapshotTree.trees);\n\tif (entries.length === 0) {\n\t\tstats.leafTrees++;\n\t} else {\n\t\tfor (const [_, tree] of entries) {\n\t\t\tstats.trees++;\n\t\t\tgetTreeStatsCore(tree, stats);\n\t\t}\n\t}\n}\n\n/**\n * This function fetches the snapshot and parse it according to what is mentioned in response headers.\n * @param odspResolvedUrl - resolved odsp url.\n * @param storageToken - token to do the auth for network request.\n * @param snapshotOptions - Options used to specify how and what to fetch in the snapshot.\n * @param loadingGroupIds - loadingGroupIds for which snapshot needs to be downloaded. Note:\n * 1.) If undefined, then legacy trees latest call will be used where no groupId query param would be specified.\n * 2.) If [] is passed, then snapshot with all ungrouped data will be fetched.\n * 3.) If any groupId is specified like [\"g1\"], then snapshot for g1 group will be fetched.\n * @param snapshotFormatFetchType - Snapshot format to fetch.\n * @param controller - abort controller if caller needs to abort the network call.\n * @param epochTracker - epoch tracker used to add/validate epoch in the network call.\n * @returns fetched snapshot.\n */\nexport const downloadSnapshot = mockify(\n\tasync (\n\t\todspResolvedUrl: IOdspResolvedUrl,\n\t\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\t\ttokenFetchOptions: TokenFetchOptionsEx,\n\t\tloadingGroupIds: string[] | undefined,\n\t\tsnapshotOptions: ISnapshotOptions | undefined,\n\t\tsnapshotFormatFetchType?: SnapshotFormatSupportType,\n\t\tcontroller?: AbortController,\n\t\tepochTracker?: EpochTracker,\n\t\tscenarioName?: string,\n\t): Promise<ISnapshotRequestAndResponseOptions> => {\n\t\t// back-compat: This block to be removed with #8784 when we only consume/consider odsp resolvers that are >= 0.51\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\t\tconst sharingLinkToRedeem = (odspResolvedUrl as any).sharingLinkToRedeem;\n\t\tif (sharingLinkToRedeem) {\n\t\t\todspResolvedUrl.shareLinkInfo = {\n\t\t\t\t...odspResolvedUrl.shareLinkInfo,\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\tsharingLinkToRedeem,\n\t\t\t};\n\t\t}\n\n\t\tconst snapshotUrl = odspResolvedUrl.endpoints.snapshotStorageUrl;\n\n\t\tconst queryParams: Record<string, unknown> = { ump: 1 };\n\t\tif (snapshotOptions !== undefined) {\n\t\t\tfor (const [key, value] of Object.entries(snapshotOptions)) {\n\t\t\t\t// Exclude \"timeout\" from query string\n\t\t\t\tif (value !== undefined && key !== \"timeout\") {\n\t\t\t\t\tqueryParams[key] = value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (loadingGroupIds !== undefined) {\n\t\t\tqueryParams.groupId = loadingGroupIds.join(\",\");\n\t\t}\n\n\t\tconst queryString = getQueryString(queryParams);\n\t\tconst url = `${snapshotUrl}/trees/latest${queryString}`;\n\t\tconst method = \"POST\";\n\t\tconst isRedemptionNonDurable: boolean =\n\t\t\todspResolvedUrl.shareLinkInfo?.isRedemptionNonDurable === true;\n\t\t// The location of file can move on Spo in which case server returns 308(Permanent Redirect) error.\n\t\t// Adding below header will make VROOM API return 404 instead of 308 and browser can intercept it.\n\t\t// This error thrown by server will contain the new redirect location. Look at the 404 error parsing\n\t\t// for further reference here: \\packages\\utils\\odsp-doclib-utils\\src\\odspErrorUtils.ts\n\t\t// If the share link is non-durable, we will add the nonDurableRedeem header to the header.prefer.\n\t\tconst header: { [key: string]: string } = isRedemptionNonDurable\n\t\t\t? { prefer: \"manualredirect, nonDurableRedeem\" }\n\t\t\t: { prefer: \"manualredirect\" };\n\t\t// Epoch tracker is handling adding the CLP Compliant App header, so only when a flow does not\n\t\t// use epoch tracker, we add the header.\n\t\tif (epochTracker === undefined && odspResolvedUrl.isClpCompliantApp !== undefined) {\n\t\t\theader[ClpCompliantAppHeader.isClpCompliantApp] =\n\t\t\t\todspResolvedUrl.isClpCompliantApp.toString();\n\t\t}\n\t\tconst authHeader = await getAuthHeader(\n\t\t\t{ ...tokenFetchOptions, request: { url, method } },\n\t\t\t\"downloadSnapshot\",\n\t\t);\n\t\tassert(authHeader !== null, 0x1e5 /* \"Storage token should not be null\" */);\n\t\tconst { body, headers } = getFormBodyAndHeaders(odspResolvedUrl, authHeader, header);\n\t\tconst fetchOptions = {\n\t\t\tbody,\n\t\t\theaders,\n\t\t\tsignal: controller?.signal,\n\t\t\tmethod,\n\t\t};\n\t\t// Decide what snapshot format to fetch as per the feature gate.\n\t\tswitch (snapshotFormatFetchType) {\n\t\t\tcase SnapshotFormatSupportType.Binary: {\n\t\t\t\theaders.accept = `application/ms-fluid; v=${currentReadVersion}`;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\t// By default ask both versions and let the server decide the format.\n\t\t\t\theaders.accept = `application/json, application/ms-fluid; v=${currentReadVersion}`;\n\t\t\t}\n\t\t}\n\n\t\tconst odspResponse = await (epochTracker?.fetch(\n\t\t\turl,\n\t\t\tfetchOptions,\n\t\t\t\"treesLatest\",\n\t\t\ttrue,\n\t\t\tscenarioName,\n\t\t) ?? fetchHelper(url, fetchOptions));\n\n\t\treturn {\n\t\t\todspResponse,\n\t\t\trequestHeaders: headers,\n\t\t\trequestUrl: url,\n\t\t};\n\t},\n);\n\nfunction isRedeemSharingLinkError(\n\todspResolvedUrl: IOdspResolvedUrl,\n\terror: Partial<IOdspError>,\n): boolean {\n\tif (\n\t\todspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem !== undefined &&\n\t\ttypeof error === \"object\" &&\n\t\terror !== null &&\n\t\t(error.errorType === OdspErrorTypes.authorizationError ||\n\t\t\terror.errorType === OdspErrorTypes.fileNotFoundOrAccessDeniedError)\n\t) {\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nfunction getEncodedShareUrl(url: string): string {\n\t/**\n\t * Encode the url to accepted format by Sharepoint\n\t * https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/shares_get\n\t */\n\tlet encodedUrl = fromUtf8ToBase64(encodeURI(url));\n\tencodedUrl = encodedUrl.replace(/=+$/g, \"\").replace(/\\//g, \"_\").replace(/\\+/g, \"-\");\n\tencodedUrl = \"u!\".concat(encodedUrl);\n\treturn encodedUrl;\n}\n"]}
@@ -77,7 +77,7 @@ exports.getFileLink = (0, mockify_js_1.mockify)(async (getToken, resolvedUrl, lo
77
77
  * @param logger - logger to send events.
78
78
  * @returns Response from the API call.
79
79
  * @legacy
80
- * @alpha
80
+ * @beta
81
81
  */
82
82
  async function getFileLinkWithLocationRedirectionHandling(getToken, resolvedUrl, logger) {
83
83
  // We can have chains of location redirection one after the other, so have a for loop
@@ -1 +1 @@
1
- {"version":3,"file":"getFileLink.js","sourceRoot":"","sources":["../src/getFileLink.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,kEAA6D;AAC7D,oEAAwF;AACxF,+EAM0D;AAC1D,uEAIkD;AAElD,+EAAmE;AACnE,6CAAuC;AACvC,iDAIwB;AACxB,2DAAkE;AAClE,mDAAmG;AAEnG,2GAA2G;AAC3G,MAAM,aAAa,GAAG,IAAI,GAAG,EAA2B,CAAC;AAEzD;;;;;;;;;;GAUG;AACU,QAAA,WAAW,GAAG,IAAA,oBAAO,EACjC,KAAK,EACJ,QAAqD,EACrD,WAA6B,EAC7B,MAA2B,EACT,EAAE;IACpB,MAAM,QAAQ,GAAG,GAAG,WAAW,CAAC,OAAO,IAAI,WAAW,CAAC,OAAO,IAAI,WAAW,CAAC,MAAM,EAAE,CAAC;IACvF,MAAM,uBAAuB,GAAG,aAAa,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC5D,IAAI,uBAAuB,KAAK,SAAS,EAAE,CAAC;QAC3C,OAAO,uBAAuB,CAAC;IAChC,CAAC;IAED,MAAM,iBAAiB,GAAG,KAAK;QAC9B,IAAI,YAAoB,CAAC;QACzB,IAAI,CAAC;YACJ,IAAI,UAAU,GAAG,CAAC,CAAC;YACnB,YAAY,GAAG,MAAM,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AAI,eAAe,CAAC,SAAS,CAAC,uBAAuB,EAAE,CAAC;QACvD,eAAe,CAAC,SAAS,CAAC,uBAAuB,GAAG,GAAG,aAAa,GAAG,IAAI,GAAG,CAAC,eAAe,CAAC,SAAS,CAAC,uBAAuB,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC9I,CAAC;IACD,IAAI,eAAe,CAAC,SAAS,CAAC,wBAAwB,EAAE,CAAC;QACxD,eAAe,CAAC,SAAS,CAAC,wBAAwB,GAAG,GAAG,aAAa,GAAG,IAAI,GAAG,CAAC,eAAe,CAAC,SAAS,CAAC,wBAAwB,CAAC,CAAC,QAAQ,EAAE,CAAC;IAChJ,CAAC;IACD,IAAI,eAAe,CAAC,SAAS,CAAC,eAAe,EAAE,CAAC;QAC/C,eAAe,CAAC,SAAS,CAAC,eAAe,GAAG,GAAG,aAAa,GAAG,IAAI,GAAG,CAAC,eAAe,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC9H,CAAC;IACD,IAAI,eAAe,CAAC,SAAS,CAAC,kBAAkB,EAAE,CAAC;QAClD,eAAe,CAAC,SAAS,CAAC,kBAAkB,GAAG,GAAG,aAAa,GAAG,IAAI,GAAG,CAAC,eAAe,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAC,QAAQ,EAAE,CAAC;IACpI,CAAC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITelemetryBaseProperties } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { NonRetryableError, runWithRetry } from \"@fluidframework/driver-utils/internal\";\nimport {\n\ttype IOdspUrlParts,\n\tOdspErrorTypes,\n\ttype OdspResourceTokenFetchOptions,\n\ttype TokenFetcher,\n\ttype IOdspResolvedUrl,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\ttype ITelemetryLoggerExt,\n\tPerformanceEvent,\n\tisFluidError,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { getHeadersWithAuth } from \"./getUrlAndHeadersWithAuth.js\";\nimport { mockify } from \"./mockify.js\";\nimport {\n\tfetchHelper,\n\tgetWithRetryForTokenRefresh,\n\ttoInstrumentedOdspStorageTokenFetcher,\n} from \"./odspUtils.js\";\nimport { pkgVersion as driverVersion } from \"./packageVersion.js\";\nimport { runWithRetry as runWithRetryForCoherencyAndServiceReadOnlyErrors } from \"./retryUtils.js\";\n\n// Store cached responses for the lifetime of web session as file link remains the same for given file item\nconst fileLinkCache = new Map<string, Promise<string>>();\n\n/**\n * Returns file link for a file with given drive and item ids.\n * Scope needed: files.readwrite.all.\n * This function keeps retrying if it gets a retriable error or wait for some delay if it gets a\n * throttling error. In future, we are thinking of app allowing to pass some cancel token, with which\n * we would be able to stop retrying.\n * @param getToken - used to fetch access tokens needed to execute operation\n * @param odspUrlParts - object describing file storage identity\n * @param logger - used to log results of operation, including any error\n * @returns Promise which resolves to file link url when successful; otherwise, undefined.\n */\nexport const getFileLink = mockify(\n\tasync (\n\t\tgetToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n\t\tresolvedUrl: IOdspResolvedUrl,\n\t\tlogger: ITelemetryLoggerExt,\n\t): Promise<string> => {\n\t\tconst cacheKey = `${resolvedUrl.siteUrl}_${resolvedUrl.driveId}_${resolvedUrl.itemId}`;\n\t\tconst maybeFileLinkCacheEntry = fileLinkCache.get(cacheKey);\n\t\tif (maybeFileLinkCacheEntry !== undefined) {\n\t\t\treturn maybeFileLinkCacheEntry;\n\t\t}\n\n\t\tconst fileLinkGenerator = async function (): Promise<string> {\n\t\t\tlet fileLinkCore: string;\n\t\t\ttry {\n\t\t\t\tlet retryCount = 0;\n\t\t\t\tfileLinkCore = await runWithRetry(\n\t\t\t\t\tasync () =>\n\t\t\t\t\t\trunWithRetryForCoherencyAndServiceReadOnlyErrors(\n\t\t\t\t\t\t\tasync () =>\n\t\t\t\t\t\t\t\tgetFileLinkWithLocationRedirectionHandling(getToken, resolvedUrl, logger),\n\t\t\t\t\t\t\t\"getFileLinkCore\",\n\t\t\t\t\t\t\tlogger,\n\t\t\t\t\t\t),\n\t\t\t\t\t\"getShareLink\",\n\t\t\t\t\tlogger,\n\t\t\t\t\t{\n\t\t\t\t\t\t// TODO: use a stronger type\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\t\t\tonRetry(delayInMs: number, error: any) {\n\t\t\t\t\t\t\tretryCount++;\n\t\t\t\t\t\t\tif (retryCount === 5) {\n\t\t\t\t\t\t\t\tif (error !== undefined && typeof error === \"object\") {\n\t\t\t\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\t\t\t\t\t\t\terror.canRetry = false;\n\t\t\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t} catch (error) {\n\t\t\t\t// Delete from the cache to permit retrying later.\n\t\t\t\tfileLinkCache.delete(cacheKey);\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\t// We are guaranteed to run the getFileLinkCore at least once with successful result (which must be a string)\n\t\t\tassert(\n\t\t\t\tfileLinkCore !== undefined,\n\t\t\t\t0x292 /* \"Unexpected undefined result from getFileLinkCore\" */,\n\t\t\t);\n\t\t\treturn fileLinkCore;\n\t\t};\n\t\tconst fileLink = fileLinkGenerator();\n\t\tfileLinkCache.set(cacheKey, fileLink);\n\t\treturn fileLink;\n\t},\n);\n\n/**\n * Handles location redirection while fulfilling the getFileLink call. We don't want browser to handle\n * the redirection as the browser will retry with same auth token which will not work as we need app\n * to regenerate tokens for the new site domain. So when we will make the network calls below we will set\n * the redirect:manual header to manually handle these redirects.\n * Refer: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/308\n * @param getToken - token fetcher to fetch the token.\n * @param odspUrlParts - parts of odsp resolved url.\n * @param logger - logger to send events.\n * @returns Response from the API call.\n * @legacy\n * @alpha\n */\nasync function getFileLinkWithLocationRedirectionHandling(\n\tgetToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n\tresolvedUrl: IOdspResolvedUrl,\n\tlogger: ITelemetryLoggerExt,\n): Promise<string> {\n\t// We can have chains of location redirection one after the other, so have a for loop\n\t// so that we can keep handling the same type of error. Set max number of redirection to 5.\n\tlet lastError: unknown;\n\tlet locationRedirected = false;\n\tfor (let count = 1; count <= 5; count++) {\n\t\ttry {\n\t\t\tconst fileItem = await getFileItemLite(getToken, resolvedUrl, logger);\n\t\t\t// Sometimes the siteUrl in the actual file is different from the siteUrl in the resolvedUrl due to location\n\t\t\t// redirection. This creates issues in the getSharingInformation call. So we need to update the siteUrl in the\n\t\t\t// resolvedUrl to the siteUrl in the fileItem which is the updated siteUrl.\n\t\t\tconst oldSiteDomain = new URL(resolvedUrl.siteUrl).origin;\n\t\t\tconst newSiteDomain = new URL(fileItem.sharepointIds.siteUrl).origin;\n\t\t\tif (oldSiteDomain !== newSiteDomain) {\n\t\t\t\tlocationRedirected = true;\n\t\t\t\tlogger.sendTelemetryEvent({\n\t\t\t\t\teventName: \"LocationRedirectionErrorForGetOdspFileLink\",\n\t\t\t\t\tretryCount: count,\n\t\t\t\t});\n\t\t\t\trenameTenantInOdspResolvedUrl(resolvedUrl, newSiteDomain);\n\t\t\t}\n\t\t\treturn await getFileLinkCore(getToken, resolvedUrl, logger, fileItem);\n\t\t} catch (error: unknown) {\n\t\t\tlastError = error;\n\t\t\t// If the getSharingLink call fails with the 401/403/404 error, then it could be due to that the file has moved\n\t\t\t// to another location. This could occur in case we have more than 1 tenant rename. In that case, we should retry\n\t\t\t// the getFileItemLite call to get the updated fileItem.\n\t\t\tif (\n\t\t\t\tisFluidError(error) &&\n\t\t\t\tlocationRedirected &&\n\t\t\t\t(error.errorType === OdspErrorTypes.fileNotFoundOrAccessDeniedError ||\n\t\t\t\t\terror.errorType === OdspErrorTypes.authorizationError)\n\t\t\t) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\tthrow lastError;\n}\n\nasync function getFileLinkCore(\n\tgetToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n\todspUrlParts: IOdspUrlParts,\n\tlogger: ITelemetryLoggerExt,\n\tfileItem: FileItemLite,\n): Promise<string> {\n\t// ODSP link requires extra call to return link that is resistant to file being renamed or moved to different folder\n\treturn PerformanceEvent.timedExecAsync(\n\t\tlogger,\n\t\t{ eventName: \"odspFileLink\", requestName: \"getSharingInformation\" },\n\t\tasync (event) => {\n\t\t\tlet attempts = 0;\n\t\t\tlet additionalProps;\n\t\t\tconst fileLink = await getWithRetryForTokenRefresh(async (options) => {\n\t\t\t\tattempts++;\n\t\t\t\tconst getAuthHeader = toInstrumentedOdspStorageTokenFetcher(\n\t\t\t\t\tlogger,\n\t\t\t\t\todspUrlParts,\n\t\t\t\t\tgetToken,\n\t\t\t\t);\n\n\t\t\t\t// IMPORTANT: In past we were using GetFileByUrl() API to get to the list item that was corresponding\n\t\t\t\t// to the file. This was intentionally replaced with GetFileById() to solve the following issue:\n\t\t\t\t// GetFileByUrl() uses webDavUrl to locate list item. This API does not work for Consumer scenarios\n\t\t\t\t// where webDavUrl is constructed using legacy ODC format for backward compatibility reasons.\n\t\t\t\t// GetFileByUrl() does not understand that format and thus fails. GetFileById() relies on file item\n\t\t\t\t// unique guid (sharepointIds.listItemUniqueId) and it works uniformly across Consumer and Commercial.\n\t\t\t\tconst url = `${\n\t\t\t\t\todspUrlParts.siteUrl\n\t\t\t\t}/_api/web/GetFileById(@a1)/ListItemAllFields/GetSharingInformation?@a1=guid${encodeURIComponent(\n\t\t\t\t\t`'${fileItem.sharepointIds.listItemUniqueId}'`,\n\t\t\t\t)}`;\n\t\t\t\tconst method = \"POST\";\n\t\t\t\tconst authHeader = await getAuthHeader(\n\t\t\t\t\t{ ...options, request: { url, method } },\n\t\t\t\t\t\"GetFileLinkCore\",\n\t\t\t\t);\n\t\t\t\tconst headers = getHeadersWithAuth(authHeader);\n\t\t\t\tconst requestInit = {\n\t\t\t\t\tmethod,\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t\"Content-Type\": \"application/json;odata=verbose\",\n\t\t\t\t\t\t\"Accept\": \"application/json;odata=verbose\",\n\t\t\t\t\t\t...headers,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\tconst response = await fetchHelper(url, requestInit);\n\t\t\t\tadditionalProps = response.propsToLog;\n\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\tconst sharingInfo = await response.content.json();\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n\t\t\t\tconst directUrl = sharingInfo?.d?.directUrl;\n\t\t\t\tif (typeof directUrl !== \"string\") {\n\t\t\t\t\t// This will retry once in getWithRetryForTokenRefresh\n\t\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\t\"Malformed GetSharingInformation response\",\n\t\t\t\t\t\tOdspErrorTypes.incorrectServerResponse,\n\t\t\t\t\t\t{ driverVersion },\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn directUrl;\n\t\t\t});\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\tevent.end({ ...additionalProps, attempts });\n\t\t\treturn fileLink;\n\t\t},\n\t);\n}\n\n/**\n * Sharepoint Ids Interface\n */\ninterface IGraphSharepointIds {\n\tlistId: string;\n\tlistItemId: string;\n\tlistItemUniqueId: string;\n\tsiteId: string;\n\tsiteUrl: string;\n\twebId: string;\n}\n\n/**\n * This represents a lite version of file item containing only select file properties\n */\ninterface FileItemLite {\n\twebUrl: string;\n\twebDavUrl: string;\n\tsharepointIds: IGraphSharepointIds;\n}\n\nconst isFileItemLite = (maybeFileItemLite: unknown): maybeFileItemLite is FileItemLite =>\n\ttypeof (maybeFileItemLite as Partial<FileItemLite>).webUrl === \"string\" &&\n\ttypeof (maybeFileItemLite as Partial<FileItemLite>).webDavUrl === \"string\" &&\n\t// TODO: stronger check\n\ttypeof (maybeFileItemLite as Partial<FileItemLite>).sharepointIds === \"object\";\n\nasync function getFileItemLite(\n\tgetToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n\todspUrlParts: IOdspUrlParts,\n\tlogger: ITelemetryLoggerExt,\n): Promise<FileItemLite> {\n\treturn PerformanceEvent.timedExecAsync(\n\t\tlogger,\n\t\t{ eventName: \"odspFileLink\", requestName: \"getFileItemLite\" },\n\t\tasync (event) => {\n\t\t\tlet attempts = 0;\n\t\t\tlet additionalProps: ITelemetryBaseProperties | undefined;\n\t\t\tconst fileItem = await getWithRetryForTokenRefresh(async (options) => {\n\t\t\t\tattempts++;\n\t\t\t\tconst { siteUrl, driveId, itemId } = odspUrlParts;\n\t\t\t\tconst getAuthHeader = toInstrumentedOdspStorageTokenFetcher(\n\t\t\t\t\tlogger,\n\t\t\t\t\todspUrlParts,\n\t\t\t\t\tgetToken,\n\t\t\t\t);\n\t\t\t\tconst url = `${siteUrl}/_api/v2.0/drives/${driveId}/items/${itemId}?select=webUrl,webDavUrl,sharepointIds`;\n\t\t\t\tconst method = \"GET\";\n\t\t\t\tconst authHeader = await getAuthHeader(\n\t\t\t\t\t{ ...options, request: { url, method } },\n\t\t\t\t\t\"GetFileItemLite\",\n\t\t\t\t);\n\t\t\t\tassert(\n\t\t\t\t\tauthHeader !== null,\n\t\t\t\t\t0x2bc /* \"Instrumented token fetcher with throwOnNullToken =true should never return null\" */,\n\t\t\t\t);\n\n\t\t\t\tconst headers = getHeadersWithAuth(authHeader);\n\t\t\t\tconst requestInit = { method, headers };\n\t\t\t\tconst response = await fetchHelper(url, requestInit);\n\t\t\t\tadditionalProps = response.propsToLog;\n\n\t\t\t\tconst responseJson: unknown = await response.content.json();\n\t\t\t\tif (!isFileItemLite(responseJson)) {\n\t\t\t\t\t// This will retry once in getWithRetryForTokenRefresh\n\t\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\t\"Malformed getFileItemLite response\",\n\t\t\t\t\t\tOdspErrorTypes.incorrectServerResponse,\n\t\t\t\t\t\t{ driverVersion },\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn responseJson;\n\t\t\t});\n\t\t\tevent.end({ ...additionalProps, attempts });\n\t\t\treturn fileItem;\n\t\t},\n\t);\n}\n\n/**\n * It takes a resolved url with old siteUrl and patches resolved url with updated site url domain.\n * @param odspResolvedUrl - Previous odsp resolved url with older site url.\n * @param newSiteDomain - New site domain after the tenant rename.\n */\nfunction renameTenantInOdspResolvedUrl(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tnewSiteDomain: string,\n): void {\n\tconst newSiteUrl = `${newSiteDomain}${new URL(odspResolvedUrl.siteUrl).pathname}`;\n\todspResolvedUrl.siteUrl = newSiteUrl;\n\n\tif (odspResolvedUrl.endpoints.attachmentGETStorageUrl) {\n\t\todspResolvedUrl.endpoints.attachmentGETStorageUrl = `${newSiteDomain}${new URL(odspResolvedUrl.endpoints.attachmentGETStorageUrl).pathname}`;\n\t}\n\tif (odspResolvedUrl.endpoints.attachmentPOSTStorageUrl) {\n\t\todspResolvedUrl.endpoints.attachmentPOSTStorageUrl = `${newSiteDomain}${new URL(odspResolvedUrl.endpoints.attachmentPOSTStorageUrl).pathname}`;\n\t}\n\tif (odspResolvedUrl.endpoints.deltaStorageUrl) {\n\t\todspResolvedUrl.endpoints.deltaStorageUrl = `${newSiteDomain}${new URL(odspResolvedUrl.endpoints.deltaStorageUrl).pathname}`;\n\t}\n\tif (odspResolvedUrl.endpoints.snapshotStorageUrl) {\n\t\todspResolvedUrl.endpoints.snapshotStorageUrl = `${newSiteDomain}${new URL(odspResolvedUrl.endpoints.snapshotStorageUrl).pathname}`;\n\t}\n}\n"]}
1
+ {"version":3,"file":"getFileLink.js","sourceRoot":"","sources":["../src/getFileLink.ts"],"names":[],"mappings":";A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AAS,CAAC,eAAe,GAAG,GAAG,aAAa,GAAG,IAAI,GAAG,CAAC,eAAe,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC9H,CAAC;IACD,IAAI,eAAe,CAAC,SAAS,CAAC,kBAAkB,EAAE,CAAC;QAClD,eAAe,CAAC,SAAS,CAAC,kBAAkB,GAAG,GAAG,aAAa,GAAG,IAAI,GAAG,CAAC,eAAe,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAC,QAAQ,EAAE,CAAC;IACpI,CAAC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITelemetryBaseProperties } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { NonRetryableError, runWithRetry } from \"@fluidframework/driver-utils/internal\";\nimport {\n\ttype IOdspUrlParts,\n\tOdspErrorTypes,\n\ttype OdspResourceTokenFetchOptions,\n\ttype TokenFetcher,\n\ttype IOdspResolvedUrl,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\ttype ITelemetryLoggerExt,\n\tPerformanceEvent,\n\tisFluidError,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { getHeadersWithAuth } from \"./getUrlAndHeadersWithAuth.js\";\nimport { mockify } from \"./mockify.js\";\nimport {\n\tfetchHelper,\n\tgetWithRetryForTokenRefresh,\n\ttoInstrumentedOdspStorageTokenFetcher,\n} from \"./odspUtils.js\";\nimport { pkgVersion as driverVersion } from \"./packageVersion.js\";\nimport { runWithRetry as runWithRetryForCoherencyAndServiceReadOnlyErrors } from \"./retryUtils.js\";\n\n// Store cached responses for the lifetime of web session as file link remains the same for given file item\nconst fileLinkCache = new Map<string, Promise<string>>();\n\n/**\n * Returns file link for a file with given drive and item ids.\n * Scope needed: files.readwrite.all.\n * This function keeps retrying if it gets a retriable error or wait for some delay if it gets a\n * throttling error. In future, we are thinking of app allowing to pass some cancel token, with which\n * we would be able to stop retrying.\n * @param getToken - used to fetch access tokens needed to execute operation\n * @param odspUrlParts - object describing file storage identity\n * @param logger - used to log results of operation, including any error\n * @returns Promise which resolves to file link url when successful; otherwise, undefined.\n */\nexport const getFileLink = mockify(\n\tasync (\n\t\tgetToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n\t\tresolvedUrl: IOdspResolvedUrl,\n\t\tlogger: ITelemetryLoggerExt,\n\t): Promise<string> => {\n\t\tconst cacheKey = `${resolvedUrl.siteUrl}_${resolvedUrl.driveId}_${resolvedUrl.itemId}`;\n\t\tconst maybeFileLinkCacheEntry = fileLinkCache.get(cacheKey);\n\t\tif (maybeFileLinkCacheEntry !== undefined) {\n\t\t\treturn maybeFileLinkCacheEntry;\n\t\t}\n\n\t\tconst fileLinkGenerator = async function (): Promise<string> {\n\t\t\tlet fileLinkCore: string;\n\t\t\ttry {\n\t\t\t\tlet retryCount = 0;\n\t\t\t\tfileLinkCore = await runWithRetry(\n\t\t\t\t\tasync () =>\n\t\t\t\t\t\trunWithRetryForCoherencyAndServiceReadOnlyErrors(\n\t\t\t\t\t\t\tasync () =>\n\t\t\t\t\t\t\t\tgetFileLinkWithLocationRedirectionHandling(getToken, resolvedUrl, logger),\n\t\t\t\t\t\t\t\"getFileLinkCore\",\n\t\t\t\t\t\t\tlogger,\n\t\t\t\t\t\t),\n\t\t\t\t\t\"getShareLink\",\n\t\t\t\t\tlogger,\n\t\t\t\t\t{\n\t\t\t\t\t\t// TODO: use a stronger type\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\t\t\tonRetry(delayInMs: number, error: any) {\n\t\t\t\t\t\t\tretryCount++;\n\t\t\t\t\t\t\tif (retryCount === 5) {\n\t\t\t\t\t\t\t\tif (error !== undefined && typeof error === \"object\") {\n\t\t\t\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\t\t\t\t\t\t\terror.canRetry = false;\n\t\t\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t} catch (error) {\n\t\t\t\t// Delete from the cache to permit retrying later.\n\t\t\t\tfileLinkCache.delete(cacheKey);\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\t// We are guaranteed to run the getFileLinkCore at least once with successful result (which must be a string)\n\t\t\tassert(\n\t\t\t\tfileLinkCore !== undefined,\n\t\t\t\t0x292 /* \"Unexpected undefined result from getFileLinkCore\" */,\n\t\t\t);\n\t\t\treturn fileLinkCore;\n\t\t};\n\t\tconst fileLink = fileLinkGenerator();\n\t\tfileLinkCache.set(cacheKey, fileLink);\n\t\treturn fileLink;\n\t},\n);\n\n/**\n * Handles location redirection while fulfilling the getFileLink call. We don't want browser to handle\n * the redirection as the browser will retry with same auth token which will not work as we need app\n * to regenerate tokens for the new site domain. So when we will make the network calls below we will set\n * the redirect:manual header to manually handle these redirects.\n * Refer: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/308\n * @param getToken - token fetcher to fetch the token.\n * @param odspUrlParts - parts of odsp resolved url.\n * @param logger - logger to send events.\n * @returns Response from the API call.\n * @legacy\n * @beta\n */\nasync function getFileLinkWithLocationRedirectionHandling(\n\tgetToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n\tresolvedUrl: IOdspResolvedUrl,\n\tlogger: ITelemetryLoggerExt,\n): Promise<string> {\n\t// We can have chains of location redirection one after the other, so have a for loop\n\t// so that we can keep handling the same type of error. Set max number of redirection to 5.\n\tlet lastError: unknown;\n\tlet locationRedirected = false;\n\tfor (let count = 1; count <= 5; count++) {\n\t\ttry {\n\t\t\tconst fileItem = await getFileItemLite(getToken, resolvedUrl, logger);\n\t\t\t// Sometimes the siteUrl in the actual file is different from the siteUrl in the resolvedUrl due to location\n\t\t\t// redirection. This creates issues in the getSharingInformation call. So we need to update the siteUrl in the\n\t\t\t// resolvedUrl to the siteUrl in the fileItem which is the updated siteUrl.\n\t\t\tconst oldSiteDomain = new URL(resolvedUrl.siteUrl).origin;\n\t\t\tconst newSiteDomain = new URL(fileItem.sharepointIds.siteUrl).origin;\n\t\t\tif (oldSiteDomain !== newSiteDomain) {\n\t\t\t\tlocationRedirected = true;\n\t\t\t\tlogger.sendTelemetryEvent({\n\t\t\t\t\teventName: \"LocationRedirectionErrorForGetOdspFileLink\",\n\t\t\t\t\tretryCount: count,\n\t\t\t\t});\n\t\t\t\trenameTenantInOdspResolvedUrl(resolvedUrl, newSiteDomain);\n\t\t\t}\n\t\t\treturn await getFileLinkCore(getToken, resolvedUrl, logger, fileItem);\n\t\t} catch (error: unknown) {\n\t\t\tlastError = error;\n\t\t\t// If the getSharingLink call fails with the 401/403/404 error, then it could be due to that the file has moved\n\t\t\t// to another location. This could occur in case we have more than 1 tenant rename. In that case, we should retry\n\t\t\t// the getFileItemLite call to get the updated fileItem.\n\t\t\tif (\n\t\t\t\tisFluidError(error) &&\n\t\t\t\tlocationRedirected &&\n\t\t\t\t(error.errorType === OdspErrorTypes.fileNotFoundOrAccessDeniedError ||\n\t\t\t\t\terror.errorType === OdspErrorTypes.authorizationError)\n\t\t\t) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\tthrow lastError;\n}\n\nasync function getFileLinkCore(\n\tgetToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n\todspUrlParts: IOdspUrlParts,\n\tlogger: ITelemetryLoggerExt,\n\tfileItem: FileItemLite,\n): Promise<string> {\n\t// ODSP link requires extra call to return link that is resistant to file being renamed or moved to different folder\n\treturn PerformanceEvent.timedExecAsync(\n\t\tlogger,\n\t\t{ eventName: \"odspFileLink\", requestName: \"getSharingInformation\" },\n\t\tasync (event) => {\n\t\t\tlet attempts = 0;\n\t\t\tlet additionalProps;\n\t\t\tconst fileLink = await getWithRetryForTokenRefresh(async (options) => {\n\t\t\t\tattempts++;\n\t\t\t\tconst getAuthHeader = toInstrumentedOdspStorageTokenFetcher(\n\t\t\t\t\tlogger,\n\t\t\t\t\todspUrlParts,\n\t\t\t\t\tgetToken,\n\t\t\t\t);\n\n\t\t\t\t// IMPORTANT: In past we were using GetFileByUrl() API to get to the list item that was corresponding\n\t\t\t\t// to the file. This was intentionally replaced with GetFileById() to solve the following issue:\n\t\t\t\t// GetFileByUrl() uses webDavUrl to locate list item. This API does not work for Consumer scenarios\n\t\t\t\t// where webDavUrl is constructed using legacy ODC format for backward compatibility reasons.\n\t\t\t\t// GetFileByUrl() does not understand that format and thus fails. GetFileById() relies on file item\n\t\t\t\t// unique guid (sharepointIds.listItemUniqueId) and it works uniformly across Consumer and Commercial.\n\t\t\t\tconst url = `${\n\t\t\t\t\todspUrlParts.siteUrl\n\t\t\t\t}/_api/web/GetFileById(@a1)/ListItemAllFields/GetSharingInformation?@a1=guid${encodeURIComponent(\n\t\t\t\t\t`'${fileItem.sharepointIds.listItemUniqueId}'`,\n\t\t\t\t)}`;\n\t\t\t\tconst method = \"POST\";\n\t\t\t\tconst authHeader = await getAuthHeader(\n\t\t\t\t\t{ ...options, request: { url, method } },\n\t\t\t\t\t\"GetFileLinkCore\",\n\t\t\t\t);\n\t\t\t\tconst headers = getHeadersWithAuth(authHeader);\n\t\t\t\tconst requestInit = {\n\t\t\t\t\tmethod,\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t\"Content-Type\": \"application/json;odata=verbose\",\n\t\t\t\t\t\t\"Accept\": \"application/json;odata=verbose\",\n\t\t\t\t\t\t...headers,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\tconst response = await fetchHelper(url, requestInit);\n\t\t\t\tadditionalProps = response.propsToLog;\n\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\tconst sharingInfo = await response.content.json();\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n\t\t\t\tconst directUrl = sharingInfo?.d?.directUrl;\n\t\t\t\tif (typeof directUrl !== \"string\") {\n\t\t\t\t\t// This will retry once in getWithRetryForTokenRefresh\n\t\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\t\"Malformed GetSharingInformation response\",\n\t\t\t\t\t\tOdspErrorTypes.incorrectServerResponse,\n\t\t\t\t\t\t{ driverVersion },\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn directUrl;\n\t\t\t});\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\tevent.end({ ...additionalProps, attempts });\n\t\t\treturn fileLink;\n\t\t},\n\t);\n}\n\n/**\n * Sharepoint Ids Interface\n */\ninterface IGraphSharepointIds {\n\tlistId: string;\n\tlistItemId: string;\n\tlistItemUniqueId: string;\n\tsiteId: string;\n\tsiteUrl: string;\n\twebId: string;\n}\n\n/**\n * This represents a lite version of file item containing only select file properties\n */\ninterface FileItemLite {\n\twebUrl: string;\n\twebDavUrl: string;\n\tsharepointIds: IGraphSharepointIds;\n}\n\nconst isFileItemLite = (maybeFileItemLite: unknown): maybeFileItemLite is FileItemLite =>\n\ttypeof (maybeFileItemLite as Partial<FileItemLite>).webUrl === \"string\" &&\n\ttypeof (maybeFileItemLite as Partial<FileItemLite>).webDavUrl === \"string\" &&\n\t// TODO: stronger check\n\ttypeof (maybeFileItemLite as Partial<FileItemLite>).sharepointIds === \"object\";\n\nasync function getFileItemLite(\n\tgetToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n\todspUrlParts: IOdspUrlParts,\n\tlogger: ITelemetryLoggerExt,\n): Promise<FileItemLite> {\n\treturn PerformanceEvent.timedExecAsync(\n\t\tlogger,\n\t\t{ eventName: \"odspFileLink\", requestName: \"getFileItemLite\" },\n\t\tasync (event) => {\n\t\t\tlet attempts = 0;\n\t\t\tlet additionalProps: ITelemetryBaseProperties | undefined;\n\t\t\tconst fileItem = await getWithRetryForTokenRefresh(async (options) => {\n\t\t\t\tattempts++;\n\t\t\t\tconst { siteUrl, driveId, itemId } = odspUrlParts;\n\t\t\t\tconst getAuthHeader = toInstrumentedOdspStorageTokenFetcher(\n\t\t\t\t\tlogger,\n\t\t\t\t\todspUrlParts,\n\t\t\t\t\tgetToken,\n\t\t\t\t);\n\t\t\t\tconst url = `${siteUrl}/_api/v2.0/drives/${driveId}/items/${itemId}?select=webUrl,webDavUrl,sharepointIds`;\n\t\t\t\tconst method = \"GET\";\n\t\t\t\tconst authHeader = await getAuthHeader(\n\t\t\t\t\t{ ...options, request: { url, method } },\n\t\t\t\t\t\"GetFileItemLite\",\n\t\t\t\t);\n\t\t\t\tassert(\n\t\t\t\t\tauthHeader !== null,\n\t\t\t\t\t0x2bc /* \"Instrumented token fetcher with throwOnNullToken =true should never return null\" */,\n\t\t\t\t);\n\n\t\t\t\tconst headers = getHeadersWithAuth(authHeader);\n\t\t\t\tconst requestInit = { method, headers };\n\t\t\t\tconst response = await fetchHelper(url, requestInit);\n\t\t\t\tadditionalProps = response.propsToLog;\n\n\t\t\t\tconst responseJson: unknown = await response.content.json();\n\t\t\t\tif (!isFileItemLite(responseJson)) {\n\t\t\t\t\t// This will retry once in getWithRetryForTokenRefresh\n\t\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\t\"Malformed getFileItemLite response\",\n\t\t\t\t\t\tOdspErrorTypes.incorrectServerResponse,\n\t\t\t\t\t\t{ driverVersion },\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn responseJson;\n\t\t\t});\n\t\t\tevent.end({ ...additionalProps, attempts });\n\t\t\treturn fileItem;\n\t\t},\n\t);\n}\n\n/**\n * It takes a resolved url with old siteUrl and patches resolved url with updated site url domain.\n * @param odspResolvedUrl - Previous odsp resolved url with older site url.\n * @param newSiteDomain - New site domain after the tenant rename.\n */\nfunction renameTenantInOdspResolvedUrl(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tnewSiteDomain: string,\n): void {\n\tconst newSiteUrl = `${newSiteDomain}${new URL(odspResolvedUrl.siteUrl).pathname}`;\n\todspResolvedUrl.siteUrl = newSiteUrl;\n\n\tif (odspResolvedUrl.endpoints.attachmentGETStorageUrl) {\n\t\todspResolvedUrl.endpoints.attachmentGETStorageUrl = `${newSiteDomain}${new URL(odspResolvedUrl.endpoints.attachmentGETStorageUrl).pathname}`;\n\t}\n\tif (odspResolvedUrl.endpoints.attachmentPOSTStorageUrl) {\n\t\todspResolvedUrl.endpoints.attachmentPOSTStorageUrl = `${newSiteDomain}${new URL(odspResolvedUrl.endpoints.attachmentPOSTStorageUrl).pathname}`;\n\t}\n\tif (odspResolvedUrl.endpoints.deltaStorageUrl) {\n\t\todspResolvedUrl.endpoints.deltaStorageUrl = `${newSiteDomain}${new URL(odspResolvedUrl.endpoints.deltaStorageUrl).pathname}`;\n\t}\n\tif (odspResolvedUrl.endpoints.snapshotStorageUrl) {\n\t\todspResolvedUrl.endpoints.snapshotStorageUrl = `${newSiteDomain}${new URL(odspResolvedUrl.endpoints.snapshotStorageUrl).pathname}`;\n\t}\n}\n"]}
@@ -8,7 +8,7 @@ import { type ICacheEntry, type IEntry, type IFileEntry, type IOdspResolvedUrl,
8
8
  /**
9
9
  * Similar to IPersistedCache, but exposes cache interface for single file
10
10
  * @legacy
11
- * @alpha
11
+ * @beta
12
12
  */
13
13
  export interface IPersistedFileCache {
14
14
  get(entry: IEntry): Promise<any>;
@@ -37,7 +37,7 @@ export declare class PromiseCacheWithOneHourSlidingExpiry<T> extends PromiseCach
37
37
  /**
38
38
  * Internal cache interface used within driver only
39
39
  * @legacy
40
- * @alpha
40
+ * @beta
41
41
  */
42
42
  export interface INonPersistentCache {
43
43
  /**
@@ -60,7 +60,7 @@ export interface INonPersistentCache {
60
60
  /**
61
61
  * Internal cache interface used within driver only
62
62
  * @legacy
63
- * @alpha
63
+ * @beta
64
64
  */
65
65
  export interface IOdspCache extends INonPersistentCache {
66
66
  /**
@@ -78,7 +78,7 @@ export declare class NonPersistentCache implements INonPersistentCache {
78
78
  }
79
79
  /**
80
80
  * @legacy
81
- * @alpha
81
+ * @beta
82
82
  */
83
83
  export interface IPrefetchSnapshotContents extends ISnapshot {
84
84
  fluidEpoch: string;
@@ -1 +1 @@
1
- {"version":3,"file":"odspCache.js","sourceRoot":"","sources":["../src/odspCache.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAmE;AAEnE,+EAQ0D;AAiB1D;;;GAGG;AACH,MAAa,oBAAoB;IAKhC,YAAoC,uBAAuB,IAAI,GAAG,IAAI;QAAlC,yBAAoB,GAApB,oBAAoB,CAAc;QAJrD,UAAK,GAAG,IAAI,GAAG,EAAmB,CAAC;QACpD,wGAAwG;QACvF,uBAAkB,GAAG,IAAI,GAAG,EAAyC,CAAC;IAEd,CAAC;IAE1E,KAAK,CAAC,GAAG,CAAC,KAAkB;QAC3B,MAAM,GAAG,GAAG,IAAA,8BAAmB,EAAC,KAAK,CAAC,CAAC;QACvC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,KAAkB,EAAE,KAAc;QAC3C,MAAM,GAAG,GAAG,IAAA,8BAAmB,EAAC,KAAK,CAAC,CAAC;QACvC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC3B,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC9C,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,IAAgB;QACnC,IAAI,CAAC,2BAA2B,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC9C,CAAC;IAEO,2BAA2B,CAAC,KAAa;QAChD,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC;QAClC,OAAO,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC;aACpB,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,EAA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QAE5D,gCAA2B,GAAG,IAAI,uBAAY,EAG3D,CAAC;IACL,CAAC;CAAA;AAZD,gDAYC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { PromiseCache } from \"@fluidframework/core-utils/internal\";\nimport type { ISnapshot } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\ttype ICacheEntry,\n\ttype IEntry,\n\ttype IFileEntry,\n\ttype IOdspResolvedUrl,\n\ttype IPersistedCache,\n\ttype ISocketStorageDiscovery,\n\tgetKeyForCacheEntry,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\n\n/**\n * Similar to IPersistedCache, but exposes cache interface for single file\n * @legacy\n * @alpha\n */\nexport interface IPersistedFileCache {\n\t// TODO: use a stronger type\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tget(entry: IEntry): Promise<any>;\n\t// TODO: use a stronger type\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tput(entry: IEntry, value: any): Promise<void>;\n\tremoveEntries(): Promise<void>;\n}\n\n/**\n * Default local-only implementation of IPersistedCache,\n * used if no persisted cache is provided by the host\n */\nexport class LocalPersistentCache implements IPersistedCache {\n\tprivate readonly cache = new Map<string, unknown>();\n\t// For every document id there will be a single expiration entry inspite of the number of cache entries.\n\tprivate readonly docIdExpirationMap = new Map<string, ReturnType<typeof setTimeout>>();\n\n\tpublic constructor(private readonly snapshotExpiryPolicy = 3600 * 1000) {}\n\n\tasync get(entry: ICacheEntry): Promise<unknown> {\n\t\tconst key = getKeyForCacheEntry(entry);\n\t\treturn this.cache.get(key);\n\t}\n\n\tasync put(entry: ICacheEntry, value: unknown): Promise<void> {\n\t\tconst key = getKeyForCacheEntry(entry);\n\t\tthis.cache.set(key, value);\n\t\tthis.updateExpirationEntry(entry.file.docId);\n\t}\n\n\tasync removeEntries(file: IFileEntry): Promise<void> {\n\t\tthis.removeDocIdEntriesFromCache(file.docId);\n\t}\n\n\tprivate removeDocIdEntriesFromCache(docId: string): void[] {\n\t\tthis.removeExpirationEntry(docId);\n\t\treturn [...this.cache]\n\t\t\t.filter(([cachekey]) => {\n\t\t\t\tconst docIdFromKey = cachekey.split(\"_\");\n\t\t\t\tif (docIdFromKey[0] === docId) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t})\n\t\t\t.map(([cachekey]) => {\n\t\t\t\tthis.cache.delete(cachekey);\n\t\t\t});\n\t}\n\n\tprivate removeExpirationEntry(docId: string): void {\n\t\tconst timeout = this.docIdExpirationMap.get(docId);\n\t\tif (timeout !== undefined) {\n\t\t\tclearTimeout(timeout);\n\t\t\tthis.docIdExpirationMap.delete(docId);\n\t\t}\n\t}\n\n\tprivate updateExpirationEntry(docId: string): void {\n\t\tthis.removeExpirationEntry(docId);\n\t\tthis.docIdExpirationMap.set(\n\t\t\tdocId,\n\t\t\tsetTimeout(() => {\n\t\t\t\tthis.removeDocIdEntriesFromCache(docId);\n\t\t\t}, this.snapshotExpiryPolicy),\n\t\t);\n\t}\n}\nexport class PromiseCacheWithOneHourSlidingExpiry<T> extends PromiseCache<string, T> {\n\tconstructor(removeOnError?: (error: unknown) => boolean) {\n\t\tsuper({ expiry: { policy: \"sliding\", durationMs: 3600000 }, removeOnError });\n\t}\n}\n\n/**\n * Internal cache interface used within driver only\n * @legacy\n * @alpha\n */\nexport interface INonPersistentCache {\n\t/**\n\t * Cache of joined/joining session info\n\t */\n\treadonly sessionJoinCache: PromiseCache<\n\t\tstring,\n\t\t{ entryTime: number; joinSessionResponse: ISocketStorageDiscovery }\n\t>;\n\n\t/**\n\t * Cache of resolved/resolving file URLs\n\t */\n\treadonly fileUrlCache: PromiseCache<string, IOdspResolvedUrl>;\n\n\t/**\n\t * Used to store the snapshot fetch promise if the prefetch has been made using the prefetchLatestSnapshot api.\n\t * This is then used later to look for the promise during the container load.\n\t */\n\treadonly snapshotPrefetchResultCache: PromiseCache<string, IPrefetchSnapshotContents>;\n}\n\n/**\n * Internal cache interface used within driver only\n * @legacy\n * @alpha\n */\nexport interface IOdspCache extends INonPersistentCache {\n\t/**\n\t * Persisted cache - only serializable content is allowed\n\t */\n\treadonly persistedCache: IPersistedFileCache;\n}\n\nexport class NonPersistentCache implements INonPersistentCache {\n\tpublic readonly sessionJoinCache = new PromiseCache<\n\t\tstring,\n\t\t{ entryTime: number; joinSessionResponse: ISocketStorageDiscovery }\n\t>();\n\n\tpublic readonly fileUrlCache = new PromiseCache<string, IOdspResolvedUrl>();\n\n\tpublic readonly snapshotPrefetchResultCache = new PromiseCache<\n\t\tstring,\n\t\tIPrefetchSnapshotContents\n\t>();\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport interface IPrefetchSnapshotContents extends ISnapshot {\n\tfluidEpoch: string;\n\tprefetchStartTime: number;\n}\n"]}
1
+ {"version":3,"file":"odspCache.js","sourceRoot":"","sources":["../src/odspCache.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAmE;AAEnE,+EAQ0D;AAiB1D;;;GAGG;AACH,MAAa,oBAAoB;IAKhC,YAAoC,uBAAuB,IAAI,GAAG,IAAI;QAAlC,yBAAoB,GAApB,oBAAoB,CAAc;QAJrD,UAAK,GAAG,IAAI,GAAG,EAAmB,CAAC;QACpD,wGAAwG;QACvF,uBAAkB,GAAG,IAAI,GAAG,EAAyC,CAAC;IAEd,CAAC;IAE1E,KAAK,CAAC,GAAG,CAAC,KAAkB;QAC3B,MAAM,GAAG,GAAG,IAAA,8BAAmB,EAAC,KAAK,CAAC,CAAC;QACvC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,KAAkB,EAAE,KAAc;QAC3C,MAAM,GAAG,GAAG,IAAA,8BAAmB,EAAC,KAAK,CAAC,CAAC;QACvC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC3B,IAAI,CAAC,qBA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ACH,CAAC;CACD;AArDD,oDAqDC;AACD,MAAa,oCAAwC,SAAQ,uBAAuB;IACnF,YAAY,aAA2C;QACtD,KAAK,CAAC,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,aAAa,EAAE,CAAC,CAAC;IAC9E,CAAC;CACD;AAJD,oFAIC;AAwCD,MAAa,kBAAkB;IAA/B;QACiB,qBAAgB,GAAG,IAAI,uBAAY,EAGhD,CAAC;QAEY,iBAAY,GAAG,IAAI,uBAAY,EAA4B,CAAC;QAE5D,gCAA2B,GAAG,IAAI,uBAAY,EAG3D,CAAC;IACL,CAAC;CAAA;AAZD,gDAYC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { PromiseCache } from \"@fluidframework/core-utils/internal\";\nimport type { ISnapshot } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\ttype ICacheEntry,\n\ttype IEntry,\n\ttype IFileEntry,\n\ttype IOdspResolvedUrl,\n\ttype IPersistedCache,\n\ttype ISocketStorageDiscovery,\n\tgetKeyForCacheEntry,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\n\n/**\n * Similar to IPersistedCache, but exposes cache interface for single file\n * @legacy\n * @beta\n */\nexport interface IPersistedFileCache {\n\t// TODO: use a stronger type\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tget(entry: IEntry): Promise<any>;\n\t// TODO: use a stronger type\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tput(entry: IEntry, value: any): Promise<void>;\n\tremoveEntries(): Promise<void>;\n}\n\n/**\n * Default local-only implementation of IPersistedCache,\n * used if no persisted cache is provided by the host\n */\nexport class LocalPersistentCache implements IPersistedCache {\n\tprivate readonly cache = new Map<string, unknown>();\n\t// For every document id there will be a single expiration entry inspite of the number of cache entries.\n\tprivate readonly docIdExpirationMap = new Map<string, ReturnType<typeof setTimeout>>();\n\n\tpublic constructor(private readonly snapshotExpiryPolicy = 3600 * 1000) {}\n\n\tasync get(entry: ICacheEntry): Promise<unknown> {\n\t\tconst key = getKeyForCacheEntry(entry);\n\t\treturn this.cache.get(key);\n\t}\n\n\tasync put(entry: ICacheEntry, value: unknown): Promise<void> {\n\t\tconst key = getKeyForCacheEntry(entry);\n\t\tthis.cache.set(key, value);\n\t\tthis.updateExpirationEntry(entry.file.docId);\n\t}\n\n\tasync removeEntries(file: IFileEntry): Promise<void> {\n\t\tthis.removeDocIdEntriesFromCache(file.docId);\n\t}\n\n\tprivate removeDocIdEntriesFromCache(docId: string): void[] {\n\t\tthis.removeExpirationEntry(docId);\n\t\treturn [...this.cache]\n\t\t\t.filter(([cachekey]) => {\n\t\t\t\tconst docIdFromKey = cachekey.split(\"_\");\n\t\t\t\tif (docIdFromKey[0] === docId) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t})\n\t\t\t.map(([cachekey]) => {\n\t\t\t\tthis.cache.delete(cachekey);\n\t\t\t});\n\t}\n\n\tprivate removeExpirationEntry(docId: string): void {\n\t\tconst timeout = this.docIdExpirationMap.get(docId);\n\t\tif (timeout !== undefined) {\n\t\t\tclearTimeout(timeout);\n\t\t\tthis.docIdExpirationMap.delete(docId);\n\t\t}\n\t}\n\n\tprivate updateExpirationEntry(docId: string): void {\n\t\tthis.removeExpirationEntry(docId);\n\t\tthis.docIdExpirationMap.set(\n\t\t\tdocId,\n\t\t\tsetTimeout(() => {\n\t\t\t\tthis.removeDocIdEntriesFromCache(docId);\n\t\t\t}, this.snapshotExpiryPolicy),\n\t\t);\n\t}\n}\nexport class PromiseCacheWithOneHourSlidingExpiry<T> extends PromiseCache<string, T> {\n\tconstructor(removeOnError?: (error: unknown) => boolean) {\n\t\tsuper({ expiry: { policy: \"sliding\", durationMs: 3600000 }, removeOnError });\n\t}\n}\n\n/**\n * Internal cache interface used within driver only\n * @legacy\n * @beta\n */\nexport interface INonPersistentCache {\n\t/**\n\t * Cache of joined/joining session info\n\t */\n\treadonly sessionJoinCache: PromiseCache<\n\t\tstring,\n\t\t{ entryTime: number; joinSessionResponse: ISocketStorageDiscovery }\n\t>;\n\n\t/**\n\t * Cache of resolved/resolving file URLs\n\t */\n\treadonly fileUrlCache: PromiseCache<string, IOdspResolvedUrl>;\n\n\t/**\n\t * Used to store the snapshot fetch promise if the prefetch has been made using the prefetchLatestSnapshot api.\n\t * This is then used later to look for the promise during the container load.\n\t */\n\treadonly snapshotPrefetchResultCache: PromiseCache<string, IPrefetchSnapshotContents>;\n}\n\n/**\n * Internal cache interface used within driver only\n * @legacy\n * @beta\n */\nexport interface IOdspCache extends INonPersistentCache {\n\t/**\n\t * Persisted cache - only serializable content is allowed\n\t */\n\treadonly persistedCache: IPersistedFileCache;\n}\n\nexport class NonPersistentCache implements INonPersistentCache {\n\tpublic readonly sessionJoinCache = new PromiseCache<\n\t\tstring,\n\t\t{ entryTime: number; joinSessionResponse: ISocketStorageDiscovery }\n\t>();\n\n\tpublic readonly fileUrlCache = new PromiseCache<string, IOdspResolvedUrl>();\n\n\tpublic readonly snapshotPrefetchResultCache = new PromiseCache<\n\t\tstring,\n\t\tIPrefetchSnapshotContents\n\t>();\n}\n\n/**\n * @legacy\n * @beta\n */\nexport interface IPrefetchSnapshotContents extends ISnapshot {\n\tfluidEpoch: string;\n\tprefetchStartTime: number;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"odspDocumentService.d.ts","sourceRoot":"","sources":["../src/odspDocumentService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,KAAK,EACX,wBAAwB,EACxB,4BAA4B,EAC5B,gBAAgB,EAChB,sBAAsB,EACtB,wBAAwB,EACxB,uBAAuB,EACvB,YAAY,EACZ,yBAAyB,EACzB,MAAM,6CAA6C,CAAC;AACrD,OA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,CAA4B;IAEvD,OAAO,CAAC,SAAS,CAAC,CAAW;IAE7B;;;;;;;;;;;;;OAaG;IACH,OAAO;IAqCP,IAAW,WAAW,IAAI,YAAY,CAErC;IACD,IAAW,QAAQ,IAAI,wBAAwB,CAE9C;IAED;;;;OAIG;IACU,gBAAgB,IAAI,OAAO,CAAC,uBAAuB,CAAC;IA4BjE;;;;OAIG;IACU,qBAAqB,IAAI,OAAO,CAAC,4BAA4B,CAAC;IAsC3E;;;;OAIG;IACU,oBAAoB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAiBrF;;;;;OAKG;YACW,yBAAyB;IA6BhC,OAAO,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI;IAerC,SAAS,KAAK,QAAQ,IAAI,QAAQ,GAAG,SAAS,CAgC7C;IAID,SAAS,CAAC,WAAW,CAAC,GAAG,EAAE,yBAAyB,EAAE,GAAG,IAAI;CAQ7D"}
@@ -125,10 +125,10 @@ class OdspDocumentService extends client_utils_1.TypedEventEmitter {
125
125
  // Get Ops from storage callback.
126
126
  async (from, to, telemetryProps, fetchReason) => service.get(from, to, telemetryProps, fetchReason),
127
127
  // Get cachedOps Callback.
128
- async (from, to) => {
129
- const res = await this.opsCache?.get(from, to);
130
- return res ?? [];
131
- },
128
+ // TODO AB#47218: This condition will be removed when file version can be read from the cache entry for an op.
129
+ this.odspResolvedUrl.fileVersion === undefined
130
+ ? async (from, to) => (await this.opsCache?.get(from, to)) ?? []
131
+ : async () => [],
132
132
  // Ops requestFromSocket Callback.
133
133
  (from, to) => {
134
134
  const currentConnection = this.odspDelayLoadedDeltaStream?.currentDeltaConnection;
@@ -1 +1 @@
1
- {"version":3,"file":"odspDocumentService.js","sourceRoot":"","sources":["../src/odspDocumentService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAiE;AACjE,kEAA6D;AAmB7D,uEAIkD;AAMlD,6EAGsC;AACtC,mFAA6E;AAC7E,yDAAk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D,2CAA2C;QAC3C,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE,CAAC;YACzD,OAAO;QACR,CAAC;QAED,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;CACD;AAtTD,kDAsTC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IClient } from \"@fluidframework/driver-definitions\";\nimport type {\n\tIDocumentDeltaConnection,\n\tIDocumentDeltaStorageService,\n\tIDocumentService,\n\tIDocumentServiceEvents,\n\tIDocumentServicePolicies,\n\tIDocumentStorageService,\n\tIResolvedUrl,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tHostStoragePolicy,\n\tIEntry,\n\tIOdspResolvedUrl,\n\tInstrumentedStorageTokenFetcher,\n\tTokenFetchOptions,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\ttype ITelemetryLoggerExt,\n\ttype MonitoringContext,\n\tcreateChildMonitoringContext,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport type { HostStoragePolicyInternal } from \"./contracts.js\";\nimport type { EpochTracker } from \"./epochTracker.js\";\nimport type { IOdspCache } from \"./odspCache.js\";\nimport type { OdspDelayLoadedDeltaStream } from \"./odspDelayLoadedDeltaStream.js\";\nimport {\n\tOdspDeltaStorageService,\n\tOdspDeltaStorageWithCache,\n} from \"./odspDeltaStorageService.js\";\nimport { OdspDocumentStorageService } from \"./odspDocumentStorageManager.js\";\nimport { hasOdcOrigin } from \"./odspUrlHelper.js\";\nimport { getOdspResolvedUrl } from \"./odspUtils.js\";\nimport { OpsCache } from \"./opsCaching.js\";\nimport { RetryErrorsStorageAdapter } from \"./retryErrorsStorageAdapter.js\";\n\n/**\n * The DocumentService manages the Socket.IO connection and manages routing requests to connected\n * clients\n */\nexport class OdspDocumentService\n\textends TypedEventEmitter<IDocumentServiceEvents>\n\timplements IDocumentService\n{\n\tprivate readonly _policies: IDocumentServicePolicies;\n\n\t// Promise to load socket module only once.\n\tprivate socketModuleP: Promise<OdspDelayLoadedDeltaStream> | undefined;\n\n\tprivate odspDelayLoadedDeltaStream: OdspDelayLoadedDeltaStream | undefined;\n\n\tprivate odspSocketModuleLoaded: boolean = false;\n\n\t/**\n\t * Creates a new OdspDocumentService instance.\n\t *\n\t * @param resolvedUrl - resolved url identifying document that will be managed by returned service instance.\n\t * @param getAuthHeader - function that can provide the Authentication header value. This is is also referred to as\n\t * the \"Vroom\" token in SPO.\n\t * @param getWebsocketToken - function that can provide a token for accessing the web socket. This is also referred\n\t * to as the \"Push\" token in SPO. If undefined then websocket token is expected to be returned with joinSession\n\t * response payload.\n\t * @param logger - a logger that can capture performance and diagnostic information\n\t * @param cache - This caches response for joinSession.\n\t * @param hostPolicy - This host constructed policy which customizes service behavior.\n\t * @param epochTracker - This helper class which adds epoch to backend calls made by returned service instance.\n\t * @param socketReferenceKeyPrefix - (optional) prefix to isolate socket reuse cache\n\t */\n\tpublic static async create(\n\t\tresolvedUrl: IResolvedUrl,\n\t\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t\tgetWebsocketToken: ((options: TokenFetchOptions) => Promise<string | null>) | undefined,\n\t\tlogger: ITelemetryLoggerExt,\n\t\tcache: IOdspCache,\n\t\thostPolicy: HostStoragePolicy,\n\t\tepochTracker: EpochTracker,\n\t\tsocketReferenceKeyPrefix?: string,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\treturn new OdspDocumentService(\n\t\t\tgetOdspResolvedUrl(resolvedUrl),\n\t\t\tgetAuthHeader,\n\t\t\tgetWebsocketToken,\n\t\t\tlogger,\n\t\t\tcache,\n\t\t\thostPolicy,\n\t\t\tepochTracker,\n\t\t\tsocketReferenceKeyPrefix,\n\t\t\tclientIsSummarizer,\n\t\t);\n\t}\n\n\tprivate storageManager?: OdspDocumentStorageService;\n\n\tprivate readonly mc: MonitoringContext;\n\n\tprivate readonly hostPolicy: HostStoragePolicyInternal;\n\n\tprivate _opsCache?: OpsCache;\n\n\t/**\n\t * @param odspResolvedUrl - resolved url identifying document that will be managed by this service instance.\n\t * @param getAuthHeader - function that can provide the Authentication header value. This is is also referred to as\n\t * the \"Vroom\" token in SPO.\n\t * @param getWebsocketToken - function that can provide a token for accessing the web socket. This is also referred\n\t * to as the \"Push\" token in SPO. If undefined then websocket token is expected to be returned with joinSession\n\t * response payload.\n\t * @param logger - a logger that can capture performance and diagnostic information\n\t * @param socketIoClientFactory - A factory that returns a promise to the socket io library required by the driver\n\t * @param cache - This caches response for joinSession.\n\t * @param hostPolicy - host constructed policy which customizes service behavior.\n\t * @param epochTracker - This helper class which adds epoch to backend calls made by this service instance.\n\t * @param socketReferenceKeyPrefix - (optional) prefix to isolate socket reuse cache\n\t */\n\tprivate constructor(\n\t\tpublic readonly odspResolvedUrl: IOdspResolvedUrl,\n\t\tprivate readonly getAuthHeader: InstrumentedStorageTokenFetcher,\n\t\tprivate readonly getWebsocketToken:\n\t\t\t| ((options: TokenFetchOptions) => Promise<string | null>)\n\t\t\t| undefined,\n\t\tlogger: ITelemetryLoggerExt,\n\t\tprivate readonly cache: IOdspCache,\n\t\thostPolicy: HostStoragePolicy,\n\t\tprivate readonly epochTracker: EpochTracker,\n\t\tprivate readonly socketReferenceKeyPrefix?: string,\n\t\tprivate readonly clientIsSummarizer?: boolean,\n\t) {\n\t\tsuper();\n\t\tthis._policies = {\n\t\t\t// load in storage-only mode if a file version is specified\n\t\t\tstorageOnly: odspResolvedUrl.fileVersion !== undefined,\n\t\t\tsummarizeProtocolTree: true,\n\t\t\tsupportGetSnapshotApi: true,\n\t\t};\n\n\t\tthis.mc = createChildMonitoringContext({\n\t\t\tlogger,\n\t\t\tproperties: {\n\t\t\t\tall: {\n\t\t\t\t\todc: hasOdcOrigin(new URL(this.odspResolvedUrl.endpoints.snapshotStorageUrl)),\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\n\t\tthis.hostPolicy = hostPolicy;\n\t\tthis.hostPolicy.supportGetSnapshotApi = this._policies.supportGetSnapshotApi;\n\t\tif (this.clientIsSummarizer) {\n\t\t\tthis.hostPolicy = { ...this.hostPolicy, summarizerClient: true };\n\t\t}\n\t}\n\n\tpublic get resolvedUrl(): IResolvedUrl {\n\t\treturn this.odspResolvedUrl;\n\t}\n\tpublic get policies(): IDocumentServicePolicies {\n\t\treturn this._policies;\n\t}\n\n\t/**\n\t * Connects to a storage endpoint for snapshot service.\n\t *\n\t * @returns returns the document storage service for sharepoint driver.\n\t */\n\tpublic async connectToStorage(): Promise<IDocumentStorageService> {\n\t\tif (!this.storageManager) {\n\t\t\tthis.storageManager = new OdspDocumentStorageService(\n\t\t\t\tthis.odspResolvedUrl,\n\t\t\t\tthis.getAuthHeader,\n\t\t\t\tthis.mc.logger,\n\t\t\t\ttrue,\n\t\t\t\tthis.cache,\n\t\t\t\tthis.hostPolicy,\n\t\t\t\tthis.epochTracker,\n\t\t\t\t// flushCallback\n\t\t\t\tasync () => {\n\t\t\t\t\tconst currentConnection = this.odspDelayLoadedDeltaStream?.currentDeltaConnection;\n\t\t\t\t\tif (currentConnection !== undefined && !currentConnection.disposed) {\n\t\t\t\t\t\treturn currentConnection.flush();\n\t\t\t\t\t}\n\t\t\t\t\tthrow new Error(\"Disconnected while uploading summary (attempt to perform flush())\");\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\treturn this.odspDelayLoadedDeltaStream?.relayServiceTenantAndSessionId;\n\t\t\t\t},\n\t\t\t\tthis.mc.config.getNumber(\"Fluid.Driver.Odsp.snapshotFormatFetchType\"),\n\t\t\t);\n\t\t}\n\n\t\treturn new RetryErrorsStorageAdapter(this.storageManager, this.mc.logger);\n\t}\n\n\t/**\n\t * Connects to a delta storage endpoint for getting ops between a range.\n\t *\n\t * @returns returns the document delta storage service for sharepoint driver.\n\t */\n\tpublic async connectToDeltaStorage(): Promise<IDocumentDeltaStorageService> {\n\t\tconst snapshotOps = this.storageManager?.ops ?? [];\n\t\tconst service = new OdspDeltaStorageService(\n\t\t\tthis.odspResolvedUrl.endpoints.deltaStorageUrl,\n\t\t\tthis.getAuthHeader,\n\t\t\tthis.epochTracker,\n\t\t\tthis.mc.logger,\n\t\t);\n\n\t\t// batch size, please see issue #5211 for data around batch sizing\n\t\tconst batchSize = this.hostPolicy.opsBatchSize ?? 5000;\n\t\tconst concurrency = this.hostPolicy.concurrentOpsBatches ?? 1;\n\t\treturn new OdspDeltaStorageWithCache(\n\t\t\tsnapshotOps,\n\t\t\tthis.mc.logger,\n\t\t\tbatchSize,\n\t\t\tconcurrency,\n\t\t\t// Get Ops from storage callback.\n\t\t\tasync (from, to, telemetryProps, fetchReason) =>\n\t\t\t\tservice.get(from, to, telemetryProps, fetchReason),\n\t\t\t// Get cachedOps Callback.\n\t\t\tasync (from, to) => {\n\t\t\t\tconst res = await this.opsCache?.get(from, to);\n\t\t\t\treturn (res as ISequencedDocumentMessage[]) ?? [];\n\t\t\t},\n\t\t\t// Ops requestFromSocket Callback.\n\t\t\t(from, to) => {\n\t\t\t\tconst currentConnection = this.odspDelayLoadedDeltaStream?.currentDeltaConnection;\n\t\t\t\tif (currentConnection !== undefined && !currentConnection.disposed) {\n\t\t\t\t\tcurrentConnection.requestOps(from, to);\n\t\t\t\t}\n\t\t\t},\n\t\t\t(ops: ISequencedDocumentMessage[]) => this.opsReceived(ops),\n\t\t\t() => this.storageManager,\n\t\t);\n\t}\n\n\t/**\n\t * Connects to a delta stream endpoint for emitting ops.\n\t *\n\t * @returns returns the document delta stream service for onedrive/sharepoint driver.\n\t */\n\tpublic async connectToDeltaStream(client: IClient): Promise<IDocumentDeltaConnection> {\n\t\tif (this.socketModuleP === undefined) {\n\t\t\tthis.socketModuleP = this.getDelayLoadedDeltaStream();\n\t\t}\n\t\treturn this.socketModuleP\n\t\t\t.then(async (m) => {\n\t\t\t\tthis.odspSocketModuleLoaded = true;\n\t\t\t\treturn m.connectToDeltaStream(client);\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\t// Setting undefined in case someone tries to recover from module failure by calling again.\n\t\t\t\tthis.socketModuleP = undefined;\n\t\t\t\tthis.odspSocketModuleLoaded = false;\n\t\t\t\tthrow error;\n\t\t\t});\n\t}\n\n\t/**\n\t * This dynamically imports the module for loading the delta connection. In many cases the delta stream, is not\n\t * required during the critical load flow. So this way we don't have to bundle this in the initial bundle and can\n\t * import this later on when required.\n\t * @returns The delta stream object.\n\t */\n\tprivate async getDelayLoadedDeltaStream(): Promise<OdspDelayLoadedDeltaStream> {\n\t\tassert(this.odspSocketModuleLoaded === false, 0x507 /* Should be loaded only once */);\n\t\tconst module = await import(\n\t\t\t/* webpackChunkName: \"socketModule\" */ \"./odspDelayLoadedDeltaStream.js\"\n\t\t)\n\t\t\t.then((m) => {\n\t\t\t\tthis.mc.logger.sendTelemetryEvent({ eventName: \"SocketModuleLoaded\" });\n\t\t\t\treturn m;\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\tthis.mc.logger.sendErrorEvent({ eventName: \"SocketModuleLoadFailed\" }, error);\n\t\t\t\tthrow error;\n\t\t\t});\n\t\tthis.odspDelayLoadedDeltaStream = new module.OdspDelayLoadedDeltaStream(\n\t\t\tthis.odspResolvedUrl,\n\t\t\tthis._policies,\n\t\t\tthis.getAuthHeader,\n\t\t\tthis.getWebsocketToken,\n\t\t\tthis.mc,\n\t\t\tthis.cache,\n\t\t\tthis.hostPolicy,\n\t\t\tthis.epochTracker,\n\t\t\t(ops: ISequencedDocumentMessage[]) => this.opsReceived(ops),\n\t\t\t(metadata: Record<string, string>) => this.emit(\"metadataUpdate\", metadata),\n\t\t\tthis.socketReferenceKeyPrefix,\n\t\t);\n\t\treturn this.odspDelayLoadedDeltaStream;\n\t}\n\n\tpublic dispose(error?: unknown): void {\n\t\t// Error might indicate mismatch between client & server knowledge about file\n\t\t// (OdspErrorTypes.fileOverwrittenInStorage).\n\t\t// For example, file might have been overwritten in storage without generating new epoch\n\t\t// In such case client cached info is stale and has to be removed.\n\t\tif (error === undefined) {\n\t\t\tthis._opsCache?.flushOps();\n\t\t} else {\n\t\t\tthis.epochTracker.removeEntries().catch(() => {});\n\t\t}\n\t\tthis._opsCache?.dispose();\n\t\t// Only need to dipose this, if it is already loaded.\n\t\tthis.odspDelayLoadedDeltaStream?.dispose();\n\t}\n\n\tprotected get opsCache(): OpsCache | undefined {\n\t\tif (this._opsCache) {\n\t\t\treturn this._opsCache;\n\t\t}\n\n\t\tconst seqNumber = this.storageManager?.snapshotSequenceNumber;\n\t\tconst batchSize = this.hostPolicy.opsCaching?.batchSize ?? 100;\n\t\tif (seqNumber === undefined || batchSize < 1) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst opsKey: Omit<IEntry, \"key\"> = {\n\t\t\ttype: \"ops\",\n\t\t};\n\t\tthis._opsCache = new OpsCache(\n\t\t\tseqNumber,\n\t\t\tthis.mc.logger,\n\t\t\t// ICache\n\t\t\t{\n\t\t\t\twrite: async (key: string, opsData: string): Promise<void> => {\n\t\t\t\t\treturn this.cache.persistedCache.put({ ...opsKey, key }, opsData);\n\t\t\t\t},\n\t\t\t\tread: async (key: string) => this.cache.persistedCache.get({ ...opsKey, key }),\n\t\t\t\tremove: (): void => {\n\t\t\t\t\tthis.cache.persistedCache.removeEntries().catch(() => {});\n\t\t\t\t},\n\t\t\t},\n\t\t\tbatchSize,\n\t\t\tthis.hostPolicy.opsCaching?.timerGranularity ?? 5000,\n\t\t\tthis.hostPolicy.opsCaching?.totalOpsToCache ?? 5000,\n\t\t);\n\t\treturn this._opsCache;\n\t}\n\n\t// Called whenever re receive ops through any channel for this document (snapshot, delta connection, delta storage)\n\t// We use it to notify caching layer of how stale is snapshot stored in cache.\n\tprotected opsReceived(ops: ISequencedDocumentMessage[]): void {\n\t\t// No need for two clients to save same ops\n\t\tif (ops.length === 0 || this.odspResolvedUrl.summarizer) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.opsCache?.addOps(ops);\n\t}\n}\n"]}
1
+ {"version":3,"file":"odspDocumentService.js","sourceRoot":"","sources":["../src/odspDocumentService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAiE;AACjE,kEAA6D;AAmB7D,uEAIkD;AAMlD,6EAGsC;AACtC,mFAA6E;AAC7E,yDAAkD;AAClD,iDAAoD;AACpD,mDAA2C;AAC3C,iFAA2E;AAE3E;;;GAGG;AACH,MAAa,mBACZ,SAAQ,gCAAyC;IAYjD;;;;;;;;;;;;;;OAcG;IACI,MAAM,CAAC,KAAK,CAAC,MAAM,CACzB,WAAyB,EACzB,aAA8C;IAC9C,kDAAkD;IAClD,iBAAuF,EACvF,MAA2B,EAC3B,KAAiB,EACjB,UAA6B,EAC7B,YAA0B,EAC1B,wBAAiC,EACjC,kBAA4B;QAE5B,OAAO,IAAI,mBAAmB,CAC7B,IAAA,iCAAkB,EAAC,WAAW,CAAC,EAC/B,aAAa,EACb,iBAAiB,EACjB,MAAM,EACN,KAAK,EACL,UAAU,EACV,YAAY,EACZ,wBAAwB,EACxB,kBAAkB,CAClB,CAAC;IACH,CAAC;IAUD;;;;;;;;;;;;;OAaG;IACH,YACiB,eAAiC,EAChC,aAA8C,EAC9C,iBAEL,EACZ,MAA2B,EACV,KAAiB,EAClC,UAA6B,EACZ,YAA0B,EAC1B,wBAAiC,EACjC,kBAA4B;QAE7C,KAAK,EAAE,CAAC;QAZQ,oBAAe,GAAf,eAAe,CAAkB;QAChC,kBAAa,GAAb,aAAa,CAAiC;QAC9C,sBAAiB,GAAjB,iBAAiB,CAEtB;QAEK,UAAK,GAAL,KAAK,CAAY;QAEjB,iBAAY,GAAZ,YAAY,CAAc;QAC1B,6BAAwB,GAAxB,wBAAwB,CAAS;QACjC,uBAAkB,GAAlB,kBA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YAC9E,MAAM,EAAE,GAAS,EAAE;gBAClB,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,aAAa,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;YAC3D,CAAC;SACD,EACD,SAAS,EACT,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,gBAAgB,IAAI,IAAI,EACpD,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,eAAe,IAAI,IAAI,CACnD,CAAC;QACF,OAAO,IAAI,CAAC,SAAS,CAAC;IACvB,CAAC;IAED,mHAAmH;IACnH,8EAA8E;IACpE,WAAW,CAAC,GAAgC;QACrD,2CAA2C;QAC3C,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE,CAAC;YACzD,OAAO;QACR,CAAC;QAED,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;CACD;AAvTD,kDAuTC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IClient } from \"@fluidframework/driver-definitions\";\nimport type {\n\tIDocumentDeltaConnection,\n\tIDocumentDeltaStorageService,\n\tIDocumentService,\n\tIDocumentServiceEvents,\n\tIDocumentServicePolicies,\n\tIDocumentStorageService,\n\tIResolvedUrl,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tHostStoragePolicy,\n\tIEntry,\n\tIOdspResolvedUrl,\n\tInstrumentedStorageTokenFetcher,\n\tTokenFetchOptions,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\ttype ITelemetryLoggerExt,\n\ttype MonitoringContext,\n\tcreateChildMonitoringContext,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport type { HostStoragePolicyInternal } from \"./contracts.js\";\nimport type { EpochTracker } from \"./epochTracker.js\";\nimport type { IOdspCache } from \"./odspCache.js\";\nimport type { OdspDelayLoadedDeltaStream } from \"./odspDelayLoadedDeltaStream.js\";\nimport {\n\tOdspDeltaStorageService,\n\tOdspDeltaStorageWithCache,\n} from \"./odspDeltaStorageService.js\";\nimport { OdspDocumentStorageService } from \"./odspDocumentStorageManager.js\";\nimport { hasOdcOrigin } from \"./odspUrlHelper.js\";\nimport { getOdspResolvedUrl } from \"./odspUtils.js\";\nimport { OpsCache } from \"./opsCaching.js\";\nimport { RetryErrorsStorageAdapter } from \"./retryErrorsStorageAdapter.js\";\n\n/**\n * The DocumentService manages the Socket.IO connection and manages routing requests to connected\n * clients\n */\nexport class OdspDocumentService\n\textends TypedEventEmitter<IDocumentServiceEvents>\n\timplements IDocumentService\n{\n\tprivate readonly _policies: IDocumentServicePolicies;\n\n\t// Promise to load socket module only once.\n\tprivate socketModuleP: Promise<OdspDelayLoadedDeltaStream> | undefined;\n\n\tprivate odspDelayLoadedDeltaStream: OdspDelayLoadedDeltaStream | undefined;\n\n\tprivate odspSocketModuleLoaded: boolean = false;\n\n\t/**\n\t * Creates a new OdspDocumentService instance.\n\t *\n\t * @param resolvedUrl - resolved url identifying document that will be managed by returned service instance.\n\t * @param getAuthHeader - function that can provide the Authentication header value. This is is also referred to as\n\t * the \"Vroom\" token in SPO.\n\t * @param getWebsocketToken - function that can provide a token for accessing the web socket. This is also referred\n\t * to as the \"Push\" token in SPO. If undefined then websocket token is expected to be returned with joinSession\n\t * response payload.\n\t * @param logger - a logger that can capture performance and diagnostic information\n\t * @param cache - This caches response for joinSession.\n\t * @param hostPolicy - This host constructed policy which customizes service behavior.\n\t * @param epochTracker - This helper class which adds epoch to backend calls made by returned service instance.\n\t * @param socketReferenceKeyPrefix - (optional) prefix to isolate socket reuse cache\n\t */\n\tpublic static async create(\n\t\tresolvedUrl: IResolvedUrl,\n\t\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t\tgetWebsocketToken: ((options: TokenFetchOptions) => Promise<string | null>) | undefined,\n\t\tlogger: ITelemetryLoggerExt,\n\t\tcache: IOdspCache,\n\t\thostPolicy: HostStoragePolicy,\n\t\tepochTracker: EpochTracker,\n\t\tsocketReferenceKeyPrefix?: string,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\treturn new OdspDocumentService(\n\t\t\tgetOdspResolvedUrl(resolvedUrl),\n\t\t\tgetAuthHeader,\n\t\t\tgetWebsocketToken,\n\t\t\tlogger,\n\t\t\tcache,\n\t\t\thostPolicy,\n\t\t\tepochTracker,\n\t\t\tsocketReferenceKeyPrefix,\n\t\t\tclientIsSummarizer,\n\t\t);\n\t}\n\n\tprivate storageManager?: OdspDocumentStorageService;\n\n\tprivate readonly mc: MonitoringContext;\n\n\tprivate readonly hostPolicy: HostStoragePolicyInternal;\n\n\tprivate _opsCache?: OpsCache;\n\n\t/**\n\t * @param odspResolvedUrl - resolved url identifying document that will be managed by this service instance.\n\t * @param getAuthHeader - function that can provide the Authentication header value. This is is also referred to as\n\t * the \"Vroom\" token in SPO.\n\t * @param getWebsocketToken - function that can provide a token for accessing the web socket. This is also referred\n\t * to as the \"Push\" token in SPO. If undefined then websocket token is expected to be returned with joinSession\n\t * response payload.\n\t * @param logger - a logger that can capture performance and diagnostic information\n\t * @param socketIoClientFactory - A factory that returns a promise to the socket io library required by the driver\n\t * @param cache - This caches response for joinSession.\n\t * @param hostPolicy - host constructed policy which customizes service behavior.\n\t * @param epochTracker - This helper class which adds epoch to backend calls made by this service instance.\n\t * @param socketReferenceKeyPrefix - (optional) prefix to isolate socket reuse cache\n\t */\n\tprivate constructor(\n\t\tpublic readonly odspResolvedUrl: IOdspResolvedUrl,\n\t\tprivate readonly getAuthHeader: InstrumentedStorageTokenFetcher,\n\t\tprivate readonly getWebsocketToken:\n\t\t\t| ((options: TokenFetchOptions) => Promise<string | null>)\n\t\t\t| undefined,\n\t\tlogger: ITelemetryLoggerExt,\n\t\tprivate readonly cache: IOdspCache,\n\t\thostPolicy: HostStoragePolicy,\n\t\tprivate readonly epochTracker: EpochTracker,\n\t\tprivate readonly socketReferenceKeyPrefix?: string,\n\t\tprivate readonly clientIsSummarizer?: boolean,\n\t) {\n\t\tsuper();\n\t\tthis._policies = {\n\t\t\t// load in storage-only mode if a file version is specified\n\t\t\tstorageOnly: odspResolvedUrl.fileVersion !== undefined,\n\t\t\tsummarizeProtocolTree: true,\n\t\t\tsupportGetSnapshotApi: true,\n\t\t};\n\n\t\tthis.mc = createChildMonitoringContext({\n\t\t\tlogger,\n\t\t\tproperties: {\n\t\t\t\tall: {\n\t\t\t\t\todc: hasOdcOrigin(new URL(this.odspResolvedUrl.endpoints.snapshotStorageUrl)),\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\n\t\tthis.hostPolicy = hostPolicy;\n\t\tthis.hostPolicy.supportGetSnapshotApi = this._policies.supportGetSnapshotApi;\n\t\tif (this.clientIsSummarizer) {\n\t\t\tthis.hostPolicy = { ...this.hostPolicy, summarizerClient: true };\n\t\t}\n\t}\n\n\tpublic get resolvedUrl(): IResolvedUrl {\n\t\treturn this.odspResolvedUrl;\n\t}\n\tpublic get policies(): IDocumentServicePolicies {\n\t\treturn this._policies;\n\t}\n\n\t/**\n\t * Connects to a storage endpoint for snapshot service.\n\t *\n\t * @returns returns the document storage service for sharepoint driver.\n\t */\n\tpublic async connectToStorage(): Promise<IDocumentStorageService> {\n\t\tif (!this.storageManager) {\n\t\t\tthis.storageManager = new OdspDocumentStorageService(\n\t\t\t\tthis.odspResolvedUrl,\n\t\t\t\tthis.getAuthHeader,\n\t\t\t\tthis.mc.logger,\n\t\t\t\ttrue,\n\t\t\t\tthis.cache,\n\t\t\t\tthis.hostPolicy,\n\t\t\t\tthis.epochTracker,\n\t\t\t\t// flushCallback\n\t\t\t\tasync () => {\n\t\t\t\t\tconst currentConnection = this.odspDelayLoadedDeltaStream?.currentDeltaConnection;\n\t\t\t\t\tif (currentConnection !== undefined && !currentConnection.disposed) {\n\t\t\t\t\t\treturn currentConnection.flush();\n\t\t\t\t\t}\n\t\t\t\t\tthrow new Error(\"Disconnected while uploading summary (attempt to perform flush())\");\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\treturn this.odspDelayLoadedDeltaStream?.relayServiceTenantAndSessionId;\n\t\t\t\t},\n\t\t\t\tthis.mc.config.getNumber(\"Fluid.Driver.Odsp.snapshotFormatFetchType\"),\n\t\t\t);\n\t\t}\n\n\t\treturn new RetryErrorsStorageAdapter(this.storageManager, this.mc.logger);\n\t}\n\n\t/**\n\t * Connects to a delta storage endpoint for getting ops between a range.\n\t *\n\t * @returns returns the document delta storage service for sharepoint driver.\n\t */\n\tpublic async connectToDeltaStorage(): Promise<IDocumentDeltaStorageService> {\n\t\tconst snapshotOps = this.storageManager?.ops ?? [];\n\t\tconst service = new OdspDeltaStorageService(\n\t\t\tthis.odspResolvedUrl.endpoints.deltaStorageUrl,\n\t\t\tthis.getAuthHeader,\n\t\t\tthis.epochTracker,\n\t\t\tthis.mc.logger,\n\t\t);\n\n\t\t// batch size, please see issue #5211 for data around batch sizing\n\t\tconst batchSize = this.hostPolicy.opsBatchSize ?? 5000;\n\t\tconst concurrency = this.hostPolicy.concurrentOpsBatches ?? 1;\n\t\treturn new OdspDeltaStorageWithCache(\n\t\t\tsnapshotOps,\n\t\t\tthis.mc.logger,\n\t\t\tbatchSize,\n\t\t\tconcurrency,\n\t\t\t// Get Ops from storage callback.\n\t\t\tasync (from, to, telemetryProps, fetchReason) =>\n\t\t\t\tservice.get(from, to, telemetryProps, fetchReason),\n\t\t\t// Get cachedOps Callback.\n\t\t\t// TODO AB#47218: This condition will be removed when file version can be read from the cache entry for an op.\n\t\t\tthis.odspResolvedUrl.fileVersion === undefined\n\t\t\t\t? async (from, to) =>\n\t\t\t\t\t\t((await this.opsCache?.get(from, to)) as ISequencedDocumentMessage[]) ?? []\n\t\t\t\t: async () => [],\n\t\t\t// Ops requestFromSocket Callback.\n\t\t\t(from, to) => {\n\t\t\t\tconst currentConnection = this.odspDelayLoadedDeltaStream?.currentDeltaConnection;\n\t\t\t\tif (currentConnection !== undefined && !currentConnection.disposed) {\n\t\t\t\t\tcurrentConnection.requestOps(from, to);\n\t\t\t\t}\n\t\t\t},\n\t\t\t(ops: ISequencedDocumentMessage[]) => this.opsReceived(ops),\n\t\t\t() => this.storageManager,\n\t\t);\n\t}\n\n\t/**\n\t * Connects to a delta stream endpoint for emitting ops.\n\t *\n\t * @returns returns the document delta stream service for onedrive/sharepoint driver.\n\t */\n\tpublic async connectToDeltaStream(client: IClient): Promise<IDocumentDeltaConnection> {\n\t\tif (this.socketModuleP === undefined) {\n\t\t\tthis.socketModuleP = this.getDelayLoadedDeltaStream();\n\t\t}\n\t\treturn this.socketModuleP\n\t\t\t.then(async (m) => {\n\t\t\t\tthis.odspSocketModuleLoaded = true;\n\t\t\t\treturn m.connectToDeltaStream(client);\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\t// Setting undefined in case someone tries to recover from module failure by calling again.\n\t\t\t\tthis.socketModuleP = undefined;\n\t\t\t\tthis.odspSocketModuleLoaded = false;\n\t\t\t\tthrow error;\n\t\t\t});\n\t}\n\n\t/**\n\t * This dynamically imports the module for loading the delta connection. In many cases the delta stream, is not\n\t * required during the critical load flow. So this way we don't have to bundle this in the initial bundle and can\n\t * import this later on when required.\n\t * @returns The delta stream object.\n\t */\n\tprivate async getDelayLoadedDeltaStream(): Promise<OdspDelayLoadedDeltaStream> {\n\t\tassert(this.odspSocketModuleLoaded === false, 0x507 /* Should be loaded only once */);\n\t\tconst module = await import(\n\t\t\t/* webpackChunkName: \"socketModule\" */ \"./odspDelayLoadedDeltaStream.js\"\n\t\t)\n\t\t\t.then((m) => {\n\t\t\t\tthis.mc.logger.sendTelemetryEvent({ eventName: \"SocketModuleLoaded\" });\n\t\t\t\treturn m;\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\tthis.mc.logger.sendErrorEvent({ eventName: \"SocketModuleLoadFailed\" }, error);\n\t\t\t\tthrow error;\n\t\t\t});\n\t\tthis.odspDelayLoadedDeltaStream = new module.OdspDelayLoadedDeltaStream(\n\t\t\tthis.odspResolvedUrl,\n\t\t\tthis._policies,\n\t\t\tthis.getAuthHeader,\n\t\t\tthis.getWebsocketToken,\n\t\t\tthis.mc,\n\t\t\tthis.cache,\n\t\t\tthis.hostPolicy,\n\t\t\tthis.epochTracker,\n\t\t\t(ops: ISequencedDocumentMessage[]) => this.opsReceived(ops),\n\t\t\t(metadata: Record<string, string>) => this.emit(\"metadataUpdate\", metadata),\n\t\t\tthis.socketReferenceKeyPrefix,\n\t\t);\n\t\treturn this.odspDelayLoadedDeltaStream;\n\t}\n\n\tpublic dispose(error?: unknown): void {\n\t\t// Error might indicate mismatch between client & server knowledge about file\n\t\t// (OdspErrorTypes.fileOverwrittenInStorage).\n\t\t// For example, file might have been overwritten in storage without generating new epoch\n\t\t// In such case client cached info is stale and has to be removed.\n\t\tif (error === undefined) {\n\t\t\tthis._opsCache?.flushOps();\n\t\t} else {\n\t\t\tthis.epochTracker.removeEntries().catch(() => {});\n\t\t}\n\t\tthis._opsCache?.dispose();\n\t\t// Only need to dipose this, if it is already loaded.\n\t\tthis.odspDelayLoadedDeltaStream?.dispose();\n\t}\n\n\tprotected get opsCache(): OpsCache | undefined {\n\t\tif (this._opsCache) {\n\t\t\treturn this._opsCache;\n\t\t}\n\n\t\tconst seqNumber = this.storageManager?.snapshotSequenceNumber;\n\t\tconst batchSize = this.hostPolicy.opsCaching?.batchSize ?? 100;\n\t\tif (seqNumber === undefined || batchSize < 1) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst opsKey: Omit<IEntry, \"key\"> = {\n\t\t\ttype: \"ops\",\n\t\t};\n\t\tthis._opsCache = new OpsCache(\n\t\t\tseqNumber,\n\t\t\tthis.mc.logger,\n\t\t\t// ICache\n\t\t\t{\n\t\t\t\twrite: async (key: string, opsData: string): Promise<void> => {\n\t\t\t\t\treturn this.cache.persistedCache.put({ ...opsKey, key }, opsData);\n\t\t\t\t},\n\t\t\t\tread: async (key: string) => this.cache.persistedCache.get({ ...opsKey, key }),\n\t\t\t\tremove: (): void => {\n\t\t\t\t\tthis.cache.persistedCache.removeEntries().catch(() => {});\n\t\t\t\t},\n\t\t\t},\n\t\t\tbatchSize,\n\t\t\tthis.hostPolicy.opsCaching?.timerGranularity ?? 5000,\n\t\t\tthis.hostPolicy.opsCaching?.totalOpsToCache ?? 5000,\n\t\t);\n\t\treturn this._opsCache;\n\t}\n\n\t// Called whenever re receive ops through any channel for this document (snapshot, delta connection, delta storage)\n\t// We use it to notify caching layer of how stale is snapshot stored in cache.\n\tprotected opsReceived(ops: ISequencedDocumentMessage[]): void {\n\t\t// No need for two clients to save same ops\n\t\tif (ops.length === 0 || this.odspResolvedUrl.summarizer) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.opsCache?.addOps(ops);\n\t}\n}\n"]}
@@ -9,7 +9,7 @@ import { OdspDocumentServiceFactoryCore } from "./odspDocumentServiceFactoryCore
9
9
  * Factory for creating the sharepoint document service. Use this if you want to
10
10
  * use the sharepoint implementation.
11
11
  * @legacy
12
- * @alpha
12
+ * @beta
13
13
  */
14
14
  export declare class OdspDocumentServiceFactory extends OdspDocumentServiceFactoryCore {
15
15
  constructor(getStorageToken: TokenFetcher<OdspResourceTokenFetchOptions>, getWebsocketToken: TokenFetcher<OdspResourceTokenFetchOptions> | undefined, persistedCache?: IPersistedCache, hostPolicy?: HostStoragePolicy);
@@ -21,7 +21,7 @@ export declare class OdspDocumentServiceFactory extends OdspDocumentServiceFacto
21
21
  * content directly.
22
22
  *
23
23
  * @legacy
24
- * @alpha
24
+ * @beta
25
25
  */
26
26
  export declare function createLocalOdspDocumentServiceFactory(localSnapshot: Uint8Array | string): IDocumentServiceFactory;
27
27
  //# sourceMappingURL=odspDocumentServiceFactory.d.ts.map
@@ -12,7 +12,7 @@ const odspDocumentServiceFactoryCore_js_1 = require("./odspDocumentServiceFactor
12
12
  * Factory for creating the sharepoint document service. Use this if you want to
13
13
  * use the sharepoint implementation.
14
14
  * @legacy
15
- * @alpha
15
+ * @beta
16
16
  */
17
17
  class OdspDocumentServiceFactory extends odspDocumentServiceFactoryCore_js_1.OdspDocumentServiceFactoryCore {
18
18
  constructor(getStorageToken, getWebsocketToken, persistedCache, hostPolicy) {
@@ -27,7 +27,7 @@ exports.OdspDocumentServiceFactory = OdspDocumentServiceFactory;
27
27
  * content directly.
28
28
  *
29
29
  * @legacy
30
- * @alpha
30
+ * @beta
31
31
  */
32
32
  function createLocalOdspDocumentServiceFactory(localSnapshot) {
33
33
  return new localOdspDocumentServiceFactory_js_1.LocalOdspDocumentServiceFactory(localSnapshot);