@trycourier/courier 3.6.0 → 3.9.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 CHANGED
@@ -5,9 +5,22 @@ This project adheres to [Semantic Versioning](http://semver.org/).
5
5
 
6
6
  ## [Unreleased][unreleased]
7
7
 
8
+ ## [3.9.0] - 2022-03-17
9
+
10
+ - adds support for bulk messaging API v2 support
11
+
12
+ ## [3.8.0] - 2022-03-14
13
+
14
+ - adds additional types for utm property (`message.metadata.utm`)
15
+
16
+ ## [v3.7.0] - 2022-03-11
17
+
18
+ - adds additional types for the tags property (`message.metadata.tags`)
19
+ - adds support for searching message by tags
20
+
8
21
  ## [v3.6.0] - 2022-02-10
9
22
 
10
- - adds additional type's for the recipient property (`message.to`)
23
+ - adds additional types for the recipient property (`message.to`)
11
24
 
12
25
  ## [v3.5.0] - 2022-02-10
13
26
 
@@ -205,7 +218,11 @@ This project adheres to [Semantic Versioning](http://semver.org/).
205
218
 
206
219
  ## v1.0.1 - 2019-07-12
207
220
 
208
- [unreleased]: https://github.com/trycourier/courier-node/compare/v3.5.0...HEAD
221
+ [unreleased]: https://github.com/trycourier/courier-node/compare/v3.9.0...HEAD
222
+ [v3.9.0]: https://github.com/trycourier/courier-node/compare/v3.8.0...v3.9.0
223
+ [v3.8.0]: https://github.com/trycourier/courier-node/compare/v3.7.0...v3.8.0
224
+ [v3.7.0]: https://github.com/trycourier/courier-node/compare/v3.6.0...v3.7.0
225
+ [v3.6.0]: https://github.com/trycourier/courier-node/compare/v3.5.0...v3.6.0
209
226
  [v3.5.0]: https://github.com/trycourier/courier-node/compare/v3.4.0...v3.5.0
210
227
  [v3.4.0]: https://github.com/trycourier/courier-node/compare/v3.3.0...v3.4.0
211
228
  [v3.3.0]: https://github.com/trycourier/courier-node/compare/v3.2.1...v3.3.0
package/README.md CHANGED
@@ -497,7 +497,7 @@ async function run() {
497
497
  await courier.notifications.cancelSubmission("notification1", "submission1");
498
498
 
499
499
  // Bulk Processing
500
- // Example: create a job
500
+ // Example: create a job (API v1 semantics)
501
501
  const response = await courier.bulk.createJob({
502
502
  message: {
503
503
  event: "RR4NDQ7NZ24A8TKPWVBEDGE15E9A",
@@ -505,13 +505,23 @@ async function run() {
505
505
  });
506
506
  console.log(response);
507
507
 
508
+ // Example: create a job (API v2 semantics)
509
+ const response = await courier.bulk.createJob({
510
+ message: {
511
+ message: {
512
+ template: "RR4NDQ7NZ24A8TKPWVBEDGE15E9A",
513
+ },
514
+ },
515
+ });
516
+ console.log(response);
517
+
508
518
  // Example: get a job
509
519
  const response = await courier.bulk.getJob({
510
520
  jobId: "1-61efe386-6ff57552409e311b7a1f371f",
511
521
  });
512
522
  console.log(response);
513
523
 
514
- // Example: Ingest users in a job
524
+ // Example: Ingest users in a job (API v1 semantics)
515
525
  const response = await courier.bulk.ingestUsers({
516
526
  jobId: "1-61efe386-6ff57552409e311b7a1f371f",
517
527
  users: [
@@ -524,6 +534,19 @@ async function run() {
524
534
  });
525
535
  console.log(response);
526
536
 
537
+ // Example: Ingest users in a job (API v2 semantics)
538
+ const response = await courier.bulk.ingestUsers({
539
+ jobId: "1-61efe386-6ff57552409e311b7a1f371f",
540
+ users: [
541
+ {
542
+ to: {
543
+ email: "tejas@courier.com",
544
+ },
545
+ },
546
+ ],
547
+ });
548
+ console.log(response);
549
+
527
550
  // Example: Run a job
528
551
  await courier.bulk.runJob({
529
552
  jobId: "1-61efe386-6ff57552409e311b7a1f371f",
@@ -1,11 +1,17 @@
1
1
  import { IRecipientPreferences } from "../preferences/types";
2
- export interface IInboundBulkMessage {
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
@@ -97,7 +97,8 @@ var getMessages = function (options) {
97
97
  messageId: params === null || params === void 0 ? void 0 : params.messageId,
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
- status: params === null || params === void 0 ? void 0 : params.status
100
+ status: params === null || params === void 0 ? void 0 : params.status,
101
+ tags: params === null || params === void 0 ? void 0 : params.tags
101
102
  }
102
103
  })];
103
104
  case 1:
@@ -238,11 +238,12 @@ export interface ElementalContentSugar {
238
238
  }
239
239
  export declare type Content = ElementalContentSugar | ElementalContent;
240
240
  export interface BaseMessage {
241
- to: MessageRecipient;
242
- data?: MessageData;
243
241
  channels?: MessageChannels;
242
+ data?: MessageData;
243
+ metadata?: MessageMetadata;
244
244
  providers?: MessageProviders;
245
245
  routing?: Routing;
246
+ to: MessageRecipient;
246
247
  }
247
248
  interface TrackingOverride {
248
249
  open: boolean;
@@ -316,15 +317,21 @@ export interface RoutingStrategyProvider<T = Record<string, any>> {
316
317
  config?: T;
317
318
  if?: string;
318
319
  }
319
- export interface ContentMessageMetadata {
320
+ export interface MessageMetadata {
320
321
  event?: string;
322
+ tags?: string[];
323
+ utm?: {
324
+ source?: string;
325
+ medium?: string;
326
+ campaign?: string;
327
+ term?: string;
328
+ content?: string;
329
+ };
321
330
  }
322
331
  export interface ContentMessage extends BaseMessage {
323
332
  content: Content;
324
- metadata?: ContentMessageMetadata;
325
333
  }
326
334
  export interface TemplateMessage extends BaseMessage {
327
- brand?: string;
328
335
  template: string;
329
336
  }
330
337
  export declare type Message = ContentMessage | TemplateMessage;
package/lib/types.d.ts CHANGED
@@ -96,6 +96,7 @@ export interface ICourierMessagesGetParameters {
96
96
  notificationId?: string;
97
97
  recipientId?: string;
98
98
  status?: string | string[];
99
+ tags?: string | string[];
99
100
  }
100
101
  export interface ICourierMessagesGetResponse {
101
102
  paging: ICourierPaging;
@@ -107,6 +108,7 @@ export interface ICourierMessagesGetResponse {
107
108
  recipient: string;
108
109
  sent?: number;
109
110
  status: string;
111
+ tags?: string[];
110
112
  }>;
111
113
  }
112
114
  export interface ICourierMessageGetResponse {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trycourier/courier",
3
- "version": "3.6.0",
3
+ "version": "3.9.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",