applesauce-common 6.2.0 → 7.1.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 +12 -0
- package/dist/casts/index.js +12 -0
- package/dist/casts/napplet-handlers.d.ts +39 -0
- package/dist/casts/napplet-handlers.js +91 -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/file-message.d.ts +24 -0
- package/dist/factories/file-message.js +37 -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 +24 -0
- package/dist/factories/index.js +24 -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-handlers.d.ts +34 -0
- package/dist/factories/napplet-handlers.js +77 -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/factories/wrapped-message.js +10 -4
- 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.d.ts +2 -11
- package/dist/helpers/encrypted-content-cache.js +6 -14
- package/dist/helpers/encrypted-file.d.ts +41 -0
- package/dist/helpers/encrypted-file.js +64 -0
- 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-message.d.ts +18 -0
- package/dist/helpers/file-message.js +44 -0
- package/dist/helpers/file-metadata.d.ts +9 -4
- package/dist/helpers/file-metadata.js +21 -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 +13 -0
- package/dist/helpers/index.js +13 -0
- package/dist/helpers/lists.js +14 -2
- package/dist/helpers/lnurl.js +1 -1
- package/dist/helpers/messages.js +3 -2
- package/dist/helpers/mute.js +20 -9
- package/dist/helpers/napplet-handlers.d.ts +79 -0
- package/dist/helpers/napplet-handlers.js +187 -0
- package/dist/helpers/napplet.d.ts +107 -0
- package/dist/helpers/napplet.js +177 -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/helpers/wrapped-messages.d.ts +2 -0
- package/dist/helpers/wrapped-messages.js +6 -1
- 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 +4 -0
- package/dist/models/index.js +4 -0
- package/dist/models/legacy-messages.js +6 -1
- package/dist/models/napplet-handlers.d.ts +16 -0
- package/dist/models/napplet-handlers.js +45 -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/models/wrapped-messages.js +9 -7
- package/dist/observable/filter-timeline-by-mutes.d.ts +1 -1
- package/dist/observable/filter-timeline-by-mutes.js +6 -2
- 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/file-message.d.ts +7 -0
- package/dist/operations/file-message.js +34 -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 +17 -0
- package/dist/operations/index.js +17 -0
- package/dist/operations/internal/git-commits.d.ts +2 -0
- package/dist/operations/internal/git-commits.js +16 -0
- package/dist/operations/napplet-handlers.d.ts +47 -0
- package/dist/operations/napplet-handlers.js +161 -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/dist/operations/wrapped-message.js +2 -2
- package/package.json +13 -17
package/dist/casts/profile.d.ts
CHANGED
|
@@ -3,22 +3,42 @@ import { CastRefEventStore, EventCast } from "./cast.js";
|
|
|
3
3
|
/** Cast a kind 0 event to a Profile */
|
|
4
4
|
export declare class Profile extends EventCast<ProfileEvent> {
|
|
5
5
|
constructor(event: NostrEvent, store: CastRefEventStore);
|
|
6
|
+
/** The parsed JSON content of the profile */
|
|
6
7
|
get metadata(): import("applesauce-core/helpers").ProfileContent;
|
|
8
|
+
/** The nickname or full name of the user */
|
|
7
9
|
get name(): string | undefined;
|
|
10
|
+
/** The display name with fallback to the name */
|
|
8
11
|
get displayName(): string | undefined;
|
|
12
|
+
/** The short bio of the user */
|
|
9
13
|
get about(): string | undefined;
|
|
14
|
+
/** The profile picture URL */
|
|
10
15
|
get picture(): string | undefined;
|
|
16
|
+
/** The NIP-92 imeta metadata for the profile picture */
|
|
17
|
+
get pictureMetadata(): import("../helpers/file-metadata.js").FileMetadataFields | undefined;
|
|
18
|
+
/** The wide banner image URL */
|
|
11
19
|
get banner(): string | undefined;
|
|
20
|
+
/** The NIP-92 imeta metadata for the banner image */
|
|
21
|
+
get bannerMetadata(): import("../helpers/file-metadata.js").FileMetadataFields | undefined;
|
|
22
|
+
/** The NIP-05 DNS identifier */
|
|
12
23
|
get dnsIdentity(): string | undefined;
|
|
24
|
+
/** The website URL */
|
|
13
25
|
get website(): string | undefined;
|
|
26
|
+
/** The LUD-16 lightning address */
|
|
14
27
|
get lud16(): string | undefined;
|
|
28
|
+
/** The LUD-06 LNURL */
|
|
15
29
|
get lud06(): string | undefined;
|
|
30
|
+
/** The LUD-16 lightning address with fallback to the LUD-06 LNURL */
|
|
16
31
|
get lightningAddress(): string | undefined;
|
|
32
|
+
/** Whether the profile is automated */
|
|
17
33
|
get bot(): boolean | undefined;
|
|
34
|
+
/** The birth date of the user, each field may be missing */
|
|
18
35
|
get birthday(): {
|
|
19
36
|
year?: number;
|
|
20
37
|
month?: number;
|
|
21
38
|
day?: number;
|
|
22
39
|
} | undefined;
|
|
40
|
+
/** The preferred languages of the user in BCP 47 format */
|
|
23
41
|
get languages(): string[] | undefined;
|
|
42
|
+
/** The lowercase hashtags from the NIP-24 "t" tags */
|
|
43
|
+
get hashtags(): string[];
|
|
24
44
|
}
|
package/dist/casts/profile.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { getDisplayName, getProfileContent, getProfilePicture, isValidProfile } from "applesauce-core/helpers/profile";
|
|
2
|
+
import { isTTag } from "applesauce-core/helpers/tags";
|
|
3
|
+
import { getMediaAttachments } from "../helpers/file-metadata.js";
|
|
2
4
|
import { EventCast } from "./cast.js";
|
|
3
5
|
/** Cast a kind 0 event to a Profile */
|
|
4
6
|
export class Profile extends EventCast {
|
|
@@ -7,46 +9,74 @@ export class Profile extends EventCast {
|
|
|
7
9
|
throw new Error("Invalid profile");
|
|
8
10
|
super(event, store);
|
|
9
11
|
}
|
|
12
|
+
/** The parsed JSON content of the profile */
|
|
10
13
|
get metadata() {
|
|
11
14
|
return getProfileContent(this.event);
|
|
12
15
|
}
|
|
16
|
+
/** The nickname or full name of the user */
|
|
13
17
|
get name() {
|
|
14
18
|
return this.metadata.name;
|
|
15
19
|
}
|
|
20
|
+
/** The display name with fallback to the name */
|
|
16
21
|
get displayName() {
|
|
17
22
|
return getDisplayName(this.metadata);
|
|
18
23
|
}
|
|
24
|
+
/** The short bio of the user */
|
|
19
25
|
get about() {
|
|
20
26
|
return this.metadata.about;
|
|
21
27
|
}
|
|
28
|
+
/** The profile picture URL */
|
|
22
29
|
get picture() {
|
|
23
30
|
return getProfilePicture(this.metadata);
|
|
24
31
|
}
|
|
32
|
+
/** The NIP-92 imeta metadata for the profile picture */
|
|
33
|
+
get pictureMetadata() {
|
|
34
|
+
const url = this.picture;
|
|
35
|
+
return url ? getMediaAttachments(this.event).find((m) => m.url === url) : undefined;
|
|
36
|
+
}
|
|
37
|
+
/** The wide banner image URL */
|
|
25
38
|
get banner() {
|
|
26
39
|
return this.metadata.banner;
|
|
27
40
|
}
|
|
41
|
+
/** The NIP-92 imeta metadata for the banner image */
|
|
42
|
+
get bannerMetadata() {
|
|
43
|
+
const url = this.banner;
|
|
44
|
+
return url ? getMediaAttachments(this.event).find((m) => m.url === url) : undefined;
|
|
45
|
+
}
|
|
46
|
+
/** The NIP-05 DNS identifier */
|
|
28
47
|
get dnsIdentity() {
|
|
29
48
|
return this.metadata.nip05;
|
|
30
49
|
}
|
|
50
|
+
/** The website URL */
|
|
31
51
|
get website() {
|
|
32
52
|
return this.metadata.website;
|
|
33
53
|
}
|
|
54
|
+
/** The LUD-16 lightning address */
|
|
34
55
|
get lud16() {
|
|
35
56
|
return this.metadata.lud16;
|
|
36
57
|
}
|
|
58
|
+
/** The LUD-06 LNURL */
|
|
37
59
|
get lud06() {
|
|
38
60
|
return this.metadata.lud06;
|
|
39
61
|
}
|
|
62
|
+
/** The LUD-16 lightning address with fallback to the LUD-06 LNURL */
|
|
40
63
|
get lightningAddress() {
|
|
41
64
|
return this.metadata.lud16 || this.metadata.lud06;
|
|
42
65
|
}
|
|
66
|
+
/** Whether the profile is automated */
|
|
43
67
|
get bot() {
|
|
44
68
|
return this.metadata.bot;
|
|
45
69
|
}
|
|
70
|
+
/** The birth date of the user, each field may be missing */
|
|
46
71
|
get birthday() {
|
|
47
72
|
return this.metadata.birthday;
|
|
48
73
|
}
|
|
74
|
+
/** The preferred languages of the user in BCP 47 format */
|
|
49
75
|
get languages() {
|
|
50
76
|
return this.metadata.languages;
|
|
51
77
|
}
|
|
78
|
+
/** The lowercase hashtags from the NIP-24 "t" tags */
|
|
79
|
+
get hashtags() {
|
|
80
|
+
return this.event.tags.filter(isTTag).map((t) => t[1].toLowerCase());
|
|
81
|
+
}
|
|
52
82
|
}
|
package/dist/casts/reaction.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export declare class Reaction extends EventCast<KnownEvent<7>> {
|
|
|
11
11
|
/** Get the address pointer for the event being reacted to (for replaceable events) */
|
|
12
12
|
get addressPointer(): import("nostr-tools/nip19").AddressPointer | undefined;
|
|
13
13
|
/** Get the pointer (event or address) for the event being reacted to */
|
|
14
|
-
get reactedPointer(): import("nostr-tools/nip19").
|
|
14
|
+
get reactedPointer(): import("nostr-tools/nip19").AddressPointer | import("nostr-tools/nip19").EventPointer | undefined;
|
|
15
15
|
/** Get the event that this reaction is reacting to */
|
|
16
16
|
get reactedTo$(): import("applesauce-core").ChainableObservable<NostrEvent | undefined>;
|
|
17
17
|
/** Alias for {@link reactedTo$} */
|
|
@@ -14,6 +14,8 @@ export declare class RelayDiscovery extends EventCast<RelayDiscoveryEvent> {
|
|
|
14
14
|
get rttWrite(): number | undefined;
|
|
15
15
|
/** Gets the network type from this discovery event (clearnet, tor, i2p, loki) */
|
|
16
16
|
get networkType(): string | undefined;
|
|
17
|
+
/** Gets all relay types from this discovery event (from `T` tags) */
|
|
18
|
+
get types(): string[];
|
|
17
19
|
/** Gets all relay attributes from this discovery event (from `W` tags) */
|
|
18
20
|
get attributes(): string[];
|
|
19
21
|
/** Gets all supported NIPs from this discovery event (from `N` tags) */
|
|
@@ -26,4 +28,6 @@ export declare class RelayDiscovery extends EventCast<RelayDiscoveryEvent> {
|
|
|
26
28
|
get acceptedKinds(): string[];
|
|
27
29
|
/** Gets the geohash from this discovery event (NIP-52 geohash) */
|
|
28
30
|
get geohash(): string | undefined;
|
|
31
|
+
/** Gets all geohashes from this discovery event (from `g` tags) */
|
|
32
|
+
get geohashes(): string[];
|
|
29
33
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getRelayDiscoveryAcceptedKinds, getRelayDiscoveryAttributes, getRelayDiscoveryGeohash, getRelayDiscoveryNetworkType, getRelayDiscoveryRequirements, getRelayDiscoveryRTT, getRelayDiscoverySupportedNIPs, getRelayDiscoveryTopics, getRelayDiscoveryURL, isValidRelayDiscovery, } from "../helpers/relay-discovery.js";
|
|
1
|
+
import { getRelayDiscoveryAcceptedKinds, getRelayDiscoveryAttributes, getRelayDiscoveryGeohash, getRelayDiscoveryGeohashes, getRelayDiscoveryNetworkType, getRelayDiscoveryRequirements, getRelayDiscoveryRTT, getRelayDiscoverySupportedNIPs, getRelayDiscoveryTopics, getRelayDiscoveryTypes, getRelayDiscoveryURL, isValidRelayDiscovery, } from "../helpers/relay-discovery.js";
|
|
2
2
|
import { EventCast } from "./cast.js";
|
|
3
3
|
/** Cast a kind 30166 event to a RelayDiscovery */
|
|
4
4
|
export class RelayDiscovery extends EventCast {
|
|
@@ -27,6 +27,10 @@ export class RelayDiscovery extends EventCast {
|
|
|
27
27
|
get networkType() {
|
|
28
28
|
return getRelayDiscoveryNetworkType(this.event);
|
|
29
29
|
}
|
|
30
|
+
/** Gets all relay types from this discovery event (from `T` tags) */
|
|
31
|
+
get types() {
|
|
32
|
+
return getRelayDiscoveryTypes(this.event);
|
|
33
|
+
}
|
|
30
34
|
/** Gets all relay attributes from this discovery event (from `W` tags) */
|
|
31
35
|
get attributes() {
|
|
32
36
|
return getRelayDiscoveryAttributes(this.event);
|
|
@@ -51,4 +55,8 @@ export class RelayDiscovery extends EventCast {
|
|
|
51
55
|
get geohash() {
|
|
52
56
|
return getRelayDiscoveryGeohash(this.event);
|
|
53
57
|
}
|
|
58
|
+
/** Gets all geohashes from this discovery event (from `g` tags) */
|
|
59
|
+
get geohashes() {
|
|
60
|
+
return getRelayDiscoveryGeohashes(this.event);
|
|
61
|
+
}
|
|
54
62
|
}
|
package/dist/casts/report.d.ts
CHANGED
|
@@ -1,31 +1,44 @@
|
|
|
1
1
|
import { KnownEvent, NostrEvent } from "applesauce-core/helpers/event";
|
|
2
|
-
import { ReportReason, ReportedEvent, ReportedUser } from "../helpers/reports.js";
|
|
2
|
+
import { REPORT_KIND, ReportReason, ReportedEvent, ReportedUser } from "../helpers/reports.js";
|
|
3
3
|
import { CastRefEventStore, EventCast } from "./cast.js";
|
|
4
|
-
|
|
5
|
-
/**
|
|
4
|
+
import { EventPointer } from "applesauce-core/helpers";
|
|
5
|
+
/** A NIP-56 report with typed targets and related users and events */
|
|
6
6
|
export declare class Report extends EventCast<KnownEvent<typeof REPORT_KIND>> {
|
|
7
|
+
/**
|
|
8
|
+
* Creates a report cast
|
|
9
|
+
* @throws if the event lacks valid report targets or context
|
|
10
|
+
*/
|
|
7
11
|
constructor(event: NostrEvent, store: CastRefEventStore);
|
|
8
|
-
/**
|
|
12
|
+
/** Returns every explicitly reported target with its reason */
|
|
13
|
+
get targets(): import("../helpers/reports.js").ReportTarget[];
|
|
14
|
+
/** Returns all explicitly reported users */
|
|
15
|
+
get reportedUsers(): import("applesauce-core/casts").User[];
|
|
16
|
+
/** Checks whether this report explicitly targets media */
|
|
17
|
+
get isBlobReport(): boolean;
|
|
18
|
+
/** Returns pointers to all reported events and blob context events */
|
|
19
|
+
get reportedEventPointers(): EventPointer[];
|
|
20
|
+
/** Subscribes to all reported events and blob context events */
|
|
21
|
+
get reportedEvents$(): import("applesauce-core").ChainableObservable<(NostrEvent | undefined)[]>;
|
|
22
|
+
/** Gets the parsed report data (either a user or event report) */
|
|
9
23
|
get reported(): ReportedEvent | ReportedUser | null;
|
|
10
|
-
/**
|
|
24
|
+
/** Checks if this is a user report */
|
|
11
25
|
get isUserReport(): boolean;
|
|
12
|
-
/**
|
|
26
|
+
/** Checks if this is an event report */
|
|
13
27
|
get isEventReport(): boolean;
|
|
14
|
-
/**
|
|
28
|
+
/** Gets the reason for the report */
|
|
15
29
|
get reason(): ReportReason | undefined;
|
|
16
|
-
/**
|
|
30
|
+
/** Gets the comment/content of the report */
|
|
17
31
|
get comment(): string | undefined;
|
|
18
|
-
/**
|
|
32
|
+
/** Gets the pubkey of the user being reported */
|
|
19
33
|
get reportedPubkey(): string | undefined;
|
|
20
|
-
/**
|
|
34
|
+
/** Gets the User being reported */
|
|
21
35
|
get reportedUser(): import("applesauce-core/casts").User | undefined;
|
|
22
|
-
/**
|
|
36
|
+
/** Gets the event ID being reported (for event reports) */
|
|
23
37
|
get reportedEventId(): string | undefined;
|
|
24
|
-
/**
|
|
38
|
+
/** Gets the event being reported (for event reports) */
|
|
25
39
|
get reportedEvent$(): import("applesauce-core").ChainableObservable<NostrEvent | undefined>;
|
|
26
|
-
/**
|
|
40
|
+
/** Gets the blob hashes being reported (for event reports with x tags) */
|
|
27
41
|
get blobs(): string[] | undefined;
|
|
28
|
-
/**
|
|
42
|
+
/** Gets the server URLs for blob reports */
|
|
29
43
|
get servers(): string[];
|
|
30
44
|
}
|
|
31
|
-
export {};
|
package/dist/casts/report.js
CHANGED
|
@@ -1,57 +1,80 @@
|
|
|
1
|
-
import { of } from "rxjs";
|
|
2
|
-
import { getReportServers, getReported } from "../helpers/reports.js";
|
|
1
|
+
import { combineLatest, of } from "rxjs";
|
|
2
|
+
import { getReportTargets, isReportIdentifier, isValidReport, getReportServers, getReported, } from "../helpers/reports.js";
|
|
3
3
|
import { EventCast } from "./cast.js";
|
|
4
4
|
import { castUser } from "./user.js";
|
|
5
5
|
import { addRelayHintsToPointer } from "applesauce-core/helpers";
|
|
6
|
-
|
|
7
|
-
function isValidReport(event) {
|
|
8
|
-
return event.kind === REPORT_KIND;
|
|
9
|
-
}
|
|
10
|
-
/** Cast a kind 1984 event to a Report */
|
|
6
|
+
/** A NIP-56 report with typed targets and related users and events */
|
|
11
7
|
export class Report extends EventCast {
|
|
8
|
+
/**
|
|
9
|
+
* Creates a report cast
|
|
10
|
+
* @throws if the event lacks valid report targets or context
|
|
11
|
+
*/
|
|
12
12
|
constructor(event, store) {
|
|
13
13
|
if (!isValidReport(event))
|
|
14
14
|
throw new Error("Invalid report");
|
|
15
15
|
super(event, store);
|
|
16
16
|
}
|
|
17
|
-
/**
|
|
17
|
+
/** Returns every explicitly reported target with its reason */
|
|
18
|
+
get targets() {
|
|
19
|
+
return getReportTargets(this.event);
|
|
20
|
+
}
|
|
21
|
+
/** Returns all explicitly reported users */
|
|
22
|
+
get reportedUsers() {
|
|
23
|
+
return this.targets.filter((t) => t.type === "user").map((t) => castUser(t.value, this.store));
|
|
24
|
+
}
|
|
25
|
+
/** Checks whether this report explicitly targets media */
|
|
26
|
+
get isBlobReport() {
|
|
27
|
+
return this.targets.some((t) => t.type === "blob");
|
|
28
|
+
}
|
|
29
|
+
/** Returns pointers to all reported events and blob context events */
|
|
30
|
+
get reportedEventPointers() {
|
|
31
|
+
return [...new Set(this.event.tags.filter((t) => t[0] === "e" && isReportIdentifier(t[1])).map((t) => t[1]))].map((id) => addRelayHintsToPointer({ id }, this.seen));
|
|
32
|
+
}
|
|
33
|
+
/** Subscribes to all reported events and blob context events */
|
|
34
|
+
get reportedEvents$() {
|
|
35
|
+
return this.$$ref("reportedEvents$", (store) => {
|
|
36
|
+
const pointers = this.reportedEventPointers;
|
|
37
|
+
return pointers.length ? combineLatest(pointers.map((p) => store.event(p))) : of([]);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
/** Gets the parsed report data (either a user or event report) */
|
|
18
41
|
get reported() {
|
|
19
42
|
return getReported(this.event);
|
|
20
43
|
}
|
|
21
|
-
/**
|
|
44
|
+
/** Checks if this is a user report */
|
|
22
45
|
get isUserReport() {
|
|
23
46
|
return this.reported?.type === "user";
|
|
24
47
|
}
|
|
25
|
-
/**
|
|
48
|
+
/** Checks if this is an event report */
|
|
26
49
|
get isEventReport() {
|
|
27
50
|
return this.reported?.type === "event";
|
|
28
51
|
}
|
|
29
|
-
/**
|
|
52
|
+
/** Gets the reason for the report */
|
|
30
53
|
get reason() {
|
|
31
54
|
return this.reported?.reason;
|
|
32
55
|
}
|
|
33
|
-
/**
|
|
56
|
+
/** Gets the comment/content of the report */
|
|
34
57
|
get comment() {
|
|
35
58
|
if (!this.reported)
|
|
36
59
|
return undefined;
|
|
37
|
-
return this.reported.
|
|
60
|
+
return this.reported.comment;
|
|
38
61
|
}
|
|
39
|
-
/**
|
|
62
|
+
/** Gets the pubkey of the user being reported */
|
|
40
63
|
get reportedPubkey() {
|
|
41
64
|
return this.reported?.pubkey;
|
|
42
65
|
}
|
|
43
|
-
/**
|
|
66
|
+
/** Gets the User being reported */
|
|
44
67
|
get reportedUser() {
|
|
45
68
|
const pubkey = this.reportedPubkey;
|
|
46
69
|
if (!pubkey)
|
|
47
70
|
return undefined;
|
|
48
71
|
return castUser(pubkey, this.store);
|
|
49
72
|
}
|
|
50
|
-
/**
|
|
73
|
+
/** Gets the event ID being reported (for event reports) */
|
|
51
74
|
get reportedEventId() {
|
|
52
75
|
return this.reported?.type === "event" ? this.reported.id : undefined;
|
|
53
76
|
}
|
|
54
|
-
/**
|
|
77
|
+
/** Gets the event being reported (for event reports) */
|
|
55
78
|
get reportedEvent$() {
|
|
56
79
|
return this.$$ref("reportedEvent$", (store) => {
|
|
57
80
|
const eventId = this.reportedEventId;
|
|
@@ -63,11 +86,11 @@ export class Report extends EventCast {
|
|
|
63
86
|
return store.event(addRelayHintsToPointer(pointer, this.seen));
|
|
64
87
|
});
|
|
65
88
|
}
|
|
66
|
-
/**
|
|
89
|
+
/** Gets the blob hashes being reported (for event reports with x tags) */
|
|
67
90
|
get blobs() {
|
|
68
91
|
return this.reported?.type === "event" ? this.reported.blobs : undefined;
|
|
69
92
|
}
|
|
70
|
-
/**
|
|
93
|
+
/** Gets the server URLs for blob reports */
|
|
71
94
|
get servers() {
|
|
72
95
|
return getReportServers(this.event);
|
|
73
96
|
}
|
package/dist/casts/share.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export declare class Share extends EventCast<ShareEvent> {
|
|
|
9
9
|
get embedded(): NostrEvent | undefined;
|
|
10
10
|
get sharedAddressPointer(): import("nostr-tools/nip19").AddressPointer | undefined;
|
|
11
11
|
get sharedEventPointer(): import("nostr-tools/nip19").EventPointer;
|
|
12
|
-
get sharedPointer(): import("nostr-tools/nip19").
|
|
12
|
+
get sharedPointer(): import("nostr-tools/nip19").AddressPointer | import("nostr-tools/nip19").EventPointer;
|
|
13
13
|
get shared$(): import("applesauce-core").ChainableObservable<NostrEvent | undefined>;
|
|
14
14
|
get reactions$(): import("applesauce-core").ChainableObservable<Reaction[]>;
|
|
15
15
|
}
|
package/dist/casts/torrent.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { CastRefEventStore, EventCast } from "./cast.js";
|
|
|
4
4
|
import { Comment } from "./comment.js";
|
|
5
5
|
import { Reaction } from "./reaction.js";
|
|
6
6
|
import { Zap } from "./zap.js";
|
|
7
|
+
/** A cast for NIP-35 torrent events (kind 2003) */
|
|
7
8
|
export declare class Torrent extends EventCast<TorrentEvent> {
|
|
8
9
|
constructor(event: NostrEvent, store: CastRefEventStore);
|
|
9
10
|
/** The BitTorrent info hash from the `x` tag */
|
|
@@ -20,12 +21,16 @@ export declare class Torrent extends EventCast<TorrentEvent> {
|
|
|
20
21
|
get searchTags(): string[];
|
|
21
22
|
/** The category path from the `tcat` identifier in `i` tags (e.g., "video,movie,4k") */
|
|
22
23
|
get categoryPath(): string | undefined;
|
|
24
|
+
/** The category path split into its parts (e.g., ["video", "movie", "4k"]) */
|
|
25
|
+
get categoryPathParts(): string[];
|
|
23
26
|
/** All external identifiers from `i` tags (excluding tcat and newznab, which are handled separately) */
|
|
24
27
|
get externalIdentifiers(): import("../helpers/torrent.js").TorrentExternalIdentifier[];
|
|
25
28
|
/** The magnet link for the torrent, built from the info hash, trackers, and title */
|
|
26
29
|
get magnetLink(): string | undefined;
|
|
27
30
|
/** Gets the NIP-22 comments to this event */
|
|
28
31
|
get comments$(): import("applesauce-core").ChainableObservable<Comment[]>;
|
|
32
|
+
/** Gets the zaps on this torrent */
|
|
29
33
|
get zaps$(): import("applesauce-core").ChainableObservable<Zap[]>;
|
|
34
|
+
/** Gets the reactions to this torrent */
|
|
30
35
|
get reactions$(): import("applesauce-core").ChainableObservable<Reaction[]>;
|
|
31
36
|
}
|
package/dist/casts/torrent.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getTorrentCategory, getTorrentCategoryPath, getTorrentExternalIdentifiers, getTorrentFiles, getTorrentInfoHash, getTorrentMagnetLink, getTorrentSearchTags, getTorrentTitle, getTorrentTrackers, isValidTorrent, } from "../helpers/torrent.js";
|
|
1
|
+
import { getTorrentCategory, getTorrentCategoryPath, getTorrentCategoryPathParts, getTorrentExternalIdentifiers, getTorrentFiles, getTorrentInfoHash, getTorrentMagnetLink, getTorrentSearchTags, getTorrentTitle, getTorrentTrackers, isValidTorrent, } from "../helpers/torrent.js";
|
|
2
2
|
import { CommentsModel } from "../models/comments.js";
|
|
3
3
|
import { ReactionsModel } from "../models/reactions.js";
|
|
4
4
|
import { EventZapsModel } from "../models/zaps.js";
|
|
@@ -7,6 +7,7 @@ import { EventCast } from "./cast.js";
|
|
|
7
7
|
import { Comment } from "./comment.js";
|
|
8
8
|
import { Reaction } from "./reaction.js";
|
|
9
9
|
import { Zap } from "./zap.js";
|
|
10
|
+
/** A cast for NIP-35 torrent events (kind 2003) */
|
|
10
11
|
export class Torrent extends EventCast {
|
|
11
12
|
constructor(event, store) {
|
|
12
13
|
if (!isValidTorrent(event))
|
|
@@ -41,6 +42,10 @@ export class Torrent extends EventCast {
|
|
|
41
42
|
get categoryPath() {
|
|
42
43
|
return getTorrentCategoryPath(this.event);
|
|
43
44
|
}
|
|
45
|
+
/** The category path split into its parts (e.g., ["video", "movie", "4k"]) */
|
|
46
|
+
get categoryPathParts() {
|
|
47
|
+
return getTorrentCategoryPathParts(this.event);
|
|
48
|
+
}
|
|
44
49
|
/** All external identifiers from `i` tags (excluding tcat and newznab, which are handled separately) */
|
|
45
50
|
get externalIdentifiers() {
|
|
46
51
|
return getTorrentExternalIdentifiers(this.event);
|
|
@@ -53,9 +58,11 @@ export class Torrent extends EventCast {
|
|
|
53
58
|
get comments$() {
|
|
54
59
|
return this.$$ref("comments$", (store) => store.model(CommentsModel, this.event).pipe(castTimelineStream(Comment, store)));
|
|
55
60
|
}
|
|
61
|
+
/** Gets the zaps on this torrent */
|
|
56
62
|
get zaps$() {
|
|
57
63
|
return this.$$ref("zaps$", (store) => store.model(EventZapsModel, this.event).pipe(castTimelineStream(Zap, store)));
|
|
58
64
|
}
|
|
65
|
+
/** Gets the reactions to this torrent */
|
|
59
66
|
get reactions$() {
|
|
60
67
|
return this.$$ref("reactions$", (store) => store.model(ReactionsModel, this.event).pipe(castTimelineStream(Reaction, store)));
|
|
61
68
|
}
|
|
@@ -55,6 +55,8 @@ export declare class TrustedProviderList extends EventCast<TrustedProviderListEv
|
|
|
55
55
|
get unlocked(): boolean;
|
|
56
56
|
/** Decrypt and unlock the hidden providers */
|
|
57
57
|
unlock(signer: HiddenContentSigner): Promise<TrustedProvider[]>;
|
|
58
|
+
/** Returns providers trusted for one assertion kind and metric tag */
|
|
59
|
+
providersFor$(kind: number, tag: string): import("applesauce-core/observable").ChainableObservable<AssertionProvider[]>;
|
|
58
60
|
/** Providers trusted for user rank (0–100) */
|
|
59
61
|
get userRank$(): import("applesauce-core/observable").ChainableObservable<AssertionProvider[]>;
|
|
60
62
|
/** Providers trusted for user follower count */
|
|
@@ -112,77 +112,78 @@ export class TrustedProviderList extends EventCast {
|
|
|
112
112
|
#allProviders$() {
|
|
113
113
|
return combineLatest([of(this.publicProviders), this.hiddenProviders$]).pipe(map(([pub, hidden]) => [...pub, ...(hidden ?? [])]));
|
|
114
114
|
}
|
|
115
|
-
|
|
115
|
+
/** Returns providers trusted for one assertion kind and metric tag */
|
|
116
|
+
providersFor$(kind, tag) {
|
|
116
117
|
return this.$$ref(`providers:${kind}:${tag}`, (store) => this.#allProviders$().pipe(map((all) => toAssertionProviders(all.filter((p) => p.kind === kind && p.tag === tag), store))));
|
|
117
118
|
}
|
|
118
119
|
// ── Kind 30382 (User assertion) provider observables ─────────────────────
|
|
119
120
|
/** Providers trusted for user rank (0–100) */
|
|
120
121
|
get userRank$() {
|
|
121
|
-
return this
|
|
122
|
+
return this.providersFor$(USER_ASSERTION_KIND, "rank");
|
|
122
123
|
}
|
|
123
124
|
/** Providers trusted for user follower count */
|
|
124
125
|
get userFollowers$() {
|
|
125
|
-
return this
|
|
126
|
+
return this.providersFor$(USER_ASSERTION_KIND, "followers");
|
|
126
127
|
}
|
|
127
128
|
/** Providers trusted for user first post timestamp */
|
|
128
129
|
get userFirstCreatedAt$() {
|
|
129
|
-
return this
|
|
130
|
+
return this.providersFor$(USER_ASSERTION_KIND, "first_created_at");
|
|
130
131
|
}
|
|
131
132
|
/** Providers trusted for user post count */
|
|
132
133
|
get userPostCount$() {
|
|
133
|
-
return this
|
|
134
|
+
return this.providersFor$(USER_ASSERTION_KIND, "post_cnt");
|
|
134
135
|
}
|
|
135
136
|
/** Providers trusted for user reply count */
|
|
136
137
|
get userReplyCount$() {
|
|
137
|
-
return this
|
|
138
|
+
return this.providersFor$(USER_ASSERTION_KIND, "reply_cnt");
|
|
138
139
|
}
|
|
139
140
|
/** Providers trusted for user reactions count */
|
|
140
141
|
get userReactionsCount$() {
|
|
141
|
-
return this
|
|
142
|
+
return this.providersFor$(USER_ASSERTION_KIND, "reactions_cnt");
|
|
142
143
|
}
|
|
143
144
|
/** Providers trusted for zap amount received */
|
|
144
145
|
get userZapAmountReceived$() {
|
|
145
|
-
return this
|
|
146
|
+
return this.providersFor$(USER_ASSERTION_KIND, "zap_amt_recd");
|
|
146
147
|
}
|
|
147
148
|
/** Providers trusted for zap amount sent */
|
|
148
149
|
get userZapAmountSent$() {
|
|
149
|
-
return this
|
|
150
|
+
return this.providersFor$(USER_ASSERTION_KIND, "zap_amt_sent");
|
|
150
151
|
}
|
|
151
152
|
/** Providers trusted for zap count received */
|
|
152
153
|
get userZapCountReceived$() {
|
|
153
|
-
return this
|
|
154
|
+
return this.providersFor$(USER_ASSERTION_KIND, "zap_cnt_recd");
|
|
154
155
|
}
|
|
155
156
|
/** Providers trusted for zap count sent */
|
|
156
157
|
get userZapCountSent$() {
|
|
157
|
-
return this
|
|
158
|
+
return this.providersFor$(USER_ASSERTION_KIND, "zap_cnt_sent");
|
|
158
159
|
}
|
|
159
160
|
/** Providers trusted for average daily zap amount received */
|
|
160
161
|
get userZapAvgAmountDayReceived$() {
|
|
161
|
-
return this
|
|
162
|
+
return this.providersFor$(USER_ASSERTION_KIND, "zap_avg_amt_day_recd");
|
|
162
163
|
}
|
|
163
164
|
/** Providers trusted for average daily zap amount sent */
|
|
164
165
|
get userZapAvgAmountDaySent$() {
|
|
165
|
-
return this
|
|
166
|
+
return this.providersFor$(USER_ASSERTION_KIND, "zap_avg_amt_day_sent");
|
|
166
167
|
}
|
|
167
168
|
/** Providers trusted for reports received count */
|
|
168
169
|
get userReportsReceived$() {
|
|
169
|
-
return this
|
|
170
|
+
return this.providersFor$(USER_ASSERTION_KIND, "reports_cnt_recd");
|
|
170
171
|
}
|
|
171
172
|
/** Providers trusted for reports sent count */
|
|
172
173
|
get userReportsSent$() {
|
|
173
|
-
return this
|
|
174
|
+
return this.providersFor$(USER_ASSERTION_KIND, "reports_cnt_sent");
|
|
174
175
|
}
|
|
175
176
|
/** Providers trusted for user common topics */
|
|
176
177
|
get userTopics$() {
|
|
177
|
-
return this
|
|
178
|
+
return this.providersFor$(USER_ASSERTION_KIND, "t");
|
|
178
179
|
}
|
|
179
180
|
/** Providers trusted for user activity hours start */
|
|
180
181
|
get userActivityHoursStart$() {
|
|
181
|
-
return this
|
|
182
|
+
return this.providersFor$(USER_ASSERTION_KIND, "active_hours_start");
|
|
182
183
|
}
|
|
183
184
|
/** Providers trusted for user activity hours end */
|
|
184
185
|
get userActivityHoursEnd$() {
|
|
185
|
-
return this
|
|
186
|
+
return this.providersFor$(USER_ASSERTION_KIND, "active_hours_end");
|
|
186
187
|
}
|
|
187
188
|
}
|
|
188
189
|
// ─── UserAssertion ───────────────────────────────────────────────────────────
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ChainableObservable } from "applesauce-core";
|
|
2
|
+
import { User } from "applesauce-core/casts/user";
|
|
3
|
+
import { NostrEvent } from "applesauce-core/helpers/event";
|
|
4
|
+
import { UserStatusEvent, UserStatusPointer } from "../helpers/user-status.js";
|
|
5
|
+
import { CastRefEventStore, EventCast } from "./cast.js";
|
|
6
|
+
/** Cast for NIP-38 user status events (kind 30315) */
|
|
7
|
+
export declare class UserStatus extends EventCast<UserStatusEvent> {
|
|
8
|
+
constructor(event: NostrEvent, store: CastRefEventStore);
|
|
9
|
+
/** The status type ("general", "music", etc) */
|
|
10
|
+
get type(): import("../helpers/user-status.js").UserStatusType;
|
|
11
|
+
/** The status text */
|
|
12
|
+
get content(): string;
|
|
13
|
+
/** Whether the status has been cleared (empty content) */
|
|
14
|
+
get cleared(): boolean;
|
|
15
|
+
/** The unix timestamp when the status expires */
|
|
16
|
+
get expiration(): number | undefined;
|
|
17
|
+
/** The URL, profile, event, or address the status links to */
|
|
18
|
+
get link(): UserStatusPointer | null;
|
|
19
|
+
/** The URL the status links to */
|
|
20
|
+
get url(): string | undefined;
|
|
21
|
+
/** The user the status links to */
|
|
22
|
+
get user(): User | undefined;
|
|
23
|
+
/** The event the status links to */
|
|
24
|
+
get linkedEvent$(): ChainableObservable<NostrEvent | undefined>;
|
|
25
|
+
}
|
|
26
|
+
declare module "applesauce-core/casts" {
|
|
27
|
+
interface User {
|
|
28
|
+
/** The user's "general" status */
|
|
29
|
+
get status$(): ChainableObservable<UserStatus | undefined>;
|
|
30
|
+
/** All of the user's statuses that have not been cleared */
|
|
31
|
+
get statuses$(): ChainableObservable<UserStatus[]>;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { castUser, User } from "applesauce-core/casts/user";
|
|
2
|
+
import { getExpirationTimestamp } from "applesauce-core/helpers/expiration";
|
|
3
|
+
import { kinds } from "applesauce-core/helpers/event";
|
|
4
|
+
import { addRelayHintsToPointer } from "applesauce-core/helpers";
|
|
5
|
+
import { map, of } from "rxjs";
|
|
6
|
+
import { getUserStatusPointer, getUserStatusType, isUserStatusCleared, isValidUserStatus, } from "../helpers/user-status.js";
|
|
7
|
+
import { castEventStream, castTimelineStream } from "../observable/cast-stream.js";
|
|
8
|
+
import { EventCast } from "./cast.js";
|
|
9
|
+
/** Cast for NIP-38 user status events (kind 30315) */
|
|
10
|
+
export class UserStatus extends EventCast {
|
|
11
|
+
constructor(event, store) {
|
|
12
|
+
if (!isValidUserStatus(event))
|
|
13
|
+
throw new Error("Invalid user status");
|
|
14
|
+
super(event, store);
|
|
15
|
+
}
|
|
16
|
+
/** The status type ("general", "music", etc) */
|
|
17
|
+
get type() {
|
|
18
|
+
return getUserStatusType(this.event);
|
|
19
|
+
}
|
|
20
|
+
/** The status text */
|
|
21
|
+
get content() {
|
|
22
|
+
return this.event.content;
|
|
23
|
+
}
|
|
24
|
+
/** Whether the status has been cleared (empty content) */
|
|
25
|
+
get cleared() {
|
|
26
|
+
return isUserStatusCleared(this.event);
|
|
27
|
+
}
|
|
28
|
+
/** The unix timestamp when the status expires */
|
|
29
|
+
get expiration() {
|
|
30
|
+
return getExpirationTimestamp(this.event);
|
|
31
|
+
}
|
|
32
|
+
/** The URL, profile, event, or address the status links to */
|
|
33
|
+
get link() {
|
|
34
|
+
return getUserStatusPointer(this.event);
|
|
35
|
+
}
|
|
36
|
+
/** The URL the status links to */
|
|
37
|
+
get url() {
|
|
38
|
+
const pointer = this.link;
|
|
39
|
+
return pointer?.type === "url" ? pointer.data : undefined;
|
|
40
|
+
}
|
|
41
|
+
/** The user the status links to */
|
|
42
|
+
get user() {
|
|
43
|
+
const pointer = this.link;
|
|
44
|
+
return pointer?.type === "nprofile" ? castUser(pointer.data, this.store) : undefined;
|
|
45
|
+
}
|
|
46
|
+
/** The event the status links to */
|
|
47
|
+
get linkedEvent$() {
|
|
48
|
+
return this.$$ref("linkedEvent$", (store) => {
|
|
49
|
+
const pointer = this.link;
|
|
50
|
+
if (pointer?.type !== "nevent" && pointer?.type !== "naddr")
|
|
51
|
+
return of(undefined);
|
|
52
|
+
return store.event(addRelayHintsToPointer(pointer.data, this.seen));
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
Object.defineProperty(User.prototype, "status$", {
|
|
57
|
+
get() {
|
|
58
|
+
return this.$$ref("status$", (store) => store.replaceable({ kind: kinds.UserStatuses, pubkey: this.pubkey, identifier: "general" }).pipe(castEventStream(UserStatus, store), map((status) => (status && !status.cleared ? status : undefined))));
|
|
59
|
+
},
|
|
60
|
+
configurable: true,
|
|
61
|
+
enumerable: false,
|
|
62
|
+
});
|
|
63
|
+
Object.defineProperty(User.prototype, "statuses$", {
|
|
64
|
+
get() {
|
|
65
|
+
return this.$$ref("statuses$", (store) => store.timeline({ kinds: [kinds.UserStatuses], authors: [this.pubkey] }).pipe(castTimelineStream(UserStatus, store), map((statuses) => statuses.filter((status) => !status.cleared))));
|
|
66
|
+
},
|
|
67
|
+
configurable: true,
|
|
68
|
+
enumerable: false,
|
|
69
|
+
});
|