@trycourier/courier-js 3.1.0 → 3.1.1
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 +106 -9
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +64 -13
- package/dist/index.mjs.map +1 -1
- package/dist/types/courier-api-urls.d.ts +4 -0
- package/dist/types/inbox.d.ts +19 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,60 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
const freezeCourierApiUrls = (urls) => Object.freeze({
|
|
5
|
+
courier: Object.freeze({
|
|
6
|
+
...urls.courier
|
|
7
|
+
}),
|
|
8
|
+
inbox: Object.freeze({
|
|
9
|
+
...urls.inbox
|
|
10
|
+
})
|
|
11
|
+
});
|
|
12
|
+
const cloneCourierApiUrls = (urls) => ({
|
|
13
|
+
courier: {
|
|
14
|
+
...urls.courier
|
|
15
|
+
},
|
|
16
|
+
inbox: {
|
|
17
|
+
...urls.inbox
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
const COURIER_API_URLS_BY_REGION = {
|
|
21
|
+
us: freezeCourierApiUrls({
|
|
22
|
+
courier: {
|
|
23
|
+
rest: "https://api.courier.com",
|
|
24
|
+
graphql: "https://api.courier.com/client/q"
|
|
25
|
+
},
|
|
26
|
+
inbox: {
|
|
27
|
+
graphql: "https://inbox.courier.com/q",
|
|
28
|
+
webSocket: "wss://realtime.courier.io"
|
|
29
|
+
}
|
|
30
|
+
}),
|
|
31
|
+
eu: freezeCourierApiUrls({
|
|
32
|
+
courier: {
|
|
33
|
+
rest: "https://api.eu.courier.com",
|
|
34
|
+
graphql: "https://api.eu.courier.com/client/q"
|
|
35
|
+
},
|
|
36
|
+
inbox: {
|
|
37
|
+
graphql: "https://inbox.eu.courier.io/q",
|
|
38
|
+
webSocket: "wss://realtime.eu.courier.io"
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
};
|
|
42
|
+
const DEFAULT_COURIER_API_URLS = COURIER_API_URLS_BY_REGION.us;
|
|
43
|
+
const EU_COURIER_API_URLS = COURIER_API_URLS_BY_REGION.eu;
|
|
44
|
+
const getCourierApiUrlsForRegion = (region = "us") => cloneCourierApiUrls(COURIER_API_URLS_BY_REGION[region]);
|
|
45
|
+
const getCourierApiUrls = (urls) => {
|
|
46
|
+
const defaultUrls = DEFAULT_COURIER_API_URLS;
|
|
47
|
+
return {
|
|
48
|
+
courier: {
|
|
49
|
+
rest: (urls == null ? void 0 : urls.courier.rest) || defaultUrls.courier.rest,
|
|
50
|
+
graphql: (urls == null ? void 0 : urls.courier.graphql) || defaultUrls.courier.graphql
|
|
51
|
+
},
|
|
52
|
+
inbox: {
|
|
53
|
+
graphql: (urls == null ? void 0 : urls.inbox.graphql) || defaultUrls.inbox.graphql,
|
|
54
|
+
webSocket: (urls == null ? void 0 : urls.inbox.webSocket) || defaultUrls.inbox.webSocket
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
};
|
|
4
58
|
var ClientAction = /* @__PURE__ */ ((ClientAction2) => {
|
|
5
59
|
ClientAction2["Subscribe"] = "subscribe";
|
|
6
60
|
ClientAction2["Unsubscribe"] = "unsubscribe";
|
|
@@ -27,16 +81,6 @@ var InboxMessageEvent = /* @__PURE__ */ ((InboxMessageEvent2) => {
|
|
|
27
81
|
InboxMessageEvent2["Unread"] = "unread";
|
|
28
82
|
return InboxMessageEvent2;
|
|
29
83
|
})(InboxMessageEvent || {});
|
|
30
|
-
const getCourierApiUrls = (urls) => ({
|
|
31
|
-
courier: {
|
|
32
|
-
rest: (urls == null ? void 0 : urls.courier.rest) || "https://api.courier.com",
|
|
33
|
-
graphql: (urls == null ? void 0 : urls.courier.graphql) || "https://api.courier.com/client/q"
|
|
34
|
-
},
|
|
35
|
-
inbox: {
|
|
36
|
-
graphql: (urls == null ? void 0 : urls.inbox.graphql) || "https://inbox.courier.com/q",
|
|
37
|
-
webSocket: (urls == null ? void 0 : urls.inbox.webSocket) || "wss://realtime.courier.io"
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
84
|
class Logger {
|
|
41
85
|
constructor(showLogs) {
|
|
42
86
|
__publicField(this, "PREFIX", "[COURIER]");
|
|
@@ -1237,6 +1281,9 @@ class InboxClient extends Client {
|
|
|
1237
1281
|
if (filter.archived) {
|
|
1238
1282
|
parts.push(`archived: ${filter.archived}`);
|
|
1239
1283
|
}
|
|
1284
|
+
if (filter.from) {
|
|
1285
|
+
parts.push(`from: "${filter.from}"`);
|
|
1286
|
+
}
|
|
1240
1287
|
return `{ ${parts.join(",")} }`;
|
|
1241
1288
|
}
|
|
1242
1289
|
/**
|
|
@@ -1592,7 +1639,7 @@ const _CourierClient = class _CourierClient extends Client {
|
|
|
1592
1639
|
...props,
|
|
1593
1640
|
showLogs,
|
|
1594
1641
|
connectionId,
|
|
1595
|
-
apiUrls: props.apiUrls ||
|
|
1642
|
+
apiUrls: props.apiUrls || getCourierApiUrlsForRegion("us"),
|
|
1596
1643
|
accessToken: props.jwt ?? props.publicApiKey
|
|
1597
1644
|
};
|
|
1598
1645
|
const courierUserAgent = new CourierUserAgent(
|
|
@@ -1639,7 +1686,7 @@ __publicField(_CourierClient, "COURIER_JS_NAME", "courier-js");
|
|
|
1639
1686
|
* User agent reporting version of the courier-js package.
|
|
1640
1687
|
* Inlined from package.json at build time.
|
|
1641
1688
|
*/
|
|
1642
|
-
__publicField(_CourierClient, "COURIER_JS_VERSION", "3.1.
|
|
1689
|
+
__publicField(_CourierClient, "COURIER_JS_VERSION", "3.1.1");
|
|
1643
1690
|
let CourierClient = _CourierClient;
|
|
1644
1691
|
class AuthenticationListener {
|
|
1645
1692
|
constructor(callback) {
|
|
@@ -1767,11 +1814,15 @@ export {
|
|
|
1767
1814
|
BrandClient,
|
|
1768
1815
|
Courier,
|
|
1769
1816
|
CourierClient,
|
|
1817
|
+
DEFAULT_COURIER_API_URLS,
|
|
1818
|
+
EU_COURIER_API_URLS,
|
|
1770
1819
|
InboxClient,
|
|
1771
1820
|
InboxMessageEvent,
|
|
1772
1821
|
ListClient,
|
|
1773
1822
|
PreferenceClient,
|
|
1774
1823
|
TokenClient,
|
|
1775
|
-
TrackingClient
|
|
1824
|
+
TrackingClient,
|
|
1825
|
+
getCourierApiUrls,
|
|
1826
|
+
getCourierApiUrlsForRegion
|
|
1776
1827
|
};
|
|
1777
1828
|
//# sourceMappingURL=index.mjs.map
|