@knocklabs/client 0.18.7 → 0.19.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/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.19.1
4
+
5
+ ### Patch Changes
6
+
7
+ - c4e67da: revert 4b888c4 to remove nextjs helper components and fix module resolution error
8
+
9
+ ## 0.19.0
10
+
11
+ ### Minor Changes
12
+
13
+ - be65601: - **Added channel-level notification preferences** to client interfaces, types, tests, and the Next.js example.
14
+ - Update your code to handle the new channels property in `PreferenceSet`, `SetPreferencesProperties`, and `WorkflowPreferenceSetting` if using `@knock/client`.
15
+
16
+ ### Patch Changes
17
+
18
+ - 4b888c4: [guides] add dedicated nextjs helper components for detecting location changes
19
+
3
20
  ## 0.18.7
4
21
 
5
22
  ### Patch Changes
package/dist/cjs/api.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var a=Object.defineProperty;var n=(t,e,s)=>e in t?a(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var r=(t,e,s)=>n(t,typeof e!="symbol"?e+"":e,s);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("axios"),l=require("axios-retry"),c=require("phoenix"),i=t=>t&&typeof t=="object"&&"default"in t?t:{default:t},d=i(u),o=i(l);class h{constructor(e){r(this,"host");r(this,"apiKey");r(this,"userToken");r(this,"axiosClient");r(this,"socket");this.host=e.host,this.apiKey=e.apiKey,this.userToken=e.userToken||null,this.axiosClient=d.default.create({baseURL:this.host,headers:{Accept:"application/json","Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`,"X-Knock-User-Token":this.userToken,"X-Knock-Client":this.getKnockClientHeader()}}),typeof window<"u"&&(this.socket=new c.Socket(`${this.host.replace("http","ws")}/ws/v1`,{params:{user_token:this.userToken,api_key:this.apiKey}})),o.default(this.axiosClient,{retries:3,retryCondition:this.canRetryRequest,retryDelay:o.default.exponentialDelay})}async makeRequest(e){try{const s=await this.axiosClient(e);return{statusCode:s.status<300?"ok":"error",body:s.data,error:void 0,status:s.status}}catch(s){return console.error(s),{statusCode:"error",status:500,body:void 0,error:s}}}canRetryRequest(e){return o.default.isNetworkError(e)?!0:e.response?e.response.status>=500&&e.response.status<=599||e.response.status===429:!1}getKnockClientHeader(){return"Knock/ClientJS 0.18.7"}}exports.default=h;
1
+ "use strict";var a=Object.defineProperty;var n=(t,e,s)=>e in t?a(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var r=(t,e,s)=>n(t,typeof e!="symbol"?e+"":e,s);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("axios"),l=require("axios-retry"),c=require("phoenix"),i=t=>t&&typeof t=="object"&&"default"in t?t:{default:t},d=i(u),o=i(l);class h{constructor(e){r(this,"host");r(this,"apiKey");r(this,"userToken");r(this,"axiosClient");r(this,"socket");this.host=e.host,this.apiKey=e.apiKey,this.userToken=e.userToken||null,this.axiosClient=d.default.create({baseURL:this.host,headers:{Accept:"application/json","Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`,"X-Knock-User-Token":this.userToken,"X-Knock-Client":this.getKnockClientHeader()}}),typeof window<"u"&&(this.socket=new c.Socket(`${this.host.replace("http","ws")}/ws/v1`,{params:{user_token:this.userToken,api_key:this.apiKey}})),o.default(this.axiosClient,{retries:3,retryCondition:this.canRetryRequest,retryDelay:o.default.exponentialDelay})}async makeRequest(e){try{const s=await this.axiosClient(e);return{statusCode:s.status<300?"ok":"error",body:s.data,error:void 0,status:s.status}}catch(s){return console.error(s),{statusCode:"error",status:500,body:void 0,error:s}}}canRetryRequest(e){return o.default.isNetworkError(e)?!0:e.response?e.response.status>=500&&e.response.status<=599||e.response.status===429:!1}getKnockClientHeader(){return"Knock/ClientJS 0.19.1"}}exports.default=h;
2
2
  //# sourceMappingURL=api.js.map
package/dist/esm/api.mjs CHANGED
@@ -53,7 +53,7 @@ class k {
53
53
  return o.isNetworkError(e) ? !0 : e.response ? e.response.status >= 500 && e.response.status <= 599 || e.response.status === 429 : !1;
54
54
  }
55
55
  getKnockClientHeader() {
56
- return "Knock/ClientJS 0.18.7";
56
+ return "Knock/ClientJS 0.19.1";
57
57
  }
58
58
  }
59
59
  export {
@@ -5,20 +5,27 @@ export type ConditionalPreferenceSettings = {
5
5
  export type ChannelTypePreferences = {
6
6
  [_K in ChannelType]?: boolean | ConditionalPreferenceSettings;
7
7
  };
8
+ export type ChannelPreferences = {
9
+ [channel_id: string]: boolean | ConditionalPreferenceSettings;
10
+ };
8
11
  export type WorkflowPreferenceSetting = boolean | {
9
12
  channel_types: ChannelTypePreferences;
13
+ } | {
14
+ channels: ChannelPreferences;
10
15
  } | ConditionalPreferenceSettings;
11
16
  export type WorkflowPreferences = Partial<Record<string, WorkflowPreferenceSetting>>;
12
17
  export interface SetPreferencesProperties {
13
18
  workflows: WorkflowPreferences;
14
19
  categories: WorkflowPreferences;
15
20
  channel_types: ChannelTypePreferences;
21
+ channels: ChannelPreferences;
16
22
  }
17
23
  export interface PreferenceSet {
18
24
  id: string;
19
25
  categories: WorkflowPreferences | null;
20
26
  workflows: WorkflowPreferences | null;
21
27
  channel_types: ChannelTypePreferences | null;
28
+ channels: ChannelPreferences | null;
22
29
  }
23
30
  export interface PreferenceOptions {
24
31
  preferenceSet?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../../src/clients/preferences/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE1D,MAAM,MAAM,6BAA6B,GAAG;IAC1C,UAAU,EAAE,SAAS,EAAE,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;KAClC,EAAE,IAAI,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,6BAA6B;CAC9D,CAAC;A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BAAkB,CAAA;CAAE,GAChC,6BAA6B,CAAC;AAElC,MAAM,MAAM,mBAAmB,GAAG,OAAO,CACvC,MAAM,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAC1C,CAAC;AAEF,MAAM,WAAW,wBAAwB;IACvC,SAAS,EAAE,mBAAmB,CAAC;IAC/B,UAAU,EAAE,mBAAmB,CAAC;IAChC,aAAa,EAAE,sBAAsB,CAAC;IACtC,QAAQ,EAAE,kBAAkB,CAAC;CAC9B;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACvC,SAAS,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACtC,aAAa,EAAE,sBAAsB,GAAG,IAAI,CAAC;IAC7C,QAAQ,EAAE,kBAAkB,GAAG,IAAI,CAAC;CACrC;AAED,MAAM,WAAW,iBAAiB;IAChC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,qBAAsB,SAAQ,iBAAiB;IAC9D,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knocklabs/client",
3
- "version": "0.18.7",
3
+ "version": "0.19.1",
4
4
  "description": "The clientside library for interacting with Knock",
5
5
  "homepage": "https://github.com/knocklabs/javascript/tree/main/packages/client",
6
6
  "author": "@knocklabs",
@@ -8,9 +8,14 @@ export type ChannelTypePreferences = {
8
8
  [_K in ChannelType]?: boolean | ConditionalPreferenceSettings;
9
9
  };
10
10
 
11
+ export type ChannelPreferences = {
12
+ [channel_id: string]: boolean | ConditionalPreferenceSettings;
13
+ };
14
+
11
15
  export type WorkflowPreferenceSetting =
12
16
  | boolean
13
17
  | { channel_types: ChannelTypePreferences }
18
+ | { channels: ChannelPreferences }
14
19
  | ConditionalPreferenceSettings;
15
20
 
16
21
  export type WorkflowPreferences = Partial<
@@ -21,6 +26,7 @@ export interface SetPreferencesProperties {
21
26
  workflows: WorkflowPreferences;
22
27
  categories: WorkflowPreferences;
23
28
  channel_types: ChannelTypePreferences;
29
+ channels: ChannelPreferences;
24
30
  }
25
31
 
26
32
  export interface PreferenceSet {
@@ -28,6 +34,7 @@ export interface PreferenceSet {
28
34
  categories: WorkflowPreferences | null;
29
35
  workflows: WorkflowPreferences | null;
30
36
  channel_types: ChannelTypePreferences | null;
37
+ channels: ChannelPreferences | null;
31
38
  }
32
39
 
33
40
  export interface PreferenceOptions {