@bisibility/sdk 0.3.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/types.d.ts CHANGED
@@ -1,3 +1,27 @@
1
+ import type { PublicIdForPrefix } from "./public-id.js";
2
+ export type AlertId = PublicIdForPrefix<"alert">;
3
+ export type ApiKeyId = PublicIdForPrefix<"key">;
4
+ export type AuditId = PublicIdForPrefix<"audit">;
5
+ export type CloudImportJobId = PublicIdForPrefix<"job">;
6
+ export type CompetitorId = PublicIdForPrefix<"comp">;
7
+ export type ConnectionId = PublicIdForPrefix<"conn">;
8
+ export type IngestHookId = PublicIdForPrefix<"hook">;
9
+ export type InviteId = PublicIdForPrefix<"invite">;
10
+ export type KeywordId = PublicIdForPrefix<"kw">;
11
+ export type MembershipId = PublicIdForPrefix<"member">;
12
+ export type MigrationTokenId = PublicIdForPrefix<"mtok">;
13
+ export type NotificationId = PublicIdForPrefix<"notif">;
14
+ export type PersonalAccessTokenId = PublicIdForPrefix<"pat">;
15
+ export type ProjectId = PublicIdForPrefix<"prj">;
16
+ export type RankCheckId = PublicIdForPrefix<"check">;
17
+ export type SavedKeywordId = PublicIdForPrefix<"skw">;
18
+ export type SavedViewId = PublicIdForPrefix<"view">;
19
+ export type SessionId = PublicIdForPrefix<"ses">;
20
+ export type SignalId = PublicIdForPrefix<"sig">;
21
+ export type TagId = PublicIdForPrefix<"tag">;
22
+ export type UserId = PublicIdForPrefix<"usr">;
23
+ export type WebhookId = PublicIdForPrefix<"webhook">;
24
+ export type AlertRuleId = PublicIdForPrefix<"rule">;
1
25
  export type Device = "desktop" | "mobile";
2
26
  export type RankCheckFrequency = "paused" | "manual" | "daily" | "weekly" | "monthly" | "custom_cron";
3
27
  export type JsonObject = Record<string, unknown>;
@@ -31,7 +55,7 @@ export type ProjectWriteMode = "active" | "migration_hold" | "migrated";
31
55
  export interface Project {
32
56
  created_at: string;
33
57
  domain: string;
34
- id: string;
58
+ id: ProjectId;
35
59
  name: string;
36
60
  updated_at: string;
37
61
  write_mode: ProjectWriteMode;
@@ -50,7 +74,7 @@ export interface ProjectDefaults {
50
74
  last_checked_at: string | null;
51
75
  location_key: string;
52
76
  next_check_at: string | null;
53
- project_id: string;
77
+ project_id: ProjectId;
54
78
  serp_depth: number;
55
79
  serp_stop_on_match: boolean;
56
80
  source: "derived" | "explicit" | "fallback";
@@ -87,7 +111,7 @@ export interface ProjectOverview {
87
111
  last_check_at: string | null;
88
112
  next_check_at: string | null;
89
113
  position_distribution: ProjectOverviewPositionDistribution[];
90
- project_id: string;
114
+ project_id: ProjectId;
91
115
  top_10_count: number | null;
92
116
  top_10_delta: number | null;
93
117
  top_100_count: number | null;
@@ -106,7 +130,7 @@ export interface KeywordMatchMarket {
106
130
  location_key: string;
107
131
  }
108
132
  export interface KeywordMatch {
109
- keyword_id: string;
133
+ keyword_id: KeywordId;
110
134
  latest_position: number | null;
111
135
  market: KeywordMatchMarket;
112
136
  /** Trimmed, lowercase request text used to match this keyword. */
@@ -135,7 +159,6 @@ export interface LocationSuggestion {
135
159
  country_code: string;
136
160
  display_name: string;
137
161
  hl: string;
138
- id: string;
139
162
  kind: LocationKind;
140
163
  language_label: string;
141
164
  location_key: string;
@@ -158,26 +181,36 @@ export interface CreateProjectInput {
158
181
  }
159
182
  export interface ApiKey {
160
183
  created_at: string;
161
- id: string;
184
+ expires_at: string | null;
185
+ id: ApiKeyId;
162
186
  last_used_at: string | null;
163
187
  name: string;
164
188
  prefix: string;
165
189
  revoked_at: string | null;
190
+ scope: ApiKeyScope;
166
191
  }
167
192
  export interface CreatedApiKey extends ApiKey {
168
193
  masked_value: string;
169
194
  token: string;
170
195
  }
196
+ export type ApiKeyScope = "admin" | "read" | "write";
197
+ export interface CreateApiKeyInput {
198
+ /** Days until the key expires, or null for no expiry. */
199
+ expires_in_days?: 30 | 90 | 365 | null;
200
+ name: string;
201
+ /** Access tier. Defaults to admin for backward compatibility. */
202
+ scope?: ApiKeyScope;
203
+ }
171
204
  export type MembershipRole = "admin" | "auditor" | "member" | "owner" | "viewer";
172
205
  export interface MeProject {
173
206
  domain: string;
174
- id: string;
207
+ id: ProjectId;
175
208
  name: string;
176
209
  role: MembershipRole;
177
210
  }
178
211
  export interface Me {
179
212
  email: string;
180
- id: string;
213
+ id: UserId;
181
214
  name: string;
182
215
  projects: MeProject[];
183
216
  }
@@ -188,7 +221,7 @@ export type PersonalAccessTokenScope = "admin" | "read" | "write";
188
221
  export interface PersonalAccessToken {
189
222
  created_at: string;
190
223
  expires_at: string | null;
191
- id: string;
224
+ id: PersonalAccessTokenId;
192
225
  last_used_at: string | null;
193
226
  name: string;
194
227
  prefix: string;
@@ -210,7 +243,7 @@ export interface Webhook {
210
243
  created_at: string;
211
244
  description: string | null;
212
245
  enabled: boolean;
213
- id: string;
246
+ id: WebhookId;
214
247
  last_delivery_at: string | null;
215
248
  updated_at: string;
216
249
  url: string;
@@ -241,12 +274,12 @@ export interface Keyword {
241
274
  country: string;
242
275
  created_at: string;
243
276
  device: Device;
244
- id: string;
277
+ id: KeywordId;
245
278
  intent: string | null;
246
279
  latest_position: number | null;
247
280
  location: string;
248
281
  previous_position: number | null;
249
- project_id: string;
282
+ project_id: ProjectId;
250
283
  ranking_url: string | null;
251
284
  schedule: KeywordSchedule | null;
252
285
  tags: string[];
@@ -306,24 +339,24 @@ export interface UpdateKeywordInput {
306
339
  }
307
340
  export type KeywordBulkOperation = "add_tags" | "delete" | "remove_tags" | "set_frequency" | "set_target_url";
308
341
  export type KeywordBulkInput = {
309
- keyword_ids: readonly string[];
342
+ keyword_ids: readonly KeywordId[];
310
343
  operation: "add_tags" | "remove_tags";
311
344
  tags: readonly string[];
312
345
  } | {
313
- keyword_ids: readonly string[];
346
+ keyword_ids: readonly KeywordId[];
314
347
  operation: "delete";
315
348
  } | {
316
- keyword_ids: readonly string[];
349
+ keyword_ids: readonly KeywordId[];
317
350
  operation: "set_frequency";
318
351
  frequency?: RankCheckFrequency;
319
352
  schedule?: KeywordScheduleInput;
320
353
  } | {
321
- keyword_ids: readonly string[];
354
+ keyword_ids: readonly KeywordId[];
322
355
  operation: "set_target_url";
323
356
  target_url?: string | null;
324
357
  };
325
358
  export interface KeywordBulkItemResult {
326
- keyword_id: string;
359
+ keyword_id: KeywordId;
327
360
  status: OpenString<"deleted" | "not_found" | "updated">;
328
361
  }
329
362
  export interface KeywordBulkResponse {
@@ -349,7 +382,7 @@ export interface RankedKeywordSuggestion {
349
382
  search_volume: number | null;
350
383
  }
351
384
  export interface RankedKeywordConnection {
352
- id: string;
385
+ id: ConnectionId;
353
386
  label: string;
354
387
  provider: "dataforseo";
355
388
  }
@@ -363,7 +396,7 @@ export interface RankedKeywordSuggestionsResponse {
363
396
  total_count: number | null;
364
397
  }
365
398
  export interface ListRankedKeywordSuggestionsOptions {
366
- connectionId?: string;
399
+ connectionId?: ConnectionId;
367
400
  fresh?: boolean;
368
401
  limit?: number;
369
402
  offset?: number;
@@ -386,7 +419,7 @@ export interface KeywordMetricsRow extends KeywordMetrics {
386
419
  keyword: string;
387
420
  }
388
421
  export interface KeywordResearchConnection {
389
- id: string;
422
+ id: ConnectionId;
390
423
  label: string;
391
424
  provider: string;
392
425
  }
@@ -493,7 +526,7 @@ export interface KeywordResearchResponse {
493
526
  total_count: number;
494
527
  }
495
528
  export interface ResearchKeywordsOptions {
496
- connectionId?: string;
529
+ connectionId?: ConnectionId;
497
530
  estimateOnly?: boolean;
498
531
  fresh?: boolean;
499
532
  includeClickstream?: boolean;
@@ -503,7 +536,7 @@ export interface ResearchKeywordsOptions {
503
536
  seed: string;
504
537
  }
505
538
  export interface GetKeywordMetricsInput {
506
- connection_id?: string;
539
+ connection_id?: ConnectionId;
507
540
  estimate_only?: boolean;
508
541
  fresh?: boolean;
509
542
  include_clickstream?: boolean;
@@ -528,9 +561,9 @@ export type RankHistoryExportRange = "30" | "90" | "all";
528
561
  export type RankHistoryExportGranularity = "daily" | "weekly";
529
562
  export interface RankHistoryExportRow {
530
563
  checked_at: string;
531
- id: string;
564
+ id: RankCheckId;
532
565
  keyword: string;
533
- keyword_id: string;
566
+ keyword_id: KeywordId;
534
567
  position: number | null;
535
568
  previous_position: number | null;
536
569
  ranking_url: string | null;
@@ -538,7 +571,7 @@ export interface RankHistoryExportRow {
538
571
  export type RankHistoryExportResponse = ListResponse<RankHistoryExportRow>;
539
572
  interface RankHistoryExportOptions {
540
573
  granularity?: RankHistoryExportGranularity;
541
- keywordIds?: readonly string[];
574
+ keywordIds?: readonly KeywordId[];
542
575
  range?: RankHistoryExportRange;
543
576
  }
544
577
  export interface ExportRankHistoryJsonOptions extends PaginationOptions, RankHistoryExportOptions {
@@ -550,15 +583,14 @@ export interface ExportRankHistoryCsvOptions extends RankHistoryExportOptions {
550
583
  export type SitemapMonitorStatus = "active" | "disabled" | "pending";
551
584
  export interface SitemapMonitorSnapshot {
552
585
  fetched_at: string;
553
- id: string;
554
586
  sitemap_url: string;
555
587
  url_count: number;
556
588
  }
557
589
  export interface SitemapMonitor {
558
590
  enabled: boolean;
559
- id: string;
591
+ id: ProjectId;
560
592
  latest_snapshot: SitemapMonitorSnapshot | null;
561
- project_id: string;
593
+ project_id: ProjectId;
562
594
  sitemap_url: string | null;
563
595
  status: SitemapMonitorStatus;
564
596
  }
@@ -576,8 +608,8 @@ export interface RankCheck {
576
608
  checked_at: string;
577
609
  cost_cents: number | null;
578
610
  error: string | null;
579
- id: string;
580
- keyword_id: string;
611
+ id: RankCheckId;
612
+ keyword_id: KeywordId;
581
613
  position: number | null;
582
614
  previous_position: number | null;
583
615
  provider: string;
@@ -595,19 +627,11 @@ export interface RunRankCheckInput {
595
627
  export interface RunRankCheckOptions extends RequestOptions {
596
628
  async?: boolean;
597
629
  }
598
- export type AlertConditionType = "change_pct" | "competitor_overtake" | "enters_top_n" | "exits_top_n" | "serp_feature" | "threshold";
630
+ export type AlertConditionType = "change_pct" | "competitor_overtake" | "ctr_drop" | "downtrend" | "enters_top_n" | "exits_top_n" | "position_drop" | "serp_feature" | "threshold" | "url_mismatch";
599
631
  export type AlertChannel = "email" | "slack" | "webhook";
600
632
  export type AlertTargetType = "all" | "keyword" | "tag";
601
633
  export type AlertSeverity = "info" | "urgent" | "warning";
602
- export interface AlertRuleTarget {
603
- created_at?: string;
604
- id: string;
605
- keyword_id?: string | null;
606
- rule_id?: string;
607
- tag_id?: string | null;
608
- updated_at?: string;
609
- }
610
- export interface AlertRule {
634
+ interface AlertRuleBase {
611
635
  change_pct?: number | string | null;
612
636
  channel?: string;
613
637
  channels: AlertChannel[];
@@ -615,37 +639,54 @@ export interface AlertRule {
615
639
  condition_type: AlertConditionType;
616
640
  competitor_domain?: string | null;
617
641
  created_at?: string;
618
- created_by_id?: string | null;
619
642
  enabled: boolean;
620
643
  fires?: string;
621
- id: string;
644
+ id: AlertRuleId;
622
645
  name: string;
623
646
  period?: string;
624
- project_id?: string;
647
+ recipient_ids: UserId[];
625
648
  scope?: string;
626
649
  serp_feature?: string | null;
627
650
  severity?: AlertSeverity;
628
651
  status?: OpenString<"active" | "paused">;
629
- target_ids?: string[];
630
- target_type: AlertTargetType;
631
- targets?: AlertRuleTarget[];
632
652
  threshold_position?: number | null;
633
653
  top_n?: number | null;
634
654
  updated_at?: string;
635
655
  }
636
- export interface AlertRuleInput {
656
+ export type AlertRule = (AlertRuleBase & {
657
+ target_ids: KeywordId[];
658
+ target_type: "keyword";
659
+ }) | (AlertRuleBase & {
660
+ target_ids: TagId[];
661
+ target_type: "tag";
662
+ }) | (AlertRuleBase & {
663
+ target_ids: [];
664
+ target_type: "all";
665
+ });
666
+ interface AlertRuleInputBase {
637
667
  change_pct?: number | null;
638
668
  channels?: readonly AlertChannel[];
639
669
  condition_type: AlertConditionType;
640
670
  competitor_domain?: string | null;
671
+ drop_positions?: number | null;
641
672
  enabled?: boolean;
642
673
  name: string;
674
+ recipient_ids?: readonly UserId[];
643
675
  serp_feature?: string | null;
644
- target_ids?: readonly string[];
645
- target_type?: AlertTargetType;
676
+ severity?: AlertSeverity;
646
677
  threshold_position?: number | null;
647
678
  top_n?: number | null;
648
679
  }
680
+ export type AlertRuleInput = (AlertRuleInputBase & {
681
+ target_ids?: readonly [];
682
+ target_type?: "all";
683
+ }) | (AlertRuleInputBase & {
684
+ target_ids: readonly KeywordId[];
685
+ target_type: "keyword";
686
+ }) | (AlertRuleInputBase & {
687
+ target_ids: readonly TagId[];
688
+ target_type: "tag";
689
+ });
649
690
  export type CreateAlertRuleInput = AlertRuleInput;
650
691
  export type UpdateAlertRuleInput = AlertRuleInput;
651
692
  export interface DeleteAlertRuleResponse {
@@ -656,7 +697,7 @@ export interface TriggeredAlert {
656
697
  ctas: string[];
657
698
  current: string;
658
699
  headline: string;
659
- id: string;
700
+ id: AlertId;
660
701
  keyword: string;
661
702
  previous: string;
662
703
  rule: string;
@@ -676,7 +717,7 @@ export type TeamRoleLabel = "Admin" | "Editor" | "Owner" | "Viewer";
676
717
  export interface TeamMember {
677
718
  color: OpenString<"accent" | "blue" | "purple">;
678
719
  email: string;
679
- id: string;
720
+ id: MembershipId;
680
721
  initials: string;
681
722
  name: string;
682
723
  role: TeamRoleLabel;
@@ -685,7 +726,7 @@ export interface TeamMember {
685
726
  export interface TeamInvite {
686
727
  email: string;
687
728
  expires_label: string;
688
- id: string;
729
+ id: InviteId;
689
730
  invited_label: string;
690
731
  role: TeamRoleLabel;
691
732
  role_value: Exclude<TeamRole, "owner">;
@@ -696,26 +737,26 @@ export interface CreateTeamInviteInput {
696
737
  }
697
738
  export interface CreatedTeamInvite {
698
739
  expires_at: string;
699
- id: string;
740
+ id: InviteId;
700
741
  invite_link: string;
701
742
  }
702
743
  export interface RevokedTeamInvite {
703
- id: string;
744
+ id: InviteId;
704
745
  }
705
746
  export type AssignableTeamRole = Exclude<TeamRole, "owner">;
706
747
  export interface UpdateTeamMemberRoleInput {
707
748
  role: AssignableTeamRole;
708
749
  }
709
750
  export interface TeamMemberRoleResult {
710
- id: string;
751
+ id: MembershipId;
711
752
  role: AssignableTeamRole;
712
753
  }
713
754
  export interface TeamMemberMutationResult {
714
- id: string;
755
+ id: MembershipId;
715
756
  }
716
757
  export interface TeamInviteResendResult {
717
758
  expires_at: string;
718
- id: string;
759
+ id: InviteId;
719
760
  invite_link: string;
720
761
  }
721
762
  export type ProviderId = "dataforseo" | "ga4" | "gsc" | "plausible" | "serpapi";
@@ -799,12 +840,12 @@ export interface ProviderConnection {
799
840
  created_at: string;
800
841
  credentials_hash?: string | null;
801
842
  enabled: boolean;
802
- id: string;
843
+ id: ConnectionId;
803
844
  is_primary: boolean;
804
845
  kind: ProviderKind;
805
846
  last_used_at: string | null;
806
847
  priority: number;
807
- project_id: string;
848
+ project_id: ProjectId;
808
849
  provider: OpenString<ProviderId>;
809
850
  status: ProviderStatus;
810
851
  updated_at: string;
@@ -822,39 +863,69 @@ export type SavedViewFilterCountry = "all" | "de" | "gb" | "pl" | "us";
822
863
  export type SavedViewFilterDevice = "all" | Device;
823
864
  export type SavedViewPositionFilter = "11-50" | "51-100" | "top10" | "top3";
824
865
  export type SavedViewSerpFilter = "ai" | "featured" | "image" | "paa" | "sitelinks" | "video";
825
- export interface SavedViewFilters {
866
+ export interface KeywordSavedViewFilters {
826
867
  change: SavedViewFilterChange;
827
868
  contains: string;
828
- country: SavedViewFilterCountry;
829
- device: SavedViewFilterDevice;
869
+ intents: string[];
870
+ last_check: "any" | RankCheckStatus;
830
871
  position: SavedViewPositionFilter[];
831
872
  serp: SavedViewSerpFilter[];
832
873
  tags: string[];
874
+ topics: string[];
875
+ url_changed: boolean;
833
876
  vol_max: number;
834
877
  vol_min: number;
835
878
  wrong_url: boolean;
836
879
  }
837
- export interface SavedViewConfig {
838
- filters: SavedViewFilters;
880
+ export type SavedViewFilters = KeywordSavedViewFilters;
881
+ export interface KeywordSavedViewConfig {
882
+ filters: KeywordSavedViewFilters;
883
+ lens: {
884
+ device: SavedViewFilterDevice;
885
+ location_id: string | null;
886
+ };
839
887
  search: string;
888
+ surface: "keywords";
889
+ version: 1;
890
+ }
891
+ export interface CompetitorSavedViewConfig {
892
+ filters: {
893
+ excluded_keyword_ids: KeywordId[];
894
+ position: "all" | "top10" | "top3";
895
+ tag: string | null;
896
+ };
897
+ scope: {
898
+ device: Device;
899
+ engine: "google";
900
+ location_id: string;
901
+ };
902
+ surface: "competitors";
903
+ version: 1;
840
904
  }
905
+ export type SavedViewConfig = CompetitorSavedViewConfig | KeywordSavedViewConfig;
841
906
  export interface CreateSavedViewInput {
842
907
  config: SavedViewConfig;
843
908
  name: string;
909
+ surface?: SavedViewSurface;
910
+ }
911
+ export type SavedViewSurface = "competitors" | "keywords";
912
+ export interface ListSavedViewsOptions extends PaginationOptions {
913
+ surface?: SavedViewSurface;
844
914
  }
845
915
  export interface SavedView {
846
916
  config: SavedViewConfig;
847
917
  created_at: string;
848
- created_by_id: string | null;
849
- id: string;
918
+ created_by_id: UserId | null;
919
+ id: SavedViewId;
850
920
  name: string;
921
+ surface: SavedViewSurface;
851
922
  }
852
923
  export interface DeleteSavedViewResponse {
853
924
  deleted: boolean;
854
925
  }
855
926
  export interface Competitor {
856
927
  domain: string;
857
- id: string;
928
+ id: CompetitorId;
858
929
  initials?: string;
859
930
  label: string | null;
860
931
  }
@@ -868,14 +939,14 @@ export interface RemoveCompetitorResponse {
868
939
  export type CompetitorKind = "Managed" | "You";
869
940
  export interface CompetitorColumn {
870
941
  domain: string;
871
- id?: string;
942
+ id?: CompetitorId;
872
943
  kind: CompetitorKind;
873
944
  label: string;
874
945
  }
875
946
  export interface CompetitorShare {
876
947
  color: string;
877
948
  domain: string;
878
- id?: string;
949
+ id?: CompetitorId;
879
950
  initials: string;
880
951
  kind: CompetitorKind;
881
952
  label: string;
@@ -885,8 +956,11 @@ export interface CompetitorShare {
885
956
  export interface HeadToHeadRow {
886
957
  gap: number | null;
887
958
  keyword: string;
888
- ranks: Record<string, number | null>;
959
+ ranks: CompetitorRankMap;
889
960
  }
961
+ export type CompetitorRankMap = {
962
+ you?: number | null;
963
+ } & Partial<Record<CompetitorId, number | null>>;
890
964
  export interface CompetitorMarket {
891
965
  checked_keyword_count: number;
892
966
  columns: CompetitorColumn[];
@@ -926,7 +1000,7 @@ export interface NotificationPreferences {
926
1000
  import_in_app: boolean;
927
1001
  invite_email: boolean;
928
1002
  invite_in_app: boolean;
929
- project_id: string;
1003
+ project_id: ProjectId;
930
1004
  slack_available?: boolean;
931
1005
  webhook_available?: boolean;
932
1006
  }
@@ -943,10 +1017,8 @@ export interface PageTrafficSnapshot {
943
1017
  created_at: string;
944
1018
  date: string;
945
1019
  engagement_rate: number | null;
946
- id: string;
947
1020
  key_events: number | null;
948
1021
  path: string;
949
- project_id: string;
950
1022
  provider: string;
951
1023
  scroll_depth: number | null;
952
1024
  sessions: number;
@@ -961,14 +1033,14 @@ export interface PageTrafficSnapshotsResponse {
961
1033
  total_count: number;
962
1034
  }
963
1035
  export interface ListSearchPerformanceQueryStatsOptions {
964
- connectionId?: string;
1036
+ connectionId?: ConnectionId;
965
1037
  endDate: Date | string;
966
1038
  limit?: number;
967
1039
  query?: string;
968
1040
  startDate: Date | string;
969
1041
  }
970
1042
  export interface AnalyticsConnection {
971
- id: string;
1043
+ id: ConnectionId;
972
1044
  label: string;
973
1045
  provider: string;
974
1046
  }
@@ -986,7 +1058,7 @@ export interface SearchPerformanceQueryStatsResponse {
986
1058
  }
987
1059
  export type TrafficSyncRunStatus = "succeeded_with_data" | "succeeded_empty" | "deferred_rate_limit" | "failed" | "not_applicable";
988
1060
  export interface TrafficSyncRun {
989
- connection_id: string;
1061
+ connection_id: ConnectionId;
990
1062
  error?: string;
991
1063
  error_class?: string;
992
1064
  provider: string;
@@ -1005,7 +1077,7 @@ export interface TrafficSyncSummary {
1005
1077
  connections: number;
1006
1078
  keyword_snapshots: number;
1007
1079
  page_snapshots: number;
1008
- project_id: string;
1080
+ project_id: ProjectId;
1009
1081
  runs: TrafficSyncRun[];
1010
1082
  skipped: TrafficSyncSkippedConnection[];
1011
1083
  }
@@ -1016,7 +1088,7 @@ export interface CloudImportJob {
1016
1088
  created_at: string | null;
1017
1089
  error: string | null;
1018
1090
  finished_at: string | null;
1019
- id: string | null;
1091
+ id: CloudImportJobId | null;
1020
1092
  progress: number;
1021
1093
  started_at: string | null;
1022
1094
  state: CloudImportState;
@@ -1028,7 +1100,7 @@ export interface ActiveMigrationToken {
1028
1100
  name: string;
1029
1101
  };
1030
1102
  expires_at: string;
1031
- id: string;
1103
+ id: MigrationTokenId;
1032
1104
  scope: MigrationScope;
1033
1105
  single_use: boolean;
1034
1106
  }
@@ -1040,7 +1112,7 @@ export interface MintMigrationTokenInput {
1040
1112
  scope?: MigrationScope;
1041
1113
  }
1042
1114
  export interface RevokedMigrationToken {
1043
- id: string;
1115
+ id: MigrationTokenId;
1044
1116
  revoked_at: string;
1045
1117
  }
1046
1118
  export interface MigrationTokenListMeta extends ListMeta {
@@ -1049,7 +1121,7 @@ export interface MigrationTokenListMeta extends ListMeta {
1049
1121
  export interface MigrationTokenListResponse extends ListResponse<ActiveMigrationToken> {
1050
1122
  meta: MigrationTokenListMeta;
1051
1123
  }
1052
- export type CloudImportSchemaVersion = 1 | 2 | 3;
1124
+ export type CloudImportSchemaVersion = 4;
1053
1125
  export type CloudImportLocation = "Australia" | "Austria" | "Belgium" | "Brazil" | "Canada" | "Denmark" | "Finland" | "France" | "Germany" | "India" | "Ireland" | "Italy" | "Japan" | "Mexico" | "Netherlands" | "New Zealand" | "Norway" | "Poland" | "Portugal" | "Singapore" | "South Africa" | "Spain" | "Sweden" | "Switzerland" | "United Arab Emirates" | "United Kingdom" | "United States";
1054
1126
  export interface CloudImportCompatibility {
1055
1127
  app_version: string;
@@ -1063,121 +1135,92 @@ export interface CloudImportRankingHistory {
1063
1135
  rankingUrl?: string | null;
1064
1136
  }
1065
1137
  export interface CloudImportKeyword {
1066
- country?: CloudImportLocation;
1067
- device?: Device;
1068
- id?: string;
1069
- keyword?: string;
1070
- location?: CloudImportLocation;
1138
+ device: Device;
1139
+ id: KeywordId;
1140
+ keyword: string;
1141
+ location: CloudImportLocation;
1071
1142
  rankingHistory?: CloudImportRankingHistory[];
1072
1143
  tags?: string[];
1073
1144
  target_url?: string | null;
1074
- targetUrl?: string | null;
1075
- text?: string;
1076
1145
  }
1077
1146
  export interface CloudImportCompetitor {
1078
1147
  domain: string;
1148
+ id: CompetitorId;
1079
1149
  label?: string | null;
1080
1150
  }
1081
1151
  export interface CloudImportSavedView {
1082
1152
  config?: unknown;
1153
+ id: SavedViewId;
1083
1154
  name: string;
1084
1155
  surface?: "competitors" | "keywords";
1085
1156
  }
1086
1157
  export type CloudImportAlertChannel = "email" | "slack" | "webhook";
1087
- export type CloudImportAlertConditionType = "change_pct" | "competitor_overtake" | "enters_top_n" | "exits_top_n" | "serp_feature" | "threshold";
1158
+ export type CloudImportAlertConditionType = "change_pct" | "competitor_overtake" | "ctr_drop" | "downtrend" | "enters_top_n" | "exits_top_n" | "position_drop" | "serp_feature" | "threshold" | "url_mismatch";
1088
1159
  export type CloudImportAlertTargetType = "all" | "keyword" | "tag";
1089
- export interface CloudImportAlertRuleTarget {
1160
+ export interface CloudImportKeywordAlertTarget {
1090
1161
  device?: Device;
1091
1162
  keyword?: string;
1092
- keyword_id?: string;
1093
- keywordId?: string;
1163
+ keyword_id: KeywordId;
1094
1164
  location?: CloudImportLocation;
1095
- tag?: string;
1096
- tag_id?: string;
1097
- tagId?: string;
1098
- type?: "keyword" | "tag";
1165
+ type: "keyword";
1166
+ }
1167
+ export interface CloudImportTagAlertTarget {
1168
+ tag: string;
1169
+ type: "tag";
1099
1170
  }
1171
+ export type CloudImportAlertRuleTarget = CloudImportKeywordAlertTarget | CloudImportTagAlertTarget;
1100
1172
  export interface CloudImportAlertRule {
1101
1173
  change_pct?: number | null;
1102
- changePct?: number | null;
1103
1174
  channels?: CloudImportAlertChannel[];
1104
1175
  competitor_domain?: string | null;
1105
- competitorDomain?: string | null;
1106
1176
  condition_type?: CloudImportAlertConditionType;
1107
- conditionType?: CloudImportAlertConditionType;
1177
+ drop_positions?: number | null;
1108
1178
  enabled?: boolean;
1179
+ id: AlertRuleId;
1109
1180
  name: string;
1110
1181
  serp_feature?: string | null;
1111
- serpFeature?: string | null;
1112
1182
  target_type?: CloudImportAlertTargetType;
1113
1183
  targets?: CloudImportAlertRuleTarget[];
1114
- targetType?: CloudImportAlertTargetType;
1115
1184
  threshold_position?: number | null;
1116
- thresholdPosition?: number | null;
1117
1185
  top_n?: number | null;
1118
- topN?: number | null;
1119
1186
  }
1120
1187
  export interface CloudImportNotificationPreference {
1121
1188
  alert_email?: boolean;
1122
1189
  alert_in_app?: boolean;
1123
- alertEmail?: boolean;
1124
- alertInApp?: boolean;
1125
1190
  check_email?: boolean;
1126
1191
  check_in_app?: boolean;
1127
- checkEmail?: boolean;
1128
- checkInApp?: boolean;
1129
1192
  import_email?: boolean;
1130
1193
  import_in_app?: boolean;
1131
- importEmail?: boolean;
1132
- importInApp?: boolean;
1133
1194
  invite_email?: boolean;
1134
1195
  invite_in_app?: boolean;
1135
- inviteEmail?: boolean;
1136
- inviteInApp?: boolean;
1137
- }
1138
- export interface CloudImportTopLevelRankCheck {
1139
- checked_at?: string;
1140
- checkedAt?: string;
1141
- keyword?: string;
1142
- keyword_id?: string;
1143
- keywordId?: string;
1144
- position?: number | null;
1145
- previous_position?: number | null;
1146
- previousPosition?: number | null;
1147
- ranking_url?: string | null;
1148
- rankingUrl?: string | null;
1149
- text?: string;
1196
+ report_email?: boolean;
1150
1197
  }
1151
1198
  export type CloudImportScope = "current" | "history";
1152
1199
  export interface CloudImportPackage {
1153
- alert_rules?: CloudImportAlertRule[];
1154
- alertRules?: CloudImportAlertRule[];
1155
- competitors?: CloudImportCompetitor[];
1156
- exportedAt?: string;
1157
- keywords?: CloudImportKeyword[];
1158
- notification_preferences?: CloudImportNotificationPreference[];
1159
- notificationPreferences?: CloudImportNotificationPreference[];
1160
- projectId?: string;
1161
- rank_checks?: CloudImportTopLevelRankCheck[];
1162
- saved_views?: CloudImportSavedView[];
1163
- savedViews?: CloudImportSavedView[];
1200
+ alert_rules: CloudImportAlertRule[];
1201
+ competitors: CloudImportCompetitor[];
1202
+ exported_at?: string;
1203
+ keywords: CloudImportKeyword[];
1204
+ notification_preferences: CloudImportNotificationPreference[];
1205
+ project_id: ProjectId;
1206
+ saved_views: CloudImportSavedView[];
1164
1207
  scope?: CloudImportScope;
1165
- version?: number;
1166
- [key: string]: unknown;
1208
+ version: CloudImportSchemaVersion;
1167
1209
  }
1168
1210
  export type CloudImportCounts = Record<string, number>;
1169
1211
  export interface CloudImportFinalizeResponse {
1170
1212
  counts: CloudImportCounts;
1171
- job_id: string;
1213
+ job_id: CloudImportJobId;
1172
1214
  state: "done";
1173
1215
  }
1174
1216
  export interface CloudImportSessionCreate {
1175
1217
  chunk_count: number;
1218
+ source_project_id: ProjectId;
1176
1219
  totals?: {
1177
1220
  keywords?: number;
1178
1221
  rank_checks?: number;
1179
1222
  };
1180
- version: 3;
1223
+ version: CloudImportSchemaVersion;
1181
1224
  }
1182
1225
  export interface CloudImportSessionCreateResponse {
1183
1226
  chunk_limits: {
@@ -1185,7 +1228,7 @@ export interface CloudImportSessionCreateResponse {
1185
1228
  max_history_rows: number;
1186
1229
  max_keywords: number;
1187
1230
  };
1188
- session_id: string;
1231
+ session_id: CloudImportJobId;
1189
1232
  state: "receiving";
1190
1233
  }
1191
1234
  export interface CloudImportSourceKeyword {
@@ -1195,15 +1238,10 @@ export interface CloudImportSourceKeyword {
1195
1238
  }
1196
1239
  export interface CloudImportSessionSections {
1197
1240
  alert_rules?: CloudImportAlertRule[];
1198
- alertRules?: CloudImportAlertRule[];
1199
1241
  competitors?: CloudImportCompetitor[];
1200
1242
  notification_preferences?: CloudImportNotificationPreference[];
1201
- notificationPreferences?: CloudImportNotificationPreference[];
1202
1243
  saved_views?: CloudImportSavedView[];
1203
- savedViews?: CloudImportSavedView[];
1204
- source_keyword_ids?: Record<string, CloudImportSourceKeyword>;
1205
- sourceKeywordIds?: Record<string, CloudImportSourceKeyword>;
1206
- [key: string]: unknown;
1244
+ source_keyword_ids?: Partial<Record<KeywordId, CloudImportSourceKeyword>>;
1207
1245
  }
1208
1246
  export interface CloudImportKeywordsChunk {
1209
1247
  checksum: string;
@@ -1231,11 +1269,11 @@ export type SignalSeverity = "critical" | "info" | "warning";
1231
1269
  export interface Signal {
1232
1270
  created_at: string;
1233
1271
  happened_at: string;
1234
- id: string;
1235
- keyword_id: string | null;
1272
+ id: SignalId;
1273
+ keyword_id: KeywordId | null;
1236
1274
  payload: JsonObject | null;
1237
- project_id: string;
1238
- public_id: string;
1275
+ project_id: ProjectId;
1276
+ public_id: SignalId;
1239
1277
  severity: SignalSeverity;
1240
1278
  source: SignalSource;
1241
1279
  type: string;
@@ -1244,7 +1282,7 @@ export interface Signal {
1244
1282
  export interface CreateSignalInput {
1245
1283
  /** ISO-8601 date-time when the signal happened. Defaults to now on the server. */
1246
1284
  happened_at?: string;
1247
- keyword_id?: string;
1285
+ keyword_id?: KeywordId;
1248
1286
  /** JSON object payload. Ingestion rejects serialized payloads above 8KB. */
1249
1287
  payload?: JsonObject;
1250
1288
  severity?: SignalSeverity;
@@ -1366,10 +1404,10 @@ export interface BisibilityClientConfig {
1366
1404
  /** Number of retries after the initial attempt. Defaults to 2; 0 disables retries. */
1367
1405
  maxRetries?: number;
1368
1406
  /**
1369
- * Project id or public id sent as the X-Bisibility-Project header on every request.
1407
+ * Project public ID sent as the X-Bisibility-Project header on every request.
1370
1408
  * Targets personal access token requests at a project on routes without one in the path.
1371
1409
  */
1372
- projectId?: string;
1410
+ projectId?: ProjectId;
1373
1411
  /** Per-attempt timeout in milliseconds. Defaults to 30 seconds; null disables it. */
1374
1412
  timeout?: number | null;
1375
1413
  }