omni-sync-sdk 0.1.1 → 0.3.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 +184 -191
- package/dist/index.d.mts +716 -27
- package/dist/index.d.ts +716 -27
- package/dist/index.js +893 -39
- package/dist/index.mjs +893 -39
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,41 @@
|
|
|
1
1
|
interface OmniSyncClientOptions {
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Connection ID for vibe-coded sites (starts with "vc_").
|
|
4
|
+
* This is the simplest way to connect - just use your Connection ID!
|
|
5
|
+
* Safe to use in frontend applications.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* // Vibe-coded site usage - simplest option!
|
|
10
|
+
* const omni = new OmniSyncClient({
|
|
11
|
+
* connectionId: 'vc_abc123xyz...',
|
|
12
|
+
* });
|
|
13
|
+
* const products = await omni.getProducts();
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
connectionId?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Store ID for public storefront access (no API key needed).
|
|
19
|
+
* Use this for frontend/browser applications.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* // Frontend usage - safe to expose
|
|
24
|
+
* const omni = new OmniSyncClient({ storeId: 'store_abc123' });
|
|
25
|
+
* ```
|
|
4
26
|
*/
|
|
5
|
-
|
|
27
|
+
storeId?: string;
|
|
28
|
+
/**
|
|
29
|
+
* API Key for admin/backend access (starts with "omni_").
|
|
30
|
+
* Keep this secret - never expose in frontend code!
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* // Backend usage - keep secret
|
|
35
|
+
* const omni = new OmniSyncClient({ apiKey: process.env.OMNI_API_KEY });
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
apiKey?: string;
|
|
6
39
|
/**
|
|
7
40
|
* Base URL of the Omni-Sync API
|
|
8
41
|
* @default "https://api.omni-sync.com"
|
|
@@ -14,6 +47,24 @@ interface OmniSyncClientOptions {
|
|
|
14
47
|
*/
|
|
15
48
|
timeout?: number;
|
|
16
49
|
}
|
|
50
|
+
interface StoreInfo {
|
|
51
|
+
id: string;
|
|
52
|
+
name: string;
|
|
53
|
+
currency: string;
|
|
54
|
+
language: string;
|
|
55
|
+
}
|
|
56
|
+
interface CustomerProfile {
|
|
57
|
+
id: string;
|
|
58
|
+
email: string;
|
|
59
|
+
firstName?: string;
|
|
60
|
+
lastName?: string;
|
|
61
|
+
phone?: string;
|
|
62
|
+
emailVerified: boolean;
|
|
63
|
+
acceptsMarketing: boolean;
|
|
64
|
+
addresses: CustomerAddress[];
|
|
65
|
+
createdAt: string;
|
|
66
|
+
updatedAt: string;
|
|
67
|
+
}
|
|
17
68
|
interface Product {
|
|
18
69
|
id: string;
|
|
19
70
|
name: string;
|
|
@@ -373,6 +424,14 @@ interface UpdateCustomerDto {
|
|
|
373
424
|
tags?: string[];
|
|
374
425
|
metadata?: Record<string, unknown>;
|
|
375
426
|
}
|
|
427
|
+
interface CustomerQueryParams {
|
|
428
|
+
page?: number;
|
|
429
|
+
limit?: number;
|
|
430
|
+
search?: string;
|
|
431
|
+
hasAccount?: boolean;
|
|
432
|
+
sortBy?: 'createdAt' | 'email' | 'firstName' | 'lastName' | 'lastOrderAt';
|
|
433
|
+
sortOrder?: 'asc' | 'desc';
|
|
434
|
+
}
|
|
376
435
|
interface CreateAddressDto {
|
|
377
436
|
label?: string;
|
|
378
437
|
firstName: string;
|
|
@@ -471,6 +530,9 @@ interface AddToCartDto {
|
|
|
471
530
|
interface UpdateCartItemDto {
|
|
472
531
|
quantity: number;
|
|
473
532
|
}
|
|
533
|
+
interface ApplyCouponDto {
|
|
534
|
+
code: string;
|
|
535
|
+
}
|
|
474
536
|
interface MergeCartsDto {
|
|
475
537
|
sourceSessionToken: string;
|
|
476
538
|
targetCustomerId: string;
|
|
@@ -564,6 +626,9 @@ interface SetShippingAddressDto {
|
|
|
564
626
|
interface SetBillingAddressDto extends SetShippingAddressDto {
|
|
565
627
|
sameAsShipping?: boolean;
|
|
566
628
|
}
|
|
629
|
+
interface SelectShippingMethodDto {
|
|
630
|
+
shippingRateId: string;
|
|
631
|
+
}
|
|
567
632
|
interface SetShippingAddressResponse {
|
|
568
633
|
checkout: Checkout;
|
|
569
634
|
rates: ShippingRate[];
|
|
@@ -580,6 +645,184 @@ interface WebhookEvent {
|
|
|
580
645
|
timestamp: string;
|
|
581
646
|
}
|
|
582
647
|
type WebhookEventType = 'product.created' | 'product.updated' | 'product.deleted' | 'inventory.updated' | 'order.created' | 'order.updated' | 'coupon.created' | 'coupon.updated' | 'coupon.deleted' | 'cart.created' | 'cart.updated' | 'cart.abandoned' | 'checkout.started' | 'checkout.completed' | 'checkout.failed';
|
|
648
|
+
type VariantStatus = 'active' | 'draft';
|
|
649
|
+
interface CreateVariantDto {
|
|
650
|
+
sku?: string;
|
|
651
|
+
name?: string;
|
|
652
|
+
attributes?: Record<string, unknown>;
|
|
653
|
+
price?: number;
|
|
654
|
+
salePrice?: number;
|
|
655
|
+
inventory?: number;
|
|
656
|
+
image?: unknown;
|
|
657
|
+
position?: number;
|
|
658
|
+
status?: VariantStatus;
|
|
659
|
+
}
|
|
660
|
+
interface UpdateVariantDto {
|
|
661
|
+
sku?: string;
|
|
662
|
+
name?: string;
|
|
663
|
+
attributes?: Record<string, unknown>;
|
|
664
|
+
price?: number;
|
|
665
|
+
salePrice?: number;
|
|
666
|
+
image?: string | unknown;
|
|
667
|
+
position?: number;
|
|
668
|
+
status?: VariantStatus;
|
|
669
|
+
}
|
|
670
|
+
interface VariantPlatformOverlay {
|
|
671
|
+
price?: number;
|
|
672
|
+
salePrice?: number;
|
|
673
|
+
sku?: string;
|
|
674
|
+
stock?: number;
|
|
675
|
+
name?: string;
|
|
676
|
+
}
|
|
677
|
+
interface BulkVariantInput {
|
|
678
|
+
id?: string;
|
|
679
|
+
sku: string;
|
|
680
|
+
name?: string;
|
|
681
|
+
attributes: Record<string, string>;
|
|
682
|
+
price?: number | null;
|
|
683
|
+
salePrice?: number | null;
|
|
684
|
+
stock: number;
|
|
685
|
+
image?: unknown | null;
|
|
686
|
+
isEnabled: boolean;
|
|
687
|
+
isDeleted?: boolean;
|
|
688
|
+
overlays?: Record<string, VariantPlatformOverlay>;
|
|
689
|
+
}
|
|
690
|
+
interface ProductAttributeInput {
|
|
691
|
+
attributeId: string;
|
|
692
|
+
selectedOptionIds: string[];
|
|
693
|
+
isForVariations: boolean;
|
|
694
|
+
}
|
|
695
|
+
interface BulkSaveVariantsDto {
|
|
696
|
+
variants: BulkVariantInput[];
|
|
697
|
+
productAttributes?: ProductAttributeInput[];
|
|
698
|
+
}
|
|
699
|
+
interface BulkSaveVariantsResponse {
|
|
700
|
+
created: number;
|
|
701
|
+
updated: number;
|
|
702
|
+
deleted: number;
|
|
703
|
+
variants: ProductVariant[];
|
|
704
|
+
}
|
|
705
|
+
interface UpdateVariantInventoryDto {
|
|
706
|
+
newTotal: number;
|
|
707
|
+
reason?: string;
|
|
708
|
+
}
|
|
709
|
+
interface VariantInventoryResponse {
|
|
710
|
+
total: number;
|
|
711
|
+
reserved: number;
|
|
712
|
+
available: number;
|
|
713
|
+
lastInventorySyncAt?: string | null;
|
|
714
|
+
}
|
|
715
|
+
type RefundType = 'full' | 'partial';
|
|
716
|
+
interface RefundLineItem {
|
|
717
|
+
lineItemId: string;
|
|
718
|
+
quantity: number;
|
|
719
|
+
}
|
|
720
|
+
interface CreateRefundDto {
|
|
721
|
+
type: RefundType;
|
|
722
|
+
items?: RefundLineItem[];
|
|
723
|
+
restockInventory?: boolean;
|
|
724
|
+
notifyCustomer?: boolean;
|
|
725
|
+
reason?: string;
|
|
726
|
+
}
|
|
727
|
+
interface RefundLineItemResponse {
|
|
728
|
+
name: string;
|
|
729
|
+
quantity: number;
|
|
730
|
+
amount: string;
|
|
731
|
+
}
|
|
732
|
+
interface Refund {
|
|
733
|
+
id: string;
|
|
734
|
+
createdAt: string;
|
|
735
|
+
amount: string;
|
|
736
|
+
currency: string;
|
|
737
|
+
reason?: string;
|
|
738
|
+
items?: RefundLineItemResponse[];
|
|
739
|
+
status: string;
|
|
740
|
+
}
|
|
741
|
+
interface UpdateOrderShippingDto {
|
|
742
|
+
firstName?: string;
|
|
743
|
+
lastName?: string;
|
|
744
|
+
name?: string;
|
|
745
|
+
company?: string;
|
|
746
|
+
line1: string;
|
|
747
|
+
line2?: string;
|
|
748
|
+
city: string;
|
|
749
|
+
state?: string;
|
|
750
|
+
country: string;
|
|
751
|
+
postalCode: string;
|
|
752
|
+
phone?: string;
|
|
753
|
+
}
|
|
754
|
+
interface FulfillOrderDto {
|
|
755
|
+
trackingNumber?: string;
|
|
756
|
+
trackingCompany?: string;
|
|
757
|
+
notifyCustomer?: boolean;
|
|
758
|
+
}
|
|
759
|
+
interface CompleteDraftDto {
|
|
760
|
+
paymentPending?: boolean;
|
|
761
|
+
}
|
|
762
|
+
interface SendInvoiceDto {
|
|
763
|
+
to?: string;
|
|
764
|
+
subject?: string;
|
|
765
|
+
customMessage?: string;
|
|
766
|
+
}
|
|
767
|
+
interface AppliedDiscount {
|
|
768
|
+
valueType: 'fixed_amount' | 'percentage';
|
|
769
|
+
value: string;
|
|
770
|
+
description?: string;
|
|
771
|
+
title?: string;
|
|
772
|
+
}
|
|
773
|
+
interface DraftLineItem {
|
|
774
|
+
variantId?: number;
|
|
775
|
+
quantity?: number;
|
|
776
|
+
title?: string;
|
|
777
|
+
price?: string;
|
|
778
|
+
appliedDiscount?: AppliedDiscount;
|
|
779
|
+
}
|
|
780
|
+
interface ShippingLine {
|
|
781
|
+
title: string;
|
|
782
|
+
price: string;
|
|
783
|
+
}
|
|
784
|
+
interface UpdateDraftDto {
|
|
785
|
+
note?: string;
|
|
786
|
+
tags?: string;
|
|
787
|
+
email?: string;
|
|
788
|
+
shippingAddress?: Record<string, unknown>;
|
|
789
|
+
billingAddress?: Record<string, unknown>;
|
|
790
|
+
lineItems?: DraftLineItem[];
|
|
791
|
+
appliedDiscount?: AppliedDiscount;
|
|
792
|
+
shippingLine?: ShippingLine;
|
|
793
|
+
}
|
|
794
|
+
interface EditInventoryDto {
|
|
795
|
+
productId: string;
|
|
796
|
+
newTotal: number;
|
|
797
|
+
reason?: string;
|
|
798
|
+
}
|
|
799
|
+
interface InventorySyncStatus {
|
|
800
|
+
total: number;
|
|
801
|
+
pending: number;
|
|
802
|
+
synced: number;
|
|
803
|
+
neverSynced: number;
|
|
804
|
+
lastSyncAt: string | null;
|
|
805
|
+
}
|
|
806
|
+
interface BulkInventoryResponse {
|
|
807
|
+
productId: string;
|
|
808
|
+
total: number;
|
|
809
|
+
reserved: number;
|
|
810
|
+
available: number;
|
|
811
|
+
}
|
|
812
|
+
interface ReconcileInventoryResponse {
|
|
813
|
+
productId?: string;
|
|
814
|
+
results?: unknown;
|
|
815
|
+
total?: number;
|
|
816
|
+
reconciled?: number;
|
|
817
|
+
discrepancies?: number;
|
|
818
|
+
}
|
|
819
|
+
interface PublishProductResponse {
|
|
820
|
+
productId: string;
|
|
821
|
+
results: Record<string, {
|
|
822
|
+
success: boolean;
|
|
823
|
+
error?: string;
|
|
824
|
+
}>;
|
|
825
|
+
}
|
|
583
826
|
interface OmniSyncApiError {
|
|
584
827
|
statusCode: number;
|
|
585
828
|
message: string;
|
|
@@ -588,37 +831,99 @@ interface OmniSyncApiError {
|
|
|
588
831
|
}
|
|
589
832
|
|
|
590
833
|
/**
|
|
591
|
-
* OmniSyncClient - SDK for integrating
|
|
834
|
+
* OmniSyncClient - SDK for integrating stores with Omni-Sync Platform
|
|
592
835
|
*
|
|
593
|
-
*
|
|
836
|
+
* Three modes of operation:
|
|
837
|
+
*
|
|
838
|
+
* **Vibe-Coded Mode (Simplest)** - Use connectionId for vibe-coded sites:
|
|
594
839
|
* ```typescript
|
|
595
|
-
* const omni = new OmniSyncClient({
|
|
596
|
-
*
|
|
597
|
-
*
|
|
840
|
+
* const omni = new OmniSyncClient({ connectionId: 'vc_abc123...' });
|
|
841
|
+
* const products = await omni.getProducts();
|
|
842
|
+
* ```
|
|
598
843
|
*
|
|
599
|
-
*
|
|
844
|
+
* **Storefront Mode (Frontend)** - Use storeId for public access:
|
|
845
|
+
* ```typescript
|
|
846
|
+
* const omni = new OmniSyncClient({ storeId: 'store_abc123' });
|
|
600
847
|
* const products = await omni.getProducts();
|
|
848
|
+
* ```
|
|
601
849
|
*
|
|
602
|
-
*
|
|
603
|
-
*
|
|
604
|
-
*
|
|
605
|
-
*
|
|
606
|
-
* totalAmount: 199.98,
|
|
607
|
-
* });
|
|
850
|
+
* **Admin Mode (Backend)** - Use apiKey for full access:
|
|
851
|
+
* ```typescript
|
|
852
|
+
* const omni = new OmniSyncClient({ apiKey: process.env.OMNI_API_KEY });
|
|
853
|
+
* const orders = await omni.getOrders();
|
|
608
854
|
* ```
|
|
609
855
|
*/
|
|
610
856
|
declare class OmniSyncClient {
|
|
611
|
-
private readonly apiKey
|
|
857
|
+
private readonly apiKey?;
|
|
858
|
+
private readonly storeId?;
|
|
859
|
+
private readonly connectionId?;
|
|
612
860
|
private readonly baseUrl;
|
|
613
861
|
private readonly timeout;
|
|
862
|
+
private customerToken;
|
|
614
863
|
constructor(options: OmniSyncClientOptions);
|
|
864
|
+
/**
|
|
865
|
+
* Check if client is in vibe-coded mode (using connectionId)
|
|
866
|
+
*/
|
|
867
|
+
isVibeCodedMode(): boolean;
|
|
868
|
+
/**
|
|
869
|
+
* Check if client is in storefront mode (using storeId)
|
|
870
|
+
*/
|
|
871
|
+
isStorefrontMode(): boolean;
|
|
872
|
+
/**
|
|
873
|
+
* Check if client is in admin mode (using apiKey)
|
|
874
|
+
*/
|
|
875
|
+
isAdminMode(): boolean;
|
|
876
|
+
/**
|
|
877
|
+
* Set the customer authentication token (obtained from login/register).
|
|
878
|
+
* Required for accessing customer-specific data in storefront mode.
|
|
879
|
+
*
|
|
880
|
+
* @example
|
|
881
|
+
* ```typescript
|
|
882
|
+
* const auth = await omni.loginCustomer('user@example.com', 'password');
|
|
883
|
+
* omni.setCustomerToken(auth.token);
|
|
884
|
+
*
|
|
885
|
+
* // Now can access customer data
|
|
886
|
+
* const profile = await omni.getMyProfile();
|
|
887
|
+
* ```
|
|
888
|
+
*/
|
|
889
|
+
setCustomerToken(token: string | null): void;
|
|
890
|
+
/**
|
|
891
|
+
* Get the current customer token
|
|
892
|
+
*/
|
|
893
|
+
getCustomerToken(): string | null;
|
|
894
|
+
/**
|
|
895
|
+
* Clear the customer token (logout)
|
|
896
|
+
*/
|
|
897
|
+
clearCustomerToken(): void;
|
|
898
|
+
/**
|
|
899
|
+
* Make a request to the Admin API (requires apiKey)
|
|
900
|
+
*/
|
|
901
|
+
private adminRequest;
|
|
902
|
+
/**
|
|
903
|
+
* Make a request to the Vibe-Coded API (public, uses connectionId)
|
|
904
|
+
*/
|
|
905
|
+
private vibeCodedRequest;
|
|
906
|
+
/**
|
|
907
|
+
* Make a request to the Storefront API (public, uses storeId)
|
|
908
|
+
*/
|
|
909
|
+
private storefrontRequest;
|
|
910
|
+
/**
|
|
911
|
+
* Smart request - uses storefront or admin API based on client mode
|
|
912
|
+
*/
|
|
615
913
|
private request;
|
|
914
|
+
/**
|
|
915
|
+
* Get store information
|
|
916
|
+
* Works in vibe-coded, storefront, and admin mode
|
|
917
|
+
*/
|
|
918
|
+
getStoreInfo(): Promise<StoreInfo>;
|
|
616
919
|
/**
|
|
617
920
|
* Get a list of products with pagination
|
|
921
|
+
* Works in vibe-coded, storefront (public), and admin mode
|
|
618
922
|
*/
|
|
619
923
|
getProducts(params?: ProductQueryParams): Promise<PaginatedResponse<Product>>;
|
|
620
924
|
/**
|
|
621
925
|
* Get a single product by ID
|
|
926
|
+
* Works in vibe-coded, storefront (public), and admin mode
|
|
622
927
|
*/
|
|
623
928
|
getProduct(productId: string): Promise<Product>;
|
|
624
929
|
/**
|
|
@@ -633,6 +938,111 @@ declare class OmniSyncClient {
|
|
|
633
938
|
* Delete a product
|
|
634
939
|
*/
|
|
635
940
|
deleteProduct(productId: string): Promise<void>;
|
|
941
|
+
/**
|
|
942
|
+
* Convert a SIMPLE product to VARIABLE product
|
|
943
|
+
*
|
|
944
|
+
* @example
|
|
945
|
+
* ```typescript
|
|
946
|
+
* const product = await omni.convertToVariable('prod_123');
|
|
947
|
+
* console.log('Product type:', product.type); // 'VARIABLE'
|
|
948
|
+
* ```
|
|
949
|
+
*/
|
|
950
|
+
convertToVariable(productId: string): Promise<Product>;
|
|
951
|
+
/**
|
|
952
|
+
* Convert a VARIABLE product to SIMPLE product
|
|
953
|
+
* Note: This will delete all variants
|
|
954
|
+
*
|
|
955
|
+
* @example
|
|
956
|
+
* ```typescript
|
|
957
|
+
* const product = await omni.convertToSimple('prod_123');
|
|
958
|
+
* console.log('Product type:', product.type); // 'SIMPLE'
|
|
959
|
+
* ```
|
|
960
|
+
*/
|
|
961
|
+
convertToSimple(productId: string): Promise<Product>;
|
|
962
|
+
/**
|
|
963
|
+
* Publish a product to specific platforms
|
|
964
|
+
*
|
|
965
|
+
* @example
|
|
966
|
+
* ```typescript
|
|
967
|
+
* const result = await omni.publishProduct('prod_123', ['SHOPIFY', 'WOOCOMMERCE']);
|
|
968
|
+
* console.log('Publish results:', result.results);
|
|
969
|
+
* ```
|
|
970
|
+
*/
|
|
971
|
+
publishProduct(productId: string, platforms: string[]): Promise<PublishProductResponse>;
|
|
972
|
+
/**
|
|
973
|
+
* Create a new variant for a product
|
|
974
|
+
*
|
|
975
|
+
* @example
|
|
976
|
+
* ```typescript
|
|
977
|
+
* const variant = await omni.createVariant('prod_123', {
|
|
978
|
+
* sku: 'PROD-SM-RED',
|
|
979
|
+
* name: 'Small / Red',
|
|
980
|
+
* attributes: { size: 'S', color: 'Red' },
|
|
981
|
+
* price: 29.99,
|
|
982
|
+
* inventory: 100,
|
|
983
|
+
* });
|
|
984
|
+
* ```
|
|
985
|
+
*/
|
|
986
|
+
createVariant(productId: string, data: CreateVariantDto): Promise<ProductVariant>;
|
|
987
|
+
/**
|
|
988
|
+
* Bulk save variants (create, update, delete in one operation)
|
|
989
|
+
*
|
|
990
|
+
* @example
|
|
991
|
+
* ```typescript
|
|
992
|
+
* const result = await omni.bulkSaveVariants('prod_123', {
|
|
993
|
+
* variants: [
|
|
994
|
+
* { sku: 'SM-RED', attributes: { size: 'S', color: 'Red' }, stock: 10, isEnabled: true },
|
|
995
|
+
* { id: 'var_456', sku: 'MD-BLUE', attributes: { size: 'M', color: 'Blue' }, stock: 5, isEnabled: true },
|
|
996
|
+
* { id: 'var_789', sku: 'LG-GREEN', attributes: {}, stock: 0, isEnabled: false, isDeleted: true },
|
|
997
|
+
* ],
|
|
998
|
+
* });
|
|
999
|
+
* console.log(`Created: ${result.created}, Updated: ${result.updated}, Deleted: ${result.deleted}`);
|
|
1000
|
+
* ```
|
|
1001
|
+
*/
|
|
1002
|
+
bulkSaveVariants(productId: string, data: BulkSaveVariantsDto): Promise<BulkSaveVariantsResponse>;
|
|
1003
|
+
/**
|
|
1004
|
+
* Update a variant
|
|
1005
|
+
*
|
|
1006
|
+
* @example
|
|
1007
|
+
* ```typescript
|
|
1008
|
+
* const variant = await omni.updateVariant('prod_123', 'var_456', {
|
|
1009
|
+
* price: 34.99,
|
|
1010
|
+
* salePrice: 29.99,
|
|
1011
|
+
* });
|
|
1012
|
+
* ```
|
|
1013
|
+
*/
|
|
1014
|
+
updateVariant(productId: string, variantId: string, data: UpdateVariantDto): Promise<ProductVariant>;
|
|
1015
|
+
/**
|
|
1016
|
+
* Delete a variant
|
|
1017
|
+
*
|
|
1018
|
+
* @example
|
|
1019
|
+
* ```typescript
|
|
1020
|
+
* await omni.deleteVariant('prod_123', 'var_456');
|
|
1021
|
+
* ```
|
|
1022
|
+
*/
|
|
1023
|
+
deleteVariant(productId: string, variantId: string): Promise<void>;
|
|
1024
|
+
/**
|
|
1025
|
+
* Get inventory for a specific variant
|
|
1026
|
+
*
|
|
1027
|
+
* @example
|
|
1028
|
+
* ```typescript
|
|
1029
|
+
* const inventory = await omni.getVariantInventory('prod_123', 'var_456');
|
|
1030
|
+
* console.log('Available:', inventory.available);
|
|
1031
|
+
* ```
|
|
1032
|
+
*/
|
|
1033
|
+
getVariantInventory(productId: string, variantId: string): Promise<VariantInventoryResponse>;
|
|
1034
|
+
/**
|
|
1035
|
+
* Update inventory for a specific variant
|
|
1036
|
+
*
|
|
1037
|
+
* @example
|
|
1038
|
+
* ```typescript
|
|
1039
|
+
* const inventory = await omni.updateVariantInventory('prod_123', 'var_456', {
|
|
1040
|
+
* newTotal: 50,
|
|
1041
|
+
* reason: 'Restocked from supplier',
|
|
1042
|
+
* });
|
|
1043
|
+
* ```
|
|
1044
|
+
*/
|
|
1045
|
+
updateVariantInventory(productId: string, variantId: string, data: UpdateVariantInventoryDto): Promise<VariantInventoryResponse>;
|
|
636
1046
|
/**
|
|
637
1047
|
* Get a list of orders with pagination
|
|
638
1048
|
*/
|
|
@@ -650,6 +1060,181 @@ declare class OmniSyncClient {
|
|
|
650
1060
|
* Update an order (e.g., change status)
|
|
651
1061
|
*/
|
|
652
1062
|
updateOrder(orderId: string, data: UpdateOrderDto): Promise<Order>;
|
|
1063
|
+
/**
|
|
1064
|
+
* Update order status
|
|
1065
|
+
*
|
|
1066
|
+
* @example
|
|
1067
|
+
* ```typescript
|
|
1068
|
+
* const order = await omni.updateOrderStatus('order_123', 'shipped');
|
|
1069
|
+
* ```
|
|
1070
|
+
*/
|
|
1071
|
+
updateOrderStatus(orderId: string, status: string): Promise<Order>;
|
|
1072
|
+
/**
|
|
1073
|
+
* Update order payment method
|
|
1074
|
+
* Note: Only WooCommerce supports syncing payment method changes back to platform
|
|
1075
|
+
*
|
|
1076
|
+
* @example
|
|
1077
|
+
* ```typescript
|
|
1078
|
+
* const order = await omni.updatePaymentMethod('order_123', 'credit_card');
|
|
1079
|
+
* ```
|
|
1080
|
+
*/
|
|
1081
|
+
updatePaymentMethod(orderId: string, paymentMethod: string): Promise<Order>;
|
|
1082
|
+
/**
|
|
1083
|
+
* Update order notes
|
|
1084
|
+
*
|
|
1085
|
+
* @example
|
|
1086
|
+
* ```typescript
|
|
1087
|
+
* const order = await omni.updateOrderNotes('order_123', 'Customer requested gift wrapping');
|
|
1088
|
+
* ```
|
|
1089
|
+
*/
|
|
1090
|
+
updateOrderNotes(orderId: string, notes: string): Promise<Order>;
|
|
1091
|
+
/**
|
|
1092
|
+
* Get refunds for an order
|
|
1093
|
+
* Returns refunds from the source platform (Shopify/WooCommerce only)
|
|
1094
|
+
*
|
|
1095
|
+
* @example
|
|
1096
|
+
* ```typescript
|
|
1097
|
+
* const refunds = await omni.getOrderRefunds('order_123');
|
|
1098
|
+
* console.log('Total refunds:', refunds.length);
|
|
1099
|
+
* ```
|
|
1100
|
+
*/
|
|
1101
|
+
getOrderRefunds(orderId: string): Promise<Refund[]>;
|
|
1102
|
+
/**
|
|
1103
|
+
* Create a refund for an order
|
|
1104
|
+
* Creates refund on the source platform (Shopify/WooCommerce only)
|
|
1105
|
+
*
|
|
1106
|
+
* @example
|
|
1107
|
+
* ```typescript
|
|
1108
|
+
* // Full refund
|
|
1109
|
+
* const refund = await omni.createRefund('order_123', {
|
|
1110
|
+
* type: 'full',
|
|
1111
|
+
* restockInventory: true,
|
|
1112
|
+
* notifyCustomer: true,
|
|
1113
|
+
* reason: 'Customer request',
|
|
1114
|
+
* });
|
|
1115
|
+
*
|
|
1116
|
+
* // Partial refund
|
|
1117
|
+
* const partialRefund = await omni.createRefund('order_123', {
|
|
1118
|
+
* type: 'partial',
|
|
1119
|
+
* items: [
|
|
1120
|
+
* { lineItemId: 'item_456', quantity: 1 },
|
|
1121
|
+
* ],
|
|
1122
|
+
* restockInventory: true,
|
|
1123
|
+
* });
|
|
1124
|
+
* ```
|
|
1125
|
+
*/
|
|
1126
|
+
createRefund(orderId: string, data: CreateRefundDto): Promise<Refund>;
|
|
1127
|
+
/**
|
|
1128
|
+
* Update order shipping address
|
|
1129
|
+
* Syncs to source platform (Shopify/WooCommerce only)
|
|
1130
|
+
*
|
|
1131
|
+
* @example
|
|
1132
|
+
* ```typescript
|
|
1133
|
+
* const order = await omni.updateOrderShipping('order_123', {
|
|
1134
|
+
* firstName: 'John',
|
|
1135
|
+
* lastName: 'Doe',
|
|
1136
|
+
* line1: '456 New Address',
|
|
1137
|
+
* city: 'Los Angeles',
|
|
1138
|
+
* state: 'CA',
|
|
1139
|
+
* country: 'US',
|
|
1140
|
+
* postalCode: '90001',
|
|
1141
|
+
* });
|
|
1142
|
+
* ```
|
|
1143
|
+
*/
|
|
1144
|
+
updateOrderShipping(orderId: string, data: UpdateOrderShippingDto): Promise<Order>;
|
|
1145
|
+
/**
|
|
1146
|
+
* Cancel an order
|
|
1147
|
+
* Works for Shopify and WooCommerce orders that haven't been fulfilled
|
|
1148
|
+
*
|
|
1149
|
+
* @example
|
|
1150
|
+
* ```typescript
|
|
1151
|
+
* const order = await omni.cancelOrder('order_123');
|
|
1152
|
+
* console.log('Order status:', order.status); // 'cancelled'
|
|
1153
|
+
* ```
|
|
1154
|
+
*/
|
|
1155
|
+
cancelOrder(orderId: string): Promise<Order>;
|
|
1156
|
+
/**
|
|
1157
|
+
* Fulfill an order (mark as shipped)
|
|
1158
|
+
* Works for Shopify and WooCommerce orders
|
|
1159
|
+
*
|
|
1160
|
+
* @example
|
|
1161
|
+
* ```typescript
|
|
1162
|
+
* const order = await omni.fulfillOrder('order_123', {
|
|
1163
|
+
* trackingNumber: '1Z999AA10123456784',
|
|
1164
|
+
* trackingCompany: 'UPS',
|
|
1165
|
+
* notifyCustomer: true,
|
|
1166
|
+
* });
|
|
1167
|
+
* ```
|
|
1168
|
+
*/
|
|
1169
|
+
fulfillOrder(orderId: string, data?: FulfillOrderDto): Promise<Order>;
|
|
1170
|
+
/**
|
|
1171
|
+
* Sync draft orders from connected platforms
|
|
1172
|
+
*
|
|
1173
|
+
* @example
|
|
1174
|
+
* ```typescript
|
|
1175
|
+
* const result = await omni.syncDraftOrders();
|
|
1176
|
+
* console.log('Draft orders synced');
|
|
1177
|
+
* ```
|
|
1178
|
+
*/
|
|
1179
|
+
syncDraftOrders(): Promise<{
|
|
1180
|
+
message: string;
|
|
1181
|
+
}>;
|
|
1182
|
+
/**
|
|
1183
|
+
* Complete a draft order (convert to regular order)
|
|
1184
|
+
*
|
|
1185
|
+
* @example
|
|
1186
|
+
* ```typescript
|
|
1187
|
+
* const order = await omni.completeDraftOrder('draft_123', {
|
|
1188
|
+
* paymentPending: false,
|
|
1189
|
+
* });
|
|
1190
|
+
* ```
|
|
1191
|
+
*/
|
|
1192
|
+
completeDraftOrder(orderId: string, data?: CompleteDraftDto): Promise<Order>;
|
|
1193
|
+
/**
|
|
1194
|
+
* Send invoice for a draft order
|
|
1195
|
+
*
|
|
1196
|
+
* @example
|
|
1197
|
+
* ```typescript
|
|
1198
|
+
* await omni.sendDraftInvoice('draft_123', {
|
|
1199
|
+
* to: 'customer@example.com',
|
|
1200
|
+
* subject: 'Your Invoice',
|
|
1201
|
+
* customMessage: 'Thank you for your order!',
|
|
1202
|
+
* });
|
|
1203
|
+
* ```
|
|
1204
|
+
*/
|
|
1205
|
+
sendDraftInvoice(orderId: string, data?: SendInvoiceDto): Promise<{
|
|
1206
|
+
message: string;
|
|
1207
|
+
}>;
|
|
1208
|
+
/**
|
|
1209
|
+
* Delete a draft order
|
|
1210
|
+
*
|
|
1211
|
+
* @example
|
|
1212
|
+
* ```typescript
|
|
1213
|
+
* await omni.deleteDraftOrder('draft_123');
|
|
1214
|
+
* ```
|
|
1215
|
+
*/
|
|
1216
|
+
deleteDraftOrder(orderId: string): Promise<void>;
|
|
1217
|
+
/**
|
|
1218
|
+
* Update a draft order
|
|
1219
|
+
*
|
|
1220
|
+
* @example
|
|
1221
|
+
* ```typescript
|
|
1222
|
+
* const order = await omni.updateDraftOrder('draft_123', {
|
|
1223
|
+
* note: 'Updated customer note',
|
|
1224
|
+
* email: 'newemail@example.com',
|
|
1225
|
+
* shippingAddress: {
|
|
1226
|
+
* firstName: 'John',
|
|
1227
|
+
* lastName: 'Doe',
|
|
1228
|
+
* address1: '123 Main St',
|
|
1229
|
+
* city: 'New York',
|
|
1230
|
+
* province: 'NY',
|
|
1231
|
+
* country: 'US',
|
|
1232
|
+
* zip: '10001',
|
|
1233
|
+
* },
|
|
1234
|
+
* });
|
|
1235
|
+
* ```
|
|
1236
|
+
*/
|
|
1237
|
+
updateDraftOrder(orderId: string, data: UpdateDraftDto): Promise<Order>;
|
|
653
1238
|
/**
|
|
654
1239
|
* Update inventory for a product
|
|
655
1240
|
* This will sync inventory to all connected platforms
|
|
@@ -663,6 +1248,64 @@ declare class OmniSyncClient {
|
|
|
663
1248
|
reserved: number;
|
|
664
1249
|
total: number;
|
|
665
1250
|
}>;
|
|
1251
|
+
/**
|
|
1252
|
+
* Edit inventory manually with reason for audit trail
|
|
1253
|
+
*
|
|
1254
|
+
* @example
|
|
1255
|
+
* ```typescript
|
|
1256
|
+
* const inventory = await omni.editInventory({
|
|
1257
|
+
* productId: 'prod_123',
|
|
1258
|
+
* newTotal: 100,
|
|
1259
|
+
* reason: 'Restocked from warehouse',
|
|
1260
|
+
* });
|
|
1261
|
+
* ```
|
|
1262
|
+
*/
|
|
1263
|
+
editInventory(data: EditInventoryDto): Promise<{
|
|
1264
|
+
total: number;
|
|
1265
|
+
reserved: number;
|
|
1266
|
+
available: number;
|
|
1267
|
+
}>;
|
|
1268
|
+
/**
|
|
1269
|
+
* Get inventory sync status for all products in the store
|
|
1270
|
+
*
|
|
1271
|
+
* @example
|
|
1272
|
+
* ```typescript
|
|
1273
|
+
* const status = await omni.getInventorySyncStatus();
|
|
1274
|
+
* console.log(`${status.pending} products pending sync`);
|
|
1275
|
+
* console.log(`Last sync: ${status.lastSyncAt}`);
|
|
1276
|
+
* ```
|
|
1277
|
+
*/
|
|
1278
|
+
getInventorySyncStatus(): Promise<InventorySyncStatus>;
|
|
1279
|
+
/**
|
|
1280
|
+
* Get inventory for multiple products at once
|
|
1281
|
+
*
|
|
1282
|
+
* @example
|
|
1283
|
+
* ```typescript
|
|
1284
|
+
* const inventories = await omni.getBulkInventory(['prod_123', 'prod_456', 'prod_789']);
|
|
1285
|
+
* inventories.forEach(inv => {
|
|
1286
|
+
* console.log(`${inv.productId}: ${inv.available} available`);
|
|
1287
|
+
* });
|
|
1288
|
+
* ```
|
|
1289
|
+
*/
|
|
1290
|
+
getBulkInventory(productIds: string[]): Promise<BulkInventoryResponse[]>;
|
|
1291
|
+
/**
|
|
1292
|
+
* Reconcile inventory between OmniSync and connected platforms
|
|
1293
|
+
* Detects and optionally fixes discrepancies
|
|
1294
|
+
*
|
|
1295
|
+
* @example
|
|
1296
|
+
* ```typescript
|
|
1297
|
+
* // Reconcile single product (dry run)
|
|
1298
|
+
* const result = await omni.reconcileInventory({ productId: 'prod_123' });
|
|
1299
|
+
*
|
|
1300
|
+
* // Reconcile all products with auto-fix
|
|
1301
|
+
* const summary = await omni.reconcileInventory({ autoFix: true });
|
|
1302
|
+
* console.log(`Reconciled ${summary.reconciled} products`);
|
|
1303
|
+
* ```
|
|
1304
|
+
*/
|
|
1305
|
+
reconcileInventory(options?: {
|
|
1306
|
+
productId?: string;
|
|
1307
|
+
autoFix?: boolean;
|
|
1308
|
+
}): Promise<ReconcileInventoryResponse>;
|
|
666
1309
|
/**
|
|
667
1310
|
* Trigger a sync to a specific platform or all platforms
|
|
668
1311
|
*/
|
|
@@ -671,16 +1314,6 @@ declare class OmniSyncClient {
|
|
|
671
1314
|
* Get the status of a sync job
|
|
672
1315
|
*/
|
|
673
1316
|
getSyncStatus(jobId: string): Promise<SyncJob>;
|
|
674
|
-
/**
|
|
675
|
-
* Get information about the connected store
|
|
676
|
-
*/
|
|
677
|
-
getStoreInfo(): Promise<{
|
|
678
|
-
id: string;
|
|
679
|
-
name: string;
|
|
680
|
-
currency: string;
|
|
681
|
-
language: string;
|
|
682
|
-
connectedPlatforms: ConnectorPlatform[];
|
|
683
|
-
}>;
|
|
684
1317
|
/**
|
|
685
1318
|
* Get a list of coupons with pagination
|
|
686
1319
|
*/
|
|
@@ -1067,6 +1700,62 @@ declare class OmniSyncClient {
|
|
|
1067
1700
|
* ```
|
|
1068
1701
|
*/
|
|
1069
1702
|
completeCheckout(checkoutId: string): Promise<CompleteCheckoutResponse>;
|
|
1703
|
+
/**
|
|
1704
|
+
* Get the current customer's profile (requires customerToken)
|
|
1705
|
+
* Only available in storefront mode
|
|
1706
|
+
*
|
|
1707
|
+
* @example
|
|
1708
|
+
* ```typescript
|
|
1709
|
+
* const auth = await omni.loginCustomer('user@example.com', 'password');
|
|
1710
|
+
* omni.setCustomerToken(auth.token);
|
|
1711
|
+
* const profile = await omni.getMyProfile();
|
|
1712
|
+
* ```
|
|
1713
|
+
*/
|
|
1714
|
+
getMyProfile(): Promise<CustomerProfile>;
|
|
1715
|
+
/**
|
|
1716
|
+
* Update the current customer's profile (requires customerToken)
|
|
1717
|
+
* Only available in storefront mode
|
|
1718
|
+
*/
|
|
1719
|
+
updateMyProfile(data: {
|
|
1720
|
+
firstName?: string;
|
|
1721
|
+
lastName?: string;
|
|
1722
|
+
phone?: string;
|
|
1723
|
+
acceptsMarketing?: boolean;
|
|
1724
|
+
}): Promise<CustomerProfile>;
|
|
1725
|
+
/**
|
|
1726
|
+
* Get the current customer's orders (requires customerToken)
|
|
1727
|
+
* Only available in storefront mode
|
|
1728
|
+
*/
|
|
1729
|
+
getMyOrders(params?: {
|
|
1730
|
+
page?: number;
|
|
1731
|
+
limit?: number;
|
|
1732
|
+
}): Promise<PaginatedResponse<Order>>;
|
|
1733
|
+
/**
|
|
1734
|
+
* Get the current customer's addresses (requires customerToken)
|
|
1735
|
+
* Only available in storefront mode
|
|
1736
|
+
*/
|
|
1737
|
+
getMyAddresses(): Promise<CustomerAddress[]>;
|
|
1738
|
+
/**
|
|
1739
|
+
* Add an address to the current customer (requires customerToken)
|
|
1740
|
+
* Only available in storefront mode
|
|
1741
|
+
*/
|
|
1742
|
+
addMyAddress(address: CreateAddressDto): Promise<CustomerAddress>;
|
|
1743
|
+
/**
|
|
1744
|
+
* Update a customer address (requires customerToken)
|
|
1745
|
+
* Only available in storefront mode
|
|
1746
|
+
*/
|
|
1747
|
+
updateMyAddress(addressId: string, data: UpdateAddressDto): Promise<CustomerAddress>;
|
|
1748
|
+
/**
|
|
1749
|
+
* Delete a customer address (requires customerToken)
|
|
1750
|
+
* Only available in storefront mode
|
|
1751
|
+
*/
|
|
1752
|
+
deleteMyAddress(addressId: string): Promise<void>;
|
|
1753
|
+
/**
|
|
1754
|
+
* Get the current customer's cart (requires customerToken)
|
|
1755
|
+
* Creates a new cart if none exists
|
|
1756
|
+
* Only available in storefront mode
|
|
1757
|
+
*/
|
|
1758
|
+
getMyCart(): Promise<Cart>;
|
|
1070
1759
|
}
|
|
1071
1760
|
/**
|
|
1072
1761
|
* Custom error class for Omni-Sync API errors
|
|
@@ -1087,7 +1776,7 @@ declare class OmniSyncError extends Error {
|
|
|
1087
1776
|
*
|
|
1088
1777
|
* @example
|
|
1089
1778
|
* ```typescript
|
|
1090
|
-
* import { verifyWebhook } from '
|
|
1779
|
+
* import { verifyWebhook } from 'omni-sync-sdk';
|
|
1091
1780
|
*
|
|
1092
1781
|
* app.post('/webhooks/omni-sync', async (req, res) => {
|
|
1093
1782
|
* const signature = req.headers['x-omni-signature'];
|
|
@@ -1134,4 +1823,4 @@ declare function isWebhookEventType(event: WebhookEvent, type: WebhookEventType)
|
|
|
1134
1823
|
*/
|
|
1135
1824
|
declare function createWebhookHandler(handlers: Partial<Record<WebhookEventType, (event: WebhookEvent) => Promise<void>>>): (payload: unknown) => Promise<void>;
|
|
1136
1825
|
|
|
1137
|
-
export { type ConnectorPlatform, type Coupon, type CouponCreateResponse, type CouponQueryParams, type CouponStatus, type CouponType, type CouponValidationWarning, type CreateCouponDto, type CreateOrderDto, type CreateProductDto, type InventoryInfo, 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 ProductImage, type ProductQueryParams, type ProductVariant, type SyncJob, type UpdateCouponDto, type UpdateInventoryDto, type UpdateOrderDto, type UpdateProductDto, type WebhookEvent, type WebhookEventType, createWebhookHandler, isCouponApplicableToProduct, isWebhookEventType, parseWebhookEvent, verifyWebhook };
|
|
1826
|
+
export { type AddToCartDto, type AppliedDiscount, type ApplyCouponDto, type BulkInventoryResponse, type BulkSaveVariantsDto, type BulkSaveVariantsResponse, type BulkVariantInput, type Cart, type CartItem, type CartStatus, 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 CreateCustomerDto, type CreateOrderDto, type CreateProductDto, type CreateRefundDto, type CreateVariantDto, type Customer, type CustomerAddress, type CustomerAuthResponse, type CustomerProfile, type CustomerQueryParams, type DraftLineItem, type EditInventoryDto, type FulfillOrderDto, type InventoryInfo, type InventorySyncStatus, type MergeCartsDto, 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 ProductVariant, type PublishProductResponse, type ReconcileInventoryResponse, type Refund, type RefundLineItem, type RefundLineItemResponse, type RefundType, type RegisterCustomerDto, 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 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 };
|