@knocklabs/node 0.6.0 → 0.6.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.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Library for interacting with the Knock API",
5
5
  "homepage": "https://github.com/knocklabs/knock-node",
6
6
  "author": "@knocklabs",
package/dist/src/knock.js CHANGED
@@ -47,6 +47,8 @@ class Knock {
47
47
  headers: {
48
48
  Authorization: `Bearer ${this.key}`,
49
49
  "User-Agent": `knocklabs/node@${package_json_1.version}`,
50
+ "Content-Type": "application/json",
51
+ Accept: "application/json",
50
52
  },
51
53
  });
52
54
  }
@@ -88,7 +90,7 @@ class Knock {
88
90
  try {
89
91
  return yield this.client.post(path, {
90
92
  params: options.query,
91
- headers: Object.assign({ "Content-Type": "application/json", Accept: "application/json" }, options.headers),
93
+ headers: Object.assign({}, options.headers),
92
94
  body: entity,
93
95
  });
94
96
  }
@@ -103,6 +105,7 @@ class Knock {
103
105
  try {
104
106
  return yield this.client.put(path, {
105
107
  params: options.query,
108
+ headers: Object.assign({}, options.headers),
106
109
  body: entity,
107
110
  });
108
111
  }
@@ -152,7 +155,12 @@ class Knock {
152
155
  throw new exceptions_1.BadRequestException(code, message, requestID);
153
156
  }
154
157
  case 422: {
155
- const { errors } = data;
158
+ // Format errors as an array before passing to exception constructor
159
+ const errors = !data.errors
160
+ ? []
161
+ : Array.isArray(data.errors)
162
+ ? data.errors
163
+ : [data.errors];
156
164
  throw new exceptions_1.UnprocessableEntityException(errors, requestID);
157
165
  }
158
166
  case 404: {
@@ -1,11 +1,11 @@
1
1
  import { CommonMetadata, PaginatedEntriesResponse } from "../../common/interfaces";
2
2
  import { Knock } from "../../knock";
3
- import { Tenant, SetTenant, ListTenantsOptions } from "./interfaces";
3
+ import { Tenant, ListTenantsOptions, SetTenantProperties } from "./interfaces";
4
4
  export declare class Tenants {
5
5
  readonly knock: Knock;
6
6
  constructor(knock: Knock);
7
7
  list(filteringOptions?: ListTenantsOptions): Promise<PaginatedEntriesResponse<Tenant>>;
8
8
  get<T = CommonMetadata>(id: string): Promise<Tenant<T>>;
9
- set<T = CommonMetadata>(id: string, tenantData: SetTenant): Promise<Tenant<T>>;
9
+ set<T = CommonMetadata>(id: string, tenantData: SetTenantProperties): Promise<Tenant<T>>;
10
10
  delete(id: string): Promise<null>;
11
11
  }
@@ -1,4 +1,4 @@
1
- import { CommonMetadata, PaginationOptions } from "../../common/interfaces";
1
+ import { CommonMetadata, PaginationOptions, SetChannelDataProperties } from "../../common/interfaces";
2
2
  import { SetPreferencesProperties } from "../preferences/interfaces";
3
3
  export interface TenantRef {
4
4
  id: string;
@@ -20,9 +20,11 @@ export interface Tenant<T = CommonMetadata> {
20
20
  created_at?: string;
21
21
  updated_at: string;
22
22
  }
23
- export interface SetTenant {
23
+ export interface SetTenantProperties {
24
24
  name?: string;
25
+ channelData?: SetChannelDataProperties;
25
26
  settings?: TenantSettings;
27
+ [key: string]: any;
26
28
  }
27
29
  export interface ListTenantsOptions extends PaginationOptions {
28
30
  tenant_id?: string;
@@ -1,13 +1,14 @@
1
1
  import { ObjectRef, SetObjectProperties } from "../objects/interfaces";
2
2
  import { IdentifyProperties } from "../users/interfaces";
3
3
  import { PaginationOptions } from "../../common/interfaces";
4
+ import { SetTenantProperties, TenantRef } from "../tenants/interfaces";
4
5
  export interface TriggerWorkflowProperties<T = {
5
6
  [key: string]: any;
6
7
  }> {
7
8
  actor?: Actor | ActorWithUpsert;
8
9
  recipients?: (Recipient | RecipientWithUpsert)[];
9
10
  cancellationKey?: string;
10
- tenant?: string;
11
+ tenant?: Tenant | TenantWithUpsert;
11
12
  data?: T;
12
13
  }
13
14
  export interface CancelWorkflowProperties {
@@ -44,7 +45,7 @@ export interface CreateSchedulesProps {
44
45
  actor?: Recipient | RecipientWithUpsert | null;
45
46
  scheduled_at?: string;
46
47
  repeats?: ScheduleRepeatProperties[];
47
- tenant?: string;
48
+ tenant?: Tenant | TenantWithUpsert | null;
48
49
  data?: {
49
50
  [key: string]: any;
50
51
  };
@@ -77,9 +78,11 @@ export interface Schedule {
77
78
  }
78
79
  export type Recipient = string | ObjectRef;
79
80
  export type Actor = Recipient;
81
+ export type Tenant = string | TenantRef;
80
82
  export interface UserWithUpsert extends IdentifyProperties {
81
83
  id: string;
82
84
  }
83
85
  export type ObjectWithUpsert = ObjectRef & SetObjectProperties;
86
+ export type TenantWithUpsert = TenantRef & SetTenantProperties;
84
87
  export type RecipientWithUpsert = UserWithUpsert | ObjectWithUpsert;
85
88
  export type ActorWithUpsert = RecipientWithUpsert;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knocklabs/node",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Library for interacting with the Knock API",
5
5
  "homepage": "https://github.com/knocklabs/knock-node",
6
6
  "author": "@knocklabs",