@trycourier/courier 2.7.0 → 3.2.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/CHANGELOG.md +21 -1
- package/README.md +4 -0
- package/lib/client.js +18 -0
- package/lib/lists/index.js +4 -0
- package/lib/lists/types.d.ts +4 -0
- package/lib/profile.d.ts +2 -2
- package/lib/types.d.ts +39 -7
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,22 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
|
5
5
|
|
|
6
6
|
## [Unreleased][unreleased]
|
|
7
7
|
|
|
8
|
+
## [v3.2.0] - 2021-11-18
|
|
9
|
+
|
|
10
|
+
- adds idempotency expiration support for send and send list endpoints
|
|
11
|
+
|
|
12
|
+
## [v3.1.0] - 2021-11-16
|
|
13
|
+
|
|
14
|
+
- Expose additional type definitions for `getMessage`
|
|
15
|
+
|
|
16
|
+
## [v3.0.0] - 2021-11-02
|
|
17
|
+
|
|
18
|
+
- fixes type definition for `getRecipientSubscriptions`
|
|
19
|
+
|
|
20
|
+
## [v2.8.0] - 2021-10-29
|
|
21
|
+
|
|
22
|
+
- adds GET /messages/{messageId}/output API
|
|
23
|
+
|
|
8
24
|
## [v2.7.0] - 2021-10-21
|
|
9
25
|
|
|
10
26
|
- adds GET /messages/{messageId}/history API
|
|
@@ -169,7 +185,11 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
|
169
185
|
|
|
170
186
|
## v1.0.1 - 2019-07-12
|
|
171
187
|
|
|
172
|
-
[unreleased]: https://github.com/trycourier/courier-node/compare/
|
|
188
|
+
[unreleased]: https://github.com/trycourier/courier-node/compare/v3.2.0...HEAD
|
|
189
|
+
[v3.2.0]: https://github.com/trycourier/courier-node/compare/v3.1.0...v3.2.0
|
|
190
|
+
[v3.1.0]: https://github.com/trycourier/courier-node/compare/v3.0.0...v3.1.0
|
|
191
|
+
[v3.0.0]: https://github.com/trycourier/courier-node/compare/v2.8.0...v3.0.0
|
|
192
|
+
[v2.8.0]: https://github.com/trycourier/courier-node/compare/v2.7.0...v2.8.0
|
|
173
193
|
[v2.7.0]: https://github.com/trycourier/courier-node/compare/v2.6.0...v2.7.0
|
|
174
194
|
[v2.6.0]: https://github.com/trycourier/courier-node/compare/v2.4.0...v2.6.0
|
|
175
195
|
[v2.4.0]: https://github.com/trycourier/courier-node/compare/v2.3.0...v2.4.0
|
package/README.md
CHANGED
|
@@ -84,6 +84,10 @@ async function run() {
|
|
|
84
84
|
const { results } = await courier.getMessageHistory(messageId);
|
|
85
85
|
console.log(results);
|
|
86
86
|
|
|
87
|
+
// Example: get a message output
|
|
88
|
+
const { results } = await courier.getMessageOutput(messageId);
|
|
89
|
+
console.log(results);
|
|
90
|
+
|
|
87
91
|
// Example: get all messages
|
|
88
92
|
const { paging, results } = await courier.getMessages();
|
|
89
93
|
console.log(results);
|
package/lib/client.js
CHANGED
|
@@ -55,6 +55,10 @@ var send = function (options) {
|
|
|
55
55
|
if (config && config.idempotencyKey) {
|
|
56
56
|
axiosConfig.headers["Idempotency-Key"] = config.idempotencyKey;
|
|
57
57
|
}
|
|
58
|
+
if (config && config.idempotencyExpiry) {
|
|
59
|
+
axiosConfig.headers["x-idempotency-expiration"] =
|
|
60
|
+
config.idempotencyExpiry;
|
|
61
|
+
}
|
|
58
62
|
return [4 /*yield*/, options.httpClient.post("/send", {
|
|
59
63
|
brand: params.brand,
|
|
60
64
|
data: params.data,
|
|
@@ -97,6 +101,19 @@ var getMessageHistory = function (options) {
|
|
|
97
101
|
});
|
|
98
102
|
}); };
|
|
99
103
|
};
|
|
104
|
+
var getMessageOutput = function (options) {
|
|
105
|
+
return function (messageId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
106
|
+
var res;
|
|
107
|
+
return __generator(this, function (_a) {
|
|
108
|
+
switch (_a.label) {
|
|
109
|
+
case 0: return [4 /*yield*/, options.httpClient.get("/messages/" + messageId + "/output")];
|
|
110
|
+
case 1:
|
|
111
|
+
res = _a.sent();
|
|
112
|
+
return [2 /*return*/, res.data];
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}); };
|
|
116
|
+
};
|
|
100
117
|
var getMessages = function (options) {
|
|
101
118
|
return function (params) { return __awaiter(void 0, void 0, void 0, function () {
|
|
102
119
|
var res;
|
|
@@ -129,6 +146,7 @@ exports.client = function (options) {
|
|
|
129
146
|
getBrands: brands_1.getBrands(options),
|
|
130
147
|
getMessage: getMessage(options),
|
|
131
148
|
getMessageHistory: getMessageHistory(options),
|
|
149
|
+
getMessageOutput: getMessageOutput(options),
|
|
132
150
|
getMessages: getMessages(options),
|
|
133
151
|
getProfile: profile_1.getProfile(options),
|
|
134
152
|
getRecipientSubscriptions: profile_1.getRecipientSubscriptions(options),
|
package/lib/lists/index.js
CHANGED
|
@@ -192,6 +192,10 @@ var send = function (options) {
|
|
|
192
192
|
if (config && config.idempotencyKey) {
|
|
193
193
|
axiosConfig.headers["Idempotency-Key"] = config.idempotencyKey;
|
|
194
194
|
}
|
|
195
|
+
if (config && config.idempotencyExpiry) {
|
|
196
|
+
axiosConfig.headers["x-idempotency-expiration"] =
|
|
197
|
+
config.idempotencyExpiry;
|
|
198
|
+
}
|
|
195
199
|
return [4 /*yield*/, options.httpClient.post("/send/list", params, axiosConfig)];
|
|
196
200
|
case 1:
|
|
197
201
|
res = _a.sent();
|
package/lib/lists/types.d.ts
CHANGED
|
@@ -6,6 +6,10 @@ export interface ICourierList {
|
|
|
6
6
|
name: string;
|
|
7
7
|
updated?: number;
|
|
8
8
|
}
|
|
9
|
+
export interface ICourierRecipientSubscriptionsResponse {
|
|
10
|
+
paging: ICourierPaging;
|
|
11
|
+
results: ICourierList[];
|
|
12
|
+
}
|
|
9
13
|
export interface ICourierListPutParams {
|
|
10
14
|
name: string;
|
|
11
15
|
preferences?: {
|
package/lib/profile.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ICourierRecipientSubscriptionsResponse } from "./lists/types";
|
|
2
2
|
import { ICourierClientConfiguration, ICourierProfileDeleteParameters, ICourierProfileGetParameters, ICourierProfileGetResponse, ICourierProfileListsPostParameters, ICourierProfilePostConfig, ICourierProfilePostParameters, ICourierProfilePostResponse, ICourierProfilePutParameters, ICourierProfilePutResponse } from "./types";
|
|
3
3
|
export declare const replaceProfile: (options: ICourierClientConfiguration) => (params: ICourierProfilePutParameters) => Promise<ICourierProfilePutResponse>;
|
|
4
4
|
export declare const mergeProfile: (options: ICourierClientConfiguration) => (params: ICourierProfilePostParameters, config?: ICourierProfilePostConfig | undefined) => Promise<ICourierProfilePostResponse>;
|
|
5
5
|
export declare const getProfile: (options: ICourierClientConfiguration) => (params: ICourierProfileGetParameters) => Promise<ICourierProfileGetResponse>;
|
|
6
6
|
export declare const deleteProfile: (options: ICourierClientConfiguration) => (params: ICourierProfileDeleteParameters) => Promise<void>;
|
|
7
|
-
export declare const getRecipientSubscriptions: (options: ICourierClientConfiguration) => (params: ICourierProfileGetParameters) => Promise<
|
|
7
|
+
export declare const getRecipientSubscriptions: (options: ICourierClientConfiguration) => (params: ICourierProfileGetParameters) => Promise<ICourierRecipientSubscriptionsResponse>;
|
|
8
8
|
export declare const addRecipientToLists: (options: ICourierClientConfiguration) => (params: ICourierProfileListsPostParameters) => Promise<ICourierProfilePostResponse>;
|
|
9
9
|
export declare const removeRecipientFromAllLists: (options: ICourierClientConfiguration) => (params: ICourierProfileGetParameters) => Promise<ICourierProfilePostResponse>;
|
package/lib/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AxiosRequestConfig } from "axios";
|
|
2
2
|
import { ICourierClientAutomations } from "./automations/types";
|
|
3
|
-
import { ICourierClientLists, ICourierList } from "./lists/types";
|
|
3
|
+
import { ICourierClientLists, ICourierList, ICourierRecipientSubscriptionsResponse } from "./lists/types";
|
|
4
4
|
import { ICourierClientNotifications } from "./notifications/types";
|
|
5
5
|
import { ICourierClientPreferences, IRecipientPreferences } from "./preferences/types";
|
|
6
6
|
export declare type HttpMethodClient = <T>(url: string, body?: object, config?: AxiosRequestConfig) => Promise<{
|
|
@@ -31,6 +31,7 @@ export interface ICourierSendParameters {
|
|
|
31
31
|
}
|
|
32
32
|
export interface ICourierSendConfig {
|
|
33
33
|
idempotencyKey?: string;
|
|
34
|
+
idempotencyExpiry?: number;
|
|
34
35
|
}
|
|
35
36
|
export interface ICourierSendResponse {
|
|
36
37
|
messageId: string;
|
|
@@ -101,25 +102,40 @@ export interface ICourierMessagesGetResponse {
|
|
|
101
102
|
}>;
|
|
102
103
|
}
|
|
103
104
|
export interface ICourierMessageGetResponse {
|
|
105
|
+
clicked?: number;
|
|
106
|
+
delivered?: number;
|
|
104
107
|
enqueued?: number;
|
|
108
|
+
error?: string;
|
|
105
109
|
event?: string;
|
|
106
110
|
id: string;
|
|
111
|
+
idempotencyKey?: string;
|
|
112
|
+
listId?: string;
|
|
113
|
+
listMessageId?: string;
|
|
107
114
|
notification?: string;
|
|
115
|
+
opened?: number;
|
|
108
116
|
providers?: Array<{
|
|
109
117
|
channel: {
|
|
110
|
-
|
|
118
|
+
key?: string;
|
|
119
|
+
name?: string;
|
|
111
120
|
template: string;
|
|
112
121
|
};
|
|
122
|
+
clicked?: number;
|
|
123
|
+
delivered?: number;
|
|
124
|
+
error?: string;
|
|
113
125
|
provider: string;
|
|
114
|
-
reference
|
|
115
|
-
|
|
126
|
+
reference?: {
|
|
127
|
+
[key: string]: string | number;
|
|
116
128
|
};
|
|
117
129
|
sent: number;
|
|
118
|
-
status:
|
|
130
|
+
status: MessageStatus;
|
|
119
131
|
}>;
|
|
132
|
+
reason?: MessageStatusReason;
|
|
133
|
+
reasonCode?: MessageStatusReasonCode;
|
|
134
|
+
reasonDetails?: string;
|
|
120
135
|
recipient: string;
|
|
136
|
+
runId?: string;
|
|
121
137
|
sent?: number;
|
|
122
|
-
status:
|
|
138
|
+
status: MessageStatus;
|
|
123
139
|
}
|
|
124
140
|
export declare type MessageStatus = "CLICKED" | "DELIVERED" | "ENQUEUED" | "FILTERED" | "OPENED" | "SENT" | "SIMULATED" | "UNDELIVERABLE" | "UNMAPPED";
|
|
125
141
|
export declare type MessageHistoryType = MessageStatus | "DELIVERING" | "FILTERED" | "MAPPED" | "PROFILE_LOADED" | "RENDERED";
|
|
@@ -188,6 +204,21 @@ export interface IProviderErrorMessageHistory extends IRoutedMessageHistory<"UND
|
|
|
188
204
|
export interface ICourierMessageGetHistoryResponse {
|
|
189
205
|
results: Array<IEnqueuedMessageHistory | IMappedMessageHistory | IProfileLoadedMessageHistory | IRenderedMessageHistory | IRoutedMessageHistory<RoutedMessageHistoryTypes> | IDeliveredMessageHistory | IProviderErrorMessageHistory | IUndeliverableMessageHistory>;
|
|
190
206
|
}
|
|
207
|
+
export interface IApiMessageOutputItem {
|
|
208
|
+
channel: string;
|
|
209
|
+
channel_id: string;
|
|
210
|
+
content: {
|
|
211
|
+
html?: string;
|
|
212
|
+
title?: string;
|
|
213
|
+
blocks?: any[];
|
|
214
|
+
body?: string;
|
|
215
|
+
subject?: string;
|
|
216
|
+
text?: string;
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
export interface ICourierMessageGetOutputResponse {
|
|
220
|
+
results: IApiMessageOutputItem[];
|
|
221
|
+
}
|
|
191
222
|
export interface ICourierProfileDeleteParameters {
|
|
192
223
|
recipientId: string;
|
|
193
224
|
}
|
|
@@ -250,10 +281,11 @@ export interface ICourierClient {
|
|
|
250
281
|
}) => Promise<ICourierBrandGetAllResponse>;
|
|
251
282
|
getMessage: (messageId: string) => Promise<ICourierMessageGetResponse>;
|
|
252
283
|
getMessageHistory: (messageId: string) => Promise<ICourierMessageGetHistoryResponse>;
|
|
284
|
+
getMessageOutput: (messageId: string) => Promise<ICourierMessageGetOutputResponse>;
|
|
253
285
|
getMessages: (params?: ICourierMessagesGetParameters) => Promise<ICourierMessagesGetResponse>;
|
|
254
286
|
getProfile: (params: ICourierProfileGetParameters) => Promise<ICourierProfileGetResponse>;
|
|
255
287
|
deleteProfile: (params: ICourierProfileDeleteParameters) => Promise<void>;
|
|
256
|
-
getRecipientSubscriptions: (params: ICourierProfileGetParameters) => Promise<
|
|
288
|
+
getRecipientSubscriptions: (params: ICourierProfileGetParameters) => Promise<ICourierRecipientSubscriptionsResponse>;
|
|
257
289
|
lists: ICourierClientLists;
|
|
258
290
|
mergeProfile: (params: ICourierProfilePostParameters, config?: ICourierProfilePostConfig) => Promise<ICourierProfilePostResponse>;
|
|
259
291
|
notifications: ICourierClientNotifications;
|