applesauce-common 6.2.0 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (224) hide show
  1. package/README.md +1 -0
  2. package/dist/casts/_circular-import.d.ts +3 -0
  3. package/dist/casts/_circular-import.js +3 -0
  4. package/dist/casts/app-handler.d.ts +56 -0
  5. package/dist/casts/app-handler.js +105 -0
  6. package/dist/casts/app-recommendation.d.ts +26 -0
  7. package/dist/casts/app-recommendation.js +41 -0
  8. package/dist/casts/external-identities.d.ts +9 -0
  9. package/dist/casts/external-identities.js +14 -0
  10. package/dist/casts/forum-thread.d.ts +17 -0
  11. package/dist/casts/forum-thread.js +31 -0
  12. package/dist/casts/git-issue.d.ts +18 -0
  13. package/dist/casts/git-issue.js +26 -0
  14. package/dist/casts/git-patch.d.ts +49 -0
  15. package/dist/casts/git-patch.js +88 -0
  16. package/dist/casts/git-pull-request.d.ts +67 -0
  17. package/dist/casts/git-pull-request.js +122 -0
  18. package/dist/casts/git-repository.d.ts +9 -0
  19. package/dist/casts/git-repository.js +16 -0
  20. package/dist/casts/git-thread.d.ts +33 -0
  21. package/dist/casts/git-thread.js +65 -0
  22. package/dist/casts/index.d.ts +11 -0
  23. package/dist/casts/index.js +11 -0
  24. package/dist/casts/napplet.d.ts +98 -0
  25. package/dist/casts/napplet.js +196 -0
  26. package/dist/casts/note.d.ts +8 -0
  27. package/dist/casts/note.js +21 -1
  28. package/dist/casts/nsite.d.ts +134 -0
  29. package/dist/casts/nsite.js +249 -0
  30. package/dist/casts/profile.d.ts +20 -0
  31. package/dist/casts/profile.js +30 -0
  32. package/dist/casts/reaction.d.ts +1 -1
  33. package/dist/casts/relay-discovery.d.ts +4 -0
  34. package/dist/casts/relay-discovery.js +9 -1
  35. package/dist/casts/report.d.ts +28 -15
  36. package/dist/casts/report.js +42 -19
  37. package/dist/casts/share.d.ts +1 -1
  38. package/dist/casts/torrent.d.ts +5 -0
  39. package/dist/casts/torrent.js +8 -1
  40. package/dist/casts/trusted-assertions.d.ts +2 -0
  41. package/dist/casts/trusted-assertions.js +19 -18
  42. package/dist/casts/user-status.d.ts +33 -0
  43. package/dist/casts/user-status.js +69 -0
  44. package/dist/casts/user.d.ts +7 -0
  45. package/dist/casts/user.js +20 -1
  46. package/dist/factories/app-handler.d.ts +31 -0
  47. package/dist/factories/app-handler.js +50 -0
  48. package/dist/factories/app-recommendation.d.ts +21 -0
  49. package/dist/factories/app-recommendation.js +28 -0
  50. package/dist/factories/chat-message.d.ts +37 -0
  51. package/dist/factories/chat-message.js +56 -0
  52. package/dist/factories/comment.d.ts +8 -7
  53. package/dist/factories/comment.js +2 -2
  54. package/dist/factories/external-identities.d.ts +17 -0
  55. package/dist/factories/external-identities.js +28 -0
  56. package/dist/factories/forum-thread.d.ts +34 -0
  57. package/dist/factories/forum-thread.js +50 -0
  58. package/dist/factories/git-applied-status.d.ts +39 -0
  59. package/dist/factories/git-applied-status.js +53 -0
  60. package/dist/factories/git-closed-status.d.ts +18 -0
  61. package/dist/factories/git-closed-status.js +24 -0
  62. package/dist/factories/git-draft-status.d.ts +18 -0
  63. package/dist/factories/git-draft-status.js +24 -0
  64. package/dist/factories/git-issue.d.ts +19 -0
  65. package/dist/factories/git-issue.js +25 -0
  66. package/dist/factories/git-open-status.d.ts +18 -0
  67. package/dist/factories/git-open-status.js +22 -0
  68. package/dist/factories/git-patch.d.ts +59 -0
  69. package/dist/factories/git-patch.js +102 -0
  70. package/dist/factories/git-pull-request-update.d.ts +23 -0
  71. package/dist/factories/git-pull-request-update.js +33 -0
  72. package/dist/factories/git-pull-request.d.ts +39 -0
  73. package/dist/factories/git-pull-request.js +64 -0
  74. package/dist/factories/index.d.ts +22 -0
  75. package/dist/factories/index.js +22 -0
  76. package/dist/factories/internal/git-pull-request.d.ts +19 -0
  77. package/dist/factories/internal/git-pull-request.js +26 -0
  78. package/dist/factories/internal/git-status.d.ts +11 -0
  79. package/dist/factories/internal/git-status.js +12 -0
  80. package/dist/factories/internal/git-thread.d.ts +19 -0
  81. package/dist/factories/internal/git-thread.js +29 -0
  82. package/dist/factories/internal/napplet-manifest.d.ts +52 -0
  83. package/dist/factories/internal/napplet-manifest.js +85 -0
  84. package/dist/factories/internal/nsite-manifest.d.ts +45 -0
  85. package/dist/factories/internal/nsite-manifest.js +68 -0
  86. package/dist/factories/legacy-message.d.ts +2 -0
  87. package/dist/factories/legacy-message.js +9 -2
  88. package/dist/factories/named-napplet.d.ts +20 -0
  89. package/dist/factories/named-napplet.js +30 -0
  90. package/dist/factories/named-nsite.d.ts +28 -0
  91. package/dist/factories/named-nsite.js +53 -0
  92. package/dist/factories/napplet-snapshot.d.ts +18 -0
  93. package/dist/factories/napplet-snapshot.js +38 -0
  94. package/dist/factories/nsite-snapshot.d.ts +18 -0
  95. package/dist/factories/nsite-snapshot.js +29 -0
  96. package/dist/factories/reaction.d.ts +3 -2
  97. package/dist/factories/report.d.ts +48 -0
  98. package/dist/factories/report.js +66 -0
  99. package/dist/factories/root-napplet.d.ts +18 -0
  100. package/dist/factories/root-napplet.js +24 -0
  101. package/dist/factories/root-nsite.d.ts +23 -0
  102. package/dist/factories/root-nsite.js +44 -0
  103. package/dist/factories/torrent.d.ts +24 -10
  104. package/dist/factories/torrent.js +48 -44
  105. package/dist/factories/trusted-provider-list.d.ts +23 -0
  106. package/dist/factories/trusted-provider-list.js +39 -0
  107. package/dist/factories/user-status.d.ts +26 -0
  108. package/dist/factories/user-status.js +52 -0
  109. package/dist/helpers/app-data.js +15 -7
  110. package/dist/helpers/app-handler.d.ts +43 -6
  111. package/dist/helpers/app-handler.js +53 -3
  112. package/dist/helpers/app-recommendation.d.ts +24 -0
  113. package/dist/helpers/app-recommendation.js +30 -0
  114. package/dist/helpers/bookmark.js +5 -2
  115. package/dist/helpers/comment.d.ts +11 -5
  116. package/dist/helpers/comment.js +7 -1
  117. package/dist/helpers/content.d.ts +3 -1
  118. package/dist/helpers/emoji-pack.js +11 -6
  119. package/dist/helpers/emoji.d.ts +2 -2
  120. package/dist/helpers/encrypted-content-cache.js +18 -1
  121. package/dist/helpers/external-id.js +13 -19
  122. package/dist/helpers/external-identities.d.ts +29 -0
  123. package/dist/helpers/external-identities.js +52 -0
  124. package/dist/helpers/file-metadata.js +5 -6
  125. package/dist/helpers/forum-thread.d.ts +10 -0
  126. package/dist/helpers/forum-thread.js +10 -0
  127. package/dist/helpers/gift-wrap.d.ts +40 -15
  128. package/dist/helpers/gift-wrap.js +110 -33
  129. package/dist/helpers/git-issue.d.ts +13 -0
  130. package/dist/helpers/git-issue.js +19 -0
  131. package/dist/helpers/git-patch.d.ts +41 -0
  132. package/dist/helpers/git-patch.js +73 -0
  133. package/dist/helpers/git-pull-request.d.ts +57 -0
  134. package/dist/helpers/git-pull-request.js +111 -0
  135. package/dist/helpers/git-repository.d.ts +4 -0
  136. package/dist/helpers/git-repository.js +16 -0
  137. package/dist/helpers/git-status.d.ts +44 -0
  138. package/dist/helpers/git-status.js +93 -0
  139. package/dist/helpers/git.d.ts +2 -0
  140. package/dist/helpers/git.js +4 -0
  141. package/dist/helpers/groups.d.ts +5 -2
  142. package/dist/helpers/groups.js +40 -18
  143. package/dist/helpers/hashtag.d.ts +4 -2
  144. package/dist/helpers/index.d.ts +10 -0
  145. package/dist/helpers/index.js +10 -0
  146. package/dist/helpers/lists.js +14 -2
  147. package/dist/helpers/lnurl.js +1 -1
  148. package/dist/helpers/mute.js +18 -7
  149. package/dist/helpers/napplet.d.ts +89 -0
  150. package/dist/helpers/napplet.js +144 -0
  151. package/dist/helpers/nsite.d.ts +90 -0
  152. package/dist/helpers/nsite.js +217 -0
  153. package/dist/helpers/relay-discovery.d.ts +4 -0
  154. package/dist/helpers/relay-discovery.js +8 -0
  155. package/dist/helpers/reports.d.ts +35 -0
  156. package/dist/helpers/reports.js +36 -5
  157. package/dist/helpers/threading.d.ts +4 -2
  158. package/dist/helpers/torrent.d.ts +9 -6
  159. package/dist/helpers/torrent.js +23 -15
  160. package/dist/helpers/trusted-assertions.d.ts +7 -0
  161. package/dist/helpers/trusted-assertions.js +41 -2
  162. package/dist/helpers/user-status.d.ts +13 -1
  163. package/dist/helpers/user-status.js +15 -0
  164. package/dist/models/app-handler.d.ts +21 -0
  165. package/dist/models/app-handler.js +47 -0
  166. package/dist/models/git.d.ts +34 -0
  167. package/dist/models/git.js +144 -0
  168. package/dist/models/index.d.ts +3 -0
  169. package/dist/models/index.js +3 -0
  170. package/dist/models/nsite.d.ts +22 -0
  171. package/dist/models/nsite.js +67 -0
  172. package/dist/models/thread.d.ts +4 -1
  173. package/dist/models/thread.js +34 -5
  174. package/dist/models/user-status.d.ts +8 -4
  175. package/dist/models/user-status.js +16 -22
  176. package/dist/observable/filter-timeline-by-mutes.d.ts +1 -1
  177. package/dist/observable/filter-timeline-by-mutes.js +5 -1
  178. package/dist/operations/app-handler.d.ts +24 -0
  179. package/dist/operations/app-handler.js +58 -0
  180. package/dist/operations/app-recommendation.d.ts +13 -0
  181. package/dist/operations/app-recommendation.js +40 -0
  182. package/dist/operations/calendar-event.js +3 -2
  183. package/dist/operations/chat-message.d.ts +9 -0
  184. package/dist/operations/chat-message.js +12 -0
  185. package/dist/operations/client.d.ts +1 -4
  186. package/dist/operations/client.js +1 -23
  187. package/dist/operations/comment.d.ts +9 -3
  188. package/dist/operations/comment.js +12 -9
  189. package/dist/operations/external-identities.d.ts +8 -0
  190. package/dist/operations/external-identities.js +23 -0
  191. package/dist/operations/forum-thread.d.ts +3 -0
  192. package/dist/operations/forum-thread.js +6 -0
  193. package/dist/operations/gift-wrap.js +38 -14
  194. package/dist/operations/git-issue.d.ts +18 -0
  195. package/dist/operations/git-issue.js +31 -0
  196. package/dist/operations/git-patch.d.ts +30 -0
  197. package/dist/operations/git-patch.js +75 -0
  198. package/dist/operations/git-pull-request.d.ts +29 -0
  199. package/dist/operations/git-pull-request.js +74 -0
  200. package/dist/operations/git-repository.js +4 -4
  201. package/dist/operations/git-status.d.ts +28 -0
  202. package/dist/operations/git-status.js +116 -0
  203. package/dist/operations/git-thread.d.ts +13 -0
  204. package/dist/operations/git-thread.js +39 -0
  205. package/dist/operations/index.d.ts +15 -0
  206. package/dist/operations/index.js +15 -0
  207. package/dist/operations/internal/git-commits.d.ts +2 -0
  208. package/dist/operations/internal/git-commits.js +16 -0
  209. package/dist/operations/napplet.d.ts +51 -0
  210. package/dist/operations/napplet.js +121 -0
  211. package/dist/operations/nsite.d.ts +51 -0
  212. package/dist/operations/nsite.js +112 -0
  213. package/dist/operations/reaction.d.ts +12 -2
  214. package/dist/operations/reaction.js +1 -1
  215. package/dist/operations/report.d.ts +33 -0
  216. package/dist/operations/report.js +60 -0
  217. package/dist/operations/stream.js +5 -4
  218. package/dist/operations/torrent.d.ts +1 -4
  219. package/dist/operations/torrent.js +24 -11
  220. package/dist/operations/trusted-providers.d.ts +14 -0
  221. package/dist/operations/trusted-providers.js +33 -0
  222. package/dist/operations/user-status.d.ts +11 -0
  223. package/dist/operations/user-status.js +29 -0
  224. package/package.json +9 -9
@@ -1,57 +1,80 @@
1
- import { of } from "rxjs";
2
- import { getReportServers, getReported } from "../helpers/reports.js";
1
+ import { combineLatest, of } from "rxjs";
2
+ import { getReportTargets, isReportIdentifier, isValidReport, getReportServers, getReported, } from "../helpers/reports.js";
3
3
  import { EventCast } from "./cast.js";
4
4
  import { castUser } from "./user.js";
5
5
  import { addRelayHintsToPointer } from "applesauce-core/helpers";
6
- const REPORT_KIND = 1984;
7
- function isValidReport(event) {
8
- return event.kind === REPORT_KIND;
9
- }
10
- /** Cast a kind 1984 event to a Report */
6
+ /** A NIP-56 report with typed targets and related users and events */
11
7
  export class Report extends EventCast {
8
+ /**
9
+ * Creates a report cast
10
+ * @throws if the event lacks valid report targets or context
11
+ */
12
12
  constructor(event, store) {
13
13
  if (!isValidReport(event))
14
14
  throw new Error("Invalid report");
15
15
  super(event, store);
16
16
  }
17
- /** Get the parsed report data (either a user or event report) */
17
+ /** Returns every explicitly reported target with its reason */
18
+ get targets() {
19
+ return getReportTargets(this.event);
20
+ }
21
+ /** Returns all explicitly reported users */
22
+ get reportedUsers() {
23
+ return this.targets.filter((t) => t.type === "user").map((t) => castUser(t.value, this.store));
24
+ }
25
+ /** Checks whether this report explicitly targets media */
26
+ get isBlobReport() {
27
+ return this.targets.some((t) => t.type === "blob");
28
+ }
29
+ /** Returns pointers to all reported events and blob context events */
30
+ get reportedEventPointers() {
31
+ return [...new Set(this.event.tags.filter((t) => t[0] === "e" && isReportIdentifier(t[1])).map((t) => t[1]))].map((id) => addRelayHintsToPointer({ id }, this.seen));
32
+ }
33
+ /** Subscribes to all reported events and blob context events */
34
+ get reportedEvents$() {
35
+ return this.$$ref("reportedEvents$", (store) => {
36
+ const pointers = this.reportedEventPointers;
37
+ return pointers.length ? combineLatest(pointers.map((p) => store.event(p))) : of([]);
38
+ });
39
+ }
40
+ /** Gets the parsed report data (either a user or event report) */
18
41
  get reported() {
19
42
  return getReported(this.event);
20
43
  }
21
- /** Check if this is a user report */
44
+ /** Checks if this is a user report */
22
45
  get isUserReport() {
23
46
  return this.reported?.type === "user";
24
47
  }
25
- /** Check if this is an event report */
48
+ /** Checks if this is an event report */
26
49
  get isEventReport() {
27
50
  return this.reported?.type === "event";
28
51
  }
29
- /** Get the reason for the report */
52
+ /** Gets the reason for the report */
30
53
  get reason() {
31
54
  return this.reported?.reason;
32
55
  }
33
- /** Get the comment/content of the report */
56
+ /** Gets the comment/content of the report */
34
57
  get comment() {
35
58
  if (!this.reported)
36
59
  return undefined;
37
- return this.reported.type === "event" ? this.reported.comment : this.reported.comment;
60
+ return this.reported.comment;
38
61
  }
39
- /** Get the pubkey of the user being reported */
62
+ /** Gets the pubkey of the user being reported */
40
63
  get reportedPubkey() {
41
64
  return this.reported?.pubkey;
42
65
  }
43
- /** Get the User being reported */
66
+ /** Gets the User being reported */
44
67
  get reportedUser() {
45
68
  const pubkey = this.reportedPubkey;
46
69
  if (!pubkey)
47
70
  return undefined;
48
71
  return castUser(pubkey, this.store);
49
72
  }
50
- /** Get the event ID being reported (for event reports) */
73
+ /** Gets the event ID being reported (for event reports) */
51
74
  get reportedEventId() {
52
75
  return this.reported?.type === "event" ? this.reported.id : undefined;
53
76
  }
54
- /** Get the event being reported (for event reports) */
77
+ /** Gets the event being reported (for event reports) */
55
78
  get reportedEvent$() {
56
79
  return this.$$ref("reportedEvent$", (store) => {
57
80
  const eventId = this.reportedEventId;
@@ -63,11 +86,11 @@ export class Report extends EventCast {
63
86
  return store.event(addRelayHintsToPointer(pointer, this.seen));
64
87
  });
65
88
  }
66
- /** Get the blob hashes being reported (for event reports with x tags) */
89
+ /** Gets the blob hashes being reported (for event reports with x tags) */
67
90
  get blobs() {
68
91
  return this.reported?.type === "event" ? this.reported.blobs : undefined;
69
92
  }
70
- /** Get the server URLs for blob reports */
93
+ /** Gets the server URLs for blob reports */
71
94
  get servers() {
72
95
  return getReportServers(this.event);
73
96
  }
@@ -9,7 +9,7 @@ export declare class Share extends EventCast<ShareEvent> {
9
9
  get embedded(): NostrEvent | undefined;
10
10
  get sharedAddressPointer(): import("nostr-tools/nip19").AddressPointer | undefined;
11
11
  get sharedEventPointer(): import("nostr-tools/nip19").EventPointer;
12
- get sharedPointer(): import("nostr-tools/nip19").EventPointer | import("nostr-tools/nip19").AddressPointer;
12
+ get sharedPointer(): import("nostr-tools/nip19").AddressPointer | import("nostr-tools/nip19").EventPointer;
13
13
  get shared$(): import("applesauce-core").ChainableObservable<NostrEvent | undefined>;
14
14
  get reactions$(): import("applesauce-core").ChainableObservable<Reaction[]>;
15
15
  }
@@ -4,6 +4,7 @@ import { CastRefEventStore, EventCast } from "./cast.js";
4
4
  import { Comment } from "./comment.js";
5
5
  import { Reaction } from "./reaction.js";
6
6
  import { Zap } from "./zap.js";
7
+ /** A cast for NIP-35 torrent events (kind 2003) */
7
8
  export declare class Torrent extends EventCast<TorrentEvent> {
8
9
  constructor(event: NostrEvent, store: CastRefEventStore);
9
10
  /** The BitTorrent info hash from the `x` tag */
@@ -20,12 +21,16 @@ export declare class Torrent extends EventCast<TorrentEvent> {
20
21
  get searchTags(): string[];
21
22
  /** The category path from the `tcat` identifier in `i` tags (e.g., "video,movie,4k") */
22
23
  get categoryPath(): string | undefined;
24
+ /** The category path split into its parts (e.g., ["video", "movie", "4k"]) */
25
+ get categoryPathParts(): string[];
23
26
  /** All external identifiers from `i` tags (excluding tcat and newznab, which are handled separately) */
24
27
  get externalIdentifiers(): import("../helpers/torrent.js").TorrentExternalIdentifier[];
25
28
  /** The magnet link for the torrent, built from the info hash, trackers, and title */
26
29
  get magnetLink(): string | undefined;
27
30
  /** Gets the NIP-22 comments to this event */
28
31
  get comments$(): import("applesauce-core").ChainableObservable<Comment[]>;
32
+ /** Gets the zaps on this torrent */
29
33
  get zaps$(): import("applesauce-core").ChainableObservable<Zap[]>;
34
+ /** Gets the reactions to this torrent */
30
35
  get reactions$(): import("applesauce-core").ChainableObservable<Reaction[]>;
31
36
  }
@@ -1,4 +1,4 @@
1
- import { getTorrentCategory, getTorrentCategoryPath, getTorrentExternalIdentifiers, getTorrentFiles, getTorrentInfoHash, getTorrentMagnetLink, getTorrentSearchTags, getTorrentTitle, getTorrentTrackers, isValidTorrent, } from "../helpers/torrent.js";
1
+ import { getTorrentCategory, getTorrentCategoryPath, getTorrentCategoryPathParts, getTorrentExternalIdentifiers, getTorrentFiles, getTorrentInfoHash, getTorrentMagnetLink, getTorrentSearchTags, getTorrentTitle, getTorrentTrackers, isValidTorrent, } from "../helpers/torrent.js";
2
2
  import { CommentsModel } from "../models/comments.js";
3
3
  import { ReactionsModel } from "../models/reactions.js";
4
4
  import { EventZapsModel } from "../models/zaps.js";
@@ -7,6 +7,7 @@ import { EventCast } from "./cast.js";
7
7
  import { Comment } from "./comment.js";
8
8
  import { Reaction } from "./reaction.js";
9
9
  import { Zap } from "./zap.js";
10
+ /** A cast for NIP-35 torrent events (kind 2003) */
10
11
  export class Torrent extends EventCast {
11
12
  constructor(event, store) {
12
13
  if (!isValidTorrent(event))
@@ -41,6 +42,10 @@ export class Torrent extends EventCast {
41
42
  get categoryPath() {
42
43
  return getTorrentCategoryPath(this.event);
43
44
  }
45
+ /** The category path split into its parts (e.g., ["video", "movie", "4k"]) */
46
+ get categoryPathParts() {
47
+ return getTorrentCategoryPathParts(this.event);
48
+ }
44
49
  /** All external identifiers from `i` tags (excluding tcat and newznab, which are handled separately) */
45
50
  get externalIdentifiers() {
46
51
  return getTorrentExternalIdentifiers(this.event);
@@ -53,9 +58,11 @@ export class Torrent extends EventCast {
53
58
  get comments$() {
54
59
  return this.$$ref("comments$", (store) => store.model(CommentsModel, this.event).pipe(castTimelineStream(Comment, store)));
55
60
  }
61
+ /** Gets the zaps on this torrent */
56
62
  get zaps$() {
57
63
  return this.$$ref("zaps$", (store) => store.model(EventZapsModel, this.event).pipe(castTimelineStream(Zap, store)));
58
64
  }
65
+ /** Gets the reactions to this torrent */
59
66
  get reactions$() {
60
67
  return this.$$ref("reactions$", (store) => store.model(ReactionsModel, this.event).pipe(castTimelineStream(Reaction, store)));
61
68
  }
@@ -55,6 +55,8 @@ export declare class TrustedProviderList extends EventCast<TrustedProviderListEv
55
55
  get unlocked(): boolean;
56
56
  /** Decrypt and unlock the hidden providers */
57
57
  unlock(signer: HiddenContentSigner): Promise<TrustedProvider[]>;
58
+ /** Returns providers trusted for one assertion kind and metric tag */
59
+ providersFor$(kind: number, tag: string): import("applesauce-core/observable").ChainableObservable<AssertionProvider[]>;
58
60
  /** Providers trusted for user rank (0–100) */
59
61
  get userRank$(): import("applesauce-core/observable").ChainableObservable<AssertionProvider[]>;
60
62
  /** Providers trusted for user follower count */
@@ -112,77 +112,78 @@ export class TrustedProviderList extends EventCast {
112
112
  #allProviders$() {
113
113
  return combineLatest([of(this.publicProviders), this.hiddenProviders$]).pipe(map(([pub, hidden]) => [...pub, ...(hidden ?? [])]));
114
114
  }
115
- #providersFor$(kind, tag) {
115
+ /** Returns providers trusted for one assertion kind and metric tag */
116
+ providersFor$(kind, tag) {
116
117
  return this.$$ref(`providers:${kind}:${tag}`, (store) => this.#allProviders$().pipe(map((all) => toAssertionProviders(all.filter((p) => p.kind === kind && p.tag === tag), store))));
117
118
  }
118
119
  // ── Kind 30382 (User assertion) provider observables ─────────────────────
119
120
  /** Providers trusted for user rank (0–100) */
120
121
  get userRank$() {
121
- return this.#providersFor$(USER_ASSERTION_KIND, "rank");
122
+ return this.providersFor$(USER_ASSERTION_KIND, "rank");
122
123
  }
123
124
  /** Providers trusted for user follower count */
124
125
  get userFollowers$() {
125
- return this.#providersFor$(USER_ASSERTION_KIND, "followers");
126
+ return this.providersFor$(USER_ASSERTION_KIND, "followers");
126
127
  }
127
128
  /** Providers trusted for user first post timestamp */
128
129
  get userFirstCreatedAt$() {
129
- return this.#providersFor$(USER_ASSERTION_KIND, "first_created_at");
130
+ return this.providersFor$(USER_ASSERTION_KIND, "first_created_at");
130
131
  }
131
132
  /** Providers trusted for user post count */
132
133
  get userPostCount$() {
133
- return this.#providersFor$(USER_ASSERTION_KIND, "post_cnt");
134
+ return this.providersFor$(USER_ASSERTION_KIND, "post_cnt");
134
135
  }
135
136
  /** Providers trusted for user reply count */
136
137
  get userReplyCount$() {
137
- return this.#providersFor$(USER_ASSERTION_KIND, "reply_cnt");
138
+ return this.providersFor$(USER_ASSERTION_KIND, "reply_cnt");
138
139
  }
139
140
  /** Providers trusted for user reactions count */
140
141
  get userReactionsCount$() {
141
- return this.#providersFor$(USER_ASSERTION_KIND, "reactions_cnt");
142
+ return this.providersFor$(USER_ASSERTION_KIND, "reactions_cnt");
142
143
  }
143
144
  /** Providers trusted for zap amount received */
144
145
  get userZapAmountReceived$() {
145
- return this.#providersFor$(USER_ASSERTION_KIND, "zap_amt_recd");
146
+ return this.providersFor$(USER_ASSERTION_KIND, "zap_amt_recd");
146
147
  }
147
148
  /** Providers trusted for zap amount sent */
148
149
  get userZapAmountSent$() {
149
- return this.#providersFor$(USER_ASSERTION_KIND, "zap_amt_sent");
150
+ return this.providersFor$(USER_ASSERTION_KIND, "zap_amt_sent");
150
151
  }
151
152
  /** Providers trusted for zap count received */
152
153
  get userZapCountReceived$() {
153
- return this.#providersFor$(USER_ASSERTION_KIND, "zap_cnt_recd");
154
+ return this.providersFor$(USER_ASSERTION_KIND, "zap_cnt_recd");
154
155
  }
155
156
  /** Providers trusted for zap count sent */
156
157
  get userZapCountSent$() {
157
- return this.#providersFor$(USER_ASSERTION_KIND, "zap_cnt_sent");
158
+ return this.providersFor$(USER_ASSERTION_KIND, "zap_cnt_sent");
158
159
  }
159
160
  /** Providers trusted for average daily zap amount received */
160
161
  get userZapAvgAmountDayReceived$() {
161
- return this.#providersFor$(USER_ASSERTION_KIND, "zap_avg_amt_day_recd");
162
+ return this.providersFor$(USER_ASSERTION_KIND, "zap_avg_amt_day_recd");
162
163
  }
163
164
  /** Providers trusted for average daily zap amount sent */
164
165
  get userZapAvgAmountDaySent$() {
165
- return this.#providersFor$(USER_ASSERTION_KIND, "zap_avg_amt_day_sent");
166
+ return this.providersFor$(USER_ASSERTION_KIND, "zap_avg_amt_day_sent");
166
167
  }
167
168
  /** Providers trusted for reports received count */
168
169
  get userReportsReceived$() {
169
- return this.#providersFor$(USER_ASSERTION_KIND, "reports_cnt_recd");
170
+ return this.providersFor$(USER_ASSERTION_KIND, "reports_cnt_recd");
170
171
  }
171
172
  /** Providers trusted for reports sent count */
172
173
  get userReportsSent$() {
173
- return this.#providersFor$(USER_ASSERTION_KIND, "reports_cnt_sent");
174
+ return this.providersFor$(USER_ASSERTION_KIND, "reports_cnt_sent");
174
175
  }
175
176
  /** Providers trusted for user common topics */
176
177
  get userTopics$() {
177
- return this.#providersFor$(USER_ASSERTION_KIND, "t");
178
+ return this.providersFor$(USER_ASSERTION_KIND, "t");
178
179
  }
179
180
  /** Providers trusted for user activity hours start */
180
181
  get userActivityHoursStart$() {
181
- return this.#providersFor$(USER_ASSERTION_KIND, "active_hours_start");
182
+ return this.providersFor$(USER_ASSERTION_KIND, "active_hours_start");
182
183
  }
183
184
  /** Providers trusted for user activity hours end */
184
185
  get userActivityHoursEnd$() {
185
- return this.#providersFor$(USER_ASSERTION_KIND, "active_hours_end");
186
+ return this.providersFor$(USER_ASSERTION_KIND, "active_hours_end");
186
187
  }
187
188
  }
188
189
  // ─── UserAssertion ───────────────────────────────────────────────────────────
@@ -0,0 +1,33 @@
1
+ import { ChainableObservable } from "applesauce-core";
2
+ import { User } from "applesauce-core/casts/user";
3
+ import { NostrEvent } from "applesauce-core/helpers/event";
4
+ import { UserStatusEvent, UserStatusPointer } from "../helpers/user-status.js";
5
+ import { CastRefEventStore, EventCast } from "./cast.js";
6
+ /** Cast for NIP-38 user status events (kind 30315) */
7
+ export declare class UserStatus extends EventCast<UserStatusEvent> {
8
+ constructor(event: NostrEvent, store: CastRefEventStore);
9
+ /** The status type ("general", "music", etc) */
10
+ get type(): import("../helpers/user-status.js").UserStatusType;
11
+ /** The status text */
12
+ get content(): string;
13
+ /** Whether the status has been cleared (empty content) */
14
+ get cleared(): boolean;
15
+ /** The unix timestamp when the status expires */
16
+ get expiration(): number | undefined;
17
+ /** The URL, profile, event, or address the status links to */
18
+ get link(): UserStatusPointer | null;
19
+ /** The URL the status links to */
20
+ get url(): string | undefined;
21
+ /** The user the status links to */
22
+ get user(): User | undefined;
23
+ /** The event the status links to */
24
+ get linkedEvent$(): ChainableObservable<NostrEvent | undefined>;
25
+ }
26
+ declare module "applesauce-core/casts" {
27
+ interface User {
28
+ /** The user's "general" status */
29
+ get status$(): ChainableObservable<UserStatus | undefined>;
30
+ /** All of the user's statuses that have not been cleared */
31
+ get statuses$(): ChainableObservable<UserStatus[]>;
32
+ }
33
+ }
@@ -0,0 +1,69 @@
1
+ import { castUser, User } from "applesauce-core/casts/user";
2
+ import { getExpirationTimestamp } from "applesauce-core/helpers/expiration";
3
+ import { kinds } from "applesauce-core/helpers/event";
4
+ import { addRelayHintsToPointer } from "applesauce-core/helpers";
5
+ import { map, of } from "rxjs";
6
+ import { getUserStatusPointer, getUserStatusType, isUserStatusCleared, isValidUserStatus, } from "../helpers/user-status.js";
7
+ import { castEventStream, castTimelineStream } from "../observable/cast-stream.js";
8
+ import { EventCast } from "./cast.js";
9
+ /** Cast for NIP-38 user status events (kind 30315) */
10
+ export class UserStatus extends EventCast {
11
+ constructor(event, store) {
12
+ if (!isValidUserStatus(event))
13
+ throw new Error("Invalid user status");
14
+ super(event, store);
15
+ }
16
+ /** The status type ("general", "music", etc) */
17
+ get type() {
18
+ return getUserStatusType(this.event);
19
+ }
20
+ /** The status text */
21
+ get content() {
22
+ return this.event.content;
23
+ }
24
+ /** Whether the status has been cleared (empty content) */
25
+ get cleared() {
26
+ return isUserStatusCleared(this.event);
27
+ }
28
+ /** The unix timestamp when the status expires */
29
+ get expiration() {
30
+ return getExpirationTimestamp(this.event);
31
+ }
32
+ /** The URL, profile, event, or address the status links to */
33
+ get link() {
34
+ return getUserStatusPointer(this.event);
35
+ }
36
+ /** The URL the status links to */
37
+ get url() {
38
+ const pointer = this.link;
39
+ return pointer?.type === "url" ? pointer.data : undefined;
40
+ }
41
+ /** The user the status links to */
42
+ get user() {
43
+ const pointer = this.link;
44
+ return pointer?.type === "nprofile" ? castUser(pointer.data, this.store) : undefined;
45
+ }
46
+ /** The event the status links to */
47
+ get linkedEvent$() {
48
+ return this.$$ref("linkedEvent$", (store) => {
49
+ const pointer = this.link;
50
+ if (pointer?.type !== "nevent" && pointer?.type !== "naddr")
51
+ return of(undefined);
52
+ return store.event(addRelayHintsToPointer(pointer.data, this.seen));
53
+ });
54
+ }
55
+ }
56
+ Object.defineProperty(User.prototype, "status$", {
57
+ get() {
58
+ return this.$$ref("status$", (store) => store.replaceable({ kind: kinds.UserStatuses, pubkey: this.pubkey, identifier: "general" }).pipe(castEventStream(UserStatus, store), map((status) => (status && !status.cleared ? status : undefined))));
59
+ },
60
+ configurable: true,
61
+ enumerable: false,
62
+ });
63
+ Object.defineProperty(User.prototype, "statuses$", {
64
+ get() {
65
+ return this.$$ref("statuses$", (store) => store.timeline({ kinds: [kinds.UserStatuses], authors: [this.pubkey] }).pipe(castTimelineStream(UserStatus, store), map((statuses) => statuses.filter((status) => !status.cleared))));
66
+ },
67
+ configurable: true,
68
+ enumerable: false,
69
+ });
@@ -2,6 +2,10 @@ import { ChainableObservable } from "../observable/chainable.js";
2
2
  export { castUser, User } from "applesauce-core/casts";
3
3
  declare module "applesauce-core/casts" {
4
4
  interface User {
5
+ /** Subscribes to reports referencing this user in the store */
6
+ get reports$(): ChainableObservable<import("./report.js").Report[]>;
7
+ /** Subscribes to reports published by this user in the store */
8
+ get reportsSent$(): ChainableObservable<import("./report.js").Report[]>;
5
9
  get profile$(): ChainableObservable<import("./profile.js").Profile | undefined>;
6
10
  get contacts$(): ChainableObservable<User[]>;
7
11
  get mutes$(): ChainableObservable<import("./mutes.js").Mutes | undefined>;
@@ -16,7 +20,10 @@ declare module "applesauce-core/casts" {
16
20
  get favoriteRelays$(): ChainableObservable<import("./relay-lists.js").FavoriteRelays | undefined>;
17
21
  get gitAuthors$(): ChainableObservable<import("./git-lists.js").GitAuthors | undefined>;
18
22
  get favoriteGitRepos$(): ChainableObservable<import("./git-lists.js").FavoriteGitRepos | undefined>;
23
+ get identities$(): ChainableObservable<import("./external-identities.js").ExternalIdentities | undefined>;
19
24
  get graspServers$(): ChainableObservable<import("./git-grasp-list.js").GitGraspList | undefined>;
25
+ /** Subscribes to the git repositories announced by the user that are in the event store */
26
+ get gitRepositories$(): ChainableObservable<import("./git-repository.js").GitRepository[]>;
20
27
  get searchRelays$(): ChainableObservable<import("./relay-lists.js").SearchRelays | undefined>;
21
28
  get lookupRelayList$(): ChainableObservable<import("./relay-lists.js").LookupRelayList | undefined>;
22
29
  get blockedRelays$(): ChainableObservable<import("./relay-lists.js").BlockedRelays | undefined>;
@@ -1,15 +1,18 @@
1
+ import { REPORT_KIND, isValidReport } from "../helpers/reports.js";
1
2
  import { castUser as coreCastUser, User } from "applesauce-core/casts";
2
3
  import { kinds, nprofileEncode } from "applesauce-core/helpers";
3
4
  import { combineLatest, defer, from, map, ReplaySubject, share, switchMap, tap } from "rxjs";
4
5
  import { BLOSSOM_SERVER_LIST_KIND, getBlossomServersFromList } from "../helpers/blossom.js";
5
6
  import { FAVORITE_EMOJI_PACKS_KIND } from "../helpers/emoji-pack.js";
7
+ import { EXTERNAL_IDENTITIES_KIND } from "../helpers/external-identities.js";
6
8
  import { GIT_GRASP_LIST_KIND } from "../helpers/git-grasp-list.js";
7
9
  import { GIT_AUTHORS_KIND, FAVORITE_GIT_REPOS_KIND } from "../helpers/git-lists.js";
10
+ import { GIT_REPOSITORY_KIND } from "../helpers/git-repository.js";
8
11
  import { GROUPS_LIST_KIND } from "../helpers/groups.js";
9
12
  import { getRelaysFromList } from "../helpers/lists.js";
10
13
  import { FAVORITE_RELAYS_KIND, LOOKUP_RELAY_LIST_KIND } from "../helpers/relay-list.js";
11
14
  import { TRUSTED_PROVIDER_LIST_KIND } from "../helpers/trusted-assertions.js";
12
- import { castEventStream } from "../observable/cast-stream.js";
15
+ import { castEventStream, castTimelineStream } from "../observable/cast-stream.js";
13
16
  // Re-export castUser and User from core so consumers don't need to change imports
14
17
  export { castUser, User } from "applesauce-core/casts";
15
18
  function memoize() {
@@ -51,6 +54,12 @@ Object.defineProperty(User.prototype, "nprofile", {
51
54
  configurable: true,
52
55
  enumerable: false,
53
56
  });
57
+ defineGetter("reports$", function () {
58
+ return this.$$ref("reports$", (store) => Circular.pipe(switchMap(({ Report }) => store.timeline({ kinds: [REPORT_KIND], "#p": [this.pubkey] }).pipe(map((events) => events.filter(isValidReport)), castTimelineStream(Report, store)))));
59
+ });
60
+ defineGetter("reportsSent$", function () {
61
+ return this.$$ref("reportsSent$", (store) => Circular.pipe(switchMap(({ Report }) => store.timeline({ kinds: [REPORT_KIND], authors: [this.pubkey] }).pipe(map((events) => events.filter(isValidReport)), castTimelineStream(Report, store)))));
62
+ });
54
63
  defineGetter("profile$", function () {
55
64
  return this.$$ref("profile$", (store) => Circular.pipe(switchMap(({ Profile }) => store.replaceable({ kind: kinds.Metadata, pubkey: this.pubkey }).pipe(castEventStream(Profile, store)))));
56
65
  });
@@ -98,11 +107,21 @@ defineGetter("favoriteGitRepos$", function () {
98
107
  .replaceable({ kind: FAVORITE_GIT_REPOS_KIND, pubkey: this.pubkey, relays: outboxes })
99
108
  .pipe(castEventStream(FavoriteGitRepos, store)))));
100
109
  });
110
+ defineGetter("identities$", function () {
111
+ return this.$$ref("identities$", (store) => combineLatest([Circular, this.outboxes$]).pipe(switchMap(([{ ExternalIdentities }, outboxes]) => store
112
+ .replaceable({ kind: EXTERNAL_IDENTITIES_KIND, pubkey: this.pubkey, relays: outboxes })
113
+ .pipe(castEventStream(ExternalIdentities, store)))));
114
+ });
101
115
  defineGetter("graspServers$", function () {
102
116
  return this.$$ref("graspServers$", (store) => combineLatest([Circular, this.outboxes$]).pipe(switchMap(([{ GitGraspList }, outboxes]) => store
103
117
  .replaceable({ kind: GIT_GRASP_LIST_KIND, pubkey: this.pubkey, relays: outboxes })
104
118
  .pipe(castEventStream(GitGraspList, store)))));
105
119
  });
120
+ defineGetter("gitRepositories$", function () {
121
+ return this.$$ref("gitRepositories$", (store) => Circular.pipe(switchMap(({ GitRepository }) => store
122
+ .timeline({ kinds: [GIT_REPOSITORY_KIND], authors: [this.pubkey] })
123
+ .pipe(castTimelineStream(GitRepository, store)))));
124
+ });
106
125
  defineGetter("searchRelays$", function () {
107
126
  return this.$$ref("searchRelays$", (store) => combineLatest([Circular, this.outboxes$]).pipe(switchMap(([{ SearchRelays }, outboxes]) => store
108
127
  .replaceable({ kind: kinds.SearchRelaysList, pubkey: this.pubkey, relays: outboxes })
@@ -0,0 +1,31 @@
1
+ import { EventFactory } from "applesauce-core/factories";
2
+ import { KnownEventTemplate, NostrEvent } from "applesauce-core/helpers/event";
3
+ import { AddressPointer } from "applesauce-core/helpers/pointers";
4
+ import { ProfileContent } from "applesauce-core/helpers/profile";
5
+ import { APP_HANDLER_KIND, HandlerLinkPlatform, HandlerLinkType } from "../helpers/app-handler.js";
6
+ /** An event template for a NIP-89 handler information event */
7
+ export type AppHandlerTemplate = KnownEventTemplate<typeof APP_HANDLER_KIND>;
8
+ /** Factory for NIP-89 handler information events (kind 31990) */
9
+ export declare class AppHandlerFactory extends EventFactory<typeof APP_HANDLER_KIND, AppHandlerTemplate> {
10
+ /** Creates a handler with the given identifier, or a random one */
11
+ static create(identifier?: string): AppHandlerFactory;
12
+ /**
13
+ * Creates a factory configured to modify an existing handler
14
+ * @throws if the event is not a valid handler information event
15
+ */
16
+ static modify(event: NostrEvent): AppHandlerFactory;
17
+ /** Sets the kind:0-style metadata, or clears it to use the author's profile */
18
+ metadata(metadata: ProfileContent | null): this;
19
+ /** Adds a supported event kind */
20
+ kind(kind: number): this;
21
+ /** Removes a supported event kind */
22
+ removeKind(kind: number): this;
23
+ /** Sets a URL template for a platform and NIP-19 entity type */
24
+ link(platform: HandlerLinkPlatform, url: string, type?: HandlerLinkType): this;
25
+ /** Removes a URL template for a platform and NIP-19 entity type */
26
+ removeLink(platform: HandlerLinkPlatform, type?: HandlerLinkType): this;
27
+ /** Sets or removes the named nsite the handler currently serves */
28
+ latest(site: AddressPointer | string | null): this;
29
+ /** Sets or removes the named nsite the handler is rolling out */
30
+ next(site: AddressPointer | string | null): this;
31
+ }
@@ -0,0 +1,50 @@
1
+ import { blankEventTemplate, EventFactory, toEventTemplate } from "applesauce-core/factories";
2
+ import { includeSingletonTag } from "applesauce-core/operations/tags";
3
+ import { APP_HANDLER_KIND, isValidAppHandler } from "../helpers/app-handler.js";
4
+ import { addHandlerKind, removeHandlerKind, removeHandlerLink, setHandlerLatest, setHandlerLink, setHandlerMetadata, setHandlerNext, } from "../operations/app-handler.js";
5
+ /** Factory for NIP-89 handler information events (kind 31990) */
6
+ export class AppHandlerFactory extends EventFactory {
7
+ /** Creates a handler with the given identifier, or a random one */
8
+ static create(identifier) {
9
+ // The blank template already has a random identifier
10
+ const factory = new AppHandlerFactory((res) => res(blankEventTemplate(APP_HANDLER_KIND)));
11
+ return identifier ? factory.chain(includeSingletonTag(["d", identifier])) : factory;
12
+ }
13
+ /**
14
+ * Creates a factory configured to modify an existing handler
15
+ * @throws if the event is not a valid handler information event
16
+ */
17
+ static modify(event) {
18
+ if (!isValidAppHandler(event))
19
+ throw new Error("Expected a NIP-89 handler information event");
20
+ return new AppHandlerFactory((res) => res(toEventTemplate(event)));
21
+ }
22
+ /** Sets the kind:0-style metadata, or clears it to use the author's profile */
23
+ metadata(metadata) {
24
+ return this.chain(setHandlerMetadata(metadata));
25
+ }
26
+ /** Adds a supported event kind */
27
+ kind(kind) {
28
+ return this.chain(addHandlerKind(kind));
29
+ }
30
+ /** Removes a supported event kind */
31
+ removeKind(kind) {
32
+ return this.chain(removeHandlerKind(kind));
33
+ }
34
+ /** Sets a URL template for a platform and NIP-19 entity type */
35
+ link(platform, url, type) {
36
+ return this.chain(setHandlerLink(platform, url, type));
37
+ }
38
+ /** Removes a URL template for a platform and NIP-19 entity type */
39
+ removeLink(platform, type) {
40
+ return this.chain(removeHandlerLink(platform, type));
41
+ }
42
+ /** Sets or removes the named nsite the handler currently serves */
43
+ latest(site) {
44
+ return this.chain(setHandlerLatest(site));
45
+ }
46
+ /** Sets or removes the named nsite the handler is rolling out */
47
+ next(site) {
48
+ return this.chain(setHandlerNext(site));
49
+ }
50
+ }
@@ -0,0 +1,21 @@
1
+ import { EventFactory } from "applesauce-core/factories";
2
+ import { KnownEventTemplate, NostrEvent } from "applesauce-core/helpers/event";
3
+ import { AddressPointer } from "applesauce-core/helpers/pointers";
4
+ import { HandlerLinkPlatform } from "../helpers/app-handler.js";
5
+ import { APP_RECOMMENDATION_KIND } from "../helpers/app-recommendation.js";
6
+ /** An event template for a NIP-89 handler recommendation */
7
+ export type AppRecommendationTemplate = KnownEventTemplate<typeof APP_RECOMMENDATION_KIND>;
8
+ /** Factory for NIP-89 handler recommendations (kind 31989) */
9
+ export declare class AppRecommendationFactory extends EventFactory<typeof APP_RECOMMENDATION_KIND, AppRecommendationTemplate> {
10
+ /** Creates a recommendation for handlers of an event kind */
11
+ static create(kind: number): AppRecommendationFactory;
12
+ /**
13
+ * Creates a factory configured to modify an existing recommendation
14
+ * @throws if the event is not a valid handler recommendation
15
+ */
16
+ static modify(event: NostrEvent): AppRecommendationFactory;
17
+ /** Adds or replaces a recommended handler for a platform */
18
+ handler(handler: AddressPointer | string, platform?: HandlerLinkPlatform): this;
19
+ /** Removes a recommended handler for every platform, one platform, or only the entry without a platform when `null` */
20
+ removeHandler(handler: AddressPointer | string, platform?: HandlerLinkPlatform | null): this;
21
+ }
@@ -0,0 +1,28 @@
1
+ import { blankEventTemplate, EventFactory, toEventTemplate } from "applesauce-core/factories";
2
+ import { includeSingletonTag } from "applesauce-core/operations/tags";
3
+ import { APP_RECOMMENDATION_KIND, isValidAppRecommendation } from "../helpers/app-recommendation.js";
4
+ import { addRecommendedHandler, removeRecommendedHandler } from "../operations/app-recommendation.js";
5
+ /** Factory for NIP-89 handler recommendations (kind 31989) */
6
+ export class AppRecommendationFactory extends EventFactory {
7
+ /** Creates a recommendation for handlers of an event kind */
8
+ static create(kind) {
9
+ return new AppRecommendationFactory((res) => res(blankEventTemplate(APP_RECOMMENDATION_KIND))).chain(includeSingletonTag(["d", String(kind)]));
10
+ }
11
+ /**
12
+ * Creates a factory configured to modify an existing recommendation
13
+ * @throws if the event is not a valid handler recommendation
14
+ */
15
+ static modify(event) {
16
+ if (!isValidAppRecommendation(event))
17
+ throw new Error("Expected a NIP-89 handler recommendation event");
18
+ return new AppRecommendationFactory((res) => res(toEventTemplate(event)));
19
+ }
20
+ /** Adds or replaces a recommended handler for a platform */
21
+ handler(handler, platform) {
22
+ return this.chain(addRecommendedHandler(handler, platform));
23
+ }
24
+ /** Removes a recommended handler for every platform, one platform, or only the entry without a platform when `null` */
25
+ removeHandler(handler, platform) {
26
+ return this.chain(removeRecommendedHandler(handler, platform));
27
+ }
28
+ }