applesauce-actions 0.0.0-next-20250522030625 → 0.0.0-next-20250606170247
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/dist/__tests__/action-hub.test.js +7 -3
- package/dist/action-hub.d.ts +6 -4
- package/dist/action-hub.js +4 -2
- package/dist/actions/__tests__/exports.test.js +4 -0
- package/dist/actions/__tests__/mute.test.js +6 -1
- package/dist/actions/bookmarks.js +1 -1
- package/dist/actions/contacts.js +1 -1
- package/dist/actions/follow-sets.d.ts +0 -3
- package/dist/actions/follow-sets.js +0 -3
- package/dist/actions/index.d.ts +2 -0
- package/dist/actions/index.js +2 -0
- package/dist/actions/legacy-messages.d.ts +7 -0
- package/dist/actions/legacy-messages.js +20 -0
- package/dist/actions/pins.js +1 -1
- package/dist/actions/wrapped-messages.d.ts +20 -0
- package/dist/actions/wrapped-messages.js +37 -0
- package/package.json +4 -4
- package/dist/actions/favorites.d.ts +0 -2
- package/dist/actions/favorites.js +0 -14
- package/dist/helpers/bookmark.d.ts +0 -15
- package/dist/helpers/bookmark.js +0 -26
- package/dist/helpers/contacts.d.ts +0 -5
- package/dist/helpers/contacts.js +0 -30
- package/dist/helpers/general.d.ts +0 -28
- package/dist/helpers/general.js +0 -62
- package/dist/helpers/groups.d.ts +0 -10
- package/dist/helpers/groups.js +0 -20
- package/dist/helpers/index.d.ts +0 -7
- package/dist/helpers/index.js +0 -7
- package/dist/helpers/mute.d.ts +0 -14
- package/dist/helpers/mute.js +0 -22
- package/dist/helpers/observable.d.ts +0 -3
- package/dist/helpers/observable.js +0 -20
- package/dist/helpers/operations/common.d.ts +0 -12
- package/dist/helpers/operations/common.js +0 -40
- package/dist/helpers/operations/groups.d.ts +0 -6
- package/dist/helpers/operations/groups.js +0 -15
- package/dist/helpers/operations/index.d.ts +0 -3
- package/dist/helpers/operations/index.js +0 -3
- package/dist/helpers/operations/relay.d.ts +0 -3
- package/dist/helpers/operations/relay.js +0 -8
- package/dist/helpers/pin.d.ts +0 -4
- package/dist/helpers/pin.js +0 -7
- package/dist/queries/bookmark.d.ts +0 -8
- package/dist/queries/bookmark.js +0 -23
- package/dist/queries/contacts.d.ts +0 -3
- package/dist/queries/contacts.js +0 -9
- package/dist/queries/index.d.ts +0 -4
- package/dist/queries/index.js +0 -4
- package/dist/queries/mute.d.ts +0 -8
- package/dist/queries/mute.js +0 -23
- package/dist/queries/pin.d.ts +0 -3
- package/dist/queries/pin.js +0 -9
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { from, Subject } from "rxjs";
|
|
2
|
-
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
3
3
|
import { subscribeSpyTo } from "@hirez_io/observer-spy";
|
|
4
4
|
import { EventFactory } from "applesauce-factory";
|
|
5
5
|
import { EventStore } from "applesauce-core";
|
|
@@ -7,8 +7,12 @@ import { FakeUser } from "./fake-user.js";
|
|
|
7
7
|
import { ActionHub } from "../action-hub.js";
|
|
8
8
|
import { CreateProfile } from "../actions/profile.js";
|
|
9
9
|
const user = new FakeUser();
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
let events = new EventStore();
|
|
11
|
+
let factory = new EventFactory({ signer: user });
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
events = new EventStore();
|
|
14
|
+
factory = new EventFactory({ signer: user });
|
|
15
|
+
});
|
|
12
16
|
describe("runAction", () => {
|
|
13
17
|
it("should handle action that return observables", async () => {
|
|
14
18
|
const e = [user.note(), user.profile({ name: "testing" })];
|
package/dist/action-hub.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Observable } from "rxjs";
|
|
2
2
|
import { NostrEvent } from "nostr-tools";
|
|
3
|
-
import { ISyncEventStore } from "applesauce-core/event-store";
|
|
4
3
|
import { EventFactory } from "applesauce-factory";
|
|
4
|
+
import { IEventStoreActions, IEventStoreRead } from "applesauce-core";
|
|
5
5
|
/**
|
|
6
6
|
* A callback used to tell the upstream app to publish an event
|
|
7
7
|
* @param label a label describing what
|
|
@@ -10,7 +10,7 @@ export type PublishMethod = (event: NostrEvent) => void | Promise<void>;
|
|
|
10
10
|
/** The context that is passed to actions for them to use to preform actions */
|
|
11
11
|
export type ActionContext = {
|
|
12
12
|
/** The event store to load events from */
|
|
13
|
-
events:
|
|
13
|
+
events: IEventStoreRead;
|
|
14
14
|
/** The pubkey of the signer in the event factory */
|
|
15
15
|
self: string;
|
|
16
16
|
/** The event factory used to build and modify events */
|
|
@@ -21,10 +21,12 @@ export type Action = (ctx: ActionContext) => Observable<NostrEvent> | AsyncGener
|
|
|
21
21
|
export type ActionConstructor<Args extends Array<any>> = (...args: Args) => Action;
|
|
22
22
|
/** The main class that runs actions */
|
|
23
23
|
export declare class ActionHub {
|
|
24
|
-
events:
|
|
24
|
+
events: IEventStoreRead & IEventStoreActions;
|
|
25
25
|
factory: EventFactory;
|
|
26
26
|
publish?: PublishMethod | undefined;
|
|
27
|
-
|
|
27
|
+
/** Whether to save all events created by actions to the event store */
|
|
28
|
+
saveToStore: boolean;
|
|
29
|
+
constructor(events: IEventStoreRead & IEventStoreActions, factory: EventFactory, publish?: PublishMethod | undefined);
|
|
28
30
|
protected context: ActionContext | undefined;
|
|
29
31
|
protected getContext(): Promise<ActionContext>;
|
|
30
32
|
/** Runs an action in a ActionContext and converts the result to an Observable */
|
package/dist/action-hub.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { from, isObservable, lastValueFrom, switchMap, toArray } from "rxjs";
|
|
1
|
+
import { from, isObservable, lastValueFrom, switchMap, tap, toArray } from "rxjs";
|
|
2
2
|
/** The main class that runs actions */
|
|
3
3
|
export class ActionHub {
|
|
4
4
|
events;
|
|
5
5
|
factory;
|
|
6
6
|
publish;
|
|
7
|
+
/** Whether to save all events created by actions to the event store */
|
|
8
|
+
saveToStore = true;
|
|
7
9
|
constructor(events, factory, publish) {
|
|
8
10
|
this.events = events;
|
|
9
11
|
this.factory = factory;
|
|
@@ -44,6 +46,6 @@ export class ActionHub {
|
|
|
44
46
|
return from(this.getContext()).pipe(switchMap((ctx) => {
|
|
45
47
|
const action = Action(...args);
|
|
46
48
|
return ActionHub.runAction(ctx, action);
|
|
47
|
-
}));
|
|
49
|
+
}), tap((event) => this.saveToStore && this.events.add(event)));
|
|
48
50
|
}
|
|
49
51
|
}
|
|
@@ -44,6 +44,10 @@ describe("exports", () => {
|
|
|
44
44
|
"RemoveRelayFromRelaySet",
|
|
45
45
|
"RemoveSearchRelay",
|
|
46
46
|
"RemoveUserFromFollowSet",
|
|
47
|
+
"ReplyToLegacyMessage",
|
|
48
|
+
"ReplyToWrappedMessage",
|
|
49
|
+
"SendLegacyMessage",
|
|
50
|
+
"SendWrappedMessage",
|
|
47
51
|
"SetDefaultBlossomServer",
|
|
48
52
|
"SetListMetadata",
|
|
49
53
|
"UnbookmarkEvent",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { beforeEach, describe, expect, it } from "vitest";
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
2
|
import { EventStore } from "applesauce-core";
|
|
3
3
|
import { EventFactory } from "applesauce-factory";
|
|
4
4
|
import { kinds } from "nostr-tools";
|
|
@@ -24,6 +24,7 @@ beforeEach(() => {
|
|
|
24
24
|
created_at: Math.floor(Date.now() / 1000),
|
|
25
25
|
});
|
|
26
26
|
events.add(muteList);
|
|
27
|
+
vi.useFakeTimers();
|
|
27
28
|
});
|
|
28
29
|
describe("MuteThread", () => {
|
|
29
30
|
it("should add an event to public tags in mute list", async () => {
|
|
@@ -46,6 +47,8 @@ describe("UnmuteThread", () => {
|
|
|
46
47
|
// First add the thread to mute list
|
|
47
48
|
const addSpy = subscribeSpyTo(hub.exec(MuteThread, testEventId), { expectErrors: false });
|
|
48
49
|
await addSpy.onComplete();
|
|
50
|
+
// Wait a second to ensure events have newer created_at
|
|
51
|
+
await vi.advanceTimersByTime(1000);
|
|
49
52
|
// Then unmute it
|
|
50
53
|
const spy = subscribeSpyTo(hub.exec(UnmuteThread, testEventId), { expectErrors: false });
|
|
51
54
|
await spy.onComplete();
|
|
@@ -57,6 +60,8 @@ describe("UnmuteThread", () => {
|
|
|
57
60
|
// First add the thread to hidden mute list
|
|
58
61
|
const addSpy = subscribeSpyTo(hub.exec(MuteThread, testEventId, true), { expectErrors: false });
|
|
59
62
|
await addSpy.onComplete();
|
|
63
|
+
// Wait a second to ensure events have newer created_at
|
|
64
|
+
await vi.advanceTimersByTime(1000);
|
|
60
65
|
// Then unmute it
|
|
61
66
|
const spy = subscribeSpyTo(hub.exec(UnmuteThread, testEventId, true), { expectErrors: false });
|
|
62
67
|
await spy.onComplete();
|
|
@@ -52,7 +52,7 @@ export function CreateBookmarkSet(title, description, additional) {
|
|
|
52
52
|
const existing = getBookmarkEvent(events, self);
|
|
53
53
|
if (existing)
|
|
54
54
|
throw new Error("Bookmark list already exists");
|
|
55
|
-
const draft = await factory.
|
|
55
|
+
const draft = await factory.build({ kind: kinds.BookmarkList }, setListTitle(title), setListDescription(description), additional.image ? setListImage(additional.image) : undefined, additional.public ? modifyPublicTags(...additional.public.map(addEventBookmarkTag)) : undefined, additional.hidden ? modifyHiddenTags(...additional.hidden.map(addEventBookmarkTag)) : undefined);
|
|
56
56
|
yield await factory.sign(draft);
|
|
57
57
|
};
|
|
58
58
|
}
|
package/dist/actions/contacts.js
CHANGED
|
@@ -29,7 +29,7 @@ export function NewContacts(pubkeys) {
|
|
|
29
29
|
const contacts = events.getReplaceable(kinds.Contacts, self);
|
|
30
30
|
if (contacts)
|
|
31
31
|
throw new Error("Contact list already exists");
|
|
32
|
-
const draft = await factory.
|
|
32
|
+
const draft = await factory.build({ kind: kinds.Contacts, tags: pubkeys?.map((p) => ["p", p]) });
|
|
33
33
|
yield await factory.sign(draft);
|
|
34
34
|
};
|
|
35
35
|
}
|
|
@@ -3,9 +3,6 @@ import { ProfilePointer } from "nostr-tools/nip19";
|
|
|
3
3
|
import { Action } from "../action-hub.js";
|
|
4
4
|
/**
|
|
5
5
|
* An action that creates a new follow set
|
|
6
|
-
* @param identifier the "d" tag of the follow set
|
|
7
|
-
* @param pubkeys the pubkeys to add to the follow set
|
|
8
|
-
* @param hidden set to true to create a hidden follow set
|
|
9
6
|
* @throws if a follow set already exists
|
|
10
7
|
*/
|
|
11
8
|
export declare function CreateFollowSet(title: string, options?: {
|
|
@@ -11,9 +11,6 @@ function getFollowSetEvent(events, self, identifier) {
|
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
13
|
* An action that creates a new follow set
|
|
14
|
-
* @param identifier the "d" tag of the follow set
|
|
15
|
-
* @param pubkeys the pubkeys to add to the follow set
|
|
16
|
-
* @param hidden set to true to create a hidden follow set
|
|
17
14
|
* @throws if a follow set already exists
|
|
18
15
|
*/
|
|
19
16
|
export function CreateFollowSet(title, options) {
|
package/dist/actions/index.d.ts
CHANGED
|
@@ -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 "./legacy-messages.js";
|
|
8
9
|
export * from "./lists.js";
|
|
9
10
|
export * from "./mailboxes.js";
|
|
10
11
|
export * from "./mute.js";
|
|
@@ -12,3 +13,4 @@ export * from "./pins.js";
|
|
|
12
13
|
export * from "./profile.js";
|
|
13
14
|
export * from "./relay-sets.js";
|
|
14
15
|
export * from "./search-relays.js";
|
|
16
|
+
export * from "./wrapped-messages.js";
|
package/dist/actions/index.js
CHANGED
|
@@ -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 "./legacy-messages.js";
|
|
8
9
|
export * from "./lists.js";
|
|
9
10
|
export * from "./mailboxes.js";
|
|
10
11
|
export * from "./mute.js";
|
|
@@ -12,3 +13,4 @@ export * from "./pins.js";
|
|
|
12
13
|
export * from "./profile.js";
|
|
13
14
|
export * from "./relay-sets.js";
|
|
14
15
|
export * from "./search-relays.js";
|
|
16
|
+
export * from "./wrapped-messages.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { LegacyMessageBlueprintOptions } from "applesauce-factory/blueprints";
|
|
2
|
+
import { NostrEvent } from "nostr-tools";
|
|
3
|
+
import { Action } from "../action-hub.js";
|
|
4
|
+
/** Sends a legacy NIP-04 message to a recipient */
|
|
5
|
+
export declare function SendLegacyMessage(recipient: string, message: string, opts?: LegacyMessageBlueprintOptions): Action;
|
|
6
|
+
/** Send a reply to a legacy message */
|
|
7
|
+
export declare function ReplyToLegacyMessage(parent: NostrEvent, message: string, opts?: LegacyMessageBlueprintOptions): Action;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { LegacyMessageBlueprint, LegacyMessageReplyBlueprint, } from "applesauce-factory/blueprints";
|
|
2
|
+
import { kinds } from "nostr-tools";
|
|
3
|
+
/** Sends a legacy NIP-04 message to a recipient */
|
|
4
|
+
export function SendLegacyMessage(recipient, message, opts) {
|
|
5
|
+
return async function* ({ factory }) {
|
|
6
|
+
const draft = await factory.create(LegacyMessageBlueprint, recipient, message, opts);
|
|
7
|
+
// Return the signed message
|
|
8
|
+
yield await factory.sign(draft);
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
/** Send a reply to a legacy message */
|
|
12
|
+
export function ReplyToLegacyMessage(parent, message, opts) {
|
|
13
|
+
return async function* ({ factory }) {
|
|
14
|
+
if (parent.kind !== kinds.EncryptedDirectMessage)
|
|
15
|
+
throw new Error("Legacy messages can only reply to other legacy messages");
|
|
16
|
+
const draft = await factory.create(LegacyMessageReplyBlueprint, parent, message, opts);
|
|
17
|
+
// Return the signed message
|
|
18
|
+
yield await factory.sign(draft);
|
|
19
|
+
};
|
|
20
|
+
}
|
package/dist/actions/pins.js
CHANGED
|
@@ -27,7 +27,7 @@ export function CreatePinList(pins = []) {
|
|
|
27
27
|
const existing = events.getReplaceable(kinds.Pinlist, self);
|
|
28
28
|
if (existing)
|
|
29
29
|
throw new Error("Pin list already exists");
|
|
30
|
-
const draft = await factory.
|
|
30
|
+
const draft = await factory.build({ kind: kinds.Pinlist }, modifyPublicTags(...pins.map((event) => addEventTag(event.id))));
|
|
31
31
|
yield await factory.sign(draft);
|
|
32
32
|
};
|
|
33
33
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Rumor } from "applesauce-core/helpers";
|
|
2
|
+
import { WrappedMessageBlueprintOptions } from "applesauce-factory/blueprints";
|
|
3
|
+
import { GiftWrapOptions } from "applesauce-factory/operations/event";
|
|
4
|
+
import { Action } from "../action-hub.js";
|
|
5
|
+
/**
|
|
6
|
+
* Sends a NIP-17 wrapped message to a conversation
|
|
7
|
+
* @param participants - A conversation identifier, user pubkey, or a list of participant pubkeys
|
|
8
|
+
* @param message - The message to send
|
|
9
|
+
* @param opts - Options for the wrapped message and gift wrap
|
|
10
|
+
* @returns Signed gift wrapped messages to send
|
|
11
|
+
*/
|
|
12
|
+
export declare function SendWrappedMessage(participants: string | string[], message: string, opts?: WrappedMessageBlueprintOptions & GiftWrapOptions): Action;
|
|
13
|
+
/**
|
|
14
|
+
* Sends a NIP-17 reply to a wrapped message
|
|
15
|
+
* @param parent - The parent wrapped message
|
|
16
|
+
* @param message - The message to send
|
|
17
|
+
* @param opts - Options for the wrapped message and gift wrap
|
|
18
|
+
* @returns Signed gift wrapped messages to send
|
|
19
|
+
*/
|
|
20
|
+
export declare function ReplyToWrappedMessage(parent: Rumor, message: string, opts?: WrappedMessageBlueprintOptions & GiftWrapOptions): Action;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { getConversationParticipants } from "applesauce-core/helpers";
|
|
2
|
+
import { GiftWrapBlueprint, WrappedMessageBlueprint, WrappedMessageReplyBlueprint, } from "applesauce-factory/blueprints";
|
|
3
|
+
/**
|
|
4
|
+
* Sends a NIP-17 wrapped message to a conversation
|
|
5
|
+
* @param participants - A conversation identifier, user pubkey, or a list of participant pubkeys
|
|
6
|
+
* @param message - The message to send
|
|
7
|
+
* @param opts - Options for the wrapped message and gift wrap
|
|
8
|
+
* @returns Signed gift wrapped messages to send
|
|
9
|
+
*/
|
|
10
|
+
export function SendWrappedMessage(participants, message, opts) {
|
|
11
|
+
return async function* ({ factory }) {
|
|
12
|
+
const rumor = await factory.create(WrappedMessageBlueprint, participants, message, opts);
|
|
13
|
+
// Get the pubkeys to send this message to (will include the sender)
|
|
14
|
+
const pubkeys = getConversationParticipants(rumor);
|
|
15
|
+
for (const pubkey of pubkeys) {
|
|
16
|
+
yield await factory.create(GiftWrapBlueprint, pubkey, rumor, opts);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Sends a NIP-17 reply to a wrapped message
|
|
22
|
+
* @param parent - The parent wrapped message
|
|
23
|
+
* @param message - The message to send
|
|
24
|
+
* @param opts - Options for the wrapped message and gift wrap
|
|
25
|
+
* @returns Signed gift wrapped messages to send
|
|
26
|
+
*/
|
|
27
|
+
export function ReplyToWrappedMessage(parent, message, opts) {
|
|
28
|
+
return async function* ({ factory }) {
|
|
29
|
+
// Create the reply message
|
|
30
|
+
const rumor = await factory.create(WrappedMessageReplyBlueprint, parent, message, opts);
|
|
31
|
+
// Get the pubkeys to send this message to (will include the sender)
|
|
32
|
+
const pubkeys = getConversationParticipants(parent);
|
|
33
|
+
for (const pubkey of pubkeys) {
|
|
34
|
+
yield await factory.create(GiftWrapBlueprint, pubkey, rumor, opts);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "applesauce-actions",
|
|
3
|
-
"version": "0.0.0-next-
|
|
3
|
+
"version": "0.0.0-next-20250606170247",
|
|
4
4
|
"description": "A package for performing common nostr actions",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -32,15 +32,15 @@
|
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"applesauce-core": "0.0.0-next-
|
|
36
|
-
"applesauce-factory": "0.0.0-next-
|
|
35
|
+
"applesauce-core": "0.0.0-next-20250606170247",
|
|
36
|
+
"applesauce-factory": "0.0.0-next-20250606170247",
|
|
37
37
|
"nostr-tools": "^2.13",
|
|
38
38
|
"rxjs": "^7.8.1"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@hirez_io/observer-spy": "^2.2.0",
|
|
42
42
|
"@types/debug": "^4.1.12",
|
|
43
|
-
"applesauce-signers": "0.0.0-next-
|
|
43
|
+
"applesauce-signers": "0.0.0-next-20250606170247",
|
|
44
44
|
"nanoid": "^5.1.5",
|
|
45
45
|
"typescript": "^5.8.3",
|
|
46
46
|
"vitest": "^3.1.1"
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { kinds } from "nostr-tools";
|
|
2
|
-
function getFollowSetEvent(events, self, identifier) {
|
|
3
|
-
const set = typeof identifier === "string" ? events.getReplaceable(kinds.Followsets, self, identifier) : identifier;
|
|
4
|
-
if (!set)
|
|
5
|
-
throw new Error("Can't find follow set");
|
|
6
|
-
if (set.kind !== kinds.FavoriteRelays)
|
|
7
|
-
throw new Error("Event is not a favorite relays");
|
|
8
|
-
return set;
|
|
9
|
-
}
|
|
10
|
-
export function AddFavoriteRelay(relay) {
|
|
11
|
-
return async function* ({ events, factory, self }) {
|
|
12
|
-
const favoriteRelays = events.getReplaceable(kinds.FavoriteRelays, self);
|
|
13
|
-
};
|
|
14
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { NostrEvent } from "nostr-tools";
|
|
2
|
-
import { AddressPointer, EventPointer } from "nostr-tools/nip19";
|
|
3
|
-
export declare const BookmarkPublicSymbol: unique symbol;
|
|
4
|
-
export declare const BookmarkHiddenSymbol: unique symbol;
|
|
5
|
-
export type Bookmarks = {
|
|
6
|
-
notes: EventPointer[];
|
|
7
|
-
articles: AddressPointer[];
|
|
8
|
-
hashtags: string[];
|
|
9
|
-
urls: string[];
|
|
10
|
-
};
|
|
11
|
-
export declare function parseBookmarkTags(tags: string[][]): Bookmarks;
|
|
12
|
-
/** Returns the public bookmarks of the event */
|
|
13
|
-
export declare function getBookmarks(bookmark: NostrEvent): Bookmarks;
|
|
14
|
-
/** Returns the bookmarks of the event if its unlocked */
|
|
15
|
-
export declare function getHiddenBookmarks(bookmark: NostrEvent): Bookmarks | undefined;
|
package/dist/helpers/bookmark.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { getAddressPointerFromATag, getEventPointerFromETag, getHiddenTags } from "applesauce-core/helpers";
|
|
2
|
-
import { kinds } from "nostr-tools";
|
|
3
|
-
import { getOrComputeCachedValue } from "applesauce-core/helpers/cache";
|
|
4
|
-
export const BookmarkPublicSymbol = Symbol.for("bookmark-public");
|
|
5
|
-
export const BookmarkHiddenSymbol = Symbol.for("bookmark-hidden");
|
|
6
|
-
export function parseBookmarkTags(tags) {
|
|
7
|
-
const notes = tags.filter((t) => t[0] === "e" && t[1]).map(getEventPointerFromETag);
|
|
8
|
-
const articles = tags
|
|
9
|
-
.filter((t) => t[0] === "a" && t[1])
|
|
10
|
-
.map(getAddressPointerFromATag)
|
|
11
|
-
.filter((addr) => addr.kind === kinds.LongFormArticle);
|
|
12
|
-
const hashtags = tags.filter((t) => t[0] === "t" && t[1]).map((t) => t[1]);
|
|
13
|
-
const urls = tags.filter((t) => t[0] === "r" && t[1]).map((t) => t[1]);
|
|
14
|
-
return { notes, articles, hashtags, urls };
|
|
15
|
-
}
|
|
16
|
-
/** Returns the public bookmarks of the event */
|
|
17
|
-
export function getBookmarks(bookmark) {
|
|
18
|
-
return getOrComputeCachedValue(bookmark, BookmarkPublicSymbol, () => parseBookmarkTags(bookmark.tags));
|
|
19
|
-
}
|
|
20
|
-
/** Returns the bookmarks of the event if its unlocked */
|
|
21
|
-
export function getHiddenBookmarks(bookmark) {
|
|
22
|
-
return getOrComputeCachedValue(bookmark, BookmarkHiddenSymbol, () => {
|
|
23
|
-
const tags = getHiddenTags(bookmark);
|
|
24
|
-
return tags && parseBookmarkTags(tags);
|
|
25
|
-
});
|
|
26
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { NostrEvent } from "nostr-tools";
|
|
2
|
-
export declare const ContactsRelaysSymbol: unique symbol;
|
|
3
|
-
export declare const ContactsPeopleSymbol: unique symbol;
|
|
4
|
-
export declare function getContactsPeople(contacts: NostrEvent): import("nostr-tools/nip19").ProfilePointer[];
|
|
5
|
-
export declare function relaysFromContactsEvent(event: NostrEvent): Map<string, "all" | "inbox" | "outbox"> | null;
|
package/dist/helpers/contacts.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { getProfilePointerFromPTag, isPTag, safeRelayUrl } from "applesauce-core/helpers";
|
|
2
|
-
import { getOrComputeCachedValue } from "applesauce-core/helpers/cache";
|
|
3
|
-
export const ContactsRelaysSymbol = Symbol.for("contacts-relays");
|
|
4
|
-
export const ContactsPeopleSymbol = Symbol.for("contacts-people");
|
|
5
|
-
export function getContactsPeople(contacts) {
|
|
6
|
-
return getOrComputeCachedValue(contacts, ContactsPeopleSymbol, () => contacts.tags.filter(isPTag).map(getProfilePointerFromPTag));
|
|
7
|
-
}
|
|
8
|
-
export function relaysFromContactsEvent(event) {
|
|
9
|
-
return getOrComputeCachedValue(event, ContactsRelaysSymbol, () => {
|
|
10
|
-
try {
|
|
11
|
-
const relayJson = JSON.parse(event.content);
|
|
12
|
-
const relays = new Map();
|
|
13
|
-
for (const [url, opts] of Object.entries(relayJson)) {
|
|
14
|
-
const safeUrl = safeRelayUrl(url);
|
|
15
|
-
if (!safeUrl)
|
|
16
|
-
continue;
|
|
17
|
-
if (opts.write && opts.read)
|
|
18
|
-
relays.set(safeUrl, "all");
|
|
19
|
-
else if (opts.read)
|
|
20
|
-
relays.set(safeUrl, "inbox");
|
|
21
|
-
else if (opts.write)
|
|
22
|
-
relays.set(safeUrl, "outbox");
|
|
23
|
-
}
|
|
24
|
-
return relays;
|
|
25
|
-
}
|
|
26
|
-
catch (error) {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { AddressPointer, EventPointer, ProfilePointer } from "nostr-tools/nip19";
|
|
2
|
-
import { NostrEvent } from "nostr-tools";
|
|
3
|
-
/**
|
|
4
|
-
* Checks if an event pointer is anywhere in a list or set
|
|
5
|
-
* NOTE: Ignores the `relay` field in EventPointer
|
|
6
|
-
* NOTE: This will check the hidden tags if the list has hidden tags and they are unlocked
|
|
7
|
-
*/
|
|
8
|
-
export declare function isEventPointerInList(list: NostrEvent, pointer: string | EventPointer): boolean;
|
|
9
|
-
/**
|
|
10
|
-
* Checks if an address pointer is anywhere in a list or set
|
|
11
|
-
* NOTE: Ignores the `relay` field in AddressPointer
|
|
12
|
-
* NOTE: This will check the hidden tags if the list has hidden tags and they are unlocked
|
|
13
|
-
*/
|
|
14
|
-
export declare function isAddressPointerInList(list: NostrEvent, pointer: string | AddressPointer): boolean;
|
|
15
|
-
/**
|
|
16
|
-
* Checks if an profile pointer is anywhere in a list or set
|
|
17
|
-
* NOTE: Ignores the `relay` field in ProfilePointer
|
|
18
|
-
* NOTE: This will check the hidden tags if the list has hidden tags and they are unlocked
|
|
19
|
-
*/
|
|
20
|
-
export declare function isProfilePointerInList(list: NostrEvent, pointer: string | ProfilePointer): boolean;
|
|
21
|
-
/** Returns all the EventPointer in a list or set */
|
|
22
|
-
export declare function getEventPointersFromList(list: NostrEvent): EventPointer[];
|
|
23
|
-
/** Returns all the AddressPointer in a list or set */
|
|
24
|
-
export declare function getAddressPointersFromList(list: NostrEvent): AddressPointer[];
|
|
25
|
-
/** Returns all the ProfilePointer in a list or set */
|
|
26
|
-
export declare function getProfilePointersFromList(list: NostrEvent): ProfilePointer[];
|
|
27
|
-
/** Returns if an event is a valid list or set */
|
|
28
|
-
export declare function isValidList(event: NostrEvent): boolean;
|
package/dist/helpers/general.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { getAddressPointerFromATag, getCoordinateFromAddressPointer, getEventPointerFromETag, getHiddenTags, getProfilePointerFromPTag, getReplaceableIdentifier, isATag, isETag, isPTag, processTags, } from "applesauce-core/helpers";
|
|
2
|
-
import { isParameterizedReplaceableKind, isReplaceableKind } from "nostr-tools/kinds";
|
|
3
|
-
function listGetAllTags(list) {
|
|
4
|
-
const hidden = getHiddenTags(list);
|
|
5
|
-
return hidden ? [...hidden, ...list.tags] : list.tags;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Checks if an event pointer is anywhere in a list or set
|
|
9
|
-
* NOTE: Ignores the `relay` field in EventPointer
|
|
10
|
-
* NOTE: This will check the hidden tags if the list has hidden tags and they are unlocked
|
|
11
|
-
*/
|
|
12
|
-
export function isEventPointerInList(list, pointer) {
|
|
13
|
-
const id = typeof pointer === "string" ? pointer : pointer.id;
|
|
14
|
-
return listGetAllTags(list).some((t) => t[0] === "e" && t[1] === id);
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Checks if an address pointer is anywhere in a list or set
|
|
18
|
-
* NOTE: Ignores the `relay` field in AddressPointer
|
|
19
|
-
* NOTE: This will check the hidden tags if the list has hidden tags and they are unlocked
|
|
20
|
-
*/
|
|
21
|
-
export function isAddressPointerInList(list, pointer) {
|
|
22
|
-
const cord = typeof pointer === "string" ? pointer : getCoordinateFromAddressPointer(pointer);
|
|
23
|
-
return listGetAllTags(list).some((t) => t[0] === "a" && t[1] === cord);
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Checks if an profile pointer is anywhere in a list or set
|
|
27
|
-
* NOTE: Ignores the `relay` field in ProfilePointer
|
|
28
|
-
* NOTE: This will check the hidden tags if the list has hidden tags and they are unlocked
|
|
29
|
-
*/
|
|
30
|
-
export function isProfilePointerInList(list, pointer) {
|
|
31
|
-
const pubkey = typeof pointer === "string" ? pointer : pointer.pubkey;
|
|
32
|
-
return listGetAllTags(list).some((t) => t[0] === "p" && t[1] === pubkey);
|
|
33
|
-
}
|
|
34
|
-
/** Returns all the EventPointer in a list or set */
|
|
35
|
-
export function getEventPointersFromList(list) {
|
|
36
|
-
return processTags(listGetAllTags(list), (tag) => (isETag(tag) ? tag : undefined), getEventPointerFromETag);
|
|
37
|
-
}
|
|
38
|
-
/** Returns all the AddressPointer in a list or set */
|
|
39
|
-
export function getAddressPointersFromList(list) {
|
|
40
|
-
return processTags(listGetAllTags(list), (t) => (isATag(t) ? t : undefined), getAddressPointerFromATag);
|
|
41
|
-
}
|
|
42
|
-
/** Returns all the ProfilePointer in a list or set */
|
|
43
|
-
export function getProfilePointersFromList(list) {
|
|
44
|
-
return processTags(listGetAllTags(list), (t) => (isPTag(t) ? t : undefined), getProfilePointerFromPTag);
|
|
45
|
-
}
|
|
46
|
-
/** Returns if an event is a valid list or set */
|
|
47
|
-
export function isValidList(event) {
|
|
48
|
-
try {
|
|
49
|
-
if (isParameterizedReplaceableKind(event.kind)) {
|
|
50
|
-
// event is a set
|
|
51
|
-
// ensure the set has an identifier
|
|
52
|
-
getReplaceableIdentifier(event);
|
|
53
|
-
return true;
|
|
54
|
-
}
|
|
55
|
-
else if (isReplaceableKind(event.kind) && event.kind >= 10000 && event.kind < 20000) {
|
|
56
|
-
// event is a list
|
|
57
|
-
return true;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
catch (error) { }
|
|
61
|
-
return false;
|
|
62
|
-
}
|
package/dist/helpers/groups.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { GroupPointer } from "applesauce-core/helpers/groups";
|
|
2
|
-
import { NostrEvent } from "nostr-tools";
|
|
3
|
-
export declare const GroupsPublicSymbol: unique symbol;
|
|
4
|
-
export declare const GroupsHiddenSymbol: unique symbol;
|
|
5
|
-
/** gets a {@link GroupPointer} from a "group" tag */
|
|
6
|
-
export declare function getGroupPointerFromGroupTag(tag: string[]): GroupPointer;
|
|
7
|
-
/** Returns all the public groups from a k:10009 list */
|
|
8
|
-
export declare function getPublicGroups(bookmark: NostrEvent): GroupPointer[];
|
|
9
|
-
/** Returns all the hidden groups from a k:10009 list */
|
|
10
|
-
export declare function getHiddenGroups(bookmark: NostrEvent): GroupPointer[] | undefined;
|
package/dist/helpers/groups.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { getHiddenTags, getOrComputeCachedValue, processTags } from "applesauce-core/helpers";
|
|
2
|
-
export const GroupsPublicSymbol = Symbol.for("groups-public");
|
|
3
|
-
export const GroupsHiddenSymbol = Symbol.for("groups-hidden");
|
|
4
|
-
/** gets a {@link GroupPointer} from a "group" tag */
|
|
5
|
-
export function getGroupPointerFromGroupTag(tag) {
|
|
6
|
-
const [_, id, relay, name] = tag;
|
|
7
|
-
return { id, relay, name };
|
|
8
|
-
}
|
|
9
|
-
/** Returns all the public groups from a k:10009 list */
|
|
10
|
-
export function getPublicGroups(bookmark) {
|
|
11
|
-
return getOrComputeCachedValue(bookmark, GroupsPublicSymbol, () => processTags(bookmark.tags.filter((t) => t[0] === "group"), getGroupPointerFromGroupTag));
|
|
12
|
-
}
|
|
13
|
-
/** Returns all the hidden groups from a k:10009 list */
|
|
14
|
-
export function getHiddenGroups(bookmark) {
|
|
15
|
-
return getOrComputeCachedValue(bookmark, GroupsHiddenSymbol, () => {
|
|
16
|
-
const tags = getHiddenTags(bookmark);
|
|
17
|
-
return (tags &&
|
|
18
|
-
processTags(bookmark.tags.filter((t) => t[0] === "group"), getGroupPointerFromGroupTag));
|
|
19
|
-
});
|
|
20
|
-
}
|
package/dist/helpers/index.d.ts
DELETED
package/dist/helpers/index.js
DELETED
package/dist/helpers/mute.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { NostrEvent } from "nostr-tools";
|
|
2
|
-
export declare const MutePublicSymbol: unique symbol;
|
|
3
|
-
export declare const MuteHiddenSymbol: unique symbol;
|
|
4
|
-
export type Mutes = {
|
|
5
|
-
pubkeys: Set<string>;
|
|
6
|
-
threads: Set<string>;
|
|
7
|
-
hashtags: Set<string>;
|
|
8
|
-
words: Set<string>;
|
|
9
|
-
};
|
|
10
|
-
export declare function parseMutedTags(tags: string[][]): Mutes;
|
|
11
|
-
/** Returns muted things */
|
|
12
|
-
export declare function getMutedThings(mute: NostrEvent): Mutes;
|
|
13
|
-
/** Returns the hidden muted content if the event is unlocked */
|
|
14
|
-
export declare function getHiddenMutedThings(mute: NostrEvent): Mutes | undefined;
|
package/dist/helpers/mute.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { getHiddenTags, isETag, isPTag, isTTag } from "applesauce-core/helpers";
|
|
2
|
-
import { getOrComputeCachedValue } from "applesauce-core/helpers/cache";
|
|
3
|
-
export const MutePublicSymbol = Symbol.for("mute-public");
|
|
4
|
-
export const MuteHiddenSymbol = Symbol.for("mute-hidden");
|
|
5
|
-
export function parseMutedTags(tags) {
|
|
6
|
-
const pubkeys = new Set(tags.filter(isPTag).map((t) => t[1]));
|
|
7
|
-
const threads = new Set(tags.filter(isETag).map((t) => t[1]));
|
|
8
|
-
const hashtags = new Set(tags.filter(isTTag).map((t) => t[1].toLocaleLowerCase()));
|
|
9
|
-
const words = new Set(tags.filter((t) => t[0] === "word" && t[1]).map((t) => t[1].toLocaleLowerCase()));
|
|
10
|
-
return { pubkeys, threads, hashtags, words };
|
|
11
|
-
}
|
|
12
|
-
/** Returns muted things */
|
|
13
|
-
export function getMutedThings(mute) {
|
|
14
|
-
return getOrComputeCachedValue(mute, MutePublicSymbol, (e) => parseMutedTags(e.tags));
|
|
15
|
-
}
|
|
16
|
-
/** Returns the hidden muted content if the event is unlocked */
|
|
17
|
-
export function getHiddenMutedThings(mute) {
|
|
18
|
-
return getOrComputeCachedValue(mute, MuteHiddenSymbol, () => {
|
|
19
|
-
const tags = getHiddenTags(mute);
|
|
20
|
-
return tags && parseMutedTags(tags);
|
|
21
|
-
});
|
|
22
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/** Subscribes to an observable, send all the values to a method and unsubscribes when complete */
|
|
2
|
-
export function play(stream, method) {
|
|
3
|
-
return new Promise((resolve, reject) => {
|
|
4
|
-
const sub = stream.subscribe({
|
|
5
|
-
next: (v) => {
|
|
6
|
-
try {
|
|
7
|
-
method(v);
|
|
8
|
-
}
|
|
9
|
-
catch (error) {
|
|
10
|
-
reject(error);
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
error: (error) => reject(error),
|
|
14
|
-
complete: () => {
|
|
15
|
-
sub.unsubscribe();
|
|
16
|
-
resolve();
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { AddressPointer, EventPointer, ProfilePointer } from "nostr-tools/nip19";
|
|
2
|
-
import { TagOperation } from "applesauce-factory/operations";
|
|
3
|
-
export declare function addPubkeyTag(pubkey: string | ProfilePointer): TagOperation;
|
|
4
|
-
export declare function removePubkeyTag(pubkey: string | ProfilePointer): TagOperation;
|
|
5
|
-
export declare function addEventTag(id: string | EventPointer): TagOperation;
|
|
6
|
-
export declare function removeEvent(id: string | EventPointer): TagOperation;
|
|
7
|
-
export declare function addCoordinateTag(cord: string | AddressPointer): TagOperation;
|
|
8
|
-
export declare function removeCoordinateTag(cord: string | AddressPointer): TagOperation;
|
|
9
|
-
/** Adds a name / value tag from a list */
|
|
10
|
-
export declare function addNameValueTag(tag: string[]): TagOperation;
|
|
11
|
-
/** Removes a name / value tag from a list */
|
|
12
|
-
export declare function removeNameValueTag(tag: string[]): TagOperation;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { getCoordinateFromAddressPointer } from "applesauce-core/helpers";
|
|
2
|
-
import { createATagFromAddressPointer, createETagFromEventPointer, ensureNamedValueTag, } from "applesauce-factory/helpers";
|
|
3
|
-
export function addPubkeyTag(pubkey) {
|
|
4
|
-
pubkey = typeof pubkey !== "string" ? pubkey.pubkey : pubkey;
|
|
5
|
-
return (tags) => [...tags, ["p", pubkey]];
|
|
6
|
-
}
|
|
7
|
-
export function removePubkeyTag(pubkey) {
|
|
8
|
-
pubkey = typeof pubkey !== "string" ? pubkey.pubkey : pubkey;
|
|
9
|
-
return (tags) => tags.filter((t) => !(t[0] === "p" && t[1] === pubkey));
|
|
10
|
-
}
|
|
11
|
-
export function addEventTag(id) {
|
|
12
|
-
if (typeof id === "string")
|
|
13
|
-
return (tags) => [...tags, ["e", id]];
|
|
14
|
-
else
|
|
15
|
-
return (tags) => [...tags, createETagFromEventPointer(id)];
|
|
16
|
-
}
|
|
17
|
-
export function removeEvent(id) {
|
|
18
|
-
if (typeof id === "string")
|
|
19
|
-
return (tags) => tags.filter((t) => !(t[0] === "e" && t[1] === id));
|
|
20
|
-
else
|
|
21
|
-
return (tags) => tags.filter((t) => !(t[0] === "e" && t[1] === id.id));
|
|
22
|
-
}
|
|
23
|
-
export function addCoordinateTag(cord) {
|
|
24
|
-
if (typeof cord === "string")
|
|
25
|
-
return (tags) => [...tags, ["a", cord]];
|
|
26
|
-
else
|
|
27
|
-
return (tags) => [...tags, createATagFromAddressPointer(cord)];
|
|
28
|
-
}
|
|
29
|
-
export function removeCoordinateTag(cord) {
|
|
30
|
-
cord = typeof cord !== "string" ? getCoordinateFromAddressPointer(cord) : cord;
|
|
31
|
-
return (tags) => tags.filter((t) => !(t[0] === "a" && t[1] === cord));
|
|
32
|
-
}
|
|
33
|
-
/** Adds a name / value tag from a list */
|
|
34
|
-
export function addNameValueTag(tag) {
|
|
35
|
-
return (tags) => ensureNamedValueTag(tags, tag);
|
|
36
|
-
}
|
|
37
|
-
/** Removes a name / value tag from a list */
|
|
38
|
-
export function removeNameValueTag(tag) {
|
|
39
|
-
return (tags) => tags.filter((t) => !(t[0] === tag[0] && t[1] === tag[1]));
|
|
40
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { GroupPointer } from "applesauce-core/helpers/groups";
|
|
2
|
-
import { TagOperation } from "applesauce-factory/operations";
|
|
3
|
-
/** Adds a "group" tag to a list */
|
|
4
|
-
export declare function addGroupTag(group: GroupPointer): TagOperation;
|
|
5
|
-
/** Removes a "group" tag from a list */
|
|
6
|
-
export declare function removeGroupTag(group: GroupPointer): TagOperation;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { createGroupTagFromGroupPointer } from "applesauce-factory/helpers";
|
|
2
|
-
/** Adds a "group" tag to a list */
|
|
3
|
-
export function addGroupTag(group) {
|
|
4
|
-
return (tags) => {
|
|
5
|
-
const existing = tags.find((t) => t[0] === "group" && t[1] === group.id && t[2] === group.relay);
|
|
6
|
-
if (existing)
|
|
7
|
-
return tags.map((tag) => (tag === existing ? createGroupTagFromGroupPointer(group) : tag));
|
|
8
|
-
else
|
|
9
|
-
return [...tags, createGroupTagFromGroupPointer(group)];
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
/** Removes a "group" tag from a list */
|
|
13
|
-
export function removeGroupTag(group) {
|
|
14
|
-
return (tags) => tags.filter((tag) => tag[0] === "group" && tag[1] === group.id && tag[2] === group.relay);
|
|
15
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export function addRelayTag(url) {
|
|
2
|
-
url = typeof url === "string" ? url : String(url);
|
|
3
|
-
return (tags) => [...tags, ["relay", url]];
|
|
4
|
-
}
|
|
5
|
-
export function removeRelayTag(url) {
|
|
6
|
-
url = typeof url === "string" ? url : String(url);
|
|
7
|
-
return (tags) => tags.filter((t) => !(t[0] === "relay" && t[1] === url));
|
|
8
|
-
}
|
package/dist/helpers/pin.d.ts
DELETED
package/dist/helpers/pin.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { getEventPointerFromETag, isETag } from "applesauce-core/helpers";
|
|
2
|
-
import { getOrComputeCachedValue } from "applesauce-core/helpers/cache";
|
|
3
|
-
export const PinnedNotesSymbol = Symbol.for("pinned-notes");
|
|
4
|
-
/** Returns a set of muted threads */
|
|
5
|
-
export function getPinnedNotes(pin) {
|
|
6
|
-
return getOrComputeCachedValue(pin, PinnedNotesSymbol, (e) => e.tags.filter(isETag).map(getEventPointerFromETag));
|
|
7
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Query } from "applesauce-core";
|
|
2
|
-
import { Bookmarks } from "../helpers/bookmark.js";
|
|
3
|
-
export declare function UserBookmarkQuery(pubkey: string): Query<Bookmarks | undefined>;
|
|
4
|
-
export declare function UserHiddenBookmarkQuery(pubkey: string): Query<(Bookmarks & {
|
|
5
|
-
locked: false;
|
|
6
|
-
}) | {
|
|
7
|
-
locked: true;
|
|
8
|
-
} | undefined>;
|
package/dist/queries/bookmark.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { kinds } from "nostr-tools";
|
|
2
|
-
import { map } from "rxjs/operators";
|
|
3
|
-
import { isHiddenTagsLocked } from "applesauce-core/helpers";
|
|
4
|
-
import { getBookmarks, getHiddenBookmarks } from "../helpers/bookmark.js";
|
|
5
|
-
export function UserBookmarkQuery(pubkey) {
|
|
6
|
-
return {
|
|
7
|
-
key: pubkey,
|
|
8
|
-
run: (store) => store.replaceable(kinds.Mutelist, pubkey).pipe(map((event) => event && getBookmarks(event))),
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
export function UserHiddenBookmarkQuery(pubkey) {
|
|
12
|
-
return {
|
|
13
|
-
key: pubkey,
|
|
14
|
-
run: (store) => store.replaceable(kinds.Mutelist, pubkey).pipe(map((event) => {
|
|
15
|
-
if (!event)
|
|
16
|
-
return undefined;
|
|
17
|
-
const bookmarks = getHiddenBookmarks(event);
|
|
18
|
-
if (isHiddenTagsLocked(event) || !bookmarks)
|
|
19
|
-
return { locked: true };
|
|
20
|
-
return { locked: false, ...bookmarks };
|
|
21
|
-
})),
|
|
22
|
-
};
|
|
23
|
-
}
|
package/dist/queries/contacts.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { kinds } from "nostr-tools";
|
|
2
|
-
import { map } from "rxjs/operators";
|
|
3
|
-
import { getContactsPeople } from "../helpers/contacts.js";
|
|
4
|
-
export function UserContactsQuery(pubkey) {
|
|
5
|
-
return {
|
|
6
|
-
key: pubkey,
|
|
7
|
-
run: (store) => store.replaceable(kinds.Mutelist, pubkey).pipe(map((event) => event && getContactsPeople(event))),
|
|
8
|
-
};
|
|
9
|
-
}
|
package/dist/queries/index.d.ts
DELETED
package/dist/queries/index.js
DELETED
package/dist/queries/mute.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Query } from "applesauce-core";
|
|
2
|
-
import { Mutes } from "../helpers/mute.js";
|
|
3
|
-
export declare function UserMuteQuery(pubkey: string): Query<Mutes | undefined>;
|
|
4
|
-
export declare function UserHiddenMuteQuery(pubkey: string): Query<(Mutes & {
|
|
5
|
-
locked: false;
|
|
6
|
-
}) | {
|
|
7
|
-
locked: true;
|
|
8
|
-
} | undefined>;
|
package/dist/queries/mute.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { kinds } from "nostr-tools";
|
|
2
|
-
import { map } from "rxjs/operators";
|
|
3
|
-
import { isHiddenTagsLocked } from "applesauce-core/helpers";
|
|
4
|
-
import { getHiddenMutedThings, getMutedThings } from "../helpers/mute.js";
|
|
5
|
-
export function UserMuteQuery(pubkey) {
|
|
6
|
-
return {
|
|
7
|
-
key: pubkey,
|
|
8
|
-
run: (store) => store.replaceable(kinds.Mutelist, pubkey).pipe(map((event) => event && getMutedThings(event))),
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
export function UserHiddenMuteQuery(pubkey) {
|
|
12
|
-
return {
|
|
13
|
-
key: pubkey,
|
|
14
|
-
run: (store) => store.replaceable(kinds.Mutelist, pubkey).pipe(map((event) => {
|
|
15
|
-
if (!event)
|
|
16
|
-
return undefined;
|
|
17
|
-
const muted = getHiddenMutedThings(event);
|
|
18
|
-
if (isHiddenTagsLocked(event) || !muted)
|
|
19
|
-
return { locked: true };
|
|
20
|
-
return { locked: false, ...muted };
|
|
21
|
-
})),
|
|
22
|
-
};
|
|
23
|
-
}
|
package/dist/queries/pin.d.ts
DELETED
package/dist/queries/pin.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { kinds } from "nostr-tools";
|
|
2
|
-
import { map } from "rxjs/operators";
|
|
3
|
-
import { getPinnedNotes } from "../helpers/pin.js";
|
|
4
|
-
export function UserPinnedNotesQuery(pubkey) {
|
|
5
|
-
return {
|
|
6
|
-
key: pubkey,
|
|
7
|
-
run: (store) => store.replaceable(kinds.Pinlist, pubkey).pipe(map((event) => event && getPinnedNotes(event))),
|
|
8
|
-
};
|
|
9
|
-
}
|