applesauce-core 0.0.0-next-20250915145415 → 0.0.0-next-20250916134023

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.
@@ -17,7 +17,7 @@ declare const AsyncEventStore_base: {
17
17
  addressable(pointer: AddressPointer): Observable<NostrEvent | undefined>;
18
18
  timeline(filters: Filter | Filter[], includeOldVersion?: boolean): Observable<NostrEvent[]>;
19
19
  profile(user: string | import("nostr-tools/nip19").ProfilePointer): Observable<import("../helpers/profile.js").ProfileContent | undefined>;
20
- contacts(user: string | import("nostr-tools/nip19").ProfilePointer): Observable<import("nostr-tools/nip19").ProfilePointer[]>;
20
+ contacts(user: string | import("nostr-tools/nip19").ProfilePointer): Observable<import("nostr-tools/nip19").ProfilePointer[] | undefined>;
21
21
  mutes(user: string | import("nostr-tools/nip19").ProfilePointer): Observable<import("../helpers/mutes.js").Mutes | undefined>;
22
22
  mailboxes(user: string | import("nostr-tools/nip19").ProfilePointer): Observable<{
23
23
  inboxes: string[];
@@ -109,7 +109,7 @@ export declare class AsyncEventStore extends AsyncEventStore_base implements IAs
109
109
  /** Returns all versions of a replaceable event */
110
110
  getReplaceableHistory(kind: number, pubkey: string, identifier?: string): Promise<NostrEvent[] | undefined>;
111
111
  /** Get all events matching a filter */
112
- getByFilters(filters: Filter | Filter[]): Promise<Set<NostrEvent>>;
112
+ getByFilters(filters: Filter | Filter[]): Promise<NostrEvent[]>;
113
113
  /** Returns a timeline of events that match filters */
114
114
  getTimeline(filters: Filter | Filter[]): Promise<NostrEvent[]>;
115
115
  /** Passthrough method for the database.touch */
@@ -288,14 +288,18 @@ export class AsyncEventStore extends EventStoreModelMixin(class {
288
288
  // NOTE: no way to read from memory since memory won't have the full set of events
289
289
  const events = await this.database.getByFilters(filters);
290
290
  // Map events to memory if available for better performance
291
- if (this.memory) {
292
- return new Set(Array.from(events).map((e) => this.mapToMemory(e) ?? e));
293
- }
294
- return events;
291
+ if (this.memory)
292
+ return events.map((e) => this.mapToMemory(e) ?? e);
293
+ else
294
+ return events;
295
295
  }
296
296
  /** Returns a timeline of events that match filters */
297
297
  async getTimeline(filters) {
298
- return await this.database.getTimeline(filters);
298
+ const events = await this.database.getTimeline(filters);
299
+ if (this.memory)
300
+ return events.map((e) => this.mapToMemory(e));
301
+ else
302
+ return events;
299
303
  }
300
304
  /** Passthrough method for the database.touch */
301
305
  touch(event) {
@@ -26,7 +26,7 @@ export declare class EventMemory implements IEventMemory {
26
26
  /** Gets the history of a replaceable event */
27
27
  getReplaceableHistory(kind: number, pubkey: string, identifier?: string): NostrEvent[] | undefined;
28
28
  /** Gets all events that match the filters */
29
- getByFilters(filters: Filter | Filter[]): Set<NostrEvent>;
29
+ getByFilters(filters: Filter | Filter[]): NostrEvent[];
30
30
  /** Gets a timeline of events that match the filters */
31
31
  getTimeline(filters: Filter | Filter[]): NostrEvent[];
32
32
  /** Inserts an event into the database and notifies all subscriptions */
@@ -72,5 +72,3 @@ export declare class EventMemory implements IEventMemory {
72
72
  /** Resets the event set */
73
73
  reset(): void;
74
74
  }
75
- /** @deprecated use {@link EventMemory} instead */
76
- export declare const EventSet: typeof EventMemory;
@@ -45,7 +45,7 @@ export class EventMemory {
45
45
  }
46
46
  /** Gets all events that match the filters */
47
47
  getByFilters(filters) {
48
- return this.getEventsForFilters(Array.isArray(filters) ? filters : [filters]);
48
+ return Array.from(this.getEventsForFilters(Array.isArray(filters) ? filters : [filters]));
49
49
  }
50
50
  /** Gets a timeline of events that match the filters */
51
51
  getTimeline(filters) {
@@ -347,5 +347,3 @@ export class EventMemory {
347
347
  this.claims = new WeakMap();
348
348
  }
349
349
  }
350
- /** @deprecated use {@link EventMemory} instead */
351
- export const EventSet = EventMemory;
@@ -17,7 +17,7 @@ declare const EventStore_base: {
17
17
  addressable(pointer: AddressPointer): Observable<NostrEvent | undefined>;
18
18
  timeline(filters: Filter | Filter[], includeOldVersion?: boolean): Observable<NostrEvent[]>;
19
19
  profile(user: string | import("nostr-tools/nip19").ProfilePointer): Observable<import("../helpers/profile.js").ProfileContent | undefined>;
20
- contacts(user: string | import("nostr-tools/nip19").ProfilePointer): Observable<import("nostr-tools/nip19").ProfilePointer[]>;
20
+ contacts(user: string | import("nostr-tools/nip19").ProfilePointer): Observable<import("nostr-tools/nip19").ProfilePointer[] | undefined>;
21
21
  mutes(user: string | import("nostr-tools/nip19").ProfilePointer): Observable<import("../helpers/mutes.js").Mutes | undefined>;
22
22
  mailboxes(user: string | import("nostr-tools/nip19").ProfilePointer): Observable<{
23
23
  inboxes: string[];
@@ -109,7 +109,7 @@ export declare class EventStore extends EventStore_base implements IEventStore {
109
109
  /** Returns all versions of a replaceable event */
110
110
  getReplaceableHistory(kind: number, pubkey: string, identifier?: string): NostrEvent[] | undefined;
111
111
  /** Get all events matching a filter */
112
- getByFilters(filters: Filter | Filter[]): Set<NostrEvent>;
112
+ getByFilters(filters: Filter | Filter[]): NostrEvent[];
113
113
  /** Returns a timeline of events that match filters */
114
114
  getTimeline(filters: Filter | Filter[]): NostrEvent[];
115
115
  /** Passthrough method for the database.touch */
@@ -291,12 +291,17 @@ export class EventStore extends EventStoreModelMixin(class {
291
291
  const events = this.database.getByFilters(filters);
292
292
  // Map events to memory if available for better performance
293
293
  if (this.memory)
294
- return new Set(Array.from(events).map((e) => this.mapToMemory(e) ?? e));
295
- return events;
294
+ return events.map((e) => this.mapToMemory(e));
295
+ else
296
+ return events;
296
297
  }
297
298
  /** Returns a timeline of events that match filters */
298
299
  getTimeline(filters) {
299
- return this.database.getTimeline(filters);
300
+ const events = this.database.getTimeline(filters);
301
+ if (this.memory)
302
+ return events.map((e) => this.mapToMemory(e));
303
+ else
304
+ return events;
300
305
  }
301
306
  /** Passthrough method for the database.touch */
302
307
  touch(event) {
@@ -18,7 +18,7 @@ export interface IEventStoreRead {
18
18
  /** Get the history of a replaceable event */
19
19
  getReplaceableHistory(kind: number, pubkey: string, identifier?: string): NostrEvent[] | undefined;
20
20
  /** Get all events that match the filters */
21
- getByFilters(filters: Filter | Filter[]): Set<NostrEvent>;
21
+ getByFilters(filters: Filter | Filter[]): NostrEvent[];
22
22
  /** Get a timeline of events that match the filters */
23
23
  getTimeline(filters: Filter | Filter[]): NostrEvent[];
24
24
  }
@@ -35,7 +35,7 @@ export interface IAsyncEventStoreRead {
35
35
  /** Get the history of a replaceable event */
36
36
  getReplaceableHistory(kind: number, pubkey: string, identifier?: string): Promise<NostrEvent[] | undefined>;
37
37
  /** Get all events that match the filters */
38
- getByFilters(filters: Filter | Filter[]): Promise<Set<NostrEvent>>;
38
+ getByFilters(filters: Filter | Filter[]): Promise<NostrEvent[]>;
39
39
  /** Get a timeline of events that match the filters */
40
40
  getTimeline(filters: Filter | Filter[]): Promise<NostrEvent[]>;
41
41
  }
@@ -112,7 +112,7 @@ export interface IEventHelpfulSubscriptions {
112
112
  /** Subscribe to a users profile */
113
113
  profile(user: string | ProfilePointer): Observable<ProfileContent | undefined>;
114
114
  /** Subscribe to a users contacts */
115
- contacts(user: string | ProfilePointer): Observable<ProfilePointer[]>;
115
+ contacts(user: string | ProfilePointer): Observable<ProfilePointer[] | undefined>;
116
116
  /** Subscribe to a users mutes */
117
117
  mutes(user: string | ProfilePointer): Observable<Mutes | undefined>;
118
118
  /** Subscribe to a users NIP-65 mailboxes */
@@ -165,9 +165,6 @@ export interface IEventMemory extends IEventStoreRead, IEventClaims {
165
165
  /** Remove an event from the store */
166
166
  remove(event: string | NostrEvent): boolean;
167
167
  }
168
- /** @deprecated use {@link IEventDatabase} instead */
169
- export interface IEventSet extends IEventDatabase {
170
- }
171
168
  /** A set of methods that an event store will use to load single events it does not have */
172
169
  export interface IEventFallbackLoaders {
173
170
  /** A method that will be called when an event isn't found in the store */
@@ -31,7 +31,7 @@ export declare function EventStoreModelMixin<T extends new (...args: any[]) => a
31
31
  /** Subscribe to a users profile */
32
32
  profile(user: string | ProfilePointer): Observable<import("../helpers/profile.js").ProfileContent | undefined>;
33
33
  /** Subscribe to a users contacts */
34
- contacts(user: string | ProfilePointer): Observable<ProfilePointer[]>;
34
+ contacts(user: string | ProfilePointer): Observable<ProfilePointer[] | undefined>;
35
35
  /** Subscribe to a users mutes */
36
36
  mutes(user: string | ProfilePointer): Observable<import("../helpers/mutes.js").Mutes | undefined>;
37
37
  /** Subscribe to a users NIP-65 mailboxes */
@@ -1,7 +1,7 @@
1
1
  import { ProfilePointer } from "nostr-tools/nip19";
2
2
  import { Model } from "../event-store/interface.js";
3
3
  /** A model that returns all contacts for a user */
4
- export declare function ContactsModel(user: string | ProfilePointer): Model<ProfilePointer[]>;
4
+ export declare function ContactsModel(user: string | ProfilePointer): Model<ProfilePointer[] | undefined>;
5
5
  /** A model that returns all public contacts for a user */
6
6
  export declare function PublicContactsModel(pubkey: string): Model<ProfilePointer[] | undefined>;
7
7
  /** A model that returns all hidden contacts for a user */
@@ -10,7 +10,7 @@ export function ContactsModel(user) {
10
10
  // listen for event updates (hidden tags unlocked)
11
11
  watchEventUpdates(events),
12
12
  // Get all contacts
13
- map((e) => (e ? getContacts(e) : [])));
13
+ map((e) => (e ? getContacts(e) : undefined)));
14
14
  }
15
15
  /** A model that returns all public contacts for a user */
16
16
  export function PublicContactsModel(pubkey) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "applesauce-core",
3
- "version": "0.0.0-next-20250915145415",
3
+ "version": "0.0.0-next-20250916134023",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",