Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@knocklabs/client

Package Overview
Dependencies
Maintainers
1
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@knocklabs/client - npm Package Compare versions

Comparing version 0.10.13 to 0.11.0-rc.0

dist/cjs/clients/in-app-messages/channel-client.js

11

CHANGELOG.md
# Changelog
## 0.11.0-rc.0
### Minor Changes
- f442962: feat: add in app messages client, hooks, provider, and components
### Patch Changes
- Updated dependencies [f442962]
- @knocklabs/types@0.1.5-rc.0
## 0.10.13

@@ -4,0 +15,0 @@

2

dist/cjs/clients/users/index.js

@@ -1,2 +0,2 @@

"use strict";var c=Object.defineProperty;var u=(s,e,t)=>e in s?c(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var a=(s,e,t)=>u(s,typeof e!="symbol"?e+"":e,t);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r="default";class l{constructor(e){a(this,"instance");this.instance=e}async get(){const e=await this.instance.client().makeRequest({method:"GET",url:`/v1/users/${this.instance.userId}`});return this.handleResponse(e)}async identify(e={}){const t=await this.instance.client().makeRequest({method:"PUT",url:`/v1/users/${this.instance.userId}`,params:e});return this.handleResponse(t)}async getAllPreferences(){const e=await this.instance.client().makeRequest({method:"GET",url:`/v1/users/${this.instance.userId}/preferences`});return this.handleResponse(e)}async getPreferences(e={}){const t=e.preferenceSet||r,n=await this.instance.client().makeRequest({method:"GET",url:`/v1/users/${this.instance.userId}/preferences/${t}`,params:{tenant:e.tenant}});return this.handleResponse(n)}async setPreferences(e,t={}){const n=t.preferenceSet||r,i=await this.instance.client().makeRequest({method:"PUT",url:`/v1/users/${this.instance.userId}/preferences/${n}`,data:e});return this.handleResponse(i)}async getChannelData(e){const t=await this.instance.client().makeRequest({method:"GET",url:`/v1/users/${this.instance.userId}/channel_data/${e.channelId}`});return this.handleResponse(t)}async setChannelData({channelId:e,channelData:t}){const n=await this.instance.client().makeRequest({method:"PUT",url:`/v1/users/${this.instance.userId}/channel_data/${e}`,data:{data:t}});return this.handleResponse(n)}handleResponse(e){if(e.statusCode==="error")throw new Error(e.error||e.body);return e.body}}exports.default=l;
"use strict";var c=Object.defineProperty;var u=(n,e,t)=>e in n?c(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var r=(n,e,t)=>u(n,typeof e!="symbol"?e+"":e,t);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i="default";class l{constructor(e){r(this,"instance");this.instance=e}async get(){const e=await this.instance.client().makeRequest({method:"GET",url:`/v1/users/${this.instance.userId}`});return this.handleResponse(e)}async identify(e={}){const t=await this.instance.client().makeRequest({method:"PUT",url:`/v1/users/${this.instance.userId}`,params:e});return this.handleResponse(t)}async getAllPreferences(){const e=await this.instance.client().makeRequest({method:"GET",url:`/v1/users/${this.instance.userId}/preferences`});return this.handleResponse(e)}async getPreferences(e={}){const t=e.preferenceSet||i,s=await this.instance.client().makeRequest({method:"GET",url:`/v1/users/${this.instance.userId}/preferences/${t}`,params:{tenant:e.tenant}});return this.handleResponse(s)}async setPreferences(e,t={}){const s=t.preferenceSet||i,a=await this.instance.client().makeRequest({method:"PUT",url:`/v1/users/${this.instance.userId}/preferences/${s}`,data:e});return this.handleResponse(a)}async getChannelData(e){const t=await this.instance.client().makeRequest({method:"GET",url:`/v1/users/${this.instance.userId}/channel_data/${e.channelId}`});return this.handleResponse(t)}async setChannelData({channelId:e,channelData:t}){const s=await this.instance.client().makeRequest({method:"PUT",url:`/v1/users/${this.instance.userId}/channel_data/${e}`,data:{data:t}});return this.handleResponse(s)}async getInAppMessages({channelId:e,messageType:t,params:s}){const a=await this.instance.client().makeRequest({method:"GET",url:`/v1/users/${this.instance.userId}/in-app-messages/${e}/${t}`,params:s});return this.handleResponse(a)}handleResponse(e){if(e.statusCode==="error")throw new Error(e.error||e.body);return e.body}}exports.default=l;
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("./clients/feed/index.js"),u=require("./knock.js"),r=require("./clients/objects/constants.js"),e=require("./networkStatus.js"),s=require("./clients/feed/feed.js");exports.FeedClient=t.default;exports.default=u.default;exports.TENANT_OBJECT_COLLECTION=r.TENANT_OBJECT_COLLECTION;exports.NetworkStatus=e.NetworkStatus;exports.isRequestInFlight=e.isRequestInFlight;exports.Feed=s.default;
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("./clients/feed/index.js"),s=require("./knock.js"),n=require("./clients/objects/constants.js"),i=require("./clients/in-app-messages/channel-client.js"),r=require("./clients/in-app-messages/message-client.js"),e=require("./networkStatus.js"),u=require("./clients/feed/feed.js");exports.FeedClient=t.default;exports.default=s.default;exports.TENANT_OBJECT_COLLECTION=n.TENANT_OBJECT_COLLECTION;exports.InAppMessagesChannelClient=i.InAppMessagesChannelClient;exports.InAppMessagesClient=r.InAppMessagesClient;exports.NetworkStatus=e.NetworkStatus;exports.isRequestInFlight=e.isRequestInFlight;exports.Feed=u.default;
//# sourceMappingURL=index.js.map
import { ChannelType } from '@knocklabs/types';
export type ChannelTypePreferences = {
[K in ChannelType]?: boolean;
[_K in ChannelType]?: boolean;
};

@@ -6,0 +6,0 @@ export type WorkflowPreferenceSetting = boolean | {

import { GenericData } from '@knocklabs/types';
import { ChannelData, User } from '../../interfaces';
import { default as Knock } from '../../knock';
import { InAppMessagesResponse } from '../in-app-messages';
import { GetPreferencesOptions, PreferenceOptions, PreferenceSet, SetPreferencesProperties } from '../preferences/interfaces';
import { GetChannelDataInput, SetChannelDataInput } from './interfaces';
import { GetChannelDataInput, GetInAppMessagesInput, SetChannelDataInput } from './interfaces';

@@ -17,2 +18,3 @@ declare class UserClient {

setChannelData<T = GenericData>({ channelId, channelData, }: SetChannelDataInput): Promise<ChannelData<T>>;
getInAppMessages<TContent extends GenericData = GenericData, TData extends GenericData = GenericData>({ channelId, messageType, params }: GetInAppMessagesInput): Promise<InAppMessagesResponse<TContent, TData>>;
private handleResponse;

@@ -19,0 +21,0 @@ }

import { GenericData } from '@knocklabs/types';
import { InAppMessagesClientOptions } from '../in-app-messages/types';

@@ -10,2 +11,7 @@ export interface SetChannelDataInput {

}
export interface GetInAppMessagesInput {
channelId: string;
messageType: string;
params: InAppMessagesClientOptions;
}
//# sourceMappingURL=interfaces.d.ts.map

@@ -15,2 +15,3 @@ import { default as FeedClient, Feed } from './clients/feed';

export * from './clients/messages';
export * from './clients/in-app-messages';
export * from './clients/messages/interfaces';

@@ -17,0 +18,0 @@ export * from './networkStatus';

{
"name": "@knocklabs/client",
"version": "0.10.13",
"version": "0.11.0-rc.0",
"description": "The clientside library for interacting with Knock",

@@ -50,7 +50,7 @@ "homepage": "https://github.com/knocklabs/javascript/tree/main/packages/client",

"devDependencies": {
"@babel/cli": "^7.25.6",
"@babel/core": "^7.20.0",
"@babel/cli": "^7.25.7",
"@babel/core": "^7.25.7",
"@babel/plugin-proposal-class-properties": "^7.16.7",
"@babel/plugin-proposal-object-rest-spread": "^7.16.7",
"@babel/plugin-transform-runtime": "^7.16.7",
"@babel/plugin-transform-runtime": "^7.25.4",
"@babel/preset-env": "^7.16.7",

@@ -60,3 +60,3 @@ "@babel/preset-typescript": "^7.16.7",

"@typescript-eslint/eslint-plugin": "^6.20.0",
"@typescript-eslint/parser": "^6.20.0",
"@typescript-eslint/parser": "^8.8.1",
"cross-env": "^7.0.3",

@@ -68,4 +68,4 @@ "crypto": "^1.0.1",

"rimraf": "^6.0.1",
"rollup": "^4.21.0",
"typescript": "^5.5.4",
"rollup": "^4.22.5",
"typescript": "^5.6.2",
"vite": "^5.0.0",

@@ -76,8 +76,10 @@ "vitest": "^2.0.5"

"@babel/runtime": "^7.25.6",
"@knocklabs/types": "^0.1.4",
"@knocklabs/types": "^0.1.5-rc.0",
"@tanstack/store": "^0.5.5",
"@types/phoenix": "^1.5.4",
"axios": "^1.7.4",
"axios-retry": "^3.1.9",
"axios-retry": "^4.5.0",
"eventemitter2": "^6.4.5",
"jwt-decode": "^4.0.0",
"nanoid": "^3.0.0",
"phoenix": "1.6.16",

@@ -84,0 +86,0 @@ "zustand": "^3.7.2"

import { ChannelType } from "@knocklabs/types";
export type ChannelTypePreferences = {
[K in ChannelType]?: boolean;
[_K in ChannelType]?: boolean;
};

@@ -6,0 +6,0 @@

@@ -6,2 +6,3 @@ import { GenericData } from "@knocklabs/types";

import Knock from "../../knock";
import { InAppMessagesResponse } from "../in-app-messages";
import {

@@ -14,3 +15,7 @@ GetPreferencesOptions,

import { GetChannelDataInput, SetChannelDataInput } from "./interfaces";
import {
GetChannelDataInput,
GetInAppMessagesInput,
SetChannelDataInput,
} from "./interfaces";

@@ -105,2 +110,15 @@ const DEFAULT_PREFERENCE_SET_ID = "default";

async getInAppMessages<
TContent extends GenericData = GenericData,
TData extends GenericData = GenericData,
>({ channelId, messageType, params }: GetInAppMessagesInput) {
const result = await this.instance.client().makeRequest({
method: "GET",
url: `/v1/users/${this.instance.userId}/in-app-messages/${channelId}/${messageType}`,
params,
});
return this.handleResponse<InAppMessagesResponse<TContent, TData>>(result);
}
private handleResponse<T>(response: ApiResponse) {

@@ -107,0 +125,0 @@ if (response.statusCode === "error") {

import { GenericData } from "@knocklabs/types";
import { InAppMessagesClientOptions } from "../in-app-messages/types";
export interface SetChannelDataInput {

@@ -11,1 +13,7 @@ channelId: string;

}
export interface GetInAppMessagesInput {
channelId: string;
messageType: string;
params: InAppMessagesClientOptions;
}

@@ -15,2 +15,3 @@ import FeedClient, { Feed } from "./clients/feed";

export * from "./clients/messages";
export * from "./clients/in-app-messages";
export * from "./clients/messages/interfaces";

@@ -17,0 +18,0 @@ export * from "./networkStatus";

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc