planvortex 0.2.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/{index-Bs_Usq51.d.cts → index-BMoQHhe-.d.cts} +16 -10
- package/dist/{index-Bs_Usq51.d.ts → index-BMoQHhe-.d.ts} +16 -10
- package/dist/index.cjs +53 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +46 -10
- package/dist/index.d.ts +46 -10
- package/dist/index.js +54 -8
- package/dist/index.js.map +1 -1
- package/dist/webhooks/index.d.cts +1 -1
- package/dist/webhooks/index.d.ts +1 -1
- package/package.json +1 -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, b as AccountMetrics, c as PersistentMenu, d as Publication, e as AiPlanCreateRequest, f as AiPlanCreateResult, g as AiPlan, h as ClientApp, i as ClientAppInput, j as SocialCapabilities, k as CommentActions, l as SocialLimits, m as PublicationLimits, n as AspectRatiosByNetwork, o as CommentNetwork, p as Comment, q as CommentThread, r as CommentReplyResult, s as ContactExtraData, t as Contact, u as ContactCreate, v as ContactUpdate, D as Dashboard, M as MetricName, w as DashboardMetricsResult, x as PublicationsSummaryResult, T as TopPublicationsResult, y as PublicationsStatsResult, z as PlanUse, I as IntegrationProviderName, B as IntegrationProvider, F as Integration, G as IntegrationConnectRequest, H as IntegrationUpdate, J as IntegrationPickerConfig, K as MessageTemplate, L as Conversation, N as ConversationTotals, O as Message, Q as MessageInput, R as Client, U as Organization, V as AiSettings, W as ClientWithOrganizations, X as PlanData, Y as ConnectToken, Z as AiContext, _ as SocialCredentialsInput, $ as Product, a0 as ProductInput, a1 as ProductCatalog, a2 as ProductCatalogInput, a3 as PublicationInput, a4 as PublicationState, a5 as PublicationStats, a6 as PublicationStatsHistory, a7 as Upload } from './index-
|
|
2
|
-
export { a8 as AccountError, a9 as AccountMetricRow, aa as AccountStateChange, ab as AccountWebhookChangeBase, ac as AccountWithError, ad as AiPlanCostEstimate, ae as AiPlanError, af as AiPlanOptions, ag as AiPlanOptionsInput, ah as AiPlanState, ai as ApiErrorBody, aj as AspectRatios, ak as AuthError, al as ClientPlan, am as CommentAuthor, an as CommentChange, ao as ContactChannel, ap as ContactError, aq as DashboardAiPlanRef, ar as DashboardPublicationRef, as as DashboardRange, at as EngagementBase, au as FileError, av as FileFormat, aw as FileProperties, ax as FileType, ay as IntegrationError, az as IntegrationErrorChange, aA as MessageChange, aB as MessageOptions, aC as MessageType, aD as MessagingError, aE as MetricRow, aF as NO_ERROR_CODE, aG as OpenApiComponents, aH as OpenApiOperations, aI as OpenApiPaths, aJ as OpenApiWebhooks, aK as OpenEnum, aL as OrganizationError, aM as PLANVORTEX_ERROR_RANGES, aN as PlanLimitError, aO as PlanVortexAuthenticationError, aP as PlanVortexConfigError, aQ as PlanVortexConnectionError, aR as PlanVortexError, aS as PlanVortexErrorOptions, aT as PlanVortexErrorRange, aU as ProductError, aV as PublicationError, aW as PublicationErrorDetail, aX as PublicationMetrics, aY as PublicationStatsPoint, aZ as PublicationType, a_ as PublicationsSummary, a$ as RssConfig, b0 as SocialAuthorizationMethod, b1 as SocialCredentials, b2 as SocialIdentifier, b3 as SocialIdentifierInput, b4 as SocialLimitsMap, b5 as TOKEN_ERROR_CODES, b6 as TopPublication, b7 as UnknownWebhookChange, b8 as UserError, b9 as WebhookAlgorithm, ba as WebhookChange, bb as WebhookEvent, bc as WithAccount, bd as WithPublication, be as account, bf as accountId, bg as errorFamilyForCode, bh as isPlanVortexError, bi as isTokenError, bj as messageContact, bk as messageContactId, bl as messageDirection, bm as messageFileIds, bn as messageFiles, bo as publication, bp as publicationId } from './index-
|
|
1
|
+
import { P as Paginated, S as SocialNetwork, C as ConnectLink, a as ConnectResult, E as EnableResult, A as Account, b as AccountMetrics, c as PersistentMenu, d as Publication, e as AiPlanCreateRequest, f as AiPlanCreateResult, g as AiPlan, h as ClientApp, i as ClientAppInput, j as SocialCapabilities, k as CommentActions, l as SocialLimits, m as PublicationLimits, n as AspectRatiosByNetwork, o as CommentNetwork, p as Comment, q as CommentThread, r as CommentReplyResult, s as ContactExtraData, t as Contact, u as ContactCreate, v as ContactUpdate, D as Dashboard, M as MetricName, w as DashboardMetricsResult, x as PublicationsSummaryResult, T as TopPublicationsResult, y as PublicationsStatsResult, z as PlanUse, I as IntegrationProviderName, B as IntegrationProvider, F as Integration, G as IntegrationConnectRequest, H as IntegrationUpdate, J as IntegrationPickerConfig, K as MessageTemplate, L as Conversation, N as ConversationTotals, O as Message, Q as MessageInput, R as Client, U as Organization, V as AiSettings, W as ClientWithOrganizations, X as PlanData, Y as ConnectToken, Z as AiContext, _ as SocialCredentialsInput, $ as Product, a0 as ProductInput, a1 as ProductCatalog, a2 as ProductCatalogInput, a3 as PublicationInput, a4 as PublicationState, a5 as PublicationStats, a6 as PublicationStatsHistory, a7 as Upload } from './index-BMoQHhe-.cjs';
|
|
2
|
+
export { a8 as AccountError, a9 as AccountMetricRow, aa as AccountStateChange, ab as AccountWebhookChangeBase, ac as AccountWithError, ad as AiPlanCostEstimate, ae as AiPlanError, af as AiPlanOptions, ag as AiPlanOptionsInput, ah as AiPlanState, ai as ApiErrorBody, aj as AspectRatios, ak as AuthError, al as ClientPlan, am as CommentAuthor, an as CommentChange, ao as ContactChannel, ap as ContactError, aq as DashboardAiPlanRef, ar as DashboardPublicationRef, as as DashboardRange, at as EngagementBase, au as FileError, av as FileFormat, aw as FileProperties, ax as FileType, ay as IntegrationError, az as IntegrationErrorChange, aA as MessageChange, aB as MessageOptions, aC as MessageType, aD as MessagingError, aE as MetricRow, aF as NO_ERROR_CODE, aG as OpenApiComponents, aH as OpenApiOperations, aI as OpenApiPaths, aJ as OpenApiWebhooks, aK as OpenEnum, aL as OrganizationError, aM as PLANVORTEX_ERROR_RANGES, aN as PlanLimitError, aO as PlanVortexAuthenticationError, aP as PlanVortexConfigError, aQ as PlanVortexConnectionError, aR as PlanVortexError, aS as PlanVortexErrorOptions, aT as PlanVortexErrorRange, aU as ProductError, aV as PublicationError, aW as PublicationErrorDetail, aX as PublicationMetrics, aY as PublicationStatsPoint, aZ as PublicationType, a_ as PublicationsSummary, a$ as RssConfig, b0 as SocialAuthorizationMethod, b1 as SocialCredentials, b2 as SocialIdentifier, b3 as SocialIdentifierInput, b4 as SocialLimitsMap, b5 as TOKEN_ERROR_CODES, b6 as TopPublication, b7 as UnknownWebhookChange, b8 as UserError, b9 as WebhookAlgorithm, ba as WebhookChange, bb as WebhookEvent, bc as WithAccount, bd as WithPublication, be as account, bf as accountId, bg as errorFamilyForCode, bh as isPlanVortexError, bi as isTokenError, bj as messageContact, bk as messageContactId, bl as messageDirection, bm as messageFileIds, bn as messageFiles, bo as publication, bp as publicationId } from './index-BMoQHhe-.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.3.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>;
|
|
@@ -751,14 +751,24 @@ interface ContactListOptions extends PageOptions {
|
|
|
751
751
|
search?: string | undefined;
|
|
752
752
|
/** Filtros por los campos propios de `extra_data`. Se combinan con Y. */
|
|
753
753
|
extra_data?: readonly ContactExtraFilter[] | undefined;
|
|
754
|
+
/**
|
|
755
|
+
* Sólo los contactos localizables en esa red. Casa contra
|
|
756
|
+
* `social_identifiers[].social_network`, así que un contacto con varios canales vuelve por
|
|
757
|
+
* cualquiera de ellos.
|
|
758
|
+
*/
|
|
759
|
+
social_network?: SocialNetwork | undefined;
|
|
754
760
|
}
|
|
755
761
|
declare class ContactsResource extends Resource {
|
|
756
762
|
/**
|
|
757
763
|
* La agenda de la organización, de la más reciente a la más antigua.
|
|
758
764
|
*
|
|
759
|
-
*
|
|
760
|
-
* array `social_identifiers`
|
|
761
|
-
*
|
|
765
|
+
* `social_network` acota a los contactos localizables en esa red. Devolvía siempre una lista
|
|
766
|
+
* vacía —el servidor comparaba el array entero de `social_identifiers` contra el nombre de la
|
|
767
|
+
* red— hasta que se arregló el 2026-08-24; hasta la 0.3.0 este método no lo exponía.
|
|
768
|
+
*
|
|
769
|
+
* ```ts
|
|
770
|
+
* const { data } = await pv.contacts.list(orgId, { social_network: "whatsapp", limit: 50 });
|
|
771
|
+
* ```
|
|
762
772
|
*/
|
|
763
773
|
list(idOrganization: string, options?: ContactListOptions & RequestOptions): Promise<Paginated<Contact>>;
|
|
764
774
|
/** La agenda, encadenando páginas. */
|
|
@@ -1140,6 +1150,13 @@ declare class MessagesResource extends Resource {
|
|
|
1140
1150
|
* En Facebook e Instagram sólo se admite **un** adjunto por mensaje (error 1509), y en WhatsApp
|
|
1141
1151
|
* fuera de la ventana de 24 horas sólo se admite una plantilla.
|
|
1142
1152
|
*
|
|
1153
|
+
* `comment_message` y `publication_message` exigen `in_response_external_id`: el identificador
|
|
1154
|
+
* EN LA RED de lo que se responde —el `external_id` de un comentario, el `external_identifier`
|
|
1155
|
+
* de una publicación—, nunca un `_id` de PlanVortex, y error 1510 si falta. El endpoint no lo
|
|
1156
|
+
* leía del cuerpo hasta el 2026-08-24, lo que dejaba los dos tipos fuera del alcance de la API
|
|
1157
|
+
* pública; ya funcionan, y sólo en Facebook e Instagram: `comment_message` manda una respuesta
|
|
1158
|
+
* privada a un comentario público y `publication_message` adjunta el post como `MEDIA_SHARE`.
|
|
1159
|
+
*
|
|
1143
1160
|
* ```ts
|
|
1144
1161
|
* await pv.messages.send(orgId, accountId, contactId, {
|
|
1145
1162
|
* message_type: "simple_message",
|
|
@@ -1394,8 +1411,10 @@ declare class OrganizationsResource extends Resource {
|
|
|
1394
1411
|
* estadísticas: lo que se manda y lo que vuelve es lo que documenta la Graph API.
|
|
1395
1412
|
* - **`total` no sirve para paginar.** En productos llega siempre a `0` (sale de un `summary` que
|
|
1396
1413
|
* no se pide) y en catálogos es la longitud de la página. Se pagina hasta ver una página corta.
|
|
1397
|
-
* - **Un producto suelto
|
|
1398
|
-
*
|
|
1414
|
+
* - **Un producto suelto se pide con {@link ProductsResource.get}, no con `list()`.** Pedir uno
|
|
1415
|
+
* por su identificador va al nodo de ESE producto en Meta, así que la red contesta con el
|
|
1416
|
+
* producto y no con una lista: `items` trae un objeto, y con un objeto no se puede construir
|
|
1417
|
+
* una página.
|
|
1399
1418
|
* - **La cuenta tiene que ser una página con negocio detrás**: el catálogo cuelga del
|
|
1400
1419
|
* `business_id`, no del perfil.
|
|
1401
1420
|
*/
|
|
@@ -1405,8 +1424,8 @@ declare class ProductsResource extends Resource {
|
|
|
1405
1424
|
* Los productos de un catálogo.
|
|
1406
1425
|
*
|
|
1407
1426
|
* `idCatalog` es obligatorio de hecho aunque la API lo pinte opcional: sin él la petición falla
|
|
1408
|
-
* con el error 2000.
|
|
1409
|
-
*
|
|
1427
|
+
* con el error 2000. Para pedir **un** producto por su identificador, {@link get} — no es un
|
|
1428
|
+
* argumento de aquí porque la respuesta viene con otra forma.
|
|
1410
1429
|
*
|
|
1411
1430
|
* ```ts
|
|
1412
1431
|
* const { data } = await pv.products.list(orgId, accountId, catalogId, { limit: 50 });
|
|
@@ -1420,6 +1439,23 @@ declare class ProductsResource extends Resource {
|
|
|
1420
1439
|
* lista `total` vale `0` siempre.
|
|
1421
1440
|
*/
|
|
1422
1441
|
iterate(idOrganization: string, idAccount: string, idCatalog: string, options?: PageOptions & RequestOptions): AsyncGenerator<Product>;
|
|
1442
|
+
/**
|
|
1443
|
+
* UN producto, por su identificador **en la red** (el de Meta, no un `_id` de PlanVortex).
|
|
1444
|
+
*
|
|
1445
|
+
* El servidor reenviaba ese filtro con un nombre que el SDK no lee, así que nunca llegaba a la
|
|
1446
|
+
* red y la llamada moría con un 2000; se arregló el 2026-08-24 y aquí se expone desde la 0.3.0.
|
|
1447
|
+
*
|
|
1448
|
+
* **La respuesta viene con otra forma que la del listado.** Pedir un producto suelto va al nodo
|
|
1449
|
+
* de ese producto, así que la red contesta con el producto y `items` trae un objeto. Por eso
|
|
1450
|
+
* esto es un método aparte y no un argumento de {@link list}: con un objeto no se construye una
|
|
1451
|
+
* página. Se acepta también una lista, que es lo que devolvería un despliegue que envolviera la
|
|
1452
|
+
* respuesta, y coger el primero es mejor que reventar por la forma del sobre.
|
|
1453
|
+
*
|
|
1454
|
+
* ```ts
|
|
1455
|
+
* const product = await pv.products.get(orgId, accountId, "7123456789012345");
|
|
1456
|
+
* ```
|
|
1457
|
+
*/
|
|
1458
|
+
get(idOrganization: string, idAccount: string, productId: string, options?: RequestOptions): Promise<Product>;
|
|
1423
1459
|
/**
|
|
1424
1460
|
* Da de alta un producto en un catálogo, o **actualiza uno existente** si el cuerpo trae `id`.
|
|
1425
1461
|
* Devuelve el identificador en la red, no el producto.
|
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, b as AccountMetrics, c as PersistentMenu, d as Publication, e as AiPlanCreateRequest, f as AiPlanCreateResult, g as AiPlan, h as ClientApp, i as ClientAppInput, j as SocialCapabilities, k as CommentActions, l as SocialLimits, m as PublicationLimits, n as AspectRatiosByNetwork, o as CommentNetwork, p as Comment, q as CommentThread, r as CommentReplyResult, s as ContactExtraData, t as Contact, u as ContactCreate, v as ContactUpdate, D as Dashboard, M as MetricName, w as DashboardMetricsResult, x as PublicationsSummaryResult, T as TopPublicationsResult, y as PublicationsStatsResult, z as PlanUse, I as IntegrationProviderName, B as IntegrationProvider, F as Integration, G as IntegrationConnectRequest, H as IntegrationUpdate, J as IntegrationPickerConfig, K as MessageTemplate, L as Conversation, N as ConversationTotals, O as Message, Q as MessageInput, R as Client, U as Organization, V as AiSettings, W as ClientWithOrganizations, X as PlanData, Y as ConnectToken, Z as AiContext, _ as SocialCredentialsInput, $ as Product, a0 as ProductInput, a1 as ProductCatalog, a2 as ProductCatalogInput, a3 as PublicationInput, a4 as PublicationState, a5 as PublicationStats, a6 as PublicationStatsHistory, a7 as Upload } from './index-
|
|
2
|
-
export { a8 as AccountError, a9 as AccountMetricRow, aa as AccountStateChange, ab as AccountWebhookChangeBase, ac as AccountWithError, ad as AiPlanCostEstimate, ae as AiPlanError, af as AiPlanOptions, ag as AiPlanOptionsInput, ah as AiPlanState, ai as ApiErrorBody, aj as AspectRatios, ak as AuthError, al as ClientPlan, am as CommentAuthor, an as CommentChange, ao as ContactChannel, ap as ContactError, aq as DashboardAiPlanRef, ar as DashboardPublicationRef, as as DashboardRange, at as EngagementBase, au as FileError, av as FileFormat, aw as FileProperties, ax as FileType, ay as IntegrationError, az as IntegrationErrorChange, aA as MessageChange, aB as MessageOptions, aC as MessageType, aD as MessagingError, aE as MetricRow, aF as NO_ERROR_CODE, aG as OpenApiComponents, aH as OpenApiOperations, aI as OpenApiPaths, aJ as OpenApiWebhooks, aK as OpenEnum, aL as OrganizationError, aM as PLANVORTEX_ERROR_RANGES, aN as PlanLimitError, aO as PlanVortexAuthenticationError, aP as PlanVortexConfigError, aQ as PlanVortexConnectionError, aR as PlanVortexError, aS as PlanVortexErrorOptions, aT as PlanVortexErrorRange, aU as ProductError, aV as PublicationError, aW as PublicationErrorDetail, aX as PublicationMetrics, aY as PublicationStatsPoint, aZ as PublicationType, a_ as PublicationsSummary, a$ as RssConfig, b0 as SocialAuthorizationMethod, b1 as SocialCredentials, b2 as SocialIdentifier, b3 as SocialIdentifierInput, b4 as SocialLimitsMap, b5 as TOKEN_ERROR_CODES, b6 as TopPublication, b7 as UnknownWebhookChange, b8 as UserError, b9 as WebhookAlgorithm, ba as WebhookChange, bb as WebhookEvent, bc as WithAccount, bd as WithPublication, be as account, bf as accountId, bg as errorFamilyForCode, bh as isPlanVortexError, bi as isTokenError, bj as messageContact, bk as messageContactId, bl as messageDirection, bm as messageFileIds, bn as messageFiles, bo as publication, bp as publicationId } from './index-
|
|
1
|
+
import { P as Paginated, S as SocialNetwork, C as ConnectLink, a as ConnectResult, E as EnableResult, A as Account, b as AccountMetrics, c as PersistentMenu, d as Publication, e as AiPlanCreateRequest, f as AiPlanCreateResult, g as AiPlan, h as ClientApp, i as ClientAppInput, j as SocialCapabilities, k as CommentActions, l as SocialLimits, m as PublicationLimits, n as AspectRatiosByNetwork, o as CommentNetwork, p as Comment, q as CommentThread, r as CommentReplyResult, s as ContactExtraData, t as Contact, u as ContactCreate, v as ContactUpdate, D as Dashboard, M as MetricName, w as DashboardMetricsResult, x as PublicationsSummaryResult, T as TopPublicationsResult, y as PublicationsStatsResult, z as PlanUse, I as IntegrationProviderName, B as IntegrationProvider, F as Integration, G as IntegrationConnectRequest, H as IntegrationUpdate, J as IntegrationPickerConfig, K as MessageTemplate, L as Conversation, N as ConversationTotals, O as Message, Q as MessageInput, R as Client, U as Organization, V as AiSettings, W as ClientWithOrganizations, X as PlanData, Y as ConnectToken, Z as AiContext, _ as SocialCredentialsInput, $ as Product, a0 as ProductInput, a1 as ProductCatalog, a2 as ProductCatalogInput, a3 as PublicationInput, a4 as PublicationState, a5 as PublicationStats, a6 as PublicationStatsHistory, a7 as Upload } from './index-BMoQHhe-.js';
|
|
2
|
+
export { a8 as AccountError, a9 as AccountMetricRow, aa as AccountStateChange, ab as AccountWebhookChangeBase, ac as AccountWithError, ad as AiPlanCostEstimate, ae as AiPlanError, af as AiPlanOptions, ag as AiPlanOptionsInput, ah as AiPlanState, ai as ApiErrorBody, aj as AspectRatios, ak as AuthError, al as ClientPlan, am as CommentAuthor, an as CommentChange, ao as ContactChannel, ap as ContactError, aq as DashboardAiPlanRef, ar as DashboardPublicationRef, as as DashboardRange, at as EngagementBase, au as FileError, av as FileFormat, aw as FileProperties, ax as FileType, ay as IntegrationError, az as IntegrationErrorChange, aA as MessageChange, aB as MessageOptions, aC as MessageType, aD as MessagingError, aE as MetricRow, aF as NO_ERROR_CODE, aG as OpenApiComponents, aH as OpenApiOperations, aI as OpenApiPaths, aJ as OpenApiWebhooks, aK as OpenEnum, aL as OrganizationError, aM as PLANVORTEX_ERROR_RANGES, aN as PlanLimitError, aO as PlanVortexAuthenticationError, aP as PlanVortexConfigError, aQ as PlanVortexConnectionError, aR as PlanVortexError, aS as PlanVortexErrorOptions, aT as PlanVortexErrorRange, aU as ProductError, aV as PublicationError, aW as PublicationErrorDetail, aX as PublicationMetrics, aY as PublicationStatsPoint, aZ as PublicationType, a_ as PublicationsSummary, a$ as RssConfig, b0 as SocialAuthorizationMethod, b1 as SocialCredentials, b2 as SocialIdentifier, b3 as SocialIdentifierInput, b4 as SocialLimitsMap, b5 as TOKEN_ERROR_CODES, b6 as TopPublication, b7 as UnknownWebhookChange, b8 as UserError, b9 as WebhookAlgorithm, ba as WebhookChange, bb as WebhookEvent, bc as WithAccount, bd as WithPublication, be as account, bf as accountId, bg as errorFamilyForCode, bh as isPlanVortexError, bi as isTokenError, bj as messageContact, bk as messageContactId, bl as messageDirection, bm as messageFileIds, bn as messageFiles, bo as publication, bp as publicationId } from './index-BMoQHhe-.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.3.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>;
|
|
@@ -751,14 +751,24 @@ interface ContactListOptions extends PageOptions {
|
|
|
751
751
|
search?: string | undefined;
|
|
752
752
|
/** Filtros por los campos propios de `extra_data`. Se combinan con Y. */
|
|
753
753
|
extra_data?: readonly ContactExtraFilter[] | undefined;
|
|
754
|
+
/**
|
|
755
|
+
* Sólo los contactos localizables en esa red. Casa contra
|
|
756
|
+
* `social_identifiers[].social_network`, así que un contacto con varios canales vuelve por
|
|
757
|
+
* cualquiera de ellos.
|
|
758
|
+
*/
|
|
759
|
+
social_network?: SocialNetwork | undefined;
|
|
754
760
|
}
|
|
755
761
|
declare class ContactsResource extends Resource {
|
|
756
762
|
/**
|
|
757
763
|
* La agenda de la organización, de la más reciente a la más antigua.
|
|
758
764
|
*
|
|
759
|
-
*
|
|
760
|
-
* array `social_identifiers`
|
|
761
|
-
*
|
|
765
|
+
* `social_network` acota a los contactos localizables en esa red. Devolvía siempre una lista
|
|
766
|
+
* vacía —el servidor comparaba el array entero de `social_identifiers` contra el nombre de la
|
|
767
|
+
* red— hasta que se arregló el 2026-08-24; hasta la 0.3.0 este método no lo exponía.
|
|
768
|
+
*
|
|
769
|
+
* ```ts
|
|
770
|
+
* const { data } = await pv.contacts.list(orgId, { social_network: "whatsapp", limit: 50 });
|
|
771
|
+
* ```
|
|
762
772
|
*/
|
|
763
773
|
list(idOrganization: string, options?: ContactListOptions & RequestOptions): Promise<Paginated<Contact>>;
|
|
764
774
|
/** La agenda, encadenando páginas. */
|
|
@@ -1140,6 +1150,13 @@ declare class MessagesResource extends Resource {
|
|
|
1140
1150
|
* En Facebook e Instagram sólo se admite **un** adjunto por mensaje (error 1509), y en WhatsApp
|
|
1141
1151
|
* fuera de la ventana de 24 horas sólo se admite una plantilla.
|
|
1142
1152
|
*
|
|
1153
|
+
* `comment_message` y `publication_message` exigen `in_response_external_id`: el identificador
|
|
1154
|
+
* EN LA RED de lo que se responde —el `external_id` de un comentario, el `external_identifier`
|
|
1155
|
+
* de una publicación—, nunca un `_id` de PlanVortex, y error 1510 si falta. El endpoint no lo
|
|
1156
|
+
* leía del cuerpo hasta el 2026-08-24, lo que dejaba los dos tipos fuera del alcance de la API
|
|
1157
|
+
* pública; ya funcionan, y sólo en Facebook e Instagram: `comment_message` manda una respuesta
|
|
1158
|
+
* privada a un comentario público y `publication_message` adjunta el post como `MEDIA_SHARE`.
|
|
1159
|
+
*
|
|
1143
1160
|
* ```ts
|
|
1144
1161
|
* await pv.messages.send(orgId, accountId, contactId, {
|
|
1145
1162
|
* message_type: "simple_message",
|
|
@@ -1394,8 +1411,10 @@ declare class OrganizationsResource extends Resource {
|
|
|
1394
1411
|
* estadísticas: lo que se manda y lo que vuelve es lo que documenta la Graph API.
|
|
1395
1412
|
* - **`total` no sirve para paginar.** En productos llega siempre a `0` (sale de un `summary` que
|
|
1396
1413
|
* no se pide) y en catálogos es la longitud de la página. Se pagina hasta ver una página corta.
|
|
1397
|
-
* - **Un producto suelto
|
|
1398
|
-
*
|
|
1414
|
+
* - **Un producto suelto se pide con {@link ProductsResource.get}, no con `list()`.** Pedir uno
|
|
1415
|
+
* por su identificador va al nodo de ESE producto en Meta, así que la red contesta con el
|
|
1416
|
+
* producto y no con una lista: `items` trae un objeto, y con un objeto no se puede construir
|
|
1417
|
+
* una página.
|
|
1399
1418
|
* - **La cuenta tiene que ser una página con negocio detrás**: el catálogo cuelga del
|
|
1400
1419
|
* `business_id`, no del perfil.
|
|
1401
1420
|
*/
|
|
@@ -1405,8 +1424,8 @@ declare class ProductsResource extends Resource {
|
|
|
1405
1424
|
* Los productos de un catálogo.
|
|
1406
1425
|
*
|
|
1407
1426
|
* `idCatalog` es obligatorio de hecho aunque la API lo pinte opcional: sin él la petición falla
|
|
1408
|
-
* con el error 2000.
|
|
1409
|
-
*
|
|
1427
|
+
* con el error 2000. Para pedir **un** producto por su identificador, {@link get} — no es un
|
|
1428
|
+
* argumento de aquí porque la respuesta viene con otra forma.
|
|
1410
1429
|
*
|
|
1411
1430
|
* ```ts
|
|
1412
1431
|
* const { data } = await pv.products.list(orgId, accountId, catalogId, { limit: 50 });
|
|
@@ -1420,6 +1439,23 @@ declare class ProductsResource extends Resource {
|
|
|
1420
1439
|
* lista `total` vale `0` siempre.
|
|
1421
1440
|
*/
|
|
1422
1441
|
iterate(idOrganization: string, idAccount: string, idCatalog: string, options?: PageOptions & RequestOptions): AsyncGenerator<Product>;
|
|
1442
|
+
/**
|
|
1443
|
+
* UN producto, por su identificador **en la red** (el de Meta, no un `_id` de PlanVortex).
|
|
1444
|
+
*
|
|
1445
|
+
* El servidor reenviaba ese filtro con un nombre que el SDK no lee, así que nunca llegaba a la
|
|
1446
|
+
* red y la llamada moría con un 2000; se arregló el 2026-08-24 y aquí se expone desde la 0.3.0.
|
|
1447
|
+
*
|
|
1448
|
+
* **La respuesta viene con otra forma que la del listado.** Pedir un producto suelto va al nodo
|
|
1449
|
+
* de ese producto, así que la red contesta con el producto y `items` trae un objeto. Por eso
|
|
1450
|
+
* esto es un método aparte y no un argumento de {@link list}: con un objeto no se construye una
|
|
1451
|
+
* página. Se acepta también una lista, que es lo que devolvería un despliegue que envolviera la
|
|
1452
|
+
* respuesta, y coger el primero es mejor que reventar por la forma del sobre.
|
|
1453
|
+
*
|
|
1454
|
+
* ```ts
|
|
1455
|
+
* const product = await pv.products.get(orgId, accountId, "7123456789012345");
|
|
1456
|
+
* ```
|
|
1457
|
+
*/
|
|
1458
|
+
get(idOrganization: string, idAccount: string, productId: string, options?: RequestOptions): Promise<Product>;
|
|
1423
1459
|
/**
|
|
1424
1460
|
* Da de alta un producto en un catálogo, o **actualiza uno existente** si el cuerpo trae `id`.
|
|
1425
1461
|
* Devuelve el identificador en la red, no el producto.
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { createErrorFromResponse, NO_ERROR_CODE, PlanVortexConfigError, isTokenError,
|
|
1
|
+
import { createErrorFromResponse, NO_ERROR_CODE, PlanVortexError, PlanVortexConfigError, isTokenError, PlanVortexConnectionError, PlanVortexAuthenticationError, isPlanVortexError } from './chunk-GUYS6XTO.js';
|
|
2
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-GUYS6XTO.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.3.0";
|
|
8
8
|
|
|
9
9
|
// src/core/auth.ts
|
|
10
10
|
var TOKEN_REFRESH_MARGIN_MS = 6e4;
|
|
@@ -1128,9 +1128,13 @@ var ContactsResource = class extends Resource {
|
|
|
1128
1128
|
/**
|
|
1129
1129
|
* La agenda de la organización, de la más reciente a la más antigua.
|
|
1130
1130
|
*
|
|
1131
|
-
*
|
|
1132
|
-
* array `social_identifiers`
|
|
1133
|
-
*
|
|
1131
|
+
* `social_network` acota a los contactos localizables en esa red. Devolvía siempre una lista
|
|
1132
|
+
* vacía —el servidor comparaba el array entero de `social_identifiers` contra el nombre de la
|
|
1133
|
+
* red— hasta que se arregló el 2026-08-24; hasta la 0.3.0 este método no lo exponía.
|
|
1134
|
+
*
|
|
1135
|
+
* ```ts
|
|
1136
|
+
* const { data } = await pv.contacts.list(orgId, { social_network: "whatsapp", limit: 50 });
|
|
1137
|
+
* ```
|
|
1134
1138
|
*/
|
|
1135
1139
|
async list(idOrganization, options = {}) {
|
|
1136
1140
|
return this.getList(this.path(idOrganization), "contacts", listQuery2(options), options);
|
|
@@ -1225,7 +1229,8 @@ function listQuery2(options) {
|
|
|
1225
1229
|
const query = {
|
|
1226
1230
|
offset: options.offset,
|
|
1227
1231
|
limit: options.limit,
|
|
1228
|
-
search: options.search
|
|
1232
|
+
search: options.search,
|
|
1233
|
+
social_network: options.social_network
|
|
1229
1234
|
};
|
|
1230
1235
|
options.extra_data?.forEach((filter, index) => {
|
|
1231
1236
|
query[`extra_data[${index}][key]`] = filter.key;
|
|
@@ -1576,6 +1581,13 @@ var MessagesResource = class extends Resource {
|
|
|
1576
1581
|
* En Facebook e Instagram sólo se admite **un** adjunto por mensaje (error 1509), y en WhatsApp
|
|
1577
1582
|
* fuera de la ventana de 24 horas sólo se admite una plantilla.
|
|
1578
1583
|
*
|
|
1584
|
+
* `comment_message` y `publication_message` exigen `in_response_external_id`: el identificador
|
|
1585
|
+
* EN LA RED de lo que se responde —el `external_id` de un comentario, el `external_identifier`
|
|
1586
|
+
* de una publicación—, nunca un `_id` de PlanVortex, y error 1510 si falta. El endpoint no lo
|
|
1587
|
+
* leía del cuerpo hasta el 2026-08-24, lo que dejaba los dos tipos fuera del alcance de la API
|
|
1588
|
+
* pública; ya funcionan, y sólo en Facebook e Instagram: `comment_message` manda una respuesta
|
|
1589
|
+
* privada a un comentario público y `publication_message` adjunta el post como `MEDIA_SHARE`.
|
|
1590
|
+
*
|
|
1579
1591
|
* ```ts
|
|
1580
1592
|
* await pv.messages.send(orgId, accountId, contactId, {
|
|
1581
1593
|
* message_type: "simple_message",
|
|
@@ -1954,8 +1966,8 @@ var ProductsResource = class extends Resource {
|
|
|
1954
1966
|
* Los productos de un catálogo.
|
|
1955
1967
|
*
|
|
1956
1968
|
* `idCatalog` es obligatorio de hecho aunque la API lo pinte opcional: sin él la petición falla
|
|
1957
|
-
* con el error 2000.
|
|
1958
|
-
*
|
|
1969
|
+
* con el error 2000. Para pedir **un** producto por su identificador, {@link get} — no es un
|
|
1970
|
+
* argumento de aquí porque la respuesta viene con otra forma.
|
|
1959
1971
|
*
|
|
1960
1972
|
* ```ts
|
|
1961
1973
|
* const { data } = await pv.products.list(orgId, accountId, catalogId, { limit: 50 });
|
|
@@ -1985,6 +1997,40 @@ var ProductsResource = class extends Resource {
|
|
|
1985
1997
|
options
|
|
1986
1998
|
);
|
|
1987
1999
|
}
|
|
2000
|
+
/**
|
|
2001
|
+
* UN producto, por su identificador **en la red** (el de Meta, no un `_id` de PlanVortex).
|
|
2002
|
+
*
|
|
2003
|
+
* El servidor reenviaba ese filtro con un nombre que el SDK no lee, así que nunca llegaba a la
|
|
2004
|
+
* red y la llamada moría con un 2000; se arregló el 2026-08-24 y aquí se expone desde la 0.3.0.
|
|
2005
|
+
*
|
|
2006
|
+
* **La respuesta viene con otra forma que la del listado.** Pedir un producto suelto va al nodo
|
|
2007
|
+
* de ese producto, así que la red contesta con el producto y `items` trae un objeto. Por eso
|
|
2008
|
+
* esto es un método aparte y no un argumento de {@link list}: con un objeto no se construye una
|
|
2009
|
+
* página. Se acepta también una lista, que es lo que devolvería un despliegue que envolviera la
|
|
2010
|
+
* respuesta, y coger el primero es mejor que reventar por la forma del sobre.
|
|
2011
|
+
*
|
|
2012
|
+
* ```ts
|
|
2013
|
+
* const product = await pv.products.get(orgId, accountId, "7123456789012345");
|
|
2014
|
+
* ```
|
|
2015
|
+
*/
|
|
2016
|
+
async get(idOrganization, idAccount, productId, options = {}) {
|
|
2017
|
+
const body = await this.httpGet(
|
|
2018
|
+
`${this.path(idOrganization, idAccount)}/products`,
|
|
2019
|
+
{ product_id: requireId(productId, "productId") },
|
|
2020
|
+
options
|
|
2021
|
+
);
|
|
2022
|
+
const content = unwrapOne(body, "items");
|
|
2023
|
+
if (Array.isArray(content)) {
|
|
2024
|
+
if (!content.length) {
|
|
2025
|
+
throw new PlanVortexError(NO_ERROR_CODE, `La red no devuelve ning\xFAn producto "${productId}".`, {
|
|
2026
|
+
family: "http",
|
|
2027
|
+
data: { product_id: productId }
|
|
2028
|
+
});
|
|
2029
|
+
}
|
|
2030
|
+
return content[0];
|
|
2031
|
+
}
|
|
2032
|
+
return content;
|
|
2033
|
+
}
|
|
1988
2034
|
/**
|
|
1989
2035
|
* Da de alta un producto en un catálogo, o **actualiza uno existente** si el cuerpo trae `id`.
|
|
1990
2036
|
* Devuelve el identificador en la red, no el producto.
|