applesauce-common 5.1.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 (265) 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 -38
  35. package/dist/casts/user.js +106 -153
  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 +4 -5
  131. package/dist/helpers/emoji.js +3 -15
  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/models/thread.d.ts +1 -1
  154. package/dist/models/thread.js +23 -7
  155. package/dist/observable/chainable.d.ts +1 -36
  156. package/dist/observable/chainable.js +2 -72
  157. package/dist/operations/app-data.d.ts +8 -3
  158. package/dist/operations/app-data.js +9 -4
  159. package/dist/operations/badge-award.d.ts +17 -0
  160. package/dist/operations/badge-award.js +30 -0
  161. package/dist/operations/badge.d.ts +22 -0
  162. package/dist/operations/badge.js +54 -0
  163. package/dist/operations/blossom.d.ts +1 -1
  164. package/dist/operations/calendar-event.d.ts +1 -1
  165. package/dist/operations/calendar-rsvp.d.ts +1 -1
  166. package/dist/operations/calendar.d.ts +1 -1
  167. package/dist/operations/channel.d.ts +1 -1
  168. package/dist/operations/client.d.ts +1 -1
  169. package/dist/operations/client.js +2 -2
  170. package/dist/operations/code-snippet.d.ts +27 -0
  171. package/dist/operations/code-snippet.js +63 -0
  172. package/dist/operations/comment.d.ts +7 -3
  173. package/dist/operations/comment.js +8 -4
  174. package/dist/operations/file-metadata.d.ts +38 -4
  175. package/dist/operations/file-metadata.js +105 -19
  176. package/dist/operations/geohash.d.ts +1 -1
  177. package/dist/operations/gift-wrap.d.ts +19 -7
  178. package/dist/operations/gift-wrap.js +36 -26
  179. package/dist/operations/group.d.ts +1 -1
  180. package/dist/operations/hashtags.d.ts +1 -1
  181. package/dist/operations/highlight.d.ts +1 -1
  182. package/dist/operations/highlight.js +5 -5
  183. package/dist/operations/index.d.ts +7 -1
  184. package/dist/operations/index.js +7 -1
  185. package/dist/operations/legacy-message.d.ts +1 -1
  186. package/dist/operations/list.d.ts +1 -1
  187. package/dist/operations/live-stream.d.ts +7 -3
  188. package/dist/operations/live-stream.js +9 -5
  189. package/dist/operations/media-attachment.d.ts +3 -3
  190. package/dist/operations/note.d.ts +10 -4
  191. package/dist/operations/note.js +14 -8
  192. package/dist/operations/picture-post.d.ts +1 -1
  193. package/dist/operations/poll-response.d.ts +1 -1
  194. package/dist/operations/poll-response.js +1 -1
  195. package/dist/operations/poll.d.ts +1 -1
  196. package/dist/operations/profile-badges.d.ts +26 -0
  197. package/dist/operations/profile-badges.js +150 -0
  198. package/dist/operations/reaction.d.ts +8 -3
  199. package/dist/operations/reaction.js +10 -5
  200. package/dist/operations/share.d.ts +8 -3
  201. package/dist/operations/share.js +10 -5
  202. package/dist/operations/stream.d.ts +1 -1
  203. package/dist/operations/tag/bookmarks.d.ts +1 -1
  204. package/dist/operations/torrent.d.ts +1 -1
  205. package/dist/operations/wrapped-message.d.ts +1 -1
  206. package/dist/operations/zap-goal.d.ts +1 -1
  207. package/dist/operations/zap-request.d.ts +22 -0
  208. package/dist/operations/zap-request.js +40 -0
  209. package/dist/operations/zap-split.d.ts +8 -4
  210. package/dist/operations/zap-split.js +10 -6
  211. package/dist/operations/zap.d.ts +12 -0
  212. package/dist/operations/zap.js +34 -0
  213. package/package.json +13 -12
  214. package/dist/blueprints/__register__.d.ts +0 -7
  215. package/dist/blueprints/__register__.js +0 -8
  216. package/dist/blueprints/app-data.d.ts +0 -5
  217. package/dist/blueprints/app-data.js +0 -10
  218. package/dist/blueprints/calendar.d.ts +0 -5
  219. package/dist/blueprints/calendar.js +0 -7
  220. package/dist/blueprints/channels.d.ts +0 -6
  221. package/dist/blueprints/channels.js +0 -13
  222. package/dist/blueprints/comment.d.ts +0 -13
  223. package/dist/blueprints/comment.js +0 -15
  224. package/dist/blueprints/delete.d.ts +0 -9
  225. package/dist/blueprints/delete.js +0 -14
  226. package/dist/blueprints/file-metadata.d.ts +0 -8
  227. package/dist/blueprints/file-metadata.js +0 -11
  228. package/dist/blueprints/follow-set.d.ts +0 -11
  229. package/dist/blueprints/follow-set.js +0 -21
  230. package/dist/blueprints/gift-wrap.d.ts +0 -5
  231. package/dist/blueprints/gift-wrap.js +0 -6
  232. package/dist/blueprints/group-mangement.d.ts +0 -25
  233. package/dist/blueprints/group-mangement.js +0 -40
  234. package/dist/blueprints/group.d.ts +0 -9
  235. package/dist/blueprints/group.js +0 -17
  236. package/dist/blueprints/highlight.d.ts +0 -20
  237. package/dist/blueprints/highlight.js +0 -12
  238. package/dist/blueprints/index.d.ts +0 -25
  239. package/dist/blueprints/index.js +0 -26
  240. package/dist/blueprints/legacy-message.d.ts +0 -7
  241. package/dist/blueprints/legacy-message.js +0 -29
  242. package/dist/blueprints/live-stream.d.ts +0 -6
  243. package/dist/blueprints/live-stream.js +0 -9
  244. package/dist/blueprints/note.d.ts +0 -16
  245. package/dist/blueprints/note.js +0 -30
  246. package/dist/blueprints/picture-post.d.ts +0 -12
  247. package/dist/blueprints/picture-post.js +0 -17
  248. package/dist/blueprints/poll.d.ts +0 -41
  249. package/dist/blueprints/poll.js +0 -33
  250. package/dist/blueprints/profile.d.ts +0 -3
  251. package/dist/blueprints/profile.js +0 -7
  252. package/dist/blueprints/reaction.d.ts +0 -10
  253. package/dist/blueprints/reaction.js +0 -14
  254. package/dist/blueprints/share.d.ts +0 -12
  255. package/dist/blueprints/share.js +0 -25
  256. package/dist/blueprints/stream.d.ts +0 -6
  257. package/dist/blueprints/stream.js +0 -7
  258. package/dist/blueprints/torrent.d.ts +0 -30
  259. package/dist/blueprints/torrent.js +0 -29
  260. package/dist/blueprints/wrapped-message.d.ts +0 -20
  261. package/dist/blueprints/wrapped-message.js +0 -64
  262. package/dist/blueprints/zap-goal.d.ts +0 -16
  263. package/dist/blueprints/zap-goal.js +0 -12
  264. package/dist/register.d.ts +0 -2
  265. package/dist/register.js +0 -4
@@ -0,0 +1,49 @@
1
+ import { blankEventTemplate, EventFactory } from "applesauce-core/factories";
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 { setGroupPointer } from "../operations/group.js";
7
+ import { addHashtag, includeHashtags } from "../operations/hashtags.js";
8
+ export class CommentFactory extends EventFactory {
9
+ /** Creates a new comment event */
10
+ static create(parent, content, options) {
11
+ let factory = new CommentFactory((res) => res(blankEventTemplate(COMMENT_KIND)))
12
+ .parent(parent)
13
+ .text(content, options);
14
+ if (options)
15
+ factory = factory.meta(options);
16
+ return factory;
17
+ }
18
+ /** Creates a new comment that is replying to a parent event or pointer */
19
+ static reply(parent, content, options) {
20
+ let factory = new CommentFactory((res) => res(blankEventTemplate(COMMENT_KIND))).parent(parent).text(content);
21
+ if (options)
22
+ factory = factory.meta(options);
23
+ return factory;
24
+ }
25
+ /** Sets the parent event or pointer that this comment is replying to */
26
+ parent(parent) {
27
+ return this.chain(setParent(parent));
28
+ }
29
+ /** Sets the text content of the comment */
30
+ text(content, options) {
31
+ return this.chain(setShortTextContent(content, options));
32
+ }
33
+ /** Sets the NIP-29 group pointer "h" tag for this comment */
34
+ group(pointer) {
35
+ return this.chain(setGroupPointer(pointer));
36
+ }
37
+ /** Adds a hashtag "t" tag to the comment */
38
+ addHashtag(hashtag) {
39
+ return this.chain(addHashtag(hashtag));
40
+ }
41
+ /** Adds multiple hashtags as "t" tags */
42
+ hashtags(tags) {
43
+ return this.chain(includeHashtags(tags));
44
+ }
45
+ /** Sets the meta tags for the comment */
46
+ meta(options) {
47
+ return this.chain(setMetaTags(options));
48
+ }
49
+ }
@@ -0,0 +1,19 @@
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
+ export type ContactsTemplate = KnownEventTemplate<kinds.Contacts>;
5
+ /** A factory class for building kind 3 contacts events */
6
+ export declare class ContactsFactory extends EventFactory<kinds.Contacts, ContactsTemplate> {
7
+ /** Creates a new contacts factory */
8
+ static create(): ContactsFactory;
9
+ /** Creates a new contacts factory from an existing contacts event */
10
+ static modify(event: NostrEvent | KnownEvent<kinds.Contacts>): ContactsFactory;
11
+ /**
12
+ * Adds or replaces a contact "p" tag.
13
+ * @param pointer - Pubkey string or ProfilePointer (relay hint taken from pointer.relays[0])
14
+ * @param petname - Optional NIP-02 petname stored as the fourth tag field
15
+ */
16
+ addContact(pointer: string | ProfilePointer, petname?: string): this;
17
+ /** Removes a contact "p" tag by pubkey */
18
+ removeContact(pointer: string | ProfilePointer): this;
19
+ }
@@ -0,0 +1,36 @@
1
+ import { blankEventTemplate, EventFactory, toEventTemplate } from "applesauce-core/factories";
2
+ import { isKind, kinds } from "applesauce-core/helpers";
3
+ import { fillAndTrimTag } from "applesauce-core/helpers/tags";
4
+ import { addProfilePointerTag, removeProfilePointerTag } from "applesauce-core/operations/tag/common";
5
+ /** A factory class for building kind 3 contacts events */
6
+ export class ContactsFactory extends EventFactory {
7
+ /** Creates a new contacts factory */
8
+ static create() {
9
+ return new ContactsFactory((res) => res(blankEventTemplate(kinds.Contacts)));
10
+ }
11
+ /** Creates a new contacts factory from an existing contacts event */
12
+ static modify(event) {
13
+ if (!isKind(event, kinds.Contacts))
14
+ throw new Error("Event is not a contacts event");
15
+ return new ContactsFactory((res) => res(toEventTemplate(event)));
16
+ }
17
+ /**
18
+ * Adds or replaces a contact "p" tag.
19
+ * @param pointer - Pubkey string or ProfilePointer (relay hint taken from pointer.relays[0])
20
+ * @param petname - Optional NIP-02 petname stored as the fourth tag field
21
+ */
22
+ addContact(pointer, petname) {
23
+ if (!petname)
24
+ return this.modifyPublicTags(addProfilePointerTag(pointer));
25
+ const pubkey = typeof pointer === "string" ? pointer : pointer.pubkey;
26
+ const relay = typeof pointer === "object" ? pointer.relays?.[0] : undefined;
27
+ return this.modifyPublicTags((tags) => {
28
+ const filtered = tags.filter((t) => !(t[0] === "p" && t[1] === pubkey));
29
+ return [...filtered, fillAndTrimTag(["p", pubkey, relay, petname])];
30
+ });
31
+ }
32
+ /** Removes a contact "p" tag by pubkey */
33
+ removeContact(pointer) {
34
+ return this.modifyPublicTags(removeProfilePointerTag(pointer));
35
+ }
36
+ }
@@ -0,0 +1,10 @@
1
+ import { kinds, KnownEvent, KnownEventTemplate, NostrEvent } from "applesauce-core/helpers";
2
+ import { NIP51RelayListFactory } from "./list.js";
3
+ export type DmRelaysTemplate = KnownEventTemplate<kinds.DirectMessageRelaysList>;
4
+ /** A factory class for building kind 10050 direct message relays list events */
5
+ export declare class DmRelaysFactory extends NIP51RelayListFactory<kinds.DirectMessageRelaysList, DmRelaysTemplate> {
6
+ /** Creates a new DM relays factory */
7
+ static create(): DmRelaysFactory;
8
+ /** Creates a new DM relays factory from an existing DM relays event */
9
+ static modify(event: NostrEvent | KnownEvent<kinds.DirectMessageRelaysList>): DmRelaysFactory;
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 10050 direct message relays list events */
5
+ export class DmRelaysFactory extends NIP51RelayListFactory {
6
+ /** Creates a new DM relays factory */
7
+ static create() {
8
+ return new DmRelaysFactory((res) => res(blankEventTemplate(kinds.DirectMessageRelaysList)));
9
+ }
10
+ /** Creates a new DM relays factory from an existing DM relays event */
11
+ static modify(event) {
12
+ if (!isKind(event, kinds.DirectMessageRelaysList))
13
+ throw new Error("Event is not a DM relays event");
14
+ return new DmRelaysFactory((res) => res(toEventTemplate(event)));
15
+ }
16
+ }
@@ -0,0 +1,16 @@
1
+ import { KnownEvent, KnownEventTemplate, NostrEvent } from "applesauce-core/helpers";
2
+ import { AddressPointer } from "applesauce-core/helpers/pointers";
3
+ import { FAVORITE_RELAYS_KIND } from "../helpers/relay-list.js";
4
+ import { NIP51RelayListFactory } from "./list.js";
5
+ export type FavoriteRelaysTemplate = KnownEventTemplate<typeof FAVORITE_RELAYS_KIND>;
6
+ /** A factory class for building kind 10012 favorite relays list events */
7
+ export declare class FavoriteRelaysFactory extends NIP51RelayListFactory<typeof FAVORITE_RELAYS_KIND, FavoriteRelaysTemplate> {
8
+ /** Creates a new favorite relays factory */
9
+ static create(): FavoriteRelaysFactory;
10
+ /** Creates a new favorite relays factory from an existing favorite relays event */
11
+ static modify(event: NostrEvent | KnownEvent<typeof FAVORITE_RELAYS_KIND>): FavoriteRelaysFactory;
12
+ /** Adds a relay set (address pointer) to the favorite relays event */
13
+ addRelaySet(addr: AddressPointer | AddressPointer[], hidden?: boolean): this;
14
+ /** Removes a relay set (address pointer) from the favorite relays event */
15
+ removeRelaySet(addr: AddressPointer | AddressPointer[], hidden?: boolean): this;
16
+ }
@@ -0,0 +1,31 @@
1
+ import { blankEventTemplate, toEventTemplate } from "applesauce-core/factories";
2
+ import { addAddressPointerTag, removeAddressPointerTag } from "applesauce-core/operations/tag/common";
3
+ import { FAVORITE_RELAYS_KIND } from "../helpers/relay-list.js";
4
+ import { NIP51RelayListFactory } from "./list.js";
5
+ /** A factory class for building kind 10012 favorite relays list events */
6
+ export class FavoriteRelaysFactory extends NIP51RelayListFactory {
7
+ /** Creates a new favorite relays factory */
8
+ static create() {
9
+ return new FavoriteRelaysFactory((res) => res(blankEventTemplate(FAVORITE_RELAYS_KIND)));
10
+ }
11
+ /** Creates a new favorite relays factory from an existing favorite relays event */
12
+ static modify(event) {
13
+ if (event.kind !== FAVORITE_RELAYS_KIND)
14
+ throw new Error("Event is not a favorite relays event");
15
+ return new FavoriteRelaysFactory((res) => res(toEventTemplate(event)));
16
+ }
17
+ /** Adds a relay set (address pointer) to the favorite relays event */
18
+ addRelaySet(addr, hidden = false) {
19
+ const addrs = Array.isArray(addr) ? addr : [addr];
20
+ return hidden
21
+ ? this.modifyHiddenTags(...addrs.map((a) => addAddressPointerTag(a)))
22
+ : this.modifyPublicTags(...addrs.map((a) => addAddressPointerTag(a)));
23
+ }
24
+ /** Removes a relay set (address pointer) from the favorite relays event */
25
+ removeRelaySet(addr, hidden = false) {
26
+ const addrs = Array.isArray(addr) ? addr : [addr];
27
+ return hidden
28
+ ? this.modifyHiddenTags(...addrs.map((a) => removeAddressPointerTag(a)))
29
+ : this.modifyPublicTags(...addrs.map((a) => removeAddressPointerTag(a)));
30
+ }
31
+ }
@@ -0,0 +1,54 @@
1
+ import { EventFactory } from "applesauce-core/factories";
2
+ import { KnownEventTemplate } from "applesauce-core/helpers";
3
+ import { FileMetadataFields } from "../helpers/file-metadata.js";
4
+ export type FileMetadataTemplate = KnownEventTemplate<1063>;
5
+ export type FileMetadataUploadResult = {
6
+ url: string;
7
+ sha256: string;
8
+ size?: number;
9
+ type?: string;
10
+ };
11
+ export type FileMetadataUploader = (file: File) => Promise<FileMetadataUploadResult> | FileMetadataUploadResult;
12
+ /** A factory class for building kind 1063 file metadata events */
13
+ export declare class FileMetadataFactory extends EventFactory<1063, FileMetadataTemplate> {
14
+ /** Creates a new file metadata factory */
15
+ static create(metadata?: FileMetadataFields): FileMetadataFactory;
16
+ /** Uploads a file and creates a kind 1063 template from the result */
17
+ static fromUpload(file: File, uploader: FileMetadataUploader): Promise<FileMetadataTemplate>;
18
+ /** Sets multiple file metadata fields */
19
+ metadata(fields: FileMetadataFields): this;
20
+ /** Sets or removes the file URL */
21
+ url(value: string | null): this;
22
+ /** Sets or removes the MIME type */
23
+ type(value: string | null): this;
24
+ /** Sets or removes the SHA-256 hash */
25
+ sha256(value: string | null): this;
26
+ /** Sets or removes the original SHA-256 hash */
27
+ originalSha256(value: string | null): this;
28
+ /** Sets or removes the file size */
29
+ size(value: number | null): this;
30
+ /** Sets or removes the dimensions */
31
+ dimensions(value: string | null): this;
32
+ /** Sets or removes the magnet URI */
33
+ magnet(value: string | null): this;
34
+ /** Sets or removes the infohash */
35
+ infohash(value: string | null): this;
36
+ /** Sets or removes the thumbnail URL */
37
+ thumbnail(value: string | null): this;
38
+ /** Sets or removes the preview image URL */
39
+ image(value: string | null): this;
40
+ /** Sets or removes the summary */
41
+ summary(value: string | null): this;
42
+ /** Sets or removes the alt text */
43
+ alt(value: string | null): this;
44
+ /** Sets or removes the blurhash */
45
+ blurhash(value: string | null): this;
46
+ /** Adds a fallback URL */
47
+ addFallbackURL(url: string, replace?: boolean): this;
48
+ /** Removes a fallback URL */
49
+ removeFallbackURL(url: string): this;
50
+ /** Removes all fallback URLs */
51
+ clearFallbackURLs(): this;
52
+ /** Replaces all fallback URLs */
53
+ fallbackURLs(urls: string[]): this;
54
+ }
@@ -0,0 +1,92 @@
1
+ import { blankEventTemplate, EventFactory } from "applesauce-core/factories";
2
+ import { addFallbackURL, clearFallbackURLs, removeFallbackURL, setFallbackURLs, setFileAlt, setFileBlurhash, setFileDimensions, setFileImage, setFileInfohash, setFileMagnet, setFileMetadata, setOriginalFileSHA256, setFileSHA256, setFileSize, setFileSummary, setFileThumbnail, setFileType, setFileURL, } from "../operations/file-metadata.js";
3
+ /** A factory class for building kind 1063 file metadata events */
4
+ export class FileMetadataFactory extends EventFactory {
5
+ /** Creates a new file metadata factory */
6
+ static create(metadata) {
7
+ const factory = new FileMetadataFactory((res) => res(blankEventTemplate(1063)));
8
+ return metadata ? factory.metadata(metadata) : factory;
9
+ }
10
+ /** Uploads a file and creates a kind 1063 template from the result */
11
+ static async fromUpload(file, uploader) {
12
+ const uploaded = await uploader(file);
13
+ return FileMetadataFactory.create({
14
+ url: uploaded.url,
15
+ sha256: uploaded.sha256,
16
+ size: uploaded.size ?? file.size,
17
+ type: (uploaded.type ?? file.type) || undefined,
18
+ });
19
+ }
20
+ /** Sets multiple file metadata fields */
21
+ metadata(fields) {
22
+ return this.chain(setFileMetadata(fields));
23
+ }
24
+ /** Sets or removes the file URL */
25
+ url(value) {
26
+ return this.chain(setFileURL(value));
27
+ }
28
+ /** Sets or removes the MIME type */
29
+ type(value) {
30
+ return this.chain(setFileType(value));
31
+ }
32
+ /** Sets or removes the SHA-256 hash */
33
+ sha256(value) {
34
+ return this.chain(setFileSHA256(value));
35
+ }
36
+ /** Sets or removes the original SHA-256 hash */
37
+ originalSha256(value) {
38
+ return this.chain(setOriginalFileSHA256(value));
39
+ }
40
+ /** Sets or removes the file size */
41
+ size(value) {
42
+ return this.chain(setFileSize(value));
43
+ }
44
+ /** Sets or removes the dimensions */
45
+ dimensions(value) {
46
+ return this.chain(setFileDimensions(value));
47
+ }
48
+ /** Sets or removes the magnet URI */
49
+ magnet(value) {
50
+ return this.chain(setFileMagnet(value));
51
+ }
52
+ /** Sets or removes the infohash */
53
+ infohash(value) {
54
+ return this.chain(setFileInfohash(value));
55
+ }
56
+ /** Sets or removes the thumbnail URL */
57
+ thumbnail(value) {
58
+ return this.chain(setFileThumbnail(value));
59
+ }
60
+ /** Sets or removes the preview image URL */
61
+ image(value) {
62
+ return this.chain(setFileImage(value));
63
+ }
64
+ /** Sets or removes the summary */
65
+ summary(value) {
66
+ return this.chain(setFileSummary(value));
67
+ }
68
+ /** Sets or removes the alt text */
69
+ alt(value) {
70
+ return this.chain(setFileAlt(value));
71
+ }
72
+ /** Sets or removes the blurhash */
73
+ blurhash(value) {
74
+ return this.chain(setFileBlurhash(value));
75
+ }
76
+ /** Adds a fallback URL */
77
+ addFallbackURL(url, replace = true) {
78
+ return this.chain(addFallbackURL(url, replace));
79
+ }
80
+ /** Removes a fallback URL */
81
+ removeFallbackURL(url) {
82
+ return this.chain(removeFallbackURL(url));
83
+ }
84
+ /** Removes all fallback URLs */
85
+ clearFallbackURLs() {
86
+ return this.chain(clearFallbackURLs());
87
+ }
88
+ /** Replaces all fallback URLs */
89
+ fallbackURLs(urls) {
90
+ return this.chain(setFallbackURLs(urls));
91
+ }
92
+ }
@@ -0,0 +1,12 @@
1
+ import { kinds, KnownEvent, KnownEventTemplate, NostrEvent } from "applesauce-core/helpers";
2
+ import { NIP51UserListFactory } from "./list.js";
3
+ export type FollowSetTemplate = KnownEventTemplate<kinds.Followsets>;
4
+ /** A factory class for building kind 30000 follow set events */
5
+ export declare class FollowSetFactory extends NIP51UserListFactory<kinds.Followsets, FollowSetTemplate> {
6
+ /** Creates a new follow set factory with an auto-generated identifier */
7
+ static create(): FollowSetFactory;
8
+ /** Sets the "d" identifier tag */
9
+ identifier(id: string): this;
10
+ /** Creates a new follow set factory from an existing follow set event */
11
+ static modify(event: NostrEvent | KnownEvent<kinds.Followsets>): FollowSetFactory;
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 { NIP51UserListFactory } from "./list.js";
6
+ /** A factory class for building kind 30000 follow set events */
7
+ export class FollowSetFactory extends NIP51UserListFactory {
8
+ /** Creates a new follow set factory with an auto-generated identifier */
9
+ static create() {
10
+ return new FollowSetFactory((res) => res(blankEventTemplate(kinds.Followsets))).identifier(nanoid());
11
+ }
12
+ /** Sets the "d" identifier tag */
13
+ identifier(id) {
14
+ return this.chain(includeReplaceableIdentifier(id));
15
+ }
16
+ /** Creates a new follow set factory from an existing follow set event */
17
+ static modify(event) {
18
+ if (!isKind(event, kinds.Followsets))
19
+ throw new Error("Event is not a follow set event");
20
+ return new FollowSetFactory((res) => res(toEventTemplate(event)));
21
+ }
22
+ }
@@ -0,0 +1,17 @@
1
+ import { EventFactory } from "applesauce-core/factories";
2
+ import { EventSigner } from "applesauce-core/factories";
3
+ import { EventTemplate, KnownEvent, KnownEventTemplate, kinds } from "applesauce-core/helpers";
4
+ import { MetaTagOptions } from "applesauce-core/operations/event";
5
+ import { Rumor } from "../helpers/gift-wrap.js";
6
+ export declare class GiftWrapFactory extends EventFactory<kinds.GiftWrap, KnownEventTemplate<kinds.GiftWrap>> {
7
+ /**
8
+ * Creates a signed gift wrap event for a recipient.
9
+ * @param signer - The signer to use for the gift wrap (ephemeral key will be generated internally)
10
+ * @param recipient - The pubkey of the recipient
11
+ * @param rumor - The inner rumor event or factory to wrap
12
+ * @param opts - Optional meta tag options
13
+ */
14
+ static create(signer: EventSigner, recipient: string, rumor: EventFactory<any> | EventTemplate | Rumor, opts?: MetaTagOptions): Promise<KnownEvent<kinds.GiftWrap>>;
15
+ /** Sets the inner rumor event of the gift wrap */
16
+ wrapEvent(pubkey: string, event: EventTemplate | Rumor, opts?: MetaTagOptions): this;
17
+ }
@@ -0,0 +1,21 @@
1
+ import { EventFactory } from "applesauce-core/factories";
2
+ import { giftWrap } from "../operations/gift-wrap.js";
3
+ export class GiftWrapFactory extends EventFactory {
4
+ /**
5
+ * Creates a signed gift wrap event for a recipient.
6
+ * @param signer - The signer to use for the gift wrap (ephemeral key will be generated internally)
7
+ * @param recipient - The pubkey of the recipient
8
+ * @param rumor - The inner rumor event or factory to wrap
9
+ * @param opts - Optional meta tag options
10
+ */
11
+ static async create(signer, recipient, rumor, opts) {
12
+ const _innerEvent = rumor instanceof EventFactory ? await rumor : rumor;
13
+ return giftWrap(recipient, signer, opts)(_innerEvent);
14
+ }
15
+ /** Sets the inner rumor event of the gift wrap */
16
+ wrapEvent(pubkey, event, opts) {
17
+ let result;
18
+ result = this.chain(async (_draft) => giftWrap(pubkey, result.signer, opts)(event));
19
+ return result;
20
+ }
21
+ }
@@ -0,0 +1,63 @@
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 { CREATE_GROUP_KIND, CREATE_INVITE_KIND, DELETE_EVENT_KIND, DELETE_GROUP_KIND, EDIT_METADATA_KIND, GroupMetadata, GroupPointer, JOIN_REQUEST_KIND, LEAVE_REQUEST_KIND, PUT_USER_KIND, REMOVE_USER_KIND } from "../helpers/groups.js";
5
+ export type GroupMembershipOptions = {
6
+ previous?: NostrEvent[];
7
+ reason?: string;
8
+ };
9
+ export declare class GroupJoinRequestFactory extends EventFactory<typeof JOIN_REQUEST_KIND, KnownEventTemplate<typeof JOIN_REQUEST_KIND>> {
10
+ static create(group: GroupPointer, reason?: string, inviteCode?: string): GroupJoinRequestFactory;
11
+ group(pointer: GroupPointer): this;
12
+ joinRequest(group: GroupPointer, inviteCode?: string): this;
13
+ /** Sets the reason for the join request */
14
+ reason(text: string): this;
15
+ }
16
+ export declare class GroupLeaveRequestFactory extends EventFactory<typeof LEAVE_REQUEST_KIND, KnownEventTemplate<typeof LEAVE_REQUEST_KIND>> {
17
+ static create(group: GroupPointer, reason?: string): GroupLeaveRequestFactory;
18
+ group(pointer: GroupPointer): this;
19
+ leaveRequest(group: GroupPointer): this;
20
+ /** Sets the reason for the leave request */
21
+ reason(text: string): this;
22
+ }
23
+ export declare class PutUserFactory extends EventFactory<typeof PUT_USER_KIND, KnownEventTemplate<typeof PUT_USER_KIND>> {
24
+ static create(group: GroupPointer, pubkey: string, roles?: string[]): PutUserFactory;
25
+ group(pointer: GroupPointer): this;
26
+ user(pubkey: string, roles?: string[]): this;
27
+ previous(events: NostrEvent[]): this;
28
+ reason(text: string): this;
29
+ }
30
+ export declare class RemoveUserFactory extends EventFactory<typeof REMOVE_USER_KIND, KnownEventTemplate<typeof REMOVE_USER_KIND>> {
31
+ static create(group: GroupPointer, pubkey: string): RemoveUserFactory;
32
+ group(pointer: GroupPointer): this;
33
+ user(pubkey: string): this;
34
+ previous(events: NostrEvent[]): this;
35
+ reason(text: string): this;
36
+ }
37
+ export declare class EditGroupMetadataFactory extends EventFactory<typeof EDIT_METADATA_KIND, KnownEventTemplate<typeof EDIT_METADATA_KIND>> {
38
+ static create(group: GroupPointer, metadata: GroupMetadata): EditGroupMetadataFactory;
39
+ group(pointer: GroupPointer): this;
40
+ metadata(metadata: GroupMetadata): this;
41
+ previous(events: NostrEvent[]): this;
42
+ }
43
+ export declare class DeleteGroupEventFactory extends EventFactory<typeof DELETE_EVENT_KIND, KnownEventTemplate<typeof DELETE_EVENT_KIND>> {
44
+ static create(group: GroupPointer, eventId: string | NostrEvent | EventPointer): DeleteGroupEventFactory;
45
+ group(pointer: GroupPointer): this;
46
+ /** Sets the event to delete — accepts an event ID string, a NostrEvent, or an EventPointer */
47
+ event(eventId: string | NostrEvent | EventPointer): this;
48
+ previous(events: NostrEvent[]): this;
49
+ }
50
+ export declare class CreateGroupFactory extends EventFactory<typeof CREATE_GROUP_KIND, KnownEventTemplate<typeof CREATE_GROUP_KIND>> {
51
+ static create(groupId: string, metadata: GroupMetadata): CreateGroupFactory;
52
+ groupId(id: string): this;
53
+ metadata(metadata: GroupMetadata): this;
54
+ }
55
+ export declare class DeleteGroupFactory extends EventFactory<typeof DELETE_GROUP_KIND, KnownEventTemplate<typeof DELETE_GROUP_KIND>> {
56
+ static create(group: GroupPointer): DeleteGroupFactory;
57
+ group(pointer: GroupPointer): this;
58
+ previous(events: NostrEvent[]): this;
59
+ }
60
+ export declare class CreateGroupInviteFactory extends EventFactory<typeof CREATE_INVITE_KIND, KnownEventTemplate<typeof CREATE_INVITE_KIND>> {
61
+ static create(group: GroupPointer): CreateGroupInviteFactory;
62
+ group(pointer: GroupPointer): this;
63
+ }
@@ -0,0 +1,147 @@
1
+ import { EventFactory, blankEventTemplate } from "applesauce-core/factories";
2
+ import { setContent } from "applesauce-core/operations/content";
3
+ import { CREATE_GROUP_KIND, CREATE_INVITE_KIND, DELETE_EVENT_KIND, DELETE_GROUP_KIND, EDIT_METADATA_KIND, JOIN_REQUEST_KIND, LEAVE_REQUEST_KIND, PUT_USER_KIND, REMOVE_USER_KIND, } from "../helpers/groups.js";
4
+ import { addPreviousRefs, setDeleteEventTags, setEditMetadataTags, setGroupPointer, setJoinRequestTags, setLeaveRequestTags, setPutUserTags, setRemoveUserTags, } from "../operations/group.js";
5
+ // Join Request Factory
6
+ export class GroupJoinRequestFactory extends EventFactory {
7
+ static create(group, reason, inviteCode) {
8
+ const factory = new GroupJoinRequestFactory((res) => res(blankEventTemplate(JOIN_REQUEST_KIND)))
9
+ .group(group)
10
+ .joinRequest(group, inviteCode);
11
+ return reason ? factory.content(reason) : factory;
12
+ }
13
+ group(pointer) {
14
+ return this.chain((draft) => setGroupPointer(pointer)(draft));
15
+ }
16
+ joinRequest(group, inviteCode) {
17
+ return this.chain((draft) => setJoinRequestTags(group, inviteCode)(draft));
18
+ }
19
+ /** Sets the reason for the join request */
20
+ reason(text) {
21
+ return this.chain((draft) => setContent(text)(draft));
22
+ }
23
+ }
24
+ // Leave Request Factory
25
+ export class GroupLeaveRequestFactory extends EventFactory {
26
+ static create(group, reason) {
27
+ const factory = new GroupLeaveRequestFactory((res) => res(blankEventTemplate(LEAVE_REQUEST_KIND)))
28
+ .group(group)
29
+ .leaveRequest(group);
30
+ return reason ? factory.content(reason) : factory;
31
+ }
32
+ group(pointer) {
33
+ return this.chain((draft) => setGroupPointer(pointer)(draft));
34
+ }
35
+ leaveRequest(group) {
36
+ return this.chain((draft) => setLeaveRequestTags(group)(draft));
37
+ }
38
+ /** Sets the reason for the leave request */
39
+ reason(text) {
40
+ return this.chain((draft) => setContent(text)(draft));
41
+ }
42
+ }
43
+ // Put User Factory
44
+ export class PutUserFactory extends EventFactory {
45
+ static create(group, pubkey, roles) {
46
+ return new PutUserFactory((res) => res(blankEventTemplate(PUT_USER_KIND))).group(group).user(pubkey, roles);
47
+ }
48
+ group(pointer) {
49
+ return this.chain((draft) => setGroupPointer(pointer)(draft));
50
+ }
51
+ user(pubkey, roles) {
52
+ return this.chain((draft) => setPutUserTags(pubkey, roles)(draft));
53
+ }
54
+ previous(events) {
55
+ return this.chain((draft) => addPreviousRefs(events)(draft));
56
+ }
57
+ reason(text) {
58
+ return this.chain((draft) => setContent(text)(draft));
59
+ }
60
+ }
61
+ // Remove User Factory
62
+ export class RemoveUserFactory extends EventFactory {
63
+ static create(group, pubkey) {
64
+ return new RemoveUserFactory((res) => res(blankEventTemplate(REMOVE_USER_KIND))).group(group).user(pubkey);
65
+ }
66
+ group(pointer) {
67
+ return this.chain((draft) => setGroupPointer(pointer)(draft));
68
+ }
69
+ user(pubkey) {
70
+ return this.chain((draft) => setRemoveUserTags(pubkey)(draft));
71
+ }
72
+ previous(events) {
73
+ return this.chain((draft) => addPreviousRefs(events)(draft));
74
+ }
75
+ reason(text) {
76
+ return this.chain((draft) => setContent(text)(draft));
77
+ }
78
+ }
79
+ // Edit Metadata Factory
80
+ export class EditGroupMetadataFactory extends EventFactory {
81
+ static create(group, metadata) {
82
+ return new EditGroupMetadataFactory((res) => res(blankEventTemplate(EDIT_METADATA_KIND)))
83
+ .group(group)
84
+ .metadata(metadata);
85
+ }
86
+ group(pointer) {
87
+ return this.chain((draft) => setGroupPointer(pointer)(draft));
88
+ }
89
+ metadata(metadata) {
90
+ return this.chain((draft) => setEditMetadataTags(metadata)(draft));
91
+ }
92
+ previous(events) {
93
+ return this.chain((draft) => addPreviousRefs(events)(draft));
94
+ }
95
+ }
96
+ // Delete Event Factory
97
+ export class DeleteGroupEventFactory extends EventFactory {
98
+ static create(group, eventId) {
99
+ return new DeleteGroupEventFactory((res) => res(blankEventTemplate(DELETE_EVENT_KIND))).group(group).event(eventId);
100
+ }
101
+ group(pointer) {
102
+ return this.chain((draft) => setGroupPointer(pointer)(draft));
103
+ }
104
+ /** Sets the event to delete — accepts an event ID string, a NostrEvent, or an EventPointer */
105
+ event(eventId) {
106
+ const id = typeof eventId === "string" ? eventId : eventId.id;
107
+ return this.chain((draft) => setDeleteEventTags(id)(draft));
108
+ }
109
+ previous(events) {
110
+ return this.chain((draft) => addPreviousRefs(events)(draft));
111
+ }
112
+ }
113
+ // Create Group Factory
114
+ export class CreateGroupFactory extends EventFactory {
115
+ static create(groupId, metadata) {
116
+ return new CreateGroupFactory((res) => res(blankEventTemplate(CREATE_GROUP_KIND)))
117
+ .groupId(groupId)
118
+ .metadata(metadata);
119
+ }
120
+ groupId(id) {
121
+ return this.chain((draft) => setGroupPointer({ id, relay: "" })(draft));
122
+ }
123
+ metadata(metadata) {
124
+ return this.chain((draft) => setEditMetadataTags(metadata)(draft));
125
+ }
126
+ }
127
+ // Delete Group Factory
128
+ export class DeleteGroupFactory extends EventFactory {
129
+ static create(group) {
130
+ return new DeleteGroupFactory((res) => res(blankEventTemplate(DELETE_GROUP_KIND))).group(group);
131
+ }
132
+ group(pointer) {
133
+ return this.chain((draft) => setGroupPointer(pointer)(draft));
134
+ }
135
+ previous(events) {
136
+ return this.chain((draft) => addPreviousRefs(events)(draft));
137
+ }
138
+ }
139
+ // Create Invite Factory
140
+ export class CreateGroupInviteFactory extends EventFactory {
141
+ static create(group) {
142
+ return new CreateGroupInviteFactory((res) => res(blankEventTemplate(CREATE_INVITE_KIND))).group(group);
143
+ }
144
+ group(pointer) {
145
+ return this.chain((draft) => setGroupPointer(pointer)(draft));
146
+ }
147
+ }
@@ -0,0 +1,35 @@
1
+ import { EventFactory } from "applesauce-core/factories";
2
+ import { KnownEventTemplate, NostrEvent } from "applesauce-core/helpers";
3
+ import { TextContentOptions } from "applesauce-core/operations/content";
4
+ import { MetaTagOptions } from "applesauce-core/operations/event";
5
+ import { GROUP_MESSAGE_KIND, GROUP_THREAD_KIND, GroupPointer } from "../helpers/groups.js";
6
+ export type GroupMessageTemplate = KnownEventTemplate<typeof GROUP_MESSAGE_KIND>;
7
+ export type GroupThreadTemplate = KnownEventTemplate<typeof GROUP_THREAD_KIND>;
8
+ export declare class GroupMessageFactory extends EventFactory<typeof GROUP_MESSAGE_KIND, GroupMessageTemplate> {
9
+ static create(group: GroupPointer, content: string): GroupMessageFactory;
10
+ group(pointer: GroupPointer): this;
11
+ text(content: string, options?: TextContentOptions): this;
12
+ previous(events: NostrEvent[]): this;
13
+ /** Sets the "e" reply tag pointing to a parent group message */
14
+ replyTo(parent: NostrEvent): this;
15
+ meta(options: MetaTagOptions): this;
16
+ /** Creates a reply to a group message */
17
+ static reply(group: GroupPointer, parent: NostrEvent, content: string): GroupMessageFactory;
18
+ }
19
+ /** A factory class for building NIP-29 group thread events (kind 11) */
20
+ export declare class GroupThreadFactory extends EventFactory<typeof GROUP_THREAD_KIND, GroupThreadTemplate> {
21
+ /** Creates a new group thread event */
22
+ static create(group: GroupPointer, title: string, content: string): GroupThreadFactory;
23
+ /** Sets the NIP-29 group pointer "h" tag */
24
+ group(pointer: GroupPointer): this;
25
+ /** Sets the thread title */
26
+ title(title: string): this;
27
+ /** Sets the text content */
28
+ text(content: string, options?: TextContentOptions): this;
29
+ /** Adds a hashtag "t" tag to the thread */
30
+ addHashtag(hashtag: string): this;
31
+ /** Adds multiple hashtags as "t" tags */
32
+ hashtags(hashtags: string[]): this;
33
+ /** Sets meta tags */
34
+ meta(options: MetaTagOptions): this;
35
+ }