/*! * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ import type { AttachState, IAudience } from "@fluidframework/container-definitions"; import type { IFluidHandle, FluidObject, IDisposable, IEvent, IEventProvider, ITelemetryBaseLogger, ErasedType } from "@fluidframework/core-interfaces"; import type { IFluidHandleContext } from "@fluidframework/core-interfaces/internal"; import type { IQuorumClients } from "@fluidframework/driver-definitions"; import type { ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal"; import type { IIdCompressor } from "@fluidframework/id-compressor"; import type { IInboundSignalMessage, MinimumVersionForCollab } from "@fluidframework/runtime-definitions/internal"; import type { IChannel } from "./channel.js"; /** * Events emitted by {@link IFluidDataStoreRuntime}. * @legacy @beta */ export interface IFluidDataStoreRuntimeEvents extends IEvent { (event: "disconnected", listener: () => void): any; (event: "dispose", listener: () => void): any; (event: "attaching", listener: () => void): any; (event: "attached", listener: () => void): any; (event: "op", listener: (message: ISequencedDocumentMessage) => void): any; (event: "signal", listener: (message: IInboundSignalMessage, local: boolean) => void): any; (event: "connected", listener: (clientId: string) => void): any; (event: "readonly", listener: (isReadOnly: boolean) => void): any; } /** * Manages the transmission of ops between the runtime and storage. * @legacy @beta */ export type IDeltaManagerErased = ErasedType<"@fluidframework/container-definitions.IDeltaManager">; /** * Represents the runtime for the data store. Contains helper functions/state of the data store. * @sealed * @legacy @beta */ export interface IFluidDataStoreRuntime extends IEventProvider, IDisposable { readonly id: string; readonly IFluidHandleContext: IFluidHandleContext; readonly rootRoutingContext: IFluidHandleContext; readonly channelsRoutingContext: IFluidHandleContext; readonly objectsRoutingContext: IFluidHandleContext; readonly options: Record; readonly deltaManager: IDeltaManagerErased; readonly clientId: string | undefined; readonly connected: boolean; /** * Get the current readonly state. * @returns true if read-only, otherwise false */ readonly isReadOnly: () => boolean; readonly logger: ITelemetryBaseLogger; /** * Indicates the attachment state of the data store to a host service. */ readonly attachState: AttachState; /** * An optional ID compressor. * @remarks * When provided, can be used to compress and decompress IDs stored in this datastore. * Some SharedObjects, like SharedTree, require this. */ readonly idCompressor: IIdCompressor | undefined; /** * Returns the channel with the given id */ getChannel(id: string): Promise; /** * Creates a new channel of the given type. * @param id - ID of the channel to be created. A unique ID will be generated if left undefined. * @param type - Type of the channel. */ createChannel(id: string | undefined, type: string): IChannel; /** * Adds an existing channel to the data store. * * @remarks * This allows callers to customize channel instance. * * For example, a channel implementation could have various modes of operations. * As long as such configuration is provided at creation * and stored in summaries (such that all users of such channel instance behave the same), this * could be useful technique to have customized solutions without introducing a number of data structures * that all have same implementation. * * This is also useful for scenarios like SharedTree DDS, where schema is provided at creation and stored in a summary. * * The channel type should be present in the registry, otherwise the runtime would reject * the channel. The runtime used to create the channel object should be same to which * it is added. * @param channel - channel which needs to be added to the runtime. */ addChannel(channel: IChannel): void; /** * Bind the channel with the data store runtime. If the runtime * is attached then we attach the channel to make it live. */ bindChannel(channel: IChannel): void; /** * Api to upload a blob of data. * @param blob - blob to be uploaded. */ uploadBlob(blob: ArrayBufferLike, signal?: AbortSignal): Promise>; /** * Submits the signal to be sent to other clients. * @param type - Type of the signal. * @param content - Content of the signal. Should be a JSON serializable object or primitive. * @param targetClientId - When specified, the signal is only sent to the provided client id. */ submitSignal: (type: string, content: unknown, targetClientId?: string) => void; /** * Returns the current quorum. */ getQuorum(): IQuorumClients; /** * Returns the current audience. */ getAudience(): IAudience; /** * Resolves when a local data store is attached. */ waitAttached(): Promise; /** * Exposes a handle to the root object / entryPoint of the data store. Use this as the primary way of interacting * with it. */ readonly entryPoint: IFluidHandle; /** * Indicates the current local operation activity being performed by the data store runtime. * * @remarks * This property allows consumers to know when the runtime itself is actively making changes to data store DDSes. * When this property is not `undefined`, consumers should expect to see state modifications initiated by the runtime * rather than by the consumer directly: * - `"applyStashed"` - The runtime is applying previously stashed operations during reconnection or container load. * Stashed operations are local changes that were submitted but not yet acknowledged when a container was closed, * and are being reapplied to restore the expected local state. * - `"rollback"` - The runtime is rolling back (reverting) local operations that the user has chosen not to submit. * This occurs when operations are being discarded, such as when exiting staging mode without committing changes. * - `undefined` - No local operation activity is currently in progress. */ readonly activeLocalOperationActivity?: "applyStashed" | "rollback" | undefined; /** * Indicates whether the container is currently in staging mode. * * @remarks * See {@link @fluidframework/runtime-definitions#IContainerRuntimeBase.enterStagingMode} for known limitations. */ readonly inStagingMode: boolean; /** * Indicates whether the data store has uncommitted local changes. */ readonly isDirty: boolean; } /** * @legacy @alpha * @sealed */ export interface IFluidDataStoreRuntimeAlpha extends IFluidDataStoreRuntime { } /** * Internal configs possibly implemented by IFuidDataStoreRuntimes, for use only within the runtime layer. * For example, temporary layer compatibility details * * @internal */ export interface IFluidDataStoreRuntimeInternalConfig { readonly submitMessagesWithoutEncodingHandles?: boolean; /** * Minimum version of the Fluid Framework runtime that is required to collaborate on new documents. * @remarks * DDSes may read this value to determine which feature flags should be enabled.Expand commentComment on line R313Resolved * This property is consumed by `SharedObjectFactory` (which are implementations of * {@link @fluidframework/datastore-definitions#IChannelFactory}). * See {@link @fluidframework/container-runtime#LoadContainerRuntimeParams.minVersionForCollab} for more details. */ readonly minVersionForCollab?: MinimumVersionForCollab; } //# sourceMappingURL=dataStoreRuntime.d.ts.map