@zernio/node 0.2.75 → 0.2.77

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.
@@ -216,19 +216,63 @@ export type goal = 'engagement' | 'traffic' | 'awareness' | 'video_views' | 'lea
216
216
 
217
217
  export type type = 'daily' | 'lifetime';
218
218
 
219
+ /**
220
+ * Budget amount in the ad account's native currency (see the campaign's `currency` field for the code).
221
+ */
222
+ export type AdBudget = {
223
+ amount: number;
224
+ type: 'daily' | 'lifetime';
225
+ };
226
+
219
227
  export type AdCampaign = {
220
228
  platformCampaignId?: string;
221
229
  platform?: 'facebook' | 'instagram' | 'tiktok' | 'linkedin' | 'pinterest' | 'google' | 'twitter';
222
230
  campaignName?: string;
223
231
  /**
224
- * Derived from child ad statuses
232
+ * Delivery status derived from child ad statuses. Distinct from `reviewStatus`.
225
233
  */
226
234
  status?: (AdStatus);
235
+ /**
236
+ * Platform-side review state of the campaign. See AdTreeCampaign.reviewStatus for the full description.
237
+ */
238
+ reviewStatus?: ('in_review' | 'approved' | 'rejected' | 'with_issues') | null;
239
+ /**
240
+ * Raw platform-level campaign status (Meta `effective_status`).
241
+ */
242
+ platformCampaignStatus?: (string) | null;
243
+ /**
244
+ * Platform-reported campaign issues (Meta `issues_info[]`).
245
+ */
246
+ campaignIssuesInfo?: Array<{
247
+ [key: string]: unknown;
248
+ }> | null;
227
249
  adCount?: number;
250
+ /**
251
+ * Effective budget (back-compat). Use `budgetLevel` to disambiguate CBO vs ABO.
252
+ */
228
253
  budget?: {
229
254
  amount?: number;
230
255
  type?: 'daily' | 'lifetime';
231
256
  } | null;
257
+ /**
258
+ * Campaign-level budget (CBO). Null for ABO campaigns.
259
+ */
260
+ campaignBudget?: {
261
+ amount?: number;
262
+ type?: 'daily' | 'lifetime';
263
+ } | null;
264
+ /**
265
+ * Canonical CBO/ABO indicator. See AdTreeCampaign.budgetLevel.
266
+ */
267
+ budgetLevel?: ('campaign' | 'adset') | null;
268
+ /**
269
+ * Meta-only. Mirrors Campaign.is_budget_schedule_enabled.
270
+ */
271
+ isBudgetScheduleEnabled?: boolean;
272
+ /**
273
+ * ISO 4217 currency code for all budget amounts. Budgets are NOT normalized to USD.
274
+ */
275
+ currency?: (string) | null;
232
276
  metrics?: AdMetrics;
233
277
  platformAdAccountId?: string;
234
278
  accountId?: string;
@@ -257,6 +301,16 @@ export type AdCampaign = {
257
301
  latestAd?: string;
258
302
  };
259
303
 
304
+ /**
305
+ * Platform-side review state of the campaign. See AdTreeCampaign.reviewStatus for the full description.
306
+ */
307
+ export type reviewStatus = 'in_review' | 'approved' | 'rejected' | 'with_issues';
308
+
309
+ /**
310
+ * Canonical CBO/ABO indicator. See AdTreeCampaign.budgetLevel.
311
+ */
312
+ export type budgetLevel = 'campaign' | 'adset';
313
+
260
314
  export type AdMetrics = {
261
315
  spend?: number;
262
316
  impressions?: number;
@@ -308,10 +362,20 @@ export type AdTreeAdSet = {
308
362
  */
309
363
  status?: (AdStatus);
310
364
  adCount?: number;
365
+ /**
366
+ * Effective budget at this level (back-compat). For CBO campaigns this mirrors the parent campaign's budget; for ABO this is the ad-set-specific budget. Use `adSetBudget` / parent `campaignBudget` + `budgetLevel` to disambiguate.
367
+ */
311
368
  budget?: {
312
369
  amount?: number;
313
370
  type?: 'daily' | 'lifetime';
314
371
  } | null;
372
+ /**
373
+ * Ad-set-level budget (ABO). Null for CBO campaigns where the budget is set on the campaign.
374
+ */
375
+ adSetBudget?: {
376
+ amount?: number;
377
+ type?: 'daily' | 'lifetime';
378
+ } | null;
315
379
  metrics?: AdMetrics;
316
380
  /**
317
381
  * Meta ad set optimization goal (e.g. OFFSITE_CONVERSIONS, VALUE, LEAD_GENERATION)
@@ -343,18 +407,60 @@ export type AdTreeCampaign = {
343
407
  platform?: 'facebook' | 'instagram' | 'tiktok' | 'linkedin' | 'pinterest' | 'google' | 'twitter';
344
408
  campaignName?: string;
345
409
  /**
346
- * Derived from child ad statuses
410
+ * Delivery status derived from child ad statuses. Distinct from `reviewStatus`, which reflects the platform-side review state.
347
411
  */
348
412
  status?: (AdStatus);
413
+ /**
414
+ * Platform-side review state of the campaign. Independent of the
415
+ * children-derived delivery `status`: a campaign can have ads
416
+ * already active (status=active) while the campaign itself is
417
+ * still being reviewed by the platform (reviewStatus=in_review).
418
+ * For Meta, derived from `effective_status` + `issues_info` on
419
+ * the Campaign, plus ad-level PENDING_REVIEW rollup.
420
+ *
421
+ */
422
+ reviewStatus?: ('in_review' | 'approved' | 'rejected' | 'with_issues') | null;
423
+ /**
424
+ * Raw platform-level campaign status (Meta `effective_status`: ACTIVE, PAUSED, DELETED, ARCHIVED, IN_PROCESS, WITH_ISSUES). Distinct from per-ad `platformStatus`.
425
+ */
426
+ platformCampaignStatus?: (string) | null;
427
+ /**
428
+ * Platform-reported campaign issues (Meta `issues_info[]`). Populated only when the platform has delivery issues to report; contains the specific error codes and messages.
429
+ */
430
+ campaignIssuesInfo?: Array<{
431
+ [key: string]: unknown;
432
+ }> | null;
349
433
  /**
350
434
  * Total ads across all ad sets
351
435
  */
352
436
  adCount?: number;
353
437
  adSetCount?: number;
438
+ /**
439
+ * Effective budget (back-compat). For CBO this mirrors `campaignBudget`, for ABO this mirrors the child ad-set budget. Use `budgetLevel` to disambiguate.
440
+ */
354
441
  budget?: {
355
442
  amount?: number;
356
443
  type?: 'daily' | 'lifetime';
357
444
  } | null;
445
+ /**
446
+ * Campaign-level budget (Campaign Budget Optimization / CBO). Populated only when the platform set the budget at the campaign level. For ABO campaigns this is null and the budget lives on the child ad set.
447
+ */
448
+ campaignBudget?: {
449
+ amount?: number;
450
+ type?: 'daily' | 'lifetime';
451
+ } | null;
452
+ /**
453
+ * Canonical CBO/ABO indicator. `campaign` = CBO (Advantage Campaign Budget, budget lives on the campaign). `adset` = ABO (budget lives on each ad set). Route budget updates to the matching Meta entity.
454
+ */
455
+ budgetLevel?: ('campaign' | 'adset') | null;
456
+ /**
457
+ * Meta-only. Mirrors Campaign.is_budget_schedule_enabled — true when the campaign uses budget scheduling (time-based budget changes). Independent of CBO/ABO.
458
+ */
459
+ isBudgetScheduleEnabled?: boolean;
460
+ /**
461
+ * ISO 4217 currency code (e.g. USD, EUR, CLP, JPY) for all budget amounts in this campaign node. Budgets are NOT normalized to USD.
462
+ */
463
+ currency?: (string) | null;
358
464
  metrics?: AdMetrics;
359
465
  platformAdAccountId?: string;
360
466
  accountId?: string;
@@ -1142,10 +1248,48 @@ export type InboxWebhookMessage = {
1142
1248
  };
1143
1249
  }>;
1144
1250
  sender: {
1251
+ /**
1252
+ * Sender's platform identifier. For WhatsApp this is the phone number
1253
+ * (without leading `+`) when available, otherwise the `businessScopedUserId`.
1254
+ * For other platforms, the platform's own user ID.
1255
+ *
1256
+ */
1145
1257
  id: string;
1146
1258
  name?: string;
1147
1259
  username?: string;
1148
1260
  picture?: string;
1261
+ /**
1262
+ * WhatsApp only. Sender's phone number in E.164 format (with leading `+`).
1263
+ *
1264
+ * **Nullable during the BSUID rollout (April 2026+).** WhatsApp users
1265
+ * who adopt a username can message businesses without exposing a phone
1266
+ * number — this field is omitted for them. Match by `businessScopedUserId`
1267
+ * instead. See `docs/whatsapp-bsuid-migration.md`.
1268
+ *
1269
+ */
1270
+ phoneNumber?: (string) | null;
1271
+ /**
1272
+ * WhatsApp only. Business-scoped user ID (BSUID) — Meta's canonical
1273
+ * identifier for a WhatsApp user within your business. Present when
1274
+ * Meta includes it in the inbound payload (rollout in progress since
1275
+ * early April 2026). **Recommended primary identity anchor** going
1276
+ * forward; fall back to `phoneNumber` only when this field is absent.
1277
+ *
1278
+ */
1279
+ businessScopedUserId?: string;
1280
+ /**
1281
+ * WhatsApp only. Parent BSUID for businesses with linked business
1282
+ * portfolios. Omitted for standalone portfolios.
1283
+ *
1284
+ */
1285
+ parentBusinessScopedUserId?: string;
1286
+ /**
1287
+ * WhatsApp only. User's WhatsApp username (e.g. `@jane`). Not a
1288
+ * stable identifier — users can change it. Useful for display, not
1289
+ * recommended as an identity anchor.
1290
+ *
1291
+ */
1292
+ whatsappUsername?: string;
1149
1293
  /**
1150
1294
  * Instagram profile data. Only present for Instagram conversations.
1151
1295
  */
@@ -2560,10 +2704,50 @@ export type WebhookPayloadMessage = {
2560
2704
  };
2561
2705
  }>;
2562
2706
  sender: {
2707
+ /**
2708
+ * Sender's platform identifier. For WhatsApp this is the phone
2709
+ * number (without leading `+`) when available, otherwise the
2710
+ * `businessScopedUserId`.
2711
+ *
2712
+ */
2563
2713
  id: string;
2564
2714
  name?: string;
2565
2715
  username?: string;
2566
2716
  picture?: string;
2717
+ /**
2718
+ * WhatsApp only. Sender's phone number in E.164 format (with leading `+`).
2719
+ *
2720
+ * **Nullable during the BSUID rollout (April 2026+).** WhatsApp
2721
+ * users who adopt a username can message businesses without
2722
+ * exposing a phone number — this field is omitted for them.
2723
+ * Match by `businessScopedUserId` instead. See
2724
+ * `docs/whatsapp-bsuid-migration.md`.
2725
+ *
2726
+ */
2727
+ phoneNumber?: (string) | null;
2728
+ /**
2729
+ * WhatsApp only. Business-scoped user ID (BSUID) — Meta's canonical
2730
+ * identifier for a WhatsApp user within your business. Present
2731
+ * when Meta includes it in the inbound payload (rollout in
2732
+ * progress since early April 2026). **Recommended primary identity
2733
+ * anchor** going forward; fall back to `phoneNumber` only when
2734
+ * this field is absent.
2735
+ *
2736
+ */
2737
+ businessScopedUserId?: string;
2738
+ /**
2739
+ * WhatsApp only. Parent BSUID for businesses with linked business
2740
+ * portfolios. Omitted for standalone portfolios.
2741
+ *
2742
+ */
2743
+ parentBusinessScopedUserId?: string;
2744
+ /**
2745
+ * WhatsApp only. User's WhatsApp username (e.g. `@jane`). Not a
2746
+ * stable identifier — users can change it. Useful for display,
2747
+ * not recommended as an identity anchor.
2748
+ *
2749
+ */
2750
+ whatsappUsername?: string;
2567
2751
  /**
2568
2752
  * Instagram profile data for the sender. Only present for Instagram conversations.
2569
2753
  */
@@ -11762,6 +11946,9 @@ export type ListAdCampaignsData = {
11762
11946
  * Profile ID
11763
11947
  */
11764
11948
  profileId?: string;
11949
+ /**
11950
+ * `zernio` (default) returns only ads created via Zernio (isExternal=false). `all` additionally returns ads discovered from the platform's ad manager (isExternal=true). Status is NOT filtered by default — use the `status` param for that.
11951
+ */
11765
11952
  source?: 'zernio' | 'all';
11766
11953
  /**
11767
11954
  * Filter by derived campaign status (post-aggregation)
@@ -11812,6 +11999,193 @@ export type UpdateAdCampaignStatusError = (unknown | {
11812
11999
  error?: string;
11813
12000
  });
11814
12001
 
12002
+ export type UpdateAdCampaignData = {
12003
+ body: {
12004
+ platform: 'facebook' | 'instagram';
12005
+ budget: {
12006
+ /**
12007
+ * Budget amount in the ad account's currency
12008
+ */
12009
+ amount: number;
12010
+ type: 'daily' | 'lifetime';
12011
+ };
12012
+ };
12013
+ path: {
12014
+ /**
12015
+ * Platform campaign ID
12016
+ */
12017
+ campaignId: string;
12018
+ };
12019
+ };
12020
+
12021
+ export type UpdateAdCampaignResponse = ({
12022
+ updated?: number;
12023
+ budget?: AdBudget;
12024
+ budgetLevel?: 'campaign';
12025
+ });
12026
+
12027
+ export type UpdateAdCampaignError = (unknown | {
12028
+ error?: string;
12029
+ });
12030
+
12031
+ export type DeleteAdCampaignData = {
12032
+ body: {
12033
+ platform: 'facebook' | 'instagram';
12034
+ };
12035
+ path: {
12036
+ /**
12037
+ * Platform campaign ID
12038
+ */
12039
+ campaignId: string;
12040
+ };
12041
+ };
12042
+
12043
+ export type DeleteAdCampaignResponse = ({
12044
+ deleted?: boolean;
12045
+ /**
12046
+ * Number of local Ad docs marked cancelled
12047
+ */
12048
+ adCount?: number;
12049
+ });
12050
+
12051
+ export type DeleteAdCampaignError = ({
12052
+ error?: string;
12053
+ } | unknown);
12054
+
12055
+ export type BulkUpdateAdCampaignStatusData = {
12056
+ body: {
12057
+ status: 'active' | 'paused';
12058
+ campaigns: Array<{
12059
+ platformCampaignId: string;
12060
+ platform: 'facebook' | 'instagram' | 'tiktok' | 'linkedin' | 'pinterest' | 'google' | 'twitter';
12061
+ }>;
12062
+ };
12063
+ };
12064
+
12065
+ export type BulkUpdateAdCampaignStatusResponse = ({
12066
+ status?: 'active' | 'paused';
12067
+ totals?: {
12068
+ updated?: number;
12069
+ skipped?: number;
12070
+ failed?: number;
12071
+ };
12072
+ results?: Array<{
12073
+ platformCampaignId?: string;
12074
+ platform?: string;
12075
+ updated?: number;
12076
+ skipped?: number;
12077
+ error?: string;
12078
+ }>;
12079
+ });
12080
+
12081
+ export type BulkUpdateAdCampaignStatusError = (unknown | {
12082
+ error?: string;
12083
+ });
12084
+
12085
+ export type DuplicateAdCampaignData = {
12086
+ body: {
12087
+ platform: 'facebook' | 'instagram';
12088
+ /**
12089
+ * Copy child ad sets + ads + creatives + targeting
12090
+ */
12091
+ deepCopy?: boolean;
12092
+ statusOption?: 'ACTIVE' | 'PAUSED' | 'INHERITED_FROM_SOURCE';
12093
+ /**
12094
+ * Reschedule the copied hierarchy's start time
12095
+ */
12096
+ startTime?: string;
12097
+ endTime?: string;
12098
+ renameStrategy?: 'DEEP_RENAME' | 'ONLY_TOP_LEVEL_RENAME' | 'NO_RENAME';
12099
+ renamePrefix?: string;
12100
+ renameSuffix?: string;
12101
+ /**
12102
+ * Trigger ads discovery on the owning account after the copy succeeds
12103
+ */
12104
+ syncAfter?: boolean;
12105
+ };
12106
+ path: {
12107
+ /**
12108
+ * Source platform campaign ID
12109
+ */
12110
+ campaignId: string;
12111
+ };
12112
+ };
12113
+
12114
+ export type DuplicateAdCampaignResponse = ({
12115
+ /**
12116
+ * Platform ID of the new campaign
12117
+ */
12118
+ copiedCampaignId?: string;
12119
+ discovery?: 'triggered' | 'skipped' | 'failed';
12120
+ /**
12121
+ * Platform-native response from the copy endpoint (Meta includes ad_object_ids for child copies)
12122
+ */
12123
+ raw?: {
12124
+ [key: string]: unknown;
12125
+ };
12126
+ });
12127
+
12128
+ export type DuplicateAdCampaignError = (unknown | {
12129
+ error?: string;
12130
+ });
12131
+
12132
+ export type UpdateAdSetData = {
12133
+ body: {
12134
+ platform: 'facebook' | 'instagram' | 'tiktok' | 'linkedin' | 'pinterest' | 'google' | 'twitter';
12135
+ /**
12136
+ * Omit if only toggling status
12137
+ */
12138
+ budget?: {
12139
+ amount?: number;
12140
+ type?: 'daily' | 'lifetime';
12141
+ };
12142
+ /**
12143
+ * Omit if only updating budget
12144
+ */
12145
+ status?: 'active' | 'paused';
12146
+ };
12147
+ path: {
12148
+ /**
12149
+ * Platform ad set ID
12150
+ */
12151
+ adSetId: string;
12152
+ };
12153
+ };
12154
+
12155
+ export type UpdateAdSetResponse = ({
12156
+ budget?: AdBudget;
12157
+ budgetLevel?: 'adset';
12158
+ status?: 'active' | 'paused';
12159
+ statusUpdated?: number;
12160
+ statusSkipped?: number;
12161
+ });
12162
+
12163
+ export type UpdateAdSetError = (unknown | {
12164
+ error?: string;
12165
+ });
12166
+
12167
+ export type UpdateAdSetStatusData = {
12168
+ body: {
12169
+ status: 'active' | 'paused';
12170
+ platform: 'facebook' | 'instagram' | 'tiktok' | 'linkedin' | 'pinterest' | 'google' | 'twitter';
12171
+ };
12172
+ path: {
12173
+ /**
12174
+ * Platform ad set ID
12175
+ */
12176
+ adSetId: string;
12177
+ };
12178
+ };
12179
+
12180
+ export type UpdateAdSetStatusResponse = ({
12181
+ updated?: number;
12182
+ skipped?: number;
12183
+ });
12184
+
12185
+ export type UpdateAdSetStatusError = (unknown | {
12186
+ error?: string;
12187
+ });
12188
+
11815
12189
  export type GetAdTreeData = {
11816
12190
  query?: {
11817
12191
  /**
@@ -11839,6 +12213,9 @@ export type GetAdTreeData = {
11839
12213
  * Profile ID
11840
12214
  */
11841
12215
  profileId?: string;
12216
+ /**
12217
+ * `zernio` (default) returns only ads created via Zernio (isExternal=false). `all` additionally returns ads discovered from the platform's ad manager (isExternal=true). Status is NOT filtered by default — use the `status` param for that.
12218
+ */
11842
12219
  source?: 'zernio' | 'all';
11843
12220
  /**
11844
12221
  * Filter by derived campaign status (post-aggregation)