@snf/qa-bot-core 0.2.36 → 0.2.37

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.
@@ -1,8 +1,9 @@
1
1
  import React from 'react';
2
+ export type TurnstileWidgetFailureReason = 'widget_error' | 'token_expired' | 'script_load_failed' | 'api_unavailable' | 'user_cancelled';
2
3
  interface TurnstileWidgetProps {
3
4
  siteKey: string;
4
5
  onVerify: (token: string) => void;
5
- onError?: () => void;
6
+ onError?: (reason: TurnstileWidgetFailureReason, errorCode?: string) => void;
6
7
  loginUrl?: string;
7
8
  }
8
9
  /**
@@ -1,9 +1,9 @@
1
- export default BaseIcon;
2
- declare function BaseIcon({ width, height, color, children, ...props }: {
3
- [x: string]: any;
4
- width?: number;
5
- height?: number;
6
- color?: string;
7
- children: any;
8
- }): React.JSX.Element;
9
1
  import React from 'react';
2
+ interface BaseIconProps extends React.SVGAttributes<SVGSVGElement> {
3
+ width?: number | string;
4
+ height?: number | string;
5
+ color?: string;
6
+ children?: React.ReactNode;
7
+ }
8
+ declare const BaseIcon: React.FC<BaseIconProps>;
9
+ export default BaseIcon;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const HomeIcon: React.FC<React.SVGAttributes<SVGSVGElement>>;
3
+ export default HomeIcon;
@@ -1,3 +1,3 @@
1
- export default RefreshIcon;
2
- declare function RefreshIcon(props: any): React.JSX.Element;
3
1
  import React from 'react';
2
+ declare const RefreshIcon: React.FC<React.SVGAttributes<SVGSVGElement>>;
3
+ export default RefreshIcon;
@@ -1,3 +1,3 @@
1
- export default UploadIcon;
2
- declare function UploadIcon(props: any): React.JSX.Element;
3
1
  import React from 'react';
2
+ declare const UploadIcon: React.FC<React.SVGAttributes<SVGSVGElement>>;
3
+ export default UploadIcon;
@@ -2,7 +2,7 @@ import type { Settings, Flow } from 'react-chatbotify';
2
2
  /**
3
3
  * Analytics event types fired by qa-bot-core
4
4
  */
5
- export type QABotAnalyticsEventType = 'chatbot_open' | 'chatbot_close' | 'chatbot_new_chat' | 'chatbot_question_sent' | 'chatbot_answer_received' | 'chatbot_answer_error' | 'chatbot_rating_sent' | 'chatbot_login_prompt_shown' | 'chatbot_login_clicked' | 'chatbot_link_clicked' | 'chatbot_turnstile_shown' | 'chatbot_turnstile_completed' | 'chatbot_turnstile_error';
5
+ export type QABotAnalyticsEventType = 'chatbot_open' | 'chatbot_close' | 'chatbot_new_chat' | 'chatbot_question_sent' | 'chatbot_answer_received' | 'chatbot_answer_error' | 'chatbot_rating_sent' | 'chatbot_login_prompt_shown' | 'chatbot_login_clicked' | 'chatbot_link_clicked' | 'chatbot_turnstile_shown' | 'chatbot_turnstile_completed' | 'chatbot_turnstile_error' | 'chatbot_turnstile_silent_failed';
6
6
  /**
7
7
  * Analytics event payload
8
8
  *
@@ -23,6 +23,10 @@ export type QABotAnalyticsEventType = 'chatbot_open' | 'chatbot_close' | 'chatbo
23
23
  * - chatbot_login_prompt_shown: (common fields only)
24
24
  * - chatbot_login_clicked: loginUrl
25
25
  * - chatbot_link_clicked: linkUrl, linkText
26
+ * - chatbot_turnstile_shown: queryId — visible challenge displayed to user
27
+ * - chatbot_turnstile_completed: queryId — user solved visible challenge
28
+ * - chatbot_turnstile_error: queryId, failureReason — visible challenge failed
29
+ * - chatbot_turnstile_silent_failed: failureReason — silent verification failed on page load
26
30
  */
27
31
  export interface QABotAnalyticsEvent {
28
32
  type: QABotAnalyticsEventType;
@@ -37,6 +41,8 @@ export interface QABotAnalyticsEvent {
37
41
  responseLength?: number;
38
42
  hasMetadata?: boolean;
39
43
  errorType?: string;
44
+ failureReason?: 'widget_error' | 'token_expired' | 'script_load_failed' | 'api_unavailable' | 'user_cancelled';
45
+ cloudflareErrorCode?: string;
40
46
  rating?: 'helpful' | 'not_helpful';
41
47
  messageCount?: number;
42
48
  durationMs?: number;
@@ -14,6 +14,7 @@
14
14
  * `refresh-expired: auto` handles re-issuing before expiry.
15
15
  */
16
16
  export type TurnstileStatus = 'idle' | 'loading' | 'verified' | 'failed';
17
+ export type TurnstileFailureReason = 'widget_error' | 'token_expired' | 'script_load_failed' | 'api_unavailable' | 'user_cancelled';
17
18
  export interface UseTurnstileResult {
18
19
  /** Current Turnstile token, or null if not yet verified / failed. */
19
20
  token: string | null;
@@ -22,8 +23,15 @@ export interface UseTurnstileResult {
22
23
  /** Reset the widget to generate a fresh token (call after each successful use). */
23
24
  reset: () => void;
24
25
  }
26
+ interface TurnstileAnalyticsEvent {
27
+ type: 'chatbot_turnstile_silent_failed';
28
+ failureReason: TurnstileFailureReason;
29
+ cloudflareErrorCode?: string;
30
+ }
25
31
  /**
26
32
  * @param siteKey Cloudflare Turnstile site key. Pass `undefined` or empty
27
33
  * string to disable (hook becomes a no-op).
34
+ * @param onEvent Optional analytics callback for silent verification failures.
28
35
  */
29
- export declare function useTurnstile(siteKey: string | undefined): UseTurnstileResult;
36
+ export declare function useTurnstile(siteKey: string | undefined, onEvent?: (event: TurnstileAnalyticsEvent) => void): UseTurnstileResult;
37
+ export {};
@@ -16,8 +16,9 @@ export interface CreateQAFlowParams {
16
16
  sessionId: () => string | null;
17
17
  /** Function that returns whether we're currently resetting */
18
18
  isResetting?: () => boolean;
19
- /** Whether the user is logged in (required) */
20
- isLoggedIn: boolean;
19
+ /** Whether the user is logged in. `undefined` means "open access mode" —
20
+ * treated as logged-in for gating purposes. */
21
+ isLoggedIn?: boolean;
21
22
  /** Allow Q&A without login (default: false) */
22
23
  allowAnonAccess?: boolean;
23
24
  /** Login URL to redirect to (optional) */
@@ -59,7 +60,7 @@ export declare const createQAFlow: ({ endpoint, ratingEndpoint, agentRatingEndpo
59
60
  };
60
61
  } | {
61
62
  qa_loop: {
62
- message: (chatState: any) => Promise<"Thanks for the feedback!" | "One moment — verifying your session…" | "I apologize, but I'm having trouble processing your question. Please try again later.">;
63
+ message: (chatState: any) => Promise<"Thanks for the feedback!" | "One moment — verifying your session…" | "I apologize, but I'm having trouble processing your question. Please try again later." | undefined>;
63
64
  options: (chatState: any) => string[];
64
65
  renderMarkdown: string[];
65
66
  chatDisabled: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snf/qa-bot-core",
3
- "version": "0.2.36",
3
+ "version": "0.2.37",
4
4
  "description": "A configurable chatbot setup for quick integration of RAG-powered Q&A and rating system",
5
5
  "main": "./dist/qa-bot-core.umd.cjs",
6
6
  "module": "./dist/qa-bot-core.js",
@@ -19,8 +19,8 @@
19
19
  ],
20
20
  "dependencies": {
21
21
  "@rcb-plugins/html-renderer": "^0.3.1",
22
- "@rcb-plugins/markdown-renderer": "^0.3.1",
23
22
  "@rcb-plugins/input-validator": "^0.3.0",
23
+ "@rcb-plugins/markdown-renderer": "^0.3.1",
24
24
  "react-chatbotify": "^2.5.0",
25
25
  "uuid": "^11.1.0"
26
26
  },