planvortex 0.13.0 → 0.15.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 +61 -18
- package/dist/{chunk-73WEEBP3.js → chunk-4EPTOW4H.js} +5 -4
- package/dist/chunk-4EPTOW4H.js.map +1 -0
- package/dist/{index-7HrCQCrx.d.cts → index-DnfzM7vS.d.cts} +482 -28
- package/dist/{index-7HrCQCrx.d.ts → index-DnfzM7vS.d.ts} +482 -28
- package/dist/index.cjs +67 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +64 -10
- package/dist/index.d.ts +64 -10
- package/dist/index.js +66 -8
- package/dist/index.js.map +1 -1
- package/dist/webhooks/index.cjs +11 -3
- 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 +9 -3
- package/dist/webhooks/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-73WEEBP3.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as Paginated, S as SocialNetwork, C as ConnectLink, a as ConnectResult, E as EnableResult, A as Account,
|
|
2
|
-
export {
|
|
1
|
+
import { P as Paginated, S as SocialNetwork, C as ConnectLink, a as ConnectResult, E as EnableResult, b as ConnectSession, A as Account, c as AccountMetrics, D as Destination, d as PersistentMenu, e as Dashboard, M as MetricName, f as DashboardMetricsResult, g as PublicationsSummaryResult, T as TopPublicationsResult, h as PublicationsStatsResult, i as PlanUse, j as Publication, k as AiPlanResultsSort, l as PlannerTemplateName, m as AiPlanCreateRequest, n as AiPlanCreateResult, o as AiPlan, p as AiPlanResults, q as ClientApp, r as ClientAppInput, s as SocialCapabilities, t as CommentActions, u as SocialLimits, v as PublicationLimits, w as AspectRatiosByNetwork, x as PlannerTemplate, y as CommentNetwork, z as Comment, B as CommentThread, F as CommentReplyResult, G as ContactExtraData, H as Contact, I as ContactCreate, J as ContactUpdate, K as IntegrationProviderName, L as IntegrationProvider, N as Integration, O as IntegrationConnectRequest, Q as IntegrationUpdate, R as IntegrationPickerConfig, U as IntegrationCatalogPage, V as MessageTemplate, W as Conversation, X as ConversationTotals, Y as Message, Z as MessageInput, _ as Client, $ as Organization, a0 as AiSettings, a1 as ClientWithOrganizations, a2 as AccountSelection, a3 as PlanData, a4 as PlanUseData, a5 as ConnectToken, a6 as AiContext, a7 as SocialCredentialsInput, a8 as Product, a9 as ProductInput, aa as ProductCatalog, ab as ProductCatalogInput, ac as PublicationInput, ad as PublicationState, ae as PublicationStats, af as PublicationStatsHistory, ag as Upload } from './index-DnfzM7vS.cjs';
|
|
2
|
+
export { ah as AccountError, ai as AccountMetricRow, aj as AccountStateChange, ak as AccountWebhookChangeBase, al as AccountWithError, am as AiImageOrigin, an as AiPlanCostEstimate, ao as AiPlanDestination, ap as AiPlanError, aq as AiPlanNotice, ar as AiPlanOptions, as as AiPlanOptionsInput, at as AiPlanResult, au as AiPlanResultsGroup, av as AiPlanResultsTemplateGroup, aw as AiPlanSource, ax as AiPlanSourceImageInput, ay as AiPlanSourceInput, az as AiPlanSourceProduct, aA as AiPlanState, aB as ApiErrorBody, aC as AspectRatios, aD as AuthError, aE as ClientPlan, aF as CommentAuthor, aG as CommentChange, aH as ConnectSessionAccount, aI as ContactChannel, aJ as ContactError, aK as DashboardAiPlanRef, aL as DashboardPublicationRef, aM as DashboardRange, aN as EngagementBase, aO as FileError, aP as FileFormat, aQ as FileProperties, aR as FileType, aS as IntegrationCatalogProduct, aT as IntegrationConfig, aU as IntegrationError, aV as IntegrationErrorChange, aW as IntegrationFormField, aX as MessageChange, aY as MessageOptions, aZ as MessageType, a_ as MessagingError, a$ as MetricRow, b0 as NO_ERROR_CODE, b1 as OpenApiComponents, b2 as OpenApiOperations, b3 as OpenApiPaths, b4 as OpenApiWebhooks, b5 as OpenEnum, b6 as OrganizationError, b7 as PLANVORTEX_ERROR_RANGES, b8 as PlanLimitError, b9 as PlanVortexAuthenticationError, ba as PlanVortexConfigError, bb as PlanVortexConnectionError, bc as PlanVortexError, bd as PlanVortexErrorOptions, be as PlanVortexErrorRange, bf as PlannerTemplateField, bg as PlannerTemplateFieldType, bh as ProductError, bi as PublicationAiGenerated, bj as PublicationDestination, bk as PublicationError, bl as PublicationErrorDetail, bm as PublicationMetrics, bn as PublicationPending, bo as PublicationStatsPoint, bp as PublicationType, bq as PublicationsSummary, br as RssConfig, bs as SocialAuthorizationMethod, bt as SocialCredentials, bu as SocialIdentifier, bv as SocialIdentifierInput, bw as SocialLimitsMap, bx as TOKEN_ERROR_CODES, by as TopPublication, bz as UnknownWebhookChange, bA as UserError, bB as WebhookAlgorithm, bC as WebhookChange, bD as WebhookEvent, bE as WithAccount, bF as WithPublication, bG as WooCommerceConnectRequest, bH as account, bI as accountId, bJ as errorFamilyForCode, bK as isPlanVortexError, bL as isTokenError, bM as messageContact, bN as messageContactId, bO as messageDirection, bP as messageFileIds, bQ as messageFiles, bR as publication, bS as publicationId } from './index-DnfzM7vS.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Las dos constantes que todo lo demás necesita. Viven aparte de `index.ts` para que `client.ts`
|
|
@@ -15,7 +15,7 @@ declare const PLANVORTEX_API_URL = "https://api.planvortex.com/v1.0.0";
|
|
|
15
15
|
* de ejecución obliga a empaquetarlo y se rompe distinto en ESM y en CJS. La mantiene sincronizada
|
|
16
16
|
* un test.
|
|
17
17
|
*/
|
|
18
|
-
declare const VERSION = "0.
|
|
18
|
+
declare const VERSION = "0.15.0";
|
|
19
19
|
|
|
20
20
|
/** `fetch` con la firma que usamos. Se puede sustituir en tests o para meter un proxy. */
|
|
21
21
|
type FetchLike = (input: string, init: RequestInit) => Promise<Response>;
|
|
@@ -283,6 +283,29 @@ declare class AccountsResource extends Resource {
|
|
|
283
283
|
* canal, no después.
|
|
284
284
|
*/
|
|
285
285
|
enable(idOrganization: string, idAccount: string, options?: RequestOptions): Promise<EnableResult>;
|
|
286
|
+
/**
|
|
287
|
+
* Una sesión de conexión: lo que autorizó tu usuario cuando el token se emitió con
|
|
288
|
+
* `account_selection: "integrator"`. Es lo que pintas en TU selector de cuentas.
|
|
289
|
+
*
|
|
290
|
+
* El `idSession` es el `connect_session` que llega a tu `redirect_uri` (y el que te devolvió
|
|
291
|
+
* `createConnectToken`: compáralos, para que una sesión que empezó otro no acabe en el navegador
|
|
292
|
+
* de tu usuario). Si en esa URL viene también `error`, la conexión no terminó —`access_denied`
|
|
293
|
+
* si canceló, `no_accounts` si la red no devolvió ninguna, `connect_failed` con `error_code`—
|
|
294
|
+
* y la sesión sigue `pending`: puede reintentarlo con el mismo enlace.
|
|
295
|
+
*
|
|
296
|
+
* **Sólo la app que emitió el token.** Cualquier otra recibe 551, igual que una sesión que no
|
|
297
|
+
* existe o que ha caducado: una `returned` vive media hora.
|
|
298
|
+
*/
|
|
299
|
+
getConnectSession(idOrganization: string, idSession: string, options?: RequestOptions): Promise<ConnectSession>;
|
|
300
|
+
/**
|
|
301
|
+
* Habilita las cuentas que eligió tu usuario y cierra la sesión. Una lista vacía es «ninguna».
|
|
302
|
+
*
|
|
303
|
+
* **O todas o ninguna**: si las nuevas no caben en el plan contesta 706 con
|
|
304
|
+
* `{limit, used, requested}` y no habilita NINGUNA, así que ese número se le puede enseñar tal
|
|
305
|
+
* cual. Las que ya estaban activas (`already_enabled`) no cuentan. Cada cuenta habilitada
|
|
306
|
+
* dispara el webhook `new_account`, como en cualquier conexión.
|
|
307
|
+
*/
|
|
308
|
+
confirmConnectSession(idOrganization: string, idSession: string, accountIds: readonly string[], options?: RequestOptions): Promise<Account[]>;
|
|
286
309
|
/** Las cuentas de una organización. */
|
|
287
310
|
list(idOrganization: string, options?: AccountListOptions & RequestOptions): Promise<Paginated<Account>>;
|
|
288
311
|
/** Las cuentas de una organización, encadenando páginas. */
|
|
@@ -489,8 +512,9 @@ declare class DashboardResource extends Resource {
|
|
|
489
512
|
* Y LO QUE SORPRENDE:
|
|
490
513
|
*
|
|
491
514
|
* - **`create()` no genera nada**: encola el plan y devuelve el presupuesto. La generación la hace
|
|
492
|
-
* un job aparte
|
|
493
|
-
* `
|
|
515
|
+
* un job aparte y puede tardar minutos. Cuando termina, el `webhook_url` de tu app recibe
|
|
516
|
+
* `ai_plan_generated` o `ai_plan_failed` (`isAiPlanChange` de `planvortex/webhooks`); sin
|
|
517
|
+
* webhook, sondea {@link AiPlansResource.get} mientras el estado sea `pending` o `generating`.
|
|
494
518
|
* - **Lo generado son publicaciones NORMALES en estado `draft`.** Se editan y se borran con
|
|
495
519
|
* `pv.publications`, no con nada de aquí. Validar es lo que las pasa a `ready`.
|
|
496
520
|
* - **Se paga en créditos de IA y el precio se sabe ANTES.** El presupuesto lo calcula el
|
|
@@ -630,8 +654,9 @@ declare class AiPlansResource extends Resource {
|
|
|
630
654
|
/**
|
|
631
655
|
* Un plan, con sus publicaciones **ya resueltas** y con los ficheros de cada una.
|
|
632
656
|
*
|
|
633
|
-
*
|
|
634
|
-
*
|
|
657
|
+
* Léelo cuando a tu app le llegue `ai_plan_generated` o `ai_plan_failed`. Sin webhook, es el
|
|
658
|
+
* endpoint que se sondea mientras `state` sea `pending` o `generating`. El webhook no se
|
|
659
|
+
* reintenta: si tu endpoint estaba caído cuando el plan terminó, esto sigue diciendo cómo acabó.
|
|
635
660
|
*/
|
|
636
661
|
get(idClient: string, idOrganization: string, idAiPlan: string, options?: RequestOptions): Promise<AiPlan>;
|
|
637
662
|
/**
|
|
@@ -686,8 +711,8 @@ declare class AiPlansResource extends Resource {
|
|
|
686
711
|
*/
|
|
687
712
|
validate(idClient: string, idOrganization: string, idAiPlan: string, options?: RequestOptions): Promise<AiPlan>;
|
|
688
713
|
/**
|
|
689
|
-
* Vuelve a encolar un plan `failed` con los mismos datos. El estado regresa a `pending` y
|
|
690
|
-
*
|
|
714
|
+
* Vuelve a encolar un plan `failed` con los mismos datos. El estado regresa a `pending` y el
|
|
715
|
+
* final vuelve a llegar como tras `create()`: por webhook, o sondeando.
|
|
691
716
|
*
|
|
692
717
|
* Usa el contexto de marca copiado al crear el plan, no el actual: el plan es reproducible
|
|
693
718
|
* aunque alguien haya editado la configuración entretanto.
|
|
@@ -1495,6 +1520,22 @@ declare class MessagesResource extends Resource {
|
|
|
1495
1520
|
* En Facebook e Instagram sólo se admite **un** adjunto por mensaje (error 1509), y en WhatsApp
|
|
1496
1521
|
* fuera de la ventana de 24 horas sólo se admite una plantilla.
|
|
1497
1522
|
*
|
|
1523
|
+
* Si el cuerpo de la plantilla tiene variables, sus valores van en `template_parameters`, en
|
|
1524
|
+
* orden: el primero rellena `{{1}}`, el segundo `{{2}}`. Sin ellos WhatsApp rechaza la plantilla.
|
|
1525
|
+
* Un valor vacío, con saltos de línea, tabuladores o más de cuatro espacios seguidos es un 1511
|
|
1526
|
+
* con `data.index` apuntando al que falla. Sólo variables posicionales del cuerpo:
|
|
1527
|
+
*
|
|
1528
|
+
* ```ts
|
|
1529
|
+
* await pv.messages.send(orgId, accountId, contactId, {
|
|
1530
|
+
* message_type: "template_message",
|
|
1531
|
+
* message_options: {
|
|
1532
|
+
* template_name: "recordatorio_cita",
|
|
1533
|
+
* template_language: "es",
|
|
1534
|
+
* template_parameters: ["María", "jueves 2 de octubre", "17:00"],
|
|
1535
|
+
* },
|
|
1536
|
+
* });
|
|
1537
|
+
* ```
|
|
1538
|
+
*
|
|
1498
1539
|
* `comment_message` y `publication_message` exigen `in_response_external_id`: el identificador
|
|
1499
1540
|
* EN LA RED de lo que se responde —el `external_id` de un comentario, el `external_identifier`
|
|
1500
1541
|
* de una publicación—, nunca un `_id` de PlanVortex, y error 1510 si falta. El endpoint no lo
|
|
@@ -1650,6 +1691,19 @@ interface ConnectTokenOptions extends RequestOptions {
|
|
|
1650
1691
|
* registrados en la app, o la llamada contesta el error 532.
|
|
1651
1692
|
*/
|
|
1652
1693
|
redirect_uri?: string | undefined;
|
|
1694
|
+
/**
|
|
1695
|
+
* Quién enseña la pantalla de elegir cuentas. Sin esto, PlanVortex (`"planvortex"`).
|
|
1696
|
+
*
|
|
1697
|
+
* Con `"integrator"` esa pantalla es tuya: la `url` que vuelve es la página de autorización
|
|
1698
|
+
* DE LA RED, el usuario va ahí directamente desde tu app, y al terminar aterriza en tu
|
|
1699
|
+
* `redirect_uri` con `?connect_session=…&social_network=…` sin ver nada de PlanVortex. Lees la
|
|
1700
|
+
* sesión con `accounts.getConnectSession()` y confirmas con `accounts.confirmConnectSession()`.
|
|
1701
|
+
*
|
|
1702
|
+
* Exige `redirect_uri` y `social_network` (549), y Telegram no puede (550): su enlace abre un
|
|
1703
|
+
* chat del que no se vuelve. En WhatsApp la `url` sigue siendo una página de PlanVortex con un
|
|
1704
|
+
* botón, porque el popup de Meta sólo se abre en nuestro dominio.
|
|
1705
|
+
*/
|
|
1706
|
+
account_selection?: AccountSelection | undefined;
|
|
1653
1707
|
}
|
|
1654
1708
|
declare class OrganizationsResource extends Resource {
|
|
1655
1709
|
/** La ficha de una organización. */
|
|
@@ -2203,4 +2257,4 @@ interface AuthProvider {
|
|
|
2203
2257
|
/** Margen con el que se pide un token nuevo antes de que caduque el que hay. */
|
|
2204
2258
|
declare const TOKEN_REFRESH_MARGIN_MS = 60000;
|
|
2205
2259
|
|
|
2206
|
-
export { Account, type AccountCapability, type AccountDestinationOptions, type AccountListOptions, AccountMetrics, type AccountMetricsOptions, AccountsResource, AiContext, AiPlan, AiPlanCreateRequest, AiPlanCreateResult, type AiPlanListOptions, type AiPlanRegenerateResult, type AiPlanRegenerateTarget, AiPlanResults, type AiPlanResultsOptions, AiPlanResultsSort, AiPlansResource, AiSettings, AppsResource, AspectRatiosByNetwork, type AuthProvider, CatalogResource, type ChildOrganizationListOptions, Client, ClientApp, ClientAppInput, type ClientCredentialsToken, type ClientListOptions, ClientWithOrganizations, ClientsResource, Comment, CommentActions, type CommentListOptions, CommentNetwork, CommentReplyResult, CommentThread, type CommentThreadOptions, type CommentUpdate, CommentsResource, type ConnectCallbackParams, ConnectLink, type ConnectLinkOptions, type ConnectLinksOptions, ConnectResult, ConnectToken, type ConnectTokenOptions, Contact, ContactCreate, ContactExtraData, type ContactExtraFilter, type ContactListOptions, ContactUpdate, ContactsResource, Conversation, type ConversationGroupBy, ConversationTotals, type ConversationTotalsOptions, DEFAULT_PAGE_SIZE, DEFAULT_RETRY, DEFAULT_TIMEOUT_MS, Dashboard, DashboardMetricsResult, DashboardResource, Destination, EnableResult, type FetchLike, type FileInput, type FileSource, type HttpHooks, type HttpMethod, type HttpRequest, type HttpResponse, type ImportError, type ImportFileInput, type ImportResult, Integration, IntegrationCatalogPage, IntegrationConnectRequest, type IntegrationListOptions, IntegrationPickerConfig, type IntegrationProductsOptions, IntegrationProvider, IntegrationProviderName, IntegrationUpdate, IntegrationsResource, MAX_PAGES, Message, MessageInput, MessageTemplate, type MessageTemplateResult, MessagesResource, MetricName, type MetricsGroupBy, type MetricsOptions, Organization, type OrganizationInput, type OrganizationListOptions, type OrganizationOptions, type OrganizationPlanInput, OrganizationsResource, PLANVORTEX_API_URL, type PageOptions, Paginated, PersistentMenu, PlanData, PlanUse, PlanUseData, PlanVortex, type PlanVortexOptions, PlannerTemplate, PlannerTemplateName, Product, ProductCatalog, ProductCatalogInput, ProductInput, ProductsResource, Publication, PublicationInput, PublicationLimits, type PublicationListOptions, type PublicationRetryResult, PublicationState, PublicationStats, PublicationStatsHistory, PublicationsResource, type PublicationsStatsOptions, PublicationsStatsResult, PublicationsSummaryResult, type QueryValue, type RangeOptions, type RequestInfo, type RequestOptions, type RequestSender, type ResponseInfo, type RetryConfig, type RetryInfo, SocialCapabilities, SocialLimits, SocialNetwork, TOKEN_REFRESH_MARGIN_MS, type TopPublicationsOptions, TopPublicationsResult, Upload, type UploadUpdate, UploadsResource, VERSION, guessContentType };
|
|
2260
|
+
export { Account, type AccountCapability, type AccountDestinationOptions, type AccountListOptions, AccountMetrics, type AccountMetricsOptions, AccountSelection, AccountsResource, AiContext, AiPlan, AiPlanCreateRequest, AiPlanCreateResult, type AiPlanListOptions, type AiPlanRegenerateResult, type AiPlanRegenerateTarget, AiPlanResults, type AiPlanResultsOptions, AiPlanResultsSort, AiPlansResource, AiSettings, AppsResource, AspectRatiosByNetwork, type AuthProvider, CatalogResource, type ChildOrganizationListOptions, Client, ClientApp, ClientAppInput, type ClientCredentialsToken, type ClientListOptions, ClientWithOrganizations, ClientsResource, Comment, CommentActions, type CommentListOptions, CommentNetwork, CommentReplyResult, CommentThread, type CommentThreadOptions, type CommentUpdate, CommentsResource, type ConnectCallbackParams, ConnectLink, type ConnectLinkOptions, type ConnectLinksOptions, ConnectResult, ConnectSession, ConnectToken, type ConnectTokenOptions, Contact, ContactCreate, ContactExtraData, type ContactExtraFilter, type ContactListOptions, ContactUpdate, ContactsResource, Conversation, type ConversationGroupBy, ConversationTotals, type ConversationTotalsOptions, DEFAULT_PAGE_SIZE, DEFAULT_RETRY, DEFAULT_TIMEOUT_MS, Dashboard, DashboardMetricsResult, DashboardResource, Destination, EnableResult, type FetchLike, type FileInput, type FileSource, type HttpHooks, type HttpMethod, type HttpRequest, type HttpResponse, type ImportError, type ImportFileInput, type ImportResult, Integration, IntegrationCatalogPage, IntegrationConnectRequest, type IntegrationListOptions, IntegrationPickerConfig, type IntegrationProductsOptions, IntegrationProvider, IntegrationProviderName, IntegrationUpdate, IntegrationsResource, MAX_PAGES, Message, MessageInput, MessageTemplate, type MessageTemplateResult, MessagesResource, MetricName, type MetricsGroupBy, type MetricsOptions, Organization, type OrganizationInput, type OrganizationListOptions, type OrganizationOptions, type OrganizationPlanInput, OrganizationsResource, PLANVORTEX_API_URL, type PageOptions, Paginated, PersistentMenu, PlanData, PlanUse, PlanUseData, PlanVortex, type PlanVortexOptions, PlannerTemplate, PlannerTemplateName, Product, ProductCatalog, ProductCatalogInput, ProductInput, ProductsResource, Publication, PublicationInput, PublicationLimits, type PublicationListOptions, type PublicationRetryResult, PublicationState, PublicationStats, PublicationStatsHistory, PublicationsResource, type PublicationsStatsOptions, PublicationsStatsResult, PublicationsSummaryResult, type QueryValue, type RangeOptions, type RequestInfo, type RequestOptions, type RequestSender, type ResponseInfo, type RetryConfig, type RetryInfo, SocialCapabilities, SocialLimits, SocialNetwork, TOKEN_REFRESH_MARGIN_MS, type TopPublicationsOptions, TopPublicationsResult, Upload, type UploadUpdate, UploadsResource, VERSION, guessContentType };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as Paginated, S as SocialNetwork, C as ConnectLink, a as ConnectResult, E as EnableResult, A as Account,
|
|
2
|
-
export {
|
|
1
|
+
import { P as Paginated, S as SocialNetwork, C as ConnectLink, a as ConnectResult, E as EnableResult, b as ConnectSession, A as Account, c as AccountMetrics, D as Destination, d as PersistentMenu, e as Dashboard, M as MetricName, f as DashboardMetricsResult, g as PublicationsSummaryResult, T as TopPublicationsResult, h as PublicationsStatsResult, i as PlanUse, j as Publication, k as AiPlanResultsSort, l as PlannerTemplateName, m as AiPlanCreateRequest, n as AiPlanCreateResult, o as AiPlan, p as AiPlanResults, q as ClientApp, r as ClientAppInput, s as SocialCapabilities, t as CommentActions, u as SocialLimits, v as PublicationLimits, w as AspectRatiosByNetwork, x as PlannerTemplate, y as CommentNetwork, z as Comment, B as CommentThread, F as CommentReplyResult, G as ContactExtraData, H as Contact, I as ContactCreate, J as ContactUpdate, K as IntegrationProviderName, L as IntegrationProvider, N as Integration, O as IntegrationConnectRequest, Q as IntegrationUpdate, R as IntegrationPickerConfig, U as IntegrationCatalogPage, V as MessageTemplate, W as Conversation, X as ConversationTotals, Y as Message, Z as MessageInput, _ as Client, $ as Organization, a0 as AiSettings, a1 as ClientWithOrganizations, a2 as AccountSelection, a3 as PlanData, a4 as PlanUseData, a5 as ConnectToken, a6 as AiContext, a7 as SocialCredentialsInput, a8 as Product, a9 as ProductInput, aa as ProductCatalog, ab as ProductCatalogInput, ac as PublicationInput, ad as PublicationState, ae as PublicationStats, af as PublicationStatsHistory, ag as Upload } from './index-DnfzM7vS.js';
|
|
2
|
+
export { ah as AccountError, ai as AccountMetricRow, aj as AccountStateChange, ak as AccountWebhookChangeBase, al as AccountWithError, am as AiImageOrigin, an as AiPlanCostEstimate, ao as AiPlanDestination, ap as AiPlanError, aq as AiPlanNotice, ar as AiPlanOptions, as as AiPlanOptionsInput, at as AiPlanResult, au as AiPlanResultsGroup, av as AiPlanResultsTemplateGroup, aw as AiPlanSource, ax as AiPlanSourceImageInput, ay as AiPlanSourceInput, az as AiPlanSourceProduct, aA as AiPlanState, aB as ApiErrorBody, aC as AspectRatios, aD as AuthError, aE as ClientPlan, aF as CommentAuthor, aG as CommentChange, aH as ConnectSessionAccount, aI as ContactChannel, aJ as ContactError, aK as DashboardAiPlanRef, aL as DashboardPublicationRef, aM as DashboardRange, aN as EngagementBase, aO as FileError, aP as FileFormat, aQ as FileProperties, aR as FileType, aS as IntegrationCatalogProduct, aT as IntegrationConfig, aU as IntegrationError, aV as IntegrationErrorChange, aW as IntegrationFormField, aX as MessageChange, aY as MessageOptions, aZ as MessageType, a_ as MessagingError, a$ as MetricRow, b0 as NO_ERROR_CODE, b1 as OpenApiComponents, b2 as OpenApiOperations, b3 as OpenApiPaths, b4 as OpenApiWebhooks, b5 as OpenEnum, b6 as OrganizationError, b7 as PLANVORTEX_ERROR_RANGES, b8 as PlanLimitError, b9 as PlanVortexAuthenticationError, ba as PlanVortexConfigError, bb as PlanVortexConnectionError, bc as PlanVortexError, bd as PlanVortexErrorOptions, be as PlanVortexErrorRange, bf as PlannerTemplateField, bg as PlannerTemplateFieldType, bh as ProductError, bi as PublicationAiGenerated, bj as PublicationDestination, bk as PublicationError, bl as PublicationErrorDetail, bm as PublicationMetrics, bn as PublicationPending, bo as PublicationStatsPoint, bp as PublicationType, bq as PublicationsSummary, br as RssConfig, bs as SocialAuthorizationMethod, bt as SocialCredentials, bu as SocialIdentifier, bv as SocialIdentifierInput, bw as SocialLimitsMap, bx as TOKEN_ERROR_CODES, by as TopPublication, bz as UnknownWebhookChange, bA as UserError, bB as WebhookAlgorithm, bC as WebhookChange, bD as WebhookEvent, bE as WithAccount, bF as WithPublication, bG as WooCommerceConnectRequest, bH as account, bI as accountId, bJ as errorFamilyForCode, bK as isPlanVortexError, bL as isTokenError, bM as messageContact, bN as messageContactId, bO as messageDirection, bP as messageFileIds, bQ as messageFiles, bR as publication, bS as publicationId } from './index-DnfzM7vS.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Las dos constantes que todo lo demás necesita. Viven aparte de `index.ts` para que `client.ts`
|
|
@@ -15,7 +15,7 @@ declare const PLANVORTEX_API_URL = "https://api.planvortex.com/v1.0.0";
|
|
|
15
15
|
* de ejecución obliga a empaquetarlo y se rompe distinto en ESM y en CJS. La mantiene sincronizada
|
|
16
16
|
* un test.
|
|
17
17
|
*/
|
|
18
|
-
declare const VERSION = "0.
|
|
18
|
+
declare const VERSION = "0.15.0";
|
|
19
19
|
|
|
20
20
|
/** `fetch` con la firma que usamos. Se puede sustituir en tests o para meter un proxy. */
|
|
21
21
|
type FetchLike = (input: string, init: RequestInit) => Promise<Response>;
|
|
@@ -283,6 +283,29 @@ declare class AccountsResource extends Resource {
|
|
|
283
283
|
* canal, no después.
|
|
284
284
|
*/
|
|
285
285
|
enable(idOrganization: string, idAccount: string, options?: RequestOptions): Promise<EnableResult>;
|
|
286
|
+
/**
|
|
287
|
+
* Una sesión de conexión: lo que autorizó tu usuario cuando el token se emitió con
|
|
288
|
+
* `account_selection: "integrator"`. Es lo que pintas en TU selector de cuentas.
|
|
289
|
+
*
|
|
290
|
+
* El `idSession` es el `connect_session` que llega a tu `redirect_uri` (y el que te devolvió
|
|
291
|
+
* `createConnectToken`: compáralos, para que una sesión que empezó otro no acabe en el navegador
|
|
292
|
+
* de tu usuario). Si en esa URL viene también `error`, la conexión no terminó —`access_denied`
|
|
293
|
+
* si canceló, `no_accounts` si la red no devolvió ninguna, `connect_failed` con `error_code`—
|
|
294
|
+
* y la sesión sigue `pending`: puede reintentarlo con el mismo enlace.
|
|
295
|
+
*
|
|
296
|
+
* **Sólo la app que emitió el token.** Cualquier otra recibe 551, igual que una sesión que no
|
|
297
|
+
* existe o que ha caducado: una `returned` vive media hora.
|
|
298
|
+
*/
|
|
299
|
+
getConnectSession(idOrganization: string, idSession: string, options?: RequestOptions): Promise<ConnectSession>;
|
|
300
|
+
/**
|
|
301
|
+
* Habilita las cuentas que eligió tu usuario y cierra la sesión. Una lista vacía es «ninguna».
|
|
302
|
+
*
|
|
303
|
+
* **O todas o ninguna**: si las nuevas no caben en el plan contesta 706 con
|
|
304
|
+
* `{limit, used, requested}` y no habilita NINGUNA, así que ese número se le puede enseñar tal
|
|
305
|
+
* cual. Las que ya estaban activas (`already_enabled`) no cuentan. Cada cuenta habilitada
|
|
306
|
+
* dispara el webhook `new_account`, como en cualquier conexión.
|
|
307
|
+
*/
|
|
308
|
+
confirmConnectSession(idOrganization: string, idSession: string, accountIds: readonly string[], options?: RequestOptions): Promise<Account[]>;
|
|
286
309
|
/** Las cuentas de una organización. */
|
|
287
310
|
list(idOrganization: string, options?: AccountListOptions & RequestOptions): Promise<Paginated<Account>>;
|
|
288
311
|
/** Las cuentas de una organización, encadenando páginas. */
|
|
@@ -489,8 +512,9 @@ declare class DashboardResource extends Resource {
|
|
|
489
512
|
* Y LO QUE SORPRENDE:
|
|
490
513
|
*
|
|
491
514
|
* - **`create()` no genera nada**: encola el plan y devuelve el presupuesto. La generación la hace
|
|
492
|
-
* un job aparte
|
|
493
|
-
* `
|
|
515
|
+
* un job aparte y puede tardar minutos. Cuando termina, el `webhook_url` de tu app recibe
|
|
516
|
+
* `ai_plan_generated` o `ai_plan_failed` (`isAiPlanChange` de `planvortex/webhooks`); sin
|
|
517
|
+
* webhook, sondea {@link AiPlansResource.get} mientras el estado sea `pending` o `generating`.
|
|
494
518
|
* - **Lo generado son publicaciones NORMALES en estado `draft`.** Se editan y se borran con
|
|
495
519
|
* `pv.publications`, no con nada de aquí. Validar es lo que las pasa a `ready`.
|
|
496
520
|
* - **Se paga en créditos de IA y el precio se sabe ANTES.** El presupuesto lo calcula el
|
|
@@ -630,8 +654,9 @@ declare class AiPlansResource extends Resource {
|
|
|
630
654
|
/**
|
|
631
655
|
* Un plan, con sus publicaciones **ya resueltas** y con los ficheros de cada una.
|
|
632
656
|
*
|
|
633
|
-
*
|
|
634
|
-
*
|
|
657
|
+
* Léelo cuando a tu app le llegue `ai_plan_generated` o `ai_plan_failed`. Sin webhook, es el
|
|
658
|
+
* endpoint que se sondea mientras `state` sea `pending` o `generating`. El webhook no se
|
|
659
|
+
* reintenta: si tu endpoint estaba caído cuando el plan terminó, esto sigue diciendo cómo acabó.
|
|
635
660
|
*/
|
|
636
661
|
get(idClient: string, idOrganization: string, idAiPlan: string, options?: RequestOptions): Promise<AiPlan>;
|
|
637
662
|
/**
|
|
@@ -686,8 +711,8 @@ declare class AiPlansResource extends Resource {
|
|
|
686
711
|
*/
|
|
687
712
|
validate(idClient: string, idOrganization: string, idAiPlan: string, options?: RequestOptions): Promise<AiPlan>;
|
|
688
713
|
/**
|
|
689
|
-
* Vuelve a encolar un plan `failed` con los mismos datos. El estado regresa a `pending` y
|
|
690
|
-
*
|
|
714
|
+
* Vuelve a encolar un plan `failed` con los mismos datos. El estado regresa a `pending` y el
|
|
715
|
+
* final vuelve a llegar como tras `create()`: por webhook, o sondeando.
|
|
691
716
|
*
|
|
692
717
|
* Usa el contexto de marca copiado al crear el plan, no el actual: el plan es reproducible
|
|
693
718
|
* aunque alguien haya editado la configuración entretanto.
|
|
@@ -1495,6 +1520,22 @@ declare class MessagesResource extends Resource {
|
|
|
1495
1520
|
* En Facebook e Instagram sólo se admite **un** adjunto por mensaje (error 1509), y en WhatsApp
|
|
1496
1521
|
* fuera de la ventana de 24 horas sólo se admite una plantilla.
|
|
1497
1522
|
*
|
|
1523
|
+
* Si el cuerpo de la plantilla tiene variables, sus valores van en `template_parameters`, en
|
|
1524
|
+
* orden: el primero rellena `{{1}}`, el segundo `{{2}}`. Sin ellos WhatsApp rechaza la plantilla.
|
|
1525
|
+
* Un valor vacío, con saltos de línea, tabuladores o más de cuatro espacios seguidos es un 1511
|
|
1526
|
+
* con `data.index` apuntando al que falla. Sólo variables posicionales del cuerpo:
|
|
1527
|
+
*
|
|
1528
|
+
* ```ts
|
|
1529
|
+
* await pv.messages.send(orgId, accountId, contactId, {
|
|
1530
|
+
* message_type: "template_message",
|
|
1531
|
+
* message_options: {
|
|
1532
|
+
* template_name: "recordatorio_cita",
|
|
1533
|
+
* template_language: "es",
|
|
1534
|
+
* template_parameters: ["María", "jueves 2 de octubre", "17:00"],
|
|
1535
|
+
* },
|
|
1536
|
+
* });
|
|
1537
|
+
* ```
|
|
1538
|
+
*
|
|
1498
1539
|
* `comment_message` y `publication_message` exigen `in_response_external_id`: el identificador
|
|
1499
1540
|
* EN LA RED de lo que se responde —el `external_id` de un comentario, el `external_identifier`
|
|
1500
1541
|
* de una publicación—, nunca un `_id` de PlanVortex, y error 1510 si falta. El endpoint no lo
|
|
@@ -1650,6 +1691,19 @@ interface ConnectTokenOptions extends RequestOptions {
|
|
|
1650
1691
|
* registrados en la app, o la llamada contesta el error 532.
|
|
1651
1692
|
*/
|
|
1652
1693
|
redirect_uri?: string | undefined;
|
|
1694
|
+
/**
|
|
1695
|
+
* Quién enseña la pantalla de elegir cuentas. Sin esto, PlanVortex (`"planvortex"`).
|
|
1696
|
+
*
|
|
1697
|
+
* Con `"integrator"` esa pantalla es tuya: la `url` que vuelve es la página de autorización
|
|
1698
|
+
* DE LA RED, el usuario va ahí directamente desde tu app, y al terminar aterriza en tu
|
|
1699
|
+
* `redirect_uri` con `?connect_session=…&social_network=…` sin ver nada de PlanVortex. Lees la
|
|
1700
|
+
* sesión con `accounts.getConnectSession()` y confirmas con `accounts.confirmConnectSession()`.
|
|
1701
|
+
*
|
|
1702
|
+
* Exige `redirect_uri` y `social_network` (549), y Telegram no puede (550): su enlace abre un
|
|
1703
|
+
* chat del que no se vuelve. En WhatsApp la `url` sigue siendo una página de PlanVortex con un
|
|
1704
|
+
* botón, porque el popup de Meta sólo se abre en nuestro dominio.
|
|
1705
|
+
*/
|
|
1706
|
+
account_selection?: AccountSelection | undefined;
|
|
1653
1707
|
}
|
|
1654
1708
|
declare class OrganizationsResource extends Resource {
|
|
1655
1709
|
/** La ficha de una organización. */
|
|
@@ -2203,4 +2257,4 @@ interface AuthProvider {
|
|
|
2203
2257
|
/** Margen con el que se pide un token nuevo antes de que caduque el que hay. */
|
|
2204
2258
|
declare const TOKEN_REFRESH_MARGIN_MS = 60000;
|
|
2205
2259
|
|
|
2206
|
-
export { Account, type AccountCapability, type AccountDestinationOptions, type AccountListOptions, AccountMetrics, type AccountMetricsOptions, AccountsResource, AiContext, AiPlan, AiPlanCreateRequest, AiPlanCreateResult, type AiPlanListOptions, type AiPlanRegenerateResult, type AiPlanRegenerateTarget, AiPlanResults, type AiPlanResultsOptions, AiPlanResultsSort, AiPlansResource, AiSettings, AppsResource, AspectRatiosByNetwork, type AuthProvider, CatalogResource, type ChildOrganizationListOptions, Client, ClientApp, ClientAppInput, type ClientCredentialsToken, type ClientListOptions, ClientWithOrganizations, ClientsResource, Comment, CommentActions, type CommentListOptions, CommentNetwork, CommentReplyResult, CommentThread, type CommentThreadOptions, type CommentUpdate, CommentsResource, type ConnectCallbackParams, ConnectLink, type ConnectLinkOptions, type ConnectLinksOptions, ConnectResult, ConnectToken, type ConnectTokenOptions, Contact, ContactCreate, ContactExtraData, type ContactExtraFilter, type ContactListOptions, ContactUpdate, ContactsResource, Conversation, type ConversationGroupBy, ConversationTotals, type ConversationTotalsOptions, DEFAULT_PAGE_SIZE, DEFAULT_RETRY, DEFAULT_TIMEOUT_MS, Dashboard, DashboardMetricsResult, DashboardResource, Destination, EnableResult, type FetchLike, type FileInput, type FileSource, type HttpHooks, type HttpMethod, type HttpRequest, type HttpResponse, type ImportError, type ImportFileInput, type ImportResult, Integration, IntegrationCatalogPage, IntegrationConnectRequest, type IntegrationListOptions, IntegrationPickerConfig, type IntegrationProductsOptions, IntegrationProvider, IntegrationProviderName, IntegrationUpdate, IntegrationsResource, MAX_PAGES, Message, MessageInput, MessageTemplate, type MessageTemplateResult, MessagesResource, MetricName, type MetricsGroupBy, type MetricsOptions, Organization, type OrganizationInput, type OrganizationListOptions, type OrganizationOptions, type OrganizationPlanInput, OrganizationsResource, PLANVORTEX_API_URL, type PageOptions, Paginated, PersistentMenu, PlanData, PlanUse, PlanUseData, PlanVortex, type PlanVortexOptions, PlannerTemplate, PlannerTemplateName, Product, ProductCatalog, ProductCatalogInput, ProductInput, ProductsResource, Publication, PublicationInput, PublicationLimits, type PublicationListOptions, type PublicationRetryResult, PublicationState, PublicationStats, PublicationStatsHistory, PublicationsResource, type PublicationsStatsOptions, PublicationsStatsResult, PublicationsSummaryResult, type QueryValue, type RangeOptions, type RequestInfo, type RequestOptions, type RequestSender, type ResponseInfo, type RetryConfig, type RetryInfo, SocialCapabilities, SocialLimits, SocialNetwork, TOKEN_REFRESH_MARGIN_MS, type TopPublicationsOptions, TopPublicationsResult, Upload, type UploadUpdate, UploadsResource, VERSION, guessContentType };
|
|
2260
|
+
export { Account, type AccountCapability, type AccountDestinationOptions, type AccountListOptions, AccountMetrics, type AccountMetricsOptions, AccountSelection, AccountsResource, AiContext, AiPlan, AiPlanCreateRequest, AiPlanCreateResult, type AiPlanListOptions, type AiPlanRegenerateResult, type AiPlanRegenerateTarget, AiPlanResults, type AiPlanResultsOptions, AiPlanResultsSort, AiPlansResource, AiSettings, AppsResource, AspectRatiosByNetwork, type AuthProvider, CatalogResource, type ChildOrganizationListOptions, Client, ClientApp, ClientAppInput, type ClientCredentialsToken, type ClientListOptions, ClientWithOrganizations, ClientsResource, Comment, CommentActions, type CommentListOptions, CommentNetwork, CommentReplyResult, CommentThread, type CommentThreadOptions, type CommentUpdate, CommentsResource, type ConnectCallbackParams, ConnectLink, type ConnectLinkOptions, type ConnectLinksOptions, ConnectResult, ConnectSession, ConnectToken, type ConnectTokenOptions, Contact, ContactCreate, ContactExtraData, type ContactExtraFilter, type ContactListOptions, ContactUpdate, ContactsResource, Conversation, type ConversationGroupBy, ConversationTotals, type ConversationTotalsOptions, DEFAULT_PAGE_SIZE, DEFAULT_RETRY, DEFAULT_TIMEOUT_MS, Dashboard, DashboardMetricsResult, DashboardResource, Destination, EnableResult, type FetchLike, type FileInput, type FileSource, type HttpHooks, type HttpMethod, type HttpRequest, type HttpResponse, type ImportError, type ImportFileInput, type ImportResult, Integration, IntegrationCatalogPage, IntegrationConnectRequest, type IntegrationListOptions, IntegrationPickerConfig, type IntegrationProductsOptions, IntegrationProvider, IntegrationProviderName, IntegrationUpdate, IntegrationsResource, MAX_PAGES, Message, MessageInput, MessageTemplate, type MessageTemplateResult, MessagesResource, MetricName, type MetricsGroupBy, type MetricsOptions, Organization, type OrganizationInput, type OrganizationListOptions, type OrganizationOptions, type OrganizationPlanInput, OrganizationsResource, PLANVORTEX_API_URL, type PageOptions, Paginated, PersistentMenu, PlanData, PlanUse, PlanUseData, PlanVortex, type PlanVortexOptions, PlannerTemplate, PlannerTemplateName, Product, ProductCatalog, ProductCatalogInput, ProductInput, ProductsResource, Publication, PublicationInput, PublicationLimits, type PublicationListOptions, type PublicationRetryResult, PublicationState, PublicationStats, PublicationStatsHistory, PublicationsResource, type PublicationsStatsOptions, PublicationsStatsResult, PublicationsSummaryResult, type QueryValue, type RangeOptions, type RequestInfo, type RequestOptions, type RequestSender, type ResponseInfo, type RetryConfig, type RetryInfo, SocialCapabilities, SocialLimits, SocialNetwork, TOKEN_REFRESH_MARGIN_MS, type TopPublicationsOptions, TopPublicationsResult, Upload, type UploadUpdate, UploadsResource, VERSION, guessContentType };
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { createErrorFromResponse, NO_ERROR_CODE, PlanVortexError, PlanVortexConfigError, isTokenError, PlanVortexConnectionError, PlanVortexAuthenticationError, isPlanVortexError } from './chunk-
|
|
2
|
-
export { AccountError, AiPlanError, AuthError, ContactError, FileError, IntegrationError, MessagingError, NO_ERROR_CODE, OrganizationError, PLANVORTEX_ERROR_RANGES, PlanLimitError, PlanVortexAuthenticationError, PlanVortexConfigError, PlanVortexConnectionError, PlanVortexError, ProductError, PublicationError, TOKEN_ERROR_CODES, UserError, errorFamilyForCode, isPlanVortexError, isTokenError } from './chunk-
|
|
1
|
+
import { createErrorFromResponse, NO_ERROR_CODE, PlanVortexError, PlanVortexConfigError, isTokenError, PlanVortexConnectionError, PlanVortexAuthenticationError, isPlanVortexError } from './chunk-4EPTOW4H.js';
|
|
2
|
+
export { AccountError, AiPlanError, AuthError, ContactError, FileError, IntegrationError, MessagingError, NO_ERROR_CODE, OrganizationError, PLANVORTEX_ERROR_RANGES, PlanLimitError, PlanVortexAuthenticationError, PlanVortexConfigError, PlanVortexConnectionError, PlanVortexError, ProductError, PublicationError, TOKEN_ERROR_CODES, UserError, errorFamilyForCode, isPlanVortexError, isTokenError } from './chunk-4EPTOW4H.js';
|
|
3
3
|
import { basename } from '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.15.0";
|
|
8
8
|
|
|
9
9
|
// src/core/auth.ts
|
|
10
10
|
var TOKEN_REFRESH_MARGIN_MS = 6e4;
|
|
@@ -554,6 +554,43 @@ var AccountsResource = class extends Resource {
|
|
|
554
554
|
);
|
|
555
555
|
return body.redirect_uri === void 0 ? {} : { redirect_uri: body.redirect_uri };
|
|
556
556
|
}
|
|
557
|
+
/**
|
|
558
|
+
* Una sesión de conexión: lo que autorizó tu usuario cuando el token se emitió con
|
|
559
|
+
* `account_selection: "integrator"`. Es lo que pintas en TU selector de cuentas.
|
|
560
|
+
*
|
|
561
|
+
* El `idSession` es el `connect_session` que llega a tu `redirect_uri` (y el que te devolvió
|
|
562
|
+
* `createConnectToken`: compáralos, para que una sesión que empezó otro no acabe en el navegador
|
|
563
|
+
* de tu usuario). Si en esa URL viene también `error`, la conexión no terminó —`access_denied`
|
|
564
|
+
* si canceló, `no_accounts` si la red no devolvió ninguna, `connect_failed` con `error_code`—
|
|
565
|
+
* y la sesión sigue `pending`: puede reintentarlo con el mismo enlace.
|
|
566
|
+
*
|
|
567
|
+
* **Sólo la app que emitió el token.** Cualquier otra recibe 551, igual que una sesión que no
|
|
568
|
+
* existe o que ha caducado: una `returned` vive media hora.
|
|
569
|
+
*/
|
|
570
|
+
async getConnectSession(idOrganization, idSession, options = {}) {
|
|
571
|
+
return this.getOne(
|
|
572
|
+
`/organizations/${requireId(idOrganization, "idOrganization")}/connect_sessions/${requireId(idSession, "idSession")}`,
|
|
573
|
+
"connect_session",
|
|
574
|
+
void 0,
|
|
575
|
+
options
|
|
576
|
+
);
|
|
577
|
+
}
|
|
578
|
+
/**
|
|
579
|
+
* Habilita las cuentas que eligió tu usuario y cierra la sesión. Una lista vacía es «ninguna».
|
|
580
|
+
*
|
|
581
|
+
* **O todas o ninguna**: si las nuevas no caben en el plan contesta 706 con
|
|
582
|
+
* `{limit, used, requested}` y no habilita NINGUNA, así que ese número se le puede enseñar tal
|
|
583
|
+
* cual. Las que ya estaban activas (`already_enabled`) no cuentan. Cada cuenta habilitada
|
|
584
|
+
* dispara el webhook `new_account`, como en cualquier conexión.
|
|
585
|
+
*/
|
|
586
|
+
async confirmConnectSession(idOrganization, idSession, accountIds, options = {}) {
|
|
587
|
+
const body = await this.httpPost(
|
|
588
|
+
`/organizations/${requireId(idOrganization, "idOrganization")}/connect_sessions/${requireId(idSession, "idSession")}/confirm`,
|
|
589
|
+
{ accounts: [...accountIds] },
|
|
590
|
+
options
|
|
591
|
+
);
|
|
592
|
+
return body.accounts;
|
|
593
|
+
}
|
|
557
594
|
/** Las cuentas de una organización. */
|
|
558
595
|
async list(idOrganization, options = {}) {
|
|
559
596
|
return this.getList(
|
|
@@ -759,8 +796,9 @@ var AiPlansResource = class extends Resource {
|
|
|
759
796
|
/**
|
|
760
797
|
* Un plan, con sus publicaciones **ya resueltas** y con los ficheros de cada una.
|
|
761
798
|
*
|
|
762
|
-
*
|
|
763
|
-
*
|
|
799
|
+
* Léelo cuando a tu app le llegue `ai_plan_generated` o `ai_plan_failed`. Sin webhook, es el
|
|
800
|
+
* endpoint que se sondea mientras `state` sea `pending` o `generating`. El webhook no se
|
|
801
|
+
* reintenta: si tu endpoint estaba caído cuando el plan terminó, esto sigue diciendo cómo acabó.
|
|
764
802
|
*/
|
|
765
803
|
async get(idClient, idOrganization, idAiPlan, options = {}) {
|
|
766
804
|
return this.getOne(
|
|
@@ -861,8 +899,8 @@ var AiPlansResource = class extends Resource {
|
|
|
861
899
|
);
|
|
862
900
|
}
|
|
863
901
|
/**
|
|
864
|
-
* Vuelve a encolar un plan `failed` con los mismos datos. El estado regresa a `pending` y
|
|
865
|
-
*
|
|
902
|
+
* Vuelve a encolar un plan `failed` con los mismos datos. El estado regresa a `pending` y el
|
|
903
|
+
* final vuelve a llegar como tras `create()`: por webhook, o sondeando.
|
|
866
904
|
*
|
|
867
905
|
* Usa el contexto de marca copiado al crear el plan, no el actual: el plan es reproducible
|
|
868
906
|
* aunque alguien haya editado la configuración entretanto.
|
|
@@ -1888,6 +1926,22 @@ var MessagesResource = class extends Resource {
|
|
|
1888
1926
|
* En Facebook e Instagram sólo se admite **un** adjunto por mensaje (error 1509), y en WhatsApp
|
|
1889
1927
|
* fuera de la ventana de 24 horas sólo se admite una plantilla.
|
|
1890
1928
|
*
|
|
1929
|
+
* Si el cuerpo de la plantilla tiene variables, sus valores van en `template_parameters`, en
|
|
1930
|
+
* orden: el primero rellena `{{1}}`, el segundo `{{2}}`. Sin ellos WhatsApp rechaza la plantilla.
|
|
1931
|
+
* Un valor vacío, con saltos de línea, tabuladores o más de cuatro espacios seguidos es un 1511
|
|
1932
|
+
* con `data.index` apuntando al que falla. Sólo variables posicionales del cuerpo:
|
|
1933
|
+
*
|
|
1934
|
+
* ```ts
|
|
1935
|
+
* await pv.messages.send(orgId, accountId, contactId, {
|
|
1936
|
+
* message_type: "template_message",
|
|
1937
|
+
* message_options: {
|
|
1938
|
+
* template_name: "recordatorio_cita",
|
|
1939
|
+
* template_language: "es",
|
|
1940
|
+
* template_parameters: ["María", "jueves 2 de octubre", "17:00"],
|
|
1941
|
+
* },
|
|
1942
|
+
* });
|
|
1943
|
+
* ```
|
|
1944
|
+
*
|
|
1891
1945
|
* `comment_message` y `publication_message` exigen `in_response_external_id`: el identificador
|
|
1892
1946
|
* EN LA RED de lo que se responde —el `external_id` de un comentario, el `external_identifier`
|
|
1893
1947
|
* de una publicación—, nunca un `_id` de PlanVortex, y error 1510 si falta. El endpoint no lo
|
|
@@ -2208,7 +2262,11 @@ var OrganizationsResource = class extends Resource {
|
|
|
2208
2262
|
async createConnectToken(idOrganization, options = {}) {
|
|
2209
2263
|
return this.httpGet(
|
|
2210
2264
|
`/organizations/${requireId(idOrganization, "idOrganization")}/temporal_connect_token`,
|
|
2211
|
-
{
|
|
2265
|
+
{
|
|
2266
|
+
social_network: options.social_network,
|
|
2267
|
+
redirect_uri: options.redirect_uri,
|
|
2268
|
+
account_selection: options.account_selection
|
|
2269
|
+
},
|
|
2212
2270
|
options
|
|
2213
2271
|
);
|
|
2214
2272
|
}
|