@gengage/assistant-fe 0.4.19 → 0.4.21

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.
Files changed (155) hide show
  1. package/dist/api-paths-Bg6iwO5w.js +1250 -0
  2. package/dist/chat-runtime.js +1 -1
  3. package/dist/chat.iife.js +17 -17
  4. package/dist/chat.js +1 -1
  5. package/dist/{common-Bpp43wr0.js → common-DDJSeQhg.js} +2 -2
  6. package/dist/common.js +79 -77
  7. package/dist/{connection-warning-C7ehvQxx.js → connection-warning-BeD-B0Ec.js} +1 -1
  8. package/dist/{fastIntent-CINRmM8r.js → fastIntent-BeeDIwd2.js} +1 -1
  9. package/dist/index.js +75 -73
  10. package/dist/native.iife.js +18 -18
  11. package/dist/qna-runtime.js +1 -1
  12. package/dist/qna.iife.js +22 -22
  13. package/dist/qna.js +1 -1
  14. package/dist/{runtime-B0hDHRlN.js → runtime-C8ZBidd2.js} +13 -13
  15. package/dist/{runtime-CLcYqzoA.js → runtime-CRSFPLku.js} +17 -17
  16. package/dist/{runtime-DhdfOJEN.js → runtime-Ct1qOl8V.js} +855 -848
  17. package/dist/{simbut-3kqLW3SM.js → simbut-BrAeZ6SH.js} +19 -22
  18. package/dist/simbut.iife.js +9 -9
  19. package/dist/simbut.js +1 -1
  20. package/dist/{simrel-fQg2EIB8.js → simrel-Cha5de6P.js} +1 -1
  21. package/dist/simrel-runtime.js +1 -1
  22. package/dist/simrel.iife.js +7 -7
  23. package/dist/simrel.js +2 -2
  24. package/dist/{widget-base-bdJaGJYi.js → widget-base-BtBl_PCR.js} +91 -83
  25. package/package.json +9 -5
  26. package/dist/api-paths-BX3Lea3A.js +0 -1213
  27. package/dist/chat/api.d.ts +0 -88
  28. package/dist/chat/assistant-mode.d.ts +0 -19
  29. package/dist/chat/attachment-utils.d.ts +0 -9
  30. package/dist/chat/catalog.d.ts +0 -826
  31. package/dist/chat/chat-presentation-state.d.ts +0 -53
  32. package/dist/chat/components/AIGroupingCards.d.ts +0 -3
  33. package/dist/chat/components/AISuggestedSearchCards.d.ts +0 -3
  34. package/dist/chat/components/AITopPicks.d.ts +0 -3
  35. package/dist/chat/components/BeautyPhotoStep.d.ts +0 -16
  36. package/dist/chat/components/CategoriesContainer.d.ts +0 -3
  37. package/dist/chat/components/ChatDrawer.d.ts +0 -360
  38. package/dist/chat/components/ChoicePrompter.d.ts +0 -21
  39. package/dist/chat/components/ComparisonTable.d.ts +0 -57
  40. package/dist/chat/components/ConsultingStylePicker.d.ts +0 -34
  41. package/dist/chat/components/FloatingComparisonButton.d.ts +0 -2
  42. package/dist/chat/components/FloatingLauncher.d.ts +0 -79
  43. package/dist/chat/components/GroundingReviewCard.d.ts +0 -3
  44. package/dist/chat/components/HandoffNotice.d.ts +0 -4
  45. package/dist/chat/components/KvkkBanner.d.ts +0 -6
  46. package/dist/chat/components/Launcher.d.ts +0 -28
  47. package/dist/chat/components/PanelRestoreCard.d.ts +0 -4
  48. package/dist/chat/components/PanelTopBar.d.ts +0 -32
  49. package/dist/chat/components/PhotoAnalysisCard.d.ts +0 -20
  50. package/dist/chat/components/ProductSummaryCard.d.ts +0 -3
  51. package/dist/chat/components/ProsAndCons.d.ts +0 -8
  52. package/dist/chat/components/ReviewHighlights.d.ts +0 -9
  53. package/dist/chat/components/actionClassifier.d.ts +0 -12
  54. package/dist/chat/components/product-price-layout.d.ts +0 -18
  55. package/dist/chat/components/productMentionLinker.d.ts +0 -25
  56. package/dist/chat/components/renderUISpec.d.ts +0 -11
  57. package/dist/chat/components/typewriter.d.ts +0 -24
  58. package/dist/chat/extendedModeManager.d.ts +0 -32
  59. package/dist/chat/features/beauty-consulting/consulting-grid.d.ts +0 -31
  60. package/dist/chat/features/beauty-consulting/drawer-extensions.d.ts +0 -20
  61. package/dist/chat/features/beauty-consulting/mode-controller.d.ts +0 -53
  62. package/dist/chat/features/beauty-consulting/registry.d.ts +0 -3
  63. package/dist/chat/features/beauty-consulting/stream-handler.d.ts +0 -38
  64. package/dist/chat/history-storage.d.ts +0 -85
  65. package/dist/chat/index.d.ts +0 -5
  66. package/dist/chat/kvkk.d.ts +0 -20
  67. package/dist/chat/locales/en.d.ts +0 -2
  68. package/dist/chat/locales/index.d.ts +0 -5
  69. package/dist/chat/locales/tr.d.ts +0 -2
  70. package/dist/chat/panel-manager.d.ts +0 -126
  71. package/dist/chat/runtime.d.ts +0 -399
  72. package/dist/chat/session-persistence.d.ts +0 -65
  73. package/dist/chat/stream-error-display.d.ts +0 -6
  74. package/dist/chat/types.d.ts +0 -543
  75. package/dist/chat/utils/chat-presentation-debug.d.ts +0 -19
  76. package/dist/chat/utils/get-chat-scroll-element.d.ts +0 -10
  77. package/dist/chat/utils/ui.d.ts +0 -10
  78. package/dist/common/action-router.d.ts +0 -26
  79. package/dist/common/activity-tracker.d.ts +0 -37
  80. package/dist/common/analytics-events.d.ts +0 -91
  81. package/dist/common/analytics.d.ts +0 -61
  82. package/dist/common/api-paths.d.ts +0 -15
  83. package/dist/common/client.d.ts +0 -27
  84. package/dist/common/communication-bridge.d.ts +0 -51
  85. package/dist/common/config-constants.d.ts +0 -1
  86. package/dist/common/config-schema.d.ts +0 -81
  87. package/dist/common/connection-warning.d.ts +0 -8
  88. package/dist/common/consulting-sources.d.ts +0 -9
  89. package/dist/common/context.d.ts +0 -27
  90. package/dist/common/css-escape.d.ts +0 -1
  91. package/dist/common/customization-factories.d.ts +0 -62
  92. package/dist/common/debug.d.ts +0 -13
  93. package/dist/common/events.d.ts +0 -46
  94. package/dist/common/fastIntent.d.ts +0 -1
  95. package/dist/common/ga-datalayer.d.ts +0 -89
  96. package/dist/common/global-error-toast.d.ts +0 -6
  97. package/dist/common/index.d.ts +0 -49
  98. package/dist/common/indexed-db.d.ts +0 -79
  99. package/dist/common/locale.d.ts +0 -1
  100. package/dist/common/native-webview.d.ts +0 -60
  101. package/dist/common/navigation.d.ts +0 -5
  102. package/dist/common/overlay.d.ts +0 -168
  103. package/dist/common/page-detect.d.ts +0 -30
  104. package/dist/common/pill-launcher.d.ts +0 -51
  105. package/dist/common/preflight.d.ts +0 -13
  106. package/dist/common/price-formatter.d.ts +0 -35
  107. package/dist/common/product-utils.d.ts +0 -35
  108. package/dist/common/protocol-adapter.d.ts +0 -105
  109. package/dist/common/renderer/dom.d.ts +0 -3
  110. package/dist/common/renderer/index.d.ts +0 -4
  111. package/dist/common/renderer/overrides.d.ts +0 -23
  112. package/dist/common/renderer/registry.d.ts +0 -2
  113. package/dist/common/renderer/types.d.ts +0 -19
  114. package/dist/common/safe-html.d.ts +0 -22
  115. package/dist/common/skeleton.d.ts +0 -8
  116. package/dist/common/streaming.d.ts +0 -37
  117. package/dist/common/suggested-search-keywords.d.ts +0 -18
  118. package/dist/common/theme-utils.d.ts +0 -15
  119. package/dist/common/tts-player.d.ts +0 -13
  120. package/dist/common/types.d.ts +0 -381
  121. package/dist/common/ui-theme.d.ts +0 -9
  122. package/dist/common/uuidv7.d.ts +0 -7
  123. package/dist/common/voice-input.d.ts +0 -74
  124. package/dist/common/widget-base.d.ts +0 -97
  125. package/dist/index.d.ts +0 -25
  126. package/dist/native/index.d.ts +0 -2
  127. package/dist/overlay.d.ts +0 -4
  128. package/dist/qna/api.d.ts +0 -23
  129. package/dist/qna/catalog.d.ts +0 -73
  130. package/dist/qna/components/ButtonRow.d.ts +0 -15
  131. package/dist/qna/components/TextInput.d.ts +0 -11
  132. package/dist/qna/components/renderUISpec.d.ts +0 -7
  133. package/dist/qna/index.d.ts +0 -3
  134. package/dist/qna/locales/en.d.ts +0 -2
  135. package/dist/qna/locales/index.d.ts +0 -5
  136. package/dist/qna/locales/tr.d.ts +0 -2
  137. package/dist/qna/normalize-ui-specs.d.ts +0 -15
  138. package/dist/qna/runtime.d.ts +0 -62
  139. package/dist/qna/types.d.ts +0 -98
  140. package/dist/simbut/index.d.ts +0 -22
  141. package/dist/simbut/locales.d.ts +0 -3
  142. package/dist/simbut/types.d.ts +0 -43
  143. package/dist/simrel/api.d.ts +0 -25
  144. package/dist/simrel/catalog.d.ts +0 -110
  145. package/dist/simrel/components/GroupTabs.d.ts +0 -24
  146. package/dist/simrel/components/ProductCard.d.ts +0 -19
  147. package/dist/simrel/components/ProductGrid.d.ts +0 -17
  148. package/dist/simrel/components/renderUISpec.d.ts +0 -7
  149. package/dist/simrel/index.d.ts +0 -5
  150. package/dist/simrel/locales/en.d.ts +0 -2
  151. package/dist/simrel/locales/index.d.ts +0 -5
  152. package/dist/simrel/locales/tr.d.ts +0 -2
  153. package/dist/simrel/renderers/default.d.ts +0 -40
  154. package/dist/simrel/runtime.d.ts +0 -59
  155. package/dist/simrel/types.d.ts +0 -141
@@ -1,97 +0,0 @@
1
- import { BaseWidgetConfig, GengageWidget, PageContext } from './types.js';
2
- import { AnalyticsInput } from './analytics.js';
3
- import { AnalyticsContext } from './analytics-events.js';
4
- type AnyHandler = (...args: unknown[]) => void;
5
- export declare abstract class BaseWidget<TConfig extends BaseWidgetConfig = BaseWidgetConfig> implements GengageWidget<TConfig> {
6
- protected config: TConfig;
7
- protected root: HTMLElement;
8
- protected isVisible: boolean;
9
- protected isInitialised: boolean;
10
- private readonly _handlers;
11
- private readonly _cleanups;
12
- private _ownsRoot;
13
- private _destroying;
14
- init(config: TConfig): Promise<void>;
15
- update(context: Partial<PageContext>): void;
16
- show(): void;
17
- hide(): void;
18
- destroy(): void;
19
- /**
20
- * Called at the end of destroy() to remove or clear the root node.
21
- * Subclasses that mount into a merchant-owned element (e.g. SimBut) should
22
- * override this to a no-op so the host page's DOM is never mutated.
23
- */
24
- protected _cleanupRoot(): void;
25
- on(event: string, handler: AnyHandler): () => void;
26
- /** Track a checkout start event. Called by host page to attribute checkout to widget interaction. */
27
- trackCheckout(type: 'start' | 'complete', data: {
28
- attribution_source: 'chat' | 'qna' | 'simrel';
29
- attribution_action_id: string;
30
- cart_value: number;
31
- currency: string;
32
- line_items: number;
33
- }): void;
34
- /** Track a metering summary event. Called by host page for session-level aggregation. */
35
- flushMeteringSummary(data: {
36
- meter_key: string;
37
- quantity: number;
38
- unit: string;
39
- }): void;
40
- protected abstract onInit(config: TConfig): Promise<void>;
41
- protected abstract onUpdate(context: Partial<PageContext>): void;
42
- protected abstract onShow(): void;
43
- protected abstract onHide(): void;
44
- protected abstract onDestroy(): void;
45
- /** Emit a widget event to all registered handlers. */
46
- protected emit(event: string, ...args: unknown[]): void;
47
- /** Register a cleanup function to run on destroy(). */
48
- protected addCleanup(fn: () => void): void;
49
- /** Track an analytics event (no-op if analyticsClient is not configured). */
50
- protected track(input: AnalyticsInput): void;
51
- /** Build the shared analytics context from widget config. */
52
- protected analyticsContext(): AnalyticsContext;
53
- private _resolveMount;
54
- private _applyTheme;
55
- }
56
- export interface ChatPublicAPI {
57
- open(options?: {
58
- state?: 'full' | 'half';
59
- initialMessage?: string;
60
- }): void;
61
- openWithAction(action: import('./types.js').ActionPayload, options?: {
62
- sku?: string;
63
- state?: 'full' | 'half';
64
- }): void;
65
- /** Send a user message programmatically (same as typing + submit). */
66
- sendMessage(text: string): void;
67
- /** Send a backend action programmatically. */
68
- sendAction(action: import('./types.js').ActionPayload, options?: {
69
- silent?: boolean;
70
- }): void;
71
- close(): void;
72
- saveSession(sessionId: string, sku: string): void;
73
- readonly isOpen: boolean;
74
- on(event: 'open' | 'close' | 'ready' | 'message' | 'error' | 'context-update' | 'destroy', handler: (...args: unknown[]) => void): () => void;
75
- trackCheckout(type: 'start' | 'complete', data: {
76
- attribution_source: 'chat' | 'qna' | 'simrel';
77
- attribution_action_id: string;
78
- cart_value: number;
79
- currency: string;
80
- line_items: number;
81
- }): void;
82
- flushMeteringSummary(data: {
83
- meter_key: string;
84
- quantity: number;
85
- unit: string;
86
- }): void;
87
- /**
88
- * Register a callback for a GA4 event name.
89
- * When the widget fires that event, the callback is invoked with the event detail.
90
- * Callbacks that return `false` or throw signal failure — the widget reacts accordingly
91
- * (e.g. showing an error message for add-to-cart failures).
92
- *
93
- * @returns unsubscribe function
94
- */
95
- addCallback(eventName: string, callback: (detail: Record<string, unknown>) => boolean | Promise<boolean>): () => void;
96
- }
97
- export {};
package/dist/index.d.ts DELETED
@@ -1,25 +0,0 @@
1
- /**
2
- * gengage-assistant-fe — top-level barrel export.
3
- *
4
- * Import the whole library:
5
- * import { GengageChat, GengageQNA, GengageSimRel, bootstrapSession } from '@gengage/assistant-fe';
6
- *
7
- * Or import individual widgets for smaller bundles:
8
- * import { GengageChat } from '@gengage/assistant-fe/chat';
9
- * import { GengageQNA } from '@gengage/assistant-fe/qna';
10
- * import { GengageSimRel } from '@gengage/assistant-fe/simrel';
11
- */
12
- export { GengageChat, createChatWidget } from './chat/index.js';
13
- export { GengageQNA, createQNAWidget } from './qna/index.js';
14
- export { GengageSimRel, createSimRelWidget, createSimRelRenderer } from './simrel/index.js';
15
- export { GengageSimBut, createSimButWidget } from './simbut/index.js';
16
- export { renderUISpec as renderChatUISpec, createDefaultChatUISpecRegistry, defaultChatUnknownUISpecRenderer, } from './chat/index.js';
17
- export { renderQnaUISpec, createDefaultQnaUISpecRegistry, defaultQnaUnknownUISpecRenderer } from './qna/index.js';
18
- export { renderSimRelUISpec, createDefaultSimRelUISpecRegistry, defaultSimRelUnknownUISpecRenderer, } from './simrel/index.js';
19
- export { bootstrapSession, updatePageContext, initOverlayWidgets, getOverlayWidgets, destroyOverlayWidgets, buildOverlayIdempotencyKey, detectNativeEnvironment, applyNativeSession, createNativeWebViewBridge, initNativeOverlayWidgets, wireQNAToChat, wireSimilarToChat, dispatch, listen, consumeStream, streamPost, buildChatEndpointUrl, normalizeMiddlewareUrl, routeStreamAction, createAnalyticsClient, renderUISpecWithRegistry, defaultUnknownUISpecRenderer, BASE_WIDGET_THEME, withBaseTheme, DEFAULT_WIDGET_THEME_TOKENS, withDefaultWidgetTheme, DEFAULT_CUSTOMIZATION_LOCALE, createAccountIdentity, createFloatingChatConfig, createPdpQnaConfig, createPdpSimRelConfig, createDefaultAnalyticsConfig, parseAccountRuntimeConfig, safeParseAccountRuntimeConfig, createDefaultAccountRuntimeConfig, AccountRuntimeConfigSchema, AnalyticsAuthModeSchema, UnknownActionPolicySchema, initGengageClient, preflightDiagnostics, wireGADataLayer, isVoiceInputSupported, VoiceInput, detectPageType, extractSkuFromUrl, autoDetectPageContext, configureConnectionWarning, makePillLauncher, } from './common/index.js';
20
- export type { PageContext, SessionContext, BaseWidgetConfig, GengageWidget, StreamEvent, UISpec, UIElement, ActionPayload, GengageEventName, ChatPublicAPI, ChatTransportConfig, ChatEndpointName, AccountRuntimeConfig, AnalyticsAuthMode, UnknownActionPolicy, HostActionHandlers, ActionRouterOptions, AnalyticsEnvelope, AnalyticsInput, AnalyticsAuthConfig, AnalyticsClientConfig, UISpecDomComponentRenderParams, UISpecDomComponentRenderer, UISpecDomRegistry, UISpecDomUnknownRendererParams, UISpecDomUnknownRenderer, RenderUISpecWithRegistryOptions, OverlayWidgetsController, OverlayWidgetsOptions, OverlayChatOptions, OverlayQNAOptions, OverlaySimRelOptions, OverlaySimButOptions, NativeBridgeEnvironment, NativeSessionPayload, NativeBridgeMessage, NativeWebViewBridgeOptions, NativeWebViewBridge, NativeOverlayInitOptions, NativeOverlayInitResult, AccountIdentityConfig, AccountIdentity, GengageClientOptions, HostActions, PreflightResult, PreflightWarning, WireQNAToChatOptions, VoiceInputState, VoiceInputErrorCode, VoiceInputCallbacks, VoiceInputOptions, DetectablePageType, PageDetectionRule, PillLauncherOptions, PillLauncherKit, } from './common/index.js';
21
- export type { ChatWidgetConfig, ChatMessage, ChatSession, ChatI18n, ChatRendererConfig, FloatingLauncherOptions, } from './chat/index.js';
22
- export type { ChatUISpecRegistry, UISpecRenderContext as ChatUISpecRenderContext } from './chat/index.js';
23
- export type { QNAWidgetConfig, QNAI18n, QNAChromeLayout, QNAChromeConfig, QNAUISpecRenderContext, QNAUISpecRegistry, QNARendererConfig, } from './qna/index.js';
24
- export type { SimRelWidgetConfig, SimilarProduct, SimRelI18n, SimRelUISpecRenderContext, SimRelUISpecRegistry, SimRelRendererConfig, SimRelFieldPath, SimRelRendererFields, SimRelRendererLabels, SimRelRendererMedia, SimRelRendererOptions, } from './simrel/index.js';
25
- export type { SimButWidgetConfig, SimButI18n, SimButInlineCardConfig, SimButLayout } from './simbut/index.js';
@@ -1,2 +0,0 @@
1
- export { DEFAULT_NATIVE_TRACKED_EVENTS, detectNativeEnvironment, applyNativeSession, createNativeWebViewBridge, initNativeOverlayWidgets, } from '../common/native-webview.js';
2
- export type { NativeBridgeEnvironment, NativeSessionPayload, NativeBridgeMessage, NativeInboundMessage, NativeTrackedEvent, NativeWebViewBridgeOptions, NativeWebViewBridge, NativeOverlayInitOptions, NativeOverlayInitResult, } from '../common/native-webview.js';
package/dist/overlay.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export { initOverlayWidgets, getOverlayWidgets, destroyOverlayWidgets, buildOverlayIdempotencyKey, } from './common/overlay.js';
2
- export type { OverlayWidgetsController, OverlayWidgetsOptions, OverlayChatOptions, OverlayQNAOptions, OverlaySimRelOptions, OverlaySimButOptions, } from './common/overlay.js';
3
- export { bootstrapSession, updatePageContext } from './common/context.js';
4
- export type { PageContext, SessionContext, WidgetTheme } from './common/types.js';
package/dist/qna/api.d.ts DELETED
@@ -1,23 +0,0 @@
1
- import { UISpec } from '../common/types.js';
2
- import { ChatTransportConfig } from '../common/api-paths.js';
3
- export interface LauncherActionRequest {
4
- account_id: string;
5
- session_id: string;
6
- correlation_id: string;
7
- sku: string;
8
- user_id?: string;
9
- view_id?: string;
10
- page_type?: string;
11
- locale?: string;
12
- output_language?: string;
13
- mode?: string;
14
- }
15
- export interface LauncherActionResult {
16
- uiSpecs: UISpec[];
17
- actions: Array<{
18
- title: string;
19
- type: string;
20
- payload?: unknown;
21
- }>;
22
- }
23
- export declare function fetchLauncherActions(request: LauncherActionRequest, transport: ChatTransportConfig, signal?: AbortSignal): Promise<LauncherActionResult>;
@@ -1,73 +0,0 @@
1
- import { z } from 'zod';
2
- export declare const ActionButtonSchema: z.ZodObject<{
3
- label: z.ZodString;
4
- action: z.ZodObject<{
5
- title: z.ZodString;
6
- type: z.ZodString;
7
- payload: z.ZodOptional<z.ZodUnknown>;
8
- }, z.core.$strip>;
9
- variant: z.ZodOptional<z.ZodEnum<{
10
- primary: "primary";
11
- outline: "outline";
12
- ghost: "ghost";
13
- }>>;
14
- }, z.core.$strip>;
15
- export declare const ButtonRowSchema: z.ZodObject<{
16
- orientation: z.ZodOptional<z.ZodEnum<{
17
- horizontal: "horizontal";
18
- vertical: "vertical";
19
- }>>;
20
- wrap: z.ZodOptional<z.ZodBoolean>;
21
- }, z.core.$strip>;
22
- export declare const TextInputSchema: z.ZodObject<{
23
- placeholder: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
24
- ctaLabel: z.ZodOptional<z.ZodString>;
25
- }, z.core.$strip>;
26
- export declare const QuestionHeadingSchema: z.ZodObject<{
27
- text: z.ZodString;
28
- }, z.core.$strip>;
29
- export declare const qnaCatalog: {
30
- readonly components: {
31
- readonly ActionButton: {
32
- readonly schema: z.ZodObject<{
33
- label: z.ZodString;
34
- action: z.ZodObject<{
35
- title: z.ZodString;
36
- type: z.ZodString;
37
- payload: z.ZodOptional<z.ZodUnknown>;
38
- }, z.core.$strip>;
39
- variant: z.ZodOptional<z.ZodEnum<{
40
- primary: "primary";
41
- outline: "outline";
42
- ghost: "ghost";
43
- }>>;
44
- }, z.core.$strip>;
45
- readonly description: "A single clickable QNA action button.";
46
- };
47
- readonly ButtonRow: {
48
- readonly schema: z.ZodObject<{
49
- orientation: z.ZodOptional<z.ZodEnum<{
50
- horizontal: "horizontal";
51
- vertical: "vertical";
52
- }>>;
53
- wrap: z.ZodOptional<z.ZodBoolean>;
54
- }, z.core.$strip>;
55
- readonly description: "Container for a group of QNA action buttons.";
56
- };
57
- readonly TextInput: {
58
- readonly schema: z.ZodObject<{
59
- placeholder: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
60
- ctaLabel: z.ZodOptional<z.ZodString>;
61
- }, z.core.$strip>;
62
- readonly description: "Free-text input with rotating placeholder and CTA button.";
63
- };
64
- readonly QuestionHeading: {
65
- readonly schema: z.ZodObject<{
66
- text: z.ZodString;
67
- }, z.core.$strip>;
68
- readonly description: "A heading displayed above the QNA button group.";
69
- };
70
- };
71
- };
72
- export type QNACatalog = typeof qnaCatalog;
73
- export type QNAComponentName = keyof QNACatalog['components'];
@@ -1,15 +0,0 @@
1
- import { ActionPayload } from '../../common/types.js';
2
- export interface ButtonRowOptions {
3
- actions: Array<{
4
- title: string;
5
- type: string;
6
- payload?: unknown;
7
- }>;
8
- onAction: (action: ActionPayload) => void;
9
- ctaText?: string;
10
- defaultCtaText?: string;
11
- onOpenChat?: () => void;
12
- orientation?: 'horizontal' | 'vertical';
13
- quickQuestionsAriaLabel?: string;
14
- }
15
- export declare function renderButtonRow(options: ButtonRowOptions): HTMLElement;
@@ -1,11 +0,0 @@
1
- import { ActionPayload } from '../../common/types.js';
2
- export interface TextInputOptions {
3
- placeholders?: string | string[];
4
- ctaLabel?: string;
5
- defaultInputPlaceholder?: string;
6
- askQuestionAriaLabel?: string;
7
- sendButtonText?: string;
8
- sendQuestionAriaLabel?: string;
9
- onSubmit: (action: ActionPayload) => void;
10
- }
11
- export declare function renderTextInput(options: TextInputOptions): HTMLElement;
@@ -1,7 +0,0 @@
1
- import { UISpecDomRegistry, UISpecDomUnknownRenderer } from '../../common/renderer/index.js';
2
- import { UISpec } from '../../common/types.js';
3
- import { QNAUISpecRenderContext } from '../types.js';
4
- export type QNAUISpecRegistry = UISpecDomRegistry<QNAUISpecRenderContext>;
5
- export declare const defaultQnaUnknownUISpecRenderer: UISpecDomUnknownRenderer<QNAUISpecRenderContext>;
6
- export declare function createDefaultQnaUISpecRegistry(): QNAUISpecRegistry;
7
- export declare function renderQnaUISpec(spec: UISpec, context: QNAUISpecRenderContext, registry?: QNAUISpecRegistry, unknownRenderer?: UISpecDomUnknownRenderer<QNAUISpecRenderContext>): HTMLElement;
@@ -1,3 +0,0 @@
1
- export * from './runtime.js';
2
- export { qnaCatalog } from './catalog.js';
3
- export type { QNACatalog, QNAComponentName } from './catalog.js';
@@ -1,2 +0,0 @@
1
- import { QNAI18n } from '../types.js';
2
- export declare const QNA_I18N_EN: QNAI18n;
@@ -1,5 +0,0 @@
1
- import { QNAI18n } from '../types.js';
2
- import { QNA_I18N_TR } from './tr.js';
3
- import { QNA_I18N_EN } from './en.js';
4
- export declare function resolveQnaLocale(locale?: string): QNAI18n;
5
- export { QNA_I18N_TR, QNA_I18N_EN };
@@ -1,2 +0,0 @@
1
- import { QNAI18n } from '../types.js';
2
- export declare const QNA_I18N_TR: QNAI18n;
@@ -1,15 +0,0 @@
1
- import { PageContext, UISpec } from '../common/types.js';
2
- import { QNAI18n } from './types.js';
3
- /** SKUs to send with the product-context quick pill (`user_message` + sku_list). */
4
- export type MergeQuickPillsOptions = {
5
- skuList?: string[] | undefined;
6
- };
7
- /**
8
- * Resolve SKU list for QNA → chat payloads: current PDP sku, or `visible_skus` on listings.
9
- */
10
- export declare function resolveQnaSkuListForPayload(pageContext: PageContext | undefined): string[] | undefined;
11
- /**
12
- * Removes standalone hero `ActionButton` blocks for `findSimilar` (e.g. from `text_image`)
13
- * and merges a product-context quick question pill instead (same row as other questions).
14
- */
15
- export declare function mergeStandaloneFindSimilarIntoQuickPills(specs: UISpec[], i18n: QNAI18n, options?: MergeQuickPillsOptions): UISpec[];
@@ -1,62 +0,0 @@
1
- import { ActionPayload, PageContext } from '../common/types.js';
2
- import { BaseWidget } from '../common/widget-base.js';
3
- import { QNAWidgetConfig } from './types.js';
4
- /**
5
- * Contextual Q&A action buttons for product pages.
6
- * Renders quick-action buttons that open the chat widget with a pre-built query.
7
- *
8
- * @example
9
- * ```ts
10
- * import { GengageQNA, wireQNAToChat, bootstrapSession } from '@gengage/assistant-fe';
11
- *
12
- * const qna = new GengageQNA();
13
- * await qna.init({
14
- * accountId: 'mystore',
15
- * middlewareUrl: '<backend service location provided for your Gengage account>',
16
- * mountTarget: '#qna-section',
17
- * pageContext: { pageType: 'pdp', sku: '12345' },
18
- * session: { sessionId: bootstrapSession() },
19
- * });
20
- * wireQNAToChat(); // Wire button clicks to chat.openWithAction()
21
- * ```
22
- */
23
- export declare class GengageQNA extends BaseWidget<QNAWidgetConfig> {
24
- private _abortController;
25
- private _debounceTimer;
26
- private _contentEl;
27
- private _lastSku;
28
- private _i18n;
29
- protected onInit(config: QNAWidgetConfig): Promise<void>;
30
- protected onUpdate(context: Partial<PageContext>): void;
31
- protected onShow(): void;
32
- protected onHide(): void;
33
- protected onDestroy(): void;
34
- private _abort;
35
- /** `headerTitle` wins over deprecated `headingTitle`. */
36
- private _resolvedQnaHeaderTitle;
37
- /** Clean up TextInput placeholder rotation timers to prevent interval leaks. */
38
- private _cleanupTextInputTimers;
39
- private _fetchAndRender;
40
- private _createLoadingIndicator;
41
- private _resolveI18n;
42
- private _createChrome;
43
- private _resolveUISpecRegistry;
44
- private _renderUISpec;
45
- private _specIncludesType;
46
- private _buildFallbackActionsSpec;
47
- /**
48
- * Free-text field when the launcher stream has no TextInput. Sits above the pills by
49
- * default; set `inputAfterPills: true` in config to place it after.
50
- */
51
- private _insertStandaloneInputBeforePills;
52
- private _appendStandaloneInput;
53
- private _handleAction;
54
- private _handleOpenChat;
55
- private _showTransitionIndicator;
56
- _actionHandler: (action: ActionPayload) => void;
57
- _openChatHandler: () => void;
58
- }
59
- export declare function createQNAWidget(): GengageQNA;
60
- export type { QNAWidgetConfig, QNAUIComponents, QNAI18n, QNAChromeLayout, QNAChromeConfig, QNAUISpecRenderContext, QNARendererConfig, } from './types.js';
61
- export { renderQnaUISpec, createDefaultQnaUISpecRegistry, defaultQnaUnknownUISpecRenderer, } from './components/renderUISpec.js';
62
- export type { QNAUISpecRegistry } from './components/renderUISpec.js';
@@ -1,98 +0,0 @@
1
- import { BaseWidgetConfig, ActionPayload } from '../common/types.js';
2
- import { UISpecRendererOverrides } from '../common/renderer/index.js';
3
- export interface QNAWidgetConfig extends BaseWidgetConfig {
4
- /** Where to mount the QNA buttons container. Required. */
5
- mountTarget: HTMLElement | string;
6
- /** Optional SDK-owned outer chrome for merchant PDP prompts. Defaults to no chrome. */
7
- chrome?: QNAChromeConfig;
8
- /** CTA label for the "open chat" pill/button (default: 'Ask something else'). */
9
- ctaText?: string;
10
- /** Hide the CTA button inside the quick-question button row.
11
- * Useful when a TextInput is already visible and the CTA would be redundant. */
12
- hideButtonRowCta?: boolean;
13
- /** Placeholder text cycling inside the free-text input.
14
- * Set to `true` to use fetched action titles as rotating placeholders. */
15
- inputPlaceholder?: string | string[] | true;
16
- /** When true, the standalone input is placed after the question pills instead of before them. */
17
- inputAfterPills?: boolean;
18
- /** Locale key for SDK defaults (for example 'tr', 'en'). */
19
- locale?: string;
20
- i18n?: Partial<QNAI18n>;
21
- renderer?: QNARendererConfig;
22
- /** Show a static question above the rotating buttons. */
23
- showStaticQuestion?: boolean;
24
- staticQuestionText?: string;
25
- /**
26
- * Title above the Q&A module (e.g. "Koçtaş'a Sor", "Teknosa'ya Sor").
27
- * When set, overrides the stream `QuestionHeading` text from the backend.
28
- * Overlay defaults: `qna.headerTitle` → `qna.headingTitle` (deprecated) → `chat.headerTitle`.
29
- */
30
- headerTitle?: string;
31
- /**
32
- * @deprecated Use `headerTitle` — same behavior.
33
- */
34
- headingTitle?: string;
35
- /** Called when a QNA action button is clicked. */
36
- onActionSelected?: (action: ActionPayload) => void;
37
- /** Called when the open-chat CTA is clicked. */
38
- onOpenChat?: () => void;
39
- }
40
- export interface QNAI18n {
41
- quickQuestionsAriaLabel: string;
42
- askQuestionAriaLabel: string;
43
- defaultInputPlaceholder: string;
44
- sendButton: string;
45
- sendQuestionAriaLabel: string;
46
- defaultCtaText: string;
47
- redirectingToChat: string;
48
- /**
49
- * Replaces the standalone backend “similar products” hero with this quick question pill
50
- * (user_message, not findSimilar).
51
- */
52
- productContextQuickPillLabel: string;
53
- }
54
- export type QNAChromeLayout = 'default' | 'side-image';
55
- export interface QNAChromeConfig {
56
- /** Optional chrome layout. `side-image` keeps the QNA body in the content column beside the image. */
57
- layout?: QNAChromeLayout;
58
- title?: string;
59
- subtitle?: string;
60
- imageUrl?: string;
61
- imageAlt?: string;
62
- /** Optional CSS padding value applied to the chrome image. */
63
- imagePadding?: string;
64
- startButtonLabel?: string;
65
- }
66
- export interface QNAUISpecRenderContext {
67
- onAction: (action: ActionPayload) => void;
68
- onOpenChat?: () => void;
69
- ctaText?: string;
70
- inputPlaceholder?: string | string[];
71
- i18n: QNAI18n;
72
- /** When set (from `QNAWidgetConfig.headerTitle` / `headingTitle`), replaces QuestionHeading `text` from the stream. */
73
- headingTitleOverride?: string;
74
- }
75
- export type QNARendererConfig = UISpecRendererOverrides<QNAUISpecRenderContext>;
76
- export interface QNAUIComponents {
77
- /** A single QNA action button. */
78
- ActionButton: {
79
- label: string;
80
- action: ActionPayload;
81
- /** Visual variant for the button. */
82
- variant?: 'primary' | 'outline' | 'ghost';
83
- };
84
- /** The container holding all action buttons. */
85
- ButtonRow: {
86
- orientation?: 'horizontal' | 'vertical';
87
- wrap?: boolean;
88
- };
89
- /** Free-text input field with rotating placeholder text. */
90
- TextInput: {
91
- placeholder?: string | string[];
92
- ctaLabel?: string;
93
- };
94
- /** A heading or label above the buttons. */
95
- QuestionHeading: {
96
- text: string;
97
- };
98
- }
@@ -1,22 +0,0 @@
1
- import { BaseWidget } from '../common/widget-base.js';
2
- import { PageContext } from '../common/types.js';
3
- import { GengageChat } from '../chat/index.js';
4
- import { SimButWidgetConfig } from './types.js';
5
- export declare class GengageSimBut extends BaseWidget<SimButWidgetConfig> {
6
- private _button;
7
- private _inlineFrame;
8
- private _label;
9
- protected onInit(config: SimButWidgetConfig): Promise<void>;
10
- private _createInlineCard;
11
- protected onUpdate(_context: Partial<PageContext>): void;
12
- hide(): void;
13
- show(): void;
14
- protected _cleanupRoot(): void;
15
- protected onShow(): void;
16
- protected onHide(): void;
17
- protected onDestroy(): void;
18
- /** Overlay chat bağlandıktan sonra çağrılabilir (isteğe bağlı). */
19
- setChat(chat: GengageChat | null): void;
20
- }
21
- export declare function createSimButWidget(): GengageSimBut;
22
- export type { SimButWidgetConfig, SimButI18n, SimButInlineCardConfig, SimButLayout } from './types.js';
@@ -1,3 +0,0 @@
1
- import { SimButI18n } from './types.js';
2
- export declare const SIMBUT_I18N_TR: SimButI18n;
3
- export declare const SIMBUT_I18N_EN: SimButI18n;
@@ -1,43 +0,0 @@
1
- import { BaseWidgetConfig } from '../common/types.js';
2
- import { GengageChat } from '../chat/index.js';
3
- export interface SimButI18n {
4
- findSimilarLabel: string;
5
- }
6
- export type SimButLayout = 'overlay' | 'inline-card';
7
- export interface SimButInlineCardConfig {
8
- title?: string;
9
- description?: string;
10
- imageUrl?: string;
11
- imageAlt?: string;
12
- }
13
- export interface SimButWidgetConfig extends BaseWidgetConfig {
14
- /**
15
- * Ürün görselinin (veya onun `position: relative` saran kutusunun) DOM öğesi.
16
- * Düğme bu kutuya göre `absolute` konumlanır; akışta ekstra yer kaplamaz.
17
- */
18
- mountTarget: HTMLElement | string;
19
- /** Visual layout. Defaults to the existing product-image overlay pill. */
20
- layout?: SimButLayout;
21
- /** Content used by `layout: 'inline-card'`. Ignored for overlay layout. */
22
- inlineCard?: SimButInlineCardConfig;
23
- /**
24
- * Ürün SKU. Verilmezse `pageContext.sku` kullanılır (overlay güncellemeleriyle birlikte).
25
- */
26
- sku?: string;
27
- /** `findSimilar` isteğine eklenecek ürün görseli URL’si (opsiyonel). */
28
- imageUrl?: string;
29
- /**
30
- * Sohbeti açıp `findSimilar` göndermek için chat örneği. `initOverlayWidgets` bunu otomatik bağlar.
31
- */
32
- chat?: GengageChat | null;
33
- /**
34
- * Varsayılan tıklama davranışının yerine geçer (ör. özel entegrasyon).
35
- * Tanımlıysa `chat` kullanılmaz.
36
- */
37
- onFindSimilar?: (detail: {
38
- sku: string;
39
- imageUrl?: string;
40
- }) => void;
41
- locale?: string;
42
- i18n?: Partial<SimButI18n>;
43
- }
@@ -1,25 +0,0 @@
1
- import { NormalizedProduct } from '../common/protocol-adapter.js';
2
- import { ChatTransportConfig } from '../common/api-paths.js';
3
- export interface SimilarProductsRequest {
4
- account_id: string;
5
- session_id: string;
6
- correlation_id: string;
7
- sku: string;
8
- domain?: string;
9
- limit?: number;
10
- output_language?: string;
11
- }
12
- export interface ProductGroupingsRequest {
13
- account_id: string;
14
- session_id: string;
15
- correlation_id: string;
16
- skus: string[];
17
- output_language?: string;
18
- }
19
- export interface ProductGroup {
20
- name: string;
21
- highlight?: string;
22
- products: NormalizedProduct[];
23
- }
24
- export declare function fetchSimilarProducts(request: SimilarProductsRequest, transport: ChatTransportConfig, signal?: AbortSignal): Promise<NormalizedProduct[]>;
25
- export declare function fetchProductGroupings(request: ProductGroupingsRequest, transport: ChatTransportConfig, signal?: AbortSignal): Promise<ProductGroup[]>;