signalbird 1.9.2 → 2.0.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/index.d.ts CHANGED
@@ -10,13 +10,18 @@
10
10
  type Level = 'debug' | 'info' | 'warn' | 'error' | 'critical';
11
11
  interface SignalbirdConfig {
12
12
  /**
13
- * Sunucu anahtarı (`sbr_live_…`).
13
+ * Gizli domain anahtarı (`sb_secret_live_…`) — `SIGNALBIRD_DOMAIN_KEY`.
14
14
  *
15
15
  * Bu anahtar GİZLİDİR ve tarayıcıya gömülemez: sunucu `Origin` başlığı taşıyan
16
- * istekleri reddeder. Tarayıcı için `signalbird/browser` ve açık anahtar
17
- * (`sbr_pub_…`) kullanılır.
16
+ * istekleri reddeder (401 `SECRET_KEY_IN_BROWSER`). Tarayıcı için
17
+ * `signalbird/browser` ve açık anahtar (`sb_public_live_…`) kullanılır.
18
+ *
19
+ * v2 (1 Eyl 2026): eskiden `apiKey` idi ve yüzey başına ayrı bir anahtar
20
+ * ailesi vardı (`sbr_live_`, `sb_`, `sbw_pub_`, `sbp_live_`). Hepsi tek
21
+ * anahtara indi — sözleşme:
22
+ * ../signalbird.api/docs/KEY_ARCHITECTURE_2026-09-01.md
18
23
  */
19
- apiKey: string;
24
+ domainKey: string;
20
25
  /** Varsayılan: https://live.signalbird.io/api */
21
26
  baseUrl?: string;
22
27
  /** Her olaya eklenen köken adı (sunucu adı, servis adı). */
@@ -35,7 +40,14 @@ interface SignalbirdConfig {
35
40
  debug?: boolean;
36
41
  }
37
42
  interface LogInput {
38
- channel: string;
43
+ /**
44
+ * Modül anahtarı — panelde açtığınız kanalın adı (`penyuSatisBildirimi`).
45
+ *
46
+ * Gizli DEĞİLDİR ve kodun içinde durur: domain anahtarı olmadan hiçbir işe
47
+ * yaramaz. Tanımsız bir ad gönderirseniz kanal SESSİZ olarak açılır — kayıt
48
+ * düşmez, ama bildirim de gitmez; kuralı panelden siz koyarsınız.
49
+ */
50
+ key: string;
39
51
  message: string;
40
52
  level?: Level;
41
53
  context?: Record<string, unknown>;
@@ -95,11 +107,11 @@ declare class SignalbirdClient {
95
107
  * durum değil satır satır döner.
96
108
  */
97
109
  batch(events: LogInput[]): Promise<BatchResult>;
98
- debugLog(channel: string, message: string, context?: Record<string, unknown>): Promise<LogResult>;
99
- info(channel: string, message: string, context?: Record<string, unknown>): Promise<LogResult>;
100
- warn(channel: string, message: string, context?: Record<string, unknown>): Promise<LogResult>;
101
- error(channel: string, message: string, context?: Record<string, unknown>): Promise<LogResult>;
102
- critical(channel: string, message: string, context?: Record<string, unknown>): Promise<LogResult>;
110
+ debugLog(key: string, message: string, context?: Record<string, unknown>): Promise<LogResult>;
111
+ info(key: string, message: string, context?: Record<string, unknown>): Promise<LogResult>;
112
+ warn(key: string, message: string, context?: Record<string, unknown>): Promise<LogResult>;
113
+ error(key: string, message: string, context?: Record<string, unknown>): Promise<LogResult>;
114
+ critical(key: string, message: string, context?: Record<string, unknown>): Promise<LogResult>;
103
115
  /**
104
116
  * Yakalanmamış hataları Telsiz'e bağlar.
105
117
  *
@@ -107,7 +119,7 @@ declare class SignalbirdClient {
107
119
  * süreci ayakta tutmak, bozuk durumdaki bir uygulamayı çalıştırmaya devam
108
120
  * etmek demektir — log göndermek bunu meşrulaştırmaz.
109
121
  */
110
- captureUncaught(channel?: string): () => void;
122
+ captureUncaught(key?: string): () => void;
111
123
  private send;
112
124
  private request;
113
125
  }
@@ -121,7 +133,7 @@ declare class SignalbirdClient {
121
133
  */
122
134
  interface MessagingConfig {
123
135
  /** Takım API anahtarı (`sb_…`). GİZLİDİR, yalnız sunucuda kullanılır. */
124
- apiKey: string;
136
+ domainKey: string;
125
137
  /** Varsayılan: https://live.signalbird.io/api */
126
138
  baseUrl?: string;
127
139
  /** İstek zaman aşımı (ms). Varsayılan 15000 — toplu kişi yükleme uzun sürebilir. */
@@ -335,7 +347,7 @@ interface Paginated$1<T> {
335
347
  type MessagingErrorCode = 'API_KEY_MISSING' | 'API_KEY_INVALID' | 'API_KEY_SCOPE' | 'API_KEY_IP_BLOCKED' | 'API_KEY_NO_TEAM' | 'MODULE_DISABLED' | 'LIMIT_REACHED' | 'OVERAGE_CEILING_REACHED' | 'SUPPRESSED' | 'NO_CONSENT' | 'NO_SENDING_DOMAIN' | 'INVALID_PHONE' | 'LIST_NOT_FOUND' | 'NO_RECIPIENTS' | 'ALREADY_FINISHED' | 'NETWORK_ERROR' | 'TIMEOUT' | 'VALIDATION_ERROR' | (string & {});
336
348
 
337
349
  declare class SignalbirdMessaging {
338
- private readonly apiKey;
350
+ private readonly domainKey;
339
351
  private readonly baseUrl;
340
352
  private readonly timeout;
341
353
  private readonly throwOnError;
@@ -421,7 +433,7 @@ interface SbResult<T = unknown> {
421
433
 
422
434
  interface PartnerConfig {
423
435
  /** `sbp_live_…` — sözleşmeli partner anahtarı. Tarayıcıya İNMEZ. */
424
- apiKey: string;
436
+ domainKey: string;
425
437
  baseUrl?: string;
426
438
  timeout?: number;
427
439
  throwOnError?: boolean;
@@ -572,7 +584,7 @@ interface EmbedToken {
572
584
 
573
585
  interface ManagementConfig {
574
586
  /** Takım API anahtarı (`sb_…`) — `radio:*`, `chat:*`, `apps:*` scope'larıyla. */
575
- apiKey: string;
587
+ domainKey: string;
576
588
  /** Varsayılan: https://live.signalbird.io/api */
577
589
  baseUrl?: string;
578
590
  /** İstek zaman aşımı (ms). Varsayılan 15000. */
@@ -590,64 +602,64 @@ interface Paginated<T> {
590
602
  total?: number;
591
603
  }
592
604
  type RadioLevel = 'debug' | 'info' | 'warn' | 'error' | 'critical';
593
- interface RadioProject {
594
- id: number;
595
- name: string;
596
- slug?: string;
597
- description?: string | null;
598
- /** Gizli anahtarın tanınacak kadarı; tamamı yalnız oluşturmada döner. */
599
- secret_hint?: string | null;
600
- public_key?: string | null;
601
- is_active?: boolean;
602
- channels_count?: number;
603
- events_count?: number;
604
- last_event_at?: string | null;
605
- channels?: RadioChannel[];
606
- }
607
- interface RadioChannel {
605
+ /** Modül anahtarı taşıyan modüller (`monitoring`/`servers` taşımaz). */
606
+ type KeyedModule = 'logger' | 'email' | 'sms' | 'push' | 'chat';
607
+ type ModuleKeyLevel = 'debug' | 'info' | 'warn' | 'error' | 'critical';
608
+ /** Bildirim kanalı — seçim KANAL düzeyindedir, kişi başına değil. */
609
+ type NotifyChannel = 'push' | 'email';
610
+ /**
611
+ * Modül anahtarı — kodun içine gömülen kanal adı.
612
+ *
613
+ * Gizli DEĞİLDİR: domain anahtarı olmadan hiçbir işe yaramaz. Domain
614
+ * anahtarına referans da VERMEZ — anahtar yenilendiğinde bu kayıtlar
615
+ * bozulmasın diye (KEY_ARCHITECTURE §2).
616
+ */
617
+ interface ModuleKey {
608
618
  id: number;
619
+ module: KeyedModule;
609
620
  key: string;
610
- name: string;
611
- description?: string | null;
612
- level?: RadioLevel;
613
- notify_push?: boolean;
614
- notify_email?: boolean;
615
- recipient_user_ids?: number[] | null;
616
- quiet_from?: number | null;
617
- quiet_to?: number | null;
618
- dedupe_seconds?: number;
619
- is_active?: boolean;
620
- is_auto?: boolean;
621
- }
622
- interface CreateRadioProjectInput {
623
- name: string;
624
- }
625
- interface UpdateRadioProjectInput {
626
- name?: string;
627
- description?: string | null;
628
- is_active?: boolean;
629
- /** Tarayıcıdan yazılabilen kanallar ve izinli kökenler. */
630
- browser_channels?: string[] | null;
631
- allowed_origins?: string[] | null;
632
- }
633
- interface RadioChannelInput {
634
- key?: string;
635
- name?: string;
636
- description?: string | null;
637
- level?: RadioLevel;
638
- notify_push?: boolean;
639
- notify_email?: boolean;
640
- recipient_user_ids?: number[] | null;
621
+ title: string;
622
+ /** Ad değiştiyse eskisi bu tarihe kadar kabul edilir. */
623
+ previous_key: string | null;
624
+ previous_key_until: string | null;
625
+ domain_id: number | null;
626
+ level: ModuleKeyLevel;
627
+ icon: string | null;
628
+ color: string | null;
629
+ notify: NotifyChannel[];
630
+ /** Boş = takımın tamamı. */
631
+ recipient_user_ids: number[];
632
+ quiet_from: number | null;
633
+ quiet_to: number | null;
634
+ dedupe_seconds: number;
635
+ config: Record<string, unknown> | null;
636
+ /** İlk çağrıda kendiliğinden açıldıysa işaretlidir ve SESSİZDİR. */
637
+ is_auto: boolean;
638
+ is_active: boolean;
639
+ last_used_at: string | null;
640
+ usage_count: number;
641
+ conversations_count?: number | null;
642
+ devices_count?: number | null;
643
+ created_at: string;
644
+ }
645
+ interface ModuleKeyInput {
646
+ title?: string;
647
+ /** Verilmezse başlıktan üretilir; çakışırsa sonuna sayı eklenir. */
648
+ key?: string | null;
649
+ /** Ad değişiminde eski adı 30 gün kabul et (varsayılan `true`). */
650
+ keep_previous?: boolean;
651
+ domain_id?: number | null;
652
+ level?: ModuleKeyLevel;
653
+ icon?: string | null;
654
+ color?: string | null;
655
+ notify?: NotifyChannel[];
656
+ recipient_user_ids?: number[];
641
657
  quiet_from?: number | null;
642
658
  quiet_to?: number | null;
643
659
  dedupe_seconds?: number;
660
+ config?: Record<string, unknown> | null;
644
661
  is_active?: boolean;
645
662
  }
646
- /** Proje açılışı: gizli anahtar YALNIZ burada döner, bir daha okunamaz. */
647
- interface RadioProjectCreated {
648
- project: RadioProject;
649
- secret: string;
650
- }
651
663
  interface RadioEvent {
652
664
  id: string;
653
665
  channel?: string;
@@ -758,29 +770,6 @@ interface CannedReplyInput {
758
770
  body?: string;
759
771
  }
760
772
  type AppPlatform = 'web' | 'ios' | 'android' | 'other';
761
- interface AppRecord {
762
- id: number;
763
- name: string;
764
- platform: AppPlatform;
765
- /** `sbw_pub_…` — açık anahtar, zaten istemciye gömülür. */
766
- public_key: string;
767
- allowed_origins?: string[] | null;
768
- chat_enabled?: boolean;
769
- push_enabled?: boolean;
770
- is_active?: boolean;
771
- settings?: Record<string, unknown> | null;
772
- devices_count?: number;
773
- conversations_count?: number;
774
- }
775
- interface AppInput {
776
- name?: string;
777
- platform?: AppPlatform;
778
- allowed_origins?: string[] | null;
779
- chat_enabled?: boolean;
780
- push_enabled?: boolean;
781
- is_active?: boolean;
782
- settings?: Record<string, unknown> | null;
783
- }
784
773
  interface AppDevice {
785
774
  id: number;
786
775
  /** Maskeli token — tamamı hiçbir zaman dönmez. */
@@ -922,38 +911,35 @@ declare class SignalbirdManagement {
922
911
  radioSummary(): Promise<SbResult<Record<string, unknown>>>;
923
912
  /** Olay akışı — kanal, seviye ve tarihe göre süzülür. */
924
913
  radioEvents(query?: ListRadioEventsQuery): Promise<SbResult<Paginated<RadioEvent>>>;
925
- listRadioProjects(): Promise<SbResult<{
926
- data: RadioProject[];
914
+ listModuleKeys(module: KeyedModule, query?: {
915
+ domain_id?: number;
916
+ }): Promise<SbResult<{
917
+ data: ModuleKey[];
918
+ }>>;
919
+ getModuleKey(module: KeyedModule, id: number | string): Promise<SbResult<{
920
+ module_key: ModuleKey;
927
921
  }>>;
928
922
  /**
929
- * Proje açar.
923
+ * Kanal açar.
930
924
  *
931
- * Dönen `secret` (`sbr_live_…`) YALNIZ BURADA görünür: sunucuda yalnız
932
- * SHA-256 özeti saklanır. Kaybedilirse `rotateRadioSecret` ile yenilenir.
925
+ * `key` verilmezse başlıktan üretilir ve çakışırsa sonuna sayı eklenir —
926
+ * "bu ad alınmış" hatasıyla geri dönmek, CI'da kanal açan bir betiği
927
+ * durdururdu.
933
928
  */
934
- createRadioProject(input: CreateRadioProjectInput): Promise<SbResult<RadioProjectCreated>>;
935
- getRadioProject(id: number | string): Promise<SbResult<{
936
- project: RadioProject;
937
- }>>;
938
- updateRadioProject(id: number | string, input: UpdateRadioProjectInput): Promise<SbResult<{
939
- project: RadioProject;
940
- }>>;
941
- deleteRadioProject(id: number | string): Promise<SbResult<unknown>>;
942
- /** Gizli anahtarı yeniler; eski anahtar ANINDA geçersizleşir. */
943
- rotateRadioSecret(id: number | string): Promise<SbResult<{
944
- secret: string;
945
- }>>;
946
- createRadioChannel(projectId: number | string, input: RadioChannelInput): Promise<SbResult<{
947
- channel: RadioChannel;
929
+ createModuleKey(module: KeyedModule, input: ModuleKeyInput): Promise<SbResult<{
930
+ module_key: ModuleKey;
948
931
  }>>;
949
932
  /**
950
- * Kanalı günceller. `key` DEĞİŞMEZ — müşterinin kodundaki `log('critical', …)`
951
- * çağrısı ona bağlıdır; sunucu gönderilse de yok sayar.
933
+ * Kanalı günceller.
934
+ *
935
+ * `key` DEĞİŞTİRİLEBİLİR (eskiden değişmezdi): eski ad 30 gün daha kabul
936
+ * edilir, böylece üretimdeki kod bir sonraki deploya kadar kayıt kaybetmez.
937
+ * `keep_previous: false` ile eski ad anında kapatılır.
952
938
  */
953
- updateRadioChannel(projectId: number | string, channelId: number | string, input: RadioChannelInput): Promise<SbResult<{
954
- channel: RadioChannel;
939
+ updateModuleKey(module: KeyedModule, id: number | string, input: ModuleKeyInput): Promise<SbResult<{
940
+ module_key: ModuleKey;
955
941
  }>>;
956
- deleteRadioChannel(projectId: number | string, channelId: number | string): Promise<SbResult<unknown>>;
942
+ deleteModuleKey(module: KeyedModule, id: number | string): Promise<SbResult<unknown>>;
957
943
  chatSummary(): Promise<SbResult<Record<string, unknown>>>;
958
944
  /** Kısa aralıklı yoklama için: yalnız değişenler + çevrimiçi ajanlar. */
959
945
  chatUpdates(): Promise<SbResult<Record<string, unknown>>>;
@@ -1030,22 +1016,17 @@ declare class SignalbirdManagement {
1030
1016
  * Veri yoksa süreler `null` döner — 0 DEĞİL.
1031
1017
  */
1032
1018
  chatReport(range?: ChatReportRange): Promise<SbResult<ChatReport>>;
1033
- listApps(): Promise<SbResult<AppRecord[]>>;
1034
- /** Yanıttaki `public_key` (`sbw_pub_…`) istemciye gömülür; gizli değildir. */
1035
- createApp(input: AppInput): Promise<SbResult<AppRecord>>;
1036
- getApp(id: number | string): Promise<SbResult<AppRecord>>;
1037
- updateApp(id: number | string, input: AppInput): Promise<SbResult<AppRecord>>;
1038
- deleteApp(id: number | string): Promise<SbResult<unknown>>;
1039
- /** Açık anahtarı yeniler; siteye gömülü eski anahtar ANINDA çalışmaz olur. */
1040
- rotateAppKey(id: number | string): Promise<SbResult<AppRecord>>;
1041
1019
  /**
1042
1020
  * Gömme jetonu — Signalbird ekranını KENDİ panelinizde göstermek için.
1043
1021
  *
1044
1022
  * 120 saniye yaşar ve TEK KULLANIMLIKTIR: dönen `url`'i doğrudan bir
1045
- * iframe'e verin, saklamayın. Anahtar `embed:issue` kapsamı ister.
1023
+ * iframe'e verin, saklamayın. Anahtarın `can_issue_embed` onayı ŞARTTIR —
1024
+ * scope sisteminden geriye kalan tek kapı, çünkü jeton 60 dakikalık bir
1025
+ * panel oturumuna çevriliyor.
1046
1026
  */
1047
1027
  embedToken(input: TeamEmbedTokenInput): Promise<SbResult<EmbedToken>>;
1048
- listAppDevices(id: number | string, query?: ListAppDevicesQuery): Promise<SbResult<Paginated<AppDevice>>>;
1028
+ /** Push kanalına kayıtlı son kullanıcı cihazları (token MASKELİ döner). */
1029
+ listModuleKeyDevices(module: KeyedModule, id: number | string, query?: ListAppDevicesQuery): Promise<SbResult<Paginated<AppDevice>>>;
1049
1030
  }
1050
1031
 
1051
1032
  /**
@@ -1181,11 +1162,11 @@ declare function verifyWebhook(rawBody: string | Uint8Array, signatureHeader: st
1181
1162
  /**
1182
1163
  * Ortam değişkeninden kurulan paylaşımlı istemci.
1183
1164
  *
1184
- * `SIGNALBIRD_KEY` okunur. Uygulamanın her köşesinde istemci kurup anahtarı
1185
- * elden ele taşımak yerine tek çağrı yeter:
1165
+ * `SIGNALBIRD_DOMAIN_KEY` okunur. Uygulamanın her köşesinde istemci kurup
1166
+ * anahtarı elden ele taşımak yerine tek çağrı yeter:
1186
1167
  *
1187
1168
  * import { signalbird } from 'signalbird'
1188
- * await signalbird().critical('critical', 'ödeme servisi öldü')
1169
+ * await signalbird().critical('kritikApiHatasi', 'ödeme servisi öldü')
1189
1170
  */
1190
1171
  declare function signalbird(config?: Partial<SignalbirdConfig>): SignalbirdClient;
1191
1172
  /** Test ve sıcak yeniden yükleme için tekil istemciyi sıfırlar. */
@@ -1193,14 +1174,14 @@ declare function resetSignalbird(): void;
1193
1174
  /**
1194
1175
  * Ortam değişkeninden kurulan paylaşımlı yönetim istemcisi.
1195
1176
  *
1196
- * `SIGNALBIRD_API_KEY` okunur (yoksa `SIGNALBIRD_MESSAGING_KEY` — ikisi de aynı
1177
+ * `SIGNALBIRD_DOMAIN_KEY` okunur (yoksa `SIGNALBIRD_DOMAIN_KEY` — ikisi de aynı
1197
1178
  * takım anahtarı ailesidir ve çoğu kurulumda tek anahtar kullanılır).
1198
1179
  *
1199
1180
  * import { management } from 'signalbird'
1200
- * await management().createRadioProject({ name: 'ödeme-servisi' })
1181
+ * await management().createModuleKey('logger', { title: 'Kritik API hatası' })
1201
1182
  */
1202
1183
  declare function management(config?: Partial<ManagementConfig>): SignalbirdManagement;
1203
1184
  /** Test ve sıcak yeniden yükleme için yönetim istemcisini sıfırlar. */
1204
1185
  declare function resetManagement(): void;
1205
1186
 
1206
- export { type AddDomainInput, type AddDomainResult, type AppDevice, type AppInput, type AppPlatform, type AppRecord, type Batch, type BatchResult, type BulkContactsInput, type BulkContactsResult, type CampaignCreateResult, type CampaignDetail, type CannedReply, type CannedReplyInput, type Channel, type ChatConversation, type ChatMessage, type ChatVisitor, type Contact, type ContactInput, type ContactList, type ConversationStatus, type CreateCampaignInput, type CreateCompanyInput, type CreateCompanyResult, type CreateContactListInput, type CreateRadioProjectInput, DEFAULT_BASE_URL, type DnsRecord, type EmbedModule, type EmbedToken, type EmbedTokenInput, type GrantModuleInput, type Level, type ListAppDevicesQuery, type ListCampaignMessagesQuery, type ListCampaignsQuery, type ListChatMessagesQuery, type ListContactsQuery, type ListConversationsQuery, type ListMessagesQuery, type ListRadioEventsQuery, type LogInput, type LogResult, type ManagementConfig, type Message, type MessageClass, type MessagingConfig, type MessagingErrorCode, type ModuleEntitlement, type Paginated$1 as Paginated, type PartnerCompany, type PartnerConfig, type PartnerDomain, type PartnerOwnerInput, type PartnerUser, type PartnerUserInput, type RadioChannel, type RadioChannelInput, type RadioEvent, type RadioLevel, type RadioProject, type RadioProjectCreated, type ReplyInput, type SbResult$1 as SbResult, type SendEmailInput, type SendPushInput, type SendResult, type SendSmsInput, SignalbirdClient, type SignalbirdConfig, SignalbirdError, SignalbirdManagement, SignalbirdMessaging, SignalbirdPartner, type SmsPreview, type StartConversationInput, type TeamEmbedTokenInput, type UpdateConversationInput, type UpdateRadioProjectInput, type UpdateVisitorInput, type UptimeIncident, type UptimeRange, type UptimeReport, type VerifyDomainResult, management, resetManagement, resetSignalbird, signalbird, verifyWebhook };
1187
+ export { type AddDomainInput, type AddDomainResult, type AppDevice, type AppPlatform, type Batch, type BatchResult, type BulkContactsInput, type BulkContactsResult, type CampaignCreateResult, type CampaignDetail, type CannedReply, type CannedReplyInput, type Channel, type ChatConversation, type ChatMessage, type ChatVisitor, type Contact, type ContactInput, type ContactList, type ConversationStatus, type CreateCampaignInput, type CreateCompanyInput, type CreateCompanyResult, type CreateContactListInput, DEFAULT_BASE_URL, type DnsRecord, type EmbedModule, type EmbedToken, type EmbedTokenInput, type GrantModuleInput, type Level, type ListAppDevicesQuery, type ListCampaignMessagesQuery, type ListCampaignsQuery, type ListChatMessagesQuery, type ListContactsQuery, type ListConversationsQuery, type ListMessagesQuery, type ListRadioEventsQuery, type LogInput, type LogResult, type ManagementConfig, type Message, type MessageClass, type MessagingConfig, type MessagingErrorCode, type ModuleEntitlement, type Paginated$1 as Paginated, type PartnerCompany, type PartnerConfig, type PartnerDomain, type PartnerOwnerInput, type PartnerUser, type PartnerUserInput, type RadioEvent, type RadioLevel, type ReplyInput, type SbResult$1 as SbResult, type SendEmailInput, type SendPushInput, type SendResult, type SendSmsInput, SignalbirdClient, type SignalbirdConfig, SignalbirdError, SignalbirdManagement, SignalbirdMessaging, SignalbirdPartner, type SmsPreview, type StartConversationInput, type TeamEmbedTokenInput, type UpdateConversationInput, type UpdateVisitorInput, type UptimeIncident, type UptimeRange, type UptimeReport, type VerifyDomainResult, management, resetManagement, resetSignalbird, signalbird, verifyWebhook };