@knocklabs/node 0.4.5 → 0.4.8

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knocklabs/node",
3
- "version": "0.4.5",
3
+ "version": "0.4.8",
4
4
  "description": "Library for interacting with the Knock API",
5
5
  "homepage": "https://github.com/knocklabs/knock-node",
6
6
  "author": "@knocklabs",
@@ -28,10 +28,14 @@ declare type PageInfo = {
28
28
  after: string;
29
29
  page_size: number;
30
30
  };
31
- export interface PaginatedResponse<T> {
31
+ export interface PaginatedFeedResponse<T> {
32
32
  entries: T[];
33
33
  page_info: PageInfo;
34
34
  }
35
+ export interface PaginatedResponse<T> {
36
+ items: T[];
37
+ page_info: PageInfo;
38
+ }
35
39
  export interface PaginationOptions {
36
40
  page_size?: number;
37
41
  after?: string;
@@ -1,13 +1,16 @@
1
1
  import { PaginatedResponse, PaginationOptions } from "../../common/interfaces";
2
- import { Message, MessageContent, MessageEvent, ListMessagesOptions } from "./interfaces";
2
+ import { Message, MessageContent, MessageEvent, ListMessagesOptions, MessageEngagementStatus } from "./interfaces";
3
3
  import { Activity } from "../activities/interfaces";
4
4
  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>>;
12
12
  getActivities(messageId: string, paginationOptions?: PaginationOptions): Promise<PaginatedResponse<Activity>>;
13
+ setStatus(messageId: string, status: MessageEngagementStatus): Promise<Message>;
14
+ deleteStatus(messageId: string, status: MessageEngagementStatus): Promise<Message>;
15
+ batchSetStatus(messageIds: string[], status: MessageEngagementStatus | "unseen" | "unread" | "unarchived"): Promise<Message[]>;
13
16
  }
@@ -56,5 +56,31 @@ class Messages {
56
56
  return data;
57
57
  });
58
58
  }
59
+ setStatus(messageId, status) {
60
+ return __awaiter(this, void 0, void 0, function* () {
61
+ if (!messageId) {
62
+ throw new Error(`Incomplete arguments. You must provide a 'messageId'`);
63
+ }
64
+ const { data } = yield this.knock.put(`/v1/messages/${messageId}/${status}`, {});
65
+ return data;
66
+ });
67
+ }
68
+ deleteStatus(messageId, status) {
69
+ return __awaiter(this, void 0, void 0, function* () {
70
+ if (!messageId) {
71
+ throw new Error(`Incomplete arguments. You must provide a 'messageId'`);
72
+ }
73
+ const { data } = yield this.knock.delete(`/v1/messages/${messageId}/${status}`);
74
+ return data;
75
+ });
76
+ }
77
+ batchSetStatus(messageIds, status) {
78
+ return __awaiter(this, void 0, void 0, function* () {
79
+ const { data } = yield this.knock.post(`/v1/messages/batch/${status}`, {
80
+ message_ids: messageIds,
81
+ });
82
+ return data;
83
+ });
84
+ }
59
85
  }
60
86
  exports.Messages = Messages;
@@ -1,9 +1,9 @@
1
- import { ObjectRef } from "../objects/interfaces";
2
1
  import { PaginationOptions } from "../../common/interfaces";
2
+ import { Recipient } from "../workflows/interfaces";
3
3
  export interface Message {
4
4
  id: string;
5
5
  channel_id: string;
6
- recipient: string | ObjectRef;
6
+ recipient: Recipient;
7
7
  tenant: string | null;
8
8
  status: MessageStatus;
9
9
  read_at: string | null;
@@ -18,7 +18,7 @@ export interface Message {
18
18
  export interface MessageEvent {
19
19
  id: string;
20
20
  environment_id: string;
21
- recipient: string | ObjectRef;
21
+ recipient: Recipient;
22
22
  data: Record<string, any>;
23
23
  type: string;
24
24
  inserted_at: string;
@@ -40,4 +40,5 @@ declare type WorkflowSource = {
40
40
  key: string;
41
41
  };
42
42
  declare type MessageStatus = "queued" | "sent" | "delivered" | "undelivered" | "not_sent";
43
+ export declare type MessageEngagementStatus = "seen" | "read" | "archived";
43
44
  export {};
@@ -1,4 +1,4 @@
1
- import { ChannelData, ChannelType, CommonMetadata, PaginatedResponse } from "../../common/interfaces";
1
+ import { ChannelData, ChannelType, CommonMetadata, PaginatedFeedResponse, PaginatedResponse } from "../../common/interfaces";
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";
@@ -13,7 +13,7 @@ export declare class Users {
13
13
  delete(userId: string): Promise<null>;
14
14
  bulkDelete(userIds: string[]): Promise<BulkOperation>;
15
15
  merge(toUserId: string, fromUserId: string): Promise<User>;
16
- getFeed(userId: string, channelId: string, feedOptions?: UserFeedOptions): Promise<any>;
16
+ getFeed(userId: string, channelId: string, feedOptions?: UserFeedOptions): Promise<PaginatedFeedResponse<any>>;
17
17
  getAllPreferences(userId: string): Promise<any>;
18
18
  /**
19
19
  * @deprecated Use `users.getPreferences` instead
@@ -1,18 +1,25 @@
1
- import { ObjectRef } from "../objects/interfaces";
1
+ import { ObjectRef, SetObjectProperties } from "../objects/interfaces";
2
+ import { IdentifyProperties } from "../users/interfaces";
2
3
  export interface TriggerWorkflowProperties<T = {
3
4
  [key: string]: any;
4
5
  }> {
5
- actor?: Actor;
6
- recipients?: Recipient[];
6
+ actor?: Actor | ActorWithUpsert;
7
+ recipients?: Array<Recipient | RecipientWithUpsert>;
7
8
  cancellationKey?: string;
8
9
  tenant?: string;
9
10
  data?: T;
10
11
  }
11
12
  export interface CancelWorkflowProperties {
12
- recipients?: string[] | ObjectRef;
13
+ recipients?: Recipient[];
13
14
  }
14
15
  export interface WorkflowRun {
15
16
  workflow_run_id: string;
16
17
  }
17
18
  export declare type Recipient = string | ObjectRef;
18
19
  export declare type Actor = Recipient;
20
+ export interface UserWithUpsert extends IdentifyProperties {
21
+ id: string;
22
+ }
23
+ export declare type ObjectWithUpsert = ObjectRef & SetObjectProperties;
24
+ export declare type RecipientWithUpsert = UserWithUpsert | ObjectWithUpsert;
25
+ export declare type ActorWithUpsert = RecipientWithUpsert;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knocklabs/node",
3
- "version": "0.4.5",
3
+ "version": "0.4.8",
4
4
  "description": "Library for interacting with the Knock API",
5
5
  "homepage": "https://github.com/knocklabs/knock-node",
6
6
  "author": "@knocklabs",