@cossistant/core 0.0.28 → 0.0.29
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/client.d.ts +11 -1
- package/client.d.ts.map +1 -1
- package/client.js +32 -1
- package/client.js.map +1 -1
- package/package.json +1 -1
- package/realtime-events.d.ts +124 -0
- package/realtime-events.d.ts.map +1 -1
- package/types/src/enums.js +4 -1
- package/types/src/enums.js.map +1 -1
package/client.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { CossistantRestClient } from "./rest-client.js";
|
|
|
6
6
|
import { ConversationsStore } from "./store/conversations-store.js";
|
|
7
7
|
import { TimelineItemsStore } from "./store/timeline-items-store.js";
|
|
8
8
|
import { WebsiteStore } from "./store/website-store.js";
|
|
9
|
-
import { AnyRealtimeEvent, DefaultMessage, IdentifyContactResponse } from "@cossistant/types";
|
|
9
|
+
import { AnyRealtimeEvent, DefaultMessage, IdentifyContactResponse, RealtimeEvent } from "@cossistant/types";
|
|
10
10
|
|
|
11
11
|
//#region src/client.d.ts
|
|
12
12
|
type InitiateConversationParams = {
|
|
@@ -88,6 +88,16 @@ declare class CossistantClient {
|
|
|
88
88
|
wasConversationCreated?: boolean;
|
|
89
89
|
}>;
|
|
90
90
|
handleRealtimeEvent(event: AnyRealtimeEvent): void;
|
|
91
|
+
/**
|
|
92
|
+
* Extract conversation status from an event timeline item.
|
|
93
|
+
* Returns the new status if this is a status-changing event, otherwise null.
|
|
94
|
+
*/
|
|
95
|
+
private extractStatusFromEventTimelineItem;
|
|
96
|
+
/**
|
|
97
|
+
* Handle conversationUpdated event from realtime
|
|
98
|
+
* Updates conversation with new title (sentiment and escalation are dashboard-only)
|
|
99
|
+
*/
|
|
100
|
+
handleConversationUpdated(event: RealtimeEvent<"conversationUpdated">): void;
|
|
91
101
|
/**
|
|
92
102
|
* Generate a presigned URL for uploading a file to S3.
|
|
93
103
|
*/
|
package/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
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A,EAAA,MAAA,GAAA,IAAA;MACgB,SAAA,EAAA,MAAA,GAAA,IAAA;MACQ,UAAA,EAAA,MAAA;MAHtB,SAAA,EAAA,MAAA;MAsHwB,SAAA,EAAA,MAAA;MA8EM,SAAA,EAAA,MAAA,GAAA,IAAA;IA4BpB,CAAA,EAAA;EAAX,CAAA,CAAA;EADO,gBAAA,CAAA,MAAA,EAAA;IAGP,cAAA,EAAA,MAAA;IAQqB,QAAA,EAAA,OAAA;IAA4C,cAAA,CAAA,EAAA,MAAA,GAAA,IAAA;IAOhC,SAAA,CAAA,EAAA,MAAA;EAA8B,CAAA,CAAA,EArQ7D,OAqQ6D,CArQrD,iCAqQqD,CAAA;EAAA,4BAAA,CAAA,MAAA,EA9PxD,mCA8PwD,GAAA;;MA7P9D,QAAQ;sBAWF;;MACN,QACF;mBACgB;2BACQ;;;6BAmHE;;;;;;;;;;mCA8EM;;;;4BA2BxB,KACP,WAAW,8DAEX;;;;;;;;;;;mBAQqB,+CAA4C;;;;+BAOhC,iCAA8B"}
|
package/client.js
CHANGED
|
@@ -218,16 +218,47 @@ var CossistantClient = class {
|
|
|
218
218
|
const timelineItem = this.timelineItemsStore.ingestRealtimeTimelineItem(event);
|
|
219
219
|
const existingConversation = this.conversationsStore.getState().byId[timelineItem.conversationId];
|
|
220
220
|
if (existingConversation) {
|
|
221
|
+
const newStatus = this.extractStatusFromEventTimelineItem(timelineItem);
|
|
221
222
|
const nextConversation = {
|
|
222
223
|
...existingConversation,
|
|
223
224
|
updatedAt: timelineItem.createdAt,
|
|
224
|
-
lastTimelineItem: timelineItem
|
|
225
|
+
lastTimelineItem: timelineItem,
|
|
226
|
+
...newStatus && { status: newStatus }
|
|
225
227
|
};
|
|
226
228
|
this.conversationsStore.ingestConversation(nextConversation);
|
|
227
229
|
}
|
|
228
230
|
}
|
|
229
231
|
}
|
|
230
232
|
/**
|
|
233
|
+
* Extract conversation status from an event timeline item.
|
|
234
|
+
* Returns the new status if this is a status-changing event, otherwise null.
|
|
235
|
+
*/
|
|
236
|
+
extractStatusFromEventTimelineItem(timelineItem) {
|
|
237
|
+
if (timelineItem.type !== ConversationTimelineType.EVENT) return null;
|
|
238
|
+
const eventPart = timelineItem.parts?.find((part) => typeof part === "object" && part !== null && "type" in part && part.type === "event");
|
|
239
|
+
if (!eventPart || typeof eventPart !== "object" || !("eventType" in eventPart)) return null;
|
|
240
|
+
switch (eventPart.eventType) {
|
|
241
|
+
case "resolved": return ConversationStatus.RESOLVED;
|
|
242
|
+
case "reopened": return ConversationStatus.OPEN;
|
|
243
|
+
default: return null;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Handle conversationUpdated event from realtime
|
|
248
|
+
* Updates conversation with new title (sentiment and escalation are dashboard-only)
|
|
249
|
+
*/
|
|
250
|
+
handleConversationUpdated(event) {
|
|
251
|
+
const { conversationId, updates } = event.payload;
|
|
252
|
+
const existingConversation = this.conversationsStore.getState().byId[conversationId];
|
|
253
|
+
if (!existingConversation) return;
|
|
254
|
+
const nextConversation = {
|
|
255
|
+
...existingConversation,
|
|
256
|
+
...updates.title !== void 0 && { title: updates.title ?? void 0 },
|
|
257
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
258
|
+
};
|
|
259
|
+
this.conversationsStore.ingestConversation(nextConversation);
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
231
262
|
* Generate a presigned URL for uploading a file to S3.
|
|
232
263
|
*/
|
|
233
264
|
async generateUploadUrl(params) {
|
package/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","names":["current: WebsiteState","conversation: Conversation","optimisticTimelineItem: TimelineItem","payload: SendTimelineItemRequest","createdAt"],"sources":["../src/client.ts"],"sourcesContent":["import {\n\ttype AnyRealtimeEvent,\n\ttype DefaultMessage,\n\tgetEventPayload,\n\ttype IdentifyContactResponse,\n\ttype RealtimeEvent,\n} from \"@cossistant/types\";\nimport type {\n\tCreateConversationRequestBody,\n\tCreateConversationResponseBody,\n\tGetConversationRequest,\n\tGetConversationResponse,\n\tListConversationsRequest,\n\tListConversationsResponse,\n\tMarkConversationSeenRequestBody,\n\tMarkConversationSeenResponseBody,\n\tSetConversationTypingResponseBody,\n} from \"@cossistant/types/api/conversation\";\nimport type {\n\tGetConversationTimelineItemsRequest,\n\tGetConversationTimelineItemsResponse,\n\tSendTimelineItemRequest,\n\tSendTimelineItemResponse,\n\tTimelineItem,\n} from \"@cossistant/types/api/timeline-item\";\nimport {\n\tConversationStatus,\n\tConversationTimelineType,\n\tSenderType,\n\tTimelineItemVisibility,\n} from \"@cossistant/types/enums\";\nimport type { Conversation } from \"@cossistant/types/schemas\";\nimport { CossistantRestClient } from \"./rest-client\";\nimport {\n\ttype ConversationsStore,\n\tcreateConversationsStore,\n} from \"./store/conversations-store\";\nimport {\n\tcreateTimelineItemsStore,\n\ttype TimelineItemsStore,\n} from \"./store/timeline-items-store\";\nimport {\n\tcreateWebsiteStore,\n\ttype WebsiteState,\n\ttype WebsiteStore,\n} from \"./store/website-store\";\nimport type {\n\tCossistantConfig,\n\tPublicWebsiteResponse,\n\tVisitorMetadata,\n\tVisitorResponse,\n} from \"./types\";\nimport { generateConversationId, generateMessageId } from \"./utils\";\n\ntype PendingConversation = {\n\tconversation: Conversation;\n\tinitialTimelineItems: TimelineItem[];\n};\n\ntype InitiateConversationParams = {\n\tconversationId?: string;\n\tvisitorId?: string | null;\n\twebsiteId?: string | null;\n\ttitle?: string;\n\tstatus?: Conversation[\"status\"];\n\tdefaultTimelineItems?: Array<DefaultMessage | TimelineItem>;\n};\n\ntype InitiateConversationResult = {\n\tconversationId: string;\n\tconversation: Conversation;\n\tdefaultTimelineItems: TimelineItem[];\n};\n\nexport class CossistantClient {\n\tprivate restClient: CossistantRestClient;\n\tprivate config: CossistantConfig;\n\tprivate pendingConversations = new Map<string, PendingConversation>();\n\tprivate websiteRequest: Promise<PublicWebsiteResponse> | null = null;\n\treadonly conversationsStore: ConversationsStore;\n\treadonly timelineItemsStore: TimelineItemsStore;\n\treadonly websiteStore: WebsiteStore;\n\n\tconstructor(config: CossistantConfig) {\n\t\tthis.config = config;\n\t\tthis.restClient = new CossistantRestClient(config);\n\t\tthis.conversationsStore = createConversationsStore();\n\t\tthis.timelineItemsStore = createTimelineItemsStore();\n\t\tthis.websiteStore = createWebsiteStore();\n\t}\n\n\t// Configuration updates\n\tupdateConfiguration(config: Partial<CossistantConfig>): void {\n\t\tthis.config = { ...this.config, ...config };\n\t\tthis.restClient.updateConfiguration(config);\n\t}\n\n\t// Utility methods\n\tgetConfiguration(): CossistantConfig {\n\t\treturn { ...this.config };\n\t}\n\n\t// Website information\n\tasync fetchWebsite(\n\t\tparams: { force?: boolean } = {}\n\t): Promise<PublicWebsiteResponse> {\n\t\tconst { force = false } = params;\n\t\tconst current: WebsiteState = this.websiteStore.getState();\n\n\t\tif (!force) {\n\t\t\tif (current.status === \"success\" && current.website) {\n\t\t\t\treturn current.website;\n\t\t\t}\n\t\t\tif (this.websiteRequest) {\n\t\t\t\treturn this.websiteRequest;\n\t\t\t}\n\t\t}\n\n\t\tthis.websiteStore.setLoading();\n\n\t\tconst request = this.restClient\n\t\t\t.getWebsite()\n\t\t\t.then((website) => {\n\t\t\t\tthis.websiteStore.setWebsite(website);\n\t\t\t\treturn website;\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\tthis.websiteStore.setError(error);\n\t\t\t\tthrow error;\n\t\t\t})\n\t\t\t.finally(() => {\n\t\t\t\tif (this.websiteRequest === request) {\n\t\t\t\t\tthis.websiteRequest = null;\n\t\t\t\t}\n\t\t\t});\n\n\t\tthis.websiteRequest = request;\n\n\t\treturn request;\n\t}\n\n\tasync getWebsite(): Promise<PublicWebsiteResponse> {\n\t\treturn this.fetchWebsite({ force: true });\n\t}\n\n\tsetWebsiteContext(websiteId: string, visitorId?: string): void {\n\t\tthis.restClient.setWebsiteContext(websiteId, visitorId);\n\t}\n\n\tsetVisitorBlocked(isBlocked: boolean): void {\n\t\tthis.restClient.setVisitorBlocked(isBlocked);\n\t}\n\n\tasync updateVisitorMetadata(\n\t\tmetadata: VisitorMetadata\n\t): Promise<VisitorResponse> {\n\t\treturn this.restClient.updateVisitorMetadata(metadata);\n\t}\n\n\tasync identify(params: {\n\t\texternalId?: string;\n\t\temail?: string;\n\t\tname?: string;\n\t\timage?: string;\n\t\tmetadata?: Record<string, unknown>;\n\t\tcontactOrganizationId?: string;\n\t}): Promise<IdentifyContactResponse> {\n\t\treturn this.restClient.identify(params);\n\t}\n\n\tasync updateContactMetadata(\n\t\tmetadata: Record<string, unknown>\n\t): Promise<VisitorResponse> {\n\t\treturn this.restClient.updateContactMetadata(metadata);\n\t}\n\n\t// Conversation management\n\tinitiateConversation(\n\t\tparams: InitiateConversationParams = {}\n\t): InitiateConversationResult {\n\t\tconst conversationId = params.conversationId ?? generateConversationId();\n\t\tconst now = typeof window !== \"undefined\" ? new Date().toISOString() : \"\";\n\t\tconst timelineItems = (params.defaultTimelineItems ?? []).map((item) =>\n\t\t\tnormalizeBootstrapTimelineItem(conversationId, item)\n\t\t);\n\t\tconst existing = this.conversationsStore.getState().byId[conversationId];\n\t\tconst baseVisitorId =\n\t\t\tparams.visitorId ?? this.restClient.getCurrentVisitorId() ?? \"\";\n\t\tconst baseWebsiteId =\n\t\t\tparams.websiteId ?? this.restClient.getCurrentWebsiteId() ?? \"\";\n\n\t\tconst conversation: Conversation = existing\n\t\t\t? {\n\t\t\t\t\t...existing,\n\t\t\t\t\ttitle: params.title ?? existing.title,\n\t\t\t\t\tstatus: params.status ?? existing.status,\n\t\t\t\t\tupdatedAt: now,\n\t\t\t\t\tlastTimelineItem: timelineItems.at(-1) ?? existing.lastTimelineItem,\n\t\t\t\t}\n\t\t\t: {\n\t\t\t\t\tid: conversationId,\n\t\t\t\t\ttitle: params.title,\n\t\t\t\t\tcreatedAt: now,\n\t\t\t\t\tupdatedAt: now,\n\t\t\t\t\tvisitorId: baseVisitorId,\n\t\t\t\t\twebsiteId: baseWebsiteId,\n\t\t\t\t\tstatus: params.status ?? ConversationStatus.OPEN,\n\t\t\t\t\tdeletedAt: null,\n\t\t\t\t\tlastTimelineItem: timelineItems.at(-1),\n\t\t\t\t};\n\n\t\tthis.conversationsStore.ingestConversation(conversation);\n\n\t\tif (timelineItems.length > 0) {\n\t\t\tthis.timelineItemsStore.ingestPage(conversationId, {\n\t\t\t\titems: timelineItems,\n\t\t\t\thasNextPage: false,\n\t\t\t\tnextCursor: undefined,\n\t\t\t});\n\t\t}\n\n\t\tif (!existing || this.pendingConversations.has(conversationId)) {\n\t\t\tthis.pendingConversations.set(conversationId, {\n\t\t\t\tconversation,\n\t\t\t\tinitialTimelineItems: timelineItems,\n\t\t\t});\n\t\t}\n\n\t\treturn {\n\t\t\tconversationId,\n\t\t\tconversation,\n\t\t\tdefaultTimelineItems: timelineItems,\n\t\t};\n\t}\n\n\tasync createConversation(\n\t\tparams?: Partial<CreateConversationRequestBody>\n\t): Promise<CreateConversationResponseBody> {\n\t\tconst response = await this.restClient.createConversation(params);\n\t\tthis.conversationsStore.ingestConversation(response.conversation);\n\t\treturn response;\n\t}\n\n\tasync listConversations(\n\t\tparams?: Partial<ListConversationsRequest>\n\t): Promise<ListConversationsResponse> {\n\t\tconst response = await this.restClient.listConversations(params);\n\t\tthis.conversationsStore.ingestList(response);\n\t\treturn response;\n\t}\n\n\tasync getConversation(\n\t\tparams: GetConversationRequest\n\t): Promise<GetConversationResponse> {\n\t\tconst response = await this.restClient.getConversation(params);\n\t\tthis.conversationsStore.ingestConversation(response.conversation);\n\t\treturn response;\n\t}\n\n\tasync markConversationSeen(\n\t\tparams: {\n\t\t\tconversationId: string;\n\t\t} & Partial<MarkConversationSeenRequestBody>\n\t): Promise<MarkConversationSeenResponseBody> {\n\t\treturn this.restClient.markConversationSeen(params);\n\t}\n\n\tasync getConversationSeenData(params: { conversationId: string }) {\n\t\treturn this.restClient.getConversationSeenData(params);\n\t}\n\n\tasync setVisitorTyping(params: {\n\t\tconversationId: string;\n\t\tisTyping: boolean;\n\t\tvisitorPreview?: string | null;\n\t\tvisitorId?: string;\n\t}): Promise<SetConversationTypingResponseBody> {\n\t\treturn this.restClient.setConversationTyping(params);\n\t}\n\n\t// Timeline items management\n\n\tasync getConversationTimelineItems(\n\t\tparams: GetConversationTimelineItemsRequest & { conversationId: string }\n\t): Promise<GetConversationTimelineItemsResponse> {\n\t\tconst response = await this.restClient.getConversationTimelineItems(params);\n\t\tthis.timelineItemsStore.ingestPage(params.conversationId, {\n\t\t\titems: response.items,\n\t\t\thasNextPage: response.hasNextPage,\n\t\t\tnextCursor: response.nextCursor ?? undefined,\n\t\t});\n\t\treturn response;\n\t}\n\n\tasync sendMessage(\n\t\tparams: SendTimelineItemRequest & { createIfPending?: boolean }\n\t): Promise<\n\t\tSendTimelineItemResponse & {\n\t\t\tconversation?: Conversation;\n\t\t\tinitialTimelineItems?: TimelineItem[];\n\t\t\twasConversationCreated?: boolean;\n\t\t}\n\t> {\n\t\tconst { createIfPending, ...rest } = params;\n\t\tconst optimisticId = rest.item.id ?? generateMessageId();\n\t\tconst createdAt = rest.item.createdAt\n\t\t\t? rest.item.createdAt\n\t\t\t: typeof window !== \"undefined\"\n\t\t\t\t? new Date().toISOString()\n\t\t\t\t: \"\";\n\n\t\t// Add optimistic timeline item\n\t\tconst optimisticTimelineItem: TimelineItem = {\n\t\t\tid: optimisticId,\n\t\t\tconversationId: rest.conversationId,\n\t\t\torganizationId: \"\", // Not available yet\n\t\t\tvisibility: rest.item.visibility ?? TimelineItemVisibility.PUBLIC,\n\t\t\ttype: rest.item.type ?? ConversationTimelineType.MESSAGE,\n\t\t\ttext: rest.item.text,\n\t\t\ttool: rest.item.tool ?? null,\n\t\t\tparts:\n\t\t\t\trest.item.parts && rest.item.parts.length > 0\n\t\t\t\t\t? rest.item.parts\n\t\t\t\t\t: rest.item.text\n\t\t\t\t\t\t? [{ type: \"text\" as const, text: rest.item.text }]\n\t\t\t\t\t\t: [],\n\t\t\tuserId: rest.item.userId ?? null,\n\t\t\tvisitorId: rest.item.visitorId ?? null,\n\t\t\taiAgentId: rest.item.aiAgentId ?? null,\n\t\t\tcreatedAt,\n\t\t\tdeletedAt: null,\n\t\t};\n\n\t\tthis.timelineItemsStore.ingestTimelineItem(optimisticTimelineItem);\n\n\t\tconst pending = this.pendingConversations.get(rest.conversationId);\n\n\t\tif (pending && createIfPending !== false) {\n\t\t\ttry {\n\t\t\t\tconst response = await this.restClient.createConversation({\n\t\t\t\t\tconversationId: rest.conversationId,\n\t\t\t\t\tdefaultTimelineItems: [\n\t\t\t\t\t\t...pending.initialTimelineItems,\n\t\t\t\t\t\toptimisticTimelineItem,\n\t\t\t\t\t],\n\t\t\t\t});\n\n\t\t\t\tthis.conversationsStore.ingestConversation(response.conversation);\n\t\t\t\tthis.timelineItemsStore.removeTimelineItem(\n\t\t\t\t\trest.conversationId,\n\t\t\t\t\toptimisticId\n\t\t\t\t);\n\t\t\t\tthis.timelineItemsStore.clearConversation(rest.conversationId);\n\n\t\t\t\tthis.timelineItemsStore.ingestPage(rest.conversationId, {\n\t\t\t\t\titems: response.initialTimelineItems,\n\t\t\t\t\thasNextPage: false,\n\t\t\t\t\tnextCursor: undefined,\n\t\t\t\t});\n\n\t\t\t\tthis.pendingConversations.delete(rest.conversationId);\n\n\t\t\t\tconst item =\n\t\t\t\t\tresponse.initialTimelineItems.at(-1) ??\n\t\t\t\t\tresponse.initialTimelineItems[0];\n\n\t\t\t\treturn {\n\t\t\t\t\titem: item as TimelineItem,\n\t\t\t\t\tconversation: response.conversation,\n\t\t\t\t\tinitialTimelineItems: response.initialTimelineItems,\n\t\t\t\t\twasConversationCreated: true,\n\t\t\t\t} satisfies SendTimelineItemResponse & {\n\t\t\t\t\tconversation: Conversation;\n\t\t\t\t\tinitialTimelineItems: TimelineItem[];\n\t\t\t\t\twasConversationCreated: true;\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\tthis.timelineItemsStore.removeTimelineItem(\n\t\t\t\t\trest.conversationId,\n\t\t\t\t\toptimisticId\n\t\t\t\t);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\n\t\tconst { createdAt: _createdAt, ...restItem } = rest.item;\n\n\t\tconst payload: SendTimelineItemRequest = {\n\t\t\t...rest,\n\t\t\titem: {\n\t\t\t\t...restItem,\n\t\t\t\tid: optimisticId,\n\t\t\t},\n\t\t};\n\n\t\ttry {\n\t\t\tconst response = await this.restClient.sendMessage(payload);\n\n\t\t\t// Finalize the timeline item\n\t\t\tthis.timelineItemsStore.finalizeTimelineItem(\n\t\t\t\trest.conversationId,\n\t\t\t\toptimisticId,\n\t\t\t\tresponse.item\n\t\t\t);\n\t\t\treturn response;\n\t\t} catch (error) {\n\t\t\tthis.timelineItemsStore.removeTimelineItem(\n\t\t\t\trest.conversationId,\n\t\t\t\toptimisticId\n\t\t\t);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\thandleRealtimeEvent(event: AnyRealtimeEvent): void {\n\t\tif (event.type === \"conversationCreated\") {\n\t\t\tconst { conversation, header } = event.payload;\n\n\t\t\tthis.conversationsStore.ingestConversation({\n\t\t\t\t...conversation,\n\t\t\t\tlastTimelineItem: conversation.lastTimelineItem ?? undefined,\n\t\t\t});\n\t\t} else if (event.type === \"timelineItemCreated\") {\n\t\t\t// Ingest timeline item into store\n\t\t\tconst timelineItem =\n\t\t\t\tthis.timelineItemsStore.ingestRealtimeTimelineItem(event);\n\n\t\t\t// Update conversation with last timeline item\n\t\t\tconst existingConversation =\n\t\t\t\tthis.conversationsStore.getState().byId[timelineItem.conversationId];\n\n\t\t\tif (existingConversation) {\n\t\t\t\tconst nextConversation = {\n\t\t\t\t\t...existingConversation,\n\t\t\t\t\tupdatedAt: timelineItem.createdAt,\n\t\t\t\t\tlastTimelineItem: timelineItem,\n\t\t\t\t};\n\n\t\t\t\tthis.conversationsStore.ingestConversation(nextConversation);\n\t\t\t}\n\t\t}\n\t}\n\n\t// File upload methods\n\t/**\n\t * Generate a presigned URL for uploading a file to S3.\n\t */\n\tasync generateUploadUrl(\n\t\tparams: Omit<\n\t\t\tParameters<CossistantRestClient[\"generateUploadUrl\"]>[0],\n\t\t\t\"websiteId\"\n\t\t>\n\t) {\n\t\treturn this.restClient.generateUploadUrl(params);\n\t}\n\n\t/**\n\t * Upload a file to S3 using a presigned URL.\n\t */\n\tasync uploadFile(file: File, uploadUrl: string, contentType: string) {\n\t\treturn this.restClient.uploadFile(file, uploadUrl, contentType);\n\t}\n\n\t/**\n\t * Upload multiple files for a conversation message.\n\t */\n\tasync uploadFilesForMessage(files: File[], conversationId: string) {\n\t\treturn this.restClient.uploadFilesForMessage(files, conversationId);\n\t}\n\n\t// Cleanup method\n\tdestroy(): void {\n\t\t// No cleanup needed for REST client\n\t}\n}\n\nfunction normalizeBootstrapTimelineItem(\n\tconversationId: string,\n\titem: DefaultMessage | TimelineItem\n): TimelineItem {\n\tif (isDefaultMessage(item)) {\n\t\tconst createdAt =\n\t\t\ttypeof window !== \"undefined\" ? new Date().toISOString() : \"\";\n\n\t\treturn {\n\t\t\tid: generateMessageId(),\n\t\t\tconversationId,\n\t\t\torganizationId: \"\", // Not available at this point\n\t\t\ttype: ConversationTimelineType.MESSAGE,\n\t\t\ttext: item.content,\n\t\t\tparts: [{ type: \"text\" as const, text: item.content }],\n\t\t\tvisibility: TimelineItemVisibility.PUBLIC,\n\t\t\tuserId:\n\t\t\t\titem.senderType === SenderType.TEAM_MEMBER\n\t\t\t\t\t? (item.senderId ?? null)\n\t\t\t\t\t: null,\n\t\t\taiAgentId:\n\t\t\t\titem.senderType === SenderType.AI ? (item.senderId ?? null) : null,\n\t\t\tvisitorId:\n\t\t\t\titem.senderType === SenderType.VISITOR ? (item.senderId ?? null) : null,\n\t\t\tcreatedAt,\n\t\t\tdeletedAt: null,\n\t\t} satisfies TimelineItem;\n\t}\n\n\tconst createdAt = item.createdAt\n\t\t? item.createdAt\n\t\t: typeof window !== \"undefined\"\n\t\t\t? new Date().toISOString()\n\t\t\t: \"\";\n\n\treturn {\n\t\t...item,\n\t\tid: item.id ?? generateMessageId(),\n\t\tconversationId,\n\t\torganizationId: item.organizationId || \"\",\n\t\ttype: item.type ?? ConversationTimelineType.MESSAGE,\n\t\ttool: item.tool ?? null,\n\t\tcreatedAt,\n\t\tdeletedAt: item.deletedAt ?? null,\n\t\tuserId: item.userId ?? null,\n\t\taiAgentId: item.aiAgentId ?? null,\n\t\tvisitorId: item.visitorId ?? null,\n\t\tvisibility: item.visibility ?? TimelineItemVisibility.PUBLIC,\n\t} satisfies TimelineItem;\n}\n\nfunction isDefaultMessage(\n\titem: DefaultMessage | TimelineItem\n): item is DefaultMessage {\n\treturn (item as DefaultMessage).content !== undefined;\n}\n"],"mappings":";;;;;;;;AA0EA,IAAa,mBAAb,MAA8B;CAC7B,AAAQ;CACR,AAAQ;CACR,AAAQ,uCAAuB,IAAI,KAAkC;CACrE,AAAQ,iBAAwD;CAChE,AAAS;CACT,AAAS;CACT,AAAS;CAET,YAAY,QAA0B;AACrC,OAAK,SAAS;AACd,OAAK,aAAa,IAAI,qBAAqB,OAAO;AAClD,OAAK,qBAAqB,0BAA0B;AACpD,OAAK,qBAAqB,0BAA0B;AACpD,OAAK,eAAe,oBAAoB;;CAIzC,oBAAoB,QAAyC;AAC5D,OAAK,SAAS;GAAE,GAAG,KAAK;GAAQ,GAAG;GAAQ;AAC3C,OAAK,WAAW,oBAAoB,OAAO;;CAI5C,mBAAqC;AACpC,SAAO,EAAE,GAAG,KAAK,QAAQ;;CAI1B,MAAM,aACL,SAA8B,EAAE,EACC;EACjC,MAAM,EAAE,QAAQ,UAAU;EAC1B,MAAMA,UAAwB,KAAK,aAAa,UAAU;AAE1D,MAAI,CAAC,OAAO;AACX,OAAI,QAAQ,WAAW,aAAa,QAAQ,QAC3C,QAAO,QAAQ;AAEhB,OAAI,KAAK,eACR,QAAO,KAAK;;AAId,OAAK,aAAa,YAAY;EAE9B,MAAM,UAAU,KAAK,WACnB,YAAY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AW,+BAAc,IAAI,MAAM,EAAC,aAAa,GAAG;AAE5D,SAAO;GACN,IAAI,mBAAmB;GACvB;GACA,gBAAgB;GAChB,MAAM,yBAAyB;GAC/B,MAAM,KAAK;GACX,OAAO,CAAC;IAAE,MAAM;IAAiB,MAAM,KAAK;IAAS,CAAC;GACtD,YAAY,uBAAuB;GACnC,QACC,KAAK,eAAe,WAAW,cAC3B,KAAK,YAAY,OAClB;GACJ,WACC,KAAK,eAAe,WAAW,KAAM,KAAK,YAAY,OAAQ;GAC/D,WACC,KAAK,eAAe,WAAW,UAAW,KAAK,YAAY,OAAQ;GACpE;GACA,WAAW;GACX;;CAGF,MAAM,YAAY,KAAK,YACpB,KAAK,YACL,OAAO,WAAW,+BACjB,IAAI,MAAM,EAAC,aAAa,GACxB;AAEJ,QAAO;EACN,GAAG;EACH,IAAI,KAAK,MAAM,mBAAmB;EAClC;EACA,gBAAgB,KAAK,kBAAkB;EACvC,MAAM,KAAK,QAAQ,yBAAyB;EAC5C,MAAM,KAAK,QAAQ;EACnB;EACA,WAAW,KAAK,aAAa;EAC7B,QAAQ,KAAK,UAAU;EACvB,WAAW,KAAK,aAAa;EAC7B,WAAW,KAAK,aAAa;EAC7B,YAAY,KAAK,cAAc,uBAAuB;EACtD;;AAGF,SAAS,iBACR,MACyB;AACzB,QAAQ,KAAwB,YAAY"}
|
|
1
|
+
{"version":3,"file":"client.js","names":["current: WebsiteState","conversation: Conversation","optimisticTimelineItem: TimelineItem","payload: SendTimelineItemRequest","createdAt"],"sources":["../src/client.ts"],"sourcesContent":["import {\n\ttype AnyRealtimeEvent,\n\ttype DefaultMessage,\n\tgetEventPayload,\n\ttype IdentifyContactResponse,\n\ttype RealtimeEvent,\n} from \"@cossistant/types\";\nimport type {\n\tCreateConversationRequestBody,\n\tCreateConversationResponseBody,\n\tGetConversationRequest,\n\tGetConversationResponse,\n\tListConversationsRequest,\n\tListConversationsResponse,\n\tMarkConversationSeenRequestBody,\n\tMarkConversationSeenResponseBody,\n\tSetConversationTypingResponseBody,\n} from \"@cossistant/types/api/conversation\";\nimport type {\n\tGetConversationTimelineItemsRequest,\n\tGetConversationTimelineItemsResponse,\n\tSendTimelineItemRequest,\n\tSendTimelineItemResponse,\n\tTimelineItem,\n} from \"@cossistant/types/api/timeline-item\";\nimport {\n\tConversationStatus,\n\tConversationTimelineType,\n\tSenderType,\n\tTimelineItemVisibility,\n} from \"@cossistant/types/enums\";\nimport type { Conversation } from \"@cossistant/types/schemas\";\nimport { CossistantRestClient } from \"./rest-client\";\nimport {\n\ttype ConversationsStore,\n\tcreateConversationsStore,\n} from \"./store/conversations-store\";\nimport {\n\tcreateTimelineItemsStore,\n\ttype TimelineItemsStore,\n} from \"./store/timeline-items-store\";\nimport {\n\tcreateWebsiteStore,\n\ttype WebsiteState,\n\ttype WebsiteStore,\n} from \"./store/website-store\";\nimport type {\n\tCossistantConfig,\n\tPublicWebsiteResponse,\n\tVisitorMetadata,\n\tVisitorResponse,\n} from \"./types\";\nimport { generateConversationId, generateMessageId } from \"./utils\";\n\ntype PendingConversation = {\n\tconversation: Conversation;\n\tinitialTimelineItems: TimelineItem[];\n};\n\ntype InitiateConversationParams = {\n\tconversationId?: string;\n\tvisitorId?: string | null;\n\twebsiteId?: string | null;\n\ttitle?: string;\n\tstatus?: Conversation[\"status\"];\n\tdefaultTimelineItems?: Array<DefaultMessage | TimelineItem>;\n};\n\ntype InitiateConversationResult = {\n\tconversationId: string;\n\tconversation: Conversation;\n\tdefaultTimelineItems: TimelineItem[];\n};\n\nexport class CossistantClient {\n\tprivate restClient: CossistantRestClient;\n\tprivate config: CossistantConfig;\n\tprivate pendingConversations = new Map<string, PendingConversation>();\n\tprivate websiteRequest: Promise<PublicWebsiteResponse> | null = null;\n\treadonly conversationsStore: ConversationsStore;\n\treadonly timelineItemsStore: TimelineItemsStore;\n\treadonly websiteStore: WebsiteStore;\n\n\tconstructor(config: CossistantConfig) {\n\t\tthis.config = config;\n\t\tthis.restClient = new CossistantRestClient(config);\n\t\tthis.conversationsStore = createConversationsStore();\n\t\tthis.timelineItemsStore = createTimelineItemsStore();\n\t\tthis.websiteStore = createWebsiteStore();\n\t}\n\n\t// Configuration updates\n\tupdateConfiguration(config: Partial<CossistantConfig>): void {\n\t\tthis.config = { ...this.config, ...config };\n\t\tthis.restClient.updateConfiguration(config);\n\t}\n\n\t// Utility methods\n\tgetConfiguration(): CossistantConfig {\n\t\treturn { ...this.config };\n\t}\n\n\t// Website information\n\tasync fetchWebsite(\n\t\tparams: { force?: boolean } = {}\n\t): Promise<PublicWebsiteResponse> {\n\t\tconst { force = false } = params;\n\t\tconst current: WebsiteState = this.websiteStore.getState();\n\n\t\tif (!force) {\n\t\t\tif (current.status === \"success\" && current.website) {\n\t\t\t\treturn current.website;\n\t\t\t}\n\t\t\tif (this.websiteRequest) {\n\t\t\t\treturn this.websiteRequest;\n\t\t\t}\n\t\t}\n\n\t\tthis.websiteStore.setLoading();\n\n\t\tconst request = this.restClient\n\t\t\t.getWebsite()\n\t\t\t.then((website) => {\n\t\t\t\tthis.websiteStore.setWebsite(website);\n\t\t\t\treturn website;\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\tthis.websiteStore.setError(error);\n\t\t\t\tthrow error;\n\t\t\t})\n\t\t\t.finally(() => {\n\t\t\t\tif (this.websiteRequest === request) {\n\t\t\t\t\tthis.websiteRequest = null;\n\t\t\t\t}\n\t\t\t});\n\n\t\tthis.websiteRequest = request;\n\n\t\treturn request;\n\t}\n\n\tasync getWebsite(): Promise<PublicWebsiteResponse> {\n\t\treturn this.fetchWebsite({ force: true });\n\t}\n\n\tsetWebsiteContext(websiteId: string, visitorId?: string): void {\n\t\tthis.restClient.setWebsiteContext(websiteId, visitorId);\n\t}\n\n\tsetVisitorBlocked(isBlocked: boolean): void {\n\t\tthis.restClient.setVisitorBlocked(isBlocked);\n\t}\n\n\tasync updateVisitorMetadata(\n\t\tmetadata: VisitorMetadata\n\t): Promise<VisitorResponse> {\n\t\treturn this.restClient.updateVisitorMetadata(metadata);\n\t}\n\n\tasync identify(params: {\n\t\texternalId?: string;\n\t\temail?: string;\n\t\tname?: string;\n\t\timage?: string;\n\t\tmetadata?: Record<string, unknown>;\n\t\tcontactOrganizationId?: string;\n\t}): Promise<IdentifyContactResponse> {\n\t\treturn this.restClient.identify(params);\n\t}\n\n\tasync updateContactMetadata(\n\t\tmetadata: Record<string, unknown>\n\t): Promise<VisitorResponse> {\n\t\treturn this.restClient.updateContactMetadata(metadata);\n\t}\n\n\t// Conversation management\n\tinitiateConversation(\n\t\tparams: InitiateConversationParams = {}\n\t): InitiateConversationResult {\n\t\tconst conversationId = params.conversationId ?? generateConversationId();\n\t\tconst now = typeof window !== \"undefined\" ? new Date().toISOString() : \"\";\n\t\tconst timelineItems = (params.defaultTimelineItems ?? []).map((item) =>\n\t\t\tnormalizeBootstrapTimelineItem(conversationId, item)\n\t\t);\n\t\tconst existing = this.conversationsStore.getState().byId[conversationId];\n\t\tconst baseVisitorId =\n\t\t\tparams.visitorId ?? this.restClient.getCurrentVisitorId() ?? \"\";\n\t\tconst baseWebsiteId =\n\t\t\tparams.websiteId ?? this.restClient.getCurrentWebsiteId() ?? \"\";\n\n\t\tconst conversation: Conversation = existing\n\t\t\t? {\n\t\t\t\t\t...existing,\n\t\t\t\t\ttitle: params.title ?? existing.title,\n\t\t\t\t\tstatus: params.status ?? existing.status,\n\t\t\t\t\tupdatedAt: now,\n\t\t\t\t\tlastTimelineItem: timelineItems.at(-1) ?? existing.lastTimelineItem,\n\t\t\t\t}\n\t\t\t: {\n\t\t\t\t\tid: conversationId,\n\t\t\t\t\ttitle: params.title,\n\t\t\t\t\tcreatedAt: now,\n\t\t\t\t\tupdatedAt: now,\n\t\t\t\t\tvisitorId: baseVisitorId,\n\t\t\t\t\twebsiteId: baseWebsiteId,\n\t\t\t\t\tstatus: params.status ?? ConversationStatus.OPEN,\n\t\t\t\t\tdeletedAt: null,\n\t\t\t\t\tlastTimelineItem: timelineItems.at(-1),\n\t\t\t\t};\n\n\t\tthis.conversationsStore.ingestConversation(conversation);\n\n\t\tif (timelineItems.length > 0) {\n\t\t\tthis.timelineItemsStore.ingestPage(conversationId, {\n\t\t\t\titems: timelineItems,\n\t\t\t\thasNextPage: false,\n\t\t\t\tnextCursor: undefined,\n\t\t\t});\n\t\t}\n\n\t\tif (!existing || this.pendingConversations.has(conversationId)) {\n\t\t\tthis.pendingConversations.set(conversationId, {\n\t\t\t\tconversation,\n\t\t\t\tinitialTimelineItems: timelineItems,\n\t\t\t});\n\t\t}\n\n\t\treturn {\n\t\t\tconversationId,\n\t\t\tconversation,\n\t\t\tdefaultTimelineItems: timelineItems,\n\t\t};\n\t}\n\n\tasync createConversation(\n\t\tparams?: Partial<CreateConversationRequestBody>\n\t): Promise<CreateConversationResponseBody> {\n\t\tconst response = await this.restClient.createConversation(params);\n\t\tthis.conversationsStore.ingestConversation(response.conversation);\n\t\treturn response;\n\t}\n\n\tasync listConversations(\n\t\tparams?: Partial<ListConversationsRequest>\n\t): Promise<ListConversationsResponse> {\n\t\tconst response = await this.restClient.listConversations(params);\n\t\tthis.conversationsStore.ingestList(response);\n\t\treturn response;\n\t}\n\n\tasync getConversation(\n\t\tparams: GetConversationRequest\n\t): Promise<GetConversationResponse> {\n\t\tconst response = await this.restClient.getConversation(params);\n\t\tthis.conversationsStore.ingestConversation(response.conversation);\n\t\treturn response;\n\t}\n\n\tasync markConversationSeen(\n\t\tparams: {\n\t\t\tconversationId: string;\n\t\t} & Partial<MarkConversationSeenRequestBody>\n\t): Promise<MarkConversationSeenResponseBody> {\n\t\treturn this.restClient.markConversationSeen(params);\n\t}\n\n\tasync getConversationSeenData(params: { conversationId: string }) {\n\t\treturn this.restClient.getConversationSeenData(params);\n\t}\n\n\tasync setVisitorTyping(params: {\n\t\tconversationId: string;\n\t\tisTyping: boolean;\n\t\tvisitorPreview?: string | null;\n\t\tvisitorId?: string;\n\t}): Promise<SetConversationTypingResponseBody> {\n\t\treturn this.restClient.setConversationTyping(params);\n\t}\n\n\t// Timeline items management\n\n\tasync getConversationTimelineItems(\n\t\tparams: GetConversationTimelineItemsRequest & { conversationId: string }\n\t): Promise<GetConversationTimelineItemsResponse> {\n\t\tconst response = await this.restClient.getConversationTimelineItems(params);\n\t\tthis.timelineItemsStore.ingestPage(params.conversationId, {\n\t\t\titems: response.items,\n\t\t\thasNextPage: response.hasNextPage,\n\t\t\tnextCursor: response.nextCursor ?? undefined,\n\t\t});\n\t\treturn response;\n\t}\n\n\tasync sendMessage(\n\t\tparams: SendTimelineItemRequest & { createIfPending?: boolean }\n\t): Promise<\n\t\tSendTimelineItemResponse & {\n\t\t\tconversation?: Conversation;\n\t\t\tinitialTimelineItems?: TimelineItem[];\n\t\t\twasConversationCreated?: boolean;\n\t\t}\n\t> {\n\t\tconst { createIfPending, ...rest } = params;\n\t\tconst optimisticId = rest.item.id ?? generateMessageId();\n\t\tconst createdAt = rest.item.createdAt\n\t\t\t? rest.item.createdAt\n\t\t\t: typeof window !== \"undefined\"\n\t\t\t\t? new Date().toISOString()\n\t\t\t\t: \"\";\n\n\t\t// Add optimistic timeline item\n\t\tconst optimisticTimelineItem: TimelineItem = {\n\t\t\tid: optimisticId,\n\t\t\tconversationId: rest.conversationId,\n\t\t\torganizationId: \"\", // Not available yet\n\t\t\tvisibility: rest.item.visibility ?? TimelineItemVisibility.PUBLIC,\n\t\t\ttype: rest.item.type ?? ConversationTimelineType.MESSAGE,\n\t\t\ttext: rest.item.text,\n\t\t\ttool: rest.item.tool ?? null,\n\t\t\tparts:\n\t\t\t\trest.item.parts && rest.item.parts.length > 0\n\t\t\t\t\t? rest.item.parts\n\t\t\t\t\t: rest.item.text\n\t\t\t\t\t\t? [{ type: \"text\" as const, text: rest.item.text }]\n\t\t\t\t\t\t: [],\n\t\t\tuserId: rest.item.userId ?? null,\n\t\t\tvisitorId: rest.item.visitorId ?? null,\n\t\t\taiAgentId: rest.item.aiAgentId ?? null,\n\t\t\tcreatedAt,\n\t\t\tdeletedAt: null,\n\t\t};\n\n\t\tthis.timelineItemsStore.ingestTimelineItem(optimisticTimelineItem);\n\n\t\tconst pending = this.pendingConversations.get(rest.conversationId);\n\n\t\tif (pending && createIfPending !== false) {\n\t\t\ttry {\n\t\t\t\tconst response = await this.restClient.createConversation({\n\t\t\t\t\tconversationId: rest.conversationId,\n\t\t\t\t\tdefaultTimelineItems: [\n\t\t\t\t\t\t...pending.initialTimelineItems,\n\t\t\t\t\t\toptimisticTimelineItem,\n\t\t\t\t\t],\n\t\t\t\t});\n\n\t\t\t\tthis.conversationsStore.ingestConversation(response.conversation);\n\t\t\t\tthis.timelineItemsStore.removeTimelineItem(\n\t\t\t\t\trest.conversationId,\n\t\t\t\t\toptimisticId\n\t\t\t\t);\n\t\t\t\tthis.timelineItemsStore.clearConversation(rest.conversationId);\n\n\t\t\t\tthis.timelineItemsStore.ingestPage(rest.conversationId, {\n\t\t\t\t\titems: response.initialTimelineItems,\n\t\t\t\t\thasNextPage: false,\n\t\t\t\t\tnextCursor: undefined,\n\t\t\t\t});\n\n\t\t\t\tthis.pendingConversations.delete(rest.conversationId);\n\n\t\t\t\tconst item =\n\t\t\t\t\tresponse.initialTimelineItems.at(-1) ??\n\t\t\t\t\tresponse.initialTimelineItems[0];\n\n\t\t\t\treturn {\n\t\t\t\t\titem: item as TimelineItem,\n\t\t\t\t\tconversation: response.conversation,\n\t\t\t\t\tinitialTimelineItems: response.initialTimelineItems,\n\t\t\t\t\twasConversationCreated: true,\n\t\t\t\t} satisfies SendTimelineItemResponse & {\n\t\t\t\t\tconversation: Conversation;\n\t\t\t\t\tinitialTimelineItems: TimelineItem[];\n\t\t\t\t\twasConversationCreated: true;\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\tthis.timelineItemsStore.removeTimelineItem(\n\t\t\t\t\trest.conversationId,\n\t\t\t\t\toptimisticId\n\t\t\t\t);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\n\t\tconst { createdAt: _createdAt, ...restItem } = rest.item;\n\n\t\tconst payload: SendTimelineItemRequest = {\n\t\t\t...rest,\n\t\t\titem: {\n\t\t\t\t...restItem,\n\t\t\t\tid: optimisticId,\n\t\t\t},\n\t\t};\n\n\t\ttry {\n\t\t\tconst response = await this.restClient.sendMessage(payload);\n\n\t\t\t// Finalize the timeline item\n\t\t\tthis.timelineItemsStore.finalizeTimelineItem(\n\t\t\t\trest.conversationId,\n\t\t\t\toptimisticId,\n\t\t\t\tresponse.item\n\t\t\t);\n\t\t\treturn response;\n\t\t} catch (error) {\n\t\t\tthis.timelineItemsStore.removeTimelineItem(\n\t\t\t\trest.conversationId,\n\t\t\t\toptimisticId\n\t\t\t);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\thandleRealtimeEvent(event: AnyRealtimeEvent): void {\n\t\tif (event.type === \"conversationCreated\") {\n\t\t\tconst { conversation, header } = event.payload;\n\n\t\t\tthis.conversationsStore.ingestConversation({\n\t\t\t\t...conversation,\n\t\t\t\tlastTimelineItem: conversation.lastTimelineItem ?? undefined,\n\t\t\t});\n\t\t} else if (event.type === \"timelineItemCreated\") {\n\t\t\t// Ingest timeline item into store\n\t\t\tconst timelineItem =\n\t\t\t\tthis.timelineItemsStore.ingestRealtimeTimelineItem(event);\n\n\t\t\t// Update conversation with last timeline item\n\t\t\tconst existingConversation =\n\t\t\t\tthis.conversationsStore.getState().byId[timelineItem.conversationId];\n\n\t\t\tif (existingConversation) {\n\t\t\t\t// Check if this is a status-changing event timeline item\n\t\t\t\tconst newStatus = this.extractStatusFromEventTimelineItem(timelineItem);\n\n\t\t\t\tconst nextConversation = {\n\t\t\t\t\t...existingConversation,\n\t\t\t\t\tupdatedAt: timelineItem.createdAt,\n\t\t\t\t\tlastTimelineItem: timelineItem,\n\t\t\t\t\t...(newStatus && { status: newStatus }),\n\t\t\t\t};\n\n\t\t\t\tthis.conversationsStore.ingestConversation(nextConversation);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Extract conversation status from an event timeline item.\n\t * Returns the new status if this is a status-changing event, otherwise null.\n\t */\n\tprivate extractStatusFromEventTimelineItem(\n\t\ttimelineItem: TimelineItem\n\t): ConversationStatus | null {\n\t\tif (timelineItem.type !== ConversationTimelineType.EVENT) {\n\t\t\treturn null;\n\t\t}\n\n\t\t// Find the event part in the timeline item\n\t\tconst eventPart = timelineItem.parts?.find(\n\t\t\t(part) =>\n\t\t\t\ttypeof part === \"object\" &&\n\t\t\t\tpart !== null &&\n\t\t\t\t\"type\" in part &&\n\t\t\t\tpart.type === \"event\"\n\t\t);\n\n\t\tif (\n\t\t\t!eventPart ||\n\t\t\ttypeof eventPart !== \"object\" ||\n\t\t\t!(\"eventType\" in eventPart)\n\t\t) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst eventType = (eventPart as { eventType: string }).eventType;\n\n\t\t// Map event types to conversation status\n\t\tswitch (eventType) {\n\t\t\tcase \"resolved\":\n\t\t\t\treturn ConversationStatus.RESOLVED;\n\t\t\tcase \"reopened\":\n\t\t\t\treturn ConversationStatus.OPEN;\n\t\t\tdefault:\n\t\t\t\treturn null;\n\t\t}\n\t}\n\n\t/**\n\t * Handle conversationUpdated event from realtime\n\t * Updates conversation with new title (sentiment and escalation are dashboard-only)\n\t */\n\thandleConversationUpdated(event: RealtimeEvent<\"conversationUpdated\">): void {\n\t\tconst { conversationId, updates } = event.payload;\n\n\t\tconst existingConversation =\n\t\t\tthis.conversationsStore.getState().byId[conversationId];\n\n\t\tif (!existingConversation) {\n\t\t\t// Conversation not in store, ignore update\n\t\t\treturn;\n\t\t}\n\n\t\t// Build the updated conversation with only the title field\n\t\t// (sentiment and escalation are dashboard-only fields)\n\t\tconst nextConversation = {\n\t\t\t...existingConversation,\n\t\t\t...(updates.title !== undefined && { title: updates.title ?? undefined }),\n\t\t\tupdatedAt: new Date().toISOString(),\n\t\t};\n\n\t\tthis.conversationsStore.ingestConversation(nextConversation);\n\t}\n\n\t// File upload methods\n\t/**\n\t * Generate a presigned URL for uploading a file to S3.\n\t */\n\tasync generateUploadUrl(\n\t\tparams: Omit<\n\t\t\tParameters<CossistantRestClient[\"generateUploadUrl\"]>[0],\n\t\t\t\"websiteId\"\n\t\t>\n\t) {\n\t\treturn this.restClient.generateUploadUrl(params);\n\t}\n\n\t/**\n\t * Upload a file to S3 using a presigned URL.\n\t */\n\tasync uploadFile(file: File, uploadUrl: string, contentType: string) {\n\t\treturn this.restClient.uploadFile(file, uploadUrl, contentType);\n\t}\n\n\t/**\n\t * Upload multiple files for a conversation message.\n\t */\n\tasync uploadFilesForMessage(files: File[], conversationId: string) {\n\t\treturn this.restClient.uploadFilesForMessage(files, conversationId);\n\t}\n\n\t// Cleanup method\n\tdestroy(): void {\n\t\t// No cleanup needed for REST client\n\t}\n}\n\nfunction normalizeBootstrapTimelineItem(\n\tconversationId: string,\n\titem: DefaultMessage | TimelineItem\n): TimelineItem {\n\tif (isDefaultMessage(item)) {\n\t\tconst createdAt =\n\t\t\ttypeof window !== \"undefined\" ? new Date().toISOString() : \"\";\n\n\t\treturn {\n\t\t\tid: generateMessageId(),\n\t\t\tconversationId,\n\t\t\torganizationId: \"\", // Not available at this point\n\t\t\ttype: ConversationTimelineType.MESSAGE,\n\t\t\ttext: item.content,\n\t\t\tparts: [{ type: \"text\" as const, text: item.content }],\n\t\t\tvisibility: TimelineItemVisibility.PUBLIC,\n\t\t\tuserId:\n\t\t\t\titem.senderType === SenderType.TEAM_MEMBER\n\t\t\t\t\t? (item.senderId ?? null)\n\t\t\t\t\t: null,\n\t\t\taiAgentId:\n\t\t\t\titem.senderType === SenderType.AI ? (item.senderId ?? null) : null,\n\t\t\tvisitorId:\n\t\t\t\titem.senderType === SenderType.VISITOR ? (item.senderId ?? null) : null,\n\t\t\tcreatedAt,\n\t\t\tdeletedAt: null,\n\t\t} satisfies TimelineItem;\n\t}\n\n\tconst createdAt = item.createdAt\n\t\t? item.createdAt\n\t\t: typeof window !== \"undefined\"\n\t\t\t? new Date().toISOString()\n\t\t\t: \"\";\n\n\treturn {\n\t\t...item,\n\t\tid: item.id ?? generateMessageId(),\n\t\tconversationId,\n\t\torganizationId: item.organizationId || \"\",\n\t\ttype: item.type ?? ConversationTimelineType.MESSAGE,\n\t\ttool: item.tool ?? null,\n\t\tcreatedAt,\n\t\tdeletedAt: item.deletedAt ?? null,\n\t\tuserId: item.userId ?? null,\n\t\taiAgentId: item.aiAgentId ?? null,\n\t\tvisitorId: item.visitorId ?? null,\n\t\tvisibility: item.visibility ?? TimelineItemVisibility.PUBLIC,\n\t} satisfies TimelineItem;\n}\n\nfunction isDefaultMessage(\n\titem: DefaultMessage | TimelineItem\n): item is DefaultMessage {\n\treturn (item as DefaultMessage).content !== undefined;\n}\n"],"mappings":";;;;;;;;AA0EA,IAAa,mBAAb,MAA8B;CAC7B,AAAQ;CACR,AAAQ;CACR,AAAQ,uCAAuB,IAAI,KAAkC;CACrE,AAAQ,iBAAwD;CAChE,AAAS;CACT,AAAS;CACT,AAAS;CAET,YAAY,QAA0B;AACrC,OAAK,SAAS;AACd,OAAK,aAAa,IAAI,qBAAqB,OAAO;AAClD,OAAK,qBAAqB,0BAA0B;AACpD,OAAK,qBAAqB,0BAA0B;AACpD,OAAK,eAAe,oBAAoB;;CAIzC,oBAAoB,QAAyC;AAC5D,OAAK,SAAS;GAAE,GAAG,KAAK;GAAQ,GAAG;GAAQ;AAC3C,OAAK,WAAW,oBAAoB,OAAO;;CAI5C,mBAAqC;AACpC,SAAO,EAAE,GAAG,KAAK,QAAQ;;CAI1B,MAAM,aACL,SAA8B,EAAE,EACC;EACjC,MAAM,EAAE,QAAQ,UAAU;EAC1B,MAAMA,UAAwB,KAAK,aAAa,UAAU;AAE1D,MAAI,CAAC,OAAO;AACX,OAAI,QAAQ,WAAW,aAAa,QAAQ,QAC3C,QAAO,QAAQ;AAEhB,OAAI,KAAK,eACR,QAAO,KAAK;;AAId,OAAK,aAAa,YAAY;EAE9B,MAAM,UAAU,KAAK,WACnB,YAAY,CACZ,MAAM,YAAY;AAClB,QAAK,aA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ACH,IAAI,KAAK,MAAM,mBAAmB;EAClC;EACA,gBAAgB,KAAK,kBAAkB;EACvC,MAAM,KAAK,QAAQ,yBAAyB;EAC5C,MAAM,KAAK,QAAQ;EACnB;EACA,WAAW,KAAK,aAAa;EAC7B,QAAQ,KAAK,UAAU;EACvB,WAAW,KAAK,aAAa;EAC7B,WAAW,KAAK,aAAa;EAC7B,YAAY,KAAK,cAAc,uBAAuB;EACtD;;AAGF,SAAS,iBACR,MACyB;AACzB,QAAQ,KAAwB,YAAY"}
|
package/package.json
CHANGED
package/realtime-events.d.ts
CHANGED
|
@@ -223,6 +223,12 @@ declare const realtimeSchema: {
|
|
|
223
223
|
resolvedAt: z.ZodNullable<z.ZodString>;
|
|
224
224
|
resolvedByUserId: z.ZodNullable<z.ZodString>;
|
|
225
225
|
resolvedByAiAgentId: z.ZodNullable<z.ZodString>;
|
|
226
|
+
escalatedAt: z.ZodNullable<z.ZodString>;
|
|
227
|
+
escalatedByAiAgentId: z.ZodNullable<z.ZodString>;
|
|
228
|
+
escalationReason: z.ZodNullable<z.ZodString>;
|
|
229
|
+
escalationHandledAt: z.ZodNullable<z.ZodString>;
|
|
230
|
+
escalationHandledByUserId: z.ZodNullable<z.ZodString>;
|
|
231
|
+
aiPausedUntil: z.ZodNullable<z.ZodString>;
|
|
226
232
|
createdAt: z.ZodString;
|
|
227
233
|
updatedAt: z.ZodString;
|
|
228
234
|
deletedAt: z.ZodNullable<z.ZodString>;
|
|
@@ -466,6 +472,124 @@ declare const realtimeSchema: {
|
|
|
466
472
|
deletedAt: z.ZodNullable<z.ZodString>;
|
|
467
473
|
}, z.core.$strip>;
|
|
468
474
|
}, z.core.$strip>;
|
|
475
|
+
readonly conversationUpdated: z.ZodObject<{
|
|
476
|
+
websiteId: z.ZodString;
|
|
477
|
+
organizationId: z.ZodString;
|
|
478
|
+
visitorId: z.ZodNullable<z.ZodString>;
|
|
479
|
+
userId: z.ZodNullable<z.ZodString>;
|
|
480
|
+
conversationId: z.ZodString;
|
|
481
|
+
updates: z.ZodObject<{
|
|
482
|
+
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
483
|
+
sentiment: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
484
|
+
positive: "positive";
|
|
485
|
+
negative: "negative";
|
|
486
|
+
neutral: "neutral";
|
|
487
|
+
}>>>;
|
|
488
|
+
sentimentConfidence: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
489
|
+
escalatedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
490
|
+
escalationReason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
491
|
+
}, z.core.$strip>;
|
|
492
|
+
aiAgentId: z.ZodNullable<z.ZodString>;
|
|
493
|
+
}, z.core.$strip>;
|
|
494
|
+
readonly crawlStarted: z.ZodObject<{
|
|
495
|
+
websiteId: z.ZodString;
|
|
496
|
+
organizationId: z.ZodString;
|
|
497
|
+
visitorId: z.ZodNullable<z.ZodString>;
|
|
498
|
+
userId: z.ZodNullable<z.ZodString>;
|
|
499
|
+
linkSourceId: z.ZodString;
|
|
500
|
+
url: z.ZodString;
|
|
501
|
+
discoveredPages: z.ZodArray<z.ZodObject<{
|
|
502
|
+
url: z.ZodString;
|
|
503
|
+
title: z.ZodNullable<z.ZodString>;
|
|
504
|
+
depth: z.ZodNumber;
|
|
505
|
+
}, z.core.$strip>>;
|
|
506
|
+
totalPagesCount: z.ZodNumber;
|
|
507
|
+
}, z.core.$strip>;
|
|
508
|
+
readonly crawlProgress: z.ZodObject<{
|
|
509
|
+
websiteId: z.ZodString;
|
|
510
|
+
organizationId: z.ZodString;
|
|
511
|
+
visitorId: z.ZodNullable<z.ZodString>;
|
|
512
|
+
userId: z.ZodNullable<z.ZodString>;
|
|
513
|
+
linkSourceId: z.ZodString;
|
|
514
|
+
url: z.ZodString;
|
|
515
|
+
page: z.ZodObject<{
|
|
516
|
+
url: z.ZodString;
|
|
517
|
+
title: z.ZodNullable<z.ZodString>;
|
|
518
|
+
status: z.ZodEnum<{
|
|
519
|
+
pending: "pending";
|
|
520
|
+
crawling: "crawling";
|
|
521
|
+
completed: "completed";
|
|
522
|
+
failed: "failed";
|
|
523
|
+
}>;
|
|
524
|
+
sizeBytes: z.ZodOptional<z.ZodNumber>;
|
|
525
|
+
error: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
526
|
+
}, z.core.$strip>;
|
|
527
|
+
completedCount: z.ZodNumber;
|
|
528
|
+
totalCount: z.ZodNumber;
|
|
529
|
+
}, z.core.$strip>;
|
|
530
|
+
readonly crawlCompleted: z.ZodObject<{
|
|
531
|
+
websiteId: z.ZodString;
|
|
532
|
+
organizationId: z.ZodString;
|
|
533
|
+
visitorId: z.ZodNullable<z.ZodString>;
|
|
534
|
+
userId: z.ZodNullable<z.ZodString>;
|
|
535
|
+
linkSourceId: z.ZodString;
|
|
536
|
+
url: z.ZodString;
|
|
537
|
+
crawledPagesCount: z.ZodNumber;
|
|
538
|
+
totalSizeBytes: z.ZodNumber;
|
|
539
|
+
failedPagesCount: z.ZodNumber;
|
|
540
|
+
}, z.core.$strip>;
|
|
541
|
+
readonly crawlFailed: z.ZodObject<{
|
|
542
|
+
websiteId: z.ZodString;
|
|
543
|
+
organizationId: z.ZodString;
|
|
544
|
+
visitorId: z.ZodNullable<z.ZodString>;
|
|
545
|
+
userId: z.ZodNullable<z.ZodString>;
|
|
546
|
+
linkSourceId: z.ZodString;
|
|
547
|
+
url: z.ZodString;
|
|
548
|
+
error: z.ZodString;
|
|
549
|
+
}, z.core.$strip>;
|
|
550
|
+
readonly linkSourceUpdated: z.ZodObject<{
|
|
551
|
+
websiteId: z.ZodString;
|
|
552
|
+
organizationId: z.ZodString;
|
|
553
|
+
visitorId: z.ZodNullable<z.ZodString>;
|
|
554
|
+
userId: z.ZodNullable<z.ZodString>;
|
|
555
|
+
linkSourceId: z.ZodString;
|
|
556
|
+
status: z.ZodEnum<{
|
|
557
|
+
pending: "pending";
|
|
558
|
+
crawling: "crawling";
|
|
559
|
+
completed: "completed";
|
|
560
|
+
failed: "failed";
|
|
561
|
+
mapping: "mapping";
|
|
562
|
+
}>;
|
|
563
|
+
discoveredPagesCount: z.ZodOptional<z.ZodNumber>;
|
|
564
|
+
crawledPagesCount: z.ZodOptional<z.ZodNumber>;
|
|
565
|
+
totalSizeBytes: z.ZodOptional<z.ZodNumber>;
|
|
566
|
+
errorMessage: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
567
|
+
}, z.core.$strip>;
|
|
568
|
+
readonly crawlPagesDiscovered: z.ZodObject<{
|
|
569
|
+
websiteId: z.ZodString;
|
|
570
|
+
organizationId: z.ZodString;
|
|
571
|
+
visitorId: z.ZodNullable<z.ZodString>;
|
|
572
|
+
userId: z.ZodNullable<z.ZodString>;
|
|
573
|
+
linkSourceId: z.ZodString;
|
|
574
|
+
pages: z.ZodArray<z.ZodObject<{
|
|
575
|
+
url: z.ZodString;
|
|
576
|
+
path: z.ZodString;
|
|
577
|
+
depth: z.ZodNumber;
|
|
578
|
+
}, z.core.$strip>>;
|
|
579
|
+
}, z.core.$strip>;
|
|
580
|
+
readonly crawlPageCompleted: z.ZodObject<{
|
|
581
|
+
websiteId: z.ZodString;
|
|
582
|
+
organizationId: z.ZodString;
|
|
583
|
+
visitorId: z.ZodNullable<z.ZodString>;
|
|
584
|
+
userId: z.ZodNullable<z.ZodString>;
|
|
585
|
+
linkSourceId: z.ZodString;
|
|
586
|
+
page: z.ZodObject<{
|
|
587
|
+
url: z.ZodString;
|
|
588
|
+
title: z.ZodNullable<z.ZodString>;
|
|
589
|
+
sizeBytes: z.ZodNumber;
|
|
590
|
+
knowledgeId: z.ZodString;
|
|
591
|
+
}, z.core.$strip>;
|
|
592
|
+
}, z.core.$strip>;
|
|
469
593
|
};
|
|
470
594
|
type RealtimeEventType = keyof typeof realtimeSchema;
|
|
471
595
|
type RealtimeEventPayload<T extends RealtimeEventType> = z.infer<(typeof realtimeSchema)[T]>;
|
package/realtime-events.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"realtime-events.d.ts","names":[],"sources":["../../types/src/realtime-events.ts"],"sourcesContent":[],"mappings":";;;;;;;;cAqBa
|
|
1
|
+
{"version":3,"file":"realtime-events.d.ts","names":[],"sources":["../../types/src/realtime-events.ts"],"sourcesContent":[],"mappings":";;;;;;;;cAqBa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAwLD,iBAAA,gBAAiC;KAEjC,+BAA+B,qBAAqB,CAAA,CAAE,cACzD,gBAAgB;KAGb,wBAAwB;QAC7B;WACG,qBAAqB"}
|
package/types/src/enums.js
CHANGED
|
@@ -32,7 +32,10 @@ const ConversationEventType = {
|
|
|
32
32
|
REOPENED: "reopened",
|
|
33
33
|
VISITOR_BLOCKED: "visitor_blocked",
|
|
34
34
|
VISITOR_UNBLOCKED: "visitor_unblocked",
|
|
35
|
-
VISITOR_IDENTIFIED: "visitor_identified"
|
|
35
|
+
VISITOR_IDENTIFIED: "visitor_identified",
|
|
36
|
+
AI_ANALYZED: "ai_analyzed",
|
|
37
|
+
TITLE_GENERATED: "title_generated",
|
|
38
|
+
AI_ESCALATED: "ai_escalated"
|
|
36
39
|
};
|
|
37
40
|
|
|
38
41
|
//#endregion
|
package/types/src/enums.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enums.js","names":[],"sources":["../../../../types/src/enums.ts"],"sourcesContent":["export const SenderType = {\n\tVISITOR: \"visitor\",\n\tTEAM_MEMBER: \"team_member\",\n\tAI: \"ai\",\n} as const;\n\nexport type SenderType = (typeof SenderType)[keyof typeof SenderType];\n\nexport const ConversationStatus = {\n\tOPEN: \"open\",\n\tRESOLVED: \"resolved\",\n\tSPAM: \"spam\",\n} as const;\n\nexport type ConversationStatus =\n\t(typeof ConversationStatus)[keyof typeof ConversationStatus];\n\nexport const ConversationPriority = {\n\tLOW: \"low\",\n\tNORMAL: \"normal\",\n\tHIGH: \"high\",\n\tURGENT: \"urgent\",\n} as const;\n\nexport const TimelineItemVisibility = {\n\tPUBLIC: \"public\",\n\tPRIVATE: \"private\",\n} as const;\n\nexport const ConversationTimelineType = {\n\tMESSAGE: \"message\",\n\tEVENT: \"event\",\n\tIDENTIFICATION: \"identification\",\n} as const;\n\nexport type ConversationTimelineType =\n\t(typeof ConversationTimelineType)[keyof typeof ConversationTimelineType];\n\nexport const ConversationEventType = {\n\tASSIGNED: \"assigned\",\n\tUNASSIGNED: \"unassigned\",\n\tPARTICIPANT_REQUESTED: \"participant_requested\",\n\tPARTICIPANT_JOINED: \"participant_joined\",\n\tPARTICIPANT_LEFT: \"participant_left\",\n\tSTATUS_CHANGED: \"status_changed\",\n\tPRIORITY_CHANGED: \"priority_changed\",\n\tTAG_ADDED: \"tag_added\",\n\tTAG_REMOVED: \"tag_removed\",\n\tRESOLVED: \"resolved\",\n\tREOPENED: \"reopened\",\n\tVISITOR_BLOCKED: \"visitor_blocked\",\n\tVISITOR_UNBLOCKED: \"visitor_unblocked\",\n\tVISITOR_IDENTIFIED: \"visitor_identified\",\n} as const;\n\nexport const ConversationParticipationStatus = {\n\tREQUESTED: \"requested\",\n\tACTIVE: \"active\",\n\tLEFT: \"left\",\n\tDECLINED: \"declined\",\n} as const;\n\nexport const ConversationSentiment = {\n\tPOSITIVE: \"positive\",\n\tNEGATIVE: \"negative\",\n\tNEUTRAL: \"neutral\",\n} as const;\n\nexport type ConversationSentiment =\n\t(typeof ConversationSentiment)[keyof typeof ConversationSentiment];\n\nexport type ConversationParticipationStatus =\n\t(typeof ConversationParticipationStatus)[keyof typeof ConversationParticipationStatus];\n\nexport type ConversationEventType =\n\t(typeof ConversationEventType)[keyof typeof ConversationEventType];\n\nexport type TimelineItemVisibility =\n\t(typeof TimelineItemVisibility)[keyof typeof TimelineItemVisibility];\n\nexport type ConversationPriority =\n\t(typeof ConversationPriority)[keyof typeof ConversationPriority];\n\nexport const WebsiteInstallationTarget = {\n\tNEXTJS: \"nextjs\",\n\tREACT: \"react\",\n} as const;\n\nexport const WebsiteStatus = {\n\tACTIVE: \"active\",\n\tINACTIVE: \"inactive\",\n} as const;\n\nexport type WebsiteStatus = (typeof WebsiteStatus)[keyof typeof WebsiteStatus];\n\nexport type WebsiteInstallationTarget =\n\t(typeof WebsiteInstallationTarget)[keyof typeof WebsiteInstallationTarget];\n\nexport const APIKeyType = {\n\tPRIVATE: \"private\",\n\tPUBLIC: \"public\",\n} as const;\n\nexport type APIKeyType = (typeof APIKeyType)[keyof typeof APIKeyType];\n"],"mappings":";AAAA,MAAa,aAAa;CACzB,SAAS;CACT,aAAa;CACb,IAAI;CACJ;AAID,MAAa,qBAAqB;CACjC,MAAM;CACN,UAAU;CACV,MAAM;CACN;AAYD,MAAa,yBAAyB;CACrC,QAAQ;CACR,SAAS;CACT;AAED,MAAa,2BAA2B;CACvC,SAAS;CACT,OAAO;CACP,gBAAgB;CAChB;AAKD,MAAa,wBAAwB;CACpC,UAAU;CACV,YAAY;CACZ,uBAAuB;CACvB,oBAAoB;CACpB,kBAAkB;CAClB,gBAAgB;CAChB,kBAAkB;CAClB,WAAW;CACX,aAAa;CACb,UAAU;CACV,UAAU;CACV,iBAAiB;CACjB,mBAAmB;CACnB,oBAAoB;
|
|
1
|
+
{"version":3,"file":"enums.js","names":[],"sources":["../../../../types/src/enums.ts"],"sourcesContent":["export const SenderType = {\n\tVISITOR: \"visitor\",\n\tTEAM_MEMBER: \"team_member\",\n\tAI: \"ai\",\n} as const;\n\nexport type SenderType = (typeof SenderType)[keyof typeof SenderType];\n\nexport const ConversationStatus = {\n\tOPEN: \"open\",\n\tRESOLVED: \"resolved\",\n\tSPAM: \"spam\",\n} as const;\n\nexport type ConversationStatus =\n\t(typeof ConversationStatus)[keyof typeof ConversationStatus];\n\nexport const ConversationPriority = {\n\tLOW: \"low\",\n\tNORMAL: \"normal\",\n\tHIGH: \"high\",\n\tURGENT: \"urgent\",\n} as const;\n\nexport const TimelineItemVisibility = {\n\tPUBLIC: \"public\",\n\tPRIVATE: \"private\",\n} as const;\n\nexport const ConversationTimelineType = {\n\tMESSAGE: \"message\",\n\tEVENT: \"event\",\n\tIDENTIFICATION: \"identification\",\n} as const;\n\nexport type ConversationTimelineType =\n\t(typeof ConversationTimelineType)[keyof typeof ConversationTimelineType];\n\nexport const ConversationEventType = {\n\tASSIGNED: \"assigned\",\n\tUNASSIGNED: \"unassigned\",\n\tPARTICIPANT_REQUESTED: \"participant_requested\",\n\tPARTICIPANT_JOINED: \"participant_joined\",\n\tPARTICIPANT_LEFT: \"participant_left\",\n\tSTATUS_CHANGED: \"status_changed\",\n\tPRIORITY_CHANGED: \"priority_changed\",\n\tTAG_ADDED: \"tag_added\",\n\tTAG_REMOVED: \"tag_removed\",\n\tRESOLVED: \"resolved\",\n\tREOPENED: \"reopened\",\n\tVISITOR_BLOCKED: \"visitor_blocked\",\n\tVISITOR_UNBLOCKED: \"visitor_unblocked\",\n\tVISITOR_IDENTIFIED: \"visitor_identified\",\n\t// Private AI events (team only, not visible to visitors)\n\tAI_ANALYZED: \"ai_analyzed\",\n\tTITLE_GENERATED: \"title_generated\",\n\tAI_ESCALATED: \"ai_escalated\",\n} as const;\n\nexport const ConversationParticipationStatus = {\n\tREQUESTED: \"requested\",\n\tACTIVE: \"active\",\n\tLEFT: \"left\",\n\tDECLINED: \"declined\",\n} as const;\n\nexport const ConversationSentiment = {\n\tPOSITIVE: \"positive\",\n\tNEGATIVE: \"negative\",\n\tNEUTRAL: \"neutral\",\n} as const;\n\nexport type ConversationSentiment =\n\t(typeof ConversationSentiment)[keyof typeof ConversationSentiment];\n\nexport type ConversationParticipationStatus =\n\t(typeof ConversationParticipationStatus)[keyof typeof ConversationParticipationStatus];\n\nexport type ConversationEventType =\n\t(typeof ConversationEventType)[keyof typeof ConversationEventType];\n\nexport type TimelineItemVisibility =\n\t(typeof TimelineItemVisibility)[keyof typeof TimelineItemVisibility];\n\nexport type ConversationPriority =\n\t(typeof ConversationPriority)[keyof typeof ConversationPriority];\n\nexport const WebsiteInstallationTarget = {\n\tNEXTJS: \"nextjs\",\n\tREACT: \"react\",\n} as const;\n\nexport const WebsiteStatus = {\n\tACTIVE: \"active\",\n\tINACTIVE: \"inactive\",\n} as const;\n\nexport type WebsiteStatus = (typeof WebsiteStatus)[keyof typeof WebsiteStatus];\n\nexport type WebsiteInstallationTarget =\n\t(typeof WebsiteInstallationTarget)[keyof typeof WebsiteInstallationTarget];\n\nexport const APIKeyType = {\n\tPRIVATE: \"private\",\n\tPUBLIC: \"public\",\n} as const;\n\nexport type APIKeyType = (typeof APIKeyType)[keyof typeof APIKeyType];\n"],"mappings":";AAAA,MAAa,aAAa;CACzB,SAAS;CACT,aAAa;CACb,IAAI;CACJ;AAID,MAAa,qBAAqB;CACjC,MAAM;CACN,UAAU;CACV,MAAM;CACN;AAYD,MAAa,yBAAyB;CACrC,QAAQ;CACR,SAAS;CACT;AAED,MAAa,2BAA2B;CACvC,SAAS;CACT,OAAO;CACP,gBAAgB;CAChB;AAKD,MAAa,wBAAwB;CACpC,UAAU;CACV,YAAY;CACZ,uBAAuB;CACvB,oBAAoB;CACpB,kBAAkB;CAClB,gBAAgB;CAChB,kBAAkB;CAClB,WAAW;CACX,aAAa;CACb,UAAU;CACV,UAAU;CACV,iBAAiB;CACjB,mBAAmB;CACnB,oBAAoB;CAEpB,aAAa;CACb,iBAAiB;CACjB,cAAc;CACd"}
|