planvortex 0.1.0 → 0.3.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 +6 -4
- package/dist/{chunk-HSMIRBF3.js → chunk-GUYS6XTO.js} +3 -3
- package/dist/{chunk-HSMIRBF3.js.map → chunk-GUYS6XTO.js.map} +1 -1
- package/dist/{index-DOC-BT2F.d.cts → index-BMoQHhe-.d.cts} +76 -22
- package/dist/{index-DOC-BT2F.d.ts → index-BMoQHhe-.d.ts} +76 -22
- package/dist/index.cjs +69 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +61 -11
- package/dist/index.d.ts +61 -11
- package/dist/index.js +70 -10
- package/dist/index.js.map +1 -1
- package/dist/webhooks/index.cjs +1 -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 +1 -1
- package/package.json +1 -1
|
@@ -698,6 +698,8 @@ interface paths {
|
|
|
698
698
|
* **It answers 200 even when it fails.** The result carries `errorCode` and `errorMsg` instead of an error body, because the browser lands here from a redirect and a raw 400 would be a broken page. Check `errorCode`: empty means everything went well.
|
|
699
699
|
*
|
|
700
700
|
* **An app cannot call this** — it needs a user token or a temporal connect token (error 519 otherwise). See `GET /organizations/{id_organization}/temporal_connect_token`.
|
|
701
|
+
*
|
|
702
|
+
* **A temporal connect token is spent here.** Once this call succeeds, that token cannot connect anything else and answers error 543; the `enable` calls that finish the same connection still work until it expires. And if the token was issued for one network, calling this for another answers error 544.
|
|
701
703
|
*/
|
|
702
704
|
get: operations["connectAccount"];
|
|
703
705
|
put?: never;
|
|
@@ -1297,6 +1299,8 @@ interface paths {
|
|
|
1297
1299
|
* **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}`).
|
|
1298
1300
|
*
|
|
1299
1301
|
* **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.
|
|
1302
|
+
*
|
|
1303
|
+
* **Read `authorization`, not `link`.** Nine of the ten networks are `redirect` and you send the person to `link`. **WhatsApp is not a URL at all**: its sign-up is Meta's Embedded Signup, a popup you raise with the Facebook JavaScript SDK, so its `link` is an empty string and everything you need to open that popup travels in `authorization`. A client that loops over the list and redirects to `link` sends its user to its own page.
|
|
1300
1304
|
*/
|
|
1301
1305
|
get: operations["getConnectLinks"];
|
|
1302
1306
|
put?: never;
|
|
@@ -2028,13 +2032,17 @@ interface paths {
|
|
|
2028
2032
|
*
|
|
2029
2033
|
* It exists because **an app cannot connect accounts**: `connect_links` and `account-connect` refuse app credentials with error 519, since authorizing Instagram is an OAuth flow with a human in front of it. The shape of the integration is therefore:
|
|
2030
2034
|
*
|
|
2031
|
-
* 1. Your server asks for this token — **this endpoint is the one that requires app credentials**, and a user token is refused. So is a temporal connect token: it cannot renew itself, which is what keeps
|
|
2035
|
+
* 1. Your server asks for this token — **this endpoint is the one that requires app credentials**, and a user token is refused. So is a temporal connect token: it cannot renew itself, which is what keeps its life a real limit rather than the first link of a chain.
|
|
2032
2036
|
* 2. You send your end user to the `url` that comes back, by redirect or in an iframe. The bare
|
|
2033
2037
|
* `token` comes back too, so a server-side client can authenticate with it directly instead of
|
|
2034
2038
|
* parsing it out of that URL.
|
|
2035
2039
|
* 3. With that token the browser completes `connect_links` and `account-connect`.
|
|
2036
2040
|
*
|
|
2037
|
-
* The token lasts **
|
|
2041
|
+
* The token lasts **fifteen minutes**, is tied to **this** organization — using it against another answers error 1101 — and carries only two permissions: create accounts and read the organization. It is the piece designed for a browser, and the only credential of ours that belongs there.
|
|
2042
|
+
*
|
|
2043
|
+
* **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.
|
|
2044
|
+
*
|
|
2045
|
+
* **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.
|
|
2038
2046
|
*
|
|
2039
2047
|
* If you send `redirect_uri` it has to be one of the app's `redirect_urls`, or the call answers error 532.
|
|
2040
2048
|
*/
|
|
@@ -2471,10 +2479,35 @@ interface components {
|
|
|
2471
2479
|
/** @description `default`, or a locale such as `es_ES`. */
|
|
2472
2480
|
locale?: string;
|
|
2473
2481
|
}[];
|
|
2482
|
+
/**
|
|
2483
|
+
* @description **How** an account of this network is authorized, which is not always "send the user to this URL".
|
|
2484
|
+
*
|
|
2485
|
+
* Nine of the ten networks are `redirect`: open `link` and the network sends the person back to PlanVortex with a code. **WhatsApp is not.** Its sign-up is Meta's *Embedded Signup*: a popup raised by the Facebook JavaScript SDK from your own page, which returns — over `postMessage` — session data (`waba_id`, `phone_number_id`) that no query string carries. Its `link` is therefore an empty string.
|
|
2486
|
+
*
|
|
2487
|
+
* Branch on `authorization.type`, never on whether `link` is empty.
|
|
2488
|
+
*/
|
|
2489
|
+
AccountsSocialAuthorizationMethod: {
|
|
2490
|
+
/** @description `meta_embedded_signup` only. Goes to `FB.init({appId})`. It is the same Meta app whose secret PlanVortex uses to exchange the code afterwards. */
|
|
2491
|
+
app_id?: string;
|
|
2492
|
+
/** @description `meta_embedded_signup` only. Goes to `FB.login(cb, {config_id})` — the Embedded Signup configuration. */
|
|
2493
|
+
config_id?: string;
|
|
2494
|
+
/** @description `meta_embedded_signup` only. Goes to `extras.featureType`. */
|
|
2495
|
+
feature_type?: string;
|
|
2496
|
+
/** @description `meta_embedded_signup` only. Goes to `FB.init({version})`. This is the JavaScript SDK version, not the Graph version PlanVortex calls server-side: they move independently. */
|
|
2497
|
+
graph_version?: string;
|
|
2498
|
+
/** @description `meta_embedded_signup` only. Goes to `extras.sessionInfoVersion`. */
|
|
2499
|
+
session_info_version?: string;
|
|
2500
|
+
/**
|
|
2501
|
+
* @description `redirect`: send the user to `link`. `meta_embedded_signup`: open the Meta popup with the fields below.
|
|
2502
|
+
* @enum {string}
|
|
2503
|
+
*/
|
|
2504
|
+
type: "redirect" | "meta_embedded_signup";
|
|
2505
|
+
};
|
|
2474
2506
|
AccountsSocialLinksList: {
|
|
2475
2507
|
/** @description One entry per network that can be connected right now. */
|
|
2476
2508
|
links: {
|
|
2477
|
-
|
|
2509
|
+
authorization: components["schemas"]["AccountsSocialAuthorizationMethod"];
|
|
2510
|
+
/** @description The network's authorization URL. Send the user there. **Empty when `authorization.type` is not `redirect`** — WhatsApp has no URL to give. */
|
|
2478
2511
|
link: string;
|
|
2479
2512
|
social_network: components["schemas"]["SocialNetwork"];
|
|
2480
2513
|
}[];
|
|
@@ -3328,7 +3361,7 @@ interface components {
|
|
|
3328
3361
|
* The catalogue grows with the product, so treat an unknown `code` as a generic failure instead of rejecting it.
|
|
3329
3362
|
*/
|
|
3330
3363
|
Error: {
|
|
3331
|
-
/** @description PlanVortex error code. Ranges: 500-
|
|
3364
|
+
/** @description PlanVortex error code. Ranges: 500-544 auth, tokens and client apps · 601-612 user · 700-715 social accounts · 800-810 files · 900-960 publications · 1000-1003 general · 1100-1111 organizations · 1200-1207 roles · 1300-1307 client plan · 1400-1408 organization plan · 1500-1512 messaging · 1600-1601 contacts · 1900-1906 payments · 2000-2099 products · 2100-2199 AI plans · 2200-2299 integrations. */
|
|
3332
3365
|
code: number;
|
|
3333
3366
|
/** @description Extra context attached to the error, when there is any. */
|
|
3334
3367
|
data?: {
|
|
@@ -3538,9 +3571,15 @@ interface components {
|
|
|
3538
3571
|
/**
|
|
3539
3572
|
* @description What you send to write a message.
|
|
3540
3573
|
*
|
|
3541
|
-
*
|
|
3574
|
+
* `comment_message` and `publication_message` need `in_response_external_id`, the identifier of the comment or the publication being answered ON THE NETWORK. The endpoint did not read it from the body until 2026-08-24, which left both types unreachable from the public API; it does now.
|
|
3542
3575
|
*/
|
|
3543
3576
|
MessagesMessageInput: {
|
|
3577
|
+
/**
|
|
3578
|
+
* @description Required by `comment_message` and `publication_message`, and ignored by every other type (error `1510` when it is missing). It is the identifier the NETWORK gives: a comment's `external_id` or a publication's `external_identifier`, never a PlanVortex `_id`.
|
|
3579
|
+
*
|
|
3580
|
+
* Only Facebook and Instagram do anything with it: `comment_message` sends a private reply to a public comment (Meta's `recipient.comment_id`) and `publication_message` attaches the post as a `MEDIA_SHARE`.
|
|
3581
|
+
*/
|
|
3582
|
+
in_response_external_id?: string;
|
|
3544
3583
|
message_options?: components["schemas"]["MessageOptions"];
|
|
3545
3584
|
message_type: components["schemas"]["MessageType"];
|
|
3546
3585
|
/** @description Required for the text-based types. Validated against `characters` in `GET /social_limits`. */
|
|
@@ -6245,6 +6284,8 @@ interface operations {
|
|
|
6245
6284
|
* | Code | Meaning |
|
|
6246
6285
|
* | --- | --- |
|
|
6247
6286
|
* | `519` | This endpoint does not accept app credentials |
|
|
6287
|
+
* | `543` | This temporal connect token has already connected an account. Issue a new one |
|
|
6288
|
+
* | `544` | This temporal connect token was issued for a different social network |
|
|
6248
6289
|
* | `1101` | Invalid organization, or a temporal token for a different one |
|
|
6249
6290
|
*/
|
|
6250
6291
|
400: {
|
|
@@ -6610,6 +6651,7 @@ interface operations {
|
|
|
6610
6651
|
* | `700` | The account has no usable token: it has to be connected again |
|
|
6611
6652
|
* | `706` | The organization has no account slots left in its plan |
|
|
6612
6653
|
* | `519` | This endpoint does not accept app credentials |
|
|
6654
|
+
* | `544` | This temporal connect token was issued for a different social network |
|
|
6613
6655
|
*/
|
|
6614
6656
|
400: {
|
|
6615
6657
|
headers: {
|
|
@@ -7049,8 +7091,9 @@ interface operations {
|
|
|
7049
7091
|
/** @description The catalogue to list. **Effectively required**: without it the request fails with `ERROR_CODE_2000`. Get one from `GET .../products_catalogs`. */
|
|
7050
7092
|
product_catalog_id?: string;
|
|
7051
7093
|
/**
|
|
7052
|
-
* @
|
|
7053
|
-
*
|
|
7094
|
+
* @description One product, by its identifier on the network. It takes precedence over `product_catalog_id`, and one of the two has to travel or the call answers `ERROR_CODE_2000`. It used to be forwarded under a name the SDK does not read, so it never reached the network; that was fixed on 2026-08-24.
|
|
7095
|
+
*
|
|
7096
|
+
* **The answer is shaped differently.** Asking for one product goes to that product's node, so the network answers with the product itself and `items` carries an object rather than an array. Handle both shapes, or use `product_catalog_id` and pick the product out of the page.
|
|
7054
7097
|
*/
|
|
7055
7098
|
product_id?: string;
|
|
7056
7099
|
};
|
|
@@ -7725,10 +7768,7 @@ interface operations {
|
|
|
7725
7768
|
offset?: components["parameters"]["Contactsoffset"];
|
|
7726
7769
|
/** @description Full-text search over the contact's name. */
|
|
7727
7770
|
search?: string;
|
|
7728
|
-
/**
|
|
7729
|
-
* @deprecated
|
|
7730
|
-
* @description **Do not use: it always returns an empty list.** The server compares the whole `social_identifiers` array against the network name, and the array holds objects, so nothing ever matches. Filter client-side on `social_identifiers[].social_network` until this is fixed.
|
|
7731
|
-
*/
|
|
7771
|
+
/** @description Only the contacts reachable on this network. It matches on `social_identifiers[].social_network`, so a contact with several channels comes back through any of them. It used to return an empty list always, because the server compared the whole array of objects against the network name; that was fixed on 2026-08-24. */
|
|
7732
7772
|
social_network?: components["schemas"]["SocialNetwork"];
|
|
7733
7773
|
};
|
|
7734
7774
|
header?: never;
|
|
@@ -9683,7 +9723,7 @@ interface operations {
|
|
|
9683
9723
|
query?: {
|
|
9684
9724
|
/** @description Where the user comes back after connecting. Has to be one of the app's `redirect_urls` (error 532). */
|
|
9685
9725
|
redirect_uri?: string;
|
|
9686
|
-
/** @description Network the user is going to connect. It travels inside the returned URL. */
|
|
9726
|
+
/** @description Network the user is going to connect. It travels inside the returned URL **and inside the token itself**, so the token will only connect that network (error 544 otherwise). A network outside the allowed list is rejected here with error 702. */
|
|
9687
9727
|
social_network?: components["schemas"]["SocialNetwork"];
|
|
9688
9728
|
};
|
|
9689
9729
|
header?: never;
|
|
@@ -9704,7 +9744,7 @@ interface operations {
|
|
|
9704
9744
|
"application/json": {
|
|
9705
9745
|
/**
|
|
9706
9746
|
* Format: date-time
|
|
9707
|
-
* @description When the token stops working.
|
|
9747
|
+
* @description When the token stops working. Fifteen minutes after it was issued.
|
|
9708
9748
|
*/
|
|
9709
9749
|
expires_at: string;
|
|
9710
9750
|
/** @description The same token, on its own. This is what you pass to a client that authenticates with a temporal token; do not parse it out of `url`. */
|
|
@@ -9721,6 +9761,7 @@ interface operations {
|
|
|
9721
9761
|
* | --- | --- |
|
|
9722
9762
|
* | `514` | This endpoint needs app credentials: neither a user token nor a temporal connect token can issue one |
|
|
9723
9763
|
* | `532` | `redirect_uri` is not one of the app's registered `redirect_urls` |
|
|
9764
|
+
* | `702` | `social_network` is not one of the networks PlanVortex supports |
|
|
9724
9765
|
* | `1101` | Invalid organization |
|
|
9725
9766
|
*/
|
|
9726
9767
|
400: {
|
|
@@ -10663,15 +10704,26 @@ type PersistentMenu = Schemas["AccountsPersistentMenu"];
|
|
|
10663
10704
|
*
|
|
10664
10705
|
* Las dos cosas valen: `url` es el camino alojado —se redirige al usuario y PlanVortex se encarga
|
|
10665
10706
|
* de todo—, y `token` es el mismo credencial suelto, para pasarselo a `pv.asTemporalToken(token)`
|
|
10666
|
-
* y conducir el flujo desde el front propio. Caduca a
|
|
10667
|
-
* organizacion.
|
|
10707
|
+
* y conducir el flujo desde el front propio. Caduca a los quince minutos (`expires_at`), sirve para
|
|
10708
|
+
* UNA organizacion y se gasta en cuanto conecta una cuenta.
|
|
10668
10709
|
*/
|
|
10669
10710
|
type ConnectToken = Operations["createTemporalConnectToken"]["responses"][200]["content"]["application/json"];
|
|
10670
10711
|
/**
|
|
10671
|
-
*
|
|
10672
|
-
* PlanVortex, que es quien completa la conexion.
|
|
10712
|
+
* Como se conecta UNA red. Casi siempre es un enlace: se manda al usuario ahi y la red lo devuelve
|
|
10713
|
+
* al panel de PlanVortex, que es quien completa la conexion.
|
|
10714
|
+
*
|
|
10715
|
+
* **Casi. Mira `authorization.type` y no si `link` esta vacio.** WhatsApp no tiene URL de
|
|
10716
|
+
* autorizacion: su alta es el Embedded Signup de Meta, un popup que levanta el SDK de JavaScript de
|
|
10717
|
+
* Facebook desde tu pagina y que devuelve por `postMessage` datos —el `waba_id`, el
|
|
10718
|
+
* `phone_number_id`— que no caben en una query string. Su `link` es cadena vacia y los parametros
|
|
10719
|
+
* del popup (`app_id`, `config_id`, `graph_version`...) viajan en `authorization`.
|
|
10673
10720
|
*/
|
|
10674
10721
|
type ConnectLink = Schemas["AccountsSocialLinksList"]["links"][number];
|
|
10722
|
+
/**
|
|
10723
|
+
* Con que se autoriza una red: `redirect` (las otras nueve) o `meta_embedded_signup` (WhatsApp).
|
|
10724
|
+
* Se saca de {@link ConnectLink} y esta aqui para poder nombrarlo en un `switch`.
|
|
10725
|
+
*/
|
|
10726
|
+
type SocialAuthorizationMethod = ConnectLink["authorization"];
|
|
10675
10727
|
/**
|
|
10676
10728
|
* Lo que dejo una autorizacion: las cuentas que se pueden dar de alta.
|
|
10677
10729
|
*
|
|
@@ -10834,9 +10886,11 @@ type ConversationTotals = Schemas["MessagesConversationTotals"];
|
|
|
10834
10886
|
/**
|
|
10835
10887
|
* Lo que se manda para escribir un mensaje.
|
|
10836
10888
|
*
|
|
10837
|
-
* `comment_message` y `publication_message`
|
|
10838
|
-
*
|
|
10839
|
-
*
|
|
10889
|
+
* `comment_message` y `publication_message` exigen `in_response_external_id`: el identificador EN
|
|
10890
|
+
* LA RED de lo que se responde —el `external_id` de un comentario, el `external_identifier` de una
|
|
10891
|
+
* publicacion—, nunca un `_id` de PlanVortex, y error 1510 si falta. El endpoint no lo leia del
|
|
10892
|
+
* cuerpo hasta el 2026-08-24, lo que dejaba los dos tipos fuera del alcance de la API publica; ya
|
|
10893
|
+
* funcionan, en Facebook y en Instagram.
|
|
10840
10894
|
*/
|
|
10841
10895
|
type MessageInput = Override<Schemas["MessagesMessageInput"], {
|
|
10842
10896
|
message_options: Partial<MessageOptions>;
|
|
@@ -11181,7 +11235,7 @@ declare class PlanVortexError extends Error {
|
|
|
11181
11235
|
readonly retryAfter: number | undefined;
|
|
11182
11236
|
constructor(code: number, message: string, options?: PlanVortexErrorOptions);
|
|
11183
11237
|
}
|
|
11184
|
-
/** 500-
|
|
11238
|
+
/** 500-544 — tokens, apps de cliente, permisos. Incluye el 501 y el 522, los de token caducado. */
|
|
11185
11239
|
declare class AuthError extends PlanVortexError {
|
|
11186
11240
|
}
|
|
11187
11241
|
/** 601-612 — el usuario final. */
|
|
@@ -11523,4 +11577,4 @@ interface PlanVortexWebhooksOptions {
|
|
|
11523
11577
|
*/
|
|
11524
11578
|
declare function planvortexWebhooks(options: PlanVortexWebhooksOptions): (request: WebhookRequestLike, response: WebhookResponseLike, next: (error?: unknown) => void) => void;
|
|
11525
11579
|
|
|
11526
|
-
export { type Product as $, type Account as A, type IntegrationProvider as B, type ConnectLink as C, type Dashboard as D, type EnableResult as E, type Integration as F, type IntegrationConnectRequest as G, type IntegrationUpdate as H, type IntegrationProviderName as I, type IntegrationPickerConfig as J, type MessageTemplate as K, type Conversation as L, type MetricName as M, type ConversationTotals as N, type Message as O, type Paginated as P, type MessageInput as Q, type Client as R, type SocialNetwork as S, type TopPublicationsResult as T, type Organization as U, type AiSettings as V, type ClientWithOrganizations as W, type PlanData as X, type ConnectToken as Y, type AiContext as Z, type SocialCredentialsInput as _, type ConnectResult as a, type RssConfig as a$, type ProductInput as a0, type ProductCatalog as a1, type ProductCatalogInput as a2, type PublicationInput as a3, type PublicationState as a4, type PublicationStats as a5, type PublicationStatsHistory as a6, type Upload as a7, AccountError as a8, type AccountMetricRow as a9, type MessageChange as aA, type MessageOptions as aB, type MessageType as aC, MessagingError as aD, type MetricRow as aE, NO_ERROR_CODE as aF, type components as aG, type operations as aH, type paths as aI, type webhooks as aJ, type OpenEnum as aK, OrganizationError as aL, PLANVORTEX_ERROR_RANGES as aM, PlanLimitError as aN, PlanVortexAuthenticationError as aO, PlanVortexConfigError as aP, PlanVortexConnectionError as aQ, PlanVortexError as aR, type PlanVortexErrorOptions as aS, type PlanVortexErrorRange as aT, ProductError as aU, PublicationError as aV, type PublicationErrorDetail as aW, type PublicationMetrics as aX, type PublicationStatsPoint as aY, type PublicationType as aZ, type PublicationsSummary as a_, type AccountStateChange as aa, type AccountWebhookChangeBase as ab, type AccountWithError as ac, type AiPlanCostEstimate as ad, AiPlanError as ae, type AiPlanOptions as af, type AiPlanOptionsInput as ag, type AiPlanState as ah, type ApiErrorBody as ai, type AspectRatios as aj, AuthError as ak, type ClientPlan as al, type CommentAuthor as am, type CommentChange as an, type ContactChannel as ao, ContactError as ap, type DashboardAiPlanRef as aq, type DashboardPublicationRef as ar, type DashboardRange as as, type EngagementBase as at, FileError as au, type FileFormat as av, type FileProperties as aw, type FileType as ax, IntegrationError as ay, type IntegrationErrorChange as az, type AccountMetrics as b, type
|
|
11580
|
+
export { type Product as $, type Account as A, type IntegrationProvider as B, type ConnectLink as C, type Dashboard as D, type EnableResult as E, type Integration as F, type IntegrationConnectRequest as G, type IntegrationUpdate as H, type IntegrationProviderName as I, type IntegrationPickerConfig as J, type MessageTemplate as K, type Conversation as L, type MetricName as M, type ConversationTotals as N, type Message as O, type Paginated as P, type MessageInput as Q, type Client as R, type SocialNetwork as S, type TopPublicationsResult as T, type Organization as U, type AiSettings as V, type ClientWithOrganizations as W, type PlanData as X, type ConnectToken as Y, type AiContext as Z, type SocialCredentialsInput as _, type ConnectResult as a, type RssConfig as a$, type ProductInput as a0, type ProductCatalog as a1, type ProductCatalogInput as a2, type PublicationInput as a3, type PublicationState as a4, type PublicationStats as a5, type PublicationStatsHistory as a6, type Upload as a7, AccountError as a8, type AccountMetricRow as a9, type MessageChange as aA, type MessageOptions as aB, type MessageType as aC, MessagingError as aD, type MetricRow as aE, NO_ERROR_CODE as aF, type components as aG, type operations as aH, type paths as aI, type webhooks as aJ, type OpenEnum as aK, OrganizationError as aL, PLANVORTEX_ERROR_RANGES as aM, PlanLimitError as aN, PlanVortexAuthenticationError as aO, PlanVortexConfigError as aP, PlanVortexConnectionError as aQ, PlanVortexError as aR, type PlanVortexErrorOptions as aS, type PlanVortexErrorRange as aT, ProductError as aU, PublicationError as aV, type PublicationErrorDetail as aW, type PublicationMetrics as aX, type PublicationStatsPoint as aY, type PublicationType as aZ, type PublicationsSummary as a_, type AccountStateChange as aa, type AccountWebhookChangeBase as ab, type AccountWithError as ac, type AiPlanCostEstimate as ad, AiPlanError as ae, type AiPlanOptions as af, type AiPlanOptionsInput as ag, type AiPlanState as ah, type ApiErrorBody as ai, type AspectRatios as aj, AuthError as ak, type ClientPlan as al, type CommentAuthor as am, type CommentChange as an, type ContactChannel as ao, ContactError as ap, type DashboardAiPlanRef as aq, type DashboardPublicationRef as ar, type DashboardRange as as, type EngagementBase as at, FileError as au, type FileFormat as av, type FileProperties as aw, type FileType as ax, IntegrationError as ay, type IntegrationErrorChange as az, type AccountMetrics as b, type SocialAuthorizationMethod as b0, type SocialCredentials as b1, type SocialIdentifier as b2, type SocialIdentifierInput as b3, type SocialLimitsMap as b4, TOKEN_ERROR_CODES as b5, type TopPublication as b6, type UnknownWebhookChange as b7, UserError as b8, type WebhookAlgorithm as b9, WebhookSignatureError as bA, handleWebhookRequest as bB, isAccountStateChange as bC, isCommentChange as bD, isIntegrationErrorChange as bE, isMessageChange as bF, parseWebhookPayload as bG, planvortexWebhooks as bH, verifyWebhookSignature as bI, type WebhookChange as ba, type WebhookEvent as bb, type WithAccount as bc, type WithPublication as bd, account as be, accountId as bf, errorFamilyForCode as bg, isPlanVortexError as bh, isTokenError as bi, messageContact as bj, messageContactId as bk, messageDirection as bl, messageFileIds as bm, messageFiles as bn, publication as bo, publicationId as bp, type HandleWebhookRequestOptions as bq, type PlanVortexWebhooksOptions as br, type RawWebhookBody as bs, type VerifyWebhookSignatureOptions as bt, WEBHOOK_EVENTS as bu, WEBHOOK_SIGNATURE_HEADERS as bv, WebhookBodyError as bw, type WebhookHeaders as bx, type WebhookRequestLike as by, type WebhookResponseLike as bz, type PersistentMenu as c, type Publication as d, type AiPlanCreateRequest as e, type AiPlanCreateResult as f, type AiPlan as g, type ClientApp as h, type ClientAppInput as i, type SocialCapabilities as j, type CommentActions as k, type SocialLimits as l, type PublicationLimits as m, type AspectRatiosByNetwork as n, type CommentNetwork as o, type Comment as p, type CommentThread as q, type CommentReplyResult as r, type ContactExtraData as s, type Contact as t, type ContactCreate as u, type ContactUpdate as v, type DashboardMetricsResult as w, type PublicationsSummaryResult as x, type PublicationsStatsResult as y, type PlanUse as z };
|
package/dist/index.cjs
CHANGED
|
@@ -4,11 +4,11 @@ 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.3.0";
|
|
8
8
|
|
|
9
9
|
// src/core/errors.ts
|
|
10
10
|
var PLANVORTEX_ERROR_RANGES = [
|
|
11
|
-
{ from: 500, to:
|
|
11
|
+
{ from: 500, to: 544, family: "auth" },
|
|
12
12
|
{ from: 601, to: 612, family: "user" },
|
|
13
13
|
{ from: 700, to: 715, family: "account" },
|
|
14
14
|
{ from: 800, to: 810, family: "file" },
|
|
@@ -609,6 +609,12 @@ var AccountsResource = class extends Resource {
|
|
|
609
609
|
* no un fallo: es lo que pasa con Discord en una organización que todavía no ha guardado sus
|
|
610
610
|
* propias credenciales de bot.
|
|
611
611
|
*
|
|
612
|
+
* **MIRA `authorization`, NO si `link` está vacío.** Nueve de las diez redes son `redirect` y se
|
|
613
|
+
* manda a la persona a `link`. **WhatsApp no es una URL**: su alta es el Embedded Signup de
|
|
614
|
+
* Meta, un popup que levantas tú con el SDK de JavaScript de Facebook, así que su `link` es
|
|
615
|
+
* cadena vacía y lo que necesitas para abrirlo viaja en `authorization` — ver {@link ConnectLink}.
|
|
616
|
+
* Recorrer la lista redirigiendo a `link` manda a tu usuario a tu propia página.
|
|
617
|
+
*
|
|
612
618
|
* OJO: la red devuelve al usuario a un front de PlanVortex, no a una URL tuya — ver
|
|
613
619
|
* `redirect_uri` en {@link ConnectLinksOptions}.
|
|
614
620
|
*/
|
|
@@ -1259,9 +1265,13 @@ var ContactsResource = class extends Resource {
|
|
|
1259
1265
|
/**
|
|
1260
1266
|
* La agenda de la organización, de la más reciente a la más antigua.
|
|
1261
1267
|
*
|
|
1262
|
-
*
|
|
1263
|
-
* array `social_identifiers`
|
|
1264
|
-
*
|
|
1268
|
+
* `social_network` acota a los contactos localizables en esa red. Devolvía siempre una lista
|
|
1269
|
+
* vacía —el servidor comparaba el array entero de `social_identifiers` contra el nombre de la
|
|
1270
|
+
* red— hasta que se arregló el 2026-08-24; hasta la 0.3.0 este método no lo exponía.
|
|
1271
|
+
*
|
|
1272
|
+
* ```ts
|
|
1273
|
+
* const { data } = await pv.contacts.list(orgId, { social_network: "whatsapp", limit: 50 });
|
|
1274
|
+
* ```
|
|
1265
1275
|
*/
|
|
1266
1276
|
async list(idOrganization, options = {}) {
|
|
1267
1277
|
return this.getList(this.path(idOrganization), "contacts", listQuery2(options), options);
|
|
@@ -1356,7 +1366,8 @@ function listQuery2(options) {
|
|
|
1356
1366
|
const query = {
|
|
1357
1367
|
offset: options.offset,
|
|
1358
1368
|
limit: options.limit,
|
|
1359
|
-
search: options.search
|
|
1369
|
+
search: options.search,
|
|
1370
|
+
social_network: options.social_network
|
|
1360
1371
|
};
|
|
1361
1372
|
options.extra_data?.forEach((filter, index) => {
|
|
1362
1373
|
query[`extra_data[${index}][key]`] = filter.key;
|
|
@@ -1707,6 +1718,13 @@ var MessagesResource = class extends Resource {
|
|
|
1707
1718
|
* En Facebook e Instagram sólo se admite **un** adjunto por mensaje (error 1509), y en WhatsApp
|
|
1708
1719
|
* fuera de la ventana de 24 horas sólo se admite una plantilla.
|
|
1709
1720
|
*
|
|
1721
|
+
* `comment_message` y `publication_message` exigen `in_response_external_id`: el identificador
|
|
1722
|
+
* EN LA RED de lo que se responde —el `external_id` de un comentario, el `external_identifier`
|
|
1723
|
+
* de una publicación—, nunca un `_id` de PlanVortex, y error 1510 si falta. El endpoint no lo
|
|
1724
|
+
* leía del cuerpo hasta el 2026-08-24, lo que dejaba los dos tipos fuera del alcance de la API
|
|
1725
|
+
* pública; ya funcionan, y sólo en Facebook e Instagram: `comment_message` manda una respuesta
|
|
1726
|
+
* privada a un comentario público y `publication_message` adjunta el post como `MEDIA_SHARE`.
|
|
1727
|
+
*
|
|
1710
1728
|
* ```ts
|
|
1711
1729
|
* await pv.messages.send(orgId, accountId, contactId, {
|
|
1712
1730
|
* message_type: "simple_message",
|
|
@@ -2007,7 +2025,15 @@ var OrganizationsResource = class extends Resource {
|
|
|
2007
2025
|
* - **`token`** — el credencial suelto, para `pv.asTemporalToken(token)` cuando la interfaz la
|
|
2008
2026
|
* pone el integrador.
|
|
2009
2027
|
*
|
|
2010
|
-
* Caduca en
|
|
2028
|
+
* Caduca en **quince minutos** y **sólo vale para esta organización**: usarlo contra otra
|
|
2029
|
+
* contesta 1101.
|
|
2030
|
+
*
|
|
2031
|
+
* **Y conecta una vez.** En cuanto un `accounts.connect` sale bien, ese token deja de poder
|
|
2032
|
+
* conectar y contesta 543; los `accounts.enable` que rematan esa misma conexión siguen valiendo
|
|
2033
|
+
* hasta que caduque. Emite uno por conexión: son gratis e inmediatos.
|
|
2034
|
+
*
|
|
2035
|
+
* **Si pasas `social_network`, el token queda atado a esa red** y no conecta ninguna otra (544).
|
|
2036
|
+
* Sin ella, el token abre cualquiera y es la persona quien elige.
|
|
2011
2037
|
*/
|
|
2012
2038
|
async createConnectToken(idOrganization, options = {}) {
|
|
2013
2039
|
return this.httpGet(
|
|
@@ -2077,8 +2103,8 @@ var ProductsResource = class extends Resource {
|
|
|
2077
2103
|
* Los productos de un catálogo.
|
|
2078
2104
|
*
|
|
2079
2105
|
* `idCatalog` es obligatorio de hecho aunque la API lo pinte opcional: sin él la petición falla
|
|
2080
|
-
* con el error 2000.
|
|
2081
|
-
*
|
|
2106
|
+
* con el error 2000. Para pedir **un** producto por su identificador, {@link get} — no es un
|
|
2107
|
+
* argumento de aquí porque la respuesta viene con otra forma.
|
|
2082
2108
|
*
|
|
2083
2109
|
* ```ts
|
|
2084
2110
|
* const { data } = await pv.products.list(orgId, accountId, catalogId, { limit: 50 });
|
|
@@ -2108,6 +2134,40 @@ var ProductsResource = class extends Resource {
|
|
|
2108
2134
|
options
|
|
2109
2135
|
);
|
|
2110
2136
|
}
|
|
2137
|
+
/**
|
|
2138
|
+
* UN producto, por su identificador **en la red** (el de Meta, no un `_id` de PlanVortex).
|
|
2139
|
+
*
|
|
2140
|
+
* El servidor reenviaba ese filtro con un nombre que el SDK no lee, así que nunca llegaba a la
|
|
2141
|
+
* red y la llamada moría con un 2000; se arregló el 2026-08-24 y aquí se expone desde la 0.3.0.
|
|
2142
|
+
*
|
|
2143
|
+
* **La respuesta viene con otra forma que la del listado.** Pedir un producto suelto va al nodo
|
|
2144
|
+
* de ese producto, así que la red contesta con el producto y `items` trae un objeto. Por eso
|
|
2145
|
+
* esto es un método aparte y no un argumento de {@link list}: con un objeto no se construye una
|
|
2146
|
+
* página. Se acepta también una lista, que es lo que devolvería un despliegue que envolviera la
|
|
2147
|
+
* respuesta, y coger el primero es mejor que reventar por la forma del sobre.
|
|
2148
|
+
*
|
|
2149
|
+
* ```ts
|
|
2150
|
+
* const product = await pv.products.get(orgId, accountId, "7123456789012345");
|
|
2151
|
+
* ```
|
|
2152
|
+
*/
|
|
2153
|
+
async get(idOrganization, idAccount, productId, options = {}) {
|
|
2154
|
+
const body = await this.httpGet(
|
|
2155
|
+
`${this.path(idOrganization, idAccount)}/products`,
|
|
2156
|
+
{ product_id: requireId(productId, "productId") },
|
|
2157
|
+
options
|
|
2158
|
+
);
|
|
2159
|
+
const content = unwrapOne(body, "items");
|
|
2160
|
+
if (Array.isArray(content)) {
|
|
2161
|
+
if (!content.length) {
|
|
2162
|
+
throw new PlanVortexError(NO_ERROR_CODE, `La red no devuelve ning\xFAn producto "${productId}".`, {
|
|
2163
|
+
family: "http",
|
|
2164
|
+
data: { product_id: productId }
|
|
2165
|
+
});
|
|
2166
|
+
}
|
|
2167
|
+
return content[0];
|
|
2168
|
+
}
|
|
2169
|
+
return content;
|
|
2170
|
+
}
|
|
2111
2171
|
/**
|
|
2112
2172
|
* Da de alta un producto en un catálogo, o **actualiza uno existente** si el cuerpo trae `id`.
|
|
2113
2173
|
* Devuelve el identificador en la red, no el producto.
|