@gengage/assistant-fe 0.4.20 → 0.5.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.
Files changed (165) hide show
  1. package/README.md +1 -1
  2. package/dist/{api-paths-CReMDZWg.js → api-paths-y5nkfEBG.js} +1 -1
  3. package/dist/chat-runtime.js +1 -1
  4. package/dist/chat.iife.js +43 -43
  5. package/dist/chat.js +1 -1
  6. package/dist/common-BKPSOoIP.js +324 -0
  7. package/dist/common.js +64 -81
  8. package/dist/{connection-warning-C_4e7ahZ.js → connection-warning-DJiyLM46.js} +1 -1
  9. package/dist/{fastIntent-DMNzXOSI.js → fastIntent-1T2g9art.js} +2 -2
  10. package/dist/index.js +49 -52
  11. package/dist/{native-webview-Bbcvvi_5.js → native-webview-y3a9R9hH.js} +1 -1
  12. package/dist/native.iife.js +23 -23
  13. package/dist/native.js +1 -1
  14. package/dist/{overlay-O4nlUrzw.js → overlay-v3nvcGlE.js} +2 -5
  15. package/dist/overlay.js +2 -2
  16. package/dist/qna-runtime.js +1 -1
  17. package/dist/qna.iife.js +36 -36
  18. package/dist/qna.js +1 -1
  19. package/dist/{runtime-C51WykbJ.js → runtime-BMNOS2Mq.js} +176 -196
  20. package/dist/runtime-DOS9yRRx.js +650 -0
  21. package/dist/{runtime-DBh8899B.js → runtime-DsP6go8z.js} +2194 -2225
  22. package/dist/{simbut-CO1rLVM9.js → simbut-BwxzoBcY.js} +7 -7
  23. package/dist/simbut.iife.js +12 -12
  24. package/dist/simbut.js +1 -1
  25. package/dist/{simrel-zCDlCrqG.js → simrel-C07wZN8Q.js} +2 -2
  26. package/dist/simrel-runtime.js +1 -1
  27. package/dist/simrel.iife.js +35 -35
  28. package/dist/simrel.js +2 -2
  29. package/dist/widget-base-Dliq3QAf.js +362 -0
  30. package/package.json +8 -6
  31. package/dist/chat/api.d.ts +0 -88
  32. package/dist/chat/assistant-mode.d.ts +0 -19
  33. package/dist/chat/attachment-utils.d.ts +0 -9
  34. package/dist/chat/catalog.d.ts +0 -826
  35. package/dist/chat/chat-presentation-state.d.ts +0 -53
  36. package/dist/chat/components/AIGroupingCards.d.ts +0 -3
  37. package/dist/chat/components/AISuggestedSearchCards.d.ts +0 -3
  38. package/dist/chat/components/AITopPicks.d.ts +0 -3
  39. package/dist/chat/components/BeautyPhotoStep.d.ts +0 -16
  40. package/dist/chat/components/CategoriesContainer.d.ts +0 -3
  41. package/dist/chat/components/ChatDrawer.d.ts +0 -360
  42. package/dist/chat/components/ChoicePrompter.d.ts +0 -21
  43. package/dist/chat/components/ComparisonTable.d.ts +0 -57
  44. package/dist/chat/components/ConsultingStylePicker.d.ts +0 -34
  45. package/dist/chat/components/FloatingComparisonButton.d.ts +0 -2
  46. package/dist/chat/components/FloatingLauncher.d.ts +0 -79
  47. package/dist/chat/components/GroundingReviewCard.d.ts +0 -3
  48. package/dist/chat/components/HandoffNotice.d.ts +0 -4
  49. package/dist/chat/components/KvkkBanner.d.ts +0 -6
  50. package/dist/chat/components/Launcher.d.ts +0 -28
  51. package/dist/chat/components/PanelRestoreCard.d.ts +0 -4
  52. package/dist/chat/components/PanelTopBar.d.ts +0 -32
  53. package/dist/chat/components/PhotoAnalysisCard.d.ts +0 -20
  54. package/dist/chat/components/ProductSummaryCard.d.ts +0 -3
  55. package/dist/chat/components/ProsAndCons.d.ts +0 -8
  56. package/dist/chat/components/ReviewHighlights.d.ts +0 -9
  57. package/dist/chat/components/actionClassifier.d.ts +0 -12
  58. package/dist/chat/components/product-price-layout.d.ts +0 -18
  59. package/dist/chat/components/productMentionLinker.d.ts +0 -25
  60. package/dist/chat/components/renderUISpec.d.ts +0 -11
  61. package/dist/chat/components/typewriter.d.ts +0 -24
  62. package/dist/chat/extendedModeManager.d.ts +0 -32
  63. package/dist/chat/features/beauty-consulting/consulting-grid.d.ts +0 -31
  64. package/dist/chat/features/beauty-consulting/drawer-extensions.d.ts +0 -20
  65. package/dist/chat/features/beauty-consulting/mode-controller.d.ts +0 -53
  66. package/dist/chat/features/beauty-consulting/registry.d.ts +0 -3
  67. package/dist/chat/features/beauty-consulting/stream-handler.d.ts +0 -38
  68. package/dist/chat/history-storage.d.ts +0 -85
  69. package/dist/chat/index.d.ts +0 -5
  70. package/dist/chat/kvkk.d.ts +0 -20
  71. package/dist/chat/locales/en.d.ts +0 -2
  72. package/dist/chat/locales/index.d.ts +0 -5
  73. package/dist/chat/locales/tr.d.ts +0 -2
  74. package/dist/chat/panel-manager.d.ts +0 -126
  75. package/dist/chat/runtime.d.ts +0 -400
  76. package/dist/chat/session-persistence.d.ts +0 -65
  77. package/dist/chat/stream-error-display.d.ts +0 -6
  78. package/dist/chat/types.d.ts +0 -543
  79. package/dist/chat/utils/chat-presentation-debug.d.ts +0 -19
  80. package/dist/chat/utils/get-chat-scroll-element.d.ts +0 -10
  81. package/dist/chat/utils/ui.d.ts +0 -10
  82. package/dist/common/action-router.d.ts +0 -26
  83. package/dist/common/activity-tracker.d.ts +0 -37
  84. package/dist/common/analytics-events.d.ts +0 -91
  85. package/dist/common/analytics.d.ts +0 -61
  86. package/dist/common/api-paths.d.ts +0 -15
  87. package/dist/common/client.d.ts +0 -27
  88. package/dist/common/communication-bridge.d.ts +0 -51
  89. package/dist/common/config-constants.d.ts +0 -1
  90. package/dist/common/config-schema.d.ts +0 -81
  91. package/dist/common/connection-warning.d.ts +0 -8
  92. package/dist/common/consulting-sources.d.ts +0 -9
  93. package/dist/common/context.d.ts +0 -27
  94. package/dist/common/css-escape.d.ts +0 -1
  95. package/dist/common/customization-factories.d.ts +0 -62
  96. package/dist/common/debug.d.ts +0 -13
  97. package/dist/common/events.d.ts +0 -46
  98. package/dist/common/fastIntent.d.ts +0 -1
  99. package/dist/common/find-similar-payload.d.ts +0 -3
  100. package/dist/common/ga-datalayer.d.ts +0 -89
  101. package/dist/common/global-error-toast.d.ts +0 -6
  102. package/dist/common/index.d.ts +0 -50
  103. package/dist/common/indexed-db.d.ts +0 -79
  104. package/dist/common/locale.d.ts +0 -1
  105. package/dist/common/native-webview.d.ts +0 -60
  106. package/dist/common/navigation.d.ts +0 -5
  107. package/dist/common/overlay.d.ts +0 -168
  108. package/dist/common/page-detect.d.ts +0 -30
  109. package/dist/common/pill-launcher.d.ts +0 -51
  110. package/dist/common/preflight.d.ts +0 -13
  111. package/dist/common/price-formatter.d.ts +0 -35
  112. package/dist/common/product-utils.d.ts +0 -35
  113. package/dist/common/protocol-adapter.d.ts +0 -105
  114. package/dist/common/renderer/dom.d.ts +0 -3
  115. package/dist/common/renderer/index.d.ts +0 -4
  116. package/dist/common/renderer/overrides.d.ts +0 -23
  117. package/dist/common/renderer/registry.d.ts +0 -2
  118. package/dist/common/renderer/types.d.ts +0 -19
  119. package/dist/common/safe-html.d.ts +0 -22
  120. package/dist/common/sdk-version.d.ts +0 -3
  121. package/dist/common/skeleton.d.ts +0 -8
  122. package/dist/common/streaming.d.ts +0 -37
  123. package/dist/common/suggested-search-keywords.d.ts +0 -18
  124. package/dist/common/theme-utils.d.ts +0 -15
  125. package/dist/common/tts-player.d.ts +0 -13
  126. package/dist/common/types.d.ts +0 -381
  127. package/dist/common/ui-theme.d.ts +0 -9
  128. package/dist/common/uuidv7.d.ts +0 -7
  129. package/dist/common/voice-input.d.ts +0 -74
  130. package/dist/common/widget-base.d.ts +0 -97
  131. package/dist/common-BM2ZsSLI.js +0 -491
  132. package/dist/index.d.ts +0 -25
  133. package/dist/native/index.d.ts +0 -2
  134. package/dist/overlay.d.ts +0 -4
  135. package/dist/qna/api.d.ts +0 -23
  136. package/dist/qna/catalog.d.ts +0 -73
  137. package/dist/qna/components/ButtonRow.d.ts +0 -15
  138. package/dist/qna/components/TextInput.d.ts +0 -11
  139. package/dist/qna/components/renderUISpec.d.ts +0 -7
  140. package/dist/qna/index.d.ts +0 -3
  141. package/dist/qna/locales/en.d.ts +0 -2
  142. package/dist/qna/locales/index.d.ts +0 -5
  143. package/dist/qna/locales/tr.d.ts +0 -2
  144. package/dist/qna/normalize-ui-specs.d.ts +0 -15
  145. package/dist/qna/runtime.d.ts +0 -62
  146. package/dist/qna/types.d.ts +0 -98
  147. package/dist/runtime-bbMljGVG.js +0 -688
  148. package/dist/simbut/index.d.ts +0 -22
  149. package/dist/simbut/locales.d.ts +0 -3
  150. package/dist/simbut/types.d.ts +0 -43
  151. package/dist/simrel/api.d.ts +0 -25
  152. package/dist/simrel/catalog.d.ts +0 -110
  153. package/dist/simrel/components/GroupTabs.d.ts +0 -24
  154. package/dist/simrel/components/ProductCard.d.ts +0 -19
  155. package/dist/simrel/components/ProductGrid.d.ts +0 -17
  156. package/dist/simrel/components/renderUISpec.d.ts +0 -7
  157. package/dist/simrel/index.d.ts +0 -5
  158. package/dist/simrel/locales/en.d.ts +0 -2
  159. package/dist/simrel/locales/index.d.ts +0 -5
  160. package/dist/simrel/locales/tr.d.ts +0 -2
  161. package/dist/simrel/renderers/default.d.ts +0 -40
  162. package/dist/simrel/runtime.d.ts +0 -59
  163. package/dist/simrel/types.d.ts +0 -141
  164. package/dist/widget-base-Cf9ofZhh.js +0 -589
  165. /package/dist/{context-DGz5F81j.js → context-BBuSsXZ9.js} +0 -0
@@ -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
- /** Optional hook for wiring overlay chat after initialization. */
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
- * Product image element, or its `position: relative` wrapper.
16
- * The button is absolutely positioned inside this element and does not take layout space.
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
- * Product SKU. Falls back to `pageContext.sku`, including overlay context updates.
25
- */
26
- sku?: string;
27
- /** Optional product image URL passed to custom `onFindSimilar`; chat actions use SKU when available. */
28
- imageUrl?: string;
29
- /**
30
- * Chat instance used to open chat and send `findSimilar`. `initOverlayWidgets` wires this automatically.
31
- */
32
- chat?: GengageChat | null;
33
- /**
34
- * Overrides the default click behavior, for example for a custom integration.
35
- * When defined, `chat` is not used.
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[]>;
@@ -1,110 +0,0 @@
1
- import { z } from 'zod';
2
- export declare const ProductGridSchema: z.ZodObject<{
3
- layout: z.ZodOptional<z.ZodEnum<{
4
- grid: "grid";
5
- carousel: "carousel";
6
- }>>;
7
- columns: z.ZodOptional<z.ZodNumber>;
8
- }, z.core.$strip>;
9
- export declare const ProductCardSchema: z.ZodObject<{
10
- product: z.ZodObject<{
11
- sku: z.ZodString;
12
- name: z.ZodString;
13
- imageUrl: z.ZodOptional<z.ZodString>;
14
- price: z.ZodOptional<z.ZodString>;
15
- originalPrice: z.ZodOptional<z.ZodString>;
16
- discountPercent: z.ZodOptional<z.ZodNumber>;
17
- url: z.ZodString;
18
- brand: z.ZodOptional<z.ZodString>;
19
- rating: z.ZodOptional<z.ZodNumber>;
20
- reviewCount: z.ZodOptional<z.ZodNumber>;
21
- }, z.core.$strip>;
22
- index: z.ZodNumber;
23
- discountType: z.ZodOptional<z.ZodEnum<{
24
- "strike-through": "strike-through";
25
- badge: "badge";
26
- }>>;
27
- }, z.core.$strip>;
28
- export declare const AddToCartButtonSchema: z.ZodObject<{
29
- sku: z.ZodString;
30
- label: z.ZodOptional<z.ZodString>;
31
- cartCode: z.ZodString;
32
- }, z.core.$strip>;
33
- export declare const QuickActionsSchema: z.ZodObject<{
34
- actions: z.ZodArray<z.ZodObject<{
35
- label: z.ZodString;
36
- action: z.ZodObject<{
37
- title: z.ZodString;
38
- type: z.ZodString;
39
- payload: z.ZodOptional<z.ZodUnknown>;
40
- }, z.core.$strip>;
41
- }, z.core.$strip>>;
42
- }, z.core.$strip>;
43
- export declare const EmptyStateSchema: z.ZodObject<{
44
- message: z.ZodOptional<z.ZodString>;
45
- }, z.core.$strip>;
46
- export declare const simRelCatalog: {
47
- readonly components: {
48
- readonly ProductGrid: {
49
- readonly schema: z.ZodObject<{
50
- layout: z.ZodOptional<z.ZodEnum<{
51
- grid: "grid";
52
- carousel: "carousel";
53
- }>>;
54
- columns: z.ZodOptional<z.ZodNumber>;
55
- }, z.core.$strip>;
56
- readonly description: "Outer grid or carousel container for similar products.";
57
- };
58
- readonly ProductCard: {
59
- readonly schema: z.ZodObject<{
60
- product: z.ZodObject<{
61
- sku: z.ZodString;
62
- name: z.ZodString;
63
- imageUrl: z.ZodOptional<z.ZodString>;
64
- price: z.ZodOptional<z.ZodString>;
65
- originalPrice: z.ZodOptional<z.ZodString>;
66
- discountPercent: z.ZodOptional<z.ZodNumber>;
67
- url: z.ZodString;
68
- brand: z.ZodOptional<z.ZodString>;
69
- rating: z.ZodOptional<z.ZodNumber>;
70
- reviewCount: z.ZodOptional<z.ZodNumber>;
71
- }, z.core.$strip>;
72
- index: z.ZodNumber;
73
- discountType: z.ZodOptional<z.ZodEnum<{
74
- "strike-through": "strike-through";
75
- badge: "badge";
76
- }>>;
77
- }, z.core.$strip>;
78
- readonly description: "A single product card with image, title, price, and actions.";
79
- };
80
- readonly AddToCartButton: {
81
- readonly schema: z.ZodObject<{
82
- sku: z.ZodString;
83
- label: z.ZodOptional<z.ZodString>;
84
- cartCode: z.ZodString;
85
- }, z.core.$strip>;
86
- readonly description: "Add-to-cart CTA rendered inside or below a product card.";
87
- };
88
- readonly QuickActions: {
89
- readonly schema: z.ZodObject<{
90
- actions: z.ZodArray<z.ZodObject<{
91
- label: z.ZodString;
92
- action: z.ZodObject<{
93
- title: z.ZodString;
94
- type: z.ZodString;
95
- payload: z.ZodOptional<z.ZodUnknown>;
96
- }, z.core.$strip>;
97
- }, z.core.$strip>>;
98
- }, z.core.$strip>;
99
- readonly description: "A row of quick-action buttons below product info.";
100
- };
101
- readonly EmptyState: {
102
- readonly schema: z.ZodObject<{
103
- message: z.ZodOptional<z.ZodString>;
104
- }, z.core.$strip>;
105
- readonly description: "Empty state shown when no similar products are available.";
106
- };
107
- };
108
- };
109
- export type SimRelCatalog = typeof simRelCatalog;
110
- export type SimRelComponentName = keyof SimRelCatalog['components'];
@@ -1,24 +0,0 @@
1
- import { NormalizedProduct } from '../../common/protocol-adapter.js';
2
- import { ProductGroup } from '../api.js';
3
- import { SimRelI18n } from '../types.js';
4
- export interface GroupTabsOptions {
5
- groups: ProductGroup[];
6
- discountType?: 'strike-through' | 'badge';
7
- onClick: (product: NormalizedProduct) => void;
8
- onAddToCart: (params: {
9
- sku: string;
10
- quantity: number;
11
- cartCode: string;
12
- }) => void;
13
- renderCard?: (product: NormalizedProduct, index: number) => string;
14
- renderCardElement?: (product: NormalizedProduct, index: number) => HTMLElement | null;
15
- i18n?: SimRelI18n;
16
- /** ProductGrid `columns`: number of cards per desktop row. */
17
- columns?: number;
18
- /** User changed grouping tab (click or keyboard). */
19
- onGroupingActivate?: (detail: {
20
- grouping_label: string;
21
- grouping_index: number;
22
- }) => void;
23
- }
24
- export declare function renderGroupTabs(options: GroupTabsOptions): HTMLElement;
@@ -1,19 +0,0 @@
1
- import { NormalizedProduct } from '../../common/protocol-adapter.js';
2
- import { SimRelI18n } from '../types.js';
3
- import { PriceFormatConfig } from '../../common/price-formatter.js';
4
- export interface ProductCardOptions {
5
- product: NormalizedProduct;
6
- index: number;
7
- discountType?: 'strike-through' | 'badge';
8
- onClick: (product: NormalizedProduct) => void;
9
- onAddToCart: (params: {
10
- sku: string;
11
- quantity: number;
12
- cartCode: string;
13
- }) => void;
14
- renderCard?: (product: NormalizedProduct, index: number) => string;
15
- renderCardElement?: (product: NormalizedProduct, index: number) => HTMLElement | null;
16
- i18n?: SimRelI18n;
17
- pricing?: PriceFormatConfig;
18
- }
19
- export declare function renderProductCard(options: ProductCardOptions): HTMLElement;
@@ -1,17 +0,0 @@
1
- import { NormalizedProduct } from '../../common/protocol-adapter.js';
2
- import { SimRelI18n } from '../types.js';
3
- export interface ProductGridOptions {
4
- products: NormalizedProduct[];
5
- columns?: number;
6
- discountType?: 'strike-through' | 'badge';
7
- onClick: (product: NormalizedProduct) => void;
8
- onAddToCart: (params: {
9
- sku: string;
10
- quantity: number;
11
- cartCode: string;
12
- }) => void;
13
- renderCard?: (product: NormalizedProduct, index: number) => string;
14
- renderCardElement?: (product: NormalizedProduct, index: number) => HTMLElement | null;
15
- i18n?: SimRelI18n;
16
- }
17
- export declare function renderProductGrid(options: ProductGridOptions): HTMLElement;
@@ -1,7 +0,0 @@
1
- import { UISpecDomRegistry, UISpecDomUnknownRenderer } from '../../common/renderer/index.js';
2
- import { UISpec } from '../../common/types.js';
3
- import { SimRelUISpecRenderContext } from '../types.js';
4
- export type SimRelUISpecRegistry = UISpecDomRegistry<SimRelUISpecRenderContext>;
5
- export declare const defaultSimRelUnknownUISpecRenderer: UISpecDomUnknownRenderer<SimRelUISpecRenderContext>;
6
- export declare function createDefaultSimRelUISpecRegistry(): SimRelUISpecRegistry;
7
- export declare function renderSimRelUISpec(spec: UISpec, context: SimRelUISpecRenderContext, registry?: SimRelUISpecRegistry, unknownRenderer?: UISpecDomUnknownRenderer<SimRelUISpecRenderContext>): HTMLElement;
@@ -1,5 +0,0 @@
1
- export * from './runtime.js';
2
- export { createSimRelRenderer } from './renderers/default.js';
3
- export type { SimRelFieldPath, SimRelRendererFields, SimRelRendererLabels, SimRelRendererMedia, SimRelRendererOptions, } from './renderers/default.js';
4
- export { simRelCatalog } from './catalog.js';
5
- export type { SimRelCatalog, SimRelComponentName } from './catalog.js';
@@ -1,2 +0,0 @@
1
- import { SimRelI18n } from '../types.js';
2
- export declare const SIMREL_I18N_EN: SimRelI18n;
@@ -1,5 +0,0 @@
1
- import { SimRelI18n } from '../types.js';
2
- import { SIMREL_I18N_TR } from './tr.js';
3
- import { SIMREL_I18N_EN } from './en.js';
4
- export declare function resolveSimRelLocale(locale?: string): SimRelI18n;
5
- export { SIMREL_I18N_TR, SIMREL_I18N_EN };
@@ -1,2 +0,0 @@
1
- import { SimRelI18n } from '../types.js';
2
- export declare const SIMREL_I18N_TR: SimRelI18n;
@@ -1,40 +0,0 @@
1
- import { PriceFormatConfig } from '../../common/price-formatter.js';
2
- import { SimilarProduct, SimRelRendererConfig } from '../types.js';
3
- export type SimRelFieldPath = string | readonly string[];
4
- export interface SimRelRendererLabels {
5
- cta?: string;
6
- productInfo?: string;
7
- customBadgeAlt?: string;
8
- review?: (count: number) => string;
9
- imageDot?: (index: number) => string;
10
- previousPromotion?: string;
11
- nextPromotion?: string;
12
- specialPriceBadgeAlt?: string;
13
- }
14
- export interface SimRelRendererFields {
15
- images?: SimRelFieldPath[];
16
- subtitle?: SimRelFieldPath[];
17
- promotions?: SimRelFieldPath[];
18
- warranties?: SimRelFieldPath[];
19
- productInfoUrl?: SimRelFieldPath[];
20
- discountReason?: SimRelFieldPath[];
21
- specialPrice?: SimRelFieldPath[];
22
- customBadgeFacets?: SimRelFieldPath[];
23
- customBadgeText?: SimRelFieldPath[];
24
- customBadgeImageUrl?: SimRelFieldPath[];
25
- }
26
- export interface SimRelRendererMedia {
27
- promotionIconUrl?: string;
28
- specialPriceBadgeUrl?: string;
29
- imageUrlTransform?: (url: string, product: SimilarProduct) => string;
30
- customBadgeImageUrl?: (product: SimilarProduct, labelText: string) => string | null | undefined;
31
- }
32
- export interface SimRelRendererOptions {
33
- labels?: SimRelRendererLabels;
34
- fields?: SimRelRendererFields;
35
- media?: SimRelRendererMedia;
36
- warrantyPromotionPattern?: RegExp;
37
- specialPricePattern?: RegExp;
38
- pricing?: PriceFormatConfig | undefined;
39
- }
40
- export declare function createSimRelRenderer(options?: SimRelRendererOptions): SimRelRendererConfig;
@@ -1,59 +0,0 @@
1
- import { PageContext } from '../common/types.js';
2
- import { NormalizedProduct } from '../common/protocol-adapter.js';
3
- import { BaseWidget } from '../common/widget-base.js';
4
- import { SimRelWidgetConfig } from './types.js';
5
- /**
6
- * Similar / related products widget for product pages.
7
- * Fetches AI-powered product recommendations and renders them as a scrollable grid.
8
- *
9
- * @example
10
- * ```ts
11
- * import { GengageSimRel, bootstrapSession } from '@gengage/assistant-fe';
12
- *
13
- * const simrel = new GengageSimRel();
14
- * await simrel.init({
15
- * accountId: 'mystore',
16
- * middlewareUrl: '<backend service location provided for your Gengage account>',
17
- * sku: '12345',
18
- * mountTarget: '#similar-products',
19
- * session: { sessionId: bootstrapSession() },
20
- * onAddToCart: ({ sku, quantity }) => cart.add(sku, quantity),
21
- * });
22
- * ```
23
- */
24
- export declare class GengageSimRel extends BaseWidget<SimRelWidgetConfig> {
25
- private _abortController;
26
- private _contentEl;
27
- private _lastSku;
28
- /** Number of products returned from the last successful fetch. Used to allow
29
- * retry when the same SKU previously produced an empty result set. */
30
- private _lastResultCount;
31
- private _i18n;
32
- protected onInit(config: SimRelWidgetConfig): Promise<void>;
33
- protected onUpdate(context: Partial<PageContext>): void;
34
- protected onShow(): void;
35
- protected onHide(): void;
36
- protected onDestroy(): void;
37
- _handleProductClick(product: NormalizedProduct): void;
38
- _handleAddToCart(params: {
39
- sku: string;
40
- quantity: number;
41
- cartCode: string;
42
- }): void;
43
- private _abort;
44
- private _isSuperseded;
45
- private _emitSimilarProductsImpression;
46
- private _resolveRequestTimeoutMs;
47
- private _fetchAndRender;
48
- private _clampGridColumns;
49
- private _resolveI18n;
50
- private _resolveUISpecRegistry;
51
- private _buildRenderContext;
52
- private _renderUISpec;
53
- private _buildProductsSpec;
54
- private _buildGroupsSpec;
55
- }
56
- export declare function createSimRelWidget(): GengageSimRel;
57
- export type { SimRelWidgetConfig, SimilarProduct, SimRelUIComponents, SimRelI18n, SimRelUISpecRenderContext, SimRelRendererConfig, } from './types.js';
58
- export { renderSimRelUISpec, createDefaultSimRelUISpecRegistry, defaultSimRelUnknownUISpecRenderer, } from './components/renderUISpec.js';
59
- export type { SimRelUISpecRegistry } from './components/renderUISpec.js';
@@ -1,141 +0,0 @@
1
- import { BaseWidgetConfig, ActionPayload } from '../common/types.js';
2
- import { UISpecRendererOverrides } from '../common/renderer/index.js';
3
- export interface SimRelWidgetConfig extends BaseWidgetConfig {
4
- /** Product SKU to find similar items for. Required. */
5
- sku: string;
6
- /** Where to render the product grid. Required. */
7
- mountTarget: HTMLElement | string;
8
- /** Called when "Add to cart" is tapped on a product card. */
9
- onAddToCart?: (params: import('../common/types.js').AddToCartParams) => void;
10
- /**
11
- * Called when the user taps a product card (navigation intent).
12
- * Return false to prevent the widget's default navigation.
13
- */
14
- onProductClick?: (product: SimilarProduct) => boolean | void;
15
- /**
16
- * Called just before navigating to a product page.
17
- * Use to call window.gengage.chat.saveSession() for cross-page session continuity.
18
- */
19
- onProductNavigate?: (url: string, sku: string, sessionId: string | null) => void;
20
- /** Forwarded to your analytics layer. */
21
- onAnalyticsEvent?: (event: string, data: Record<string, unknown>) => void;
22
- /**
23
- * Override the default product card template.
24
- *
25
- * ⚠️ XSS WARNING: This function returns a raw HTML string injected into the DOM.
26
- * You MUST sanitize any user-controlled data (e.g. product names from the API)
27
- * using DOMPurify or a similar library before returning.
28
- *
29
- * Glov/Gengage accepts no responsibility for XSS vulnerabilities introduced
30
- * by unsafe renderCard implementations.
31
- */
32
- renderCard?: (product: SimilarProduct, index: number) => string;
33
- /**
34
- * Override the default product card with a full DOM element.
35
- * Unlike `renderCard` (HTML string), this returns an HTMLElement,
36
- * allowing interactive elements (event listeners, state, etc.).
37
- * Takes precedence over `renderCard` when both are provided.
38
- */
39
- renderCardElement?: (product: SimilarProduct, index: number) => HTMLElement | null;
40
- /** Show the first slot as a "special" card (e.g. a promo or bundle). */
41
- useSpecialCard?: boolean;
42
- renderSpecialCard?: (product: SimilarProduct) => string | null;
43
- discountType?: 'strike-through' | 'badge';
44
- /**
45
- * Number of product cards per desktop row (1-12). Default: 4.
46
- * Narrow screens (<=768px) keep the horizontally scrollable carousel behavior.
47
- */
48
- gridColumns?: number;
49
- /** Client-side abort cap for similar-products and grouping requests. Defaults to 120 seconds. */
50
- requestTimeoutMs?: number;
51
- domain?: string;
52
- /** Locale key for SDK defaults (for example 'tr', 'en'). */
53
- locale?: string;
54
- i18n?: Partial<SimRelI18n>;
55
- renderer?: SimRelRendererConfig;
56
- }
57
- export interface SimilarProduct {
58
- sku: string;
59
- name: string;
60
- imageUrl?: string;
61
- price?: string;
62
- originalPrice?: string;
63
- discountPercent?: number;
64
- url: string;
65
- brand?: string;
66
- rating?: number;
67
- reviewCount?: number;
68
- cartCode?: string;
69
- inStock?: boolean;
70
- /** Pass-through bag for backend fields not consumed by the SDK. */
71
- extras?: Record<string, unknown>;
72
- }
73
- export interface SimRelI18n {
74
- similarProductsAriaLabel: string;
75
- emptyStateMessage: string;
76
- addToCartButton: string;
77
- ctaLabel: string;
78
- outOfStockLabel: string;
79
- decreaseLabel: string;
80
- increaseLabel: string;
81
- /** Inline error message shown when similar products fail to load. */
82
- errorLoadingMessage: string;
83
- /** Retry button label shown alongside the error message. */
84
- retryButtonText: string;
85
- /**
86
- * @deprecated Prefer `pricing` config on the widget for locale-aware formatting.
87
- * Kept for backwards compatibility with existing custom integrations.
88
- */
89
- priceSuffix: string;
90
- scrollTabsLeft?: string;
91
- scrollTabsRight?: string;
92
- }
93
- export interface SimRelUISpecRenderContext {
94
- onClick: (product: SimilarProduct) => void;
95
- onAddToCart: (params: import('../common/types.js').AddToCartParams) => void;
96
- /** Fires when the shopper selects a grouping tab (not the initial tab mount). */
97
- onGroupingActivate?: (detail: {
98
- grouping_label: string;
99
- grouping_index: number;
100
- }) => void;
101
- onAction?: (action: ActionPayload) => void;
102
- discountType?: 'strike-through' | 'badge';
103
- renderCard?: (product: SimilarProduct, index: number) => string;
104
- renderCardElement?: (product: SimilarProduct, index: number) => HTMLElement | null;
105
- i18n: SimRelI18n;
106
- pricing?: import('../common/price-formatter.js').PriceFormatConfig;
107
- /** Used when the ui_spec `ProductGrid` omits `columns` (widget `gridColumns`). */
108
- gridColumns?: number;
109
- }
110
- export type SimRelRendererConfig = UISpecRendererOverrides<SimRelUISpecRenderContext>;
111
- export interface SimRelUIComponents {
112
- /** The outer grid/carousel container. */
113
- ProductGrid: {
114
- layout?: 'grid' | 'carousel';
115
- columns?: number;
116
- };
117
- /** A single product card in the grid. */
118
- ProductCard: {
119
- product: SimilarProduct;
120
- index: number;
121
- discountType?: 'strike-through' | 'badge';
122
- };
123
- /** Add-to-cart button inside a card. */
124
- AddToCartButton: {
125
- sku: string;
126
- label?: string;
127
- /** Cart code / variant identifier. */
128
- cartCode: string;
129
- };
130
- /** A "quick action" row of buttons below the product info. */
131
- QuickActions: {
132
- actions: Array<{
133
- label: string;
134
- action: ActionPayload;
135
- }>;
136
- };
137
- /** Empty state shown when no similar products are found. */
138
- EmptyState: {
139
- message?: string;
140
- };
141
- }