@jay-framework/wix-cart 0.19.7 → 0.21.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.
@@ -1,13 +1,154 @@
1
1
  import * as _jay_framework_runtime from '@jay-framework/runtime';
2
2
  import { EventEmitter, HTMLElementProxy, HTMLElementCollectionProxy } from '@jay-framework/runtime';
3
3
  import { Getter } from '@jay-framework/reactive';
4
- import { currentCart } from '@wix/ecom';
5
- import { LineItem, Cart } from '@wix/auto_sdk_ecom_current-cart';
6
- import { BuildDescriptors } from '@wix/sdk-types';
4
+ import { WixClient } from '@wix/sdk';
7
5
  import * as _jay_framework_fullstack_component from '@jay-framework/fullstack-component';
8
6
  import { Signals, PageProps } from '@jay-framework/fullstack-component';
9
7
  import * as _jay_framework_component from '@jay-framework/component';
10
- import { redirects } from '@wix/redirects';
8
+
9
+ /**
10
+ * Wix eCommerce Cart types.
11
+ * Copied and simplified from @wix/auto_sdk_ecom_current-cart.
12
+ */
13
+ interface Cart {
14
+ _id?: string;
15
+ id?: string;
16
+ lineItems?: LineItem[];
17
+ buyerInfo?: BuyerInfo;
18
+ currency?: string;
19
+ subtotal?: CartAmount;
20
+ appliedDiscount?: CartDiscount;
21
+ appliedDiscounts?: Array<{
22
+ coupon?: CartDiscount['coupon'];
23
+ discountRule?: CartDiscount['discountRule'];
24
+ }>;
25
+ }
26
+ interface LineItemUrl {
27
+ relativePath?: string;
28
+ url?: string;
29
+ }
30
+ interface LineItemImage {
31
+ id?: string;
32
+ url?: string;
33
+ height?: number;
34
+ width?: number;
35
+ }
36
+ interface LineItem {
37
+ _id?: string;
38
+ id?: string;
39
+ quantity?: number;
40
+ catalogReference?: CatalogReference;
41
+ productName?: ProductName;
42
+ url?: string | LineItemUrl;
43
+ price?: CartAmount;
44
+ fullPrice?: CartAmount;
45
+ priceBeforeDiscounts?: CartAmount;
46
+ lineItemPrice?: CartAmount;
47
+ descriptionLines?: DescriptionLine[];
48
+ image?: string | LineItemImage;
49
+ availability?: Availability;
50
+ physicalProperties?: PhysicalProperties;
51
+ couponScopes?: Array<{
52
+ namespace?: string;
53
+ group?: {
54
+ name?: string;
55
+ entityId?: string;
56
+ };
57
+ }>;
58
+ itemType?: ItemType;
59
+ paymentOption?: string;
60
+ }
61
+ interface CatalogReference {
62
+ catalogItemId?: string;
63
+ appId?: string;
64
+ options?: Record<string, unknown>;
65
+ }
66
+ interface ProductName {
67
+ original?: string;
68
+ translated?: string;
69
+ }
70
+ interface CartAmount {
71
+ amount?: string;
72
+ convertedAmount?: string;
73
+ formattedAmount?: string;
74
+ formattedConvertedAmount?: string;
75
+ }
76
+ interface CartDiscount {
77
+ coupon?: {
78
+ _id?: string;
79
+ code?: string;
80
+ amount?: CartAmount;
81
+ name?: string;
82
+ };
83
+ discountRule?: {
84
+ _id?: string;
85
+ name?: string;
86
+ amount?: CartAmount;
87
+ };
88
+ merchantDiscount?: {
89
+ amount?: CartAmount;
90
+ };
91
+ }
92
+ interface DescriptionLine {
93
+ name?: ProductName;
94
+ plainText?: ProductName;
95
+ colorInfo?: {
96
+ original?: string;
97
+ translated?: string;
98
+ code?: string;
99
+ };
100
+ }
101
+ interface BuyerInfo {
102
+ visitorId?: string;
103
+ memberId?: string;
104
+ contactId?: string;
105
+ }
106
+ interface Availability {
107
+ status?: string;
108
+ quantityAvailable?: number;
109
+ }
110
+ interface PhysicalProperties {
111
+ weight?: number;
112
+ sku?: string;
113
+ shippable?: boolean;
114
+ }
115
+ interface ItemType {
116
+ preset?: string;
117
+ custom?: string;
118
+ }
119
+ interface EstimateCurrentCartTotalsResponse {
120
+ cart?: Cart;
121
+ calculatedLineItems?: CalculatedLineItem[];
122
+ priceSummary?: PriceSummary;
123
+ appliedDiscounts?: Array<{
124
+ coupon?: CartDiscount['coupon'];
125
+ discountRule?: CartDiscount['discountRule'];
126
+ }>;
127
+ [key: string]: any;
128
+ }
129
+ interface CalculatedLineItem {
130
+ lineItemId?: string;
131
+ pricesBreakdown?: PriceBreakdown;
132
+ [key: string]: any;
133
+ }
134
+ interface PriceBreakdown {
135
+ totalPriceAfterTax?: CartAmount;
136
+ totalPriceBeforeTax?: CartAmount;
137
+ totalDiscount?: CartAmount;
138
+ price?: CartAmount;
139
+ priceBeforeDiscounts?: CartAmount;
140
+ lineItemPrice?: CartAmount;
141
+ tax?: CartAmount;
142
+ [key: string]: any;
143
+ }
144
+ interface PriceSummary {
145
+ subtotal?: CartAmount;
146
+ total?: CartAmount;
147
+ shipping?: CartAmount;
148
+ tax?: CartAmount;
149
+ discount?: CartAmount;
150
+ [key: string]: any;
151
+ }
11
152
 
12
153
  /**
13
154
  * Cart Helper Types and Functions
@@ -16,9 +157,7 @@ import { redirects } from '@wix/redirects';
16
157
  * Used by both context and components.
17
158
  */
18
159
 
19
- type CurrentCartClient = BuildDescriptors<typeof currentCart, {}>;
20
- type EstimateMethod = CurrentCartClient['estimateCurrentCartTotals'];
21
- type EstimateTotalsResult = Awaited<ReturnType<EstimateMethod>>;
160
+ type EstimateTotalsResult = EstimateCurrentCartTotalsResponse;
22
161
  /**
23
162
  * Cart line item for display
24
163
  */
@@ -117,16 +256,11 @@ declare function mapCartToIndicator(cart: Cart | null): CartIndicatorState;
117
256
  * The Wix Cart API returns 404 when no cart exists (before first item is added).
118
257
  * This helper normalizes that case to return null, which the mappers handle as empty.
119
258
  */
120
- declare function getCurrentCartOrNull(cartClient: CurrentCartClient): Promise<Cart | null>;
259
+ declare function getCurrentCartOrNull(wixClient: WixClient): Promise<Cart | null>;
121
260
  /**
122
261
  * Estimate the current cart totals, treating 404 as an empty cart.
123
- *
124
- * This API provides complete price totals including tax calculations.
125
- * Use this for cart pages where accurate totals are needed.
126
- *
127
- * @see https://dev.wix.com/docs/sdk/backend-modules/ecom/current-cart/estimate-current-cart-totals
128
262
  */
129
- declare function estimateCurrentCartTotalsOrNull(cartClient: CurrentCartClient): Promise<EstimateTotalsResult | null>;
263
+ declare function estimateCurrentCartTotalsOrNull(wixClient: WixClient): Promise<any | null>;
130
264
  /**
131
265
  * Map estimate totals response to CartState.
132
266
  * The estimate response includes calculated totals with tax.
@@ -283,11 +417,7 @@ interface CartIndicatorRefs {
283
417
  }
284
418
 
285
419
  interface WixCartService {
286
- cart: BuildDescriptors<typeof currentCart, {}>;
287
- redirects: BuildDescriptors<typeof redirects, {}>;
288
- urls: {
289
- thankYou: string;
290
- };
420
+ wixClient: WixClient;
291
421
  }
292
422
  /**
293
423
  * Server service marker for Wix Cart.
@@ -1,9 +1,6 @@
1
- export { A as AddToCartOptions, q as CartIndicatorState, n as CartLineItem, C as CartOperationResult, l as CartState, o as CartSummary, R as ReactiveCartIndicator, b as WIX_CART_CONTEXT, c as WixCartContext, r as cartIndicator, s as cartPage, u as init, t as miniCart } from './index.client-C7UwcsSn.js';
1
+ export { A as AddToCartOptions, q as CartIndicatorState, n as CartLineItem, C as CartOperationResult, l as CartState, o as CartSummary, R as ReactiveCartIndicator, b as WIX_CART_CONTEXT, c as WixCartContext, r as cartIndicator, s as cartPage, u as init, t as miniCart } from './index.client-Ca5v2viE.js';
2
2
  import '@jay-framework/runtime';
3
3
  import '@jay-framework/reactive';
4
- import '@wix/ecom';
5
- import '@wix/auto_sdk_ecom_current-cart';
6
- import '@wix/sdk-types';
4
+ import '@wix/sdk';
7
5
  import '@jay-framework/fullstack-component';
8
6
  import '@jay-framework/component';
9
- import '@wix/redirects';