omni-sync-sdk 0.8.3 → 0.10.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/dist/index.d.mts +57 -5
- package/dist/index.d.ts +57 -5
- package/dist/index.js +95 -32
- package/dist/index.mjs +95 -32
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1000,6 +1000,37 @@ interface ReconcileInventoryResponse {
|
|
|
1000
1000
|
reconciled?: number;
|
|
1001
1001
|
discrepancies?: number;
|
|
1002
1002
|
}
|
|
1003
|
+
interface StockAvailabilityRequest {
|
|
1004
|
+
productId: string;
|
|
1005
|
+
variantId?: string;
|
|
1006
|
+
quantity: number;
|
|
1007
|
+
}
|
|
1008
|
+
interface StockAvailabilityResult {
|
|
1009
|
+
productId: string;
|
|
1010
|
+
variantId?: string | null;
|
|
1011
|
+
isAvailable: boolean;
|
|
1012
|
+
available: number;
|
|
1013
|
+
requested: number;
|
|
1014
|
+
shortfall: number;
|
|
1015
|
+
}
|
|
1016
|
+
interface StockAvailabilityResponse {
|
|
1017
|
+
allAvailable: boolean;
|
|
1018
|
+
results: StockAvailabilityResult[];
|
|
1019
|
+
}
|
|
1020
|
+
interface InsufficientStockError {
|
|
1021
|
+
code: 'INSUFFICIENT_STOCK';
|
|
1022
|
+
message: string;
|
|
1023
|
+
available: number;
|
|
1024
|
+
requested: number;
|
|
1025
|
+
productId?: string;
|
|
1026
|
+
variantId?: string;
|
|
1027
|
+
items?: Array<{
|
|
1028
|
+
productId: string;
|
|
1029
|
+
variantId?: string;
|
|
1030
|
+
available: number;
|
|
1031
|
+
requested: number;
|
|
1032
|
+
}>;
|
|
1033
|
+
}
|
|
1003
1034
|
interface PublishProductResponse {
|
|
1004
1035
|
productId: string;
|
|
1005
1036
|
results: Record<string, {
|
|
@@ -1568,6 +1599,27 @@ declare class OmniSyncClient {
|
|
|
1568
1599
|
productId?: string;
|
|
1569
1600
|
autoFix?: boolean;
|
|
1570
1601
|
}): Promise<ReconcileInventoryResponse>;
|
|
1602
|
+
/**
|
|
1603
|
+
* Check stock availability for one or more items before adding to cart or checkout
|
|
1604
|
+
* Use this to validate stock before operations that might fail due to insufficient inventory
|
|
1605
|
+
*
|
|
1606
|
+
* @example
|
|
1607
|
+
* ```typescript
|
|
1608
|
+
* // Check if items are available before adding to cart
|
|
1609
|
+
* const result = await omni.checkStockAvailability([
|
|
1610
|
+
* { productId: 'prod_123', quantity: 2 },
|
|
1611
|
+
* { productId: 'prod_456', variantId: 'var_789', quantity: 1 }
|
|
1612
|
+
* ]);
|
|
1613
|
+
*
|
|
1614
|
+
* if (!result.allAvailable) {
|
|
1615
|
+
* const unavailable = result.results.filter(r => !r.isAvailable);
|
|
1616
|
+
* unavailable.forEach(item => {
|
|
1617
|
+
* console.log(`Only ${item.available} available for product ${item.productId}`);
|
|
1618
|
+
* });
|
|
1619
|
+
* }
|
|
1620
|
+
* ```
|
|
1621
|
+
*/
|
|
1622
|
+
checkStockAvailability(items: StockAvailabilityRequest[]): Promise<StockAvailabilityResponse>;
|
|
1571
1623
|
/**
|
|
1572
1624
|
* Trigger a sync to a specific platform or all platforms
|
|
1573
1625
|
*/
|
|
@@ -2379,22 +2431,22 @@ declare class OmniSyncClient {
|
|
|
2379
2431
|
}): Promise<PaginatedResponse<Order>>;
|
|
2380
2432
|
/**
|
|
2381
2433
|
* Get the current customer's addresses (requires customerToken)
|
|
2382
|
-
*
|
|
2434
|
+
* Works in vibe-coded and storefront modes
|
|
2383
2435
|
*/
|
|
2384
2436
|
getMyAddresses(): Promise<CustomerAddress[]>;
|
|
2385
2437
|
/**
|
|
2386
2438
|
* Add an address to the current customer (requires customerToken)
|
|
2387
|
-
*
|
|
2439
|
+
* Works in vibe-coded and storefront modes
|
|
2388
2440
|
*/
|
|
2389
2441
|
addMyAddress(address: CreateAddressDto): Promise<CustomerAddress>;
|
|
2390
2442
|
/**
|
|
2391
2443
|
* Update a customer address (requires customerToken)
|
|
2392
|
-
*
|
|
2444
|
+
* Works in vibe-coded and storefront modes
|
|
2393
2445
|
*/
|
|
2394
2446
|
updateMyAddress(addressId: string, data: UpdateAddressDto): Promise<CustomerAddress>;
|
|
2395
2447
|
/**
|
|
2396
2448
|
* Delete a customer address (requires customerToken)
|
|
2397
|
-
*
|
|
2449
|
+
* Works in vibe-coded and storefront modes
|
|
2398
2450
|
*/
|
|
2399
2451
|
deleteMyAddress(addressId: string): Promise<void>;
|
|
2400
2452
|
/**
|
|
@@ -2556,4 +2608,4 @@ declare function isWebhookEventType(event: WebhookEvent, type: WebhookEventType)
|
|
|
2556
2608
|
*/
|
|
2557
2609
|
declare function createWebhookHandler(handlers: Partial<Record<WebhookEventType, (event: WebhookEvent) => Promise<void>>>): (payload: unknown) => Promise<void>;
|
|
2558
2610
|
|
|
2559
|
-
export { type AddToCartDto, type AppliedDiscount, type ApplyCouponDto, type BulkInventoryResponse, type BulkSaveVariantsDto, type BulkSaveVariantsResponse, type BulkVariantInput, type Cart, type CartItem, type CartStatus, type CategorySuggestion, type Checkout, type CheckoutAddress, type CheckoutLineItem, type CheckoutStatus, type CompleteCheckoutResponse, type CompleteDraftDto, type ConnectorPlatform, type Coupon, type CouponCreateResponse, type CouponQueryParams, type CouponStatus, type CouponType, type CouponValidationWarning, type CreateAddressDto, type CreateCheckoutDto, type CreateCouponDto, type CreateCustomApiDto, type CreateCustomerDto, type CreateGuestOrderDto, type CreateOrderDto, type CreateProductDto, type CreateRefundDto, type CreateVariantDto, type CustomApiAuthType, type CustomApiConnectionStatus, type CustomApiCredentials, type CustomApiIntegration, type CustomApiSyncConfig, type CustomApiSyncDirection, type CustomApiTestResult, type Customer, type CustomerAddress, type CustomerAuthResponse, type CustomerOAuthProvider, type CustomerProfile, type CustomerQueryParams, type DraftLineItem, type EditInventoryDto, type EmailVerificationResponse, type FulfillOrderDto, type GuestCheckoutStartResponse, type GuestOrderResponse, type InventoryInfo, type InventorySyncStatus, type LocalCart, type LocalCartItem, type MergeCartsDto, type OAuthAuthorizeResponse, type OAuthCallbackResponse, type OAuthConnection, type OAuthConnectionsResponse, type OAuthProvidersResponse, type OmniSyncApiError, OmniSyncClient, type OmniSyncClientOptions, OmniSyncError, type Order, type OrderAddress, type OrderCustomer, type OrderItem, type OrderQueryParams, type OrderStatus, type PaginatedResponse, type PlatformCouponCapabilities, type Product, type ProductAttributeInput, type ProductImage, type ProductQueryParams, type ProductSuggestion, type ProductVariant, type PublishProductResponse, type ReconcileInventoryResponse, type Refund, type RefundLineItem, type RefundLineItemResponse, type RefundType, type RegisterCustomerDto, type SearchSuggestions, type SelectShippingMethodDto, type SendInvoiceDto, type SetBillingAddressDto, type SetCheckoutCustomerDto, type SetShippingAddressDto, type SetShippingAddressResponse, type ShippingLine, type ShippingRate, type StoreInfo, type SyncJob, type UpdateAddressDto, type UpdateCartItemDto, type UpdateCouponDto, type UpdateCustomApiDto, type UpdateCustomerDto, type UpdateDraftDto, type UpdateInventoryDto, type UpdateOrderDto, type UpdateOrderShippingDto, type UpdateProductDto, type UpdateVariantDto, type UpdateVariantInventoryDto, type VariantInventoryResponse, type VariantPlatformOverlay, type VariantStatus, type WebhookEvent, type WebhookEventType, createWebhookHandler, isCouponApplicableToProduct, isWebhookEventType, parseWebhookEvent, verifyWebhook };
|
|
2611
|
+
export { type AddToCartDto, type AppliedDiscount, type ApplyCouponDto, type BulkInventoryResponse, type BulkSaveVariantsDto, type BulkSaveVariantsResponse, type BulkVariantInput, type Cart, type CartItem, type CartStatus, type CategorySuggestion, type Checkout, type CheckoutAddress, type CheckoutLineItem, type CheckoutStatus, type CompleteCheckoutResponse, type CompleteDraftDto, type ConnectorPlatform, type Coupon, type CouponCreateResponse, type CouponQueryParams, type CouponStatus, type CouponType, type CouponValidationWarning, type CreateAddressDto, type CreateCheckoutDto, type CreateCouponDto, type CreateCustomApiDto, type CreateCustomerDto, type CreateGuestOrderDto, type CreateOrderDto, type CreateProductDto, type CreateRefundDto, type CreateVariantDto, type CustomApiAuthType, type CustomApiConnectionStatus, type CustomApiCredentials, type CustomApiIntegration, type CustomApiSyncConfig, type CustomApiSyncDirection, type CustomApiTestResult, type Customer, type CustomerAddress, type CustomerAuthResponse, type CustomerOAuthProvider, type CustomerProfile, type CustomerQueryParams, type DraftLineItem, type EditInventoryDto, type EmailVerificationResponse, type FulfillOrderDto, type GuestCheckoutStartResponse, type GuestOrderResponse, type InsufficientStockError, type InventoryInfo, type InventorySyncStatus, type LocalCart, type LocalCartItem, type MergeCartsDto, type OAuthAuthorizeResponse, type OAuthCallbackResponse, type OAuthConnection, type OAuthConnectionsResponse, type OAuthProvidersResponse, type OmniSyncApiError, OmniSyncClient, type OmniSyncClientOptions, OmniSyncError, type Order, type OrderAddress, type OrderCustomer, type OrderItem, type OrderQueryParams, type OrderStatus, type PaginatedResponse, type PlatformCouponCapabilities, type Product, type ProductAttributeInput, type ProductImage, type ProductQueryParams, type ProductSuggestion, type ProductVariant, type PublishProductResponse, type ReconcileInventoryResponse, type Refund, type RefundLineItem, type RefundLineItemResponse, type RefundType, type RegisterCustomerDto, type SearchSuggestions, type SelectShippingMethodDto, type SendInvoiceDto, type SetBillingAddressDto, type SetCheckoutCustomerDto, type SetShippingAddressDto, type SetShippingAddressResponse, type ShippingLine, type ShippingRate, type StockAvailabilityRequest, type StockAvailabilityResponse, type StockAvailabilityResult, type StoreInfo, type SyncJob, type UpdateAddressDto, type UpdateCartItemDto, type UpdateCouponDto, type UpdateCustomApiDto, type UpdateCustomerDto, type UpdateDraftDto, type UpdateInventoryDto, type UpdateOrderDto, type UpdateOrderShippingDto, type UpdateProductDto, type UpdateVariantDto, type UpdateVariantInventoryDto, type VariantInventoryResponse, type VariantPlatformOverlay, type VariantStatus, type WebhookEvent, type WebhookEventType, createWebhookHandler, isCouponApplicableToProduct, isWebhookEventType, parseWebhookEvent, verifyWebhook };
|
package/dist/index.d.ts
CHANGED
|
@@ -1000,6 +1000,37 @@ interface ReconcileInventoryResponse {
|
|
|
1000
1000
|
reconciled?: number;
|
|
1001
1001
|
discrepancies?: number;
|
|
1002
1002
|
}
|
|
1003
|
+
interface StockAvailabilityRequest {
|
|
1004
|
+
productId: string;
|
|
1005
|
+
variantId?: string;
|
|
1006
|
+
quantity: number;
|
|
1007
|
+
}
|
|
1008
|
+
interface StockAvailabilityResult {
|
|
1009
|
+
productId: string;
|
|
1010
|
+
variantId?: string | null;
|
|
1011
|
+
isAvailable: boolean;
|
|
1012
|
+
available: number;
|
|
1013
|
+
requested: number;
|
|
1014
|
+
shortfall: number;
|
|
1015
|
+
}
|
|
1016
|
+
interface StockAvailabilityResponse {
|
|
1017
|
+
allAvailable: boolean;
|
|
1018
|
+
results: StockAvailabilityResult[];
|
|
1019
|
+
}
|
|
1020
|
+
interface InsufficientStockError {
|
|
1021
|
+
code: 'INSUFFICIENT_STOCK';
|
|
1022
|
+
message: string;
|
|
1023
|
+
available: number;
|
|
1024
|
+
requested: number;
|
|
1025
|
+
productId?: string;
|
|
1026
|
+
variantId?: string;
|
|
1027
|
+
items?: Array<{
|
|
1028
|
+
productId: string;
|
|
1029
|
+
variantId?: string;
|
|
1030
|
+
available: number;
|
|
1031
|
+
requested: number;
|
|
1032
|
+
}>;
|
|
1033
|
+
}
|
|
1003
1034
|
interface PublishProductResponse {
|
|
1004
1035
|
productId: string;
|
|
1005
1036
|
results: Record<string, {
|
|
@@ -1568,6 +1599,27 @@ declare class OmniSyncClient {
|
|
|
1568
1599
|
productId?: string;
|
|
1569
1600
|
autoFix?: boolean;
|
|
1570
1601
|
}): Promise<ReconcileInventoryResponse>;
|
|
1602
|
+
/**
|
|
1603
|
+
* Check stock availability for one or more items before adding to cart or checkout
|
|
1604
|
+
* Use this to validate stock before operations that might fail due to insufficient inventory
|
|
1605
|
+
*
|
|
1606
|
+
* @example
|
|
1607
|
+
* ```typescript
|
|
1608
|
+
* // Check if items are available before adding to cart
|
|
1609
|
+
* const result = await omni.checkStockAvailability([
|
|
1610
|
+
* { productId: 'prod_123', quantity: 2 },
|
|
1611
|
+
* { productId: 'prod_456', variantId: 'var_789', quantity: 1 }
|
|
1612
|
+
* ]);
|
|
1613
|
+
*
|
|
1614
|
+
* if (!result.allAvailable) {
|
|
1615
|
+
* const unavailable = result.results.filter(r => !r.isAvailable);
|
|
1616
|
+
* unavailable.forEach(item => {
|
|
1617
|
+
* console.log(`Only ${item.available} available for product ${item.productId}`);
|
|
1618
|
+
* });
|
|
1619
|
+
* }
|
|
1620
|
+
* ```
|
|
1621
|
+
*/
|
|
1622
|
+
checkStockAvailability(items: StockAvailabilityRequest[]): Promise<StockAvailabilityResponse>;
|
|
1571
1623
|
/**
|
|
1572
1624
|
* Trigger a sync to a specific platform or all platforms
|
|
1573
1625
|
*/
|
|
@@ -2379,22 +2431,22 @@ declare class OmniSyncClient {
|
|
|
2379
2431
|
}): Promise<PaginatedResponse<Order>>;
|
|
2380
2432
|
/**
|
|
2381
2433
|
* Get the current customer's addresses (requires customerToken)
|
|
2382
|
-
*
|
|
2434
|
+
* Works in vibe-coded and storefront modes
|
|
2383
2435
|
*/
|
|
2384
2436
|
getMyAddresses(): Promise<CustomerAddress[]>;
|
|
2385
2437
|
/**
|
|
2386
2438
|
* Add an address to the current customer (requires customerToken)
|
|
2387
|
-
*
|
|
2439
|
+
* Works in vibe-coded and storefront modes
|
|
2388
2440
|
*/
|
|
2389
2441
|
addMyAddress(address: CreateAddressDto): Promise<CustomerAddress>;
|
|
2390
2442
|
/**
|
|
2391
2443
|
* Update a customer address (requires customerToken)
|
|
2392
|
-
*
|
|
2444
|
+
* Works in vibe-coded and storefront modes
|
|
2393
2445
|
*/
|
|
2394
2446
|
updateMyAddress(addressId: string, data: UpdateAddressDto): Promise<CustomerAddress>;
|
|
2395
2447
|
/**
|
|
2396
2448
|
* Delete a customer address (requires customerToken)
|
|
2397
|
-
*
|
|
2449
|
+
* Works in vibe-coded and storefront modes
|
|
2398
2450
|
*/
|
|
2399
2451
|
deleteMyAddress(addressId: string): Promise<void>;
|
|
2400
2452
|
/**
|
|
@@ -2556,4 +2608,4 @@ declare function isWebhookEventType(event: WebhookEvent, type: WebhookEventType)
|
|
|
2556
2608
|
*/
|
|
2557
2609
|
declare function createWebhookHandler(handlers: Partial<Record<WebhookEventType, (event: WebhookEvent) => Promise<void>>>): (payload: unknown) => Promise<void>;
|
|
2558
2610
|
|
|
2559
|
-
export { type AddToCartDto, type AppliedDiscount, type ApplyCouponDto, type BulkInventoryResponse, type BulkSaveVariantsDto, type BulkSaveVariantsResponse, type BulkVariantInput, type Cart, type CartItem, type CartStatus, type CategorySuggestion, type Checkout, type CheckoutAddress, type CheckoutLineItem, type CheckoutStatus, type CompleteCheckoutResponse, type CompleteDraftDto, type ConnectorPlatform, type Coupon, type CouponCreateResponse, type CouponQueryParams, type CouponStatus, type CouponType, type CouponValidationWarning, type CreateAddressDto, type CreateCheckoutDto, type CreateCouponDto, type CreateCustomApiDto, type CreateCustomerDto, type CreateGuestOrderDto, type CreateOrderDto, type CreateProductDto, type CreateRefundDto, type CreateVariantDto, type CustomApiAuthType, type CustomApiConnectionStatus, type CustomApiCredentials, type CustomApiIntegration, type CustomApiSyncConfig, type CustomApiSyncDirection, type CustomApiTestResult, type Customer, type CustomerAddress, type CustomerAuthResponse, type CustomerOAuthProvider, type CustomerProfile, type CustomerQueryParams, type DraftLineItem, type EditInventoryDto, type EmailVerificationResponse, type FulfillOrderDto, type GuestCheckoutStartResponse, type GuestOrderResponse, type InventoryInfo, type InventorySyncStatus, type LocalCart, type LocalCartItem, type MergeCartsDto, type OAuthAuthorizeResponse, type OAuthCallbackResponse, type OAuthConnection, type OAuthConnectionsResponse, type OAuthProvidersResponse, type OmniSyncApiError, OmniSyncClient, type OmniSyncClientOptions, OmniSyncError, type Order, type OrderAddress, type OrderCustomer, type OrderItem, type OrderQueryParams, type OrderStatus, type PaginatedResponse, type PlatformCouponCapabilities, type Product, type ProductAttributeInput, type ProductImage, type ProductQueryParams, type ProductSuggestion, type ProductVariant, type PublishProductResponse, type ReconcileInventoryResponse, type Refund, type RefundLineItem, type RefundLineItemResponse, type RefundType, type RegisterCustomerDto, type SearchSuggestions, type SelectShippingMethodDto, type SendInvoiceDto, type SetBillingAddressDto, type SetCheckoutCustomerDto, type SetShippingAddressDto, type SetShippingAddressResponse, type ShippingLine, type ShippingRate, type StoreInfo, type SyncJob, type UpdateAddressDto, type UpdateCartItemDto, type UpdateCouponDto, type UpdateCustomApiDto, type UpdateCustomerDto, type UpdateDraftDto, type UpdateInventoryDto, type UpdateOrderDto, type UpdateOrderShippingDto, type UpdateProductDto, type UpdateVariantDto, type UpdateVariantInventoryDto, type VariantInventoryResponse, type VariantPlatformOverlay, type VariantStatus, type WebhookEvent, type WebhookEventType, createWebhookHandler, isCouponApplicableToProduct, isWebhookEventType, parseWebhookEvent, verifyWebhook };
|
|
2611
|
+
export { type AddToCartDto, type AppliedDiscount, type ApplyCouponDto, type BulkInventoryResponse, type BulkSaveVariantsDto, type BulkSaveVariantsResponse, type BulkVariantInput, type Cart, type CartItem, type CartStatus, type CategorySuggestion, type Checkout, type CheckoutAddress, type CheckoutLineItem, type CheckoutStatus, type CompleteCheckoutResponse, type CompleteDraftDto, type ConnectorPlatform, type Coupon, type CouponCreateResponse, type CouponQueryParams, type CouponStatus, type CouponType, type CouponValidationWarning, type CreateAddressDto, type CreateCheckoutDto, type CreateCouponDto, type CreateCustomApiDto, type CreateCustomerDto, type CreateGuestOrderDto, type CreateOrderDto, type CreateProductDto, type CreateRefundDto, type CreateVariantDto, type CustomApiAuthType, type CustomApiConnectionStatus, type CustomApiCredentials, type CustomApiIntegration, type CustomApiSyncConfig, type CustomApiSyncDirection, type CustomApiTestResult, type Customer, type CustomerAddress, type CustomerAuthResponse, type CustomerOAuthProvider, type CustomerProfile, type CustomerQueryParams, type DraftLineItem, type EditInventoryDto, type EmailVerificationResponse, type FulfillOrderDto, type GuestCheckoutStartResponse, type GuestOrderResponse, type InsufficientStockError, type InventoryInfo, type InventorySyncStatus, type LocalCart, type LocalCartItem, type MergeCartsDto, type OAuthAuthorizeResponse, type OAuthCallbackResponse, type OAuthConnection, type OAuthConnectionsResponse, type OAuthProvidersResponse, type OmniSyncApiError, OmniSyncClient, type OmniSyncClientOptions, OmniSyncError, type Order, type OrderAddress, type OrderCustomer, type OrderItem, type OrderQueryParams, type OrderStatus, type PaginatedResponse, type PlatformCouponCapabilities, type Product, type ProductAttributeInput, type ProductImage, type ProductQueryParams, type ProductSuggestion, type ProductVariant, type PublishProductResponse, type ReconcileInventoryResponse, type Refund, type RefundLineItem, type RefundLineItemResponse, type RefundType, type RegisterCustomerDto, type SearchSuggestions, type SelectShippingMethodDto, type SendInvoiceDto, type SetBillingAddressDto, type SetCheckoutCustomerDto, type SetShippingAddressDto, type SetShippingAddressResponse, type ShippingLine, type ShippingRate, type StockAvailabilityRequest, type StockAvailabilityResponse, type StockAvailabilityResult, type StoreInfo, type SyncJob, type UpdateAddressDto, type UpdateCartItemDto, type UpdateCouponDto, type UpdateCustomApiDto, type UpdateCustomerDto, type UpdateDraftDto, type UpdateInventoryDto, type UpdateOrderDto, type UpdateOrderShippingDto, type UpdateProductDto, type UpdateVariantDto, type UpdateVariantInventoryDto, type VariantInventoryResponse, type VariantPlatformOverlay, type VariantStatus, type WebhookEvent, type WebhookEventType, createWebhookHandler, isCouponApplicableToProduct, isWebhookEventType, parseWebhookEvent, verifyWebhook };
|
package/dist/index.js
CHANGED
|
@@ -880,6 +880,45 @@ var OmniSyncClient = class {
|
|
|
880
880
|
queryParams
|
|
881
881
|
);
|
|
882
882
|
}
|
|
883
|
+
/**
|
|
884
|
+
* Check stock availability for one or more items before adding to cart or checkout
|
|
885
|
+
* Use this to validate stock before operations that might fail due to insufficient inventory
|
|
886
|
+
*
|
|
887
|
+
* @example
|
|
888
|
+
* ```typescript
|
|
889
|
+
* // Check if items are available before adding to cart
|
|
890
|
+
* const result = await omni.checkStockAvailability([
|
|
891
|
+
* { productId: 'prod_123', quantity: 2 },
|
|
892
|
+
* { productId: 'prod_456', variantId: 'var_789', quantity: 1 }
|
|
893
|
+
* ]);
|
|
894
|
+
*
|
|
895
|
+
* if (!result.allAvailable) {
|
|
896
|
+
* const unavailable = result.results.filter(r => !r.isAvailable);
|
|
897
|
+
* unavailable.forEach(item => {
|
|
898
|
+
* console.log(`Only ${item.available} available for product ${item.productId}`);
|
|
899
|
+
* });
|
|
900
|
+
* }
|
|
901
|
+
* ```
|
|
902
|
+
*/
|
|
903
|
+
async checkStockAvailability(items) {
|
|
904
|
+
if (this.isVibeCodedMode()) {
|
|
905
|
+
return this.vibeCodedRequest(
|
|
906
|
+
"POST",
|
|
907
|
+
"/inventory/check-availability",
|
|
908
|
+
{ items }
|
|
909
|
+
);
|
|
910
|
+
}
|
|
911
|
+
if (this.storeId && !this.apiKey) {
|
|
912
|
+
return this.storefrontRequest(
|
|
913
|
+
"POST",
|
|
914
|
+
"/inventory/check-availability",
|
|
915
|
+
{ items }
|
|
916
|
+
);
|
|
917
|
+
}
|
|
918
|
+
return this.request("POST", "/api/v1/inventory/check-availability", {
|
|
919
|
+
items
|
|
920
|
+
});
|
|
921
|
+
}
|
|
883
922
|
// -------------------- Sync --------------------
|
|
884
923
|
/**
|
|
885
924
|
* Trigger a sync to a specific platform or all platforms
|
|
@@ -2301,26 +2340,32 @@ var OmniSyncClient = class {
|
|
|
2301
2340
|
* ```
|
|
2302
2341
|
*/
|
|
2303
2342
|
async getMyProfile() {
|
|
2304
|
-
if (!this.storeId) {
|
|
2305
|
-
throw new OmniSyncError("getMyProfile is only available in storefront mode", 400);
|
|
2306
|
-
}
|
|
2307
2343
|
if (!this.customerToken) {
|
|
2308
2344
|
throw new OmniSyncError("Customer token required. Call setCustomerToken() after login.", 401);
|
|
2309
2345
|
}
|
|
2310
|
-
|
|
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);
|
|
2311
2353
|
}
|
|
2312
2354
|
/**
|
|
2313
2355
|
* Update the current customer's profile (requires customerToken)
|
|
2314
2356
|
* Only available in storefront mode
|
|
2315
2357
|
*/
|
|
2316
2358
|
async updateMyProfile(data) {
|
|
2317
|
-
if (!this.storeId) {
|
|
2318
|
-
throw new OmniSyncError("updateMyProfile is only available in storefront mode", 400);
|
|
2319
|
-
}
|
|
2320
2359
|
if (!this.customerToken) {
|
|
2321
2360
|
throw new OmniSyncError("Customer token required. Call setCustomerToken() after login.", 401);
|
|
2322
2361
|
}
|
|
2323
|
-
|
|
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("updateMyProfile is only available in vibe-coded or storefront mode", 400);
|
|
2324
2369
|
}
|
|
2325
2370
|
/**
|
|
2326
2371
|
* Get the current customer's orders (requires customerToken)
|
|
@@ -2354,59 +2399,77 @@ var OmniSyncClient = class {
|
|
|
2354
2399
|
}
|
|
2355
2400
|
/**
|
|
2356
2401
|
* Get the current customer's addresses (requires customerToken)
|
|
2357
|
-
*
|
|
2402
|
+
* Works in vibe-coded and storefront modes
|
|
2358
2403
|
*/
|
|
2359
2404
|
async getMyAddresses() {
|
|
2360
|
-
if (!this.storeId) {
|
|
2361
|
-
throw new OmniSyncError("getMyAddresses is only available in storefront mode", 400);
|
|
2362
|
-
}
|
|
2363
2405
|
if (!this.customerToken) {
|
|
2364
2406
|
throw new OmniSyncError("Customer token required. Call setCustomerToken() after login.", 401);
|
|
2365
2407
|
}
|
|
2366
|
-
|
|
2408
|
+
if (this.isVibeCodedMode()) {
|
|
2409
|
+
return this.vibeCodedRequest("GET", "/customers/me/addresses");
|
|
2410
|
+
}
|
|
2411
|
+
if (this.storeId && !this.apiKey) {
|
|
2412
|
+
return this.storefrontRequest("GET", "/customers/me/addresses");
|
|
2413
|
+
}
|
|
2414
|
+
throw new OmniSyncError("getMyAddresses is only available in vibe-coded or storefront mode", 400);
|
|
2367
2415
|
}
|
|
2368
2416
|
/**
|
|
2369
2417
|
* Add an address to the current customer (requires customerToken)
|
|
2370
|
-
*
|
|
2418
|
+
* Works in vibe-coded and storefront modes
|
|
2371
2419
|
*/
|
|
2372
2420
|
async addMyAddress(address) {
|
|
2373
|
-
if (!this.storeId) {
|
|
2374
|
-
throw new OmniSyncError("addMyAddress is only available in storefront mode", 400);
|
|
2375
|
-
}
|
|
2376
2421
|
if (!this.customerToken) {
|
|
2377
2422
|
throw new OmniSyncError("Customer token required. Call setCustomerToken() after login.", 401);
|
|
2378
2423
|
}
|
|
2379
|
-
|
|
2424
|
+
if (this.isVibeCodedMode()) {
|
|
2425
|
+
return this.vibeCodedRequest("POST", "/customers/me/addresses", address);
|
|
2426
|
+
}
|
|
2427
|
+
if (this.storeId && !this.apiKey) {
|
|
2428
|
+
return this.storefrontRequest("POST", "/customers/me/addresses", address);
|
|
2429
|
+
}
|
|
2430
|
+
throw new OmniSyncError("addMyAddress is only available in vibe-coded or storefront mode", 400);
|
|
2380
2431
|
}
|
|
2381
2432
|
/**
|
|
2382
2433
|
* Update a customer address (requires customerToken)
|
|
2383
|
-
*
|
|
2434
|
+
* Works in vibe-coded and storefront modes
|
|
2384
2435
|
*/
|
|
2385
2436
|
async updateMyAddress(addressId, data) {
|
|
2386
|
-
if (!this.storeId) {
|
|
2387
|
-
throw new OmniSyncError("updateMyAddress is only available in storefront mode", 400);
|
|
2388
|
-
}
|
|
2389
2437
|
if (!this.customerToken) {
|
|
2390
2438
|
throw new OmniSyncError("Customer token required. Call setCustomerToken() after login.", 401);
|
|
2391
2439
|
}
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2440
|
+
if (this.isVibeCodedMode()) {
|
|
2441
|
+
return this.vibeCodedRequest(
|
|
2442
|
+
"PATCH",
|
|
2443
|
+
`/customers/me/addresses/${addressId}`,
|
|
2444
|
+
data
|
|
2445
|
+
);
|
|
2446
|
+
}
|
|
2447
|
+
if (this.storeId && !this.apiKey) {
|
|
2448
|
+
return this.storefrontRequest(
|
|
2449
|
+
"PATCH",
|
|
2450
|
+
`/customers/me/addresses/${addressId}`,
|
|
2451
|
+
data
|
|
2452
|
+
);
|
|
2453
|
+
}
|
|
2454
|
+
throw new OmniSyncError("updateMyAddress is only available in vibe-coded or storefront mode", 400);
|
|
2397
2455
|
}
|
|
2398
2456
|
/**
|
|
2399
2457
|
* Delete a customer address (requires customerToken)
|
|
2400
|
-
*
|
|
2458
|
+
* Works in vibe-coded and storefront modes
|
|
2401
2459
|
*/
|
|
2402
2460
|
async deleteMyAddress(addressId) {
|
|
2403
|
-
if (!this.storeId) {
|
|
2404
|
-
throw new OmniSyncError("deleteMyAddress is only available in storefront mode", 400);
|
|
2405
|
-
}
|
|
2406
2461
|
if (!this.customerToken) {
|
|
2407
2462
|
throw new OmniSyncError("Customer token required. Call setCustomerToken() after login.", 401);
|
|
2408
2463
|
}
|
|
2409
|
-
|
|
2464
|
+
if (this.isVibeCodedMode()) {
|
|
2465
|
+
await this.vibeCodedRequest("DELETE", `/customers/me/addresses/${addressId}`);
|
|
2466
|
+
return;
|
|
2467
|
+
}
|
|
2468
|
+
if (this.storeId && !this.apiKey) {
|
|
2469
|
+
await this.storefrontRequest("DELETE", `/customers/me/addresses/${addressId}`);
|
|
2470
|
+
return;
|
|
2471
|
+
}
|
|
2472
|
+
throw new OmniSyncError("deleteMyAddress is only available in vibe-coded or storefront mode", 400);
|
|
2410
2473
|
}
|
|
2411
2474
|
/**
|
|
2412
2475
|
* Get the current customer's cart (requires customerToken)
|
package/dist/index.mjs
CHANGED
|
@@ -855,6 +855,45 @@ var OmniSyncClient = class {
|
|
|
855
855
|
queryParams
|
|
856
856
|
);
|
|
857
857
|
}
|
|
858
|
+
/**
|
|
859
|
+
* Check stock availability for one or more items before adding to cart or checkout
|
|
860
|
+
* Use this to validate stock before operations that might fail due to insufficient inventory
|
|
861
|
+
*
|
|
862
|
+
* @example
|
|
863
|
+
* ```typescript
|
|
864
|
+
* // Check if items are available before adding to cart
|
|
865
|
+
* const result = await omni.checkStockAvailability([
|
|
866
|
+
* { productId: 'prod_123', quantity: 2 },
|
|
867
|
+
* { productId: 'prod_456', variantId: 'var_789', quantity: 1 }
|
|
868
|
+
* ]);
|
|
869
|
+
*
|
|
870
|
+
* if (!result.allAvailable) {
|
|
871
|
+
* const unavailable = result.results.filter(r => !r.isAvailable);
|
|
872
|
+
* unavailable.forEach(item => {
|
|
873
|
+
* console.log(`Only ${item.available} available for product ${item.productId}`);
|
|
874
|
+
* });
|
|
875
|
+
* }
|
|
876
|
+
* ```
|
|
877
|
+
*/
|
|
878
|
+
async checkStockAvailability(items) {
|
|
879
|
+
if (this.isVibeCodedMode()) {
|
|
880
|
+
return this.vibeCodedRequest(
|
|
881
|
+
"POST",
|
|
882
|
+
"/inventory/check-availability",
|
|
883
|
+
{ items }
|
|
884
|
+
);
|
|
885
|
+
}
|
|
886
|
+
if (this.storeId && !this.apiKey) {
|
|
887
|
+
return this.storefrontRequest(
|
|
888
|
+
"POST",
|
|
889
|
+
"/inventory/check-availability",
|
|
890
|
+
{ items }
|
|
891
|
+
);
|
|
892
|
+
}
|
|
893
|
+
return this.request("POST", "/api/v1/inventory/check-availability", {
|
|
894
|
+
items
|
|
895
|
+
});
|
|
896
|
+
}
|
|
858
897
|
// -------------------- Sync --------------------
|
|
859
898
|
/**
|
|
860
899
|
* Trigger a sync to a specific platform or all platforms
|
|
@@ -2276,26 +2315,32 @@ var OmniSyncClient = class {
|
|
|
2276
2315
|
* ```
|
|
2277
2316
|
*/
|
|
2278
2317
|
async getMyProfile() {
|
|
2279
|
-
if (!this.storeId) {
|
|
2280
|
-
throw new OmniSyncError("getMyProfile is only available in storefront mode", 400);
|
|
2281
|
-
}
|
|
2282
2318
|
if (!this.customerToken) {
|
|
2283
2319
|
throw new OmniSyncError("Customer token required. Call setCustomerToken() after login.", 401);
|
|
2284
2320
|
}
|
|
2285
|
-
|
|
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);
|
|
2286
2328
|
}
|
|
2287
2329
|
/**
|
|
2288
2330
|
* Update the current customer's profile (requires customerToken)
|
|
2289
2331
|
* Only available in storefront mode
|
|
2290
2332
|
*/
|
|
2291
2333
|
async updateMyProfile(data) {
|
|
2292
|
-
if (!this.storeId) {
|
|
2293
|
-
throw new OmniSyncError("updateMyProfile is only available in storefront mode", 400);
|
|
2294
|
-
}
|
|
2295
2334
|
if (!this.customerToken) {
|
|
2296
2335
|
throw new OmniSyncError("Customer token required. Call setCustomerToken() after login.", 401);
|
|
2297
2336
|
}
|
|
2298
|
-
|
|
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("updateMyProfile is only available in vibe-coded or storefront mode", 400);
|
|
2299
2344
|
}
|
|
2300
2345
|
/**
|
|
2301
2346
|
* Get the current customer's orders (requires customerToken)
|
|
@@ -2329,59 +2374,77 @@ var OmniSyncClient = class {
|
|
|
2329
2374
|
}
|
|
2330
2375
|
/**
|
|
2331
2376
|
* Get the current customer's addresses (requires customerToken)
|
|
2332
|
-
*
|
|
2377
|
+
* Works in vibe-coded and storefront modes
|
|
2333
2378
|
*/
|
|
2334
2379
|
async getMyAddresses() {
|
|
2335
|
-
if (!this.storeId) {
|
|
2336
|
-
throw new OmniSyncError("getMyAddresses is only available in storefront mode", 400);
|
|
2337
|
-
}
|
|
2338
2380
|
if (!this.customerToken) {
|
|
2339
2381
|
throw new OmniSyncError("Customer token required. Call setCustomerToken() after login.", 401);
|
|
2340
2382
|
}
|
|
2341
|
-
|
|
2383
|
+
if (this.isVibeCodedMode()) {
|
|
2384
|
+
return this.vibeCodedRequest("GET", "/customers/me/addresses");
|
|
2385
|
+
}
|
|
2386
|
+
if (this.storeId && !this.apiKey) {
|
|
2387
|
+
return this.storefrontRequest("GET", "/customers/me/addresses");
|
|
2388
|
+
}
|
|
2389
|
+
throw new OmniSyncError("getMyAddresses is only available in vibe-coded or storefront mode", 400);
|
|
2342
2390
|
}
|
|
2343
2391
|
/**
|
|
2344
2392
|
* Add an address to the current customer (requires customerToken)
|
|
2345
|
-
*
|
|
2393
|
+
* Works in vibe-coded and storefront modes
|
|
2346
2394
|
*/
|
|
2347
2395
|
async addMyAddress(address) {
|
|
2348
|
-
if (!this.storeId) {
|
|
2349
|
-
throw new OmniSyncError("addMyAddress is only available in storefront mode", 400);
|
|
2350
|
-
}
|
|
2351
2396
|
if (!this.customerToken) {
|
|
2352
2397
|
throw new OmniSyncError("Customer token required. Call setCustomerToken() after login.", 401);
|
|
2353
2398
|
}
|
|
2354
|
-
|
|
2399
|
+
if (this.isVibeCodedMode()) {
|
|
2400
|
+
return this.vibeCodedRequest("POST", "/customers/me/addresses", address);
|
|
2401
|
+
}
|
|
2402
|
+
if (this.storeId && !this.apiKey) {
|
|
2403
|
+
return this.storefrontRequest("POST", "/customers/me/addresses", address);
|
|
2404
|
+
}
|
|
2405
|
+
throw new OmniSyncError("addMyAddress is only available in vibe-coded or storefront mode", 400);
|
|
2355
2406
|
}
|
|
2356
2407
|
/**
|
|
2357
2408
|
* Update a customer address (requires customerToken)
|
|
2358
|
-
*
|
|
2409
|
+
* Works in vibe-coded and storefront modes
|
|
2359
2410
|
*/
|
|
2360
2411
|
async updateMyAddress(addressId, data) {
|
|
2361
|
-
if (!this.storeId) {
|
|
2362
|
-
throw new OmniSyncError("updateMyAddress is only available in storefront mode", 400);
|
|
2363
|
-
}
|
|
2364
2412
|
if (!this.customerToken) {
|
|
2365
2413
|
throw new OmniSyncError("Customer token required. Call setCustomerToken() after login.", 401);
|
|
2366
2414
|
}
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2415
|
+
if (this.isVibeCodedMode()) {
|
|
2416
|
+
return this.vibeCodedRequest(
|
|
2417
|
+
"PATCH",
|
|
2418
|
+
`/customers/me/addresses/${addressId}`,
|
|
2419
|
+
data
|
|
2420
|
+
);
|
|
2421
|
+
}
|
|
2422
|
+
if (this.storeId && !this.apiKey) {
|
|
2423
|
+
return this.storefrontRequest(
|
|
2424
|
+
"PATCH",
|
|
2425
|
+
`/customers/me/addresses/${addressId}`,
|
|
2426
|
+
data
|
|
2427
|
+
);
|
|
2428
|
+
}
|
|
2429
|
+
throw new OmniSyncError("updateMyAddress is only available in vibe-coded or storefront mode", 400);
|
|
2372
2430
|
}
|
|
2373
2431
|
/**
|
|
2374
2432
|
* Delete a customer address (requires customerToken)
|
|
2375
|
-
*
|
|
2433
|
+
* Works in vibe-coded and storefront modes
|
|
2376
2434
|
*/
|
|
2377
2435
|
async deleteMyAddress(addressId) {
|
|
2378
|
-
if (!this.storeId) {
|
|
2379
|
-
throw new OmniSyncError("deleteMyAddress is only available in storefront mode", 400);
|
|
2380
|
-
}
|
|
2381
2436
|
if (!this.customerToken) {
|
|
2382
2437
|
throw new OmniSyncError("Customer token required. Call setCustomerToken() after login.", 401);
|
|
2383
2438
|
}
|
|
2384
|
-
|
|
2439
|
+
if (this.isVibeCodedMode()) {
|
|
2440
|
+
await this.vibeCodedRequest("DELETE", `/customers/me/addresses/${addressId}`);
|
|
2441
|
+
return;
|
|
2442
|
+
}
|
|
2443
|
+
if (this.storeId && !this.apiKey) {
|
|
2444
|
+
await this.storefrontRequest("DELETE", `/customers/me/addresses/${addressId}`);
|
|
2445
|
+
return;
|
|
2446
|
+
}
|
|
2447
|
+
throw new OmniSyncError("deleteMyAddress is only available in vibe-coded or storefront mode", 400);
|
|
2385
2448
|
}
|
|
2386
2449
|
/**
|
|
2387
2450
|
* 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.10.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",
|