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
@@ -1,20 +0,0 @@
1
- import { NostrEvent } from "applesauce-core/helpers/event";
2
- import { AddressPointer } from "applesauce-core/helpers/pointers";
3
- import { MetaTagOptions } from "applesauce-core/operations/event";
4
- import { HighlightAttribution } from "../helpers/index.js";
5
- import { ZapOptions } from "../operations/zap-split.js";
6
- export type HighlightBlueprintOptions = MetaTagOptions & ZapOptions & {
7
- /** Additional context surrounding the highlight */
8
- context?: string;
9
- /** Comment to create a quote highlight */
10
- comment?: string;
11
- /** Attribution information for the original content */
12
- attributions?: HighlightAttribution[];
13
- /** Alt description for clients that can't render the event */
14
- alt?: string;
15
- };
16
- /**
17
- * NIP-84 Highlight event (kind 9802) blueprint
18
- * Creates a highlight event that references content from nostr events or external URLs
19
- */
20
- export declare function HighlightBlueprint(content: string, source: NostrEvent | AddressPointer | string, options?: HighlightBlueprintOptions): import("applesauce-core/event-factory").EventBlueprint;
@@ -1,12 +0,0 @@
1
- import { blueprint } from "applesauce-core/event-factory";
2
- import { kinds } from "applesauce-core/helpers/event";
3
- import { includeAltTag, setMetaTags } from "applesauce-core/operations/event";
4
- import { setAttributions, setComment, setContext, setHighlightContent, setSource } from "../operations/highlight.js";
5
- import { setZapSplit } from "../operations/zap-split.js";
6
- /**
7
- * NIP-84 Highlight event (kind 9802) blueprint
8
- * Creates a highlight event that references content from nostr events or external URLs
9
- */
10
- export function HighlightBlueprint(content, source, options) {
11
- return blueprint(kinds.Highlights, setHighlightContent(content), setSource(source), options?.attributions ? setAttributions(options.attributions) : undefined, options?.context ? setContext(options.context) : undefined, options?.comment ? setComment(options.comment) : undefined, setZapSplit(options), setMetaTags(options), includeAltTag(options?.alt ?? "A text highlight"));
12
- }
@@ -1,25 +0,0 @@
1
- export * from "./app-data.js";
2
- export * from "./calendar.js";
3
- export * from "./channels.js";
4
- export * from "./comment.js";
5
- export * from "./delete.js";
6
- export * from "./file-metadata.js";
7
- export * from "./follow-set.js";
8
- export * from "./gift-wrap.js";
9
- export * from "./group.js";
10
- export * from "./group-mangement.js";
11
- export * from "./delete.js";
12
- export * from "./highlight.js";
13
- export * from "./legacy-message.js";
14
- export * from "./live-stream.js";
15
- export * from "./note.js";
16
- export * from "./picture-post.js";
17
- export * from "./poll.js";
18
- export * from "./profile.js";
19
- export * from "./reaction.js";
20
- export * from "./share.js";
21
- export * from "./stream.js";
22
- export * from "./torrent.js";
23
- export * from "./wrapped-message.js";
24
- export * from "./zap-goal.js";
25
- import "../register.js";
@@ -1,26 +0,0 @@
1
- export * from "./app-data.js";
2
- export * from "./calendar.js";
3
- export * from "./channels.js";
4
- export * from "./comment.js";
5
- export * from "./delete.js";
6
- export * from "./file-metadata.js";
7
- export * from "./follow-set.js";
8
- export * from "./gift-wrap.js";
9
- export * from "./group.js";
10
- export * from "./group-mangement.js";
11
- export * from "./delete.js";
12
- export * from "./highlight.js";
13
- export * from "./legacy-message.js";
14
- export * from "./live-stream.js";
15
- export * from "./note.js";
16
- export * from "./picture-post.js";
17
- export * from "./poll.js";
18
- export * from "./profile.js";
19
- export * from "./reaction.js";
20
- export * from "./share.js";
21
- export * from "./stream.js";
22
- export * from "./torrent.js";
23
- export * from "./wrapped-message.js";
24
- export * from "./zap-goal.js";
25
- // Register the common blueprints with the event factory
26
- import "../register.js";
@@ -1,7 +0,0 @@
1
- import { NostrEvent } from "applesauce-core/helpers/event";
2
- import { MetaTagOptions } from "applesauce-core/operations/event";
3
- export type LegacyMessageBlueprintOptions = MetaTagOptions;
4
- /** A blueprint to create a nip-04 encrypted direct message */
5
- export declare function LegacyMessageBlueprint(recipient: string, message: string, opts?: LegacyMessageBlueprintOptions): import("applesauce-core/event-factory").EventBlueprint;
6
- /** Creates a reply to a legacy message */
7
- export declare function LegacyMessageReplyBlueprint(parent: NostrEvent, message: string, opts?: LegacyMessageBlueprintOptions): import("applesauce-core/event-factory").EventBlueprint;
@@ -1,29 +0,0 @@
1
- import { blueprint } from "applesauce-core/event-factory";
2
- import { kinds } from "applesauce-core/helpers/event";
3
- import { setEncryptedContent } from "applesauce-core/operations/encrypted-content";
4
- import { setMetaTags } from "applesauce-core/operations/event";
5
- import { setMessageAddress, setMessageParent } from "../operations/legacy-message.js";
6
- /** A blueprint to create a nip-04 encrypted direct message */
7
- export function LegacyMessageBlueprint(recipient, message, opts) {
8
- return blueprint(kinds.EncryptedDirectMessage,
9
- // Encrypt the contents of the message to the recipient
10
- setEncryptedContent(recipient, message),
11
- // Include the necessary "p" tag of the recipient
12
- setMessageAddress(recipient),
13
- // Include the meta tags
14
- setMetaTags(opts));
15
- }
16
- /** Creates a reply to a legacy message */
17
- export function LegacyMessageReplyBlueprint(parent, message, opts) {
18
- if (parent.kind !== kinds.EncryptedDirectMessage)
19
- throw new Error("Parent message must be a legacy message (kind 4)");
20
- return blueprint(kinds.EncryptedDirectMessage,
21
- // Encrypt the contents of the message to the recipient
22
- setEncryptedContent(parent.pubkey, message),
23
- // Include the necessary "p" tag of the recipient
24
- setMessageAddress(parent.pubkey),
25
- // Include the parent message id
26
- setMessageParent(parent),
27
- // Include the meta tags
28
- setMetaTags(opts));
29
- }
@@ -1,6 +0,0 @@
1
- import { NostrEvent } from "applesauce-core/helpers/event";
2
- import { TextContentOptions } from "applesauce-core/operations/content";
3
- import { MetaTagOptions } from "applesauce-core/operations/event";
4
- export type LiveChatMessageBlueprintOptions = TextContentOptions & MetaTagOptions;
5
- /** A blueprint for creating a live stream message */
6
- export declare function LiveChatMessageBlueprint(stream: NostrEvent, message: string, options?: LiveChatMessageBlueprintOptions): import("applesauce-core/event-factory").EventBlueprint;
@@ -1,9 +0,0 @@
1
- import { blueprint } from "applesauce-core/event-factory";
2
- import { kinds } from "applesauce-core/helpers/event";
3
- import { setShortTextContent } from "applesauce-core/operations/content";
4
- import { setMetaTags } from "applesauce-core/operations/event";
5
- import { includeLiveStreamTag } from "../operations/live-stream.js";
6
- /** A blueprint for creating a live stream message */
7
- export function LiveChatMessageBlueprint(stream, message, options) {
8
- return blueprint(kinds.LiveChatMessage, includeLiveStreamTag(stream), setShortTextContent(message, options), setMetaTags(options));
9
- }
@@ -1,16 +0,0 @@
1
- import { EventTemplate, NostrEvent } from "applesauce-core/helpers/event";
2
- import { MetaTagOptions, TextContentOptions } from "applesauce-core/operations";
3
- import { ZapOptions } from "../operations/zap-split.js";
4
- export type NoteBlueprintOptions = TextContentOptions & MetaTagOptions & ZapOptions;
5
- /** Short text note (kind 1) blueprint */
6
- export declare function NoteBlueprint(content: string, options?: NoteBlueprintOptions): import("applesauce-core/event-factory").EventBlueprint;
7
- /** Short text note reply (kind 1) blueprint */
8
- export declare function NoteReplyBlueprint(parent: NostrEvent, content: string, options?: TextContentOptions): import("applesauce-core/event-factory").EventBlueprint;
9
- declare module "applesauce-core/event-factory" {
10
- interface EventFactory {
11
- /** Create a short text note (kind 1) */
12
- note(content: string, options?: NoteBlueprintOptions): Promise<EventTemplate>;
13
- /** Create a short text note reply (kind 1) */
14
- noteReply(parent: NostrEvent, content: string, options?: TextContentOptions): Promise<EventTemplate>;
15
- }
16
- }
@@ -1,30 +0,0 @@
1
- import { blueprint } from "applesauce-core/event-factory";
2
- import { kinds } from "applesauce-core/helpers/event";
3
- import { setMetaTags, setShortTextContent } from "applesauce-core/operations";
4
- import { setZapSplit } from "../operations/zap-split.js";
5
- import { includePubkeyNotificationTags, setThreadParent } from "../operations/note.js";
6
- // Import EventFactory as a value (class) to modify its prototype
7
- import { EventFactory } from "applesauce-core/event-factory";
8
- /** Short text note (kind 1) blueprint */
9
- export function NoteBlueprint(content, options) {
10
- return blueprint(kinds.ShortTextNote, setShortTextContent(content, options), setZapSplit(options), setMetaTags(options));
11
- }
12
- /** Short text note reply (kind 1) blueprint */
13
- export function NoteReplyBlueprint(parent, content, options) {
14
- if (parent.kind !== kinds.ShortTextNote)
15
- throw new Error("Kind 1 replies should only be used to reply to kind 1 notes");
16
- return blueprint(kinds.ShortTextNote,
17
- // add NIP-10 tags
18
- setThreadParent(parent),
19
- // copy "p" tags from parent
20
- includePubkeyNotificationTags(parent),
21
- // set default text content
22
- setShortTextContent(content, options));
23
- }
24
- // Register these blueprints with EventFactory
25
- EventFactory.prototype.note = function (content, options) {
26
- return this.create(NoteBlueprint, content, options);
27
- };
28
- EventFactory.prototype.noteReply = function (parent, content, options) {
29
- return this.create(NoteReplyBlueprint, parent, content, options);
30
- };
@@ -1,12 +0,0 @@
1
- import { TextContentOptions } from "applesauce-core/operations/content";
2
- import { MetaTagOptions } from "applesauce-core/operations/event";
3
- import { MediaAttachment } from "../helpers/index.js";
4
- export type PicturePostBlueprintOptions = TextContentOptions & MetaTagOptions & {
5
- hashtags?: string[];
6
- };
7
- /**
8
- * A blueprint to create a kind 20 picture post
9
- * @see https://github.com/nostr-protocol/nips/blob/master/68.md
10
- * @throws {Error} if the pictures are not image/* types
11
- */
12
- export declare function PicturePostBlueprint(pictures: MediaAttachment[], content: string, options?: PicturePostBlueprintOptions): import("applesauce-core/event-factory").EventBlueprint;
@@ -1,17 +0,0 @@
1
- import { blueprint } from "applesauce-core/event-factory";
2
- import { setShortTextContent } from "applesauce-core/operations/content";
3
- import { setMetaTags } from "applesauce-core/operations/event";
4
- import { PICTURE_POST_KIND } from "../helpers/index.js";
5
- import { includeHashtags } from "../operations/hashtags.js";
6
- import { addMediaAttachments } from "../operations/media-attachment.js";
7
- import { setImageMetadata } from "../operations/picture-post.js";
8
- /**
9
- * A blueprint to create a kind 20 picture post
10
- * @see https://github.com/nostr-protocol/nips/blob/master/68.md
11
- * @throws {Error} if the pictures are not image/* types
12
- */
13
- export function PicturePostBlueprint(pictures, content, options) {
14
- if (pictures.some((m) => !m.type?.includes("image/")))
15
- throw new Error("Only image/* types can be added to a picture post");
16
- return blueprint(PICTURE_POST_KIND, addMediaAttachments(pictures), setImageMetadata(pictures), setShortTextContent(content, options), setMetaTags(options), options?.hashtags ? includeHashtags(options.hashtags) : undefined);
17
- }
@@ -1,41 +0,0 @@
1
- import { EventTemplate, NostrEvent } from "applesauce-core/helpers/event";
2
- import { EventPointer } from "applesauce-core/helpers/pointers";
3
- import { MetaTagOptions } from "applesauce-core/operations";
4
- import { PollType } from "../helpers/poll.js";
5
- import { ZapOptions } from "../operations/zap-split.js";
6
- export interface PollOption {
7
- id: string;
8
- label: string;
9
- }
10
- export type PollBlueprintOptions = MetaTagOptions & ZapOptions & {
11
- /** Poll type - singlechoice or multiplechoice. Defaults to singlechoice */
12
- pollType?: PollType;
13
- /** Unix timestamp when the poll ends */
14
- endsAt?: number;
15
- /** Relay URLs where responses should be published */
16
- relays?: string[];
17
- };
18
- /**
19
- * NIP-88 Poll event (kind 1068) blueprint
20
- * Creates a poll event with question and options
21
- */
22
- export declare function PollBlueprint(question: string, options: PollOption[], opts?: PollBlueprintOptions): import("applesauce-core").EventBlueprint;
23
- export type PollResponseBlueprintOptions = MetaTagOptions & {
24
- comment?: string;
25
- };
26
- /**
27
- * NIP-88 Poll Response event (kind 1018) blueprint
28
- * Creates a response to a poll event
29
- */
30
- export declare function PollResponseBlueprint(poll: NostrEvent | EventPointer | string, optionIds: string[], opts?: PollResponseBlueprintOptions): import("applesauce-core").EventBlueprint;
31
- /**
32
- * Convenience blueprint for single-choice poll responses
33
- * Creates a response to a poll event with a single option
34
- */
35
- export declare function SingleChoicePollResponseBlueprint(poll: NostrEvent | EventPointer | string, optionId: string, opts?: PollResponseBlueprintOptions): import("applesauce-core").EventBlueprint;
36
- declare module "applesauce-core/event-factory" {
37
- interface EventFactory {
38
- /** Create a NIP-88 poll event */
39
- poll(question: string, options: PollOption[], opts?: PollBlueprintOptions): Promise<EventTemplate>;
40
- }
41
- }
@@ -1,33 +0,0 @@
1
- import { blueprint } from "applesauce-core";
2
- import { setContent, setMetaTags } from "applesauce-core/operations";
3
- import { POLL_KIND, POLL_RESPONSE_KIND } from "../helpers/poll.js";
4
- import * as PollResponse from "../operations/poll-response.js";
5
- import * as Poll from "../operations/poll.js";
6
- import { setZapSplit } from "../operations/zap-split.js";
7
- // Import EventFactory as a value (class) to modify its prototype
8
- import { EventFactory } from "applesauce-core/event-factory";
9
- /**
10
- * NIP-88 Poll event (kind 1068) blueprint
11
- * Creates a poll event with question and options
12
- */
13
- export function PollBlueprint(question, options, opts) {
14
- return blueprint(POLL_KIND, Poll.setQuestion(question), Poll.setOptions(options), opts?.pollType ? Poll.setType(opts.pollType) : undefined, opts?.endsAt ? Poll.setEndsAt(opts.endsAt) : undefined, opts?.relays ? Poll.setRelays(opts.relays) : undefined, setZapSplit(opts), setMetaTags({ ...opts, alt: opts?.alt ?? `Poll: ${question}` }));
15
- }
16
- /**
17
- * NIP-88 Poll Response event (kind 1018) blueprint
18
- * Creates a response to a poll event
19
- */
20
- export function PollResponseBlueprint(poll, optionIds, opts) {
21
- return blueprint(POLL_RESPONSE_KIND, PollResponse.setPollEvent(poll), PollResponse.setChoices(optionIds), opts?.comment ? setContent(opts.comment) : undefined, setMetaTags({ ...opts, alt: opts?.alt ?? "Poll response" }));
22
- }
23
- /**
24
- * Convenience blueprint for single-choice poll responses
25
- * Creates a response to a poll event with a single option
26
- */
27
- export function SingleChoicePollResponseBlueprint(poll, optionId, opts) {
28
- return blueprint(POLL_RESPONSE_KIND, PollResponse.setPollEvent(poll), PollResponse.setChoice(optionId), opts?.comment ? setContent(opts.comment) : undefined, setMetaTags({ ...opts, alt: opts?.alt ?? "Poll response" }));
29
- }
30
- // Register this blueprint with EventFactory
31
- EventFactory.prototype.poll = function (question, options, opts) {
32
- return this.create(PollBlueprint, question, options, opts);
33
- };
@@ -1,3 +0,0 @@
1
- import { ProfileContent } from "applesauce-core/helpers/profile";
2
- /** User Profile (kind 0) blueprint */
3
- export declare function ProfileBlueprint(content: ProfileContent): import("applesauce-core/event-factory").EventBlueprint;
@@ -1,7 +0,0 @@
1
- import { blueprint } from "applesauce-core/event-factory";
2
- import { kinds } from "applesauce-core/helpers/event";
3
- import { setProfile } from "applesauce-core/operations/profile";
4
- /** User Profile (kind 0) blueprint */
5
- export function ProfileBlueprint(content) {
6
- return blueprint(kinds.Metadata, setProfile(content));
7
- }
@@ -1,10 +0,0 @@
1
- import { Emoji } from "applesauce-core/event-factory";
2
- import { EventTemplate, NostrEvent } from "applesauce-core/helpers/event";
3
- /** blueprint for kind 7 reaction event */
4
- export declare function ReactionBlueprint(event: NostrEvent, emoji?: string | Emoji): import("applesauce-core/event-factory").EventBlueprint;
5
- declare module "applesauce-core/event-factory" {
6
- interface EventFactory {
7
- /** Create a kind 7 reaction event */
8
- reaction(event: NostrEvent, emoji?: string | Emoji): Promise<EventTemplate>;
9
- }
10
- }
@@ -1,14 +0,0 @@
1
- import { blueprint } from "applesauce-core/event-factory";
2
- import { kinds } from "applesauce-core/helpers/event";
3
- import { includeEmojis } from "applesauce-core/operations/content";
4
- import { setReaction, setReactionParent } from "../operations/reaction.js";
5
- // Import EventFactory as a value (class) to modify its prototype
6
- import { EventFactory } from "applesauce-core/event-factory";
7
- /** blueprint for kind 7 reaction event */
8
- export function ReactionBlueprint(event, emoji = "+") {
9
- return blueprint(kinds.Reaction, setReaction(emoji), setReactionParent(event), typeof emoji !== "string" ? includeEmojis([emoji]) : undefined);
10
- }
11
- // Register this blueprint with EventFactory
12
- EventFactory.prototype.reaction = function (event, emoji = "+") {
13
- return this.create(ReactionBlueprint, event, emoji);
14
- };
@@ -1,12 +0,0 @@
1
- import { MetaTagOptions } from "applesauce-core/operations/event";
2
- import { EventTemplate, NostrEvent } from "applesauce-core/helpers/event";
3
- import { ZapOptions } from "../operations/zap-split.js";
4
- export type ShareBlueprintOptions = MetaTagOptions & ZapOptions;
5
- /** Blueprint for a NIP-18 repost event */
6
- export declare function ShareBlueprint(event: NostrEvent, options?: ShareBlueprintOptions): import("applesauce-core/event-factory").EventBlueprint;
7
- declare module "applesauce-core/event-factory" {
8
- interface EventFactory {
9
- /** Create a NIP-18 repost event */
10
- share(event: NostrEvent, options?: ShareBlueprintOptions): Promise<EventTemplate>;
11
- }
12
- }
@@ -1,25 +0,0 @@
1
- import { setMetaTags } from "applesauce-core/operations/event";
2
- import { embedSharedEvent, setShareKind, setShareTags } from "../operations/share.js";
3
- import { blueprint } from "applesauce-core/event-factory";
4
- import { kinds } from "applesauce-core/helpers/event";
5
- import { setZapSplit } from "../operations/zap-split.js";
6
- // Import EventFactory as a value (class) to modify its prototype
7
- import { EventFactory } from "applesauce-core/event-factory";
8
- /** Blueprint for a NIP-18 repost event */
9
- export function ShareBlueprint(event, options) {
10
- return blueprint(kinds.Repost,
11
- // set the kind to 6 or 16 based on the kind of event being shared
12
- setShareKind(event),
13
- // embed the shared event as a JSON string
14
- embedSharedEvent(event),
15
- // include the NIP-18 repost tags
16
- setShareTags(event),
17
- // include the meta tags
18
- setMetaTags(options),
19
- // include the zap split tags
20
- setZapSplit(options));
21
- }
22
- // Register this blueprint with EventFactory
23
- EventFactory.prototype.share = function (event, options) {
24
- return this.create(ShareBlueprint, event, options);
25
- };
@@ -1,6 +0,0 @@
1
- import { TextContentOptions } from "applesauce-core/operations";
2
- import { AddressPointer } from "applesauce-core/helpers/pointers";
3
- import { NostrEvent } from "applesauce-core/helpers/event";
4
- import { EventBlueprint } from "applesauce-core/event-factory";
5
- /** Creates a stream chat message */
6
- export declare function StreamChatMessage(stream: AddressPointer | NostrEvent, content: string, options?: TextContentOptions): EventBlueprint;
@@ -1,7 +0,0 @@
1
- import { blueprint } from "applesauce-core/event-factory";
2
- import { kinds } from "applesauce-core/helpers/event";
3
- import { setMessage, setStream } from "../operations/stream-chat.js";
4
- /** Creates a stream chat message */
5
- export function StreamChatMessage(stream, content, options) {
6
- return blueprint(kinds.LiveChatMessage, setMessage(content, options), setStream(stream));
7
- }
@@ -1,30 +0,0 @@
1
- import { EventTemplate } from "applesauce-core/helpers/event";
2
- import { MetaTagOptions } from "applesauce-core/operations/event";
3
- import { TorrentExternalIdentifier, TorrentFile } from "../helpers/torrent.js";
4
- export type TorrentBlueprintOptions = MetaTagOptions & {
5
- /** Torrent title */
6
- title?: string;
7
- /** File entries in the torrent */
8
- files?: TorrentFile[];
9
- /** Tracker URLs */
10
- trackers?: string[];
11
- /** Newznab category ID */
12
- category?: number;
13
- /** Search tags for searchability (t tags) */
14
- searchTags?: string[];
15
- /** Category path (tcat) */
16
- categoryPath?: string;
17
- /** External identifiers */
18
- externalIdentifiers?: TorrentExternalIdentifier[];
19
- };
20
- /**
21
- * NIP-35 Torrent event (kind 2003) blueprint
22
- * Creates a torrent event with info hash and optional metadata
23
- */
24
- export declare function TorrentBlueprint(infoHash: string, content: string, options?: TorrentBlueprintOptions): import("applesauce-core/event-factory").EventBlueprint;
25
- declare module "applesauce-core/event-factory" {
26
- interface EventFactory {
27
- /** Create a NIP-35 torrent event (kind 2003) */
28
- torrent(infoHash: string, content: string, options?: TorrentBlueprintOptions): Promise<EventTemplate>;
29
- }
30
- }
@@ -1,29 +0,0 @@
1
- import { blueprint, EventFactory } from "applesauce-core/event-factory";
2
- import { eventPipe } from "applesauce-core/helpers/pipeline";
3
- import { setContent } from "applesauce-core/operations/content";
4
- import { setMetaTags } from "applesauce-core/operations/event";
5
- import { TORRENT_KIND } from "../helpers/torrent.js";
6
- import { addTorrentExternalIdentifier, addTorrentFile, addTorrentSearchTag, addTorrentTracker, setTorrentCategory, setTorrentCategoryPath, setTorrentInfoHash, setTorrentTitle, } from "../operations/torrent.js";
7
- /**
8
- * NIP-35 Torrent event (kind 2003) blueprint
9
- * Creates a torrent event with info hash and optional metadata
10
- */
11
- export function TorrentBlueprint(infoHash, content, options) {
12
- return blueprint(TORRENT_KIND, setTorrentInfoHash(infoHash), setContent(content), options?.title ? setTorrentTitle(options.title) : undefined, options?.categoryPath ? setTorrentCategoryPath(options.categoryPath) : undefined,
13
- // Add files
14
- options?.files ? eventPipe(...options.files.map((file) => addTorrentFile(file))) : undefined,
15
- // Add trackers
16
- options?.trackers ? eventPipe(...options.trackers.map((tracker) => addTorrentTracker(tracker))) : undefined,
17
- // Set newznab category
18
- options?.category !== undefined ? setTorrentCategory(options.category) : undefined,
19
- // Add search tags
20
- options?.searchTags ? eventPipe(...options.searchTags.map((tag) => addTorrentSearchTag(tag))) : undefined,
21
- // Add external identifiers
22
- options?.externalIdentifiers
23
- ? eventPipe(...options.externalIdentifiers.map((id) => addTorrentExternalIdentifier(id)))
24
- : undefined, setMetaTags({ ...options, alt: options?.alt ?? `Torrent: ${options?.title ?? infoHash}` }));
25
- }
26
- // Register this blueprint with EventFactory
27
- EventFactory.prototype.torrent = function (infoHash, content, options) {
28
- return this.create(TorrentBlueprint, infoHash, content, options);
29
- };
@@ -1,20 +0,0 @@
1
- import { Emoji } from "applesauce-core/event-factory";
2
- import { EventBlueprint } from "applesauce-core/event-factory";
3
- import { Rumor } from "../helpers/gift-wrap.js";
4
- export type WrappedMessageBlueprintOptions = {
5
- emojis?: Emoji[];
6
- subject?: string;
7
- };
8
- /**
9
- * A blueprint that creates a wrapped message event to a conversation
10
- * @param participants - The conversation identifier (pubkey1:pubkey2:pubkey3), a users pubkey, or a list of participant pubkeys
11
- * @param message - The message to wrap
12
- * @returns A blueprint that creates a wrapped message event to a conversation
13
- */
14
- export declare function WrappedMessageBlueprint(participants: string | string[], message: string, opts?: WrappedMessageBlueprintOptions): EventBlueprint<Rumor>;
15
- /**
16
- * A blueprint that creates a reply to a wrapped message event
17
- * @param message - The message to wrap
18
- * @returns A blueprint that creates a wrapped message event to a conversation
19
- */
20
- export declare function WrappedMessageReplyBlueprint(parent: Rumor, message: string, opts?: WrappedMessageBlueprintOptions): EventBlueprint<Rumor>;
@@ -1,64 +0,0 @@
1
- import { blueprint } from "applesauce-core/event-factory";
2
- import { kinds } from "applesauce-core/helpers/event";
3
- import { repairNostrLinks, setContent } from "applesauce-core/operations";
4
- import { setConversation, setParent, setSubject } from "../operations/wrapped-message.js";
5
- import { includeEmojis } from "applesauce-core/operations/content";
6
- import { toRumor } from "../operations/gift-wrap.js";
7
- import { getConversationParticipants } from "../helpers/messages.js";
8
- /**
9
- * A blueprint that creates a wrapped message event to a conversation
10
- * @param participants - The conversation identifier (pubkey1:pubkey2:pubkey3), a users pubkey, or a list of participant pubkeys
11
- * @param message - The message to wrap
12
- * @returns A blueprint that creates a wrapped message event to a conversation
13
- */
14
- export function WrappedMessageBlueprint(participants, message, opts) {
15
- return async (context) => {
16
- if (!context.signer)
17
- throw new Error("Missing signer");
18
- const self = await context.signer.getPublicKey();
19
- return blueprint(kinds.PrivateDirectMessage,
20
- // set text content
21
- setContent(message),
22
- // fix @ mentions
23
- repairNostrLinks(),
24
- // Include the "p" tags for the conversation
25
- setConversation(participants, self),
26
- // include "emoji" tags
27
- opts?.emojis ? includeEmojis(opts.emojis) : undefined,
28
- // Include the subject if provided
29
- opts?.subject ? setSubject(opts.subject) : undefined,
30
- // Convert the event to a rumor
31
- toRumor())(context);
32
- };
33
- }
34
- /**
35
- * A blueprint that creates a reply to a wrapped message event
36
- * @param message - The message to wrap
37
- * @returns A blueprint that creates a wrapped message event to a conversation
38
- */
39
- export function WrappedMessageReplyBlueprint(parent, message, opts) {
40
- return async (context) => {
41
- if (typeof parent !== "string" && parent.kind !== kinds.PrivateDirectMessage)
42
- throw new Error("Parent must be a wrapped message event (kind 14)");
43
- if (!context.signer)
44
- throw new Error("Missing signer");
45
- const self = await context.signer.getPublicKey();
46
- // Get the identifier for the conversation
47
- const participants = getConversationParticipants(parent);
48
- return blueprint(kinds.PrivateDirectMessage,
49
- // set text content
50
- setContent(message),
51
- // fix @ mentions
52
- repairNostrLinks(),
53
- // Include the "p" tags for the conversation
54
- setConversation(participants, self),
55
- // Include the parent message id
56
- setParent(parent),
57
- // include "emoji" tags
58
- opts?.emojis ? includeEmojis(opts.emojis) : undefined,
59
- // Include the subject if provided
60
- opts?.subject ? setSubject(opts.subject) : undefined,
61
- // Convert the event to a rumor
62
- toRumor())(context);
63
- };
64
- }
@@ -1,16 +0,0 @@
1
- import { EventBlueprint } from "applesauce-core/event-factory";
2
- import { MetaTagOptions } from "applesauce-core/operations";
3
- import { ZapOptions } from "../operations/zap-split.js";
4
- export type ZapGoalBlueprintOptions = MetaTagOptions & ZapOptions & {
5
- /** Unix timestamp when the goal closes */
6
- closedAt?: number;
7
- /** Image URL for the goal */
8
- image?: string;
9
- /** Brief summary of the goal */
10
- summary?: string;
11
- };
12
- /**
13
- * NIP-75 Zap Goal event (kind 9041) blueprint
14
- * Creates a zap goal event with description, target amount, and relays
15
- */
16
- export declare function ZapGoalBlueprint(description: string, amount: number, relays: string[], opts?: ZapGoalBlueprintOptions): EventBlueprint;
@@ -1,12 +0,0 @@
1
- import { blueprint } from "applesauce-core/event-factory";
2
- import { setContent, setMetaTags } from "applesauce-core/operations";
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
- /**
7
- * NIP-75 Zap Goal event (kind 9041) blueprint
8
- * Creates a zap goal event with description, target amount, and relays
9
- */
10
- export function ZapGoalBlueprint(description, amount, relays, opts) {
11
- return blueprint(ZAP_GOAL_KIND, setContent(description), ZapGoal.setAmount(amount), ZapGoal.setRelays(relays), opts?.closedAt ? ZapGoal.setClosedAt(opts.closedAt) : undefined, opts?.image ? ZapGoal.setImage(opts.image) : undefined, opts?.summary ? ZapGoal.setSummary(opts.summary) : undefined, setZapSplit(opts), setMetaTags({ ...opts, alt: opts?.alt ?? `Zap Goal: ${opts?.summary || description}` }));
12
- }
@@ -1,2 +0,0 @@
1
- import "./models/__register__.js";
2
- import "./blueprints/__register__.js";
package/dist/register.js DELETED
@@ -1,4 +0,0 @@
1
- // Import models that should register with the event store
2
- import "./models/__register__.js";
3
- // Import blueprints that should register with the event factory
4
- import "./blueprints/__register__.js";