applesauce-common 6.1.0 → 7.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 (231) hide show
  1. package/README.md +1 -0
  2. package/dist/casts/_circular-import.d.ts +3 -0
  3. package/dist/casts/_circular-import.js +3 -0
  4. package/dist/casts/app-handler.d.ts +56 -0
  5. package/dist/casts/app-handler.js +105 -0
  6. package/dist/casts/app-recommendation.d.ts +26 -0
  7. package/dist/casts/app-recommendation.js +41 -0
  8. package/dist/casts/external-identities.d.ts +9 -0
  9. package/dist/casts/external-identities.js +14 -0
  10. package/dist/casts/forum-thread.d.ts +17 -0
  11. package/dist/casts/forum-thread.js +31 -0
  12. package/dist/casts/git-issue.d.ts +18 -0
  13. package/dist/casts/git-issue.js +26 -0
  14. package/dist/casts/git-patch.d.ts +49 -0
  15. package/dist/casts/git-patch.js +88 -0
  16. package/dist/casts/git-pull-request.d.ts +67 -0
  17. package/dist/casts/git-pull-request.js +122 -0
  18. package/dist/casts/git-repository.d.ts +9 -0
  19. package/dist/casts/git-repository.js +16 -0
  20. package/dist/casts/git-thread.d.ts +33 -0
  21. package/dist/casts/git-thread.js +65 -0
  22. package/dist/casts/index.d.ts +11 -0
  23. package/dist/casts/index.js +11 -0
  24. package/dist/casts/napplet.d.ts +98 -0
  25. package/dist/casts/napplet.js +196 -0
  26. package/dist/casts/note.d.ts +8 -0
  27. package/dist/casts/note.js +21 -1
  28. package/dist/casts/nsite.d.ts +134 -0
  29. package/dist/casts/nsite.js +249 -0
  30. package/dist/casts/profile.d.ts +20 -0
  31. package/dist/casts/profile.js +30 -0
  32. package/dist/casts/reaction.d.ts +1 -1
  33. package/dist/casts/relay-discovery.d.ts +4 -0
  34. package/dist/casts/relay-discovery.js +9 -1
  35. package/dist/casts/report.d.ts +28 -15
  36. package/dist/casts/report.js +42 -19
  37. package/dist/casts/share.d.ts +1 -1
  38. package/dist/casts/torrent.d.ts +5 -0
  39. package/dist/casts/torrent.js +8 -1
  40. package/dist/casts/trusted-assertions.d.ts +4 -2
  41. package/dist/casts/trusted-assertions.js +20 -19
  42. package/dist/casts/user-status.d.ts +33 -0
  43. package/dist/casts/user-status.js +69 -0
  44. package/dist/casts/user.d.ts +7 -0
  45. package/dist/casts/user.js +20 -1
  46. package/dist/factories/app-handler.d.ts +31 -0
  47. package/dist/factories/app-handler.js +50 -0
  48. package/dist/factories/app-recommendation.d.ts +21 -0
  49. package/dist/factories/app-recommendation.js +28 -0
  50. package/dist/factories/chat-message.d.ts +37 -0
  51. package/dist/factories/chat-message.js +56 -0
  52. package/dist/factories/comment.d.ts +8 -7
  53. package/dist/factories/comment.js +2 -2
  54. package/dist/factories/external-identities.d.ts +17 -0
  55. package/dist/factories/external-identities.js +28 -0
  56. package/dist/factories/forum-thread.d.ts +34 -0
  57. package/dist/factories/forum-thread.js +50 -0
  58. package/dist/factories/git-applied-status.d.ts +39 -0
  59. package/dist/factories/git-applied-status.js +53 -0
  60. package/dist/factories/git-closed-status.d.ts +18 -0
  61. package/dist/factories/git-closed-status.js +24 -0
  62. package/dist/factories/git-draft-status.d.ts +18 -0
  63. package/dist/factories/git-draft-status.js +24 -0
  64. package/dist/factories/git-issue.d.ts +19 -0
  65. package/dist/factories/git-issue.js +25 -0
  66. package/dist/factories/git-open-status.d.ts +18 -0
  67. package/dist/factories/git-open-status.js +22 -0
  68. package/dist/factories/git-patch.d.ts +59 -0
  69. package/dist/factories/git-patch.js +102 -0
  70. package/dist/factories/git-pull-request-update.d.ts +23 -0
  71. package/dist/factories/git-pull-request-update.js +33 -0
  72. package/dist/factories/git-pull-request.d.ts +39 -0
  73. package/dist/factories/git-pull-request.js +64 -0
  74. package/dist/factories/index.d.ts +23 -0
  75. package/dist/factories/index.js +23 -0
  76. package/dist/factories/internal/git-pull-request.d.ts +19 -0
  77. package/dist/factories/internal/git-pull-request.js +26 -0
  78. package/dist/factories/internal/git-status.d.ts +11 -0
  79. package/dist/factories/internal/git-status.js +12 -0
  80. package/dist/factories/internal/git-thread.d.ts +19 -0
  81. package/dist/factories/internal/git-thread.js +29 -0
  82. package/dist/factories/internal/napplet-manifest.d.ts +52 -0
  83. package/dist/factories/internal/napplet-manifest.js +85 -0
  84. package/dist/factories/internal/nsite-manifest.d.ts +45 -0
  85. package/dist/factories/internal/nsite-manifest.js +68 -0
  86. package/dist/factories/legacy-message.d.ts +2 -0
  87. package/dist/factories/legacy-message.js +9 -2
  88. package/dist/factories/named-napplet.d.ts +20 -0
  89. package/dist/factories/named-napplet.js +30 -0
  90. package/dist/factories/named-nsite.d.ts +28 -0
  91. package/dist/factories/named-nsite.js +53 -0
  92. package/dist/factories/napplet-snapshot.d.ts +18 -0
  93. package/dist/factories/napplet-snapshot.js +38 -0
  94. package/dist/factories/nostr-web-token.d.ts +39 -0
  95. package/dist/factories/nostr-web-token.js +95 -0
  96. package/dist/factories/nsite-snapshot.d.ts +18 -0
  97. package/dist/factories/nsite-snapshot.js +29 -0
  98. package/dist/factories/reaction.d.ts +3 -2
  99. package/dist/factories/report.d.ts +48 -0
  100. package/dist/factories/report.js +66 -0
  101. package/dist/factories/root-napplet.d.ts +18 -0
  102. package/dist/factories/root-napplet.js +24 -0
  103. package/dist/factories/root-nsite.d.ts +23 -0
  104. package/dist/factories/root-nsite.js +44 -0
  105. package/dist/factories/torrent.d.ts +24 -10
  106. package/dist/factories/torrent.js +48 -44
  107. package/dist/factories/trusted-provider-list.d.ts +23 -0
  108. package/dist/factories/trusted-provider-list.js +39 -0
  109. package/dist/factories/user-status.d.ts +26 -0
  110. package/dist/factories/user-status.js +52 -0
  111. package/dist/helpers/app-data.js +15 -7
  112. package/dist/helpers/app-handler.d.ts +43 -6
  113. package/dist/helpers/app-handler.js +53 -3
  114. package/dist/helpers/app-recommendation.d.ts +24 -0
  115. package/dist/helpers/app-recommendation.js +30 -0
  116. package/dist/helpers/bookmark.js +5 -2
  117. package/dist/helpers/comment.d.ts +11 -5
  118. package/dist/helpers/comment.js +7 -1
  119. package/dist/helpers/content.d.ts +3 -1
  120. package/dist/helpers/emoji-pack.js +11 -6
  121. package/dist/helpers/emoji.d.ts +2 -2
  122. package/dist/helpers/encrypted-content-cache.js +18 -1
  123. package/dist/helpers/external-id.d.ts +1 -0
  124. package/dist/helpers/external-id.js +21 -46
  125. package/dist/helpers/external-identities.d.ts +29 -0
  126. package/dist/helpers/external-identities.js +52 -0
  127. package/dist/helpers/file-metadata.js +5 -6
  128. package/dist/helpers/forum-thread.d.ts +10 -0
  129. package/dist/helpers/forum-thread.js +10 -0
  130. package/dist/helpers/gift-wrap.d.ts +40 -15
  131. package/dist/helpers/gift-wrap.js +110 -33
  132. package/dist/helpers/git-issue.d.ts +13 -0
  133. package/dist/helpers/git-issue.js +19 -0
  134. package/dist/helpers/git-patch.d.ts +41 -0
  135. package/dist/helpers/git-patch.js +73 -0
  136. package/dist/helpers/git-pull-request.d.ts +57 -0
  137. package/dist/helpers/git-pull-request.js +111 -0
  138. package/dist/helpers/git-repository.d.ts +4 -0
  139. package/dist/helpers/git-repository.js +16 -0
  140. package/dist/helpers/git-status.d.ts +44 -0
  141. package/dist/helpers/git-status.js +93 -0
  142. package/dist/helpers/git.d.ts +2 -0
  143. package/dist/helpers/git.js +4 -0
  144. package/dist/helpers/groups.d.ts +5 -2
  145. package/dist/helpers/groups.js +40 -18
  146. package/dist/helpers/hashtag.d.ts +4 -2
  147. package/dist/helpers/index.d.ts +11 -0
  148. package/dist/helpers/index.js +11 -0
  149. package/dist/helpers/lists.js +14 -2
  150. package/dist/helpers/lnurl.js +1 -1
  151. package/dist/helpers/mute.js +18 -7
  152. package/dist/helpers/napplet.d.ts +89 -0
  153. package/dist/helpers/napplet.js +144 -0
  154. package/dist/helpers/nostr-web-token.d.ts +54 -0
  155. package/dist/helpers/nostr-web-token.js +124 -0
  156. package/dist/helpers/nsite.d.ts +90 -0
  157. package/dist/helpers/nsite.js +217 -0
  158. package/dist/helpers/relay-discovery.d.ts +4 -0
  159. package/dist/helpers/relay-discovery.js +8 -0
  160. package/dist/helpers/reports.d.ts +35 -0
  161. package/dist/helpers/reports.js +36 -5
  162. package/dist/helpers/threading.d.ts +4 -2
  163. package/dist/helpers/torrent.d.ts +9 -6
  164. package/dist/helpers/torrent.js +23 -15
  165. package/dist/helpers/trusted-assertions.d.ts +7 -0
  166. package/dist/helpers/trusted-assertions.js +41 -2
  167. package/dist/helpers/user-status.d.ts +13 -1
  168. package/dist/helpers/user-status.js +15 -0
  169. package/dist/models/app-handler.d.ts +21 -0
  170. package/dist/models/app-handler.js +47 -0
  171. package/dist/models/git.d.ts +34 -0
  172. package/dist/models/git.js +144 -0
  173. package/dist/models/index.d.ts +3 -0
  174. package/dist/models/index.js +3 -0
  175. package/dist/models/nsite.d.ts +22 -0
  176. package/dist/models/nsite.js +67 -0
  177. package/dist/models/thread.d.ts +4 -1
  178. package/dist/models/thread.js +34 -5
  179. package/dist/models/user-status.d.ts +8 -4
  180. package/dist/models/user-status.js +16 -22
  181. package/dist/observable/filter-timeline-by-mutes.d.ts +1 -1
  182. package/dist/observable/filter-timeline-by-mutes.js +5 -1
  183. package/dist/operations/app-handler.d.ts +24 -0
  184. package/dist/operations/app-handler.js +58 -0
  185. package/dist/operations/app-recommendation.d.ts +13 -0
  186. package/dist/operations/app-recommendation.js +40 -0
  187. package/dist/operations/calendar-event.js +3 -2
  188. package/dist/operations/chat-message.d.ts +9 -0
  189. package/dist/operations/chat-message.js +12 -0
  190. package/dist/operations/client.d.ts +1 -4
  191. package/dist/operations/client.js +1 -23
  192. package/dist/operations/comment.d.ts +9 -3
  193. package/dist/operations/comment.js +12 -9
  194. package/dist/operations/external-identities.d.ts +8 -0
  195. package/dist/operations/external-identities.js +23 -0
  196. package/dist/operations/forum-thread.d.ts +3 -0
  197. package/dist/operations/forum-thread.js +6 -0
  198. package/dist/operations/gift-wrap.js +38 -14
  199. package/dist/operations/git-issue.d.ts +18 -0
  200. package/dist/operations/git-issue.js +31 -0
  201. package/dist/operations/git-patch.d.ts +30 -0
  202. package/dist/operations/git-patch.js +75 -0
  203. package/dist/operations/git-pull-request.d.ts +29 -0
  204. package/dist/operations/git-pull-request.js +74 -0
  205. package/dist/operations/git-repository.js +4 -4
  206. package/dist/operations/git-status.d.ts +28 -0
  207. package/dist/operations/git-status.js +116 -0
  208. package/dist/operations/git-thread.d.ts +13 -0
  209. package/dist/operations/git-thread.js +39 -0
  210. package/dist/operations/index.d.ts +16 -0
  211. package/dist/operations/index.js +16 -0
  212. package/dist/operations/internal/git-commits.d.ts +2 -0
  213. package/dist/operations/internal/git-commits.js +16 -0
  214. package/dist/operations/napplet.d.ts +51 -0
  215. package/dist/operations/napplet.js +121 -0
  216. package/dist/operations/nostr-web-token.d.ts +27 -0
  217. package/dist/operations/nostr-web-token.js +58 -0
  218. package/dist/operations/nsite.d.ts +51 -0
  219. package/dist/operations/nsite.js +112 -0
  220. package/dist/operations/reaction.d.ts +12 -2
  221. package/dist/operations/reaction.js +1 -1
  222. package/dist/operations/report.d.ts +33 -0
  223. package/dist/operations/report.js +60 -0
  224. package/dist/operations/stream.js +5 -4
  225. package/dist/operations/torrent.d.ts +1 -4
  226. package/dist/operations/torrent.js +24 -11
  227. package/dist/operations/trusted-providers.d.ts +14 -0
  228. package/dist/operations/trusted-providers.js +33 -0
  229. package/dist/operations/user-status.d.ts +11 -0
  230. package/dist/operations/user-status.js +29 -0
  231. package/package.json +10 -10
@@ -0,0 +1,37 @@
1
+ import { EventFactory } from "applesauce-core/factories";
2
+ import { kinds, KnownEventTemplate, NostrEvent } from "applesauce-core/helpers";
3
+ import { EventPointer, ProfilePointer } from "applesauce-core/helpers/pointers";
4
+ import { TextContentOptions } from "applesauce-core/operations/content";
5
+ import { FileMetadataFields } from "../helpers/file-metadata.js";
6
+ import { Emoji } from "../helpers/emoji.js";
7
+ export type ChatMessageTemplate = KnownEventTemplate<kinds.ChatMessage>;
8
+ export type ChatMessageFactoryOptions = TextContentOptions;
9
+ /**
10
+ * A factory class for building NIP-C7 kind 9 chat message events. Replies are
11
+ * additional kind 9 events that quote their parent with a `q` tag.
12
+ */
13
+ export declare class ChatMessageFactory extends EventFactory<kinds.ChatMessage, ChatMessageTemplate> {
14
+ /**
15
+ * Creates a new chat message factory
16
+ * @param content - Optional initial message content
17
+ * @param options - Optional content options
18
+ */
19
+ static create(content?: string, options?: ChatMessageFactoryOptions): ChatMessageFactory;
20
+ /**
21
+ * Creates a chat message factory configured as a reply to another chat message
22
+ * @param parent - The parent chat message being replied to
23
+ * @param content - Optional initial message content
24
+ * @param options - Optional content options
25
+ */
26
+ static reply(parent: NostrEvent | EventPointer, content?: string, options?: ChatMessageFactoryOptions): ChatMessageFactory;
27
+ /** Sets the message content, tagging mentions (NIP-C7), quotes (NIP-18), and custom emojis (NIP-30) */
28
+ text(content: string, options?: ChatMessageFactoryOptions): this;
29
+ /** Adds the NIP-C7 `q` reply tag pointing at the parent message */
30
+ replyTo(parent: NostrEvent | EventPointer): this;
31
+ /** Adds a "p" mention tag for a pubkey or ProfilePointer */
32
+ mention(pubkey: string | ProfilePointer): this;
33
+ /** Adds NIP-92 "imeta" tags for media attachments */
34
+ attachments(attachments: FileMetadataFields[]): this;
35
+ /** Adds NIP-30 "emoji" tags for custom emojis */
36
+ emojis(emojis: Emoji[]): this;
37
+ }
@@ -0,0 +1,56 @@
1
+ import { blankEventTemplate, EventFactory } from "applesauce-core/factories";
2
+ import { kinds } from "applesauce-core/helpers";
3
+ import { ensureProfilePointerTag } from "applesauce-core/helpers/factory";
4
+ import { includeEmojis, setShortTextContent } from "applesauce-core/operations/content";
5
+ import { includeChatReply } from "../operations/chat-message.js";
6
+ import { addMediaAttachments } from "../operations/media-attachment.js";
7
+ /**
8
+ * A factory class for building NIP-C7 kind 9 chat message events. Replies are
9
+ * additional kind 9 events that quote their parent with a `q` tag.
10
+ */
11
+ export class ChatMessageFactory extends EventFactory {
12
+ /**
13
+ * Creates a new chat message factory
14
+ * @param content - Optional initial message content
15
+ * @param options - Optional content options
16
+ */
17
+ static create(content, options) {
18
+ let factory = new ChatMessageFactory((res) => res(blankEventTemplate(kinds.ChatMessage)));
19
+ if (content !== undefined)
20
+ factory = factory.text(content, options);
21
+ return factory;
22
+ }
23
+ /**
24
+ * Creates a chat message factory configured as a reply to another chat message
25
+ * @param parent - The parent chat message being replied to
26
+ * @param content - Optional initial message content
27
+ * @param options - Optional content options
28
+ */
29
+ static reply(parent, content, options) {
30
+ let factory = new ChatMessageFactory((res) => res(blankEventTemplate(kinds.ChatMessage))).replyTo(parent);
31
+ if (content !== undefined)
32
+ factory = factory.text(content, options);
33
+ return factory;
34
+ }
35
+ /** Sets the message content, tagging mentions (NIP-C7), quotes (NIP-18), and custom emojis (NIP-30) */
36
+ text(content, options) {
37
+ return this.chain(setShortTextContent(content, options));
38
+ }
39
+ /** Adds the NIP-C7 `q` reply tag pointing at the parent message */
40
+ replyTo(parent) {
41
+ return this.chain(includeChatReply(parent));
42
+ }
43
+ /** Adds a "p" mention tag for a pubkey or ProfilePointer */
44
+ mention(pubkey) {
45
+ const pointer = typeof pubkey === "string" ? { pubkey } : pubkey;
46
+ return this.modifyPublicTags((tags) => ensureProfilePointerTag(tags, pointer));
47
+ }
48
+ /** Adds NIP-92 "imeta" tags for media attachments */
49
+ attachments(attachments) {
50
+ return this.chain(addMediaAttachments(attachments));
51
+ }
52
+ /** Adds NIP-30 "emoji" tags for custom emojis */
53
+ emojis(emojis) {
54
+ return this.chain(includeEmojis(emojis));
55
+ }
56
+ }
@@ -1,18 +1,19 @@
1
1
  import { EventFactory } from "applesauce-core/factories";
2
- import { KnownEventTemplate, NostrEvent } from "applesauce-core/helpers";
2
+ import { KnownEventTemplate } from "applesauce-core/helpers";
3
3
  import { TextContentOptions } from "applesauce-core/operations/content";
4
4
  import { MetaTagOptions } from "applesauce-core/operations/event";
5
- import { COMMENT_KIND, CommentPointer } from "../helpers/comment.js";
5
+ import { COMMENT_KIND } from "../helpers/comment.js";
6
+ import { CommentParent } from "../operations/comment.js";
6
7
  import { GroupPointer } from "../helpers/groups.js";
7
8
  export type CommentTemplate = KnownEventTemplate<typeof COMMENT_KIND>;
8
9
  export type CommentFactoryOptions = TextContentOptions & MetaTagOptions;
9
10
  export declare class CommentFactory extends EventFactory<typeof COMMENT_KIND, CommentTemplate> {
10
11
  /** Creates a new comment event */
11
- static create(parent: NostrEvent | CommentPointer, content: string, options?: CommentFactoryOptions): CommentFactory;
12
- /** Creates a new comment that is replying to a parent event or pointer */
13
- static reply(parent: NostrEvent | CommentPointer, content: string, options?: CommentFactoryOptions): CommentFactory;
14
- /** Sets the parent event or pointer that this comment is replying to */
15
- parent(parent: NostrEvent | CommentPointer): this;
12
+ static create(parent: CommentParent, content: string, options?: CommentFactoryOptions): CommentFactory;
13
+ /** Creates a new comment that is replying to a parent event, rumor, or pointer */
14
+ static reply(parent: CommentParent, content: string, options?: CommentFactoryOptions): CommentFactory;
15
+ /** Sets the parent event, rumor, or pointer that this comment is replying to */
16
+ parent(parent: CommentParent): this;
16
17
  /** Sets the text content of the comment */
17
18
  text(content: string, options?: TextContentOptions): this;
18
19
  /** Sets the NIP-29 group pointer "h" tag for this comment */
@@ -14,7 +14,7 @@ export class CommentFactory extends EventFactory {
14
14
  factory.meta(options);
15
15
  return factory;
16
16
  }
17
- /** Creates a new comment that is replying to a parent event or pointer */
17
+ /** Creates a new comment that is replying to a parent event, rumor, or pointer */
18
18
  static reply(parent, content, options) {
19
19
  let factory = new CommentFactory((res) => res(blankEventTemplate(COMMENT_KIND)))
20
20
  .parent(parent)
@@ -23,7 +23,7 @@ export class CommentFactory extends EventFactory {
23
23
  factory.meta(options);
24
24
  return factory;
25
25
  }
26
- /** Sets the parent event or pointer that this comment is replying to */
26
+ /** Sets the parent event, rumor, or pointer that this comment is replying to */
27
27
  parent(parent) {
28
28
  return this.chain(setParent(parent));
29
29
  }
@@ -0,0 +1,17 @@
1
+ import { EventFactory } from "applesauce-core/factories";
2
+ import { KnownEventTemplate, NostrEvent } from "applesauce-core/helpers";
3
+ import { EXTERNAL_IDENTITIES_KIND, ExternalIdentity } from "../helpers/external-identities.js";
4
+ export type ExternalIdentitiesTemplate = KnownEventTemplate<typeof EXTERNAL_IDENTITIES_KIND>;
5
+ /** Factory for NIP-39 external identity lists */
6
+ export declare class ExternalIdentitiesFactory extends EventFactory<typeof EXTERNAL_IDENTITIES_KIND, ExternalIdentitiesTemplate> {
7
+ /** Creates an external identities factory */
8
+ static create(identities?: ExternalIdentity[]): ExternalIdentitiesFactory;
9
+ /** Creates a factory configured to modify an existing external identities list */
10
+ static modify(event: NostrEvent): ExternalIdentitiesFactory;
11
+ /** Replaces all external identities */
12
+ setIdentities(identities: ExternalIdentity[]): this;
13
+ /** Adds or replaces an external identity */
14
+ addIdentity(identity: ExternalIdentity): this;
15
+ /** Removes an external identity */
16
+ removeIdentity(platform: string, identity: string): this;
17
+ }
@@ -0,0 +1,28 @@
1
+ import { blankEventTemplate, EventFactory, toEventTemplate } from "applesauce-core/factories";
2
+ import { EXTERNAL_IDENTITIES_KIND } from "../helpers/external-identities.js";
3
+ import { addExternalIdentity, removeExternalIdentity, setExternalIdentities, } from "../operations/external-identities.js";
4
+ /** Factory for NIP-39 external identity lists */
5
+ export class ExternalIdentitiesFactory extends EventFactory {
6
+ /** Creates an external identities factory */
7
+ static create(identities = []) {
8
+ return new ExternalIdentitiesFactory((res) => res(blankEventTemplate(EXTERNAL_IDENTITIES_KIND))).setIdentities(identities);
9
+ }
10
+ /** Creates a factory configured to modify an existing external identities list */
11
+ static modify(event) {
12
+ if (event.kind !== EXTERNAL_IDENTITIES_KIND)
13
+ throw new Error("Expected an external identities event");
14
+ return new ExternalIdentitiesFactory((res) => res(toEventTemplate(event)));
15
+ }
16
+ /** Replaces all external identities */
17
+ setIdentities(identities) {
18
+ return this.chain(setExternalIdentities(identities));
19
+ }
20
+ /** Adds or replaces an external identity */
21
+ addIdentity(identity) {
22
+ return this.chain(addExternalIdentity(identity));
23
+ }
24
+ /** Removes an external identity */
25
+ removeIdentity(platform, identity) {
26
+ return this.chain(removeExternalIdentity(platform, identity));
27
+ }
28
+ }
@@ -0,0 +1,34 @@
1
+ import { EventFactory } from "applesauce-core/factories";
2
+ import { KnownEventTemplate } from "applesauce-core/helpers";
3
+ import { ProfilePointer } from "applesauce-core/helpers/pointers";
4
+ import { TextContentOptions } from "applesauce-core/operations/content";
5
+ import { FORUM_THREAD_KIND } from "../helpers/forum-thread.js";
6
+ import { Emoji } from "../helpers/emoji.js";
7
+ export type ForumThreadTemplate = KnownEventTemplate<typeof FORUM_THREAD_KIND>;
8
+ export type ForumThreadFactoryOptions = TextContentOptions;
9
+ /**
10
+ * A factory class for building NIP-7D forum thread events (kind 11). Replies to
11
+ * a thread are NIP-22 kind 1111 comments to the root — build them with the
12
+ * `CommentFactory` (`CommentFactory.create(thread, body)`).
13
+ */
14
+ export declare class ForumThreadFactory extends EventFactory<typeof FORUM_THREAD_KIND, ForumThreadTemplate> {
15
+ /**
16
+ * Creates a new forum thread factory
17
+ * @param title - The thread title (NIP-7D `title` tag)
18
+ * @param content - Optional initial thread body
19
+ * @param options - Optional content options
20
+ */
21
+ static create(title: string, content?: string, options?: ForumThreadFactoryOptions): ForumThreadFactory;
22
+ /** Sets the NIP-7D `title` tag */
23
+ title(title: string): this;
24
+ /** Sets the thread body, tagging mentions, quotes, hashtags, and custom emojis */
25
+ text(content: string, options?: ForumThreadFactoryOptions): this;
26
+ /** Adds a "p" mention tag for a pubkey or ProfilePointer */
27
+ mention(pubkey: string | ProfilePointer): this;
28
+ /** Adds a hashtag "t" tag */
29
+ addHashtag(hashtag: string): this;
30
+ /** Adds multiple hashtags as "t" tags */
31
+ hashtags(tags: string[]): this;
32
+ /** Adds NIP-30 "emoji" tags for custom emojis */
33
+ emojis(emojis: Emoji[]): this;
34
+ }
@@ -0,0 +1,50 @@
1
+ import { blankEventTemplate, EventFactory } from "applesauce-core/factories";
2
+ import { ensureProfilePointerTag } from "applesauce-core/helpers/factory";
3
+ import { includeEmojis, setShortTextContent } from "applesauce-core/operations/content";
4
+ import { FORUM_THREAD_KIND } from "../helpers/forum-thread.js";
5
+ import { setTitle } from "../operations/forum-thread.js";
6
+ import { addHashtag, includeHashtags } from "../operations/hashtags.js";
7
+ /**
8
+ * A factory class for building NIP-7D forum thread events (kind 11). Replies to
9
+ * a thread are NIP-22 kind 1111 comments to the root — build them with the
10
+ * `CommentFactory` (`CommentFactory.create(thread, body)`).
11
+ */
12
+ export class ForumThreadFactory extends EventFactory {
13
+ /**
14
+ * Creates a new forum thread factory
15
+ * @param title - The thread title (NIP-7D `title` tag)
16
+ * @param content - Optional initial thread body
17
+ * @param options - Optional content options
18
+ */
19
+ static create(title, content, options) {
20
+ let factory = new ForumThreadFactory((res) => res(blankEventTemplate(FORUM_THREAD_KIND))).title(title);
21
+ if (content !== undefined)
22
+ factory = factory.text(content, options);
23
+ return factory;
24
+ }
25
+ /** Sets the NIP-7D `title` tag */
26
+ title(title) {
27
+ return this.chain(setTitle(title));
28
+ }
29
+ /** Sets the thread body, tagging mentions, quotes, hashtags, and custom emojis */
30
+ text(content, options) {
31
+ return this.chain(setShortTextContent(content, options));
32
+ }
33
+ /** Adds a "p" mention tag for a pubkey or ProfilePointer */
34
+ mention(pubkey) {
35
+ const pointer = typeof pubkey === "string" ? { pubkey } : pubkey;
36
+ return this.modifyPublicTags((tags) => ensureProfilePointerTag(tags, pointer));
37
+ }
38
+ /** Adds a hashtag "t" tag */
39
+ addHashtag(hashtag) {
40
+ return this.chain(addHashtag(hashtag));
41
+ }
42
+ /** Adds multiple hashtags as "t" tags */
43
+ hashtags(tags) {
44
+ return this.chain(includeHashtags(tags));
45
+ }
46
+ /** Adds NIP-30 "emoji" tags for custom emojis */
47
+ emojis(emojis) {
48
+ return this.chain(includeEmojis(emojis));
49
+ }
50
+ }
@@ -0,0 +1,39 @@
1
+ import { KnownEventTemplate, NostrEvent } from "applesauce-core/helpers/event";
2
+ import { GIT_STATUS_APPLIED_KIND } from "../helpers/git-status.js";
3
+ import { GitStatusTargetFactory } from "./internal/git-status.js";
4
+ import { EventPointer } from "applesauce-core/helpers/pointers";
5
+ /** An event template for a NIP-34 applied status */
6
+ export type GitAppliedStatusTemplate = KnownEventTemplate<typeof GIT_STATUS_APPLIED_KIND>;
7
+ /** A factory for NIP-34 applied statuses (kind 1631) */
8
+ export declare class GitAppliedStatusFactory extends GitStatusTargetFactory<typeof GIT_STATUS_APPLIED_KIND> {
9
+ /**
10
+ * Creates a applied status for an original thread root
11
+ * @throws if the target is not a supported original root
12
+ */
13
+ static create(root: NostrEvent, content?: string): GitAppliedStatusFactory;
14
+ /**
15
+ * Creates a factory for modifying a applied status draft
16
+ * @throws if the event is not a valid applied status
17
+ */
18
+ static modify(event: NostrEvent): GitAppliedStatusFactory;
19
+ /**
20
+ * Sets or removes the accepted revision
21
+ * @throws if the patch is not a revision of this status root
22
+ */
23
+ acceptedRevision(revision: NostrEvent | null, relay?: string): this;
24
+ /**
25
+ * Replaces the applied patch references
26
+ * @throws if a patch id is invalid
27
+ */
28
+ appliedPatches(patches: (string | EventPointer)[]): this;
29
+ /**
30
+ * Replaces the applied commit ids
31
+ * @throws if a commit is not a Git object id
32
+ */
33
+ appliedCommits(commits: string[]): this;
34
+ /**
35
+ * Sets or removes the merge commit
36
+ * @throws if the commit is not a Git object id
37
+ */
38
+ mergeCommit(commit: string | null): this;
39
+ }
@@ -0,0 +1,53 @@
1
+ import { blankEventTemplate, toEventTemplate } from "applesauce-core/factories";
2
+ import { GIT_STATUS_APPLIED_KIND, isValidGitStatus } from "../helpers/git-status.js";
3
+ import { GitStatusTargetFactory } from "./internal/git-status.js";
4
+ import { setGitStatusAcceptedRevision, setGitStatusAppliedPatches, setGitStatusAppliedCommits, setGitStatusMergeCommit, } from "../operations/git-status.js";
5
+ /** A factory for NIP-34 applied statuses (kind 1631) */
6
+ export class GitAppliedStatusFactory extends GitStatusTargetFactory {
7
+ /**
8
+ * Creates a applied status for an original thread root
9
+ * @throws if the target is not a supported original root
10
+ */
11
+ static create(root, content = "") {
12
+ return new GitAppliedStatusFactory((res) => res(blankEventTemplate(GIT_STATUS_APPLIED_KIND)))
13
+ .root(root)
14
+ .content(content);
15
+ }
16
+ /**
17
+ * Creates a factory for modifying a applied status draft
18
+ * @throws if the event is not a valid applied status
19
+ */
20
+ static modify(event) {
21
+ if (!isValidGitStatus(event) || event.kind !== GIT_STATUS_APPLIED_KIND)
22
+ throw new Error("Expected a applied status");
23
+ return new GitAppliedStatusFactory((res) => res(toEventTemplate({ ...event, kind: GIT_STATUS_APPLIED_KIND })));
24
+ }
25
+ /**
26
+ * Sets or removes the accepted revision
27
+ * @throws if the patch is not a revision of this status root
28
+ */
29
+ acceptedRevision(revision, relay) {
30
+ return this.chain(setGitStatusAcceptedRevision(revision, relay));
31
+ }
32
+ /**
33
+ * Replaces the applied patch references
34
+ * @throws if a patch id is invalid
35
+ */
36
+ appliedPatches(patches) {
37
+ return this.chain(setGitStatusAppliedPatches(patches));
38
+ }
39
+ /**
40
+ * Replaces the applied commit ids
41
+ * @throws if a commit is not a Git object id
42
+ */
43
+ appliedCommits(commits) {
44
+ return this.chain(setGitStatusAppliedCommits(commits));
45
+ }
46
+ /**
47
+ * Sets or removes the merge commit
48
+ * @throws if the commit is not a Git object id
49
+ */
50
+ mergeCommit(commit) {
51
+ return this.chain(setGitStatusMergeCommit(commit));
52
+ }
53
+ }
@@ -0,0 +1,18 @@
1
+ import { KnownEventTemplate, NostrEvent } from "applesauce-core/helpers/event";
2
+ import { GIT_STATUS_CLOSED_KIND } from "../helpers/git-status.js";
3
+ import { GitStatusTargetFactory } from "./internal/git-status.js";
4
+ /** An event template for a NIP-34 closed status */
5
+ export type GitClosedStatusTemplate = KnownEventTemplate<typeof GIT_STATUS_CLOSED_KIND>;
6
+ /** A factory for NIP-34 closed statuses (kind 1632) */
7
+ export declare class GitClosedStatusFactory extends GitStatusTargetFactory<typeof GIT_STATUS_CLOSED_KIND> {
8
+ /**
9
+ * Creates a closed status for an original thread root
10
+ * @throws if the target is not a supported original root
11
+ */
12
+ static create(root: NostrEvent, content?: string): GitClosedStatusFactory;
13
+ /**
14
+ * Creates a factory for modifying a closed status draft
15
+ * @throws if the event is not a valid closed status
16
+ */
17
+ static modify(event: NostrEvent): GitClosedStatusFactory;
18
+ }
@@ -0,0 +1,24 @@
1
+ import { blankEventTemplate, toEventTemplate } from "applesauce-core/factories";
2
+ import { GIT_STATUS_CLOSED_KIND, isValidGitStatus } from "../helpers/git-status.js";
3
+ import { GitStatusTargetFactory } from "./internal/git-status.js";
4
+ /** A factory for NIP-34 closed statuses (kind 1632) */
5
+ export class GitClosedStatusFactory extends GitStatusTargetFactory {
6
+ /**
7
+ * Creates a closed status for an original thread root
8
+ * @throws if the target is not a supported original root
9
+ */
10
+ static create(root, content = "") {
11
+ return new GitClosedStatusFactory((res) => res(blankEventTemplate(GIT_STATUS_CLOSED_KIND)))
12
+ .root(root)
13
+ .content(content);
14
+ }
15
+ /**
16
+ * Creates a factory for modifying a closed status draft
17
+ * @throws if the event is not a valid closed status
18
+ */
19
+ static modify(event) {
20
+ if (!isValidGitStatus(event) || event.kind !== GIT_STATUS_CLOSED_KIND)
21
+ throw new Error("Expected a closed status");
22
+ return new GitClosedStatusFactory((res) => res(toEventTemplate({ ...event, kind: GIT_STATUS_CLOSED_KIND })));
23
+ }
24
+ }
@@ -0,0 +1,18 @@
1
+ import { KnownEventTemplate, NostrEvent } from "applesauce-core/helpers/event";
2
+ import { GIT_STATUS_DRAFT_KIND } from "../helpers/git-status.js";
3
+ import { GitStatusTargetFactory } from "./internal/git-status.js";
4
+ /** An event template for a NIP-34 draft status */
5
+ export type GitDraftStatusTemplate = KnownEventTemplate<typeof GIT_STATUS_DRAFT_KIND>;
6
+ /** A factory for NIP-34 draft statuses (kind 1633) */
7
+ export declare class GitDraftStatusFactory extends GitStatusTargetFactory<typeof GIT_STATUS_DRAFT_KIND> {
8
+ /**
9
+ * Creates a draft status for an original thread root
10
+ * @throws if the target is not a supported original root
11
+ */
12
+ static create(root: NostrEvent, content?: string): GitDraftStatusFactory;
13
+ /**
14
+ * Creates a factory for modifying a draft status draft
15
+ * @throws if the event is not a valid draft status
16
+ */
17
+ static modify(event: NostrEvent): GitDraftStatusFactory;
18
+ }
@@ -0,0 +1,24 @@
1
+ import { blankEventTemplate, toEventTemplate } from "applesauce-core/factories";
2
+ import { GIT_STATUS_DRAFT_KIND, isValidGitStatus } from "../helpers/git-status.js";
3
+ import { GitStatusTargetFactory } from "./internal/git-status.js";
4
+ /** A factory for NIP-34 draft statuses (kind 1633) */
5
+ export class GitDraftStatusFactory extends GitStatusTargetFactory {
6
+ /**
7
+ * Creates a draft status for an original thread root
8
+ * @throws if the target is not a supported original root
9
+ */
10
+ static create(root, content = "") {
11
+ return new GitDraftStatusFactory((res) => res(blankEventTemplate(GIT_STATUS_DRAFT_KIND)))
12
+ .root(root)
13
+ .content(content);
14
+ }
15
+ /**
16
+ * Creates a factory for modifying a draft status draft
17
+ * @throws if the event is not a valid draft status
18
+ */
19
+ static modify(event) {
20
+ if (!isValidGitStatus(event) || event.kind !== GIT_STATUS_DRAFT_KIND)
21
+ throw new Error("Expected a draft status");
22
+ return new GitDraftStatusFactory((res) => res(toEventTemplate({ ...event, kind: GIT_STATUS_DRAFT_KIND })));
23
+ }
24
+ }
@@ -0,0 +1,19 @@
1
+ import { KnownEventTemplate, NostrEvent } from "applesauce-core/helpers/event";
2
+ import { GIT_ISSUE_KIND } from "../helpers/git-issue.js";
3
+ import { GitRepositoryPointer } from "../helpers/git-repository.js";
4
+ import { GitThreadFactory } from "./internal/git-thread.js";
5
+ /** An event template for a NIP-34 issue */
6
+ export type GitIssueTemplate = KnownEventTemplate<typeof GIT_ISSUE_KIND>;
7
+ /** A factory for NIP-34 issues (kind 1621) */
8
+ export declare class GitIssueFactory extends GitThreadFactory<typeof GIT_ISSUE_KIND> {
9
+ /**
10
+ * Creates an issue for a repository
11
+ * @throws if the repository is invalid
12
+ */
13
+ static create(repo: GitRepositoryPointer | NostrEvent, subject?: string | null, content?: string): GitIssueFactory;
14
+ /**
15
+ * Creates a factory for modifying an existing issue draft
16
+ * @throws if the event is not a valid issue
17
+ */
18
+ static modify(event: NostrEvent): GitIssueFactory;
19
+ }
@@ -0,0 +1,25 @@
1
+ import { blankEventTemplate, toEventTemplate } from "applesauce-core/factories";
2
+ import { GIT_ISSUE_KIND, isValidGitIssue } from "../helpers/git-issue.js";
3
+ import { GitThreadFactory } from "./internal/git-thread.js";
4
+ /** A factory for NIP-34 issues (kind 1621) */
5
+ export class GitIssueFactory extends GitThreadFactory {
6
+ /**
7
+ * Creates an issue for a repository
8
+ * @throws if the repository is invalid
9
+ */
10
+ static create(repo, subject = null, content = "") {
11
+ return new GitIssueFactory((res) => res(blankEventTemplate(GIT_ISSUE_KIND)))
12
+ .repository(repo)
13
+ .subject(subject)
14
+ .content(content);
15
+ }
16
+ /**
17
+ * Creates a factory for modifying an existing issue draft
18
+ * @throws if the event is not a valid issue
19
+ */
20
+ static modify(event) {
21
+ if (!isValidGitIssue(event))
22
+ throw new Error("Expected a valid git issue");
23
+ return new GitIssueFactory((res) => res(toEventTemplate(event)));
24
+ }
25
+ }
@@ -0,0 +1,18 @@
1
+ import { KnownEventTemplate, NostrEvent } from "applesauce-core/helpers/event";
2
+ import { GIT_STATUS_OPEN_KIND } from "../helpers/git-status.js";
3
+ import { GitStatusTargetFactory } from "./internal/git-status.js";
4
+ /** An event template for a NIP-34 open status */
5
+ export type GitOpenStatusTemplate = KnownEventTemplate<typeof GIT_STATUS_OPEN_KIND>;
6
+ /** A factory for NIP-34 open statuses (kind 1630) */
7
+ export declare class GitOpenStatusFactory extends GitStatusTargetFactory<typeof GIT_STATUS_OPEN_KIND> {
8
+ /**
9
+ * Creates a open status for an original thread root
10
+ * @throws if the target is not a supported original root
11
+ */
12
+ static create(root: NostrEvent, content?: string): GitOpenStatusFactory;
13
+ /**
14
+ * Creates a factory for modifying a open status draft
15
+ * @throws if the event is not a valid open status
16
+ */
17
+ static modify(event: NostrEvent): GitOpenStatusFactory;
18
+ }
@@ -0,0 +1,22 @@
1
+ import { blankEventTemplate, toEventTemplate } from "applesauce-core/factories";
2
+ import { GIT_STATUS_OPEN_KIND, isValidGitStatus } from "../helpers/git-status.js";
3
+ import { GitStatusTargetFactory } from "./internal/git-status.js";
4
+ /** A factory for NIP-34 open statuses (kind 1630) */
5
+ export class GitOpenStatusFactory extends GitStatusTargetFactory {
6
+ /**
7
+ * Creates a open status for an original thread root
8
+ * @throws if the target is not a supported original root
9
+ */
10
+ static create(root, content = "") {
11
+ return new GitOpenStatusFactory((res) => res(blankEventTemplate(GIT_STATUS_OPEN_KIND))).root(root).content(content);
12
+ }
13
+ /**
14
+ * Creates a factory for modifying a open status draft
15
+ * @throws if the event is not a valid open status
16
+ */
17
+ static modify(event) {
18
+ if (!isValidGitStatus(event) || event.kind !== GIT_STATUS_OPEN_KIND)
19
+ throw new Error("Expected a open status");
20
+ return new GitOpenStatusFactory((res) => res(toEventTemplate({ ...event, kind: GIT_STATUS_OPEN_KIND })));
21
+ }
22
+ }
@@ -0,0 +1,59 @@
1
+ import { KnownEventTemplate, NostrEvent } from "applesauce-core/helpers/event";
2
+ import { EventPointer } from "applesauce-core/helpers/pointers";
3
+ import { GIT_PATCH_KIND, GitPatchCommitter } from "../helpers/git-patch.js";
4
+ import { GitRepositoryPointer } from "../helpers/git-repository.js";
5
+ import { GitThreadFactory } from "./internal/git-thread.js";
6
+ /** An event template for a NIP-34 patch */
7
+ export type GitPatchTemplate = KnownEventTemplate<typeof GIT_PATCH_KIND>;
8
+ /** A factory for NIP-34 patches (kind 1617) */
9
+ export declare class GitPatchFactory extends GitThreadFactory<typeof GIT_PATCH_KIND> {
10
+ /**
11
+ * Creates the first patch or cover letter of a new series
12
+ * @throws if the repository is invalid
13
+ */
14
+ static create(repo: GitRepositoryPointer | NostrEvent, content: string): GitPatchFactory;
15
+ /**
16
+ * Creates the next patch in a series
17
+ * @throws if the previous event is not a valid patch
18
+ */
19
+ static next(previous: NostrEvent, content: string): GitPatchFactory;
20
+ /**
21
+ * Creates the first patch of a revision linked to the original root
22
+ * @throws if the original event is not an original root patch
23
+ */
24
+ static revision(original: NostrEvent, content: string): GitPatchFactory;
25
+ /**
26
+ * Creates a factory for modifying a patch draft
27
+ * @throws if the event is not a valid patch
28
+ */
29
+ static modify(event: NostrEvent): GitPatchFactory;
30
+ private copyRepositoryCommit;
31
+ /** Marks this as the first patch of a new series */
32
+ root(): this;
33
+ /** Sets or removes the series marker */
34
+ seriesMarker(type: "root" | "root-revision" | null): this;
35
+ /**
36
+ * Sets or removes the previous patch or original root
37
+ * @throws if the pointer has an invalid event id
38
+ */
39
+ previous(patch: NostrEvent | EventPointer | null): this;
40
+ /** Replaces labels while preserving series markers */
41
+ labels(labels: string[]): this;
42
+ /**
43
+ * Sets or removes the commit id
44
+ * @throws if the commit is not a Git object id
45
+ */
46
+ commit(commit: string | null): this;
47
+ /**
48
+ * Sets or removes the parent commit
49
+ * @throws if the commit is not a Git object id
50
+ */
51
+ parentCommit(commit: string | null): this;
52
+ /** Sets or removes the commit signature */
53
+ commitSignature(signature: string | null): this;
54
+ /**
55
+ * Sets or removes committer metadata
56
+ * @throws if the timestamp or timezone is invalid
57
+ */
58
+ committer(committer: GitPatchCommitter | null): this;
59
+ }