applesauce-common 6.2.0 → 7.1.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 (251) 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 +12 -0
  23. package/dist/casts/index.js +12 -0
  24. package/dist/casts/napplet-handlers.d.ts +39 -0
  25. package/dist/casts/napplet-handlers.js +91 -0
  26. package/dist/casts/napplet.d.ts +98 -0
  27. package/dist/casts/napplet.js +196 -0
  28. package/dist/casts/note.d.ts +8 -0
  29. package/dist/casts/note.js +21 -1
  30. package/dist/casts/nsite.d.ts +134 -0
  31. package/dist/casts/nsite.js +249 -0
  32. package/dist/casts/profile.d.ts +20 -0
  33. package/dist/casts/profile.js +30 -0
  34. package/dist/casts/reaction.d.ts +1 -1
  35. package/dist/casts/relay-discovery.d.ts +4 -0
  36. package/dist/casts/relay-discovery.js +9 -1
  37. package/dist/casts/report.d.ts +28 -15
  38. package/dist/casts/report.js +42 -19
  39. package/dist/casts/share.d.ts +1 -1
  40. package/dist/casts/torrent.d.ts +5 -0
  41. package/dist/casts/torrent.js +8 -1
  42. package/dist/casts/trusted-assertions.d.ts +2 -0
  43. package/dist/casts/trusted-assertions.js +19 -18
  44. package/dist/casts/user-status.d.ts +33 -0
  45. package/dist/casts/user-status.js +69 -0
  46. package/dist/casts/user.d.ts +7 -0
  47. package/dist/casts/user.js +20 -1
  48. package/dist/factories/app-handler.d.ts +31 -0
  49. package/dist/factories/app-handler.js +50 -0
  50. package/dist/factories/app-recommendation.d.ts +21 -0
  51. package/dist/factories/app-recommendation.js +28 -0
  52. package/dist/factories/chat-message.d.ts +37 -0
  53. package/dist/factories/chat-message.js +56 -0
  54. package/dist/factories/comment.d.ts +8 -7
  55. package/dist/factories/comment.js +2 -2
  56. package/dist/factories/external-identities.d.ts +17 -0
  57. package/dist/factories/external-identities.js +28 -0
  58. package/dist/factories/file-message.d.ts +24 -0
  59. package/dist/factories/file-message.js +37 -0
  60. package/dist/factories/forum-thread.d.ts +34 -0
  61. package/dist/factories/forum-thread.js +50 -0
  62. package/dist/factories/git-applied-status.d.ts +39 -0
  63. package/dist/factories/git-applied-status.js +53 -0
  64. package/dist/factories/git-closed-status.d.ts +18 -0
  65. package/dist/factories/git-closed-status.js +24 -0
  66. package/dist/factories/git-draft-status.d.ts +18 -0
  67. package/dist/factories/git-draft-status.js +24 -0
  68. package/dist/factories/git-issue.d.ts +19 -0
  69. package/dist/factories/git-issue.js +25 -0
  70. package/dist/factories/git-open-status.d.ts +18 -0
  71. package/dist/factories/git-open-status.js +22 -0
  72. package/dist/factories/git-patch.d.ts +59 -0
  73. package/dist/factories/git-patch.js +102 -0
  74. package/dist/factories/git-pull-request-update.d.ts +23 -0
  75. package/dist/factories/git-pull-request-update.js +33 -0
  76. package/dist/factories/git-pull-request.d.ts +39 -0
  77. package/dist/factories/git-pull-request.js +64 -0
  78. package/dist/factories/index.d.ts +24 -0
  79. package/dist/factories/index.js +24 -0
  80. package/dist/factories/internal/git-pull-request.d.ts +19 -0
  81. package/dist/factories/internal/git-pull-request.js +26 -0
  82. package/dist/factories/internal/git-status.d.ts +11 -0
  83. package/dist/factories/internal/git-status.js +12 -0
  84. package/dist/factories/internal/git-thread.d.ts +19 -0
  85. package/dist/factories/internal/git-thread.js +29 -0
  86. package/dist/factories/internal/napplet-manifest.d.ts +52 -0
  87. package/dist/factories/internal/napplet-manifest.js +85 -0
  88. package/dist/factories/internal/nsite-manifest.d.ts +45 -0
  89. package/dist/factories/internal/nsite-manifest.js +68 -0
  90. package/dist/factories/legacy-message.d.ts +2 -0
  91. package/dist/factories/legacy-message.js +9 -2
  92. package/dist/factories/named-napplet.d.ts +20 -0
  93. package/dist/factories/named-napplet.js +30 -0
  94. package/dist/factories/named-nsite.d.ts +28 -0
  95. package/dist/factories/named-nsite.js +53 -0
  96. package/dist/factories/napplet-handlers.d.ts +34 -0
  97. package/dist/factories/napplet-handlers.js +77 -0
  98. package/dist/factories/napplet-snapshot.d.ts +18 -0
  99. package/dist/factories/napplet-snapshot.js +38 -0
  100. package/dist/factories/nsite-snapshot.d.ts +18 -0
  101. package/dist/factories/nsite-snapshot.js +29 -0
  102. package/dist/factories/reaction.d.ts +3 -2
  103. package/dist/factories/report.d.ts +48 -0
  104. package/dist/factories/report.js +66 -0
  105. package/dist/factories/root-napplet.d.ts +18 -0
  106. package/dist/factories/root-napplet.js +24 -0
  107. package/dist/factories/root-nsite.d.ts +23 -0
  108. package/dist/factories/root-nsite.js +44 -0
  109. package/dist/factories/torrent.d.ts +24 -10
  110. package/dist/factories/torrent.js +48 -44
  111. package/dist/factories/trusted-provider-list.d.ts +23 -0
  112. package/dist/factories/trusted-provider-list.js +39 -0
  113. package/dist/factories/user-status.d.ts +26 -0
  114. package/dist/factories/user-status.js +52 -0
  115. package/dist/factories/wrapped-message.js +10 -4
  116. package/dist/helpers/app-data.js +15 -7
  117. package/dist/helpers/app-handler.d.ts +43 -6
  118. package/dist/helpers/app-handler.js +53 -3
  119. package/dist/helpers/app-recommendation.d.ts +24 -0
  120. package/dist/helpers/app-recommendation.js +30 -0
  121. package/dist/helpers/bookmark.js +5 -2
  122. package/dist/helpers/comment.d.ts +11 -5
  123. package/dist/helpers/comment.js +7 -1
  124. package/dist/helpers/content.d.ts +3 -1
  125. package/dist/helpers/emoji-pack.js +11 -6
  126. package/dist/helpers/emoji.d.ts +2 -2
  127. package/dist/helpers/encrypted-content-cache.d.ts +2 -11
  128. package/dist/helpers/encrypted-content-cache.js +6 -14
  129. package/dist/helpers/encrypted-file.d.ts +41 -0
  130. package/dist/helpers/encrypted-file.js +64 -0
  131. package/dist/helpers/external-id.js +13 -19
  132. package/dist/helpers/external-identities.d.ts +29 -0
  133. package/dist/helpers/external-identities.js +52 -0
  134. package/dist/helpers/file-message.d.ts +18 -0
  135. package/dist/helpers/file-message.js +44 -0
  136. package/dist/helpers/file-metadata.d.ts +9 -4
  137. package/dist/helpers/file-metadata.js +21 -6
  138. package/dist/helpers/forum-thread.d.ts +10 -0
  139. package/dist/helpers/forum-thread.js +10 -0
  140. package/dist/helpers/gift-wrap.d.ts +40 -15
  141. package/dist/helpers/gift-wrap.js +110 -33
  142. package/dist/helpers/git-issue.d.ts +13 -0
  143. package/dist/helpers/git-issue.js +19 -0
  144. package/dist/helpers/git-patch.d.ts +41 -0
  145. package/dist/helpers/git-patch.js +73 -0
  146. package/dist/helpers/git-pull-request.d.ts +57 -0
  147. package/dist/helpers/git-pull-request.js +111 -0
  148. package/dist/helpers/git-repository.d.ts +4 -0
  149. package/dist/helpers/git-repository.js +16 -0
  150. package/dist/helpers/git-status.d.ts +44 -0
  151. package/dist/helpers/git-status.js +93 -0
  152. package/dist/helpers/git.d.ts +2 -0
  153. package/dist/helpers/git.js +4 -0
  154. package/dist/helpers/groups.d.ts +5 -2
  155. package/dist/helpers/groups.js +40 -18
  156. package/dist/helpers/hashtag.d.ts +4 -2
  157. package/dist/helpers/index.d.ts +13 -0
  158. package/dist/helpers/index.js +13 -0
  159. package/dist/helpers/lists.js +14 -2
  160. package/dist/helpers/lnurl.js +1 -1
  161. package/dist/helpers/messages.js +3 -2
  162. package/dist/helpers/mute.js +20 -9
  163. package/dist/helpers/napplet-handlers.d.ts +79 -0
  164. package/dist/helpers/napplet-handlers.js +187 -0
  165. package/dist/helpers/napplet.d.ts +107 -0
  166. package/dist/helpers/napplet.js +177 -0
  167. package/dist/helpers/nsite.d.ts +90 -0
  168. package/dist/helpers/nsite.js +217 -0
  169. package/dist/helpers/relay-discovery.d.ts +4 -0
  170. package/dist/helpers/relay-discovery.js +8 -0
  171. package/dist/helpers/reports.d.ts +35 -0
  172. package/dist/helpers/reports.js +36 -5
  173. package/dist/helpers/threading.d.ts +4 -2
  174. package/dist/helpers/torrent.d.ts +9 -6
  175. package/dist/helpers/torrent.js +23 -15
  176. package/dist/helpers/trusted-assertions.d.ts +7 -0
  177. package/dist/helpers/trusted-assertions.js +41 -2
  178. package/dist/helpers/user-status.d.ts +13 -1
  179. package/dist/helpers/user-status.js +15 -0
  180. package/dist/helpers/wrapped-messages.d.ts +2 -0
  181. package/dist/helpers/wrapped-messages.js +6 -1
  182. package/dist/models/app-handler.d.ts +21 -0
  183. package/dist/models/app-handler.js +47 -0
  184. package/dist/models/git.d.ts +34 -0
  185. package/dist/models/git.js +144 -0
  186. package/dist/models/index.d.ts +4 -0
  187. package/dist/models/index.js +4 -0
  188. package/dist/models/legacy-messages.js +6 -1
  189. package/dist/models/napplet-handlers.d.ts +16 -0
  190. package/dist/models/napplet-handlers.js +45 -0
  191. package/dist/models/nsite.d.ts +22 -0
  192. package/dist/models/nsite.js +67 -0
  193. package/dist/models/thread.d.ts +4 -1
  194. package/dist/models/thread.js +34 -5
  195. package/dist/models/user-status.d.ts +8 -4
  196. package/dist/models/user-status.js +16 -22
  197. package/dist/models/wrapped-messages.js +9 -7
  198. package/dist/observable/filter-timeline-by-mutes.d.ts +1 -1
  199. package/dist/observable/filter-timeline-by-mutes.js +6 -2
  200. package/dist/operations/app-handler.d.ts +24 -0
  201. package/dist/operations/app-handler.js +58 -0
  202. package/dist/operations/app-recommendation.d.ts +13 -0
  203. package/dist/operations/app-recommendation.js +40 -0
  204. package/dist/operations/calendar-event.js +3 -2
  205. package/dist/operations/chat-message.d.ts +9 -0
  206. package/dist/operations/chat-message.js +12 -0
  207. package/dist/operations/client.d.ts +1 -4
  208. package/dist/operations/client.js +1 -23
  209. package/dist/operations/comment.d.ts +9 -3
  210. package/dist/operations/comment.js +12 -9
  211. package/dist/operations/external-identities.d.ts +8 -0
  212. package/dist/operations/external-identities.js +23 -0
  213. package/dist/operations/file-message.d.ts +7 -0
  214. package/dist/operations/file-message.js +34 -0
  215. package/dist/operations/forum-thread.d.ts +3 -0
  216. package/dist/operations/forum-thread.js +6 -0
  217. package/dist/operations/gift-wrap.js +38 -14
  218. package/dist/operations/git-issue.d.ts +18 -0
  219. package/dist/operations/git-issue.js +31 -0
  220. package/dist/operations/git-patch.d.ts +30 -0
  221. package/dist/operations/git-patch.js +75 -0
  222. package/dist/operations/git-pull-request.d.ts +29 -0
  223. package/dist/operations/git-pull-request.js +74 -0
  224. package/dist/operations/git-repository.js +4 -4
  225. package/dist/operations/git-status.d.ts +28 -0
  226. package/dist/operations/git-status.js +116 -0
  227. package/dist/operations/git-thread.d.ts +13 -0
  228. package/dist/operations/git-thread.js +39 -0
  229. package/dist/operations/index.d.ts +17 -0
  230. package/dist/operations/index.js +17 -0
  231. package/dist/operations/internal/git-commits.d.ts +2 -0
  232. package/dist/operations/internal/git-commits.js +16 -0
  233. package/dist/operations/napplet-handlers.d.ts +47 -0
  234. package/dist/operations/napplet-handlers.js +161 -0
  235. package/dist/operations/napplet.d.ts +51 -0
  236. package/dist/operations/napplet.js +121 -0
  237. package/dist/operations/nsite.d.ts +51 -0
  238. package/dist/operations/nsite.js +112 -0
  239. package/dist/operations/reaction.d.ts +12 -2
  240. package/dist/operations/reaction.js +1 -1
  241. package/dist/operations/report.d.ts +33 -0
  242. package/dist/operations/report.js +60 -0
  243. package/dist/operations/stream.js +5 -4
  244. package/dist/operations/torrent.d.ts +1 -4
  245. package/dist/operations/torrent.js +24 -11
  246. package/dist/operations/trusted-providers.d.ts +14 -0
  247. package/dist/operations/trusted-providers.js +33 -0
  248. package/dist/operations/user-status.d.ts +11 -0
  249. package/dist/operations/user-status.js +29 -0
  250. package/dist/operations/wrapped-message.js +2 -2
  251. package/package.json +13 -17
@@ -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
+ }
@@ -0,0 +1,102 @@
1
+ import { blankEventTemplate, toEventTemplate } from "applesauce-core/factories";
2
+ import { GIT_PATCH_KIND, isGitPatchRoot, isValidGitPatch } from "../helpers/git-patch.js";
3
+ import { getGitRepositoryReference } from "../helpers/git-repository.js";
4
+ import { setGitPatchRoot, setGitPatchPrevious, setGitPatchLabels, setGitPatchCommit, setGitPatchParentCommit, setGitPatchCommitSignature, setGitPatchCommitter, } from "../operations/git-patch.js";
5
+ import { GitThreadFactory } from "./internal/git-thread.js";
6
+ /** A factory for NIP-34 patches (kind 1617) */
7
+ export class GitPatchFactory extends GitThreadFactory {
8
+ /**
9
+ * Creates the first patch or cover letter of a new series
10
+ * @throws if the repository is invalid
11
+ */
12
+ static create(repo, content) {
13
+ return new GitPatchFactory((res) => res(blankEventTemplate(GIT_PATCH_KIND)))
14
+ .repository(repo)
15
+ .content(content)
16
+ .root();
17
+ }
18
+ /**
19
+ * Creates the next patch in a series
20
+ * @throws if the previous event is not a valid patch
21
+ */
22
+ static next(previous, content) {
23
+ if (!isValidGitPatch(previous))
24
+ throw new Error("Expected a valid patch");
25
+ return GitPatchFactory.create(getGitRepositoryReference(previous), content)
26
+ .seriesMarker(null)
27
+ .previous(previous)
28
+ .copyRepositoryCommit(previous);
29
+ }
30
+ /**
31
+ * Creates the first patch of a revision linked to the original root
32
+ * @throws if the original event is not an original root patch
33
+ */
34
+ static revision(original, content) {
35
+ if (!isValidGitPatch(original) ||
36
+ !isGitPatchRoot(original) ||
37
+ original.tags.some((t) => t[0] === "t" && t[1] === "root-revision"))
38
+ throw new Error("Expected an original root patch");
39
+ return GitPatchFactory.create(getGitRepositoryReference(original), content)
40
+ .seriesMarker("root-revision")
41
+ .previous(original)
42
+ .copyRepositoryCommit(original);
43
+ }
44
+ /**
45
+ * Creates a factory for modifying a patch draft
46
+ * @throws if the event is not a valid patch
47
+ */
48
+ static modify(event) {
49
+ if (!isValidGitPatch(event))
50
+ throw new Error("Expected a valid patch");
51
+ return new GitPatchFactory((res) => res(toEventTemplate(event)));
52
+ }
53
+ copyRepositoryCommit(source) {
54
+ const commit = source.tags.find((t) => t[0] === "commit")?.[1];
55
+ const euc = source.tags.find((t) => t[0] === "r" && (t[1] !== commit || source.tags.filter((r) => r[0] === "r" && r[1] === commit).length > 1))?.[1];
56
+ return euc ? this.modifyPublicTags((tags) => [...tags, ["r", euc]]) : this;
57
+ }
58
+ /** Marks this as the first patch of a new series */
59
+ root() {
60
+ return this.seriesMarker("root").previous(null);
61
+ }
62
+ /** Sets or removes the series marker */
63
+ seriesMarker(type) {
64
+ return this.chain(setGitPatchRoot(type));
65
+ }
66
+ /**
67
+ * Sets or removes the previous patch or original root
68
+ * @throws if the pointer has an invalid event id
69
+ */
70
+ previous(patch) {
71
+ return this.chain(setGitPatchPrevious(patch));
72
+ }
73
+ /** Replaces labels while preserving series markers */
74
+ labels(labels) {
75
+ return this.chain(setGitPatchLabels(labels));
76
+ }
77
+ /**
78
+ * Sets or removes the commit id
79
+ * @throws if the commit is not a Git object id
80
+ */
81
+ commit(commit) {
82
+ return this.chain(setGitPatchCommit(commit));
83
+ }
84
+ /**
85
+ * Sets or removes the parent commit
86
+ * @throws if the commit is not a Git object id
87
+ */
88
+ parentCommit(commit) {
89
+ return this.chain(setGitPatchParentCommit(commit));
90
+ }
91
+ /** Sets or removes the commit signature */
92
+ commitSignature(signature) {
93
+ return this.chain(setGitPatchCommitSignature(signature));
94
+ }
95
+ /**
96
+ * Sets or removes committer metadata
97
+ * @throws if the timestamp or timezone is invalid
98
+ */
99
+ committer(committer) {
100
+ return this.chain(setGitPatchCommitter(committer));
101
+ }
102
+ }
@@ -0,0 +1,23 @@
1
+ import { KnownEventTemplate, NostrEvent } from "applesauce-core/helpers/event";
2
+ import { GIT_PULL_REQUEST_UPDATE_KIND } from "../helpers/git-pull-request.js";
3
+ import { GitPullRequestFetchFactory } from "./internal/git-pull-request.js";
4
+ /** An event template for a NIP-34 pull request update */
5
+ export type GitPullRequestUpdateTemplate = KnownEventTemplate<typeof GIT_PULL_REQUEST_UPDATE_KIND>;
6
+ /** A factory for NIP-34 pull request updates (kind 1619) */
7
+ export declare class GitPullRequestUpdateFactory extends GitPullRequestFetchFactory<typeof GIT_PULL_REQUEST_UPDATE_KIND> {
8
+ /**
9
+ * Creates a complete fetch-state update for a pull request
10
+ * @throws if the pull request, commit or clone URLs are invalid
11
+ */
12
+ static create(pr: NostrEvent, tipCommit: string, cloneUrls: string[]): GitPullRequestUpdateFactory;
13
+ /**
14
+ * Creates a factory for modifying a pull request update draft
15
+ * @throws if the event is not a valid pull request update
16
+ */
17
+ static modify(event: NostrEvent): GitPullRequestUpdateFactory;
18
+ /**
19
+ * Sets the pull request targeted by this update
20
+ * @throws if the pull request is invalid
21
+ */
22
+ target(pr: NostrEvent, relay?: string): this;
23
+ }
@@ -0,0 +1,33 @@
1
+ import { blankEventTemplate, toEventTemplate } from "applesauce-core/factories";
2
+ import { GIT_PULL_REQUEST_UPDATE_KIND, isValidGitPullRequestUpdate } from "../helpers/git-pull-request.js";
3
+ import { setGitPullRequestUpdateTarget } from "../operations/git-pull-request.js";
4
+ import { GitPullRequestFetchFactory } from "./internal/git-pull-request.js";
5
+ /** A factory for NIP-34 pull request updates (kind 1619) */
6
+ export class GitPullRequestUpdateFactory extends GitPullRequestFetchFactory {
7
+ /**
8
+ * Creates a complete fetch-state update for a pull request
9
+ * @throws if the pull request, commit or clone URLs are invalid
10
+ */
11
+ static create(pr, tipCommit, cloneUrls) {
12
+ return new GitPullRequestUpdateFactory((res) => res(blankEventTemplate(GIT_PULL_REQUEST_UPDATE_KIND)))
13
+ .target(pr)
14
+ .tipCommit(tipCommit)
15
+ .cloneUrls(cloneUrls);
16
+ }
17
+ /**
18
+ * Creates a factory for modifying a pull request update draft
19
+ * @throws if the event is not a valid pull request update
20
+ */
21
+ static modify(event) {
22
+ if (!isValidGitPullRequestUpdate(event))
23
+ throw new Error("Expected a valid pull request update");
24
+ return new GitPullRequestUpdateFactory((res) => res(toEventTemplate(event)));
25
+ }
26
+ /**
27
+ * Sets the pull request targeted by this update
28
+ * @throws if the pull request is invalid
29
+ */
30
+ target(pr, relay) {
31
+ return this.chain(setGitPullRequestUpdateTarget(pr, relay));
32
+ }
33
+ }
@@ -0,0 +1,39 @@
1
+ import { KnownEventTemplate, NostrEvent } from "applesauce-core/helpers/event";
2
+ import { GIT_PULL_REQUEST_KIND } from "../helpers/git-pull-request.js";
3
+ import { GitRepositoryPointer } from "../helpers/git-repository.js";
4
+ import { GitPullRequestFetchFactory } from "./internal/git-pull-request.js";
5
+ /** An event template for a NIP-34 pull request */
6
+ export type GitPullRequestTemplate = KnownEventTemplate<typeof GIT_PULL_REQUEST_KIND>;
7
+ /** A factory for NIP-34 pull requests (kind 1618) */
8
+ export declare class GitPullRequestFactory extends GitPullRequestFetchFactory<typeof GIT_PULL_REQUEST_KIND> {
9
+ /**
10
+ * Creates a pull request with a fetchable branch tip
11
+ * @throws if the repository, commit or clone URLs are invalid
12
+ */
13
+ static create(repo: GitRepositoryPointer | NostrEvent, subject: string, tipCommit: string, cloneUrls: string[], content?: string): GitPullRequestFactory;
14
+ /**
15
+ * Creates a factory for modifying a pull request draft
16
+ * @throws if the event is not a valid pull request
17
+ */
18
+ static modify(event: NostrEvent): GitPullRequestFactory;
19
+ /**
20
+ * Sets the target repository
21
+ * @throws if the repository is invalid
22
+ */
23
+ repository(repo: GitRepositoryPointer | NostrEvent): this;
24
+ /** Sets or removes the subject */
25
+ subject(subject: string | null): this;
26
+ /** Replaces all labels */
27
+ labels(labels: string[]): this;
28
+ /** Adds a label */
29
+ addLabel(label: string): this;
30
+ /** Removes a label */
31
+ removeLabel(label: string): this;
32
+ /** Sets or removes the recommended branch name */
33
+ branchName(name: string | null): this;
34
+ /**
35
+ * Sets or removes the root patch revised by this pull request
36
+ * @throws if the patch is not a root patch or its id is invalid
37
+ */
38
+ patch(patch: NostrEvent | string | null): this;
39
+ }
@@ -0,0 +1,64 @@
1
+ import { blankEventTemplate, toEventTemplate } from "applesauce-core/factories";
2
+ import { GIT_PULL_REQUEST_KIND, isValidGitPullRequest } from "../helpers/git-pull-request.js";
3
+ import { addGitIssueLabel, removeGitIssueLabel, setGitIssueLabels, setGitIssueSubject, } from "../operations/git-issue.js";
4
+ import { setGitThreadRepository } from "../operations/git-thread.js";
5
+ import { setGitPullRequestBranchName, setGitPullRequestPatch } from "../operations/git-pull-request.js";
6
+ import { GitPullRequestFetchFactory } from "./internal/git-pull-request.js";
7
+ /** A factory for NIP-34 pull requests (kind 1618) */
8
+ export class GitPullRequestFactory extends GitPullRequestFetchFactory {
9
+ /**
10
+ * Creates a pull request with a fetchable branch tip
11
+ * @throws if the repository, commit or clone URLs are invalid
12
+ */
13
+ static create(repo, subject, tipCommit, cloneUrls, content = "") {
14
+ return new GitPullRequestFactory((res) => res(blankEventTemplate(GIT_PULL_REQUEST_KIND)))
15
+ .repository(repo)
16
+ .subject(subject)
17
+ .tipCommit(tipCommit)
18
+ .cloneUrls(cloneUrls)
19
+ .content(content);
20
+ }
21
+ /**
22
+ * Creates a factory for modifying a pull request draft
23
+ * @throws if the event is not a valid pull request
24
+ */
25
+ static modify(event) {
26
+ if (!isValidGitPullRequest(event))
27
+ throw new Error("Expected a valid pull request");
28
+ return new GitPullRequestFactory((res) => res(toEventTemplate(event)));
29
+ }
30
+ /**
31
+ * Sets the target repository
32
+ * @throws if the repository is invalid
33
+ */
34
+ repository(repo) {
35
+ return this.chain(setGitThreadRepository(repo));
36
+ }
37
+ /** Sets or removes the subject */
38
+ subject(subject) {
39
+ return this.chain(setGitIssueSubject(subject));
40
+ }
41
+ /** Replaces all labels */
42
+ labels(labels) {
43
+ return this.chain(setGitIssueLabels(labels));
44
+ }
45
+ /** Adds a label */
46
+ addLabel(label) {
47
+ return this.chain(addGitIssueLabel(label));
48
+ }
49
+ /** Removes a label */
50
+ removeLabel(label) {
51
+ return this.chain(removeGitIssueLabel(label));
52
+ }
53
+ /** Sets or removes the recommended branch name */
54
+ branchName(name) {
55
+ return this.chain(setGitPullRequestBranchName(name));
56
+ }
57
+ /**
58
+ * Sets or removes the root patch revised by this pull request
59
+ * @throws if the patch is not a root patch or its id is invalid
60
+ */
61
+ patch(patch) {
62
+ return this.chain(setGitPullRequestPatch(patch));
63
+ }
64
+ }
@@ -1,4 +1,6 @@
1
1
  export * from "./note.js";
2
+ export * from "./chat-message.js";
3
+ export * from "./forum-thread.js";
2
4
  export * from "./reaction.js";
3
5
  export * from "./comment.js";
4
6
  export * from "./share.js";
@@ -12,6 +14,7 @@ export * from "./group.js";
12
14
  export * from "./group-management.js";
13
15
  export * from "./legacy-message.js";
14
16
  export * from "./wrapped-message.js";
17
+ export * from "./file-message.js";
15
18
  export * from "./app-data.js";
16
19
  export * from "./zap-goal.js";
17
20
  export * from "./zap-request.js";
@@ -24,10 +27,19 @@ export * from "./bookmark-list.js";
24
27
  export * from "./bookmark-set.js";
25
28
  export * from "./relay-lists.js";
26
29
  export * from "./blossom-server-list.js";
30
+ export * from "./external-identities.js";
27
31
  export * from "./git-grasp-list.js";
28
32
  export * from "./git-authors.js";
29
33
  export * from "./favorite-git-repos.js";
30
34
  export * from "./git-repository.js";
35
+ export * from "./git-issue.js";
36
+ export * from "./git-patch.js";
37
+ export * from "./git-pull-request.js";
38
+ export * from "./git-pull-request-update.js";
39
+ export * from "./git-open-status.js";
40
+ export * from "./git-applied-status.js";
41
+ export * from "./git-closed-status.js";
42
+ export * from "./git-draft-status.js";
31
43
  export * from "./follow-set.js";
32
44
  export * from "./relay-set.js";
33
45
  export * from "./list.js";
@@ -41,3 +53,15 @@ export * from "./badge.js";
41
53
  export * from "./badge-award.js";
42
54
  export * from "./profile-badges.js";
43
55
  export * from "./nostr-web-token.js";
56
+ export * from "./root-napplet.js";
57
+ export * from "./named-napplet.js";
58
+ export * from "./napplet-snapshot.js";
59
+ export * from "./napplet-handlers.js";
60
+ export * from "./app-handler.js";
61
+ export * from "./app-recommendation.js";
62
+ export * from "./root-nsite.js";
63
+ export * from "./named-nsite.js";
64
+ export * from "./nsite-snapshot.js";
65
+ export * from "./user-status.js";
66
+ export * from "./trusted-provider-list.js";
67
+ export * from "./report.js";
@@ -1,4 +1,6 @@
1
1
  export * from "./note.js";
2
+ export * from "./chat-message.js";
3
+ export * from "./forum-thread.js";
2
4
  export * from "./reaction.js";
3
5
  export * from "./comment.js";
4
6
  export * from "./share.js";
@@ -12,6 +14,7 @@ export * from "./group.js";
12
14
  export * from "./group-management.js";
13
15
  export * from "./legacy-message.js";
14
16
  export * from "./wrapped-message.js";
17
+ export * from "./file-message.js";
15
18
  export * from "./app-data.js";
16
19
  export * from "./zap-goal.js";
17
20
  export * from "./zap-request.js";
@@ -24,10 +27,19 @@ export * from "./bookmark-list.js";
24
27
  export * from "./bookmark-set.js";
25
28
  export * from "./relay-lists.js";
26
29
  export * from "./blossom-server-list.js";
30
+ export * from "./external-identities.js";
27
31
  export * from "./git-grasp-list.js";
28
32
  export * from "./git-authors.js";
29
33
  export * from "./favorite-git-repos.js";
30
34
  export * from "./git-repository.js";
35
+ export * from "./git-issue.js";
36
+ export * from "./git-patch.js";
37
+ export * from "./git-pull-request.js";
38
+ export * from "./git-pull-request-update.js";
39
+ export * from "./git-open-status.js";
40
+ export * from "./git-applied-status.js";
41
+ export * from "./git-closed-status.js";
42
+ export * from "./git-draft-status.js";
31
43
  export * from "./follow-set.js";
32
44
  export * from "./relay-set.js";
33
45
  export * from "./list.js";
@@ -41,3 +53,15 @@ export * from "./badge.js";
41
53
  export * from "./badge-award.js";
42
54
  export * from "./profile-badges.js";
43
55
  export * from "./nostr-web-token.js";
56
+ export * from "./root-napplet.js";
57
+ export * from "./named-napplet.js";
58
+ export * from "./napplet-snapshot.js";
59
+ export * from "./napplet-handlers.js";
60
+ export * from "./app-handler.js";
61
+ export * from "./app-recommendation.js";
62
+ export * from "./root-nsite.js";
63
+ export * from "./named-nsite.js";
64
+ export * from "./nsite-snapshot.js";
65
+ export * from "./user-status.js";
66
+ export * from "./trusted-provider-list.js";
67
+ export * from "./report.js";
@@ -0,0 +1,19 @@
1
+ import { EventFactory } from "applesauce-core/factories";
2
+ /** A shared implementation of pull request fetch operations */
3
+ export declare class GitPullRequestFetchFactory<K extends 1618 | 1619> extends EventFactory<K> {
4
+ /**
5
+ * Sets the proposed branch tip
6
+ * @throws if the commit is not a Git object id
7
+ */
8
+ tipCommit(commit: string): this;
9
+ /**
10
+ * Replaces the clone URLs containing the tip
11
+ * @throws if there are no nonempty URLs
12
+ */
13
+ cloneUrls(urls: string[]): this;
14
+ /**
15
+ * Sets or removes the merge base
16
+ * @throws if the commit is not a Git object id
17
+ */
18
+ mergeBase(commit: string | null): this;
19
+ }
@@ -0,0 +1,26 @@
1
+ import { EventFactory } from "applesauce-core/factories";
2
+ import { setGitPullRequestTipCommit, setGitPullRequestCloneUrls, setGitPullRequestMergeBase, } from "../../operations/git-pull-request.js";
3
+ /** A shared implementation of pull request fetch operations */
4
+ export class GitPullRequestFetchFactory extends EventFactory {
5
+ /**
6
+ * Sets the proposed branch tip
7
+ * @throws if the commit is not a Git object id
8
+ */
9
+ tipCommit(commit) {
10
+ return this.chain(setGitPullRequestTipCommit(commit));
11
+ }
12
+ /**
13
+ * Replaces the clone URLs containing the tip
14
+ * @throws if there are no nonempty URLs
15
+ */
16
+ cloneUrls(urls) {
17
+ return this.chain(setGitPullRequestCloneUrls(urls));
18
+ }
19
+ /**
20
+ * Sets or removes the merge base
21
+ * @throws if the commit is not a Git object id
22
+ */
23
+ mergeBase(commit) {
24
+ return this.chain(setGitPullRequestMergeBase(commit));
25
+ }
26
+ }