@cimulate/copilot-widget 1.57.1 → 1.58.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 +7 -0
- package/README.md +20 -1
- package/dist/cimulate-copilot-widget.d.ts +22 -11
- package/dist/cimulate-copilot-widget.es.js +972 -964
- package/dist/cimulate-copilot-widget.umd.js +17 -17
- package/dist/copilot.es.js +972 -964
- package/dist/copilot.umd.js +17 -17
- package/dist/messaging.css +1 -1
- package/dist/messaging.d.ts +84 -25
- package/dist/messaging.es.js +11585 -10770
- package/dist/messaging.umd.js +34 -34
- package/package.json +1 -1
package/dist/messaging.d.ts
CHANGED
|
@@ -35,6 +35,8 @@ import { RefinedSearch } from '@cimulate/copilot-sdk';
|
|
|
35
35
|
import { SearchParams } from '@cimulate/copilot-sdk';
|
|
36
36
|
import { SessionContextEntry } from '@cimulate/agentforce-sdk';
|
|
37
37
|
|
|
38
|
+
export declare const addCartActionListener: (listener: EventListener) => void;
|
|
39
|
+
|
|
38
40
|
export declare const addCartUpdateListener: (listener: EventListener) => void;
|
|
39
41
|
|
|
40
42
|
declare interface AddToCartParams {
|
|
@@ -103,8 +105,51 @@ declare interface BrowseState extends CommonParams {
|
|
|
103
105
|
categoryName?: string;
|
|
104
106
|
}
|
|
105
107
|
|
|
108
|
+
export declare const CART_ACTION_EVENT = "cimulate:cart-action";
|
|
109
|
+
|
|
106
110
|
export declare const CART_UPDATE_EVENT = "cimulate:cart-update";
|
|
107
111
|
|
|
112
|
+
/**
|
|
113
|
+
* `detail` of `cimulate:cart-action`. Call `respond` once with the latest cart
|
|
114
|
+
* after the storefront finishes the action. `itemId` is the basket line.
|
|
115
|
+
* `quantity` and `remove` also include `productId` (empty when the line has none)
|
|
116
|
+
* and `variants` (`lbl`, `type`, `value`), omitting entries with no value.
|
|
117
|
+
*/
|
|
118
|
+
export declare type CartActionDetail = CartActionRequest & {
|
|
119
|
+
respond: (result: CartActionResult) => void;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export declare type CartActionRequest = {
|
|
123
|
+
action: "get";
|
|
124
|
+
} | {
|
|
125
|
+
action: "quantity";
|
|
126
|
+
itemId: string;
|
|
127
|
+
quantity: number;
|
|
128
|
+
productId: string;
|
|
129
|
+
variants: CartItemVariant[];
|
|
130
|
+
} | {
|
|
131
|
+
action: "remove";
|
|
132
|
+
itemId: string;
|
|
133
|
+
productId: string;
|
|
134
|
+
variants: CartItemVariant[];
|
|
135
|
+
} | {
|
|
136
|
+
action: "coupon";
|
|
137
|
+
code: string;
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Cart the storefront passes to `respond` after it handles `cimulate:cart-action`.
|
|
142
|
+
* `cart` on a failure is the basket the storefront still knows about, when it has one.
|
|
143
|
+
*/
|
|
144
|
+
export declare type CartActionResult = {
|
|
145
|
+
ok: true;
|
|
146
|
+
cart: CartDetails;
|
|
147
|
+
} | {
|
|
148
|
+
ok: false;
|
|
149
|
+
error: string;
|
|
150
|
+
cart?: CartDetails;
|
|
151
|
+
};
|
|
152
|
+
|
|
108
153
|
export declare type CartChange = CartLineChange | CartCouponChange;
|
|
109
154
|
|
|
110
155
|
/** A change to the set of applied coupon codes. */
|
|
@@ -192,11 +237,8 @@ export declare interface CartMutationApi {
|
|
|
192
237
|
}
|
|
193
238
|
|
|
194
239
|
/**
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
* post arbitrary text or reconcile a message by id. Basket edits go through the
|
|
198
|
-
* structured {@link CartMutationApi}; checkout and express payment stay
|
|
199
|
-
* widget-owned.
|
|
240
|
+
* Structured basket mutations without `sendMessage`.
|
|
241
|
+
* Agent-mode checkout stays widget-owned; direct-mode overrides own payment controls.
|
|
200
242
|
*/
|
|
201
243
|
export declare interface CartOverrideApi extends Pick<MessagingContextType, "isConnected"> {
|
|
202
244
|
cart: CartMutationApi;
|
|
@@ -242,6 +284,13 @@ declare type CartResponseData = {
|
|
|
242
284
|
};
|
|
243
285
|
};
|
|
244
286
|
|
|
287
|
+
/**
|
|
288
|
+
* `"agent"` (default) edits the basket with natural-language prompts.
|
|
289
|
+
* `"direct"` dispatches `cimulate:cart-action` and renders the cart the
|
|
290
|
+
* storefront returns from `detail.respond`.
|
|
291
|
+
*/
|
|
292
|
+
export declare type CartTransport = "agent" | "direct";
|
|
293
|
+
|
|
245
294
|
/**
|
|
246
295
|
* Primary action for a settled cart mutation, derived from the previous-vs-new
|
|
247
296
|
* cart diff, or from the agent's `cartSummary.cartOperation` (matched
|
|
@@ -361,16 +410,9 @@ export declare interface ComponentOverrides {
|
|
|
361
410
|
*/
|
|
362
411
|
OrderConfirmation?: OverrideTagName;
|
|
363
412
|
/**
|
|
364
|
-
*
|
|
365
|
-
*
|
|
366
|
-
*
|
|
367
|
-
* {@link CartOverrideProps} — a display-only {@link DisplayCart} (no
|
|
368
|
-
* checkout/express URLs) and a {@link CartOverrideApi} whose `cart` methods are
|
|
369
|
-
* the only way to mutate the basket; there is no `sendMessage`. The widget
|
|
370
|
-
* marks every cart snapshot except the newest `readOnly` and refuses mutations
|
|
371
|
-
* while it is set (or the cart is busy/disconnected), but an override should
|
|
372
|
-
* also reflect `readOnly` in its controls so a shopper can't act on a stale
|
|
373
|
-
* basket.
|
|
413
|
+
* Receives {@link CartOverrideProps} with display data and structured cart actions.
|
|
414
|
+
* Agent mode replaces the cart body; checkout stays widget-owned.
|
|
415
|
+
* Direct mode replaces the iframe or built-in cart and its payment controls.
|
|
374
416
|
*/
|
|
375
417
|
Cart?: OverrideTagName;
|
|
376
418
|
/**
|
|
@@ -501,13 +543,7 @@ declare type CouponEntry = string | StructuredCoupon;
|
|
|
501
543
|
|
|
502
544
|
declare type DialogPosition = "top" | "top-left" | "top-right" | "bottom" | "bottom-left" | "bottom-right" | "left" | "right" | "center";
|
|
503
545
|
|
|
504
|
-
/**
|
|
505
|
-
* The cart summary handed to a `Cart` override: {@link CartDetails} minus the
|
|
506
|
-
* transactional URLs. The widget renders checkout and Apple/Google Pay itself,
|
|
507
|
-
* beneath the override, so `checkoutButtonUrl` and `expressPaymentUrl` never
|
|
508
|
-
* enter customer markup — everything else is display data for the override to
|
|
509
|
-
* lay out.
|
|
510
|
-
*/
|
|
546
|
+
/** Cart display data excludes checkout and express payment URLs in both modes. */
|
|
511
547
|
export declare type DisplayCart = Omit<CartDetails, "checkoutButtonUrl" | "expressPaymentUrl">;
|
|
512
548
|
|
|
513
549
|
declare const ENTRY_TYPES: readonly ["ask_cim", "search", "browse", "pdp"];
|
|
@@ -560,7 +596,7 @@ export declare function getAuthLinkKey(): Promise<string>;
|
|
|
560
596
|
|
|
561
597
|
export declare function getPageContext(): PageContext | null;
|
|
562
598
|
|
|
563
|
-
export declare type HeaderActionName = "close" | "toggleExpanded" | "toggleFullscreen" | "toggleDialogPosition" | "minimize" | "clearChat" | "endConversation" | "downloadTranscript";
|
|
599
|
+
export declare type HeaderActionName = "cart" | "close" | "toggleExpanded" | "toggleFullscreen" | "toggleDialogPosition" | "minimize" | "clearChat" | "endConversation" | "downloadTranscript";
|
|
564
600
|
|
|
565
601
|
/**
|
|
566
602
|
* Header controls a `HeaderActions` override can invoke. Each method calls the
|
|
@@ -734,6 +770,13 @@ export declare interface MessagingContextType {
|
|
|
734
770
|
* is not connected or the request fails.
|
|
735
771
|
*/
|
|
736
772
|
getAuthLinkKey: () => Promise<string>;
|
|
773
|
+
cartTransport: CartTransport;
|
|
774
|
+
directCart: CartDetails | null;
|
|
775
|
+
directCartError: string | null;
|
|
776
|
+
directCartLoading: boolean;
|
|
777
|
+
storefrontCartPageUrl: string;
|
|
778
|
+
loadDirectCart: () => Promise<void>;
|
|
779
|
+
applyDirectCartChange: (request: CartActionRequest) => Promise<SendMessageResult>;
|
|
737
780
|
}
|
|
738
781
|
|
|
739
782
|
/**
|
|
@@ -864,9 +907,20 @@ export declare interface MessagingModeConfig {
|
|
|
864
907
|
* entries are ignored. `null` hides the connecting indicator entirely.
|
|
865
908
|
*/
|
|
866
909
|
connectingMessages?: readonly string[] | null;
|
|
910
|
+
/**
|
|
911
|
+
* Who edits the basket. `"agent"` (default) sends the natural-language cart
|
|
912
|
+
* prompts. `"direct"` dispatches `cimulate:cart-action` and renders the cart
|
|
913
|
+
* the storefront passes to `detail.respond`.
|
|
914
|
+
*/
|
|
915
|
+
cartTransport?: CartTransport;
|
|
916
|
+
/**
|
|
917
|
+
* Storefront cart page embedded in the cart tab. When set, that page replaces
|
|
918
|
+
* the built-in lines, coupon field, totals, and checkout.
|
|
919
|
+
*/
|
|
920
|
+
storefrontCartPageUrl?: string;
|
|
867
921
|
}
|
|
868
922
|
|
|
869
|
-
export declare const MessagingProvider: ({ scrt2Url, orgId, esDeveloperName, routingAttributes, conversationId: configConversationId, continuationToken: configContinuationToken, lastEventId: configLastEventId, capabilitiesVersion, enablePageContext, enableLogging, onConnect, onMessage, onError, onProductResult, onEndConversation, onSessionUpdate, onWelcomeTimeout, children, }: MessagingProviderProps) => JSX_2.Element;
|
|
923
|
+
export declare const MessagingProvider: ({ scrt2Url, orgId, esDeveloperName, routingAttributes, conversationId: configConversationId, continuationToken: configContinuationToken, lastEventId: configLastEventId, capabilitiesVersion, enablePageContext, enableLogging, onConnect, onMessage, onError, onProductResult, onEndConversation, onSessionUpdate, onWelcomeTimeout, cartTransport, storefrontCartPageUrl, children, }: MessagingProviderProps) => JSX_2.Element;
|
|
870
924
|
|
|
871
925
|
declare interface MessagingProviderProps {
|
|
872
926
|
scrt2Url: string;
|
|
@@ -887,6 +941,8 @@ declare interface MessagingProviderProps {
|
|
|
887
941
|
onEndConversation?: (conversationId: string | null) => Promise<void> | void;
|
|
888
942
|
onSessionUpdate?: (update: MessagingSessionUpdate) => void;
|
|
889
943
|
onWelcomeTimeout?: () => void;
|
|
944
|
+
cartTransport?: CartTransport;
|
|
945
|
+
storefrontCartPageUrl?: string;
|
|
890
946
|
children: ReactNode;
|
|
891
947
|
}
|
|
892
948
|
|
|
@@ -1121,7 +1177,8 @@ export declare interface OverrideFailureOptions {
|
|
|
1121
1177
|
* - "Cart" → uses its own {@link CartOverrideProps}, not this
|
|
1122
1178
|
* generic shape: a display-only {@link DisplayCart} plus
|
|
1123
1179
|
* a structured `cart` mutation api and NO `sendMessage`.
|
|
1124
|
-
*
|
|
1180
|
+
* In agent mode, checkout and express payment stay widget-owned.
|
|
1181
|
+
* In direct mode, the override replaces the cart and its payment controls. See
|
|
1125
1182
|
* ComponentOverrides.Cart.
|
|
1126
1183
|
* - "HeaderActions" → uses its own {@link HeaderActionsOverrideProps}:
|
|
1127
1184
|
* `payload.actions` is the live header state, and `api`
|
|
@@ -1359,6 +1416,8 @@ declare type RangeFilters = Array<{
|
|
|
1359
1416
|
max: number;
|
|
1360
1417
|
}>;
|
|
1361
1418
|
|
|
1419
|
+
export declare const removeCartActionListener: (listener: EventListener) => void;
|
|
1420
|
+
|
|
1362
1421
|
export declare const removeCartUpdateListener: (listener: EventListener) => void;
|
|
1363
1422
|
|
|
1364
1423
|
/**
|