@coristen/widget 0.1.0 → 0.1.2

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,29 +1,39 @@
1
- # @coristen/widget
2
-
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.
1
+ # @coristen/widget
2
+
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 apiKey="coristen_pk_..." />
15
+ }
16
+ ```
17
+
18
+ Public websites use `apiKey`; visitors are remembered in that browser. For an
19
+ authenticated app, use an identity route instead so conversations follow the
20
+ signed-in customer:
21
+
22
+ ```tsx
23
+ <CoristenWidget identity="/api/coristen/identity" />
24
+ ```
25
+
26
+ Create the route with the server-only helper:
27
+
28
+ ```ts
29
+ import { coristenIdentity } from "@coristen/widget/server"
30
+
31
+ export const { GET } = coristenIdentity(async (request) => {
32
+ const user = await getSignedInUser(request)
33
+ return user ? { id: user.id, name: user.name, email: user.email } : null
34
+ })
35
+ ```
36
+
37
+ Set `CORISTEN_KEY` on the server when using identity mode. Identity mode renders
38
+ only for a verified signed-in customer; it never falls back to anonymous access.
39
+ Use `apiUrl="http://localhost:3000"` while developing Coristen locally.
package/dist/api.d.ts CHANGED
@@ -6,7 +6,6 @@ export type ChatMessage = {
6
6
  inReplyTo?: string;
7
7
  generationStatus?: "generating" | "complete" | "failed";
8
8
  generationError?: string;
9
- model?: string;
10
9
  citations?: Array<{
11
10
  sourceId: string;
12
11
  title: string;
@@ -28,6 +27,8 @@ export type ChatAttachment = {
28
27
  };
29
28
  export type WidgetSettings = {
30
29
  name: string;
30
+ agentName: string;
31
+ agentImageUrl: string | null;
31
32
  brandColor: string;
32
33
  welcomeMessage: string;
33
34
  privacyPolicyUrl: string;
@@ -41,9 +42,6 @@ export type WidgetSettings = {
41
42
  radius: "none" | "sm" | "md" | "lg";
42
43
  bubbleIcon: string;
43
44
  bubbleColor: string;
44
- bubbleShowText: boolean;
45
- bubbleText: string;
46
- bubbleIconPosition: "left" | "right";
47
45
  showPoweredBy: boolean;
48
46
  maxAttachmentSizeMb: number;
49
47
  allowedAttachmentTypes: string[];
package/dist/index.d.ts CHANGED
@@ -1,14 +1,24 @@
1
1
  import type { WidgetSettings } from "./api";
2
- export type CoristenWidgetProps = {
3
- identity: string;
2
+ type CoristenWidgetOptions = {
4
3
  apiUrl?: string;
5
4
  defaultOpen?: boolean;
6
5
  fontSize?: string;
7
6
  appearance?: WidgetAppearance;
7
+ onReady?: () => void;
8
+ onError?: (error: Error) => void;
8
9
  };
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;
10
+ export type CoristenWidgetProps = CoristenWidgetOptions & ({
11
+ apiKey: string;
12
+ identity?: never;
13
+ } | {
14
+ identity: string;
15
+ apiKey?: never;
16
+ });
17
+ export type WidgetAppearance = Partial<Pick<WidgetSettings, "brandColor" | "position" | "theme" | "tintedGrayscale" | "accentEnabled" | "accentHeader" | "accentSendIcon" | "radius" | "bubbleIcon" | "bubbleColor" | "showPoweredBy">>;
18
+ export declare function CoristenWidget({ identity, apiKey, apiUrl, defaultOpen, fontSize, appearance, onReady, onError, }: CoristenWidgetProps): import("react").JSX.Element | null;
11
19
  export type { WidgetSettings } from "./api";
12
20
  export declare const coristenWidget: {
21
+ open(): void;
22
+ close(): void;
13
23
  reset(): void;
14
24
  };