zapind 0.1.3 → 1.0.0

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/index.d.cts CHANGED
@@ -663,7 +663,8 @@ declare class InFlightDeduplicator {
663
663
  }
664
664
 
665
665
  interface ThreadTargetLike {
666
- readonly id: string;
666
+ readonly id?: string;
667
+ readonly threadId?: string;
667
668
  readonly threadType?: ThreadType;
668
669
  }
669
670
  /**
@@ -913,6 +914,9 @@ interface ServiceDeps {
913
914
  groupCache: TTLCache<string, Group>;
914
915
  dedup: InFlightDeduplicator;
915
916
  }
917
+ interface CacheLookupOptions {
918
+ readonly skipCache?: boolean;
919
+ }
916
920
  declare class AccountService {
917
921
  private readonly deps;
918
922
  constructor(deps: ServiceDeps);
@@ -931,10 +935,8 @@ declare class AccountService {
931
935
  declare class UsersService {
932
936
  private readonly deps;
933
937
  constructor(deps: ServiceDeps);
934
- get(userId: string, options?: {
935
- skipCache?: boolean;
936
- }): Promise<User | null>;
937
- getMany(userIds: readonly string[]): Promise<Record<string, User>>;
938
+ get(userId: string, options?: CacheLookupOptions): Promise<User | null>;
939
+ getMany(userIds: readonly string[], options?: CacheLookupOptions): Promise<Record<string, User>>;
938
940
  findByPhone(phoneNumber: string): Promise<User | null>;
939
941
  findByUsername(username: string): Promise<User | null>;
940
942
  getLastOnline(userId: string): Promise<LastOnlineInfo>;
@@ -959,10 +961,8 @@ declare class GroupsService {
959
961
  private readonly deps;
960
962
  constructor(deps: ServiceDeps);
961
963
  list(): Promise<GroupSummary[]>;
962
- get(groupId: string, options?: {
963
- skipCache?: boolean;
964
- }): Promise<Group>;
965
- getMany(groupIds: readonly string[]): Promise<Record<string, Group>>;
964
+ get(groupId: string, options?: CacheLookupOptions): Promise<Group>;
965
+ getMany(groupIds: readonly string[], options?: CacheLookupOptions): Promise<Record<string, Group>>;
966
966
  create(options: {
967
967
  name?: string;
968
968
  members: readonly string[];
@@ -976,19 +976,17 @@ declare class GroupsService {
976
976
  declare class ConversationsService {
977
977
  private readonly deps;
978
978
  constructor(deps: ServiceDeps);
979
- private fetchGroupIds;
980
979
  get(id: string, threadType?: ThreadType): Promise<Conversation>;
981
980
  getMessages(conversationId: string, count?: number): Promise<MessagePage>;
982
981
  getPinned(): Promise<PinnedConversations>;
983
982
  getUnread(): Promise<UnreadMarks>;
984
- pin(target: ThreadTarget, pinned?: boolean): Promise<void>;
985
- mute(target: ThreadTarget, durationSeconds: number): Promise<void>;
986
- sendTyping(target: ThreadTarget): Promise<void>;
983
+ pin(target: ThreadTarget, pinned?: boolean, explicitType?: ThreadType): Promise<void>;
984
+ mute(target: ThreadTarget, durationSeconds: number, explicitType?: ThreadType): Promise<void>;
985
+ sendTyping(target: ThreadTarget, explicitType?: ThreadType): Promise<void>;
987
986
  }
988
987
  declare class MessagesService {
989
988
  private readonly deps;
990
989
  constructor(deps: ServiceDeps);
991
- private fetchGroupIds;
992
990
  /**
993
991
  * Unified message sender. Automatically resolves threadType from target or Group ID cache.
994
992
  */
@@ -1003,7 +1001,6 @@ declare class MediaService {
1003
1001
  private readonly deps;
1004
1002
  private readonly messages;
1005
1003
  constructor(deps: ServiceDeps, messages: MessagesService);
1006
- private fetchGroupIds;
1007
1004
  upload(target: ThreadTarget, sources: MediaInput | readonly MediaInput[], explicitType?: ThreadType): Promise<UploadedMedia[]>;
1008
1005
  send(target: ThreadTarget, media: MediaInput | readonly MediaInput[], caption?: string): Promise<SendMessageReceipt>;
1009
1006
  }
@@ -1120,6 +1117,10 @@ declare class Zapind {
1120
1117
  private authenticateWithCredentials;
1121
1118
  private loginWithQR;
1122
1119
  logout(options?: LogoutOptions): Promise<void>;
1120
+ /**
1121
+ * Stops realtime listeners, disconnects, clears caches, and removes all registered event listeners.
1122
+ */
1123
+ destroy(options?: LogoutOptions): Promise<void>;
1123
1124
  on<K extends ZapindEventName>(event: K, handler: ZapindEventHandler<K>): UnsubscribeFn;
1124
1125
  once<K extends ZapindEventName>(event: K, handler: ZapindEventHandler<K>): UnsubscribeFn;
1125
1126
  off<K extends ZapindEventName>(event: K, handler: ZapindEventHandler<K>): void;
@@ -1129,4 +1130,4 @@ declare class Zapind {
1129
1130
  stopListening(): void;
1130
1131
  }
1131
1132
 
1132
- export { APIError, type AccountSettings, type Attachment, type AttachmentKind, type AuthRequiredEvent, AuthenticationError, ClientStatus, CloseReason, type ConnectionEvent, Contact, Conversation, DEFAULT_USER_AGENT, EncryptedFileSessionStore, type EventsNamespace, FileSessionStore, Gender, Group, type GroupMember, type GroupSettings, type GroupSummary, GroupType, type GroupUpdateEvent, type ImageMetadata, type ImageMetadataGetter, type LastOnlineInfo, type Logger, type LoginOptions, type LogoutOptions, type MediaInput, MemorySessionStore, type Mention, Message, type MessagePage, type MessageQuote, type MessageSenderRef, type MessageStyle, NetworkError, NotFoundError, type OnlineStatus, PermissionError, type PinnedConversations, Profile, type QRCodeData, type QRScannedData, RateLimitError, type RateLimiterOptions, Reaction, type ReactionEvent, RedactingLogger, type RetryOptions, type SeenEvent, type SendMessageContent, type SendMessagePayload, type SendMessageReceipt, type SerializedCookie, type SessionCredentials, SessionError, type SessionInfo, type SessionStore, type StoredSessionRecord, TextStyle, type ThreadTarget, ThreadType, type TransportAdapter, type TypingEvent, type UndoEvent, type UnreadMark, type UnreadMarks, type UnsubscribeFn, type UploadedMedia, Urgency, User, type UserUpdateEvent, ValidationError, Zapind, ZapindError, type ZapindErrorCode, type ZapindErrorOptions, type ZapindEventHandler, type ZapindEventMap, type ZapindEventName, type ZapindOptions, noopLogger };
1133
+ export { APIError, type AccountSettings, type Attachment, type AttachmentKind, type AuthRequiredEvent, AuthenticationError, type CacheLookupOptions, ClientStatus, CloseReason, type ConnectionEvent, Contact, Conversation, DEFAULT_USER_AGENT, EncryptedFileSessionStore, type EventsNamespace, FileSessionStore, Gender, Group, type GroupMember, type GroupSettings, type GroupSummary, GroupType, type GroupUpdateEvent, type ImageMetadata, type ImageMetadataGetter, type LastOnlineInfo, type Logger, type LoginOptions, type LogoutOptions, type MediaInput, MemorySessionStore, type Mention, Message, type MessagePage, type MessageQuote, type MessageSenderRef, type MessageStyle, NetworkError, NotFoundError, type OnlineStatus, PermissionError, type PinnedConversations, Profile, type QRCodeData, type QRScannedData, RateLimitError, type RateLimiterOptions, Reaction, type ReactionEvent, RedactingLogger, type RetryOptions, type SeenEvent, type SendMessageContent, type SendMessagePayload, type SendMessageReceipt, type SerializedCookie, type SessionCredentials, SessionError, type SessionInfo, type SessionStore, type StoredSessionRecord, TextStyle, type ThreadTarget, ThreadType, type TransportAdapter, type TypingEvent, type UndoEvent, type UnreadMark, type UnreadMarks, type UnsubscribeFn, type UploadedMedia, Urgency, User, type UserUpdateEvent, ValidationError, Zapind, ZapindError, type ZapindErrorCode, type ZapindErrorOptions, type ZapindEventHandler, type ZapindEventMap, type ZapindEventName, type ZapindOptions, noopLogger };
package/dist/index.d.ts CHANGED
@@ -663,7 +663,8 @@ declare class InFlightDeduplicator {
663
663
  }
664
664
 
665
665
  interface ThreadTargetLike {
666
- readonly id: string;
666
+ readonly id?: string;
667
+ readonly threadId?: string;
667
668
  readonly threadType?: ThreadType;
668
669
  }
669
670
  /**
@@ -913,6 +914,9 @@ interface ServiceDeps {
913
914
  groupCache: TTLCache<string, Group>;
914
915
  dedup: InFlightDeduplicator;
915
916
  }
917
+ interface CacheLookupOptions {
918
+ readonly skipCache?: boolean;
919
+ }
916
920
  declare class AccountService {
917
921
  private readonly deps;
918
922
  constructor(deps: ServiceDeps);
@@ -931,10 +935,8 @@ declare class AccountService {
931
935
  declare class UsersService {
932
936
  private readonly deps;
933
937
  constructor(deps: ServiceDeps);
934
- get(userId: string, options?: {
935
- skipCache?: boolean;
936
- }): Promise<User | null>;
937
- getMany(userIds: readonly string[]): Promise<Record<string, User>>;
938
+ get(userId: string, options?: CacheLookupOptions): Promise<User | null>;
939
+ getMany(userIds: readonly string[], options?: CacheLookupOptions): Promise<Record<string, User>>;
938
940
  findByPhone(phoneNumber: string): Promise<User | null>;
939
941
  findByUsername(username: string): Promise<User | null>;
940
942
  getLastOnline(userId: string): Promise<LastOnlineInfo>;
@@ -959,10 +961,8 @@ declare class GroupsService {
959
961
  private readonly deps;
960
962
  constructor(deps: ServiceDeps);
961
963
  list(): Promise<GroupSummary[]>;
962
- get(groupId: string, options?: {
963
- skipCache?: boolean;
964
- }): Promise<Group>;
965
- getMany(groupIds: readonly string[]): Promise<Record<string, Group>>;
964
+ get(groupId: string, options?: CacheLookupOptions): Promise<Group>;
965
+ getMany(groupIds: readonly string[], options?: CacheLookupOptions): Promise<Record<string, Group>>;
966
966
  create(options: {
967
967
  name?: string;
968
968
  members: readonly string[];
@@ -976,19 +976,17 @@ declare class GroupsService {
976
976
  declare class ConversationsService {
977
977
  private readonly deps;
978
978
  constructor(deps: ServiceDeps);
979
- private fetchGroupIds;
980
979
  get(id: string, threadType?: ThreadType): Promise<Conversation>;
981
980
  getMessages(conversationId: string, count?: number): Promise<MessagePage>;
982
981
  getPinned(): Promise<PinnedConversations>;
983
982
  getUnread(): Promise<UnreadMarks>;
984
- pin(target: ThreadTarget, pinned?: boolean): Promise<void>;
985
- mute(target: ThreadTarget, durationSeconds: number): Promise<void>;
986
- sendTyping(target: ThreadTarget): Promise<void>;
983
+ pin(target: ThreadTarget, pinned?: boolean, explicitType?: ThreadType): Promise<void>;
984
+ mute(target: ThreadTarget, durationSeconds: number, explicitType?: ThreadType): Promise<void>;
985
+ sendTyping(target: ThreadTarget, explicitType?: ThreadType): Promise<void>;
987
986
  }
988
987
  declare class MessagesService {
989
988
  private readonly deps;
990
989
  constructor(deps: ServiceDeps);
991
- private fetchGroupIds;
992
990
  /**
993
991
  * Unified message sender. Automatically resolves threadType from target or Group ID cache.
994
992
  */
@@ -1003,7 +1001,6 @@ declare class MediaService {
1003
1001
  private readonly deps;
1004
1002
  private readonly messages;
1005
1003
  constructor(deps: ServiceDeps, messages: MessagesService);
1006
- private fetchGroupIds;
1007
1004
  upload(target: ThreadTarget, sources: MediaInput | readonly MediaInput[], explicitType?: ThreadType): Promise<UploadedMedia[]>;
1008
1005
  send(target: ThreadTarget, media: MediaInput | readonly MediaInput[], caption?: string): Promise<SendMessageReceipt>;
1009
1006
  }
@@ -1120,6 +1117,10 @@ declare class Zapind {
1120
1117
  private authenticateWithCredentials;
1121
1118
  private loginWithQR;
1122
1119
  logout(options?: LogoutOptions): Promise<void>;
1120
+ /**
1121
+ * Stops realtime listeners, disconnects, clears caches, and removes all registered event listeners.
1122
+ */
1123
+ destroy(options?: LogoutOptions): Promise<void>;
1123
1124
  on<K extends ZapindEventName>(event: K, handler: ZapindEventHandler<K>): UnsubscribeFn;
1124
1125
  once<K extends ZapindEventName>(event: K, handler: ZapindEventHandler<K>): UnsubscribeFn;
1125
1126
  off<K extends ZapindEventName>(event: K, handler: ZapindEventHandler<K>): void;
@@ -1129,4 +1130,4 @@ declare class Zapind {
1129
1130
  stopListening(): void;
1130
1131
  }
1131
1132
 
1132
- export { APIError, type AccountSettings, type Attachment, type AttachmentKind, type AuthRequiredEvent, AuthenticationError, ClientStatus, CloseReason, type ConnectionEvent, Contact, Conversation, DEFAULT_USER_AGENT, EncryptedFileSessionStore, type EventsNamespace, FileSessionStore, Gender, Group, type GroupMember, type GroupSettings, type GroupSummary, GroupType, type GroupUpdateEvent, type ImageMetadata, type ImageMetadataGetter, type LastOnlineInfo, type Logger, type LoginOptions, type LogoutOptions, type MediaInput, MemorySessionStore, type Mention, Message, type MessagePage, type MessageQuote, type MessageSenderRef, type MessageStyle, NetworkError, NotFoundError, type OnlineStatus, PermissionError, type PinnedConversations, Profile, type QRCodeData, type QRScannedData, RateLimitError, type RateLimiterOptions, Reaction, type ReactionEvent, RedactingLogger, type RetryOptions, type SeenEvent, type SendMessageContent, type SendMessagePayload, type SendMessageReceipt, type SerializedCookie, type SessionCredentials, SessionError, type SessionInfo, type SessionStore, type StoredSessionRecord, TextStyle, type ThreadTarget, ThreadType, type TransportAdapter, type TypingEvent, type UndoEvent, type UnreadMark, type UnreadMarks, type UnsubscribeFn, type UploadedMedia, Urgency, User, type UserUpdateEvent, ValidationError, Zapind, ZapindError, type ZapindErrorCode, type ZapindErrorOptions, type ZapindEventHandler, type ZapindEventMap, type ZapindEventName, type ZapindOptions, noopLogger };
1133
+ export { APIError, type AccountSettings, type Attachment, type AttachmentKind, type AuthRequiredEvent, AuthenticationError, type CacheLookupOptions, ClientStatus, CloseReason, type ConnectionEvent, Contact, Conversation, DEFAULT_USER_AGENT, EncryptedFileSessionStore, type EventsNamespace, FileSessionStore, Gender, Group, type GroupMember, type GroupSettings, type GroupSummary, GroupType, type GroupUpdateEvent, type ImageMetadata, type ImageMetadataGetter, type LastOnlineInfo, type Logger, type LoginOptions, type LogoutOptions, type MediaInput, MemorySessionStore, type Mention, Message, type MessagePage, type MessageQuote, type MessageSenderRef, type MessageStyle, NetworkError, NotFoundError, type OnlineStatus, PermissionError, type PinnedConversations, Profile, type QRCodeData, type QRScannedData, RateLimitError, type RateLimiterOptions, Reaction, type ReactionEvent, RedactingLogger, type RetryOptions, type SeenEvent, type SendMessageContent, type SendMessagePayload, type SendMessageReceipt, type SerializedCookie, type SessionCredentials, SessionError, type SessionInfo, type SessionStore, type StoredSessionRecord, TextStyle, type ThreadTarget, ThreadType, type TransportAdapter, type TypingEvent, type UndoEvent, type UnreadMark, type UnreadMarks, type UnsubscribeFn, type UploadedMedia, Urgency, User, type UserUpdateEvent, ValidationError, Zapind, ZapindError, type ZapindErrorCode, type ZapindErrorOptions, type ZapindEventHandler, type ZapindEventMap, type ZapindEventName, type ZapindOptions, noopLogger };