omni-sync-sdk 0.19.0 → 0.19.2
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 +45 -12
- package/dist/index.d.ts +45 -12
- package/dist/index.js +42 -5
- package/dist/index.mjs +42 -5
- package/package.json +9 -10
package/LICENSE
ADDED
|
File without changes
|
package/dist/index.d.mts
CHANGED
|
@@ -247,6 +247,14 @@ interface ProductVariant {
|
|
|
247
247
|
salePrice?: string | null;
|
|
248
248
|
/** Variant attributes (e.g., { "Color": "Red", "Size": "M" }) */
|
|
249
249
|
attributes?: Record<string, string> | null;
|
|
250
|
+
/**
|
|
251
|
+
* Variant options as array (alternative to attributes).
|
|
252
|
+
* Use getVariantOptions(variant) helper for consistent access.
|
|
253
|
+
*/
|
|
254
|
+
options?: Array<{
|
|
255
|
+
name: string;
|
|
256
|
+
value: string;
|
|
257
|
+
}>;
|
|
250
258
|
inventory?: InventoryInfo | null;
|
|
251
259
|
/** Variant image URL or image object */
|
|
252
260
|
image?: string | {
|
|
@@ -322,11 +330,12 @@ interface InventoryInfo {
|
|
|
322
330
|
*/
|
|
323
331
|
declare function isHtmlDescription(product: Pick<Product, 'descriptionFormat'> | null | undefined): boolean;
|
|
324
332
|
/**
|
|
325
|
-
* Get the product description ready for rendering
|
|
326
|
-
* Returns an
|
|
333
|
+
* Get the product description ready for rendering.
|
|
334
|
+
* NOTE: Returns an OBJECT, not a string! Use product.description directly if you need the raw string.
|
|
335
|
+
* Returns { html: string } for HTML content, { text: string } for plain text, or null if no description.
|
|
327
336
|
*
|
|
328
337
|
* @param product - The product object
|
|
329
|
-
* @returns Object with either { html: string } or { text: string } or null
|
|
338
|
+
* @returns Object with either { html: string } or { text: string } or null - NOT a plain string!
|
|
330
339
|
*
|
|
331
340
|
* @example
|
|
332
341
|
* ```tsx
|
|
@@ -406,12 +415,13 @@ interface FormatPriceOptions {
|
|
|
406
415
|
asNumber?: boolean;
|
|
407
416
|
}
|
|
408
417
|
/**
|
|
409
|
-
* Parse a price
|
|
418
|
+
* Parse a price value and format it for display.
|
|
410
419
|
*
|
|
411
420
|
* All price fields in Cart, Checkout, and ShippingRate are strings (e.g., "29.99")
|
|
412
421
|
* to preserve decimal precision. This helper simplifies formatting them.
|
|
422
|
+
* Also accepts numbers directly from helper functions like getProductPriceInfo().
|
|
413
423
|
*
|
|
414
|
-
* @param priceString - The price as a string (e.g., "29.99")
|
|
424
|
+
* @param priceString - The price as a string (e.g., "29.99") or number
|
|
415
425
|
* @param options - Formatting options
|
|
416
426
|
* @returns Formatted price string (e.g., "$29.99") or number if asNumber is true
|
|
417
427
|
*
|
|
@@ -428,6 +438,10 @@ interface FormatPriceOptions {
|
|
|
428
438
|
* // Get as number for calculations
|
|
429
439
|
* formatPrice(item.unitPrice, { asNumber: true }); // 29.99
|
|
430
440
|
*
|
|
441
|
+
* // Works with numbers from helper functions
|
|
442
|
+
* const { price } = getProductPriceInfo(product);
|
|
443
|
+
* formatPrice(price, { currency: 'USD' }); // "$29.99"
|
|
444
|
+
*
|
|
431
445
|
* // With locale
|
|
432
446
|
* formatPrice('1234.56', { locale: 'de-DE', currency: 'EUR' }); // "1.234,56 €"
|
|
433
447
|
*
|
|
@@ -436,7 +450,7 @@ interface FormatPriceOptions {
|
|
|
436
450
|
* formatPrice(null); // "$0.00"
|
|
437
451
|
* ```
|
|
438
452
|
*/
|
|
439
|
-
declare function formatPrice(priceString: string | undefined | null, options?: FormatPriceOptions): string | number;
|
|
453
|
+
declare function formatPrice(priceString: string | number | undefined | null, options?: FormatPriceOptions): string | number;
|
|
440
454
|
/**
|
|
441
455
|
* Get the effective price of a product (sale price if on sale, otherwise base price).
|
|
442
456
|
* Returns the price as a NUMBER, not string.
|
|
@@ -615,6 +629,8 @@ interface ProductSuggestion {
|
|
|
615
629
|
name: string;
|
|
616
630
|
slug: string | null;
|
|
617
631
|
image: string | null;
|
|
632
|
+
/** Effective price as string (salePrice if on sale, otherwise basePrice). */
|
|
633
|
+
price: string;
|
|
618
634
|
/** Base price as string. Use parseFloat() for calculations. */
|
|
619
635
|
basePrice: string;
|
|
620
636
|
/** Sale price as string. Use parseFloat() for calculations. */
|
|
@@ -2109,6 +2125,8 @@ interface PaymentProviderConfig {
|
|
|
2109
2125
|
/** Whether this is the default provider */
|
|
2110
2126
|
isDefault: boolean;
|
|
2111
2127
|
}
|
|
2128
|
+
/** Alias for PaymentProviderConfig for convenience */
|
|
2129
|
+
type PaymentProvider = PaymentProviderConfig;
|
|
2112
2130
|
/**
|
|
2113
2131
|
* All available payment providers for a store.
|
|
2114
2132
|
* Use this to build dynamic payment UI based on what's configured.
|
|
@@ -2183,8 +2201,8 @@ interface PaymentIntent {
|
|
|
2183
2201
|
interface PaymentStatus {
|
|
2184
2202
|
/** Checkout ID */
|
|
2185
2203
|
checkoutId: string;
|
|
2186
|
-
/** Payment status: pending, succeeded, failed, canceled */
|
|
2187
|
-
status: 'pending' | 'succeeded' | 'failed' | 'canceled';
|
|
2204
|
+
/** Payment status: pending, processing, succeeded, failed, canceled */
|
|
2205
|
+
status: 'pending' | 'processing' | 'succeeded' | 'failed' | 'canceled';
|
|
2188
2206
|
/** Order ID if payment succeeded and order was created */
|
|
2189
2207
|
orderId?: string;
|
|
2190
2208
|
/** Order number if payment succeeded (e.g., "ORD-20260201-0001") */
|
|
@@ -3765,13 +3783,28 @@ declare class OmniSyncClient {
|
|
|
3765
3783
|
message: string;
|
|
3766
3784
|
}>;
|
|
3767
3785
|
/**
|
|
3768
|
-
* Get available OAuth providers for this store
|
|
3769
|
-
*
|
|
3786
|
+
* Get available OAuth providers for this store.
|
|
3787
|
+
* Returns an array of provider strings (not objects).
|
|
3788
|
+
* Works in vibe-coded and storefront modes.
|
|
3789
|
+
*
|
|
3790
|
+
* @returns Object with `providers` array containing strings like 'GOOGLE', 'FACEBOOK', 'GITHUB'
|
|
3770
3791
|
*
|
|
3771
3792
|
* @example
|
|
3772
3793
|
* ```typescript
|
|
3773
3794
|
* const { providers } = await omni.getAvailableOAuthProviders();
|
|
3774
|
-
* // providers: ['GOOGLE', 'FACEBOOK']
|
|
3795
|
+
* // providers: ['GOOGLE', 'FACEBOOK'] - array of strings, not objects!
|
|
3796
|
+
*
|
|
3797
|
+
* // To display with friendly names:
|
|
3798
|
+
* const providerNames: Record<string, string> = {
|
|
3799
|
+
* GOOGLE: 'Google',
|
|
3800
|
+
* FACEBOOK: 'Facebook',
|
|
3801
|
+
* GITHUB: 'GitHub'
|
|
3802
|
+
* };
|
|
3803
|
+
*
|
|
3804
|
+
* providers.map(p => ({
|
|
3805
|
+
* provider: p,
|
|
3806
|
+
* name: providerNames[p] || p
|
|
3807
|
+
* }));
|
|
3775
3808
|
* ```
|
|
3776
3809
|
*/
|
|
3777
3810
|
getAvailableOAuthProviders(): Promise<OAuthProvidersResponse>;
|
|
@@ -5448,4 +5481,4 @@ declare function isWebhookEventType(event: WebhookEvent, type: WebhookEventType)
|
|
|
5448
5481
|
*/
|
|
5449
5482
|
declare function createWebhookHandler(handlers: Partial<Record<WebhookEventType, (event: WebhookEvent) => Promise<void>>>): (payload: unknown) => Promise<void>;
|
|
5450
5483
|
|
|
5451
|
-
export { type AddToCartDto, type AppliedDiscount, type ApplyCouponDto, type Attribute, type AttributeOption, type AttributeSource, type Brand, type BulkInventoryResponse, type BulkSaveVariantsDto, type BulkSaveVariantsResponse, type BulkVariantInput, type Cart, type CartItem, type CartStatus, type Category, type CategorySuggestion, type Checkout, type CheckoutAddress, type CheckoutLineItem, type CheckoutPrefillData, type CheckoutStatus, type CompleteCheckoutResponse, type CompleteDraftDto, type ConfigureOAuthProviderDto as ConfigureOAuthProviderInput, type ConflictStatus, type ConnectorPlatform, type Coupon, type CouponCreateResponse, type CouponQueryParams, type CouponStatus, type CouponType, type CouponValidationWarning, type CreateAddressDto, type CreateAttributeDto as CreateAttributeInput, type CreateAttributeOptionDto as CreateAttributeOptionInput, type CreateBrandDto as CreateBrandInput, type CreateCategoryDto as CreateCategoryInput, type CreateCheckoutDto, type CreateCouponDto, type CreateCustomApiDto, type CreateCustomerDto, type CreateEmailTemplateDto as CreateEmailTemplateInput, type CreateGuestOrderDto, type CreateMetafieldDefinitionDto as CreateMetafieldDefinitionInput, type CreateOrderDto, type CreateProductDto, type CreateRefundDto, type CreateShippingRateDto as CreateShippingRateInput, type CreateShippingZoneDto as CreateShippingZoneInput, type CreateTagDto as CreateTagInput, type CreateTaxRateDto as CreateTaxRateInput, 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 DeleteProductResponse, type DraftLineItem, type EditInventoryDto, type EmailDomain, type EmailEventSettings, type EmailEventType, type EmailSettings, type EmailTemplate, type EmailTemplatePreview, type EmailVerificationResponse, type ExtendReservationResponse, type FormatPriceOptions, type FulfillOrderDto, type GuestCheckoutStartResponse, type GuestOrderResponse, type InsufficientStockError, type InventoryInfo, type InventoryReservationStrategy, type InventorySyncStatus, type InventoryTrackingMode, type InvitationStatus, type InviteMemberDto as InviteMemberInput, type LocalCart, type LocalCartItem, type MergeCartsDto, type MetafieldConflict, type MetafieldConflictResolution, type MetafieldDefinition, type MetafieldPlatformMapping, type MetafieldType, type OAuthAuthorizeResponse, type OAuthCallbackResponse, type OAuthConnection, type OAuthConnectionsResponse, type OAuthProviderConfig, type OAuthProviderType, type OAuthProvidersResponse, type OmniSyncApiError, OmniSyncClient, type OmniSyncClientOptions, OmniSyncError, type Order, type OrderAddress, type OrderCustomer, type OrderItem, type OrderQueryParams, type OrderStatus, type PaginatedResponse, type PaymentConfig, type PaymentIntent, type PaymentProviderConfig, type PaymentProvidersConfig, type PaymentStatus, type PlatformCouponCapabilities, type PreviewEmailTemplateDto as PreviewEmailTemplateInput, type Product, type ProductAttributeInput, type ProductAvailability, type ProductImage, type ProductMetafield, type ProductMetafieldValue, type ProductQueryParams, type ProductSuggestion, type ProductVariant, type PublishProductResponse, type ReconcileInventoryResponse, type Refund, type RefundLineItem, type RefundLineItemResponse, type RefundType, type RegisterCustomerDto, type ReservationInfo, type ResolveMetafieldConflictDto as ResolveMetafieldConflictInput, type ResolveSyncConflictDto as ResolveSyncConflictInput, type SearchSuggestions, type SelectShippingMethodDto, type SendInvoiceDto, type SetBillingAddressDto, type SetCheckoutCustomerDto, type SetShippingAddressDto, type SetShippingAddressResponse, type ShippingLine, type ShippingRate, type ShippingRateConfig, type ShippingRateType, type ShippingZone, type ShippingZoneQueryParams, type StockAvailabilityRequest, type StockAvailabilityResponse, type StockAvailabilityResult, type StoreInfo, type SyncConflict, type SyncConflictResolution, type SyncJob, type Tag, type TaxBreakdown, type TaxBreakdownItem, type TaxRate, type TaxonomyQueryParams, type TeamInvitation, type TeamInvitationsResponse, type TeamMember, type TeamMembersResponse, type TeamRole, type UpdateAddressDto, type UpdateAttributeDto as UpdateAttributeInput, type UpdateAttributeOptionDto as UpdateAttributeOptionInput, type UpdateBrandDto as UpdateBrandInput, type UpdateCartItemDto, type UpdateCategoryDto as UpdateCategoryInput, type UpdateCouponDto, type UpdateCustomApiDto, type UpdateCustomerDto, type UpdateDraftDto, type UpdateEmailSettingsDto as UpdateEmailSettingsInput, type UpdateEmailTemplateDto as UpdateEmailTemplateInput, type UpdateInventoryDto, type UpdateMemberRoleDto as UpdateMemberRoleInput, type UpdateMetafieldDefinitionDto as UpdateMetafieldDefinitionInput, type UpdateOAuthProviderDto as UpdateOAuthProviderInput, type UpdateOrderDto, type UpdateOrderShippingDto, type UpdateProductDto, type UpdateShippingRateDto as UpdateShippingRateInput, type UpdateShippingZoneDto as UpdateShippingZoneInput, type UpdateTagDto as UpdateTagInput, type UpdateTaxRateDto as UpdateTaxRateInput, type UpdateVariantDto, type UpdateVariantInventoryDto, type UpsertProductMetafieldDto as UpsertProductMetafieldInput, type VariantInventoryResponse, type VariantPlatformOverlay, type VariantStatus, type WaitForOrderOptions, type WaitForOrderResult, type WebhookEvent, type WebhookEventType, createWebhookHandler, formatPrice, getCartItemImage, getCartItemName, getCartTotals, getDescriptionContent, formatPrice as getPriceDisplay, getProductPrice, getProductPriceInfo, getStockStatus, getVariantOptions, getVariantPrice, isCouponApplicableToProduct, isHtmlDescription, isWebhookEventType, parseWebhookEvent, verifyWebhook };
|
|
5484
|
+
export { type AddToCartDto, type AppliedDiscount, type ApplyCouponDto, type Attribute, type AttributeOption, type AttributeSource, type Brand, type BulkInventoryResponse, type BulkSaveVariantsDto, type BulkSaveVariantsResponse, type BulkVariantInput, type Cart, type CartItem, type CartStatus, type Category, type CategorySuggestion, type Checkout, type CheckoutAddress, type CheckoutLineItem, type CheckoutPrefillData, type CheckoutStatus, type CompleteCheckoutResponse, type CompleteDraftDto, type ConfigureOAuthProviderDto as ConfigureOAuthProviderInput, type ConflictStatus, type ConnectorPlatform, type Coupon, type CouponCreateResponse, type CouponQueryParams, type CouponStatus, type CouponType, type CouponValidationWarning, type CreateAddressDto, type CreateAttributeDto as CreateAttributeInput, type CreateAttributeOptionDto as CreateAttributeOptionInput, type CreateBrandDto as CreateBrandInput, type CreateCategoryDto as CreateCategoryInput, type CreateCheckoutDto, type CreateCouponDto, type CreateCustomApiDto, type CreateCustomerDto, type CreateEmailTemplateDto as CreateEmailTemplateInput, type CreateGuestOrderDto, type CreateMetafieldDefinitionDto as CreateMetafieldDefinitionInput, type CreateOrderDto, type CreateProductDto, type CreateRefundDto, type CreateShippingRateDto as CreateShippingRateInput, type CreateShippingZoneDto as CreateShippingZoneInput, type CreateTagDto as CreateTagInput, type CreateTaxRateDto as CreateTaxRateInput, 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 DeleteProductResponse, type DraftLineItem, type EditInventoryDto, type EmailDomain, type EmailEventSettings, type EmailEventType, type EmailSettings, type EmailTemplate, type EmailTemplatePreview, type EmailVerificationResponse, type ExtendReservationResponse, type FormatPriceOptions, type FulfillOrderDto, type GuestCheckoutStartResponse, type GuestOrderResponse, type InsufficientStockError, type InventoryInfo, type InventoryReservationStrategy, type InventorySyncStatus, type InventoryTrackingMode, type InvitationStatus, type InviteMemberDto as InviteMemberInput, type LocalCart, type LocalCartItem, type MergeCartsDto, type MetafieldConflict, type MetafieldConflictResolution, type MetafieldDefinition, type MetafieldPlatformMapping, type MetafieldType, type OAuthAuthorizeResponse, type OAuthCallbackResponse, type OAuthConnection, type OAuthConnectionsResponse, type OAuthProviderConfig, type OAuthProviderType, type OAuthProvidersResponse, type OmniSyncApiError, OmniSyncClient, type OmniSyncClientOptions, OmniSyncError, type Order, type OrderAddress, type OrderCustomer, type OrderItem, type OrderQueryParams, type OrderStatus, type PaginatedResponse, type PaymentConfig, type PaymentIntent, type PaymentProvider, type PaymentProviderConfig, type PaymentProvidersConfig, type PaymentStatus, type PlatformCouponCapabilities, type PreviewEmailTemplateDto as PreviewEmailTemplateInput, type Product, type ProductAttributeInput, type ProductAvailability, type ProductImage, type ProductMetafield, type ProductMetafieldValue, type ProductQueryParams, type ProductSuggestion, type ProductVariant, type PublishProductResponse, type ReconcileInventoryResponse, type Refund, type RefundLineItem, type RefundLineItemResponse, type RefundType, type RegisterCustomerDto, type ReservationInfo, type ResolveMetafieldConflictDto as ResolveMetafieldConflictInput, type ResolveSyncConflictDto as ResolveSyncConflictInput, type SearchSuggestions, type SelectShippingMethodDto, type SendInvoiceDto, type SetBillingAddressDto, type SetCheckoutCustomerDto, type SetShippingAddressDto, type SetShippingAddressResponse, type ShippingLine, type ShippingRate, type ShippingRateConfig, type ShippingRateType, type ShippingZone, type ShippingZoneQueryParams, type StockAvailabilityRequest, type StockAvailabilityResponse, type StockAvailabilityResult, type StoreInfo, type SyncConflict, type SyncConflictResolution, type SyncJob, type Tag, type TaxBreakdown, type TaxBreakdownItem, type TaxRate, type TaxonomyQueryParams, type TeamInvitation, type TeamInvitationsResponse, type TeamMember, type TeamMembersResponse, type TeamRole, type UpdateAddressDto, type UpdateAttributeDto as UpdateAttributeInput, type UpdateAttributeOptionDto as UpdateAttributeOptionInput, type UpdateBrandDto as UpdateBrandInput, type UpdateCartItemDto, type UpdateCategoryDto as UpdateCategoryInput, type UpdateCouponDto, type UpdateCustomApiDto, type UpdateCustomerDto, type UpdateDraftDto, type UpdateEmailSettingsDto as UpdateEmailSettingsInput, type UpdateEmailTemplateDto as UpdateEmailTemplateInput, type UpdateInventoryDto, type UpdateMemberRoleDto as UpdateMemberRoleInput, type UpdateMetafieldDefinitionDto as UpdateMetafieldDefinitionInput, type UpdateOAuthProviderDto as UpdateOAuthProviderInput, type UpdateOrderDto, type UpdateOrderShippingDto, type UpdateProductDto, type UpdateShippingRateDto as UpdateShippingRateInput, type UpdateShippingZoneDto as UpdateShippingZoneInput, type UpdateTagDto as UpdateTagInput, type UpdateTaxRateDto as UpdateTaxRateInput, type UpdateVariantDto, type UpdateVariantInventoryDto, type UpsertProductMetafieldDto as UpsertProductMetafieldInput, type VariantInventoryResponse, type VariantPlatformOverlay, type VariantStatus, type WaitForOrderOptions, type WaitForOrderResult, type WebhookEvent, type WebhookEventType, createWebhookHandler, formatPrice, getCartItemImage, getCartItemName, getCartTotals, getDescriptionContent, formatPrice as getPriceDisplay, getProductPrice, getProductPriceInfo, getStockStatus, getVariantOptions, getVariantPrice, isCouponApplicableToProduct, isHtmlDescription, isWebhookEventType, parseWebhookEvent, verifyWebhook };
|
package/dist/index.d.ts
CHANGED
|
@@ -247,6 +247,14 @@ interface ProductVariant {
|
|
|
247
247
|
salePrice?: string | null;
|
|
248
248
|
/** Variant attributes (e.g., { "Color": "Red", "Size": "M" }) */
|
|
249
249
|
attributes?: Record<string, string> | null;
|
|
250
|
+
/**
|
|
251
|
+
* Variant options as array (alternative to attributes).
|
|
252
|
+
* Use getVariantOptions(variant) helper for consistent access.
|
|
253
|
+
*/
|
|
254
|
+
options?: Array<{
|
|
255
|
+
name: string;
|
|
256
|
+
value: string;
|
|
257
|
+
}>;
|
|
250
258
|
inventory?: InventoryInfo | null;
|
|
251
259
|
/** Variant image URL or image object */
|
|
252
260
|
image?: string | {
|
|
@@ -322,11 +330,12 @@ interface InventoryInfo {
|
|
|
322
330
|
*/
|
|
323
331
|
declare function isHtmlDescription(product: Pick<Product, 'descriptionFormat'> | null | undefined): boolean;
|
|
324
332
|
/**
|
|
325
|
-
* Get the product description ready for rendering
|
|
326
|
-
* Returns an
|
|
333
|
+
* Get the product description ready for rendering.
|
|
334
|
+
* NOTE: Returns an OBJECT, not a string! Use product.description directly if you need the raw string.
|
|
335
|
+
* Returns { html: string } for HTML content, { text: string } for plain text, or null if no description.
|
|
327
336
|
*
|
|
328
337
|
* @param product - The product object
|
|
329
|
-
* @returns Object with either { html: string } or { text: string } or null
|
|
338
|
+
* @returns Object with either { html: string } or { text: string } or null - NOT a plain string!
|
|
330
339
|
*
|
|
331
340
|
* @example
|
|
332
341
|
* ```tsx
|
|
@@ -406,12 +415,13 @@ interface FormatPriceOptions {
|
|
|
406
415
|
asNumber?: boolean;
|
|
407
416
|
}
|
|
408
417
|
/**
|
|
409
|
-
* Parse a price
|
|
418
|
+
* Parse a price value and format it for display.
|
|
410
419
|
*
|
|
411
420
|
* All price fields in Cart, Checkout, and ShippingRate are strings (e.g., "29.99")
|
|
412
421
|
* to preserve decimal precision. This helper simplifies formatting them.
|
|
422
|
+
* Also accepts numbers directly from helper functions like getProductPriceInfo().
|
|
413
423
|
*
|
|
414
|
-
* @param priceString - The price as a string (e.g., "29.99")
|
|
424
|
+
* @param priceString - The price as a string (e.g., "29.99") or number
|
|
415
425
|
* @param options - Formatting options
|
|
416
426
|
* @returns Formatted price string (e.g., "$29.99") or number if asNumber is true
|
|
417
427
|
*
|
|
@@ -428,6 +438,10 @@ interface FormatPriceOptions {
|
|
|
428
438
|
* // Get as number for calculations
|
|
429
439
|
* formatPrice(item.unitPrice, { asNumber: true }); // 29.99
|
|
430
440
|
*
|
|
441
|
+
* // Works with numbers from helper functions
|
|
442
|
+
* const { price } = getProductPriceInfo(product);
|
|
443
|
+
* formatPrice(price, { currency: 'USD' }); // "$29.99"
|
|
444
|
+
*
|
|
431
445
|
* // With locale
|
|
432
446
|
* formatPrice('1234.56', { locale: 'de-DE', currency: 'EUR' }); // "1.234,56 €"
|
|
433
447
|
*
|
|
@@ -436,7 +450,7 @@ interface FormatPriceOptions {
|
|
|
436
450
|
* formatPrice(null); // "$0.00"
|
|
437
451
|
* ```
|
|
438
452
|
*/
|
|
439
|
-
declare function formatPrice(priceString: string | undefined | null, options?: FormatPriceOptions): string | number;
|
|
453
|
+
declare function formatPrice(priceString: string | number | undefined | null, options?: FormatPriceOptions): string | number;
|
|
440
454
|
/**
|
|
441
455
|
* Get the effective price of a product (sale price if on sale, otherwise base price).
|
|
442
456
|
* Returns the price as a NUMBER, not string.
|
|
@@ -615,6 +629,8 @@ interface ProductSuggestion {
|
|
|
615
629
|
name: string;
|
|
616
630
|
slug: string | null;
|
|
617
631
|
image: string | null;
|
|
632
|
+
/** Effective price as string (salePrice if on sale, otherwise basePrice). */
|
|
633
|
+
price: string;
|
|
618
634
|
/** Base price as string. Use parseFloat() for calculations. */
|
|
619
635
|
basePrice: string;
|
|
620
636
|
/** Sale price as string. Use parseFloat() for calculations. */
|
|
@@ -2109,6 +2125,8 @@ interface PaymentProviderConfig {
|
|
|
2109
2125
|
/** Whether this is the default provider */
|
|
2110
2126
|
isDefault: boolean;
|
|
2111
2127
|
}
|
|
2128
|
+
/** Alias for PaymentProviderConfig for convenience */
|
|
2129
|
+
type PaymentProvider = PaymentProviderConfig;
|
|
2112
2130
|
/**
|
|
2113
2131
|
* All available payment providers for a store.
|
|
2114
2132
|
* Use this to build dynamic payment UI based on what's configured.
|
|
@@ -2183,8 +2201,8 @@ interface PaymentIntent {
|
|
|
2183
2201
|
interface PaymentStatus {
|
|
2184
2202
|
/** Checkout ID */
|
|
2185
2203
|
checkoutId: string;
|
|
2186
|
-
/** Payment status: pending, succeeded, failed, canceled */
|
|
2187
|
-
status: 'pending' | 'succeeded' | 'failed' | 'canceled';
|
|
2204
|
+
/** Payment status: pending, processing, succeeded, failed, canceled */
|
|
2205
|
+
status: 'pending' | 'processing' | 'succeeded' | 'failed' | 'canceled';
|
|
2188
2206
|
/** Order ID if payment succeeded and order was created */
|
|
2189
2207
|
orderId?: string;
|
|
2190
2208
|
/** Order number if payment succeeded (e.g., "ORD-20260201-0001") */
|
|
@@ -3765,13 +3783,28 @@ declare class OmniSyncClient {
|
|
|
3765
3783
|
message: string;
|
|
3766
3784
|
}>;
|
|
3767
3785
|
/**
|
|
3768
|
-
* Get available OAuth providers for this store
|
|
3769
|
-
*
|
|
3786
|
+
* Get available OAuth providers for this store.
|
|
3787
|
+
* Returns an array of provider strings (not objects).
|
|
3788
|
+
* Works in vibe-coded and storefront modes.
|
|
3789
|
+
*
|
|
3790
|
+
* @returns Object with `providers` array containing strings like 'GOOGLE', 'FACEBOOK', 'GITHUB'
|
|
3770
3791
|
*
|
|
3771
3792
|
* @example
|
|
3772
3793
|
* ```typescript
|
|
3773
3794
|
* const { providers } = await omni.getAvailableOAuthProviders();
|
|
3774
|
-
* // providers: ['GOOGLE', 'FACEBOOK']
|
|
3795
|
+
* // providers: ['GOOGLE', 'FACEBOOK'] - array of strings, not objects!
|
|
3796
|
+
*
|
|
3797
|
+
* // To display with friendly names:
|
|
3798
|
+
* const providerNames: Record<string, string> = {
|
|
3799
|
+
* GOOGLE: 'Google',
|
|
3800
|
+
* FACEBOOK: 'Facebook',
|
|
3801
|
+
* GITHUB: 'GitHub'
|
|
3802
|
+
* };
|
|
3803
|
+
*
|
|
3804
|
+
* providers.map(p => ({
|
|
3805
|
+
* provider: p,
|
|
3806
|
+
* name: providerNames[p] || p
|
|
3807
|
+
* }));
|
|
3775
3808
|
* ```
|
|
3776
3809
|
*/
|
|
3777
3810
|
getAvailableOAuthProviders(): Promise<OAuthProvidersResponse>;
|
|
@@ -5448,4 +5481,4 @@ declare function isWebhookEventType(event: WebhookEvent, type: WebhookEventType)
|
|
|
5448
5481
|
*/
|
|
5449
5482
|
declare function createWebhookHandler(handlers: Partial<Record<WebhookEventType, (event: WebhookEvent) => Promise<void>>>): (payload: unknown) => Promise<void>;
|
|
5450
5483
|
|
|
5451
|
-
export { type AddToCartDto, type AppliedDiscount, type ApplyCouponDto, type Attribute, type AttributeOption, type AttributeSource, type Brand, type BulkInventoryResponse, type BulkSaveVariantsDto, type BulkSaveVariantsResponse, type BulkVariantInput, type Cart, type CartItem, type CartStatus, type Category, type CategorySuggestion, type Checkout, type CheckoutAddress, type CheckoutLineItem, type CheckoutPrefillData, type CheckoutStatus, type CompleteCheckoutResponse, type CompleteDraftDto, type ConfigureOAuthProviderDto as ConfigureOAuthProviderInput, type ConflictStatus, type ConnectorPlatform, type Coupon, type CouponCreateResponse, type CouponQueryParams, type CouponStatus, type CouponType, type CouponValidationWarning, type CreateAddressDto, type CreateAttributeDto as CreateAttributeInput, type CreateAttributeOptionDto as CreateAttributeOptionInput, type CreateBrandDto as CreateBrandInput, type CreateCategoryDto as CreateCategoryInput, type CreateCheckoutDto, type CreateCouponDto, type CreateCustomApiDto, type CreateCustomerDto, type CreateEmailTemplateDto as CreateEmailTemplateInput, type CreateGuestOrderDto, type CreateMetafieldDefinitionDto as CreateMetafieldDefinitionInput, type CreateOrderDto, type CreateProductDto, type CreateRefundDto, type CreateShippingRateDto as CreateShippingRateInput, type CreateShippingZoneDto as CreateShippingZoneInput, type CreateTagDto as CreateTagInput, type CreateTaxRateDto as CreateTaxRateInput, 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 DeleteProductResponse, type DraftLineItem, type EditInventoryDto, type EmailDomain, type EmailEventSettings, type EmailEventType, type EmailSettings, type EmailTemplate, type EmailTemplatePreview, type EmailVerificationResponse, type ExtendReservationResponse, type FormatPriceOptions, type FulfillOrderDto, type GuestCheckoutStartResponse, type GuestOrderResponse, type InsufficientStockError, type InventoryInfo, type InventoryReservationStrategy, type InventorySyncStatus, type InventoryTrackingMode, type InvitationStatus, type InviteMemberDto as InviteMemberInput, type LocalCart, type LocalCartItem, type MergeCartsDto, type MetafieldConflict, type MetafieldConflictResolution, type MetafieldDefinition, type MetafieldPlatformMapping, type MetafieldType, type OAuthAuthorizeResponse, type OAuthCallbackResponse, type OAuthConnection, type OAuthConnectionsResponse, type OAuthProviderConfig, type OAuthProviderType, type OAuthProvidersResponse, type OmniSyncApiError, OmniSyncClient, type OmniSyncClientOptions, OmniSyncError, type Order, type OrderAddress, type OrderCustomer, type OrderItem, type OrderQueryParams, type OrderStatus, type PaginatedResponse, type PaymentConfig, type PaymentIntent, type PaymentProviderConfig, type PaymentProvidersConfig, type PaymentStatus, type PlatformCouponCapabilities, type PreviewEmailTemplateDto as PreviewEmailTemplateInput, type Product, type ProductAttributeInput, type ProductAvailability, type ProductImage, type ProductMetafield, type ProductMetafieldValue, type ProductQueryParams, type ProductSuggestion, type ProductVariant, type PublishProductResponse, type ReconcileInventoryResponse, type Refund, type RefundLineItem, type RefundLineItemResponse, type RefundType, type RegisterCustomerDto, type ReservationInfo, type ResolveMetafieldConflictDto as ResolveMetafieldConflictInput, type ResolveSyncConflictDto as ResolveSyncConflictInput, type SearchSuggestions, type SelectShippingMethodDto, type SendInvoiceDto, type SetBillingAddressDto, type SetCheckoutCustomerDto, type SetShippingAddressDto, type SetShippingAddressResponse, type ShippingLine, type ShippingRate, type ShippingRateConfig, type ShippingRateType, type ShippingZone, type ShippingZoneQueryParams, type StockAvailabilityRequest, type StockAvailabilityResponse, type StockAvailabilityResult, type StoreInfo, type SyncConflict, type SyncConflictResolution, type SyncJob, type Tag, type TaxBreakdown, type TaxBreakdownItem, type TaxRate, type TaxonomyQueryParams, type TeamInvitation, type TeamInvitationsResponse, type TeamMember, type TeamMembersResponse, type TeamRole, type UpdateAddressDto, type UpdateAttributeDto as UpdateAttributeInput, type UpdateAttributeOptionDto as UpdateAttributeOptionInput, type UpdateBrandDto as UpdateBrandInput, type UpdateCartItemDto, type UpdateCategoryDto as UpdateCategoryInput, type UpdateCouponDto, type UpdateCustomApiDto, type UpdateCustomerDto, type UpdateDraftDto, type UpdateEmailSettingsDto as UpdateEmailSettingsInput, type UpdateEmailTemplateDto as UpdateEmailTemplateInput, type UpdateInventoryDto, type UpdateMemberRoleDto as UpdateMemberRoleInput, type UpdateMetafieldDefinitionDto as UpdateMetafieldDefinitionInput, type UpdateOAuthProviderDto as UpdateOAuthProviderInput, type UpdateOrderDto, type UpdateOrderShippingDto, type UpdateProductDto, type UpdateShippingRateDto as UpdateShippingRateInput, type UpdateShippingZoneDto as UpdateShippingZoneInput, type UpdateTagDto as UpdateTagInput, type UpdateTaxRateDto as UpdateTaxRateInput, type UpdateVariantDto, type UpdateVariantInventoryDto, type UpsertProductMetafieldDto as UpsertProductMetafieldInput, type VariantInventoryResponse, type VariantPlatformOverlay, type VariantStatus, type WaitForOrderOptions, type WaitForOrderResult, type WebhookEvent, type WebhookEventType, createWebhookHandler, formatPrice, getCartItemImage, getCartItemName, getCartTotals, getDescriptionContent, formatPrice as getPriceDisplay, getProductPrice, getProductPriceInfo, getStockStatus, getVariantOptions, getVariantPrice, isCouponApplicableToProduct, isHtmlDescription, isWebhookEventType, parseWebhookEvent, verifyWebhook };
|
|
5484
|
+
export { type AddToCartDto, type AppliedDiscount, type ApplyCouponDto, type Attribute, type AttributeOption, type AttributeSource, type Brand, type BulkInventoryResponse, type BulkSaveVariantsDto, type BulkSaveVariantsResponse, type BulkVariantInput, type Cart, type CartItem, type CartStatus, type Category, type CategorySuggestion, type Checkout, type CheckoutAddress, type CheckoutLineItem, type CheckoutPrefillData, type CheckoutStatus, type CompleteCheckoutResponse, type CompleteDraftDto, type ConfigureOAuthProviderDto as ConfigureOAuthProviderInput, type ConflictStatus, type ConnectorPlatform, type Coupon, type CouponCreateResponse, type CouponQueryParams, type CouponStatus, type CouponType, type CouponValidationWarning, type CreateAddressDto, type CreateAttributeDto as CreateAttributeInput, type CreateAttributeOptionDto as CreateAttributeOptionInput, type CreateBrandDto as CreateBrandInput, type CreateCategoryDto as CreateCategoryInput, type CreateCheckoutDto, type CreateCouponDto, type CreateCustomApiDto, type CreateCustomerDto, type CreateEmailTemplateDto as CreateEmailTemplateInput, type CreateGuestOrderDto, type CreateMetafieldDefinitionDto as CreateMetafieldDefinitionInput, type CreateOrderDto, type CreateProductDto, type CreateRefundDto, type CreateShippingRateDto as CreateShippingRateInput, type CreateShippingZoneDto as CreateShippingZoneInput, type CreateTagDto as CreateTagInput, type CreateTaxRateDto as CreateTaxRateInput, 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 DeleteProductResponse, type DraftLineItem, type EditInventoryDto, type EmailDomain, type EmailEventSettings, type EmailEventType, type EmailSettings, type EmailTemplate, type EmailTemplatePreview, type EmailVerificationResponse, type ExtendReservationResponse, type FormatPriceOptions, type FulfillOrderDto, type GuestCheckoutStartResponse, type GuestOrderResponse, type InsufficientStockError, type InventoryInfo, type InventoryReservationStrategy, type InventorySyncStatus, type InventoryTrackingMode, type InvitationStatus, type InviteMemberDto as InviteMemberInput, type LocalCart, type LocalCartItem, type MergeCartsDto, type MetafieldConflict, type MetafieldConflictResolution, type MetafieldDefinition, type MetafieldPlatformMapping, type MetafieldType, type OAuthAuthorizeResponse, type OAuthCallbackResponse, type OAuthConnection, type OAuthConnectionsResponse, type OAuthProviderConfig, type OAuthProviderType, type OAuthProvidersResponse, type OmniSyncApiError, OmniSyncClient, type OmniSyncClientOptions, OmniSyncError, type Order, type OrderAddress, type OrderCustomer, type OrderItem, type OrderQueryParams, type OrderStatus, type PaginatedResponse, type PaymentConfig, type PaymentIntent, type PaymentProvider, type PaymentProviderConfig, type PaymentProvidersConfig, type PaymentStatus, type PlatformCouponCapabilities, type PreviewEmailTemplateDto as PreviewEmailTemplateInput, type Product, type ProductAttributeInput, type ProductAvailability, type ProductImage, type ProductMetafield, type ProductMetafieldValue, type ProductQueryParams, type ProductSuggestion, type ProductVariant, type PublishProductResponse, type ReconcileInventoryResponse, type Refund, type RefundLineItem, type RefundLineItemResponse, type RefundType, type RegisterCustomerDto, type ReservationInfo, type ResolveMetafieldConflictDto as ResolveMetafieldConflictInput, type ResolveSyncConflictDto as ResolveSyncConflictInput, type SearchSuggestions, type SelectShippingMethodDto, type SendInvoiceDto, type SetBillingAddressDto, type SetCheckoutCustomerDto, type SetShippingAddressDto, type SetShippingAddressResponse, type ShippingLine, type ShippingRate, type ShippingRateConfig, type ShippingRateType, type ShippingZone, type ShippingZoneQueryParams, type StockAvailabilityRequest, type StockAvailabilityResponse, type StockAvailabilityResult, type StoreInfo, type SyncConflict, type SyncConflictResolution, type SyncJob, type Tag, type TaxBreakdown, type TaxBreakdownItem, type TaxRate, type TaxonomyQueryParams, type TeamInvitation, type TeamInvitationsResponse, type TeamMember, type TeamMembersResponse, type TeamRole, type UpdateAddressDto, type UpdateAttributeDto as UpdateAttributeInput, type UpdateAttributeOptionDto as UpdateAttributeOptionInput, type UpdateBrandDto as UpdateBrandInput, type UpdateCartItemDto, type UpdateCategoryDto as UpdateCategoryInput, type UpdateCouponDto, type UpdateCustomApiDto, type UpdateCustomerDto, type UpdateDraftDto, type UpdateEmailSettingsDto as UpdateEmailSettingsInput, type UpdateEmailTemplateDto as UpdateEmailTemplateInput, type UpdateInventoryDto, type UpdateMemberRoleDto as UpdateMemberRoleInput, type UpdateMetafieldDefinitionDto as UpdateMetafieldDefinitionInput, type UpdateOAuthProviderDto as UpdateOAuthProviderInput, type UpdateOrderDto, type UpdateOrderShippingDto, type UpdateProductDto, type UpdateShippingRateDto as UpdateShippingRateInput, type UpdateShippingZoneDto as UpdateShippingZoneInput, type UpdateTagDto as UpdateTagInput, type UpdateTaxRateDto as UpdateTaxRateInput, type UpdateVariantDto, type UpdateVariantInventoryDto, type UpsertProductMetafieldDto as UpsertProductMetafieldInput, type VariantInventoryResponse, type VariantPlatformOverlay, type VariantStatus, type WaitForOrderOptions, type WaitForOrderResult, type WebhookEvent, type WebhookEventType, createWebhookHandler, formatPrice, getCartItemImage, getCartItemName, getCartTotals, getDescriptionContent, formatPrice as getPriceDisplay, getProductPrice, getProductPriceInfo, getStockStatus, getVariantOptions, getVariantPrice, isCouponApplicableToProduct, isHtmlDescription, isWebhookEventType, parseWebhookEvent, verifyWebhook };
|
package/dist/index.js
CHANGED
|
@@ -1379,13 +1379,28 @@ var OmniSyncClient = class {
|
|
|
1379
1379
|
// Customer OAuth (Social Login)
|
|
1380
1380
|
// ===================================================
|
|
1381
1381
|
/**
|
|
1382
|
-
* Get available OAuth providers for this store
|
|
1383
|
-
*
|
|
1382
|
+
* Get available OAuth providers for this store.
|
|
1383
|
+
* Returns an array of provider strings (not objects).
|
|
1384
|
+
* Works in vibe-coded and storefront modes.
|
|
1385
|
+
*
|
|
1386
|
+
* @returns Object with `providers` array containing strings like 'GOOGLE', 'FACEBOOK', 'GITHUB'
|
|
1384
1387
|
*
|
|
1385
1388
|
* @example
|
|
1386
1389
|
* ```typescript
|
|
1387
1390
|
* const { providers } = await omni.getAvailableOAuthProviders();
|
|
1388
|
-
* // providers: ['GOOGLE', 'FACEBOOK']
|
|
1391
|
+
* // providers: ['GOOGLE', 'FACEBOOK'] - array of strings, not objects!
|
|
1392
|
+
*
|
|
1393
|
+
* // To display with friendly names:
|
|
1394
|
+
* const providerNames: Record<string, string> = {
|
|
1395
|
+
* GOOGLE: 'Google',
|
|
1396
|
+
* FACEBOOK: 'Facebook',
|
|
1397
|
+
* GITHUB: 'GitHub'
|
|
1398
|
+
* };
|
|
1399
|
+
*
|
|
1400
|
+
* providers.map(p => ({
|
|
1401
|
+
* provider: p,
|
|
1402
|
+
* name: providerNames[p] || p
|
|
1403
|
+
* }));
|
|
1389
1404
|
* ```
|
|
1390
1405
|
*/
|
|
1391
1406
|
async getAvailableOAuthProviders() {
|
|
@@ -1741,10 +1756,32 @@ var OmniSyncClient = class {
|
|
|
1741
1756
|
*/
|
|
1742
1757
|
async addToCart(cartId, item) {
|
|
1743
1758
|
if (cartId === this.VIRTUAL_LOCAL_CART_ID) {
|
|
1759
|
+
let productName = "Unknown Product";
|
|
1760
|
+
let productPrice = "0";
|
|
1761
|
+
let productImage;
|
|
1762
|
+
try {
|
|
1763
|
+
const product = await this.getProduct(item.productId);
|
|
1764
|
+
productName = product.name;
|
|
1765
|
+
productPrice = product.salePrice || product.basePrice;
|
|
1766
|
+
productImage = product.images?.[0]?.url;
|
|
1767
|
+
if (item.variantId && product.variants) {
|
|
1768
|
+
const variant = product.variants.find((v) => v.id === item.variantId);
|
|
1769
|
+
if (variant) {
|
|
1770
|
+
productPrice = variant.salePrice || variant.price || productPrice;
|
|
1771
|
+
if (variant.image) {
|
|
1772
|
+
productImage = typeof variant.image === "string" ? variant.image : variant.image.url;
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1775
|
+
}
|
|
1776
|
+
} catch {
|
|
1777
|
+
}
|
|
1744
1778
|
this.addToLocalCart({
|
|
1745
1779
|
productId: item.productId,
|
|
1746
1780
|
variantId: item.variantId,
|
|
1747
|
-
quantity: item.quantity
|
|
1781
|
+
quantity: item.quantity,
|
|
1782
|
+
name: productName,
|
|
1783
|
+
price: productPrice,
|
|
1784
|
+
image: productImage
|
|
1748
1785
|
});
|
|
1749
1786
|
return this.localCartToCart(this.getLocalCart());
|
|
1750
1787
|
}
|
|
@@ -4276,7 +4313,7 @@ function getStockStatus(inventory, options) {
|
|
|
4276
4313
|
return options?.inStockText ?? "In Stock";
|
|
4277
4314
|
}
|
|
4278
4315
|
function formatPrice(priceString, options) {
|
|
4279
|
-
const value = parseFloat(priceString || "0");
|
|
4316
|
+
const value = typeof priceString === "number" ? priceString : parseFloat(priceString || "0");
|
|
4280
4317
|
if (options?.asNumber) {
|
|
4281
4318
|
return isNaN(value) ? 0 : value;
|
|
4282
4319
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1342,13 +1342,28 @@ var OmniSyncClient = class {
|
|
|
1342
1342
|
// Customer OAuth (Social Login)
|
|
1343
1343
|
// ===================================================
|
|
1344
1344
|
/**
|
|
1345
|
-
* Get available OAuth providers for this store
|
|
1346
|
-
*
|
|
1345
|
+
* Get available OAuth providers for this store.
|
|
1346
|
+
* Returns an array of provider strings (not objects).
|
|
1347
|
+
* Works in vibe-coded and storefront modes.
|
|
1348
|
+
*
|
|
1349
|
+
* @returns Object with `providers` array containing strings like 'GOOGLE', 'FACEBOOK', 'GITHUB'
|
|
1347
1350
|
*
|
|
1348
1351
|
* @example
|
|
1349
1352
|
* ```typescript
|
|
1350
1353
|
* const { providers } = await omni.getAvailableOAuthProviders();
|
|
1351
|
-
* // providers: ['GOOGLE', 'FACEBOOK']
|
|
1354
|
+
* // providers: ['GOOGLE', 'FACEBOOK'] - array of strings, not objects!
|
|
1355
|
+
*
|
|
1356
|
+
* // To display with friendly names:
|
|
1357
|
+
* const providerNames: Record<string, string> = {
|
|
1358
|
+
* GOOGLE: 'Google',
|
|
1359
|
+
* FACEBOOK: 'Facebook',
|
|
1360
|
+
* GITHUB: 'GitHub'
|
|
1361
|
+
* };
|
|
1362
|
+
*
|
|
1363
|
+
* providers.map(p => ({
|
|
1364
|
+
* provider: p,
|
|
1365
|
+
* name: providerNames[p] || p
|
|
1366
|
+
* }));
|
|
1352
1367
|
* ```
|
|
1353
1368
|
*/
|
|
1354
1369
|
async getAvailableOAuthProviders() {
|
|
@@ -1704,10 +1719,32 @@ var OmniSyncClient = class {
|
|
|
1704
1719
|
*/
|
|
1705
1720
|
async addToCart(cartId, item) {
|
|
1706
1721
|
if (cartId === this.VIRTUAL_LOCAL_CART_ID) {
|
|
1722
|
+
let productName = "Unknown Product";
|
|
1723
|
+
let productPrice = "0";
|
|
1724
|
+
let productImage;
|
|
1725
|
+
try {
|
|
1726
|
+
const product = await this.getProduct(item.productId);
|
|
1727
|
+
productName = product.name;
|
|
1728
|
+
productPrice = product.salePrice || product.basePrice;
|
|
1729
|
+
productImage = product.images?.[0]?.url;
|
|
1730
|
+
if (item.variantId && product.variants) {
|
|
1731
|
+
const variant = product.variants.find((v) => v.id === item.variantId);
|
|
1732
|
+
if (variant) {
|
|
1733
|
+
productPrice = variant.salePrice || variant.price || productPrice;
|
|
1734
|
+
if (variant.image) {
|
|
1735
|
+
productImage = typeof variant.image === "string" ? variant.image : variant.image.url;
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1739
|
+
} catch {
|
|
1740
|
+
}
|
|
1707
1741
|
this.addToLocalCart({
|
|
1708
1742
|
productId: item.productId,
|
|
1709
1743
|
variantId: item.variantId,
|
|
1710
|
-
quantity: item.quantity
|
|
1744
|
+
quantity: item.quantity,
|
|
1745
|
+
name: productName,
|
|
1746
|
+
price: productPrice,
|
|
1747
|
+
image: productImage
|
|
1711
1748
|
});
|
|
1712
1749
|
return this.localCartToCart(this.getLocalCart());
|
|
1713
1750
|
}
|
|
@@ -4239,7 +4276,7 @@ function getStockStatus(inventory, options) {
|
|
|
4239
4276
|
return options?.inStockText ?? "In Stock";
|
|
4240
4277
|
}
|
|
4241
4278
|
function formatPrice(priceString, options) {
|
|
4242
|
-
const value = parseFloat(priceString || "0");
|
|
4279
|
+
const value = typeof priceString === "number" ? priceString : parseFloat(priceString || "0");
|
|
4243
4280
|
if (options?.asNumber) {
|
|
4244
4281
|
return isNaN(value) ? 0 : value;
|
|
4245
4282
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omni-sync-sdk",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.2",
|
|
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
|
+
}
|