@knocklabs/node 0.4.26 → 0.5.1

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.26",
3
+ "version": "0.5.1",
4
4
  "description": "Library for interacting with the Knock API",
5
5
  "homepage": "https://github.com/knocklabs/knock-node",
6
6
  "author": "@knocklabs",
@@ -1,7 +1,6 @@
1
1
  import { AxiosResponse } from "axios";
2
2
  import { KnockOptions, PostAndPutOptions, SignUserTokenOptions, MethodOptions } from "./common/interfaces";
3
3
  import { Users } from "./resources/users";
4
- import { Preferences } from "./resources/preferences";
5
4
  import { Workflows } from "./resources/workflows";
6
5
  import { TriggerWorkflowProperties } from "./resources/workflows/interfaces";
7
6
  import { BulkOperations } from "./resources/bulk_operations";
@@ -14,7 +13,6 @@ declare class Knock {
14
13
  readonly host: string;
15
14
  private readonly client;
16
15
  readonly users: Users;
17
- readonly preferences: Preferences;
18
16
  readonly workflows: Workflows;
19
17
  readonly bulkOperations: BulkOperations;
20
18
  readonly objects: Objects;
@@ -30,7 +28,7 @@ declare class Knock {
30
28
  * @param options Optionally specify the signing key to use (in PEM or base-64 encoded format), and how long the token should be valid for in seconds
31
29
  * @returns {string} A JWT token that can be used to authenticate requests to the Knock API (e.g. by passing into the <KnockFeedProvider /> component)
32
30
  */
33
- static signUserToken(userId: string, options: SignUserTokenOptions): string;
31
+ static signUserToken(userId: string, options?: SignUserTokenOptions): string;
34
32
  post(path: string, entity: any, options?: PostAndPutOptions): Promise<AxiosResponse>;
35
33
  put(path: string, entity: any, options?: PostAndPutOptions): Promise<AxiosResponse>;
36
34
  delete(path: string, entity?: any): Promise<AxiosResponse>;
package/dist/src/knock.js CHANGED
@@ -18,7 +18,6 @@ const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
18
18
  const package_json_1 = require("../package.json");
19
19
  const exceptions_1 = require("./common/exceptions");
20
20
  const users_1 = require("./resources/users");
21
- const preferences_1 = require("./resources/preferences");
22
21
  const workflows_1 = require("./resources/workflows");
23
22
  const bulk_operations_1 = require("./resources/bulk_operations");
24
23
  const objects_1 = require("./resources/objects");
@@ -31,7 +30,6 @@ class Knock {
31
30
  this.options = options;
32
31
  // Service accessors
33
32
  this.users = new users_1.Users(this);
34
- this.preferences = new preferences_1.Preferences(this);
35
33
  this.workflows = new workflows_1.Workflows(this);
36
34
  this.bulkOperations = new bulk_operations_1.BulkOperations(this);
37
35
  this.objects = new objects_1.Objects(this);
@@ -68,11 +66,11 @@ class Knock {
68
66
  */
69
67
  static signUserToken(userId, options) {
70
68
  var _a;
71
- const signingKey = prepareSigningKey(options.signingKey);
69
+ const signingKey = prepareSigningKey(options === null || options === void 0 ? void 0 : options.signingKey);
72
70
  // JWT NumericDates specified in seconds:
73
71
  const currentTime = Math.floor(Date.now() / 1000);
74
72
  // Default to 1 hour from now
75
- const expireInSeconds = (_a = options.expiresInSeconds) !== null && _a !== void 0 ? _a : 60 * 60;
73
+ const expireInSeconds = (_a = options === null || options === void 0 ? void 0 : options.expiresInSeconds) !== null && _a !== void 0 ? _a : 60 * 60;
76
74
  return jsonwebtoken_1.default.sign({
77
75
  sub: userId,
78
76
  iat: currentTime,
@@ -4,7 +4,7 @@ import { AddObjectSubscriptionProperties, BulkAddSubscriptionsOption, BulkSetObj
4
4
  import { BulkOperation } from "../bulk_operations/interfaces";
5
5
  import { ListMessagesOptions, Message } from "../messages/interfaces";
6
6
  import { ListSchedulesProps, Schedule } from "../workflows/interfaces";
7
- import { ChannelTypePreferences, PreferenceOptions, PreferenceSet, SetPreferencesProperties, WorkflowPreferences, WorkflowPreferenceSetting } from "../preferences/interfaces";
7
+ import { ChannelTypePreferences, GetPreferencesOptions, PreferenceOptions, PreferenceSet, SetPreferencesProperties, WorkflowPreferences, WorkflowPreferenceSetting } from "../preferences/interfaces";
8
8
  export declare class Objects {
9
9
  readonly knock: Knock;
10
10
  constructor(knock: Knock);
@@ -20,11 +20,7 @@ export declare class Objects {
20
20
  unsetChannelData(collection: string, id: string, channelId: string): Promise<any>;
21
21
  getMessages(collection: string, objectId: string, filteringOptions?: ListMessagesOptions): Promise<PaginatedItemsResponse<Message>>;
22
22
  getAllPreferences(collection: string, objectId: string): Promise<PreferenceSet[]>;
23
- /**
24
- * @deprecated Use `objects.getPreferences` instead
25
- */
26
- getPrefences(collection: string, objectId: string, options?: PreferenceOptions): Promise<PreferenceSet>;
27
- getPreferences(collection: string, objectId: string, options?: PreferenceOptions): Promise<PreferenceSet>;
23
+ getPreferences(collection: string, objectId: string, options?: GetPreferencesOptions): Promise<PreferenceSet>;
28
24
  setPreferences(collection: string, objectId: string, preferenceSet: SetPreferencesProperties, options?: PreferenceOptions): Promise<PreferenceSet>;
29
25
  setChannelTypesPreferences(collection: string, objectId: string, channelTypePreferences: ChannelTypePreferences, options?: PreferenceOptions): Promise<PreferenceSet>;
30
26
  setChannelTypePreferences(collection: string, objectId: string, channelType: ChannelType, setting: boolean, options?: PreferenceOptions): Promise<PreferenceSet>;
@@ -104,18 +104,10 @@ class Objects {
104
104
  return data;
105
105
  });
106
106
  }
107
- /**
108
- * @deprecated Use `objects.getPreferences` instead
109
- */
110
- getPrefences(collection, objectId, options = {}) {
111
- return __awaiter(this, void 0, void 0, function* () {
112
- return this.getPreferences(collection, objectId, options);
113
- });
114
- }
115
107
  getPreferences(collection, objectId, options = {}) {
116
108
  return __awaiter(this, void 0, void 0, function* () {
117
109
  const preferenceSetId = options.preferenceSet || helpers_1.DEFAULT_PREFERENCE_SET_ID;
118
- const { data } = yield this.knock.get(`/v1/objects/${collection}/${objectId}/preferences/${preferenceSetId}`);
110
+ const { data, } = yield this.knock.get(`/v1/objects/${collection}/${objectId}/preferences/${preferenceSetId}`, { tenant: options.tenant });
119
111
  return data;
120
112
  });
121
113
  }
@@ -25,3 +25,6 @@ export interface PreferenceSet {
25
25
  export interface PreferenceOptions {
26
26
  preferenceSet?: string;
27
27
  }
28
+ export interface GetPreferencesOptions extends PreferenceOptions {
29
+ tenant?: string;
30
+ }
@@ -1,6 +1,6 @@
1
1
  import { ChannelData, ChannelType, CommonMetadata, PaginatedItemsResponse, PaginatedEntriesResponse } from "../../common/interfaces";
2
2
  import { BulkOperation } from "../bulk_operations/interfaces";
3
- import { ChannelTypePreferences, PreferenceOptions, PreferenceSet, SetPreferencesProperties, WorkflowPreferences, WorkflowPreferenceSetting } from "../preferences/interfaces";
3
+ import { ChannelTypePreferences, PreferenceOptions, PreferenceSet, GetPreferencesOptions, SetPreferencesProperties, WorkflowPreferences, WorkflowPreferenceSetting } from "../preferences/interfaces";
4
4
  import { ListMessagesOptions, Message } from "../messages/interfaces";
5
5
  import { ListSchedulesProps, Schedule } from "../workflows/interfaces";
6
6
  import { Knock } from "../../knock";
@@ -18,11 +18,7 @@ export declare class Users {
18
18
  merge(toUserId: string, fromUserId: string): Promise<User>;
19
19
  getFeed(userId: string, channelId: string, feedOptions?: UserFeedOptions): Promise<PaginatedEntriesResponse<any>>;
20
20
  getAllPreferences(userId: string): Promise<any>;
21
- /**
22
- * @deprecated Use `users.getPreferences` instead
23
- */
24
- getPrefences(userId: string, options?: PreferenceOptions): Promise<PreferenceSet>;
25
- getPreferences(userId: string, options?: PreferenceOptions): Promise<PreferenceSet>;
21
+ getPreferences(userId: string, options?: GetPreferencesOptions): Promise<PreferenceSet>;
26
22
  setPreferences(userId: string, preferenceSet: SetPreferencesProperties, options?: PreferenceOptions): Promise<PreferenceSet>;
27
23
  bulkSetPreferences(userIds: string[], preferenceSet: SetPreferencesProperties, options?: PreferenceOptions): Promise<BulkOperation>;
28
24
  setChannelTypesPreferences(userId: string, channelTypePreferences: ChannelTypePreferences, options?: PreferenceOptions): Promise<PreferenceSet>;
@@ -94,18 +94,10 @@ class Users {
94
94
  return data;
95
95
  });
96
96
  }
97
- /**
98
- * @deprecated Use `users.getPreferences` instead
99
- */
100
- getPrefences(userId, options = {}) {
101
- return __awaiter(this, void 0, void 0, function* () {
102
- return this.getPreferences(userId, options);
103
- });
104
- }
105
97
  getPreferences(userId, options = {}) {
106
98
  return __awaiter(this, void 0, void 0, function* () {
107
99
  const preferenceSetId = options.preferenceSet || helpers_1.DEFAULT_PREFERENCE_SET_ID;
108
- const { data } = yield this.knock.get(`/v1/users/${userId}/preferences/${preferenceSetId}`);
100
+ const { data, } = yield this.knock.get(`/v1/users/${userId}/preferences/${preferenceSetId}`, { tenant: options.tenant });
109
101
  return data;
110
102
  });
111
103
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knocklabs/node",
3
- "version": "0.4.26",
3
+ "version": "0.5.1",
4
4
  "description": "Library for interacting with the Knock API",
5
5
  "homepage": "https://github.com/knocklabs/knock-node",
6
6
  "author": "@knocklabs",
@@ -47,4 +47,4 @@
47
47
  "axios": "1.6",
48
48
  "jsonwebtoken": "^9.0.0"
49
49
  }
50
- }
50
+ }
@@ -1,43 +0,0 @@
1
- import { ChannelType } from "../../common/interfaces";
2
- import { Knock } from "../../knock";
3
- import { ChannelTypePreferences, WorkflowPreferenceSetting, WorkflowPreferences, PreferenceOptions, SetPreferencesProperties, PreferenceSet } from "./interfaces";
4
- export declare class Preferences {
5
- readonly knock: Knock;
6
- constructor(knock: Knock);
7
- /**
8
- * @deprecated Use `users.getAllPreferences` instead
9
- */
10
- getAll(userId: string): Promise<PreferenceSet[]>;
11
- /**
12
- * @deprecated Use `users.getPreferences` instead
13
- */
14
- get(userId: string, options?: PreferenceOptions): Promise<PreferenceSet>;
15
- /**
16
- * @deprecated Use `users.setPreferences` instead
17
- */
18
- set(userId: string, preferenceSet: SetPreferencesProperties, options?: PreferenceOptions): Promise<PreferenceSet>;
19
- /**
20
- * @deprecated Use `users.setChannelTypesPreferences` instead
21
- */
22
- setChannelTypes(userId: string, channelTypePreferences: ChannelTypePreferences, options?: PreferenceOptions): Promise<PreferenceSet>;
23
- /**
24
- * @deprecated Use `users.setChannelTypePreferences` instead
25
- */
26
- setChannelType(userId: string, channelType: ChannelType, setting: boolean, options?: PreferenceOptions): Promise<PreferenceSet>;
27
- /**
28
- * @deprecated Use `users.setWorkflowsPreferences` instead
29
- */
30
- setWorkflows(userId: string, workflowPreferences: WorkflowPreferences, options?: PreferenceOptions): Promise<PreferenceSet>;
31
- /**
32
- * @deprecated Use `users.setWorkflowPreferences` instead
33
- */
34
- setWorkflow(userId: string, workflowKey: string, setting: WorkflowPreferenceSetting, options?: PreferenceOptions): Promise<PreferenceSet>;
35
- /**
36
- * @deprecated Use `users.setCategoriesPreferences` instead
37
- */
38
- setCategories(userId: string, categoryPreferences: WorkflowPreferences, options?: PreferenceOptions): Promise<PreferenceSet>;
39
- /**
40
- * @deprecated Use `users.setCategoryPreferences` instead
41
- */
42
- setCategory(userId: string, categoryKey: string, setting: WorkflowPreferenceSetting, options?: PreferenceOptions): Promise<PreferenceSet>;
43
- }
@@ -1,91 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Preferences = void 0;
13
- // Deprecated all of the methods in this to be removed in `0.5.0`
14
- class Preferences {
15
- constructor(knock) {
16
- this.knock = knock;
17
- }
18
- /**
19
- * @deprecated Use `users.getAllPreferences` instead
20
- */
21
- getAll(userId) {
22
- return __awaiter(this, void 0, void 0, function* () {
23
- return this.knock.users.getAllPreferences(userId);
24
- });
25
- }
26
- /**
27
- * @deprecated Use `users.getPreferences` instead
28
- */
29
- get(userId, options = {}) {
30
- return __awaiter(this, void 0, void 0, function* () {
31
- return this.knock.users.getPrefences(userId, options);
32
- });
33
- }
34
- /**
35
- * @deprecated Use `users.setPreferences` instead
36
- */
37
- set(userId, preferenceSet, options = {}) {
38
- return __awaiter(this, void 0, void 0, function* () {
39
- return this.knock.users.setPreferences(userId, preferenceSet, options);
40
- });
41
- }
42
- /**
43
- * @deprecated Use `users.setChannelTypesPreferences` instead
44
- */
45
- setChannelTypes(userId, channelTypePreferences, options = {}) {
46
- return __awaiter(this, void 0, void 0, function* () {
47
- return this.knock.users.setChannelTypesPreferences(userId, channelTypePreferences, options);
48
- });
49
- }
50
- /**
51
- * @deprecated Use `users.setChannelTypePreferences` instead
52
- */
53
- setChannelType(userId, channelType, setting, options = {}) {
54
- return __awaiter(this, void 0, void 0, function* () {
55
- return this.knock.users.setChannelTypePreferences(userId, channelType, setting, options);
56
- });
57
- }
58
- /**
59
- * @deprecated Use `users.setWorkflowsPreferences` instead
60
- */
61
- setWorkflows(userId, workflowPreferences, options = {}) {
62
- return __awaiter(this, void 0, void 0, function* () {
63
- return this.knock.users.setWorkflowsPreferences(userId, workflowPreferences, options);
64
- });
65
- }
66
- /**
67
- * @deprecated Use `users.setWorkflowPreferences` instead
68
- */
69
- setWorkflow(userId, workflowKey, setting, options = {}) {
70
- return __awaiter(this, void 0, void 0, function* () {
71
- return this.knock.users.setWorkflowPreferences(userId, workflowKey, setting, options);
72
- });
73
- }
74
- /**
75
- * @deprecated Use `users.setCategoriesPreferences` instead
76
- */
77
- setCategories(userId, categoryPreferences, options = {}) {
78
- return __awaiter(this, void 0, void 0, function* () {
79
- return this.knock.users.setCategoriesPreferences(userId, categoryPreferences, options);
80
- });
81
- }
82
- /**
83
- * @deprecated Use `users.setCategoryPreferences` instead
84
- */
85
- setCategory(userId, categoryKey, setting, options = {}) {
86
- return __awaiter(this, void 0, void 0, function* () {
87
- return this.knock.users.setCategoryPreferences(userId, categoryKey, setting, options);
88
- });
89
- }
90
- }
91
- exports.Preferences = Preferences;