import * as subscribableevent from 'subscribableevent'; import * as socket_io_client from 'socket.io-client'; import * as _socket_io_component_emitter from '@socket.io/component-emitter'; import * as openapi_fetch from 'openapi-fetch'; import { ApiPaths } from '@engagespot/api-client'; type Notification = NonNullable[number]; type Channels = Exclude[number]['channel'], undefined>; type NotificationState = NonNullable; type EventCallback = (params: T) => void; type EventCallbackMap = { notificationReceive: EventCallback; notificationDelete: EventCallback; notificationRead: EventCallback; notificationSeen: EventCallback; notificationReadAll: EventCallback; notificationDeleteAll: EventCallback; notificationStateChange: EventCallback; }; type NotificationReceiveEvent = { notification: Notification; }; type NotificationDeleteEvent = { id: string; }; type NotificationClickEvent = { id: string; }; type NotificationSeenEvent = { unseenCount: number; }; type NotificationReadAll = void; type NotificationDeleteAll = void; type NotificationStateChange = { notification: Notification; }; type PermissionState = 'denied' | 'granted' | 'default' | 'unsupported'; type SetUserAttributes = Record; type DataRegion = 'us' | 'eu'; type InstanceOptions = { /** * Unique user identifier */ userId: string; /** * Unique tenant identifier */ tenantIdentifier?: string; /** * Engagespot API key */ apiKey: string; /** * signature for the user * @deprecated */ userSignature?: string; /** * Enabling secure mode enforces token based authentication for the front-end in-app inbox. * Production apps must enable secure mode to prevent unauthorised access to your users in-app inbox. * * https://docs.engagespot.co/docs/features/in-app-inbox/authentication/#enabling-the-secure-mode */ userToken?: string; /** * disable web push notifications. * Default is false */ disableWebPush?: boolean; /** * Allow non-HTTPS web push. Useful for development environments. * Default is false */ allowNonHttpsWebPush?: boolean; serviceWorkerRegistration?: ServiceWorkerRegistration; /** * Disables realtime messages * Default is false */ disableRtm?: boolean; /** * optional base URL for Engagespot server. * Should be set if the Engagespot server is hosted on a different domain. */ baseUrl?: string; /** * Enable debug mode * Default is false */ debug?: boolean; /** * Disabling this will prevent Engagespot from calling the `connect()` and `realTime()` services automatically. */ disableAutoStart?: boolean; /** * Region where the Engagespot data is hosted, the baseUrl will be automatically set based on the region. */ dataRegion?: DataRegion; }; type Instance = ReturnType; /** * * * @param {InstanceOptions} instanceOptions * @returns {Instance} */ declare function createInstance(instanceOptions: InstanceOptions): { apiKey: string; userId: string; app: { connect: () => Promise & { parameters: Omit<{ header: { 'X-ENGAGESPOT-API-KEY': string; 'X-ENGAGESPOT-USER-ID': string; 'X-ENGAGESPOT-DEVICE-ID': string; 'Authentication Bearer'?: string | undefined; 'X-ENGAGESPOT-USER-SIGNATURE'?: string | undefined; }; }, "header"> & { header?: Omit<{ 'X-ENGAGESPOT-API-KEY': string; 'X-ENGAGESPOT-USER-ID': string; 'X-ENGAGESPOT-DEVICE-ID': string; 'Authentication Bearer'?: string | undefined; 'X-ENGAGESPOT-USER-SIGNATURE'?: string | undefined; }, "X-ENGAGESPOT-USER-ID" | "X-ENGAGESPOT-API-KEY"> | undefined; }; }, { body: { browserType: string; deviceType: "browser" | "ios" | "android" | "react-native"; }; }, `${string}/${string}`>>; getInfo: () => Promise & { parameters: Omit<{ header: { 'X-ENGAGESPOT-API-KEY': string; 'X-ENGAGESPOT-USER-ID': string; 'X-ENGAGESPOT-DEVICE-ID': string; 'Authentication Bearer'?: string | undefined; 'X-ENGAGESPOT-USER-SIGNATURE'?: string | undefined; }; }, "header"> & { header?: Omit<{ 'X-ENGAGESPOT-API-KEY': string; 'X-ENGAGESPOT-USER-ID': string; 'X-ENGAGESPOT-DEVICE-ID': string; 'Authentication Bearer'?: string | undefined; 'X-ENGAGESPOT-USER-SIGNATURE'?: string | undefined; }, "X-ENGAGESPOT-USER-ID" | "X-ENGAGESPOT-API-KEY"> | undefined; }; }, { body: { browserType: string; deviceType: "browser" | "ios" | "android" | "react-native"; }; }, `${string}/${string}`>>; }; realTime: { connect: () => Promise | undefined>; disconnect: () => void; }; notification: { getByPage: ({ pageNo, limit, category, filter, tenantIdentifier, }?: { pageNo: number; limit: number; userIdentifier?: string | undefined; category?: string | undefined; tenantIdentifier?: string | undefined; filter?: "unread" | "read" | "interacted" | undefined; }) => Promise | null | undefined; category?: { id?: string | undefined; identifier?: string | undefined; name?: string | undefined; } | undefined; blocks?: ({ id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "button"; link?: string | undefined; externalLink?: boolean | undefined; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "box"; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "typography"; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "blue-dot"; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "rating-star"; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "card"; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "image"; src?: string | string[] | undefined; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "textarea"; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "input"; })[] | undefined; createdAt?: string | undefined; seenAt?: string | null | undefined; clickedAt?: string | null | undefined; state?: "unread" | "seen" | "clicked" | null | undefined; }[] | undefined; }; }; }; }; }, { params: { /** * Disabling this will prevent Engagespot from calling the `connect()` and `realTime()` services automatically. */ query: { pageNo: number; limit: number; category: string | undefined; tenantIdentifier: string | undefined; filter: "unread" | "read" | "interacted" | undefined; }; }; }, `${string}/${string}`>>; getById: (id: string | { id: string; }) => Promise | null | undefined; category?: { id?: string | undefined; identifier?: string | undefined; name?: string | undefined; } | undefined; blocks?: ({ id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "button"; link?: string | undefined; externalLink?: boolean | undefined; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "box"; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "typography"; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "blue-dot"; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "rating-star"; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "card"; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "image"; src?: string | string[] | undefined; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "textarea"; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "input"; })[] | undefined; createdAt?: string | undefined; seenAt?: string | null | undefined; clickedAt?: string | null | undefined; state?: "unread" | "seen" | "clicked" | null | undefined; }; }; }; }; }, { params: { path: { notificationId: string; }; }; }, `${string}/${string}`>>; markAsRead: (id: string | { id: string; }) => Promise>; remove: (id: string | { id: string; }) => Promise>; removeAll: () => Promise>; markAllAsSeen: ({ limit, page, }: { limit: number; page: number; }) => Promise>; markAllAsRead: () => Promise>; changeState: ({ id, state }: { id: string; state: string; }) => Promise | null | undefined; category?: { id?: string | undefined; identifier?: string | undefined; name?: string | undefined; } | undefined; blocks?: ({ id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "button"; link?: string | undefined; externalLink?: boolean | undefined; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "box"; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "typography"; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "blue-dot"; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "rating-star"; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "card"; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "image"; src?: string | string[] | undefined; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "textarea"; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "input"; })[] | undefined; createdAt?: string | undefined; seenAt?: string | null | undefined; clickedAt?: string | null | undefined; state?: "unread" | "seen" | "clicked" | null | undefined; } | undefined; }; }; }; }; }, { params: { path: { notificationId: string; }; }; body: { state: string; }; }, `${string}/${string}`>>; createNotification: (notification: { id: number; title: string; message?: string | null | undefined; icon?: string | null | undefined; url?: string | null | undefined; data?: Record | null | undefined; category?: { id?: string | undefined; identifier?: string | undefined; name?: string | undefined; } | undefined; blocks?: ({ id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "button"; link?: string | undefined; externalLink?: boolean | undefined; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "box"; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "typography"; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "blue-dot"; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "rating-star"; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "card"; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "image"; src?: string | string[] | undefined; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "textarea"; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "input"; })[] | undefined; createdAt?: string | undefined; seenAt?: string | null | undefined; clickedAt?: string | null | undefined; state?: "unread" | "seen" | "clicked" | null | undefined; }) => { id: number; title: string; message?: string | null | undefined; icon?: string | null | undefined; url?: string | null | undefined; data?: Record | null | undefined; category?: { id?: string | undefined; identifier?: string | undefined; name?: string | undefined; } | undefined; blocks?: ({ id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "button"; link?: string | undefined; externalLink?: boolean | undefined; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "box"; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "typography"; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "blue-dot"; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "rating-star"; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "card"; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "image"; src?: string | string[] | undefined; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "textarea"; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "input"; })[] | undefined; createdAt?: string | undefined; seenAt?: string | null | undefined; clickedAt?: string | null | undefined; state?: "unread" | "seen" | "clicked" | null | undefined; }; }; preferences: { getSupportedChannels: () => Promise<{ readonly inApp: { readonly name: "In-App"; readonly id: "inApp"; }; readonly webPush: { readonly name: "Web Push"; readonly id: "webPush"; }; readonly email: { readonly name: "Email"; readonly id: "email"; }; readonly mobilePush: { readonly name: "Mobile Push"; readonly id: "mobilePush"; }; readonly sms: { readonly name: "SMS"; readonly id: "sms"; }; readonly whatsapp: { readonly name: "WhatsApp"; readonly id: "whatsapp"; }; readonly slack: { readonly name: "Slack"; readonly id: "slack"; }; readonly chat: { readonly name: "Chat"; readonly id: "chat"; }; }>; getPreferences: () => Promise | undefined, `${string}/${string}`>>; setPreferences: (preferences: { categoryId?: number | undefined; channels?: { channel?: "inApp" | "webPush" | "email" | "mobilePush" | "sms" | "whatsapp" | "webhook" | "discord" | "slack" | "chat" | undefined; enabled?: boolean | undefined; }[] | undefined; }[]) => Promise>; setProfileAttributes: (attributes: SetUserAttributes) => Promise; getCategories: () => Promise | undefined, `${string}/${string}`>>; }; events: { notificationReceive: subscribableevent.default<(params: { notification: { id: number; title: string; message?: string | null | undefined; icon?: string | null | undefined; url?: string | null | undefined; data?: Record | null | undefined; category?: { id?: string | undefined; identifier?: string | undefined; name?: string | undefined; } | undefined; blocks?: ({ id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "button"; link?: string | undefined; externalLink?: boolean | undefined; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "box"; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "typography"; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "blue-dot"; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "rating-star"; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "card"; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "image"; src?: string | string[] | undefined; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "textarea"; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "input"; })[] | undefined; createdAt?: string | undefined; seenAt?: string | null | undefined; clickedAt?: string | null | undefined; state?: "unread" | "seen" | "clicked" | null | undefined; }; }) => void>; notificationDelete: subscribableevent.default<(params: { id: string; }) => void>; notificationRead: subscribableevent.default<(params: { id: string; }) => void>; notificationSeen: subscribableevent.default<(params: { unseenCount: number; }) => void>; notificationReadAll: subscribableevent.default<(params: void) => void>; /** * optional base URL for Engagespot server. * Should be set if the Engagespot server is hosted on a different domain. */ notificationDeleteAll: subscribableevent.default<(params: void) => void>; notificationStateChange: subscribableevent.default<(params: { notification: { id: number; title: string; message?: string | null | undefined; icon?: string | null | undefined; url?: string | null | undefined; data?: Record | null | undefined; category?: { id?: string | undefined; identifier?: string | undefined; name?: string | undefined; } | undefined; blocks?: ({ id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "button"; link?: string | undefined; externalLink?: boolean | undefined; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "box"; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "typography"; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "blue-dot"; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "rating-star"; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "card"; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "image"; src?: string | string[] | undefined; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "textarea"; } | { id: string; text?: string | undefined; variant: "default" | "primary" | "secondary"; type: "input"; })[] | undefined; createdAt?: string | undefined; seenAt?: string | null | undefined; clickedAt?: string | null | undefined; state?: "unread" | "seen" | "clicked" | null | undefined; }; }) => void>; webPushPermissionChange: subscribableevent.default<(params: { permission: PermissionState; }) => void>; }; webPush: { connect: () => Promise; isSupported: () => boolean; getRegistrationState: () => "unsupported" | NotificationPermission; clearWebPushSubscription: () => Promise; subscribe(): Promise; }; }; declare const API_BASE_URLS: Record; export { API_BASE_URLS, type Channels as EngagespotChannels, type Notification as EngagespotNotification, type NotificationState as EngagespotNotificationState, type PermissionState as EngagespotWebPushPermissionState, type EventCallbackMap, type Instance, type InstanceOptions, createInstance };