omni-sync-sdk 0.9.0 → 0.11.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/README.md +6 -6
- package/dist/index.d.mts +10 -12
- package/dist/index.d.ts +10 -12
- package/dist/index.js +71 -37
- package/dist/index.mjs +71 -37
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -280,9 +280,9 @@ const response: PaginatedResponse<Product> = await omni.getProducts({
|
|
|
280
280
|
sortOrder: 'desc', // Optional: 'asc' | 'desc'
|
|
281
281
|
});
|
|
282
282
|
|
|
283
|
-
console.log(response.
|
|
284
|
-
console.log(response.
|
|
285
|
-
console.log(response.
|
|
283
|
+
console.log(response.items); // Product[]
|
|
284
|
+
console.log(response.total); // Total number of products
|
|
285
|
+
console.log(response.totalPages); // Total pages
|
|
286
286
|
```
|
|
287
287
|
|
|
288
288
|
#### Get Single Product
|
|
@@ -1710,8 +1710,8 @@ export default function ProductsPage() {
|
|
|
1710
1710
|
<button onClick={() => setPage(p => Math.max(1, p - 1))} disabled={page === 1}>
|
|
1711
1711
|
Previous
|
|
1712
1712
|
</button>
|
|
1713
|
-
<span>Page {data.
|
|
1714
|
-
<button onClick={() => setPage(p => p + 1)} disabled={page >= data.
|
|
1713
|
+
<span>Page {data.page} of {data.totalPages}</span>
|
|
1714
|
+
<button onClick={() => setPage(p => p + 1)} disabled={page >= data.totalPages}>
|
|
1715
1715
|
Next
|
|
1716
1716
|
</button>
|
|
1717
1717
|
</div>
|
|
@@ -2606,7 +2606,7 @@ export default function AccountPage() {
|
|
|
2606
2606
|
omni.getMyOrders({ limit: 10 }),
|
|
2607
2607
|
]);
|
|
2608
2608
|
setProfile(p);
|
|
2609
|
-
setOrders(o.
|
|
2609
|
+
setOrders(o.items);
|
|
2610
2610
|
} finally {
|
|
2611
2611
|
setLoading(false);
|
|
2612
2612
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -149,13 +149,11 @@ interface SearchSuggestions {
|
|
|
149
149
|
categories: CategorySuggestion[];
|
|
150
150
|
}
|
|
151
151
|
interface PaginatedResponse<T> {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
totalPages: number;
|
|
158
|
-
};
|
|
152
|
+
items: T[];
|
|
153
|
+
page: number;
|
|
154
|
+
limit: number;
|
|
155
|
+
total: number;
|
|
156
|
+
totalPages: number;
|
|
159
157
|
}
|
|
160
158
|
interface CreateProductDto {
|
|
161
159
|
name: string;
|
|
@@ -1967,7 +1965,7 @@ declare class OmniSyncClient {
|
|
|
1967
1965
|
* @example
|
|
1968
1966
|
* ```typescript
|
|
1969
1967
|
* const orders = await omni.getCustomerOrders('cust_123', { page: 1, limit: 10 });
|
|
1970
|
-
* console.log(`Customer has ${orders.
|
|
1968
|
+
* console.log(`Customer has ${orders.total} total orders`);
|
|
1971
1969
|
* ```
|
|
1972
1970
|
*/
|
|
1973
1971
|
getCustomerOrders(customerId: string, params?: {
|
|
@@ -2431,22 +2429,22 @@ declare class OmniSyncClient {
|
|
|
2431
2429
|
}): Promise<PaginatedResponse<Order>>;
|
|
2432
2430
|
/**
|
|
2433
2431
|
* Get the current customer's addresses (requires customerToken)
|
|
2434
|
-
*
|
|
2432
|
+
* Works in vibe-coded and storefront modes
|
|
2435
2433
|
*/
|
|
2436
2434
|
getMyAddresses(): Promise<CustomerAddress[]>;
|
|
2437
2435
|
/**
|
|
2438
2436
|
* Add an address to the current customer (requires customerToken)
|
|
2439
|
-
*
|
|
2437
|
+
* Works in vibe-coded and storefront modes
|
|
2440
2438
|
*/
|
|
2441
2439
|
addMyAddress(address: CreateAddressDto): Promise<CustomerAddress>;
|
|
2442
2440
|
/**
|
|
2443
2441
|
* Update a customer address (requires customerToken)
|
|
2444
|
-
*
|
|
2442
|
+
* Works in vibe-coded and storefront modes
|
|
2445
2443
|
*/
|
|
2446
2444
|
updateMyAddress(addressId: string, data: UpdateAddressDto): Promise<CustomerAddress>;
|
|
2447
2445
|
/**
|
|
2448
2446
|
* Delete a customer address (requires customerToken)
|
|
2449
|
-
*
|
|
2447
|
+
* Works in vibe-coded and storefront modes
|
|
2450
2448
|
*/
|
|
2451
2449
|
deleteMyAddress(addressId: string): Promise<void>;
|
|
2452
2450
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -149,13 +149,11 @@ interface SearchSuggestions {
|
|
|
149
149
|
categories: CategorySuggestion[];
|
|
150
150
|
}
|
|
151
151
|
interface PaginatedResponse<T> {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
totalPages: number;
|
|
158
|
-
};
|
|
152
|
+
items: T[];
|
|
153
|
+
page: number;
|
|
154
|
+
limit: number;
|
|
155
|
+
total: number;
|
|
156
|
+
totalPages: number;
|
|
159
157
|
}
|
|
160
158
|
interface CreateProductDto {
|
|
161
159
|
name: string;
|
|
@@ -1967,7 +1965,7 @@ declare class OmniSyncClient {
|
|
|
1967
1965
|
* @example
|
|
1968
1966
|
* ```typescript
|
|
1969
1967
|
* const orders = await omni.getCustomerOrders('cust_123', { page: 1, limit: 10 });
|
|
1970
|
-
* console.log(`Customer has ${orders.
|
|
1968
|
+
* console.log(`Customer has ${orders.total} total orders`);
|
|
1971
1969
|
* ```
|
|
1972
1970
|
*/
|
|
1973
1971
|
getCustomerOrders(customerId: string, params?: {
|
|
@@ -2431,22 +2429,22 @@ declare class OmniSyncClient {
|
|
|
2431
2429
|
}): Promise<PaginatedResponse<Order>>;
|
|
2432
2430
|
/**
|
|
2433
2431
|
* Get the current customer's addresses (requires customerToken)
|
|
2434
|
-
*
|
|
2432
|
+
* Works in vibe-coded and storefront modes
|
|
2435
2433
|
*/
|
|
2436
2434
|
getMyAddresses(): Promise<CustomerAddress[]>;
|
|
2437
2435
|
/**
|
|
2438
2436
|
* Add an address to the current customer (requires customerToken)
|
|
2439
|
-
*
|
|
2437
|
+
* Works in vibe-coded and storefront modes
|
|
2440
2438
|
*/
|
|
2441
2439
|
addMyAddress(address: CreateAddressDto): Promise<CustomerAddress>;
|
|
2442
2440
|
/**
|
|
2443
2441
|
* Update a customer address (requires customerToken)
|
|
2444
|
-
*
|
|
2442
|
+
* Works in vibe-coded and storefront modes
|
|
2445
2443
|
*/
|
|
2446
2444
|
updateMyAddress(addressId: string, data: UpdateAddressDto): Promise<CustomerAddress>;
|
|
2447
2445
|
/**
|
|
2448
2446
|
* Delete a customer address (requires customerToken)
|
|
2449
|
-
*
|
|
2447
|
+
* Works in vibe-coded and storefront modes
|
|
2450
2448
|
*/
|
|
2451
2449
|
deleteMyAddress(addressId: string): Promise<void>;
|
|
2452
2450
|
/**
|
package/dist/index.js
CHANGED
|
@@ -915,11 +915,9 @@ var OmniSyncClient = class {
|
|
|
915
915
|
{ items }
|
|
916
916
|
);
|
|
917
917
|
}
|
|
918
|
-
return this.request(
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
{ items }
|
|
922
|
-
);
|
|
918
|
+
return this.request("POST", "/api/v1/inventory/check-availability", {
|
|
919
|
+
items
|
|
920
|
+
});
|
|
923
921
|
}
|
|
924
922
|
// -------------------- Sync --------------------
|
|
925
923
|
/**
|
|
@@ -1499,7 +1497,7 @@ var OmniSyncClient = class {
|
|
|
1499
1497
|
* @example
|
|
1500
1498
|
* ```typescript
|
|
1501
1499
|
* const orders = await omni.getCustomerOrders('cust_123', { page: 1, limit: 10 });
|
|
1502
|
-
* console.log(`Customer has ${orders.
|
|
1500
|
+
* console.log(`Customer has ${orders.total} total orders`);
|
|
1503
1501
|
* ```
|
|
1504
1502
|
*/
|
|
1505
1503
|
async getCustomerOrders(customerId, params) {
|
|
@@ -2342,26 +2340,35 @@ var OmniSyncClient = class {
|
|
|
2342
2340
|
* ```
|
|
2343
2341
|
*/
|
|
2344
2342
|
async getMyProfile() {
|
|
2345
|
-
if (!this.storeId) {
|
|
2346
|
-
throw new OmniSyncError("getMyProfile is only available in storefront mode", 400);
|
|
2347
|
-
}
|
|
2348
2343
|
if (!this.customerToken) {
|
|
2349
2344
|
throw new OmniSyncError("Customer token required. Call setCustomerToken() after login.", 401);
|
|
2350
2345
|
}
|
|
2351
|
-
|
|
2346
|
+
if (this.isVibeCodedMode()) {
|
|
2347
|
+
return this.vibeCodedRequest("GET", "/customers/me");
|
|
2348
|
+
}
|
|
2349
|
+
if (this.storeId && !this.apiKey) {
|
|
2350
|
+
return this.storefrontRequest("GET", "/customers/me");
|
|
2351
|
+
}
|
|
2352
|
+
throw new OmniSyncError("getMyProfile is only available in vibe-coded or storefront mode", 400);
|
|
2352
2353
|
}
|
|
2353
2354
|
/**
|
|
2354
2355
|
* Update the current customer's profile (requires customerToken)
|
|
2355
2356
|
* Only available in storefront mode
|
|
2356
2357
|
*/
|
|
2357
2358
|
async updateMyProfile(data) {
|
|
2358
|
-
if (!this.storeId) {
|
|
2359
|
-
throw new OmniSyncError("updateMyProfile is only available in storefront mode", 400);
|
|
2360
|
-
}
|
|
2361
2359
|
if (!this.customerToken) {
|
|
2362
2360
|
throw new OmniSyncError("Customer token required. Call setCustomerToken() after login.", 401);
|
|
2363
2361
|
}
|
|
2364
|
-
|
|
2362
|
+
if (this.isVibeCodedMode()) {
|
|
2363
|
+
return this.vibeCodedRequest("PATCH", "/customers/me", data);
|
|
2364
|
+
}
|
|
2365
|
+
if (this.storeId && !this.apiKey) {
|
|
2366
|
+
return this.storefrontRequest("PATCH", "/customers/me", data);
|
|
2367
|
+
}
|
|
2368
|
+
throw new OmniSyncError(
|
|
2369
|
+
"updateMyProfile is only available in vibe-coded or storefront mode",
|
|
2370
|
+
400
|
|
2371
|
+
);
|
|
2365
2372
|
}
|
|
2366
2373
|
/**
|
|
2367
2374
|
* Get the current customer's orders (requires customerToken)
|
|
@@ -2395,59 +2402,86 @@ var OmniSyncClient = class {
|
|
|
2395
2402
|
}
|
|
2396
2403
|
/**
|
|
2397
2404
|
* Get the current customer's addresses (requires customerToken)
|
|
2398
|
-
*
|
|
2405
|
+
* Works in vibe-coded and storefront modes
|
|
2399
2406
|
*/
|
|
2400
2407
|
async getMyAddresses() {
|
|
2401
|
-
if (!this.storeId) {
|
|
2402
|
-
throw new OmniSyncError("getMyAddresses is only available in storefront mode", 400);
|
|
2403
|
-
}
|
|
2404
2408
|
if (!this.customerToken) {
|
|
2405
2409
|
throw new OmniSyncError("Customer token required. Call setCustomerToken() after login.", 401);
|
|
2406
2410
|
}
|
|
2407
|
-
|
|
2411
|
+
if (this.isVibeCodedMode()) {
|
|
2412
|
+
return this.vibeCodedRequest("GET", "/customers/me/addresses");
|
|
2413
|
+
}
|
|
2414
|
+
if (this.storeId && !this.apiKey) {
|
|
2415
|
+
return this.storefrontRequest("GET", "/customers/me/addresses");
|
|
2416
|
+
}
|
|
2417
|
+
throw new OmniSyncError(
|
|
2418
|
+
"getMyAddresses is only available in vibe-coded or storefront mode",
|
|
2419
|
+
400
|
|
2420
|
+
);
|
|
2408
2421
|
}
|
|
2409
2422
|
/**
|
|
2410
2423
|
* Add an address to the current customer (requires customerToken)
|
|
2411
|
-
*
|
|
2424
|
+
* Works in vibe-coded and storefront modes
|
|
2412
2425
|
*/
|
|
2413
2426
|
async addMyAddress(address) {
|
|
2414
|
-
if (!this.storeId) {
|
|
2415
|
-
throw new OmniSyncError("addMyAddress is only available in storefront mode", 400);
|
|
2416
|
-
}
|
|
2417
2427
|
if (!this.customerToken) {
|
|
2418
2428
|
throw new OmniSyncError("Customer token required. Call setCustomerToken() after login.", 401);
|
|
2419
2429
|
}
|
|
2420
|
-
|
|
2430
|
+
if (this.isVibeCodedMode()) {
|
|
2431
|
+
return this.vibeCodedRequest("POST", "/customers/me/addresses", address);
|
|
2432
|
+
}
|
|
2433
|
+
if (this.storeId && !this.apiKey) {
|
|
2434
|
+
return this.storefrontRequest("POST", "/customers/me/addresses", address);
|
|
2435
|
+
}
|
|
2436
|
+
throw new OmniSyncError("addMyAddress is only available in vibe-coded or storefront mode", 400);
|
|
2421
2437
|
}
|
|
2422
2438
|
/**
|
|
2423
2439
|
* Update a customer address (requires customerToken)
|
|
2424
|
-
*
|
|
2440
|
+
* Works in vibe-coded and storefront modes
|
|
2425
2441
|
*/
|
|
2426
2442
|
async updateMyAddress(addressId, data) {
|
|
2427
|
-
if (!this.storeId) {
|
|
2428
|
-
throw new OmniSyncError("updateMyAddress is only available in storefront mode", 400);
|
|
2429
|
-
}
|
|
2430
2443
|
if (!this.customerToken) {
|
|
2431
2444
|
throw new OmniSyncError("Customer token required. Call setCustomerToken() after login.", 401);
|
|
2432
2445
|
}
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2446
|
+
if (this.isVibeCodedMode()) {
|
|
2447
|
+
return this.vibeCodedRequest(
|
|
2448
|
+
"PATCH",
|
|
2449
|
+
`/customers/me/addresses/${addressId}`,
|
|
2450
|
+
data
|
|
2451
|
+
);
|
|
2452
|
+
}
|
|
2453
|
+
if (this.storeId && !this.apiKey) {
|
|
2454
|
+
return this.storefrontRequest(
|
|
2455
|
+
"PATCH",
|
|
2456
|
+
`/customers/me/addresses/${addressId}`,
|
|
2457
|
+
data
|
|
2458
|
+
);
|
|
2459
|
+
}
|
|
2460
|
+
throw new OmniSyncError(
|
|
2461
|
+
"updateMyAddress is only available in vibe-coded or storefront mode",
|
|
2462
|
+
400
|
|
2437
2463
|
);
|
|
2438
2464
|
}
|
|
2439
2465
|
/**
|
|
2440
2466
|
* Delete a customer address (requires customerToken)
|
|
2441
|
-
*
|
|
2467
|
+
* Works in vibe-coded and storefront modes
|
|
2442
2468
|
*/
|
|
2443
2469
|
async deleteMyAddress(addressId) {
|
|
2444
|
-
if (!this.storeId) {
|
|
2445
|
-
throw new OmniSyncError("deleteMyAddress is only available in storefront mode", 400);
|
|
2446
|
-
}
|
|
2447
2470
|
if (!this.customerToken) {
|
|
2448
2471
|
throw new OmniSyncError("Customer token required. Call setCustomerToken() after login.", 401);
|
|
2449
2472
|
}
|
|
2450
|
-
|
|
2473
|
+
if (this.isVibeCodedMode()) {
|
|
2474
|
+
await this.vibeCodedRequest("DELETE", `/customers/me/addresses/${addressId}`);
|
|
2475
|
+
return;
|
|
2476
|
+
}
|
|
2477
|
+
if (this.storeId && !this.apiKey) {
|
|
2478
|
+
await this.storefrontRequest("DELETE", `/customers/me/addresses/${addressId}`);
|
|
2479
|
+
return;
|
|
2480
|
+
}
|
|
2481
|
+
throw new OmniSyncError(
|
|
2482
|
+
"deleteMyAddress is only available in vibe-coded or storefront mode",
|
|
2483
|
+
400
|
|
2484
|
+
);
|
|
2451
2485
|
}
|
|
2452
2486
|
/**
|
|
2453
2487
|
* Get the current customer's cart (requires customerToken)
|
package/dist/index.mjs
CHANGED
|
@@ -890,11 +890,9 @@ var OmniSyncClient = class {
|
|
|
890
890
|
{ items }
|
|
891
891
|
);
|
|
892
892
|
}
|
|
893
|
-
return this.request(
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
{ items }
|
|
897
|
-
);
|
|
893
|
+
return this.request("POST", "/api/v1/inventory/check-availability", {
|
|
894
|
+
items
|
|
895
|
+
});
|
|
898
896
|
}
|
|
899
897
|
// -------------------- Sync --------------------
|
|
900
898
|
/**
|
|
@@ -1474,7 +1472,7 @@ var OmniSyncClient = class {
|
|
|
1474
1472
|
* @example
|
|
1475
1473
|
* ```typescript
|
|
1476
1474
|
* const orders = await omni.getCustomerOrders('cust_123', { page: 1, limit: 10 });
|
|
1477
|
-
* console.log(`Customer has ${orders.
|
|
1475
|
+
* console.log(`Customer has ${orders.total} total orders`);
|
|
1478
1476
|
* ```
|
|
1479
1477
|
*/
|
|
1480
1478
|
async getCustomerOrders(customerId, params) {
|
|
@@ -2317,26 +2315,35 @@ var OmniSyncClient = class {
|
|
|
2317
2315
|
* ```
|
|
2318
2316
|
*/
|
|
2319
2317
|
async getMyProfile() {
|
|
2320
|
-
if (!this.storeId) {
|
|
2321
|
-
throw new OmniSyncError("getMyProfile is only available in storefront mode", 400);
|
|
2322
|
-
}
|
|
2323
2318
|
if (!this.customerToken) {
|
|
2324
2319
|
throw new OmniSyncError("Customer token required. Call setCustomerToken() after login.", 401);
|
|
2325
2320
|
}
|
|
2326
|
-
|
|
2321
|
+
if (this.isVibeCodedMode()) {
|
|
2322
|
+
return this.vibeCodedRequest("GET", "/customers/me");
|
|
2323
|
+
}
|
|
2324
|
+
if (this.storeId && !this.apiKey) {
|
|
2325
|
+
return this.storefrontRequest("GET", "/customers/me");
|
|
2326
|
+
}
|
|
2327
|
+
throw new OmniSyncError("getMyProfile is only available in vibe-coded or storefront mode", 400);
|
|
2327
2328
|
}
|
|
2328
2329
|
/**
|
|
2329
2330
|
* Update the current customer's profile (requires customerToken)
|
|
2330
2331
|
* Only available in storefront mode
|
|
2331
2332
|
*/
|
|
2332
2333
|
async updateMyProfile(data) {
|
|
2333
|
-
if (!this.storeId) {
|
|
2334
|
-
throw new OmniSyncError("updateMyProfile is only available in storefront mode", 400);
|
|
2335
|
-
}
|
|
2336
2334
|
if (!this.customerToken) {
|
|
2337
2335
|
throw new OmniSyncError("Customer token required. Call setCustomerToken() after login.", 401);
|
|
2338
2336
|
}
|
|
2339
|
-
|
|
2337
|
+
if (this.isVibeCodedMode()) {
|
|
2338
|
+
return this.vibeCodedRequest("PATCH", "/customers/me", data);
|
|
2339
|
+
}
|
|
2340
|
+
if (this.storeId && !this.apiKey) {
|
|
2341
|
+
return this.storefrontRequest("PATCH", "/customers/me", data);
|
|
2342
|
+
}
|
|
2343
|
+
throw new OmniSyncError(
|
|
2344
|
+
"updateMyProfile is only available in vibe-coded or storefront mode",
|
|
2345
|
+
400
|
|
2346
|
+
);
|
|
2340
2347
|
}
|
|
2341
2348
|
/**
|
|
2342
2349
|
* Get the current customer's orders (requires customerToken)
|
|
@@ -2370,59 +2377,86 @@ var OmniSyncClient = class {
|
|
|
2370
2377
|
}
|
|
2371
2378
|
/**
|
|
2372
2379
|
* Get the current customer's addresses (requires customerToken)
|
|
2373
|
-
*
|
|
2380
|
+
* Works in vibe-coded and storefront modes
|
|
2374
2381
|
*/
|
|
2375
2382
|
async getMyAddresses() {
|
|
2376
|
-
if (!this.storeId) {
|
|
2377
|
-
throw new OmniSyncError("getMyAddresses is only available in storefront mode", 400);
|
|
2378
|
-
}
|
|
2379
2383
|
if (!this.customerToken) {
|
|
2380
2384
|
throw new OmniSyncError("Customer token required. Call setCustomerToken() after login.", 401);
|
|
2381
2385
|
}
|
|
2382
|
-
|
|
2386
|
+
if (this.isVibeCodedMode()) {
|
|
2387
|
+
return this.vibeCodedRequest("GET", "/customers/me/addresses");
|
|
2388
|
+
}
|
|
2389
|
+
if (this.storeId && !this.apiKey) {
|
|
2390
|
+
return this.storefrontRequest("GET", "/customers/me/addresses");
|
|
2391
|
+
}
|
|
2392
|
+
throw new OmniSyncError(
|
|
2393
|
+
"getMyAddresses is only available in vibe-coded or storefront mode",
|
|
2394
|
+
400
|
|
2395
|
+
);
|
|
2383
2396
|
}
|
|
2384
2397
|
/**
|
|
2385
2398
|
* Add an address to the current customer (requires customerToken)
|
|
2386
|
-
*
|
|
2399
|
+
* Works in vibe-coded and storefront modes
|
|
2387
2400
|
*/
|
|
2388
2401
|
async addMyAddress(address) {
|
|
2389
|
-
if (!this.storeId) {
|
|
2390
|
-
throw new OmniSyncError("addMyAddress is only available in storefront mode", 400);
|
|
2391
|
-
}
|
|
2392
2402
|
if (!this.customerToken) {
|
|
2393
2403
|
throw new OmniSyncError("Customer token required. Call setCustomerToken() after login.", 401);
|
|
2394
2404
|
}
|
|
2395
|
-
|
|
2405
|
+
if (this.isVibeCodedMode()) {
|
|
2406
|
+
return this.vibeCodedRequest("POST", "/customers/me/addresses", address);
|
|
2407
|
+
}
|
|
2408
|
+
if (this.storeId && !this.apiKey) {
|
|
2409
|
+
return this.storefrontRequest("POST", "/customers/me/addresses", address);
|
|
2410
|
+
}
|
|
2411
|
+
throw new OmniSyncError("addMyAddress is only available in vibe-coded or storefront mode", 400);
|
|
2396
2412
|
}
|
|
2397
2413
|
/**
|
|
2398
2414
|
* Update a customer address (requires customerToken)
|
|
2399
|
-
*
|
|
2415
|
+
* Works in vibe-coded and storefront modes
|
|
2400
2416
|
*/
|
|
2401
2417
|
async updateMyAddress(addressId, data) {
|
|
2402
|
-
if (!this.storeId) {
|
|
2403
|
-
throw new OmniSyncError("updateMyAddress is only available in storefront mode", 400);
|
|
2404
|
-
}
|
|
2405
2418
|
if (!this.customerToken) {
|
|
2406
2419
|
throw new OmniSyncError("Customer token required. Call setCustomerToken() after login.", 401);
|
|
2407
2420
|
}
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2421
|
+
if (this.isVibeCodedMode()) {
|
|
2422
|
+
return this.vibeCodedRequest(
|
|
2423
|
+
"PATCH",
|
|
2424
|
+
`/customers/me/addresses/${addressId}`,
|
|
2425
|
+
data
|
|
2426
|
+
);
|
|
2427
|
+
}
|
|
2428
|
+
if (this.storeId && !this.apiKey) {
|
|
2429
|
+
return this.storefrontRequest(
|
|
2430
|
+
"PATCH",
|
|
2431
|
+
`/customers/me/addresses/${addressId}`,
|
|
2432
|
+
data
|
|
2433
|
+
);
|
|
2434
|
+
}
|
|
2435
|
+
throw new OmniSyncError(
|
|
2436
|
+
"updateMyAddress is only available in vibe-coded or storefront mode",
|
|
2437
|
+
400
|
|
2412
2438
|
);
|
|
2413
2439
|
}
|
|
2414
2440
|
/**
|
|
2415
2441
|
* Delete a customer address (requires customerToken)
|
|
2416
|
-
*
|
|
2442
|
+
* Works in vibe-coded and storefront modes
|
|
2417
2443
|
*/
|
|
2418
2444
|
async deleteMyAddress(addressId) {
|
|
2419
|
-
if (!this.storeId) {
|
|
2420
|
-
throw new OmniSyncError("deleteMyAddress is only available in storefront mode", 400);
|
|
2421
|
-
}
|
|
2422
2445
|
if (!this.customerToken) {
|
|
2423
2446
|
throw new OmniSyncError("Customer token required. Call setCustomerToken() after login.", 401);
|
|
2424
2447
|
}
|
|
2425
|
-
|
|
2448
|
+
if (this.isVibeCodedMode()) {
|
|
2449
|
+
await this.vibeCodedRequest("DELETE", `/customers/me/addresses/${addressId}`);
|
|
2450
|
+
return;
|
|
2451
|
+
}
|
|
2452
|
+
if (this.storeId && !this.apiKey) {
|
|
2453
|
+
await this.storefrontRequest("DELETE", `/customers/me/addresses/${addressId}`);
|
|
2454
|
+
return;
|
|
2455
|
+
}
|
|
2456
|
+
throw new OmniSyncError(
|
|
2457
|
+
"deleteMyAddress is only available in vibe-coded or storefront mode",
|
|
2458
|
+
400
|
|
2459
|
+
);
|
|
2426
2460
|
}
|
|
2427
2461
|
/**
|
|
2428
2462
|
* Get the current customer's cart (requires customerToken)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omni-sync-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.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",
|