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,5 +1,8 @@
1
1
  import { getOrComputeCachedValue } from "applesauce-core/helpers/cache";
2
+ import { getReplaceableIdentifier, kinds } from "applesauce-core/helpers/event";
2
3
  import { getAddressPointerFromATag, getEventPointerFromETag, getProfilePointerFromPTag, } from "applesauce-core/helpers/pointers";
4
+ /** The event kind for NIP-38 user statuses */
5
+ export const USER_STATUS_KIND = kinds.UserStatuses;
3
6
  export const UserStatusPointerSymbol = Symbol.for("user-status-pointer");
4
7
  function getStatusPointer(status) {
5
8
  const pTag = status.tags.find((t) => t[0] === "p" && t[1]);
@@ -25,6 +28,18 @@ function getStatusPointer(status) {
25
28
  return { type: "url", data: rTag[1] };
26
29
  return null;
27
30
  }
31
+ /** Checks if an event is a valid NIP-38 user status */
32
+ export function isValidUserStatus(event) {
33
+ return !!event && event.kind === kinds.UserStatuses && event.tags.some((t) => t[0] === "d");
34
+ }
35
+ /** Gets the status type (the "d" tag) of a user status event */
36
+ export function getUserStatusType(status) {
37
+ return getReplaceableIdentifier(status);
38
+ }
39
+ /** Checks if a user status has been cleared (empty content) */
40
+ export function isUserStatusCleared(status) {
41
+ return status.content.trim() === "";
42
+ }
28
43
  /** Gets the {@link UserStatusPointer} for a status event */
29
44
  export function getUserStatusPointer(status) {
30
45
  return getOrComputeCachedValue(status, UserStatusPointerSymbol, () => getStatusPointer(status));
@@ -0,0 +1,21 @@
1
+ import { Model } from "applesauce-core/event-store";
2
+ import { ProfilePointer } from "applesauce-core/helpers/pointers";
3
+ import { AppHandlerEvent } from "../helpers/app-handler.js";
4
+ import { AppRecommendationEvent } from "../helpers/app-recommendation.js";
5
+ /** A handler ranked by the authors that recommend it */
6
+ export interface RankedAppHandler {
7
+ /** The handler information event */
8
+ handler: AppHandlerEvent;
9
+ /** The pubkeys of the authors recommending the handler */
10
+ recommenders: string[];
11
+ }
12
+ /** A model that returns NIP-89 handlers that advertise support for an event kind */
13
+ export declare function AppHandlersModel(kind: number): Model<AppHandlerEvent[]>;
14
+ /** A model that returns NIP-89 handler recommendations for an event kind, optionally from a set of authors */
15
+ export declare function AppRecommendationsModel(kind: number, authors?: string[]): Model<AppRecommendationEvent[]>;
16
+ /** A model that returns the handlers a user has published */
17
+ export declare function UserAppHandlersModel(user: string | ProfilePointer): Model<AppHandlerEvent[]>;
18
+ /** A model that returns a user's handler recommendations for every event kind */
19
+ export declare function UserAppRecommendationsModel(user: string | ProfilePointer): Model<AppRecommendationEvent[]>;
20
+ /** A model that returns the handlers recommended for an event kind, ranked by how many authors recommend each */
21
+ export declare function RecommendedAppHandlersModel(kind: number, authors?: string[]): Model<RankedAppHandler[]>;
@@ -0,0 +1,47 @@
1
+ import { getReplaceableAddressFromPointer } from "applesauce-core/helpers/pointers";
2
+ import { combineLatest, map, of, switchMap } from "rxjs";
3
+ import { APP_HANDLER_KIND, getAppHandlersFilter, isValidAppHandler } from "../helpers/app-handler.js";
4
+ import { APP_RECOMMENDATION_KIND, getAppRecommendationsFilter, getRecommendedHandlers, isValidAppRecommendation, } from "../helpers/app-recommendation.js";
5
+ /** A model that returns NIP-89 handlers that advertise support for an event kind */
6
+ export function AppHandlersModel(kind) {
7
+ return (store) => store.timeline(getAppHandlersFilter(kind)).pipe(map((events) => events.filter(isValidAppHandler)));
8
+ }
9
+ /** A model that returns NIP-89 handler recommendations for an event kind, optionally from a set of authors */
10
+ export function AppRecommendationsModel(kind, authors) {
11
+ return (store) => store
12
+ .timeline(getAppRecommendationsFilter(kind, authors))
13
+ .pipe(map((events) => events.filter(isValidAppRecommendation)));
14
+ }
15
+ /** A model that returns the handlers a user has published */
16
+ export function UserAppHandlersModel(user) {
17
+ const pubkey = typeof user === "string" ? user : user.pubkey;
18
+ return (store) => store
19
+ .timeline({ kinds: [APP_HANDLER_KIND], authors: [pubkey] })
20
+ .pipe(map((events) => events.filter(isValidAppHandler)));
21
+ }
22
+ /** A model that returns a user's handler recommendations for every event kind */
23
+ export function UserAppRecommendationsModel(user) {
24
+ const pubkey = typeof user === "string" ? user : user.pubkey;
25
+ return (store) => store
26
+ .timeline({ kinds: [APP_RECOMMENDATION_KIND], authors: [pubkey] })
27
+ .pipe(map((events) => events.filter(isValidAppRecommendation)));
28
+ }
29
+ /** A model that returns the handlers recommended for an event kind, ranked by how many authors recommend each */
30
+ export function RecommendedAppHandlersModel(kind, authors) {
31
+ return (store) => store.model(AppRecommendationsModel, kind, authors).pipe(switchMap((recommendations) => {
32
+ const ranked = new Map();
33
+ for (const recommendation of recommendations) {
34
+ // A set counts each author once, even if they list the handler for several platforms
35
+ for (const { pointer } of getRecommendedHandlers(recommendation)) {
36
+ const address = getReplaceableAddressFromPointer(pointer);
37
+ const entry = ranked.get(address) ?? { pointer, recommenders: new Set() };
38
+ entry.recommenders.add(recommendation.pubkey);
39
+ ranked.set(address, entry);
40
+ }
41
+ }
42
+ if (ranked.size === 0)
43
+ return of([]);
44
+ const entries = [...ranked.values()].sort((a, b) => b.recommenders.size - a.recommenders.size);
45
+ return combineLatest(entries.map((e) => store.replaceable(e.pointer))).pipe(map((events) => events.flatMap((handler, i) => isValidAppHandler(handler) ? [{ handler, recommenders: [...entries[i].recommenders] }] : [])));
46
+ }));
47
+ }
@@ -0,0 +1,34 @@
1
+ import { Model } from "applesauce-core/event-store";
2
+ import { NostrEvent } from "applesauce-core/helpers/event";
3
+ import { GitPatchEvent } from "../helpers/git-patch.js";
4
+ import { GitPullRequestEvent, GitPullRequestUpdateEvent, GitPullRequestState } from "../helpers/git-pull-request.js";
5
+ import { GitRepositoryPointer } from "../helpers/git-repository.js";
6
+ import { GitStatus, GitStatusEvent } from "../helpers/git-status.js";
7
+ /** A model that returns the latest authorized status event for an issue, patch or pull request */
8
+ export declare function GitStatusEventModel(root: NostrEvent, maintainers?: string[]): Model<GitStatusEvent | undefined>;
9
+ /** A model that returns the current status of an issue, patch or pull request */
10
+ export declare function GitStatusModel(root: NostrEvent, maintainers?: string[]): Model<GitStatus>;
11
+ /** A model that returns all NIP-22 comments in an issue, patch or pull request thread */
12
+ export declare function GitThreadCommentsModel(root: NostrEvent): Model<NostrEvent[]>;
13
+ /** A model that returns the updates to a pull request */
14
+ export declare function GitPullRequestUpdatesModel(pr: NostrEvent): Model<GitPullRequestUpdateEvent[]>;
15
+ /** A model that returns the latest complete fetch state of a pull request */
16
+ export declare function GitPullRequestStateModel(pr: GitPullRequestEvent): Model<GitPullRequestState>;
17
+ /** A model that resolves the first patch of the current series or revision */
18
+ export declare function GitPatchSeriesRootModel(patch: NostrEvent): Model<GitPatchEvent | undefined>;
19
+ /** A model that resolves the original root through patch and revision ancestors */
20
+ export declare function GitPatchOriginalRootModel(patch: NostrEvent): Model<GitPatchEvent | undefined>;
21
+ /** A model that returns patches in dependency order within a series, excluding other revisions */
22
+ export declare function GitPatchSeriesModel(patch: NostrEvent): Model<GitPatchEvent[]>;
23
+ /** A model that returns revision roots pointing to the original root patch */
24
+ export declare function GitPatchRevisionsModel(patch: NostrEvent): Model<GitPatchEvent[]>;
25
+ /** A model that returns the original root's latest authorized status event for a patch */
26
+ export declare function GitPatchStatusEventModel(patch: NostrEvent, maintainers?: string[]): Model<GitStatusEvent | undefined>;
27
+ /** A model that inherits original status and closes unaccepted revisions after application */
28
+ export declare function GitPatchStatusModel(patch: NostrEvent, maintainers?: string[]): Model<GitStatus>;
29
+ /** A model that returns the issues of a repository */
30
+ export declare function GitRepositoryIssuesModel(repo: GitRepositoryPointer): Model<NostrEvent[]>;
31
+ /** A model that returns the pull requests of a repository */
32
+ export declare function GitRepositoryPullRequestsModel(repo: GitRepositoryPointer): Model<NostrEvent[]>;
33
+ /** A model that returns the root patches (the first patch of each series) of a repository */
34
+ export declare function GitRepositoryPatchesModel(repo: GitRepositoryPointer): Model<NostrEvent[]>;
@@ -0,0 +1,144 @@
1
+ import { getReplaceableAddressFromPointer } from "applesauce-core/helpers/pointers";
2
+ import { combineLatest, map, of, switchMap } from "rxjs";
3
+ import { COMMENT_KIND, getCommentRootPointer, isValidComment } from "../helpers/comment.js";
4
+ import { GIT_ISSUE_KIND } from "../helpers/git-issue.js";
5
+ import { GIT_PATCH_KIND, getGitPatchPreviousPointer, isGitPatchRoot, isGitPatchRootRevision, isValidGitPatch, } from "../helpers/git-patch.js";
6
+ import { GIT_PULL_REQUEST_KIND, GIT_PULL_REQUEST_UPDATE_KIND, getGitPullRequestUpdateAuthor, getGitPullRequestUpdateTarget, getGitPullRequestState, isValidGitPullRequestUpdate, } from "../helpers/git-pull-request.js";
7
+ import { getGitRepositoryReference } from "../helpers/git-repository.js";
8
+ import { getGitCurrentStatusEvent, getGitStatusType, GIT_STATUS_KINDS, getGitStatusAcceptedRevisionId, getGitStatusAppliedPatchIds, } from "../helpers/git-status.js";
9
+ /** A model that returns the latest authorized status event for an issue, patch or pull request */
10
+ export function GitStatusEventModel(root, maintainers = []) {
11
+ return (store) => store
12
+ .timeline({ kinds: GIT_STATUS_KINDS, "#e": [root.id] })
13
+ .pipe(map((statuses) => getGitCurrentStatusEvent(root, statuses, maintainers)));
14
+ }
15
+ /** A model that returns the current status of an issue, patch or pull request */
16
+ export function GitStatusModel(root, maintainers = []) {
17
+ return (store) => store
18
+ .model(GitStatusEventModel, root, maintainers)
19
+ .pipe(map((status) => (status ? getGitStatusType(status) : "open")));
20
+ }
21
+ /** A model that returns all NIP-22 comments in an issue, patch or pull request thread */
22
+ export function GitThreadCommentsModel(root) {
23
+ return (store) => store.timeline({ kinds: [COMMENT_KIND], "#E": [root.id] }).pipe(map((comments) => comments.filter((event) => {
24
+ if (!isValidComment(event))
25
+ return false;
26
+ const pointer = getCommentRootPointer(event);
27
+ return pointer.type === "event" && pointer.id === root.id && pointer.kind === root.kind;
28
+ })));
29
+ }
30
+ /** A model that returns the updates to a pull request */
31
+ export function GitPullRequestUpdatesModel(pr) {
32
+ return (store) => store
33
+ .timeline({ kinds: [GIT_PULL_REQUEST_UPDATE_KIND], "#E": [pr.id] })
34
+ .pipe(map((updates) => updates.filter((update) => isValidGitPullRequestUpdate(update) &&
35
+ getGitPullRequestUpdateTarget(update) === pr.id &&
36
+ getGitPullRequestUpdateAuthor(update) === pr.pubkey &&
37
+ update.pubkey === pr.pubkey &&
38
+ update.created_at >= pr.created_at)));
39
+ }
40
+ /** A model that returns the latest complete fetch state of a pull request */
41
+ export function GitPullRequestStateModel(pr) {
42
+ return (store) => store.model(GitPullRequestUpdatesModel, pr).pipe(map((updates) => getGitPullRequestState(updates[0] ?? pr)));
43
+ }
44
+ function patchRootModel(patch, original, visited = []) {
45
+ return (store) => {
46
+ if (!isValidGitPatch(patch) || visited.includes(patch.id))
47
+ return of(undefined);
48
+ if (isGitPatchRoot(patch) && (!original || !isGitPatchRootRevision(patch)))
49
+ return of(patch);
50
+ const previous = getGitPatchPreviousPointer(patch);
51
+ if (!previous)
52
+ return of(undefined);
53
+ return store.event(previous).pipe(switchMap((parent) => {
54
+ if (!parent ||
55
+ getGitRepositoryReference(parent)?.pubkey !== getGitRepositoryReference(patch)?.pubkey ||
56
+ getGitRepositoryReference(parent)?.identifier !== getGitRepositoryReference(patch)?.identifier)
57
+ return of(undefined);
58
+ return patchRootModel(parent, original, [...visited, patch.id])(store);
59
+ }));
60
+ };
61
+ }
62
+ /** A model that resolves the first patch of the current series or revision */
63
+ export function GitPatchSeriesRootModel(patch) {
64
+ return patchRootModel(patch, false);
65
+ }
66
+ /** A model that resolves the original root through patch and revision ancestors */
67
+ export function GitPatchOriginalRootModel(patch) {
68
+ return patchRootModel(patch, true);
69
+ }
70
+ /** A model that returns patches in dependency order within a series, excluding other revisions */
71
+ export function GitPatchSeriesModel(patch) {
72
+ return (store) => store.model(GitPatchSeriesRootModel, patch).pipe(switchMap((root) => {
73
+ const repo = root && getGitRepositoryReference(root);
74
+ if (!root || !repo)
75
+ return of([]);
76
+ return store.timeline({ kinds: [GIT_PATCH_KIND], "#a": [getReplaceableAddressFromPointer(repo)] }).pipe(map((events) => {
77
+ const result = [root];
78
+ const seen = new Set([root.id]);
79
+ let frontier = [root.id];
80
+ while (frontier.length) {
81
+ const next = events
82
+ .filter((event) => isValidGitPatch(event) &&
83
+ !isGitPatchRoot(event) &&
84
+ !seen.has(event.id) &&
85
+ frontier.includes(getGitPatchPreviousPointer(event)?.id ?? ""))
86
+ .sort((a, b) => a.created_at - b.created_at || a.id.localeCompare(b.id));
87
+ result.push(...next);
88
+ frontier = next.map((event) => event.id);
89
+ for (const id of frontier)
90
+ seen.add(id);
91
+ }
92
+ return result;
93
+ }));
94
+ }));
95
+ }
96
+ /** A model that returns revision roots pointing to the original root patch */
97
+ export function GitPatchRevisionsModel(patch) {
98
+ return (store) => store.model(GitPatchOriginalRootModel, patch).pipe(switchMap((root) => {
99
+ if (!root)
100
+ return of([]);
101
+ return store
102
+ .timeline({ kinds: [GIT_PATCH_KIND], "#e": [root.id] })
103
+ .pipe(map((events) => events.filter((event) => isValidGitPatch(event) &&
104
+ isGitPatchRootRevision(event) &&
105
+ getGitPatchPreviousPointer(event)?.id === root.id &&
106
+ getGitRepositoryReference(event)?.pubkey === getGitRepositoryReference(root)?.pubkey &&
107
+ getGitRepositoryReference(event)?.identifier === getGitRepositoryReference(root)?.identifier)));
108
+ }));
109
+ }
110
+ /** A model that returns the original root's latest authorized status event for a patch */
111
+ export function GitPatchStatusEventModel(patch, maintainers = []) {
112
+ return (store) => store
113
+ .model(GitPatchOriginalRootModel, patch)
114
+ .pipe(switchMap((root) => (root ? store.model(GitStatusEventModel, root, maintainers) : of(undefined))));
115
+ }
116
+ /** A model that inherits original status and closes unaccepted revisions after application */
117
+ export function GitPatchStatusModel(patch, maintainers = []) {
118
+ return (store) => combineLatest([
119
+ store.model(GitPatchSeriesRootModel, patch),
120
+ store.model(GitPatchStatusEventModel, patch, maintainers),
121
+ store.model(GitPatchSeriesModel, patch),
122
+ ]).pipe(map(([seriesRoot, status, series]) => {
123
+ const type = status ? getGitStatusType(status) : "open";
124
+ if (type !== "applied" || !seriesRoot || !isGitPatchRootRevision(seriesRoot) || !status)
125
+ return type;
126
+ const accepted = getGitStatusAcceptedRevisionId(status);
127
+ const applied = getGitStatusAppliedPatchIds(status);
128
+ return accepted === seriesRoot.id || series.some((event) => applied.includes(event.id)) ? "applied" : "closed";
129
+ }));
130
+ }
131
+ /** A model that returns the issues of a repository */
132
+ export function GitRepositoryIssuesModel(repo) {
133
+ return (store) => store.timeline({ kinds: [GIT_ISSUE_KIND], "#a": [getReplaceableAddressFromPointer(repo)] });
134
+ }
135
+ /** A model that returns the pull requests of a repository */
136
+ export function GitRepositoryPullRequestsModel(repo) {
137
+ return (store) => store.timeline({ kinds: [GIT_PULL_REQUEST_KIND], "#a": [getReplaceableAddressFromPointer(repo)] });
138
+ }
139
+ /** A model that returns the root patches (the first patch of each series) of a repository */
140
+ export function GitRepositoryPatchesModel(repo) {
141
+ return (store) => store
142
+ .timeline({ kinds: [GIT_PATCH_KIND], "#a": [getReplaceableAddressFromPointer(repo)] })
143
+ .pipe(map((patches) => patches.filter(isGitPatchRoot)));
144
+ }
@@ -1,8 +1,10 @@
1
+ export * from "./app-handler.js";
1
2
  export * from "./blossom.js";
2
3
  export * from "./bookmarks.js";
3
4
  export * from "./calendar.js";
4
5
  export * from "./channels.js";
5
6
  export * from "./comments.js";
7
+ export * from "./git.js";
6
8
  export * from "./legacy-messages.js";
7
9
  export * from "./mutes.js";
8
10
  export * from "./pins.js";
@@ -18,3 +20,4 @@ export * from "./shares.js";
18
20
  export * from "./zap-goals.js";
19
21
  export * from "applesauce-core/models";
20
22
  import "./__register__.js";
23
+ export * from "./nsite.js";
@@ -1,8 +1,10 @@
1
+ export * from "./app-handler.js";
1
2
  export * from "./blossom.js";
2
3
  export * from "./bookmarks.js";
3
4
  export * from "./calendar.js";
4
5
  export * from "./channels.js";
5
6
  export * from "./comments.js";
7
+ export * from "./git.js";
6
8
  export * from "./legacy-messages.js";
7
9
  export * from "./mutes.js";
8
10
  export * from "./pins.js";
@@ -20,3 +22,4 @@ export * from "./zap-goals.js";
20
22
  export * from "applesauce-core/models";
21
23
  // Register the common models with the event store
22
24
  import "./__register__.js";
25
+ export * from "./nsite.js";
@@ -0,0 +1,22 @@
1
+ import { Model } from "applesauce-core/event-store";
2
+ import { NostrEvent } from "applesauce-core/helpers/event";
3
+ import { AddressPointer, EventPointer, ProfilePointer } from "applesauce-core/helpers/pointers";
4
+ import { NsiteEvent, NsiteSnapshotEvent, RootNsiteEvent } from "../helpers/nsite.js";
5
+ /** A model that resolves a site or snapshot pointer and validates its manifest */
6
+ export declare function NsiteModel(pointer: AddressPointer | EventPointer | string): Model<NsiteEvent | undefined>;
7
+ /** A model that returns a user's root and named sites */
8
+ export declare function UserNsitesModel(user: string | ProfilePointer): Model<NsiteEvent[]>;
9
+ /** A model that returns a user's root site */
10
+ export declare function RootNsiteModel(user: string | ProfilePointer): Model<RootNsiteEvent | undefined>;
11
+ /** A model that returns a user's manifest snapshots */
12
+ export declare function UserNsiteSnapshotsModel(user: string | ProfilePointer): Model<NsiteSnapshotEvent[]>;
13
+ /** A model that returns snapshots of a specific site */
14
+ export declare function NsiteSnapshotsModel(site: NostrEvent | AddressPointer | string): Model<NsiteSnapshotEvent[]>;
15
+ /** A model that returns sites copied directly from a site */
16
+ export declare function NsiteCopiesModel(site: NostrEvent | AddressPointer | string): Model<NsiteEvent[]>;
17
+ /** A model that returns copied sites and snapshots with a shared lineage origin */
18
+ export declare function NsiteLineageModel(site: NostrEvent | AddressPointer | string): Model<NsiteEvent[]>;
19
+ /** A model that returns manifests belonging to an upstream app descriptor */
20
+ export declare function AppNsitesModel(app: NostrEvent | AddressPointer | string): Model<NsiteEvent[]>;
21
+ /** A model that returns manifests advertising an aggregate hash */
22
+ export declare function NsitesByHashModel(hash: string): Model<NsiteEvent[]>;
@@ -0,0 +1,67 @@
1
+ import { getReplaceableAddressForEvent, getReplaceableAddressFromPointer, } from "applesauce-core/helpers/pointers";
2
+ import { map } from "rxjs";
3
+ import { isValidNsite, isValidNsiteSnapshot, isValidRootNsite, NSITE_KIND, NSITE_ROOT_KIND, NSITE_SNAPSHOT_KIND, } from "../helpers/nsite.js";
4
+ function coordinate(site) {
5
+ return typeof site === "string"
6
+ ? site
7
+ : "id" in site
8
+ ? getReplaceableAddressForEvent(site)
9
+ : getReplaceableAddressFromPointer(site);
10
+ }
11
+ /** A model that resolves a site or snapshot pointer and validates its manifest */
12
+ export function NsiteModel(pointer) {
13
+ return (store) => store.event(pointer).pipe(map((event) => (isValidNsite(event) ? event : undefined)));
14
+ }
15
+ /** A model that returns a user's root and named sites */
16
+ export function UserNsitesModel(user) {
17
+ const pubkey = typeof user === "string" ? user : user.pubkey;
18
+ return (store) => store
19
+ .timeline({ kinds: [NSITE_ROOT_KIND, NSITE_KIND], authors: [pubkey] })
20
+ .pipe(map((events) => events.filter(isValidNsite)));
21
+ }
22
+ /** A model that returns a user's root site */
23
+ export function RootNsiteModel(user) {
24
+ const pointer = typeof user === "string" ? { pubkey: user } : user;
25
+ return (store) => store
26
+ .replaceable({ ...pointer, kind: NSITE_ROOT_KIND })
27
+ .pipe(map((event) => (isValidRootNsite(event) ? event : undefined)));
28
+ }
29
+ /** A model that returns a user's manifest snapshots */
30
+ export function UserNsiteSnapshotsModel(user) {
31
+ const pubkey = typeof user === "string" ? user : user.pubkey;
32
+ return (store) => store
33
+ .timeline({ kinds: [NSITE_SNAPSHOT_KIND], authors: [pubkey] })
34
+ .pipe(map((events) => events.filter(isValidNsiteSnapshot)));
35
+ }
36
+ /** A model that returns snapshots of a specific site */
37
+ export function NsiteSnapshotsModel(site) {
38
+ return (store) => store
39
+ .timeline({ kinds: [NSITE_SNAPSHOT_KIND], "#a": [coordinate(site)] })
40
+ .pipe(map((events) => events.filter(isValidNsiteSnapshot)));
41
+ }
42
+ /** A model that returns sites copied directly from a site */
43
+ export function NsiteCopiesModel(site) {
44
+ return (store) => store
45
+ .timeline({ kinds: [NSITE_ROOT_KIND, NSITE_KIND], "#a": [coordinate(site)] })
46
+ .pipe(map((events) => events.filter(isValidNsite)));
47
+ }
48
+ /** A model that returns copied sites and snapshots with a shared lineage origin */
49
+ export function NsiteLineageModel(site) {
50
+ return (store) => store
51
+ .timeline({ kinds: [NSITE_ROOT_KIND, NSITE_KIND, NSITE_SNAPSHOT_KIND], "#A": [coordinate(site)] })
52
+ .pipe(map((events) => events.filter(isValidNsite)));
53
+ }
54
+ /** A model that returns manifests belonging to an upstream app descriptor */
55
+ export function AppNsitesModel(app) {
56
+ const address = coordinate(app);
57
+ // NIP-01 indexes only single-letter tags; app linkage must be filtered locally.
58
+ return (store) => store
59
+ .timeline({ kinds: [NSITE_ROOT_KIND, NSITE_KIND, NSITE_SNAPSHOT_KIND] })
60
+ .pipe(map((events) => events.filter((event) => isValidNsite(event) && event.tags.some((tag) => tag[0] === "app" && tag[1] === address))));
61
+ }
62
+ /** A model that returns manifests advertising an aggregate hash */
63
+ export function NsitesByHashModel(hash) {
64
+ return (store) => store
65
+ .timeline({ kinds: [NSITE_ROOT_KIND, NSITE_KIND, NSITE_SNAPSHOT_KIND], "#x": [hash] })
66
+ .pipe(map((events) => events.filter(isValidNsite)));
67
+ }
@@ -19,9 +19,12 @@ export type ThreadItem = {
19
19
  replies: Set<ThreadItem>;
20
20
  };
21
21
  export type ThreadModelOptions = {
22
+ /** The NIP-10 reply kinds to include, defaults to kind 1 */
22
23
  kinds?: number[];
24
+ /** Whether to include NIP-22 comments, defaults to true */
25
+ comments?: boolean;
23
26
  };
24
- /** A model that returns a NIP-10 thread of events */
27
+ /** A model that returns a thread of NIP-10 replies and NIP-22 comments */
25
28
  export declare function ThreadModel(root: string | AddressPointer | EventPointer, opts?: ThreadModelOptions): Model<Thread>;
26
29
  /** A model that gets all legacy and NIP-10, and NIP-22 replies for an event */
27
30
  export declare function RepliesModel(event: NostrEvent | EventPointer | AddressPointer, overrideKinds?: number[]): Model<NostrEvent[]>;
@@ -3,39 +3,68 @@ import { buildCommonEventRelationFilters } from "applesauce-core/helpers";
3
3
  import { getEventUID, kinds } from "applesauce-core/helpers/event";
4
4
  import { eventMatchesPointer, getReplaceableAddressFromPointer, isAddressPointer, isAddressPointerSame, isEventPointer, isEventPointerSame, } from "applesauce-core/helpers/pointers";
5
5
  import { map } from "rxjs/operators";
6
- import { COMMENT_KIND, getCommentReplyPointer } from "../helpers/comment.js";
6
+ import { COMMENT_KIND, getCommentReplyPointer, getCommentRootPointer } from "../helpers/comment.js";
7
7
  import { getNip10References } from "../helpers/threading.js";
8
8
  const defaultOptions = {
9
9
  kinds: [kinds.ShortTextNote],
10
+ comments: true,
10
11
  };
11
- /** A model that returns a NIP-10 thread of events */
12
+ /** Converts a NIP-22 comment pointer into a NIP-10 style thread reference */
13
+ function commentPointerToReference(pointer) {
14
+ if (pointer?.type === "event") {
15
+ const { id, kind, pubkey, relay } = pointer;
16
+ return { e: { id, kind, author: pubkey, relays: relay ? [relay] : undefined }, a: undefined };
17
+ }
18
+ if (pointer?.type === "address") {
19
+ const { kind, pubkey, identifier, relay } = pointer;
20
+ return { e: undefined, a: { kind, pubkey, identifier, relays: relay ? [relay] : undefined } };
21
+ }
22
+ // External roots have no event in the thread
23
+ return undefined;
24
+ }
25
+ /** Gets the thread references of a NIP-10 reply or a NIP-22 comment */
26
+ function getThreadReferences(event) {
27
+ if (event.kind !== COMMENT_KIND)
28
+ return getNip10References(event);
29
+ return {
30
+ root: commentPointerToReference(getCommentRootPointer(event)),
31
+ reply: commentPointerToReference(getCommentReplyPointer(event)),
32
+ };
33
+ }
34
+ /** A model that returns a thread of NIP-10 replies and NIP-22 comments */
12
35
  export function ThreadModel(root, opts) {
13
36
  const parentReferences = new Map();
14
37
  const items = new Map();
15
- const { kinds } = { ...defaultOptions, ...opts };
38
+ const { kinds, comments } = { ...defaultOptions, ...opts };
16
39
  let rootUID = "";
17
40
  const rootFilter = {};
18
41
  const replyFilter = { kinds };
42
+ // NIP-22 comments reference the root with uppercase tags at every depth
43
+ const commentFilter = { kinds: [COMMENT_KIND] };
19
44
  if (isAddressPointer(root)) {
20
45
  rootUID = getReplaceableAddressFromPointer(root);
21
46
  rootFilter.kinds = [root.kind];
22
47
  rootFilter.authors = [root.pubkey];
23
48
  rootFilter["#d"] = [root.identifier];
24
49
  replyFilter["#a"] = [rootUID];
50
+ commentFilter["#A"] = [rootUID];
25
51
  }
26
52
  else if (typeof root === "string") {
27
53
  rootUID = root;
28
54
  rootFilter.ids = [root];
29
55
  replyFilter["#e"] = [root];
56
+ commentFilter["#E"] = [root];
30
57
  }
31
58
  else {
32
59
  rootUID = root.id;
33
60
  rootFilter.ids = [root.id];
34
61
  replyFilter["#e"] = [root.id];
62
+ commentFilter["#E"] = [root.id];
35
63
  }
36
- return (events) => events.filters([rootFilter, replyFilter]).pipe(map((event) => {
64
+ const filters = comments ? [rootFilter, replyFilter, commentFilter] : [rootFilter, replyFilter];
65
+ return (events) => events.filters(filters).pipe(map((event) => {
37
66
  if (!items.has(getEventUID(event))) {
38
- const refs = getNip10References(event);
67
+ const refs = getThreadReferences(event);
39
68
  const replies = parentReferences.get(getEventUID(event)) || new Set();
40
69
  const item = { event, refs, replies };
41
70
  for (const child of replies) {
@@ -1,11 +1,15 @@
1
1
  import { Model } from "applesauce-core/event-store";
2
2
  import { NostrEvent } from "applesauce-core/helpers/event";
3
3
  import { UserStatusPointer } from "../helpers/user-status.js";
4
- export type UserStatus = UserStatusPointer & {
4
+ /** A parsed user status, the pointer fields are only set when the status links to something */
5
+ export type UserStatus = (UserStatusPointer | {
6
+ type?: undefined;
7
+ data?: undefined;
8
+ }) & {
5
9
  event: NostrEvent;
6
10
  content: string;
7
11
  };
8
- /** A model that returns a parsed {@link UserStatus} for a certain type */
9
- export declare function UserStatusModel(pubkey: string, type?: string): Model<UserStatus | undefined | null>;
10
- /** A model that returns a directory of parsed {@link UserStatus} for a pubkey */
12
+ /** A model that returns a parsed {@link UserStatus} for a certain type, or undefined when missing or cleared */
13
+ export declare function UserStatusModel(pubkey: string, type?: string): Model<UserStatus | undefined>;
14
+ /** A model that returns a directory of parsed {@link UserStatus} for a pubkey, excluding cleared statuses */
11
15
  export declare function UserStatusesModel(pubkey: string): Model<Record<string, UserStatus>>;
@@ -1,32 +1,26 @@
1
- import { getReplaceableIdentifier, kinds } from "applesauce-core/helpers/event";
1
+ import { kinds } from "applesauce-core/helpers/event";
2
2
  import { map } from "rxjs";
3
- import { getUserStatusPointer } from "../helpers/user-status.js";
4
- /** A model that returns a parsed {@link UserStatus} for a certain type */
3
+ import { getUserStatusPointer, getUserStatusType, isUserStatusCleared, isValidUserStatus, } from "../helpers/user-status.js";
4
+ function parseUserStatus(event) {
5
+ return { ...getUserStatusPointer(event), event, content: event.content };
6
+ }
7
+ /** A model that returns a parsed {@link UserStatus} for a certain type, or undefined when missing or cleared */
5
8
  export function UserStatusModel(pubkey, type = "general") {
6
9
  return (events) => events.replaceable(kinds.UserStatuses, pubkey, type).pipe(map((event) => {
7
- if (!event)
10
+ if (!event || !isValidUserStatus(event) || isUserStatusCleared(event))
8
11
  return undefined;
9
- const pointer = getUserStatusPointer(event);
10
- if (!pointer)
11
- return null;
12
- return {
13
- ...pointer,
14
- event,
15
- content: event.content,
16
- };
12
+ return parseUserStatus(event);
17
13
  }));
18
14
  }
19
- /** A model that returns a directory of parsed {@link UserStatus} for a pubkey */
15
+ /** A model that returns a directory of parsed {@link UserStatus} for a pubkey, excluding cleared statuses */
20
16
  export function UserStatusesModel(pubkey) {
21
17
  return (events) => events.timeline([{ kinds: [kinds.UserStatuses], authors: [pubkey] }]).pipe(map((events) => {
22
- return events.reduce((dir, event) => {
23
- try {
24
- const d = getReplaceableIdentifier(event);
25
- return { ...dir, [d]: { event, ...getUserStatusPointer(event), content: event.content } };
26
- }
27
- catch (error) {
28
- return dir;
29
- }
30
- }, {});
18
+ const dir = {};
19
+ for (const event of events) {
20
+ if (!isValidUserStatus(event) || isUserStatusCleared(event))
21
+ continue;
22
+ dir[getUserStatusType(event)] = parseUserStatus(event);
23
+ }
24
+ return dir;
31
25
  }));
32
26
  }
@@ -3,4 +3,4 @@ import { NostrEvent } from "applesauce-core/helpers/event";
3
3
  import { ProfilePointer } from "applesauce-core/helpers/pointers";
4
4
  import { MonoTypeOperatorFunction } from "rxjs";
5
5
  /** Filters a timeline of events by a users mutes */
6
- export declare function filterTimelineByMutes<T extends NostrEvent>(eventStore: IEventModelMixin<IEventStore | IAsyncEventStore>, user: string | ProfilePointer): MonoTypeOperatorFunction<T[]>;
6
+ export declare function filterTimelineByMutes<T extends NostrEvent>(eventStore: IEventModelMixin<NostrEvent, IEventStore | IAsyncEventStore>, user: string | ProfilePointer): MonoTypeOperatorFunction<T[]>;
@@ -2,6 +2,10 @@ import { combineLatest, map } from "rxjs";
2
2
  import { matchMutes } from "../helpers/mute.js";
3
3
  import { MuteModel } from "../models/mutes.js";
4
4
  /** Filters a timeline of events by a users mutes */
5
- export function filterTimelineByMutes(eventStore, user) {
5
+ export function filterTimelineByMutes(
6
+ // Gate-driven fix (02-02): IEventModelMixin gained a required <E> parameter when the D-02/WR-02
7
+ // seam was closed in applesauce-core; MuteModel is NostrEvent-only, so E is pinned explicitly
8
+ // to restore the arity this bare 1-arg usage relied on.
9
+ eventStore, user) {
6
10
  return (source) => combineLatest([source, eventStore.model(MuteModel, user)]).pipe(map(([source, mutes]) => (mutes ? source.filter((event) => matchMutes(mutes, event)) : source)));
7
11
  }
@@ -0,0 +1,24 @@
1
+ import { EventOperation } from "applesauce-core/factories";
2
+ import { ProfileContent } from "applesauce-core/helpers/profile";
3
+ import { AddressPointer } from "applesauce-core/helpers/pointers";
4
+ import { HandlerLinkPlatform, HandlerLinkType } from "../helpers/app-handler.js";
5
+ /** Sets the handler's kind:0-style metadata, or clears it to fall back to the author's profile */
6
+ export declare function setHandlerMetadata(metadata: ProfileContent | null): EventOperation;
7
+ /** Adds a supported event kind */
8
+ export declare function addHandlerKind(kind: number): EventOperation;
9
+ /** Removes a supported event kind */
10
+ export declare function removeHandlerKind(kind: number): EventOperation;
11
+ /** Sets the URL template for a platform and NIP-19 entity type, or the generic template when type is omitted */
12
+ export declare function setHandlerLink(platform: HandlerLinkPlatform, url: string, type?: HandlerLinkType): EventOperation;
13
+ /** Removes the URL template for a platform and NIP-19 entity type */
14
+ export declare function removeHandlerLink(platform: HandlerLinkPlatform, type?: HandlerLinkType): EventOperation;
15
+ /**
16
+ * Sets or removes the named nsite the handler currently serves
17
+ * @throws if the address is not a named nsite (kind 35128)
18
+ */
19
+ export declare function setHandlerLatest(site: AddressPointer | string | null): EventOperation;
20
+ /**
21
+ * Sets or removes the named nsite the handler is rolling out
22
+ * @throws if the address is not a named nsite (kind 35128)
23
+ */
24
+ export declare function setHandlerNext(site: AddressPointer | string | null): EventOperation;