signalbird 1.4.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/README.md +576 -0
- package/dist/angular.d.mts +53 -0
- package/dist/angular.d.ts +53 -0
- package/dist/angular.js +578 -0
- package/dist/angular.js.map +1 -0
- package/dist/angular.mjs +574 -0
- package/dist/angular.mjs.map +1 -0
- package/dist/app.d.mts +343 -0
- package/dist/app.d.ts +343 -0
- package/dist/app.js +518 -0
- package/dist/app.js.map +1 -0
- package/dist/app.mjs +514 -0
- package/dist/app.mjs.map +1 -0
- package/dist/browser.d.mts +56 -0
- package/dist/browser.d.ts +56 -0
- package/dist/browser.js +113 -0
- package/dist/browser.js.map +1 -0
- package/dist/browser.mjs +109 -0
- package/dist/browser.mjs.map +1 -0
- package/dist/index.d.mts +1170 -0
- package/dist/index.d.ts +1170 -0
- package/dist/index.js +853 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +841 -0
- package/dist/index.mjs.map +1 -0
- package/dist/react-native.d.mts +46 -0
- package/dist/react-native.d.ts +46 -0
- package/dist/react-native.js +576 -0
- package/dist/react-native.js.map +1 -0
- package/dist/react-native.mjs +569 -0
- package/dist/react-native.mjs.map +1 -0
- package/dist/react.d.mts +43 -0
- package/dist/react.d.ts +43 -0
- package/dist/react.js +587 -0
- package/dist/react.js.map +1 -0
- package/dist/react.mjs +580 -0
- package/dist/react.mjs.map +1 -0
- package/dist/signalbird.js +141 -0
- package/dist/vue.d.mts +46 -0
- package/dist/vue.d.ts +46 -0
- package/dist/vue.js +575 -0
- package/dist/vue.js.map +1 -0
- package/dist/vue.mjs +568 -0
- package/dist/vue.mjs.map +1 -0
- package/package.json +125 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,1170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Telsiz (Radio) istemcisinin ortak tipleri.
|
|
3
|
+
*
|
|
4
|
+
* SDK'nın tek işi vardır: bir kanala mesaj yazmak. Bildirimin kime, hangi
|
|
5
|
+
* kanaldan ve hangi saatte gideceği SUNUCUDA, kanal ayarlarında durur —
|
|
6
|
+
* istemci bunu bilmez ve bilmemelidir. Aksi hâlde bildirim kuralını
|
|
7
|
+
* değiştirmek için müşterinin kodunu yeniden yayınlaması gerekirdi.
|
|
8
|
+
*/
|
|
9
|
+
/** Kanalın seviyesi; verilmezse kanalın kendi varsayılanı geçerlidir. */
|
|
10
|
+
type Level = 'debug' | 'info' | 'warn' | 'error' | 'critical';
|
|
11
|
+
interface SignalbirdConfig {
|
|
12
|
+
/**
|
|
13
|
+
* Sunucu anahtarı (`sbr_live_…`).
|
|
14
|
+
*
|
|
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.
|
|
18
|
+
*/
|
|
19
|
+
apiKey: string;
|
|
20
|
+
/** Varsayılan: https://signalbird.io/api */
|
|
21
|
+
baseUrl?: string;
|
|
22
|
+
/** Her olaya eklenen köken adı (sunucu adı, servis adı). */
|
|
23
|
+
source?: string;
|
|
24
|
+
/** İstek zaman aşımı (ms). Varsayılan 5000 — log göndermek isteği bekletmemeli. */
|
|
25
|
+
timeout?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Hata fırlatılsın mı. Varsayılan `false`.
|
|
28
|
+
*
|
|
29
|
+
* Log göndermek uygulamanın ASIL işi değildir: telsiz erişilemezse müşterinin
|
|
30
|
+
* ödeme akışı çökmemelidir. Varsayılan davranış sessizce yutup `ok: false`
|
|
31
|
+
* dönmektir; geliştirme sırasında `throwOnError: true` ile açılabilir.
|
|
32
|
+
*/
|
|
33
|
+
throwOnError?: boolean;
|
|
34
|
+
/** Konsola uyarı yazılsın mı (varsayılan: NODE_ENV !== 'production'). */
|
|
35
|
+
debug?: boolean;
|
|
36
|
+
}
|
|
37
|
+
interface LogInput {
|
|
38
|
+
channel: string;
|
|
39
|
+
message: string;
|
|
40
|
+
level?: Level;
|
|
41
|
+
context?: Record<string, unknown>;
|
|
42
|
+
source?: string;
|
|
43
|
+
}
|
|
44
|
+
interface LogResult {
|
|
45
|
+
ok: boolean;
|
|
46
|
+
/** Sunucunun döndüğü olay kimliği (rev_…). */
|
|
47
|
+
eventId?: string;
|
|
48
|
+
/** Reddedildiyse sebep: INVALID_KEY, MODULE_DISABLED, LIMIT_REACHED… */
|
|
49
|
+
code?: string;
|
|
50
|
+
status?: number;
|
|
51
|
+
}
|
|
52
|
+
interface BatchResult {
|
|
53
|
+
accepted: number;
|
|
54
|
+
total: number;
|
|
55
|
+
results: Record<number, {
|
|
56
|
+
ok: boolean;
|
|
57
|
+
eventId?: string;
|
|
58
|
+
code?: string;
|
|
59
|
+
}>;
|
|
60
|
+
}
|
|
61
|
+
/** `throwOnError: true` iken fırlatılır. */
|
|
62
|
+
declare class SignalbirdError extends Error {
|
|
63
|
+
readonly status: number;
|
|
64
|
+
readonly code?: string | undefined;
|
|
65
|
+
/** Sunucunun ham yanıt gövdesi (varsa) — gönderim istemcisi doldurur. */
|
|
66
|
+
readonly body?: unknown | undefined;
|
|
67
|
+
constructor(message: string, status: number, code?: string | undefined,
|
|
68
|
+
/** Sunucunun ham yanıt gövdesi (varsa) — gönderim istemcisi doldurur. */
|
|
69
|
+
body?: unknown | undefined);
|
|
70
|
+
}
|
|
71
|
+
declare const DEFAULT_BASE_URL = "https://signalbird.io/api";
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Telsiz istemcisi (sunucu tarafı).
|
|
75
|
+
*
|
|
76
|
+
* Bağımlılığı yoktur: Node 18+ ile gelen `fetch` kullanılır. Bir log
|
|
77
|
+
* kütüphanesinin kendi bağımlılık zincirini müşterinin projesine taşıması,
|
|
78
|
+
* sürüm çakışmalarının en sinir bozucu kaynağıdır.
|
|
79
|
+
*/
|
|
80
|
+
|
|
81
|
+
declare class SignalbirdClient {
|
|
82
|
+
private readonly config;
|
|
83
|
+
private readonly baseUrl;
|
|
84
|
+
private readonly timeout;
|
|
85
|
+
private readonly throwOnError;
|
|
86
|
+
private readonly debug;
|
|
87
|
+
private readonly source?;
|
|
88
|
+
constructor(config: SignalbirdConfig);
|
|
89
|
+
/** Tek kayıt gönderir. */
|
|
90
|
+
log(input: LogInput): Promise<LogResult>;
|
|
91
|
+
/**
|
|
92
|
+
* Toplu gönderim — 100 kayda kadar.
|
|
93
|
+
*
|
|
94
|
+
* Kısmi başarı normaldir (kota tam ortada dolabilir), o yüzden sonuç tek bir
|
|
95
|
+
* durum değil satır satır döner.
|
|
96
|
+
*/
|
|
97
|
+
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>;
|
|
103
|
+
/**
|
|
104
|
+
* Yakalanmamış hataları Telsiz'e bağlar.
|
|
105
|
+
*
|
|
106
|
+
* Kancayı takıp süreci ÖLDÜRMEYE devam eder: `uncaughtException` sonrası
|
|
107
|
+
* süreci ayakta tutmak, bozuk durumdaki bir uygulamayı çalıştırmaya devam
|
|
108
|
+
* etmek demektir — log göndermek bunu meşrulaştırmaz.
|
|
109
|
+
*/
|
|
110
|
+
captureUncaught(channel?: string): () => void;
|
|
111
|
+
private send;
|
|
112
|
+
private request;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Gönderim (Messaging) istemcisinin tipleri.
|
|
117
|
+
*
|
|
118
|
+
* Alan adları API ile birebir aynıdır (snake_case) — SDK, sunucunun döndüğünü
|
|
119
|
+
* yeniden adlandırmaz. Böylece API dokümanındaki bir alan SDK'da da aynı adla
|
|
120
|
+
* bulunur ve iki doküman arasında çeviri tablosu gerekmez.
|
|
121
|
+
*/
|
|
122
|
+
interface MessagingConfig {
|
|
123
|
+
/** Takım API anahtarı (`sb_…`). GİZLİDİR, yalnız sunucuda kullanılır. */
|
|
124
|
+
apiKey: string;
|
|
125
|
+
/** Varsayılan: https://signalbird.io/api */
|
|
126
|
+
baseUrl?: string;
|
|
127
|
+
/** İstek zaman aşımı (ms). Varsayılan 15000 — toplu kişi yükleme uzun sürebilir. */
|
|
128
|
+
timeout?: number;
|
|
129
|
+
/** Hata fırlatılsın mı. Varsayılan `false`: `ok:false` + `code` döner. */
|
|
130
|
+
throwOnError?: boolean;
|
|
131
|
+
/** Konsola uyarı yazılsın mı. */
|
|
132
|
+
debug?: boolean;
|
|
133
|
+
}
|
|
134
|
+
/** Her metodun döndüğü sonuç: ya `ok:true` + `data`, ya `ok:false` + `code`. */
|
|
135
|
+
type SbResult$1<T> = {
|
|
136
|
+
ok: true;
|
|
137
|
+
status: number;
|
|
138
|
+
data: T;
|
|
139
|
+
} | {
|
|
140
|
+
ok: false;
|
|
141
|
+
status: number;
|
|
142
|
+
code: string;
|
|
143
|
+
message: string;
|
|
144
|
+
data?: unknown;
|
|
145
|
+
};
|
|
146
|
+
/** İleti sınıfı — API'de zorunludur ve varsayılanı YOKTUR (hukuki kapı). */
|
|
147
|
+
type MessageClass = 'transactional' | 'commercial';
|
|
148
|
+
type Channel = 'email' | 'sms' | 'push';
|
|
149
|
+
interface SendEmailInput {
|
|
150
|
+
to: string;
|
|
151
|
+
class: MessageClass;
|
|
152
|
+
subject: string;
|
|
153
|
+
body?: string;
|
|
154
|
+
template_hash?: string;
|
|
155
|
+
vars?: Record<string, unknown>;
|
|
156
|
+
sending_domain_id?: number;
|
|
157
|
+
contact_id?: number;
|
|
158
|
+
}
|
|
159
|
+
interface SendSmsInput {
|
|
160
|
+
to: string;
|
|
161
|
+
class: MessageClass;
|
|
162
|
+
body: string;
|
|
163
|
+
brand_id?: number;
|
|
164
|
+
contact_id?: number;
|
|
165
|
+
}
|
|
166
|
+
interface SendPushInput {
|
|
167
|
+
/** Cihaz token'ı, `contact:<id>` ya da `external:<external_id>`. */
|
|
168
|
+
to: string;
|
|
169
|
+
class: MessageClass;
|
|
170
|
+
subject: string;
|
|
171
|
+
body: string;
|
|
172
|
+
/** `data` (FCM data yükü), `image`, `url`. */
|
|
173
|
+
vars?: Record<string, unknown>;
|
|
174
|
+
contact_id?: number;
|
|
175
|
+
}
|
|
176
|
+
/** 202 Accepted */
|
|
177
|
+
interface SendResult {
|
|
178
|
+
id: string;
|
|
179
|
+
status: string;
|
|
180
|
+
units: number;
|
|
181
|
+
}
|
|
182
|
+
interface SmsPreview {
|
|
183
|
+
units: number;
|
|
184
|
+
encoding?: string;
|
|
185
|
+
length?: number;
|
|
186
|
+
[key: string]: unknown;
|
|
187
|
+
}
|
|
188
|
+
interface ContactInput {
|
|
189
|
+
email?: string;
|
|
190
|
+
phone?: string;
|
|
191
|
+
first_name?: string;
|
|
192
|
+
last_name?: string;
|
|
193
|
+
attributes?: Record<string, unknown>;
|
|
194
|
+
list_ids?: number[];
|
|
195
|
+
consent_source?: string;
|
|
196
|
+
consent_text?: string;
|
|
197
|
+
[key: string]: unknown;
|
|
198
|
+
}
|
|
199
|
+
interface Contact {
|
|
200
|
+
id: number;
|
|
201
|
+
email: string | null;
|
|
202
|
+
phone: string | null;
|
|
203
|
+
first_name: string | null;
|
|
204
|
+
last_name: string | null;
|
|
205
|
+
attributes: Record<string, unknown> | null;
|
|
206
|
+
[key: string]: unknown;
|
|
207
|
+
}
|
|
208
|
+
interface ListContactsQuery {
|
|
209
|
+
q?: string;
|
|
210
|
+
list_id?: number;
|
|
211
|
+
page?: number;
|
|
212
|
+
per_page?: number;
|
|
213
|
+
[key: string]: unknown;
|
|
214
|
+
}
|
|
215
|
+
interface BulkContactsInput {
|
|
216
|
+
contacts: ContactInput[];
|
|
217
|
+
list_id?: number;
|
|
218
|
+
consent_source?: string;
|
|
219
|
+
consent_text?: string;
|
|
220
|
+
}
|
|
221
|
+
interface BulkContactsResult {
|
|
222
|
+
imported: number;
|
|
223
|
+
updated: number;
|
|
224
|
+
skipped: unknown[];
|
|
225
|
+
}
|
|
226
|
+
interface ContactList {
|
|
227
|
+
id: number;
|
|
228
|
+
name: string;
|
|
229
|
+
description: string | null;
|
|
230
|
+
contacts_count?: number;
|
|
231
|
+
[key: string]: unknown;
|
|
232
|
+
}
|
|
233
|
+
interface CreateContactListInput {
|
|
234
|
+
name: string;
|
|
235
|
+
description?: string;
|
|
236
|
+
}
|
|
237
|
+
interface CreateCampaignInput {
|
|
238
|
+
name: string;
|
|
239
|
+
channel: Channel;
|
|
240
|
+
/**
|
|
241
|
+
* TXT ile doğrulanmış müşteri domaininin id'si — ZORUNLU. Doğrulanmamış
|
|
242
|
+
* domain adına kampanya açılamaz (`DOMAIN_NOT_VERIFIED`).
|
|
243
|
+
*/
|
|
244
|
+
domain_id: number;
|
|
245
|
+
/** Hedef: `list_id` VEYA `segment_id` — ikisinden tam biri. */
|
|
246
|
+
list_id?: number;
|
|
247
|
+
segment_id?: number;
|
|
248
|
+
subject?: string;
|
|
249
|
+
body: string;
|
|
250
|
+
template_hash?: string;
|
|
251
|
+
sending_domain_id?: number;
|
|
252
|
+
brand_id?: number;
|
|
253
|
+
/** ISO-8601; verilirse parti `scheduled` açılır. */
|
|
254
|
+
scheduled_at?: string;
|
|
255
|
+
/** E-postada görünen isim; zarf adresi sendsignalbird havuzunda kalır. */
|
|
256
|
+
from_name?: string;
|
|
257
|
+
/** Yanıt adresi (Reply-To). */
|
|
258
|
+
reply_to?: string;
|
|
259
|
+
metadata?: Record<string, unknown>;
|
|
260
|
+
external_ref?: string;
|
|
261
|
+
}
|
|
262
|
+
interface Batch {
|
|
263
|
+
id: number;
|
|
264
|
+
name: string;
|
|
265
|
+
channel: Channel;
|
|
266
|
+
status: string;
|
|
267
|
+
[key: string]: unknown;
|
|
268
|
+
}
|
|
269
|
+
/** 202 Accepted */
|
|
270
|
+
interface CampaignCreateResult {
|
|
271
|
+
batch: Batch;
|
|
272
|
+
class: MessageClass;
|
|
273
|
+
summary: {
|
|
274
|
+
total: number;
|
|
275
|
+
queued: number;
|
|
276
|
+
skipped: number;
|
|
277
|
+
stopped_reason: string | null;
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
interface CampaignDetail {
|
|
281
|
+
batch: Batch;
|
|
282
|
+
status_breakdown: Record<string, number>;
|
|
283
|
+
jobs: unknown[];
|
|
284
|
+
}
|
|
285
|
+
interface ListCampaignsQuery {
|
|
286
|
+
status?: string;
|
|
287
|
+
channel?: Channel;
|
|
288
|
+
page?: number;
|
|
289
|
+
per_page?: number;
|
|
290
|
+
[key: string]: unknown;
|
|
291
|
+
}
|
|
292
|
+
interface Message {
|
|
293
|
+
id: string;
|
|
294
|
+
channel: Channel;
|
|
295
|
+
class: MessageClass;
|
|
296
|
+
/** Maskeli alıcı (`a***@example.com`). */
|
|
297
|
+
recipient: string;
|
|
298
|
+
subject: string | null;
|
|
299
|
+
status: string;
|
|
300
|
+
status_label: string;
|
|
301
|
+
units: number;
|
|
302
|
+
last_code: string | null;
|
|
303
|
+
queued_at: string | null;
|
|
304
|
+
sent_at: string | null;
|
|
305
|
+
delivered_at: string | null;
|
|
306
|
+
first_opened_at: string | null;
|
|
307
|
+
first_clicked_at: string | null;
|
|
308
|
+
contact_id: number | null;
|
|
309
|
+
external_ref: string | null;
|
|
310
|
+
batch_id: number | null;
|
|
311
|
+
}
|
|
312
|
+
interface ListMessagesQuery {
|
|
313
|
+
status?: string;
|
|
314
|
+
channel?: Channel;
|
|
315
|
+
batch_id?: number;
|
|
316
|
+
page?: number;
|
|
317
|
+
per_page?: number;
|
|
318
|
+
[key: string]: unknown;
|
|
319
|
+
}
|
|
320
|
+
interface ListCampaignMessagesQuery {
|
|
321
|
+
page?: number;
|
|
322
|
+
per_page?: number;
|
|
323
|
+
status?: string;
|
|
324
|
+
}
|
|
325
|
+
/** Laravel sayfalayıcısı. */
|
|
326
|
+
interface Paginated$1<T> {
|
|
327
|
+
data: T[];
|
|
328
|
+
current_page: number;
|
|
329
|
+
last_page: number;
|
|
330
|
+
per_page: number;
|
|
331
|
+
total: number;
|
|
332
|
+
[key: string]: unknown;
|
|
333
|
+
}
|
|
334
|
+
/** API'nin döndürebileceği hata kodları (bilinenler). */
|
|
335
|
+
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
|
+
|
|
337
|
+
declare class SignalbirdMessaging {
|
|
338
|
+
private readonly apiKey;
|
|
339
|
+
private readonly baseUrl;
|
|
340
|
+
private readonly timeout;
|
|
341
|
+
private readonly throwOnError;
|
|
342
|
+
private readonly debug;
|
|
343
|
+
constructor(config: MessagingConfig);
|
|
344
|
+
sendEmail(input: SendEmailInput): Promise<SbResult$1<SendResult>>;
|
|
345
|
+
sendSms(input: SendSmsInput): Promise<SbResult$1<SendResult>>;
|
|
346
|
+
/** SMS parça/karakter hesabı — kota harcamaz. */
|
|
347
|
+
previewSms(body: string): Promise<SbResult$1<SmsPreview>>;
|
|
348
|
+
sendPush(input: SendPushInput): Promise<SbResult$1<SendResult>>;
|
|
349
|
+
listContacts(query?: ListContactsQuery): Promise<SbResult$1<Paginated$1<Contact>>>;
|
|
350
|
+
createContact(contact: ContactInput): Promise<SbResult$1<Contact>>;
|
|
351
|
+
updateContact(id: number | string, contact: Partial<ContactInput>): Promise<SbResult$1<Contact>>;
|
|
352
|
+
deleteContact(id: number | string): Promise<SbResult$1<unknown>>;
|
|
353
|
+
/**
|
|
354
|
+
* Toplu kişi yükleme.
|
|
355
|
+
*
|
|
356
|
+
* 1000'lik parçalara bölünür ve SIRAYLA gönderilir (paralel değil: aynı
|
|
357
|
+
* e-posta iki parçada da varsa yarış olmasın). Sonuçlar tek yanıtta
|
|
358
|
+
* birleştirilir. Bir parça başarısız olursa o noktada durulur ve o ana kadar
|
|
359
|
+
* biriken sayımlar `data` içinde döner — çağıran kaç kişinin işlendiğini görür.
|
|
360
|
+
*/
|
|
361
|
+
bulkContacts(input: BulkContactsInput): Promise<SbResult$1<BulkContactsResult>>;
|
|
362
|
+
listContactLists(): Promise<SbResult$1<ContactList[] | Paginated$1<ContactList>>>;
|
|
363
|
+
createContactList(input: CreateContactListInput): Promise<SbResult$1<ContactList>>;
|
|
364
|
+
deleteContactList(id: number | string): Promise<SbResult$1<unknown>>;
|
|
365
|
+
listCampaigns(query?: ListCampaignsQuery): Promise<SbResult$1<Paginated$1<Batch> | Batch[]>>;
|
|
366
|
+
createCampaign(input: CreateCampaignInput): Promise<SbResult$1<CampaignCreateResult>>;
|
|
367
|
+
getCampaign(id: number | string): Promise<SbResult$1<CampaignDetail>>;
|
|
368
|
+
cancelCampaign(id: number | string): Promise<SbResult$1<unknown>>;
|
|
369
|
+
listCampaignMessages(id: number | string, query?: ListCampaignMessagesQuery): Promise<SbResult$1<Paginated$1<Message>>>;
|
|
370
|
+
/**
|
|
371
|
+
* Bir kampanyanın tüm mesajlarını sayfa sayfa gezer.
|
|
372
|
+
*
|
|
373
|
+
* for await (const m of sdk.iterateCampaignMessages(42)) { … }
|
|
374
|
+
*
|
|
375
|
+
* Bir sayfa alınamazsa `SignalbirdError` fırlatır (sessiz yarım liste,
|
|
376
|
+
* "hepsi bu" sanılır — o daha tehlikeli).
|
|
377
|
+
*/
|
|
378
|
+
iterateCampaignMessages(id: number | string, query?: Omit<ListCampaignMessagesQuery, 'page'>): AsyncGenerator<Message, void, undefined>;
|
|
379
|
+
listMessages(query?: ListMessagesQuery): Promise<SbResult$1<Paginated$1<Message>>>;
|
|
380
|
+
getMessage(id: string): Promise<SbResult$1<Message>>;
|
|
381
|
+
private request;
|
|
382
|
+
private fail;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/** Her metodun döndüğü zarf. Başarısızlık istisna değil, veridir. */
|
|
386
|
+
interface SbResult<T = unknown> {
|
|
387
|
+
ok: boolean;
|
|
388
|
+
status: number;
|
|
389
|
+
data?: T;
|
|
390
|
+
code?: string;
|
|
391
|
+
message?: string;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Yönetim (Management) yüzeyinin tipleri.
|
|
396
|
+
*
|
|
397
|
+
* Alan adları API ile BİREBİR aynıdır (snake_case). SDK yeniden adlandırmaz:
|
|
398
|
+
* müşteri bir alanı belgede görüp kodda başka adla bulursa, kaybettiği zaman
|
|
399
|
+
* SDK'nın kazandırdığı zamandan fazladır.
|
|
400
|
+
*/
|
|
401
|
+
|
|
402
|
+
interface ManagementConfig {
|
|
403
|
+
/** Takım API anahtarı (`sb_…`) — `radio:*`, `chat:*`, `apps:*` scope'larıyla. */
|
|
404
|
+
apiKey: string;
|
|
405
|
+
/** Varsayılan: https://signalbird.io/api */
|
|
406
|
+
baseUrl?: string;
|
|
407
|
+
/** İstek zaman aşımı (ms). Varsayılan 15000. */
|
|
408
|
+
timeout?: number;
|
|
409
|
+
/** Açıksa `SignalbirdError` fırlatılır; varsayılan `false`. */
|
|
410
|
+
throwOnError?: boolean;
|
|
411
|
+
debug?: boolean;
|
|
412
|
+
}
|
|
413
|
+
/** Sayfalı Laravel yanıtı. */
|
|
414
|
+
interface Paginated<T> {
|
|
415
|
+
data: T[];
|
|
416
|
+
current_page?: number;
|
|
417
|
+
last_page?: number;
|
|
418
|
+
per_page?: number;
|
|
419
|
+
total?: number;
|
|
420
|
+
}
|
|
421
|
+
type RadioLevel = 'debug' | 'info' | 'warn' | 'error' | 'critical';
|
|
422
|
+
interface RadioProject {
|
|
423
|
+
id: number;
|
|
424
|
+
name: string;
|
|
425
|
+
slug?: string;
|
|
426
|
+
description?: string | null;
|
|
427
|
+
/** Gizli anahtarın tanınacak kadarı; tamamı yalnız oluşturmada döner. */
|
|
428
|
+
secret_hint?: string | null;
|
|
429
|
+
public_key?: string | null;
|
|
430
|
+
is_active?: boolean;
|
|
431
|
+
channels_count?: number;
|
|
432
|
+
events_count?: number;
|
|
433
|
+
last_event_at?: string | null;
|
|
434
|
+
channels?: RadioChannel[];
|
|
435
|
+
}
|
|
436
|
+
interface RadioChannel {
|
|
437
|
+
id: number;
|
|
438
|
+
key: string;
|
|
439
|
+
name: string;
|
|
440
|
+
description?: string | null;
|
|
441
|
+
level?: RadioLevel;
|
|
442
|
+
notify_push?: boolean;
|
|
443
|
+
notify_email?: boolean;
|
|
444
|
+
recipient_user_ids?: number[] | null;
|
|
445
|
+
quiet_from?: number | null;
|
|
446
|
+
quiet_to?: number | null;
|
|
447
|
+
dedupe_seconds?: number;
|
|
448
|
+
is_active?: boolean;
|
|
449
|
+
is_auto?: boolean;
|
|
450
|
+
}
|
|
451
|
+
interface CreateRadioProjectInput {
|
|
452
|
+
name: string;
|
|
453
|
+
}
|
|
454
|
+
interface UpdateRadioProjectInput {
|
|
455
|
+
name?: string;
|
|
456
|
+
description?: string | null;
|
|
457
|
+
is_active?: boolean;
|
|
458
|
+
/** Tarayıcıdan yazılabilen kanallar ve izinli kökenler. */
|
|
459
|
+
browser_channels?: string[] | null;
|
|
460
|
+
allowed_origins?: string[] | null;
|
|
461
|
+
}
|
|
462
|
+
interface RadioChannelInput {
|
|
463
|
+
key?: string;
|
|
464
|
+
name?: string;
|
|
465
|
+
description?: string | null;
|
|
466
|
+
level?: RadioLevel;
|
|
467
|
+
notify_push?: boolean;
|
|
468
|
+
notify_email?: boolean;
|
|
469
|
+
recipient_user_ids?: number[] | null;
|
|
470
|
+
quiet_from?: number | null;
|
|
471
|
+
quiet_to?: number | null;
|
|
472
|
+
dedupe_seconds?: number;
|
|
473
|
+
is_active?: boolean;
|
|
474
|
+
}
|
|
475
|
+
/** Proje açılışı: gizli anahtar YALNIZ burada döner, bir daha okunamaz. */
|
|
476
|
+
interface RadioProjectCreated {
|
|
477
|
+
project: RadioProject;
|
|
478
|
+
secret: string;
|
|
479
|
+
}
|
|
480
|
+
interface RadioEvent {
|
|
481
|
+
id: string;
|
|
482
|
+
channel?: string;
|
|
483
|
+
channel_id?: number;
|
|
484
|
+
project_id?: number;
|
|
485
|
+
message: string;
|
|
486
|
+
level: RadioLevel;
|
|
487
|
+
context?: Record<string, unknown> | null;
|
|
488
|
+
source?: string | null;
|
|
489
|
+
created_at?: string;
|
|
490
|
+
}
|
|
491
|
+
interface ListRadioEventsQuery {
|
|
492
|
+
project_id?: number;
|
|
493
|
+
channel_id?: number;
|
|
494
|
+
level?: RadioLevel;
|
|
495
|
+
q?: string;
|
|
496
|
+
from?: string;
|
|
497
|
+
to?: string;
|
|
498
|
+
page?: number;
|
|
499
|
+
per_page?: number;
|
|
500
|
+
}
|
|
501
|
+
type ConversationStatus = 'open' | 'pending' | 'resolved' | 'closed';
|
|
502
|
+
interface ChatConversation {
|
|
503
|
+
id: string;
|
|
504
|
+
status: ConversationStatus;
|
|
505
|
+
subject?: string | null;
|
|
506
|
+
priority?: string | null;
|
|
507
|
+
tags?: string[] | null;
|
|
508
|
+
unread_count?: number;
|
|
509
|
+
assigned_user_id?: number | null;
|
|
510
|
+
visitor?: ChatVisitor | null;
|
|
511
|
+
last_message_preview?: string | null;
|
|
512
|
+
last_message_at?: string | null;
|
|
513
|
+
created_at?: string;
|
|
514
|
+
}
|
|
515
|
+
interface ChatVisitor {
|
|
516
|
+
id: string;
|
|
517
|
+
name?: string | null;
|
|
518
|
+
email?: string | null;
|
|
519
|
+
phone?: string | null;
|
|
520
|
+
external_id?: string | null;
|
|
521
|
+
attributes?: Record<string, unknown> | null;
|
|
522
|
+
is_banned?: boolean;
|
|
523
|
+
last_seen_at?: string | null;
|
|
524
|
+
}
|
|
525
|
+
interface ChatMessage {
|
|
526
|
+
id: string;
|
|
527
|
+
conversation_id?: string;
|
|
528
|
+
sender_type: 'visitor' | 'agent' | 'system';
|
|
529
|
+
sender_id?: number | string | null;
|
|
530
|
+
body?: string | null;
|
|
531
|
+
is_internal?: boolean;
|
|
532
|
+
attachments?: unknown[] | null;
|
|
533
|
+
reply_to_id?: string | null;
|
|
534
|
+
reactions?: Record<string, unknown> | null;
|
|
535
|
+
created_at?: string;
|
|
536
|
+
}
|
|
537
|
+
interface ListConversationsQuery {
|
|
538
|
+
status?: ConversationStatus | ConversationStatus[];
|
|
539
|
+
assigned_user_id?: number | 'me' | 'none';
|
|
540
|
+
app_id?: number;
|
|
541
|
+
q?: string;
|
|
542
|
+
page?: number;
|
|
543
|
+
per_page?: number;
|
|
544
|
+
}
|
|
545
|
+
interface ListChatMessagesQuery {
|
|
546
|
+
after?: string;
|
|
547
|
+
before?: string;
|
|
548
|
+
limit?: number;
|
|
549
|
+
/** Ajan tarafı iç notları da okuyabilir; ziyaretçi asla göremez. */
|
|
550
|
+
include_internal?: boolean;
|
|
551
|
+
}
|
|
552
|
+
interface StartConversationInput {
|
|
553
|
+
/** Ziyaretçi ya da kişi — biri zorunlu. */
|
|
554
|
+
visitor_id?: string;
|
|
555
|
+
contact_id?: number;
|
|
556
|
+
body: string;
|
|
557
|
+
app_id?: number;
|
|
558
|
+
}
|
|
559
|
+
interface UpdateConversationInput {
|
|
560
|
+
subject?: string | null;
|
|
561
|
+
priority?: string | null;
|
|
562
|
+
tags?: string[] | null;
|
|
563
|
+
}
|
|
564
|
+
interface ReplyInput {
|
|
565
|
+
body?: string;
|
|
566
|
+
/** İç not: gelen kutusunda görünür, ziyaretçiye ASLA gitmez. */
|
|
567
|
+
is_internal?: boolean;
|
|
568
|
+
reply_to_id?: string | null;
|
|
569
|
+
attachments?: unknown[];
|
|
570
|
+
}
|
|
571
|
+
interface UpdateVisitorInput {
|
|
572
|
+
name?: string | null;
|
|
573
|
+
email?: string | null;
|
|
574
|
+
phone?: string | null;
|
|
575
|
+
attributes?: Record<string, unknown> | null;
|
|
576
|
+
}
|
|
577
|
+
interface CannedReply {
|
|
578
|
+
id: number;
|
|
579
|
+
shortcut: string;
|
|
580
|
+
title?: string | null;
|
|
581
|
+
body: string;
|
|
582
|
+
usage_count?: number;
|
|
583
|
+
}
|
|
584
|
+
interface CannedReplyInput {
|
|
585
|
+
shortcut?: string;
|
|
586
|
+
title?: string | null;
|
|
587
|
+
body?: string;
|
|
588
|
+
}
|
|
589
|
+
type AppPlatform = 'web' | 'ios' | 'android' | 'other';
|
|
590
|
+
interface AppRecord {
|
|
591
|
+
id: number;
|
|
592
|
+
name: string;
|
|
593
|
+
platform: AppPlatform;
|
|
594
|
+
/** `sbw_pub_…` — açık anahtar, zaten istemciye gömülür. */
|
|
595
|
+
public_key: string;
|
|
596
|
+
allowed_origins?: string[] | null;
|
|
597
|
+
chat_enabled?: boolean;
|
|
598
|
+
push_enabled?: boolean;
|
|
599
|
+
is_active?: boolean;
|
|
600
|
+
settings?: Record<string, unknown> | null;
|
|
601
|
+
devices_count?: number;
|
|
602
|
+
conversations_count?: number;
|
|
603
|
+
}
|
|
604
|
+
interface AppInput {
|
|
605
|
+
name?: string;
|
|
606
|
+
platform?: AppPlatform;
|
|
607
|
+
allowed_origins?: string[] | null;
|
|
608
|
+
chat_enabled?: boolean;
|
|
609
|
+
push_enabled?: boolean;
|
|
610
|
+
is_active?: boolean;
|
|
611
|
+
settings?: Record<string, unknown> | null;
|
|
612
|
+
}
|
|
613
|
+
interface AppDevice {
|
|
614
|
+
id: number;
|
|
615
|
+
/** Maskeli token — tamamı hiçbir zaman dönmez. */
|
|
616
|
+
token_masked?: string;
|
|
617
|
+
platform?: string;
|
|
618
|
+
provider?: string | null;
|
|
619
|
+
device_name?: string | null;
|
|
620
|
+
app_version?: string | null;
|
|
621
|
+
locale?: string | null;
|
|
622
|
+
is_active?: boolean;
|
|
623
|
+
last_seen_at?: string | null;
|
|
624
|
+
}
|
|
625
|
+
interface ListAppDevicesQuery {
|
|
626
|
+
page?: number;
|
|
627
|
+
per_page?: number;
|
|
628
|
+
}
|
|
629
|
+
type ChatTriggerEvent = 'conversation.created' | 'visitor.message' | 'no_reply';
|
|
630
|
+
interface ChatTriggerRule {
|
|
631
|
+
field: string;
|
|
632
|
+
op: string;
|
|
633
|
+
value?: string | number | boolean | null;
|
|
634
|
+
}
|
|
635
|
+
interface ChatTriggerAction {
|
|
636
|
+
type: 'reply' | 'internal_note' | 'tag' | 'priority' | 'assign';
|
|
637
|
+
body?: string;
|
|
638
|
+
value?: string;
|
|
639
|
+
user_id?: number;
|
|
640
|
+
}
|
|
641
|
+
interface ChatTrigger {
|
|
642
|
+
id: number;
|
|
643
|
+
name: string;
|
|
644
|
+
event: ChatTriggerEvent;
|
|
645
|
+
/** Boş = takımın tüm uygulamaları. */
|
|
646
|
+
app_id: number | null;
|
|
647
|
+
conditions: {
|
|
648
|
+
match: 'all' | 'any';
|
|
649
|
+
rules: ChatTriggerRule[];
|
|
650
|
+
};
|
|
651
|
+
actions: ChatTriggerAction[];
|
|
652
|
+
/** Yalnız `no_reply` olayında okunur. */
|
|
653
|
+
delay_seconds: number;
|
|
654
|
+
is_active: boolean;
|
|
655
|
+
priority: number;
|
|
656
|
+
stop_after_match: boolean;
|
|
657
|
+
fired_count: number;
|
|
658
|
+
last_fired_at: string | null;
|
|
659
|
+
}
|
|
660
|
+
interface ChatTriggerInput {
|
|
661
|
+
name: string;
|
|
662
|
+
event: ChatTriggerEvent;
|
|
663
|
+
app_id?: number | null;
|
|
664
|
+
conditions?: {
|
|
665
|
+
match: 'all' | 'any';
|
|
666
|
+
rules: ChatTriggerRule[];
|
|
667
|
+
};
|
|
668
|
+
actions: ChatTriggerAction[];
|
|
669
|
+
delay_seconds?: number;
|
|
670
|
+
is_active?: boolean;
|
|
671
|
+
priority?: number;
|
|
672
|
+
stop_after_match?: boolean;
|
|
673
|
+
}
|
|
674
|
+
type ChatReportRange = '7d' | '30d' | '90d';
|
|
675
|
+
interface ChatReportAgent {
|
|
676
|
+
user_id: number;
|
|
677
|
+
name: string | null;
|
|
678
|
+
assigned: number;
|
|
679
|
+
replies: number;
|
|
680
|
+
resolved: number;
|
|
681
|
+
median_first_response_s: number | null;
|
|
682
|
+
rating_average: number | null;
|
|
683
|
+
rating_count: number;
|
|
684
|
+
}
|
|
685
|
+
interface ChatReport {
|
|
686
|
+
range: string;
|
|
687
|
+
since: string;
|
|
688
|
+
volume: {
|
|
689
|
+
total: number;
|
|
690
|
+
open: number;
|
|
691
|
+
resolved: number;
|
|
692
|
+
closed: number;
|
|
693
|
+
unanswered: number;
|
|
694
|
+
};
|
|
695
|
+
/** Ortalama DEĞİL ortanca; veri yoksa `null` döner, 0 değil. */
|
|
696
|
+
first_response: {
|
|
697
|
+
median_s: number | null;
|
|
698
|
+
p90_s: number | null;
|
|
699
|
+
answered: number;
|
|
700
|
+
};
|
|
701
|
+
resolution: {
|
|
702
|
+
median_s: number | null;
|
|
703
|
+
p90_s: number | null;
|
|
704
|
+
resolved: number;
|
|
705
|
+
};
|
|
706
|
+
satisfaction: {
|
|
707
|
+
average: number | null;
|
|
708
|
+
count: number;
|
|
709
|
+
breakdown: Record<string, number>;
|
|
710
|
+
};
|
|
711
|
+
agents: ChatReportAgent[];
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
/**
|
|
715
|
+
* Yönetim (Management) istemcisi — sunucu tarafı.
|
|
716
|
+
*
|
|
717
|
+
* Müşterinin panelde tıklayarak yaptığı her şeyi kodla yapar: Telsiz projesi ve
|
|
718
|
+
* kanalı açar, olay akışını okur, sohbet gelen kutusunu işler, uygulama kaydı
|
|
719
|
+
* ve cihaz listesi yönetir.
|
|
720
|
+
*
|
|
721
|
+
* Bu ADMIN yüzeyi DEĞİLDİR. Anahtar tek bir takıma bağlıdır ve yalnız o takımın
|
|
722
|
+
* kayıtlarına dokunur; başka takımın kaydı 404 döner.
|
|
723
|
+
*
|
|
724
|
+
* Neden ayrı sınıf: Gönderim (`SignalbirdMessaging`) ileti gönderir ve kota
|
|
725
|
+
* harcar; bu istemci yapılandırma değiştirir. Aynı anahtar ailesini kullanırlar
|
|
726
|
+
* (`sb_…`) ama scope'ları ve hata kümeleri farklıdır — tek sınıfta birleşseydi
|
|
727
|
+
* "hangi scope gerekiyordu" sorusu her metotta yeniden sorulurdu.
|
|
728
|
+
*
|
|
729
|
+
* Sözleşme: docs/CONTRACT.md § 10
|
|
730
|
+
*/
|
|
731
|
+
|
|
732
|
+
declare class SignalbirdManagement {
|
|
733
|
+
private readonly http;
|
|
734
|
+
constructor(config: ManagementConfig);
|
|
735
|
+
/** Panelin Telsiz özeti: proje sayısı, günlük hacim, son olaylar. */
|
|
736
|
+
radioSummary(): Promise<SbResult<Record<string, unknown>>>;
|
|
737
|
+
/** Olay akışı — kanal, seviye ve tarihe göre süzülür. */
|
|
738
|
+
radioEvents(query?: ListRadioEventsQuery): Promise<SbResult<Paginated<RadioEvent>>>;
|
|
739
|
+
listRadioProjects(): Promise<SbResult<{
|
|
740
|
+
data: RadioProject[];
|
|
741
|
+
}>>;
|
|
742
|
+
/**
|
|
743
|
+
* Proje açar.
|
|
744
|
+
*
|
|
745
|
+
* Dönen `secret` (`sbr_live_…`) YALNIZ BURADA görünür: sunucuda yalnız
|
|
746
|
+
* SHA-256 özeti saklanır. Kaybedilirse `rotateRadioSecret` ile yenilenir.
|
|
747
|
+
*/
|
|
748
|
+
createRadioProject(input: CreateRadioProjectInput): Promise<SbResult<RadioProjectCreated>>;
|
|
749
|
+
getRadioProject(id: number | string): Promise<SbResult<{
|
|
750
|
+
project: RadioProject;
|
|
751
|
+
}>>;
|
|
752
|
+
updateRadioProject(id: number | string, input: UpdateRadioProjectInput): Promise<SbResult<{
|
|
753
|
+
project: RadioProject;
|
|
754
|
+
}>>;
|
|
755
|
+
deleteRadioProject(id: number | string): Promise<SbResult<unknown>>;
|
|
756
|
+
/** Gizli anahtarı yeniler; eski anahtar ANINDA geçersizleşir. */
|
|
757
|
+
rotateRadioSecret(id: number | string): Promise<SbResult<{
|
|
758
|
+
secret: string;
|
|
759
|
+
}>>;
|
|
760
|
+
createRadioChannel(projectId: number | string, input: RadioChannelInput): Promise<SbResult<{
|
|
761
|
+
channel: RadioChannel;
|
|
762
|
+
}>>;
|
|
763
|
+
/**
|
|
764
|
+
* Kanalı günceller. `key` DEĞİŞMEZ — müşterinin kodundaki `log('critical', …)`
|
|
765
|
+
* çağrısı ona bağlıdır; sunucu gönderilse de yok sayar.
|
|
766
|
+
*/
|
|
767
|
+
updateRadioChannel(projectId: number | string, channelId: number | string, input: RadioChannelInput): Promise<SbResult<{
|
|
768
|
+
channel: RadioChannel;
|
|
769
|
+
}>>;
|
|
770
|
+
deleteRadioChannel(projectId: number | string, channelId: number | string): Promise<SbResult<unknown>>;
|
|
771
|
+
chatSummary(): Promise<SbResult<Record<string, unknown>>>;
|
|
772
|
+
/** Kısa aralıklı yoklama için: yalnız değişenler + çevrimiçi ajanlar. */
|
|
773
|
+
chatUpdates(): Promise<SbResult<Record<string, unknown>>>;
|
|
774
|
+
listConversations(query?: ListConversationsQuery): Promise<SbResult<Paginated<ChatConversation>>>;
|
|
775
|
+
getConversation(id: string): Promise<SbResult<{
|
|
776
|
+
conversation: ChatConversation;
|
|
777
|
+
}>>;
|
|
778
|
+
/** `after` imleci `cm_…` mesaj kimliğidir; yoklamada tam listeyi çekmez. */
|
|
779
|
+
listConversationMessages(id: string, query?: ListChatMessagesQuery): Promise<SbResult<{
|
|
780
|
+
messages: ChatMessage[];
|
|
781
|
+
}>>;
|
|
782
|
+
/** Proaktif sohbet — ziyaretçi yazmadan ajan başlatır. */
|
|
783
|
+
startConversation(input: StartConversationInput): Promise<SbResult<{
|
|
784
|
+
conversation: ChatConversation;
|
|
785
|
+
}>>;
|
|
786
|
+
updateConversation(id: string, input: UpdateConversationInput): Promise<SbResult<{
|
|
787
|
+
conversation: ChatConversation;
|
|
788
|
+
}>>;
|
|
789
|
+
setConversationStatus(id: string, status: ConversationStatus): Promise<SbResult<{
|
|
790
|
+
conversation: ChatConversation;
|
|
791
|
+
}>>;
|
|
792
|
+
/**
|
|
793
|
+
* Atama atomiktir: `userId` verilmezse çağıran anahtarın sahibine atanır.
|
|
794
|
+
* Başkasına atanmış sohbeti devralmak `chat:write` ister.
|
|
795
|
+
*/
|
|
796
|
+
assignConversation(id: string, userId?: number | null): Promise<SbResult<{
|
|
797
|
+
conversation: ChatConversation;
|
|
798
|
+
}>>;
|
|
799
|
+
readConversation(id: string, lastMessageId?: string): Promise<SbResult<unknown>>;
|
|
800
|
+
setTyping(id: string, isTyping: boolean): Promise<SbResult<unknown>>;
|
|
801
|
+
reply(id: string, input: ReplyInput): Promise<SbResult<{
|
|
802
|
+
message: ChatMessage;
|
|
803
|
+
}>>;
|
|
804
|
+
editChatMessage(id: string, messageId: string, body: string): Promise<SbResult<{
|
|
805
|
+
message: ChatMessage;
|
|
806
|
+
}>>;
|
|
807
|
+
deleteChatMessage(id: string, messageId: string): Promise<SbResult<unknown>>;
|
|
808
|
+
/** Tepki açma/kapama — aynı emoji ikinci kez gönderilirse kaldırılır. */
|
|
809
|
+
reactToChatMessage(id: string, messageId: string, emoji: string): Promise<SbResult<{
|
|
810
|
+
message: ChatMessage;
|
|
811
|
+
}>>;
|
|
812
|
+
getVisitor(id: string): Promise<SbResult<{
|
|
813
|
+
visitor: ChatVisitor;
|
|
814
|
+
}>>;
|
|
815
|
+
updateVisitor(id: string, input: UpdateVisitorInput): Promise<SbResult<{
|
|
816
|
+
visitor: ChatVisitor;
|
|
817
|
+
}>>;
|
|
818
|
+
banVisitor(id: string): Promise<SbResult<{
|
|
819
|
+
visitor: ChatVisitor;
|
|
820
|
+
}>>;
|
|
821
|
+
listCannedReplies(): Promise<SbResult<{
|
|
822
|
+
data: CannedReply[];
|
|
823
|
+
}>>;
|
|
824
|
+
createCannedReply(input: CannedReplyInput): Promise<SbResult<{
|
|
825
|
+
reply: CannedReply;
|
|
826
|
+
}>>;
|
|
827
|
+
updateCannedReply(id: number | string, input: CannedReplyInput): Promise<SbResult<{
|
|
828
|
+
reply: CannedReply;
|
|
829
|
+
}>>;
|
|
830
|
+
deleteCannedReply(id: number | string): Promise<SbResult<unknown>>;
|
|
831
|
+
listChatTriggers(): Promise<SbResult<{
|
|
832
|
+
data: ChatTrigger[];
|
|
833
|
+
schema: Record<string, string[]>;
|
|
834
|
+
}>>;
|
|
835
|
+
createChatTrigger(input: ChatTriggerInput): Promise<SbResult<{
|
|
836
|
+
trigger: ChatTrigger;
|
|
837
|
+
}>>;
|
|
838
|
+
updateChatTrigger(id: number | string, input: Partial<ChatTriggerInput>): Promise<SbResult<{
|
|
839
|
+
trigger: ChatTrigger;
|
|
840
|
+
}>>;
|
|
841
|
+
deleteChatTrigger(id: number | string): Promise<SbResult<unknown>>;
|
|
842
|
+
/**
|
|
843
|
+
* Yanıt süresi, çözüm süresi, memnuniyet ve ajan kırılımı.
|
|
844
|
+
* Veri yoksa süreler `null` döner — 0 DEĞİL.
|
|
845
|
+
*/
|
|
846
|
+
chatReport(range?: ChatReportRange): Promise<SbResult<ChatReport>>;
|
|
847
|
+
listApps(): Promise<SbResult<AppRecord[]>>;
|
|
848
|
+
/** Yanıttaki `public_key` (`sbw_pub_…`) istemciye gömülür; gizli değildir. */
|
|
849
|
+
createApp(input: AppInput): Promise<SbResult<AppRecord>>;
|
|
850
|
+
getApp(id: number | string): Promise<SbResult<AppRecord>>;
|
|
851
|
+
updateApp(id: number | string, input: AppInput): Promise<SbResult<AppRecord>>;
|
|
852
|
+
deleteApp(id: number | string): Promise<SbResult<unknown>>;
|
|
853
|
+
/** Açık anahtarı yeniler; siteye gömülü eski anahtar ANINDA çalışmaz olur. */
|
|
854
|
+
rotateAppKey(id: number | string): Promise<SbResult<AppRecord>>;
|
|
855
|
+
listAppDevices(id: number | string, query?: ListAppDevicesQuery): Promise<SbResult<Paginated<AppDevice>>>;
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
/**
|
|
859
|
+
* Partner (beşinci yüzey) tipleri.
|
|
860
|
+
*
|
|
861
|
+
* Sözleşme: docs/CONTRACT.md § 12 ve
|
|
862
|
+
* signalbird.api/docs/PARTNER_PLATFORM_2026-08-20.md.
|
|
863
|
+
*
|
|
864
|
+
* Alan adları API ile birebir aynıdır (snake_case) — SDK yeniden adlandırmaz.
|
|
865
|
+
*/
|
|
866
|
+
|
|
867
|
+
interface PartnerConfig {
|
|
868
|
+
/** `sbp_live_…` — sözleşmeli partner anahtarı. Tarayıcıya İNMEZ. */
|
|
869
|
+
apiKey: string;
|
|
870
|
+
baseUrl?: string;
|
|
871
|
+
timeout?: number;
|
|
872
|
+
throwOnError?: boolean;
|
|
873
|
+
debug?: boolean;
|
|
874
|
+
}
|
|
875
|
+
interface PartnerOwnerInput {
|
|
876
|
+
email: string;
|
|
877
|
+
name?: string;
|
|
878
|
+
/** Partner'ın kendi tarafındaki kullanıcı kimliği. */
|
|
879
|
+
external_id?: string;
|
|
880
|
+
locale?: string;
|
|
881
|
+
}
|
|
882
|
+
interface CreateCompanyInput {
|
|
883
|
+
/** Partner'ın kendi tarafındaki müşteri kimliği — idempotens anahtarı. */
|
|
884
|
+
external_id: string;
|
|
885
|
+
name: string;
|
|
886
|
+
owner: PartnerOwnerInput;
|
|
887
|
+
team_name?: string;
|
|
888
|
+
link_email?: string;
|
|
889
|
+
}
|
|
890
|
+
interface PartnerCompany {
|
|
891
|
+
id: number;
|
|
892
|
+
external_id: string;
|
|
893
|
+
name: string;
|
|
894
|
+
status: string;
|
|
895
|
+
billing_managed_by_partner: boolean;
|
|
896
|
+
modules: string[];
|
|
897
|
+
created_at: string | null;
|
|
898
|
+
}
|
|
899
|
+
interface CreateCompanyResult {
|
|
900
|
+
created: boolean;
|
|
901
|
+
company: PartnerCompany;
|
|
902
|
+
team: {
|
|
903
|
+
id: number | null;
|
|
904
|
+
name: string | null;
|
|
905
|
+
};
|
|
906
|
+
owner: {
|
|
907
|
+
id: number | null;
|
|
908
|
+
email: string | null;
|
|
909
|
+
name: string | null;
|
|
910
|
+
};
|
|
911
|
+
/** YALNIZ ilk oluşturmada döner. Kaybedilirse `rotateKey` yenisini üretir. */
|
|
912
|
+
keys?: {
|
|
913
|
+
api_key: string;
|
|
914
|
+
app_key: string;
|
|
915
|
+
};
|
|
916
|
+
}
|
|
917
|
+
interface DnsRecord {
|
|
918
|
+
host: string;
|
|
919
|
+
type: string;
|
|
920
|
+
value: string;
|
|
921
|
+
}
|
|
922
|
+
interface PartnerDomain {
|
|
923
|
+
id: number;
|
|
924
|
+
external_id: string;
|
|
925
|
+
domain: string;
|
|
926
|
+
verified_at: string | null;
|
|
927
|
+
/** `txt` | `partner` — partner beyanı kampanya için YETMEZ. */
|
|
928
|
+
verified_via: string | null;
|
|
929
|
+
can_send_campaigns: boolean;
|
|
930
|
+
is_active: boolean;
|
|
931
|
+
}
|
|
932
|
+
interface AddDomainInput {
|
|
933
|
+
external_id: string;
|
|
934
|
+
domain: string;
|
|
935
|
+
monitoring?: {
|
|
936
|
+
enabled?: boolean;
|
|
937
|
+
frequency?: number;
|
|
938
|
+
};
|
|
939
|
+
}
|
|
940
|
+
interface AddDomainResult {
|
|
941
|
+
created: boolean;
|
|
942
|
+
domain: PartnerDomain;
|
|
943
|
+
watcher: {
|
|
944
|
+
id: number;
|
|
945
|
+
frequency: number;
|
|
946
|
+
} | null;
|
|
947
|
+
dns: DnsRecord[];
|
|
948
|
+
note: string;
|
|
949
|
+
}
|
|
950
|
+
interface VerifyDomainResult {
|
|
951
|
+
verified: boolean;
|
|
952
|
+
domain: PartnerDomain;
|
|
953
|
+
dns: DnsRecord[];
|
|
954
|
+
}
|
|
955
|
+
interface UptimeIncident {
|
|
956
|
+
started_at: string;
|
|
957
|
+
ended_at: string | null;
|
|
958
|
+
duration_s: number;
|
|
959
|
+
reason: string | null;
|
|
960
|
+
}
|
|
961
|
+
interface UptimeReport {
|
|
962
|
+
domain?: string;
|
|
963
|
+
external_id?: string;
|
|
964
|
+
monitored?: boolean;
|
|
965
|
+
range: string;
|
|
966
|
+
/** Hiç kontrol yoksa `null` döner — %100 DEĞİL. */
|
|
967
|
+
uptime: number | null;
|
|
968
|
+
avg_response_ms: number | null;
|
|
969
|
+
checks: number;
|
|
970
|
+
status: string | null;
|
|
971
|
+
last_checked_at: string | null;
|
|
972
|
+
incidents: UptimeIncident[];
|
|
973
|
+
}
|
|
974
|
+
type UptimeRange = '24h' | '7d' | '30d';
|
|
975
|
+
interface ModuleEntitlement {
|
|
976
|
+
module: string;
|
|
977
|
+
limits: Record<string, number>;
|
|
978
|
+
source: string;
|
|
979
|
+
expires_at: string | null;
|
|
980
|
+
}
|
|
981
|
+
interface GrantModuleInput {
|
|
982
|
+
module: string;
|
|
983
|
+
limits?: Record<string, number>;
|
|
984
|
+
/** Aboneliğin bittiği tarih; yenilemede tazelenmezse modül kendi kapanır. */
|
|
985
|
+
expires_at?: string;
|
|
986
|
+
reason?: string;
|
|
987
|
+
}
|
|
988
|
+
interface PartnerUserInput {
|
|
989
|
+
external_id: string;
|
|
990
|
+
email: string;
|
|
991
|
+
name?: string;
|
|
992
|
+
role?: 'owner' | 'billing' | 'member';
|
|
993
|
+
team_role?: string;
|
|
994
|
+
permissions?: string[];
|
|
995
|
+
}
|
|
996
|
+
interface PartnerUser {
|
|
997
|
+
id: number;
|
|
998
|
+
external_id: string | null;
|
|
999
|
+
email: string;
|
|
1000
|
+
name: string | null;
|
|
1001
|
+
role: string | null;
|
|
1002
|
+
}
|
|
1003
|
+
type EmbedModule = 'chat' | 'monitoring' | 'campaigns' | 'contacts' | 'radio';
|
|
1004
|
+
interface EmbedTokenInput {
|
|
1005
|
+
user_external_id: string;
|
|
1006
|
+
module: EmbedModule;
|
|
1007
|
+
locale?: string;
|
|
1008
|
+
theme?: 'light' | 'dark';
|
|
1009
|
+
accent?: string;
|
|
1010
|
+
}
|
|
1011
|
+
interface EmbedToken {
|
|
1012
|
+
url: string;
|
|
1013
|
+
token: string;
|
|
1014
|
+
expires_at: string;
|
|
1015
|
+
ttl: number;
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
/**
|
|
1019
|
+
* Partner istemcisi — BEŞİNCİ yüzey.
|
|
1020
|
+
*
|
|
1021
|
+
* Signalbird'ü kendi ürününün içinde satan sözleşmeli platform (veribenim,
|
|
1022
|
+
* submitcms) müşterisini bununla sağlar ve yetkilendirir: company + takım +
|
|
1023
|
+
* owner açar, domain ekler ve izlemeye alır, uptime okur, modül açar/kapatır,
|
|
1024
|
+
* gömme jetonu üretir.
|
|
1025
|
+
*
|
|
1026
|
+
* **Bu, CLAUDE.md'deki "Admin yüzeyi OLMAYACAK" kuralının bilinçli
|
|
1027
|
+
* istisnasıdır** ve istisna olduğu için ayrı anahtar türü taşır. Kural,
|
|
1028
|
+
* müşterinin kendi anahtarıyla (`sb_`) şirket açamaması içindi; o kural aynen
|
|
1029
|
+
* duruyor. Sözleşmeli partner farklı bir taraftır.
|
|
1030
|
+
*
|
|
1031
|
+
* Anahtar `sbp_live_…` **asla tarayıcıya inmez**: gömme jetonunu partner'ın
|
|
1032
|
+
* kendi sunucusu üretir, tarayıcı yalnız o kısa ömürlü jetonu görür.
|
|
1033
|
+
*
|
|
1034
|
+
* Sözleşme: docs/CONTRACT.md § 12
|
|
1035
|
+
*/
|
|
1036
|
+
|
|
1037
|
+
declare class SignalbirdPartner {
|
|
1038
|
+
private readonly http;
|
|
1039
|
+
constructor(config: PartnerConfig);
|
|
1040
|
+
/**
|
|
1041
|
+
* Company + takım + owner açar. **Idempotenttir**: aynı `external_id` ile
|
|
1042
|
+
* ikinci çağrı yeni kayıt açmaz, `created:false` ile var olanı döner.
|
|
1043
|
+
* Anahtarlar (`keys`) yalnız ilk oluşturmada gelir.
|
|
1044
|
+
*/
|
|
1045
|
+
createCompany(input: CreateCompanyInput): Promise<SbResult<CreateCompanyResult>>;
|
|
1046
|
+
listCompanies(query?: {
|
|
1047
|
+
page?: number;
|
|
1048
|
+
q?: string;
|
|
1049
|
+
per_page?: number;
|
|
1050
|
+
}): Promise<SbResult<{
|
|
1051
|
+
data: PartnerCompany[];
|
|
1052
|
+
meta: Record<string, number>;
|
|
1053
|
+
}>>;
|
|
1054
|
+
getCompany(externalId: string): Promise<SbResult<{
|
|
1055
|
+
company: PartnerCompany;
|
|
1056
|
+
}>>;
|
|
1057
|
+
updateCompany(externalId: string, input: {
|
|
1058
|
+
name?: string;
|
|
1059
|
+
is_active?: boolean;
|
|
1060
|
+
}): Promise<SbResult<{
|
|
1061
|
+
company: PartnerCompany;
|
|
1062
|
+
}>>;
|
|
1063
|
+
/** Askıya alır — SİLMEZ. Müşterinin izleme ve mesaj geçmişi durur. */
|
|
1064
|
+
suspendCompany(externalId: string): Promise<SbResult<{
|
|
1065
|
+
company: PartnerCompany;
|
|
1066
|
+
}>>;
|
|
1067
|
+
rotateKey(externalId: string, type: 'api' | 'app'): Promise<SbResult<{
|
|
1068
|
+
type: string;
|
|
1069
|
+
key: string;
|
|
1070
|
+
}>>;
|
|
1071
|
+
/**
|
|
1072
|
+
* Domain ekler ve (istenirse) izlemeye alır. Kayıt `verified_via:'partner'`
|
|
1073
|
+
* ile doğar: izleme, sohbet ve push için yeter — **e-posta/SMS kampanyası
|
|
1074
|
+
* için TXT şarttır**. Yanıttaki `dns` kaydını yayınlayıp `verifyDomain`
|
|
1075
|
+
* çağırmak kapıyı açar.
|
|
1076
|
+
*/
|
|
1077
|
+
addDomain(companyExternalId: string, input: AddDomainInput): Promise<SbResult<AddDomainResult>>;
|
|
1078
|
+
listDomains(companyExternalId: string): Promise<SbResult<{
|
|
1079
|
+
data: PartnerDomain[];
|
|
1080
|
+
}>>;
|
|
1081
|
+
getDomain(externalId: string): Promise<SbResult<{
|
|
1082
|
+
domain: PartnerDomain;
|
|
1083
|
+
}>>;
|
|
1084
|
+
/** TXT'yi hemen sorgular; eşleşirse domain kampanya kapısından geçer olur. */
|
|
1085
|
+
verifyDomain(externalId: string): Promise<SbResult<VerifyDomainResult>>;
|
|
1086
|
+
removeDomain(externalId: string): Promise<SbResult<{
|
|
1087
|
+
deleted: boolean;
|
|
1088
|
+
}>>;
|
|
1089
|
+
domainUptime(externalId: string, range?: UptimeRange): Promise<SbResult<UptimeReport>>;
|
|
1090
|
+
/** Tek istekte müşterinin tüm domainleri — liste ekranı N+1 atmasın. */
|
|
1091
|
+
companyUptime(companyExternalId: string, range?: UptimeRange): Promise<SbResult<{
|
|
1092
|
+
range: string;
|
|
1093
|
+
data: UptimeReport[];
|
|
1094
|
+
}>>;
|
|
1095
|
+
listModules(companyExternalId: string): Promise<SbResult<{
|
|
1096
|
+
data: ModuleEntitlement[];
|
|
1097
|
+
}>>;
|
|
1098
|
+
/** "Bu müşteri şu modül için ödeme yaptı, kullanabilir." */
|
|
1099
|
+
grantModule(companyExternalId: string, input: GrantModuleInput): Promise<SbResult<ModuleEntitlement>>;
|
|
1100
|
+
/** Yalnız partner'ın KENDİ verdiği hakkı geri alır; plan hakkına dokunmaz. */
|
|
1101
|
+
revokeModule(companyExternalId: string, module: string): Promise<SbResult<{
|
|
1102
|
+
removed: boolean;
|
|
1103
|
+
}>>;
|
|
1104
|
+
createUser(companyExternalId: string, input: PartnerUserInput): Promise<SbResult<{
|
|
1105
|
+
created: boolean;
|
|
1106
|
+
user: PartnerUser;
|
|
1107
|
+
}>>;
|
|
1108
|
+
listUsers(companyExternalId: string): Promise<SbResult<{
|
|
1109
|
+
data: PartnerUser[];
|
|
1110
|
+
}>>;
|
|
1111
|
+
/** Üyeliği kaldırır, kişinin Signalbird hesabını SİLMEZ. */
|
|
1112
|
+
removeUser(companyExternalId: string, userExternalId: string): Promise<SbResult<{
|
|
1113
|
+
removed: boolean;
|
|
1114
|
+
}>>;
|
|
1115
|
+
/**
|
|
1116
|
+
* Panel ekranını partner sayfasına gömmek için kısa ömürlü jeton üretir.
|
|
1117
|
+
* 120 saniye yaşar ve TEK KULLANIMLIKTIR — jeton URL'de gider, log ve
|
|
1118
|
+
* `Referer` başlığına düşer.
|
|
1119
|
+
*/
|
|
1120
|
+
createEmbedToken(companyExternalId: string, input: EmbedTokenInput): Promise<SbResult<EmbedToken>>;
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
declare function verifyWebhook(rawBody: string | Uint8Array, signatureHeader: string | null | undefined, secret: string): boolean;
|
|
1124
|
+
|
|
1125
|
+
/**
|
|
1126
|
+
* signalbird — sunucu tarafı giriş noktası.
|
|
1127
|
+
*
|
|
1128
|
+
* Next.js sunucu bileşenleri, API route'ları, Express/Fastify/NestJS ve düz
|
|
1129
|
+
* Node betikleri buradan alır. TARAYICI için `signalbird/browser`
|
|
1130
|
+
* kullanılır — gizli anahtar istemciye inmez.
|
|
1131
|
+
*
|
|
1132
|
+
* Üç sunucu istemcisi vardır; anahtarları ve kapıları farklıdır:
|
|
1133
|
+
* - `SignalbirdClient` → Telsiz (log yazma), `sbr_live_…`
|
|
1134
|
+
* - `SignalbirdMessaging` → Gönderim (e-posta/SMS/push/kişi/kampanya), `sb_…`
|
|
1135
|
+
* - `SignalbirdManagement` → Yönetim (Telsiz projesi, sohbet gelen kutusu,
|
|
1136
|
+
* uygulama kaydı), `sb_…` + `radio|chat|apps` scope'ları
|
|
1137
|
+
* - `SignalbirdPartner` → Partner (müşteri sağlama, modül yetkisi, gömme),
|
|
1138
|
+
* `sbp_live_…` — yalnız sözleşmeli platformlar
|
|
1139
|
+
*
|
|
1140
|
+
* Son kullanıcı (ziyaretçi) yüzeyi ayrı giriş noktasındadır:
|
|
1141
|
+
* `signalbird/app` — ve onun çatı uyarlamaları `/react`, `/vue`,
|
|
1142
|
+
* `/angular`, `/react-native`.
|
|
1143
|
+
*/
|
|
1144
|
+
|
|
1145
|
+
/**
|
|
1146
|
+
* Ortam değişkeninden kurulan paylaşımlı istemci.
|
|
1147
|
+
*
|
|
1148
|
+
* `SIGNALBIRD_KEY` okunur. Uygulamanın her köşesinde istemci kurup anahtarı
|
|
1149
|
+
* elden ele taşımak yerine tek çağrı yeter:
|
|
1150
|
+
*
|
|
1151
|
+
* import { signalbird } from 'signalbird'
|
|
1152
|
+
* await signalbird().critical('critical', 'ödeme servisi öldü')
|
|
1153
|
+
*/
|
|
1154
|
+
declare function signalbird(config?: Partial<SignalbirdConfig>): SignalbirdClient;
|
|
1155
|
+
/** Test ve sıcak yeniden yükleme için tekil istemciyi sıfırlar. */
|
|
1156
|
+
declare function resetSignalbird(): void;
|
|
1157
|
+
/**
|
|
1158
|
+
* Ortam değişkeninden kurulan paylaşımlı yönetim istemcisi.
|
|
1159
|
+
*
|
|
1160
|
+
* `SIGNALBIRD_API_KEY` okunur (yoksa `SIGNALBIRD_MESSAGING_KEY` — ikisi de aynı
|
|
1161
|
+
* takım anahtarı ailesidir ve çoğu kurulumda tek anahtar kullanılır).
|
|
1162
|
+
*
|
|
1163
|
+
* import { management } from 'signalbird'
|
|
1164
|
+
* await management().createRadioProject({ name: 'ödeme-servisi' })
|
|
1165
|
+
*/
|
|
1166
|
+
declare function management(config?: Partial<ManagementConfig>): SignalbirdManagement;
|
|
1167
|
+
/** Test ve sıcak yeniden yükleme için yönetim istemcisini sıfırlar. */
|
|
1168
|
+
declare function resetManagement(): void;
|
|
1169
|
+
|
|
1170
|
+
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 UpdateConversationInput, type UpdateRadioProjectInput, type UpdateVisitorInput, type UptimeIncident, type UptimeRange, type UptimeReport, type VerifyDomainResult, management, resetManagement, resetSignalbird, signalbird, verifyWebhook };
|