import { AuthState } from '../auth/index.js'; import { SyncStatus } from '../client/model/shapes.js'; import { QualifiedTablename } from '../util/tablename.js'; import { ConnectivityState, DbName, RowId, DataChangeType, DbRecord } from '../util/types.js'; export { EventNotifier } from './event.js'; export { MockNotifier } from './mock.js'; export interface AuthStateNotification { authState: AuthState; } export type RecordChange = { primaryKey: DbRecord; type: `${DataChangeType}` | 'INITIAL'; }; export interface Change { qualifiedTablename: QualifiedTablename; rowids?: RowId[]; recordChanges?: RecordChange[]; } export type ChangeOrigin = 'local' | 'remote' | 'initial'; export interface ChangeNotification { dbName: DbName; changes: Change[]; origin: ChangeOrigin; } export interface PotentialChangeNotification { dbName: DbName; } export interface ConnectivityStateChangeNotification { dbName: DbName; connectivityState: ConnectivityState; } export interface ShapeSubscriptionSyncStatusChangeNotification { dbName: DbName; key: string; status: SyncStatus; } export type Notification = AuthStateNotification | ChangeNotification | PotentialChangeNotification | ConnectivityStateChangeNotification | ShapeSubscriptionSyncStatusChangeNotification; export type AuthStateCallback = (notification: AuthStateNotification) => void; export type ChangeCallback = (notification: ChangeNotification) => void; export type PotentialChangeCallback = (notification: PotentialChangeNotification) => void; export type ConnectivityStateChangeCallback = (notification: ConnectivityStateChangeNotification) => void; export type ShapeSubscriptionSyncStatusChangeCallback = (notification: ShapeSubscriptionSyncStatusChangeNotification) => void; export type NotificationCallback = AuthStateCallback | ChangeCallback | PotentialChangeCallback | ConnectivityStateChangeCallback | ShapeSubscriptionSyncStatusChangeCallback; export type UnsubscribeFunction = () => void; export interface Notifier { dbName: DbName; attach(dbName: DbName, dbAlias: string): void; detach(dbAlias: string): void; attachedDbIndex: { byAlias: { [key: string]: DbName; }; byName: { [key: DbName]: string; }; }; alias(notification: ChangeNotification): QualifiedTablename[]; authStateChanged(authState: AuthState): void; subscribeToAuthStateChanges(callback: AuthStateCallback): UnsubscribeFunction; potentiallyChanged(): void; subscribeToPotentialDataChanges(callback: PotentialChangeCallback): UnsubscribeFunction; actuallyChanged(dbName: DbName, changes: Change[], origin: ChangeOrigin): void; subscribeToDataChanges(callback: ChangeCallback): UnsubscribeFunction; connectivityStateChanged(dbName: string, state: ConnectivityState): void; subscribeToConnectivityStateChanges(callback: ConnectivityStateChangeCallback): UnsubscribeFunction; shapeSubscriptionSyncStatusChanged(dbName: DbName, key: string, status: SyncStatus): void; subscribeToShapeSubscriptionSyncStatusChanges(callback: ShapeSubscriptionSyncStatusChangeCallback): UnsubscribeFunction; }