applesauce-common 6.1.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 +4 -2
- package/dist/casts/trusted-assertions.js +20 -19
- 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 +23 -0
- package/dist/factories/index.js +23 -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/nostr-web-token.d.ts +39 -0
- package/dist/factories/nostr-web-token.js +95 -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.d.ts +1 -0
- package/dist/helpers/external-id.js +21 -46
- 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 +11 -0
- package/dist/helpers/index.js +11 -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/nostr-web-token.d.ts +54 -0
- package/dist/helpers/nostr-web-token.js +124 -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 +16 -0
- package/dist/operations/index.js +16 -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/nostr-web-token.d.ts +27 -0
- package/dist/operations/nostr-web-token.js +58 -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 +10 -10
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { serializeURL } from "applesauce-core/helpers/url";
|
|
1
2
|
import { ensureMarkedProfilePointerTag } from "applesauce-core/helpers/factory";
|
|
2
3
|
import { addNameValueTag, removeNameValueTag } from "applesauce-core/operations/tag/common";
|
|
3
4
|
import { includeSingletonTag, modifyPublicTags } from "applesauce-core/operations/tags";
|
|
@@ -17,11 +18,11 @@ export function setImage(image) {
|
|
|
17
18
|
}
|
|
18
19
|
/** Sets the streaming URL for a live event */
|
|
19
20
|
export function setStreamingUrl(url) {
|
|
20
|
-
return includeSingletonTag(["streaming",
|
|
21
|
+
return includeSingletonTag(["streaming", serializeURL(url)], true);
|
|
21
22
|
}
|
|
22
23
|
/** Sets the recording URL for a live event (typically after the event ends) */
|
|
23
24
|
export function setRecordingUrl(url) {
|
|
24
|
-
return includeSingletonTag(["recording",
|
|
25
|
+
return includeSingletonTag(["recording", serializeURL(url)], true);
|
|
25
26
|
}
|
|
26
27
|
/** Sets the start timestamp for a live event */
|
|
27
28
|
export function setStartTime(start) {
|
|
@@ -59,11 +60,11 @@ export function removeParticipant(pubkey) {
|
|
|
59
60
|
}
|
|
60
61
|
/** Adds a relay to the live event's relay list */
|
|
61
62
|
export function addRelay(relay) {
|
|
62
|
-
return modifyPublicTags(addNameValueTag(["relays",
|
|
63
|
+
return modifyPublicTags(addNameValueTag(["relays", serializeURL(relay)], true));
|
|
63
64
|
}
|
|
64
65
|
/** Removes a relay from the live event's relay list */
|
|
65
66
|
export function removeRelay(relay) {
|
|
66
|
-
return modifyPublicTags(removeNameValueTag(["relays",
|
|
67
|
+
return modifyPublicTags(removeNameValueTag(["relays", serializeURL(relay)]));
|
|
67
68
|
}
|
|
68
69
|
/** Sets a pinned live chat message */
|
|
69
70
|
export function setPinnedMessage(eventId) {
|
|
@@ -26,10 +26,7 @@ export declare function setTorrentCategoryPath(categoryPath: string): EventOpera
|
|
|
26
26
|
export declare function removeTorrentCategoryPath(): EventOperation;
|
|
27
27
|
/** Adds an external identifier */
|
|
28
28
|
export declare function addTorrentExternalIdentifier(identifier: TorrentExternalIdentifier): EventOperation;
|
|
29
|
-
/**
|
|
30
|
-
* Adds an external identifier using prefix, id, and optional mediaType
|
|
31
|
-
* Convenience function that creates the identifier object automatically
|
|
32
|
-
*/
|
|
29
|
+
/** Adds an external identifier built from a prefix, id, and optional media type */
|
|
33
30
|
export declare function addTorrentExternalIdentifierByParts(prefix: TorrentExternalIdentifierPrefix, id: string, mediaType?: string): EventOperation;
|
|
34
31
|
/** Removes an external identifier */
|
|
35
32
|
export declare function removeTorrentExternalIdentifier(identifier: string): EventOperation;
|
|
@@ -11,9 +11,7 @@ export function setTorrentTitle(title) {
|
|
|
11
11
|
}
|
|
12
12
|
/** Adds a file entry to the torrent */
|
|
13
13
|
export function addTorrentFile(file) {
|
|
14
|
-
const tag = file.size
|
|
15
|
-
? ["file", file.name, file.size.toString()]
|
|
16
|
-
: ["file", file.name];
|
|
14
|
+
const tag = file.size !== undefined ? ["file", file.name, file.size.toString()] : ["file", file.name];
|
|
17
15
|
return modifyPublicTags(addNameValueTag(tag, false));
|
|
18
16
|
}
|
|
19
17
|
/** Removes a file entry from the torrent */
|
|
@@ -28,13 +26,31 @@ export function addTorrentTracker(tracker) {
|
|
|
28
26
|
export function removeTorrentTracker(tracker) {
|
|
29
27
|
return modifyPublicTags(removeNameValueTag(["tracker", tracker]));
|
|
30
28
|
}
|
|
29
|
+
// Replaces the first `i` tag with the given prefix and removes the rest, leaving other `i` tags untouched
|
|
30
|
+
function setPrefixedIdentifierTag(prefix, value) {
|
|
31
|
+
return (tags) => {
|
|
32
|
+
const tag = ["i", `${prefix}:${value}`];
|
|
33
|
+
const index = tags.findIndex((t) => t[0] === "i" && t[1]?.startsWith(`${prefix}:`));
|
|
34
|
+
if (index === -1)
|
|
35
|
+
return [...tags, tag];
|
|
36
|
+
return tags.flatMap((t, i) => {
|
|
37
|
+
if (i === index)
|
|
38
|
+
return [tag];
|
|
39
|
+
return t[0] === "i" && t[1]?.startsWith(`${prefix}:`) ? [] : [t];
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
// Removes every `i` tag with the given prefix
|
|
44
|
+
function removePrefixedIdentifierTags(prefix) {
|
|
45
|
+
return (tags) => tags.filter((t) => !(t[0] === "i" && t[1]?.startsWith(`${prefix}:`)));
|
|
46
|
+
}
|
|
31
47
|
/** Sets the newznab category ID (replaces any existing newznab category) */
|
|
32
48
|
export function setTorrentCategory(categoryId) {
|
|
33
|
-
return modifyPublicTags(
|
|
49
|
+
return modifyPublicTags(setPrefixedIdentifierTag("newznab", String(categoryId)));
|
|
34
50
|
}
|
|
35
51
|
/** Removes the newznab category ID */
|
|
36
52
|
export function removeTorrentCategory() {
|
|
37
|
-
return modifyPublicTags((
|
|
53
|
+
return modifyPublicTags(removePrefixedIdentifierTags("newznab"));
|
|
38
54
|
}
|
|
39
55
|
/** Adds a search tag (for searchability) */
|
|
40
56
|
export function addTorrentSearchTag(tag) {
|
|
@@ -46,20 +62,17 @@ export function removeTorrentSearchTag(tag) {
|
|
|
46
62
|
}
|
|
47
63
|
/** Sets the category path (tcat) */
|
|
48
64
|
export function setTorrentCategoryPath(categoryPath) {
|
|
49
|
-
return modifyPublicTags(
|
|
65
|
+
return modifyPublicTags(setPrefixedIdentifierTag("tcat", categoryPath));
|
|
50
66
|
}
|
|
51
67
|
/** Removes the category path (tcat) */
|
|
52
68
|
export function removeTorrentCategoryPath() {
|
|
53
|
-
return modifyPublicTags((
|
|
69
|
+
return modifyPublicTags(removePrefixedIdentifierTags("tcat"));
|
|
54
70
|
}
|
|
55
71
|
/** Adds an external identifier */
|
|
56
72
|
export function addTorrentExternalIdentifier(identifier) {
|
|
57
73
|
return modifyPublicTags(addNameValueTag(["i", identifier.identifier], false));
|
|
58
74
|
}
|
|
59
|
-
/**
|
|
60
|
-
* Adds an external identifier using prefix, id, and optional mediaType
|
|
61
|
-
* Convenience function that creates the identifier object automatically
|
|
62
|
-
*/
|
|
75
|
+
/** Adds an external identifier built from a prefix, id, and optional media type */
|
|
63
76
|
export function addTorrentExternalIdentifierByParts(prefix, id, mediaType) {
|
|
64
77
|
const identifier = createTorrentExternalIdentifier(prefix, id, mediaType);
|
|
65
78
|
return addTorrentExternalIdentifier(identifier);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TagOperation } from "applesauce-core/factories";
|
|
2
|
+
import { TrustedProvider } from "../helpers/trusted-assertions.js";
|
|
3
|
+
/** A provider slot, optionally narrowed to a single service pubkey */
|
|
4
|
+
export type TrustedProviderSelector = Pick<TrustedProvider, "kind" | "tag"> & {
|
|
5
|
+
servicePubkey?: string;
|
|
6
|
+
};
|
|
7
|
+
/** Adds a provider to a kind 10040 tag list, or updates the relay hint of an existing entry */
|
|
8
|
+
export declare function addProviderTag(provider: TrustedProvider): TagOperation;
|
|
9
|
+
/** Removes a provider from a kind 10040 tag list, or every provider in the slot if no pubkey is given */
|
|
10
|
+
export declare function removeProviderTag(selector: TrustedProviderSelector): TagOperation;
|
|
11
|
+
/** Replaces every provider in the `kind:tag` slot with a single provider */
|
|
12
|
+
export declare function setProviderTag(provider: TrustedProvider): TagOperation;
|
|
13
|
+
/** Removes a service pubkey from every slot in a kind 10040 tag list */
|
|
14
|
+
export declare function removeServiceTags(servicePubkey: string): TagOperation;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { createProviderTag, parseProviderTag } from "../helpers/trusted-assertions.js";
|
|
2
|
+
/** Checks if a tag matches a provider selector */
|
|
3
|
+
function matchesProvider(tag, selector) {
|
|
4
|
+
const parsed = parseProviderTag(tag);
|
|
5
|
+
if (!parsed || parsed.kind !== selector.kind || parsed.tag !== selector.tag)
|
|
6
|
+
return false;
|
|
7
|
+
return selector.servicePubkey === undefined || parsed.servicePubkey === selector.servicePubkey;
|
|
8
|
+
}
|
|
9
|
+
/** Adds a provider to a kind 10040 tag list, or updates the relay hint of an existing entry */
|
|
10
|
+
export function addProviderTag(provider) {
|
|
11
|
+
return (tags) => {
|
|
12
|
+
const tag = createProviderTag(provider);
|
|
13
|
+
const index = tags.findIndex((t) => matchesProvider(t, provider));
|
|
14
|
+
if (index === -1)
|
|
15
|
+
return [...tags, tag];
|
|
16
|
+
return tags.map((t, i) => (i === index ? tag : t));
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/** Removes a provider from a kind 10040 tag list, or every provider in the slot if no pubkey is given */
|
|
20
|
+
export function removeProviderTag(selector) {
|
|
21
|
+
return (tags) => tags.filter((t) => !matchesProvider(t, selector));
|
|
22
|
+
}
|
|
23
|
+
/** Replaces every provider in the `kind:tag` slot with a single provider */
|
|
24
|
+
export function setProviderTag(provider) {
|
|
25
|
+
return (tags) => [
|
|
26
|
+
...tags.filter((t) => !matchesProvider(t, { kind: provider.kind, tag: provider.tag })),
|
|
27
|
+
createProviderTag(provider),
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
/** Removes a service pubkey from every slot in a kind 10040 tag list */
|
|
31
|
+
export function removeServiceTags(servicePubkey) {
|
|
32
|
+
return (tags) => tags.filter((t) => parseProviderTag(t)?.servicePubkey !== servicePubkey);
|
|
33
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { EventOperation } from "applesauce-core/factories";
|
|
2
|
+
import { UserStatusPointer, UserStatusType } from "../helpers/user-status.js";
|
|
3
|
+
/** Sets the status type ("d" tag) of a user status */
|
|
4
|
+
export declare function setStatusType(type: UserStatusType): EventOperation;
|
|
5
|
+
/**
|
|
6
|
+
* Sets the single URL, profile, event, or address the status links to
|
|
7
|
+
* @param link a URL string or a {@link UserStatusPointer}
|
|
8
|
+
*/
|
|
9
|
+
export declare function setStatusLink(link: string | UserStatusPointer): EventOperation;
|
|
10
|
+
/** Removes any "r", "p", "e", or "a" link tags from the status */
|
|
11
|
+
export declare function clearStatusLink(): EventOperation;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { addAddressPointerTag, addEventPointerTag, addProfilePointerTag, setSingletonTag, } from "applesauce-core/operations/tag/common";
|
|
2
|
+
import { modifyPublicTags } from "applesauce-core/operations/tags";
|
|
3
|
+
const LINK_TAGS = ["r", "p", "e", "a"];
|
|
4
|
+
const removeLinkTags = (tags) => tags.filter((t) => !LINK_TAGS.includes(t[0]));
|
|
5
|
+
/** Sets the status type ("d" tag) of a user status */
|
|
6
|
+
export function setStatusType(type) {
|
|
7
|
+
return modifyPublicTags(setSingletonTag(["d", type], true));
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Sets the single URL, profile, event, or address the status links to
|
|
11
|
+
* @param link a URL string or a {@link UserStatusPointer}
|
|
12
|
+
*/
|
|
13
|
+
export function setStatusLink(link) {
|
|
14
|
+
const pointer = typeof link === "string" ? { type: "url", data: link } : link;
|
|
15
|
+
switch (pointer.type) {
|
|
16
|
+
case "url":
|
|
17
|
+
return modifyPublicTags(removeLinkTags, (tags) => [...tags, ["r", pointer.data]]);
|
|
18
|
+
case "nprofile":
|
|
19
|
+
return modifyPublicTags(removeLinkTags, addProfilePointerTag(pointer.data));
|
|
20
|
+
case "nevent":
|
|
21
|
+
return modifyPublicTags(removeLinkTags, addEventPointerTag(pointer.data));
|
|
22
|
+
case "naddr":
|
|
23
|
+
return modifyPublicTags(removeLinkTags, addAddressPointerTag(pointer.data));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/** Removes any "r", "p", "e", or "a" link tags from the status */
|
|
27
|
+
export function clearStatusLink() {
|
|
28
|
+
return modifyPublicTags(removeLinkTags);
|
|
29
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "applesauce-common",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "Common NIP-specific helpers and models for applesauce",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -82,8 +82,9 @@
|
|
|
82
82
|
}
|
|
83
83
|
},
|
|
84
84
|
"dependencies": {
|
|
85
|
-
"@
|
|
86
|
-
"
|
|
85
|
+
"@noble/hashes": "^2.2.0",
|
|
86
|
+
"@scure/base": "^2.2.0",
|
|
87
|
+
"applesauce-core": "^7.0.0",
|
|
87
88
|
"hash-sum": "^2.0.0",
|
|
88
89
|
"light-bolt11-decoder": "^3.2.0",
|
|
89
90
|
"nanoid": "^5.0.9",
|
|
@@ -92,16 +93,15 @@
|
|
|
92
93
|
"devDependencies": {
|
|
93
94
|
"@hirez_io/observer-spy": "^2.2.0",
|
|
94
95
|
"@nostrability/schemata": "^0.3.2",
|
|
95
|
-
"@types/debug": "^4.1.12",
|
|
96
96
|
"@types/hash-sum": "^1.0.2",
|
|
97
|
-
"@types/node": "^22.
|
|
97
|
+
"@types/node": "^22.20.5",
|
|
98
98
|
"ajv": "^8.20.0",
|
|
99
99
|
"ajv-formats": "^3.0.1",
|
|
100
|
-
"nostr-tools": "^2.
|
|
101
|
-
"rimraf": "^6.
|
|
102
|
-
"typescript": "^
|
|
103
|
-
"vitest": "^4.
|
|
104
|
-
"yaml": "^2.9.
|
|
100
|
+
"nostr-tools": "^2.25.2",
|
|
101
|
+
"rimraf": "^6.1.3",
|
|
102
|
+
"typescript": "^7.0.2",
|
|
103
|
+
"vitest": "^4.1.11",
|
|
104
|
+
"yaml": "^2.9.1"
|
|
105
105
|
},
|
|
106
106
|
"funding": {
|
|
107
107
|
"type": "lightning",
|