applesauce-extra 0.0.0-next-20251009104432 → 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 CHANGED
@@ -1,330 +1,187 @@
1
- import type { NostrEvent } from "applesauce-core/helpers";
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
- export type ExploreLegendCounts = {
6
- req: ["explore_legend_counts", {
7
- pubkey: string;
8
- }];
9
- event: NostrEvent;
10
- };
11
- export type Explore = {
12
- req: [
13
- "explore",
14
- {
15
- timeframe: "popular" | "trending" | "recent";
16
- pubkeys?: string[];
17
- limit?: number;
18
- created_after?: number;
19
- since?: number;
20
- until?: number;
21
- offset?: number;
22
- group_by_pubkey?: boolean;
23
- user_pubkey?: string;
24
- include_top_zaps?: boolean;
25
- apply_humaness_check?: boolean;
26
- gm_mode?: boolean;
27
- }
28
- ];
29
- event: NostrEvent;
30
- };
31
- export type ExploreGlobalTrending24h = {
32
- req: ["explore_global_trending_24h", {
33
- limit?: number;
34
- }];
35
- event: NostrEvent;
36
- };
37
- export type ExploreGlobalMostZapped4h = {
38
- req: ["explore_global_mostzapped_4h", {
39
- limit?: number;
40
- }];
41
- event: NostrEvent;
42
- };
43
- export type Scored = {
44
- req: [
45
- "scored",
46
- {
47
- timeframe: "popular" | "trending" | "recent";
48
- pubkeys?: string[];
49
- limit?: number;
50
- created_after?: number;
51
- since?: number;
52
- until?: number;
53
- offset?: number;
54
- group_by_pubkey?: boolean;
55
- user_pubkey?: string;
56
- include_top_zaps?: boolean;
57
- apply_humaness_check?: boolean;
58
- gm_mode?: boolean;
59
- }
60
- ];
61
- event: NostrEvent;
62
- };
63
- export type ScoredUsers = {
64
- req: ["scored_users", {
65
- limit?: number;
66
- }];
67
- event: NostrEvent;
68
- };
69
- export type ScoredUsers24h = {
70
- req: ["scored_users_24h", {
71
- limit?: number;
72
- }];
73
- event: NostrEvent;
74
- };
75
- export type GetDefaultRelays = {
76
- req: ["get_default_relays", {}];
77
- event: NostrEvent;
78
- };
79
- export type GetRecommendedUsers = {
80
- req: ["get_recommended_users", {
81
- limit?: number;
82
- }];
83
- event: NostrEvent;
84
- };
85
- export type GetSuggestedUsers = {
86
- req: ["get_suggested_users", {
87
- limit?: number;
88
- }];
89
- event: NostrEvent;
90
- };
91
- export type UserProfileScoredContent = {
92
- req: [
93
- "user_profile_scored_content",
94
- {
95
- pubkey: string;
96
- limit?: number;
97
- created_after?: number;
98
- since?: number;
99
- until?: number;
100
- offset?: number;
101
- }
102
- ];
103
- event: NostrEvent;
104
- };
105
- export type UserProfileScoredMediaThumbnails = {
106
- req: [
107
- "user_profile_scored_media_thumbnails",
108
- {
109
- pubkey: string;
110
- limit?: number;
111
- created_after?: number;
112
- since?: number;
113
- until?: number;
114
- offset?: number;
115
- }
116
- ];
117
- event: NostrEvent;
118
- };
119
- export type Search = {
120
- req: [
121
- "search",
122
- {
123
- query: string;
124
- limit?: number;
125
- since?: number;
126
- until?: number;
127
- offset?: number;
128
- }
129
- ];
130
- event: NostrEvent;
131
- };
132
- export type AdvancedSearch = {
133
- req: [
134
- "advanced_search",
135
- {
136
- query: string;
137
- limit?: number;
138
- since?: number;
139
- until?: number;
140
- offset?: number;
141
- sort?: "latest" | "popular" | "trending";
142
- }
143
- ];
144
- event: NostrEvent;
145
- };
146
- export type AdvancedFeed = {
147
- req: [
148
- "advanced_feed",
149
- {
150
- feed_type: string;
151
- limit?: number;
152
- since?: number;
153
- until?: number;
154
- offset?: number;
155
- }
156
- ];
157
- event: NostrEvent;
158
- };
159
- export type Relays = {
160
- req: ["relays", {}];
161
- event: NostrEvent;
162
- };
163
- export type GetNotifications = {
164
- req: [
165
- "get_notifications",
166
- {
167
- pubkey: string;
168
- limit?: number;
169
- since?: number;
170
- until?: number;
171
- offset?: number;
172
- }
173
- ];
174
- event: NostrEvent;
175
- };
176
- export type SetNotificationsSeen = {
177
- req: ["set_notifications_seen", {
178
- pubkey: string;
179
- until: number;
180
- }];
181
- event: NostrEvent;
182
- };
183
- export type GetNotificationsSeen = {
184
- req: ["get_notifications_seen", {
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 lastValueFrom(this.cacheRequest(["explore_legend_counts", { pubkey }]).pipe(mapEventsToTimeline()));
28
+ return this.timelineRequest("explore_legend_counts", { pubkey });
24
29
  }
25
30
  /** Explore content with various filters */
26
31
  explore(params) {
27
- return lastValueFrom(this.cacheRequest(["explore", params]).pipe(mapEventsToTimeline()));
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 lastValueFrom(this.cacheRequest(["explore_global_trending_24h", { limit }]).pipe(mapEventsToTimeline()));
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 lastValueFrom(this.cacheRequest(["explore_global_mostzapped_4h", { limit }]).pipe(mapEventsToTimeline()));
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 lastValueFrom(this.cacheRequest(["scored", params]).pipe(mapEventsToTimeline()));
45
+ return this.timelineRequest("scored", params);
41
46
  }
42
47
  /** Get scored users */
43
48
  scoredUsers(limit = 20) {
44
- return lastValueFrom(this.cacheRequest(["scored_users", { limit }]).pipe(mapEventsToTimeline()));
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 lastValueFrom(this.cacheRequest(["scored_users_24h", { limit }]).pipe(mapEventsToTimeline()));
53
+ return this.timelineRequest("scored_users_24h", { limit });
49
54
  }
50
55
  // ===== RELAY METHODS =====
51
56
  /** Get default relays */
52
57
  getDefaultRelays() {
53
- return lastValueFrom(this.cacheRequest(["get_default_relays", {}]).pipe(mapEventsToTimeline()));
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 lastValueFrom(this.cacheRequest(["get_recommended_users", { limit }]).pipe(mapEventsToTimeline()));
63
+ return this.timelineRequest("get_recommended_users", { limit });
59
64
  }
60
65
  /** Get suggested users */
61
66
  getSuggestedUsers(limit = 20) {
62
- return lastValueFrom(this.cacheRequest(["get_suggested_users", { limit }]).pipe(mapEventsToTimeline()));
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(mapEventsToTimeline()));
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 lastValueFrom(this.cacheRequest([
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 lastValueFrom(this.cacheRequest(["user_profile_scored_content", params]).pipe(mapEventsToTimeline()));
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 lastValueFrom(this.cacheRequest(["user_profile_scored_media_thumbnails", params]).pipe(mapEventsToTimeline()));
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 lastValueFrom(this.cacheRequest(["search", params]).pipe(mapEventsToTimeline()));
95
+ return this.timelineRequest("search", params);
88
96
  }
89
97
  /** Advanced search */
90
98
  advancedSearch(params) {
91
- return lastValueFrom(this.cacheRequest(["advanced_search", params]).pipe(mapEventsToTimeline()));
99
+ return this.timelineRequest("advanced_search", params);
92
100
  }
93
101
  // ===== FEED METHODS =====
94
102
  /** Advanced feed */
95
103
  advancedFeed(params) {
96
- return lastValueFrom(this.cacheRequest(["advanced_feed", params]).pipe(mapEventsToTimeline()));
104
+ return this.timelineRequest("advanced_feed", params);
97
105
  }
98
106
  /** Feed directive */
99
107
  feedDirective(params) {
100
- return lastValueFrom(this.cacheRequest(["feed_directive", params]).pipe(mapEventsToTimeline()));
108
+ return this.timelineRequest("feed_directive", params);
101
109
  }
102
110
  /** Feed directive v2 */
103
111
  feedDirective2(params) {
104
- return lastValueFrom(this.cacheRequest(["feed_directive_2", params]).pipe(mapEventsToTimeline()));
112
+ return this.timelineRequest("feed_directive_2", params);
105
113
  }
106
114
  /** Get advanced feeds */
107
115
  getAdvancedFeeds() {
108
- return lastValueFrom(this.cacheRequest(["get_advanced_feeds", {}]).pipe(mapEventsToTimeline()));
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 lastValueFrom(this.cacheRequest(["trending_hashtags", { limit }]).pipe(mapEventsToTimeline()));
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 lastValueFrom(this.cacheRequest(["trending_hashtags_4h", { limit }]).pipe(mapEventsToTimeline()));
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 lastValueFrom(this.cacheRequest(["trending_hashtags_7d", { limit }]).pipe(mapEventsToTimeline()));
129
+ return this.timelineRequest("trending_hashtags_7d", { limit });
122
130
  }
123
131
  /** Get trending images */
124
132
  trendingImages(limit = 20) {
125
- return lastValueFrom(this.cacheRequest(["trending_images", { limit }]).pipe(mapEventsToTimeline()));
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 lastValueFrom(this.cacheRequest(["trending_images_4h", { limit }]).pipe(mapEventsToTimeline()));
137
+ return this.timelineRequest("trending_images_4h", { limit });
130
138
  }
131
139
  // ===== NOTIFICATION METHODS =====
132
140
  /** Get notifications */
133
141
  getNotifications(params) {
134
- return lastValueFrom(this.cacheRequest(["get_notifications", params]).pipe(mapEventsToTimeline()));
142
+ return this.timelineRequest("get_notifications", params);
135
143
  }
136
144
  /** Set notifications as seen */
137
145
  setNotificationsSeen(pubkey, until) {
138
- return lastValueFrom(this.cacheRequest(["set_notifications_seen", { pubkey, until }]).pipe(mapEventsToTimeline()));
146
+ return this.timelineRequest("set_notifications_seen", { pubkey, until });
139
147
  }
140
148
  /** Get notifications seen status */
141
149
  getNotificationsSeen(pubkey) {
142
- return lastValueFrom(this.cacheRequest(["get_notifications_seen", { pubkey }]).pipe(mapEventsToTimeline()));
150
+ return this.timelineRequest("get_notifications_seen", { pubkey });
143
151
  }
144
152
  // ===== RELAY METHODS =====
145
153
  /** Get relays */
146
154
  relays() {
147
- return lastValueFrom(this.cacheRequest(["relays", {}]).pipe(mapEventsToTimeline()));
155
+ return this.timelineRequest("relays", {});
148
156
  }
149
157
  // ===== REPORT METHODS =====
150
158
  /** Report user */
151
159
  reportUser(pubkey, reason) {
152
- return lastValueFrom(this.cacheRequest(["report_user", { pubkey, reason }]).pipe(mapEventsToTimeline()));
160
+ return this.timelineRequest("report_user", { pubkey, reason });
153
161
  }
154
162
  /** Report note */
155
163
  reportNote(eventId, reason) {
156
- return lastValueFrom(this.cacheRequest(["report_note", { event_id: eventId, reason }]).pipe(mapEventsToTimeline()));
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 lastValueFrom(this.cacheRequest(["get_filterlist", {}]).pipe(mapEventsToTimeline()));
169
+ return this.timelineRequest("get_filterlist", {});
162
170
  }
163
171
  /** Check filterlist */
164
172
  checkFilterlist(pubkeys) {
165
- return lastValueFrom(this.cacheRequest(["check_filterlist", { pubkeys }]).pipe(mapEventsToTimeline()));
173
+ return this.timelineRequest("check_filterlist", { pubkeys });
166
174
  }
167
175
  // ===== BROADCAST METHODS =====
168
176
  /** Broadcast reply */
169
177
  broadcastReply(event) {
170
- return lastValueFrom(this.cacheRequest(["broadcast_reply", { event }]).pipe(mapEventsToTimeline()));
178
+ return this.timelineRequest("broadcast_reply", { event });
171
179
  }
172
180
  /** Broadcast events */
173
181
  broadcastEvents(events, relays) {
174
- return lastValueFrom(this.cacheRequest(["broadcast_events", { events, relays }]).pipe(mapEventsToTimeline()));
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 lastValueFrom(this.cacheRequest(["note_mentions", params]).pipe(mapEventsToTimeline()));
187
+ return this.timelineRequest("note_mentions", params);
180
188
  }
181
189
  /** Get note mentions count */
182
190
  noteMentionsCount(eventId) {
183
- return lastValueFrom(this.cacheRequest(["note_mentions_count", { event_id: eventId }]).pipe(mapEventsToTimeline()));
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 lastValueFrom(this.cacheRequest(["get_media_metadata", { urls }]).pipe(mapEventsToTimeline()));
196
+ return this.timelineRequest("get_media_metadata", { urls });
189
197
  }
190
198
  }
package/dist/vertex.js CHANGED
@@ -12,10 +12,12 @@ 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
- this.authenticate(this.signer);
19
+ authenticating = true;
20
+ this.authenticate(this.signer).finally(() => (authenticating = false));
19
21
  }
20
22
  });
21
23
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "applesauce-extra",
3
- "version": "0.0.0-next-20251009104432",
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-signers": "^0.0.0-next-20251009104432"
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",