wa-multi-mongodb 3.10.2 → 3.10.3

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.
Files changed (82) hide show
  1. package/dist/Defaults/index.js +4 -9
  2. package/dist/Error/index.js +1 -5
  3. package/dist/Messaging/index.d.ts +1 -1
  4. package/dist/Messaging/index.js +123 -137
  5. package/dist/Profile/index.d.ts +1 -1
  6. package/dist/Profile/index.js +6 -10
  7. package/dist/Socket/index.d.ts +1 -1
  8. package/dist/Socket/index.d.ts.map +1 -1
  9. package/dist/Socket/index.js +134 -200
  10. package/dist/Types/index.js +1 -2
  11. package/dist/Types/profile.js +1 -2
  12. package/dist/Utils/create-delay.js +2 -7
  13. package/dist/Utils/error.js +1 -4
  14. package/dist/Utils/group-cache.js +8 -15
  15. package/dist/Utils/index.d.ts +5 -5
  16. package/dist/Utils/index.js +5 -21
  17. package/dist/Utils/is-exist.d.ts +1 -1
  18. package/dist/Utils/is-exist.js +7 -10
  19. package/dist/Utils/lid-utils.js +13 -20
  20. package/dist/Utils/message-status.d.ts +1 -1
  21. package/dist/Utils/message-status.js +7 -11
  22. package/dist/Utils/mongo-auth-state.js +10 -13
  23. package/dist/Utils/phone-to-jid.js +6 -14
  24. package/dist/Utils/save-media.d.ts +1 -1
  25. package/dist/Utils/save-media.js +16 -26
  26. package/dist/cjs/Defaults/index.d.ts +21 -0
  27. package/dist/cjs/Defaults/index.d.ts.map +1 -0
  28. package/dist/cjs/Defaults/index.js +31 -0
  29. package/dist/cjs/Error/index.d.ts +5 -0
  30. package/dist/cjs/Error/index.d.ts.map +1 -0
  31. package/dist/cjs/Error/index.js +14 -0
  32. package/dist/cjs/Messaging/index.d.ts +45 -0
  33. package/dist/cjs/Messaging/index.d.ts.map +1 -0
  34. package/dist/cjs/Messaging/index.js +784 -0
  35. package/dist/cjs/Profile/index.d.ts +9 -0
  36. package/dist/cjs/Profile/index.d.ts.map +1 -0
  37. package/dist/cjs/Profile/index.js +34 -0
  38. package/dist/cjs/Socket/index.d.ts +105 -0
  39. package/dist/cjs/Socket/index.d.ts.map +1 -0
  40. package/dist/cjs/Socket/index.js +875 -0
  41. package/dist/cjs/Types/index.d.ts +74 -0
  42. package/dist/cjs/Types/index.d.ts.map +1 -0
  43. package/dist/cjs/Types/index.js +2 -0
  44. package/dist/cjs/Types/profile.d.ts +5 -0
  45. package/dist/cjs/Types/profile.d.ts.map +1 -0
  46. package/dist/cjs/Types/profile.js +2 -0
  47. package/dist/cjs/Utils/create-delay.d.ts +17 -0
  48. package/dist/cjs/Utils/create-delay.d.ts.map +1 -0
  49. package/dist/cjs/Utils/create-delay.js +38 -0
  50. package/dist/cjs/Utils/error.d.ts +4 -0
  51. package/dist/cjs/Utils/error.d.ts.map +1 -0
  52. package/dist/cjs/Utils/error.js +8 -0
  53. package/dist/cjs/Utils/group-cache.d.ts +23 -0
  54. package/dist/cjs/Utils/group-cache.d.ts.map +1 -0
  55. package/dist/cjs/Utils/group-cache.js +176 -0
  56. package/dist/cjs/Utils/index.d.ts +6 -0
  57. package/dist/cjs/Utils/index.d.ts.map +1 -0
  58. package/dist/cjs/Utils/index.js +23 -0
  59. package/dist/cjs/Utils/is-exist.d.ts +6 -0
  60. package/dist/cjs/Utils/is-exist.d.ts.map +1 -0
  61. package/dist/cjs/Utils/is-exist.js +53 -0
  62. package/dist/cjs/Utils/lid-utils.d.ts +26 -0
  63. package/dist/cjs/Utils/lid-utils.d.ts.map +1 -0
  64. package/dist/cjs/Utils/lid-utils.js +81 -0
  65. package/dist/cjs/Utils/message-status.d.ts +4 -0
  66. package/dist/cjs/Utils/message-status.d.ts.map +1 -0
  67. package/dist/cjs/Utils/message-status.js +18 -0
  68. package/dist/cjs/Utils/mongo-auth-state.d.ts +15 -0
  69. package/dist/cjs/Utils/mongo-auth-state.d.ts.map +1 -0
  70. package/dist/cjs/Utils/mongo-auth-state.js +109 -0
  71. package/dist/cjs/Utils/phone-to-jid.d.ts +17 -0
  72. package/dist/cjs/Utils/phone-to-jid.d.ts.map +1 -0
  73. package/dist/cjs/Utils/phone-to-jid.js +51 -0
  74. package/dist/cjs/Utils/save-media.d.ts +6 -0
  75. package/dist/cjs/Utils/save-media.d.ts.map +1 -0
  76. package/dist/cjs/Utils/save-media.js +55 -0
  77. package/dist/cjs/index.d.ts +8 -0
  78. package/dist/cjs/index.d.ts.map +1 -0
  79. package/dist/cjs/index.js +46 -0
  80. package/dist/index.d.ts +6 -6
  81. package/dist/index.js +7 -46
  82. package/package.json +57 -42
@@ -0,0 +1,9 @@
1
+ import { GetProfileInfoProps } from "../Types/profile";
2
+ /**
3
+ * Get profile information of a target (people or group)
4
+ */
5
+ export declare const getProfileInfo: (props: GetProfileInfoProps) => Promise<{
6
+ profilePictureUrl: string;
7
+ status: import("baileys").USyncQueryResultList[];
8
+ }>;
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Profile/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD;;GAEG;AACH,eAAO,MAAM,cAAc,GAAU,OAAO,mBAAmB;;;EAgB9D,CAAC"}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.getProfileInfo = void 0;
13
+ const Defaults_1 = require("../Defaults");
14
+ const Error_1 = require("../Error");
15
+ const Socket_1 = require("../Socket");
16
+ /**
17
+ * Get profile information of a target (people or group)
18
+ */
19
+ const getProfileInfo = (props) => __awaiter(void 0, void 0, void 0, function* () {
20
+ const session = (0, Socket_1.getSession)(props.sessionId);
21
+ if (!session)
22
+ throw new Error_1.WhatsappError(Defaults_1.Messages.sessionNotFound(props.sessionId));
23
+ const [profilePictureUrl, status] = yield Promise.allSettled([
24
+ session.profilePictureUrl(props.target, "image", 5000),
25
+ session.fetchStatus(props.target),
26
+ ]);
27
+ return {
28
+ profilePictureUrl: profilePictureUrl.status === "fulfilled"
29
+ ? profilePictureUrl.value || null
30
+ : null,
31
+ status: status.status === "fulfilled" ? status.value || null : null,
32
+ };
33
+ });
34
+ exports.getProfileInfo = getProfileInfo;
@@ -0,0 +1,105 @@
1
+ import { WASocket } from "baileys";
2
+ import type { MessageReceived, MessageUpdated, StartSessionParams } from "../Types";
3
+ /**
4
+ * Set MongoDB URI for connection
5
+ * This function will be used to configure MongoDB connection with just the URI
6
+ *
7
+ * @param uri MongoDB connection URI
8
+ */
9
+ export declare const setMongoURI: (uri: string) => Promise<void>;
10
+ export declare function setMongoCollection(collection: any): void;
11
+ export declare const startSession: (sessionId?: string, options?: StartSessionParams) => Promise<WASocket>;
12
+ /**
13
+ * Start WhatsApp session using pairing code method
14
+ * This is the recommended way to create sessions with pairing code
15
+ *
16
+ * @param sessionId Unique session identifier
17
+ * @param phoneNumber Phone number with country code (without + prefix)
18
+ * @param options Optional configuration for the session
19
+ * @returns Promise<WASocket> The WhatsApp socket instance
20
+ */
21
+ export declare const startSessionWithPairingCode: (sessionId: string, phoneNumber: string, options?: StartSessionParams) => Promise<WASocket>;
22
+ /**
23
+ * @deprecated Use startSession method instead
24
+ */
25
+ export declare const startWhatsapp: (sessionId?: string, options?: StartSessionParams) => Promise<WASocket>;
26
+ export declare const deleteSession: (sessionId: string) => Promise<void>;
27
+ /**
28
+ * Get all active session IDs
29
+ * @returns Array of session IDs
30
+ */
31
+ export declare const getAllSession: () => Promise<string[]>;
32
+ export declare const getAllSessionSync: () => string[];
33
+ export declare const getSession: (key: string) => WASocket | undefined;
34
+ /**
35
+ * @deprecated Use loadSessionsFromMongo instead
36
+ */
37
+ export declare const loadSessionsFromStorage: () => void;
38
+ export declare const onMessageReceived: (listener: (msg: MessageReceived) => any) => void;
39
+ export declare const onQRUpdated: (listener: ({ sessionId, qr }: {
40
+ sessionId: string;
41
+ qr: string;
42
+ }) => any) => void;
43
+ export declare const onConnected: (listener: (sessionId: string) => any) => void;
44
+ export declare const onDisconnected: (listener: (sessionId: string) => any) => void;
45
+ export declare const onConnecting: (listener: (sessionId: string) => any) => void;
46
+ export declare const onMessageUpdate: (listener: (data: MessageUpdated) => any) => void;
47
+ export declare const onPairingCode: (listener: (sessionId: string, code: string) => any) => void;
48
+ /**
49
+ * Load all sessions from MongoDB and start them automatically
50
+ */
51
+ export declare const loadSessionsFromMongo: () => Promise<void>;
52
+ /**
53
+ * Configure MongoDB database and collection names
54
+ *
55
+ * @param dbName MongoDB database name (default: "wa_session")
56
+ * @param collectionName MongoDB collection name for auth storage (default: "auth")
57
+ */
58
+ export declare const setMongoDBNames: (dbName?: string, collectionName?: string) => void;
59
+ /**
60
+ * Sets the directory name for storing credentials (File-based storage)
61
+ *
62
+ * @deprecated When using MongoDB, this setting has no effect. Only used for legacy file-based storage.
63
+ * @param dirname Directory name for storing credentials (default: "wa_credentials")
64
+ */
65
+ export declare const setCredentialsDir: (dirname?: string) => void;
66
+ /**
67
+ * Attempt to reconnect a disconnected session
68
+ *
69
+ * @param sessionId Session ID to reconnect
70
+ * @returns Promise<boolean> indicating success
71
+ */
72
+ export declare const reconnect: (sessionId: string) => Promise<boolean>;
73
+ /**
74
+ * Reconnect all pairing code sessions that are tracked
75
+ * Useful for bulk reconnection after system restart
76
+ */
77
+ export declare const reconnectAllPairingCodeSessions: () => Promise<{
78
+ [sessionId: string]: boolean;
79
+ }>;
80
+ /**
81
+ * Get all tracked pairing code sessions
82
+ * @returns Array of session IDs that were created with pairing code
83
+ */
84
+ export declare const getPairingCodeSessions: () => string[];
85
+ /**
86
+ * Get session status information
87
+ * @param sessionId Session ID to check
88
+ * @returns Object with session status information
89
+ */
90
+ export declare const getSessionStatus: (sessionId: string) => {
91
+ sessionId: string;
92
+ isRunning: boolean;
93
+ isPairingCodeSession: boolean;
94
+ retryAttempts: number;
95
+ hasCredentials: boolean;
96
+ };
97
+ export declare const setGroupCacheConfig: (options: {
98
+ stdTTL?: number;
99
+ checkperiod?: number;
100
+ }) => void;
101
+ export declare const getGroupMetadata: (sessionId: string, jid: string, forceFetch?: boolean) => Promise<any>;
102
+ export declare const clearGroupMetadataCache: (sessionId: string, jid: string) => Promise<void>;
103
+ export declare const clearSessionGroupMetadataCache: (sessionId: string) => Promise<void>;
104
+ export declare const clearAllGroupMetadataCache: () => void;
105
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Socket/index.ts"],"names":[],"mappings":"AAAA,OAAqB,EAInB,QAAQ,EACT,MAAM,SAAS,CAAC;AAMjB,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,kBAAkB,EAEnB,MAAM,UAAU,CAAC;AAiClB;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAU,KAAK,MAAM,kBAkB5C,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,GAAG,QAEjD;AAkBD,eAAO,MAAM,YAAY,GACvB,kBAAuB,EACvB,UAAS,kBAAsC,KAC9C,OAAO,CAAC,QAAQ,CAwJlB,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,2BAA2B,GACtC,WAAW,MAAM,EACjB,aAAa,MAAM,EACnB,UAAS,kBAAuB,KAC/B,OAAO,CAAC,QAAQ,CA0MlB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,iCAvXf,kBAAkB,KAC1B,OAAO,CAAC,QAAQ,CA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