planvortex 0.14.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 +13 -5
- package/dist/{index-C6-SJxzP.d.cts → index-DnfzM7vS.d.cts} +144 -20
- package/dist/{index-C6-SJxzP.d.ts → index-DnfzM7vS.d.ts} +144 -20
- package/dist/index.cjs +6 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -9
- package/dist/index.d.ts +11 -9
- package/dist/index.js +6 -5
- package/dist/index.js.map +1 -1
- package/dist/webhooks/index.cjs +8 -1
- package/dist/webhooks/index.cjs.map +1 -1
- package/dist/webhooks/index.d.cts +1 -1
- package/dist/webhooks/index.d.ts +1 -1
- package/dist/webhooks/index.js +8 -2
- package/dist/webhooks/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -165,8 +165,13 @@ const { ai_plan, estimate } = await pv.aiPlans.create(clientId, orgId, {
|
|
|
165
165
|
console.log(estimate.images_target); // 0 — the pictures come from the source
|
|
166
166
|
```
|
|
167
167
|
|
|
168
|
-
|
|
168
|
+
Five things worth knowing before you build the screen:
|
|
169
169
|
|
|
170
|
+
- **You do not have to poll.** When the plan finishes, your app's webhook receives
|
|
171
|
+
`ai_plan_generated` or `ai_plan_failed` (see [the events](#the-events)), and that is the moment to
|
|
172
|
+
read it with `pv.aiPlans.get()`. Without a webhook, poll `get` while `state` is `pending` or
|
|
173
|
+
`generating`. Deliveries are not retried, so if your endpoint was down, `get` still tells you how
|
|
174
|
+
the plan ended.
|
|
170
175
|
- **The template that does not generate images does not spend image credits, and images are 94 % of
|
|
171
176
|
a plan.** The same week — 7 publications, a picture on each — costs 519 credits as `standard` and
|
|
172
177
|
**48** as `from_images`. Say it before the plan is created, not after it is charged.
|
|
@@ -366,14 +371,17 @@ malformed signature.
|
|
|
366
371
|
| `messaging_error` | The network refused a message you sent | `messageObj.message_errors` |
|
|
367
372
|
| `comments` | A comment came in | `commentObj` |
|
|
368
373
|
| `integration_error` | An integration stopped working | `provider`, `error_code` |
|
|
374
|
+
| `ai_plan_generated` | An AI plan finished and is ready to review | `id_ai_plan`, `warnings` |
|
|
375
|
+
| `ai_plan_failed` | An AI plan gave up | `id_ai_plan`, `error` |
|
|
369
376
|
|
|
370
|
-
`isAccountStateChange`, `isMessageChange`, `isCommentChange
|
|
371
|
-
a change to its own type. Use them rather than a `switch`: the union carries a member for the
|
|
377
|
+
`isAccountStateChange`, `isMessageChange`, `isCommentChange`, `isIntegrationErrorChange` and
|
|
378
|
+
`isAiPlanChange` narrow a change to its own type. Use them rather than a `switch`: the union carries a member for the
|
|
372
379
|
`field`s this version does not know yet — the list grows — and TypeScript cannot rule that one out
|
|
373
380
|
of a `case`.
|
|
374
381
|
|
|
375
|
-
Two things about the payload that are easy to get wrong. An **integration** change
|
|
376
|
-
`id_account` nor `social_network`, because
|
|
382
|
+
Two things about the payload that are easy to get wrong. An **integration** change and an **AI
|
|
383
|
+
plan** change carry neither `id_account` nor `social_network`, because both hang off the
|
|
384
|
+
organization. And
|
|
377
385
|
`messageObj` arrives **populated**: `contact_id`, `from_contact_id` and `message_options.files`
|
|
378
386
|
carry whole objects rather than identifiers, which is what `messageContact`, `messageContactId`,
|
|
379
387
|
`messageDirection` and `messageFiles` are for.
|
|
@@ -367,7 +367,7 @@ interface paths {
|
|
|
367
367
|
put?: never;
|
|
368
368
|
/**
|
|
369
369
|
* Create an AI publication plan
|
|
370
|
-
* @description Create a weekly AI publication plan. The plan is queued in state 'pending' and generated asynchronously by the generate-ai-plans job; poll GET by id while state is pending or generating. Validations at creation: the client plan allows AI (it contracts AI credits; Free does not), the accounts belong to the organization, there are enough AI credits for the deterministic base cost (orchestration + target texts), and there is room in the organization's monthly publication limit. Returns the created plan together with the deterministic cost estimate. Requires the ai_plans:create permission. Since the plan can be generated from a SOURCE (`template` + `source`), part of that validation is the source itself: the article is downloaded, the catalogue is read live and the product pictures are copied — all of it inside this request, so what does not work fails with the user in front of it. A plan whose source did not fit in the week is still created, and says so in ai_plan.warnings (2117). With a Pinterest account in the plan, two more checks run at creation: every Pinterest account needs its board in `destinations` (2118), and a configuration that would leave pins without an image is refused (2119).
|
|
370
|
+
* @description Create a weekly AI publication plan. The plan is queued in state 'pending' and generated asynchronously by the generate-ai-plans job. When it finishes, your app's `webhook_url` receives `ai_plan_generated` or `ai_plan_failed` (the payload is in the comments specification, `AiPlanWebhookChange`); without a webhook, poll GET by id while state is pending or generating. The webhook is best effort and not retried, so the GET is still the source of truth. Validations at creation: the client plan allows AI (it contracts AI credits; Free does not), the accounts belong to the organization, there are enough AI credits for the deterministic base cost (orchestration + target texts), and there is room in the organization's monthly publication limit. Returns the created plan together with the deterministic cost estimate. Requires the ai_plans:create permission. Since the plan can be generated from a SOURCE (`template` + `source`), part of that validation is the source itself: the article is downloaded, the catalogue is read live and the product pictures are copied — all of it inside this request, so what does not work fails with the user in front of it. A plan whose source did not fit in the week is still created, and says so in ai_plan.warnings (2117). With a Pinterest account in the plan, two more checks run at creation: every Pinterest account needs its board in `destinations` (2118), and a configuration that would leave pins without an image is refused (2119).
|
|
371
371
|
*/
|
|
372
372
|
post: operations["addAiPlan"];
|
|
373
373
|
delete?: never;
|
|
@@ -385,7 +385,7 @@ interface paths {
|
|
|
385
385
|
};
|
|
386
386
|
/**
|
|
387
387
|
* Get an AI publication plan by id
|
|
388
|
-
* @description Return a single AI plan with its generated publications populated.
|
|
388
|
+
* @description Return a single AI plan with its generated publications populated. Read it when your app receives `ai_plan_generated` or `ai_plan_failed`. Without a webhook, this is the endpoint to poll while state is pending or generating. The webhook is not retried, so if your endpoint was down when the plan finished, this GET still tells you how it ended. Requires the ai_plans:read permission.
|
|
389
389
|
*/
|
|
390
390
|
get: operations["getAiPlan"];
|
|
391
391
|
put?: never;
|
|
@@ -463,7 +463,7 @@ interface paths {
|
|
|
463
463
|
put?: never;
|
|
464
464
|
/**
|
|
465
465
|
* Retry a failed AI publication plan
|
|
466
|
-
* @description Re-queue a failed plan: it goes back to state 'pending' (attempts and error reset) and the background job regenerates it with the SAME data (prompt, accounts, options).
|
|
466
|
+
* @description Re-queue a failed plan: it goes back to state 'pending' (attempts and error reset) and the background job regenerates it with the SAME data (prompt, accounts, options). As after creation, the end arrives on your webhook as `ai_plan_generated` or `ai_plan_failed`; without one, poll the plan while state is pending or generating. Only valid from state 'failed'. Already-spent credits are NOT refunded and a new generation spends again; drafts left over from the failed attempt are discarded by the generation itself. If the failure was a business error (no AI credits, no monthly publication slots), retrying will fail the same way. Requires the ai_plans:update permission.
|
|
467
467
|
*/
|
|
468
468
|
post: operations["retryAiPlan"];
|
|
469
469
|
delete?: never;
|
|
@@ -1242,7 +1242,9 @@ interface paths {
|
|
|
1242
1242
|
put?: never;
|
|
1243
1243
|
/**
|
|
1244
1244
|
* Create new publications
|
|
1245
|
-
* @description Create new publications. For X (Twitter) accounts, paid actions consume the client's monthly X credit pool (shared across organizations). When a publication is sent immediately, the required credits are checked before publishing and only charged on success. A tweet costs 15 credits, or 200 credits if its text contains a link. Link detection uses the same rule the backend applies: an http(s):// URL, a www. host, or a bare domain with a recognized TLD (regex TWITTER_LINK_REGEX). A scheduled publication does not consume credits when created; it is charged when the background job publishes it. If there are not enough credits at publish time the scheduled publication is left in state 'withErrors' with publication_errors.code = 940 and
|
|
1245
|
+
* @description Create new publications. For X (Twitter) accounts, paid actions consume the client's monthly X credit pool (shared across organizations). When a publication is sent immediately, the required credits are checked before publishing and only charged on success. A tweet costs 15 credits, or 200 credits if its text contains a link. Link detection uses the same rule the backend applies: an http(s):// URL, a www. host, or a bare domain with a recognized TLD (regex TWITTER_LINK_REGEX). A scheduled publication does not consume credits when created; it is charged when the background job publishes it. If there are not enough credits at publish time the scheduled publication is left in state 'withErrors' with publication_errors.code = 940 (it is never thrown, and no webhook announces it: read the publication to find out). Publishing immediately without enough credits returns error 940.
|
|
1246
|
+
*
|
|
1247
|
+
* **An Instagram video can come back in state `publishing`, and that is not an error.** Instagram processes a video before it can be published, and the request waits about 30 seconds for it. If Meta has not finished by then, the response carries `state: "publishing"` and a `pending_publish` object, and PlanVortex keeps asking Instagram about once a minute in the background, for up to 10 minutes. Read the publication again (`GET /organizations/{id_organization}/publish/{id_publication}`) after `pending_publish.next_check` until it is `sended` or `withErrors`. **Do not retry it or create it again**: the first one is still on its way, and a second one would publish the video twice.
|
|
1246
1248
|
*/
|
|
1247
1249
|
post: operations["addPublication"];
|
|
1248
1250
|
delete?: never;
|
|
@@ -1992,6 +1994,8 @@ interface paths {
|
|
|
1992
1994
|
* @description Delete publication by identifier. It stops being readable by identifier afterwards, so deleting twice answers error 917. For an already-sent X (Twitter) publication, removing the tweet on X is a paid action that consumes 15 X credits; it is only removed on X when there are enough credits. Returns error 940 when the X credit pool is exhausted.
|
|
1993
1995
|
*
|
|
1994
1996
|
* **On Telegram there is a 48-hour window.** Past it the Bot API refuses to delete a message whatever the bot's role is, and the answer is error 966 with `published_date` and `max_hours` in `data` — so the sensible thing is to grey the button out rather than offer it and fail. Error 969 is the other case: the bot is no longer allowed to delete there. And an album is several messages: all of them go, or the post would be left half-published in the channel.
|
|
1997
|
+
*
|
|
1998
|
+
* **Deleting a publication that is still `publishing` with `pending_publish` stops it**: PlanVortex stops asking Instagram and never publishes it, unless the check running at that very moment has already done so.
|
|
1995
1999
|
*/
|
|
1996
2000
|
delete: operations["deletePublication"];
|
|
1997
2001
|
options?: never;
|
|
@@ -2062,7 +2066,9 @@ interface paths {
|
|
|
2062
2066
|
* Retry a failed publication
|
|
2063
2067
|
* @description Sends a publication that ended in state `withErrors` to its social network again, WITHOUT changing its content.
|
|
2064
2068
|
*
|
|
2065
|
-
* The publication is sent during the request, so the response already carries the outcome: `state: "sended"` if it went out, or `state: "withErrors"` with the errors of THIS attempt if it failed again.
|
|
2069
|
+
* The publication is sent during the request, so the response already carries the outcome: `state: "sended"` if it went out, or `state: "withErrors"` with the errors of THIS attempt if it failed again. An Instagram video can also come back in `publishing` with `pending_publish`: the attempt goes on in the background, and the retry is already spent (see `pending_publish` in `Publication`).
|
|
2070
|
+
*
|
|
2071
|
+
* On Instagram, a retry is worth it after a **999** (Meta ran out of time) and pointless after a **998** (Meta rejected the file): change the file with a `PUT` first. A scheduled publication whose date has not arrived yet goes back to `ready` and the scheduler picks it up at its time.
|
|
2066
2072
|
*
|
|
2067
2073
|
* Every accepted call spends one retry, even when the publication fails again — what the endpoint promises is an attempt, not a success. The limit is `max_retries`, also served by `GET /publication_limits`. Once it is spent the way to try again is to update the publication (`PUT`), which resets the counter to 0, or to create a new one.
|
|
2068
2074
|
*/
|
|
@@ -2670,9 +2676,9 @@ interface webhooks {
|
|
|
2670
2676
|
* A change happened (notification to your app)
|
|
2671
2677
|
* @description PlanVortex `POST`s to the `webhook_url` of your client app when something happens. **The body is an array of changes**, and each one carries `field` telling you what it is — switch on it and ignore what you do not handle, because the list grows with the product.
|
|
2672
2678
|
*
|
|
2673
|
-
*
|
|
2679
|
+
* 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.
|
|
2674
2680
|
*
|
|
2675
|
-
* The events delivered today are `new_account`, `change_state_account`, `messages`, `messaging_postbacks`, `messaging_seen`, `messaging_error`, `comments` and `
|
|
2681
|
+
* 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`.
|
|
2676
2682
|
*
|
|
2677
2683
|
* ### Comments
|
|
2678
2684
|
*
|
|
@@ -2682,6 +2688,14 @@ interface webhooks {
|
|
|
2682
2688
|
*
|
|
2683
2689
|
* **Meta repeats deliveries.** The same comment can arrive more than once; the backend is idempotent about it and so should you be — deduplicate on `commentObj.external_id`.
|
|
2684
2690
|
*
|
|
2691
|
+
* ### AI plans
|
|
2692
|
+
*
|
|
2693
|
+
* `ai_plan_generated` and `ai_plan_failed` say that a plan has **finished**: it was generated, or it gave up. Instead of polling the plan every few seconds, wait for one of these and then read it once with `GET /clients/{id_client}/organizations/{id_organization}/ai_plans/{id_ai_plan}`. The change carries ids and numbers only, never the prompt or the generated text, so the publications are in that `GET`.
|
|
2694
|
+
*
|
|
2695
|
+
* A plan that hits a transient error goes back to the queue and is retried. That is not an end and sends nothing, so each plan sends **one** of these two events, never a `failed` followed by a `generated`. A plan generated with notices (`warnings` above zero) is still `ai_plan_generated`: it is usable, and the notices are in the plan.
|
|
2696
|
+
*
|
|
2697
|
+
* 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.
|
|
2698
|
+
*
|
|
2685
2699
|
* ### Verifying the signature
|
|
2686
2700
|
*
|
|
2687
2701
|
* Every delivery carries the body signed with your app's secret, twice:
|
|
@@ -3044,7 +3058,7 @@ interface components {
|
|
|
3044
3058
|
/** @description The source snapshot. Absent on a `standard` plan, which has no source. */
|
|
3045
3059
|
source?: components["schemas"]["AiPlansAiPlanSource"];
|
|
3046
3060
|
/**
|
|
3047
|
-
* @description State machine: pending -> generating -> generated -> validated | failed | cancelled.
|
|
3061
|
+
* @description State machine: pending -> generating -> generated -> validated | failed | cancelled. Reaching `generated` or `failed` is announced to your app's webhook (`ai_plan_generated`, `ai_plan_failed`); without one, poll the plan while state is pending or generating.
|
|
3048
3062
|
* @enum {string}
|
|
3049
3063
|
*/
|
|
3050
3064
|
state: "pending" | "generating" | "generated" | "validated" | "failed" | "cancelled";
|
|
@@ -3355,7 +3369,7 @@ interface components {
|
|
|
3355
3369
|
*
|
|
3356
3370
|
* **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.
|
|
3357
3371
|
*
|
|
3358
|
-
* The events delivered today are `new_account`, `change_state_account`, `messages`, `messaging_postbacks`, `messaging_seen`, `messaging_error`, `comments` and `
|
|
3372
|
+
* 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.
|
|
3359
3373
|
*/
|
|
3360
3374
|
webhook_url?: string;
|
|
3361
3375
|
};
|
|
@@ -3645,6 +3659,40 @@ interface components {
|
|
|
3645
3659
|
total?: number;
|
|
3646
3660
|
users?: components["schemas"]["ClientsRolesUser"][];
|
|
3647
3661
|
};
|
|
3662
|
+
/**
|
|
3663
|
+
* @description One change in the array PlanVortex posts to your app's `webhook_url`, when an **AI plan finished**: `ai_plan_generated` when it came out, `ai_plan_failed` when it gave up.
|
|
3664
|
+
*
|
|
3665
|
+
* Like `IntegrationWebhookChange`, it carries no `id_account` and no `social_network`: a plan can span several networks, and it hangs off the organization. It carries ids and numbers only. Read the plan itself with `GET /clients/{id_client}/organizations/{id_organization}/ai_plans/{id_ai_plan}`.
|
|
3666
|
+
*/
|
|
3667
|
+
CommentsAiPlanWebhookChange: {
|
|
3668
|
+
/** @description AI credits the generation consumed, the same figure as `AiPlan.credits_spent`. A failed plan can have spent credits too, and they are not refunded. */
|
|
3669
|
+
credits_spent: number;
|
|
3670
|
+
/** @description Only on `ai_plan_failed`: why the plan failed, the same `code` and `message` as `AiPlan.error`. Its `data` does not travel here; read the plan for it. */
|
|
3671
|
+
error?: components["schemas"]["CommentsAiPlanWebhookError"];
|
|
3672
|
+
/** @enum {string} */
|
|
3673
|
+
field: "ai_plan_generated" | "ai_plan_failed";
|
|
3674
|
+
id_ai_plan: string;
|
|
3675
|
+
id_organization: string;
|
|
3676
|
+
/**
|
|
3677
|
+
* @description The state the plan finished in. It always matches `field`: `generated` with `ai_plan_generated`, `failed` with `ai_plan_failed`.
|
|
3678
|
+
* @enum {string}
|
|
3679
|
+
*/
|
|
3680
|
+
state: "generated" | "failed";
|
|
3681
|
+
/**
|
|
3682
|
+
* @description What the plan was generated from, the same value as `AiPlan.template`.
|
|
3683
|
+
* @enum {string}
|
|
3684
|
+
*/
|
|
3685
|
+
template: "standard" | "from_images" | "from_text" | "from_catalog" | "campaign";
|
|
3686
|
+
/** @description How many draft publications the plan holds. A failed plan can still hold the drafts of its failed attempt; retrying it discards them. */
|
|
3687
|
+
total_publications: number;
|
|
3688
|
+
/** @description **How many** non-blocking notices the plan has, not the notices themselves: those are in `AiPlan.warnings`. Above zero the plan is still generated and usable. */
|
|
3689
|
+
warnings: number;
|
|
3690
|
+
};
|
|
3691
|
+
/** @description Why an AI plan failed, inside `AiPlanWebhookChange.error`: the same `code` and `message` as `AiPlan.error`. Its `data` is left out, because it can carry what the AI provider answered; read the plan for it. */
|
|
3692
|
+
CommentsAiPlanWebhookError: {
|
|
3693
|
+
code: number;
|
|
3694
|
+
message: string;
|
|
3695
|
+
};
|
|
3648
3696
|
/** @description A comment — or a review — as PlanVortex stores it. Remember it is a **snapshot** of what the network said at `collected_date`; the live thread endpoints return the same shape reconciled against the network. */
|
|
3649
3697
|
CommentsComment: {
|
|
3650
3698
|
_id: string;
|
|
@@ -3776,7 +3824,7 @@ interface components {
|
|
|
3776
3824
|
/**
|
|
3777
3825
|
* @description One change in the array PlanVortex posts to your app's `webhook_url`, when the change concerns a social **account**.
|
|
3778
3826
|
*
|
|
3779
|
-
* An integration that stopped working has a shape of its own
|
|
3827
|
+
* An integration that stopped working has a shape of its own (`IntegrationWebhookChange`), and so does an AI plan that finished (`AiPlanWebhookChange`). One delivery can mix them. Switch on `field`, and ignore what you do not handle.
|
|
3780
3828
|
*/
|
|
3781
3829
|
CommentsWebhookChange: {
|
|
3782
3830
|
/** @description The comment. Present only when `field` is `comments`, and absent even then if the author deleted a comment we had never seen. */
|
|
@@ -4720,10 +4768,13 @@ interface components {
|
|
|
4720
4768
|
name?: string;
|
|
4721
4769
|
/** Format: date-time */
|
|
4722
4770
|
next_stats_update?: string;
|
|
4771
|
+
pending_publish?: components["schemas"]["PublicationPending"];
|
|
4723
4772
|
/**
|
|
4724
4773
|
* @description Why the publication failed, one entry per problem. **It is an array**, and it is empty on a publication that has not failed.
|
|
4725
4774
|
*
|
|
4726
|
-
* For a scheduled X (Twitter) publication that runs out of credits at publish time, `code` is 940 and `data` is `{ used, limit }`; the publication stays in state `withErrors
|
|
4775
|
+
* For a scheduled X (Twitter) publication that runs out of credits at publish time, `code` is 940 and `data` is `{ used, limit }`; the publication stays in state `withErrors`. No webhook announces it: read the publication to find out.
|
|
4776
|
+
*
|
|
4777
|
+
* On Instagram, two codes tell you whether a retry makes sense. **998**: Meta rejected the media while processing it (a codec, a duration, a URL it could not download). `data` carries `container_id`, `status_code` and, when Meta gives one, its reason in `status`. Retrying the same file fails the same way: change it first. **999**: Meta had not finished processing the media 10 minutes after it was sent. `data` carries `container_ids` and `minutes`. The file is not the problem, and a retry usually works.
|
|
4727
4778
|
*/
|
|
4728
4779
|
publication_errors: {
|
|
4729
4780
|
code: number;
|
|
@@ -4749,6 +4800,8 @@ interface components {
|
|
|
4749
4800
|
social_network: components["schemas"]["SocialNetwork"];
|
|
4750
4801
|
/**
|
|
4751
4802
|
* @description `draft` is never sent; `ready` is scheduled; `publishing` is in the network's hands right now; `sended` went out; `withErrors` failed and carries the reason in `publication_errors`.
|
|
4803
|
+
*
|
|
4804
|
+
* `publishing` usually lasts a few seconds, but it can last **up to 10 minutes** when the network is still processing a video (today, Instagram). Then `pending_publish` is present: wait and read the publication again, do not retry it.
|
|
4752
4805
|
* @enum {string}
|
|
4753
4806
|
*/
|
|
4754
4807
|
state: "ready" | "withErrors" | "sended" | "draft" | "publishing";
|
|
@@ -4793,6 +4846,31 @@ interface components {
|
|
|
4793
4846
|
/** @description The section's label, for display. Decides nothing. */
|
|
4794
4847
|
section_name?: string;
|
|
4795
4848
|
};
|
|
4849
|
+
/**
|
|
4850
|
+
* @description Present only while the network is still **processing** what was sent, and PlanVortex is waiting to publish it. Today that happens on Instagram alone, when Meta takes longer than the ~30 seconds the request waits to process the media. In practice, that means videos.
|
|
4851
|
+
*
|
|
4852
|
+
* The publication stays in state `publishing`, and the background job asks Instagram again about once a minute until it goes out (`sended`) or fails (`withErrors`). It gives up 10 minutes after the media was sent to Instagram, and then the publication ends in `withErrors` with code 999. The object disappears as soon as the publication is resolved.
|
|
4853
|
+
*
|
|
4854
|
+
* **Wait for it. Do not retry it and do not create it again**: it has not failed, and a second publication would put the same video out twice. There is no webhook for the outcome: read the publication again after `next_check`. While this object is present the publication **cannot be updated** (error 921), for the same reason.
|
|
4855
|
+
*/
|
|
4856
|
+
PublicationPending: {
|
|
4857
|
+
/** @description PlanVortex's own bookkeeping to resume the publication (on Instagram, the ids of Meta's containers). Its content may change without notice. */
|
|
4858
|
+
data?: {
|
|
4859
|
+
[key: string]: unknown;
|
|
4860
|
+
};
|
|
4861
|
+
/**
|
|
4862
|
+
* Format: date-time
|
|
4863
|
+
* @description When PlanVortex stops waiting. If the network has not finished by then, the publication ends in `withErrors` (999 on Instagram).
|
|
4864
|
+
*/
|
|
4865
|
+
deadline?: string;
|
|
4866
|
+
/**
|
|
4867
|
+
* Format: date-time
|
|
4868
|
+
* @description When PlanVortex will ask the network again. A good moment to read the publication again: asking before it changes nothing.
|
|
4869
|
+
*/
|
|
4870
|
+
next_check?: string;
|
|
4871
|
+
/** @description PlanVortex's own bookkeeping: the temporary cropped files the network may still be downloading. Do not rely on it. */
|
|
4872
|
+
temp_keys?: string[];
|
|
4873
|
+
};
|
|
4796
4874
|
/** @description A place inside the account a publication can be sent to: on Pinterest, a board. */
|
|
4797
4875
|
PublicationsDestination: {
|
|
4798
4876
|
/** @description The destination's own description, when the network has one. */
|
|
@@ -8791,7 +8869,7 @@ interface operations {
|
|
|
8791
8869
|
* | `1101` | Invalid organization |
|
|
8792
8870
|
* | `917` | Publication doesn't exists |
|
|
8793
8871
|
* | `935` | Invalid publication |
|
|
8794
|
-
* | `921` | Can't update a publication already sended |
|
|
8872
|
+
* | `921` | Can't update a publication already sended, **or one the network is still processing** (state `publishing` with `pending_publish`; then `data.state` is `publishing`). Editing it would publish it twice. It can be edited again if it fails. |
|
|
8795
8873
|
* | `940` | X (Twitter) credits exhausted. Not enough monthly credits to publish this tweet (same link detection and 15/200 tariff as on create). Response data: { used, limit }. |
|
|
8796
8874
|
* | `523` | Invalid application |
|
|
8797
8875
|
*/
|
|
@@ -10423,7 +10501,7 @@ interface operations {
|
|
|
10423
10501
|
* | `1101` | Invalid organization |
|
|
10424
10502
|
* | `917` | Publication doesn't exists |
|
|
10425
10503
|
* | `935` | Invalid publication |
|
|
10426
|
-
* | `921` | Can't update a publication already sended |
|
|
10504
|
+
* | `921` | Can't update a publication already sended, **or one the network is still processing** (state `publishing` with `pending_publish`; then `data.state` is `publishing`). Editing it would publish it twice. It can be edited again if it fails. |
|
|
10427
10505
|
* | `940` | X (Twitter) credits exhausted. Not enough monthly credits to publish this tweet (same link detection and 15/200 tariff as on create). Response data: { used, limit }. |
|
|
10428
10506
|
* | `523` | Invalid application |
|
|
10429
10507
|
*/
|
|
@@ -12167,7 +12245,7 @@ interface operations {
|
|
|
12167
12245
|
* }
|
|
12168
12246
|
* ]
|
|
12169
12247
|
*/
|
|
12170
|
-
"application/json": (components["schemas"]["CommentsWebhookChange"] | components["schemas"]["CommentsIntegrationWebhookChange"])[];
|
|
12248
|
+
"application/json": (components["schemas"]["CommentsWebhookChange"] | components["schemas"]["CommentsIntegrationWebhookChange"] | components["schemas"]["CommentsAiPlanWebhookChange"])[];
|
|
12171
12249
|
};
|
|
12172
12250
|
};
|
|
12173
12251
|
responses: {
|
|
@@ -12591,6 +12669,16 @@ type AiImageOrigin = Schemas["AiImageOrigin"];
|
|
|
12591
12669
|
* guarda: cambiar la imagen generada por una foto propia lo apaga.
|
|
12592
12670
|
*/
|
|
12593
12671
|
type PublicationAiGenerated = Schemas["PublicationAiGenerated"];
|
|
12672
|
+
/**
|
|
12673
|
+
* La red aun esta PROCESANDO lo que se le mando y PlanVortex espera para publicarlo: hoy, un video
|
|
12674
|
+
* de Instagram que Meta tarda mas de ~30 s en procesar. La {@link Publication} sigue en
|
|
12675
|
+
* `publishing` hasta 10 minutos, y PlanVortex vuelve a preguntar solo una vez por minuto.
|
|
12676
|
+
*
|
|
12677
|
+
* **Hay que esperar, no reintentar ni volver a crearla**: saldria el video dos veces. No hay webhook
|
|
12678
|
+
* del resultado: vuelve a leer la publicacion despues de `next_check`. Mientras esta puesto no se
|
|
12679
|
+
* puede editar (error 921). `temp_keys` y `data` son contabilidad interna de PlanVortex.
|
|
12680
|
+
*/
|
|
12681
|
+
type PublicationPending = Schemas["PublicationPending"];
|
|
12594
12682
|
/**
|
|
12595
12683
|
* Una publicacion: programada, enviada o fallida.
|
|
12596
12684
|
*
|
|
@@ -13393,11 +13481,12 @@ type WebhookAlgorithm = keyof typeof WEBHOOK_SIGNATURE_HEADERS;
|
|
|
13393
13481
|
* Los eventos que hoy se entregan de verdad, comprobados uno a uno contra el servidor.
|
|
13394
13482
|
*
|
|
13395
13483
|
* Salen de dos sitios: `ALLOWED_WEBHOOKS_NOTIFICATIONS` para los que levanta PlanVortex
|
|
13396
|
-
* (`new_account`, `change_state_account`, `integration_error
|
|
13397
|
-
* llegan de la red y sobreviven al filtro.
|
|
13398
|
-
* ignora en vez de romper: para eso está
|
|
13484
|
+
* (`new_account`, `change_state_account`, `integration_error`, `ai_plan_generated`,
|
|
13485
|
+
* `ai_plan_failed`) y `WEBHOOKS_TO_HANDLE` para los que llegan de la red y sobreviven al filtro.
|
|
13486
|
+
* **La lista crece**, así que un `field` desconocido se ignora en vez de romper: para eso está
|
|
13487
|
+
* {@link UnknownWebhookChange}.
|
|
13399
13488
|
*/
|
|
13400
|
-
declare const WEBHOOK_EVENTS: readonly ["new_account", "change_state_account", "messages", "messaging_postbacks", "messaging_seen", "messaging_error", "comments", "integration_error"];
|
|
13489
|
+
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"];
|
|
13401
13490
|
type WebhookEvent = (typeof WEBHOOK_EVENTS)[number];
|
|
13402
13491
|
/** Lo que trae todo cambio que cuelga de una CUENTA, pase lo que pase. */
|
|
13403
13492
|
interface AccountWebhookChangeBase {
|
|
@@ -13459,6 +13548,39 @@ interface IntegrationErrorChange {
|
|
|
13459
13548
|
/** El código del catálogo de PlanVortex que dice qué pasó. Los de integraciones van del 2200 al 2299. */
|
|
13460
13549
|
error_code: number;
|
|
13461
13550
|
}
|
|
13551
|
+
/**
|
|
13552
|
+
* Un plan de IA TERMINÓ: salió (`ai_plan_generated`) o se rindió (`ai_plan_failed`).
|
|
13553
|
+
*
|
|
13554
|
+
* Es lo que te ahorra preguntar por el plan cada pocos segundos: espera a este evento y lee el plan
|
|
13555
|
+
* una vez con `pv.aiPlans.get()`. Sólo trae ids y números, nunca el prompt ni lo generado.
|
|
13556
|
+
*
|
|
13557
|
+
* **No trae `id_account` ni `social_network`**, igual que {@link IntegrationErrorChange}: un plan
|
|
13558
|
+
* puede abarcar varias redes y cuelga de la organización.
|
|
13559
|
+
*
|
|
13560
|
+
* Un fallo transitorio devuelve el plan a la cola y no manda nada, así que cada plan manda **uno**
|
|
13561
|
+
* de los dos, nunca un `failed` seguido de un `generated`. Y no se reintenta: si tu endpoint estaba
|
|
13562
|
+
* caído cuando terminó, `pv.aiPlans.get()` sigue diciendo cómo acabó.
|
|
13563
|
+
*/
|
|
13564
|
+
interface AiPlanChange {
|
|
13565
|
+
field: "ai_plan_generated" | "ai_plan_failed";
|
|
13566
|
+
id_ai_plan: string;
|
|
13567
|
+
id_organization: string;
|
|
13568
|
+
/** El estado en que terminó. Siempre cuadra con `field`: `generated` o `failed`. */
|
|
13569
|
+
state: "generated" | "failed";
|
|
13570
|
+
/** De qué salió el plan: el mismo valor que `AiPlan.template`. La lista crece. */
|
|
13571
|
+
template: PlannerTemplateName;
|
|
13572
|
+
/** Cuántas publicaciones en borrador tiene. Uno `failed` puede conservar las del intento fallido. */
|
|
13573
|
+
total_publications: number;
|
|
13574
|
+
/** Los créditos de IA que gastó. Uno `failed` también puede haber gastado, y no se devuelven. */
|
|
13575
|
+
credits_spent: number;
|
|
13576
|
+
/** CUÁNTOS avisos dejó, no los avisos: ésos están en `AiPlan.warnings`. Con avisos sigue siendo usable. */
|
|
13577
|
+
warnings: number;
|
|
13578
|
+
/** Sólo en `ai_plan_failed`: el mismo `code` y `message` que `AiPlan.error`. Su `data`, en el plan. */
|
|
13579
|
+
error?: {
|
|
13580
|
+
code: number;
|
|
13581
|
+
message: string;
|
|
13582
|
+
};
|
|
13583
|
+
}
|
|
13462
13584
|
/**
|
|
13463
13585
|
* Un `field` que esta versión del paquete todavía no conoce.
|
|
13464
13586
|
*
|
|
@@ -13477,7 +13599,7 @@ interface UnknownWebhookChange {
|
|
|
13477
13599
|
* `CommentChange | UnknownWebhookChange`. Para estrechar de verdad están los predicados
|
|
13478
13600
|
* {@link isCommentChange} y compañía, que es la forma recomendada.
|
|
13479
13601
|
*/
|
|
13480
|
-
type WebhookChange = AccountStateChange | MessageChange | CommentChange | IntegrationErrorChange | UnknownWebhookChange;
|
|
13602
|
+
type WebhookChange = AccountStateChange | MessageChange | CommentChange | IntegrationErrorChange | AiPlanChange | UnknownWebhookChange;
|
|
13481
13603
|
/** Una cuenta se conectó o cambió de estado. */
|
|
13482
13604
|
declare function isAccountStateChange(change: WebhookChange): change is AccountStateChange;
|
|
13483
13605
|
/** Algo pasó en la mensajería. Incluye el visto y el rechazo de la red, no sólo el mensaje nuevo. */
|
|
@@ -13486,6 +13608,8 @@ declare function isMessageChange(change: WebhookChange): change is MessageChange
|
|
|
13486
13608
|
declare function isCommentChange(change: WebhookChange): change is CommentChange;
|
|
13487
13609
|
/** Una integración dejó de funcionar. */
|
|
13488
13610
|
declare function isIntegrationErrorChange(change: WebhookChange): change is IntegrationErrorChange;
|
|
13611
|
+
/** Un plan de IA terminó, bien o mal. Mira `field` (o `state`) para saber cuál. */
|
|
13612
|
+
declare function isAiPlanChange(change: WebhookChange): change is AiPlanChange;
|
|
13489
13613
|
/**
|
|
13490
13614
|
* La firma no cuadra, o no venía ninguna.
|
|
13491
13615
|
*
|
|
@@ -13628,4 +13752,4 @@ interface PlanVortexWebhooksOptions {
|
|
|
13628
13752
|
*/
|
|
13629
13753
|
declare function planvortexWebhooks(options: PlanVortexWebhooksOptions): (request: WebhookRequestLike, response: WebhookResponseLike, next: (error?: unknown) => void) => void;
|
|
13630
13754
|
|
|
13631
|
-
export { type Organization as $, type Account as A, type CommentThread as B, type ConnectLink as C, type Destination as D, type EnableResult as E, type CommentReplyResult as F, type ContactExtraData as G, type Contact as H, type ContactCreate as I, type ContactUpdate as J, type IntegrationProviderName as K, type IntegrationProvider as L, type MetricName as M, type Integration as N, type IntegrationConnectRequest as O, type Paginated as P, type IntegrationUpdate as Q, type IntegrationPickerConfig as R, type SocialNetwork as S, type TopPublicationsResult as T, type IntegrationCatalogPage as U, type MessageTemplate as V, type Conversation as W, type ConversationTotals as X, type Message as Y, type MessageInput as Z, type Client as _, type ConnectResult as a, type MetricRow as a$, type AiSettings as a0, type ClientWithOrganizations as a1, type AccountSelection as a2, type PlanData as a3, type PlanUseData as a4, type ConnectToken as a5, type AiContext as a6, type SocialCredentialsInput as a7, type Product as a8, type ProductInput as a9, type AiPlanState as aA, type ApiErrorBody as aB, type AspectRatios as aC, AuthError as aD, type ClientPlan as aE, type CommentAuthor as aF, type CommentChange as aG, type ConnectSessionAccount as aH, type ContactChannel as aI, ContactError as aJ, type DashboardAiPlanRef as aK, type DashboardPublicationRef as aL, type DashboardRange as aM, type EngagementBase as aN, FileError as aO, type FileFormat as aP, type FileProperties as aQ, type FileType as aR, type IntegrationCatalogProduct as aS, type IntegrationConfig as aT, IntegrationError as aU, type IntegrationErrorChange as aV, type IntegrationFormField as aW, type MessageChange as aX, type MessageOptions as aY, type MessageType as aZ, MessagingError as a_, type ProductCatalog as aa, type ProductCatalogInput as ab, type PublicationInput as ac, type PublicationState as ad, type PublicationStats as ae, type PublicationStatsHistory as af, type Upload as ag, AccountError as ah, type AccountMetricRow as ai, type AccountStateChange as aj, type AccountWebhookChangeBase as ak, type AccountWithError as al, type AiImageOrigin as am, type AiPlanCostEstimate as an, type AiPlanDestination as ao, AiPlanError as ap, type AiPlanNotice as aq, type AiPlanOptions as ar, type AiPlanOptionsInput as as, type AiPlanResult as at, type AiPlanResultsGroup as au, type AiPlanResultsTemplateGroup as av, type AiPlanSource as aw, type AiPlanSourceImageInput as ax, type AiPlanSourceInput as ay, type AiPlanSourceProduct as az, type ConnectSession as b, type
|
|
13755
|
+
export { type Organization as $, type Account as A, type CommentThread as B, type ConnectLink as C, type Destination as D, type EnableResult as E, type CommentReplyResult as F, type ContactExtraData as G, type Contact as H, type ContactCreate as I, type ContactUpdate as J, type IntegrationProviderName as K, type IntegrationProvider as L, type MetricName as M, type Integration as N, type IntegrationConnectRequest as O, type Paginated as P, type IntegrationUpdate as Q, type IntegrationPickerConfig as R, type SocialNetwork as S, type TopPublicationsResult as T, type IntegrationCatalogPage as U, type MessageTemplate as V, type Conversation as W, type ConversationTotals as X, type Message as Y, type MessageInput as Z, type Client as _, type ConnectResult as a, type MetricRow as a$, type AiSettings as a0, type ClientWithOrganizations as a1, type AccountSelection as a2, type PlanData as a3, type PlanUseData as a4, type ConnectToken as a5, type AiContext as a6, type SocialCredentialsInput as a7, type Product as a8, type ProductInput as a9, type AiPlanState as aA, type ApiErrorBody as aB, type AspectRatios as aC, AuthError as aD, type ClientPlan as aE, type CommentAuthor as aF, type CommentChange as aG, type ConnectSessionAccount as aH, type ContactChannel as aI, ContactError as aJ, type DashboardAiPlanRef as aK, type DashboardPublicationRef as aL, type DashboardRange as aM, type EngagementBase as aN, FileError as aO, type FileFormat as aP, type FileProperties as aQ, type FileType as aR, type IntegrationCatalogProduct as aS, type IntegrationConfig as aT, IntegrationError as aU, type IntegrationErrorChange as aV, type IntegrationFormField as aW, type MessageChange as aX, type MessageOptions as aY, type MessageType as aZ, MessagingError as a_, type ProductCatalog as aa, type ProductCatalogInput as ab, type PublicationInput as ac, type PublicationState as ad, type PublicationStats as ae, type PublicationStatsHistory as af, type Upload as ag, AccountError as ah, type AccountMetricRow as ai, type AccountStateChange as aj, type AccountWebhookChangeBase as ak, type AccountWithError as al, type AiImageOrigin as am, type AiPlanCostEstimate as an, type AiPlanDestination as ao, AiPlanError as ap, type AiPlanNotice as aq, type AiPlanOptions as ar, type AiPlanOptionsInput as as, type AiPlanResult as at, type AiPlanResultsGroup as au, type AiPlanResultsTemplateGroup as av, type AiPlanSource as aw, type AiPlanSourceImageInput as ax, type AiPlanSourceInput as ay, type AiPlanSourceProduct as az, type ConnectSession as b, type WebhookHeaders as b$, NO_ERROR_CODE as b0, type components as b1, type operations as b2, type paths as b3, type webhooks as b4, type OpenEnum as b5, OrganizationError as b6, PLANVORTEX_ERROR_RANGES as b7, PlanLimitError as b8, PlanVortexAuthenticationError as b9, UserError as bA, type WebhookAlgorithm as bB, type WebhookChange as bC, type WebhookEvent as bD, type WithAccount as bE, type WithPublication as bF, type WooCommerceConnectRequest as bG, account as bH, accountId as bI, errorFamilyForCode as bJ, isPlanVortexError as bK, isTokenError as bL, messageContact as bM, messageContactId as bN, messageDirection as bO, messageFileIds as bP, messageFiles as bQ, publication as bR, publicationId as bS, type AiPlanChange as bT, type HandleWebhookRequestOptions as bU, type PlanVortexWebhooksOptions as bV, type RawWebhookBody as bW, type VerifyWebhookSignatureOptions as bX, WEBHOOK_EVENTS as bY, WEBHOOK_SIGNATURE_HEADERS as bZ, WebhookBodyError as b_, PlanVortexConfigError as ba, PlanVortexConnectionError as bb, PlanVortexError as bc, type PlanVortexErrorOptions as bd, type PlanVortexErrorRange as be, type PlannerTemplateField as bf, type PlannerTemplateFieldType as bg, ProductError as bh, type PublicationAiGenerated as bi, type PublicationDestination as bj, PublicationError as bk, type PublicationErrorDetail as bl, type PublicationMetrics as bm, type PublicationPending as bn, type PublicationStatsPoint as bo, type PublicationType as bp, type PublicationsSummary as bq, type RssConfig as br, type SocialAuthorizationMethod as bs, type SocialCredentials as bt, type SocialIdentifier as bu, type SocialIdentifierInput as bv, type SocialLimitsMap as bw, TOKEN_ERROR_CODES as bx, type TopPublication as by, type UnknownWebhookChange as bz, type AccountMetrics as c, type WebhookRequestLike as c0, type WebhookResponseLike as c1, WebhookSignatureError as c2, handleWebhookRequest as c3, isAccountStateChange as c4, isAiPlanChange as c5, isCommentChange as c6, isIntegrationErrorChange as c7, isMessageChange as c8, parseWebhookPayload as c9, planvortexWebhooks as ca, verifyWebhookSignature as cb, type PersistentMenu as d, type Dashboard as e, type DashboardMetricsResult as f, type PublicationsSummaryResult as g, type PublicationsStatsResult as h, type PlanUse as i, type Publication as j, type AiPlanResultsSort as k, type PlannerTemplateName as l, type AiPlanCreateRequest as m, type AiPlanCreateResult as n, type AiPlan as o, type AiPlanResults as p, type ClientApp as q, type ClientAppInput as r, type SocialCapabilities as s, type CommentActions as t, type SocialLimits as u, type PublicationLimits as v, type AspectRatiosByNetwork as w, type PlannerTemplate as x, type CommentNetwork as y, type Comment as z };
|