@knocklabs/node 0.4.18 → 0.4.19
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 +2 -0
- package/dist/src/resources/objects/index.js +12 -0
- package/dist/src/resources/users/index.d.ts +2 -0
- package/dist/src/resources/users/index.js +12 -0
- package/dist/src/resources/workflows/index.d.ts +6 -2
- package/dist/src/resources/workflows/index.js +24 -0
- package/dist/src/resources/workflows/interfaces.d.ts +59 -0
- package/dist/src/resources/workflows/interfaces.js +18 -0
- package/package.json +1 -1
package/dist/package.json
CHANGED
|
@@ -3,6 +3,7 @@ import { Knock } from "../../knock";
|
|
|
3
3
|
import { AddObjectSubscriptionProperties, BulkSetObjectOption, DeleteObjectSubscriptionProperties, ListObjectOptions, ListObjectSubscriptionsOptions, Object, ObjectSubscription, SetObjectProperties } from "./interfaces";
|
|
4
4
|
import { BulkOperation } from "../bulk_operations/interfaces";
|
|
5
5
|
import { ListMessagesOptions, Message } from "../messages/interfaces";
|
|
6
|
+
import { ListSchedulesProps, Schedule } from "../workflows/interfaces";
|
|
6
7
|
import { ChannelTypePreferences, PreferenceOptions, PreferenceSet, SetPreferencesProperties, WorkflowPreferences, WorkflowPreferenceSetting } from "../preferences/interfaces";
|
|
7
8
|
export declare class Objects {
|
|
8
9
|
readonly knock: Knock;
|
|
@@ -33,4 +34,5 @@ export declare class Objects {
|
|
|
33
34
|
listSubscriptions(collection: string, objectId: string, options?: ListObjectSubscriptionsOptions): Promise<PaginatedEntriesResponse<ObjectSubscription>>;
|
|
34
35
|
addSubscriptions(collection: string, objectId: string, properties?: AddObjectSubscriptionProperties): Promise<ObjectSubscription[]>;
|
|
35
36
|
deleteSubscriptions(collection: string, objectId: string, properties?: DeleteObjectSubscriptionProperties): Promise<ObjectSubscription[]>;
|
|
37
|
+
getSchedules(collection: string, objectId: string, filteringOptions?: ListSchedulesProps): Promise<PaginatedEntriesResponse<Schedule>>;
|
|
36
38
|
}
|
|
@@ -181,5 +181,17 @@ class Objects {
|
|
|
181
181
|
return data;
|
|
182
182
|
});
|
|
183
183
|
}
|
|
184
|
+
//
|
|
185
|
+
// Schedules
|
|
186
|
+
//
|
|
187
|
+
getSchedules(collection, objectId, filteringOptions = {}) {
|
|
188
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
189
|
+
if (!collection || !objectId) {
|
|
190
|
+
throw new Error(`Incomplete arguments. You must provide a 'collection' and 'objectId'`);
|
|
191
|
+
}
|
|
192
|
+
const { data } = yield this.knock.get(`/v1/objects/${collection}/${objectId}/schedules`, filteringOptions);
|
|
193
|
+
return data;
|
|
194
|
+
});
|
|
195
|
+
}
|
|
184
196
|
}
|
|
185
197
|
exports.Objects = Objects;
|
|
@@ -2,6 +2,7 @@ import { ChannelData, ChannelType, CommonMetadata, PaginatedItemsResponse, Pagin
|
|
|
2
2
|
import { BulkOperation } from "../bulk_operations/interfaces";
|
|
3
3
|
import { ChannelTypePreferences, PreferenceOptions, PreferenceSet, SetPreferencesProperties, WorkflowPreferences, WorkflowPreferenceSetting } from "../preferences/interfaces";
|
|
4
4
|
import { ListMessagesOptions, Message } from "../messages/interfaces";
|
|
5
|
+
import { ListSchedulesProps, Schedule } from "../workflows/interfaces";
|
|
5
6
|
import { Knock } from "../../knock";
|
|
6
7
|
import { BulkIdentifyUser, IdentifyProperties, ListUserOptions, User, UserFeedOptions } from "./interfaces";
|
|
7
8
|
export declare class Users {
|
|
@@ -33,4 +34,5 @@ export declare class Users {
|
|
|
33
34
|
setChannelData<T = CommonMetadata>(userId: string, channelId: string, channelData: Record<string, any>): Promise<ChannelData<T>>;
|
|
34
35
|
unsetChannelData(userId: string, channelId: string): Promise<any>;
|
|
35
36
|
getMessages(userId: string, filteringOptions?: ListMessagesOptions): Promise<PaginatedItemsResponse<Message>>;
|
|
37
|
+
getSchedules(userId: string, filteringOptions?: ListSchedulesProps): Promise<PaginatedEntriesResponse<Schedule>>;
|
|
36
38
|
}
|
|
@@ -212,5 +212,17 @@ class Users {
|
|
|
212
212
|
return data;
|
|
213
213
|
});
|
|
214
214
|
}
|
|
215
|
+
//
|
|
216
|
+
// Schedules
|
|
217
|
+
//
|
|
218
|
+
getSchedules(userId, filteringOptions = {}) {
|
|
219
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
220
|
+
if (!userId) {
|
|
221
|
+
throw new Error(`Incomplete arguments. You must provide a 'userId'`);
|
|
222
|
+
}
|
|
223
|
+
const { data } = yield this.knock.get(`/v1/users/${userId}/schedules`, filteringOptions);
|
|
224
|
+
return data;
|
|
225
|
+
});
|
|
226
|
+
}
|
|
215
227
|
}
|
|
216
228
|
exports.Users = Users;
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { Knock } from "../../knock";
|
|
2
|
-
import { MethodOptions } from "../../common/interfaces";
|
|
3
|
-
import { CancelWorkflowProperties, TriggerWorkflowProperties, WorkflowRun } from "./interfaces";
|
|
2
|
+
import { MethodOptions, PaginatedEntriesResponse } from "../../common/interfaces";
|
|
3
|
+
import { CancelWorkflowProperties, TriggerWorkflowProperties, CreateSchedulesProps, UpdateSchedulesProps, ListSchedulesProps, DeleteSchedulesProps, Schedule, WorkflowRun } from "./interfaces";
|
|
4
4
|
export declare class Workflows {
|
|
5
5
|
readonly knock: Knock;
|
|
6
6
|
constructor(knock: Knock);
|
|
7
7
|
trigger(workflowKey: string, { actor, recipients, cancellationKey, tenant, data: notifyData, }: TriggerWorkflowProperties, { idempotencyKey }?: MethodOptions): Promise<WorkflowRun>;
|
|
8
8
|
cancel(workflowKey: string, cancellationKey: string, { recipients }?: CancelWorkflowProperties): Promise<any>;
|
|
9
|
+
createSchedules(workflowKey: string, params: CreateSchedulesProps): Promise<Schedule[]>;
|
|
10
|
+
updateSchedules(params: UpdateSchedulesProps): Promise<Schedule[]>;
|
|
11
|
+
listSchedules(workflowKey: string, params?: ListSchedulesProps): Promise<PaginatedEntriesResponse<Schedule>>;
|
|
12
|
+
deleteSchedules(params: DeleteSchedulesProps): Promise<Schedule[]>;
|
|
9
13
|
}
|
|
@@ -42,5 +42,29 @@ class Workflows {
|
|
|
42
42
|
return data;
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
|
+
createSchedules(workflowKey, params) {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
const { data } = yield this.knock.post("/v1/schedules", Object.assign(Object.assign({}, params), { workflow: workflowKey }));
|
|
48
|
+
return data;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
updateSchedules(params) {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
const { data } = yield this.knock.put("/v1/schedules", params);
|
|
54
|
+
return data;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
listSchedules(workflowKey, params = {}) {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
const { data } = yield this.knock.get("/v1/schedules", Object.assign(Object.assign({}, params), { workflow: workflowKey }));
|
|
60
|
+
return data;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
deleteSchedules(params) {
|
|
64
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
const { data } = yield this.knock.delete("/v1/schedules", params);
|
|
66
|
+
return data;
|
|
67
|
+
});
|
|
68
|
+
}
|
|
45
69
|
}
|
|
46
70
|
exports.Workflows = Workflows;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ObjectRef, SetObjectProperties } from "../objects/interfaces";
|
|
2
2
|
import { IdentifyProperties } from "../users/interfaces";
|
|
3
|
+
import { PaginationOptions } from "../../common/interfaces";
|
|
3
4
|
export interface TriggerWorkflowProperties<T = {
|
|
4
5
|
[key: string]: any;
|
|
5
6
|
}> {
|
|
@@ -15,6 +16,64 @@ export interface CancelWorkflowProperties {
|
|
|
15
16
|
export interface WorkflowRun {
|
|
16
17
|
workflow_run_id: string;
|
|
17
18
|
}
|
|
19
|
+
export declare enum DaysOfWeek {
|
|
20
|
+
Mon = "mon",
|
|
21
|
+
Tue = "tue",
|
|
22
|
+
Wed = "wed",
|
|
23
|
+
Thu = "thu",
|
|
24
|
+
Fri = "fri",
|
|
25
|
+
Sat = "sat",
|
|
26
|
+
Sun = "sun"
|
|
27
|
+
}
|
|
28
|
+
export declare enum RepeatFrequency {
|
|
29
|
+
Monthly = "monthly",
|
|
30
|
+
Weekly = "weekly",
|
|
31
|
+
Daily = "daily",
|
|
32
|
+
Hourly = "hourly"
|
|
33
|
+
}
|
|
34
|
+
export declare type ScheduleRepeatProperties = {
|
|
35
|
+
frequency: RepeatFrequency;
|
|
36
|
+
interval?: number;
|
|
37
|
+
day_of_month?: number;
|
|
38
|
+
days?: DaysOfWeek[] | "weekdays" | "weekends";
|
|
39
|
+
hours?: number;
|
|
40
|
+
minutes?: number;
|
|
41
|
+
};
|
|
42
|
+
export interface CreateSchedulesProps {
|
|
43
|
+
recipients: (Recipient | RecipientWithUpsert)[];
|
|
44
|
+
actor?: Recipient | RecipientWithUpsert | null;
|
|
45
|
+
scheduled_at?: string;
|
|
46
|
+
repeats: ScheduleRepeatProperties[];
|
|
47
|
+
tenant?: string;
|
|
48
|
+
data?: {
|
|
49
|
+
[key: string]: any;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export interface UpdateSchedulesProps extends Omit<CreateSchedulesProps, "recipients"> {
|
|
53
|
+
schedule_ids: string[];
|
|
54
|
+
}
|
|
55
|
+
export interface ListSchedulesProps extends PaginationOptions {
|
|
56
|
+
recipients?: Recipient[];
|
|
57
|
+
tenant?: string;
|
|
58
|
+
}
|
|
59
|
+
export interface DeleteSchedulesProps {
|
|
60
|
+
schedule_ids: string[];
|
|
61
|
+
}
|
|
62
|
+
export interface Schedule {
|
|
63
|
+
id: string;
|
|
64
|
+
recipient: Recipient;
|
|
65
|
+
actor: Recipient | null;
|
|
66
|
+
tenant: string | null;
|
|
67
|
+
workflow: string;
|
|
68
|
+
data: {
|
|
69
|
+
[key: string]: any;
|
|
70
|
+
};
|
|
71
|
+
next_occurrence_at: string;
|
|
72
|
+
inserted_at: string;
|
|
73
|
+
updated_at: string;
|
|
74
|
+
repeats: ScheduleRepeatProperties[];
|
|
75
|
+
__cursor?: string;
|
|
76
|
+
}
|
|
18
77
|
export declare type Recipient = string | ObjectRef;
|
|
19
78
|
export declare type Actor = Recipient;
|
|
20
79
|
export interface UserWithUpsert extends IdentifyProperties {
|
|
@@ -1,2 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RepeatFrequency = exports.DaysOfWeek = void 0;
|
|
4
|
+
var DaysOfWeek;
|
|
5
|
+
(function (DaysOfWeek) {
|
|
6
|
+
DaysOfWeek["Mon"] = "mon";
|
|
7
|
+
DaysOfWeek["Tue"] = "tue";
|
|
8
|
+
DaysOfWeek["Wed"] = "wed";
|
|
9
|
+
DaysOfWeek["Thu"] = "thu";
|
|
10
|
+
DaysOfWeek["Fri"] = "fri";
|
|
11
|
+
DaysOfWeek["Sat"] = "sat";
|
|
12
|
+
DaysOfWeek["Sun"] = "sun";
|
|
13
|
+
})(DaysOfWeek = exports.DaysOfWeek || (exports.DaysOfWeek = {}));
|
|
14
|
+
var RepeatFrequency;
|
|
15
|
+
(function (RepeatFrequency) {
|
|
16
|
+
RepeatFrequency["Monthly"] = "monthly";
|
|
17
|
+
RepeatFrequency["Weekly"] = "weekly";
|
|
18
|
+
RepeatFrequency["Daily"] = "daily";
|
|
19
|
+
RepeatFrequency["Hourly"] = "hourly";
|
|
20
|
+
})(RepeatFrequency = exports.RepeatFrequency || (exports.RepeatFrequency = {}));
|