@knocklabs/client
Advanced tools
Comparing version 0.10.9 to 0.10.10
# Changelog | ||
## 0.10.10 | ||
### Patch Changes | ||
- a4d520c: chore: update generic types | ||
- Updated dependencies [a4d520c] | ||
- @knocklabs/types@0.1.4 | ||
## 0.10.9 | ||
@@ -4,0 +12,0 @@ |
@@ -0,1 +1,2 @@ | ||
import { GenericData } from "@knocklabs/types"; | ||
import { StoreApi } from "zustand"; | ||
@@ -34,12 +35,12 @@ import Knock from "../../knock"; | ||
getState(): FeedStoreState; | ||
markAsSeen(itemOrItems: FeedItemOrItems): Promise<import("../messages/interfaces").Message<any>[]>; | ||
markAsSeen(itemOrItems: FeedItemOrItems): Promise<import("../messages/interfaces").Message<GenericData>[]>; | ||
markAllAsSeen(): Promise<import("../..").BulkOperation>; | ||
markAsUnseen(itemOrItems: FeedItemOrItems): Promise<import("../messages/interfaces").Message<any>[]>; | ||
markAsRead(itemOrItems: FeedItemOrItems): Promise<import("../messages/interfaces").Message<any>[]>; | ||
markAsUnseen(itemOrItems: FeedItemOrItems): Promise<import("../messages/interfaces").Message<GenericData>[]>; | ||
markAsRead(itemOrItems: FeedItemOrItems): Promise<import("../messages/interfaces").Message<GenericData>[]>; | ||
markAllAsRead(): Promise<import("../..").BulkOperation>; | ||
markAsUnread(itemOrItems: FeedItemOrItems): Promise<import("../messages/interfaces").Message<any>[]>; | ||
markAsInteracted(itemOrItems: FeedItemOrItems): Promise<import("../messages/interfaces").Message<any>[]>; | ||
markAsArchived(itemOrItems: FeedItemOrItems): Promise<import("../messages/interfaces").Message<any>[]>; | ||
markAsUnread(itemOrItems: FeedItemOrItems): Promise<import("../messages/interfaces").Message<GenericData>[]>; | ||
markAsInteracted(itemOrItems: FeedItemOrItems): Promise<import("../messages/interfaces").Message<GenericData>[]>; | ||
markAsArchived(itemOrItems: FeedItemOrItems): Promise<import("../messages/interfaces").Message<GenericData>[]>; | ||
markAllAsArchived(): Promise<import("../..").BulkOperation>; | ||
markAsUnarchived(itemOrItems: FeedItemOrItems): Promise<import("../messages/interfaces").Message<any>[]>; | ||
markAsUnarchived(itemOrItems: FeedItemOrItems): Promise<import("../messages/interfaces").Message<GenericData>[]>; | ||
fetch(options?: FetchFeedOptions): Promise<{ | ||
@@ -46,0 +47,0 @@ status: "ok" | "error"; |
@@ -70,3 +70,3 @@ import { GenericData, PageInfo } from "@knocklabs/types"; | ||
} | ||
export interface FeedResponse<T = any> { | ||
export interface FeedResponse<T = GenericData> { | ||
entries: FeedItem<T>[]; | ||
@@ -73,0 +73,0 @@ meta: FeedMetadata; |
@@ -1,2 +0,2 @@ | ||
import { PageInfo } from "@knocklabs/types"; | ||
import { GenericData, PageInfo } from "@knocklabs/types"; | ||
import { NetworkStatus } from "../../networkStatus"; | ||
@@ -26,3 +26,3 @@ import { FeedItem, FeedMetadata, FeedResponse } from "./interfaces"; | ||
export type BindableFeedEvent = FeedEvent | "items.received.*" | "items.*"; | ||
export interface FeedEventPayload<T = any> { | ||
export interface FeedEventPayload<T = GenericData> { | ||
event: Omit<FeedEvent, "messages.new">; | ||
@@ -29,0 +29,0 @@ items: FeedItem<T>[]; |
@@ -0,1 +1,2 @@ | ||
import { GenericData } from "@knocklabs/types"; | ||
import { RecipientRef } from "../.."; | ||
@@ -9,3 +10,3 @@ export type MessageDeliveryStatus = "queued" | "sent" | "delivered" | "delivery_attempted" | "undelivered" | "not_sent"; | ||
export type MessageEngagementStatus = "seen" | "read" | "interacted" | "archived"; | ||
export interface Message<T = any> { | ||
export interface Message<T = GenericData> { | ||
id: string; | ||
@@ -12,0 +13,0 @@ channel_id: string; |
@@ -0,1 +1,2 @@ | ||
import { GenericData } from "@knocklabs/types"; | ||
import { ChannelData } from "../../interfaces"; | ||
@@ -12,3 +13,3 @@ import Knock from "../../knock"; | ||
channelId: string; | ||
data: any; | ||
data: GenericData; | ||
}; | ||
@@ -18,3 +19,3 @@ declare class ObjectClient { | ||
constructor(instance: Knock); | ||
getChannelData<T = any>({ collection, objectId, channelId, }: GetChannelDataInput): Promise<ChannelData<T>>; | ||
getChannelData<T = GenericData>({ collection, objectId, channelId, }: GetChannelDataInput): Promise<ChannelData<T>>; | ||
setChannelData({ objectId, collection, channelId, data, }: SetChannelDataInput): Promise<unknown>; | ||
@@ -21,0 +22,0 @@ private handleResponse; |
import { ChannelType } from "@knocklabs/types"; | ||
import Knock from "../../knock"; | ||
import { ChannelTypePreferences, PreferenceOptions, SetPreferencesProperties, WorkflowPreferenceSetting, WorkflowPreferences, PreferenceSet } from "./interfaces"; | ||
import { ChannelTypePreferences, PreferenceOptions, PreferenceSet, SetPreferencesProperties, WorkflowPreferenceSetting, WorkflowPreferences } from "./interfaces"; | ||
declare class Preferences { | ||
@@ -5,0 +5,0 @@ private instance; |
@@ -0,1 +1,2 @@ | ||
import { GenericData } from "@knocklabs/types"; | ||
import { ChannelData, User } from "../../interfaces"; | ||
@@ -9,8 +10,8 @@ import Knock from "../../knock"; | ||
get(): Promise<User>; | ||
identify(props?: Record<string, any>): Promise<User>; | ||
identify(props?: GenericData): Promise<User>; | ||
getAllPreferences(): Promise<PreferenceSet[]>; | ||
getPreferences(options?: GetPreferencesOptions): Promise<PreferenceSet>; | ||
setPreferences(preferenceSet: SetPreferencesProperties, options?: PreferenceOptions): Promise<PreferenceSet>; | ||
getChannelData<T = any>(params: GetChannelDataInput): Promise<ChannelData<T>>; | ||
setChannelData<T = any>({ channelId, channelData, }: SetChannelDataInput): Promise<ChannelData<T>>; | ||
getChannelData<T = GenericData>(params: GetChannelDataInput): Promise<ChannelData<T>>; | ||
setChannelData<T = GenericData>({ channelId, channelData, }: SetChannelDataInput): Promise<ChannelData<T>>; | ||
private handleResponse; | ||
@@ -17,0 +18,0 @@ } |
@@ -0,4 +1,5 @@ | ||
import { GenericData } from "@knocklabs/types"; | ||
export interface SetChannelDataInput { | ||
channelId: string; | ||
channelData: Record<string, any>; | ||
channelData: GenericData; | ||
} | ||
@@ -5,0 +6,0 @@ export interface GetChannelDataInput { |
import { GenericData } from "@knocklabs/types"; | ||
import { JwtPayload } from "jwt-decode"; | ||
export type LogLevel = "debug"; | ||
@@ -36,7 +37,7 @@ export interface KnockOptions { | ||
} | ||
export interface ChannelData<T = any> { | ||
export interface ChannelData<T = GenericData> { | ||
channel_id: string; | ||
data: T; | ||
} | ||
export type UserTokenExpiringCallback = (currentToken: string, decodedToken: any) => Promise<string | void>; | ||
export type UserTokenExpiringCallback = (currentToken: string, decodedToken: JwtPayload) => Promise<string | void>; | ||
export interface AuthenticateOptions { | ||
@@ -43,0 +44,0 @@ onUserTokenExpiring?: UserTokenExpiringCallback; |
{ | ||
"name": "@knocklabs/client", | ||
"version": "0.10.9", | ||
"version": "0.10.10", | ||
"description": "The clientside library for interacting with Knock", | ||
@@ -36,3 +36,3 @@ "homepage": "https://github.com/knocklabs/javascript/tree/main/packages/client", | ||
"dev": "tsc && vite build --watch --emptyOutDir false", | ||
"lint": "eslint \"src/**/*.+(ts|js|tsx)\"", | ||
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", | ||
"format": "prettier \"src/**/*.{js,ts,tsx}\" --write", | ||
@@ -42,6 +42,5 @@ "format:check": "prettier \"src/**/*.{js,ts,tsx}\" --check", | ||
"test:watch": "vitest", | ||
"type:check": "tsc --noEmit", | ||
"coverage": "vitest run --coverage", | ||
"clean": "rimraf dist", | ||
"type-check": "tsc --noEmit", | ||
"type-check:watch": "npm run type-check -- --watch", | ||
"build": "yarn clean && yarn build:cjs && yarn build:esm", | ||
@@ -61,7 +60,7 @@ "build:esm": "BUILD_TARGET=esm; vite build", | ||
"@types/jsonwebtoken": "^9.0.5", | ||
"@typescript-eslint/eslint-plugin": "^6.10.0", | ||
"@typescript-eslint/parser": "^6.10.0", | ||
"@typescript-eslint/eslint-plugin": "^6.20.0", | ||
"@typescript-eslint/parser": "^6.20.0", | ||
"cross-env": "^7.0.3", | ||
"crypto": "^1.0.1", | ||
"eslint": "^8.53.0", | ||
"eslint": "^8.56.0", | ||
"jsonwebtoken": "^9.0.2", | ||
@@ -71,3 +70,3 @@ "prettier": "^3.1.0", | ||
"rollup": "^2.46.0", | ||
"typescript": "^5.2.2", | ||
"typescript": "^5.3.3", | ||
"vite": "^5.0.0", | ||
@@ -78,3 +77,3 @@ "vitest": "^1.2.2" | ||
"@babel/runtime": "^7.23.9", | ||
"@knocklabs/types": "^0.1.3", | ||
"@knocklabs/types": "^0.1.4", | ||
"@types/phoenix": "^1.5.4", | ||
@@ -81,0 +80,0 @@ "axios": "^1.6.0", |
@@ -53,3 +53,2 @@ import axios, { AxiosError, AxiosInstance, AxiosRequestConfig } from "axios"; | ||
// @ts-ignore | ||
axiosRetry(this.axiosClient, { | ||
@@ -56,0 +55,0 @@ retries: 3, |
@@ -0,1 +1,2 @@ | ||
import { GenericData } from "@knocklabs/types"; | ||
import EventEmitter from "eventemitter2"; | ||
@@ -45,5 +46,5 @@ import { Channel } from "phoenix"; | ||
private disconnectTimer: ReturnType<typeof setTimeout> | null = null; | ||
private hasSubscribedToRealTimeUpdates: Boolean = false; | ||
private hasSubscribedToRealTimeUpdates: boolean = false; | ||
private visibilityChangeHandler: () => void = () => {}; | ||
private visibilityChangeListenerConnected: Boolean = false; | ||
private visibilityChangeListenerConnected: boolean = false; | ||
@@ -663,3 +664,3 @@ // The raw store instance, used for binding in React and other environments | ||
private broadcastOverChannel(type: string, payload: any) { | ||
private broadcastOverChannel(type: string, payload: GenericData) { | ||
// The broadcastChannel may not be available in non-browser environments | ||
@@ -666,0 +667,0 @@ if (!this.broadcastChannel) { |
@@ -97,3 +97,3 @@ import { GenericData, PageInfo } from "@knocklabs/types"; | ||
export interface FeedResponse<T = any> { | ||
export interface FeedResponse<T = GenericData> { | ||
entries: FeedItem<T>[]; | ||
@@ -100,0 +100,0 @@ meta: FeedMetadata; |
@@ -0,1 +1,2 @@ | ||
import { GenericData } from "@knocklabs/types"; | ||
import create from "zustand/vanilla"; | ||
@@ -56,3 +57,3 @@ | ||
const items = options.shouldAppend | ||
? processItems(state.items.concat(entries)) | ||
? processItems(state.items.concat(entries as FeedItem<GenericData>[])) | ||
: entries; | ||
@@ -59,0 +60,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { PageInfo } from "@knocklabs/types"; | ||
import { GenericData, PageInfo } from "@knocklabs/types"; | ||
@@ -54,3 +54,3 @@ import { NetworkStatus } from "../../networkStatus"; | ||
export interface FeedEventPayload<T = any> { | ||
export interface FeedEventPayload<T = GenericData> { | ||
event: Omit<FeedEvent, "messages.new">; | ||
@@ -57,0 +57,0 @@ items: FeedItem<T>[]; |
@@ -78,3 +78,3 @@ import { ApiResponse } from "../../api"; | ||
private handleResponse<T = any>(response: ApiResponse) { | ||
private handleResponse<T = unknown>(response: ApiResponse) { | ||
if (response.statusCode === "error") { | ||
@@ -81,0 +81,0 @@ if (response.error?.response?.status < 500) { |
@@ -0,1 +1,3 @@ | ||
import { GenericData } from "@knocklabs/types"; | ||
import { RecipientRef } from "../.."; | ||
@@ -23,3 +25,3 @@ | ||
export interface Message<T = any> { | ||
export interface Message<T = GenericData> { | ||
id: string; | ||
@@ -26,0 +28,0 @@ channel_id: string; |
@@ -0,1 +1,3 @@ | ||
import { GenericData } from "@knocklabs/types"; | ||
import { ApiResponse } from "../../api"; | ||
@@ -15,3 +17,3 @@ import { ChannelData } from "../../interfaces"; | ||
channelId: string; | ||
data: any; | ||
data: GenericData; | ||
}; | ||
@@ -25,3 +27,3 @@ | ||
} | ||
async getChannelData<T = any>({ | ||
async getChannelData<T = GenericData>({ | ||
collection, | ||
@@ -28,0 +30,0 @@ objectId, |
import { ChannelType } from "@knocklabs/types"; | ||
import { ApiResponse } from "../../api"; | ||
import Knock from "../../knock"; | ||
import { | ||
ChannelTypePreferences, | ||
PreferenceOptions, | ||
PreferenceSet, | ||
SetPreferencesProperties, | ||
WorkflowPreferenceSetting, | ||
WorkflowPreferences, | ||
PreferenceSet, | ||
} from "./interfaces"; | ||
@@ -12,0 +14,0 @@ |
@@ -0,1 +1,3 @@ | ||
import { GenericData } from "@knocklabs/types"; | ||
import { ApiResponse } from "../../api"; | ||
@@ -31,3 +33,3 @@ import { ChannelData, User } from "../../interfaces"; | ||
async identify(props: Record<string, any> = {}) { | ||
async identify(props: GenericData = {}) { | ||
const result = await this.instance.client().makeRequest({ | ||
@@ -80,3 +82,3 @@ method: "PUT", | ||
async getChannelData<T = any>(params: GetChannelDataInput) { | ||
async getChannelData<T = GenericData>(params: GetChannelDataInput) { | ||
const result = await this.instance.client().makeRequest({ | ||
@@ -90,3 +92,3 @@ method: "GET", | ||
async setChannelData<T = any>({ | ||
async setChannelData<T = GenericData>({ | ||
channelId, | ||
@@ -93,0 +95,0 @@ channelData, |
@@ -0,4 +1,6 @@ | ||
import { GenericData } from "@knocklabs/types"; | ||
export interface SetChannelDataInput { | ||
channelId: string; | ||
channelData: Record<string, any>; | ||
channelData: GenericData; | ||
} | ||
@@ -5,0 +7,0 @@ |
import { GenericData } from "@knocklabs/types"; | ||
import { JwtPayload } from "jwt-decode"; | ||
@@ -41,3 +42,3 @@ export type LogLevel = "debug"; | ||
export interface ChannelData<T = any> { | ||
export interface ChannelData<T = GenericData> { | ||
channel_id: string; | ||
@@ -49,3 +50,3 @@ data: T; | ||
currentToken: string, | ||
decodedToken: any, | ||
decodedToken: JwtPayload, | ||
) => Promise<string | void>; | ||
@@ -52,0 +53,0 @@ |
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
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
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
331023
3520
Updated@knocklabs/types@^0.1.4