/*! * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ import { TypedEventEmitter } from "@fluid-internal/client-utils"; import type { IClient } from "@fluidframework/driver-definitions"; import type { IDocumentServiceEvents, IDocumentService, IResolvedUrl, IDocumentStorageService, IDocumentDeltaConnection, IDocumentDeltaStorageService, } from "@fluidframework/driver-definitions/internal"; import type { FileDeltaStorageService } from "./fileDeltaStorageService.js"; /** * The DocumentService manages the different endpoints for connecting to * underlying storage for file document service. */ export class FileDocumentService extends TypedEventEmitter implements IDocumentService { constructor( public readonly resolvedUrl: IResolvedUrl, private readonly storage: IDocumentStorageService, private readonly deltaStorage: FileDeltaStorageService, private readonly deltaConnection: IDocumentDeltaConnection, ) { super(); } public dispose(): void {} public async connectToStorage(): Promise { return this.storage; } public async connectToDeltaStorage(): Promise { return this.deltaStorage; } /** * Connects to a delta storage endpoint of provided documentService to get ops and then replaying * them so as to mimic a delta stream endpoint. * * @param client - Client that connects to socket. * @returns returns the delta stream service. */ public async connectToDeltaStream(client: IClient): Promise { return this.deltaConnection; } }