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,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";
@@ -24,10 +26,19 @@ export * from "./bookmark-list.js";
24
26
  export * from "./bookmark-set.js";
25
27
  export * from "./relay-lists.js";
26
28
  export * from "./blossom-server-list.js";
29
+ export * from "./external-identities.js";
27
30
  export * from "./git-grasp-list.js";
28
31
  export * from "./git-authors.js";
29
32
  export * from "./favorite-git-repos.js";
30
33
  export * from "./git-repository.js";
34
+ export * from "./git-issue.js";
35
+ export * from "./git-patch.js";
36
+ export * from "./git-pull-request.js";
37
+ export * from "./git-pull-request-update.js";
38
+ export * from "./git-open-status.js";
39
+ export * from "./git-applied-status.js";
40
+ export * from "./git-closed-status.js";
41
+ export * from "./git-draft-status.js";
31
42
  export * from "./follow-set.js";
32
43
  export * from "./relay-set.js";
33
44
  export * from "./list.js";
@@ -40,3 +51,15 @@ export * from "./picture-post.js";
40
51
  export * from "./badge.js";
41
52
  export * from "./badge-award.js";
42
53
  export * from "./profile-badges.js";
54
+ export * from "./nostr-web-token.js";
55
+ export * from "./root-napplet.js";
56
+ export * from "./named-napplet.js";
57
+ export * from "./napplet-snapshot.js";
58
+ export * from "./app-handler.js";
59
+ export * from "./app-recommendation.js";
60
+ export * from "./root-nsite.js";
61
+ export * from "./named-nsite.js";
62
+ export * from "./nsite-snapshot.js";
63
+ export * from "./user-status.js";
64
+ export * from "./trusted-provider-list.js";
65
+ 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";
@@ -24,10 +26,19 @@ export * from "./bookmark-list.js";
24
26
  export * from "./bookmark-set.js";
25
27
  export * from "./relay-lists.js";
26
28
  export * from "./blossom-server-list.js";
29
+ export * from "./external-identities.js";
27
30
  export * from "./git-grasp-list.js";
28
31
  export * from "./git-authors.js";
29
32
  export * from "./favorite-git-repos.js";
30
33
  export * from "./git-repository.js";
34
+ export * from "./git-issue.js";
35
+ export * from "./git-patch.js";
36
+ export * from "./git-pull-request.js";
37
+ export * from "./git-pull-request-update.js";
38
+ export * from "./git-open-status.js";
39
+ export * from "./git-applied-status.js";
40
+ export * from "./git-closed-status.js";
41
+ export * from "./git-draft-status.js";
31
42
  export * from "./follow-set.js";
32
43
  export * from "./relay-set.js";
33
44
  export * from "./list.js";
@@ -40,3 +51,15 @@ export * from "./picture-post.js";
40
51
  export * from "./badge.js";
41
52
  export * from "./badge-award.js";
42
53
  export * from "./profile-badges.js";
54
+ export * from "./nostr-web-token.js";
55
+ export * from "./root-napplet.js";
56
+ export * from "./named-napplet.js";
57
+ export * from "./napplet-snapshot.js";
58
+ export * from "./app-handler.js";
59
+ export * from "./app-recommendation.js";
60
+ export * from "./root-nsite.js";
61
+ export * from "./named-nsite.js";
62
+ export * from "./nsite-snapshot.js";
63
+ export * from "./user-status.js";
64
+ export * from "./trusted-provider-list.js";
65
+ 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
+ }
@@ -0,0 +1,11 @@
1
+ import { EventFactory } from "applesauce-core/factories";
2
+ import { NostrEvent } from "applesauce-core/helpers/event";
3
+ import { GitStatusKind } from "../../helpers/git-status.js";
4
+ /** A shared implementation of status target operations */
5
+ export declare class GitStatusTargetFactory<K extends GitStatusKind> extends EventFactory<K> {
6
+ /**
7
+ * Sets the original issue, pull request or root patch
8
+ * @throws if the event is not a supported original root
9
+ */
10
+ root(root: NostrEvent, relay?: string): this;
11
+ }
@@ -0,0 +1,12 @@
1
+ import { EventFactory } from "applesauce-core/factories";
2
+ import { setGitStatusRoot } from "../../operations/git-status.js";
3
+ /** A shared implementation of status target operations */
4
+ export class GitStatusTargetFactory extends EventFactory {
5
+ /**
6
+ * Sets the original issue, pull request or root patch
7
+ * @throws if the event is not a supported original root
8
+ */
9
+ root(root, relay) {
10
+ return this.chain(setGitStatusRoot(root, relay));
11
+ }
12
+ }
@@ -0,0 +1,19 @@
1
+ import { EventFactory } from "applesauce-core/factories";
2
+ import { NostrEvent } from "applesauce-core/helpers/event";
3
+ import { GitRepositoryPointer } from "../../helpers/git-repository.js";
4
+ /** A shared implementation of repository thread operations */
5
+ export declare class GitThreadFactory<K extends 1617 | 1618 | 1621> extends EventFactory<K> {
6
+ /**
7
+ * Sets the repository for this thread
8
+ * @throws if the event or pointer is not a valid repository
9
+ */
10
+ repository(repo: GitRepositoryPointer | NostrEvent): this;
11
+ /** Sets or removes the subject */
12
+ subject(subject: string | null): this;
13
+ /** Replaces all labels */
14
+ labels(labels: string[]): this;
15
+ /** Adds a label */
16
+ addLabel(label: string): this;
17
+ /** Removes a label */
18
+ removeLabel(label: string): this;
19
+ }
@@ -0,0 +1,29 @@
1
+ import { EventFactory } from "applesauce-core/factories";
2
+ import { setGitThreadRepository } from "../../operations/git-thread.js";
3
+ import { addGitIssueLabel, removeGitIssueLabel, setGitIssueLabels, setGitIssueSubject, } from "../../operations/git-issue.js";
4
+ /** A shared implementation of repository thread operations */
5
+ export class GitThreadFactory extends EventFactory {
6
+ /**
7
+ * Sets the repository for this thread
8
+ * @throws if the event or pointer is not a valid repository
9
+ */
10
+ repository(repo) {
11
+ return this.chain(setGitThreadRepository(repo));
12
+ }
13
+ /** Sets or removes the subject */
14
+ subject(subject) {
15
+ return this.chain(setGitIssueSubject(subject));
16
+ }
17
+ /** Replaces all labels */
18
+ labels(labels) {
19
+ return this.chain(setGitIssueLabels(labels));
20
+ }
21
+ /** Adds a label */
22
+ addLabel(label) {
23
+ return this.chain(addGitIssueLabel(label));
24
+ }
25
+ /** Removes a label */
26
+ removeLabel(label) {
27
+ return this.chain(removeGitIssueLabel(label));
28
+ }
29
+ }
@@ -0,0 +1,52 @@
1
+ import { EventFactory } from "applesauce-core/factories";
2
+ import { AddressPointer } from "applesauce-core/helpers/pointers";
3
+ import { NappletKind, NappletIconType } from "../../helpers/napplet.js";
4
+ /** A shared implementation of napplet manifest operations */
5
+ export declare class NappletManifestFactory<K extends NappletKind> extends EventFactory<K> {
6
+ /**
7
+ * Sets the sha256 of the `index.html` artifact
8
+ * @throws if the hash is not a lowercase hex sha256
9
+ */
10
+ artifact(sha256: string): this;
11
+ /** Sets the plain-text description */
12
+ description(value: string): this;
13
+ /** Sets or removes the display title */
14
+ title(value: string | null): this;
15
+ /** Sets or removes the source URL */
16
+ source(url: string | null): this;
17
+ /** Adds an archetype */
18
+ archetype(archetype: string): this;
19
+ /** Removes an archetype */
20
+ removeArchetype(archetype: string): this;
21
+ /** Adds or replaces an accepted intent and its parameter names */
22
+ intent(intent: string, params?: string[]): this;
23
+ /** Removes an accepted intent */
24
+ removeIntent(intent: string): this;
25
+ /** Adds a required NAP domain */
26
+ requires(domain: string): this;
27
+ /** Removes a required NAP domain */
28
+ removeRequires(domain: string): this;
29
+ /** Adds an optional NAP domain */
30
+ optional(domain: string): this;
31
+ /** Removes an optional NAP domain */
32
+ removeOptional(domain: string): this;
33
+ /** Adds a Blossom server hint */
34
+ server(url: string): this;
35
+ /** Removes a Blossom server hint */
36
+ removeServer(url: string): this;
37
+ /**
38
+ * Sets or removes the icon
39
+ * @throws if the hash or MIME type is invalid
40
+ */
41
+ icon(sha256: string | null, type?: NappletIconType): this;
42
+ /**
43
+ * Sets or removes the address of the napplet a snapshot derives from
44
+ * @throws if the address cannot be parsed
45
+ */
46
+ parent(parent: AddressPointer | string | null): this;
47
+ /**
48
+ * Sets or removes the address of the root napplet a snapshot's lineage originates from
49
+ * @throws if the address cannot be parsed
50
+ */
51
+ root(root: AddressPointer | string | null): this;
52
+ }
@@ -0,0 +1,85 @@
1
+ import { EventFactory } from "applesauce-core/factories";
2
+ import { addNappletArchetype, addNappletIntent, addNappletOptionalDomain, addNappletRequiredDomain, addNappletServer, removeNappletArchetype, removeNappletIntent, removeNappletOptionalDomain, removeNappletRequiredDomain, removeNappletServer, setNappletArtifactHash, setNappletDescription, setNappletIcon, setNappletParent, setNappletRoot, setNappletSource, setNappletTitle, } from "../../operations/napplet.js";
3
+ /** A shared implementation of napplet manifest operations */
4
+ export class NappletManifestFactory extends EventFactory {
5
+ /**
6
+ * Sets the sha256 of the `index.html` artifact
7
+ * @throws if the hash is not a lowercase hex sha256
8
+ */
9
+ artifact(sha256) {
10
+ return this.chain(setNappletArtifactHash(sha256));
11
+ }
12
+ /** Sets the plain-text description */
13
+ description(value) {
14
+ return this.chain(setNappletDescription(value));
15
+ }
16
+ /** Sets or removes the display title */
17
+ title(value) {
18
+ return this.chain(setNappletTitle(value));
19
+ }
20
+ /** Sets or removes the source URL */
21
+ source(url) {
22
+ return this.chain(setNappletSource(url));
23
+ }
24
+ /** Adds an archetype */
25
+ archetype(archetype) {
26
+ return this.chain(addNappletArchetype(archetype));
27
+ }
28
+ /** Removes an archetype */
29
+ removeArchetype(archetype) {
30
+ return this.chain(removeNappletArchetype(archetype));
31
+ }
32
+ /** Adds or replaces an accepted intent and its parameter names */
33
+ intent(intent, params) {
34
+ return this.chain(addNappletIntent(intent, params));
35
+ }
36
+ /** Removes an accepted intent */
37
+ removeIntent(intent) {
38
+ return this.chain(removeNappletIntent(intent));
39
+ }
40
+ /** Adds a required NAP domain */
41
+ requires(domain) {
42
+ return this.chain(addNappletRequiredDomain(domain));
43
+ }
44
+ /** Removes a required NAP domain */
45
+ removeRequires(domain) {
46
+ return this.chain(removeNappletRequiredDomain(domain));
47
+ }
48
+ /** Adds an optional NAP domain */
49
+ optional(domain) {
50
+ return this.chain(addNappletOptionalDomain(domain));
51
+ }
52
+ /** Removes an optional NAP domain */
53
+ removeOptional(domain) {
54
+ return this.chain(removeNappletOptionalDomain(domain));
55
+ }
56
+ /** Adds a Blossom server hint */
57
+ server(url) {
58
+ return this.chain(addNappletServer(url));
59
+ }
60
+ /** Removes a Blossom server hint */
61
+ removeServer(url) {
62
+ return this.chain(removeNappletServer(url));
63
+ }
64
+ /**
65
+ * Sets or removes the icon
66
+ * @throws if the hash or MIME type is invalid
67
+ */
68
+ icon(sha256, type) {
69
+ return this.chain(setNappletIcon(sha256, type));
70
+ }
71
+ /**
72
+ * Sets or removes the address of the napplet a snapshot derives from
73
+ * @throws if the address cannot be parsed
74
+ */
75
+ parent(parent) {
76
+ return this.chain(setNappletParent(parent));
77
+ }
78
+ /**
79
+ * Sets or removes the address of the root napplet a snapshot's lineage originates from
80
+ * @throws if the address cannot be parsed
81
+ */
82
+ root(root) {
83
+ return this.chain(setNappletRoot(root));
84
+ }
85
+ }
@@ -0,0 +1,45 @@
1
+ import { EventFactory } from "applesauce-core/factories";
2
+ import { AddressPointer } from "applesauce-core/helpers/pointers";
3
+ import { NsiteKind } from "../../helpers/nsite.js";
4
+ /** A shared implementation of nsite manifest operations */
5
+ export declare class NsiteManifestFactory<K extends NsiteKind> extends EventFactory<K> {
6
+ /**
7
+ * Adds or replaces a file mapping and refreshes the aggregate hash
8
+ * @throws if the path or hash is invalid
9
+ */
10
+ file(path: string, hash: string): this;
11
+ /** Removes a file mapping and refreshes the aggregate hash */
12
+ removeFile(path: string): this;
13
+ /** Updates the aggregate hash from the current manifest */
14
+ aggregate(): this;
15
+ /** Sets or removes the site's title */
16
+ title(value: string | null): this;
17
+ /** Sets or removes the site's description */
18
+ description(value: string | null): this;
19
+ /** Sets or removes the site's source URL */
20
+ source(value: string | null): this;
21
+ /** Adds a Blossom server hint */
22
+ server(url: string): this;
23
+ /** Removes a Blossom server hint */
24
+ removeServer(url: string): this;
25
+ /**
26
+ * Adds or replaces an upstream app descriptor reference
27
+ * @throws if the address is not addressable
28
+ */
29
+ app(pointer: AddressPointer | string): this;
30
+ /**
31
+ * Removes an upstream app descriptor reference
32
+ * @throws if the address is not addressable
33
+ */
34
+ removeApp(pointer: AddressPointer | string): this;
35
+ /**
36
+ * Sets or removes the immediate parent site
37
+ * @throws if the address does not reference a root or named site
38
+ */
39
+ parent(pointer: AddressPointer | string | null): this;
40
+ /**
41
+ * Sets or removes the origin site of the copy lineage
42
+ * @throws if the address does not reference a root or named site
43
+ */
44
+ root(pointer: AddressPointer | string | null): this;
45
+ }