UNPKG

@towns-protocol/sdk

Version:

For more details, visit the following resources:

49 lines 2.73 kB
import { PersistedEvent, PersistedMiniblock, PersistedSyncedStream, SyncCookie, PayloadCaseType, ContentCaseType, StreamEvent } from '@towns-protocol/proto'; import { ParsedEvent, ParsedMiniblock, ExclusionFilter } from './types'; export interface ParsedPersistedSyncedStream { streamId: string; syncCookie: SyncCookie; lastSnapshotMiniblockNum: bigint; minipoolEvents: ParsedEvent[]; lastMiniblockNum: bigint; } export declare function isPersistedEvent(event: ParsedEvent, direction: 'forward' | 'backward'): boolean; export declare function persistedEventToParsedEvent(event: PersistedEvent): ParsedEvent | undefined; export declare function persistedMiniblockToParsedMiniblock(miniblock: PersistedMiniblock): ParsedMiniblock | undefined; export declare function parsedMiniblockToPersistedMiniblock(miniblock: ParsedMiniblock, direction: 'forward' | 'backward'): PersistedMiniblock; export declare function persistedSyncedStreamToParsedSyncedStream(streamId: string, stream: PersistedSyncedStream): ParsedPersistedSyncedStream | undefined; /** * Applies exclusion filters to miniblocks, similar to the Go backend implementation. * Returns new miniblocks with filtered events and partial flag set if any events were excluded. * * This function filters events based on their payload and content types, matching the behavior * of the Go backend's applyExclusionFilter function. Events that match any filter in the * exclusionFilter array are excluded from the returned miniblocks. * * @param miniblocks - Array of miniblocks to filter * @param exclusionFilter - Array of filters specifying which events to exclude * @returns Array of filtered miniblocks with partial flag set if events were excluded */ export declare function applyExclusionFilterToMiniblocks(miniblocks: ParsedMiniblock[], exclusionFilter: ExclusionFilter): ParsedMiniblock[]; /** * Determines if an event should be excluded based on exclusion filters. * Similar to the Go backend's shouldExcludeEvent function. */ export declare function shouldExcludeEvent(event: ParsedEvent, exclusionFilter: ExclusionFilter): boolean; /** * Extracts payload type and content type from a StreamEvent. * Similar to the Go backend's extractEventTypeInfo function. */ export declare function extractEventTypeInfo(event: StreamEvent): { payloadType: string; contentType: string; }; /** * Checks if the payload/content types match the EventFilter. * Similar to the Go backend's matchesEventFilter function. */ export declare function matchesEventFilter(payloadType: string, contentType: string, filter: { payload: PayloadCaseType | '*'; content: ContentCaseType | '*'; }): boolean; //# sourceMappingURL=streamUtils.d.ts.map