@fluidframework/odsp-driver 2.0.4 → 2.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/createFile.d.ts.map +1 -1
  2. package/dist/createFile.js +1 -1
  3. package/dist/createFile.js.map +1 -1
  4. package/dist/createNewContainerOnExistingFile.d.ts.map +1 -1
  5. package/dist/createNewContainerOnExistingFile.js +2 -1
  6. package/dist/createNewContainerOnExistingFile.js.map +1 -1
  7. package/dist/epochTracker.d.ts.map +1 -1
  8. package/dist/epochTracker.js +3 -3
  9. package/dist/epochTracker.js.map +1 -1
  10. package/dist/odspDocumentStorageManager.d.ts +1 -0
  11. package/dist/odspDocumentStorageManager.d.ts.map +1 -1
  12. package/dist/odspDocumentStorageManager.js +4 -3
  13. package/dist/odspDocumentStorageManager.js.map +1 -1
  14. package/dist/odspUtils.d.ts +3 -2
  15. package/dist/odspUtils.d.ts.map +1 -1
  16. package/dist/odspUtils.js +7 -3
  17. package/dist/odspUtils.js.map +1 -1
  18. package/dist/packageVersion.d.ts +1 -1
  19. package/dist/packageVersion.js +1 -1
  20. package/dist/packageVersion.js.map +1 -1
  21. package/dist/prefetchLatestSnapshot.d.ts.map +1 -1
  22. package/dist/prefetchLatestSnapshot.js +2 -2
  23. package/dist/prefetchLatestSnapshot.js.map +1 -1
  24. package/lib/createFile.d.ts.map +1 -1
  25. package/lib/createFile.js +3 -3
  26. package/lib/createFile.js.map +1 -1
  27. package/lib/createNewContainerOnExistingFile.d.ts.map +1 -1
  28. package/lib/createNewContainerOnExistingFile.js +3 -2
  29. package/lib/createNewContainerOnExistingFile.js.map +1 -1
  30. package/lib/epochTracker.d.ts.map +1 -1
  31. package/lib/epochTracker.js +4 -4
  32. package/lib/epochTracker.js.map +1 -1
  33. package/lib/odspDocumentStorageManager.d.ts +1 -0
  34. package/lib/odspDocumentStorageManager.d.ts.map +1 -1
  35. package/lib/odspDocumentStorageManager.js +5 -4
  36. package/lib/odspDocumentStorageManager.js.map +1 -1
  37. package/lib/odspUtils.d.ts +3 -2
  38. package/lib/odspUtils.d.ts.map +1 -1
  39. package/lib/odspUtils.js +6 -3
  40. package/lib/odspUtils.js.map +1 -1
  41. package/lib/packageVersion.d.ts +1 -1
  42. package/lib/packageVersion.js +1 -1
  43. package/lib/packageVersion.js.map +1 -1
  44. package/lib/prefetchLatestSnapshot.d.ts.map +1 -1
  45. package/lib/prefetchLatestSnapshot.js +3 -3
  46. package/lib/prefetchLatestSnapshot.js.map +1 -1
  47. package/package.json +11 -11
  48. package/src/createFile.ts +9 -1
  49. package/src/createNewContainerOnExistingFile.ts +16 -3
  50. package/src/epochTracker.ts +4 -3
  51. package/src/odspDocumentStorageManager.ts +18 -3
  52. package/src/odspUtils.ts +13 -2
  53. package/src/packageVersion.ts +1 -1
  54. package/src/prefetchLatestSnapshot.ts +3 -4
@@ -1 +1 @@
1
- {"version":3,"file":"createFile.d.ts","sourceRoot":"","sources":["../src/createFile.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAGlE,OAAO,EACN,UAAU,EACV,gBAAgB,EAChB,+BAA+B,EAG/B,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EACN,mBAAmB,EAEnB,MAAM,0CAA0C,CAAC;AAElD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAQrD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAIjD,OAAO,EACN,YAAY,EAIZ,MAAM,gBAAgB,CAAC;AASxB;;;GAGG;AACH,wBAAsB,kBAAkB,CACvC,aAAa,EAAE,+BAA+B,EAC9C,WAAW,EAAE,YAAY,EACzB,MAAM,EAAE,mBAAmB,EAC3B,gBAAgB,EAAE,YAAY,GAAG,SAAS,EAC1C,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,UAAU,EACrB,gBAAgB,EAAE,OAAO,EACzB,s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AO,EAC3B,yCAAyC,CAAC,EAAE,OAAO,GACjD,OAAO,CAAC,gBAAgB,CAAC,CA2D3B;AA2CD,wBAAsB,uBAAuB,CAC5C,aAAa,EAAE,+BAA+B,EAC9C,WAAW,EAAE,YAAY,EACzB,MAAM,EAAE,mBAAmB,EAC3B,YAAY,EAAE,YAAY,GACxB,OAAO,CAAC,MAAM,CAAC,CAuDjB;AAED,wBAAsB,6BAA6B,CAClD,aAAa,EAAE,+BAA+B,EAC9C,WAAW,EAAE,YAAY,EACzB,MAAM,EAAE,mBAAmB,EAC3B,gBAAgB,EAAE,YAAY,EAC9B,YAAY,EAAE,YAAY,EAC1B,sCAAsC,EAAE,OAAO,GAC7C,OAAO,CAAC,mBAAmB,CAAC,CAmC9B"}
@@ -59,7 +59,7 @@ async function createNewFluidFile(getAuthHeader, newFileInfo, logger, createNewS
59
59
  // converting summary and getting sequence number
60
60
  const snapshot = (0, createNewUtils_js_1.convertCreateNewSummaryTreeToTreeAndBlobs)(createNewSummary, summaryHandle);
61
61
  // caching the converted summary
62
- await epochTracker.put((0, odspUtils_js_1.createCacheSnapshotKey)(odspResolvedUrl), snapshot);
62
+ await epochTracker.put((0, odspUtils_js_1.createCacheSnapshotKey)(odspResolvedUrl, (0, odspUtils_js_1.snapshotWithLoadingGroupIdSupported)((0, internal_4.loggerToMonitoringContext)(logger).config)), snapshot);
63
63
  }
64
64
  return odspResolvedUrl;
65
65
  }
@@ -1 +1 @@
1
- {"version":3,"file":"createFile.js","sourceRoot":"","sources":["../src/createFile.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAG7D,oEAA0E;AAC1E,+EAM0D;AAC1D,uEAGkD;AAGlD,6DAA6D;AAC7D,2DAI6B;AAC7B,yDAAmD;AAEnD,+EAAmE;AACnE,yEAAmE;AACnE,yDAAgD;AAChD,iDAKwB;AACxB,2DAAkE;AAClE,mDAA+C;AAE/C,MAAM,iBAAiB,GAAG,CAAC,QAAgB,EAAW,EAAE;I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,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} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tPerformanceEvent,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { ICreateFileResponse } from \"./contracts.js\";\nimport { ClpCompliantAppHeader } from \"./contractsPublic.js\";\nimport {\n\tconvertCreateNewSummaryTreeToTreeAndBlobs,\n\tconvertSummaryIntoContainerSnapshot,\n\tcreateNewFluidContainerCore,\n} from \"./createNewUtils.js\";\nimport { createOdspUrl } from \"./createOdspUrl.js\";\nimport { EpochTracker } from \"./epochTracker.js\";\nimport { getHeadersWithAuth } from \"./getUrlAndHeadersWithAuth.js\";\nimport { OdspDriverUrlResolver } from \"./odspDriverUrlResolver.js\";\nimport { getApiRoot } from \"./odspUrlHelper.js\";\nimport {\n\tINewFileInfo,\n\tbuildOdspShareLinkReqParams,\n\tcreateCacheSnapshotKey,\n\tgetWithRetryForTokenRefresh,\n} from \"./odspUtils.js\";\nimport { pkgVersion as driverVersion } from \"./packageVersion.js\";\nimport { runWithRetry } from \"./retryUtils.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): 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 summaryHandle: string = \"\";\n\tlet shareLinkInfo: ShareLinkInfoType | undefined;\n\tif (createNewSummary === undefined) {\n\t\titemId = await createNewEmptyFluidFile(getAuthHeader, newFileInfo, logger, epochTracker);\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.shareLinkInfo = shareLinkInfo;\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(createCacheSnapshotKey(odspResolvedUrl), snapshot);\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\nexport async function createNewEmptyFluidFile(\n\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\tnewFileInfo: INewFileInfo,\n\tlogger: ITelemetryLoggerExt,\n\tepochTracker: EpochTracker,\n): Promise<string> {\n\tconst filePath = newFileInfo.filePath ? encodeURIComponent(`/${newFileInfo.filePath}`) : \"\";\n\t// add .tmp extension to empty file (host is expected to rename)\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\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{ eventName: \"createNewEmptyFile\" },\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 content.id;\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 = newFileInfo.filePath ? encodeURIComponent(`/${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.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAG7D,oEAA0E;AAC1E,+EAM0D;AAC1D,uEAIkD;AAGlD,6DAA6D;AAC7D,2DAI6B;AAC7B,yDAAmD;AAEnD,+EAAmE;AACnE,yEAAmE;AACnE,yDAAgD;AAChD,iDAMwB;AACxB,2DAAkE;AAClE,mDAA+C;AAE/C,MAAM,iBAAiB,GAAG,CAAC,QAAgB,EAAW,EAAE;IACvD,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;IAC3C,OAAO,iBAA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,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} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tloggerToMonitoringContext,\n\tPerformanceEvent,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { ICreateFileResponse } from \"./contracts.js\";\nimport { ClpCompliantAppHeader } from \"./contractsPublic.js\";\nimport {\n\tconvertCreateNewSummaryTreeToTreeAndBlobs,\n\tconvertSummaryIntoContainerSnapshot,\n\tcreateNewFluidContainerCore,\n} from \"./createNewUtils.js\";\nimport { createOdspUrl } from \"./createOdspUrl.js\";\nimport { EpochTracker } from \"./epochTracker.js\";\nimport { getHeadersWithAuth } from \"./getUrlAndHeadersWithAuth.js\";\nimport { OdspDriverUrlResolver } from \"./odspDriverUrlResolver.js\";\nimport { getApiRoot } from \"./odspUrlHelper.js\";\nimport {\n\tINewFileInfo,\n\tbuildOdspShareLinkReqParams,\n\tcreateCacheSnapshotKey,\n\tgetWithRetryForTokenRefresh,\n\tsnapshotWithLoadingGroupIdSupported,\n} from \"./odspUtils.js\";\nimport { pkgVersion as driverVersion } from \"./packageVersion.js\";\nimport { runWithRetry } from \"./retryUtils.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): 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 summaryHandle: string = \"\";\n\tlet shareLinkInfo: ShareLinkInfoType | undefined;\n\tif (createNewSummary === undefined) {\n\t\titemId = await createNewEmptyFluidFile(getAuthHeader, newFileInfo, logger, epochTracker);\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.shareLinkInfo = shareLinkInfo;\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\nexport async function createNewEmptyFluidFile(\n\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\tnewFileInfo: INewFileInfo,\n\tlogger: ITelemetryLoggerExt,\n\tepochTracker: EpochTracker,\n): Promise<string> {\n\tconst filePath = newFileInfo.filePath ? encodeURIComponent(`/${newFileInfo.filePath}`) : \"\";\n\t// add .tmp extension to empty file (host is expected to rename)\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\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{ eventName: \"createNewEmptyFile\" },\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 content.id;\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 = newFileInfo.filePath ? encodeURIComponent(`/${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 +1 @@
1
- {"version":3,"file":"createNewContainerOnExistingFile.d.ts","sourceRoot":"","sources":["../src/createNewContainerOnExistingFile.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAGlE,OAAO,EACN,UAAU,EACV,gBAAgB,EAChB,+BA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,EAAE,OAAO,GACzB,OAAO,CAAC,gBAAgB,CAAC,CAkD3B"}
@@ -6,6 +6,7 @@
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.createNewContainerOnExistingFile = void 0;
8
8
  const internal_1 = require("@fluidframework/driver-utils/internal");
9
+ const internal_2 = require("@fluidframework/telemetry-utils/internal");
9
10
  const contractsPublic_js_1 = require("./contractsPublic.js");
10
11
  const createNewUtils_js_1 = require("./createNewUtils.js");
11
12
  const createOdspUrl_js_1 = require("./createOdspUrl.js");
@@ -52,7 +53,7 @@ async function createNewContainerOnExistingFile(getAuthHeader, fileInfo, logger,
52
53
  // converting summary and getting sequence number
53
54
  const snapshot = (0, createNewUtils_js_1.convertCreateNewSummaryTreeToTreeAndBlobs)(createNewSummary, summaryHandle);
54
55
  // caching the converted summary
55
- await epochTracker.put((0, odspUtils_js_1.createCacheSnapshotKey)(odspResolvedUrl), snapshot);
56
+ await epochTracker.put((0, odspUtils_js_1.createCacheSnapshotKey)(odspResolvedUrl, (0, odspUtils_js_1.snapshotWithLoadingGroupIdSupported)((0, internal_2.loggerToMonitoringContext)(logger).config)), snapshot);
56
57
  }
57
58
  return odspResolvedUrl;
58
59
  }
@@ -1 +1 @@
1
- {"version":3,"file":"createNewContainerOnExistingFile.js","sourceRoot":"","sources":["../src/createNewContainerOnExistingFile.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,oEAAmE;AASnE,6DAA6D;AAC7D,2DAI6B;AAC7B,yDAAmD;AAEnD,yEAAmE;AACnE,yDAAgD;AAChD,iDAA2E;AAE3E;;;;;;;;;;GAUG;AACI,KAAK,UAAU,gCAAgC,CACrD,aAA8C,EAC9C,QAA2B,EAC3B,MAA2B,EAC3B,gBAA0C,EAC1C,YAA0B,EAC1B,SAAqB,EACrB,gBAAyB,EACzB,sCAA+C,EAC/C,iBAA2B;IAE3B,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;QACpC,MAAM,IAAI,qBAAU,CAAC,u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ACxB,CAAC;AAtDD,4EAsDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport { ISnapshot } from \"@fluidframework/driver-definitions/internal\";\nimport { UsageError } from \"@fluidframework/driver-utils/internal\";\nimport {\n\tIFileEntry,\n\tIOdspResolvedUrl,\n\tInstrumentedStorageTokenFetcher,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { IWriteSummaryResponse } from \"./contracts.js\";\nimport { ClpCompliantAppHeader } from \"./contractsPublic.js\";\nimport {\n\tconvertCreateNewSummaryTreeToTreeAndBlobs,\n\tconvertSummaryIntoContainerSnapshot,\n\tcreateNewFluidContainerCore,\n} from \"./createNewUtils.js\";\nimport { createOdspUrl } from \"./createOdspUrl.js\";\nimport { EpochTracker } from \"./epochTracker.js\";\nimport { OdspDriverUrlResolver } from \"./odspDriverUrlResolver.js\";\nimport { getApiRoot } from \"./odspUrlHelper.js\";\nimport { IExistingFileInfo, createCacheSnapshotKey } from \"./odspUtils.js\";\n\n/**\n * Creates a new Fluid container on an existing file.\n *\n * @remarks This requires service's capability to manage Fluid container inside an existing file.\n *\n * @example\n *\n * This enables a scenario where Fluid data is not stored as a standalone file but in a way that is managed\n * by an existing file. For example, SharePoint Pages is able to store Fluid container in an\n * \"alternative file partition\" where the main File stub is an ASPX page.\n */\nexport async function createNewContainerOnExistingFile(\n\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\tfileInfo: IExistingFileInfo,\n\tlogger: ITelemetryLoggerExt,\n\tcreateNewSummary: ISummaryTree | undefined,\n\tepochTracker: EpochTracker,\n\tfileEntry: IFileEntry,\n\tcreateNewCaching: boolean,\n\tforceAccessTokenViaAuthorizationHeader: boolean,\n\tisClpCompliantApp?: boolean,\n): Promise<IOdspResolvedUrl> {\n\tif (createNewSummary === undefined) {\n\t\tthrow new UsageError(\"createNewSummary must exist to create a new container\");\n\t}\n\n\tconst baseUrl = `${getApiRoot(new URL(fileInfo.siteUrl))}/drives/${fileInfo.driveId}/items/${\n\t\tfileInfo.itemId\n\t}`;\n\n\tconst containerSnapshot = convertSummaryIntoContainerSnapshot(createNewSummary);\n\n\tconst initialUrl = `${baseUrl}/opStream/snapshots/snapshot`;\n\n\tconst { id: summaryHandle } = await createNewFluidContainerCore<IWriteSummaryResponse>({\n\t\tcontainerSnapshot,\n\t\tgetAuthHeader,\n\t\tlogger,\n\t\tinitialUrl,\n\t\tforceAccessTokenViaAuthorizationHeader,\n\t\tepochTracker,\n\t\ttelemetryName: \"CreateNewContainerOnExistingFile\",\n\t\tfetchType: \"uploadSummary\",\n\t});\n\n\tconst odspUrl = createOdspUrl({ ...fileInfo, 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\tif (createNewCaching) {\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(createCacheSnapshotKey(odspResolvedUrl), snapshot);\n\t}\n\n\treturn odspResolvedUrl;\n}\n"]}
1
+ {"version":3,"file":"createNewContainerOnExistingFile.js","sourceRoot":"","sources":["../src/createNewContainerOnExistingFile.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,oEAAmE;AAMnE,uEAGkD;AAGlD,6DAA6D;AAC7D,2DAI6B;AAC7B,yDAAmD;AAEnD,yEAAmE;AACnE,yDAAgD;AAChD,iDAIwB;AAExB;;;;;;;;;;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AAC;QACtB,iDAAiD;QACjD,MAAM,QAAQ,GAAc,IAAA,6DAAyC,EACpE,gBAAgB,EAChB,aAAa,CACb,CAAC;QACF,gCAAgC;QAChC,MAAM,YAAY,CAAC,GAAG,CACrB,IAAA,qCAAsB,EACrB,eAAe,EACf,IAAA,kDAAmC,EAAC,IAAA,oCAAyB,EAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAC7E,EACD,QAAQ,CACR,CAAC;IACH,CAAC;IAED,OAAO,eAAe,CAAC;AACxB,CAAC;AA5DD,4EA4DC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport { ISnapshot } from \"@fluidframework/driver-definitions/internal\";\nimport { UsageError } from \"@fluidframework/driver-utils/internal\";\nimport {\n\tIFileEntry,\n\tIOdspResolvedUrl,\n\tInstrumentedStorageTokenFetcher,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tloggerToMonitoringContext,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { IWriteSummaryResponse } from \"./contracts.js\";\nimport { ClpCompliantAppHeader } from \"./contractsPublic.js\";\nimport {\n\tconvertCreateNewSummaryTreeToTreeAndBlobs,\n\tconvertSummaryIntoContainerSnapshot,\n\tcreateNewFluidContainerCore,\n} from \"./createNewUtils.js\";\nimport { createOdspUrl } from \"./createOdspUrl.js\";\nimport { EpochTracker } from \"./epochTracker.js\";\nimport { OdspDriverUrlResolver } from \"./odspDriverUrlResolver.js\";\nimport { getApiRoot } from \"./odspUrlHelper.js\";\nimport {\n\tIExistingFileInfo,\n\tcreateCacheSnapshotKey,\n\tsnapshotWithLoadingGroupIdSupported,\n} from \"./odspUtils.js\";\n\n/**\n * Creates a new Fluid container on an existing file.\n *\n * @remarks This requires service's capability to manage Fluid container inside an existing file.\n *\n * @example\n *\n * This enables a scenario where Fluid data is not stored as a standalone file but in a way that is managed\n * by an existing file. For example, SharePoint Pages is able to store Fluid container in an\n * \"alternative file partition\" where the main File stub is an ASPX page.\n */\nexport async function createNewContainerOnExistingFile(\n\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\tfileInfo: IExistingFileInfo,\n\tlogger: ITelemetryLoggerExt,\n\tcreateNewSummary: ISummaryTree | undefined,\n\tepochTracker: EpochTracker,\n\tfileEntry: IFileEntry,\n\tcreateNewCaching: boolean,\n\tforceAccessTokenViaAuthorizationHeader: boolean,\n\tisClpCompliantApp?: boolean,\n): Promise<IOdspResolvedUrl> {\n\tif (createNewSummary === undefined) {\n\t\tthrow new UsageError(\"createNewSummary must exist to create a new container\");\n\t}\n\n\tconst baseUrl = `${getApiRoot(new URL(fileInfo.siteUrl))}/drives/${fileInfo.driveId}/items/${\n\t\tfileInfo.itemId\n\t}`;\n\n\tconst containerSnapshot = convertSummaryIntoContainerSnapshot(createNewSummary);\n\n\tconst initialUrl = `${baseUrl}/opStream/snapshots/snapshot`;\n\n\tconst { id: summaryHandle } = await createNewFluidContainerCore<IWriteSummaryResponse>({\n\t\tcontainerSnapshot,\n\t\tgetAuthHeader,\n\t\tlogger,\n\t\tinitialUrl,\n\t\tforceAccessTokenViaAuthorizationHeader,\n\t\tepochTracker,\n\t\ttelemetryName: \"CreateNewContainerOnExistingFile\",\n\t\tfetchType: \"uploadSummary\",\n\t});\n\n\tconst odspUrl = createOdspUrl({ ...fileInfo, 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\tif (createNewCaching) {\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\n\treturn odspResolvedUrl;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"epochTracker.d.ts","sourceRoot":"","sources":["../src/epochTracker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAGN,WAAW,EAEX,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAEN,MAAM,EACN,UAAU,EAIV,eAAe,EAIf,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EACN,mBAAmB,EAMnB,MAAM,0CAA0C,CAAC;AAKlD,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAEtF,OAAO,EACN,aAAa,EAKb,MAAM,gBAAgB,CAAC;AAGxB;;GAEG;AACH,MAAM,MAAM,SAAS,GAClB,MAAM,GACN,YAAY,GACZ,YAAY,GACZ,aAAa,GACb,KAAK,GACL,MAAM,GACN,cAAc,GACd,aAAa,GACb,eAAe,GACf,MAAM,GACN,UAAU,CAAC;AAEd;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,OAAO,CAAC;AAEpD,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAE3C;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,YAAa,YAAW,mBAAmB;IAStD,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,eAAe;IACzC,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,UAAU;IACxC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,mBAAmB;IAC9C,SAAS,CAAC,QAAQ,CAAC,kBAAkB,CAAC;IAXvC,OAAO,CAAC,WAAW,CAAqB;IAExC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AAE,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,CAAA;KAAE,EAC9C,SAAS,EAAE,SAAS,EACpB,SAAS,GAAE,OAAe,EAC1B,WAAW,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;CAkE5B;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC,KAAK,EAAE,UAAU,CAAC;IAClB,YAAY,EAAE,YAAY,CAAC;CAC3B;AAED,wBAAgB,yBAAyB,CACxC,iBAAiB,EAAE,eAAe,EAClC,kBAAkB,EAAE,mBAAmB,EACvC,SAAS,EAAE,UAAU,EACrB,MAAM,EAAE,mBAAmB,EAC3B,kBAAkB,CAAC,EAAE,OAAO,GAC1B,gBAAgB,CAclB"}
@@ -82,7 +82,7 @@ class EpochTracker {
82
82
  }
83
83
  // Expire the cached snapshot if it's older than snapshotCacheExpiryTimeoutMs and immediately
84
84
  // expire all old caches that do not have cacheEntryTime
85
- if (entry.type === internal_3.snapshotKey) {
85
+ if (entry.type === internal_3.snapshotKey || entry.type === internal_3.snapshotWithLoadingGroupIdKey) {
86
86
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
87
87
  const cacheTime = value.value?.cacheEntryTime;
88
88
  const currentTime = Date.now();
@@ -111,7 +111,7 @@ class EpochTracker {
111
111
  (0, internal_1.assert)(this._fluidEpoch !== undefined, 0x1dd /* "no epoch" */);
112
112
  // For snapshots, the value should have the cacheEntryTime.
113
113
  // This will be used to expire snapshots older than snapshotCacheExpiryTimeoutMs.
114
- if (entry.type === internal_3.snapshotKey) {
114
+ if (entry.type === internal_3.snapshotKey || entry.type === internal_3.snapshotWithLoadingGroupIdKey) {
115
115
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
116
116
  value.cacheEntryTime = value.cacheEntryTime ?? Date.now();
117
117
  }
@@ -359,7 +359,7 @@ class EpochTrackerWithRedemption extends EpochTracker {
359
359
  async get(entry) {
360
360
  let result = super.get(entry);
361
361
  // equivalence of what happens in fetchAndParseAsJSON()
362
- if (entry.type === internal_3.snapshotKey) {
362
+ if (entry.type === internal_3.snapshotKey || entry.type === internal_3.snapshotWithLoadingGroupIdKey) {
363
363
  result = result
364
364
  .then((value) => {
365
365
  // If there is nothing in cache, we need to wait for network call to complete (and do redemption)
@@ -1 +1 @@
1
- {"version":3,"file":"epochTracker.js","sourceRoot":"","sources":["../src/epochTracker.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAuE;AACvE,oEAK+C;AAC/C,+EAW0D;AAC1D,uEAOkD;AAClD,+BAAkC;AAElC,iDAAsF;AACtF,6DAA6D;AAE7D,6EAAoE;AACpE,iDAMwB;AACxB,2DAAkE;AAuBrD,QAAA,YAAY,GAAG,cAAc,CAAC;AAE3C;;;;;;;;;;;;;;;GAeG;AACH,MAAa,YAAY;IAQxB,YACoB,KAAsB,EACtB,SAAqB,EACrB,MAA2B,EAC3B,kBAA4B;QAH5B,UAAK,GAAL,KAAK,CAAiB;QACtB,cAAS,GAAT,SAAS,CAAY;QACrB,WAAM,GAAN,MAAM,CAAqB;QAC3B,uBAAkB,GAAlB,kBAAkB,CAAU;QAP/B,aAAQ,GAAG,IAAA,SAAI,GAAE,CAAC;QACnC,8DAA8D;QACtD,sBAAiB,GAAG,CAAC,CAAC;QAO7B,sDAAsD;QACtD,IAAI,CAAC,WAAW,GAAG,IAAI,sBAAW,CAAC,EAAE,CAAC,CAAC;QAEvC,6FAA6F;QAC7F,IAAI,CAAC,4BAA4B,GAAG,IAAA,oCAAyB,EAAC,MAAM,CAAC,CAAC,MAAM,CAAC,UAAU,CACtF,qDAAqD,CACrD;YACA,CAAC,CAAC,CAAC;YACH,CAAC,CAAC,iCAAsB,CAAC;IAC3B,CAAC;IAED,+BAA+B;IACxB,QAAQ,CAAC,KAAa,EAAE,SAAkB,EAAE,SAA4B;QAC9E,IAAA,iBAAM,EAAC,IAA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,KAAK,CAAC,mBAAmB,CAAI,GAAG,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;IAC9E,CAAC;CACD;AA5HD,gEA4HC;AAUD,SAAgB,yBAAyB,CACxC,iBAAkC,EAClC,kBAAuC,EACvC,SAAqB,EACrB,MAA2B,EAC3B,kBAA4B;IAE5B,MAAM,YAAY,GAAG,IAAI,0BAA0B,CAClD,iBAAiB,EACjB,SAAS,EACT,MAAM,EACN,kBAAkB,CAClB,CAAC;IACF,OAAO;QACN,KAAK,EAAE;YACN,GAAG,kBAAkB;YACrB,cAAc,EAAE,YAAY;SAC5B;QACD,YAAY;KACZ,CAAC;AACH,CAAC;AApBD,8DAoBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, Deferred } from \"@fluidframework/core-utils/internal\";\nimport {\n\tLocationRedirectionError,\n\tNonRetryableError,\n\tRateLimiter,\n\tThrottlingError,\n} from \"@fluidframework/driver-utils/internal\";\nimport {\n\tICacheEntry,\n\tIEntry,\n\tIFileEntry,\n\tIOdspError,\n\tIOdspErrorAugmentations,\n\tIOdspResolvedUrl,\n\tIPersistedCache,\n\tOdspErrorTypes,\n\tmaximumCacheDurationMs,\n\tsnapshotKey,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tPerformanceEvent,\n\tisFluidError,\n\tloggerToMonitoringContext,\n\tnormalizeError,\n\twrapError,\n} from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport { IVersionedValueWithEpoch, persistedCacheValueVersion } from \"./contracts.js\";\nimport { ClpCompliantAppHeader } from \"./contractsPublic.js\";\nimport { INonPersistentCache, IOdspCache, IPersistedFileCache } from \"./odspCache.js\";\nimport { patchOdspResolvedUrl } from \"./odspLocationRedirection.js\";\nimport {\n\tIOdspResponse,\n\tfetchAndParseAsJSONHelper,\n\tfetchArray,\n\tfetchHelper,\n\tgetOdspResolvedUrl,\n} from \"./odspUtils.js\";\nimport { pkgVersion as driverVersion } from \"./packageVersion.js\";\n\n/**\n * @alpha\n */\nexport type FetchType =\n\t| \"blob\"\n\t| \"createBlob\"\n\t| \"createFile\"\n\t| \"joinSession\"\n\t| \"ops\"\n\t| \"test\"\n\t| \"snapshotTree\"\n\t| \"treesLatest\"\n\t| \"uploadSummary\"\n\t| \"push\"\n\t| \"versions\";\n\n/**\n * @alpha\n */\nexport type FetchTypeInternal = FetchType | \"cache\";\n\nexport const Odsp409Error = \"Odsp409Error\";\n\n/**\n * In ODSP, the concept of \"epoch\" refers to binary updates to files. For example, this might include using\n * version restore, or if the user downloads a Fluid file and then uploads it again. These result in the epoch\n * value being incremented.\n *\n * The implications of these binary updates is that the Fluid state is disrupted: the sequence number might\n * go backwards, the data might be inconsistent with the latest state of collaboration, etc. As a result, it's\n * not safe to continue collaboration across an epoch change. We need to detect these epoch changes and\n * error out from the collaboration.\n *\n * This class is a wrapper around fetch calls. It adds epoch to the request made so that the\n * server can match it with its epoch value in order to match the version.\n * It also validates the epoch value received in response of fetch calls. If the epoch does not match,\n * then it also clears all the cached entries for the given container.\n * @alpha\n */\nexport class EpochTracker implements IPersistedFileCache {\n\tprivate _fluidEpoch: string | undefined;\n\n\tprivate readonly snapshotCacheExpiryTimeoutMs: number;\n\tpublic readonly rateLimiter: RateLimiter;\n\tprivate readonly driverId = uuid();\n\t// This tracks the request number made by the driver instance.\n\tprivate networkCallNumber = 1;\n\tconstructor(\n\t\tprotected readonly cache: IPersistedCache,\n\t\tprotected readonly fileEntry: IFileEntry,\n\t\tprotected readonly logger: ITelemetryLoggerExt,\n\t\tprotected readonly clientIsSummarizer?: boolean,\n\t) {\n\t\t// Limits the max number of concurrent requests to 24.\n\t\tthis.rateLimiter = new RateLimiter(24);\n\n\t\t// Matches the TestOverride logic for the policy defined in odspDocumentStorageServiceBase.ts\n\t\tthis.snapshotCacheExpiryTimeoutMs = loggerToMonitoringContext(logger).config.getBoolean(\n\t\t\t\"Fluid.Driver.Odsp.TestOverride.DisableSnapshotCache\",\n\t\t)\n\t\t\t? 0\n\t\t\t: maximumCacheDurationMs;\n\t}\n\n\t// public for UT purposes only!\n\tpublic setEpoch(epoch: string, fromCache: boolean, fetchType: FetchTypeInternal): void {\n\t\tassert(this._fluidEpoch === undefined, 0x1db /* \"epoch exists\" */);\n\t\tthis._fluidEpoch = epoch;\n\n\t\tthis.logger.sendTelemetryEvent({\n\t\t\teventName: \"EpochLearnedFirstTime\",\n\t\t\tepoch,\n\t\t\tfetchType,\n\t\t\tfromCache,\n\t\t});\n\t}\n\n\t// TODO: return a stronger type\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic async get(entry: IEntry): Promise<any> {\n\t\ttry {\n\t\t\t// Return undefined so that the ops/snapshots are grabbed from the server instead of the cache\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\tconst value: IVersionedValueWithEpoch = await this.cache.get(\n\t\t\t\tthis.fileEntryFromEntry(entry),\n\t\t\t);\n\t\t\t// Version mismatch between what the runtime expects and what it recieved.\n\t\t\t// The cached value should not be used\n\t\t\tif (value === undefined || value.version !== persistedCacheValueVersion) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tassert(value.fluidEpoch !== undefined, 0x1dc /* \"all entries have to have epoch\" */);\n\t\t\tif (this._fluidEpoch === undefined) {\n\t\t\t\tthis.setEpoch(value.fluidEpoch, true, \"cache\");\n\t\t\t\t// Epoch mismatch, the cached value is considerably different from what the current state of\n\t\t\t\t// the runtime and should not be used\n\t\t\t} else if (this._fluidEpoch !== value.fluidEpoch) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\t// Expire the cached snapshot if it's older than snapshotCacheExpiryTimeoutMs and immediately\n\t\t\t// expire all old caches that do not have cacheEntryTime\n\t\t\tif (entry.type === snapshotKey) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n\t\t\t\tconst cacheTime = value.value?.cacheEntryTime;\n\t\t\t\tconst currentTime = Date.now();\n\t\t\t\tif (\n\t\t\t\t\tcacheTime === undefined ||\n\t\t\t\t\tcurrentTime - cacheTime >= this.snapshotCacheExpiryTimeoutMs\n\t\t\t\t) {\n\t\t\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\t\t\teventName: \"odspVersionsCacheExpired\",\n\t\t\t\t\t\tduration: currentTime - cacheTime,\n\t\t\t\t\t\tmaxCacheAgeMs: this.snapshotCacheExpiryTimeoutMs,\n\t\t\t\t\t});\n\t\t\t\t\tawait this.removeEntries();\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\t\treturn value.value;\n\t\t} catch (error) {\n\t\t\tthis.logger.sendErrorEvent({ eventName: \"cacheFetchError\", type: entry.type }, error);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t// TODO: take a stronger type or `unknown`\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any\n\tpublic async put(entry: IEntry, value: any): Promise<void> {\n\t\tassert(this._fluidEpoch !== undefined, 0x1dd /* \"no epoch\" */);\n\t\t// For snapshots, the value should have the cacheEntryTime.\n\t\t// This will be used to expire snapshots older than snapshotCacheExpiryTimeoutMs.\n\t\tif (entry.type === snapshotKey) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n\t\t\tvalue.cacheEntryTime = value.cacheEntryTime ?? Date.now();\n\t\t}\n\t\tconst data: IVersionedValueWithEpoch = {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\tvalue,\n\t\t\tversion: persistedCacheValueVersion,\n\t\t\tfluidEpoch: this._fluidEpoch,\n\t\t};\n\t\treturn this.cache.put(this.fileEntryFromEntry(entry), data).catch((error) => {\n\t\t\tthis.logger.sendErrorEvent({ eventName: \"cachePutError\", type: entry.type }, error);\n\t\t\tthrow error;\n\t\t});\n\t}\n\n\tpublic async removeEntries(): Promise<void> {\n\t\ttry {\n\t\t\treturn await this.cache.removeEntries(this.fileEntry);\n\t\t} catch (error) {\n\t\t\tthis.logger.sendErrorEvent({ eventName: \"removeCacheEntries\" }, error);\n\t\t}\n\t}\n\n\tpublic get fluidEpoch(): string | undefined {\n\t\treturn this._fluidEpoch;\n\t}\n\n\tpublic async validateEpoch(epoch: string | undefined, fetchType: FetchType): Promise<void> {\n\t\tassert(epoch !== undefined, 0x584 /* response should contain epoch */);\n\t\ttry {\n\t\t\tthis.validateEpochFromResponse(epoch, fetchType);\n\t\t} catch (error) {\n\t\t\tawait this.checkForEpochError(error, epoch, fetchType);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Api to fetch the response for given request and parse it as json.\n\t * @param url - url of the request\n\t * @param fetchOptions - fetch options for request containing body, headers etc.\n\t * @param fetchType - method for which fetch is called.\n\t * @param addInBody - Pass True if caller wants to add epoch in post body.\n\t * @param fetchReason - fetch reason to add to the request.\n\t */\n\tpublic async fetchAndParseAsJSON<T>(\n\t\turl: string,\n\t\tfetchOptions: RequestInit,\n\t\tfetchType: FetchType,\n\t\taddInBody: boolean = false,\n\t\tfetchReason?: string,\n\t): Promise<IOdspResponse<T>> {\n\t\treturn this.fetchCore<T>(\n\t\t\turl,\n\t\t\tfetchOptions,\n\t\t\tfetchAndParseAsJSONHelper,\n\t\t\tfetchType,\n\t\t\taddInBody,\n\t\t\tfetchReason,\n\t\t);\n\t}\n\n\t/**\n\t * Api to fetch the response for given request and parse it as json.\n\t * @param url - url of the request\n\t * @param fetchOptions - fetch options for request containing body, headers etc.\n\t * @param fetchType - method for which fetch is called.\n\t * @param addInBody - Pass True if caller wants to add epoch in post body.\n\t * @param fetchReason - fetch reason to add to the request.\n\t */\n\tpublic async fetch(\n\t\turl: string,\n\t\tfetchOptions: RequestInit,\n\t\tfetchType: FetchType,\n\t\taddInBody: boolean = false,\n\t\tfetchReason?: string,\n\t): Promise<IOdspResponse<Response>> {\n\t\treturn this.fetchCore<Response>(\n\t\t\turl,\n\t\t\tfetchOptions,\n\t\t\tfetchHelper,\n\t\t\tfetchType,\n\t\t\taddInBody,\n\t\t\tfetchReason,\n\t\t);\n\t}\n\n\tprivate async fetchCore<T>(\n\t\turl: string,\n\t\tfetchOptions: RequestInit,\n\t\tfetcher: (url: string, fetchOptions: RequestInit) => Promise<IOdspResponse<T>>,\n\t\tfetchType: FetchType,\n\t\taddInBody: boolean = false,\n\t\tfetchReason?: string,\n\t): Promise<IOdspResponse<T>> {\n\t\tconst clientCorrelationId = this.formatClientCorrelationId(fetchReason);\n\t\t// Add epoch in fetch request.\n\t\tthis.addEpochInRequest(fetchOptions, addInBody, clientCorrelationId);\n\t\tlet epochFromResponse: string | undefined;\n\t\treturn this.rateLimiter\n\t\t\t.schedule(async () => fetcher(url, fetchOptions))\n\t\t\t.then((response) => {\n\t\t\t\tepochFromResponse = response.headers.get(\"x-fluid-epoch\");\n\t\t\t\tthis.validateEpochFromResponse(epochFromResponse, fetchType);\n\t\t\t\tresponse.propsToLog.XRequestStatsHeader = clientCorrelationId;\n\t\t\t\treturn response;\n\t\t\t})\n\t\t\t.catch(async (error) => {\n\t\t\t\t// Get the server epoch from error in case we don't have it as if undefined we won't be able\n\t\t\t\t// to mark it as epoch error.\n\t\t\t\tif (epochFromResponse === undefined) {\n\t\t\t\t\tepochFromResponse = (error as IOdspError).serverEpoch;\n\t\t\t\t}\n\t\t\t\tawait this.checkForEpochError(error, epochFromResponse, fetchType);\n\t\t\t\tthrow error;\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\t// If the error is about location redirection, then we need to generate new resolved url with correct\n\t\t\t\t// location info.\n\t\t\t\tif (\n\t\t\t\t\tisFluidError(error) &&\n\t\t\t\t\terror.errorType === OdspErrorTypes.fileNotFoundOrAccessDeniedError\n\t\t\t\t) {\n\t\t\t\t\tconst redirectLocation = (error as IOdspErrorAugmentations).redirectLocation;\n\t\t\t\t\tif (redirectLocation !== undefined) {\n\t\t\t\t\t\tconst redirectUrl: IOdspResolvedUrl = patchOdspResolvedUrl(\n\t\t\t\t\t\t\tthis.fileEntry.resolvedUrl,\n\t\t\t\t\t\t\tredirectLocation,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst locationRedirectionError = new LocationRedirectionError(\n\t\t\t\t\t\t\terror.message,\n\t\t\t\t\t\t\tredirectUrl,\n\t\t\t\t\t\t\t{ driverVersion, redirectLocation },\n\t\t\t\t\t\t);\n\t\t\t\t\t\tlocationRedirectionError.addTelemetryProperties(error.getTelemetryProperties());\n\t\t\t\t\t\tthrow locationRedirectionError;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\tconst fluidError = normalizeError(error, {\n\t\t\t\t\tprops: { XRequestStatsHeader: clientCorrelationId },\n\t\t\t\t});\n\t\t\t\tthrow fluidError;\n\t\t\t});\n\t}\n\n\t/**\n\t * Api to fetch the response as it is for given request.\n\t * @param url - url of the request\n\t * @param fetchOptions - fetch options for request containing body, headers etc.\n\t * @param fetchType - method for which fetch is called.\n\t * @param addInBody - Pass True if caller wants to add epoch in post body.\n\t * @param fetchReason - fetch reason to add to the request.\n\t */\n\tpublic async fetchArray(\n\t\turl: string,\n\t\tfetchOptions: { [index: string]: RequestInit },\n\t\tfetchType: FetchType,\n\t\taddInBody: boolean = false,\n\t\tfetchReason?: string,\n\t): Promise<IOdspResponse<ArrayBuffer>> {\n\t\treturn this.fetchCore<ArrayBuffer>(\n\t\t\turl,\n\t\t\tfetchOptions,\n\t\t\tfetchArray,\n\t\t\tfetchType,\n\t\t\taddInBody,\n\t\t\tfetchReason,\n\t\t);\n\t}\n\n\tprivate addEpochInRequest(\n\t\tfetchOptions: RequestInit,\n\t\taddInBody: boolean,\n\t\tclientCorrelationId: string,\n\t): void {\n\t\tconst isClpCompliantApp = getOdspResolvedUrl(this.fileEntry.resolvedUrl).isClpCompliantApp;\n\t\tif (addInBody) {\n\t\t\tconst headers: { [key: string]: string } = {};\n\t\t\theaders[\"X-RequestStats\"] = clientCorrelationId;\n\t\t\tif (this.fluidEpoch !== undefined) {\n\t\t\t\theaders[\"x-fluid-epoch\"] = this.fluidEpoch;\n\t\t\t}\n\t\t\tif (isClpCompliantApp) {\n\t\t\t\theaders[ClpCompliantAppHeader.isClpCompliantApp] = isClpCompliantApp.toString();\n\t\t\t}\n\t\t\tthis.addParamInBody(fetchOptions, headers);\n\t\t} else {\n\t\t\tconst addHeader = (key: string, val: string): void => {\n\t\t\t\tfetchOptions.headers = {\n\t\t\t\t\t...fetchOptions.headers,\n\t\t\t\t};\n\t\t\t\tassert(\n\t\t\t\t\tfetchOptions.headers !== undefined,\n\t\t\t\t\t0x282 /* \"Headers should be present now\" */,\n\t\t\t\t);\n\t\t\t\tfetchOptions.headers[key] = val;\n\t\t\t};\n\t\t\taddHeader(\"X-RequestStats\", clientCorrelationId);\n\t\t\tif (this.fluidEpoch !== undefined) {\n\t\t\t\taddHeader(\"x-fluid-epoch\", this.fluidEpoch);\n\t\t\t}\n\t\t\tif (isClpCompliantApp) {\n\t\t\t\taddHeader(ClpCompliantAppHeader.isClpCompliantApp, isClpCompliantApp.toString());\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate addParamInBody(fetchOptions: RequestInit, headers: { [key: string]: string }): void {\n\t\t// We use multi part form request for post body where we want to use this.\n\t\t// So extract the form boundary to mark the end of form.\n\t\tconst body = fetchOptions.body;\n\t\tassert(typeof body === \"string\", 0x21d /* \"body is not string\" */);\n\t\tconst splitBody = body.split(\"\\r\\n\");\n\t\tconst firstLine = splitBody.shift();\n\t\tassert(firstLine?.startsWith(\"--\") === true, 0x21e /* \"improper boundary format\" */);\n\t\tconst formParams = [firstLine];\n\t\tfor (const [key, value] of Object.entries(headers)) {\n\t\t\tformParams.push(`${key}: ${value}`);\n\t\t}\n\t\tfor (const value of splitBody) {\n\t\t\tformParams.push(value);\n\t\t}\n\t\tfetchOptions.body = formParams.join(\"\\r\\n\");\n\t}\n\n\tprivate formatClientCorrelationId(fetchReason?: string): string {\n\t\tconst items: string[] = [\n\t\t\t`driverId=${this.driverId}`,\n\t\t\t`RequestNumber=${this.networkCallNumber++}`,\n\t\t\t`driverVersion=${driverVersion}`,\n\t\t\t`isSummarizer=${this.clientIsSummarizer}`,\n\t\t];\n\t\tif (fetchReason !== undefined) {\n\t\t\titems.push(`fetchReason=${fetchReason}`);\n\t\t}\n\t\treturn items.join(\", \");\n\t}\n\n\tprotected validateEpochFromResponse(\n\t\tepochFromResponse: string | undefined,\n\t\tfetchType: FetchTypeInternal,\n\t\tfromCache: boolean = false,\n\t): void {\n\t\tconst error = this.checkForEpochErrorCore(epochFromResponse);\n\t\tif (error !== undefined) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (epochFromResponse !== undefined && this._fluidEpoch === undefined) {\n\t\t\tthis.setEpoch(epochFromResponse, fromCache, fetchType);\n\t\t}\n\t}\n\n\tprivate async checkForEpochError(\n\t\terror: unknown,\n\t\tepochFromResponse: string | null | undefined,\n\t\tfetchType: FetchTypeInternal,\n\t\tfromCache: boolean = false,\n\t): Promise<void> {\n\t\tif (isFluidError(error) && error.errorType === OdspErrorTypes.fileOverwrittenInStorage) {\n\t\t\tconst epochError = this.checkForEpochErrorCore(epochFromResponse);\n\t\t\tif (epochError !== undefined) {\n\t\t\t\tepochError.addTelemetryProperties({\n\t\t\t\t\tfromCache,\n\t\t\t\t\tfetchType,\n\t\t\t\t});\n\t\t\t\tthis.logger.sendErrorEvent({ eventName: \"fileOverwrittenInStorage\" }, epochError);\n\t\t\t\t// If the epoch mismatches, then clear all entries for such file entry from cache.\n\t\t\t\tawait this.removeEntries();\n\t\t\t\tthrow epochError;\n\t\t\t}\n\t\t\t// If it was categorized as epoch error but the epoch returned in response matches with the client epoch\n\t\t\t// then it was coherency 409, so rethrow it as throttling error so that it can retried. Default throttling\n\t\t\t// time is 1s.\n\t\t\tconst newError = wrapError(error, (message: string) => {\n\t\t\t\treturn new ThrottlingError(`Coherency 409: ${message}`, 1 /* retryAfterSeconds */, {\n\t\t\t\t\t[Odsp409Error]: true,\n\t\t\t\t\tdriverVersion,\n\t\t\t\t});\n\t\t\t});\n\t\t\tthrow newError;\n\t\t}\n\t}\n\n\tprivate checkForEpochErrorCore(\n\t\tepochFromResponse: string | null | undefined,\n\t): NonRetryableError<\"fileOverwrittenInStorage\"> | undefined {\n\t\t// If epoch is undefined, then don't compare it because initially for createNew or TreesLatest\n\t\t// initializes this value. Sometimes response does not contain epoch as it is still in\n\t\t// implementation phase at server side. In that case also, don't compare it with our epoch value.\n\t\tif (this.fluidEpoch && epochFromResponse && this.fluidEpoch !== epochFromResponse) {\n\t\t\t// This is similar in nature to how fluidEpochMismatchError (409) is handled.\n\t\t\t// Difference - client detected mismatch, instead of server detecting it.\n\t\t\treturn new NonRetryableError(\"Epoch mismatch\", OdspErrorTypes.fileOverwrittenInStorage, {\n\t\t\t\tdriverVersion,\n\t\t\t\tserverEpoch: epochFromResponse,\n\t\t\t\tclientEpoch: this.fluidEpoch,\n\t\t\t});\n\t\t}\n\t}\n\n\tprivate fileEntryFromEntry(entry: IEntry): ICacheEntry {\n\t\treturn { ...entry, file: this.fileEntry };\n\t}\n}\n\nexport class EpochTrackerWithRedemption extends EpochTracker {\n\tprivate readonly treesLatestDeferral = new Deferred<void>();\n\n\tconstructor(\n\t\tprotected readonly cache: IPersistedCache,\n\t\tprotected readonly fileEntry: IFileEntry,\n\t\tprotected readonly logger: ITelemetryLoggerExt,\n\t\tprotected readonly clientIsSummarizer?: boolean,\n\t) {\n\t\tsuper(cache, fileEntry, logger, clientIsSummarizer);\n\t\t// Handles the rejected promise within treesLatestDeferral.\n\t\tthis.treesLatestDeferral.promise.catch(() => {});\n\t}\n\n\tprotected validateEpochFromResponse(\n\t\tepochFromResponse: string | undefined,\n\t\tfetchType: FetchType,\n\t\tfromCache: boolean = false,\n\t): void {\n\t\tsuper.validateEpochFromResponse(epochFromResponse, fetchType, fromCache);\n\n\t\t// Any successful call means we have access to a file, i.e. any redemption that was required already happened.\n\t\t// That covers cases of \"treesLatest\" as well as \"getVersions\" or \"createFile\" - all the ways we can start\n\t\t// exploring a file.\n\t\tthis.treesLatestDeferral.resolve();\n\t}\n\n\t// TODO: return a stronger type\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic async get(entry: IEntry): Promise<any> {\n\t\tlet result = super.get(entry);\n\n\t\t// equivalence of what happens in fetchAndParseAsJSON()\n\t\tif (entry.type === snapshotKey) {\n\t\t\tresult = result\n\t\t\t\t.then((value) => {\n\t\t\t\t\t// If there is nothing in cache, we need to wait for network call to complete (and do redemption)\n\t\t\t\t\t// Otherwise file was redeemed in prior session, so if joinSession failed, we should not retry\n\t\t\t\t\tif (value !== undefined) {\n\t\t\t\t\t\tthis.treesLatestDeferral.resolve();\n\t\t\t\t\t}\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\t\t\t\treturn value;\n\t\t\t\t})\n\t\t\t\t.catch((error) => {\n\t\t\t\t\tthis.treesLatestDeferral.reject(error);\n\t\t\t\t\tthrow error;\n\t\t\t\t});\n\t\t}\n\t\treturn result;\n\t}\n\n\tpublic async fetchAndParseAsJSON<T>(\n\t\turl: string,\n\t\tfetchOptions: { [index: string]: RequestInit },\n\t\tfetchType: FetchType,\n\t\taddInBody: boolean = false,\n\t\tfetchReason?: string,\n\t): Promise<IOdspResponse<T>> {\n\t\t// Optimize the flow if we know that treesLatestDeferral was already completed by the timer we started\n\t\t// joinSession call. If we did - there is no reason to repeat the call as it will fail with same error.\n\t\tconst completed = this.treesLatestDeferral.isCompleted;\n\n\t\ttry {\n\t\t\treturn await super.fetchAndParseAsJSON<T>(\n\t\t\t\turl,\n\t\t\t\tfetchOptions,\n\t\t\t\tfetchType,\n\t\t\t\taddInBody,\n\t\t\t\tfetchReason,\n\t\t\t);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t} catch (error: any) {\n\t\t\t// Only handling here treesLatest. If createFile failed, we should never try to do joinSession.\n\t\t\t// Similar, if getVersions failed, we should not do any further storage calls.\n\t\t\t// So treesLatest is the only call that can have parallel joinSession request.\n\t\t\tif (fetchType === \"treesLatest\") {\n\t\t\t\tthis.treesLatestDeferral.reject(error);\n\t\t\t}\n\t\t\tif (\n\t\t\t\tfetchType !== \"joinSession\" ||\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\t\terror.statusCode < 401 ||\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\t\terror.statusCode > 404 ||\n\t\t\t\tcompleted\n\t\t\t) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\n\t\t// It is joinSession failing with 401..404 error\n\t\t// Repeat after waiting for treeLatest succeeding (or fail if it failed).\n\t\t// No special handling after first call - if file has been deleted, then it's game over.\n\n\t\t// Ensure we have some safety here - we do not want to deadlock if we got logic somewhere wrong.\n\t\t// If we waited too long, we will log error event and proceed with call.\n\t\t// It may result in failure for user, but refreshing document would address it.\n\t\t// Thus we use rather long timeout (not to get these failures as much as possible), but not large enough\n\t\t// to unblock the process.\n\t\tawait PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{ eventName: \"JoinSessionSyncWait\" },\n\t\t\tasync (event) => {\n\t\t\t\tconst timeoutRes = 51; // anything will work here\n\t\t\t\tlet timer: ReturnType<typeof setTimeout>;\n\t\t\t\tconst timeoutP = new Promise<number>((resolve) => {\n\t\t\t\t\ttimer = setTimeout(() => {\n\t\t\t\t\t\tresolve(timeoutRes);\n\t\t\t\t\t}, 15000);\n\t\t\t\t});\n\t\t\t\tconst res = await Promise.race([\n\t\t\t\t\ttimeoutP,\n\t\t\t\t\t// cancel timeout to unblock UTs (otherwise Node process does not exit for 15 sec)\n\t\t\t\t\tthis.treesLatestDeferral.promise.finally(() => clearTimeout(timer)),\n\t\t\t\t]);\n\t\t\t\tif (res === timeoutRes) {\n\t\t\t\t\tevent.cancel();\n\t\t\t\t}\n\t\t\t},\n\t\t\t{ start: true, end: true, cancel: \"generic\" },\n\t\t);\n\t\treturn super.fetchAndParseAsJSON<T>(url, fetchOptions, fetchType, addInBody);\n\t}\n}\n\n/**\n * @alpha\n */\nexport interface ICacheAndTracker {\n\tcache: IOdspCache;\n\tepochTracker: EpochTracker;\n}\n\nexport function createOdspCacheAndTracker(\n\tpersistedCacheArg: IPersistedCache,\n\tnonpersistentCache: INonPersistentCache,\n\tfileEntry: IFileEntry,\n\tlogger: ITelemetryLoggerExt,\n\tclientIsSummarizer?: boolean,\n): ICacheAndTracker {\n\tconst epochTracker = new EpochTrackerWithRedemption(\n\t\tpersistedCacheArg,\n\t\tfileEntry,\n\t\tlogger,\n\t\tclientIsSummarizer,\n\t);\n\treturn {\n\t\tcache: {\n\t\t\t...nonpersistentCache,\n\t\t\tpersistedCache: epochTracker,\n\t\t},\n\t\tepochTracker,\n\t};\n}\n"]}
1
+ {"version":3,"file":"epochTracker.js","sourceRoot":"","sources":["../src/epochTracker.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAuE;AACvE,oEAK+C;AAC/C,+EAY0D;AAC1D,uEAOkD;AAClD,+BAAkC;AAElC,iDAAsF;AACtF,6DAA6D;AAE7D,6EAAoE;AACpE,iDAMwB;AACxB,2DAAkE;AAuBrD,QAAA,YAAY,GAAG,cAAc,CAAC;AAE3C;;;;;;;;;;;;;;;GAeG;AACH,MAAa,YAAY;IAQxB,YACoB,KAAsB,EACtB,SAAqB,EACrB,MAA2B,EAC3B,kBAA4B;QAH5B,UAAK,GAAL,KAAK,CAAiB;QACtB,cAAS,GAAT,SAAS,CAAY;QACrB,WAAM,GAAN,MAAM,CAAqB;QAC3B,uBAAkB,GAAlB,kBAAkB,CAAU;QAP/B,aAAQ,GAAG,IAAA,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AChD,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;oBACvB,OAAO,CAAC,UAAU,CAAC,CAAC;gBACrB,CAAC,EAAE,KAAK,CAAC,CAAC;YACX,CAAC,CAAC,CAAC;YACH,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC;gBAC9B,QAAQ;gBACR,kFAAkF;gBAClF,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;aACnE,CAAC,CAAC;YACH,IAAI,GAAG,KAAK,UAAU,EAAE,CAAC;gBACxB,KAAK,CAAC,MAAM,EAAE,CAAC;YAChB,CAAC;QACF,CAAC,EACD,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,CAC7C,CAAC;QACF,OAAO,KAAK,CAAC,mBAAmB,CAAI,GAAG,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;IAC9E,CAAC;CACD;AA5HD,gEA4HC;AAUD,SAAgB,yBAAyB,CACxC,iBAAkC,EAClC,kBAAuC,EACvC,SAAqB,EACrB,MAA2B,EAC3B,kBAA4B;IAE5B,MAAM,YAAY,GAAG,IAAI,0BAA0B,CAClD,iBAAiB,EACjB,SAAS,EACT,MAAM,EACN,kBAAkB,CAClB,CAAC;IACF,OAAO;QACN,KAAK,EAAE;YACN,GAAG,kBAAkB;YACrB,cAAc,EAAE,YAAY;SAC5B;QACD,YAAY;KACZ,CAAC;AACH,CAAC;AApBD,8DAoBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, Deferred } from \"@fluidframework/core-utils/internal\";\nimport {\n\tLocationRedirectionError,\n\tNonRetryableError,\n\tRateLimiter,\n\tThrottlingError,\n} from \"@fluidframework/driver-utils/internal\";\nimport {\n\tICacheEntry,\n\tIEntry,\n\tIFileEntry,\n\tIOdspError,\n\tIOdspErrorAugmentations,\n\tIOdspResolvedUrl,\n\tIPersistedCache,\n\tOdspErrorTypes,\n\tmaximumCacheDurationMs,\n\tsnapshotKey,\n\tsnapshotWithLoadingGroupIdKey,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tPerformanceEvent,\n\tisFluidError,\n\tloggerToMonitoringContext,\n\tnormalizeError,\n\twrapError,\n} from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport { IVersionedValueWithEpoch, persistedCacheValueVersion } from \"./contracts.js\";\nimport { ClpCompliantAppHeader } from \"./contractsPublic.js\";\nimport { INonPersistentCache, IOdspCache, IPersistedFileCache } from \"./odspCache.js\";\nimport { patchOdspResolvedUrl } from \"./odspLocationRedirection.js\";\nimport {\n\tIOdspResponse,\n\tfetchAndParseAsJSONHelper,\n\tfetchArray,\n\tfetchHelper,\n\tgetOdspResolvedUrl,\n} from \"./odspUtils.js\";\nimport { pkgVersion as driverVersion } from \"./packageVersion.js\";\n\n/**\n * @alpha\n */\nexport type FetchType =\n\t| \"blob\"\n\t| \"createBlob\"\n\t| \"createFile\"\n\t| \"joinSession\"\n\t| \"ops\"\n\t| \"test\"\n\t| \"snapshotTree\"\n\t| \"treesLatest\"\n\t| \"uploadSummary\"\n\t| \"push\"\n\t| \"versions\";\n\n/**\n * @alpha\n */\nexport type FetchTypeInternal = FetchType | \"cache\";\n\nexport const Odsp409Error = \"Odsp409Error\";\n\n/**\n * In ODSP, the concept of \"epoch\" refers to binary updates to files. For example, this might include using\n * version restore, or if the user downloads a Fluid file and then uploads it again. These result in the epoch\n * value being incremented.\n *\n * The implications of these binary updates is that the Fluid state is disrupted: the sequence number might\n * go backwards, the data might be inconsistent with the latest state of collaboration, etc. As a result, it's\n * not safe to continue collaboration across an epoch change. We need to detect these epoch changes and\n * error out from the collaboration.\n *\n * This class is a wrapper around fetch calls. It adds epoch to the request made so that the\n * server can match it with its epoch value in order to match the version.\n * It also validates the epoch value received in response of fetch calls. If the epoch does not match,\n * then it also clears all the cached entries for the given container.\n * @alpha\n */\nexport class EpochTracker implements IPersistedFileCache {\n\tprivate _fluidEpoch: string | undefined;\n\n\tprivate readonly snapshotCacheExpiryTimeoutMs: number;\n\tpublic readonly rateLimiter: RateLimiter;\n\tprivate readonly driverId = uuid();\n\t// This tracks the request number made by the driver instance.\n\tprivate networkCallNumber = 1;\n\tconstructor(\n\t\tprotected readonly cache: IPersistedCache,\n\t\tprotected readonly fileEntry: IFileEntry,\n\t\tprotected readonly logger: ITelemetryLoggerExt,\n\t\tprotected readonly clientIsSummarizer?: boolean,\n\t) {\n\t\t// Limits the max number of concurrent requests to 24.\n\t\tthis.rateLimiter = new RateLimiter(24);\n\n\t\t// Matches the TestOverride logic for the policy defined in odspDocumentStorageServiceBase.ts\n\t\tthis.snapshotCacheExpiryTimeoutMs = loggerToMonitoringContext(logger).config.getBoolean(\n\t\t\t\"Fluid.Driver.Odsp.TestOverride.DisableSnapshotCache\",\n\t\t)\n\t\t\t? 0\n\t\t\t: maximumCacheDurationMs;\n\t}\n\n\t// public for UT purposes only!\n\tpublic setEpoch(epoch: string, fromCache: boolean, fetchType: FetchTypeInternal): void {\n\t\tassert(this._fluidEpoch === undefined, 0x1db /* \"epoch exists\" */);\n\t\tthis._fluidEpoch = epoch;\n\n\t\tthis.logger.sendTelemetryEvent({\n\t\t\teventName: \"EpochLearnedFirstTime\",\n\t\t\tepoch,\n\t\t\tfetchType,\n\t\t\tfromCache,\n\t\t});\n\t}\n\n\t// TODO: return a stronger type\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic async get(entry: IEntry): Promise<any> {\n\t\ttry {\n\t\t\t// Return undefined so that the ops/snapshots are grabbed from the server instead of the cache\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\tconst value: IVersionedValueWithEpoch = await this.cache.get(\n\t\t\t\tthis.fileEntryFromEntry(entry),\n\t\t\t);\n\t\t\t// Version mismatch between what the runtime expects and what it recieved.\n\t\t\t// The cached value should not be used\n\t\t\tif (value === undefined || value.version !== persistedCacheValueVersion) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tassert(value.fluidEpoch !== undefined, 0x1dc /* \"all entries have to have epoch\" */);\n\t\t\tif (this._fluidEpoch === undefined) {\n\t\t\t\tthis.setEpoch(value.fluidEpoch, true, \"cache\");\n\t\t\t\t// Epoch mismatch, the cached value is considerably different from what the current state of\n\t\t\t\t// the runtime and should not be used\n\t\t\t} else if (this._fluidEpoch !== value.fluidEpoch) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\t// Expire the cached snapshot if it's older than snapshotCacheExpiryTimeoutMs and immediately\n\t\t\t// expire all old caches that do not have cacheEntryTime\n\t\t\tif (entry.type === snapshotKey || entry.type === snapshotWithLoadingGroupIdKey) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n\t\t\t\tconst cacheTime = value.value?.cacheEntryTime;\n\t\t\t\tconst currentTime = Date.now();\n\t\t\t\tif (\n\t\t\t\t\tcacheTime === undefined ||\n\t\t\t\t\tcurrentTime - cacheTime >= this.snapshotCacheExpiryTimeoutMs\n\t\t\t\t) {\n\t\t\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\t\t\teventName: \"odspVersionsCacheExpired\",\n\t\t\t\t\t\tduration: currentTime - cacheTime,\n\t\t\t\t\t\tmaxCacheAgeMs: this.snapshotCacheExpiryTimeoutMs,\n\t\t\t\t\t});\n\t\t\t\t\tawait this.removeEntries();\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\t\treturn value.value;\n\t\t} catch (error) {\n\t\t\tthis.logger.sendErrorEvent({ eventName: \"cacheFetchError\", type: entry.type }, error);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t// TODO: take a stronger type or `unknown`\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any\n\tpublic async put(entry: IEntry, value: any): Promise<void> {\n\t\tassert(this._fluidEpoch !== undefined, 0x1dd /* \"no epoch\" */);\n\t\t// For snapshots, the value should have the cacheEntryTime.\n\t\t// This will be used to expire snapshots older than snapshotCacheExpiryTimeoutMs.\n\t\tif (entry.type === snapshotKey || entry.type === snapshotWithLoadingGroupIdKey) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n\t\t\tvalue.cacheEntryTime = value.cacheEntryTime ?? Date.now();\n\t\t}\n\t\tconst data: IVersionedValueWithEpoch = {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\tvalue,\n\t\t\tversion: persistedCacheValueVersion,\n\t\t\tfluidEpoch: this._fluidEpoch,\n\t\t};\n\t\treturn this.cache.put(this.fileEntryFromEntry(entry), data).catch((error) => {\n\t\t\tthis.logger.sendErrorEvent({ eventName: \"cachePutError\", type: entry.type }, error);\n\t\t\tthrow error;\n\t\t});\n\t}\n\n\tpublic async removeEntries(): Promise<void> {\n\t\ttry {\n\t\t\treturn await this.cache.removeEntries(this.fileEntry);\n\t\t} catch (error) {\n\t\t\tthis.logger.sendErrorEvent({ eventName: \"removeCacheEntries\" }, error);\n\t\t}\n\t}\n\n\tpublic get fluidEpoch(): string | undefined {\n\t\treturn this._fluidEpoch;\n\t}\n\n\tpublic async validateEpoch(epoch: string | undefined, fetchType: FetchType): Promise<void> {\n\t\tassert(epoch !== undefined, 0x584 /* response should contain epoch */);\n\t\ttry {\n\t\t\tthis.validateEpochFromResponse(epoch, fetchType);\n\t\t} catch (error) {\n\t\t\tawait this.checkForEpochError(error, epoch, fetchType);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Api to fetch the response for given request and parse it as json.\n\t * @param url - url of the request\n\t * @param fetchOptions - fetch options for request containing body, headers etc.\n\t * @param fetchType - method for which fetch is called.\n\t * @param addInBody - Pass True if caller wants to add epoch in post body.\n\t * @param fetchReason - fetch reason to add to the request.\n\t */\n\tpublic async fetchAndParseAsJSON<T>(\n\t\turl: string,\n\t\tfetchOptions: RequestInit,\n\t\tfetchType: FetchType,\n\t\taddInBody: boolean = false,\n\t\tfetchReason?: string,\n\t): Promise<IOdspResponse<T>> {\n\t\treturn this.fetchCore<T>(\n\t\t\turl,\n\t\t\tfetchOptions,\n\t\t\tfetchAndParseAsJSONHelper,\n\t\t\tfetchType,\n\t\t\taddInBody,\n\t\t\tfetchReason,\n\t\t);\n\t}\n\n\t/**\n\t * Api to fetch the response for given request and parse it as json.\n\t * @param url - url of the request\n\t * @param fetchOptions - fetch options for request containing body, headers etc.\n\t * @param fetchType - method for which fetch is called.\n\t * @param addInBody - Pass True if caller wants to add epoch in post body.\n\t * @param fetchReason - fetch reason to add to the request.\n\t */\n\tpublic async fetch(\n\t\turl: string,\n\t\tfetchOptions: RequestInit,\n\t\tfetchType: FetchType,\n\t\taddInBody: boolean = false,\n\t\tfetchReason?: string,\n\t): Promise<IOdspResponse<Response>> {\n\t\treturn this.fetchCore<Response>(\n\t\t\turl,\n\t\t\tfetchOptions,\n\t\t\tfetchHelper,\n\t\t\tfetchType,\n\t\t\taddInBody,\n\t\t\tfetchReason,\n\t\t);\n\t}\n\n\tprivate async fetchCore<T>(\n\t\turl: string,\n\t\tfetchOptions: RequestInit,\n\t\tfetcher: (url: string, fetchOptions: RequestInit) => Promise<IOdspResponse<T>>,\n\t\tfetchType: FetchType,\n\t\taddInBody: boolean = false,\n\t\tfetchReason?: string,\n\t): Promise<IOdspResponse<T>> {\n\t\tconst clientCorrelationId = this.formatClientCorrelationId(fetchReason);\n\t\t// Add epoch in fetch request.\n\t\tthis.addEpochInRequest(fetchOptions, addInBody, clientCorrelationId);\n\t\tlet epochFromResponse: string | undefined;\n\t\treturn this.rateLimiter\n\t\t\t.schedule(async () => fetcher(url, fetchOptions))\n\t\t\t.then((response) => {\n\t\t\t\tepochFromResponse = response.headers.get(\"x-fluid-epoch\");\n\t\t\t\tthis.validateEpochFromResponse(epochFromResponse, fetchType);\n\t\t\t\tresponse.propsToLog.XRequestStatsHeader = clientCorrelationId;\n\t\t\t\treturn response;\n\t\t\t})\n\t\t\t.catch(async (error) => {\n\t\t\t\t// Get the server epoch from error in case we don't have it as if undefined we won't be able\n\t\t\t\t// to mark it as epoch error.\n\t\t\t\tif (epochFromResponse === undefined) {\n\t\t\t\t\tepochFromResponse = (error as IOdspError).serverEpoch;\n\t\t\t\t}\n\t\t\t\tawait this.checkForEpochError(error, epochFromResponse, fetchType);\n\t\t\t\tthrow error;\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\t// If the error is about location redirection, then we need to generate new resolved url with correct\n\t\t\t\t// location info.\n\t\t\t\tif (\n\t\t\t\t\tisFluidError(error) &&\n\t\t\t\t\terror.errorType === OdspErrorTypes.fileNotFoundOrAccessDeniedError\n\t\t\t\t) {\n\t\t\t\t\tconst redirectLocation = (error as IOdspErrorAugmentations).redirectLocation;\n\t\t\t\t\tif (redirectLocation !== undefined) {\n\t\t\t\t\t\tconst redirectUrl: IOdspResolvedUrl = patchOdspResolvedUrl(\n\t\t\t\t\t\t\tthis.fileEntry.resolvedUrl,\n\t\t\t\t\t\t\tredirectLocation,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst locationRedirectionError = new LocationRedirectionError(\n\t\t\t\t\t\t\terror.message,\n\t\t\t\t\t\t\tredirectUrl,\n\t\t\t\t\t\t\t{ driverVersion, redirectLocation },\n\t\t\t\t\t\t);\n\t\t\t\t\t\tlocationRedirectionError.addTelemetryProperties(error.getTelemetryProperties());\n\t\t\t\t\t\tthrow locationRedirectionError;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\tconst fluidError = normalizeError(error, {\n\t\t\t\t\tprops: { XRequestStatsHeader: clientCorrelationId },\n\t\t\t\t});\n\t\t\t\tthrow fluidError;\n\t\t\t});\n\t}\n\n\t/**\n\t * Api to fetch the response as it is for given request.\n\t * @param url - url of the request\n\t * @param fetchOptions - fetch options for request containing body, headers etc.\n\t * @param fetchType - method for which fetch is called.\n\t * @param addInBody - Pass True if caller wants to add epoch in post body.\n\t * @param fetchReason - fetch reason to add to the request.\n\t */\n\tpublic async fetchArray(\n\t\turl: string,\n\t\tfetchOptions: { [index: string]: RequestInit },\n\t\tfetchType: FetchType,\n\t\taddInBody: boolean = false,\n\t\tfetchReason?: string,\n\t): Promise<IOdspResponse<ArrayBuffer>> {\n\t\treturn this.fetchCore<ArrayBuffer>(\n\t\t\turl,\n\t\t\tfetchOptions,\n\t\t\tfetchArray,\n\t\t\tfetchType,\n\t\t\taddInBody,\n\t\t\tfetchReason,\n\t\t);\n\t}\n\n\tprivate addEpochInRequest(\n\t\tfetchOptions: RequestInit,\n\t\taddInBody: boolean,\n\t\tclientCorrelationId: string,\n\t): void {\n\t\tconst isClpCompliantApp = getOdspResolvedUrl(this.fileEntry.resolvedUrl).isClpCompliantApp;\n\t\tif (addInBody) {\n\t\t\tconst headers: { [key: string]: string } = {};\n\t\t\theaders[\"X-RequestStats\"] = clientCorrelationId;\n\t\t\tif (this.fluidEpoch !== undefined) {\n\t\t\t\theaders[\"x-fluid-epoch\"] = this.fluidEpoch;\n\t\t\t}\n\t\t\tif (isClpCompliantApp) {\n\t\t\t\theaders[ClpCompliantAppHeader.isClpCompliantApp] = isClpCompliantApp.toString();\n\t\t\t}\n\t\t\tthis.addParamInBody(fetchOptions, headers);\n\t\t} else {\n\t\t\tconst addHeader = (key: string, val: string): void => {\n\t\t\t\tfetchOptions.headers = {\n\t\t\t\t\t...fetchOptions.headers,\n\t\t\t\t};\n\t\t\t\tassert(\n\t\t\t\t\tfetchOptions.headers !== undefined,\n\t\t\t\t\t0x282 /* \"Headers should be present now\" */,\n\t\t\t\t);\n\t\t\t\tfetchOptions.headers[key] = val;\n\t\t\t};\n\t\t\taddHeader(\"X-RequestStats\", clientCorrelationId);\n\t\t\tif (this.fluidEpoch !== undefined) {\n\t\t\t\taddHeader(\"x-fluid-epoch\", this.fluidEpoch);\n\t\t\t}\n\t\t\tif (isClpCompliantApp) {\n\t\t\t\taddHeader(ClpCompliantAppHeader.isClpCompliantApp, isClpCompliantApp.toString());\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate addParamInBody(fetchOptions: RequestInit, headers: { [key: string]: string }): void {\n\t\t// We use multi part form request for post body where we want to use this.\n\t\t// So extract the form boundary to mark the end of form.\n\t\tconst body = fetchOptions.body;\n\t\tassert(typeof body === \"string\", 0x21d /* \"body is not string\" */);\n\t\tconst splitBody = body.split(\"\\r\\n\");\n\t\tconst firstLine = splitBody.shift();\n\t\tassert(firstLine?.startsWith(\"--\") === true, 0x21e /* \"improper boundary format\" */);\n\t\tconst formParams = [firstLine];\n\t\tfor (const [key, value] of Object.entries(headers)) {\n\t\t\tformParams.push(`${key}: ${value}`);\n\t\t}\n\t\tfor (const value of splitBody) {\n\t\t\tformParams.push(value);\n\t\t}\n\t\tfetchOptions.body = formParams.join(\"\\r\\n\");\n\t}\n\n\tprivate formatClientCorrelationId(fetchReason?: string): string {\n\t\tconst items: string[] = [\n\t\t\t`driverId=${this.driverId}`,\n\t\t\t`RequestNumber=${this.networkCallNumber++}`,\n\t\t\t`driverVersion=${driverVersion}`,\n\t\t\t`isSummarizer=${this.clientIsSummarizer}`,\n\t\t];\n\t\tif (fetchReason !== undefined) {\n\t\t\titems.push(`fetchReason=${fetchReason}`);\n\t\t}\n\t\treturn items.join(\", \");\n\t}\n\n\tprotected validateEpochFromResponse(\n\t\tepochFromResponse: string | undefined,\n\t\tfetchType: FetchTypeInternal,\n\t\tfromCache: boolean = false,\n\t): void {\n\t\tconst error = this.checkForEpochErrorCore(epochFromResponse);\n\t\tif (error !== undefined) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (epochFromResponse !== undefined && this._fluidEpoch === undefined) {\n\t\t\tthis.setEpoch(epochFromResponse, fromCache, fetchType);\n\t\t}\n\t}\n\n\tprivate async checkForEpochError(\n\t\terror: unknown,\n\t\tepochFromResponse: string | null | undefined,\n\t\tfetchType: FetchTypeInternal,\n\t\tfromCache: boolean = false,\n\t): Promise<void> {\n\t\tif (isFluidError(error) && error.errorType === OdspErrorTypes.fileOverwrittenInStorage) {\n\t\t\tconst epochError = this.checkForEpochErrorCore(epochFromResponse);\n\t\t\tif (epochError !== undefined) {\n\t\t\t\tepochError.addTelemetryProperties({\n\t\t\t\t\tfromCache,\n\t\t\t\t\tfetchType,\n\t\t\t\t});\n\t\t\t\tthis.logger.sendErrorEvent({ eventName: \"fileOverwrittenInStorage\" }, epochError);\n\t\t\t\t// If the epoch mismatches, then clear all entries for such file entry from cache.\n\t\t\t\tawait this.removeEntries();\n\t\t\t\tthrow epochError;\n\t\t\t}\n\t\t\t// If it was categorized as epoch error but the epoch returned in response matches with the client epoch\n\t\t\t// then it was coherency 409, so rethrow it as throttling error so that it can retried. Default throttling\n\t\t\t// time is 1s.\n\t\t\tconst newError = wrapError(error, (message: string) => {\n\t\t\t\treturn new ThrottlingError(`Coherency 409: ${message}`, 1 /* retryAfterSeconds */, {\n\t\t\t\t\t[Odsp409Error]: true,\n\t\t\t\t\tdriverVersion,\n\t\t\t\t});\n\t\t\t});\n\t\t\tthrow newError;\n\t\t}\n\t}\n\n\tprivate checkForEpochErrorCore(\n\t\tepochFromResponse: string | null | undefined,\n\t): NonRetryableError<\"fileOverwrittenInStorage\"> | undefined {\n\t\t// If epoch is undefined, then don't compare it because initially for createNew or TreesLatest\n\t\t// initializes this value. Sometimes response does not contain epoch as it is still in\n\t\t// implementation phase at server side. In that case also, don't compare it with our epoch value.\n\t\tif (this.fluidEpoch && epochFromResponse && this.fluidEpoch !== epochFromResponse) {\n\t\t\t// This is similar in nature to how fluidEpochMismatchError (409) is handled.\n\t\t\t// Difference - client detected mismatch, instead of server detecting it.\n\t\t\treturn new NonRetryableError(\"Epoch mismatch\", OdspErrorTypes.fileOverwrittenInStorage, {\n\t\t\t\tdriverVersion,\n\t\t\t\tserverEpoch: epochFromResponse,\n\t\t\t\tclientEpoch: this.fluidEpoch,\n\t\t\t});\n\t\t}\n\t}\n\n\tprivate fileEntryFromEntry(entry: IEntry): ICacheEntry {\n\t\treturn { ...entry, file: this.fileEntry };\n\t}\n}\n\nexport class EpochTrackerWithRedemption extends EpochTracker {\n\tprivate readonly treesLatestDeferral = new Deferred<void>();\n\n\tconstructor(\n\t\tprotected readonly cache: IPersistedCache,\n\t\tprotected readonly fileEntry: IFileEntry,\n\t\tprotected readonly logger: ITelemetryLoggerExt,\n\t\tprotected readonly clientIsSummarizer?: boolean,\n\t) {\n\t\tsuper(cache, fileEntry, logger, clientIsSummarizer);\n\t\t// Handles the rejected promise within treesLatestDeferral.\n\t\tthis.treesLatestDeferral.promise.catch(() => {});\n\t}\n\n\tprotected validateEpochFromResponse(\n\t\tepochFromResponse: string | undefined,\n\t\tfetchType: FetchType,\n\t\tfromCache: boolean = false,\n\t): void {\n\t\tsuper.validateEpochFromResponse(epochFromResponse, fetchType, fromCache);\n\n\t\t// Any successful call means we have access to a file, i.e. any redemption that was required already happened.\n\t\t// That covers cases of \"treesLatest\" as well as \"getVersions\" or \"createFile\" - all the ways we can start\n\t\t// exploring a file.\n\t\tthis.treesLatestDeferral.resolve();\n\t}\n\n\t// TODO: return a stronger type\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic async get(entry: IEntry): Promise<any> {\n\t\tlet result = super.get(entry);\n\n\t\t// equivalence of what happens in fetchAndParseAsJSON()\n\t\tif (entry.type === snapshotKey || entry.type === snapshotWithLoadingGroupIdKey) {\n\t\t\tresult = result\n\t\t\t\t.then((value) => {\n\t\t\t\t\t// If there is nothing in cache, we need to wait for network call to complete (and do redemption)\n\t\t\t\t\t// Otherwise file was redeemed in prior session, so if joinSession failed, we should not retry\n\t\t\t\t\tif (value !== undefined) {\n\t\t\t\t\t\tthis.treesLatestDeferral.resolve();\n\t\t\t\t\t}\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\t\t\t\treturn value;\n\t\t\t\t})\n\t\t\t\t.catch((error) => {\n\t\t\t\t\tthis.treesLatestDeferral.reject(error);\n\t\t\t\t\tthrow error;\n\t\t\t\t});\n\t\t}\n\t\treturn result;\n\t}\n\n\tpublic async fetchAndParseAsJSON<T>(\n\t\turl: string,\n\t\tfetchOptions: { [index: string]: RequestInit },\n\t\tfetchType: FetchType,\n\t\taddInBody: boolean = false,\n\t\tfetchReason?: string,\n\t): Promise<IOdspResponse<T>> {\n\t\t// Optimize the flow if we know that treesLatestDeferral was already completed by the timer we started\n\t\t// joinSession call. If we did - there is no reason to repeat the call as it will fail with same error.\n\t\tconst completed = this.treesLatestDeferral.isCompleted;\n\n\t\ttry {\n\t\t\treturn await super.fetchAndParseAsJSON<T>(\n\t\t\t\turl,\n\t\t\t\tfetchOptions,\n\t\t\t\tfetchType,\n\t\t\t\taddInBody,\n\t\t\t\tfetchReason,\n\t\t\t);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t} catch (error: any) {\n\t\t\t// Only handling here treesLatest. If createFile failed, we should never try to do joinSession.\n\t\t\t// Similar, if getVersions failed, we should not do any further storage calls.\n\t\t\t// So treesLatest is the only call that can have parallel joinSession request.\n\t\t\tif (fetchType === \"treesLatest\") {\n\t\t\t\tthis.treesLatestDeferral.reject(error);\n\t\t\t}\n\t\t\tif (\n\t\t\t\tfetchType !== \"joinSession\" ||\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\t\terror.statusCode < 401 ||\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\t\terror.statusCode > 404 ||\n\t\t\t\tcompleted\n\t\t\t) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\n\t\t// It is joinSession failing with 401..404 error\n\t\t// Repeat after waiting for treeLatest succeeding (or fail if it failed).\n\t\t// No special handling after first call - if file has been deleted, then it's game over.\n\n\t\t// Ensure we have some safety here - we do not want to deadlock if we got logic somewhere wrong.\n\t\t// If we waited too long, we will log error event and proceed with call.\n\t\t// It may result in failure for user, but refreshing document would address it.\n\t\t// Thus we use rather long timeout (not to get these failures as much as possible), but not large enough\n\t\t// to unblock the process.\n\t\tawait PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{ eventName: \"JoinSessionSyncWait\" },\n\t\t\tasync (event) => {\n\t\t\t\tconst timeoutRes = 51; // anything will work here\n\t\t\t\tlet timer: ReturnType<typeof setTimeout>;\n\t\t\t\tconst timeoutP = new Promise<number>((resolve) => {\n\t\t\t\t\ttimer = setTimeout(() => {\n\t\t\t\t\t\tresolve(timeoutRes);\n\t\t\t\t\t}, 15000);\n\t\t\t\t});\n\t\t\t\tconst res = await Promise.race([\n\t\t\t\t\ttimeoutP,\n\t\t\t\t\t// cancel timeout to unblock UTs (otherwise Node process does not exit for 15 sec)\n\t\t\t\t\tthis.treesLatestDeferral.promise.finally(() => clearTimeout(timer)),\n\t\t\t\t]);\n\t\t\t\tif (res === timeoutRes) {\n\t\t\t\t\tevent.cancel();\n\t\t\t\t}\n\t\t\t},\n\t\t\t{ start: true, end: true, cancel: \"generic\" },\n\t\t);\n\t\treturn super.fetchAndParseAsJSON<T>(url, fetchOptions, fetchType, addInBody);\n\t}\n}\n\n/**\n * @alpha\n */\nexport interface ICacheAndTracker {\n\tcache: IOdspCache;\n\tepochTracker: EpochTracker;\n}\n\nexport function createOdspCacheAndTracker(\n\tpersistedCacheArg: IPersistedCache,\n\tnonpersistentCache: INonPersistentCache,\n\tfileEntry: IFileEntry,\n\tlogger: ITelemetryLoggerExt,\n\tclientIsSummarizer?: boolean,\n): ICacheAndTracker {\n\tconst epochTracker = new EpochTrackerWithRedemption(\n\t\tpersistedCacheArg,\n\t\tfileEntry,\n\t\tlogger,\n\t\tclientIsSummarizer,\n\t);\n\treturn {\n\t\tcache: {\n\t\t\t...nonpersistentCache,\n\t\t\tpersistedCache: epochTracker,\n\t\t},\n\t\tepochTracker,\n\t};\n}\n"]}
@@ -33,6 +33,7 @@ export declare class OdspDocumentStorageService extends OdspDocumentStorageServi
33
33
  private readonly snapshotUrl;
34
34
  private readonly attachmentPOSTUrl;
35
35
  private readonly attachmentGETUrl;
36
+ private readonly config;
36
37
  /**
37
38
  * NOTE: While commit cfff6e3 added restrictions to prevent large payloads, snapshot failures will continue to
38
39
  * happen until blob request throttling is implemented. Until then, as a temporary fix we set arbitrarily large
@@ -1 +1 @@
1
- {"version":3,"file":"odspDocumentStorageManager.d.ts","sourceRoot":"","sources":["../src/odspDocumentStorageManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EACN,WAAW,EACX,SAAS,EACT,qBAAqB,EACrB,eAAe,EACf,mBAAmB,EACnB,QAAQ,EACR,aAAa,EACb,MAAM,6CAA6C,CAAC;AAErD,OAAO,EACN,gBAAgB,EAEhB,+BAA+B,EAG/B,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EACN,mBAAmB,EAMnB,MAAM,0CAA0C,CAAC;AAElD,OAAO,EACN,yBAAyB,EAMzB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAEN,yBAAyB,EAKzB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,UAAU,EAA6B,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AAarF,eAAO,MAAM,mCAAmC,EAAE,MAAkB,CAAC;AAOrE,qBAAa,0BAA2B,SAAQ,8BAA8B;IAwB5E,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC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4BAA4B;IAuB1C,OAAO,CAAC,gBAAgB;IAUxB,OAAO,CAAC,sBAAsB;IAU9B,OAAO,CAAC,qBAAqB;cAUb,qBAAqB,CACpC,EAAE,EAAE,MAAM,EACV,YAAY,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;CAyCrC"}
@@ -48,6 +48,7 @@ class OdspDocumentStorageService extends odspDocumentStorageServiceBase_js_1.Ods
48
48
  this.snapshotUrl = this.odspResolvedUrl.endpoints.snapshotStorageUrl;
49
49
  this.attachmentPOSTUrl = this.odspResolvedUrl.endpoints.attachmentPOSTStorageUrl;
50
50
  this.attachmentGETUrl = this.odspResolvedUrl.endpoints.attachmentGETStorageUrl;
51
+ this.config = (0, internal_6.loggerToMonitoringContext)(logger).config;
51
52
  }
52
53
  get isFirstSnapshotFromNetwork() {
53
54
  return this._isFirstSnapshotFromNetwork;
@@ -161,7 +162,7 @@ class OdspDocumentStorageService extends odspDocumentStorageServiceBase_js_1.Ods
161
162
  // Here's the logic to grab the persistent cache snapshot implemented by the host
162
163
  // Epoch tracker is responsible for communicating with the persistent cache, handling epochs and cache versions
163
164
  const cachedSnapshotP = this.epochTracker
164
- .get((0, odspUtils_js_1.createCacheSnapshotKey)(this.odspResolvedUrl))
165
+ .get((0, odspUtils_js_1.createCacheSnapshotKey)(this.odspResolvedUrl, (0, odspUtils_js_1.snapshotWithLoadingGroupIdSupported)(this.config)))
165
166
  .then(async (
166
167
  // eslint-disable-next-line import/no-deprecated
167
168
  snapshotCachedEntry) => {
@@ -368,7 +369,7 @@ class OdspDocumentStorageService extends odspDocumentStorageServiceBase_js_1.Ods
368
369
  // Don't look into cache, if the host specifically tells us so. Also, if request is
369
370
  // for initial snapshot, don't consult the prefetch cache.
370
371
  if (!this.hostPolicy.avoidPrefetchSnapshotCache && this.firstSnapshotFetchCall) {
371
- const prefetchCacheKey = (0, internal_5.getKeyForCacheEntry)((0, odspUtils_js_1.createCacheSnapshotKey)(this.odspResolvedUrl));
372
+ const prefetchCacheKey = (0, internal_5.getKeyForCacheEntry)((0, odspUtils_js_1.createCacheSnapshotKey)(this.odspResolvedUrl, (0, odspUtils_js_1.snapshotWithLoadingGroupIdSupported)(this.config)));
372
373
  const result = await this.cache.snapshotPrefetchResultCache
373
374
  ?.get(prefetchCacheKey)
374
375
  ?.then(async (response) => {
@@ -407,7 +408,7 @@ class OdspDocumentStorageService extends odspDocumentStorageServiceBase_js_1.Ods
407
408
  return (0, fetchSnapshot_js_1.downloadSnapshot)(finalOdspResolvedUrl, tokenFetcher, tokenFetchOptions, loadingGroupId, options, this.snapshotFormatFetchType, controller, this.epochTracker, scenarioName);
408
409
  };
409
410
  const putInCache = async (valueWithEpoch) => {
410
- return this.cache.persistedCache.put((0, odspUtils_js_1.createCacheSnapshotKey)(this.odspResolvedUrl),
411
+ return this.cache.persistedCache.put((0, odspUtils_js_1.createCacheSnapshotKey)(this.odspResolvedUrl, (0, odspUtils_js_1.snapshotWithLoadingGroupIdSupported)(this.config)),
411
412
  // Epoch tracker will add the epoch and version to the value here. So just send value to cache.
412
413
  valueWithEpoch.value);
413
414
  };