@opens/gateways 1.16.6 → 1.16.8
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/customer-service/contracts/index.d.mts +44 -42
- package/dist/customer-service/contracts/index.d.ts +44 -42
- package/dist/index.d.mts +64 -3
- package/dist/index.d.ts +64 -3
- package/dist/index.js +94 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +94 -3
- package/dist/index.mjs.map +1 -1
- package/dist/notifications/contracts/index.d.mts +160 -0
- package/dist/notifications/contracts/index.d.ts +160 -0
- package/dist/notifications/contracts/index.js +19 -0
- package/dist/notifications/contracts/index.js.map +1 -0
- package/dist/notifications/contracts/index.mjs +1 -0
- package/dist/notifications/contracts/index.mjs.map +1 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1383,6 +1383,88 @@ var AccessHubGateway = class {
|
|
|
1383
1383
|
}
|
|
1384
1384
|
};
|
|
1385
1385
|
|
|
1386
|
+
// src/notifications/index.ts
|
|
1387
|
+
var NotificationsGateway = class {
|
|
1388
|
+
constructor(httpClient, baseUrl) {
|
|
1389
|
+
this.httpClient = httpClient;
|
|
1390
|
+
this.baseUrl = baseUrl;
|
|
1391
|
+
}
|
|
1392
|
+
httpClient;
|
|
1393
|
+
baseUrl;
|
|
1394
|
+
/**
|
|
1395
|
+
* Returns the catalog of available system notifications with their types and metadata.
|
|
1396
|
+
* @param params - Optional filters by type slug or type ID.
|
|
1397
|
+
* @returns A list of system notifications and the total count.
|
|
1398
|
+
*/
|
|
1399
|
+
async getSystemNotifications(params) {
|
|
1400
|
+
const { data } = await this.httpClient.get(
|
|
1401
|
+
`${this.baseUrl}/notification/system-notifications`,
|
|
1402
|
+
{ params }
|
|
1403
|
+
);
|
|
1404
|
+
return data;
|
|
1405
|
+
}
|
|
1406
|
+
/**
|
|
1407
|
+
* Lists push notification devices registered for the authenticated user.
|
|
1408
|
+
* @param params - Optional filters, pagination and service-token context.
|
|
1409
|
+
* @returns A list of user devices and the total count.
|
|
1410
|
+
*/
|
|
1411
|
+
async getUserDevices(params) {
|
|
1412
|
+
const { data } = await this.httpClient.get(`${this.baseUrl}/user/devices`, { params });
|
|
1413
|
+
return data;
|
|
1414
|
+
}
|
|
1415
|
+
/**
|
|
1416
|
+
* Registers or updates a push notification token for a user device.
|
|
1417
|
+
* Idempotent via findOrCreate on deviceToken.
|
|
1418
|
+
* @param payload - Device token and either deviceSlug or deviceId.
|
|
1419
|
+
* @returns The registered device summary.
|
|
1420
|
+
*/
|
|
1421
|
+
async registerUserDevice(payload) {
|
|
1422
|
+
const { data } = await this.httpClient.post(`${this.baseUrl}/user/devices`, payload);
|
|
1423
|
+
return data;
|
|
1424
|
+
}
|
|
1425
|
+
/**
|
|
1426
|
+
* Deletes a registered user device and its notification token.
|
|
1427
|
+
* @param id - UUID of the user device record.
|
|
1428
|
+
* @returns Confirmation of deletion.
|
|
1429
|
+
*/
|
|
1430
|
+
async deleteUserDevice(id) {
|
|
1431
|
+
const { data } = await this.httpClient.delete(`${this.baseUrl}/user/devices/${id}`);
|
|
1432
|
+
return data;
|
|
1433
|
+
}
|
|
1434
|
+
/**
|
|
1435
|
+
* Lists active notification preferences for the user, optionally filtered by device.
|
|
1436
|
+
* @param params - Optional filters and service-token context.
|
|
1437
|
+
* @returns A list of user preferences.
|
|
1438
|
+
*/
|
|
1439
|
+
async getUserPreferences(params) {
|
|
1440
|
+
const { data } = await this.httpClient.get(`${this.baseUrl}/user/preferences`, { params });
|
|
1441
|
+
return data;
|
|
1442
|
+
}
|
|
1443
|
+
/**
|
|
1444
|
+
* Creates or activates a notification preference for a user device.
|
|
1445
|
+
* Idempotent via findOrCreate on the user/device/notification combination.
|
|
1446
|
+
* @param payload - Device ID and either systemNotificationSlug or systemNotificationId.
|
|
1447
|
+
* @returns The created or existing preference.
|
|
1448
|
+
*/
|
|
1449
|
+
async createUserPreference(payload) {
|
|
1450
|
+
const { data } = await this.httpClient.post(`${this.baseUrl}/user/preferences`, payload);
|
|
1451
|
+
return data;
|
|
1452
|
+
}
|
|
1453
|
+
/**
|
|
1454
|
+
* Deletes a notification preference by its ID.
|
|
1455
|
+
* @param id - UUID of the preference in `user_notification_preferences`.
|
|
1456
|
+
* @param params - Optional companyId/userId for Service Token context.
|
|
1457
|
+
* @returns Confirmation of deletion.
|
|
1458
|
+
*/
|
|
1459
|
+
async deleteUserPreference(id, params) {
|
|
1460
|
+
const { data } = await this.httpClient.delete(
|
|
1461
|
+
`${this.baseUrl}/user/preferences/${id}`,
|
|
1462
|
+
{ params }
|
|
1463
|
+
);
|
|
1464
|
+
return data;
|
|
1465
|
+
}
|
|
1466
|
+
};
|
|
1467
|
+
|
|
1386
1468
|
// src/@common/client.ts
|
|
1387
1469
|
import axios from "axios";
|
|
1388
1470
|
var SDKGateways = class {
|
|
@@ -1399,7 +1481,8 @@ var SDKGateways = class {
|
|
|
1399
1481
|
cases;
|
|
1400
1482
|
rh;
|
|
1401
1483
|
accessHub;
|
|
1402
|
-
|
|
1484
|
+
notifications;
|
|
1485
|
+
constructor(customerService, chatConfig, campaigns, chatAdapter, assets, contactList, integrations, chatWebservice, callReport, calls, cases, rh, accessHub, notifications) {
|
|
1403
1486
|
this.customerService = customerService;
|
|
1404
1487
|
this.chatConfig = chatConfig;
|
|
1405
1488
|
this.campaigns = campaigns;
|
|
@@ -1413,6 +1496,7 @@ var SDKGateways = class {
|
|
|
1413
1496
|
this.cases = cases;
|
|
1414
1497
|
this.rh = rh;
|
|
1415
1498
|
this.accessHub = accessHub;
|
|
1499
|
+
this.notifications = notifications;
|
|
1416
1500
|
}
|
|
1417
1501
|
};
|
|
1418
1502
|
function createClient(params) {
|
|
@@ -1434,6 +1518,7 @@ function createClient(params) {
|
|
|
1434
1518
|
const cases = params.services.cases ? new CasesGateway(httpClient, params.services.cases.baseUrl) : null;
|
|
1435
1519
|
const rh = params.services.rh ? new RhGateway(httpClient, params.services.rh.baseUrl) : null;
|
|
1436
1520
|
const accessHub = params.services.accessHub ? new AccessHubGateway(httpClient, params.services.accessHub.baseUrl) : null;
|
|
1521
|
+
const notifications = params.services.notifications ? new NotificationsGateway(httpClient, params.services.notifications.baseUrl) : null;
|
|
1437
1522
|
return new SDKGateways(
|
|
1438
1523
|
customerService,
|
|
1439
1524
|
chatConfig,
|
|
@@ -1447,7 +1532,8 @@ function createClient(params) {
|
|
|
1447
1532
|
calls,
|
|
1448
1533
|
cases,
|
|
1449
1534
|
rh,
|
|
1450
|
-
accessHub
|
|
1535
|
+
accessHub,
|
|
1536
|
+
notifications
|
|
1451
1537
|
);
|
|
1452
1538
|
}
|
|
1453
1539
|
|
|
@@ -1465,7 +1551,8 @@ var SERVICE_GATEWAYS = {
|
|
|
1465
1551
|
CALLS: "calls",
|
|
1466
1552
|
CASES: "cases",
|
|
1467
1553
|
RH: "rh",
|
|
1468
|
-
ACCESS_HUB: "access-hub"
|
|
1554
|
+
ACCESS_HUB: "access-hub",
|
|
1555
|
+
NOTIFICATIONS: "notifications"
|
|
1469
1556
|
};
|
|
1470
1557
|
|
|
1471
1558
|
// src/index.ts
|
|
@@ -1534,6 +1621,10 @@ function gateway(service) {
|
|
|
1534
1621
|
if (!sdk.client.accessHub)
|
|
1535
1622
|
throw new Error(`Service 'access-hub' is not configured. Provide its baseUrl in configure().`);
|
|
1536
1623
|
return sdk.client.accessHub;
|
|
1624
|
+
case SERVICE_GATEWAYS.NOTIFICATIONS:
|
|
1625
|
+
if (!sdk.client.notifications)
|
|
1626
|
+
throw new Error(`Service 'notifications' is not configured. Provide its baseUrl in configure().`);
|
|
1627
|
+
return sdk.client.notifications;
|
|
1537
1628
|
default:
|
|
1538
1629
|
throw new Error(`Unknown service gateway: ${service}`);
|
|
1539
1630
|
}
|