summaryrefslogtreecommitdiff
path: root/gui/src/types/nostrill.ts
blob: 13ec942af726c2f80651abae229b1c9ec704f7b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import type { NostrEvent } from "./nostr";
import type { FC, Poast } from "./trill";

export type UserType = { urbit: string } | { nostr: string };
export type UserProfile = {
  name: string;
  picture: string; // URL
  about: string;
  other: Record<string, any>;
};
export type DateObj = { month: number; day: number; year?: number };

export type PostWrapper =
  | { nostr: NostrPost }
  | { urbit: { post: Poast; nostr?: NostrMetadata } };
export type NostrPost = {
  relay: string;
  event: NostrEvent;
  post: Poast;
};
export type NostrMetadata = {
  pubkey: string;
  eventId: string;
  relay?: string;
  post: Poast;
};
export type Relays = Record<string, RelayStats>;
export type RelayStats = {
  start: number;
  wid: number;
  reqs: Record<string, number>;
};

export type Fact =
  | { nostr: NostrFact }
  | { post: PostFact }
  | { enga: EngaFact }
  | { fols: FolsFact }
  | { hark: Notification };

export type NostrFact =
  | { feed: NostrEvent[] }
  | { user: NostrEvent[] }
  | { thread: NostrEvent[] }
  | { event: NostrEvent }
  | { relays: Relays };

export type PostFact = { add: { post: Poast } } | { del: { post: Poast } };

export type EngaFact = { add: NostrEvent[] } | { del: NostrEvent[] };

export type FolsFact =
  | { new: { user: string; feed: FC; profile: UserProfile } }
  | { quit: string };

export type Notification =
  | { prof: NostrEvent[] }
  | { fols: NostrEvent[] }
  | { beg: NostrEvent[] }
  | { fans: NostrEvent[] }
  | { post: NostrEvent[] };