@constructor-io/constructorio-ui-asa 1.0.0 → 1.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/lib/cjs/components/Chat/Chat.js +10 -1
- package/lib/cjs/components/Chat/ChatMessageList.js +1 -1
- package/lib/cjs/components/Chat/WelcomeScreen.js +3 -2
- package/lib/cjs/components/CioAsaProvider/CioAsaProvider.js +4 -2
- package/lib/cjs/components/ResultsBlock/ResultsBlock.js +13 -38
- package/lib/cjs/components/ResultsBlock/ResultsGroup.js +109 -0
- package/lib/cjs/hooks/asaStreamHandlers.js +3 -1
- package/lib/cjs/hooks/useAsaResults.js +69 -14
- package/lib/cjs/hooks/useAsaTracking.js +66 -0
- package/lib/cjs/hooks/useViewportTracking.js +39 -0
- package/lib/cjs/index.js +3 -1
- package/lib/cjs/utils/productNormalizer.js +2 -11
- package/lib/cjs/version.js +1 -1
- package/lib/mjs/components/Chat/Chat.js +10 -1
- package/lib/mjs/components/Chat/ChatMessageList.js +1 -1
- package/lib/mjs/components/Chat/WelcomeScreen.js +3 -2
- package/lib/mjs/components/CioAsaProvider/CioAsaProvider.js +4 -2
- package/lib/mjs/components/ResultsBlock/ResultsBlock.js +12 -45
- package/lib/mjs/components/ResultsBlock/ResultsGroup.js +117 -0
- package/lib/mjs/hooks/asaStreamHandlers.js +8 -1
- package/lib/mjs/hooks/useAsaResults.js +62 -10
- package/lib/mjs/hooks/useAsaTracking.js +91 -0
- package/lib/mjs/hooks/useViewportTracking.js +36 -0
- package/lib/mjs/index.js +1 -0
- package/lib/mjs/utils/productNormalizer.js +1 -0
- package/lib/mjs/version.js +1 -1
- package/lib/types/components/Chat/WelcomeScreen.d.ts +2 -2
- package/lib/types/components/ResultsBlock/ResultsBlock.d.ts +4 -1
- package/lib/types/components/ResultsBlock/ResultsGroup.d.ts +36 -0
- package/lib/types/hooks/useAsaTracking.d.ts +54 -0
- package/lib/types/hooks/useViewportTracking.d.ts +15 -0
- package/lib/types/index.d.ts +3 -1
- package/lib/types/types.d.ts +63 -1
- package/lib/types/utils/productNormalizer.d.ts +1 -0
- package/lib/types/version.d.ts +1 -1
- package/package.json +5 -5
package/lib/types/index.d.ts
CHANGED
|
@@ -6,7 +6,9 @@ export type { AspectRatio } from './components/ResultsBlock/ResultsBlock';
|
|
|
6
6
|
export { default as Button } from './components/Button/Button';
|
|
7
7
|
export type { ButtonProps } from './components/Button/Button';
|
|
8
8
|
export { default as useAsaResults } from './hooks/useAsaResults';
|
|
9
|
+
export { default as useAsaTracking } from './hooks/useAsaTracking';
|
|
10
|
+
export type { UseAsaTrackingProps, UseAsaTrackingReturn } from './hooks/useAsaTracking';
|
|
9
11
|
export { normalizeItemToProduct } from './utils/productNormalizer';
|
|
10
12
|
export type { Product, NormalizeOptions } from './utils/productNormalizer';
|
|
11
13
|
export { ConstructorIOClient } from './types';
|
|
12
|
-
export type { Nullable, CioAsaProviderProps, AsaContextValue, CioClientOptions, RequestConfigs, Formatters, UrlHelpers, QueryParamEncodingOptions, DefaultQueryStringMap, Translations, ChatMessage, ChatMessageStatus, ResultGroup, ResultGroupMeta, UseChatReturn, ChatComponentOverrides, WelcomeScreenOverrides, ChatInputOverrides, AiMessageOverrides, ResultsBlockOverrides, ComponentOverrideProps, IncludeComponentOverrides, ChatHeaderRenderProps, ChatInputRenderProps, WelcomeScreenTitleRenderProps, WelcomeScreenInputRenderProps, SuggestedQuestionsRenderProps, UserMessageRenderProps, AiMessageLoaderRenderProps, AiMessageTextRenderProps, ResultsGroupTitleRenderProps, ResultsViewMoreRenderProps, } from './types';
|
|
14
|
+
export type { Nullable, CioAsaProviderProps, AsaContextValue, CioClientOptions, RequestConfigs, Formatters, UrlHelpers, QueryParamEncodingOptions, DefaultQueryStringMap, Translations, ChatMessage, ChatMessageStatus, ResultGroup, ResultGroupMeta, UseChatReturn, AsaCallbacks, AssistantSubmitSource, AssistantTrackedItem, ChatComponentOverrides, WelcomeScreenOverrides, ChatInputOverrides, AiMessageOverrides, ResultsBlockOverrides, ComponentOverrideProps, IncludeComponentOverrides, ChatHeaderRenderProps, ChatInputRenderProps, WelcomeScreenTitleRenderProps, WelcomeScreenInputRenderProps, SuggestedQuestionsRenderProps, UserMessageRenderProps, AiMessageLoaderRenderProps, AiMessageTextRenderProps, ResultsGroupTitleRenderProps, ResultsViewMoreRenderProps, } from './types';
|
package/lib/types/types.d.ts
CHANGED
|
@@ -19,6 +19,8 @@ export interface AsaContextValue {
|
|
|
19
19
|
staticRequestConfigs: RequestConfigs;
|
|
20
20
|
formatters: Formatters;
|
|
21
21
|
urlHelpers: UrlHelpers;
|
|
22
|
+
callbacks?: AsaCallbacks;
|
|
23
|
+
section?: string;
|
|
22
24
|
}
|
|
23
25
|
export interface RequestConfigs extends IAgentParameters {
|
|
24
26
|
intent?: string;
|
|
@@ -65,6 +67,9 @@ export interface ChatMessage {
|
|
|
65
67
|
text: string;
|
|
66
68
|
groups?: ResultGroup[];
|
|
67
69
|
status: ChatMessageStatus;
|
|
70
|
+
intent?: string;
|
|
71
|
+
intentResultId?: string;
|
|
72
|
+
threadId?: string;
|
|
68
73
|
}
|
|
69
74
|
export type ChatMessageStatus = 'idle' | 'loading' | 'streaming' | 'done' | 'error';
|
|
70
75
|
export interface ResultGroupMeta {
|
|
@@ -78,13 +83,70 @@ export interface ResultGroupMeta {
|
|
|
78
83
|
export interface ResultGroup {
|
|
79
84
|
group: ResultGroupMeta;
|
|
80
85
|
searchResults: Record<string, unknown>[];
|
|
86
|
+
searchResultId?: string;
|
|
87
|
+
intentResultId?: string;
|
|
81
88
|
}
|
|
82
89
|
export interface UseChatReturn {
|
|
83
90
|
messages: ChatMessage[];
|
|
84
|
-
sendMessage: (text: string) => void;
|
|
91
|
+
sendMessage: (text: string, source?: AssistantSubmitSource) => void;
|
|
85
92
|
isStreaming: boolean;
|
|
86
93
|
clearHistory: () => void;
|
|
87
94
|
}
|
|
95
|
+
/** How an intent was submitted: typed into the input, or a suggestion chip clicked. */
|
|
96
|
+
export type AssistantSubmitSource = 'input' | 'suggestion';
|
|
97
|
+
/** An item within a viewed/clicked search_result pod. */
|
|
98
|
+
export interface AssistantTrackedItem {
|
|
99
|
+
itemId?: string;
|
|
100
|
+
itemName?: string;
|
|
101
|
+
variationId?: string;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Optional consumer callbacks fired alongside the built-in behavioral tracking.
|
|
105
|
+
* Each fires immediately after its corresponding `trackAssistant*` beacon is sent,
|
|
106
|
+
* so consumers can mirror ASA analytics into their own systems. All are optional.
|
|
107
|
+
*/
|
|
108
|
+
export interface AsaCallbacks {
|
|
109
|
+
/** User submitted an intent (typed) or clicked a suggestion. */
|
|
110
|
+
onAssistantSubmit?: (payload: {
|
|
111
|
+
intent: string;
|
|
112
|
+
source: AssistantSubmitSource;
|
|
113
|
+
}) => void;
|
|
114
|
+
/** The ASA response stream started. */
|
|
115
|
+
onResultLoadStart?: (payload: {
|
|
116
|
+
intent: string;
|
|
117
|
+
intentResultId?: string;
|
|
118
|
+
}) => void;
|
|
119
|
+
/** The ASA response stream finished; `searchResultCount` = number of pods loaded. */
|
|
120
|
+
onResultLoadFinish?: (payload: {
|
|
121
|
+
intent: string;
|
|
122
|
+
searchResultCount: number;
|
|
123
|
+
intentResultId?: string;
|
|
124
|
+
}) => void;
|
|
125
|
+
/** A product inside a search_result pod was clicked. */
|
|
126
|
+
onResultClick?: (payload: {
|
|
127
|
+
intent: string;
|
|
128
|
+
searchResultId: string;
|
|
129
|
+
intentResultId?: string;
|
|
130
|
+
item: AssistantTrackedItem;
|
|
131
|
+
}) => void;
|
|
132
|
+
/** A search_result pod scrolled into view. */
|
|
133
|
+
onResultView?: (payload: {
|
|
134
|
+
intent: string;
|
|
135
|
+
searchResultId: string;
|
|
136
|
+
intentResultId?: string;
|
|
137
|
+
numResultsViewed: number;
|
|
138
|
+
items?: AssistantTrackedItem[];
|
|
139
|
+
}) => void;
|
|
140
|
+
/** A search query inside a search_result pod was submitted (e.g. "View more"). */
|
|
141
|
+
onSearchSubmit?: (payload: {
|
|
142
|
+
intent: string;
|
|
143
|
+
searchTerm: string;
|
|
144
|
+
userInput: string;
|
|
145
|
+
searchResultId: string;
|
|
146
|
+
intentResultId?: string;
|
|
147
|
+
groupId?: string;
|
|
148
|
+
}) => void;
|
|
149
|
+
}
|
|
88
150
|
/**
|
|
89
151
|
* Translations type for internationalizing UI strings.
|
|
90
152
|
* All keys are optional — any non-provided translation will fall back to the English default.
|
package/lib/types/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "1.
|
|
1
|
+
declare const _default: "1.1.0";
|
|
2
2
|
export default _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constructor-io/constructorio-ui-asa",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Constructor.io AI Shopping Agent UI library for web applications",
|
|
5
5
|
"author": "constructor.io",
|
|
6
6
|
"license": "MIT",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"prepare": "husky install"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
|
-
"@constructor-io/constructorio-client-javascript": "^2.
|
|
72
|
+
"@constructor-io/constructorio-client-javascript": "^2.91.0",
|
|
73
73
|
"@constructor-io/constructorio-ui-components": "^1.6.0",
|
|
74
74
|
"react": ">=16.12.0",
|
|
75
75
|
"react-dom": ">=16.12.0",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
79
|
"@axe-core/react": "^4.7.0",
|
|
80
|
-
"@constructor-io/constructorio-client-javascript": "^2.
|
|
80
|
+
"@constructor-io/constructorio-client-javascript": "^2.91.0",
|
|
81
81
|
"@constructor-io/constructorio-ui-components": "^1.6.0",
|
|
82
82
|
"@babel/preset-env": "^7.28.3",
|
|
83
83
|
"@babel/preset-react": "^7.27.1",
|
|
@@ -132,8 +132,8 @@
|
|
|
132
132
|
},
|
|
133
133
|
"dependencies": {},
|
|
134
134
|
"overrides": {
|
|
135
|
-
"brace-expansion@1": "1.1.
|
|
136
|
-
"brace-expansion@2": "2.1.
|
|
135
|
+
"brace-expansion@1": "1.1.18",
|
|
136
|
+
"brace-expansion@2": "2.1.4",
|
|
137
137
|
"minimatch@9": "9.0.9",
|
|
138
138
|
"form-data": "4.0.6",
|
|
139
139
|
"joi": "17.13.4",
|