@gengage/assistant-fe 0.4.4 → 0.4.6

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 (50) hide show
  1. package/README.md +1 -1
  2. package/dist/api-paths-C4GDpeTf.js +1214 -0
  3. package/dist/chat/index.d.ts +1 -374
  4. package/dist/chat/runtime.d.ts +374 -0
  5. package/dist/chat/types.d.ts +1 -1
  6. package/dist/chat-BRKK63lt.js +303 -0
  7. package/dist/chat-runtime.js +13 -0
  8. package/dist/chat.iife.js +7 -7
  9. package/dist/chat.js +11 -10
  10. package/dist/common/config-constants.d.ts +1 -0
  11. package/dist/common/config-schema.d.ts +0 -1
  12. package/dist/common/overlay.d.ts +4 -4
  13. package/dist/common-CEN5OW7E.js +491 -0
  14. package/dist/common.js +78 -76
  15. package/dist/{connection-warning-n88bjkqL.js → connection-warning-B6oIU-9s.js} +1 -1
  16. package/dist/context-VIG4SVcS.js +529 -0
  17. package/dist/index.js +70 -67
  18. package/dist/locale-CfqNifrU.js +7 -0
  19. package/dist/native-webview-DudQ7nHe.js +273 -0
  20. package/dist/native.iife.js +28 -91
  21. package/dist/native.js +1 -1
  22. package/dist/overlay-1EO41ZC7.js +212 -0
  23. package/dist/overlay.d.ts +4 -0
  24. package/dist/overlay.js +10 -0
  25. package/dist/pill-launcher-57nrdLRr.js +364 -0
  26. package/dist/qna/index.d.ts +1 -61
  27. package/dist/qna/runtime.d.ts +61 -0
  28. package/dist/qna-BNvttR6s.js +40 -0
  29. package/dist/qna-runtime.js +8 -0
  30. package/dist/qna.iife.js +4 -4
  31. package/dist/qna.js +6 -5
  32. package/dist/{simrel-K2TGFi1r.js → runtime-BdwZZIrO.js} +244 -293
  33. package/dist/{chat-DI7Vm0gh.js → runtime-C0qZk0y7.js} +1644 -2298
  34. package/dist/{qna-C5Ok3wd0.js → runtime-DDu8Wk0z.js} +87 -121
  35. package/dist/schemas-CLo8wCjs.js +3207 -0
  36. package/dist/{simbut-Cb5RfaAp.js → simbut-BMWC6x_t.js} +24 -22
  37. package/dist/simbut.js +1 -1
  38. package/dist/simrel/index.d.ts +1 -59
  39. package/dist/simrel/runtime.d.ts +59 -0
  40. package/dist/simrel-ohfkluhp.js +55 -0
  41. package/dist/simrel-runtime.js +8 -0
  42. package/dist/simrel.iife.js +4 -4
  43. package/dist/simrel.js +7 -6
  44. package/dist/widget-base-TgwiA8cD.js +578 -0
  45. package/package.json +17 -1
  46. package/dist/common-BxSi3UWt.js +0 -387
  47. package/dist/locale-MM0U5eeR.js +0 -1109
  48. package/dist/native-webview-DFqnyus6.js +0 -586
  49. package/dist/schemas-JpRGzRQT.js +0 -4419
  50. /package/dist/{price-formatter-CR6VT5z4.js → price-formatter-xI3g9Cd4.js} +0 -0
@@ -1,18 +1,20 @@
1
- import { A as u, U as d, k as f, n as b, t as g, z as m } from "./locale-MM0U5eeR.js";
2
- var l = { findSimilarLabel: "Benzerlerini Bul" }, S = { findSimilarLabel: "Find Similar" };
3
- function p(t, i) {
4
- return i?.findSimilarLabel ? i.findSimilarLabel : (t ?? "tr").toLowerCase().startsWith("en") ? S.findSimilarLabel : l.findSimilarLabel;
1
+ import { t as u } from "./widget-base-TgwiA8cD.js";
2
+ import { D as d, _ as f, j as m, v as b } from "./context-VIG4SVcS.js";
3
+ import { t as g } from "./locale-CfqNifrU.js";
4
+ var l = { findSimilarLabel: "Benzerlerini Bul" }, p = { findSimilarLabel: "Find Similar" };
5
+ function S(t, i) {
6
+ return i?.findSimilarLabel ? i.findSimilarLabel : (t ?? "tr").toLowerCase().startsWith("en") ? p.findSimilarLabel : l.findSimilarLabel;
5
7
  }
6
8
  function s(t) {
7
9
  const i = typeof t.sku == "string" && t.sku.length > 0 ? t.sku : void 0, o = typeof t.pageContext?.sku == "string" && t.pageContext.sku.length > 0 ? t.pageContext.sku : void 0;
8
10
  return i ?? o;
9
11
  }
10
- var _ = class extends b {
12
+ var _ = class extends u {
11
13
  constructor(...t) {
12
14
  super(...t), this._button = null, this._label = l.findSimilarLabel;
13
15
  }
14
16
  async onInit(t) {
15
- this._label = p(t.locale, t.i18n), this.root.classList.add("gengage-simbut-root"), window.getComputedStyle(this.root).position === "static" && (this.root.style.position = "relative");
17
+ this._label = S(t.locale, t.i18n), this.root.classList.add("gengage-simbut-root"), window.getComputedStyle(this.root).position === "static" && (this.root.style.position = "relative");
16
18
  const i = document.createElement("button");
17
19
  i.type = "button", i.className = "gengage-chat-find-similar-pill", i.lang = g(t.locale), i.textContent = this._label, this._button = i;
18
20
  const o = () => {
@@ -20,14 +22,14 @@ var _ = class extends b {
20
22
  };
21
23
  i.addEventListener("click", (h) => {
22
24
  h.stopPropagation();
23
- const n = s(this.config);
24
- if (!n) return;
25
- const a = this.config.imageUrl, e = typeof a == "string" && d(a) ? a : void 0;
26
- if (m(this._label, "findSimilar"), f(n), this.config.onFindSimilar) {
27
- this.config.onFindSimilar(e ? {
28
- sku: n,
29
- imageUrl: e
30
- } : { sku: n });
25
+ const e = s(this.config);
26
+ if (!e) return;
27
+ const a = this.config.imageUrl, n = typeof a == "string" && m(a) ? a : void 0;
28
+ if (d(this._label, "findSimilar"), f(e), this.config.onFindSimilar) {
29
+ this.config.onFindSimilar(n ? {
30
+ sku: e,
31
+ imageUrl: n
32
+ } : { sku: e });
31
33
  return;
32
34
  }
33
35
  const r = this.config.chat;
@@ -35,13 +37,13 @@ var _ = class extends b {
35
37
  const c = {
36
38
  title: this._label,
37
39
  type: "findSimilar",
38
- payload: e ? {
39
- sku: n,
40
- image_url: e
41
- } : { sku: n }
40
+ payload: n ? {
41
+ sku: e,
42
+ image_url: n
43
+ } : { sku: e }
42
44
  };
43
- r.openWithAction(c, { sku: n });
44
- }), this.root.appendChild(i), o(), u("simbut");
45
+ r.openWithAction(c, { sku: e });
46
+ }), this.root.appendChild(i), o(), b("simbut");
45
47
  }
46
48
  onUpdate(t) {
47
49
  if (!this._button) return;
@@ -70,10 +72,10 @@ var _ = class extends b {
70
72
  }
71
73
  }
72
74
  };
73
- function k() {
75
+ function L() {
74
76
  return new _();
75
77
  }
76
78
  export {
77
- k as n,
79
+ L as n,
78
80
  _ as t
79
81
  };
package/dist/simbut.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as e, t as a } from "./simbut-Cb5RfaAp.js";
1
+ import { n as e, t as a } from "./simbut-BMWC6x_t.js";
2
2
  export {
3
3
  a as GengageSimBut,
4
4
  e as createSimButWidget
@@ -1,61 +1,3 @@
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
+ export * from './runtime.js';
60
2
  export { simRelCatalog } from './catalog.js';
61
3
  export type { SimRelCatalog, SimRelComponentName } from './catalog.js';
@@ -0,0 +1,59 @@
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';
@@ -0,0 +1,55 @@
1
+ import { a as t, c as o, n as r, o as a, t as i, u as e } from "./schemas-CLo8wCjs.js";
2
+ var n = a({
3
+ sku: o(),
4
+ name: o(),
5
+ imageUrl: o().url().optional(),
6
+ price: o().optional(),
7
+ originalPrice: o().optional(),
8
+ discountPercent: t().optional(),
9
+ url: o().url(),
10
+ brand: o().optional(),
11
+ rating: t().min(0).max(5).optional(),
12
+ reviewCount: t().int().nonnegative().optional()
13
+ }), c = a({
14
+ layout: i(["grid", "carousel"]).optional(),
15
+ columns: t().int().positive().optional()
16
+ }), s = a({
17
+ product: n,
18
+ index: t().int().nonnegative(),
19
+ discountType: i(["strike-through", "badge"]).optional()
20
+ }), d = a({
21
+ sku: o(),
22
+ label: o().optional(),
23
+ cartCode: o()
24
+ }), l = a({ actions: r(a({
25
+ label: o(),
26
+ action: a({
27
+ title: o(),
28
+ type: o(),
29
+ payload: e().optional()
30
+ })
31
+ })) }), p = a({ message: o().optional() }), m = { components: {
32
+ ProductGrid: {
33
+ schema: c,
34
+ description: "Outer grid or carousel container for similar products."
35
+ },
36
+ ProductCard: {
37
+ schema: s,
38
+ description: "A single product card with image, title, price, and actions."
39
+ },
40
+ AddToCartButton: {
41
+ schema: d,
42
+ description: "Add-to-cart CTA rendered inside or below a product card."
43
+ },
44
+ QuickActions: {
45
+ schema: l,
46
+ description: "A row of quick-action buttons below product info."
47
+ },
48
+ EmptyState: {
49
+ schema: p,
50
+ description: "Empty state shown when no similar products are available."
51
+ }
52
+ } };
53
+ export {
54
+ m as t
55
+ };
@@ -0,0 +1,8 @@
1
+ import { a, i as r, n as i, r as t, t as S } from "./runtime-BdwZZIrO.js";
2
+ export {
3
+ S as GengageSimRel,
4
+ t as createDefaultSimRelUISpecRegistry,
5
+ i as createSimRelWidget,
6
+ r as defaultSimRelUnknownUISpecRenderer,
7
+ a as renderSimRelUISpec
8
+ };