applesauce-extra 0.0.0-next-20251009095925 → 0.0.0-next-20251012142625
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/primal.d.ts +184 -324
- package/dist/primal.js +50 -42
- package/dist/vertex.d.ts +3 -1
- package/dist/vertex.js +14 -4
- package/package.json +3 -3
package/dist/primal.d.ts
CHANGED
|
@@ -1,330 +1,187 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type NostrEvent } from "applesauce-core/helpers";
|
|
2
2
|
import { Relay, type RelayOptions } from "applesauce-relay";
|
|
3
3
|
import { Observable } from "rxjs";
|
|
4
4
|
export declare const DEFAULT_PRIMAL_RELAY = "wss://cache2.primal.net/v1";
|
|
5
|
-
|
|
6
|
-
req: [
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
export type
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
export type
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
export type
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
event: NostrEvent;
|
|
162
|
-
}
|
|
163
|
-
export type
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
pubkey: string;
|
|
186
|
-
}];
|
|
187
|
-
event: NostrEvent;
|
|
188
|
-
};
|
|
189
|
-
export type UserSearch = {
|
|
190
|
-
req: ["user_search", {
|
|
191
|
-
query: string;
|
|
192
|
-
limit?: number;
|
|
193
|
-
}];
|
|
194
|
-
event: NostrEvent;
|
|
195
|
-
};
|
|
196
|
-
export type FeedDirective = {
|
|
197
|
-
req: [
|
|
198
|
-
"feed_directive",
|
|
199
|
-
{
|
|
200
|
-
pubkey: string;
|
|
201
|
-
feed_type: string;
|
|
202
|
-
limit?: number;
|
|
203
|
-
since?: number;
|
|
204
|
-
until?: number;
|
|
205
|
-
offset?: number;
|
|
206
|
-
}
|
|
207
|
-
];
|
|
208
|
-
event: NostrEvent;
|
|
209
|
-
};
|
|
210
|
-
export type FeedDirective2 = {
|
|
211
|
-
req: [
|
|
212
|
-
"feed_directive_2",
|
|
213
|
-
{
|
|
214
|
-
pubkey: string;
|
|
215
|
-
feed_type: string;
|
|
216
|
-
limit?: number;
|
|
217
|
-
since?: number;
|
|
218
|
-
until?: number;
|
|
219
|
-
offset?: number;
|
|
220
|
-
}
|
|
221
|
-
];
|
|
222
|
-
event: NostrEvent;
|
|
223
|
-
};
|
|
224
|
-
export type GetAdvancedFeeds = {
|
|
225
|
-
req: ["get_advanced_feeds", {}];
|
|
226
|
-
event: NostrEvent;
|
|
227
|
-
};
|
|
228
|
-
export type TrendingHashtags = {
|
|
229
|
-
req: ["trending_hashtags", {
|
|
230
|
-
limit?: number;
|
|
231
|
-
}];
|
|
232
|
-
event: NostrEvent;
|
|
233
|
-
};
|
|
234
|
-
export type TrendingHashtags4h = {
|
|
235
|
-
req: ["trending_hashtags_4h", {
|
|
236
|
-
limit?: number;
|
|
237
|
-
}];
|
|
238
|
-
event: NostrEvent;
|
|
239
|
-
};
|
|
240
|
-
export type TrendingHashtags7d = {
|
|
241
|
-
req: ["trending_hashtags_7d", {
|
|
242
|
-
limit?: number;
|
|
243
|
-
}];
|
|
244
|
-
event: NostrEvent;
|
|
245
|
-
};
|
|
246
|
-
export type TrendingImages = {
|
|
247
|
-
req: ["trending_images", {
|
|
248
|
-
limit?: number;
|
|
249
|
-
}];
|
|
250
|
-
event: NostrEvent;
|
|
251
|
-
};
|
|
252
|
-
export type TrendingImages4h = {
|
|
253
|
-
req: ["trending_images_4h", {
|
|
254
|
-
limit?: number;
|
|
255
|
-
}];
|
|
256
|
-
event: NostrEvent;
|
|
257
|
-
};
|
|
258
|
-
export type ReportUser = {
|
|
259
|
-
req: ["report_user", {
|
|
260
|
-
pubkey: string;
|
|
261
|
-
reason: string;
|
|
262
|
-
}];
|
|
263
|
-
event: NostrEvent;
|
|
264
|
-
};
|
|
265
|
-
export type ReportNote = {
|
|
266
|
-
req: ["report_note", {
|
|
267
|
-
event_id: string;
|
|
268
|
-
reason: string;
|
|
269
|
-
}];
|
|
270
|
-
event: NostrEvent;
|
|
271
|
-
};
|
|
272
|
-
export type GetFilterlist = {
|
|
273
|
-
req: ["get_filterlist", {}];
|
|
274
|
-
event: NostrEvent;
|
|
275
|
-
};
|
|
276
|
-
export type CheckFilterlist = {
|
|
277
|
-
req: ["check_filterlist", {
|
|
278
|
-
pubkeys: string[];
|
|
279
|
-
}];
|
|
280
|
-
event: NostrEvent;
|
|
281
|
-
};
|
|
282
|
-
export type BroadcastReply = {
|
|
283
|
-
req: ["broadcast_reply", {
|
|
284
|
-
event: NostrEvent;
|
|
285
|
-
}];
|
|
286
|
-
event: NostrEvent;
|
|
287
|
-
};
|
|
288
|
-
export type BroadcastEvents = {
|
|
289
|
-
req: ["broadcast_events", {
|
|
290
|
-
events: NostrEvent[];
|
|
291
|
-
relays: string[];
|
|
292
|
-
}];
|
|
293
|
-
event: NostrEvent;
|
|
294
|
-
};
|
|
295
|
-
export type TrustedUsers = {
|
|
296
|
-
req: ["trusted_users", {
|
|
297
|
-
limit?: number;
|
|
298
|
-
extended_response?: boolean;
|
|
299
|
-
}];
|
|
300
|
-
event: NostrEvent;
|
|
301
|
-
};
|
|
302
|
-
export type NoteMentions = {
|
|
303
|
-
req: [
|
|
304
|
-
"note_mentions",
|
|
305
|
-
{
|
|
306
|
-
event_id?: string;
|
|
307
|
-
pubkey?: string;
|
|
308
|
-
identifier?: string;
|
|
309
|
-
limit?: number;
|
|
310
|
-
offset?: number;
|
|
311
|
-
user_pubkey?: string;
|
|
312
|
-
}
|
|
313
|
-
];
|
|
314
|
-
event: NostrEvent;
|
|
315
|
-
};
|
|
316
|
-
export type NoteMentionsCount = {
|
|
317
|
-
req: ["note_mentions_count", {
|
|
318
|
-
event_id: string;
|
|
319
|
-
}];
|
|
320
|
-
event: NostrEvent;
|
|
321
|
-
};
|
|
322
|
-
export type GetMediaMetadata = {
|
|
323
|
-
req: ["get_media_metadata", {
|
|
324
|
-
urls: string[];
|
|
325
|
-
}];
|
|
326
|
-
event: NostrEvent;
|
|
327
|
-
};
|
|
5
|
+
type RequestAndResponse<M extends string, Args extends {}, Return> = {
|
|
6
|
+
req: [M, Args];
|
|
7
|
+
event: Return;
|
|
8
|
+
};
|
|
9
|
+
export type ExploreLegendCounts = RequestAndResponse<"explore_legend_counts", {
|
|
10
|
+
pubkey: string;
|
|
11
|
+
}, NostrEvent>;
|
|
12
|
+
export type Explore = RequestAndResponse<"explore", {
|
|
13
|
+
timeframe: "popular" | "trending" | "recent";
|
|
14
|
+
pubkeys?: string[];
|
|
15
|
+
limit?: number;
|
|
16
|
+
created_after?: number;
|
|
17
|
+
since?: number;
|
|
18
|
+
until?: number;
|
|
19
|
+
offset?: number;
|
|
20
|
+
group_by_pubkey?: boolean;
|
|
21
|
+
user_pubkey?: string;
|
|
22
|
+
include_top_zaps?: boolean;
|
|
23
|
+
apply_humaness_check?: boolean;
|
|
24
|
+
gm_mode?: boolean;
|
|
25
|
+
}, NostrEvent>;
|
|
26
|
+
export type ExploreGlobalTrending24h = RequestAndResponse<"explore_global_trending_24h", {
|
|
27
|
+
limit?: number;
|
|
28
|
+
}, NostrEvent>;
|
|
29
|
+
export type ExploreGlobalMostZapped4h = RequestAndResponse<"explore_global_mostzapped_4h", {
|
|
30
|
+
limit?: number;
|
|
31
|
+
}, NostrEvent>;
|
|
32
|
+
export type Scored = RequestAndResponse<"scored", {
|
|
33
|
+
timeframe: "popular" | "trending" | "recent";
|
|
34
|
+
pubkeys?: string[];
|
|
35
|
+
limit?: number;
|
|
36
|
+
created_after?: number;
|
|
37
|
+
since?: number;
|
|
38
|
+
until?: number;
|
|
39
|
+
offset?: number;
|
|
40
|
+
group_by_pubkey?: boolean;
|
|
41
|
+
user_pubkey?: string;
|
|
42
|
+
include_top_zaps?: boolean;
|
|
43
|
+
apply_humaness_check?: boolean;
|
|
44
|
+
gm_mode?: boolean;
|
|
45
|
+
}, NostrEvent>;
|
|
46
|
+
export type ScoredUsers = RequestAndResponse<"scored_users", {
|
|
47
|
+
limit?: number;
|
|
48
|
+
}, NostrEvent>;
|
|
49
|
+
export type ScoredUsers24h = RequestAndResponse<"scored_users_24h", {
|
|
50
|
+
limit?: number;
|
|
51
|
+
}, NostrEvent>;
|
|
52
|
+
export type GetDefaultRelays = RequestAndResponse<"get_default_relays", {}, NostrEvent>;
|
|
53
|
+
export type GetRecommendedUsers = RequestAndResponse<"get_recommended_users", {
|
|
54
|
+
limit?: number;
|
|
55
|
+
}, NostrEvent>;
|
|
56
|
+
export type GetSuggestedUsers = RequestAndResponse<"get_suggested_users", {
|
|
57
|
+
limit?: number;
|
|
58
|
+
}, NostrEvent>;
|
|
59
|
+
export type UserProfileScoredContent = RequestAndResponse<"user_profile_scored_content", {
|
|
60
|
+
pubkey: string;
|
|
61
|
+
limit?: number;
|
|
62
|
+
created_after?: number;
|
|
63
|
+
since?: number;
|
|
64
|
+
until?: number;
|
|
65
|
+
offset?: number;
|
|
66
|
+
}, NostrEvent>;
|
|
67
|
+
export type UserProfileScoredMediaThumbnails = RequestAndResponse<"user_profile_scored_media_thumbnails", {
|
|
68
|
+
pubkey: string;
|
|
69
|
+
limit?: number;
|
|
70
|
+
created_after?: number;
|
|
71
|
+
since?: number;
|
|
72
|
+
until?: number;
|
|
73
|
+
offset?: number;
|
|
74
|
+
}, NostrEvent>;
|
|
75
|
+
export type Search = RequestAndResponse<"search", {
|
|
76
|
+
query: string;
|
|
77
|
+
limit?: number;
|
|
78
|
+
since?: number;
|
|
79
|
+
until?: number;
|
|
80
|
+
offset?: number;
|
|
81
|
+
}, NostrEvent>;
|
|
82
|
+
export type AdvancedSearch = RequestAndResponse<"advanced_search", {
|
|
83
|
+
query: string;
|
|
84
|
+
limit?: number;
|
|
85
|
+
since?: number;
|
|
86
|
+
until?: number;
|
|
87
|
+
offset?: number;
|
|
88
|
+
sort?: "latest" | "popular" | "trending";
|
|
89
|
+
}, NostrEvent>;
|
|
90
|
+
export type AdvancedFeed = RequestAndResponse<"advanced_feed", {
|
|
91
|
+
feed_type: string;
|
|
92
|
+
limit?: number;
|
|
93
|
+
since?: number;
|
|
94
|
+
until?: number;
|
|
95
|
+
offset?: number;
|
|
96
|
+
}, NostrEvent>;
|
|
97
|
+
export type Relays = RequestAndResponse<"relays", {}, NostrEvent>;
|
|
98
|
+
export type GetNotifications = RequestAndResponse<"get_notifications", {
|
|
99
|
+
pubkey: string;
|
|
100
|
+
limit?: number;
|
|
101
|
+
since?: number;
|
|
102
|
+
until?: number;
|
|
103
|
+
offset?: number;
|
|
104
|
+
}, NostrEvent>;
|
|
105
|
+
export type SetNotificationsSeen = RequestAndResponse<"set_notifications_seen", {
|
|
106
|
+
pubkey: string;
|
|
107
|
+
until: number;
|
|
108
|
+
}, NostrEvent>;
|
|
109
|
+
export type GetNotificationsSeen = RequestAndResponse<"get_notifications_seen", {
|
|
110
|
+
pubkey: string;
|
|
111
|
+
}, NostrEvent>;
|
|
112
|
+
export type UserSearch = RequestAndResponse<"user_search", {
|
|
113
|
+
query: string;
|
|
114
|
+
limit?: number;
|
|
115
|
+
}, NostrEvent>;
|
|
116
|
+
export type FeedDirective = RequestAndResponse<"feed_directive", {
|
|
117
|
+
pubkey: string;
|
|
118
|
+
feed_type: string;
|
|
119
|
+
limit?: number;
|
|
120
|
+
since?: number;
|
|
121
|
+
until?: number;
|
|
122
|
+
offset?: number;
|
|
123
|
+
}, NostrEvent>;
|
|
124
|
+
export type FeedDirective2 = RequestAndResponse<"feed_directive_2", {
|
|
125
|
+
pubkey: string;
|
|
126
|
+
feed_type: string;
|
|
127
|
+
limit?: number;
|
|
128
|
+
since?: number;
|
|
129
|
+
until?: number;
|
|
130
|
+
offset?: number;
|
|
131
|
+
}, NostrEvent>;
|
|
132
|
+
export type GetAdvancedFeeds = RequestAndResponse<"get_advanced_feeds", {}, NostrEvent>;
|
|
133
|
+
export type TrendingHashtags = RequestAndResponse<"trending_hashtags", {
|
|
134
|
+
limit?: number;
|
|
135
|
+
}, NostrEvent>;
|
|
136
|
+
export type TrendingHashtags4h = RequestAndResponse<"trending_hashtags_4h", {
|
|
137
|
+
limit?: number;
|
|
138
|
+
}, NostrEvent>;
|
|
139
|
+
export type TrendingHashtags7d = RequestAndResponse<"trending_hashtags_7d", {
|
|
140
|
+
limit?: number;
|
|
141
|
+
}, NostrEvent>;
|
|
142
|
+
export type TrendingImages = RequestAndResponse<"trending_images", {
|
|
143
|
+
limit?: number;
|
|
144
|
+
}, NostrEvent>;
|
|
145
|
+
export type TrendingImages4h = RequestAndResponse<"trending_images_4h", {
|
|
146
|
+
limit?: number;
|
|
147
|
+
}, NostrEvent>;
|
|
148
|
+
export type ReportUser = RequestAndResponse<"report_user", {
|
|
149
|
+
pubkey: string;
|
|
150
|
+
reason: string;
|
|
151
|
+
}, NostrEvent>;
|
|
152
|
+
export type ReportNote = RequestAndResponse<"report_note", {
|
|
153
|
+
event_id: string;
|
|
154
|
+
reason: string;
|
|
155
|
+
}, NostrEvent>;
|
|
156
|
+
export type GetFilterlist = RequestAndResponse<"get_filterlist", {}, NostrEvent>;
|
|
157
|
+
export type CheckFilterlist = RequestAndResponse<"check_filterlist", {
|
|
158
|
+
pubkeys: string[];
|
|
159
|
+
}, NostrEvent>;
|
|
160
|
+
export type BroadcastReply = RequestAndResponse<"broadcast_reply", {
|
|
161
|
+
event: NostrEvent;
|
|
162
|
+
}, NostrEvent>;
|
|
163
|
+
export type BroadcastEvents = RequestAndResponse<"broadcast_events", {
|
|
164
|
+
events: NostrEvent[];
|
|
165
|
+
relays: string[];
|
|
166
|
+
}, NostrEvent>;
|
|
167
|
+
export type TrustedUsers = RequestAndResponse<"trusted_users", {
|
|
168
|
+
limit?: number;
|
|
169
|
+
extended_response?: boolean;
|
|
170
|
+
}, NostrEvent>;
|
|
171
|
+
export type NoteMentions = RequestAndResponse<"note_mentions", {
|
|
172
|
+
event_id?: string;
|
|
173
|
+
pubkey?: string;
|
|
174
|
+
identifier?: string;
|
|
175
|
+
limit?: number;
|
|
176
|
+
offset?: number;
|
|
177
|
+
user_pubkey?: string;
|
|
178
|
+
}, NostrEvent>;
|
|
179
|
+
export type NoteMentionsCount = RequestAndResponse<"note_mentions_count", {
|
|
180
|
+
event_id: string;
|
|
181
|
+
}, NostrEvent>;
|
|
182
|
+
export type GetMediaMetadata = RequestAndResponse<"get_media_metadata", {
|
|
183
|
+
urls: string[];
|
|
184
|
+
}, NostrEvent>;
|
|
328
185
|
export type CacheRequest = ExploreLegendCounts | Explore | ExploreGlobalTrending24h | ExploreGlobalMostZapped4h | Scored | ScoredUsers | ScoredUsers24h | GetDefaultRelays | GetRecommendedUsers | GetSuggestedUsers | UserProfileScoredContent | UserProfileScoredMediaThumbnails | Search | AdvancedSearch | AdvancedFeed | Relays | GetNotifications | SetNotificationsSeen | GetNotificationsSeen | UserSearch | FeedDirective | FeedDirective2 | GetAdvancedFeeds | TrendingHashtags | TrendingHashtags4h | TrendingHashtags7d | TrendingImages | TrendingImages4h | ReportUser | ReportNote | GetFilterlist | CheckFilterlist | BroadcastReply | BroadcastEvents | TrustedUsers | NoteMentions | NoteMentionsCount | GetMediaMetadata;
|
|
329
186
|
/**
|
|
330
187
|
* Extended relay interface for primal caching server
|
|
@@ -334,6 +191,8 @@ export declare class PrimalCache extends Relay {
|
|
|
334
191
|
constructor(url?: string, opts?: RelayOptions);
|
|
335
192
|
/** Make a "cache" request to the caching server */
|
|
336
193
|
cacheRequest<R extends CacheRequest>(request: CacheRequest["req"]): Observable<R["event"]>;
|
|
194
|
+
/** Makes a cache request and returns a timeline of events */
|
|
195
|
+
protected timelineRequest<R extends RequestAndResponse<any, any, any>>(method: R["req"][0], args: R["req"][1]): Promise<R["event"][]>;
|
|
337
196
|
/** Get legend counts for explore page */
|
|
338
197
|
exploreLegendCounts(pubkey: string): Promise<ExploreLegendCounts["event"][]>;
|
|
339
198
|
/** Explore content with various filters */
|
|
@@ -411,3 +270,4 @@ export declare class PrimalCache extends Relay {
|
|
|
411
270
|
/** Get media metadata */
|
|
412
271
|
getMediaMetadata(urls: string[]): Promise<GetMediaMetadata["event"][]>;
|
|
413
272
|
}
|
|
273
|
+
export {};
|
package/dist/primal.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { mapEventsToTimeline } from "applesauce-core";
|
|
2
|
+
import { isEvent } from "applesauce-core/helpers";
|
|
2
3
|
import { completeOnEose, Relay } from "applesauce-relay";
|
|
3
|
-
import { lastValueFrom } from "rxjs";
|
|
4
|
+
import { filter, lastValueFrom } from "rxjs";
|
|
4
5
|
export const DEFAULT_PRIMAL_RELAY = "wss://cache2.primal.net/v1";
|
|
5
6
|
/**
|
|
6
7
|
* Extended relay interface for primal caching server
|
|
@@ -17,174 +18,181 @@ export class PrimalCache extends Relay {
|
|
|
17
18
|
cache: request,
|
|
18
19
|
}).pipe(completeOnEose());
|
|
19
20
|
}
|
|
21
|
+
/** Makes a cache request and returns a timeline of events */
|
|
22
|
+
timelineRequest(method, args) {
|
|
23
|
+
return lastValueFrom(this.cacheRequest([method, args]).pipe(mapEventsToTimeline()));
|
|
24
|
+
}
|
|
20
25
|
// ===== EXPLORE METHODS =====
|
|
21
26
|
/** Get legend counts for explore page */
|
|
22
27
|
exploreLegendCounts(pubkey) {
|
|
23
|
-
return
|
|
28
|
+
return this.timelineRequest("explore_legend_counts", { pubkey });
|
|
24
29
|
}
|
|
25
30
|
/** Explore content with various filters */
|
|
26
31
|
explore(params) {
|
|
27
|
-
return
|
|
32
|
+
return this.timelineRequest("explore", params);
|
|
28
33
|
}
|
|
29
34
|
/** Get global trending content from last 24 hours */
|
|
30
35
|
exploreGlobalTrending24h(limit = 20) {
|
|
31
|
-
return
|
|
36
|
+
return this.timelineRequest("explore_global_trending_24h", { limit });
|
|
32
37
|
}
|
|
33
38
|
/** Get global most zapped content from last 4 hours */
|
|
34
39
|
exploreGlobalMostZapped4h(limit = 20) {
|
|
35
|
-
return
|
|
40
|
+
return this.timelineRequest("explore_global_mostzapped_4h", { limit });
|
|
36
41
|
}
|
|
37
42
|
// ===== SCORED CONTENT METHODS =====
|
|
38
43
|
/** Get scored content */
|
|
39
44
|
scored(params) {
|
|
40
|
-
return
|
|
45
|
+
return this.timelineRequest("scored", params);
|
|
41
46
|
}
|
|
42
47
|
/** Get scored users */
|
|
43
48
|
scoredUsers(limit = 20) {
|
|
44
|
-
return
|
|
49
|
+
return this.timelineRequest("scored_users", { limit });
|
|
45
50
|
}
|
|
46
51
|
/** Get scored users from last 24 hours */
|
|
47
52
|
scoredUsers24h(limit = 20) {
|
|
48
|
-
return
|
|
53
|
+
return this.timelineRequest("scored_users_24h", { limit });
|
|
49
54
|
}
|
|
50
55
|
// ===== RELAY METHODS =====
|
|
51
56
|
/** Get default relays */
|
|
52
57
|
getDefaultRelays() {
|
|
53
|
-
return
|
|
58
|
+
return this.timelineRequest("get_default_relays", {});
|
|
54
59
|
}
|
|
55
60
|
// ===== USER METHODS =====
|
|
56
61
|
/** Get recommended users */
|
|
57
62
|
getRecommendedUsers(limit = 20) {
|
|
58
|
-
return
|
|
63
|
+
return this.timelineRequest("get_recommended_users", { limit });
|
|
59
64
|
}
|
|
60
65
|
/** Get suggested users */
|
|
61
66
|
getSuggestedUsers(limit = 20) {
|
|
62
|
-
return
|
|
67
|
+
return this.timelineRequest("get_suggested_users", { limit });
|
|
63
68
|
}
|
|
64
69
|
/** Search for users by query */
|
|
65
70
|
userSearch(query, limit = 10) {
|
|
66
|
-
return lastValueFrom(this.cacheRequest(["user_search", { query, limit }]).pipe(
|
|
71
|
+
return lastValueFrom(this.cacheRequest(["user_search", { query, limit }]).pipe(
|
|
72
|
+
// Ignore non events
|
|
73
|
+
filter(isEvent),
|
|
74
|
+
// Only accept profile kinds
|
|
75
|
+
filter((e) => e.kind === 0),
|
|
76
|
+
// Add to timeline
|
|
77
|
+
mapEventsToTimeline()));
|
|
67
78
|
}
|
|
68
79
|
/** Get trusted users */
|
|
69
80
|
trustedUsers(limit = 500, extendedResponse = true) {
|
|
70
|
-
return
|
|
71
|
-
"trusted_users",
|
|
72
|
-
{ limit, extended_response: extendedResponse },
|
|
73
|
-
]).pipe(mapEventsToTimeline()));
|
|
81
|
+
return this.timelineRequest("trusted_users", { limit, extended_response: extendedResponse });
|
|
74
82
|
}
|
|
75
83
|
// ===== PROFILE METHODS =====
|
|
76
84
|
/** Get user profile scored content */
|
|
77
85
|
userProfileScoredContent(params) {
|
|
78
|
-
return
|
|
86
|
+
return this.timelineRequest("user_profile_scored_content", params);
|
|
79
87
|
}
|
|
80
88
|
/** Get user profile scored media thumbnails */
|
|
81
89
|
userProfileScoredMediaThumbnails(params) {
|
|
82
|
-
return
|
|
90
|
+
return this.timelineRequest("user_profile_scored_media_thumbnails", params);
|
|
83
91
|
}
|
|
84
92
|
// ===== SEARCH METHODS =====
|
|
85
93
|
/** Search content */
|
|
86
94
|
search(params) {
|
|
87
|
-
return
|
|
95
|
+
return this.timelineRequest("search", params);
|
|
88
96
|
}
|
|
89
97
|
/** Advanced search */
|
|
90
98
|
advancedSearch(params) {
|
|
91
|
-
return
|
|
99
|
+
return this.timelineRequest("advanced_search", params);
|
|
92
100
|
}
|
|
93
101
|
// ===== FEED METHODS =====
|
|
94
102
|
/** Advanced feed */
|
|
95
103
|
advancedFeed(params) {
|
|
96
|
-
return
|
|
104
|
+
return this.timelineRequest("advanced_feed", params);
|
|
97
105
|
}
|
|
98
106
|
/** Feed directive */
|
|
99
107
|
feedDirective(params) {
|
|
100
|
-
return
|
|
108
|
+
return this.timelineRequest("feed_directive", params);
|
|
101
109
|
}
|
|
102
110
|
/** Feed directive v2 */
|
|
103
111
|
feedDirective2(params) {
|
|
104
|
-
return
|
|
112
|
+
return this.timelineRequest("feed_directive_2", params);
|
|
105
113
|
}
|
|
106
114
|
/** Get advanced feeds */
|
|
107
115
|
getAdvancedFeeds() {
|
|
108
|
-
return
|
|
116
|
+
return this.timelineRequest("get_advanced_feeds", {});
|
|
109
117
|
}
|
|
110
118
|
// ===== TRENDING METHODS =====
|
|
111
119
|
/** Get trending hashtags */
|
|
112
120
|
trendingHashtags(limit = 20) {
|
|
113
|
-
return
|
|
121
|
+
return this.timelineRequest("trending_hashtags", { limit });
|
|
114
122
|
}
|
|
115
123
|
/** Get trending hashtags from last 4 hours */
|
|
116
124
|
trendingHashtags4h(limit = 20) {
|
|
117
|
-
return
|
|
125
|
+
return this.timelineRequest("trending_hashtags_4h", { limit });
|
|
118
126
|
}
|
|
119
127
|
/** Get trending hashtags from last 7 days */
|
|
120
128
|
trendingHashtags7d(limit = 20) {
|
|
121
|
-
return
|
|
129
|
+
return this.timelineRequest("trending_hashtags_7d", { limit });
|
|
122
130
|
}
|
|
123
131
|
/** Get trending images */
|
|
124
132
|
trendingImages(limit = 20) {
|
|
125
|
-
return
|
|
133
|
+
return this.timelineRequest("trending_images", { limit });
|
|
126
134
|
}
|
|
127
135
|
/** Get trending images from last 4 hours */
|
|
128
136
|
trendingImages4h(limit = 20) {
|
|
129
|
-
return
|
|
137
|
+
return this.timelineRequest("trending_images_4h", { limit });
|
|
130
138
|
}
|
|
131
139
|
// ===== NOTIFICATION METHODS =====
|
|
132
140
|
/** Get notifications */
|
|
133
141
|
getNotifications(params) {
|
|
134
|
-
return
|
|
142
|
+
return this.timelineRequest("get_notifications", params);
|
|
135
143
|
}
|
|
136
144
|
/** Set notifications as seen */
|
|
137
145
|
setNotificationsSeen(pubkey, until) {
|
|
138
|
-
return
|
|
146
|
+
return this.timelineRequest("set_notifications_seen", { pubkey, until });
|
|
139
147
|
}
|
|
140
148
|
/** Get notifications seen status */
|
|
141
149
|
getNotificationsSeen(pubkey) {
|
|
142
|
-
return
|
|
150
|
+
return this.timelineRequest("get_notifications_seen", { pubkey });
|
|
143
151
|
}
|
|
144
152
|
// ===== RELAY METHODS =====
|
|
145
153
|
/** Get relays */
|
|
146
154
|
relays() {
|
|
147
|
-
return
|
|
155
|
+
return this.timelineRequest("relays", {});
|
|
148
156
|
}
|
|
149
157
|
// ===== REPORT METHODS =====
|
|
150
158
|
/** Report user */
|
|
151
159
|
reportUser(pubkey, reason) {
|
|
152
|
-
return
|
|
160
|
+
return this.timelineRequest("report_user", { pubkey, reason });
|
|
153
161
|
}
|
|
154
162
|
/** Report note */
|
|
155
163
|
reportNote(eventId, reason) {
|
|
156
|
-
return
|
|
164
|
+
return this.timelineRequest("report_note", { event_id: eventId, reason });
|
|
157
165
|
}
|
|
158
166
|
// ===== FILTERLIST METHODS =====
|
|
159
167
|
/** Get filterlist */
|
|
160
168
|
getFilterlist() {
|
|
161
|
-
return
|
|
169
|
+
return this.timelineRequest("get_filterlist", {});
|
|
162
170
|
}
|
|
163
171
|
/** Check filterlist */
|
|
164
172
|
checkFilterlist(pubkeys) {
|
|
165
|
-
return
|
|
173
|
+
return this.timelineRequest("check_filterlist", { pubkeys });
|
|
166
174
|
}
|
|
167
175
|
// ===== BROADCAST METHODS =====
|
|
168
176
|
/** Broadcast reply */
|
|
169
177
|
broadcastReply(event) {
|
|
170
|
-
return
|
|
178
|
+
return this.timelineRequest("broadcast_reply", { event });
|
|
171
179
|
}
|
|
172
180
|
/** Broadcast events */
|
|
173
181
|
broadcastEvents(events, relays) {
|
|
174
|
-
return
|
|
182
|
+
return this.timelineRequest("broadcast_events", { events, relays });
|
|
175
183
|
}
|
|
176
184
|
// ===== MENTION METHODS =====
|
|
177
185
|
/** Get note mentions */
|
|
178
186
|
noteMentions(params) {
|
|
179
|
-
return
|
|
187
|
+
return this.timelineRequest("note_mentions", params);
|
|
180
188
|
}
|
|
181
189
|
/** Get note mentions count */
|
|
182
190
|
noteMentionsCount(eventId) {
|
|
183
|
-
return
|
|
191
|
+
return this.timelineRequest("note_mentions_count", { event_id: eventId });
|
|
184
192
|
}
|
|
185
193
|
// ===== MEDIA METHODS =====
|
|
186
194
|
/** Get media metadata */
|
|
187
195
|
getMediaMetadata(urls) {
|
|
188
|
-
return
|
|
196
|
+
return this.timelineRequest("get_media_metadata", { urls });
|
|
189
197
|
}
|
|
190
198
|
}
|
package/dist/vertex.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { LRU } from "applesauce-core/helpers";
|
|
1
2
|
import { ProfilePointer } from "applesauce-core/helpers/pointers";
|
|
2
3
|
import { Relay, type RelayOptions } from "applesauce-relay";
|
|
3
4
|
import { type ISigner } from "applesauce-signers";
|
|
@@ -25,8 +26,9 @@ export declare class Vertex extends Relay {
|
|
|
25
26
|
private signer;
|
|
26
27
|
private autoAuth;
|
|
27
28
|
constructor(signer: ISigner, relay?: string, opts?: RelayOptions);
|
|
29
|
+
protected userSearchCache: LRU<ProfilePointer[]>;
|
|
28
30
|
/** Lookup user profiles by search query */
|
|
29
|
-
|
|
31
|
+
userSearch(query: string, sortMethod?: SortMethod, limit?: number): Promise<ProfilePointer[]>;
|
|
30
32
|
/** Verify reputation of a pubkey */
|
|
31
33
|
verifyReputation(options: VerifyReputationOptions): Promise<VerifyReputationResult[]>;
|
|
32
34
|
/** Method to get credit balance on vertex */
|
package/dist/vertex.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getTagValue, hasNameValueTag, unixNow } from "applesauce-core/helpers";
|
|
1
|
+
import { getTagValue, hasNameValueTag, LRU, unixNow } from "applesauce-core/helpers";
|
|
2
2
|
import { onlyEvents, Relay } from "applesauce-relay";
|
|
3
3
|
import { combineLatest, filter, firstValueFrom, map, take } from "rxjs";
|
|
4
4
|
export const VERTEX_RELAY = "wss://relay.vertexlab.io";
|
|
@@ -12,15 +12,23 @@ export class Vertex extends Relay {
|
|
|
12
12
|
super(relay, opts);
|
|
13
13
|
this.signer = signer;
|
|
14
14
|
// Automatically authenticate to the relay when a challenge is received
|
|
15
|
+
let authenticating = false;
|
|
15
16
|
this.autoAuth = combineLatest([this.challenge$, this.authenticated$]).subscribe(([challenge, authenticated]) => {
|
|
16
|
-
if (challenge && !authenticated) {
|
|
17
|
+
if (challenge && !authenticated && !authenticating) {
|
|
17
18
|
console.info("[VERTEX] Authenticating to relay");
|
|
18
|
-
|
|
19
|
+
authenticating = true;
|
|
20
|
+
this.authenticate(this.signer).finally(() => (authenticating = false));
|
|
19
21
|
}
|
|
20
22
|
});
|
|
21
23
|
}
|
|
24
|
+
// Create a cache for user search results that expires after 1 hour
|
|
25
|
+
userSearchCache = new LRU(1000, 60 * 60 * 1000);
|
|
22
26
|
/** Lookup user profiles by search query */
|
|
23
|
-
async
|
|
27
|
+
async userSearch(query, sortMethod = "globalPagerank", limit = 10) {
|
|
28
|
+
// Check cache
|
|
29
|
+
const cached = this.userSearchCache.get([query, sortMethod, limit].join(":"));
|
|
30
|
+
if (cached)
|
|
31
|
+
return cached;
|
|
24
32
|
// Create request
|
|
25
33
|
const request = await this.signer.signEvent({
|
|
26
34
|
kind: VERTEX_SEARCH_KIND,
|
|
@@ -57,6 +65,8 @@ export class Vertex extends Relay {
|
|
|
57
65
|
pubkey,
|
|
58
66
|
relays: [VERTEX_RELAY],
|
|
59
67
|
}));
|
|
68
|
+
// Cache the results
|
|
69
|
+
this.userSearchCache.set([query, sortMethod, limit].join(":"), pointers);
|
|
60
70
|
return pointers;
|
|
61
71
|
}
|
|
62
72
|
/** Verify reputation of a pubkey */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "applesauce-extra",
|
|
3
|
-
"version": "0.0.0-next-
|
|
3
|
+
"version": "0.0.0-next-20251012142625",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"rxjs": "^7.8.2",
|
|
21
|
-
"applesauce-core": "^4.0.0",
|
|
22
21
|
"applesauce-relay": "^4.0.0",
|
|
23
|
-
"applesauce-
|
|
22
|
+
"applesauce-core": "^4.0.0",
|
|
23
|
+
"applesauce-signers": "^0.0.0-next-20251012142625"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@hirez_io/observer-spy": "^2.2.0",
|