@cimulate/copilot-widget 1.42.1 → 1.43.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  `@cimulate/copilot-widget` follows [Semantic Versioning](https://semver.org/). Each entry is a released `package.json` version (deployed on merge to `master`), newest first.
4
4
 
5
+ ## 1.43.0 — 2026-09-23
6
+
7
+ - Messaging mode: the in-chat cart card is now overridable via the `Cart` key in `ComponentOverrides`, but as a **presentational** slot — an override replaces only the card body (items, totals, coupons), while checkout and the Apple/Google Pay express-payment iframe stay widget-owned and render beneath it. The slot receives its own `CartOverrideProps`: a display-only `DisplayCart` (with `checkoutButtonUrl`/`expressPaymentUrl` stripped) plus `productsToHighlight`/`readOnly`, and a narrower `CartOverrideApi` with **no** `sendMessage`. Basket edits go through a structured `api.cart` — `setQuantity(itemId, n)`, `remove(itemId)`, `applyCoupon(code)` — which the widget turns into the same request the built-in sends, clamps to the item's `minQuantity`..`maxQuantity`, and refuses while the cart is `readOnly` or loading. `readOnly` is true for every cart snapshot except the most recent; an override should still reflect it (and `api.isConnected`) in its own controls. The `Cart` slot is the one named override wrapped in an error boundary, so a throwing override body renders blank (the widget-owned checkout/express footer still renders) instead of tearing down the transcript. New exported types: `CartOverrideProps`, `CartOverrideApi`, `CartMutationApi`, `DisplayCart`.
8
+ - `CartItem` now exposes optional `minQuantity`/`maxQuantity`, the per-item quantity bounds a cart override's quantity control can clamp to (absent → `1..∞`). Additive and backward-compatible; the built-in cart is unchanged.
9
+
5
10
  ## 1.42.1 — 2026-09-22
6
11
 
7
12
  - Agentforce messaging mode now holds the first shopper send until the agent's welcome message has arrived (or a 3s fallback), even when the widget is already open. Fixes prompts and in-widget search submitting after conversation creation but before the welcome paints.
@@ -109,13 +109,13 @@ declare interface CommonParams {
109
109
  * One flat map from override key to custom-element tag name.
110
110
  *
111
111
  * `ProductTile`, `ProductCarousel`, `ProductDetailCard`, `ProductComparison`,
112
- * `ProgressSteps`, and `Suggestions` are the named keys the widget consults for
113
- * its built-in UI: register one and the widget mounts your element in place of
114
- * the default tile/carousel/detail card/comparison table/progress panel/
115
- * follow-up buttons (leave it unset and the built-in renders). Every other key
116
- * is matched against a `type:"tool_results"` block's top-level `output_name`
117
- * (never a field inside the arbitrary `data` payload); an unmatched block
118
- * renders nothing. All of them receive the same `OverrideProps`.
112
+ * `ProgressSteps`, `Suggestions`, and `Cart` are the named keys the widget
113
+ * consults for its built-in UI: register one and the widget mounts your element
114
+ * in place of the default tile/carousel/detail card/comparison table/progress
115
+ * panel/follow-up buttons/cart card (leave it unset and the built-in renders).
116
+ * Every other key is matched against a `type:"tool_results"` block's top-level
117
+ * `output_name` (never a field inside the arbitrary `data` payload); an
118
+ * unmatched block renders nothing. All of them receive the same `OverrideProps`.
119
119
  *
120
120
  * { ProductTile: "cx-product-card", recentOrders: "cx-recent-orders" }
121
121
  *
@@ -130,6 +130,19 @@ declare interface ComponentOverrides {
130
130
  ProductComparison?: OverrideTagName;
131
131
  ProgressSteps?: OverrideTagName;
132
132
  Suggestions?: OverrideTagName;
133
+ /**
134
+ * Replaces the in-chat cart BODY (items, totals, coupons) — a presentational
135
+ * slot. Checkout and the Apple/Google Pay iframe are NOT part of it: the widget
136
+ * keeps rendering them itself, beneath the override. The slot receives a
137
+ * {@link CartOverrideProps} — a display-only {@link DisplayCart} (no
138
+ * checkout/express URLs) and a {@link CartOverrideApi} whose `cart` methods are
139
+ * the only way to mutate the basket; there is no `sendMessage`. The widget
140
+ * marks every cart snapshot except the newest `readOnly` and refuses mutations
141
+ * while it is set (or the cart is busy/disconnected), but an override should
142
+ * also reflect `readOnly` in its controls so a shopper can't act on a stale
143
+ * basket.
144
+ */
145
+ Cart?: OverrideTagName;
133
146
  [key: string]: OverrideTagName | undefined;
134
147
  }
135
148
 
@@ -128,6 +128,8 @@ declare type CartItem = {
128
128
  name: string;
129
129
  imageUrl: string;
130
130
  quantity: number;
131
+ minQuantity?: number;
132
+ maxQuantity?: number;
131
133
  itemSubtotal: number;
132
134
  originalSubtotal: number;
133
135
  variants: CartItemVariant[];
@@ -144,6 +146,51 @@ declare type CartItemVariant = {
144
146
  value: string;
145
147
  };
146
148
 
149
+ /**
150
+ * The basket-mutation surface handed to a `Cart` override. Each method states an
151
+ * intent, not a message: the widget builds the natural-language request (using
152
+ * the same line identifier the built-in card sends), clamps quantity to the
153
+ * item's `minQuantity`..`maxQuantity`, and drops the mutation when the cart is
154
+ * read-only, loading, or disconnected. `itemId` is `CartItem.itemId` from the
155
+ * payload's cart. There is no free-text send.
156
+ */
157
+ export declare interface CartMutationApi {
158
+ setQuantity: (itemId: string, quantity: number) => void;
159
+ remove: (itemId: string) => void;
160
+ applyCoupon: (code: string) => void;
161
+ }
162
+
163
+ /**
164
+ * The api handed to a `Cart` override. Deliberately narrower than the shared
165
+ * {@link OverrideApi}: it has no `sendMessage`, so the most sensitive slot cannot
166
+ * post arbitrary text or reconcile a message by id. Basket edits go through the
167
+ * structured {@link CartMutationApi}; checkout and express payment stay
168
+ * widget-owned.
169
+ */
170
+ export declare interface CartOverrideApi extends Pick<MessagingContextType, "isConnected"> {
171
+ cart: CartMutationApi;
172
+ isLoading: MessagingContextType["loading"];
173
+ componentType: ComponentType;
174
+ mode: Mode;
175
+ }
176
+
177
+ /**
178
+ * The props a `Cart` override receives. Pinned to the cart slot: `name` is always
179
+ * `"Cart"`, `payload.cart` is a display-only {@link DisplayCart}, and `api` is the
180
+ * narrower {@link CartOverrideApi}. `readOnly` is true for every cart snapshot
181
+ * except the latest in the transcript; the widget refuses mutations while it is
182
+ * set, but an override should still reflect it in its own controls.
183
+ */
184
+ export declare interface CartOverrideProps {
185
+ name: "Cart";
186
+ payload: {
187
+ cart: DisplayCart;
188
+ productsToHighlight?: string[];
189
+ readOnly?: boolean;
190
+ };
191
+ api: CartOverrideApi;
192
+ }
193
+
147
194
  declare type CartResponse = {
148
195
  type: "cart";
149
196
  index: number;
@@ -217,13 +264,13 @@ declare type ComparisonTableRow = {
217
264
  * One flat map from override key to custom-element tag name.
218
265
  *
219
266
  * `ProductTile`, `ProductCarousel`, `ProductDetailCard`, `ProductComparison`,
220
- * `ProgressSteps`, and `Suggestions` are the named keys the widget consults for
221
- * its built-in UI: register one and the widget mounts your element in place of
222
- * the default tile/carousel/detail card/comparison table/progress panel/
223
- * follow-up buttons (leave it unset and the built-in renders). Every other key
224
- * is matched against a `type:"tool_results"` block's top-level `output_name`
225
- * (never a field inside the arbitrary `data` payload); an unmatched block
226
- * renders nothing. All of them receive the same `OverrideProps`.
267
+ * `ProgressSteps`, `Suggestions`, and `Cart` are the named keys the widget
268
+ * consults for its built-in UI: register one and the widget mounts your element
269
+ * in place of the default tile/carousel/detail card/comparison table/progress
270
+ * panel/follow-up buttons/cart card (leave it unset and the built-in renders).
271
+ * Every other key is matched against a `type:"tool_results"` block's top-level
272
+ * `output_name` (never a field inside the arbitrary `data` payload); an
273
+ * unmatched block renders nothing. All of them receive the same `OverrideProps`.
227
274
  *
228
275
  * { ProductTile: "cx-product-card", recentOrders: "cx-recent-orders" }
229
276
  *
@@ -238,6 +285,19 @@ export declare interface ComponentOverrides {
238
285
  ProductComparison?: OverrideTagName;
239
286
  ProgressSteps?: OverrideTagName;
240
287
  Suggestions?: OverrideTagName;
288
+ /**
289
+ * Replaces the in-chat cart BODY (items, totals, coupons) — a presentational
290
+ * slot. Checkout and the Apple/Google Pay iframe are NOT part of it: the widget
291
+ * keeps rendering them itself, beneath the override. The slot receives a
292
+ * {@link CartOverrideProps} — a display-only {@link DisplayCart} (no
293
+ * checkout/express URLs) and a {@link CartOverrideApi} whose `cart` methods are
294
+ * the only way to mutate the basket; there is no `sendMessage`. The widget
295
+ * marks every cart snapshot except the newest `readOnly` and refuses mutations
296
+ * while it is set (or the cart is busy/disconnected), but an override should
297
+ * also reflect `readOnly` in its controls so a shopper can't act on a stale
298
+ * basket.
299
+ */
300
+ Cart?: OverrideTagName;
241
301
  [key: string]: OverrideTagName | undefined;
242
302
  }
243
303
 
@@ -340,6 +400,15 @@ declare type CouponEntry = string | StructuredCoupon;
340
400
 
341
401
  declare type DialogPosition = "top" | "top-left" | "top-right" | "bottom" | "bottom-left" | "bottom-right" | "left" | "right" | "center";
342
402
 
403
+ /**
404
+ * The cart summary handed to a `Cart` override: {@link CartDetails} minus the
405
+ * transactional URLs. The widget renders checkout and Apple/Google Pay itself,
406
+ * beneath the override, so `checkoutButtonUrl` and `expressPaymentUrl` never
407
+ * enter customer markup — everything else is display data for the override to
408
+ * lay out.
409
+ */
410
+ export declare type DisplayCart = Omit<CartDetails, "checkoutButtonUrl" | "expressPaymentUrl">;
411
+
343
412
  declare const ENTRY_TYPES: readonly ["ask_cim", "search", "browse", "pdp"];
344
413
 
345
414
  export declare type EntryType = (typeof ENTRY_TYPES)[number];
@@ -770,10 +839,15 @@ export declare class OverrideElement extends HTMLElement {
770
839
  * the current (active) step.
771
840
  * - "Suggestions" → { suggestions: string[] } — the follow-up suggestion
772
841
  * strings shown after an agent message, in order.
842
+ * - "Cart" → uses its own {@link CartOverrideProps}, not this
843
+ * generic shape: a display-only {@link DisplayCart} plus
844
+ * a structured `cart` mutation api and NO `sendMessage`.
845
+ * Checkout and express payment stay widget-owned. See
846
+ * ComponentOverrides.Cart.
773
847
  * - any custom-block key → the `tool_results` block's raw `data`, your own shape
774
848
  */
775
849
  export declare interface OverrideProps {
776
- /** The resolved override key: "ProductTile"/"ProductCarousel"/"ProductDetailCard"/"ProductComparison"/"ProgressSteps"/"Suggestions" for the built-in slots, else the `tool_results` block's `output_name`. */
850
+ /** The resolved override key: "ProductTile"/"ProductCarousel"/"ProductDetailCard"/"ProductComparison"/"ProgressSteps"/"Suggestions"/"Cart" for the built-in slots, else the `tool_results` block's `output_name`. */
777
851
  name: string;
778
852
  payload: unknown;
779
853
  api: OverrideApi;