Skip to content

Commit 8eea56e

Browse files
authored
Merge pull request #17 from notificationapi-com/RZz5QMES/3059-add-region-to-react-sdk
Update version to 0.0.15 and enhance type safety by introducing API_REGION and WS_REGION enums for host and websocketHost properties.
2 parents 03b8be9 + 80bcf9b commit 8eea56e

File tree

5 files changed

+21
-7
lines changed

5 files changed

+21
-7
lines changed

lib/api.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import { API_REGION } from './interfaces';
2+
13
export const api = async (
24
method: 'GET' | 'POST' | 'PATCH' | 'DELETE',
3-
host: string,
5+
host: string | API_REGION,
46
resource: string,
57
clientId: string,
68
userId: string,

lib/client.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { api } from './api';
22
import {
3+
API_REGION,
34
BaseDeliveryOptions,
45
Channels,
56
DeliveryOptionsForEmail,
67
DeliveryOptionsForInappWeb,
78
PostUserRequest,
8-
UserAccountMetadata
9+
UserAccountMetadata,
10+
WS_REGION
911
} from './interfaces';
1012
import {
1113
GetPreferencesResponse,
@@ -17,14 +19,14 @@ type NotificationAPIClientSDKConfig = {
1719
userId: string;
1820
clientId: string;
1921
hashedUserId: string;
20-
host: string;
22+
host: string | API_REGION;
2123

2224
// inapp notifications:
2325
getInAppDefaultCount: number;
2426
getInAppDefaultOldest: string;
2527

2628
// Websocket:
27-
websocketHost: string;
29+
websocketHost: string | WS_REGION;
2830
keepWebSocketAliveForSeconds: number;
2931
onNewInAppNotifications?: (notifications: InAppNotification[]) => unknown;
3032
};

lib/interfaces.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,17 @@ export interface WebSocket_NewNotification_Message {
4848
notifications: InAppNotification[];
4949
};
5050
}
51+
export enum API_REGION {
52+
US = 'api.notificationapi.com',
53+
EU = 'api.eu.notificationapi.com',
54+
CA = 'api.ca.notificationapi.com'
55+
}
5156

57+
export enum WS_REGION {
58+
US = 'ws.notificationapi.com',
59+
EU = 'ws.eu.notificationapi.com',
60+
CA = 'ws.ca.notificationapi.com'
61+
}
5262
export type Channels =
5363
| 'EMAIL'
5464
| 'INAPP_WEB'

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@notificationapi/core",
3-
"version": "0.0.14",
3+
"version": "0.0.15",
44
"type": "module",
55
"main": "dist/main.js",
66
"types": "dist/main.d.ts",

0 commit comments

Comments
 (0)