applesauce-common 6.2.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.
- 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 +11 -0
- package/dist/casts/index.js +11 -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/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 +22 -0
- package/dist/factories/index.js +22 -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-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/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.js +18 -1
- 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-metadata.js +5 -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 +10 -0
- package/dist/helpers/index.js +10 -0
- package/dist/helpers/lists.js +14 -2
- package/dist/helpers/lnurl.js +1 -1
- package/dist/helpers/mute.js +18 -7
- package/dist/helpers/napplet.d.ts +89 -0
- package/dist/helpers/napplet.js +144 -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/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 +3 -0
- package/dist/models/index.js +3 -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/observable/filter-timeline-by-mutes.d.ts +1 -1
- package/dist/observable/filter-timeline-by-mutes.js +5 -1
- 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/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 +15 -0
- package/dist/operations/index.js +15 -0
- package/dist/operations/internal/git-commits.d.ts +2 -0
- package/dist/operations/internal/git-commits.js +16 -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/package.json +9 -9
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { getReplaceableAddressFromPointer, parseReplaceableAddress, } from "applesauce-core/helpers/pointers";
|
|
2
|
+
import { isSafeRelayURL } from "applesauce-core/helpers/relays";
|
|
3
|
+
import { normalizeURL } from "applesauce-core/helpers/url";
|
|
4
|
+
import { setContent } from "applesauce-core/operations/content";
|
|
5
|
+
import { addNameValueTag, removeNameValueTag } from "applesauce-core/operations/tag/common";
|
|
6
|
+
import { modifyPublicTags } from "applesauce-core/operations/tags";
|
|
7
|
+
import { isNsiteAddressPointer, NSITE_KIND } from "../helpers/nsite.js";
|
|
8
|
+
function sameLink(t, platform, type) {
|
|
9
|
+
return t[0] === platform && (t[2] || undefined) === type;
|
|
10
|
+
}
|
|
11
|
+
function nsiteTag(name, site) {
|
|
12
|
+
let tag;
|
|
13
|
+
if (site !== null) {
|
|
14
|
+
const pointer = typeof site === "string" ? parseReplaceableAddress(site) : site;
|
|
15
|
+
if (!pointer || pointer.kind !== NSITE_KIND || !isNsiteAddressPointer(pointer))
|
|
16
|
+
throw new Error("Expected a named nsite address");
|
|
17
|
+
const relay = pointer.relays?.find(isSafeRelayURL);
|
|
18
|
+
tag = [name, getReplaceableAddressFromPointer(pointer), ...(relay ? [normalizeURL(relay)] : [])];
|
|
19
|
+
}
|
|
20
|
+
return modifyPublicTags((tags) => [...tags.filter((t) => t[0] !== name), ...(tag ? [tag] : [])]);
|
|
21
|
+
}
|
|
22
|
+
/** Sets the handler's kind:0-style metadata, or clears it to fall back to the author's profile */
|
|
23
|
+
export function setHandlerMetadata(metadata) {
|
|
24
|
+
return setContent(metadata ? JSON.stringify(metadata) : "");
|
|
25
|
+
}
|
|
26
|
+
/** Adds a supported event kind */
|
|
27
|
+
export function addHandlerKind(kind) {
|
|
28
|
+
return modifyPublicTags(addNameValueTag(["k", String(kind)]));
|
|
29
|
+
}
|
|
30
|
+
/** Removes a supported event kind */
|
|
31
|
+
export function removeHandlerKind(kind) {
|
|
32
|
+
return modifyPublicTags(removeNameValueTag(["k", String(kind)]));
|
|
33
|
+
}
|
|
34
|
+
/** Sets the URL template for a platform and NIP-19 entity type, or the generic template when type is omitted */
|
|
35
|
+
export function setHandlerLink(platform, url, type) {
|
|
36
|
+
return modifyPublicTags((tags) => [
|
|
37
|
+
...tags.filter((t) => !sameLink(t, platform, type)),
|
|
38
|
+
type ? [platform, url, type] : [platform, url],
|
|
39
|
+
]);
|
|
40
|
+
}
|
|
41
|
+
/** Removes the URL template for a platform and NIP-19 entity type */
|
|
42
|
+
export function removeHandlerLink(platform, type) {
|
|
43
|
+
return modifyPublicTags((tags) => tags.filter((t) => !sameLink(t, platform, type)));
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Sets or removes the named nsite the handler currently serves
|
|
47
|
+
* @throws if the address is not a named nsite (kind 35128)
|
|
48
|
+
*/
|
|
49
|
+
export function setHandlerLatest(site) {
|
|
50
|
+
return nsiteTag("latest", site);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Sets or removes the named nsite the handler is rolling out
|
|
54
|
+
* @throws if the address is not a named nsite (kind 35128)
|
|
55
|
+
*/
|
|
56
|
+
export function setHandlerNext(site) {
|
|
57
|
+
return nsiteTag("next", site);
|
|
58
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { EventOperation } from "applesauce-core/factories";
|
|
2
|
+
import { AddressPointer } from "applesauce-core/helpers/pointers";
|
|
3
|
+
import { HandlerLinkPlatform } from "../helpers/app-handler.js";
|
|
4
|
+
/**
|
|
5
|
+
* Adds or replaces a recommended handler for a platform
|
|
6
|
+
* @throws if the address is not a handler information event (kind 31990)
|
|
7
|
+
*/
|
|
8
|
+
export declare function addRecommendedHandler(handler: AddressPointer | string, platform?: HandlerLinkPlatform): EventOperation;
|
|
9
|
+
/**
|
|
10
|
+
* Removes a recommended handler for every platform, one platform, or only the entry without a platform when `null`
|
|
11
|
+
* @throws if the address is not a handler information event (kind 31990)
|
|
12
|
+
*/
|
|
13
|
+
export declare function removeRecommendedHandler(handler: AddressPointer | string, platform?: HandlerLinkPlatform | null): EventOperation;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { getReplaceableAddressFromPointer, parseReplaceableAddress, } from "applesauce-core/helpers/pointers";
|
|
2
|
+
import { isSafeRelayURL } from "applesauce-core/helpers/relays";
|
|
3
|
+
import { normalizeURL } from "applesauce-core/helpers/url";
|
|
4
|
+
import { modifyPublicTags } from "applesauce-core/operations/tags";
|
|
5
|
+
import { APP_HANDLER_KIND } from "../helpers/app-handler.js";
|
|
6
|
+
function handlerPointer(handler) {
|
|
7
|
+
const pointer = typeof handler === "string" ? parseReplaceableAddress(handler) : handler;
|
|
8
|
+
if (!pointer || pointer.kind !== APP_HANDLER_KIND)
|
|
9
|
+
throw new Error("Expected a NIP-89 handler address");
|
|
10
|
+
return pointer;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Adds or replaces a recommended handler for a platform
|
|
14
|
+
* @throws if the address is not a handler information event (kind 31990)
|
|
15
|
+
*/
|
|
16
|
+
export function addRecommendedHandler(handler, platform) {
|
|
17
|
+
const pointer = handlerPointer(handler);
|
|
18
|
+
const address = getReplaceableAddressFromPointer(pointer);
|
|
19
|
+
const relay = pointer.relays?.find(isSafeRelayURL);
|
|
20
|
+
// The relay hint is positional, so keep an empty slot when only the platform is known
|
|
21
|
+
const tag = [
|
|
22
|
+
"a",
|
|
23
|
+
address,
|
|
24
|
+
...(relay || platform ? [relay ? normalizeURL(relay) : ""] : []),
|
|
25
|
+
...(platform ? [platform] : []),
|
|
26
|
+
];
|
|
27
|
+
return modifyPublicTags((tags) => [
|
|
28
|
+
...tags.filter((t) => !(t[0] === "a" && t[1] === address && t[3] === platform)),
|
|
29
|
+
tag,
|
|
30
|
+
]);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Removes a recommended handler for every platform, one platform, or only the entry without a platform when `null`
|
|
34
|
+
* @throws if the address is not a handler information event (kind 31990)
|
|
35
|
+
*/
|
|
36
|
+
export function removeRecommendedHandler(handler, platform) {
|
|
37
|
+
const address = getReplaceableAddressFromPointer(handlerPointer(handler));
|
|
38
|
+
const matches = (t) => (platform === undefined ? true : platform === null ? !t[3] : t[3] === platform);
|
|
39
|
+
return modifyPublicTags((tags) => tags.filter((t) => !(t[0] === "a" && t[1] === address && matches(t))));
|
|
40
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { serializeURL } from "applesauce-core/helpers/url";
|
|
1
2
|
import { addNameValueTag, removeNameValueTag, setSingletonTag } from "applesauce-core/operations/tag/common";
|
|
2
3
|
import { includeNameValueTag, includeSingletonTag, modifyPublicTags } from "applesauce-core/operations/tags";
|
|
3
4
|
import { createCalendarEventParticipantTag } from "../helpers/calendar-event.js";
|
|
@@ -32,11 +33,11 @@ export function removeLocation(location) {
|
|
|
32
33
|
}
|
|
33
34
|
/** Adds a location to a calendar event */
|
|
34
35
|
export function addReferenceLink(link) {
|
|
35
|
-
return modifyPublicTags(addNameValueTag(["r",
|
|
36
|
+
return modifyPublicTags(addNameValueTag(["r", serializeURL(link)], true));
|
|
36
37
|
}
|
|
37
38
|
/** Removes a location from a calendar event */
|
|
38
39
|
export function removeReferenceLink(link) {
|
|
39
|
-
return modifyPublicTags(removeNameValueTag(["r",
|
|
40
|
+
return modifyPublicTags(removeNameValueTag(["r", serializeURL(link)]));
|
|
40
41
|
}
|
|
41
42
|
/** Removes all locations from a calendar event */
|
|
42
43
|
export function clearLocations() {
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
* Adds a NIP-C7 `q` reply tag pointing at the parent chat message. A reply to a
|
|
6
|
+
* kind 9 is another kind 9 that quotes its parent with a `q` tag
|
|
7
|
+
* (`["q", <id>, <relay>, <pubkey>]`).
|
|
8
|
+
*/
|
|
9
|
+
export declare function includeChatReply(parent: NostrEvent | EventPointer): EventOperation;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ensureQuoteEventPointerTag } from "applesauce-core/helpers/factory";
|
|
2
|
+
import { modifyPublicTags } from "applesauce-core/operations/tags";
|
|
3
|
+
/**
|
|
4
|
+
* Adds a NIP-C7 `q` reply tag pointing at the parent chat message. A reply to a
|
|
5
|
+
* kind 9 is another kind 9 that quotes its parent with a `q` tag
|
|
6
|
+
* (`["q", <id>, <relay>, <pubkey>]`).
|
|
7
|
+
*/
|
|
8
|
+
export function includeChatReply(parent) {
|
|
9
|
+
// Normalize a full event to an EventPointer (pubkey -> author)
|
|
10
|
+
const pointer = "pubkey" in parent ? { id: parent.id, author: parent.pubkey } : parent;
|
|
11
|
+
return modifyPublicTags((tags) => ensureQuoteEventPointerTag(tags, pointer));
|
|
12
|
+
}
|
|
@@ -1,4 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { AddressPointer } from "applesauce-core/helpers/pointers";
|
|
3
|
-
/** Includes a NIP-89 client tag in an event*/
|
|
4
|
-
export declare function setClient(name: string, pointer?: Omit<AddressPointer, "kind" | "relays">, replace?: boolean): EventOperation;
|
|
1
|
+
export { setClient } from "applesauce-core/operations/client";
|
|
@@ -1,23 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { getReplaceableAddressFromPointer } from "applesauce-core/helpers/pointers";
|
|
3
|
-
import { fillAndTrimTag } from "applesauce-core/helpers/tags";
|
|
4
|
-
import { includeSingletonTag } from "applesauce-core/operations/tags";
|
|
5
|
-
// A list of event kinds to never attach the "client" tag to
|
|
6
|
-
const NEVER_ATTACH_CLIENT_TAG = [kinds.EncryptedDirectMessage, kinds.GiftWrap, kinds.Seal];
|
|
7
|
-
/** Includes a NIP-89 client tag in an event*/
|
|
8
|
-
export function setClient(name, pointer, replace = true) {
|
|
9
|
-
return (draft) => {
|
|
10
|
-
if (NEVER_ATTACH_CLIENT_TAG.includes(draft.kind))
|
|
11
|
-
return draft;
|
|
12
|
-
else {
|
|
13
|
-
const coordinate = pointer
|
|
14
|
-
? getReplaceableAddressFromPointer({
|
|
15
|
-
pubkey: pointer.pubkey,
|
|
16
|
-
identifier: pointer.identifier,
|
|
17
|
-
kind: kinds.Handlerinformation,
|
|
18
|
-
})
|
|
19
|
-
: undefined;
|
|
20
|
-
return includeSingletonTag(fillAndTrimTag(["client", name, coordinate]), replace)(draft);
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
}
|
|
1
|
+
export { setClient } from "applesauce-core/operations/client";
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { EventOperation } from "applesauce-core/factories";
|
|
2
|
-
import { NostrEvent } from "applesauce-core/helpers/event";
|
|
2
|
+
import { NostrEvent, Rumor } from "applesauce-core/helpers/event";
|
|
3
3
|
import { CommentPointer } from "../helpers/comment.js";
|
|
4
|
+
/**
|
|
5
|
+
* The event a comment points to. A full event/rumor carries its tags (so a reply
|
|
6
|
+
* to another comment can inherit that comment's root pointer), or a
|
|
7
|
+
* {@link CommentPointer} for cases where only the identity is known.
|
|
8
|
+
*/
|
|
9
|
+
export type CommentParent = NostrEvent | Rumor | CommentPointer;
|
|
4
10
|
/**
|
|
5
11
|
* Sets the necessary tags for a NIP-22 comment event to point to a parent event or pointer
|
|
6
|
-
* @param parent - Parent event or comment pointer
|
|
12
|
+
* @param parent - Parent event, rumor, or comment pointer
|
|
7
13
|
* @param getRelayHint - Optional function to get relay hint for event ID
|
|
8
14
|
*/
|
|
9
|
-
export declare function setParent(parent:
|
|
15
|
+
export declare function setParent(parent: CommentParent, getRelayHint?: (eventId: string) => Promise<string | undefined>): EventOperation;
|
|
@@ -1,15 +1,23 @@
|
|
|
1
|
-
import { isEvent } from "applesauce-core/helpers/event";
|
|
2
1
|
import { COMMENT_KIND, createCommentTagsForEvent, createCommentTagsFromCommentPointer, } from "../helpers/comment.js";
|
|
3
2
|
/**
|
|
4
3
|
* Sets the necessary tags for a NIP-22 comment event to point to a parent event or pointer
|
|
5
|
-
* @param parent - Parent event or comment pointer
|
|
4
|
+
* @param parent - Parent event, rumor, or comment pointer
|
|
6
5
|
* @param getRelayHint - Optional function to get relay hint for event ID
|
|
7
6
|
*/
|
|
8
7
|
export function setParent(parent, getRelayHint) {
|
|
9
8
|
return async (draft) => {
|
|
10
9
|
let tags = Array.from(draft.tags);
|
|
11
|
-
//
|
|
12
|
-
|
|
10
|
+
// Only a full event or rumor carries tags; a pointer is just an identity.
|
|
11
|
+
// Discriminate on that rather than on the signature — an unsigned rumor
|
|
12
|
+
// (e.g. a NIP-59 seal's inner event) has everything needed to build tags.
|
|
13
|
+
if ("tags" in parent) {
|
|
14
|
+
const relayHint = getRelayHint ? await getRelayHint(parent.id) : undefined;
|
|
15
|
+
tags.push(...createCommentTagsForEvent(parent, relayHint));
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
// A pointer to a comment carries no root tags, and NIP-22 requires nested
|
|
19
|
+
// replies to stay rooted on the original event — so the full comment
|
|
20
|
+
// event is the only thing correct root tags can be built from.
|
|
13
21
|
if (parent.kind === COMMENT_KIND)
|
|
14
22
|
throw new Error("Comment pointer cannot be a comment kind. please pass the full nip-22 comment event");
|
|
15
23
|
// For CommentPointer, treat as root comment: both root and reply tags point to the same pointer
|
|
@@ -19,11 +27,6 @@ export function setParent(parent, getRelayHint) {
|
|
|
19
27
|
// Add reply tags (lowercase)
|
|
20
28
|
tags.push(...createCommentTagsFromCommentPointer(parent, false));
|
|
21
29
|
}
|
|
22
|
-
else {
|
|
23
|
-
// If parent is a NostrEvent, use existing logic
|
|
24
|
-
const relayHint = getRelayHint ? await getRelayHint(parent.id) : undefined;
|
|
25
|
-
tags.push(...createCommentTagsForEvent(parent, relayHint));
|
|
26
|
-
}
|
|
27
30
|
return { ...draft, tags };
|
|
28
31
|
};
|
|
29
32
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { EventOperation } from "applesauce-core/factories";
|
|
2
|
+
import { ExternalIdentity } from "../helpers/external-identities.js";
|
|
3
|
+
/** Adds or replaces an external identity */
|
|
4
|
+
export declare function addExternalIdentity(identity: ExternalIdentity): EventOperation;
|
|
5
|
+
/** Removes an external identity */
|
|
6
|
+
export declare function removeExternalIdentity(platform: string, identity: string): EventOperation;
|
|
7
|
+
/** Replaces all external identities */
|
|
8
|
+
export declare function setExternalIdentities(identities: ExternalIdentity[]): EventOperation;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { modifyPublicTags } from "applesauce-core/operations/tags";
|
|
2
|
+
import { createExternalIdentityTag } from "../helpers/external-identities.js";
|
|
3
|
+
function isIdentityTag(tag, platform, identity) {
|
|
4
|
+
return tag[0] === "i" && tag[1] === `${platform}:${identity}`;
|
|
5
|
+
}
|
|
6
|
+
/** Adds or replaces an external identity */
|
|
7
|
+
export function addExternalIdentity(identity) {
|
|
8
|
+
return modifyPublicTags((tags) => [
|
|
9
|
+
...tags.filter((tag) => !isIdentityTag(tag, identity.platform, identity.identity)),
|
|
10
|
+
createExternalIdentityTag(identity),
|
|
11
|
+
]);
|
|
12
|
+
}
|
|
13
|
+
/** Removes an external identity */
|
|
14
|
+
export function removeExternalIdentity(platform, identity) {
|
|
15
|
+
return modifyPublicTags((tags) => tags.filter((tag) => !isIdentityTag(tag, platform, identity)));
|
|
16
|
+
}
|
|
17
|
+
/** Replaces all external identities */
|
|
18
|
+
export function setExternalIdentities(identities) {
|
|
19
|
+
return modifyPublicTags((tags) => [
|
|
20
|
+
...tags.filter((tag) => tag[0] !== "i"),
|
|
21
|
+
...identities.map(createExternalIdentityTag),
|
|
22
|
+
]);
|
|
23
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { setSingletonTag } from "applesauce-core/operations/tag/common";
|
|
2
|
+
import { modifyPublicTags } from "applesauce-core/operations/tags";
|
|
3
|
+
/** Sets the NIP-7D `title` tag on a forum thread (kind 11) */
|
|
4
|
+
export function setTitle(title) {
|
|
5
|
+
return modifyPublicTags(setSingletonTag(["title", title]));
|
|
6
|
+
}
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
// Read https://github.com/nostr-protocol/nips/blob/master/59.md#overview for details on rumors and seals
|
|
2
2
|
// Gift wrap (signed random key) -> seal (signed sender key) -> rumor (unsigned)
|
|
3
3
|
import { blankEventTemplate } from "applesauce-core/factories";
|
|
4
|
+
import { setCachedValue } from "applesauce-core/helpers/cache";
|
|
4
5
|
import { EncryptedContentSymbol } from "applesauce-core/helpers/encrypted-content";
|
|
5
6
|
import { nip44 } from "applesauce-core/helpers/encryption";
|
|
6
7
|
import { finalizeEvent, getEventHash, kinds, } from "applesauce-core/helpers/event";
|
|
7
8
|
import { generateSecretKey } from "applesauce-core/helpers/keys";
|
|
8
|
-
import { eventPipe
|
|
9
|
+
import { eventPipe } from "applesauce-core/helpers/pipeline";
|
|
9
10
|
import { unixNow } from "applesauce-core/helpers/time";
|
|
10
11
|
import { setEncryptedContent } from "applesauce-core/operations/encrypted-content";
|
|
11
12
|
import { setMetaTags, stamp } from "applesauce-core/operations/event";
|
|
12
13
|
import { GiftWrapSymbol, RumorSymbol, SealSymbol } from "../helpers/gift-wrap.js";
|
|
13
|
-
//
|
|
14
|
-
PRESERVE_EVENT_SYMBOLS.
|
|
15
|
-
PRESERVE_EVENT_SYMBOLS.add(SealSymbol);
|
|
16
|
-
PRESERVE_EVENT_SYMBOLS.add(RumorSymbol);
|
|
14
|
+
// GiftWrapSymbol/SealSymbol/RumorSymbol are static members of applesauce-core's
|
|
15
|
+
// PRESERVE_EVENT_SYMBOLS (see core/helpers/pipeline.ts) — no import-time mutation needed here.
|
|
17
16
|
/** Create a timestamp with a random offset of an hour */
|
|
18
17
|
function randomNow() {
|
|
19
18
|
return unixNow() - Math.floor(Math.random() * 60 * 60);
|
|
@@ -56,14 +55,23 @@ export function sealRumor(pubkey, signer) {
|
|
|
56
55
|
// Stamp the seal with the signer's pubkey
|
|
57
56
|
stamp(signer))({ ...blankEventTemplate(kinds.Seal), created_at: randomNow() });
|
|
58
57
|
const seal = await signer.signEvent(unsigned);
|
|
59
|
-
// Set the downstream reference on the seal
|
|
60
|
-
|
|
58
|
+
// Set the downstream reference on the seal: an object-reference link to `rumor`, not a
|
|
59
|
+
// value copy. `RumorSymbol` is a static member of `PRESERVE_EVENT_SYMBOLS` (applesauce-core),
|
|
60
|
+
// which stops `eventPipe`'s delete loop from scrubbing it mid-pipe — it is NOT carried onto a
|
|
61
|
+
// redelivered duplicate of this event by `EventStore.copySymbolsToDuplicateEvent`'s merge
|
|
62
|
+
// list, which has no gift-wrap symbols — accumulated state (see cache.ts one-rule doc block).
|
|
63
|
+
// Written non-enumerable via setCachedValue so a plain spread drops it instead of silently
|
|
64
|
+
// carrying a stale reference forward.
|
|
65
|
+
setCachedValue(seal, RumorSymbol, rumor);
|
|
61
66
|
// Add the upstream reference to the rumor
|
|
62
67
|
const seals = Reflect.get(rumor, SealSymbol);
|
|
63
68
|
if (seals)
|
|
64
69
|
seals.add(seal);
|
|
70
|
+
// Initializes the mutable Set that grows in place elsewhere (helpers/gift-wrap.ts's
|
|
71
|
+
// addParentSealReference) — accumulated state (see cache.ts one-rule doc block), not a memo.
|
|
72
|
+
// Written non-enumerable via setCachedValue.
|
|
65
73
|
else
|
|
66
|
-
|
|
74
|
+
setCachedValue(rumor, SealSymbol, new Set([seal]));
|
|
67
75
|
return seal;
|
|
68
76
|
};
|
|
69
77
|
}
|
|
@@ -81,12 +89,28 @@ export function wrapSeal(pubkey, opts) {
|
|
|
81
89
|
tags: [["p", pubkey]],
|
|
82
90
|
});
|
|
83
91
|
const gift = finalizeEvent(draft, key);
|
|
84
|
-
// Set the upstream
|
|
85
|
-
|
|
86
|
-
//
|
|
87
|
-
|
|
88
|
-
//
|
|
89
|
-
|
|
92
|
+
// Set the upstream reference on the seal: an object-reference link to `gift`, not a
|
|
93
|
+
// value copy. `GiftWrapSymbol` is a static member of `PRESERVE_EVENT_SYMBOLS` (applesauce-core),
|
|
94
|
+
// which stops `eventPipe`'s delete loop from scrubbing it mid-pipe — it is NOT carried onto a
|
|
95
|
+
// redelivered duplicate of this event by `EventStore.copySymbolsToDuplicateEvent`'s merge
|
|
96
|
+
// list, which has no gift-wrap symbols — accumulated state (see cache.ts one-rule doc block).
|
|
97
|
+
// Written non-enumerable via setCachedValue.
|
|
98
|
+
setCachedValue(seal, GiftWrapSymbol, gift);
|
|
99
|
+
// Set the downstream reference on the gift wrap: an object-reference link to `seal`, not
|
|
100
|
+
// a value copy. `SealSymbol`'s static membership in `PRESERVE_EVENT_SYMBOLS` (applesauce-core)
|
|
101
|
+
// buys survival of `eventPipe`'s delete loop, nothing more — it is NOT carried onto a
|
|
102
|
+
// redelivered duplicate of this event by that merge list, which has no gift-wrap symbols
|
|
103
|
+
// — accumulated state (see cache.ts one-rule doc block). Written non-enumerable via
|
|
104
|
+
// setCachedValue.
|
|
105
|
+
setCachedValue(gift, SealSymbol, seal);
|
|
106
|
+
// Set the encrypted content on the gift wrap: a build-path write, like applesauce-core's
|
|
107
|
+
// operations/tags.ts's modifyHiddenTags return and operations/encrypted-content.ts's
|
|
108
|
+
// setEncryptedContent return. `wrapSeal` is the last step of the `giftWrap` eventPipe, so this
|
|
109
|
+
// write survives because PRESERVE_EVENT_SYMBOLS keeps it through the delete loop that runs
|
|
110
|
+
// immediately after this operation — it is set directly on this operation's own returned
|
|
111
|
+
// event (`gift`), not inherited from a prior step's carry-forward. Written non-enumerable via
|
|
112
|
+
// setCachedValue (see cache.ts one-rule doc block).
|
|
113
|
+
setCachedValue(gift, EncryptedContentSymbol, plaintext);
|
|
90
114
|
return gift;
|
|
91
115
|
};
|
|
92
116
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { EventOperation } from "applesauce-core/factories";
|
|
2
|
+
import { NostrEvent } from "applesauce-core/helpers/event";
|
|
3
|
+
import { GitRepositoryPointer } from "../helpers/git-repository.js";
|
|
4
|
+
/** Returns the `a`, `p` and `r` tags that link an event to a repository */
|
|
5
|
+
export { createGitRepositoryTags } from "./git-thread.js";
|
|
6
|
+
/**
|
|
7
|
+
* Sets the repository an issue belongs to
|
|
8
|
+
* @throws if the event or pointer is not a valid repository
|
|
9
|
+
*/
|
|
10
|
+
export declare function setGitIssueRepository(repo: GitRepositoryPointer | NostrEvent): EventOperation;
|
|
11
|
+
/** Sets or removes the issue subject */
|
|
12
|
+
export declare function setGitIssueSubject(subject: string | null): EventOperation;
|
|
13
|
+
/** Adds a label `t` tag */
|
|
14
|
+
export declare function addGitIssueLabel(label: string): EventOperation;
|
|
15
|
+
/** Removes a label `t` tag */
|
|
16
|
+
export declare function removeGitIssueLabel(label: string): EventOperation;
|
|
17
|
+
/** Replaces all label `t` tags */
|
|
18
|
+
export declare function setGitIssueLabels(labels: string[]): EventOperation;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { modifyPublicTags } from "applesauce-core/operations/tags";
|
|
2
|
+
import { removeSingletonTag, setSingletonTag } from "applesauce-core/operations/tag/common";
|
|
3
|
+
import { setGitThreadRepository } from "./git-thread.js";
|
|
4
|
+
/** Returns the `a`, `p` and `r` tags that link an event to a repository */
|
|
5
|
+
export { createGitRepositoryTags } from "./git-thread.js";
|
|
6
|
+
/**
|
|
7
|
+
* Sets the repository an issue belongs to
|
|
8
|
+
* @throws if the event or pointer is not a valid repository
|
|
9
|
+
*/
|
|
10
|
+
export function setGitIssueRepository(repo) {
|
|
11
|
+
return setGitThreadRepository(repo);
|
|
12
|
+
}
|
|
13
|
+
/** Sets or removes the issue subject */
|
|
14
|
+
export function setGitIssueSubject(subject) {
|
|
15
|
+
return modifyPublicTags(subject === null ? removeSingletonTag("subject") : setSingletonTag(["subject", subject]));
|
|
16
|
+
}
|
|
17
|
+
/** Adds a label `t` tag */
|
|
18
|
+
export function addGitIssueLabel(label) {
|
|
19
|
+
return modifyPublicTags((tags) => [...tags.filter((t) => !(t[0] === "t" && t[1] === label)), ["t", label]]);
|
|
20
|
+
}
|
|
21
|
+
/** Removes a label `t` tag */
|
|
22
|
+
export function removeGitIssueLabel(label) {
|
|
23
|
+
return modifyPublicTags((tags) => tags.filter((t) => !(t[0] === "t" && t[1] === label)));
|
|
24
|
+
}
|
|
25
|
+
/** Replaces all label `t` tags */
|
|
26
|
+
export function setGitIssueLabels(labels) {
|
|
27
|
+
return modifyPublicTags((tags) => [
|
|
28
|
+
...tags.filter((t) => t[0] !== "t"),
|
|
29
|
+
...[...new Set(labels)].map((label) => ["t", label]),
|
|
30
|
+
]);
|
|
31
|
+
}
|
|
@@ -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;
|