@knocklabs/node 0.6.7 → 0.6.10

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/README.md CHANGED
@@ -42,7 +42,7 @@ const { Knock } = require("@knocklabs/node");
42
42
  const knockClient = new Knock("sk_12345");
43
43
 
44
44
  // The key of the workflow (from Knock dashboard)
45
- await knockClient.notify("dinosaurs-loose", {
45
+ await knockClient.workflows.trigger("dinosaurs-loose", {
46
46
  // user id of who performed the action
47
47
  actor: "dnedry",
48
48
  // list of user ids for who should receive the notification
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knocklabs/node",
3
- "version": "0.6.7",
3
+ "version": "0.6.10",
4
4
  "description": "Library for interacting with the Knock API",
5
5
  "homepage": "https://github.com/knocklabs/knock-node",
6
6
  "author": "@knocklabs",
@@ -69,6 +69,9 @@ class FetchClient {
69
69
  }
70
70
  buildUrl(path, params) {
71
71
  const url = new URL(this.config.baseURL + path);
72
+ function containsObject(array) {
73
+ return array.some((item) => typeof item === "object" && item !== null);
74
+ }
72
75
  function appendParams(key, value, parentKey) {
73
76
  const fullKey = parentKey ? `${parentKey}[${key}]` : key;
74
77
  if (typeof value === "object" &&
@@ -80,6 +83,22 @@ class FetchClient {
80
83
  appendParams(nestedKey, nestedValue, fullKey);
81
84
  });
82
85
  }
86
+ else if (Array.isArray(value) && containsObject(value)) {
87
+ // Send array values as individual values with identifier
88
+ // e.g. key[0]=user1&key[1]=userid2&key[3][field1Key]=field1Value&key[3][field2Key]=field2Value
89
+ value.forEach((item, index) => {
90
+ const indexKey = index.toString();
91
+ if (typeof item === "string") {
92
+ url.searchParams.append(`${fullKey}[${indexKey}]`, item);
93
+ }
94
+ else if (typeof item === "object" && item !== null) {
95
+ Object.entries(item).forEach(([key, val]) => {
96
+ const strVal = val;
97
+ url.searchParams.append(`${fullKey}[${indexKey}][${key}]`, strVal);
98
+ });
99
+ }
100
+ });
101
+ }
83
102
  else if (Array.isArray(value)) {
84
103
  // Send array values as individual values instead of a comma separated list
85
104
  // e.g. key[]=1&key[]=2&key[]=3 instead of key=1,2,3
@@ -10,7 +10,7 @@ export declare class Messages {
10
10
  getContent(messageId: string): Promise<MessageContent>;
11
11
  getEvents(messageId: string, paginationOptions?: PaginationOptions): Promise<PaginatedItemsResponse<MessageEvent>>;
12
12
  getActivities(messageId: string, filteringOptions?: ListMessageActivitiesOptions): Promise<PaginatedItemsResponse<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
+ setStatus(messageId: string, status: Exclude<MessageEngagementStatus, "link_clicked">): Promise<Message>;
14
+ deleteStatus(messageId: string, status: Exclude<MessageEngagementStatus, "link_clicked">): Promise<Message>;
15
+ batchSetStatus(messageIds: string[], status: Exclude<MessageEngagementStatus, "link_clicked"> | "unseen" | "unread" | "unarchived"): Promise<Message[]>;
16
16
  }
@@ -44,5 +44,5 @@ type WorkflowSource = {
44
44
  key: string;
45
45
  };
46
46
  type MessageStatus = "queued" | "sent" | "delivered" | "undelivered" | "not_sent";
47
- export type MessageEngagementStatus = "seen" | "read" | "archived";
47
+ export type MessageEngagementStatus = "seen" | "read" | "archived" | "interacted" | "link_clicked";
48
48
  export {};
@@ -1,6 +1,6 @@
1
1
  import { ChannelData, CommonMetadata, SetChannelDataProperties, PaginatedEntriesResponse, ChannelType, PaginatedItemsResponse } from "../../common/interfaces";
2
2
  import { Knock } from "../../knock";
3
- import { AddObjectSubscriptionProperties, BulkAddSubscriptionsOption, BulkSetObjectOption, DeleteObjectSubscriptionProperties, ListObjectOptions, ListObjectSubscriptionsOptions, Object, ObjectSubscription, SetObjectProperties } from "./interfaces";
3
+ import { AddObjectSubscriptionProperties, BulkAddSubscriptionsOption, BulkSetObjectOption, DeleteObjectSubscriptionProperties, GetObjectSubscriptionsOptions, ListObjectOptions, ListObjectSubscriptionsOptions, Object, ObjectSubscription, SetObjectProperties } from "./interfaces";
4
4
  import { BulkOperation } from "../bulk_operations/interfaces";
5
5
  import { ListMessagesOptions, Message } from "../messages/interfaces";
6
6
  import { ListSchedulesProps, Schedule } from "../workflows/interfaces";
@@ -29,7 +29,7 @@ export declare class Objects {
29
29
  setCategoriesPreferences(collection: string, objectId: string, categoryPreferences: WorkflowPreferences, options?: PreferenceOptions): Promise<PreferenceSet>;
30
30
  setCategoryPreferences(collection: string, objectId: string, categoryKey: string, setting: WorkflowPreferenceSetting, options?: PreferenceOptions): Promise<PreferenceSet>;
31
31
  listSubscriptions(collection: string, objectId: string, options?: ListObjectSubscriptionsOptions): Promise<PaginatedEntriesResponse<ObjectSubscription>>;
32
- getSubscriptions(collection: string, objectId: string, options?: ListObjectSubscriptionsOptions): Promise<PaginatedEntriesResponse<ObjectSubscription>>;
32
+ getSubscriptions(collection: string, objectId: string, options?: GetObjectSubscriptionsOptions): Promise<PaginatedEntriesResponse<ObjectSubscription>>;
33
33
  addSubscriptions(collection: string, objectId: string, properties?: AddObjectSubscriptionProperties): Promise<ObjectSubscription[]>;
34
34
  deleteSubscriptions(collection: string, objectId: string, properties?: DeleteObjectSubscriptionProperties): Promise<ObjectSubscription[]>;
35
35
  getSchedules(collection: string, objectId: string, filteringOptions?: ListSchedulesProps): Promise<PaginatedEntriesResponse<Schedule>>;
@@ -27,10 +27,13 @@ export interface BulkAddSubscriptionsOption<T = CommonMetadata> {
27
27
  recipients: (IdentifyUserProperties | SetObjectProperties | string)[];
28
28
  }
29
29
  export interface ListObjectOptions extends PaginationOptions {
30
- object_id?: string;
31
- name?: string;
30
+ include?: Array<"preferences">;
32
31
  }
33
32
  export interface ListObjectSubscriptionsOptions extends PaginationOptions {
33
+ recipients?: Recipient[];
34
+ }
35
+ export interface GetObjectSubscriptionsOptions extends PaginationOptions {
36
+ objects?: ObjectRef[];
34
37
  }
35
38
  export interface ObjectSubscription<T = CommonMetadata> {
36
39
  recipient: User | Object;
@@ -1,4 +1,5 @@
1
1
  import { PaginationOptions } from "../../common/interfaces";
2
+ import { ObjectRef } from "../objects/interfaces";
2
3
  export interface IdentifyProperties {
3
4
  name?: string;
4
5
  email?: string;
@@ -26,9 +27,8 @@ export interface UserFeedOptions extends PaginationOptions {
26
27
  trigger_data?: Record<string, any>;
27
28
  }
28
29
  export interface ListUserOptions extends PaginationOptions {
29
- name?: string;
30
- email?: string;
31
- user_id?: string;
30
+ include?: Array<"preferences">;
32
31
  }
33
32
  export interface ListSubscriptionsOptions extends PaginationOptions {
33
+ objects?: ObjectRef[];
34
34
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knocklabs/node",
3
- "version": "0.6.7",
3
+ "version": "0.6.10",
4
4
  "description": "Library for interacting with the Knock API",
5
5
  "homepage": "https://github.com/knocklabs/knock-node",
6
6
  "author": "@knocklabs",