@great-detail/whatsapp
Advanced tools
Comparing version 7.0.6 to 7.0.7
#!/usr/bin/env node | ||
import{a as m}from"./chunk-HXKRHTK4.js";import{program as n}from"commander";import c from"get-stdin";var s=process.env.WHATSAPP_ACCESS_TOKEN,p=process.env.WHATSAPP_PHONE_NUMBER_ID,o=new m;n.name("whatsapp").description("WhatsApp SDK CLI");var i=n.command("media").description("Media");i.command("download").description("Download Media").argument("<MEDIA_URL>","Media URL").requiredOption("--access-token <ACCESS_TOKEN>","WhatsApp Access Token",s).action(async e=>{let a=await(await o.media.download(e)).arrayBuffer(),r=Buffer.from(a);process.stdout.write(r)});i.command("delete").description("Delete Media").argument("<MEDIA_ID>","Media ID").option("--phone-number-id <PHONE_NUMBER_ID>","From Phone Number ID",p).requiredOption("--access-token <ACCESS_TOKEN>","WhatsApp Access Token",s).action(async(e,t)=>{let a=await o.media.delete({mediaID:e,phoneNumberID:t.phoneNumberId});console.log(await a.json())});i.command("get-url").description("Get Media URL").argument("<MEDIA_ID>","Media ID").option("--phone-number-id <PHONE_NUMBER_ID>","From Phone Number ID",p).requiredOption("--access-token <ACCESS_TOKEN>","WhatsApp Access Token",s).action(async(e,t)=>{let a=await o.media.getURL({mediaID:e,phoneNumberID:t.phoneNumberId});console.log(await a.json())});i.command("upload").description("Upload Media").option("--filename <FILENAME>","Filename").requiredOption("--mime-type <MIME_TYPE>","MIME Type").requiredOption("--phone-number-id <PHONE_NUMBER_ID>","From Phone Number ID",p).requiredOption("--access-token <ACCESS_TOKEN>","WhatsApp Access Token",s).action(async e=>{let t=await c.buffer(),a=new Blob([t],{type:e.mimeType}),r=await o.media.upload({file:a,phoneNumberID:e.phoneNumberId,mimeType:e.mimeType,filename:e.filename});console.log(await r.json())});var d=n.command("message").description("Message");d.command("text").description("Send a Text message").argument("<RECIPIENT>","Message recipient Phone Number or Phone Number ID").requiredOption("--body <BODY>","Message body").option("--preview-url","Enable URL previewing for the message").action(async(e,t)=>{let a=await o.message.createMessage({to:e,phoneNumberID:t.phoneNumberId,type:"text",text:{body:t.body,preview_url:t.previewUrl}});console.log(await a.json())});n.parseAsync(); | ||
import{a as d}from"./chunk-KCPETIM6.js";import{program as t}from"commander";import c from"get-stdin";var s=process.env.WHATSAPP_ACCESS_TOKEN,m=process.env.WHATSAPP_PHONE_NUMBER_ID,a=new d;t.name("whatsapp").description("WhatsApp SDK CLI");var i=t.command("media").description("Media");i.command("download").description("Download Media").argument("<MEDIA_URL>","Media URL").requiredOption("--access-token <ACCESS_TOKEN>","WhatsApp Access Token",s).action(async e=>{let n=await(await a.media.download(e)).arrayBuffer(),r=Buffer.from(n);process.stdout.write(r)});i.command("delete").description("Delete Media").argument("<MEDIA_ID>","Media ID").option("--phone-number-id <PHONE_NUMBER_ID>","From Phone Number ID",m).requiredOption("--access-token <ACCESS_TOKEN>","WhatsApp Access Token",s).action(async(e,o)=>{let n=await a.media.delete({mediaID:e,phoneNumberID:o.phoneNumberId});console.log(await n.json())});i.command("get-url").description("Get Media URL").argument("<MEDIA_ID>","Media ID").option("--phone-number-id <PHONE_NUMBER_ID>","From Phone Number ID",m).requiredOption("--access-token <ACCESS_TOKEN>","WhatsApp Access Token",s).action(async(e,o)=>{let n=await a.media.getURL({mediaID:e,phoneNumberID:o.phoneNumberId});console.log(await n.json())});i.command("upload").description("Upload Media").option("--filename <FILENAME>","Filename").requiredOption("--mime-type <MIME_TYPE>","MIME Type").requiredOption("--phone-number-id <PHONE_NUMBER_ID>","From Phone Number ID",m).requiredOption("--access-token <ACCESS_TOKEN>","WhatsApp Access Token",s).action(async e=>{let o=await c.buffer(),n=new Blob([o],{type:e.mimeType}),r=await a.media.upload({file:n,phoneNumberID:e.phoneNumberId,mimeType:e.mimeType,filename:e.filename});console.log(await r.json())});var p=t.command("message").description("Message");p.command("text").description("Send a Text message").argument("<RECIPIENT>","Message recipient Phone Number or Phone Number ID").requiredOption("--body <BODY>","Message body").option("--preview-url","Enable URL previewing for the message").action(async(e,o)=>{let n=await a.message.createMessage({to:e,phoneNumberID:o.phoneNumberId,type:"text",text:{body:o.body,preview_url:o.previewUrl}});console.log(await n.json())});t.parseAsync(); |
@@ -504,10 +504,2 @@ import * as ky from 'ky'; | ||
*/ | ||
/** | ||
* WhatsApp Message ID. | ||
* This ID likely starts with `wamid.`. | ||
*/ | ||
type MessageID = `wamid.${string}` | (string & NonNullable<unknown>); | ||
type MessageStatusType = "read" | (string & NonNullable<unknown>); | ||
type MessageRecipientType = "individual" | "group" | (string & NonNullable<unknown>); | ||
declare enum MessageType { | ||
@@ -538,2 +530,18 @@ Audio = "audio",// for audio messages. | ||
} | ||
/** | ||
* WhatsApp NodeJS SDK. | ||
* | ||
* @author Great Detail Ltd <info@greatdetail.com> | ||
* @author Dom Webber <dom.webber@hotmail.com> | ||
* @see https://greatdetail.com | ||
*/ | ||
/** | ||
* WhatsApp Message ID. | ||
* This ID likely starts with `wamid.`. | ||
*/ | ||
type MessageID = `wamid.${string}` | (string & NonNullable<unknown>); | ||
type MessageStatusType = "read" | (string & NonNullable<unknown>); | ||
type MessageRecipientType = "individual" | "group" | (string & NonNullable<unknown>); | ||
type CreateMessageOptions = { | ||
@@ -540,0 +548,0 @@ phoneNumberID: PhoneNumberID; |
@@ -1,1 +0,1 @@ | ||
import{a as e}from"./chunk-HXKRHTK4.js";export{e as Client,e as CloudAPI,e as default}; | ||
import{a as e,b as s}from"./chunk-KCPETIM6.js";export{e as Client,e as CloudAPI,s as MessageType,e as default}; |
{ | ||
"name": "@great-detail/whatsapp", | ||
"version": "7.0.6", | ||
"version": "7.0.7", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "description": "SDK for interfacing with WhatsApp Business Platform in Typescript or Node.js using the Cloud API, hosted by Meta.", |
@@ -27,3 +27,3 @@ # Node.js SDK for WhatsApp Business Platform APIs | ||
```ts | ||
const CloudAPI = require("@great-detail/whatsapp").default; | ||
const Client = require("@great-detail/whatsapp").default; | ||
``` | ||
@@ -71,2 +71,7 @@ | ||
# NPM / Yarn / PNPM | ||
npx @great-detail/whatsapp ... | ||
yarn dlx @great-detail/whatsapp ... | ||
pnpx @great-detail/whatsapp ... | ||
# Send a Text Message | ||
@@ -109,7 +114,7 @@ # TODO: Re-add with updated SDK | ||
Additional NodeJS versions may also work, however, automated testing runs on the | ||
following versions. | ||
**Tested on NodeJS**: `v21`, `v22`, `v23`. | ||
Additional NodeJS versions may also work, however, automated testing requires | ||
NodeJS' test suite, which was introduced in `v21`. | ||
## TODO | ||
@@ -127,5 +132,5 @@ | ||
- [ ] List Message Types. | ||
- [ ] WABA Webhook Subscription Management. | ||
- [x] WABA Webhook Subscription Management. | ||
- [ ] WABA Extended Credit Management. | ||
- [ ] WABA Phone Number Management. | ||
- [x] WABA Phone Number Management. | ||
- [ ] WABA System User Management? | ||
@@ -132,0 +137,0 @@ - [ ] Considering Authentication usage improvements. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
119727
1462
139