@livechatta/sdk 0.0.0-stage → 1.0.0
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 +218 -0
- package/LICENSE +21 -0
- package/README.md +2558 -2
- package/bin/chatta.mjs +7 -0
- package/bin/lib/cli.d.mts +46 -0
- package/bin/lib/cli.mjs +2088 -0
- package/dist/cjs/livechatta.cjs.js +7258 -0
- package/dist/cjs/livechatta.cjs.js.map +1 -0
- package/dist/cjs/livechatta.cjs.min.js +2 -0
- package/dist/cjs/livechatta.cjs.min.js.map +1 -0
- package/dist/esm/livechatta.esm.js +7077 -0
- package/dist/esm/livechatta.esm.js.map +1 -0
- package/dist/esm/livechatta.esm.min.js +2 -0
- package/dist/esm/livechatta.esm.min.js.map +1 -0
- package/dist/platforms/android/LiveChattaClient.kt +367 -0
- package/dist/platforms/android/LiveChattaHttpAPI.kt +2630 -0
- package/dist/platforms/android/LiveChattaJson.kt +83 -0
- package/dist/platforms/android/LiveChattaModels.kt +22805 -0
- package/dist/platforms/android/LiveChattaSentFrom.kt +30 -0
- package/dist/platforms/android/LiveChattaSocketAPI.kt +2113 -0
- package/dist/platforms/android/LiveChattaTyped.kt +239 -0
- package/dist/platforms/android/LiveChattaWebView.kt +158 -0
- package/dist/platforms/angular/livechatta-bridge.service.d.ts +35 -0
- package/dist/platforms/angular/livechatta-bridge.service.js +1 -0
- package/dist/platforms/angular/livechatta-bridge.service.js.map +1 -0
- package/dist/platforms/angular/livechatta-embed.component.d.ts +46 -0
- package/dist/platforms/angular/livechatta-embed.component.js +1 -0
- package/dist/platforms/angular/livechatta-embed.component.js.map +1 -0
- package/dist/platforms/angular/livechatta.service.d.ts +66 -0
- package/dist/platforms/angular/livechatta.service.js +1 -0
- package/dist/platforms/angular/livechatta.service.js.map +1 -0
- package/dist/platforms/capacitor/CapacitorBridge.d.ts +27 -0
- package/dist/platforms/capacitor/CapacitorBridge.js +1 -0
- package/dist/platforms/capacitor/CapacitorBridge.js.map +1 -0
- package/dist/platforms/capacitor/CapacitorDeepLinks.d.ts +23 -0
- package/dist/platforms/capacitor/CapacitorDeepLinks.js +1 -0
- package/dist/platforms/capacitor/CapacitorDeepLinks.js.map +1 -0
- package/dist/platforms/capacitor/CapacitorPermissions.d.ts +29 -0
- package/dist/platforms/capacitor/CapacitorPermissions.js +1 -0
- package/dist/platforms/capacitor/CapacitorPermissions.js.map +1 -0
- package/dist/platforms/capacitor/CapacitorPush.d.ts +33 -0
- package/dist/platforms/capacitor/CapacitorPush.js +1 -0
- package/dist/platforms/capacitor/CapacitorPush.js.map +1 -0
- package/dist/platforms/capacitor/index.d.ts +24 -0
- package/dist/platforms/capacitor/index.js +1 -0
- package/dist/platforms/capacitor/index.js.map +1 -0
- package/dist/platforms/flutter/livechatta_client.dart +359 -0
- package/dist/platforms/flutter/livechatta_http_api.dart +1942 -0
- package/dist/platforms/flutter/livechatta_json.dart +57 -0
- package/dist/platforms/flutter/livechatta_models.dart +23531 -0
- package/dist/platforms/flutter/livechatta_sent_from.dart +35 -0
- package/dist/platforms/flutter/livechatta_socket_api.dart +1504 -0
- package/dist/platforms/flutter/livechatta_typed.dart +234 -0
- package/dist/platforms/flutter/livechatta_webview.dart +190 -0
- package/dist/platforms/ios/LiveChattaClient.swift +374 -0
- package/dist/platforms/ios/LiveChattaHttpAPI.swift +2431 -0
- package/dist/platforms/ios/LiveChattaJSON.swift +84 -0
- package/dist/platforms/ios/LiveChattaModels.swift +27050 -0
- package/dist/platforms/ios/LiveChattaSentFrom.swift +32 -0
- package/dist/platforms/ios/LiveChattaSocketAPI.swift +1446 -0
- package/dist/platforms/ios/LiveChattaTyped.swift +268 -0
- package/dist/platforms/ios/LiveChattaWebView.swift +191 -0
- package/dist/platforms/nuxt/LiveChattaView.d.ts +1 -0
- package/dist/platforms/nuxt/LiveChattaView.js +1 -0
- package/dist/platforms/nuxt/LiveChattaView.js.map +1 -0
- package/dist/platforms/nuxt/useChattaBridge.d.ts +9 -0
- package/dist/platforms/nuxt/useChattaBridge.js +1 -0
- package/dist/platforms/nuxt/useChattaBridge.js.map +1 -0
- package/dist/platforms/nuxt/useLiveChatta.d.ts +63 -0
- package/dist/platforms/nuxt/useLiveChatta.js +1 -0
- package/dist/platforms/nuxt/useLiveChatta.js.map +1 -0
- package/dist/platforms/react/LiveChattaView.d.ts +58 -0
- package/dist/platforms/react/LiveChattaView.js +1 -0
- package/dist/platforms/react/LiveChattaView.js.map +1 -0
- package/dist/platforms/react/useChattaBridge.d.ts +1 -0
- package/dist/platforms/react/useChattaBridge.js +1 -0
- package/dist/platforms/react/useChattaBridge.js.map +1 -0
- package/dist/platforms/react/useChattaDeepLink.d.ts +2 -0
- package/dist/platforms/react/useChattaDeepLink.js +1 -0
- package/dist/platforms/react/useChattaDeepLink.js.map +1 -0
- package/dist/platforms/react/useChattaPermissions.d.ts +9 -0
- package/dist/platforms/react/useChattaPermissions.js +1 -0
- package/dist/platforms/react/useChattaPermissions.js.map +1 -0
- package/dist/platforms/react/useChattaUnread.d.ts +1 -0
- package/dist/platforms/react/useChattaUnread.js +1 -0
- package/dist/platforms/react/useChattaUnread.js.map +1 -0
- package/dist/platforms/react/useLiveChatta.d.ts +29 -0
- package/dist/platforms/react/useLiveChatta.js +1 -0
- package/dist/platforms/react/useLiveChatta.js.map +1 -0
- package/dist/platforms/react-native/LiveChattaView.d.ts +52 -0
- package/dist/platforms/react-native/LiveChattaView.js +1 -0
- package/dist/platforms/react-native/LiveChattaView.js.map +1 -0
- package/dist/platforms/react-native/useChattaBridge.d.ts +12 -0
- package/dist/platforms/react-native/useChattaBridge.js +1 -0
- package/dist/platforms/react-native/useChattaBridge.js.map +1 -0
- package/dist/platforms/react-native/useLiveChatta.d.ts +29 -0
- package/dist/platforms/react-native/useLiveChatta.js +1 -0
- package/dist/platforms/react-native/useLiveChatta.js.map +1 -0
- package/dist/platforms/svelte/LiveChattaEmbed.d.ts +54 -0
- package/dist/platforms/svelte/LiveChattaEmbed.js +1 -0
- package/dist/platforms/svelte/LiveChattaEmbed.js.map +1 -0
- package/dist/platforms/svelte/chattaBridgeStore.d.ts +19 -0
- package/dist/platforms/svelte/chattaBridgeStore.js +1 -0
- package/dist/platforms/svelte/chattaBridgeStore.js.map +1 -0
- package/dist/platforms/svelte/useLiveChatta.d.ts +61 -0
- package/dist/platforms/svelte/useLiveChatta.js +1 -0
- package/dist/platforms/svelte/useLiveChatta.js.map +1 -0
- package/dist/platforms/tauri/TauriBridge.d.ts +34 -0
- package/dist/platforms/tauri/TauriBridge.js +1 -0
- package/dist/platforms/tauri/TauriBridge.js.map +1 -0
- package/dist/platforms/tauri/TauriDeepLinks.d.ts +29 -0
- package/dist/platforms/tauri/TauriDeepLinks.js +1 -0
- package/dist/platforms/tauri/TauriDeepLinks.js.map +1 -0
- package/dist/platforms/tauri/TauriPermissions.d.ts +21 -0
- package/dist/platforms/tauri/TauriPermissions.js +1 -0
- package/dist/platforms/tauri/TauriPermissions.js.map +1 -0
- package/dist/platforms/tauri/TauriUpdater.d.ts +31 -0
- package/dist/platforms/tauri/TauriUpdater.js +1 -0
- package/dist/platforms/tauri/TauriUpdater.js.map +1 -0
- package/dist/platforms/tauri/index.d.ts +22 -0
- package/dist/platforms/tauri/index.js +1 -0
- package/dist/platforms/tauri/index.js.map +1 -0
- package/dist/platforms/vue/LiveChattaView.d.ts +1 -0
- package/dist/platforms/vue/LiveChattaView.js +1 -0
- package/dist/platforms/vue/LiveChattaView.js.map +1 -0
- package/dist/platforms/vue/useChattaBridge.d.ts +11 -0
- package/dist/platforms/vue/useChattaBridge.js +1 -0
- package/dist/platforms/vue/useChattaBridge.js.map +1 -0
- package/dist/platforms/vue/useChattaDeepLink.d.ts +2 -0
- package/dist/platforms/vue/useChattaDeepLink.js +1 -0
- package/dist/platforms/vue/useChattaDeepLink.js.map +1 -0
- package/dist/platforms/vue/useChattaPermissions.d.ts +9 -0
- package/dist/platforms/vue/useChattaPermissions.js +1 -0
- package/dist/platforms/vue/useChattaPermissions.js.map +1 -0
- package/dist/platforms/vue/useChattaUnread.d.ts +8 -0
- package/dist/platforms/vue/useChattaUnread.js +1 -0
- package/dist/platforms/vue/useChattaUnread.js.map +1 -0
- package/dist/platforms/vue/useLiveChatta.d.ts +58 -0
- package/dist/platforms/vue/useLiveChatta.js +1 -0
- package/dist/platforms/vue/useLiveChatta.js.map +1 -0
- package/dist/platforms/web/LiveChattaEmbed.d.ts +94 -0
- package/dist/platforms/web/LiveChattaEmbed.js +1 -0
- package/dist/platforms/web/LiveChattaEmbed.js.map +1 -0
- package/dist/platforms/web/bridge.d.ts +8 -0
- package/dist/platforms/web/bridge.js +1 -0
- package/dist/platforms/web/bridge.js.map +1 -0
- package/dist/platforms/web/permissions.d.ts +8 -0
- package/dist/platforms/web/permissions.js +1 -0
- package/dist/platforms/web/permissions.js.map +1 -0
- package/dist/types/billing.d.ts +355 -0
- package/dist/types/billing.js +53 -0
- package/dist/types/billing.js.map +1 -0
- package/dist/types/calendar.d.ts +132 -0
- package/dist/types/calendar.js +15 -0
- package/dist/types/calendar.js.map +1 -0
- package/dist/types/chat-core.d.ts +901 -0
- package/dist/types/chat-core.js +98 -0
- package/dist/types/chat-core.js.map +1 -0
- package/dist/types/chat-features.d.ts +775 -0
- package/dist/types/chat-features.js +50 -0
- package/dist/types/chat-features.js.map +1 -0
- package/dist/types/content.d.ts +138 -0
- package/dist/types/content.js +2 -0
- package/dist/types/content.js.map +1 -0
- package/dist/types/core/AutoRefresh.d.ts +68 -0
- package/dist/types/core/Bridge.d.ts +124 -0
- package/dist/types/core/Config.d.ts +26 -0
- package/dist/types/core/DeepLinks.d.ts +38 -0
- package/dist/types/core/EventBus.d.ts +15 -0
- package/dist/types/core/GrantStore.d.ts +29 -0
- package/dist/types/core/LiveChatta.d.ts +128 -0
- package/dist/types/core/Permissions.d.ts +34 -0
- package/dist/types/core/TokenManager.d.ts +25 -0
- package/dist/types/core/events.d.ts +140 -0
- package/dist/types/csat.d.ts +110 -0
- package/dist/types/csat.js +12 -0
- package/dist/types/csat.js.map +1 -0
- package/dist/types/events.d.ts +242 -0
- package/dist/types/events.js +275 -0
- package/dist/types/events.js.map +1 -0
- package/dist/types/extras.d.ts +353 -0
- package/dist/types/extras.js +31 -0
- package/dist/types/extras.js.map +1 -0
- package/dist/types/http/HttpAPI.d.ts +944 -0
- package/dist/types/http/HttpTransport.d.ts +66 -0
- package/dist/types/http/incomingWebhook.d.ts +17 -0
- package/dist/types/incoming-webhooks.d.ts +78 -0
- package/dist/types/incoming-webhooks.js +16 -0
- package/dist/types/incoming-webhooks.js.map +1 -0
- package/dist/types/index.d.ts +15 -0
- package/dist/types/index.js +16 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/liveflex.d.ts +578 -0
- package/dist/types/liveflex.js +7 -0
- package/dist/types/liveflex.js.map +1 -0
- package/dist/types/models.d.ts +1753 -0
- package/dist/types/models.js +148 -0
- package/dist/types/models.js.map +1 -0
- package/dist/types/options.d.ts +190 -0
- package/dist/types/options.js +43 -0
- package/dist/types/options.js.map +1 -0
- package/dist/types/shared-channels.d.ts +236 -0
- package/dist/types/shared-channels.js +50 -0
- package/dist/types/shared-channels.js.map +1 -0
- package/dist/types/socket/SocketAPI.d.ts +1026 -0
- package/dist/types/socket/SocketTransport.d.ts +44 -0
- package/dist/types/types/billing.d.ts +355 -0
- package/dist/types/types/calendar.d.ts +132 -0
- package/dist/types/types/chat-core.d.ts +901 -0
- package/dist/types/types/chat-features.d.ts +775 -0
- package/dist/types/types/content.d.ts +138 -0
- package/dist/types/types/csat.d.ts +110 -0
- package/dist/types/types/events.d.ts +242 -0
- package/dist/types/types/extras.d.ts +353 -0
- package/dist/types/types/incoming-webhooks.d.ts +78 -0
- package/dist/types/types/index.d.ts +15 -0
- package/dist/types/types/liveflex.d.ts +578 -0
- package/dist/types/types/models.d.ts +1753 -0
- package/dist/types/types/options.d.ts +190 -0
- package/dist/types/types/shared-channels.d.ts +236 -0
- package/dist/types/types/workspace-gifs.d.ts +95 -0
- package/dist/types/types/workspace.d.ts +390 -0
- package/dist/types/ui/EmbedConfig.d.ts +38 -0
- package/dist/types/ui/EmbedUI.d.ts +44 -0
- package/dist/types/ui/Launcher.d.ts +122 -0
- package/dist/types/ui/brand.d.ts +27 -0
- package/dist/types/ui/embedMessages.d.ts +23 -0
- package/dist/types/ui/hours.d.ts +35 -0
- package/dist/types/ui/prechat.d.ts +35 -0
- package/dist/types/ui/widgetConfig.d.ts +4 -0
- package/dist/types/utils/crypto.d.ts +6 -0
- package/dist/types/utils/hmac.d.ts +40 -0
- package/dist/types/utils/permissions.d.ts +5 -0
- package/dist/types/utils/platform.d.ts +18 -0
- package/dist/types/utils/visitor.d.ts +2 -0
- package/dist/types/workspace-gifs.d.ts +95 -0
- package/dist/types/workspace-gifs.js +3 -0
- package/dist/types/workspace-gifs.js.map +1 -0
- package/dist/types/workspace.d.ts +390 -0
- package/dist/types/workspace.js +13 -0
- package/dist/types/workspace.js.map +1 -0
- package/dist/umd/livechatta.umd.js +7262 -0
- package/dist/umd/livechatta.umd.js.map +1 -0
- package/dist/umd/livechatta.umd.min.js +2 -0
- package/dist/umd/livechatta.umd.min.js.map +1 -0
- package/package.json +278 -4
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Socket } from 'socket.io-client';
|
|
2
|
+
import { Config } from '../core/Config';
|
|
3
|
+
import { TokenManager } from '../core/TokenManager';
|
|
4
|
+
import { EventBus } from '../core/EventBus';
|
|
5
|
+
import { ConnectionState } from '../types/models';
|
|
6
|
+
import { LiveChattaError } from '../http/HttpTransport';
|
|
7
|
+
/** Denied socket calls ack `{ error }`: the chat-error body, or a string from the handler. */
|
|
8
|
+
export declare function socketAckError(response: unknown): LiveChattaError | null;
|
|
9
|
+
export declare class SocketTransport {
|
|
10
|
+
private readonly config;
|
|
11
|
+
private readonly tokenManager;
|
|
12
|
+
private readonly eventBus;
|
|
13
|
+
private socket;
|
|
14
|
+
private state;
|
|
15
|
+
private queue;
|
|
16
|
+
private reconnectAttempt;
|
|
17
|
+
private selfUserId;
|
|
18
|
+
private static readonly MAX_QUEUE_SIZE;
|
|
19
|
+
constructor(config: Config, tokenManager: TokenManager, eventBus: EventBus);
|
|
20
|
+
connect(): Promise<void>;
|
|
21
|
+
/** Chat-user id of this connection, from the `online` event the server sends on connect (null before). */
|
|
22
|
+
getSelfUserId(): string | null;
|
|
23
|
+
disconnect(): void;
|
|
24
|
+
/** Reject and clear every queued emit (used on teardown). */
|
|
25
|
+
private rejectQueue;
|
|
26
|
+
isConnected(): boolean;
|
|
27
|
+
getState(): ConnectionState;
|
|
28
|
+
/**
|
|
29
|
+
* Emit an event and receive an ack response.
|
|
30
|
+
* If disconnected, queues the emit and resolves when reconnected.
|
|
31
|
+
*/
|
|
32
|
+
emit<T = any>(event: string, data?: any): Promise<T>;
|
|
33
|
+
/** Register a listener for an event */
|
|
34
|
+
on(event: string, callback: (...args: any[]) => void): void;
|
|
35
|
+
/** Remove a listener */
|
|
36
|
+
off(event: string, callback?: (...args: any[]) => void): void;
|
|
37
|
+
/** Get the underlying socket.io Socket instance */
|
|
38
|
+
getSocket(): Socket | null;
|
|
39
|
+
private doEmit;
|
|
40
|
+
private setupLifecycleListeners;
|
|
41
|
+
private flushQueue;
|
|
42
|
+
private setState;
|
|
43
|
+
private log;
|
|
44
|
+
}
|
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
/** Public tiers plus CUSTOM (one client's contract plan, assigned by the LiveChatta team). */
|
|
2
|
+
export declare const PLAN_TYPES: readonly ["FLASH", "PULSE", "FLASH_PRO", "ORBIT", "CUSTOM"];
|
|
3
|
+
export type PlanType = (typeof PLAN_TYPES)[number];
|
|
4
|
+
export declare const PLAN_BILLING_CYCLES: readonly ["MONTHLY", "QUARTERLY", "SEMI_YEARLY", "YEARLY"];
|
|
5
|
+
export type PlanBillingCycle = (typeof PLAN_BILLING_CYCLES)[number];
|
|
6
|
+
/**
|
|
7
|
+
* A plan as `GET subscriptions/plans` returns it. Limits follow the credit convention:
|
|
8
|
+
* `0` = unlimited, `-1` = none, `> 0` = that many. Every `allow*` flag is typed loosely. */
|
|
9
|
+
export interface Plan {
|
|
10
|
+
_id: string;
|
|
11
|
+
code: string;
|
|
12
|
+
name: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
type: PlanType;
|
|
15
|
+
visibility?: 'PUBLIC' | 'HIDDEN';
|
|
16
|
+
status: string;
|
|
17
|
+
priceMonthly: number;
|
|
18
|
+
priceQuarterly: number;
|
|
19
|
+
priceSemiYearly: number;
|
|
20
|
+
priceYearly: number;
|
|
21
|
+
currency?: string;
|
|
22
|
+
/** CUSTOM plans only: the client the plan belongs to. */
|
|
23
|
+
owner?: string | null;
|
|
24
|
+
maxChatLinks?: number;
|
|
25
|
+
maxMembersPerLink?: number;
|
|
26
|
+
maxMessagesPerDay?: number;
|
|
27
|
+
aiCreditsPerMonth?: number;
|
|
28
|
+
maxApiKeys?: number;
|
|
29
|
+
maxWebhooks?: number;
|
|
30
|
+
/** Monthly upload allowance in GB for the workspace: 0 unlimited, -1 no uploads (chatta #420). */
|
|
31
|
+
maxStorageGB?: number;
|
|
32
|
+
/** Free trial length in days; 0 / absent = no trial (chatta #424). */
|
|
33
|
+
trialDays?: number;
|
|
34
|
+
[limit: string]: unknown;
|
|
35
|
+
}
|
|
36
|
+
/** How a plan is paid: a saved card that auto-renews, or a bank transfer paid each period (chatta #421). */
|
|
37
|
+
export declare const PAYMENT_CHANNELS: readonly ["card", "bank_transfer"];
|
|
38
|
+
export type PaymentChannel = (typeof PAYMENT_CHANNELS)[number];
|
|
39
|
+
export interface SubscribePayload {
|
|
40
|
+
planId: string;
|
|
41
|
+
billingCycle: PlanBillingCycle;
|
|
42
|
+
/** Default `card` (saved, renews automatically); `bank_transfer` shows a one-time account each period. */
|
|
43
|
+
paymentMethod?: PaymentChannel;
|
|
44
|
+
}
|
|
45
|
+
export interface ChangePlanPayload {
|
|
46
|
+
planId: string;
|
|
47
|
+
billingCycle: PlanBillingCycle;
|
|
48
|
+
/** Only a downgrade to a cheaper public tier may wait for the period end (400 otherwise). */
|
|
49
|
+
scheduleForPeriodEnd?: boolean;
|
|
50
|
+
/** Upgrades only: `card` (default) or `bank_transfer`. A scheduled downgrade needs no payment. */
|
|
51
|
+
paymentMethod?: PaymentChannel;
|
|
52
|
+
}
|
|
53
|
+
/** Paystack checkout to open; finish with the matching verify call. */
|
|
54
|
+
export interface PaymentCheckout {
|
|
55
|
+
authorizationUrl: string;
|
|
56
|
+
reference: string;
|
|
57
|
+
accessCode: string;
|
|
58
|
+
/** Echoed on subscribe (chatta #421). */
|
|
59
|
+
paymentMethod?: PaymentChannel;
|
|
60
|
+
}
|
|
61
|
+
/** Upgrade checkout: `credit` is the unused part of the current period, `netAmount` the charge (USD). */
|
|
62
|
+
export interface PlanChangeCheckout extends PaymentCheckout {
|
|
63
|
+
credit: number;
|
|
64
|
+
netAmount: number;
|
|
65
|
+
/** Extra seats that carry over to the new plan (capped at its seat limit). */
|
|
66
|
+
extraSeats?: number;
|
|
67
|
+
/** What the carried seats add to the charge, USD. */
|
|
68
|
+
extraSeatsUsd?: number;
|
|
69
|
+
/** Seats that no longer fit and are dropped (current seats minus `extraSeats`). */
|
|
70
|
+
droppedSeats?: number;
|
|
71
|
+
/** Storage packs re-aligned to the new plan's period, USD. */
|
|
72
|
+
storageAddonUsd?: number;
|
|
73
|
+
/** Bank-transfer checkouts expire; null for card. */
|
|
74
|
+
expiresAt?: string | null;
|
|
75
|
+
}
|
|
76
|
+
/** Downgrade between public tiers: no charge, applied at `effectiveAt`. */
|
|
77
|
+
export interface PlanChangeScheduled {
|
|
78
|
+
scheduled: true;
|
|
79
|
+
effectiveAt: string;
|
|
80
|
+
newPlanName: string;
|
|
81
|
+
message: string;
|
|
82
|
+
}
|
|
83
|
+
export type PlanChangeResult = PlanChangeCheckout | PlanChangeScheduled;
|
|
84
|
+
/** Bank transfers stay pending; the server settles them later, so poll or wait for the webhook. */
|
|
85
|
+
export interface PaymentPendingResult {
|
|
86
|
+
status: 'pending';
|
|
87
|
+
pending: true;
|
|
88
|
+
channel: string | null;
|
|
89
|
+
reference: string;
|
|
90
|
+
}
|
|
91
|
+
/** A pending downgrade; stored as a typed sub-document since chatta #396 (null when nothing is scheduled). */
|
|
92
|
+
export interface SubscriptionScheduledChange {
|
|
93
|
+
planId: string;
|
|
94
|
+
billingCycle: PlanBillingCycle;
|
|
95
|
+
scheduledAt: string;
|
|
96
|
+
effectiveAt: string;
|
|
97
|
+
}
|
|
98
|
+
export interface PlanSubscription {
|
|
99
|
+
_id: string;
|
|
100
|
+
owner: string;
|
|
101
|
+
plan: Plan | string;
|
|
102
|
+
status: 'ACTIVE' | 'EXPIRED' | 'CANCELLED' | 'PAST_DUE';
|
|
103
|
+
currentPeriodStart: string;
|
|
104
|
+
currentPeriodEnd: string;
|
|
105
|
+
nextBillingDate?: string;
|
|
106
|
+
amount?: number;
|
|
107
|
+
amountInDollar?: number;
|
|
108
|
+
currency?: string;
|
|
109
|
+
cancelledAt?: string | null;
|
|
110
|
+
scheduledChange?: SubscriptionScheduledChange | null;
|
|
111
|
+
extraSeats?: number;
|
|
112
|
+
reference?: string;
|
|
113
|
+
/** null / absent = card (chatta #421). */
|
|
114
|
+
paymentChannel?: PaymentChannel | null;
|
|
115
|
+
/** Renewal reminders already emailed for this period (days before the end). */
|
|
116
|
+
renewalNotices?: {
|
|
117
|
+
periodEnd: string | null;
|
|
118
|
+
sent: number[];
|
|
119
|
+
};
|
|
120
|
+
lastChargeAttemptAt?: string | null;
|
|
121
|
+
/** Free trial (chatta #424): the period ends at `trialEndsAt`; a paid renewal clears `isTrial`. */
|
|
122
|
+
isTrial?: boolean;
|
|
123
|
+
trialStartedAt?: string | null;
|
|
124
|
+
trialEndsAt?: string | null;
|
|
125
|
+
trialExtensions?: TrialExtension[];
|
|
126
|
+
createdAt?: string;
|
|
127
|
+
updatedAt?: string;
|
|
128
|
+
}
|
|
129
|
+
/** One "Extend trial" action by the LiveChatta team. */
|
|
130
|
+
export interface TrialExtension {
|
|
131
|
+
days: number;
|
|
132
|
+
reason: string;
|
|
133
|
+
by: string;
|
|
134
|
+
at: string;
|
|
135
|
+
from: string | null;
|
|
136
|
+
to: string;
|
|
137
|
+
}
|
|
138
|
+
export interface TrialSummary {
|
|
139
|
+
subscriptionId: string;
|
|
140
|
+
planName: string;
|
|
141
|
+
status: 'active' | 'ended';
|
|
142
|
+
endsAt: string;
|
|
143
|
+
daysLeft: number;
|
|
144
|
+
/** A saved card is charged when the trial ends; without one the plan pauses (PAST_DUE). */
|
|
145
|
+
hasCard: boolean;
|
|
146
|
+
amountUsd: number;
|
|
147
|
+
}
|
|
148
|
+
/** `GET subscriptions/trial`: `eligible` is false once the one trial is used or a plan is active. */
|
|
149
|
+
export interface TrialStatus {
|
|
150
|
+
eligible: boolean;
|
|
151
|
+
trial: TrialSummary | null;
|
|
152
|
+
}
|
|
153
|
+
/** Body of `POST subscriptions/trial`; `billingCycle` is billed after the trial (default MONTHLY). */
|
|
154
|
+
export interface StartTrialPayload {
|
|
155
|
+
planId: string;
|
|
156
|
+
billingCycle?: PlanBillingCycle;
|
|
157
|
+
}
|
|
158
|
+
export interface TrialStartResult {
|
|
159
|
+
subscriptionId: string;
|
|
160
|
+
planName: string;
|
|
161
|
+
trialEndsAt: string;
|
|
162
|
+
days: number;
|
|
163
|
+
}
|
|
164
|
+
/** due-soon = ≤ 7 days; grace = past the end; lapsed = paused (PAST_DUE). */
|
|
165
|
+
export type RenewalState = 'current' | 'due-soon' | 'due' | 'grace' | 'lapsed';
|
|
166
|
+
export interface RenewalSummary {
|
|
167
|
+
state: RenewalState;
|
|
168
|
+
subscriptionId: string;
|
|
169
|
+
periodEnd: string | null;
|
|
170
|
+
graceEndsAt: string | null;
|
|
171
|
+
daysLeft: number;
|
|
172
|
+
/** Current plan price plus extra seats (no grandfathering). */
|
|
173
|
+
amountUsd: number;
|
|
174
|
+
}
|
|
175
|
+
/** `GET subscriptions/renewal`: null when nothing is paid by transfer or paused. */
|
|
176
|
+
export interface RenewalStatus {
|
|
177
|
+
renewal: RenewalSummary | null;
|
|
178
|
+
}
|
|
179
|
+
/** `POST subscriptions/:id/renew` checkout (`rnw_…`); finish with `verifySubscription(reference)`. */
|
|
180
|
+
export interface RenewalCheckout {
|
|
181
|
+
authorizationUrl: string;
|
|
182
|
+
reference: string;
|
|
183
|
+
/** Paystack access code: open the checkout in place with Paystack Inline instead of the URL. Empty for crypto. */
|
|
184
|
+
accessCode?: string;
|
|
185
|
+
paymentMethod: PaymentChannel;
|
|
186
|
+
}
|
|
187
|
+
/** `POST subscriptions/payment-method/bank-transfer`: every active plan stops auto-charging the card. */
|
|
188
|
+
export interface PaymentChannelResult {
|
|
189
|
+
paymentChannel: PaymentChannel;
|
|
190
|
+
}
|
|
191
|
+
/** `reason` on `subscription:failed` when a bank-transfer plan paused after its grace period. */
|
|
192
|
+
export declare const SUBSCRIPTION_FAILED_TRANSFER_UNPAID = "transfer_unpaid";
|
|
193
|
+
/** Webhook `subscription:renewed` data; renewal checkouts add `channel`. */
|
|
194
|
+
export interface SubscriptionRenewedWebhookData {
|
|
195
|
+
subscriptionId: string;
|
|
196
|
+
planName: string;
|
|
197
|
+
billingCycle: PlanBillingCycle;
|
|
198
|
+
amountInDollar: number;
|
|
199
|
+
reference: string;
|
|
200
|
+
channel?: PaymentChannel;
|
|
201
|
+
}
|
|
202
|
+
/** Webhook `subscription:failed` data; a paused transfer plan adds `reason: 'transfer_unpaid'` and `pausedAt`. */
|
|
203
|
+
export interface SubscriptionFailedWebhookData {
|
|
204
|
+
subscriptionId: string;
|
|
205
|
+
planName: string;
|
|
206
|
+
amountInDollar: number;
|
|
207
|
+
reason?: typeof SUBSCRIPTION_FAILED_TRANSFER_UNPAID;
|
|
208
|
+
pausedAt?: string;
|
|
209
|
+
}
|
|
210
|
+
/** 400 `{ message, code: 'STORAGE_LIMIT', resetsAt }` on an upload past the month's allowance (also the socket ack). */
|
|
211
|
+
export declare const STORAGE_LIMIT = "STORAGE_LIMIT";
|
|
212
|
+
export interface StorageLimitError {
|
|
213
|
+
statusCode: 400;
|
|
214
|
+
message: string;
|
|
215
|
+
code: typeof STORAGE_LIMIT;
|
|
216
|
+
resetsAt: string;
|
|
217
|
+
}
|
|
218
|
+
/** ok < 80%, warning 80–99%, full at 100%; unlimited (cap 0) and none (cap -1) have no bar. */
|
|
219
|
+
export type StorageState = 'ok' | 'warning' | 'full' | 'unlimited' | 'none';
|
|
220
|
+
/** `GET subscriptions/storage`: this month's uploads against plan `maxStorageGB` + STORAGE add-ons. */
|
|
221
|
+
export interface StorageUsage {
|
|
222
|
+
monthBytes: number;
|
|
223
|
+
/** Since counting began; deletes do not lower it. */
|
|
224
|
+
totalBytes: number;
|
|
225
|
+
/** 0 unlimited, -1 no uploads, > 0 plan + add-ons. */
|
|
226
|
+
capGB: number;
|
|
227
|
+
planGB: number;
|
|
228
|
+
addonGB: number;
|
|
229
|
+
/** null when unlimited or none. */
|
|
230
|
+
pct: number | null;
|
|
231
|
+
/** null when unlimited. */
|
|
232
|
+
remainingBytes: number | null;
|
|
233
|
+
state: StorageState;
|
|
234
|
+
periodStart: string;
|
|
235
|
+
resetsAt: string;
|
|
236
|
+
}
|
|
237
|
+
/** 404 from `getPlan` for a plan the caller may not see (hidden, another client's CUSTOM, the template). */
|
|
238
|
+
export declare const PLAN_NOT_FOUND_MESSAGE = "Plan not found.";
|
|
239
|
+
/** 400 from subscribe / change-plan / gift: hidden, inactive, template or someone else's plan. */
|
|
240
|
+
export declare const PLAN_NOT_AVAILABLE_MESSAGE = "This plan is not available.";
|
|
241
|
+
/** 400 when the plan costs $0 for that cycle: only the LiveChatta team can switch you to it. */
|
|
242
|
+
export declare const PLAN_TEAM_ACTIVATED_MESSAGE = "This plan is activated by the LiveChatta team. Contact support to switch to it.";
|
|
243
|
+
/** Stable `code` on plan refusals (chatta #396); bodies are `{ message, code }`. Always 404. */
|
|
244
|
+
export declare const PLAN_NOT_FOUND = "PLAN_NOT_FOUND";
|
|
245
|
+
/** Always 400. */
|
|
246
|
+
export declare const PLAN_NOT_AVAILABLE = "PLAN_NOT_AVAILABLE";
|
|
247
|
+
/** Always 400. */
|
|
248
|
+
export declare const PLAN_TEAM_ACTIVATED = "PLAN_TEAM_ACTIVATED";
|
|
249
|
+
export type PlanAccessError = 'not-found' | 'not-available' | 'team-activated';
|
|
250
|
+
/** Which plan refusal an error is, or null. Reads `code` first, then the messages older servers send. */
|
|
251
|
+
export declare function planAccessError(err: unknown): PlanAccessError | null;
|
|
252
|
+
/** A public plan as the gift store shows it (no owner, limits or internal flags). */
|
|
253
|
+
export interface PublicGiftPlan {
|
|
254
|
+
_id: string;
|
|
255
|
+
code: string;
|
|
256
|
+
name: string;
|
|
257
|
+
description: string;
|
|
258
|
+
priceMonthly: number;
|
|
259
|
+
priceQuarterly: number;
|
|
260
|
+
priceSemiYearly: number;
|
|
261
|
+
priceYearly: number;
|
|
262
|
+
}
|
|
263
|
+
/** A feature pricing row plus whether the owner's plan includes it or it is active now. */
|
|
264
|
+
export interface PublicGiftFeature {
|
|
265
|
+
featureKey?: string;
|
|
266
|
+
category?: string;
|
|
267
|
+
_included: boolean;
|
|
268
|
+
_active: boolean;
|
|
269
|
+
[key: string]: unknown;
|
|
270
|
+
}
|
|
271
|
+
/** Public plans only; `currentPlanId` is set only when the owner is on one of them (`ownerSubscription` is gone). */
|
|
272
|
+
export interface PublicGiftStoreData {
|
|
273
|
+
giftPlans: PublicGiftPlan[];
|
|
274
|
+
features: PublicGiftFeature[];
|
|
275
|
+
currentPlanId: string | null;
|
|
276
|
+
}
|
|
277
|
+
export declare const CUSTOM_PLAN_REQUEST_FEATURES: readonly ["SSO", "WHITE_LABEL", "API_ACCESS", "WEBINARS", "AUTOMATION", "ADVANCED_ANALYTICS", "HOP_RECORDING", "LONG_RETENTION", "DEDICATED_SUPPORT"];
|
|
278
|
+
export type CustomPlanRequestFeature = (typeof CUSTOM_PLAN_REQUEST_FEATURES)[number];
|
|
279
|
+
export declare const CUSTOM_PLAN_REQUEST_STATUSES: readonly ["NEW", "CONTACTED", "QUOTED", "ASSIGNED", "CLOSED"];
|
|
280
|
+
export type CustomPlanRequestStatus = (typeof CUSTOM_PLAN_REQUEST_STATUSES)[number];
|
|
281
|
+
/** Backend `CreateCustomPlanRequestDto`; limits in the comments are server-enforced. */
|
|
282
|
+
export interface CustomPlanRequestPayload {
|
|
283
|
+
/** ≤ 120 chars. */
|
|
284
|
+
contactName: string;
|
|
285
|
+
/** ≤ 254 chars. */
|
|
286
|
+
contactEmail: string;
|
|
287
|
+
/** ≤ 160 chars. */
|
|
288
|
+
company?: string;
|
|
289
|
+
/** 1–100 000. */
|
|
290
|
+
expectedChatLinks?: number;
|
|
291
|
+
/** 1–10 000 000. */
|
|
292
|
+
membersPerLink?: number;
|
|
293
|
+
/** AI credits per month, 0–1 000 000 000. */
|
|
294
|
+
aiCredits?: number;
|
|
295
|
+
features?: CustomPlanRequestFeature[];
|
|
296
|
+
/** ≤ 2000 chars. */
|
|
297
|
+
message?: string;
|
|
298
|
+
/** Public route only; signed-in requests are always CLIENT. */
|
|
299
|
+
source?: 'PRICING' | 'ENTERPRISE';
|
|
300
|
+
}
|
|
301
|
+
/** A repeat from the same email within 10 minutes returns the open request instead of a new one. */
|
|
302
|
+
export interface CustomPlanRequestStatusView {
|
|
303
|
+
id: string;
|
|
304
|
+
status: CustomPlanRequestStatus;
|
|
305
|
+
createdAt: string;
|
|
306
|
+
statusUpdatedAt: string | null;
|
|
307
|
+
}
|
|
308
|
+
export interface LatestPlanRequest {
|
|
309
|
+
request: CustomPlanRequestStatusView | null;
|
|
310
|
+
}
|
|
311
|
+
/** One add-on (or AI credit pack) with a per-day USD price; same rows as `FeaturePricing`. */
|
|
312
|
+
export interface StoreFeature {
|
|
313
|
+
_id: string;
|
|
314
|
+
featureKey: string;
|
|
315
|
+
name: string;
|
|
316
|
+
description: string;
|
|
317
|
+
pricePerDay: number;
|
|
318
|
+
/** 0 = unlimited for the duration; > 0 = that many uses (tokens for AI credit packs). */
|
|
319
|
+
usageLimit: number;
|
|
320
|
+
/** STORAGE = Extra storage add-on (adds GB to the month's allowance, chatta #420). */
|
|
321
|
+
category: 'FEATURE' | 'AI_CREDITS' | 'STORAGE';
|
|
322
|
+
status: string;
|
|
323
|
+
}
|
|
324
|
+
export interface PurchaseFeaturePayload {
|
|
325
|
+
featurePricingId: string;
|
|
326
|
+
/** 1–365. */
|
|
327
|
+
durationDays: number;
|
|
328
|
+
}
|
|
329
|
+
/** Row of `GET subscriptions/features/my-purchases` (newest first, ≤ 100). */
|
|
330
|
+
export interface MyFeaturePurchase {
|
|
331
|
+
_id: string;
|
|
332
|
+
owner: string;
|
|
333
|
+
featurePricing: Pick<StoreFeature, '_id' | 'featureKey' | 'name' | 'category' | 'description'> | string;
|
|
334
|
+
featureKey: string;
|
|
335
|
+
category: string;
|
|
336
|
+
pricePerDay: number;
|
|
337
|
+
durationDays: number;
|
|
338
|
+
pricePaid: number;
|
|
339
|
+
amountPaid?: number;
|
|
340
|
+
usageLimit: number;
|
|
341
|
+
purchasedAt: string;
|
|
342
|
+
expiresAt: string;
|
|
343
|
+
status: string;
|
|
344
|
+
reference: string;
|
|
345
|
+
giftedBy?: string | null;
|
|
346
|
+
createdAt?: string;
|
|
347
|
+
}
|
|
348
|
+
export interface GiftPlanPayload {
|
|
349
|
+
planId: string;
|
|
350
|
+
billingCycle: PlanBillingCycle;
|
|
351
|
+
}
|
|
352
|
+
/** `PUT chats/links/:linkId/embed-domains` result: the normalised list (empty = any site). */
|
|
353
|
+
export interface EmbedDomainsResult {
|
|
354
|
+
domains: string[];
|
|
355
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/** The calendars a member can connect. */
|
|
2
|
+
export declare const CALENDAR_PROVIDERS: readonly ["google", "microsoft"];
|
|
3
|
+
export type CalendarProviderId = (typeof CALENDAR_PROVIDERS)[number];
|
|
4
|
+
/** `needs_reauth`: the provider dropped the grant; the member must connect again. */
|
|
5
|
+
export type CalendarConnectionStatus = 'active' | 'needs_reauth';
|
|
6
|
+
export interface CalendarProviderInfo {
|
|
7
|
+
id: CalendarProviderId;
|
|
8
|
+
label: string;
|
|
9
|
+
}
|
|
10
|
+
/** One connected calendar. Tokens never reach the client. */
|
|
11
|
+
export interface CalendarConnection {
|
|
12
|
+
provider: CalendarProviderId;
|
|
13
|
+
label: string;
|
|
14
|
+
status: CalendarConnectionStatus;
|
|
15
|
+
accountHint: string;
|
|
16
|
+
connectedAt: string;
|
|
17
|
+
lastSyncAt: string | null;
|
|
18
|
+
lastError: string;
|
|
19
|
+
/** Busy blocks (never titles) shown to members who share a conversation with you; off by default. */
|
|
20
|
+
shareBusy: boolean;
|
|
21
|
+
/** True while a push channel keeps the calendar in step in real time. */
|
|
22
|
+
realtime: boolean;
|
|
23
|
+
}
|
|
24
|
+
/** `GET calendar-sync/status`. `enabled: false` (and no providers) when the server has no calendar keys. */
|
|
25
|
+
export interface CalendarSyncStatus {
|
|
26
|
+
enabled: boolean;
|
|
27
|
+
providers: CalendarProviderInfo[];
|
|
28
|
+
connections: CalendarConnection[];
|
|
29
|
+
}
|
|
30
|
+
export interface CalendarConnectPayload {
|
|
31
|
+
/** Same-origin path to return to after consent, e.g. `/in/ABC123` (web only). */
|
|
32
|
+
returnTo?: string;
|
|
33
|
+
/** True from native apps: `authUrl` opens a confirmation page in the system browser, which ends at `livechatta://calendar-sync/done?code=`. */
|
|
34
|
+
native?: boolean;
|
|
35
|
+
}
|
|
36
|
+
/** Open `authUrl` in a browser to finish signing in. */
|
|
37
|
+
export interface CalendarConnectResult {
|
|
38
|
+
authUrl: string;
|
|
39
|
+
}
|
|
40
|
+
/** `{ ok: true }` from native complete, disconnect and share-busy. */
|
|
41
|
+
export interface CalendarOkResult {
|
|
42
|
+
ok: true;
|
|
43
|
+
}
|
|
44
|
+
/** `POST calendar-sync/sync`: how many connections were queued (202). */
|
|
45
|
+
export interface CalendarSyncQueued {
|
|
46
|
+
queued: number;
|
|
47
|
+
}
|
|
48
|
+
export interface CalendarBusyBlock {
|
|
49
|
+
start: string;
|
|
50
|
+
end: string;
|
|
51
|
+
}
|
|
52
|
+
export interface CalendarBusyMember {
|
|
53
|
+
userId: string;
|
|
54
|
+
/** True when the member has a calendar connected and has chosen to share busy times. */
|
|
55
|
+
connected: boolean;
|
|
56
|
+
busy: CalendarBusyBlock[];
|
|
57
|
+
}
|
|
58
|
+
export interface CalendarBusy {
|
|
59
|
+
members: CalendarBusyMember[];
|
|
60
|
+
}
|
|
61
|
+
/** `GET calendar-sync/busy`: up to 20 member ids who share a conversation with you, a window of at most 14 days. */
|
|
62
|
+
export interface CalendarBusyQuery {
|
|
63
|
+
userIds: string[];
|
|
64
|
+
from: string;
|
|
65
|
+
to: string;
|
|
66
|
+
}
|
|
67
|
+
/** Realtime `hop-meeting-updated`: a connected calendar moved a meeting you are in. */
|
|
68
|
+
export interface HopMeetingUpdatedEvent {
|
|
69
|
+
conversationId: string;
|
|
70
|
+
startAt: string;
|
|
71
|
+
endAt: string;
|
|
72
|
+
title: string;
|
|
73
|
+
}
|
|
74
|
+
/** A mention of you or a reaction to your message (`GET notifications/activity`). */
|
|
75
|
+
export interface ActivityNotification {
|
|
76
|
+
_id: string;
|
|
77
|
+
type: string;
|
|
78
|
+
title?: string;
|
|
79
|
+
body?: string;
|
|
80
|
+
data?: {
|
|
81
|
+
[key: string]: string | number | boolean | undefined;
|
|
82
|
+
};
|
|
83
|
+
status?: string;
|
|
84
|
+
readAt?: string | null;
|
|
85
|
+
createdAt: string;
|
|
86
|
+
sender?: {
|
|
87
|
+
_id?: string;
|
|
88
|
+
displayName?: string;
|
|
89
|
+
handle?: string;
|
|
90
|
+
};
|
|
91
|
+
conversation?: {
|
|
92
|
+
_id?: string;
|
|
93
|
+
name?: string;
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
export interface ActivityQuery {
|
|
97
|
+
nextCursor?: string;
|
|
98
|
+
prevCursor?: string;
|
|
99
|
+
limit?: number;
|
|
100
|
+
}
|
|
101
|
+
export interface ActivityUnreadCount {
|
|
102
|
+
count: number;
|
|
103
|
+
}
|
|
104
|
+
/** Your own sidebar category names for one link (empty ones included). */
|
|
105
|
+
export interface SidebarCategories {
|
|
106
|
+
categories: string[];
|
|
107
|
+
}
|
|
108
|
+
/** `PUT chats/conversations/:id/category`: an empty `category` removes the conversation from its category. */
|
|
109
|
+
export interface ConversationCategoryResult extends SidebarCategories {
|
|
110
|
+
conversationId: string;
|
|
111
|
+
category: string;
|
|
112
|
+
}
|
|
113
|
+
export interface RenameSidebarCategoryPayload {
|
|
114
|
+
chatLinkId?: string;
|
|
115
|
+
from: string;
|
|
116
|
+
to: string;
|
|
117
|
+
}
|
|
118
|
+
/** `PUT chats/links/:linkId/app-origins` (owner): the native app origins allowed to frame the app embed. */
|
|
119
|
+
export interface LinkAppOriginsResult {
|
|
120
|
+
origins: string[];
|
|
121
|
+
}
|
|
122
|
+
/** Meeting-guest and calendar hand-back error codes (400 unless noted). */
|
|
123
|
+
export declare const CALENDAR_ACCOUNT_MISMATCH = "CALENDAR_ACCOUNT_MISMATCH";
|
|
124
|
+
export declare const CALENDAR_SIGNIN_EXPIRED = "CALENDAR_SIGNIN_EXPIRED";
|
|
125
|
+
export declare const GUEST_CODE_EXPIRED = "GUEST_CODE_EXPIRED";
|
|
126
|
+
export declare const GUEST_CODE_INVALID = "GUEST_CODE_INVALID";
|
|
127
|
+
/** 429: too many wrong codes; ask for a new one. */
|
|
128
|
+
export declare const GUEST_CODE_LOCKED = "GUEST_CODE_LOCKED";
|
|
129
|
+
/** 429: a code was just sent; wait a minute. */
|
|
130
|
+
export declare const GUEST_CODE_COOLDOWN = "GUEST_CODE_COOLDOWN";
|
|
131
|
+
/** 429: five codes an hour. */
|
|
132
|
+
export declare const GUEST_CODE_RATE_LIMITED = "GUEST_CODE_RATE_LIMITED";
|