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.
- package/README.md +1 -0
- package/dist/casts/_circular-import.d.ts +3 -0
- package/dist/casts/_circular-import.js +3 -0
- package/dist/casts/app-handler.d.ts +56 -0
- package/dist/casts/app-handler.js +105 -0
- package/dist/casts/app-recommendation.d.ts +26 -0
- package/dist/casts/app-recommendation.js +41 -0
- package/dist/casts/external-identities.d.ts +9 -0
- package/dist/casts/external-identities.js +14 -0
- package/dist/casts/forum-thread.d.ts +17 -0
- package/dist/casts/forum-thread.js +31 -0
- package/dist/casts/git-issue.d.ts +18 -0
- package/dist/casts/git-issue.js +26 -0
- package/dist/casts/git-patch.d.ts +49 -0
- package/dist/casts/git-patch.js +88 -0
- package/dist/casts/git-pull-request.d.ts +67 -0
- package/dist/casts/git-pull-request.js +122 -0
- package/dist/casts/git-repository.d.ts +9 -0
- package/dist/casts/git-repository.js +16 -0
- package/dist/casts/git-thread.d.ts +33 -0
- package/dist/casts/git-thread.js +65 -0
- package/dist/casts/index.d.ts +11 -0
- package/dist/casts/index.js +11 -0
- package/dist/casts/napplet.d.ts +98 -0
- package/dist/casts/napplet.js +196 -0
- package/dist/casts/note.d.ts +8 -0
- package/dist/casts/note.js +21 -1
- package/dist/casts/nsite.d.ts +134 -0
- package/dist/casts/nsite.js +249 -0
- package/dist/casts/profile.d.ts +20 -0
- package/dist/casts/profile.js +30 -0
- package/dist/casts/reaction.d.ts +1 -1
- package/dist/casts/relay-discovery.d.ts +4 -0
- package/dist/casts/relay-discovery.js +9 -1
- package/dist/casts/report.d.ts +28 -15
- package/dist/casts/report.js +42 -19
- package/dist/casts/share.d.ts +1 -1
- package/dist/casts/torrent.d.ts +5 -0
- package/dist/casts/torrent.js +8 -1
- package/dist/casts/trusted-assertions.d.ts +2 -0
- package/dist/casts/trusted-assertions.js +19 -18
- package/dist/casts/user-status.d.ts +33 -0
- package/dist/casts/user-status.js +69 -0
- package/dist/casts/user.d.ts +7 -0
- package/dist/casts/user.js +20 -1
- package/dist/factories/app-handler.d.ts +31 -0
- package/dist/factories/app-handler.js +50 -0
- package/dist/factories/app-recommendation.d.ts +21 -0
- package/dist/factories/app-recommendation.js +28 -0
- package/dist/factories/chat-message.d.ts +37 -0
- package/dist/factories/chat-message.js +56 -0
- package/dist/factories/comment.d.ts +8 -7
- package/dist/factories/comment.js +2 -2
- package/dist/factories/external-identities.d.ts +17 -0
- package/dist/factories/external-identities.js +28 -0
- package/dist/factories/forum-thread.d.ts +34 -0
- package/dist/factories/forum-thread.js +50 -0
- package/dist/factories/git-applied-status.d.ts +39 -0
- package/dist/factories/git-applied-status.js +53 -0
- package/dist/factories/git-closed-status.d.ts +18 -0
- package/dist/factories/git-closed-status.js +24 -0
- package/dist/factories/git-draft-status.d.ts +18 -0
- package/dist/factories/git-draft-status.js +24 -0
- package/dist/factories/git-issue.d.ts +19 -0
- package/dist/factories/git-issue.js +25 -0
- package/dist/factories/git-open-status.d.ts +18 -0
- package/dist/factories/git-open-status.js +22 -0
- package/dist/factories/git-patch.d.ts +59 -0
- package/dist/factories/git-patch.js +102 -0
- package/dist/factories/git-pull-request-update.d.ts +23 -0
- package/dist/factories/git-pull-request-update.js +33 -0
- package/dist/factories/git-pull-request.d.ts +39 -0
- package/dist/factories/git-pull-request.js +64 -0
- package/dist/factories/index.d.ts +22 -0
- package/dist/factories/index.js +22 -0
- package/dist/factories/internal/git-pull-request.d.ts +19 -0
- package/dist/factories/internal/git-pull-request.js +26 -0
- package/dist/factories/internal/git-status.d.ts +11 -0
- package/dist/factories/internal/git-status.js +12 -0
- package/dist/factories/internal/git-thread.d.ts +19 -0
- package/dist/factories/internal/git-thread.js +29 -0
- package/dist/factories/internal/napplet-manifest.d.ts +52 -0
- package/dist/factories/internal/napplet-manifest.js +85 -0
- package/dist/factories/internal/nsite-manifest.d.ts +45 -0
- package/dist/factories/internal/nsite-manifest.js +68 -0
- package/dist/factories/legacy-message.d.ts +2 -0
- package/dist/factories/legacy-message.js +9 -2
- package/dist/factories/named-napplet.d.ts +20 -0
- package/dist/factories/named-napplet.js +30 -0
- package/dist/factories/named-nsite.d.ts +28 -0
- package/dist/factories/named-nsite.js +53 -0
- package/dist/factories/napplet-snapshot.d.ts +18 -0
- package/dist/factories/napplet-snapshot.js +38 -0
- package/dist/factories/nsite-snapshot.d.ts +18 -0
- package/dist/factories/nsite-snapshot.js +29 -0
- package/dist/factories/reaction.d.ts +3 -2
- package/dist/factories/report.d.ts +48 -0
- package/dist/factories/report.js +66 -0
- package/dist/factories/root-napplet.d.ts +18 -0
- package/dist/factories/root-napplet.js +24 -0
- package/dist/factories/root-nsite.d.ts +23 -0
- package/dist/factories/root-nsite.js +44 -0
- package/dist/factories/torrent.d.ts +24 -10
- package/dist/factories/torrent.js +48 -44
- package/dist/factories/trusted-provider-list.d.ts +23 -0
- package/dist/factories/trusted-provider-list.js +39 -0
- package/dist/factories/user-status.d.ts +26 -0
- package/dist/factories/user-status.js +52 -0
- package/dist/helpers/app-data.js +15 -7
- package/dist/helpers/app-handler.d.ts +43 -6
- package/dist/helpers/app-handler.js +53 -3
- package/dist/helpers/app-recommendation.d.ts +24 -0
- package/dist/helpers/app-recommendation.js +30 -0
- package/dist/helpers/bookmark.js +5 -2
- package/dist/helpers/comment.d.ts +11 -5
- package/dist/helpers/comment.js +7 -1
- package/dist/helpers/content.d.ts +3 -1
- package/dist/helpers/emoji-pack.js +11 -6
- package/dist/helpers/emoji.d.ts +2 -2
- package/dist/helpers/encrypted-content-cache.js +18 -1
- package/dist/helpers/external-id.js +13 -19
- package/dist/helpers/external-identities.d.ts +29 -0
- package/dist/helpers/external-identities.js +52 -0
- package/dist/helpers/file-metadata.js +5 -6
- package/dist/helpers/forum-thread.d.ts +10 -0
- package/dist/helpers/forum-thread.js +10 -0
- package/dist/helpers/gift-wrap.d.ts +40 -15
- package/dist/helpers/gift-wrap.js +110 -33
- package/dist/helpers/git-issue.d.ts +13 -0
- package/dist/helpers/git-issue.js +19 -0
- package/dist/helpers/git-patch.d.ts +41 -0
- package/dist/helpers/git-patch.js +73 -0
- package/dist/helpers/git-pull-request.d.ts +57 -0
- package/dist/helpers/git-pull-request.js +111 -0
- package/dist/helpers/git-repository.d.ts +4 -0
- package/dist/helpers/git-repository.js +16 -0
- package/dist/helpers/git-status.d.ts +44 -0
- package/dist/helpers/git-status.js +93 -0
- package/dist/helpers/git.d.ts +2 -0
- package/dist/helpers/git.js +4 -0
- package/dist/helpers/groups.d.ts +5 -2
- package/dist/helpers/groups.js +40 -18
- package/dist/helpers/hashtag.d.ts +4 -2
- package/dist/helpers/index.d.ts +10 -0
- package/dist/helpers/index.js +10 -0
- package/dist/helpers/lists.js +14 -2
- package/dist/helpers/lnurl.js +1 -1
- package/dist/helpers/mute.js +18 -7
- package/dist/helpers/napplet.d.ts +89 -0
- package/dist/helpers/napplet.js +144 -0
- package/dist/helpers/nsite.d.ts +90 -0
- package/dist/helpers/nsite.js +217 -0
- package/dist/helpers/relay-discovery.d.ts +4 -0
- package/dist/helpers/relay-discovery.js +8 -0
- package/dist/helpers/reports.d.ts +35 -0
- package/dist/helpers/reports.js +36 -5
- package/dist/helpers/threading.d.ts +4 -2
- package/dist/helpers/torrent.d.ts +9 -6
- package/dist/helpers/torrent.js +23 -15
- package/dist/helpers/trusted-assertions.d.ts +7 -0
- package/dist/helpers/trusted-assertions.js +41 -2
- package/dist/helpers/user-status.d.ts +13 -1
- package/dist/helpers/user-status.js +15 -0
- package/dist/models/app-handler.d.ts +21 -0
- package/dist/models/app-handler.js +47 -0
- package/dist/models/git.d.ts +34 -0
- package/dist/models/git.js +144 -0
- package/dist/models/index.d.ts +3 -0
- package/dist/models/index.js +3 -0
- package/dist/models/nsite.d.ts +22 -0
- package/dist/models/nsite.js +67 -0
- package/dist/models/thread.d.ts +4 -1
- package/dist/models/thread.js +34 -5
- package/dist/models/user-status.d.ts +8 -4
- package/dist/models/user-status.js +16 -22
- package/dist/observable/filter-timeline-by-mutes.d.ts +1 -1
- package/dist/observable/filter-timeline-by-mutes.js +5 -1
- package/dist/operations/app-handler.d.ts +24 -0
- package/dist/operations/app-handler.js +58 -0
- package/dist/operations/app-recommendation.d.ts +13 -0
- package/dist/operations/app-recommendation.js +40 -0
- package/dist/operations/calendar-event.js +3 -2
- package/dist/operations/chat-message.d.ts +9 -0
- package/dist/operations/chat-message.js +12 -0
- package/dist/operations/client.d.ts +1 -4
- package/dist/operations/client.js +1 -23
- package/dist/operations/comment.d.ts +9 -3
- package/dist/operations/comment.js +12 -9
- package/dist/operations/external-identities.d.ts +8 -0
- package/dist/operations/external-identities.js +23 -0
- package/dist/operations/forum-thread.d.ts +3 -0
- package/dist/operations/forum-thread.js +6 -0
- package/dist/operations/gift-wrap.js +38 -14
- package/dist/operations/git-issue.d.ts +18 -0
- package/dist/operations/git-issue.js +31 -0
- package/dist/operations/git-patch.d.ts +30 -0
- package/dist/operations/git-patch.js +75 -0
- package/dist/operations/git-pull-request.d.ts +29 -0
- package/dist/operations/git-pull-request.js +74 -0
- package/dist/operations/git-repository.js +4 -4
- package/dist/operations/git-status.d.ts +28 -0
- package/dist/operations/git-status.js +116 -0
- package/dist/operations/git-thread.d.ts +13 -0
- package/dist/operations/git-thread.js +39 -0
- package/dist/operations/index.d.ts +15 -0
- package/dist/operations/index.js +15 -0
- package/dist/operations/internal/git-commits.d.ts +2 -0
- package/dist/operations/internal/git-commits.js +16 -0
- package/dist/operations/napplet.d.ts +51 -0
- package/dist/operations/napplet.js +121 -0
- package/dist/operations/nsite.d.ts +51 -0
- package/dist/operations/nsite.js +112 -0
- package/dist/operations/reaction.d.ts +12 -2
- package/dist/operations/reaction.js +1 -1
- package/dist/operations/report.d.ts +33 -0
- package/dist/operations/report.js +60 -0
- package/dist/operations/stream.js +5 -4
- package/dist/operations/torrent.d.ts +1 -4
- package/dist/operations/torrent.js +24 -11
- package/dist/operations/trusted-providers.d.ts +14 -0
- package/dist/operations/trusted-providers.js +33 -0
- package/dist/operations/user-status.d.ts +11 -0
- package/dist/operations/user-status.js +29 -0
- package/package.json +9 -9
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { castEventStream, castTimelineStream } from "applesauce-core/observable/cast-stream";
|
|
2
|
+
import { map, of } from "rxjs";
|
|
3
|
+
import { getGitPullRequestBranchName, getGitPullRequestCloneUrls, getGitPullRequestLabels, getGitPullRequestMergeBase, getGitPullRequestSubject, getGitPullRequestTipCommit, getGitPullRequestUpdateCloneUrls, getGitPullRequestUpdateTarget, getGitPullRequestUpdateTipCommit, isValidGitPullRequest, isValidGitPullRequestUpdate, getGitPullRequestPatchId, getGitPullRequestUpdateAuthor, getGitPullRequestUpdatePointer, getGitPullRequestPatchPointer, } from "../helpers/git-pull-request.js";
|
|
4
|
+
import { GitPullRequestUpdatesModel, GitPullRequestStateModel } from "../models/git.js";
|
|
5
|
+
import { GitPatch } from "./git-patch.js";
|
|
6
|
+
import { EventCast } from "./cast.js";
|
|
7
|
+
import { GitThread } from "./git-thread.js";
|
|
8
|
+
/** Cast for NIP-34 pull request update events */
|
|
9
|
+
export class GitPullRequestUpdate extends EventCast {
|
|
10
|
+
/**
|
|
11
|
+
* Creates a pull request update cast
|
|
12
|
+
* @throws if the event is not a valid update
|
|
13
|
+
*/
|
|
14
|
+
constructor(event, store) {
|
|
15
|
+
if (!isValidGitPullRequestUpdate(event))
|
|
16
|
+
throw new Error("Invalid git pull request update event");
|
|
17
|
+
super(event, store);
|
|
18
|
+
}
|
|
19
|
+
/** The id of the pull request this update targets */
|
|
20
|
+
get pullRequestId() {
|
|
21
|
+
return getGitPullRequestUpdateTarget(this.event);
|
|
22
|
+
}
|
|
23
|
+
/** The updated branch tip commit */
|
|
24
|
+
get tipCommit() {
|
|
25
|
+
return getGitPullRequestUpdateTipCommit(this.event);
|
|
26
|
+
}
|
|
27
|
+
/** The clone URLs containing the updated tip */
|
|
28
|
+
get cloneUrls() {
|
|
29
|
+
return getGitPullRequestUpdateCloneUrls(this.event);
|
|
30
|
+
}
|
|
31
|
+
/** The common ancestor with the target branch */
|
|
32
|
+
get mergeBase() {
|
|
33
|
+
return getGitPullRequestMergeBase(this.event);
|
|
34
|
+
}
|
|
35
|
+
/** The author of the targeted pull request */
|
|
36
|
+
get pullRequestAuthor() {
|
|
37
|
+
return getGitPullRequestUpdateAuthor(this.event);
|
|
38
|
+
}
|
|
39
|
+
/** The target pull request pointer with its relay and author hints */
|
|
40
|
+
get pullRequestPointer() {
|
|
41
|
+
return getGitPullRequestUpdatePointer(this.event);
|
|
42
|
+
}
|
|
43
|
+
/** Subscribes to the targeted pull request */
|
|
44
|
+
get pullRequest$() {
|
|
45
|
+
return this.$$ref("pullRequest$", (store) => store.event(this.pullRequestPointer).pipe(castEventStream(GitPullRequest, store)));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/** Cast for NIP-34 pull request events */
|
|
49
|
+
export class GitPullRequest extends GitThread {
|
|
50
|
+
/**
|
|
51
|
+
* Creates a pull request cast
|
|
52
|
+
* @throws if the event is not a valid pull request
|
|
53
|
+
*/
|
|
54
|
+
constructor(event, store) {
|
|
55
|
+
if (!isValidGitPullRequest(event))
|
|
56
|
+
throw new Error("Invalid git pull request event");
|
|
57
|
+
super(event, store);
|
|
58
|
+
}
|
|
59
|
+
/** The pull request subject */
|
|
60
|
+
get subject() {
|
|
61
|
+
return getGitPullRequestSubject(this.event);
|
|
62
|
+
}
|
|
63
|
+
/** The subject or first content line */
|
|
64
|
+
get title() {
|
|
65
|
+
return this.subject ?? super.title;
|
|
66
|
+
}
|
|
67
|
+
/** The pull request labels */
|
|
68
|
+
get labels() {
|
|
69
|
+
return getGitPullRequestLabels(this.event);
|
|
70
|
+
}
|
|
71
|
+
/** The original branch tip commit */
|
|
72
|
+
get tipCommit() {
|
|
73
|
+
return getGitPullRequestTipCommit(this.event);
|
|
74
|
+
}
|
|
75
|
+
/** The original clone URLs */
|
|
76
|
+
get cloneUrls() {
|
|
77
|
+
return getGitPullRequestCloneUrls(this.event);
|
|
78
|
+
}
|
|
79
|
+
/** The recommended branch name */
|
|
80
|
+
get branchName() {
|
|
81
|
+
return getGitPullRequestBranchName(this.event);
|
|
82
|
+
}
|
|
83
|
+
/** The original common ancestor with the target branch */
|
|
84
|
+
get mergeBase() {
|
|
85
|
+
return getGitPullRequestMergeBase(this.event);
|
|
86
|
+
}
|
|
87
|
+
/** The id of the original patch revised by this pull request */
|
|
88
|
+
get patchId() {
|
|
89
|
+
return getGitPullRequestPatchId(this.event);
|
|
90
|
+
}
|
|
91
|
+
/** The pointer to the original patch with its relay hint */
|
|
92
|
+
get patchPointer() {
|
|
93
|
+
return getGitPullRequestPatchPointer(this.event);
|
|
94
|
+
}
|
|
95
|
+
/** Subscribes to the original patch revised by this pull request */
|
|
96
|
+
get patch$() {
|
|
97
|
+
return this.$$ref("patch$", (store) => this.patchPointer ? store.event(this.patchPointer).pipe(castEventStream(GitPatch, store)) : of(undefined));
|
|
98
|
+
}
|
|
99
|
+
/** Subscribes to the latest coherent tip, clone URLs and merge base */
|
|
100
|
+
get state$() {
|
|
101
|
+
return this.$$ref("state$", (store) => store.model(GitPullRequestStateModel, this.event));
|
|
102
|
+
}
|
|
103
|
+
/** Subscribes to the updates published by the pull request author */
|
|
104
|
+
get updates$() {
|
|
105
|
+
return this.$$ref("updates$", (store) => store.model(GitPullRequestUpdatesModel, this.event).pipe(castTimelineStream(GitPullRequestUpdate, store)));
|
|
106
|
+
}
|
|
107
|
+
/** Subscribes to the latest branch tip commit, including updates */
|
|
108
|
+
get latestTipCommit$() {
|
|
109
|
+
return this.$$ref("latestTipCommit$", () => this.state$.pipe(map((state) => state.tipCommit)));
|
|
110
|
+
}
|
|
111
|
+
/** Subscribes to the clone URLs containing the latest tip */
|
|
112
|
+
get latestCloneUrls$() {
|
|
113
|
+
return this.$$ref("latestCloneUrls$", () => this.state$.pipe(map((state) => state.cloneUrls)));
|
|
114
|
+
}
|
|
115
|
+
/** Subscribes to the latest merge base */
|
|
116
|
+
get latestMergeBase$() {
|
|
117
|
+
return this.$$ref("latestMergeBase$", () => this.state$.pipe(map((state) => state.mergeBase)));
|
|
118
|
+
}
|
|
119
|
+
activity$() {
|
|
120
|
+
return this.store.model(GitPullRequestUpdatesModel, this.event);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -3,6 +3,9 @@ import { User } from "applesauce-core/casts/user";
|
|
|
3
3
|
import { NostrEvent } from "applesauce-core/helpers/event";
|
|
4
4
|
import { GitRepositoryEvent, GitRepositoryPointer } from "../helpers/git-repository.js";
|
|
5
5
|
import { CastRefEventStore, EventCast } from "./cast.js";
|
|
6
|
+
import { GitIssue } from "./git-issue.js";
|
|
7
|
+
import { GitPatch } from "./git-patch.js";
|
|
8
|
+
import { GitPullRequest } from "./git-pull-request.js";
|
|
6
9
|
import { Reaction } from "./reaction.js";
|
|
7
10
|
/** Cast for NIP-34 repository announcement events. */
|
|
8
11
|
export declare class GitRepository extends EventCast<GitRepositoryEvent> {
|
|
@@ -26,4 +29,10 @@ export declare class GitRepository extends EventCast<GitRepositoryEvent> {
|
|
|
26
29
|
get followers$(): ChainableObservable<User[]>;
|
|
27
30
|
/** Returns a timeline of all reactions to this git repository */
|
|
28
31
|
get reactions$(): ChainableObservable<Reaction[]>;
|
|
32
|
+
/** Subscribes to the issues of this repository */
|
|
33
|
+
get issues$(): ChainableObservable<GitIssue[]>;
|
|
34
|
+
/** Subscribes to the pull requests of this repository */
|
|
35
|
+
get pullRequests$(): ChainableObservable<GitPullRequest[]>;
|
|
36
|
+
/** Subscribes to the root patches (the first patch of each series) of this repository */
|
|
37
|
+
get patches$(): ChainableObservable<GitPatch[]>;
|
|
29
38
|
}
|
|
@@ -4,8 +4,12 @@ import { castEventStream, castTimelineStream } from "applesauce-core/observable/
|
|
|
4
4
|
import { map, of } from "rxjs";
|
|
5
5
|
import { FAVORITE_GIT_REPOS_KIND } from "../helpers/git-lists.js";
|
|
6
6
|
import { getGitRepositoryCloneUrls, getGitRepositoryDescription, getGitRepositoryEarliestUniqueCommit, getGitRepositoryHashtags, getGitRepositoryIdentifier, getGitRepositoryMaintainers, getGitRepositoryName, getGitRepositoryRelays, getGitRepositoryUpstream, getGitRepositoryWebUrls, isValidGitRepository, } from "../helpers/git-repository.js";
|
|
7
|
+
import { GitRepositoryIssuesModel, GitRepositoryPatchesModel, GitRepositoryPullRequestsModel } from "../models/git.js";
|
|
7
8
|
import { ReactionsModel } from "../models/reactions.js";
|
|
8
9
|
import { EventCast } from "./cast.js";
|
|
10
|
+
import { GitIssue } from "./git-issue.js";
|
|
11
|
+
import { GitPatch } from "./git-patch.js";
|
|
12
|
+
import { GitPullRequest } from "./git-pull-request.js";
|
|
9
13
|
import { Reaction } from "./reaction.js";
|
|
10
14
|
/** Cast for NIP-34 repository announcement events. */
|
|
11
15
|
export class GitRepository extends EventCast {
|
|
@@ -65,4 +69,16 @@ export class GitRepository extends EventCast {
|
|
|
65
69
|
get reactions$() {
|
|
66
70
|
return this.$$ref("reactions$", (store) => store.model(ReactionsModel, this.event).pipe(castTimelineStream(Reaction, store)));
|
|
67
71
|
}
|
|
72
|
+
/** Subscribes to the issues of this repository */
|
|
73
|
+
get issues$() {
|
|
74
|
+
return this.$$ref("issues$", (store) => store.model(GitRepositoryIssuesModel, this.pointer).pipe(castTimelineStream(GitIssue, store)));
|
|
75
|
+
}
|
|
76
|
+
/** Subscribes to the pull requests of this repository */
|
|
77
|
+
get pullRequests$() {
|
|
78
|
+
return this.$$ref("pullRequests$", (store) => store.model(GitRepositoryPullRequestsModel, this.pointer).pipe(castTimelineStream(GitPullRequest, store)));
|
|
79
|
+
}
|
|
80
|
+
/** Subscribes to the root patches (the first patch of each series) of this repository */
|
|
81
|
+
get patches$() {
|
|
82
|
+
return this.$$ref("patches$", (store) => store.model(GitRepositoryPatchesModel, this.pointer).pipe(castTimelineStream(GitPatch, store)));
|
|
83
|
+
}
|
|
68
84
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ChainableObservable } from "applesauce-core";
|
|
2
|
+
import { NostrEvent } from "applesauce-core/helpers/event";
|
|
3
|
+
import { Observable } from "rxjs";
|
|
4
|
+
import { GitRepositoryPointer } from "../helpers/git-repository.js";
|
|
5
|
+
import { GitStatus } from "../helpers/git-status.js";
|
|
6
|
+
import { CastRefEventStore, EventCast } from "./cast.js";
|
|
7
|
+
import { Comment } from "./comment.js";
|
|
8
|
+
import type { GitRepository } from "./git-repository.js";
|
|
9
|
+
/** Base cast for NIP-34 issues, patches and pull requests */
|
|
10
|
+
export declare class GitThread<T extends NostrEvent = NostrEvent> extends EventCast<T> {
|
|
11
|
+
/** Creates a shared repository thread cast */
|
|
12
|
+
constructor(event: T, store: CastRefEventStore);
|
|
13
|
+
/** The pointer to the repository this thread belongs to */
|
|
14
|
+
get repositoryPointer(): GitRepositoryPointer;
|
|
15
|
+
/** The `<kind>:<pubkey>:<identifier>` address of the repository */
|
|
16
|
+
get repositoryAddress(): string;
|
|
17
|
+
/** The title of the thread, falls back to the first line of the content */
|
|
18
|
+
get title(): string;
|
|
19
|
+
/** Subscribes to the repository announcement */
|
|
20
|
+
get repository$(): ChainableObservable<GitRepository | undefined>;
|
|
21
|
+
/** Subscribes to the pubkeys allowed to set the status, the repository owner is used until the announcement loads */
|
|
22
|
+
get maintainers$(): ChainableObservable<string[]>;
|
|
23
|
+
/** Subscribes to the current status */
|
|
24
|
+
get status$(): ChainableObservable<GitStatus>;
|
|
25
|
+
/** Subscribes to the latest authorized status event */
|
|
26
|
+
get statusEvent$(): ChainableObservable<NostrEvent | undefined>;
|
|
27
|
+
/** Subscribes to all NIP-22 comments in the thread */
|
|
28
|
+
get comments$(): ChainableObservable<Comment[]>;
|
|
29
|
+
/** Extra events that count as activity on the thread */
|
|
30
|
+
protected activity$(): Observable<NostrEvent[]>;
|
|
31
|
+
/** Subscribes to the unix timestamp of the most recent activity (status, comment or update) */
|
|
32
|
+
get updatedAt$(): ChainableObservable<number>;
|
|
33
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { castEventStream, castTimelineStream } from "applesauce-core/observable/cast-stream";
|
|
2
|
+
import { combineLatest, defer, from, map, of, switchMap } from "rxjs";
|
|
3
|
+
import { getGitRepositoryMaintainers, getGitRepositoryReference, } from "../helpers/git-repository.js";
|
|
4
|
+
import { GitStatusEventModel, GitStatusModel, GitThreadCommentsModel } from "../models/git.js";
|
|
5
|
+
import { EventCast } from "./cast.js";
|
|
6
|
+
import { Comment } from "./comment.js";
|
|
7
|
+
// GitRepository imports the thread casts, so it MUST be imported lazily to avoid a circular dependency
|
|
8
|
+
const GitRepositoryModule = defer(() => from(import("./git-repository.js")));
|
|
9
|
+
/** Base cast for NIP-34 issues, patches and pull requests */
|
|
10
|
+
export class GitThread extends EventCast {
|
|
11
|
+
/** Creates a shared repository thread cast */
|
|
12
|
+
constructor(event, store) {
|
|
13
|
+
super(event, store);
|
|
14
|
+
}
|
|
15
|
+
/** The pointer to the repository this thread belongs to */
|
|
16
|
+
get repositoryPointer() {
|
|
17
|
+
return getGitRepositoryReference(this.event);
|
|
18
|
+
}
|
|
19
|
+
/** The `<kind>:<pubkey>:<identifier>` address of the repository */
|
|
20
|
+
get repositoryAddress() {
|
|
21
|
+
const { kind, pubkey, identifier } = this.repositoryPointer;
|
|
22
|
+
return `${kind}:${pubkey}:${identifier}`;
|
|
23
|
+
}
|
|
24
|
+
/** The title of the thread, falls back to the first line of the content */
|
|
25
|
+
get title() {
|
|
26
|
+
return this.event.content.split("\n", 1)[0].trim();
|
|
27
|
+
}
|
|
28
|
+
/** Subscribes to the repository announcement */
|
|
29
|
+
get repository$() {
|
|
30
|
+
return this.$$ref("repository$", (store) => GitRepositoryModule.pipe(switchMap(({ GitRepository }) => store.replaceable(this.repositoryPointer).pipe(castEventStream(GitRepository, store)))));
|
|
31
|
+
}
|
|
32
|
+
/** Subscribes to the pubkeys allowed to set the status, the repository owner is used until the announcement loads */
|
|
33
|
+
get maintainers$() {
|
|
34
|
+
return this.$$ref("maintainers$", (store) => store
|
|
35
|
+
.replaceable(this.repositoryPointer)
|
|
36
|
+
.pipe(map((repo) => (repo ? getGitRepositoryMaintainers(repo) : [this.repositoryPointer.pubkey]))));
|
|
37
|
+
}
|
|
38
|
+
/** Subscribes to the current status */
|
|
39
|
+
get status$() {
|
|
40
|
+
return this.$$ref("status$", (store) => this.maintainers$.pipe(switchMap((maintainers) => store.model(GitStatusModel, this.event, maintainers))));
|
|
41
|
+
}
|
|
42
|
+
/** Subscribes to the latest authorized status event */
|
|
43
|
+
get statusEvent$() {
|
|
44
|
+
return this.$$ref("statusEvent$", (store) => this.maintainers$.pipe(switchMap((maintainers) => store.model(GitStatusEventModel, this.event, maintainers))));
|
|
45
|
+
}
|
|
46
|
+
/** Subscribes to all NIP-22 comments in the thread */
|
|
47
|
+
get comments$() {
|
|
48
|
+
return this.$$ref("comments$", (store) => store.model(GitThreadCommentsModel, this.event).pipe(castTimelineStream(Comment, store)));
|
|
49
|
+
}
|
|
50
|
+
/** Extra events that count as activity on the thread */
|
|
51
|
+
activity$() {
|
|
52
|
+
return of([]);
|
|
53
|
+
}
|
|
54
|
+
/** Subscribes to the unix timestamp of the most recent activity (status, comment or update) */
|
|
55
|
+
get updatedAt$() {
|
|
56
|
+
return this.$$ref("updatedAt$", (store) => combineLatest([this.statusEvent$, store.model(GitThreadCommentsModel, this.event), this.activity$()]).pipe(map(([status, comments, activity]) => {
|
|
57
|
+
let latest = Math.max(this.event.created_at, status?.created_at ?? 0);
|
|
58
|
+
for (const event of comments)
|
|
59
|
+
latest = Math.max(latest, event.created_at);
|
|
60
|
+
for (const event of activity)
|
|
61
|
+
latest = Math.max(latest, event.created_at);
|
|
62
|
+
return latest;
|
|
63
|
+
})));
|
|
64
|
+
}
|
|
65
|
+
}
|
package/dist/casts/index.d.ts
CHANGED
|
@@ -1,16 +1,25 @@
|
|
|
1
|
+
export * from "./app-handler.js";
|
|
2
|
+
export * from "./app-recommendation.js";
|
|
1
3
|
export * from "./article.js";
|
|
4
|
+
export * from "./forum-thread.js";
|
|
2
5
|
export * from "./bookmarks.js";
|
|
3
6
|
export * from "./cast.js";
|
|
4
7
|
export * from "./code-snippet.js";
|
|
5
8
|
export * from "./comment.js";
|
|
6
9
|
export * from "./emoji-pack.js";
|
|
10
|
+
export * from "./external-identities.js";
|
|
7
11
|
export * from "./favorite-emojis.js";
|
|
8
12
|
export * from "./file-metadata.js";
|
|
9
13
|
export * from "./git-grasp-list.js";
|
|
14
|
+
export * from "./git-issue.js";
|
|
10
15
|
export * from "./git-lists.js";
|
|
16
|
+
export * from "./git-patch.js";
|
|
17
|
+
export * from "./git-pull-request.js";
|
|
11
18
|
export * from "./git-repository.js";
|
|
19
|
+
export * from "./git-thread.js";
|
|
12
20
|
export * from "./groups.js";
|
|
13
21
|
export * from "./mutes.js";
|
|
22
|
+
export * from "./napplet.js";
|
|
14
23
|
export * from "./note.js";
|
|
15
24
|
export * from "./profile.js";
|
|
16
25
|
export * from "./profile-badges.js";
|
|
@@ -23,8 +32,10 @@ export * from "./share.js";
|
|
|
23
32
|
export * from "./stream.js";
|
|
24
33
|
export * from "./torrent.js";
|
|
25
34
|
export * from "./user.js";
|
|
35
|
+
export * from "./user-status.js";
|
|
26
36
|
export * from "./badge.js";
|
|
27
37
|
export * from "./badge-award.js";
|
|
28
38
|
export * from "./zap.js";
|
|
29
39
|
export * from "./trusted-assertions.js";
|
|
30
40
|
export * from "./zap-goal.js";
|
|
41
|
+
export * from "./nsite.js";
|
package/dist/casts/index.js
CHANGED
|
@@ -1,16 +1,25 @@
|
|
|
1
|
+
export * from "./app-handler.js";
|
|
2
|
+
export * from "./app-recommendation.js";
|
|
1
3
|
export * from "./article.js";
|
|
4
|
+
export * from "./forum-thread.js";
|
|
2
5
|
export * from "./bookmarks.js";
|
|
3
6
|
export * from "./cast.js";
|
|
4
7
|
export * from "./code-snippet.js";
|
|
5
8
|
export * from "./comment.js";
|
|
6
9
|
export * from "./emoji-pack.js";
|
|
10
|
+
export * from "./external-identities.js";
|
|
7
11
|
export * from "./favorite-emojis.js";
|
|
8
12
|
export * from "./file-metadata.js";
|
|
9
13
|
export * from "./git-grasp-list.js";
|
|
14
|
+
export * from "./git-issue.js";
|
|
10
15
|
export * from "./git-lists.js";
|
|
16
|
+
export * from "./git-patch.js";
|
|
17
|
+
export * from "./git-pull-request.js";
|
|
11
18
|
export * from "./git-repository.js";
|
|
19
|
+
export * from "./git-thread.js";
|
|
12
20
|
export * from "./groups.js";
|
|
13
21
|
export * from "./mutes.js";
|
|
22
|
+
export * from "./napplet.js";
|
|
14
23
|
export * from "./note.js";
|
|
15
24
|
export * from "./profile.js";
|
|
16
25
|
export * from "./profile-badges.js";
|
|
@@ -23,8 +32,10 @@ export * from "./share.js";
|
|
|
23
32
|
export * from "./stream.js";
|
|
24
33
|
export * from "./torrent.js";
|
|
25
34
|
export * from "./user.js";
|
|
35
|
+
export * from "./user-status.js";
|
|
26
36
|
export * from "./badge.js";
|
|
27
37
|
export * from "./badge-award.js";
|
|
28
38
|
export * from "./zap.js";
|
|
29
39
|
export * from "./trusted-assertions.js";
|
|
30
40
|
export * from "./zap-goal.js";
|
|
41
|
+
export * from "./nsite.js";
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { ChainableObservable } from "applesauce-core";
|
|
2
|
+
import { NostrEvent } from "applesauce-core/helpers/event";
|
|
3
|
+
import { AddressPointer, EventPointer } from "applesauce-core/helpers/pointers";
|
|
4
|
+
import { Observable } from "rxjs";
|
|
5
|
+
import { NamedNappletEvent, NappletEvent, NappletSnapshotEvent, RootNappletEvent } from "../helpers/napplet.js";
|
|
6
|
+
import { CastRefEventStore, EventCast } from "./cast.js";
|
|
7
|
+
import { Comment } from "./comment.js";
|
|
8
|
+
import { Reaction } from "./reaction.js";
|
|
9
|
+
import { Share } from "./share.js";
|
|
10
|
+
import { Zap } from "./zap.js";
|
|
11
|
+
/** Cast for any NIP-5D napplet manifest (kinds 5129, 15129 and 35129) */
|
|
12
|
+
export declare class Napplet<T extends NappletEvent = NappletEvent> extends EventCast<T> {
|
|
13
|
+
constructor(event: NostrEvent, store: CastRefEventStore);
|
|
14
|
+
/** The sha256 of the napplet `index.html` artifact */
|
|
15
|
+
get artifactHash(): string;
|
|
16
|
+
/** The plain-text description of the napplet */
|
|
17
|
+
get description(): string;
|
|
18
|
+
/** The short display label */
|
|
19
|
+
get title(): string | undefined;
|
|
20
|
+
/** The archetypes the napplet advertises */
|
|
21
|
+
get archetypes(): string[];
|
|
22
|
+
/** The intents the napplet accepts */
|
|
23
|
+
get intents(): import("../helpers/napplet.js").NappletIntent[];
|
|
24
|
+
/** The NAP domains required for full functionality */
|
|
25
|
+
get requiredDomains(): string[];
|
|
26
|
+
/** The optional NAP domains */
|
|
27
|
+
get optionalDomains(): string[];
|
|
28
|
+
/** The content-addressed icon, if valid */
|
|
29
|
+
get icon(): import("../helpers/napplet.js").NappletIcon | undefined;
|
|
30
|
+
/** The Blossom server hints for the artifact and icon blobs */
|
|
31
|
+
get servers(): string[];
|
|
32
|
+
/** The source URL */
|
|
33
|
+
get source(): string | undefined;
|
|
34
|
+
/** Whether this is a kind 5129 snapshot */
|
|
35
|
+
get isSnapshot(): boolean;
|
|
36
|
+
/** Whether this is a kind 15129 root napplet */
|
|
37
|
+
get isRoot(): boolean;
|
|
38
|
+
/** Whether this is a kind 35129 named napplet */
|
|
39
|
+
get isNamed(): boolean;
|
|
40
|
+
/** An address pointer for root and named napplets, or an event pointer for snapshots */
|
|
41
|
+
get pointer(): AddressPointer | EventPointer;
|
|
42
|
+
/** An observable of the pointer with relay hints from the authors outboxes */
|
|
43
|
+
get pointer$(): Observable<AddressPointer | EventPointer>;
|
|
44
|
+
/** The NIP-19 naddr, or nevent for snapshots */
|
|
45
|
+
get address(): string;
|
|
46
|
+
/** An observable of the NIP-19 address with relay hints from the authors outboxes */
|
|
47
|
+
get address$(): Observable<string>;
|
|
48
|
+
/** Subscribes to the NIP-22 comments on this napplet */
|
|
49
|
+
get comments$(): ChainableObservable<Comment[]>;
|
|
50
|
+
/** Subscribes to the reactions to this napplet */
|
|
51
|
+
get reactions$(): ChainableObservable<Reaction[]>;
|
|
52
|
+
/** Subscribes to the zaps of this napplet */
|
|
53
|
+
get zaps$(): ChainableObservable<Zap[]>;
|
|
54
|
+
/** Subscribes to the shares of this napplet */
|
|
55
|
+
get shares$(): ChainableObservable<Share[]>;
|
|
56
|
+
}
|
|
57
|
+
/** Base class for root and named napplets that snapshots can derive from */
|
|
58
|
+
declare class AddressableNapplet<T extends RootNappletEvent | NamedNappletEvent> extends Napplet<T> {
|
|
59
|
+
/** The `kind:pubkey:identifier` address used by snapshot `a` and `A` tags */
|
|
60
|
+
get coordinate(): string;
|
|
61
|
+
/** Subscribes to the snapshots that derive directly from this napplet */
|
|
62
|
+
get snapshots$(): ChainableObservable<NappletSnapshot[]>;
|
|
63
|
+
/** Subscribes to every snapshot whose lineage originates from this napplet */
|
|
64
|
+
get lineage$(): ChainableObservable<NappletSnapshot[]>;
|
|
65
|
+
}
|
|
66
|
+
/** Cast for a NIP-5D root napplet (kind 15129) */
|
|
67
|
+
export declare class RootNapplet extends AddressableNapplet<RootNappletEvent> {
|
|
68
|
+
constructor(event: NostrEvent, store: CastRefEventStore);
|
|
69
|
+
}
|
|
70
|
+
/** Cast for a NIP-5D named napplet (kind 35129) */
|
|
71
|
+
export declare class NamedNapplet extends AddressableNapplet<NamedNappletEvent> {
|
|
72
|
+
constructor(event: NostrEvent, store: CastRefEventStore);
|
|
73
|
+
/** The `d` tag identifier of the napplet */
|
|
74
|
+
get identifier(): string;
|
|
75
|
+
}
|
|
76
|
+
/** Cast for a NIP-5D napplet snapshot (kind 5129) */
|
|
77
|
+
export declare class NappletSnapshot extends Napplet<NappletSnapshotEvent> {
|
|
78
|
+
constructor(event: NostrEvent, store: CastRefEventStore);
|
|
79
|
+
/** The address of the napplet this snapshot derives from */
|
|
80
|
+
get parentPointer(): AddressPointer | undefined;
|
|
81
|
+
/** The address of the root napplet this snapshot's lineage originates from */
|
|
82
|
+
get rootPointer(): AddressPointer | undefined;
|
|
83
|
+
/** Subscribes to the napplet this snapshot derives from */
|
|
84
|
+
get parent$(): ChainableObservable<Napplet | undefined>;
|
|
85
|
+
/** Alias for {@link parent$} */
|
|
86
|
+
get upstream$(): ChainableObservable<Napplet<NappletEvent> | undefined>;
|
|
87
|
+
/** Subscribes to the root napplet this snapshot's lineage originates from */
|
|
88
|
+
get root$(): ChainableObservable<Napplet | undefined>;
|
|
89
|
+
}
|
|
90
|
+
declare module "applesauce-core/casts" {
|
|
91
|
+
interface User {
|
|
92
|
+
/** Subscribes to the user's root and named napplets */
|
|
93
|
+
get napplets$(): ChainableObservable<Napplet[]>;
|
|
94
|
+
/** Subscribes to the user's root (kind 15129) napplet */
|
|
95
|
+
get napplet$(): ChainableObservable<RootNapplet | undefined>;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
export {};
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { withImmediateValueOrDefault } from "applesauce-core";
|
|
2
|
+
import { User } from "applesauce-core/casts/user";
|
|
3
|
+
import { addRelayHintsToPointer, encodePointer, getAddressPointerForEvent, getEventPointerForEvent, } from "applesauce-core/helpers/pointers";
|
|
4
|
+
import { map, of } from "rxjs";
|
|
5
|
+
import { getNappletArchetypes, getNappletArtifactHash, getNappletDescription, getNappletIcon, getNappletIdentifier, getNappletIntents, getNappletOptionalDomains, getNappletParentPointer, getNappletRequiredDomains, getNappletRootPointer, getNappletServers, getNappletSource, getNappletTitle, isNamedNapplet, isNappletSnapshot, isRootNapplet, isValidNamedNapplet, isValidNapplet, isValidNappletSnapshot, isValidRootNapplet, NAPPLET_KIND, NAPPLET_ROOT_KIND, NAPPLET_SNAPSHOT_KIND, } from "../helpers/napplet.js";
|
|
6
|
+
import { CommentsModel } from "../models/comments.js";
|
|
7
|
+
import { ReactionsModel } from "../models/reactions.js";
|
|
8
|
+
import { SharesModel } from "../models/shares.js";
|
|
9
|
+
import { EventZapsModel } from "../models/zaps.js";
|
|
10
|
+
import { castEventStream, castTimelineStream } from "../observable/cast-stream.js";
|
|
11
|
+
import { EventCast } from "./cast.js";
|
|
12
|
+
import { Comment } from "./comment.js";
|
|
13
|
+
import { Reaction } from "./reaction.js";
|
|
14
|
+
import { Share } from "./share.js";
|
|
15
|
+
import { Zap } from "./zap.js";
|
|
16
|
+
/** Cast for any NIP-5D napplet manifest (kinds 5129, 15129 and 35129) */
|
|
17
|
+
export class Napplet extends EventCast {
|
|
18
|
+
constructor(event, store) {
|
|
19
|
+
if (!isValidNapplet(event))
|
|
20
|
+
throw new Error("Invalid napplet manifest");
|
|
21
|
+
super(event, store);
|
|
22
|
+
}
|
|
23
|
+
/** The sha256 of the napplet `index.html` artifact */
|
|
24
|
+
get artifactHash() {
|
|
25
|
+
return getNappletArtifactHash(this.event);
|
|
26
|
+
}
|
|
27
|
+
/** The plain-text description of the napplet */
|
|
28
|
+
get description() {
|
|
29
|
+
return getNappletDescription(this.event);
|
|
30
|
+
}
|
|
31
|
+
/** The short display label */
|
|
32
|
+
get title() {
|
|
33
|
+
return getNappletTitle(this.event);
|
|
34
|
+
}
|
|
35
|
+
/** The archetypes the napplet advertises */
|
|
36
|
+
get archetypes() {
|
|
37
|
+
return getNappletArchetypes(this.event);
|
|
38
|
+
}
|
|
39
|
+
/** The intents the napplet accepts */
|
|
40
|
+
get intents() {
|
|
41
|
+
return getNappletIntents(this.event);
|
|
42
|
+
}
|
|
43
|
+
/** The NAP domains required for full functionality */
|
|
44
|
+
get requiredDomains() {
|
|
45
|
+
return getNappletRequiredDomains(this.event);
|
|
46
|
+
}
|
|
47
|
+
/** The optional NAP domains */
|
|
48
|
+
get optionalDomains() {
|
|
49
|
+
return getNappletOptionalDomains(this.event);
|
|
50
|
+
}
|
|
51
|
+
/** The content-addressed icon, if valid */
|
|
52
|
+
get icon() {
|
|
53
|
+
return getNappletIcon(this.event);
|
|
54
|
+
}
|
|
55
|
+
/** The Blossom server hints for the artifact and icon blobs */
|
|
56
|
+
get servers() {
|
|
57
|
+
return getNappletServers(this.event);
|
|
58
|
+
}
|
|
59
|
+
/** The source URL */
|
|
60
|
+
get source() {
|
|
61
|
+
return getNappletSource(this.event);
|
|
62
|
+
}
|
|
63
|
+
/** Whether this is a kind 5129 snapshot */
|
|
64
|
+
get isSnapshot() {
|
|
65
|
+
return isNappletSnapshot(this.event);
|
|
66
|
+
}
|
|
67
|
+
/** Whether this is a kind 15129 root napplet */
|
|
68
|
+
get isRoot() {
|
|
69
|
+
return isRootNapplet(this.event);
|
|
70
|
+
}
|
|
71
|
+
/** Whether this is a kind 35129 named napplet */
|
|
72
|
+
get isNamed() {
|
|
73
|
+
return isNamedNapplet(this.event);
|
|
74
|
+
}
|
|
75
|
+
/** An address pointer for root and named napplets, or an event pointer for snapshots */
|
|
76
|
+
get pointer() {
|
|
77
|
+
return getAddressPointerForEvent(this.event) ?? getEventPointerForEvent(this.event);
|
|
78
|
+
}
|
|
79
|
+
/** An observable of the pointer with relay hints from the authors outboxes */
|
|
80
|
+
get pointer$() {
|
|
81
|
+
return this.author.outboxes$.pipe(withImmediateValueOrDefault(undefined), map((outboxes) => (outboxes ? addRelayHintsToPointer(this.pointer, outboxes.slice(0, 3)) : this.pointer)));
|
|
82
|
+
}
|
|
83
|
+
/** The NIP-19 naddr, or nevent for snapshots */
|
|
84
|
+
get address() {
|
|
85
|
+
return encodePointer(this.pointer);
|
|
86
|
+
}
|
|
87
|
+
/** An observable of the NIP-19 address with relay hints from the authors outboxes */
|
|
88
|
+
get address$() {
|
|
89
|
+
return this.pointer$.pipe(map((pointer) => encodePointer(pointer)));
|
|
90
|
+
}
|
|
91
|
+
/** Subscribes to the NIP-22 comments on this napplet */
|
|
92
|
+
get comments$() {
|
|
93
|
+
return this.$$ref("comments$", (store) => store.model(CommentsModel, this.event).pipe(castTimelineStream(Comment, store)));
|
|
94
|
+
}
|
|
95
|
+
/** Subscribes to the reactions to this napplet */
|
|
96
|
+
get reactions$() {
|
|
97
|
+
return this.$$ref("reactions$", (store) => store.model(ReactionsModel, this.event).pipe(castTimelineStream(Reaction, store)));
|
|
98
|
+
}
|
|
99
|
+
/** Subscribes to the zaps of this napplet */
|
|
100
|
+
get zaps$() {
|
|
101
|
+
return this.$$ref("zaps$", (store) => store.model(EventZapsModel, this.event).pipe(castTimelineStream(Zap, store)));
|
|
102
|
+
}
|
|
103
|
+
/** Subscribes to the shares of this napplet */
|
|
104
|
+
get shares$() {
|
|
105
|
+
return this.$$ref("shares$", (store) => store.model(SharesModel, this.event).pipe(castTimelineStream(Share, store)));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/** Base class for root and named napplets that snapshots can derive from */
|
|
109
|
+
class AddressableNapplet extends Napplet {
|
|
110
|
+
/** The `kind:pubkey:identifier` address used by snapshot `a` and `A` tags */
|
|
111
|
+
get coordinate() {
|
|
112
|
+
return super.coordinate;
|
|
113
|
+
}
|
|
114
|
+
/** Subscribes to the snapshots that derive directly from this napplet */
|
|
115
|
+
get snapshots$() {
|
|
116
|
+
return this.$$ref("snapshots$", (store) => store
|
|
117
|
+
.timeline({ kinds: [NAPPLET_SNAPSHOT_KIND], "#a": [this.coordinate] })
|
|
118
|
+
.pipe(castTimelineStream(NappletSnapshot, store)));
|
|
119
|
+
}
|
|
120
|
+
/** Subscribes to every snapshot whose lineage originates from this napplet */
|
|
121
|
+
get lineage$() {
|
|
122
|
+
return this.$$ref("lineage$", (store) => store
|
|
123
|
+
.timeline({ kinds: [NAPPLET_SNAPSHOT_KIND], "#A": [this.coordinate] })
|
|
124
|
+
.pipe(castTimelineStream(NappletSnapshot, store)));
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/** Cast for a NIP-5D root napplet (kind 15129) */
|
|
128
|
+
export class RootNapplet extends AddressableNapplet {
|
|
129
|
+
constructor(event, store) {
|
|
130
|
+
if (!isValidRootNapplet(event))
|
|
131
|
+
throw new Error("Invalid root napplet");
|
|
132
|
+
super(event, store);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/** Cast for a NIP-5D named napplet (kind 35129) */
|
|
136
|
+
export class NamedNapplet extends AddressableNapplet {
|
|
137
|
+
constructor(event, store) {
|
|
138
|
+
if (!isValidNamedNapplet(event))
|
|
139
|
+
throw new Error("Invalid named napplet");
|
|
140
|
+
super(event, store);
|
|
141
|
+
}
|
|
142
|
+
/** The `d` tag identifier of the napplet */
|
|
143
|
+
get identifier() {
|
|
144
|
+
return getNappletIdentifier(this.event);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/** Cast for a NIP-5D napplet snapshot (kind 5129) */
|
|
148
|
+
export class NappletSnapshot extends Napplet {
|
|
149
|
+
constructor(event, store) {
|
|
150
|
+
if (!isValidNappletSnapshot(event))
|
|
151
|
+
throw new Error("Invalid napplet snapshot");
|
|
152
|
+
super(event, store);
|
|
153
|
+
}
|
|
154
|
+
/** The address of the napplet this snapshot derives from */
|
|
155
|
+
get parentPointer() {
|
|
156
|
+
return getNappletParentPointer(this.event);
|
|
157
|
+
}
|
|
158
|
+
/** The address of the root napplet this snapshot's lineage originates from */
|
|
159
|
+
get rootPointer() {
|
|
160
|
+
return getNappletRootPointer(this.event);
|
|
161
|
+
}
|
|
162
|
+
/** Subscribes to the napplet this snapshot derives from */
|
|
163
|
+
get parent$() {
|
|
164
|
+
return this.$$ref("parent$", (store) => {
|
|
165
|
+
const pointer = this.parentPointer;
|
|
166
|
+
return pointer ? store.replaceable(pointer).pipe(castEventStream(Napplet, store)) : of(undefined);
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
/** Alias for {@link parent$} */
|
|
170
|
+
get upstream$() {
|
|
171
|
+
return this.parent$;
|
|
172
|
+
}
|
|
173
|
+
/** Subscribes to the root napplet this snapshot's lineage originates from */
|
|
174
|
+
get root$() {
|
|
175
|
+
return this.$$ref("root$", (store) => {
|
|
176
|
+
const pointer = this.rootPointer;
|
|
177
|
+
return pointer ? store.replaceable(pointer).pipe(castEventStream(Napplet, store)) : of(undefined);
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
Object.defineProperty(User.prototype, "napplets$", {
|
|
182
|
+
get() {
|
|
183
|
+
return this.$$ref("napplets$", (store) => store
|
|
184
|
+
.timeline({ kinds: [NAPPLET_ROOT_KIND, NAPPLET_KIND], authors: [this.pubkey] })
|
|
185
|
+
.pipe(castTimelineStream(Napplet, store)));
|
|
186
|
+
},
|
|
187
|
+
configurable: true,
|
|
188
|
+
enumerable: false,
|
|
189
|
+
});
|
|
190
|
+
Object.defineProperty(User.prototype, "napplet$", {
|
|
191
|
+
get() {
|
|
192
|
+
return this.$$ref("napplet$", (store) => store.replaceable({ kind: NAPPLET_ROOT_KIND, pubkey: this.pubkey }).pipe(castEventStream(RootNapplet, store)));
|
|
193
|
+
},
|
|
194
|
+
configurable: true,
|
|
195
|
+
enumerable: false,
|
|
196
|
+
});
|
package/dist/casts/note.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { Report } from "./report.js";
|
|
1
2
|
import { EventPointer, KnownEvent, NostrEvent } from "applesauce-core/helpers";
|
|
3
|
+
import { AppHandler } from "./app-handler.js";
|
|
2
4
|
import { CastRefEventStore, EventCast } from "./cast.js";
|
|
3
5
|
import { Comment } from "./comment.js";
|
|
4
6
|
import { Reaction } from "./reaction.js";
|
|
@@ -6,9 +8,15 @@ import { Share } from "./share.js";
|
|
|
6
8
|
import { Zap } from "./zap.js";
|
|
7
9
|
export declare class Note extends EventCast<KnownEvent<1>> {
|
|
8
10
|
constructor(event: NostrEvent, store: CastRefEventStore);
|
|
11
|
+
/** Subscribes to reports referencing this event in the store */
|
|
12
|
+
get reports$(): import("applesauce-core").ChainableObservable<Report[]>;
|
|
9
13
|
get references(): import("../helpers/threading.js").ThreadReferences;
|
|
10
14
|
get isReply(): boolean;
|
|
11
15
|
get isRoot(): boolean;
|
|
16
|
+
/** The NIP-89 client that published the note */
|
|
17
|
+
get client(): import("../helpers/app-handler.js").ClientTag | undefined;
|
|
18
|
+
/** Subscribes to the NIP-89 handler referenced by the note's client tag */
|
|
19
|
+
get client$(): import("applesauce-core").ChainableObservable<AppHandler | undefined>;
|
|
12
20
|
/** An array of events that this note is quoting */
|
|
13
21
|
get quotePointers(): EventPointer[];
|
|
14
22
|
/** Gets the NIP-10 root event */
|