omni-sync-sdk 0.19.4 → 0.20.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/LICENSE +0 -0
- package/dist/index.d.mts +55 -1
- package/dist/index.d.ts +55 -1
- package/dist/index.js +35 -2
- package/dist/index.mjs +35 -2
- package/package.json +9 -10
package/LICENSE
ADDED
|
File without changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1778,9 +1778,36 @@ interface Checkout {
|
|
|
1778
1778
|
*/
|
|
1779
1779
|
reservation?: ReservationInfo;
|
|
1780
1780
|
}
|
|
1781
|
+
/**
|
|
1782
|
+
* Options for creating a checkout from a cart.
|
|
1783
|
+
*
|
|
1784
|
+
* Supports **partial checkout** (AliExpress-style): pass `selectedItemIds` to
|
|
1785
|
+
* checkout only specific items. After payment, only selected items are removed
|
|
1786
|
+
* from the cart - remaining items stay for future purchases.
|
|
1787
|
+
*/
|
|
1781
1788
|
interface CreateCheckoutDto {
|
|
1789
|
+
/** The cart ID to create checkout from */
|
|
1782
1790
|
cartId: string;
|
|
1791
|
+
/** Optional customer ID to associate with checkout */
|
|
1783
1792
|
customerId?: string;
|
|
1793
|
+
/**
|
|
1794
|
+
* **Partial checkout**: Only include these cart item IDs in the checkout.
|
|
1795
|
+
* If omitted, all cart items are included (full cart checkout).
|
|
1796
|
+
*
|
|
1797
|
+
* After successful payment:
|
|
1798
|
+
* - Selected items are removed from the cart
|
|
1799
|
+
* - Unselected items remain in the cart (cart stays ACTIVE)
|
|
1800
|
+
*
|
|
1801
|
+
* @example
|
|
1802
|
+
* ```typescript
|
|
1803
|
+
* // Checkout only items 1 and 3, leave item 2 in cart
|
|
1804
|
+
* const checkout = await omni.createCheckout({
|
|
1805
|
+
* cartId: 'cart_123',
|
|
1806
|
+
* selectedItemIds: ['item_1', 'item_3'],
|
|
1807
|
+
* });
|
|
1808
|
+
* ```
|
|
1809
|
+
*/
|
|
1810
|
+
selectedItemIds?: string[];
|
|
1784
1811
|
}
|
|
1785
1812
|
interface SetCheckoutCustomerDto {
|
|
1786
1813
|
email: string;
|
|
@@ -4215,14 +4242,41 @@ declare class OmniSyncClient {
|
|
|
4215
4242
|
* ```
|
|
4216
4243
|
*/
|
|
4217
4244
|
onLogout(): void;
|
|
4245
|
+
/**
|
|
4246
|
+
* Clear cart cache after successful checkout
|
|
4247
|
+
*
|
|
4248
|
+
* Call this after a successful order to ensure the next smartGetCart()
|
|
4249
|
+
* creates a fresh cart instead of returning the converted one.
|
|
4250
|
+
*
|
|
4251
|
+
* @example
|
|
4252
|
+
* ```typescript
|
|
4253
|
+
* // After payment success
|
|
4254
|
+
* if (paymentStatus === 'succeeded') {
|
|
4255
|
+
* omni.onCheckoutComplete();
|
|
4256
|
+
* omni.clearLocalCart(); // Also clear localStorage for guests
|
|
4257
|
+
* }
|
|
4258
|
+
* ```
|
|
4259
|
+
*/
|
|
4260
|
+
onCheckoutComplete(): void;
|
|
4218
4261
|
/**
|
|
4219
4262
|
* Create a checkout from a cart
|
|
4220
4263
|
* Starts the checkout process and returns checkout with available options
|
|
4221
4264
|
*
|
|
4265
|
+
* **Partial Checkout (AliExpress-style):**
|
|
4266
|
+
* Pass `selectedItemIds` to checkout only specific items from the cart.
|
|
4267
|
+
* After payment, only the selected items are removed from the cart -
|
|
4268
|
+
* remaining items stay in the cart for future purchases.
|
|
4269
|
+
*
|
|
4222
4270
|
* @example
|
|
4223
4271
|
* ```typescript
|
|
4272
|
+
* // Full cart checkout (default)
|
|
4224
4273
|
* const checkout = await omni.createCheckout({ cartId: 'cart_123' });
|
|
4225
|
-
*
|
|
4274
|
+
*
|
|
4275
|
+
* // Partial checkout - only buy selected items
|
|
4276
|
+
* const checkout = await omni.createCheckout({
|
|
4277
|
+
* cartId: 'cart_123',
|
|
4278
|
+
* selectedItemIds: ['item_1', 'item_3'], // Only these items will be purchased
|
|
4279
|
+
* });
|
|
4226
4280
|
* ```
|
|
4227
4281
|
*/
|
|
4228
4282
|
createCheckout(data: CreateCheckoutDto): Promise<Checkout>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1778,9 +1778,36 @@ interface Checkout {
|
|
|
1778
1778
|
*/
|
|
1779
1779
|
reservation?: ReservationInfo;
|
|
1780
1780
|
}
|
|
1781
|
+
/**
|
|
1782
|
+
* Options for creating a checkout from a cart.
|
|
1783
|
+
*
|
|
1784
|
+
* Supports **partial checkout** (AliExpress-style): pass `selectedItemIds` to
|
|
1785
|
+
* checkout only specific items. After payment, only selected items are removed
|
|
1786
|
+
* from the cart - remaining items stay for future purchases.
|
|
1787
|
+
*/
|
|
1781
1788
|
interface CreateCheckoutDto {
|
|
1789
|
+
/** The cart ID to create checkout from */
|
|
1782
1790
|
cartId: string;
|
|
1791
|
+
/** Optional customer ID to associate with checkout */
|
|
1783
1792
|
customerId?: string;
|
|
1793
|
+
/**
|
|
1794
|
+
* **Partial checkout**: Only include these cart item IDs in the checkout.
|
|
1795
|
+
* If omitted, all cart items are included (full cart checkout).
|
|
1796
|
+
*
|
|
1797
|
+
* After successful payment:
|
|
1798
|
+
* - Selected items are removed from the cart
|
|
1799
|
+
* - Unselected items remain in the cart (cart stays ACTIVE)
|
|
1800
|
+
*
|
|
1801
|
+
* @example
|
|
1802
|
+
* ```typescript
|
|
1803
|
+
* // Checkout only items 1 and 3, leave item 2 in cart
|
|
1804
|
+
* const checkout = await omni.createCheckout({
|
|
1805
|
+
* cartId: 'cart_123',
|
|
1806
|
+
* selectedItemIds: ['item_1', 'item_3'],
|
|
1807
|
+
* });
|
|
1808
|
+
* ```
|
|
1809
|
+
*/
|
|
1810
|
+
selectedItemIds?: string[];
|
|
1784
1811
|
}
|
|
1785
1812
|
interface SetCheckoutCustomerDto {
|
|
1786
1813
|
email: string;
|
|
@@ -4215,14 +4242,41 @@ declare class OmniSyncClient {
|
|
|
4215
4242
|
* ```
|
|
4216
4243
|
*/
|
|
4217
4244
|
onLogout(): void;
|
|
4245
|
+
/**
|
|
4246
|
+
* Clear cart cache after successful checkout
|
|
4247
|
+
*
|
|
4248
|
+
* Call this after a successful order to ensure the next smartGetCart()
|
|
4249
|
+
* creates a fresh cart instead of returning the converted one.
|
|
4250
|
+
*
|
|
4251
|
+
* @example
|
|
4252
|
+
* ```typescript
|
|
4253
|
+
* // After payment success
|
|
4254
|
+
* if (paymentStatus === 'succeeded') {
|
|
4255
|
+
* omni.onCheckoutComplete();
|
|
4256
|
+
* omni.clearLocalCart(); // Also clear localStorage for guests
|
|
4257
|
+
* }
|
|
4258
|
+
* ```
|
|
4259
|
+
*/
|
|
4260
|
+
onCheckoutComplete(): void;
|
|
4218
4261
|
/**
|
|
4219
4262
|
* Create a checkout from a cart
|
|
4220
4263
|
* Starts the checkout process and returns checkout with available options
|
|
4221
4264
|
*
|
|
4265
|
+
* **Partial Checkout (AliExpress-style):**
|
|
4266
|
+
* Pass `selectedItemIds` to checkout only specific items from the cart.
|
|
4267
|
+
* After payment, only the selected items are removed from the cart -
|
|
4268
|
+
* remaining items stay in the cart for future purchases.
|
|
4269
|
+
*
|
|
4222
4270
|
* @example
|
|
4223
4271
|
* ```typescript
|
|
4272
|
+
* // Full cart checkout (default)
|
|
4224
4273
|
* const checkout = await omni.createCheckout({ cartId: 'cart_123' });
|
|
4225
|
-
*
|
|
4274
|
+
*
|
|
4275
|
+
* // Partial checkout - only buy selected items
|
|
4276
|
+
* const checkout = await omni.createCheckout({
|
|
4277
|
+
* cartId: 'cart_123',
|
|
4278
|
+
* selectedItemIds: ['item_1', 'item_3'], // Only these items will be purchased
|
|
4279
|
+
* });
|
|
4226
4280
|
* ```
|
|
4227
4281
|
*/
|
|
4228
4282
|
createCheckout(data: CreateCheckoutDto): Promise<Checkout>;
|
package/dist/index.js
CHANGED
|
@@ -1981,7 +1981,11 @@ var OmniSyncClient = class {
|
|
|
1981
1981
|
async getOrCreateCustomerCart() {
|
|
1982
1982
|
if (this.customerCartId) {
|
|
1983
1983
|
try {
|
|
1984
|
-
|
|
1984
|
+
const existingCart = await this.getCart(this.customerCartId);
|
|
1985
|
+
if (existingCart.status === "ACTIVE") {
|
|
1986
|
+
return existingCart;
|
|
1987
|
+
}
|
|
1988
|
+
this.customerCartId = null;
|
|
1985
1989
|
} catch {
|
|
1986
1990
|
this.customerCartId = null;
|
|
1987
1991
|
}
|
|
@@ -2144,15 +2148,44 @@ var OmniSyncClient = class {
|
|
|
2144
2148
|
onLogout() {
|
|
2145
2149
|
this.customerCartId = null;
|
|
2146
2150
|
}
|
|
2151
|
+
/**
|
|
2152
|
+
* Clear cart cache after successful checkout
|
|
2153
|
+
*
|
|
2154
|
+
* Call this after a successful order to ensure the next smartGetCart()
|
|
2155
|
+
* creates a fresh cart instead of returning the converted one.
|
|
2156
|
+
*
|
|
2157
|
+
* @example
|
|
2158
|
+
* ```typescript
|
|
2159
|
+
* // After payment success
|
|
2160
|
+
* if (paymentStatus === 'succeeded') {
|
|
2161
|
+
* omni.onCheckoutComplete();
|
|
2162
|
+
* omni.clearLocalCart(); // Also clear localStorage for guests
|
|
2163
|
+
* }
|
|
2164
|
+
* ```
|
|
2165
|
+
*/
|
|
2166
|
+
onCheckoutComplete() {
|
|
2167
|
+
this.customerCartId = null;
|
|
2168
|
+
}
|
|
2147
2169
|
// -------------------- Checkout --------------------
|
|
2148
2170
|
/**
|
|
2149
2171
|
* Create a checkout from a cart
|
|
2150
2172
|
* Starts the checkout process and returns checkout with available options
|
|
2151
2173
|
*
|
|
2174
|
+
* **Partial Checkout (AliExpress-style):**
|
|
2175
|
+
* Pass `selectedItemIds` to checkout only specific items from the cart.
|
|
2176
|
+
* After payment, only the selected items are removed from the cart -
|
|
2177
|
+
* remaining items stay in the cart for future purchases.
|
|
2178
|
+
*
|
|
2152
2179
|
* @example
|
|
2153
2180
|
* ```typescript
|
|
2181
|
+
* // Full cart checkout (default)
|
|
2154
2182
|
* const checkout = await omni.createCheckout({ cartId: 'cart_123' });
|
|
2155
|
-
*
|
|
2183
|
+
*
|
|
2184
|
+
* // Partial checkout - only buy selected items
|
|
2185
|
+
* const checkout = await omni.createCheckout({
|
|
2186
|
+
* cartId: 'cart_123',
|
|
2187
|
+
* selectedItemIds: ['item_1', 'item_3'], // Only these items will be purchased
|
|
2188
|
+
* });
|
|
2156
2189
|
* ```
|
|
2157
2190
|
*/
|
|
2158
2191
|
async createCheckout(data) {
|
package/dist/index.mjs
CHANGED
|
@@ -1944,7 +1944,11 @@ var OmniSyncClient = class {
|
|
|
1944
1944
|
async getOrCreateCustomerCart() {
|
|
1945
1945
|
if (this.customerCartId) {
|
|
1946
1946
|
try {
|
|
1947
|
-
|
|
1947
|
+
const existingCart = await this.getCart(this.customerCartId);
|
|
1948
|
+
if (existingCart.status === "ACTIVE") {
|
|
1949
|
+
return existingCart;
|
|
1950
|
+
}
|
|
1951
|
+
this.customerCartId = null;
|
|
1948
1952
|
} catch {
|
|
1949
1953
|
this.customerCartId = null;
|
|
1950
1954
|
}
|
|
@@ -2107,15 +2111,44 @@ var OmniSyncClient = class {
|
|
|
2107
2111
|
onLogout() {
|
|
2108
2112
|
this.customerCartId = null;
|
|
2109
2113
|
}
|
|
2114
|
+
/**
|
|
2115
|
+
* Clear cart cache after successful checkout
|
|
2116
|
+
*
|
|
2117
|
+
* Call this after a successful order to ensure the next smartGetCart()
|
|
2118
|
+
* creates a fresh cart instead of returning the converted one.
|
|
2119
|
+
*
|
|
2120
|
+
* @example
|
|
2121
|
+
* ```typescript
|
|
2122
|
+
* // After payment success
|
|
2123
|
+
* if (paymentStatus === 'succeeded') {
|
|
2124
|
+
* omni.onCheckoutComplete();
|
|
2125
|
+
* omni.clearLocalCart(); // Also clear localStorage for guests
|
|
2126
|
+
* }
|
|
2127
|
+
* ```
|
|
2128
|
+
*/
|
|
2129
|
+
onCheckoutComplete() {
|
|
2130
|
+
this.customerCartId = null;
|
|
2131
|
+
}
|
|
2110
2132
|
// -------------------- Checkout --------------------
|
|
2111
2133
|
/**
|
|
2112
2134
|
* Create a checkout from a cart
|
|
2113
2135
|
* Starts the checkout process and returns checkout with available options
|
|
2114
2136
|
*
|
|
2137
|
+
* **Partial Checkout (AliExpress-style):**
|
|
2138
|
+
* Pass `selectedItemIds` to checkout only specific items from the cart.
|
|
2139
|
+
* After payment, only the selected items are removed from the cart -
|
|
2140
|
+
* remaining items stay in the cart for future purchases.
|
|
2141
|
+
*
|
|
2115
2142
|
* @example
|
|
2116
2143
|
* ```typescript
|
|
2144
|
+
* // Full cart checkout (default)
|
|
2117
2145
|
* const checkout = await omni.createCheckout({ cartId: 'cart_123' });
|
|
2118
|
-
*
|
|
2146
|
+
*
|
|
2147
|
+
* // Partial checkout - only buy selected items
|
|
2148
|
+
* const checkout = await omni.createCheckout({
|
|
2149
|
+
* cartId: 'cart_123',
|
|
2150
|
+
* selectedItemIds: ['item_1', 'item_3'], // Only these items will be purchased
|
|
2151
|
+
* });
|
|
2119
2152
|
* ```
|
|
2120
2153
|
*/
|
|
2121
2154
|
async createCheckout(data) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omni-sync-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "Official SDK for building e-commerce storefronts with OmniSync Platform. Perfect for vibe-coded sites, AI-built stores (Cursor, Lovable, v0), and custom storefronts.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -16,14 +16,6 @@
|
|
|
16
16
|
"dist",
|
|
17
17
|
"README.md"
|
|
18
18
|
],
|
|
19
|
-
"scripts": {
|
|
20
|
-
"build": "tsup src/index.ts --format cjs,esm --dts",
|
|
21
|
-
"dev": "tsup src/index.ts --format cjs,esm --dts --watch",
|
|
22
|
-
"lint": "eslint \"src/**/*.ts\"",
|
|
23
|
-
"test": "vitest run",
|
|
24
|
-
"test:watch": "vitest",
|
|
25
|
-
"prepublishOnly": "pnpm build"
|
|
26
|
-
},
|
|
27
19
|
"keywords": [
|
|
28
20
|
"omni-sync",
|
|
29
21
|
"e-commerce",
|
|
@@ -72,5 +64,12 @@
|
|
|
72
64
|
"typescript": {
|
|
73
65
|
"optional": true
|
|
74
66
|
}
|
|
67
|
+
},
|
|
68
|
+
"scripts": {
|
|
69
|
+
"build": "tsup src/index.ts --format cjs,esm --dts",
|
|
70
|
+
"dev": "tsup src/index.ts --format cjs,esm --dts --watch",
|
|
71
|
+
"lint": "eslint \"src/**/*.ts\"",
|
|
72
|
+
"test": "vitest run",
|
|
73
|
+
"test:watch": "vitest"
|
|
75
74
|
}
|
|
76
|
-
}
|
|
75
|
+
}
|