@bootstrapware/answers 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +245 -0
- package/CHANGELOG.md +14 -0
- package/LICENSE +21 -0
- package/README.md +60 -0
- package/dist/answers.iife.js +72 -0
- package/dist/answers.iife.js.map +1 -0
- package/dist/index.d.ts +78 -0
- package/dist/index.js +629 -0
- package/dist/index.js.map +1 -0
- package/dist/styles.css +621 -0
- package/package.json +61 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
|
|
3
|
+
declare const QUESTION_MAX = 1000;
|
|
4
|
+
declare const WIDGET_ROOT_CLASS = "bsw-an";
|
|
5
|
+
type AnswersPageContext = {
|
|
6
|
+
url?: string;
|
|
7
|
+
title?: string;
|
|
8
|
+
};
|
|
9
|
+
type AnswersCitation = {
|
|
10
|
+
id: string;
|
|
11
|
+
title: string;
|
|
12
|
+
url?: string;
|
|
13
|
+
excerpt?: string;
|
|
14
|
+
};
|
|
15
|
+
type AnswersOutcome = "answered" | "unanswered";
|
|
16
|
+
type AnswersAskInput = {
|
|
17
|
+
sessionId: string;
|
|
18
|
+
question: string;
|
|
19
|
+
pageContext?: AnswersPageContext;
|
|
20
|
+
};
|
|
21
|
+
type AnswersResult = {
|
|
22
|
+
sessionId: string;
|
|
23
|
+
answerId: string;
|
|
24
|
+
outcome: AnswersOutcome;
|
|
25
|
+
answer?: string;
|
|
26
|
+
citations?: AnswersCitation[];
|
|
27
|
+
fallback?: string;
|
|
28
|
+
};
|
|
29
|
+
type AnswersFeedbackInput = {
|
|
30
|
+
sessionId: string;
|
|
31
|
+
answerId: string;
|
|
32
|
+
helpful: boolean;
|
|
33
|
+
/** Optional note. Webhook payloads omit this text. */
|
|
34
|
+
reason?: string;
|
|
35
|
+
};
|
|
36
|
+
type AnswersAdapter = {
|
|
37
|
+
ask: (input: AnswersAskInput) => Promise<AnswersResult>;
|
|
38
|
+
feedback?: (input: AnswersFeedbackInput) => Promise<void> | void;
|
|
39
|
+
};
|
|
40
|
+
type AnswersPresentation = "launcher" | "section" | "modal" | "window";
|
|
41
|
+
type AnswersTheme = "light" | "dark";
|
|
42
|
+
type AnswersProps = {
|
|
43
|
+
appId?: string;
|
|
44
|
+
publishableKey?: string;
|
|
45
|
+
adapter?: AnswersAdapter;
|
|
46
|
+
presentation?: AnswersPresentation;
|
|
47
|
+
defaultOpen?: boolean;
|
|
48
|
+
theme?: AnswersTheme;
|
|
49
|
+
pageContext?: AnswersPageContext;
|
|
50
|
+
onFallback?: (result: AnswersResult) => void;
|
|
51
|
+
/** Layout hook only. Skin the widget with the `--bsw-an-*` tokens. */
|
|
52
|
+
className?: string;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
declare function Answers(props: AnswersProps): react.JSX.Element;
|
|
56
|
+
|
|
57
|
+
declare const LOCAL_FALLBACK = "We could not find that in the Northwind Outfitters sample. Ask about hours, returns, or shipping.";
|
|
58
|
+
declare const LOCAL_PROMPTS: {
|
|
59
|
+
readonly returns: "What is your return window?";
|
|
60
|
+
readonly returnsFollowUp: "How long do I have?";
|
|
61
|
+
readonly hours: "What are your hours?";
|
|
62
|
+
readonly shipping: "Is shipping free?";
|
|
63
|
+
readonly unsupported: "Do you price match?";
|
|
64
|
+
};
|
|
65
|
+
type Topic = "hours" | "returns" | "shipping";
|
|
66
|
+
declare const LOCAL_CITATIONS: Record<Topic, AnswersCitation>;
|
|
67
|
+
/**
|
|
68
|
+
* Deterministic sample company. Supported facts, a follow-up that needs the
|
|
69
|
+
* previous topic, and an explicit unanswered fallback. No network.
|
|
70
|
+
*/
|
|
71
|
+
declare function createLocalAdapter(): AnswersAdapter;
|
|
72
|
+
/** Returns the caller adapter. Question text stays on the customer backend. */
|
|
73
|
+
declare function createByoAdapter(impl: AnswersAdapter): AnswersAdapter;
|
|
74
|
+
|
|
75
|
+
declare function mount(el: Element, props?: AnswersProps): () => void;
|
|
76
|
+
declare function unmount(el: Element): void;
|
|
77
|
+
|
|
78
|
+
export { Answers, type AnswersAdapter, type AnswersAskInput, type AnswersCitation, type AnswersFeedbackInput, type AnswersOutcome, type AnswersPageContext, type AnswersPresentation, type AnswersProps, type AnswersResult, type AnswersTheme, LOCAL_CITATIONS, LOCAL_FALLBACK, LOCAL_PROMPTS, QUESTION_MAX, WIDGET_ROOT_CLASS, createByoAdapter, createLocalAdapter, mount, unmount };
|