@fluidframework/odsp-driver 2.0.0-dev.5.2.0.169897 → 2.0.0-dev.5.3.2.178189
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/contracts.d.ts +0 -25
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js.map +1 -1
- package/dist/epochTracker.d.ts.map +1 -1
- package/dist/epochTracker.js +7 -1
- package/dist/epochTracker.js.map +1 -1
- package/dist/localOdspDriver/localOdspDocumentServiceFactory.d.ts +1 -1
- package/dist/localOdspDriver/localOdspDocumentServiceFactory.d.ts.map +1 -1
- package/dist/localOdspDriver/localOdspDocumentServiceFactory.js.map +1 -1
- package/dist/odspCache.d.ts +2 -3
- package/dist/odspCache.d.ts.map +1 -1
- package/dist/odspCache.js +5 -5
- package/dist/odspCache.js.map +1 -1
- package/dist/odspDelayLoadedDeltaStream.d.ts.map +1 -1
- package/dist/odspDelayLoadedDeltaStream.js +1 -1
- package/dist/odspDelayLoadedDeltaStream.js.map +1 -1
- package/dist/odspDeltaStorageService.d.ts +1 -1
- package/dist/odspDeltaStorageService.d.ts.map +1 -1
- package/dist/odspDeltaStorageService.js +6 -3
- package/dist/odspDeltaStorageService.js.map +1 -1
- package/dist/odspDocumentServiceFactoryCore.d.ts +12 -4
- package/dist/odspDocumentServiceFactoryCore.d.ts.map +1 -1
- package/dist/odspDocumentServiceFactoryCore.js +14 -0
- package/dist/odspDocumentServiceFactoryCore.js.map +1 -1
- package/dist/odspDocumentStorageManager.d.ts.map +1 -1
- package/dist/odspDocumentStorageManager.js +2 -0
- package/dist/odspDocumentStorageManager.js.map +1 -1
- package/dist/odspDriverUrlResolverForShareLink.d.ts +1 -2
- package/dist/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
- package/dist/odspDriverUrlResolverForShareLink.js.map +1 -1
- package/dist/odspUtils.d.ts +2 -1
- package/dist/odspUtils.d.ts.map +1 -1
- package/dist/odspUtils.js +5 -1
- package/dist/odspUtils.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/prefetchLatestSnapshot.d.ts +1 -1
- package/dist/prefetchLatestSnapshot.d.ts.map +1 -1
- package/dist/prefetchLatestSnapshot.js +14 -5
- package/dist/prefetchLatestSnapshot.js.map +1 -1
- package/dist/retryErrorsStorageAdapter.d.ts +1 -1
- package/dist/retryErrorsStorageAdapter.d.ts.map +1 -1
- package/dist/retryErrorsStorageAdapter.js.map +1 -1
- package/dist/vroom.d.ts +1 -2
- package/dist/vroom.d.ts.map +1 -1
- package/dist/vroom.js.map +1 -1
- package/lib/contracts.d.ts +0 -25
- package/lib/contracts.d.ts.map +1 -1
- package/lib/contracts.js.map +1 -1
- package/lib/epochTracker.d.ts.map +1 -1
- package/lib/epochTracker.js +8 -2
- package/lib/epochTracker.js.map +1 -1
- package/lib/localOdspDriver/localOdspDocumentServiceFactory.d.ts +1 -1
- package/lib/localOdspDriver/localOdspDocumentServiceFactory.d.ts.map +1 -1
- package/lib/localOdspDriver/localOdspDocumentServiceFactory.js.map +1 -1
- package/lib/odspCache.d.ts +2 -3
- package/lib/odspCache.d.ts.map +1 -1
- package/lib/odspCache.js +1 -1
- package/lib/odspCache.js.map +1 -1
- package/lib/odspDelayLoadedDeltaStream.d.ts.map +1 -1
- package/lib/odspDelayLoadedDeltaStream.js +2 -2
- package/lib/odspDelayLoadedDeltaStream.js.map +1 -1
- package/lib/odspDeltaStorageService.d.ts +1 -1
- package/lib/odspDeltaStorageService.d.ts.map +1 -1
- package/lib/odspDeltaStorageService.js +6 -3
- package/lib/odspDeltaStorageService.js.map +1 -1
- package/lib/odspDocumentServiceFactoryCore.d.ts +12 -4
- package/lib/odspDocumentServiceFactoryCore.d.ts.map +1 -1
- package/lib/odspDocumentServiceFactoryCore.js +15 -1
- package/lib/odspDocumentServiceFactoryCore.js.map +1 -1
- package/lib/odspDocumentStorageManager.d.ts.map +1 -1
- package/lib/odspDocumentStorageManager.js +2 -0
- package/lib/odspDocumentStorageManager.js.map +1 -1
- package/lib/odspDriverUrlResolverForShareLink.d.ts +1 -2
- package/lib/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
- package/lib/odspDriverUrlResolverForShareLink.js.map +1 -1
- package/lib/odspUtils.d.ts +2 -1
- package/lib/odspUtils.d.ts.map +1 -1
- package/lib/odspUtils.js +3 -0
- package/lib/odspUtils.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/prefetchLatestSnapshot.d.ts +1 -1
- package/lib/prefetchLatestSnapshot.d.ts.map +1 -1
- package/lib/prefetchLatestSnapshot.js +14 -5
- package/lib/prefetchLatestSnapshot.js.map +1 -1
- package/lib/retryErrorsStorageAdapter.d.ts +1 -1
- package/lib/retryErrorsStorageAdapter.d.ts.map +1 -1
- package/lib/retryErrorsStorageAdapter.js.map +1 -1
- package/lib/vroom.d.ts +1 -2
- package/lib/vroom.d.ts.map +1 -1
- package/lib/vroom.js.map +1 -1
- package/package.json +29 -14
- package/src/contracts.ts +0 -34
- package/src/epochTracker.ts +8 -5
- package/src/localOdspDriver/localOdspDocumentServiceFactory.ts +1 -1
- package/src/odspCache.ts +2 -2
- package/src/odspDelayLoadedDeltaStream.ts +7 -3
- package/src/odspDeltaStorageService.ts +7 -4
- package/src/odspDocumentServiceFactoryCore.ts +27 -2
- package/src/odspDocumentStorageManager.ts +2 -0
- package/src/odspDriverUrlResolverForShareLink.ts +1 -2
- package/src/odspUtils.ts +5 -1
- package/src/packageVersion.ts +1 -1
- package/src/prefetchLatestSnapshot.ts +15 -6
- package/src/retryErrorsStorageAdapter.ts +1 -1
- package/src/vroom.ts +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspDelayLoadedDeltaStream.js","sourceRoot":"","sources":["../src/odspDelayLoadedDeltaStream.ts"],"names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,CAAC;QAC7B,MAAA,IAAI,CAAC,iBAAiB,0CAAE,OAAO,EAAE,CAAC;QAClC,IAAI,CAAC,iBAAiB,GAAG,SAAS,CAAC;IACpC,CAAC;CACD;AAzZD,gEAyZC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, performance } from \"@fluidframework/common-utils\";\nimport {\n\tIFluidErrorBase,\n\tMonitoringContext,\n\tnormalizeError,\n} from \"@fluidframework/telemetry-utils\";\nimport {\n\tIDocumentDeltaConnection,\n\tIResolvedUrl,\n\tIDocumentServicePolicies,\n\tDriverErrorType,\n} from \"@fluidframework/driver-definitions\";\nimport {\n\tDeltaStreamConnectionForbiddenError,\n\tNonRetryableError,\n} from \"@fluidframework/driver-utils\";\nimport { IClient, ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport {\n\tIOdspResolvedUrl,\n\tTokenFetchOptions,\n\tHostStoragePolicy,\n\tInstrumentedStorageTokenFetcher,\n\tOdspErrorType,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { hasFacetCodes } from \"@fluidframework/odsp-doclib-utils\";\nimport { ISocketStorageDiscovery } from \"./contracts\";\nimport { IOdspCache } from \"./odspCache\";\nimport { OdspDocumentDeltaConnection } from \"./odspDocumentDeltaConnection\";\nimport { getWithRetryForTokenRefresh, TokenFetchOptionsEx } from \"./odspUtils\";\nimport { fetchJoinSession } from \"./vroom\";\nimport { EpochTracker } from \"./epochTracker\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\n\n/**\n * This OdspDelayLoadedDeltaStream is used by OdspDocumentService.ts to delay load the delta connection\n * as they are not on critical path of loading a container.\n */\nexport class OdspDelayLoadedDeltaStream {\n\t// Timer which runs and executes the join session call after intervals.\n\tprivate joinSessionRefreshTimer: ReturnType<typeof setTimeout> | undefined;\n\n\tprivate readonly joinSessionKey: string;\n\n\tprivate currentConnection?: OdspDocumentDeltaConnection;\n\n\tprivate _relayServiceTenantAndSessionId: string | undefined;\n\n\t/**\n\t * @param odspResolvedUrl - resolved url identifying document that will be managed by this service instance.\n\t * @param policies - Document service policies.\n\t * @param getStorageToken - function that can provide the storage token. This is is also referred to as\n\t * the \"Vroom\" token in SPO.\n\t * @param getWebsocketToken - function that can provide a token for accessing the web socket. This is also referred\n\t * to as the \"Push\" token in SPO. If undefined then websocket token is expected to be returned with joinSession\n\t * response payload.\n\t * @param mc - a logger that can capture performance and diagnostic information\n\t * @param cache - This caches response for joinSession.\n\t * @param hostPolicy - host constructed policy which customizes service behavior.\n\t * @param epochTracker - This helper class which adds epoch to backend calls made by this service instance.\n\t * @param opsReceived - To register the ops received through socket.\n\t * @param socketReferenceKeyPrefix - (optional) prefix to isolate socket reuse cache\n\t */\n\tpublic constructor(\n\t\tpublic readonly odspResolvedUrl: IOdspResolvedUrl,\n\t\tpublic policies: IDocumentServicePolicies,\n\t\tprivate readonly getStorageToken: InstrumentedStorageTokenFetcher,\n\t\tprivate readonly getWebsocketToken:\n\t\t\t| ((options: TokenFetchOptions) => Promise<string | null>)\n\t\t\t| undefined,\n\t\tprivate readonly mc: MonitoringContext,\n\t\tprivate readonly cache: IOdspCache,\n\t\tprivate readonly hostPolicy: HostStoragePolicy,\n\t\tprivate readonly epochTracker: EpochTracker,\n\t\tprivate readonly opsReceived: (ops: ISequencedDocumentMessage[]) => void,\n\t\tprivate readonly socketReferenceKeyPrefix?: string,\n\t) {\n\t\tthis.joinSessionKey = `${this.odspResolvedUrl.hashedDocumentId}/joinsession`;\n\t}\n\n\tpublic get resolvedUrl(): IResolvedUrl {\n\t\treturn this.odspResolvedUrl;\n\t}\n\n\tpublic get currentDeltaConnection(): OdspDocumentDeltaConnection | undefined {\n\t\treturn this.currentConnection;\n\t}\n\n\tpublic get relayServiceTenantAndSessionId(): string | undefined {\n\t\treturn this._relayServiceTenantAndSessionId;\n\t}\n\n\t/** Annotate the given error indicating which connection step failed */\n\tprivate annotateConnectionError(\n\t\terror: any,\n\t\tfailedConnectionStep: string,\n\t\tseparateTokenRequest: boolean,\n\t): IFluidErrorBase {\n\t\treturn normalizeError(error, {\n\t\t\tprops: {\n\t\t\t\tfailedConnectionStep,\n\t\t\t\tseparateTokenRequest,\n\t\t\t},\n\t\t});\n\t}\n\n\t/**\n\t * Connects to a delta stream endpoint for emitting ops.\n\t *\n\t * @returns returns the document delta stream service for onedrive/sharepoint driver.\n\t */\n\tpublic async connectToDeltaStream(client: IClient): Promise<IDocumentDeltaConnection> {\n\t\tassert(\n\t\t\tthis.currentConnection === undefined,\n\t\t\t0x4ad /* Should not be called when connection is already present! */,\n\t\t);\n\t\t// Attempt to connect twice, in case we used expired token.\n\t\treturn getWithRetryForTokenRefresh<IDocumentDeltaConnection>(async (options) => {\n\t\t\t// Presence of getWebsocketToken callback dictates whether callback is used for fetching\n\t\t\t// websocket token or whether it is returned with joinSession response payload\n\t\t\tconst requestWebsocketTokenFromJoinSession = this.getWebsocketToken === undefined;\n\t\t\tconst websocketTokenPromise = requestWebsocketTokenFromJoinSession\n\t\t\t\t? Promise.resolve(null)\n\t\t\t\t: this.getWebsocketToken!(options);\n\n\t\t\tconst annotateAndRethrowConnectionError = (step: string) => (error: any) => {\n\t\t\t\tthrow this.annotateConnectionError(\n\t\t\t\t\terror,\n\t\t\t\t\tstep,\n\t\t\t\t\t!requestWebsocketTokenFromJoinSession,\n\t\t\t\t);\n\t\t\t};\n\n\t\t\tconst joinSessionPromise = this.joinSession(\n\t\t\t\trequestWebsocketTokenFromJoinSession,\n\t\t\t\toptions,\n\t\t\t\tfalse /* isRefreshingJoinSession */,\n\t\t\t);\n\t\t\tconst [websocketEndpoint, websocketToken] = await Promise.all([\n\t\t\t\tjoinSessionPromise.catch(annotateAndRethrowConnectionError(\"joinSession\")),\n\t\t\t\twebsocketTokenPromise.catch(annotateAndRethrowConnectionError(\"getWebsocketToken\")),\n\t\t\t]);\n\n\t\t\tconst finalWebsocketToken = websocketToken ?? websocketEndpoint.socketToken ?? null;\n\t\t\tif (finalWebsocketToken === null) {\n\t\t\t\tthrow this.annotateConnectionError(\n\t\t\t\t\tnew NonRetryableError(\n\t\t\t\t\t\t\"Websocket token is null\",\n\t\t\t\t\t\tOdspErrorType.fetchTokenError,\n\t\t\t\t\t\t{ driverVersion },\n\t\t\t\t\t),\n\t\t\t\t\t\"getWebsocketToken\",\n\t\t\t\t\t!requestWebsocketTokenFromJoinSession,\n\t\t\t\t);\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tconst connection = await this.createDeltaConnection(\n\t\t\t\t\twebsocketEndpoint.tenantId,\n\t\t\t\t\twebsocketEndpoint.id,\n\t\t\t\t\tfinalWebsocketToken,\n\t\t\t\t\tclient,\n\t\t\t\t\twebsocketEndpoint.deltaStreamSocketUrl,\n\t\t\t\t);\n\t\t\t\tconnection.on(\"op\", (documentId, ops: ISequencedDocumentMessage[]) => {\n\t\t\t\t\tthis.opsReceived(ops);\n\t\t\t\t});\n\t\t\t\t// On disconnect with 401/403 error code, we can just clear the joinSession cache as we will again\n\t\t\t\t// get the auth error on reconnecting and face latency.\n\t\t\t\tconnection.once(\"disconnect\", (error: any) => {\n\t\t\t\t\t// Clear the join session refresh timer so that it can be restarted on reconnection.\n\t\t\t\t\tthis.clearJoinSessionTimer();\n\t\t\t\t\tif (\n\t\t\t\t\t\ttypeof error === \"object\" &&\n\t\t\t\t\t\terror !== null &&\n\t\t\t\t\t\terror.errorType === DriverErrorType.authorizationError\n\t\t\t\t\t) {\n\t\t\t\t\t\tthis.cache.sessionJoinCache.remove(this.joinSessionKey);\n\t\t\t\t\t}\n\t\t\t\t\t// If we hit this assert, it means that \"disconnect\" event is emitted before the connection went through\n\t\t\t\t\t// dispose flow which is not correct and could lead to a bunch of errors.\n\t\t\t\t\tassert(connection.disposed, 0x4ae /* Connection should be disposed by now */);\n\t\t\t\t\tthis.currentConnection = undefined;\n\t\t\t\t});\n\t\t\t\tthis.currentConnection = connection;\n\t\t\t\treturn connection;\n\t\t\t} catch (error) {\n\t\t\t\tthis.clearJoinSessionTimer();\n\t\t\t\tthis.cache.sessionJoinCache.remove(this.joinSessionKey);\n\n\t\t\t\tconst normalizedError = this.annotateConnectionError(\n\t\t\t\t\terror,\n\t\t\t\t\t\"createDeltaConnection\",\n\t\t\t\t\t!requestWebsocketTokenFromJoinSession,\n\t\t\t\t);\n\t\t\t\tif (typeof error === \"object\" && error !== null) {\n\t\t\t\t\tnormalizedError.addTelemetryProperties({\n\t\t\t\t\t\tsocketDocumentId: websocketEndpoint.id,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tthrow normalizedError;\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate clearJoinSessionTimer() {\n\t\tif (this.joinSessionRefreshTimer !== undefined) {\n\t\t\tclearTimeout(this.joinSessionRefreshTimer);\n\t\t\tthis.joinSessionRefreshTimer = undefined;\n\t\t}\n\t}\n\n\tprivate async scheduleJoinSessionRefresh(\n\t\tdelta: number,\n\t\trequestSocketToken: boolean,\n\t\tclientId: string | undefined,\n\t) {\n\t\tif (this.joinSessionRefreshTimer !== undefined) {\n\t\t\tthis.clearJoinSessionTimer();\n\t\t\tconst originalStackTraceLimit = (Error as any).stackTraceLimit;\n\t\t\t(Error as any).stackTraceLimit = 50;\n\t\t\tthis.mc.logger.sendTelemetryEvent(\n\t\t\t\t{\n\t\t\t\t\teventName: \"DuplicateJoinSessionRefresh\",\n\t\t\t\t},\n\t\t\t\tnew Error(\"DuplicateJoinSessionRefresh\"),\n\t\t\t);\n\t\t\t(Error as any).stackTraceLimit = originalStackTraceLimit;\n\t\t}\n\n\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\tthis.joinSessionRefreshTimer = setTimeout(() => {\n\t\t\t\tgetWithRetryForTokenRefresh(async (options) => {\n\t\t\t\t\tawait this.joinSession(\n\t\t\t\t\t\trequestSocketToken,\n\t\t\t\t\t\toptions,\n\t\t\t\t\t\ttrue /* isRefreshingJoinSession */,\n\t\t\t\t\t\tclientId,\n\t\t\t\t\t);\n\t\t\t\t\tresolve();\n\t\t\t\t}).catch((error) => {\n\t\t\t\t\treject(error);\n\t\t\t\t});\n\t\t\t}, delta);\n\t\t});\n\t}\n\n\tprivate async joinSession(\n\t\trequestSocketToken: boolean,\n\t\toptions: TokenFetchOptionsEx,\n\t\tisRefreshingJoinSession: boolean,\n\t\tclientId?: string,\n\t) {\n\t\t// If this call is to refresh the join session for the current connection but we are already disconnected in\n\t\t// the meantime or disconnected and then reconnected then do not make the call. However, we should not have\n\t\t// come here if that is the case because timer should have been disposed, but due to race condition with the\n\t\t// timer we should not make the call and throw error.\n\t\tif (\n\t\t\tisRefreshingJoinSession &&\n\t\t\t(this.currentConnection === undefined ||\n\t\t\t\t(clientId !== undefined && this.currentConnection.clientId !== clientId))\n\t\t) {\n\t\t\tthis.clearJoinSessionTimer();\n\t\t\tthrow new NonRetryableError(\n\t\t\t\t\"JoinSessionRefreshTimerNotCancelled\",\n\t\t\t\tDriverErrorType.genericError,\n\t\t\t\t{\n\t\t\t\t\tdriverVersion,\n\t\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t\tschedulerClientId: clientId,\n\t\t\t\t\t\tcurrentClientId: this.currentConnection?.clientId,\n\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t\tconst response = await this.joinSessionCore(\n\t\t\trequestSocketToken,\n\t\t\toptions,\n\t\t\tisRefreshingJoinSession,\n\t\t).catch((e) => {\n\t\t\tif (hasFacetCodes(e) && e.facetCodes !== undefined) {\n\t\t\t\tfor (const code of e.facetCodes) {\n\t\t\t\t\tswitch (code) {\n\t\t\t\t\t\tcase \"sessionForbidden\":\n\t\t\t\t\t\tcase \"sessionForbiddenOnPreservedFiles\":\n\t\t\t\t\t\tcase \"sessionForbiddenOnModerationEnabledLibrary\":\n\t\t\t\t\t\tcase \"sessionForbiddenOnRequireCheckout\":\n\t\t\t\t\t\tcase \"sessionForbiddenOnCheckoutFile\":\n\t\t\t\t\t\tcase \"sessionForbiddenOnInvisibleMinorVersion\":\n\t\t\t\t\t\t\t// This document can only be opened in storage-only mode.\n\t\t\t\t\t\t\t// DeltaManager will recognize this error\n\t\t\t\t\t\t\t// and load without a delta stream connection.\n\t\t\t\t\t\t\tthis.policies = { ...this.policies, storageOnly: true };\n\t\t\t\t\t\t\tthrow new DeltaStreamConnectionForbiddenError(\n\t\t\t\t\t\t\t\t`Storage-only due to ${code}`,\n\t\t\t\t\t\t\t\t{ driverVersion },\n\t\t\t\t\t\t\t\tcode,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow e;\n\t\t});\n\t\tthis._relayServiceTenantAndSessionId = `${response.tenantId}/${response.id}`;\n\t\treturn response;\n\t}\n\n\tprivate async joinSessionCore(\n\t\trequestSocketToken: boolean,\n\t\toptions: TokenFetchOptionsEx,\n\t\tisRefreshingJoinSession: boolean,\n\t): Promise<ISocketStorageDiscovery> {\n\t\tconst disableJoinSessionRefresh = this.mc.config.getBoolean(\n\t\t\t\"Fluid.Driver.Odsp.disableJoinSessionRefresh\",\n\t\t);\n\t\tconst executeFetch = async () => {\n\t\t\tconst joinSessionResponse = await fetchJoinSession(\n\t\t\t\tthis.odspResolvedUrl,\n\t\t\t\t\"opStream/joinSession\",\n\t\t\t\t\"POST\",\n\t\t\t\tthis.mc.logger,\n\t\t\t\tthis.getStorageToken,\n\t\t\t\tthis.epochTracker,\n\t\t\t\trequestSocketToken,\n\t\t\t\toptions,\n\t\t\t\tdisableJoinSessionRefresh,\n\t\t\t\tisRefreshingJoinSession,\n\t\t\t\tthis.hostPolicy.sessionOptions?.unauthenticatedUserDisplayName,\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tentryTime: Date.now(),\n\t\t\t\tjoinSessionResponse,\n\t\t\t};\n\t\t};\n\n\t\tconst getResponseAndRefreshAfterDeltaMs = async () => {\n\t\t\tconst _response = await this.cache.sessionJoinCache.addOrGet(\n\t\t\t\tthis.joinSessionKey,\n\t\t\t\texecuteFetch,\n\t\t\t);\n\t\t\t// If the response does not contain refreshSessionDurationSeconds, then treat it as old flow and let the\n\t\t\t// cache entry to be treated as expired after 1 hour.\n\t\t\t_response.joinSessionResponse.refreshSessionDurationSeconds =\n\t\t\t\t_response.joinSessionResponse.refreshSessionDurationSeconds ?? 3600;\n\t\t\treturn {\n\t\t\t\t..._response,\n\t\t\t\trefreshAfterDeltaMs: this.calculateJoinSessionRefreshDelta(\n\t\t\t\t\t_response.entryTime,\n\t\t\t\t\t_response.joinSessionResponse.refreshSessionDurationSeconds,\n\t\t\t\t),\n\t\t\t};\n\t\t};\n\t\tlet response = await getResponseAndRefreshAfterDeltaMs();\n\t\t// This means that the cached entry has expired(This should not be possible if the response is fetched\n\t\t// from the network call). In this case we remove the cached entry and fetch the new response.\n\t\tif (response.refreshAfterDeltaMs <= 0) {\n\t\t\tthis.cache.sessionJoinCache.remove(this.joinSessionKey);\n\t\t\tresponse = await getResponseAndRefreshAfterDeltaMs();\n\t\t}\n\t\tif (!disableJoinSessionRefresh) {\n\t\t\tconst props = {\n\t\t\t\tentryTime: response.entryTime,\n\t\t\t\trefreshSessionDurationSeconds:\n\t\t\t\t\tresponse.joinSessionResponse.refreshSessionDurationSeconds,\n\t\t\t\trefreshAfterDeltaMs: response.refreshAfterDeltaMs,\n\t\t\t};\n\t\t\tif (response.refreshAfterDeltaMs > 0) {\n\t\t\t\tthis.scheduleJoinSessionRefresh(\n\t\t\t\t\tresponse.refreshAfterDeltaMs,\n\t\t\t\t\trequestSocketToken,\n\t\t\t\t\tthis.currentConnection?.clientId,\n\t\t\t\t).catch((error) => {\n\t\t\t\t\t// Log the error and do nothing as the reconnection would fetch the join session.\n\t\t\t\t\tthis.mc.logger.sendTelemetryEvent(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\teventName: \"JoinSessionRefreshError\",\n\t\t\t\t\t\t\tdetails: JSON.stringify(props),\n\t\t\t\t\t\t},\n\t\t\t\t\t\terror,\n\t\t\t\t\t);\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\t// Logging just for informational purposes to help with debugging as this is a new feature.\n\t\t\t\tthis.mc.logger.sendTelemetryEvent({\n\t\t\t\t\teventName: \"JoinSessionRefreshNotScheduled\",\n\t\t\t\t\tdetails: JSON.stringify(props),\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\treturn response.joinSessionResponse;\n\t}\n\n\tprivate calculateJoinSessionRefreshDelta(\n\t\tresponseFetchTime: number,\n\t\trefreshSessionDurationSeconds: number,\n\t) {\n\t\t// 30 seconds is buffer time to refresh the session.\n\t\treturn responseFetchTime + (refreshSessionDurationSeconds * 1000 - 30000) - Date.now();\n\t}\n\n\t/**\n\t * Creates a connection to the given delta stream endpoint\n\t *\n\t * @param tenantId - the ID of the tenant\n\t * @param documentId - document ID\n\t * @param token - authorization token for delta service\n\t * @param client - information about the client\n\t * @param webSocketUrl - websocket URL\n\t */\n\tprivate async createDeltaConnection(\n\t\ttenantId: string,\n\t\tdocumentId: string,\n\t\ttoken: string | null,\n\t\tclient: IClient,\n\t\twebSocketUrl: string,\n\t): Promise<OdspDocumentDeltaConnection> {\n\t\tconst startTime = performance.now();\n\t\tconst connection = await OdspDocumentDeltaConnection.create(\n\t\t\ttenantId,\n\t\t\tdocumentId,\n\t\t\ttoken,\n\t\t\tclient,\n\t\t\twebSocketUrl,\n\t\t\tthis.mc.logger,\n\t\t\t60000,\n\t\t\tthis.epochTracker,\n\t\t\tthis.socketReferenceKeyPrefix,\n\t\t);\n\t\tconst duration = performance.now() - startTime;\n\t\t// This event happens rather often, so it adds up to cost of telemetry.\n\t\t// Given that most reconnects result in reusing socket and happen very quickly,\n\t\t// report event only if it took longer than threshold.\n\t\tif (duration >= 2000) {\n\t\t\tthis.mc.logger.sendPerformanceEvent({\n\t\t\t\teventName: \"ConnectionSuccess\",\n\t\t\t\tduration,\n\t\t\t});\n\t\t}\n\t\treturn connection;\n\t}\n\n\tpublic dispose(error?: any) {\n\t\tthis.clearJoinSessionTimer();\n\t\tthis.currentConnection?.dispose();\n\t\tthis.currentConnection = undefined;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"odspDelayLoadedDeltaStream.js","sourceRoot":"","sources":["../src/odspDelayLoadedDeltaStream.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAmE;AACnE,qEAIyC;AACzC,2EAK4C;AAC5C,+DAGsC;AAEtC,qFAOiD;AACjD,yEAAkE;AAElE,+EAA4E;AAC5E,2CAIqB;AACrB,mCAA2C;AAE3C,qDAA+D;AAE/D;;;GAGG;AACH,MAAa,0BAA0B;IAUtC;;;;;;;;;;;;;;OAcG;IACH,YACiB,eAAiC,EAC1C,QAAkC,EACxB,eAAgD,EAChD,iBAEL,EACK,EAAqB,EACrB,KAAiB,EACjB,UAA6B,EAC7B,YAA0B,EAC1B,WAAuD,EACvD,wBAAiC;QAXlC,oBAAe,GAAf,eAAe,CAAkB;QAC1C,aAAQ,GAAR,QAAQ,CAA0B;QACxB,oBAAe,GAAf,eAAe,CAAiC;QAChD,sBAAiB,GAAjB,iBAAiB,CAEtB;QACK,OAAE,GAAF,EAAE,CAAmB;QACrB,UAAK,GAAL,KAAK,CAAY;QACjB,eAAU,GAAV,UAAU,CAAmB;QAC7B,iBAAY,GAAZ,YAAY,CAAc;QAC1B,gBAAW,GAAX,WAAW,CAA4C;QACvD,6BAAwB,GAAxB,wBAAwB,CAAS;QAElD,IAAI,CAAC,cAAc,GAAG,IAAA,kCAAsB,EAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IACpE,CAAC;IAED,IAAW,WAAW;QACrB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC7B,CAAC;IAED,IAAW,sBAAsB;QAChC,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAC/B,CAAC;IAED,IAAW,8BAA8B;QACxC,OAAO,IAAI,CAAC,+BAA+B,CAAC;IAC7C,CAAC;IAED,uEAAuE;IAC/D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AAE,CAAC,MAAM,CAAC,oBAAoB,CAAC;gBACnC,SAAS,EAAE,mBAAmB;gBAC9B,QAAQ;aACR,CAAC,CAAC;SACH;QACD,OAAO,UAAU,CAAC;IACnB,CAAC;IAEM,OAAO,CAAC,KAAW;;QACzB,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAC7B,MAAA,IAAI,CAAC,iBAAiB,0CAAE,OAAO,EAAE,CAAC;QAClC,IAAI,CAAC,iBAAiB,GAAG,SAAS,CAAC;IACpC,CAAC;CACD;AAzZD,gEAyZC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, performance } from \"@fluidframework/common-utils\";\nimport {\n\tIFluidErrorBase,\n\tMonitoringContext,\n\tnormalizeError,\n} from \"@fluidframework/telemetry-utils\";\nimport {\n\tIDocumentDeltaConnection,\n\tIResolvedUrl,\n\tIDocumentServicePolicies,\n\tDriverErrorType,\n} from \"@fluidframework/driver-definitions\";\nimport {\n\tDeltaStreamConnectionForbiddenError,\n\tNonRetryableError,\n} from \"@fluidframework/driver-utils\";\nimport { IClient, ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport {\n\tIOdspResolvedUrl,\n\tTokenFetchOptions,\n\tHostStoragePolicy,\n\tInstrumentedStorageTokenFetcher,\n\tISocketStorageDiscovery,\n\tOdspErrorType,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { hasFacetCodes } from \"@fluidframework/odsp-doclib-utils\";\nimport { IOdspCache } from \"./odspCache\";\nimport { OdspDocumentDeltaConnection } from \"./odspDocumentDeltaConnection\";\nimport {\n\tgetJoinSessionCacheKey,\n\tgetWithRetryForTokenRefresh,\n\tTokenFetchOptionsEx,\n} from \"./odspUtils\";\nimport { fetchJoinSession } from \"./vroom\";\nimport { EpochTracker } from \"./epochTracker\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\n\n/**\n * This OdspDelayLoadedDeltaStream is used by OdspDocumentService.ts to delay load the delta connection\n * as they are not on critical path of loading a container.\n */\nexport class OdspDelayLoadedDeltaStream {\n\t// Timer which runs and executes the join session call after intervals.\n\tprivate joinSessionRefreshTimer: ReturnType<typeof setTimeout> | undefined;\n\n\tprivate readonly joinSessionKey: string;\n\n\tprivate currentConnection?: OdspDocumentDeltaConnection;\n\n\tprivate _relayServiceTenantAndSessionId: string | undefined;\n\n\t/**\n\t * @param odspResolvedUrl - resolved url identifying document that will be managed by this service instance.\n\t * @param policies - Document service policies.\n\t * @param getStorageToken - function that can provide the storage token. This is is also referred to as\n\t * the \"Vroom\" token in SPO.\n\t * @param getWebsocketToken - function that can provide a token for accessing the web socket. This is also referred\n\t * to as the \"Push\" token in SPO. If undefined then websocket token is expected to be returned with joinSession\n\t * response payload.\n\t * @param mc - a logger that can capture performance and diagnostic information\n\t * @param cache - This caches response for joinSession.\n\t * @param hostPolicy - host constructed policy which customizes service behavior.\n\t * @param epochTracker - This helper class which adds epoch to backend calls made by this service instance.\n\t * @param opsReceived - To register the ops received through socket.\n\t * @param socketReferenceKeyPrefix - (optional) prefix to isolate socket reuse cache\n\t */\n\tpublic constructor(\n\t\tpublic readonly odspResolvedUrl: IOdspResolvedUrl,\n\t\tpublic policies: IDocumentServicePolicies,\n\t\tprivate readonly getStorageToken: InstrumentedStorageTokenFetcher,\n\t\tprivate readonly getWebsocketToken:\n\t\t\t| ((options: TokenFetchOptions) => Promise<string | null>)\n\t\t\t| undefined,\n\t\tprivate readonly mc: MonitoringContext,\n\t\tprivate readonly cache: IOdspCache,\n\t\tprivate readonly hostPolicy: HostStoragePolicy,\n\t\tprivate readonly epochTracker: EpochTracker,\n\t\tprivate readonly opsReceived: (ops: ISequencedDocumentMessage[]) => void,\n\t\tprivate readonly socketReferenceKeyPrefix?: string,\n\t) {\n\t\tthis.joinSessionKey = getJoinSessionCacheKey(this.odspResolvedUrl);\n\t}\n\n\tpublic get resolvedUrl(): IResolvedUrl {\n\t\treturn this.odspResolvedUrl;\n\t}\n\n\tpublic get currentDeltaConnection(): OdspDocumentDeltaConnection | undefined {\n\t\treturn this.currentConnection;\n\t}\n\n\tpublic get relayServiceTenantAndSessionId(): string | undefined {\n\t\treturn this._relayServiceTenantAndSessionId;\n\t}\n\n\t/** Annotate the given error indicating which connection step failed */\n\tprivate annotateConnectionError(\n\t\terror: any,\n\t\tfailedConnectionStep: string,\n\t\tseparateTokenRequest: boolean,\n\t): IFluidErrorBase {\n\t\treturn normalizeError(error, {\n\t\t\tprops: {\n\t\t\t\tfailedConnectionStep,\n\t\t\t\tseparateTokenRequest,\n\t\t\t},\n\t\t});\n\t}\n\n\t/**\n\t * Connects to a delta stream endpoint for emitting ops.\n\t *\n\t * @returns returns the document delta stream service for onedrive/sharepoint driver.\n\t */\n\tpublic async connectToDeltaStream(client: IClient): Promise<IDocumentDeltaConnection> {\n\t\tassert(\n\t\t\tthis.currentConnection === undefined,\n\t\t\t0x4ad /* Should not be called when connection is already present! */,\n\t\t);\n\t\t// Attempt to connect twice, in case we used expired token.\n\t\treturn getWithRetryForTokenRefresh<IDocumentDeltaConnection>(async (options) => {\n\t\t\t// Presence of getWebsocketToken callback dictates whether callback is used for fetching\n\t\t\t// websocket token or whether it is returned with joinSession response payload\n\t\t\tconst requestWebsocketTokenFromJoinSession = this.getWebsocketToken === undefined;\n\t\t\tconst websocketTokenPromise = requestWebsocketTokenFromJoinSession\n\t\t\t\t? Promise.resolve(null)\n\t\t\t\t: this.getWebsocketToken!(options);\n\n\t\t\tconst annotateAndRethrowConnectionError = (step: string) => (error: any) => {\n\t\t\t\tthrow this.annotateConnectionError(\n\t\t\t\t\terror,\n\t\t\t\t\tstep,\n\t\t\t\t\t!requestWebsocketTokenFromJoinSession,\n\t\t\t\t);\n\t\t\t};\n\n\t\t\tconst joinSessionPromise = this.joinSession(\n\t\t\t\trequestWebsocketTokenFromJoinSession,\n\t\t\t\toptions,\n\t\t\t\tfalse /* isRefreshingJoinSession */,\n\t\t\t);\n\t\t\tconst [websocketEndpoint, websocketToken] = await Promise.all([\n\t\t\t\tjoinSessionPromise.catch(annotateAndRethrowConnectionError(\"joinSession\")),\n\t\t\t\twebsocketTokenPromise.catch(annotateAndRethrowConnectionError(\"getWebsocketToken\")),\n\t\t\t]);\n\n\t\t\tconst finalWebsocketToken = websocketToken ?? websocketEndpoint.socketToken ?? null;\n\t\t\tif (finalWebsocketToken === null) {\n\t\t\t\tthrow this.annotateConnectionError(\n\t\t\t\t\tnew NonRetryableError(\n\t\t\t\t\t\t\"Websocket token is null\",\n\t\t\t\t\t\tOdspErrorType.fetchTokenError,\n\t\t\t\t\t\t{ driverVersion },\n\t\t\t\t\t),\n\t\t\t\t\t\"getWebsocketToken\",\n\t\t\t\t\t!requestWebsocketTokenFromJoinSession,\n\t\t\t\t);\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tconst connection = await this.createDeltaConnection(\n\t\t\t\t\twebsocketEndpoint.tenantId,\n\t\t\t\t\twebsocketEndpoint.id,\n\t\t\t\t\tfinalWebsocketToken,\n\t\t\t\t\tclient,\n\t\t\t\t\twebsocketEndpoint.deltaStreamSocketUrl,\n\t\t\t\t);\n\t\t\t\tconnection.on(\"op\", (documentId, ops: ISequencedDocumentMessage[]) => {\n\t\t\t\t\tthis.opsReceived(ops);\n\t\t\t\t});\n\t\t\t\t// On disconnect with 401/403 error code, we can just clear the joinSession cache as we will again\n\t\t\t\t// get the auth error on reconnecting and face latency.\n\t\t\t\tconnection.once(\"disconnect\", (error: any) => {\n\t\t\t\t\t// Clear the join session refresh timer so that it can be restarted on reconnection.\n\t\t\t\t\tthis.clearJoinSessionTimer();\n\t\t\t\t\tif (\n\t\t\t\t\t\ttypeof error === \"object\" &&\n\t\t\t\t\t\terror !== null &&\n\t\t\t\t\t\terror.errorType === DriverErrorType.authorizationError\n\t\t\t\t\t) {\n\t\t\t\t\t\tthis.cache.sessionJoinCache.remove(this.joinSessionKey);\n\t\t\t\t\t}\n\t\t\t\t\t// If we hit this assert, it means that \"disconnect\" event is emitted before the connection went through\n\t\t\t\t\t// dispose flow which is not correct and could lead to a bunch of errors.\n\t\t\t\t\tassert(connection.disposed, 0x4ae /* Connection should be disposed by now */);\n\t\t\t\t\tthis.currentConnection = undefined;\n\t\t\t\t});\n\t\t\t\tthis.currentConnection = connection;\n\t\t\t\treturn connection;\n\t\t\t} catch (error) {\n\t\t\t\tthis.clearJoinSessionTimer();\n\t\t\t\tthis.cache.sessionJoinCache.remove(this.joinSessionKey);\n\n\t\t\t\tconst normalizedError = this.annotateConnectionError(\n\t\t\t\t\terror,\n\t\t\t\t\t\"createDeltaConnection\",\n\t\t\t\t\t!requestWebsocketTokenFromJoinSession,\n\t\t\t\t);\n\t\t\t\tif (typeof error === \"object\" && error !== null) {\n\t\t\t\t\tnormalizedError.addTelemetryProperties({\n\t\t\t\t\t\tsocketDocumentId: websocketEndpoint.id,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tthrow normalizedError;\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate clearJoinSessionTimer() {\n\t\tif (this.joinSessionRefreshTimer !== undefined) {\n\t\t\tclearTimeout(this.joinSessionRefreshTimer);\n\t\t\tthis.joinSessionRefreshTimer = undefined;\n\t\t}\n\t}\n\n\tprivate async scheduleJoinSessionRefresh(\n\t\tdelta: number,\n\t\trequestSocketToken: boolean,\n\t\tclientId: string | undefined,\n\t) {\n\t\tif (this.joinSessionRefreshTimer !== undefined) {\n\t\t\tthis.clearJoinSessionTimer();\n\t\t\tconst originalStackTraceLimit = (Error as any).stackTraceLimit;\n\t\t\t(Error as any).stackTraceLimit = 50;\n\t\t\tthis.mc.logger.sendTelemetryEvent(\n\t\t\t\t{\n\t\t\t\t\teventName: \"DuplicateJoinSessionRefresh\",\n\t\t\t\t},\n\t\t\t\tnew Error(\"DuplicateJoinSessionRefresh\"),\n\t\t\t);\n\t\t\t(Error as any).stackTraceLimit = originalStackTraceLimit;\n\t\t}\n\n\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\tthis.joinSessionRefreshTimer = setTimeout(() => {\n\t\t\t\tgetWithRetryForTokenRefresh(async (options) => {\n\t\t\t\t\tawait this.joinSession(\n\t\t\t\t\t\trequestSocketToken,\n\t\t\t\t\t\toptions,\n\t\t\t\t\t\ttrue /* isRefreshingJoinSession */,\n\t\t\t\t\t\tclientId,\n\t\t\t\t\t);\n\t\t\t\t\tresolve();\n\t\t\t\t}).catch((error) => {\n\t\t\t\t\treject(error);\n\t\t\t\t});\n\t\t\t}, delta);\n\t\t});\n\t}\n\n\tprivate async joinSession(\n\t\trequestSocketToken: boolean,\n\t\toptions: TokenFetchOptionsEx,\n\t\tisRefreshingJoinSession: boolean,\n\t\tclientId?: string,\n\t) {\n\t\t// If this call is to refresh the join session for the current connection but we are already disconnected in\n\t\t// the meantime or disconnected and then reconnected then do not make the call. However, we should not have\n\t\t// come here if that is the case because timer should have been disposed, but due to race condition with the\n\t\t// timer we should not make the call and throw error.\n\t\tif (\n\t\t\tisRefreshingJoinSession &&\n\t\t\t(this.currentConnection === undefined ||\n\t\t\t\t(clientId !== undefined && this.currentConnection.clientId !== clientId))\n\t\t) {\n\t\t\tthis.clearJoinSessionTimer();\n\t\t\tthrow new NonRetryableError(\n\t\t\t\t\"JoinSessionRefreshTimerNotCancelled\",\n\t\t\t\tDriverErrorType.genericError,\n\t\t\t\t{\n\t\t\t\t\tdriverVersion,\n\t\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t\tschedulerClientId: clientId,\n\t\t\t\t\t\tcurrentClientId: this.currentConnection?.clientId,\n\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t\tconst response = await this.joinSessionCore(\n\t\t\trequestSocketToken,\n\t\t\toptions,\n\t\t\tisRefreshingJoinSession,\n\t\t).catch((e) => {\n\t\t\tif (hasFacetCodes(e) && e.facetCodes !== undefined) {\n\t\t\t\tfor (const code of e.facetCodes) {\n\t\t\t\t\tswitch (code) {\n\t\t\t\t\t\tcase \"sessionForbidden\":\n\t\t\t\t\t\tcase \"sessionForbiddenOnPreservedFiles\":\n\t\t\t\t\t\tcase \"sessionForbiddenOnModerationEnabledLibrary\":\n\t\t\t\t\t\tcase \"sessionForbiddenOnRequireCheckout\":\n\t\t\t\t\t\tcase \"sessionForbiddenOnCheckoutFile\":\n\t\t\t\t\t\tcase \"sessionForbiddenOnInvisibleMinorVersion\":\n\t\t\t\t\t\t\t// This document can only be opened in storage-only mode.\n\t\t\t\t\t\t\t// DeltaManager will recognize this error\n\t\t\t\t\t\t\t// and load without a delta stream connection.\n\t\t\t\t\t\t\tthis.policies = { ...this.policies, storageOnly: true };\n\t\t\t\t\t\t\tthrow new DeltaStreamConnectionForbiddenError(\n\t\t\t\t\t\t\t\t`Storage-only due to ${code}`,\n\t\t\t\t\t\t\t\t{ driverVersion },\n\t\t\t\t\t\t\t\tcode,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow e;\n\t\t});\n\t\tthis._relayServiceTenantAndSessionId = `${response.tenantId}/${response.id}`;\n\t\treturn response;\n\t}\n\n\tprivate async joinSessionCore(\n\t\trequestSocketToken: boolean,\n\t\toptions: TokenFetchOptionsEx,\n\t\tisRefreshingJoinSession: boolean,\n\t): Promise<ISocketStorageDiscovery> {\n\t\tconst disableJoinSessionRefresh = this.mc.config.getBoolean(\n\t\t\t\"Fluid.Driver.Odsp.disableJoinSessionRefresh\",\n\t\t);\n\t\tconst executeFetch = async () => {\n\t\t\tconst joinSessionResponse = await fetchJoinSession(\n\t\t\t\tthis.odspResolvedUrl,\n\t\t\t\t\"opStream/joinSession\",\n\t\t\t\t\"POST\",\n\t\t\t\tthis.mc.logger,\n\t\t\t\tthis.getStorageToken,\n\t\t\t\tthis.epochTracker,\n\t\t\t\trequestSocketToken,\n\t\t\t\toptions,\n\t\t\t\tdisableJoinSessionRefresh,\n\t\t\t\tisRefreshingJoinSession,\n\t\t\t\tthis.hostPolicy.sessionOptions?.unauthenticatedUserDisplayName,\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tentryTime: Date.now(),\n\t\t\t\tjoinSessionResponse,\n\t\t\t};\n\t\t};\n\n\t\tconst getResponseAndRefreshAfterDeltaMs = async () => {\n\t\t\tconst _response = await this.cache.sessionJoinCache.addOrGet(\n\t\t\t\tthis.joinSessionKey,\n\t\t\t\texecuteFetch,\n\t\t\t);\n\t\t\t// If the response does not contain refreshSessionDurationSeconds, then treat it as old flow and let the\n\t\t\t// cache entry to be treated as expired after 1 hour.\n\t\t\t_response.joinSessionResponse.refreshSessionDurationSeconds =\n\t\t\t\t_response.joinSessionResponse.refreshSessionDurationSeconds ?? 3600;\n\t\t\treturn {\n\t\t\t\t..._response,\n\t\t\t\trefreshAfterDeltaMs: this.calculateJoinSessionRefreshDelta(\n\t\t\t\t\t_response.entryTime,\n\t\t\t\t\t_response.joinSessionResponse.refreshSessionDurationSeconds,\n\t\t\t\t),\n\t\t\t};\n\t\t};\n\t\tlet response = await getResponseAndRefreshAfterDeltaMs();\n\t\t// This means that the cached entry has expired(This should not be possible if the response is fetched\n\t\t// from the network call). In this case we remove the cached entry and fetch the new response.\n\t\tif (response.refreshAfterDeltaMs <= 0) {\n\t\t\tthis.cache.sessionJoinCache.remove(this.joinSessionKey);\n\t\t\tresponse = await getResponseAndRefreshAfterDeltaMs();\n\t\t}\n\t\tif (!disableJoinSessionRefresh) {\n\t\t\tconst props = {\n\t\t\t\tentryTime: response.entryTime,\n\t\t\t\trefreshSessionDurationSeconds:\n\t\t\t\t\tresponse.joinSessionResponse.refreshSessionDurationSeconds,\n\t\t\t\trefreshAfterDeltaMs: response.refreshAfterDeltaMs,\n\t\t\t};\n\t\t\tif (response.refreshAfterDeltaMs > 0) {\n\t\t\t\tthis.scheduleJoinSessionRefresh(\n\t\t\t\t\tresponse.refreshAfterDeltaMs,\n\t\t\t\t\trequestSocketToken,\n\t\t\t\t\tthis.currentConnection?.clientId,\n\t\t\t\t).catch((error) => {\n\t\t\t\t\t// Log the error and do nothing as the reconnection would fetch the join session.\n\t\t\t\t\tthis.mc.logger.sendTelemetryEvent(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\teventName: \"JoinSessionRefreshError\",\n\t\t\t\t\t\t\tdetails: JSON.stringify(props),\n\t\t\t\t\t\t},\n\t\t\t\t\t\terror,\n\t\t\t\t\t);\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\t// Logging just for informational purposes to help with debugging as this is a new feature.\n\t\t\t\tthis.mc.logger.sendTelemetryEvent({\n\t\t\t\t\teventName: \"JoinSessionRefreshNotScheduled\",\n\t\t\t\t\tdetails: JSON.stringify(props),\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\treturn response.joinSessionResponse;\n\t}\n\n\tprivate calculateJoinSessionRefreshDelta(\n\t\tresponseFetchTime: number,\n\t\trefreshSessionDurationSeconds: number,\n\t) {\n\t\t// 30 seconds is buffer time to refresh the session.\n\t\treturn responseFetchTime + (refreshSessionDurationSeconds * 1000 - 30000) - Date.now();\n\t}\n\n\t/**\n\t * Creates a connection to the given delta stream endpoint\n\t *\n\t * @param tenantId - the ID of the tenant\n\t * @param documentId - document ID\n\t * @param token - authorization token for delta service\n\t * @param client - information about the client\n\t * @param webSocketUrl - websocket URL\n\t */\n\tprivate async createDeltaConnection(\n\t\ttenantId: string,\n\t\tdocumentId: string,\n\t\ttoken: string | null,\n\t\tclient: IClient,\n\t\twebSocketUrl: string,\n\t): Promise<OdspDocumentDeltaConnection> {\n\t\tconst startTime = performance.now();\n\t\tconst connection = await OdspDocumentDeltaConnection.create(\n\t\t\ttenantId,\n\t\t\tdocumentId,\n\t\t\ttoken,\n\t\t\tclient,\n\t\t\twebSocketUrl,\n\t\t\tthis.mc.logger,\n\t\t\t60000,\n\t\t\tthis.epochTracker,\n\t\t\tthis.socketReferenceKeyPrefix,\n\t\t);\n\t\tconst duration = performance.now() - startTime;\n\t\t// This event happens rather often, so it adds up to cost of telemetry.\n\t\t// Given that most reconnects result in reusing socket and happen very quickly,\n\t\t// report event only if it took longer than threshold.\n\t\tif (duration >= 2000) {\n\t\t\tthis.mc.logger.sendPerformanceEvent({\n\t\t\t\teventName: \"ConnectionSuccess\",\n\t\t\t\tduration,\n\t\t\t});\n\t\t}\n\t\treturn connection;\n\t}\n\n\tpublic dispose(error?: any) {\n\t\tthis.clearJoinSessionTimer();\n\t\tthis.currentConnection?.dispose();\n\t\tthis.currentConnection = undefined;\n\t}\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 { ITelemetryProperties } from "@fluidframework/
|
|
5
|
+
import { ITelemetryProperties } from "@fluidframework/core-interfaces";
|
|
6
6
|
import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
|
|
7
7
|
import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
|
|
8
8
|
import { InstrumentedStorageTokenFetcher } from "@fluidframework/odsp-driver-definitions";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspDeltaStorageService.d.ts","sourceRoot":"","sources":["../src/odspDeltaStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,oBAAoB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"odspDeltaStorageService.d.ts","sourceRoot":"","sources":["../src/odspDeltaStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAEvE,OAAO,EAAE,mBAAmB,EAAoB,MAAM,iCAAiC,CAAC;AAExF,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAE,+BAA+B,EAAE,MAAM,yCAAyC,CAAC;AAC1F,OAAO,EACN,kBAAkB,EAClB,4BAA4B,EAC5B,MAAM,oC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f,SAAS,EAAE,CAC3B,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,KACN,OAAO,CAAC,yBAAyB,EAAE,CAAC,EACxB,iBAAiB,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,IAAI,EACrD,WAAW,EAAE,CAAC,GAAG,EAAE,yBAAyB,EAAE,KAAK,IAAI;IAGlE,aAAa,CACnB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,WAAW,CAAC,EAAE,WAAW,EACzB,UAAU,CAAC,EAAE,OAAO,EACpB,WAAW,CAAC,EAAE,MAAM;CA2FrB"}
|
|
@@ -93,7 +93,7 @@ class OdspDeltaStorageWithCache {
|
|
|
93
93
|
this.getCached = getCached;
|
|
94
94
|
this.requestFromSocket = requestFromSocket;
|
|
95
95
|
this.opsReceived = opsReceived;
|
|
96
|
-
this.firstCacheMiss =
|
|
96
|
+
this.firstCacheMiss = false;
|
|
97
97
|
}
|
|
98
98
|
fetchMessages(fromTotal, toTotal, abortSignal, cachedOnly, fetchReason) {
|
|
99
99
|
// We do not control what's in the cache. Current API assumes that fetchMessages() keeps banging on
|
|
@@ -119,9 +119,12 @@ class OdspDeltaStorageWithCache {
|
|
|
119
119
|
this.requestFromSocket(from, to);
|
|
120
120
|
// Cache in normal flow is continuous. Once there is a miss, stop consulting cache.
|
|
121
121
|
// This saves a bit of processing time
|
|
122
|
-
if (
|
|
122
|
+
if (!this.firstCacheMiss) {
|
|
123
123
|
const messagesFromCache = await this.getCached(from, to);
|
|
124
124
|
(0, driver_base_1.validateMessages)("cached", messagesFromCache, from, this.logger);
|
|
125
|
+
// Set the firstCacheMiss as true in case we didn't get all the ops.
|
|
126
|
+
// This will save an extra cache read on "DocumentOpen" or "PostDocumentOpen".
|
|
127
|
+
this.firstCacheMiss = from + messagesFromCache.length < to;
|
|
125
128
|
if (messagesFromCache.length !== 0) {
|
|
126
129
|
opsFromCache += messagesFromCache.length;
|
|
127
130
|
return {
|
|
@@ -129,7 +132,6 @@ class OdspDeltaStorageWithCache {
|
|
|
129
132
|
partialResult: true,
|
|
130
133
|
};
|
|
131
134
|
}
|
|
132
|
-
this.firstCacheMiss = Math.min(this.firstCacheMiss, from);
|
|
133
135
|
}
|
|
134
136
|
if (cachedOnly) {
|
|
135
137
|
return { messages: [], partialResult: false };
|
|
@@ -158,6 +160,7 @@ class OdspDeltaStorageWithCache {
|
|
|
158
160
|
opsFromSnapshot,
|
|
159
161
|
opsFromCache,
|
|
160
162
|
opsFromStorage,
|
|
163
|
+
reason: fetchReason,
|
|
161
164
|
});
|
|
162
165
|
}
|
|
163
166
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspDeltaStorageService.js","sourceRoot":"","sources":["../src/odspDeltaStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,wEAA8D;AAC9D,+BAAkC;AAElC,6DAA+D;AAC/D,qEAAwF;AACxF,+DAAsD;AAOtD,+DAA0E;AAG1E,2CAA0D;AAE1D;;GAEG;AACH,MAAa,uBAAuB;IACnC,YACkB,YAAoB,EACpB,eAAgD,EAChD,YAA0B,EAC1B,MAA2B;QAH3B,iBAAY,GAAZ,YAAY,CAAQ;QACpB,oBAAe,GAAf,eAAe,CAAiC;QAChD,iBAAY,GAAZ,YAAY,CAAc;QAC1B,WAAM,GAAN,MAAM,CAAqB;IAC1C,CAAC;IAEJ;;;;;;;OAOG;IACI,KAAK,CAAC,GAAG,CACf,IAAY,EACZ,EAAU,EACV,cAAoC,EACpC,YAAqB;QAErB,OAAO,IAAA,uCAA2B,EAAC,KAAK,EAAE,OAAO,EAAE,EAAE;YACpD,gFAAgF;YAChF,kFAAkF;YAClF,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YACxC,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,cAAc,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EAAE,IAAY,EAAE,EAAU,EAAE,cAAoC,EAAE,EAAE;YACxE,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,IAAI,EAAE,EAAE,EAAE,cAAc,CAAC,CAAC;YAC/D,+BAA+B;YAC/B,IAAA,8BAAgB,EAAC,WAAW,EAAE,MAAM,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;YAClE,OAAO,MAAM,CAAC;QACf,CAAC;QACD,uEAAuE;QACvE,0DAA0D;QAC1D,IAAI,CAAC,WAAW,EAChB,SAAS,EAAE,YAAY;QACvB,OAAO,EAAE,YAAY;QACrB,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,MAAM,EACX,WAAW,EACX,WAAW,CACX,CAAC;QAEF,OAAO,IAAA,6BAAc,EAAC,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE;YACxC,IAAI,MAAM,CAAC,IAAI,IAAI,eAAe,GAAG,YAAY,GAAG,cAAc,KAAK,CAAC,EAAE;gBACzE,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC;oBAChC,SAAS,EAAE,mBAAmB;oBAC9B,eAAe;oBACf,YAAY;oBACZ,cAAc;iBACd,CAAC,CAAC;aACH;QACF,CAAC,CAAC,CAAC;IACJ,CAAC;CACD;AAnHD,8DAmHC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { default as AbortController } from \"abort-controller\";\nimport { v4 as uuid } from \"uuid\";\nimport { ITelemetryProperties } from \"@fluidframework/common-definitions\";\nimport { validateMessages } from \"@fluidframework/driver-base\";\nimport { ITelemetryLoggerExt, PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { assert } from \"@fluidframework/common-utils\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { InstrumentedStorageTokenFetcher } from \"@fluidframework/odsp-driver-definitions\";\nimport {\n\tIDeltasFetchResult,\n\tIDocumentDeltaStorageService,\n} from \"@fluidframework/driver-definitions\";\nimport { requestOps, streamObserver } from \"@fluidframework/driver-utils\";\nimport { IDeltaStorageGetResponse, ISequencedDeltaOpMessage } from \"./contracts\";\nimport { EpochTracker } from \"./epochTracker\";\nimport { getWithRetryForTokenRefresh } from \"./odspUtils\";\n\n/**\n * Provides access to the underlying delta storage on the server for sharepoint driver.\n */\nexport class OdspDeltaStorageService {\n\tconstructor(\n\t\tprivate readonly deltaFeedUrl: string,\n\t\tprivate readonly getStorageToken: InstrumentedStorageTokenFetcher,\n\t\tprivate readonly epochTracker: EpochTracker,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t) {}\n\n\t/**\n\t * Retrieves ops from storage\n\t * @param from - inclusive\n\t * @param to - exclusive\n\t * @param telemetryProps - properties to add when issuing telemetry events\n\t * @param scenarioName - reason for fetching ops\n\t * @returns ops retrieved & info if result was partial (i.e. more is available)\n\t */\n\tpublic async get(\n\t\tfrom: number,\n\t\tto: number,\n\t\ttelemetryProps: ITelemetryProperties,\n\t\tscenarioName?: string,\n\t): Promise<IDeltasFetchResult> {\n\t\treturn getWithRetryForTokenRefresh(async (options) => {\n\t\t\t// Note - this call ends up in getSocketStorageDiscovery() and can refresh token\n\t\t\t// Thus it needs to be done before we call getStorageToken() to reduce extra calls\n\t\t\tconst baseUrl = this.buildUrl(from, to);\n\t\t\tconst storageToken = await this.getStorageToken(options, \"DeltaStorage\");\n\n\t\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\t\tthis.logger,\n\t\t\t\t{\n\t\t\t\t\teventName: \"OpsFetch\",\n\t\t\t\t\tattempts: options.refresh ? 2 : 1,\n\t\t\t\t\tfrom,\n\t\t\t\t\tto,\n\t\t\t\t\t...telemetryProps,\n\t\t\t\t\treason: scenarioName,\n\t\t\t\t},\n\t\t\t\tasync (event) => {\n\t\t\t\t\tconst formBoundary = uuid();\n\t\t\t\t\tlet postBody = `--${formBoundary}\\r\\n`;\n\t\t\t\t\tpostBody += `Authorization: Bearer ${storageToken}\\r\\n`;\n\t\t\t\t\tpostBody += `X-HTTP-Method-Override: GET\\r\\n`;\n\n\t\t\t\t\tpostBody += `_post: 1\\r\\n`;\n\t\t\t\t\tpostBody += `\\r\\n--${formBoundary}--`;\n\t\t\t\t\tconst headers: { [index: string]: any } = {\n\t\t\t\t\t\t\"Content-Type\": `multipart/form-data;boundary=${formBoundary}`,\n\t\t\t\t\t};\n\n\t\t\t\t\t// Some request take a long time (1-2 minutes) to complete, where telemetry shows very small amount\n\t\t\t\t\t// of time spent on server, and usually small payload sizes. I.e. all the time is spent somewhere in\n\t\t\t\t\t// networking. Even bigger problem - a lot of requests timeout (based on cursory look - after 1-2 minutes)\n\t\t\t\t\t// So adding some timeout to ensure we retry again in hope of faster success.\n\t\t\t\t\t// Please see https://github.com/microsoft/FluidFramework/issues/6997 for details.\n\t\t\t\t\tconst abort = new AbortController();\n\t\t\t\t\tconst timer = setTimeout(() => abort.abort(), 30000);\n\n\t\t\t\t\tconst response =\n\t\t\t\t\t\tawait this.epochTracker.fetchAndParseAsJSON<IDeltaStorageGetResponse>(\n\t\t\t\t\t\t\tbaseUrl,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\theaders,\n\t\t\t\t\t\t\t\tbody: postBody,\n\t\t\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\t\t\tsignal: abort.signal,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\"ops\",\n\t\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t\tscenarioName,\n\t\t\t\t\t\t);\n\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\tconst deltaStorageResponse = response.content;\n\t\t\t\t\tconst messages =\n\t\t\t\t\t\tdeltaStorageResponse.value.length > 0 &&\n\t\t\t\t\t\t\"op\" in deltaStorageResponse.value[0]\n\t\t\t\t\t\t\t? (deltaStorageResponse.value as ISequencedDeltaOpMessage[]).map(\n\t\t\t\t\t\t\t\t\t(operation) => operation.op,\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: (deltaStorageResponse.value as ISequencedDocumentMessage[]);\n\n\t\t\t\t\tevent.end({\n\t\t\t\t\t\theaders: Object.keys(headers).length !== 0 ? true : undefined,\n\t\t\t\t\t\tlength: messages.length,\n\t\t\t\t\t\t...response.propsToLog,\n\t\t\t\t\t});\n\n\t\t\t\t\t// It is assumed that server always returns all the ops that it has in the range that was requested.\n\t\t\t\t\t// This may change in the future, if so, we need to adjust and receive \"end\" value from server in such case.\n\t\t\t\t\treturn { messages, partialResult: false };\n\t\t\t\t},\n\t\t\t);\n\t\t});\n\t}\n\n\tpublic buildUrl(from: number, to: number) {\n\t\tconst filter = encodeURIComponent(\n\t\t\t`sequenceNumber ge ${from} and sequenceNumber le ${to - 1}`,\n\t\t);\n\t\tconst queryString = `?ump=1&filter=${filter}`;\n\t\treturn `${this.deltaFeedUrl}${queryString}`;\n\t}\n}\n\nexport class OdspDeltaStorageWithCache implements IDocumentDeltaStorageService {\n\tprivate firstCacheMiss = Number.MAX_SAFE_INTEGER;\n\n\tpublic constructor(\n\t\tprivate snapshotOps: ISequencedDocumentMessage[] | undefined,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\tprivate readonly batchSize: number,\n\t\tprivate readonly concurrency: number,\n\t\tprivate readonly getFromStorage: (\n\t\t\tfrom: number,\n\t\t\tto: number,\n\t\t\ttelemetryProps: ITelemetryProperties,\n\t\t\tfetchReason?: string,\n\t\t) => Promise<IDeltasFetchResult>,\n\t\tprivate readonly getCached: (\n\t\t\tfrom: number,\n\t\t\tto: number,\n\t\t) => Promise<ISequencedDocumentMessage[]>,\n\t\tprivate readonly requestFromSocket: (from: number, to: number) => void,\n\t\tprivate readonly opsReceived: (ops: ISequencedDocumentMessage[]) => void,\n\t) {}\n\n\tpublic fetchMessages(\n\t\tfromTotal: number,\n\t\ttoTotal: number | undefined,\n\t\tabortSignal?: AbortSignal,\n\t\tcachedOnly?: boolean,\n\t\tfetchReason?: string,\n\t) {\n\t\t// We do not control what's in the cache. Current API assumes that fetchMessages() keeps banging on\n\t\t// storage / cache until it gets ops it needs. This would result in deadlock if fixed range is asked from\n\t\t// cache and it's not there.\n\t\t// Better implementation would be to return only what we have in cache, but that also breaks API\n\t\tassert(!cachedOnly || toTotal === undefined, 0x1e3);\n\n\t\tlet opsFromSnapshot = 0;\n\t\tlet opsFromCache = 0;\n\t\tlet opsFromStorage = 0;\n\n\t\tconst requestCallback = async (\n\t\t\tfrom: number,\n\t\t\tto: number,\n\t\t\ttelemetryProps: ITelemetryProperties,\n\t\t) => {\n\t\t\tif (this.snapshotOps !== undefined && this.snapshotOps.length !== 0) {\n\t\t\t\tconst messages = this.snapshotOps.filter(\n\t\t\t\t\t(op) => op.sequenceNumber >= from && op.sequenceNumber < to,\n\t\t\t\t);\n\t\t\t\tvalidateMessages(\"cached\", messages, from, this.logger);\n\t\t\t\tif (messages.length > 0 && messages[0].sequenceNumber === from) {\n\t\t\t\t\tthis.snapshotOps = this.snapshotOps.filter((op) => op.sequenceNumber >= to);\n\t\t\t\t\topsFromSnapshot += messages.length;\n\t\t\t\t\treturn { messages, partialResult: true };\n\t\t\t\t}\n\t\t\t\tthis.snapshotOps = undefined;\n\t\t\t}\n\n\t\t\t// Kick out request to PUSH for ops if it has them\n\t\t\tthis.requestFromSocket(from, to);\n\n\t\t\t// Cache in normal flow is continuous. Once there is a miss, stop consulting cache.\n\t\t\t// This saves a bit of processing time\n\t\t\tif (from < this.firstCacheMiss) {\n\t\t\t\tconst messagesFromCache = await this.getCached(from, to);\n\t\t\t\tvalidateMessages(\"cached\", messagesFromCache, from, this.logger);\n\t\t\t\tif (messagesFromCache.length !== 0) {\n\t\t\t\t\topsFromCache += messagesFromCache.length;\n\t\t\t\t\treturn {\n\t\t\t\t\t\tmessages: messagesFromCache,\n\t\t\t\t\t\tpartialResult: true,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tthis.firstCacheMiss = Math.min(this.firstCacheMiss, from);\n\t\t\t}\n\n\t\t\tif (cachedOnly) {\n\t\t\t\treturn { messages: [], partialResult: false };\n\t\t\t}\n\n\t\t\tconst ops = await this.getFromStorage(from, to, telemetryProps, fetchReason);\n\t\t\tvalidateMessages(\"storage\", ops.messages, from, this.logger);\n\t\t\topsFromStorage += ops.messages.length;\n\t\t\tthis.opsReceived(ops.messages);\n\t\t\treturn ops;\n\t\t};\n\n\t\tconst stream = requestOps(\n\t\t\tasync (from: number, to: number, telemetryProps: ITelemetryProperties) => {\n\t\t\t\tconst result = await requestCallback(from, to, telemetryProps);\n\t\t\t\t// Catch all case, just in case\n\t\t\t\tvalidateMessages(\"catch all\", result.messages, from, this.logger);\n\t\t\t\treturn result;\n\t\t\t},\n\t\t\t// Staging: starting with no concurrency, listening for feedback first.\n\t\t\t// In future releases we will switch to actual concurrency\n\t\t\tthis.concurrency,\n\t\t\tfromTotal, // inclusive\n\t\t\ttoTotal, // exclusive\n\t\t\tthis.batchSize,\n\t\t\tthis.logger,\n\t\t\tabortSignal,\n\t\t\tfetchReason,\n\t\t);\n\n\t\treturn streamObserver(stream, (result) => {\n\t\t\tif (result.done && opsFromSnapshot + opsFromCache + opsFromStorage !== 0) {\n\t\t\t\tthis.logger.sendPerformanceEvent({\n\t\t\t\t\teventName: \"CacheOpsRetrieved\",\n\t\t\t\t\topsFromSnapshot,\n\t\t\t\t\topsFromCache,\n\t\t\t\t\topsFromStorage,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"odspDeltaStorageService.js","sourceRoot":"","sources":["../src/odspDeltaStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,wEAA8D;AAC9D,+BAAkC;AAElC,6DAA+D;AAC/D,qEAAwF;AACxF,+DAAsD;AAOtD,+DAA0E;AAG1E,2CAA0D;AAE1D;;GAEG;AACH,MAAa,uBAAuB;IACnC,YACkB,YAAoB,EACpB,eAAgD,EAChD,YAA0B,EAC1B,MAA2B;QAH3B,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nB,CAAC,CAAC;aACH;QACF,CAAC,CAAC,CAAC;IACJ,CAAC;CACD;AAtHD,8DAsHC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { default as AbortController } from \"abort-controller\";\nimport { v4 as uuid } from \"uuid\";\nimport { ITelemetryProperties } from \"@fluidframework/core-interfaces\";\nimport { validateMessages } from \"@fluidframework/driver-base\";\nimport { ITelemetryLoggerExt, PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { assert } from \"@fluidframework/common-utils\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { InstrumentedStorageTokenFetcher } from \"@fluidframework/odsp-driver-definitions\";\nimport {\n\tIDeltasFetchResult,\n\tIDocumentDeltaStorageService,\n} from \"@fluidframework/driver-definitions\";\nimport { requestOps, streamObserver } from \"@fluidframework/driver-utils\";\nimport { IDeltaStorageGetResponse, ISequencedDeltaOpMessage } from \"./contracts\";\nimport { EpochTracker } from \"./epochTracker\";\nimport { getWithRetryForTokenRefresh } from \"./odspUtils\";\n\n/**\n * Provides access to the underlying delta storage on the server for sharepoint driver.\n */\nexport class OdspDeltaStorageService {\n\tconstructor(\n\t\tprivate readonly deltaFeedUrl: string,\n\t\tprivate readonly getStorageToken: InstrumentedStorageTokenFetcher,\n\t\tprivate readonly epochTracker: EpochTracker,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t) {}\n\n\t/**\n\t * Retrieves ops from storage\n\t * @param from - inclusive\n\t * @param to - exclusive\n\t * @param telemetryProps - properties to add when issuing telemetry events\n\t * @param scenarioName - reason for fetching ops\n\t * @returns ops retrieved & info if result was partial (i.e. more is available)\n\t */\n\tpublic async get(\n\t\tfrom: number,\n\t\tto: number,\n\t\ttelemetryProps: ITelemetryProperties,\n\t\tscenarioName?: string,\n\t): Promise<IDeltasFetchResult> {\n\t\treturn getWithRetryForTokenRefresh(async (options) => {\n\t\t\t// Note - this call ends up in getSocketStorageDiscovery() and can refresh token\n\t\t\t// Thus it needs to be done before we call getStorageToken() to reduce extra calls\n\t\t\tconst baseUrl = this.buildUrl(from, to);\n\t\t\tconst storageToken = await this.getStorageToken(options, \"DeltaStorage\");\n\n\t\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\t\tthis.logger,\n\t\t\t\t{\n\t\t\t\t\teventName: \"OpsFetch\",\n\t\t\t\t\tattempts: options.refresh ? 2 : 1,\n\t\t\t\t\tfrom,\n\t\t\t\t\tto,\n\t\t\t\t\t...telemetryProps,\n\t\t\t\t\treason: scenarioName,\n\t\t\t\t},\n\t\t\t\tasync (event) => {\n\t\t\t\t\tconst formBoundary = uuid();\n\t\t\t\t\tlet postBody = `--${formBoundary}\\r\\n`;\n\t\t\t\t\tpostBody += `Authorization: Bearer ${storageToken}\\r\\n`;\n\t\t\t\t\tpostBody += `X-HTTP-Method-Override: GET\\r\\n`;\n\n\t\t\t\t\tpostBody += `_post: 1\\r\\n`;\n\t\t\t\t\tpostBody += `\\r\\n--${formBoundary}--`;\n\t\t\t\t\tconst headers: { [index: string]: any } = {\n\t\t\t\t\t\t\"Content-Type\": `multipart/form-data;boundary=${formBoundary}`,\n\t\t\t\t\t};\n\n\t\t\t\t\t// Some request take a long time (1-2 minutes) to complete, where telemetry shows very small amount\n\t\t\t\t\t// of time spent on server, and usually small payload sizes. I.e. all the time is spent somewhere in\n\t\t\t\t\t// networking. Even bigger problem - a lot of requests timeout (based on cursory look - after 1-2 minutes)\n\t\t\t\t\t// So adding some timeout to ensure we retry again in hope of faster success.\n\t\t\t\t\t// Please see https://github.com/microsoft/FluidFramework/issues/6997 for details.\n\t\t\t\t\tconst abort = new AbortController();\n\t\t\t\t\tconst timer = setTimeout(() => abort.abort(), 30000);\n\n\t\t\t\t\tconst response =\n\t\t\t\t\t\tawait this.epochTracker.fetchAndParseAsJSON<IDeltaStorageGetResponse>(\n\t\t\t\t\t\t\tbaseUrl,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\theaders,\n\t\t\t\t\t\t\t\tbody: postBody,\n\t\t\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\t\t\tsignal: abort.signal,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\"ops\",\n\t\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t\tscenarioName,\n\t\t\t\t\t\t);\n\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\tconst deltaStorageResponse = response.content;\n\t\t\t\t\tconst messages =\n\t\t\t\t\t\tdeltaStorageResponse.value.length > 0 &&\n\t\t\t\t\t\t\"op\" in deltaStorageResponse.value[0]\n\t\t\t\t\t\t\t? (deltaStorageResponse.value as ISequencedDeltaOpMessage[]).map(\n\t\t\t\t\t\t\t\t\t(operation) => operation.op,\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: (deltaStorageResponse.value as ISequencedDocumentMessage[]);\n\n\t\t\t\t\tevent.end({\n\t\t\t\t\t\theaders: Object.keys(headers).length !== 0 ? true : undefined,\n\t\t\t\t\t\tlength: messages.length,\n\t\t\t\t\t\t...response.propsToLog,\n\t\t\t\t\t});\n\n\t\t\t\t\t// It is assumed that server always returns all the ops that it has in the range that was requested.\n\t\t\t\t\t// This may change in the future, if so, we need to adjust and receive \"end\" value from server in such case.\n\t\t\t\t\treturn { messages, partialResult: false };\n\t\t\t\t},\n\t\t\t);\n\t\t});\n\t}\n\n\tpublic buildUrl(from: number, to: number) {\n\t\tconst filter = encodeURIComponent(\n\t\t\t`sequenceNumber ge ${from} and sequenceNumber le ${to - 1}`,\n\t\t);\n\t\tconst queryString = `?ump=1&filter=${filter}`;\n\t\treturn `${this.deltaFeedUrl}${queryString}`;\n\t}\n}\n\nexport class OdspDeltaStorageWithCache implements IDocumentDeltaStorageService {\n\tprivate firstCacheMiss = false;\n\n\tpublic constructor(\n\t\tprivate snapshotOps: ISequencedDocumentMessage[] | undefined,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\tprivate readonly batchSize: number,\n\t\tprivate readonly concurrency: number,\n\t\tprivate readonly getFromStorage: (\n\t\t\tfrom: number,\n\t\t\tto: number,\n\t\t\ttelemetryProps: ITelemetryProperties,\n\t\t\tfetchReason?: string,\n\t\t) => Promise<IDeltasFetchResult>,\n\t\tprivate readonly getCached: (\n\t\t\tfrom: number,\n\t\t\tto: number,\n\t\t) => Promise<ISequencedDocumentMessage[]>,\n\t\tprivate readonly requestFromSocket: (from: number, to: number) => void,\n\t\tprivate readonly opsReceived: (ops: ISequencedDocumentMessage[]) => void,\n\t) {}\n\n\tpublic fetchMessages(\n\t\tfromTotal: number,\n\t\ttoTotal: number | undefined,\n\t\tabortSignal?: AbortSignal,\n\t\tcachedOnly?: boolean,\n\t\tfetchReason?: string,\n\t) {\n\t\t// We do not control what's in the cache. Current API assumes that fetchMessages() keeps banging on\n\t\t// storage / cache until it gets ops it needs. This would result in deadlock if fixed range is asked from\n\t\t// cache and it's not there.\n\t\t// Better implementation would be to return only what we have in cache, but that also breaks API\n\t\tassert(!cachedOnly || toTotal === undefined, 0x1e3);\n\n\t\tlet opsFromSnapshot = 0;\n\t\tlet opsFromCache = 0;\n\t\tlet opsFromStorage = 0;\n\n\t\tconst requestCallback = async (\n\t\t\tfrom: number,\n\t\t\tto: number,\n\t\t\ttelemetryProps: ITelemetryProperties,\n\t\t) => {\n\t\t\tif (this.snapshotOps !== undefined && this.snapshotOps.length !== 0) {\n\t\t\t\tconst messages = this.snapshotOps.filter(\n\t\t\t\t\t(op) => op.sequenceNumber >= from && op.sequenceNumber < to,\n\t\t\t\t);\n\t\t\t\tvalidateMessages(\"cached\", messages, from, this.logger);\n\t\t\t\tif (messages.length > 0 && messages[0].sequenceNumber === from) {\n\t\t\t\t\tthis.snapshotOps = this.snapshotOps.filter((op) => op.sequenceNumber >= to);\n\t\t\t\t\topsFromSnapshot += messages.length;\n\t\t\t\t\treturn { messages, partialResult: true };\n\t\t\t\t}\n\t\t\t\tthis.snapshotOps = undefined;\n\t\t\t}\n\n\t\t\t// Kick out request to PUSH for ops if it has them\n\t\t\tthis.requestFromSocket(from, to);\n\n\t\t\t// Cache in normal flow is continuous. Once there is a miss, stop consulting cache.\n\t\t\t// This saves a bit of processing time\n\t\t\tif (!this.firstCacheMiss) {\n\t\t\t\tconst messagesFromCache = await this.getCached(from, to);\n\t\t\t\tvalidateMessages(\"cached\", messagesFromCache, from, this.logger);\n\t\t\t\t// Set the firstCacheMiss as true in case we didn't get all the ops.\n\t\t\t\t// This will save an extra cache read on \"DocumentOpen\" or \"PostDocumentOpen\".\n\t\t\t\tthis.firstCacheMiss = from + messagesFromCache.length < to;\n\t\t\t\tif (messagesFromCache.length !== 0) {\n\t\t\t\t\topsFromCache += messagesFromCache.length;\n\t\t\t\t\treturn {\n\t\t\t\t\t\tmessages: messagesFromCache,\n\t\t\t\t\t\tpartialResult: true,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (cachedOnly) {\n\t\t\t\treturn { messages: [], partialResult: false };\n\t\t\t}\n\n\t\t\tconst ops = await this.getFromStorage(from, to, telemetryProps, fetchReason);\n\t\t\tvalidateMessages(\"storage\", ops.messages, from, this.logger);\n\t\t\topsFromStorage += ops.messages.length;\n\t\t\tthis.opsReceived(ops.messages);\n\t\t\treturn ops;\n\t\t};\n\n\t\tconst stream = requestOps(\n\t\t\tasync (from: number, to: number, telemetryProps: ITelemetryProperties) => {\n\t\t\t\tconst result = await requestCallback(from, to, telemetryProps);\n\t\t\t\t// Catch all case, just in case\n\t\t\t\tvalidateMessages(\"catch all\", result.messages, from, this.logger);\n\t\t\t\treturn result;\n\t\t\t},\n\t\t\t// Staging: starting with no concurrency, listening for feedback first.\n\t\t\t// In future releases we will switch to actual concurrency\n\t\t\tthis.concurrency,\n\t\t\tfromTotal, // inclusive\n\t\t\ttoTotal, // exclusive\n\t\t\tthis.batchSize,\n\t\t\tthis.logger,\n\t\t\tabortSignal,\n\t\t\tfetchReason,\n\t\t);\n\n\t\treturn streamObserver(stream, (result) => {\n\t\t\tif (result.done && opsFromSnapshot + opsFromCache + opsFromStorage !== 0) {\n\t\t\t\tthis.logger.sendPerformanceEvent({\n\t\t\t\t\teventName: \"CacheOpsRetrieved\",\n\t\t\t\t\topsFromSnapshot,\n\t\t\t\t\topsFromCache,\n\t\t\t\t\topsFromStorage,\n\t\t\t\t\treason: fetchReason,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n}\n"]}
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { ITelemetryBaseLogger } from "@fluidframework/
|
|
5
|
+
import { ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
|
|
6
6
|
import { IDocumentService, IDocumentServiceFactory, IResolvedUrl } from "@fluidframework/driver-definitions";
|
|
7
7
|
import { ISummaryTree } from "@fluidframework/protocol-definitions";
|
|
8
8
|
import { TelemetryLogger } from "@fluidframework/telemetry-utils";
|
|
9
|
-
import { OdspResourceTokenFetchOptions, TokenFetcher, IPersistedCache, HostStoragePolicy } from "@fluidframework/odsp-driver-definitions";
|
|
9
|
+
import { OdspResourceTokenFetchOptions, TokenFetcher, IPersistedCache, HostStoragePolicy, ISocketStorageDiscovery, IRelaySessionAwareDriverFactory } from "@fluidframework/odsp-driver-definitions";
|
|
10
10
|
import { ICacheAndTracker } from "./epochTracker";
|
|
11
11
|
/**
|
|
12
12
|
* Factory for creating the sharepoint document service. Use this if you want to
|
|
@@ -15,14 +15,22 @@ import { ICacheAndTracker } from "./epochTracker";
|
|
|
15
15
|
* This constructor should be used by environments that support dynamic imports and that wish
|
|
16
16
|
* to leverage code splitting as a means to keep bundles as small as possible.
|
|
17
17
|
*/
|
|
18
|
-
export declare class OdspDocumentServiceFactoryCore implements IDocumentServiceFactory {
|
|
18
|
+
export declare class OdspDocumentServiceFactoryCore implements IDocumentServiceFactory, IRelaySessionAwareDriverFactory {
|
|
19
19
|
private readonly getStorageToken;
|
|
20
20
|
private readonly getWebsocketToken;
|
|
21
21
|
protected persistedCache: IPersistedCache;
|
|
22
22
|
private readonly hostPolicy;
|
|
23
23
|
private readonly nonPersistentCache;
|
|
24
24
|
private readonly socketReferenceKeyPrefix?;
|
|
25
|
-
get snapshotPrefetchResultCache(): import("@fluidframework/
|
|
25
|
+
get snapshotPrefetchResultCache(): import("@fluidframework/core-utils").PromiseCache<string, import("./odspCache").IPrefetchSnapshotContents>;
|
|
26
|
+
get IRelaySessionAwareDriverFactory(): this;
|
|
27
|
+
/**
|
|
28
|
+
* This function would return info about relay service session only if this factory established (or attempted to
|
|
29
|
+
* establish) connection very recently. Otherwise, it will return undefined.
|
|
30
|
+
* @param resolvedUrl - resolved url for container
|
|
31
|
+
* @returns - Current join session response stored in cache. Undefined if not present.
|
|
32
|
+
*/
|
|
33
|
+
getRelayServiceSessionInfo(resolvedUrl: IResolvedUrl): Promise<ISocketStorageDiscovery | undefined>;
|
|
26
34
|
createContainer(createNewSummary: ISummaryTree | undefined, createNewResolvedUrl: IResolvedUrl, logger?: ITelemetryBaseLogger, clientIsSummarizer?: boolean): Promise<IDocumentService>;
|
|
27
35
|
/**
|
|
28
36
|
* @param getStorageToken - function that can provide the storage token for a given site. This is
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspDocumentServiceFactoryCore.d.ts","sourceRoot":"","sources":["../src/odspDocumentServiceFactoryCore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"odspDocumentServiceFactoryCore.d.ts","sourceRoot":"","sources":["../src/odspDocumentServiceFactoryCore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EACN,gBAAgB,EAChB,uBAAuB,EACvB,YAAY,EACZ,MAAM,oCAAoC,CAAC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OAAO,CAAC,gBAAgB,CAAC;cASZ,yBAAyB,CACxC,WAAW,EAAE,YAAY,EACzB,UAAU,EAAE,eAAe,EAC3B,kBAAkB,CAAC,EAAE,gBAAgB,EACrC,kBAAkB,CAAC,EAAE,OAAO,GAC1B,OAAO,CAAC,gBAAgB,CAAC;CA+C5B"}
|
|
@@ -67,6 +67,20 @@ class OdspDocumentServiceFactoryCore {
|
|
|
67
67
|
get snapshotPrefetchResultCache() {
|
|
68
68
|
return this.nonPersistentCache.snapshotPrefetchResultCache;
|
|
69
69
|
}
|
|
70
|
+
get IRelaySessionAwareDriverFactory() {
|
|
71
|
+
return this;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* This function would return info about relay service session only if this factory established (or attempted to
|
|
75
|
+
* establish) connection very recently. Otherwise, it will return undefined.
|
|
76
|
+
* @param resolvedUrl - resolved url for container
|
|
77
|
+
* @returns - Current join session response stored in cache. Undefined if not present.
|
|
78
|
+
*/
|
|
79
|
+
async getRelayServiceSessionInfo(resolvedUrl) {
|
|
80
|
+
const odspResolvedUrl = (0, odspUtils_1.getOdspResolvedUrl)(resolvedUrl);
|
|
81
|
+
const joinSessionResponse = await this.nonPersistentCache.sessionJoinCache.get((0, odspUtils_1.getJoinSessionCacheKey)(odspResolvedUrl));
|
|
82
|
+
return joinSessionResponse === null || joinSessionResponse === void 0 ? void 0 : joinSessionResponse.joinSessionResponse;
|
|
83
|
+
}
|
|
70
84
|
async createContainer(createNewSummary, createNewResolvedUrl, logger, clientIsSummarizer) {
|
|
71
85
|
let odspResolvedUrl = (0, odspUtils_1.getOdspResolvedUrl)(createNewResolvedUrl);
|
|
72
86
|
const resolvedUrlData = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspDocumentServiceFactoryCore.js","sourceRoot":"","sources":["../src/odspDocumentServiceFactoryCore.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;AASH,qEAAoF;AACpF,+DAGsC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AkG;IAClG,IAAI,oBAAmE,CAAC;IACxE,IAAI,UAAU,CAAC,yCAAyC,EAAE;QACzD,MAAM,eAAe,GAAG,YAAY,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAC5D,MAAM,cAAc,GAAG,YAAY,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;QAC1D,IAAI,eAAe,IAAI,0CAAgB,CAAC,eAAe,CAAC,EAAE;YACzD,oBAAoB,mBACnB,KAAK,EAAE,0CAAgB,CAAC,eAAe,CAAC,IACrC,CAAC,cAAc,IAAI,yCAAe,CAAC,cAAc,CAAC;gBACpD,CAAC,CAAC,EAAE,IAAI,EAAE,yCAAe,CAAC,cAAc,CAAC,EAAE;gBAC3C,CAAC,CAAC,EAAE,CAAC,CACN,CAAC;SACF;KACD;SAAM,IAAI,UAAU,CAAC,yBAAyB,EAAE;QAChD,MAAM,cAAc,GAAG,YAAY,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;QAC1D,IAAI,cAAc,IAAI,wCAAc,CAAC,cAAc,CAAC,EAAE;YACrD,oBAAoB,GAAG,wCAAc,CAAC,cAAc,IAAI,EAAE,CAAC,CAAC;SAC5D;KACD;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 { ITelemetryBaseLogger } from \"@fluidframework/common-definitions\";\nimport {\n\tIDocumentService,\n\tIDocumentServiceFactory,\n\tIResolvedUrl,\n} from \"@fluidframework/driver-definitions\";\nimport { ISummaryTree } from \"@fluidframework/protocol-definitions\";\nimport { TelemetryLogger, PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport {\n\tgetDocAttributesFromProtocolSummary,\n\tisCombinedAppAndProtocolSummary,\n} from \"@fluidframework/driver-utils\";\nimport {\n\tTokenFetchOptions,\n\tOdspResourceTokenFetchOptions,\n\tTokenFetcher,\n\tIPersistedCache,\n\tHostStoragePolicy,\n\tIFileEntry,\n\tIOdspUrlParts,\n\tSharingLinkScope,\n\tSharingLinkRole,\n\tShareLinkTypes,\n\tISharingLinkKind,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { v4 as uuid } from \"uuid\";\nimport { INonPersistentCache, LocalPersistentCache, NonPersistentCache } from \"./odspCache\";\nimport { createOdspCacheAndTracker, ICacheAndTracker } from \"./epochTracker\";\nimport { OdspDocumentService } from \"./odspDocumentService\";\nimport {\n\tINewFileInfo,\n\tgetOdspResolvedUrl,\n\tcreateOdspLogger,\n\ttoInstrumentedOdspTokenFetcher,\n\tIExistingFileInfo,\n\tisNewFileInfo,\n} from \"./odspUtils\";\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 */\nexport class OdspDocumentServiceFactoryCore implements IDocumentServiceFactory {\n\tprivate readonly nonPersistentCache: INonPersistentCache = new NonPersistentCache();\n\tprivate readonly socketReferenceKeyPrefix?: string;\n\n\tpublic get snapshotPrefetchResultCache() {\n\t\treturn this.nonPersistentCache.snapshotPrefetchResultCache;\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\tlet 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: ShareLinkTypes | 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};\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\tenableShareLinkWithCreate: this.hostPolicy.enableShareLinkWithCreate,\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 getStorageToken = toInstrumentedOdspTokenFetcher(\n\t\t\t\t\todspLogger,\n\t\t\t\t\tresolvedUrlData,\n\t\t\t\t\tthis.getStorageToken,\n\t\t\t\t\ttrue /* throwOnNullToken */,\n\t\t\t\t);\n\t\t\t\t// We can delay load this module as this path will not be executed in load flows and create flow\n\t\t\t\t// while only happens once in lifetime of a document happens in the background after creation of\n\t\t\t\t// detached container.\n\t\t\t\tconst module = await import(\n\t\t\t\t\t/* webpackChunkName: \"createNewModule\" */ \"./createNewModule\"\n\t\t\t\t)\n\t\t\t\t\t.then((m) => {\n\t\t\t\t\t\todspLogger.sendTelemetryEvent({ eventName: \"createNewModuleLoaded\" });\n\t\t\t\t\t\treturn m;\n\t\t\t\t\t})\n\t\t\t\t\t.catch((error) => {\n\t\t\t\t\t\todspLogger.sendErrorEvent(\n\t\t\t\t\t\t\t{ eventName: \"createNewModuleLoadFailed\" },\n\t\t\t\t\t\t\terror,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t});\n\t\t\t\todspResolvedUrl = isNewFileInfo(fileInfo)\n\t\t\t\t\t? await module.createNewFluidFile(\n\t\t\t\t\t\t\tgetStorageToken,\n\t\t\t\t\t\t\tfileInfo,\n\t\t\t\t\t\t\todspLogger,\n\t\t\t\t\t\t\tcreateNewSummary,\n\t\t\t\t\t\t\tcacheAndTracker.epochTracker,\n\t\t\t\t\t\t\tfileEntry,\n\t\t\t\t\t\t\tthis.hostPolicy.cacheCreateNewSummary ?? true,\n\t\t\t\t\t\t\t!!this.hostPolicy.sessionOptions\n\t\t\t\t\t\t\t\t?.forceAccessTokenViaAuthorizationHeader,\n\t\t\t\t\t\t\todspResolvedUrl.isClpCompliantApp,\n\t\t\t\t\t\t\tthis.hostPolicy.enableSingleRequestForShareLinkWithCreate,\n\t\t\t\t\t\t\tthis.hostPolicy.enableShareLinkWithCreate,\n\t\t\t\t\t )\n\t\t\t\t\t: await module.createNewContainerOnExistingFile(\n\t\t\t\t\t\t\tgetStorageToken,\n\t\t\t\t\t\t\tfileInfo,\n\t\t\t\t\t\t\todspLogger,\n\t\t\t\t\t\t\tcreateNewSummary,\n\t\t\t\t\t\t\tcacheAndTracker.epochTracker,\n\t\t\t\t\t\t\tfileEntry,\n\t\t\t\t\t\t\tthis.hostPolicy.cacheCreateNewSummary ?? true,\n\t\t\t\t\t\t\t!!this.hostPolicy.sessionOptions\n\t\t\t\t\t\t\t\t?.forceAccessTokenViaAuthorizationHeader,\n\t\t\t\t\t\t\todspResolvedUrl.isClpCompliantApp,\n\t\t\t\t\t );\n\t\t\t\tconst docService = this.createDocumentServiceCore(\n\t\t\t\t\todspResolvedUrl,\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: TokenFetcher<OdspResourceTokenFetchOptions> | 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\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: TelemetryLogger,\n\t\tcacheAndTrackerArg?: ICacheAndTracker,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\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\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{ resolvedUrl: odspResolvedUrl, docId: odspResolvedUrl.hashedDocumentId },\n\t\t\t\todspLogger,\n\t\t\t\tclientIsSummarizer,\n\t\t\t);\n\n\t\tconst storageTokenFetcher = toInstrumentedOdspTokenFetcher(\n\t\t\todspLogger,\n\t\t\tresolvedUrlData,\n\t\t\tthis.getStorageToken,\n\t\t\ttrue /* throwOnNullToken */,\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) =>\n\t\t\t\t\t\ttoInstrumentedOdspTokenFetcher(\n\t\t\t\t\t\t\todspLogger,\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)(options, \"GetWebsocketToken\");\n\n\t\treturn OdspDocumentService.create(\n\t\t\tresolvedUrl,\n\t\t\tstorageTokenFetcher,\n\t\t\twebSocketTokenFetcher,\n\t\t\todspLogger,\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): ShareLinkTypes | ISharingLinkKind | undefined {\n\t// extract request parameters for creation of sharing link (if provided) if the feature is enabled\n\tlet createShareLinkParam: ShareLinkTypes | 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\tscope: SharingLinkScope[createLinkScope],\n\t\t\t\t...(createLinkRole && SharingLinkRole[createLinkRole]\n\t\t\t\t\t? { role: SharingLinkRole[createLinkRole] }\n\t\t\t\t\t: {}),\n\t\t\t};\n\t\t}\n\t} else if (hostPolicy.enableShareLinkWithCreate) {\n\t\tconst createLinkType = searchParams.get(\"createLinkType\");\n\t\tif (createLinkType && ShareLinkTypes[createLinkType]) {\n\t\t\tcreateShareLinkParam = ShareLinkTypes[createLinkType || \"\"];\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;;;;;;;;;;;;;;;;;;;;;;AASH,qEAAoF;AACpF,+DAGsC;AACtC,qFAciD;AACjD,+BAAkC;AAClC,2CAA4F;AAC5F,iDAA6E;AAC7E,+DAA4D;AAC5D,2CAQqB;AAErB;;;;;;GAMG;AACH,MAAa,8BAA8B;IA4K1C;;;;;;;;OAQG;IACH,YACkB,eAA4D,EAC5D,iBAA0E,EACjF,iBAAkC,IAAI,gCAAoB,EAAE,EACrD,aAAgC,EAAE;;QAHlC,oBAAe,GAAf,eAAe,CAA6C;QAC5D,sBAAiB,GAAjB,iBAAiB,CAAyD;QACjF,mBAAc,GAAd,cAAc,CAA8C;QACrD,eAAU,GAAV,UAAU,CAAwB;QAtLnC,uBAAkB,GAAwB,IAAI,8BAAkB,EAAE,CAAC;QAwLnF,IAAI,IAAI,CAAC,UAAU,CAAC,kBAAkB,KAAK,IAAI,EAAE;YAChD,oDAAoD;YACpD,IAAI,CAAC,wBAAwB,GAAG,IAAA,SAAI,GAAE,CAAC;SACvC;QACD,+CAA+C;QAC/C,IAAI,CAAC,UAAU,CAAC,oBAAoB,GAAG,MAAA,IAAI,CAAC,UAAU,CAAC,oBAAoB,mCAAI,IAAI,CAAC;QACpF,IAAI,CAAC,UAAU,CAAC,cAAc,mBAC7B,sCAAsC,EAAE,IAAI,IACzC,IAAI,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BACpD,CAAC,CAAC,EAAE,IAAI,EAAE,yCAAe,CAAC,cAAc,CAAC,EAAE;gBAC3C,CAAC,CAAC,EAAE,CAAC,CACN,CAAC;SACF;KACD;SAAM,IAAI,UAAU,CAAC,yBAAyB,EAAE;QAChD,MAAM,cAAc,GAAG,YAAY,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;QAC1D,IAAI,cAAc,IAAI,wCAAc,CAAC,cAAc,CAAC,EAAE;YACrD,oBAAoB,GAAG,wCAAc,CAAC,cAAc,IAAI,EAAE,CAAC,CAAC;SAC5D;KACD;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 { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport {\n\tIDocumentService,\n\tIDocumentServiceFactory,\n\tIResolvedUrl,\n} from \"@fluidframework/driver-definitions\";\nimport { ISummaryTree } from \"@fluidframework/protocol-definitions\";\nimport { TelemetryLogger, PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport {\n\tgetDocAttributesFromProtocolSummary,\n\tisCombinedAppAndProtocolSummary,\n} from \"@fluidframework/driver-utils\";\nimport {\n\tTokenFetchOptions,\n\tOdspResourceTokenFetchOptions,\n\tTokenFetcher,\n\tIPersistedCache,\n\tHostStoragePolicy,\n\tIFileEntry,\n\tIOdspUrlParts,\n\tSharingLinkScope,\n\tSharingLinkRole,\n\tShareLinkTypes,\n\tISharingLinkKind,\n\tISocketStorageDiscovery,\n\tIRelaySessionAwareDriverFactory,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { v4 as uuid } from \"uuid\";\nimport { INonPersistentCache, LocalPersistentCache, NonPersistentCache } from \"./odspCache\";\nimport { createOdspCacheAndTracker, ICacheAndTracker } from \"./epochTracker\";\nimport { OdspDocumentService } from \"./odspDocumentService\";\nimport {\n\tINewFileInfo,\n\tgetOdspResolvedUrl,\n\tcreateOdspLogger,\n\ttoInstrumentedOdspTokenFetcher,\n\tIExistingFileInfo,\n\tisNewFileInfo,\n\tgetJoinSessionCacheKey,\n} from \"./odspUtils\";\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 */\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() {\n\t\treturn this.nonPersistentCache.snapshotPrefetchResultCache;\n\t}\n\n\tpublic get IRelaySessionAwareDriverFactory() {\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 - 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\tlet 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: ShareLinkTypes | 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};\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\tenableShareLinkWithCreate: this.hostPolicy.enableShareLinkWithCreate,\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 getStorageToken = toInstrumentedOdspTokenFetcher(\n\t\t\t\t\todspLogger,\n\t\t\t\t\tresolvedUrlData,\n\t\t\t\t\tthis.getStorageToken,\n\t\t\t\t\ttrue /* throwOnNullToken */,\n\t\t\t\t);\n\t\t\t\t// We can delay load this module as this path will not be executed in load flows and create flow\n\t\t\t\t// while only happens once in lifetime of a document happens in the background after creation of\n\t\t\t\t// detached container.\n\t\t\t\tconst module = await import(\n\t\t\t\t\t/* webpackChunkName: \"createNewModule\" */ \"./createNewModule\"\n\t\t\t\t)\n\t\t\t\t\t.then((m) => {\n\t\t\t\t\t\todspLogger.sendTelemetryEvent({ eventName: \"createNewModuleLoaded\" });\n\t\t\t\t\t\treturn m;\n\t\t\t\t\t})\n\t\t\t\t\t.catch((error) => {\n\t\t\t\t\t\todspLogger.sendErrorEvent(\n\t\t\t\t\t\t\t{ eventName: \"createNewModuleLoadFailed\" },\n\t\t\t\t\t\t\terror,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t});\n\t\t\t\todspResolvedUrl = isNewFileInfo(fileInfo)\n\t\t\t\t\t? await module.createNewFluidFile(\n\t\t\t\t\t\t\tgetStorageToken,\n\t\t\t\t\t\t\tfileInfo,\n\t\t\t\t\t\t\todspLogger,\n\t\t\t\t\t\t\tcreateNewSummary,\n\t\t\t\t\t\t\tcacheAndTracker.epochTracker,\n\t\t\t\t\t\t\tfileEntry,\n\t\t\t\t\t\t\tthis.hostPolicy.cacheCreateNewSummary ?? true,\n\t\t\t\t\t\t\t!!this.hostPolicy.sessionOptions\n\t\t\t\t\t\t\t\t?.forceAccessTokenViaAuthorizationHeader,\n\t\t\t\t\t\t\todspResolvedUrl.isClpCompliantApp,\n\t\t\t\t\t\t\tthis.hostPolicy.enableSingleRequestForShareLinkWithCreate,\n\t\t\t\t\t\t\tthis.hostPolicy.enableShareLinkWithCreate,\n\t\t\t\t\t )\n\t\t\t\t\t: await module.createNewContainerOnExistingFile(\n\t\t\t\t\t\t\tgetStorageToken,\n\t\t\t\t\t\t\tfileInfo,\n\t\t\t\t\t\t\todspLogger,\n\t\t\t\t\t\t\tcreateNewSummary,\n\t\t\t\t\t\t\tcacheAndTracker.epochTracker,\n\t\t\t\t\t\t\tfileEntry,\n\t\t\t\t\t\t\tthis.hostPolicy.cacheCreateNewSummary ?? true,\n\t\t\t\t\t\t\t!!this.hostPolicy.sessionOptions\n\t\t\t\t\t\t\t\t?.forceAccessTokenViaAuthorizationHeader,\n\t\t\t\t\t\t\todspResolvedUrl.isClpCompliantApp,\n\t\t\t\t\t );\n\t\t\t\tconst docService = this.createDocumentServiceCore(\n\t\t\t\t\todspResolvedUrl,\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: TokenFetcher<OdspResourceTokenFetchOptions> | 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\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: TelemetryLogger,\n\t\tcacheAndTrackerArg?: ICacheAndTracker,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\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\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{ resolvedUrl: odspResolvedUrl, docId: odspResolvedUrl.hashedDocumentId },\n\t\t\t\todspLogger,\n\t\t\t\tclientIsSummarizer,\n\t\t\t);\n\n\t\tconst storageTokenFetcher = toInstrumentedOdspTokenFetcher(\n\t\t\todspLogger,\n\t\t\tresolvedUrlData,\n\t\t\tthis.getStorageToken,\n\t\t\ttrue /* throwOnNullToken */,\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) =>\n\t\t\t\t\t\ttoInstrumentedOdspTokenFetcher(\n\t\t\t\t\t\t\todspLogger,\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)(options, \"GetWebsocketToken\");\n\n\t\treturn OdspDocumentService.create(\n\t\t\tresolvedUrl,\n\t\t\tstorageTokenFetcher,\n\t\t\twebSocketTokenFetcher,\n\t\t\todspLogger,\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): ShareLinkTypes | ISharingLinkKind | undefined {\n\t// extract request parameters for creation of sharing link (if provided) if the feature is enabled\n\tlet createShareLinkParam: ShareLinkTypes | 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\tscope: SharingLinkScope[createLinkScope],\n\t\t\t\t...(createLinkRole && SharingLinkRole[createLinkRole]\n\t\t\t\t\t? { role: SharingLinkRole[createLinkRole] }\n\t\t\t\t\t: {}),\n\t\t\t};\n\t\t}\n\t} else if (hostPolicy.enableShareLinkWithCreate) {\n\t\tconst createLinkType = searchParams.get(\"createLinkType\");\n\t\tif (createLinkType && ShareLinkTypes[createLinkType]) {\n\t\t\tcreateShareLinkParam = ShareLinkTypes[createLinkType || \"\"];\n\t\t}\n\t}\n\treturn createShareLinkParam;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspDocumentStorageManager.d.ts","sourceRoot":"","sources":["../src/odspDocumentStorageManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,mBAAmB,EAGnB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,KAAK,GAAG,MAAM,sCAAsC,CAAC;AAE5D,OAAO,EAAE,eAAe,EAAmB,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAEnG,OAAO,EACN,gBAAgB,EAGhB,+BAA+B,EAE/B,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAEN,yBAAyB,EAGzB,MAAM,aAAa,CAAC;AACrB,OAAO,EAKN,yBAAyB,EACzB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,UAAU,EAA6B,MAAM,aAAa,CAAC;AAGpE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAE5D,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAElF,eAAO,MAAM,mCAAmC,EAAE,MAAkB,CAAC;AAOrE,qBAAa,0BAA2B,SAAQ,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,CAAC,mBAAmB,CAAC;cA2ChE,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC;IAgD/E,eAAe,CAC3B,OAAO,CAAC,EAAE,GAAG,CAAC,QAAQ,EACtB,YAAY,CAAC,EAAE,MAAM,GAEnB,OAAO,CAAC,GAAG,CAAC,aAAa,GAAG,IAAI,CAAC;IAOvB,WAAW,CAEvB,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,KAAK,EAAE,MAAM,EACb,YAAY,CAAC,EAAE,MAAM,EACrB,WAAW,CAAC,EAAE,WAAW,GACvB,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;YA8MZ,aAAa;YAiBb,iBAAiB;IAiIlB,wBAAwB,CACpC,OAAO,EAAE,GAAG,CAAC,YAAY,EACzB,OAAO,EAAE,eAAe,GACtB,OAAO,CAAC,MAAM,CAAC;YA4DJ,4BAA4B;IAwB1C,OAAO,CAAC,gBAAgB;IAUxB,OAAO,CAAC,sBAAsB;IAU9B,OAAO,CAAC,qBAAqB;cAUb,qBAAqB,CACpC,EAAE,EAAE,MAAM,EACV,YAAY,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,GAAG,CAAC,aAAa,GAAG,SAAS,CAAC;CAyCzC"}
|
|
@@ -285,6 +285,8 @@ class OdspDocumentStorageService extends odspDocumentStorageServiceBase_1.OdspDo
|
|
|
285
285
|
if (!this.hostPolicy.avoidPrefetchSnapshotCache) {
|
|
286
286
|
const prefetchCacheKey = (0, odsp_driver_definitions_1.getKeyForCacheEntry)((0, odspUtils_1.createCacheSnapshotKey)(this.odspResolvedUrl));
|
|
287
287
|
const result = await ((_b = (_a = this.cache.snapshotPrefetchResultCache) === null || _a === void 0 ? void 0 : _a.get(prefetchCacheKey)) === null || _b === void 0 ? void 0 : _b.then(async (response) => {
|
|
288
|
+
// Remove it from cache once used.
|
|
289
|
+
this.cache.snapshotPrefetchResultCache.remove(prefetchCacheKey);
|
|
288
290
|
// Validate the epoch from the prefetched snapshot result.
|
|
289
291
|
await this.epochTracker.validateEpoch(response.fluidEpoch, "treesLatest");
|
|
290
292
|
return response;
|