@coristen/widget 0.0.0-stage → 0.1.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/README.md CHANGED
@@ -1,3 +1,29 @@
1
- # Temporary Holding Version
1
+ # @coristen/widget
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Install the Coristen customer-experience widget in any React application.
4
+
5
+ ```bash
6
+ npm install @coristen/widget
7
+ ```
8
+
9
+ ```tsx
10
+ import { CoristenWidget } from "@coristen/widget"
11
+ import "@coristen/widget/styles.css"
12
+
13
+ export default function App() {
14
+ return <CoristenWidget identity="/api/coristen/identity" />
15
+ }
16
+ ```
17
+
18
+ Create the route with the server-only helper:
19
+
20
+ ```ts
21
+ import { coristenIdentity } from "@coristen/widget/server"
22
+
23
+ export const { GET } = coristenIdentity(async (request) => {
24
+ const user = await getSignedInUser(request)
25
+ return user ? { id: user.id, name: user.name, email: user.email } : null
26
+ })
27
+ ```
28
+
29
+ Set `CORISTEN_KEY` on the server. The widget renders only for a verified signed-in customer; there is no anonymous fallback. Use `apiUrl="http://localhost:3000"` while developing Coristen locally.
package/dist/api.d.ts ADDED
@@ -0,0 +1,120 @@
1
+ export type ChatMessage = {
2
+ _id: string;
3
+ _creationTime: number;
4
+ sender: "customer" | "merchant";
5
+ body: string;
6
+ inReplyTo?: string;
7
+ generationStatus?: "generating" | "complete" | "failed";
8
+ generationError?: string;
9
+ model?: string;
10
+ citations?: Array<{
11
+ sourceId: string;
12
+ title: string;
13
+ url?: string;
14
+ }>;
15
+ attachments: Array<{
16
+ storageId: string;
17
+ name: string;
18
+ type: string;
19
+ size: number;
20
+ url: string | null;
21
+ }>;
22
+ };
23
+ export type ChatAttachment = {
24
+ storageId: string;
25
+ name: string;
26
+ type: string;
27
+ size: number;
28
+ };
29
+ export type WidgetSettings = {
30
+ name: string;
31
+ brandColor: string;
32
+ welcomeMessage: string;
33
+ privacyPolicyUrl: string;
34
+ position: "left" | "right";
35
+ enabled: boolean;
36
+ theme: "light" | "dark";
37
+ tintedGrayscale: boolean;
38
+ accentEnabled: boolean;
39
+ accentHeader: boolean;
40
+ accentSendIcon: boolean;
41
+ radius: "none" | "sm" | "md" | "lg";
42
+ bubbleIcon: string;
43
+ bubbleColor: string;
44
+ bubbleShowText: boolean;
45
+ bubbleText: string;
46
+ bubbleIconPosition: "left" | "right";
47
+ showPoweredBy: boolean;
48
+ maxAttachmentSizeMb: number;
49
+ allowedAttachmentTypes: string[];
50
+ };
51
+ export declare const widgetApi: {
52
+ workspace: import("convex/server").FunctionReference<"query", "public", {
53
+ workspaceId: string;
54
+ }, WidgetSettings | null, string | undefined>;
55
+ visitorProfile: import("convex/server").FunctionReference<"query", "public", {
56
+ workspaceId: string;
57
+ visitorId: string;
58
+ sessionToken: string;
59
+ }, {
60
+ name: string;
61
+ email: string;
62
+ } | null, string | undefined>;
63
+ openWebsite: import("convex/server").FunctionReference<"mutation", "public", {
64
+ workspaceId: string;
65
+ visitorId: string;
66
+ name: string;
67
+ email: string;
68
+ currentPage: string;
69
+ referrer: string;
70
+ browser: string;
71
+ device: string;
72
+ newConversation?: boolean;
73
+ sessionToken: string;
74
+ }, string | null, string | undefined>;
75
+ visitorConversations: import("convex/server").FunctionReference<"query", "public", {
76
+ workspaceId: string;
77
+ visitorId: string;
78
+ sessionToken: string;
79
+ }, {
80
+ _id: string;
81
+ lastMessageAt: number;
82
+ lastMessagePreview?: string;
83
+ customerUnreadCount?: number;
84
+ }[], string | undefined>;
85
+ customerMessages: import("convex/server").FunctionReference<"query", "public", {
86
+ conversationId: string;
87
+ visitorId: string;
88
+ sessionToken: string;
89
+ }, ChatMessage[], string | undefined>;
90
+ startCustomer: import("convex/server").FunctionReference<"mutation", "public", {
91
+ workspaceId: string;
92
+ visitorId: string;
93
+ body: string;
94
+ attachments?: ChatAttachment[];
95
+ sessionToken: string;
96
+ }, string, string | undefined>;
97
+ sendCustomer: import("convex/server").FunctionReference<"mutation", "public", {
98
+ conversationId: string;
99
+ visitorId: string;
100
+ body: string;
101
+ attachments?: ChatAttachment[];
102
+ sessionToken: string;
103
+ }, string, string | undefined>;
104
+ retryAgentResponse: import("convex/server").FunctionReference<"mutation", "public", {
105
+ conversationId: string;
106
+ visitorId: string;
107
+ customerMessageId: string;
108
+ sessionToken: string;
109
+ }, null, string | undefined>;
110
+ generateAttachmentUploadUrl: import("convex/server").FunctionReference<"mutation", "public", {
111
+ workspaceId: string;
112
+ visitorId: string;
113
+ sessionToken: string;
114
+ }, string, string | undefined>;
115
+ markCustomerRead: import("convex/server").FunctionReference<"mutation", "public", {
116
+ conversationId: string;
117
+ visitorId: string;
118
+ sessionToken: string;
119
+ }, null, string | undefined>;
120
+ };
@@ -0,0 +1,14 @@
1
+ import type { WidgetSettings } from "./api";
2
+ export type CoristenWidgetProps = {
3
+ identity: string;
4
+ apiUrl?: string;
5
+ defaultOpen?: boolean;
6
+ fontSize?: string;
7
+ appearance?: WidgetAppearance;
8
+ };
9
+ export type WidgetAppearance = Partial<Pick<WidgetSettings, "brandColor" | "position" | "theme" | "tintedGrayscale" | "accentEnabled" | "accentHeader" | "accentSendIcon" | "radius" | "bubbleIcon" | "bubbleColor" | "bubbleShowText" | "bubbleText" | "bubbleIconPosition" | "showPoweredBy">>;
10
+ export declare function CoristenWidget({ identity, apiUrl, defaultOpen, fontSize, appearance, }: CoristenWidgetProps): import("react").JSX.Element | null;
11
+ export type { WidgetSettings } from "./api";
12
+ export declare const coristenWidget: {
13
+ reset(): void;
14
+ };