planvortex 0.18.1 → 0.20.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/README.md +20 -3
- package/dist/{chunk-ZHS7FY3T.js → chunk-DRVCK5JO.js} +7 -3
- package/dist/chunk-DRVCK5JO.js.map +1 -0
- package/dist/{index-6DpRjLs4.d.cts → index-BQPQczjR.d.cts} +229 -19
- package/dist/{index-6DpRjLs4.d.ts → index-BQPQczjR.d.ts} +229 -19
- package/dist/index.cjs +84 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +61 -6
- package/dist/index.d.ts +61 -6
- package/dist/index.js +81 -3
- package/dist/index.js.map +1 -1
- package/dist/webhooks/index.cjs +10 -1
- package/dist/webhooks/index.cjs.map +1 -1
- package/dist/webhooks/index.d.cts +1 -1
- package/dist/webhooks/index.d.ts +1 -1
- package/dist/webhooks/index.js +6 -2
- package/dist/webhooks/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-ZHS7FY3T.js.map +0 -1
|
@@ -991,7 +991,7 @@ interface paths {
|
|
|
991
991
|
* Re-enable a disconnected account
|
|
992
992
|
* @description Brings back an account that was removed, without going through the authorization again — as long as its stored token still works.
|
|
993
993
|
*
|
|
994
|
-
* It takes a **slot of the plan**, so it fails with error 706 when the organization is already at its account limit. It also turns the network's webhooks back on, on any plan but the free one.
|
|
994
|
+
* It takes a **slot of the plan**, so it fails with error 706 when the organization is already at its account limit. It also turns the network's webhooks back on, on any plan but the free one. On the free plan a `whatsapp` account that is not active cannot be enabled (error 516), because its chat and its templates need a paid plan. One that is already active can still be reconnected.
|
|
995
995
|
*
|
|
996
996
|
* **On `telegram` you normally never call this.** That network's accounts are born active — there is no authorization return in which to choose them, so PlanVortex takes the slot when the bot is added to the channel. The one case left is a channel that arrived while the plan was full: it stays off until a slot frees up, and this is what turns it on.
|
|
997
997
|
*
|
|
@@ -1017,6 +1017,10 @@ interface paths {
|
|
|
1017
1017
|
*
|
|
1018
1018
|
* The shape of a template is the network's own: PlanVortex does not normalise it.
|
|
1019
1019
|
*
|
|
1020
|
+
* **A rejected template says why.** WhatsApp templates carry `rejected_reason` (`INVALID_FORMAT`, `PROMOTIONAL`, `TAG_CONTENT_MISMATCH`...) next to their `status`, as WhatsApp sends it.
|
|
1021
|
+
*
|
|
1022
|
+
* **`health` says whether the account can start conversations at all.** A template is only needed outside the 24-hour window, which is exactly what a failed payment method or an unverified business blocks, and neither of them fails when you create or approve a template: the message is simply never delivered. `health` is WhatsApp's own status for the phone number, reduced to `can_send_message` (`AVAILABLE`, `LIMITED`, `BLOCKED`), the `issues` behind it with WhatsApp's code (141006 = payment method, 141010 = business not verified) and `notes`. When it can't be read the field is absent, which means unknown, not healthy.
|
|
1023
|
+
*
|
|
1020
1024
|
* **WhatsApp only.** No other network implements message templates: asking any of them returns HTTP 500 with `code: 500` (an unhandled server error), not the 1502 you would expect. Check `messages` in `GET /social_capabilities` and that the account is WhatsApp before calling.
|
|
1021
1025
|
*/
|
|
1022
1026
|
get: operations["getMessageTemplates"];
|
|
@@ -1027,6 +1031,10 @@ interface paths {
|
|
|
1027
1031
|
*
|
|
1028
1032
|
* **Approval is not immediate.** The template comes back in a pending state and only becomes usable when the network approves it, which takes minutes or hours and can be refused.
|
|
1029
1033
|
*
|
|
1034
|
+
* **WhatsApp templates are checked before they leave.** WhatsApp rejects a badly formatted template in the same second with `INVALID_FORMAT` and no explanation, so PlanVortex checks the rules it documents first and answers **1513** with `data.field` and `data.reason`: `invalid_name` (lowercase letters, numbers and underscores only), `missing_language`, `missing_body`, `body_too_long` (1,024 characters), `malformed_variable`, `variables_not_sequential`, `variable_at_edge` (the text can't start or end with a variable), `adjacent_variables` and `missing_examples`. **A body with variables needs one example per variable** in `example.body_text`, as in the example below.
|
|
1035
|
+
*
|
|
1036
|
+
* If WhatsApp refuses the template when it is created (a language it doesn't have, a name already in use), the answer is **1514** with WhatsApp's own `code`, `subcode` and `message` in `data`.
|
|
1037
|
+
*
|
|
1030
1038
|
* **WhatsApp only.** No other network implements message templates: asking any of them returns HTTP 500 with `code: 500` (an unhandled server error), not the 1502 you would expect. Check `messages` in `GET /social_capabilities` and that the account is WhatsApp before calling.
|
|
1031
1039
|
*/
|
|
1032
1040
|
post: operations["createMessageTemplate"];
|
|
@@ -1097,6 +1105,35 @@ interface paths {
|
|
|
1097
1105
|
patch?: never;
|
|
1098
1106
|
trace?: never;
|
|
1099
1107
|
};
|
|
1108
|
+
"/organizations/{id_organization}/accounts/{id_account}/messages/{id_message}/files/{index}": {
|
|
1109
|
+
parameters: {
|
|
1110
|
+
query?: never;
|
|
1111
|
+
header?: never;
|
|
1112
|
+
path?: never;
|
|
1113
|
+
cookie?: never;
|
|
1114
|
+
};
|
|
1115
|
+
/**
|
|
1116
|
+
* One file of a message, fetched from the network
|
|
1117
|
+
* @description Files that arrive in a message (a photo, a video, a voice note, a document, a sticker) **are not stored by PlanVortex**: they stay on the network, and `message_options.files_urls` says where each one is.
|
|
1118
|
+
*
|
|
1119
|
+
* • **With `url`** (Instagram and Messenger): Meta's own CDN link. It works until Meta expires it.
|
|
1120
|
+
* • **Without `url`** (every WhatsApp file): WhatsApp only hands a file over with the account's token, through a link that lasts five minutes, so there is no link to give you.
|
|
1121
|
+
*
|
|
1122
|
+
* Either way, this endpoint asks the network for the file now and streams it back without keeping a copy. `index` is the file's position in `files_urls`. `message_options.files` holds only the files **you** sent from PlanVortex, which are uploads.
|
|
1123
|
+
*
|
|
1124
|
+
* **The network decides how long a file lives.** WhatsApp lets go of a file 7 days after it arrived, and Meta drops one when the message or the story is deleted. After that the answer is **1515**, with `data.social_network`; on a number that also runs the WhatsApp Business app, the file is still there. **1516** means the message is not from this account, or has no file at that position.
|
|
1125
|
+
*
|
|
1126
|
+
* Images, videos and audio come back `inline`. Anything else (a PDF, a spreadsheet, an HTML file, an SVG) comes back as an `attachment`: someone outside the business sent it, so don't render it inside your own pages.
|
|
1127
|
+
*/
|
|
1128
|
+
get: operations["getMessageFile"];
|
|
1129
|
+
put?: never;
|
|
1130
|
+
post?: never;
|
|
1131
|
+
delete?: never;
|
|
1132
|
+
options?: never;
|
|
1133
|
+
head?: never;
|
|
1134
|
+
patch?: never;
|
|
1135
|
+
trace?: never;
|
|
1136
|
+
};
|
|
1100
1137
|
"/organizations/{id_organization}/accounts/{id_account}/metric_list": {
|
|
1101
1138
|
parameters: {
|
|
1102
1139
|
query?: never;
|
|
@@ -1419,6 +1456,40 @@ interface paths {
|
|
|
1419
1456
|
patch?: never;
|
|
1420
1457
|
trace?: never;
|
|
1421
1458
|
};
|
|
1459
|
+
"/organizations/{id_organization}/comments/{id_comment}/files/{index}": {
|
|
1460
|
+
parameters: {
|
|
1461
|
+
query?: never;
|
|
1462
|
+
header?: never;
|
|
1463
|
+
path?: never;
|
|
1464
|
+
cookie?: never;
|
|
1465
|
+
};
|
|
1466
|
+
/**
|
|
1467
|
+
* One file of a comment, fetched from the network
|
|
1468
|
+
* @description Files in a comment (a photo, a GIF, a sticker, a video) **are not stored by PlanVortex**: they stay on the network, and the comment's `files_urls` says where each one is. This endpoint asks the network for the file now and streams it back without keeping a copy. `index` is the file's position in `files_urls`.
|
|
1469
|
+
*
|
|
1470
|
+
* You need it when a file has no `url`, or when its `url` stopped loading:
|
|
1471
|
+
*
|
|
1472
|
+
* • **LinkedIn** gives only the image's id, never a link.
|
|
1473
|
+
* • **Telegram**'s download link carries the bot's token, so it never leaves PlanVortex. A bot can only download up to 20 MB: past that the answer is **1515** with `data.reason: "too_big"`, and the file is only visible in Telegram.
|
|
1474
|
+
* • **Bluesky** videos are an HLS playlist that browsers other than Safari do not play; this returns the video file itself.
|
|
1475
|
+
* • **Facebook, Threads and Discord** links expire; this reads the comment again and returns the file behind a fresh link.
|
|
1476
|
+
* • **X** links do not expire, and reading a post again costs money, so X is not re-read: if its `url` no longer loads, the post was deleted and the answer is **1515**.
|
|
1477
|
+
*
|
|
1478
|
+
* **1515** means the network no longer has the file (`data.social_network`), and **2602** that the comment has no file at that position. A comment of another organization is **1102**.
|
|
1479
|
+
*
|
|
1480
|
+
* Images, videos and audio come back `inline`. Anything else comes back as an `attachment`: someone outside the business posted it, so don't render it inside your own pages.
|
|
1481
|
+
*
|
|
1482
|
+
* Requires the `comments:read` permission (`client_organization_comments:read` for apps) and a paid plan.
|
|
1483
|
+
*/
|
|
1484
|
+
get: operations["getCommentFile"];
|
|
1485
|
+
put?: never;
|
|
1486
|
+
post?: never;
|
|
1487
|
+
delete?: never;
|
|
1488
|
+
options?: never;
|
|
1489
|
+
head?: never;
|
|
1490
|
+
patch?: never;
|
|
1491
|
+
trace?: never;
|
|
1492
|
+
};
|
|
1422
1493
|
"/organizations/{id_organization}/comments/{id_comment}/replies": {
|
|
1423
1494
|
parameters: {
|
|
1424
1495
|
query?: never;
|
|
@@ -1490,6 +1561,8 @@ interface paths {
|
|
|
1490
1561
|
*
|
|
1491
1562
|
* **A network that cannot produce a link simply does not appear.** That is a legitimate answer, not a failure: it is what happens with `discord` in an organization that has not saved its own bot credentials yet (see `PUT /organizations/{id_organization}/social_credentials/{social_network}`).
|
|
1492
1563
|
*
|
|
1564
|
+
* **On the free plan `whatsapp` does not appear either**, unless the organization already has an active WhatsApp account, which has to stay reconnectable. Its chat and its templates need a paid plan, so enabling a new account answers error 516. Asking for it by name gets you an empty list, not an error.
|
|
1565
|
+
*
|
|
1493
1566
|
* **An app cannot call this.** Connecting a social account is an OAuth flow with a person in front of it, so this endpoint only accepts a user token or a temporal connect token; with app credentials it answers error 519. The way an integration does it is to issue a temporal connect token with `GET /organizations/{id_organization}/temporal_connect_token` and hand it to its end user.
|
|
1494
1567
|
*
|
|
1495
1568
|
* **Read `authorization`, not `link`.** Almost every network is `redirect` and you send the person to `link`. Two are not, and neither of them fails visibly if you treat it as one:
|
|
@@ -2335,7 +2408,7 @@ interface paths {
|
|
|
2335
2408
|
*
|
|
2336
2409
|
* **It connects once.** As soon as an `account-connect` succeeds, the token stops being able to connect anything else and answers error 543; the `enable` calls that finish that same connection keep working until it expires. Issue a new one per connection — they are free and immediate.
|
|
2337
2410
|
*
|
|
2338
|
-
* **If you pass `social_network`, the token is bound to that network** and will not connect any other (error 544). Leave it out to let the person pick.
|
|
2411
|
+
* **If you pass `social_network`, the token is bound to that network** and will not connect any other (error 544). Leave it out to let the person pick. On the free plan, asking for `whatsapp` answers error 516 unless the organization already has an active WhatsApp account to reconnect: its chat and its templates need a paid plan.
|
|
2339
2412
|
*
|
|
2340
2413
|
* **Or show the account picker yourself** with `account_selection=integrator`. By default PlanVortex shows the screen where the person picks which accounts to enable, and only then sends them to your `redirect_uri`. In this mode that screen is yours:
|
|
2341
2414
|
*
|
|
@@ -2711,7 +2784,7 @@ interface webhooks {
|
|
|
2711
2784
|
*
|
|
2712
2785
|
* Three shapes travel in that array. A change on an **account** (`WebhookChange`) always carries `id_account`, `id_organization` and `social_network`. A change on an **integration** (`IntegrationWebhookChange`) and the end of an **AI plan** (`AiPlanWebhookChange`) carry none of those, because they hang off the organization and not off any account.
|
|
2713
2786
|
*
|
|
2714
|
-
* The events delivered today are `new_account`, `change_state_account`, `messages`, `messaging_postbacks`, `messaging_seen`, `messaging_error`, `comments`, `integration_error`, `ai_plan_generated` and `ai_plan_failed`.
|
|
2787
|
+
* The events delivered today are `new_account`, `change_state_account`, `messages`, `messaging_postbacks`, `messaging_seen`, `messaging_error`, `message_echoes`, `comments`, `integration_error`, `ai_plan_generated` and `ai_plan_failed`.
|
|
2715
2788
|
*
|
|
2716
2789
|
* ### Comments
|
|
2717
2790
|
*
|
|
@@ -2729,6 +2802,12 @@ interface webhooks {
|
|
|
2729
2802
|
*
|
|
2730
2803
|
* The event goes to **every** app of the client that has a `webhook_url`, not only to the one that created the plan. And it is not retried: if your endpoint was down when the plan finished, the `GET` still tells you how it ended, so on startup read the plans you were waiting for.
|
|
2731
2804
|
*
|
|
2805
|
+
* ### WhatsApp replies sent from the phone
|
|
2806
|
+
*
|
|
2807
|
+
* A WhatsApp number can work in the **WhatsApp Business app** on a phone and in PlanVortex at the same time. What the business sends from the app arrives as `field: "message_echoes"`, with the message in `messageObj` as one of **ours**: `contact_id` is the person it was sent to and `from_contact_id` is absent. Store it in the thread; do not answer it. It does not open WhatsApp's 24-hour window.
|
|
2808
|
+
*
|
|
2809
|
+
* When a contact edits or deletes a message, no event is sent: the message itself changes, and the next read returns it with `edit_date` or `deleted_date`.
|
|
2810
|
+
*
|
|
2732
2811
|
* ### Verifying the signature
|
|
2733
2812
|
*
|
|
2734
2813
|
* Every delivery carries the body signed with your app's secret, twice:
|
|
@@ -3411,7 +3490,7 @@ interface components {
|
|
|
3411
3490
|
*
|
|
3412
3491
|
* **The body is an array of changes, not a single object**, and it carries two signature headers computed with this app's secret over the **raw** body: `x-hub-signature` (`sha1=<hex>`) and `x-hub-signature-256` (`sha256=<hex>`). Verify against the bytes you received — parsing the JSON and re-serialising it changes them and the signature will not match.
|
|
3413
3492
|
*
|
|
3414
|
-
* The events delivered today are `new_account`, `change_state_account`, `messages`, `messaging_postbacks`, `messaging_seen`, `messaging_error`, `comments`, `integration_error`, `ai_plan_generated` and `ai_plan_failed`. The payload is documented in the `comments` specification. **Every** app of the client that has a `webhook_url` receives every event, not only the app whose call caused it: with two apps, each event arrives twice. Delivery is best effort: PlanVortex does not retry a webhook that fails.
|
|
3493
|
+
* The events delivered today are `new_account`, `change_state_account`, `messages`, `messaging_postbacks`, `messaging_seen`, `messaging_error`, `message_echoes`, `comments`, `integration_error`, `ai_plan_generated` and `ai_plan_failed`. The payload is documented in the `comments` specification. **Every** app of the client that has a `webhook_url` receives every event, not only the app whose call caused it: with two apps, each event arrives twice. Delivery is best effort: PlanVortex does not retry a webhook that fails.
|
|
3415
3494
|
*/
|
|
3416
3495
|
webhook_url?: string;
|
|
3417
3496
|
};
|
|
@@ -3765,6 +3844,12 @@ interface components {
|
|
|
3765
3844
|
* • A Telegram comment lives in a **different chat** from the post it answers (the channel's linked discussion group), so it needs two ids at once and travels as `{thread}/{message}`: replying wants the first, deleting wants the second.
|
|
3766
3845
|
*/
|
|
3767
3846
|
external_id: string;
|
|
3847
|
+
/**
|
|
3848
|
+
* @description The comment's files: a photo, a GIF, a sticker, a video. **PlanVortex does not store them** (see `SocialFileUrl`): open `url` when there is one, and when there is not, or it stops loading, fetch the file with `GET /organizations/{id_organization}/comments/{id_comment}/files/{index}`.
|
|
3849
|
+
*
|
|
3850
|
+
* Facebook, Threads, LinkedIn, X, Bluesky, Discord and Telegram give a comment's files, and on Google Business they are the photos and videos of a review. Instagram and YouTube do not expose them in their APIs, so there the list is always empty. A comment that is only a photo has an empty `text` and one file here.
|
|
3851
|
+
*/
|
|
3852
|
+
files_urls?: components["schemas"]["SocialFileUrl"][];
|
|
3768
3853
|
/** @description Hidden on the network. A hidden comment is never swept as deleted: on YouTube, hiding one makes the API stop returning it forever, and without that exception hiding would be indistinguishable from deleting. */
|
|
3769
3854
|
hidden: boolean;
|
|
3770
3855
|
/**
|
|
@@ -3801,7 +3886,7 @@ interface components {
|
|
|
3801
3886
|
/** @description Absent when the network does not publish it — not zero */
|
|
3802
3887
|
reply_count?: number;
|
|
3803
3888
|
social_network: components["schemas"]["CommentsCommentNetworkName"];
|
|
3804
|
-
/** @description **May legitimately be empty.** A stars-only review carries no text at all, so render `rating` alongside it and never assume a blank comment is a loading failure. */
|
|
3889
|
+
/** @description **May legitimately be empty.** A stars-only review carries no text at all, and a comment can be only a photo or a sticker (see `files_urls`), so render `rating` and the files alongside it and never assume a blank comment is a loading failure. */
|
|
3805
3890
|
text: string;
|
|
3806
3891
|
};
|
|
3807
3892
|
/** @description What one network lets you do to a comment. Four booleans and never fewer: an absent key would be indistinguishable from an oversight. */
|
|
@@ -3889,15 +3974,16 @@ interface components {
|
|
|
3889
3974
|
/**
|
|
3890
3975
|
* @description What kind of change this is. **Treat it as an open list** and ignore what you do not handle: it grows with the product.
|
|
3891
3976
|
*
|
|
3892
|
-
* - `new_account` / `change_state_account`: an account was connected, or its state changed — it stopped working, its token was refreshed, it was disconnected. On `telegram` this is the **only** way to hear about a connection: there is no callback there, so no request of yours ever returns that account.
|
|
3977
|
+
* - `new_account` / `change_state_account`: an account was connected, or its state changed — it stopped working, its token was refreshed, it was disconnected. A WhatsApp number disconnected from the WhatsApp Business app (or by Meta, after about 14 days without the phone using the app) arrives here with `error_code` 717. On `telegram` this is the **only** way to hear about a connection: there is no callback there, so no request of yours ever returns that account.
|
|
3893
3978
|
* - `messages`: a message came in. It travels in `messageObj`.
|
|
3894
3979
|
* - `messaging_postbacks`: the contact pressed a button or a quick reply. Also in `messageObj`.
|
|
3895
3980
|
* - `messaging_seen`: the contact read the conversation. `messageObj` carries the message they read, when we still have it.
|
|
3896
3981
|
* - `messaging_error`: the network refused a message we sent. The reason is in `messageObj.message_errors`.
|
|
3982
|
+
* - `message_echoes`: WhatsApp only, when the number is also used in the **WhatsApp Business app** on a phone. The business replied from the app, and the reply travels in `messageObj` as **our** message (`contact_id` is set, `from_contact_id` is not). It is a separate `field` on purpose: a bot that answers every `messages` must not answer the business itself.
|
|
3897
3983
|
* - `comments`: a comment came in. It travels in `commentObj`, never in `messageObj`.
|
|
3898
3984
|
* @enum {string}
|
|
3899
3985
|
*/
|
|
3900
|
-
field: "new_account" | "change_state_account" | "messages" | "messaging_postbacks" | "messaging_seen" | "messaging_error" | "comments";
|
|
3986
|
+
field: "new_account" | "change_state_account" | "messages" | "messaging_postbacks" | "messaging_seen" | "messaging_error" | "message_echoes" | "comments";
|
|
3901
3987
|
id_account: string;
|
|
3902
3988
|
/** @description Only for messaging fields. A comment has no contact: its author is not someone you can write to. */
|
|
3903
3989
|
id_contact?: string;
|
|
@@ -4236,7 +4322,7 @@ interface components {
|
|
|
4236
4322
|
* The catalogue grows with the product, so treat an unknown `code` as a generic failure instead of rejecting it.
|
|
4237
4323
|
*/
|
|
4238
4324
|
Error: {
|
|
4239
|
-
/** @description PlanVortex error code. Ranges: 500-554 auth, tokens, client apps and connect sessions · 601-612 user · 700-716 social accounts · 800-810 files · 900-996 publications · 1000-1003 general · 1100-1111 organizations · 1200-1207 roles · 1300-
|
|
4325
|
+
/** @description PlanVortex error code. Ranges: 500-554 auth, tokens, client apps and connect sessions · 601-612 user · 700-716 social accounts · 800-810 files · 900-996 publications · 1000-1003 general · 1100-1111 organizations · 1200-1207 roles · 1300-1309 client plan · 1400-1408 organization plan · 1500-1516 messaging · 1600-1601 contacts · 1900-1906 payments · 2000-2099 products · 2100-2199 AI plans · 2200-2299 integrations · 2500-2599 publication fields, the ones that no longer fit in 900-996 (visibility, made for kids, TikTok's interactions and commercial content) · 2600-2699 comments, the ones that no longer fit in 945-948. */
|
|
4240
4326
|
code: number;
|
|
4241
4327
|
/** @description Extra context attached to the error, when there is any. */
|
|
4242
4328
|
data?: {
|
|
@@ -4470,6 +4556,16 @@ interface components {
|
|
|
4470
4556
|
contact_id?: string | components["schemas"]["Contact"];
|
|
4471
4557
|
/** Format: date-time */
|
|
4472
4558
|
creation_date: string;
|
|
4559
|
+
/**
|
|
4560
|
+
* Format: date-time
|
|
4561
|
+
* @description When the contact **deleted** this message for everyone (WhatsApp allows it for two days). The message stays in the thread with no `text` and no files.
|
|
4562
|
+
*/
|
|
4563
|
+
deleted_date?: string;
|
|
4564
|
+
/**
|
|
4565
|
+
* Format: date-time
|
|
4566
|
+
* @description When the contact **edited** this message on the network (WhatsApp allows it for 15 minutes). `text` is already the edited text; the original is not kept.
|
|
4567
|
+
*/
|
|
4568
|
+
edit_date?: string;
|
|
4473
4569
|
/** @description Identifier of this message on the network. */
|
|
4474
4570
|
element_external_id?: string;
|
|
4475
4571
|
/** @description Set when the **contact** wrote to us. */
|
|
@@ -4491,11 +4587,8 @@ interface components {
|
|
|
4491
4587
|
MessageOptions: {
|
|
4492
4588
|
/** @description The uploads attached to the message. **Populated** wherever the message itself is: the messages list and webhook deliveries carry whole uploads, everything else carries their identifiers. Handle both. */
|
|
4493
4589
|
files: (string | components["schemas"]["Upload"])[];
|
|
4494
|
-
/** @description Files
|
|
4495
|
-
files_urls:
|
|
4496
|
-
mime_type?: string;
|
|
4497
|
-
url?: string;
|
|
4498
|
-
}[];
|
|
4590
|
+
/** @description Files that arrived with the message from the network. PlanVortex does not store them: they live on the network (see `SocialFileUrl`). On WhatsApp every file is here, photos and videos included, and none has a `url`. */
|
|
4591
|
+
files_urls: components["schemas"]["SocialFileUrl"][];
|
|
4499
4592
|
/** @description Meta cards, for `elements_message` and `button_message`. */
|
|
4500
4593
|
metaElements?: {
|
|
4501
4594
|
[key: string]: unknown;
|
|
@@ -4564,9 +4657,11 @@ interface components {
|
|
|
4564
4657
|
};
|
|
4565
4658
|
/**
|
|
4566
4659
|
* @description What kind of message this is. `simple_message` and `file_message` work everywhere; the rest are network-specific shapes.
|
|
4660
|
+
*
|
|
4661
|
+
* `unsupported_message` only ever **arrives**: a WhatsApp message that cannot be shown through the API (a voice note, a document, a sticker, or a type WhatsApp does not let the API read). It carries no files, keeps the caption as `text` when there is one, and may carry the network's reason in `message_errors`. If the number is also in the WhatsApp Business app, the message can be read there. Sending one is refused.
|
|
4567
4662
|
* @enum {string}
|
|
4568
4663
|
*/
|
|
4569
|
-
MessageType: "simple_message" | "file_message" | "comment_message" | "publication_message" | "quick_reply_message" | "button_message" | "elements_message" | "postback_message" | "template_message" | "interactive_message";
|
|
4664
|
+
MessageType: "simple_message" | "file_message" | "comment_message" | "publication_message" | "quick_reply_message" | "button_message" | "elements_message" | "postback_message" | "template_message" | "interactive_message" | "unsupported_message";
|
|
4570
4665
|
/**
|
|
4571
4666
|
* @description Metrics translated to a **common vocabulary** shared by every network, which is what makes two networks comparable and summable (each network names them differently: `page_post_engagements`, `total_interactions`, `views`…).
|
|
4572
4667
|
*
|
|
@@ -5353,6 +5448,24 @@ interface components {
|
|
|
5353
5448
|
*/
|
|
5354
5449
|
verified_date?: string;
|
|
5355
5450
|
};
|
|
5451
|
+
/**
|
|
5452
|
+
* @description A file that arrived from the network: a photo, a video, a voice note, a document or a sticker in a private message or a comment. **PlanVortex does not store it**: it stays on the network, and this says where to find it.
|
|
5453
|
+
*
|
|
5454
|
+
* • **With `url`**: the network's own link, which your page can load directly. On Instagram, Messenger, Facebook, Threads and Discord it **expires**; on X and Bluesky it does not.
|
|
5455
|
+
* • **Without `url`**: the network only hands the file over with a token that never leaves PlanVortex (WhatsApp, and Telegram, whose download link carries the bot's token), or gives only an identifier (LinkedIn, a Bluesky video). Fetch it through the API.
|
|
5456
|
+
*
|
|
5457
|
+
* Either way, when `url` is missing or stops loading, fetch the file with `GET .../messages/{id_message}/files/{index}` or `GET .../comments/{id_comment}/files/{index}`, where `index` is its position in the list. PlanVortex asks the network for it at that moment and streams it back without keeping a copy.
|
|
5458
|
+
*/
|
|
5459
|
+
SocialFileUrl: {
|
|
5460
|
+
/** @description The file's id on the network (WhatsApp's media id, Telegram's `file_id`, a Bluesky CID, a LinkedIn image URN). Treat it as opaque. */
|
|
5461
|
+
external_id?: string;
|
|
5462
|
+
/** @description Always present, so you can decide how to show it. When the network does not say, it is the most likely type: the file fetched through the API comes with its real `Content-Type`. */
|
|
5463
|
+
mime_type: string;
|
|
5464
|
+
/** @description The document's file name, when the network gives one. */
|
|
5465
|
+
name?: string;
|
|
5466
|
+
/** @description The network's direct link, when there is one a browser can open. It may expire. Never present on WhatsApp, Telegram, LinkedIn or a Bluesky video. */
|
|
5467
|
+
url?: string;
|
|
5468
|
+
};
|
|
5356
5469
|
/** @description The same person, on one channel. */
|
|
5357
5470
|
SocialIdentifier: {
|
|
5358
5471
|
_id: string;
|
|
@@ -8339,6 +8452,7 @@ interface operations {
|
|
|
8339
8452
|
* | --- | --- |
|
|
8340
8453
|
* | `700` | The account has no usable token: it has to be connected again |
|
|
8341
8454
|
* | `706` | The organization has no account slots left in its plan |
|
|
8455
|
+
* | `516` | The plan is free and this network needs a paid plan (today, `whatsapp`) |
|
|
8342
8456
|
* | `519` | This endpoint does not accept app credentials |
|
|
8343
8457
|
* | `544` | This temporal connect token was issued for a different social network |
|
|
8344
8458
|
*/
|
|
@@ -8385,7 +8499,23 @@ interface operations {
|
|
|
8385
8499
|
};
|
|
8386
8500
|
content: {
|
|
8387
8501
|
"application/json": {
|
|
8388
|
-
/** @description
|
|
8502
|
+
/** @description Whether the account can start conversations. WhatsApp only, and absent when it couldn't be read. */
|
|
8503
|
+
health?: {
|
|
8504
|
+
/** @enum {string} */
|
|
8505
|
+
can_send_message: "AVAILABLE" | "LIMITED" | "BLOCKED";
|
|
8506
|
+
/** @description What blocks or limits it. Calling (SIP) errors are left out: they don't affect messaging. */
|
|
8507
|
+
issues: {
|
|
8508
|
+
/** @description WhatsApp's code: 141006 = payment method, 141010 = business not verified. */
|
|
8509
|
+
code: number;
|
|
8510
|
+
description?: string;
|
|
8511
|
+
/** @description Where the problem is: `PHONE_NUMBER`, `WABA`, `BUSINESS` or `APP`. */
|
|
8512
|
+
entity_type: string;
|
|
8513
|
+
solution?: string;
|
|
8514
|
+
}[];
|
|
8515
|
+
/** @description Warnings that are not errors, such as a display name still pending approval. */
|
|
8516
|
+
notes: string[];
|
|
8517
|
+
};
|
|
8518
|
+
/** @description Templates as the network returns them. For WhatsApp: `id`, `name`, `status`, `category`, `language`, `components` and, when rejected, `rejected_reason`. */
|
|
8389
8519
|
templates: {
|
|
8390
8520
|
[key: string]: unknown;
|
|
8391
8521
|
}[];
|
|
@@ -8559,6 +8689,36 @@ interface operations {
|
|
|
8559
8689
|
400: components["responses"]["MessagesError"];
|
|
8560
8690
|
};
|
|
8561
8691
|
};
|
|
8692
|
+
getMessageFile: {
|
|
8693
|
+
parameters: {
|
|
8694
|
+
query?: never;
|
|
8695
|
+
header?: never;
|
|
8696
|
+
path: {
|
|
8697
|
+
/** @description Connected account identifier */
|
|
8698
|
+
id_account: components["parameters"]["MessagesidAccount"];
|
|
8699
|
+
/** @description The message's `_id`. */
|
|
8700
|
+
id_message: string;
|
|
8701
|
+
/** @description Organization identifier */
|
|
8702
|
+
id_organization: components["parameters"]["MessagesidOrganization"];
|
|
8703
|
+
/** @description Position of the file in `message_options.files_urls`, from 0. */
|
|
8704
|
+
index: number;
|
|
8705
|
+
};
|
|
8706
|
+
cookie?: never;
|
|
8707
|
+
};
|
|
8708
|
+
requestBody?: never;
|
|
8709
|
+
responses: {
|
|
8710
|
+
/** @description The file, with the network's `Content-Type`. */
|
|
8711
|
+
200: {
|
|
8712
|
+
headers: {
|
|
8713
|
+
[name: string]: unknown;
|
|
8714
|
+
};
|
|
8715
|
+
content: {
|
|
8716
|
+
"*/*": string;
|
|
8717
|
+
};
|
|
8718
|
+
};
|
|
8719
|
+
400: components["responses"]["MessagesError"];
|
|
8720
|
+
};
|
|
8721
|
+
};
|
|
8562
8722
|
getMetricList: {
|
|
8563
8723
|
parameters: {
|
|
8564
8724
|
query?: never;
|
|
@@ -9403,6 +9563,34 @@ interface operations {
|
|
|
9403
9563
|
400: components["responses"]["CommentsCommentError"];
|
|
9404
9564
|
};
|
|
9405
9565
|
};
|
|
9566
|
+
getCommentFile: {
|
|
9567
|
+
parameters: {
|
|
9568
|
+
query?: never;
|
|
9569
|
+
header?: never;
|
|
9570
|
+
path: {
|
|
9571
|
+
/** @description Comment identifier (PlanVortex's `_id`, not the network's `external_id`) */
|
|
9572
|
+
id_comment: components["parameters"]["CommentsidComment"];
|
|
9573
|
+
/** @description Organization identifier */
|
|
9574
|
+
id_organization: components["parameters"]["CommentsidOrganization"];
|
|
9575
|
+
/** @description Position of the file in the comment's `files_urls`, from 0. */
|
|
9576
|
+
index: number;
|
|
9577
|
+
};
|
|
9578
|
+
cookie?: never;
|
|
9579
|
+
};
|
|
9580
|
+
requestBody?: never;
|
|
9581
|
+
responses: {
|
|
9582
|
+
/** @description The file, with the network's `Content-Type`. */
|
|
9583
|
+
200: {
|
|
9584
|
+
headers: {
|
|
9585
|
+
[name: string]: unknown;
|
|
9586
|
+
};
|
|
9587
|
+
content: {
|
|
9588
|
+
"*/*": string;
|
|
9589
|
+
};
|
|
9590
|
+
};
|
|
9591
|
+
400: components["responses"]["CommentsCommentError"];
|
|
9592
|
+
};
|
|
9593
|
+
};
|
|
9406
9594
|
getCommentReplies: {
|
|
9407
9595
|
parameters: {
|
|
9408
9596
|
query?: {
|
|
@@ -9620,6 +9808,7 @@ interface operations {
|
|
|
9620
9808
|
* | `553` | Some account is not part of this session. `data.accounts` lists them |
|
|
9621
9809
|
* | `706` | The new accounts do not fit in the plan. `data` carries `limit`, `used` and `requested`, and none was enabled |
|
|
9622
9810
|
* | `1101` | Invalid organization |
|
|
9811
|
+
* | `516` | The plan is free and one of the accounts belongs to a network that needs a paid plan (today, `whatsapp`) |
|
|
9623
9812
|
*/
|
|
9624
9813
|
400: {
|
|
9625
9814
|
headers: {
|
|
@@ -11743,6 +11932,7 @@ interface operations {
|
|
|
11743
11932
|
* | Code | Meaning |
|
|
11744
11933
|
* | --- | --- |
|
|
11745
11934
|
* | `514` | This endpoint needs app credentials: neither a user token nor a temporal connect token can issue one |
|
|
11935
|
+
* | `516` | The plan is free, `social_network` needs a paid plan (today, `whatsapp`) and the organization has no active account of it to reconnect |
|
|
11746
11936
|
* | `532` | `redirect_uri` is not one of the app's registered `redirect_urls` |
|
|
11747
11937
|
* | `549` | `account_selection` is not `planvortex` or `integrator`, or it is `integrator` without `redirect_uri` or `social_network`. `data` says which |
|
|
11748
11938
|
* | `550` | `account_selection=integrator` on a network with no return to the browser (`telegram`) |
|
|
@@ -13728,7 +13918,7 @@ declare class OrganizationError extends PlanVortexError {
|
|
|
13728
13918
|
*/
|
|
13729
13919
|
declare class PlanLimitError extends PlanVortexError {
|
|
13730
13920
|
}
|
|
13731
|
-
/** 1500-
|
|
13921
|
+
/** 1500-1516 — conversaciones, mensajes, plantillas y sus archivos. Exige plan de pago. */
|
|
13732
13922
|
declare class MessagingError extends PlanVortexError {
|
|
13733
13923
|
}
|
|
13734
13924
|
/** 1600-1601 — contactos. */
|
|
@@ -13814,7 +14004,7 @@ type WebhookAlgorithm = keyof typeof WEBHOOK_SIGNATURE_HEADERS;
|
|
|
13814
14004
|
* **La lista crece**, así que un `field` desconocido se ignora en vez de romper: para eso está
|
|
13815
14005
|
* {@link UnknownWebhookChange}.
|
|
13816
14006
|
*/
|
|
13817
|
-
declare const WEBHOOK_EVENTS: readonly ["new_account", "change_state_account", "messages", "messaging_postbacks", "messaging_seen", "messaging_error", "comments", "integration_error", "ai_plan_generated", "ai_plan_failed"];
|
|
14007
|
+
declare const WEBHOOK_EVENTS: readonly ["new_account", "change_state_account", "messages", "messaging_postbacks", "messaging_seen", "messaging_error", "message_echoes", "comments", "integration_error", "ai_plan_generated", "ai_plan_failed"];
|
|
13818
14008
|
type WebhookEvent = (typeof WEBHOOK_EVENTS)[number];
|
|
13819
14009
|
/** Lo que trae todo cambio que cuelga de una CUENTA, pase lo que pase. */
|
|
13820
14010
|
interface AccountWebhookChangeBase {
|
|
@@ -13846,6 +14036,21 @@ interface MessageChange extends AccountWebhookChangeBase {
|
|
|
13846
14036
|
/** El contacto del otro lado. Un comentario no tiene, y por eso aquí sí y allí no. */
|
|
13847
14037
|
id_contact?: string;
|
|
13848
14038
|
}
|
|
14039
|
+
/**
|
|
14040
|
+
* WhatsApp, cuando el número se usa también en la **app WhatsApp Business** del móvil: el negocio
|
|
14041
|
+
* contestó desde la app. `messageObj` es un mensaje **nuestro** —lleva `contact_id`, el contacto al
|
|
14042
|
+
* que se escribió, y no `from_contact_id`— y llega poblado, como en {@link MessageChange}.
|
|
14043
|
+
*
|
|
14044
|
+
* Es un evento aparte a propósito, y {@link isMessageChange} **no** lo incluye: un bot que contesta a
|
|
14045
|
+
* cada mensaje que entra no tiene que contestarle al propio negocio. Guárdalo en el hilo y ya. No
|
|
14046
|
+
* abre la ventana de 24 horas de WhatsApp.
|
|
14047
|
+
*/
|
|
14048
|
+
interface MessageEchoChange extends AccountWebhookChangeBase {
|
|
14049
|
+
field: "message_echoes";
|
|
14050
|
+
messageObj?: Message;
|
|
14051
|
+
/** El contacto al que escribió el negocio */
|
|
14052
|
+
id_contact?: string;
|
|
14053
|
+
}
|
|
13849
14054
|
/**
|
|
13850
14055
|
* Llegó un comentario.
|
|
13851
14056
|
*
|
|
@@ -13927,11 +14132,16 @@ interface UnknownWebhookChange {
|
|
|
13927
14132
|
* `CommentChange | UnknownWebhookChange`. Para estrechar de verdad están los predicados
|
|
13928
14133
|
* {@link isCommentChange} y compañía, que es la forma recomendada.
|
|
13929
14134
|
*/
|
|
13930
|
-
type WebhookChange = AccountStateChange | MessageChange | CommentChange | IntegrationErrorChange | AiPlanChange | UnknownWebhookChange;
|
|
14135
|
+
type WebhookChange = AccountStateChange | MessageChange | MessageEchoChange | CommentChange | IntegrationErrorChange | AiPlanChange | UnknownWebhookChange;
|
|
13931
14136
|
/** Una cuenta se conectó o cambió de estado. */
|
|
13932
14137
|
declare function isAccountStateChange(change: WebhookChange): change is AccountStateChange;
|
|
13933
14138
|
/** Algo pasó en la mensajería. Incluye el visto y el rechazo de la red, no sólo el mensaje nuevo. */
|
|
13934
14139
|
declare function isMessageChange(change: WebhookChange): change is MessageChange;
|
|
14140
|
+
/**
|
|
14141
|
+
* El negocio contestó desde la app WhatsApp Business del móvil. No es un mensaje entrante: no lo
|
|
14142
|
+
* contestes. {@link isMessageChange} no lo incluye.
|
|
14143
|
+
*/
|
|
14144
|
+
declare function isMessageEchoChange(change: WebhookChange): change is MessageEchoChange;
|
|
13935
14145
|
/** Llegó un comentario. */
|
|
13936
14146
|
declare function isCommentChange(change: WebhookChange): change is CommentChange;
|
|
13937
14147
|
/** Una integración dejó de funcionar. */
|
|
@@ -14080,4 +14290,4 @@ interface PlanVortexWebhooksOptions {
|
|
|
14080
14290
|
*/
|
|
14081
14291
|
declare function planvortexWebhooks(options: PlanVortexWebhooksOptions): (request: WebhookRequestLike, response: WebhookResponseLike, next: (error?: unknown) => void) => void;
|
|
14082
14292
|
|
|
14083
|
-
export { type Client as $, type Account as A, type Comment as B, type ConnectLink as C, type Destination as D, type EnableResult as E, type CommentThread as F, type CommentReplyResult as G, type ContactExtraData as H, type Contact as I, type ContactCreate as J, type ContactUpdate as K, type IntegrationProviderName as L, type MetricName as M, type IntegrationProvider as N, type Integration as O, type Paginated as P, type IntegrationConnectRequest as Q, type IntegrationUpdate as R, type SocialNetwork as S, type TopPublicationsResult as T, type IntegrationPickerConfig as U, type IntegrationCatalogPage as V, type MessageTemplate as W, type Conversation as X, type ConversationTotals as Y, type Message as Z, type MessageInput as _, type ConnectResult as a,
|
|
14293
|
+
export { type Client as $, type Account as A, type Comment as B, type ConnectLink as C, type Destination as D, type EnableResult as E, type CommentThread as F, type CommentReplyResult as G, type ContactExtraData as H, type Contact as I, type ContactCreate as J, type ContactUpdate as K, type IntegrationProviderName as L, type MetricName as M, type IntegrationProvider as N, type Integration as O, type Paginated as P, type IntegrationConnectRequest as Q, type IntegrationUpdate as R, type SocialNetwork as S, type TopPublicationsResult as T, type IntegrationPickerConfig as U, type IntegrationCatalogPage as V, type MessageTemplate as W, type Conversation as X, type ConversationTotals as Y, type Message as Z, type MessageInput as _, type ConnectResult as a, type MessageType as a$, type Organization as a0, type AiSettings as a1, type ClientWithOrganizations as a2, type AccountSelection as a3, type PlanData as a4, type PlanUseData as a5, type ConnectToken as a6, type AiContext as a7, type SocialCredentialsInput as a8, type Product as a9, type AiPlanSourceProduct as aA, type AiPlanState as aB, type ApiErrorBody as aC, type AspectRatios as aD, AuthError as aE, type ClientPlan as aF, type CommentAuthor as aG, type CommentChange as aH, type ConnectSessionAccount as aI, type ContactChannel as aJ, ContactError as aK, type DashboardAiPlanRef as aL, type DashboardPublicationRef as aM, type DashboardRange as aN, type EngagementBase as aO, FileError as aP, type FileFormat as aQ, type FileProperties as aR, type FileType as aS, type IntegrationCatalogProduct as aT, type IntegrationConfig as aU, IntegrationError as aV, type IntegrationErrorChange as aW, type IntegrationFormField as aX, type MessageChange as aY, type MessageEchoChange as aZ, type MessageOptions as a_, type ProductInput as aa, type ProductCatalog as ab, type ProductCatalogInput as ac, type PublicationInput as ad, type PublicationState as ae, type PublicationStats as af, type PublicationStatsHistory as ag, type Upload as ah, AccountError as ai, type AccountMetricRow as aj, type AccountStateChange as ak, type AccountWebhookChangeBase as al, type AccountWithError as am, type AiImageOrigin as an, type AiPlanCostEstimate as ao, type AiPlanDestination as ap, AiPlanError as aq, type AiPlanNotice as ar, type AiPlanOptions as as, type AiPlanOptionsInput as at, type AiPlanResult as au, type AiPlanResultsGroup as av, type AiPlanResultsTemplateGroup as aw, type AiPlanSource as ax, type AiPlanSourceImageInput as ay, type AiPlanSourceInput as az, type ConnectSession as b, WEBHOOK_SIGNATURE_HEADERS as b$, MessagingError as b0, type MetricRow as b1, NO_ERROR_CODE as b2, type components as b3, type operations as b4, type paths as b5, type webhooks as b6, type OpenEnum as b7, OrganizationError as b8, PLANVORTEX_ERROR_RANGES as b9, type TopPublication as bA, type UnknownWebhookChange as bB, UserError as bC, type WebhookAlgorithm as bD, type WebhookChange as bE, type WebhookEvent as bF, type WithAccount as bG, type WithPublication as bH, type WooCommerceConnectRequest as bI, account as bJ, accountId as bK, errorFamilyForCode as bL, isPlanVortexError as bM, isTokenError as bN, messageContact as bO, messageContactId as bP, messageDirection as bQ, messageFileIds as bR, messageFiles as bS, publication as bT, publicationId as bU, type AiPlanChange as bV, type HandleWebhookRequestOptions as bW, type PlanVortexWebhooksOptions as bX, type RawWebhookBody as bY, type VerifyWebhookSignatureOptions as bZ, WEBHOOK_EVENTS as b_, PlanLimitError as ba, PlanVortexAuthenticationError as bb, PlanVortexConfigError as bc, PlanVortexConnectionError as bd, PlanVortexError as be, type PlanVortexErrorOptions as bf, type PlanVortexErrorRange as bg, type PlannerTemplateField as bh, type PlannerTemplateFieldType as bi, ProductError as bj, type PublicationAiGenerated as bk, type PublicationDestination as bl, PublicationError as bm, type PublicationErrorDetail as bn, type PublicationMetrics as bo, type PublicationPending as bp, type PublicationStatsPoint as bq, type PublicationType as br, type PublicationsSummary as bs, type RssConfig as bt, type SocialAuthorizationMethod as bu, type SocialCredentials as bv, type SocialIdentifier as bw, type SocialIdentifierInput as bx, type SocialLimitsMap as by, TOKEN_ERROR_CODES as bz, type AccountMetrics as c, WebhookBodyError as c0, type WebhookHeaders as c1, type WebhookRequestLike as c2, type WebhookResponseLike as c3, WebhookSignatureError as c4, handleWebhookRequest as c5, isAccountStateChange as c6, isAiPlanChange as c7, isCommentChange as c8, isIntegrationErrorChange as c9, isMessageChange as ca, isMessageEchoChange as cb, parseWebhookPayload as cc, planvortexWebhooks as cd, verifyWebhookSignature as ce, type PublishSettings as d, type PersistentMenu as e, type Dashboard as f, type DashboardMetricsResult as g, type PublicationsSummaryResult as h, type PublicationsStatsResult as i, type PlanUse as j, type Publication as k, type AiPlanResultsSort as l, type PlannerTemplateName as m, type AiPlanCreateRequest as n, type AiPlanCreateResult as o, type AiPlan as p, type AiPlanResults as q, type ClientApp as r, type ClientAppInput as s, type SocialCapabilities as t, type CommentActions as u, type SocialLimits as v, type PublicationLimits as w, type AspectRatiosByNetwork as x, type PlannerTemplate as y, type CommentNetwork as z };
|
package/dist/index.cjs
CHANGED
|
@@ -4,7 +4,7 @@ var path = require('path');
|
|
|
4
4
|
|
|
5
5
|
// src/version.ts
|
|
6
6
|
var PLANVORTEX_API_URL = "https://api.planvortex.com/v1.0.0";
|
|
7
|
-
var VERSION = "0.
|
|
7
|
+
var VERSION = "0.20.0";
|
|
8
8
|
|
|
9
9
|
// src/core/errors.ts
|
|
10
10
|
var PLANVORTEX_ERROR_RANGES = [
|
|
@@ -31,7 +31,11 @@ var PLANVORTEX_ERROR_RANGES = [
|
|
|
31
31
|
//1308 es el tope de APPS del plan, que nacio al quitar el candado de precio de la API.
|
|
32
32
|
{ from: 1300, to: 1308, family: "plan_limit" },
|
|
33
33
|
{ from: 1400, to: 1408, family: "plan_limit" },
|
|
34
|
-
|
|
34
|
+
//1513 y 1514 son las plantillas de WhatsApp: el formato que Meta rechazaria sin decir por que,
|
|
35
|
+
//y Meta rechazandola al crearla. Nacieron por encima del techo, la cuarta vez que pasa. 1515 y
|
|
36
|
+
//1516 son los archivos que llegan de la red: 1515 = la red ya no lo tiene (tambien en un
|
|
37
|
+
//comentario), 1516 = ese mensaje o esa posicion no existen.
|
|
38
|
+
{ from: 1500, to: 1516, family: "messaging" },
|
|
35
39
|
{ from: 1600, to: 1601, family: "contact" },
|
|
36
40
|
{ from: 1900, to: 1906, family: "payment" },
|
|
37
41
|
{ from: 2e3, to: 2099, family: "product" },
|
|
@@ -471,6 +475,9 @@ var HttpClient = class {
|
|
|
471
475
|
if (request.parse === "none" || response.status === 204) {
|
|
472
476
|
return void 0;
|
|
473
477
|
}
|
|
478
|
+
if (request.parse === "binary") {
|
|
479
|
+
return new Uint8Array(await response.arrayBuffer());
|
|
480
|
+
}
|
|
474
481
|
return this.readBody(response);
|
|
475
482
|
}
|
|
476
483
|
/** JSON si se puede; si no, el texto crudo. Un cuerpo vacío es `undefined`, nunca un throw. */
|
|
@@ -552,6 +559,19 @@ async function* iteratePages(fetchPage, options = {}) {
|
|
|
552
559
|
}
|
|
553
560
|
|
|
554
561
|
// src/resources/base.ts
|
|
562
|
+
function dispositionFileName(header) {
|
|
563
|
+
if (!header) {
|
|
564
|
+
return void 0;
|
|
565
|
+
}
|
|
566
|
+
const encoded = /filename\*=UTF-8''([^;]+)/i.exec(header);
|
|
567
|
+
if (encoded?.[1]) {
|
|
568
|
+
try {
|
|
569
|
+
return decodeURIComponent(encoded[1]);
|
|
570
|
+
} catch {
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
return /filename="([^"]*)"/i.exec(header)?.[1];
|
|
574
|
+
}
|
|
555
575
|
var Resource = class {
|
|
556
576
|
constructor(client) {
|
|
557
577
|
this.client = client;
|
|
@@ -575,6 +595,27 @@ var Resource = class {
|
|
|
575
595
|
* nombre obvio de mandar un mensaje, y con el genérico ocupando `send` la subclase no
|
|
576
596
|
* compilaba.
|
|
577
597
|
*/
|
|
598
|
+
/**
|
|
599
|
+
* Un archivo, en bytes y con lo que dicen sus cabeceras. Lo usan las dos rutas de archivos de la
|
|
600
|
+
* API, la de mensajes y la de comentarios. Lleva `_` al final por lo mismo que los verbos llevan
|
|
601
|
+
* `http` delante: el método público de los recursos se llama `downloadFile`.
|
|
602
|
+
*/
|
|
603
|
+
async downloadFile_(path, options = {}) {
|
|
604
|
+
const response = await this.client.request({
|
|
605
|
+
method: "GET",
|
|
606
|
+
path,
|
|
607
|
+
parse: "binary",
|
|
608
|
+
...options.signal === void 0 ? {} : { signal: options.signal },
|
|
609
|
+
...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs }
|
|
610
|
+
});
|
|
611
|
+
const disposition = response.headers?.get("content-disposition") ?? null;
|
|
612
|
+
return {
|
|
613
|
+
data: response.data ?? new Uint8Array(),
|
|
614
|
+
contentType: (response.headers?.get("content-type") ?? "application/octet-stream").split(";")[0].trim(),
|
|
615
|
+
fileName: dispositionFileName(disposition),
|
|
616
|
+
disposition: disposition?.toLowerCase().startsWith("inline") ? "inline" : "attachment"
|
|
617
|
+
};
|
|
618
|
+
}
|
|
578
619
|
httpGet(path, query, options) {
|
|
579
620
|
return this.dispatch({ method: "GET", path, ...query ? { query } : {} }, options);
|
|
580
621
|
}
|
|
@@ -613,6 +654,12 @@ function requireId(value, name) {
|
|
|
613
654
|
}
|
|
614
655
|
return value;
|
|
615
656
|
}
|
|
657
|
+
function fileIndex(index) {
|
|
658
|
+
if (!Number.isInteger(index) || index < 0) {
|
|
659
|
+
throw new TypeError(`index tiene que ser un entero desde 0, y es ${String(index)}.`);
|
|
660
|
+
}
|
|
661
|
+
return index;
|
|
662
|
+
}
|
|
616
663
|
|
|
617
664
|
// src/resources/accounts.ts
|
|
618
665
|
var AccountsResource = class extends Resource {
|
|
@@ -1522,6 +1569,22 @@ var CommentsResource = class extends Resource {
|
|
|
1522
1569
|
options
|
|
1523
1570
|
);
|
|
1524
1571
|
}
|
|
1572
|
+
/**
|
|
1573
|
+
* Un archivo del comentario (la foto, el GIF, el sticker o el vídeo de `files_urls[index]`),
|
|
1574
|
+
* pedido a la red en ese momento: PlanVortex no lo guarda y lo reenvía sin quedarse una copia.
|
|
1575
|
+
*
|
|
1576
|
+
* Hace falta cuando el archivo no trae `url` (LinkedIn solo da el id de la imagen; el enlace de
|
|
1577
|
+
* Telegram lleva el token del bot; el vídeo de Bluesky es una lista HLS) o cuando el `url` ya no
|
|
1578
|
+
* carga (Facebook, Threads y Discord lo caducan). Si la red ya no lo tiene, error 1515; si el
|
|
1579
|
+
* comentario no tiene archivo en esa posición, 2602. Un bot de Telegram no baja más de 20 MB:
|
|
1580
|
+
* pasado eso es un 1515 con `data.reason: "too_big"`.
|
|
1581
|
+
*
|
|
1582
|
+
* Un `disposition: "attachment"` es un documento que alguien de fuera colgó: no lo pintes dentro
|
|
1583
|
+
* de tus propias páginas.
|
|
1584
|
+
*/
|
|
1585
|
+
async downloadFile(idOrganization, idComment, index, options = {}) {
|
|
1586
|
+
return this.downloadFile_(`${this.path(idOrganization, idComment)}/files/${fileIndex(index)}`, options);
|
|
1587
|
+
}
|
|
1525
1588
|
/**
|
|
1526
1589
|
* Responde EN PÚBLICO, colgando de ese comentario.
|
|
1527
1590
|
*
|
|
@@ -2213,6 +2276,25 @@ var MessagesResource = class extends Resource {
|
|
|
2213
2276
|
options
|
|
2214
2277
|
);
|
|
2215
2278
|
}
|
|
2279
|
+
/**
|
|
2280
|
+
* Un archivo de un mensaje que llegó de la red (`message_options.files_urls[index]`): una foto,
|
|
2281
|
+
* un vídeo, una nota de voz, un documento o un sticker. PlanVortex no lo guarda: lo pide a la red
|
|
2282
|
+
* en ese momento y lo reenvía sin quedarse una copia.
|
|
2283
|
+
*
|
|
2284
|
+
* En WhatsApp es la ÚNICA forma de abrir un archivo: ninguno trae `url`, porque WhatsApp solo los
|
|
2285
|
+
* entrega con el token de la cuenta. En Instagram y Messenger hace falta cuando el `url` del CDN
|
|
2286
|
+
* de Meta caducó. WhatsApp suelta un archivo 7 días después de que llegara: a partir de ahí es un
|
|
2287
|
+
* error 1515. Un 1516 es que el mensaje no es de esa cuenta o no tiene archivo en esa posición.
|
|
2288
|
+
*
|
|
2289
|
+
* Un `disposition: "attachment"` es un documento que mandó alguien de fuera: no lo pintes dentro
|
|
2290
|
+
* de tus propias páginas.
|
|
2291
|
+
*/
|
|
2292
|
+
async downloadFile(idOrganization, idAccount, idMessage, index, options = {}) {
|
|
2293
|
+
return this.downloadFile_(
|
|
2294
|
+
`${this.accountPath(idOrganization, idAccount)}/messages/${requireId(idMessage, "idMessage")}/files/${fileIndex(index)}`,
|
|
2295
|
+
options
|
|
2296
|
+
);
|
|
2297
|
+
}
|
|
2216
2298
|
accountPath(idOrganization, idAccount) {
|
|
2217
2299
|
return `/organizations/${requireId(idOrganization, "idOrganization")}/accounts/${requireId(idAccount, "idAccount")}`;
|
|
2218
2300
|
}
|