@knocklabs/node 0.4.23 → 0.4.25

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.23",
3
+ "version": "0.4.25",
4
4
  "description": "Library for interacting with the Knock API",
5
5
  "homepage": "https://github.com/knocklabs/knock-node",
6
6
  "author": "@knocklabs",
@@ -35,7 +35,7 @@
35
35
  "@types/jsonwebtoken": "^9.0.1",
36
36
  "@types/node": "^15.0.1",
37
37
  "@types/pluralize": "0.0.29",
38
- "axios-mock-adapter": "1.19.0",
38
+ "axios-mock-adapter": "^1.22.0",
39
39
  "jest": "26.6.3",
40
40
  "prettier": "2.2.1",
41
41
  "supertest": "6.1.3",
@@ -44,7 +44,7 @@
44
44
  "typescript": "4.2.4"
45
45
  },
46
46
  "dependencies": {
47
- "axios": "^0.21.1",
47
+ "axios": "1.6",
48
48
  "jsonwebtoken": "^9.0.0"
49
49
  }
50
50
  }
@@ -18,7 +18,7 @@ export interface UnprocessableEntityError {
18
18
  type: string;
19
19
  field: string;
20
20
  }
21
- export declare type ChannelType = "email" | "in_app_feed" | "sms" | "push" | "chat";
21
+ export declare type ChannelType = "email" | "in_app_feed" | "sms" | "push" | "chat" | "http";
22
22
  export declare type CommonMetadata = Record<string, any>;
23
23
  export interface ChannelData<T = CommonMetadata> {
24
24
  channel_id: string;
@@ -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, BulkSetObjectOption, DeleteObjectSubscriptionProperties, ListObjectOptions, ListObjectSubscriptionsOptions, Object, ObjectSubscription, SetObjectProperties } from "./interfaces";
3
+ import { AddObjectSubscriptionProperties, BulkAddSubscriptionsOption, 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
6
  import { ListSchedulesProps, Schedule } from "../workflows/interfaces";
@@ -14,6 +14,7 @@ export declare class Objects {
14
14
  bulkSet(collection: string, objects: BulkSetObjectOption[]): Promise<BulkOperation>;
15
15
  delete(collection: string, id: string): Promise<null>;
16
16
  bulkDelete(collection: string, objectIds: string[]): Promise<BulkOperation>;
17
+ bulkAddSubscriptions<T = CommonMetadata>(collection: string, subscriptions: BulkAddSubscriptionsOption<T>[]): Promise<BulkOperation>;
17
18
  getChannelData<T = CommonMetadata>(collection: string, id: string, channelId: string): Promise<ChannelData<T>>;
18
19
  setChannelData<T = CommonMetadata>(collection: string, id: string, channelId: string, channelData: SetChannelDataProperties): Promise<ChannelData<T>>;
19
20
  unsetChannelData(collection: string, id: string, channelId: string): Promise<any>;
@@ -33,6 +33,7 @@ class Objects {
33
33
  return data;
34
34
  });
35
35
  }
36
+ // Bulk ops
36
37
  bulkSet(collection, objects) {
37
38
  return __awaiter(this, void 0, void 0, function* () {
38
39
  const attrs = { objects };
@@ -55,6 +56,13 @@ class Objects {
55
56
  return data;
56
57
  });
57
58
  }
59
+ bulkAddSubscriptions(collection, subscriptions) {
60
+ return __awaiter(this, void 0, void 0, function* () {
61
+ const attrs = { subscriptions };
62
+ const { data } = yield this.knock.post(`/v1/objects/${collection}/bulk/subscriptions/add`, attrs);
63
+ return data;
64
+ });
65
+ }
58
66
  // Channel data
59
67
  getChannelData(collection, id, channelId) {
60
68
  return __awaiter(this, void 0, void 0, function* () {
@@ -171,7 +179,7 @@ class Objects {
171
179
  }
172
180
  getSubscriptions(collection, objectId, options = {}) {
173
181
  return __awaiter(this, void 0, void 0, function* () {
174
- const { data } = yield this.knock.get(`/v1/objects/${collection}/${objectId}/subscriptions`, Object.assign(Object.assign({}, options), { mode: "recipient" }));
182
+ const { data, } = yield this.knock.get(`/v1/objects/${collection}/${objectId}/subscriptions`, Object.assign(Object.assign({}, options), { mode: "recipient" }));
175
183
  return data;
176
184
  });
177
185
  }
@@ -1,5 +1,5 @@
1
1
  import { CommonMetadata, PaginationOptions } from "../../common/interfaces";
2
- import { User } from "../users/interfaces";
2
+ import { User, IdentifyProperties as IdentifyUserProperties } from "../users/interfaces";
3
3
  import { Recipient, RecipientWithUpsert } from "../workflows/interfaces";
4
4
  export interface ObjectRef {
5
5
  collection: string;
@@ -21,6 +21,11 @@ export interface BulkSetObjectOption {
21
21
  name?: string;
22
22
  [key: string]: any;
23
23
  }
24
+ export interface BulkAddSubscriptionsOption<T = CommonMetadata> {
25
+ id: string;
26
+ properties?: T;
27
+ recipients: (IdentifyUserProperties | SetObjectProperties | string)[];
28
+ }
24
29
  export interface ListObjectOptions extends PaginationOptions {
25
30
  object_id?: string;
26
31
  name?: string;
@@ -19,7 +19,9 @@ class Workflows {
19
19
  if (!workflowKey && !recipients) {
20
20
  throw new Error(`Incomplete arguments. At a minimum you need to specify 'workflowKey' and 'recipients'.`);
21
21
  }
22
- const options = idempotencyKey ? { headers: { 'Idempotency-Key': idempotencyKey } } : {};
22
+ const options = idempotencyKey
23
+ ? { headers: { "Idempotency-Key": idempotencyKey } }
24
+ : {};
23
25
  const { data } = yield this.knock.post(`/v1/workflows/${workflowKey}/trigger`, {
24
26
  actor,
25
27
  recipients,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knocklabs/node",
3
- "version": "0.4.23",
3
+ "version": "0.4.25",
4
4
  "description": "Library for interacting with the Knock API",
5
5
  "homepage": "https://github.com/knocklabs/knock-node",
6
6
  "author": "@knocklabs",
@@ -35,7 +35,7 @@
35
35
  "@types/jsonwebtoken": "^9.0.1",
36
36
  "@types/node": "^15.0.1",
37
37
  "@types/pluralize": "0.0.29",
38
- "axios-mock-adapter": "1.19.0",
38
+ "axios-mock-adapter": "^1.22.0",
39
39
  "jest": "26.6.3",
40
40
  "prettier": "2.2.1",
41
41
  "supertest": "6.1.3",
@@ -44,7 +44,7 @@
44
44
  "typescript": "4.2.4"
45
45
  },
46
46
  "dependencies": {
47
- "axios": "^0.21.1",
47
+ "axios": "1.6",
48
48
  "jsonwebtoken": "^9.0.0"
49
49
  }
50
- }
50
+ }