@messagebird/sdk 0.16.0 → 0.21.2
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.mts +610 -470
- package/dist/index.mjs +413 -251
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1031,6 +1031,23 @@ var BirdHTTPClient = class {
|
|
|
1031
1031
|
this.defaults = defaults;
|
|
1032
1032
|
}
|
|
1033
1033
|
/**
|
|
1034
|
+
* Resolve the credential headers an operation's security schemes require.
|
|
1035
|
+
* Throws before the request when one is unconfigured, so a caller gets a named
|
|
1036
|
+
* error instead of a 401.
|
|
1037
|
+
*/
|
|
1038
|
+
credentialHeaders(schemes, override) {
|
|
1039
|
+
if (!schemes?.length) return {};
|
|
1040
|
+
const out = {};
|
|
1041
|
+
for (const scheme of schemes) {
|
|
1042
|
+
const cred = this.defaults.credentials?.[scheme];
|
|
1043
|
+
if (!cred) throw new Error(`Unknown credential scheme "${scheme}"`);
|
|
1044
|
+
const value = override?.[scheme] ?? cred.value;
|
|
1045
|
+
if (!value) throw new Error(`${cred.header} is required for this operation. ${cred.how}`);
|
|
1046
|
+
out[cred.header] = value;
|
|
1047
|
+
}
|
|
1048
|
+
return out;
|
|
1049
|
+
}
|
|
1050
|
+
/**
|
|
1034
1051
|
* Run a generated hey-api SDK call through the request lifecycle.
|
|
1035
1052
|
*
|
|
1036
1053
|
* @param call Invokes the SDK function; receives the per-attempt signal and
|
|
@@ -1188,14 +1205,25 @@ const client = createClient(createConfig());
|
|
|
1188
1205
|
* Publishes an event to one or more channels of a Realtime app. Listing several channels broadcasts the event to all of them in one call. Connected clients subscribed to those channels receive it in real time.
|
|
1189
1206
|
*/
|
|
1190
1207
|
const publishRealtimeAppEvent = (options) => (options.client ?? client).post({
|
|
1191
|
-
security: [
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1208
|
+
security: [
|
|
1209
|
+
{
|
|
1210
|
+
scheme: "bearer",
|
|
1211
|
+
type: "http"
|
|
1212
|
+
},
|
|
1213
|
+
{
|
|
1214
|
+
name: "X-Realtime-Key",
|
|
1215
|
+
type: "apiKey"
|
|
1216
|
+
},
|
|
1217
|
+
{
|
|
1218
|
+
name: "X-Realtime-Secret",
|
|
1219
|
+
type: "apiKey"
|
|
1220
|
+
},
|
|
1221
|
+
{
|
|
1222
|
+
in: "cookie",
|
|
1223
|
+
name: "bird_session",
|
|
1224
|
+
type: "apiKey"
|
|
1225
|
+
}
|
|
1226
|
+
],
|
|
1199
1227
|
url: "/v1/realtime/apps/{realtime_app_id}/events",
|
|
1200
1228
|
...options,
|
|
1201
1229
|
headers: {
|
|
@@ -1209,14 +1237,25 @@ const publishRealtimeAppEvent = (options) => (options.client ?? client).post({
|
|
|
1209
1237
|
* Publishes up to 10 events (each to one channel) in a single request.
|
|
1210
1238
|
*/
|
|
1211
1239
|
const publishRealtimeAppBatch = (options) => (options.client ?? client).post({
|
|
1212
|
-
security: [
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1240
|
+
security: [
|
|
1241
|
+
{
|
|
1242
|
+
scheme: "bearer",
|
|
1243
|
+
type: "http"
|
|
1244
|
+
},
|
|
1245
|
+
{
|
|
1246
|
+
name: "X-Realtime-Key",
|
|
1247
|
+
type: "apiKey"
|
|
1248
|
+
},
|
|
1249
|
+
{
|
|
1250
|
+
name: "X-Realtime-Secret",
|
|
1251
|
+
type: "apiKey"
|
|
1252
|
+
},
|
|
1253
|
+
{
|
|
1254
|
+
in: "cookie",
|
|
1255
|
+
name: "bird_session",
|
|
1256
|
+
type: "apiKey"
|
|
1257
|
+
}
|
|
1258
|
+
],
|
|
1220
1259
|
url: "/v1/realtime/apps/{realtime_app_id}/batch-events",
|
|
1221
1260
|
...options,
|
|
1222
1261
|
headers: {
|
|
@@ -1230,14 +1269,25 @@ const publishRealtimeAppBatch = (options) => (options.client ?? client).post({
|
|
|
1230
1269
|
* Lists the app's currently occupied channels, optionally filtered by name prefix.
|
|
1231
1270
|
*/
|
|
1232
1271
|
const listRealtimeAppChannels = (options) => (options.client ?? client).get({
|
|
1233
|
-
security: [
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1272
|
+
security: [
|
|
1273
|
+
{
|
|
1274
|
+
scheme: "bearer",
|
|
1275
|
+
type: "http"
|
|
1276
|
+
},
|
|
1277
|
+
{
|
|
1278
|
+
name: "X-Realtime-Key",
|
|
1279
|
+
type: "apiKey"
|
|
1280
|
+
},
|
|
1281
|
+
{
|
|
1282
|
+
name: "X-Realtime-Secret",
|
|
1283
|
+
type: "apiKey"
|
|
1284
|
+
},
|
|
1285
|
+
{
|
|
1286
|
+
in: "cookie",
|
|
1287
|
+
name: "bird_session",
|
|
1288
|
+
type: "apiKey"
|
|
1289
|
+
}
|
|
1290
|
+
],
|
|
1241
1291
|
url: "/v1/realtime/apps/{realtime_app_id}/channels",
|
|
1242
1292
|
...options
|
|
1243
1293
|
});
|
|
@@ -1247,14 +1297,25 @@ const listRealtimeAppChannels = (options) => (options.client ?? client).get({
|
|
|
1247
1297
|
* Returns a single channel's occupancy and (on request) counts. Channels exist implicitly — a channel appears when the first connection subscribes and vanishes when the last one leaves — so this endpoint reports state, not existence: an unknown or never-used name returns 200 with `occupied: false`, never 404.
|
|
1248
1298
|
*/
|
|
1249
1299
|
const getRealtimeAppChannel = (options) => (options.client ?? client).get({
|
|
1250
|
-
security: [
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1300
|
+
security: [
|
|
1301
|
+
{
|
|
1302
|
+
scheme: "bearer",
|
|
1303
|
+
type: "http"
|
|
1304
|
+
},
|
|
1305
|
+
{
|
|
1306
|
+
name: "X-Realtime-Key",
|
|
1307
|
+
type: "apiKey"
|
|
1308
|
+
},
|
|
1309
|
+
{
|
|
1310
|
+
name: "X-Realtime-Secret",
|
|
1311
|
+
type: "apiKey"
|
|
1312
|
+
},
|
|
1313
|
+
{
|
|
1314
|
+
in: "cookie",
|
|
1315
|
+
name: "bird_session",
|
|
1316
|
+
type: "apiKey"
|
|
1317
|
+
}
|
|
1318
|
+
],
|
|
1258
1319
|
url: "/v1/realtime/apps/{realtime_app_id}/channels/{channel_name}",
|
|
1259
1320
|
...options
|
|
1260
1321
|
});
|
|
@@ -1264,14 +1325,25 @@ const getRealtimeAppChannel = (options) => (options.client ?? client).get({
|
|
|
1264
1325
|
* Lists the member ids currently subscribed to a presence channel. Ids only: `member_info` (the profile data attached by your authorization endpoint) is delivered to subscribed clients over the realtime connection and is not available over REST.
|
|
1265
1326
|
*/
|
|
1266
1327
|
const listRealtimeAppChannelMembers = (options) => (options.client ?? client).get({
|
|
1267
|
-
security: [
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1328
|
+
security: [
|
|
1329
|
+
{
|
|
1330
|
+
scheme: "bearer",
|
|
1331
|
+
type: "http"
|
|
1332
|
+
},
|
|
1333
|
+
{
|
|
1334
|
+
name: "X-Realtime-Key",
|
|
1335
|
+
type: "apiKey"
|
|
1336
|
+
},
|
|
1337
|
+
{
|
|
1338
|
+
name: "X-Realtime-Secret",
|
|
1339
|
+
type: "apiKey"
|
|
1340
|
+
},
|
|
1341
|
+
{
|
|
1342
|
+
in: "cookie",
|
|
1343
|
+
name: "bird_session",
|
|
1344
|
+
type: "apiKey"
|
|
1345
|
+
}
|
|
1346
|
+
],
|
|
1275
1347
|
url: "/v1/realtime/apps/{realtime_app_id}/channels/{channel_name}/members",
|
|
1276
1348
|
...options
|
|
1277
1349
|
});
|
|
@@ -1281,18 +1353,62 @@ const listRealtimeAppChannelMembers = (options) => (options.client ?? client).ge
|
|
|
1281
1353
|
* Disconnects all of a member's active connections (e.g. on sign-out or ban).
|
|
1282
1354
|
*/
|
|
1283
1355
|
const disconnectRealtimeAppMember = (options) => (options.client ?? client).post({
|
|
1284
|
-
security: [
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1356
|
+
security: [
|
|
1357
|
+
{
|
|
1358
|
+
scheme: "bearer",
|
|
1359
|
+
type: "http"
|
|
1360
|
+
},
|
|
1361
|
+
{
|
|
1362
|
+
name: "X-Realtime-Key",
|
|
1363
|
+
type: "apiKey"
|
|
1364
|
+
},
|
|
1365
|
+
{
|
|
1366
|
+
name: "X-Realtime-Secret",
|
|
1367
|
+
type: "apiKey"
|
|
1368
|
+
},
|
|
1369
|
+
{
|
|
1370
|
+
in: "cookie",
|
|
1371
|
+
name: "bird_session",
|
|
1372
|
+
type: "apiKey"
|
|
1373
|
+
}
|
|
1374
|
+
],
|
|
1292
1375
|
url: "/v1/realtime/apps/{realtime_app_id}/members/{member_id}/disconnect",
|
|
1293
1376
|
...options
|
|
1294
1377
|
});
|
|
1295
1378
|
/**
|
|
1379
|
+
* Send an event to a member
|
|
1380
|
+
*
|
|
1381
|
+
* Delivers an event to one member of a Realtime app, addressing the person rather than a channel. Every connection that member currently holds receives it, across tabs and devices, so there is no need to track their connections or give them a channel of their own.
|
|
1382
|
+
* The member must have signed in on the connection for it to be addressable. Delivery is best-effort and not queued: a member holding no connections at the moment of the call simply does not receive the event.
|
|
1383
|
+
*/
|
|
1384
|
+
const sendRealtimeAppMemberEvent = (options) => (options.client ?? client).post({
|
|
1385
|
+
security: [
|
|
1386
|
+
{
|
|
1387
|
+
scheme: "bearer",
|
|
1388
|
+
type: "http"
|
|
1389
|
+
},
|
|
1390
|
+
{
|
|
1391
|
+
name: "X-Realtime-Key",
|
|
1392
|
+
type: "apiKey"
|
|
1393
|
+
},
|
|
1394
|
+
{
|
|
1395
|
+
name: "X-Realtime-Secret",
|
|
1396
|
+
type: "apiKey"
|
|
1397
|
+
},
|
|
1398
|
+
{
|
|
1399
|
+
in: "cookie",
|
|
1400
|
+
name: "bird_session",
|
|
1401
|
+
type: "apiKey"
|
|
1402
|
+
}
|
|
1403
|
+
],
|
|
1404
|
+
url: "/v1/realtime/apps/{realtime_app_id}/members/{member_id}/events",
|
|
1405
|
+
...options,
|
|
1406
|
+
headers: {
|
|
1407
|
+
"Content-Type": "application/json",
|
|
1408
|
+
...options.headers
|
|
1409
|
+
}
|
|
1410
|
+
});
|
|
1411
|
+
/**
|
|
1296
1412
|
* List messages
|
|
1297
1413
|
*
|
|
1298
1414
|
* Returns the workspace's sent and scheduled messages, newest first, as a cursor page. Each item carries the aggregate delivery `status` and per-state recipient counts, not the message body. Combine filters to narrow the page: `status`, `category`, `tag`, exact `to`/`from` address, and a `created_after`/`created_before` time window.
|
|
@@ -1311,7 +1427,7 @@ const listEmailMessages = (options) => (options?.client ?? client).get({
|
|
|
1311
1427
|
...options
|
|
1312
1428
|
});
|
|
1313
1429
|
/**
|
|
1314
|
-
* Send
|
|
1430
|
+
* Send an email message
|
|
1315
1431
|
*
|
|
1316
1432
|
* Sends an email to the recipients you list explicitly in `to`/`cc`/`bcc`. Use it for
|
|
1317
1433
|
* transactional sends (receipts, password resets, alerts) and for marketing sends where
|
|
@@ -1408,7 +1524,7 @@ const cancelEmailMessage = (options) => (options.client ?? client).post({
|
|
|
1408
1524
|
/**
|
|
1409
1525
|
* List contacts
|
|
1410
1526
|
*
|
|
1411
|
-
* Returns a paginated list of contacts in the workspace, newest first. Look up a single contact by its exact `email` or `external_id`, or search by email substring with `q`.
|
|
1527
|
+
* Returns a paginated list of contacts in the workspace, newest first. Look up a single contact by its exact `email`, `phone`, or `external_id`, or search by email, first name, last name, or phone substring with `q`. Pass `include_total=true` to add the total number of matching contacts to the response.
|
|
1412
1528
|
*
|
|
1413
1529
|
*/
|
|
1414
1530
|
const listContacts = (options) => (options?.client ?? client).get({
|
|
@@ -1426,7 +1542,7 @@ const listContacts = (options) => (options?.client ?? client).get({
|
|
|
1426
1542
|
/**
|
|
1427
1543
|
* Create a contact
|
|
1428
1544
|
*
|
|
1429
|
-
* Creates a contact in the workspace
|
|
1545
|
+
* Creates a contact in the workspace, identified by an email address, a phone number, or both; at least one is required. Email is stored trimmed and lowercased, and phone in its canonical international form. Creating a second contact with the same email or phone number, or reusing another contact's `external_id`, returns a conflict error.
|
|
1430
1546
|
*
|
|
1431
1547
|
* To create or update many contacts in one request, or to write a contact without knowing whether the address already exists, use [Create or update contacts in bulk](/docs/api/reference/create-contact-batch) instead.
|
|
1432
1548
|
*
|
|
@@ -1450,7 +1566,7 @@ const createContact = (options) => (options.client ?? client).post({
|
|
|
1450
1566
|
/**
|
|
1451
1567
|
* Create or update contacts in bulk
|
|
1452
1568
|
*
|
|
1453
|
-
* Creates or updates up to 1,000 contacts in one request
|
|
1569
|
+
* Creates or updates up to 1,000 contacts in one request. Each entry is matched automatically against every identifier it supplies: its email address (trimmed and lowercased before matching), its phone number (normalized to international form), and your own `external_id`. An entry that matches no existing contact creates one; an entry whose identifiers all point at one contact updates it with the fields it supplies, and omitted fields keep their stored values, so a contact's email address can change under a stable `external_id` without creating a second record. An entry whose identifiers belong to more than one contact fails with an error naming each matched contact, since Bird never merges contacts or picks between them. Supplying `match_on` overrides the automatic matching: every entry is matched by that one field only, and must carry it. Optionally adds every contact in the request to up to 10 audiences.
|
|
1454
1570
|
*
|
|
1455
1571
|
* Each entry succeeds or fails on its own: the response lists one result per contact in submission order (`created`, `updated`, or `failed` with the reason), and a failed entry does not abort the rest. If the request itself is invalid, for example when an entry in `audience_ids` does not exist, the whole request fails with a validation error and no contacts are written.
|
|
1456
1572
|
*
|
|
@@ -1512,7 +1628,7 @@ const getContact = (options) => (options.client ?? client).get({
|
|
|
1512
1628
|
*
|
|
1513
1629
|
* Updates a contact. Supplied fields are changed and omitted fields are left unchanged; set `first_name`, `last_name`, or `external_id` to null to clear them. Custom values in `data` are merged: keys you supply are set, keys set to null are removed, and keys you omit are unchanged.
|
|
1514
1630
|
*
|
|
1515
|
-
* Changing the email address or `external_id` to a value already used by another contact returns a conflict error.
|
|
1631
|
+
* Changing the email address, phone number, or `external_id` to a value already used by another contact returns a conflict error, and a contact always keeps at least one identifier: clearing both email and phone in the same contact is rejected.
|
|
1516
1632
|
*
|
|
1517
1633
|
*/
|
|
1518
1634
|
const updateContact = (options) => (options.client ?? client).patch({
|
|
@@ -2024,7 +2140,7 @@ const createVerificationCheck = (options) => (options.client ?? client).post({
|
|
|
2024
2140
|
/**
|
|
2025
2141
|
* List WhatsApp messages
|
|
2026
2142
|
*
|
|
2027
|
-
* Returns the workspace's WhatsApp messages as a cursor-paginated list, newest first. Filter by status, contact phone number, business-scoped user ID, tag, or creation time; pass the response's `next_cursor` back as `starting_after` to fetch the next page. To follow a single message's delivery, use [Get a WhatsApp message](/docs/api/reference/get-whats-app-message) instead.
|
|
2143
|
+
* Returns the workspace's WhatsApp messages as a cursor-paginated list, newest first. Filter by direction, status, contact phone number, business-scoped user ID, tag, or creation time; pass the response's `next_cursor` back as `starting_after` to fetch the next page. To follow a single message's delivery, use [Get a WhatsApp message](/docs/api/reference/get-whats-app-message) instead.
|
|
2028
2144
|
*
|
|
2029
2145
|
*/
|
|
2030
2146
|
const listWhatsAppMessages = (options) => (options?.client ?? client).get({
|
|
@@ -2044,10 +2160,10 @@ const listWhatsAppMessages = (options) => (options?.client ?? client).get({
|
|
|
2044
2160
|
*
|
|
2045
2161
|
* Sends a WhatsApp message built from a message template to one recipient.
|
|
2046
2162
|
* Name the template, optionally pick its language variant, and fill its
|
|
2047
|
-
* placeholders in `components`; Bird selects
|
|
2048
|
-
*
|
|
2049
|
-
*
|
|
2050
|
-
*
|
|
2163
|
+
* placeholders in `components`; a Bird-managed template selects its sender
|
|
2164
|
+
* number from its category, so the request carries no sender field. A request
|
|
2165
|
+
* that carries no content is rejected with a `422`. Browse your workspace's
|
|
2166
|
+
* templates in the Bird dashboard.
|
|
2051
2167
|
*
|
|
2052
2168
|
* The `202` response is the accepted message, echoing the resolved template
|
|
2053
2169
|
* and language; it is not a delivery confirmation. Follow delivery with
|
|
@@ -2058,10 +2174,11 @@ const listWhatsAppMessages = (options) => (options?.client ?? client).get({
|
|
|
2058
2174
|
*
|
|
2059
2175
|
* A template slug or language the catalogue does not stock, parameter values
|
|
2060
2176
|
* that do not match the template's declared placeholders, and a recipient
|
|
2061
|
-
* that is not a valid phone number each return a `422
|
|
2177
|
+
* that is not a valid phone number each return a `422`, as does a request
|
|
2178
|
+
* that carries no content at all.
|
|
2062
2179
|
*
|
|
2063
2180
|
*/
|
|
2064
|
-
const
|
|
2181
|
+
const createWhatsAppMessage = (options) => (options.client ?? client).post({
|
|
2065
2182
|
security: [{
|
|
2066
2183
|
scheme: "bearer",
|
|
2067
2184
|
type: "http"
|
|
@@ -2790,7 +2907,7 @@ const listMailboxReceiveRules = (options) => (options.client ?? client).get({
|
|
|
2790
2907
|
/**
|
|
2791
2908
|
* Add a receive rule
|
|
2792
2909
|
*
|
|
2793
|
-
* Adds an allow or block rule to the mailbox. Rules match the message's envelope sender; domain entries also match subdomains. Block rules always win — over allow rules and over the reply admission on allowlist mailboxes. An entry
|
|
2910
|
+
* Adds an allow or block rule to the mailbox. Rules match the message's envelope sender; domain entries also match subdomains. Block rules always win — over allow rules and over the reply admission on allowlist mailboxes. An entry is either allow or block. Rules have no update operation, so a rule that needs the other action is a new rule and the old one is removed. A mailbox holds up to 200 rules.
|
|
2794
2911
|
*
|
|
2795
2912
|
*/
|
|
2796
2913
|
const createMailboxReceiveRule = (options) => (options.client ?? client).post({
|
|
@@ -2812,7 +2929,7 @@ const createMailboxReceiveRule = (options) => (options.client ?? client).post({
|
|
|
2812
2929
|
/**
|
|
2813
2930
|
* Delete a receive rule
|
|
2814
2931
|
*
|
|
2815
|
-
* Removes a receive rule from the mailbox.
|
|
2932
|
+
* Removes a receive rule from the mailbox. There is no update operation for rules, so a rule's allow or block action cannot be changed after it is created.
|
|
2816
2933
|
*
|
|
2817
2934
|
*/
|
|
2818
2935
|
const deleteMailboxReceiveRule = (options) => (options.client ?? client).delete({
|
|
@@ -3047,18 +3164,23 @@ var Resource = class {
|
|
|
3047
3164
|
this.client = client;
|
|
3048
3165
|
}
|
|
3049
3166
|
/** Run a single typed call through the lifecycle. */
|
|
3050
|
-
call(method, options, invoke) {
|
|
3051
|
-
|
|
3167
|
+
call(method, options, invoke, schemes) {
|
|
3168
|
+
const credentials = this.core.credentialHeaders(schemes, options?.credentials);
|
|
3169
|
+
return apiPromise(this.core.request((ctx) => invoke(callContext(ctx, options, credentials)), lifecycle(method, options)));
|
|
3052
3170
|
}
|
|
3053
3171
|
/** Run a cursor-paginated list through the lifecycle (each page retried independently). */
|
|
3054
|
-
paginated(method, options, invoke) {
|
|
3055
|
-
|
|
3172
|
+
paginated(method, options, invoke, schemes) {
|
|
3173
|
+
const credentials = this.core.credentialHeaders(schemes, options?.credentials);
|
|
3174
|
+
return paginate((cursor) => this.core.request((ctx) => invoke(callContext(ctx, options, credentials), cursor), lifecycle(method, options)));
|
|
3056
3175
|
}
|
|
3057
3176
|
};
|
|
3058
|
-
function callContext(ctx, options) {
|
|
3177
|
+
function callContext(ctx, options, credentials = {}) {
|
|
3059
3178
|
return {
|
|
3060
3179
|
signal: ctx.signal,
|
|
3061
|
-
headers:
|
|
3180
|
+
headers: {
|
|
3181
|
+
...mergeHeaders(ctx.idempotencyKey, options?.headers),
|
|
3182
|
+
...credentials
|
|
3183
|
+
}
|
|
3062
3184
|
};
|
|
3063
3185
|
}
|
|
3064
3186
|
function lifecycle(method, options) {
|
|
@@ -3080,7 +3202,7 @@ function mergeHeaders(idempotencyKey, extra) {
|
|
|
3080
3202
|
//#region src/resources/email.gen.ts
|
|
3081
3203
|
var EmailResourceBase = class extends Resource {
|
|
3082
3204
|
/**
|
|
3083
|
-
* Fetch one email message by id
|
|
3205
|
+
* Fetch one email message by id, with aggregate delivery status and per-state recipient counts. The message body (html, text) is not returned. Per-recipient delivery statuses and the event log are separate sub-resources: GET /v1/email/messages/{message_id}/recipients and GET /v1/email/messages/{message_id}/events.
|
|
3084
3206
|
*
|
|
3085
3207
|
* @example
|
|
3086
3208
|
* const msg = await bird.email.get("em_abc123");
|
|
@@ -3097,7 +3219,7 @@ var EmailResourceBase = class extends Resource {
|
|
|
3097
3219
|
}));
|
|
3098
3220
|
}
|
|
3099
3221
|
/**
|
|
3100
|
-
* List sent email messages, newest first, as a cursor page ({data, next_cursor, …}). Pass next_cursor back as starting_after to fetch the next page. Filter by creation time with the half-open range created_after (inclusive) / created_before (exclusive)
|
|
3222
|
+
* List sent email messages, newest first, as a cursor page ({data, next_cursor, …}). Pass next_cursor back as starting_after to fetch the next page. Filter by creation time with the half-open range created_after (inclusive) / created_before (exclusive). For a single UTC day, created_after is that day at 00:00:00Z and created_before is the next day at 00:00:00Z.
|
|
3101
3223
|
*
|
|
3102
3224
|
* @example
|
|
3103
3225
|
* for await (const message of bird.email.list({ status: "bounced" })) {
|
|
@@ -3116,7 +3238,7 @@ var EmailResourceBase = class extends Resource {
|
|
|
3116
3238
|
}));
|
|
3117
3239
|
}
|
|
3118
3240
|
/**
|
|
3119
|
-
* Cancel a scheduled email before it sends. Only works while the message is still scheduled (status `scheduled`); once it starts sending
|
|
3241
|
+
* Cancel a scheduled email before it sends. Only works while the message is still scheduled (status `scheduled`); once it starts sending, or was already canceled, the call returns a conflict error. Canceling does not return consumed scheduled-send quota.
|
|
3120
3242
|
*
|
|
3121
3243
|
* @example
|
|
3122
3244
|
* await bird.email.cancel("em_abc123");
|
|
@@ -3312,7 +3434,7 @@ var EmailStatsResource = class extends Resource {
|
|
|
3312
3434
|
}));
|
|
3313
3435
|
}
|
|
3314
3436
|
/**
|
|
3315
|
-
* Email delivery and engagement stats grouped by the template used at send time, keyed by template id (`emt_…`); only templated sends appear.
|
|
3437
|
+
* Email delivery and engagement stats grouped by the template used at send time, keyed by template id (`emt_…`); only templated sends appear. A single template's trend over time comes from email_stats_daily with its `template` filter.
|
|
3316
3438
|
*
|
|
3317
3439
|
* @example
|
|
3318
3440
|
* const { data } = await bird.email.stats.byTemplate({
|
|
@@ -3370,7 +3492,7 @@ var EmailStatsResource = class extends Resource {
|
|
|
3370
3492
|
}));
|
|
3371
3493
|
}
|
|
3372
3494
|
/**
|
|
3373
|
-
* Bounce counts grouped by the SMTP error code the receiving server returned, with the hard/soft/admin/block/undetermined split; failure side only.
|
|
3495
|
+
* Bounce counts grouped by the SMTP error code the receiving server returned, with the hard/soft/admin/block/undetermined split; failure side only. It shows what is driving bounces, while bounces by destination come from email_stats_by_recipient_domain or email_stats_by_mailbox_provider.
|
|
3374
3496
|
*
|
|
3375
3497
|
* @example
|
|
3376
3498
|
* const { data } = await bird.email.stats.byBounceCode({
|
|
@@ -3405,7 +3527,7 @@ var EmailStatsResource = class extends Resource {
|
|
|
3405
3527
|
}));
|
|
3406
3528
|
}
|
|
3407
3529
|
/**
|
|
3408
|
-
* Email delivery and engagement stats grouped by broadcast; only broadcast sends appear. Reflects roughly the last 30 days of activity
|
|
3530
|
+
* Email delivery and engagement stats grouped by broadcast; only broadcast sends appear. Reflects roughly the last 30 days of activity.
|
|
3409
3531
|
*
|
|
3410
3532
|
* @example
|
|
3411
3533
|
* const { data } = await bird.email.stats.byBroadcast({
|
|
@@ -3427,7 +3549,7 @@ var EmailStatsResource = class extends Resource {
|
|
|
3427
3549
|
};
|
|
3428
3550
|
//#endregion
|
|
3429
3551
|
//#region src/resources/emailMailboxes.gen.ts
|
|
3430
|
-
var
|
|
3552
|
+
var EmailMailboxesResourceBase = class extends Resource {
|
|
3431
3553
|
/**
|
|
3432
3554
|
* List the workspace's mailboxes as a cursor page, newest first. Search addresses and display names with q, or filter by exact address, state, or domain.
|
|
3433
3555
|
*
|
|
@@ -3448,7 +3570,7 @@ var EmailMailboxesResource$1 = class extends Resource {
|
|
|
3448
3570
|
}));
|
|
3449
3571
|
}
|
|
3450
3572
|
/**
|
|
3451
|
-
* Create a mailbox
|
|
3573
|
+
* Create a mailbox: a durable agent identity that owns an email address, groups mail into threads, and remembers conversations for its retention tier.
|
|
3452
3574
|
*
|
|
3453
3575
|
* @example Create a mailbox
|
|
3454
3576
|
* const mailbox = await bird.email.mailboxes.create({ display_name: "Support" });
|
|
@@ -3463,6 +3585,8 @@ var EmailMailboxesResource$1 = class extends Resource {
|
|
|
3463
3585
|
}));
|
|
3464
3586
|
}
|
|
3465
3587
|
/**
|
|
3588
|
+
* Read one mailbox by id. A mailbox deleted within its 30-day restore window is still returned, carrying a non-null `deleted_at`; once that window closes it is gone and this returns 404.
|
|
3589
|
+
*
|
|
3466
3590
|
* @example Get a mailbox
|
|
3467
3591
|
* const mailbox = await bird.email.mailboxes.get("mbx_01abc");
|
|
3468
3592
|
* console.log(mailbox.state); // "active"
|
|
@@ -3476,7 +3600,7 @@ var EmailMailboxesResource$1 = class extends Resource {
|
|
|
3476
3600
|
}));
|
|
3477
3601
|
}
|
|
3478
3602
|
/**
|
|
3479
|
-
* Update a mailbox's display name, reply-to, receive policy, retention tier,
|
|
3603
|
+
* Update a mailbox's display name, reply-to, receive policy, retention tier, IP pool, or metadata. Lowering the retention tier onto remembered messages older than the new horizon requires confirm=true.
|
|
3480
3604
|
*
|
|
3481
3605
|
* @example Change a mailbox's receive policy
|
|
3482
3606
|
* const mailbox = await bird.email.mailboxes.update("mbx_01abc", {
|
|
@@ -3539,6 +3663,8 @@ var EmailMailboxesResource$1 = class extends Resource {
|
|
|
3539
3663
|
}));
|
|
3540
3664
|
}
|
|
3541
3665
|
/**
|
|
3666
|
+
* Read a mailbox's sent and received email statistics over a window: a period summary plus a bucketed series. Rows are bucketed by event time rather than send time, so engagement that arrived during the period for messages sent earlier is counted here. Both window bounds must use the same form, calendar days or RFC 3339 instants, matching the granularity.
|
|
3667
|
+
*
|
|
3542
3668
|
* @example Get mailbox stats
|
|
3543
3669
|
* const stats = await bird.email.mailboxes.stats("mbx_01abc");
|
|
3544
3670
|
* console.log(stats.summary?.sends_accepted);
|
|
@@ -3634,7 +3760,7 @@ var EmailMailboxesReceiveRulesResource = class extends Resource {
|
|
|
3634
3760
|
}));
|
|
3635
3761
|
}
|
|
3636
3762
|
/**
|
|
3637
|
-
* Remove a receive rule from a mailbox.
|
|
3763
|
+
* Remove a receive rule from a mailbox. Rules have no update operation, so a rule's allow or block action cannot be changed after it is created.
|
|
3638
3764
|
*
|
|
3639
3765
|
* @example Delete a rule
|
|
3640
3766
|
* await bird.email.mailboxes.receiveRules.delete("mbx_01abc", "erl_01xyz");
|
|
@@ -3653,7 +3779,7 @@ var EmailMailboxesReceiveRulesResource = class extends Resource {
|
|
|
3653
3779
|
};
|
|
3654
3780
|
//#endregion
|
|
3655
3781
|
//#region src/resources/emailMailboxes.ts
|
|
3656
|
-
var EmailMailboxesResource = class extends
|
|
3782
|
+
var EmailMailboxesResource = class extends EmailMailboxesResourceBase {
|
|
3657
3783
|
/** Messages sent from the mailbox's own address — `bird.email.mailboxes.messages.create(...)`. */
|
|
3658
3784
|
messages;
|
|
3659
3785
|
/** Per-sender allow/block rules — `bird.email.mailboxes.receiveRules.create(...)`, `.list(...)`, `.delete(...)`. */
|
|
@@ -3666,9 +3792,9 @@ var EmailMailboxesResource = class extends EmailMailboxesResource$1 {
|
|
|
3666
3792
|
};
|
|
3667
3793
|
//#endregion
|
|
3668
3794
|
//#region src/resources/emailThreads.gen.ts
|
|
3669
|
-
var
|
|
3795
|
+
var EmailThreadsResourceBase = class extends Resource {
|
|
3670
3796
|
/**
|
|
3671
|
-
* List mailbox conversations as a cursor page, most recently active first. `label` selects the view
|
|
3797
|
+
* List mailbox conversations as a cursor page, most recently active first. `label` selects the view: inbox (default), archive, spam, blocked, or a custom label. Filter by mailbox, contact, participant address, or subject substring.
|
|
3672
3798
|
*
|
|
3673
3799
|
* @example List conversation threads
|
|
3674
3800
|
* for await (const thread of bird.email.threads.list({ mailbox_id: "mbx_01abc" })) {
|
|
@@ -3702,7 +3828,7 @@ var EmailThreadsResource$1 = class extends Resource {
|
|
|
3702
3828
|
}));
|
|
3703
3829
|
}
|
|
3704
3830
|
/**
|
|
3705
|
-
* Add or remove labels on a conversation
|
|
3831
|
+
* Add or remove labels on a conversation, or link and unlink a contact. Adding `spam` files it as spam, `archive` clears it out of the inbox, and `inbox` brings it back.
|
|
3706
3832
|
*
|
|
3707
3833
|
* @example Apply label changes to a thread
|
|
3708
3834
|
* const thread = await bird.email.threads.update("thr_01abc", {
|
|
@@ -3759,7 +3885,7 @@ var EmailThreadsMessagesResource = class extends Resource {
|
|
|
3759
3885
|
}));
|
|
3760
3886
|
}
|
|
3761
3887
|
/**
|
|
3762
|
-
* Get one conversation message with its extracted plain text
|
|
3888
|
+
* Get one conversation message with its extracted plain text, readable for the mailbox's full retention period without MIME parsing.
|
|
3763
3889
|
*
|
|
3764
3890
|
* @example Get a message
|
|
3765
3891
|
* const msg = await bird.email.threads.messages.get("thr_01abc", "rem_01xyz");
|
|
@@ -3836,7 +3962,7 @@ var EmailThreadsMessagesResource = class extends Resource {
|
|
|
3836
3962
|
};
|
|
3837
3963
|
//#endregion
|
|
3838
3964
|
//#region src/resources/emailThreads.ts
|
|
3839
|
-
var EmailThreadsResource = class extends
|
|
3965
|
+
var EmailThreadsResource = class extends EmailThreadsResourceBase {
|
|
3840
3966
|
/** Messages in a conversation — `bird.email.threads.messages.list(...)`, `.reply(...)`, … */
|
|
3841
3967
|
messages;
|
|
3842
3968
|
constructor(...args) {
|
|
@@ -4165,7 +4291,7 @@ var DomainsResource = class extends Resource {
|
|
|
4165
4291
|
}));
|
|
4166
4292
|
}
|
|
4167
4293
|
/**
|
|
4168
|
-
* Register a new sending domain and get the DNS records to publish.
|
|
4294
|
+
* Register a new sending domain and get the DNS records to publish. Verification is a second step: the records go live at the DNS provider, then email_domains_verify confirms them. Propagation takes minutes to hours, so the first verify often still reports unverified and a later one succeeds.
|
|
4169
4295
|
*
|
|
4170
4296
|
* @example Register a sending domain
|
|
4171
4297
|
* const domain = await bird.domains.create({ domain: "mail.acme.com" });
|
|
@@ -4195,7 +4321,7 @@ var DomainsResource = class extends Resource {
|
|
|
4195
4321
|
}));
|
|
4196
4322
|
}
|
|
4197
4323
|
/**
|
|
4198
|
-
* Update a sending domain's tracking and inbound configuration. Tracking:
|
|
4324
|
+
* Update a sending domain's tracking and inbound configuration. Tracking: click_tracking and open_tracking apply immediately to new sends, and the tracking domain can be set, changed, or removed (the name part only; Bird appends the sending domain). Enabling either toggle with no tracking domain configured returns 409, and removing the tracking domain while either toggle is still on also returns 409. Tracking-domain changes on a verified domain are staged behind DNS verification, so the current config keeps serving until the new records verify. Inbound receiving: inbound.enabled starts or stops receiving mail for the domain. Enabling requires the domain's DKIM to be verified first (a fresh enable on an unverified domain returns 422), and a domain already receiving inbound for another organization returns 422. The MX records to publish are always listed in dns_records regardless, so receiving starts only once inbound.enabled is set, even when those records are already published.
|
|
4199
4325
|
*
|
|
4200
4326
|
* @example Enable tracking on a domain
|
|
4201
4327
|
* await bird.domains.update("dom_01krdgeqcxet5s7t44vh8rt9mg", {
|
|
@@ -4281,7 +4407,7 @@ var ContactPropertiesResource = class extends Resource {
|
|
|
4281
4407
|
}));
|
|
4282
4408
|
}
|
|
4283
4409
|
/**
|
|
4284
|
-
* Update a contact property's fallback value.
|
|
4410
|
+
* Update a contact property's fallback value. Only the fallback value can change; the key and type are fixed at creation, so a different key or type needs a new property.
|
|
4285
4411
|
*
|
|
4286
4412
|
* @example Change a property's fallback value
|
|
4287
4413
|
* await bird.contactProperties.update("cp_01krdgeqcxet5s7t44vh8rt9mg", { fallback_value: "free" });
|
|
@@ -4329,7 +4455,7 @@ var ContactPropertiesResource = class extends Resource {
|
|
|
4329
4455
|
//#region src/resources/contacts.gen.ts
|
|
4330
4456
|
var ContactsResource = class extends Resource {
|
|
4331
4457
|
/**
|
|
4332
|
-
* List the workspace's contacts as a cursor page, newest first. Look one up by exact email or external_id, or search by email substring.
|
|
4458
|
+
* List the workspace's contacts as a cursor page, newest first. Look one up by exact email, phone, or external_id, or search by email, name, or phone substring. Pass include_total for a total count.
|
|
4333
4459
|
*
|
|
4334
4460
|
* @example Iterate every contact, or take one page
|
|
4335
4461
|
* for await (const contact of bird.contacts.list({ q: "acme.com" })) {
|
|
@@ -4349,7 +4475,7 @@ var ContactsResource = class extends Resource {
|
|
|
4349
4475
|
}));
|
|
4350
4476
|
}
|
|
4351
4477
|
/**
|
|
4352
|
-
* Get a single contact by ID (`con_`-prefixed). Look up an ID by exact email or external_id with `contacts.list`.
|
|
4478
|
+
* Get a single contact by ID (`con_`-prefixed). Look up an ID by exact email, phone, or external_id with `contacts.list`.
|
|
4353
4479
|
*
|
|
4354
4480
|
* @example Fetch a contact by id
|
|
4355
4481
|
* const contact = await bird.contacts.get("con_01krdgeqcxet5s7t44vh8rt9mg");
|
|
@@ -4364,7 +4490,7 @@ var ContactsResource = class extends Resource {
|
|
|
4364
4490
|
}));
|
|
4365
4491
|
}
|
|
4366
4492
|
/**
|
|
4367
|
-
* Create a contact by email address
|
|
4493
|
+
* Create a contact identified by an email address, an E.164 phone number, or both. Fails with a conflict if the email, phone, or external_id is already used by another contact. For bulk import or create-or-update semantics use `contacts.batch`.
|
|
4368
4494
|
*
|
|
4369
4495
|
* @example Create a contact
|
|
4370
4496
|
* const contact = await bird.contacts.create({
|
|
@@ -4373,7 +4499,7 @@ var ContactsResource = class extends Resource {
|
|
|
4373
4499
|
* });
|
|
4374
4500
|
* console.log(contact.id); // "con_…"
|
|
4375
4501
|
*/
|
|
4376
|
-
create(params, options) {
|
|
4502
|
+
create(params = {}, options) {
|
|
4377
4503
|
return this.call("POST", options, ({ signal, headers }) => createContact({
|
|
4378
4504
|
client: this.client,
|
|
4379
4505
|
body: params,
|
|
@@ -4382,7 +4508,7 @@ var ContactsResource = class extends Resource {
|
|
|
4382
4508
|
}));
|
|
4383
4509
|
}
|
|
4384
4510
|
/**
|
|
4385
|
-
* Update a contact's name, external_id, email, or custom data. Only supplied fields change; custom data keys are merged, with null removing a key.
|
|
4511
|
+
* Update a contact's name, external_id, email, phone, or custom data. Only supplied fields change; custom data keys are merged, with null removing a key. A contact keeps at least one identifier: clearing both email and phone is rejected.
|
|
4386
4512
|
*
|
|
4387
4513
|
* @example Change a contact's fields
|
|
4388
4514
|
* const contact = await bird.contacts.update("con_01krdgeqcxet5s7t44vh8rt9mg", {
|
|
@@ -4414,14 +4540,14 @@ var ContactsResource = class extends Resource {
|
|
|
4414
4540
|
}));
|
|
4415
4541
|
}
|
|
4416
4542
|
/**
|
|
4417
|
-
* Create or update up to 1,000 contacts in one request, matched
|
|
4543
|
+
* Create or update up to 1,000 contacts in one request, each entry matched automatically against every identifier it supplies (email, phone, external_id) or, with match_on, by that one field only, and optionally add them all to one or more audiences. Per-contact results are returned in submission order.
|
|
4418
4544
|
*
|
|
4419
|
-
* @example Create or update many contacts at once, matched by
|
|
4545
|
+
* @example Create or update many contacts at once, matched by the identifiers each entry carries
|
|
4420
4546
|
* const result = await bird.contacts.batch({
|
|
4421
4547
|
* contacts: [{ email: "jane@acme.com", first_name: "Jane" }],
|
|
4422
4548
|
* });
|
|
4423
4549
|
* for (const item of result.data) {
|
|
4424
|
-
* console.log(item.email, item.status);
|
|
4550
|
+
* console.log(item.entry.email, item.status);
|
|
4425
4551
|
* }
|
|
4426
4552
|
*/
|
|
4427
4553
|
batch(params, options) {
|
|
@@ -4575,7 +4701,7 @@ var WhatsappResourceBase = class extends Resource {
|
|
|
4575
4701
|
}));
|
|
4576
4702
|
}
|
|
4577
4703
|
/**
|
|
4578
|
-
* List WhatsApp messages, newest first, as a cursor page ({data, next_cursor, …}). Pass next_cursor back as starting_after to fetch the next page. Filter by status, contact phone number, bsuid, or tag. Use whatsapp_get for one message's current state.
|
|
4704
|
+
* List WhatsApp messages, newest first, as a cursor page ({data, next_cursor, …}). Pass next_cursor back as starting_after to fetch the next page. Filter by direction, status, contact phone number, bsuid, or tag. Use whatsapp_get for one message's current state.
|
|
4579
4705
|
*
|
|
4580
4706
|
* @example Iterate delivered messages
|
|
4581
4707
|
* for await (const msg of bird.whatsapp.list({ status: ["delivered"] })) {
|
|
@@ -4632,7 +4758,7 @@ var WhatsappResource = class extends WhatsappResourceBase {
|
|
|
4632
4758
|
* console.log(msg.id, msg.status);
|
|
4633
4759
|
*/
|
|
4634
4760
|
send(params, options) {
|
|
4635
|
-
return this.call("POST", options, ({ signal, headers }) =>
|
|
4761
|
+
return this.call("POST", options, ({ signal, headers }) => createWhatsAppMessage({
|
|
4636
4762
|
client: this.client,
|
|
4637
4763
|
body: params,
|
|
4638
4764
|
headers,
|
|
@@ -4750,39 +4876,49 @@ function toHeaderRecord(headers) {
|
|
|
4750
4876
|
return headers instanceof Headers ? Object.fromEntries(headers) : headers;
|
|
4751
4877
|
}
|
|
4752
4878
|
//#endregion
|
|
4753
|
-
//#region src/resources/realtime.ts
|
|
4754
|
-
var
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
4879
|
+
//#region src/resources/realtime.gen.ts
|
|
4880
|
+
var RealtimeResourceBase = class extends Resource {
|
|
4881
|
+
/**
|
|
4882
|
+
* @example Broadcast an event to a channel
|
|
4883
|
+
* const result = await bird.realtime.publish("rap_01krdgeqcxet5s7t44vh8rt9mg", {
|
|
4884
|
+
* event: "order.updated",
|
|
4885
|
+
* channels: ["orders", "presence-lobby"],
|
|
4886
|
+
* data: { order_id: "ord_123", status: "shipped" },
|
|
4887
|
+
* });
|
|
4888
|
+
* console.log(result.data?.length); // one entry per channel
|
|
4889
|
+
*/
|
|
4890
|
+
publish(realtimeAppId, params, options) {
|
|
4891
|
+
return this.call("POST", options, ({ signal, headers }) => publishRealtimeAppEvent({
|
|
4892
|
+
client: this.client,
|
|
4893
|
+
path: { realtime_app_id: realtimeAppId },
|
|
4894
|
+
body: params,
|
|
4895
|
+
headers,
|
|
4896
|
+
signal
|
|
4897
|
+
}), ["RealtimeKey", "RealtimeSecret"]);
|
|
4759
4898
|
}
|
|
4760
4899
|
/**
|
|
4761
|
-
*
|
|
4762
|
-
*
|
|
4763
|
-
*
|
|
4900
|
+
* @example Publish two events in one call
|
|
4901
|
+
* await bird.realtime.publishBatch("rap_01krdgeqcxet5s7t44vh8rt9mg", {
|
|
4902
|
+
* events: [
|
|
4903
|
+
* { event: "order.created", channel: "orders", data: { id: 1 } },
|
|
4904
|
+
* { event: "order.updated", channel: "orders", data: { id: 2 } },
|
|
4905
|
+
* ],
|
|
4906
|
+
* });
|
|
4764
4907
|
*/
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
};
|
|
4908
|
+
publishBatch(realtimeAppId, params, options) {
|
|
4909
|
+
return this.call("POST", options, ({ signal, headers }) => publishRealtimeAppBatch({
|
|
4910
|
+
client: this.client,
|
|
4911
|
+
path: { realtime_app_id: realtimeAppId },
|
|
4912
|
+
body: params,
|
|
4913
|
+
headers,
|
|
4914
|
+
signal
|
|
4915
|
+
}), ["RealtimeKey", "RealtimeSecret"]);
|
|
4773
4916
|
}
|
|
4774
4917
|
};
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
* the last one leaves, so these report occupancy, never existence.
|
|
4779
|
-
*/
|
|
4780
|
-
var RealtimeChannelsResource = class extends RealtimeBase {
|
|
4918
|
+
//#endregion
|
|
4919
|
+
//#region src/resources/realtimeChannels.gen.ts
|
|
4920
|
+
var RealtimeChannelsResource = class extends Resource {
|
|
4781
4921
|
/**
|
|
4782
|
-
* List the app's currently occupied channels, optionally filtered by name
|
|
4783
|
-
* prefix. The Realtime service returns them all in one response — this is a
|
|
4784
|
-
* point read, not a cursor list, so there is nothing to iterate.
|
|
4785
|
-
*
|
|
4786
4922
|
* @example List the occupied presence channels with their member counts
|
|
4787
4923
|
* const { data } = await bird.realtime.channels.list("rap_01krdgeqcxet5s7t44vh8rt9mg", {
|
|
4788
4924
|
* prefix: "presence-",
|
|
@@ -4790,171 +4926,104 @@ var RealtimeChannelsResource = class extends RealtimeBase {
|
|
|
4790
4926
|
* });
|
|
4791
4927
|
* for (const channel of data) console.log(channel.name, channel.member_count);
|
|
4792
4928
|
*/
|
|
4793
|
-
list(
|
|
4794
|
-
const auth = this.auth(options);
|
|
4929
|
+
list(realtimeAppId, query, options) {
|
|
4795
4930
|
return this.call("GET", options, ({ signal, headers }) => listRealtimeAppChannels({
|
|
4796
4931
|
client: this.client,
|
|
4797
|
-
path: { realtime_app_id:
|
|
4932
|
+
path: { realtime_app_id: realtimeAppId },
|
|
4798
4933
|
query,
|
|
4799
|
-
headers
|
|
4800
|
-
...headers,
|
|
4801
|
-
...auth
|
|
4802
|
-
},
|
|
4934
|
+
headers,
|
|
4803
4935
|
signal
|
|
4804
|
-
}));
|
|
4936
|
+
}), ["RealtimeKey", "RealtimeSecret"]);
|
|
4805
4937
|
}
|
|
4806
4938
|
/**
|
|
4807
|
-
* Read one channel's state. An unknown or never-used name is not an error —
|
|
4808
|
-
* it resolves with `occupied: false`.
|
|
4809
|
-
*
|
|
4810
4939
|
* @example Check whether anyone is in a channel
|
|
4811
|
-
* const channel = await bird.realtime.channels.get(
|
|
4812
|
-
* "
|
|
4813
|
-
*
|
|
4814
|
-
* { include: ["member_count"] },
|
|
4815
|
-
* );
|
|
4940
|
+
* const channel = await bird.realtime.channels.get("rap_01krdgeqcxet5s7t44vh8rt9mg", "presence-lobby", {
|
|
4941
|
+
* include: ["member_count"],
|
|
4942
|
+
* });
|
|
4816
4943
|
* console.log(channel.occupied, channel.member_count);
|
|
4817
4944
|
*/
|
|
4818
|
-
get(
|
|
4819
|
-
const auth = this.auth(options);
|
|
4945
|
+
get(realtimeAppId, channelName, query, options) {
|
|
4820
4946
|
return this.call("GET", options, ({ signal, headers }) => getRealtimeAppChannel({
|
|
4821
4947
|
client: this.client,
|
|
4822
4948
|
path: {
|
|
4823
|
-
realtime_app_id:
|
|
4949
|
+
realtime_app_id: realtimeAppId,
|
|
4824
4950
|
channel_name: channelName
|
|
4825
4951
|
},
|
|
4826
4952
|
query,
|
|
4827
|
-
headers
|
|
4828
|
-
...headers,
|
|
4829
|
-
...auth
|
|
4830
|
-
},
|
|
4953
|
+
headers,
|
|
4831
4954
|
signal
|
|
4832
|
-
}));
|
|
4955
|
+
}), ["RealtimeKey", "RealtimeSecret"]);
|
|
4833
4956
|
}
|
|
4834
4957
|
/**
|
|
4835
|
-
* List the member ids subscribed to a presence channel. Ids only — the
|
|
4836
|
-
* `member_info` your authorization endpoint attaches is delivered to subscribed
|
|
4837
|
-
* clients over the realtime connection and is not available over REST.
|
|
4838
|
-
*
|
|
4839
4958
|
* @example Who is in the lobby
|
|
4840
|
-
* const { members } = await bird.realtime.channels.members(
|
|
4841
|
-
* "rap_01krdgeqcxet5s7t44vh8rt9mg",
|
|
4842
|
-
* "presence-lobby",
|
|
4843
|
-
* );
|
|
4959
|
+
* const { members } = await bird.realtime.channels.members("rap_01krdgeqcxet5s7t44vh8rt9mg", "presence-lobby");
|
|
4844
4960
|
* for (const member of members) console.log(member.member_id);
|
|
4845
4961
|
*/
|
|
4846
|
-
members(
|
|
4847
|
-
const auth = this.auth(options);
|
|
4962
|
+
members(realtimeAppId, channelName, options) {
|
|
4848
4963
|
return this.call("GET", options, ({ signal, headers }) => listRealtimeAppChannelMembers({
|
|
4849
4964
|
client: this.client,
|
|
4850
4965
|
path: {
|
|
4851
|
-
realtime_app_id:
|
|
4966
|
+
realtime_app_id: realtimeAppId,
|
|
4852
4967
|
channel_name: channelName
|
|
4853
4968
|
},
|
|
4854
|
-
headers
|
|
4855
|
-
...headers,
|
|
4856
|
-
...auth
|
|
4857
|
-
},
|
|
4969
|
+
headers,
|
|
4858
4970
|
signal
|
|
4859
|
-
}));
|
|
4971
|
+
}), ["RealtimeKey", "RealtimeSecret"]);
|
|
4860
4972
|
}
|
|
4861
4973
|
};
|
|
4862
|
-
|
|
4863
|
-
|
|
4974
|
+
//#endregion
|
|
4975
|
+
//#region src/resources/realtimeMembers.gen.ts
|
|
4976
|
+
var RealtimeMembersResource = class extends Resource {
|
|
4977
|
+
/**
|
|
4978
|
+
* @example Notify one person wherever they are signed in
|
|
4979
|
+
* await bird.realtime.members.send("rap_01krdgeqcxet5s7t44vh8rt9mg", "user_42", {
|
|
4980
|
+
* event: "order-shipped",
|
|
4981
|
+
* data: { order_id: "ord_123" },
|
|
4982
|
+
* });
|
|
4983
|
+
*/
|
|
4984
|
+
send(realtimeAppId, memberId, params, options) {
|
|
4985
|
+
return this.call("POST", options, ({ signal, headers }) => sendRealtimeAppMemberEvent({
|
|
4986
|
+
client: this.client,
|
|
4987
|
+
path: {
|
|
4988
|
+
realtime_app_id: realtimeAppId,
|
|
4989
|
+
member_id: memberId
|
|
4990
|
+
},
|
|
4991
|
+
body: params,
|
|
4992
|
+
headers,
|
|
4993
|
+
signal
|
|
4994
|
+
}), ["RealtimeKey", "RealtimeSecret"]);
|
|
4995
|
+
}
|
|
4864
4996
|
/**
|
|
4865
|
-
* Disconnect every active connection a member holds — sign-out, ban, or a
|
|
4866
|
-
* revoked session. Resolves once the disconnect is applied; the member may
|
|
4867
|
-
* reconnect immediately unless your authorization endpoint refuses them.
|
|
4868
|
-
*
|
|
4869
4997
|
* @example Kick a member off every connection
|
|
4870
4998
|
* await bird.realtime.members.disconnect("rap_01krdgeqcxet5s7t44vh8rt9mg", "user_42");
|
|
4871
4999
|
*/
|
|
4872
|
-
disconnect(
|
|
4873
|
-
const auth = this.auth(options);
|
|
5000
|
+
disconnect(realtimeAppId, memberId, options) {
|
|
4874
5001
|
return this.call("POST", options, ({ signal, headers }) => disconnectRealtimeAppMember({
|
|
4875
5002
|
client: this.client,
|
|
4876
5003
|
path: {
|
|
4877
|
-
realtime_app_id:
|
|
5004
|
+
realtime_app_id: realtimeAppId,
|
|
4878
5005
|
member_id: memberId
|
|
4879
5006
|
},
|
|
4880
|
-
headers
|
|
4881
|
-
...headers,
|
|
4882
|
-
...auth
|
|
4883
|
-
},
|
|
5007
|
+
headers,
|
|
4884
5008
|
signal
|
|
4885
|
-
}));
|
|
5009
|
+
}), ["RealtimeKey", "RealtimeSecret"]);
|
|
4886
5010
|
}
|
|
4887
5011
|
};
|
|
5012
|
+
//#endregion
|
|
5013
|
+
//#region src/resources/realtime.ts
|
|
4888
5014
|
/**
|
|
4889
5015
|
* `bird.realtime` — publish events to a Realtime app's channels and inspect its
|
|
4890
|
-
* live state.
|
|
4891
|
-
* `realtime: { key, secret }` on the client, or pass `{ key, secret }` in a
|
|
4892
|
-
* call's options to reach a different app. Reached as `bird.realtime.*`.
|
|
5016
|
+
* live state. Reached as `bird.realtime.*`.
|
|
4893
5017
|
*/
|
|
4894
|
-
var RealtimeResource = class extends
|
|
5018
|
+
var RealtimeResource = class extends RealtimeResourceBase {
|
|
4895
5019
|
/** Channel state — `bird.realtime.channels.list(...)`, `.get(...)`, `.members(...)`. */
|
|
4896
5020
|
channels;
|
|
4897
|
-
/** Members — `bird.realtime.members.disconnect(...)`. */
|
|
5021
|
+
/** Members — `bird.realtime.members.send(...)`, `.disconnect(...)`. */
|
|
4898
5022
|
members;
|
|
4899
|
-
constructor(core, client
|
|
4900
|
-
super(core, client
|
|
4901
|
-
this.channels = new RealtimeChannelsResource(core, client
|
|
4902
|
-
this.members = new RealtimeMembersResource(core, client
|
|
4903
|
-
}
|
|
4904
|
-
/**
|
|
4905
|
-
* Publish one event to one or more of the app's channels. Listing several
|
|
4906
|
-
* channels broadcasts the same event to all of them in a single call. Resolves
|
|
4907
|
-
* once the event is accepted — delivery to connected clients is asynchronous.
|
|
4908
|
-
*
|
|
4909
|
-
* Pass `exclude_connection_id` to skip the connection that triggered the
|
|
4910
|
-
* change, so the originating client doesn't echo its own update.
|
|
4911
|
-
*
|
|
4912
|
-
* @example Broadcast an event to a channel
|
|
4913
|
-
* const result = await bird.realtime.publish("rap_01krdgeqcxet5s7t44vh8rt9mg", {
|
|
4914
|
-
* event: "order.updated",
|
|
4915
|
-
* channels: ["orders", "presence-lobby"],
|
|
4916
|
-
* data: { order_id: "ord_123", status: "shipped" },
|
|
4917
|
-
* });
|
|
4918
|
-
* console.log(result.data?.length); // one entry per channel
|
|
4919
|
-
*/
|
|
4920
|
-
publish(appId, params, options) {
|
|
4921
|
-
const auth = this.auth(options);
|
|
4922
|
-
return this.call("POST", options, ({ signal, headers }) => publishRealtimeAppEvent({
|
|
4923
|
-
client: this.client,
|
|
4924
|
-
path: { realtime_app_id: appId },
|
|
4925
|
-
body: params,
|
|
4926
|
-
headers: {
|
|
4927
|
-
...headers,
|
|
4928
|
-
...auth
|
|
4929
|
-
},
|
|
4930
|
-
signal
|
|
4931
|
-
}));
|
|
4932
|
-
}
|
|
4933
|
-
/**
|
|
4934
|
-
* Publish up to 10 events in one request, each to a single channel. Use it to
|
|
4935
|
-
* fan different events out at once; to send the *same* event to many channels,
|
|
4936
|
-
* use `publish` with several `channels` instead.
|
|
4937
|
-
*
|
|
4938
|
-
* @example Publish two events in one call
|
|
4939
|
-
* await bird.realtime.publishBatch("rap_01krdgeqcxet5s7t44vh8rt9mg", {
|
|
4940
|
-
* events: [
|
|
4941
|
-
* { event: "order.created", channel: "orders", data: { id: 1 } },
|
|
4942
|
-
* { event: "order.updated", channel: "orders", data: { id: 2 } },
|
|
4943
|
-
* ],
|
|
4944
|
-
* });
|
|
4945
|
-
*/
|
|
4946
|
-
publishBatch(appId, params, options) {
|
|
4947
|
-
const auth = this.auth(options);
|
|
4948
|
-
return this.call("POST", options, ({ signal, headers }) => publishRealtimeAppBatch({
|
|
4949
|
-
client: this.client,
|
|
4950
|
-
path: { realtime_app_id: appId },
|
|
4951
|
-
body: params,
|
|
4952
|
-
headers: {
|
|
4953
|
-
...headers,
|
|
4954
|
-
...auth
|
|
4955
|
-
},
|
|
4956
|
-
signal
|
|
4957
|
-
}));
|
|
5023
|
+
constructor(core, client) {
|
|
5024
|
+
super(core, client);
|
|
5025
|
+
this.channels = new RealtimeChannelsResource(core, client);
|
|
5026
|
+
this.members = new RealtimeMembersResource(core, client);
|
|
4958
5027
|
}
|
|
4959
5028
|
};
|
|
4960
5029
|
//#endregion
|
|
@@ -5040,9 +5109,9 @@ var BirdClient = class {
|
|
|
5040
5109
|
this.#headers = {
|
|
5041
5110
|
...opts.defaultHeaders,
|
|
5042
5111
|
Authorization: `Bearer ${opts.apiKey}`,
|
|
5043
|
-
"User-Agent": `bird-sdk-js/0.
|
|
5112
|
+
"User-Agent": `bird-sdk-js/0.21.2`,
|
|
5044
5113
|
"Bird-Surface": "sdk-js",
|
|
5045
|
-
"Bird-Version": "0.
|
|
5114
|
+
"Bird-Version": "0.21.2"
|
|
5046
5115
|
};
|
|
5047
5116
|
const caller = detectCaller();
|
|
5048
5117
|
if (caller) this.#headers["Bird-Caller"] = caller;
|
|
@@ -5053,7 +5122,19 @@ var BirdClient = class {
|
|
|
5053
5122
|
}));
|
|
5054
5123
|
this.core = new BirdHTTPClient({
|
|
5055
5124
|
timeout: opts.timeout ?? DEFAULT_TIMEOUT_MS,
|
|
5056
|
-
maxRetries: opts.maxRetries ?? DEFAULT_MAX_RETRIES
|
|
5125
|
+
maxRetries: opts.maxRetries ?? DEFAULT_MAX_RETRIES,
|
|
5126
|
+
credentials: {
|
|
5127
|
+
RealtimeKey: {
|
|
5128
|
+
header: "X-Realtime-Key",
|
|
5129
|
+
value: opts.realtime?.key,
|
|
5130
|
+
how: "Set `realtime: { key, secret }` on the client."
|
|
5131
|
+
},
|
|
5132
|
+
RealtimeSecret: {
|
|
5133
|
+
header: "X-Realtime-Secret",
|
|
5134
|
+
value: opts.realtime?.secret,
|
|
5135
|
+
how: "Set `realtime: { key, secret }` on the client."
|
|
5136
|
+
}
|
|
5137
|
+
}
|
|
5057
5138
|
});
|
|
5058
5139
|
this.email = new EmailResource(this.core, this.#client, opts.email);
|
|
5059
5140
|
this.sms = new SmsResource(this.core, this.#client);
|
|
@@ -5065,7 +5146,7 @@ var BirdClient = class {
|
|
|
5065
5146
|
this.contactProperties = new ContactPropertiesResource(this.core, this.#client);
|
|
5066
5147
|
this.domains = new DomainsResource(this.core, this.#client);
|
|
5067
5148
|
this.webhooks = new WebhooksResource(opts.webhooks);
|
|
5068
|
-
this.realtime = new RealtimeResource(this.core, this.#client
|
|
5149
|
+
this.realtime = new RealtimeResource(this.core, this.#client);
|
|
5069
5150
|
}
|
|
5070
5151
|
/**
|
|
5071
5152
|
* Escape hatch for endpoints the typed resources don't cover. Runs the full
|
|
@@ -5155,10 +5236,6 @@ const WebhookEventType = {
|
|
|
5155
5236
|
SmsFailed: "sms.failed",
|
|
5156
5237
|
SmsRejected: "sms.rejected",
|
|
5157
5238
|
SmsSent: "sms.sent",
|
|
5158
|
-
SmsTfnVerificationApproved: "sms.tfn_verification.approved",
|
|
5159
|
-
SmsTfnVerificationInfoRequested: "sms.tfn_verification.info_requested",
|
|
5160
|
-
SmsTfnVerificationRejected: "sms.tfn_verification.rejected",
|
|
5161
|
-
SmsTfnVerificationSubmitted: "sms.tfn_verification.submitted",
|
|
5162
5239
|
SmsUndelivered: "sms.undelivered",
|
|
5163
5240
|
VerifyAttemptDelivered: "verify.attempt.delivered",
|
|
5164
5241
|
VerifyAttemptSent: "verify.attempt.sent",
|
|
@@ -5176,6 +5253,91 @@ const WebhookEventType = {
|
|
|
5176
5253
|
WhatsappSent: "whatsapp.sent"
|
|
5177
5254
|
};
|
|
5178
5255
|
//#endregion
|
|
5179
|
-
|
|
5256
|
+
//#region src/open-enums.gen.ts
|
|
5257
|
+
/**
|
|
5258
|
+
* Values of EmailEventType known at this SDK version. The wire value is an open
|
|
5259
|
+
* string: a value added by a newer server deserializes unchanged, so switch on
|
|
5260
|
+
* these with a `default` branch rather than treating the set as closed.
|
|
5261
|
+
*/
|
|
5262
|
+
const EmailEventType = {
|
|
5263
|
+
EmailAccepted: "email.accepted",
|
|
5264
|
+
EmailBounced: "email.bounced",
|
|
5265
|
+
EmailCanceled: "email.canceled",
|
|
5266
|
+
EmailClicked: "email.clicked",
|
|
5267
|
+
EmailComplained: "email.complained",
|
|
5268
|
+
EmailDeferred: "email.deferred",
|
|
5269
|
+
EmailDelivered: "email.delivered",
|
|
5270
|
+
EmailListUnsubscribed: "email.list_unsubscribed",
|
|
5271
|
+
EmailOpened: "email.opened",
|
|
5272
|
+
EmailOutOfBandBounce: "email.out_of_band_bounce",
|
|
5273
|
+
EmailProcessed: "email.processed",
|
|
5274
|
+
EmailRejected: "email.rejected",
|
|
5275
|
+
EmailScheduled: "email.scheduled",
|
|
5276
|
+
EmailUnsubscribed: "email.unsubscribed"
|
|
5277
|
+
};
|
|
5278
|
+
/**
|
|
5279
|
+
* Values of VerificationAttemptFailureReason known at this SDK version. The wire value is an open
|
|
5280
|
+
* string: a value added by a newer server deserializes unchanged, so switch on
|
|
5281
|
+
* these with a `default` branch rather than treating the set as closed.
|
|
5282
|
+
*/
|
|
5283
|
+
const VerificationAttemptFailureReason = {
|
|
5284
|
+
CarrierRejected: "carrier_rejected",
|
|
5285
|
+
ChannelDisabled: "channel_disabled",
|
|
5286
|
+
ChannelUnavailable: "channel_unavailable",
|
|
5287
|
+
HardBounce: "hard_bounce",
|
|
5288
|
+
SoftBounce: "soft_bounce",
|
|
5289
|
+
Undelivered: "undelivered"
|
|
5290
|
+
};
|
|
5291
|
+
/**
|
|
5292
|
+
* Values of VerificationChannel known at this SDK version. The wire value is an open
|
|
5293
|
+
* string: a value added by a newer server deserializes unchanged, so switch on
|
|
5294
|
+
* these with a `default` branch rather than treating the set as closed.
|
|
5295
|
+
*/
|
|
5296
|
+
const VerificationChannel = {
|
|
5297
|
+
Email: "email",
|
|
5298
|
+
Sms: "sms",
|
|
5299
|
+
Whatsapp: "whatsapp"
|
|
5300
|
+
};
|
|
5301
|
+
/**
|
|
5302
|
+
* Values of VerificationTerminalReason known at this SDK version. The wire value is an open
|
|
5303
|
+
* string: a value added by a newer server deserializes unchanged, so switch on
|
|
5304
|
+
* these with a `default` branch rather than treating the set as closed.
|
|
5305
|
+
*/
|
|
5306
|
+
const VerificationTerminalReason = {
|
|
5307
|
+
AttemptsExhausted: "attempts_exhausted",
|
|
5308
|
+
TtlElapsed: "ttl_elapsed"
|
|
5309
|
+
};
|
|
5310
|
+
/**
|
|
5311
|
+
* Values of WhatsAppErrorCode known at this SDK version. The wire value is an open
|
|
5312
|
+
* string: a value added by a newer server deserializes unchanged, so switch on
|
|
5313
|
+
* these with a `default` branch rather than treating the set as closed.
|
|
5314
|
+
*/
|
|
5315
|
+
const WhatsAppErrorCode = {
|
|
5316
|
+
InsufficientBalance: "insufficient_balance",
|
|
5317
|
+
InternalError: "internal_error",
|
|
5318
|
+
PriceNotFound: "price_not_found",
|
|
5319
|
+
RateLimited: "rate_limited",
|
|
5320
|
+
RecipientSuppressed: "recipient_suppressed",
|
|
5321
|
+
ServiceWindowExpired: "service_window_expired",
|
|
5322
|
+
Undeliverable: "undeliverable"
|
|
5323
|
+
};
|
|
5324
|
+
/**
|
|
5325
|
+
* Values of WhatsAppTemplateCategory known at this SDK version. The wire value is an open
|
|
5326
|
+
* string: a value added by a newer server deserializes unchanged, so switch on
|
|
5327
|
+
* these with a `default` branch rather than treating the set as closed.
|
|
5328
|
+
*/
|
|
5329
|
+
const WhatsAppTemplateCategory = {
|
|
5330
|
+
Authentication: "authentication",
|
|
5331
|
+
Marketing: "marketing",
|
|
5332
|
+
Utility: "utility"
|
|
5333
|
+
};
|
|
5334
|
+
/**
|
|
5335
|
+
* Values of WhatsAppTemplateParameterType known at this SDK version. The wire value is an open
|
|
5336
|
+
* string: a value added by a newer server deserializes unchanged, so switch on
|
|
5337
|
+
* these with a `default` branch rather than treating the set as closed.
|
|
5338
|
+
*/
|
|
5339
|
+
const WhatsAppTemplateParameterType = { Text: "text" };
|
|
5340
|
+
//#endregion
|
|
5341
|
+
export { BirdAPIError, BirdAuthError, BirdBadRequestError, BirdBillingError, BirdClient, BirdConflictError, BirdConnectionError, BirdError, BirdInternalError, BirdMisdirectedError, BirdNotFoundError, BirdNotImplementedError, BirdPayloadTooLargeError, BirdPermissionError, BirdPreconditionError, BirdRateLimitError, BirdServiceUnavailableError, BirdTimeoutError, BirdValidationError, BirdWebhookVerificationError, EmailEventType, VerificationAttemptFailureReason, VerificationChannel, VerificationTerminalReason, WebhookEventType, WhatsAppErrorCode, WhatsAppTemplateCategory, WhatsAppTemplateParameterType, baseUrlForRegion, regionFromApiKey };
|
|
5180
5342
|
|
|
5181
5343
|
//# sourceMappingURL=index.mjs.map
|