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.
Files changed (263) hide show
  1. package/dist/casts/_circular-import.d.ts +7 -0
  2. package/dist/casts/_circular-import.js +9 -0
  3. package/dist/casts/article.d.ts +1 -1
  4. package/dist/casts/badge-award.d.ts +24 -0
  5. package/dist/casts/badge-award.js +39 -0
  6. package/dist/casts/badge.d.ts +19 -0
  7. package/dist/casts/badge.js +48 -0
  8. package/dist/casts/bookmarks.d.ts +5 -5
  9. package/dist/casts/cast.d.ts +1 -30
  10. package/dist/casts/cast.js +2 -67
  11. package/dist/casts/comment.d.ts +5 -5
  12. package/dist/casts/emoji-pack.d.ts +11 -0
  13. package/dist/casts/emoji-pack.js +25 -0
  14. package/dist/casts/favorite-emojis.d.ts +25 -0
  15. package/dist/casts/favorite-emojis.js +62 -0
  16. package/dist/casts/file-metadata.d.ts +22 -0
  17. package/dist/casts/file-metadata.js +55 -0
  18. package/dist/casts/groups.d.ts +1 -1
  19. package/dist/casts/index.d.ts +7 -0
  20. package/dist/casts/index.js +7 -0
  21. package/dist/casts/mutes.d.ts +1 -1
  22. package/dist/casts/note.d.ts +7 -7
  23. package/dist/casts/profile-badges.d.ts +28 -0
  24. package/dist/casts/profile-badges.js +59 -0
  25. package/dist/casts/reaction.d.ts +1 -1
  26. package/dist/casts/relay-lists.d.ts +1 -1
  27. package/dist/casts/relay-monitor.d.ts +1 -1
  28. package/dist/casts/report.d.ts +2 -2
  29. package/dist/casts/share.d.ts +2 -2
  30. package/dist/casts/stream.d.ts +9 -9
  31. package/dist/casts/torrent.d.ts +3 -3
  32. package/dist/casts/trusted-assertions.d.ts +144 -0
  33. package/dist/casts/trusted-assertions.js +281 -0
  34. package/dist/casts/user.d.ts +22 -40
  35. package/dist/casts/user.js +105 -161
  36. package/dist/casts/zap-goal.d.ts +2 -2
  37. package/dist/casts/zap.d.ts +4 -4
  38. package/dist/factories/app-data.d.ts +13 -0
  39. package/dist/factories/app-data.js +20 -0
  40. package/dist/factories/badge-award.d.ts +25 -0
  41. package/dist/factories/badge-award.js +41 -0
  42. package/dist/factories/badge.d.ts +32 -0
  43. package/dist/factories/badge.js +50 -0
  44. package/dist/factories/blocked-relays.d.ts +10 -0
  45. package/dist/factories/blocked-relays.js +16 -0
  46. package/dist/factories/blossom-server-list.d.ts +19 -0
  47. package/dist/factories/blossom-server-list.js +36 -0
  48. package/dist/factories/bookmark-list.d.ts +23 -0
  49. package/dist/factories/bookmark-list.js +45 -0
  50. package/dist/factories/bookmark-set.d.ts +25 -0
  51. package/dist/factories/bookmark-set.js +51 -0
  52. package/dist/factories/calendar-event.d.ts +88 -0
  53. package/dist/factories/calendar-event.js +175 -0
  54. package/dist/factories/calendar-rsvp.d.ts +22 -0
  55. package/dist/factories/calendar-rsvp.js +35 -0
  56. package/dist/factories/calendar.d.ts +20 -0
  57. package/dist/factories/calendar.js +36 -0
  58. package/dist/factories/code-snippet.d.ts +65 -0
  59. package/dist/factories/code-snippet.js +100 -0
  60. package/dist/factories/comment.d.ts +26 -0
  61. package/dist/factories/comment.js +49 -0
  62. package/dist/factories/contacts.d.ts +19 -0
  63. package/dist/factories/contacts.js +36 -0
  64. package/dist/factories/dm-relays.d.ts +10 -0
  65. package/dist/factories/dm-relays.js +16 -0
  66. package/dist/factories/favorite-relays.d.ts +16 -0
  67. package/dist/factories/favorite-relays.js +31 -0
  68. package/dist/factories/file-metadata.d.ts +54 -0
  69. package/dist/factories/file-metadata.js +92 -0
  70. package/dist/factories/follow-set.d.ts +12 -0
  71. package/dist/factories/follow-set.js +22 -0
  72. package/dist/factories/gift-wrap.d.ts +17 -0
  73. package/dist/factories/gift-wrap.js +21 -0
  74. package/dist/factories/group-management.d.ts +63 -0
  75. package/dist/factories/group-management.js +147 -0
  76. package/dist/factories/group.d.ts +35 -0
  77. package/dist/factories/group.js +69 -0
  78. package/dist/factories/highlight.d.ts +33 -0
  79. package/dist/factories/highlight.js +49 -0
  80. package/dist/factories/index.d.ts +41 -0
  81. package/dist/factories/index.js +41 -0
  82. package/dist/factories/legacy-message.d.ts +10 -0
  83. package/dist/factories/legacy-message.js +19 -0
  84. package/dist/factories/list.d.ts +56 -0
  85. package/dist/factories/list.js +120 -0
  86. package/dist/factories/live-stream.d.ts +48 -0
  87. package/dist/factories/live-stream.js +90 -0
  88. package/dist/factories/mute-list.d.ts +27 -0
  89. package/dist/factories/mute-list.js +57 -0
  90. package/dist/factories/note.d.ts +38 -0
  91. package/dist/factories/note.js +66 -0
  92. package/dist/factories/picture-post.d.ts +28 -0
  93. package/dist/factories/picture-post.js +46 -0
  94. package/dist/factories/pin-list.d.ts +14 -0
  95. package/dist/factories/pin-list.js +24 -0
  96. package/dist/factories/poll-response.d.ts +36 -0
  97. package/dist/factories/poll-response.js +46 -0
  98. package/dist/factories/poll.d.ts +35 -0
  99. package/dist/factories/poll.js +48 -0
  100. package/dist/factories/profile-badges.d.ts +31 -0
  101. package/dist/factories/profile-badges.js +52 -0
  102. package/dist/factories/reaction.d.ts +22 -0
  103. package/dist/factories/reaction.js +37 -0
  104. package/dist/factories/relay-set.d.ts +12 -0
  105. package/dist/factories/relay-set.js +22 -0
  106. package/dist/factories/search-relays.d.ts +10 -0
  107. package/dist/factories/search-relays.js +16 -0
  108. package/dist/factories/share.d.ts +26 -0
  109. package/dist/factories/share.js +44 -0
  110. package/dist/factories/stream-chat-message.d.ts +22 -0
  111. package/dist/factories/stream-chat-message.js +31 -0
  112. package/dist/factories/torrent.d.ts +57 -0
  113. package/dist/factories/torrent.js +93 -0
  114. package/dist/factories/wrapped-message.d.ts +22 -0
  115. package/dist/factories/wrapped-message.js +39 -0
  116. package/dist/factories/zap-goal.d.ts +35 -0
  117. package/dist/factories/zap-goal.js +49 -0
  118. package/dist/factories/zap-request.d.ts +28 -0
  119. package/dist/factories/zap-request.js +55 -0
  120. package/dist/factories/zap.d.ts +13 -0
  121. package/dist/factories/zap.js +21 -0
  122. package/dist/helpers/badge-award.d.ts +15 -0
  123. package/dist/helpers/badge-award.js +32 -0
  124. package/dist/helpers/badge.d.ts +27 -0
  125. package/dist/helpers/badge.js +59 -0
  126. package/dist/helpers/blossom.d.ts +29 -1
  127. package/dist/helpers/blossom.js +64 -7
  128. package/dist/helpers/emoji-pack.d.ts +43 -0
  129. package/dist/helpers/emoji-pack.js +108 -0
  130. package/dist/helpers/emoji.d.ts +0 -4
  131. package/dist/helpers/emoji.js +0 -16
  132. package/dist/helpers/file-metadata.d.ts +18 -13
  133. package/dist/helpers/file-metadata.js +10 -4
  134. package/dist/helpers/groups.d.ts +1 -0
  135. package/dist/helpers/groups.js +3 -2
  136. package/dist/helpers/hashtag.d.ts +1 -0
  137. package/dist/helpers/hashtag.js +3 -3
  138. package/dist/helpers/index.d.ts +7 -2
  139. package/dist/helpers/index.js +7 -2
  140. package/dist/helpers/lists.d.ts +8 -0
  141. package/dist/helpers/lists.js +27 -5
  142. package/dist/helpers/picture-post.d.ts +2 -2
  143. package/dist/helpers/profile-badges.d.ts +23 -0
  144. package/dist/helpers/profile-badges.js +51 -0
  145. package/dist/helpers/trusted-assertions.d.ts +81 -0
  146. package/dist/helpers/trusted-assertions.js +161 -0
  147. package/dist/helpers/zap.d.ts +8 -2
  148. package/dist/helpers/zap.js +31 -26
  149. package/dist/index.d.ts +2 -2
  150. package/dist/index.js +3 -3
  151. package/dist/models/index.d.ts +1 -1
  152. package/dist/models/index.js +1 -1
  153. package/dist/observable/chainable.d.ts +1 -36
  154. package/dist/observable/chainable.js +2 -72
  155. package/dist/operations/app-data.d.ts +8 -3
  156. package/dist/operations/app-data.js +9 -4
  157. package/dist/operations/badge-award.d.ts +17 -0
  158. package/dist/operations/badge-award.js +30 -0
  159. package/dist/operations/badge.d.ts +22 -0
  160. package/dist/operations/badge.js +54 -0
  161. package/dist/operations/blossom.d.ts +1 -1
  162. package/dist/operations/calendar-event.d.ts +1 -1
  163. package/dist/operations/calendar-rsvp.d.ts +1 -1
  164. package/dist/operations/calendar.d.ts +1 -1
  165. package/dist/operations/channel.d.ts +1 -1
  166. package/dist/operations/client.d.ts +1 -1
  167. package/dist/operations/client.js +2 -2
  168. package/dist/operations/code-snippet.d.ts +27 -0
  169. package/dist/operations/code-snippet.js +63 -0
  170. package/dist/operations/comment.d.ts +7 -3
  171. package/dist/operations/comment.js +8 -4
  172. package/dist/operations/file-metadata.d.ts +38 -4
  173. package/dist/operations/file-metadata.js +105 -19
  174. package/dist/operations/geohash.d.ts +1 -1
  175. package/dist/operations/gift-wrap.d.ts +19 -7
  176. package/dist/operations/gift-wrap.js +36 -26
  177. package/dist/operations/group.d.ts +1 -1
  178. package/dist/operations/hashtags.d.ts +1 -1
  179. package/dist/operations/highlight.d.ts +1 -1
  180. package/dist/operations/highlight.js +5 -5
  181. package/dist/operations/index.d.ts +7 -1
  182. package/dist/operations/index.js +7 -1
  183. package/dist/operations/legacy-message.d.ts +1 -1
  184. package/dist/operations/list.d.ts +1 -1
  185. package/dist/operations/live-stream.d.ts +7 -3
  186. package/dist/operations/live-stream.js +9 -5
  187. package/dist/operations/media-attachment.d.ts +3 -3
  188. package/dist/operations/note.d.ts +10 -4
  189. package/dist/operations/note.js +14 -8
  190. package/dist/operations/picture-post.d.ts +1 -1
  191. package/dist/operations/poll-response.d.ts +1 -1
  192. package/dist/operations/poll-response.js +1 -1
  193. package/dist/operations/poll.d.ts +1 -1
  194. package/dist/operations/profile-badges.d.ts +26 -0
  195. package/dist/operations/profile-badges.js +150 -0
  196. package/dist/operations/reaction.d.ts +8 -3
  197. package/dist/operations/reaction.js +10 -5
  198. package/dist/operations/share.d.ts +8 -3
  199. package/dist/operations/share.js +10 -5
  200. package/dist/operations/stream.d.ts +1 -1
  201. package/dist/operations/tag/bookmarks.d.ts +1 -1
  202. package/dist/operations/torrent.d.ts +1 -1
  203. package/dist/operations/wrapped-message.d.ts +1 -1
  204. package/dist/operations/zap-goal.d.ts +1 -1
  205. package/dist/operations/zap-request.d.ts +22 -0
  206. package/dist/operations/zap-request.js +40 -0
  207. package/dist/operations/zap-split.d.ts +8 -4
  208. package/dist/operations/zap-split.js +10 -6
  209. package/dist/operations/zap.d.ts +12 -0
  210. package/dist/operations/zap.js +34 -0
  211. package/package.json +12 -11
  212. package/dist/blueprints/__register__.d.ts +0 -7
  213. package/dist/blueprints/__register__.js +0 -8
  214. package/dist/blueprints/app-data.d.ts +0 -5
  215. package/dist/blueprints/app-data.js +0 -10
  216. package/dist/blueprints/calendar.d.ts +0 -5
  217. package/dist/blueprints/calendar.js +0 -7
  218. package/dist/blueprints/channels.d.ts +0 -6
  219. package/dist/blueprints/channels.js +0 -13
  220. package/dist/blueprints/comment.d.ts +0 -13
  221. package/dist/blueprints/comment.js +0 -15
  222. package/dist/blueprints/delete.d.ts +0 -9
  223. package/dist/blueprints/delete.js +0 -14
  224. package/dist/blueprints/file-metadata.d.ts +0 -8
  225. package/dist/blueprints/file-metadata.js +0 -11
  226. package/dist/blueprints/follow-set.d.ts +0 -11
  227. package/dist/blueprints/follow-set.js +0 -21
  228. package/dist/blueprints/gift-wrap.d.ts +0 -5
  229. package/dist/blueprints/gift-wrap.js +0 -6
  230. package/dist/blueprints/group-mangement.d.ts +0 -25
  231. package/dist/blueprints/group-mangement.js +0 -40
  232. package/dist/blueprints/group.d.ts +0 -9
  233. package/dist/blueprints/group.js +0 -17
  234. package/dist/blueprints/highlight.d.ts +0 -20
  235. package/dist/blueprints/highlight.js +0 -12
  236. package/dist/blueprints/index.d.ts +0 -25
  237. package/dist/blueprints/index.js +0 -26
  238. package/dist/blueprints/legacy-message.d.ts +0 -7
  239. package/dist/blueprints/legacy-message.js +0 -29
  240. package/dist/blueprints/live-stream.d.ts +0 -6
  241. package/dist/blueprints/live-stream.js +0 -9
  242. package/dist/blueprints/note.d.ts +0 -16
  243. package/dist/blueprints/note.js +0 -30
  244. package/dist/blueprints/picture-post.d.ts +0 -12
  245. package/dist/blueprints/picture-post.js +0 -17
  246. package/dist/blueprints/poll.d.ts +0 -41
  247. package/dist/blueprints/poll.js +0 -33
  248. package/dist/blueprints/profile.d.ts +0 -3
  249. package/dist/blueprints/profile.js +0 -7
  250. package/dist/blueprints/reaction.d.ts +0 -10
  251. package/dist/blueprints/reaction.js +0 -14
  252. package/dist/blueprints/share.d.ts +0 -12
  253. package/dist/blueprints/share.js +0 -25
  254. package/dist/blueprints/stream.d.ts +0 -6
  255. package/dist/blueprints/stream.js +0 -7
  256. package/dist/blueprints/torrent.d.ts +0 -30
  257. package/dist/blueprints/torrent.js +0 -29
  258. package/dist/blueprints/wrapped-message.d.ts +0 -20
  259. package/dist/blueprints/wrapped-message.js +0 -64
  260. package/dist/blueprints/zap-goal.d.ts +0 -16
  261. package/dist/blueprints/zap-goal.js +0 -12
  262. package/dist/register.d.ts +0 -2
  263. package/dist/register.js +0 -4
@@ -0,0 +1,48 @@
1
+ import { EventFactory } from "applesauce-core/factories";
2
+ import { kinds, KnownEvent, KnownEventTemplate, NostrEvent } from "applesauce-core/helpers";
3
+ import { ProfilePointer } from "applesauce-core/helpers/pointers";
4
+ import { StreamRole } from "../helpers/stream.js";
5
+ export type LiveStreamTemplate = KnownEventTemplate<kinds.LiveEvent>;
6
+ /** A factory class for building NIP-53 live stream events (kind 30311) */
7
+ export declare class LiveStreamFactory extends EventFactory<kinds.LiveEvent, LiveStreamTemplate> {
8
+ /** Creates a new live stream factory with an auto-generated identifier */
9
+ static create(title: string): LiveStreamFactory;
10
+ /** Creates a factory from an existing live stream event for editing */
11
+ static modify(event: NostrEvent | KnownEvent<kinds.LiveEvent>): LiveStreamFactory;
12
+ /** Sets the "d" identifier tag */
13
+ identifier(id: string): this;
14
+ /** Sets the title of the live stream */
15
+ title(title: string): this;
16
+ /** Sets the summary/description of the live stream */
17
+ summary(summary: string): this;
18
+ /** Sets the preview image for the live stream */
19
+ image(url: string): this;
20
+ /** Sets the streaming URL */
21
+ streamingUrl(url: string | URL): this;
22
+ /** Sets the recording URL (typically after the stream ends) */
23
+ recordingUrl(url: string | URL): this;
24
+ /** Sets the start time of the stream */
25
+ startTime(time: number | Date): this;
26
+ /** Sets the end time of the stream */
27
+ endTime(time: number | Date): this;
28
+ /** Sets the status of the stream */
29
+ status(status: "planned" | "live" | "ended"): this;
30
+ /** Sets the host of the stream */
31
+ host(user: ProfilePointer): this;
32
+ /** Adds a participant to the stream with a role */
33
+ addParticipant(user: ProfilePointer, role: StreamRole): this;
34
+ /** Removes a participant from the stream */
35
+ removeParticipant(pubkey: string): this;
36
+ /** Adds a relay to the stream's relay list */
37
+ addRelay(relay: string | URL): this;
38
+ /** Removes a relay from the stream's relay list */
39
+ removeRelay(relay: string | URL): this;
40
+ /** Sets the pinned live chat message */
41
+ pinnedMessage(eventId: string): this;
42
+ /** Removes the pinned live chat message */
43
+ removePinnedMessage(): this;
44
+ /** Adds a hashtag "t" tag to the stream */
45
+ addHashtag(hashtag: string): this;
46
+ /** Removes a hashtag from the stream */
47
+ removeHashtag(hashtag: string): this;
48
+ }
@@ -0,0 +1,90 @@
1
+ import { EventFactory, 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 * as Stream from "../operations/stream.js";
6
+ /** A factory class for building NIP-53 live stream events (kind 30311) */
7
+ export class LiveStreamFactory extends EventFactory {
8
+ /** Creates a new live stream factory with an auto-generated identifier */
9
+ static create(title) {
10
+ return new LiveStreamFactory((res) => res(blankEventTemplate(kinds.LiveEvent))).identifier(nanoid()).title(title);
11
+ }
12
+ /** Creates a factory from an existing live stream event for editing */
13
+ static modify(event) {
14
+ if (!isKind(event, kinds.LiveEvent))
15
+ throw new Error("Event is not a live stream event");
16
+ return new LiveStreamFactory((res) => res(toEventTemplate(event)));
17
+ }
18
+ /** Sets the "d" identifier tag */
19
+ identifier(id) {
20
+ return this.chain(includeReplaceableIdentifier(id));
21
+ }
22
+ /** Sets the title of the live stream */
23
+ title(title) {
24
+ return this.chain(Stream.setTitle(title));
25
+ }
26
+ /** Sets the summary/description of the live stream */
27
+ summary(summary) {
28
+ return this.chain(Stream.setSummary(summary));
29
+ }
30
+ /** Sets the preview image for the live stream */
31
+ image(url) {
32
+ return this.chain(Stream.setImage(url));
33
+ }
34
+ /** Sets the streaming URL */
35
+ streamingUrl(url) {
36
+ return this.chain(Stream.setStreamingUrl(url));
37
+ }
38
+ /** Sets the recording URL (typically after the stream ends) */
39
+ recordingUrl(url) {
40
+ return this.chain(Stream.setRecordingUrl(url));
41
+ }
42
+ /** Sets the start time of the stream */
43
+ startTime(time) {
44
+ return this.chain(Stream.setStartTime(time));
45
+ }
46
+ /** Sets the end time of the stream */
47
+ endTime(time) {
48
+ return this.chain(Stream.setEndTime(time));
49
+ }
50
+ /** Sets the status of the stream */
51
+ status(status) {
52
+ return this.chain(Stream.setStatus(status));
53
+ }
54
+ /** Sets the host of the stream */
55
+ host(user) {
56
+ return this.chain(Stream.setHost(user));
57
+ }
58
+ /** Adds a participant to the stream with a role */
59
+ addParticipant(user, role) {
60
+ return this.chain(Stream.addParticipant(user, role));
61
+ }
62
+ /** Removes a participant from the stream */
63
+ removeParticipant(pubkey) {
64
+ return this.chain(Stream.removeParticipant(pubkey));
65
+ }
66
+ /** Adds a relay to the stream's relay list */
67
+ addRelay(relay) {
68
+ return this.chain(Stream.addRelay(relay));
69
+ }
70
+ /** Removes a relay from the stream's relay list */
71
+ removeRelay(relay) {
72
+ return this.chain(Stream.removeRelay(relay));
73
+ }
74
+ /** Sets the pinned live chat message */
75
+ pinnedMessage(eventId) {
76
+ return this.chain(Stream.setPinnedMessage(eventId));
77
+ }
78
+ /** Removes the pinned live chat message */
79
+ removePinnedMessage() {
80
+ return this.chain(Stream.removePinnedMessage());
81
+ }
82
+ /** Adds a hashtag "t" tag to the stream */
83
+ addHashtag(hashtag) {
84
+ return this.chain(Stream.addHashtag(hashtag));
85
+ }
86
+ /** Removes a hashtag from the stream */
87
+ removeHashtag(hashtag) {
88
+ return this.chain(Stream.removeHashtag(hashtag));
89
+ }
90
+ }
@@ -0,0 +1,27 @@
1
+ import { kinds, KnownEvent, KnownEventTemplate, NostrEvent } from "applesauce-core/helpers";
2
+ import { EventPointer, ProfilePointer } from "applesauce-core/helpers/pointers";
3
+ import { NIP51UserListFactory } from "./list.js";
4
+ export type MuteListTemplate = KnownEventTemplate<kinds.Mutelist>;
5
+ /** A factory class for building kind 10000 mute list events */
6
+ export declare class MuteListFactory extends NIP51UserListFactory<kinds.Mutelist, MuteListTemplate> {
7
+ /** Creates a new mute list factory */
8
+ static create(): MuteListFactory;
9
+ /** Creates a new mute list factory from an existing mute list event */
10
+ static modify(event: NostrEvent | KnownEvent<kinds.Mutelist>): MuteListFactory;
11
+ /** Mutes a thread by event id or EventPointer */
12
+ muteThread(thread: string | NostrEvent | EventPointer, hidden?: boolean): this;
13
+ /** Unmutes a thread by event id or EventPointer */
14
+ unmuteThread(thread: string | EventPointer, hidden?: boolean): this;
15
+ /** Mutes a word */
16
+ muteWord(word: string, hidden?: boolean): this;
17
+ /** Unmutes a word */
18
+ unmuteWord(word: string, hidden?: boolean): this;
19
+ /** Mutes a hashtag */
20
+ muteHashtag(hashtag: string, hidden?: boolean): this;
21
+ /** Unmutes a hashtag */
22
+ unmuteHashtag(hashtag: string, hidden?: boolean): this;
23
+ /** Mutes a pubkey — semantic alias for addUser() */
24
+ mutePubkey(pubkey: string | ProfilePointer, hidden?: boolean): this;
25
+ /** Unmutes a pubkey — semantic alias for removeUser() */
26
+ unmutePubkey(pubkey: string | ProfilePointer, hidden?: boolean): this;
27
+ }
@@ -0,0 +1,57 @@
1
+ import { blankEventTemplate, toEventTemplate } from "applesauce-core/factories";
2
+ import { isKind, kinds } from "applesauce-core/helpers";
3
+ import { addEventPointerTag, addNameValueTag, removeEventPointerTag, removeNameValueTag, } from "applesauce-core/operations/tag/common";
4
+ import { NIP51UserListFactory } from "./list.js";
5
+ /** A factory class for building kind 10000 mute list events */
6
+ export class MuteListFactory extends NIP51UserListFactory {
7
+ /** Creates a new mute list factory */
8
+ static create() {
9
+ return new MuteListFactory((res) => res(blankEventTemplate(kinds.Mutelist)));
10
+ }
11
+ /** Creates a new mute list factory from an existing mute list event */
12
+ static modify(event) {
13
+ if (!isKind(event, kinds.Mutelist))
14
+ throw new Error("Event is not a mute list event");
15
+ return new MuteListFactory((res) => res(toEventTemplate(event)));
16
+ }
17
+ /** Mutes a thread by event id or EventPointer */
18
+ muteThread(thread, hidden = false) {
19
+ return hidden
20
+ ? this.modifyHiddenTags(addEventPointerTag(thread))
21
+ : this.modifyPublicTags(addEventPointerTag(thread));
22
+ }
23
+ /** Unmutes a thread by event id or EventPointer */
24
+ unmuteThread(thread, hidden = false) {
25
+ return hidden
26
+ ? this.modifyHiddenTags(removeEventPointerTag(thread))
27
+ : this.modifyPublicTags(removeEventPointerTag(thread));
28
+ }
29
+ /** Mutes a word */
30
+ muteWord(word, hidden = false) {
31
+ const op = addNameValueTag(["word", word.toLocaleLowerCase()], true);
32
+ return hidden ? this.modifyHiddenTags(op) : this.modifyPublicTags(op);
33
+ }
34
+ /** Unmutes a word */
35
+ unmuteWord(word, hidden = false) {
36
+ const op = removeNameValueTag(["word", word.toLocaleLowerCase()]);
37
+ return hidden ? this.modifyHiddenTags(op) : this.modifyPublicTags(op);
38
+ }
39
+ /** Mutes a hashtag */
40
+ muteHashtag(hashtag, hidden = false) {
41
+ const op = addNameValueTag(["t", hashtag.toLocaleLowerCase()], true);
42
+ return hidden ? this.modifyHiddenTags(op) : this.modifyPublicTags(op);
43
+ }
44
+ /** Unmutes a hashtag */
45
+ unmuteHashtag(hashtag, hidden = false) {
46
+ const op = removeNameValueTag(["t", hashtag.toLocaleLowerCase()]);
47
+ return hidden ? this.modifyHiddenTags(op) : this.modifyPublicTags(op);
48
+ }
49
+ /** Mutes a pubkey — semantic alias for addUser() */
50
+ mutePubkey(pubkey, hidden = false) {
51
+ return this.addUser(pubkey, hidden);
52
+ }
53
+ /** Unmutes a pubkey — semantic alias for removeUser() */
54
+ unmutePubkey(pubkey, hidden = false) {
55
+ return this.removeUser(pubkey, hidden);
56
+ }
57
+ }
@@ -0,0 +1,38 @@
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 { ProfilePointer } from "applesauce-core/helpers/pointers";
6
+ import { ZapOptions } from "../operations/zap-split.js";
7
+ export type NoteTemplate = KnownEventTemplate<kinds.ShortTextNote>;
8
+ export type NoteBlueprintOptions = TextContentOptions & MetaTagOptions & ZapOptions;
9
+ /** A factory class for building kind 1 short text note events */
10
+ export declare class NoteFactory extends EventFactory<kinds.ShortTextNote, NoteTemplate> {
11
+ /**
12
+ * Creates a new note factory
13
+ * @param content - Optional initial content
14
+ * @returns A new note factory
15
+ */
16
+ static create(content?: string): NoteFactory;
17
+ /**
18
+ * Creates a note reply factory
19
+ * @param parent - The parent note to reply to
20
+ * @param content - Optional initial content
21
+ * @returns A new note factory configured as a reply
22
+ */
23
+ static reply(parent: NostrEvent, content?: string): NoteFactory;
24
+ /** Sets the parent note for NIP-10 threading */
25
+ replyTo(parent: NostrEvent): this;
26
+ /** Sets the text content with optional formatting */
27
+ text(content: string, options?: TextContentOptions): this;
28
+ /** Adds a "p" mention tag for a pubkey or ProfilePointer */
29
+ mention(pubkey: string | ProfilePointer): this;
30
+ /** Sets the NIP-14 thread subject tag */
31
+ subject(subject: string): this;
32
+ /** Adds a hashtag "t" tag */
33
+ addHashtag(hashtag: string): this;
34
+ /** Adds multiple hashtags as "t" tags */
35
+ hashtags(tags: string[]): this;
36
+ /** Sets zap split configuration */
37
+ zapSplit(options: ZapOptions): this;
38
+ }
@@ -0,0 +1,66 @@
1
+ import { blankEventTemplate, EventFactory } from "applesauce-core/factories";
2
+ import { isKind, kinds, pipeFromAsyncArray } from "applesauce-core/helpers";
3
+ import { setShortTextContent } from "applesauce-core/operations/content";
4
+ import { includeNameValueTag } from "applesauce-core/operations/tags";
5
+ import { ensureProfilePointerTag } from "applesauce-core/helpers/factory";
6
+ import { includePubkeyNotificationTags, setThreadParent } from "../operations/note.js";
7
+ import { addHashtag, includeHashtags } from "../operations/hashtags.js";
8
+ import { setZapSplit } from "../operations/zap-split.js";
9
+ /** A factory class for building kind 1 short text note events */
10
+ export class NoteFactory extends EventFactory {
11
+ /**
12
+ * Creates a new note factory
13
+ * @param content - Optional initial content
14
+ * @returns A new note factory
15
+ */
16
+ static create(content) {
17
+ const factory = new NoteFactory((res) => res(blankEventTemplate(kinds.ShortTextNote)));
18
+ return content ? factory.text(content) : factory;
19
+ }
20
+ /**
21
+ * Creates a note reply factory
22
+ * @param parent - The parent note to reply to
23
+ * @param content - Optional initial content
24
+ * @returns A new note factory configured as a reply
25
+ */
26
+ static reply(parent, content) {
27
+ if (!isKind(parent, kinds.ShortTextNote))
28
+ throw new Error("Kind 1 replies should only be used to reply to kind 1 notes");
29
+ const factory = new NoteFactory((res) => res(blankEventTemplate(kinds.ShortTextNote))).replyTo(parent);
30
+ return content ? factory.text(content) : factory;
31
+ }
32
+ /** Sets the parent note for NIP-10 threading */
33
+ replyTo(parent) {
34
+ return this.chain(pipeFromAsyncArray([
35
+ // Add the "e" tags for the thread
36
+ setThreadParent(parent, undefined),
37
+ // Copy the "p" tags from the parent event
38
+ includePubkeyNotificationTags(parent, undefined),
39
+ ]));
40
+ }
41
+ /** Sets the text content with optional formatting */
42
+ text(content, options) {
43
+ return this.chain(setShortTextContent(content, options));
44
+ }
45
+ /** Adds a "p" mention tag for a pubkey or ProfilePointer */
46
+ mention(pubkey) {
47
+ const pointer = typeof pubkey === "string" ? { pubkey } : pubkey;
48
+ return this.modifyPublicTags((tags) => ensureProfilePointerTag(tags, pointer));
49
+ }
50
+ /** Sets the NIP-14 thread subject tag */
51
+ subject(subject) {
52
+ return this.chain(includeNameValueTag(["subject", subject]));
53
+ }
54
+ /** Adds a hashtag "t" tag */
55
+ addHashtag(hashtag) {
56
+ return this.chain(addHashtag(hashtag));
57
+ }
58
+ /** Adds multiple hashtags as "t" tags */
59
+ hashtags(tags) {
60
+ return this.chain(includeHashtags(tags));
61
+ }
62
+ /** Sets zap split configuration */
63
+ zapSplit(options) {
64
+ return this.chain(setZapSplit(options, undefined));
65
+ }
66
+ }
@@ -0,0 +1,28 @@
1
+ import { EventFactory } from "applesauce-core/factories";
2
+ import { KnownEventTemplate } from "applesauce-core/helpers";
3
+ import { TextContentOptions } from "applesauce-core/operations/content";
4
+ import { MetaTagOptions } from "applesauce-core/operations/event";
5
+ import { FileMetadataFields } from "../helpers/file-metadata.js";
6
+ import { PICTURE_POST_KIND } from "../helpers/picture-post.js";
7
+ export type PicturePostTemplate = KnownEventTemplate<typeof PICTURE_POST_KIND>;
8
+ /** A factory class for building kind 20 picture post events */
9
+ export declare class PicturePostFactory extends EventFactory<typeof PICTURE_POST_KIND, PicturePostTemplate> {
10
+ /**
11
+ * Creates a new picture post factory
12
+ * @param attachments - One or more image attachments
13
+ * @param caption - Optional caption text
14
+ */
15
+ static create(attachments: FileMetadataFields | FileMetadataFields[], caption?: string): PicturePostFactory;
16
+ /** Adds image attachments via "imeta" tags */
17
+ attachments(attachments: FileMetadataFields[]): this;
18
+ /** Sets the image metadata (x/m tags) for the post */
19
+ imageMetadata(pictures: FileMetadataFields[]): this;
20
+ /** Sets the caption/content of the picture post */
21
+ caption(text: string, options?: TextContentOptions): this;
22
+ /** Adds a hashtag "t" tag to the post */
23
+ addHashtag(hashtag: string): this;
24
+ /** Adds multiple hashtags as "t" tags */
25
+ hashtags(tags: string[]): this;
26
+ /** Sets meta tags */
27
+ meta(options: MetaTagOptions): this;
28
+ }
@@ -0,0 +1,46 @@
1
+ import { EventFactory, blankEventTemplate } from "applesauce-core/factories";
2
+ import { setShortTextContent } from "applesauce-core/operations/content";
3
+ import { setMetaTags } from "applesauce-core/operations/event";
4
+ import { PICTURE_POST_KIND } from "../helpers/picture-post.js";
5
+ import { setImageMetadata } from "../operations/picture-post.js";
6
+ import { addMediaAttachments } from "../operations/media-attachment.js";
7
+ import { addHashtag, includeHashtags } from "../operations/hashtags.js";
8
+ /** A factory class for building kind 20 picture post events */
9
+ export class PicturePostFactory extends EventFactory {
10
+ /**
11
+ * Creates a new picture post factory
12
+ * @param attachments - One or more image attachments
13
+ * @param caption - Optional caption text
14
+ */
15
+ static create(attachments, caption) {
16
+ const list = Array.isArray(attachments) ? attachments : [attachments];
17
+ let factory = new PicturePostFactory((res) => res(blankEventTemplate(PICTURE_POST_KIND))).attachments(list);
18
+ if (caption)
19
+ factory = factory.caption(caption);
20
+ return factory;
21
+ }
22
+ /** Adds image attachments via "imeta" tags */
23
+ attachments(attachments) {
24
+ return this.chain(addMediaAttachments(attachments));
25
+ }
26
+ /** Sets the image metadata (x/m tags) for the post */
27
+ imageMetadata(pictures) {
28
+ return this.chain(setImageMetadata(pictures));
29
+ }
30
+ /** Sets the caption/content of the picture post */
31
+ caption(text, options) {
32
+ return this.chain(setShortTextContent(text, options));
33
+ }
34
+ /** Adds a hashtag "t" tag to the post */
35
+ addHashtag(hashtag) {
36
+ return this.chain(addHashtag(hashtag));
37
+ }
38
+ /** Adds multiple hashtags as "t" tags */
39
+ hashtags(tags) {
40
+ return this.chain(includeHashtags(tags));
41
+ }
42
+ /** Sets meta tags */
43
+ meta(options) {
44
+ return this.chain(setMetaTags(options));
45
+ }
46
+ }
@@ -0,0 +1,14 @@
1
+ import { kinds, KnownEvent, KnownEventTemplate, NostrEvent } from "applesauce-core/helpers";
2
+ import { NIP51ItemListFactory } from "./list.js";
3
+ export type PinListTemplate = KnownEventTemplate<kinds.Pinlist>;
4
+ /** A factory class for building kind 10001 pin list events */
5
+ export declare class PinListFactory extends NIP51ItemListFactory<kinds.Pinlist, PinListTemplate> {
6
+ /** Creates a new pin list factory */
7
+ static create(): PinListFactory;
8
+ /** Creates a new pin list factory from an existing pin list event */
9
+ static modify(event: NostrEvent | KnownEvent<kinds.Pinlist>): PinListFactory;
10
+ /** Pins an event — uses an "a" tag for replaceable events, "e" tag for others */
11
+ pinEvent(event: NostrEvent, hidden?: boolean): this;
12
+ /** Unpins an event — uses an "a" tag for replaceable events, "e" tag for others */
13
+ unpinEvent(event: NostrEvent, hidden?: boolean): this;
14
+ }
@@ -0,0 +1,24 @@
1
+ import { blankEventTemplate, toEventTemplate } from "applesauce-core/factories";
2
+ import { isKind, isReplaceable, kinds } from "applesauce-core/helpers";
3
+ import { NIP51ItemListFactory } from "./list.js";
4
+ /** A factory class for building kind 10001 pin list events */
5
+ export class PinListFactory extends NIP51ItemListFactory {
6
+ /** Creates a new pin list factory */
7
+ static create() {
8
+ return new PinListFactory((res) => res(blankEventTemplate(kinds.Pinlist)));
9
+ }
10
+ /** Creates a new pin list factory from an existing pin list event */
11
+ static modify(event) {
12
+ if (!isKind(event, kinds.Pinlist))
13
+ throw new Error("Event is not a pin list event");
14
+ return new PinListFactory((res) => res(toEventTemplate(event)));
15
+ }
16
+ /** Pins an event — uses an "a" tag for replaceable events, "e" tag for others */
17
+ pinEvent(event, hidden = false) {
18
+ return isReplaceable(event.kind) ? this.addAddressItem(event, hidden) : this.addEventItem(event, hidden);
19
+ }
20
+ /** Unpins an event — uses an "a" tag for replaceable events, "e" tag for others */
21
+ unpinEvent(event, hidden = false) {
22
+ return isReplaceable(event.kind) ? this.removeAddressItem(event, hidden) : this.removeEventItem(event.id, hidden);
23
+ }
24
+ }
@@ -0,0 +1,36 @@
1
+ import { EventFactory } from "applesauce-core/factories";
2
+ import { KnownEventTemplate, NostrEvent } from "applesauce-core/helpers";
3
+ import { EventPointer } from "applesauce-core/helpers/pointers";
4
+ import { MetaTagOptions } from "applesauce-core/operations/event";
5
+ import { POLL_RESPONSE_KIND } from "../helpers/poll.js";
6
+ export type PollResponseTemplate = KnownEventTemplate<typeof POLL_RESPONSE_KIND>;
7
+ export type PollResponseBlueprintOptions = MetaTagOptions & {
8
+ comment?: string;
9
+ };
10
+ /** A factory class for building NIP-88 poll response events (kind 1018) */
11
+ export declare class PollResponseFactory extends EventFactory<typeof POLL_RESPONSE_KIND, PollResponseTemplate> {
12
+ /**
13
+ * Creates a new poll response factory for multiple choices
14
+ * @param poll - The poll event, pointer, or ID
15
+ * @param optionIds - The selected option IDs
16
+ * @returns A new poll response factory
17
+ */
18
+ static create(poll: NostrEvent | EventPointer | string, optionIds: string[]): PollResponseFactory;
19
+ /**
20
+ * Creates a new poll response for a single choice
21
+ * @param poll - The poll event, pointer, or ID
22
+ * @param optionId - The selected option ID
23
+ * @returns A new poll response factory
24
+ */
25
+ static single(poll: NostrEvent | EventPointer | string, optionId: string): PollResponseFactory;
26
+ /** Sets the poll being responded to */
27
+ poll(poll: NostrEvent | EventPointer | string): this;
28
+ /** Sets multiple choice selections */
29
+ choices(optionIds: string[]): this;
30
+ /** Sets a single choice selection */
31
+ choice(optionId: string): this;
32
+ /** Sets an optional comment */
33
+ comment(comment: string): this;
34
+ /** Sets meta tags */
35
+ meta(options: MetaTagOptions): this;
36
+ }
@@ -0,0 +1,46 @@
1
+ import { EventFactory, blankEventTemplate } from "applesauce-core/factories";
2
+ import { setContent } from "applesauce-core/operations/content";
3
+ import { setMetaTags } from "applesauce-core/operations/event";
4
+ import { POLL_RESPONSE_KIND } from "../helpers/poll.js";
5
+ import * as PollResponse from "../operations/poll-response.js";
6
+ /** A factory class for building NIP-88 poll response events (kind 1018) */
7
+ export class PollResponseFactory extends EventFactory {
8
+ /**
9
+ * Creates a new poll response factory for multiple choices
10
+ * @param poll - The poll event, pointer, or ID
11
+ * @param optionIds - The selected option IDs
12
+ * @returns A new poll response factory
13
+ */
14
+ static create(poll, optionIds) {
15
+ return new PollResponseFactory((res) => res(blankEventTemplate(POLL_RESPONSE_KIND))).poll(poll).choices(optionIds);
16
+ }
17
+ /**
18
+ * Creates a new poll response for a single choice
19
+ * @param poll - The poll event, pointer, or ID
20
+ * @param optionId - The selected option ID
21
+ * @returns A new poll response factory
22
+ */
23
+ static single(poll, optionId) {
24
+ return new PollResponseFactory((res) => res(blankEventTemplate(POLL_RESPONSE_KIND))).poll(poll).choice(optionId);
25
+ }
26
+ /** Sets the poll being responded to */
27
+ poll(poll) {
28
+ return this.chain((draft) => PollResponse.setPollEvent(poll)(draft));
29
+ }
30
+ /** Sets multiple choice selections */
31
+ choices(optionIds) {
32
+ return this.chain((draft) => PollResponse.setChoices(optionIds)(draft));
33
+ }
34
+ /** Sets a single choice selection */
35
+ choice(optionId) {
36
+ return this.chain((draft) => PollResponse.setChoice(optionId)(draft));
37
+ }
38
+ /** Sets an optional comment */
39
+ comment(comment) {
40
+ return this.chain((draft) => setContent(comment)(draft));
41
+ }
42
+ /** Sets meta tags */
43
+ meta(options) {
44
+ return this.chain((draft) => setMetaTags(options)(draft));
45
+ }
46
+ }
@@ -0,0 +1,35 @@
1
+ import { EventFactory } from "applesauce-core/factories";
2
+ import { KnownEventTemplate } from "applesauce-core/helpers";
3
+ import { POLL_KIND, PollType } from "../helpers/poll.js";
4
+ import { ZapOptions } from "../operations/zap-split.js";
5
+ export interface PollOption {
6
+ id: string;
7
+ label: string;
8
+ }
9
+ export type PollTemplate = KnownEventTemplate<typeof POLL_KIND>;
10
+ /** A factory class for building NIP-88 poll events (kind 1068) */
11
+ export declare class PollFactory extends EventFactory<typeof POLL_KIND, PollTemplate> {
12
+ /**
13
+ * Creates a new poll factory
14
+ * @param question - The poll question
15
+ * @param options - The poll options
16
+ * @returns A new poll factory
17
+ */
18
+ static create(question: string, options: PollOption[]): PollFactory;
19
+ /** Sets the poll question */
20
+ question(question: string): this;
21
+ /** Sets the poll options */
22
+ options(options: PollOption[]): this;
23
+ /** Sets the poll type (singlechoice or multiplechoice) */
24
+ pollType(type: PollType): this;
25
+ /** Sets when the poll ends */
26
+ endsAt(timestamp: number): this;
27
+ /** Adds a single option to the poll */
28
+ addOption(id: string, label: string): this;
29
+ /** Sets relay URLs where responses should be published */
30
+ relays(urls: string[]): this;
31
+ /** Adds a single relay URL where responses should be published */
32
+ addRelay(url: string): this;
33
+ /** Sets zap split configuration */
34
+ zapSplit(options: ZapOptions): this;
35
+ }
@@ -0,0 +1,48 @@
1
+ import { blankEventTemplate, EventFactory } from "applesauce-core/factories";
2
+ import { POLL_KIND } from "../helpers/poll.js";
3
+ import * as Poll from "../operations/poll.js";
4
+ import { setZapSplit } from "../operations/zap-split.js";
5
+ /** A factory class for building NIP-88 poll events (kind 1068) */
6
+ export class PollFactory extends EventFactory {
7
+ /**
8
+ * Creates a new poll factory
9
+ * @param question - The poll question
10
+ * @param options - The poll options
11
+ * @returns A new poll factory
12
+ */
13
+ static create(question, options) {
14
+ return new PollFactory((res) => res(blankEventTemplate(POLL_KIND))).question(question).options(options);
15
+ }
16
+ /** Sets the poll question */
17
+ question(question) {
18
+ return this.chain((draft) => Poll.setQuestion(question)(draft));
19
+ }
20
+ /** Sets the poll options */
21
+ options(options) {
22
+ return this.chain((draft) => Poll.setOptions(options)(draft));
23
+ }
24
+ /** Sets the poll type (singlechoice or multiplechoice) */
25
+ pollType(type) {
26
+ return this.chain((draft) => Poll.setType(type)(draft));
27
+ }
28
+ /** Sets when the poll ends */
29
+ endsAt(timestamp) {
30
+ return this.chain((draft) => Poll.setEndsAt(timestamp)(draft));
31
+ }
32
+ /** Adds a single option to the poll */
33
+ addOption(id, label) {
34
+ return this.chain((draft) => Poll.addOption(id, label)(draft));
35
+ }
36
+ /** Sets relay URLs where responses should be published */
37
+ relays(urls) {
38
+ return this.chain((draft) => Poll.setRelays(urls)(draft));
39
+ }
40
+ /** Adds a single relay URL where responses should be published */
41
+ addRelay(url) {
42
+ return this.chain((draft) => Poll.addRelay(url)(draft));
43
+ }
44
+ /** Sets zap split configuration */
45
+ zapSplit(options) {
46
+ return this.chain((draft) => setZapSplit(options, undefined)(draft));
47
+ }
48
+ }
@@ -0,0 +1,31 @@
1
+ import { EventFactory } from "applesauce-core/factories";
2
+ import { KnownEventTemplate, NostrEvent } from "applesauce-core/helpers";
3
+ import { PROFILE_BADGES_KIND } from "../helpers/profile-badges.js";
4
+ import type { ProfileBadgeSlotInput } from "../operations/profile-badges.js";
5
+ import { removeSlotByAward, removeSlotByBadge } from "../operations/profile-badges.js";
6
+ export type ProfileBadgesTemplate = KnownEventTemplate<typeof PROFILE_BADGES_KIND>;
7
+ /** Factory for profile badges events (kind 10008) */
8
+ export declare class ProfileBadgesFactory extends EventFactory<typeof PROFILE_BADGES_KIND, ProfileBadgesTemplate> {
9
+ /** Creates a profile badges factory */
10
+ static create(): ProfileBadgesFactory;
11
+ /** Creates a factory configured to modify an existing profile badge event */
12
+ static modify(event: NostrEvent): ProfileBadgesFactory;
13
+ /** Replaces all slots */
14
+ slots(slots: Array<ProfileBadgeSlotInput>): this;
15
+ /** Adds a single slot to the end */
16
+ addSlot(slot: ProfileBadgeSlotInput): this;
17
+ /** Inserts a slot at a specific position */
18
+ insertSlot(index: number, slot: ProfileBadgeSlotInput): this;
19
+ /** Inserts a slot at the beginning */
20
+ prependSlot(slot: ProfileBadgeSlotInput): this;
21
+ /** Inserts a slot at the end */
22
+ appendSlot(slot: ProfileBadgeSlotInput): this;
23
+ /** Replaces the slot at a specific position */
24
+ setSlot(index: number, slot: ProfileBadgeSlotInput): this;
25
+ /** Removes every slot */
26
+ clearSlots(): this;
27
+ /** Removes the slot tied to a badge definition */
28
+ removeByBadge(badge: Parameters<typeof removeSlotByBadge>[0]): this;
29
+ /** Removes the slot tied to an award event */
30
+ removeByAward(award: Parameters<typeof removeSlotByAward>[0]): this;
31
+ }