@zernio/node 0.2.115 → 0.2.117

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.
@@ -2655,7 +2655,20 @@ export type UploadTokenStatusResponse = {
2655
2655
  completedAt?: string;
2656
2656
  };
2657
2657
 
2658
+ /**
2659
+ * Plan and usage stats. The response shape depends on `billingSystem`:
2660
+ * * Stripe users (default): per-period counters like `usage.uploads` and
2661
+ * `usage.profiles` are returned, scoped by the plan's `limits`.
2662
+ * * Metronome users (usage-based): `limits` are unlimited (-1). The
2663
+ * `usage` block carries connected-account and per-X-operation counts,
2664
+ * and the `spend` block carries current-period costs plus the X cap.
2665
+ *
2666
+ */
2658
2667
  export type UsageStats = {
2668
+ /**
2669
+ * Which billing system the account is on. Shape of `usage`/`spend` differs.
2670
+ */
2671
+ billingSystem?: 'stripe' | 'metronome';
2659
2672
  planName?: string;
2660
2673
  billingPeriod?: 'monthly' | 'yearly';
2661
2674
  signupDate?: string;
@@ -2663,17 +2676,115 @@ export type UsageStats = {
2663
2676
  * Day of month (1-31) when the billing cycle resets
2664
2677
  */
2665
2678
  billingAnchorDay?: number;
2679
+ /**
2680
+ * True if the account is in good standing. False for past-due/unpaid/paused subscriptions.
2681
+ */
2682
+ hasAccess?: boolean;
2683
+ /**
2684
+ * Stripe customer ID, when present.
2685
+ */
2686
+ customerId?: (string) | null;
2687
+ /**
2688
+ * True if this is a team member; limits/usage reflect the account owner.
2689
+ */
2690
+ isInvitedUser?: boolean;
2691
+ /**
2692
+ * Stripe-only. Always false for Metronome users.
2693
+ */
2694
+ autoUpgradeEnabled?: boolean;
2695
+ /**
2696
+ * Plan limits. For Metronome users both fields are `-1` (unlimited).
2697
+ */
2666
2698
  limits?: {
2667
2699
  uploads?: number;
2668
2700
  profiles?: number;
2669
2701
  };
2702
+ /**
2703
+ * Per-period usage counts. Fields present depend on `billingSystem`:
2704
+ * Stripe returns `uploads` / `profiles` / `lastReset`;
2705
+ * Metronome returns `connectedAccounts` / `xApiCalls` / `xApiCallsByOperation`.
2706
+ *
2707
+ */
2670
2708
  usage?: {
2709
+ /**
2710
+ * Stripe users only. Uploads consumed in the current period.
2711
+ */
2671
2712
  uploads?: number;
2713
+ /**
2714
+ * Stripe users only. Profiles currently owned.
2715
+ */
2672
2716
  profiles?: number;
2717
+ /**
2718
+ * Stripe users only.
2719
+ */
2673
2720
  lastReset?: string;
2721
+ /**
2722
+ * Metronome users only. Accounts currently connected across the team.
2723
+ */
2724
+ connectedAccounts?: number;
2725
+ /**
2726
+ * Metronome users only. Aggregated X API call counts bucketed by
2727
+ * price tier (backward-compat). For per-operation breakdown use
2728
+ * `xApiCallsByOperation`.
2729
+ *
2730
+ */
2731
+ xApiCalls?: {
2732
+ /**
2733
+ * Calls at $0.005 per call (reads, list mgmt, bookmarks, etc.)
2734
+ */
2735
+ x_api_005?: number;
2736
+ /**
2737
+ * Calls at $0.010 per call (publish/delete, DM reads, follows)
2738
+ */
2739
+ x_api_010?: number;
2740
+ /**
2741
+ * Calls at $0.015 per call (sending DMs, follow actions)
2742
+ */
2743
+ x_api_015?: number;
2744
+ };
2745
+ /**
2746
+ * Metronome users only. Per-operation X API call counts keyed by
2747
+ * operation (e.g. `posts_read`, `content_create`). Resolve each key
2748
+ * to price and metadata via `GET /v1/billing/x-pricing`.
2749
+ *
2750
+ */
2751
+ xApiCallsByOperation?: {
2752
+ [key: string]: (number);
2753
+ };
2754
+ };
2755
+ /**
2756
+ * Metronome users only. Current-period spend summary.
2757
+ */
2758
+ spend?: {
2759
+ /**
2760
+ * Total current-period spend in cents (all products combined).
2761
+ */
2762
+ currentPeriodCents?: number;
2763
+ /**
2764
+ * Free-tier credit remaining in cents. Applied before any charge.
2765
+ */
2766
+ creditsRemainingCents?: number;
2767
+ /**
2768
+ * Current-period X/Twitter API spend in cents, derived from the per-tier
2769
+ * call counts. Rounded up for conservative enforcement against `xSpendLimitCents`.
2770
+ *
2771
+ */
2772
+ xSpendCents?: number;
2773
+ /**
2774
+ * Monthly X spend cap set by the account owner, or null if no cap.
2775
+ * When current X spend hits this cap, analytics and inbox sync are
2776
+ * auto-paused for X accounts. Publishing is never blocked by this cap.
2777
+ *
2778
+ */
2779
+ xSpendLimitCents?: (number) | null;
2674
2780
  };
2675
2781
  };
2676
2782
 
2783
+ /**
2784
+ * Which billing system the account is on. Shape of `usage`/`spend` differs.
2785
+ */
2786
+ export type billingSystem = 'stripe' | 'metronome';
2787
+
2677
2788
  export type billingPeriod = 'monthly' | 'yearly';
2678
2789
 
2679
2790
  export type User = {
@@ -3611,6 +3722,92 @@ export type otp_type = 'copy_code' | 'one_tap' | 'zero_tap';
3611
3722
 
3612
3723
  export type WhatsAppTemplateComponent = WhatsAppHeaderComponent | WhatsAppBodyComponent | WhatsAppFooterComponent | WhatsAppButtonsComponent;
3613
3724
 
3725
+ /**
3726
+ * A single X API operation with its per-call price and the Zernio platform methods that trigger it.
3727
+ */
3728
+ export type XApiOperation = {
3729
+ /**
3730
+ * Internal operation key. Matches keys in `xApiCallsByOperation`.
3731
+ */
3732
+ operation?: string;
3733
+ /**
3734
+ * Metronome `event_type` emitted when this operation runs.
3735
+ */
3736
+ eventType?: string;
3737
+ /**
3738
+ * Human-readable label shown on Metronome invoices.
3739
+ */
3740
+ displayName?: string;
3741
+ pricePerCallUsd?: number;
3742
+ /**
3743
+ * Per-call price in cents. Fractional values are intentional.
3744
+ */
3745
+ pricePerCallCents?: number;
3746
+ /**
3747
+ * Which aggregate price tier this operation falls into.
3748
+ */
3749
+ tier?: 'x_api_005' | 'x_api_010' | 'x_api_015';
3750
+ /**
3751
+ * Zernio platform methods that emit this operation, with their metering rule.
3752
+ */
3753
+ triggeredBy?: Array<{
3754
+ /**
3755
+ * Zernio platform method name.
3756
+ */
3757
+ method?: string;
3758
+ /**
3759
+ * When the method actually bills the user:
3760
+ * * `always` — every call is metered
3761
+ * * `analytics_optin` — only when the X account has analytics enabled
3762
+ * * `inbox_optin` — only when the X account has inbox sync enabled
3763
+ * * `absorbed` — Zernio eats the cost, never billed
3764
+ *
3765
+ */
3766
+ metering?: 'always' | 'analytics_optin' | 'inbox_optin' | 'absorbed';
3767
+ }>;
3768
+ };
3769
+
3770
+ /**
3771
+ * Which aggregate price tier this operation falls into.
3772
+ */
3773
+ export type tier = 'x_api_005' | 'x_api_010' | 'x_api_015';
3774
+
3775
+ /**
3776
+ * Canonical X/Twitter API pricing table. Zernio passes X API costs through
3777
+ * at exact rates with zero markup, so every call you make has a known per-unit
3778
+ * price. Use this payload alongside `/v1/usage-stats` (which returns
3779
+ * per-operation call counts via `xApiCallsByOperation`) to compute exact
3780
+ * cost attribution by X action.
3781
+ *
3782
+ */
3783
+ export type XApiPricing = {
3784
+ currency?: string;
3785
+ /**
3786
+ * Always 0% — Zernio does not mark up X API rates.
3787
+ */
3788
+ markup?: string;
3789
+ source?: string;
3790
+ /**
3791
+ * Date the prices were last verified against X's published rates.
3792
+ */
3793
+ lastVerified?: string;
3794
+ /**
3795
+ * Rollup of operations grouped by their per-call price.
3796
+ */
3797
+ tiers?: Array<{
3798
+ /**
3799
+ * Historical bucket key used in `xApiCalls` aggregation.
3800
+ */
3801
+ tier?: 'x_api_005' | 'x_api_010' | 'x_api_015';
3802
+ pricePerCallUsd?: number;
3803
+ operationCount?: number;
3804
+ }>;
3805
+ /**
3806
+ * Flat list of every X operation Zernio can perform, with its rate.
3807
+ */
3808
+ operations?: Array<XApiOperation>;
3809
+ };
3810
+
3614
3811
  export type YouTubeDailyViewsResponse = {
3615
3812
  success?: boolean;
3616
3813
  /**
@@ -4896,6 +5093,12 @@ export type GetRedditFeedError = (unknown | {
4896
5093
  error?: string;
4897
5094
  });
4898
5095
 
5096
+ export type GetXApiPricingResponse = (XApiPricing);
5097
+
5098
+ export type GetXApiPricingError = ({
5099
+ error?: string;
5100
+ });
5101
+
4899
5102
  export type GetUsageStatsResponse = (UsageStats);
4900
5103
 
4901
5104
  export type GetUsageStatsError = ({
@@ -5324,6 +5527,61 @@ export type CreateProfileResponse = (ProfileCreateResponse);
5324
5527
 
5325
5528
  export type CreateProfileError = (unknown | {
5326
5529
  error?: string;
5530
+ } | {
5531
+ /**
5532
+ * Human-readable error message suitable for end-user display.
5533
+ */
5534
+ error: string;
5535
+ /**
5536
+ * Machine-readable error code. Stable across versions.
5537
+ */
5538
+ code: 'PAYMENT_REQUIRED';
5539
+ /**
5540
+ * Discriminator for which gate fired.
5541
+ */
5542
+ reason: 'free_tier_exceeded' | 'twitter_passthrough' | 'enterprise_required';
5543
+ /**
5544
+ * Link to the relevant documentation page.
5545
+ */
5546
+ documentation_url?: string;
5547
+ /**
5548
+ * Deep-link to send the end-user to. For
5549
+ * `free_tier_exceeded` and `twitter_passthrough` this is
5550
+ * the Zernio billing tab. For `enterprise_required` this
5551
+ * is the Zernio enterprise contact page.
5552
+ *
5553
+ */
5554
+ dashboard_url?: string;
5555
+ /**
5556
+ * Structured context for SDK clients that want to render their own UX. Keys vary by `reason`.
5557
+ */
5558
+ details?: {
5559
+ /**
5560
+ * How many accounts the free tier allows. Only set when reason=free_tier_exceeded.
5561
+ */
5562
+ free_tier_account_limit?: number;
5563
+ /**
5564
+ * How many accounts the team currently has connected. Set when reason=free_tier_exceeded or reason=enterprise_required.
5565
+ */
5566
+ current_account_count?: number;
5567
+ /**
5568
+ * Whether the team currently has a card on file in Stripe. Set when reason=free_tier_exceeded or reason=twitter_passthrough.
5569
+ */
5570
+ has_payment_method?: boolean;
5571
+ /**
5572
+ * Public pricing ceiling (the published cap beyond which an enterprise contract is required). Only set when reason=enterprise_required.
5573
+ */
5574
+ public_account_limit?: number;
5575
+ /**
5576
+ * The cap actually applied to this team. Equals
5577
+ * `public_account_limit` for organic teams; for teams
5578
+ * with a per-customer override (grandfathered legacy
5579
+ * customers, signed enterprise contracts) this can
5580
+ * be higher. Only set when reason=enterprise_required.
5581
+ *
5582
+ */
5583
+ effective_account_limit?: number;
5584
+ };
5327
5585
  });
5328
5586
 
5329
5587
  export type GetProfileData = {
@@ -5468,6 +5726,32 @@ export type UpdateAccountData = {
5468
5726
  body: {
5469
5727
  username?: string;
5470
5728
  displayName?: string;
5729
+ /**
5730
+ * X/Twitter only. Per-account opt-in toggles for background API
5731
+ * operations that incur X API pass-through costs. Each call is
5732
+ * billed via Metronome at the X tier rate. Either field can be
5733
+ * sent independently; omitted fields are unchanged.
5734
+ *
5735
+ */
5736
+ xCapabilities?: {
5737
+ /**
5738
+ * Enable periodic analytics reads (impressions, likes, etc.)
5739
+ * for this X account. Each X API call is metered as
5740
+ * `posts_read` and billed pass-through (~$0.005/call at the
5741
+ * time of writing — actual rate depends on X's pricing tier).
5742
+ *
5743
+ */
5744
+ analytics?: boolean;
5745
+ /**
5746
+ * Enable DM polling and inbox sync for this X account. DM
5747
+ * reads are metered as `dm_event_read` (~$0.010/call) and
5748
+ * DM sends as `dm_interaction_create` (~$0.015/call), both
5749
+ * billed pass-through. DM sends fire only on user-initiated
5750
+ * actions; reads/polling fire only when this flag is true.
5751
+ *
5752
+ */
5753
+ inbox?: boolean;
5754
+ };
5471
5755
  };
5472
5756
  path: {
5473
5757
  accountId: string;
@@ -5478,6 +5762,15 @@ export type UpdateAccountResponse = ({
5478
5762
  message?: string;
5479
5763
  username?: string;
5480
5764
  displayName?: string;
5765
+ /**
5766
+ * Echo of the resulting `xCapabilities` state, returned only
5767
+ * when the request body included an `xCapabilities` object.
5768
+ *
5769
+ */
5770
+ xCapabilities?: {
5771
+ analytics?: boolean;
5772
+ inbox?: boolean;
5773
+ };
5481
5774
  });
5482
5775
 
5483
5776
  export type UpdateAccountError = (unknown | {
@@ -5812,6 +6105,61 @@ export type GetConnectUrlResponse = ({
5812
6105
 
5813
6106
  export type GetConnectUrlError = (unknown | {
5814
6107
  error?: string;
6108
+ } | {
6109
+ /**
6110
+ * Human-readable error message suitable for end-user display.
6111
+ */
6112
+ error: string;
6113
+ /**
6114
+ * Machine-readable error code. Stable across versions.
6115
+ */
6116
+ code: 'PAYMENT_REQUIRED';
6117
+ /**
6118
+ * Discriminator for which gate fired.
6119
+ */
6120
+ reason: 'free_tier_exceeded' | 'twitter_passthrough' | 'enterprise_required';
6121
+ /**
6122
+ * Link to the relevant documentation page.
6123
+ */
6124
+ documentation_url?: string;
6125
+ /**
6126
+ * Deep-link to send the end-user to. For
6127
+ * `free_tier_exceeded` and `twitter_passthrough` this is
6128
+ * the Zernio billing tab. For `enterprise_required` this
6129
+ * is the Zernio enterprise contact page.
6130
+ *
6131
+ */
6132
+ dashboard_url?: string;
6133
+ /**
6134
+ * Structured context for SDK clients that want to render their own UX. Keys vary by `reason`.
6135
+ */
6136
+ details?: {
6137
+ /**
6138
+ * How many accounts the free tier allows. Only set when reason=free_tier_exceeded.
6139
+ */
6140
+ free_tier_account_limit?: number;
6141
+ /**
6142
+ * How many accounts the team currently has connected. Set when reason=free_tier_exceeded or reason=enterprise_required.
6143
+ */
6144
+ current_account_count?: number;
6145
+ /**
6146
+ * Whether the team currently has a card on file in Stripe. Set when reason=free_tier_exceeded or reason=twitter_passthrough.
6147
+ */
6148
+ has_payment_method?: boolean;
6149
+ /**
6150
+ * Public pricing ceiling (the published cap beyond which an enterprise contract is required). Only set when reason=enterprise_required.
6151
+ */
6152
+ public_account_limit?: number;
6153
+ /**
6154
+ * The cap actually applied to this team. Equals
6155
+ * `public_account_limit` for organic teams; for teams
6156
+ * with a per-customer override (grandfathered legacy
6157
+ * customers, signed enterprise contracts) this can
6158
+ * be higher. Only set when reason=enterprise_required.
6159
+ *
6160
+ */
6161
+ effective_account_limit?: number;
6162
+ };
5815
6163
  });
5816
6164
 
5817
6165
  export type HandleOAuthCallbackData = {
@@ -7435,6 +7783,129 @@ export type ConnectWhatsAppCredentialsResponse = ({
7435
7783
 
7436
7784
  export type ConnectWhatsAppCredentialsError = (unknown);
7437
7785
 
7786
+ export type ListWhatsAppPhoneNumbersData = {
7787
+ headers?: {
7788
+ /**
7789
+ * Alternative auth for API users' end customers (used when the bearer token is scoped to a different user)
7790
+ */
7791
+ 'X-Connect-Token'?: string;
7792
+ };
7793
+ query: {
7794
+ /**
7795
+ * The Zernio profile ID from the headless redirect
7796
+ */
7797
+ profileId: string;
7798
+ /**
7799
+ * The temporary access token from the headless redirect
7800
+ */
7801
+ tempToken: string;
7802
+ };
7803
+ };
7804
+
7805
+ export type ListWhatsAppPhoneNumbersResponse = ({
7806
+ phoneNumbers?: Array<{
7807
+ /**
7808
+ * Phone Number ID (Meta)
7809
+ */
7810
+ id?: string;
7811
+ /**
7812
+ * E.164-formatted display number
7813
+ */
7814
+ display_phone_number?: string;
7815
+ /**
7816
+ * Meta-verified business name
7817
+ */
7818
+ verified_name?: string;
7819
+ /**
7820
+ * GREEN, YELLOW, RED, or UNKNOWN
7821
+ */
7822
+ quality_rating?: string;
7823
+ /**
7824
+ * APPROVED, PENDING_REVIEW, DECLINED, or NONE
7825
+ */
7826
+ name_status?: string;
7827
+ /**
7828
+ * TIER_250, TIER_1K, TIER_10K, TIER_100K, or TIER_UNLIMITED
7829
+ */
7830
+ messaging_limit_tier?: string;
7831
+ /**
7832
+ * WhatsApp Business Account ID (Zernio enrichment)
7833
+ */
7834
+ wabaId?: string;
7835
+ /**
7836
+ * WABA display name (Zernio enrichment)
7837
+ */
7838
+ wabaName?: string;
7839
+ }>;
7840
+ });
7841
+
7842
+ export type ListWhatsAppPhoneNumbersError = (ErrorResponse | {
7843
+ error?: string;
7844
+ });
7845
+
7846
+ export type CompleteWhatsAppPhoneSelectionData = {
7847
+ body: {
7848
+ /**
7849
+ * The Zernio profile ID
7850
+ */
7851
+ profileId: string;
7852
+ /**
7853
+ * The selected phone number ID (from listWhatsAppPhoneNumbers)
7854
+ */
7855
+ phoneNumberId: string;
7856
+ /**
7857
+ * The WABA ID containing the selected phone
7858
+ */
7859
+ wabaId: string;
7860
+ /**
7861
+ * The temporary access token from the headless redirect
7862
+ */
7863
+ tempToken: string;
7864
+ /**
7865
+ * Optional user profile data (passthrough)
7866
+ */
7867
+ userProfile?: {
7868
+ [key: string]: unknown;
7869
+ };
7870
+ /**
7871
+ * Optional URL to receive the post-connection redirect target
7872
+ */
7873
+ redirect_url?: string;
7874
+ };
7875
+ headers?: {
7876
+ /**
7877
+ * Alternative auth for API users' end customers
7878
+ */
7879
+ 'X-Connect-Token'?: string;
7880
+ };
7881
+ };
7882
+
7883
+ export type CompleteWhatsAppPhoneSelectionResponse = ({
7884
+ message?: string;
7885
+ /**
7886
+ * Present only if redirect_url was provided in the request
7887
+ */
7888
+ redirect_url?: string;
7889
+ account?: {
7890
+ accountId?: string;
7891
+ platform?: 'whatsapp';
7892
+ /**
7893
+ * Display phone number
7894
+ */
7895
+ username?: string;
7896
+ /**
7897
+ * Meta-verified business name
7898
+ */
7899
+ displayName?: string;
7900
+ isActive?: boolean;
7901
+ selectedPhoneNumber?: string;
7902
+ };
7903
+ });
7904
+
7905
+ export type CompleteWhatsAppPhoneSelectionError = (ErrorResponse | {
7906
+ error?: string;
7907
+ } | unknown);
7908
+
7438
7909
  export type GetTelegramConnectStatusData = {
7439
7910
  query: {
7440
7911
  /**