@trycourier/courier 2.6.0 → 3.1.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 +12 -0
- package/lib/client.js +28 -0
- package/lib/lists/types.d.ts +4 -0
- package/lib/profile.d.ts +2 -2
- package/lib/types.d.ts +106 -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.1.0] - 2021-11-16
|
|
9
|
+
|
|
10
|
+
- Expose additional type definitions for `getMessage`
|
|
11
|
+
|
|
12
|
+
## [v3.0.0] - 2021-11-02
|
|
13
|
+
|
|
14
|
+
- fixes type definition for `getRecipientSubscriptions`
|
|
15
|
+
|
|
16
|
+
## [v2.8.0] - 2021-10-29
|
|
17
|
+
|
|
18
|
+
- adds GET /messages/{messageId}/output API
|
|
19
|
+
|
|
20
|
+
## [v2.7.0] - 2021-10-21
|
|
21
|
+
|
|
22
|
+
- adds GET /messages/{messageId}/history API
|
|
23
|
+
|
|
8
24
|
## [v2.6.0] - 2021-10-07
|
|
9
25
|
|
|
10
26
|
- Add support for DELETE /profiles/{recipient_id} (#58)
|
|
@@ -165,7 +181,11 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
|
165
181
|
|
|
166
182
|
## v1.0.1 - 2019-07-12
|
|
167
183
|
|
|
168
|
-
[unreleased]: https://github.com/trycourier/courier-node/compare/
|
|
184
|
+
[unreleased]: https://github.com/trycourier/courier-node/compare/v3.1.0...HEAD
|
|
185
|
+
[v3.1.0]: https://github.com/trycourier/courier-node/compare/v3.0.0...v3.1.0
|
|
186
|
+
[v3.0.0]: https://github.com/trycourier/courier-node/compare/v2.8.0...v3.0.0
|
|
187
|
+
[v2.8.0]: https://github.com/trycourier/courier-node/compare/v2.7.0...v2.8.0
|
|
188
|
+
[v2.7.0]: https://github.com/trycourier/courier-node/compare/v2.6.0...v2.7.0
|
|
169
189
|
[v2.6.0]: https://github.com/trycourier/courier-node/compare/v2.4.0...v2.6.0
|
|
170
190
|
[v2.4.0]: https://github.com/trycourier/courier-node/compare/v2.3.0...v2.4.0
|
|
171
191
|
[v2.3.0]: https://github.com/trycourier/courier-node/compare/v2.2.0...v2.3.0
|
package/README.md
CHANGED
|
@@ -80,6 +80,18 @@ async function run() {
|
|
|
80
80
|
const messageStatus = await courier.getMessage(messageId);
|
|
81
81
|
console.log(messageStatus);
|
|
82
82
|
|
|
83
|
+
// Example: get a message history
|
|
84
|
+
const { results } = await courier.getMessageHistory(messageId);
|
|
85
|
+
console.log(results);
|
|
86
|
+
|
|
87
|
+
// Example: get a message output
|
|
88
|
+
const { results } = await courier.getMessageOutput(messageId);
|
|
89
|
+
console.log(results);
|
|
90
|
+
|
|
91
|
+
// Example: get all messages
|
|
92
|
+
const { paging, results } = await courier.getMessages();
|
|
93
|
+
console.log(results);
|
|
94
|
+
|
|
83
95
|
// Example: replace a recipient's profile
|
|
84
96
|
const { status: replaceStatus } = await courier.replaceProfile({
|
|
85
97
|
recipientId: "<RECIPIENT_ID>",
|
package/lib/client.js
CHANGED
|
@@ -84,6 +84,32 @@ var getMessage = function (options) {
|
|
|
84
84
|
});
|
|
85
85
|
}); };
|
|
86
86
|
};
|
|
87
|
+
var getMessageHistory = function (options) {
|
|
88
|
+
return function (messageId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
89
|
+
var res;
|
|
90
|
+
return __generator(this, function (_a) {
|
|
91
|
+
switch (_a.label) {
|
|
92
|
+
case 0: return [4 /*yield*/, options.httpClient.get("/messages/" + messageId + "/history")];
|
|
93
|
+
case 1:
|
|
94
|
+
res = _a.sent();
|
|
95
|
+
return [2 /*return*/, res.data];
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}); };
|
|
99
|
+
};
|
|
100
|
+
var getMessageOutput = function (options) {
|
|
101
|
+
return function (messageId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
102
|
+
var res;
|
|
103
|
+
return __generator(this, function (_a) {
|
|
104
|
+
switch (_a.label) {
|
|
105
|
+
case 0: return [4 /*yield*/, options.httpClient.get("/messages/" + messageId + "/output")];
|
|
106
|
+
case 1:
|
|
107
|
+
res = _a.sent();
|
|
108
|
+
return [2 /*return*/, res.data];
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}); };
|
|
112
|
+
};
|
|
87
113
|
var getMessages = function (options) {
|
|
88
114
|
return function (params) { return __awaiter(void 0, void 0, void 0, function () {
|
|
89
115
|
var res;
|
|
@@ -115,6 +141,8 @@ exports.client = function (options) {
|
|
|
115
141
|
getBrand: brands_1.getBrand(options),
|
|
116
142
|
getBrands: brands_1.getBrands(options),
|
|
117
143
|
getMessage: getMessage(options),
|
|
144
|
+
getMessageHistory: getMessageHistory(options),
|
|
145
|
+
getMessageOutput: getMessageOutput(options),
|
|
118
146
|
getMessages: getMessages(options),
|
|
119
147
|
getProfile: profile_1.getProfile(options),
|
|
120
148
|
getRecipientSubscriptions: profile_1.getRecipientSubscriptions(options),
|
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<{
|
|
@@ -101,25 +101,122 @@ export interface ICourierMessagesGetResponse {
|
|
|
101
101
|
}>;
|
|
102
102
|
}
|
|
103
103
|
export interface ICourierMessageGetResponse {
|
|
104
|
+
clicked?: number;
|
|
105
|
+
delivered?: number;
|
|
104
106
|
enqueued?: number;
|
|
107
|
+
error?: string;
|
|
105
108
|
event?: string;
|
|
106
109
|
id: string;
|
|
110
|
+
idempotencyKey?: string;
|
|
111
|
+
listId?: string;
|
|
112
|
+
listMessageId?: string;
|
|
107
113
|
notification?: string;
|
|
114
|
+
opened?: number;
|
|
108
115
|
providers?: Array<{
|
|
109
116
|
channel: {
|
|
110
|
-
|
|
117
|
+
key?: string;
|
|
118
|
+
name?: string;
|
|
111
119
|
template: string;
|
|
112
120
|
};
|
|
121
|
+
clicked?: number;
|
|
122
|
+
delivered?: number;
|
|
123
|
+
error?: string;
|
|
113
124
|
provider: string;
|
|
114
|
-
reference
|
|
115
|
-
|
|
125
|
+
reference?: {
|
|
126
|
+
[key: string]: string | number;
|
|
116
127
|
};
|
|
117
128
|
sent: number;
|
|
118
|
-
status:
|
|
129
|
+
status: MessageStatus;
|
|
119
130
|
}>;
|
|
131
|
+
reason?: MessageStatusReason;
|
|
132
|
+
reasonCode?: MessageStatusReasonCode;
|
|
133
|
+
reasonDetails?: string;
|
|
120
134
|
recipient: string;
|
|
135
|
+
runId?: string;
|
|
121
136
|
sent?: number;
|
|
122
|
-
status:
|
|
137
|
+
status: MessageStatus;
|
|
138
|
+
}
|
|
139
|
+
export declare type MessageStatus = "CLICKED" | "DELIVERED" | "ENQUEUED" | "FILTERED" | "OPENED" | "SENT" | "SIMULATED" | "UNDELIVERABLE" | "UNMAPPED";
|
|
140
|
+
export declare type MessageHistoryType = MessageStatus | "DELIVERING" | "FILTERED" | "MAPPED" | "PROFILE_LOADED" | "RENDERED";
|
|
141
|
+
export declare type MessageStatusReason = "BOUNCED" | "FAILED" | "FILTERED" | "NO_CHANNELS" | "NO_PROVIDERS" | "OPT_IN_REQUIRED" | "PROVIDER_ERROR" | "UNPUBLISHED" | "UNSUBSCRIBED";
|
|
142
|
+
export declare type MessageStatusReasonCode = "HARD" | "SOFT";
|
|
143
|
+
export interface IMessageHistory<T extends MessageHistoryType> {
|
|
144
|
+
ts: number;
|
|
145
|
+
type: T;
|
|
146
|
+
}
|
|
147
|
+
export interface IEnqueuedMessageHistory extends IMessageHistory<"ENQUEUED"> {
|
|
148
|
+
data?: string | {
|
|
149
|
+
[key: string]: string;
|
|
150
|
+
};
|
|
151
|
+
event: string;
|
|
152
|
+
profile?: {
|
|
153
|
+
[key: string]: any;
|
|
154
|
+
};
|
|
155
|
+
override?: {
|
|
156
|
+
[key: string]: any;
|
|
157
|
+
};
|
|
158
|
+
recipient: string;
|
|
159
|
+
}
|
|
160
|
+
export interface IMappedMessageHistory extends IMessageHistory<"MAPPED"> {
|
|
161
|
+
event_id: string;
|
|
162
|
+
notification_id: string;
|
|
163
|
+
}
|
|
164
|
+
export interface IProfileLoadedMessageHistory extends IMessageHistory<"PROFILE_LOADED"> {
|
|
165
|
+
merged_profile?: {
|
|
166
|
+
[key: string]: any;
|
|
167
|
+
};
|
|
168
|
+
received_profile?: {
|
|
169
|
+
[key: string]: any;
|
|
170
|
+
};
|
|
171
|
+
stored_profile?: {
|
|
172
|
+
[key: string]: any;
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
export interface IRenderedMessageHistory extends IRoutedMessageHistory<"RENDERED"> {
|
|
176
|
+
output: {
|
|
177
|
+
[key: string]: string;
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
export interface IUndeliverableMessageHistory extends IMessageHistory<"UNDELIVERABLE">, Partial<Omit<IRoutedMessageHistory<"UNDELIVERABLE">, "ts" | "type">> {
|
|
181
|
+
reason: MessageStatusReason;
|
|
182
|
+
reasonCode?: MessageStatusReasonCode;
|
|
183
|
+
}
|
|
184
|
+
export declare type RoutedMessageHistoryTypes = Extract<MessageHistoryType, "CLICKED" | "DELIVERED" | "DELIVERING" | "OPENED" | "RENDERED" | "SENT" | "UNDELIVERABLE">;
|
|
185
|
+
export interface IRoutedMessageHistory<T extends RoutedMessageHistoryTypes> extends IMessageHistory<T> {
|
|
186
|
+
channel: {
|
|
187
|
+
id: string;
|
|
188
|
+
label?: string;
|
|
189
|
+
};
|
|
190
|
+
integration: {
|
|
191
|
+
id: string;
|
|
192
|
+
provider: string;
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
export interface IDeliveredMessageHistory extends IRoutedMessageHistory<"DELIVERED"> {
|
|
196
|
+
reference: {
|
|
197
|
+
[key: string]: string;
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
export interface IProviderErrorMessageHistory extends IRoutedMessageHistory<"UNDELIVERABLE"> {
|
|
201
|
+
error_message: string;
|
|
202
|
+
}
|
|
203
|
+
export interface ICourierMessageGetHistoryResponse {
|
|
204
|
+
results: Array<IEnqueuedMessageHistory | IMappedMessageHistory | IProfileLoadedMessageHistory | IRenderedMessageHistory | IRoutedMessageHistory<RoutedMessageHistoryTypes> | IDeliveredMessageHistory | IProviderErrorMessageHistory | IUndeliverableMessageHistory>;
|
|
205
|
+
}
|
|
206
|
+
export interface IApiMessageOutputItem {
|
|
207
|
+
channel: string;
|
|
208
|
+
channel_id: string;
|
|
209
|
+
content: {
|
|
210
|
+
html?: string;
|
|
211
|
+
title?: string;
|
|
212
|
+
blocks?: any[];
|
|
213
|
+
body?: string;
|
|
214
|
+
subject?: string;
|
|
215
|
+
text?: string;
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
export interface ICourierMessageGetOutputResponse {
|
|
219
|
+
results: IApiMessageOutputItem[];
|
|
123
220
|
}
|
|
124
221
|
export interface ICourierProfileDeleteParameters {
|
|
125
222
|
recipientId: string;
|
|
@@ -182,10 +279,12 @@ export interface ICourierClient {
|
|
|
182
279
|
cursor: string;
|
|
183
280
|
}) => Promise<ICourierBrandGetAllResponse>;
|
|
184
281
|
getMessage: (messageId: string) => Promise<ICourierMessageGetResponse>;
|
|
282
|
+
getMessageHistory: (messageId: string) => Promise<ICourierMessageGetHistoryResponse>;
|
|
283
|
+
getMessageOutput: (messageId: string) => Promise<ICourierMessageGetOutputResponse>;
|
|
185
284
|
getMessages: (params?: ICourierMessagesGetParameters) => Promise<ICourierMessagesGetResponse>;
|
|
186
285
|
getProfile: (params: ICourierProfileGetParameters) => Promise<ICourierProfileGetResponse>;
|
|
187
286
|
deleteProfile: (params: ICourierProfileDeleteParameters) => Promise<void>;
|
|
188
|
-
getRecipientSubscriptions: (params: ICourierProfileGetParameters) => Promise<
|
|
287
|
+
getRecipientSubscriptions: (params: ICourierProfileGetParameters) => Promise<ICourierRecipientSubscriptionsResponse>;
|
|
189
288
|
lists: ICourierClientLists;
|
|
190
289
|
mergeProfile: (params: ICourierProfilePostParameters, config?: ICourierProfilePostConfig) => Promise<ICourierProfilePostResponse>;
|
|
191
290
|
notifications: ICourierClientNotifications;
|