planvortex 0.18.1 → 0.19.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.
@@ -2711,7 +2711,7 @@ interface webhooks {
2711
2711
  *
2712
2712
  * 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
2713
  *
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`.
2714
+ * 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
2715
  *
2716
2716
  * ### Comments
2717
2717
  *
@@ -2729,6 +2729,12 @@ interface webhooks {
2729
2729
  *
2730
2730
  * 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
2731
  *
2732
+ * ### WhatsApp replies sent from the phone
2733
+ *
2734
+ * 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.
2735
+ *
2736
+ * 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`.
2737
+ *
2732
2738
  * ### Verifying the signature
2733
2739
  *
2734
2740
  * Every delivery carries the body signed with your app's secret, twice:
@@ -3411,7 +3417,7 @@ interface components {
3411
3417
  *
3412
3418
  * **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
3419
  *
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.
3420
+ * 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
3421
  */
3416
3422
  webhook_url?: string;
3417
3423
  };
@@ -3889,15 +3895,16 @@ interface components {
3889
3895
  /**
3890
3896
  * @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
3897
  *
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.
3898
+ * - `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
3899
  * - `messages`: a message came in. It travels in `messageObj`.
3894
3900
  * - `messaging_postbacks`: the contact pressed a button or a quick reply. Also in `messageObj`.
3895
3901
  * - `messaging_seen`: the contact read the conversation. `messageObj` carries the message they read, when we still have it.
3896
3902
  * - `messaging_error`: the network refused a message we sent. The reason is in `messageObj.message_errors`.
3903
+ * - `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
3904
  * - `comments`: a comment came in. It travels in `commentObj`, never in `messageObj`.
3898
3905
  * @enum {string}
3899
3906
  */
3900
- field: "new_account" | "change_state_account" | "messages" | "messaging_postbacks" | "messaging_seen" | "messaging_error" | "comments";
3907
+ field: "new_account" | "change_state_account" | "messages" | "messaging_postbacks" | "messaging_seen" | "messaging_error" | "message_echoes" | "comments";
3901
3908
  id_account: string;
3902
3909
  /** @description Only for messaging fields. A comment has no contact: its author is not someone you can write to. */
3903
3910
  id_contact?: string;
@@ -4470,6 +4477,16 @@ interface components {
4470
4477
  contact_id?: string | components["schemas"]["Contact"];
4471
4478
  /** Format: date-time */
4472
4479
  creation_date: string;
4480
+ /**
4481
+ * Format: date-time
4482
+ * @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.
4483
+ */
4484
+ deleted_date?: string;
4485
+ /**
4486
+ * Format: date-time
4487
+ * @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.
4488
+ */
4489
+ edit_date?: string;
4473
4490
  /** @description Identifier of this message on the network. */
4474
4491
  element_external_id?: string;
4475
4492
  /** @description Set when the **contact** wrote to us. */
@@ -4564,9 +4581,11 @@ interface components {
4564
4581
  };
4565
4582
  /**
4566
4583
  * @description What kind of message this is. `simple_message` and `file_message` work everywhere; the rest are network-specific shapes.
4584
+ *
4585
+ * `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
4586
  * @enum {string}
4568
4587
  */
4569
- MessageType: "simple_message" | "file_message" | "comment_message" | "publication_message" | "quick_reply_message" | "button_message" | "elements_message" | "postback_message" | "template_message" | "interactive_message";
4588
+ 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
4589
  /**
4571
4590
  * @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
4591
  *
@@ -13814,7 +13833,7 @@ type WebhookAlgorithm = keyof typeof WEBHOOK_SIGNATURE_HEADERS;
13814
13833
  * **La lista crece**, así que un `field` desconocido se ignora en vez de romper: para eso está
13815
13834
  * {@link UnknownWebhookChange}.
13816
13835
  */
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"];
13836
+ 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
13837
  type WebhookEvent = (typeof WEBHOOK_EVENTS)[number];
13819
13838
  /** Lo que trae todo cambio que cuelga de una CUENTA, pase lo que pase. */
13820
13839
  interface AccountWebhookChangeBase {
@@ -13846,6 +13865,21 @@ interface MessageChange extends AccountWebhookChangeBase {
13846
13865
  /** El contacto del otro lado. Un comentario no tiene, y por eso aquí sí y allí no. */
13847
13866
  id_contact?: string;
13848
13867
  }
13868
+ /**
13869
+ * WhatsApp, cuando el número se usa también en la **app WhatsApp Business** del móvil: el negocio
13870
+ * contestó desde la app. `messageObj` es un mensaje **nuestro** —lleva `contact_id`, el contacto al
13871
+ * que se escribió, y no `from_contact_id`— y llega poblado, como en {@link MessageChange}.
13872
+ *
13873
+ * Es un evento aparte a propósito, y {@link isMessageChange} **no** lo incluye: un bot que contesta a
13874
+ * cada mensaje que entra no tiene que contestarle al propio negocio. Guárdalo en el hilo y ya. No
13875
+ * abre la ventana de 24 horas de WhatsApp.
13876
+ */
13877
+ interface MessageEchoChange extends AccountWebhookChangeBase {
13878
+ field: "message_echoes";
13879
+ messageObj?: Message;
13880
+ /** El contacto al que escribió el negocio */
13881
+ id_contact?: string;
13882
+ }
13849
13883
  /**
13850
13884
  * Llegó un comentario.
13851
13885
  *
@@ -13927,11 +13961,16 @@ interface UnknownWebhookChange {
13927
13961
  * `CommentChange | UnknownWebhookChange`. Para estrechar de verdad están los predicados
13928
13962
  * {@link isCommentChange} y compañía, que es la forma recomendada.
13929
13963
  */
13930
- type WebhookChange = AccountStateChange | MessageChange | CommentChange | IntegrationErrorChange | AiPlanChange | UnknownWebhookChange;
13964
+ type WebhookChange = AccountStateChange | MessageChange | MessageEchoChange | CommentChange | IntegrationErrorChange | AiPlanChange | UnknownWebhookChange;
13931
13965
  /** Una cuenta se conectó o cambió de estado. */
13932
13966
  declare function isAccountStateChange(change: WebhookChange): change is AccountStateChange;
13933
13967
  /** Algo pasó en la mensajería. Incluye el visto y el rechazo de la red, no sólo el mensaje nuevo. */
13934
13968
  declare function isMessageChange(change: WebhookChange): change is MessageChange;
13969
+ /**
13970
+ * El negocio contestó desde la app WhatsApp Business del móvil. No es un mensaje entrante: no lo
13971
+ * contestes. {@link isMessageChange} no lo incluye.
13972
+ */
13973
+ declare function isMessageEchoChange(change: WebhookChange): change is MessageEchoChange;
13935
13974
  /** Llegó un comentario. */
13936
13975
  declare function isCommentChange(change: WebhookChange): change is CommentChange;
13937
13976
  /** Una integración dejó de funcionar. */
@@ -14080,4 +14119,4 @@ interface PlanVortexWebhooksOptions {
14080
14119
  */
14081
14120
  declare function planvortexWebhooks(options: PlanVortexWebhooksOptions): (request: WebhookRequestLike, response: WebhookResponseLike, next: (error?: unknown) => void) => void;
14082
14121
 
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, MessagingError 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 MessageOptions as aZ, type MessageType 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, WebhookBodyError as b$, type MetricRow as b0, NO_ERROR_CODE as b1, type components as b2, type operations as b3, type paths as b4, type webhooks as b5, type OpenEnum as b6, OrganizationError as b7, PLANVORTEX_ERROR_RANGES as b8, PlanLimitError as b9, type UnknownWebhookChange as bA, UserError as bB, type WebhookAlgorithm as bC, type WebhookChange as bD, type WebhookEvent as bE, type WithAccount as bF, type WithPublication as bG, type WooCommerceConnectRequest as bH, account as bI, accountId as bJ, errorFamilyForCode as bK, isPlanVortexError as bL, isTokenError as bM, messageContact as bN, messageContactId as bO, messageDirection as bP, messageFileIds as bQ, messageFiles as bR, publication as bS, publicationId as bT, type AiPlanChange as bU, type HandleWebhookRequestOptions as bV, type PlanVortexWebhooksOptions as bW, type RawWebhookBody as bX, type VerifyWebhookSignatureOptions as bY, WEBHOOK_EVENTS as bZ, WEBHOOK_SIGNATURE_HEADERS as b_, PlanVortexAuthenticationError as ba, PlanVortexConfigError as bb, PlanVortexConnectionError as bc, PlanVortexError as bd, type PlanVortexErrorOptions as be, type PlanVortexErrorRange as bf, type PlannerTemplateField as bg, type PlannerTemplateFieldType as bh, ProductError as bi, type PublicationAiGenerated as bj, type PublicationDestination as bk, PublicationError as bl, type PublicationErrorDetail as bm, type PublicationMetrics as bn, type PublicationPending as bo, type PublicationStatsPoint as bp, type PublicationType as bq, type PublicationsSummary as br, type RssConfig as bs, type SocialAuthorizationMethod as bt, type SocialCredentials as bu, type SocialIdentifier as bv, type SocialIdentifierInput as bw, type SocialLimitsMap as bx, TOKEN_ERROR_CODES as by, type TopPublication as bz, type AccountMetrics as c, type WebhookHeaders as c0, type WebhookRequestLike as c1, type WebhookResponseLike as c2, WebhookSignatureError as c3, handleWebhookRequest as c4, isAccountStateChange as c5, isAiPlanChange as c6, isCommentChange as c7, isIntegrationErrorChange as c8, isMessageChange as c9, parseWebhookPayload as ca, planvortexWebhooks as cb, verifyWebhookSignature as cc, 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 };
14122
+ 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 };
@@ -2711,7 +2711,7 @@ interface webhooks {
2711
2711
  *
2712
2712
  * 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
2713
  *
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`.
2714
+ * 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
2715
  *
2716
2716
  * ### Comments
2717
2717
  *
@@ -2729,6 +2729,12 @@ interface webhooks {
2729
2729
  *
2730
2730
  * 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
2731
  *
2732
+ * ### WhatsApp replies sent from the phone
2733
+ *
2734
+ * 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.
2735
+ *
2736
+ * 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`.
2737
+ *
2732
2738
  * ### Verifying the signature
2733
2739
  *
2734
2740
  * Every delivery carries the body signed with your app's secret, twice:
@@ -3411,7 +3417,7 @@ interface components {
3411
3417
  *
3412
3418
  * **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
3419
  *
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.
3420
+ * 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
3421
  */
3416
3422
  webhook_url?: string;
3417
3423
  };
@@ -3889,15 +3895,16 @@ interface components {
3889
3895
  /**
3890
3896
  * @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
3897
  *
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.
3898
+ * - `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
3899
  * - `messages`: a message came in. It travels in `messageObj`.
3894
3900
  * - `messaging_postbacks`: the contact pressed a button or a quick reply. Also in `messageObj`.
3895
3901
  * - `messaging_seen`: the contact read the conversation. `messageObj` carries the message they read, when we still have it.
3896
3902
  * - `messaging_error`: the network refused a message we sent. The reason is in `messageObj.message_errors`.
3903
+ * - `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
3904
  * - `comments`: a comment came in. It travels in `commentObj`, never in `messageObj`.
3898
3905
  * @enum {string}
3899
3906
  */
3900
- field: "new_account" | "change_state_account" | "messages" | "messaging_postbacks" | "messaging_seen" | "messaging_error" | "comments";
3907
+ field: "new_account" | "change_state_account" | "messages" | "messaging_postbacks" | "messaging_seen" | "messaging_error" | "message_echoes" | "comments";
3901
3908
  id_account: string;
3902
3909
  /** @description Only for messaging fields. A comment has no contact: its author is not someone you can write to. */
3903
3910
  id_contact?: string;
@@ -4470,6 +4477,16 @@ interface components {
4470
4477
  contact_id?: string | components["schemas"]["Contact"];
4471
4478
  /** Format: date-time */
4472
4479
  creation_date: string;
4480
+ /**
4481
+ * Format: date-time
4482
+ * @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.
4483
+ */
4484
+ deleted_date?: string;
4485
+ /**
4486
+ * Format: date-time
4487
+ * @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.
4488
+ */
4489
+ edit_date?: string;
4473
4490
  /** @description Identifier of this message on the network. */
4474
4491
  element_external_id?: string;
4475
4492
  /** @description Set when the **contact** wrote to us. */
@@ -4564,9 +4581,11 @@ interface components {
4564
4581
  };
4565
4582
  /**
4566
4583
  * @description What kind of message this is. `simple_message` and `file_message` work everywhere; the rest are network-specific shapes.
4584
+ *
4585
+ * `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
4586
  * @enum {string}
4568
4587
  */
4569
- MessageType: "simple_message" | "file_message" | "comment_message" | "publication_message" | "quick_reply_message" | "button_message" | "elements_message" | "postback_message" | "template_message" | "interactive_message";
4588
+ 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
4589
  /**
4571
4590
  * @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
4591
  *
@@ -13814,7 +13833,7 @@ type WebhookAlgorithm = keyof typeof WEBHOOK_SIGNATURE_HEADERS;
13814
13833
  * **La lista crece**, así que un `field` desconocido se ignora en vez de romper: para eso está
13815
13834
  * {@link UnknownWebhookChange}.
13816
13835
  */
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"];
13836
+ 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
13837
  type WebhookEvent = (typeof WEBHOOK_EVENTS)[number];
13819
13838
  /** Lo que trae todo cambio que cuelga de una CUENTA, pase lo que pase. */
13820
13839
  interface AccountWebhookChangeBase {
@@ -13846,6 +13865,21 @@ interface MessageChange extends AccountWebhookChangeBase {
13846
13865
  /** El contacto del otro lado. Un comentario no tiene, y por eso aquí sí y allí no. */
13847
13866
  id_contact?: string;
13848
13867
  }
13868
+ /**
13869
+ * WhatsApp, cuando el número se usa también en la **app WhatsApp Business** del móvil: el negocio
13870
+ * contestó desde la app. `messageObj` es un mensaje **nuestro** —lleva `contact_id`, el contacto al
13871
+ * que se escribió, y no `from_contact_id`— y llega poblado, como en {@link MessageChange}.
13872
+ *
13873
+ * Es un evento aparte a propósito, y {@link isMessageChange} **no** lo incluye: un bot que contesta a
13874
+ * cada mensaje que entra no tiene que contestarle al propio negocio. Guárdalo en el hilo y ya. No
13875
+ * abre la ventana de 24 horas de WhatsApp.
13876
+ */
13877
+ interface MessageEchoChange extends AccountWebhookChangeBase {
13878
+ field: "message_echoes";
13879
+ messageObj?: Message;
13880
+ /** El contacto al que escribió el negocio */
13881
+ id_contact?: string;
13882
+ }
13849
13883
  /**
13850
13884
  * Llegó un comentario.
13851
13885
  *
@@ -13927,11 +13961,16 @@ interface UnknownWebhookChange {
13927
13961
  * `CommentChange | UnknownWebhookChange`. Para estrechar de verdad están los predicados
13928
13962
  * {@link isCommentChange} y compañía, que es la forma recomendada.
13929
13963
  */
13930
- type WebhookChange = AccountStateChange | MessageChange | CommentChange | IntegrationErrorChange | AiPlanChange | UnknownWebhookChange;
13964
+ type WebhookChange = AccountStateChange | MessageChange | MessageEchoChange | CommentChange | IntegrationErrorChange | AiPlanChange | UnknownWebhookChange;
13931
13965
  /** Una cuenta se conectó o cambió de estado. */
13932
13966
  declare function isAccountStateChange(change: WebhookChange): change is AccountStateChange;
13933
13967
  /** Algo pasó en la mensajería. Incluye el visto y el rechazo de la red, no sólo el mensaje nuevo. */
13934
13968
  declare function isMessageChange(change: WebhookChange): change is MessageChange;
13969
+ /**
13970
+ * El negocio contestó desde la app WhatsApp Business del móvil. No es un mensaje entrante: no lo
13971
+ * contestes. {@link isMessageChange} no lo incluye.
13972
+ */
13973
+ declare function isMessageEchoChange(change: WebhookChange): change is MessageEchoChange;
13935
13974
  /** Llegó un comentario. */
13936
13975
  declare function isCommentChange(change: WebhookChange): change is CommentChange;
13937
13976
  /** Una integración dejó de funcionar. */
@@ -14080,4 +14119,4 @@ interface PlanVortexWebhooksOptions {
14080
14119
  */
14081
14120
  declare function planvortexWebhooks(options: PlanVortexWebhooksOptions): (request: WebhookRequestLike, response: WebhookResponseLike, next: (error?: unknown) => void) => void;
14082
14121
 
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, MessagingError 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 MessageOptions as aZ, type MessageType 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, WebhookBodyError as b$, type MetricRow as b0, NO_ERROR_CODE as b1, type components as b2, type operations as b3, type paths as b4, type webhooks as b5, type OpenEnum as b6, OrganizationError as b7, PLANVORTEX_ERROR_RANGES as b8, PlanLimitError as b9, type UnknownWebhookChange as bA, UserError as bB, type WebhookAlgorithm as bC, type WebhookChange as bD, type WebhookEvent as bE, type WithAccount as bF, type WithPublication as bG, type WooCommerceConnectRequest as bH, account as bI, accountId as bJ, errorFamilyForCode as bK, isPlanVortexError as bL, isTokenError as bM, messageContact as bN, messageContactId as bO, messageDirection as bP, messageFileIds as bQ, messageFiles as bR, publication as bS, publicationId as bT, type AiPlanChange as bU, type HandleWebhookRequestOptions as bV, type PlanVortexWebhooksOptions as bW, type RawWebhookBody as bX, type VerifyWebhookSignatureOptions as bY, WEBHOOK_EVENTS as bZ, WEBHOOK_SIGNATURE_HEADERS as b_, PlanVortexAuthenticationError as ba, PlanVortexConfigError as bb, PlanVortexConnectionError as bc, PlanVortexError as bd, type PlanVortexErrorOptions as be, type PlanVortexErrorRange as bf, type PlannerTemplateField as bg, type PlannerTemplateFieldType as bh, ProductError as bi, type PublicationAiGenerated as bj, type PublicationDestination as bk, PublicationError as bl, type PublicationErrorDetail as bm, type PublicationMetrics as bn, type PublicationPending as bo, type PublicationStatsPoint as bp, type PublicationType as bq, type PublicationsSummary as br, type RssConfig as bs, type SocialAuthorizationMethod as bt, type SocialCredentials as bu, type SocialIdentifier as bv, type SocialIdentifierInput as bw, type SocialLimitsMap as bx, TOKEN_ERROR_CODES as by, type TopPublication as bz, type AccountMetrics as c, type WebhookHeaders as c0, type WebhookRequestLike as c1, type WebhookResponseLike as c2, WebhookSignatureError as c3, handleWebhookRequest as c4, isAccountStateChange as c5, isAiPlanChange as c6, isCommentChange as c7, isIntegrationErrorChange as c8, isMessageChange as c9, parseWebhookPayload as ca, planvortexWebhooks as cb, verifyWebhookSignature as cc, 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 };
14122
+ 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.18.1";
7
+ var VERSION = "0.19.0";
8
8
 
9
9
  // src/core/errors.ts
10
10
  var PLANVORTEX_ERROR_RANGES = [