@gengage/assistant-fe 0.4.20 → 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 (156) hide show
  1. package/dist/{api-paths-CReMDZWg.js → api-paths-Bg6iwO5w.js} +1 -1
  2. package/dist/chat-runtime.js +1 -1
  3. package/dist/chat.iife.js +2 -2
  4. package/dist/chat.js +1 -1
  5. package/dist/{common-BM2ZsSLI.js → common-DDJSeQhg.js} +2 -2
  6. package/dist/common.js +5 -5
  7. package/dist/{connection-warning-C_4e7ahZ.js → connection-warning-BeD-B0Ec.js} +1 -1
  8. package/dist/{fastIntent-DMNzXOSI.js → fastIntent-BeeDIwd2.js} +1 -1
  9. package/dist/index.js +10 -10
  10. package/dist/native.iife.js +2 -2
  11. package/dist/qna-runtime.js +1 -1
  12. package/dist/qna.iife.js +1 -1
  13. package/dist/qna.js +1 -1
  14. package/dist/{runtime-C51WykbJ.js → runtime-C8ZBidd2.js} +3 -3
  15. package/dist/{runtime-bbMljGVG.js → runtime-CRSFPLku.js} +3 -3
  16. package/dist/{runtime-DBh8899B.js → runtime-Ct1qOl8V.js} +5 -5
  17. package/dist/{simbut-CO1rLVM9.js → simbut-BrAeZ6SH.js} +1 -1
  18. package/dist/simbut.iife.js +1 -1
  19. package/dist/simbut.js +1 -1
  20. package/dist/{simrel-zCDlCrqG.js → simrel-Cha5de6P.js} +1 -1
  21. package/dist/simrel-runtime.js +1 -1
  22. package/dist/simrel.iife.js +1 -1
  23. package/dist/simrel.js +2 -2
  24. package/dist/{widget-base-Cf9ofZhh.js → widget-base-BtBl_PCR.js} +1 -1
  25. package/package.json +8 -5
  26. package/dist/chat/api.d.ts +0 -88
  27. package/dist/chat/assistant-mode.d.ts +0 -19
  28. package/dist/chat/attachment-utils.d.ts +0 -9
  29. package/dist/chat/catalog.d.ts +0 -826
  30. package/dist/chat/chat-presentation-state.d.ts +0 -53
  31. package/dist/chat/components/AIGroupingCards.d.ts +0 -3
  32. package/dist/chat/components/AISuggestedSearchCards.d.ts +0 -3
  33. package/dist/chat/components/AITopPicks.d.ts +0 -3
  34. package/dist/chat/components/BeautyPhotoStep.d.ts +0 -16
  35. package/dist/chat/components/CategoriesContainer.d.ts +0 -3
  36. package/dist/chat/components/ChatDrawer.d.ts +0 -360
  37. package/dist/chat/components/ChoicePrompter.d.ts +0 -21
  38. package/dist/chat/components/ComparisonTable.d.ts +0 -57
  39. package/dist/chat/components/ConsultingStylePicker.d.ts +0 -34
  40. package/dist/chat/components/FloatingComparisonButton.d.ts +0 -2
  41. package/dist/chat/components/FloatingLauncher.d.ts +0 -79
  42. package/dist/chat/components/GroundingReviewCard.d.ts +0 -3
  43. package/dist/chat/components/HandoffNotice.d.ts +0 -4
  44. package/dist/chat/components/KvkkBanner.d.ts +0 -6
  45. package/dist/chat/components/Launcher.d.ts +0 -28
  46. package/dist/chat/components/PanelRestoreCard.d.ts +0 -4
  47. package/dist/chat/components/PanelTopBar.d.ts +0 -32
  48. package/dist/chat/components/PhotoAnalysisCard.d.ts +0 -20
  49. package/dist/chat/components/ProductSummaryCard.d.ts +0 -3
  50. package/dist/chat/components/ProsAndCons.d.ts +0 -8
  51. package/dist/chat/components/ReviewHighlights.d.ts +0 -9
  52. package/dist/chat/components/actionClassifier.d.ts +0 -12
  53. package/dist/chat/components/product-price-layout.d.ts +0 -18
  54. package/dist/chat/components/productMentionLinker.d.ts +0 -25
  55. package/dist/chat/components/renderUISpec.d.ts +0 -11
  56. package/dist/chat/components/typewriter.d.ts +0 -24
  57. package/dist/chat/extendedModeManager.d.ts +0 -32
  58. package/dist/chat/features/beauty-consulting/consulting-grid.d.ts +0 -31
  59. package/dist/chat/features/beauty-consulting/drawer-extensions.d.ts +0 -20
  60. package/dist/chat/features/beauty-consulting/mode-controller.d.ts +0 -53
  61. package/dist/chat/features/beauty-consulting/registry.d.ts +0 -3
  62. package/dist/chat/features/beauty-consulting/stream-handler.d.ts +0 -38
  63. package/dist/chat/history-storage.d.ts +0 -85
  64. package/dist/chat/index.d.ts +0 -5
  65. package/dist/chat/kvkk.d.ts +0 -20
  66. package/dist/chat/locales/en.d.ts +0 -2
  67. package/dist/chat/locales/index.d.ts +0 -5
  68. package/dist/chat/locales/tr.d.ts +0 -2
  69. package/dist/chat/panel-manager.d.ts +0 -126
  70. package/dist/chat/runtime.d.ts +0 -400
  71. package/dist/chat/session-persistence.d.ts +0 -65
  72. package/dist/chat/stream-error-display.d.ts +0 -6
  73. package/dist/chat/types.d.ts +0 -543
  74. package/dist/chat/utils/chat-presentation-debug.d.ts +0 -19
  75. package/dist/chat/utils/get-chat-scroll-element.d.ts +0 -10
  76. package/dist/chat/utils/ui.d.ts +0 -10
  77. package/dist/common/action-router.d.ts +0 -26
  78. package/dist/common/activity-tracker.d.ts +0 -37
  79. package/dist/common/analytics-events.d.ts +0 -91
  80. package/dist/common/analytics.d.ts +0 -61
  81. package/dist/common/api-paths.d.ts +0 -15
  82. package/dist/common/client.d.ts +0 -27
  83. package/dist/common/communication-bridge.d.ts +0 -51
  84. package/dist/common/config-constants.d.ts +0 -1
  85. package/dist/common/config-schema.d.ts +0 -81
  86. package/dist/common/connection-warning.d.ts +0 -8
  87. package/dist/common/consulting-sources.d.ts +0 -9
  88. package/dist/common/context.d.ts +0 -27
  89. package/dist/common/css-escape.d.ts +0 -1
  90. package/dist/common/customization-factories.d.ts +0 -62
  91. package/dist/common/debug.d.ts +0 -13
  92. package/dist/common/events.d.ts +0 -46
  93. package/dist/common/fastIntent.d.ts +0 -1
  94. package/dist/common/find-similar-payload.d.ts +0 -3
  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 -50
  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/sdk-version.d.ts +0 -3
  116. package/dist/common/skeleton.d.ts +0 -8
  117. package/dist/common/streaming.d.ts +0 -37
  118. package/dist/common/suggested-search-keywords.d.ts +0 -18
  119. package/dist/common/theme-utils.d.ts +0 -15
  120. package/dist/common/tts-player.d.ts +0 -13
  121. package/dist/common/types.d.ts +0 -381
  122. package/dist/common/ui-theme.d.ts +0 -9
  123. package/dist/common/uuidv7.d.ts +0 -7
  124. package/dist/common/voice-input.d.ts +0 -74
  125. package/dist/common/widget-base.d.ts +0 -97
  126. package/dist/index.d.ts +0 -25
  127. package/dist/native/index.d.ts +0 -2
  128. package/dist/overlay.d.ts +0 -4
  129. package/dist/qna/api.d.ts +0 -23
  130. package/dist/qna/catalog.d.ts +0 -73
  131. package/dist/qna/components/ButtonRow.d.ts +0 -15
  132. package/dist/qna/components/TextInput.d.ts +0 -11
  133. package/dist/qna/components/renderUISpec.d.ts +0 -7
  134. package/dist/qna/index.d.ts +0 -3
  135. package/dist/qna/locales/en.d.ts +0 -2
  136. package/dist/qna/locales/index.d.ts +0 -5
  137. package/dist/qna/locales/tr.d.ts +0 -2
  138. package/dist/qna/normalize-ui-specs.d.ts +0 -15
  139. package/dist/qna/runtime.d.ts +0 -62
  140. package/dist/qna/types.d.ts +0 -98
  141. package/dist/simbut/index.d.ts +0 -22
  142. package/dist/simbut/locales.d.ts +0 -3
  143. package/dist/simbut/types.d.ts +0 -43
  144. package/dist/simrel/api.d.ts +0 -25
  145. package/dist/simrel/catalog.d.ts +0 -110
  146. package/dist/simrel/components/GroupTabs.d.ts +0 -24
  147. package/dist/simrel/components/ProductCard.d.ts +0 -19
  148. package/dist/simrel/components/ProductGrid.d.ts +0 -17
  149. package/dist/simrel/components/renderUISpec.d.ts +0 -7
  150. package/dist/simrel/index.d.ts +0 -5
  151. package/dist/simrel/locales/en.d.ts +0 -2
  152. package/dist/simrel/locales/index.d.ts +0 -5
  153. package/dist/simrel/locales/tr.d.ts +0 -2
  154. package/dist/simrel/renderers/default.d.ts +0 -40
  155. package/dist/simrel/runtime.d.ts +0 -59
  156. package/dist/simrel/types.d.ts +0 -141
@@ -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
- }