applesauce-core 0.0.0-next-20251015123951 → 0.0.0-next-20251020143053

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.
@@ -1,4 +1,5 @@
1
- import { ProfilePointer } from "nostr-tools/nip19";
1
+ import { ProfilePointer } from "./pointers.js";
2
+ import { Filter } from "./filter.js";
2
3
  export type SelectOptimalRelaysOptions = {
3
4
  /** Maximum number of connections (relays) to select */
4
5
  maxConnections: number;
@@ -13,5 +14,11 @@ export declare function setFallbackRelays(users: ProfilePointer[], fallbacks: st
13
14
  export declare function removeBlacklistedRelays(users: ProfilePointer[], blacklist: string[]): ProfilePointer[];
14
15
  /** A map of pubkeys by relay */
15
16
  export type OutboxMap = Record<string, ProfilePointer[]>;
16
- /** RxJS operator that aggregates contacts with outboxes into a relay -> pubkeys map */
17
+ /** A map of filters by relay */
18
+ export type FilterMap = Record<string, Filter | Filter[]>;
19
+ /** Creates an {@link OutboxMap} for an array of profile points (groups users by relay) */
17
20
  export declare function groupPubkeysByRelay(pointers: ProfilePointer[]): OutboxMap;
21
+ /** Alias for {@link groupPubkeysByRelay} */
22
+ export declare const createOutboxMap: typeof groupPubkeysByRelay;
23
+ /** Creates a {@link FilterMap} for an {@link OutboxMap} */
24
+ export declare function createFilterMap(outboxMap: OutboxMap, filter: Omit<Filter, "authors">): FilterMap;
@@ -86,7 +86,7 @@ export function removeBlacklistedRelays(users, blacklist) {
86
86
  return { ...user, relays: user.relays.filter((relay) => !blacklist.includes(relay)) };
87
87
  });
88
88
  }
89
- /** RxJS operator that aggregates contacts with outboxes into a relay -> pubkeys map */
89
+ /** Creates an {@link OutboxMap} for an array of profile points (groups users by relay) */
90
90
  export function groupPubkeysByRelay(pointers) {
91
91
  const outbox = {};
92
92
  for (const pointer of pointers) {
@@ -100,3 +100,12 @@ export function groupPubkeysByRelay(pointers) {
100
100
  }
101
101
  return outbox;
102
102
  }
103
+ /** Alias for {@link groupPubkeysByRelay} */
104
+ export const createOutboxMap = groupPubkeysByRelay;
105
+ /** Creates a {@link FilterMap} for an {@link OutboxMap} */
106
+ export function createFilterMap(outboxMap, filter) {
107
+ return Object.fromEntries(Array.from(Object.entries(outboxMap)).map(([relay, users]) => [
108
+ relay,
109
+ { authors: users.map((user) => user.pubkey), ...filter },
110
+ ]));
111
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "applesauce-core",
3
- "version": "0.0.0-next-20251015123951",
3
+ "version": "0.0.0-next-20251020143053",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",