@trycourier/courier 3.7.0 → 3.10.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 +17 -2
- package/README.md +48 -2
- package/lib/bulk/types.d.ts +9 -1
- package/lib/client.js +2 -2
- package/lib/send/types.d.ts +21 -9
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,9 +5,20 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
|
5
5
|
|
|
6
6
|
## [Unreleased][unreleased]
|
|
7
7
|
|
|
8
|
+
## [3.10.0] - 2022-03-20
|
|
9
|
+
- adds support for messages timeout (`message.timeout`)
|
|
10
|
+
|
|
11
|
+
## [3.9.0] - 2022-03-17
|
|
12
|
+
|
|
13
|
+
- adds support for bulk messaging API v2 support
|
|
14
|
+
|
|
15
|
+
## [3.8.0] - 2022-03-14
|
|
16
|
+
|
|
17
|
+
- adds additional types for utm property (`message.metadata.utm`)
|
|
18
|
+
|
|
8
19
|
## [v3.7.0] - 2022-03-11
|
|
9
20
|
|
|
10
|
-
- adds additional types for the tags property (`message.tags`)
|
|
21
|
+
- adds additional types for the tags property (`message.metadata.tags`)
|
|
11
22
|
- adds support for searching message by tags
|
|
12
23
|
|
|
13
24
|
## [v3.6.0] - 2022-02-10
|
|
@@ -210,7 +221,11 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
|
210
221
|
|
|
211
222
|
## v1.0.1 - 2019-07-12
|
|
212
223
|
|
|
213
|
-
[unreleased]: https://github.com/trycourier/courier-node/compare/v3.
|
|
224
|
+
[unreleased]: https://github.com/trycourier/courier-node/compare/v3.9.0...HEAD
|
|
225
|
+
[v3.9.0]: https://github.com/trycourier/courier-node/compare/v3.8.0...v3.9.0
|
|
226
|
+
[v3.8.0]: https://github.com/trycourier/courier-node/compare/v3.7.0...v3.8.0
|
|
227
|
+
[v3.7.0]: https://github.com/trycourier/courier-node/compare/v3.6.0...v3.7.0
|
|
228
|
+
[v3.6.0]: https://github.com/trycourier/courier-node/compare/v3.5.0...v3.6.0
|
|
214
229
|
[v3.5.0]: https://github.com/trycourier/courier-node/compare/v3.4.0...v3.5.0
|
|
215
230
|
[v3.4.0]: https://github.com/trycourier/courier-node/compare/v3.3.0...v3.4.0
|
|
216
231
|
[v3.3.0]: https://github.com/trycourier/courier-node/compare/v3.2.1...v3.3.0
|
package/README.md
CHANGED
|
@@ -160,6 +160,29 @@ const { requestId } = await courier.send({
|
|
|
160
160
|
},
|
|
161
161
|
},
|
|
162
162
|
});
|
|
163
|
+
|
|
164
|
+
// Example: send a basic message that expires after the specified timeout
|
|
165
|
+
const { requestId } = await courier.send({
|
|
166
|
+
message: {
|
|
167
|
+
to: {
|
|
168
|
+
data: {
|
|
169
|
+
name: "Marty",
|
|
170
|
+
},
|
|
171
|
+
email: "marty_mcfly@email.com",
|
|
172
|
+
},
|
|
173
|
+
content: {
|
|
174
|
+
title: "Back to the Future",
|
|
175
|
+
body: "Oh my {{name}}, we need 1.21 Gigawatts!",
|
|
176
|
+
},
|
|
177
|
+
routing: {
|
|
178
|
+
method: "single",
|
|
179
|
+
channels: ["email"],
|
|
180
|
+
},
|
|
181
|
+
timeout: {
|
|
182
|
+
message: 3600000 // 1 hour in milliseconds
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
});
|
|
163
186
|
```
|
|
164
187
|
|
|
165
188
|
## Environment Variables
|
|
@@ -497,7 +520,7 @@ async function run() {
|
|
|
497
520
|
await courier.notifications.cancelSubmission("notification1", "submission1");
|
|
498
521
|
|
|
499
522
|
// Bulk Processing
|
|
500
|
-
// Example: create a job
|
|
523
|
+
// Example: create a job (API v1 semantics)
|
|
501
524
|
const response = await courier.bulk.createJob({
|
|
502
525
|
message: {
|
|
503
526
|
event: "RR4NDQ7NZ24A8TKPWVBEDGE15E9A",
|
|
@@ -505,13 +528,23 @@ async function run() {
|
|
|
505
528
|
});
|
|
506
529
|
console.log(response);
|
|
507
530
|
|
|
531
|
+
// Example: create a job (API v2 semantics)
|
|
532
|
+
const response = await courier.bulk.createJob({
|
|
533
|
+
message: {
|
|
534
|
+
message: {
|
|
535
|
+
template: "RR4NDQ7NZ24A8TKPWVBEDGE15E9A",
|
|
536
|
+
},
|
|
537
|
+
},
|
|
538
|
+
});
|
|
539
|
+
console.log(response);
|
|
540
|
+
|
|
508
541
|
// Example: get a job
|
|
509
542
|
const response = await courier.bulk.getJob({
|
|
510
543
|
jobId: "1-61efe386-6ff57552409e311b7a1f371f",
|
|
511
544
|
});
|
|
512
545
|
console.log(response);
|
|
513
546
|
|
|
514
|
-
// Example: Ingest users in a job
|
|
547
|
+
// Example: Ingest users in a job (API v1 semantics)
|
|
515
548
|
const response = await courier.bulk.ingestUsers({
|
|
516
549
|
jobId: "1-61efe386-6ff57552409e311b7a1f371f",
|
|
517
550
|
users: [
|
|
@@ -524,6 +557,19 @@ async function run() {
|
|
|
524
557
|
});
|
|
525
558
|
console.log(response);
|
|
526
559
|
|
|
560
|
+
// Example: Ingest users in a job (API v2 semantics)
|
|
561
|
+
const response = await courier.bulk.ingestUsers({
|
|
562
|
+
jobId: "1-61efe386-6ff57552409e311b7a1f371f",
|
|
563
|
+
users: [
|
|
564
|
+
{
|
|
565
|
+
to: {
|
|
566
|
+
email: "tejas@courier.com",
|
|
567
|
+
},
|
|
568
|
+
},
|
|
569
|
+
],
|
|
570
|
+
});
|
|
571
|
+
console.log(response);
|
|
572
|
+
|
|
527
573
|
// Example: Run a job
|
|
528
574
|
await courier.bulk.runJob({
|
|
529
575
|
jobId: "1-61efe386-6ff57552409e311b7a1f371f",
|
package/lib/bulk/types.d.ts
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { IRecipientPreferences } from "../preferences/types";
|
|
2
|
-
|
|
2
|
+
import { Message, UserRecipient } from "../send/types";
|
|
3
|
+
interface IInboundBulkMessageApiV1 {
|
|
3
4
|
brand?: string;
|
|
4
5
|
data?: object;
|
|
5
6
|
event: string;
|
|
6
7
|
locale?: string;
|
|
7
8
|
override?: object;
|
|
8
9
|
}
|
|
10
|
+
declare type InboundBulkMessageApiV2 = Omit<Message, "to">;
|
|
11
|
+
export interface IInboundBulkMessage extends IInboundBulkMessageApiV1 {
|
|
12
|
+
message?: InboundBulkMessageApiV2;
|
|
13
|
+
}
|
|
14
|
+
export declare type InboundBulkMessage = IInboundBulkMessage;
|
|
9
15
|
export interface ICourierBulkConfig {
|
|
10
16
|
idempotencyKey?: string;
|
|
11
17
|
idempotencyExpiry?: number;
|
|
@@ -21,6 +27,7 @@ export interface IInboundBulkMessageUser {
|
|
|
21
27
|
profile?: object;
|
|
22
28
|
recipient?: string;
|
|
23
29
|
data?: object;
|
|
30
|
+
to?: UserRecipient;
|
|
24
31
|
}
|
|
25
32
|
export declare type InboundBulkMessageUser = IInboundBulkMessageUser;
|
|
26
33
|
export interface ICourierBulkIngestUsersParams {
|
|
@@ -74,3 +81,4 @@ export interface ICourierClientBulk {
|
|
|
74
81
|
getJob: (params: ICourierBulkGetJobParams) => Promise<ICourierBulkGetJobResponse>;
|
|
75
82
|
getJobUsers: (params: ICourierBulkGetJobUsersParams) => Promise<ICourierBulkGetJobUsersResponse>;
|
|
76
83
|
}
|
|
84
|
+
export {};
|
package/lib/client.js
CHANGED
|
@@ -98,8 +98,8 @@ var getMessages = function (options) {
|
|
|
98
98
|
notification: params === null || params === void 0 ? void 0 : params.notificationId,
|
|
99
99
|
recipient: params === null || params === void 0 ? void 0 : params.recipientId,
|
|
100
100
|
status: params === null || params === void 0 ? void 0 : params.status,
|
|
101
|
-
tags: params === null || params === void 0 ? void 0 : params.tags
|
|
102
|
-
}
|
|
101
|
+
tags: params === null || params === void 0 ? void 0 : params.tags
|
|
102
|
+
}
|
|
103
103
|
})];
|
|
104
104
|
case 1:
|
|
105
105
|
res = _a.sent();
|
package/lib/send/types.d.ts
CHANGED
|
@@ -236,13 +236,23 @@ export interface ElementalContentSugar {
|
|
|
236
236
|
body?: string;
|
|
237
237
|
title?: string;
|
|
238
238
|
}
|
|
239
|
+
export interface Timeout {
|
|
240
|
+
provider?: number;
|
|
241
|
+
channel?: number;
|
|
242
|
+
message?: number;
|
|
243
|
+
escalation?: number;
|
|
244
|
+
criteria?: "no-escalation" | "delivered" | "viewed" | "engaged";
|
|
245
|
+
}
|
|
239
246
|
export declare type Content = ElementalContentSugar | ElementalContent;
|
|
240
247
|
export interface BaseMessage {
|
|
241
|
-
|
|
242
|
-
data?: MessageData;
|
|
248
|
+
brand_id?: string;
|
|
243
249
|
channels?: MessageChannels;
|
|
250
|
+
data?: MessageData;
|
|
251
|
+
metadata?: MessageMetadata;
|
|
244
252
|
providers?: MessageProviders;
|
|
245
253
|
routing?: Routing;
|
|
254
|
+
timeout?: Timeout;
|
|
255
|
+
to: MessageRecipient;
|
|
246
256
|
}
|
|
247
257
|
interface TrackingOverride {
|
|
248
258
|
open: boolean;
|
|
@@ -316,19 +326,21 @@ export interface RoutingStrategyProvider<T = Record<string, any>> {
|
|
|
316
326
|
config?: T;
|
|
317
327
|
if?: string;
|
|
318
328
|
}
|
|
319
|
-
export interface
|
|
320
|
-
tags?: [string?, string?, string?, string?, string?, string?, string?, string?, string?];
|
|
321
|
-
}
|
|
322
|
-
export interface ContentMessageMetadata extends BaseMessageMetadata {
|
|
329
|
+
export interface MessageMetadata {
|
|
323
330
|
event?: string;
|
|
331
|
+
tags?: string[];
|
|
332
|
+
utm?: {
|
|
333
|
+
source?: string;
|
|
334
|
+
medium?: string;
|
|
335
|
+
campaign?: string;
|
|
336
|
+
term?: string;
|
|
337
|
+
content?: string;
|
|
338
|
+
};
|
|
324
339
|
}
|
|
325
340
|
export interface ContentMessage extends BaseMessage {
|
|
326
341
|
content: Content;
|
|
327
|
-
metadata?: ContentMessageMetadata;
|
|
328
342
|
}
|
|
329
343
|
export interface TemplateMessage extends BaseMessage {
|
|
330
|
-
brand?: string;
|
|
331
|
-
metadata?: BaseMessageMetadata;
|
|
332
344
|
template: string;
|
|
333
345
|
}
|
|
334
346
|
export declare type Message = ContentMessage | TemplateMessage;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trycourier/courier",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.10.0",
|
|
4
4
|
"description": "A node.js module for communicating with the Courier REST API.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -33,4 +33,4 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"axios": "^0.21.1"
|
|
35
35
|
}
|
|
36
|
-
}
|
|
36
|
+
}
|