applesauce-actions 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  A collection of pre-built actions nostr clients can use. Built on top of `applesauce-core` and `applesauce-factory`.
4
4
 
5
- [Documentation](https://hzrd149.github.io/applesauce/typedoc/modules/applesauce_actions.html)
5
+ [Documentation](https://hzrd149.github.io/applesauce/typedoc/modules/applesauce-actions.html)
6
6
 
7
7
  ## Installation
8
8
 
@@ -1,6 +1,6 @@
1
- import { kinds } from "nostr-tools";
2
- import { addEventBookmarkTag, removeEventBookmarkTag } from "applesauce-factory/operations/tag";
3
1
  import { modifyHiddenTags, modifyPublicTags, setListDescription, setListImage, setListTitle, } from "applesauce-factory/operations/event";
2
+ import { addEventBookmarkTag, removeEventBookmarkTag } from "applesauce-factory/operations/tag";
3
+ import { kinds } from "nostr-tools";
4
4
  function getBookmarkEvent(events, self, identifier) {
5
5
  return events.getReplaceable(identifier ? kinds.Bookmarksets : kinds.BookmarkList, self, identifier);
6
6
  }
@@ -1,6 +1,6 @@
1
1
  import { NostrEvent } from "nostr-tools";
2
- import { Action } from "../action-hub.js";
3
2
  import { ProfilePointer } from "nostr-tools/nip19";
3
+ import { Action } from "../action-hub.js";
4
4
  /**
5
5
  * An action that creates a new follow set
6
6
  * @param identifier the "d" tag of the follow set
@@ -1,6 +1,6 @@
1
- import { kinds } from "nostr-tools";
2
- import { addPubkeyTag, removePubkeyTag } from "applesauce-factory/operations/tag";
3
1
  import { modifyHiddenTags, modifyPublicTags, setListDescription, setListImage, setListTitle, } from "applesauce-factory/operations/event";
2
+ import { addPubkeyTag, removePubkeyTag } from "applesauce-factory/operations/tag";
3
+ import { kinds } from "nostr-tools";
4
4
  function getFollowSetEvent(events, self, identifier) {
5
5
  const set = typeof identifier === "string" ? events.getReplaceable(kinds.Followsets, self, identifier) : identifier;
6
6
  if (!set)
@@ -5,6 +5,7 @@ export * from "./contacts.js";
5
5
  export * from "./dm-relays.js";
6
6
  export * from "./favorite-relays.js";
7
7
  export * from "./follow-sets.js";
8
+ export * from "./lists.js";
8
9
  export * from "./mailboxes.js";
9
10
  export * from "./mute.js";
10
11
  export * from "./pins.js";
@@ -5,6 +5,7 @@ export * from "./contacts.js";
5
5
  export * from "./dm-relays.js";
6
6
  export * from "./favorite-relays.js";
7
7
  export * from "./follow-sets.js";
8
+ export * from "./lists.js";
8
9
  export * from "./mailboxes.js";
9
10
  export * from "./mute.js";
10
11
  export * from "./pins.js";
@@ -0,0 +1,9 @@
1
+ import { NostrEvent } from "nostr-tools";
2
+ import { AddressPointer } from "nostr-tools/nip19";
3
+ import { Action } from "../action-hub.js";
4
+ /** An action that sets or removes a NIP-15 list information */
5
+ export declare function SetListMetadata(list: NostrEvent | AddressPointer, info: {
6
+ title?: string;
7
+ description?: string;
8
+ image?: string;
9
+ }): Action;
@@ -0,0 +1,18 @@
1
+ import { isAddressPointer } from "applesauce-core/helpers";
2
+ import { setListDescription, setListImage, setListTitle } from "applesauce-factory/operations/event";
3
+ function getList(events, address) {
4
+ const list = isAddressPointer(address)
5
+ ? events.getReplaceable(address.kind, address.pubkey, address.identifier)
6
+ : address;
7
+ if (!list)
8
+ throw new Error("Can't find list");
9
+ return list;
10
+ }
11
+ /** An action that sets or removes a NIP-15 list information */
12
+ export function SetListMetadata(list, info) {
13
+ return async function* ({ events, factory }) {
14
+ list = getList(events, list);
15
+ const draft = await factory.modify(list, setListTitle(info.title ?? null), setListDescription(info.description ?? null), setListImage(info.image ?? null));
16
+ yield await factory.sign(draft);
17
+ };
18
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "applesauce-actions",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "A package for performing common nostr actions",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "applesauce-core": "^1.0.0",
36
- "applesauce-factory": "^1.0.0",
36
+ "applesauce-factory": "^1.1.0",
37
37
  "nostr-tools": "^2.10.4",
38
38
  "rxjs": "^7.8.1"
39
39
  },