applesauce-actions 0.0.0-next-20250312111321 → 0.0.0-next-20250312113207
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/actions/index.d.ts
CHANGED
package/dist/actions/index.js
CHANGED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ProfileContent } from "applesauce-core/helpers";
|
|
2
|
+
import { Action } from "../action-hub.js";
|
|
3
|
+
/** An action that creates a new kind 0 profile event for a user */
|
|
4
|
+
export declare function CreateProfile(content: ProfileContent): Action;
|
|
5
|
+
/** An action that updates a kind 0 profile evnet for a user */
|
|
6
|
+
export declare function UpdateProfile(content: Partial<ProfileContent>): Action;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { kinds } from "nostr-tools";
|
|
2
|
+
import { setProfileContent, updateProfileContent } from "applesauce-factory/operations/event";
|
|
3
|
+
/** An action that creates a new kind 0 profile event for a user */
|
|
4
|
+
export function CreateProfile(content) {
|
|
5
|
+
return async ({ events, factory, self, publish }) => {
|
|
6
|
+
const metadata = events.getReplaceable(kinds.Metadata, self);
|
|
7
|
+
if (metadata)
|
|
8
|
+
throw new Error("Profile already exists");
|
|
9
|
+
const draft = await factory.process({ kind: kinds.Metadata }, setProfileContent(content));
|
|
10
|
+
await publish("Create profile", await factory.sign(draft));
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
/** An action that updates a kind 0 profile evnet for a user */
|
|
14
|
+
export function UpdateProfile(content) {
|
|
15
|
+
return async ({ events, factory, self, publish }) => {
|
|
16
|
+
const metadata = events.getReplaceable(kinds.Metadata, self);
|
|
17
|
+
if (!metadata)
|
|
18
|
+
throw new Error("Profile does not exists");
|
|
19
|
+
const draft = await factory.modify(metadata, updateProfileContent(content));
|
|
20
|
+
await publish("Update profile", await factory.sign(draft));
|
|
21
|
+
};
|
|
22
|
+
}
|
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-20250312113207",
|
|
4
4
|
"description": "A package for performing common nostr actions",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -32,13 +32,13 @@
|
|
|
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-20250312113207",
|
|
36
|
+
"applesauce-factory": "0.0.0-next-20250312113207",
|
|
37
37
|
"nostr-tools": "^2.10.4"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/debug": "^4.1.12",
|
|
41
|
-
"applesauce-signers": "0.0.0-next-
|
|
41
|
+
"applesauce-signers": "0.0.0-next-20250312113207",
|
|
42
42
|
"nanoid": "^5.0.9",
|
|
43
43
|
"typescript": "^5.7.3",
|
|
44
44
|
"vitest": "^3.0.5"
|