whatsapp-cloud 0.1.2 → 0.1.4

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # whatzapp
2
2
 
3
+ ## 0.1.4
4
+
5
+ ### Patch Changes
6
+
7
+ - 0741aba: add sendMessage method
8
+
9
+ ## 0.1.3
10
+
11
+ ### Patch Changes
12
+
13
+ - 6b76203: remove pkg
14
+
3
15
  ## 0.1.2
4
16
 
5
17
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -503,6 +503,24 @@ var MessagesService = class {
503
503
  const client = this.getClient(phoneNumberId);
504
504
  return sendReaction(client, input);
505
505
  }
506
+ /**
507
+ * Send any message type using the discriminated union
508
+ *
509
+ * @param message - Any outgoing message (text, image, location, reaction)
510
+ * @param phoneNumberId - Optional phone number ID (overrides client config)
511
+ */
512
+ async sendMessage(message, phoneNumberId) {
513
+ switch (message.type) {
514
+ case "text":
515
+ return this.sendText(message, phoneNumberId);
516
+ case "image":
517
+ return this.sendImage(message, phoneNumberId);
518
+ case "location":
519
+ return this.sendLocation(message, phoneNumberId);
520
+ case "reaction":
521
+ return this.sendReaction(message, phoneNumberId);
522
+ }
523
+ }
506
524
  };
507
525
 
508
526
  // src/services/accounts/AccountsClient.ts
package/dist/index.d.cts CHANGED
@@ -279,6 +279,13 @@ declare class MessagesService {
279
279
  * @param phoneNumberId - Optional phone number ID (overrides client config)
280
280
  */
281
281
  sendReaction(input: SendReactionInput, phoneNumberId?: string): Promise<MessageResponse>;
282
+ /**
283
+ * Send any message type using the discriminated union
284
+ *
285
+ * @param message - Any outgoing message (text, image, location, reaction)
286
+ * @param phoneNumberId - Optional phone number ID (overrides client config)
287
+ */
288
+ sendMessage(message: OutgoingMessage, phoneNumberId?: string): Promise<MessageResponse>;
282
289
  }
283
290
 
284
291
  /**
package/dist/index.d.ts CHANGED
@@ -279,6 +279,13 @@ declare class MessagesService {
279
279
  * @param phoneNumberId - Optional phone number ID (overrides client config)
280
280
  */
281
281
  sendReaction(input: SendReactionInput, phoneNumberId?: string): Promise<MessageResponse>;
282
+ /**
283
+ * Send any message type using the discriminated union
284
+ *
285
+ * @param message - Any outgoing message (text, image, location, reaction)
286
+ * @param phoneNumberId - Optional phone number ID (overrides client config)
287
+ */
288
+ sendMessage(message: OutgoingMessage, phoneNumberId?: string): Promise<MessageResponse>;
282
289
  }
283
290
 
284
291
  /**
package/dist/index.js CHANGED
@@ -430,6 +430,24 @@ var MessagesService = class {
430
430
  const client = this.getClient(phoneNumberId);
431
431
  return sendReaction(client, input);
432
432
  }
433
+ /**
434
+ * Send any message type using the discriminated union
435
+ *
436
+ * @param message - Any outgoing message (text, image, location, reaction)
437
+ * @param phoneNumberId - Optional phone number ID (overrides client config)
438
+ */
439
+ async sendMessage(message, phoneNumberId) {
440
+ switch (message.type) {
441
+ case "text":
442
+ return this.sendText(message, phoneNumberId);
443
+ case "image":
444
+ return this.sendImage(message, phoneNumberId);
445
+ case "location":
446
+ return this.sendLocation(message, phoneNumberId);
447
+ case "reaction":
448
+ return this.sendReaction(message, phoneNumberId);
449
+ }
450
+ }
433
451
  };
434
452
 
435
453
  // src/services/accounts/AccountsClient.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whatsapp-cloud",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Work in progress. A WhatsApp client tailored for LLMs—built to actually work.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -21,7 +21,7 @@
21
21
  "zod": "^4.2.1"
22
22
  },
23
23
  "scripts": {
24
- "build": "tsup src/index.ts --format cjs,esm --dts",
24
+ "build": "tsup src/index.ts --format cjs,esm --dts --clean",
25
25
  "lint": "tsc",
26
26
  "example": "tsx src/examples/main.ts"
27
27
  }
@@ -10,6 +10,7 @@ import type {
10
10
  SendImageInput,
11
11
  SendLocationInput,
12
12
  SendReactionInput,
13
+ OutgoingMessage,
13
14
  } from "../../types/messages/outgoing";
14
15
  import type { MessageResponse } from "../../types/messages/response";
15
16
 
@@ -94,4 +95,26 @@ export class MessagesService {
94
95
  const client = this.getClient(phoneNumberId);
95
96
  return sendReaction(client, input);
96
97
  }
98
+
99
+ /**
100
+ * Send any message type using the discriminated union
101
+ *
102
+ * @param message - Any outgoing message (text, image, location, reaction)
103
+ * @param phoneNumberId - Optional phone number ID (overrides client config)
104
+ */
105
+ async sendMessage(
106
+ message: OutgoingMessage,
107
+ phoneNumberId?: string
108
+ ): Promise<MessageResponse> {
109
+ switch (message.type) {
110
+ case "text":
111
+ return this.sendText(message, phoneNumberId);
112
+ case "image":
113
+ return this.sendImage(message, phoneNumberId);
114
+ case "location":
115
+ return this.sendLocation(message, phoneNumberId);
116
+ case "reaction":
117
+ return this.sendReaction(message, phoneNumberId);
118
+ }
119
+ }
97
120
  }
@@ -1,5 +1,5 @@
1
1
  import type { WebhookPayload } from "../../../types/webhooks";
2
- import type { IncomingMessage } from "../../../types/webhooks/incoming-message";
2
+ import type { IncomingMessage } from "../../../types/messages/incoming";
3
3
 
4
4
  /**
5
5
  * Extract all incoming messages from webhook payload
package/dist/index.d.mts DELETED
@@ -1,2 +0,0 @@
1
-
2
- export { }