@fluidframework/odsp-driver 2.41.0-338401 → 2.42.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.
- package/CHANGELOG.md +8 -0
- package/api-report/odsp-driver.legacy.alpha.api.md +1 -4
- package/dist/createFile/createFile.js +1 -1
- package/dist/createFile/createFile.js.map +1 -1
- package/dist/createOdspCreateContainerRequest.d.ts +2 -17
- package/dist/createOdspCreateContainerRequest.d.ts.map +1 -1
- package/dist/createOdspCreateContainerRequest.js +1 -1
- package/dist/createOdspCreateContainerRequest.js.map +1 -1
- package/dist/fetchSnapshot.d.ts.map +1 -1
- package/dist/fetchSnapshot.js +17 -23
- package/dist/fetchSnapshot.js.map +1 -1
- package/dist/odspDelayLoadedDeltaStream.d.ts +2 -0
- package/dist/odspDelayLoadedDeltaStream.d.ts.map +1 -1
- package/dist/odspDelayLoadedDeltaStream.js +18 -3
- package/dist/odspDelayLoadedDeltaStream.js.map +1 -1
- package/dist/odspDocumentDeltaConnection.d.ts +2 -1
- package/dist/odspDocumentDeltaConnection.d.ts.map +1 -1
- package/dist/odspDocumentDeltaConnection.js +2 -2
- package/dist/odspDocumentDeltaConnection.js.map +1 -1
- package/dist/odspDocumentStorageManager.d.ts.map +1 -1
- package/dist/odspDocumentStorageManager.js +4 -0
- package/dist/odspDocumentStorageManager.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/lib/createFile/createFile.js +1 -1
- package/lib/createFile/createFile.js.map +1 -1
- package/lib/createOdspCreateContainerRequest.d.ts +2 -17
- package/lib/createOdspCreateContainerRequest.d.ts.map +1 -1
- package/lib/createOdspCreateContainerRequest.js +1 -1
- package/lib/createOdspCreateContainerRequest.js.map +1 -1
- package/lib/fetchSnapshot.d.ts.map +1 -1
- package/lib/fetchSnapshot.js +18 -24
- package/lib/fetchSnapshot.js.map +1 -1
- package/lib/odspDelayLoadedDeltaStream.d.ts +2 -0
- package/lib/odspDelayLoadedDeltaStream.d.ts.map +1 -1
- package/lib/odspDelayLoadedDeltaStream.js +18 -3
- package/lib/odspDelayLoadedDeltaStream.js.map +1 -1
- package/lib/odspDocumentDeltaConnection.d.ts +2 -1
- package/lib/odspDocumentDeltaConnection.d.ts.map +1 -1
- package/lib/odspDocumentDeltaConnection.js +2 -2
- package/lib/odspDocumentDeltaConnection.js.map +1 -1
- package/lib/odspDocumentStorageManager.d.ts.map +1 -1
- package/lib/odspDocumentStorageManager.js +4 -0
- package/lib/odspDocumentStorageManager.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/package.json +13 -13
- package/src/createFile/createFile.ts +1 -1
- package/src/createOdspCreateContainerRequest.ts +1 -45
- package/src/fetchSnapshot.ts +16 -28
- package/src/odspDelayLoadedDeltaStream.ts +20 -0
- package/src/odspDocumentDeltaConnection.ts +2 -1
- package/src/odspDocumentStorageManager.ts +4 -0
- package/src/packageVersion.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -11,10 +11,7 @@ export function checkUrl(documentUrl: URL): DriverPreCheckInfo | undefined;
|
|
|
11
11
|
export function createLocalOdspDocumentServiceFactory(localSnapshot: Uint8Array | string): IDocumentServiceFactory;
|
|
12
12
|
|
|
13
13
|
// @alpha @legacy
|
|
14
|
-
export function createOdspCreateContainerRequest(siteUrl: string, driveId: string, filePath: string, fileName: string, createShareLinkType?: ISharingLinkKind): IRequest;
|
|
15
|
-
|
|
16
|
-
// @alpha @deprecated @legacy
|
|
17
|
-
export function createOdspCreateContainerRequest(siteUrl: string, driveId: string, filePath: string, fileName: string, createShareLinkType: ISharingLinkKind | undefined, containerPackageInfo: IContainerPackageInfo | undefined): IRequest;
|
|
14
|
+
export function createOdspCreateContainerRequest(siteUrl: string, driveId: string, filePath: string, fileName: string, createShareLinkType?: ISharingLinkKind, containerPackageInfo?: IContainerPackageInfo | undefined): IRequest;
|
|
18
15
|
|
|
19
16
|
// @alpha @legacy
|
|
20
17
|
export function createOdspUrl(l: OdspFluidDataStoreLocator): string;
|
|
@@ -126,7 +126,7 @@ function encodeFilePath(path) {
|
|
|
126
126
|
async function createNewEmptyFluidFile(getAuthHeader, newFileInfo, logger, epochTracker) {
|
|
127
127
|
const filePath = encodeFilePath(newFileInfo.filePath);
|
|
128
128
|
const encodedFilename = encodeURIComponent(`${newFileInfo.filename}.tmp`);
|
|
129
|
-
const initialUrl = `${(0, odspUrlHelper_js_1.getApiRoot)(new URL(newFileInfo.siteUrl))}/drives/${newFileInfo.driveId}/items/root
|
|
129
|
+
const initialUrl = `${(0, odspUrlHelper_js_1.getApiRoot)(new URL(newFileInfo.siteUrl))}/drives/${newFileInfo.driveId}/items/root:${filePath}/${encodedFilename}:/content?@name.conflictBehavior=rename&select=id,name,parentReference`;
|
|
130
130
|
return (0, odspUtils_js_1.getWithRetryForTokenRefresh)(async (options) => {
|
|
131
131
|
const url = initialUrl;
|
|
132
132
|
const method = "PUT";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createFile.js","sourceRoot":"","sources":["../../src/createFile/createFile.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAG7D,oEAA0E;AAC1E,+EAO0D;AAC1D,uEAIkD;AAGlD,gEAAgE;AAChE,4DAAsD;AAEtD,kFAAsE;AACtE,4EAAsE;AACtE,4DAAgF;AAChF,oDAO2B;AAC3B,8DAAqE;AACrE,sDAAkD;AAClD,2DAI6B;AAE7B,MAAM,iBAAiB,GAAG,CAAC,QAAgB,EAAW,EAAE;IACvD,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;IAC3C,OAAO,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACzC,CAAC,CAAC;AAEF;;;GAGG;AACI,KAAK,UAAU,kBAAkB,C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,8EAA8E;IAC9E,iGAAiG;IACjG,MAAM,oBAAoB,GAAG,IAAA,0CAA2B,EAAC,WAAW,CAAC,cAAc,CAAC,CAAC;IACrF,MAAM,UAAU,GAAG,GAAG,OAAO,gCAC5B,oBAAoB,CAAC,CAAC,CAAC,IAAI,oBAAoB,EAAE,CAAC,CAAC,CAAC,EACrD,EAAE,CAAC;IAEH,OAAO,IAAA,+CAA2B,EAAsB;QACvD,iBAAiB;QACjB,aAAa;QACb,MAAM;QACN,UAAU;QACV,sCAAsC;QACtC,YAAY;QACZ,aAAa,EAAE,eAAe;QAC9B,SAAS,EAAE,YAAY;QACvB,wBAAwB,EAAE,CAAC,OAAO,EAAE,EAAE;YACrC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;gBACtB,MAAM,IAAI,4BAAiB,CAC1B,0CAA0C,EAC1C,yBAAc,CAAC,uBAAuB,EACtC,EAAE,aAAa,EAAb,8BAAa,EAAE,CACjB,CAAC;YACH,CAAC;QACF,CAAC;KACD,CAAC,CAAC;AACJ,CAAC;AA1CD,sEA0CC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport { ISnapshot } from \"@fluidframework/driver-definitions/internal\";\nimport { NonRetryableError } from \"@fluidframework/driver-utils/internal\";\nimport {\n\tIFileEntry,\n\tIOdspResolvedUrl,\n\tInstrumentedStorageTokenFetcher,\n\tOdspErrorTypes,\n\tShareLinkInfoType,\n\ttype IOdspUrlParts,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tloggerToMonitoringContext,\n\tPerformanceEvent,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { ICreateFileResponse, type IRenameFileResponse } from \"./../contracts.js\";\nimport { ClpCompliantAppHeader } from \"./../contractsPublic.js\";\nimport { createOdspUrl } from \"./../createOdspUrl.js\";\nimport { EpochTracker } from \"./../epochTracker.js\";\nimport { getHeadersWithAuth } from \"./../getUrlAndHeadersWithAuth.js\";\nimport { OdspDriverUrlResolver } from \"./../odspDriverUrlResolver.js\";\nimport { checkForKnownServerFarmType, getApiRoot } from \"./../odspUrlHelper.js\";\nimport {\n\tINewFileInfo,\n\tappendNavParam,\n\tbuildOdspShareLinkReqParams,\n\tcreateCacheSnapshotKey,\n\tgetWithRetryForTokenRefresh,\n\tsnapshotWithLoadingGroupIdSupported,\n} from \"./../odspUtils.js\";\nimport { pkgVersion as driverVersion } from \"./../packageVersion.js\";\nimport { runWithRetry } from \"./../retryUtils.js\";\nimport {\n\tconvertCreateNewSummaryTreeToTreeAndBlobs,\n\tconvertSummaryIntoContainerSnapshot,\n\tcreateNewFluidContainerCore,\n} from \"./createNewUtils.js\";\n\nconst isInvalidFileName = (fileName: string): boolean => {\n\tconst invalidCharsRegex = /[\"*/:<>?\\\\|]+/g;\n\treturn invalidCharsRegex.test(fileName);\n};\n\n/**\n * Creates a new Fluid file.\n * Returns resolved url\n */\nexport async function createNewFluidFile(\n\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\tnewFileInfo: INewFileInfo,\n\tlogger: ITelemetryLoggerExt,\n\tcreateNewSummary: ISummaryTree | undefined,\n\tepochTracker: EpochTracker,\n\tfileEntry: IFileEntry,\n\tcreateNewCaching: boolean,\n\tforceAccessTokenViaAuthorizationHeader: boolean,\n\tisClpCompliantApp?: boolean,\n\tenableSingleRequestForShareLinkWithCreate?: boolean,\n\tresolvedUrl?: IOdspResolvedUrl,\n): Promise<IOdspResolvedUrl> {\n\t// Check for valid filename before the request to create file is actually made.\n\tif (isInvalidFileName(newFileInfo.filename)) {\n\t\tthrow new NonRetryableError(\n\t\t\t// pre-0.58 error message: Invalid filename\n\t\t\t\"Invalid filename for createNew\",\n\t\t\tOdspErrorTypes.invalidFileNameError,\n\t\t\t{ driverVersion },\n\t\t);\n\t}\n\n\tlet itemId: string;\n\tlet pendingRename: string | undefined;\n\tlet summaryHandle: string = \"\";\n\tlet shareLinkInfo: ShareLinkInfoType | undefined;\n\tif (createNewSummary === undefined) {\n\t\tconst content = await createNewEmptyFluidFile(\n\t\t\tgetAuthHeader,\n\t\t\tnewFileInfo,\n\t\t\tlogger,\n\t\t\tepochTracker,\n\t\t);\n\t\titemId = content.itemId;\n\t\tpendingRename = newFileInfo.filename;\n\t} else {\n\t\tconst content = await createNewFluidFileFromSummary(\n\t\t\tgetAuthHeader,\n\t\t\tnewFileInfo,\n\t\t\tlogger,\n\t\t\tcreateNewSummary,\n\t\t\tepochTracker,\n\t\t\tforceAccessTokenViaAuthorizationHeader,\n\t\t);\n\t\titemId = content.itemId;\n\t\tsummaryHandle = content.id;\n\n\t\tshareLinkInfo = extractShareLinkData(content, enableSingleRequestForShareLinkWithCreate);\n\t}\n\n\tconst odspUrl = createOdspUrl({ ...newFileInfo, itemId, dataStorePath: \"/\" });\n\tconst resolver = new OdspDriverUrlResolver();\n\tconst odspResolvedUrl = await resolver.resolve({\n\t\turl: odspUrl,\n\t\theaders: { [ClpCompliantAppHeader.isClpCompliantApp]: isClpCompliantApp },\n\t});\n\tfileEntry.docId = odspResolvedUrl.hashedDocumentId;\n\tfileEntry.resolvedUrl = odspResolvedUrl;\n\n\todspResolvedUrl.context = resolvedUrl?.context;\n\todspResolvedUrl.appName = resolvedUrl?.appName;\n\todspResolvedUrl.codeHint = odspResolvedUrl.codeHint?.containerPackageName\n\t\t? odspResolvedUrl.codeHint\n\t\t: resolvedUrl?.codeHint;\n\n\tif (shareLinkInfo?.createLink?.link) {\n\t\tlet newWebUrl = shareLinkInfo.createLink.link.webUrl;\n\t\tnewWebUrl = appendNavParam(\n\t\t\tnewWebUrl,\n\t\t\todspResolvedUrl,\n\t\t\todspResolvedUrl.dataStorePath ?? \"/\",\n\t\t\todspResolvedUrl.codeHint?.containerPackageName,\n\t\t);\n\t\tshareLinkInfo.createLink.link.webUrl = newWebUrl;\n\t}\n\n\todspResolvedUrl.shareLinkInfo = shareLinkInfo;\n\todspResolvedUrl.pendingRename = pendingRename;\n\n\tif (createNewSummary !== undefined && createNewCaching) {\n\t\tassert(summaryHandle !== undefined, 0x203 /* \"Summary handle is undefined\" */);\n\t\t// converting summary and getting sequence number\n\t\tconst snapshot: ISnapshot = convertCreateNewSummaryTreeToTreeAndBlobs(\n\t\t\tcreateNewSummary,\n\t\t\tsummaryHandle,\n\t\t);\n\t\t// caching the converted summary\n\t\tawait epochTracker.put(\n\t\t\tcreateCacheSnapshotKey(\n\t\t\t\todspResolvedUrl,\n\t\t\t\tsnapshotWithLoadingGroupIdSupported(loggerToMonitoringContext(logger).config),\n\t\t\t),\n\t\t\tsnapshot,\n\t\t);\n\t}\n\treturn odspResolvedUrl;\n}\n\n/**\n * If user requested creation of a sharing link along with the creation of the file by providing\n * createLinkScope in the request parameters then extract and save the sharing link information from\n * the response if it is available.\n * In case there was an error in creation of the sharing link, error is provided back in the response,\n * and does not impact the creation of file in ODSP.\n * @param requestedSharingLinkKind - Kind of sharing link requested to be created along with the creation of file.\n * @param response - Response object received from the /snapshot api call\n * @returns Sharing link information received in the response from a successful creation of a file.\n */\nfunction extractShareLinkData(\n\tresponse: ICreateFileResponse,\n\tenableSingleRequestForShareLinkWithCreate?: boolean,\n): ShareLinkInfoType | undefined {\n\tlet shareLinkInfo: ShareLinkInfoType | undefined;\n\tif (enableSingleRequestForShareLinkWithCreate) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\tconst { sharing } = response;\n\t\tif (!sharing) {\n\t\t\treturn;\n\t\t}\n\t\t/* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access */\n\t\tshareLinkInfo = {\n\t\t\tcreateLink: {\n\t\t\t\tlink: sharing.sharingLink\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tscope: sharing.sharingLink.scope,\n\t\t\t\t\t\t\trole: sharing.sharingLink.type,\n\t\t\t\t\t\t\twebUrl: sharing.sharingLink.webUrl,\n\t\t\t\t\t\t\t...sharing.sharingLink,\n\t\t\t\t\t\t}\n\t\t\t\t\t: undefined,\n\t\t\t\terror: sharing.error,\n\t\t\t\tshareId: sharing.shareId,\n\t\t\t},\n\t\t};\n\t\t/* eslint-enable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access */\n\t}\n\treturn shareLinkInfo;\n}\n\n/**\n * Encodes file path so it can be embedded in the request url\n * @param path - path to encode\n * @returns encoded path or \"\" if path is undefined\n */\nfunction encodeFilePath(path: string | undefined): string {\n\treturn path ? encodeURIComponent(path.startsWith(\"/\") ? path : `/${path}`) : \"\";\n}\n\nexport async function createNewEmptyFluidFile(\n\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\tnewFileInfo: INewFileInfo,\n\tlogger: ITelemetryLoggerExt,\n\tepochTracker: EpochTracker,\n): Promise<{ itemId: string; fileName: string }> {\n\tconst filePath = encodeFilePath(newFileInfo.filePath);\n\tconst encodedFilename = encodeURIComponent(`${newFileInfo.filename}.tmp`);\n\tconst initialUrl = `${getApiRoot(new URL(newFileInfo.siteUrl))}/drives/${\n\t\tnewFileInfo.driveId\n\t}/items/root:/${filePath}/${encodedFilename}:/content?@name.conflictBehavior=rename&select=id,name,parentReference`;\n\n\treturn getWithRetryForTokenRefresh(async (options) => {\n\t\tconst url = initialUrl;\n\t\tconst method = \"PUT\";\n\t\tconst authHeader = await getAuthHeader(\n\t\t\t{ ...options, request: { url, method } },\n\t\t\t\"CreateNewFile\",\n\t\t);\n\t\tconst internalFarmType = checkForKnownServerFarmType(newFileInfo.siteUrl);\n\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{\n\t\t\t\teventName: \"createNewEmptyFile\",\n\t\t\t\tdetails: {\n\t\t\t\t\tinternalFarmType,\n\t\t\t\t},\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst headers = getHeadersWithAuth(authHeader);\n\t\t\t\theaders[\"Content-Type\"] = \"application/json\";\n\n\t\t\t\tconst fetchResponse = await runWithRetry(\n\t\t\t\t\tasync () =>\n\t\t\t\t\t\tepochTracker.fetchAndParseAsJSON<ICreateFileResponse>(\n\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tbody: undefined,\n\t\t\t\t\t\t\t\theaders,\n\t\t\t\t\t\t\t\tmethod,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\"createFile\",\n\t\t\t\t\t\t),\n\t\t\t\t\t\"createFile\",\n\t\t\t\t\tlogger,\n\t\t\t\t);\n\n\t\t\t\tconst content = fetchResponse.content;\n\t\t\t\tif (!content?.id) {\n\t\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\t// pre-0.58 error message: ODSP CreateFile call returned no item ID\n\t\t\t\t\t\t\"ODSP CreateFile call returned no item ID (for empty file)\",\n\t\t\t\t\t\tOdspErrorTypes.incorrectServerResponse,\n\t\t\t\t\t\t{ driverVersion },\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tevent.end({\n\t\t\t\t\t...fetchResponse.propsToLog,\n\t\t\t\t});\n\t\t\t\treturn { itemId: content.id, fileName: content.name };\n\t\t\t},\n\t\t\t{ end: true, cancel: \"error\" },\n\t\t);\n\t});\n}\n\nexport async function renameEmptyFluidFile(\n\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\todspParts: IOdspUrlParts,\n\trequestedFileName: string,\n\tlogger: ITelemetryLoggerExt,\n\tepochTracker: EpochTracker,\n): Promise<IRenameFileResponse> {\n\tconst initialUrl = `${getApiRoot(new URL(odspParts.siteUrl))}/drives/${\n\t\todspParts.driveId\n\t}/items/${odspParts.itemId}?@name.conflictBehavior=rename`;\n\n\treturn getWithRetryForTokenRefresh(async (options) => {\n\t\tconst url = initialUrl;\n\t\tconst method = \"PATCH\";\n\t\tconst authHeader = await getAuthHeader(\n\t\t\t{ ...options, request: { url, method } },\n\t\t\t\"renameFile\",\n\t\t);\n\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{ eventName: \"renameFile\" },\n\t\t\tasync (event) => {\n\t\t\t\tconst headers = getHeadersWithAuth(authHeader);\n\t\t\t\theaders[\"Content-Type\"] = \"application/json\";\n\n\t\t\t\tconst fetchResponse = await runWithRetry(\n\t\t\t\t\tasync () =>\n\t\t\t\t\t\tepochTracker.fetchAndParseAsJSON<IRenameFileResponse>(\n\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tbody: JSON.stringify({\n\t\t\t\t\t\t\t\t\tname: requestedFileName,\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\theaders,\n\t\t\t\t\t\t\t\tmethod: \"PATCH\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\"renameFile\",\n\t\t\t\t\t\t),\n\t\t\t\t\t\"renameFile\",\n\t\t\t\t\tlogger,\n\t\t\t\t);\n\n\t\t\t\tconst content = fetchResponse.content;\n\t\t\t\tif (!content?.id) {\n\t\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\t\"ODSP RenameFile call returned no item ID (for empty file)\",\n\t\t\t\t\t\tOdspErrorTypes.incorrectServerResponse,\n\t\t\t\t\t\t{ driverVersion },\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tevent.end({\n\t\t\t\t\t...fetchResponse.propsToLog,\n\t\t\t\t});\n\t\t\t\treturn content;\n\t\t\t},\n\t\t\t{ end: true, cancel: \"error\" },\n\t\t);\n\t});\n}\n\nexport async function createNewFluidFileFromSummary(\n\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\tnewFileInfo: INewFileInfo,\n\tlogger: ITelemetryLoggerExt,\n\tcreateNewSummary: ISummaryTree,\n\tepochTracker: EpochTracker,\n\tforceAccessTokenViaAuthorizationHeader: boolean,\n): Promise<ICreateFileResponse> {\n\tconst filePath = encodeFilePath(newFileInfo.filePath);\n\tconst encodedFilename = encodeURIComponent(newFileInfo.filename);\n\tconst baseUrl =\n\t\t`${getApiRoot(new URL(newFileInfo.siteUrl))}/drives/${newFileInfo.driveId}/items/root:` +\n\t\t`${filePath}/${encodedFilename}`;\n\n\tconst containerSnapshot = convertSummaryIntoContainerSnapshot(createNewSummary);\n\n\t// Build share link parameter based on the createLinkType provided so that the\n\t// snapshot api can create and return the share link along with creation of file in the response.\n\tconst createShareLinkParam = buildOdspShareLinkReqParams(newFileInfo.createLinkType);\n\tconst initialUrl = `${baseUrl}:/opStream/snapshots/snapshot${\n\t\tcreateShareLinkParam ? `?${createShareLinkParam}` : \"\"\n\t}`;\n\n\treturn createNewFluidContainerCore<ICreateFileResponse>({\n\t\tcontainerSnapshot,\n\t\tgetAuthHeader,\n\t\tlogger,\n\t\tinitialUrl,\n\t\tforceAccessTokenViaAuthorizationHeader,\n\t\tepochTracker,\n\t\ttelemetryName: \"CreateNewFile\",\n\t\tfetchType: \"createFile\",\n\t\tvalidateResponseCallback: (content) => {\n\t\t\tif (!content?.itemId) {\n\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\"ODSP CreateFile call returned no item ID\",\n\t\t\t\t\tOdspErrorTypes.incorrectServerResponse,\n\t\t\t\t\t{ driverVersion },\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t});\n}\n"]}
|
|
1
|
+
{"version":3,"file":"createFile.js","sourceRoot":"","sources":["../../src/createFile/createFile.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAG7D,oEAA0E;AAC1E,+EAO0D;AAC1D,uEAIkD;AAGlD,gEAAgE;AAChE,4DAAsD;AAEtD,kFAAsE;AACtE,4EAAsE;AACtE,4DAAgF;AAChF,oDAO2B;AAC3B,8DAAqE;AACrE,sDAAkD;AAClD,2DAI6B;AAE7B,MAAM,iBAAiB,GAAG,CAAC,QAAgB,EAAW,EAAE;IACvD,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;IAC3C,OAAO,iBAAiB,CAAC,IA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EAAE,CAAC;IAElC,MAAM,iBAAiB,GAAG,IAAA,uDAAmC,EAAC,gBAAgB,CAAC,CAAC;IAEhF,8EAA8E;IAC9E,iGAAiG;IACjG,MAAM,oBAAoB,GAAG,IAAA,0CAA2B,EAAC,WAAW,CAAC,cAAc,CAAC,CAAC;IACrF,MAAM,UAAU,GAAG,GAAG,OAAO,gCAC5B,oBAAoB,CAAC,CAAC,CAAC,IAAI,oBAAoB,EAAE,CAAC,CAAC,CAAC,EACrD,EAAE,CAAC;IAEH,OAAO,IAAA,+CAA2B,EAAsB;QACvD,iBAAiB;QACjB,aAAa;QACb,MAAM;QACN,UAAU;QACV,sCAAsC;QACtC,YAAY;QACZ,aAAa,EAAE,eAAe;QAC9B,SAAS,EAAE,YAAY;QACvB,wBAAwB,EAAE,CAAC,OAAO,EAAE,EAAE;YACrC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;gBACtB,MAAM,IAAI,4BAAiB,CAC1B,0CAA0C,EAC1C,yBAAc,CAAC,uBAAuB,EACtC,EAAE,aAAa,EAAb,8BAAa,EAAE,CACjB,CAAC;YACH,CAAC;QACF,CAAC;KACD,CAAC,CAAC;AACJ,CAAC;AA1CD,sEA0CC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport { ISnapshot } from \"@fluidframework/driver-definitions/internal\";\nimport { NonRetryableError } from \"@fluidframework/driver-utils/internal\";\nimport {\n\tIFileEntry,\n\tIOdspResolvedUrl,\n\tInstrumentedStorageTokenFetcher,\n\tOdspErrorTypes,\n\tShareLinkInfoType,\n\ttype IOdspUrlParts,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tloggerToMonitoringContext,\n\tPerformanceEvent,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { ICreateFileResponse, type IRenameFileResponse } from \"./../contracts.js\";\nimport { ClpCompliantAppHeader } from \"./../contractsPublic.js\";\nimport { createOdspUrl } from \"./../createOdspUrl.js\";\nimport { EpochTracker } from \"./../epochTracker.js\";\nimport { getHeadersWithAuth } from \"./../getUrlAndHeadersWithAuth.js\";\nimport { OdspDriverUrlResolver } from \"./../odspDriverUrlResolver.js\";\nimport { checkForKnownServerFarmType, getApiRoot } from \"./../odspUrlHelper.js\";\nimport {\n\tINewFileInfo,\n\tappendNavParam,\n\tbuildOdspShareLinkReqParams,\n\tcreateCacheSnapshotKey,\n\tgetWithRetryForTokenRefresh,\n\tsnapshotWithLoadingGroupIdSupported,\n} from \"./../odspUtils.js\";\nimport { pkgVersion as driverVersion } from \"./../packageVersion.js\";\nimport { runWithRetry } from \"./../retryUtils.js\";\nimport {\n\tconvertCreateNewSummaryTreeToTreeAndBlobs,\n\tconvertSummaryIntoContainerSnapshot,\n\tcreateNewFluidContainerCore,\n} from \"./createNewUtils.js\";\n\nconst isInvalidFileName = (fileName: string): boolean => {\n\tconst invalidCharsRegex = /[\"*/:<>?\\\\|]+/g;\n\treturn invalidCharsRegex.test(fileName);\n};\n\n/**\n * Creates a new Fluid file.\n * Returns resolved url\n */\nexport async function createNewFluidFile(\n\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\tnewFileInfo: INewFileInfo,\n\tlogger: ITelemetryLoggerExt,\n\tcreateNewSummary: ISummaryTree | undefined,\n\tepochTracker: EpochTracker,\n\tfileEntry: IFileEntry,\n\tcreateNewCaching: boolean,\n\tforceAccessTokenViaAuthorizationHeader: boolean,\n\tisClpCompliantApp?: boolean,\n\tenableSingleRequestForShareLinkWithCreate?: boolean,\n\tresolvedUrl?: IOdspResolvedUrl,\n): Promise<IOdspResolvedUrl> {\n\t// Check for valid filename before the request to create file is actually made.\n\tif (isInvalidFileName(newFileInfo.filename)) {\n\t\tthrow new NonRetryableError(\n\t\t\t// pre-0.58 error message: Invalid filename\n\t\t\t\"Invalid filename for createNew\",\n\t\t\tOdspErrorTypes.invalidFileNameError,\n\t\t\t{ driverVersion },\n\t\t);\n\t}\n\n\tlet itemId: string;\n\tlet pendingRename: string | undefined;\n\tlet summaryHandle: string = \"\";\n\tlet shareLinkInfo: ShareLinkInfoType | undefined;\n\tif (createNewSummary === undefined) {\n\t\tconst content = await createNewEmptyFluidFile(\n\t\t\tgetAuthHeader,\n\t\t\tnewFileInfo,\n\t\t\tlogger,\n\t\t\tepochTracker,\n\t\t);\n\t\titemId = content.itemId;\n\t\tpendingRename = newFileInfo.filename;\n\t} else {\n\t\tconst content = await createNewFluidFileFromSummary(\n\t\t\tgetAuthHeader,\n\t\t\tnewFileInfo,\n\t\t\tlogger,\n\t\t\tcreateNewSummary,\n\t\t\tepochTracker,\n\t\t\tforceAccessTokenViaAuthorizationHeader,\n\t\t);\n\t\titemId = content.itemId;\n\t\tsummaryHandle = content.id;\n\n\t\tshareLinkInfo = extractShareLinkData(content, enableSingleRequestForShareLinkWithCreate);\n\t}\n\n\tconst odspUrl = createOdspUrl({ ...newFileInfo, itemId, dataStorePath: \"/\" });\n\tconst resolver = new OdspDriverUrlResolver();\n\tconst odspResolvedUrl = await resolver.resolve({\n\t\turl: odspUrl,\n\t\theaders: { [ClpCompliantAppHeader.isClpCompliantApp]: isClpCompliantApp },\n\t});\n\tfileEntry.docId = odspResolvedUrl.hashedDocumentId;\n\tfileEntry.resolvedUrl = odspResolvedUrl;\n\n\todspResolvedUrl.context = resolvedUrl?.context;\n\todspResolvedUrl.appName = resolvedUrl?.appName;\n\todspResolvedUrl.codeHint = odspResolvedUrl.codeHint?.containerPackageName\n\t\t? odspResolvedUrl.codeHint\n\t\t: resolvedUrl?.codeHint;\n\n\tif (shareLinkInfo?.createLink?.link) {\n\t\tlet newWebUrl = shareLinkInfo.createLink.link.webUrl;\n\t\tnewWebUrl = appendNavParam(\n\t\t\tnewWebUrl,\n\t\t\todspResolvedUrl,\n\t\t\todspResolvedUrl.dataStorePath ?? \"/\",\n\t\t\todspResolvedUrl.codeHint?.containerPackageName,\n\t\t);\n\t\tshareLinkInfo.createLink.link.webUrl = newWebUrl;\n\t}\n\n\todspResolvedUrl.shareLinkInfo = shareLinkInfo;\n\todspResolvedUrl.pendingRename = pendingRename;\n\n\tif (createNewSummary !== undefined && createNewCaching) {\n\t\tassert(summaryHandle !== undefined, 0x203 /* \"Summary handle is undefined\" */);\n\t\t// converting summary and getting sequence number\n\t\tconst snapshot: ISnapshot = convertCreateNewSummaryTreeToTreeAndBlobs(\n\t\t\tcreateNewSummary,\n\t\t\tsummaryHandle,\n\t\t);\n\t\t// caching the converted summary\n\t\tawait epochTracker.put(\n\t\t\tcreateCacheSnapshotKey(\n\t\t\t\todspResolvedUrl,\n\t\t\t\tsnapshotWithLoadingGroupIdSupported(loggerToMonitoringContext(logger).config),\n\t\t\t),\n\t\t\tsnapshot,\n\t\t);\n\t}\n\treturn odspResolvedUrl;\n}\n\n/**\n * If user requested creation of a sharing link along with the creation of the file by providing\n * createLinkScope in the request parameters then extract and save the sharing link information from\n * the response if it is available.\n * In case there was an error in creation of the sharing link, error is provided back in the response,\n * and does not impact the creation of file in ODSP.\n * @param requestedSharingLinkKind - Kind of sharing link requested to be created along with the creation of file.\n * @param response - Response object received from the /snapshot api call\n * @returns Sharing link information received in the response from a successful creation of a file.\n */\nfunction extractShareLinkData(\n\tresponse: ICreateFileResponse,\n\tenableSingleRequestForShareLinkWithCreate?: boolean,\n): ShareLinkInfoType | undefined {\n\tlet shareLinkInfo: ShareLinkInfoType | undefined;\n\tif (enableSingleRequestForShareLinkWithCreate) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\tconst { sharing } = response;\n\t\tif (!sharing) {\n\t\t\treturn;\n\t\t}\n\t\t/* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access */\n\t\tshareLinkInfo = {\n\t\t\tcreateLink: {\n\t\t\t\tlink: sharing.sharingLink\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tscope: sharing.sharingLink.scope,\n\t\t\t\t\t\t\trole: sharing.sharingLink.type,\n\t\t\t\t\t\t\twebUrl: sharing.sharingLink.webUrl,\n\t\t\t\t\t\t\t...sharing.sharingLink,\n\t\t\t\t\t\t}\n\t\t\t\t\t: undefined,\n\t\t\t\terror: sharing.error,\n\t\t\t\tshareId: sharing.shareId,\n\t\t\t},\n\t\t};\n\t\t/* eslint-enable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access */\n\t}\n\treturn shareLinkInfo;\n}\n\n/**\n * Encodes file path so it can be embedded in the request url\n * @param path - path to encode\n * @returns encoded path or \"\" if path is undefined\n */\nfunction encodeFilePath(path: string | undefined): string {\n\treturn path ? encodeURIComponent(path.startsWith(\"/\") ? path : `/${path}`) : \"\";\n}\n\nexport async function createNewEmptyFluidFile(\n\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\tnewFileInfo: INewFileInfo,\n\tlogger: ITelemetryLoggerExt,\n\tepochTracker: EpochTracker,\n): Promise<{ itemId: string; fileName: string }> {\n\tconst filePath = encodeFilePath(newFileInfo.filePath);\n\tconst encodedFilename = encodeURIComponent(`${newFileInfo.filename}.tmp`);\n\tconst initialUrl = `${getApiRoot(new URL(newFileInfo.siteUrl))}/drives/${\n\t\tnewFileInfo.driveId\n\t}/items/root:${filePath}/${encodedFilename}:/content?@name.conflictBehavior=rename&select=id,name,parentReference`;\n\n\treturn getWithRetryForTokenRefresh(async (options) => {\n\t\tconst url = initialUrl;\n\t\tconst method = \"PUT\";\n\t\tconst authHeader = await getAuthHeader(\n\t\t\t{ ...options, request: { url, method } },\n\t\t\t\"CreateNewFile\",\n\t\t);\n\t\tconst internalFarmType = checkForKnownServerFarmType(newFileInfo.siteUrl);\n\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{\n\t\t\t\teventName: \"createNewEmptyFile\",\n\t\t\t\tdetails: {\n\t\t\t\t\tinternalFarmType,\n\t\t\t\t},\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst headers = getHeadersWithAuth(authHeader);\n\t\t\t\theaders[\"Content-Type\"] = \"application/json\";\n\n\t\t\t\tconst fetchResponse = await runWithRetry(\n\t\t\t\t\tasync () =>\n\t\t\t\t\t\tepochTracker.fetchAndParseAsJSON<ICreateFileResponse>(\n\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tbody: undefined,\n\t\t\t\t\t\t\t\theaders,\n\t\t\t\t\t\t\t\tmethod,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\"createFile\",\n\t\t\t\t\t\t),\n\t\t\t\t\t\"createFile\",\n\t\t\t\t\tlogger,\n\t\t\t\t);\n\n\t\t\t\tconst content = fetchResponse.content;\n\t\t\t\tif (!content?.id) {\n\t\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\t// pre-0.58 error message: ODSP CreateFile call returned no item ID\n\t\t\t\t\t\t\"ODSP CreateFile call returned no item ID (for empty file)\",\n\t\t\t\t\t\tOdspErrorTypes.incorrectServerResponse,\n\t\t\t\t\t\t{ driverVersion },\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tevent.end({\n\t\t\t\t\t...fetchResponse.propsToLog,\n\t\t\t\t});\n\t\t\t\treturn { itemId: content.id, fileName: content.name };\n\t\t\t},\n\t\t\t{ end: true, cancel: \"error\" },\n\t\t);\n\t});\n}\n\nexport async function renameEmptyFluidFile(\n\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\todspParts: IOdspUrlParts,\n\trequestedFileName: string,\n\tlogger: ITelemetryLoggerExt,\n\tepochTracker: EpochTracker,\n): Promise<IRenameFileResponse> {\n\tconst initialUrl = `${getApiRoot(new URL(odspParts.siteUrl))}/drives/${\n\t\todspParts.driveId\n\t}/items/${odspParts.itemId}?@name.conflictBehavior=rename`;\n\n\treturn getWithRetryForTokenRefresh(async (options) => {\n\t\tconst url = initialUrl;\n\t\tconst method = \"PATCH\";\n\t\tconst authHeader = await getAuthHeader(\n\t\t\t{ ...options, request: { url, method } },\n\t\t\t\"renameFile\",\n\t\t);\n\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{ eventName: \"renameFile\" },\n\t\t\tasync (event) => {\n\t\t\t\tconst headers = getHeadersWithAuth(authHeader);\n\t\t\t\theaders[\"Content-Type\"] = \"application/json\";\n\n\t\t\t\tconst fetchResponse = await runWithRetry(\n\t\t\t\t\tasync () =>\n\t\t\t\t\t\tepochTracker.fetchAndParseAsJSON<IRenameFileResponse>(\n\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tbody: JSON.stringify({\n\t\t\t\t\t\t\t\t\tname: requestedFileName,\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\theaders,\n\t\t\t\t\t\t\t\tmethod: \"PATCH\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\"renameFile\",\n\t\t\t\t\t\t),\n\t\t\t\t\t\"renameFile\",\n\t\t\t\t\tlogger,\n\t\t\t\t);\n\n\t\t\t\tconst content = fetchResponse.content;\n\t\t\t\tif (!content?.id) {\n\t\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\t\"ODSP RenameFile call returned no item ID (for empty file)\",\n\t\t\t\t\t\tOdspErrorTypes.incorrectServerResponse,\n\t\t\t\t\t\t{ driverVersion },\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tevent.end({\n\t\t\t\t\t...fetchResponse.propsToLog,\n\t\t\t\t});\n\t\t\t\treturn content;\n\t\t\t},\n\t\t\t{ end: true, cancel: \"error\" },\n\t\t);\n\t});\n}\n\nexport async function createNewFluidFileFromSummary(\n\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\tnewFileInfo: INewFileInfo,\n\tlogger: ITelemetryLoggerExt,\n\tcreateNewSummary: ISummaryTree,\n\tepochTracker: EpochTracker,\n\tforceAccessTokenViaAuthorizationHeader: boolean,\n): Promise<ICreateFileResponse> {\n\tconst filePath = encodeFilePath(newFileInfo.filePath);\n\tconst encodedFilename = encodeURIComponent(newFileInfo.filename);\n\tconst baseUrl =\n\t\t`${getApiRoot(new URL(newFileInfo.siteUrl))}/drives/${newFileInfo.driveId}/items/root:` +\n\t\t`${filePath}/${encodedFilename}`;\n\n\tconst containerSnapshot = convertSummaryIntoContainerSnapshot(createNewSummary);\n\n\t// Build share link parameter based on the createLinkType provided so that the\n\t// snapshot api can create and return the share link along with creation of file in the response.\n\tconst createShareLinkParam = buildOdspShareLinkReqParams(newFileInfo.createLinkType);\n\tconst initialUrl = `${baseUrl}:/opStream/snapshots/snapshot${\n\t\tcreateShareLinkParam ? `?${createShareLinkParam}` : \"\"\n\t}`;\n\n\treturn createNewFluidContainerCore<ICreateFileResponse>({\n\t\tcontainerSnapshot,\n\t\tgetAuthHeader,\n\t\tlogger,\n\t\tinitialUrl,\n\t\tforceAccessTokenViaAuthorizationHeader,\n\t\tepochTracker,\n\t\ttelemetryName: \"CreateNewFile\",\n\t\tfetchType: \"createFile\",\n\t\tvalidateResponseCallback: (content) => {\n\t\t\tif (!content?.itemId) {\n\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\"ODSP CreateFile call returned no item ID\",\n\t\t\t\t\tOdspErrorTypes.incorrectServerResponse,\n\t\t\t\t\t{ driverVersion },\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t});\n}\n"]}
|
|
@@ -13,25 +13,10 @@ import { ISharingLinkKind } from "@fluidframework/odsp-driver-definitions/intern
|
|
|
13
13
|
* @param fileName - name of the new file to be created
|
|
14
14
|
* @param createShareLinkType - type of sharing link you would like to create for this file. ShareLinkTypes
|
|
15
15
|
* will be deprecated soon, so for any new implementation please provide createShareLinkType of type ShareLink
|
|
16
|
-
* @
|
|
17
|
-
* @alpha
|
|
18
|
-
*/
|
|
19
|
-
export declare function createOdspCreateContainerRequest(siteUrl: string, driveId: string, filePath: string, fileName: string, createShareLinkType?: ISharingLinkKind): IRequest;
|
|
20
|
-
/**
|
|
21
|
-
* Create the request object with url and headers for creating a new file on OneDrive Sharepoint
|
|
22
|
-
* @param siteUrl - Base url for OneDrive
|
|
23
|
-
* @param driveId - drive identifier
|
|
24
|
-
* @param filePath - path where file needs to be created
|
|
25
|
-
* @param fileName - name of the new file to be created
|
|
26
|
-
* @param createShareLinkType - type of sharing link you would like to create for this file. ShareLinkTypes
|
|
27
|
-
* will be deprecated soon, so for any new implementation please provide createShareLinkType of type ShareLink
|
|
28
|
-
* @param containerPackageInfo - **Deprecated Parameter** - container package information which will be used to extract the container package name.
|
|
16
|
+
* @param containerPackageInfo - Container package information which will be used to extract the container package name.
|
|
29
17
|
* If not given that means that the container package does not have a name.
|
|
30
18
|
* @legacy
|
|
31
19
|
* @alpha
|
|
32
|
-
* @deprecated To be removed in 2.40
|
|
33
|
-
* Add containerPackageInfo to the OdspDriverUrlResolverForShareLink constructor instead; see https://github.com/microsoft/FluidFramework/issues/23882 for more details.
|
|
34
|
-
* Deprecating overloaded function to remove containerPackageInfo
|
|
35
20
|
*/
|
|
36
|
-
export declare function createOdspCreateContainerRequest(siteUrl: string, driveId: string, filePath: string, fileName: string, createShareLinkType
|
|
21
|
+
export declare function createOdspCreateContainerRequest(siteUrl: string, driveId: string, filePath: string, fileName: string, createShareLinkType?: ISharingLinkKind, containerPackageInfo?: IContainerPackageInfo | undefined): IRequest;
|
|
37
22
|
//# sourceMappingURL=createOdspCreateContainerRequest.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createOdspCreateContainerRequest.d.ts","sourceRoot":"","sources":["../src/createOdspCreateContainerRequest.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAEN,KAAK,qBAAqB,EAC1B,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kDAAkD,CAAC;AAIpF
|
|
1
|
+
{"version":3,"file":"createOdspCreateContainerRequest.d.ts","sourceRoot":"","sources":["../src/createOdspCreateContainerRequest.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAEN,KAAK,qBAAqB,EAC1B,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kDAAkD,CAAC;AAIpF;;;;;;;;;;;;GAYG;AACH,wBAAgB,gCAAgC,CAC/C,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,mBAAmB,CAAC,EAAE,gBAAgB,EACtC,oBAAoB,CAAC,EAAE,qBAAqB,GAAG,SAAS,GACtD,QAAQ,CAaV"}
|
|
@@ -15,7 +15,7 @@ const odspUtils_js_1 = require("./odspUtils.js");
|
|
|
15
15
|
* @param fileName - name of the new file to be created
|
|
16
16
|
* @param createShareLinkType - type of sharing link you would like to create for this file. ShareLinkTypes
|
|
17
17
|
* will be deprecated soon, so for any new implementation please provide createShareLinkType of type ShareLink
|
|
18
|
-
* @param containerPackageInfo -
|
|
18
|
+
* @param containerPackageInfo - Container package information which will be used to extract the container package name.
|
|
19
19
|
* If not given that means that the container package does not have a name.
|
|
20
20
|
* @legacy
|
|
21
21
|
* @alpha
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createOdspCreateContainerRequest.js","sourceRoot":"","sources":["../src/createOdspCreateContainerRequest.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,0EAGqD;AAGrD,iDAAsF;
|
|
1
|
+
{"version":3,"file":"createOdspCreateContainerRequest.js","sourceRoot":"","sources":["../src/createOdspCreateContainerRequest.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,0EAGqD;AAGrD,iDAAsF;AAEtF;;;;;;;;;;;;GAYG;AACH,SAAgB,gCAAgC,CAC/C,OAAe,EACf,OAAe,EACf,QAAgB,EAChB,QAAgB,EAChB,mBAAsC,EACtC,oBAAwD;IAExD,MAAM,sBAAsB,GAAG,IAAA,0CAA2B,EAAC,mBAAmB,CAAC,CAAC;IAChF,MAAM,gBAAgB,GAAa;QAClC,GAAG,EAAE,GAAG,OAAO,YAAY,kBAAkB,CAAC,OAAO,CAAC,SAAS,kBAAkB,CAChF,QAAQ,CACR,GAAG,oBAAoB,CAAC,CAAC,CAAC,yBAAyB,IAAA,sCAAuB,EAAC,oBAAoB,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,sBAAsB,CAAC,CAAC,CAAC,IAAI,sBAAsB,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE;QACvK,OAAO,EAAE;YACR,CAAC,uBAAY,CAAC,SAAS,CAAC,EAAE;gBACzB,QAAQ;aACR;SACD;KACD,CAAC;IACF,OAAO,gBAAgB,CAAC;AACzB,CAAC;AApBD,4EAoBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IRequest } from \"@fluidframework/core-interfaces\";\nimport {\n\tDriverHeader,\n\ttype IContainerPackageInfo,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { ISharingLinkKind } from \"@fluidframework/odsp-driver-definitions/internal\";\n\nimport { buildOdspShareLinkReqParams, getContainerPackageName } from \"./odspUtils.js\";\n\n/**\n * Create the request object with url and headers for creating a new file on OneDrive Sharepoint\n * @param siteUrl - Base url for OneDrive\n * @param driveId - drive identifier\n * @param filePath - path where file needs to be created\n * @param fileName - name of the new file to be created\n * @param createShareLinkType - type of sharing link you would like to create for this file. ShareLinkTypes\n * will be deprecated soon, so for any new implementation please provide createShareLinkType of type ShareLink\n * @param containerPackageInfo - Container package information which will be used to extract the container package name.\n * If not given that means that the container package does not have a name.\n * @legacy\n * @alpha\n */\nexport function createOdspCreateContainerRequest(\n\tsiteUrl: string,\n\tdriveId: string,\n\tfilePath: string,\n\tfileName: string,\n\tcreateShareLinkType?: ISharingLinkKind,\n\tcontainerPackageInfo?: IContainerPackageInfo | undefined,\n): IRequest {\n\tconst shareLinkRequestParams = buildOdspShareLinkReqParams(createShareLinkType);\n\tconst createNewRequest: IRequest = {\n\t\turl: `${siteUrl}?driveId=${encodeURIComponent(driveId)}&path=${encodeURIComponent(\n\t\t\tfilePath,\n\t\t)}${containerPackageInfo ? `&containerPackageName=${getContainerPackageName(containerPackageInfo)}` : \"\"}${shareLinkRequestParams ? `&${shareLinkRequestParams}` : \"\"}`,\n\t\theaders: {\n\t\t\t[DriverHeader.createNew]: {\n\t\t\t\tfileName,\n\t\t\t},\n\t\t},\n\t};\n\treturn createNewRequest;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchSnapshot.d.ts","sourceRoot":"","sources":["../src/fetchSnapshot.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,SAAS,EAAiB,MAAM,6CAA6C,CAAC;AAUvF,OAAO,EAEN,gBAAgB,EAChB,gBAAgB,EAChB,+BAA+B,EAE/B,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EACN,mBAAmB,
|
|
1
|
+
{"version":3,"file":"fetchSnapshot.d.ts","sourceRoot":"","sources":["../src/fetchSnapshot.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,SAAS,EAAiB,MAAM,6CAA6C,CAAC;AAUvF,OAAO,EAEN,gBAAgB,EAChB,gBAAgB,EAChB,+BAA+B,EAE/B,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EACN,mBAAmB,EAInB,MAAM,0CAA0C,CAAC;AAQlD,OAAO,EACN,aAAa,EAEb,wBAAwB,EAExB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAMjD,OAAO,EACN,aAAa,EASb,KAAK,mBAAmB,EACxB,MAAM,gBAAgB,CAAC;AAG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CAAC;CAC5C;AAsCD,UAAU,UAAU;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,SAAS,GAAG,UAAU,GAAG;IAAE,gBAAgB,EAAE,MAAM,CAAA;CAAE,CAY3F;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI,CASnE;AAiBD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,gBAAgB,oDAEV,gBAAgB,iBAClB,+BAA+B,qBAC3B,mBAAmB,mBACrB,MAAM,EAAE,GAAG,SAAS,mBACpB,gBAAgB,GAAG,SAAS,4BACnB,yBAAyB,eACtC,eAAe,iBACb,YAAY,iBACZ,MAAM,KACnB,QAAQ,kCAAkC,CAAC,CA0E9C,CAAC"}
|
package/dist/fetchSnapshot.js
CHANGED
|
@@ -111,7 +111,7 @@ exports.fetchSnapshotWithRedeem = fetchSnapshotWithRedeem;
|
|
|
111
111
|
async function redeemSharingLink(odspResolvedUrl, getAuthHeader, logger) {
|
|
112
112
|
await internal_6.PerformanceEvent.timedExecAsync(logger, {
|
|
113
113
|
eventName: "RedeemShareLink",
|
|
114
|
-
}, async () => {
|
|
114
|
+
}, async (event) => {
|
|
115
115
|
(0, internal_1.assert)(!!odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem, 0x1ed /* "Share link should be present" */);
|
|
116
116
|
const encodedShareUrl = getEncodedShareUrl(odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem);
|
|
117
117
|
let redeemUrl;
|
|
@@ -131,30 +131,24 @@ async function redeemSharingLink(odspResolvedUrl, getAuthHeader, logger) {
|
|
|
131
131
|
await (0, odspUtils_js_1.fetchAndParseAsJSONHelper)(url, { headers, method });
|
|
132
132
|
});
|
|
133
133
|
}
|
|
134
|
-
const
|
|
134
|
+
const details = JSON.stringify({
|
|
135
|
+
length: redeemUrl?.length,
|
|
136
|
+
shareLinkUrlLength: odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem.length,
|
|
137
|
+
queryParamsLength: new URL(odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem).search
|
|
138
|
+
.length,
|
|
139
|
+
useHeaders: true,
|
|
140
|
+
});
|
|
135
141
|
// There is an issue where if we use the siteUrl in /shares, then the allowed length of url is just a few hundred characters(300-400)
|
|
136
|
-
// and we fail to do the redeem. But if we use the tenant domain in the url, then the allowed length becomes 2048. So,
|
|
137
|
-
// construct the url for /shares using tenant domain
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
logger.sendTelemetryEvent({
|
|
146
|
-
eventName: "ShareLinkRedeemFailedWithTenantDomain",
|
|
147
|
-
details: JSON.stringify({
|
|
148
|
-
length: redeemUrl?.length,
|
|
149
|
-
shareLinkUrlLength: odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem.length,
|
|
150
|
-
queryParamsLength: new URL(odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem)
|
|
151
|
-
.search.length,
|
|
152
|
-
useHeaders: true,
|
|
153
|
-
}),
|
|
154
|
-
}, error);
|
|
155
|
-
}
|
|
142
|
+
// and we fail to do the redeem. But if we use the tenant domain in the url, then the allowed length becomes 2048. So,
|
|
143
|
+
// construct the url for /shares using tenant domain. We get tenant domain by getting origin of the siteUrl.
|
|
144
|
+
try {
|
|
145
|
+
await callSharesAPI(new URL(odspResolvedUrl.siteUrl).origin);
|
|
146
|
+
event.end({ details });
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
event.cancel({ details }, error);
|
|
150
|
+
throw error;
|
|
156
151
|
}
|
|
157
|
-
await callSharesAPI(odspResolvedUrl.siteUrl);
|
|
158
152
|
});
|
|
159
153
|
}
|
|
160
154
|
async function fetchLatestSnapshotCore(odspResolvedUrl, getAuthHeader, snapshotOptions, logger, snapshotDownloader, putInCache, loadingGroupIds, enableRedeemFallback) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchSnapshot.js","sourceRoot":"","sources":["../src/fetchSnapshot.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAgE;AAChE,kEAA6D;AAC7D,mEAAkE;AAElE,oEAI+C;AAC/C,yEAGoD;AACpD,+EAM0D;AAC1D,uEAMkD;AAClD,+BAAkC;AAElC,yEAIoC;AACpC,iDAKwB;AAExB,2DAAqD;AACrD,+EAAmE;AACnE,6CAAuC;AACvC,mEAAoF;AACpF,yDAAiE;AACjE,iDAWwB;AACxB,2DAAiD;AAEjD;;;;GAIG;AACH,IAAY,yBAIX;AAJD,WAAY,yBAAyB;IACpC,yEAAQ,CAAA;IACR,6EAAU,CAAA;IACV,2FAAiB,CAAA;AAClB,CAAC,EAJW,yBAAyB,yCAAzB,yBAAyB,QAIpC;AAED;;;;;;;;GAQG;AACI,KAAK,UAAU,aAAa,CAClC,WAAmB,EACnB,SAAiB,EACjB,iBAA0B,EAC1B,sCAA+C,EAC/C,MAA2B,EAC3B,kBAAoE;IAEpE,MAAM,IAAI,GAAG,UAAU,SAAS,EAAE,CAAC;IACnC,IAAI,WAAW,GAAqB,EAAE,CAAC;IAEvC,IAAI,iBAAiB,EAAE,CAAC;QACvB,WAAW,GAAG,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;IAC/E,CAAC;IAED,MAAM,WAAW,GAAG,IAAA,kCAAc,EAAC,WAAW,CAAC,CAAC;IAChD,MAAM,GAAG,GAAG,GAAG,WAAW,GAAG,IAAI,GAAG,WAAW,EAAE,CAAC;IAClD,MAAM,QAAQ,GAAG,CAAC,MAAM,2BAAgB,CAAC,cAAc,CACtD,MAAM,EACN;QACC,SAAS,EAAE,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,eAAe,CAAC,aAAa,EAAE,mBAAmB,KAAK,SAAS;QAChE,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,CAAC,KAAK,CAAC,SAAS,KAAK,yBAAc,CAAC,kBAAkB;YACrD,KAAK,CAAC,SAAS,KAAK,yBAAc,CAAC,+BAA+B,CAAC,EACnE,CAAC;QACF,OAAO,IAAI,CAAC;IACb,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AAED,SAAS,kBAAkB,CAAC,GAAW;IACtC;;;OAGG;IACH,IAAI,UAAU,GAAG,IAAA,+BAAgB,EAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;IAClD,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACpF,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACrC,OAAO,UAAU,CAAC;AACnB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { fromUtf8ToBase64 } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { getW3CData } from \"@fluidframework/driver-base/internal\";\nimport { ISnapshot, ISnapshotTree } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tDriverErrorTelemetryProps,\n\tNonRetryableError,\n\tisRuntimeMessage,\n} from \"@fluidframework/driver-utils/internal\";\nimport {\n\tfetchIncorrectResponse,\n\tthrowOdspNetworkError,\n} from \"@fluidframework/odsp-doclib-utils/internal\";\nimport {\n\ttype IOdspError,\n\tIOdspResolvedUrl,\n\tISnapshotOptions,\n\tInstrumentedStorageTokenFetcher,\n\tOdspErrorTypes,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tPerformanceEvent,\n\tisFluidError,\n\tloggerToMonitoringContext,\n\twrapError,\n} from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport {\n\tISnapshotContentsWithProps,\n\tcurrentReadVersion,\n\tparseCompactSnapshotResponse,\n} from \"./compactSnapshotParser.js\";\nimport {\n\tIOdspSnapshot,\n\tISnapshotCachedEntry2,\n\tIVersionedValueWithEpoch,\n\tpersistedCacheValueVersion,\n} from \"./contracts.js\";\nimport { EpochTracker } from \"./epochTracker.js\";\nimport { getQueryString } from \"./getQueryString.js\";\nimport { getHeadersWithAuth } from \"./getUrlAndHeadersWithAuth.js\";\nimport { mockify } from \"./mockify.js\";\nimport { convertOdspSnapshotToSnapshotTreeAndBlobs } from \"./odspSnapshotParser.js\";\nimport { checkForKnownServerFarmType } from \"./odspUrlHelper.js\";\nimport {\n\tIOdspResponse,\n\tfetchAndParseAsJSONHelper,\n\tfetchHelper,\n\tgetWithRetryForTokenRefresh,\n\tgetWithRetryForTokenRefreshRepeat,\n\tisSnapshotFetchForLoadingGroup,\n\tmeasure,\n\tmeasureP,\n\tuseLegacyFlowWithoutGroupsForSnapshotFetch,\n\ttype TokenFetchOptionsEx,\n} from \"./odspUtils.js\";\nimport { pkgVersion } from \"./packageVersion.js\";\n\n/**\n * Enum to support different types of snapshot formats.\n * @legacy\n * @alpha\n */\nexport enum SnapshotFormatSupportType {\n\tJson = 0,\n\tBinary = 1,\n\tJsonAndBinary = 2,\n}\n\n/**\n * Fetches a snapshot from the server with a given version id.\n * @param snapshotUrl - snapshot url from where the odsp snapshot will be fetched\n * @param versionId - id of specific snapshot to be fetched\n * @param fetchFullSnapshot - whether we want to fetch full snapshot(with blobs)\n * @param forceAccessTokenViaAuthorizationHeader - Deprecated and not used, true value always used instead. Whether to force passing given token via authorization header\n * @param snapshotDownloader - Implementation of the get/post methods used to fetch the snapshot. snapshotDownloader is responsible for generating the appropriate headers (including Authorization header) as well as handling any token refreshes before retrying.\n * @returns A promise of the snapshot and the status code of the response\n */\nexport async function fetchSnapshot(\n\tsnapshotUrl: string,\n\tversionId: string,\n\tfetchFullSnapshot: boolean,\n\tforceAccessTokenViaAuthorizationHeader: boolean,\n\tlogger: ITelemetryLoggerExt,\n\tsnapshotDownloader: (url: string) => Promise<IOdspResponse<unknown>>,\n): Promise<ISnapshot> {\n\tconst path = `/trees/${versionId}`;\n\tlet queryParams: ISnapshotOptions = {};\n\n\tif (fetchFullSnapshot) {\n\t\tqueryParams = versionId === \"latest\" ? { deltas: 1, blobs: 2 } : { blobs: 2 };\n\t}\n\n\tconst queryString = getQueryString(queryParams);\n\tconst url = `${snapshotUrl}${path}${queryString}`;\n\tconst response = (await PerformanceEvent.timedExecAsync(\n\t\tlogger,\n\t\t{\n\t\t\teventName: \"fetchSnapshot\",\n\t\t},\n\t\tasync () => snapshotDownloader(url),\n\t)) as IOdspResponse<IOdspSnapshot>;\n\treturn convertOdspSnapshotToSnapshotTreeAndBlobs(response.content);\n}\n\nexport async function fetchSnapshotWithRedeem(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tstorageTokenFetcher: InstrumentedStorageTokenFetcher,\n\tsnapshotOptions: ISnapshotOptions | undefined,\n\tforceAccessTokenViaAuthorizationHeader: boolean,\n\tlogger: ITelemetryLoggerExt,\n\tsnapshotDownloader: (\n\t\tfinalOdspResolvedUrl: IOdspResolvedUrl,\n\t\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\t\ttokenFetchOptions: TokenFetchOptionsEx,\n\t\tloadingGroupIds: string[] | undefined,\n\t\tsnapshotOptions: ISnapshotOptions | undefined,\n\t\tcontroller?: AbortController,\n\t) => Promise<ISnapshotRequestAndResponseOptions>,\n\tputInCache: (valueWithEpoch: IVersionedValueWithEpoch) => Promise<void>,\n\tremoveEntries: () => Promise<void>,\n\tloadingGroupIds: string[] | undefined,\n\tenableRedeemFallback?: boolean,\n): Promise<ISnapshot> {\n\t// back-compat: This block to be removed with #8784 when we only consume/consider odsp resolvers that are >= 0.51\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\tconst sharingLinkToRedeem = (odspResolvedUrl as any).sharingLinkToRedeem;\n\tif (sharingLinkToRedeem) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\todspResolvedUrl.shareLinkInfo = { ...odspResolvedUrl.shareLinkInfo, sharingLinkToRedeem };\n\t}\n\n\treturn fetchLatestSnapshotCore(\n\t\todspResolvedUrl,\n\t\tstorageTokenFetcher,\n\t\tsnapshotOptions,\n\t\tlogger,\n\t\tsnapshotDownloader,\n\t\tputInCache,\n\t\tloadingGroupIds,\n\t\tenableRedeemFallback,\n\t)\n\t\t.catch(async (error) => {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\tif (enableRedeemFallback && isRedeemSharingLinkError(odspResolvedUrl, error)) {\n\t\t\t\t// Execute the redeem fallback\n\t\t\t\tawait redeemSharingLink(odspResolvedUrl, storageTokenFetcher, logger);\n\n\t\t\t\tconst odspResolvedUrlWithoutShareLink: IOdspResolvedUrl = {\n\t\t\t\t\t...odspResolvedUrl,\n\t\t\t\t\tshareLinkInfo: {\n\t\t\t\t\t\t...odspResolvedUrl.shareLinkInfo,\n\t\t\t\t\t\tsharingLinkToRedeem: undefined,\n\t\t\t\t\t},\n\t\t\t\t};\n\n\t\t\t\t// Log initial failure only if redeem succeeded - it points out to some bug somewhere\n\t\t\t\t// If redeem failed, that most likely means user has no permissions to access a file,\n\t\t\t\t// and thus it's not worth it logging extra errors - same error will be logged by end-to-end\n\t\t\t\t// flow (container open) based on a failure above.\n\t\t\t\tlogger.sendTelemetryEvent(\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: \"RedeemFallback\",\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n\t\t\t\t\t\terrorType: error.errorType,\n\t\t\t\t\t},\n\t\t\t\t\terror,\n\t\t\t\t);\n\n\t\t\t\treturn fetchLatestSnapshotCore(\n\t\t\t\t\todspResolvedUrlWithoutShareLink,\n\t\t\t\t\tstorageTokenFetcher,\n\t\t\t\t\tsnapshotOptions,\n\t\t\t\t\tlogger,\n\t\t\t\t\tsnapshotDownloader,\n\t\t\t\t\tputInCache,\n\t\t\t\t\tloadingGroupIds,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t})\n\t\t.catch(async (error) => {\n\t\t\t// Clear the cache on 401/403/404 on snapshot fetch from network because this means either the user doesn't\n\t\t\t// have permissions for the file or it was deleted. So, if we do not clear cache, we will continue fetching\n\t\t\t// snapshot from cache in the future.\n\t\t\tif (\n\t\t\t\t(typeof error === \"object\" &&\n\t\t\t\t\terror !== null &&\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\t\t\terror.errorType === OdspErrorTypes.authorizationError) ||\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\t\terror.errorType === OdspErrorTypes.fileNotFoundOrAccessDeniedError\n\t\t\t) {\n\t\t\t\tawait removeEntries();\n\t\t\t}\n\t\t\tthrow error;\n\t\t});\n}\n\nasync function redeemSharingLink(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\tlogger: ITelemetryLoggerExt,\n): Promise<void> {\n\tawait PerformanceEvent.timedExecAsync(\n\t\tlogger,\n\t\t{\n\t\t\teventName: \"RedeemShareLink\",\n\t\t},\n\t\tasync () => {\n\t\t\tassert(\n\t\t\t\t!!odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem,\n\t\t\t\t0x1ed /* \"Share link should be present\" */,\n\t\t\t);\n\n\t\t\tconst encodedShareUrl = getEncodedShareUrl(\n\t\t\t\todspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem,\n\t\t\t);\n\n\t\t\tlet redeemUrl: string | undefined;\n\t\t\tasync function callSharesAPI(baseUrl: string): Promise<void> {\n\t\t\t\tawait getWithRetryForTokenRefresh(async (tokenFetchOptions) => {\n\t\t\t\t\t// IMPORTANT: Note that redeemUrl has '/driveItem' in it. Technically it is not required for executing redeem operation.\n\t\t\t\t\t// However, we have other cases that use '/shares' API and do require to specify '/driveItem' in order to get specific\n\t\t\t\t\t// drive item properties. The reason this matters is when caller of this API must possess logical permissions to call\n\t\t\t\t\t// this API (for instance, this will be the case when call is made with app-only token) then two separate logical\n\t\t\t\t\t// permissions are needed for the '/shares' call with and without '/driveItem'.\n\t\t\t\t\tredeemUrl = `${baseUrl}/_api/v2.0/shares/${encodedShareUrl}/driveItem`;\n\t\t\t\t\tconst url = redeemUrl;\n\t\t\t\t\tconst method = \"GET\";\n\t\t\t\t\tconst authHeader = await getAuthHeader(\n\t\t\t\t\t\t{ ...tokenFetchOptions, request: { url, method } },\n\t\t\t\t\t\t\"RedeemShareLink\",\n\t\t\t\t\t);\n\t\t\t\t\tconst headers = getHeadersWithAuth(authHeader);\n\t\t\t\t\theaders.prefer = \"redeemSharingLink\";\n\t\t\t\t\tawait fetchAndParseAsJSONHelper(url, { headers, method });\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst disableUsingTenantDomain = loggerToMonitoringContext(logger).config.getBoolean(\n\t\t\t\t\"Fluid.Driver.Odsp.DisableUsingTenantDomainForSharesApi\",\n\t\t\t);\n\t\t\t// There is an issue where if we use the siteUrl in /shares, then the allowed length of url is just a few hundred characters(300-400)\n\t\t\t// and we fail to do the redeem. But if we use the tenant domain in the url, then the allowed length becomes 2048. So, first\n\t\t\t// construct the url for /shares using tenant domain but to be on safer side, fallback to using the siteUrl. We get tenant domain\n\t\t\t// by getting origin of the siteUrl.\n\t\t\tif (!disableUsingTenantDomain) {\n\t\t\t\ttry {\n\t\t\t\t\tawait callSharesAPI(new URL(odspResolvedUrl.siteUrl).origin);\n\t\t\t\t\treturn;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tlogger.sendTelemetryEvent(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\teventName: \"ShareLinkRedeemFailedWithTenantDomain\",\n\t\t\t\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t\t\t\tlength: redeemUrl?.length,\n\t\t\t\t\t\t\t\tshareLinkUrlLength: odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem.length,\n\t\t\t\t\t\t\t\tqueryParamsLength: new URL(odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem)\n\t\t\t\t\t\t\t\t\t.search.length,\n\t\t\t\t\t\t\t\tuseHeaders: true,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t},\n\t\t\t\t\t\terror,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait callSharesAPI(odspResolvedUrl.siteUrl);\n\t\t},\n\t);\n}\n\nasync function fetchLatestSnapshotCore(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\tsnapshotOptions: ISnapshotOptions | undefined,\n\tlogger: ITelemetryLoggerExt,\n\tsnapshotDownloader: (\n\t\tfinalOdspResolvedUrl: IOdspResolvedUrl,\n\t\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\t\ttokenFetchOptions: TokenFetchOptionsEx,\n\t\tloadingGroupIds: string[] | undefined,\n\t\tsnapshotOptions: ISnapshotOptions | undefined,\n\t\tcontroller?: AbortController,\n\t) => Promise<ISnapshotRequestAndResponseOptions>,\n\tputInCache: (valueWithEpoch: IVersionedValueWithEpoch) => Promise<void>,\n\tloadingGroupIds: string[] | undefined,\n\tenableRedeemFallback?: boolean,\n): Promise<ISnapshot> {\n\treturn getWithRetryForTokenRefresh(async (tokenFetchOptions) => {\n\t\tconst fetchSnapshotForLoadingGroup = isSnapshotFetchForLoadingGroup(loadingGroupIds);\n\t\tconst eventName = fetchSnapshotForLoadingGroup ? \"TreesLatestForGroup\" : \"TreesLatest\";\n\t\tconst internalFarmType = checkForKnownServerFarmType(odspResolvedUrl.siteUrl);\n\n\t\tconst perfEvent = {\n\t\t\teventName,\n\t\t\tattempts: tokenFetchOptions.refresh ? 2 : 1,\n\t\t\tshareLinkPresent: odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem !== undefined,\n\t\t\tisSummarizer: odspResolvedUrl.summarizer,\n\t\t\tredeemFallbackEnabled: enableRedeemFallback,\n\t\t\tdetails: {\n\t\t\t\tinternalFarmType,\n\t\t\t},\n\t\t};\n\t\tif (snapshotOptions !== undefined) {\n\t\t\tfor (const [key, value] of Object.entries(snapshotOptions)) {\n\t\t\t\tif (value !== undefined) {\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\t\tperfEvent[`snapshotOption_${key}`] = value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// This event measures only successful cases of getLatest call (no tokens, no retries).\n\t\treturn PerformanceEvent.timedExecAsync(logger, perfEvent, async (event) => {\n\t\t\tlet controller: AbortController | undefined;\n\t\t\tlet fetchTimeout: ReturnType<typeof setTimeout> | undefined;\n\t\t\tif (snapshotOptions?.timeout !== undefined) {\n\t\t\t\tcontroller = new AbortController();\n\t\t\t\tfetchTimeout = setTimeout(() => controller!.abort(), snapshotOptions.timeout);\n\t\t\t}\n\n\t\t\tconst [response, fetchTime] = await measureP(async () =>\n\t\t\t\tsnapshotDownloader(\n\t\t\t\t\todspResolvedUrl,\n\t\t\t\t\tgetAuthHeader,\n\t\t\t\t\ttokenFetchOptions,\n\t\t\t\t\tloadingGroupIds,\n\t\t\t\t\tsnapshotOptions,\n\t\t\t\t\tcontroller,\n\t\t\t\t),\n\t\t\t).finally(() => {\n\t\t\t\t// Clear the fetchTimeout once the response is fetched.\n\t\t\t\tif (fetchTimeout !== undefined) {\n\t\t\t\t\tclearTimeout(fetchTimeout);\n\t\t\t\t\tfetchTimeout = undefined;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tconst odspResponse = response.odspResponse;\n\t\t\tconst contentType = odspResponse.headers.get(\"content-type\");\n\n\t\t\tconst propsToLog: DriverErrorTelemetryProps = {\n\t\t\t\t...odspResponse.propsToLog,\n\t\t\t\tcontentType,\n\t\t\t\taccept: response.requestHeaders.accept,\n\t\t\t\tdriverVersion: pkgVersion,\n\t\t\t};\n\n\t\t\tlet parsedSnapshotContents: IOdspResponse<ISnapshotContentsWithProps> | undefined;\n\t\t\tlet contentTypeToRead: string | undefined;\n\t\t\tif (contentType?.includes(\"application/ms-fluid\")) {\n\t\t\t\tcontentTypeToRead = \"application/ms-fluid\";\n\t\t\t} else if (contentType?.includes(\"application/json\")) {\n\t\t\t\tcontentTypeToRead = \"application/json\";\n\t\t\t}\n\n\t\t\tlet parseTime: number;\n\t\t\tlet receiveContentTime: number;\n\t\t\ttry {\n\t\t\t\tswitch (contentTypeToRead) {\n\t\t\t\t\tcase \"application/json\": {\n\t\t\t\t\t\tlet text: string;\n\t\t\t\t\t\t[text, receiveContentTime] = await measureP(async () =>\n\t\t\t\t\t\t\todspResponse.content\n\t\t\t\t\t\t\t\t.text()\n\t\t\t\t\t\t\t\t.then((res) => {\n\t\t\t\t\t\t\t\t\tif (res.length === 0) {\n\t\t\t\t\t\t\t\t\t\tthrowOdspNetworkError(\n\t\t\t\t\t\t\t\t\t\t\t\"Response from browser is empty\",\n\t\t\t\t\t\t\t\t\t\t\tfetchIncorrectResponse,\n\t\t\t\t\t\t\t\t\t\t\todspResponse.content, // response\n\t\t\t\t\t\t\t\t\t\t\tundefined, // response text\n\t\t\t\t\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn res;\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t.catch((error) =>\n\t\t\t\t\t\t\t\t\t// Parsing can fail and message could contain full request URI, including\n\t\t\t\t\t\t\t\t\t// tokens, etc. So do not log error object itself.\n\t\t\t\t\t\t\t\t\tthrowOdspNetworkError(\n\t\t\t\t\t\t\t\t\t\t\"Error while parsing fetch response\",\n\t\t\t\t\t\t\t\t\t\tfetchIncorrectResponse,\n\t\t\t\t\t\t\t\t\t\todspResponse.content, // response\n\t\t\t\t\t\t\t\t\t\tundefined, // response text\n\t\t\t\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tpropsToLog.bodySize = text.length;\n\t\t\t\t\t\tlet content: IOdspSnapshot;\n\t\t\t\t\t\t[content, parseTime] = measure(() => JSON.parse(text) as IOdspSnapshot);\n\t\t\t\t\t\tvalidateBlobsAndTrees(content);\n\t\t\t\t\t\tconst snapshotContents: ISnapshot =\n\t\t\t\t\t\t\tconvertOdspSnapshotToSnapshotTreeAndBlobs(content);\n\t\t\t\t\t\tparsedSnapshotContents = {\n\t\t\t\t\t\t\t...odspResponse,\n\t\t\t\t\t\t\tcontent: {\n\t\t\t\t\t\t\t\t...snapshotContents,\n\t\t\t\t\t\t\t\ttelemetryProps: {},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"application/ms-fluid\": {\n\t\t\t\t\t\tlet content: ArrayBuffer;\n\t\t\t\t\t\t[content, receiveContentTime] = await measureP(async () =>\n\t\t\t\t\t\t\todspResponse.content\n\t\t\t\t\t\t\t\t.arrayBuffer()\n\t\t\t\t\t\t\t\t.then((res) => {\n\t\t\t\t\t\t\t\t\tif (res.byteLength === 0) {\n\t\t\t\t\t\t\t\t\t\tthrowOdspNetworkError(\n\t\t\t\t\t\t\t\t\t\t\t\"Response from browser is empty\",\n\t\t\t\t\t\t\t\t\t\t\tfetchIncorrectResponse,\n\t\t\t\t\t\t\t\t\t\t\todspResponse.content, // response\n\t\t\t\t\t\t\t\t\t\t\tundefined, // response text\n\t\t\t\t\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn res;\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t.catch((error) =>\n\t\t\t\t\t\t\t\t\t// Parsing can fail and message could contain full request URI, including\n\t\t\t\t\t\t\t\t\t// tokens, etc. So do not log error object itself.\n\t\t\t\t\t\t\t\t\tthrowOdspNetworkError(\n\t\t\t\t\t\t\t\t\t\t\"Error while parsing fetch response\",\n\t\t\t\t\t\t\t\t\t\tfetchIncorrectResponse,\n\t\t\t\t\t\t\t\t\t\todspResponse.content, // response\n\t\t\t\t\t\t\t\t\t\tundefined, // response text\n\t\t\t\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tpropsToLog.bodySize = content.byteLength;\n\t\t\t\t\t\tlet snapshotContents: ISnapshotContentsWithProps;\n\t\t\t\t\t\t[snapshotContents, parseTime] = measure(() =>\n\t\t\t\t\t\t\tparseCompactSnapshotResponse(new Uint8Array(content), logger),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tsnapshotContents.snapshotTree.trees === undefined ||\n\t\t\t\t\t\t\tsnapshotContents.snapshotTree.blobs === undefined\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\t\t\t\"Returned odsp snapshot is malformed. No trees or blobs!\",\n\t\t\t\t\t\t\t\tOdspErrorTypes.incorrectServerResponse,\n\t\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst props = snapshotContents.telemetryProps;\n\t\t\t\t\t\tconst slowTreeParseCodePaths = props.slowTreeStructureCount ?? 0;\n\t\t\t\t\t\tconst slowBlobParseCodePaths = props.slowBlobStructureCount ?? 0;\n\t\t\t\t\t\tconst treeStructureCountWithGroupId = props.treeStructureCountWithGroupId ?? 0;\n\t\t\t\t\t\t// As trees with groupId go through normal parsing, so exclude them.\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tslowTreeParseCodePaths - treeStructureCountWithGroupId > 10 ||\n\t\t\t\t\t\t\tslowBlobParseCodePaths > 10\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tlogger.sendErrorEvent({\n\t\t\t\t\t\t\t\teventName: \"SlowSnapshotParseCodePaths\",\n\t\t\t\t\t\t\t\tslowTreeStructureCount: slowTreeParseCodePaths,\n\t\t\t\t\t\t\t\tslowBlobStructureCount: slowBlobParseCodePaths,\n\t\t\t\t\t\t\t\ttreeStructureCountWithGroupId,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\tparsedSnapshotContents = { ...odspResponse, content: snapshotContents };\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tdefault: {\n\t\t\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\t\t\"Unknown snapshot content type\",\n\t\t\t\t\t\t\tOdspErrorTypes.incorrectServerResponse,\n\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tif (isFluidError(error)) {\n\t\t\t\t\terror.addTelemetryProperties(propsToLog);\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t\tconst enhancedError = wrapError(\n\t\t\t\t\terror,\n\t\t\t\t\t(errorMessage) =>\n\t\t\t\t\t\tnew NonRetryableError(\n\t\t\t\t\t\t\t`Error parsing snapshot response: ${errorMessage}`,\n\t\t\t\t\t\t\tOdspErrorTypes.genericError,\n\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\tthrow enhancedError;\n\t\t\t}\n\n\t\t\tassert(parsedSnapshotContents !== undefined, 0x312 /* snapshot should be parsed */);\n\t\t\tconst snapshot = parsedSnapshotContents.content;\n\n\t\t\t// There are some scenarios in ODSP where we cannot cache, trees/latest will explicitly tell us when we\n\t\t\t// cannot cache using an HTTP response header. Only cache snapshot if it is not for a loading group.\n\t\t\tconst canCache =\n\t\t\t\todspResponse.headers.get(\"disablebrowsercachingofusercontent\") !== \"true\" &&\n\t\t\t\t!fetchSnapshotForLoadingGroup;\n\t\t\tconst sequenceNumber: number = snapshot.sequenceNumber ?? 0;\n\t\t\tconst seqNumberFromOps =\n\t\t\t\tsnapshot.ops && snapshot.ops.length > 0\n\t\t\t\t\t? snapshot.ops[0].sequenceNumber - 1\n\t\t\t\t\t: undefined;\n\n\t\t\tif (\n\t\t\t\t!Number.isInteger(sequenceNumber) ||\n\t\t\t\t(seqNumberFromOps !== undefined && seqNumberFromOps !== sequenceNumber)\n\t\t\t) {\n\t\t\t\tlogger.sendErrorEvent({\n\t\t\t\t\teventName: \"fetchSnapshotError\",\n\t\t\t\t\tsequenceNumber,\n\t\t\t\t\tseqNumberFromOps,\n\t\t\t\t});\n\t\t\t\tsnapshot.sequenceNumber = undefined;\n\t\t\t} else if (canCache) {\n\t\t\t\tconst fluidEpoch = odspResponse.headers.get(\"x-fluid-epoch\");\n\t\t\t\tassert(fluidEpoch !== undefined, 0x1e6 /* \"Epoch should be present in response\" */);\n\t\t\t\tconst value: ISnapshotCachedEntry2 = {\n\t\t\t\t\t...snapshot,\n\t\t\t\t\tcacheEntryTime: Date.now(),\n\t\t\t\t};\n\t\t\t\tconst valueWithEpoch: IVersionedValueWithEpoch = {\n\t\t\t\t\tvalue,\n\t\t\t\t\tfluidEpoch,\n\t\t\t\t\tversion: persistedCacheValueVersion,\n\t\t\t\t};\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-floating-promises\n\t\t\t\tputInCache(valueWithEpoch);\n\t\t\t}\n\n\t\t\tevent.end({\n\t\t\t\t// trees, leafTrees, blobNodes, encodedBlobsSize,\n\t\t\t\t// blobNodes - blobs tells us (roughly) how many blobs are deduped by service.\n\t\t\t\t...getTreeStats(snapshot),\n\t\t\t\tblobs: snapshot.blobContents?.size ?? 0,\n\t\t\t\tsequenceNumber,\n\t\t\t\tops: snapshot.ops?.length ?? 0,\n\t\t\t\tfetchSnapshotForLoadingGroup,\n\t\t\t\tuseLegacyFlowWithoutGroups:\n\t\t\t\t\tuseLegacyFlowWithoutGroupsForSnapshotFetch(loadingGroupIds),\n\t\t\t\tuserOps: snapshot.ops?.filter((op) => isRuntimeMessage(op)).length ?? 0,\n\t\t\t\t// Measures time to make fetch call. Should be similar to\n\t\t\t\t// fetchStartToResponseEndTime - receiveContentTime, i.e. it looks like it's time till first byte /\n\t\t\t\t// end of response headers\n\t\t\t\tfetchTime,\n\t\t\t\t// time it takes client to parse payload. Same payload as in \"SnapshotParse\" event, here for\n\t\t\t\t// easier analyzes.\n\t\t\t\tparseTime,\n\t\t\t\t// Time it takes to receive content (text of buffer) from Response object.\n\t\t\t\t// This time likely is very closely correlated with networkTime, i.e. time it takes to receive\n\t\t\t\t// actual content (starting measuring from first bite / end of response header)\n\t\t\t\treceiveContentTime,\n\t\t\t\t...getW3CData(response.requestUrl, \"fetch\"),\n\t\t\t\t// Sharing link telemetry regarding sharing link redeem status and performance. Ex: FRL; dur=100,\n\t\t\t\t// Azure Fluid Relay service; desc=S, FRP; desc=False. Here, FRL is the duration taken for redeem,\n\t\t\t\t// Azure Fluid Relay service is the redeem status (S means success), and FRP is a flag to indicate\n\t\t\t\t// if the permission has changed.\n\t\t\t\tsltelemetry: odspResponse.headers.get(\"x-fluid-sltelemetry\"),\n\t\t\t\t// All other props\n\t\t\t\t...propsToLog,\n\t\t\t\t// Various perf counters and measures collected by binary parsing code:\n\t\t\t\t// slowTreeStructureCount, slowBlobStructureCount, durationStructure, durationStrings,\n\t\t\t\t// durationSnapshotTree, durationBlobs, etc.\n\t\t\t\t...parsedSnapshotContents.content.telemetryProps,\n\t\t\t});\n\t\t\treturn snapshot;\n\t\t}).catch((error) => {\n\t\t\t// We hit these errors in stress tests, under load\n\t\t\t// It's useful to try one more time in such case.\n\t\t\tif (\n\t\t\t\ttypeof error === \"object\" &&\n\t\t\t\terror !== null &&\n\t\t\t\t((error as Partial<IOdspError>).errorType === OdspErrorTypes.fetchFailure ||\n\t\t\t\t\t(error as Partial<IOdspError>).errorType === OdspErrorTypes.fetchTimeout)\n\t\t\t) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\t\terror[getWithRetryForTokenRefreshRepeat] = true;\n\t\t\t}\n\t\t\tthrow error;\n\t\t});\n\t});\n}\n\nexport interface ISnapshotRequestAndResponseOptions {\n\todspResponse: IOdspResponse<Response>;\n\trequestUrl: string;\n\trequestHeaders: { [index: string]: string };\n}\n\nfunction getFormBodyAndHeaders(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tauthHeader: string,\n\theaders?: { [index: string]: string },\n): {\n\tbody: string;\n\theaders: {\n\t\t[index: string]: string;\n\t};\n} {\n\tconst formBoundary = uuid();\n\tconst formParams: string[] = [];\n\tformParams.push(\n\t\t`--${formBoundary}`,\n\t\t`Authorization: ${authHeader}`,\n\t\t`X-HTTP-Method-Override: GET`,\n\t);\n\n\tif (headers !== undefined) {\n\t\tfor (const [key, value] of Object.entries(headers)) {\n\t\t\tif (value !== undefined) {\n\t\t\t\tformParams.push(`${key}: ${value}`);\n\t\t\t}\n\t\t}\n\t}\n\tif (odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem) {\n\t\tformParams.push(`sl: ${odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem}`);\n\t}\n\tformParams.push(`_post: 1`, `\\r\\n--${formBoundary}--`);\n\tconst postBody = formParams.join(\"\\r\\n\");\n\tconst header: { [index: string]: string } = {\n\t\t\"Content-Type\": `multipart/form-data;boundary=${formBoundary}`,\n\t};\n\treturn { body: postBody, headers: header };\n}\n\ninterface ITreeStats {\n\ttrees: number;\n\tleafTrees: number;\n\tblobNodes: number;\n}\n\nexport function getTreeStats(snapshot: ISnapshot): ITreeStats & { encodedBlobsSize: number } {\n\tconst stats: ITreeStats = {\n\t\ttrees: 0,\n\t\tleafTrees: 0,\n\t\tblobNodes: 0,\n\t};\n\tgetTreeStatsCore(snapshot.snapshotTree, stats);\n\tlet encodedBlobsSize = 0;\n\tfor (const [_, blobContent] of snapshot.blobContents) {\n\t\tencodedBlobsSize += blobContent.byteLength;\n\t}\n\treturn { ...stats, encodedBlobsSize };\n}\n\nexport function validateBlobsAndTrees(snapshot: IOdspSnapshot): void {\n\tassert(\n\t\tsnapshot.trees !== undefined,\n\t\t0x200 /* \"Returned odsp snapshot is malformed. No trees!\" */,\n\t);\n\tassert(\n\t\tsnapshot.blobs !== undefined,\n\t\t0x201 /* \"Returned odsp snapshot is malformed. No blobs!\" */,\n\t);\n}\n\nfunction getTreeStatsCore(snapshotTree: ISnapshotTree, stats: ITreeStats): void {\n\tstats.blobNodes += Object.entries(snapshotTree.blobs).length;\n\tstats.trees++;\n\n\tconst entries = Object.entries(snapshotTree.trees);\n\tif (entries.length === 0) {\n\t\tstats.leafTrees++;\n\t} else {\n\t\tfor (const [_, tree] of entries) {\n\t\t\tstats.trees++;\n\t\t\tgetTreeStatsCore(tree, stats);\n\t\t}\n\t}\n}\n\n/**\n * This function fetches the snapshot and parse it according to what is mentioned in response headers.\n * @param odspResolvedUrl - resolved odsp url.\n * @param storageToken - token to do the auth for network request.\n * @param snapshotOptions - Options used to specify how and what to fetch in the snapshot.\n * @param loadingGroupIds - loadingGroupIds for which snapshot needs to be downloaded. Note:\n * 1.) If undefined, then legacy trees latest call will be used where no groupId query param would be specified.\n * 2.) If [] is passed, then snapshot with all ungrouped data will be fetched.\n * 3.) If any groupId is specified like [\"g1\"], then snapshot for g1 group will be fetched.\n * @param snapshotFormatFetchType - Snapshot format to fetch.\n * @param controller - abort controller if caller needs to abort the network call.\n * @param epochTracker - epoch tracker used to add/validate epoch in the network call.\n * @returns fetched snapshot.\n */\nexport const downloadSnapshot = mockify(\n\tasync (\n\t\todspResolvedUrl: IOdspResolvedUrl,\n\t\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\t\ttokenFetchOptions: TokenFetchOptionsEx,\n\t\tloadingGroupIds: string[] | undefined,\n\t\tsnapshotOptions: ISnapshotOptions | undefined,\n\t\tsnapshotFormatFetchType?: SnapshotFormatSupportType,\n\t\tcontroller?: AbortController,\n\t\tepochTracker?: EpochTracker,\n\t\tscenarioName?: string,\n\t): Promise<ISnapshotRequestAndResponseOptions> => {\n\t\t// back-compat: This block to be removed with #8784 when we only consume/consider odsp resolvers that are >= 0.51\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\t\tconst sharingLinkToRedeem = (odspResolvedUrl as any).sharingLinkToRedeem;\n\t\tif (sharingLinkToRedeem) {\n\t\t\todspResolvedUrl.shareLinkInfo = {\n\t\t\t\t...odspResolvedUrl.shareLinkInfo,\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\tsharingLinkToRedeem,\n\t\t\t};\n\t\t}\n\n\t\tconst snapshotUrl = odspResolvedUrl.endpoints.snapshotStorageUrl;\n\n\t\tconst queryParams: Record<string, unknown> = { ump: 1 };\n\t\tif (snapshotOptions !== undefined) {\n\t\t\tfor (const [key, value] of Object.entries(snapshotOptions)) {\n\t\t\t\t// Exclude \"timeout\" from query string\n\t\t\t\tif (value !== undefined && key !== \"timeout\") {\n\t\t\t\t\tqueryParams[key] = value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (loadingGroupIds !== undefined) {\n\t\t\tqueryParams.groupId = loadingGroupIds.join(\",\");\n\t\t}\n\n\t\tconst queryString = getQueryString(queryParams);\n\t\tconst url = `${snapshotUrl}/trees/latest${queryString}`;\n\t\tconst method = \"POST\";\n\t\t// The location of file can move on Spo in which case server returns 308(Permanent Redirect) error.\n\t\t// Adding below header will make VROOM API return 404 instead of 308 and browser can intercept it.\n\t\t// This error thrown by server will contain the new redirect location. Look at the 404 error parsing\n\t\t// for further reference here: \\packages\\utils\\odsp-doclib-utils\\src\\odspErrorUtils.ts\n\t\tconst header = { prefer: \"manualredirect\" };\n\t\tconst authHeader = await getAuthHeader(\n\t\t\t{ ...tokenFetchOptions, request: { url, method } },\n\t\t\t\"downloadSnapshot\",\n\t\t);\n\t\tassert(authHeader !== null, 0x1e5 /* \"Storage token should not be null\" */);\n\t\tconst { body, headers } = getFormBodyAndHeaders(odspResolvedUrl, authHeader, header);\n\t\tconst fetchOptions = {\n\t\t\tbody,\n\t\t\theaders,\n\t\t\tsignal: controller?.signal,\n\t\t\tmethod,\n\t\t};\n\t\t// Decide what snapshot format to fetch as per the feature gate.\n\t\tswitch (snapshotFormatFetchType) {\n\t\t\tcase SnapshotFormatSupportType.Binary: {\n\t\t\t\theaders.accept = `application/ms-fluid; v=${currentReadVersion}`;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\t// By default ask both versions and let the server decide the format.\n\t\t\t\theaders.accept = `application/json, application/ms-fluid; v=${currentReadVersion}`;\n\t\t\t}\n\t\t}\n\n\t\tconst odspResponse = await (epochTracker?.fetch(\n\t\t\turl,\n\t\t\tfetchOptions,\n\t\t\t\"treesLatest\",\n\t\t\ttrue,\n\t\t\tscenarioName,\n\t\t) ?? fetchHelper(url, fetchOptions));\n\n\t\treturn {\n\t\t\todspResponse,\n\t\t\trequestHeaders: headers,\n\t\t\trequestUrl: url,\n\t\t};\n\t},\n);\n\nfunction isRedeemSharingLinkError(\n\todspResolvedUrl: IOdspResolvedUrl,\n\terror: Partial<IOdspError>,\n): boolean {\n\tif (\n\t\todspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem !== undefined &&\n\t\ttypeof error === \"object\" &&\n\t\terror !== null &&\n\t\t(error.errorType === OdspErrorTypes.authorizationError ||\n\t\t\terror.errorType === OdspErrorTypes.fileNotFoundOrAccessDeniedError)\n\t) {\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nfunction getEncodedShareUrl(url: string): string {\n\t/**\n\t * Encode the url to accepted format by Sharepoint\n\t * https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/shares_get\n\t */\n\tlet encodedUrl = fromUtf8ToBase64(encodeURI(url));\n\tencodedUrl = encodedUrl.replace(/=+$/g, \"\").replace(/\\//g, \"_\").replace(/\\+/g, \"-\");\n\tencodedUrl = \"u!\".concat(encodedUrl);\n\treturn encodedUrl;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"fetchSnapshot.js","sourceRoot":"","sources":["../src/fetchSnapshot.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAgE;AAChE,kEAA6D;AAC7D,mEAAkE;AAElE,oEAI+C;AAC/C,yEAGoD;AACpD,+EAM0D;AAC1D,uEAKkD;AAClD,+BAAkC;AAElC,yEAIoC;AACpC,iDAKwB;AAExB,2DAAqD;AACrD,+EAAmE;AACnE,6CAAuC;AACvC,mEAAoF;AACpF,yDAAiE;AACjE,iDAWwB;AACxB,2DAAiD;AAEjD;;;;GAIG;AACH,IAAY,yBAIX;AAJD,WAAY,yBAAyB;IACpC,yEAAQ,CAAA;IACR,6EAAU,CAAA;IACV,2FAAiB,CAAA;AAClB,CAAC,EAJW,yBAAyB,yCAAzB,yBAAyB,QAIpC;AAED;;;;;;;;GAQG;AACI,KAAK,UAAU,aAAa,CAClC,WAAmB,EACnB,SAAiB,EACjB,iBAA0B,EAC1B,sCAA+C,EAC/C,MAA2B,EAC3B,kBAAoE;IAEpE,MAAM,IAAI,GAAG,UAAU,SAAS,EAAE,CAAC;IACnC,IAAI,WAAW,GAAqB,EAAE,CAAC;IAEvC,IAAI,iBAAiB,EAAE,CAAC;QACvB,WAAW,GAAG,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,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CAAC;AACH,CAAC,CACD,CAAC;AAEF,SAAS,wBAAwB,CAChC,eAAiC,EACjC,KAA0B;IAE1B,IACC,eAAe,CAAC,aAAa,EAAE,mBAAmB,KAAK,SAAS;QAChE,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,CAAC,KAAK,CAAC,SAAS,KAAK,yBAAc,CAAC,kBAAkB;YACrD,KAAK,CAAC,SAAS,KAAK,yBAAc,CAAC,+BAA+B,CAAC,EACnE,CAAC;QACF,OAAO,IAAI,CAAC;IACb,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AAED,SAAS,kBAAkB,CAAC,GAAW;IACtC;;;OAGG;IACH,IAAI,UAAU,GAAG,IAAA,+BAAgB,EAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;IAClD,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACpF,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACrC,OAAO,UAAU,CAAC;AACnB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { fromUtf8ToBase64 } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { getW3CData } from \"@fluidframework/driver-base/internal\";\nimport { ISnapshot, ISnapshotTree } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tDriverErrorTelemetryProps,\n\tNonRetryableError,\n\tisRuntimeMessage,\n} from \"@fluidframework/driver-utils/internal\";\nimport {\n\tfetchIncorrectResponse,\n\tthrowOdspNetworkError,\n} from \"@fluidframework/odsp-doclib-utils/internal\";\nimport {\n\ttype IOdspError,\n\tIOdspResolvedUrl,\n\tISnapshotOptions,\n\tInstrumentedStorageTokenFetcher,\n\tOdspErrorTypes,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tPerformanceEvent,\n\tisFluidError,\n\twrapError,\n} from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport {\n\tISnapshotContentsWithProps,\n\tcurrentReadVersion,\n\tparseCompactSnapshotResponse,\n} from \"./compactSnapshotParser.js\";\nimport {\n\tIOdspSnapshot,\n\tISnapshotCachedEntry2,\n\tIVersionedValueWithEpoch,\n\tpersistedCacheValueVersion,\n} from \"./contracts.js\";\nimport { EpochTracker } from \"./epochTracker.js\";\nimport { getQueryString } from \"./getQueryString.js\";\nimport { getHeadersWithAuth } from \"./getUrlAndHeadersWithAuth.js\";\nimport { mockify } from \"./mockify.js\";\nimport { convertOdspSnapshotToSnapshotTreeAndBlobs } from \"./odspSnapshotParser.js\";\nimport { checkForKnownServerFarmType } from \"./odspUrlHelper.js\";\nimport {\n\tIOdspResponse,\n\tfetchAndParseAsJSONHelper,\n\tfetchHelper,\n\tgetWithRetryForTokenRefresh,\n\tgetWithRetryForTokenRefreshRepeat,\n\tisSnapshotFetchForLoadingGroup,\n\tmeasure,\n\tmeasureP,\n\tuseLegacyFlowWithoutGroupsForSnapshotFetch,\n\ttype TokenFetchOptionsEx,\n} from \"./odspUtils.js\";\nimport { pkgVersion } from \"./packageVersion.js\";\n\n/**\n * Enum to support different types of snapshot formats.\n * @legacy\n * @alpha\n */\nexport enum SnapshotFormatSupportType {\n\tJson = 0,\n\tBinary = 1,\n\tJsonAndBinary = 2,\n}\n\n/**\n * Fetches a snapshot from the server with a given version id.\n * @param snapshotUrl - snapshot url from where the odsp snapshot will be fetched\n * @param versionId - id of specific snapshot to be fetched\n * @param fetchFullSnapshot - whether we want to fetch full snapshot(with blobs)\n * @param forceAccessTokenViaAuthorizationHeader - Deprecated and not used, true value always used instead. Whether to force passing given token via authorization header\n * @param snapshotDownloader - Implementation of the get/post methods used to fetch the snapshot. snapshotDownloader is responsible for generating the appropriate headers (including Authorization header) as well as handling any token refreshes before retrying.\n * @returns A promise of the snapshot and the status code of the response\n */\nexport async function fetchSnapshot(\n\tsnapshotUrl: string,\n\tversionId: string,\n\tfetchFullSnapshot: boolean,\n\tforceAccessTokenViaAuthorizationHeader: boolean,\n\tlogger: ITelemetryLoggerExt,\n\tsnapshotDownloader: (url: string) => Promise<IOdspResponse<unknown>>,\n): Promise<ISnapshot> {\n\tconst path = `/trees/${versionId}`;\n\tlet queryParams: ISnapshotOptions = {};\n\n\tif (fetchFullSnapshot) {\n\t\tqueryParams = versionId === \"latest\" ? { deltas: 1, blobs: 2 } : { blobs: 2 };\n\t}\n\n\tconst queryString = getQueryString(queryParams);\n\tconst url = `${snapshotUrl}${path}${queryString}`;\n\tconst response = (await PerformanceEvent.timedExecAsync(\n\t\tlogger,\n\t\t{\n\t\t\teventName: \"fetchSnapshot\",\n\t\t},\n\t\tasync () => snapshotDownloader(url),\n\t)) as IOdspResponse<IOdspSnapshot>;\n\treturn convertOdspSnapshotToSnapshotTreeAndBlobs(response.content);\n}\n\nexport async function fetchSnapshotWithRedeem(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tstorageTokenFetcher: InstrumentedStorageTokenFetcher,\n\tsnapshotOptions: ISnapshotOptions | undefined,\n\tforceAccessTokenViaAuthorizationHeader: boolean,\n\tlogger: ITelemetryLoggerExt,\n\tsnapshotDownloader: (\n\t\tfinalOdspResolvedUrl: IOdspResolvedUrl,\n\t\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\t\ttokenFetchOptions: TokenFetchOptionsEx,\n\t\tloadingGroupIds: string[] | undefined,\n\t\tsnapshotOptions: ISnapshotOptions | undefined,\n\t\tcontroller?: AbortController,\n\t) => Promise<ISnapshotRequestAndResponseOptions>,\n\tputInCache: (valueWithEpoch: IVersionedValueWithEpoch) => Promise<void>,\n\tremoveEntries: () => Promise<void>,\n\tloadingGroupIds: string[] | undefined,\n\tenableRedeemFallback?: boolean,\n): Promise<ISnapshot> {\n\t// back-compat: This block to be removed with #8784 when we only consume/consider odsp resolvers that are >= 0.51\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\tconst sharingLinkToRedeem = (odspResolvedUrl as any).sharingLinkToRedeem;\n\tif (sharingLinkToRedeem) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\todspResolvedUrl.shareLinkInfo = { ...odspResolvedUrl.shareLinkInfo, sharingLinkToRedeem };\n\t}\n\n\treturn fetchLatestSnapshotCore(\n\t\todspResolvedUrl,\n\t\tstorageTokenFetcher,\n\t\tsnapshotOptions,\n\t\tlogger,\n\t\tsnapshotDownloader,\n\t\tputInCache,\n\t\tloadingGroupIds,\n\t\tenableRedeemFallback,\n\t)\n\t\t.catch(async (error) => {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\tif (enableRedeemFallback && isRedeemSharingLinkError(odspResolvedUrl, error)) {\n\t\t\t\t// Execute the redeem fallback\n\t\t\t\tawait redeemSharingLink(odspResolvedUrl, storageTokenFetcher, logger);\n\n\t\t\t\tconst odspResolvedUrlWithoutShareLink: IOdspResolvedUrl = {\n\t\t\t\t\t...odspResolvedUrl,\n\t\t\t\t\tshareLinkInfo: {\n\t\t\t\t\t\t...odspResolvedUrl.shareLinkInfo,\n\t\t\t\t\t\tsharingLinkToRedeem: undefined,\n\t\t\t\t\t},\n\t\t\t\t};\n\n\t\t\t\t// Log initial failure only if redeem succeeded - it points out to some bug somewhere\n\t\t\t\t// If redeem failed, that most likely means user has no permissions to access a file,\n\t\t\t\t// and thus it's not worth it logging extra errors - same error will be logged by end-to-end\n\t\t\t\t// flow (container open) based on a failure above.\n\t\t\t\tlogger.sendTelemetryEvent(\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: \"RedeemFallback\",\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n\t\t\t\t\t\terrorType: error.errorType,\n\t\t\t\t\t},\n\t\t\t\t\terror,\n\t\t\t\t);\n\n\t\t\t\treturn fetchLatestSnapshotCore(\n\t\t\t\t\todspResolvedUrlWithoutShareLink,\n\t\t\t\t\tstorageTokenFetcher,\n\t\t\t\t\tsnapshotOptions,\n\t\t\t\t\tlogger,\n\t\t\t\t\tsnapshotDownloader,\n\t\t\t\t\tputInCache,\n\t\t\t\t\tloadingGroupIds,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t})\n\t\t.catch(async (error) => {\n\t\t\t// Clear the cache on 401/403/404 on snapshot fetch from network because this means either the user doesn't\n\t\t\t// have permissions for the file or it was deleted. So, if we do not clear cache, we will continue fetching\n\t\t\t// snapshot from cache in the future.\n\t\t\tif (\n\t\t\t\t(typeof error === \"object\" &&\n\t\t\t\t\terror !== null &&\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\t\t\terror.errorType === OdspErrorTypes.authorizationError) ||\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\t\terror.errorType === OdspErrorTypes.fileNotFoundOrAccessDeniedError\n\t\t\t) {\n\t\t\t\tawait removeEntries();\n\t\t\t}\n\t\t\tthrow error;\n\t\t});\n}\n\nasync function redeemSharingLink(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\tlogger: ITelemetryLoggerExt,\n): Promise<void> {\n\tawait PerformanceEvent.timedExecAsync(\n\t\tlogger,\n\t\t{\n\t\t\teventName: \"RedeemShareLink\",\n\t\t},\n\t\tasync (event) => {\n\t\t\tassert(\n\t\t\t\t!!odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem,\n\t\t\t\t0x1ed /* \"Share link should be present\" */,\n\t\t\t);\n\n\t\t\tconst encodedShareUrl = getEncodedShareUrl(\n\t\t\t\todspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem,\n\t\t\t);\n\n\t\t\tlet redeemUrl: string | undefined;\n\t\t\tasync function callSharesAPI(baseUrl: string): Promise<void> {\n\t\t\t\tawait getWithRetryForTokenRefresh(async (tokenFetchOptions) => {\n\t\t\t\t\t// IMPORTANT: Note that redeemUrl has '/driveItem' in it. Technically it is not required for executing redeem operation.\n\t\t\t\t\t// However, we have other cases that use '/shares' API and do require to specify '/driveItem' in order to get specific\n\t\t\t\t\t// drive item properties. The reason this matters is when caller of this API must possess logical permissions to call\n\t\t\t\t\t// this API (for instance, this will be the case when call is made with app-only token) then two separate logical\n\t\t\t\t\t// permissions are needed for the '/shares' call with and without '/driveItem'.\n\t\t\t\t\tredeemUrl = `${baseUrl}/_api/v2.0/shares/${encodedShareUrl}/driveItem`;\n\t\t\t\t\tconst url = redeemUrl;\n\t\t\t\t\tconst method = \"GET\";\n\t\t\t\t\tconst authHeader = await getAuthHeader(\n\t\t\t\t\t\t{ ...tokenFetchOptions, request: { url, method } },\n\t\t\t\t\t\t\"RedeemShareLink\",\n\t\t\t\t\t);\n\t\t\t\t\tconst headers = getHeadersWithAuth(authHeader);\n\t\t\t\t\theaders.prefer = \"redeemSharingLink\";\n\t\t\t\t\tawait fetchAndParseAsJSONHelper(url, { headers, method });\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst details = JSON.stringify({\n\t\t\t\tlength: redeemUrl?.length,\n\t\t\t\tshareLinkUrlLength: odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem.length,\n\t\t\t\tqueryParamsLength: new URL(odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem).search\n\t\t\t\t\t.length,\n\t\t\t\tuseHeaders: true,\n\t\t\t});\n\t\t\t// There is an issue where if we use the siteUrl in /shares, then the allowed length of url is just a few hundred characters(300-400)\n\t\t\t// and we fail to do the redeem. But if we use the tenant domain in the url, then the allowed length becomes 2048. So,\n\t\t\t// construct the url for /shares using tenant domain. We get tenant domain by getting origin of the siteUrl.\n\t\t\ttry {\n\t\t\t\tawait callSharesAPI(new URL(odspResolvedUrl.siteUrl).origin);\n\t\t\t\tevent.end({ details });\n\t\t\t} catch (error) {\n\t\t\t\tevent.cancel({ details }, error);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\t);\n}\n\nasync function fetchLatestSnapshotCore(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\tsnapshotOptions: ISnapshotOptions | undefined,\n\tlogger: ITelemetryLoggerExt,\n\tsnapshotDownloader: (\n\t\tfinalOdspResolvedUrl: IOdspResolvedUrl,\n\t\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\t\ttokenFetchOptions: TokenFetchOptionsEx,\n\t\tloadingGroupIds: string[] | undefined,\n\t\tsnapshotOptions: ISnapshotOptions | undefined,\n\t\tcontroller?: AbortController,\n\t) => Promise<ISnapshotRequestAndResponseOptions>,\n\tputInCache: (valueWithEpoch: IVersionedValueWithEpoch) => Promise<void>,\n\tloadingGroupIds: string[] | undefined,\n\tenableRedeemFallback?: boolean,\n): Promise<ISnapshot> {\n\treturn getWithRetryForTokenRefresh(async (tokenFetchOptions) => {\n\t\tconst fetchSnapshotForLoadingGroup = isSnapshotFetchForLoadingGroup(loadingGroupIds);\n\t\tconst eventName = fetchSnapshotForLoadingGroup ? \"TreesLatestForGroup\" : \"TreesLatest\";\n\t\tconst internalFarmType = checkForKnownServerFarmType(odspResolvedUrl.siteUrl);\n\n\t\tconst perfEvent = {\n\t\t\teventName,\n\t\t\tattempts: tokenFetchOptions.refresh ? 2 : 1,\n\t\t\tshareLinkPresent: odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem !== undefined,\n\t\t\tisSummarizer: odspResolvedUrl.summarizer,\n\t\t\tredeemFallbackEnabled: enableRedeemFallback,\n\t\t\tdetails: {\n\t\t\t\tinternalFarmType,\n\t\t\t},\n\t\t};\n\t\tif (snapshotOptions !== undefined) {\n\t\t\tfor (const [key, value] of Object.entries(snapshotOptions)) {\n\t\t\t\tif (value !== undefined) {\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\t\tperfEvent[`snapshotOption_${key}`] = value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// This event measures only successful cases of getLatest call (no tokens, no retries).\n\t\treturn PerformanceEvent.timedExecAsync(logger, perfEvent, async (event) => {\n\t\t\tlet controller: AbortController | undefined;\n\t\t\tlet fetchTimeout: ReturnType<typeof setTimeout> | undefined;\n\t\t\tif (snapshotOptions?.timeout !== undefined) {\n\t\t\t\tcontroller = new AbortController();\n\t\t\t\tfetchTimeout = setTimeout(() => controller!.abort(), snapshotOptions.timeout);\n\t\t\t}\n\n\t\t\tconst [response, fetchTime] = await measureP(async () =>\n\t\t\t\tsnapshotDownloader(\n\t\t\t\t\todspResolvedUrl,\n\t\t\t\t\tgetAuthHeader,\n\t\t\t\t\ttokenFetchOptions,\n\t\t\t\t\tloadingGroupIds,\n\t\t\t\t\tsnapshotOptions,\n\t\t\t\t\tcontroller,\n\t\t\t\t),\n\t\t\t).finally(() => {\n\t\t\t\t// Clear the fetchTimeout once the response is fetched.\n\t\t\t\tif (fetchTimeout !== undefined) {\n\t\t\t\t\tclearTimeout(fetchTimeout);\n\t\t\t\t\tfetchTimeout = undefined;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tconst odspResponse = response.odspResponse;\n\t\t\tconst contentType = odspResponse.headers.get(\"content-type\");\n\n\t\t\tconst propsToLog: DriverErrorTelemetryProps = {\n\t\t\t\t...odspResponse.propsToLog,\n\t\t\t\tcontentType,\n\t\t\t\taccept: response.requestHeaders.accept,\n\t\t\t\tdriverVersion: pkgVersion,\n\t\t\t};\n\n\t\t\tlet parsedSnapshotContents: IOdspResponse<ISnapshotContentsWithProps> | undefined;\n\t\t\tlet contentTypeToRead: string | undefined;\n\t\t\tif (contentType?.includes(\"application/ms-fluid\")) {\n\t\t\t\tcontentTypeToRead = \"application/ms-fluid\";\n\t\t\t} else if (contentType?.includes(\"application/json\")) {\n\t\t\t\tcontentTypeToRead = \"application/json\";\n\t\t\t}\n\n\t\t\tlet parseTime: number;\n\t\t\tlet receiveContentTime: number;\n\t\t\ttry {\n\t\t\t\tswitch (contentTypeToRead) {\n\t\t\t\t\tcase \"application/json\": {\n\t\t\t\t\t\tlet text: string;\n\t\t\t\t\t\t[text, receiveContentTime] = await measureP(async () =>\n\t\t\t\t\t\t\todspResponse.content\n\t\t\t\t\t\t\t\t.text()\n\t\t\t\t\t\t\t\t.then((res) => {\n\t\t\t\t\t\t\t\t\tif (res.length === 0) {\n\t\t\t\t\t\t\t\t\t\tthrowOdspNetworkError(\n\t\t\t\t\t\t\t\t\t\t\t\"Response from browser is empty\",\n\t\t\t\t\t\t\t\t\t\t\tfetchIncorrectResponse,\n\t\t\t\t\t\t\t\t\t\t\todspResponse.content, // response\n\t\t\t\t\t\t\t\t\t\t\tundefined, // response text\n\t\t\t\t\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn res;\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t.catch((error) =>\n\t\t\t\t\t\t\t\t\t// Parsing can fail and message could contain full request URI, including\n\t\t\t\t\t\t\t\t\t// tokens, etc. So do not log error object itself.\n\t\t\t\t\t\t\t\t\tthrowOdspNetworkError(\n\t\t\t\t\t\t\t\t\t\t\"Error while parsing fetch response\",\n\t\t\t\t\t\t\t\t\t\tfetchIncorrectResponse,\n\t\t\t\t\t\t\t\t\t\todspResponse.content, // response\n\t\t\t\t\t\t\t\t\t\tundefined, // response text\n\t\t\t\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tpropsToLog.bodySize = text.length;\n\t\t\t\t\t\tlet content: IOdspSnapshot;\n\t\t\t\t\t\t[content, parseTime] = measure(() => JSON.parse(text) as IOdspSnapshot);\n\t\t\t\t\t\tvalidateBlobsAndTrees(content);\n\t\t\t\t\t\tconst snapshotContents: ISnapshot =\n\t\t\t\t\t\t\tconvertOdspSnapshotToSnapshotTreeAndBlobs(content);\n\t\t\t\t\t\tparsedSnapshotContents = {\n\t\t\t\t\t\t\t...odspResponse,\n\t\t\t\t\t\t\tcontent: {\n\t\t\t\t\t\t\t\t...snapshotContents,\n\t\t\t\t\t\t\t\ttelemetryProps: {},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"application/ms-fluid\": {\n\t\t\t\t\t\tlet content: ArrayBuffer;\n\t\t\t\t\t\t[content, receiveContentTime] = await measureP(async () =>\n\t\t\t\t\t\t\todspResponse.content\n\t\t\t\t\t\t\t\t.arrayBuffer()\n\t\t\t\t\t\t\t\t.then((res) => {\n\t\t\t\t\t\t\t\t\tif (res.byteLength === 0) {\n\t\t\t\t\t\t\t\t\t\tthrowOdspNetworkError(\n\t\t\t\t\t\t\t\t\t\t\t\"Response from browser is empty\",\n\t\t\t\t\t\t\t\t\t\t\tfetchIncorrectResponse,\n\t\t\t\t\t\t\t\t\t\t\todspResponse.content, // response\n\t\t\t\t\t\t\t\t\t\t\tundefined, // response text\n\t\t\t\t\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn res;\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t.catch((error) =>\n\t\t\t\t\t\t\t\t\t// Parsing can fail and message could contain full request URI, including\n\t\t\t\t\t\t\t\t\t// tokens, etc. So do not log error object itself.\n\t\t\t\t\t\t\t\t\tthrowOdspNetworkError(\n\t\t\t\t\t\t\t\t\t\t\"Error while parsing fetch response\",\n\t\t\t\t\t\t\t\t\t\tfetchIncorrectResponse,\n\t\t\t\t\t\t\t\t\t\todspResponse.content, // response\n\t\t\t\t\t\t\t\t\t\tundefined, // response text\n\t\t\t\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tpropsToLog.bodySize = content.byteLength;\n\t\t\t\t\t\tlet snapshotContents: ISnapshotContentsWithProps;\n\t\t\t\t\t\t[snapshotContents, parseTime] = measure(() =>\n\t\t\t\t\t\t\tparseCompactSnapshotResponse(new Uint8Array(content), logger),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tsnapshotContents.snapshotTree.trees === undefined ||\n\t\t\t\t\t\t\tsnapshotContents.snapshotTree.blobs === undefined\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\t\t\t\"Returned odsp snapshot is malformed. No trees or blobs!\",\n\t\t\t\t\t\t\t\tOdspErrorTypes.incorrectServerResponse,\n\t\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst props = snapshotContents.telemetryProps;\n\t\t\t\t\t\tconst slowTreeParseCodePaths = props.slowTreeStructureCount ?? 0;\n\t\t\t\t\t\tconst slowBlobParseCodePaths = props.slowBlobStructureCount ?? 0;\n\t\t\t\t\t\tconst treeStructureCountWithGroupId = props.treeStructureCountWithGroupId ?? 0;\n\t\t\t\t\t\t// As trees with groupId go through normal parsing, so exclude them.\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tslowTreeParseCodePaths - treeStructureCountWithGroupId > 10 ||\n\t\t\t\t\t\t\tslowBlobParseCodePaths > 10\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tlogger.sendErrorEvent({\n\t\t\t\t\t\t\t\teventName: \"SlowSnapshotParseCodePaths\",\n\t\t\t\t\t\t\t\tslowTreeStructureCount: slowTreeParseCodePaths,\n\t\t\t\t\t\t\t\tslowBlobStructureCount: slowBlobParseCodePaths,\n\t\t\t\t\t\t\t\ttreeStructureCountWithGroupId,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\tparsedSnapshotContents = { ...odspResponse, content: snapshotContents };\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tdefault: {\n\t\t\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\t\t\"Unknown snapshot content type\",\n\t\t\t\t\t\t\tOdspErrorTypes.incorrectServerResponse,\n\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tif (isFluidError(error)) {\n\t\t\t\t\terror.addTelemetryProperties(propsToLog);\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t\tconst enhancedError = wrapError(\n\t\t\t\t\terror,\n\t\t\t\t\t(errorMessage) =>\n\t\t\t\t\t\tnew NonRetryableError(\n\t\t\t\t\t\t\t`Error parsing snapshot response: ${errorMessage}`,\n\t\t\t\t\t\t\tOdspErrorTypes.genericError,\n\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\tthrow enhancedError;\n\t\t\t}\n\n\t\t\tassert(parsedSnapshotContents !== undefined, 0x312 /* snapshot should be parsed */);\n\t\t\tconst snapshot = parsedSnapshotContents.content;\n\n\t\t\t// There are some scenarios in ODSP where we cannot cache, trees/latest will explicitly tell us when we\n\t\t\t// cannot cache using an HTTP response header. Only cache snapshot if it is not for a loading group.\n\t\t\tconst canCache =\n\t\t\t\todspResponse.headers.get(\"disablebrowsercachingofusercontent\") !== \"true\" &&\n\t\t\t\t!fetchSnapshotForLoadingGroup;\n\t\t\tconst sequenceNumber: number = snapshot.sequenceNumber ?? 0;\n\t\t\tconst seqNumberFromOps =\n\t\t\t\tsnapshot.ops && snapshot.ops.length > 0\n\t\t\t\t\t? snapshot.ops[0].sequenceNumber - 1\n\t\t\t\t\t: undefined;\n\n\t\t\tif (\n\t\t\t\t!Number.isInteger(sequenceNumber) ||\n\t\t\t\t(seqNumberFromOps !== undefined && seqNumberFromOps !== sequenceNumber)\n\t\t\t) {\n\t\t\t\tlogger.sendErrorEvent({\n\t\t\t\t\teventName: \"fetchSnapshotError\",\n\t\t\t\t\tsequenceNumber,\n\t\t\t\t\tseqNumberFromOps,\n\t\t\t\t});\n\t\t\t\tsnapshot.sequenceNumber = undefined;\n\t\t\t} else if (canCache) {\n\t\t\t\tconst fluidEpoch = odspResponse.headers.get(\"x-fluid-epoch\");\n\t\t\t\tassert(fluidEpoch !== undefined, 0x1e6 /* \"Epoch should be present in response\" */);\n\t\t\t\tconst value: ISnapshotCachedEntry2 = {\n\t\t\t\t\t...snapshot,\n\t\t\t\t\tcacheEntryTime: Date.now(),\n\t\t\t\t};\n\t\t\t\tconst valueWithEpoch: IVersionedValueWithEpoch = {\n\t\t\t\t\tvalue,\n\t\t\t\t\tfluidEpoch,\n\t\t\t\t\tversion: persistedCacheValueVersion,\n\t\t\t\t};\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-floating-promises\n\t\t\t\tputInCache(valueWithEpoch);\n\t\t\t}\n\n\t\t\tevent.end({\n\t\t\t\t// trees, leafTrees, blobNodes, encodedBlobsSize,\n\t\t\t\t// blobNodes - blobs tells us (roughly) how many blobs are deduped by service.\n\t\t\t\t...getTreeStats(snapshot),\n\t\t\t\tblobs: snapshot.blobContents?.size ?? 0,\n\t\t\t\tsequenceNumber,\n\t\t\t\tops: snapshot.ops?.length ?? 0,\n\t\t\t\tfetchSnapshotForLoadingGroup,\n\t\t\t\tuseLegacyFlowWithoutGroups:\n\t\t\t\t\tuseLegacyFlowWithoutGroupsForSnapshotFetch(loadingGroupIds),\n\t\t\t\tuserOps: snapshot.ops?.filter((op) => isRuntimeMessage(op)).length ?? 0,\n\t\t\t\t// Measures time to make fetch call. Should be similar to\n\t\t\t\t// fetchStartToResponseEndTime - receiveContentTime, i.e. it looks like it's time till first byte /\n\t\t\t\t// end of response headers\n\t\t\t\tfetchTime,\n\t\t\t\t// time it takes client to parse payload. Same payload as in \"SnapshotParse\" event, here for\n\t\t\t\t// easier analyzes.\n\t\t\t\tparseTime,\n\t\t\t\t// Time it takes to receive content (text of buffer) from Response object.\n\t\t\t\t// This time likely is very closely correlated with networkTime, i.e. time it takes to receive\n\t\t\t\t// actual content (starting measuring from first bite / end of response header)\n\t\t\t\treceiveContentTime,\n\t\t\t\t...getW3CData(response.requestUrl, \"fetch\"),\n\t\t\t\t// Sharing link telemetry regarding sharing link redeem status and performance. Ex: FRL; dur=100,\n\t\t\t\t// Azure Fluid Relay service; desc=S, FRP; desc=False. Here, FRL is the duration taken for redeem,\n\t\t\t\t// Azure Fluid Relay service is the redeem status (S means success), and FRP is a flag to indicate\n\t\t\t\t// if the permission has changed.\n\t\t\t\tsltelemetry: odspResponse.headers.get(\"x-fluid-sltelemetry\"),\n\t\t\t\t// All other props\n\t\t\t\t...propsToLog,\n\t\t\t\t// Various perf counters and measures collected by binary parsing code:\n\t\t\t\t// slowTreeStructureCount, slowBlobStructureCount, durationStructure, durationStrings,\n\t\t\t\t// durationSnapshotTree, durationBlobs, etc.\n\t\t\t\t...parsedSnapshotContents.content.telemetryProps,\n\t\t\t});\n\t\t\treturn snapshot;\n\t\t}).catch((error) => {\n\t\t\t// We hit these errors in stress tests, under load\n\t\t\t// It's useful to try one more time in such case.\n\t\t\tif (\n\t\t\t\ttypeof error === \"object\" &&\n\t\t\t\terror !== null &&\n\t\t\t\t((error as Partial<IOdspError>).errorType === OdspErrorTypes.fetchFailure ||\n\t\t\t\t\t(error as Partial<IOdspError>).errorType === OdspErrorTypes.fetchTimeout)\n\t\t\t) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\t\terror[getWithRetryForTokenRefreshRepeat] = true;\n\t\t\t}\n\t\t\tthrow error;\n\t\t});\n\t});\n}\n\nexport interface ISnapshotRequestAndResponseOptions {\n\todspResponse: IOdspResponse<Response>;\n\trequestUrl: string;\n\trequestHeaders: { [index: string]: string };\n}\n\nfunction getFormBodyAndHeaders(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tauthHeader: string,\n\theaders?: { [index: string]: string },\n): {\n\tbody: string;\n\theaders: {\n\t\t[index: string]: string;\n\t};\n} {\n\tconst formBoundary = uuid();\n\tconst formParams: string[] = [];\n\tformParams.push(\n\t\t`--${formBoundary}`,\n\t\t`Authorization: ${authHeader}`,\n\t\t`X-HTTP-Method-Override: GET`,\n\t);\n\n\tif (headers !== undefined) {\n\t\tfor (const [key, value] of Object.entries(headers)) {\n\t\t\tif (value !== undefined) {\n\t\t\t\tformParams.push(`${key}: ${value}`);\n\t\t\t}\n\t\t}\n\t}\n\tif (odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem) {\n\t\tformParams.push(`sl: ${odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem}`);\n\t}\n\tformParams.push(`_post: 1`, `\\r\\n--${formBoundary}--`);\n\tconst postBody = formParams.join(\"\\r\\n\");\n\tconst header: { [index: string]: string } = {\n\t\t\"Content-Type\": `multipart/form-data;boundary=${formBoundary}`,\n\t};\n\treturn { body: postBody, headers: header };\n}\n\ninterface ITreeStats {\n\ttrees: number;\n\tleafTrees: number;\n\tblobNodes: number;\n}\n\nexport function getTreeStats(snapshot: ISnapshot): ITreeStats & { encodedBlobsSize: number } {\n\tconst stats: ITreeStats = {\n\t\ttrees: 0,\n\t\tleafTrees: 0,\n\t\tblobNodes: 0,\n\t};\n\tgetTreeStatsCore(snapshot.snapshotTree, stats);\n\tlet encodedBlobsSize = 0;\n\tfor (const [_, blobContent] of snapshot.blobContents) {\n\t\tencodedBlobsSize += blobContent.byteLength;\n\t}\n\treturn { ...stats, encodedBlobsSize };\n}\n\nexport function validateBlobsAndTrees(snapshot: IOdspSnapshot): void {\n\tassert(\n\t\tsnapshot.trees !== undefined,\n\t\t0x200 /* \"Returned odsp snapshot is malformed. No trees!\" */,\n\t);\n\tassert(\n\t\tsnapshot.blobs !== undefined,\n\t\t0x201 /* \"Returned odsp snapshot is malformed. No blobs!\" */,\n\t);\n}\n\nfunction getTreeStatsCore(snapshotTree: ISnapshotTree, stats: ITreeStats): void {\n\tstats.blobNodes += Object.entries(snapshotTree.blobs).length;\n\tstats.trees++;\n\n\tconst entries = Object.entries(snapshotTree.trees);\n\tif (entries.length === 0) {\n\t\tstats.leafTrees++;\n\t} else {\n\t\tfor (const [_, tree] of entries) {\n\t\t\tstats.trees++;\n\t\t\tgetTreeStatsCore(tree, stats);\n\t\t}\n\t}\n}\n\n/**\n * This function fetches the snapshot and parse it according to what is mentioned in response headers.\n * @param odspResolvedUrl - resolved odsp url.\n * @param storageToken - token to do the auth for network request.\n * @param snapshotOptions - Options used to specify how and what to fetch in the snapshot.\n * @param loadingGroupIds - loadingGroupIds for which snapshot needs to be downloaded. Note:\n * 1.) If undefined, then legacy trees latest call will be used where no groupId query param would be specified.\n * 2.) If [] is passed, then snapshot with all ungrouped data will be fetched.\n * 3.) If any groupId is specified like [\"g1\"], then snapshot for g1 group will be fetched.\n * @param snapshotFormatFetchType - Snapshot format to fetch.\n * @param controller - abort controller if caller needs to abort the network call.\n * @param epochTracker - epoch tracker used to add/validate epoch in the network call.\n * @returns fetched snapshot.\n */\nexport const downloadSnapshot = mockify(\n\tasync (\n\t\todspResolvedUrl: IOdspResolvedUrl,\n\t\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\t\ttokenFetchOptions: TokenFetchOptionsEx,\n\t\tloadingGroupIds: string[] | undefined,\n\t\tsnapshotOptions: ISnapshotOptions | undefined,\n\t\tsnapshotFormatFetchType?: SnapshotFormatSupportType,\n\t\tcontroller?: AbortController,\n\t\tepochTracker?: EpochTracker,\n\t\tscenarioName?: string,\n\t): Promise<ISnapshotRequestAndResponseOptions> => {\n\t\t// back-compat: This block to be removed with #8784 when we only consume/consider odsp resolvers that are >= 0.51\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\t\tconst sharingLinkToRedeem = (odspResolvedUrl as any).sharingLinkToRedeem;\n\t\tif (sharingLinkToRedeem) {\n\t\t\todspResolvedUrl.shareLinkInfo = {\n\t\t\t\t...odspResolvedUrl.shareLinkInfo,\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\tsharingLinkToRedeem,\n\t\t\t};\n\t\t}\n\n\t\tconst snapshotUrl = odspResolvedUrl.endpoints.snapshotStorageUrl;\n\n\t\tconst queryParams: Record<string, unknown> = { ump: 1 };\n\t\tif (snapshotOptions !== undefined) {\n\t\t\tfor (const [key, value] of Object.entries(snapshotOptions)) {\n\t\t\t\t// Exclude \"timeout\" from query string\n\t\t\t\tif (value !== undefined && key !== \"timeout\") {\n\t\t\t\t\tqueryParams[key] = value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (loadingGroupIds !== undefined) {\n\t\t\tqueryParams.groupId = loadingGroupIds.join(\",\");\n\t\t}\n\n\t\tconst queryString = getQueryString(queryParams);\n\t\tconst url = `${snapshotUrl}/trees/latest${queryString}`;\n\t\tconst method = \"POST\";\n\t\t// The location of file can move on Spo in which case server returns 308(Permanent Redirect) error.\n\t\t// Adding below header will make VROOM API return 404 instead of 308 and browser can intercept it.\n\t\t// This error thrown by server will contain the new redirect location. Look at the 404 error parsing\n\t\t// for further reference here: \\packages\\utils\\odsp-doclib-utils\\src\\odspErrorUtils.ts\n\t\tconst header = { prefer: \"manualredirect\" };\n\t\tconst authHeader = await getAuthHeader(\n\t\t\t{ ...tokenFetchOptions, request: { url, method } },\n\t\t\t\"downloadSnapshot\",\n\t\t);\n\t\tassert(authHeader !== null, 0x1e5 /* \"Storage token should not be null\" */);\n\t\tconst { body, headers } = getFormBodyAndHeaders(odspResolvedUrl, authHeader, header);\n\t\tconst fetchOptions = {\n\t\t\tbody,\n\t\t\theaders,\n\t\t\tsignal: controller?.signal,\n\t\t\tmethod,\n\t\t};\n\t\t// Decide what snapshot format to fetch as per the feature gate.\n\t\tswitch (snapshotFormatFetchType) {\n\t\t\tcase SnapshotFormatSupportType.Binary: {\n\t\t\t\theaders.accept = `application/ms-fluid; v=${currentReadVersion}`;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\t// By default ask both versions and let the server decide the format.\n\t\t\t\theaders.accept = `application/json, application/ms-fluid; v=${currentReadVersion}`;\n\t\t\t}\n\t\t}\n\n\t\tconst odspResponse = await (epochTracker?.fetch(\n\t\t\turl,\n\t\t\tfetchOptions,\n\t\t\t\"treesLatest\",\n\t\t\ttrue,\n\t\t\tscenarioName,\n\t\t) ?? fetchHelper(url, fetchOptions));\n\n\t\treturn {\n\t\t\todspResponse,\n\t\t\trequestHeaders: headers,\n\t\t\trequestUrl: url,\n\t\t};\n\t},\n);\n\nfunction isRedeemSharingLinkError(\n\todspResolvedUrl: IOdspResolvedUrl,\n\terror: Partial<IOdspError>,\n): boolean {\n\tif (\n\t\todspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem !== undefined &&\n\t\ttypeof error === \"object\" &&\n\t\terror !== null &&\n\t\t(error.errorType === OdspErrorTypes.authorizationError ||\n\t\t\terror.errorType === OdspErrorTypes.fileNotFoundOrAccessDeniedError)\n\t) {\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nfunction getEncodedShareUrl(url: string): string {\n\t/**\n\t * Encode the url to accepted format by Sharepoint\n\t * https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/shares_get\n\t */\n\tlet encodedUrl = fromUtf8ToBase64(encodeURI(url));\n\tencodedUrl = encodedUrl.replace(/=+$/g, \"\").replace(/\\//g, \"_\").replace(/\\+/g, \"-\");\n\tencodedUrl = \"u!\".concat(encodedUrl);\n\treturn encodedUrl;\n}\n"]}
|
|
@@ -29,6 +29,7 @@ export declare class OdspDelayLoadedDeltaStream {
|
|
|
29
29
|
private readonly joinSessionKey;
|
|
30
30
|
private currentConnection?;
|
|
31
31
|
private _relayServiceTenantAndSessionId;
|
|
32
|
+
private firstConnectionAttempt;
|
|
32
33
|
private labelUpdateTimestamp;
|
|
33
34
|
/**
|
|
34
35
|
* @param odspResolvedUrl - resolved url identifying document that will be managed by this service instance.
|
|
@@ -74,6 +75,7 @@ export declare class OdspDelayLoadedDeltaStream {
|
|
|
74
75
|
* @param token - authorization token for delta service
|
|
75
76
|
* @param client - information about the client
|
|
76
77
|
* @param webSocketUrl - websocket URL
|
|
78
|
+
* @param connectionId - connection ID for the connection
|
|
77
79
|
*/
|
|
78
80
|
private createDeltaConnection;
|
|
79
81
|
dispose(error?: unknown): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspDelayLoadedDeltaStream.d.ts","sourceRoot":"","sources":["../src/odspDelayLoadedDeltaStream.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAC7D,OAAO,EACN,wBAAwB,EACxB,wBAAwB,EACxB,YAAY,EAEZ,yBAAyB,EAEzB,MAAM,6CAA6C,CAAC;AAMrD,OAAO,EACN,iBAAiB,EAEjB,gBAAgB,EAEhB,+BAA+B,EAE/B,iBAAiB,EACjB,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EAEN,iBAAiB,EAEjB,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"odspDelayLoadedDeltaStream.d.ts","sourceRoot":"","sources":["../src/odspDelayLoadedDeltaStream.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAC7D,OAAO,EACN,wBAAwB,EACxB,wBAAwB,EACxB,YAAY,EAEZ,yBAAyB,EAEzB,MAAM,6CAA6C,CAAC;AAMrD,OAAO,EACN,iBAAiB,EAEjB,gBAAgB,EAEhB,+BAA+B,EAE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YAAY,EAAE,YAAY,EAC1B,WAAW,EAAE,CAAC,GAAG,EAAE,yBAAyB,EAAE,KAAK,IAAI,EACvD,qBAAqB,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,EACjE,wBAAwB,CAAC,oBAAQ;IAKnD,IAAW,WAAW,IAAI,YAAY,CAErC;IAED,IAAW,sBAAsB,IAAI,2BAA2B,GAAG,SAAS,CAE3E;IAED,IAAW,8BAA8B,IAAI,MAAM,GAAG,SAAS,CAE9D;IAED;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAa/B;;;;OAIG;IACU,oBAAoB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,wBAAwB,CAAC;IA2HrF,OAAO,CAAC,QAAQ,CAAC,aAAa,CAoB5B;IAEF,OAAO,CAAC,qBAAqB;YAOf,0BAA0B;YA2C1B,WAAW;YAkEX,eAAe;IAoG7B,OAAO,CAAC,uBAAuB;IAe/B,OAAO,CAAC,gCAAgC;IAQxC;;;;;;;;;OASG;YACW,qBAAqB;IAkC5B,OAAO,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI;CAKrC"}
|
|
@@ -11,6 +11,7 @@ const internal_2 = require("@fluidframework/driver-utils/internal");
|
|
|
11
11
|
const internal_3 = require("@fluidframework/odsp-doclib-utils/internal");
|
|
12
12
|
const internal_4 = require("@fluidframework/odsp-driver-definitions/internal");
|
|
13
13
|
const internal_5 = require("@fluidframework/telemetry-utils/internal");
|
|
14
|
+
const uuid_1 = require("uuid");
|
|
14
15
|
const contracts_js_1 = require("./contracts.js");
|
|
15
16
|
const odspDocumentDeltaConnection_js_1 = require("./odspDocumentDeltaConnection.js");
|
|
16
17
|
const odspUtils_js_1 = require("./odspUtils.js");
|
|
@@ -48,6 +49,7 @@ class OdspDelayLoadedDeltaStream {
|
|
|
48
49
|
this.opsReceived = opsReceived;
|
|
49
50
|
this.metadataUpdateHandler = metadataUpdateHandler;
|
|
50
51
|
this.socketReferenceKeyPrefix = socketReferenceKeyPrefix;
|
|
52
|
+
this.firstConnectionAttempt = true;
|
|
51
53
|
// Tracks the time at which the Policy Labels were updated the last time. This is used to resolve race conditions
|
|
52
54
|
// between label updates from the join session and the Fluid signals and they could have same or different timestamps.
|
|
53
55
|
// So this timestamp is updated with timestamp from the service/signals with the most recent timestamp. We could also
|
|
@@ -133,8 +135,20 @@ class OdspDelayLoadedDeltaStream {
|
|
|
133
135
|
sensitivityLabelsInfo: websocketEndpoint.sensitivityLabelsInfo,
|
|
134
136
|
});
|
|
135
137
|
}
|
|
138
|
+
const connectionId = (0, uuid_1.v4)();
|
|
139
|
+
if (this.firstConnectionAttempt) {
|
|
140
|
+
this.firstConnectionAttempt = false;
|
|
141
|
+
this.mc.logger.sendTelemetryEvent({
|
|
142
|
+
eventName: "FirstConnectionAttemptDetails",
|
|
143
|
+
details: {
|
|
144
|
+
connectionId,
|
|
145
|
+
tenantId: websocketEndpoint.tenantId,
|
|
146
|
+
documentId: websocketEndpoint.id,
|
|
147
|
+
},
|
|
148
|
+
});
|
|
149
|
+
}
|
|
136
150
|
try {
|
|
137
|
-
const connection = await this.createDeltaConnection(websocketEndpoint.tenantId, websocketEndpoint.id, finalWebsocketToken, client, websocketEndpoint.deltaStreamSocketUrl);
|
|
151
|
+
const connection = await this.createDeltaConnection(websocketEndpoint.tenantId, websocketEndpoint.id, finalWebsocketToken, client, websocketEndpoint.deltaStreamSocketUrl, connectionId);
|
|
138
152
|
connection.on("op", (documentId, ops) => {
|
|
139
153
|
this.opsReceived(ops);
|
|
140
154
|
});
|
|
@@ -339,10 +353,11 @@ class OdspDelayLoadedDeltaStream {
|
|
|
339
353
|
* @param token - authorization token for delta service
|
|
340
354
|
* @param client - information about the client
|
|
341
355
|
* @param webSocketUrl - websocket URL
|
|
356
|
+
* @param connectionId - connection ID for the connection
|
|
342
357
|
*/
|
|
343
|
-
async createDeltaConnection(tenantId, documentId, token, client, webSocketUrl) {
|
|
358
|
+
async createDeltaConnection(tenantId, documentId, token, client, webSocketUrl, connectionId) {
|
|
344
359
|
const startTime = (0, client_utils_1.performanceNow)();
|
|
345
|
-
const connection = await odspDocumentDeltaConnection_js_1.OdspDocumentDeltaConnection.create(tenantId, documentId, token, client, webSocketUrl, this.mc.logger, 60000, this.epochTracker, this.socketReferenceKeyPrefix);
|
|
360
|
+
const connection = await odspDocumentDeltaConnection_js_1.OdspDocumentDeltaConnection.create(tenantId, documentId, token, client, webSocketUrl, this.mc.logger, 60000, this.epochTracker, this.socketReferenceKeyPrefix, connectionId);
|
|
346
361
|
const duration = (0, client_utils_1.performanceNow)() - startTime;
|
|
347
362
|
// This event happens rather often, so it adds up to cost of telemetry.
|
|
348
363
|
// Given that most reconnects result in reusing socket and happen very quickly,
|