@fluidframework/odsp-driver 2.0.0-internal.2.1.2 → 2.0.0-internal.2.2.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 (83) hide show
  1. package/.eslintrc.js +1 -1
  2. package/dist/compactSnapshotParser.d.ts +1 -2
  3. package/dist/compactSnapshotParser.d.ts.map +1 -1
  4. package/dist/compactSnapshotParser.js +6 -2
  5. package/dist/compactSnapshotParser.js.map +1 -1
  6. package/dist/fetchSnapshot.d.ts.map +1 -1
  7. package/dist/fetchSnapshot.js +13 -18
  8. package/dist/fetchSnapshot.js.map +1 -1
  9. package/dist/localOdspDriver/localOdspDeltaStorageService.d.ts +17 -0
  10. package/dist/localOdspDriver/localOdspDeltaStorageService.d.ts.map +1 -0
  11. package/dist/localOdspDriver/localOdspDeltaStorageService.js +35 -0
  12. package/dist/localOdspDriver/localOdspDeltaStorageService.js.map +1 -0
  13. package/dist/localOdspDriver/localOdspDocumentService.d.ts +1 -0
  14. package/dist/localOdspDriver/localOdspDocumentService.d.ts.map +1 -1
  15. package/dist/localOdspDriver/localOdspDocumentService.js +5 -2
  16. package/dist/localOdspDriver/localOdspDocumentService.js.map +1 -1
  17. package/dist/odspDeltaStorageService.d.ts +0 -1
  18. package/dist/odspDeltaStorageService.d.ts.map +1 -1
  19. package/dist/odspDeltaStorageService.js +4 -20
  20. package/dist/odspDeltaStorageService.js.map +1 -1
  21. package/dist/odspDocumentDeltaConnection.js +1 -1
  22. package/dist/odspDocumentDeltaConnection.js.map +1 -1
  23. package/dist/odspDocumentService.d.ts.map +1 -1
  24. package/dist/odspDocumentService.js +9 -2
  25. package/dist/odspDocumentService.js.map +1 -1
  26. package/dist/odspUtils.d.ts +4 -0
  27. package/dist/odspUtils.d.ts.map +1 -1
  28. package/dist/odspUtils.js +32 -1
  29. package/dist/odspUtils.js.map +1 -1
  30. package/dist/packageVersion.d.ts +1 -1
  31. package/dist/packageVersion.js +1 -1
  32. package/dist/packageVersion.js.map +1 -1
  33. package/dist/zipItDataRepresentationUtils.d.ts +17 -2
  34. package/dist/zipItDataRepresentationUtils.d.ts.map +1 -1
  35. package/dist/zipItDataRepresentationUtils.js +15 -2
  36. package/dist/zipItDataRepresentationUtils.js.map +1 -1
  37. package/lib/compactSnapshotParser.d.ts +1 -2
  38. package/lib/compactSnapshotParser.d.ts.map +1 -1
  39. package/lib/compactSnapshotParser.js +6 -2
  40. package/lib/compactSnapshotParser.js.map +1 -1
  41. package/lib/fetchSnapshot.d.ts.map +1 -1
  42. package/lib/fetchSnapshot.js +14 -19
  43. package/lib/fetchSnapshot.js.map +1 -1
  44. package/lib/localOdspDriver/localOdspDeltaStorageService.d.ts +17 -0
  45. package/lib/localOdspDriver/localOdspDeltaStorageService.d.ts.map +1 -0
  46. package/lib/localOdspDriver/localOdspDeltaStorageService.js +31 -0
  47. package/lib/localOdspDriver/localOdspDeltaStorageService.js.map +1 -0
  48. package/lib/localOdspDriver/localOdspDocumentService.d.ts +1 -0
  49. package/lib/localOdspDriver/localOdspDocumentService.d.ts.map +1 -1
  50. package/lib/localOdspDriver/localOdspDocumentService.js +6 -3
  51. package/lib/localOdspDriver/localOdspDocumentService.js.map +1 -1
  52. package/lib/odspDeltaStorageService.d.ts +0 -1
  53. package/lib/odspDeltaStorageService.d.ts.map +1 -1
  54. package/lib/odspDeltaStorageService.js +5 -21
  55. package/lib/odspDeltaStorageService.js.map +1 -1
  56. package/lib/odspDocumentDeltaConnection.js +1 -1
  57. package/lib/odspDocumentDeltaConnection.js.map +1 -1
  58. package/lib/odspDocumentService.d.ts.map +1 -1
  59. package/lib/odspDocumentService.js +10 -3
  60. package/lib/odspDocumentService.js.map +1 -1
  61. package/lib/odspUtils.d.ts +4 -0
  62. package/lib/odspUtils.d.ts.map +1 -1
  63. package/lib/odspUtils.js +28 -0
  64. package/lib/odspUtils.js.map +1 -1
  65. package/lib/packageVersion.d.ts +1 -1
  66. package/lib/packageVersion.js +1 -1
  67. package/lib/packageVersion.js.map +1 -1
  68. package/lib/zipItDataRepresentationUtils.d.ts +17 -2
  69. package/lib/zipItDataRepresentationUtils.d.ts.map +1 -1
  70. package/lib/zipItDataRepresentationUtils.js +15 -2
  71. package/lib/zipItDataRepresentationUtils.js.map +1 -1
  72. package/package.json +19 -14
  73. package/prettier.config.cjs +8 -0
  74. package/src/compactSnapshotParser.ts +16 -12
  75. package/src/fetchSnapshot.ts +29 -24
  76. package/src/localOdspDriver/localOdspDeltaStorageService.ts +46 -0
  77. package/src/localOdspDriver/localOdspDocumentService.ts +9 -3
  78. package/src/odspDeltaStorageService.ts +5 -22
  79. package/src/odspDocumentDeltaConnection.ts +1 -1
  80. package/src/odspDocumentService.ts +9 -2
  81. package/src/odspUtils.ts +37 -0
  82. package/src/packageVersion.ts +1 -1
  83. package/src/zipItDataRepresentationUtils.ts +18 -3
@@ -1 +1 @@
1
- {"version":3,"file":"fetchSnapshot.js","sourceRoot":"","sources":["../src/fetchSnapshot.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AACrF,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAC5F,OAAO,EAGH,aAAa,GAEhB,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EAA6B,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAC9G,OAAO,EAAiE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AACxH,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,wBAAwB,EAAE,MAAM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;YACI,qEAAqE;YACrE,OAAO,CAAC,MAAM,GAAG,6CAA6C,kBAAkB,EAAE,CAAC;KAC1F;IAED,MAAM,YAAY,GAAG,MAAM,CAAC,MAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,KAAK,CAAC,GAAG,EAAE,YAAY,EAAE,aAAa,EAAE,IAAI,EAAE,YAAY,CAAC,mCACjG,WAAW,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC;IAEpC,OAAO;QACH,YAAY;QACZ,cAAc,EAAE,OAAO;QACvB,UAAU,EAAE,GAAG;KAClB,CAAC;AACN,CAAC;AAED,SAAS,wBAAwB,CAAC,eAAiC,EAAE,KAAU;;IAC3E,IAAI,CAAA,MAAA,eAAe,CAAC,aAAa,0CAAE,mBAAmB,MAAK,SAAS;WAC7D,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;WAC7C,CAAC,KAAK,CAAC,SAAS,KAAK,eAAe,CAAC,kBAAkB;eACnD,KAAK,CAAC,SAAS,KAAK,eAAe,CAAC,+BAA+B,CAAC,EAAE;QAC7E,OAAO,IAAI,CAAC;KACf;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,SAAS,kBAAkB,CAAC,GAAW;IACnC;;;OAGG;IACH,IAAI,UAAU,GAAG,gBAAgB,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;IAClD,UAAU,GAAG,UAAU;SAClB,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;SACnB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACnB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACzB,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACrC,OAAO,UAAU,CAAC;AACtB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { default as AbortController } from \"abort-controller\";\nimport { v4 as uuid } from \"uuid\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, fromUtf8ToBase64, performance } from \"@fluidframework/common-utils\";\nimport { DriverErrorType } from \"@fluidframework/driver-definitions\";\nimport { isFluidError, PerformanceEvent, wrapError } from \"@fluidframework/telemetry-utils\";\nimport {\n IOdspResolvedUrl,\n ISnapshotOptions,\n OdspErrorType,\n InstrumentedStorageTokenFetcher,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport { DriverErrorTelemetryProps, isRuntimeMessage, NonRetryableError } from \"@fluidframework/driver-utils\";\nimport { IOdspSnapshot, ISnapshotCachedEntry, IVersionedValueWithEpoch, persistedCacheValueVersion } from \"./contracts\";\nimport { getQueryString } from \"./getQueryString\";\nimport { getUrlAndHeadersWithAuth } from \"./getUrlAndHeadersWithAuth\";\nimport {\n fetchAndParseAsJSONHelper,\n fetchHelper,\n getWithRetryForTokenRefresh,\n getWithRetryForTokenRefreshRepeat,\n IOdspResponse,\n} from \"./odspUtils\";\nimport { ISnapshotContents } from \"./odspPublicUtils\";\nimport { convertOdspSnapshotToSnapshotTreeAndBlobs } from \"./odspSnapshotParser\";\nimport { currentReadVersion, ISnapshotContentsWithProps, parseCompactSnapshotResponse } from \"./compactSnapshotParser\";\nimport { EpochTracker } from \"./epochTracker\";\nimport { pkgVersion } from \"./packageVersion\";\n\nasync function measure<T>(callback: () => T | Promise<T>): Promise<[T, number]> {\n const start = performance.now();\n const result = await callback();\n const time = performance.now() - start;\n return [result, time];\n}\n\n/**\n * Enum to support different types of snapshot formats.\n */\nexport enum SnapshotFormatSupportType {\n Json = 0,\n Binary = 1,\n JsonAndBinary = 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 token - token used for authorization in the request\n * @param storageFetchWrapper - Implementation of the get/post methods used to fetch the snapshot\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 - whether to force passing given token via authorization header\n * @returns A promise of the snapshot and the status code of the response\n */\nexport async function fetchSnapshot(\n snapshotUrl: string,\n token: string | null,\n versionId: string,\n fetchFullSnapshot: boolean,\n forceAccessTokenViaAuthorizationHeader: boolean,\n logger: ITelemetryLogger,\n snapshotDownloader: (url: string, fetchOptions: { [index: string]: any; }) => Promise<IOdspResponse<unknown>>,\n): Promise<ISnapshotContents> {\n const path = `/trees/${versionId}`;\n let queryParams: ISnapshotOptions = {};\n\n if (fetchFullSnapshot) {\n queryParams = versionId !== \"latest\" ? { blobs: 2 } : { deltas: 1, blobs: 2 };\n }\n\n const queryString = getQueryString(queryParams);\n const { url, headers } = getUrlAndHeadersWithAuth(\n `${snapshotUrl}${path}${queryString}`, token, forceAccessTokenViaAuthorizationHeader);\n const response = await PerformanceEvent.timedExecAsync(\n logger,\n {\n eventName: \"fetchSnapshot\",\n headers: Object.keys(headers).length !== 0 ? true : undefined,\n },\n async () => snapshotDownloader(url, { headers }),\n ) as IOdspResponse<IOdspSnapshot>;\n return convertOdspSnapshotToSnapshotTreeAndBlobs(response.content);\n}\n\nexport async function fetchSnapshotWithRedeem(\n odspResolvedUrl: IOdspResolvedUrl,\n storageTokenFetcher: InstrumentedStorageTokenFetcher,\n snapshotOptions: ISnapshotOptions | undefined,\n forceAccessTokenViaAuthorizationHeader: boolean,\n logger: ITelemetryLogger,\n snapshotDownloader: (\n finalOdspResolvedUrl: IOdspResolvedUrl,\n storageToken: string,\n snapshotOptions: ISnapshotOptions | undefined,\n controller?: AbortController,\n ) => Promise<ISnapshotRequestAndResponseOptions>,\n putInCache: (valueWithEpoch: IVersionedValueWithEpoch) => Promise<void>,\n removeEntries: () => Promise<void>,\n enableRedeemFallback?: boolean,\n): Promise<ISnapshotContents> {\n // back-compat: This block to be removed with #8784 when we only consume/consider odsp resolvers that are >= 0.51\n const sharingLinkToRedeem = (odspResolvedUrl as any).sharingLinkToRedeem;\n if (sharingLinkToRedeem) {\n odspResolvedUrl.shareLinkInfo = { ...odspResolvedUrl.shareLinkInfo, sharingLinkToRedeem };\n }\n\n return fetchLatestSnapshotCore(\n odspResolvedUrl,\n storageTokenFetcher,\n snapshotOptions,\n logger,\n snapshotDownloader,\n putInCache,\n enableRedeemFallback,\n ).catch(async (error) => {\n if (enableRedeemFallback && isRedeemSharingLinkError(odspResolvedUrl, error)) {\n // Execute the redeem fallback\n\n await redeemSharingLink(\n odspResolvedUrl, storageTokenFetcher, logger, forceAccessTokenViaAuthorizationHeader);\n const odspResolvedUrlWithoutShareLink: IOdspResolvedUrl =\n {\n ...odspResolvedUrl,\n shareLinkInfo: {\n ...odspResolvedUrl.shareLinkInfo,\n sharingLinkToRedeem: undefined,\n },\n };\n\n // Log initial failure only if redeem succeeded - it points out to some bug somewhere\n // If redeem failed, that most likely means user has no permissions to access a file,\n // and thus it's not worth it logging extra errors - same error will be logged by end-to-end\n // flow (container open) based on a failure above.\n logger.sendErrorEvent({\n eventName: \"RedeemFallback\",\n errorType: error.errorType,\n }, error);\n\n return fetchLatestSnapshotCore(\n odspResolvedUrlWithoutShareLink,\n storageTokenFetcher,\n snapshotOptions,\n logger,\n snapshotDownloader,\n putInCache,\n );\n } else {\n throw error;\n }\n }).catch(async (error) => {\n // Clear the cache on 401/403/404 on snapshot fetch from network because this means either the user doesn't\n // have permissions for the file or it was deleted. So, if we do not clear cache, we will continue fetching\n // snapshot from cache in the future.\n if (typeof error === \"object\" && error !== null && error.errorType === DriverErrorType.authorizationError\n || error.errorType === DriverErrorType.fileNotFoundOrAccessDeniedError) {\n await removeEntries();\n }\n throw error;\n });\n}\n\nasync function redeemSharingLink(\n odspResolvedUrl: IOdspResolvedUrl,\n storageTokenFetcher: InstrumentedStorageTokenFetcher,\n logger: ITelemetryLogger,\n forceAccessTokenViaAuthorizationHeader: boolean,\n) {\n return PerformanceEvent.timedExecAsync(\n logger,\n {\n eventName: \"RedeemShareLink\",\n },\n async () => getWithRetryForTokenRefresh(async (tokenFetchOptions) => {\n assert(!!odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem,\n 0x1ed /* \"Share link should be present\" */);\n const storageToken = await storageTokenFetcher(tokenFetchOptions, \"RedeemShareLink\");\n const encodedShareUrl = getEncodedShareUrl(odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem);\n const redeemUrl = `${odspResolvedUrl.siteUrl}/_api/v2.0/shares/${encodedShareUrl}`;\n const { url, headers } = getUrlAndHeadersWithAuth(\n redeemUrl, storageToken, forceAccessTokenViaAuthorizationHeader);\n headers.prefer = \"redeemSharingLink\";\n return fetchAndParseAsJSONHelper(url, { headers });\n }),\n );\n}\n\nasync function fetchLatestSnapshotCore(\n odspResolvedUrl: IOdspResolvedUrl,\n storageTokenFetcher: InstrumentedStorageTokenFetcher,\n snapshotOptions: ISnapshotOptions | undefined,\n logger: ITelemetryLogger,\n snapshotDownloader: (\n finalOdspResolvedUrl: IOdspResolvedUrl,\n storageToken: string,\n snapshotOptions: ISnapshotOptions | undefined,\n controller?: AbortController,\n ) => Promise<ISnapshotRequestAndResponseOptions>,\n putInCache: (valueWithEpoch: IVersionedValueWithEpoch) => Promise<void>,\n enableRedeemFallback?: boolean,\n): Promise<ISnapshotContents> {\n return getWithRetryForTokenRefresh(async (tokenFetchOptions) => {\n const storageToken = await storageTokenFetcher(tokenFetchOptions, \"TreesLatest\", true);\n assert(storageToken !== null, 0x1e5 /* \"Storage token should not be null\" */);\n\n const perfEvent = {\n eventName: \"TreesLatest\",\n attempts: tokenFetchOptions.refresh ? 2 : 1,\n shareLinkPresent: odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem !== undefined,\n isSummarizer: odspResolvedUrl.summarizer,\n redeemFallbackEnabled: enableRedeemFallback,\n };\n if (snapshotOptions !== undefined) {\n Object.entries(snapshotOptions).forEach(([key, value]) => {\n if (value !== undefined) {\n perfEvent[`snapshotOption_${key}`] = value;\n }\n });\n }\n // This event measures only successful cases of getLatest call (no tokens, no retries).\n return PerformanceEvent.timedExecAsync(\n logger,\n perfEvent,\n async (event) => {\n let controller: AbortController | undefined;\n let fetchTimeout: ReturnType<typeof setTimeout> | undefined;\n if (snapshotOptions?.timeout !== undefined) {\n controller = new AbortController();\n fetchTimeout = setTimeout(\n () => controller!.abort(),\n snapshotOptions.timeout,\n );\n }\n\n const [response, fetchTime] = await measure(async () => snapshotDownloader(\n odspResolvedUrl,\n storageToken,\n snapshotOptions,\n controller,\n )).finally(() => {\n // Clear the fetchTimeout once the response is fetched.\n if (fetchTimeout !== undefined) {\n clearTimeout(fetchTimeout);\n fetchTimeout = undefined;\n }\n });\n\n const odspResponse = response.odspResponse;\n const contentType = odspResponse.headers.get(\"content-type\");\n\n const propsToLog: DriverErrorTelemetryProps = {\n ...odspResponse.propsToLog,\n contentType,\n accept: response.requestHeaders.accept,\n driverVersion: pkgVersion,\n };\n\n let parsedSnapshotContents: IOdspResponse<ISnapshotContentsWithProps> | undefined;\n let contentTypeToRead: string | undefined;\n if (contentType?.includes(\"application/ms-fluid\")) {\n contentTypeToRead = \"application/ms-fluid\";\n } else if (contentType?.includes(\"application/json\")) {\n contentTypeToRead = \"application/json\";\n }\n\n let parseTime: number;\n let receiveContentTime: number;\n try {\n switch (contentTypeToRead) {\n case \"application/json\": {\n let text: string;\n [text, receiveContentTime] = await measure(async () => odspResponse.content.text());\n propsToLog.bodySize = text.length;\n let content: IOdspSnapshot;\n [content, parseTime] = await measure( () => JSON.parse(text) as IOdspSnapshot);\n validateBlobsAndTrees(content);\n const snapshotContents: ISnapshotContents =\n convertOdspSnapshotToSnapshotTreeAndBlobs(content);\n parsedSnapshotContents = { ...odspResponse, content: snapshotContents };\n break;\n }\n case \"application/ms-fluid\": {\n let content: ArrayBuffer;\n [content, receiveContentTime] =\n await measure(async () => odspResponse.content.arrayBuffer());\n propsToLog.bodySize = content.byteLength;\n let snapshotContents: ISnapshotContentsWithProps;\n [snapshotContents, parseTime] = await measure(() => parseCompactSnapshotResponse(\n new Uint8Array(content),\n logger));\n if (snapshotContents.snapshotTree.trees === undefined ||\n snapshotContents.snapshotTree.blobs === undefined) {\n throw new NonRetryableError(\n \"Returned odsp snapshot is malformed. No trees or blobs!\",\n DriverErrorType.incorrectServerResponse,\n propsToLog,\n );\n }\n const slowTreeParseCodePaths = snapshotContents.slowTreeStructureCount ?? 0;\n const slowBlobParseCodePaths = snapshotContents.slowBlobStructureCount ?? 0;\n if (slowTreeParseCodePaths > 10 || slowBlobParseCodePaths > 10) {\n logger.sendErrorEvent({\n eventName: \"SlowSnapshotParseCodePaths\",\n slowTreeStructureCount: slowTreeParseCodePaths,\n slowBlobStructureCount: slowBlobParseCodePaths,\n });\n }\n parsedSnapshotContents = { ...odspResponse, content: snapshotContents };\n break;\n }\n default:\n throw new NonRetryableError(\n \"Unknown snapshot content type\",\n DriverErrorType.incorrectServerResponse,\n propsToLog,\n );\n }\n } catch (error) {\n if (isFluidError(error)) {\n error.addTelemetryProperties(propsToLog);\n throw error;\n }\n const enhancedError = wrapError(\n error,\n (errorMessage) => new NonRetryableError(\n `Error parsing snapshot response: ${errorMessage}`,\n DriverErrorType.genericError,\n propsToLog));\n throw enhancedError;\n }\n\n assert(parsedSnapshotContents !== undefined, 0x312 /* snapshot should be parsed */);\n const snapshot = parsedSnapshotContents.content;\n const { trees, numBlobs, encodedBlobsSize } = evalBlobsAndTrees(snapshot);\n\n // From: https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming\n // fetchStart: immediately before the browser starts to fetch the resource.\n // requestStart: immediately before the browser starts requesting the resource from the server\n // responseStart: immediately after the browser receives the first byte of the response from the server.\n // responseEnd: immediately after the browser receives the last byte of the resource\n // or immediately before the transport connection is closed, whichever comes first.\n // secureConnectionStart: immediately before the browser starts the handshake process to secure the\n // current connection. If a secure connection is not used, this property returns zero.\n // startTime: Time when the resource fetch started. This value is equivalent to fetchStart.\n // domainLookupStart: immediately before the browser starts the domain name lookup for the resource.\n // domainLookupEnd: immediately after the browser finishes the domain name lookup for the resource.\n // redirectStart: start time of the fetch which that initiates the redirect.\n // redirectEnd: immediately after receiving the last byte of the response of the last redirect.\n let dnsLookupTime: number | undefined; // domainLookupEnd - domainLookupStart\n let redirectTime: number | undefined; // redirectEnd - redirectStart\n let tcpHandshakeTime: number | undefined; // connectEnd - connectStart\n let secureConnectionTime: number | undefined; // connectEnd - secureConnectionStart\n let responseNetworkTime: number | undefined; // responsEnd - responseStart\n let fetchStartToResponseEndTime: number | undefined; // responseEnd - fetchStart\n let reqStartToResponseEndTime: number | undefined; // responseEnd - requestStart\n let networkTime: number | undefined; // responseEnd - startTime\n const spReqDuration = odspResponse.headers.get(\"sprequestduration\");\n\n // getEntriesByType is only available in browser performance object\n const resources1 = performance.getEntriesByType?.(\"resource\") ?? [];\n // Usually the latest fetch call is to the end of resources, so we start from the end.\n for (let i = resources1.length - 1; i > 0; i--) {\n const indResTime = resources1[i] as PerformanceResourceTiming;\n const resource_name = indResTime.name;\n const resource_initiatortype = indResTime.initiatorType;\n if ((resource_initiatortype.localeCompare(\"fetch\") === 0)\n && (resource_name.localeCompare(response.requestUrl) === 0)) {\n redirectTime = indResTime.redirectEnd - indResTime.redirectStart;\n dnsLookupTime = indResTime.domainLookupEnd - indResTime.domainLookupStart;\n tcpHandshakeTime = indResTime.connectEnd - indResTime.connectStart;\n secureConnectionTime = (indResTime.secureConnectionStart > 0) ?\n (indResTime.connectEnd - indResTime.secureConnectionStart) : undefined;\n responseNetworkTime = (indResTime.responseStart > 0) ?\n (indResTime.responseEnd - indResTime.responseStart) : undefined;\n fetchStartToResponseEndTime = (indResTime.fetchStart > 0) ?\n (indResTime.responseEnd - indResTime.fetchStart) : undefined;\n reqStartToResponseEndTime = (indResTime.requestStart > 0) ?\n (indResTime.responseEnd - indResTime.requestStart) : undefined;\n networkTime = fetchStartToResponseEndTime;\n if (spReqDuration !== undefined && networkTime !== undefined) {\n networkTime = networkTime - parseInt(spReqDuration, 10);\n }\n break;\n }\n }\n\n // There are some scenarios in ODSP where we cannot cache, trees/latest will explicitly tell us when we\n // cannot cache using an HTTP response header.\n const canCache =\n odspResponse.headers.get(\"disablebrowsercachingofusercontent\") !== \"true\";\n const sequenceNumber: number = snapshot.sequenceNumber ?? 0;\n const seqNumberFromOps = snapshot.ops && snapshot.ops.length > 0 ?\n snapshot.ops[0].sequenceNumber - 1 :\n undefined;\n\n if (!Number.isInteger(sequenceNumber)\n || seqNumberFromOps !== undefined && seqNumberFromOps !== sequenceNumber) {\n logger.sendErrorEvent({ eventName: \"fetchSnapshotError\", sequenceNumber, seqNumberFromOps });\n snapshot.sequenceNumber = undefined;\n } else if (canCache) {\n const fluidEpoch = odspResponse.headers.get(\"x-fluid-epoch\");\n assert(fluidEpoch !== undefined, 0x1e6 /* \"Epoch should be present in response\" */);\n const value: ISnapshotCachedEntry = {\n ...snapshot,\n cacheEntryTime: Date.now(),\n };\n const valueWithEpoch: IVersionedValueWithEpoch = {\n value,\n fluidEpoch,\n version: persistedCacheValueVersion,\n };\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n putInCache(valueWithEpoch);\n }\n\n event.end({\n trees,\n blobs: snapshot.blobs?.size ?? 0,\n leafNodes: numBlobs,\n encodedBlobsSize,\n sequenceNumber,\n ops: snapshot.ops?.length ?? 0,\n slowTreeStructureCount: snapshot.slowTreeStructureCount ?? 0,\n slowBlobStructureCount: snapshot.slowBlobStructureCount ?? 0,\n userOps: snapshot.ops?.filter((op) => isRuntimeMessage(op)).length ?? 0,\n headers: Object.keys(response.requestHeaders).length !== 0 ? true : undefined,\n // Interval between the first fetch until the last byte of the last redirect.\n redirectTime,\n // Interval between start and finish of the domain name lookup for the resource.\n dnsLookupTime,\n // Interval to receive all (first to last) bytes form the server.\n responseNetworkTime,\n // Time to establish the connection to the server to retrieve the resource.\n tcpHandshakeTime,\n // Time from the end of the connection until the inital handshake process to secure the connection.\n secureConnectionTime,\n // Interval between the initial fetch until the last byte is received.\n // Likely same as fetchTime + receiveContentTime.\n fetchStartToResponseEndTime,\n // reqStartToResponseEndTime = fetchStartToResponseEndTime - <initial TCP handshake>\n // Interval between starting the request for the resource until receiving the last byte.\n reqStartToResponseEndTime,\n // networkTime = fetchStartToResponseEndTime - sprequestduration\n // Interval between starting the request for the resource until receiving the last byte but\n // excluding the snaphot request duration indicated on the snapshot response header.\n networkTime,\n // Measures time to make fetch call. Should be similar to\n // fetchStartToResponseEndTime - receiveContentTime, i.e. it looks like it's time till first byte /\n // end of response headers\n fetchTime,\n // time it takes client to parse payload. Same payload as in \"SnapshotParse\" event, here for\n // easier analyzes.\n parseTime,\n // Time it takes to receive content (text of buffer) from Response object.\n // This time likely is very closely correlated with networkTime, i.e. time it takes to receive\n // actual content (starting measuring from first bite / end of response header)\n receiveContentTime,\n // Sharing link telemetry regarding sharing link redeem status and performance. Ex: FRL; dur=100,\n // Azure Fluid Relay service; desc=S, FRP; desc=False. Here, FRL is the duration taken for redeem,\n // Azure Fluid Relay service is the redeem status (S means success), and FRP is a flag to indicate\n // if the permission has changed.\n sltelemetry: odspResponse.headers.get(\"x-fluid-sltelemetry\"),\n // All other props\n ...propsToLog,\n });\n return snapshot;\n },\n ).catch((error) => {\n // We hit these errors in stress tests, under load\n // It's useful to try one more time in such case.\n if (typeof error === \"object\" && error !== null && (error.errorType === DriverErrorType.fetchFailure ||\n error.errorType === OdspErrorType.fetchTimeout)) {\n error[getWithRetryForTokenRefreshRepeat] = true;\n }\n throw error;\n });\n });\n}\n\nexport interface ISnapshotRequestAndResponseOptions {\n odspResponse: IOdspResponse<Response>;\n requestUrl: string;\n requestHeaders: { [index: string]: any; };\n}\n\nfunction getFormBodyAndHeaders(\n odspResolvedUrl: IOdspResolvedUrl,\n storageToken: string,\n snapshotOptions: ISnapshotOptions | undefined,\n headers?: { [index: string]: string; },\n) {\n const formBoundary = uuid();\n const formParams: string[] = [];\n formParams.push(`--${formBoundary}`);\n formParams.push(`Authorization: Bearer ${storageToken}`);\n formParams.push(`X-HTTP-Method-Override: GET`);\n if (snapshotOptions !== undefined) {\n Object.entries(snapshotOptions).forEach(([key, value]) => {\n if (value !== undefined) {\n formParams.push(`${key}: ${value}`);\n }\n });\n }\n if (headers !== undefined) {\n Object.entries(headers).forEach(([key, value]) => {\n if (value !== undefined) {\n formParams.push(`${key}: ${value}`);\n }\n });\n }\n if (odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem) {\n formParams.push(`sl: ${odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem}`);\n }\n formParams.push(`_post: 1`);\n formParams.push(`\\r\\n--${formBoundary}--`);\n const postBody = formParams.join(\"\\r\\n\");\n const header: { [index: string]: any; } = {\n \"Content-Type\": `multipart/form-data;boundary=${formBoundary}`,\n };\n return { body: postBody, headers: header };\n}\n\nfunction evalBlobsAndTrees(snapshot: ISnapshotContents) {\n const trees = countTreesInSnapshotTree(snapshot.snapshotTree);\n const numBlobs = snapshot.blobs.size;\n let encodedBlobsSize = 0;\n for (const [_, blobContent] of snapshot.blobs) {\n encodedBlobsSize += blobContent.byteLength;\n }\n return { trees, numBlobs, encodedBlobsSize };\n}\n\nexport function validateBlobsAndTrees(snapshot: IOdspSnapshot) {\n assert(snapshot.trees !== undefined,\n 0x200 /* \"Returned odsp snapshot is malformed. No trees!\" */);\n assert(snapshot.blobs !== undefined,\n 0x201 /* \"Returned odsp snapshot is malformed. No blobs!\" */);\n}\n\nfunction countTreesInSnapshotTree(snapshotTree: ISnapshotTree): number {\n let numTrees = 0;\n for (const [_, tree] of Object.entries(snapshotTree.trees)) {\n numTrees += 1;\n numTrees += countTreesInSnapshotTree(tree);\n }\n return numTrees;\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 logger - logger\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 async function downloadSnapshot(\n odspResolvedUrl: IOdspResolvedUrl,\n storageToken: string,\n logger: ITelemetryLogger,\n snapshotOptions: ISnapshotOptions | undefined,\n snapshotFormatFetchType?: SnapshotFormatSupportType,\n controller?: AbortController,\n epochTracker?: EpochTracker,\n scenarioName?: string,\n): Promise<ISnapshotRequestAndResponseOptions> {\n // back-compat: This block to be removed with #8784 when we only consume/consider odsp resolvers that are >= 0.51\n const sharingLinkToRedeem = (odspResolvedUrl as any).sharingLinkToRedeem;\n if (sharingLinkToRedeem) {\n odspResolvedUrl.shareLinkInfo = { ...odspResolvedUrl.shareLinkInfo, sharingLinkToRedeem };\n }\n\n const snapshotUrl = odspResolvedUrl.endpoints.snapshotStorageUrl;\n const url = `${snapshotUrl}/trees/latest?ump=1`;\n // The location of file can move on Spo in which case server returns 308(Permanent Redirect) error.\n // Adding below header will make VROOM API return 404 instead of 308 and browser can intercept it.\n // This error thrown by server will contain the new redirect location. Look at the 404 error parsing\n // for futher reference here: \\packages\\utils\\odsp-doclib-utils\\src\\odspErrorUtils.ts\n const header = { prefer: \"manualredirect\" };\n const { body, headers } = getFormBodyAndHeaders(\n odspResolvedUrl, storageToken, snapshotOptions, header);\n const fetchOptions = {\n body,\n headers,\n signal: controller?.signal,\n method: \"POST\",\n };\n // Decide what snapshot format to fetch as per the feature gate.\n switch (snapshotFormatFetchType) {\n case SnapshotFormatSupportType.Binary:\n headers.accept = `application/ms-fluid; v=${currentReadVersion}`;\n break;\n default:\n // By default ask both versions and let the server decide the format.\n headers.accept = `application/json, application/ms-fluid; v=${currentReadVersion}`;\n }\n\n const odspResponse = await (epochTracker?.fetch(url, fetchOptions, \"treesLatest\", true, scenarioName) ??\n fetchHelper(url, fetchOptions));\n\n return {\n odspResponse,\n requestHeaders: headers,\n requestUrl: url,\n };\n}\n\nfunction isRedeemSharingLinkError(odspResolvedUrl: IOdspResolvedUrl, error: any) {\n if (odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem !== undefined\n && (typeof error === \"object\" && error !== null)\n && (error.errorType === DriverErrorType.authorizationError\n || error.errorType === DriverErrorType.fileNotFoundOrAccessDeniedError)) {\n return true;\n }\n return false;\n}\n\nfunction getEncodedShareUrl(url: string): string {\n /**\n * Encode the url to accepted format by Sharepoint\n * https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/shares_get\n */\n let encodedUrl = fromUtf8ToBase64(encodeURI(url));\n encodedUrl = encodedUrl\n .replace(/=+$/g, \"\")\n .replace(/\\//g, \"_\")\n .replace(/\\+/g, \"-\");\n encodedUrl = \"u!\".concat(encodedUrl);\n return encodedUrl;\n}\n"]}
1
+ {"version":3,"file":"fetchSnapshot.js","sourceRoot":"","sources":["../src/fetchSnapshot.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AACrF,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAC5F,OAAO,EAGH,aAAa,GAEhB,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EAA6B,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAC9G,OAAO,EAAiE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AACxH,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EACH,yBAAyB,EACzB,WAAW,EACX,2BAA2B,EAC3B,iCAAiC,EAEjC,OAAO,EACP,QAA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CAAC;AAED,SAAS,wBAAwB,CAAC,eAAiC,EAAE,KAAU;;IAC3E,IAAI,CAAA,MAAA,eAAe,CAAC,aAAa,0CAAE,mBAAmB,MAAK,SAAS;WAC7D,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;WAC7C,CAAC,KAAK,CAAC,SAAS,KAAK,eAAe,CAAC,kBAAkB;eACnD,KAAK,CAAC,SAAS,KAAK,eAAe,CAAC,+BAA+B,CAAC,EAAE;QAC7E,OAAO,IAAI,CAAC;KACf;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,SAAS,kBAAkB,CAAC,GAAW;IACnC;;;OAGG;IACH,IAAI,UAAU,GAAG,gBAAgB,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;IAClD,UAAU,GAAG,UAAU;SAClB,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;SACnB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACnB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACzB,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACrC,OAAO,UAAU,CAAC;AACtB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { default as AbortController } from \"abort-controller\";\nimport { v4 as uuid } from \"uuid\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, fromUtf8ToBase64, performance } from \"@fluidframework/common-utils\";\nimport { DriverErrorType } from \"@fluidframework/driver-definitions\";\nimport { isFluidError, PerformanceEvent, wrapError } from \"@fluidframework/telemetry-utils\";\nimport {\n IOdspResolvedUrl,\n ISnapshotOptions,\n OdspErrorType,\n InstrumentedStorageTokenFetcher,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport { DriverErrorTelemetryProps, isRuntimeMessage, NonRetryableError } from \"@fluidframework/driver-utils\";\nimport { IOdspSnapshot, ISnapshotCachedEntry, IVersionedValueWithEpoch, persistedCacheValueVersion } from \"./contracts\";\nimport { getQueryString } from \"./getQueryString\";\nimport { getUrlAndHeadersWithAuth } from \"./getUrlAndHeadersWithAuth\";\nimport {\n fetchAndParseAsJSONHelper,\n fetchHelper,\n getWithRetryForTokenRefresh,\n getWithRetryForTokenRefreshRepeat,\n IOdspResponse,\n measure,\n measureP,\n} from \"./odspUtils\";\nimport { ISnapshotContents } from \"./odspPublicUtils\";\nimport { convertOdspSnapshotToSnapshotTreeAndBlobs } from \"./odspSnapshotParser\";\nimport { currentReadVersion, ISnapshotContentsWithProps, parseCompactSnapshotResponse } from \"./compactSnapshotParser\";\nimport { EpochTracker } from \"./epochTracker\";\nimport { pkgVersion } from \"./packageVersion\";\n\n/**\n * Enum to support different types of snapshot formats.\n */\nexport enum SnapshotFormatSupportType {\n Json = 0,\n Binary = 1,\n JsonAndBinary = 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 token - token used for authorization in the request\n * @param storageFetchWrapper - Implementation of the get/post methods used to fetch the snapshot\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 - whether to force passing given token via authorization header\n * @returns A promise of the snapshot and the status code of the response\n */\nexport async function fetchSnapshot(\n snapshotUrl: string,\n token: string | null,\n versionId: string,\n fetchFullSnapshot: boolean,\n forceAccessTokenViaAuthorizationHeader: boolean,\n logger: ITelemetryLogger,\n snapshotDownloader: (url: string, fetchOptions: { [index: string]: any; }) => Promise<IOdspResponse<unknown>>,\n): Promise<ISnapshotContents> {\n const path = `/trees/${versionId}`;\n let queryParams: ISnapshotOptions = {};\n\n if (fetchFullSnapshot) {\n queryParams = versionId !== \"latest\" ? { blobs: 2 } : { deltas: 1, blobs: 2 };\n }\n\n const queryString = getQueryString(queryParams);\n const { url, headers } = getUrlAndHeadersWithAuth(\n `${snapshotUrl}${path}${queryString}`, token, forceAccessTokenViaAuthorizationHeader);\n const response = await PerformanceEvent.timedExecAsync(\n logger,\n {\n eventName: \"fetchSnapshot\",\n headers: Object.keys(headers).length !== 0 ? true : undefined,\n },\n async () => snapshotDownloader(url, { headers }),\n ) as IOdspResponse<IOdspSnapshot>;\n return convertOdspSnapshotToSnapshotTreeAndBlobs(response.content);\n}\n\nexport async function fetchSnapshotWithRedeem(\n odspResolvedUrl: IOdspResolvedUrl,\n storageTokenFetcher: InstrumentedStorageTokenFetcher,\n snapshotOptions: ISnapshotOptions | undefined,\n forceAccessTokenViaAuthorizationHeader: boolean,\n logger: ITelemetryLogger,\n snapshotDownloader: (\n finalOdspResolvedUrl: IOdspResolvedUrl,\n storageToken: string,\n snapshotOptions: ISnapshotOptions | undefined,\n controller?: AbortController,\n ) => Promise<ISnapshotRequestAndResponseOptions>,\n putInCache: (valueWithEpoch: IVersionedValueWithEpoch) => Promise<void>,\n removeEntries: () => Promise<void>,\n enableRedeemFallback?: boolean,\n): Promise<ISnapshotContents> {\n // back-compat: This block to be removed with #8784 when we only consume/consider odsp resolvers that are >= 0.51\n const sharingLinkToRedeem = (odspResolvedUrl as any).sharingLinkToRedeem;\n if (sharingLinkToRedeem) {\n odspResolvedUrl.shareLinkInfo = { ...odspResolvedUrl.shareLinkInfo, sharingLinkToRedeem };\n }\n\n return fetchLatestSnapshotCore(\n odspResolvedUrl,\n storageTokenFetcher,\n snapshotOptions,\n logger,\n snapshotDownloader,\n putInCache,\n enableRedeemFallback,\n ).catch(async (error) => {\n if (enableRedeemFallback && isRedeemSharingLinkError(odspResolvedUrl, error)) {\n // Execute the redeem fallback\n\n await redeemSharingLink(\n odspResolvedUrl, storageTokenFetcher, logger, forceAccessTokenViaAuthorizationHeader);\n const odspResolvedUrlWithoutShareLink: IOdspResolvedUrl =\n {\n ...odspResolvedUrl,\n shareLinkInfo: {\n ...odspResolvedUrl.shareLinkInfo,\n sharingLinkToRedeem: undefined,\n },\n };\n\n // Log initial failure only if redeem succeeded - it points out to some bug somewhere\n // If redeem failed, that most likely means user has no permissions to access a file,\n // and thus it's not worth it logging extra errors - same error will be logged by end-to-end\n // flow (container open) based on a failure above.\n logger.sendErrorEvent({\n eventName: \"RedeemFallback\",\n errorType: error.errorType,\n }, error);\n\n return fetchLatestSnapshotCore(\n odspResolvedUrlWithoutShareLink,\n storageTokenFetcher,\n snapshotOptions,\n logger,\n snapshotDownloader,\n putInCache,\n );\n } else {\n throw error;\n }\n }).catch(async (error) => {\n // Clear the cache on 401/403/404 on snapshot fetch from network because this means either the user doesn't\n // have permissions for the file or it was deleted. So, if we do not clear cache, we will continue fetching\n // snapshot from cache in the future.\n if (typeof error === \"object\" && error !== null && error.errorType === DriverErrorType.authorizationError\n || error.errorType === DriverErrorType.fileNotFoundOrAccessDeniedError) {\n await removeEntries();\n }\n throw error;\n });\n}\n\nasync function redeemSharingLink(\n odspResolvedUrl: IOdspResolvedUrl,\n storageTokenFetcher: InstrumentedStorageTokenFetcher,\n logger: ITelemetryLogger,\n forceAccessTokenViaAuthorizationHeader: boolean,\n) {\n return PerformanceEvent.timedExecAsync(\n logger,\n {\n eventName: \"RedeemShareLink\",\n },\n async () => getWithRetryForTokenRefresh(async (tokenFetchOptions) => {\n assert(!!odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem,\n 0x1ed /* \"Share link should be present\" */);\n const storageToken = await storageTokenFetcher(tokenFetchOptions, \"RedeemShareLink\");\n const encodedShareUrl = getEncodedShareUrl(odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem);\n const redeemUrl = `${odspResolvedUrl.siteUrl}/_api/v2.0/shares/${encodedShareUrl}`;\n const { url, headers } = getUrlAndHeadersWithAuth(\n redeemUrl, storageToken, forceAccessTokenViaAuthorizationHeader);\n headers.prefer = \"redeemSharingLink\";\n return fetchAndParseAsJSONHelper(url, { headers });\n }),\n );\n}\n\nasync function fetchLatestSnapshotCore(\n odspResolvedUrl: IOdspResolvedUrl,\n storageTokenFetcher: InstrumentedStorageTokenFetcher,\n snapshotOptions: ISnapshotOptions | undefined,\n logger: ITelemetryLogger,\n snapshotDownloader: (\n finalOdspResolvedUrl: IOdspResolvedUrl,\n storageToken: string,\n snapshotOptions: ISnapshotOptions | undefined,\n controller?: AbortController,\n ) => Promise<ISnapshotRequestAndResponseOptions>,\n putInCache: (valueWithEpoch: IVersionedValueWithEpoch) => Promise<void>,\n enableRedeemFallback?: boolean,\n): Promise<ISnapshotContents> {\n return getWithRetryForTokenRefresh(async (tokenFetchOptions) => {\n const storageToken = await storageTokenFetcher(tokenFetchOptions, \"TreesLatest\", true);\n assert(storageToken !== null, 0x1e5 /* \"Storage token should not be null\" */);\n\n const perfEvent = {\n eventName: \"TreesLatest\",\n attempts: tokenFetchOptions.refresh ? 2 : 1,\n shareLinkPresent: odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem !== undefined,\n isSummarizer: odspResolvedUrl.summarizer,\n redeemFallbackEnabled: enableRedeemFallback,\n };\n if (snapshotOptions !== undefined) {\n Object.entries(snapshotOptions).forEach(([key, value]) => {\n if (value !== undefined) {\n perfEvent[`snapshotOption_${key}`] = value;\n }\n });\n }\n // This event measures only successful cases of getLatest call (no tokens, no retries).\n return PerformanceEvent.timedExecAsync(\n logger,\n perfEvent,\n async (event) => {\n let controller: AbortController | undefined;\n let fetchTimeout: ReturnType<typeof setTimeout> | undefined;\n if (snapshotOptions?.timeout !== undefined) {\n controller = new AbortController();\n fetchTimeout = setTimeout(\n () => controller!.abort(),\n snapshotOptions.timeout,\n );\n }\n\n const [response, fetchTime] = await measureP(async () => snapshotDownloader(\n odspResolvedUrl,\n storageToken,\n snapshotOptions,\n controller,\n )).finally(() => {\n // Clear the fetchTimeout once the response is fetched.\n if (fetchTimeout !== undefined) {\n clearTimeout(fetchTimeout);\n fetchTimeout = undefined;\n }\n });\n\n const odspResponse = response.odspResponse;\n const contentType = odspResponse.headers.get(\"content-type\");\n\n const propsToLog: DriverErrorTelemetryProps = {\n ...odspResponse.propsToLog,\n contentType,\n accept: response.requestHeaders.accept,\n driverVersion: pkgVersion,\n };\n\n let parsedSnapshotContents: IOdspResponse<ISnapshotContentsWithProps> | undefined;\n let contentTypeToRead: string | undefined;\n if (contentType?.includes(\"application/ms-fluid\")) {\n contentTypeToRead = \"application/ms-fluid\";\n } else if (contentType?.includes(\"application/json\")) {\n contentTypeToRead = \"application/json\";\n }\n\n let parseTime: number;\n let receiveContentTime: number;\n try {\n switch (contentTypeToRead) {\n case \"application/json\": {\n let text: string;\n [text, receiveContentTime] = await measureP(async () => odspResponse.content.text());\n propsToLog.bodySize = text.length;\n let content: IOdspSnapshot;\n [content, parseTime] = measure( () => JSON.parse(text) as IOdspSnapshot);\n validateBlobsAndTrees(content);\n const snapshotContents: ISnapshotContents =\n convertOdspSnapshotToSnapshotTreeAndBlobs(content);\n parsedSnapshotContents = {\n ...odspResponse,\n content: {\n ...snapshotContents,\n telemetryProps: {},\n },\n };\n break;\n }\n case \"application/ms-fluid\": {\n let content: ArrayBuffer;\n [content, receiveContentTime] =\n await measureP(async () => odspResponse.content.arrayBuffer());\n propsToLog.bodySize = content.byteLength;\n let snapshotContents: ISnapshotContentsWithProps;\n [snapshotContents, parseTime] = measure(() => parseCompactSnapshotResponse(\n new Uint8Array(content),\n logger));\n if (snapshotContents.snapshotTree.trees === undefined ||\n snapshotContents.snapshotTree.blobs === undefined) {\n throw new NonRetryableError(\n \"Returned odsp snapshot is malformed. No trees or blobs!\",\n DriverErrorType.incorrectServerResponse,\n propsToLog,\n );\n }\n\n const props = snapshotContents.telemetryProps;\n const slowTreeParseCodePaths = props.slowTreeStructureCount ?? 0;\n const slowBlobParseCodePaths = props.slowBlobStructureCount ?? 0;\n if (slowTreeParseCodePaths > 10 || slowBlobParseCodePaths > 10) {\n logger.sendErrorEvent({\n eventName: \"SlowSnapshotParseCodePaths\",\n slowTreeStructureCount: slowTreeParseCodePaths,\n slowBlobStructureCount: slowBlobParseCodePaths,\n });\n }\n parsedSnapshotContents = { ...odspResponse, content: snapshotContents };\n break;\n }\n default:\n throw new NonRetryableError(\n \"Unknown snapshot content type\",\n DriverErrorType.incorrectServerResponse,\n propsToLog,\n );\n }\n } catch (error) {\n if (isFluidError(error)) {\n error.addTelemetryProperties(propsToLog);\n throw error;\n }\n const enhancedError = wrapError(\n error,\n (errorMessage) => new NonRetryableError(\n `Error parsing snapshot response: ${errorMessage}`,\n DriverErrorType.genericError,\n propsToLog));\n throw enhancedError;\n }\n\n assert(parsedSnapshotContents !== undefined, 0x312 /* snapshot should be parsed */);\n const snapshot = parsedSnapshotContents.content;\n const { trees, numBlobs, encodedBlobsSize } = evalBlobsAndTrees(snapshot);\n\n // From: https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming\n // fetchStart: immediately before the browser starts to fetch the resource.\n // requestStart: immediately before the browser starts requesting the resource from the server\n // responseStart: immediately after the browser receives the first byte of the response from the server.\n // responseEnd: immediately after the browser receives the last byte of the resource\n // or immediately before the transport connection is closed, whichever comes first.\n // secureConnectionStart: immediately before the browser starts the handshake process to secure the\n // current connection. If a secure connection is not used, this property returns zero.\n // startTime: Time when the resource fetch started. This value is equivalent to fetchStart.\n // domainLookupStart: immediately before the browser starts the domain name lookup for the resource.\n // domainLookupEnd: immediately after the browser finishes the domain name lookup for the resource.\n // redirectStart: start time of the fetch which that initiates the redirect.\n // redirectEnd: immediately after receiving the last byte of the response of the last redirect.\n let dnsLookupTime: number | undefined; // domainLookupEnd - domainLookupStart\n let redirectTime: number | undefined; // redirectEnd - redirectStart\n let tcpHandshakeTime: number | undefined; // connectEnd - connectStart\n let secureConnectionTime: number | undefined; // connectEnd - secureConnectionStart\n let responseNetworkTime: number | undefined; // responsEnd - responseStart\n let fetchStartToResponseEndTime: number | undefined; // responseEnd - fetchStart\n let reqStartToResponseEndTime: number | undefined; // responseEnd - requestStart\n let networkTime: number | undefined; // responseEnd - startTime\n const spReqDuration = odspResponse.headers.get(\"sprequestduration\");\n\n // getEntriesByType is only available in browser performance object\n const resources1 = performance.getEntriesByType?.(\"resource\") ?? [];\n // Usually the latest fetch call is to the end of resources, so we start from the end.\n for (let i = resources1.length - 1; i > 0; i--) {\n const indResTime = resources1[i] as PerformanceResourceTiming;\n const resource_name = indResTime.name;\n const resource_initiatortype = indResTime.initiatorType;\n if ((resource_initiatortype.localeCompare(\"fetch\") === 0)\n && (resource_name.localeCompare(response.requestUrl) === 0)) {\n redirectTime = indResTime.redirectEnd - indResTime.redirectStart;\n dnsLookupTime = indResTime.domainLookupEnd - indResTime.domainLookupStart;\n tcpHandshakeTime = indResTime.connectEnd - indResTime.connectStart;\n secureConnectionTime = (indResTime.secureConnectionStart > 0) ?\n (indResTime.connectEnd - indResTime.secureConnectionStart) : undefined;\n responseNetworkTime = (indResTime.responseStart > 0) ?\n (indResTime.responseEnd - indResTime.responseStart) : undefined;\n fetchStartToResponseEndTime = (indResTime.fetchStart > 0) ?\n (indResTime.responseEnd - indResTime.fetchStart) : undefined;\n reqStartToResponseEndTime = (indResTime.requestStart > 0) ?\n (indResTime.responseEnd - indResTime.requestStart) : undefined;\n networkTime = fetchStartToResponseEndTime;\n if (spReqDuration !== undefined && networkTime !== undefined) {\n networkTime = networkTime - parseInt(spReqDuration, 10);\n }\n break;\n }\n }\n\n // There are some scenarios in ODSP where we cannot cache, trees/latest will explicitly tell us when we\n // cannot cache using an HTTP response header.\n const canCache =\n odspResponse.headers.get(\"disablebrowsercachingofusercontent\") !== \"true\";\n const sequenceNumber: number = snapshot.sequenceNumber ?? 0;\n const seqNumberFromOps = snapshot.ops && snapshot.ops.length > 0 ?\n snapshot.ops[0].sequenceNumber - 1 :\n undefined;\n\n if (!Number.isInteger(sequenceNumber)\n || seqNumberFromOps !== undefined && seqNumberFromOps !== sequenceNumber) {\n logger.sendErrorEvent({ eventName: \"fetchSnapshotError\", sequenceNumber, seqNumberFromOps });\n snapshot.sequenceNumber = undefined;\n } else if (canCache) {\n const fluidEpoch = odspResponse.headers.get(\"x-fluid-epoch\");\n assert(fluidEpoch !== undefined, 0x1e6 /* \"Epoch should be present in response\" */);\n const value: ISnapshotCachedEntry = {\n ...snapshot,\n cacheEntryTime: Date.now(),\n };\n const valueWithEpoch: IVersionedValueWithEpoch = {\n value,\n fluidEpoch,\n version: persistedCacheValueVersion,\n };\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n putInCache(valueWithEpoch);\n }\n\n event.end({\n trees,\n blobs: snapshot.blobs?.size ?? 0,\n leafNodes: numBlobs,\n encodedBlobsSize,\n sequenceNumber,\n ops: snapshot.ops?.length ?? 0,\n userOps: snapshot.ops?.filter((op) => isRuntimeMessage(op)).length ?? 0,\n headers: Object.keys(response.requestHeaders).length !== 0 ? true : undefined,\n // Interval between the first fetch until the last byte of the last redirect.\n redirectTime,\n // Interval between start and finish of the domain name lookup for the resource.\n dnsLookupTime,\n // Interval to receive all (first to last) bytes form the server.\n responseNetworkTime,\n // Time to establish the connection to the server to retrieve the resource.\n tcpHandshakeTime,\n // Time from the end of the connection until the inital handshake process to secure the connection.\n secureConnectionTime,\n // Interval between the initial fetch until the last byte is received.\n // Likely same as fetchTime + receiveContentTime.\n fetchStartToResponseEndTime,\n // reqStartToResponseEndTime = fetchStartToResponseEndTime - <initial TCP handshake>\n // Interval between starting the request for the resource until receiving the last byte.\n reqStartToResponseEndTime,\n // networkTime = fetchStartToResponseEndTime - sprequestduration\n // Interval between starting the request for the resource until receiving the last byte but\n // excluding the snaphot request duration indicated on the snapshot response header.\n networkTime,\n // Measures time to make fetch call. Should be similar to\n // fetchStartToResponseEndTime - receiveContentTime, i.e. it looks like it's time till first byte /\n // end of response headers\n fetchTime,\n // time it takes client to parse payload. Same payload as in \"SnapshotParse\" event, here for\n // easier analyzes.\n parseTime,\n // Time it takes to receive content (text of buffer) from Response object.\n // This time likely is very closely correlated with networkTime, i.e. time it takes to receive\n // actual content (starting measuring from first bite / end of response header)\n receiveContentTime,\n // Sharing link telemetry regarding sharing link redeem status and performance. Ex: FRL; dur=100,\n // Azure Fluid Relay service; desc=S, FRP; desc=False. Here, FRL is the duration taken for redeem,\n // Azure Fluid Relay service is the redeem status (S means success), and FRP is a flag to indicate\n // if the permission has changed.\n sltelemetry: odspResponse.headers.get(\"x-fluid-sltelemetry\"),\n // All other props\n ...propsToLog,\n // Various perf counters and measures collected by binary parsing code:\n // slowTreeStructureCount, slowBlobStructureCount, durationStructure, durationStrings,\n // durationSnapshotTree, durationBlobs, etc.\n ...parsedSnapshotContents.content.telemetryProps,\n });\n return snapshot;\n },\n ).catch((error) => {\n // We hit these errors in stress tests, under load\n // It's useful to try one more time in such case.\n if (typeof error === \"object\" && error !== null && (error.errorType === DriverErrorType.fetchFailure ||\n error.errorType === OdspErrorType.fetchTimeout)) {\n error[getWithRetryForTokenRefreshRepeat] = true;\n }\n throw error;\n });\n });\n}\n\nexport interface ISnapshotRequestAndResponseOptions {\n odspResponse: IOdspResponse<Response>;\n requestUrl: string;\n requestHeaders: { [index: string]: any; };\n}\n\nfunction getFormBodyAndHeaders(\n odspResolvedUrl: IOdspResolvedUrl,\n storageToken: string,\n snapshotOptions: ISnapshotOptions | undefined,\n headers?: { [index: string]: string; },\n) {\n const formBoundary = uuid();\n const formParams: string[] = [];\n formParams.push(`--${formBoundary}`);\n formParams.push(`Authorization: Bearer ${storageToken}`);\n formParams.push(`X-HTTP-Method-Override: GET`);\n if (snapshotOptions !== undefined) {\n Object.entries(snapshotOptions).forEach(([key, value]) => {\n if (value !== undefined) {\n formParams.push(`${key}: ${value}`);\n }\n });\n }\n if (headers !== undefined) {\n Object.entries(headers).forEach(([key, value]) => {\n if (value !== undefined) {\n formParams.push(`${key}: ${value}`);\n }\n });\n }\n if (odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem) {\n formParams.push(`sl: ${odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem}`);\n }\n formParams.push(`_post: 1`);\n formParams.push(`\\r\\n--${formBoundary}--`);\n const postBody = formParams.join(\"\\r\\n\");\n const header: { [index: string]: any; } = {\n \"Content-Type\": `multipart/form-data;boundary=${formBoundary}`,\n };\n return { body: postBody, headers: header };\n}\n\nfunction evalBlobsAndTrees(snapshot: ISnapshotContents) {\n const trees = countTreesInSnapshotTree(snapshot.snapshotTree);\n const numBlobs = snapshot.blobs.size;\n let encodedBlobsSize = 0;\n for (const [_, blobContent] of snapshot.blobs) {\n encodedBlobsSize += blobContent.byteLength;\n }\n return { trees, numBlobs, encodedBlobsSize };\n}\n\nexport function validateBlobsAndTrees(snapshot: IOdspSnapshot) {\n assert(snapshot.trees !== undefined,\n 0x200 /* \"Returned odsp snapshot is malformed. No trees!\" */);\n assert(snapshot.blobs !== undefined,\n 0x201 /* \"Returned odsp snapshot is malformed. No blobs!\" */);\n}\n\nfunction countTreesInSnapshotTree(snapshotTree: ISnapshotTree): number {\n let numTrees = 0;\n for (const [_, tree] of Object.entries(snapshotTree.trees)) {\n numTrees += 1;\n numTrees += countTreesInSnapshotTree(tree);\n }\n return numTrees;\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 logger - logger\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 async function downloadSnapshot(\n odspResolvedUrl: IOdspResolvedUrl,\n storageToken: string,\n logger: ITelemetryLogger,\n snapshotOptions: ISnapshotOptions | undefined,\n snapshotFormatFetchType?: SnapshotFormatSupportType,\n controller?: AbortController,\n epochTracker?: EpochTracker,\n scenarioName?: string,\n): Promise<ISnapshotRequestAndResponseOptions> {\n // back-compat: This block to be removed with #8784 when we only consume/consider odsp resolvers that are >= 0.51\n const sharingLinkToRedeem = (odspResolvedUrl as any).sharingLinkToRedeem;\n if (sharingLinkToRedeem) {\n odspResolvedUrl.shareLinkInfo = { ...odspResolvedUrl.shareLinkInfo, sharingLinkToRedeem };\n }\n\n const snapshotUrl = odspResolvedUrl.endpoints.snapshotStorageUrl;\n const url = `${snapshotUrl}/trees/latest?ump=1`;\n // The location of file can move on Spo in which case server returns 308(Permanent Redirect) error.\n // Adding below header will make VROOM API return 404 instead of 308 and browser can intercept it.\n // This error thrown by server will contain the new redirect location. Look at the 404 error parsing\n // for futher reference here: \\packages\\utils\\odsp-doclib-utils\\src\\odspErrorUtils.ts\n const header = { prefer: \"manualredirect\" };\n const { body, headers } = getFormBodyAndHeaders(\n odspResolvedUrl, storageToken, snapshotOptions, header);\n const fetchOptions = {\n body,\n headers,\n signal: controller?.signal,\n method: \"POST\",\n };\n // Decide what snapshot format to fetch as per the feature gate.\n switch (snapshotFormatFetchType) {\n case SnapshotFormatSupportType.Binary:\n headers.accept = `application/ms-fluid; v=${currentReadVersion}`;\n break;\n default:\n // By default ask both versions and let the server decide the format.\n headers.accept = `application/json, application/ms-fluid; v=${currentReadVersion}`;\n }\n\n const odspResponse = await (epochTracker?.fetch(url, fetchOptions, \"treesLatest\", true, scenarioName) ??\n fetchHelper(url, fetchOptions));\n\n return {\n odspResponse,\n requestHeaders: headers,\n requestUrl: url,\n };\n}\n\nfunction isRedeemSharingLinkError(odspResolvedUrl: IOdspResolvedUrl, error: any) {\n if (odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem !== undefined\n && (typeof error === \"object\" && error !== null)\n && (error.errorType === DriverErrorType.authorizationError\n || error.errorType === DriverErrorType.fileNotFoundOrAccessDeniedError)) {\n return true;\n }\n return false;\n}\n\nfunction getEncodedShareUrl(url: string): string {\n /**\n * Encode the url to accepted format by Sharepoint\n * https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/shares_get\n */\n let encodedUrl = fromUtf8ToBase64(encodeURI(url));\n encodedUrl = encodedUrl\n .replace(/=+$/g, \"\")\n .replace(/\\//g, \"_\")\n .replace(/\\+/g, \"-\");\n encodedUrl = \"u!\".concat(encodedUrl);\n return encodedUrl;\n}\n"]}
@@ -0,0 +1,17 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { ITelemetryLogger } from "@fluidframework/common-definitions";
6
+ import { IDocumentDeltaStorageService, IStream } from "@fluidframework/driver-definitions";
7
+ import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
8
+ /**
9
+ * Implementation of IDocumentDeltaStorageService that will return snapshot ops when fetching messages
10
+ */
11
+ export declare class LocalOdspDeltaStorageService implements IDocumentDeltaStorageService {
12
+ private readonly logger;
13
+ private snapshotOps;
14
+ constructor(logger: ITelemetryLogger, snapshotOps: ISequencedDocumentMessage[]);
15
+ fetchMessages(from: number, to: number | undefined, _abortSignal?: AbortSignal, _cachedOnly?: boolean, _fetchReason?: string): IStream<ISequencedDocumentMessage[]>;
16
+ }
17
+ //# sourceMappingURL=localOdspDeltaStorageService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localOdspDeltaStorageService.d.ts","sourceRoot":"","sources":["../../src/localOdspDriver/localOdspDeltaStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,4BAA4B,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAE3F,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AAGjF;;GAEG;AACH,qBAAa,4BAA6B,YAAW,4BAA4B;IAEzE,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,WAAW;gBADF,MAAM,EAAE,gBAAgB,EACjC,WAAW,EAAE,yBAAyB,EAAE;IAG7C,aAAa,CAChB,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,GAAG,SAAS,EACtB,YAAY,CAAC,EAAE,WAAW,EAC1B,WAAW,CAAC,EAAE,OAAO,EACrB,YAAY,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,yBAAyB,EAAE,CAAC;CAmB1C"}
@@ -0,0 +1,31 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { Queue, emptyMessageStream } from "@fluidframework/driver-utils";
6
+ import { validateMessages } from "../odspUtils";
7
+ /**
8
+ * Implementation of IDocumentDeltaStorageService that will return snapshot ops when fetching messages
9
+ */
10
+ export class LocalOdspDeltaStorageService {
11
+ constructor(logger, snapshotOps) {
12
+ this.logger = logger;
13
+ this.snapshotOps = snapshotOps;
14
+ }
15
+ fetchMessages(from, to, _abortSignal, _cachedOnly, _fetchReason) {
16
+ if (this.snapshotOps.length === 0) {
17
+ return emptyMessageStream;
18
+ }
19
+ const queue = new Queue();
20
+ const messages = this.snapshotOps.filter((op) => op.sequenceNumber >= from && (to === undefined || op.sequenceNumber < to));
21
+ validateMessages("cached", messages, from, this.logger);
22
+ if (messages.length === 0 || messages[0].sequenceNumber !== from) {
23
+ this.snapshotOps = [];
24
+ }
25
+ this.snapshotOps = this.snapshotOps.filter((op) => to !== undefined && op.sequenceNumber >= to);
26
+ queue.pushValue(messages);
27
+ queue.pushDone();
28
+ return queue;
29
+ }
30
+ }
31
+ //# sourceMappingURL=localOdspDeltaStorageService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localOdspDeltaStorageService.js","sourceRoot":"","sources":["../../src/localOdspDriver/localOdspDeltaStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAEzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD;;GAEG;AACH,MAAM,OAAO,4BAA4B;IACrC,YACqB,MAAwB,EACjC,WAAwC;QAD/B,WAAM,GAAN,MAAM,CAAkB;QACjC,gBAAW,GAAX,WAAW,CAA6B;IAChD,CAAC;IAEE,aAAa,CAChB,IAAY,EACZ,EAAsB,EACtB,YAA0B,EAC1B,WAAqB,EACrB,YAAqB;QAErB,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE;YAC/B,OAAO,kBAAkB,CAAC;SAC7B;QAED,MAAM,KAAK,GAAG,IAAI,KAAK,EAA+B,CAAC;QACvD,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAC5C,EAAE,CAAC,cAAc,IAAI,IAAI,IAAI,CAAC,EAAE,KAAK,SAAS,IAAI,EAAE,CAAC,cAAc,GAAG,EAAE,CAAC,CAAC,CAAC;QAC/E,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAExD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,cAAc,KAAK,IAAI,EAAE;YAC9D,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;SACzB;QACD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,SAAS,IAAI,EAAE,CAAC,cAAc,IAAI,EAAE,CAAC,CAAC;QAEhG,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QAC1B,KAAK,CAAC,QAAQ,EAAE,CAAC;QACjB,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { IDocumentDeltaStorageService, IStream } from \"@fluidframework/driver-definitions\";\nimport { Queue, emptyMessageStream } from \"@fluidframework/driver-utils\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { validateMessages } from \"../odspUtils\";\n\n/**\n * Implementation of IDocumentDeltaStorageService that will return snapshot ops when fetching messages\n */\nexport class LocalOdspDeltaStorageService implements IDocumentDeltaStorageService {\n constructor(\n private readonly logger: ITelemetryLogger,\n private snapshotOps: ISequencedDocumentMessage[],\n ) { }\n\n public fetchMessages(\n from: number,\n to: number | undefined,\n _abortSignal?: AbortSignal,\n _cachedOnly?: boolean,\n _fetchReason?: string,\n ): IStream<ISequencedDocumentMessage[]> {\n if (this.snapshotOps.length === 0) {\n return emptyMessageStream;\n }\n\n const queue = new Queue<ISequencedDocumentMessage[]>();\n const messages = this.snapshotOps.filter((op) =>\n op.sequenceNumber >= from && (to === undefined || op.sequenceNumber < to));\n validateMessages(\"cached\", messages, from, this.logger);\n\n if (messages.length === 0 || messages[0].sequenceNumber !== from) {\n this.snapshotOps = [];\n }\n this.snapshotOps = this.snapshotOps.filter((op) => to !== undefined && op.sequenceNumber >= to);\n\n queue.pushValue(messages);\n queue.pushDone();\n return queue;\n }\n}\n"]}
@@ -16,6 +16,7 @@ export declare class LocalOdspDocumentService implements IDocumentService {
16
16
  policies: {
17
17
  storageOnly: boolean;
18
18
  };
19
+ private storageManager?;
19
20
  constructor(odspResolvedUrl: IOdspResolvedUrl, logger: ITelemetryLogger, localSnapshot: Uint8Array | string);
20
21
  get resolvedUrl(): IResolvedUrl;
21
22
  connectToStorage(): Promise<IDocumentStorageService>;
@@ -1 +1 @@
1
- {"version":3,"file":"localOdspDocumentService.d.ts","sourceRoot":"","sources":["../../src/localOdspDriver/localOdspDocumentService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EACH,4BAA4B,EAC5B,gBAAgB,EAChB,uBAAuB,EACvB,YAAY,EACf,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAC3E,OAAO,EAA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AM;IAGvD,IAAW,WAAW,IAAI,YAAY,CAErC;IAEY,gBAAgB,IAAI,OAAO,CAAC,uBAAuB,CAAC;IAQpD,qBAAqB,IAAI,OAAO,CAAC,4BAA4B,CAAC;IAOpE,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,KAAK;IAM7C,OAAO,CAAC,MAAM,CAAC,EAAE,GAAG,GAAG,IAAI;CAGrC"}
@@ -2,7 +2,8 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { UsageError, EmptyDocumentDeltaStorageService } from "@fluidframework/driver-utils";
5
+ import { UsageError } from "@fluidframework/driver-utils";
6
+ import { LocalOdspDeltaStorageService } from "./localOdspDeltaStorageService";
6
7
  import { LocalOdspDocumentStorageService } from "./localOdspDocumentStorageManager";
7
8
  /**
8
9
  * IDocumentService implementation that provides explicit snapshot to the document storage service.
@@ -18,10 +19,12 @@ export class LocalOdspDocumentService {
18
19
  return this.odspResolvedUrl;
19
20
  }
20
21
  async connectToStorage() {
21
- return new LocalOdspDocumentStorageService(this.logger, this.localSnapshot);
22
+ this.storageManager = new LocalOdspDocumentStorageService(this.logger, this.localSnapshot);
23
+ return this.storageManager;
22
24
  }
23
25
  async connectToDeltaStorage() {
24
- return new EmptyDocumentDeltaStorageService();
26
+ var _a, _b;
27
+ return new LocalOdspDeltaStorageService(this.logger, (_b = (_a = this.storageManager) === null || _a === void 0 ? void 0 : _a.ops) !== null && _b !== void 0 ? _b : []);
25
28
  }
26
29
  connectToDeltaStream(_client) {
27
30
  const toThrow = new UsageError("\"connectToDeltaStream\" is not supported by LocalOdspDocumentService");
@@ -1 +1 @@
1
- {"version":3,"file":"localOdspDocumentService.js","sourceRoot":"","sources":["../../src/localOdspDriver/localOdspDocumentService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,OAAO,EAAE,UAAU,EAAE,gCAAgC,EAAE,MAAM,8BAA8B,CAAC;AAG5F,OAAO,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAC;AAEpF;;GAEG;AACH,MAAM,OAAO,wBAAwB;IAGjC,YACqB,eAAiC,EACjC,MAAwB,EACxB,aAAkC;QAFlC,oBAAe,GAAf,eAAe,CAAkB;QACjC,WAAM,GAAN,MAAM,CAAkB;QACxB,kBAAa,GAAb,aAAa,CAAqB;QALhD,aAAQ,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;IAMpC,CAAC;IAEL,IAAW,WAAW;QAClB,OAAO,IAAI,CAAC,eAAe,CAAC;IAChC,CAAC;IAEM,KAAK,CAAC,gBAAgB;QACzB,OAAO,IAAI,+BAA+B,CACtC,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,aAAa,CACrB,CAAC;IACN,CAAC;IAEM,KAAK,CAAC,qBAAqB;QAC9B,OAAO,IAAI,gCAAgC,EAAE,CAAC;IAClD,CAAC;IAEM,oBAAoB,CAAC,OAAgB;QACxC,MAAM,OAAO,GAAG,IAAI,UAAU,CAAC,uEAAuE,CAAC,CAAC;QACxG,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,SAAS,EAAE,kBAAkB,EAAE,EAAE,OAAO,CAAC,CAAC;QACvE,MAAM,OAAO,CAAC;IAClB,CAAC;IAEM,OAAO,CAAC,MAAY;QACvB,aAAa;IACjB,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport {\n IDocumentDeltaStorageService,\n IDocumentService,\n IDocumentStorageService,\n IResolvedUrl,\n} from \"@fluidframework/driver-definitions\";\nimport { UsageError, EmptyDocumentDeltaStorageService } from \"@fluidframework/driver-utils\";\nimport { IOdspResolvedUrl } from \"@fluidframework/odsp-driver-definitions\";\nimport { IClient } from \"@fluidframework/protocol-definitions\";\nimport { LocalOdspDocumentStorageService } from \"./localOdspDocumentStorageManager\";\n\n/**\n * IDocumentService implementation that provides explicit snapshot to the document storage service.\n */\nexport class LocalOdspDocumentService implements IDocumentService {\n public policies = { storageOnly: true };\n\n constructor(\n private readonly odspResolvedUrl: IOdspResolvedUrl,\n private readonly logger: ITelemetryLogger,\n private readonly localSnapshot: Uint8Array | string,\n ) { }\n\n public get resolvedUrl(): IResolvedUrl {\n return this.odspResolvedUrl;\n }\n\n public async connectToStorage(): Promise<IDocumentStorageService> {\n return new LocalOdspDocumentStorageService(\n this.logger,\n this.localSnapshot,\n );\n }\n\n public async connectToDeltaStorage(): Promise<IDocumentDeltaStorageService> {\n return new EmptyDocumentDeltaStorageService();\n }\n\n public connectToDeltaStream(_client: IClient): never {\n const toThrow = new UsageError(\"\\\"connectToDeltaStream\\\" is not supported by LocalOdspDocumentService\");\n this.logger.sendErrorEvent({ eventName: \"UnsupportedUsage\" }, toThrow);\n throw toThrow;\n }\n\n public dispose(_error?: any): void {\n // Do nothing\n }\n}\n"]}
1
+ {"version":3,"file":"localOdspDocumentService.js","sourceRoot":"","sources":["../../src/localOdspDriver/localOdspDocumentService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAG1D,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAC;AAEpF;;GAEG;AACH,MAAM,OAAO,wBAAwB;IAIjC,YACqB,eAAiC,EACjC,MAAwB,EACxB,aAAkC;QAFlC,oBAAe,GAAf,eAAe,CAAkB;QACjC,WAAM,GAAN,MAAM,CAAkB;QACxB,kBAAa,GAAb,aAAa,CAAqB;QANhD,aAAQ,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;IAOpC,CAAC;IAEL,IAAW,WAAW;QAClB,OAAO,IAAI,CAAC,eAAe,CAAC;IAChC,CAAC;IAEM,KAAK,CAAC,gBAAgB;QACzB,IAAI,CAAC,cAAc,GAAG,IAAI,+BAA+B,CACrD,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,aAAa,CACrB,CAAC;QACF,OAAO,IAAI,CAAC,cAAc,CAAC;IAC/B,CAAC;IAEM,KAAK,CAAC,qBAAqB;;QAC9B,OAAO,IAAI,4BAA4B,CACnC,IAAI,CAAC,MAAM,EACX,MAAA,MAAA,IAAI,CAAC,cAAc,0CAAE,GAAG,mCAAI,EAAE,CACjC,CAAC;IACN,CAAC;IAEM,oBAAoB,CAAC,OAAgB;QACxC,MAAM,OAAO,GAAG,IAAI,UAAU,CAAC,uEAAuE,CAAC,CAAC;QACxG,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,SAAS,EAAE,kBAAkB,EAAE,EAAE,OAAO,CAAC,CAAC;QACvE,MAAM,OAAO,CAAC;IAClB,CAAC;IAEM,OAAO,CAAC,MAAY;QACvB,aAAa;IACjB,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport {\n IDocumentDeltaStorageService,\n IDocumentService,\n IDocumentStorageService,\n IResolvedUrl,\n} from \"@fluidframework/driver-definitions\";\nimport { UsageError } from \"@fluidframework/driver-utils\";\nimport { IOdspResolvedUrl } from \"@fluidframework/odsp-driver-definitions\";\nimport { IClient } from \"@fluidframework/protocol-definitions\";\nimport { LocalOdspDeltaStorageService } from \"./localOdspDeltaStorageService\";\nimport { LocalOdspDocumentStorageService } from \"./localOdspDocumentStorageManager\";\n\n/**\n * IDocumentService implementation that provides explicit snapshot to the document storage service.\n */\nexport class LocalOdspDocumentService implements IDocumentService {\n public policies = { storageOnly: true };\n private storageManager?: LocalOdspDocumentStorageService;\n\n constructor(\n private readonly odspResolvedUrl: IOdspResolvedUrl,\n private readonly logger: ITelemetryLogger,\n private readonly localSnapshot: Uint8Array | string,\n ) { }\n\n public get resolvedUrl(): IResolvedUrl {\n return this.odspResolvedUrl;\n }\n\n public async connectToStorage(): Promise<IDocumentStorageService> {\n this.storageManager = new LocalOdspDocumentStorageService(\n this.logger,\n this.localSnapshot,\n );\n return this.storageManager;\n }\n\n public async connectToDeltaStorage(): Promise<IDocumentDeltaStorageService> {\n return new LocalOdspDeltaStorageService(\n this.logger,\n this.storageManager?.ops ?? [],\n );\n }\n\n public connectToDeltaStream(_client: IClient): never {\n const toThrow = new UsageError(\"\\\"connectToDeltaStream\\\" is not supported by LocalOdspDocumentService\");\n this.logger.sendErrorEvent({ eventName: \"UnsupportedUsage\" }, toThrow);\n throw toThrow;\n }\n\n public dispose(_error?: any): void {\n // Do nothing\n }\n}\n"]}
@@ -38,7 +38,6 @@ export declare class OdspDeltaStorageWithCache implements IDocumentDeltaStorageS
38
38
  private readonly opsReceived;
39
39
  private firstCacheMiss;
40
40
  constructor(snapshotOps: ISequencedDocumentMessage[] | undefined, logger: ITelemetryLogger, batchSize: number, concurrency: number, getFromStorage: (from: number, to: number, telemetryProps: ITelemetryProperties, fetchReason?: string) => Promise<IDeltasFetchResult>, getCached: (from: number, to: number) => Promise<ISequencedDocumentMessage[]>, requestFromSocket: (from: number, to: number) => void, opsReceived: (ops: ISequencedDocumentMessage[]) => void);
41
- protected validateMessages(reason: string, messages: ISequencedDocumentMessage[], from: number): void;
42
41
  fetchMessages(fromTotal: number, toTotal: number | undefined, abortSignal?: AbortSignal, cachedOnly?: boolean, fetchReason?: string): import("@fluidframework/driver-definitions").IStream<ISequencedDocumentMessage[]>;
43
42
  }
44
43
  //# sourceMappingURL=odspDeltaStorageService.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"odspDeltaStorageService.d.ts","sourceRoot":"","sources":["../src/odspDeltaStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAE5F,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAE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AE,MAAM,EACjB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,WAAW,CAAC,EAAE,WAAW,EACzB,UAAU,CAAC,EAAE,OAAO,EACpB,WAAW,CAAC,EAAE,MAAM;CAkF3B"}
@@ -6,7 +6,7 @@ import { default as AbortController } from "abort-controller";
6
6
  import { v4 as uuid } from "uuid";
7
7
  import { assert } from "@fluidframework/common-utils";
8
8
  import { requestOps, streamObserver, } from "@fluidframework/driver-utils";
9
- import { getWithRetryForTokenRefresh } from "./odspUtils";
9
+ import { getWithRetryForTokenRefresh, validateMessages } from "./odspUtils";
10
10
  /**
11
11
  * Provides access to the underlying delta storage on the server for sharepoint driver.
12
12
  */
@@ -83,22 +83,6 @@ export class OdspDeltaStorageWithCache {
83
83
  this.opsReceived = opsReceived;
84
84
  this.firstCacheMiss = Number.MAX_SAFE_INTEGER;
85
85
  }
86
- validateMessages(reason, messages, from) {
87
- if (messages.length !== 0) {
88
- const start = messages[0].sequenceNumber;
89
- const length = messages.length;
90
- const last = messages[length - 1].sequenceNumber;
91
- if (start !== from) {
92
- this.logger.sendErrorEvent({ eventName: "OpsFetchViolation", reason, from, start, last, length });
93
- messages.length = 0;
94
- }
95
- if (last + 1 !== from + length) {
96
- this.logger.sendErrorEvent({ eventName: "OpsFetchViolation", reason, from, start, last, length });
97
- // we can do better here by finding consecutive sub-block and return it
98
- messages.length = 0;
99
- }
100
- }
101
- }
102
86
  fetchMessages(fromTotal, toTotal, abortSignal, cachedOnly, fetchReason) {
103
87
  // We do not control what's in the cache. Current API assumes that fetchMessages() keeps banging on
104
88
  // storage / cache until it gets ops it needs. This would result in deadlock if fixed range is asked from
@@ -111,7 +95,7 @@ export class OdspDeltaStorageWithCache {
111
95
  const requestCallback = async (from, to, telemetryProps) => {
112
96
  if (this.snapshotOps !== undefined && this.snapshotOps.length !== 0) {
113
97
  const messages = this.snapshotOps.filter((op) => op.sequenceNumber >= from && op.sequenceNumber < to);
114
- this.validateMessages("cached", messages, from);
98
+ validateMessages("cached", messages, from, this.logger);
115
99
  if (messages.length > 0 && messages[0].sequenceNumber === from) {
116
100
  this.snapshotOps = this.snapshotOps.filter((op) => op.sequenceNumber >= to);
117
101
  opsFromSnapshot = messages.length;
@@ -125,7 +109,7 @@ export class OdspDeltaStorageWithCache {
125
109
  // This saves a bit of processing time
126
110
  if (from < this.firstCacheMiss) {
127
111
  const messagesFromCache = await this.getCached(from, to);
128
- this.validateMessages("cached", messagesFromCache, from);
112
+ validateMessages("cached", messagesFromCache, from, this.logger);
129
113
  if (messagesFromCache.length !== 0) {
130
114
  opsFromCache += messagesFromCache.length;
131
115
  return {
@@ -139,7 +123,7 @@ export class OdspDeltaStorageWithCache {
139
123
  return { messages: [], partialResult: false };
140
124
  }
141
125
  const ops = await this.getFromStorage(from, to, telemetryProps, fetchReason);
142
- this.validateMessages("storage", ops.messages, from);
126
+ validateMessages("storage", ops.messages, from, this.logger);
143
127
  opsFromStorage += ops.messages.length;
144
128
  this.opsReceived(ops.messages);
145
129
  return ops;
@@ -147,7 +131,7 @@ export class OdspDeltaStorageWithCache {
147
131
  const stream = requestOps(async (from, to, telemetryProps) => {
148
132
  const result = await requestCallback(from, to, telemetryProps);
149
133
  // Catch all case, just in case
150
- this.validateMessages("catch all", result.messages, from);
134
+ validateMessages("catch all", result.messages, from, this.logger);
151
135
  return result;
152
136
  },
153
137
  // Staging: starting with no concurrency, listening for feedback first.
@@ -1 +1 @@
1
- {"version":3,"file":"odspDeltaStorageService.js","sourceRoot":"","sources":["../src/odspDeltaStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAItD,OAAO,EACH,UAAU,EACV,cAAc,GACjB,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAA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MAAM,GAAG,UAAU,CACrB,KAAK,EAAE,IAAY,EAAE,EAAU,EAAE,cAAoC,EAAE,EAAE;YACrE,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,IAAI,EAAE,EAAE,EAAE,cAAc,CAAC,CAAC;YAC/D,+BAA+B;YAC/B,IAAI,CAAC,gBAAgB,CAAC,WAAW,EAAE,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;YAC1D,OAAO,MAAM,CAAC;QAClB,CAAC;QACD,uEAAuE;QACvE,0DAA0D;QAC1D,IAAI,CAAC,WAAW,EAChB,SAAS,EAAE,YAAY;QACvB,OAAO,EAAE,YAAY;QACrB,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,MAAM,EACX,WAAW,EACX,WAAW,CACd,CAAC;QAEF,OAAO,cAAc,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE;YACrC,IAAI,MAAM,CAAC,IAAI,IAAI,eAAe,GAAG,YAAY,GAAG,cAAc,KAAK,CAAC,EAAE;gBACtE,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC;oBAC7B,SAAS,EAAE,mBAAmB;oBAC9B,eAAe;oBACf,YAAY;oBACZ,cAAc;iBACjB,CAAC,CAAC;aACN;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { default as AbortController } from \"abort-controller\";\nimport { v4 as uuid } from \"uuid\";\nimport { ITelemetryLogger, ITelemetryProperties } from \"@fluidframework/common-definitions\";\nimport { assert } from \"@fluidframework/common-utils\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { InstrumentedStorageTokenFetcher } from \"@fluidframework/odsp-driver-definitions\";\nimport { IDeltasFetchResult, IDocumentDeltaStorageService } from \"@fluidframework/driver-definitions\";\nimport {\n requestOps,\n streamObserver,\n} from \"@fluidframework/driver-utils\";\nimport { IDeltaStorageGetResponse, ISequencedDeltaOpMessage } from \"./contracts\";\nimport { EpochTracker } from \"./epochTracker\";\nimport { getWithRetryForTokenRefresh } from \"./odspUtils\";\n\n/**\n * Provides access to the underlying delta storage on the server for sharepoint driver.\n */\nexport class OdspDeltaStorageService {\n constructor(\n private readonly deltaFeedUrl: string,\n private readonly getStorageToken: InstrumentedStorageTokenFetcher,\n private readonly epochTracker: EpochTracker,\n private readonly logger: ITelemetryLogger,\n ) {\n }\n\n /**\n * Retrieves ops from storage\n * @param from - inclusive\n * @param to - exclusive\n * @param telemetryProps - properties to add when issuing telemetry events\n * @param scenarioName - reason for fetching ops\n * @returns ops retrieved & info if result was partial (i.e. more is available)\n */\n public async get(\n from: number,\n to: number,\n telemetryProps: ITelemetryProperties,\n scenarioName?: string,\n ): Promise<IDeltasFetchResult> {\n return getWithRetryForTokenRefresh(async (options) => {\n // Note - this call ends up in getSocketStorageDiscovery() and can refresh token\n // Thus it needs to be done before we call getStorageToken() to reduce extra calls\n const baseUrl = this.buildUrl(from, to);\n const storageToken = await this.getStorageToken(options, \"DeltaStorage\");\n\n const formBoundary = uuid();\n let postBody = `--${formBoundary}\\r\\n`;\n postBody += `Authorization: Bearer ${storageToken}\\r\\n`;\n postBody += `X-HTTP-Method-Override: GET\\r\\n`;\n\n postBody += `_post: 1\\r\\n`;\n postBody += `\\r\\n--${formBoundary}--`;\n const headers: { [index: string]: any; } = {\n \"Content-Type\": `multipart/form-data;boundary=${formBoundary}`,\n };\n\n // Some request take a long time (1-2 minutes) to complete, where telemetry shows very small amount\n // of time spent on server, and usually small payload sizes. I.e. all the time is spent somewhere in\n // networking. Even bigger problem - a lot of requests timeout (based on cursory look - after 1-2 minutes)\n // So adding some timeout to ensure we retry again in hope of faster success.\n // Please see https://github.com/microsoft/FluidFramework/issues/6997 for details.\n const abort = new AbortController();\n const timer = setTimeout(() => abort.abort(), 30000);\n\n const response = await this.epochTracker.fetchAndParseAsJSON<IDeltaStorageGetResponse>(\n baseUrl,\n {\n headers,\n body: postBody,\n method: \"POST\",\n signal: abort.signal,\n },\n \"ops\",\n true,\n scenarioName,\n );\n clearTimeout(timer);\n const deltaStorageResponse = response.content;\n const messages = deltaStorageResponse.value.length > 0 && \"op\" in deltaStorageResponse.value[0]\n ? (deltaStorageResponse.value as ISequencedDeltaOpMessage[]).map((operation) => operation.op)\n : deltaStorageResponse.value as ISequencedDocumentMessage[];\n\n this.logger.sendPerformanceEvent({\n eventName: \"OpsFetch\",\n headers: Object.keys(headers).length !== 0 ? true : undefined,\n length: messages.length,\n duration: response.duration, // this duration for single attempt!\n ...response.propsToLog,\n attempts: options.refresh ? 2 : 1,\n from,\n to,\n ...telemetryProps,\n reason: scenarioName,\n });\n\n // It is assumed that server always returns all the ops that it has in the range that was requested.\n // This may change in the future, if so, we need to adjust and receive \"end\" value from server in such case.\n return { messages, partialResult: false };\n });\n }\n\n public buildUrl(from: number, to: number) {\n const filter = encodeURIComponent(`sequenceNumber ge ${from} and sequenceNumber le ${to - 1}`);\n const queryString = `?ump=1&filter=${filter}`;\n return `${this.deltaFeedUrl}${queryString}`;\n }\n}\n\nexport class OdspDeltaStorageWithCache implements IDocumentDeltaStorageService {\n private firstCacheMiss = Number.MAX_SAFE_INTEGER;\n\n public constructor(\n private snapshotOps: ISequencedDocumentMessage[] | undefined,\n private readonly logger: ITelemetryLogger,\n private readonly batchSize: number,\n private readonly concurrency: number,\n private readonly getFromStorage: (\n from: number,\n to: number,\n telemetryProps: ITelemetryProperties,\n fetchReason?: string) => Promise<IDeltasFetchResult>,\n private readonly getCached: (from: number, to: number) => Promise<ISequencedDocumentMessage[]>,\n private readonly requestFromSocket: (from: number, to: number) => void,\n private readonly opsReceived: (ops: ISequencedDocumentMessage[]) => void,\n ) {\n }\n\n protected validateMessages(reason: string, messages: ISequencedDocumentMessage[], from: number) {\n if (messages.length !== 0) {\n const start = messages[0].sequenceNumber;\n const length = messages.length;\n const last = messages[length - 1].sequenceNumber;\n if (start !== from) {\n this.logger.sendErrorEvent({ eventName: \"OpsFetchViolation\", reason, from, start, last, length });\n messages.length = 0;\n }\n if (last + 1 !== from + length) {\n this.logger.sendErrorEvent({ eventName: \"OpsFetchViolation\", reason, from, start, last, length });\n // we can do better here by finding consecutive sub-block and return it\n messages.length = 0;\n }\n }\n }\n\n public fetchMessages(\n fromTotal: number,\n toTotal: number | undefined,\n abortSignal?: AbortSignal,\n cachedOnly?: boolean,\n fetchReason?: string) {\n // We do not control what's in the cache. Current API assumes that fetchMessages() keeps banging on\n // storage / cache until it gets ops it needs. This would result in deadlock if fixed range is asked from\n // cache and it's not there.\n // Better implementation would be to return only what we have in cache, but that also breaks API\n assert(!cachedOnly || toTotal === undefined, 0x1e3);\n\n let opsFromSnapshot = 0;\n let opsFromCache = 0;\n let opsFromStorage = 0;\n\n const requestCallback = async (from: number, to: number, telemetryProps: ITelemetryProperties) => {\n if (this.snapshotOps !== undefined && this.snapshotOps.length !== 0) {\n const messages = this.snapshotOps.filter((op) =>\n op.sequenceNumber >= from && op.sequenceNumber < to);\n this.validateMessages(\"cached\", messages, from);\n if (messages.length > 0 && messages[0].sequenceNumber === from) {\n this.snapshotOps = this.snapshotOps.filter((op) => op.sequenceNumber >= to);\n opsFromSnapshot = messages.length;\n return { messages, partialResult: true };\n }\n this.snapshotOps = undefined;\n }\n\n // Kick out request to PUSH for ops if it has them\n this.requestFromSocket(from, to);\n\n // Cache in normal flow is continuous. Once there is a miss, stop consulting cache.\n // This saves a bit of processing time\n if (from < this.firstCacheMiss) {\n const messagesFromCache = await this.getCached(from, to);\n this.validateMessages(\"cached\", messagesFromCache, from);\n if (messagesFromCache.length !== 0) {\n opsFromCache += messagesFromCache.length;\n return {\n messages: messagesFromCache,\n partialResult: true,\n };\n }\n this.firstCacheMiss = Math.min(this.firstCacheMiss, from);\n }\n\n if (cachedOnly) {\n return { messages: [], partialResult: false };\n }\n\n const ops = await this.getFromStorage(from, to, telemetryProps, fetchReason);\n this.validateMessages(\"storage\", ops.messages, from);\n opsFromStorage += ops.messages.length;\n this.opsReceived(ops.messages);\n return ops;\n };\n\n const stream = requestOps(\n async (from: number, to: number, telemetryProps: ITelemetryProperties) => {\n const result = await requestCallback(from, to, telemetryProps);\n // Catch all case, just in case\n this.validateMessages(\"catch all\", result.messages, from);\n return result;\n },\n // Staging: starting with no concurrency, listening for feedback first.\n // In future releases we will switch to actual concurrency\n this.concurrency,\n fromTotal, // inclusive\n toTotal, // exclusive\n this.batchSize,\n this.logger,\n abortSignal,\n fetchReason,\n );\n\n return streamObserver(stream, (result) => {\n if (result.done && opsFromSnapshot + opsFromCache + opsFromStorage !== 0) {\n this.logger.sendPerformanceEvent({\n eventName: \"CacheOpsRetrieved\",\n opsFromSnapshot,\n opsFromCache,\n opsFromStorage,\n });\n }\n });\n }\n}\n"]}
1
+ {"version":3,"file":"odspDeltaStorageService.js","sourceRoot":"","sources":["../src/odspDeltaStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAItD,OAAO,EACH,UAAU,EACV,cAAc,GACjB,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAAE,2BAA2B,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE5E;;GAEG;AACH,MAAM,OAAO,uBAAuB;IAChC,YACqB,YAAoB,EACpB,eAAgD,EAChD,YAA0B,EAC1B,MAAwB;QAHxB,iBAAY,GAAZ,YAAY,CAAQ;QACpB,oBAAe,GAAf,eAAe,CAAiC;QAChD,iBAAY,GAAZ,YAAY,CAAc;QAC1B,WAAM,GAAN,MAAM,CAAkB;IAE7C,CAAC;IAED;;;;;;;OAOG;IACK,KAAK,CAAC,GAAG,CACb,IAAY,EACZ,EAAU,EACV,cAAoC,EACpC,YAAqB;QAErB,OAAO,2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C,CAAC;YAC/B,OAAO,GAAG,CAAC;QACf,CAAC,CAAC;QAEF,MAAM,MAAM,GAAG,UAAU,CACrB,KAAK,EAAE,IAAY,EAAE,EAAU,EAAE,cAAoC,EAAE,EAAE;YACrE,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,IAAI,EAAE,EAAE,EAAE,cAAc,CAAC,CAAC;YAC/D,+BAA+B;YAC/B,gBAAgB,CAAC,WAAW,EAAE,MAAM,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;YAClE,OAAO,MAAM,CAAC;QAClB,CAAC;QACD,uEAAuE;QACvE,0DAA0D;QAC1D,IAAI,CAAC,WAAW,EAChB,SAAS,EAAE,YAAY;QACvB,OAAO,EAAE,YAAY;QACrB,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,MAAM,EACX,WAAW,EACX,WAAW,CACd,CAAC;QAEF,OAAO,cAAc,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE;YACrC,IAAI,MAAM,CAAC,IAAI,IAAI,eAAe,GAAG,YAAY,GAAG,cAAc,KAAK,CAAC,EAAE;gBACtE,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC;oBAC7B,SAAS,EAAE,mBAAmB;oBAC9B,eAAe;oBACf,YAAY;oBACZ,cAAc;iBACjB,CAAC,CAAC;aACN;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { default as AbortController } from \"abort-controller\";\nimport { v4 as uuid } from \"uuid\";\nimport { ITelemetryLogger, ITelemetryProperties } from \"@fluidframework/common-definitions\";\nimport { assert } from \"@fluidframework/common-utils\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { InstrumentedStorageTokenFetcher } from \"@fluidframework/odsp-driver-definitions\";\nimport { IDeltasFetchResult, IDocumentDeltaStorageService } from \"@fluidframework/driver-definitions\";\nimport {\n requestOps,\n streamObserver,\n} from \"@fluidframework/driver-utils\";\nimport { IDeltaStorageGetResponse, ISequencedDeltaOpMessage } from \"./contracts\";\nimport { EpochTracker } from \"./epochTracker\";\nimport { getWithRetryForTokenRefresh, validateMessages } from \"./odspUtils\";\n\n/**\n * Provides access to the underlying delta storage on the server for sharepoint driver.\n */\nexport class OdspDeltaStorageService {\n constructor(\n private readonly deltaFeedUrl: string,\n private readonly getStorageToken: InstrumentedStorageTokenFetcher,\n private readonly epochTracker: EpochTracker,\n private readonly logger: ITelemetryLogger,\n ) {\n }\n\n /**\n * Retrieves ops from storage\n * @param from - inclusive\n * @param to - exclusive\n * @param telemetryProps - properties to add when issuing telemetry events\n * @param scenarioName - reason for fetching ops\n * @returns ops retrieved & info if result was partial (i.e. more is available)\n */\n public async get(\n from: number,\n to: number,\n telemetryProps: ITelemetryProperties,\n scenarioName?: string,\n ): Promise<IDeltasFetchResult> {\n return getWithRetryForTokenRefresh(async (options) => {\n // Note - this call ends up in getSocketStorageDiscovery() and can refresh token\n // Thus it needs to be done before we call getStorageToken() to reduce extra calls\n const baseUrl = this.buildUrl(from, to);\n const storageToken = await this.getStorageToken(options, \"DeltaStorage\");\n\n const formBoundary = uuid();\n let postBody = `--${formBoundary}\\r\\n`;\n postBody += `Authorization: Bearer ${storageToken}\\r\\n`;\n postBody += `X-HTTP-Method-Override: GET\\r\\n`;\n\n postBody += `_post: 1\\r\\n`;\n postBody += `\\r\\n--${formBoundary}--`;\n const headers: { [index: string]: any; } = {\n \"Content-Type\": `multipart/form-data;boundary=${formBoundary}`,\n };\n\n // Some request take a long time (1-2 minutes) to complete, where telemetry shows very small amount\n // of time spent on server, and usually small payload sizes. I.e. all the time is spent somewhere in\n // networking. Even bigger problem - a lot of requests timeout (based on cursory look - after 1-2 minutes)\n // So adding some timeout to ensure we retry again in hope of faster success.\n // Please see https://github.com/microsoft/FluidFramework/issues/6997 for details.\n const abort = new AbortController();\n const timer = setTimeout(() => abort.abort(), 30000);\n\n const response = await this.epochTracker.fetchAndParseAsJSON<IDeltaStorageGetResponse>(\n baseUrl,\n {\n headers,\n body: postBody,\n method: \"POST\",\n signal: abort.signal,\n },\n \"ops\",\n true,\n scenarioName,\n );\n clearTimeout(timer);\n const deltaStorageResponse = response.content;\n const messages = deltaStorageResponse.value.length > 0 && \"op\" in deltaStorageResponse.value[0]\n ? (deltaStorageResponse.value as ISequencedDeltaOpMessage[]).map((operation) => operation.op)\n : deltaStorageResponse.value as ISequencedDocumentMessage[];\n\n this.logger.sendPerformanceEvent({\n eventName: \"OpsFetch\",\n headers: Object.keys(headers).length !== 0 ? true : undefined,\n length: messages.length,\n duration: response.duration, // this duration for single attempt!\n ...response.propsToLog,\n attempts: options.refresh ? 2 : 1,\n from,\n to,\n ...telemetryProps,\n reason: scenarioName,\n });\n\n // It is assumed that server always returns all the ops that it has in the range that was requested.\n // This may change in the future, if so, we need to adjust and receive \"end\" value from server in such case.\n return { messages, partialResult: false };\n });\n }\n\n public buildUrl(from: number, to: number) {\n const filter = encodeURIComponent(`sequenceNumber ge ${from} and sequenceNumber le ${to - 1}`);\n const queryString = `?ump=1&filter=${filter}`;\n return `${this.deltaFeedUrl}${queryString}`;\n }\n}\n\nexport class OdspDeltaStorageWithCache implements IDocumentDeltaStorageService {\n private firstCacheMiss = Number.MAX_SAFE_INTEGER;\n\n public constructor(\n private snapshotOps: ISequencedDocumentMessage[] | undefined,\n private readonly logger: ITelemetryLogger,\n private readonly batchSize: number,\n private readonly concurrency: number,\n private readonly getFromStorage: (\n from: number,\n to: number,\n telemetryProps: ITelemetryProperties,\n fetchReason?: string) => Promise<IDeltasFetchResult>,\n private readonly getCached: (from: number, to: number) => Promise<ISequencedDocumentMessage[]>,\n private readonly requestFromSocket: (from: number, to: number) => void,\n private readonly opsReceived: (ops: ISequencedDocumentMessage[]) => void,\n ) {\n }\n\n public fetchMessages(\n fromTotal: number,\n toTotal: number | undefined,\n abortSignal?: AbortSignal,\n cachedOnly?: boolean,\n fetchReason?: string) {\n // We do not control what's in the cache. Current API assumes that fetchMessages() keeps banging on\n // storage / cache until it gets ops it needs. This would result in deadlock if fixed range is asked from\n // cache and it's not there.\n // Better implementation would be to return only what we have in cache, but that also breaks API\n assert(!cachedOnly || toTotal === undefined, 0x1e3);\n\n let opsFromSnapshot = 0;\n let opsFromCache = 0;\n let opsFromStorage = 0;\n\n const requestCallback = async (from: number, to: number, telemetryProps: ITelemetryProperties) => {\n if (this.snapshotOps !== undefined && this.snapshotOps.length !== 0) {\n const messages = this.snapshotOps.filter((op) =>\n op.sequenceNumber >= from && op.sequenceNumber < to);\n validateMessages(\"cached\", messages, from, this.logger);\n if (messages.length > 0 && messages[0].sequenceNumber === from) {\n this.snapshotOps = this.snapshotOps.filter((op) => op.sequenceNumber >= to);\n opsFromSnapshot = messages.length;\n return { messages, partialResult: true };\n }\n this.snapshotOps = undefined;\n }\n\n // Kick out request to PUSH for ops if it has them\n this.requestFromSocket(from, to);\n\n // Cache in normal flow is continuous. Once there is a miss, stop consulting cache.\n // This saves a bit of processing time\n if (from < this.firstCacheMiss) {\n const messagesFromCache = await this.getCached(from, to);\n validateMessages(\"cached\", messagesFromCache, from, this.logger);\n if (messagesFromCache.length !== 0) {\n opsFromCache += messagesFromCache.length;\n return {\n messages: messagesFromCache,\n partialResult: true,\n };\n }\n this.firstCacheMiss = Math.min(this.firstCacheMiss, from);\n }\n\n if (cachedOnly) {\n return { messages: [], partialResult: false };\n }\n\n const ops = await this.getFromStorage(from, to, telemetryProps, fetchReason);\n validateMessages(\"storage\", ops.messages, from, this.logger);\n opsFromStorage += ops.messages.length;\n this.opsReceived(ops.messages);\n return ops;\n };\n\n const stream = requestOps(\n async (from: number, to: number, telemetryProps: ITelemetryProperties) => {\n const result = await requestCallback(from, to, telemetryProps);\n // Catch all case, just in case\n validateMessages(\"catch all\", result.messages, from, this.logger);\n return result;\n },\n // Staging: starting with no concurrency, listening for feedback first.\n // In future releases we will switch to actual concurrency\n this.concurrency,\n fromTotal, // inclusive\n toTotal, // exclusive\n this.batchSize,\n this.logger,\n abortSignal,\n fetchReason,\n );\n\n return streamObserver(stream, (result) => {\n if (result.done && opsFromSnapshot + opsFromCache + opsFromStorage !== 0) {\n this.logger.sendPerformanceEvent({\n eventName: \"CacheOpsRetrieved\",\n opsFromSnapshot,\n opsFromCache,\n opsFromStorage,\n });\n }\n });\n }\n}\n"]}
@@ -154,8 +154,8 @@ export class OdspDocumentDeltaConnection extends DocumentDeltaConnection {
154
154
  this.getOpsMap = new Map();
155
155
  this.disconnectHandler = (error, clientId) => {
156
156
  if (clientId === undefined || clientId === this.clientId) {
157
+ this.logger.sendTelemetryEvent({ eventName: "ServerDisconnect", clientId: this.hasDetails ? this.clientId : undefined }, error);
157
158
  this.disconnect(error);
158
- this.logger.sendTelemetryEvent({ eventName: "ServerDisconnect", clientId: this.clientId }, error);
159
159
  }
160
160
  };
161
161
  this.socketReference = socketReference;