import { IFluidDataStoreRuntime , IChannelServices , IChannelAttributes , IChannelFactory , } from "@fluidframework/datastore-definitions" ; import { ISharedObject , ISharedObjectEvents } from "@fluidframework/shared-object-base" ; export enum ConsensusResult { Release , Complete } returns export type ConsensusCallback < T > = ( value : T ) => Promise < ConsensusResult > ; /**
 * Consensus Ordered Collection channel factory interface
 *
 * Extends the base IChannelFactory to return a more definite type of IConsensusOrderedCollection
 * Use for the runtime to create and load distributed data structure by type name of each channel
 */ export interface IConsensusOrderedCollectionFactory extends IChannelFactory { load ( document , id , services , attributes ) : Promise < IConsensusOrderedCollection > ; create ( document , id ) : IConsensusOrderedCollection ; } /**
 * Events notifying about addition, acquisition, release and completion of items
 */ export interface IConsensusOrderedCollectionEvents < T > extends ISharedObjectEvents { param newlyAdded ( event , listener ) : this ; /**
     * Event fires when a client acquired an item
     * Fires both for locally acquired items, as well as items acquired by remote clients
     */ ( event , listener ) : this ; /**
     * "Complete event fires when a client completes an item.
     */ ( event , listener ) : this ; param intentional ( event , listener ) : this ; } remarks export interface IConsensusOrderedCollection < T = any > extends ISharedObject < IConsensusOrderedCollectionEvents < T > > { /**
     * Adds a value to the collection
     */ add ( value ) : Promise < void > ; returns acquire ( callback ) : Promise < boolean > ; /**
     * Wait for a value to be available and remove it from the consensus collection
     * Calls callback with retrieved value.
     */ waitAndAcquire ( callback ) : Promise < void > ; } /**
 * Interface for object that can be snapshoted
 *
 * TODO: move this to be use in other place
 * TODO: currently input and output is not symmetrical, can they become symmetrical?
 */ export interface ISnapshotable < T > { asArray ( ) : T [ ] ; loadFrom ( values ) : void ; } /**
 * Ordered Collection interface
 *
 * Collection of objects that has deterministic add and remove ordering.
 * Object implementing this interface can be used as the data backing
 * for the ConsensusOrderedCollection
 */ export interface IOrderedCollection < T = any > extends ISnapshotable < T > { /**
     * Adds a value to the collection
     */ add ( value ) ; /**
     * Retrieves a value from the collection.
     */ remove ( ) : T ; /**
     * Return the size of the collection
     */ size ( ) : number ; }