@catalisa/wpp-sdk 0.2.3 → 0.3.2
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/README.md +178 -1
- package/dist/client.d.ts +2 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +2 -0
- package/dist/client.js.map +1 -1
- package/dist/http/client.d.ts +4 -0
- package/dist/http/client.d.ts.map +1 -1
- package/dist/http/client.js +6 -0
- package/dist/http/client.js.map +1 -1
- package/dist/resources/storage.d.ts +151 -0
- package/dist/resources/storage.d.ts.map +1 -0
- package/dist/resources/storage.js +162 -0
- package/dist/resources/storage.js.map +1 -0
- package/dist/resources/whatsapp.d.ts +193 -1
- package/dist/resources/whatsapp.d.ts.map +1 -1
- package/dist/resources/whatsapp.js +217 -0
- package/dist/resources/whatsapp.js.map +1 -1
- package/dist/resources/whatsapp.test.d.ts +2 -0
- package/dist/resources/whatsapp.test.d.ts.map +1 -0
- package/dist/resources/whatsapp.test.js +780 -0
- package/dist/resources/whatsapp.test.js.map +1 -0
- package/dist/test/fixtures/webhook-events.d.ts +1197 -0
- package/dist/test/fixtures/webhook-events.d.ts.map +1 -0
- package/dist/test/fixtures/webhook-events.js +737 -0
- package/dist/test/fixtures/webhook-events.js.map +1 -0
- package/dist/test/message-type-filter.test.d.ts +6 -0
- package/dist/test/message-type-filter.test.d.ts.map +1 -0
- package/dist/test/message-type-filter.test.js +368 -0
- package/dist/test/message-type-filter.test.js.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/storage.d.ts +86 -0
- package/dist/types/storage.d.ts.map +1 -0
- package/dist/types/storage.js +6 -0
- package/dist/types/storage.js.map +1 -0
- package/dist/types/webhook.d.ts +205 -0
- package/dist/types/webhook.d.ts.map +1 -1
- package/dist/types/webhook.js +24 -0
- package/dist/types/webhook.js.map +1 -1
- package/dist/types/whatsapp.d.ts +245 -2
- package/dist/types/whatsapp.d.ts.map +1 -1
- package/package.json +14 -3
package/README.md
CHANGED
|
@@ -235,6 +235,180 @@ console.log('Status:', operation.status); // 'pending', 'completed', or 'failed'
|
|
|
235
235
|
console.log('Result:', operation.result);
|
|
236
236
|
```
|
|
237
237
|
|
|
238
|
+
### Media Operations
|
|
239
|
+
|
|
240
|
+
#### Sending Media
|
|
241
|
+
|
|
242
|
+
Send images, videos, audio, and documents via URL or base64:
|
|
243
|
+
|
|
244
|
+
```typescript
|
|
245
|
+
// Send image from URL
|
|
246
|
+
await client.whatsapp.sendMedia({
|
|
247
|
+
jid: '5511999999999@s.whatsapp.net',
|
|
248
|
+
type: 'image',
|
|
249
|
+
url: 'https://example.com/photo.jpg',
|
|
250
|
+
caption: 'Check this out!'
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
// Send image from base64
|
|
254
|
+
await client.whatsapp.sendMedia({
|
|
255
|
+
jid: '5511999999999@s.whatsapp.net',
|
|
256
|
+
type: 'image',
|
|
257
|
+
base64: '/9j/4AAQSkZJRg...', // Base64 encoded image (without data URI prefix)
|
|
258
|
+
mimetype: 'image/jpeg',
|
|
259
|
+
caption: 'Photo uploaded from device'
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
// Send audio (voice message)
|
|
263
|
+
await client.whatsapp.sendMedia({
|
|
264
|
+
jid: '5511999999999@s.whatsapp.net',
|
|
265
|
+
type: 'audio',
|
|
266
|
+
base64: 'T2dnUwAC...', // Base64 encoded audio
|
|
267
|
+
mimetype: 'audio/ogg; codecs=opus'
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
// Send document
|
|
271
|
+
await client.whatsapp.sendMedia({
|
|
272
|
+
jid: '5511999999999@s.whatsapp.net',
|
|
273
|
+
type: 'document',
|
|
274
|
+
url: 'https://example.com/contract.pdf',
|
|
275
|
+
filename: 'contract.pdf',
|
|
276
|
+
mimetype: 'application/pdf',
|
|
277
|
+
caption: 'Please review and sign'
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
// Send video
|
|
281
|
+
await client.whatsapp.sendMedia({
|
|
282
|
+
jid: '5511999999999@s.whatsapp.net',
|
|
283
|
+
type: 'video',
|
|
284
|
+
url: 'https://example.com/video.mp4',
|
|
285
|
+
caption: 'Watch this!'
|
|
286
|
+
});
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
#### Receiving Media (via Webhooks)
|
|
290
|
+
|
|
291
|
+
Incoming media is automatically downloaded, decrypted, and included in webhook events:
|
|
292
|
+
|
|
293
|
+
```typescript
|
|
294
|
+
// Webhook payload structure for messages.upsert with media
|
|
295
|
+
interface MessageUpsertEvent {
|
|
296
|
+
event: 'messages.upsert';
|
|
297
|
+
tenantId: string;
|
|
298
|
+
type: 'notify';
|
|
299
|
+
messages: Array<{
|
|
300
|
+
key: {
|
|
301
|
+
remoteJid: string;
|
|
302
|
+
fromMe: boolean;
|
|
303
|
+
id: string;
|
|
304
|
+
};
|
|
305
|
+
message: {
|
|
306
|
+
imageMessage?: {
|
|
307
|
+
url: string; // WhatsApp CDN URL (encrypted, temporary)
|
|
308
|
+
mimetype: string; // e.g., 'image/jpeg'
|
|
309
|
+
caption?: string;
|
|
310
|
+
fileSha256: string;
|
|
311
|
+
fileLength: string;
|
|
312
|
+
mediaKey: string; // Decryption key
|
|
313
|
+
};
|
|
314
|
+
audioMessage?: {
|
|
315
|
+
url: string;
|
|
316
|
+
mimetype: string; // e.g., 'audio/ogg; codecs=opus'
|
|
317
|
+
seconds: number; // Duration in seconds
|
|
318
|
+
ptt: boolean; // True if voice note
|
|
319
|
+
mediaKey: string;
|
|
320
|
+
};
|
|
321
|
+
videoMessage?: { /* similar structure */ };
|
|
322
|
+
documentMessage?: {
|
|
323
|
+
url: string;
|
|
324
|
+
mimetype: string;
|
|
325
|
+
fileName: string;
|
|
326
|
+
mediaKey: string;
|
|
327
|
+
};
|
|
328
|
+
};
|
|
329
|
+
// Automatically downloaded and decrypted media (when downloadMedia=true)
|
|
330
|
+
downloadedMedia?: {
|
|
331
|
+
localPath: string; // e.g., '/tmp/wpp-media/tenant123/1234567890_abc123.jpg'
|
|
332
|
+
base64: string; // Base64 encoded content (ready to use)
|
|
333
|
+
mimetype: string; // e.g., 'image/jpeg'
|
|
334
|
+
type: 'image' | 'video' | 'audio' | 'document' | 'sticker';
|
|
335
|
+
};
|
|
336
|
+
}>;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// Example webhook handler
|
|
340
|
+
app.post('/webhook', (req, res) => {
|
|
341
|
+
const { event, messages } = req.body;
|
|
342
|
+
|
|
343
|
+
if (event === 'messages.upsert') {
|
|
344
|
+
for (const msg of messages) {
|
|
345
|
+
// Check if message has downloaded media
|
|
346
|
+
if (msg.downloadedMedia) {
|
|
347
|
+
const { type, base64, mimetype, localPath } = msg.downloadedMedia;
|
|
348
|
+
|
|
349
|
+
console.log(`Received ${type}: ${mimetype}`);
|
|
350
|
+
console.log(`Local path: ${localPath}`);
|
|
351
|
+
|
|
352
|
+
// Use base64 directly (e.g., display in frontend)
|
|
353
|
+
const dataUri = `data:${mimetype};base64,${base64}`;
|
|
354
|
+
|
|
355
|
+
// Or read from localPath (within Docker container)
|
|
356
|
+
// Note: localPath is only accessible within the worker container
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
// Text content (caption for media, or regular text)
|
|
360
|
+
const text = msg.message?.conversation ||
|
|
361
|
+
msg.message?.extendedTextMessage?.text ||
|
|
362
|
+
msg.message?.imageMessage?.caption ||
|
|
363
|
+
msg.message?.audioMessage?.caption;
|
|
364
|
+
|
|
365
|
+
if (text) {
|
|
366
|
+
console.log('Text:', text);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
res.status(200).send('OK');
|
|
372
|
+
});
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
#### Media Download Configuration
|
|
376
|
+
|
|
377
|
+
Media download is enabled by default per tenant. To disable:
|
|
378
|
+
|
|
379
|
+
```sql
|
|
380
|
+
-- Disable automatic media download for a tenant
|
|
381
|
+
UPDATE "TenantSettings"
|
|
382
|
+
SET "downloadMedia" = false
|
|
383
|
+
WHERE "tenantId" = 'your-tenant-id';
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
#### Supported Media Types
|
|
387
|
+
|
|
388
|
+
| Type | Supported Formats | Max Size (recommended) |
|
|
389
|
+
|------|------------------|------------------------|
|
|
390
|
+
| `image` | JPEG, PNG, GIF, WebP | 5 MB |
|
|
391
|
+
| `video` | MP4, 3GP | 16 MB |
|
|
392
|
+
| `audio` | OGG (Opus), MP3, M4A | 16 MB |
|
|
393
|
+
| `document` | PDF, DOC, XLS, etc. | 100 MB |
|
|
394
|
+
| `sticker` | WebP | 100 KB |
|
|
395
|
+
|
|
396
|
+
#### SendMediaRequest Type
|
|
397
|
+
|
|
398
|
+
```typescript
|
|
399
|
+
interface SendMediaRequest {
|
|
400
|
+
jid: string; // Recipient JID
|
|
401
|
+
type: 'image' | 'video' | 'audio' | 'document'; // Media type
|
|
402
|
+
url?: string; // URL to download media from
|
|
403
|
+
base64?: string; // Base64 encoded content
|
|
404
|
+
caption?: string; // Caption text
|
|
405
|
+
mimetype?: string; // MIME type (auto-detected if URL provided)
|
|
406
|
+
filename?: string; // Filename (for documents)
|
|
407
|
+
callbackUrl?: string; // Webhook for operation result
|
|
408
|
+
correlationId?: string; // Custom tracking ID
|
|
409
|
+
}
|
|
410
|
+
```
|
|
411
|
+
|
|
238
412
|
### Group Management
|
|
239
413
|
|
|
240
414
|
```typescript
|
|
@@ -444,9 +618,12 @@ client.clearAuth();
|
|
|
444
618
|
|
|
445
619
|
### WhatsApp (User)
|
|
446
620
|
- Session: `connect()`, `reconnect()`, `reset()`, `logout()`, `ping()`
|
|
447
|
-
- Messaging: `sendMessage()`, `sendReaction()
|
|
621
|
+
- Messaging: `sendMessage()`, `sendReaction()`
|
|
622
|
+
- Media: `sendMedia({ type, url?, base64?, caption?, mimetype?, filename? })`
|
|
448
623
|
- Groups: `createGroup()`, `updateGroupSubject()`, `addGroupParticipants()`, etc.
|
|
449
624
|
- Queries: `listGroups()`, `listChats()`, `listContacts()`, `getOperation()`
|
|
625
|
+
- Pairing: `requestPairingCode()`, `getPairingCode()`
|
|
626
|
+
- Driver Config: `configureDriver()`, `getDriverConfig()`
|
|
450
627
|
|
|
451
628
|
### WhatsApp Admin
|
|
452
629
|
- Device: `listDevices()`, `getDevice()`, `getQR()`
|
package/dist/client.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { WhatsAppAdminResource } from './resources/whatsappAdmin';
|
|
|
8
8
|
import { WebhooksResource } from './resources/webhooks';
|
|
9
9
|
import { BrandingResource } from './resources/branding';
|
|
10
10
|
import { HealthResource } from './resources/health';
|
|
11
|
+
import { StorageResource } from './resources/storage';
|
|
11
12
|
export interface WhatsAppAPIClientConfig {
|
|
12
13
|
baseURL: string;
|
|
13
14
|
timeout?: number;
|
|
@@ -55,6 +56,7 @@ export declare class WhatsAppAPIClient {
|
|
|
55
56
|
readonly webhooks: WebhooksResource;
|
|
56
57
|
readonly branding: BrandingResource;
|
|
57
58
|
readonly health: HealthResource;
|
|
59
|
+
readonly storage: StorageResource;
|
|
58
60
|
constructor(config: WhatsAppAPIClientConfig);
|
|
59
61
|
/**
|
|
60
62
|
* Set authentication token
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EA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AS,CAAC,CAAC;CACvC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,UAAU,CAAa;IAG/B,SAAgB,IAAI,EAAE,YAAY,CAAC;IACnC,SAAgB,KAAK,EAAE,aAAa,CAAC;IACrC,SAAgB,OAAO,EAAE,eAAe,CAAC;IACzC,SAAgB,SAAS,EAAE,iBAAiB,CAAC;IAC7C,SAAgB,QAAQ,EAAE,gBAAgB,CAAC;IAC3C,SAAgB,aAAa,EAAE,qBAAqB,CAAC;IACrD,SAAgB,QAAQ,EAAE,gBAAgB,CAAC;IAC3C,SAAgB,QAAQ,EAAE,gBAAgB,CAAC;IAC3C,SAAgB,MAAM,EAAE,cAAc,CAAC;IACvC,SAAgB,OAAO,EAAE,eAAe,CAAC;gBAE7B,MAAM,EAAE,uBAAuB;IA4B3C;;;;OAIG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,GAAE,KAAK,GAAG,UAAkB,GAAG,IAAI;IAI9D;;OAEG;IACH,SAAS,IAAI,IAAI;IAIjB;;;;;OAKG;IACG,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAM3C;;OAEG;IACH,MAAM,IAAI,IAAI;CAGf"}
|
package/dist/client.js
CHANGED
|
@@ -11,6 +11,7 @@ const whatsappAdmin_1 = require("./resources/whatsappAdmin");
|
|
|
11
11
|
const webhooks_1 = require("./resources/webhooks");
|
|
12
12
|
const branding_1 = require("./resources/branding");
|
|
13
13
|
const health_1 = require("./resources/health");
|
|
14
|
+
const storage_1 = require("./resources/storage");
|
|
14
15
|
/**
|
|
15
16
|
* WhatsApp Multi-tenant API Client
|
|
16
17
|
*
|
|
@@ -60,6 +61,7 @@ class WhatsAppAPIClient {
|
|
|
60
61
|
this.webhooks = new webhooks_1.WebhooksResource(this.httpClient);
|
|
61
62
|
this.branding = new branding_1.BrandingResource(this.httpClient);
|
|
62
63
|
this.health = new health_1.HealthResource(this.httpClient);
|
|
64
|
+
this.storage = new storage_1.StorageResource(this.httpClient);
|
|
63
65
|
}
|
|
64
66
|
/**
|
|
65
67
|
* Set authentication token
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAAA,0CAA6D;AAC7D,2CAAgD;AAChD,6CAAkD;AAClD,iDAAsD;AACtD,qDAA0D;AAC1D,mDAAwD;AACxD,6DAAkE;AAClE,mDAAwD;AACxD,mDAAwD;AACxD,+CAAoD;
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAAA,0CAA6D;AAC7D,2CAAgD;AAChD,6CAAkD;AAClD,iDAAsD;AACtD,qDAA0D;AAC1D,mDAAwD;AACxD,6DAAkE;AAClE,mDAAwD;AACxD,mDAAwD;AACxD,+CAAoD;AACpD,iDAAsD;AActD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAa,iBAAiB;IAe5B,YAAY,MAA+B;QACzC,yBAAyB;QACzB,IAAI,CAAC,UAAU,GAAG,IAAI,mBAAU,CAAC;YAC/B,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,UAAU,EAAE,MAAM,CAAC,UAAU;YAC7B,OAAO,EAAE,MAAM,CAAC,OAAO;SACxB,CAAC,CAAC;QAEH,+BAA+B;QAC/B,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;YAChB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACpD,CAAC;QAED,uBAAuB;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,mBAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC9C,IA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;IAC9B,OAAO,CAAC,MAAM,CAAmB;gBAErB,MAAM,EAAE,gBAAgB;IAcpC,OAAO,CAAC,iBAAiB;IAgCzB,OAAO,CAAC,WAAW;IA0CnB;;OAEG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,GAAE,KAAK,GAAG,UAAkB,GAAG,IAAI;IAQ9D;;OAEG;IACH,SAAS,IAAI,IAAI;IAKjB;;OAEG;IACH,UAAU,IAAI,MAAM;IAIpB;;OAEG;IACG,GAAG,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,CAAC,CAAC;IAKxE;;OAEG;IACG,IAAI,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,CAAC,CAAC;IAKrF;;OAEG;IACG,GAAG,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,CAAC,CAAC;IAKpF;;OAEG;IACG,KAAK,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,CAAC,CAAC;IAKtF;;OAEG;IACG,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,CAAC,CAAC;CAI5E"}
|
package/dist/http/client.js
CHANGED
|
@@ -85,6 +85,12 @@ class HTTPClient {
|
|
|
85
85
|
delete this.client.defaults.headers.common['Authorization'];
|
|
86
86
|
delete this.client.defaults.headers.common['x-api-key'];
|
|
87
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* Get the base URL of the client
|
|
90
|
+
*/
|
|
91
|
+
getBaseURL() {
|
|
92
|
+
return this.config.baseURL;
|
|
93
|
+
}
|
|
88
94
|
/**
|
|
89
95
|
* GET request
|
|
90
96
|
*/
|
package/dist/http/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/http/client.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAwH;AACxH,sCAOmB;AAWnB;;GAEG;AACH,MAAa,UAAU;IAIrB,YAAY,MAAwB;QAClC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,eAAK,CAAC,MAAM,CAAC;YACzB,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,KAAK;YAChC,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,GAAG,MAAM,CAAC,OAAO;aAClB;SACF,CAAC,CAAC;QAEH,IAAI,CAAC,iBAAiB,EAAE,CAAC;IAC3B,CAAC;IAEO,iBAAiB;QACvB,sBAAsB;QACtB,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAClC,KAAK,EAAE,MAAM,EAAE,EAAE;YACf,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;gBAC1B,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;YAC7C,CAAC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC,EACD,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CACjC,CAAC;QAEF,uBAAuB;QACvB,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CACnC,KAAK,EAAE,QAAQ,EAAE,EAAE;YACjB,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,E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AAC;CACF;AA7JD,gCA6JC"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { HTTPClient } from '../http/client';
|
|
2
|
+
import { StorageConfigResponse, ConfigureStorageRequest, TestStorageResponse, DeleteStorageResponse } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Storage resource
|
|
5
|
+
* Manages storage provider configuration per tenant
|
|
6
|
+
*
|
|
7
|
+
* Requires API Token authentication (x-api-key header)
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const client = new WhatsAppAPIClient({
|
|
12
|
+
* baseURL: 'https://api.example.com',
|
|
13
|
+
* auth: { type: 'apiToken', token: 'wpp_live_xxx' }
|
|
14
|
+
* });
|
|
15
|
+
*
|
|
16
|
+
* // Get current storage configuration
|
|
17
|
+
* const config = await client.storage.getConfig('tenant-123');
|
|
18
|
+
* console.log(config.provider); // 'local' or 'spaces' or 's3'
|
|
19
|
+
*
|
|
20
|
+
* // Test connection before configuring
|
|
21
|
+
* const test = await client.storage.testConnection('tenant-123', {
|
|
22
|
+
* provider: 'spaces',
|
|
23
|
+
* spaces: {
|
|
24
|
+
* endpoint: 'nyc3.digitaloceanspaces.com',
|
|
25
|
+
* region: 'nyc3',
|
|
26
|
+
* bucket: 'my-wpp-media',
|
|
27
|
+
* accessKeyId: 'DO00...',
|
|
28
|
+
* secretAccessKey: '...'
|
|
29
|
+
* }
|
|
30
|
+
* });
|
|
31
|
+
*
|
|
32
|
+
* if (test.success) {
|
|
33
|
+
* // Configure storage
|
|
34
|
+
* await client.storage.configure('tenant-123', {
|
|
35
|
+
* provider: 'spaces',
|
|
36
|
+
* spaces: { ... }
|
|
37
|
+
* });
|
|
38
|
+
* }
|
|
39
|
+
*
|
|
40
|
+
* // Revert to local storage
|
|
41
|
+
* await client.storage.deleteConfig('tenant-123');
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare class StorageResource {
|
|
45
|
+
private http;
|
|
46
|
+
constructor(http: HTTPClient);
|
|
47
|
+
/**
|
|
48
|
+
* Get current storage configuration for a tenant
|
|
49
|
+
*
|
|
50
|
+
* Returns the configured storage provider and settings.
|
|
51
|
+
* Sensitive credentials are never returned in the response.
|
|
52
|
+
*
|
|
53
|
+
* @param tenantId - The tenant ID
|
|
54
|
+
* @returns Storage configuration (without sensitive data)
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* const config = await client.storage.getConfig('tenant-123');
|
|
59
|
+
* console.log(config.provider); // 'spaces'
|
|
60
|
+
* console.log(config.spaces?.bucket); // 'my-bucket'
|
|
61
|
+
* console.log(config.spaces?.hasCredentials); // true
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
getConfig(tenantId: string): Promise<StorageConfigResponse>;
|
|
65
|
+
/**
|
|
66
|
+
* Configure storage provider for a tenant
|
|
67
|
+
*
|
|
68
|
+
* Sets up the storage backend for media files. Supports:
|
|
69
|
+
* - `local`: Local filesystem (default, not recommended for production)
|
|
70
|
+
* - `spaces`: DigitalOcean Spaces (S3-compatible)
|
|
71
|
+
* - `s3`: AWS S3
|
|
72
|
+
*
|
|
73
|
+
* Credentials are encrypted before storage.
|
|
74
|
+
*
|
|
75
|
+
* @param tenantId - The tenant ID
|
|
76
|
+
* @param config - Storage configuration
|
|
77
|
+
* @returns Updated storage configuration
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* // Configure DigitalOcean Spaces
|
|
82
|
+
* await client.storage.configure('tenant-123', {
|
|
83
|
+
* provider: 'spaces',
|
|
84
|
+
* spaces: {
|
|
85
|
+
* endpoint: 'nyc3.digitaloceanspaces.com',
|
|
86
|
+
* region: 'nyc3',
|
|
87
|
+
* bucket: 'wpp-media',
|
|
88
|
+
* accessKeyId: 'DO00...',
|
|
89
|
+
* secretAccessKey: '...',
|
|
90
|
+
* cdnEndpoint: 'cdn.example.com' // optional
|
|
91
|
+
* }
|
|
92
|
+
* });
|
|
93
|
+
*
|
|
94
|
+
* // Configure local storage
|
|
95
|
+
* await client.storage.configure('tenant-123', {
|
|
96
|
+
* provider: 'local',
|
|
97
|
+
* local: { basePath: '/data/media' }
|
|
98
|
+
* });
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
configure(tenantId: string, config: ConfigureStorageRequest): Promise<StorageConfigResponse>;
|
|
102
|
+
/**
|
|
103
|
+
* Test storage connection before saving configuration
|
|
104
|
+
*
|
|
105
|
+
* Validates credentials and bucket access without persisting the config.
|
|
106
|
+
* Use this to verify settings before calling configure().
|
|
107
|
+
*
|
|
108
|
+
* @param tenantId - The tenant ID
|
|
109
|
+
* @param config - Storage configuration to test
|
|
110
|
+
* @returns Test result with success status and any errors
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```typescript
|
|
114
|
+
* const test = await client.storage.testConnection('tenant-123', {
|
|
115
|
+
* provider: 'spaces',
|
|
116
|
+
* spaces: {
|
|
117
|
+
* endpoint: 'nyc3.digitaloceanspaces.com',
|
|
118
|
+
* region: 'nyc3',
|
|
119
|
+
* bucket: 'my-bucket',
|
|
120
|
+
* accessKeyId: '...',
|
|
121
|
+
* secretAccessKey: '...'
|
|
122
|
+
* }
|
|
123
|
+
* });
|
|
124
|
+
*
|
|
125
|
+
* if (test.success) {
|
|
126
|
+
* console.log('Connection successful!');
|
|
127
|
+
* console.log('Details:', test.details);
|
|
128
|
+
* } else {
|
|
129
|
+
* console.error('Connection failed:', test.error);
|
|
130
|
+
* }
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
testConnection(tenantId: string, config: ConfigureStorageRequest): Promise<TestStorageResponse>;
|
|
134
|
+
/**
|
|
135
|
+
* Delete storage configuration (revert to local storage)
|
|
136
|
+
*
|
|
137
|
+
* Removes the storage configuration for a tenant, reverting to
|
|
138
|
+
* local filesystem storage.
|
|
139
|
+
*
|
|
140
|
+
* @param tenantId - The tenant ID
|
|
141
|
+
* @returns Success status
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```typescript
|
|
145
|
+
* await client.storage.deleteConfig('tenant-123');
|
|
146
|
+
* // Tenant now uses local storage
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
deleteConfig(tenantId: string): Promise<DeleteStorageResponse>;
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/resources/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,UAAU,CAAC;AAElB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,qBAAa,eAAe;IACd,OAAO,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAEpC;;;;;;;;;;;;;;;;OAgBG;IACG,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAIjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IACG,SAAS,CACb,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,uBAAuB,GAC9B,OAAO,CAAC,qBAAqB,CAAC;IAIjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACG,cAAc,CAClB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,uBAAuB,GAC9B,OAAO,CAAC,mBAAmB,CAAC;IAI/B;;;;;;;;;;;;;;OAcG;IACG,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAGrE"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StorageResource = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Storage resource
|
|
6
|
+
* Manages storage provider configuration per tenant
|
|
7
|
+
*
|
|
8
|
+
* Requires API Token authentication (x-api-key header)
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const client = new WhatsAppAPIClient({
|
|
13
|
+
* baseURL: 'https://api.example.com',
|
|
14
|
+
* auth: { type: 'apiToken', token: 'wpp_live_xxx' }
|
|
15
|
+
* });
|
|
16
|
+
*
|
|
17
|
+
* // Get current storage configuration
|
|
18
|
+
* const config = await client.storage.getConfig('tenant-123');
|
|
19
|
+
* console.log(config.provider); // 'local' or 'spaces' or 's3'
|
|
20
|
+
*
|
|
21
|
+
* // Test connection before configuring
|
|
22
|
+
* const test = await client.storage.testConnection('tenant-123', {
|
|
23
|
+
* provider: 'spaces',
|
|
24
|
+
* spaces: {
|
|
25
|
+
* endpoint: 'nyc3.digitaloceanspaces.com',
|
|
26
|
+
* region: 'nyc3',
|
|
27
|
+
* bucket: 'my-wpp-media',
|
|
28
|
+
* accessKeyId: 'DO00...',
|
|
29
|
+
* secretAccessKey: '...'
|
|
30
|
+
* }
|
|
31
|
+
* });
|
|
32
|
+
*
|
|
33
|
+
* if (test.success) {
|
|
34
|
+
* // Configure storage
|
|
35
|
+
* await client.storage.configure('tenant-123', {
|
|
36
|
+
* provider: 'spaces',
|
|
37
|
+
* spaces: { ... }
|
|
38
|
+
* });
|
|
39
|
+
* }
|
|
40
|
+
*
|
|
41
|
+
* // Revert to local storage
|
|
42
|
+
* await client.storage.deleteConfig('tenant-123');
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
class StorageResource {
|
|
46
|
+
constructor(http) {
|
|
47
|
+
this.http = http;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Get current storage configuration for a tenant
|
|
51
|
+
*
|
|
52
|
+
* Returns the configured storage provider and settings.
|
|
53
|
+
* Sensitive credentials are never returned in the response.
|
|
54
|
+
*
|
|
55
|
+
* @param tenantId - The tenant ID
|
|
56
|
+
* @returns Storage configuration (without sensitive data)
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* const config = await client.storage.getConfig('tenant-123');
|
|
61
|
+
* console.log(config.provider); // 'spaces'
|
|
62
|
+
* console.log(config.spaces?.bucket); // 'my-bucket'
|
|
63
|
+
* console.log(config.spaces?.hasCredentials); // true
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
async getConfig(tenantId) {
|
|
67
|
+
return this.http.get(`/wpp/${tenantId}/storage`);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Configure storage provider for a tenant
|
|
71
|
+
*
|
|
72
|
+
* Sets up the storage backend for media files. Supports:
|
|
73
|
+
* - `local`: Local filesystem (default, not recommended for production)
|
|
74
|
+
* - `spaces`: DigitalOcean Spaces (S3-compatible)
|
|
75
|
+
* - `s3`: AWS S3
|
|
76
|
+
*
|
|
77
|
+
* Credentials are encrypted before storage.
|
|
78
|
+
*
|
|
79
|
+
* @param tenantId - The tenant ID
|
|
80
|
+
* @param config - Storage configuration
|
|
81
|
+
* @returns Updated storage configuration
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* // Configure DigitalOcean Spaces
|
|
86
|
+
* await client.storage.configure('tenant-123', {
|
|
87
|
+
* provider: 'spaces',
|
|
88
|
+
* spaces: {
|
|
89
|
+
* endpoint: 'nyc3.digitaloceanspaces.com',
|
|
90
|
+
* region: 'nyc3',
|
|
91
|
+
* bucket: 'wpp-media',
|
|
92
|
+
* accessKeyId: 'DO00...',
|
|
93
|
+
* secretAccessKey: '...',
|
|
94
|
+
* cdnEndpoint: 'cdn.example.com' // optional
|
|
95
|
+
* }
|
|
96
|
+
* });
|
|
97
|
+
*
|
|
98
|
+
* // Configure local storage
|
|
99
|
+
* await client.storage.configure('tenant-123', {
|
|
100
|
+
* provider: 'local',
|
|
101
|
+
* local: { basePath: '/data/media' }
|
|
102
|
+
* });
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
async configure(tenantId, config) {
|
|
106
|
+
return this.http.post(`/wpp/${tenantId}/storage`, config);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Test storage connection before saving configuration
|
|
110
|
+
*
|
|
111
|
+
* Validates credentials and bucket access without persisting the config.
|
|
112
|
+
* Use this to verify settings before calling configure().
|
|
113
|
+
*
|
|
114
|
+
* @param tenantId - The tenant ID
|
|
115
|
+
* @param config - Storage configuration to test
|
|
116
|
+
* @returns Test result with success status and any errors
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```typescript
|
|
120
|
+
* const test = await client.storage.testConnection('tenant-123', {
|
|
121
|
+
* provider: 'spaces',
|
|
122
|
+
* spaces: {
|
|
123
|
+
* endpoint: 'nyc3.digitaloceanspaces.com',
|
|
124
|
+
* region: 'nyc3',
|
|
125
|
+
* bucket: 'my-bucket',
|
|
126
|
+
* accessKeyId: '...',
|
|
127
|
+
* secretAccessKey: '...'
|
|
128
|
+
* }
|
|
129
|
+
* });
|
|
130
|
+
*
|
|
131
|
+
* if (test.success) {
|
|
132
|
+
* console.log('Connection successful!');
|
|
133
|
+
* console.log('Details:', test.details);
|
|
134
|
+
* } else {
|
|
135
|
+
* console.error('Connection failed:', test.error);
|
|
136
|
+
* }
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
async testConnection(tenantId, config) {
|
|
140
|
+
return this.http.post(`/wpp/${tenantId}/storage/test`, config);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Delete storage configuration (revert to local storage)
|
|
144
|
+
*
|
|
145
|
+
* Removes the storage configuration for a tenant, reverting to
|
|
146
|
+
* local filesystem storage.
|
|
147
|
+
*
|
|
148
|
+
* @param tenantId - The tenant ID
|
|
149
|
+
* @returns Success status
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```typescript
|
|
153
|
+
* await client.storage.deleteConfig('tenant-123');
|
|
154
|
+
* // Tenant now uses local storage
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
async deleteConfig(tenantId) {
|
|
158
|
+
return this.http.delete(`/wpp/${tenantId}/storage`);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
exports.StorageResource = StorageResource;
|
|
162
|
+
//# sourceMappingURL=storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../src/resources/storage.ts"],"names":[],"mappings":";;;AAQA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MAAa,eAAe;IAC1B,YAAoB,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAExC;;;;;;;;;;;;;;;;OAgBG;IACH,KAAK,CAAC,SAAS,CAAC,QAAgB;QAC9B,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAwB,QAAQ,QAAQ,UAAU,CAAC,CAAC;IAC1E,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IACH,KAAK,CAAC,SAAS,CACb,QAAgB,EAChB,MAA+B;QAE/B,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAwB,QAAQ,QAAQ,UAAU,EAAE,MAAM,CAAC,CAAC;IACnF,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,KAAK,CAAC,cAAc,CAClB,QAAgB,EAChB,MAA+B;QAE/B,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAsB,QAAQ,QAAQ,eAAe,EAAE,MAAM,CAAC,CAAC;IACtF,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,KAAK,CAAC,YAAY,CAAC,QAAgB;QACjC,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAwB,QAAQ,QAAQ,UAAU,CAAC,CAAC;IAC7E,CAAC;CACF;AA3HD,0CA2HC"}
|