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.
- package/README.md +1 -0
- package/dist/casts/_circular-import.d.ts +3 -0
- package/dist/casts/_circular-import.js +3 -0
- package/dist/casts/app-handler.d.ts +56 -0
- package/dist/casts/app-handler.js +105 -0
- package/dist/casts/app-recommendation.d.ts +26 -0
- package/dist/casts/app-recommendation.js +41 -0
- package/dist/casts/external-identities.d.ts +9 -0
- package/dist/casts/external-identities.js +14 -0
- package/dist/casts/forum-thread.d.ts +17 -0
- package/dist/casts/forum-thread.js +31 -0
- package/dist/casts/git-issue.d.ts +18 -0
- package/dist/casts/git-issue.js +26 -0
- package/dist/casts/git-patch.d.ts +49 -0
- package/dist/casts/git-patch.js +88 -0
- package/dist/casts/git-pull-request.d.ts +67 -0
- package/dist/casts/git-pull-request.js +122 -0
- package/dist/casts/git-repository.d.ts +9 -0
- package/dist/casts/git-repository.js +16 -0
- package/dist/casts/git-thread.d.ts +33 -0
- package/dist/casts/git-thread.js +65 -0
- package/dist/casts/index.d.ts +12 -0
- package/dist/casts/index.js +12 -0
- package/dist/casts/napplet-handlers.d.ts +39 -0
- package/dist/casts/napplet-handlers.js +91 -0
- package/dist/casts/napplet.d.ts +98 -0
- package/dist/casts/napplet.js +196 -0
- package/dist/casts/note.d.ts +8 -0
- package/dist/casts/note.js +21 -1
- package/dist/casts/nsite.d.ts +134 -0
- package/dist/casts/nsite.js +249 -0
- package/dist/casts/profile.d.ts +20 -0
- package/dist/casts/profile.js +30 -0
- package/dist/casts/reaction.d.ts +1 -1
- package/dist/casts/relay-discovery.d.ts +4 -0
- package/dist/casts/relay-discovery.js +9 -1
- package/dist/casts/report.d.ts +28 -15
- package/dist/casts/report.js +42 -19
- package/dist/casts/share.d.ts +1 -1
- package/dist/casts/torrent.d.ts +5 -0
- package/dist/casts/torrent.js +8 -1
- package/dist/casts/trusted-assertions.d.ts +2 -0
- package/dist/casts/trusted-assertions.js +19 -18
- package/dist/casts/user-status.d.ts +33 -0
- package/dist/casts/user-status.js +69 -0
- package/dist/casts/user.d.ts +7 -0
- package/dist/casts/user.js +20 -1
- package/dist/factories/app-handler.d.ts +31 -0
- package/dist/factories/app-handler.js +50 -0
- package/dist/factories/app-recommendation.d.ts +21 -0
- package/dist/factories/app-recommendation.js +28 -0
- package/dist/factories/chat-message.d.ts +37 -0
- package/dist/factories/chat-message.js +56 -0
- package/dist/factories/comment.d.ts +8 -7
- package/dist/factories/comment.js +2 -2
- package/dist/factories/external-identities.d.ts +17 -0
- package/dist/factories/external-identities.js +28 -0
- package/dist/factories/file-message.d.ts +24 -0
- package/dist/factories/file-message.js +37 -0
- package/dist/factories/forum-thread.d.ts +34 -0
- package/dist/factories/forum-thread.js +50 -0
- package/dist/factories/git-applied-status.d.ts +39 -0
- package/dist/factories/git-applied-status.js +53 -0
- package/dist/factories/git-closed-status.d.ts +18 -0
- package/dist/factories/git-closed-status.js +24 -0
- package/dist/factories/git-draft-status.d.ts +18 -0
- package/dist/factories/git-draft-status.js +24 -0
- package/dist/factories/git-issue.d.ts +19 -0
- package/dist/factories/git-issue.js +25 -0
- package/dist/factories/git-open-status.d.ts +18 -0
- package/dist/factories/git-open-status.js +22 -0
- package/dist/factories/git-patch.d.ts +59 -0
- package/dist/factories/git-patch.js +102 -0
- package/dist/factories/git-pull-request-update.d.ts +23 -0
- package/dist/factories/git-pull-request-update.js +33 -0
- package/dist/factories/git-pull-request.d.ts +39 -0
- package/dist/factories/git-pull-request.js +64 -0
- package/dist/factories/index.d.ts +24 -0
- package/dist/factories/index.js +24 -0
- package/dist/factories/internal/git-pull-request.d.ts +19 -0
- package/dist/factories/internal/git-pull-request.js +26 -0
- package/dist/factories/internal/git-status.d.ts +11 -0
- package/dist/factories/internal/git-status.js +12 -0
- package/dist/factories/internal/git-thread.d.ts +19 -0
- package/dist/factories/internal/git-thread.js +29 -0
- package/dist/factories/internal/napplet-manifest.d.ts +52 -0
- package/dist/factories/internal/napplet-manifest.js +85 -0
- package/dist/factories/internal/nsite-manifest.d.ts +45 -0
- package/dist/factories/internal/nsite-manifest.js +68 -0
- package/dist/factories/legacy-message.d.ts +2 -0
- package/dist/factories/legacy-message.js +9 -2
- package/dist/factories/named-napplet.d.ts +20 -0
- package/dist/factories/named-napplet.js +30 -0
- package/dist/factories/named-nsite.d.ts +28 -0
- package/dist/factories/named-nsite.js +53 -0
- package/dist/factories/napplet-handlers.d.ts +34 -0
- package/dist/factories/napplet-handlers.js +77 -0
- package/dist/factories/napplet-snapshot.d.ts +18 -0
- package/dist/factories/napplet-snapshot.js +38 -0
- package/dist/factories/nsite-snapshot.d.ts +18 -0
- package/dist/factories/nsite-snapshot.js +29 -0
- package/dist/factories/reaction.d.ts +3 -2
- package/dist/factories/report.d.ts +48 -0
- package/dist/factories/report.js +66 -0
- package/dist/factories/root-napplet.d.ts +18 -0
- package/dist/factories/root-napplet.js +24 -0
- package/dist/factories/root-nsite.d.ts +23 -0
- package/dist/factories/root-nsite.js +44 -0
- package/dist/factories/torrent.d.ts +24 -10
- package/dist/factories/torrent.js +48 -44
- package/dist/factories/trusted-provider-list.d.ts +23 -0
- package/dist/factories/trusted-provider-list.js +39 -0
- package/dist/factories/user-status.d.ts +26 -0
- package/dist/factories/user-status.js +52 -0
- package/dist/factories/wrapped-message.js +10 -4
- package/dist/helpers/app-data.js +15 -7
- package/dist/helpers/app-handler.d.ts +43 -6
- package/dist/helpers/app-handler.js +53 -3
- package/dist/helpers/app-recommendation.d.ts +24 -0
- package/dist/helpers/app-recommendation.js +30 -0
- package/dist/helpers/bookmark.js +5 -2
- package/dist/helpers/comment.d.ts +11 -5
- package/dist/helpers/comment.js +7 -1
- package/dist/helpers/content.d.ts +3 -1
- package/dist/helpers/emoji-pack.js +11 -6
- package/dist/helpers/emoji.d.ts +2 -2
- package/dist/helpers/encrypted-content-cache.d.ts +2 -11
- package/dist/helpers/encrypted-content-cache.js +6 -14
- package/dist/helpers/encrypted-file.d.ts +41 -0
- package/dist/helpers/encrypted-file.js +64 -0
- package/dist/helpers/external-id.js +13 -19
- package/dist/helpers/external-identities.d.ts +29 -0
- package/dist/helpers/external-identities.js +52 -0
- package/dist/helpers/file-message.d.ts +18 -0
- package/dist/helpers/file-message.js +44 -0
- package/dist/helpers/file-metadata.d.ts +9 -4
- package/dist/helpers/file-metadata.js +21 -6
- package/dist/helpers/forum-thread.d.ts +10 -0
- package/dist/helpers/forum-thread.js +10 -0
- package/dist/helpers/gift-wrap.d.ts +40 -15
- package/dist/helpers/gift-wrap.js +110 -33
- package/dist/helpers/git-issue.d.ts +13 -0
- package/dist/helpers/git-issue.js +19 -0
- package/dist/helpers/git-patch.d.ts +41 -0
- package/dist/helpers/git-patch.js +73 -0
- package/dist/helpers/git-pull-request.d.ts +57 -0
- package/dist/helpers/git-pull-request.js +111 -0
- package/dist/helpers/git-repository.d.ts +4 -0
- package/dist/helpers/git-repository.js +16 -0
- package/dist/helpers/git-status.d.ts +44 -0
- package/dist/helpers/git-status.js +93 -0
- package/dist/helpers/git.d.ts +2 -0
- package/dist/helpers/git.js +4 -0
- package/dist/helpers/groups.d.ts +5 -2
- package/dist/helpers/groups.js +40 -18
- package/dist/helpers/hashtag.d.ts +4 -2
- package/dist/helpers/index.d.ts +13 -0
- package/dist/helpers/index.js +13 -0
- package/dist/helpers/lists.js +14 -2
- package/dist/helpers/lnurl.js +1 -1
- package/dist/helpers/messages.js +3 -2
- package/dist/helpers/mute.js +20 -9
- package/dist/helpers/napplet-handlers.d.ts +79 -0
- package/dist/helpers/napplet-handlers.js +187 -0
- package/dist/helpers/napplet.d.ts +107 -0
- package/dist/helpers/napplet.js +177 -0
- package/dist/helpers/nsite.d.ts +90 -0
- package/dist/helpers/nsite.js +217 -0
- package/dist/helpers/relay-discovery.d.ts +4 -0
- package/dist/helpers/relay-discovery.js +8 -0
- package/dist/helpers/reports.d.ts +35 -0
- package/dist/helpers/reports.js +36 -5
- package/dist/helpers/threading.d.ts +4 -2
- package/dist/helpers/torrent.d.ts +9 -6
- package/dist/helpers/torrent.js +23 -15
- package/dist/helpers/trusted-assertions.d.ts +7 -0
- package/dist/helpers/trusted-assertions.js +41 -2
- package/dist/helpers/user-status.d.ts +13 -1
- package/dist/helpers/user-status.js +15 -0
- package/dist/helpers/wrapped-messages.d.ts +2 -0
- package/dist/helpers/wrapped-messages.js +6 -1
- package/dist/models/app-handler.d.ts +21 -0
- package/dist/models/app-handler.js +47 -0
- package/dist/models/git.d.ts +34 -0
- package/dist/models/git.js +144 -0
- package/dist/models/index.d.ts +4 -0
- package/dist/models/index.js +4 -0
- package/dist/models/legacy-messages.js +6 -1
- package/dist/models/napplet-handlers.d.ts +16 -0
- package/dist/models/napplet-handlers.js +45 -0
- package/dist/models/nsite.d.ts +22 -0
- package/dist/models/nsite.js +67 -0
- package/dist/models/thread.d.ts +4 -1
- package/dist/models/thread.js +34 -5
- package/dist/models/user-status.d.ts +8 -4
- package/dist/models/user-status.js +16 -22
- package/dist/models/wrapped-messages.js +9 -7
- package/dist/observable/filter-timeline-by-mutes.d.ts +1 -1
- package/dist/observable/filter-timeline-by-mutes.js +6 -2
- package/dist/operations/app-handler.d.ts +24 -0
- package/dist/operations/app-handler.js +58 -0
- package/dist/operations/app-recommendation.d.ts +13 -0
- package/dist/operations/app-recommendation.js +40 -0
- package/dist/operations/calendar-event.js +3 -2
- package/dist/operations/chat-message.d.ts +9 -0
- package/dist/operations/chat-message.js +12 -0
- package/dist/operations/client.d.ts +1 -4
- package/dist/operations/client.js +1 -23
- package/dist/operations/comment.d.ts +9 -3
- package/dist/operations/comment.js +12 -9
- package/dist/operations/external-identities.d.ts +8 -0
- package/dist/operations/external-identities.js +23 -0
- package/dist/operations/file-message.d.ts +7 -0
- package/dist/operations/file-message.js +34 -0
- package/dist/operations/forum-thread.d.ts +3 -0
- package/dist/operations/forum-thread.js +6 -0
- package/dist/operations/gift-wrap.js +38 -14
- package/dist/operations/git-issue.d.ts +18 -0
- package/dist/operations/git-issue.js +31 -0
- package/dist/operations/git-patch.d.ts +30 -0
- package/dist/operations/git-patch.js +75 -0
- package/dist/operations/git-pull-request.d.ts +29 -0
- package/dist/operations/git-pull-request.js +74 -0
- package/dist/operations/git-repository.js +4 -4
- package/dist/operations/git-status.d.ts +28 -0
- package/dist/operations/git-status.js +116 -0
- package/dist/operations/git-thread.d.ts +13 -0
- package/dist/operations/git-thread.js +39 -0
- package/dist/operations/index.d.ts +17 -0
- package/dist/operations/index.js +17 -0
- package/dist/operations/internal/git-commits.d.ts +2 -0
- package/dist/operations/internal/git-commits.js +16 -0
- package/dist/operations/napplet-handlers.d.ts +47 -0
- package/dist/operations/napplet-handlers.js +161 -0
- package/dist/operations/napplet.d.ts +51 -0
- package/dist/operations/napplet.js +121 -0
- package/dist/operations/nsite.d.ts +51 -0
- package/dist/operations/nsite.js +112 -0
- package/dist/operations/reaction.d.ts +12 -2
- package/dist/operations/reaction.js +1 -1
- package/dist/operations/report.d.ts +33 -0
- package/dist/operations/report.js +60 -0
- package/dist/operations/stream.js +5 -4
- package/dist/operations/torrent.d.ts +1 -4
- package/dist/operations/torrent.js +24 -11
- package/dist/operations/trusted-providers.d.ts +14 -0
- package/dist/operations/trusted-providers.js +33 -0
- package/dist/operations/user-status.d.ts +11 -0
- package/dist/operations/user-status.js +29 -0
- package/dist/operations/wrapped-message.js +2 -2
- package/package.json +13 -17
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { EventOperation } from "applesauce-core/factories";
|
|
2
|
+
import { NostrEvent } from "applesauce-core/helpers/event";
|
|
3
|
+
import { EventPointer } from "applesauce-core/helpers/pointers";
|
|
4
|
+
import { GitPatchCommitter } from "../helpers/git-patch.js";
|
|
5
|
+
/** Sets the patch series marker, preserving ordinary labels */
|
|
6
|
+
export declare function setGitPatchRoot(type: "root" | "root-revision" | null): EventOperation;
|
|
7
|
+
/** Replaces patch labels while preserving series markers */
|
|
8
|
+
export declare function setGitPatchLabels(labels: string[]): EventOperation;
|
|
9
|
+
/**
|
|
10
|
+
* Sets or removes the previous patch or original root reference
|
|
11
|
+
* @throws if the pointer has an invalid event id
|
|
12
|
+
*/
|
|
13
|
+
export declare function setGitPatchPrevious(patch: NostrEvent | EventPointer | null): EventOperation;
|
|
14
|
+
/**
|
|
15
|
+
* Sets or removes the patch commit and its matching discovery tag
|
|
16
|
+
* @throws if the commit is not a Git object id
|
|
17
|
+
*/
|
|
18
|
+
export declare function setGitPatchCommit(commit: string | null): EventOperation;
|
|
19
|
+
/**
|
|
20
|
+
* Sets or removes the parent commit
|
|
21
|
+
* @throws if the commit is not a Git object id
|
|
22
|
+
*/
|
|
23
|
+
export declare function setGitPatchParentCommit(commit: string | null): EventOperation;
|
|
24
|
+
/** Sets or removes the commit signature, retaining an empty string for unsigned commits */
|
|
25
|
+
export declare function setGitPatchCommitSignature(signature: string | null): EventOperation;
|
|
26
|
+
/**
|
|
27
|
+
* Sets or removes reproducible committer metadata
|
|
28
|
+
* @throws if the timestamp or timezone is invalid
|
|
29
|
+
*/
|
|
30
|
+
export declare function setGitPatchCommitter(committer: GitPatchCommitter | null): EventOperation;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { isHexKey } from "applesauce-core/helpers/string";
|
|
2
|
+
import { modifyPublicTags } from "applesauce-core/operations/tags";
|
|
3
|
+
import { removeSingletonTag, setSingletonTag } from "applesauce-core/operations/tag/common";
|
|
4
|
+
import { isGitCommitId } from "../helpers/git.js";
|
|
5
|
+
import { replaceGitCommitReferences } from "./internal/git-commits.js";
|
|
6
|
+
/** Sets the patch series marker, preserving ordinary labels */
|
|
7
|
+
export function setGitPatchRoot(type) {
|
|
8
|
+
return modifyPublicTags((tags) => [
|
|
9
|
+
...tags.filter((t) => !(t[0] === "t" && ["root", "root-revision"].includes(t[1]))),
|
|
10
|
+
...(type ? [["t", type]] : []),
|
|
11
|
+
]);
|
|
12
|
+
}
|
|
13
|
+
/** Replaces patch labels while preserving series markers */
|
|
14
|
+
export function setGitPatchLabels(labels) {
|
|
15
|
+
return modifyPublicTags((tags) => [
|
|
16
|
+
...tags.filter((t) => t[0] !== "t" || ["root", "root-revision"].includes(t[1])),
|
|
17
|
+
...[...new Set(labels)].filter((label) => !["root", "root-revision"].includes(label)).map((label) => ["t", label]),
|
|
18
|
+
]);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Sets or removes the previous patch or original root reference
|
|
22
|
+
* @throws if the pointer has an invalid event id
|
|
23
|
+
*/
|
|
24
|
+
export function setGitPatchPrevious(patch) {
|
|
25
|
+
if (patch && !isHexKey(patch.id))
|
|
26
|
+
throw new Error("Invalid patch id");
|
|
27
|
+
const relay = patch && "relays" in patch ? patch.relays?.[0] : "";
|
|
28
|
+
const author = patch && "pubkey" in patch ? patch.pubkey : patch?.author;
|
|
29
|
+
return modifyPublicTags((tags) => [
|
|
30
|
+
...tags.filter((t) => !(t[0] === "e" && t[3] === "reply")),
|
|
31
|
+
...(patch ? [["e", patch.id, relay || "", "reply", ...(author ? [author] : [])]] : []),
|
|
32
|
+
]);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Sets or removes the patch commit and its matching discovery tag
|
|
36
|
+
* @throws if the commit is not a Git object id
|
|
37
|
+
*/
|
|
38
|
+
export function setGitPatchCommit(commit) {
|
|
39
|
+
if (commit !== null && !isGitCommitId(commit))
|
|
40
|
+
throw new Error("Invalid Git commit id");
|
|
41
|
+
return modifyPublicTags((tags) => replaceGitCommitReferences(tags, "commit", commit ? [commit] : []));
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Sets or removes the parent commit
|
|
45
|
+
* @throws if the commit is not a Git object id
|
|
46
|
+
*/
|
|
47
|
+
export function setGitPatchParentCommit(commit) {
|
|
48
|
+
if (commit !== null && !isGitCommitId(commit))
|
|
49
|
+
throw new Error("Invalid Git commit id");
|
|
50
|
+
return modifyPublicTags(commit === null ? removeSingletonTag("parent-commit") : setSingletonTag(["parent-commit", commit]));
|
|
51
|
+
}
|
|
52
|
+
/** Sets or removes the commit signature, retaining an empty string for unsigned commits */
|
|
53
|
+
export function setGitPatchCommitSignature(signature) {
|
|
54
|
+
return modifyPublicTags(signature === null ? removeSingletonTag("commit-pgp-sig") : setSingletonTag(["commit-pgp-sig", signature]));
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Sets or removes reproducible committer metadata
|
|
58
|
+
* @throws if the timestamp or timezone is invalid
|
|
59
|
+
*/
|
|
60
|
+
export function setGitPatchCommitter(committer) {
|
|
61
|
+
if (committer &&
|
|
62
|
+
(!Number.isSafeInteger(committer.timestamp) ||
|
|
63
|
+
committer.timestamp < 0 ||
|
|
64
|
+
!Number.isInteger(committer.timezoneOffset)))
|
|
65
|
+
throw new Error("Invalid committer timestamp or timezone");
|
|
66
|
+
return modifyPublicTags(committer === null
|
|
67
|
+
? removeSingletonTag("committer")
|
|
68
|
+
: setSingletonTag([
|
|
69
|
+
"committer",
|
|
70
|
+
committer.name,
|
|
71
|
+
committer.email,
|
|
72
|
+
String(committer.timestamp),
|
|
73
|
+
String(committer.timezoneOffset),
|
|
74
|
+
]));
|
|
75
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { EventOperation } from "applesauce-core/factories";
|
|
2
|
+
import { NostrEvent } from "applesauce-core/helpers/event";
|
|
3
|
+
/**
|
|
4
|
+
* Sets the branch tip commit of a pull request or update
|
|
5
|
+
* @throws if the commit is not a Git object id
|
|
6
|
+
*/
|
|
7
|
+
export declare function setGitPullRequestTipCommit(commit: string): EventOperation;
|
|
8
|
+
/**
|
|
9
|
+
* Replaces the clone URLs of a pull request or update
|
|
10
|
+
* @throws if there are no nonempty clone URLs
|
|
11
|
+
*/
|
|
12
|
+
export declare function setGitPullRequestCloneUrls(urls: string[]): EventOperation;
|
|
13
|
+
/** Sets or removes the recommended branch name */
|
|
14
|
+
export declare function setGitPullRequestBranchName(name: string | null): EventOperation;
|
|
15
|
+
/**
|
|
16
|
+
* Sets or removes the common ancestor with the target branch
|
|
17
|
+
* @throws if the commit is not a Git object id
|
|
18
|
+
*/
|
|
19
|
+
export declare function setGitPullRequestMergeBase(commit: string | null): EventOperation;
|
|
20
|
+
/**
|
|
21
|
+
* Sets or removes the original patch revised by a pull request
|
|
22
|
+
* @throws if the target is not a root patch or its id is invalid
|
|
23
|
+
*/
|
|
24
|
+
export declare function setGitPullRequestPatch(patch: NostrEvent | string | null): EventOperation;
|
|
25
|
+
/**
|
|
26
|
+
* Sets the pull request targeted by an update and copies its repository tags
|
|
27
|
+
* @throws if the target is not a valid pull request
|
|
28
|
+
*/
|
|
29
|
+
export declare function setGitPullRequestUpdateTarget(pr: NostrEvent, relay?: string): EventOperation;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { isHexKey } from "applesauce-core/helpers/string";
|
|
2
|
+
import { modifyPublicTags } from "applesauce-core/operations/tags";
|
|
3
|
+
import { removeSingletonTag, setSingletonTag } from "applesauce-core/operations/tag/common";
|
|
4
|
+
import { isGitCommitId } from "../helpers/git.js";
|
|
5
|
+
import { isGitPatchRoot, isValidGitPatch } from "../helpers/git-patch.js";
|
|
6
|
+
import { isValidGitPullRequest } from "../helpers/git-pull-request.js";
|
|
7
|
+
import { getGitRepositoryReference } from "../helpers/git-repository.js";
|
|
8
|
+
import { setGitThreadRepository } from "./git-thread.js";
|
|
9
|
+
/**
|
|
10
|
+
* Sets the branch tip commit of a pull request or update
|
|
11
|
+
* @throws if the commit is not a Git object id
|
|
12
|
+
*/
|
|
13
|
+
export function setGitPullRequestTipCommit(commit) {
|
|
14
|
+
if (!isGitCommitId(commit))
|
|
15
|
+
throw new Error("Invalid Git commit id");
|
|
16
|
+
return modifyPublicTags(setSingletonTag(["c", commit]));
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Replaces the clone URLs of a pull request or update
|
|
20
|
+
* @throws if there are no nonempty clone URLs
|
|
21
|
+
*/
|
|
22
|
+
export function setGitPullRequestCloneUrls(urls) {
|
|
23
|
+
if (!urls.length || urls.some((url) => !url.trim()))
|
|
24
|
+
throw new Error("Expected at least one clone URL");
|
|
25
|
+
return modifyPublicTags((tags) => [...tags.filter((t) => t[0] !== "clone"), ["clone", ...new Set(urls)]]);
|
|
26
|
+
}
|
|
27
|
+
/** Sets or removes the recommended branch name */
|
|
28
|
+
export function setGitPullRequestBranchName(name) {
|
|
29
|
+
return modifyPublicTags(name === null ? removeSingletonTag("branch-name") : setSingletonTag(["branch-name", name]));
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Sets or removes the common ancestor with the target branch
|
|
33
|
+
* @throws if the commit is not a Git object id
|
|
34
|
+
*/
|
|
35
|
+
export function setGitPullRequestMergeBase(commit) {
|
|
36
|
+
if (commit !== null && !isGitCommitId(commit))
|
|
37
|
+
throw new Error("Invalid Git commit id");
|
|
38
|
+
return modifyPublicTags(commit === null ? removeSingletonTag("merge-base") : setSingletonTag(["merge-base", commit]));
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Sets or removes the original patch revised by a pull request
|
|
42
|
+
* @throws if the target is not a root patch or its id is invalid
|
|
43
|
+
*/
|
|
44
|
+
export function setGitPullRequestPatch(patch) {
|
|
45
|
+
if (patch !== null && typeof patch !== "string" && (!isValidGitPatch(patch) || !isGitPatchRoot(patch)))
|
|
46
|
+
throw new Error("Expected a root patch");
|
|
47
|
+
const id = typeof patch === "string" ? patch : patch?.id;
|
|
48
|
+
if (id !== undefined && !isHexKey(id))
|
|
49
|
+
throw new Error("Invalid patch id");
|
|
50
|
+
return modifyPublicTags(id === undefined ? removeSingletonTag("e") : setSingletonTag(["e", id]));
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Sets the pull request targeted by an update and copies its repository tags
|
|
54
|
+
* @throws if the target is not a valid pull request
|
|
55
|
+
*/
|
|
56
|
+
export function setGitPullRequestUpdateTarget(pr, relay = "") {
|
|
57
|
+
if (!isValidGitPullRequest(pr) || !isHexKey(pr.id) || !isHexKey(pr.pubkey))
|
|
58
|
+
throw new Error("Expected a valid pull request");
|
|
59
|
+
const repo = getGitRepositoryReference(pr);
|
|
60
|
+
const repository = setGitThreadRepository(repo);
|
|
61
|
+
return async (draft) => {
|
|
62
|
+
const next = await repository(draft);
|
|
63
|
+
return modifyPublicTags((tags) => {
|
|
64
|
+
const oldAuthor = tags.find((t) => t[0] === "P")?.[1];
|
|
65
|
+
const result = tags.filter((t) => t[0] !== "E" && t[0] !== "P" && t[0] !== "r" && !(t[0] === "p" && t[1] === oldAuthor && t[1] !== repo.pubkey));
|
|
66
|
+
const euc = pr.tags.find((t) => t[0] === "r")?.[1];
|
|
67
|
+
if (euc)
|
|
68
|
+
result.push(["r", euc]);
|
|
69
|
+
if (!result.some((t) => t[0] === "p" && t[1] === pr.pubkey))
|
|
70
|
+
result.push(["p", pr.pubkey]);
|
|
71
|
+
return [...result, ["E", pr.id, relay], ["P", pr.pubkey]];
|
|
72
|
+
})(next);
|
|
73
|
+
};
|
|
74
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getReplaceableAddressFromPointer } from "applesauce-core/helpers/pointers";
|
|
2
2
|
import { isSafeRelayURL } from "applesauce-core/helpers/relays";
|
|
3
|
-
import { normalizeURL } from "applesauce-core/helpers/url";
|
|
3
|
+
import { normalizeURL, serializeURL } from "applesauce-core/helpers/url";
|
|
4
4
|
import { includeSingletonTag, modifyPublicTags } from "applesauce-core/operations/tags";
|
|
5
5
|
import { removeSingletonTag, setSingletonTag } from "applesauce-core/operations/tag/common";
|
|
6
6
|
import { GIT_REPOSITORY_KIND } from "../helpers/git-repository.js";
|
|
@@ -46,7 +46,7 @@ export function setGitRepositoryCloneUrls(urls) {
|
|
|
46
46
|
/** Sets the repository relay URLs (single `relays` tag, normalized). */
|
|
47
47
|
export function setGitRepositoryRelays(relays) {
|
|
48
48
|
return modifyPublicTags((tags) => {
|
|
49
|
-
const normalized = relays.map((relay) =>
|
|
49
|
+
const normalized = relays.map((relay) => serializeURL(relay));
|
|
50
50
|
return withFlatListTag(tags, "relays", normalized);
|
|
51
51
|
});
|
|
52
52
|
}
|
|
@@ -84,7 +84,7 @@ export function removeGitRepositoryCloneUrl(url) {
|
|
|
84
84
|
}
|
|
85
85
|
/** Adds a repository relay URL. */
|
|
86
86
|
export function addGitRepositoryRelay(relay) {
|
|
87
|
-
const normalized =
|
|
87
|
+
const normalized = serializeURL(relay);
|
|
88
88
|
return modifyPublicTags((tags) => {
|
|
89
89
|
const cur = collectFlatTagValues(tags, "relays");
|
|
90
90
|
if (cur.includes(normalized))
|
|
@@ -94,7 +94,7 @@ export function addGitRepositoryRelay(relay) {
|
|
|
94
94
|
}
|
|
95
95
|
/** Removes a repository relay URL. */
|
|
96
96
|
export function removeGitRepositoryRelay(relay) {
|
|
97
|
-
const normalized =
|
|
97
|
+
const normalized = serializeURL(relay);
|
|
98
98
|
return modifyPublicTags((tags) => {
|
|
99
99
|
const cur = collectFlatTagValues(tags, "relays").filter((r) => r !== normalized);
|
|
100
100
|
return withFlatListTag(tags, "relays", cur);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { EventOperation } from "applesauce-core/factories";
|
|
2
|
+
import { NostrEvent } from "applesauce-core/helpers/event";
|
|
3
|
+
import { EventPointer } from "applesauce-core/helpers/pointers";
|
|
4
|
+
/**
|
|
5
|
+
* Sets the original root and removes tags belonging to a replaced target
|
|
6
|
+
* @throws if the target is not an issue, pull request or original root patch
|
|
7
|
+
*/
|
|
8
|
+
export declare function setGitStatusRoot(root: NostrEvent, relay?: string): EventOperation;
|
|
9
|
+
/**
|
|
10
|
+
* Replaces the applied patch references, retaining relay and author hints
|
|
11
|
+
* @throws if a patch id is invalid
|
|
12
|
+
*/
|
|
13
|
+
export declare function setGitStatusAppliedPatches(patches: (string | EventPointer)[]): EventOperation;
|
|
14
|
+
/**
|
|
15
|
+
* Sets or removes the accepted revision root and tags its author
|
|
16
|
+
* @throws if the event is not a revision root patch
|
|
17
|
+
*/
|
|
18
|
+
export declare function setGitStatusAcceptedRevision(revision: NostrEvent | null, relay?: string): EventOperation;
|
|
19
|
+
/**
|
|
20
|
+
* Sets or removes the merge commit and its discovery tag
|
|
21
|
+
* @throws if the commit is not a Git object id
|
|
22
|
+
*/
|
|
23
|
+
export declare function setGitStatusMergeCommit(commit: string | null): EventOperation;
|
|
24
|
+
/**
|
|
25
|
+
* Replaces the applied commit ids and their discovery tags
|
|
26
|
+
* @throws if a commit is not a Git object id
|
|
27
|
+
*/
|
|
28
|
+
export declare function setGitStatusAppliedCommits(commits: string[]): EventOperation;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { isHexKey } from "applesauce-core/helpers/string";
|
|
2
|
+
import { modifyPublicTags } from "applesauce-core/operations/tags";
|
|
3
|
+
import { isValidGitIssue } from "../helpers/git-issue.js";
|
|
4
|
+
import { isGitPatchRoot, isGitPatchRootRevision, isValidGitPatch } from "../helpers/git-patch.js";
|
|
5
|
+
import { isValidGitPullRequest } from "../helpers/git-pull-request.js";
|
|
6
|
+
import { getGitRepositoryReference } from "../helpers/git-repository.js";
|
|
7
|
+
import { isGitCommitId } from "../helpers/git.js";
|
|
8
|
+
import { createGitRepositoryTags } from "./git-thread.js";
|
|
9
|
+
import { replaceGitCommitReferences } from "./internal/git-commits.js";
|
|
10
|
+
/**
|
|
11
|
+
* Sets the original root and removes tags belonging to a replaced target
|
|
12
|
+
* @throws if the target is not an issue, pull request or original root patch
|
|
13
|
+
*/
|
|
14
|
+
export function setGitStatusRoot(root, relay = "") {
|
|
15
|
+
if (!(isValidGitIssue(root) ||
|
|
16
|
+
isValidGitPullRequest(root) ||
|
|
17
|
+
(isValidGitPatch(root) && isGitPatchRoot(root) && !isGitPatchRootRevision(root))) ||
|
|
18
|
+
!isHexKey(root.id) ||
|
|
19
|
+
!isHexKey(root.pubkey))
|
|
20
|
+
throw new Error("Expected an issue, pull request or original root patch");
|
|
21
|
+
return modifyPublicTags((tags) => {
|
|
22
|
+
const oldRoot = tags.find((t) => t[0] === "e" && t[3] === "root");
|
|
23
|
+
const changed = !!oldRoot && oldRoot[1] !== root.id;
|
|
24
|
+
const oldOwner = getGitRepositoryReference({ tags })?.pubkey;
|
|
25
|
+
const oldAuthor = oldRoot?.[4];
|
|
26
|
+
const oldRevisionAuthor = tags.find((t) => t[0] === "e" && t[3] === "reply")?.[4];
|
|
27
|
+
const scoped = ["q", "merge-commit", "applied-as-commits"];
|
|
28
|
+
const next = tags.filter((t) => t[0] !== "a" &&
|
|
29
|
+
t[0] !== "r" &&
|
|
30
|
+
!(t[0] === "e" && (t[3] === "root" || (changed && t[3] === "reply"))) &&
|
|
31
|
+
!(changed &&
|
|
32
|
+
(scoped.includes(t[0]) || (t[0] === "p" && [oldOwner, oldAuthor, oldRevisionAuthor].includes(t[1])))));
|
|
33
|
+
// The fifth field preserves the generated author when the target is replaced later.
|
|
34
|
+
next.push(["e", root.id, relay, "root", root.pubkey]);
|
|
35
|
+
const repo = getGitRepositoryReference(root);
|
|
36
|
+
for (const tag of createGitRepositoryTags(repo))
|
|
37
|
+
if (tag[0] !== "p")
|
|
38
|
+
next.push(tag);
|
|
39
|
+
const patchCommit = root.tags.find((t) => t[0] === "commit")?.[1];
|
|
40
|
+
const euc = root.tags.find((t) => t[0] === "r" &&
|
|
41
|
+
(t[1] !== patchCommit || root.tags.filter((r) => r[0] === "r" && r[1] === patchCommit).length > 1))?.[1];
|
|
42
|
+
if (euc)
|
|
43
|
+
next.push(["r", euc]);
|
|
44
|
+
for (const pubkey of new Set([root.pubkey, repo.pubkey]))
|
|
45
|
+
if (!next.some((t) => t[0] === "p" && t[1] === pubkey))
|
|
46
|
+
next.push(["p", pubkey]);
|
|
47
|
+
for (const commit of next.filter((t) => scoped.slice(1).includes(t[0])).flatMap((t) => t.slice(1)))
|
|
48
|
+
next.push(["r", commit]);
|
|
49
|
+
return next;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Replaces the applied patch references, retaining relay and author hints
|
|
54
|
+
* @throws if a patch id is invalid
|
|
55
|
+
*/
|
|
56
|
+
export function setGitStatusAppliedPatches(patches) {
|
|
57
|
+
if (patches.some((patch) => !isHexKey(typeof patch === "string" ? patch : patch.id)))
|
|
58
|
+
throw new Error("Invalid patch id");
|
|
59
|
+
return modifyPublicTags((tags) => [
|
|
60
|
+
...tags.filter((t) => t[0] !== "q"),
|
|
61
|
+
...patches.map((patch) => typeof patch === "string"
|
|
62
|
+
? ["q", patch]
|
|
63
|
+
: ["q", patch.id, patch.relays?.[0] || "", ...(patch.author ? [patch.author] : [])]),
|
|
64
|
+
]);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Sets or removes the accepted revision root and tags its author
|
|
68
|
+
* @throws if the event is not a revision root patch
|
|
69
|
+
*/
|
|
70
|
+
export function setGitStatusAcceptedRevision(revision, relay = "") {
|
|
71
|
+
if (revision &&
|
|
72
|
+
(!isValidGitPatch(revision) ||
|
|
73
|
+
!isGitPatchRootRevision(revision) ||
|
|
74
|
+
!isHexKey(revision.id) ||
|
|
75
|
+
!isHexKey(revision.pubkey)))
|
|
76
|
+
throw new Error("Expected a revision root patch");
|
|
77
|
+
return modifyPublicTags((tags) => {
|
|
78
|
+
const root = tags.find((t) => t[0] === "e" && t[3] === "root");
|
|
79
|
+
const previous = revision?.tags.find((t) => t[0] === "e" && t[3] === "reply")?.[1];
|
|
80
|
+
if (revision && (!root || previous !== root[1]))
|
|
81
|
+
throw new Error("Revision must reference the status root");
|
|
82
|
+
const oldAuthor = tags.find((t) => t[0] === "e" && t[3] === "reply")?.[4];
|
|
83
|
+
const repository = getGitRepositoryReference({ tags });
|
|
84
|
+
const revisionRepository = revision && getGitRepositoryReference(revision);
|
|
85
|
+
if (revision &&
|
|
86
|
+
(repository?.pubkey !== revisionRepository?.pubkey || repository?.identifier !== revisionRepository?.identifier))
|
|
87
|
+
throw new Error("Revision must belong to the status repository");
|
|
88
|
+
const owner = repository?.pubkey;
|
|
89
|
+
const next = tags.filter((t) => !(t[0] === "e" && t[3] === "reply") &&
|
|
90
|
+
!(t[0] === "p" && t[1] === oldAuthor && t[1] !== root?.[4] && t[1] !== owner));
|
|
91
|
+
if (revision) {
|
|
92
|
+
next.push(["e", revision.id, relay, "reply", revision.pubkey]);
|
|
93
|
+
if (!next.some((t) => t[0] === "p" && t[1] === revision.pubkey))
|
|
94
|
+
next.push(["p", revision.pubkey]);
|
|
95
|
+
}
|
|
96
|
+
return next;
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Sets or removes the merge commit and its discovery tag
|
|
101
|
+
* @throws if the commit is not a Git object id
|
|
102
|
+
*/
|
|
103
|
+
export function setGitStatusMergeCommit(commit) {
|
|
104
|
+
if (commit !== null && !isGitCommitId(commit))
|
|
105
|
+
throw new Error("Invalid Git commit id");
|
|
106
|
+
return modifyPublicTags((tags) => replaceGitCommitReferences(tags, "merge-commit", commit ? [commit] : []));
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Replaces the applied commit ids and their discovery tags
|
|
110
|
+
* @throws if a commit is not a Git object id
|
|
111
|
+
*/
|
|
112
|
+
export function setGitStatusAppliedCommits(commits) {
|
|
113
|
+
if (commits.some((commit) => !isGitCommitId(commit)))
|
|
114
|
+
throw new Error("Invalid Git commit id");
|
|
115
|
+
return modifyPublicTags((tags) => replaceGitCommitReferences(tags, "applied-as-commits", commits));
|
|
116
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { EventOperation } from "applesauce-core/factories";
|
|
2
|
+
import { NostrEvent } from "applesauce-core/helpers/event";
|
|
3
|
+
import { GitRepositoryPointer } from "../helpers/git-repository.js";
|
|
4
|
+
/**
|
|
5
|
+
* Returns the tags linking a thread to a repository
|
|
6
|
+
* @throws if the event or pointer is not a valid repository
|
|
7
|
+
*/
|
|
8
|
+
export declare function createGitRepositoryTags(repo: GitRepositoryPointer | NostrEvent): string[][];
|
|
9
|
+
/**
|
|
10
|
+
* Replaces repository tags while preserving commit references and unrelated recipients
|
|
11
|
+
* @throws if the event or pointer is not a valid repository
|
|
12
|
+
*/
|
|
13
|
+
export declare function setGitThreadRepository(repo: GitRepositoryPointer | NostrEvent): EventOperation;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { isEvent } from "applesauce-core/helpers/event";
|
|
2
|
+
import { createATagFromAddressPointer } from "applesauce-core/helpers/factory";
|
|
3
|
+
import { getAddressPointerForEvent } from "applesauce-core/helpers/pointers";
|
|
4
|
+
import { isHexKey } from "applesauce-core/helpers/string";
|
|
5
|
+
import { modifyPublicTags } from "applesauce-core/operations/tags";
|
|
6
|
+
import { GIT_REPOSITORY_KIND, getGitRepositoryEarliestUniqueCommit, getGitRepositoryReference, isValidGitRepository, } from "../helpers/git-repository.js";
|
|
7
|
+
/**
|
|
8
|
+
* Returns the tags linking a thread to a repository
|
|
9
|
+
* @throws if the event or pointer is not a valid repository
|
|
10
|
+
*/
|
|
11
|
+
export function createGitRepositoryTags(repo) {
|
|
12
|
+
if (isEvent(repo) && !isValidGitRepository(repo))
|
|
13
|
+
throw new Error("Expected a git repository event");
|
|
14
|
+
const pointer = isEvent(repo) ? getAddressPointerForEvent(repo) : repo;
|
|
15
|
+
if (!pointer || pointer.kind !== GIT_REPOSITORY_KIND || !pointer.identifier || !isHexKey(pointer.pubkey))
|
|
16
|
+
throw new Error("Expected a git repository pointer");
|
|
17
|
+
const tags = [createATagFromAddressPointer(pointer), ["p", pointer.pubkey]];
|
|
18
|
+
const euc = isEvent(repo) ? getGitRepositoryEarliestUniqueCommit(repo) : undefined;
|
|
19
|
+
if (euc)
|
|
20
|
+
tags.push(["r", euc]);
|
|
21
|
+
return tags;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Replaces repository tags while preserving commit references and unrelated recipients
|
|
25
|
+
* @throws if the event or pointer is not a valid repository
|
|
26
|
+
*/
|
|
27
|
+
export function setGitThreadRepository(repo) {
|
|
28
|
+
const repoTags = createGitRepositoryTags(repo);
|
|
29
|
+
return modifyPublicTags((tags) => {
|
|
30
|
+
const oldRepo = getGitRepositoryReference({ tags });
|
|
31
|
+
const commitTags = tags
|
|
32
|
+
.filter((t) => ["commit", "c", "merge-commit", "applied-as-commits"].includes(t[0]))
|
|
33
|
+
.flatMap((t) => [...new Set(t.slice(1))])
|
|
34
|
+
.filter((id) => tags.some((t) => t[0] === "r" && t[1] === id))
|
|
35
|
+
.map((id) => ["r", id]);
|
|
36
|
+
const next = tags.filter((t) => t[0] !== "a" && t[0] !== "r" && !(t[0] === "p" && (t[1] === oldRepo?.pubkey || t[1] === repoTags[1][1])));
|
|
37
|
+
return [...next, ...commitTags, ...repoTags];
|
|
38
|
+
});
|
|
39
|
+
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export * as AppData from "./app-data.js";
|
|
2
|
+
export * as AppHandler from "./app-handler.js";
|
|
3
|
+
export * as AppRecommendation from "./app-recommendation.js";
|
|
2
4
|
export * as Badge from "./badge.js";
|
|
3
5
|
export * as BadgeAward from "./badge-award.js";
|
|
4
6
|
export * as CodeSnippet from "./code-snippet.js";
|
|
@@ -6,13 +8,22 @@ export * as Calendar from "./calendar.js";
|
|
|
6
8
|
export * as CalendarEvent from "./calendar-event.js";
|
|
7
9
|
export * as CalendarRsvp from "./calendar-rsvp.js";
|
|
8
10
|
export * as Channel from "./channel.js";
|
|
11
|
+
export * as ChatMessage from "./chat-message.js";
|
|
12
|
+
export * as ForumThread from "./forum-thread.js";
|
|
9
13
|
export * as Client from "./client.js";
|
|
10
14
|
export * as Comment from "./comment.js";
|
|
15
|
+
export * as ExternalIdentities from "./external-identities.js";
|
|
16
|
+
export * as FileMessage from "./file-message.js";
|
|
11
17
|
export * as FileMetadata from "./file-metadata.js";
|
|
12
18
|
export * as Geohash from "./geohash.js";
|
|
13
19
|
export * as GiftWrap from "./gift-wrap.js";
|
|
14
20
|
export * as GitGraspList from "./git-grasp-list.js";
|
|
21
|
+
export * as GitIssue from "./git-issue.js";
|
|
22
|
+
export * as GitThread from "./git-thread.js";
|
|
23
|
+
export * as GitPatch from "./git-patch.js";
|
|
24
|
+
export * as GitPullRequest from "./git-pull-request.js";
|
|
15
25
|
export * as GitRepository from "./git-repository.js";
|
|
26
|
+
export * as GitStatus from "./git-status.js";
|
|
16
27
|
export * as Group from "./group.js";
|
|
17
28
|
export * as Hashtags from "./hashtags.js";
|
|
18
29
|
export * as Highlight from "./highlight.js";
|
|
@@ -20,6 +31,8 @@ export * as LegacyMessage from "./legacy-message.js";
|
|
|
20
31
|
export * as List from "./list.js";
|
|
21
32
|
export * as LiveStream from "./live-stream.js";
|
|
22
33
|
export * as MediaAttachment from "./media-attachment.js";
|
|
34
|
+
export * as Napplet from "./napplet.js";
|
|
35
|
+
export * as NappletHandlers from "./napplet-handlers.js";
|
|
23
36
|
export * as Note from "./note.js";
|
|
24
37
|
export * as NostrWebToken from "./nostr-web-token.js";
|
|
25
38
|
export * as PicturePost from "./picture-post.js";
|
|
@@ -30,9 +43,13 @@ export * as ProfileBadges from "./profile-badges.js";
|
|
|
30
43
|
export * as Stream from "./stream.js";
|
|
31
44
|
export * as StreamChat from "./stream-chat.js";
|
|
32
45
|
export * as Torrent from "./torrent.js";
|
|
46
|
+
export * as TrustedProviders from "./trusted-providers.js";
|
|
47
|
+
export * as UserStatus from "./user-status.js";
|
|
33
48
|
export * as WrappedMessage from "./wrapped-message.js";
|
|
34
49
|
export * as Zap from "./zap.js";
|
|
35
50
|
export * as ZapGoal from "./zap-goal.js";
|
|
36
51
|
export * as ZapRequest from "./zap-request.js";
|
|
37
52
|
export * as ZapSplit from "./zap-split.js";
|
|
38
53
|
export * as TagOperations from "./tag/index.js";
|
|
54
|
+
export * from "./nsite.js";
|
|
55
|
+
export * from "./report.js";
|
package/dist/operations/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export * as AppData from "./app-data.js";
|
|
2
|
+
export * as AppHandler from "./app-handler.js";
|
|
3
|
+
export * as AppRecommendation from "./app-recommendation.js";
|
|
2
4
|
export * as Badge from "./badge.js";
|
|
3
5
|
export * as BadgeAward from "./badge-award.js";
|
|
4
6
|
export * as CodeSnippet from "./code-snippet.js";
|
|
@@ -6,13 +8,22 @@ export * as Calendar from "./calendar.js";
|
|
|
6
8
|
export * as CalendarEvent from "./calendar-event.js";
|
|
7
9
|
export * as CalendarRsvp from "./calendar-rsvp.js";
|
|
8
10
|
export * as Channel from "./channel.js";
|
|
11
|
+
export * as ChatMessage from "./chat-message.js";
|
|
12
|
+
export * as ForumThread from "./forum-thread.js";
|
|
9
13
|
export * as Client from "./client.js";
|
|
10
14
|
export * as Comment from "./comment.js";
|
|
15
|
+
export * as ExternalIdentities from "./external-identities.js";
|
|
16
|
+
export * as FileMessage from "./file-message.js";
|
|
11
17
|
export * as FileMetadata from "./file-metadata.js";
|
|
12
18
|
export * as Geohash from "./geohash.js";
|
|
13
19
|
export * as GiftWrap from "./gift-wrap.js";
|
|
14
20
|
export * as GitGraspList from "./git-grasp-list.js";
|
|
21
|
+
export * as GitIssue from "./git-issue.js";
|
|
22
|
+
export * as GitThread from "./git-thread.js";
|
|
23
|
+
export * as GitPatch from "./git-patch.js";
|
|
24
|
+
export * as GitPullRequest from "./git-pull-request.js";
|
|
15
25
|
export * as GitRepository from "./git-repository.js";
|
|
26
|
+
export * as GitStatus from "./git-status.js";
|
|
16
27
|
export * as Group from "./group.js";
|
|
17
28
|
export * as Hashtags from "./hashtags.js";
|
|
18
29
|
export * as Highlight from "./highlight.js";
|
|
@@ -20,6 +31,8 @@ export * as LegacyMessage from "./legacy-message.js";
|
|
|
20
31
|
export * as List from "./list.js";
|
|
21
32
|
export * as LiveStream from "./live-stream.js";
|
|
22
33
|
export * as MediaAttachment from "./media-attachment.js";
|
|
34
|
+
export * as Napplet from "./napplet.js";
|
|
35
|
+
export * as NappletHandlers from "./napplet-handlers.js";
|
|
23
36
|
export * as Note from "./note.js";
|
|
24
37
|
export * as NostrWebToken from "./nostr-web-token.js";
|
|
25
38
|
export * as PicturePost from "./picture-post.js";
|
|
@@ -30,9 +43,13 @@ export * as ProfileBadges from "./profile-badges.js";
|
|
|
30
43
|
export * as Stream from "./stream.js";
|
|
31
44
|
export * as StreamChat from "./stream-chat.js";
|
|
32
45
|
export * as Torrent from "./torrent.js";
|
|
46
|
+
export * as TrustedProviders from "./trusted-providers.js";
|
|
47
|
+
export * as UserStatus from "./user-status.js";
|
|
33
48
|
export * as WrappedMessage from "./wrapped-message.js";
|
|
34
49
|
export * as Zap from "./zap.js";
|
|
35
50
|
export * as ZapGoal from "./zap-goal.js";
|
|
36
51
|
export * as ZapRequest from "./zap-request.js";
|
|
37
52
|
export * as ZapSplit from "./zap-split.js";
|
|
38
53
|
export * as TagOperations from "./tag/index.js";
|
|
54
|
+
export * from "./nsite.js";
|
|
55
|
+
export * from "./report.js";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Replaces commit metadata and the discovery tags owned by that metadata */
|
|
2
|
+
export function replaceGitCommitReferences(tags, name, commits) {
|
|
3
|
+
const old = new Set(tags.filter((tag) => tag[0] === name).flatMap((tag) => tag.slice(1)));
|
|
4
|
+
const next = tags.filter((tag) => tag[0] !== name);
|
|
5
|
+
// Each generated role owns one discovery tag; the same id may also identify the repository.
|
|
6
|
+
for (const commit of old) {
|
|
7
|
+
for (let index = next.length - 1; index >= 0; index--) {
|
|
8
|
+
if (next[index][0] === "r" && next[index][1] === commit) {
|
|
9
|
+
next.splice(index, 1);
|
|
10
|
+
break;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const ids = [...new Set(commits)];
|
|
15
|
+
return [...next, ...(ids.length ? [[name, ...ids], ...ids.map((id) => ["r", id])] : [])];
|
|
16
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { TagOperation } from "applesauce-core/factories";
|
|
2
|
+
import { NostrEvent } from "applesauce-core/helpers/event";
|
|
3
|
+
import { AddressPointer, EventPointer } from "applesauce-core/helpers/pointers";
|
|
4
|
+
/** A napplet to reference: a coordinate, snapshot id, `naddr`, `nevent`, pointer, or manifest event */
|
|
5
|
+
export type NappletHandlerInput = string | AddressPointer | EventPointer | NostrEvent;
|
|
6
|
+
/**
|
|
7
|
+
* Creates the archetype-wide `a` or `e` tag for a napplet
|
|
8
|
+
* @throws if the input is not a root or named napplet, or a kind 5129 snapshot
|
|
9
|
+
*/
|
|
10
|
+
export declare function createNappletHandlerTag(input: NappletHandlerInput): string[];
|
|
11
|
+
/**
|
|
12
|
+
* Returns the coordinate or snapshot id used as an `i` tag reference
|
|
13
|
+
* @throws if the input is not a root or named napplet, or a kind 5129 snapshot
|
|
14
|
+
*/
|
|
15
|
+
export declare function getNappletHandlerReference(input: NappletHandlerInput): string;
|
|
16
|
+
/**
|
|
17
|
+
* Adds an archetype-wide handler as the last fallback, or updates its relay hint in place
|
|
18
|
+
* @throws if the input is not a root or named napplet, or a kind 5129 snapshot
|
|
19
|
+
*/
|
|
20
|
+
export declare function addNappletHandlerTag(input: NappletHandlerInput): TagOperation;
|
|
21
|
+
/**
|
|
22
|
+
* Moves or inserts an archetype-wide handler to the front so it becomes preferred
|
|
23
|
+
* @throws if the input is not a root or named napplet, or a kind 5129 snapshot
|
|
24
|
+
*/
|
|
25
|
+
export declare function preferNappletHandlerTag(input: NappletHandlerInput): TagOperation;
|
|
26
|
+
/**
|
|
27
|
+
* Removes an archetype-wide handler
|
|
28
|
+
* @throws if the input is not a root or named napplet, or a kind 5129 snapshot
|
|
29
|
+
*/
|
|
30
|
+
export declare function removeNappletHandlerTag(input: NappletHandlerInput): TagOperation;
|
|
31
|
+
/**
|
|
32
|
+
* Adds an intent-specific handler as the last fallback for a convention identity
|
|
33
|
+
* @throws if the identity is invalid, or the input is not a napplet or kind 5129 snapshot
|
|
34
|
+
*/
|
|
35
|
+
export declare function addNappletIntentHandlerTag(identity: string, input: NappletHandlerInput): TagOperation;
|
|
36
|
+
/**
|
|
37
|
+
* Moves or inserts an intent-specific handler to the front so it becomes preferred for a convention identity
|
|
38
|
+
* @throws if the identity is invalid, or the input is not a napplet or kind 5129 snapshot
|
|
39
|
+
*/
|
|
40
|
+
export declare function preferNappletIntentHandlerTag(identity: string, input: NappletHandlerInput): TagOperation;
|
|
41
|
+
/**
|
|
42
|
+
* Removes one intent-specific handler, or every handler for the convention identity when no input is given
|
|
43
|
+
* @throws if the input is not a napplet or kind 5129 snapshot
|
|
44
|
+
*/
|
|
45
|
+
export declare function removeNappletIntentHandlerTag(identity: string, input?: NappletHandlerInput): TagOperation;
|
|
46
|
+
/** Removes every `a`, `e`, and `i` handler entry while keeping the `d` tag and unknown tags */
|
|
47
|
+
export declare function clearNappletHandlerTags(): TagOperation;
|