/*! * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ import type { AttributionKey } from "@fluidframework/runtime-definitions/internal"; import type { ISegment } from "./mergeTreeNodes.js"; /** * @legacy @beta */ export interface SequenceOffsets { /** * Parallel array with posBreakpoints which tracks the seq of insertion. * * @example * * If seqs is [45, 46] and posBreakpoints is [0, 3], the section of the string * between offsets 0 and 3 was inserted at seq 45 and the section of the string between * 3 and the length of the string was inserted at seq 46. * * @remarks We use null here rather than undefined as round-tripping through JSON converts * undefineds to null anyway */ seqs: (number | AttributionKey | null)[]; posBreakpoints: number[]; } /** * @legacy @beta */ export interface SerializedAttributionCollection extends SequenceOffsets { channels?: { [name: string]: SequenceOffsets; }; length: number; } /** * @legacy @beta */ export interface IAttributionCollectionSpec { root: Iterable<{ offset: number; key: T | null; }>; channels?: { [name: string]: Iterable<{ offset: number; key: T | null; }>; }; length: number; } /** * @legacy @beta * @sealed */ export interface IAttributionCollectionSerializer { /***/ serializeAttributionCollections(segments: Iterable<{ attribution?: IAttributionCollection; cachedLength: number; }>): SerializedAttributionCollection; /** * Populates attribution information on segments using the provided summary. */ populateAttributionCollections(segments: Iterable, summary: SerializedAttributionCollection): void; } /** * @legacy @beta */ export interface IAttributionCollection { /** * Retrieves the attribution key associated with the provided offset. * @param channel - When specified, gets an attribution key associated with a particular channel. */ getAtOffset(offset: number, channel?: string): AttributionKey | undefined; /** * Retrieves all the [Offset, Attribution key] pairs for the provided offset range. Note: * The returned array is sorted by offset. * The first offset in response could be lower than the startOffset as the Attribution Key for the startOffset * could start at a lower offset than the startOffset in case where Attribution key offset boundaries don't * align exactly with startOffset. * Example: If the Attribution Offsets in the segment is [0, 10, 20, 30, 40] and request is for (startOffset: 5, endOffset: 25), * then result would be [(offset: 0, key: key1), (offset:10, key: key2), (offset:20, key: key3)]. * @param channel - When specified, gets attribution keys associated with a particular channel. * @returns undefined if the provided channel is not found or list of attribution keys along with * the corresponding offset start boundary. */ getKeysInOffsetRange(startOffset: number, endOffset?: number, channel?: string): { offset: number; key: AttributionKey; }[] | undefined; /** * Total length of all attribution keys in this collection. */ readonly length: number; readonly channelNames: Iterable; /** * Retrieve all key/offset pairs stored on this segment. Entries should be ordered by offset, such that * the `i`th result's attribution key applies to offsets in the open range between the `i`th offset and the * `i+1`th offset. * The last entry's key applies to the open interval from the last entry's offset to this collection's length. */ getAll(): IAttributionCollectionSpec; /***/ splitAt(pos: number): IAttributionCollection; /***/ append(other: IAttributionCollection): void; /***/ clone(): IAttributionCollection; /** * Updates this collection with new attribution data. * @param name - Name of the channel that requires an update. Undefined signifies the root channel. * Updates apply only to the individual channel (i.e. if an attribution policy needs to update the root * channel and 4 other channels, it should call `.update` 5 times). * @param channel - Updated collection for that channel. */ update(name: string | undefined, channel: IAttributionCollection): void; } export declare function areEqualAttributionKeys(a: AttributionKey | null | undefined, b: AttributionKey | null | undefined): boolean; export declare class AttributionCollection implements IAttributionCollection { private _length; private offsets; private keys; private channels?; private get channelEntries(); constructor(_length: number, baseEntry?: AttributionKey | null); get channelNames(): string[]; getAtOffset(offset: number): AttributionKey; getAtOffset(offset: number, channel: string): AttributionKey | undefined; getKeysInOffsetRange(startOffset: number, endOffset?: number): { offset: number; key: AttributionKey; }[]; getKeysInOffsetRange(startOffset: number, endOffset?: number, channel?: string): { offset: number; key: AttributionKey; }[] | undefined; private findIndex; private get; get length(): number; /** * Splits this attribution collection into two with entries for [0, pos) and [pos, length). */ splitAt(pos: number): AttributionCollection; append(other: AttributionCollection): void; getAll(): IAttributionCollectionSpec; clone(): AttributionCollection; update(name: string | undefined, channel: AttributionCollection): void; /** * Rehydrates attribution information from its serialized form into the provided iterable of consecutive segments. */ static populateAttributionCollections(segments: ISegment[], summary: SerializedAttributionCollection): void; /** * Condenses attribution information on consecutive segments into a `SerializedAttributionCollection` * * Note: this operates on segments rather than attribution collections directly so that it can handle cases * where only some segments have attribution defined. */ static serializeAttributionCollections(segments: Iterable<{ attribution?: IAttributionCollection; cachedLength: number; }>): SerializedAttributionCollection; } //# sourceMappingURL=attributionCollection.d.ts.map