@fluidframework/odsp-driver 0.59.2001 → 0.59.3000
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/.eslintrc.js +0 -1
- package/dist/ReadBufferUtils.js +2 -2
- package/dist/ReadBufferUtils.js.map +1 -1
- package/dist/WriteBufferUtils.js +14 -14
- package/dist/WriteBufferUtils.js.map +1 -1
- package/dist/checkUrl.js +1 -1
- package/dist/checkUrl.js.map +1 -1
- package/dist/compactSnapshotParser.js +27 -27
- package/dist/compactSnapshotParser.js.map +1 -1
- package/dist/compactSnapshotWriter.js +15 -15
- package/dist/compactSnapshotWriter.js.map +1 -1
- package/dist/contracts.d.ts +0 -1
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js.map +1 -1
- package/dist/createFile.js +15 -15
- package/dist/createFile.js.map +1 -1
- package/dist/createNewUtils.js +4 -4
- package/dist/createNewUtils.js.map +1 -1
- package/dist/epochTracker.d.ts.map +1 -1
- package/dist/epochTracker.js +11 -11
- package/dist/epochTracker.js.map +1 -1
- package/dist/fetch.js +1 -1
- package/dist/fetch.js.map +1 -1
- package/dist/fetchSnapshot.d.ts.map +1 -1
- package/dist/fetchSnapshot.js +19 -19
- package/dist/fetchSnapshot.js.map +1 -1
- package/dist/getFileLink.js +19 -19
- package/dist/getFileLink.js.map +1 -1
- package/dist/getQueryString.d.ts.map +1 -1
- package/dist/getQueryString.js.map +1 -1
- package/dist/getUrlAndHeadersWithAuth.d.ts.map +1 -1
- package/dist/getUrlAndHeadersWithAuth.js.map +1 -1
- package/dist/odspCache.d.ts.map +1 -1
- package/dist/odspCache.js.map +1 -1
- package/dist/odspDeltaStorageService.d.ts.map +1 -1
- package/dist/odspDeltaStorageService.js +5 -5
- package/dist/odspDeltaStorageService.js.map +1 -1
- package/dist/odspDocumentDeltaConnection.d.ts.map +1 -1
- package/dist/odspDocumentDeltaConnection.js +12 -12
- package/dist/odspDocumentDeltaConnection.js.map +1 -1
- package/dist/odspDocumentService.js +9 -8
- package/dist/odspDocumentService.js.map +1 -1
- package/dist/odspDocumentServiceFactory.js +1 -1
- package/dist/odspDocumentServiceFactory.js.map +1 -1
- package/dist/odspDocumentServiceFactoryCore.d.ts.map +1 -1
- package/dist/odspDocumentServiceFactoryCore.js +20 -12
- package/dist/odspDocumentServiceFactoryCore.js.map +1 -1
- package/dist/odspDocumentStorageManager.d.ts +1 -0
- package/dist/odspDocumentStorageManager.d.ts.map +1 -1
- package/dist/odspDocumentStorageManager.js +34 -32
- package/dist/odspDocumentStorageManager.js.map +1 -1
- package/dist/odspDriverUrlResolver.js +10 -10
- package/dist/odspDriverUrlResolver.js.map +1 -1
- package/dist/odspDriverUrlResolverForShareLink.js +10 -10
- package/dist/odspDriverUrlResolverForShareLink.js.map +1 -1
- package/dist/odspError.d.ts +1 -1
- package/dist/odspError.d.ts.map +1 -1
- package/dist/odspError.js +1 -1
- package/dist/odspError.js.map +1 -1
- package/dist/odspFluidFileLink.js +2 -2
- package/dist/odspFluidFileLink.js.map +1 -1
- package/dist/odspPublicUtils.js +1 -1
- package/dist/odspPublicUtils.js.map +1 -1
- package/dist/odspSnapshotParser.js +3 -3
- package/dist/odspSnapshotParser.js.map +1 -1
- package/dist/odspSummaryUploadManager.js +7 -7
- package/dist/odspSummaryUploadManager.js.map +1 -1
- package/dist/odspUtils.js +9 -9
- package/dist/odspUtils.js.map +1 -1
- package/dist/opsCaching.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.js +7 -7
- package/dist/prefetchLatestSnapshot.js.map +1 -1
- package/dist/retryErrorsStorageAdapter.d.ts.map +1 -1
- package/dist/retryErrorsStorageAdapter.js +1 -1
- package/dist/retryErrorsStorageAdapter.js.map +1 -1
- package/dist/retryUtils.js +4 -4
- package/dist/retryUtils.js.map +1 -1
- package/dist/vroom.js +3 -3
- package/dist/vroom.js.map +1 -1
- package/dist/zipItDataRepresentationUtils.d.ts.map +1 -1
- package/dist/zipItDataRepresentationUtils.js +21 -12
- package/dist/zipItDataRepresentationUtils.js.map +1 -1
- package/lib/WriteBufferUtils.js +1 -1
- package/lib/WriteBufferUtils.js.map +1 -1
- package/lib/compactSnapshotParser.js.map +1 -1
- package/lib/compactSnapshotWriter.js.map +1 -1
- package/lib/contracts.d.ts +0 -1
- package/lib/contracts.d.ts.map +1 -1
- package/lib/contracts.js.map +1 -1
- package/lib/createFile.js.map +1 -1
- package/lib/epochTracker.d.ts.map +1 -1
- package/lib/epochTracker.js +1 -1
- package/lib/epochTracker.js.map +1 -1
- package/lib/fetchSnapshot.d.ts.map +1 -1
- package/lib/fetchSnapshot.js.map +1 -1
- package/lib/getFileLink.js +6 -6
- package/lib/getFileLink.js.map +1 -1
- package/lib/getQueryString.d.ts.map +1 -1
- package/lib/getQueryString.js.map +1 -1
- package/lib/getUrlAndHeadersWithAuth.d.ts.map +1 -1
- package/lib/getUrlAndHeadersWithAuth.js.map +1 -1
- package/lib/odspCache.d.ts.map +1 -1
- package/lib/odspCache.js.map +1 -1
- package/lib/odspDeltaStorageService.d.ts.map +1 -1
- package/lib/odspDeltaStorageService.js.map +1 -1
- package/lib/odspDocumentDeltaConnection.d.ts.map +1 -1
- package/lib/odspDocumentDeltaConnection.js +1 -1
- package/lib/odspDocumentDeltaConnection.js.map +1 -1
- package/lib/odspDocumentService.js +2 -1
- package/lib/odspDocumentService.js.map +1 -1
- package/lib/odspDocumentServiceFactoryCore.d.ts.map +1 -1
- package/lib/odspDocumentServiceFactoryCore.js +10 -2
- package/lib/odspDocumentServiceFactoryCore.js.map +1 -1
- package/lib/odspDocumentStorageManager.d.ts +1 -0
- package/lib/odspDocumentStorageManager.d.ts.map +1 -1
- package/lib/odspDocumentStorageManager.js +17 -15
- package/lib/odspDocumentStorageManager.js.map +1 -1
- package/lib/odspDriverUrlResolver.js +5 -5
- package/lib/odspDriverUrlResolver.js.map +1 -1
- package/lib/odspDriverUrlResolverForShareLink.js.map +1 -1
- package/lib/odspError.d.ts +1 -1
- package/lib/odspError.d.ts.map +1 -1
- package/lib/odspFluidFileLink.js.map +1 -1
- package/lib/odspSnapshotParser.js +1 -1
- package/lib/odspSnapshotParser.js.map +1 -1
- package/lib/odspUtils.js.map +1 -1
- package/lib/opsCaching.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/retryErrorsStorageAdapter.d.ts.map +1 -1
- package/lib/retryErrorsStorageAdapter.js.map +1 -1
- package/lib/retryUtils.js +1 -1
- package/lib/retryUtils.js.map +1 -1
- package/lib/vroom.js.map +1 -1
- package/lib/zipItDataRepresentationUtils.d.ts.map +1 -1
- package/lib/zipItDataRepresentationUtils.js +12 -3
- package/lib/zipItDataRepresentationUtils.js.map +1 -1
- package/package.json +14 -13
- package/src/compactSnapshotParser.ts +2 -2
- package/src/contracts.ts +4 -5
- package/src/createFile.ts +2 -2
- package/src/epochTracker.ts +9 -10
- package/src/fetchSnapshot.ts +10 -10
- package/src/getFileLink.ts +10 -10
- package/src/getQueryString.ts +1 -1
- package/src/getUrlAndHeadersWithAuth.ts +1 -1
- package/src/odspCache.ts +2 -2
- package/src/odspDeltaStorageService.ts +4 -5
- package/src/odspDocumentDeltaConnection.ts +2 -2
- package/src/odspDocumentService.ts +5 -5
- package/src/odspDocumentServiceFactoryCore.ts +13 -1
- package/src/odspDocumentStorageManager.ts +25 -18
- package/src/odspDriverUrlResolver.ts +2 -2
- package/src/odspDriverUrlResolverForShareLink.ts +1 -1
- package/src/odspSnapshotParser.ts +2 -2
- package/src/odspUtils.ts +6 -6
- package/src/opsCaching.ts +2 -2
- package/src/packageVersion.ts +1 -1
- package/src/retryErrorsStorageAdapter.ts +1 -1
- package/src/vroom.ts +1 -1
- package/src/zipItDataRepresentationUtils.ts +15 -13
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspDocum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G,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,aAAa,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC,CAAC,CAAC;SAC/E,EACD,SAAS,cACT,IAAI,CAAC,UAAU,CAAC,UAAU,0CAAE,gBAAgB,mCAAI,IAAI,cACpD,IAAI,CAAC,UAAU,CAAC,UAAU,0CAAE,eAAe,mCAAI,IAAI,CACtD,CAAC;QACF,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED,mHAAmH;IACnH,8EAA8E;IACpE,WAAW,CAAC,GAAgC;;QAClD,2CAA2C;QAC3C,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE;YACrD,OAAO;SACV;QAED,MAAA,IAAI,CAAC,QAAQ,0CAAE,MAAM,CAAC,GAAG,EAAE;IAC/B,CAAC;CACJ;AApeD,kDAoeC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { performance } from \"@fluidframework/common-utils\";\nimport {\n ChildLogger,\n IFluidErrorBase,\n loggerToMonitoringContext,\n MonitoringContext,\n normalizeError,\n} from \"@fluidframework/telemetry-utils\";\nimport {\n IDocumentDeltaConnection,\n IDocumentDeltaStorageService,\n IDocumentService,\n IResolvedUrl,\n IDocumentStorageService,\n IDocumentServicePolicies,\n DriverErrorType,\n} from \"@fluidframework/driver-definitions\";\nimport { DeltaStreamConnectionForbiddenError, NonRetryableError } from \"@fluidframework/driver-utils\";\nimport { IFacetCodes } from \"@fluidframework/odsp-doclib-utils\";\nimport {\n IClient,\n ISequencedDocumentMessage,\n} from \"@fluidframework/protocol-definitions\";\nimport {\n IOdspResolvedUrl,\n TokenFetchOptions,\n IEntry,\n HostStoragePolicy,\n InstrumentedStorageTokenFetcher,\n OdspErrorType,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport type { io as SocketIOClientStatic } from \"socket.io-client\";\nimport { HostStoragePolicyInternal, ISocketStorageDiscovery } from \"./contracts\";\nimport { IOdspCache } from \"./odspCache\";\nimport { OdspDeltaStorageService, OdspDeltaStorageWithCache } from \"./odspDeltaStorageService\";\nimport { OdspDocumentDeltaConnection } from \"./odspDocumentDeltaConnection\";\nimport { OdspDocumentStorageService } from \"./odspDocumentStorageManager\";\nimport { getWithRetryForTokenRefresh, getOdspResolvedUrl, TokenFetchOptionsEx } from \"./odspUtils\";\nimport { fetchJoinSession } from \"./vroom\";\nimport { isOdcOrigin } from \"./odspUrlHelper\";\nimport { EpochTracker } from \"./epochTracker\";\nimport { OpsCache } from \"./opsCaching\";\nimport { RetryErrorsStorageAdapter } from \"./retryErrorsStorageAdapter\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\n\n/**\n * The DocumentService manages the Socket.IO connection and manages routing requests to connected\n * clients\n */\nexport class OdspDocumentService implements IDocumentService {\n private _policies: IDocumentServicePolicies;\n // Timer which runs and executes the join session call after intervals.\n private joinSessionRefreshTimer: ReturnType<typeof setTimeout> | undefined;\n /**\n * @param resolvedUrl - resolved url identifying document that will be managed by returned service instance.\n * @param getStorageToken - function that can provide the storage token. This is is also referred to as\n * the \"Vroom\" token in SPO.\n * @param getWebsocketToken - function that can provide a token for accessing the web socket. This is also referred\n * to as the \"Push\" token in SPO. If undefined then websocket token is expected to be returned with joinSession\n * response payload.\n * @param logger - a logger that can capture performance and diagnostic information\n * @param socketIoClientFactory - A factory that returns a promise to the socket io library required by the driver\n * @param cache - This caches response for joinSession.\n * @param hostPolicy - This host constructed policy which customizes service behavior.\n * @param epochTracker - This helper class which adds epoch to backend calls made by returned service instance.\n * @param socketReferenceKeyPrefix - (optional) prefix to isolate socket reuse cache\n */\n public static async create(\n resolvedUrl: IResolvedUrl,\n getStorageToken: InstrumentedStorageTokenFetcher,\n getWebsocketToken: ((options: TokenFetchOptions) => Promise<string | null>) | undefined,\n logger: ITelemetryLogger,\n socketIoClientFactory: () => Promise<typeof SocketIOClientStatic>,\n cache: IOdspCache,\n hostPolicy: HostStoragePolicy,\n epochTracker: EpochTracker,\n socketReferenceKeyPrefix?: string,\n clientIsSummarizer?: boolean,\n ): Promise<IDocumentService> {\n return new OdspDocumentService(\n getOdspResolvedUrl(resolvedUrl),\n getStorageToken,\n getWebsocketToken,\n logger,\n socketIoClientFactory,\n cache,\n hostPolicy,\n epochTracker,\n socketReferenceKeyPrefix,\n clientIsSummarizer,\n );\n }\n\n private storageManager?: OdspDocumentStorageService;\n\n private readonly mc: MonitoringContext;\n\n private readonly joinSessionKey: string;\n\n private readonly hostPolicy: HostStoragePolicyInternal;\n\n private _opsCache?: OpsCache;\n\n private currentConnection?: OdspDocumentDeltaConnection;\n\n /**\n * @param odspResolvedUrl - resolved url identifying document that will be managed by this service instance.\n * @param getStorageToken - function that can provide the storage token. This is is also referred to as\n * the \"Vroom\" token in SPO.\n * @param getWebsocketToken - function that can provide a token for accessing the web socket. This is also referred\n * to as the \"Push\" token in SPO. If undefined then websocket token is expected to be returned with joinSession\n * response payload.\n * @param logger - a logger that can capture performance and diagnostic information\n * @param socketIoClientFactory - A factory that returns a promise to the socket io library required by the driver\n * @param cache - This caches response for joinSession.\n * @param hostPolicy - host constructed policy which customizes service behavior.\n * @param epochTracker - This helper class which adds epoch to backend calls made by this service instance.\n * @param socketReferenceKeyPrefix - (optional) prefix to isolate socket reuse cache\n */\n private constructor(\n public readonly odspResolvedUrl: IOdspResolvedUrl,\n private readonly getStorageToken: InstrumentedStorageTokenFetcher,\n private readonly getWebsocketToken: ((options: TokenFetchOptions) => Promise<string | null>) | undefined,\n logger: ITelemetryLogger,\n private readonly socketIoClientFactory: () => Promise<typeof SocketIOClientStatic>,\n private readonly cache: IOdspCache,\n hostPolicy: HostStoragePolicy,\n private readonly epochTracker: EpochTracker,\n private readonly socketReferenceKeyPrefix?: string,\n private readonly clientIsSummarizer?: boolean,\n ) {\n this._policies = {\n // load in storage-only mode if a file version is specified\n storageOnly: odspResolvedUrl.fileVersion !== undefined,\n };\n\n this.joinSessionKey = `${this.odspResolvedUrl.hashedDocumentId}/joinsession`;\n this.mc = loggerToMonitoringContext(\n ChildLogger.create(logger,\n undefined,\n {\n all: {\n odc: isOdcOrigin(new URL(this.odspResolvedUrl.endpoints.snapshotStorageUrl).origin),\n },\n }));\n\n this.hostPolicy = hostPolicy;\n if (this.clientIsSummarizer) {\n this.hostPolicy = { ...this.hostPolicy, summarizerClient: true };\n }\n }\n\n public get resolvedUrl(): IResolvedUrl {\n return this.odspResolvedUrl;\n }\n public get policies() {\n return this._policies;\n }\n\n /**\n * Connects to a storage endpoint for snapshot service.\n *\n * @returns returns the document storage service for sharepoint driver.\n */\n public async connectToStorage(): Promise<IDocumentStorageService> {\n if (!this.storageManager) {\n this.storageManager = new OdspDocumentStorageService(\n this.odspResolvedUrl,\n this.getStorageToken,\n this.mc.logger,\n true,\n this.cache,\n this.hostPolicy,\n this.epochTracker,\n // flushCallback\n async () => {\n if (this.currentConnection !== undefined && !this.currentConnection.disposed) {\n return this.currentConnection.flush();\n }\n throw new Error(\"Disconnected while uploading summary (attempt to perform flush())\");\n },\n this.mc.config.getNumber(\"Fluid.Driver.Odsp.snapshotFormatFetchType\"),\n );\n }\n\n return new RetryErrorsStorageAdapter(this.storageManager, this.mc.logger);\n }\n\n /**\n * Connects to a delta storage endpoint for getting ops between a range.\n *\n * @returns returns the document delta storage service for sharepoint driver.\n */\n public async connectToDeltaStorage(): Promise<IDocumentDeltaStorageService> {\n const snapshotOps = this.storageManager?.ops ?? [];\n const service = new OdspDeltaStorageService(\n this.odspResolvedUrl.endpoints.deltaStorageUrl,\n this.getStorageToken,\n this.epochTracker,\n this.mc.logger,\n );\n\n // batch size, please see issue #5211 for data around batch sizing\n const batchSize = this.hostPolicy.opsBatchSize ?? 5000;\n const concurrency = this.hostPolicy.concurrentOpsBatches ?? 1;\n return new OdspDeltaStorageWithCache(\n snapshotOps,\n this.mc.logger,\n batchSize,\n concurrency,\n async (from, to, telemetryProps, fetchReason) => service.get(from, to, telemetryProps, fetchReason),\n async (from, to) => {\n const res = await this.opsCache?.get(from, to);\n return res as ISequencedDocumentMessage[] ?? [];\n },\n (from, to) => {\n if (this.currentConnection !== undefined && !this.currentConnection.disposed) {\n this.currentConnection.requestOps(from, to);\n }\n },\n (ops: ISequencedDocumentMessage[]) => this.opsReceived(ops),\n );\n }\n\n /** Annotate the given error indicating which connection step failed */\n private annotateConnectionError(\n error: any,\n failedConnectionStep: string,\n separateTokenRequest: boolean,\n ): IFluidErrorBase {\n return normalizeError(error, { props: {\n failedConnectionStep,\n separateTokenRequest,\n }});\n }\n\n /**\n * Connects to a delta stream endpoint for emitting ops.\n *\n * @returns returns the document delta stream service for onedrive/sharepoint driver.\n */\n public async connectToDeltaStream(client: IClient): Promise<IDocumentDeltaConnection> {\n // Attempt to connect twice, in case we used expired token.\n return getWithRetryForTokenRefresh<IDocumentDeltaConnection>(async (options) => {\n // Presence of getWebsocketToken callback dictates whether callback is used for fetching\n // websocket token or whether it is returned with joinSession response payload\n const requestWebsocketTokenFromJoinSession = this.getWebsocketToken === undefined;\n const websocketTokenPromise = requestWebsocketTokenFromJoinSession\n ? Promise.resolve(null)\n : this.getWebsocketToken!(options);\n\n const annotateAndRethrowConnectionError = (step: string) => (error: any) => {\n throw this.annotateConnectionError(error, step, !requestWebsocketTokenFromJoinSession);\n };\n\n const joinSessionPromise = this.joinSession(requestWebsocketTokenFromJoinSession, options);\n const [websocketEndpoint, websocketToken, io] =\n await Promise.all([\n joinSessionPromise.catch(annotateAndRethrowConnectionError(\"joinSession\")),\n websocketTokenPromise.catch(annotateAndRethrowConnectionError(\"getWebsocketToken\")),\n this.socketIoClientFactory().catch(annotateAndRethrowConnectionError(\"socketIoClientFactory\")),\n ]);\n\n const finalWebsocketToken = websocketToken ?? (websocketEndpoint.socketToken || null);\n if (finalWebsocketToken === null) {\n throw this.annotateConnectionError(\n new NonRetryableError(\n \"Websocket token is null\",\n OdspErrorType.fetchTokenError,\n { driverVersion },\n ),\n \"getWebsocketToken\",\n !requestWebsocketTokenFromJoinSession);\n }\n try {\n const connection = await this.createDeltaConnection(\n websocketEndpoint.tenantId,\n websocketEndpoint.id,\n finalWebsocketToken,\n io,\n client,\n websocketEndpoint.deltaStreamSocketUrl);\n connection.on(\"op\", (documentId, ops: ISequencedDocumentMessage[]) => {\n this.opsReceived(ops);\n });\n // On disconnect with 401/403 error code, we can just clear the joinSession cache as we will again\n // get the auth error on reconnecting and face latency.\n connection.on(\"disconnect\", (error: any) => {\n // Clear the join session refresh timer so that it can be restarted on reconnection.\n this.clearJoinSessionTimer();\n if (typeof error === \"object\" && error !== null\n && error.errorType === DriverErrorType.authorizationError) {\n this.cache.sessionJoinCache.remove(this.joinSessionKey);\n }\n });\n this.currentConnection = connection;\n return connection;\n } catch (error) {\n this.cache.sessionJoinCache.remove(this.joinSessionKey);\n\n const normalizedError = this.annotateConnectionError(\n error,\n \"createDeltaConnection\",\n !requestWebsocketTokenFromJoinSession);\n if (typeof error === \"object\" && error !== null) {\n normalizedError.addTelemetryProperties({socketDocumentId: websocketEndpoint.id});\n }\n throw normalizedError;\n }\n });\n }\n\n private clearJoinSessionTimer() {\n if (this.joinSessionRefreshTimer !== undefined) {\n clearTimeout(this.joinSessionRefreshTimer);\n this.joinSessionRefreshTimer = undefined;\n }\n }\n\n private async scheduleJoinSessionRefresh(delta: number) {\n await new Promise<void>((resolve, reject) => {\n this.joinSessionRefreshTimer = setTimeout(() => {\n getWithRetryForTokenRefresh(async (options) => {\n await this.joinSession(false, options);\n resolve();\n }).catch((error) => {\n reject(error);\n });\n }, delta);\n });\n }\n\n private async joinSession(\n requestSocketToken: boolean,\n options: TokenFetchOptionsEx,\n ) {\n return this.joinSessionCore(requestSocketToken, options).catch((e) => {\n const likelyFacetCodes = e as IFacetCodes;\n if (Array.isArray(likelyFacetCodes.facetCodes)) {\n for (const code of likelyFacetCodes.facetCodes) {\n switch (code) {\n case \"sessionForbiddenOnPreservedFiles\":\n case \"sessionForbiddenOnModerationEnabledLibrary\":\n case \"sessionForbiddenOnRequireCheckout\":\n // This document can only be opened in storage-only mode.\n // DeltaManager will recognize this error\n // and load without a delta stream connection.\n this._policies = {...this._policies,storageOnly: true};\n throw new DeltaStreamConnectionForbiddenError(code, { driverVersion });\n default:\n continue;\n }\n }\n }\n throw e;\n });\n }\n\n private async joinSessionCore(\n requestSocketToken: boolean,\n options: TokenFetchOptionsEx,\n ): Promise<ISocketStorageDiscovery> {\n const disableJoinSessionRefresh = this.mc.config.getBoolean(\"Fluid.Driver.Odsp.disableJoinSessionRefresh\");\n const executeFetch = async () => {\n const joinSessionResponse = await fetchJoinSession(\n this.odspResolvedUrl,\n \"opStream/joinSession\",\n \"POST\",\n this.mc.logger,\n this.getStorageToken,\n this.epochTracker,\n requestSocketToken,\n options,\n disableJoinSessionRefresh,\n this.hostPolicy.sessionOptions?.unauthenticatedUserDisplayName,\n );\n return {\n entryTime: Date.now(),\n joinSessionResponse,\n };\n };\n\n const getResponseAndRefreshAfterDeltaMs = async () => {\n const _response = await this.cache.sessionJoinCache.addOrGet(this.joinSessionKey, executeFetch);\n // If the response does not contain refreshSessionDurationSeconds, then treat it as old flow and let the\n // cache entry to be treated as expired after 1 hour.\n _response.joinSessionResponse.refreshSessionDurationSeconds =\n _response.joinSessionResponse.refreshSessionDurationSeconds ?? 3600;\n return {\n ..._response,\n refreshAfterDeltaMs: this.calculateJoinSessionRefreshDelta(\n _response.entryTime, _response.joinSessionResponse.refreshSessionDurationSeconds),\n };\n };\n let response = await getResponseAndRefreshAfterDeltaMs();\n // This means that the cached entry has expired(This should not be possible if the response is fetched\n // from the network call). In this case we remove the cached entry and fetch the new response.\n if (response.refreshAfterDeltaMs <= 0) {\n this.cache.sessionJoinCache.remove(this.joinSessionKey);\n response = await getResponseAndRefreshAfterDeltaMs();\n }\n if (!disableJoinSessionRefresh) {\n const props = {\n entryTime: response.entryTime,\n refreshSessionDurationSeconds:\n response.joinSessionResponse.refreshSessionDurationSeconds,\n refreshAfterDeltaMs: response.refreshAfterDeltaMs,\n };\n if (response.refreshAfterDeltaMs > 0) {\n this.scheduleJoinSessionRefresh(response.refreshAfterDeltaMs)\n .catch((error) => {\n this.mc.logger.sendErrorEvent({\n eventName: \"JoinSessionRefreshError\",\n details: JSON.stringify(props),\n },\n error,\n );\n });\n } else {\n // Logging just for informational purposes to help with debugging as this is a new feature.\n this.mc.logger.sendTelemetryEvent({\n eventName: \"JoinSessionRefreshNotScheduled\",\n details: JSON.stringify(props),\n });\n }\n }\n return response.joinSessionResponse;\n }\n\n private calculateJoinSessionRefreshDelta(responseFetchTime: number, refreshSessionDurationSeconds: number) {\n // 30 seconds is buffer time to refresh the session.\n return responseFetchTime + ((refreshSessionDurationSeconds * 1000) - 30000) - Date.now();\n }\n\n /**\n * Creats a connection to the given delta stream endpoint\n *\n * @param tenantId - the ID of the tenant\n * @param documentId - document ID\n * @param token - authorization token for delta service\n * @param io - websocket library\n * @param client - information about the client\n * @param webSocketUrl - websocket URL\n */\n private async createDeltaConnection(\n tenantId: string,\n documentId: string,\n token: string | null,\n io: typeof SocketIOClientStatic,\n client: IClient,\n webSocketUrl: string,\n ): Promise<OdspDocumentDeltaConnection> {\n const startTime = performance.now();\n const connection = await OdspDocumentDeltaConnection.create(\n tenantId,\n documentId,\n token,\n io,\n client,\n webSocketUrl,\n this.mc.logger,\n 60000,\n this.epochTracker,\n this.socketReferenceKeyPrefix,\n );\n const duration = performance.now() - startTime;\n // This event happens rather often, so it adds up to cost of telemetry.\n // Given that most reconnects result in reusing socket and happen very quickly,\n // report event only if it took longer than threshold.\n if (duration >= 2000) {\n this.mc.logger.sendPerformanceEvent({\n eventName: \"ConnectionSuccess\",\n duration,\n });\n }\n return connection;\n }\n\n public dispose(error?: any) {\n // Error might indicate mismatch between client & server knowlege about file\n // (DriverErrorType.fileOverwrittenInStorage).\n // For example, file might have been overwritten in storage without generating new epoch\n // In such case client cached info is stale and has to be removed.\n if (error !== undefined) {\n this.epochTracker.removeEntries().catch(() => {});\n } else {\n this._opsCache?.flushOps();\n }\n this._opsCache?.dispose();\n }\n\n protected get opsCache() {\n if (this._opsCache) {\n return this._opsCache;\n }\n\n const seqNumber = this.storageManager?.snapshotSequenceNumber;\n const batchSize = this.hostPolicy.opsCaching?.batchSize ?? 100;\n if (seqNumber === undefined || batchSize < 1) {\n return;\n }\n\n const opsKey: Omit<IEntry, \"key\"> = {\n type: \"ops\",\n };\n this._opsCache = new OpsCache(\n seqNumber,\n this.mc.logger,\n // ICache\n {\n write: async (key: string, opsData: string) => {\n return this.cache.persistedCache.put({...opsKey, key}, opsData);\n },\n read: async (key: string) => this.cache.persistedCache.get({...opsKey, key}),\n remove: () => { this.cache.persistedCache.removeEntries().catch(() => {}); },\n },\n batchSize,\n this.hostPolicy.opsCaching?.timerGranularity ?? 5000,\n this.hostPolicy.opsCaching?.totalOpsToCache ?? 5000,\n );\n return this._opsCache;\n }\n\n // Called whenever re receive ops through any channel for this document (snapshot, delta connection, delta storage)\n // We use it to notify caching layer of how stale is snapshot stored in cache.\n protected opsReceived(ops: ISequencedDocumentMessage[]) {\n // No need for two clients to save same ops\n if (ops.length === 0 || this.odspResolvedUrl.summarizer) {\n return;\n }\n\n this.opsCache?.addOps(ops);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"odspDocumentService.js","sourceRoot":"","sources":["../src/odspDocumentService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+DAA2D;AAC3D,qEAMyC;AACzC,2EAQ4C;AAC5C,+DAAsG;AAMtG,qFAOiD;AAIjD,uEAA+F;AAC/F,+EAA4E;AAC5E,6EAA0E;AAC1E,2CAAmG;AACnG,mCAA2C;AAC3C,mDAA8C;AAE9C,6CAAwC;AACxC,2EAAwE;AACxE,qDAA+D;AAE/D;;;GAGG;AACH,MAAa,mBAAmB;IAwD5B;;;;;;;;;;;;;OAaG;IACH,YACoB,eAAi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,MAAA,MAAA,IAAI,CAAC,UAAU,CAAC,UAAU,0CAAE,eAAe,mCAAI,IAAI,CACtD,CAAC;QACF,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED,mHAAmH;IACnH,8EAA8E;IACpE,WAAW,CAAC,GAAgC;;QAClD,2CAA2C;QAC3C,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE;YACrD,OAAO;SACV;QAED,MAAA,IAAI,CAAC,QAAQ,0CAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC;CACJ;AApeD,kDAoeC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { performance } from \"@fluidframework/common-utils\";\nimport {\n ChildLogger,\n IFluidErrorBase,\n loggerToMonitoringContext,\n MonitoringContext,\n normalizeError,\n} from \"@fluidframework/telemetry-utils\";\nimport {\n IDocumentDeltaConnection,\n IDocumentDeltaStorageService,\n IDocumentService,\n IResolvedUrl,\n IDocumentStorageService,\n IDocumentServicePolicies,\n DriverErrorType,\n} from \"@fluidframework/driver-definitions\";\nimport { DeltaStreamConnectionForbiddenError, NonRetryableError } from \"@fluidframework/driver-utils\";\nimport { IFacetCodes } from \"@fluidframework/odsp-doclib-utils\";\nimport {\n IClient,\n ISequencedDocumentMessage,\n} from \"@fluidframework/protocol-definitions\";\nimport {\n IOdspResolvedUrl,\n TokenFetchOptions,\n IEntry,\n HostStoragePolicy,\n InstrumentedStorageTokenFetcher,\n OdspErrorType,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport type { io as SocketIOClientStatic } from \"socket.io-client\";\nimport { HostStoragePolicyInternal, ISocketStorageDiscovery } from \"./contracts\";\nimport { IOdspCache } from \"./odspCache\";\nimport { OdspDeltaStorageService, OdspDeltaStorageWithCache } from \"./odspDeltaStorageService\";\nimport { OdspDocumentDeltaConnection } from \"./odspDocumentDeltaConnection\";\nimport { OdspDocumentStorageService } from \"./odspDocumentStorageManager\";\nimport { getWithRetryForTokenRefresh, getOdspResolvedUrl, TokenFetchOptionsEx } from \"./odspUtils\";\nimport { fetchJoinSession } from \"./vroom\";\nimport { isOdcOrigin } from \"./odspUrlHelper\";\nimport { EpochTracker } from \"./epochTracker\";\nimport { OpsCache } from \"./opsCaching\";\nimport { RetryErrorsStorageAdapter } from \"./retryErrorsStorageAdapter\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\n\n/**\n * The DocumentService manages the Socket.IO connection and manages routing requests to connected\n * clients\n */\nexport class OdspDocumentService implements IDocumentService {\n private _policies: IDocumentServicePolicies;\n // Timer which runs and executes the join session call after intervals.\n private joinSessionRefreshTimer: ReturnType<typeof setTimeout> | undefined;\n /**\n * @param resolvedUrl - resolved url identifying document that will be managed by returned service instance.\n * @param getStorageToken - function that can provide the storage token. This is is also referred to as\n * the \"Vroom\" token in SPO.\n * @param getWebsocketToken - function that can provide a token for accessing the web socket. This is also referred\n * to as the \"Push\" token in SPO. If undefined then websocket token is expected to be returned with joinSession\n * response payload.\n * @param logger - a logger that can capture performance and diagnostic information\n * @param socketIoClientFactory - A factory that returns a promise to the socket io library required by the driver\n * @param cache - This caches response for joinSession.\n * @param hostPolicy - This host constructed policy which customizes service behavior.\n * @param epochTracker - This helper class which adds epoch to backend calls made by returned service instance.\n * @param socketReferenceKeyPrefix - (optional) prefix to isolate socket reuse cache\n */\n public static async create(\n resolvedUrl: IResolvedUrl,\n getStorageToken: InstrumentedStorageTokenFetcher,\n getWebsocketToken: ((options: TokenFetchOptions) => Promise<string | null>) | undefined,\n logger: ITelemetryLogger,\n socketIoClientFactory: () => Promise<typeof SocketIOClientStatic>,\n cache: IOdspCache,\n hostPolicy: HostStoragePolicy,\n epochTracker: EpochTracker,\n socketReferenceKeyPrefix?: string,\n clientIsSummarizer?: boolean,\n ): Promise<IDocumentService> {\n return new OdspDocumentService(\n getOdspResolvedUrl(resolvedUrl),\n getStorageToken,\n getWebsocketToken,\n logger,\n socketIoClientFactory,\n cache,\n hostPolicy,\n epochTracker,\n socketReferenceKeyPrefix,\n clientIsSummarizer,\n );\n }\n\n private storageManager?: OdspDocumentStorageService;\n\n private readonly mc: MonitoringContext;\n\n private readonly joinSessionKey: string;\n\n private readonly hostPolicy: HostStoragePolicyInternal;\n\n private _opsCache?: OpsCache;\n\n private currentConnection?: OdspDocumentDeltaConnection;\n\n /**\n * @param odspResolvedUrl - resolved url identifying document that will be managed by this service instance.\n * @param getStorageToken - function that can provide the storage token. This is is also referred to as\n * the \"Vroom\" token in SPO.\n * @param getWebsocketToken - function that can provide a token for accessing the web socket. This is also referred\n * to as the \"Push\" token in SPO. If undefined then websocket token is expected to be returned with joinSession\n * response payload.\n * @param logger - a logger that can capture performance and diagnostic information\n * @param socketIoClientFactory - A factory that returns a promise to the socket io library required by the driver\n * @param cache - This caches response for joinSession.\n * @param hostPolicy - host constructed policy which customizes service behavior.\n * @param epochTracker - This helper class which adds epoch to backend calls made by this service instance.\n * @param socketReferenceKeyPrefix - (optional) prefix to isolate socket reuse cache\n */\n private constructor(\n public readonly odspResolvedUrl: IOdspResolvedUrl,\n private readonly getStorageToken: InstrumentedStorageTokenFetcher,\n private readonly getWebsocketToken: ((options: TokenFetchOptions) => Promise<string | null>) | undefined,\n logger: ITelemetryLogger,\n private readonly socketIoClientFactory: () => Promise<typeof SocketIOClientStatic>,\n private readonly cache: IOdspCache,\n hostPolicy: HostStoragePolicy,\n private readonly epochTracker: EpochTracker,\n private readonly socketReferenceKeyPrefix?: string,\n private readonly clientIsSummarizer?: boolean,\n ) {\n this._policies = {\n // load in storage-only mode if a file version is specified\n storageOnly: odspResolvedUrl.fileVersion !== undefined,\n };\n\n this.joinSessionKey = `${this.odspResolvedUrl.hashedDocumentId}/joinsession`;\n this.mc = loggerToMonitoringContext(\n ChildLogger.create(logger,\n undefined,\n {\n all: {\n odc: isOdcOrigin(new URL(this.odspResolvedUrl.endpoints.snapshotStorageUrl).origin),\n },\n }));\n\n this.hostPolicy = hostPolicy;\n if (this.clientIsSummarizer) {\n this.hostPolicy = { ...this.hostPolicy, summarizerClient: true };\n }\n }\n\n public get resolvedUrl(): IResolvedUrl {\n return this.odspResolvedUrl;\n }\n public get policies() {\n return this._policies;\n }\n\n /**\n * Connects to a storage endpoint for snapshot service.\n *\n * @returns returns the document storage service for sharepoint driver.\n */\n public async connectToStorage(): Promise<IDocumentStorageService> {\n if (!this.storageManager) {\n this.storageManager = new OdspDocumentStorageService(\n this.odspResolvedUrl,\n this.getStorageToken,\n this.mc.logger,\n true,\n this.cache,\n this.hostPolicy,\n this.epochTracker,\n // flushCallback\n async () => {\n if (this.currentConnection !== undefined && !this.currentConnection.disposed) {\n return this.currentConnection.flush();\n }\n throw new Error(\"Disconnected while uploading summary (attempt to perform flush())\");\n },\n this.mc.config.getNumber(\"Fluid.Driver.Odsp.snapshotFormatFetchType\"),\n );\n }\n\n return new RetryErrorsStorageAdapter(this.storageManager, this.mc.logger);\n }\n\n /**\n * Connects to a delta storage endpoint for getting ops between a range.\n *\n * @returns returns the document delta storage service for sharepoint driver.\n */\n public async connectToDeltaStorage(): Promise<IDocumentDeltaStorageService> {\n const snapshotOps = this.storageManager?.ops ?? [];\n const service = new OdspDeltaStorageService(\n this.odspResolvedUrl.endpoints.deltaStorageUrl,\n this.getStorageToken,\n this.epochTracker,\n this.mc.logger,\n );\n\n // batch size, please see issue #5211 for data around batch sizing\n const batchSize = this.hostPolicy.opsBatchSize ?? 5000;\n const concurrency = this.hostPolicy.concurrentOpsBatches ?? 1;\n return new OdspDeltaStorageWithCache(\n snapshotOps,\n this.mc.logger,\n batchSize,\n concurrency,\n async (from, to, telemetryProps, fetchReason) => service.get(from, to, telemetryProps, fetchReason),\n async (from, to) => {\n const res = await this.opsCache?.get(from, to);\n return res as ISequencedDocumentMessage[] ?? [];\n },\n (from, to) => {\n if (this.currentConnection !== undefined && !this.currentConnection.disposed) {\n this.currentConnection.requestOps(from, to);\n }\n },\n (ops: ISequencedDocumentMessage[]) => this.opsReceived(ops),\n );\n }\n\n /** Annotate the given error indicating which connection step failed */\n private annotateConnectionError(\n error: any,\n failedConnectionStep: string,\n separateTokenRequest: boolean,\n ): IFluidErrorBase {\n return normalizeError(error, { props: {\n failedConnectionStep,\n separateTokenRequest,\n } });\n }\n\n /**\n * Connects to a delta stream endpoint for emitting ops.\n *\n * @returns returns the document delta stream service for onedrive/sharepoint driver.\n */\n public async connectToDeltaStream(client: IClient): Promise<IDocumentDeltaConnection> {\n // Attempt to connect twice, in case we used expired token.\n return getWithRetryForTokenRefresh<IDocumentDeltaConnection>(async (options) => {\n // Presence of getWebsocketToken callback dictates whether callback is used for fetching\n // websocket token or whether it is returned with joinSession response payload\n const requestWebsocketTokenFromJoinSession = this.getWebsocketToken === undefined;\n const websocketTokenPromise = requestWebsocketTokenFromJoinSession\n ? Promise.resolve(null)\n : this.getWebsocketToken!(options);\n\n const annotateAndRethrowConnectionError = (step: string) => (error: any) => {\n throw this.annotateConnectionError(error, step, !requestWebsocketTokenFromJoinSession);\n };\n\n const joinSessionPromise = this.joinSession(requestWebsocketTokenFromJoinSession, options);\n const [websocketEndpoint, websocketToken, io] =\n await Promise.all([\n joinSessionPromise.catch(annotateAndRethrowConnectionError(\"joinSession\")),\n websocketTokenPromise.catch(annotateAndRethrowConnectionError(\"getWebsocketToken\")),\n this.socketIoClientFactory().catch(annotateAndRethrowConnectionError(\"socketIoClientFactory\")),\n ]);\n\n const finalWebsocketToken = websocketToken ?? (websocketEndpoint.socketToken || null);\n if (finalWebsocketToken === null) {\n throw this.annotateConnectionError(\n new NonRetryableError(\n \"Websocket token is null\",\n OdspErrorType.fetchTokenError,\n { driverVersion },\n ),\n \"getWebsocketToken\",\n !requestWebsocketTokenFromJoinSession);\n }\n try {\n const connection = await this.createDeltaConnection(\n websocketEndpoint.tenantId,\n websocketEndpoint.id,\n finalWebsocketToken,\n io,\n client,\n websocketEndpoint.deltaStreamSocketUrl);\n connection.on(\"op\", (documentId, ops: ISequencedDocumentMessage[]) => {\n this.opsReceived(ops);\n });\n // On disconnect with 401/403 error code, we can just clear the joinSession cache as we will again\n // get the auth error on reconnecting and face latency.\n connection.on(\"disconnect\", (error: any) => {\n // Clear the join session refresh timer so that it can be restarted on reconnection.\n this.clearJoinSessionTimer();\n if (typeof error === \"object\" && error !== null\n && error.errorType === DriverErrorType.authorizationError) {\n this.cache.sessionJoinCache.remove(this.joinSessionKey);\n }\n });\n this.currentConnection = connection;\n return connection;\n } catch (error) {\n this.cache.sessionJoinCache.remove(this.joinSessionKey);\n\n const normalizedError = this.annotateConnectionError(\n error,\n \"createDeltaConnection\",\n !requestWebsocketTokenFromJoinSession);\n if (typeof error === \"object\" && error !== null) {\n normalizedError.addTelemetryProperties({ socketDocumentId: websocketEndpoint.id });\n }\n throw normalizedError;\n }\n });\n }\n\n private clearJoinSessionTimer() {\n if (this.joinSessionRefreshTimer !== undefined) {\n clearTimeout(this.joinSessionRefreshTimer);\n this.joinSessionRefreshTimer = undefined;\n }\n }\n\n private async scheduleJoinSessionRefresh(delta: number) {\n await new Promise<void>((resolve, reject) => {\n this.joinSessionRefreshTimer = setTimeout(() => {\n getWithRetryForTokenRefresh(async (options) => {\n await this.joinSession(false, options);\n resolve();\n }).catch((error) => {\n reject(error);\n });\n }, delta);\n });\n }\n\n private async joinSession(\n requestSocketToken: boolean,\n options: TokenFetchOptionsEx,\n ) {\n return this.joinSessionCore(requestSocketToken, options).catch((e) => {\n const likelyFacetCodes = e as IFacetCodes;\n if (Array.isArray(likelyFacetCodes.facetCodes)) {\n for (const code of likelyFacetCodes.facetCodes) {\n switch (code) {\n case \"sessionForbiddenOnPreservedFiles\":\n case \"sessionForbiddenOnModerationEnabledLibrary\":\n case \"sessionForbiddenOnRequireCheckout\":\n // This document can only be opened in storage-only mode.\n // DeltaManager will recognize this error\n // and load without a delta stream connection.\n this._policies = { ...this._policies, storageOnly: true };\n throw new DeltaStreamConnectionForbiddenError(code, { driverVersion });\n default:\n continue;\n }\n }\n }\n throw e;\n });\n }\n\n private async joinSessionCore(\n requestSocketToken: boolean,\n options: TokenFetchOptionsEx,\n ): Promise<ISocketStorageDiscovery> {\n const disableJoinSessionRefresh = this.mc.config.getBoolean(\"Fluid.Driver.Odsp.disableJoinSessionRefresh\");\n const executeFetch = async () => {\n const joinSessionResponse = await fetchJoinSession(\n this.odspResolvedUrl,\n \"opStream/joinSession\",\n \"POST\",\n this.mc.logger,\n this.getStorageToken,\n this.epochTracker,\n requestSocketToken,\n options,\n disableJoinSessionRefresh,\n this.hostPolicy.sessionOptions?.unauthenticatedUserDisplayName,\n );\n return {\n entryTime: Date.now(),\n joinSessionResponse,\n };\n };\n\n const getResponseAndRefreshAfterDeltaMs = async () => {\n const _response = await this.cache.sessionJoinCache.addOrGet(this.joinSessionKey, executeFetch);\n // If the response does not contain refreshSessionDurationSeconds, then treat it as old flow and let the\n // cache entry to be treated as expired after 1 hour.\n _response.joinSessionResponse.refreshSessionDurationSeconds =\n _response.joinSessionResponse.refreshSessionDurationSeconds ?? 3600;\n return {\n ..._response,\n refreshAfterDeltaMs: this.calculateJoinSessionRefreshDelta(\n _response.entryTime, _response.joinSessionResponse.refreshSessionDurationSeconds),\n };\n };\n let response = await getResponseAndRefreshAfterDeltaMs();\n // This means that the cached entry has expired(This should not be possible if the response is fetched\n // from the network call). In this case we remove the cached entry and fetch the new response.\n if (response.refreshAfterDeltaMs <= 0) {\n this.cache.sessionJoinCache.remove(this.joinSessionKey);\n response = await getResponseAndRefreshAfterDeltaMs();\n }\n if (!disableJoinSessionRefresh) {\n const props = {\n entryTime: response.entryTime,\n refreshSessionDurationSeconds:\n response.joinSessionResponse.refreshSessionDurationSeconds,\n refreshAfterDeltaMs: response.refreshAfterDeltaMs,\n };\n if (response.refreshAfterDeltaMs > 0) {\n this.scheduleJoinSessionRefresh(response.refreshAfterDeltaMs)\n .catch((error) => {\n this.mc.logger.sendErrorEvent({\n eventName: \"JoinSessionRefreshError\",\n details: JSON.stringify(props),\n },\n error,\n );\n });\n } else {\n // Logging just for informational purposes to help with debugging as this is a new feature.\n this.mc.logger.sendTelemetryEvent({\n eventName: \"JoinSessionRefreshNotScheduled\",\n details: JSON.stringify(props),\n });\n }\n }\n return response.joinSessionResponse;\n }\n\n private calculateJoinSessionRefreshDelta(responseFetchTime: number, refreshSessionDurationSeconds: number) {\n // 30 seconds is buffer time to refresh the session.\n return responseFetchTime + ((refreshSessionDurationSeconds * 1000) - 30000) - Date.now();\n }\n\n /**\n * Creats a connection to the given delta stream endpoint\n *\n * @param tenantId - the ID of the tenant\n * @param documentId - document ID\n * @param token - authorization token for delta service\n * @param io - websocket library\n * @param client - information about the client\n * @param webSocketUrl - websocket URL\n */\n private async createDeltaConnection(\n tenantId: string,\n documentId: string,\n token: string | null,\n io: typeof SocketIOClientStatic,\n client: IClient,\n webSocketUrl: string,\n ): Promise<OdspDocumentDeltaConnection> {\n const startTime = performance.now();\n const connection = await OdspDocumentDeltaConnection.create(\n tenantId,\n documentId,\n token,\n io,\n client,\n webSocketUrl,\n this.mc.logger,\n 60000,\n this.epochTracker,\n this.socketReferenceKeyPrefix,\n );\n const duration = performance.now() - startTime;\n // This event happens rather often, so it adds up to cost of telemetry.\n // Given that most reconnects result in reusing socket and happen very quickly,\n // report event only if it took longer than threshold.\n if (duration >= 2000) {\n this.mc.logger.sendPerformanceEvent({\n eventName: \"ConnectionSuccess\",\n duration,\n });\n }\n return connection;\n }\n\n public dispose(error?: any) {\n // Error might indicate mismatch between client & server knowlege about file\n // (DriverErrorType.fileOverwrittenInStorage).\n // For example, file might have been overwritten in storage without generating new epoch\n // In such case client cached info is stale and has to be removed.\n if (error !== undefined) {\n this.epochTracker.removeEntries().catch(() => {});\n } else {\n this._opsCache?.flushOps();\n }\n this._opsCache?.dispose();\n }\n\n protected get opsCache() {\n if (this._opsCache) {\n return this._opsCache;\n }\n\n const seqNumber = this.storageManager?.snapshotSequenceNumber;\n const batchSize = this.hostPolicy.opsCaching?.batchSize ?? 100;\n if (seqNumber === undefined || batchSize < 1) {\n return;\n }\n\n const opsKey: Omit<IEntry, \"key\"> = {\n type: \"ops\",\n };\n this._opsCache = new OpsCache(\n seqNumber,\n this.mc.logger,\n // ICache\n {\n write: async (key: string, opsData: string) => {\n return this.cache.persistedCache.put({ ...opsKey, key }, opsData);\n },\n read: async (key: string) => this.cache.persistedCache.get({ ...opsKey, key }),\n remove: () => { this.cache.persistedCache.removeEntries().catch(() => {}); },\n },\n batchSize,\n this.hostPolicy.opsCaching?.timerGranularity ?? 5000,\n this.hostPolicy.opsCaching?.totalOpsToCache ?? 5000,\n );\n return this._opsCache;\n }\n\n // Called whenever re receive ops through any channel for this document (snapshot, delta connection, delta storage)\n // We use it to notify caching layer of how stale is snapshot stored in cache.\n protected opsReceived(ops: ISequencedDocumentMessage[]) {\n // No need for two clients to save same ops\n if (ops.length === 0 || this.odspResolvedUrl.summarizer) {\n return;\n }\n\n this.opsCache?.addOps(ops);\n }\n}\n"]}
|
|
@@ -13,7 +13,7 @@ const getSocketIo_1 = require("./getSocketIo");
|
|
|
13
13
|
*/
|
|
14
14
|
class OdspDocumentServiceFactory extends odspDocumentServiceFactoryCore_1.OdspDocumentServiceFactoryCore {
|
|
15
15
|
constructor(getStorageToken, getWebsocketToken, persistedCache, hostPolicy) {
|
|
16
|
-
super(getStorageToken, getWebsocketToken, async () => getSocketIo_1.getSocketIo(), persistedCache, hostPolicy);
|
|
16
|
+
super(getStorageToken, getWebsocketToken, async () => (0, getSocketIo_1.getSocketIo)(), persistedCache, hostPolicy);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
exports.OdspDocumentServiceFactory = OdspDocumentServiceFactory;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspDocumentServiceFactory.js","sourceRoot":"","sources":["../src/odspDocumentServiceFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AASH,qFAAkF;AAClF,+CAA4C;AAE5C;;;GAGG;AACH,MAAa,0BACT,SAAQ,+DAA8B;IAEtC,YACI,eAA4D,EAC5D,iBAA0E,EAC1E,cAAgC,EAChC,UAA8B;QAE9B,KAAK,CACD,eAAe,EACf,iBAAiB,EACjB,KAAK,IAAI,EAAE,CAAC,yBAAW,
|
|
1
|
+
{"version":3,"file":"odspDocumentServiceFactory.js","sourceRoot":"","sources":["../src/odspDocumentServiceFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AASH,qFAAkF;AAClF,+CAA4C;AAE5C;;;GAGG;AACH,MAAa,0BACT,SAAQ,+DAA8B;IAEtC,YACI,eAA4D,EAC5D,iBAA0E,EAC1E,cAAgC,EAChC,UAA8B;QAE9B,KAAK,CACD,eAAe,EACf,iBAAiB,EACjB,KAAK,IAAI,EAAE,CAAC,IAAA,yBAAW,GAAE,EACzB,cAAc,EACd,UAAU,CACb,CAAC;IACN,CAAC;CACJ;AAjBD,gEAiBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDocumentServiceFactory } from \"@fluidframework/driver-definitions\";\nimport {\n OdspResourceTokenFetchOptions,\n TokenFetcher,\n IPersistedCache,\n HostStoragePolicy,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { OdspDocumentServiceFactoryCore } from \"./odspDocumentServiceFactoryCore\";\nimport { getSocketIo } from \"./getSocketIo\";\n\n/**\n * Factory for creating the sharepoint document service. Use this if you want to\n * use the sharepoint implementation.\n */\nexport class OdspDocumentServiceFactory\n extends OdspDocumentServiceFactoryCore\n implements IDocumentServiceFactory {\n constructor(\n getStorageToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n getWebsocketToken: TokenFetcher<OdspResourceTokenFetchOptions> | undefined,\n persistedCache?: IPersistedCache,\n hostPolicy?: HostStoragePolicy,\n ) {\n super(\n getStorageToken,\n getWebsocketToken,\n async () => getSocketIo(),\n persistedCache,\n hostPolicy,\n );\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspDocumentServiceFactoryCore.d.ts","sourceRoot":"","sources":["../src/odspDocumentServiceFactoryCore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EACH,gBAAgB,EAChB,uBAAuB,EACvB,YAAY,EACf,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"odspDocumentServiceFactoryCore.d.ts","sourceRoot":"","sources":["../src/odspDocumentServiceFactoryCore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EACH,gBAAgB,EAChB,uBAAuB,EACvB,YAAY,EACf,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AASpE,OAAO,EAEH,6BAA6B,EAC7B,YAAY,EACZ,eAAe,EACf,iBAAiB,EAGpB,MAAM,yCAAyC,CAAC;AACjD,OAAO,KAAK,EAAE,EAAE,IAAI,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAcnE;;;;;;GAMG;AACH,qBAAa,8BAA+B,YAAW,uBAAuB;IAkGtE,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAClC,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAClC,SAAS,CAAC,cAAc,EAAE,eAAe;IACzC,OAAO,CAAC,QAAQ,CAAC,UAAU;IArG/B,SAAgB,YAAY,iBAAiB;IAE7C,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAA4B;IAC/D,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAAC,CAAS;IAEtC,eAAe,CACxB,gBAAgB,EAAE,YAAY,GAAG,SAAS,EAC1C,oBAAoB,EAAE,YAAY,EAClC,MAAM,CAAC,EAAE,oBAAoB,EAC7B,kBAAkB,CAAC,EAAE,OAAO,GAC7B,OAAO,CAAC,gBAAgB,CAAC;IA4E5B;;;;;;;;;OASG;gBAEkB,eAAe,EAAE,YAAY,CAAC,6BAA6B,CAAC,EAC5D,iBAAiB,EAAE,YAAY,CAAC,6BAA6B,CAAC,GAAG,SAAS,EAC1E,iBAAiB,EAAE,MAAM,OAAO,CAAC,OAAO,oBAAoB,CAAC,EACpE,cAAc,GAAE,eAA4C,EACrD,UAAU,GAAE,iBAAsB;IAQ1C,qBAAqB,CAC9B,WAAW,EAAE,YAAY,EACzB,MAAM,CAAC,EAAE,oBAAoB,EAC7B,kBAAkB,CAAC,EAAE,OAAO,GAC7B,OAAO,CAAC,gBAAgB,CAAC;YAId,yBAAyB;CA+C1C"}
|
|
@@ -41,13 +41,13 @@ class OdspDocumentServiceFactoryCore {
|
|
|
41
41
|
this.nonPersistentCache = new odspCache_1.NonPersistentCache();
|
|
42
42
|
if (this.hostPolicy.isolateSocketCache === true) {
|
|
43
43
|
// create the key to separate the socket reuse cache
|
|
44
|
-
this.socketReferenceKeyPrefix = uuid_1.v4();
|
|
44
|
+
this.socketReferenceKeyPrefix = (0, uuid_1.v4)();
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
async createContainer(createNewSummary, createNewResolvedUrl, logger, clientIsSummarizer) {
|
|
48
48
|
var _a, _b;
|
|
49
|
-
driver_utils_1.ensureFluidResolvedUrl(createNewResolvedUrl);
|
|
50
|
-
let odspResolvedUrl = odspUtils_1.getOdspResolvedUrl(createNewResolvedUrl);
|
|
49
|
+
(0, driver_utils_1.ensureFluidResolvedUrl)(createNewResolvedUrl);
|
|
50
|
+
let odspResolvedUrl = (0, odspUtils_1.getOdspResolvedUrl)(createNewResolvedUrl);
|
|
51
51
|
const resolvedUrlData = {
|
|
52
52
|
siteUrl: odspResolvedUrl.siteUrl,
|
|
53
53
|
driveId: odspResolvedUrl.driveId,
|
|
@@ -59,6 +59,13 @@ class OdspDocumentServiceFactoryCore {
|
|
|
59
59
|
if (filePath === undefined || filePath === null) {
|
|
60
60
|
throw new Error("File path should be provided!!");
|
|
61
61
|
}
|
|
62
|
+
const protocolSummary = createNewSummary === null || createNewSummary === void 0 ? void 0 : createNewSummary.tree[".protocol"];
|
|
63
|
+
if (protocolSummary) {
|
|
64
|
+
const documentAttributes = (0, driver_utils_1.getDocAttributesFromProtocolSummary)(protocolSummary);
|
|
65
|
+
if ((documentAttributes === null || documentAttributes === void 0 ? void 0 : documentAttributes.sequenceNumber) !== 0) {
|
|
66
|
+
throw new Error("Seq number in detached ODSP container should be 0");
|
|
67
|
+
}
|
|
68
|
+
}
|
|
62
69
|
const newFileInfo = {
|
|
63
70
|
driveId: odspResolvedUrl.driveId,
|
|
64
71
|
siteUrl: odspResolvedUrl.siteUrl,
|
|
@@ -66,17 +73,18 @@ class OdspDocumentServiceFactoryCore {
|
|
|
66
73
|
filename: odspResolvedUrl.fileName,
|
|
67
74
|
// set createLinkType to undefined if enableShareLinkWithCreate is set to false,
|
|
68
75
|
// so that share link creation with create file can be enabled
|
|
69
|
-
createLinkType: this.hostPolicy.enableShareLinkWithCreate ?
|
|
76
|
+
createLinkType: this.hostPolicy.enableShareLinkWithCreate ?
|
|
77
|
+
(_b = (_a = odspResolvedUrl.shareLinkInfo) === null || _a === void 0 ? void 0 : _a.createLink) === null || _b === void 0 ? void 0 : _b.type : undefined,
|
|
70
78
|
};
|
|
71
|
-
const odspLogger = odspUtils_1.createOdspLogger(logger);
|
|
79
|
+
const odspLogger = (0, odspUtils_1.createOdspLogger)(logger);
|
|
72
80
|
const fileEntry = { resolvedUrl: odspResolvedUrl, docId: odspResolvedUrl.hashedDocumentId };
|
|
73
|
-
const cacheAndTracker = epochTracker_1.createOdspCacheAndTracker(this.persistedCache, this.nonPersistentCache, fileEntry, odspLogger);
|
|
81
|
+
const cacheAndTracker = (0, epochTracker_1.createOdspCacheAndTracker)(this.persistedCache, this.nonPersistentCache, fileEntry, odspLogger);
|
|
74
82
|
return telemetry_utils_1.PerformanceEvent.timedExecAsync(odspLogger, {
|
|
75
83
|
eventName: "CreateNew",
|
|
76
84
|
isWithSummaryUpload: true,
|
|
77
85
|
}, async (event) => {
|
|
78
86
|
var _a, _b;
|
|
79
|
-
odspResolvedUrl = await createFile_1.createNewFluidFile(odspUtils_1.toInstrumentedOdspTokenFetcher(odspLogger, resolvedUrlData, this.getStorageToken, true /* throwOnNullToken */), newFileInfo, odspLogger, createNewSummary, cacheAndTracker.epochTracker, fileEntry, (_a = this.hostPolicy.cacheCreateNewSummary) !== null && _a !== void 0 ? _a : true, !!((_b = this.hostPolicy.sessionOptions) === null || _b === void 0 ? void 0 : _b.forceAccessTokenViaAuthorizationHeader));
|
|
87
|
+
odspResolvedUrl = await (0, createFile_1.createNewFluidFile)((0, odspUtils_1.toInstrumentedOdspTokenFetcher)(odspLogger, resolvedUrlData, this.getStorageToken, true /* throwOnNullToken */), newFileInfo, odspLogger, createNewSummary, cacheAndTracker.epochTracker, fileEntry, (_a = this.hostPolicy.cacheCreateNewSummary) !== null && _a !== void 0 ? _a : true, !!((_b = this.hostPolicy.sessionOptions) === null || _b === void 0 ? void 0 : _b.forceAccessTokenViaAuthorizationHeader));
|
|
80
88
|
const docService = this.createDocumentServiceCore(odspResolvedUrl, odspLogger, cacheAndTracker, clientIsSummarizer);
|
|
81
89
|
event.end({
|
|
82
90
|
docId: odspResolvedUrl.hashedDocumentId,
|
|
@@ -85,20 +93,20 @@ class OdspDocumentServiceFactoryCore {
|
|
|
85
93
|
});
|
|
86
94
|
}
|
|
87
95
|
async createDocumentService(resolvedUrl, logger, clientIsSummarizer) {
|
|
88
|
-
return this.createDocumentServiceCore(resolvedUrl, odspUtils_1.createOdspLogger(logger), undefined, clientIsSummarizer);
|
|
96
|
+
return this.createDocumentServiceCore(resolvedUrl, (0, odspUtils_1.createOdspLogger)(logger), undefined, clientIsSummarizer);
|
|
89
97
|
}
|
|
90
98
|
async createDocumentServiceCore(resolvedUrl, odspLogger, cacheAndTrackerArg, clientIsSummarizer) {
|
|
91
|
-
const odspResolvedUrl = odspUtils_1.getOdspResolvedUrl(resolvedUrl);
|
|
99
|
+
const odspResolvedUrl = (0, odspUtils_1.getOdspResolvedUrl)(resolvedUrl);
|
|
92
100
|
const resolvedUrlData = {
|
|
93
101
|
siteUrl: odspResolvedUrl.siteUrl,
|
|
94
102
|
driveId: odspResolvedUrl.driveId,
|
|
95
103
|
itemId: odspResolvedUrl.itemId,
|
|
96
104
|
};
|
|
97
|
-
const cacheAndTracker = cacheAndTrackerArg !== null && cacheAndTrackerArg !== void 0 ? cacheAndTrackerArg : epochTracker_1.createOdspCacheAndTracker(this.persistedCache, this.nonPersistentCache, { resolvedUrl: odspResolvedUrl, docId: odspResolvedUrl.hashedDocumentId }, odspLogger);
|
|
98
|
-
const storageTokenFetcher = odspUtils_1.toInstrumentedOdspTokenFetcher(odspLogger, resolvedUrlData, this.getStorageToken, true /* throwOnNullToken */);
|
|
105
|
+
const cacheAndTracker = cacheAndTrackerArg !== null && cacheAndTrackerArg !== void 0 ? cacheAndTrackerArg : (0, epochTracker_1.createOdspCacheAndTracker)(this.persistedCache, this.nonPersistentCache, { resolvedUrl: odspResolvedUrl, docId: odspResolvedUrl.hashedDocumentId }, odspLogger);
|
|
106
|
+
const storageTokenFetcher = (0, odspUtils_1.toInstrumentedOdspTokenFetcher)(odspLogger, resolvedUrlData, this.getStorageToken, true /* throwOnNullToken */);
|
|
99
107
|
const webSocketTokenFetcher = this.getWebsocketToken === undefined
|
|
100
108
|
? undefined
|
|
101
|
-
: async (options) => odspUtils_1.toInstrumentedOdspTokenFetcher(odspLogger, resolvedUrlData, this.getWebsocketToken, false /* throwOnNullToken */)(options, "GetWebsocketToken");
|
|
109
|
+
: async (options) => (0, odspUtils_1.toInstrumentedOdspTokenFetcher)(odspLogger, resolvedUrlData, this.getWebsocketToken, false /* throwOnNullToken */)(options, "GetWebsocketToken");
|
|
102
110
|
return odspDocumentService_1.OdspDocumentService.create(resolvedUrl, storageTokenFetcher, webSocketTokenFetcher, odspLogger, this.getSocketIOClient, cacheAndTracker.cache, this.hostPolicy, cacheAndTracker.epochTracker, this.socketReferenceKeyPrefix, clientIsSummarizer);
|
|
103
111
|
}
|
|
104
112
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspDocumentServiceFactoryCore.js","sourceRoot":"","sources":["../src/odspDocumentServiceFactoryCore.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AASH,qEAGyC;AACzC,+DAAsE;AAWtE,+BAAkC;AAClC,2CAGqB;AACrB,iDAGwB;AACxB,+DAA4D;AAC5D,2CAAiH;AACjH,6CAAkD;AAElD;;;;;;GAMG;AACH,MAAa,8BAA8B;IA8EvC;;;;;;;;;OASG;IACH,YACqB,eAA4D,EAC5D,iBAA0E,EAC1E,iBAA6D,EACpE,iBAAkC,IAAI,gCAAoB,EAAE,EACrD,aAAgC,EAAE;QAJlC,oBAAe,GAAf,eAAe,CAA6C;QAC5D,sBAAiB,GAAjB,iBAAiB,CAAyD;QAC1E,sBAAiB,GAAjB,iBAAiB,CAA4C;QACpE,mBAAc,GAAd,cAAc,CAA8C;QACrD,eAAU,GAAV,UAAU,CAAwB;QA5FvC,iBAAY,GAAG,aAAa,CAAC;QAE5B,uBAAkB,GAAG,IAAI,8BAAkB,EAAE,CAAC;QA4F3D,IAAI,IAAI,CAAC,UAAU,CAAC,kBAAkB,KAAK,IAAI,EAAE;YAC7C,oDAAoD;YACpD,IAAI,CAAC,wBAAwB,GAAG,SAAI,EAAE,CAAC;SAC1C;IACL,CAAC;IA7FM,KAAK,CAAC,eAAe,CACxB,gBAA0C,EAC1C,oBAAkC,EAClC,MAA6B,EAC7B,kBAA4B;;QAE5B,qCAAsB,CAAC,oBAAoB,CAAC,CAAC;QAE7C,IAAI,eAAe,GAAG,8BAAkB,CAAC,oBAAoB,CAAC,CAAC;QAC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e,EAAE,KAAK,EAAE,eAAe,CAAC,gBAAgB,EAAE,EACzE,UAAU,CAAC,CAAC;QAEhB,MAAM,mBAAmB,GAAG,0CAA8B,CACtD,UAAU,EACV,eAAe,EACf,IAAI,CAAC,eAAe,EACpB,IAAI,CAAC,sBAAsB,CAC9B,CAAC;QAEF,MAAM,qBAAqB,GAAG,IAAI,CAAC,iBAAiB,KAAK,SAAS;YAC9D,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,KAAK,EAAE,OAA0B,EAAE,EAAE,CAAC,0CAA8B,CAClE,UAAU,EACV,eAAe,EACf,IAAI,CAAC,iBAAkB,EACvB,KAAK,CAAC,sBAAsB,CAC/B,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAC;QAEpC,OAAO,yCAAmB,CAAC,MAAM,CAC7B,WAAW,EACX,mBAAmB,EACnB,qBAAqB,EACrB,UAAU,EACV,IAAI,CAAC,iBAAiB,EACtB,eAAe,CAAC,KAAK,EACrB,IAAI,CAAC,UAAU,EACf,eAAe,CAAC,YAAY,EAC5B,IAAI,CAAC,wBAAwB,EAC7B,kBAAkB,CACrB,CAAC;IACN,CAAC;CACJ;AA5JD,wEA4JC","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 IDocumentService,\n IDocumentServiceFactory,\n IResolvedUrl,\n} from \"@fluidframework/driver-definitions\";\nimport { ISummaryTree } from \"@fluidframework/protocol-definitions\";\nimport {\n TelemetryLogger,\n PerformanceEvent,\n} from \"@fluidframework/telemetry-utils\";\nimport { ensureFluidResolvedUrl } from \"@fluidframework/driver-utils\";\nimport {\n TokenFetchOptions,\n OdspResourceTokenFetchOptions,\n TokenFetcher,\n IPersistedCache,\n HostStoragePolicy,\n IFileEntry,\n IOdspUrlParts,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport type { io as SocketIOClientStatic } from \"socket.io-client\";\nimport { v4 as uuid } from \"uuid\";\nimport {\n LocalPersistentCache,\n NonPersistentCache,\n} from \"./odspCache\";\nimport {\n createOdspCacheAndTracker,\n ICacheAndTracker,\n} from \"./epochTracker\";\nimport { OdspDocumentService } from \"./odspDocumentService\";\nimport { INewFileInfo, getOdspResolvedUrl, createOdspLogger, toInstrumentedOdspTokenFetcher } from \"./odspUtils\";\nimport { createNewFluidFile } from \"./createFile\";\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 public readonly protocolName = \"fluid-odsp:\";\n\n private readonly nonPersistentCache = new NonPersistentCache();\n private readonly socketReferenceKeyPrefix?: string;\n\n public async createContainer(\n createNewSummary: ISummaryTree | undefined,\n createNewResolvedUrl: IResolvedUrl,\n logger?: ITelemetryBaseLogger,\n clientIsSummarizer?: boolean,\n ): Promise<IDocumentService> {\n ensureFluidResolvedUrl(createNewResolvedUrl);\n\n let odspResolvedUrl = getOdspResolvedUrl(createNewResolvedUrl);\n const resolvedUrlData: IOdspUrlParts = {\n siteUrl: odspResolvedUrl.siteUrl,\n driveId: odspResolvedUrl.driveId,\n itemId: odspResolvedUrl.itemId,\n };\n const [, queryString] = odspResolvedUrl.url.split(\"?\");\n\n const searchParams = new URLSearchParams(queryString);\n const filePath = searchParams.get(\"path\");\n if (filePath === undefined || filePath === null) {\n throw new Error(\"File path should be provided!!\");\n }\n const newFileInfo: INewFileInfo = {\n driveId: odspResolvedUrl.driveId,\n siteUrl: odspResolvedUrl.siteUrl,\n filePath,\n filename: odspResolvedUrl.fileName,\n // set createLinkType to undefined if enableShareLinkWithCreate is set to false,\n // so that share link creation with create file can be enabled\n createLinkType: this.hostPolicy.enableShareLinkWithCreate ?\n odspResolvedUrl.shareLinkInfo?.createLink?.type : undefined,\n };\n\n const odspLogger = createOdspLogger(logger);\n\n const fileEntry: IFileEntry = { resolvedUrl: odspResolvedUrl, docId: odspResolvedUrl.hashedDocumentId };\n const cacheAndTracker = createOdspCacheAndTracker(\n this.persistedCache,\n this.nonPersistentCache,\n fileEntry,\n odspLogger);\n\n return PerformanceEvent.timedExecAsync(\n odspLogger,\n {\n eventName: \"CreateNew\",\n isWithSummaryUpload: true,\n },\n async (event) => {\n odspResolvedUrl = await createNewFluidFile(\n toInstrumentedOdspTokenFetcher(\n odspLogger,\n resolvedUrlData,\n this.getStorageToken,\n true /* throwOnNullToken */,\n ),\n newFileInfo,\n odspLogger,\n createNewSummary,\n cacheAndTracker.epochTracker,\n fileEntry,\n this.hostPolicy.cacheCreateNewSummary ?? true,\n !!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n );\n const docService = this.createDocumentServiceCore(odspResolvedUrl, odspLogger,\n cacheAndTracker, clientIsSummarizer);\n event.end({\n docId: odspResolvedUrl.hashedDocumentId,\n });\n return docService;\n });\n }\n\n /**\n * @param getStorageToken - function that can provide the storage token for a given site. This is\n * is also referred to as the \"Vroom\" token in SPO.\n * @param getWebsocketToken - function that can provide a token for accessing the web socket. This is also\n * to as the \"Push\" token in SPO. If undefined then websocket token is expected to be returned with joinSession\n * response payload.\n * @param storageFetchWrapper - if not provided FetchWrapper will be used\n * @param deltasFetchWrapper - if not provided FetchWrapper will be used\n * @param persistedCache - PersistedCache provided by host for use in this session.\n */\n constructor(\n private readonly getStorageToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n private readonly getWebsocketToken: TokenFetcher<OdspResourceTokenFetchOptions> | undefined,\n private readonly getSocketIOClient: () => Promise<typeof SocketIOClientStatic>,\n protected persistedCache: IPersistedCache = new LocalPersistentCache(),\n private readonly hostPolicy: HostStoragePolicy = {},\n ) {\n if (this.hostPolicy.isolateSocketCache === true) {\n // create the key to separate the socket reuse cache\n this.socketReferenceKeyPrefix = uuid();\n }\n }\n\n public async createDocumentService(\n resolvedUrl: IResolvedUrl,\n logger?: ITelemetryBaseLogger,\n clientIsSummarizer?: boolean,\n ): Promise<IDocumentService> {\n return this.createDocumentServiceCore(resolvedUrl, createOdspLogger(logger), undefined, clientIsSummarizer);\n }\n\n private async createDocumentServiceCore(\n resolvedUrl: IResolvedUrl,\n odspLogger: TelemetryLogger,\n cacheAndTrackerArg?: ICacheAndTracker,\n clientIsSummarizer?: boolean,\n ): Promise<IDocumentService> {\n const odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n const resolvedUrlData: IOdspUrlParts = {\n siteUrl: odspResolvedUrl.siteUrl,\n driveId: odspResolvedUrl.driveId,\n itemId: odspResolvedUrl.itemId,\n };\n const cacheAndTracker = cacheAndTrackerArg ?? createOdspCacheAndTracker(\n this.persistedCache,\n this.nonPersistentCache,\n { resolvedUrl: odspResolvedUrl, docId: odspResolvedUrl.hashedDocumentId },\n odspLogger);\n\n const storageTokenFetcher = toInstrumentedOdspTokenFetcher(\n odspLogger,\n resolvedUrlData,\n this.getStorageToken,\n true /* throwOnNullToken */,\n );\n\n const webSocketTokenFetcher = this.getWebsocketToken === undefined\n ? undefined\n : async (options: TokenFetchOptions) => toInstrumentedOdspTokenFetcher(\n odspLogger,\n resolvedUrlData,\n this.getWebsocketToken!,\n false /* throwOnNullToken */,\n )(options, \"GetWebsocketToken\");\n\n return OdspDocumentService.create(\n resolvedUrl,\n storageTokenFetcher,\n webSocketTokenFetcher,\n odspLogger,\n this.getSocketIOClient,\n cacheAndTracker.cache,\n this.hostPolicy,\n cacheAndTracker.epochTracker,\n this.socketReferenceKeyPrefix,\n clientIsSummarizer,\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"odspDocumentServiceFactoryCore.js","sourceRoot":"","sources":["../src/odspDocumentServiceFactoryCore.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AASH,qEAGyC;AACzC,+DAGsC;AAWtC,+BAAkC;AAClC,2CAGqB;AACrB,iDAGwB;AACxB,+DAA4D;AAC5D,2CAAiH;AACjH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CAAC,gBAAgB,EAAE,EACzE,UAAU,CAAC,CAAC;QAEhB,MAAM,mBAAmB,GAAG,IAAA,0CAA8B,EACtD,UAAU,EACV,eAAe,EACf,IAAI,CAAC,eAAe,EACpB,IAAI,CAAC,sBAAsB,CAC9B,CAAC;QAEF,MAAM,qBAAqB,GAAG,IAAI,CAAC,iBAAiB,KAAK,SAAS;YAC9D,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,KAAK,EAAE,OAA0B,EAAE,EAAE,CAAC,IAAA,0CAA8B,EAClE,UAAU,EACV,eAAe,EACf,IAAI,CAAC,iBAAkB,EACvB,KAAK,CAAC,sBAAsB,CAC/B,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAC;QAEpC,OAAO,yCAAmB,CAAC,MAAM,CAC7B,WAAW,EACX,mBAAmB,EACnB,qBAAqB,EACrB,UAAU,EACV,IAAI,CAAC,iBAAiB,EACtB,eAAe,CAAC,KAAK,EACrB,IAAI,CAAC,UAAU,EACf,eAAe,CAAC,YAAY,EAC5B,IAAI,CAAC,wBAAwB,EAC7B,kBAAkB,CACrB,CAAC;IACN,CAAC;CACJ;AArKD,wEAqKC","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 IDocumentService,\n IDocumentServiceFactory,\n IResolvedUrl,\n} from \"@fluidframework/driver-definitions\";\nimport { ISummaryTree } from \"@fluidframework/protocol-definitions\";\nimport {\n TelemetryLogger,\n PerformanceEvent,\n} from \"@fluidframework/telemetry-utils\";\nimport {\n getDocAttributesFromProtocolSummary,\n ensureFluidResolvedUrl,\n} from \"@fluidframework/driver-utils\";\nimport {\n TokenFetchOptions,\n OdspResourceTokenFetchOptions,\n TokenFetcher,\n IPersistedCache,\n HostStoragePolicy,\n IFileEntry,\n IOdspUrlParts,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport type { io as SocketIOClientStatic } from \"socket.io-client\";\nimport { v4 as uuid } from \"uuid\";\nimport {\n LocalPersistentCache,\n NonPersistentCache,\n} from \"./odspCache\";\nimport {\n createOdspCacheAndTracker,\n ICacheAndTracker,\n} from \"./epochTracker\";\nimport { OdspDocumentService } from \"./odspDocumentService\";\nimport { INewFileInfo, getOdspResolvedUrl, createOdspLogger, toInstrumentedOdspTokenFetcher } from \"./odspUtils\";\nimport { createNewFluidFile } from \"./createFile\";\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 public readonly protocolName = \"fluid-odsp:\";\n\n private readonly nonPersistentCache = new NonPersistentCache();\n private readonly socketReferenceKeyPrefix?: string;\n\n public async createContainer(\n createNewSummary: ISummaryTree | undefined,\n createNewResolvedUrl: IResolvedUrl,\n logger?: ITelemetryBaseLogger,\n clientIsSummarizer?: boolean,\n ): Promise<IDocumentService> {\n ensureFluidResolvedUrl(createNewResolvedUrl);\n\n let odspResolvedUrl = getOdspResolvedUrl(createNewResolvedUrl);\n const resolvedUrlData: IOdspUrlParts = {\n siteUrl: odspResolvedUrl.siteUrl,\n driveId: odspResolvedUrl.driveId,\n itemId: odspResolvedUrl.itemId,\n };\n const [, queryString] = odspResolvedUrl.url.split(\"?\");\n\n const searchParams = new URLSearchParams(queryString);\n const filePath = searchParams.get(\"path\");\n if (filePath === undefined || filePath === null) {\n throw new Error(\"File path should be provided!!\");\n }\n\n const protocolSummary = createNewSummary?.tree[\".protocol\"];\n if (protocolSummary) {\n const documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary as ISummaryTree);\n if (documentAttributes?.sequenceNumber !== 0) {\n throw new Error(\"Seq number in detached ODSP container should be 0\");\n }\n }\n\n const newFileInfo: INewFileInfo = {\n driveId: odspResolvedUrl.driveId,\n siteUrl: odspResolvedUrl.siteUrl,\n filePath,\n filename: odspResolvedUrl.fileName,\n // set createLinkType to undefined if enableShareLinkWithCreate is set to false,\n // so that share link creation with create file can be enabled\n createLinkType: this.hostPolicy.enableShareLinkWithCreate ?\n odspResolvedUrl.shareLinkInfo?.createLink?.type : undefined,\n };\n\n const odspLogger = createOdspLogger(logger);\n\n const fileEntry: IFileEntry = { resolvedUrl: odspResolvedUrl, docId: odspResolvedUrl.hashedDocumentId };\n const cacheAndTracker = createOdspCacheAndTracker(\n this.persistedCache,\n this.nonPersistentCache,\n fileEntry,\n odspLogger);\n\n return PerformanceEvent.timedExecAsync(\n odspLogger,\n {\n eventName: \"CreateNew\",\n isWithSummaryUpload: true,\n },\n async (event) => {\n odspResolvedUrl = await createNewFluidFile(\n toInstrumentedOdspTokenFetcher(\n odspLogger,\n resolvedUrlData,\n this.getStorageToken,\n true /* throwOnNullToken */,\n ),\n newFileInfo,\n odspLogger,\n createNewSummary,\n cacheAndTracker.epochTracker,\n fileEntry,\n this.hostPolicy.cacheCreateNewSummary ?? true,\n !!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n );\n const docService = this.createDocumentServiceCore(odspResolvedUrl, odspLogger,\n cacheAndTracker, clientIsSummarizer);\n event.end({\n docId: odspResolvedUrl.hashedDocumentId,\n });\n return docService;\n });\n }\n\n /**\n * @param getStorageToken - function that can provide the storage token for a given site. This is\n * is also referred to as the \"Vroom\" token in SPO.\n * @param getWebsocketToken - function that can provide a token for accessing the web socket. This is also\n * to as the \"Push\" token in SPO. If undefined then websocket token is expected to be returned with joinSession\n * response payload.\n * @param storageFetchWrapper - if not provided FetchWrapper will be used\n * @param deltasFetchWrapper - if not provided FetchWrapper will be used\n * @param persistedCache - PersistedCache provided by host for use in this session.\n */\n constructor(\n private readonly getStorageToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n private readonly getWebsocketToken: TokenFetcher<OdspResourceTokenFetchOptions> | undefined,\n private readonly getSocketIOClient: () => Promise<typeof SocketIOClientStatic>,\n protected persistedCache: IPersistedCache = new LocalPersistentCache(),\n private readonly hostPolicy: HostStoragePolicy = {},\n ) {\n if (this.hostPolicy.isolateSocketCache === true) {\n // create the key to separate the socket reuse cache\n this.socketReferenceKeyPrefix = uuid();\n }\n }\n\n public async createDocumentService(\n resolvedUrl: IResolvedUrl,\n logger?: ITelemetryBaseLogger,\n clientIsSummarizer?: boolean,\n ): Promise<IDocumentService> {\n return this.createDocumentServiceCore(resolvedUrl, createOdspLogger(logger), undefined, clientIsSummarizer);\n }\n\n private async createDocumentServiceCore(\n resolvedUrl: IResolvedUrl,\n odspLogger: TelemetryLogger,\n cacheAndTrackerArg?: ICacheAndTracker,\n clientIsSummarizer?: boolean,\n ): Promise<IDocumentService> {\n const odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n const resolvedUrlData: IOdspUrlParts = {\n siteUrl: odspResolvedUrl.siteUrl,\n driveId: odspResolvedUrl.driveId,\n itemId: odspResolvedUrl.itemId,\n };\n const cacheAndTracker = cacheAndTrackerArg ?? createOdspCacheAndTracker(\n this.persistedCache,\n this.nonPersistentCache,\n { resolvedUrl: odspResolvedUrl, docId: odspResolvedUrl.hashedDocumentId },\n odspLogger);\n\n const storageTokenFetcher = toInstrumentedOdspTokenFetcher(\n odspLogger,\n resolvedUrlData,\n this.getStorageToken,\n true /* throwOnNullToken */,\n );\n\n const webSocketTokenFetcher = this.getWebsocketToken === undefined\n ? undefined\n : async (options: TokenFetchOptions) => toInstrumentedOdspTokenFetcher(\n odspLogger,\n resolvedUrlData,\n this.getWebsocketToken!,\n false /* throwOnNullToken */,\n )(options, \"GetWebsocketToken\");\n\n return OdspDocumentService.create(\n resolvedUrl,\n storageTokenFetcher,\n webSocketTokenFetcher,\n odspLogger,\n this.getSocketIOClient,\n cacheAndTracker.cache,\n this.hostPolicy,\n cacheAndTracker.epochTracker,\n this.socketReferenceKeyPrefix,\n clientIsSummarizer,\n );\n }\n}\n"]}
|
|
@@ -11,6 +11,7 @@ import { SnapshotFormatSupportType } from "./fetchSnapshot";
|
|
|
11
11
|
import { IOdspCache } from "./odspCache";
|
|
12
12
|
import { EpochTracker } from "./epochTracker";
|
|
13
13
|
import { FlushResult } from "./odspDocumentDeltaConnection";
|
|
14
|
+
export declare const defaultSummarizerCacheExpiryTimeout: number;
|
|
14
15
|
export declare class OdspDocumentStorageService implements IDocumentStorageService {
|
|
15
16
|
private readonly odspResolvedUrl;
|
|
16
17
|
private readonly getStorageToken;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspDocumentStorageManager.d.ts","sourceRoot":"","sources":["../src/odspDocumentStorageManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAQtE,OAAO,KAAK,GAAG,MAAM,sCAAsC,CAAC;AAC5D,OAAO,EACH,eAAe,EACf,uBAAuB,EACvB,mBAAmB,EAEtB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EACH,gBAAgB,EAGhB,+BAA+B,EAClC,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAEH,yBAAyB,EAG5B,MAAM,aAAa,CAAC;AACrB,OAAO,EAA4D,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAEtH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAMzC,OAAO,EAA+B,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE3E,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"odspDocumentStorageManager.d.ts","sourceRoot":"","sources":["../src/odspDocumentStorageManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAQtE,OAAO,KAAK,GAAG,MAAM,sCAAsC,CAAC;AAC5D,OAAO,EACH,eAAe,EACf,uBAAuB,EACvB,mBAAmB,EAEtB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EACH,gBA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MjF,wBAAwB,CAAC,OAAO,EAAE,GAAG,CAAC,YAAY,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC;IAuC9F,eAAe,CAAC,MAAM,EAAE,GAAG,CAAC,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;IAInF,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,sBAAsB;IAS9B,OAAO,CAAC,qBAAqB;YASf,QAAQ;IA8CtB,OAAO,CAAC,iCAAiC;CAkB5C"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.OdspDocumentStorageService = void 0;
|
|
7
|
+
exports.OdspDocumentStorageService = exports.defaultSummarizerCacheExpiryTimeout = void 0;
|
|
8
8
|
const common_utils_1 = require("@fluidframework/common-utils");
|
|
9
9
|
const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
|
|
10
10
|
const driver_definitions_1 = require("@fluidframework/driver-definitions");
|
|
@@ -16,6 +16,7 @@ const odspUtils_1 = require("./odspUtils");
|
|
|
16
16
|
const epochTracker_1 = require("./epochTracker");
|
|
17
17
|
const odspSummaryUploadManager_1 = require("./odspSummaryUploadManager");
|
|
18
18
|
const packageVersion_1 = require("./packageVersion");
|
|
19
|
+
exports.defaultSummarizerCacheExpiryTimeout = 60 * 1000; // 60 seconds.
|
|
19
20
|
/* eslint-disable max-len */
|
|
20
21
|
// An implementation of Promise.race that gives you the winner of the promise race
|
|
21
22
|
async function promiseRaceWithWinner(promises) {
|
|
@@ -163,7 +164,7 @@ class OdspDocumentStorageService {
|
|
|
163
164
|
this.odspSummaryUploadManager = new odspSummaryUploadManager_1.OdspSummaryUploadManager(this.snapshotUrl, getStorageToken, logger, epochTracker, !!((_a = this.hostPolicy.sessionOptions) === null || _a === void 0 ? void 0 : _a.forceAccessTokenViaAuthorizationHeader));
|
|
164
165
|
}
|
|
165
166
|
set ops(ops) {
|
|
166
|
-
common_utils_1.assert(this._ops === undefined, 0x0a5 /* "Trying to set ops when they are already set!" */);
|
|
167
|
+
(0, common_utils_1.assert)(this._ops === undefined, 0x0a5 /* "Trying to set ops when they are already set!" */);
|
|
167
168
|
this._ops = ops;
|
|
168
169
|
}
|
|
169
170
|
get ops() {
|
|
@@ -177,10 +178,10 @@ class OdspDocumentStorageService {
|
|
|
177
178
|
}
|
|
178
179
|
async createBlob(file) {
|
|
179
180
|
this.checkAttachmentPOSTUrl();
|
|
180
|
-
const response = await odspUtils_1.getWithRetryForTokenRefresh(async (options) => {
|
|
181
|
+
const response = await (0, odspUtils_1.getWithRetryForTokenRefresh)(async (options) => {
|
|
181
182
|
var _a;
|
|
182
183
|
const storageToken = await this.getStorageToken(options, "CreateBlob");
|
|
183
|
-
const { url, headers } = getUrlAndHeadersWithAuth_1.getUrlAndHeadersWithAuth(`${this.attachmentPOSTUrl}/content`, storageToken, !!((_a = this.hostPolicy.sessionOptions) === null || _a === void 0 ? void 0 : _a.forceAccessTokenViaAuthorizationHeader));
|
|
184
|
+
const { url, headers } = (0, getUrlAndHeadersWithAuth_1.getUrlAndHeadersWithAuth)(`${this.attachmentPOSTUrl}/content`, storageToken, !!((_a = this.hostPolicy.sessionOptions) === null || _a === void 0 ? void 0 : _a.forceAccessTokenViaAuthorizationHeader));
|
|
184
185
|
headers["Content-Type"] = "application/octet-stream";
|
|
185
186
|
return telemetry_utils_1.PerformanceEvent.timedExecAsync(this.logger, {
|
|
186
187
|
eventName: "createBlob",
|
|
@@ -203,11 +204,11 @@ class OdspDocumentStorageService {
|
|
|
203
204
|
let blob = blobContent;
|
|
204
205
|
if (blob === undefined) {
|
|
205
206
|
this.checkAttachmentGETUrl();
|
|
206
|
-
blob = await odspUtils_1.getWithRetryForTokenRefresh(async (options) => {
|
|
207
|
+
blob = await (0, odspUtils_1.getWithRetryForTokenRefresh)(async (options) => {
|
|
207
208
|
var _a;
|
|
208
209
|
const storageToken = await this.getStorageToken(options, "GetBlob");
|
|
209
210
|
const unAuthedUrl = `${this.attachmentGETUrl}/${encodeURIComponent(blobId)}/content`;
|
|
210
|
-
const { url, headers } = getUrlAndHeadersWithAuth_1.getUrlAndHeadersWithAuth(unAuthedUrl, storageToken, !!((_a = this.hostPolicy.sessionOptions) === null || _a === void 0 ? void 0 : _a.forceAccessTokenViaAuthorizationHeader));
|
|
211
|
+
const { url, headers } = (0, getUrlAndHeadersWithAuth_1.getUrlAndHeadersWithAuth)(unAuthedUrl, storageToken, !!((_a = this.hostPolicy.sessionOptions) === null || _a === void 0 ? void 0 : _a.forceAccessTokenViaAuthorizationHeader));
|
|
211
212
|
return telemetry_utils_1.PerformanceEvent.timedExecAsync(this.logger, {
|
|
212
213
|
eventName: "readDataBlob",
|
|
213
214
|
blobId,
|
|
@@ -290,15 +291,27 @@ class OdspDocumentStorageService {
|
|
|
290
291
|
let retrievedSnapshot;
|
|
291
292
|
// Here's the logic to grab the persistent cache snapshot implemented by the host
|
|
292
293
|
// Epoch tracker is responsible for communicating with the persistent cache, handling epochs and cache versions
|
|
293
|
-
const cachedSnapshotP = this.epochTracker.get(odspUtils_1.createCacheSnapshotKey(this.odspResolvedUrl))
|
|
294
|
+
const cachedSnapshotP = this.epochTracker.get((0, odspUtils_1.createCacheSnapshotKey)(this.odspResolvedUrl))
|
|
294
295
|
.then(async (snapshotCachedEntry) => {
|
|
295
296
|
var _a;
|
|
296
297
|
if (snapshotCachedEntry !== undefined) {
|
|
297
298
|
// If the cached entry does not contain the entry time, then assign it a default of 30 days old.
|
|
298
299
|
const age = Date.now() - ((_a = snapshotCachedEntry.cacheEntryTime) !== null && _a !== void 0 ? _a : (Date.now() - 30 * 24 * 60 * 60 * 1000));
|
|
300
|
+
// In order to decrease the number of times we have to execute a snapshot refresh,
|
|
301
|
+
// if this is the summarizer and we have a cache entry but it is past the defaultSummarizerCacheExpiryTimeout,
|
|
302
|
+
// force the network retrieval instead as there might be a more recent snapshot available.
|
|
303
|
+
// See: https://github.com/microsoft/FluidFramework/issues/8995 for additional information.
|
|
304
|
+
if (this.hostPolicy.summarizerClient) {
|
|
305
|
+
if (age > exports.defaultSummarizerCacheExpiryTimeout) {
|
|
306
|
+
props.cacheSummarizerExpired = true;
|
|
307
|
+
return undefined;
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
props.cacheSummarizerExpired = false;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
299
313
|
// Record the cache age
|
|
300
|
-
|
|
301
|
-
props["cacheEntryAge"] = age;
|
|
314
|
+
props.cacheEntryAge = age;
|
|
302
315
|
}
|
|
303
316
|
return snapshotCachedEntry;
|
|
304
317
|
});
|
|
@@ -341,8 +354,7 @@ class OdspDocumentStorageService {
|
|
|
341
354
|
}
|
|
342
355
|
}
|
|
343
356
|
if (method === "network") {
|
|
344
|
-
|
|
345
|
-
props["cacheEntryAge"] = undefined;
|
|
357
|
+
props.cacheEntryAge = undefined;
|
|
346
358
|
}
|
|
347
359
|
event.end(Object.assign(Object.assign({}, props), { method }));
|
|
348
360
|
return retrievedSnapshot;
|
|
@@ -355,7 +367,7 @@ class OdspDocumentStorageService {
|
|
|
355
367
|
let id;
|
|
356
368
|
if (snapshotTree) {
|
|
357
369
|
id = snapshotTree.id;
|
|
358
|
-
common_utils_1.assert(id !== undefined, 0x221 /* "Root tree should contain the id" */);
|
|
370
|
+
(0, common_utils_1.assert)(id !== undefined, 0x221 /* "Root tree should contain the id" */);
|
|
359
371
|
this.setRootTree(id, snapshotTree);
|
|
360
372
|
}
|
|
361
373
|
if (blobs) {
|
|
@@ -364,10 +376,10 @@ class OdspDocumentStorageService {
|
|
|
364
376
|
this.ops = ops;
|
|
365
377
|
return id ? [{ id, treeId: undefined }] : [];
|
|
366
378
|
}
|
|
367
|
-
return odspUtils_1.getWithRetryForTokenRefresh(async (options) => {
|
|
379
|
+
return (0, odspUtils_1.getWithRetryForTokenRefresh)(async (options) => {
|
|
368
380
|
var _a;
|
|
369
381
|
const storageToken = await this.getStorageToken(options, "GetVersions");
|
|
370
|
-
const { url, headers } = getUrlAndHeadersWithAuth_1.getUrlAndHeadersWithAuth(`${this.snapshotUrl}/versions?
|
|
382
|
+
const { url, headers } = (0, getUrlAndHeadersWithAuth_1.getUrlAndHeadersWithAuth)(`${this.snapshotUrl}/versions?top=${count}`, storageToken, !!((_a = this.hostPolicy.sessionOptions) === null || _a === void 0 ? void 0 : _a.forceAccessTokenViaAuthorizationHeader));
|
|
371
383
|
// Fetch the latest snapshot versions for the document
|
|
372
384
|
const response = await telemetry_utils_1.PerformanceEvent.timedExecAsync(this.logger, {
|
|
373
385
|
eventName: "getVersions",
|
|
@@ -381,17 +393,7 @@ class OdspDocumentStorageService {
|
|
|
381
393
|
throw new driver_utils_1.NonRetryableError("Incorrect response from /versions endpoint, expected an array", driver_definitions_1.DriverErrorType.genericNetworkError, { driverVersion: packageVersion_1.pkgVersion });
|
|
382
394
|
}
|
|
383
395
|
return versionsResponse.value.map((version) => {
|
|
384
|
-
// Parse the date from the message
|
|
385
|
-
let date;
|
|
386
|
-
for (const rec of version.message.split("\n")) {
|
|
387
|
-
const index = rec.indexOf(":");
|
|
388
|
-
if (index !== -1 && rec.substr(0, index) === "Date") {
|
|
389
|
-
date = rec.substr(index + 1).trim();
|
|
390
|
-
break;
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
396
|
return {
|
|
394
|
-
date,
|
|
395
397
|
id: version.id,
|
|
396
398
|
treeId: undefined,
|
|
397
399
|
};
|
|
@@ -420,16 +422,16 @@ class OdspDocumentStorageService {
|
|
|
420
422
|
snapshotOptions.timeout = undefined;
|
|
421
423
|
}
|
|
422
424
|
const snapshotDownloader = async (finalOdspResolvedUrl, storageToken, options, controller) => {
|
|
423
|
-
return fetchSnapshot_1.downloadSnapshot(finalOdspResolvedUrl, storageToken, this.logger, options, this.snapshotFormatFetchType, controller, this.epochTracker);
|
|
425
|
+
return (0, fetchSnapshot_1.downloadSnapshot)(finalOdspResolvedUrl, storageToken, this.logger, options, this.snapshotFormatFetchType, controller, this.epochTracker);
|
|
424
426
|
};
|
|
425
427
|
const putInCache = async (valueWithEpoch) => {
|
|
426
|
-
return this.cache.persistedCache.put(odspUtils_1.createCacheSnapshotKey(this.odspResolvedUrl),
|
|
428
|
+
return this.cache.persistedCache.put((0, odspUtils_1.createCacheSnapshotKey)(this.odspResolvedUrl),
|
|
427
429
|
// Epoch tracker will add the epoch and version to the value here. So just send value to cache.
|
|
428
430
|
valueWithEpoch.value);
|
|
429
431
|
};
|
|
430
432
|
const removeEntries = async () => this.cache.persistedCache.removeEntries();
|
|
431
433
|
try {
|
|
432
|
-
const odspSnapshot = await fetchSnapshot_1.fetchSnapshotWithRedeem(this.odspResolvedUrl, this.getStorageToken, snapshotOptions, !!((_a = this.hostPolicy.sessionOptions) === null || _a === void 0 ? void 0 : _a.forceAccessTokenViaAuthorizationHeader), this.logger, snapshotDownloader, putInCache, removeEntries, this.hostPolicy.enableRedeemFallback);
|
|
434
|
+
const odspSnapshot = await (0, fetchSnapshot_1.fetchSnapshotWithRedeem)(this.odspResolvedUrl, this.getStorageToken, snapshotOptions, !!((_a = this.hostPolicy.sessionOptions) === null || _a === void 0 ? void 0 : _a.forceAccessTokenViaAuthorizationHeader), this.logger, snapshotDownloader, putInCache, removeEntries, this.hostPolicy.enableRedeemFallback);
|
|
433
435
|
return odspSnapshot;
|
|
434
436
|
}
|
|
435
437
|
catch (error) {
|
|
@@ -445,7 +447,7 @@ class OdspDocumentStorageService {
|
|
|
445
447
|
errorType,
|
|
446
448
|
});
|
|
447
449
|
const snapshotOptionsWithoutBlobs = Object.assign(Object.assign({}, snapshotOptions), { blobs: 0, mds: undefined, timeout: undefined });
|
|
448
|
-
const odspSnapshot = await fetchSnapshot_1.fetchSnapshotWithRedeem(this.odspResolvedUrl, this.getStorageToken, snapshotOptionsWithoutBlobs, !!((_b = this.hostPolicy.sessionOptions) === null || _b === void 0 ? void 0 : _b.forceAccessTokenViaAuthorizationHeader), this.logger, snapshotDownloader, putInCache, removeEntries, this.hostPolicy.enableRedeemFallback);
|
|
450
|
+
const odspSnapshot = await (0, fetchSnapshot_1.fetchSnapshotWithRedeem)(this.odspResolvedUrl, this.getStorageToken, snapshotOptionsWithoutBlobs, !!((_b = this.hostPolicy.sessionOptions) === null || _b === void 0 ? void 0 : _b.forceAccessTokenViaAuthorizationHeader), this.logger, snapshotDownloader, putInCache, removeEntries, this.hostPolicy.enableRedeemFallback);
|
|
449
451
|
return odspSnapshot;
|
|
450
452
|
}
|
|
451
453
|
throw error;
|
|
@@ -473,7 +475,7 @@ class OdspDocumentStorageService {
|
|
|
473
475
|
break;
|
|
474
476
|
}
|
|
475
477
|
this.logger.sendPerformanceEvent(Object.assign(Object.assign({ eventName: "FlushExtraCall" }, result), { retry, referenceSequenceNumber: context.referenceSequenceNumber }));
|
|
476
|
-
await common_utils_1.delay(1000 * ((_a = result.retryAfter) !== null && _a !== void 0 ? _a : 1));
|
|
478
|
+
await (0, common_utils_1.delay)(1000 * ((_a = result.retryAfter) !== null && _a !== void 0 ? _a : 1));
|
|
477
479
|
}
|
|
478
480
|
}
|
|
479
481
|
const id = await this.odspSummaryUploadManager.writeSummaryTree(summary, context);
|
|
@@ -509,16 +511,16 @@ class OdspDocumentStorageService {
|
|
|
509
511
|
}
|
|
510
512
|
let tree = this.commitCache.get(id);
|
|
511
513
|
if (!tree) {
|
|
512
|
-
tree = await odspUtils_1.getWithRetryForTokenRefresh(async (options) => {
|
|
514
|
+
tree = await (0, odspUtils_1.getWithRetryForTokenRefresh)(async (options) => {
|
|
513
515
|
var _a, _b;
|
|
514
516
|
const storageToken = await this.getStorageToken(options, "ReadCommit");
|
|
515
517
|
const snapshotDownloader = async (url, fetchOptions) => {
|
|
516
518
|
return this.epochTracker.fetchAndParseAsJSON(url, fetchOptions, "snapshotTree");
|
|
517
519
|
};
|
|
518
|
-
const snapshot = await fetchSnapshot_1.fetchSnapshot(this.snapshotUrl, storageToken, id, this.fetchFullSnapshot, !!((_a = this.hostPolicy.sessionOptions) === null || _a === void 0 ? void 0 : _a.forceAccessTokenViaAuthorizationHeader), this.logger, snapshotDownloader);
|
|
520
|
+
const snapshot = await (0, fetchSnapshot_1.fetchSnapshot)(this.snapshotUrl, storageToken, id, this.fetchFullSnapshot, !!((_a = this.hostPolicy.sessionOptions) === null || _a === void 0 ? void 0 : _a.forceAccessTokenViaAuthorizationHeader), this.logger, snapshotDownloader);
|
|
519
521
|
let treeId = "";
|
|
520
522
|
if (snapshot.snapshotTree) {
|
|
521
|
-
common_utils_1.assert(snapshot.snapshotTree.id !== undefined, 0x222 /* "Root tree should contain the id!!" */);
|
|
523
|
+
(0, common_utils_1.assert)(snapshot.snapshotTree.id !== undefined, 0x222 /* "Root tree should contain the id!!" */);
|
|
522
524
|
treeId = snapshot.snapshotTree.id;
|
|
523
525
|
this.setRootTree(treeId, snapshot.snapshotTree);
|
|
524
526
|
}
|