@zernio/node 0.2.678 → 0.2.679

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/dist/index.d.mts CHANGED
@@ -8439,9 +8439,23 @@ type WebhookPayloadMessage = {
8439
8439
  text: (string) | null;
8440
8440
  attachments: Array<{
8441
8441
  /**
8442
- * Attachment type (image, video, file, sticker, audio)
8442
+ * Attachment type (image, video, file, sticker, audio, share)
8443
8443
  */
8444
8444
  type: string;
8445
+ /**
8446
+ * Instagram and Facebook only, and present only when it differs
8447
+ * from `type`. Meta's own attachment type before Zernio normalized
8448
+ * it: `ig_reel` and `reel` become `video`, while `ig_post`, `post`,
8449
+ * `ig_story` and `story_mention` all become `share`.
8450
+ *
8451
+ * Read it before rendering, because `type: "share"` alone is
8452
+ * ambiguous. In particular a story mention arrives as
8453
+ * `type: "share"` with `originalType: "story_mention"`; treating an
8454
+ * unrecognized type as a generic document shows your agent
8455
+ * "document received" for what is usually a lead.
8456
+ *
8457
+ */
8458
+ originalType?: string;
8445
8459
  /**
8446
8460
  * Where to fetch the attachment. **The contract differs by platform.**
8447
8461
  *
@@ -8456,6 +8470,18 @@ type WebhookPayloadMessage = {
8456
8470
  * that needs no authentication and expires on the platform's own
8457
8471
  * schedule.
8458
8472
  *
8473
+ * **Webhook attachments carry no `refreshUrl`.** That field is
8474
+ * stamped only when you read a message back over REST
8475
+ * (`GET /v1/inbox/conversations/{conversationId}/messages`). On
8476
+ * Instagram and Facebook the url above is a signed Meta CDN link
8477
+ * that expires, so do not persist it: store the message id and
8478
+ * resolve the media through
8479
+ * `GET /v1/inbox/conversations/{conversationId}/messages/{messageId}/attachments/{index}?accountId={accountId}`,
8480
+ * which re-mints it on demand. Every value that URL needs is
8481
+ * already in this payload: `message.conversationId`,
8482
+ * `message.platformMessageId`, `account.accountId`, and the
8483
+ * attachment's zero-based position in this array.
8484
+ *
8459
8485
  */
8460
8486
  url: string;
8461
8487
  /**
@@ -9013,9 +9039,13 @@ type WebhookPayloadMessageSent = {
9013
9039
  text: (string) | null;
9014
9040
  attachments: Array<{
9015
9041
  /**
9016
- * Attachment type (image, video, file, sticker, audio)
9042
+ * Attachment type (image, video, file, sticker, audio, share)
9017
9043
  */
9018
9044
  type: string;
9045
+ /**
9046
+ * Instagram and Facebook only, and present only when it differs from `type`. Meta's own attachment type before Zernio normalized it. See the same field on message.received for the full mapping.
9047
+ */
9048
+ originalType?: string;
9019
9049
  /**
9020
9050
  * Where to fetch the attachment. For outgoing messages this is the
9021
9051
  * media URL as sent, so for WhatsApp it is the URL you supplied when
@@ -9024,6 +9054,11 @@ type WebhookPayloadMessageSent = {
9024
9054
  * `message.received` attachment URLs on WhatsApp point at the
9025
9055
  * authenticated `GET /v1/whatsapp/media/{mediaId}`.
9026
9056
  *
9057
+ * As on `message.received`, webhook attachments carry no
9058
+ * `refreshUrl`: that field is stamped only on the REST read. Resolve
9059
+ * Instagram and Facebook media through
9060
+ * `GET /v1/inbox/conversations/{conversationId}/messages/{messageId}/attachments/{index}?accountId={accountId}`.
9061
+ *
9027
9062
  */
9028
9063
  url: string;
9029
9064
  /**
@@ -9033,14 +9068,37 @@ type WebhookPayloadMessageSent = {
9033
9068
  [key: string]: unknown;
9034
9069
  };
9035
9070
  }>;
9071
+ /**
9072
+ * **On this event the sender is your own business, not the person you
9073
+ * are talking to.** `id` is the Zernio account id and `name`,
9074
+ * `username` and `picture` are that connected account's own profile.
9075
+ *
9076
+ * Do not read these to name or update a contact: doing so on an echo
9077
+ * relabels the customer's record with your business name. The other
9078
+ * party is `conversation.participantId` / `participantName` /
9079
+ * `participantUsername`, which are populated in both directions.
9080
+ *
9081
+ */
9036
9082
  sender: {
9083
+ /**
9084
+ * The Zernio account id of the connected account that sent the message, not a contact id.
9085
+ */
9037
9086
  id: string;
9038
9087
  /**
9039
9088
  * Always omitted on this event: the sender is the business, not a contact. Use conversation.contactId to join back to the CRM Contact.
9040
9089
  */
9041
9090
  contactId?: string;
9091
+ /**
9092
+ * Display name of your connected account.
9093
+ */
9042
9094
  name?: string;
9095
+ /**
9096
+ * Username of your connected account.
9097
+ */
9043
9098
  username?: string;
9099
+ /**
9100
+ * Profile picture of your connected account.
9101
+ */
9044
9102
  picture?: string;
9045
9103
  };
9046
9104
  /**
@@ -13440,6 +13498,60 @@ type GetConnectUrlData = {
13440
13498
  profileId: string;
13441
13499
  /**
13442
13500
  * Your custom redirect URL after connection completes. Accepts an http(s) URL, a custom app scheme for mobile deeplinks (e.g. myapp://callback), or a relative path. Result params are appended with the URL API, so an existing query string is preserved. Standard mode appends connected={platform}&profileId=X&accountId=Y&username=Z. Headless mode appends OAuth data params for platforms requiring selection (e.g. LinkedIn orgs, Facebook pages). If no selection is needed, the account is created directly and the redirect includes accountId.
13501
+ *
13502
+ * On failure, the browser is sent to the same redirect_url with `error` and `platform` appended.
13503
+ * `error` and `platform` are always present. `error_message`, `is_user_fixable`, `reason` and
13504
+ * `dashboard_url` are conditional and must be treated as optional.
13505
+ *
13506
+ * This list is NOT exhaustive and new values may be added at any time. Treat an unrecognized
13507
+ * value as a generic failure rather than matching it exhaustively. Existing values are not
13508
+ * renamed or removed without notice.
13509
+ *
13510
+ * OAuth and callback:
13511
+ * oauth_denied, invalid_callback, invalid_state, unsupported_platform, connection_failed,
13512
+ * internal_error, token_exchange_failed, byok_config_error, personal_account_not_supported,
13513
+ * missing_google_permissions, platform_requires_destination, reconnect_account_mismatch,
13514
+ * invalid_request
13515
+ *
13516
+ * Access and limits:
13517
+ * profile_not_found, invalid_profile_id, access_denied, account_limit_exceeded,
13518
+ * profile_limit_exceeded, payment_required
13519
+ *
13520
+ * Destination selection:
13521
+ * no_facebook_pages, facebook_pages_error, no_google_locations, google_locations_error,
13522
+ * google_permission_denied, no_snapchat_public_profiles, snapchat_profiles_error,
13523
+ * discord_no_guild, slack_no_team
13524
+ *
13525
+ * WhatsApp:
13526
+ * whatsapp_error, one_whatsapp_per_profile, whatsapp_number_already_connected,
13527
+ * whatsapp_number_pinned_to_profile, connection_cancelled
13528
+ *
13529
+ * Google Ads (platform=googleads):
13530
+ * google_ads_auth_failed, google_ads_invalid_state, google_ads_config_error,
13531
+ * google_ads_token_failed, google_ads_quota_exhausted, google_ads_callback_error
13532
+ *
13533
+ * TikTok Ads (platform=tiktokads):
13534
+ * tiktok_ads_auth_failed, tiktok_ads_invalid_state, tiktok_ads_access_denied,
13535
+ * tiktok_ads_config_error, tiktok_ads_token_failed, tiktok_ads_account_not_found,
13536
+ * tiktok_ads_callback_error
13537
+ *
13538
+ * X Ads (platform=xads):
13539
+ * x_ads_denied, x_ads_auth_failed, x_ads_config_error, x_ads_account_not_found,
13540
+ * x_ads_state_error, x_ads_token_failed, x_ads_token_missing, x_ads_callback_error
13541
+ *
13542
+ * Shopify (platform=shopify):
13543
+ * shopify_auth_failed, shopify_config_error, shopify_invalid_state, shopify_invalid_hmac,
13544
+ * shopify_invalid_shop, shopify_missing_scopes, shopify_callback_error
13545
+ *
13546
+ * 1. On this endpoint every upstream OAuth error is collapsed into `oauth_denied`. The
13547
+ * provider's own value (for example Meta's `access_denied`) is not forwarded. The dedicated
13548
+ * ads flows below are different: they use their own denial slugs and `google_ads_auth_failed`
13549
+ * and `tiktok_ads_auth_failed` may carry the provider's raw error string in `error_message`.
13550
+ *
13551
+ * 2. On the tiktok and twitter ads flows `platform` carries the ads platform id
13552
+ * (`tiktokads`, `xads`), not the value used in the request path. The googleads and shopify
13553
+ * flows report `googleads` and `shopify`.
13554
+ *
13443
13555
  */
13444
13556
  redirect_url?: string;
13445
13557
  };
@@ -13580,6 +13692,11 @@ type ConnectAdsData = {
13580
13692
  path: {
13581
13693
  /**
13582
13694
  * Platform to connect ads for. Only platforms with ads support are accepted.
13695
+ *
13696
+ * `instagram` requires an Instagram account connected with loginMethod=facebook_login whose
13697
+ * token carries ads_management and ads_read. With an account connected through the default
13698
+ * instagram_login flow no ads account can be created; do not use this value for those accounts.
13699
+ *
13583
13700
  */
13584
13701
  platform: 'facebook' | 'instagram' | 'linkedin' | 'tiktok' | 'twitter' | 'pinterest' | 'googleads';
13585
13702
  };
@@ -13643,8 +13760,12 @@ type ConnectAdsData = {
13643
13760
  * `tiktok`, `twitter` and `googleads` land on the URL unchanged, while the
13644
13761
  * same-token platforms (`facebook`, `instagram`, `linkedin`, `pinterest`)
13645
13762
  * append `connected`, `profileId`, `accountId`, `username` and, on API-key
13646
- * calls, `connect_token`. On failure every platform appends error details,
13647
- * starting with `error` and `platform`. When omitted, the browser lands on
13763
+ * calls, `connect_token`. On failure the same error contract applies as on
13764
+ * GET /v1/connect/{platform}: `error` and `platform` are always appended,
13765
+ * other params are optional, and the value list there is not exhaustive.
13766
+ * Note that on the tiktok, twitter and googleads flows `platform` carries
13767
+ * the ads platform id (`tiktokads`, `xads`, `googleads`), not the value
13768
+ * used in the request path. When omitted, the browser lands on
13648
13769
  * the Zernio dashboard.
13649
13770
  *
13650
13771
  */
@@ -19320,6 +19441,10 @@ type GetInboxConversationMessagesResponse = ({
19320
19441
  attachments?: Array<{
19321
19442
  id?: string;
19322
19443
  type?: 'image' | 'video' | 'audio' | 'file' | 'sticker' | 'share';
19444
+ /**
19445
+ * Instagram and Facebook only, and present only when it differs from `type`. Meta's own type before normalization: `ig_reel` and `reel` become `video`, while `ig_post`, `post`, `ig_story` and `story_mention` become `share`. A story mention is `type: "share"` with `originalType: "story_mention"`; render on this field, since `share` alone is ambiguous.
19446
+ */
19447
+ originalType?: string;
19323
19448
  /**
19324
19449
  * Direct media link. On Instagram and Facebook this is a signed Meta CDN url that EXPIRES: use it now, do not store it. Persist `refreshUrl` instead.
19325
19450
  */
@@ -20460,7 +20585,7 @@ type GetMessageAttachmentData = {
20460
20585
  };
20461
20586
  query: {
20462
20587
  /**
20463
- * Social account ID
20588
+ * Social account ID. Required: without it the request returns 400 missing_required_field.
20464
20589
  */
20465
20590
  accountId: string;
20466
20591
  /**
package/dist/index.d.ts CHANGED
@@ -8439,9 +8439,23 @@ type WebhookPayloadMessage = {
8439
8439
  text: (string) | null;
8440
8440
  attachments: Array<{
8441
8441
  /**
8442
- * Attachment type (image, video, file, sticker, audio)
8442
+ * Attachment type (image, video, file, sticker, audio, share)
8443
8443
  */
8444
8444
  type: string;
8445
+ /**
8446
+ * Instagram and Facebook only, and present only when it differs
8447
+ * from `type`. Meta's own attachment type before Zernio normalized
8448
+ * it: `ig_reel` and `reel` become `video`, while `ig_post`, `post`,
8449
+ * `ig_story` and `story_mention` all become `share`.
8450
+ *
8451
+ * Read it before rendering, because `type: "share"` alone is
8452
+ * ambiguous. In particular a story mention arrives as
8453
+ * `type: "share"` with `originalType: "story_mention"`; treating an
8454
+ * unrecognized type as a generic document shows your agent
8455
+ * "document received" for what is usually a lead.
8456
+ *
8457
+ */
8458
+ originalType?: string;
8445
8459
  /**
8446
8460
  * Where to fetch the attachment. **The contract differs by platform.**
8447
8461
  *
@@ -8456,6 +8470,18 @@ type WebhookPayloadMessage = {
8456
8470
  * that needs no authentication and expires on the platform's own
8457
8471
  * schedule.
8458
8472
  *
8473
+ * **Webhook attachments carry no `refreshUrl`.** That field is
8474
+ * stamped only when you read a message back over REST
8475
+ * (`GET /v1/inbox/conversations/{conversationId}/messages`). On
8476
+ * Instagram and Facebook the url above is a signed Meta CDN link
8477
+ * that expires, so do not persist it: store the message id and
8478
+ * resolve the media through
8479
+ * `GET /v1/inbox/conversations/{conversationId}/messages/{messageId}/attachments/{index}?accountId={accountId}`,
8480
+ * which re-mints it on demand. Every value that URL needs is
8481
+ * already in this payload: `message.conversationId`,
8482
+ * `message.platformMessageId`, `account.accountId`, and the
8483
+ * attachment's zero-based position in this array.
8484
+ *
8459
8485
  */
8460
8486
  url: string;
8461
8487
  /**
@@ -9013,9 +9039,13 @@ type WebhookPayloadMessageSent = {
9013
9039
  text: (string) | null;
9014
9040
  attachments: Array<{
9015
9041
  /**
9016
- * Attachment type (image, video, file, sticker, audio)
9042
+ * Attachment type (image, video, file, sticker, audio, share)
9017
9043
  */
9018
9044
  type: string;
9045
+ /**
9046
+ * Instagram and Facebook only, and present only when it differs from `type`. Meta's own attachment type before Zernio normalized it. See the same field on message.received for the full mapping.
9047
+ */
9048
+ originalType?: string;
9019
9049
  /**
9020
9050
  * Where to fetch the attachment. For outgoing messages this is the
9021
9051
  * media URL as sent, so for WhatsApp it is the URL you supplied when
@@ -9024,6 +9054,11 @@ type WebhookPayloadMessageSent = {
9024
9054
  * `message.received` attachment URLs on WhatsApp point at the
9025
9055
  * authenticated `GET /v1/whatsapp/media/{mediaId}`.
9026
9056
  *
9057
+ * As on `message.received`, webhook attachments carry no
9058
+ * `refreshUrl`: that field is stamped only on the REST read. Resolve
9059
+ * Instagram and Facebook media through
9060
+ * `GET /v1/inbox/conversations/{conversationId}/messages/{messageId}/attachments/{index}?accountId={accountId}`.
9061
+ *
9027
9062
  */
9028
9063
  url: string;
9029
9064
  /**
@@ -9033,14 +9068,37 @@ type WebhookPayloadMessageSent = {
9033
9068
  [key: string]: unknown;
9034
9069
  };
9035
9070
  }>;
9071
+ /**
9072
+ * **On this event the sender is your own business, not the person you
9073
+ * are talking to.** `id` is the Zernio account id and `name`,
9074
+ * `username` and `picture` are that connected account's own profile.
9075
+ *
9076
+ * Do not read these to name or update a contact: doing so on an echo
9077
+ * relabels the customer's record with your business name. The other
9078
+ * party is `conversation.participantId` / `participantName` /
9079
+ * `participantUsername`, which are populated in both directions.
9080
+ *
9081
+ */
9036
9082
  sender: {
9083
+ /**
9084
+ * The Zernio account id of the connected account that sent the message, not a contact id.
9085
+ */
9037
9086
  id: string;
9038
9087
  /**
9039
9088
  * Always omitted on this event: the sender is the business, not a contact. Use conversation.contactId to join back to the CRM Contact.
9040
9089
  */
9041
9090
  contactId?: string;
9091
+ /**
9092
+ * Display name of your connected account.
9093
+ */
9042
9094
  name?: string;
9095
+ /**
9096
+ * Username of your connected account.
9097
+ */
9043
9098
  username?: string;
9099
+ /**
9100
+ * Profile picture of your connected account.
9101
+ */
9044
9102
  picture?: string;
9045
9103
  };
9046
9104
  /**
@@ -13440,6 +13498,60 @@ type GetConnectUrlData = {
13440
13498
  profileId: string;
13441
13499
  /**
13442
13500
  * Your custom redirect URL after connection completes. Accepts an http(s) URL, a custom app scheme for mobile deeplinks (e.g. myapp://callback), or a relative path. Result params are appended with the URL API, so an existing query string is preserved. Standard mode appends connected={platform}&profileId=X&accountId=Y&username=Z. Headless mode appends OAuth data params for platforms requiring selection (e.g. LinkedIn orgs, Facebook pages). If no selection is needed, the account is created directly and the redirect includes accountId.
13501
+ *
13502
+ * On failure, the browser is sent to the same redirect_url with `error` and `platform` appended.
13503
+ * `error` and `platform` are always present. `error_message`, `is_user_fixable`, `reason` and
13504
+ * `dashboard_url` are conditional and must be treated as optional.
13505
+ *
13506
+ * This list is NOT exhaustive and new values may be added at any time. Treat an unrecognized
13507
+ * value as a generic failure rather than matching it exhaustively. Existing values are not
13508
+ * renamed or removed without notice.
13509
+ *
13510
+ * OAuth and callback:
13511
+ * oauth_denied, invalid_callback, invalid_state, unsupported_platform, connection_failed,
13512
+ * internal_error, token_exchange_failed, byok_config_error, personal_account_not_supported,
13513
+ * missing_google_permissions, platform_requires_destination, reconnect_account_mismatch,
13514
+ * invalid_request
13515
+ *
13516
+ * Access and limits:
13517
+ * profile_not_found, invalid_profile_id, access_denied, account_limit_exceeded,
13518
+ * profile_limit_exceeded, payment_required
13519
+ *
13520
+ * Destination selection:
13521
+ * no_facebook_pages, facebook_pages_error, no_google_locations, google_locations_error,
13522
+ * google_permission_denied, no_snapchat_public_profiles, snapchat_profiles_error,
13523
+ * discord_no_guild, slack_no_team
13524
+ *
13525
+ * WhatsApp:
13526
+ * whatsapp_error, one_whatsapp_per_profile, whatsapp_number_already_connected,
13527
+ * whatsapp_number_pinned_to_profile, connection_cancelled
13528
+ *
13529
+ * Google Ads (platform=googleads):
13530
+ * google_ads_auth_failed, google_ads_invalid_state, google_ads_config_error,
13531
+ * google_ads_token_failed, google_ads_quota_exhausted, google_ads_callback_error
13532
+ *
13533
+ * TikTok Ads (platform=tiktokads):
13534
+ * tiktok_ads_auth_failed, tiktok_ads_invalid_state, tiktok_ads_access_denied,
13535
+ * tiktok_ads_config_error, tiktok_ads_token_failed, tiktok_ads_account_not_found,
13536
+ * tiktok_ads_callback_error
13537
+ *
13538
+ * X Ads (platform=xads):
13539
+ * x_ads_denied, x_ads_auth_failed, x_ads_config_error, x_ads_account_not_found,
13540
+ * x_ads_state_error, x_ads_token_failed, x_ads_token_missing, x_ads_callback_error
13541
+ *
13542
+ * Shopify (platform=shopify):
13543
+ * shopify_auth_failed, shopify_config_error, shopify_invalid_state, shopify_invalid_hmac,
13544
+ * shopify_invalid_shop, shopify_missing_scopes, shopify_callback_error
13545
+ *
13546
+ * 1. On this endpoint every upstream OAuth error is collapsed into `oauth_denied`. The
13547
+ * provider's own value (for example Meta's `access_denied`) is not forwarded. The dedicated
13548
+ * ads flows below are different: they use their own denial slugs and `google_ads_auth_failed`
13549
+ * and `tiktok_ads_auth_failed` may carry the provider's raw error string in `error_message`.
13550
+ *
13551
+ * 2. On the tiktok and twitter ads flows `platform` carries the ads platform id
13552
+ * (`tiktokads`, `xads`), not the value used in the request path. The googleads and shopify
13553
+ * flows report `googleads` and `shopify`.
13554
+ *
13443
13555
  */
13444
13556
  redirect_url?: string;
13445
13557
  };
@@ -13580,6 +13692,11 @@ type ConnectAdsData = {
13580
13692
  path: {
13581
13693
  /**
13582
13694
  * Platform to connect ads for. Only platforms with ads support are accepted.
13695
+ *
13696
+ * `instagram` requires an Instagram account connected with loginMethod=facebook_login whose
13697
+ * token carries ads_management and ads_read. With an account connected through the default
13698
+ * instagram_login flow no ads account can be created; do not use this value for those accounts.
13699
+ *
13583
13700
  */
13584
13701
  platform: 'facebook' | 'instagram' | 'linkedin' | 'tiktok' | 'twitter' | 'pinterest' | 'googleads';
13585
13702
  };
@@ -13643,8 +13760,12 @@ type ConnectAdsData = {
13643
13760
  * `tiktok`, `twitter` and `googleads` land on the URL unchanged, while the
13644
13761
  * same-token platforms (`facebook`, `instagram`, `linkedin`, `pinterest`)
13645
13762
  * append `connected`, `profileId`, `accountId`, `username` and, on API-key
13646
- * calls, `connect_token`. On failure every platform appends error details,
13647
- * starting with `error` and `platform`. When omitted, the browser lands on
13763
+ * calls, `connect_token`. On failure the same error contract applies as on
13764
+ * GET /v1/connect/{platform}: `error` and `platform` are always appended,
13765
+ * other params are optional, and the value list there is not exhaustive.
13766
+ * Note that on the tiktok, twitter and googleads flows `platform` carries
13767
+ * the ads platform id (`tiktokads`, `xads`, `googleads`), not the value
13768
+ * used in the request path. When omitted, the browser lands on
13648
13769
  * the Zernio dashboard.
13649
13770
  *
13650
13771
  */
@@ -19320,6 +19441,10 @@ type GetInboxConversationMessagesResponse = ({
19320
19441
  attachments?: Array<{
19321
19442
  id?: string;
19322
19443
  type?: 'image' | 'video' | 'audio' | 'file' | 'sticker' | 'share';
19444
+ /**
19445
+ * Instagram and Facebook only, and present only when it differs from `type`. Meta's own type before normalization: `ig_reel` and `reel` become `video`, while `ig_post`, `post`, `ig_story` and `story_mention` become `share`. A story mention is `type: "share"` with `originalType: "story_mention"`; render on this field, since `share` alone is ambiguous.
19446
+ */
19447
+ originalType?: string;
19323
19448
  /**
19324
19449
  * Direct media link. On Instagram and Facebook this is a signed Meta CDN url that EXPIRES: use it now, do not store it. Persist `refreshUrl` instead.
19325
19450
  */
@@ -20460,7 +20585,7 @@ type GetMessageAttachmentData = {
20460
20585
  };
20461
20586
  query: {
20462
20587
  /**
20463
- * Social account ID
20588
+ * Social account ID. Required: without it the request returns 400 missing_required_field.
20464
20589
  */
20465
20590
  accountId: string;
20466
20591
  /**
package/dist/index.js CHANGED
@@ -36,7 +36,7 @@ module.exports = __toCommonJS(index_exports);
36
36
  // package.json
37
37
  var package_default = {
38
38
  name: "@zernio/node",
39
- version: "0.2.678",
39
+ version: "0.2.679",
40
40
  description: "The official Node.js library for the Zernio API",
41
41
  main: "dist/index.js",
42
42
  module: "dist/index.mjs",
package/dist/index.mjs CHANGED
@@ -5,7 +5,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
5
5
  // package.json
6
6
  var package_default = {
7
7
  name: "@zernio/node",
8
- version: "0.2.678",
8
+ version: "0.2.679",
9
9
  description: "The official Node.js library for the Zernio API",
10
10
  main: "dist/index.js",
11
11
  module: "dist/index.mjs",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zernio/node",
3
- "version": "0.2.678",
3
+ "version": "0.2.679",
4
4
  "description": "The official Node.js library for the Zernio API",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -1467,7 +1467,24 @@ export const handleOAuthCallback = <ThrowOnError extends boolean = false>(option
1467
1467
  * Connect ads for a platform
1468
1468
  * Unified ads connection endpoint. Creates a dedicated ads SocialAccount for the specified platform.
1469
1469
  *
1470
- * Same-token platforms (facebook, instagram, linkedin, pinterest): Creates an ads SocialAccount (metaads, linkedinads, pinterestads) with a copied OAuth token from the parent posting account. If the ads account already exists, returns alreadyConnected: true. No extra OAuth needed.
1470
+ * Same-token platforms (facebook, instagram, linkedin, pinterest): the ads SocialAccount
1471
+ * (metaads, linkedinads, pinterestads) reuses the OAuth token of the parent posting account,
1472
+ * but only when an active parent exists and, for facebook and instagram, its stored token
1473
+ * carries ads_management and ads_read (linkedin and pinterest need no extra scope). In that
1474
+ * case no extra OAuth happens and the response is alreadyConnected: true. When no such parent
1475
+ * exists, or the scopes are missing, the endpoint returns an authUrl and a full OAuth round
1476
+ * trip is required. When a parent exists but carries no token usable for ad accounts, the call
1477
+ * fails with 400 RECONNECT_REQUIRED. Independently of the branch, the call can return 403
1478
+ * ADS_ADDON_REQUIRED without the ads add-on and 402 PAYMENT_REQUIRED when the billing gate is
1479
+ * closed.
1480
+ *
1481
+ * Meta Ads prerequisite: connecting Meta Ads (via facebook or instagram) requires a Facebook
1482
+ * Page. Not because the ad account is read through a Page, but because both parent posting
1483
+ * accounts are: the facebook flow only offers Pages you manage, and the instagram flow with
1484
+ * loginMethod=facebook_login only offers Instagram accounts linked to one of those Pages.
1485
+ * Without a Page there is no parent account to inherit a token from. A user who manages no
1486
+ * Facebook Page cannot complete this connection, and the facebook flow ends with
1487
+ * error=no_facebook_pages.
1471
1488
  *
1472
1489
  * Separate-token platforms (tiktok, twitter): Starts the platform-specific marketing API OAuth flow and creates an ads SocialAccount (tiktokads, xads) with its own token. If the ads account already exists, returns alreadyConnected: true.
1473
1490
  * - tiktok: accountId is OPTIONAL. With accountId, the new tiktokads account links to that posting account (parentAccountId set) — Spark Ads + standalone ads using the posting TT_USER identity become available. Without accountId, ads-only mode kicks in: the new tiktokads account has parentAccountId=null and standalone ads use a synthetic CUSTOMIZED_USER ("Brand Identity"); Spark Ads are unavailable because TikTok requires a posting account for them. The Brand Identity is configured separately via PATCH /v1/connect/tiktok-ads (or inline on POST /v1/ads/create via the brandIdentity field).
@@ -3769,7 +3786,16 @@ export const deleteTelegramCommands = <ThrowOnError extends boolean = false>(opt
3769
3786
  * and stops working later. This endpoint checks the stored url and, when it
3770
3787
  * has gone stale, re-mints the message's media from Meta and persists it
3771
3788
  * before answering. The message id never expires, so this URL is the one to
3772
- * store — it is returned on each attachment as `refreshUrl`.
3789
+ * store. It is returned ready-made on each attachment as `refreshUrl` when
3790
+ * you read a message over REST.
3791
+ *
3792
+ * **Webhook payloads do not carry `refreshUrl`**, so a webhook-driven
3793
+ * integration builds this URL itself. Every piece is in the event:
3794
+ * `message.conversationId`, `message.platformMessageId`, the attachment's
3795
+ * zero-based position, and `account.accountId`. Note that **`accountId` is a
3796
+ * required query parameter**; omitting it returns `400`
3797
+ * `missing_required_field`, which is the same requirement
3798
+ * `GET /v1/whatsapp/media/{mediaId}` has.
3773
3799
  *
3774
3800
  * By default it responds `302` to the live media url, so it can be used
3775
3801
  * directly as an `<img src>` on a browser session. API-key integrators
@@ -7378,9 +7378,23 @@ export type WebhookPayloadMessage = {
7378
7378
  text: (string) | null;
7379
7379
  attachments: Array<{
7380
7380
  /**
7381
- * Attachment type (image, video, file, sticker, audio)
7381
+ * Attachment type (image, video, file, sticker, audio, share)
7382
7382
  */
7383
7383
  type: string;
7384
+ /**
7385
+ * Instagram and Facebook only, and present only when it differs
7386
+ * from `type`. Meta's own attachment type before Zernio normalized
7387
+ * it: `ig_reel` and `reel` become `video`, while `ig_post`, `post`,
7388
+ * `ig_story` and `story_mention` all become `share`.
7389
+ *
7390
+ * Read it before rendering, because `type: "share"` alone is
7391
+ * ambiguous. In particular a story mention arrives as
7392
+ * `type: "share"` with `originalType: "story_mention"`; treating an
7393
+ * unrecognized type as a generic document shows your agent
7394
+ * "document received" for what is usually a lead.
7395
+ *
7396
+ */
7397
+ originalType?: string;
7384
7398
  /**
7385
7399
  * Where to fetch the attachment. **The contract differs by platform.**
7386
7400
  *
@@ -7395,6 +7409,18 @@ export type WebhookPayloadMessage = {
7395
7409
  * that needs no authentication and expires on the platform's own
7396
7410
  * schedule.
7397
7411
  *
7412
+ * **Webhook attachments carry no `refreshUrl`.** That field is
7413
+ * stamped only when you read a message back over REST
7414
+ * (`GET /v1/inbox/conversations/{conversationId}/messages`). On
7415
+ * Instagram and Facebook the url above is a signed Meta CDN link
7416
+ * that expires, so do not persist it: store the message id and
7417
+ * resolve the media through
7418
+ * `GET /v1/inbox/conversations/{conversationId}/messages/{messageId}/attachments/{index}?accountId={accountId}`,
7419
+ * which re-mints it on demand. Every value that URL needs is
7420
+ * already in this payload: `message.conversationId`,
7421
+ * `message.platformMessageId`, `account.accountId`, and the
7422
+ * attachment's zero-based position in this array.
7423
+ *
7398
7424
  */
7399
7425
  url: string;
7400
7426
  /**
@@ -7963,9 +7989,13 @@ export type WebhookPayloadMessageSent = {
7963
7989
  text: (string) | null;
7964
7990
  attachments: Array<{
7965
7991
  /**
7966
- * Attachment type (image, video, file, sticker, audio)
7992
+ * Attachment type (image, video, file, sticker, audio, share)
7967
7993
  */
7968
7994
  type: string;
7995
+ /**
7996
+ * Instagram and Facebook only, and present only when it differs from `type`. Meta's own attachment type before Zernio normalized it. See the same field on message.received for the full mapping.
7997
+ */
7998
+ originalType?: string;
7969
7999
  /**
7970
8000
  * Where to fetch the attachment. For outgoing messages this is the
7971
8001
  * media URL as sent, so for WhatsApp it is the URL you supplied when
@@ -7974,6 +8004,11 @@ export type WebhookPayloadMessageSent = {
7974
8004
  * `message.received` attachment URLs on WhatsApp point at the
7975
8005
  * authenticated `GET /v1/whatsapp/media/{mediaId}`.
7976
8006
  *
8007
+ * As on `message.received`, webhook attachments carry no
8008
+ * `refreshUrl`: that field is stamped only on the REST read. Resolve
8009
+ * Instagram and Facebook media through
8010
+ * `GET /v1/inbox/conversations/{conversationId}/messages/{messageId}/attachments/{index}?accountId={accountId}`.
8011
+ *
7977
8012
  */
7978
8013
  url: string;
7979
8014
  /**
@@ -7983,14 +8018,37 @@ export type WebhookPayloadMessageSent = {
7983
8018
  [key: string]: unknown;
7984
8019
  };
7985
8020
  }>;
8021
+ /**
8022
+ * **On this event the sender is your own business, not the person you
8023
+ * are talking to.** `id` is the Zernio account id and `name`,
8024
+ * `username` and `picture` are that connected account's own profile.
8025
+ *
8026
+ * Do not read these to name or update a contact: doing so on an echo
8027
+ * relabels the customer's record with your business name. The other
8028
+ * party is `conversation.participantId` / `participantName` /
8029
+ * `participantUsername`, which are populated in both directions.
8030
+ *
8031
+ */
7986
8032
  sender: {
8033
+ /**
8034
+ * The Zernio account id of the connected account that sent the message, not a contact id.
8035
+ */
7987
8036
  id: string;
7988
8037
  /**
7989
8038
  * Always omitted on this event: the sender is the business, not a contact. Use conversation.contactId to join back to the CRM Contact.
7990
8039
  */
7991
8040
  contactId?: string;
8041
+ /**
8042
+ * Display name of your connected account.
8043
+ */
7992
8044
  name?: string;
8045
+ /**
8046
+ * Username of your connected account.
8047
+ */
7993
8048
  username?: string;
8049
+ /**
8050
+ * Profile picture of your connected account.
8051
+ */
7994
8052
  picture?: string;
7995
8053
  };
7996
8054
  /**
@@ -12695,6 +12753,60 @@ export type GetConnectUrlData = {
12695
12753
  profileId: string;
12696
12754
  /**
12697
12755
  * Your custom redirect URL after connection completes. Accepts an http(s) URL, a custom app scheme for mobile deeplinks (e.g. myapp://callback), or a relative path. Result params are appended with the URL API, so an existing query string is preserved. Standard mode appends connected={platform}&profileId=X&accountId=Y&username=Z. Headless mode appends OAuth data params for platforms requiring selection (e.g. LinkedIn orgs, Facebook pages). If no selection is needed, the account is created directly and the redirect includes accountId.
12756
+ *
12757
+ * On failure, the browser is sent to the same redirect_url with `error` and `platform` appended.
12758
+ * `error` and `platform` are always present. `error_message`, `is_user_fixable`, `reason` and
12759
+ * `dashboard_url` are conditional and must be treated as optional.
12760
+ *
12761
+ * This list is NOT exhaustive and new values may be added at any time. Treat an unrecognized
12762
+ * value as a generic failure rather than matching it exhaustively. Existing values are not
12763
+ * renamed or removed without notice.
12764
+ *
12765
+ * OAuth and callback:
12766
+ * oauth_denied, invalid_callback, invalid_state, unsupported_platform, connection_failed,
12767
+ * internal_error, token_exchange_failed, byok_config_error, personal_account_not_supported,
12768
+ * missing_google_permissions, platform_requires_destination, reconnect_account_mismatch,
12769
+ * invalid_request
12770
+ *
12771
+ * Access and limits:
12772
+ * profile_not_found, invalid_profile_id, access_denied, account_limit_exceeded,
12773
+ * profile_limit_exceeded, payment_required
12774
+ *
12775
+ * Destination selection:
12776
+ * no_facebook_pages, facebook_pages_error, no_google_locations, google_locations_error,
12777
+ * google_permission_denied, no_snapchat_public_profiles, snapchat_profiles_error,
12778
+ * discord_no_guild, slack_no_team
12779
+ *
12780
+ * WhatsApp:
12781
+ * whatsapp_error, one_whatsapp_per_profile, whatsapp_number_already_connected,
12782
+ * whatsapp_number_pinned_to_profile, connection_cancelled
12783
+ *
12784
+ * Google Ads (platform=googleads):
12785
+ * google_ads_auth_failed, google_ads_invalid_state, google_ads_config_error,
12786
+ * google_ads_token_failed, google_ads_quota_exhausted, google_ads_callback_error
12787
+ *
12788
+ * TikTok Ads (platform=tiktokads):
12789
+ * tiktok_ads_auth_failed, tiktok_ads_invalid_state, tiktok_ads_access_denied,
12790
+ * tiktok_ads_config_error, tiktok_ads_token_failed, tiktok_ads_account_not_found,
12791
+ * tiktok_ads_callback_error
12792
+ *
12793
+ * X Ads (platform=xads):
12794
+ * x_ads_denied, x_ads_auth_failed, x_ads_config_error, x_ads_account_not_found,
12795
+ * x_ads_state_error, x_ads_token_failed, x_ads_token_missing, x_ads_callback_error
12796
+ *
12797
+ * Shopify (platform=shopify):
12798
+ * shopify_auth_failed, shopify_config_error, shopify_invalid_state, shopify_invalid_hmac,
12799
+ * shopify_invalid_shop, shopify_missing_scopes, shopify_callback_error
12800
+ *
12801
+ * 1. On this endpoint every upstream OAuth error is collapsed into `oauth_denied`. The
12802
+ * provider's own value (for example Meta's `access_denied`) is not forwarded. The dedicated
12803
+ * ads flows below are different: they use their own denial slugs and `google_ads_auth_failed`
12804
+ * and `tiktok_ads_auth_failed` may carry the provider's raw error string in `error_message`.
12805
+ *
12806
+ * 2. On the tiktok and twitter ads flows `platform` carries the ads platform id
12807
+ * (`tiktokads`, `xads`), not the value used in the request path. The googleads and shopify
12808
+ * flows report `googleads` and `shopify`.
12809
+ *
12698
12810
  */
12699
12811
  redirect_url?: string;
12700
12812
  };
@@ -12841,6 +12953,11 @@ export type ConnectAdsData = {
12841
12953
  path: {
12842
12954
  /**
12843
12955
  * Platform to connect ads for. Only platforms with ads support are accepted.
12956
+ *
12957
+ * `instagram` requires an Instagram account connected with loginMethod=facebook_login whose
12958
+ * token carries ads_management and ads_read. With an account connected through the default
12959
+ * instagram_login flow no ads account can be created; do not use this value for those accounts.
12960
+ *
12844
12961
  */
12845
12962
  platform: 'facebook' | 'instagram' | 'linkedin' | 'tiktok' | 'twitter' | 'pinterest' | 'googleads';
12846
12963
  };
@@ -12904,8 +13021,12 @@ export type ConnectAdsData = {
12904
13021
  * `tiktok`, `twitter` and `googleads` land on the URL unchanged, while the
12905
13022
  * same-token platforms (`facebook`, `instagram`, `linkedin`, `pinterest`)
12906
13023
  * append `connected`, `profileId`, `accountId`, `username` and, on API-key
12907
- * calls, `connect_token`. On failure every platform appends error details,
12908
- * starting with `error` and `platform`. When omitted, the browser lands on
13024
+ * calls, `connect_token`. On failure the same error contract applies as on
13025
+ * GET /v1/connect/{platform}: `error` and `platform` are always appended,
13026
+ * other params are optional, and the value list there is not exhaustive.
13027
+ * Note that on the tiktok, twitter and googleads flows `platform` carries
13028
+ * the ads platform id (`tiktokads`, `xads`, `googleads`), not the value
13029
+ * used in the request path. When omitted, the browser lands on
12909
13030
  * the Zernio dashboard.
12910
13031
  *
12911
13032
  */
@@ -18971,6 +19092,10 @@ export type GetInboxConversationMessagesResponse = ({
18971
19092
  attachments?: Array<{
18972
19093
  id?: string;
18973
19094
  type?: 'image' | 'video' | 'audio' | 'file' | 'sticker' | 'share';
19095
+ /**
19096
+ * Instagram and Facebook only, and present only when it differs from `type`. Meta's own type before normalization: `ig_reel` and `reel` become `video`, while `ig_post`, `post`, `ig_story` and `story_mention` become `share`. A story mention is `type: "share"` with `originalType: "story_mention"`; render on this field, since `share` alone is ambiguous.
19097
+ */
19098
+ originalType?: string;
18974
19099
  /**
18975
19100
  * Direct media link. On Instagram and Facebook this is a signed Meta CDN url that EXPIRES: use it now, do not store it. Persist `refreshUrl` instead.
18976
19101
  */
@@ -20167,7 +20292,7 @@ export type GetMessageAttachmentData = {
20167
20292
  };
20168
20293
  query: {
20169
20294
  /**
20170
- * Social account ID
20295
+ * Social account ID. Required: without it the request returns 400 missing_required_field.
20171
20296
  */
20172
20297
  accountId: string;
20173
20298
  /**