pubky-app-specs 0.4.0 → 0.4.1

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/example.js CHANGED
@@ -1,4 +1,18 @@
1
- import { PubkyAppPostKind, PubkySpecsBuilder, PubkyAppPostEmbed } from "./index.js";
1
+ import {
2
+ PubkyAppPostKind,
3
+ PubkySpecsBuilder,
4
+ PubkyAppPostEmbed,
5
+ userUriBuilder,
6
+ postUriBuilder,
7
+ bookmarkUriBuilder,
8
+ followUriBuilder,
9
+ tagUriBuilder,
10
+ muteUriBuilder,
11
+ lastReadUriBuilder,
12
+ blobUriBuilder,
13
+ fileUriBuilder,
14
+ feedUriBuilder,
15
+ } from "./index.js";
2
16
 
3
17
  const OTTO = "8kkppkmiubfq4pxn6f73nqrhhhgkb5xyfprntc9si3np9ydbotto";
4
18
  const RIO = "dzswkfy7ek3bqnoc89jxuqqfbzhjrj6mi8qthgbxxcqkdugm3rio";
@@ -6,88 +20,146 @@ const RIO = "dzswkfy7ek3bqnoc89jxuqqfbzhjrj6mi8qthgbxxcqkdugm3rio";
6
20
  // 👤 Create a user profile
7
21
  console.log("👤 Creating User Profile...");
8
22
  const specsBuilder = new PubkySpecsBuilder(OTTO);
9
- const { user, meta: userMeta } =
10
- specsBuilder.createUser("Alice Smith", "Software Developer", null, null, "active");
23
+ const { user, meta: userMeta } = specsBuilder.createUser(
24
+ "Alice Smith",
25
+ "Software Developer",
26
+ null,
27
+ null,
28
+ "active"
29
+ );
11
30
  console.log("User Profile URL:", userMeta.url);
12
31
  console.log("User Data:", JSON.stringify(user.toJson(), null, 2));
13
32
  console.log("-".repeat(60));
14
33
 
15
34
  // 📝 Create different posts
16
35
  console.log("📝 Creating First Post...");
17
- const { post, meta } = specsBuilder.createPost("Hello, Pubky world! This is my first post.", PubkyAppPostKind.Short, null, null, null);
36
+ const { post, meta } = specsBuilder.createPost(
37
+ "Hello, Pubky world! This is my first post.",
38
+ PubkyAppPostKind.Short,
39
+ null,
40
+ null,
41
+ null
42
+ );
18
43
  console.log("Post ID:", meta.id);
19
44
  console.log("Post URL:", meta.url);
20
45
  console.log("Post Data:", JSON.stringify(post.toJson(), null, 2));
21
46
  console.log("-".repeat(60));
22
47
 
23
48
  console.log("💬 Creating Reply Post...");
24
- const { post: replyPost, meta: replyMeta } = specsBuilder.createPost("This is a reply to the first post!", PubkyAppPostKind.Short, userMeta.url, null, null);
49
+ const { post: replyPost, meta: replyMeta } = specsBuilder.createPost(
50
+ "This is a reply to the first post!",
51
+ PubkyAppPostKind.Short,
52
+ userMeta.url,
53
+ null,
54
+ null
55
+ );
25
56
  console.log("Reply Post ID:", replyMeta.id);
26
57
  console.log("Reply Post URL:", replyMeta.url);
27
58
  console.log("Reply Data:", JSON.stringify(replyPost.toJson(), null, 2));
28
59
  console.log("-".repeat(60));
29
60
 
30
61
  console.log("🔄 Creating Repost with Embed...");
31
- let embeed = new PubkyAppPostEmbed(`pubky://${RIO}/pub/pubky.app/posts/0033SREKPC4N0`, PubkyAppPostKind.Video);
32
- const { post: repost, meta: repostMeta } = specsBuilder.createPost("This is a repost to random post!", PubkyAppPostKind.Short, null, embeed, null);
62
+ let embeed = new PubkyAppPostEmbed(
63
+ `pubky://${RIO}/pub/pubky.app/posts/0033SREKPC4N0`,
64
+ PubkyAppPostKind.Video
65
+ );
66
+ const { post: repost, meta: repostMeta } = specsBuilder.createPost(
67
+ "This is a repost to random post!",
68
+ PubkyAppPostKind.Short,
69
+ null,
70
+ embeed,
71
+ null
72
+ );
33
73
  console.log("Repost Post ID:", repostMeta.id);
34
74
  console.log("Repost Post URL:", repostMeta.url);
35
75
  console.log("Repost Data:", JSON.stringify(repost.toJson(), null, 2));
36
76
  console.log("-".repeat(60));
37
77
 
38
78
  console.log("🔖 Creating Bookmark...");
39
- let { bookmark, meta: bookmarkMeta } = specsBuilder.createBookmark(`pubky://${RIO}/pub/pubky.app/posts/0033SREKPC4N0`);
79
+ let { bookmark, meta: bookmarkMeta } = specsBuilder.createBookmark(
80
+ `pubky://${RIO}/pub/pubky.app/posts/0033SREKPC4N0`
81
+ );
40
82
  console.log("Bookmark ID:", bookmarkMeta.id);
41
83
  console.log("Bookmark URL:", bookmarkMeta.url);
42
84
  console.log("Bookmark Data:", JSON.stringify(bookmark.toJson(), null, 2));
43
85
  console.log("-".repeat(60));
44
86
 
45
87
  console.log("👥 Creating Follow...");
46
- let {follow, meta: followMeta} = specsBuilder.createFollow(RIO);
88
+ let { follow, meta: followMeta } = specsBuilder.createFollow(RIO);
47
89
  console.log("Follow ID:", followMeta.id);
48
90
  console.log("Follow URL:", followMeta.url);
49
91
  console.log("Follow Data:", JSON.stringify(follow.toJson(), null, 2));
50
92
  console.log("-".repeat(60));
51
93
 
52
94
  console.log("🏷️ Creating Tag...");
53
- let {tag, meta: tagMeta} = specsBuilder.createTag(`pubky://${OTTO}/pub/pubky.app/profile.json`, "otto");
95
+ let { tag, meta: tagMeta } = specsBuilder.createTag(
96
+ `pubky://${OTTO}/pub/pubky.app/profile.json`,
97
+ "otto"
98
+ );
54
99
  console.log("Tag ID:", tagMeta.id);
55
100
  console.log("Tag URL:", tagMeta.url);
56
101
  console.log("Tag Data:", JSON.stringify(tag.toJson(), null, 2));
57
102
  console.log("-".repeat(60));
58
103
 
59
104
  console.log("🔇 Creating Mute...");
60
- let {mute, meta: muteMeta} = specsBuilder.createMute(RIO);
105
+ let { mute, meta: muteMeta } = specsBuilder.createMute(RIO);
61
106
  console.log("Mute ID:", muteMeta.id);
62
107
  console.log("Mute URL:", muteMeta.url);
63
108
  console.log("Mute Data:", JSON.stringify(mute.toJson(), null, 2));
64
109
  console.log("-".repeat(60));
65
110
 
66
111
  console.log("📖 Creating Last Read...");
67
- let {last_read, meta: lastReadMeta} = specsBuilder.createLastRead(RIO);
112
+ let { last_read, meta: lastReadMeta } = specsBuilder.createLastRead(RIO);
68
113
  console.log("LastRead Timestamp:", lastReadMeta.url);
69
114
  console.log("LastRead Data:", JSON.stringify(last_read.toJson(), null, 2));
70
115
  console.log("-".repeat(60));
71
116
 
72
117
  console.log("💾 Creating Blob...");
73
- let { blob, meta: blobMeta } = specsBuilder.createBlob(Array.from({length: 8}, () => Math.floor(Math.random() * 256)));
118
+ let { blob, meta: blobMeta } = specsBuilder.createBlob(
119
+ Array.from({ length: 8 }, () => Math.floor(Math.random() * 256))
120
+ );
74
121
  console.log("Blob ID:", blobMeta.id);
75
122
  console.log("Blob URL:", blobMeta.url);
76
123
  console.log("Blob Data:", JSON.stringify(blob.toJson(), null, 2));
77
124
  console.log("-".repeat(60));
78
125
 
79
126
  console.log("📄 Creating File...");
80
- let { file, meta: fileMeta } = specsBuilder.createFile("My adventures", blobMeta.url, "application/pdf", 88);
127
+ let { file, meta: fileMeta } = specsBuilder.createFile(
128
+ "My adventures",
129
+ blobMeta.url,
130
+ "application/pdf",
131
+ 88
132
+ );
81
133
  console.log("File ID:", fileMeta.id);
82
134
  console.log("File URL:", fileMeta.url);
83
135
  console.log("File Data:", JSON.stringify(file.toJson(), null, 2));
84
136
  console.log("-".repeat(60));
85
137
 
86
138
  console.log("📰 Creating Feed...");
87
- let { feed, meta: feedMeta } = specsBuilder.createFeed(["mountain","hike"], "all", "columns", "recent", "image", "nature");
139
+ let { feed, meta: feedMeta } = specsBuilder.createFeed(
140
+ ["mountain", "hike"],
141
+ "all",
142
+ "columns",
143
+ "recent",
144
+ "image",
145
+ "nature"
146
+ );
88
147
  console.log("Feed ID:", feedMeta.id);
89
148
  console.log("Feed URL:", feedMeta.url);
90
149
  console.log("Feed Data:", JSON.stringify(feed.toJson(), null, 2));
150
+ console.log("-".repeat(60));
151
+
152
+ console.log("🔗 Utility Functions...");
153
+ console.log("User URI:", userUriBuilder(OTTO));
154
+ console.log("Post URI:", postUriBuilder(OTTO, meta.id));
155
+ console.log("Bookmark URI:", bookmarkUriBuilder(OTTO, bookmarkMeta.id));
156
+ console.log("Follow URI:", followUriBuilder(OTTO, RIO));
157
+ console.log("Tag URI:", tagUriBuilder(OTTO, tagMeta.id));
158
+ console.log("Mute URI:", muteUriBuilder(OTTO, RIO));
159
+ console.log("LastRead URI:", lastReadUriBuilder(OTTO));
160
+ console.log("Blob URI:", blobUriBuilder(OTTO, blobMeta.id));
161
+ console.log("File URI:", fileUriBuilder(OTTO, fileMeta.id));
162
+
91
163
  console.log("=".repeat(60));
92
164
  console.log("🎉 All Pubky App Specs examples completed successfully!");
93
165
  console.log("=".repeat(60));