waba-toolkit 0.3.1 → 0.4.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/ARCHITECTURE.md +26 -12
- package/README.md +65 -10
- package/dist/index.cli.js +561 -10
- package/dist/index.d.mts +169 -1
- package/dist/index.d.ts +169 -1
- package/dist/index.js +258 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +258 -0
- package/dist/index.mjs.map +1 -1
- package/docs/CLI.md +392 -0
- package/docs/TROUBLESHOOTING.md +2 -2
- package/package.json +1 -1
package/ARCHITECTURE.md
CHANGED
|
@@ -23,21 +23,28 @@ A minimal, type-safe npm package for WhatsApp Business API webhook processing an
|
|
|
23
23
|
waba-toolkit/
|
|
24
24
|
├── src/
|
|
25
25
|
│ ├── index.ts # Main exports
|
|
26
|
-
│ ├── client.ts # WABAClient class
|
|
27
|
-
│ ├── media.ts # Media download logic
|
|
26
|
+
│ ├── client.ts # WABAClient class (includes media download)
|
|
28
27
|
│ ├── errors.ts # Error classes
|
|
29
28
|
│ ├── helpers.ts # Utility helpers
|
|
30
29
|
│ ├── verify.ts # Webhook signature verification
|
|
30
|
+
│ ├── api/
|
|
31
|
+
│ │ ├── index.ts # API client exports
|
|
32
|
+
│ │ ├── client.ts # WABAApiClient class
|
|
33
|
+
│ │ └── types.ts # API request/response types
|
|
31
34
|
│ ├── webhooks/
|
|
32
35
|
│ │ ├── index.ts # Webhook exports
|
|
33
36
|
│ │ ├── classify.ts # Webhook type classification
|
|
34
37
|
│ │ └── messages.ts # Message type classification
|
|
35
|
-
│
|
|
36
|
-
│
|
|
37
|
-
│
|
|
38
|
-
│
|
|
39
|
-
│
|
|
40
|
-
│
|
|
38
|
+
│ ├── types/
|
|
39
|
+
│ │ ├── index.ts # Type exports
|
|
40
|
+
│ │ ├── client.ts # Client options types
|
|
41
|
+
│ │ ├── media.ts # Media response types
|
|
42
|
+
│ │ ├── webhooks.ts # Webhook payload types
|
|
43
|
+
│ │ └── messages.ts # Message type definitions
|
|
44
|
+
│ └── cli/ # CLI implementation
|
|
45
|
+
│ ├── index.ts # CLI entry point
|
|
46
|
+
│ ├── config-manager.ts # Configuration management
|
|
47
|
+
│ └── commands/ # CLI commands
|
|
41
48
|
├── package.json
|
|
42
49
|
├── tsconfig.json
|
|
43
50
|
├── tsup.config.ts
|
|
@@ -180,10 +187,13 @@ export type WebhookClassification =
|
|
|
180
187
|
| { type: 'message'; payload: MessageWebhookValue }
|
|
181
188
|
| { type: 'status'; payload: StatusWebhookValue }
|
|
182
189
|
| { type: 'call'; payload: CallWebhookValue }
|
|
183
|
-
| { type: 'error'; payload: ErrorWebhookValue }
|
|
184
190
|
| { type: 'unknown'; payload: unknown };
|
|
185
191
|
```
|
|
186
192
|
|
|
193
|
+
> **Note:** Errors are not a separate webhook type. They appear as:
|
|
194
|
+
> - `errors[]` array in message webhooks when `type: 'unknown'`
|
|
195
|
+
> - `errors[]` array in status webhooks when `status: 'failed'`
|
|
196
|
+
|
|
187
197
|
### Message Types (Discriminated Union)
|
|
188
198
|
|
|
189
199
|
```typescript
|
|
@@ -394,12 +404,16 @@ Classification is based on:
|
|
|
394
404
|
|
|
395
405
|
## Dependencies
|
|
396
406
|
|
|
397
|
-
**
|
|
407
|
+
**Library**: None (uses native fetch)
|
|
408
|
+
|
|
409
|
+
**CLI**:
|
|
410
|
+
- `commander` ^12.x (command parsing)
|
|
411
|
+
- `inquirer` ^9.x (interactive prompts)
|
|
398
412
|
|
|
399
413
|
**Development**:
|
|
400
414
|
- `typescript` ^5.x
|
|
401
415
|
- `tsup` ^8.x (zero-config bundler, uses esbuild under the hood)
|
|
402
|
-
- `vitest` for testing
|
|
416
|
+
- `vitest` ^4.x for testing
|
|
403
417
|
|
|
404
418
|
---
|
|
405
419
|
|
|
@@ -408,7 +422,7 @@ Classification is based on:
|
|
|
408
422
|
```json
|
|
409
423
|
{
|
|
410
424
|
"name": "waba-toolkit",
|
|
411
|
-
"version": "0.1
|
|
425
|
+
"version": "0.3.1",
|
|
412
426
|
"main": "./dist/index.js",
|
|
413
427
|
"module": "./dist/index.mjs",
|
|
414
428
|
"types": "./dist/index.d.ts",
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Type-safe WhatsApp Business API toolkit with CLI for Node.js 20+
|
|
4
4
|
|
|
5
|
-
**TL;DR:** Process webhooks, download media, send messages. Zero dependencies. Fully typed. Works as library or CLI.
|
|
5
|
+
**TL;DR:** Process webhooks, download media, send messages. Zero library dependencies. Fully typed. Works as library or CLI.
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -12,8 +12,9 @@ Type-safe WhatsApp Business API toolkit with CLI for Node.js 20+
|
|
|
12
12
|
- **Download Media** → Images, videos, documents with automatic URL refresh
|
|
13
13
|
- **Send Messages** → Text, templates, media via library or CLI
|
|
14
14
|
- **Manage Phones** → Register/deregister business phone numbers
|
|
15
|
+
- **Manage Flows** → Create and update WhatsApp Flows via CLI
|
|
15
16
|
|
|
16
|
-
Zero
|
|
17
|
+
Zero library dependencies (CLI uses commander + inquirer). ESM + CommonJS. Full TypeScript support.
|
|
17
18
|
|
|
18
19
|
---
|
|
19
20
|
|
|
@@ -108,6 +109,27 @@ waba-toolkit register --pin 123456
|
|
|
108
109
|
|
|
109
110
|
# List phone numbers
|
|
110
111
|
waba-toolkit list-phones --waba-id YOUR_WABA_ID
|
|
112
|
+
|
|
113
|
+
# List all flows
|
|
114
|
+
waba-toolkit list-flows --waba-id YOUR_WABA_ID
|
|
115
|
+
|
|
116
|
+
# Create a WhatsApp Flow
|
|
117
|
+
waba-toolkit create flow --name "My Flow" --categories LEAD_GENERATION
|
|
118
|
+
|
|
119
|
+
# Upload Flow JSON
|
|
120
|
+
waba-toolkit update flow --flow-id 123456789 --file ./my-flow.json
|
|
121
|
+
|
|
122
|
+
# Publish flow (irreversible)
|
|
123
|
+
waba-toolkit publish flow --flow-id 123456789
|
|
124
|
+
|
|
125
|
+
# List message templates
|
|
126
|
+
waba-toolkit list-templates --waba-id YOUR_WABA_ID
|
|
127
|
+
|
|
128
|
+
# Create a message template
|
|
129
|
+
waba-toolkit create template --name my_template --file ./template.json
|
|
130
|
+
|
|
131
|
+
# Delete a template
|
|
132
|
+
waba-toolkit delete template --name old_template
|
|
111
133
|
```
|
|
112
134
|
|
|
113
135
|
→ **Learn more:** [CLI Guide](docs/CLI.md)
|
|
@@ -127,6 +149,13 @@ waba-toolkit list-phones --waba-id YOUR_WABA_ID
|
|
|
127
149
|
| Send custom message payloads | ✅ | ✅ |
|
|
128
150
|
| Register/deregister phones | ✅ | ✅ |
|
|
129
151
|
| List phone numbers | ✅ | ✅ |
|
|
152
|
+
| List WhatsApp Flows | ✅ | ✅ |
|
|
153
|
+
| Create WhatsApp Flows | ✅ | ✅ |
|
|
154
|
+
| Update Flow JSON | ✅ | ✅ |
|
|
155
|
+
| Publish Flows | ✅ | ✅ |
|
|
156
|
+
| List message templates | ✅ | ✅ |
|
|
157
|
+
| Create message templates | ✅ | ✅ |
|
|
158
|
+
| Delete message templates | ✅ | ✅ |
|
|
130
159
|
| Encrypted config storage | - | ✅ |
|
|
131
160
|
|
|
132
161
|
---
|
|
@@ -328,6 +357,19 @@ await apiClient.sendTemplateMessage('1234567890', {
|
|
|
328
357
|
waba-toolkit send template --to 1234567890 --file template.json
|
|
329
358
|
```
|
|
330
359
|
|
|
360
|
+
### CLI: Create, Update & Publish Flow
|
|
361
|
+
|
|
362
|
+
```bash
|
|
363
|
+
# Create flow
|
|
364
|
+
waba-toolkit create flow --name "Lead Form" --categories LEAD_GENERATION
|
|
365
|
+
|
|
366
|
+
# Upload Flow JSON (returns validation errors if invalid)
|
|
367
|
+
waba-toolkit update flow --flow-id 123456789 --file ./lead-form.json
|
|
368
|
+
|
|
369
|
+
# Publish flow (irreversible - makes flow available for use)
|
|
370
|
+
waba-toolkit publish flow --flow-id 123456789
|
|
371
|
+
```
|
|
372
|
+
|
|
331
373
|
---
|
|
332
374
|
|
|
333
375
|
## TypeScript Support
|
|
@@ -357,6 +399,25 @@ import type {
|
|
|
357
399
|
SendMessageResponse,
|
|
358
400
|
TemplateComponent,
|
|
359
401
|
PhoneNumber,
|
|
402
|
+
|
|
403
|
+
// Flows
|
|
404
|
+
FlowCategory,
|
|
405
|
+
FlowStatus,
|
|
406
|
+
FlowListItem,
|
|
407
|
+
ListFlowsResponse,
|
|
408
|
+
CreateFlowResponse,
|
|
409
|
+
UpdateFlowJsonResponse,
|
|
410
|
+
FlowValidationError,
|
|
411
|
+
PublishFlowResponse,
|
|
412
|
+
|
|
413
|
+
// Templates
|
|
414
|
+
TemplateCategory,
|
|
415
|
+
TemplateStatus,
|
|
416
|
+
TemplateListItem,
|
|
417
|
+
ListTemplatesResponse,
|
|
418
|
+
CreateTemplateRequest,
|
|
419
|
+
CreateTemplateResponse,
|
|
420
|
+
DeleteTemplateResponse,
|
|
360
421
|
} from 'waba-toolkit';
|
|
361
422
|
```
|
|
362
423
|
|
|
@@ -364,12 +425,6 @@ See [API_REFERENCE.md](API_REFERENCE.md) for complete type documentation.
|
|
|
364
425
|
|
|
365
426
|
---
|
|
366
427
|
|
|
367
|
-
## Contributing
|
|
368
|
-
|
|
369
|
-
See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup and guidelines.
|
|
370
|
-
|
|
371
|
-
---
|
|
372
|
-
|
|
373
428
|
## License
|
|
374
429
|
|
|
375
430
|
MIT
|
|
@@ -379,6 +434,6 @@ MIT
|
|
|
379
434
|
## Links
|
|
380
435
|
|
|
381
436
|
- **npm:** https://www.npmjs.com/package/waba-toolkit
|
|
382
|
-
- **GitHub:** https://github.com/
|
|
383
|
-
- **Issues:** https://github.com/
|
|
437
|
+
- **GitHub:** https://github.com/teknicus/waba-toolkit
|
|
438
|
+
- **Issues:** https://github.com/teknicus/waba-toolkit/issues
|
|
384
439
|
- **WhatsApp Business API Docs:** https://developers.facebook.com/docs/whatsapp/cloud-api
|