@atproto/ozone
Version:
Backend service for moderating the Bluesky network.
60 lines • 1.71 kB
TypeScript
import { WebSocketKeepAlive } from '@atproto/xrpc-server';
type JetstreamRecord = Record<string, unknown>;
type OnCreateCallback<T extends JetstreamRecord> = (e: CommitCreateEvent<T>) => Promise<void>;
export type JetstreamOptions = {
endpoint: string;
/**
* The record collections that you want to receive updates for.
* Leave this empty to receive updates for all record collections.
*/
wantedCollections?: string[];
/**
* The DIDs that you want to receive updates for.
* Leave this empty to receive updates for all DIDs.
*/
wantedDids?: string[];
/**
* The Unix timestamp in microseconds that you want to receive updates from.
*/
cursor?: number;
};
export type EventBase = {
did: string;
time_us: number;
kind: 'commit';
};
export type CommitBase = {
collection: string;
rkey: string;
cid: string;
};
export interface CommitCreateEvent<RecordType extends JetstreamRecord> extends EventBase {
kind: 'commit';
commit: {
operation: 'create';
record: RecordType;
} & CommitBase;
}
export interface CommitDeleteEvent extends EventBase {
kind: 'commit';
commit: {
operation: 'delete';
} & CommitBase;
}
export declare class Jetstream {
ws?: WebSocketKeepAlive;
url: URL;
/** The current cursor. */
cursor?: number;
constructor(opts: JetstreamOptions);
start(options: {
onCreate?: Record<string, OnCreateCallback<any>>;
onDelete?: Record<string, (e: CommitDeleteEvent) => Promise<void>>;
}): Promise<void>;
/**
* Closes the WebSocket connection.
*/
close(): void;
}
export {};
//# sourceMappingURL=service.d.ts.map