@fluidframework/odsp-driver 2.74.0 → 2.80.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/createFile/createNewUtils.d.ts.map +1 -1
  3. package/dist/createFile/createNewUtils.js.map +1 -1
  4. package/dist/epochTracker.d.ts.map +1 -1
  5. package/dist/epochTracker.js.map +1 -1
  6. package/dist/fetchSnapshot.d.ts.map +1 -1
  7. package/dist/fetchSnapshot.js.map +1 -1
  8. package/dist/odspDelayLoadedDeltaStream.d.ts.map +1 -1
  9. package/dist/odspDelayLoadedDeltaStream.js.map +1 -1
  10. package/dist/odspDeltaStorageService.d.ts.map +1 -1
  11. package/dist/odspDeltaStorageService.js.map +1 -1
  12. package/dist/odspDocumentDeltaConnection.d.ts.map +1 -1
  13. package/dist/odspDocumentDeltaConnection.js.map +1 -1
  14. package/dist/odspDocumentServiceFactoryCore.d.ts.map +1 -1
  15. package/dist/odspDocumentServiceFactoryCore.js.map +1 -1
  16. package/dist/odspLayerCompatState.d.ts +1 -1
  17. package/dist/odspLayerCompatState.d.ts.map +1 -1
  18. package/dist/odspLayerCompatState.js +2 -1
  19. package/dist/odspLayerCompatState.js.map +1 -1
  20. package/dist/packageVersion.d.ts +1 -1
  21. package/dist/packageVersion.js +1 -1
  22. package/dist/packageVersion.js.map +1 -1
  23. package/dist/vroom.d.ts.map +1 -1
  24. package/dist/vroom.js.map +1 -1
  25. package/lib/createFile/createNewUtils.d.ts.map +1 -1
  26. package/lib/createFile/createNewUtils.js.map +1 -1
  27. package/lib/epochTracker.d.ts.map +1 -1
  28. package/lib/epochTracker.js.map +1 -1
  29. package/lib/fetchSnapshot.d.ts.map +1 -1
  30. package/lib/fetchSnapshot.js.map +1 -1
  31. package/lib/odspDelayLoadedDeltaStream.d.ts.map +1 -1
  32. package/lib/odspDelayLoadedDeltaStream.js.map +1 -1
  33. package/lib/odspDeltaStorageService.d.ts.map +1 -1
  34. package/lib/odspDeltaStorageService.js.map +1 -1
  35. package/lib/odspDocumentDeltaConnection.d.ts.map +1 -1
  36. package/lib/odspDocumentDeltaConnection.js.map +1 -1
  37. package/lib/odspDocumentServiceFactoryCore.d.ts.map +1 -1
  38. package/lib/odspDocumentServiceFactoryCore.js.map +1 -1
  39. package/lib/odspLayerCompatState.d.ts +1 -1
  40. package/lib/odspLayerCompatState.d.ts.map +1 -1
  41. package/lib/odspLayerCompatState.js +2 -1
  42. package/lib/odspLayerCompatState.js.map +1 -1
  43. package/lib/packageVersion.d.ts +1 -1
  44. package/lib/packageVersion.js +1 -1
  45. package/lib/packageVersion.js.map +1 -1
  46. package/lib/vroom.d.ts.map +1 -1
  47. package/lib/vroom.js.map +1 -1
  48. package/package.json +20 -20
  49. package/src/createFile/createNewUtils.ts +0 -1
  50. package/src/epochTracker.ts +0 -1
  51. package/src/fetchSnapshot.ts +0 -1
  52. package/src/odspDelayLoadedDeltaStream.ts +0 -1
  53. package/src/odspDeltaStorageService.ts +0 -1
  54. package/src/odspDocumentDeltaConnection.ts +0 -1
  55. package/src/odspDocumentServiceFactoryCore.ts +0 -1
  56. package/src/odspLayerCompatState.ts +2 -2
  57. package/src/packageVersion.ts +1 -1
  58. package/src/vroom.ts +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"odspDocumentServiceFactoryCore.js","sourceRoot":"","sources":["../src/odspDocumentServiceFactoryCore.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAYH,oEAG+C;AAC/C,+EAW0D;AAC1D,uEAA+F;AAE/F,+BAAkC;AAElC,oDAA2D;AAC3D,uDAAqF;AACrF,iDAKwB;AACxB,qEAA+D;AAC/D,uEAA6E;AAC7E,iDASwB;AAExB;;;;;;;;GAQG;AACH,MAAa,8BAA8B;IAM1C,IAAW,2BAA2B;QACrC,OAAO,IAAI,CAAC,kBAAkB,CAAC,2BAA2B,CAAC;IAC5D,CAAC;IAED,qFAAqF;IACrF,IAAW,+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AC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAC5D,MAAM,cAAc,GAAG,YAAY,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;QAC1D,IAAI,eAAe,IAAI,2BAAgB,CAAC,eAAe,CAAC,EAAE,CAAC;YAC1D,oBAAoB,GAAG;gBACtB,mEAAmE;gBACnE,KAAK,EAAE,2BAAgB,CAAC,eAAe,CAAC;gBACxC,GAAG,CAAC,cAAc,IAAI,0BAAe,CAAC,cAAc,CAAC;oBACpD,CAAC,CAAC,mEAAmE;wBACpE,EAAE,IAAI,EAAE,0BAAe,CAAC,cAAc,CAAC,EAAE;oBAC1C,CAAC,CAAC,EAAE,CAAC;aACN,CAAC;QACH,CAAC;IACF,CAAC;IACD,OAAO,oBAAoB,CAAC;AAC7B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport type { PromiseCache } from \"@fluidframework/core-utils/internal\";\nimport type { ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport type {\n\tIDocumentService,\n\tIDocumentServiceFactory,\n\tIFileEntry,\n\tIPersistedCache,\n\tIResolvedUrl,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tgetDocAttributesFromProtocolSummary,\n\tisCombinedAppAndProtocolSummary,\n} from \"@fluidframework/driver-utils/internal\";\nimport {\n\ttype HostStoragePolicy,\n\ttype IOdspUrlParts,\n\ttype IRelaySessionAwareDriverFactory,\n\ttype ISharingLinkKind,\n\ttype ISocketStorageDiscovery,\n\ttype OdspResourceTokenFetchOptions,\n\tSharingLinkRole,\n\tSharingLinkScope,\n\ttype TokenFetchOptions,\n\ttype TokenFetcher,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport { PerformanceEvent, createChildLogger } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { v4 as uuid } from \"uuid\";\n\nimport { useCreateNewModule } from \"./createFile/index.js\";\nimport { type ICacheAndTracker, createOdspCacheAndTracker } from \"./epochTracker.js\";\nimport {\n\ttype INonPersistentCache,\n\ttype IPrefetchSnapshotContents,\n\tLocalPersistentCache,\n\tNonPersistentCache,\n} from \"./odspCache.js\";\nimport { OdspDocumentService } from \"./odspDocumentService.js\";\nimport { odspDriverCompatDetailsForLoader } from \"./odspLayerCompatState.js\";\nimport {\n\ttype IExistingFileInfo,\n\ttype INewFileInfo,\n\tcreateOdspLogger,\n\tgetJoinSessionCacheKey,\n\tgetOdspResolvedUrl,\n\tisNewFileInfo,\n\ttoInstrumentedOdspStorageTokenFetcher,\n\ttoInstrumentedOdspTokenFetcher,\n} from \"./odspUtils.js\";\n\n/**\n * Factory for creating the sharepoint document service. Use this if you want to\n * use the sharepoint implementation.\n *\n * This constructor should be used by environments that support dynamic imports and that wish\n * to leverage code splitting as a means to keep bundles as small as possible.\n * @legacy\n * @beta\n */\nexport class OdspDocumentServiceFactoryCore\n\timplements IDocumentServiceFactory, IRelaySessionAwareDriverFactory\n{\n\tprivate readonly nonPersistentCache: INonPersistentCache = new NonPersistentCache();\n\tprivate readonly socketReferenceKeyPrefix?: string;\n\n\tpublic get snapshotPrefetchResultCache(): PromiseCache<string, IPrefetchSnapshotContents> {\n\t\treturn this.nonPersistentCache.snapshotPrefetchResultCache;\n\t}\n\n\t// TODO: return `IRelaySessionAwareDriverFactory` instead of `this` (breaking change)\n\tpublic get IRelaySessionAwareDriverFactory(): this {\n\t\treturn this;\n\t}\n\n\t/**\n\t * This function would return info about relay service session only if this factory established (or attempted to\n\t * establish) connection very recently. Otherwise, it will return undefined.\n\t * @param resolvedUrl - resolved url for container\n\t * @returns The current join session response stored in cache. `undefined` if not present.\n\t */\n\tpublic async getRelayServiceSessionInfo(\n\t\tresolvedUrl: IResolvedUrl,\n\t): Promise<ISocketStorageDiscovery | undefined> {\n\t\tconst odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n\t\tconst joinSessionResponse = await this.nonPersistentCache.sessionJoinCache.get(\n\t\t\tgetJoinSessionCacheKey(odspResolvedUrl),\n\t\t);\n\t\treturn joinSessionResponse?.joinSessionResponse;\n\t}\n\n\tpublic async createContainer(\n\t\tcreateNewSummary: ISummaryTree | undefined,\n\t\tcreateNewResolvedUrl: IResolvedUrl,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\tconst odspResolvedUrl = getOdspResolvedUrl(createNewResolvedUrl);\n\t\tconst resolvedUrlData: IOdspUrlParts = {\n\t\t\tsiteUrl: odspResolvedUrl.siteUrl,\n\t\t\tdriveId: odspResolvedUrl.driveId,\n\t\t\titemId: odspResolvedUrl.itemId,\n\t\t};\n\n\t\tlet fileInfo: INewFileInfo | IExistingFileInfo;\n\t\tlet createShareLinkParam: ISharingLinkKind | undefined;\n\t\tif (odspResolvedUrl.itemId) {\n\t\t\tfileInfo = {\n\t\t\t\ttype: \"Existing\",\n\t\t\t\tdriveId: odspResolvedUrl.driveId,\n\t\t\t\tsiteUrl: odspResolvedUrl.siteUrl,\n\t\t\t\titemId: odspResolvedUrl.itemId,\n\t\t\t};\n\t\t} else if (odspResolvedUrl.fileName) {\n\t\t\tconst [, queryString] = odspResolvedUrl.url.split(\"?\");\n\t\t\tconst searchParams = new URLSearchParams(queryString);\n\t\t\tconst filePath = searchParams.get(\"path\");\n\t\t\tif (filePath === undefined || filePath === null) {\n\t\t\t\tthrow new Error(\"File path should be provided!!\");\n\t\t\t}\n\t\t\tcreateShareLinkParam = getSharingLinkParams(this.hostPolicy, searchParams);\n\t\t\tfileInfo = {\n\t\t\t\ttype: \"New\",\n\t\t\t\tdriveId: odspResolvedUrl.driveId,\n\t\t\t\tsiteUrl: odspResolvedUrl.siteUrl,\n\t\t\t\tfilePath,\n\t\t\t\tfilename: odspResolvedUrl.fileName,\n\t\t\t\tcreateLinkType: createShareLinkParam,\n\t\t\t};\n\t\t} else {\n\t\t\tthrow new Error(\"A new or existing file must be specified to create container!\");\n\t\t}\n\n\t\tif (isCombinedAppAndProtocolSummary(createNewSummary)) {\n\t\t\tconst documentAttributes = getDocAttributesFromProtocolSummary(\n\t\t\t\tcreateNewSummary.tree[\".protocol\"],\n\t\t\t);\n\t\t\tif (documentAttributes?.sequenceNumber !== 0) {\n\t\t\t\tthrow new Error(\"Seq number in detached ODSP container should be 0\");\n\t\t\t}\n\t\t}\n\n\t\tconst odspLogger = createOdspLogger(logger);\n\n\t\tconst fileEntry: IFileEntry = {\n\t\t\tresolvedUrl: odspResolvedUrl,\n\t\t\tdocId: odspResolvedUrl.hashedDocumentId,\n\t\t\tfileVersion: undefined,\n\t\t};\n\t\tconst cacheAndTracker = createOdspCacheAndTracker(\n\t\t\tthis.persistedCache,\n\t\t\tthis.nonPersistentCache,\n\t\t\tfileEntry,\n\t\t\todspLogger,\n\t\t\tclientIsSummarizer,\n\t\t);\n\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\todspLogger,\n\t\t\t{\n\t\t\t\teventName: \"CreateNew\",\n\t\t\t\tisWithSummaryUpload: true,\n\t\t\t\tcreateShareLinkParam: createShareLinkParam\n\t\t\t\t\t? JSON.stringify(createShareLinkParam)\n\t\t\t\t\t: undefined,\n\t\t\t\tenableSingleRequestForShareLinkWithCreate:\n\t\t\t\t\tthis.hostPolicy.enableSingleRequestForShareLinkWithCreate,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst getAuthHeader = toInstrumentedOdspStorageTokenFetcher(\n\t\t\t\t\todspLogger,\n\t\t\t\t\tresolvedUrlData,\n\t\t\t\t\tthis.getStorageToken,\n\t\t\t\t);\n\t\t\t\tconst _odspResolvedUrl = await useCreateNewModule(odspLogger, async (module) => {\n\t\t\t\t\treturn isNewFileInfo(fileInfo)\n\t\t\t\t\t\t? module.createNewFluidFile(\n\t\t\t\t\t\t\t\tgetAuthHeader,\n\t\t\t\t\t\t\t\tfileInfo,\n\t\t\t\t\t\t\t\todspLogger,\n\t\t\t\t\t\t\t\tcreateNewSummary,\n\t\t\t\t\t\t\t\tcacheAndTracker.epochTracker,\n\t\t\t\t\t\t\t\tfileEntry,\n\t\t\t\t\t\t\t\tthis.hostPolicy.cacheCreateNewSummary ?? true,\n\t\t\t\t\t\t\t\t!!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n\t\t\t\t\t\t\t\todspResolvedUrl.isClpCompliantApp,\n\t\t\t\t\t\t\t\tthis.hostPolicy.enableSingleRequestForShareLinkWithCreate,\n\t\t\t\t\t\t\t\todspResolvedUrl,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: module.createNewContainerOnExistingFile(\n\t\t\t\t\t\t\t\tgetAuthHeader,\n\t\t\t\t\t\t\t\tfileInfo,\n\t\t\t\t\t\t\t\todspLogger,\n\t\t\t\t\t\t\t\tcreateNewSummary,\n\t\t\t\t\t\t\t\tcacheAndTracker.epochTracker,\n\t\t\t\t\t\t\t\tfileEntry,\n\t\t\t\t\t\t\t\tthis.hostPolicy.cacheCreateNewSummary ?? true,\n\t\t\t\t\t\t\t\t!!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n\t\t\t\t\t\t\t\todspResolvedUrl.isClpCompliantApp,\n\t\t\t\t\t\t\t\todspResolvedUrl.fileMetadata?.eTag,\n\t\t\t\t\t\t\t);\n\t\t\t\t});\n\t\t\t\tconst docService = this.createDocumentServiceCore(\n\t\t\t\t\t_odspResolvedUrl,\n\t\t\t\t\todspLogger,\n\t\t\t\t\tcacheAndTracker,\n\t\t\t\t\tclientIsSummarizer,\n\t\t\t\t);\n\t\t\t\tevent.end({\n\t\t\t\t\tdocId: _odspResolvedUrl.hashedDocumentId,\n\t\t\t\t});\n\t\t\t\treturn docService;\n\t\t\t},\n\t\t);\n\t}\n\n\t/**\n\t * @param getStorageToken - function that can provide the storage token for a given site. This is\n\t * is also referred to as the \"Vroom\" token in SPO.\n\t * @param getWebsocketToken - function that can provide a token for accessing the web socket. This is also\n\t * to as the \"Push\" token in SPO. If undefined then websocket token is expected to be returned with joinSession\n\t * response payload.\n\t * @param persistedCache - PersistedCache provided by host for use in this session.\n\t * @param hostPolicy - Policy for storage provided by host.\n\t */\n\tconstructor(\n\t\tprivate readonly getStorageToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n\t\tprivate readonly getWebsocketToken:\n\t\t\t| TokenFetcher<OdspResourceTokenFetchOptions>\n\t\t\t| undefined,\n\t\tprotected persistedCache: IPersistedCache = new LocalPersistentCache(),\n\t\tprivate readonly hostPolicy: HostStoragePolicy = {},\n\t) {\n\t\tif (this.hostPolicy.isolateSocketCache === true) {\n\t\t\t// create the key to separate the socket reuse cache\n\t\t\tthis.socketReferenceKeyPrefix = uuid();\n\t\t}\n\t\t// Set enableRedeemFallback by default as true.\n\t\tthis.hostPolicy.enableRedeemFallback = this.hostPolicy.enableRedeemFallback ?? true;\n\t\tthis.hostPolicy.sessionOptions = {\n\t\t\tforceAccessTokenViaAuthorizationHeader: true,\n\t\t\t...this.hostPolicy.sessionOptions,\n\t\t};\n\t}\n\n\t/**\n\t * The compatibility details of the ODSP Driver layer that is exposed to the Loader layer\n\t * for validating Loader-Driver compatibility.\n\t * @remarks This is for internal use only.\n\t * The type of this should be ILayerCompatDetails. However, ILayerCompatDetails is internal and this class\n\t * is currently marked as legacy alpha. So, using unknown here.\n\t */\n\tpublic readonly ILayerCompatDetails?: unknown = odspDriverCompatDetailsForLoader;\n\n\tpublic async createDocumentService(\n\t\tresolvedUrl: IResolvedUrl,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\treturn this.createDocumentServiceCore(\n\t\t\tresolvedUrl,\n\t\t\tcreateOdspLogger(logger),\n\t\t\tundefined,\n\t\t\tclientIsSummarizer,\n\t\t);\n\t}\n\n\tprotected async createDocumentServiceCore(\n\t\tresolvedUrl: IResolvedUrl,\n\t\todspLogger: ITelemetryBaseLogger,\n\t\tcacheAndTrackerArg?: ICacheAndTracker,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\tconst extLogger = createChildLogger({ logger: odspLogger });\n\t\tconst odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n\t\tconst resolvedUrlData: IOdspUrlParts = {\n\t\t\tsiteUrl: odspResolvedUrl.siteUrl,\n\t\t\tdriveId: odspResolvedUrl.driveId,\n\t\t\titemId: odspResolvedUrl.itemId,\n\t\t};\n\n\t\tconst cacheAndTracker =\n\t\t\tcacheAndTrackerArg ??\n\t\t\tcreateOdspCacheAndTracker(\n\t\t\t\tthis.persistedCache,\n\t\t\t\tthis.nonPersistentCache,\n\t\t\t\t{\n\t\t\t\t\tresolvedUrl: odspResolvedUrl,\n\t\t\t\t\tdocId: odspResolvedUrl.hashedDocumentId,\n\t\t\t\t\tfileVersion: odspResolvedUrl.fileVersion,\n\t\t\t\t},\n\t\t\t\textLogger,\n\t\t\t\tclientIsSummarizer,\n\t\t\t);\n\n\t\tconst storageTokenFetcher = toInstrumentedOdspStorageTokenFetcher(\n\t\t\textLogger,\n\t\t\tresolvedUrlData,\n\t\t\tthis.getStorageToken,\n\t\t);\n\n\t\tconst webSocketTokenFetcher =\n\t\t\tthis.getWebsocketToken === undefined\n\t\t\t\t? undefined\n\t\t\t\t: async (options: TokenFetchOptions): Promise<string | null> =>\n\t\t\t\t\t\t// websocket expects a plain token\n\t\t\t\t\t\ttoInstrumentedOdspTokenFetcher(\n\t\t\t\t\t\t\textLogger,\n\t\t\t\t\t\t\tresolvedUrlData,\n\t\t\t\t\t\t\tthis.getWebsocketToken!,\n\t\t\t\t\t\t\tfalse /* throwOnNullToken */,\n\t\t\t\t\t\t\ttrue /* returnPlainToken */,\n\t\t\t\t\t\t)(options, \"GetWebsocketToken\");\n\n\t\treturn OdspDocumentService.create(\n\t\t\tresolvedUrl,\n\t\t\tstorageTokenFetcher,\n\t\t\twebSocketTokenFetcher,\n\t\t\textLogger,\n\t\t\tcacheAndTracker.cache,\n\t\t\tthis.hostPolicy,\n\t\t\tcacheAndTracker.epochTracker,\n\t\t\tthis.socketReferenceKeyPrefix,\n\t\t\tclientIsSummarizer,\n\t\t);\n\t}\n}\n\n/**\n * Extract the sharing link kind from the resolved URL's query paramerters\n */\nfunction getSharingLinkParams(\n\thostPolicy: HostStoragePolicy,\n\tsearchParams: URLSearchParams,\n): ISharingLinkKind | undefined {\n\t// extract request parameters for creation of sharing link (if provided) if the feature is enabled\n\tlet createShareLinkParam: ISharingLinkKind | undefined;\n\tif (hostPolicy.enableSingleRequestForShareLinkWithCreate) {\n\t\tconst createLinkScope = searchParams.get(\"createLinkScope\");\n\t\tconst createLinkRole = searchParams.get(\"createLinkRole\");\n\t\tif (createLinkScope && SharingLinkScope[createLinkScope]) {\n\t\t\tcreateShareLinkParam = {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\tscope: SharingLinkScope[createLinkScope],\n\t\t\t\t...(createLinkRole && SharingLinkRole[createLinkRole]\n\t\t\t\t\t? // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\t\t\t{ role: SharingLinkRole[createLinkRole] }\n\t\t\t\t\t: {}),\n\t\t\t};\n\t\t}\n\t}\n\treturn createShareLinkParam;\n}\n"]}
1
+ {"version":3,"file":"odspDocumentServiceFactoryCore.js","sourceRoot":"","sources":["../src/odspDocumentServiceFactoryCore.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAYH,oEAG+C;AAC/C,+EAW0D;AAC1D,uEAA+F;AAC/F,+BAAkC;AAElC,oDAA2D;AAC3D,uDAAqF;AACrF,iDAKwB;AACxB,qEAA+D;AAC/D,uEAA6E;AAC7E,iDASwB;AAExB;;;;;;;;GAQG;AACH,MAAa,8BAA8B;IAM1C,IAAW,2BAA2B;QACrC,OAAO,IAAI,CAAC,kBAAkB,CAAC,2BAA2B,CAAC;IAC5D,CAAC;IAED,qFAAqF;IACrF,IAAW,+BAA+B;QACzC,OAAO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AAiB,CAAC,CAAC;QAC5D,MAAM,cAAc,GAAG,YAAY,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;QAC1D,IAAI,eAAe,IAAI,2BAAgB,CAAC,eAAe,CAAC,EAAE,CAAC;YAC1D,oBAAoB,GAAG;gBACtB,mEAAmE;gBACnE,KAAK,EAAE,2BAAgB,CAAC,eAAe,CAAC;gBACxC,GAAG,CAAC,cAAc,IAAI,0BAAe,CAAC,cAAc,CAAC;oBACpD,CAAC,CAAC,mEAAmE;wBACpE,EAAE,IAAI,EAAE,0BAAe,CAAC,cAAc,CAAC,EAAE;oBAC1C,CAAC,CAAC,EAAE,CAAC;aACN,CAAC;QACH,CAAC;IACF,CAAC;IACD,OAAO,oBAAoB,CAAC;AAC7B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport type { PromiseCache } from \"@fluidframework/core-utils/internal\";\nimport type { ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport type {\n\tIDocumentService,\n\tIDocumentServiceFactory,\n\tIFileEntry,\n\tIPersistedCache,\n\tIResolvedUrl,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tgetDocAttributesFromProtocolSummary,\n\tisCombinedAppAndProtocolSummary,\n} from \"@fluidframework/driver-utils/internal\";\nimport {\n\ttype HostStoragePolicy,\n\ttype IOdspUrlParts,\n\ttype IRelaySessionAwareDriverFactory,\n\ttype ISharingLinkKind,\n\ttype ISocketStorageDiscovery,\n\ttype OdspResourceTokenFetchOptions,\n\tSharingLinkRole,\n\tSharingLinkScope,\n\ttype TokenFetchOptions,\n\ttype TokenFetcher,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport { PerformanceEvent, createChildLogger } from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport { useCreateNewModule } from \"./createFile/index.js\";\nimport { type ICacheAndTracker, createOdspCacheAndTracker } from \"./epochTracker.js\";\nimport {\n\ttype INonPersistentCache,\n\ttype IPrefetchSnapshotContents,\n\tLocalPersistentCache,\n\tNonPersistentCache,\n} from \"./odspCache.js\";\nimport { OdspDocumentService } from \"./odspDocumentService.js\";\nimport { odspDriverCompatDetailsForLoader } from \"./odspLayerCompatState.js\";\nimport {\n\ttype IExistingFileInfo,\n\ttype INewFileInfo,\n\tcreateOdspLogger,\n\tgetJoinSessionCacheKey,\n\tgetOdspResolvedUrl,\n\tisNewFileInfo,\n\ttoInstrumentedOdspStorageTokenFetcher,\n\ttoInstrumentedOdspTokenFetcher,\n} from \"./odspUtils.js\";\n\n/**\n * Factory for creating the sharepoint document service. Use this if you want to\n * use the sharepoint implementation.\n *\n * This constructor should be used by environments that support dynamic imports and that wish\n * to leverage code splitting as a means to keep bundles as small as possible.\n * @legacy\n * @beta\n */\nexport class OdspDocumentServiceFactoryCore\n\timplements IDocumentServiceFactory, IRelaySessionAwareDriverFactory\n{\n\tprivate readonly nonPersistentCache: INonPersistentCache = new NonPersistentCache();\n\tprivate readonly socketReferenceKeyPrefix?: string;\n\n\tpublic get snapshotPrefetchResultCache(): PromiseCache<string, IPrefetchSnapshotContents> {\n\t\treturn this.nonPersistentCache.snapshotPrefetchResultCache;\n\t}\n\n\t// TODO: return `IRelaySessionAwareDriverFactory` instead of `this` (breaking change)\n\tpublic get IRelaySessionAwareDriverFactory(): this {\n\t\treturn this;\n\t}\n\n\t/**\n\t * This function would return info about relay service session only if this factory established (or attempted to\n\t * establish) connection very recently. Otherwise, it will return undefined.\n\t * @param resolvedUrl - resolved url for container\n\t * @returns The current join session response stored in cache. `undefined` if not present.\n\t */\n\tpublic async getRelayServiceSessionInfo(\n\t\tresolvedUrl: IResolvedUrl,\n\t): Promise<ISocketStorageDiscovery | undefined> {\n\t\tconst odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n\t\tconst joinSessionResponse = await this.nonPersistentCache.sessionJoinCache.get(\n\t\t\tgetJoinSessionCacheKey(odspResolvedUrl),\n\t\t);\n\t\treturn joinSessionResponse?.joinSessionResponse;\n\t}\n\n\tpublic async createContainer(\n\t\tcreateNewSummary: ISummaryTree | undefined,\n\t\tcreateNewResolvedUrl: IResolvedUrl,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\tconst odspResolvedUrl = getOdspResolvedUrl(createNewResolvedUrl);\n\t\tconst resolvedUrlData: IOdspUrlParts = {\n\t\t\tsiteUrl: odspResolvedUrl.siteUrl,\n\t\t\tdriveId: odspResolvedUrl.driveId,\n\t\t\titemId: odspResolvedUrl.itemId,\n\t\t};\n\n\t\tlet fileInfo: INewFileInfo | IExistingFileInfo;\n\t\tlet createShareLinkParam: ISharingLinkKind | undefined;\n\t\tif (odspResolvedUrl.itemId) {\n\t\t\tfileInfo = {\n\t\t\t\ttype: \"Existing\",\n\t\t\t\tdriveId: odspResolvedUrl.driveId,\n\t\t\t\tsiteUrl: odspResolvedUrl.siteUrl,\n\t\t\t\titemId: odspResolvedUrl.itemId,\n\t\t\t};\n\t\t} else if (odspResolvedUrl.fileName) {\n\t\t\tconst [, queryString] = odspResolvedUrl.url.split(\"?\");\n\t\t\tconst searchParams = new URLSearchParams(queryString);\n\t\t\tconst filePath = searchParams.get(\"path\");\n\t\t\tif (filePath === undefined || filePath === null) {\n\t\t\t\tthrow new Error(\"File path should be provided!!\");\n\t\t\t}\n\t\t\tcreateShareLinkParam = getSharingLinkParams(this.hostPolicy, searchParams);\n\t\t\tfileInfo = {\n\t\t\t\ttype: \"New\",\n\t\t\t\tdriveId: odspResolvedUrl.driveId,\n\t\t\t\tsiteUrl: odspResolvedUrl.siteUrl,\n\t\t\t\tfilePath,\n\t\t\t\tfilename: odspResolvedUrl.fileName,\n\t\t\t\tcreateLinkType: createShareLinkParam,\n\t\t\t};\n\t\t} else {\n\t\t\tthrow new Error(\"A new or existing file must be specified to create container!\");\n\t\t}\n\n\t\tif (isCombinedAppAndProtocolSummary(createNewSummary)) {\n\t\t\tconst documentAttributes = getDocAttributesFromProtocolSummary(\n\t\t\t\tcreateNewSummary.tree[\".protocol\"],\n\t\t\t);\n\t\t\tif (documentAttributes?.sequenceNumber !== 0) {\n\t\t\t\tthrow new Error(\"Seq number in detached ODSP container should be 0\");\n\t\t\t}\n\t\t}\n\n\t\tconst odspLogger = createOdspLogger(logger);\n\n\t\tconst fileEntry: IFileEntry = {\n\t\t\tresolvedUrl: odspResolvedUrl,\n\t\t\tdocId: odspResolvedUrl.hashedDocumentId,\n\t\t\tfileVersion: undefined,\n\t\t};\n\t\tconst cacheAndTracker = createOdspCacheAndTracker(\n\t\t\tthis.persistedCache,\n\t\t\tthis.nonPersistentCache,\n\t\t\tfileEntry,\n\t\t\todspLogger,\n\t\t\tclientIsSummarizer,\n\t\t);\n\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\todspLogger,\n\t\t\t{\n\t\t\t\teventName: \"CreateNew\",\n\t\t\t\tisWithSummaryUpload: true,\n\t\t\t\tcreateShareLinkParam: createShareLinkParam\n\t\t\t\t\t? JSON.stringify(createShareLinkParam)\n\t\t\t\t\t: undefined,\n\t\t\t\tenableSingleRequestForShareLinkWithCreate:\n\t\t\t\t\tthis.hostPolicy.enableSingleRequestForShareLinkWithCreate,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst getAuthHeader = toInstrumentedOdspStorageTokenFetcher(\n\t\t\t\t\todspLogger,\n\t\t\t\t\tresolvedUrlData,\n\t\t\t\t\tthis.getStorageToken,\n\t\t\t\t);\n\t\t\t\tconst _odspResolvedUrl = await useCreateNewModule(odspLogger, async (module) => {\n\t\t\t\t\treturn isNewFileInfo(fileInfo)\n\t\t\t\t\t\t? module.createNewFluidFile(\n\t\t\t\t\t\t\t\tgetAuthHeader,\n\t\t\t\t\t\t\t\tfileInfo,\n\t\t\t\t\t\t\t\todspLogger,\n\t\t\t\t\t\t\t\tcreateNewSummary,\n\t\t\t\t\t\t\t\tcacheAndTracker.epochTracker,\n\t\t\t\t\t\t\t\tfileEntry,\n\t\t\t\t\t\t\t\tthis.hostPolicy.cacheCreateNewSummary ?? true,\n\t\t\t\t\t\t\t\t!!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n\t\t\t\t\t\t\t\todspResolvedUrl.isClpCompliantApp,\n\t\t\t\t\t\t\t\tthis.hostPolicy.enableSingleRequestForShareLinkWithCreate,\n\t\t\t\t\t\t\t\todspResolvedUrl,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: module.createNewContainerOnExistingFile(\n\t\t\t\t\t\t\t\tgetAuthHeader,\n\t\t\t\t\t\t\t\tfileInfo,\n\t\t\t\t\t\t\t\todspLogger,\n\t\t\t\t\t\t\t\tcreateNewSummary,\n\t\t\t\t\t\t\t\tcacheAndTracker.epochTracker,\n\t\t\t\t\t\t\t\tfileEntry,\n\t\t\t\t\t\t\t\tthis.hostPolicy.cacheCreateNewSummary ?? true,\n\t\t\t\t\t\t\t\t!!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n\t\t\t\t\t\t\t\todspResolvedUrl.isClpCompliantApp,\n\t\t\t\t\t\t\t\todspResolvedUrl.fileMetadata?.eTag,\n\t\t\t\t\t\t\t);\n\t\t\t\t});\n\t\t\t\tconst docService = this.createDocumentServiceCore(\n\t\t\t\t\t_odspResolvedUrl,\n\t\t\t\t\todspLogger,\n\t\t\t\t\tcacheAndTracker,\n\t\t\t\t\tclientIsSummarizer,\n\t\t\t\t);\n\t\t\t\tevent.end({\n\t\t\t\t\tdocId: _odspResolvedUrl.hashedDocumentId,\n\t\t\t\t});\n\t\t\t\treturn docService;\n\t\t\t},\n\t\t);\n\t}\n\n\t/**\n\t * @param getStorageToken - function that can provide the storage token for a given site. This is\n\t * is also referred to as the \"Vroom\" token in SPO.\n\t * @param getWebsocketToken - function that can provide a token for accessing the web socket. This is also\n\t * to as the \"Push\" token in SPO. If undefined then websocket token is expected to be returned with joinSession\n\t * response payload.\n\t * @param persistedCache - PersistedCache provided by host for use in this session.\n\t * @param hostPolicy - Policy for storage provided by host.\n\t */\n\tconstructor(\n\t\tprivate readonly getStorageToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n\t\tprivate readonly getWebsocketToken:\n\t\t\t| TokenFetcher<OdspResourceTokenFetchOptions>\n\t\t\t| undefined,\n\t\tprotected persistedCache: IPersistedCache = new LocalPersistentCache(),\n\t\tprivate readonly hostPolicy: HostStoragePolicy = {},\n\t) {\n\t\tif (this.hostPolicy.isolateSocketCache === true) {\n\t\t\t// create the key to separate the socket reuse cache\n\t\t\tthis.socketReferenceKeyPrefix = uuid();\n\t\t}\n\t\t// Set enableRedeemFallback by default as true.\n\t\tthis.hostPolicy.enableRedeemFallback = this.hostPolicy.enableRedeemFallback ?? true;\n\t\tthis.hostPolicy.sessionOptions = {\n\t\t\tforceAccessTokenViaAuthorizationHeader: true,\n\t\t\t...this.hostPolicy.sessionOptions,\n\t\t};\n\t}\n\n\t/**\n\t * The compatibility details of the ODSP Driver layer that is exposed to the Loader layer\n\t * for validating Loader-Driver compatibility.\n\t * @remarks This is for internal use only.\n\t * The type of this should be ILayerCompatDetails. However, ILayerCompatDetails is internal and this class\n\t * is currently marked as legacy alpha. So, using unknown here.\n\t */\n\tpublic readonly ILayerCompatDetails?: unknown = odspDriverCompatDetailsForLoader;\n\n\tpublic async createDocumentService(\n\t\tresolvedUrl: IResolvedUrl,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\treturn this.createDocumentServiceCore(\n\t\t\tresolvedUrl,\n\t\t\tcreateOdspLogger(logger),\n\t\t\tundefined,\n\t\t\tclientIsSummarizer,\n\t\t);\n\t}\n\n\tprotected async createDocumentServiceCore(\n\t\tresolvedUrl: IResolvedUrl,\n\t\todspLogger: ITelemetryBaseLogger,\n\t\tcacheAndTrackerArg?: ICacheAndTracker,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\tconst extLogger = createChildLogger({ logger: odspLogger });\n\t\tconst odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n\t\tconst resolvedUrlData: IOdspUrlParts = {\n\t\t\tsiteUrl: odspResolvedUrl.siteUrl,\n\t\t\tdriveId: odspResolvedUrl.driveId,\n\t\t\titemId: odspResolvedUrl.itemId,\n\t\t};\n\n\t\tconst cacheAndTracker =\n\t\t\tcacheAndTrackerArg ??\n\t\t\tcreateOdspCacheAndTracker(\n\t\t\t\tthis.persistedCache,\n\t\t\t\tthis.nonPersistentCache,\n\t\t\t\t{\n\t\t\t\t\tresolvedUrl: odspResolvedUrl,\n\t\t\t\t\tdocId: odspResolvedUrl.hashedDocumentId,\n\t\t\t\t\tfileVersion: odspResolvedUrl.fileVersion,\n\t\t\t\t},\n\t\t\t\textLogger,\n\t\t\t\tclientIsSummarizer,\n\t\t\t);\n\n\t\tconst storageTokenFetcher = toInstrumentedOdspStorageTokenFetcher(\n\t\t\textLogger,\n\t\t\tresolvedUrlData,\n\t\t\tthis.getStorageToken,\n\t\t);\n\n\t\tconst webSocketTokenFetcher =\n\t\t\tthis.getWebsocketToken === undefined\n\t\t\t\t? undefined\n\t\t\t\t: async (options: TokenFetchOptions): Promise<string | null> =>\n\t\t\t\t\t\t// websocket expects a plain token\n\t\t\t\t\t\ttoInstrumentedOdspTokenFetcher(\n\t\t\t\t\t\t\textLogger,\n\t\t\t\t\t\t\tresolvedUrlData,\n\t\t\t\t\t\t\tthis.getWebsocketToken!,\n\t\t\t\t\t\t\tfalse /* throwOnNullToken */,\n\t\t\t\t\t\t\ttrue /* returnPlainToken */,\n\t\t\t\t\t\t)(options, \"GetWebsocketToken\");\n\n\t\treturn OdspDocumentService.create(\n\t\t\tresolvedUrl,\n\t\t\tstorageTokenFetcher,\n\t\t\twebSocketTokenFetcher,\n\t\t\textLogger,\n\t\t\tcacheAndTracker.cache,\n\t\t\tthis.hostPolicy,\n\t\t\tcacheAndTracker.epochTracker,\n\t\t\tthis.socketReferenceKeyPrefix,\n\t\t\tclientIsSummarizer,\n\t\t);\n\t}\n}\n\n/**\n * Extract the sharing link kind from the resolved URL's query paramerters\n */\nfunction getSharingLinkParams(\n\thostPolicy: HostStoragePolicy,\n\tsearchParams: URLSearchParams,\n): ISharingLinkKind | undefined {\n\t// extract request parameters for creation of sharing link (if provided) if the feature is enabled\n\tlet createShareLinkParam: ISharingLinkKind | undefined;\n\tif (hostPolicy.enableSingleRequestForShareLinkWithCreate) {\n\t\tconst createLinkScope = searchParams.get(\"createLinkScope\");\n\t\tconst createLinkRole = searchParams.get(\"createLinkRole\");\n\t\tif (createLinkScope && SharingLinkScope[createLinkScope]) {\n\t\t\tcreateShareLinkParam = {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\tscope: SharingLinkScope[createLinkScope],\n\t\t\t\t...(createLinkRole && SharingLinkRole[createLinkRole]\n\t\t\t\t\t? // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\t\t\t{ role: SharingLinkRole[createLinkRole] }\n\t\t\t\t\t: {}),\n\t\t\t};\n\t\t}\n\t}\n\treturn createShareLinkParam;\n}\n"]}
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import type { ILayerCompatDetails } from "@fluid-internal/client-utils";
5
+ import { type ILayerCompatDetails } from "@fluid-internal/client-utils";
6
6
  /**
7
7
  * ODSP Driver's compatibility details that is exposed to the Loader layer.
8
8
  * @internal
@@ -1 +1 @@
1
- {"version":3,"file":"odspLayerCompatState.d.ts","sourceRoot":"","sources":["../src/odspLayerCompatState.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAIxE;;;GAGG;AACH,eAAO,MAAM,gCAAgC,EAAE,mBAa9C,CAAC"}
1
+ {"version":3,"file":"odspLayerCompatState.d.ts","sourceRoot":"","sources":["../src/odspLayerCompatState.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAc,KAAK,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAIpF;;;GAGG;AACH,eAAO,MAAM,gCAAgC,EAAE,mBAa9C,CAAC"}
@@ -5,6 +5,7 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.odspDriverCompatDetailsForLoader = void 0;
8
+ const client_utils_1 = require("@fluid-internal/client-utils");
8
9
  const packageVersion_js_1 = require("./packageVersion.js");
9
10
  /**
10
11
  * ODSP Driver's compatibility details that is exposed to the Loader layer.
@@ -18,7 +19,7 @@ exports.odspDriverCompatDetailsForLoader = {
18
19
  /**
19
20
  * The current generation of the ODSP Driver layer.
20
21
  */
21
- generation: 3,
22
+ generation: client_utils_1.generation,
22
23
  /**
23
24
  * The features supported by the ODSP Driver layer across the Driver / Loader boundary.
24
25
  */
@@ -1 +1 @@
1
- {"version":3,"file":"odspLayerCompatState.js","sourceRoot":"","sources":["../src/odspLayerCompatState.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,2DAAiD;AAEjD;;;GAGG;AACU,QAAA,gCAAgC,GAAwB;IACpE;;OAEG;IACH,UAAU,EAAV,8BAAU;IACV;;OAEG;IACH,UAAU,EAAE,CAAC;IACb;;OAEG;IACH,iBAAiB,EAAE,IAAI,GAAG,EAAU;CACpC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ILayerCompatDetails } from \"@fluid-internal/client-utils\";\n\nimport { pkgVersion } from \"./packageVersion.js\";\n\n/**\n * ODSP Driver's compatibility details that is exposed to the Loader layer.\n * @internal\n */\nexport const odspDriverCompatDetailsForLoader: ILayerCompatDetails = {\n\t/**\n\t * The package version of the ODSP Driver layer.\n\t */\n\tpkgVersion,\n\t/**\n\t * The current generation of the ODSP Driver layer.\n\t */\n\tgeneration: 3,\n\t/**\n\t * The features supported by the ODSP Driver layer across the Driver / Loader boundary.\n\t */\n\tsupportedFeatures: new Set<string>(),\n};\n"]}
1
+ {"version":3,"file":"odspLayerCompatState.js","sourceRoot":"","sources":["../src/odspLayerCompatState.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAoF;AAEpF,2DAAiD;AAEjD;;;GAGG;AACU,QAAA,gCAAgC,GAAwB;IACpE;;OAEG;IACH,UAAU,EAAV,8BAAU;IACV;;OAEG;IACH,UAAU,EAAV,yBAAU;IACV;;OAEG;IACH,iBAAiB,EAAE,IAAI,GAAG,EAAU;CACpC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { generation, type ILayerCompatDetails } from \"@fluid-internal/client-utils\";\n\nimport { pkgVersion } from \"./packageVersion.js\";\n\n/**\n * ODSP Driver's compatibility details that is exposed to the Loader layer.\n * @internal\n */\nexport const odspDriverCompatDetailsForLoader: ILayerCompatDetails = {\n\t/**\n\t * The package version of the ODSP Driver layer.\n\t */\n\tpkgVersion,\n\t/**\n\t * The current generation of the ODSP Driver layer.\n\t */\n\tgeneration,\n\t/**\n\t * The features supported by the ODSP Driver layer across the Driver / Loader boundary.\n\t */\n\tsupportedFeatures: new Set<string>(),\n};\n"]}
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export declare const pkgName = "@fluidframework/odsp-driver";
8
- export declare const pkgVersion = "2.74.0";
8
+ export declare const pkgVersion = "2.80.0";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -8,5 +8,5 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.pkgVersion = exports.pkgName = void 0;
10
10
  exports.pkgName = "@fluidframework/odsp-driver";
11
- exports.pkgVersion = "2.74.0";
11
+ exports.pkgVersion = "2.80.0";
12
12
  //# sourceMappingURL=packageVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,6BAA6B,CAAC;AACxC,QAAA,UAAU,GAAG,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/odsp-driver\";\nexport const pkgVersion = \"2.74.0\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,6BAA6B,CAAC;AACxC,QAAA,UAAU,GAAG,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/odsp-driver\";\nexport const pkgVersion = \"2.80.0\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"vroom.d.ts","sourceRoot":"","sources":["../src/vroom.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACX,aAAa,EACb,uBAAuB,EACvB,+BAA+B,EAC/B,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EACN,KAAK,mBAAmB,EAExB,MAAM,0CAA0C,CAAC;AAIlD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGtD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAQ1D;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,gBAAgB,6CAEjB,aAAa,QACjB,MAAM,UACJ,KAAK,GAAG,MAAM,UACd,mBAAmB,iBACZ,+BAA+B,gBAChC,YAAY,sBACN,OAAO,WAClB,mBAAmB,6BACD,OAAO,GAAG,SAAS,6BACnB,OAAO,GAAG,SAAS,2BACrB,OAAO,eACnB,MAAM,GAAG,SAAS,KAC7B,QAAQ,uBAAuB,CAAC,CAwFnC,CAAC"}
1
+ {"version":3,"file":"vroom.d.ts","sourceRoot":"","sources":["../src/vroom.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACX,aAAa,EACb,uBAAuB,EACvB,+BAA+B,EAC/B,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EACN,KAAK,mBAAmB,EAExB,MAAM,0CAA0C,CAAC;AAGlD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGtD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAQ1D;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,gBAAgB,6CAEjB,aAAa,QACjB,MAAM,UACJ,KAAK,GAAG,MAAM,UACd,mBAAmB,iBACZ,+BAA+B,gBAChC,YAAY,sBACN,OAAO,WAClB,mBAAmB,6BACD,OAAO,GAAG,SAAS,6BACnB,OAAO,GAAG,SAAS,2BACrB,OAAO,eACnB,MAAM,GAAG,SAAS,KAC7B,QAAQ,uBAAuB,CAAC,CAwFnC,CAAC"}
package/dist/vroom.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"vroom.js","sourceRoot":"","sources":["../src/vroom.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAQH,uEAGkD;AAElD,+BAAkC;AAGlC,6CAAuC;AACvC,yDAAgD;AAEhD,mDAA+C;AAO/C;;;;;;;;;;;;;;;;;GAiBG;AACU,QAAA,gBAAgB,GAAG,IAAA,oBAAO,EACtC,KAAK,EACJ,QAAuB,EACvB,IAAY,EACZ,MAAsB,EACtB,MAA2B,EAC3B,a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,EAAE,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC;YACnC,iBAAiB;YACjB,6BAA6B,EAAE,QAAQ,CAAC,OAAO,CAAC,6BAA6B;SAC7E,CAAC,CAAC;QAEH,IAAI,QAAQ,CAAC,OAAO,CAAC,eAAe,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;YACpE,QAAQ,CAAC,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,eAAe,CAAC;QAC9D,CAAC;QAED,OAAO,QAAQ,CAAC,OAAO,CAAC;IACzB,CAAC,CACD,CAAC;AACH,CAAC,CACD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITelemetryBaseProperties } from \"@fluidframework/core-interfaces\";\nimport type {\n\tIOdspUrlParts,\n\tISocketStorageDiscovery,\n\tInstrumentedStorageTokenFetcher,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\ttype ITelemetryLoggerExt,\n\tPerformanceEvent,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { v4 as uuid } from \"uuid\";\n\nimport type { EpochTracker } from \"./epochTracker.js\";\nimport { mockify } from \"./mockify.js\";\nimport { getApiRoot } from \"./odspUrlHelper.js\";\nimport type { TokenFetchOptionsEx } from \"./odspUtils.js\";\nimport { runWithRetry } from \"./retryUtils.js\";\n\ninterface IJoinSessionBody {\n\trequestSocketToken?: boolean;\n\tdisplayName?: string;\n}\n\n/**\n * Makes join session call on SPO to get information about the web socket for a document\n * @param urlParts - The SPO drive id, itemId, siteUrl that this request should be made against\n * @param path - The API path that is relevant to this request\n * @param method - The type of request, such as GET or POST\n * @param logger - A logger to use for this request\n * @param getAuthHeader - A function that is able to provide the access token for this request\n * @param epochTracker - fetch wrapper which incorporates epoch logic around joinSession call\n * @param requestSocketToken - flag indicating whether joinSession is expected to return access token\n * which is used when establishing websocket connection with collab session backend service.\n * @param options - Options to fetch the token.\n * @param disableJoinSessionRefresh - Whether the caller wants to disable refreshing join session periodically.\n * @param setSensitivityLabelHeader - Whether the caller wants to set the Return-Sensitivity-Labels Prefer header in the join session request.\n * @param isRefreshingJoinSession - whether call is to refresh the session before expiry.\n * @param displayName - display name used to identify client joining a session.\n * This is optional and used only when collab session is being joined by client acting in app-only mode (i.e. without user context).\n * If not specified client display name is extracted from the access token that is used to join session.\n */\nexport const fetchJoinSession = mockify(\n\tasync (\n\t\turlParts: IOdspUrlParts,\n\t\tpath: string,\n\t\tmethod: \"GET\" | \"POST\",\n\t\tlogger: ITelemetryLoggerExt,\n\t\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\t\tepochTracker: EpochTracker,\n\t\trequestSocketToken: boolean,\n\t\toptions: TokenFetchOptionsEx,\n\t\tdisableJoinSessionRefresh: boolean | undefined,\n\t\tsetSensitivityLabelHeader: boolean | undefined,\n\t\tisRefreshingJoinSession: boolean,\n\t\tdisplayName: string | undefined,\n\t): Promise<ISocketStorageDiscovery> => {\n\t\tconst apiRoot = getApiRoot(new URL(urlParts.siteUrl));\n\t\tconst url = `${apiRoot}/drives/${urlParts.driveId}/items/${urlParts.itemId}/${path}?ump=1`;\n\t\tconst authHeader = await getAuthHeader(\n\t\t\t{ ...options, request: { url, method } },\n\t\t\t\"JoinSession\",\n\t\t);\n\n\t\tconst tokenRefreshProps = options.refresh\n\t\t\t? { hasClaims: !!options.claims, hasTenantId: !!options.tenantId }\n\t\t\t: {};\n\t\tconst details: ITelemetryBaseProperties = {\n\t\t\trefreshedToken: options.refresh,\n\t\t\trequestSocketToken,\n\t\t\t...tokenRefreshProps,\n\t\t\trefreshingSession: isRefreshingJoinSession,\n\t\t};\n\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{\n\t\t\t\teventName: \"JoinSession\",\n\t\t\t\tattempts: options.refresh ? 2 : 1,\n\t\t\t\tdetails: JSON.stringify(details),\n\t\t\t\t...tokenRefreshProps,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst formBoundary = uuid();\n\t\t\t\tlet postBody = `--${formBoundary}\\r\\n`;\n\t\t\t\tpostBody += `Authorization: ${authHeader}\\r\\n`;\n\t\t\t\tpostBody += `X-HTTP-Method-Override: POST\\r\\n`;\n\t\t\t\tpostBody += `Content-Type: application/json\\r\\n`;\n\t\t\t\tif (!disableJoinSessionRefresh) {\n\t\t\t\t\tpostBody += `Prefer: FluidRemoveCheckAccess\\r\\n`;\n\t\t\t\t}\n\t\t\t\tif (setSensitivityLabelHeader) {\n\t\t\t\t\tpostBody += `Prefer: Return-Sensitivity-Labels\\r\\n`;\n\t\t\t\t}\n\t\t\t\tpostBody += `_post: 1\\r\\n`;\n\n\t\t\t\tlet requestBody: IJoinSessionBody | undefined;\n\t\t\t\tif (requestSocketToken) {\n\t\t\t\t\trequestBody = { ...requestBody, requestSocketToken: true };\n\t\t\t\t}\n\t\t\t\tif (displayName) {\n\t\t\t\t\trequestBody = { ...requestBody, displayName };\n\t\t\t\t}\n\t\t\t\tif (requestBody) {\n\t\t\t\t\tpostBody += `\\r\\n${JSON.stringify(requestBody)}\\r\\n`;\n\t\t\t\t}\n\t\t\t\tpostBody += `\\r\\n--${formBoundary}--`;\n\t\t\t\tconst headers: { [index: string]: string } = {\n\t\t\t\t\t\"Content-Type\": `multipart/form-data;boundary=${formBoundary}`,\n\t\t\t\t};\n\n\t\t\t\tconst response = await runWithRetry(\n\t\t\t\t\tasync () =>\n\t\t\t\t\t\tepochTracker.fetchAndParseAsJSON<ISocketStorageDiscovery>(\n\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t\t{ method, headers, body: postBody },\n\t\t\t\t\t\t\t\"joinSession\",\n\t\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t),\n\t\t\t\t\t\"joinSession\",\n\t\t\t\t\tlogger,\n\t\t\t\t);\n\n\t\t\t\tconst socketUrl = response.content.deltaStreamSocketUrl;\n\t\t\t\t// expecting socketUrl to be something like https://{hostName}/...\n\t\t\t\tconst webSocketHostName = socketUrl.split(\"/\")[2];\n\n\t\t\t\t// TODO SPO-specific telemetry\n\t\t\t\tevent.end({\n\t\t\t\t\t...response.propsToLog,\n\t\t\t\t\t// pushV2 websocket urls will contain pushf\n\t\t\t\t\tpushv2: socketUrl.includes(\"pushf\"),\n\t\t\t\t\twebSocketHostName,\n\t\t\t\t\trefreshSessionDurationSeconds: response.content.refreshSessionDurationSeconds,\n\t\t\t\t});\n\n\t\t\t\tif (response.content.runtimeTenantId && !response.content.tenantId) {\n\t\t\t\t\tresponse.content.tenantId = response.content.runtimeTenantId;\n\t\t\t\t}\n\n\t\t\t\treturn response.content;\n\t\t\t},\n\t\t);\n\t},\n);\n"]}
1
+ {"version":3,"file":"vroom.js","sourceRoot":"","sources":["../src/vroom.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAQH,uEAGkD;AAClD,+BAAkC;AAGlC,6CAAuC;AACvC,yDAAgD;AAEhD,mDAA+C;AAO/C;;;;;;;;;;;;;;;;;GAiBG;AACU,QAAA,gBAAgB,GAAG,IAAA,oBAAO,EACtC,KAAK,EACJ,QAAuB,EACvB,IAAY,EACZ,MAAsB,EACtB,MAA2B,EAC3B,aAA8C,EAC9C,YAA0B,EAC1B,kBAA2B,EAC3B,OAA4B,EAC5B,yBAA8C,EAC9C,yBAA8C,EAC9C,uBAAgC,EAChC,WAA+B,EACI,EAAE;IACrC,MAAM,OAAO,GAAG,IAAA,6BAAU,EAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;IACtD,MAAM,GAAG,GAAG,GAAG,OAAO,WAAW,QAAQ,CAAC,OAAO,UAAU,QAAQ,CAAC,MAAM,IAAI,IAAI,QAAQ,CAAC;IAC3F,MAAM,UAAU,GAAG,MAAM,aAAa,CACrC,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EACxC,aAAa,CACb,CA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under the MIT License.\n */\n\nimport type { ITelemetryBaseProperties } from \"@fluidframework/core-interfaces\";\nimport type {\n\tIOdspUrlParts,\n\tISocketStorageDiscovery,\n\tInstrumentedStorageTokenFetcher,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\ttype ITelemetryLoggerExt,\n\tPerformanceEvent,\n} from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport type { EpochTracker } from \"./epochTracker.js\";\nimport { mockify } from \"./mockify.js\";\nimport { getApiRoot } from \"./odspUrlHelper.js\";\nimport type { TokenFetchOptionsEx } from \"./odspUtils.js\";\nimport { runWithRetry } from \"./retryUtils.js\";\n\ninterface IJoinSessionBody {\n\trequestSocketToken?: boolean;\n\tdisplayName?: string;\n}\n\n/**\n * Makes join session call on SPO to get information about the web socket for a document\n * @param urlParts - The SPO drive id, itemId, siteUrl that this request should be made against\n * @param path - The API path that is relevant to this request\n * @param method - The type of request, such as GET or POST\n * @param logger - A logger to use for this request\n * @param getAuthHeader - A function that is able to provide the access token for this request\n * @param epochTracker - fetch wrapper which incorporates epoch logic around joinSession call\n * @param requestSocketToken - flag indicating whether joinSession is expected to return access token\n * which is used when establishing websocket connection with collab session backend service.\n * @param options - Options to fetch the token.\n * @param disableJoinSessionRefresh - Whether the caller wants to disable refreshing join session periodically.\n * @param setSensitivityLabelHeader - Whether the caller wants to set the Return-Sensitivity-Labels Prefer header in the join session request.\n * @param isRefreshingJoinSession - whether call is to refresh the session before expiry.\n * @param displayName - display name used to identify client joining a session.\n * This is optional and used only when collab session is being joined by client acting in app-only mode (i.e. without user context).\n * If not specified client display name is extracted from the access token that is used to join session.\n */\nexport const fetchJoinSession = mockify(\n\tasync (\n\t\turlParts: IOdspUrlParts,\n\t\tpath: string,\n\t\tmethod: \"GET\" | \"POST\",\n\t\tlogger: ITelemetryLoggerExt,\n\t\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\t\tepochTracker: EpochTracker,\n\t\trequestSocketToken: boolean,\n\t\toptions: TokenFetchOptionsEx,\n\t\tdisableJoinSessionRefresh: boolean | undefined,\n\t\tsetSensitivityLabelHeader: boolean | undefined,\n\t\tisRefreshingJoinSession: boolean,\n\t\tdisplayName: string | undefined,\n\t): Promise<ISocketStorageDiscovery> => {\n\t\tconst apiRoot = getApiRoot(new URL(urlParts.siteUrl));\n\t\tconst url = `${apiRoot}/drives/${urlParts.driveId}/items/${urlParts.itemId}/${path}?ump=1`;\n\t\tconst authHeader = await getAuthHeader(\n\t\t\t{ ...options, request: { url, method } },\n\t\t\t\"JoinSession\",\n\t\t);\n\n\t\tconst tokenRefreshProps = options.refresh\n\t\t\t? { hasClaims: !!options.claims, hasTenantId: !!options.tenantId }\n\t\t\t: {};\n\t\tconst details: ITelemetryBaseProperties = {\n\t\t\trefreshedToken: options.refresh,\n\t\t\trequestSocketToken,\n\t\t\t...tokenRefreshProps,\n\t\t\trefreshingSession: isRefreshingJoinSession,\n\t\t};\n\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{\n\t\t\t\teventName: \"JoinSession\",\n\t\t\t\tattempts: options.refresh ? 2 : 1,\n\t\t\t\tdetails: JSON.stringify(details),\n\t\t\t\t...tokenRefreshProps,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst formBoundary = uuid();\n\t\t\t\tlet postBody = `--${formBoundary}\\r\\n`;\n\t\t\t\tpostBody += `Authorization: ${authHeader}\\r\\n`;\n\t\t\t\tpostBody += `X-HTTP-Method-Override: POST\\r\\n`;\n\t\t\t\tpostBody += `Content-Type: application/json\\r\\n`;\n\t\t\t\tif (!disableJoinSessionRefresh) {\n\t\t\t\t\tpostBody += `Prefer: FluidRemoveCheckAccess\\r\\n`;\n\t\t\t\t}\n\t\t\t\tif (setSensitivityLabelHeader) {\n\t\t\t\t\tpostBody += `Prefer: Return-Sensitivity-Labels\\r\\n`;\n\t\t\t\t}\n\t\t\t\tpostBody += `_post: 1\\r\\n`;\n\n\t\t\t\tlet requestBody: IJoinSessionBody | undefined;\n\t\t\t\tif (requestSocketToken) {\n\t\t\t\t\trequestBody = { ...requestBody, requestSocketToken: true };\n\t\t\t\t}\n\t\t\t\tif (displayName) {\n\t\t\t\t\trequestBody = { ...requestBody, displayName };\n\t\t\t\t}\n\t\t\t\tif (requestBody) {\n\t\t\t\t\tpostBody += `\\r\\n${JSON.stringify(requestBody)}\\r\\n`;\n\t\t\t\t}\n\t\t\t\tpostBody += `\\r\\n--${formBoundary}--`;\n\t\t\t\tconst headers: { [index: string]: string } = {\n\t\t\t\t\t\"Content-Type\": `multipart/form-data;boundary=${formBoundary}`,\n\t\t\t\t};\n\n\t\t\t\tconst response = await runWithRetry(\n\t\t\t\t\tasync () =>\n\t\t\t\t\t\tepochTracker.fetchAndParseAsJSON<ISocketStorageDiscovery>(\n\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t\t{ method, headers, body: postBody },\n\t\t\t\t\t\t\t\"joinSession\",\n\t\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t),\n\t\t\t\t\t\"joinSession\",\n\t\t\t\t\tlogger,\n\t\t\t\t);\n\n\t\t\t\tconst socketUrl = response.content.deltaStreamSocketUrl;\n\t\t\t\t// expecting socketUrl to be something like https://{hostName}/...\n\t\t\t\tconst webSocketHostName = socketUrl.split(\"/\")[2];\n\n\t\t\t\t// TODO SPO-specific telemetry\n\t\t\t\tevent.end({\n\t\t\t\t\t...response.propsToLog,\n\t\t\t\t\t// pushV2 websocket urls will contain pushf\n\t\t\t\t\tpushv2: socketUrl.includes(\"pushf\"),\n\t\t\t\t\twebSocketHostName,\n\t\t\t\t\trefreshSessionDurationSeconds: response.content.refreshSessionDurationSeconds,\n\t\t\t\t});\n\n\t\t\t\tif (response.content.runtimeTenantId && !response.content.tenantId) {\n\t\t\t\t\tresponse.content.tenantId = response.content.runtimeTenantId;\n\t\t\t\t}\n\n\t\t\t\treturn response.content;\n\t\t\t},\n\t\t);\n\t},\n);\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"createNewUtils.d.ts","sourceRoot":"","sources":["../../src/createFile/createNewUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAEN,KAAK,YAAY,EAGjB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAAE,SAAS,EAAiB,MAAM,6CAA6C,CAAC;AAM5F,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,kDAAkD,CAAC;AACxG,OAAO,EACN,KAAK,mBAAmB,EAExB,MAAM,0CAA0C,CAAC;AAIlD,OAAO,KAAK,EACX,mBAAmB,EAInB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAMpE;;GAEG;AACH,wBAAgB,yCAAyC,CACxD,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,MAAM,GACZ,SAAS,CAiBX;AAiDD,wBAAgB,mCAAmC,CAClD,gBAAgB,EAAE,YAAY,GAC5B,mBAAmB,CA2BrB;AAiED,wBAAsB,2BAA2B,CAAC,CAAC,EAAE,IAAI,EAAE;IAC1D,iBAAiB,EAAE,mBAAmB,CAAC;IACvC,aAAa,EAAE,+BAA+B,CAAC;IAC/C,MAAM,EAAE,mBAAmB,CAAC;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,sCAAsC,EAAE,OAAO,CAAC;IAChD,YAAY,EAAE,YAAY,CAAC;IAC3B,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,SAAS,CAAC;IACrB,wBAAwB,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,IAAI,CAAC;IAChD,iBAAiB,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;CAC9C,GAAG,OAAO,CAAC,CAAC,CAAC,CAwGb"}
1
+ {"version":3,"file":"createNewUtils.d.ts","sourceRoot":"","sources":["../../src/createFile/createNewUtils.ts"],"names":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AkB,CAAC,eAAe,CAAC;oBACtC,cAAc,EAAE,kBAAkB;iBAClC,CAAC;gBACF,QAAQ,GAAG,YAAY,CAAC;YACzB,CAAC;YAED,MAAM,aAAa,GAAG,MAAM,YAAY,CACvC,KAAK,IAAI,EAAE,CACV,YAAY,CAAC,mBAAmB,CAC/B,GAAG,EACH;gBACC,IAAI,EAAE,QAAQ;gBACd,OAAO;gBACP,MAAM;aACN,EACD,SAAS,EACT,SAAS,CACT,EACF,aAAa,EACb,MAAM,CACN,CAAC;YAEF,wBAAwB,EAAE,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;YAElD,KAAK,CAAC,GAAG,CAAC;gBACT,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACjC,GAAG,aAAa,CAAC,UAAU;aAC3B,CAAC,CAAC;YAEH,OAAO,aAAa,CAAC,OAAO,CAAC;QAC9B,CAAC,CACD,CAAC;IACH,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { Uint8ArrayToString, stringToBuffer } from \"@fluid-internal/client-utils\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport {\n\ttype ISummaryBlob,\n\ttype ISummaryTree,\n\ttype SummaryObject,\n\tSummaryType,\n} from \"@fluidframework/driver-definitions\";\nimport type { ISnapshot, ISnapshotTree } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tgetDocAttributesFromProtocolSummary,\n\tgetGitType,\n\tisCombinedAppAndProtocolSummary,\n} from \"@fluidframework/driver-utils/internal\";\nimport type { InstrumentedStorageTokenFetcher } from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\ttype ITelemetryLoggerExt,\n\tPerformanceEvent,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { v4 as uuid } from \"uuid\";\n\nimport type {\n\tIOdspSummaryPayload,\n\tIOdspSummaryTree,\n\tOdspSummaryTreeEntry,\n\tOdspSummaryTreeValue,\n} from \"./../contracts.js\";\nimport type { EpochTracker, FetchType } from \"./../epochTracker.js\";\nimport { getHeadersWithAuth } from \"./../getUrlAndHeadersWithAuth.js\";\nimport { checkForKnownServerFarmType } from \"./../odspUrlHelper.js\";\nimport { getWithRetryForTokenRefresh, maxUmpPostBodySize } from \"./../odspUtils.js\";\nimport { runWithRetry } from \"./../retryUtils.js\";\n\n/**\n * Converts a summary(ISummaryTree) taken in detached container to snapshot tree and blobs\n */\nexport function convertCreateNewSummaryTreeToTreeAndBlobs(\n\tsummary: ISummaryTree,\n\ttreeId: string,\n): ISnapshot {\n\tconst protocolSummary = summary.tree[\".protocol\"] as ISummaryTree;\n\tconst documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);\n\tconst sequenceNumber = documentAttributes.sequenceNumber;\n\tconst blobContents = new Map<string, ArrayBuffer>();\n\tconst snapshotTree = convertCreateNewSummaryTreeToTreeAndBlobsCore(summary, blobContents);\n\tsnapshotTree.id = treeId;\n\tconst snapshotTreeValue: ISnapshot = {\n\t\tsnapshotTree,\n\t\tblobContents,\n\t\tops: [],\n\t\tsequenceNumber,\n\t\tlatestSequenceNumber: sequenceNumber,\n\t\tsnapshotFormatV: 1,\n\t};\n\n\treturn snapshotTreeValue;\n}\n\nfunction convertCreateNewSummaryTreeToTreeAndBlobsCore(\n\tsummary: ISummaryTree,\n\tblobs: Map<string, ArrayBuffer>,\n): ISnapshotTree {\n\tconst treeNode: ISnapshotTree = {\n\t\tblobs: {},\n\t\ttrees: {},\n\t\tunreferenced: summary.unreferenced,\n\t\tgroupId: summary.groupId,\n\t};\n\tconst keys = Object.keys(summary.tree);\n\tfor (const key of keys) {\n\t\tconst summaryObject = summary.tree[key];\n\n\t\tswitch (summaryObject.type) {\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\ttreeNode.trees[key] = convertCreateNewSummaryTreeToTreeAndBlobsCore(\n\t\t\t\t\tsummaryObject,\n\t\t\t\t\tblobs,\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\tconst contentBuffer =\n\t\t\t\t\ttypeof summaryObject.content === \"string\"\n\t\t\t\t\t\t? stringToBuffer(summaryObject.content, \"utf8\")\n\t\t\t\t\t\t: summaryObject.content;\n\t\t\t\tconst blobId = uuid();\n\t\t\t\ttreeNode.blobs[key] = blobId;\n\t\t\t\tblobs.set(blobId, contentBuffer);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Handle:\n\t\t\tcase SummaryType.Attachment: {\n\t\t\t\tthrow new Error(`No ${summaryObject.type} should be present for detached summary!`);\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(\n\t\t\t\t\tsummaryObject,\n\t\t\t\t\t`Unknown tree type ${(summaryObject as SummaryObject).type}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\treturn treeNode;\n}\n\nexport function convertSummaryIntoContainerSnapshot(\n\tcreateNewSummary: ISummaryTree,\n): IOdspSummaryPayload {\n\tif (!isCombinedAppAndProtocolSummary(createNewSummary)) {\n\t\tthrow new Error(\"App and protocol summary required for create new path!!\");\n\t}\n\tconst appSummary = createNewSummary.tree[\".app\"];\n\tconst protocolSummary = createNewSummary.tree[\".protocol\"];\n\tconst documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);\n\tconst attributesSummaryBlob: ISummaryBlob = {\n\t\ttype: SummaryType.Blob,\n\t\tcontent: JSON.stringify(documentAttributes),\n\t};\n\tprotocolSummary.tree.attributes = attributesSummaryBlob;\n\tconst convertedCreateNewSummary: ISummaryTree = {\n\t\ttype: SummaryType.Tree,\n\t\ttree: {\n\t\t\t\".protocol\": protocolSummary,\n\t\t\t\".app\": appSummary,\n\t\t},\n\t};\n\tconst snapshotTree = convertSummaryToSnapshotTreeForCreateNew(convertedCreateNewSummary);\n\tconst snapshot: IOdspSummaryPayload = {\n\t\tentries: snapshotTree.entries ?? [],\n\t\tmessage: \"app\",\n\t\tsequenceNumber: documentAttributes.sequenceNumber,\n\t\ttype: \"container\",\n\t};\n\treturn snapshot;\n}\n\n/**\n * Converts a summary tree to ODSP tree\n */\nfunction convertSummaryToSnapshotTreeForCreateNew(summary: ISummaryTree): IOdspSummaryTree {\n\tconst snapshotTree: IOdspSummaryTree = {\n\t\ttype: \"tree\",\n\t\tentries: [],\n\t};\n\n\tconst keys = Object.keys(summary.tree);\n\tfor (const key of keys) {\n\t\tassert(!key.includes(\"/\"), 0x9cc /* id should not include slashes */);\n\t\tconst summaryObject = summary.tree[key];\n\n\t\tlet value: OdspSummaryTreeValue;\n\t\t// Tracks if an entry is unreferenced. Currently, only tree entries can be marked as unreferenced. If the\n\t\t// property is not present, the tree entry is considered referenced. If the property is present and is true,\n\t\t// the tree entry is considered unreferenced.\n\t\tlet unreferenced: true | undefined;\n\t\tlet groupId: string | undefined;\n\n\t\tswitch (summaryObject.type) {\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\tvalue = convertSummaryToSnapshotTreeForCreateNew(summaryObject);\n\t\t\t\tunreferenced = summaryObject.unreferenced;\n\t\t\t\tgroupId = summaryObject.groupId;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\tconst content =\n\t\t\t\t\ttypeof summaryObject.content === \"string\"\n\t\t\t\t\t\t? summaryObject.content\n\t\t\t\t\t\t: Uint8ArrayToString(summaryObject.content, \"base64\");\n\t\t\t\tconst encoding = typeof summaryObject.content === \"string\" ? \"utf-8\" : \"base64\";\n\n\t\t\t\tvalue = {\n\t\t\t\t\ttype: \"blob\",\n\t\t\t\t\tcontent,\n\t\t\t\t\tencoding,\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Handle: {\n\t\t\t\tthrow new Error(\"No handle should be present for first summary!!\");\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow new Error(`Unknown tree type ${summaryObject.type}`);\n\t\t\t}\n\t\t}\n\n\t\tconst entry: OdspSummaryTreeEntry = {\n\t\t\tpath: key,\n\t\t\ttype: getGitType(summaryObject),\n\t\t\tvalue,\n\t\t\tunreferenced,\n\t\t\tgroupId,\n\t\t};\n\t\tsnapshotTree.entries?.push(entry);\n\t}\n\n\treturn snapshotTree;\n}\n\nexport async function createNewFluidContainerCore<T>(args: {\n\tcontainerSnapshot: IOdspSummaryPayload;\n\tgetAuthHeader: InstrumentedStorageTokenFetcher;\n\tlogger: ITelemetryLoggerExt;\n\tinitialUrl: string;\n\tforceAccessTokenViaAuthorizationHeader: boolean;\n\tepochTracker: EpochTracker;\n\ttelemetryName: string;\n\tfetchType: FetchType;\n\tvalidateResponseCallback?: (content: T) => void;\n\tadditionalHeaders?: { [key: string]: string };\n}): Promise<T> {\n\tconst {\n\t\tcontainerSnapshot,\n\t\tgetAuthHeader,\n\t\tlogger,\n\t\tinitialUrl,\n\t\tepochTracker,\n\t\ttelemetryName,\n\t\tfetchType,\n\t\tvalidateResponseCallback,\n\t\tadditionalHeaders = {},\n\t} = args;\n\tconst internalFarmType = checkForKnownServerFarmType(initialUrl);\n\n\treturn getWithRetryForTokenRefresh(async (options) => {\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{ eventName: telemetryName, details: { internalFarmType } },\n\t\t\tasync (event) => {\n\t\t\t\tconst snapshotBody = JSON.stringify(containerSnapshot);\n\t\t\t\tlet url: string;\n\t\t\t\tlet headers: { [index: string]: string };\n\t\t\t\tlet addInBody = false;\n\t\t\t\tconst formBoundary = uuid();\n\t\t\t\tconst urlObj = new URL(initialUrl);\n\t\t\t\turlObj.searchParams.set(\"ump\", \"1\");\n\t\t\t\tconst authInBodyUrl = urlObj.href;\n\t\t\t\tconst method = \"POST\";\n\t\t\t\tconst authHeader = await getAuthHeader(\n\t\t\t\t\t{ ...options, request: { url: authInBodyUrl, method } },\n\t\t\t\t\ttelemetryName,\n\t\t\t\t);\n\t\t\t\tconst postBodyWithAuthHeaders = [\n\t\t\t\t\t`Authorization: ${authHeader}`,\n\t\t\t\t\t`X-HTTP-Method-Override: POST`,\n\t\t\t\t\t`Content-Type: application/json`,\n\t\t\t\t];\n\t\t\t\tif (additionalHeaders !== undefined) {\n\t\t\t\t\tfor (const [key, value] of Object.entries(additionalHeaders)) {\n\t\t\t\t\t\tpostBodyWithAuthHeaders.push(`${key}: ${value}`);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst postBodyWithAuth = [\n\t\t\t\t\t`--${formBoundary}`,\n\t\t\t\t\t...postBodyWithAuthHeaders,\n\t\t\t\t\t`_post: 1`,\n\t\t\t\t\t`\\r\\n${snapshotBody}`,\n\t\t\t\t\t`\\r\\n--${formBoundary}--`,\n\t\t\t\t].join(\"\\r\\n\");\n\n\t\t\t\tlet postBody = snapshotBody;\n\t\t\t\t// We use the byte length of the post body to determine if we should use the multipart/form-data or not. This helps\n\t\t\t\t// in cases where the body contains data with different language where 1 char could be multiple code points.\n\t\t\t\tif (\n\t\t\t\t\tnew TextEncoder().encode(postBodyWithAuth).length <= maxUmpPostBodySize &&\n\t\t\t\t\tauthHeader?.startsWith(\"Bearer\")\n\t\t\t\t) {\n\t\t\t\t\turl = authInBodyUrl;\n\t\t\t\t\theaders = {\n\t\t\t\t\t\t\"Content-Type\": `multipart/form-data;boundary=${formBoundary}`,\n\t\t\t\t\t};\n\t\t\t\t\taddInBody = true;\n\t\t\t\t\tpostBody = postBodyWithAuth;\n\t\t\t\t} else {\n\t\t\t\t\turl = initialUrl;\n\t\t\t\t\tconst authHeaderNoUmp = await getAuthHeader(\n\t\t\t\t\t\t{ ...options, request: { url, method } },\n\t\t\t\t\t\ttelemetryName,\n\t\t\t\t\t);\n\t\t\t\t\theaders = {\n\t\t\t\t\t\t...additionalHeaders,\n\t\t\t\t\t\t...getHeadersWithAuth(authHeaderNoUmp),\n\t\t\t\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t\t\t};\n\t\t\t\t\tpostBody = snapshotBody;\n\t\t\t\t}\n\n\t\t\t\tconst fetchResponse = await runWithRetry(\n\t\t\t\t\tasync () =>\n\t\t\t\t\t\tepochTracker.fetchAndParseAsJSON<T>(\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: postBody,\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\tfetchType,\n\t\t\t\t\t\t\taddInBody,\n\t\t\t\t\t\t),\n\t\t\t\t\ttelemetryName,\n\t\t\t\t\tlogger,\n\t\t\t\t);\n\n\t\t\t\tvalidateResponseCallback?.(fetchResponse.content);\n\n\t\t\t\tevent.end({\n\t\t\t\t\tattempts: options.refresh ? 2 : 1,\n\t\t\t\t\t...fetchResponse.propsToLog,\n\t\t\t\t});\n\n\t\t\t\treturn fetchResponse.content;\n\t\t\t},\n\t\t);\n\t});\n}\n"]}
1
+ {"version":3,"file":"createNewUtils.js","sourceRoot":"","sources":["../../src/createFile/createNewUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAClF,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,EAIN,WAAW,GACX,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EACN,mCAAmC,EACnC,UAAU,EACV,+BAA+B,GAC/B,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAEN,gBAAgB,GAChB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AASlC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,2BAA2B,EAAE,k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CAAC,CAAC,CAAC,CAAC,CAAC;gBACjC,GAAG,aAAa,CAAC,UAAU;aAC3B,CAAC,CAAC;YAEH,OAAO,aAAa,CAAC,OAAO,CAAC;QAC9B,CAAC,CACD,CAAC;IACH,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { Uint8ArrayToString, stringToBuffer } from \"@fluid-internal/client-utils\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport {\n\ttype ISummaryBlob,\n\ttype ISummaryTree,\n\ttype SummaryObject,\n\tSummaryType,\n} from \"@fluidframework/driver-definitions\";\nimport type { ISnapshot, ISnapshotTree } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tgetDocAttributesFromProtocolSummary,\n\tgetGitType,\n\tisCombinedAppAndProtocolSummary,\n} from \"@fluidframework/driver-utils/internal\";\nimport type { InstrumentedStorageTokenFetcher } from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\ttype ITelemetryLoggerExt,\n\tPerformanceEvent,\n} from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport type {\n\tIOdspSummaryPayload,\n\tIOdspSummaryTree,\n\tOdspSummaryTreeEntry,\n\tOdspSummaryTreeValue,\n} from \"./../contracts.js\";\nimport type { EpochTracker, FetchType } from \"./../epochTracker.js\";\nimport { getHeadersWithAuth } from \"./../getUrlAndHeadersWithAuth.js\";\nimport { checkForKnownServerFarmType } from \"./../odspUrlHelper.js\";\nimport { getWithRetryForTokenRefresh, maxUmpPostBodySize } from \"./../odspUtils.js\";\nimport { runWithRetry } from \"./../retryUtils.js\";\n\n/**\n * Converts a summary(ISummaryTree) taken in detached container to snapshot tree and blobs\n */\nexport function convertCreateNewSummaryTreeToTreeAndBlobs(\n\tsummary: ISummaryTree,\n\ttreeId: string,\n): ISnapshot {\n\tconst protocolSummary = summary.tree[\".protocol\"] as ISummaryTree;\n\tconst documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);\n\tconst sequenceNumber = documentAttributes.sequenceNumber;\n\tconst blobContents = new Map<string, ArrayBuffer>();\n\tconst snapshotTree = convertCreateNewSummaryTreeToTreeAndBlobsCore(summary, blobContents);\n\tsnapshotTree.id = treeId;\n\tconst snapshotTreeValue: ISnapshot = {\n\t\tsnapshotTree,\n\t\tblobContents,\n\t\tops: [],\n\t\tsequenceNumber,\n\t\tlatestSequenceNumber: sequenceNumber,\n\t\tsnapshotFormatV: 1,\n\t};\n\n\treturn snapshotTreeValue;\n}\n\nfunction convertCreateNewSummaryTreeToTreeAndBlobsCore(\n\tsummary: ISummaryTree,\n\tblobs: Map<string, ArrayBuffer>,\n): ISnapshotTree {\n\tconst treeNode: ISnapshotTree = {\n\t\tblobs: {},\n\t\ttrees: {},\n\t\tunreferenced: summary.unreferenced,\n\t\tgroupId: summary.groupId,\n\t};\n\tconst keys = Object.keys(summary.tree);\n\tfor (const key of keys) {\n\t\tconst summaryObject = summary.tree[key];\n\n\t\tswitch (summaryObject.type) {\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\ttreeNode.trees[key] = convertCreateNewSummaryTreeToTreeAndBlobsCore(\n\t\t\t\t\tsummaryObject,\n\t\t\t\t\tblobs,\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\tconst contentBuffer =\n\t\t\t\t\ttypeof summaryObject.content === \"string\"\n\t\t\t\t\t\t? stringToBuffer(summaryObject.content, \"utf8\")\n\t\t\t\t\t\t: summaryObject.content;\n\t\t\t\tconst blobId = uuid();\n\t\t\t\ttreeNode.blobs[key] = blobId;\n\t\t\t\tblobs.set(blobId, contentBuffer);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Handle:\n\t\t\tcase SummaryType.Attachment: {\n\t\t\t\tthrow new Error(`No ${summaryObject.type} should be present for detached summary!`);\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(\n\t\t\t\t\tsummaryObject,\n\t\t\t\t\t`Unknown tree type ${(summaryObject as SummaryObject).type}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\treturn treeNode;\n}\n\nexport function convertSummaryIntoContainerSnapshot(\n\tcreateNewSummary: ISummaryTree,\n): IOdspSummaryPayload {\n\tif (!isCombinedAppAndProtocolSummary(createNewSummary)) {\n\t\tthrow new Error(\"App and protocol summary required for create new path!!\");\n\t}\n\tconst appSummary = createNewSummary.tree[\".app\"];\n\tconst protocolSummary = createNewSummary.tree[\".protocol\"];\n\tconst documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);\n\tconst attributesSummaryBlob: ISummaryBlob = {\n\t\ttype: SummaryType.Blob,\n\t\tcontent: JSON.stringify(documentAttributes),\n\t};\n\tprotocolSummary.tree.attributes = attributesSummaryBlob;\n\tconst convertedCreateNewSummary: ISummaryTree = {\n\t\ttype: SummaryType.Tree,\n\t\ttree: {\n\t\t\t\".protocol\": protocolSummary,\n\t\t\t\".app\": appSummary,\n\t\t},\n\t};\n\tconst snapshotTree = convertSummaryToSnapshotTreeForCreateNew(convertedCreateNewSummary);\n\tconst snapshot: IOdspSummaryPayload = {\n\t\tentries: snapshotTree.entries ?? [],\n\t\tmessage: \"app\",\n\t\tsequenceNumber: documentAttributes.sequenceNumber,\n\t\ttype: \"container\",\n\t};\n\treturn snapshot;\n}\n\n/**\n * Converts a summary tree to ODSP tree\n */\nfunction convertSummaryToSnapshotTreeForCreateNew(summary: ISummaryTree): IOdspSummaryTree {\n\tconst snapshotTree: IOdspSummaryTree = {\n\t\ttype: \"tree\",\n\t\tentries: [],\n\t};\n\n\tconst keys = Object.keys(summary.tree);\n\tfor (const key of keys) {\n\t\tassert(!key.includes(\"/\"), 0x9cc /* id should not include slashes */);\n\t\tconst summaryObject = summary.tree[key];\n\n\t\tlet value: OdspSummaryTreeValue;\n\t\t// Tracks if an entry is unreferenced. Currently, only tree entries can be marked as unreferenced. If the\n\t\t// property is not present, the tree entry is considered referenced. If the property is present and is true,\n\t\t// the tree entry is considered unreferenced.\n\t\tlet unreferenced: true | undefined;\n\t\tlet groupId: string | undefined;\n\n\t\tswitch (summaryObject.type) {\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\tvalue = convertSummaryToSnapshotTreeForCreateNew(summaryObject);\n\t\t\t\tunreferenced = summaryObject.unreferenced;\n\t\t\t\tgroupId = summaryObject.groupId;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\tconst content =\n\t\t\t\t\ttypeof summaryObject.content === \"string\"\n\t\t\t\t\t\t? summaryObject.content\n\t\t\t\t\t\t: Uint8ArrayToString(summaryObject.content, \"base64\");\n\t\t\t\tconst encoding = typeof summaryObject.content === \"string\" ? \"utf-8\" : \"base64\";\n\n\t\t\t\tvalue = {\n\t\t\t\t\ttype: \"blob\",\n\t\t\t\t\tcontent,\n\t\t\t\t\tencoding,\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Handle: {\n\t\t\t\tthrow new Error(\"No handle should be present for first summary!!\");\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow new Error(`Unknown tree type ${summaryObject.type}`);\n\t\t\t}\n\t\t}\n\n\t\tconst entry: OdspSummaryTreeEntry = {\n\t\t\tpath: key,\n\t\t\ttype: getGitType(summaryObject),\n\t\t\tvalue,\n\t\t\tunreferenced,\n\t\t\tgroupId,\n\t\t};\n\t\tsnapshotTree.entries?.push(entry);\n\t}\n\n\treturn snapshotTree;\n}\n\nexport async function createNewFluidContainerCore<T>(args: {\n\tcontainerSnapshot: IOdspSummaryPayload;\n\tgetAuthHeader: InstrumentedStorageTokenFetcher;\n\tlogger: ITelemetryLoggerExt;\n\tinitialUrl: string;\n\tforceAccessTokenViaAuthorizationHeader: boolean;\n\tepochTracker: EpochTracker;\n\ttelemetryName: string;\n\tfetchType: FetchType;\n\tvalidateResponseCallback?: (content: T) => void;\n\tadditionalHeaders?: { [key: string]: string };\n}): Promise<T> {\n\tconst {\n\t\tcontainerSnapshot,\n\t\tgetAuthHeader,\n\t\tlogger,\n\t\tinitialUrl,\n\t\tepochTracker,\n\t\ttelemetryName,\n\t\tfetchType,\n\t\tvalidateResponseCallback,\n\t\tadditionalHeaders = {},\n\t} = args;\n\tconst internalFarmType = checkForKnownServerFarmType(initialUrl);\n\n\treturn getWithRetryForTokenRefresh(async (options) => {\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{ eventName: telemetryName, details: { internalFarmType } },\n\t\t\tasync (event) => {\n\t\t\t\tconst snapshotBody = JSON.stringify(containerSnapshot);\n\t\t\t\tlet url: string;\n\t\t\t\tlet headers: { [index: string]: string };\n\t\t\t\tlet addInBody = false;\n\t\t\t\tconst formBoundary = uuid();\n\t\t\t\tconst urlObj = new URL(initialUrl);\n\t\t\t\turlObj.searchParams.set(\"ump\", \"1\");\n\t\t\t\tconst authInBodyUrl = urlObj.href;\n\t\t\t\tconst method = \"POST\";\n\t\t\t\tconst authHeader = await getAuthHeader(\n\t\t\t\t\t{ ...options, request: { url: authInBodyUrl, method } },\n\t\t\t\t\ttelemetryName,\n\t\t\t\t);\n\t\t\t\tconst postBodyWithAuthHeaders = [\n\t\t\t\t\t`Authorization: ${authHeader}`,\n\t\t\t\t\t`X-HTTP-Method-Override: POST`,\n\t\t\t\t\t`Content-Type: application/json`,\n\t\t\t\t];\n\t\t\t\tif (additionalHeaders !== undefined) {\n\t\t\t\t\tfor (const [key, value] of Object.entries(additionalHeaders)) {\n\t\t\t\t\t\tpostBodyWithAuthHeaders.push(`${key}: ${value}`);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst postBodyWithAuth = [\n\t\t\t\t\t`--${formBoundary}`,\n\t\t\t\t\t...postBodyWithAuthHeaders,\n\t\t\t\t\t`_post: 1`,\n\t\t\t\t\t`\\r\\n${snapshotBody}`,\n\t\t\t\t\t`\\r\\n--${formBoundary}--`,\n\t\t\t\t].join(\"\\r\\n\");\n\n\t\t\t\tlet postBody = snapshotBody;\n\t\t\t\t// We use the byte length of the post body to determine if we should use the multipart/form-data or not. This helps\n\t\t\t\t// in cases where the body contains data with different language where 1 char could be multiple code points.\n\t\t\t\tif (\n\t\t\t\t\tnew TextEncoder().encode(postBodyWithAuth).length <= maxUmpPostBodySize &&\n\t\t\t\t\tauthHeader?.startsWith(\"Bearer\")\n\t\t\t\t) {\n\t\t\t\t\turl = authInBodyUrl;\n\t\t\t\t\theaders = {\n\t\t\t\t\t\t\"Content-Type\": `multipart/form-data;boundary=${formBoundary}`,\n\t\t\t\t\t};\n\t\t\t\t\taddInBody = true;\n\t\t\t\t\tpostBody = postBodyWithAuth;\n\t\t\t\t} else {\n\t\t\t\t\turl = initialUrl;\n\t\t\t\t\tconst authHeaderNoUmp = await getAuthHeader(\n\t\t\t\t\t\t{ ...options, request: { url, method } },\n\t\t\t\t\t\ttelemetryName,\n\t\t\t\t\t);\n\t\t\t\t\theaders = {\n\t\t\t\t\t\t...additionalHeaders,\n\t\t\t\t\t\t...getHeadersWithAuth(authHeaderNoUmp),\n\t\t\t\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t\t\t};\n\t\t\t\t\tpostBody = snapshotBody;\n\t\t\t\t}\n\n\t\t\t\tconst fetchResponse = await runWithRetry(\n\t\t\t\t\tasync () =>\n\t\t\t\t\t\tepochTracker.fetchAndParseAsJSON<T>(\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: postBody,\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\tfetchType,\n\t\t\t\t\t\t\taddInBody,\n\t\t\t\t\t\t),\n\t\t\t\t\ttelemetryName,\n\t\t\t\t\tlogger,\n\t\t\t\t);\n\n\t\t\t\tvalidateResponseCallback?.(fetchResponse.content);\n\n\t\t\t\tevent.end({\n\t\t\t\t\tattempts: options.refresh ? 2 : 1,\n\t\t\t\t\t...fetchResponse.propsToLog,\n\t\t\t\t});\n\n\t\t\t\treturn fetchResponse.content;\n\t\t\t},\n\t\t);\n\t});\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"epochTracker.d.ts","sourceRoot":"","sources":["../src/epochTracker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAEX,MAAM,EACN,UAAU,EACV,eAAe,EACf,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAIN,WAAW,EAEX,MAAM,uCAAuC,CAAC;AAS/C,OAAO,EACN,KAAK,mBAAmB,EAMxB,MAAM,0CAA0C,CAAC;AAMlD,OAAO,KAAK,EAAE,mBAAmB,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAE3F,OAAO,EACN,KAAK,aAAa,EAKlB,MAAM,gBAAgB,CAAC;AAGxB;;;GAGG;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,GACV,YAAY,CAAC;AAEhB;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,OAAO,CAAC;AAEpD,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAE3C;;;;;;;;;;;;;;;;GAgBG;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,OAAO,CAAC,QAAQ,CAAC,4BAA4B,CAAS;IACtD,SA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* Licensed under the MIT License.\n */\n\nimport { assert, Deferred } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tICacheEntry,\n\tIEntry,\n\tIFileEntry,\n\tIPersistedCache,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tLocationRedirectionError,\n\tmaximumCacheDurationMs,\n\tNonRetryableError,\n\tRateLimiter,\n\tThrottlingError,\n} from \"@fluidframework/driver-utils/internal\";\nimport {\n\ttype IOdspError,\n\ttype IOdspErrorAugmentations,\n\ttype IOdspResolvedUrl,\n\tOdspErrorTypes,\n\tsnapshotKey,\n\tsnapshotWithLoadingGroupIdKey,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\ttype ITelemetryLoggerExt,\n\tPerformanceEvent,\n\tisFluidError,\n\tloggerToMonitoringContext,\n\tnormalizeError,\n\twrapError,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { v4 as uuid } from \"uuid\";\n\nimport { type IVersionedValueWithEpoch, persistedCacheValueVersion } from \"./contracts.js\";\nimport { ClpCompliantAppHeader } from \"./contractsPublic.js\";\nimport type { INonPersistentCache, IOdspCache, IPersistedFileCache } from \"./odspCache.js\";\nimport { patchOdspResolvedUrl } from \"./odspLocationRedirection.js\";\nimport {\n\ttype IOdspResponse,\n\tfetchAndParseAsJSONHelper,\n\tfetchArray,\n\tfetchHelper,\n\tgetOdspResolvedUrl,\n} from \"./odspUtils.js\";\nimport { pkgVersion as driverVersion } from \"./packageVersion.js\";\n\n/**\n * @legacy\n * @beta\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\t| \"renameFile\";\n\n/**\n * @legacy\n * @beta\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 * @legacy\n * @beta\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\tconst value = (await this.cache.get(\n\t\t\t\tthis.fileEntryFromEntry(entry),\n\t\t\t)) as IVersionedValueWithEpoch;\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 * @legacy\n * @beta\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,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AAOvE,OAAO,EACN,wBAAwB,EACxB,sBAAsB,EACtB,iBAAiB,EACjB,WAAW,EACX,eAAe,GACf,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAIN,cAAc,EACd,WAAW,EACX,6BAA6B,GAC7B,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EAEN,gBAAgB,EAChB,YAAY,EACZ,yBAAyB,EACzB,cAAc,EACd,SAAS,GACT,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EAAiC,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AAC3F,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAEN,yBAAyB,EACzB,UAAU,EACV,WAAW,EACX,kBAAkB,GAClB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,UAAU,IAAI,aAAa,EAAE,MAAM,qBAAqB,CAAC;AA0BlE,MAAM,CAAC,MAAM,YAAY,GAAG,cAAc,CAAC;AAE3C;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0B;YACjD,IAAI,KAAoC,CAAC;YACzC,MAAM,QAAQ,GAAG,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,EAAE;gBAChD,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;AAWD,MAAM,UAAU,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","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 type {\n\tICacheEntry,\n\tIEntry,\n\tIFileEntry,\n\tIPersistedCache,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tLocationRedirectionError,\n\tmaximumCacheDurationMs,\n\tNonRetryableError,\n\tRateLimiter,\n\tThrottlingError,\n} from \"@fluidframework/driver-utils/internal\";\nimport {\n\ttype IOdspError,\n\ttype IOdspErrorAugmentations,\n\ttype IOdspResolvedUrl,\n\tOdspErrorTypes,\n\tsnapshotKey,\n\tsnapshotWithLoadingGroupIdKey,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\ttype ITelemetryLoggerExt,\n\tPerformanceEvent,\n\tisFluidError,\n\tloggerToMonitoringContext,\n\tnormalizeError,\n\twrapError,\n} from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport { type IVersionedValueWithEpoch, persistedCacheValueVersion } from \"./contracts.js\";\nimport { ClpCompliantAppHeader } from \"./contractsPublic.js\";\nimport type { INonPersistentCache, IOdspCache, IPersistedFileCache } from \"./odspCache.js\";\nimport { patchOdspResolvedUrl } from \"./odspLocationRedirection.js\";\nimport {\n\ttype IOdspResponse,\n\tfetchAndParseAsJSONHelper,\n\tfetchArray,\n\tfetchHelper,\n\tgetOdspResolvedUrl,\n} from \"./odspUtils.js\";\nimport { pkgVersion as driverVersion } from \"./packageVersion.js\";\n\n/**\n * @legacy\n * @beta\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\t| \"renameFile\";\n\n/**\n * @legacy\n * @beta\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 * @legacy\n * @beta\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\tconst value = (await this.cache.get(\n\t\t\t\tthis.fileEntryFromEntry(entry),\n\t\t\t)) as IVersionedValueWithEpoch;\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 * @legacy\n * @beta\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 +1 @@
1
- {"version":3,"file":"fetchSnapshot.d.ts","sourceRoot":"","sources":["../src/fetchSnapshot.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,SAAS,EAAiB,MAAM,6CAA6C,CAAC;AAU5F,OAAO,EAEN,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,+BAA+B,EAEpC,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EACN,KAAK,mBAAmB,EAIxB,MAAM,0CAA0C,CAAC;AASlD,OAAO,EACN,KAAK,aAAa,EAElB,KAAK,wBAAwB,EAE7B,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAMtD,OAAO,EACN,KAAK,aAAa,EASlB,KAAK,mBAAmB,EACxB,MAAM,gBAAgB,CAAC;AAGxB;;;;GAIG;AACH,oBAAY,yBAAyB;IACpC,IAAI,IAAI;IACR,MAAM,IAAI;IACV,aAAa,IAAI;CACjB;AAED;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CAClC,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,iBAAiB,EAAE,OAAO,EAC1B,sCAAsC,EAAE,OAAO,EAC/C,MAAM,EAAE,mBAAmB,EAC3B,kBAAkB,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,GAClE,OAAO,CAAC,SAAS,CAAC,CAkBpB;AAED,wBAAsB,uBAAuB,CAC5C,eAAe,EAAE,gBAAg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