/*! * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ import { TypedEventEmitter } from "@fluid-internal/client-utils"; import { AttachState, type IAudience } from "@fluidframework/container-definitions"; import type { IDeltaManager } from "@fluidframework/container-definitions/internal"; import type { FluidObject, IFluidHandle, IRequest, IResponse } from "@fluidframework/core-interfaces"; import type { IFluidHandleContext, IFluidHandleInternal } from "@fluidframework/core-interfaces/internal"; import type { IChannel, IChannelFactory, IFluidDataStoreRuntime, IFluidDataStoreRuntimeEvents, IDeltaManagerErased } from "@fluidframework/datastore-definitions/internal"; import { type IClientDetails, type IQuorumClients } from "@fluidframework/driver-definitions"; import type { IDocumentMessage, ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal"; import type { IIdCompressor } from "@fluidframework/id-compressor"; import { type ISummaryTreeWithStats, type ITelemetryContext, type IGarbageCollectionData, type IAttachMessage, type IEnvelope, type IFluidDataStoreChannel, type IFluidDataStoreContext, VisibilityState, type IInboundSignalMessage, type IRuntimeMessageCollection, type IFluidDataStorePolicies, type OldestSupportedClientVersion } from "@fluidframework/runtime-definitions/internal"; import type { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils/legacy"; /** * @legacy @beta */ export declare enum DataStoreMessageType { Attach = "attach", ChannelOp = "op" } /** * Outgoing {@link FluidDataStoreRuntime} message structures. * @internal * * @privateRemarks * The types here are required to satisfy {@link @fluidframework/runtime-definitions#FluidDataStoreMessage} interface. */ export type LocalFluidDataStoreRuntimeMessage = { type: DataStoreMessageType.ChannelOp; content: IEnvelope; } | { type: DataStoreMessageType.Attach; content: IAttachMessage; }; /** * @legacy @beta */ export interface ISharedObjectRegistry { get(name: string): IChannelFactory | undefined; } /** * Wraps an {@link ISharedObjectRegistry} to transparently redirect legacy URL-based DDS type * strings to the factories registered under the corresponding short-name path segment. * * When a lookup by the full URL fails, this wrapper retries using only the portion of the URL * after `"https://graph.microsoft.com/types/"`. This allows old documents whose summaries * contain URL-based type strings to be loaded against a registry built with the current * short-name factory types. * * @remarks * See {@link legacyTypeUrlPrefix} for details on old vs. new formats */ export declare class LegacyTypeAwareRegistry implements ISharedObjectRegistry { private readonly base; constructor(base: ISharedObjectRegistry); get(name: string): IChannelFactory | undefined; } /** * Base data store class * @legacy @beta */ export declare class FluidDataStoreRuntime extends TypedEventEmitter implements IFluidDataStoreChannel, IFluidDataStoreRuntime, IFluidHandleContext { private readonly dataStoreContext; readonly entryPoint: IFluidHandleInternal; get connected(): boolean; readonly policies: IFluidDataStorePolicies; readonly isReadOnly: () => boolean; get clientId(): string | undefined; get clientDetails(): IClientDetails; get isAttached(): boolean; get attachState(): AttachState; get absolutePath(): string; get routeContext(): IFluidHandleContext; get idCompressor(): IIdCompressor | undefined; get IFluidHandleContext(): this; get rootRoutingContext(): this; get channelsRoutingContext(): this; get objectsRoutingContext(): this; private localOpActivity; get activeLocalOperationActivity(): "applyStashed" | "rollback" | undefined; private _disposed; get disposed(): boolean; private readonly contexts; private readonly pendingAttach; private readonly deferredAttached; private readonly localChannelContextQueue; private readonly notBoundedChannelContextSet; private _attachState; visibilityState: VisibilityState; private readonly pendingHandlesToMakeVisible; readonly id: string; readonly options: Record; readonly deltaManagerInternal: IDeltaManager; private readonly sharedObjectRegistry; private readonly quorum; private readonly audience; private readonly mc; get logger(): ITelemetryLoggerExt; /** * If the summarizer makes local changes, a telemetry event is logged. This has the potential to be very noisy. * So, adding a count of how many telemetry events are logged per data store context. This can be * controlled via feature flags. */ private localChangesTelemetryCount; /** * The compatibility details of the DataStore layer that is exposed to the Runtime layer * for validating Runtime-DataStore compatibility. * @remarks This is for internal use only. * The type of this should be ILayerCompatDetails. However, ILayerCompatDetails is internal and this class * is currently marked as legacy alpha. So, using unknown here. */ readonly ILayerCompatDetails?: unknown; /** * See IFluidDataStoreRuntimeInternalConfig.submitMessagesWithoutEncodingHandles * * Note: this class doesn't declare that it implements IFluidDataStoreRuntimeInternalConfig, * and we keep this property as private, but consumers may optimistically cast * to the internal interface to access this property. */ private readonly submitMessagesWithoutEncodingHandles; /** * {@inheritDoc @fluidframework/runtime-definitions#IFluidParentContext.minVersionForCollab} */ readonly minVersionForCollab: OldestSupportedClientVersion; /** * {@inheritDoc @fluidframework/runtime-definitions#IFluidParentContext.oldestSupportedClient} */ readonly oldestSupportedClient?: OldestSupportedClientVersion; /** * Create an instance of a DataStore runtime. * * @param dataStoreContext - Context object for the runtime. * @param sharedObjectRegistry - The registry of shared objects that this data store will be able to instantiate. * @param existing - Pass 'true' if loading this datastore from an existing file; pass 'false' otherwise. * @param provideEntryPoint - Function to initialize the entryPoint object for the data store runtime. The * handle to this data store runtime will point to the object returned by this function. If this function is not * provided, the handle will be left undefined. This is here so we can start making handles a first-class citizen * and the primary way of interacting with some Fluid objects, and should be used if possible. */ constructor(dataStoreContext: IFluidDataStoreContext, sharedObjectRegistry: ISharedObjectRegistry, existing: boolean, provideEntryPoint: (runtime: IFluidDataStoreRuntime) => Promise, policies?: Partial); get inStagingMode(): boolean; get isDirty(): boolean; get deltaManager(): IDeltaManagerErased; dispose(): void; resolveHandle(request: IRequest): Promise; request(request: IRequest): Promise; getChannel(id: string): Promise; /** * Validate user provided channel ID * Channel ID has limitations. "/" is not allowed as IDs in storage can not have slashes - we parse tree paths and use "/" as separator. * IDs cannot start with "_" as it could result in collision of IDs with auto-assigned (by FF) short IDs. * @param id - channel ID. */ protected validateChannelId(id: string): void; /** * Api which allows caller to create the channel first and then add it to the runtime. * The channel type should be present in the registry, otherwise the runtime would reject * the channel. Also 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; createChannel(idArg: string | undefined, type: string): IChannel; private createChannelContext; private createRehydratedLocalChannelContext; /** * Binds a channel with the runtime. If the runtime is attached we will attach the channel right away. * If the runtime is not attached we will defer the attach until the runtime attaches. * @param channel - channel to be registered. */ bindChannel(channel: IChannel): void; /** * This function is called when a data store becomes root. It does the following: * * 1. Marks the data store locally visible in the container. * * 2. Attaches the graph of all the handles bound to it. * * 3. Calls into the data store context to mark it visible in the container too. If the container is globally * visible, it will mark us globally visible. Otherwise, it will mark us globally visible when it becomes * globally visible. */ makeVisibleAndAttachGraph(): void; /** * This function is called when a handle to this data store is added to a visible DDS. */ attachGraph(): void; bind(handle: IFluidHandle): void; setConnectionState(connected: boolean, clientId?: string): void; private _readonly; /** * This function is used by the datastore context to configure the * readonly state of this object. It should not be invoked by * any other callers. */ notifyReadOnlyState(readonly: boolean): void; getQuorum(): IQuorumClients; getAudience(): IAudience; uploadBlob(blob: ArrayBufferLike, signal?: AbortSignal): Promise>; private createRemoteChannelContext; /** * Process channel messages. The messages here are contiguous channel types messages in a batch for this data * store. * @param messageCollection - The collection of messages to process. */ private processChannelMessages; private processAttachMessages; /** * Process messages for this data store. The messages here are contiguous messages in a batch. * @param messageCollection - The collection of messages to process. */ processMessages(messageCollection: IRuntimeMessageCollection): void; processSignal(message: IInboundSignalMessage, local: boolean): void; private isChannelAttached; /** * Returns the outbound routes of this channel. Currently, all contexts in this channel are considered * referenced and are hence outbound. This will change when we have root and non-root channel contexts. * The only root contexts will be considered as referenced. */ private getOutboundRoutes; /** * Updates the GC nodes of this channel. It does the following: * - Adds a back route to self to all its child GC nodes. * - Adds a node for this channel. * @param builder - The builder that contains the GC nodes for this channel's children. */ private updateGCNodes; /** * Returns a summary at the current sequence number. * @param fullTree - true to bypass optimizations and force a full summary tree * @param trackState - This tells whether we should track state from this summary. * @param telemetryContext - summary data passed through the layers for telemetry purposes */ summarize(fullTree?: boolean, trackState?: boolean, telemetryContext?: ITelemetryContext): Promise; /** * Generates data used for garbage collection. This includes a list of GC nodes that represent this channel * including any of its child channel contexts. Each node has a set of outbound routes to other GC nodes in the * document. It does the following: * * 1. Calls into each child context to get its GC data. * * 2. Prefixes the child context's id to the GC nodes in the child's GC data. This makes sure that the node can be * identified as belonging to the child. * * 3. Adds a GC node for this channel to the nodes received from the children. All these nodes together represent * the GC data of this channel. * * @param fullGC - true to bypass optimizations and force full generation of GC data. */ getGCData(fullGC?: boolean): Promise; /** * After GC has run, called to notify this channel of routes that are used in it. It calls the child contexts to * update their used routes. * @param usedRoutes - The routes that are used in all contexts in this channel. */ updateUsedRoutes(usedRoutes: string[]): void; getAttachSummary(telemetryContext?: ITelemetryContext): ISummaryTreeWithStats; /** * Get the GC Data for the initial state being attached so remote clients can learn of this DataStore's outbound routes */ getAttachGCData(telemetryContext?: ITelemetryContext): IGarbageCollectionData; /** * Helper method for preparing to summarize this channel. * Runs the callback for each bound context to incorporate its data however the caller specifies */ private visitContextsDuringSummary; /** * Helper method for preparing to attach this dataStore. * Runs the callback for each bound context to incorporate its data however the caller specifies */ private visitLocalBoundContextsDuringAttach; /** * 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; /** * Will return when the data store is attached. */ waitAttached(): Promise; /** * Assuming this DataStore is already attached, this will make the given channel locally visible * by submitting its attach op. */ private makeChannelLocallyVisible; private submitChannelOp; /** * Count of pending ops that have been submitted but not yet ack'd. * Used to compute {@link FluidDataStoreRuntime.isDirty} */ private readonly pendingOpCount; private submit; /** * For messages of type MessageType.Operation, finds the right channel and asks it to resubmit the message. * For all other messages, just submit it again. * This typically happens when we reconnect and there are unacked messages. * @param content - The content of the original message. * @param localOpMetadata - The local metadata associated with the original message. * * @privateRemarks * `type` parameter's type of `DataStoreMessageType` is a covariance exception * over `string` that `IFluidDataStoreChannel` specifies. So long as local * submissions conform to this type all is well. (`unreachableCase` might be * reachable over time without better typing in this area if a mistake is made.) * See {@link @fluidframework/runtime-definitions#FluidDataStoreMessage} comment * for opportunity to resolve this. */ reSubmit(type: DataStoreMessageType, content: any, localOpMetadata: unknown, squash: boolean): void; /** * Revert a local op. * @param content - The content of the original message. * @param localOpMetadata - The local metadata associated with the original message. * * @privateRemarks * `type` parameter's type of `DataStoreMessageType` is a covariance exception * over `string` that `IFluidDataStoreChannel` specifies. So long as local * submissions conform to this type all is well. (`unreachableCase` might be * reachable over time without better typing in this area if a mistake is made.) * See {@link @fluidframework/runtime-definitions#FluidDataStoreMessage} comment * for opportunity to resolve this. */ rollback?(type: DataStoreMessageType, content: any, localOpMetadata: unknown): void; applyStashedOp(content: any): Promise; /** * Indicates the given channel is dirty from Summarizer's point of view, * i.e. it has local changes that need to be included in the summary. * * @remarks If a channel's changes are rolled back or rebased away, we won't * clear the dirty flag set here. */ private setChannelDirty; private verifyNotClosed; /** * Summarizer client should not have local changes. These changes can become part of the summary and can break * eventual consistency. For example, the next summary (say at ref seq# 100) may contain these changes whereas * other clients that are up-to-date till seq# 100 may not have them yet. */ private identifyLocalChangeInSummarizer; setAttachState(attachState: AttachState.Attaching | AttachState.Attached): void; } /** * Mixin class that adds request handler to FluidDataStoreRuntime * Request handler is only called when data store can't resolve request, i.e. for custom requests. * @param Base - base class, inherits from FluidDataStoreRuntime * @param requestHandler - request handler to mix in * @legacy @beta */ export declare const mixinRequestHandler: (requestHandler: (request: IRequest, runtime: FluidDataStoreRuntime) => Promise, Base?: typeof FluidDataStoreRuntime) => typeof FluidDataStoreRuntime; /** * Mixin class that adds await for DataObject to finish initialization before we proceed to summary. * @param handler - handler that returns info about blob to be added to summary. * Or undefined not to add anything to summary. * @param Base - base class, inherits from FluidDataStoreRuntime * @legacy @beta * @deprecated This API is deprecated and will be removed in a future release. There is no replacement for it. * @privateRemarks * This should not be removed until all consumers are migrated off using it. See AB#78575. */ export declare const mixinSummaryHandler: (handler: (runtime: FluidDataStoreRuntime, setCurrentSummarizeStep: (currentStep: string) => void) => Promise<{ path: string[]; content: string; } | undefined>, Base?: typeof FluidDataStoreRuntime) => typeof FluidDataStoreRuntime; //# sourceMappingURL=dataStoreRuntime.d.ts.map