@trycourier/courier 2.8.0 → 3.2.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/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.1] - 2022-01-13
9
+
10
+ - Fixes `getMessages` query params
11
+
12
+ ## [v3.2.0] - 2021-11-18
13
+
14
+ - adds idempotency expiration support for send and send list endpoints
15
+
16
+ ## [v3.1.0] - 2021-11-16
17
+
18
+ - Expose additional type definitions for `getMessage`
19
+
20
+ ## [v3.0.0] - 2021-11-02
21
+
22
+ - fixes type definition for `getRecipientSubscriptions`
23
+
8
24
  ## [v2.8.0] - 2021-10-29
9
25
 
10
26
  - adds GET /messages/{messageId}/output API
@@ -173,7 +189,11 @@ This project adheres to [Semantic Versioning](http://semver.org/).
173
189
 
174
190
  ## v1.0.1 - 2019-07-12
175
191
 
176
- [unreleased]: https://github.com/trycourier/courier-node/compare/v2.8.0...HEAD
192
+ [unreleased]: https://github.com/trycourier/courier-node/compare/v3.2.1...HEAD
193
+ [v3.2.1]: https://github.com/trycourier/courier-node/compare/v3.2.0...v3.2.1
194
+ [v3.2.0]: https://github.com/trycourier/courier-node/compare/v3.1.0...v3.2.0
195
+ [v3.1.0]: https://github.com/trycourier/courier-node/compare/v3.0.0...v3.1.0
196
+ [v3.0.0]: https://github.com/trycourier/courier-node/compare/v2.8.0...v3.0.0
177
197
  [v2.8.0]: https://github.com/trycourier/courier-node/compare/v2.7.0...v2.8.0
178
198
  [v2.7.0]: https://github.com/trycourier/courier-node/compare/v2.6.0...v2.7.0
179
199
  [v2.6.0]: https://github.com/trycourier/courier-node/compare/v2.4.0...v2.6.0
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,
@@ -116,13 +120,15 @@ var getMessages = function (options) {
116
120
  return __generator(this, function (_a) {
117
121
  switch (_a.label) {
118
122
  case 0: return [4 /*yield*/, options.httpClient.get("/messages", {
119
- cursor: params === null || params === void 0 ? void 0 : params.cursor,
120
- event: params === null || params === void 0 ? void 0 : params.eventId,
121
- list: params === null || params === void 0 ? void 0 : params.listId,
122
- messageId: params === null || params === void 0 ? void 0 : params.messageId,
123
- notification: params === null || params === void 0 ? void 0 : params.notificationId,
124
- recipient: params === null || params === void 0 ? void 0 : params.recipientId,
125
- status: params === null || params === void 0 ? void 0 : params.status
123
+ params: {
124
+ cursor: params === null || params === void 0 ? void 0 : params.cursor,
125
+ event: params === null || params === void 0 ? void 0 : params.eventId,
126
+ list: params === null || params === void 0 ? void 0 : params.listId,
127
+ messageId: params === null || params === void 0 ? void 0 : params.messageId,
128
+ notification: params === null || params === void 0 ? void 0 : params.notificationId,
129
+ recipient: params === null || params === void 0 ? void 0 : params.recipientId,
130
+ status: params === null || params === void 0 ? void 0 : params.status
131
+ }
126
132
  })];
127
133
  case 1:
128
134
  res = _a.sent();
@@ -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();
@@ -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 { ICourierList } from "./lists/types";
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<ICourierList[]>;
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
- name: string;
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
- "x-message-id": string;
126
+ reference?: {
127
+ [key: string]: string | number;
116
128
  };
117
129
  sent: number;
118
- status: string;
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: string;
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";
@@ -269,7 +285,7 @@ export interface ICourierClient {
269
285
  getMessages: (params?: ICourierMessagesGetParameters) => Promise<ICourierMessagesGetResponse>;
270
286
  getProfile: (params: ICourierProfileGetParameters) => Promise<ICourierProfileGetResponse>;
271
287
  deleteProfile: (params: ICourierProfileDeleteParameters) => Promise<void>;
272
- getRecipientSubscriptions: (params: ICourierProfileGetParameters) => Promise<ICourierList[]>;
288
+ getRecipientSubscriptions: (params: ICourierProfileGetParameters) => Promise<ICourierRecipientSubscriptionsResponse>;
273
289
  lists: ICourierClientLists;
274
290
  mergeProfile: (params: ICourierProfilePostParameters, config?: ICourierProfilePostConfig) => Promise<ICourierProfilePostResponse>;
275
291
  notifications: ICourierClientNotifications;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trycourier/courier",
3
- "version": "2.8.0",
3
+ "version": "3.2.1",
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",