@knocklabs/node 0.4.3 → 0.4.4
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/objects/index.d.ts +12 -1
- package/dist/src/resources/objects/index.js +72 -0
- package/dist/src/resources/users/index.d.ts +1 -0
- package/dist/src/resources/users/index.js +9 -0
- package/dist/src/resources/workflows/interfaces.d.ts +4 -2
- package/package.json +1 -1
package/dist/package.json
CHANGED
|
@@ -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,15 @@ 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
|
+
getPrefences(collection: string, objectId: string, options?: PreferenceOptions): Promise<PreferenceSet>;
|
|
21
|
+
setPreferences(collection: string, objectId: string, preferenceSet: SetPreferencesProperties, options?: PreferenceOptions): Promise<PreferenceSet>;
|
|
22
|
+
setChannelTypesPreferences(collection: string, objectId: string, channelTypePreferences: ChannelTypePreferences, options?: PreferenceOptions): Promise<PreferenceSet>;
|
|
23
|
+
setChannelTypePreferences(collection: string, objectId: string, channelType: ChannelType, setting: boolean, options?: PreferenceOptions): Promise<PreferenceSet>;
|
|
24
|
+
setWorkflowsPreferences(collection: string, objectId: string, workflowPreferences: WorkflowPreferences, options?: PreferenceOptions): Promise<PreferenceSet>;
|
|
25
|
+
setWorkflowPreferences(collection: string, objectId: string, workflowKey: string, setting: WorkflowPreferenceSetting, options?: PreferenceOptions): Promise<PreferenceSet>;
|
|
26
|
+
setCategoriesPreferences(collection: string, objectId: string, categoryPreferences: WorkflowPreferences, options?: PreferenceOptions): Promise<PreferenceSet>;
|
|
27
|
+
setCategoryPreferences(collection: string, objectId: string, categoryKey: string, setting: WorkflowPreferenceSetting, options?: PreferenceOptions): Promise<PreferenceSet>;
|
|
17
28
|
}
|
|
@@ -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,70 @@ 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
|
+
getPrefences(collection, objectId, options = {}) {
|
|
94
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
+
const preferenceSetId = options.preferenceSet || helpers_1.DEFAULT_PREFERENCE_SET_ID;
|
|
96
|
+
const { data } = yield this.knock.get(`/v1/objects/${collection}/${objectId}/preferences/${preferenceSetId}`);
|
|
97
|
+
return data;
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
setPreferences(collection, objectId, preferenceSet, options = {}) {
|
|
101
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
102
|
+
const preferenceSetId = options.preferenceSet || helpers_1.DEFAULT_PREFERENCE_SET_ID;
|
|
103
|
+
const { data } = yield this.knock.put(`/v1/objects/${collection}/${objectId}/preferences/${preferenceSetId}`, preferenceSet);
|
|
104
|
+
return data;
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
setChannelTypesPreferences(collection, objectId, channelTypePreferences, options = {}) {
|
|
108
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
109
|
+
const preferenceSetId = options.preferenceSet || helpers_1.DEFAULT_PREFERENCE_SET_ID;
|
|
110
|
+
const { data } = yield this.knock.put(`/v1/objects/${collection}/${objectId}/preferences/${preferenceSetId}/channel_types`, channelTypePreferences);
|
|
111
|
+
return data;
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
setChannelTypePreferences(collection, objectId, channelType, setting, options = {}) {
|
|
115
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
116
|
+
const preferenceSetId = options.preferenceSet || helpers_1.DEFAULT_PREFERENCE_SET_ID;
|
|
117
|
+
const { data, } = yield this.knock.put(`/v1/objects/${collection}/${objectId}/preferences/${preferenceSetId}/channel_types/${channelType}`, { subscribed: setting });
|
|
118
|
+
return data;
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
setWorkflowsPreferences(collection, objectId, workflowPreferences, options = {}) {
|
|
122
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
123
|
+
const preferenceSetId = options.preferenceSet || helpers_1.DEFAULT_PREFERENCE_SET_ID;
|
|
124
|
+
const { data } = yield this.knock.put(`/v1/objects/${collection}/${objectId}/preferences/${preferenceSetId}/workflows`, workflowPreferences);
|
|
125
|
+
return data;
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
setWorkflowPreferences(collection, objectId, workflowKey, setting, options = {}) {
|
|
129
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
+
const preferenceSetId = options.preferenceSet || helpers_1.DEFAULT_PREFERENCE_SET_ID;
|
|
131
|
+
const { data } = yield this.knock.put(`/v1/objects/${collection}/${objectId}/preferences/${preferenceSetId}/workflows/${workflowKey}`, helpers_1.buildUpdateParam(setting));
|
|
132
|
+
return data;
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
setCategoriesPreferences(collection, objectId, categoryPreferences, options = {}) {
|
|
136
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
137
|
+
const preferenceSetId = options.preferenceSet || helpers_1.DEFAULT_PREFERENCE_SET_ID;
|
|
138
|
+
const { data } = yield this.knock.put(`/v1/objects/${collection}/${objectId}/preferences/${preferenceSetId}/categories`, categoryPreferences);
|
|
139
|
+
return data;
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
setCategoryPreferences(collection, objectId, categoryKey, setting, options = {}) {
|
|
143
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
144
|
+
const preferenceSetId = options.preferenceSet || helpers_1.DEFAULT_PREFERENCE_SET_ID;
|
|
145
|
+
const { data } = yield this.knock.put(`/v1/objects/${collection}/${objectId}/preferences/${preferenceSetId}/categories/${categoryKey}`, helpers_1.buildUpdateParam(setting));
|
|
146
|
+
return data;
|
|
147
|
+
});
|
|
148
|
+
}
|
|
77
149
|
}
|
|
78
150
|
exports.Objects = Objects;
|
|
@@ -26,5 +26,6 @@ export declare class Users {
|
|
|
26
26
|
setCategoryPreferences(userId: string, categoryKey: string, setting: WorkflowPreferenceSetting, options?: PreferenceOptions): Promise<PreferenceSet>;
|
|
27
27
|
getChannelData<T = CommonMetadata>(userId: string, channelId: string): Promise<ChannelData<T>>;
|
|
28
28
|
setChannelData<T = CommonMetadata>(userId: string, channelId: string, channelData: Record<string, any>): Promise<ChannelData<T>>;
|
|
29
|
+
unsetChannelData(userId: string, channelId: string): Promise<any>;
|
|
29
30
|
getMessages(userId: string, filteringOptions?: ListMessagesOptions): Promise<PaginatedResponse<Message>>;
|
|
30
31
|
}
|
|
@@ -177,6 +177,15 @@ class Users {
|
|
|
177
177
|
return data;
|
|
178
178
|
});
|
|
179
179
|
}
|
|
180
|
+
unsetChannelData(userId, channelId) {
|
|
181
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
182
|
+
if (!userId || !channelId) {
|
|
183
|
+
throw new Error(`Incomplete arguments. You must provide a 'userId' and a 'channelId'`);
|
|
184
|
+
}
|
|
185
|
+
const { data } = yield this.knock.delete(`/v1/users/${userId}/channel_data/${channelId}`);
|
|
186
|
+
return data;
|
|
187
|
+
});
|
|
188
|
+
}
|
|
180
189
|
//
|
|
181
190
|
// Messages
|
|
182
191
|
//
|
|
@@ -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;
|