import { IFluidHandle } from "@fluidframework/core-interfaces" ; import { IChannel } from "@fluidframework/datastore-definitions" ; import { IDocumentStorageService } from "@fluidframework/driver-definitions" ; import { ISequencedDocumentMessage , ISnapshotTree } from "@fluidframework/protocol-definitions" ; import { IGarbageCollectionData , ISummarizeResult , ISummaryTreeWithStats , } from "@fluidframework/runtime-definitions" ; import { addBlobToSummary } from "@fluidframework/runtime-utils" ; import { ChannelDeltaConnection } from "./channelDeltaConnection" ; import { ChannelStorageService } from "./channelStorageService" ; export const attributesBlobKey = ".attributes" ; export interface IChannelContext { getChannel ( ) : Promise < IChannel > ; setConnectionState ( connected , clientId ? ) ; processOp ( message , local , localOpMetadata ? ) : void ; summarize ( fullTree ? , trackState ? ) : Promise < ISummarizeResult > ; reSubmit ( content , localOpMetadata ) : void ; applyStashedOp ( content ) : unknown ; param fullGC getGCData ( fullGC ? ) : Promise < IGarbageCollectionData > ; /**
     * After GC has run, called to notify this context of routes that are used in it. These are used for the following:
     * 1. To identify if this context is being referenced in the document or not.
     * 2. To identify if this context or any of its children's used routes changed since last summary.
     * 3. They are added to the summary generated by this context.
     * 4. To update the timestamp when this context is marked as unreferenced.
     */ updateUsedRoutes ( usedRoutes , gcTimestamp ? ) : void ; } export function createServiceEndpoints ( id , connected , submitFn , dirtyFn , addedGCOutboundReferenceFn , storageService , tree ? , extraBlobs ? ) { const deltaConnection = new ChannelDeltaConnection ( id , connected , ( message , localOpMetadata ) => submitFn ( message , localOpMetadata ) , dirtyFn , addedGCOutboundReferenceFn ) ; const objectStorage = new ChannelStorageService ( tree , storageService , extraBlobs ) ; return { deltaConnection , objectStorage } ; } export function summarizeChannel ( channel , fullTree = false , trackState = false ) { const summarizeResult = channel . getAttachSummary ( fullTree , trackState ) ; addBlobToSummary ( summarizeResult , attributesBlobKey , JSON . stringify ( channel . attributes ) ) ; return summarizeResult ; } export async function summarizeChannelAsync ( channel , fullTree = false , trackState = false ) { const summarizeResult = await channel . summarize ( fullTree , trackState ) ; addBlobToSummary ( summarizeResult , attributesBlobKey , JSON . stringify ( channel . attributes ) ) ; return summarizeResult ; }