applesauce-common 5.2.0 → 6.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/dist/casts/_circular-import.d.ts +7 -0
- package/dist/casts/_circular-import.js +9 -0
- package/dist/casts/article.d.ts +1 -1
- package/dist/casts/badge-award.d.ts +24 -0
- package/dist/casts/badge-award.js +39 -0
- package/dist/casts/badge.d.ts +19 -0
- package/dist/casts/badge.js +48 -0
- package/dist/casts/bookmarks.d.ts +5 -5
- package/dist/casts/cast.d.ts +1 -30
- package/dist/casts/cast.js +2 -67
- package/dist/casts/comment.d.ts +5 -5
- package/dist/casts/emoji-pack.d.ts +11 -0
- package/dist/casts/emoji-pack.js +25 -0
- package/dist/casts/favorite-emojis.d.ts +25 -0
- package/dist/casts/favorite-emojis.js +62 -0
- package/dist/casts/file-metadata.d.ts +22 -0
- package/dist/casts/file-metadata.js +55 -0
- package/dist/casts/groups.d.ts +1 -1
- package/dist/casts/index.d.ts +7 -0
- package/dist/casts/index.js +7 -0
- package/dist/casts/mutes.d.ts +1 -1
- package/dist/casts/note.d.ts +7 -7
- package/dist/casts/profile-badges.d.ts +28 -0
- package/dist/casts/profile-badges.js +59 -0
- package/dist/casts/reaction.d.ts +1 -1
- package/dist/casts/relay-lists.d.ts +1 -1
- package/dist/casts/relay-monitor.d.ts +1 -1
- package/dist/casts/report.d.ts +2 -2
- package/dist/casts/share.d.ts +2 -2
- package/dist/casts/stream.d.ts +9 -9
- package/dist/casts/torrent.d.ts +3 -3
- package/dist/casts/trusted-assertions.d.ts +144 -0
- package/dist/casts/trusted-assertions.js +281 -0
- package/dist/casts/user.d.ts +22 -40
- package/dist/casts/user.js +105 -161
- package/dist/casts/zap-goal.d.ts +2 -2
- package/dist/casts/zap.d.ts +4 -4
- package/dist/factories/app-data.d.ts +13 -0
- package/dist/factories/app-data.js +20 -0
- package/dist/factories/badge-award.d.ts +25 -0
- package/dist/factories/badge-award.js +41 -0
- package/dist/factories/badge.d.ts +32 -0
- package/dist/factories/badge.js +50 -0
- package/dist/factories/blocked-relays.d.ts +10 -0
- package/dist/factories/blocked-relays.js +16 -0
- package/dist/factories/blossom-server-list.d.ts +19 -0
- package/dist/factories/blossom-server-list.js +36 -0
- package/dist/factories/bookmark-list.d.ts +23 -0
- package/dist/factories/bookmark-list.js +45 -0
- package/dist/factories/bookmark-set.d.ts +25 -0
- package/dist/factories/bookmark-set.js +51 -0
- package/dist/factories/calendar-event.d.ts +88 -0
- package/dist/factories/calendar-event.js +175 -0
- package/dist/factories/calendar-rsvp.d.ts +22 -0
- package/dist/factories/calendar-rsvp.js +35 -0
- package/dist/factories/calendar.d.ts +20 -0
- package/dist/factories/calendar.js +36 -0
- package/dist/factories/code-snippet.d.ts +65 -0
- package/dist/factories/code-snippet.js +100 -0
- package/dist/factories/comment.d.ts +26 -0
- package/dist/factories/comment.js +49 -0
- package/dist/factories/contacts.d.ts +19 -0
- package/dist/factories/contacts.js +36 -0
- package/dist/factories/dm-relays.d.ts +10 -0
- package/dist/factories/dm-relays.js +16 -0
- package/dist/factories/favorite-relays.d.ts +16 -0
- package/dist/factories/favorite-relays.js +31 -0
- package/dist/factories/file-metadata.d.ts +54 -0
- package/dist/factories/file-metadata.js +92 -0
- package/dist/factories/follow-set.d.ts +12 -0
- package/dist/factories/follow-set.js +22 -0
- package/dist/factories/gift-wrap.d.ts +17 -0
- package/dist/factories/gift-wrap.js +21 -0
- package/dist/factories/group-management.d.ts +63 -0
- package/dist/factories/group-management.js +147 -0
- package/dist/factories/group.d.ts +35 -0
- package/dist/factories/group.js +69 -0
- package/dist/factories/highlight.d.ts +33 -0
- package/dist/factories/highlight.js +49 -0
- package/dist/factories/index.d.ts +41 -0
- package/dist/factories/index.js +41 -0
- package/dist/factories/legacy-message.d.ts +10 -0
- package/dist/factories/legacy-message.js +19 -0
- package/dist/factories/list.d.ts +56 -0
- package/dist/factories/list.js +120 -0
- package/dist/factories/live-stream.d.ts +48 -0
- package/dist/factories/live-stream.js +90 -0
- package/dist/factories/mute-list.d.ts +27 -0
- package/dist/factories/mute-list.js +57 -0
- package/dist/factories/note.d.ts +38 -0
- package/dist/factories/note.js +66 -0
- package/dist/factories/picture-post.d.ts +28 -0
- package/dist/factories/picture-post.js +46 -0
- package/dist/factories/pin-list.d.ts +14 -0
- package/dist/factories/pin-list.js +24 -0
- package/dist/factories/poll-response.d.ts +36 -0
- package/dist/factories/poll-response.js +46 -0
- package/dist/factories/poll.d.ts +35 -0
- package/dist/factories/poll.js +48 -0
- package/dist/factories/profile-badges.d.ts +31 -0
- package/dist/factories/profile-badges.js +52 -0
- package/dist/factories/reaction.d.ts +22 -0
- package/dist/factories/reaction.js +37 -0
- package/dist/factories/relay-set.d.ts +12 -0
- package/dist/factories/relay-set.js +22 -0
- package/dist/factories/search-relays.d.ts +10 -0
- package/dist/factories/search-relays.js +16 -0
- package/dist/factories/share.d.ts +26 -0
- package/dist/factories/share.js +44 -0
- package/dist/factories/stream-chat-message.d.ts +22 -0
- package/dist/factories/stream-chat-message.js +31 -0
- package/dist/factories/torrent.d.ts +57 -0
- package/dist/factories/torrent.js +93 -0
- package/dist/factories/wrapped-message.d.ts +22 -0
- package/dist/factories/wrapped-message.js +39 -0
- package/dist/factories/zap-goal.d.ts +35 -0
- package/dist/factories/zap-goal.js +49 -0
- package/dist/factories/zap-request.d.ts +28 -0
- package/dist/factories/zap-request.js +55 -0
- package/dist/factories/zap.d.ts +13 -0
- package/dist/factories/zap.js +21 -0
- package/dist/helpers/badge-award.d.ts +15 -0
- package/dist/helpers/badge-award.js +32 -0
- package/dist/helpers/badge.d.ts +27 -0
- package/dist/helpers/badge.js +59 -0
- package/dist/helpers/blossom.d.ts +29 -1
- package/dist/helpers/blossom.js +64 -7
- package/dist/helpers/emoji-pack.d.ts +43 -0
- package/dist/helpers/emoji-pack.js +108 -0
- package/dist/helpers/emoji.d.ts +0 -4
- package/dist/helpers/emoji.js +0 -16
- package/dist/helpers/file-metadata.d.ts +18 -13
- package/dist/helpers/file-metadata.js +10 -4
- package/dist/helpers/groups.d.ts +1 -0
- package/dist/helpers/groups.js +3 -2
- package/dist/helpers/hashtag.d.ts +1 -0
- package/dist/helpers/hashtag.js +3 -3
- package/dist/helpers/index.d.ts +7 -2
- package/dist/helpers/index.js +7 -2
- package/dist/helpers/lists.d.ts +8 -0
- package/dist/helpers/lists.js +27 -5
- package/dist/helpers/picture-post.d.ts +2 -2
- package/dist/helpers/profile-badges.d.ts +23 -0
- package/dist/helpers/profile-badges.js +51 -0
- package/dist/helpers/trusted-assertions.d.ts +81 -0
- package/dist/helpers/trusted-assertions.js +161 -0
- package/dist/helpers/zap.d.ts +8 -2
- package/dist/helpers/zap.js +31 -26
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/models/index.d.ts +1 -1
- package/dist/models/index.js +1 -1
- package/dist/observable/chainable.d.ts +1 -36
- package/dist/observable/chainable.js +2 -72
- package/dist/operations/app-data.d.ts +8 -3
- package/dist/operations/app-data.js +9 -4
- package/dist/operations/badge-award.d.ts +17 -0
- package/dist/operations/badge-award.js +30 -0
- package/dist/operations/badge.d.ts +22 -0
- package/dist/operations/badge.js +54 -0
- package/dist/operations/blossom.d.ts +1 -1
- package/dist/operations/calendar-event.d.ts +1 -1
- package/dist/operations/calendar-rsvp.d.ts +1 -1
- package/dist/operations/calendar.d.ts +1 -1
- package/dist/operations/channel.d.ts +1 -1
- package/dist/operations/client.d.ts +1 -1
- package/dist/operations/client.js +2 -2
- package/dist/operations/code-snippet.d.ts +27 -0
- package/dist/operations/code-snippet.js +63 -0
- package/dist/operations/comment.d.ts +7 -3
- package/dist/operations/comment.js +8 -4
- package/dist/operations/file-metadata.d.ts +38 -4
- package/dist/operations/file-metadata.js +105 -19
- package/dist/operations/geohash.d.ts +1 -1
- package/dist/operations/gift-wrap.d.ts +19 -7
- package/dist/operations/gift-wrap.js +36 -26
- package/dist/operations/group.d.ts +1 -1
- package/dist/operations/hashtags.d.ts +1 -1
- package/dist/operations/highlight.d.ts +1 -1
- package/dist/operations/highlight.js +5 -5
- package/dist/operations/index.d.ts +7 -1
- package/dist/operations/index.js +7 -1
- package/dist/operations/legacy-message.d.ts +1 -1
- package/dist/operations/list.d.ts +1 -1
- package/dist/operations/live-stream.d.ts +7 -3
- package/dist/operations/live-stream.js +9 -5
- package/dist/operations/media-attachment.d.ts +3 -3
- package/dist/operations/note.d.ts +10 -4
- package/dist/operations/note.js +14 -8
- package/dist/operations/picture-post.d.ts +1 -1
- package/dist/operations/poll-response.d.ts +1 -1
- package/dist/operations/poll-response.js +1 -1
- package/dist/operations/poll.d.ts +1 -1
- package/dist/operations/profile-badges.d.ts +26 -0
- package/dist/operations/profile-badges.js +150 -0
- package/dist/operations/reaction.d.ts +8 -3
- package/dist/operations/reaction.js +10 -5
- package/dist/operations/share.d.ts +8 -3
- package/dist/operations/share.js +10 -5
- package/dist/operations/stream.d.ts +1 -1
- package/dist/operations/tag/bookmarks.d.ts +1 -1
- package/dist/operations/torrent.d.ts +1 -1
- package/dist/operations/wrapped-message.d.ts +1 -1
- package/dist/operations/zap-goal.d.ts +1 -1
- package/dist/operations/zap-request.d.ts +22 -0
- package/dist/operations/zap-request.js +40 -0
- package/dist/operations/zap-split.d.ts +8 -4
- package/dist/operations/zap-split.js +10 -6
- package/dist/operations/zap.d.ts +12 -0
- package/dist/operations/zap.js +34 -0
- package/package.json +12 -11
- package/dist/blueprints/__register__.d.ts +0 -7
- package/dist/blueprints/__register__.js +0 -8
- package/dist/blueprints/app-data.d.ts +0 -5
- package/dist/blueprints/app-data.js +0 -10
- package/dist/blueprints/calendar.d.ts +0 -5
- package/dist/blueprints/calendar.js +0 -7
- package/dist/blueprints/channels.d.ts +0 -6
- package/dist/blueprints/channels.js +0 -13
- package/dist/blueprints/comment.d.ts +0 -13
- package/dist/blueprints/comment.js +0 -15
- package/dist/blueprints/delete.d.ts +0 -9
- package/dist/blueprints/delete.js +0 -14
- package/dist/blueprints/file-metadata.d.ts +0 -8
- package/dist/blueprints/file-metadata.js +0 -11
- package/dist/blueprints/follow-set.d.ts +0 -11
- package/dist/blueprints/follow-set.js +0 -21
- package/dist/blueprints/gift-wrap.d.ts +0 -5
- package/dist/blueprints/gift-wrap.js +0 -6
- package/dist/blueprints/group-mangement.d.ts +0 -25
- package/dist/blueprints/group-mangement.js +0 -40
- package/dist/blueprints/group.d.ts +0 -9
- package/dist/blueprints/group.js +0 -17
- package/dist/blueprints/highlight.d.ts +0 -20
- package/dist/blueprints/highlight.js +0 -12
- package/dist/blueprints/index.d.ts +0 -25
- package/dist/blueprints/index.js +0 -26
- package/dist/blueprints/legacy-message.d.ts +0 -7
- package/dist/blueprints/legacy-message.js +0 -29
- package/dist/blueprints/live-stream.d.ts +0 -6
- package/dist/blueprints/live-stream.js +0 -9
- package/dist/blueprints/note.d.ts +0 -16
- package/dist/blueprints/note.js +0 -30
- package/dist/blueprints/picture-post.d.ts +0 -12
- package/dist/blueprints/picture-post.js +0 -17
- package/dist/blueprints/poll.d.ts +0 -41
- package/dist/blueprints/poll.js +0 -33
- package/dist/blueprints/profile.d.ts +0 -3
- package/dist/blueprints/profile.js +0 -7
- package/dist/blueprints/reaction.d.ts +0 -10
- package/dist/blueprints/reaction.js +0 -14
- package/dist/blueprints/share.d.ts +0 -12
- package/dist/blueprints/share.js +0 -25
- package/dist/blueprints/stream.d.ts +0 -6
- package/dist/blueprints/stream.js +0 -7
- package/dist/blueprints/torrent.d.ts +0 -30
- package/dist/blueprints/torrent.js +0 -29
- package/dist/blueprints/wrapped-message.d.ts +0 -20
- package/dist/blueprints/wrapped-message.js +0 -64
- package/dist/blueprints/zap-goal.d.ts +0 -16
- package/dist/blueprints/zap-goal.js +0 -12
- package/dist/register.d.ts +0 -2
- package/dist/register.js +0 -4
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { isEvent } from "applesauce-core/helpers/event";
|
|
2
|
+
import { createATagFromAddressPointer, createETagFromEventPointer } from "applesauce-core/helpers/factory";
|
|
3
|
+
import { getAddressPointerForEvent, getAddressPointerFromATag, getEventPointerForEvent, getEventPointerFromETag, getReplaceableAddressFromPointer, normalizeToAddressPointer, normalizeToEventPointer, } from "applesauce-core/helpers/pointers";
|
|
4
|
+
import { modifyPublicTags } from "applesauce-core/operations/tags";
|
|
5
|
+
import { isValidBadgeAward } from "../helpers/badge-award.js";
|
|
6
|
+
import { isValidBadge } from "../helpers/badge.js";
|
|
7
|
+
/** Normalizes a profile badge slot input to a profile badge slot */
|
|
8
|
+
function normalizeSlot(input) {
|
|
9
|
+
const badgePointer = typeof input.badge === "string"
|
|
10
|
+
? normalizeToAddressPointer(input.badge)
|
|
11
|
+
: isEvent(input.badge)
|
|
12
|
+
? isValidBadge(input.badge)
|
|
13
|
+
? getAddressPointerForEvent(input.badge)
|
|
14
|
+
: undefined
|
|
15
|
+
: input.badge;
|
|
16
|
+
if (!badgePointer)
|
|
17
|
+
throw new Error("Invalid badge pointer provided");
|
|
18
|
+
const awardPointer = typeof input.award === "string"
|
|
19
|
+
? normalizeToEventPointer(input.award)
|
|
20
|
+
: isEvent(input.award)
|
|
21
|
+
? isValidBadgeAward(input.award)
|
|
22
|
+
? getEventPointerForEvent(input.award)
|
|
23
|
+
: undefined
|
|
24
|
+
: input.award;
|
|
25
|
+
if (!awardPointer)
|
|
26
|
+
throw new Error("Invalid award pointer provided");
|
|
27
|
+
return { badge: badgePointer, award: awardPointer };
|
|
28
|
+
}
|
|
29
|
+
/** Encodes a profile badge slot to a list of tags */
|
|
30
|
+
function encodeSlot(slot) {
|
|
31
|
+
return [createATagFromAddressPointer(slot.badge), createETagFromEventPointer(slot.award)];
|
|
32
|
+
}
|
|
33
|
+
/** Removes slot pairs from a list of tags */
|
|
34
|
+
function removeSlotPairs(tags, predicate) {
|
|
35
|
+
const result = [];
|
|
36
|
+
for (let i = 0; i < tags.length; i++) {
|
|
37
|
+
const tag = tags[i];
|
|
38
|
+
if (tag[0] === "a" && i + 1 < tags.length && tags[i + 1][0] === "e") {
|
|
39
|
+
const next = tags[i + 1];
|
|
40
|
+
const badge = getAddressPointerFromATag(tag);
|
|
41
|
+
const award = getEventPointerFromETag(next);
|
|
42
|
+
const slot = badge && award ? { badge, award } : undefined;
|
|
43
|
+
const shouldRemove = predicate ? (slot ? predicate(slot) : false) : true;
|
|
44
|
+
if (shouldRemove) {
|
|
45
|
+
i += 1;
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
result.push(tag, next);
|
|
49
|
+
i += 1;
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
result.push(tag);
|
|
53
|
+
}
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
function sameBadge(a, b) {
|
|
57
|
+
return getReplaceableAddressFromPointer(a) === getReplaceableAddressFromPointer(b);
|
|
58
|
+
}
|
|
59
|
+
function sameAward(a, b) {
|
|
60
|
+
return a.id === b.id;
|
|
61
|
+
}
|
|
62
|
+
/** Returns the tag-index ranges [start, start+2) for each slot pair */
|
|
63
|
+
function getSlotRanges(tags) {
|
|
64
|
+
const ranges = [];
|
|
65
|
+
for (let i = 0; i < tags.length; i++) {
|
|
66
|
+
if (tags[i][0] === "a" && i + 1 < tags.length && tags[i + 1][0] === "e") {
|
|
67
|
+
ranges.push([i, i + 2]);
|
|
68
|
+
i += 1;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return ranges;
|
|
72
|
+
}
|
|
73
|
+
/** Replaces every badge slot with the provided list */
|
|
74
|
+
export function setSlots(slots) {
|
|
75
|
+
const normalized = slots.map(normalizeSlot);
|
|
76
|
+
return modifyPublicTags((tags) => {
|
|
77
|
+
const remaining = removeSlotPairs(tags);
|
|
78
|
+
const newTags = normalized.flatMap((slot) => encodeSlot(slot));
|
|
79
|
+
return [...remaining, ...newTags];
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
/** Adds a slot, replacing any existing slot for the same badge */
|
|
83
|
+
export function addSlot(slot) {
|
|
84
|
+
const normalized = normalizeSlot(slot);
|
|
85
|
+
return modifyPublicTags((tags) => {
|
|
86
|
+
const filtered = removeSlotPairs(tags, (existing) => sameBadge(existing.badge, normalized.badge));
|
|
87
|
+
return [...filtered, ...encodeSlot(normalized)];
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
/** Removes every slot */
|
|
91
|
+
export function clearSlots() {
|
|
92
|
+
return modifyPublicTags((tags) => removeSlotPairs(tags));
|
|
93
|
+
}
|
|
94
|
+
/** Removes the slot associated with a specific badge definition */
|
|
95
|
+
export function removeSlotByBadge(badge) {
|
|
96
|
+
let pointer = null;
|
|
97
|
+
if (typeof badge === "string")
|
|
98
|
+
pointer = normalizeToAddressPointer(badge);
|
|
99
|
+
else if (isEvent(badge))
|
|
100
|
+
pointer = isValidBadge(badge) ? getAddressPointerForEvent(badge) : null;
|
|
101
|
+
else
|
|
102
|
+
pointer = badge;
|
|
103
|
+
if (!pointer)
|
|
104
|
+
throw new Error("Invalid badge pointer provided");
|
|
105
|
+
return modifyPublicTags((tags) => removeSlotPairs(tags, (slot) => sameBadge(slot.badge, pointer)));
|
|
106
|
+
}
|
|
107
|
+
/** Removes the slot referencing a specific award receipt */
|
|
108
|
+
export function removeSlotByAward(award) {
|
|
109
|
+
let pointer = null;
|
|
110
|
+
if (typeof award === "string")
|
|
111
|
+
pointer = normalizeToEventPointer(award);
|
|
112
|
+
else if (isEvent(award))
|
|
113
|
+
pointer = isValidBadgeAward(award) ? getEventPointerForEvent(award) : null;
|
|
114
|
+
else
|
|
115
|
+
pointer = award;
|
|
116
|
+
if (!pointer)
|
|
117
|
+
throw new Error("Invalid award pointer provided");
|
|
118
|
+
return modifyPublicTags((tags) => removeSlotPairs(tags, (slot) => sameAward(slot.award, pointer)));
|
|
119
|
+
}
|
|
120
|
+
/** Inserts a slot at a specific position among existing slots */
|
|
121
|
+
export function insertSlot(index, slot) {
|
|
122
|
+
const normalized = normalizeSlot(slot);
|
|
123
|
+
return modifyPublicTags((tags) => {
|
|
124
|
+
const ranges = getSlotRanges(tags);
|
|
125
|
+
const encoded = encodeSlot(normalized);
|
|
126
|
+
if (ranges.length === 0 || index >= ranges.length)
|
|
127
|
+
return [...tags, ...encoded];
|
|
128
|
+
const insertAt = ranges[Math.max(0, index)][0];
|
|
129
|
+
return [...tags.slice(0, insertAt), ...encoded, ...tags.slice(insertAt)];
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
/** Inserts a slot at the beginning */
|
|
133
|
+
export function prependSlot(slot) {
|
|
134
|
+
return insertSlot(0, slot);
|
|
135
|
+
}
|
|
136
|
+
/** Inserts a slot at the end */
|
|
137
|
+
export function appendSlot(slot) {
|
|
138
|
+
return insertSlot(Infinity, slot);
|
|
139
|
+
}
|
|
140
|
+
/** Replaces the slot at a specific position with a new one */
|
|
141
|
+
export function setSlot(index, slot) {
|
|
142
|
+
const normalized = normalizeSlot(slot);
|
|
143
|
+
return modifyPublicTags((tags) => {
|
|
144
|
+
const ranges = getSlotRanges(tags);
|
|
145
|
+
if (index < 0 || index >= ranges.length)
|
|
146
|
+
throw new Error(`Slot index ${index} out of range`);
|
|
147
|
+
const [start, end] = ranges[index];
|
|
148
|
+
return [...tags.slice(0, start), ...encodeSlot(normalized), ...tags.slice(end)];
|
|
149
|
+
});
|
|
150
|
+
}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import { EventOperation } from "applesauce-core/
|
|
1
|
+
import { EventOperation } from "applesauce-core/factories";
|
|
2
2
|
import { NostrEvent } from "applesauce-core/helpers/event";
|
|
3
3
|
import { Emoji } from "../helpers/emoji.js";
|
|
4
4
|
/** Sets the content for a reaction event */
|
|
5
5
|
export declare function setReaction(emoji?: string | Emoji): EventOperation;
|
|
6
|
-
/**
|
|
7
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Includes NIP-25 "e", "p", "k", and "a" tags for a reaction event to point to a parent event
|
|
8
|
+
* @param event - Event being reacted to
|
|
9
|
+
* @param getEventRelayHint - Optional function to get relay hint for event ID
|
|
10
|
+
* @param getPubkeyRelayHint - Optional function to get relay hint for pubkey
|
|
11
|
+
*/
|
|
12
|
+
export declare function setReactionParent(event: NostrEvent, getEventRelayHint?: (eventId: string) => Promise<string | undefined>, getPubkeyRelayHint?: (pubkey: string) => Promise<string | undefined>): EventOperation;
|
|
@@ -5,12 +5,17 @@ import { ensureAddressPointerTag, ensureEventPointerTag, ensureKTag, ensureProfi
|
|
|
5
5
|
export function setReaction(emoji = "+") {
|
|
6
6
|
return (draft) => ({ ...draft, content: typeof emoji === "string" ? emoji : `:${emoji.shortcode}:` });
|
|
7
7
|
}
|
|
8
|
-
/**
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Includes NIP-25 "e", "p", "k", and "a" tags for a reaction event to point to a parent event
|
|
10
|
+
* @param event - Event being reacted to
|
|
11
|
+
* @param getEventRelayHint - Optional function to get relay hint for event ID
|
|
12
|
+
* @param getPubkeyRelayHint - Optional function to get relay hint for pubkey
|
|
13
|
+
*/
|
|
14
|
+
export function setReactionParent(event, getEventRelayHint, getPubkeyRelayHint) {
|
|
15
|
+
return async (draft) => {
|
|
11
16
|
let tags = Array.from(draft.tags);
|
|
12
|
-
const eventHint = await
|
|
13
|
-
const pubkeyHint = await
|
|
17
|
+
const eventHint = getEventRelayHint ? await getEventRelayHint(event.id) : undefined;
|
|
18
|
+
const pubkeyHint = getPubkeyRelayHint ? await getPubkeyRelayHint(event.pubkey) : undefined;
|
|
14
19
|
// include "e" tag
|
|
15
20
|
tags = ensureEventPointerTag(tags, {
|
|
16
21
|
id: event.id,
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import { EventOperation } from "applesauce-core/
|
|
1
|
+
import { EventOperation } from "applesauce-core/factories";
|
|
2
2
|
import { NostrEvent } from "applesauce-core/helpers/event";
|
|
3
|
-
/**
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Includes NIP-18 repost tags
|
|
5
|
+
* @param event - Event being shared/reposted
|
|
6
|
+
* @param getEventRelayHint - Optional function to get relay hint for event ID
|
|
7
|
+
* @param getPubkeyRelayHint - Optional function to get relay hint for pubkey
|
|
8
|
+
*/
|
|
9
|
+
export declare function setShareTags(event: NostrEvent, getEventRelayHint?: (eventId: string) => Promise<string | undefined>, getPubkeyRelayHint?: (pubkey: string) => Promise<string | undefined>): EventOperation;
|
|
5
10
|
/** Sets the NIP-18 repost kind based on the kind of event being shared */
|
|
6
11
|
export declare function setShareKind(event: NostrEvent): EventOperation;
|
|
7
12
|
/** Sets the content of the event to a JSON string of the shared event */
|
package/dist/operations/share.js
CHANGED
|
@@ -3,11 +3,16 @@ import { ensureAddressPointerTag, ensureEventPointerTag, ensureKTag, ensureProfi
|
|
|
3
3
|
import { getAddressPointerForEvent, getEventPointerForEvent } from "applesauce-core/helpers/pointers";
|
|
4
4
|
import { setContent } from "applesauce-core/operations/content";
|
|
5
5
|
// TODO: some of these operations should be refactored to use "modifyPublicTags"
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Includes NIP-18 repost tags
|
|
8
|
+
* @param event - Event being shared/reposted
|
|
9
|
+
* @param getEventRelayHint - Optional function to get relay hint for event ID
|
|
10
|
+
* @param getPubkeyRelayHint - Optional function to get relay hint for pubkey
|
|
11
|
+
*/
|
|
12
|
+
export function setShareTags(event, getEventRelayHint, getPubkeyRelayHint) {
|
|
13
|
+
return async (draft) => {
|
|
9
14
|
let tags = Array.from(draft.tags);
|
|
10
|
-
const hint = await
|
|
15
|
+
const hint = getEventRelayHint ? await getEventRelayHint(event.id) : undefined;
|
|
11
16
|
// add "e" tag
|
|
12
17
|
tags = ensureEventPointerTag(tags, getEventPointerForEvent(event, hint ? [hint] : undefined));
|
|
13
18
|
// add "a" tag
|
|
@@ -17,7 +22,7 @@ export function setShareTags(event) {
|
|
|
17
22
|
tags = ensureAddressPointerTag(tags, pointer);
|
|
18
23
|
}
|
|
19
24
|
// add "p" tag for notify
|
|
20
|
-
const pubkeyHint = await
|
|
25
|
+
const pubkeyHint = getPubkeyRelayHint ? await getPubkeyRelayHint(event.pubkey) : undefined;
|
|
21
26
|
tags = ensureProfilePointerTag(tags, { pubkey: event.pubkey, relays: pubkeyHint ? [pubkeyHint] : undefined });
|
|
22
27
|
// add "k" tag
|
|
23
28
|
tags = ensureKTag(tags, event.kind);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EventOperation } from "applesauce-core/
|
|
1
|
+
import { EventOperation } from "applesauce-core/factories";
|
|
2
2
|
import { ProfilePointer } from "applesauce-core/helpers/pointers";
|
|
3
3
|
import { StreamRole } from "../helpers/stream.js";
|
|
4
4
|
/** Sets the title of a live event */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TagOperation } from "applesauce-core/
|
|
1
|
+
import { TagOperation } from "applesauce-core/factories";
|
|
2
2
|
import { NostrEvent } from "applesauce-core/helpers/event";
|
|
3
3
|
import { AddressPointer, EventPointer } from "applesauce-core/helpers/pointers";
|
|
4
4
|
/** Adds an "e" or "a" tag to a bookmark list or set */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EventOperation } from "applesauce-core/
|
|
1
|
+
import { EventOperation } from "applesauce-core/factories";
|
|
2
2
|
import { TorrentExternalIdentifier, TorrentExternalIdentifierPrefix, TorrentFile } from "../helpers/torrent.js";
|
|
3
3
|
/** Sets the BitTorrent info hash (required `x` tag) */
|
|
4
4
|
export declare function setTorrentInfoHash(infoHash: string): EventOperation;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EventOperation } from "applesauce-core/
|
|
1
|
+
import { EventOperation } from "applesauce-core/factories";
|
|
2
2
|
/** Sets the target amount in milisats for a zap goal */
|
|
3
3
|
export declare function setAmount(amount: number): EventOperation;
|
|
4
4
|
/** Sets the relay URLs for a zap goal */
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { EventOperation } from "applesauce-core/factories";
|
|
2
|
+
import { NostrEvent, ProfilePointer } from "applesauce-core/helpers";
|
|
3
|
+
/** Sets the relays tag on a zap request */
|
|
4
|
+
export declare function setRelays(relays: string[]): EventOperation;
|
|
5
|
+
/** Sets the amount in millisatoshis on a zap request */
|
|
6
|
+
export declare function setAmount(amount: number): EventOperation;
|
|
7
|
+
/** Sets the lnurl tag (bech32-encoded) on a zap request */
|
|
8
|
+
export declare function setLnurl(lnurl: string): EventOperation;
|
|
9
|
+
/**
|
|
10
|
+
* Sets the event target on an event zap request.
|
|
11
|
+
* Sets the k tag (kind), a tag (coordinate for replaceable/addressable events),
|
|
12
|
+
* e tag (event id), and p tag (recipient pubkey).
|
|
13
|
+
* @param event - The NostrEvent being zapped
|
|
14
|
+
* @param hint - Optional relay hint for the event
|
|
15
|
+
*/
|
|
16
|
+
export declare function setEventTarget(event: NostrEvent, hint?: string): EventOperation;
|
|
17
|
+
/**
|
|
18
|
+
* Sets the profile target on a profile zap request. Sets the p tag (recipient)
|
|
19
|
+
* @param pubkey - Pubkey string or ProfilePointer
|
|
20
|
+
* @param hint - Optional relay hint
|
|
21
|
+
*/
|
|
22
|
+
export declare function setProfileTarget(pubkey: string | ProfilePointer, hint?: string): EventOperation;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { isReplaceable, skip, tagPipe } from "applesauce-core/helpers";
|
|
2
|
+
import { modifyPublicTags } from "applesauce-core/operations";
|
|
3
|
+
import { addAddressPointerTag, addEventPointerTag, addProfilePointerTag, setSingletonTag, } from "applesauce-core/operations/tag/common";
|
|
4
|
+
import { includeSingletonTag } from "applesauce-core/operations/tags";
|
|
5
|
+
/** Sets the relays tag on a zap request */
|
|
6
|
+
export function setRelays(relays) {
|
|
7
|
+
return includeSingletonTag(["relays", ...relays], true);
|
|
8
|
+
}
|
|
9
|
+
/** Sets the amount in millisatoshis on a zap request */
|
|
10
|
+
export function setAmount(amount) {
|
|
11
|
+
return includeSingletonTag(["amount", amount.toString()], true);
|
|
12
|
+
}
|
|
13
|
+
/** Sets the lnurl tag (bech32-encoded) on a zap request */
|
|
14
|
+
export function setLnurl(lnurl) {
|
|
15
|
+
return includeSingletonTag(["lnurl", lnurl], true);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Sets the event target on an event zap request.
|
|
19
|
+
* Sets the k tag (kind), a tag (coordinate for replaceable/addressable events),
|
|
20
|
+
* e tag (event id), and p tag (recipient pubkey).
|
|
21
|
+
* @param event - The NostrEvent being zapped
|
|
22
|
+
* @param hint - Optional relay hint for the event
|
|
23
|
+
*/
|
|
24
|
+
export function setEventTarget(event, hint) {
|
|
25
|
+
return modifyPublicTags(tagPipe(setSingletonTag(["k", String(event.kind)], true),
|
|
26
|
+
// Include the "e" tag for the event id
|
|
27
|
+
addEventPointerTag(event, hint, true),
|
|
28
|
+
// Include the "a" tag only for replaceable/addressable events
|
|
29
|
+
isReplaceable(event.kind) ? addAddressPointerTag(event, hint, true) : skip(),
|
|
30
|
+
// Include the "p" tag for the event author (recipient)
|
|
31
|
+
addProfilePointerTag({ pubkey: event.pubkey }, hint, true)));
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Sets the profile target on a profile zap request. Sets the p tag (recipient)
|
|
35
|
+
* @param pubkey - Pubkey string or ProfilePointer
|
|
36
|
+
* @param hint - Optional relay hint
|
|
37
|
+
*/
|
|
38
|
+
export function setProfileTarget(pubkey, hint) {
|
|
39
|
+
return modifyPublicTags(addProfilePointerTag(pubkey, hint, true));
|
|
40
|
+
}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import { EventOperation } from "applesauce-core/
|
|
1
|
+
import { EventOperation } from "applesauce-core/factories";
|
|
2
2
|
import { ZapSplit } from "../helpers/zap.js";
|
|
3
|
-
/**
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Override the zap splits on an event
|
|
5
|
+
* @param splits - Array of zap splits
|
|
6
|
+
* @param getRelayHint - Optional function to get relay hint for pubkey
|
|
7
|
+
*/
|
|
8
|
+
export declare function setZapSplitTags(splits: Omit<ZapSplit, "percent" | "relay">[], getRelayHint?: (pubkey: string) => Promise<string | undefined>): EventOperation;
|
|
5
9
|
/** Options for {@link setZapSplit} */
|
|
6
10
|
export type ZapOptions = {
|
|
7
11
|
splits?: Omit<ZapSplit, "percent" | "relay">[];
|
|
8
12
|
};
|
|
9
13
|
/** Creates the necessary operations for zap options */
|
|
10
|
-
export declare function setZapSplit(options?: ZapOptions): EventOperation;
|
|
14
|
+
export declare function setZapSplit(options?: ZapOptions, getRelayHint?: (pubkey: string) => Promise<string | undefined>): EventOperation;
|
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
import { skip } from "applesauce-core/helpers/pipeline";
|
|
2
2
|
import { fillAndTrimTag } from "applesauce-core/helpers/tags";
|
|
3
|
-
/**
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Override the zap splits on an event
|
|
5
|
+
* @param splits - Array of zap splits
|
|
6
|
+
* @param getRelayHint - Optional function to get relay hint for pubkey
|
|
7
|
+
*/
|
|
8
|
+
export function setZapSplitTags(splits, getRelayHint) {
|
|
9
|
+
return async (draft) => {
|
|
6
10
|
let tags = Array.from(draft.tags);
|
|
7
11
|
// remove any existing zap split tags
|
|
8
12
|
tags = tags.filter((t) => t[0] !== "zap");
|
|
9
13
|
// add split tags
|
|
10
14
|
for (const split of splits) {
|
|
11
|
-
const hint = await
|
|
15
|
+
const hint = getRelayHint ? await getRelayHint(split.pubkey) : undefined;
|
|
12
16
|
tags.push(fillAndTrimTag(["zap", split.pubkey, hint, String(split.weight)]));
|
|
13
17
|
}
|
|
14
18
|
return { ...draft, tags };
|
|
15
19
|
};
|
|
16
20
|
}
|
|
17
21
|
/** Creates the necessary operations for zap options */
|
|
18
|
-
export function setZapSplit(options) {
|
|
19
|
-
return options?.splits ? setZapSplitTags(options.splits) : skip();
|
|
22
|
+
export function setZapSplit(options, getRelayHint) {
|
|
23
|
+
return options?.splits ? setZapSplitTags(options.splits, getRelayHint) : skip();
|
|
20
24
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { EventOperation } from "applesauce-core/factories";
|
|
2
|
+
import { NostrEvent } from "applesauce-core/helpers";
|
|
3
|
+
/** Sets the bolt11 invoice tag on a zap event */
|
|
4
|
+
export declare function setBolt11(invoice: string): EventOperation;
|
|
5
|
+
/**
|
|
6
|
+
* Sets the zap request on a zap event. Validates the request, then sets the
|
|
7
|
+
* description tag (JSON-encoded), P tag (sender), and copies the p, e, a, k,
|
|
8
|
+
* and amount tags from the zap request
|
|
9
|
+
*/
|
|
10
|
+
export declare function setRequest(zapRequest: NostrEvent): EventOperation;
|
|
11
|
+
/** Sets the preimage tag on a zap event */
|
|
12
|
+
export declare function setPreimage(preimage: string): EventOperation;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { tagPipe } from "applesauce-core/helpers";
|
|
2
|
+
import { modifyPublicTags } from "applesauce-core/operations";
|
|
3
|
+
import { setSingletonTag } from "applesauce-core/operations/tag/common";
|
|
4
|
+
import { includeSingletonTag } from "applesauce-core/operations/tags";
|
|
5
|
+
import { isValidZapRequest } from "../helpers/zap.js";
|
|
6
|
+
/** Tags that are copied from the zap request to the zap receipt */
|
|
7
|
+
const COPIED_TAGS = ["p", "e", "a", "k", "amount"];
|
|
8
|
+
/** Sets the bolt11 invoice tag on a zap event */
|
|
9
|
+
export function setBolt11(invoice) {
|
|
10
|
+
return includeSingletonTag(["bolt11", invoice], true);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Sets the zap request on a zap event. Validates the request, then sets the
|
|
14
|
+
* description tag (JSON-encoded), P tag (sender), and copies the p, e, a, k,
|
|
15
|
+
* and amount tags from the zap request
|
|
16
|
+
*/
|
|
17
|
+
export function setRequest(zapRequest) {
|
|
18
|
+
if (!isValidZapRequest(zapRequest))
|
|
19
|
+
throw new Error("Invalid zap request event");
|
|
20
|
+
return modifyPublicTags(tagPipe(
|
|
21
|
+
// Set the description tag and sender P tags
|
|
22
|
+
setSingletonTag(["description", JSON.stringify(zapRequest)], true), setSingletonTag(["P", zapRequest.pubkey], true),
|
|
23
|
+
// Copy each singleton tag from the zap request
|
|
24
|
+
(tags) => [
|
|
25
|
+
// Keep tags that won't be replaced
|
|
26
|
+
...tags.filter((tag) => !COPIED_TAGS.includes(tag[0])),
|
|
27
|
+
// Append copied tags from the zap request
|
|
28
|
+
...zapRequest.tags.filter((tag) => COPIED_TAGS.includes(tag[0])),
|
|
29
|
+
]));
|
|
30
|
+
}
|
|
31
|
+
/** Sets the preimage tag on a zap event */
|
|
32
|
+
export function setPreimage(preimage) {
|
|
33
|
+
return includeSingletonTag(["preimage", preimage], true);
|
|
34
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "applesauce-common",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "Common NIP-specific helpers and models for applesauce",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -50,15 +50,15 @@
|
|
|
50
50
|
"require": "./dist/operations/*.js",
|
|
51
51
|
"types": "./dist/operations/*.d.ts"
|
|
52
52
|
},
|
|
53
|
-
"./
|
|
54
|
-
"import": "./dist/
|
|
55
|
-
"require": "./dist/
|
|
56
|
-
"types": "./dist/
|
|
53
|
+
"./factories": {
|
|
54
|
+
"import": "./dist/factories/index.js",
|
|
55
|
+
"require": "./dist/factories/index.js",
|
|
56
|
+
"types": "./dist/factories/index.d.ts"
|
|
57
57
|
},
|
|
58
|
-
"./
|
|
59
|
-
"import": "./dist/
|
|
60
|
-
"require": "./dist/
|
|
61
|
-
"types": "./dist/
|
|
58
|
+
"./factories/*": {
|
|
59
|
+
"import": "./dist/factories/*.js",
|
|
60
|
+
"require": "./dist/factories/*.js",
|
|
61
|
+
"types": "./dist/factories/*.d.ts"
|
|
62
62
|
},
|
|
63
63
|
"./observable": {
|
|
64
64
|
"import": "./dist/observable/index.js",
|
|
@@ -83,14 +83,15 @@
|
|
|
83
83
|
},
|
|
84
84
|
"dependencies": {
|
|
85
85
|
"@scure/base": "^1.2.4",
|
|
86
|
-
"applesauce-core": "^
|
|
86
|
+
"applesauce-core": "^6.0.0",
|
|
87
87
|
"hash-sum": "^2.0.0",
|
|
88
88
|
"light-bolt11-decoder": "^3.2.0",
|
|
89
|
+
"nanoid": "^5.0.9",
|
|
89
90
|
"rxjs": "^7.8.1"
|
|
90
91
|
},
|
|
91
92
|
"devDependencies": {
|
|
92
93
|
"@hirez_io/observer-spy": "^2.2.0",
|
|
93
|
-
"@nostrability/schemata": "
|
|
94
|
+
"@nostrability/schemata": "^0.3.2",
|
|
94
95
|
"@types/debug": "^4.1.12",
|
|
95
96
|
"@types/hash-sum": "^1.0.2",
|
|
96
97
|
"@types/node": "^22.19.1",
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { EventBlueprint } from "applesauce-core/event-factory";
|
|
2
|
-
import { EncryptionMethod } from "applesauce-core/helpers/encrypted-content";
|
|
3
|
-
import { MetaTagOptions } from "applesauce-core/operations/event";
|
|
4
|
-
/** A blueprint for creating kind 30078 application data events */
|
|
5
|
-
export declare function AppDataBlueprint<T>(identifier: string, data: T, encryption?: boolean | EncryptionMethod, options?: MetaTagOptions): EventBlueprint;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { blueprint } from "applesauce-core/event-factory";
|
|
2
|
-
import { setMetaTags } from "applesauce-core/operations/event";
|
|
3
|
-
import { APP_DATA_KIND } from "../helpers/app-data.js";
|
|
4
|
-
import * as AppData from "../operations/app-data.js";
|
|
5
|
-
/** A blueprint for creating kind 30078 application data events */
|
|
6
|
-
export function AppDataBlueprint(identifier, data, encryption, options) {
|
|
7
|
-
return blueprint(APP_DATA_KIND, AppData.setIdentifier(identifier),
|
|
8
|
-
// Set the content as either encrypted or plaintext
|
|
9
|
-
AppData.setContent(data, encryption), setMetaTags(options));
|
|
10
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { EventBlueprint } from "applesauce-core/event-factory";
|
|
2
|
-
import { NostrEvent } from "applesauce-core/helpers/event";
|
|
3
|
-
import { AddressPointer } from "applesauce-core/helpers/pointers";
|
|
4
|
-
/** Creates a calendar event with a title and optional events */
|
|
5
|
-
export declare function CalendarBlueprint(title: string, events?: (NostrEvent | AddressPointer)[]): EventBlueprint;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { blueprint } from "applesauce-core/event-factory";
|
|
2
|
-
import { kinds } from "applesauce-core/helpers/event";
|
|
3
|
-
import { addEvent, setTitle } from "../operations/calendar.js";
|
|
4
|
-
/** Creates a calendar event with a title and optional events */
|
|
5
|
-
export function CalendarBlueprint(title, events) {
|
|
6
|
-
return blueprint(kinds.Calendar, setTitle(title), ...(events?.map((event) => addEvent(event)) ?? []));
|
|
7
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { NostrEvent } from "applesauce-core/helpers/event";
|
|
2
|
-
import { TextContentOptions } from "applesauce-core/operations";
|
|
3
|
-
/** Creates a NIP-28 channel message */
|
|
4
|
-
export declare function ChannelMessageBlueprint(channel: NostrEvent, message: string, options?: TextContentOptions): import("applesauce-core/event-factory").EventBlueprint;
|
|
5
|
-
/** Creates a NIP-28 channel message reply */
|
|
6
|
-
export declare function ChannelMessageReplyBlueprint(parent: NostrEvent, message: string, options?: TextContentOptions): import("applesauce-core/event-factory").EventBlueprint;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { blueprint } from "applesauce-core/event-factory";
|
|
2
|
-
import { kinds } from "applesauce-core/helpers/event";
|
|
3
|
-
import { setShortTextContent } from "applesauce-core/operations";
|
|
4
|
-
import { includeChannelPointerTag } from "../operations/channel.js";
|
|
5
|
-
import { includePubkeyNotificationTags, setThreadParent } from "../operations/note.js";
|
|
6
|
-
/** Creates a NIP-28 channel message */
|
|
7
|
-
export function ChannelMessageBlueprint(channel, message, options) {
|
|
8
|
-
return blueprint(kinds.ChannelMessage, includeChannelPointerTag(channel), setShortTextContent(message, options));
|
|
9
|
-
}
|
|
10
|
-
/** Creates a NIP-28 channel message reply */
|
|
11
|
-
export function ChannelMessageReplyBlueprint(parent, message, options) {
|
|
12
|
-
return blueprint(kinds.ChannelMessage, setThreadParent(parent), includePubkeyNotificationTags(parent), setShortTextContent(message, options));
|
|
13
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { NostrEvent, EventTemplate } from "applesauce-core/helpers/event";
|
|
2
|
-
import { TextContentOptions } from "applesauce-core/operations/content";
|
|
3
|
-
import { MetaTagOptions } from "applesauce-core/operations/event";
|
|
4
|
-
import { CommentPointer } from "../helpers/comment.js";
|
|
5
|
-
export type CommentBlueprintOptions = TextContentOptions & MetaTagOptions;
|
|
6
|
-
/** A blueprint to create a NIP-22 comment event */
|
|
7
|
-
export declare function CommentBlueprint(parent: NostrEvent | CommentPointer, content: string, options?: CommentBlueprintOptions): import("applesauce-core/event-factory").EventBlueprint;
|
|
8
|
-
declare module "applesauce-core/event-factory" {
|
|
9
|
-
interface EventFactory {
|
|
10
|
-
/** Create a NIP-22 comment event */
|
|
11
|
-
comment(parent: NostrEvent | CommentPointer, content: string, options?: CommentBlueprintOptions): Promise<EventTemplate>;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { blueprint } from "applesauce-core/event-factory";
|
|
2
|
-
import { setShortTextContent } from "applesauce-core/operations/content";
|
|
3
|
-
import { setMetaTags } from "applesauce-core/operations/event";
|
|
4
|
-
import { COMMENT_KIND } from "../helpers/comment.js";
|
|
5
|
-
import { setParent } from "../operations/comment.js";
|
|
6
|
-
// Import EventFactory as a value (class) to modify its prototype
|
|
7
|
-
import { EventFactory } from "applesauce-core/event-factory";
|
|
8
|
-
/** A blueprint to create a NIP-22 comment event */
|
|
9
|
-
export function CommentBlueprint(parent, content, options) {
|
|
10
|
-
return blueprint(COMMENT_KIND, setParent(parent), setShortTextContent(content, options), setMetaTags(options));
|
|
11
|
-
}
|
|
12
|
-
// Register this blueprint with EventFactory
|
|
13
|
-
EventFactory.prototype.comment = function (parent, content, options) {
|
|
14
|
-
return this.create(CommentBlueprint, parent, content, options);
|
|
15
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { EventTemplate, NostrEvent } from "applesauce-core/helpers/event";
|
|
2
|
-
/** A blueprint for a NIP-09 delete event */
|
|
3
|
-
export declare function DeleteBlueprint(events: (string | NostrEvent)[], reason?: string): import("applesauce-core/event-factory").EventBlueprint;
|
|
4
|
-
declare module "applesauce-core/event-factory" {
|
|
5
|
-
interface EventFactory {
|
|
6
|
-
/** Create a NIP-09 delete event */
|
|
7
|
-
delete(events: (string | NostrEvent)[], reason?: string): Promise<EventTemplate>;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { blueprint } from "applesauce-core/event-factory";
|
|
2
|
-
import { kinds } from "applesauce-core/helpers/event";
|
|
3
|
-
import { setContent } from "applesauce-core/operations";
|
|
4
|
-
import { setDeleteEvents } from "applesauce-core/operations/delete";
|
|
5
|
-
// Import EventFactory as a value (class) to modify its prototype
|
|
6
|
-
import { EventFactory } from "applesauce-core/event-factory";
|
|
7
|
-
/** A blueprint for a NIP-09 delete event */
|
|
8
|
-
export function DeleteBlueprint(events, reason) {
|
|
9
|
-
return blueprint(kinds.EventDeletion, reason ? setContent(reason) : undefined, setDeleteEvents(events));
|
|
10
|
-
}
|
|
11
|
-
// Register this blueprint with EventFactory
|
|
12
|
-
EventFactory.prototype.delete = function (events, reason) {
|
|
13
|
-
return this.create(DeleteBlueprint, events, reason);
|
|
14
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { TextContentOptions } from "applesauce-core/operations/content";
|
|
2
|
-
import { MetaTagOptions } from "applesauce-core/operations/event";
|
|
3
|
-
import { FileMetadata } from "../helpers/file-metadata.js";
|
|
4
|
-
export type FileMetadataBlueprintOptions = TextContentOptions & MetaTagOptions & {
|
|
5
|
-
hashtags?: string[];
|
|
6
|
-
};
|
|
7
|
-
/** Blueprint to create a NIP-94 file metadata event */
|
|
8
|
-
export declare function FileMetadataBlueprint(metadata: FileMetadata, description?: string, options?: FileMetadataBlueprintOptions): import("applesauce-core/event-factory").EventBlueprint;
|