import { FSDB_COLLECTION } from '@andyburke/fsdb'; import { by_lurid } from '@andyburke/fsdb/organizers'; import { FSDB_INDEXER_SYMLINKS } from '@andyburke/fsdb/indexers'; /** * @typedef {object} WATCH_TYPE_INFO * @property {boolean} ignored if true, this type should NOT produce any indications or notifications * @property {string} last_id_seen the last event id the user has seen for this event type * @property {string} last_id_notified the last event id the user was notified about for this type */ export type WATCH_TYPE_INFO = { ignored: boolean; last_id_seen: string; last_id_notified: string; }; /** * @typedef {object} WATCH_TIMESTAMPS * @property {string} created the created date of the watch * @property {string} updated the last updated date, usually coinciding with the last seen id being changed */ /** * WATCH * * @property {string} id - lurid (stable) * @property {string} creator_id - user id of the watch creator * @property {string} topic_id - the topic_id being watched * @property {[WATCH_TYPE_INFO]} types - information for types being watched within this topic * @property {Record} [meta] - optional metadata about the watch * @property {WATCH_TIMESTAMPS} timestamps - timestamps for the watch */ export type WATCH = { id: string; creator_id: string; topic_id: string; types: [WATCH_TYPE_INFO]; meta?: Record; timestamps: { created: string; updated: string; }; }; export const WATCHES = new FSDB_COLLECTION({ name: 'watches', id_field: 'id', organize: by_lurid, indexers: { creator_id: new FSDB_INDEXER_SYMLINKS({ name: 'creator_id', field: 'creator_id', to_many: true, organize: by_lurid }), topic_id: new FSDB_INDEXER_SYMLINKS({ name: 'topic_id', field: 'topic_id', to_many: true, organize: by_lurid }) } });