@corti/embedded-web 0.3.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -1
- package/dist/CortiEmbedded.d.ts +7 -1
- package/dist/CortiEmbedded.js +26 -0
- package/dist/CortiEmbedded.js.map +1 -1
- package/dist/bundle.js +26 -0
- package/dist/public-types.d.ts +14 -7
- package/dist/public-types.js.map +1 -1
- package/dist/react/CortiEmbeddedReact.d.ts +1 -0
- package/dist/react/CortiEmbeddedReact.js +1 -0
- package/dist/react/CortiEmbeddedReact.js.map +1 -1
- package/dist/types/api.d.ts +10 -3
- package/dist/types/api.js.map +1 -1
- package/dist/types/config.d.ts +4 -0
- package/dist/types/config.js.map +1 -1
- package/dist/types/generated/interview-details.d.ts +41 -0
- package/dist/types/generated/interview-details.js.map +1 -1
- package/dist/types/payloads.d.ts +72 -6
- package/dist/types/payloads.js.map +1 -1
- package/dist/types/protocol.d.ts +5 -2
- package/dist/types/protocol.js.map +1 -1
- package/dist/types/responses.d.ts +14 -2
- package/dist/types/responses.js.map +1 -1
- package/dist/web-bundle.js +25 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,6 +15,48 @@ A web component and React component library that provides an embedded interface
|
|
|
15
15
|
npm install @corti/embedded-web
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
+
## Testing
|
|
19
|
+
|
|
20
|
+
Install dependencies before running tests:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Run the full test suite:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm test
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Run tests in watch mode while developing:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npm run test:watch
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Run only the embedded component communication integration test:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npx tsc -p tsconfig.test.json && npx wtr .tmp/test-dist/test/corti-embedded.integration.test.js
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Run the integration test across Chromium, Firefox, and WebKit:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
npx tsc -p tsconfig.test.json && EMBEDDED_WEB_TEST_BROWSERS=chromium,firefox,webkit npx wtr .tmp/test-dist/test/corti-embedded.integration.test.js
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Run the integration test against an installed Microsoft Edge channel:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
npx tsc -p tsconfig.test.json && EMBEDDED_WEB_TEST_BROWSERS=chromium EMBEDDED_WEB_CHROMIUM_CHANNEL=msedge npx wtr .tmp/test-dist/test/corti-embedded.integration.test.js
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
The integration test runs in Playwright Chromium by default and can be expanded to Firefox, WebKit, or an installed Edge channel. It validates the public web component API against a real iframe `postMessage` boundary and uses the local test runner setup, so it does not require access to the live embedded Assistant service.
|
|
57
|
+
|
|
58
|
+
Pull requests also run the integration test against Microsoft Edge on a Windows GitHub Actions runner.
|
|
59
|
+
|
|
18
60
|
## Usage
|
|
19
61
|
|
|
20
62
|
### Web Component
|
|
@@ -280,7 +322,7 @@ The component uses a `PostMessageHandler` utility class that:
|
|
|
280
322
|
|
|
281
323
|
The React component (`CortiEmbeddedReact`) is available as an additional export and provides:
|
|
282
324
|
|
|
283
|
-
- **Hook-based API access**: `useCortiEmbeddedApi(ref)` exposes instance-bound methods (`auth`, `navigate`, `createInteraction`, etc.)
|
|
325
|
+
- **Hook-based API access**: `useCortiEmbeddedApi(ref)` exposes instance-bound methods (`auth`, `navigate`, `createInteraction`, `showDeviceLinkQR`, etc.)
|
|
284
326
|
- **Generic event stream**: `onEvent` receives the wrapper's `event` `CustomEvent`, with `event.detail` shaped as `{ name, payload }`
|
|
285
327
|
- **Status hook**: `useCortiEmbeddedStatus(ref)` keeps latest status/reactive state
|
|
286
328
|
- **Multi-instance safety**: API methods are scoped to the ref you pass
|
package/dist/CortiEmbedded.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Corti } from "@corti/sdk";
|
|
2
2
|
import { LitElement, type PropertyValues } from "lit";
|
|
3
|
-
import type { ConfigureApplicationPayload, ConfigureApplicationResponse, ConfigurePayload, ConfigureResponse, CreateInteractionPayload, NavigatePayload, SetInteractionOptionsPayload, SetCredentialsPayload, CortiEmbeddedAPI, InteractionDetails, SessionConfig, User, GetStatusResponse, GetTemplatesResponse, KeycloakTokenResponse } from "./public-types.js";
|
|
3
|
+
import type { ConfigureApplicationPayload, ConfigureApplicationResponse, ConfigurePayload, ConfigureResponse, CreateInteractionPayload, DeviceLinkTokenResponse, NavigatePayload, SetInteractionOptionsPayload, SetCredentialsPayload, CortiEmbeddedAPI, InteractionDetails, SessionConfig, User, GetStatusResponse, GetTemplatesResponse, KeycloakTokenResponse, ShowDeviceLinkQRResponse } from "./public-types.js";
|
|
4
4
|
type DOMEventListener = ((event: Event) => void) | {
|
|
5
5
|
handleEvent(event: Event): void;
|
|
6
6
|
};
|
|
@@ -112,6 +112,12 @@ export declare class CortiEmbedded extends LitElement implements CortiEmbeddedAP
|
|
|
112
112
|
* Get templates
|
|
113
113
|
*/
|
|
114
114
|
getTemplates(): Promise<GetTemplatesResponse>;
|
|
115
|
+
/**
|
|
116
|
+
* Show the device-link QR code in the embedded UI
|
|
117
|
+
* @param payload Device-link token response to render as a QR code
|
|
118
|
+
* @returns Promise resolving to the rendered QR code state
|
|
119
|
+
*/
|
|
120
|
+
showDeviceLinkQR(payload: DeviceLinkTokenResponse): Promise<ShowDeviceLinkQRResponse>;
|
|
115
121
|
/**
|
|
116
122
|
* Check the current status of the iframe and PostMessageHandler
|
|
117
123
|
* Useful for debugging
|
package/dist/CortiEmbedded.js
CHANGED
|
@@ -559,6 +559,32 @@ export class CortiEmbedded extends LitElement {
|
|
|
559
559
|
throw new Error(JSON.stringify(formattedError));
|
|
560
560
|
}
|
|
561
561
|
}
|
|
562
|
+
/**
|
|
563
|
+
* Show the device-link QR code in the embedded UI
|
|
564
|
+
* @param payload Device-link token response to render as a QR code
|
|
565
|
+
* @returns Promise resolving to the rendered QR code state
|
|
566
|
+
*/
|
|
567
|
+
async showDeviceLinkQR(payload) {
|
|
568
|
+
if (!this.postMessageHandler) {
|
|
569
|
+
throw new Error("Component not ready");
|
|
570
|
+
}
|
|
571
|
+
try {
|
|
572
|
+
const response = await this.postMessageHandler.postMessage({
|
|
573
|
+
type: "CORTI_EMBEDDED",
|
|
574
|
+
version: "v1",
|
|
575
|
+
action: "showDeviceLinkQR",
|
|
576
|
+
payload,
|
|
577
|
+
});
|
|
578
|
+
if (response.success && response.payload) {
|
|
579
|
+
return response.payload;
|
|
580
|
+
}
|
|
581
|
+
throw new Error(response.error);
|
|
582
|
+
}
|
|
583
|
+
catch (error) {
|
|
584
|
+
const formattedError = formatError(error, "Failed to show device link QR");
|
|
585
|
+
throw new Error(JSON.stringify(formattedError));
|
|
586
|
+
}
|
|
587
|
+
}
|
|
562
588
|
/**
|
|
563
589
|
* Check the current status of the iframe and PostMessageHandler
|
|
564
590
|
* Useful for debugging
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CortiEmbedded.js","sourceRoot":"","sources":["../src/CortiEmbedded.ts"],"names":[],"mappings":";;;;;;AAEA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAuB,MAAM,KAAK,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAsB7C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,E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OAAO,EAAE,IAAI,EAAE,CAAC;iDACpB;AAGtB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8CACzB","sourcesContent":["/* eslint-disable no-console */\nimport type { Corti } from \"@corti/sdk\";\nimport { html, LitElement, type PropertyValues } from \"lit\";\nimport { property } from \"lit/decorators.js\";\nimport type {\n AuthResponse,\n AddFactsPayload,\n ConfigureApplicationPayload,\n ConfigureApplicationResponse,\n ConfigurePayload,\n ConfigureResponse,\n ConfigureSessionPayload,\n CreateInteractionPayload,\n CreateInteractionResponse,\n NavigatePayload,\n SetInteractionOptionsPayload,\n SetCredentialsPayload,\n CortiEmbeddedAPI,\n InteractionDetails,\n SessionConfig,\n User,\n GetStatusResponse,\n GetTemplatesResponse,\n KeycloakTokenResponse,\n} from \"./public-types.js\";\nimport { baseStyles } from \"./styles/base.js\";\nimport { containerStyles } from \"./styles/container-styles.js\";\nimport { validateAndNormalizeBaseURL } from \"./utils/baseUrl.js\";\nimport { buildEmbeddedUrl, isRealEmbeddedLoad } from \"./utils/embedUrl.js\";\nimport { formatError } from \"./utils/errorFormatter.js\";\nimport {\n PostMessageHandler,\n type PostMessageHandlerCallbacks,\n} from \"./utils/PostMessageHandler.js\";\n\nconst IFRAME_SANDBOX_POLICY =\n \"allow-forms allow-modals allow-scripts allow-same-origin\";\n\nconst DEPRECATION_TIMELINE_URL =\n \"https://docs.corti.ai/assistant/deprecation-timeline\";\n\nconst CONFIGURATION_MIGRATION_URL =\n \"https://docs.corti.ai/assistant/configuration-migration\";\n\nconst DEPRECATED_EVENT_SUBSCRIPTIONS = new Set([\n \"ready\",\n \"loaded\",\n \"recordingStarted\",\n \"recordingStopped\",\n \"documentGenerated\",\n \"documentUpdated\",\n \"documentSynced\",\n \"authChanged\",\n \"interactionCreated\",\n \"navigationChanged\",\n \"usage\",\n \"embedded-event\",\n]);\n\ntype DOMEventListener =\n | ((event: Event) => void)\n | { handleEvent(event: Event): void };\n\ntype DOMAddEventListenerOptions =\n | boolean\n | {\n capture?: boolean;\n once?: boolean;\n passive?: boolean;\n signal?: AbortSignal;\n };\n\nexport class CortiEmbedded extends LitElement implements CortiEmbeddedAPI {\n static styles = [baseStyles, containerStyles];\n\n @property({ type: String, reflect: true })\n visibility = \"hidden\";\n\n @property({ type: String, reflect: true })\n baseURL!: string;\n\n private postMessageHandler: PostMessageHandler | null = null;\n\n private normalizedBaseURL: string | null = null;\n\n private warnedDeprecatedEventSubscriptions = new Set<string>();\n\n addEventListener(\n type: string,\n callback: DOMEventListener,\n options?: DOMAddEventListenerOptions,\n ): void {\n this.warnDeprecatedEventSubscription(type);\n super.addEventListener(type, callback, options);\n }\n\n private warnDeprecatedEventSubscription(eventName: string): void {\n if (\n !DEPRECATED_EVENT_SUBSCRIPTIONS.has(eventName) ||\n this.warnedDeprecatedEventSubscriptions.has(eventName)\n ) {\n return;\n }\n\n this.warnedDeprecatedEventSubscriptions.add(eventName);\n console.warn(\n `[Corti Embedded] The '${eventName}' event subscription is deprecated and will be removed in a future release. Subscribe to the canonical 'event' stream instead. See ${DEPRECATION_TIMELINE_URL}.`,\n );\n }\n\n // eslint-disable-next-line class-methods-use-this\n private getIframeAllowPolicy(normalizedBaseURL?: string | null): string {\n const permissionTarget = normalizedBaseURL\n ? new URL(normalizedBaseURL).origin\n : \"*\";\n\n return [\n `microphone ${permissionTarget}`,\n `camera ${permissionTarget}`,\n `device-capture ${permissionTarget}`,\n `display-capture ${permissionTarget}`,\n `clipboard-write ${permissionTarget}`,\n ].join(\"; \");\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n // Ensure baseURL is provided\n if (!this.baseURL) {\n this.dispatchErrorEvent({\n message: \"baseURL is required\",\n });\n return;\n }\n\n // Validate and normalize the initial baseURL early (fail fast)\n try {\n this.normalizedBaseURL = validateAndNormalizeBaseURL(this.baseURL);\n } catch (error) {\n this.dispatchErrorEvent({\n message: (error as Error).message || \"Invalid baseURL\",\n });\n // Dispatch the error event rather than throwing so consumers can handle it\n // via the 'error' event listener without wrapping connectedCallback in try/catch.\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n if (this.postMessageHandler) {\n this.postMessageHandler.destroy();\n this.postMessageHandler = null;\n }\n }\n\n private async setupPostMessageHandler() {\n // Prevent multiple setups\n if (this.postMessageHandler) {\n return;\n }\n\n const iframe = this.getIframe();\n\n if (iframe?.contentWindow) {\n const callbacks: PostMessageHandlerCallbacks = {\n onEvent: event => {\n this.dispatchEmbeddedEvent(event.name, event.payload);\n },\n onError: error => {\n this.dispatchErrorEvent(error);\n },\n };\n\n this.postMessageHandler = new PostMessageHandler(iframe, callbacks);\n } else {\n this.dispatchErrorEvent({\n message: \"No iframe or contentWindow available\",\n });\n }\n }\n\n private dispatchPublicEvent(event: string, data: unknown) {\n this.dispatchEvent(new CustomEvent(event, { detail: data }));\n }\n\n private dispatchEmbeddedEvent(rawEventName: string, payload: unknown) {\n if (rawEventName === \"ready\" || rawEventName === \"loaded\") return;\n // Pass all other events through as raw DOM events for direct listeners.\n this.dispatchPublicEvent(rawEventName, payload);\n\n // Forward supported embedded events through the generic 'event' stream so\n // consumers can observe them without subscribing to each raw event name.\n this.dispatchPublicEvent(\"event\", {\n name: rawEventName,\n payload,\n });\n\n // Also emit the legacy 'embedded-event' stream for backward compatibility.\n // This allows existing integrations listening for 'embedded-event' to continue\n // working while newer consumers can use the 'event' stream.\n this.dispatchPublicEvent(\"embedded-event\", {\n name: rawEventName,\n payload,\n });\n }\n\n private dispatchErrorEvent(error: {\n message: string;\n code?: string;\n details?: unknown;\n }) {\n this.dispatchPublicEvent(\"error\", error);\n }\n\n private static warnDeprecatedAPI(\n methodName: string,\n replacement: string,\n ): void {\n console.warn(\n `[Corti Embedded] ${methodName} is deprecated and will be removed in a future release. Use ${replacement} instead. See ${CONFIGURATION_MIGRATION_URL} and ${DEPRECATION_TIMELINE_URL}.`,\n );\n }\n\n private isRealIframeLoad(iframe: HTMLIFrameElement): boolean {\n const src = iframe.getAttribute(\"src\") || \"\";\n if (!this.normalizedBaseURL) return false;\n return isRealEmbeddedLoad(src, this.normalizedBaseURL);\n }\n\n private async handleIframeLoad(event: Event) {\n const iframe = event.target as HTMLIFrameElement | null;\n if (!iframe) {\n return;\n }\n // Only initialize on real URL load, ignore about:blank\n if (!this.isRealIframeLoad(iframe)) {\n return;\n }\n try {\n await this.setupPostMessageHandler();\n } catch (error) {\n this.dispatchErrorEvent({\n message: `Failed to setup PostMessageHandler on iframe load: ${error}`,\n });\n }\n }\n\n private getIframe(): HTMLIFrameElement | null {\n return this.shadowRoot?.querySelector(\"iframe\") || null;\n }\n\n protected updated(changedProps: PropertyValues) {\n super.updated(changedProps);\n if (changedProps.has(\"baseURL\")) {\n // Tear down the existing handler; the new one is created in handleIframeLoad\n if (this.postMessageHandler) {\n this.postMessageHandler.destroy();\n this.postMessageHandler = null;\n }\n\n // Validate the new URL\n try {\n this.normalizedBaseURL = validateAndNormalizeBaseURL(this.baseURL);\n } catch (error) {\n this.normalizedBaseURL = null;\n const iframe = this.getIframe();\n if (iframe) {\n iframe.setAttribute(\"src\", \"about:blank\");\n }\n this.dispatchErrorEvent({\n message: (error as Error).message || \"Invalid baseURL\",\n });\n return;\n }\n\n // Update the iframe to the new URL\n const iframe = this.getIframe();\n if (iframe) {\n const expected = buildEmbeddedUrl(this.normalizedBaseURL);\n iframe.setAttribute(\"allow\", this.getIframeAllowPolicy(expected));\n if (iframe.getAttribute(\"src\") !== expected) {\n iframe.setAttribute(\"src\", expected);\n }\n }\n }\n }\n\n // Public API Implementation\n\n /**\n * Authenticate with the Corti system\n * @param credentials Authentication credentials\n * @returns Promise resolving to user information\n */\n async auth(credentials: KeycloakTokenResponse): Promise<User> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n const payload: KeycloakTokenResponse = {\n access_token: credentials.access_token,\n token_type: credentials.token_type,\n expires_at: credentials.expires_at,\n expires_in: credentials.expires_in,\n refresh_expires_in: credentials.refresh_expires_in,\n refresh_token: credentials.refresh_token,\n id_token: credentials.id_token,\n \"not-before-policy\": credentials[\"not-before-policy\"],\n session_state: credentials.session_state,\n scope: credentials.scope,\n profile: credentials.profile,\n };\n\n const response = await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"auth\",\n payload,\n });\n\n if (response.success && response.payload) {\n return (response.payload as AuthResponse).user;\n }\n throw new Error(response.error);\n } catch (error) {\n const formattedError = formatError(error, \"Authentication failed\");\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Create a new interaction\n * @param encounter Encounter request data\n * @returns Promise resolving to interaction details\n */\n async createInteraction(\n encounter: CreateInteractionPayload,\n ): Promise<InteractionDetails> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n const response = await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"createInteraction\",\n payload: encounter,\n });\n\n if (response.success && response.payload) {\n const result = response.payload as CreateInteractionResponse;\n return {\n id: result.id,\n createdAt: result.createdAt,\n };\n }\n throw new Error(response.error);\n } catch (error) {\n const formattedError = formatError(error, \"Failed to create interaction\");\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Configure the current session\n * @param config Session configuration\n * @returns Promise that resolves when configuration is complete\n */\n async configureSession(config: SessionConfig): Promise<void> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n CortiEmbedded.warnDeprecatedAPI(\n \"configureSession()\",\n \"setInteractionOptions()\",\n );\n const payload: ConfigureSessionPayload = {\n defaultLanguage: config.defaultLanguage,\n defaultOutputLanguage: config.defaultOutputLanguage,\n defaultTemplateKey: config.defaultTemplateKey,\n defaultMode: config.defaultMode,\n };\n\n await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"configureSession\",\n payload,\n });\n } catch (error) {\n const formattedError = formatError(error, \"Failed to configure session\");\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Add facts to the current session\n * @param facts Array of facts to add\n * @returns Promise that resolves when facts are added\n */\n async addFacts(facts: Corti.FactsCreateInput[]): Promise<void> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n const payload: AddFactsPayload = { facts };\n await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"addFacts\",\n payload,\n });\n } catch (error) {\n const formattedError = formatError(error, \"Failed to add facts\");\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Navigate to a specific path within the embedded UI\n * @param payload Navigation request payload or legacy path string\n * @returns Promise that resolves when navigation is complete\n */\n async navigate(payload: NavigatePayload | string): Promise<void> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n const normalizedPayload: NavigatePayload =\n typeof payload === \"string\" ? { path: payload } : payload;\n await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"navigate\",\n payload: normalizedPayload,\n });\n } catch (error) {\n const formattedError = formatError(error, \"Failed to navigate\");\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Start recording\n * @returns Promise that resolves when recording starts\n */\n async startRecording(): Promise<void> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"startRecording\",\n payload: {},\n });\n } catch (error) {\n const formattedError = formatError(error, \"Failed to start recording\");\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Stop recording\n * @returns Promise that resolves when recording stops\n */\n async stopRecording(): Promise<void> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"stopRecording\",\n payload: {},\n });\n } catch (error) {\n const formattedError = formatError(error, \"Failed to stop recording\");\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Get current component status\n * @returns Promise resolving to current status\n */\n async getStatus(): Promise<GetStatusResponse> {\n if (!this.postMessageHandler) {\n return {\n auth: {\n isAuthenticated: false,\n user: undefined,\n },\n currentUrl: \"\",\n interaction: null,\n };\n }\n\n try {\n const response = await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"getStatus\",\n payload: {},\n });\n\n if (response.success && response.payload) {\n return response.payload as GetStatusResponse;\n }\n throw new Error(response.error);\n } catch (error) {\n const formattedError = formatError(error, \"Failed to get status\");\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Configure the component\n * @param config Component configuration\n * @returns Promise that resolves when configuration is applied\n */\n async configureApp(\n config: ConfigureApplicationPayload,\n ): Promise<ConfigureApplicationResponse> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n const response = await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"configureApp\",\n payload: config,\n });\n\n if (response.success && response.payload) {\n return response.payload as ConfigureApplicationResponse;\n }\n throw new Error(response.error);\n } catch (error) {\n const formattedError = formatError(error, \"Failed to configure app\");\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Configure the component\n * @param config Component configuration\n * @returns Promise that resolves when configuration is applied\n */\n async configure(config: ConfigurePayload): Promise<ConfigureResponse> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n CortiEmbedded.warnDeprecatedAPI(\"configure()\", \"configureApp()\");\n const response = await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"configure\",\n payload: config,\n });\n\n if (response.success && response.payload) {\n return response.payload as ConfigureResponse;\n }\n throw new Error(response.error);\n } catch (error) {\n const formattedError = formatError(\n error,\n \"Failed to configure component\",\n );\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Set one-shot interaction options for the embedded instance.\n * @param config Interaction/session-level options\n * @returns Promise that resolves when options are applied\n */\n async setInteractionOptions(\n config: SetInteractionOptionsPayload,\n ): Promise<void> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n const response = await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"setInteractionOptions\",\n payload: config,\n });\n\n if (response.success === false || response.error) {\n throw new Error(response.error);\n }\n } catch (error) {\n const formattedError = formatError(\n error,\n \"Failed to set interaction options\",\n );\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Set authentication credentials without triggering auth flow\n * @param credentials Authentication credentials to store\n * @returns Promise that resolves when credentials are set\n */\n async setCredentials(credentials: SetCredentialsPayload): Promise<void> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n if (!credentials.password) {\n throw new Error(\"Password is required\");\n }\n await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"setCredentials\",\n payload: credentials,\n });\n } catch (error) {\n const formattedError = formatError(error, \"Failed to set credentials\");\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Show the embedded UI\n */\n show(): void {\n this.visibility = \"visible\";\n }\n\n /**\n * Hide the embedded UI\n */\n hide(): void {\n this.visibility = \"hidden\";\n }\n\n /**\n * Get templates\n */\n async getTemplates(): Promise<GetTemplatesResponse> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n const response = await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"getTemplates\",\n });\n\n if (response.success && response.payload) {\n return response.payload as GetTemplatesResponse;\n }\n throw new Error(response.error);\n } catch (error) {\n const formattedError = formatError(error, \"Failed to get templates\");\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Check the current status of the iframe and PostMessageHandler\n * Useful for debugging\n * @deprecated Use getStatus() instead\n */\n getDebugStatus() {\n const iframe = this.getIframe();\n return {\n ready: iframe?.contentDocument?.readyState === \"complete\",\n iframeExists: !!iframe,\n iframeSrc: iframe?.src,\n iframeContentWindow: !!iframe?.contentWindow,\n iframeContentDocument: !!iframe?.contentDocument,\n iframeReadyState: iframe?.contentDocument?.readyState,\n postMessageHandlerExists: !!this.postMessageHandler,\n postMessageHandlerReady: this.postMessageHandler?.ready || false,\n baseURL: this.baseURL,\n };\n }\n\n render() {\n // Use the pre-validated normalizedBaseURL so render() never throws.\n // normalizedBaseURL is set in connectedCallback (before first render) and\n // kept up to date by updated() on each baseURL change.\n if (!this.normalizedBaseURL) {\n return html``;\n }\n\n return html`\n <iframe\n src=${buildEmbeddedUrl(this.normalizedBaseURL)}\n title=\"Corti Embedded UI\"\n sandbox=${IFRAME_SANDBOX_POLICY}\n allow=${this.getIframeAllowPolicy(this.normalizedBaseURL)}\n @load=${(event: Event) => this.handleIframeLoad(event)}\n @unload=${() => this.postMessageHandler?.destroy()}\n style=${this.visibility === \"hidden\"\n ? \"display: none;\"\n : \"display: block;\"}\n ></iframe>\n `;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CortiEmbedded.js","sourceRoot":"","sources":["../src/CortiEmbedded.ts"],"names":[],"mappings":";;;;;;AAEA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAuB,MAAM,KAAK,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAwB7C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EACL,kBAA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J,CAAC;IAED,MAAM;QACJ,oEAAoE;QACpE,0EAA0E;QAC1E,uDAAuD;QACvD,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC5B,OAAO,IAAI,CAAA,EAAE,CAAC;QAChB,CAAC;QAED,OAAO,IAAI,CAAA;;cAED,gBAAgB,CAAC,IAAI,CAAC,iBAAiB,CAAC;;kBAEpC,qBAAqB;gBACvB,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,iBAAiB,CAAC;gBACjD,CAAC,KAAY,EAAE,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC;kBAC5C,GAAG,EAAE,CAAC,IAAI,CAAC,kBAAkB,EAAE,OAAO,EAAE;gBAC1C,IAAI,CAAC,UAAU,KAAK,QAAQ;YAClC,CAAC,CAAC,gBAAgB;YAClB,CAAC,CAAC,iBAAiB;;KAExB,CAAC;IACJ,CAAC;;AA/qBM,oBAAM,GAAG,CAAC,UAAU,EAAE,eAAe,CAAC,AAAhC,CAAiC;AAG9C;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;iDACpB;AAGtB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8CACzB","sourcesContent":["/* eslint-disable no-console */\nimport type { Corti } from \"@corti/sdk\";\nimport { html, LitElement, type PropertyValues } from \"lit\";\nimport { property } from \"lit/decorators.js\";\nimport type {\n AuthResponse,\n AddFactsPayload,\n ConfigureApplicationPayload,\n ConfigureApplicationResponse,\n ConfigurePayload,\n ConfigureResponse,\n ConfigureSessionPayload,\n CreateInteractionPayload,\n CreateInteractionResponse,\n DeviceLinkTokenResponse,\n NavigatePayload,\n SetInteractionOptionsPayload,\n SetCredentialsPayload,\n CortiEmbeddedAPI,\n InteractionDetails,\n SessionConfig,\n User,\n GetStatusResponse,\n GetTemplatesResponse,\n KeycloakTokenResponse,\n ShowDeviceLinkQRResponse,\n} from \"./public-types.js\";\nimport { baseStyles } from \"./styles/base.js\";\nimport { containerStyles } from \"./styles/container-styles.js\";\nimport { validateAndNormalizeBaseURL } from \"./utils/baseUrl.js\";\nimport { buildEmbeddedUrl, isRealEmbeddedLoad } from \"./utils/embedUrl.js\";\nimport { formatError } from \"./utils/errorFormatter.js\";\nimport {\n PostMessageHandler,\n type PostMessageHandlerCallbacks,\n} from \"./utils/PostMessageHandler.js\";\n\nconst IFRAME_SANDBOX_POLICY =\n \"allow-forms allow-modals allow-scripts allow-same-origin\";\n\nconst DEPRECATION_TIMELINE_URL =\n \"https://docs.corti.ai/assistant/deprecation-timeline\";\n\nconst CONFIGURATION_MIGRATION_URL =\n \"https://docs.corti.ai/assistant/configuration-migration\";\n\nconst DEPRECATED_EVENT_SUBSCRIPTIONS = new Set([\n \"ready\",\n \"loaded\",\n \"recordingStarted\",\n \"recordingStopped\",\n \"documentGenerated\",\n \"documentUpdated\",\n \"documentSynced\",\n \"authChanged\",\n \"interactionCreated\",\n \"navigationChanged\",\n \"usage\",\n \"embedded-event\",\n]);\n\ntype DOMEventListener =\n | ((event: Event) => void)\n | { handleEvent(event: Event): void };\n\ntype DOMAddEventListenerOptions =\n | boolean\n | {\n capture?: boolean;\n once?: boolean;\n passive?: boolean;\n signal?: AbortSignal;\n };\n\nexport class CortiEmbedded extends LitElement implements CortiEmbeddedAPI {\n static styles = [baseStyles, containerStyles];\n\n @property({ type: String, reflect: true })\n visibility = \"hidden\";\n\n @property({ type: String, reflect: true })\n baseURL!: string;\n\n private postMessageHandler: PostMessageHandler | null = null;\n\n private normalizedBaseURL: string | null = null;\n\n private warnedDeprecatedEventSubscriptions = new Set<string>();\n\n addEventListener(\n type: string,\n callback: DOMEventListener,\n options?: DOMAddEventListenerOptions,\n ): void {\n this.warnDeprecatedEventSubscription(type);\n super.addEventListener(type, callback, options);\n }\n\n private warnDeprecatedEventSubscription(eventName: string): void {\n if (\n !DEPRECATED_EVENT_SUBSCRIPTIONS.has(eventName) ||\n this.warnedDeprecatedEventSubscriptions.has(eventName)\n ) {\n return;\n }\n\n this.warnedDeprecatedEventSubscriptions.add(eventName);\n console.warn(\n `[Corti Embedded] The '${eventName}' event subscription is deprecated and will be removed in a future release. Subscribe to the canonical 'event' stream instead. See ${DEPRECATION_TIMELINE_URL}.`,\n );\n }\n\n // eslint-disable-next-line class-methods-use-this\n private getIframeAllowPolicy(normalizedBaseURL?: string | null): string {\n const permissionTarget = normalizedBaseURL\n ? new URL(normalizedBaseURL).origin\n : \"*\";\n\n return [\n `microphone ${permissionTarget}`,\n `camera ${permissionTarget}`,\n `device-capture ${permissionTarget}`,\n `display-capture ${permissionTarget}`,\n `clipboard-write ${permissionTarget}`,\n ].join(\"; \");\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n // Ensure baseURL is provided\n if (!this.baseURL) {\n this.dispatchErrorEvent({\n message: \"baseURL is required\",\n });\n return;\n }\n\n // Validate and normalize the initial baseURL early (fail fast)\n try {\n this.normalizedBaseURL = validateAndNormalizeBaseURL(this.baseURL);\n } catch (error) {\n this.dispatchErrorEvent({\n message: (error as Error).message || \"Invalid baseURL\",\n });\n // Dispatch the error event rather than throwing so consumers can handle it\n // via the 'error' event listener without wrapping connectedCallback in try/catch.\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n if (this.postMessageHandler) {\n this.postMessageHandler.destroy();\n this.postMessageHandler = null;\n }\n }\n\n private async setupPostMessageHandler() {\n // Prevent multiple setups\n if (this.postMessageHandler) {\n return;\n }\n\n const iframe = this.getIframe();\n\n if (iframe?.contentWindow) {\n const callbacks: PostMessageHandlerCallbacks = {\n onEvent: event => {\n this.dispatchEmbeddedEvent(event.name, event.payload);\n },\n onError: error => {\n this.dispatchErrorEvent(error);\n },\n };\n\n this.postMessageHandler = new PostMessageHandler(iframe, callbacks);\n } else {\n this.dispatchErrorEvent({\n message: \"No iframe or contentWindow available\",\n });\n }\n }\n\n private dispatchPublicEvent(event: string, data: unknown) {\n this.dispatchEvent(new CustomEvent(event, { detail: data }));\n }\n\n private dispatchEmbeddedEvent(rawEventName: string, payload: unknown) {\n if (rawEventName === \"ready\" || rawEventName === \"loaded\") return;\n // Pass all other events through as raw DOM events for direct listeners.\n this.dispatchPublicEvent(rawEventName, payload);\n\n // Forward supported embedded events through the generic 'event' stream so\n // consumers can observe them without subscribing to each raw event name.\n this.dispatchPublicEvent(\"event\", {\n name: rawEventName,\n payload,\n });\n\n // Also emit the legacy 'embedded-event' stream for backward compatibility.\n // This allows existing integrations listening for 'embedded-event' to continue\n // working while newer consumers can use the 'event' stream.\n this.dispatchPublicEvent(\"embedded-event\", {\n name: rawEventName,\n payload,\n });\n }\n\n private dispatchErrorEvent(error: {\n message: string;\n code?: string;\n details?: unknown;\n }) {\n this.dispatchPublicEvent(\"error\", error);\n }\n\n private static warnDeprecatedAPI(\n methodName: string,\n replacement: string,\n ): void {\n console.warn(\n `[Corti Embedded] ${methodName} is deprecated and will be removed in a future release. Use ${replacement} instead. See ${CONFIGURATION_MIGRATION_URL} and ${DEPRECATION_TIMELINE_URL}.`,\n );\n }\n\n private isRealIframeLoad(iframe: HTMLIFrameElement): boolean {\n const src = iframe.getAttribute(\"src\") || \"\";\n if (!this.normalizedBaseURL) return false;\n return isRealEmbeddedLoad(src, this.normalizedBaseURL);\n }\n\n private async handleIframeLoad(event: Event) {\n const iframe = event.target as HTMLIFrameElement | null;\n if (!iframe) {\n return;\n }\n // Only initialize on real URL load, ignore about:blank\n if (!this.isRealIframeLoad(iframe)) {\n return;\n }\n try {\n await this.setupPostMessageHandler();\n } catch (error) {\n this.dispatchErrorEvent({\n message: `Failed to setup PostMessageHandler on iframe load: ${error}`,\n });\n }\n }\n\n private getIframe(): HTMLIFrameElement | null {\n return this.shadowRoot?.querySelector(\"iframe\") || null;\n }\n\n protected updated(changedProps: PropertyValues) {\n super.updated(changedProps);\n if (changedProps.has(\"baseURL\")) {\n // Tear down the existing handler; the new one is created in handleIframeLoad\n if (this.postMessageHandler) {\n this.postMessageHandler.destroy();\n this.postMessageHandler = null;\n }\n\n // Validate the new URL\n try {\n this.normalizedBaseURL = validateAndNormalizeBaseURL(this.baseURL);\n } catch (error) {\n this.normalizedBaseURL = null;\n const iframe = this.getIframe();\n if (iframe) {\n iframe.setAttribute(\"src\", \"about:blank\");\n }\n this.dispatchErrorEvent({\n message: (error as Error).message || \"Invalid baseURL\",\n });\n return;\n }\n\n // Update the iframe to the new URL\n const iframe = this.getIframe();\n if (iframe) {\n const expected = buildEmbeddedUrl(this.normalizedBaseURL);\n iframe.setAttribute(\"allow\", this.getIframeAllowPolicy(expected));\n if (iframe.getAttribute(\"src\") !== expected) {\n iframe.setAttribute(\"src\", expected);\n }\n }\n }\n }\n\n // Public API Implementation\n\n /**\n * Authenticate with the Corti system\n * @param credentials Authentication credentials\n * @returns Promise resolving to user information\n */\n async auth(credentials: KeycloakTokenResponse): Promise<User> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n const payload: KeycloakTokenResponse = {\n access_token: credentials.access_token,\n token_type: credentials.token_type,\n expires_at: credentials.expires_at,\n expires_in: credentials.expires_in,\n refresh_expires_in: credentials.refresh_expires_in,\n refresh_token: credentials.refresh_token,\n id_token: credentials.id_token,\n \"not-before-policy\": credentials[\"not-before-policy\"],\n session_state: credentials.session_state,\n scope: credentials.scope,\n profile: credentials.profile,\n };\n\n const response = await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"auth\",\n payload,\n });\n\n if (response.success && response.payload) {\n return (response.payload as AuthResponse).user;\n }\n throw new Error(response.error);\n } catch (error) {\n const formattedError = formatError(error, \"Authentication failed\");\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Create a new interaction\n * @param encounter Encounter request data\n * @returns Promise resolving to interaction details\n */\n async createInteraction(\n encounter: CreateInteractionPayload,\n ): Promise<InteractionDetails> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n const response = await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"createInteraction\",\n payload: encounter,\n });\n\n if (response.success && response.payload) {\n const result = response.payload as CreateInteractionResponse;\n return {\n id: result.id,\n createdAt: result.createdAt,\n };\n }\n throw new Error(response.error);\n } catch (error) {\n const formattedError = formatError(error, \"Failed to create interaction\");\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Configure the current session\n * @param config Session configuration\n * @returns Promise that resolves when configuration is complete\n */\n async configureSession(config: SessionConfig): Promise<void> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n CortiEmbedded.warnDeprecatedAPI(\n \"configureSession()\",\n \"setInteractionOptions()\",\n );\n const payload: ConfigureSessionPayload = {\n defaultLanguage: config.defaultLanguage,\n defaultOutputLanguage: config.defaultOutputLanguage,\n defaultTemplateKey: config.defaultTemplateKey,\n defaultMode: config.defaultMode,\n };\n\n await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"configureSession\",\n payload,\n });\n } catch (error) {\n const formattedError = formatError(error, \"Failed to configure session\");\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Add facts to the current session\n * @param facts Array of facts to add\n * @returns Promise that resolves when facts are added\n */\n async addFacts(facts: Corti.FactsCreateInput[]): Promise<void> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n const payload: AddFactsPayload = { facts };\n await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"addFacts\",\n payload,\n });\n } catch (error) {\n const formattedError = formatError(error, \"Failed to add facts\");\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Navigate to a specific path within the embedded UI\n * @param payload Navigation request payload or legacy path string\n * @returns Promise that resolves when navigation is complete\n */\n async navigate(payload: NavigatePayload | string): Promise<void> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n const normalizedPayload: NavigatePayload =\n typeof payload === \"string\" ? { path: payload } : payload;\n await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"navigate\",\n payload: normalizedPayload,\n });\n } catch (error) {\n const formattedError = formatError(error, \"Failed to navigate\");\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Start recording\n * @returns Promise that resolves when recording starts\n */\n async startRecording(): Promise<void> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"startRecording\",\n payload: {},\n });\n } catch (error) {\n const formattedError = formatError(error, \"Failed to start recording\");\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Stop recording\n * @returns Promise that resolves when recording stops\n */\n async stopRecording(): Promise<void> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"stopRecording\",\n payload: {},\n });\n } catch (error) {\n const formattedError = formatError(error, \"Failed to stop recording\");\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Get current component status\n * @returns Promise resolving to current status\n */\n async getStatus(): Promise<GetStatusResponse> {\n if (!this.postMessageHandler) {\n return {\n auth: {\n isAuthenticated: false,\n user: undefined,\n },\n currentUrl: \"\",\n interaction: null,\n };\n }\n\n try {\n const response = await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"getStatus\",\n payload: {},\n });\n\n if (response.success && response.payload) {\n return response.payload as GetStatusResponse;\n }\n throw new Error(response.error);\n } catch (error) {\n const formattedError = formatError(error, \"Failed to get status\");\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Configure the component\n * @param config Component configuration\n * @returns Promise that resolves when configuration is applied\n */\n async configureApp(\n config: ConfigureApplicationPayload,\n ): Promise<ConfigureApplicationResponse> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n const response = await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"configureApp\",\n payload: config,\n });\n\n if (response.success && response.payload) {\n return response.payload as ConfigureApplicationResponse;\n }\n throw new Error(response.error);\n } catch (error) {\n const formattedError = formatError(error, \"Failed to configure app\");\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Configure the component\n * @param config Component configuration\n * @returns Promise that resolves when configuration is applied\n */\n async configure(config: ConfigurePayload): Promise<ConfigureResponse> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n CortiEmbedded.warnDeprecatedAPI(\"configure()\", \"configureApp()\");\n const response = await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"configure\",\n payload: config,\n });\n\n if (response.success && response.payload) {\n return response.payload as ConfigureResponse;\n }\n throw new Error(response.error);\n } catch (error) {\n const formattedError = formatError(\n error,\n \"Failed to configure component\",\n );\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Set one-shot interaction options for the embedded instance.\n * @param config Interaction/session-level options\n * @returns Promise that resolves when options are applied\n */\n async setInteractionOptions(\n config: SetInteractionOptionsPayload,\n ): Promise<void> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n const response = await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"setInteractionOptions\",\n payload: config,\n });\n\n if (response.success === false || response.error) {\n throw new Error(response.error);\n }\n } catch (error) {\n const formattedError = formatError(\n error,\n \"Failed to set interaction options\",\n );\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Set authentication credentials without triggering auth flow\n * @param credentials Authentication credentials to store\n * @returns Promise that resolves when credentials are set\n */\n async setCredentials(credentials: SetCredentialsPayload): Promise<void> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n if (!credentials.password) {\n throw new Error(\"Password is required\");\n }\n await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"setCredentials\",\n payload: credentials,\n });\n } catch (error) {\n const formattedError = formatError(error, \"Failed to set credentials\");\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Show the embedded UI\n */\n show(): void {\n this.visibility = \"visible\";\n }\n\n /**\n * Hide the embedded UI\n */\n hide(): void {\n this.visibility = \"hidden\";\n }\n\n /**\n * Get templates\n */\n async getTemplates(): Promise<GetTemplatesResponse> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n const response = await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"getTemplates\",\n });\n\n if (response.success && response.payload) {\n return response.payload as GetTemplatesResponse;\n }\n throw new Error(response.error);\n } catch (error) {\n const formattedError = formatError(error, \"Failed to get templates\");\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Show the device-link QR code in the embedded UI\n * @param payload Device-link token response to render as a QR code\n * @returns Promise resolving to the rendered QR code state\n */\n async showDeviceLinkQR(\n payload: DeviceLinkTokenResponse,\n ): Promise<ShowDeviceLinkQRResponse> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n const response = await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"showDeviceLinkQR\",\n payload,\n });\n\n if (response.success && response.payload) {\n return response.payload as ShowDeviceLinkQRResponse;\n }\n throw new Error(response.error);\n } catch (error) {\n const formattedError = formatError(\n error,\n \"Failed to show device link QR\",\n );\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Check the current status of the iframe and PostMessageHandler\n * Useful for debugging\n * @deprecated Use getStatus() instead\n */\n getDebugStatus() {\n const iframe = this.getIframe();\n return {\n ready: iframe?.contentDocument?.readyState === \"complete\",\n iframeExists: !!iframe,\n iframeSrc: iframe?.src,\n iframeContentWindow: !!iframe?.contentWindow,\n iframeContentDocument: !!iframe?.contentDocument,\n iframeReadyState: iframe?.contentDocument?.readyState,\n postMessageHandlerExists: !!this.postMessageHandler,\n postMessageHandlerReady: this.postMessageHandler?.ready || false,\n baseURL: this.baseURL,\n };\n }\n\n render() {\n // Use the pre-validated normalizedBaseURL so render() never throws.\n // normalizedBaseURL is set in connectedCallback (before first render) and\n // kept up to date by updated() on each baseURL change.\n if (!this.normalizedBaseURL) {\n return html``;\n }\n\n return html`\n <iframe\n src=${buildEmbeddedUrl(this.normalizedBaseURL)}\n title=\"Corti Embedded UI\"\n sandbox=${IFRAME_SANDBOX_POLICY}\n allow=${this.getIframeAllowPolicy(this.normalizedBaseURL)}\n @load=${(event: Event) => this.handleIframeLoad(event)}\n @unload=${() => this.postMessageHandler?.destroy()}\n style=${this.visibility === \"hidden\"\n ? \"display: none;\"\n : \"display: block;\"}\n ></iframe>\n `;\n }\n}\n"]}
|
package/dist/bundle.js
CHANGED
|
@@ -1537,6 +1537,31 @@ var CortiEmbedded = class _CortiEmbedded extends i4 {
|
|
|
1537
1537
|
throw new Error(JSON.stringify(formattedError));
|
|
1538
1538
|
}
|
|
1539
1539
|
}
|
|
1540
|
+
/**
|
|
1541
|
+
* Show the device-link QR code in the embedded UI
|
|
1542
|
+
* @param payload Device-link token response to render as a QR code
|
|
1543
|
+
* @returns Promise resolving to the rendered QR code state
|
|
1544
|
+
*/
|
|
1545
|
+
async showDeviceLinkQR(payload) {
|
|
1546
|
+
if (!this.postMessageHandler) {
|
|
1547
|
+
throw new Error("Component not ready");
|
|
1548
|
+
}
|
|
1549
|
+
try {
|
|
1550
|
+
const response = await this.postMessageHandler.postMessage({
|
|
1551
|
+
type: "CORTI_EMBEDDED",
|
|
1552
|
+
version: "v1",
|
|
1553
|
+
action: "showDeviceLinkQR",
|
|
1554
|
+
payload
|
|
1555
|
+
});
|
|
1556
|
+
if (response.success && response.payload) {
|
|
1557
|
+
return response.payload;
|
|
1558
|
+
}
|
|
1559
|
+
throw new Error(response.error);
|
|
1560
|
+
} catch (error) {
|
|
1561
|
+
const formattedError = formatError(error, "Failed to show device link QR");
|
|
1562
|
+
throw new Error(JSON.stringify(formattedError));
|
|
1563
|
+
}
|
|
1564
|
+
}
|
|
1540
1565
|
/**
|
|
1541
1566
|
* Check the current status of the iframe and PostMessageHandler
|
|
1542
1567
|
* Useful for debugging
|
|
@@ -1722,6 +1747,7 @@ function useCortiEmbeddedApi(ref) {
|
|
|
1722
1747
|
setInteractionOptions: (...args) => getInstance().setInteractionOptions(...args),
|
|
1723
1748
|
getTemplates: (...args) => getInstance().getTemplates(...args),
|
|
1724
1749
|
setCredentials: (...args) => getInstance().setCredentials(...args),
|
|
1750
|
+
showDeviceLinkQR: (...args) => getInstance().showDeviceLinkQR(...args),
|
|
1725
1751
|
show: (...args) => getInstance().show(...args),
|
|
1726
1752
|
hide: (...args) => getInstance().hide(...args)
|
|
1727
1753
|
}), [getInstance]);
|
package/dist/public-types.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { ConfigureAppPayload as GeneratedConfigureApplicationPayload, ConfigureFeaturesConfig, ConfigurePayload } from "./types/config.js";
|
|
2
2
|
import type { AuthChangedEventPayload, DocumentEventPayload, ErrorEventPayload, InteractionCreatedEventPayload, NavigationChangedEventPayload, UsageEventPayload } from "./types/events.js";
|
|
3
|
-
import type { AddFactsPayload, ConfigureSessionPayload, CreateInteractionPayload, Fact, KeycloakTokenResponse, NavigatePayload, SetCredentialsPayload, SetInteractionOptionsPayload } from "./types/payloads.js";
|
|
3
|
+
import type { AddFactsPayload, ConfigureSessionPayload, CreateInteractionPayload, DeviceLinkTokenResponse, Fact, KeycloakTokenResponse, NavigatePayload, SetCredentialsPayload, SetInteractionOptionsPayload } from "./types/payloads.js";
|
|
4
4
|
import type { DefaultMode } from "./types/protocol.js";
|
|
5
|
-
import type { AuthResponse, ConfigureAppResponse as GeneratedConfigureApplicationResponse, ConfigureResponse, CreateInteractionResponse, GetStatusResponse, GetTemplatesResponse } from "./types/responses.js";
|
|
5
|
+
import type { AuthResponse, ConfigureAppResponse as GeneratedConfigureApplicationResponse, ConfigureResponse, CreateInteractionResponse, GetStatusResponse, GetTemplatesResponse, ShowDeviceLinkQRResponse } from "./types/responses.js";
|
|
6
6
|
export type { AppearanceConfig, ConfigureFeaturesConfig, ConfigurePayload, LocaleConfig, NetworkConfig, UIConfig, } from "./types/config.js";
|
|
7
7
|
export type { AuthChangedEventPayload, DocumentEventPayload, ErrorEventPayload, InteractionCreatedEventPayload, NavigationChangedEventPayload, UsageEventPayload, } from "./types/events.js";
|
|
8
|
-
export type { AddFactsPayload, ConfigureSessionPayload, CreateInteractionPayload, Fact, KeycloakTokenResponse, NavigatePayload, SetCredentialsPayload, SetInteractionOptionsPayload, } from "./types/payloads.js";
|
|
8
|
+
export type { AddFactsPayload, ConfigureSessionPayload, CreateInteractionPayload, DeviceLinkTokenResponse, Fact, KeycloakTokenResponse, NavigatePayload, SetCredentialsPayload, SetInteractionOptionsPayload, } from "./types/payloads.js";
|
|
9
9
|
export type { AnyDeprecatedEmbeddedEvent, AnyEmbeddedMessage, AnyEmbeddedRequest, AnyEmbeddedResponse, AnyEvent, APIVersion, BaseMessage, DeprecatedEmbeddedEvent, EmbeddedAction, EmbeddedEventMessage, EmbeddedRequest, EmbeddedResponse, MessageType, } from "./types/protocol.js";
|
|
10
|
-
export type { AuthResponse, ConfigureResponse, CreateInteractionResponse, EmbeddedTemplate, GetStatusResponse, GetTemplatesResponse, UserInfo, } from "./types/responses.js";
|
|
10
|
+
export type { AuthResponse, ConfigureResponse, CreateInteractionResponse, EmbeddedTemplate, GetStatusResponse, GetTemplatesResponse, ShowDeviceLinkQRResponse, UserInfo, } from "./types/responses.js";
|
|
11
11
|
/**
|
|
12
12
|
* @deprecated Use ConfigureFeaturesConfig instead.
|
|
13
13
|
*/
|
|
@@ -75,6 +75,7 @@ export interface CortiEmbeddedV1API {
|
|
|
75
75
|
setCredentials(payload: SetCredentialsPayload): Promise<void>;
|
|
76
76
|
getStatus(): Promise<GetStatusResponse>;
|
|
77
77
|
getTemplates(): Promise<GetTemplatesResponse>;
|
|
78
|
+
showDeviceLinkQR(payload: DeviceLinkTokenResponse): Promise<ShowDeviceLinkQRResponse>;
|
|
78
79
|
}
|
|
79
80
|
export interface CortiEmbeddedWindowAPI {
|
|
80
81
|
v1: CortiEmbeddedV1API;
|
|
@@ -159,9 +160,9 @@ export interface CortiEmbeddedAPI {
|
|
|
159
160
|
/**
|
|
160
161
|
* Set one-shot interaction options for the embedded instance.
|
|
161
162
|
*
|
|
162
|
-
* Each call
|
|
163
|
-
* instance. Omitted branches
|
|
164
|
-
* values from
|
|
163
|
+
* Each call applies the provided interaction-options branches to the current
|
|
164
|
+
* snapshot for the embedded instance. Omitted branches preserve their existing
|
|
165
|
+
* values from previous calls.
|
|
165
166
|
* @param config Interaction/session-level options
|
|
166
167
|
* @returns Promise that resolves when options are applied
|
|
167
168
|
*/
|
|
@@ -182,4 +183,10 @@ export interface CortiEmbeddedAPI {
|
|
|
182
183
|
* Hide the embedded UI
|
|
183
184
|
*/
|
|
184
185
|
hide(): void;
|
|
186
|
+
/**
|
|
187
|
+
* Show the device-link QR code in the embedded UI
|
|
188
|
+
* @param payload Device-link token response to render as a QR code
|
|
189
|
+
* @returns Promise resolving to the rendered QR code state
|
|
190
|
+
*/
|
|
191
|
+
showDeviceLinkQR(payload: DeviceLinkTokenResponse): Promise<ShowDeviceLinkQRResponse>;
|
|
185
192
|
}
|
package/dist/public-types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public-types.js","sourceRoot":"","sources":["../src/public-types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n
|
|
1
|
+
{"version":3,"file":"public-types.js","sourceRoot":"","sources":["../src/public-types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n ConfigureAppPayload as GeneratedConfigureApplicationPayload,\n ConfigureFeaturesConfig,\n ConfigurePayload,\n} from \"./types/config.js\";\nimport type {\n AuthChangedEventPayload,\n DocumentEventPayload,\n ErrorEventPayload,\n InteractionCreatedEventPayload,\n NavigationChangedEventPayload,\n UsageEventPayload,\n} from \"./types/events.js\";\nimport type {\n AddFactsPayload,\n ConfigureSessionPayload,\n CreateInteractionPayload,\n DeviceLinkTokenResponse,\n Fact,\n KeycloakTokenResponse,\n NavigatePayload,\n SetCredentialsPayload,\n SetInteractionOptionsPayload,\n} from \"./types/payloads.js\";\nimport type { DefaultMode } from \"./types/protocol.js\";\nimport type {\n AuthResponse,\n ConfigureAppResponse as GeneratedConfigureApplicationResponse,\n ConfigureResponse,\n CreateInteractionResponse,\n GetStatusResponse,\n GetTemplatesResponse,\n ShowDeviceLinkQRResponse,\n} from \"./types/responses.js\";\n\nexport type {\n AppearanceConfig,\n ConfigureFeaturesConfig,\n ConfigurePayload,\n LocaleConfig,\n NetworkConfig,\n UIConfig,\n} from \"./types/config.js\";\nexport type {\n AuthChangedEventPayload,\n DocumentEventPayload,\n ErrorEventPayload,\n InteractionCreatedEventPayload,\n NavigationChangedEventPayload,\n UsageEventPayload,\n} from \"./types/events.js\";\nexport type {\n AddFactsPayload,\n ConfigureSessionPayload,\n CreateInteractionPayload,\n DeviceLinkTokenResponse,\n Fact,\n KeycloakTokenResponse,\n NavigatePayload,\n SetCredentialsPayload,\n SetInteractionOptionsPayload,\n} from \"./types/payloads.js\";\nexport type {\n AnyDeprecatedEmbeddedEvent,\n AnyEmbeddedMessage,\n AnyEmbeddedRequest,\n AnyEmbeddedResponse,\n AnyEvent,\n APIVersion,\n BaseMessage,\n DeprecatedEmbeddedEvent,\n EmbeddedAction,\n EmbeddedEventMessage,\n EmbeddedRequest,\n EmbeddedResponse,\n MessageType,\n} from \"./types/protocol.js\";\nexport type {\n AuthResponse,\n ConfigureResponse,\n CreateInteractionResponse,\n EmbeddedTemplate,\n GetStatusResponse,\n GetTemplatesResponse,\n ShowDeviceLinkQRResponse,\n UserInfo,\n} from \"./types/responses.js\";\n\n/**\n * @deprecated Use ConfigureFeaturesConfig instead.\n */\nexport type FeaturesConfig = ConfigureFeaturesConfig;\n\n/**\n * @deprecated Use ConfigurePayload for configure() or ConfigureApplicationPayload for configureApp().\n */\nexport type ConfigureAppPayload = ConfigurePayload;\n\nexport type ConfigureApplicationPayload = GeneratedConfigureApplicationPayload;\n\n/**\n * @deprecated Use ConfigureResponse for configure() or ConfigureApplicationResponse for configureApp().\n */\nexport type ConfigureAppResponse = ConfigureResponse;\n\nexport type ConfigureApplicationResponse =\n GeneratedConfigureApplicationResponse;\n\n/**\n * User information returned from authentication\n */\nexport interface User {\n id: string;\n email: string;\n}\n\n/**\n * Details of a created interaction\n */\nexport interface InteractionDetails {\n id: string;\n createdAt: string;\n}\n\n/**\n * Session configuration options\n */\nexport interface SessionConfig {\n defaultLanguage?: string;\n defaultOutputLanguage?: string;\n defaultTemplateKey?: string;\n defaultMode?: DefaultMode;\n}\n\n/**\n * Event data types for component events\n */\nexport interface EmbeddedEventData {\n ready: undefined;\n \"auth-changed\": AuthChangedEventPayload;\n \"interaction-created\": InteractionCreatedEventPayload;\n \"recording-started\": undefined;\n \"recording-stopped\": undefined;\n \"document-generated\": DocumentEventPayload;\n \"document-updated\": DocumentEventPayload;\n \"document-synced\": DocumentEventPayload;\n \"navigation-changed\": NavigationChangedEventPayload;\n usage: UsageEventPayload;\n error: ErrorEventPayload;\n}\n\n// Window API Types\nexport interface CortiEmbeddedV1API {\n auth(payload: KeycloakTokenResponse): Promise<AuthResponse>;\n createInteraction(\n payload: CreateInteractionPayload,\n ): Promise<CreateInteractionResponse>;\n addFacts(payload: AddFactsPayload): Promise<void>;\n configureApp(\n payload: ConfigureApplicationPayload,\n ): Promise<ConfigureApplicationResponse>;\n configureSession(payload: ConfigureSessionPayload): Promise<void>;\n setInteractionOptions(payload: SetInteractionOptionsPayload): Promise<void>;\n configure(payload: ConfigurePayload): Promise<ConfigureResponse>;\n navigate(payload: NavigatePayload): Promise<void>;\n startRecording(): Promise<void>;\n stopRecording(): Promise<void>;\n setCredentials(payload: SetCredentialsPayload): Promise<void>;\n getStatus(): Promise<GetStatusResponse>;\n getTemplates(): Promise<GetTemplatesResponse>;\n showDeviceLinkQR(\n payload: DeviceLinkTokenResponse,\n ): Promise<ShowDeviceLinkQRResponse>;\n}\n\nexport interface CortiEmbeddedWindowAPI {\n v1: CortiEmbeddedV1API;\n}\n\ndeclare global {\n interface Window {\n CortiEmbedded?: CortiEmbeddedWindowAPI;\n }\n}\n\n/**\n * Event listener function type\n */\nexport type EventListener<T = unknown> = (data: T) => void;\n\n/**\n * Public API interface for the Corti Embedded component\n */\nexport interface CortiEmbeddedAPI {\n /**\n * Authenticate with the Corti system\n * @param credentials Authentication credentials\n * @returns Promise resolving to user information\n */\n auth(credentials: KeycloakTokenResponse): Promise<User>;\n\n /**\n * Create a new interaction\n * @param encounter Encounter request data\n * @returns Promise resolving to interaction details\n */\n createInteraction(\n encounter: CreateInteractionPayload,\n ): Promise<InteractionDetails>;\n\n /**\n * Configure the current session\n * @param config Session configuration\n * @returns Promise that resolves when configuration is complete\n * @deprecated Use setInteractionOptions() instead. See https://docs.corti.ai/assistant/deprecation-timeline.\n */\n configureSession(config: SessionConfig): Promise<void>;\n\n /**\n * Add facts to the current session\n * @param facts Array of facts to add\n * @returns Promise that resolves when facts are added\n */\n addFacts(facts: Fact[]): Promise<void>;\n\n /**\n * Navigate to a specific path within the embedded UI\n * @param payload Navigation request payload or legacy path string\n * @returns Promise that resolves when navigation is complete\n */\n navigate(payload: NavigatePayload | string): Promise<void>;\n\n /**\n * Start recording\n * @returns Promise that resolves when recording starts\n */\n startRecording(): Promise<void>;\n\n /**\n * Stop recording\n * @returns Promise that resolves when recording stops\n */\n stopRecording(): Promise<void>;\n\n /**\n * Get current component status\n * @returns Promise resolving to current status\n */\n getStatus(): Promise<GetStatusResponse>;\n\n /**\n * Get all templates available to the current user\n * @returns Promise resolving to list of templates\n */\n getTemplates(): Promise<GetTemplatesResponse>;\n\n /**\n * Configure the embedded application\n * @param config Application-level configuration\n * @returns Promise that resolves when configuration is applied\n */\n configureApp(\n config: ConfigureApplicationPayload,\n ): Promise<ConfigureApplicationResponse>;\n\n /**\n * Configure the application\n * @param config Application configuration\n * @returns Promise that resolves when configuration is applied\n * @deprecated Use configureApp() and setInteractionOptions() instead. See https://docs.corti.ai/assistant/deprecation-timeline.\n */\n configure(config: ConfigurePayload): Promise<ConfigureResponse>;\n\n /**\n * Set one-shot interaction options for the embedded instance.\n *\n * Each call applies the provided interaction-options branches to the current\n * snapshot for the embedded instance. Omitted branches preserve their existing\n * values from previous calls.\n * @param config Interaction/session-level options\n * @returns Promise that resolves when options are applied\n */\n setInteractionOptions(config: SetInteractionOptionsPayload): Promise<void>;\n\n /**\n * Set authentication credentials without triggering auth flow\n * @param credentials Authentication credentials to store\n * @returns Promise that resolves when credentials are set\n */\n setCredentials(credentials: { password: string }): Promise<void>;\n\n /**\n * Show the embedded UI\n */\n show(): void;\n\n /**\n * Hide the embedded UI\n */\n hide(): void;\n\n /**\n * Show the device-link QR code in the embedded UI\n * @param payload Device-link token response to render as a QR code\n * @returns Promise resolving to the rendered QR code state\n */\n showDeviceLinkQR(\n payload: DeviceLinkTokenResponse,\n ): Promise<ShowDeviceLinkQRResponse>;\n}\n"]}
|
|
@@ -51,6 +51,7 @@ export interface UseCortiEmbeddedApiResult {
|
|
|
51
51
|
setInteractionOptions: (...args: Parameters<CortiEmbeddedReactRef["setInteractionOptions"]>) => ReturnType<CortiEmbeddedReactRef["setInteractionOptions"]>;
|
|
52
52
|
getTemplates: (...args: Parameters<CortiEmbeddedReactRef["getTemplates"]>) => ReturnType<CortiEmbeddedReactRef["getTemplates"]>;
|
|
53
53
|
setCredentials: (...args: Parameters<CortiEmbeddedReactRef["setCredentials"]>) => ReturnType<CortiEmbeddedReactRef["setCredentials"]>;
|
|
54
|
+
showDeviceLinkQR: (...args: Parameters<CortiEmbeddedReactRef["showDeviceLinkQR"]>) => ReturnType<CortiEmbeddedReactRef["showDeviceLinkQR"]>;
|
|
54
55
|
show: (...args: Parameters<CortiEmbeddedReactRef["show"]>) => ReturnType<CortiEmbeddedReactRef["show"]>;
|
|
55
56
|
hide: (...args: Parameters<CortiEmbeddedReactRef["hide"]>) => ReturnType<CortiEmbeddedReactRef["hide"]>;
|
|
56
57
|
}
|
|
@@ -149,6 +149,7 @@ export function useCortiEmbeddedApi(ref) {
|
|
|
149
149
|
setInteractionOptions: (...args) => getInstance().setInteractionOptions(...args),
|
|
150
150
|
getTemplates: (...args) => getInstance().getTemplates(...args),
|
|
151
151
|
setCredentials: (...args) => getInstance().setCredentials(...args),
|
|
152
|
+
showDeviceLinkQR: (...args) => getInstance().showDeviceLinkQR(...args),
|
|
152
153
|
show: (...args) => getInstance().show(...args),
|
|
153
154
|
hide: (...args) => getInstance().hide(...args),
|
|
154
155
|
}), [getInstance]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CortiEmbeddedReact.js","sourceRoot":"","sources":["../../src/react/CortiEmbeddedReact.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,sBAAsB,CAAC;AAmC9B,sBAAsB;AACtB,cAAc,oBAAoB,CAAC;AAEnC,0EAA0E;AAC1E,4EAA4E;AAC5E,iEAAiE;AACjE,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC,UAAU,CAIhD,CACE,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,EACpE,YAAY,EACZ,EAAE;IACF,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAA+B,IAAI,CAAC,CAAC;IACrE,MAAM,kBAAkB,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CA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E,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC;QAClE,aAAa,EAAE,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,WAAW,EAAE,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC;QAChE,SAAS,EAAE,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,WAAW,EAAE,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;QACxD,YAAY,EAAE,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,WAAW,EAAE,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC;QAC9D,SAAS,EAAE,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,WAAW,EAAE,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;QACxD,qBAAqB,EAAE,CAAC,GAAG,IAAI,EAAE,EAAE,CACjC,WAAW,EAAE,CAAC,qBAAqB,CAAC,GAAG,IAAI,CAAC;QAC9C,YAAY,EAAE,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,WAAW,EAAE,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC;QAC9D,cAAc,EAAE,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,WAAW,EAAE,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC;QAClE,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;QAC9C,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;KAC/C,CAAC,EACF,CAAC,WAAW,CAAC,CACd,CAAC;AACJ,CAAC","sourcesContent":["import * as React from \"react\";\nimport \"../corti-embedded.js\";\nimport type { CortiEmbedded } from \"../CortiEmbedded.js\";\nimport type { CortiEmbeddedAPI } from \"../public-types.js\";\n\nexport interface CortiEmbeddedEventDetail {\n name: string;\n payload: unknown;\n}\n\nexport type CortiEmbeddedEvent = CustomEvent<CortiEmbeddedEventDetail>;\nexport type CortiEmbeddedReadyEvent = CustomEvent<Record<string, unknown>>;\n\nexport interface CortiEmbeddedErrorDetail {\n message: string;\n code?: string;\n details?: unknown;\n}\n\n// Props interface\nexport interface CortiEmbeddedReactProps {\n baseURL: string;\n visibility?: \"visible\" | \"hidden\";\n\n // Event handlers receive the raw CustomEvent emitted by the custom element.\n onEvent?: (event: CortiEmbeddedEvent) => void;\n onReady?: (event: CortiEmbeddedReadyEvent) => void;\n onError?: (event: CustomEvent<CortiEmbeddedErrorDetail>) => void;\n\n // Additional props\n className?: string;\n style?: React.CSSProperties;\n}\n\nexport type CortiEmbeddedReactRef = CortiEmbedded & CortiEmbeddedAPI;\n\n// Export public types\nexport * from \"../public-types.js\";\n\n// Renders the custom element directly so React sets the ref to the actual\n// CortiEmbedded DOM instance. This avoids the @lit/react wrapper chain that\n// was preventing the ref from reaching the DOM node in React 19.\nexport const CortiEmbeddedReact = React.forwardRef<\n CortiEmbeddedReactRef,\n CortiEmbeddedReactProps\n>(\n (\n { onEvent, onReady, onError, baseURL, visibility, className, style },\n forwardedRef,\n ) => {\n const internalRef = React.useRef<CortiEmbeddedReactRef | null>(null);\n const hasEmittedReadyRef = React.useRef(false);\n\n // \"Latest ref\" pattern: update on every render so handlers are always\n // current without re-attaching event listeners.\n const onEventRef = React.useRef(onEvent);\n const onReadyRef = React.useRef(onReady);\n const onErrorRef = React.useRef(onError);\n onEventRef.current = onEvent;\n onReadyRef.current = onReady;\n onErrorRef.current = onError;\n\n // Expose the DOM element to the consumer's forwarded ref. Native element\n // refs are set during React's mutation phase, before layout effects run,\n // so internalRef.current is always populated when this executes.\n React.useImperativeHandle(forwardedRef, () => internalRef.current!, []);\n\n // Keep LitElement reactive properties in sync with React props.\n React.useLayoutEffect(() => {\n if (internalRef.current) internalRef.current.baseURL = baseURL;\n }, [baseURL]);\n\n React.useLayoutEffect(() => {\n if (internalRef.current == null || visibility === undefined) return;\n internalRef.current.visibility = visibility;\n }, [visibility]);\n\n // Attach DOM event listeners once on mount. The latest-ref pattern above\n // ensures handlers always call the current prop without re-attaching.\n React.useEffect(() => {\n const el = internalRef.current;\n if (!el) return undefined;\n\n const handleEvent = (e: Event) =>\n onEventRef.current?.(e as CortiEmbeddedEvent);\n const handleReady = (e: Event) => {\n if (hasEmittedReadyRef.current) return;\n hasEmittedReadyRef.current = true;\n onReadyRef.current?.(e as CortiEmbeddedReadyEvent);\n };\n const handleError = (e: Event) =>\n onErrorRef.current?.(e as CustomEvent<CortiEmbeddedErrorDetail>);\n\n el.addEventListener(\"event\", handleEvent);\n el.addEventListener(\"embedded.ready\", handleReady);\n el.addEventListener(\"error\", handleError);\n return () => {\n el.removeEventListener(\"event\", handleEvent);\n el.removeEventListener(\"embedded.ready\", handleReady);\n el.removeEventListener(\"error\", handleError);\n };\n }, []);\n\n return React.createElement(\"corti-embedded\", {\n ref: internalRef,\n baseurl: baseURL,\n ...(visibility !== undefined ? { visibility } : {}),\n ...(className !== undefined ? { className } : {}),\n style,\n });\n },\n);\n\nCortiEmbeddedReact.displayName = \"CortiEmbeddedReact\";\n\nexport interface UseCortiEmbeddedStatusOptions {\n enabled?: boolean;\n onError?: (error: unknown) => void;\n shouldRefreshOnEvent?: (event: CortiEmbeddedEventDetail) => boolean;\n}\n\nexport interface UseCortiEmbeddedStatusResult {\n status: Awaited<ReturnType<CortiEmbeddedReactRef[\"getStatus\"]>> | null;\n isLoading: boolean;\n error: unknown;\n lastEvent: CortiEmbeddedEventDetail | null;\n}\n\nexport function useCortiEmbeddedStatus(\n ref: React.RefObject<CortiEmbeddedReactRef | null>,\n options: UseCortiEmbeddedStatusOptions = {},\n): UseCortiEmbeddedStatusResult {\n const {\n enabled = true,\n onError,\n shouldRefreshOnEvent = event => {\n const normalized = event.name.toLowerCase();\n if (normalized.includes(\"getstatus\")) return false;\n if (normalized.includes(\"statusreturned\")) return false;\n return true;\n },\n } = options;\n const [status, setStatus] =\n React.useState<UseCortiEmbeddedStatusResult[\"status\"]>(null);\n const [isLoading, setIsLoading] = React.useState(false);\n const [error, setError] = React.useState<unknown>(null);\n const [lastEvent, setLastEvent] =\n React.useState<UseCortiEmbeddedStatusResult[\"lastEvent\"]>(null);\n const onErrorRef = React.useRef(onError);\n const shouldRefreshOnEventRef = React.useRef(shouldRefreshOnEvent);\n const isRefreshingRef = React.useRef(false);\n\n React.useEffect(() => {\n onErrorRef.current = onError;\n }, [onError]);\n\n React.useEffect(() => {\n shouldRefreshOnEventRef.current = shouldRefreshOnEvent;\n }, [shouldRefreshOnEvent]);\n\n const refresh = React.useCallback(async () => {\n if (!enabled || !ref.current || isRefreshingRef.current) return;\n isRefreshingRef.current = true;\n setIsLoading(true);\n try {\n const nextStatus = await ref.current.getStatus();\n setStatus(nextStatus);\n setError(null);\n } catch (refreshError) {\n setError(refreshError);\n onErrorRef.current?.(refreshError);\n } finally {\n setIsLoading(false);\n isRefreshingRef.current = false;\n }\n }, [enabled, ref]);\n\n React.useEffect(() => {\n if (!enabled || !ref.current) return undefined;\n\n const target = ref.current;\n const handleEvent = (event: Event) => {\n const { detail } = event as CustomEvent<CortiEmbeddedEventDetail>;\n setLastEvent(detail);\n if (!shouldRefreshOnEventRef.current(detail)) return;\n if (isRefreshingRef.current) return;\n refresh();\n };\n\n target.addEventListener(\"event\", handleEvent);\n return () => target.removeEventListener(\"event\", handleEvent);\n }, [enabled, ref, refresh]);\n\n return {\n status,\n isLoading,\n error,\n lastEvent,\n };\n}\n\nexport interface UseCortiEmbeddedApiResult {\n auth: (\n ...args: Parameters<CortiEmbeddedReactRef[\"auth\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"auth\"]>;\n createInteraction: (\n ...args: Parameters<CortiEmbeddedReactRef[\"createInteraction\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"createInteraction\"]>;\n configureSession: (\n ...args: Parameters<CortiEmbeddedReactRef[\"configureSession\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"configureSession\"]>;\n addFacts: (\n ...args: Parameters<CortiEmbeddedReactRef[\"addFacts\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"addFacts\"]>;\n navigate: (\n ...args: Parameters<CortiEmbeddedReactRef[\"navigate\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"navigate\"]>;\n startRecording: (\n ...args: Parameters<CortiEmbeddedReactRef[\"startRecording\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"startRecording\"]>;\n stopRecording: (\n ...args: Parameters<CortiEmbeddedReactRef[\"stopRecording\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"stopRecording\"]>;\n getStatus: (\n ...args: Parameters<CortiEmbeddedReactRef[\"getStatus\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"getStatus\"]>;\n configureApp: (\n ...args: Parameters<CortiEmbeddedReactRef[\"configureApp\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"configureApp\"]>;\n configure: (\n ...args: Parameters<CortiEmbeddedReactRef[\"configure\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"configure\"]>;\n setInteractionOptions: (\n ...args: Parameters<CortiEmbeddedReactRef[\"setInteractionOptions\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"setInteractionOptions\"]>;\n getTemplates: (\n ...args: Parameters<CortiEmbeddedReactRef[\"getTemplates\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"getTemplates\"]>;\n setCredentials: (\n ...args: Parameters<CortiEmbeddedReactRef[\"setCredentials\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"setCredentials\"]>;\n show: (\n ...args: Parameters<CortiEmbeddedReactRef[\"show\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"show\"]>;\n hide: (\n ...args: Parameters<CortiEmbeddedReactRef[\"hide\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"hide\"]>;\n}\n\nfunction getCortiEmbeddedInstanceFromRefOrThrow(\n ref: React.RefObject<CortiEmbeddedReactRef | null>,\n): CortiEmbeddedReactRef {\n const instance = ref.current;\n if (!instance) {\n throw new Error(\n \"No active corti-embedded instance found for this ref. Mount <CortiEmbeddedReact ref={...} /> first.\",\n );\n }\n return instance;\n}\n\nexport function useCortiEmbeddedApi(\n ref: React.RefObject<CortiEmbeddedReactRef | null>,\n): UseCortiEmbeddedApiResult {\n const getInstance = React.useCallback(\n () => getCortiEmbeddedInstanceFromRefOrThrow(ref),\n [ref],\n );\n\n return React.useMemo(\n () => ({\n auth: (...args) => getInstance().auth(...args),\n createInteraction: (...args) => getInstance().createInteraction(...args),\n configureSession: (...args) => getInstance().configureSession(...args),\n addFacts: (...args) => getInstance().addFacts(...args),\n navigate: (...args) => getInstance().navigate(...args),\n startRecording: (...args) => getInstance().startRecording(...args),\n stopRecording: (...args) => getInstance().stopRecording(...args),\n getStatus: (...args) => getInstance().getStatus(...args),\n configureApp: (...args) => getInstance().configureApp(...args),\n configure: (...args) => getInstance().configure(...args),\n setInteractionOptions: (...args) =>\n getInstance().setInteractionOptions(...args),\n getTemplates: (...args) => getInstance().getTemplates(...args),\n setCredentials: (...args) => getInstance().setCredentials(...args),\n show: (...args) => getInstance().show(...args),\n hide: (...args) => getInstance().hide(...args),\n }),\n [getInstance],\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CortiEmbeddedReact.js","sourceRoot":"","sources":["../../src/react/CortiEmbeddedReact.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,sBAAsB,CAAC;AAmC9B,sBAAsB;AACtB,cAAc,oBAAoB,CAAC;AAEnC,0EAA0E;AAC1E,4EAA4E;AAC5E,iEAAiE;AACjE,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC,UAAU,CAIhD,CACE,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,EACpE,YAAY,EACZ,EAAE;IACF,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAA+B,IAAI,CAAC,CA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../corti-embedded.js\";\nimport type { CortiEmbedded } from \"../CortiEmbedded.js\";\nimport type { CortiEmbeddedAPI } from \"../public-types.js\";\n\nexport interface CortiEmbeddedEventDetail {\n name: string;\n payload: unknown;\n}\n\nexport type CortiEmbeddedEvent = CustomEvent<CortiEmbeddedEventDetail>;\nexport type CortiEmbeddedReadyEvent = CustomEvent<Record<string, unknown>>;\n\nexport interface CortiEmbeddedErrorDetail {\n message: string;\n code?: string;\n details?: unknown;\n}\n\n// Props interface\nexport interface CortiEmbeddedReactProps {\n baseURL: string;\n visibility?: \"visible\" | \"hidden\";\n\n // Event handlers receive the raw CustomEvent emitted by the custom element.\n onEvent?: (event: CortiEmbeddedEvent) => void;\n onReady?: (event: CortiEmbeddedReadyEvent) => void;\n onError?: (event: CustomEvent<CortiEmbeddedErrorDetail>) => void;\n\n // Additional props\n className?: string;\n style?: React.CSSProperties;\n}\n\nexport type CortiEmbeddedReactRef = CortiEmbedded & CortiEmbeddedAPI;\n\n// Export public types\nexport * from \"../public-types.js\";\n\n// Renders the custom element directly so React sets the ref to the actual\n// CortiEmbedded DOM instance. This avoids the @lit/react wrapper chain that\n// was preventing the ref from reaching the DOM node in React 19.\nexport const CortiEmbeddedReact = React.forwardRef<\n CortiEmbeddedReactRef,\n CortiEmbeddedReactProps\n>(\n (\n { onEvent, onReady, onError, baseURL, visibility, className, style },\n forwardedRef,\n ) => {\n const internalRef = React.useRef<CortiEmbeddedReactRef | null>(null);\n const hasEmittedReadyRef = React.useRef(false);\n\n // \"Latest ref\" pattern: update on every render so handlers are always\n // current without re-attaching event listeners.\n const onEventRef = React.useRef(onEvent);\n const onReadyRef = React.useRef(onReady);\n const onErrorRef = React.useRef(onError);\n onEventRef.current = onEvent;\n onReadyRef.current = onReady;\n onErrorRef.current = onError;\n\n // Expose the DOM element to the consumer's forwarded ref. Native element\n // refs are set during React's mutation phase, before layout effects run,\n // so internalRef.current is always populated when this executes.\n React.useImperativeHandle(forwardedRef, () => internalRef.current!, []);\n\n // Keep LitElement reactive properties in sync with React props.\n React.useLayoutEffect(() => {\n if (internalRef.current) internalRef.current.baseURL = baseURL;\n }, [baseURL]);\n\n React.useLayoutEffect(() => {\n if (internalRef.current == null || visibility === undefined) return;\n internalRef.current.visibility = visibility;\n }, [visibility]);\n\n // Attach DOM event listeners once on mount. The latest-ref pattern above\n // ensures handlers always call the current prop without re-attaching.\n React.useEffect(() => {\n const el = internalRef.current;\n if (!el) return undefined;\n\n const handleEvent = (e: Event) =>\n onEventRef.current?.(e as CortiEmbeddedEvent);\n const handleReady = (e: Event) => {\n if (hasEmittedReadyRef.current) return;\n hasEmittedReadyRef.current = true;\n onReadyRef.current?.(e as CortiEmbeddedReadyEvent);\n };\n const handleError = (e: Event) =>\n onErrorRef.current?.(e as CustomEvent<CortiEmbeddedErrorDetail>);\n\n el.addEventListener(\"event\", handleEvent);\n el.addEventListener(\"embedded.ready\", handleReady);\n el.addEventListener(\"error\", handleError);\n return () => {\n el.removeEventListener(\"event\", handleEvent);\n el.removeEventListener(\"embedded.ready\", handleReady);\n el.removeEventListener(\"error\", handleError);\n };\n }, []);\n\n return React.createElement(\"corti-embedded\", {\n ref: internalRef,\n baseurl: baseURL,\n ...(visibility !== undefined ? { visibility } : {}),\n ...(className !== undefined ? { className } : {}),\n style,\n });\n },\n);\n\nCortiEmbeddedReact.displayName = \"CortiEmbeddedReact\";\n\nexport interface UseCortiEmbeddedStatusOptions {\n enabled?: boolean;\n onError?: (error: unknown) => void;\n shouldRefreshOnEvent?: (event: CortiEmbeddedEventDetail) => boolean;\n}\n\nexport interface UseCortiEmbeddedStatusResult {\n status: Awaited<ReturnType<CortiEmbeddedReactRef[\"getStatus\"]>> | null;\n isLoading: boolean;\n error: unknown;\n lastEvent: CortiEmbeddedEventDetail | null;\n}\n\nexport function useCortiEmbeddedStatus(\n ref: React.RefObject<CortiEmbeddedReactRef | null>,\n options: UseCortiEmbeddedStatusOptions = {},\n): UseCortiEmbeddedStatusResult {\n const {\n enabled = true,\n onError,\n shouldRefreshOnEvent = event => {\n const normalized = event.name.toLowerCase();\n if (normalized.includes(\"getstatus\")) return false;\n if (normalized.includes(\"statusreturned\")) return false;\n return true;\n },\n } = options;\n const [status, setStatus] =\n React.useState<UseCortiEmbeddedStatusResult[\"status\"]>(null);\n const [isLoading, setIsLoading] = React.useState(false);\n const [error, setError] = React.useState<unknown>(null);\n const [lastEvent, setLastEvent] =\n React.useState<UseCortiEmbeddedStatusResult[\"lastEvent\"]>(null);\n const onErrorRef = React.useRef(onError);\n const shouldRefreshOnEventRef = React.useRef(shouldRefreshOnEvent);\n const isRefreshingRef = React.useRef(false);\n\n React.useEffect(() => {\n onErrorRef.current = onError;\n }, [onError]);\n\n React.useEffect(() => {\n shouldRefreshOnEventRef.current = shouldRefreshOnEvent;\n }, [shouldRefreshOnEvent]);\n\n const refresh = React.useCallback(async () => {\n if (!enabled || !ref.current || isRefreshingRef.current) return;\n isRefreshingRef.current = true;\n setIsLoading(true);\n try {\n const nextStatus = await ref.current.getStatus();\n setStatus(nextStatus);\n setError(null);\n } catch (refreshError) {\n setError(refreshError);\n onErrorRef.current?.(refreshError);\n } finally {\n setIsLoading(false);\n isRefreshingRef.current = false;\n }\n }, [enabled, ref]);\n\n React.useEffect(() => {\n if (!enabled || !ref.current) return undefined;\n\n const target = ref.current;\n const handleEvent = (event: Event) => {\n const { detail } = event as CustomEvent<CortiEmbeddedEventDetail>;\n setLastEvent(detail);\n if (!shouldRefreshOnEventRef.current(detail)) return;\n if (isRefreshingRef.current) return;\n refresh();\n };\n\n target.addEventListener(\"event\", handleEvent);\n return () => target.removeEventListener(\"event\", handleEvent);\n }, [enabled, ref, refresh]);\n\n return {\n status,\n isLoading,\n error,\n lastEvent,\n };\n}\n\nexport interface UseCortiEmbeddedApiResult {\n auth: (\n ...args: Parameters<CortiEmbeddedReactRef[\"auth\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"auth\"]>;\n createInteraction: (\n ...args: Parameters<CortiEmbeddedReactRef[\"createInteraction\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"createInteraction\"]>;\n configureSession: (\n ...args: Parameters<CortiEmbeddedReactRef[\"configureSession\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"configureSession\"]>;\n addFacts: (\n ...args: Parameters<CortiEmbeddedReactRef[\"addFacts\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"addFacts\"]>;\n navigate: (\n ...args: Parameters<CortiEmbeddedReactRef[\"navigate\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"navigate\"]>;\n startRecording: (\n ...args: Parameters<CortiEmbeddedReactRef[\"startRecording\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"startRecording\"]>;\n stopRecording: (\n ...args: Parameters<CortiEmbeddedReactRef[\"stopRecording\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"stopRecording\"]>;\n getStatus: (\n ...args: Parameters<CortiEmbeddedReactRef[\"getStatus\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"getStatus\"]>;\n configureApp: (\n ...args: Parameters<CortiEmbeddedReactRef[\"configureApp\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"configureApp\"]>;\n configure: (\n ...args: Parameters<CortiEmbeddedReactRef[\"configure\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"configure\"]>;\n setInteractionOptions: (\n ...args: Parameters<CortiEmbeddedReactRef[\"setInteractionOptions\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"setInteractionOptions\"]>;\n getTemplates: (\n ...args: Parameters<CortiEmbeddedReactRef[\"getTemplates\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"getTemplates\"]>;\n setCredentials: (\n ...args: Parameters<CortiEmbeddedReactRef[\"setCredentials\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"setCredentials\"]>;\n showDeviceLinkQR: (\n ...args: Parameters<CortiEmbeddedReactRef[\"showDeviceLinkQR\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"showDeviceLinkQR\"]>;\n show: (\n ...args: Parameters<CortiEmbeddedReactRef[\"show\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"show\"]>;\n hide: (\n ...args: Parameters<CortiEmbeddedReactRef[\"hide\"]>\n ) => ReturnType<CortiEmbeddedReactRef[\"hide\"]>;\n}\n\nfunction getCortiEmbeddedInstanceFromRefOrThrow(\n ref: React.RefObject<CortiEmbeddedReactRef | null>,\n): CortiEmbeddedReactRef {\n const instance = ref.current;\n if (!instance) {\n throw new Error(\n \"No active corti-embedded instance found for this ref. Mount <CortiEmbeddedReact ref={...} /> first.\",\n );\n }\n return instance;\n}\n\nexport function useCortiEmbeddedApi(\n ref: React.RefObject<CortiEmbeddedReactRef | null>,\n): UseCortiEmbeddedApiResult {\n const getInstance = React.useCallback(\n () => getCortiEmbeddedInstanceFromRefOrThrow(ref),\n [ref],\n );\n\n return React.useMemo(\n () => ({\n auth: (...args) => getInstance().auth(...args),\n createInteraction: (...args) => getInstance().createInteraction(...args),\n configureSession: (...args) => getInstance().configureSession(...args),\n addFacts: (...args) => getInstance().addFacts(...args),\n navigate: (...args) => getInstance().navigate(...args),\n startRecording: (...args) => getInstance().startRecording(...args),\n stopRecording: (...args) => getInstance().stopRecording(...args),\n getStatus: (...args) => getInstance().getStatus(...args),\n configureApp: (...args) => getInstance().configureApp(...args),\n configure: (...args) => getInstance().configure(...args),\n setInteractionOptions: (...args) =>\n getInstance().setInteractionOptions(...args),\n getTemplates: (...args) => getInstance().getTemplates(...args),\n setCredentials: (...args) => getInstance().setCredentials(...args),\n showDeviceLinkQR: (...args) => getInstance().showDeviceLinkQR(...args),\n show: (...args) => getInstance().show(...args),\n hide: (...args) => getInstance().hide(...args),\n }),\n [getInstance],\n );\n}\n"]}
|
package/dist/types/api.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { ConfigureAppPayload, ConfigurePayload } from "./config.js";
|
|
2
2
|
import type { AuthChangedEventPayload, DocumentEventPayload, ErrorEventPayload, InteractionCreatedEventPayload, NavigationChangedEventPayload, UsageEventPayload } from "./events.js";
|
|
3
|
-
import type { AddFactsPayload, ConfigureSessionPayload, CreateInteractionPayload, Fact, KeycloakTokenResponse, NavigatePayload, SetInteractionOptionsPayload, SetCredentialsPayload } from "./payloads.js";
|
|
3
|
+
import type { AddFactsPayload, ConfigureSessionPayload, CreateInteractionPayload, DeviceLinkTokenResponse, Fact, KeycloakTokenResponse, NavigatePayload, SetInteractionOptionsPayload, SetCredentialsPayload } from "./payloads.js";
|
|
4
4
|
import type { DefaultMode } from "./protocol.js";
|
|
5
|
-
import type { AuthResponse, ConfigureAppResponse, ConfigureResponse, CreateInteractionResponse, GetStatusResponse, GetTemplatesResponse } from "./responses.js";
|
|
5
|
+
import type { AuthResponse, ConfigureAppResponse, ConfigureResponse, CreateInteractionResponse, GetStatusResponse, GetTemplatesResponse, ShowDeviceLinkQRResponse } from "./responses.js";
|
|
6
6
|
export type { ConfigureAppPayload, ConfigurePayload } from "./config.js";
|
|
7
|
-
export type { UserInfo } from "./responses.js";
|
|
7
|
+
export type { ShowDeviceLinkQRResponse, UserInfo } from "./responses.js";
|
|
8
8
|
/**
|
|
9
9
|
* User information returned from authentication
|
|
10
10
|
*/
|
|
@@ -58,6 +58,7 @@ export interface CortiEmbeddedV1API {
|
|
|
58
58
|
setCredentials(payload: SetCredentialsPayload): Promise<void>;
|
|
59
59
|
getStatus(): Promise<GetStatusResponse>;
|
|
60
60
|
getTemplates(): Promise<GetTemplatesResponse>;
|
|
61
|
+
showDeviceLinkQR(payload: DeviceLinkTokenResponse): Promise<ShowDeviceLinkQRResponse>;
|
|
61
62
|
}
|
|
62
63
|
export interface CortiEmbeddedWindowAPI {
|
|
63
64
|
v1: CortiEmbeddedV1API;
|
|
@@ -163,4 +164,10 @@ export interface CortiEmbeddedAPI {
|
|
|
163
164
|
* Hide the embedded UI
|
|
164
165
|
*/
|
|
165
166
|
hide(): void;
|
|
167
|
+
/**
|
|
168
|
+
* Show the device-link QR code in the embedded UI
|
|
169
|
+
* @param payload Device-link token response to render as a QR code
|
|
170
|
+
* @returns Promise resolving to the rendered QR code state
|
|
171
|
+
*/
|
|
172
|
+
showDeviceLinkQR(payload: DeviceLinkTokenResponse): Promise<ShowDeviceLinkQRResponse>;
|
|
166
173
|
}
|
package/dist/types/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/types/api.ts"],"names":[],"mappings":"AAAA,qCAAqC","sourcesContent":["// Public API types for SDK consumers\n\nimport type { ConfigureAppPayload, ConfigurePayload } from \"./config.js\";\nimport type {\n AuthChangedEventPayload,\n DocumentEventPayload,\n ErrorEventPayload,\n InteractionCreatedEventPayload,\n NavigationChangedEventPayload,\n UsageEventPayload,\n} from \"./events.js\";\nimport type {\n AddFactsPayload,\n ConfigureSessionPayload,\n CreateInteractionPayload,\n Fact,\n KeycloakTokenResponse,\n NavigatePayload,\n SetInteractionOptionsPayload,\n SetCredentialsPayload,\n} from \"./payloads.js\";\nimport type { DefaultMode } from \"./protocol.js\";\nimport type {\n AuthResponse,\n ConfigureAppResponse,\n ConfigureResponse,\n CreateInteractionResponse,\n GetStatusResponse,\n GetTemplatesResponse,\n} from \"./responses.js\";\n\nexport type { ConfigureAppPayload, ConfigurePayload } from \"./config.js\";\n// Re-export common types for public API\nexport type { UserInfo } from \"./responses.js\";\n\n/**\n * User information returned from authentication\n */\nexport interface User {\n id: string;\n email: string;\n}\n\n/**\n * Details of a created interaction\n */\nexport interface InteractionDetails {\n id: string;\n createdAt: string;\n}\n\n/**\n * Session configuration options\n */\nexport interface SessionConfig {\n defaultLanguage?: string;\n defaultOutputLanguage?: string;\n defaultTemplateKey?: string;\n defaultMode?: DefaultMode;\n}\n\n/**\n * Event data types for component events\n */\nexport interface EmbeddedEventData {\n ready: undefined;\n \"auth-changed\": AuthChangedEventPayload;\n \"interaction-created\": InteractionCreatedEventPayload;\n \"recording-started\": undefined;\n \"recording-stopped\": undefined;\n \"document-generated\": DocumentEventPayload;\n \"document-updated\": DocumentEventPayload;\n \"document-synced\": DocumentEventPayload;\n \"navigation-changed\": NavigationChangedEventPayload;\n usage: UsageEventPayload;\n error: ErrorEventPayload;\n}\n\n// Window API Types\nexport interface CortiEmbeddedV1API {\n auth(payload: KeycloakTokenResponse): Promise<AuthResponse>;\n createInteraction(payload: CreateInteractionPayload): Promise<CreateInteractionResponse>;\n addFacts(payload: AddFactsPayload): Promise<void>;\n configureApp(payload: ConfigureAppPayload): Promise<ConfigureAppResponse>;\n configureSession(payload: ConfigureSessionPayload): Promise<void>;\n setInteractionOptions(payload: SetInteractionOptionsPayload): Promise<void>;\n configure(payload: ConfigurePayload): Promise<ConfigureResponse>;\n navigate(payload: NavigatePayload): Promise<void>;\n startRecording(): Promise<void>;\n stopRecording(): Promise<void>;\n setCredentials(payload: SetCredentialsPayload): Promise<void>;\n getStatus(): Promise<GetStatusResponse>;\n getTemplates(): Promise<GetTemplatesResponse>;\n}\nexport interface CortiEmbeddedWindowAPI {\n v1: CortiEmbeddedV1API;\n}\n\n// Extend Window interface\ndeclare global {\n interface Window {\n CortiEmbedded?: CortiEmbeddedWindowAPI;\n }\n}\n\n/**\n * Event listener function type\n */\nexport type EventListener<T = unknown> = (data: T) => void;\n\n/**\n * Public API interface for the Corti Embedded component\n */\nexport interface CortiEmbeddedAPI {\n /**\n * Authenticate with the Corti system\n * @param credentials Authentication credentials\n * @returns Promise resolving to user information\n */\n auth(credentials: KeycloakTokenResponse): Promise<User>;\n\n /**\n * Create a new interaction\n * @param encounter Encounter request data\n * @returns Promise resolving to interaction details\n */\n createInteraction(encounter: CreateInteractionPayload): Promise<InteractionDetails>;\n\n /**\n * Configure the current session\n * @param config Session configuration\n * @returns Promise that resolves when configuration is complete\n */\n configureSession(config: SessionConfig): Promise<void>;\n\n /**\n * Add facts to the current session\n * @param facts Array of facts to add\n * @returns Promise that resolves when facts are added\n */\n addFacts(facts: Fact[]): Promise<void>;\n\n /**\n * Navigate to a specific path within the embedded UI\n * @param path Path to navigate to\n * @returns Promise that resolves when navigation is complete\n */\n navigate(path: string): Promise<void>;\n\n /**\n * Start recording\n * @returns Promise that resolves when recording starts\n */\n startRecording(): Promise<void>;\n\n /**\n * Stop recording\n * @returns Promise that resolves when recording stops\n */\n stopRecording(): Promise<void>;\n\n /**\n * Get current component status\n * @returns Promise resolving to current status\n */\n getStatus(): Promise<GetStatusResponse>;\n\n /**\n * Get all templates available to the current user\n * @returns Promise resolving to list of templates\n */\n getTemplates(): Promise<GetTemplatesResponse>;\n\n /**\n * Configure the embedded application\n * @param config Application-level configuration\n * @returns Promise that resolves when configuration is applied\n */\n configureApp(config: ConfigureAppPayload): Promise<ConfigureAppResponse>;\n\n /**\n * Configure the application\n * @param config Application configuration\n * @returns Promise that resolves when configuration is applied\n */\n configure(config: ConfigurePayload): Promise<ConfigureResponse>;\n\n /**\n * Set one-shot interaction options for the embedded instance.\n *\n * Each call patches the provided interaction-options branches onto the current\n * snapshot for the embedded instance. Omitted branches preserve their existing\n * values from previous calls.\n * @param config Interaction/session-level options\n * @returns Promise that resolves when options are applied\n */\n setInteractionOptions(config: SetInteractionOptionsPayload): Promise<void>;\n\n /**\n * Set authentication credentials without triggering auth flow\n * @param credentials Authentication credentials to store\n * @returns Promise that resolves when credentials are set\n */\n setCredentials(credentials: { password: string }): Promise<void>;\n\n /**\n * Show the embedded UI\n */\n show(): void;\n\n /**\n * Hide the embedded UI\n */\n hide(): void;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/types/api.ts"],"names":[],"mappings":"AAAA,qCAAqC","sourcesContent":["// Public API types for SDK consumers\n\nimport type { ConfigureAppPayload, ConfigurePayload } from \"./config.js\";\nimport type {\n AuthChangedEventPayload,\n DocumentEventPayload,\n ErrorEventPayload,\n InteractionCreatedEventPayload,\n NavigationChangedEventPayload,\n UsageEventPayload,\n} from \"./events.js\";\nimport type {\n AddFactsPayload,\n ConfigureSessionPayload,\n CreateInteractionPayload,\n DeviceLinkTokenResponse,\n Fact,\n KeycloakTokenResponse,\n NavigatePayload,\n SetInteractionOptionsPayload,\n SetCredentialsPayload,\n} from \"./payloads.js\";\nimport type { DefaultMode } from \"./protocol.js\";\nimport type {\n AuthResponse,\n ConfigureAppResponse,\n ConfigureResponse,\n CreateInteractionResponse,\n GetStatusResponse,\n GetTemplatesResponse,\n ShowDeviceLinkQRResponse,\n} from \"./responses.js\";\n\nexport type { ConfigureAppPayload, ConfigurePayload } from \"./config.js\";\n// Re-export common types for public API\nexport type { ShowDeviceLinkQRResponse, UserInfo } from \"./responses.js\";\n\n/**\n * User information returned from authentication\n */\nexport interface User {\n id: string;\n email: string;\n}\n\n/**\n * Details of a created interaction\n */\nexport interface InteractionDetails {\n id: string;\n createdAt: string;\n}\n\n/**\n * Session configuration options\n */\nexport interface SessionConfig {\n defaultLanguage?: string;\n defaultOutputLanguage?: string;\n defaultTemplateKey?: string;\n defaultMode?: DefaultMode;\n}\n\n/**\n * Event data types for component events\n */\nexport interface EmbeddedEventData {\n ready: undefined;\n \"auth-changed\": AuthChangedEventPayload;\n \"interaction-created\": InteractionCreatedEventPayload;\n \"recording-started\": undefined;\n \"recording-stopped\": undefined;\n \"document-generated\": DocumentEventPayload;\n \"document-updated\": DocumentEventPayload;\n \"document-synced\": DocumentEventPayload;\n \"navigation-changed\": NavigationChangedEventPayload;\n usage: UsageEventPayload;\n error: ErrorEventPayload;\n}\n\n// Window API Types\nexport interface CortiEmbeddedV1API {\n auth(payload: KeycloakTokenResponse): Promise<AuthResponse>;\n createInteraction(\n payload: CreateInteractionPayload,\n ): Promise<CreateInteractionResponse>;\n addFacts(payload: AddFactsPayload): Promise<void>;\n configureApp(payload: ConfigureAppPayload): Promise<ConfigureAppResponse>;\n configureSession(payload: ConfigureSessionPayload): Promise<void>;\n setInteractionOptions(payload: SetInteractionOptionsPayload): Promise<void>;\n configure(payload: ConfigurePayload): Promise<ConfigureResponse>;\n navigate(payload: NavigatePayload): Promise<void>;\n startRecording(): Promise<void>;\n stopRecording(): Promise<void>;\n setCredentials(payload: SetCredentialsPayload): Promise<void>;\n getStatus(): Promise<GetStatusResponse>;\n getTemplates(): Promise<GetTemplatesResponse>;\n showDeviceLinkQR(\n payload: DeviceLinkTokenResponse,\n ): Promise<ShowDeviceLinkQRResponse>;\n}\nexport interface CortiEmbeddedWindowAPI {\n v1: CortiEmbeddedV1API;\n}\n\n// Extend Window interface\ndeclare global {\n interface Window {\n CortiEmbedded?: CortiEmbeddedWindowAPI;\n }\n}\n\n/**\n * Event listener function type\n */\nexport type EventListener<T = unknown> = (data: T) => void;\n\n/**\n * Public API interface for the Corti Embedded component\n */\nexport interface CortiEmbeddedAPI {\n /**\n * Authenticate with the Corti system\n * @param credentials Authentication credentials\n * @returns Promise resolving to user information\n */\n auth(credentials: KeycloakTokenResponse): Promise<User>;\n\n /**\n * Create a new interaction\n * @param encounter Encounter request data\n * @returns Promise resolving to interaction details\n */\n createInteraction(\n encounter: CreateInteractionPayload,\n ): Promise<InteractionDetails>;\n\n /**\n * Configure the current session\n * @param config Session configuration\n * @returns Promise that resolves when configuration is complete\n */\n configureSession(config: SessionConfig): Promise<void>;\n\n /**\n * Add facts to the current session\n * @param facts Array of facts to add\n * @returns Promise that resolves when facts are added\n */\n addFacts(facts: Fact[]): Promise<void>;\n\n /**\n * Navigate to a specific path within the embedded UI\n * @param path Path to navigate to\n * @returns Promise that resolves when navigation is complete\n */\n navigate(path: string): Promise<void>;\n\n /**\n * Start recording\n * @returns Promise that resolves when recording starts\n */\n startRecording(): Promise<void>;\n\n /**\n * Stop recording\n * @returns Promise that resolves when recording stops\n */\n stopRecording(): Promise<void>;\n\n /**\n * Get current component status\n * @returns Promise resolving to current status\n */\n getStatus(): Promise<GetStatusResponse>;\n\n /**\n * Get all templates available to the current user\n * @returns Promise resolving to list of templates\n */\n getTemplates(): Promise<GetTemplatesResponse>;\n\n /**\n * Configure the embedded application\n * @param config Application-level configuration\n * @returns Promise that resolves when configuration is applied\n */\n configureApp(config: ConfigureAppPayload): Promise<ConfigureAppResponse>;\n\n /**\n * Configure the application\n * @param config Application configuration\n * @returns Promise that resolves when configuration is applied\n */\n configure(config: ConfigurePayload): Promise<ConfigureResponse>;\n\n /**\n * Set one-shot interaction options for the embedded instance.\n *\n * Each call patches the provided interaction-options branches onto the current\n * snapshot for the embedded instance. Omitted branches preserve their existing\n * values from previous calls.\n * @param config Interaction/session-level options\n * @returns Promise that resolves when options are applied\n */\n setInteractionOptions(config: SetInteractionOptionsPayload): Promise<void>;\n\n /**\n * Set authentication credentials without triggering auth flow\n * @param credentials Authentication credentials to store\n * @returns Promise that resolves when credentials are set\n */\n setCredentials(credentials: { password: string }): Promise<void>;\n\n /**\n * Show the embedded UI\n */\n show(): void;\n\n /**\n * Hide the embedded UI\n */\n hide(): void;\n\n /**\n * Show the device-link QR code in the embedded UI\n * @param payload Device-link token response to render as a QR code\n * @returns Promise resolving to the rendered QR code state\n */\n showDeviceLinkQR(\n payload: DeviceLinkTokenResponse,\n ): Promise<ShowDeviceLinkQRResponse>;\n}\n"]}
|
package/dist/types/config.d.ts
CHANGED
|
@@ -7,6 +7,9 @@ export interface UIConfig {
|
|
|
7
7
|
documentFeedback: boolean;
|
|
8
8
|
navigation: boolean;
|
|
9
9
|
}
|
|
10
|
+
export interface CompanionAppConfig {
|
|
11
|
+
enabled: boolean;
|
|
12
|
+
}
|
|
10
13
|
export interface ConfigureFeaturesConfig {
|
|
11
14
|
interactionTitle: boolean;
|
|
12
15
|
aiChat: boolean;
|
|
@@ -34,6 +37,7 @@ export interface ConfigurePayload {
|
|
|
34
37
|
export interface ConfigureAppPayload {
|
|
35
38
|
debug?: boolean;
|
|
36
39
|
ui?: Partial<UIConfig>;
|
|
40
|
+
companionApp?: CompanionAppConfig;
|
|
37
41
|
appearance?: Partial<AppearanceConfig>;
|
|
38
42
|
locale?: Partial<LocaleConfig>;
|
|
39
43
|
network?: Partial<NetworkConfig>;
|
package/dist/types/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA,iDAAiD","sourcesContent":["// Configuration types for the embedded component\n\nexport interface AppearanceConfig {\n primaryColor: string | null;\n}\n\nexport interface UIConfig {\n interactionTitle: boolean;\n aiChat: boolean;\n documentFeedback: boolean;\n navigation: boolean;\n}\n\nexport interface ConfigureFeaturesConfig {\n interactionTitle: boolean;\n aiChat: boolean;\n documentFeedback: boolean;\n navigation: boolean;\n virtualMode: boolean;\n syncDocumentAction: boolean;\n templateEditor: boolean;\n}\n\nexport interface LocaleConfig {\n interfaceLanguage: string;\n dictationLanguage?: string | null;\n overrides?: Record<string, string>;\n}\n\nexport interface NetworkConfig {\n websocketBaseUrl?: string | null;\n}\n\nexport interface ConfigurePayload {\n debug?: boolean;\n appearance?: Partial<AppearanceConfig>;\n features?: Partial<ConfigureFeaturesConfig>;\n locale?: Partial<LocaleConfig>;\n network?: Partial<NetworkConfig>;\n}\n\nexport interface ConfigureAppPayload {\n debug?: boolean;\n ui?: Partial<UIConfig>;\n appearance?: Partial<AppearanceConfig>;\n locale?: Partial<LocaleConfig>;\n network?: Partial<NetworkConfig>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA,iDAAiD","sourcesContent":["// Configuration types for the embedded component\n\nexport interface AppearanceConfig {\n primaryColor: string | null;\n}\n\nexport interface UIConfig {\n interactionTitle: boolean;\n aiChat: boolean;\n documentFeedback: boolean;\n navigation: boolean;\n}\n\nexport interface CompanionAppConfig {\n enabled: boolean;\n}\n\nexport interface ConfigureFeaturesConfig {\n interactionTitle: boolean;\n aiChat: boolean;\n documentFeedback: boolean;\n navigation: boolean;\n virtualMode: boolean;\n syncDocumentAction: boolean;\n templateEditor: boolean;\n}\n\nexport interface LocaleConfig {\n interfaceLanguage: string;\n dictationLanguage?: string | null;\n overrides?: Record<string, string>;\n}\n\nexport interface NetworkConfig {\n websocketBaseUrl?: string | null;\n}\n\nexport interface ConfigurePayload {\n debug?: boolean;\n appearance?: Partial<AppearanceConfig>;\n features?: Partial<ConfigureFeaturesConfig>;\n locale?: Partial<LocaleConfig>;\n network?: Partial<NetworkConfig>;\n}\n\nexport interface ConfigureAppPayload {\n debug?: boolean;\n ui?: Partial<UIConfig>;\n companionApp?: CompanionAppConfig;\n appearance?: Partial<AppearanceConfig>;\n locale?: Partial<LocaleConfig>;\n network?: Partial<NetworkConfig>;\n}\n"]}
|
|
@@ -79,6 +79,47 @@ export type EmbeddedInterviewDetails = {
|
|
|
79
79
|
/** Not applicable for built-in templates */
|
|
80
80
|
customTemplateId: null;
|
|
81
81
|
state: "generated" | "pending" | "error" | "stale" | "missing_template";
|
|
82
|
+
} | {
|
|
83
|
+
/** Unique document identifier */
|
|
84
|
+
id: string;
|
|
85
|
+
/** Document name */
|
|
86
|
+
name: string;
|
|
87
|
+
/** Language code for document output */
|
|
88
|
+
outputLanguage: string;
|
|
89
|
+
/** Whether document is streamed */
|
|
90
|
+
isStream: boolean;
|
|
91
|
+
/** Document sections */
|
|
92
|
+
sections: {
|
|
93
|
+
/** Unique identifier for the section */
|
|
94
|
+
key: string;
|
|
95
|
+
/** Display name of the section */
|
|
96
|
+
name: string;
|
|
97
|
+
/** Section content text */
|
|
98
|
+
text: string;
|
|
99
|
+
/** Sort order for displaying sections */
|
|
100
|
+
sort: number;
|
|
101
|
+
/** ISO 8601 timestamp when section was created */
|
|
102
|
+
createdAt: string;
|
|
103
|
+
/** ISO 8601 timestamp when section was last updated */
|
|
104
|
+
updatedAt: string;
|
|
105
|
+
/** Markdown formatted content */
|
|
106
|
+
markdown?: (string | null) | undefined;
|
|
107
|
+
/** HTML formatted content */
|
|
108
|
+
htmlText?: string | undefined;
|
|
109
|
+
/** Plain text content */
|
|
110
|
+
plainText?: string | undefined;
|
|
111
|
+
}[];
|
|
112
|
+
/** Usage information */
|
|
113
|
+
usageInfo?: {
|
|
114
|
+
creditsConsumed: number;
|
|
115
|
+
} | undefined;
|
|
116
|
+
/** Reference to the template used */
|
|
117
|
+
templateRef: string;
|
|
118
|
+
/** Type of template used */
|
|
119
|
+
templateType: "schema-driven";
|
|
120
|
+
/** Not applicable for schema-driven templates */
|
|
121
|
+
customTemplateId: null;
|
|
122
|
+
state: "generated" | "pending" | "error" | "stale" | "missing_template";
|
|
82
123
|
} | {
|
|
83
124
|
/** Unique document identifier */
|
|
84
125
|
id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interview-details.js","sourceRoot":"","sources":["../../../src/types/generated/interview-details.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,uBAAuB","sourcesContent":["// This file is auto-generated by scripts/generate-embedded-interview-details.ts\n// Do not edit by hand.\n\nexport type EmbeddedInterviewDetails = {\n /** Unique interview identifier */\n id: string;\n /** Interview title */\n title: string | null;\n /** Current state of the interaction */\n state
|
|
1
|
+
{"version":3,"file":"interview-details.js","sourceRoot":"","sources":["../../../src/types/generated/interview-details.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,uBAAuB","sourcesContent":["// This file is auto-generated by scripts/generate-embedded-interview-details.ts\n// Do not edit by hand.\n\nexport type EmbeddedInterviewDetails = {\n /** Unique interview identifier */\n id: string;\n /** Interview title */\n title: string | null;\n /** Current state of the interaction */\n state:\n | \"planned\"\n | \"ongoing\"\n | \"paused\"\n | \"disconnected\"\n | \"ending\"\n | \"parsing\"\n | \"ended\";\n /** ISO 8601 timestamp when interview started */\n startedAt: string;\n /** ISO 8601 timestamp when interview ended */\n endedAt: string | null;\n /** ISO 8601 timestamp when interview is scheduled to end */\n endsAt: string | null;\n /** Maximum duration in minutes */\n maxDurationInMinutes?: (number | null) | undefined;\n transcripts: {\n utterances: {\n /** Unique utterance identifier */\n id: string;\n /** Start time in seconds */\n start: number;\n /** Duration in seconds */\n duration: number;\n /** Utterance text content */\n text: string;\n /** Whether the utterance is finalized */\n isFinal: boolean;\n /** ID of the participant who spoke */\n participantId?: string | undefined;\n }[];\n participants: {\n /** Unique participant identifier */\n id?: string | undefined;\n /** Audio channel number for the participant */\n channel: number;\n /** Role of the participant in the interaction */\n role: \"agent\" | \"patient\" | \"other\" | \"multiple\";\n }[];\n isMultiChannel: boolean;\n }[];\n documents: (\n | {\n /** Unique document identifier */\n id: string;\n /** Document name */\n name: string;\n /** Language code for document output */\n outputLanguage: string;\n /** Whether document is streamed */\n isStream: boolean;\n /** Document sections */\n sections: {\n /** Unique identifier for the section */\n key: string;\n /** Display name of the section */\n name: string;\n /** Section content text */\n text: string;\n /** Sort order for displaying sections */\n sort: number;\n /** ISO 8601 timestamp when section was created */\n createdAt: string;\n /** ISO 8601 timestamp when section was last updated */\n updatedAt: string;\n /** Markdown formatted content */\n markdown?: (string | null) | undefined;\n /** HTML formatted content */\n htmlText?: string | undefined;\n /** Plain text content */\n plainText?: string | undefined;\n }[];\n /** Usage information */\n usageInfo?:\n | {\n creditsConsumed: number;\n }\n | undefined;\n /** Reference to the template used */\n templateRef: string;\n /** Type of template used */\n templateType: \"built-in\";\n /** Not applicable for built-in templates */\n customTemplateId: null;\n state: \"generated\" | \"pending\" | \"error\" | \"stale\" | \"missing_template\";\n }\n | {\n /** Unique document identifier */\n id: string;\n /** Document name */\n name: string;\n /** Language code for document output */\n outputLanguage: string;\n /** Whether document is streamed */\n isStream: boolean;\n /** Document sections */\n sections: {\n /** Unique identifier for the section */\n key: string;\n /** Display name of the section */\n name: string;\n /** Section content text */\n text: string;\n /** Sort order for displaying sections */\n sort: number;\n /** ISO 8601 timestamp when section was created */\n createdAt: string;\n /** ISO 8601 timestamp when section was last updated */\n updatedAt: string;\n /** Markdown formatted content */\n markdown?: (string | null) | undefined;\n /** HTML formatted content */\n htmlText?: string | undefined;\n /** Plain text content */\n plainText?: string | undefined;\n }[];\n /** Usage information */\n usageInfo?:\n | {\n creditsConsumed: number;\n }\n | undefined;\n /** Reference to the template used */\n templateRef: string;\n /** Type of template used */\n templateType: \"schema-driven\";\n /** Not applicable for schema-driven templates */\n customTemplateId: null;\n state: \"generated\" | \"pending\" | \"error\" | \"stale\" | \"missing_template\";\n }\n | {\n /** Unique document identifier */\n id: string;\n /** Document name */\n name: string;\n /** Language code for document output */\n outputLanguage: string;\n /** Whether document is streamed */\n isStream: boolean;\n /** Document sections */\n sections: {\n /** Unique identifier for the section */\n key: string;\n /** Display name of the section */\n name: string;\n /** Section content text */\n text: string;\n /** Sort order for displaying sections */\n sort: number;\n /** ISO 8601 timestamp when section was created */\n createdAt: string;\n /** ISO 8601 timestamp when section was last updated */\n updatedAt: string;\n /** Markdown formatted content */\n markdown?: (string | null) | undefined;\n /** HTML formatted content */\n htmlText?: string | undefined;\n /** Plain text content */\n plainText?: string | undefined;\n }[];\n /** Usage information */\n usageInfo?:\n | {\n creditsConsumed: number;\n }\n | undefined;\n /** Type of template used */\n templateType: \"custom\";\n /** Not applicable for custom templates */\n templateRef: null;\n /** ID of the custom template */\n customTemplateId: string;\n state: \"generated\" | \"pending\" | \"error\" | \"stale\" | \"missing_template\";\n }\n )[];\n factGroups:\n | {\n /** DEPRECATED: Legacy identifier, use 'key' instead */\n id?: string | undefined;\n /** Unique fact group key */\n key: string;\n translations: {\n /** Translation identifier */\n id: number;\n /** Language identifier */\n languages_id: string;\n /** Translated group name */\n name: string;\n }[];\n }[]\n | null;\n facts:\n | {\n /** Unique fact identifier */\n id: string;\n /** The fact content */\n text: string;\n /** Category group key for organizing facts */\n group: string;\n /** DEPRECATED: Legacy group identifier, use 'group' instead */\n groupId?: (string | null) | undefined;\n /** Whether the fact has been discarded */\n isDiscarded: boolean;\n /** Origin of the fact: core (built-in), system (auto-generated), or user (manual) */\n source: \"core\" | \"system\" | \"user\";\n /** ISO 8601 timestamp when fact was created */\n createdAt?: string | undefined;\n /** ISO 8601 timestamp when fact was last updated */\n updatedAt: string;\n /** Whether this is a newly added fact */\n isNew?: boolean | undefined;\n }[]\n | null;\n websocketUrl: string;\n};\n"]}
|
package/dist/types/payloads.d.ts
CHANGED
|
@@ -17,6 +17,9 @@ export interface KeycloakTokenResponse {
|
|
|
17
17
|
sub: string;
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
+
export type DeviceLinkTokenResponse = KeycloakTokenResponse & {
|
|
21
|
+
refresh_token: string;
|
|
22
|
+
};
|
|
20
23
|
export interface Fact {
|
|
21
24
|
text: Corti.FactsCreateInput["text"];
|
|
22
25
|
group: string;
|
|
@@ -51,23 +54,84 @@ export interface ConfigureSessionPayload {
|
|
|
51
54
|
defaultMode?: DefaultMode;
|
|
52
55
|
}
|
|
53
56
|
export interface InteractionModeOptions {
|
|
54
|
-
fallback
|
|
57
|
+
fallback?: DefaultMode;
|
|
55
58
|
options: DefaultMode[];
|
|
56
59
|
}
|
|
57
60
|
export interface SpokenLanguageOptions {
|
|
58
|
-
fallback
|
|
61
|
+
fallback?: string;
|
|
62
|
+
options?: string[];
|
|
63
|
+
}
|
|
64
|
+
export interface InlineTemplateLabel {
|
|
65
|
+
key: string;
|
|
66
|
+
value: string;
|
|
67
|
+
}
|
|
68
|
+
export interface InlineTemplateSectionInstructions {
|
|
69
|
+
contentPrompt: string;
|
|
70
|
+
writingStylePrompt?: string;
|
|
71
|
+
miscPrompt?: string;
|
|
72
|
+
}
|
|
73
|
+
export interface InlineTemplateSection {
|
|
74
|
+
heading: string;
|
|
75
|
+
labels?: InlineTemplateLabel[];
|
|
76
|
+
instructions: InlineTemplateSectionInstructions;
|
|
77
|
+
outputSchema?: Record<string, unknown>;
|
|
78
|
+
}
|
|
79
|
+
export interface InlineTemplate {
|
|
80
|
+
id?: string;
|
|
81
|
+
name: string;
|
|
82
|
+
labels?: InlineTemplateLabel[];
|
|
83
|
+
generation: {
|
|
84
|
+
instructions: {
|
|
85
|
+
prompt: string;
|
|
86
|
+
};
|
|
87
|
+
sections: InlineTemplateSection[];
|
|
88
|
+
};
|
|
59
89
|
}
|
|
60
90
|
export interface InteractionTemplateReference {
|
|
61
|
-
source: "standard";
|
|
91
|
+
source: "standard" | "project";
|
|
62
92
|
id: string;
|
|
63
93
|
}
|
|
64
94
|
export interface DefaultInteractionTemplateOptions {
|
|
65
|
-
behaviour
|
|
66
|
-
template
|
|
95
|
+
behaviour?: "fallback";
|
|
96
|
+
template?: InteractionTemplateReference;
|
|
97
|
+
allowUserSelection?: boolean;
|
|
98
|
+
}
|
|
99
|
+
export interface PersonalTemplateSectionFieldConfig {
|
|
100
|
+
visible?: boolean;
|
|
101
|
+
editable?: boolean;
|
|
102
|
+
}
|
|
103
|
+
export interface PersonalTemplateSectionFields {
|
|
104
|
+
heading?: {
|
|
105
|
+
editable?: boolean;
|
|
106
|
+
};
|
|
107
|
+
description?: {
|
|
108
|
+
editable?: boolean;
|
|
109
|
+
};
|
|
110
|
+
contentPrompt?: PersonalTemplateSectionFieldConfig;
|
|
111
|
+
writingStylePrompt?: PersonalTemplateSectionFieldConfig;
|
|
112
|
+
miscPrompt?: PersonalTemplateSectionFieldConfig;
|
|
113
|
+
outputSchema?: PersonalTemplateSectionFieldConfig;
|
|
67
114
|
}
|
|
68
115
|
export interface InteractionTemplateSources {
|
|
69
116
|
personal?: {
|
|
70
|
-
enabled
|
|
117
|
+
enabled?: boolean;
|
|
118
|
+
sectionFields?: PersonalTemplateSectionFields;
|
|
119
|
+
};
|
|
120
|
+
standard?: {
|
|
121
|
+
enabled?: boolean;
|
|
122
|
+
include?: {
|
|
123
|
+
regions?: string[];
|
|
124
|
+
families?: string[];
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
project?: {
|
|
128
|
+
enabled?: boolean;
|
|
129
|
+
include?: {
|
|
130
|
+
ids?: string[];
|
|
131
|
+
};
|
|
132
|
+
exclude?: {
|
|
133
|
+
ids?: string[];
|
|
134
|
+
};
|
|
71
135
|
};
|
|
72
136
|
}
|
|
73
137
|
export interface InteractionTemplateOptions {
|
|
@@ -78,6 +142,8 @@ export interface InteractionDocumentOptions {
|
|
|
78
142
|
actions?: {
|
|
79
143
|
sync?: boolean;
|
|
80
144
|
};
|
|
145
|
+
allowedLanguages?: string[];
|
|
146
|
+
maxGenerated?: number | "unlimited";
|
|
81
147
|
}
|
|
82
148
|
export interface SetInteractionOptionsPayload {
|
|
83
149
|
mode?: InteractionModeOptions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payloads.js","sourceRoot":"","sources":["../../src/types/payloads.ts"],"names":[],"mappings":"","sourcesContent":["// Payload types for embedded API requests and responses\nimport type { Corti } from \"@corti/sdk\";\n\nimport type { DefaultMode } from \"./protocol.js\";\n\n// Keycloak token structure\nexport interface KeycloakTokenResponse {\n access_token: string;\n token_type: string;\n expires_at?: number | null;\n expires_in?: number | null;\n refresh_expires_in?: number | null;\n refresh_token?: string;\n id_token?: string;\n \"not-before-policy\"?: number | null;\n session_state?: string;\n scope?: string;\n profile?: {\n name: string;\n email: string;\n sub: string;\n };\n}\n\n// Fact structure\nexport interface Fact {\n text: Corti.FactsCreateInput[\"text\"];\n group: string;\n source?: Corti.FactsCreateInput[\"source\"];\n}\n\n// Create interaction payload\nexport interface CreateInteractionPayload {\n assignedUserId?: Corti.InteractionsCreateRequest[\"assignedUserId\"] | null;\n encounter: {\n identifier: Corti.InteractionsCreateRequest[\"encounter\"][\"identifier\"];\n status: Corti.InteractionsCreateRequest[\"encounter\"][\"status\"];\n type: Corti.InteractionsCreateRequest[\"encounter\"][\"type\"];\n period: {\n startedAt: string;\n endedAt?: string;\n };\n title?: string;\n };\n patient?: {\n identifier?: Corti.InteractionsPatient[\"identifier\"];\n name?: string;\n birthDate?: string | null;\n gender?: Corti.InteractionsPatient[\"gender\"];\n };\n}\n\n// Add facts payload\nexport interface AddFactsPayload {\n facts: Fact[];\n}\n\n// Configure session payload\nexport interface ConfigureSessionPayload {\n defaultLanguage?: string;\n defaultOutputLanguage?: string;\n defaultTemplateKey?: string;\n defaultMode?: DefaultMode;\n}\n\nexport interface InteractionModeOptions {\n fallback
|
|
1
|
+
{"version":3,"file":"payloads.js","sourceRoot":"","sources":["../../src/types/payloads.ts"],"names":[],"mappings":"","sourcesContent":["// Payload types for embedded API requests and responses\nimport type { Corti } from \"@corti/sdk\";\n\nimport type { DefaultMode } from \"./protocol.js\";\n\n// Keycloak token structure\nexport interface KeycloakTokenResponse {\n access_token: string;\n token_type: string;\n expires_at?: number | null;\n expires_in?: number | null;\n refresh_expires_in?: number | null;\n refresh_token?: string;\n id_token?: string;\n \"not-before-policy\"?: number | null;\n session_state?: string;\n scope?: string;\n profile?: {\n name: string;\n email: string;\n sub: string;\n };\n}\n\nexport type DeviceLinkTokenResponse = KeycloakTokenResponse & {\n refresh_token: string;\n};\n\n// Fact structure\nexport interface Fact {\n text: Corti.FactsCreateInput[\"text\"];\n group: string;\n source?: Corti.FactsCreateInput[\"source\"];\n}\n\n// Create interaction payload\nexport interface CreateInteractionPayload {\n assignedUserId?: Corti.InteractionsCreateRequest[\"assignedUserId\"] | null;\n encounter: {\n identifier: Corti.InteractionsCreateRequest[\"encounter\"][\"identifier\"];\n status: Corti.InteractionsCreateRequest[\"encounter\"][\"status\"];\n type: Corti.InteractionsCreateRequest[\"encounter\"][\"type\"];\n period: {\n startedAt: string;\n endedAt?: string;\n };\n title?: string;\n };\n patient?: {\n identifier?: Corti.InteractionsPatient[\"identifier\"];\n name?: string;\n birthDate?: string | null;\n gender?: Corti.InteractionsPatient[\"gender\"];\n };\n}\n\n// Add facts payload\nexport interface AddFactsPayload {\n facts: Fact[];\n}\n\n// Configure session payload\nexport interface ConfigureSessionPayload {\n defaultLanguage?: string;\n defaultOutputLanguage?: string;\n defaultTemplateKey?: string;\n defaultMode?: DefaultMode;\n}\n\nexport interface InteractionModeOptions {\n fallback?: DefaultMode;\n options: DefaultMode[];\n}\n\nexport interface SpokenLanguageOptions {\n fallback?: string;\n options?: string[];\n}\n\nexport interface InlineTemplateLabel {\n key: string;\n value: string;\n}\n\nexport interface InlineTemplateSectionInstructions {\n contentPrompt: string;\n writingStylePrompt?: string;\n miscPrompt?: string;\n}\n\nexport interface InlineTemplateSection {\n heading: string;\n labels?: InlineTemplateLabel[];\n instructions: InlineTemplateSectionInstructions;\n outputSchema?: Record<string, unknown>;\n}\n\nexport interface InlineTemplate {\n id?: string;\n name: string;\n labels?: InlineTemplateLabel[];\n generation: {\n instructions: {\n prompt: string;\n };\n sections: InlineTemplateSection[];\n };\n}\n\nexport interface InteractionTemplateReference {\n source: \"standard\" | \"project\";\n id: string;\n}\n\nexport interface DefaultInteractionTemplateOptions {\n behaviour?: \"fallback\";\n template?: InteractionTemplateReference;\n allowUserSelection?: boolean;\n}\n\nexport interface PersonalTemplateSectionFieldConfig {\n visible?: boolean;\n editable?: boolean;\n}\n\nexport interface PersonalTemplateSectionFields {\n heading?: { editable?: boolean };\n description?: { editable?: boolean };\n contentPrompt?: PersonalTemplateSectionFieldConfig;\n writingStylePrompt?: PersonalTemplateSectionFieldConfig;\n miscPrompt?: PersonalTemplateSectionFieldConfig;\n outputSchema?: PersonalTemplateSectionFieldConfig;\n}\n\nexport interface InteractionTemplateSources {\n personal?: {\n enabled?: boolean;\n sectionFields?: PersonalTemplateSectionFields;\n };\n standard?: {\n enabled?: boolean;\n include?: {\n regions?: string[];\n families?: string[];\n };\n };\n project?: {\n enabled?: boolean;\n include?: {\n ids?: string[];\n };\n exclude?: {\n ids?: string[];\n };\n };\n}\n\nexport interface InteractionTemplateOptions {\n sources?: InteractionTemplateSources;\n defaultTemplate?: DefaultInteractionTemplateOptions;\n}\n\nexport interface InteractionDocumentOptions {\n actions?: {\n sync?: boolean;\n };\n allowedLanguages?: string[];\n maxGenerated?: number | \"unlimited\";\n}\n\nexport interface SetInteractionOptionsPayload {\n mode?: InteractionModeOptions;\n spokenLanguage?: SpokenLanguageOptions;\n templates?: InteractionTemplateOptions;\n documents?: InteractionDocumentOptions;\n}\n\n// Navigate payload\nexport interface NavigatePayload {\n path: string;\n}\n\n// Set credentials payload\nexport interface SetCredentialsPayload {\n password: string;\n}\n"]}
|
package/dist/types/protocol.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export type APIVersion = "v1";
|
|
2
2
|
export type MessageType = "CORTI_EMBEDDED" | "CORTI_EMBEDDED_RESPONSE" | "CORTI_EMBEDDED_EVENT";
|
|
3
3
|
export type DefaultMode = "virtual" | "in-person";
|
|
4
|
-
export type EmbeddedAction = "auth" | "createInteraction" | "addFacts" | "configureApp" | "configureSession" | "setInteractionOptions" | "navigate" | "startRecording" | "stopRecording" | "getStatus" | "getTemplates" | "configure" | "setCredentials";
|
|
4
|
+
export type EmbeddedAction = "auth" | "createInteraction" | "addFacts" | "configureApp" | "configureSession" | "setInteractionOptions" | "navigate" | "startRecording" | "stopRecording" | "getStatus" | "getTemplates" | "configure" | "setCredentials" | "showDeviceLinkQR";
|
|
5
5
|
export type DeprecatedEmbeddedEvent = "ready" | "loaded" | "recordingStarted" | "recordingStopped" | "documentGenerated" | "documentUpdated" | "documentSynced" | "authChanged" | "interactionCreated" | "navigationChanged" | "usage";
|
|
6
6
|
export interface BaseMessage {
|
|
7
7
|
type: MessageType;
|
|
@@ -75,6 +75,9 @@ export interface ConfigureRequest extends EmbeddedRequest {
|
|
|
75
75
|
export interface SetCredentialsRequest extends EmbeddedRequest {
|
|
76
76
|
action: "setCredentials";
|
|
77
77
|
}
|
|
78
|
+
export interface ShowDeviceLinkQRRequest extends EmbeddedRequest {
|
|
79
|
+
action: "showDeviceLinkQR";
|
|
80
|
+
}
|
|
78
81
|
export interface ReadyEvent extends DeprecatedEmbeddedEventMessage {
|
|
79
82
|
event: "ready";
|
|
80
83
|
}
|
|
@@ -108,7 +111,7 @@ export interface NavigationChangedEvent extends DeprecatedEmbeddedEventMessage {
|
|
|
108
111
|
export interface UsageEvent extends DeprecatedEmbeddedEventMessage {
|
|
109
112
|
event: "usage";
|
|
110
113
|
}
|
|
111
|
-
export type AnyEmbeddedRequest = AuthRequest | CreateInteractionRequest | AddFactsRequest | ConfigureAppRequest | ConfigureSessionRequest | GetTemplatesRequest | NavigateRequest | SetInteractionOptionsRequest | StartRecordingRequest | StopRecordingRequest | GetStatusRequest | ConfigureRequest | SetCredentialsRequest;
|
|
114
|
+
export type AnyEmbeddedRequest = AuthRequest | CreateInteractionRequest | AddFactsRequest | ConfigureAppRequest | ConfigureSessionRequest | GetTemplatesRequest | NavigateRequest | SetInteractionOptionsRequest | StartRecordingRequest | StopRecordingRequest | GetStatusRequest | ConfigureRequest | SetCredentialsRequest | ShowDeviceLinkQRRequest;
|
|
112
115
|
export type AnyEmbeddedResponse = EmbeddedResponse;
|
|
113
116
|
export type AnyDeprecatedEmbeddedEvent = ReadyEvent | LoadedEvent | RecordingStartedEvent | RecordingStoppedEvent | DocumentGeneratedEvent | DocumentUpdatedEvent | DocumentSyncedEvent | AuthChangedEvent | InteractionCreatedEvent | NavigationChangedEvent | UsageEvent;
|
|
114
117
|
export type AnyEvent = EmbeddedEventMessage | AnyDeprecatedEmbeddedEvent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../src/types/protocol.ts"],"names":[],"mappings":"AAAA,4FAA4F","sourcesContent":["// Protocol types for communication between parent applications and embedded Corti Assistant\n\nexport type APIVersion = \"v1\";\n\nexport type MessageType
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../src/types/protocol.ts"],"names":[],"mappings":"AAAA,4FAA4F","sourcesContent":["// Protocol types for communication between parent applications and embedded Corti Assistant\n\nexport type APIVersion = \"v1\";\n\nexport type MessageType =\n | \"CORTI_EMBEDDED\"\n | \"CORTI_EMBEDDED_RESPONSE\"\n | \"CORTI_EMBEDDED_EVENT\";\n\nexport type DefaultMode = \"virtual\" | \"in-person\";\n\nexport type EmbeddedAction =\n | \"auth\"\n | \"createInteraction\"\n | \"addFacts\"\n | \"configureApp\"\n | \"configureSession\"\n | \"setInteractionOptions\"\n | \"navigate\"\n | \"startRecording\"\n | \"stopRecording\"\n | \"getStatus\"\n | \"getTemplates\"\n | \"configure\"\n | \"setCredentials\"\n | \"showDeviceLinkQR\";\n\nexport type DeprecatedEmbeddedEvent =\n | \"ready\"\n | \"loaded\"\n | \"recordingStarted\"\n | \"recordingStopped\"\n | \"documentGenerated\"\n | \"documentUpdated\"\n | \"documentSynced\"\n | \"authChanged\"\n | \"interactionCreated\"\n | \"navigationChanged\"\n | \"usage\";\n\n// Base Message Types\nexport interface BaseMessage {\n type: MessageType;\n version: APIVersion;\n}\n\nexport interface EmbeddedRequest extends BaseMessage {\n type: \"CORTI_EMBEDDED\";\n action: EmbeddedAction;\n requestId: string;\n payload?: unknown;\n}\n\nexport interface EmbeddedResponse extends BaseMessage {\n type: \"CORTI_EMBEDDED_RESPONSE\";\n action: EmbeddedAction;\n requestId: string;\n success: boolean;\n payload?: unknown;\n error?: string;\n errorCode?: string;\n errorDetails?: unknown;\n}\n\ninterface BaseEventMessage extends BaseMessage {\n type: \"CORTI_EMBEDDED_EVENT\";\n event: string | DeprecatedEmbeddedEvent;\n payload?: unknown;\n}\n\nexport interface DeprecatedEmbeddedEventMessage extends BaseEventMessage {\n event: DeprecatedEmbeddedEvent;\n deprecated: true;\n}\n\nexport interface EmbeddedEventMessage extends BaseEventMessage {\n payload: null | Record<string, unknown>;\n confidential: boolean;\n}\n\n// Specific Request Types\nexport interface AuthRequest extends EmbeddedRequest {\n action: \"auth\";\n}\n\nexport interface CreateInteractionRequest extends EmbeddedRequest {\n action: \"createInteraction\";\n}\n\nexport interface AddFactsRequest extends EmbeddedRequest {\n action: \"addFacts\";\n}\n\nexport interface ConfigureSessionRequest extends EmbeddedRequest {\n action: \"configureSession\";\n}\n\nexport interface ConfigureAppRequest extends EmbeddedRequest {\n action: \"configureApp\";\n}\n\nexport interface SetInteractionOptionsRequest extends EmbeddedRequest {\n action: \"setInteractionOptions\";\n}\n\nexport interface NavigateRequest extends EmbeddedRequest {\n action: \"navigate\";\n}\n\nexport interface StartRecordingRequest extends EmbeddedRequest {\n action: \"startRecording\";\n}\n\nexport interface StopRecordingRequest extends EmbeddedRequest {\n action: \"stopRecording\";\n}\n\nexport interface GetStatusRequest extends EmbeddedRequest {\n action: \"getStatus\";\n}\n\nexport interface GetTemplatesRequest extends EmbeddedRequest {\n action: \"getTemplates\";\n}\n\nexport interface ConfigureRequest extends EmbeddedRequest {\n action: \"configure\";\n}\n\nexport interface SetCredentialsRequest extends EmbeddedRequest {\n action: \"setCredentials\";\n}\n\nexport interface ShowDeviceLinkQRRequest extends EmbeddedRequest {\n action: \"showDeviceLinkQR\";\n}\n\n// Event Types\nexport interface ReadyEvent extends DeprecatedEmbeddedEventMessage {\n event: \"ready\";\n}\n\nexport interface LoadedEvent extends DeprecatedEmbeddedEventMessage {\n event: \"loaded\";\n}\n\nexport interface RecordingStartedEvent extends DeprecatedEmbeddedEventMessage {\n event: \"recordingStarted\";\n}\n\nexport interface RecordingStoppedEvent extends DeprecatedEmbeddedEventMessage {\n event: \"recordingStopped\";\n}\n\nexport interface DocumentGeneratedEvent extends DeprecatedEmbeddedEventMessage {\n event: \"documentGenerated\";\n}\n\nexport interface DocumentUpdatedEvent extends DeprecatedEmbeddedEventMessage {\n event: \"documentUpdated\";\n}\n\nexport interface DocumentSyncedEvent extends DeprecatedEmbeddedEventMessage {\n event: \"documentSynced\";\n}\n\nexport interface AuthChangedEvent extends DeprecatedEmbeddedEventMessage {\n event: \"authChanged\";\n}\n\nexport interface InteractionCreatedEvent extends DeprecatedEmbeddedEventMessage {\n event: \"interactionCreated\";\n}\n\nexport interface NavigationChangedEvent extends DeprecatedEmbeddedEventMessage {\n event: \"navigationChanged\";\n}\n\nexport interface UsageEvent extends DeprecatedEmbeddedEventMessage {\n event: \"usage\";\n}\n\n// Request/Response/Event type unions\nexport type AnyEmbeddedRequest =\n | AuthRequest\n | CreateInteractionRequest\n | AddFactsRequest\n | ConfigureAppRequest\n | ConfigureSessionRequest\n | GetTemplatesRequest\n | NavigateRequest\n | SetInteractionOptionsRequest\n | StartRecordingRequest\n | StopRecordingRequest\n | GetStatusRequest\n | ConfigureRequest\n | SetCredentialsRequest\n | ShowDeviceLinkQRRequest;\n\nexport type AnyEmbeddedResponse = EmbeddedResponse;\n\nexport type AnyDeprecatedEmbeddedEvent =\n | ReadyEvent\n | LoadedEvent\n | RecordingStartedEvent\n | RecordingStoppedEvent\n | DocumentGeneratedEvent\n | DocumentUpdatedEvent\n | DocumentSyncedEvent\n | AuthChangedEvent\n | InteractionCreatedEvent\n | NavigationChangedEvent\n | UsageEvent;\n\nexport type AnyEvent = EmbeddedEventMessage | AnyDeprecatedEmbeddedEvent;\n\nexport type AnyEmbeddedMessage =\n | AnyEmbeddedRequest\n | AnyEmbeddedResponse\n | AnyEvent;\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AppearanceConfig, ConfigureFeaturesConfig, LocaleConfig, NetworkConfig, UIConfig } from "./config.js";
|
|
1
|
+
import type { AppearanceConfig, CompanionAppConfig, ConfigureFeaturesConfig, LocaleConfig, NetworkConfig, UIConfig } from "./config.js";
|
|
2
2
|
import type { EmbeddedInterviewDetails } from "./generated/interview-details.js";
|
|
3
3
|
export interface UserInfo {
|
|
4
4
|
id: string;
|
|
@@ -18,12 +18,20 @@ export interface EmbeddedTemplate {
|
|
|
18
18
|
id: string;
|
|
19
19
|
name: string;
|
|
20
20
|
description?: string;
|
|
21
|
+
templateType?: "built-in" | "custom" | "schema-driven";
|
|
21
22
|
language: {
|
|
22
23
|
code: string;
|
|
23
24
|
name: string;
|
|
24
25
|
locale?: string;
|
|
26
|
+
localName?: string;
|
|
25
27
|
};
|
|
26
|
-
|
|
28
|
+
outputLanguages?: Array<{
|
|
29
|
+
code: string;
|
|
30
|
+
name: string;
|
|
31
|
+
locale?: string;
|
|
32
|
+
hasPreview: boolean;
|
|
33
|
+
}>;
|
|
34
|
+
sections?: Array<{
|
|
27
35
|
id: string;
|
|
28
36
|
title: string;
|
|
29
37
|
}>;
|
|
@@ -51,6 +59,10 @@ export interface ConfigureAppResponse {
|
|
|
51
59
|
debug?: boolean;
|
|
52
60
|
appearance: AppearanceConfig;
|
|
53
61
|
ui: UIConfig;
|
|
62
|
+
companionApp: CompanionAppConfig;
|
|
54
63
|
locale: LocaleConfig;
|
|
55
64
|
network: NetworkConfig;
|
|
56
65
|
}
|
|
66
|
+
export interface ShowDeviceLinkQRResponse {
|
|
67
|
+
status: "approved" | "denied" | "expired" | "dismissed";
|
|
68
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"responses.js","sourceRoot":"","sources":["../../src/types/responses.ts"],"names":[],"mappings":"AAAA,kCAAkC","sourcesContent":["// Response types for embedded API\n\nimport type {\n AppearanceConfig,\n ConfigureFeaturesConfig,\n LocaleConfig,\n NetworkConfig,\n UIConfig,\n} from \"./config.js\";\nimport type { EmbeddedInterviewDetails } from \"./generated/interview-details.js\";\n\nexport interface UserInfo {\n id: string;\n email: string;\n name?: string;\n [key: string]: unknown;\n}\n\nexport interface AuthResponse {\n user: UserInfo;\n}\n\nexport interface CreateInteractionResponse {\n id: string;\n createdAt: string;\n status?: string;\n}\n\nexport interface EmbeddedTemplate {\n id: string;\n name: string;\n description?: string;\n language: {\n code: string;\n name: string;\n locale?: string;\n };\n
|
|
1
|
+
{"version":3,"file":"responses.js","sourceRoot":"","sources":["../../src/types/responses.ts"],"names":[],"mappings":"AAAA,kCAAkC","sourcesContent":["// Response types for embedded API\n\nimport type {\n AppearanceConfig,\n CompanionAppConfig,\n ConfigureFeaturesConfig,\n LocaleConfig,\n NetworkConfig,\n UIConfig,\n} from \"./config.js\";\nimport type { EmbeddedInterviewDetails } from \"./generated/interview-details.js\";\n\nexport interface UserInfo {\n id: string;\n email: string;\n name?: string;\n [key: string]: unknown;\n}\n\nexport interface AuthResponse {\n user: UserInfo;\n}\n\nexport interface CreateInteractionResponse {\n id: string;\n createdAt: string;\n status?: string;\n}\n\nexport interface EmbeddedTemplate {\n id: string;\n name: string;\n description?: string;\n templateType?: \"built-in\" | \"custom\" | \"schema-driven\";\n language: {\n code: string;\n name: string;\n locale?: string;\n localName?: string;\n };\n outputLanguages?: Array<{\n code: string;\n name: string;\n locale?: string;\n hasPreview: boolean;\n }>;\n sections?: Array<{\n id: string;\n title: string;\n }>;\n isCustom: boolean;\n}\n\nexport interface GetStatusResponse {\n auth: {\n isAuthenticated: boolean;\n user?: UserInfo;\n };\n currentUrl: string;\n interaction: EmbeddedInterviewDetails | null;\n}\n\nexport interface GetTemplatesResponse {\n templates: EmbeddedTemplate[];\n}\n\nexport interface ConfigureResponse {\n debug?: boolean;\n appearance: AppearanceConfig;\n features: ConfigureFeaturesConfig;\n locale: LocaleConfig;\n network: NetworkConfig;\n}\n\nexport interface ConfigureAppResponse {\n debug?: boolean;\n appearance: AppearanceConfig;\n ui: UIConfig;\n companionApp: CompanionAppConfig;\n locale: LocaleConfig;\n network: NetworkConfig;\n}\n\nexport interface ShowDeviceLinkQRResponse {\n status: \"approved\" | \"denied\" | \"expired\" | \"dismissed\";\n}\n"]}
|
package/dist/web-bundle.js
CHANGED
|
@@ -1537,6 +1537,31 @@ var CortiEmbedded = class _CortiEmbedded extends i4 {
|
|
|
1537
1537
|
throw new Error(JSON.stringify(formattedError));
|
|
1538
1538
|
}
|
|
1539
1539
|
}
|
|
1540
|
+
/**
|
|
1541
|
+
* Show the device-link QR code in the embedded UI
|
|
1542
|
+
* @param payload Device-link token response to render as a QR code
|
|
1543
|
+
* @returns Promise resolving to the rendered QR code state
|
|
1544
|
+
*/
|
|
1545
|
+
async showDeviceLinkQR(payload) {
|
|
1546
|
+
if (!this.postMessageHandler) {
|
|
1547
|
+
throw new Error("Component not ready");
|
|
1548
|
+
}
|
|
1549
|
+
try {
|
|
1550
|
+
const response = await this.postMessageHandler.postMessage({
|
|
1551
|
+
type: "CORTI_EMBEDDED",
|
|
1552
|
+
version: "v1",
|
|
1553
|
+
action: "showDeviceLinkQR",
|
|
1554
|
+
payload
|
|
1555
|
+
});
|
|
1556
|
+
if (response.success && response.payload) {
|
|
1557
|
+
return response.payload;
|
|
1558
|
+
}
|
|
1559
|
+
throw new Error(response.error);
|
|
1560
|
+
} catch (error) {
|
|
1561
|
+
const formattedError = formatError(error, "Failed to show device link QR");
|
|
1562
|
+
throw new Error(JSON.stringify(formattedError));
|
|
1563
|
+
}
|
|
1564
|
+
}
|
|
1540
1565
|
/**
|
|
1541
1566
|
* Check the current status of the iframe and PostMessageHandler
|
|
1542
1567
|
* Useful for debugging
|