applesauce-common 6.0.2 → 6.2.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 (103) hide show
  1. package/dist/casts/_circular-import.d.ts +2 -0
  2. package/dist/casts/_circular-import.js +2 -0
  3. package/dist/casts/git-grasp-list.d.ts +8 -0
  4. package/dist/casts/git-grasp-list.js +13 -0
  5. package/dist/casts/git-lists.d.ts +42 -0
  6. package/dist/casts/git-lists.js +94 -0
  7. package/dist/casts/git-repository.d.ts +29 -0
  8. package/dist/casts/git-repository.js +68 -0
  9. package/dist/casts/index.d.ts +3 -0
  10. package/dist/casts/index.js +3 -0
  11. package/dist/casts/reaction.d.ts +3 -1
  12. package/dist/casts/reaction.js +6 -2
  13. package/dist/casts/relay-lists.d.ts +6 -2
  14. package/dist/casts/relay-lists.js +11 -2
  15. package/dist/casts/trusted-assertions.d.ts +2 -2
  16. package/dist/casts/trusted-assertions.js +1 -1
  17. package/dist/casts/user.d.ts +4 -0
  18. package/dist/casts/user.js +23 -1
  19. package/dist/factories/calendar-event.d.ts +0 -5
  20. package/dist/factories/calendar-event.js +0 -9
  21. package/dist/factories/calendar-rsvp.d.ts +1 -0
  22. package/dist/factories/calendar-rsvp.js +1 -0
  23. package/dist/factories/code-snippet.d.ts +0 -2
  24. package/dist/factories/code-snippet.js +0 -5
  25. package/dist/factories/comment.d.ts +0 -2
  26. package/dist/factories/comment.js +5 -8
  27. package/dist/factories/favorite-git-repos.d.ts +17 -0
  28. package/dist/factories/favorite-git-repos.js +43 -0
  29. package/dist/factories/gift-wrap.js +2 -2
  30. package/dist/factories/git-authors.d.ts +17 -0
  31. package/dist/factories/git-authors.js +24 -0
  32. package/dist/factories/git-grasp-list.d.ts +14 -0
  33. package/dist/factories/git-grasp-list.js +25 -0
  34. package/dist/factories/git-repository.d.ts +51 -0
  35. package/dist/factories/git-repository.js +96 -0
  36. package/dist/factories/group.d.ts +5 -7
  37. package/dist/factories/group.js +8 -14
  38. package/dist/factories/highlight.d.ts +1 -10
  39. package/dist/factories/highlight.js +2 -12
  40. package/dist/factories/index.d.ts +6 -4
  41. package/dist/factories/index.js +6 -4
  42. package/dist/factories/legacy-message.d.ts +0 -1
  43. package/dist/factories/list.d.ts +0 -10
  44. package/dist/factories/list.js +0 -21
  45. package/dist/factories/nostr-web-token.d.ts +39 -0
  46. package/dist/factories/nostr-web-token.js +95 -0
  47. package/dist/factories/picture-post.d.ts +3 -4
  48. package/dist/factories/picture-post.js +3 -7
  49. package/dist/factories/poll-response.d.ts +0 -2
  50. package/dist/factories/poll-response.js +0 -5
  51. package/dist/factories/poll.d.ts +9 -6
  52. package/dist/factories/poll.js +12 -9
  53. package/dist/factories/relay-lists.d.ts +46 -0
  54. package/dist/factories/relay-lists.js +93 -0
  55. package/dist/factories/relay-set.d.ts +1 -1
  56. package/dist/factories/relay-set.js +1 -1
  57. package/dist/factories/share.d.ts +0 -7
  58. package/dist/factories/share.js +0 -11
  59. package/dist/factories/stream-chat-message.d.ts +0 -3
  60. package/dist/factories/stream-chat-message.js +0 -5
  61. package/dist/factories/torrent.d.ts +0 -2
  62. package/dist/factories/torrent.js +0 -5
  63. package/dist/factories/zap-goal.d.ts +0 -2
  64. package/dist/factories/zap-goal.js +0 -5
  65. package/dist/helpers/external-id.d.ts +1 -0
  66. package/dist/helpers/external-id.js +8 -27
  67. package/dist/helpers/git-grasp-list.d.ts +8 -0
  68. package/dist/helpers/git-grasp-list.js +15 -0
  69. package/dist/helpers/git-lists.d.ts +20 -0
  70. package/dist/helpers/git-lists.js +28 -0
  71. package/dist/helpers/git-repository.d.ts +39 -0
  72. package/dist/helpers/git-repository.js +104 -0
  73. package/dist/helpers/index.d.ts +4 -0
  74. package/dist/helpers/index.js +4 -0
  75. package/dist/helpers/nostr-web-token.d.ts +54 -0
  76. package/dist/helpers/nostr-web-token.js +124 -0
  77. package/dist/helpers/relay-list.d.ts +5 -0
  78. package/dist/helpers/relay-list.js +8 -0
  79. package/dist/observable/cast-stream.d.ts +1 -8
  80. package/dist/observable/cast-stream.js +2 -29
  81. package/dist/observable/chainable.d.ts +1 -1
  82. package/dist/observable/chainable.js +1 -1
  83. package/dist/operations/git-grasp-list.d.ts +7 -0
  84. package/dist/operations/git-grasp-list.js +18 -0
  85. package/dist/operations/git-repository.d.ts +45 -0
  86. package/dist/operations/git-repository.js +160 -0
  87. package/dist/operations/hashtags.d.ts +2 -0
  88. package/dist/operations/hashtags.js +7 -0
  89. package/dist/operations/index.d.ts +3 -0
  90. package/dist/operations/index.js +3 -0
  91. package/dist/operations/nostr-web-token.d.ts +27 -0
  92. package/dist/operations/nostr-web-token.js +58 -0
  93. package/dist/operations/poll.d.ts +3 -2
  94. package/dist/operations/poll.js +4 -3
  95. package/package.json +4 -4
  96. package/dist/factories/blocked-relays.d.ts +0 -10
  97. package/dist/factories/blocked-relays.js +0 -16
  98. package/dist/factories/dm-relays.d.ts +0 -10
  99. package/dist/factories/dm-relays.js +0 -16
  100. package/dist/factories/favorite-relays.d.ts +0 -16
  101. package/dist/factories/favorite-relays.js +0 -31
  102. package/dist/factories/search-relays.d.ts +0 -10
  103. package/dist/factories/search-relays.js +0 -16
@@ -0,0 +1,43 @@
1
+ import { blankEventTemplate, toEventTemplate } from "applesauce-core/factories";
2
+ import { getAddressPointerForEvent, getReplaceableAddressFromPointer, isAddressPointer, parseReplaceableAddress, } from "applesauce-core/helpers/pointers";
3
+ import { FAVORITE_GIT_REPOS_KIND, REPOSITORY_ANNOUNCEMENT_KIND, } from "../helpers/git-lists.js";
4
+ import { NIP51ItemListFactory } from "./list.js";
5
+ function getRepositoryAddress(repository) {
6
+ if (typeof repository === "string") {
7
+ const pointer = parseReplaceableAddress(repository, true);
8
+ if (pointer?.kind !== REPOSITORY_ANNOUNCEMENT_KIND)
9
+ throw new Error("Repository address must be kind 30617");
10
+ return repository;
11
+ }
12
+ if (isAddressPointer(repository)) {
13
+ if (repository.kind !== REPOSITORY_ANNOUNCEMENT_KIND)
14
+ throw new Error("Repository pointer must be kind 30617");
15
+ return repository;
16
+ }
17
+ const pointer = getAddressPointerForEvent(repository);
18
+ if (pointer?.kind !== REPOSITORY_ANNOUNCEMENT_KIND)
19
+ throw new Error("Repository event must be kind 30617");
20
+ return pointer;
21
+ }
22
+ /** A factory class for building kind 10018 git repositories list events */
23
+ export class FavoriteGitReposFactory extends NIP51ItemListFactory {
24
+ /** Creates a new git repositories list factory */
25
+ static create() {
26
+ return new FavoriteGitReposFactory((res) => res(blankEventTemplate(FAVORITE_GIT_REPOS_KIND)));
27
+ }
28
+ /** Creates a new git repositories list factory from an existing list event */
29
+ static modify(event) {
30
+ if (event.kind !== FAVORITE_GIT_REPOS_KIND)
31
+ throw new Error("Event is not a git repositories list event");
32
+ return new FavoriteGitReposFactory((res) => res(toEventTemplate(event)));
33
+ }
34
+ /** Adds a NIP-34 repository announcement pointer to the list */
35
+ addRepository(repository, hidden = false) {
36
+ return this.addAddressItem(getRepositoryAddress(repository), hidden);
37
+ }
38
+ /** Removes a NIP-34 repository announcement pointer from the list */
39
+ removeRepository(repository, hidden = false) {
40
+ const address = getRepositoryAddress(repository);
41
+ return this.removeAddressItem(typeof address === "string" ? address : getReplaceableAddressFromPointer(address), hidden);
42
+ }
43
+ }
@@ -10,12 +10,12 @@ export class GiftWrapFactory extends EventFactory {
10
10
  */
11
11
  static async create(signer, recipient, rumor, opts) {
12
12
  const _innerEvent = rumor instanceof EventFactory ? await rumor : rumor;
13
- return giftWrap(recipient, signer, opts)(_innerEvent);
13
+ return giftWrap(recipient, signer, { alt: "A gift-wrapped event", ...opts })(_innerEvent);
14
14
  }
15
15
  /** Sets the inner rumor event of the gift wrap */
16
16
  wrapEvent(pubkey, event, opts) {
17
17
  let result;
18
- result = this.chain(async (_draft) => giftWrap(pubkey, result.signer, opts)(event));
18
+ result = this.chain(async (_draft) => giftWrap(pubkey, result.signer, { alt: "A gift-wrapped event", ...opts })(event));
19
19
  return result;
20
20
  }
21
21
  }
@@ -0,0 +1,17 @@
1
+ import { KnownEvent, KnownEventTemplate, NostrEvent } from "applesauce-core/helpers";
2
+ import { ProfilePointer } from "applesauce-core/helpers/pointers";
3
+ import { GIT_AUTHORS_KIND, GitAuthorsListEvent } from "../helpers/git-lists.js";
4
+ import { NIP51UserListFactory } from "./list.js";
5
+ export type GitAuthorsTemplate = KnownEventTemplate<typeof GIT_AUTHORS_KIND>;
6
+ /** A factory class for building kind 10017 git authors list events */
7
+ export declare class GitAuthorsFactory extends NIP51UserListFactory<typeof GIT_AUTHORS_KIND, GitAuthorsTemplate> {
8
+ /** Creates a new git authors list factory */
9
+ static create(): GitAuthorsFactory;
10
+ /** Creates a new git authors list factory from an existing list event */
11
+ static modify(event: NostrEvent | KnownEvent<typeof GIT_AUTHORS_KIND>): GitAuthorsFactory;
12
+ /** Adds one or more git authors to the list */
13
+ addAuthor(author: string | ProfilePointer | (string | ProfilePointer)[], hidden?: boolean): this;
14
+ /** Removes one or more git authors from the list */
15
+ removeAuthor(author: string | ProfilePointer | (string | ProfilePointer)[], hidden?: boolean): this;
16
+ }
17
+ export type { GitAuthorsListEvent };
@@ -0,0 +1,24 @@
1
+ import { blankEventTemplate, toEventTemplate } from "applesauce-core/factories";
2
+ import { GIT_AUTHORS_KIND } from "../helpers/git-lists.js";
3
+ import { NIP51UserListFactory } from "./list.js";
4
+ /** A factory class for building kind 10017 git authors list events */
5
+ export class GitAuthorsFactory extends NIP51UserListFactory {
6
+ /** Creates a new git authors list factory */
7
+ static create() {
8
+ return new GitAuthorsFactory((res) => res(blankEventTemplate(GIT_AUTHORS_KIND)));
9
+ }
10
+ /** Creates a new git authors list factory from an existing list event */
11
+ static modify(event) {
12
+ if (event.kind !== GIT_AUTHORS_KIND)
13
+ throw new Error("Event is not a git authors list event");
14
+ return new GitAuthorsFactory((res) => res(toEventTemplate(event)));
15
+ }
16
+ /** Adds one or more git authors to the list */
17
+ addAuthor(author, hidden = false) {
18
+ return this.addUser(author, hidden);
19
+ }
20
+ /** Removes one or more git authors from the list */
21
+ removeAuthor(author, hidden = false) {
22
+ return this.removeUser(author, hidden);
23
+ }
24
+ }
@@ -0,0 +1,14 @@
1
+ import { EventFactory } from "applesauce-core/factories";
2
+ import { KnownEventTemplate, NostrEvent } from "applesauce-core/helpers";
3
+ import { GIT_GRASP_LIST_KIND } from "../helpers/git-grasp-list.js";
4
+ export type GitGraspListTemplate = KnownEventTemplate<typeof GIT_GRASP_LIST_KIND>;
5
+ /** Factory for NIP-34 user grasp server lists. */
6
+ export declare class GitGraspListFactory extends EventFactory<typeof GIT_GRASP_LIST_KIND, GitGraspListTemplate> {
7
+ /** Creates a grasp list factory. */
8
+ static create(servers?: string[]): GitGraspListFactory;
9
+ /** Creates a factory configured to modify an existing grasp list. */
10
+ static modify(event: NostrEvent): GitGraspListFactory;
11
+ setServers(servers: string[]): this;
12
+ addServer(url: string): this;
13
+ removeServer(url: string): this;
14
+ }
@@ -0,0 +1,25 @@
1
+ import { blankEventTemplate, EventFactory, toEventTemplate } from "applesauce-core/factories";
2
+ import { GIT_GRASP_LIST_KIND } from "../helpers/git-grasp-list.js";
3
+ import { addGitGraspServer, removeGitGraspServer, setGitGraspServers } from "../operations/git-grasp-list.js";
4
+ /** Factory for NIP-34 user grasp server lists. */
5
+ export class GitGraspListFactory extends EventFactory {
6
+ /** Creates a grasp list factory. */
7
+ static create(servers = []) {
8
+ return new GitGraspListFactory((res) => res(blankEventTemplate(GIT_GRASP_LIST_KIND))).setServers(servers);
9
+ }
10
+ /** Creates a factory configured to modify an existing grasp list. */
11
+ static modify(event) {
12
+ if (event.kind !== GIT_GRASP_LIST_KIND)
13
+ throw new Error("Expected a git grasp list event");
14
+ return new GitGraspListFactory((res) => res(toEventTemplate(event)));
15
+ }
16
+ setServers(servers) {
17
+ return this.chain(setGitGraspServers(servers));
18
+ }
19
+ addServer(url) {
20
+ return this.chain(addGitGraspServer(url));
21
+ }
22
+ removeServer(url) {
23
+ return this.chain(removeGitGraspServer(url));
24
+ }
25
+ }
@@ -0,0 +1,51 @@
1
+ import { EventFactory } from "applesauce-core/factories";
2
+ import { KnownEventTemplate, NostrEvent } from "applesauce-core/helpers";
3
+ import { GIT_REPOSITORY_KIND, GitRepositoryPointer } from "../helpers/git-repository.js";
4
+ export type GitRepositoryTemplate = KnownEventTemplate<typeof GIT_REPOSITORY_KIND>;
5
+ /** Factory for NIP-34 repository announcement events. */
6
+ export declare class GitRepositoryFactory extends EventFactory<typeof GIT_REPOSITORY_KIND, GitRepositoryTemplate> {
7
+ /** Creates a repository announcement factory. */
8
+ static create(identifier: string): GitRepositoryFactory;
9
+ /** Creates a factory configured to modify an existing repository announcement. */
10
+ static modify(event: NostrEvent): GitRepositoryFactory;
11
+ /** Sets the replaceable repository `d` identifier tag. */
12
+ identifier(value: string): this;
13
+ /** Sets or clears the display name (`name` tag). */
14
+ name(value: string | null): this;
15
+ /** Sets or clears the repository description. */
16
+ description(value: string | null): this;
17
+ /** Replaces all web browsing URLs. */
18
+ setWebUrls(urls: string[]): this;
19
+ /** Appends a web browsing URL. */
20
+ addWebUrl(url: string): this;
21
+ /** Removes a web browsing URL. */
22
+ removeWebUrl(url: string): this;
23
+ /** Replaces all git clone URLs. */
24
+ setCloneUrls(urls: string[]): this;
25
+ /** Appends a git clone URL. */
26
+ addClone(url: string): this;
27
+ /** Removes a git clone URL. */
28
+ removeClone(url: string): this;
29
+ /** Replaces all relay URLs (normalized). */
30
+ setRelays(relays: string[]): this;
31
+ /** Appends a relay URL. */
32
+ addRelay(url: string): this;
33
+ /** Removes a relay URL. */
34
+ removeRelay(url: string): this;
35
+ /** Sets or clears the earliest unique commit (`r` … `euc` tag). */
36
+ earliestUniqueCommit(commit: string | null): this;
37
+ /** Replaces all maintainer pubkeys. */
38
+ setMaintainers(pubkeys: string[]): this;
39
+ /** Appends a maintainer pubkey. */
40
+ maintainer(pubkey: string): this;
41
+ /** Removes a maintainer pubkey. */
42
+ removeMaintainer(pubkey: string): this;
43
+ /** Replaces subject hashtags. */
44
+ setHashtags(hashtags: string[]): this;
45
+ /** Appends a subject hashtag (`t` tag). */
46
+ hashtag(hashtag: string): this;
47
+ /** Removes a subject hashtag. */
48
+ removeHashtag(hashtag: string): this;
49
+ /** Sets or clears the upstream repository pointer (the repo this one was forked from). */
50
+ upstream(pointer: GitRepositoryPointer | null): this;
51
+ }
@@ -0,0 +1,96 @@
1
+ import { blankEventTemplate, EventFactory, toEventTemplate } from "applesauce-core/factories";
2
+ import { GIT_REPOSITORY_KIND, isValidGitRepository } from "../helpers/git-repository.js";
3
+ import { addGitRepositoryCloneUrl, addGitRepositoryHashtag, addGitRepositoryMaintainer, addGitRepositoryRelay, addGitRepositoryWebUrl, removeGitRepositoryCloneUrl, removeGitRepositoryHashtag, removeGitRepositoryMaintainer, removeGitRepositoryRelay, removeGitRepositoryWebUrl, setGitRepositoryCloneUrls, setGitRepositoryDescription, setGitRepositoryEarliestUniqueCommit, setGitRepositoryHashtags, setGitRepositoryIdentifier, setGitRepositoryMaintainers, setGitRepositoryName, setGitRepositoryRelays, setGitRepositoryUpstream, setGitRepositoryWebUrls, } from "../operations/git-repository.js";
4
+ /** Factory for NIP-34 repository announcement events. */
5
+ export class GitRepositoryFactory extends EventFactory {
6
+ /** Creates a repository announcement factory. */
7
+ static create(identifier) {
8
+ return new GitRepositoryFactory((res) => res(blankEventTemplate(GIT_REPOSITORY_KIND))).identifier(identifier);
9
+ }
10
+ /** Creates a factory configured to modify an existing repository announcement. */
11
+ static modify(event) {
12
+ if (!isValidGitRepository(event))
13
+ throw new Error("Expected a git repository announcement event");
14
+ return new GitRepositoryFactory((res) => res(toEventTemplate(event)));
15
+ }
16
+ /** Sets the replaceable repository `d` identifier tag. */
17
+ identifier(value) {
18
+ return this.chain(setGitRepositoryIdentifier(value));
19
+ }
20
+ /** Sets or clears the display name (`name` tag). */
21
+ name(value) {
22
+ return this.chain(setGitRepositoryName(value));
23
+ }
24
+ /** Sets or clears the repository description. */
25
+ description(value) {
26
+ return this.chain(setGitRepositoryDescription(value));
27
+ }
28
+ /** Replaces all web browsing URLs. */
29
+ setWebUrls(urls) {
30
+ return this.chain(setGitRepositoryWebUrls(urls));
31
+ }
32
+ /** Appends a web browsing URL. */
33
+ addWebUrl(url) {
34
+ return this.chain(addGitRepositoryWebUrl(url));
35
+ }
36
+ /** Removes a web browsing URL. */
37
+ removeWebUrl(url) {
38
+ return this.chain(removeGitRepositoryWebUrl(url));
39
+ }
40
+ /** Replaces all git clone URLs. */
41
+ setCloneUrls(urls) {
42
+ return this.chain(setGitRepositoryCloneUrls(urls));
43
+ }
44
+ /** Appends a git clone URL. */
45
+ addClone(url) {
46
+ return this.chain(addGitRepositoryCloneUrl(url));
47
+ }
48
+ /** Removes a git clone URL. */
49
+ removeClone(url) {
50
+ return this.chain(removeGitRepositoryCloneUrl(url));
51
+ }
52
+ /** Replaces all relay URLs (normalized). */
53
+ setRelays(relays) {
54
+ return this.chain(setGitRepositoryRelays(relays));
55
+ }
56
+ /** Appends a relay URL. */
57
+ addRelay(url) {
58
+ return this.chain(addGitRepositoryRelay(url));
59
+ }
60
+ /** Removes a relay URL. */
61
+ removeRelay(url) {
62
+ return this.chain(removeGitRepositoryRelay(url));
63
+ }
64
+ /** Sets or clears the earliest unique commit (`r` … `euc` tag). */
65
+ earliestUniqueCommit(commit) {
66
+ return this.chain(setGitRepositoryEarliestUniqueCommit(commit));
67
+ }
68
+ /** Replaces all maintainer pubkeys. */
69
+ setMaintainers(pubkeys) {
70
+ return this.chain(setGitRepositoryMaintainers(pubkeys));
71
+ }
72
+ /** Appends a maintainer pubkey. */
73
+ maintainer(pubkey) {
74
+ return this.chain(addGitRepositoryMaintainer(pubkey));
75
+ }
76
+ /** Removes a maintainer pubkey. */
77
+ removeMaintainer(pubkey) {
78
+ return this.chain(removeGitRepositoryMaintainer(pubkey));
79
+ }
80
+ /** Replaces subject hashtags. */
81
+ setHashtags(hashtags) {
82
+ return this.chain(setGitRepositoryHashtags(hashtags));
83
+ }
84
+ /** Appends a subject hashtag (`t` tag). */
85
+ hashtag(hashtag) {
86
+ return this.chain(addGitRepositoryHashtag(hashtag));
87
+ }
88
+ /** Removes a subject hashtag. */
89
+ removeHashtag(hashtag) {
90
+ return this.chain(removeGitRepositoryHashtag(hashtag));
91
+ }
92
+ /** Sets or clears the upstream repository pointer (the repo this one was forked from). */
93
+ upstream(pointer) {
94
+ return this.chain(setGitRepositoryUpstream(pointer));
95
+ }
96
+ }
@@ -1,25 +1,25 @@
1
1
  import { EventFactory } from "applesauce-core/factories";
2
2
  import { KnownEventTemplate, NostrEvent } from "applesauce-core/helpers";
3
3
  import { TextContentOptions } from "applesauce-core/operations/content";
4
- import { MetaTagOptions } from "applesauce-core/operations/event";
5
4
  import { GROUP_MESSAGE_KIND, GROUP_THREAD_KIND, GroupPointer } from "../helpers/groups.js";
6
5
  export type GroupMessageTemplate = KnownEventTemplate<typeof GROUP_MESSAGE_KIND>;
7
6
  export type GroupThreadTemplate = KnownEventTemplate<typeof GROUP_THREAD_KIND>;
7
+ export type GroupMessageFactoryOptions = TextContentOptions;
8
8
  export declare class GroupMessageFactory extends EventFactory<typeof GROUP_MESSAGE_KIND, GroupMessageTemplate> {
9
- static create(group: GroupPointer, content: string): GroupMessageFactory;
9
+ static create(group: GroupPointer, content: string, options?: GroupMessageFactoryOptions): GroupMessageFactory;
10
10
  group(pointer: GroupPointer): this;
11
11
  text(content: string, options?: TextContentOptions): this;
12
12
  previous(events: NostrEvent[]): this;
13
13
  /** Sets the "e" reply tag pointing to a parent group message */
14
14
  replyTo(parent: NostrEvent): this;
15
- meta(options: MetaTagOptions): this;
16
15
  /** Creates a reply to a group message */
17
- static reply(group: GroupPointer, parent: NostrEvent, content: string): GroupMessageFactory;
16
+ static reply(group: GroupPointer, parent: NostrEvent, content: string, options?: GroupMessageFactoryOptions): GroupMessageFactory;
18
17
  }
18
+ export type GroupThreadFactoryOptions = TextContentOptions;
19
19
  /** A factory class for building NIP-29 group thread events (kind 11) */
20
20
  export declare class GroupThreadFactory extends EventFactory<typeof GROUP_THREAD_KIND, GroupThreadTemplate> {
21
21
  /** Creates a new group thread event */
22
- static create(group: GroupPointer, title: string, content: string): GroupThreadFactory;
22
+ static create(group: GroupPointer, title: string, content: string, options?: GroupThreadFactoryOptions): GroupThreadFactory;
23
23
  /** Sets the NIP-29 group pointer "h" tag */
24
24
  group(pointer: GroupPointer): this;
25
25
  /** Sets the thread title */
@@ -30,6 +30,4 @@ export declare class GroupThreadFactory extends EventFactory<typeof GROUP_THREAD
30
30
  addHashtag(hashtag: string): this;
31
31
  /** Adds multiple hashtags as "t" tags */
32
32
  hashtags(hashtags: string[]): this;
33
- /** Sets meta tags */
34
- meta(options: MetaTagOptions): this;
35
33
  }
@@ -1,13 +1,14 @@
1
1
  import { EventFactory, blankEventTemplate } from "applesauce-core/factories";
2
2
  import { setShortTextContent } from "applesauce-core/operations/content";
3
- import { setMetaTags } from "applesauce-core/operations/event";
4
3
  import { includeNameValueTag, includeSingletonTag } from "applesauce-core/operations/tags";
5
4
  import { GROUP_MESSAGE_KIND, GROUP_THREAD_KIND } from "../helpers/groups.js";
6
5
  import { addPreviousRefs, setGroupPointer } from "../operations/group.js";
7
6
  import { addHashtag, includeHashtags } from "../operations/hashtags.js";
8
7
  export class GroupMessageFactory extends EventFactory {
9
- static create(group, content) {
10
- return new GroupMessageFactory((res) => res(blankEventTemplate(GROUP_MESSAGE_KIND))).group(group).text(content);
8
+ static create(group, content, options) {
9
+ return new GroupMessageFactory((res) => res(blankEventTemplate(GROUP_MESSAGE_KIND)))
10
+ .group(group)
11
+ .text(content, options);
11
12
  }
12
13
  group(pointer) {
13
14
  return this.chain((draft) => setGroupPointer(pointer)(draft));
@@ -22,25 +23,22 @@ export class GroupMessageFactory extends EventFactory {
22
23
  replyTo(parent) {
23
24
  return this.chain(includeNameValueTag(["e", parent.id]));
24
25
  }
25
- meta(options) {
26
- return this.chain((draft) => setMetaTags(options)(draft));
27
- }
28
26
  /** Creates a reply to a group message */
29
- static reply(group, parent, content) {
27
+ static reply(group, parent, content, options) {
30
28
  return new GroupMessageFactory((res) => res(blankEventTemplate(GROUP_MESSAGE_KIND)))
31
29
  .group(group)
32
30
  .replyTo(parent)
33
- .text(content);
31
+ .text(content, options);
34
32
  }
35
33
  }
36
34
  /** A factory class for building NIP-29 group thread events (kind 11) */
37
35
  export class GroupThreadFactory extends EventFactory {
38
36
  /** Creates a new group thread event */
39
- static create(group, title, content) {
37
+ static create(group, title, content, options) {
40
38
  return new GroupThreadFactory((res) => res(blankEventTemplate(GROUP_THREAD_KIND)))
41
39
  .group(group)
42
40
  .title(title)
43
- .text(content);
41
+ .text(content, options);
44
42
  }
45
43
  /** Sets the NIP-29 group pointer "h" tag */
46
44
  group(pointer) {
@@ -62,8 +60,4 @@ export class GroupThreadFactory extends EventFactory {
62
60
  hashtags(hashtags) {
63
61
  return this.chain(includeHashtags(hashtags));
64
62
  }
65
- /** Sets meta tags */
66
- meta(options) {
67
- return this.chain(setMetaTags(options));
68
- }
69
63
  }
@@ -1,19 +1,12 @@
1
1
  import { EventFactory } from "applesauce-core/factories";
2
2
  import { kinds, KnownEventTemplate, NostrEvent } from "applesauce-core/helpers";
3
3
  import { AddressPointer } from "applesauce-core/helpers/pointers";
4
- import { MetaTagOptions } from "applesauce-core/operations/event";
5
4
  import { HighlightAttribution } from "../helpers/index.js";
6
5
  import { ZapOptions } from "../operations/zap-split.js";
7
6
  export type HighlightTemplate = KnownEventTemplate<kinds.Highlights>;
8
- export type HighlightBlueprintOptions = MetaTagOptions & ZapOptions & {
9
- context?: string;
10
- comment?: string;
11
- attributions?: HighlightAttribution[];
12
- alt?: string;
13
- };
14
7
  export declare class HighlightFactory extends EventFactory<kinds.Highlights, HighlightTemplate> {
15
8
  /** Creates a new highlight factory from content and source */
16
- static create(content: string, source: NostrEvent | AddressPointer | string, options?: HighlightBlueprintOptions): HighlightFactory;
9
+ static create(content: string, source: NostrEvent | AddressPointer | string): HighlightFactory;
17
10
  /** Sets the content of the highlight */
18
11
  highlight(content: string): this;
19
12
  /** Sets the source event that was highlighted using an 'e' tag */
@@ -28,6 +21,4 @@ export declare class HighlightFactory extends EventFactory<kinds.Highlights, Hig
28
21
  comment(comment: string): this;
29
22
  /** Sets the zap split for the highlight */
30
23
  zapSplit(options: ZapOptions): this;
31
- /** Sets the meta tags for the highlight */
32
- meta(options: MetaTagOptions): this;
33
24
  }
@@ -1,18 +1,12 @@
1
1
  // highlight.ts
2
2
  import { blankEventTemplate, EventFactory } from "applesauce-core/factories";
3
3
  import { kinds } from "applesauce-core/helpers";
4
- import { setMetaTags } from "applesauce-core/operations/event";
5
4
  import { addAttribution, setAttributions, setComment, setContext, setHighlightContent, setSource, } from "../operations/highlight.js";
6
5
  import { setZapSplit } from "../operations/zap-split.js";
7
6
  export class HighlightFactory extends EventFactory {
8
7
  /** Creates a new highlight factory from content and source */
9
- static create(content, source, options) {
10
- let factory = new HighlightFactory((res) => res(blankEventTemplate(kinds.Highlights)))
11
- .highlight(content)
12
- .source(source);
13
- if (options)
14
- factory = factory.meta(options);
15
- return factory;
8
+ static create(content, source) {
9
+ return new HighlightFactory((res) => res(blankEventTemplate(kinds.Highlights))).highlight(content).source(source);
16
10
  }
17
11
  /** Sets the content of the highlight */
18
12
  highlight(content) {
@@ -42,8 +36,4 @@ export class HighlightFactory extends EventFactory {
42
36
  zapSplit(options) {
43
37
  return this.chain(setZapSplit(options, undefined));
44
38
  }
45
- /** Sets the meta tags for the highlight */
46
- meta(options) {
47
- return this.chain(setMetaTags(options));
48
- }
49
39
  }
@@ -22,11 +22,12 @@ export * from "./mute-list.js";
22
22
  export * from "./pin-list.js";
23
23
  export * from "./bookmark-list.js";
24
24
  export * from "./bookmark-set.js";
25
- export * from "./blocked-relays.js";
26
- export * from "./search-relays.js";
27
- export * from "./favorite-relays.js";
28
- export * from "./dm-relays.js";
25
+ export * from "./relay-lists.js";
29
26
  export * from "./blossom-server-list.js";
27
+ export * from "./git-grasp-list.js";
28
+ export * from "./git-authors.js";
29
+ export * from "./favorite-git-repos.js";
30
+ export * from "./git-repository.js";
30
31
  export * from "./follow-set.js";
31
32
  export * from "./relay-set.js";
32
33
  export * from "./list.js";
@@ -39,3 +40,4 @@ export * from "./picture-post.js";
39
40
  export * from "./badge.js";
40
41
  export * from "./badge-award.js";
41
42
  export * from "./profile-badges.js";
43
+ export * from "./nostr-web-token.js";
@@ -22,11 +22,12 @@ export * from "./mute-list.js";
22
22
  export * from "./pin-list.js";
23
23
  export * from "./bookmark-list.js";
24
24
  export * from "./bookmark-set.js";
25
- export * from "./blocked-relays.js";
26
- export * from "./search-relays.js";
27
- export * from "./favorite-relays.js";
28
- export * from "./dm-relays.js";
25
+ export * from "./relay-lists.js";
29
26
  export * from "./blossom-server-list.js";
27
+ export * from "./git-grasp-list.js";
28
+ export * from "./git-authors.js";
29
+ export * from "./favorite-git-repos.js";
30
+ export * from "./git-repository.js";
30
31
  export * from "./follow-set.js";
31
32
  export * from "./relay-set.js";
32
33
  export * from "./list.js";
@@ -39,3 +40,4 @@ export * from "./picture-post.js";
39
40
  export * from "./badge.js";
40
41
  export * from "./badge-award.js";
41
42
  export * from "./profile-badges.js";
43
+ export * from "./nostr-web-token.js";
@@ -1,7 +1,6 @@
1
1
  import { EventFactory } from "applesauce-core/factories";
2
2
  import { kinds, KnownEventTemplate, NostrEvent } from "applesauce-core/helpers";
3
3
  export type LegacyMessageTemplate = KnownEventTemplate<kinds.EncryptedDirectMessage>;
4
- export type LegacyMessageBlueprintOptions = {};
5
4
  export declare class LegacyMessageFactory extends EventFactory<kinds.EncryptedDirectMessage, LegacyMessageTemplate> {
6
5
  static create(recipient: string, message: string): LegacyMessageFactory;
7
6
  static reply(parent: NostrEvent, recipient: string, message: string): LegacyMessageFactory;
@@ -12,16 +12,6 @@ export declare class ListFactory<K extends number = number, T extends KnownEvent
12
12
  /** Sets or removes the image of the list */
13
13
  image(image: string | null): this;
14
14
  }
15
- /**
16
- * A base factory class for NIP-51 lists that contain relay URLs.
17
- * Provides `addRelay` and `removeRelay` methods in addition to `title`, `description`, and `image`.
18
- */
19
- export declare class NIP51RelayListFactory<K extends number = number, T extends KnownEventTemplate<K> = KnownEventTemplate<K>> extends ListFactory<K, T> {
20
- /** Adds a relay URL to the list's public tags */
21
- addRelay(relay: string | string[], hidden?: boolean): this;
22
- /** Removes a relay URL from the list */
23
- removeRelay(relay: string | string[], hidden?: boolean): this;
24
- }
25
15
  /**
26
16
  * A base factory class for NIP-51 lists that contain user pubkeys (profile pointers).
27
17
  * Provides `addUser` and `removeUser` methods in addition to `title`, `description`, and `image`.
@@ -1,6 +1,5 @@
1
1
  import { EventFactory, toEventTemplate } from "applesauce-core/factories";
2
2
  import { addAddressPointerTag, addEventPointerTag, addNameValueTag, addProfilePointerTag, removeAddressPointerTag, removeEventPointerTag, removeNameValueTag, removeProfilePointerTag, removeSingletonTag, setSingletonTag, } from "applesauce-core/operations/tag/common";
3
- import { addRelayTag, removeRelayTag } from "applesauce-core/operations/tag/relay";
4
3
  /** A factory class for modifying any NIP-51 list event (kind-agnostic) */
5
4
  export class ListFactory extends EventFactory {
6
5
  /** Creates a new list factory from an existing list event */
@@ -26,26 +25,6 @@ export class ListFactory extends EventFactory {
26
25
  : this.modifyPublicTags(setSingletonTag(["image", image], true));
27
26
  }
28
27
  }
29
- /**
30
- * A base factory class for NIP-51 lists that contain relay URLs.
31
- * Provides `addRelay` and `removeRelay` methods in addition to `title`, `description`, and `image`.
32
- */
33
- export class NIP51RelayListFactory extends ListFactory {
34
- /** Adds a relay URL to the list's public tags */
35
- addRelay(relay, hidden = false) {
36
- const relays = Array.isArray(relay) ? relay : [relay];
37
- return hidden
38
- ? this.modifyHiddenTags(...relays.map((r) => addRelayTag(r)))
39
- : this.modifyPublicTags(...relays.map((r) => addRelayTag(r)));
40
- }
41
- /** Removes a relay URL from the list */
42
- removeRelay(relay, hidden = false) {
43
- const relays = Array.isArray(relay) ? relay : [relay];
44
- return hidden
45
- ? this.modifyHiddenTags(...relays.map((r) => removeRelayTag(r)))
46
- : this.modifyPublicTags(...relays.map((r) => removeRelayTag(r)));
47
- }
48
- }
49
28
  /**
50
29
  * A base factory class for NIP-51 lists that contain user pubkeys (profile pointers).
51
30
  * Provides `addUser` and `removeUser` methods in addition to `title`, `description`, and `image`.
@@ -0,0 +1,39 @@
1
+ import { EventFactory } from "applesauce-core/factories";
2
+ import { KnownEventTemplate, NostrEvent } from "applesauce-core/helpers";
3
+ import { NOSTR_WEB_TOKEN_KIND, NostrWebTokenClaims } from "../helpers/nostr-web-token.js";
4
+ export type NostrWebTokenTemplate = KnownEventTemplate<typeof NOSTR_WEB_TOKEN_KIND>;
5
+ /** Factory for Nostr Web Token events (kind 27519). @see https://github.com/Open-Ranking/nostr-web-tokens */
6
+ export declare class NostrWebTokenFactory extends EventFactory<typeof NOSTR_WEB_TOKEN_KIND, NostrWebTokenTemplate> {
7
+ /** Creates a Nostr Web Token factory. */
8
+ static create(claims?: Partial<NostrWebTokenClaims>): NostrWebTokenFactory;
9
+ /** Creates a factory configured to modify an existing Nostr Web Token. */
10
+ static modify(event: NostrEvent): NostrWebTokenFactory;
11
+ /** Sets or removes the issuer claim. */
12
+ issuer(value: string | null): this;
13
+ /** Sets or removes the subject claim. */
14
+ subject(value: string | null): this;
15
+ /** Replaces all audience claims. */
16
+ audiences(values: string[]): this;
17
+ /** Adds an audience claim. */
18
+ addAudience(value: string, replace?: boolean): this;
19
+ /** Removes a matching audience claim. */
20
+ removeAudience(value: string): this;
21
+ /** Clears all audience claims. */
22
+ clearAudiences(): this;
23
+ /** Sets or removes the issued-at claim. */
24
+ issuedAt(value: number | null): this;
25
+ /** Sets or removes the expiration claim. */
26
+ expiration(value: number | null): this;
27
+ /** Sets or removes the not-before claim. */
28
+ notBefore(value: number | null): this;
29
+ /** Sets or removes a singleton claim. */
30
+ claim(name: string, value: string | number | null): this;
31
+ /** Adds an application-defined claim. */
32
+ addClaim(name: string, value: string | number, replace?: boolean): this;
33
+ /** Removes matching values for a claim, or all tags with the claim name when value is omitted. */
34
+ removeClaim(name: string, value?: string | number): this;
35
+ /** Clears all tags with the claim name. */
36
+ clearClaim(name: string): this;
37
+ /** Sets the human-readable signing message. */
38
+ message(content: string): this;
39
+ }