applesauce-extra 0.0.0-next-20251009095925 → 0.0.0-next-20251009104432

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/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
- lookupProfiles(query: string, sortMethod?: SortMethod, limit?: number): Promise<ProfilePointer[]>;
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";
@@ -19,8 +19,14 @@ export class Vertex extends Relay {
19
19
  }
20
20
  });
21
21
  }
22
+ // Create a cache for user search results that expires after 1 hour
23
+ userSearchCache = new LRU(1000, 60 * 60 * 1000);
22
24
  /** Lookup user profiles by search query */
23
- async lookupProfiles(query, sortMethod = "globalPagerank", limit = 10) {
25
+ async userSearch(query, sortMethod = "globalPagerank", limit = 10) {
26
+ // Check cache
27
+ const cached = this.userSearchCache.get([query, sortMethod, limit].join(":"));
28
+ if (cached)
29
+ return cached;
24
30
  // Create request
25
31
  const request = await this.signer.signEvent({
26
32
  kind: VERTEX_SEARCH_KIND,
@@ -57,6 +63,8 @@ export class Vertex extends Relay {
57
63
  pubkey,
58
64
  relays: [VERTEX_RELAY],
59
65
  }));
66
+ // Cache the results
67
+ this.userSearchCache.set([query, sortMethod, limit].join(":"), pointers);
60
68
  return pointers;
61
69
  }
62
70
  /** 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-20251009095925",
3
+ "version": "0.0.0-next-20251009104432",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -20,7 +20,7 @@
20
20
  "rxjs": "^7.8.2",
21
21
  "applesauce-core": "^4.0.0",
22
22
  "applesauce-relay": "^4.0.0",
23
- "applesauce-signers": "^0.0.0-next-20251009095925"
23
+ "applesauce-signers": "^0.0.0-next-20251009104432"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@hirez_io/observer-spy": "^2.2.0",