Add DittoEvent and DittoFilter dedicated interface modules

This commit is contained in:
Alex Gleason 2024-01-23 11:17:31 -06:00
parent 789ce80990
commit f58c2098f0
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
3 changed files with 40 additions and 0 deletions

View File

@ -91,6 +91,8 @@ export {
type LNURLDetails,
type MapCache,
NIP05,
type NostrEvent,
type NostrFilter,
} from 'https://gitlab.com/soapbox-pub/nlib/-/raw/5d711597f3b2a163817cc1fb0f1f3ce8cede7cf7/mod.ts';
export type * as TypeFest from 'npm:type-fest@^4.3.0';

View File

@ -0,0 +1,24 @@
import { type NostrEvent } from '@/deps.ts';
/** Ditto internal stats for the event's author. */
export interface AuthorStats {
followers_count: number;
following_count: number;
notes_count: number;
}
/** Ditto internal stats for the event. */
export interface EventStats {
replies_count: number;
reposts_count: number;
reactions_count: number;
}
/** Internal Event representation used by Ditto, including extra keys. */
export interface DittoEvent extends NostrEvent {
author?: DittoEvent;
author_stats?: AuthorStats;
event_stats?: EventStats;
d_author?: DittoEvent;
user?: DittoEvent;
}

View File

@ -0,0 +1,14 @@
import { type NostrEvent, type NostrFilter } from '@/deps.ts';
import { type DittoEvent } from './DittoEvent.ts';
/** Additional properties that may be added by Ditto to events. */
export type DittoRelation = Exclude<keyof DittoEvent, keyof NostrEvent>;
/** Custom filter interface that extends Nostr filters with extra options for Ditto. */
export interface DittoFilter extends NostrFilter {
/** Whether the event was authored by a local user. */
local?: boolean;
/** Additional fields to add to the returned event. */
relations?: DittoRelation[];
}