@trycourier/courier 4.9.0 → 5.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/lib/client.js +5 -5
- package/lib/send/types.d.ts +6 -0
- package/lib/tenants/index.d.ts +8 -0
- package/lib/{accounts → tenants}/index.js +18 -18
- package/lib/{accounts → tenants}/types.d.ts +8 -8
- package/lib/types.d.ts +2 -2
- package/package.json +1 -1
- package/lib/accounts/index.d.ts +0 -8
- /package/lib/{accounts → tenants}/types.js +0 -0
package/lib/client.js
CHANGED
|
@@ -37,7 +37,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.client = void 0;
|
|
40
|
-
var accounts_1 = require("./accounts");
|
|
41
40
|
var audiences_1 = require("./audiences");
|
|
42
41
|
var audit_events_1 = require("./audit-events");
|
|
43
42
|
var automations_1 = require("./automations");
|
|
@@ -48,6 +47,7 @@ var notifications_1 = require("./notifications");
|
|
|
48
47
|
var preferences_1 = require("./preferences");
|
|
49
48
|
var profile_1 = require("./profile");
|
|
50
49
|
var send_1 = require("./send");
|
|
50
|
+
var tenants_1 = require("./tenants");
|
|
51
51
|
var token_management_1 = require("./token-management");
|
|
52
52
|
var users_1 = require("./users");
|
|
53
53
|
var cancelMessage = function (options) {
|
|
@@ -116,8 +116,8 @@ var getMessages = function (options) {
|
|
|
116
116
|
notification: params === null || params === void 0 ? void 0 : params.notificationId,
|
|
117
117
|
recipient: params === null || params === void 0 ? void 0 : params.recipientId,
|
|
118
118
|
status: params === null || params === void 0 ? void 0 : params.status,
|
|
119
|
-
tags: params === null || params === void 0 ? void 0 : params.tags
|
|
120
|
-
}
|
|
119
|
+
tags: params === null || params === void 0 ? void 0 : params.tags,
|
|
120
|
+
},
|
|
121
121
|
})];
|
|
122
122
|
case 1:
|
|
123
123
|
res = _a.sent();
|
|
@@ -128,7 +128,6 @@ var getMessages = function (options) {
|
|
|
128
128
|
};
|
|
129
129
|
exports.client = function (options) {
|
|
130
130
|
return {
|
|
131
|
-
accounts: accounts_1.accounts(options),
|
|
132
131
|
addRecipientToLists: profile_1.addRecipientToLists(options),
|
|
133
132
|
audiences: audiences_1.audiences(options),
|
|
134
133
|
auditEvents: audit_events_1.auditEvents(options),
|
|
@@ -154,7 +153,8 @@ exports.client = function (options) {
|
|
|
154
153
|
replaceBrand: brands_1.replaceBrand(options),
|
|
155
154
|
replaceProfile: profile_1.replaceProfile(options),
|
|
156
155
|
send: send_1.send(options),
|
|
156
|
+
tenants: tenants_1.tenants(options),
|
|
157
157
|
tokenManagement: token_management_1.tokenManagement(options),
|
|
158
|
-
users: users_1.users(options)
|
|
158
|
+
users: users_1.users(options),
|
|
159
159
|
};
|
|
160
160
|
};
|
package/lib/send/types.d.ts
CHANGED
|
@@ -164,6 +164,9 @@ interface ElementalBaseNode {
|
|
|
164
164
|
if?: string;
|
|
165
165
|
loop?: string;
|
|
166
166
|
}
|
|
167
|
+
export interface MessageContext {
|
|
168
|
+
tenant_id?: string;
|
|
169
|
+
}
|
|
167
170
|
export interface MessageData extends Record<string, any> {
|
|
168
171
|
}
|
|
169
172
|
export declare type RuleType = "snooze" | "channel_preferences" | "status";
|
|
@@ -240,12 +243,14 @@ export interface AudienceRecipient {
|
|
|
240
243
|
}
|
|
241
244
|
export interface UserRecipient extends UserRecipientType {
|
|
242
245
|
account_id?: string;
|
|
246
|
+
context?: MessageContext;
|
|
243
247
|
data?: MessageData;
|
|
244
248
|
email?: string;
|
|
245
249
|
locale?: string;
|
|
246
250
|
user_id?: string;
|
|
247
251
|
phone_number?: string;
|
|
248
252
|
preferences?: IProfilePreferences;
|
|
253
|
+
tenant_id?: string;
|
|
249
254
|
}
|
|
250
255
|
export declare type Recipient = AudienceRecipient | ListRecipient | ListPatternRecipient | UserRecipient;
|
|
251
256
|
export declare type MessageRecipient = Recipient | Recipient[];
|
|
@@ -268,6 +273,7 @@ export declare type Content = ElementalContentSugar | ElementalContent;
|
|
|
268
273
|
export interface BaseMessage {
|
|
269
274
|
brand_id?: string;
|
|
270
275
|
channels?: MessageChannels;
|
|
276
|
+
context?: MessageContext;
|
|
271
277
|
data?: MessageData;
|
|
272
278
|
metadata?: MessageMetadata;
|
|
273
279
|
providers?: MessageProviders;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ICourierClientConfiguration } from "../types";
|
|
2
|
+
import * as TenantTypes from "./types";
|
|
3
|
+
export declare const tenants: (options: ICourierClientConfiguration) => {
|
|
4
|
+
delete: (tenantId: string) => Promise<void>;
|
|
5
|
+
get: (tenantId: string) => Promise<TenantTypes.ITenant>;
|
|
6
|
+
listTenants: (listOptions?: TenantTypes.ITenantListOptions | undefined) => Promise<TenantTypes.IPaginatedResult<TenantTypes.ITenant>>;
|
|
7
|
+
put: (tenant: Omit<TenantTypes.ITenant, "type">) => Promise<TenantTypes.ITenant>;
|
|
8
|
+
};
|
|
@@ -36,23 +36,23 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.
|
|
40
|
-
var
|
|
39
|
+
exports.tenants = void 0;
|
|
40
|
+
var deleteTenant = function (options) { return function (tenantId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
41
41
|
return __generator(this, function (_a) {
|
|
42
42
|
switch (_a.label) {
|
|
43
|
-
case 0: return [4 /*yield*/, options.httpClient.delete("/
|
|
43
|
+
case 0: return [4 /*yield*/, options.httpClient.delete("/tenants/" + tenantId)];
|
|
44
44
|
case 1:
|
|
45
45
|
_a.sent();
|
|
46
46
|
return [2 /*return*/];
|
|
47
47
|
}
|
|
48
48
|
});
|
|
49
49
|
}); }; };
|
|
50
|
-
var
|
|
51
|
-
return function (
|
|
50
|
+
var getTenant = function (options) {
|
|
51
|
+
return function (tenantId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
52
52
|
var response;
|
|
53
53
|
return __generator(this, function (_a) {
|
|
54
54
|
switch (_a.label) {
|
|
55
|
-
case 0: return [4 /*yield*/, options.httpClient.get("/
|
|
55
|
+
case 0: return [4 /*yield*/, options.httpClient.get("/tenants/" + tenantId)];
|
|
56
56
|
case 1:
|
|
57
57
|
response = _a.sent();
|
|
58
58
|
return [2 /*return*/, response.data];
|
|
@@ -60,16 +60,16 @@ var getAccount = function (options) {
|
|
|
60
60
|
});
|
|
61
61
|
}); };
|
|
62
62
|
};
|
|
63
|
-
var
|
|
63
|
+
var listTenants = function (options) {
|
|
64
64
|
return function (listOptions) { return __awaiter(void 0, void 0, void 0, function () {
|
|
65
65
|
var response;
|
|
66
66
|
return __generator(this, function (_a) {
|
|
67
67
|
switch (_a.label) {
|
|
68
|
-
case 0: return [4 /*yield*/, options.httpClient.get("/
|
|
68
|
+
case 0: return [4 /*yield*/, options.httpClient.get("/tenants", undefined, {
|
|
69
69
|
params: {
|
|
70
70
|
cursor: (listOptions === null || listOptions === void 0 ? void 0 : listOptions.cursor) || "",
|
|
71
|
-
limit: (listOptions === null || listOptions === void 0 ? void 0 : listOptions.limit) || "20"
|
|
72
|
-
}
|
|
71
|
+
limit: (listOptions === null || listOptions === void 0 ? void 0 : listOptions.limit) || "20",
|
|
72
|
+
},
|
|
73
73
|
})];
|
|
74
74
|
case 1:
|
|
75
75
|
response = _a.sent();
|
|
@@ -78,12 +78,12 @@ var listAccounts = function (options) {
|
|
|
78
78
|
});
|
|
79
79
|
}); };
|
|
80
80
|
};
|
|
81
|
-
var
|
|
82
|
-
return function (
|
|
81
|
+
var putTenant = function (options) {
|
|
82
|
+
return function (tenant) { return __awaiter(void 0, void 0, void 0, function () {
|
|
83
83
|
var response;
|
|
84
84
|
return __generator(this, function (_a) {
|
|
85
85
|
switch (_a.label) {
|
|
86
|
-
case 0: return [4 /*yield*/, options.httpClient.put("/
|
|
86
|
+
case 0: return [4 /*yield*/, options.httpClient.put("/tenants/" + tenant.id, tenant)];
|
|
87
87
|
case 1:
|
|
88
88
|
response = _a.sent();
|
|
89
89
|
return [2 /*return*/, response.data];
|
|
@@ -91,9 +91,9 @@ var putAccount = function (options) {
|
|
|
91
91
|
});
|
|
92
92
|
}); };
|
|
93
93
|
};
|
|
94
|
-
exports.
|
|
95
|
-
delete:
|
|
96
|
-
get:
|
|
97
|
-
|
|
98
|
-
put:
|
|
94
|
+
exports.tenants = function (options) { return ({
|
|
95
|
+
delete: deleteTenant(options),
|
|
96
|
+
get: getTenant(options),
|
|
97
|
+
listTenants: listTenants(options),
|
|
98
|
+
put: putTenant(options),
|
|
99
99
|
}); };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface ITenant {
|
|
2
2
|
brand_id?: string;
|
|
3
3
|
id: string;
|
|
4
4
|
name: string;
|
|
5
|
-
|
|
5
|
+
parent_tenant_id?: string;
|
|
6
6
|
default_preferences?: {
|
|
7
7
|
items: Array<{
|
|
8
8
|
id: string;
|
|
@@ -14,7 +14,7 @@ export interface IAccount {
|
|
|
14
14
|
[key: string]: any;
|
|
15
15
|
};
|
|
16
16
|
user_profile?: Record<string, any>;
|
|
17
|
-
type: "
|
|
17
|
+
type: "tenant";
|
|
18
18
|
}
|
|
19
19
|
export interface IPaginatedResult<T> {
|
|
20
20
|
cursor?: string;
|
|
@@ -24,13 +24,13 @@ export interface IPaginatedResult<T> {
|
|
|
24
24
|
type: "list";
|
|
25
25
|
url: string;
|
|
26
26
|
}
|
|
27
|
-
export interface
|
|
27
|
+
export interface ITenantListOptions {
|
|
28
28
|
cursor?: string;
|
|
29
29
|
limit?: string;
|
|
30
30
|
}
|
|
31
|
-
export interface
|
|
31
|
+
export interface ICourierClientTenants {
|
|
32
32
|
delete: (id: string) => Promise<void>;
|
|
33
|
-
get: (id: string) => Promise<
|
|
34
|
-
|
|
35
|
-
put: (
|
|
33
|
+
get: (id: string) => Promise<ITenant>;
|
|
34
|
+
listTenants: (options?: ITenantListOptions) => Promise<IPaginatedResult<ITenant>>;
|
|
35
|
+
put: (tenant: Omit<ITenant, "type">) => Promise<ITenant>;
|
|
36
36
|
}
|
package/lib/types.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ICourierClientAccounts } from "./accounts/types";
|
|
2
1
|
import { ICourierClientAudiences } from "./audiences/types";
|
|
3
2
|
import { auditEvents } from "./audit-events";
|
|
4
3
|
import { ICourierClientAutomations } from "./automations/types";
|
|
@@ -7,6 +6,7 @@ import { ICourierClientLists, ICourierList, ICourierRecipientSubscriptionsRespon
|
|
|
7
6
|
import { ICourierClientNotifications } from "./notifications/types";
|
|
8
7
|
import { ICourierClientPreferences, IRecipientPreferences } from "./preferences/types";
|
|
9
8
|
import { Message } from "./send/types";
|
|
9
|
+
import { ICourierClientTenants } from "./tenants/types";
|
|
10
10
|
import { tokenManagement } from "./token-management";
|
|
11
11
|
import { users } from "./users";
|
|
12
12
|
export interface IInitHttpClientOptions {
|
|
@@ -319,7 +319,7 @@ export interface ICourierBrandGetAllResponse {
|
|
|
319
319
|
export declare type SendResponse<T extends ICourierSendParameters | ICourierSendMessageParameters> = T extends ICourierSendParameters ? ICourierSendResponse : ICourierSendMessageResponse;
|
|
320
320
|
export interface ICourierClient {
|
|
321
321
|
addRecipientToLists: (params: ICourierProfileListsPostParameters) => Promise<ICourierProfilePostResponse>;
|
|
322
|
-
|
|
322
|
+
tenants: ICourierClientTenants;
|
|
323
323
|
audiences: ICourierClientAudiences;
|
|
324
324
|
auditEvents: ReturnType<typeof auditEvents>;
|
|
325
325
|
automations: ICourierClientAutomations;
|
package/package.json
CHANGED
package/lib/accounts/index.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ICourierClientConfiguration } from "../types";
|
|
2
|
-
import * as AccountTypes from "./types";
|
|
3
|
-
export declare const accounts: (options: ICourierClientConfiguration) => {
|
|
4
|
-
delete: (accountId: string) => Promise<void>;
|
|
5
|
-
get: (accountId: string) => Promise<AccountTypes.IAccount>;
|
|
6
|
-
listAccounts: (listOptions?: AccountTypes.IAccountListOptions | undefined) => Promise<AccountTypes.IPaginatedResult<AccountTypes.IAccount>>;
|
|
7
|
-
put: (account: Omit<AccountTypes.IAccount, "type">) => Promise<AccountTypes.IAccount>;
|
|
8
|
-
};
|
|
File without changes
|