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,160 @@
1
+ import { getReplaceableAddressFromPointer } from "applesauce-core/helpers/pointers";
2
+ import { isSafeRelayURL } from "applesauce-core/helpers/relays";
3
+ import { normalizeURL } from "applesauce-core/helpers/url";
4
+ import { includeSingletonTag, modifyPublicTags } from "applesauce-core/operations/tags";
5
+ import { removeSingletonTag, setSingletonTag } from "applesauce-core/operations/tag/common";
6
+ import { GIT_REPOSITORY_KIND } from "../helpers/git-repository.js";
7
+ import { addHashtag, removeHashtag, setHashtags } from "./hashtags.js";
8
+ /** NIP-34 uses one tag per name with all values in that tag: `["web", url1, url2, ...]`. */
9
+ function collectFlatTagValues(tags, name) {
10
+ const values = [];
11
+ for (const t of tags) {
12
+ if (t[0] === name && t.length > 1)
13
+ values.push(...t.slice(1));
14
+ }
15
+ return values;
16
+ }
17
+ function stripTagsNamed(tags, name) {
18
+ return tags.filter((t) => t[0] !== name);
19
+ }
20
+ function withFlatListTag(tags, name, values) {
21
+ const base = stripTagsNamed(tags, name);
22
+ if (values.length === 0)
23
+ return base;
24
+ return [...base, [name, ...values]];
25
+ }
26
+ /** Sets the repository identifier `d` tag. */
27
+ export function setGitRepositoryIdentifier(identifier) {
28
+ return includeSingletonTag(["d", identifier], true);
29
+ }
30
+ /** Sets or removes the repository name. */
31
+ export function setGitRepositoryName(name) {
32
+ return modifyPublicTags(name === null ? removeSingletonTag("name") : setSingletonTag(["name", name], true));
33
+ }
34
+ /** Sets or removes the repository description. */
35
+ export function setGitRepositoryDescription(description) {
36
+ return modifyPublicTags(description === null ? removeSingletonTag("description") : setSingletonTag(["description", description], true));
37
+ }
38
+ /** Sets the repository web URLs (single `web` tag, NIP-34 flat list). */
39
+ export function setGitRepositoryWebUrls(urls) {
40
+ return modifyPublicTags((tags) => withFlatListTag(tags, "web", urls));
41
+ }
42
+ /** Sets the git clone URLs (single `clone` tag). */
43
+ export function setGitRepositoryCloneUrls(urls) {
44
+ return modifyPublicTags((tags) => withFlatListTag(tags, "clone", urls));
45
+ }
46
+ /** Sets the repository relay URLs (single `relays` tag, normalized). */
47
+ export function setGitRepositoryRelays(relays) {
48
+ return modifyPublicTags((tags) => {
49
+ const normalized = relays.map((relay) => new URL(relay).toString());
50
+ return withFlatListTag(tags, "relays", normalized);
51
+ });
52
+ }
53
+ /** Adds a web browsing URL. */
54
+ export function addGitRepositoryWebUrl(url) {
55
+ return modifyPublicTags((tags) => {
56
+ const cur = collectFlatTagValues(tags, "web");
57
+ if (cur.includes(url))
58
+ return withFlatListTag(tags, "web", cur);
59
+ return withFlatListTag(tags, "web", [...cur, url]);
60
+ });
61
+ }
62
+ /** Removes a web browsing URL. */
63
+ export function removeGitRepositoryWebUrl(url) {
64
+ return modifyPublicTags((tags) => {
65
+ const cur = collectFlatTagValues(tags, "web").filter((u) => u !== url);
66
+ return withFlatListTag(tags, "web", cur);
67
+ });
68
+ }
69
+ /** Adds a git clone URL. */
70
+ export function addGitRepositoryCloneUrl(url) {
71
+ return modifyPublicTags((tags) => {
72
+ const cur = collectFlatTagValues(tags, "clone");
73
+ if (cur.includes(url))
74
+ return withFlatListTag(tags, "clone", cur);
75
+ return withFlatListTag(tags, "clone", [...cur, url]);
76
+ });
77
+ }
78
+ /** Removes a git clone URL. */
79
+ export function removeGitRepositoryCloneUrl(url) {
80
+ return modifyPublicTags((tags) => {
81
+ const cur = collectFlatTagValues(tags, "clone").filter((u) => u !== url);
82
+ return withFlatListTag(tags, "clone", cur);
83
+ });
84
+ }
85
+ /** Adds a repository relay URL. */
86
+ export function addGitRepositoryRelay(relay) {
87
+ const normalized = new URL(relay).toString();
88
+ return modifyPublicTags((tags) => {
89
+ const cur = collectFlatTagValues(tags, "relays");
90
+ if (cur.includes(normalized))
91
+ return withFlatListTag(tags, "relays", cur);
92
+ return withFlatListTag(tags, "relays", [...cur, normalized]);
93
+ });
94
+ }
95
+ /** Removes a repository relay URL. */
96
+ export function removeGitRepositoryRelay(relay) {
97
+ const normalized = new URL(relay).toString();
98
+ return modifyPublicTags((tags) => {
99
+ const cur = collectFlatTagValues(tags, "relays").filter((r) => r !== normalized);
100
+ return withFlatListTag(tags, "relays", cur);
101
+ });
102
+ }
103
+ /** Sets or removes the earliest unique commit marker. */
104
+ export function setGitRepositoryEarliestUniqueCommit(commit) {
105
+ return modifyPublicTags((tags) => {
106
+ const filtered = tags.filter((tag) => !(tag[0] === "r" && tag[2] === "euc"));
107
+ return commit === null ? filtered : [...filtered, ["r", commit, "euc"]];
108
+ });
109
+ }
110
+ /** Sets the recognized maintainer pubkeys (single `maintainers` tag). */
111
+ export function setGitRepositoryMaintainers(pubkeys) {
112
+ return modifyPublicTags((tags) => withFlatListTag(tags, "maintainers", pubkeys));
113
+ }
114
+ /** Adds a recognized maintainer pubkey. */
115
+ export function addGitRepositoryMaintainer(pubkey) {
116
+ return modifyPublicTags((tags) => {
117
+ const cur = collectFlatTagValues(tags, "maintainers");
118
+ if (cur.includes(pubkey))
119
+ return withFlatListTag(tags, "maintainers", cur);
120
+ return withFlatListTag(tags, "maintainers", [...cur, pubkey]);
121
+ });
122
+ }
123
+ /** Removes a recognized maintainer pubkey. */
124
+ export function removeGitRepositoryMaintainer(pubkey) {
125
+ return modifyPublicTags((tags) => {
126
+ const cur = collectFlatTagValues(tags, "maintainers").filter((pk) => pk !== pubkey);
127
+ return withFlatListTag(tags, "maintainers", cur);
128
+ });
129
+ }
130
+ /** Sets repository hashtags (NIP-34: multiple `["t", "<topic>"]` tags). */
131
+ export function setGitRepositoryHashtags(hashtags) {
132
+ return setHashtags(hashtags);
133
+ }
134
+ /** Adds a repository hashtag (NIP-34: `["t", "<topic>"]`). */
135
+ export function addGitRepositoryHashtag(hashtag) {
136
+ return addHashtag(hashtag);
137
+ }
138
+ /** Removes a repository hashtag. */
139
+ export function removeGitRepositoryHashtag(hashtag) {
140
+ return removeHashtag(hashtag);
141
+ }
142
+ /**
143
+ * Sets or clears the upstream repository pointer (the repo this one was forked from).
144
+ * Writes a `["u", "30617:<pubkey>:<identifier>", "<relay hint>"]` tag.
145
+ */
146
+ export function setGitRepositoryUpstream(pointer) {
147
+ return modifyPublicTags((tags) => {
148
+ const filtered = tags.filter((tag) => tag[0] !== "u");
149
+ if (!pointer)
150
+ return filtered;
151
+ if (pointer.kind !== GIT_REPOSITORY_KIND)
152
+ throw new Error(`Upstream pointer must reference kind ${GIT_REPOSITORY_KIND}`);
153
+ if (!pointer.identifier)
154
+ throw new Error("Upstream pointer must include an identifier");
155
+ const address = getReplaceableAddressFromPointer(pointer);
156
+ const hint = pointer.relays?.find((url) => isSafeRelayURL(url));
157
+ const tag = hint ? ["u", address, normalizeURL(hint)] : ["u", address];
158
+ return [...filtered, tag];
159
+ });
160
+ }
@@ -3,5 +3,7 @@ import { EventOperation } from "applesauce-core/factories";
3
3
  export declare function addHashtag(hashtag: string): EventOperation;
4
4
  /** Removes a hashtag from the live event */
5
5
  export declare function removeHashtag(hashtag: string): EventOperation;
6
+ /** Sets all the hashtags on an event. */
7
+ export declare function setHashtags(hashtags: string[]): EventOperation;
6
8
  /** Adds "t" tags for an array of hashtags */
7
9
  export declare function includeHashtags(hashtags: string[]): EventOperation;
@@ -11,6 +11,13 @@ export function removeHashtag(hashtag) {
11
11
  const cleanTag = (hashtag.startsWith("#") ? hashtag.slice(1) : hashtag).toLocaleLowerCase();
12
12
  return modifyPublicTags((tags) => tags.filter((t) => t[0] !== "t" || t[1].toLocaleLowerCase() !== cleanTag));
13
13
  }
14
+ /** Sets all the hashtags on an event. */
15
+ export function setHashtags(hashtags) {
16
+ return modifyPublicTags((tags) => [
17
+ ...tags.filter((t) => t[0] !== "t"),
18
+ ...hashtags.map((hashtag) => ["t", hashtag.toLocaleLowerCase()]),
19
+ ]);
20
+ }
14
21
  /** Adds "t" tags for an array of hashtags */
15
22
  export function includeHashtags(hashtags) {
16
23
  return modifyPublicTags(...hashtags.map((hashtag) => addNameValueTag(["t", hashtag.toLocaleLowerCase()])));
@@ -11,6 +11,8 @@ export * as Comment from "./comment.js";
11
11
  export * as FileMetadata from "./file-metadata.js";
12
12
  export * as Geohash from "./geohash.js";
13
13
  export * as GiftWrap from "./gift-wrap.js";
14
+ export * as GitGraspList from "./git-grasp-list.js";
15
+ export * as GitRepository from "./git-repository.js";
14
16
  export * as Group from "./group.js";
15
17
  export * as Hashtags from "./hashtags.js";
16
18
  export * as Highlight from "./highlight.js";
@@ -19,6 +21,7 @@ export * as List from "./list.js";
19
21
  export * as LiveStream from "./live-stream.js";
20
22
  export * as MediaAttachment from "./media-attachment.js";
21
23
  export * as Note from "./note.js";
24
+ export * as NostrWebToken from "./nostr-web-token.js";
22
25
  export * as PicturePost from "./picture-post.js";
23
26
  export * as Poll from "./poll.js";
24
27
  export * as PollResponse from "./poll-response.js";
@@ -11,6 +11,8 @@ export * as Comment from "./comment.js";
11
11
  export * as FileMetadata from "./file-metadata.js";
12
12
  export * as Geohash from "./geohash.js";
13
13
  export * as GiftWrap from "./gift-wrap.js";
14
+ export * as GitGraspList from "./git-grasp-list.js";
15
+ export * as GitRepository from "./git-repository.js";
14
16
  export * as Group from "./group.js";
15
17
  export * as Hashtags from "./hashtags.js";
16
18
  export * as Highlight from "./highlight.js";
@@ -19,6 +21,7 @@ export * as List from "./list.js";
19
21
  export * as LiveStream from "./live-stream.js";
20
22
  export * as MediaAttachment from "./media-attachment.js";
21
23
  export * as Note from "./note.js";
24
+ export * as NostrWebToken from "./nostr-web-token.js";
22
25
  export * as PicturePost from "./picture-post.js";
23
26
  export * as Poll from "./poll.js";
24
27
  export * as PollResponse from "./poll-response.js";
@@ -0,0 +1,27 @@
1
+ import { EventOperation } from "applesauce-core/factories";
2
+ /** Sets or removes the issuer claim. */
3
+ export declare function setIssuer(value: string | null): EventOperation;
4
+ /** Sets or removes the subject claim. */
5
+ export declare function setSubject(value: string | null): EventOperation;
6
+ /** Sets or removes the issued-at claim. */
7
+ export declare function setIssuedAt(value: number | null): EventOperation;
8
+ /** Sets or removes the expiration claim. */
9
+ export declare function setExpiration(value: number | null): EventOperation;
10
+ /** Sets or removes the not-before claim. */
11
+ export declare function setNotBefore(value: number | null): EventOperation;
12
+ /** Adds an audience claim. */
13
+ export declare function addAudience(value: string, replace?: boolean): EventOperation;
14
+ /** Removes a matching audience claim. */
15
+ export declare function removeAudience(value: string): EventOperation;
16
+ /** Removes all audience claims. */
17
+ export declare function clearAudiences(): EventOperation;
18
+ /** Replaces all audience claims. */
19
+ export declare function setAudiences(values: string[]): EventOperation;
20
+ /** Sets or removes a singleton claim. */
21
+ export declare function setClaim(name: string, value: string | number | null): EventOperation;
22
+ /** Adds an application-defined claim. */
23
+ export declare function addClaim(name: string, value: string | number, replace?: boolean): EventOperation;
24
+ /** Removes matching values for a claim, or all tags with the claim name when value is omitted. */
25
+ export declare function removeClaim(name: string, value?: string | number): EventOperation;
26
+ /** Removes all tags with the claim name. */
27
+ export declare function clearClaim(name: string): EventOperation;
@@ -0,0 +1,58 @@
1
+ import { eventPipe } from "applesauce-core/helpers";
2
+ import { addNameValueTag, removeSingletonTag, setSingletonTag } from "applesauce-core/operations/tag/common";
3
+ import { modifyPublicTags } from "applesauce-core/operations/tags";
4
+ function setNullableSingletonTag(name, value) {
5
+ return modifyPublicTags(value === null ? removeSingletonTag(name) : setSingletonTag([name, String(value)], true));
6
+ }
7
+ /** Sets or removes the issuer claim. */
8
+ export function setIssuer(value) {
9
+ return setNullableSingletonTag("iss", value);
10
+ }
11
+ /** Sets or removes the subject claim. */
12
+ export function setSubject(value) {
13
+ return setNullableSingletonTag("sub", value);
14
+ }
15
+ /** Sets or removes the issued-at claim. */
16
+ export function setIssuedAt(value) {
17
+ return setNullableSingletonTag("iat", value);
18
+ }
19
+ /** Sets or removes the expiration claim. */
20
+ export function setExpiration(value) {
21
+ return setNullableSingletonTag("exp", value);
22
+ }
23
+ /** Sets or removes the not-before claim. */
24
+ export function setNotBefore(value) {
25
+ return setNullableSingletonTag("nbf", value);
26
+ }
27
+ /** Adds an audience claim. */
28
+ export function addAudience(value, replace = true) {
29
+ return modifyPublicTags(addNameValueTag(["aud", value], replace));
30
+ }
31
+ /** Removes a matching audience claim. */
32
+ export function removeAudience(value) {
33
+ return modifyPublicTags((tags) => tags.filter((tag) => !(tag[0] === "aud" && tag[1] === value)));
34
+ }
35
+ /** Removes all audience claims. */
36
+ export function clearAudiences() {
37
+ return modifyPublicTags((tags) => tags.filter((tag) => tag[0] !== "aud"));
38
+ }
39
+ /** Replaces all audience claims. */
40
+ export function setAudiences(values) {
41
+ return eventPipe(clearAudiences(), ...values.map((value) => addAudience(value, false)));
42
+ }
43
+ /** Sets or removes a singleton claim. */
44
+ export function setClaim(name, value) {
45
+ return setNullableSingletonTag(name, value);
46
+ }
47
+ /** Adds an application-defined claim. */
48
+ export function addClaim(name, value, replace = true) {
49
+ return modifyPublicTags(addNameValueTag([name, String(value)], replace));
50
+ }
51
+ /** Removes matching values for a claim, or all tags with the claim name when value is omitted. */
52
+ export function removeClaim(name, value) {
53
+ return modifyPublicTags((tags) => tags.filter((tag) => (value === undefined ? tag[0] !== name : !(tag[0] === name && tag[1] === String(value)))));
54
+ }
55
+ /** Removes all tags with the claim name. */
56
+ export function clearClaim(name) {
57
+ return removeClaim(name);
58
+ }
@@ -1,7 +1,8 @@
1
1
  import { EventOperation } from "applesauce-core/factories";
2
+ import { TextContentOptions } from "applesauce-core/operations/content";
2
3
  import { PollType } from "../helpers/poll.js";
3
- /** Sets the content (poll question/label) for a poll event */
4
- export declare function setQuestion(question: string): EventOperation;
4
+ /** Sets the poll question as event content, with hashtag / mention / quote / custom emoji handling */
5
+ export declare function setQuestion(question: string, options?: TextContentOptions): EventOperation;
5
6
  /** Adds an option to a poll with an option ID and label */
6
7
  export declare function addOption(optionId: string, label: string): EventOperation;
7
8
  /** Sets multiple poll options at once, replacing any existing option tags */
@@ -1,8 +1,9 @@
1
1
  import { modifyPublicTags } from "applesauce-core/operations";
2
+ import { setShortTextContent } from "applesauce-core/operations/content";
2
3
  import { includeSingletonTag } from "applesauce-core/operations/tags";
3
- /** Sets the content (poll question/label) for a poll event */
4
- export function setQuestion(question) {
5
- return (draft) => ({ ...draft, content: question });
4
+ /** Sets the poll question as event content, with hashtag / mention / quote / custom emoji handling */
5
+ export function setQuestion(question, options) {
6
+ return setShortTextContent(question, options);
6
7
  }
7
8
  /** Adds an option to a poll with an option ID and label */
8
9
  export function addOption(optionId, label) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "applesauce-common",
3
- "version": "6.0.2",
3
+ "version": "6.2.0",
4
4
  "description": "Common NIP-specific helpers and models for applesauce",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -82,8 +82,8 @@
82
82
  }
83
83
  },
84
84
  "dependencies": {
85
- "@scure/base": "^1.2.4",
86
- "applesauce-core": "^6.0.0",
85
+ "@scure/base": "^2.2.0",
86
+ "applesauce-core": "^6.2.0",
87
87
  "hash-sum": "^2.0.0",
88
88
  "light-bolt11-decoder": "^3.2.0",
89
89
  "nanoid": "^5.0.9",
@@ -101,7 +101,7 @@
101
101
  "rimraf": "^6.0.1",
102
102
  "typescript": "^5.8.3",
103
103
  "vitest": "^4.0.15",
104
- "yaml": "^2.8.4"
104
+ "yaml": "^2.9.0"
105
105
  },
106
106
  "funding": {
107
107
  "type": "lightning",
@@ -1,10 +0,0 @@
1
- import { kinds, KnownEvent, KnownEventTemplate, NostrEvent } from "applesauce-core/helpers";
2
- import { NIP51RelayListFactory } from "./list.js";
3
- export type BlockedRelaysTemplate = KnownEventTemplate<kinds.BlockedRelaysList>;
4
- /** A factory class for building kind 10006 blocked relays list events */
5
- export declare class BlockedRelaysFactory extends NIP51RelayListFactory<kinds.BlockedRelaysList, BlockedRelaysTemplate> {
6
- /** Creates a new blocked relays factory */
7
- static create(): BlockedRelaysFactory;
8
- /** Creates a new blocked relays factory from an existing blocked relays event */
9
- static modify(event: NostrEvent | KnownEvent<kinds.BlockedRelaysList>): BlockedRelaysFactory;
10
- }
@@ -1,16 +0,0 @@
1
- import { blankEventTemplate, toEventTemplate } from "applesauce-core/factories";
2
- import { isKind, kinds } from "applesauce-core/helpers";
3
- import { NIP51RelayListFactory } from "./list.js";
4
- /** A factory class for building kind 10006 blocked relays list events */
5
- export class BlockedRelaysFactory extends NIP51RelayListFactory {
6
- /** Creates a new blocked relays factory */
7
- static create() {
8
- return new BlockedRelaysFactory((res) => res(blankEventTemplate(kinds.BlockedRelaysList)));
9
- }
10
- /** Creates a new blocked relays factory from an existing blocked relays event */
11
- static modify(event) {
12
- if (!isKind(event, kinds.BlockedRelaysList))
13
- throw new Error("Event is not a blocked relays event");
14
- return new BlockedRelaysFactory((res) => res(toEventTemplate(event)));
15
- }
16
- }
@@ -1,10 +0,0 @@
1
- import { kinds, KnownEvent, KnownEventTemplate, NostrEvent } from "applesauce-core/helpers";
2
- import { NIP51RelayListFactory } from "./list.js";
3
- export type DmRelaysTemplate = KnownEventTemplate<kinds.DirectMessageRelaysList>;
4
- /** A factory class for building kind 10050 direct message relays list events */
5
- export declare class DmRelaysFactory extends NIP51RelayListFactory<kinds.DirectMessageRelaysList, DmRelaysTemplate> {
6
- /** Creates a new DM relays factory */
7
- static create(): DmRelaysFactory;
8
- /** Creates a new DM relays factory from an existing DM relays event */
9
- static modify(event: NostrEvent | KnownEvent<kinds.DirectMessageRelaysList>): DmRelaysFactory;
10
- }
@@ -1,16 +0,0 @@
1
- import { blankEventTemplate, toEventTemplate } from "applesauce-core/factories";
2
- import { isKind, kinds } from "applesauce-core/helpers";
3
- import { NIP51RelayListFactory } from "./list.js";
4
- /** A factory class for building kind 10050 direct message relays list events */
5
- export class DmRelaysFactory extends NIP51RelayListFactory {
6
- /** Creates a new DM relays factory */
7
- static create() {
8
- return new DmRelaysFactory((res) => res(blankEventTemplate(kinds.DirectMessageRelaysList)));
9
- }
10
- /** Creates a new DM relays factory from an existing DM relays event */
11
- static modify(event) {
12
- if (!isKind(event, kinds.DirectMessageRelaysList))
13
- throw new Error("Event is not a DM relays event");
14
- return new DmRelaysFactory((res) => res(toEventTemplate(event)));
15
- }
16
- }
@@ -1,16 +0,0 @@
1
- import { KnownEvent, KnownEventTemplate, NostrEvent } from "applesauce-core/helpers";
2
- import { AddressPointer } from "applesauce-core/helpers/pointers";
3
- import { FAVORITE_RELAYS_KIND } from "../helpers/relay-list.js";
4
- import { NIP51RelayListFactory } from "./list.js";
5
- export type FavoriteRelaysTemplate = KnownEventTemplate<typeof FAVORITE_RELAYS_KIND>;
6
- /** A factory class for building kind 10012 favorite relays list events */
7
- export declare class FavoriteRelaysFactory extends NIP51RelayListFactory<typeof FAVORITE_RELAYS_KIND, FavoriteRelaysTemplate> {
8
- /** Creates a new favorite relays factory */
9
- static create(): FavoriteRelaysFactory;
10
- /** Creates a new favorite relays factory from an existing favorite relays event */
11
- static modify(event: NostrEvent | KnownEvent<typeof FAVORITE_RELAYS_KIND>): FavoriteRelaysFactory;
12
- /** Adds a relay set (address pointer) to the favorite relays event */
13
- addRelaySet(addr: AddressPointer | AddressPointer[], hidden?: boolean): this;
14
- /** Removes a relay set (address pointer) from the favorite relays event */
15
- removeRelaySet(addr: AddressPointer | AddressPointer[], hidden?: boolean): this;
16
- }
@@ -1,31 +0,0 @@
1
- import { blankEventTemplate, toEventTemplate } from "applesauce-core/factories";
2
- import { addAddressPointerTag, removeAddressPointerTag } from "applesauce-core/operations/tag/common";
3
- import { FAVORITE_RELAYS_KIND } from "../helpers/relay-list.js";
4
- import { NIP51RelayListFactory } from "./list.js";
5
- /** A factory class for building kind 10012 favorite relays list events */
6
- export class FavoriteRelaysFactory extends NIP51RelayListFactory {
7
- /** Creates a new favorite relays factory */
8
- static create() {
9
- return new FavoriteRelaysFactory((res) => res(blankEventTemplate(FAVORITE_RELAYS_KIND)));
10
- }
11
- /** Creates a new favorite relays factory from an existing favorite relays event */
12
- static modify(event) {
13
- if (event.kind !== FAVORITE_RELAYS_KIND)
14
- throw new Error("Event is not a favorite relays event");
15
- return new FavoriteRelaysFactory((res) => res(toEventTemplate(event)));
16
- }
17
- /** Adds a relay set (address pointer) to the favorite relays event */
18
- addRelaySet(addr, hidden = false) {
19
- const addrs = Array.isArray(addr) ? addr : [addr];
20
- return hidden
21
- ? this.modifyHiddenTags(...addrs.map((a) => addAddressPointerTag(a)))
22
- : this.modifyPublicTags(...addrs.map((a) => addAddressPointerTag(a)));
23
- }
24
- /** Removes a relay set (address pointer) from the favorite relays event */
25
- removeRelaySet(addr, hidden = false) {
26
- const addrs = Array.isArray(addr) ? addr : [addr];
27
- return hidden
28
- ? this.modifyHiddenTags(...addrs.map((a) => removeAddressPointerTag(a)))
29
- : this.modifyPublicTags(...addrs.map((a) => removeAddressPointerTag(a)));
30
- }
31
- }
@@ -1,10 +0,0 @@
1
- import { kinds, KnownEvent, KnownEventTemplate, NostrEvent } from "applesauce-core/helpers";
2
- import { NIP51RelayListFactory } from "./list.js";
3
- export type SearchRelaysTemplate = KnownEventTemplate<kinds.SearchRelaysList>;
4
- /** A factory class for building kind 10007 search relays list events */
5
- export declare class SearchRelaysFactory extends NIP51RelayListFactory<kinds.SearchRelaysList, SearchRelaysTemplate> {
6
- /** Creates a new search relays factory */
7
- static create(): SearchRelaysFactory;
8
- /** Creates a new search relays factory from an existing search relays event */
9
- static modify(event: NostrEvent | KnownEvent<kinds.SearchRelaysList>): SearchRelaysFactory;
10
- }
@@ -1,16 +0,0 @@
1
- import { blankEventTemplate, toEventTemplate } from "applesauce-core/factories";
2
- import { isKind, kinds } from "applesauce-core/helpers";
3
- import { NIP51RelayListFactory } from "./list.js";
4
- /** A factory class for building kind 10007 search relays list events */
5
- export class SearchRelaysFactory extends NIP51RelayListFactory {
6
- /** Creates a new search relays factory */
7
- static create() {
8
- return new SearchRelaysFactory((res) => res(blankEventTemplate(kinds.SearchRelaysList)));
9
- }
10
- /** Creates a new search relays factory from an existing search relays event */
11
- static modify(event) {
12
- if (!isKind(event, kinds.SearchRelaysList))
13
- throw new Error("Event is not a search relays event");
14
- return new SearchRelaysFactory((res) => res(toEventTemplate(event)));
15
- }
16
- }