@ziila/sdk 0.1.40 → 0.1.50

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.
@@ -1,3 +1,3 @@
1
1
  export { ZiilaWidget } from '../src/ZiilaWidget';
2
2
  export { isZiilaError } from '../src/utils';
3
- export type { ThemeTokens, ThemeStyles, ButtonElementStyle, ButtonVariant, ButtonSize, ButtonVariantStyle, ButtonSizeStyle, InputElementStyle, ThemeElement, ZiilaConfig, WidgetInitConfig, ZiilaEvent, ZiilaCommand, EventPayloadMap, CommandPayloadMap, AddToCartPayload, ProductViewedPayload, SearchPayload, ErrorPayload, ParentMessage, WidgetMessage, HandshakeMessage, ConfirmKind, } from '../src/types';
3
+ export type { ThemeTokens, ThemeStyles, ButtonElementStyle, ButtonVariant, ButtonSize, ButtonVariantStyle, ButtonSizeStyle, InputElementStyle, ThemeElement, ZiilaConfig, WidgetInitConfig, ZiilaEvent, ZiilaCommand, EventPayloadMap, CommandPayloadMap, AddToCartPayload, RemoveFromCartPayload, CartUpdatedItem, CartUpdatedPayload, ProductViewedPayload, SearchPayload, ErrorPayload, ParentMessage, WidgetMessage, HandshakeMessage, ConfirmKind, } from '../src/types';
@@ -14,6 +14,6 @@ export declare class ZiilaWidget {
14
14
  on<K extends ZiilaEvent>(event: K, handler: (data: EventPayloadMap[K]) => void): () => void;
15
15
  off<K extends ZiilaEvent>(event: K, handler: (data: EventPayloadMap[K]) => void): void;
16
16
  emit<K extends ZiilaCommand>(command: K, payload?: CommandPayloadMap[K]): void;
17
- update(updates: Partial<Pick<ZiilaConfig, 'locale' | 'theme'>>): void;
17
+ update(updates: Partial<Pick<ZiilaConfig, 'locale' | 'theme' | 'cartId'>>): void;
18
18
  destroy(): void;
19
19
  }
@@ -67,6 +67,8 @@ export interface ThemeStyles {
67
67
  export interface ZiilaConfig {
68
68
  apiKey: string;
69
69
  agentId: string;
70
+ /** Merchant cart id — required; all cart mutations target this cart. */
71
+ cartId: string;
70
72
  container: string | HTMLElement;
71
73
  locale?: string;
72
74
  widgetTitle?: string;
@@ -75,8 +77,24 @@ export interface ZiilaConfig {
75
77
  }
76
78
  export interface AddToCartPayload {
77
79
  sku: string;
80
+ /** The sku's new total quantity in the cart — never a delta. */
78
81
  quantity: number;
79
82
  }
83
+ export interface RemoveFromCartPayload {
84
+ sku: string;
85
+ /** The sku's new total quantity; 0 means fully removed. */
86
+ quantity: number;
87
+ }
88
+ export interface CartUpdatedItem {
89
+ sku: string;
90
+ quantity: number;
91
+ price: number;
92
+ }
93
+ export interface CartUpdatedPayload {
94
+ items: CartUpdatedItem[];
95
+ totalItems: number;
96
+ grandTotal: number;
97
+ }
80
98
  export interface ProductViewedPayload {
81
99
  sku: string;
82
100
  }
@@ -87,11 +105,13 @@ export interface ErrorPayload {
87
105
  code: string;
88
106
  message: string;
89
107
  }
90
- export type ZiilaEvent = 'ready' | 'addToCart' | 'productViewed' | 'search' | 'error';
108
+ export type ZiilaEvent = 'ready' | 'addToCart' | 'removeFromCart' | 'cartUpdated' | 'productViewed' | 'search' | 'error';
91
109
  export type ZiilaCommand = 'clear';
92
110
  export interface EventPayloadMap {
93
111
  ready: undefined;
94
112
  addToCart: AddToCartPayload;
113
+ removeFromCart: RemoveFromCartPayload;
114
+ cartUpdated: CartUpdatedPayload;
95
115
  productViewed: ProductViewedPayload;
96
116
  search: SearchPayload;
97
117
  error: ErrorPayload;
@@ -115,7 +135,7 @@ export type ParentMessage = {
115
135
  payload?: unknown;
116
136
  } | {
117
137
  type: 'UPDATE';
118
- payload: Partial<Pick<ZiilaConfig, 'locale' | 'theme'>>;
138
+ payload: Partial<Pick<ZiilaConfig, 'locale' | 'theme' | 'cartId'>>;
119
139
  } | {
120
140
  type: 'THEME_UPDATE';
121
141
  payload: Partial<ThemeTokens>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ziila/sdk",
3
- "version": "0.1.40",
3
+ "version": "0.1.50",
4
4
  "description": "Ziila Shopping Assistant SDK — embeddable widget loader and host-page bridge.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {