@knocklabs/node 0.4.3 → 0.4.6
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/dist/package.json +1 -1
- package/dist/src/resources/messages/index.d.ts +1 -1
- package/dist/src/resources/objects/index.d.ts +16 -1
- package/dist/src/resources/objects/index.js +80 -0
- package/dist/src/resources/users/index.d.ts +5 -0
- package/dist/src/resources/users/index.js +17 -0
- package/dist/src/resources/workflows/interfaces.d.ts +4 -2
- package/package.json +1 -1
package/dist/package.json
CHANGED
|
@@ -5,7 +5,7 @@ import { Knock } from "../../knock";
|
|
|
5
5
|
export declare class Messages {
|
|
6
6
|
readonly knock: Knock;
|
|
7
7
|
constructor(knock: Knock);
|
|
8
|
-
list(filteringOptions?: ListMessagesOptions): Promise<Message
|
|
8
|
+
list(filteringOptions?: ListMessagesOptions): Promise<PaginatedResponse<Message>>;
|
|
9
9
|
get(messageId: string): Promise<Message>;
|
|
10
10
|
getContent(messageId: string): Promise<MessageContent>;
|
|
11
11
|
getEvents(messageId: string, paginationOptions?: PaginationOptions): Promise<PaginatedResponse<MessageEvent>>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { ChannelData, CommonMetadata, SetChannelDataProperties, PaginatedResponse } from "../../common/interfaces";
|
|
1
|
+
import { ChannelData, CommonMetadata, SetChannelDataProperties, PaginatedResponse, ChannelType } from "../../common/interfaces";
|
|
2
2
|
import { Knock } from "../../knock";
|
|
3
3
|
import { BulkSetObjectOption, Object, SetObjectProperties } from "./interfaces";
|
|
4
4
|
import { BulkOperation } from "../bulk_operations/interfaces";
|
|
5
5
|
import { ListMessagesOptions, Message } from "../messages/interfaces";
|
|
6
|
+
import { ChannelTypePreferences, PreferenceOptions, PreferenceSet, SetPreferencesProperties, WorkflowPreferences, WorkflowPreferenceSetting } from "../preferences/interfaces";
|
|
6
7
|
export declare class Objects {
|
|
7
8
|
readonly knock: Knock;
|
|
8
9
|
constructor(knock: Knock);
|
|
@@ -13,5 +14,19 @@ export declare class Objects {
|
|
|
13
14
|
bulkDelete(collection: string, objectIds: string[]): Promise<BulkOperation>;
|
|
14
15
|
getChannelData<T = CommonMetadata>(collection: string, id: string, channelId: string): Promise<ChannelData<T>>;
|
|
15
16
|
setChannelData<T = CommonMetadata>(collection: string, id: string, channelId: string, channelData: SetChannelDataProperties): Promise<ChannelData<T>>;
|
|
17
|
+
unsetChannelData(collection: string, id: string, channelId: string): Promise<any>;
|
|
16
18
|
getMessages(collection: string, objectId: string, filteringOptions?: ListMessagesOptions): Promise<PaginatedResponse<Message>>;
|
|
19
|
+
getAllPreferences(collection: string, objectId: string): Promise<PreferenceSet[]>;
|
|
20
|
+
/**
|
|
21
|
+
* @deprecated Use `objects.getPreferences` instead
|
|
22
|
+
*/
|
|
23
|
+
getPrefences(collection: string, objectId: string, options?: PreferenceOptions): Promise<PreferenceSet>;
|
|
24
|
+
getPreferences(collection: string, objectId: string, options?: PreferenceOptions): Promise<PreferenceSet>;
|
|
25
|
+
setPreferences(collection: string, objectId: string, preferenceSet: SetPreferencesProperties, options?: PreferenceOptions): Promise<PreferenceSet>;
|
|
26
|
+
setChannelTypesPreferences(collection: string, objectId: string, channelTypePreferences: ChannelTypePreferences, options?: PreferenceOptions): Promise<PreferenceSet>;
|
|
27
|
+
setChannelTypePreferences(collection: string, objectId: string, channelType: ChannelType, setting: boolean, options?: PreferenceOptions): Promise<PreferenceSet>;
|
|
28
|
+
setWorkflowsPreferences(collection: string, objectId: string, workflowPreferences: WorkflowPreferences, options?: PreferenceOptions): Promise<PreferenceSet>;
|
|
29
|
+
setWorkflowPreferences(collection: string, objectId: string, workflowKey: string, setting: WorkflowPreferenceSetting, options?: PreferenceOptions): Promise<PreferenceSet>;
|
|
30
|
+
setCategoriesPreferences(collection: string, objectId: string, categoryPreferences: WorkflowPreferences, options?: PreferenceOptions): Promise<PreferenceSet>;
|
|
31
|
+
setCategoryPreferences(collection: string, objectId: string, categoryKey: string, setting: WorkflowPreferenceSetting, options?: PreferenceOptions): Promise<PreferenceSet>;
|
|
17
32
|
}
|
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.Objects = void 0;
|
|
13
|
+
const helpers_1 = require("../preferences/helpers");
|
|
13
14
|
class Objects {
|
|
14
15
|
constructor(knock) {
|
|
15
16
|
this.knock = knock;
|
|
@@ -62,6 +63,12 @@ class Objects {
|
|
|
62
63
|
return data;
|
|
63
64
|
});
|
|
64
65
|
}
|
|
66
|
+
unsetChannelData(collection, id, channelId) {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
const { data } = yield this.knock.delete(`/v1/objects/${collection}/${id}/channel_data/${channelId}`);
|
|
69
|
+
return data;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
65
72
|
//
|
|
66
73
|
// Messages
|
|
67
74
|
//
|
|
@@ -74,5 +81,78 @@ class Objects {
|
|
|
74
81
|
return data;
|
|
75
82
|
});
|
|
76
83
|
}
|
|
84
|
+
//
|
|
85
|
+
// Preferences
|
|
86
|
+
//
|
|
87
|
+
getAllPreferences(collection, objectId) {
|
|
88
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
const { data } = yield this.knock.get(`/v1/objects/${collection}/${objectId}/preferences`);
|
|
90
|
+
return data;
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* @deprecated Use `objects.getPreferences` instead
|
|
95
|
+
*/
|
|
96
|
+
getPrefences(collection, objectId, options = {}) {
|
|
97
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
98
|
+
return this.getPreferences(collection, objectId, options);
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
getPreferences(collection, objectId, options = {}) {
|
|
102
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
const preferenceSetId = options.preferenceSet || helpers_1.DEFAULT_PREFERENCE_SET_ID;
|
|
104
|
+
const { data } = yield this.knock.get(`/v1/objects/${collection}/${objectId}/preferences/${preferenceSetId}`);
|
|
105
|
+
return data;
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
setPreferences(collection, objectId, preferenceSet, options = {}) {
|
|
109
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
110
|
+
const preferenceSetId = options.preferenceSet || helpers_1.DEFAULT_PREFERENCE_SET_ID;
|
|
111
|
+
const { data } = yield this.knock.put(`/v1/objects/${collection}/${objectId}/preferences/${preferenceSetId}`, preferenceSet);
|
|
112
|
+
return data;
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
setChannelTypesPreferences(collection, objectId, channelTypePreferences, options = {}) {
|
|
116
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
117
|
+
const preferenceSetId = options.preferenceSet || helpers_1.DEFAULT_PREFERENCE_SET_ID;
|
|
118
|
+
const { data } = yield this.knock.put(`/v1/objects/${collection}/${objectId}/preferences/${preferenceSetId}/channel_types`, channelTypePreferences);
|
|
119
|
+
return data;
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
setChannelTypePreferences(collection, objectId, channelType, setting, options = {}) {
|
|
123
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
124
|
+
const preferenceSetId = options.preferenceSet || helpers_1.DEFAULT_PREFERENCE_SET_ID;
|
|
125
|
+
const { data, } = yield this.knock.put(`/v1/objects/${collection}/${objectId}/preferences/${preferenceSetId}/channel_types/${channelType}`, { subscribed: setting });
|
|
126
|
+
return data;
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
setWorkflowsPreferences(collection, objectId, workflowPreferences, options = {}) {
|
|
130
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
131
|
+
const preferenceSetId = options.preferenceSet || helpers_1.DEFAULT_PREFERENCE_SET_ID;
|
|
132
|
+
const { data } = yield this.knock.put(`/v1/objects/${collection}/${objectId}/preferences/${preferenceSetId}/workflows`, workflowPreferences);
|
|
133
|
+
return data;
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
setWorkflowPreferences(collection, objectId, workflowKey, setting, options = {}) {
|
|
137
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
138
|
+
const preferenceSetId = options.preferenceSet || helpers_1.DEFAULT_PREFERENCE_SET_ID;
|
|
139
|
+
const { data } = yield this.knock.put(`/v1/objects/${collection}/${objectId}/preferences/${preferenceSetId}/workflows/${workflowKey}`, helpers_1.buildUpdateParam(setting));
|
|
140
|
+
return data;
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
setCategoriesPreferences(collection, objectId, categoryPreferences, options = {}) {
|
|
144
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
145
|
+
const preferenceSetId = options.preferenceSet || helpers_1.DEFAULT_PREFERENCE_SET_ID;
|
|
146
|
+
const { data } = yield this.knock.put(`/v1/objects/${collection}/${objectId}/preferences/${preferenceSetId}/categories`, categoryPreferences);
|
|
147
|
+
return data;
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
setCategoryPreferences(collection, objectId, categoryKey, setting, options = {}) {
|
|
151
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
152
|
+
const preferenceSetId = options.preferenceSet || helpers_1.DEFAULT_PREFERENCE_SET_ID;
|
|
153
|
+
const { data } = yield this.knock.put(`/v1/objects/${collection}/${objectId}/preferences/${preferenceSetId}/categories/${categoryKey}`, helpers_1.buildUpdateParam(setting));
|
|
154
|
+
return data;
|
|
155
|
+
});
|
|
156
|
+
}
|
|
77
157
|
}
|
|
78
158
|
exports.Objects = Objects;
|
|
@@ -15,7 +15,11 @@ export declare class Users {
|
|
|
15
15
|
merge(toUserId: string, fromUserId: string): Promise<User>;
|
|
16
16
|
getFeed(userId: string, channelId: string, feedOptions?: UserFeedOptions): Promise<any>;
|
|
17
17
|
getAllPreferences(userId: string): Promise<any>;
|
|
18
|
+
/**
|
|
19
|
+
* @deprecated Use `users.getPreferences` instead
|
|
20
|
+
*/
|
|
18
21
|
getPrefences(userId: string, options?: PreferenceOptions): Promise<PreferenceSet>;
|
|
22
|
+
getPreferences(userId: string, options?: PreferenceOptions): Promise<PreferenceSet>;
|
|
19
23
|
setPreferences(userId: string, preferenceSet: SetPreferencesProperties, options?: PreferenceOptions): Promise<PreferenceSet>;
|
|
20
24
|
bulkSetPreferences(userIds: string[], preferenceSet: SetPreferencesProperties, options?: PreferenceOptions): Promise<BulkOperation>;
|
|
21
25
|
setChannelTypesPreferences(userId: string, channelTypePreferences: ChannelTypePreferences, options?: PreferenceOptions): Promise<PreferenceSet>;
|
|
@@ -26,5 +30,6 @@ export declare class Users {
|
|
|
26
30
|
setCategoryPreferences(userId: string, categoryKey: string, setting: WorkflowPreferenceSetting, options?: PreferenceOptions): Promise<PreferenceSet>;
|
|
27
31
|
getChannelData<T = CommonMetadata>(userId: string, channelId: string): Promise<ChannelData<T>>;
|
|
28
32
|
setChannelData<T = CommonMetadata>(userId: string, channelId: string, channelData: Record<string, any>): Promise<ChannelData<T>>;
|
|
33
|
+
unsetChannelData(userId: string, channelId: string): Promise<any>;
|
|
29
34
|
getMessages(userId: string, filteringOptions?: ListMessagesOptions): Promise<PaginatedResponse<Message>>;
|
|
30
35
|
}
|
|
@@ -88,7 +88,15 @@ class Users {
|
|
|
88
88
|
return data;
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* @deprecated Use `users.getPreferences` instead
|
|
93
|
+
*/
|
|
91
94
|
getPrefences(userId, options = {}) {
|
|
95
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
+
return this.getPreferences(userId, options);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
getPreferences(userId, options = {}) {
|
|
92
100
|
return __awaiter(this, void 0, void 0, function* () {
|
|
93
101
|
const preferenceSetId = options.preferenceSet || helpers_1.DEFAULT_PREFERENCE_SET_ID;
|
|
94
102
|
const { data } = yield this.knock.get(`/v1/users/${userId}/preferences/${preferenceSetId}`);
|
|
@@ -177,6 +185,15 @@ class Users {
|
|
|
177
185
|
return data;
|
|
178
186
|
});
|
|
179
187
|
}
|
|
188
|
+
unsetChannelData(userId, channelId) {
|
|
189
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
190
|
+
if (!userId || !channelId) {
|
|
191
|
+
throw new Error(`Incomplete arguments. You must provide a 'userId' and a 'channelId'`);
|
|
192
|
+
}
|
|
193
|
+
const { data } = yield this.knock.delete(`/v1/users/${userId}/channel_data/${channelId}`);
|
|
194
|
+
return data;
|
|
195
|
+
});
|
|
196
|
+
}
|
|
180
197
|
//
|
|
181
198
|
// Messages
|
|
182
199
|
//
|
|
@@ -2,8 +2,8 @@ import { ObjectRef } from "../objects/interfaces";
|
|
|
2
2
|
export interface TriggerWorkflowProperties<T = {
|
|
3
3
|
[key: string]: any;
|
|
4
4
|
}> {
|
|
5
|
-
actor?:
|
|
6
|
-
recipients?:
|
|
5
|
+
actor?: Actor;
|
|
6
|
+
recipients?: Recipient[];
|
|
7
7
|
cancellationKey?: string;
|
|
8
8
|
tenant?: string;
|
|
9
9
|
data?: T;
|
|
@@ -14,3 +14,5 @@ export interface CancelWorkflowProperties {
|
|
|
14
14
|
export interface WorkflowRun {
|
|
15
15
|
workflow_run_id: string;
|
|
16
16
|
}
|
|
17
|
+
export declare type Recipient = string | ObjectRef;
|
|
18
|
+
export declare type Actor = Recipient;
|