@zernio/node 0.2.112 → 0.2.113

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.
@@ -918,6 +918,54 @@ export type ConversionEvent = {
918
918
  */
919
919
  export type actionSource = 'web' | 'app' | 'offline' | 'crm' | 'phone_call' | 'system_generated';
920
920
 
921
+ export type CreateLeadFormBody = {
922
+ /**
923
+ * Facebook social account ID (Late SocialAccount _id).
924
+ */
925
+ accountId: string;
926
+ name: string;
927
+ questions: Array<LeadGenFormQuestion>;
928
+ /**
929
+ * Required by Meta. Must be reachable from Meta's crawler.
930
+ */
931
+ privacyPolicyUrl: string;
932
+ privacyPolicyLinkText?: string;
933
+ followUpActionUrl?: string;
934
+ locale?: string;
935
+ thankYouTitle?: string;
936
+ thankYouBody?: string;
937
+ thankYouButtonText?: string;
938
+ /**
939
+ * Meta enum (e.g. VIEW_WEBSITE, CALL_BUSINESS, DOWNLOAD)
940
+ */
941
+ thankYouButtonType?: string;
942
+ thankYouWebsiteUrl?: string;
943
+ isOptimizedForQuality?: boolean;
944
+ contextCard?: {
945
+ title?: string;
946
+ style?: 'LIST_STYLE' | 'PARAGRAPH_STYLE';
947
+ content?: Array<(string)>;
948
+ buttonText?: string;
949
+ };
950
+ legalContent?: {
951
+ customDisclaimer?: {
952
+ title?: string;
953
+ body?: string;
954
+ };
955
+ };
956
+ /**
957
+ * Up to 20 key/value pairs surfaced on every lead for attribution.
958
+ */
959
+ trackingParameters?: {
960
+ [key: string]: (string);
961
+ };
962
+ questionPageCustomHeadline?: string;
963
+ allowOrganicLead?: boolean;
964
+ blockDisplayForNonTargetedViewer?: boolean;
965
+ };
966
+
967
+ export type style = 'LIST_STYLE' | 'PARAGRAPH_STYLE';
968
+
921
969
  /**
922
970
  * Discord message settings. Supports plain text (2,000 chars), rich embeds (up to 10), native polls, forum posts, threads, and announcement crossposts. Media attachments support images (JPEG, PNG, GIF, WebP), videos (MP4), and documents (up to 10 files, 25 MB each). Webhook identity (username + avatar) can be customized per-account via PATCH /v1/connect/discord or per-post via webhookUsername/webhookAvatarUrl.
923
971
  *
@@ -1617,6 +1665,111 @@ export type contentType2 = 'story';
1617
1665
  */
1618
1666
  export type graduationStrategy = 'MANUAL' | 'SS_PERFORMANCE';
1619
1667
 
1668
+ /**
1669
+ * A single lead submission returned by the leads endpoint and the lead.received webhook.
1670
+ */
1671
+ export type Lead = {
1672
+ /**
1673
+ * Meta `leadgen_id`.
1674
+ */
1675
+ id?: string;
1676
+ createdTime?: string;
1677
+ /**
1678
+ * Meta ad ID that surfaced the form. Organic leads omit this.
1679
+ */
1680
+ adId?: (string) | null;
1681
+ formId?: string;
1682
+ /**
1683
+ * Flattened key→value map of answers (multi-value fields joined with ", ").
1684
+ */
1685
+ fields?: {
1686
+ [key: string]: (string);
1687
+ };
1688
+ /**
1689
+ * Raw `field_data` from Meta (one entry per question).
1690
+ */
1691
+ fieldData?: Array<{
1692
+ name?: string;
1693
+ values?: Array<(string)>;
1694
+ }>;
1695
+ };
1696
+
1697
+ /**
1698
+ * Common meta-block returned alongside lead-form responses for traceability.
1699
+ */
1700
+ export type LeadFormResponseMeta = {
1701
+ platform?: string;
1702
+ accountId?: string;
1703
+ formId?: (string) | null;
1704
+ leadId?: (string) | null;
1705
+ pageId?: (string) | null;
1706
+ lastUpdated?: string;
1707
+ };
1708
+
1709
+ /**
1710
+ * A Meta Lead Gen (Instant) Form definition.
1711
+ */
1712
+ export type LeadGenForm = {
1713
+ id?: string;
1714
+ name?: string;
1715
+ status?: 'ACTIVE' | 'ARCHIVED' | 'DELETED' | 'DRAFT';
1716
+ locale?: string;
1717
+ created_time?: string;
1718
+ /**
1719
+ * Total leads (real + organic).
1720
+ */
1721
+ leads_count?: number;
1722
+ organic_leads_count?: (number) | null;
1723
+ expired_leads_count?: (number) | null;
1724
+ questions?: Array<LeadGenFormQuestion>;
1725
+ privacy_policy_url?: (string) | null;
1726
+ follow_up_action_url?: (string) | null;
1727
+ thank_you_page?: {
1728
+ [key: string]: unknown;
1729
+ } | null;
1730
+ context_card?: {
1731
+ [key: string]: unknown;
1732
+ } | null;
1733
+ question_page_custom_headline?: (string) | null;
1734
+ is_optimized_for_quality?: (boolean) | null;
1735
+ page_id?: (string) | null;
1736
+ };
1737
+
1738
+ export type status3 = 'ACTIVE' | 'ARCHIVED' | 'DELETED' | 'DRAFT';
1739
+
1740
+ /**
1741
+ * A single question on a Meta Instant Form. The `type` enum spans Meta's
1742
+ * prefill set (FULL_NAME, EMAIL, PHONE, STREET_ADDRESS, CITY, STATE,
1743
+ * COUNTRY, POST_CODE, DOB, GENDER, JOB_TITLE, COMPANY_NAME, etc.) plus
1744
+ * custom types (CUSTOM, MULTIPLE_CHOICE, CONDITIONAL, STORE_LOOKUP,
1745
+ * APPOINTMENT_REQUEST). See Meta's Lead Ads docs for the full list —
1746
+ * we forward whatever string the caller sends so new types work without
1747
+ * a Zernio release.
1748
+ *
1749
+ */
1750
+ export type LeadGenFormQuestion = {
1751
+ /**
1752
+ * Stable key returned in `field_data` on each lead. If omitted, Meta auto-derives one from `label`.
1753
+ */
1754
+ key?: string;
1755
+ /**
1756
+ * Display text shown above the input.
1757
+ */
1758
+ label?: string;
1759
+ type: string;
1760
+ /**
1761
+ * Required for MULTIPLE_CHOICE / CONDITIONAL questions.
1762
+ */
1763
+ options?: Array<{
1764
+ key?: string;
1765
+ value?: string;
1766
+ }>;
1767
+ /**
1768
+ * Help text rendered below the field.
1769
+ */
1770
+ inline_context?: string;
1771
+ };
1772
+
1620
1773
  /**
1621
1774
  * Response for DAILY aggregation (time series breakdown)
1622
1775
  */
@@ -1867,7 +2020,7 @@ export type PlatformAnalytics = {
1867
2020
  errorMessage?: (string) | null;
1868
2021
  };
1869
2022
 
1870
- export type status3 = 'published' | 'failed';
2023
+ export type status4 = 'published' | 'failed';
1871
2024
 
1872
2025
  /**
1873
2026
  * Sync state of analytics for this platform
@@ -1977,7 +2130,7 @@ export type Post = {
1977
2130
  updatedAt?: string;
1978
2131
  };
1979
2132
 
1980
- export type status4 = 'draft' | 'scheduled' | 'publishing' | 'published' | 'failed' | 'partial';
2133
+ export type status5 = 'draft' | 'scheduled' | 'publishing' | 'published' | 'failed' | 'partial';
1981
2134
 
1982
2135
  export type visibility = 'public' | 'private' | 'unlisted';
1983
2136
 
@@ -2644,7 +2797,7 @@ export type UploadTokenResponse = {
2644
2797
  status?: 'pending' | 'completed' | 'expired';
2645
2798
  };
2646
2799
 
2647
- export type status5 = 'pending' | 'completed' | 'expired';
2800
+ export type status6 = 'pending' | 'completed' | 'expired';
2648
2801
 
2649
2802
  export type UploadTokenStatusResponse = {
2650
2803
  token?: string;
@@ -2715,7 +2868,7 @@ export type Webhook = {
2715
2868
  /**
2716
2869
  * Events subscribed to
2717
2870
  */
2718
- events?: Array<('post.scheduled' | 'post.published' | 'post.failed' | 'post.partial' | 'post.cancelled' | 'post.recycled' | 'account.connected' | 'account.disconnected' | 'account.ads.initial_sync_completed' | 'message.received' | 'message.sent' | 'message.edited' | 'message.deleted' | 'message.delivered' | 'message.read' | 'message.failed' | 'comment.received' | 'review.new' | 'review.updated')>;
2871
+ events?: Array<('post.scheduled' | 'post.published' | 'post.failed' | 'post.partial' | 'post.cancelled' | 'post.recycled' | 'account.connected' | 'account.disconnected' | 'account.ads.initial_sync_completed' | 'message.received' | 'message.sent' | 'message.edited' | 'message.deleted' | 'message.delivered' | 'message.read' | 'message.failed' | 'comment.received' | 'review.new' | 'review.updated' | 'lead.received')>;
2719
2872
  /**
2720
2873
  * Whether webhook delivery is enabled
2721
2874
  */
@@ -2843,7 +2996,7 @@ export type event = 'account.ads.initial_sync_completed';
2843
2996
  /**
2844
2997
  * Overall outcome of the initial sync.
2845
2998
  */
2846
- export type status6 = 'success' | 'failure';
2999
+ export type status7 = 'success' | 'failure';
2847
3000
 
2848
3001
  /**
2849
3002
  * Stable category for UX branching. New values may be added; existing ones are
@@ -3023,6 +3176,34 @@ export type event4 = 'comment.received';
3023
3176
 
3024
3177
  export type platform6 = 'instagram' | 'facebook' | 'twitter' | 'youtube' | 'linkedin' | 'bluesky' | 'reddit';
3025
3178
 
3179
+ /**
3180
+ * Webhook payload for the lead.received event. Fired when a Meta Lead Gen
3181
+ * Form receives a new submission. Real-time delivery requires the page to
3182
+ * be subscribed to the `leadgen` webhook field — Zernio subscribes
3183
+ * on connect; existing accounts get backfilled by
3184
+ * `scripts/backfill-fb-webhook-subscriptions.ts`.
3185
+ *
3186
+ * Requires the Ads add-on. Subscribers without the add-on are filtered at
3187
+ * delivery time.
3188
+ *
3189
+ */
3190
+ export type WebhookPayloadLeadReceived = {
3191
+ /**
3192
+ * Stable webhook event ID
3193
+ */
3194
+ id: string;
3195
+ event: 'lead.received';
3196
+ lead: Lead;
3197
+ account: {
3198
+ id: string;
3199
+ platform: string;
3200
+ username: string;
3201
+ };
3202
+ timestamp: string;
3203
+ };
3204
+
3205
+ export type event5 = 'lead.received';
3206
+
3026
3207
  /**
3027
3208
  * Webhook payload for message received events
3028
3209
  */
@@ -3238,7 +3419,7 @@ export type WebhookPayloadMessage = {
3238
3419
  timestamp: string;
3239
3420
  };
3240
3421
 
3241
- export type event5 = 'message.received';
3422
+ export type event6 = 'message.received';
3242
3423
 
3243
3424
  /**
3244
3425
  * WhatsApp only. Which kind of interactive reply the user sent:
@@ -3270,7 +3451,7 @@ export type WebhookPayloadMessageDeleted = {
3270
3451
  timestamp: string;
3271
3452
  };
3272
3453
 
3273
- export type event6 = 'message.deleted';
3454
+ export type event7 = 'message.deleted';
3274
3455
 
3275
3456
  /**
3276
3457
  * Shared payload for message.delivered, message.read, and
@@ -3305,7 +3486,7 @@ export type WebhookPayloadMessageDeliveryStatus = {
3305
3486
  timestamp: string;
3306
3487
  };
3307
3488
 
3308
- export type event7 = 'message.delivered' | 'message.read' | 'message.failed';
3489
+ export type event8 = 'message.delivered' | 'message.read' | 'message.failed';
3309
3490
 
3310
3491
  /**
3311
3492
  * Webhook payload for message.edited events. Fires when the sender
@@ -3347,7 +3528,7 @@ export type WebhookPayloadMessageEdited = {
3347
3528
  timestamp: string;
3348
3529
  };
3349
3530
 
3350
- export type event8 = 'message.edited';
3531
+ export type event9 = 'message.edited';
3351
3532
 
3352
3533
  /**
3353
3534
  * Webhook payload for message sent events (fired when a message is sent via the API)
@@ -3423,7 +3604,7 @@ export type WebhookPayloadMessageSent = {
3423
3604
  timestamp: string;
3424
3605
  };
3425
3606
 
3426
- export type event9 = 'message.sent';
3607
+ export type event10 = 'message.sent';
3427
3608
 
3428
3609
  /**
3429
3610
  * Webhook payload for post events
@@ -3451,7 +3632,7 @@ export type WebhookPayloadPost = {
3451
3632
  timestamp: string;
3452
3633
  };
3453
3634
 
3454
- export type event10 = 'post.scheduled' | 'post.published' | 'post.failed' | 'post.partial' | 'post.cancelled' | 'post.recycled';
3635
+ export type event11 = 'post.scheduled' | 'post.published' | 'post.failed' | 'post.partial' | 'post.cancelled' | 'post.recycled';
3455
3636
 
3456
3637
  /**
3457
3638
  * Webhook payload for the review.new event (new review posted on a connected account).
@@ -3471,7 +3652,7 @@ export type WebhookPayloadReviewNew = {
3471
3652
  timestamp: string;
3472
3653
  };
3473
3654
 
3474
- export type event11 = 'review.new';
3655
+ export type event12 = 'review.new';
3475
3656
 
3476
3657
  /**
3477
3658
  * Webhook payload for the review.updated event. Fired when the reviewer edits
@@ -3495,7 +3676,7 @@ export type WebhookPayloadReviewUpdated = {
3495
3676
  timestamp: string;
3496
3677
  };
3497
3678
 
3498
- export type event12 = 'review.updated';
3679
+ export type event13 = 'review.updated';
3499
3680
 
3500
3681
  /**
3501
3682
  * Webhook payload for test deliveries
@@ -3513,7 +3694,7 @@ export type WebhookPayloadTest = {
3513
3694
  timestamp: string;
3514
3695
  };
3515
3696
 
3516
- export type event13 = 'webhook.test';
3697
+ export type event14 = 'webhook.test';
3517
3698
 
3518
3699
  export type WhatsAppBodyComponent = {
3519
3700
  type: 'body';
@@ -13543,9 +13724,13 @@ export type CreateStandaloneAdData = {
13543
13724
  */
13544
13725
  body?: string;
13545
13726
  /**
13546
- * Required on legacy + attach shapes for Meta. Honoured on TikTok too — passes through to the Spark Ad creative's `call_to_action`. Ignored by other platforms.
13727
+ * Required on legacy + attach shapes for Meta. Honoured on TikTok too — passes through to the Spark Ad creative's `call_to_action`. Ignored by other platforms. Ignored on Meta when `leadGenFormId` is set — lead ads force CTA type to SIGN_UP.
13547
13728
  */
13548
13729
  callToAction?: 'LEARN_MORE' | 'SHOP_NOW' | 'SIGN_UP' | 'BOOK_TRAVEL' | 'CONTACT_US' | 'DOWNLOAD' | 'GET_OFFER' | 'GET_QUOTE' | 'SUBSCRIBE' | 'WATCH_MORE';
13730
+ /**
13731
+ * Meta-only. Attaches a Lead Gen (Instant) Form to the creative. Required when `goal="lead_generation"`. Force-overrides the CTA to SIGN_UP. Create a form first via POST /v1/ads/lead-forms. On the multi-creative shape this can also be set per `creatives[i]` to A/B different forms inside one ad set.
13732
+ */
13733
+ leadGenFormId?: string;
13549
13734
  /**
13550
13735
  * Required on legacy + attach shapes. Skip for multi-creative.
13551
13736
  */
@@ -13603,6 +13788,10 @@ export type CreateStandaloneAdData = {
13603
13788
  };
13604
13789
  linkUrl: string;
13605
13790
  callToAction: 'LEARN_MORE' | 'SHOP_NOW' | 'SIGN_UP' | 'BOOK_TRAVEL' | 'CONTACT_US' | 'DOWNLOAD' | 'GET_OFFER' | 'GET_QUOTE' | 'SUBSCRIBE' | 'WATCH_MORE';
13791
+ /**
13792
+ * Per-creative Lead Gen Form ID. Wins over the top-level `leadGenFormId` so each ad in a campaign can A/B a different form. Forces CTA to SIGN_UP.
13793
+ */
13794
+ leadGenFormId?: string;
13606
13795
  }>;
13607
13796
  /**
13608
13797
  * Meta-only. When present, switches to the attach shape: adds
@@ -14067,6 +14256,189 @@ export type AddUsersToAdAudienceError = (unknown | {
14067
14256
  error?: string;
14068
14257
  });
14069
14258
 
14259
+ export type ListLeadFormsData = {
14260
+ query: {
14261
+ /**
14262
+ * Facebook social account ID (Late SocialAccount _id)
14263
+ */
14264
+ accountId: string;
14265
+ /**
14266
+ * Meta `paging.cursors.after` from a prior page
14267
+ */
14268
+ cursor?: string;
14269
+ limit?: number;
14270
+ };
14271
+ };
14272
+
14273
+ export type ListLeadFormsResponse = ({
14274
+ status?: string;
14275
+ forms?: Array<LeadGenForm>;
14276
+ pagination?: {
14277
+ hasMore?: boolean;
14278
+ cursor?: (string) | null;
14279
+ };
14280
+ meta?: LeadFormResponseMeta;
14281
+ });
14282
+
14283
+ export type ListLeadFormsError = ({
14284
+ error?: string;
14285
+ } | unknown);
14286
+
14287
+ export type CreateLeadFormData = {
14288
+ body: CreateLeadFormBody;
14289
+ };
14290
+
14291
+ export type CreateLeadFormResponse = ({
14292
+ status?: string;
14293
+ form?: {
14294
+ id?: string;
14295
+ name?: string;
14296
+ };
14297
+ meta?: LeadFormResponseMeta;
14298
+ });
14299
+
14300
+ export type CreateLeadFormError = (unknown | {
14301
+ error?: string;
14302
+ });
14303
+
14304
+ export type GetLeadFormData = {
14305
+ path: {
14306
+ /**
14307
+ * Meta lead form ID (numeric string)
14308
+ */
14309
+ formId: string;
14310
+ };
14311
+ query: {
14312
+ accountId: string;
14313
+ };
14314
+ };
14315
+
14316
+ export type GetLeadFormResponse = ({
14317
+ status?: string;
14318
+ form?: LeadGenForm;
14319
+ meta?: LeadFormResponseMeta;
14320
+ });
14321
+
14322
+ export type GetLeadFormError = ({
14323
+ error?: string;
14324
+ } | unknown);
14325
+
14326
+ export type UpdateLeadFormData = {
14327
+ body: {
14328
+ accountId: string;
14329
+ status: 'ACTIVE' | 'ARCHIVED' | 'DRAFT';
14330
+ };
14331
+ path: {
14332
+ formId: string;
14333
+ };
14334
+ };
14335
+
14336
+ export type UpdateLeadFormResponse = ({
14337
+ status?: string;
14338
+ success?: boolean;
14339
+ meta?: LeadFormResponseMeta;
14340
+ });
14341
+
14342
+ export type UpdateLeadFormError = (unknown | {
14343
+ error?: string;
14344
+ });
14345
+
14346
+ export type DeleteLeadFormData = {
14347
+ path: {
14348
+ formId: string;
14349
+ };
14350
+ query: {
14351
+ accountId: string;
14352
+ };
14353
+ };
14354
+
14355
+ export type DeleteLeadFormResponse = ({
14356
+ status?: string;
14357
+ success?: boolean;
14358
+ meta?: LeadFormResponseMeta;
14359
+ });
14360
+
14361
+ export type DeleteLeadFormError = ({
14362
+ error?: string;
14363
+ } | unknown);
14364
+
14365
+ export type ListLeadFormLeadsData = {
14366
+ path: {
14367
+ formId: string;
14368
+ };
14369
+ query: {
14370
+ accountId: string;
14371
+ cursor?: string;
14372
+ limit?: number;
14373
+ /**
14374
+ * Unix timestamp; only return leads created strictly after this.
14375
+ */
14376
+ since?: number;
14377
+ };
14378
+ };
14379
+
14380
+ export type ListLeadFormLeadsResponse = ({
14381
+ status?: string;
14382
+ leads?: Array<Lead>;
14383
+ pagination?: {
14384
+ hasMore?: boolean;
14385
+ cursor?: (string) | null;
14386
+ };
14387
+ meta?: LeadFormResponseMeta;
14388
+ });
14389
+
14390
+ export type ListLeadFormLeadsError = ({
14391
+ error?: string;
14392
+ } | unknown);
14393
+
14394
+ export type CreateLeadFormTestLeadData = {
14395
+ body: {
14396
+ accountId: string;
14397
+ fieldData: Array<{
14398
+ /**
14399
+ * Question key (matches `key` from form definition)
14400
+ */
14401
+ name: string;
14402
+ values: Array<(string)>;
14403
+ }>;
14404
+ };
14405
+ path: {
14406
+ formId: string;
14407
+ };
14408
+ };
14409
+
14410
+ export type CreateLeadFormTestLeadResponse = ({
14411
+ status?: string;
14412
+ testLead?: {
14413
+ id?: string;
14414
+ };
14415
+ meta?: LeadFormResponseMeta;
14416
+ });
14417
+
14418
+ export type CreateLeadFormTestLeadError = ({
14419
+ error?: string;
14420
+ } | unknown);
14421
+
14422
+ export type DeleteLeadFormTestLeadData = {
14423
+ path: {
14424
+ formId: string;
14425
+ leadId: string;
14426
+ };
14427
+ query: {
14428
+ accountId: string;
14429
+ };
14430
+ };
14431
+
14432
+ export type DeleteLeadFormTestLeadResponse = ({
14433
+ status?: string;
14434
+ success?: boolean;
14435
+ meta?: LeadFormResponseMeta;
14436
+ });
14437
+
14438
+ export type DeleteLeadFormTestLeadError = ({
14439
+ error?: string;
14440
+ } | unknown);
14441
+
14070
14442
  export type SendConversionsData = {
14071
14443
  body: {
14072
14444
  /**