applesauce-common 0.0.0-next-20251203172109 → 0.0.0-next-20251205152544
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/helpers/groups.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { NostrEvent } from "applesauce-core/helpers/event";
|
|
2
|
+
import { NameValueTag } from "applesauce-core/helpers/tags";
|
|
2
3
|
export declare const GROUPS_LIST_KIND = 10009;
|
|
3
4
|
export declare const GROUP_MESSAGE_KIND = 9;
|
|
4
5
|
/** NIP-29 group pointer */
|
|
@@ -24,3 +25,9 @@ export declare function getGroupPointerFromGroupTag(tag: string[]): GroupPointer
|
|
|
24
25
|
export declare function getPublicGroups(bookmark: NostrEvent): GroupPointer[];
|
|
25
26
|
/** Returns all the hidden groups from a k:10009 list */
|
|
26
27
|
export declare function getHiddenGroups(bookmark: NostrEvent): GroupPointer[] | undefined;
|
|
28
|
+
/** Gets a {@link GroupPointer} from a kind 39000 group metadata event */
|
|
29
|
+
export declare function getGroupPointerFromMetadata(event: NostrEvent, relay: string): GroupPointer | undefined;
|
|
30
|
+
/** Creates a "h" tag for chat messages from a {@link GroupPointer} */
|
|
31
|
+
export declare function createGroupHTagFromGroupPointer(group: GroupPointer): NameValueTag;
|
|
32
|
+
/** Creates a "group" tag from a {@link GroupPointer} */
|
|
33
|
+
export declare function createGroupTagFromGroupPointer(group: GroupPointer): NameValueTag;
|
package/dist/helpers/groups.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { getOrComputeCachedValue } from "applesauce-core/helpers/cache";
|
|
2
|
+
import { getReplaceableIdentifier, getTagValue } from "applesauce-core/helpers/event";
|
|
2
3
|
import { getHiddenTags } from "applesauce-core/helpers/hidden-tags";
|
|
3
|
-
import { processTags } from "applesauce-core/helpers/tags";
|
|
4
|
-
import { normalizeURL } from "applesauce-core/helpers/url";
|
|
4
|
+
import { fillAndTrimTag, processTags } from "applesauce-core/helpers/tags";
|
|
5
|
+
import { ensureWebSocketURL, normalizeURL } from "applesauce-core/helpers/url";
|
|
5
6
|
export const GROUPS_LIST_KIND = 10009;
|
|
6
7
|
export const GROUP_MESSAGE_KIND = 9;
|
|
7
8
|
/** decodes a group identifier into a group pointer object */
|
|
@@ -47,3 +48,22 @@ export function getHiddenGroups(bookmark) {
|
|
|
47
48
|
processTags(bookmark.tags.filter((t) => t[0] === "group"), getGroupPointerFromGroupTag));
|
|
48
49
|
});
|
|
49
50
|
}
|
|
51
|
+
/** Gets a {@link GroupPointer} from a kind 39000 group metadata event */
|
|
52
|
+
export function getGroupPointerFromMetadata(event, relay) {
|
|
53
|
+
// Use the "d" tag for the group ID and the provided relay
|
|
54
|
+
const groupId = getReplaceableIdentifier(event) || "_";
|
|
55
|
+
const name = getTagValue(event, "name");
|
|
56
|
+
return {
|
|
57
|
+
id: groupId,
|
|
58
|
+
relay: relay,
|
|
59
|
+
name: name,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/** Creates a "h" tag for chat messages from a {@link GroupPointer} */
|
|
63
|
+
export function createGroupHTagFromGroupPointer(group) {
|
|
64
|
+
return fillAndTrimTag(["h", group.id, ensureWebSocketURL(group.relay)]);
|
|
65
|
+
}
|
|
66
|
+
/** Creates a "group" tag from a {@link GroupPointer} */
|
|
67
|
+
export function createGroupTagFromGroupPointer(group) {
|
|
68
|
+
return fillAndTrimTag(["group", group.id, ensureWebSocketURL(group.relay), group.name], 3);
|
|
69
|
+
}
|
package/dist/operations/group.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ensureNamedValueTag } from "applesauce-core/helpers";
|
|
2
2
|
import { includeSingletonTag, modifyPublicTags } from "applesauce-core/operations/tags";
|
|
3
|
-
import { createGroupHTagFromGroupPointer, createGroupTagFromGroupPointer } from "../helpers/groups
|
|
3
|
+
import { createGroupHTagFromGroupPointer, createGroupTagFromGroupPointer } from "../helpers/groups.js";
|
|
4
4
|
/** Adds a "group" tag to a list */
|
|
5
5
|
export function addGroupTag(group) {
|
|
6
6
|
return modifyPublicTags((tags) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "applesauce-common",
|
|
3
|
-
"version": "0.0.0-next-
|
|
3
|
+
"version": "0.0.0-next-20251205152544",
|
|
4
4
|
"description": "Common NIP-specific helpers and models for applesauce",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"@scure/base": "^1.2.4",
|
|
66
|
-
"applesauce-core": "0.0.0-next-
|
|
66
|
+
"applesauce-core": "0.0.0-next-20251205152544",
|
|
67
67
|
"hash-sum": "^2.0.0",
|
|
68
68
|
"light-bolt11-decoder": "^3.2.0",
|
|
69
69
|
"rxjs": "^7.8.1"
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { NameValueTag } from "applesauce-core/helpers";
|
|
2
|
-
import { GroupPointer } from "./groups.js";
|
|
3
|
-
/** Creates a "h" tag for chat messages from a {@link GroupPointer} */
|
|
4
|
-
export declare function createGroupHTagFromGroupPointer(group: GroupPointer): NameValueTag;
|
|
5
|
-
/** Creates a "group" tag from a {@link GroupPointer} */
|
|
6
|
-
export declare function createGroupTagFromGroupPointer(group: GroupPointer): NameValueTag;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ensureWebSocketURL, fillAndTrimTag } from "applesauce-core/helpers";
|
|
2
|
-
/** Creates a "h" tag for chat messages from a {@link GroupPointer} */
|
|
3
|
-
export function createGroupHTagFromGroupPointer(group) {
|
|
4
|
-
return fillAndTrimTag(["h", group.id, ensureWebSocketURL(group.relay)]);
|
|
5
|
-
}
|
|
6
|
-
/** Creates a "group" tag from a {@link GroupPointer} */
|
|
7
|
-
export function createGroupTagFromGroupPointer(group) {
|
|
8
|
-
return fillAndTrimTag(["group", group.id, ensureWebSocketURL(group.relay), group.name], 3);
|
|
9
|
-
}
|