@lilaquadrat/chat 0.1.17 → 0.1.18
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/dist/wc/lilaquadrat-studio-chat.js +5 -5
- package/dist/wc/lilaquadrat-studio-chat.umd.cjs +1 -1
- package/package.json +24 -23
- package/dist/app/assets/de-BPWT8j6E.js +0 -1
- package/dist/app/assets/loadFonts-DmNZ8tPj.js +0 -1
- package/dist/app/assets/main-B18LDkun.js +0 -2
- package/dist/app/assets/preload-helper-OSX1TyOM.js +0 -1
- package/dist/app/assets/support-DgYHnicF.js +0 -2
- package/dist/app/assets/support-agent-CTl6KCJE.js +0 -1
- package/dist/app/assets/web-component-BANWBXIc.js +0 -1
- package/dist/app/index.html +0 -37
- package/dist/app/support/index.html +0 -43
- package/dist/studio-chat-module.js +0 -0
- package/dist/studio-chat-module.umd.cjs +0 -1
- package/dist/types/src/bot/botClient.d.ts +0 -40
- package/dist/types/src/bot/botManager.d.ts +0 -3
- package/dist/types/src/composables/useChatBootstrap.d.ts +0 -27
- package/dist/types/src/composables/useChatVisibility.d.ts +0 -18
- package/dist/types/src/composables/useTriggerEvent.d.ts +0 -10
- package/dist/types/src/composables/useWebSocket.d.ts +0 -11
- package/dist/types/src/config/auth.d.ts +0 -19
- package/dist/types/src/config/bootstrap.agent.d.ts +0 -86
- package/dist/types/src/config/bootstrap.d.ts +0 -10
- package/dist/types/src/config/chatConfig.d.ts +0 -83
- package/dist/types/src/config/components.shared.d.ts +0 -18
- package/dist/types/src/config/users.d.ts +0 -27
- package/dist/types/src/helpers/date.d.ts +0 -7
- package/dist/types/src/helpers/handleMessages.d.ts +0 -2
- package/dist/types/src/helpers/loadComponents.d.ts +0 -10
- package/dist/types/src/helpers/participants.d.ts +0 -50
- package/dist/types/src/helpers/rights.d.ts +0 -19
- package/dist/types/src/helpers/sdkOptions.d.ts +0 -17
- package/dist/types/src/helpers/sounds.d.ts +0 -8
- package/dist/types/src/helpers/supportStatus.d.ts +0 -15
- package/dist/types/src/interfaces/Conversation.d.ts +0 -44
- package/dist/types/src/interfaces/ConversationSla.d.ts +0 -9
- package/dist/types/src/interfaces/IncomingFrame.d.ts +0 -71
- package/dist/types/src/interfaces/Message.d.ts +0 -18
- package/dist/types/src/interfaces/ParticipantDocument.d.ts +0 -13
- package/dist/types/src/libs/StudioSDK.d.ts +0 -148
- package/dist/types/src/libs/chatSession.d.ts +0 -113
- package/dist/types/src/libs/resize.d.ts +0 -79
- package/dist/types/src/libs/websocketManager.d.ts +0 -54
- package/dist/types/src/locales/de.d.ts +0 -115
- package/dist/types/src/locales/en.d.ts +0 -115
- package/dist/types/src/main.d.ts +0 -1
- package/dist/types/src/mixins/groupMessages.d.ts +0 -14
- package/dist/types/src/mixins/hardCopy.d.ts +0 -2
- package/dist/types/src/mixins/logger.d.ts +0 -8
- package/dist/types/src/mixins/traceable.d.ts +0 -11
- package/dist/types/src/plugins/i18n.d.ts +0 -124
- package/dist/types/src/standalone/auth.d.ts +0 -26
- package/dist/types/src/standalone/main.d.ts +0 -1
- package/dist/types/src/standalone/settings.d.ts +0 -63
- package/dist/types/src/standalone-support/main.d.ts +0 -1
- package/dist/types/src/stores/bots.store.d.ts +0 -69
- package/dist/types/src/stores/calls.store.d.ts +0 -14
- package/dist/types/src/stores/contacts.store.d.ts +0 -87
- package/dist/types/src/stores/conversations.store.d.ts +0 -2228
- package/dist/types/src/stores/main.store.d.ts +0 -184
- package/dist/types/src/stores/supportConversations.store.d.ts +0 -65
- package/dist/types/src/stores/user.store.d.ts +0 -8
- package/dist/types/src/stores/usersCache.store.d.ts +0 -31
- package/dist/types/src/styles/loadFonts.d.ts +0 -15
- package/dist/types/src/support-agent.d.ts +0 -18
- package/dist/types/tsconfig.build.tsbuildinfo +0 -1
- package/dist/wc-support/lilaquadrat-studio-support.js +0 -9
- package/dist/wc-support/lilaquadrat-studio-support.umd.cjs +0 -1
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import type { Pinia } from 'pinia';
|
|
2
|
-
import { type Feature } from '@/stores/main.store';
|
|
3
|
-
import { type GetUsersFn } from '@/config/users';
|
|
4
|
-
import { type GetTokenFn } from '@/config/auth';
|
|
5
|
-
import type { ParticipantUser } from '@/helpers/participants';
|
|
6
|
-
/**
|
|
7
|
-
* The host-facing configuration and how it is applied to the stores.
|
|
8
|
-
*
|
|
9
|
-
* This lives apart from bootstrap.ts on purpose. bootstrap.ts statically imports every
|
|
10
|
-
* customer-only component, and rollup tree-shakes by module, not by branch — so a support-agent
|
|
11
|
-
* entry that pulled `applyConfig` out of bootstrap.ts would drag the whole customer widget into
|
|
12
|
-
* its bundle and undo the point of shipping a second element. Both bootstrap paths import from
|
|
13
|
-
* here instead; bootstrap.ts re-exports for existing consumers.
|
|
14
|
-
*/
|
|
15
|
-
export interface ChatModuleConfig {
|
|
16
|
-
/** how the host resolves users. Required for default mode; unused in support mode. */
|
|
17
|
-
getUsers?: GetUsersFn;
|
|
18
|
-
/**
|
|
19
|
-
* enabled features. Defaults to ['chat']. The two are orthogonal:
|
|
20
|
-
* ['chat'] = normal user↔user chats only
|
|
21
|
-
* ['support'] = support-only widget
|
|
22
|
-
* ['chat','support'] = normal chats + an on-demand support chat alongside them
|
|
23
|
-
*/
|
|
24
|
-
features?: Feature[];
|
|
25
|
-
/**
|
|
26
|
-
* @deprecated legacy single-axis mode; use `features` instead.
|
|
27
|
-
* 'chat'|'default' → ['chat'], 'support' → ['support'], 'both' → ['chat','support'].
|
|
28
|
-
*/
|
|
29
|
-
mode?: 'chat' | 'support' | 'both' | 'default';
|
|
30
|
-
/** the current user id. Falls back to the ?user= query param (dev) when omitted. */
|
|
31
|
-
userId?: string;
|
|
32
|
-
/**
|
|
33
|
-
* the current user's own profile (prename/lastname/...). The backend enriches *other*
|
|
34
|
-
* participants but not the requesting user, so the host passes its own data here to
|
|
35
|
-
* resolve the current user's name. `id` defaults to `userId` when omitted.
|
|
36
|
-
*/
|
|
37
|
-
user?: ParticipantUser;
|
|
38
|
-
/**
|
|
39
|
-
* @deprecated ignored. The backend owns the support team (everyone holding the
|
|
40
|
-
* `support:member` scope) and attaches it itself, so a client-side recipient list could
|
|
41
|
-
* only ever drift from reality. Still accepted so existing embeds keep working.
|
|
42
|
-
*/
|
|
43
|
-
support?: {
|
|
44
|
-
participants: string[];
|
|
45
|
-
};
|
|
46
|
-
/** websocket endpoint. Defaults to ws://localhost:3001 (dev). */
|
|
47
|
-
wsUrl?: string;
|
|
48
|
-
/** API endpoint. Defaults to http://localhost:3000 (dev). */
|
|
49
|
-
apiUrl?: string;
|
|
50
|
-
/** media endpoint. Defaults to http://localhost:3000 (dev). */
|
|
51
|
-
mediaUrl?: string;
|
|
52
|
-
/** called whenever the unread message/conversation count changes */
|
|
53
|
-
unread?: (_stats: {
|
|
54
|
-
unreadMessages: number;
|
|
55
|
-
unreadConversations: number;
|
|
56
|
-
}) => void;
|
|
57
|
-
/** called when the close button in the header is clicked */
|
|
58
|
-
close?: () => void;
|
|
59
|
-
/**
|
|
60
|
-
* notification sounds. On at full volume by default; `false` silences them.
|
|
61
|
-
* A sound is only played for remote events the user cannot currently see.
|
|
62
|
-
*/
|
|
63
|
-
sound?: boolean | {
|
|
64
|
-
enabled?: boolean;
|
|
65
|
-
volume?: number;
|
|
66
|
-
};
|
|
67
|
-
/** the host's OIDC access token. Identity is derived from its `sub`; sent as Bearer + WS auth. */
|
|
68
|
-
token?: string;
|
|
69
|
-
/**
|
|
70
|
-
* host-provided token resolver. Called on every (re)connect; may be async and must always
|
|
71
|
-
* return a currently-valid token. Receives `true` after AUTH_FAILED to force rotation.
|
|
72
|
-
* Preferred over the static `token` — identity comes from its `sub`.
|
|
73
|
-
*/
|
|
74
|
-
getToken?: GetTokenFn;
|
|
75
|
-
}
|
|
76
|
-
/** resolve the enabled features from config: explicit `features` wins, else map legacy `mode`. */
|
|
77
|
-
export declare function resolveFeatures(config: ChatModuleConfig): Feature[];
|
|
78
|
-
/**
|
|
79
|
-
* Apply host configuration to the stores / providers. Shared by every bootstrap path
|
|
80
|
-
* (createChatModule, the <lilaquadrat-studio-chat> element and the support-agent element).
|
|
81
|
-
* Pass the pinia instance when calling outside an active-pinia context.
|
|
82
|
-
*/
|
|
83
|
-
export declare function applyConfig(config: ChatModuleConfig, pinia?: Pinia): void;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Components every bundle needs: the shell App.vue renders plus everything reachable from the
|
|
3
|
-
* chat view (chats → chat → chat-header/chat-input, main-right-target → chat/user details).
|
|
4
|
-
*
|
|
5
|
-
* This lives in its own file on purpose. Rollup only tree-shakes across module boundaries, so a
|
|
6
|
-
* runtime flag inside bootstrap.ts could not drop a single byte — the `import` statements at the
|
|
7
|
-
* top of that file are what pull the components into the bundle. The support-agent entry imports
|
|
8
|
-
* only these two lists and therefore never references the customer-only components at all.
|
|
9
|
-
*/
|
|
10
|
-
declare const SHARED_MODULES: {
|
|
11
|
-
name: string;
|
|
12
|
-
component: import("vue").DefineComponent<Record<string, unknown>, Record<string, unknown>, unknown>;
|
|
13
|
-
}[];
|
|
14
|
-
declare const SHARED_PARTIALS: {
|
|
15
|
-
name: string;
|
|
16
|
-
component: import("vue").DefineComponent<Record<string, unknown>, Record<string, unknown>, unknown>;
|
|
17
|
-
}[];
|
|
18
|
-
export { SHARED_MODULES, SHARED_PARTIALS, };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pluggable user source.
|
|
3
|
-
*
|
|
4
|
-
* The chat module never hardcodes its users. The host application provides the
|
|
5
|
-
* implementation once, via `createChatModule({ getUsers })` (see main.ts) or by
|
|
6
|
-
* calling `setGetUsers()` directly before the contacts UI is used. This lets every
|
|
7
|
-
* host plug in its own backend (REST, OIDC, in-memory, ...).
|
|
8
|
-
*/
|
|
9
|
-
export interface ChatUser {
|
|
10
|
-
id: string;
|
|
11
|
-
prename?: string;
|
|
12
|
-
lastname?: string;
|
|
13
|
-
name?: string;
|
|
14
|
-
status?: string;
|
|
15
|
-
}
|
|
16
|
-
export interface GetUsersOptions {
|
|
17
|
-
/** restrict to specific user ids (e.g. to resolve participant names) */
|
|
18
|
-
ids?: string[];
|
|
19
|
-
/** free-text search/filter */
|
|
20
|
-
query?: string;
|
|
21
|
-
}
|
|
22
|
-
export type GetUsersFn = (_options?: GetUsersOptions) => Promise<ChatUser[]> | ChatUser[];
|
|
23
|
-
/** register the host implementation. last call wins. */
|
|
24
|
-
export declare function setGetUsers(fn: GetUsersFn): void;
|
|
25
|
-
export declare function hasGetUsers(): boolean;
|
|
26
|
-
/** resolve users through the registered implementation. returns [] (with a warning) if none was set. */
|
|
27
|
-
export declare function getUsers(options?: GetUsersOptions): Promise<ChatUser[]>;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import dayjs from 'dayjs';
|
|
2
|
-
import 'dayjs/locale/de';
|
|
3
|
-
import 'dayjs/locale/en';
|
|
4
|
-
declare function date(date: string | Date | dayjs.Dayjs, format?: string): string;
|
|
5
|
-
declare function time(date: string | Date | dayjs.Dayjs, format?: string): string;
|
|
6
|
-
declare function dateRelative(date: string | Date | dayjs.Dayjs): string;
|
|
7
|
-
export { date, time, dateRelative, dayjs };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type App, type Component, type AsyncComponentLoader } from 'vue';
|
|
2
|
-
declare function loadViaDeclaration(components: {
|
|
3
|
-
name: string;
|
|
4
|
-
component: AsyncComponentLoader<Component>;
|
|
5
|
-
}[], namespace: string | undefined, type: 'module' | 'partial', app: App<Element>): void;
|
|
6
|
-
declare function loadViaDeclarationSync(components: {
|
|
7
|
-
name: string;
|
|
8
|
-
component: Component;
|
|
9
|
-
}[], namespace: string | undefined, type: 'module' | 'partial', app: App<Element>): void;
|
|
10
|
-
export { loadViaDeclaration, loadViaDeclarationSync, };
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Participants arrive in two shapes: backend-enriched objects ({ id, prename, ... })
|
|
3
|
-
* on real conversations, and bare id strings on local drafts (and on the write path
|
|
4
|
-
* we send back to the server). These helpers normalize both so comparisons, keys and
|
|
5
|
-
* display work regardless of shape.
|
|
6
|
-
*/
|
|
7
|
-
export interface ParticipantUser {
|
|
8
|
-
id: string;
|
|
9
|
-
prename?: string;
|
|
10
|
-
lastname?: string;
|
|
11
|
-
email?: string;
|
|
12
|
-
/** host-provided contact name (see @/config/users ChatUser) */
|
|
13
|
-
name?: string;
|
|
14
|
-
/** presence: last proof of life as an ISO string; absent for a user who never connected */
|
|
15
|
-
lastSeen?: string;
|
|
16
|
-
/** presence: derived server-side from lastSeen freshness, pushed live via user:presence */
|
|
17
|
-
online?: boolean;
|
|
18
|
-
/**
|
|
19
|
-
* the participant's role in the conversation. `'agent'` for a member of the support team.
|
|
20
|
-
*
|
|
21
|
-
* `null`, not absent, for everyone else: the backend collapses two different absences with an
|
|
22
|
-
* `$ifNull` (no participant doc at all vs. a doc carrying no role) so that both the REST row
|
|
23
|
-
* and the `conversation:new` frame carry the key on every participant. Never test for
|
|
24
|
-
* `undefined` or `'role' in participant` — that would hold on one path and not the other.
|
|
25
|
-
* Optional here only because a local draft's participants are built client-side.
|
|
26
|
-
*/
|
|
27
|
-
role?: 'agent' | null;
|
|
28
|
-
}
|
|
29
|
-
export type Participant = string | ParticipantUser;
|
|
30
|
-
/** the user id of a participant, whether it's a bare id or an object */
|
|
31
|
-
export declare function participantId(participant: Participant): string;
|
|
32
|
-
/** map a participant list to its ids (e.g. before sending to the backend) */
|
|
33
|
-
export declare function participantIds(participants?: Participant[]): string[];
|
|
34
|
-
/**
|
|
35
|
-
* the person being helped in a support conversation: the participant NOT marked
|
|
36
|
-
* `role: 'agent'`. There is no separate customer entity — a support conversation is a
|
|
37
|
-
* conversation whose participants carry roles, and this reads the counterpart back out.
|
|
38
|
-
*
|
|
39
|
-
* Matched by inequality against `'agent'`, deliberately: the counterpart's role arrives as
|
|
40
|
-
* `null` from the server and is absent on a client-built draft, so anything testing for
|
|
41
|
-
* `undefined` specifically would hold on one path and not the other.
|
|
42
|
-
*
|
|
43
|
-
* undefined when nothing in the list distinguishes anyone. That is the legacy case
|
|
44
|
-
* (conversations from before roles were stamped mark nobody): with no agent marked, every
|
|
45
|
-
* participant looks alike, and guessing would name an agent as the person being helped.
|
|
46
|
-
* Callers show an unknown counterpart instead.
|
|
47
|
-
*/
|
|
48
|
-
export declare function customerParticipant(participants?: Participant[]): ParticipantUser | undefined;
|
|
49
|
-
/** human-readable name: "lastname, prename", else host name, else the raw id */
|
|
50
|
-
export declare function participantName(participant: Participant): string;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export interface ConversationRightsSource {
|
|
2
|
-
isNew?: boolean;
|
|
3
|
-
participant?: {
|
|
4
|
-
state?: string;
|
|
5
|
-
rights?: string[];
|
|
6
|
-
};
|
|
7
|
-
}
|
|
8
|
-
type Conversation = ConversationRightsSource | null | undefined;
|
|
9
|
-
/**
|
|
10
|
-
* still a member? drafts count, every non-active backend state does not — the server
|
|
11
|
-
* knows 'active' | 'left' | 'removed' | 'blocked' | 'deleted' and keeps only 'active'
|
|
12
|
-
* participants in `conversation.participants` (see participants.service).
|
|
13
|
-
* A missing state means the payload does not track it — treated as a member, the
|
|
14
|
-
* rights check below still applies.
|
|
15
|
-
*/
|
|
16
|
-
export declare function isActiveParticipant(conversation: Conversation): boolean;
|
|
17
|
-
/** membership plus the named right ('read' | 'write' | 'rename' | 'participants' | 'block') */
|
|
18
|
-
export declare function can(conversation: Conversation, right: string): boolean;
|
|
19
|
-
export default can;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Options for a StudioSDK instance: a currently-valid token plus the configured endpoints.
|
|
3
|
-
*
|
|
4
|
-
* The token is re-resolved through the host's `getToken` on every call rather than read once at
|
|
5
|
-
* boot. The WS session already re-authenticates with a fresh token on every (re)connect (see
|
|
6
|
-
* libs/chatSession.ts); without this, HTTP kept sending the boot-time token and started to 401
|
|
7
|
-
* once it expired — harmless in a host app that reloads often, fatal for a standalone tab left
|
|
8
|
-
* open. Hosts that pass only a static `token` are unaffected: resolveToken() returns undefined
|
|
9
|
-
* and the stored token is used.
|
|
10
|
-
*/
|
|
11
|
-
export default function sdkOptions(): Promise<{
|
|
12
|
-
authToken: string;
|
|
13
|
-
customEndpoints: {
|
|
14
|
-
api: string;
|
|
15
|
-
media: string;
|
|
16
|
-
};
|
|
17
|
-
}>;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export type SoundName = 'new-message' | 'new-conversation';
|
|
2
|
-
/**
|
|
3
|
-
* Play a notification sound. Never throws and never rejects: browsers refuse audio until
|
|
4
|
-
* the page has seen a user gesture, and a machine without an output device rejects too —
|
|
5
|
-
* neither is worth surfacing for something purely decorative.
|
|
6
|
-
*/
|
|
7
|
-
export declare function playSound(name: SoundName, volume?: number): void;
|
|
8
|
-
export default playSound;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { ConversationSla } from '@/interfaces/ConversationSla';
|
|
2
|
-
export declare const SUPPORT_STATUSES: readonly ["awaiting_agent", "awaiting_customer", "resolved"];
|
|
3
|
-
export type SupportStatus = typeof SUPPORT_STATUSES[number];
|
|
4
|
-
export type SupportStatusFilter = SupportStatus | 'all';
|
|
5
|
-
export interface SupportStatusResponse {
|
|
6
|
-
conversation: string;
|
|
7
|
-
status: SupportStatus;
|
|
8
|
-
updatedAt: string;
|
|
9
|
-
version: number;
|
|
10
|
-
sla: ConversationSla | null;
|
|
11
|
-
serverTime: string;
|
|
12
|
-
}
|
|
13
|
-
export declare const DEFAULT_SUPPORT_STATUS: SupportStatus;
|
|
14
|
-
export declare function isSupportStatus(value: unknown): value is SupportStatus;
|
|
15
|
-
export declare function normalizeSupportStatus(value: unknown): SupportStatus;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type { Participant } from '@/helpers/participants';
|
|
2
|
-
import type { SupportStatus } from '@/helpers/supportStatus';
|
|
3
|
-
import type { Message } from '@/interfaces/Message';
|
|
4
|
-
import type { ParticipantDocument } from '@/interfaces/ParticipantDocument';
|
|
5
|
-
import type { ConversationSla } from '@/interfaces/ConversationSla';
|
|
6
|
-
export type ConversationOperationMode = 'chat' | 'support';
|
|
7
|
-
export interface Conversation {
|
|
8
|
-
_id?: string;
|
|
9
|
-
id?: string;
|
|
10
|
-
name?: string;
|
|
11
|
-
participants: Participant[];
|
|
12
|
-
blocked?: string[];
|
|
13
|
-
messagesCount?: number;
|
|
14
|
-
messagesCountSystem?: number;
|
|
15
|
-
createdAt?: string;
|
|
16
|
-
lastActivity?: string;
|
|
17
|
-
operationMode: ConversationOperationMode;
|
|
18
|
-
supportStatus?: SupportStatus;
|
|
19
|
-
supportStatusUpdatedAt?: string;
|
|
20
|
-
supportStatusVersion?: number;
|
|
21
|
-
sla?: ConversationSla | null;
|
|
22
|
-
participant?: ParticipantDocument;
|
|
23
|
-
participantDocs?: ParticipantDocument[];
|
|
24
|
-
lastMessage?: Message;
|
|
25
|
-
oldestMessageId?: number | null;
|
|
26
|
-
messages?: Message[];
|
|
27
|
-
messagesLoaded?: boolean;
|
|
28
|
-
unreadCount?: number;
|
|
29
|
-
unread?: boolean;
|
|
30
|
-
isMember?: boolean;
|
|
31
|
-
isNew?: boolean;
|
|
32
|
-
isTemp?: boolean;
|
|
33
|
-
creator?: string;
|
|
34
|
-
}
|
|
35
|
-
export type ConversationPayload = Omit<Conversation, '_id' | 'operationMode' | 'participants'> & {
|
|
36
|
-
_id: string;
|
|
37
|
-
operationMode?: 'default' | ConversationOperationMode;
|
|
38
|
-
participants?: Participant[];
|
|
39
|
-
};
|
|
40
|
-
export type SupportConversationPage = {
|
|
41
|
-
data: ConversationPayload[];
|
|
42
|
-
hasMore: boolean;
|
|
43
|
-
serverTime?: string;
|
|
44
|
-
};
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import type { Participant } from '@/helpers/participants';
|
|
2
|
-
import type { SupportStatus } from '@/helpers/supportStatus';
|
|
3
|
-
import type { ConversationPayload } from '@/interfaces/Conversation';
|
|
4
|
-
import type { Message } from '@/interfaces/Message';
|
|
5
|
-
import type { ConversationSla } from '@/interfaces/ConversationSla';
|
|
6
|
-
export type ConversationNewFrame = ConversationPayload & {
|
|
7
|
-
type: 'conversation:new';
|
|
8
|
-
};
|
|
9
|
-
export type ConversationRenamedFrame = {
|
|
10
|
-
type: 'conversation:renamed';
|
|
11
|
-
conversation: string;
|
|
12
|
-
names: {
|
|
13
|
-
to: string;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
export type ConversationParticipantsFrame = {
|
|
17
|
-
type: 'conversation:participants';
|
|
18
|
-
conversation: string;
|
|
19
|
-
participants: Participant[];
|
|
20
|
-
};
|
|
21
|
-
export type ConversationUserFrame = {
|
|
22
|
-
type: 'conversation:left';
|
|
23
|
-
conversation: string;
|
|
24
|
-
user: string;
|
|
25
|
-
};
|
|
26
|
-
export type ConversationRemovedFrame = {
|
|
27
|
-
type: 'conversation:removed';
|
|
28
|
-
conversation: string;
|
|
29
|
-
};
|
|
30
|
-
export type ConversationMutedFrame = {
|
|
31
|
-
type: 'conversation:muted';
|
|
32
|
-
conversation: string;
|
|
33
|
-
muted: boolean;
|
|
34
|
-
};
|
|
35
|
-
export type ConversationStatusFrame = {
|
|
36
|
-
type: 'conversation:status';
|
|
37
|
-
conversation: string;
|
|
38
|
-
status: SupportStatus;
|
|
39
|
-
version: number;
|
|
40
|
-
updatedAt: string;
|
|
41
|
-
sla: ConversationSla | null;
|
|
42
|
-
serverTime: string;
|
|
43
|
-
};
|
|
44
|
-
export type ConversationRightsFrame = {
|
|
45
|
-
type: 'conversation:rights';
|
|
46
|
-
conversation: string;
|
|
47
|
-
user: string;
|
|
48
|
-
rights: string[];
|
|
49
|
-
};
|
|
50
|
-
export type ConversationTypingFrame = {
|
|
51
|
-
type: 'conversation:typing';
|
|
52
|
-
conversation: string;
|
|
53
|
-
user: string;
|
|
54
|
-
typing: boolean;
|
|
55
|
-
};
|
|
56
|
-
export type UserPresenceFrame = {
|
|
57
|
-
type: 'user:presence';
|
|
58
|
-
user: string;
|
|
59
|
-
online: boolean;
|
|
60
|
-
lastSeen?: string;
|
|
61
|
-
};
|
|
62
|
-
export type ErrorFrame = {
|
|
63
|
-
type: 'error';
|
|
64
|
-
error?: unknown;
|
|
65
|
-
messageType?: string;
|
|
66
|
-
};
|
|
67
|
-
export type MessageFrame = Message & {
|
|
68
|
-
type: 'message';
|
|
69
|
-
};
|
|
70
|
-
export type IncomingFrame = ConversationNewFrame | ConversationRenamedFrame | ConversationParticipantsFrame | ConversationUserFrame | ConversationRemovedFrame | ConversationMutedFrame | ConversationStatusFrame | ConversationRightsFrame | ConversationTypingFrame | UserPresenceFrame | ErrorFrame | MessageFrame;
|
|
71
|
-
export declare function isIncomingFrame(value: unknown): value is IncomingFrame;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export type MessageHistory = {
|
|
2
|
-
created: string;
|
|
3
|
-
updated?: string;
|
|
4
|
-
};
|
|
5
|
-
export interface Message {
|
|
6
|
-
_id?: string;
|
|
7
|
-
id: number;
|
|
8
|
-
conversation: string;
|
|
9
|
-
user?: string;
|
|
10
|
-
message?: string;
|
|
11
|
-
origin: 'user' | 'system';
|
|
12
|
-
history: MessageHistory;
|
|
13
|
-
action?: string;
|
|
14
|
-
actionData?: Record<string, unknown>;
|
|
15
|
-
clientMessageId?: string;
|
|
16
|
-
duplicate?: boolean;
|
|
17
|
-
isUser?: boolean;
|
|
18
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export type ParticipantState = 'active' | 'left' | 'removed' | 'blocked' | 'deleted';
|
|
2
|
-
export interface ParticipantDocument {
|
|
3
|
-
_id?: string;
|
|
4
|
-
conversation: string;
|
|
5
|
-
user: string;
|
|
6
|
-
state: ParticipantState;
|
|
7
|
-
rights: string[];
|
|
8
|
-
lastReadId?: number;
|
|
9
|
-
latestMessageId?: number;
|
|
10
|
-
muted?: boolean;
|
|
11
|
-
role?: 'agent';
|
|
12
|
-
joinedAt?: string;
|
|
13
|
-
}
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { type AxiosResponse, type AxiosRequestConfig } from 'axios';
|
|
2
|
-
import type { SupportStatus, SupportStatusResponse } from '@/helpers/supportStatus';
|
|
3
|
-
import type { ConversationPayload, SupportConversationPage } from '@/interfaces/Conversation';
|
|
4
|
-
import type { Message } from '@/interfaces/Message';
|
|
5
|
-
import type { ParticipantDocument } from '@/interfaces/ParticipantDocument';
|
|
6
|
-
import type { ChatUser } from '@/config/users';
|
|
7
|
-
type HttpStatusCode = number;
|
|
8
|
-
export type SDKResponse<T> = {
|
|
9
|
-
data: T;
|
|
10
|
-
status: HttpStatusCode;
|
|
11
|
-
cacheLifetime?: number;
|
|
12
|
-
cacheTime?: number;
|
|
13
|
-
isCache?: boolean;
|
|
14
|
-
};
|
|
15
|
-
export type SDKCache = {
|
|
16
|
-
group?: string;
|
|
17
|
-
action?: string;
|
|
18
|
-
id?: string;
|
|
19
|
-
cacheLifetime?: number;
|
|
20
|
-
cacheTime?: number;
|
|
21
|
-
};
|
|
22
|
-
export type SDKCallOptions = {
|
|
23
|
-
/**
|
|
24
|
-
* ignore the cache and always execute the call
|
|
25
|
-
*/
|
|
26
|
-
bypassCache?: boolean;
|
|
27
|
-
group?: string;
|
|
28
|
-
action?: string;
|
|
29
|
-
/**
|
|
30
|
-
* if a id is given, use it as key for atomic cache flushing
|
|
31
|
-
*
|
|
32
|
-
* e.g. ``flushId(id)``
|
|
33
|
-
*
|
|
34
|
-
* instead of the whole action category
|
|
35
|
-
*
|
|
36
|
-
* e.g. ``flushCache(group, action)``
|
|
37
|
-
*
|
|
38
|
-
*/
|
|
39
|
-
id?: string;
|
|
40
|
-
/**
|
|
41
|
-
* in milliseconds
|
|
42
|
-
*/
|
|
43
|
-
cacheLifetime?: number;
|
|
44
|
-
};
|
|
45
|
-
export default class StudioSDK {
|
|
46
|
-
readonly endpoints: {
|
|
47
|
-
live: {
|
|
48
|
-
api: string;
|
|
49
|
-
media: string;
|
|
50
|
-
};
|
|
51
|
-
next: {
|
|
52
|
-
api: string;
|
|
53
|
-
media: string;
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
customEndpoints: {
|
|
57
|
-
api: string;
|
|
58
|
-
media: string;
|
|
59
|
-
};
|
|
60
|
-
authToken: string;
|
|
61
|
-
mode: 'live' | 'next' | 'custom';
|
|
62
|
-
company: string;
|
|
63
|
-
project: string;
|
|
64
|
-
app: string;
|
|
65
|
-
universalModel: string;
|
|
66
|
-
options: {
|
|
67
|
-
company?: string;
|
|
68
|
-
project?: string;
|
|
69
|
-
authToken?: string;
|
|
70
|
-
mode?: StudioSDK['mode'];
|
|
71
|
-
customEndpoints?: {
|
|
72
|
-
api: string;
|
|
73
|
-
media: string;
|
|
74
|
-
};
|
|
75
|
-
universalModel?: string;
|
|
76
|
-
};
|
|
77
|
-
constructor(app: string, options: StudioSDK['options']);
|
|
78
|
-
private getUrl;
|
|
79
|
-
private getHeaders;
|
|
80
|
-
static getCacheKeyMock(url: string): string;
|
|
81
|
-
static getCacheKey(url: string): string;
|
|
82
|
-
static getCache(): Record<string, SDKResponse<unknown> & SDKCache>;
|
|
83
|
-
static handleCall<T, D = unknown>(call: AxiosRequestConfig<D>, options?: SDKCallOptions): Promise<SDKResponse<T>>;
|
|
84
|
-
static cache<T>(url: string, response?: AxiosResponse<T>, options?: SDKCallOptions): SDKResponse<T> & SDKCache;
|
|
85
|
-
static flushCache(group?: string, action?: string): void;
|
|
86
|
-
/**
|
|
87
|
-
* one id can hold several entries (one per query string, e.g. every `beforeId` page of a
|
|
88
|
-
* conversation), so flushing has to drop all of them — otherwise a new message would only
|
|
89
|
-
* invalidate the page whose url happened to match.
|
|
90
|
-
*/
|
|
91
|
-
static flushId(id: string): void;
|
|
92
|
-
conversations: {
|
|
93
|
-
list: () => Promise<SDKResponse<ConversationPayload[]>>;
|
|
94
|
-
activate: () => Promise<SDKResponse<unknown>>;
|
|
95
|
-
create: (data: {
|
|
96
|
-
participants: string[];
|
|
97
|
-
}) => Promise<SDKResponse<unknown>>;
|
|
98
|
-
rename: (conversationId: string, name: string) => Promise<SDKResponse<unknown>>;
|
|
99
|
-
participants: (conversationId: string, add: string[], remove: string[]) => Promise<SDKResponse<unknown>>;
|
|
100
|
-
leave: (conversationId: string) => Promise<SDKResponse<unknown>>;
|
|
101
|
-
/**
|
|
102
|
-
* POST, not DELETE: this removes the conversation for the CALLER only (their participant
|
|
103
|
-
* state goes to 'deleted' server-side), it does not delete the resource for everyone.
|
|
104
|
-
*/
|
|
105
|
-
delete: (conversationId: string) => Promise<SDKResponse<unknown>>;
|
|
106
|
-
listParticipants: (conversationId: string) => Promise<SDKResponse<ParticipantDocument[]>>;
|
|
107
|
-
rights: (conversationId: string, user: string, rights: string[]) => Promise<SDKResponse<unknown>>;
|
|
108
|
-
/**
|
|
109
|
-
* silence the conversation for the CALLER only. Stored on their participant doc and never
|
|
110
|
-
* broadcast to the other members — muting is private.
|
|
111
|
-
*/
|
|
112
|
-
mute: (conversationId: string, muted: boolean) => Promise<SDKResponse<unknown>>;
|
|
113
|
-
block: (conversationId: string, user: string, block: boolean) => Promise<SDKResponse<unknown>>;
|
|
114
|
-
};
|
|
115
|
-
contacts: {
|
|
116
|
-
list: (search?: string) => Promise<SDKResponse<ChatUser[]>>;
|
|
117
|
-
single: (contactId: string) => Promise<SDKResponse<ChatUser>>;
|
|
118
|
-
block: (contactId: string) => Promise<SDKResponse<unknown>>;
|
|
119
|
-
unblock: (contactId: string) => Promise<SDKResponse<unknown>>;
|
|
120
|
-
};
|
|
121
|
-
messages: {
|
|
122
|
-
list: (conversation: string, beforeId?: number) => Promise<SDKResponse<Message[]>>;
|
|
123
|
-
};
|
|
124
|
-
support: {
|
|
125
|
-
/**
|
|
126
|
-
* every support conversation the staff can see, newest activity first. Mirrors
|
|
127
|
-
* conversations.list() for the agent side. Keyset pagination — pass the last row's
|
|
128
|
-
* `lastActivity` as `before` and its `_id` as `beforeId`.
|
|
129
|
-
*
|
|
130
|
-
* Its own cache GROUP on purpose, even though the action is now also called 'list'.
|
|
131
|
-
* deleteConversation() and setMuted() flush ('conversations','list') to drop a stale
|
|
132
|
-
* customer list; if this shared that group a flush would take it with it — and, worse, this
|
|
133
|
-
* loader's own reload() flushing 'conversations' would throw away a list the agent console
|
|
134
|
-
* never even loads.
|
|
135
|
-
*/
|
|
136
|
-
list: (options?: {
|
|
137
|
-
limit?: number;
|
|
138
|
-
before?: string;
|
|
139
|
-
beforeId?: string;
|
|
140
|
-
status?: SupportStatus;
|
|
141
|
-
}) => Promise<SDKResponse<SupportConversationPage>>;
|
|
142
|
-
setStatus: (conversationId: string, status: SupportStatus, version: number) => Promise<SDKResponse<SupportStatusResponse>>;
|
|
143
|
-
};
|
|
144
|
-
health: {
|
|
145
|
-
health: () => Promise<SDKResponse<void>>;
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
export {};
|