applesauce-common 5.2.0 → 6.0.1
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 +40 -0
- package/dist/factories/note.js +74 -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,52 @@
|
|
|
1
|
+
import { blankEventTemplate, EventFactory, toEventTemplate } from "applesauce-core/factories";
|
|
2
|
+
import { LEGACY_PROFILE_BADGES_KIND, PROFILE_BADGES_KIND } from "../helpers/profile-badges.js";
|
|
3
|
+
import { addSlot, appendSlot, clearSlots, insertSlot, prependSlot, removeSlotByAward, removeSlotByBadge, setSlot, setSlots, } from "../operations/profile-badges.js";
|
|
4
|
+
/** Factory for profile badges events (kind 10008) */
|
|
5
|
+
export class ProfileBadgesFactory extends EventFactory {
|
|
6
|
+
/** Creates a profile badges factory */
|
|
7
|
+
static create() {
|
|
8
|
+
return new ProfileBadgesFactory((res) => res(blankEventTemplate(PROFILE_BADGES_KIND)));
|
|
9
|
+
}
|
|
10
|
+
/** Creates a factory configured to modify an existing profile badge event */
|
|
11
|
+
static modify(event) {
|
|
12
|
+
if (event.kind !== PROFILE_BADGES_KIND && event.kind !== LEGACY_PROFILE_BADGES_KIND)
|
|
13
|
+
throw new Error("Expected a profile badges event");
|
|
14
|
+
return new ProfileBadgesFactory((res) => res(toEventTemplate(event)));
|
|
15
|
+
}
|
|
16
|
+
/** Replaces all slots */
|
|
17
|
+
slots(slots) {
|
|
18
|
+
return this.chain(setSlots(slots));
|
|
19
|
+
}
|
|
20
|
+
/** Adds a single slot to the end */
|
|
21
|
+
addSlot(slot) {
|
|
22
|
+
return this.chain(addSlot(slot));
|
|
23
|
+
}
|
|
24
|
+
/** Inserts a slot at a specific position */
|
|
25
|
+
insertSlot(index, slot) {
|
|
26
|
+
return this.chain(insertSlot(index, slot));
|
|
27
|
+
}
|
|
28
|
+
/** Inserts a slot at the beginning */
|
|
29
|
+
prependSlot(slot) {
|
|
30
|
+
return this.chain(prependSlot(slot));
|
|
31
|
+
}
|
|
32
|
+
/** Inserts a slot at the end */
|
|
33
|
+
appendSlot(slot) {
|
|
34
|
+
return this.chain(appendSlot(slot));
|
|
35
|
+
}
|
|
36
|
+
/** Replaces the slot at a specific position */
|
|
37
|
+
setSlot(index, slot) {
|
|
38
|
+
return this.chain(setSlot(index, slot));
|
|
39
|
+
}
|
|
40
|
+
/** Removes every slot */
|
|
41
|
+
clearSlots() {
|
|
42
|
+
return this.chain(clearSlots());
|
|
43
|
+
}
|
|
44
|
+
/** Removes the slot tied to a badge definition */
|
|
45
|
+
removeByBadge(badge) {
|
|
46
|
+
return this.chain(removeSlotByBadge(badge));
|
|
47
|
+
}
|
|
48
|
+
/** Removes the slot tied to an award event */
|
|
49
|
+
removeByAward(award) {
|
|
50
|
+
return this.chain(removeSlotByAward(award));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { EventFactory } from "applesauce-core/factories";
|
|
2
|
+
import { kinds, KnownEventTemplate, NostrEvent } from "applesauce-core/helpers";
|
|
3
|
+
import { Emoji } from "../helpers/emoji.js";
|
|
4
|
+
export type ReactionTemplate = KnownEventTemplate<kinds.Reaction>;
|
|
5
|
+
/** A factory class for building kind 7 reaction events */
|
|
6
|
+
export declare class ReactionFactory extends EventFactory<kinds.Reaction, ReactionTemplate> {
|
|
7
|
+
/**
|
|
8
|
+
* Creates a new reaction factory for an event
|
|
9
|
+
* @param event - The event being reacted to
|
|
10
|
+
* @param emoji - The emoji to react with (default: "+")
|
|
11
|
+
* @returns A new reaction factory
|
|
12
|
+
*/
|
|
13
|
+
static create(event: NostrEvent, emoji?: string | Emoji): ReactionFactory;
|
|
14
|
+
/** Creates a "+" like reaction for an event */
|
|
15
|
+
static like(event: NostrEvent): ReactionFactory;
|
|
16
|
+
/** Creates a "-" dislike reaction for an event */
|
|
17
|
+
static dislike(event: NostrEvent): ReactionFactory;
|
|
18
|
+
/** Sets the parent event being reacted to */
|
|
19
|
+
reactTo(event: NostrEvent): this;
|
|
20
|
+
/** Sets the reaction emoji */
|
|
21
|
+
reaction(emoji: "+" | "-" | string | Emoji): this;
|
|
22
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { EventFactory, blankEventTemplate } from "applesauce-core/factories";
|
|
2
|
+
import { kinds, pipeFromAsyncArray, skip } from "applesauce-core/helpers";
|
|
3
|
+
import { includeEmojis } from "applesauce-core/operations/content";
|
|
4
|
+
import { setReaction, setReactionParent } from "../operations/reaction.js";
|
|
5
|
+
/** A factory class for building kind 7 reaction events */
|
|
6
|
+
export class ReactionFactory extends EventFactory {
|
|
7
|
+
/**
|
|
8
|
+
* Creates a new reaction factory for an event
|
|
9
|
+
* @param event - The event being reacted to
|
|
10
|
+
* @param emoji - The emoji to react with (default: "+")
|
|
11
|
+
* @returns A new reaction factory
|
|
12
|
+
*/
|
|
13
|
+
static create(event, emoji = "+") {
|
|
14
|
+
return new ReactionFactory((res) => res(blankEventTemplate(kinds.Reaction))).reactTo(event).reaction(emoji);
|
|
15
|
+
}
|
|
16
|
+
/** Creates a "+" like reaction for an event */
|
|
17
|
+
static like(event) {
|
|
18
|
+
return ReactionFactory.create(event, "+");
|
|
19
|
+
}
|
|
20
|
+
/** Creates a "-" dislike reaction for an event */
|
|
21
|
+
static dislike(event) {
|
|
22
|
+
return ReactionFactory.create(event, "-");
|
|
23
|
+
}
|
|
24
|
+
/** Sets the parent event being reacted to */
|
|
25
|
+
reactTo(event) {
|
|
26
|
+
return this.chain(setReactionParent(event, undefined, undefined));
|
|
27
|
+
}
|
|
28
|
+
/** Sets the reaction emoji */
|
|
29
|
+
reaction(emoji) {
|
|
30
|
+
return this.chain(pipeFromAsyncArray([
|
|
31
|
+
// Set the event content
|
|
32
|
+
setReaction(emoji),
|
|
33
|
+
// If custom emoji, include emoji tag
|
|
34
|
+
typeof emoji !== "string" ? includeEmojis([emoji]) : skip(),
|
|
35
|
+
]));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { kinds, KnownEvent, KnownEventTemplate, NostrEvent } from "applesauce-core/helpers";
|
|
2
|
+
import { NIP51RelayListFactory } from "./list.js";
|
|
3
|
+
export type RelaySetTemplate = KnownEventTemplate<kinds.Relaysets>;
|
|
4
|
+
/** A factory class for building kind 30002 relay set events */
|
|
5
|
+
export declare class RelaySetFactory extends NIP51RelayListFactory<kinds.Relaysets, RelaySetTemplate> {
|
|
6
|
+
/** Creates a new relay set factory with an auto-generated identifier */
|
|
7
|
+
static create(): RelaySetFactory;
|
|
8
|
+
/** Sets the "d" identifier tag */
|
|
9
|
+
identifier(id: string): this;
|
|
10
|
+
/** Creates a new relay set factory from an existing relay set event */
|
|
11
|
+
static modify(event: NostrEvent | KnownEvent<kinds.Relaysets>): RelaySetFactory;
|
|
12
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { blankEventTemplate, toEventTemplate } from "applesauce-core/factories";
|
|
2
|
+
import { isKind, kinds } from "applesauce-core/helpers";
|
|
3
|
+
import { includeReplaceableIdentifier } from "applesauce-core/operations/index";
|
|
4
|
+
import { nanoid } from "nanoid";
|
|
5
|
+
import { NIP51RelayListFactory } from "./list.js";
|
|
6
|
+
/** A factory class for building kind 30002 relay set events */
|
|
7
|
+
export class RelaySetFactory extends NIP51RelayListFactory {
|
|
8
|
+
/** Creates a new relay set factory with an auto-generated identifier */
|
|
9
|
+
static create() {
|
|
10
|
+
return new RelaySetFactory((res) => res(blankEventTemplate(kinds.Relaysets))).identifier(nanoid());
|
|
11
|
+
}
|
|
12
|
+
/** Sets the "d" identifier tag */
|
|
13
|
+
identifier(id) {
|
|
14
|
+
return this.chain(includeReplaceableIdentifier(id));
|
|
15
|
+
}
|
|
16
|
+
/** Creates a new relay set factory from an existing relay set event */
|
|
17
|
+
static modify(event) {
|
|
18
|
+
if (!isKind(event, kinds.Relaysets))
|
|
19
|
+
throw new Error("Event is not a relay set event");
|
|
20
|
+
return new RelaySetFactory((res) => res(toEventTemplate(event)));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { kinds, KnownEvent, KnownEventTemplate, NostrEvent } from "applesauce-core/helpers";
|
|
2
|
+
import { NIP51RelayListFactory } from "./list.js";
|
|
3
|
+
export type SearchRelaysTemplate = KnownEventTemplate<kinds.SearchRelaysList>;
|
|
4
|
+
/** A factory class for building kind 10007 search relays list events */
|
|
5
|
+
export declare class SearchRelaysFactory extends NIP51RelayListFactory<kinds.SearchRelaysList, SearchRelaysTemplate> {
|
|
6
|
+
/** Creates a new search relays factory */
|
|
7
|
+
static create(): SearchRelaysFactory;
|
|
8
|
+
/** Creates a new search relays factory from an existing search relays event */
|
|
9
|
+
static modify(event: NostrEvent | KnownEvent<kinds.SearchRelaysList>): SearchRelaysFactory;
|
|
10
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { blankEventTemplate, toEventTemplate } from "applesauce-core/factories";
|
|
2
|
+
import { isKind, kinds } from "applesauce-core/helpers";
|
|
3
|
+
import { NIP51RelayListFactory } from "./list.js";
|
|
4
|
+
/** A factory class for building kind 10007 search relays list events */
|
|
5
|
+
export class SearchRelaysFactory extends NIP51RelayListFactory {
|
|
6
|
+
/** Creates a new search relays factory */
|
|
7
|
+
static create() {
|
|
8
|
+
return new SearchRelaysFactory((res) => res(blankEventTemplate(kinds.SearchRelaysList)));
|
|
9
|
+
}
|
|
10
|
+
/** Creates a new search relays factory from an existing search relays event */
|
|
11
|
+
static modify(event) {
|
|
12
|
+
if (!isKind(event, kinds.SearchRelaysList))
|
|
13
|
+
throw new Error("Event is not a search relays event");
|
|
14
|
+
return new SearchRelaysFactory((res) => res(toEventTemplate(event)));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { EventFactory } from "applesauce-core/factories";
|
|
2
|
+
import { EventTemplate, NostrEvent } from "applesauce-core/helpers";
|
|
3
|
+
import { MetaTagOptions } from "applesauce-core/operations/event";
|
|
4
|
+
import { ZapOptions } from "../operations/zap-split.js";
|
|
5
|
+
export type ShareBlueprintOptions = MetaTagOptions & ZapOptions;
|
|
6
|
+
/** A factory class for building NIP-18 repost/share events (kind 6/16) */
|
|
7
|
+
export declare class ShareFactory extends EventFactory<number, EventTemplate> {
|
|
8
|
+
/**
|
|
9
|
+
* Creates a new share factory
|
|
10
|
+
* @param event - The event being shared
|
|
11
|
+
* @returns A new share factory
|
|
12
|
+
*/
|
|
13
|
+
static create(event: NostrEvent): ShareFactory;
|
|
14
|
+
/** Creates a new share event for an existing event */
|
|
15
|
+
static share(event: NostrEvent): ShareFactory;
|
|
16
|
+
/**
|
|
17
|
+
* Creates a quote-repost: sets the event reference tags and uses a custom comment as content
|
|
18
|
+
* @param event - The event being quoted
|
|
19
|
+
* @param comment - The quote comment text
|
|
20
|
+
*/
|
|
21
|
+
static quote(event: NostrEvent, comment: string): ShareFactory;
|
|
22
|
+
/** Sets the event being shared */
|
|
23
|
+
setEvent(event: NostrEvent): this;
|
|
24
|
+
/** Sets zap split configuration */
|
|
25
|
+
zapSplit(options: ZapOptions): this;
|
|
26
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { blankEventTemplate, EventFactory } from "applesauce-core/factories";
|
|
2
|
+
import { kinds, pipeFromAsyncArray } from "applesauce-core/helpers";
|
|
3
|
+
import { embedSharedEvent, setShareKind, setShareTags } from "../operations/share.js";
|
|
4
|
+
import { setZapSplit } from "../operations/zap-split.js";
|
|
5
|
+
/** A factory class for building NIP-18 repost/share events (kind 6/16) */
|
|
6
|
+
export class ShareFactory extends EventFactory {
|
|
7
|
+
/**
|
|
8
|
+
* Creates a new share factory
|
|
9
|
+
* @param event - The event being shared
|
|
10
|
+
* @returns A new share factory
|
|
11
|
+
*/
|
|
12
|
+
static create(event) {
|
|
13
|
+
return new ShareFactory((res) => res(blankEventTemplate(kinds.Repost))).setEvent(event);
|
|
14
|
+
}
|
|
15
|
+
/** Creates a new share event for an existing event */
|
|
16
|
+
static share(event) {
|
|
17
|
+
return ShareFactory.create(event);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Creates a quote-repost: sets the event reference tags and uses a custom comment as content
|
|
21
|
+
* @param event - The event being quoted
|
|
22
|
+
* @param comment - The quote comment text
|
|
23
|
+
*/
|
|
24
|
+
static quote(event, comment) {
|
|
25
|
+
return new ShareFactory((res) => res(blankEventTemplate(kinds.Repost)))
|
|
26
|
+
.setEvent(event)
|
|
27
|
+
.chain((draft) => ({ ...draft, content: comment }));
|
|
28
|
+
}
|
|
29
|
+
/** Sets the event being shared */
|
|
30
|
+
setEvent(event) {
|
|
31
|
+
return this.chain(pipeFromAsyncArray([
|
|
32
|
+
// Set the kind
|
|
33
|
+
setShareKind(event),
|
|
34
|
+
// Then embed the event into the content
|
|
35
|
+
embedSharedEvent(event),
|
|
36
|
+
// Then set the reference tags
|
|
37
|
+
setShareTags(event),
|
|
38
|
+
]));
|
|
39
|
+
}
|
|
40
|
+
/** Sets zap split configuration */
|
|
41
|
+
zapSplit(options) {
|
|
42
|
+
return this.chain(setZapSplit(options, undefined));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { EventFactory } from "applesauce-core/factories";
|
|
2
|
+
import { kinds, KnownEventTemplate, NostrEvent } from "applesauce-core/helpers";
|
|
3
|
+
import { TextContentOptions } from "applesauce-core/operations/content";
|
|
4
|
+
import { MetaTagOptions } from "applesauce-core/operations/event";
|
|
5
|
+
import { AddressPointer } from "applesauce-core/helpers/pointers";
|
|
6
|
+
export type StreamChatMessageTemplate = KnownEventTemplate<kinds.LiveChatMessage>;
|
|
7
|
+
/** A factory class for building NIP-53 stream chat message events (kind 1311) */
|
|
8
|
+
export declare class StreamChatMessageFactory extends EventFactory<kinds.LiveChatMessage, StreamChatMessageTemplate> {
|
|
9
|
+
/**
|
|
10
|
+
* Creates a new stream chat message factory
|
|
11
|
+
* @param stream - The stream event or address pointer
|
|
12
|
+
* @param content - The message content
|
|
13
|
+
* @returns A new stream chat message factory
|
|
14
|
+
*/
|
|
15
|
+
static create(stream: NostrEvent | AddressPointer, content: string, options?: TextContentOptions): StreamChatMessageFactory;
|
|
16
|
+
/** Sets the stream for this chat message */
|
|
17
|
+
stream(stream: NostrEvent | AddressPointer): this;
|
|
18
|
+
/** Sets the message content */
|
|
19
|
+
message(content: string, options?: TextContentOptions): this;
|
|
20
|
+
/** Sets meta tags */
|
|
21
|
+
meta(options: MetaTagOptions): this;
|
|
22
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { EventFactory, blankEventTemplate } from "applesauce-core/factories";
|
|
2
|
+
import { kinds } from "applesauce-core/helpers";
|
|
3
|
+
import { setMetaTags } from "applesauce-core/operations/event";
|
|
4
|
+
import { setMessage, setStream } from "../operations/stream-chat.js";
|
|
5
|
+
/** A factory class for building NIP-53 stream chat message events (kind 1311) */
|
|
6
|
+
export class StreamChatMessageFactory extends EventFactory {
|
|
7
|
+
/**
|
|
8
|
+
* Creates a new stream chat message factory
|
|
9
|
+
* @param stream - The stream event or address pointer
|
|
10
|
+
* @param content - The message content
|
|
11
|
+
* @returns A new stream chat message factory
|
|
12
|
+
*/
|
|
13
|
+
static create(stream, content, options) {
|
|
14
|
+
let factory = new StreamChatMessageFactory((res) => res(blankEventTemplate(kinds.LiveChatMessage)))
|
|
15
|
+
.stream(stream)
|
|
16
|
+
.message(content, options);
|
|
17
|
+
return factory;
|
|
18
|
+
}
|
|
19
|
+
/** Sets the stream for this chat message */
|
|
20
|
+
stream(stream) {
|
|
21
|
+
return this.chain(setStream(stream));
|
|
22
|
+
}
|
|
23
|
+
/** Sets the message content */
|
|
24
|
+
message(content, options) {
|
|
25
|
+
return this.chain(setMessage(content, options));
|
|
26
|
+
}
|
|
27
|
+
/** Sets meta tags */
|
|
28
|
+
meta(options) {
|
|
29
|
+
return this.chain(setMetaTags(options));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { EventFactory } from "applesauce-core/factories";
|
|
2
|
+
import { KnownEventTemplate } from "applesauce-core/helpers";
|
|
3
|
+
import { MetaTagOptions } from "applesauce-core/operations/event";
|
|
4
|
+
import { TORRENT_KIND, TorrentExternalIdentifier, TorrentFile } from "../helpers/torrent.js";
|
|
5
|
+
export type TorrentTemplate = KnownEventTemplate<typeof TORRENT_KIND>;
|
|
6
|
+
export type TorrentBlueprintOptions = MetaTagOptions & {
|
|
7
|
+
/** Torrent title */
|
|
8
|
+
title?: string;
|
|
9
|
+
/** File entries in the torrent */
|
|
10
|
+
files?: TorrentFile[];
|
|
11
|
+
/** Tracker URLs */
|
|
12
|
+
trackers?: string[];
|
|
13
|
+
/** Newznab category ID */
|
|
14
|
+
category?: number;
|
|
15
|
+
/** Search tags for searchability (t tags) */
|
|
16
|
+
searchTags?: string[];
|
|
17
|
+
/** Category path (tcat) */
|
|
18
|
+
categoryPath?: string;
|
|
19
|
+
/** External identifiers */
|
|
20
|
+
externalIdentifiers?: TorrentExternalIdentifier[];
|
|
21
|
+
};
|
|
22
|
+
/** A factory class for building NIP-35 torrent events (kind 2003) */
|
|
23
|
+
export declare class TorrentFactory extends EventFactory<typeof TORRENT_KIND, TorrentTemplate> {
|
|
24
|
+
/**
|
|
25
|
+
* Creates a new torrent factory
|
|
26
|
+
* @param infoHash - The torrent info hash
|
|
27
|
+
* @param content - Optional description
|
|
28
|
+
* @returns A new torrent factory
|
|
29
|
+
*/
|
|
30
|
+
static create(infoHash: string, content?: string): TorrentFactory;
|
|
31
|
+
/** Sets the torrent info hash */
|
|
32
|
+
infoHash(hash: string): this;
|
|
33
|
+
/** Sets the torrent title */
|
|
34
|
+
title(title: string): this;
|
|
35
|
+
/** Sets the category path */
|
|
36
|
+
categoryPath(path: string): this;
|
|
37
|
+
/** Sets the newznab category */
|
|
38
|
+
category(id: number): this;
|
|
39
|
+
/** Adds a file to the torrent */
|
|
40
|
+
addFile(file: TorrentFile): this;
|
|
41
|
+
/** Adds files to the torrent */
|
|
42
|
+
files(files: TorrentFile[]): this;
|
|
43
|
+
/** Adds a tracker URL */
|
|
44
|
+
addTracker(url: string): this;
|
|
45
|
+
/** Adds tracker URLs */
|
|
46
|
+
trackers(urls: string[]): this;
|
|
47
|
+
/** Adds a search tag */
|
|
48
|
+
addSearchTag(tag: string): this;
|
|
49
|
+
/** Adds search tags */
|
|
50
|
+
searchTags(tags: string[]): this;
|
|
51
|
+
/** Adds an external identifier */
|
|
52
|
+
addExternalId(id: TorrentExternalIdentifier): this;
|
|
53
|
+
/** Adds external identifiers */
|
|
54
|
+
externalIds(ids: TorrentExternalIdentifier[]): this;
|
|
55
|
+
/** Sets meta tags */
|
|
56
|
+
meta(options: MetaTagOptions): this;
|
|
57
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { EventFactory, blankEventTemplate } from "applesauce-core/factories";
|
|
2
|
+
import { setMetaTags } from "applesauce-core/operations/event";
|
|
3
|
+
import { TORRENT_KIND } from "../helpers/torrent.js";
|
|
4
|
+
import { addTorrentExternalIdentifier, addTorrentFile, addTorrentSearchTag, addTorrentTracker, setTorrentCategory, setTorrentCategoryPath, setTorrentInfoHash, setTorrentTitle, } from "../operations/torrent.js";
|
|
5
|
+
/** A factory class for building NIP-35 torrent events (kind 2003) */
|
|
6
|
+
export class TorrentFactory extends EventFactory {
|
|
7
|
+
/**
|
|
8
|
+
* Creates a new torrent factory
|
|
9
|
+
* @param infoHash - The torrent info hash
|
|
10
|
+
* @param content - Optional description
|
|
11
|
+
* @returns A new torrent factory
|
|
12
|
+
*/
|
|
13
|
+
static create(infoHash, content) {
|
|
14
|
+
const factory = new TorrentFactory((res) => res(blankEventTemplate(TORRENT_KIND))).infoHash(infoHash);
|
|
15
|
+
return content ? factory.content(content) : factory;
|
|
16
|
+
}
|
|
17
|
+
/** Sets the torrent info hash */
|
|
18
|
+
infoHash(hash) {
|
|
19
|
+
return this.chain((draft) => setTorrentInfoHash(hash)(draft));
|
|
20
|
+
}
|
|
21
|
+
/** Sets the torrent title */
|
|
22
|
+
title(title) {
|
|
23
|
+
return this.chain((draft) => setTorrentTitle(title)(draft));
|
|
24
|
+
}
|
|
25
|
+
/** Sets the category path */
|
|
26
|
+
categoryPath(path) {
|
|
27
|
+
return this.chain((draft) => setTorrentCategoryPath(path)(draft));
|
|
28
|
+
}
|
|
29
|
+
/** Sets the newznab category */
|
|
30
|
+
category(id) {
|
|
31
|
+
return this.chain((draft) => setTorrentCategory(id)(draft));
|
|
32
|
+
}
|
|
33
|
+
/** Adds a file to the torrent */
|
|
34
|
+
addFile(file) {
|
|
35
|
+
return this.chain((draft) => addTorrentFile(file)(draft));
|
|
36
|
+
}
|
|
37
|
+
/** Adds files to the torrent */
|
|
38
|
+
files(files) {
|
|
39
|
+
return this.chain(async (draft) => {
|
|
40
|
+
let result = draft;
|
|
41
|
+
for (const file of files) {
|
|
42
|
+
result = await addTorrentFile(file)(result);
|
|
43
|
+
}
|
|
44
|
+
return result;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/** Adds a tracker URL */
|
|
48
|
+
addTracker(url) {
|
|
49
|
+
return this.chain((draft) => addTorrentTracker(url)(draft));
|
|
50
|
+
}
|
|
51
|
+
/** Adds tracker URLs */
|
|
52
|
+
trackers(urls) {
|
|
53
|
+
return this.chain(async (draft) => {
|
|
54
|
+
let result = draft;
|
|
55
|
+
for (const url of urls) {
|
|
56
|
+
result = await addTorrentTracker(url)(result);
|
|
57
|
+
}
|
|
58
|
+
return result;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
/** Adds a search tag */
|
|
62
|
+
addSearchTag(tag) {
|
|
63
|
+
return this.chain((draft) => addTorrentSearchTag(tag)(draft));
|
|
64
|
+
}
|
|
65
|
+
/** Adds search tags */
|
|
66
|
+
searchTags(tags) {
|
|
67
|
+
return this.chain(async (draft) => {
|
|
68
|
+
let result = draft;
|
|
69
|
+
for (const tag of tags) {
|
|
70
|
+
result = await addTorrentSearchTag(tag)(result);
|
|
71
|
+
}
|
|
72
|
+
return result;
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
/** Adds an external identifier */
|
|
76
|
+
addExternalId(id) {
|
|
77
|
+
return this.chain((draft) => addTorrentExternalIdentifier(id)(draft));
|
|
78
|
+
}
|
|
79
|
+
/** Adds external identifiers */
|
|
80
|
+
externalIds(ids) {
|
|
81
|
+
return this.chain(async (draft) => {
|
|
82
|
+
let result = draft;
|
|
83
|
+
for (const id of ids) {
|
|
84
|
+
result = await addTorrentExternalIdentifier(id)(result);
|
|
85
|
+
}
|
|
86
|
+
return result;
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/** Sets meta tags */
|
|
90
|
+
meta(options) {
|
|
91
|
+
return this.chain((draft) => setMetaTags(options)(draft));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { EventFactory } from "applesauce-core/factories";
|
|
2
|
+
import { kinds, KnownEventTemplate } from "applesauce-core/helpers";
|
|
3
|
+
import { TextContentOptions } from "applesauce-core/operations/content";
|
|
4
|
+
import { Rumor } from "../helpers/gift-wrap.js";
|
|
5
|
+
export type WrappedMessageTemplate = KnownEventTemplate<kinds.PrivateDirectMessage>;
|
|
6
|
+
export type WrappedMessageBlueprintOptions = TextContentOptions;
|
|
7
|
+
export declare class WrappedMessageFactory extends EventFactory<kinds.PrivateDirectMessage, WrappedMessageTemplate> {
|
|
8
|
+
/**
|
|
9
|
+
* Creates a new wrapped message.
|
|
10
|
+
* @param recipients - A single recipient pubkey or an array of recipient pubkeys
|
|
11
|
+
* @param message - The plaintext message content
|
|
12
|
+
*/
|
|
13
|
+
static create(recipients: string | string[], message: string): WrappedMessageFactory;
|
|
14
|
+
/** Creates a reply to a wrapped message */
|
|
15
|
+
static reply(parent: Rumor | string, recipient: string, message: string): WrappedMessageFactory;
|
|
16
|
+
/** Sets the text content of the message */
|
|
17
|
+
text(content: string, options?: TextContentOptions): this;
|
|
18
|
+
/** Sets the parent message "e" tag for NIP-17 reply threading */
|
|
19
|
+
replyTo(parent: Rumor | string): this;
|
|
20
|
+
/** Sets the subject tag for the message thread */
|
|
21
|
+
subject(subject: string): this;
|
|
22
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { blankEventTemplate, EventFactory } from "applesauce-core/factories";
|
|
2
|
+
import { kinds } from "applesauce-core/helpers";
|
|
3
|
+
import { includeNameValueTag } from "applesauce-core/operations/tags";
|
|
4
|
+
import { setShortTextContent } from "applesauce-core/operations/content";
|
|
5
|
+
import { setParent, setSubject } from "../operations/wrapped-message.js";
|
|
6
|
+
export class WrappedMessageFactory extends EventFactory {
|
|
7
|
+
/**
|
|
8
|
+
* Creates a new wrapped message.
|
|
9
|
+
* @param recipients - A single recipient pubkey or an array of recipient pubkeys
|
|
10
|
+
* @param message - The plaintext message content
|
|
11
|
+
*/
|
|
12
|
+
static create(recipients, message) {
|
|
13
|
+
const recipientList = typeof recipients === "string" ? [recipients] : recipients;
|
|
14
|
+
let factory = new WrappedMessageFactory((res) => res(blankEventTemplate(kinds.PrivateDirectMessage))).chain(setShortTextContent(message));
|
|
15
|
+
for (const recipient of recipientList) {
|
|
16
|
+
factory = factory.chain(includeNameValueTag(["p", recipient]));
|
|
17
|
+
}
|
|
18
|
+
return factory;
|
|
19
|
+
}
|
|
20
|
+
/** Creates a reply to a wrapped message */
|
|
21
|
+
static reply(parent, recipient, message) {
|
|
22
|
+
return new WrappedMessageFactory((res) => res(blankEventTemplate(kinds.PrivateDirectMessage)))
|
|
23
|
+
.chain(setShortTextContent(message))
|
|
24
|
+
.chain(includeNameValueTag(["p", recipient]))
|
|
25
|
+
.replyTo(parent);
|
|
26
|
+
}
|
|
27
|
+
/** Sets the text content of the message */
|
|
28
|
+
text(content, options) {
|
|
29
|
+
return this.chain(setShortTextContent(content, options));
|
|
30
|
+
}
|
|
31
|
+
/** Sets the parent message "e" tag for NIP-17 reply threading */
|
|
32
|
+
replyTo(parent) {
|
|
33
|
+
return this.chain(setParent(parent));
|
|
34
|
+
}
|
|
35
|
+
/** Sets the subject tag for the message thread */
|
|
36
|
+
subject(subject) {
|
|
37
|
+
return this.chain(setSubject(subject));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { EventFactory } from "applesauce-core/factories";
|
|
2
|
+
import { KnownEventTemplate } from "applesauce-core/helpers";
|
|
3
|
+
import { MetaTagOptions } from "applesauce-core/operations/event";
|
|
4
|
+
import { ZAP_GOAL_KIND } from "../helpers/zap-goal.js";
|
|
5
|
+
import { ZapOptions } from "../operations/zap-split.js";
|
|
6
|
+
export type ZapGoalTemplate = KnownEventTemplate<typeof ZAP_GOAL_KIND>;
|
|
7
|
+
export type ZapGoalBlueprintOptions = MetaTagOptions & ZapOptions & {
|
|
8
|
+
closedAt?: number;
|
|
9
|
+
image?: string;
|
|
10
|
+
summary?: string;
|
|
11
|
+
};
|
|
12
|
+
export declare class ZapGoalFactory extends EventFactory<typeof ZAP_GOAL_KIND, ZapGoalTemplate> {
|
|
13
|
+
static create(description: string, amount: number, relays: string[]): ZapGoalFactory;
|
|
14
|
+
/** Sets the amount of the zap goal */
|
|
15
|
+
amount(amount: number): this;
|
|
16
|
+
/** Sets the relays for the zap goal */
|
|
17
|
+
relays(urls: string[]): this;
|
|
18
|
+
/** Sets the closed at timestamp for the zap goal */
|
|
19
|
+
closedAt(timestamp: number): this;
|
|
20
|
+
/** Sets the image for the zap goal */
|
|
21
|
+
image(url: string): this;
|
|
22
|
+
/** Sets the summary for the zap goal */
|
|
23
|
+
summary(text: string): this;
|
|
24
|
+
/** Sets the beneficiaries for the zap goal using zap split tags */
|
|
25
|
+
beneficiaries(beneficiaries: Array<{
|
|
26
|
+
pubkey: string;
|
|
27
|
+
weight: number;
|
|
28
|
+
}>): this;
|
|
29
|
+
/** Sets a goal tag linking this goal to a specific event */
|
|
30
|
+
goal(goalId: string, relay?: string): this;
|
|
31
|
+
/** Sets the zap split for the zap goal */
|
|
32
|
+
zapSplit(options: ZapOptions): this;
|
|
33
|
+
/** Sets the meta tags for the zap goal */
|
|
34
|
+
meta(options: MetaTagOptions): this;
|
|
35
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { blankEventTemplate, EventFactory } from "applesauce-core/factories";
|
|
2
|
+
import { setMetaTags } from "applesauce-core/operations/event";
|
|
3
|
+
import { ZAP_GOAL_KIND } from "../helpers/zap-goal.js";
|
|
4
|
+
import * as ZapGoal from "../operations/zap-goal.js";
|
|
5
|
+
import { setZapSplit } from "../operations/zap-split.js";
|
|
6
|
+
export class ZapGoalFactory extends EventFactory {
|
|
7
|
+
static create(description, amount, relays) {
|
|
8
|
+
return new ZapGoalFactory((res) => res(blankEventTemplate(ZAP_GOAL_KIND)))
|
|
9
|
+
.content(description)
|
|
10
|
+
.amount(amount)
|
|
11
|
+
.relays(relays);
|
|
12
|
+
}
|
|
13
|
+
/** Sets the amount of the zap goal */
|
|
14
|
+
amount(amount) {
|
|
15
|
+
return this.chain(ZapGoal.setAmount(amount));
|
|
16
|
+
}
|
|
17
|
+
/** Sets the relays for the zap goal */
|
|
18
|
+
relays(urls) {
|
|
19
|
+
return this.chain(ZapGoal.setRelays(urls));
|
|
20
|
+
}
|
|
21
|
+
/** Sets the closed at timestamp for the zap goal */
|
|
22
|
+
closedAt(timestamp) {
|
|
23
|
+
return this.chain(ZapGoal.setClosedAt(timestamp));
|
|
24
|
+
}
|
|
25
|
+
/** Sets the image for the zap goal */
|
|
26
|
+
image(url) {
|
|
27
|
+
return this.chain(ZapGoal.setImage(url));
|
|
28
|
+
}
|
|
29
|
+
/** Sets the summary for the zap goal */
|
|
30
|
+
summary(text) {
|
|
31
|
+
return this.chain(ZapGoal.setSummary(text));
|
|
32
|
+
}
|
|
33
|
+
/** Sets the beneficiaries for the zap goal using zap split tags */
|
|
34
|
+
beneficiaries(beneficiaries) {
|
|
35
|
+
return this.chain(ZapGoal.setBeneficiaries(beneficiaries));
|
|
36
|
+
}
|
|
37
|
+
/** Sets a goal tag linking this goal to a specific event */
|
|
38
|
+
goal(goalId, relay) {
|
|
39
|
+
return this.chain(ZapGoal.setGoalTag(goalId, relay));
|
|
40
|
+
}
|
|
41
|
+
/** Sets the zap split for the zap goal */
|
|
42
|
+
zapSplit(options) {
|
|
43
|
+
return this.chain(setZapSplit(options, undefined));
|
|
44
|
+
}
|
|
45
|
+
/** Sets the meta tags for the zap goal */
|
|
46
|
+
meta(options) {
|
|
47
|
+
return this.chain(setMetaTags(options));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { EventFactory } from "applesauce-core/factories";
|
|
2
|
+
import { kinds, KnownEventTemplate, NostrEvent, ProfilePointer } from "applesauce-core/helpers";
|
|
3
|
+
export type ZapRequestTemplate = KnownEventTemplate<typeof kinds.ZapRequest>;
|
|
4
|
+
export declare class ZapRequestFactory extends EventFactory<typeof kinds.ZapRequest, ZapRequestTemplate> {
|
|
5
|
+
/**
|
|
6
|
+
* Creates a new zap request event
|
|
7
|
+
* @param event - The NostrEvent being zapped
|
|
8
|
+
* @param amount - The amount in millisatoshis
|
|
9
|
+
* @param relays - The relays to use for the zap request
|
|
10
|
+
*/
|
|
11
|
+
static create(event: NostrEvent, amount: number, relays: string[]): ZapRequestFactory;
|
|
12
|
+
/** Creates a zap request for a profile */
|
|
13
|
+
static profile(pubkey: string | ProfilePointer, amount: number, relays: string[], hint?: string): ZapRequestFactory;
|
|
14
|
+
/** Creates a zap request for an event */
|
|
15
|
+
static event(event: NostrEvent, amount: number, relays: string[], hint?: string): ZapRequestFactory;
|
|
16
|
+
/** Sets the relays for the zap request */
|
|
17
|
+
relays(urls: string[]): this;
|
|
18
|
+
/** Sets the event target. Sets the k (kind), e (event id), a (coordinate for replaceable events), and p (recipient) tags */
|
|
19
|
+
eventTarget(event: NostrEvent, hint?: string): this;
|
|
20
|
+
/** Sets the profile target. Sets the p tag (recipient) */
|
|
21
|
+
profileTarget(pubkey: string | ProfilePointer, hint?: string): this;
|
|
22
|
+
/** Sets the amount in millisatoshis */
|
|
23
|
+
amount(amount: number): this;
|
|
24
|
+
/** Sets the lnurl (bech32-encoded) */
|
|
25
|
+
lnurl(lnurl: string): this;
|
|
26
|
+
/** Sets the zap message */
|
|
27
|
+
message(text: string): this;
|
|
28
|
+
}
|