import { IDocumentMessage , INack , INackContent , ISequencedDocumentMessage , ScopeType , } from "@fluidframework/protocol-definitions" ; import { LambdaName } from "./lambdas" ; export const RawOperationType = "RawOperation" ; export const SequencedOperationType = "SequencedOperation" ; export const NackOperationType = "Nack" ; export const SystemType = "System" ; export const BoxcarType = "boxcar" ; /**
 * Base class for messages placed on the distributed log
 */ export interface IMessage { type : string ; } export enum SystemOperations { Join , Leave } /**
 * Object that indicates a specific session/document in the system
 */ export interface IRoutingKey { tenantId : string ; documentId : string ; } export interface ISystemMessage extends IMessage { id : string ; group : string ; operation : any ; } /**
 * Message relating to an object
 */ export interface IObjectMessage extends IMessage , IRoutingKey { clientId : string | null ; timestamp : number ; } /**
 * Message sent when a client is updating their sequence number directly
 */ export interface IUpdateReferenceSequenceNumberMessage extends IObjectMessage { sequenceNumber : number ; } /**
 * Raw message inserted into the event hub queue
 */ export interface IRawOperationMessage extends IObjectMessage { type : typeof RawOperationType ; operation : IDocumentMessage ; } /**
 * A group of IRawOperationMessage objects. Used in receiving batches of ops from Kafka.
 */ export interface IRawOperationMessageBatch extends IRoutingKey { index : number ; contents : IRawOperationMessage [ ] ; } export interface ITicketedMessage extends IMessage , IRoutingKey { } /**
 * Message sent when a raw operation is nacked
 */ export interface INackMessage extends ITicketedMessage { type : typeof NackOperationType ; clientId : string ; operation : INack ; timestamp : number ; } /**
 * A sequenced operation
 */ export interface ISequencedOperationMessage extends ITicketedMessage { type : typeof SequencedOperationType ; operation : ISequencedDocumentMessage ; } export interface IBoxcarMessage extends ITicketedMessage { type : typeof BoxcarType ; contents : IMessage [ ] ; } /**
 * Control messages for service to service communication only
 */ export interface IControlMessage { type : string ; contents : any ; } /**
 * Control messages types
 */ export enum ControlMessageType { UpdateDSN = "updateDSN" , NackMessages = "nackMessages" , LambdaStartResult = "lambdaStartResult" } export interface IUpdateDSNControlMessageContents { durableSequenceNumber : number ; isClientSummary : boolean ; clearCache : boolean ; } /**
 * Nack messages types
 */ export enum NackMessagesType { SummaryMaxOps = "summaryMaxOps" } export interface INackMessagesControlMessageContents { /**
     * Identifier for the type/reason for this nack messages
     */ identifier : NackMessagesType | undefined ; /**
     * The INackContent to send when nacking the message
     */ content : INackContent ; /**
     * If a client has a scope in this list, there message will be allowed
     * If undefined, scope will not affect message nacking
     */ allowedScopes ? : ScopeType [ ] ; /**
     * Controls if system messages should be nacked
     */ allowSystemMessages ? : boolean ; } export interface ILambdaStartControlMessageContents { lambdaName : LambdaName ; success : boolean ; }