omni-sync-sdk 0.1.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.
@@ -0,0 +1,1137 @@
1
+ interface OmniSyncClientOptions {
2
+ /**
3
+ * API Key for authentication (starts with "omni_")
4
+ */
5
+ apiKey: string;
6
+ /**
7
+ * Base URL of the Omni-Sync API
8
+ * @default "https://api.omni-sync.com"
9
+ */
10
+ baseUrl?: string;
11
+ /**
12
+ * Request timeout in milliseconds
13
+ * @default 30000
14
+ */
15
+ timeout?: number;
16
+ }
17
+ interface Product {
18
+ id: string;
19
+ name: string;
20
+ description?: string | null;
21
+ sku: string;
22
+ basePrice: number;
23
+ salePrice?: number | null;
24
+ costPrice?: number | null;
25
+ status: 'active' | 'draft' | 'archived';
26
+ type: 'SIMPLE' | 'VARIABLE';
27
+ images?: ProductImage[];
28
+ inventory?: InventoryInfo | null;
29
+ variants?: ProductVariant[];
30
+ categories?: string[];
31
+ tags?: string[];
32
+ channels?: Record<string, Record<string, unknown>>;
33
+ createdAt: string;
34
+ updatedAt: string;
35
+ }
36
+ interface ProductImage {
37
+ url: string;
38
+ position?: number;
39
+ isMain?: boolean;
40
+ }
41
+ interface ProductVariant {
42
+ id: string;
43
+ sku?: string | null;
44
+ name?: string | null;
45
+ price?: number | null;
46
+ salePrice?: number | null;
47
+ attributes?: Record<string, string>;
48
+ inventory?: InventoryInfo | null;
49
+ }
50
+ interface InventoryInfo {
51
+ total: number;
52
+ reserved: number;
53
+ available: number;
54
+ }
55
+ interface ProductQueryParams {
56
+ page?: number;
57
+ limit?: number;
58
+ search?: string;
59
+ status?: 'active' | 'draft' | 'archived';
60
+ type?: 'SIMPLE' | 'VARIABLE';
61
+ sortBy?: 'name' | 'createdAt' | 'updatedAt' | 'basePrice';
62
+ sortOrder?: 'asc' | 'desc';
63
+ }
64
+ interface PaginatedResponse<T> {
65
+ data: T[];
66
+ meta: {
67
+ page: number;
68
+ limit: number;
69
+ total: number;
70
+ totalPages: number;
71
+ };
72
+ }
73
+ interface CreateProductDto {
74
+ name: string;
75
+ sku?: string;
76
+ description?: string;
77
+ basePrice: number;
78
+ salePrice?: number;
79
+ costPrice?: number;
80
+ status?: 'active' | 'draft';
81
+ type?: 'SIMPLE' | 'VARIABLE';
82
+ categories?: string[];
83
+ tags?: string[];
84
+ images?: ProductImage[];
85
+ }
86
+ interface UpdateProductDto {
87
+ name?: string;
88
+ sku?: string;
89
+ description?: string;
90
+ basePrice?: number;
91
+ salePrice?: number | null;
92
+ costPrice?: number | null;
93
+ status?: 'active' | 'draft' | 'archived';
94
+ categories?: string[];
95
+ tags?: string[];
96
+ images?: ProductImage[];
97
+ }
98
+ interface Order {
99
+ id: string;
100
+ externalId?: string;
101
+ status: OrderStatus;
102
+ totalAmount: number;
103
+ customer: OrderCustomer;
104
+ items: OrderItem[];
105
+ platform?: string;
106
+ createdAt: string;
107
+ }
108
+ type OrderStatus = 'pending' | 'processing' | 'shipped' | 'delivered' | 'cancelled' | 'refunded';
109
+ interface OrderCustomer {
110
+ email: string;
111
+ name?: string;
112
+ phone?: string;
113
+ address?: OrderAddress;
114
+ }
115
+ interface OrderAddress {
116
+ line1: string;
117
+ line2?: string;
118
+ city: string;
119
+ state?: string;
120
+ postalCode: string;
121
+ country: string;
122
+ }
123
+ interface OrderItem {
124
+ productId: string;
125
+ sku?: string;
126
+ name?: string;
127
+ quantity: number;
128
+ price: number;
129
+ variantId?: string;
130
+ }
131
+ interface OrderQueryParams {
132
+ page?: number;
133
+ limit?: number;
134
+ status?: OrderStatus;
135
+ sortBy?: 'createdAt' | 'totalAmount';
136
+ sortOrder?: 'asc' | 'desc';
137
+ }
138
+ interface CreateOrderDto {
139
+ items: {
140
+ productId: string;
141
+ quantity: number;
142
+ price: number;
143
+ variantId?: string;
144
+ }[];
145
+ customer: OrderCustomer;
146
+ totalAmount: number;
147
+ externalId?: string;
148
+ }
149
+ interface UpdateOrderDto {
150
+ status?: OrderStatus;
151
+ }
152
+ interface UpdateInventoryDto {
153
+ quantity: number;
154
+ variantId?: string;
155
+ }
156
+ interface SyncJob {
157
+ jobId: string;
158
+ status: 'queued' | 'processing' | 'completed' | 'failed';
159
+ platform?: string;
160
+ message?: string;
161
+ }
162
+ type ConnectorPlatform = 'SHOPIFY' | 'TIKTOK' | 'META' | 'WOOCOMMERCE' | 'CUSTOM';
163
+ type CouponType = 'PERCENTAGE' | 'FIXED_AMOUNT' | 'FREE_SHIPPING' | 'BUY_X_GET_Y';
164
+ type CouponStatus = 'ACTIVE' | 'SCHEDULED' | 'EXPIRED' | 'DISABLED';
165
+ interface Coupon {
166
+ id: string;
167
+ code: string;
168
+ title?: string | null;
169
+ description?: string | null;
170
+ type: CouponType;
171
+ value: number;
172
+ startsAt?: string | null;
173
+ endsAt?: string | null;
174
+ status: CouponStatus;
175
+ usageLimit?: number | null;
176
+ usageLimitPerCustomer?: number | null;
177
+ usageCount: number;
178
+ minimumOrderAmount?: number | null;
179
+ maximumDiscount?: number | null;
180
+ conditions?: Record<string, unknown> | null;
181
+ /**
182
+ * Product IDs this coupon applies to.
183
+ * If set, coupon only applies to these specific products.
184
+ */
185
+ applicableProducts?: string[] | null;
186
+ /**
187
+ * Product IDs excluded from this coupon.
188
+ * These products will not receive the discount even if in applicable categories.
189
+ */
190
+ excludedProducts?: string[] | null;
191
+ /**
192
+ * Category IDs this coupon applies to.
193
+ * If set, coupon only applies to products in these categories.
194
+ */
195
+ applicableCategories?: string[] | null;
196
+ /**
197
+ * Category IDs excluded from this coupon.
198
+ * Products in these categories will not receive the discount.
199
+ */
200
+ excludedCategories?: string[] | null;
201
+ combinesWithOther: boolean;
202
+ freeShipping: boolean;
203
+ shopifyCouponId?: string | null;
204
+ woocommerceCouponId?: string | null;
205
+ tiktokCouponId?: string | null;
206
+ createdAt: string;
207
+ updatedAt: string;
208
+ }
209
+ interface CouponQueryParams {
210
+ page?: number;
211
+ limit?: number;
212
+ search?: string;
213
+ status?: CouponStatus;
214
+ type?: CouponType;
215
+ platform?: ConnectorPlatform;
216
+ sortBy?: 'code' | 'createdAt' | 'updatedAt' | 'value';
217
+ sortOrder?: 'asc' | 'desc';
218
+ }
219
+ interface CreateCouponDto {
220
+ code: string;
221
+ title?: string;
222
+ description?: string;
223
+ type: CouponType;
224
+ value: number;
225
+ startsAt?: string;
226
+ endsAt?: string;
227
+ status?: CouponStatus;
228
+ usageLimit?: number;
229
+ usageLimitPerCustomer?: number;
230
+ minimumOrderAmount?: number;
231
+ maximumDiscount?: number;
232
+ conditions?: Record<string, unknown>;
233
+ /** Product IDs this coupon applies to */
234
+ applicableProducts?: string[];
235
+ /** Product IDs excluded from this coupon */
236
+ excludedProducts?: string[];
237
+ /** Category IDs this coupon applies to */
238
+ applicableCategories?: string[];
239
+ /** Category IDs excluded from this coupon */
240
+ excludedCategories?: string[];
241
+ combinesWithOther?: boolean;
242
+ freeShipping?: boolean;
243
+ /** Platforms to publish this coupon to */
244
+ platforms?: ConnectorPlatform[];
245
+ }
246
+ interface UpdateCouponDto {
247
+ code?: string;
248
+ title?: string;
249
+ description?: string;
250
+ type?: CouponType;
251
+ value?: number;
252
+ startsAt?: string | null;
253
+ endsAt?: string | null;
254
+ status?: CouponStatus;
255
+ usageLimit?: number | null;
256
+ usageLimitPerCustomer?: number | null;
257
+ minimumOrderAmount?: number | null;
258
+ maximumDiscount?: number | null;
259
+ conditions?: Record<string, unknown> | null;
260
+ applicableProducts?: string[] | null;
261
+ excludedProducts?: string[] | null;
262
+ applicableCategories?: string[] | null;
263
+ excludedCategories?: string[] | null;
264
+ combinesWithOther?: boolean;
265
+ freeShipping?: boolean;
266
+ }
267
+ /**
268
+ * Validation warning returned when syncing coupons to platforms
269
+ * that don't support certain features.
270
+ */
271
+ interface CouponValidationWarning {
272
+ platform: string;
273
+ warnings: string[];
274
+ }
275
+ /**
276
+ * Response from createCoupon with optional validation warnings
277
+ */
278
+ interface CouponCreateResponse extends Coupon {
279
+ validationWarnings?: CouponValidationWarning[];
280
+ }
281
+ /**
282
+ * Platform capability information for coupon features.
283
+ * Use this to understand what features each platform supports.
284
+ */
285
+ interface PlatformCouponCapabilities {
286
+ supportsProducts: boolean;
287
+ supportsProductExclusions: boolean;
288
+ supportsCategories: boolean;
289
+ supportsCategoryExclusions: boolean;
290
+ maxProducts?: number | null;
291
+ notes: string[];
292
+ }
293
+ /**
294
+ * Helper function to check if a coupon applies to a specific product.
295
+ * Use this in your custom platform to implement coupon validation.
296
+ *
297
+ * Validation Order:
298
+ * 1. Check if product is in excludedProducts → REJECT
299
+ * 2. Check if product's category is in excludedCategories → REJECT
300
+ * 3. If applicableProducts is set → product MUST be in list
301
+ * 4. If applicableCategories is set → product MUST be in one of the categories
302
+ * 5. If no targeting rules → APPLY to all products
303
+ *
304
+ * @param coupon - The coupon to check
305
+ * @param productId - The product ID to validate
306
+ * @param productCategoryIds - Array of category IDs the product belongs to
307
+ * @returns true if the coupon applies to this product
308
+ *
309
+ * @example
310
+ * ```typescript
311
+ * const coupon = await omni.getCoupon('coupon_123');
312
+ * const product = await omni.getProduct('prod_456');
313
+ *
314
+ * if (isCouponApplicableToProduct(coupon, product.id, product.categories || [])) {
315
+ * // Apply discount
316
+ * }
317
+ * ```
318
+ */
319
+ declare function isCouponApplicableToProduct(coupon: Pick<Coupon, 'applicableProducts' | 'excludedProducts' | 'applicableCategories' | 'excludedCategories'>, productId: string, productCategoryIds: string[]): boolean;
320
+ interface Customer {
321
+ id: string;
322
+ email: string;
323
+ firstName?: string;
324
+ lastName?: string;
325
+ phone?: string;
326
+ hasAccount: boolean;
327
+ emailVerified: boolean;
328
+ acceptsMarketing: boolean;
329
+ tags: string[];
330
+ totalOrders: number;
331
+ lastOrderAt?: string;
332
+ metadata?: Record<string, unknown>;
333
+ shopifyCustomerId?: string;
334
+ woocommerceCustomerId?: string;
335
+ tiktokCustomerId?: string;
336
+ addresses: CustomerAddress[];
337
+ createdAt: string;
338
+ updatedAt: string;
339
+ }
340
+ interface CustomerAddress {
341
+ id: string;
342
+ label?: string;
343
+ firstName: string;
344
+ lastName: string;
345
+ company?: string;
346
+ line1: string;
347
+ line2?: string;
348
+ city: string;
349
+ region?: string;
350
+ postalCode: string;
351
+ country: string;
352
+ phone?: string;
353
+ isDefault: boolean;
354
+ createdAt: string;
355
+ updatedAt: string;
356
+ }
357
+ interface CreateCustomerDto {
358
+ email: string;
359
+ phone?: string;
360
+ firstName?: string;
361
+ lastName?: string;
362
+ password?: string;
363
+ acceptsMarketing?: boolean;
364
+ tags?: string[];
365
+ metadata?: Record<string, unknown>;
366
+ }
367
+ interface UpdateCustomerDto {
368
+ email?: string;
369
+ phone?: string;
370
+ firstName?: string;
371
+ lastName?: string;
372
+ acceptsMarketing?: boolean;
373
+ tags?: string[];
374
+ metadata?: Record<string, unknown>;
375
+ }
376
+ interface CreateAddressDto {
377
+ label?: string;
378
+ firstName: string;
379
+ lastName: string;
380
+ company?: string;
381
+ line1: string;
382
+ line2?: string;
383
+ city: string;
384
+ region?: string;
385
+ postalCode: string;
386
+ country: string;
387
+ phone?: string;
388
+ isDefault?: boolean;
389
+ }
390
+ interface UpdateAddressDto {
391
+ label?: string;
392
+ firstName?: string;
393
+ lastName?: string;
394
+ company?: string;
395
+ line1?: string;
396
+ line2?: string;
397
+ city?: string;
398
+ region?: string;
399
+ postalCode?: string;
400
+ country?: string;
401
+ phone?: string;
402
+ isDefault?: boolean;
403
+ }
404
+ interface CustomerAuthResponse {
405
+ customer: {
406
+ id: string;
407
+ email: string;
408
+ firstName?: string;
409
+ lastName?: string;
410
+ phone?: string;
411
+ emailVerified: boolean;
412
+ };
413
+ token: string;
414
+ expiresAt: string;
415
+ }
416
+ interface RegisterCustomerDto {
417
+ email: string;
418
+ password: string;
419
+ firstName?: string;
420
+ lastName?: string;
421
+ phone?: string;
422
+ }
423
+ type CartStatus = 'ACTIVE' | 'MERGED' | 'CONVERTED' | 'ABANDONED';
424
+ interface CartItem {
425
+ id: string;
426
+ productId: string;
427
+ variantId?: string | null;
428
+ quantity: number;
429
+ unitPrice: string;
430
+ discountAmount: string;
431
+ notes?: string | null;
432
+ metadata?: Record<string, unknown> | null;
433
+ product: {
434
+ id: string;
435
+ name: string;
436
+ sku: string;
437
+ images?: unknown[];
438
+ };
439
+ variant?: {
440
+ id: string;
441
+ name?: string | null;
442
+ sku?: string | null;
443
+ image?: unknown;
444
+ } | null;
445
+ createdAt: string;
446
+ updatedAt: string;
447
+ }
448
+ interface Cart {
449
+ id: string;
450
+ sessionToken?: string | null;
451
+ customerId?: string | null;
452
+ status: CartStatus;
453
+ currency: string;
454
+ notes?: string | null;
455
+ subtotal: string;
456
+ discountAmount: string;
457
+ couponCode?: string | null;
458
+ items: CartItem[];
459
+ itemCount: number;
460
+ expiresAt?: string | null;
461
+ createdAt: string;
462
+ updatedAt: string;
463
+ }
464
+ interface AddToCartDto {
465
+ productId: string;
466
+ variantId?: string;
467
+ quantity: number;
468
+ notes?: string;
469
+ metadata?: Record<string, unknown>;
470
+ }
471
+ interface UpdateCartItemDto {
472
+ quantity: number;
473
+ }
474
+ interface MergeCartsDto {
475
+ sourceSessionToken: string;
476
+ targetCustomerId: string;
477
+ }
478
+ type CheckoutStatus = 'PENDING' | 'SHIPPING_SET' | 'PAYMENT_PENDING' | 'PAYMENT_PROCESSING' | 'COMPLETED' | 'FAILED' | 'EXPIRED';
479
+ interface CheckoutAddress {
480
+ firstName: string;
481
+ lastName: string;
482
+ company?: string | null;
483
+ line1: string;
484
+ line2?: string | null;
485
+ city: string;
486
+ region?: string | null;
487
+ postalCode: string;
488
+ country: string;
489
+ phone?: string | null;
490
+ }
491
+ interface CheckoutLineItem {
492
+ id: string;
493
+ productId: string;
494
+ variantId?: string | null;
495
+ quantity: number;
496
+ unitPrice: string;
497
+ discountAmount: string;
498
+ product: {
499
+ id: string;
500
+ name: string;
501
+ sku: string;
502
+ images?: unknown[];
503
+ };
504
+ variant?: {
505
+ id: string;
506
+ name?: string | null;
507
+ sku?: string | null;
508
+ } | null;
509
+ }
510
+ interface ShippingRate {
511
+ id: string;
512
+ name: string;
513
+ description?: string | null;
514
+ price: string;
515
+ currency: string;
516
+ estimatedDays?: number | null;
517
+ }
518
+ interface Checkout {
519
+ id: string;
520
+ status: CheckoutStatus;
521
+ email?: string | null;
522
+ customerId?: string | null;
523
+ shippingAddress?: CheckoutAddress | null;
524
+ billingAddress?: CheckoutAddress | null;
525
+ shippingRateId?: string | null;
526
+ shippingMethod?: ShippingRate | null;
527
+ currency: string;
528
+ subtotal: string;
529
+ discountAmount: string;
530
+ shippingAmount: string;
531
+ taxAmount: string;
532
+ total: string;
533
+ couponCode?: string | null;
534
+ items: CheckoutLineItem[];
535
+ itemCount: number;
536
+ availableShippingRates?: ShippingRate[];
537
+ expiresAt?: string | null;
538
+ createdAt: string;
539
+ updatedAt: string;
540
+ }
541
+ interface CreateCheckoutDto {
542
+ cartId: string;
543
+ customerId?: string;
544
+ }
545
+ interface SetCheckoutCustomerDto {
546
+ email: string;
547
+ firstName?: string;
548
+ lastName?: string;
549
+ phone?: string;
550
+ acceptsMarketing?: boolean;
551
+ }
552
+ interface SetShippingAddressDto {
553
+ firstName: string;
554
+ lastName: string;
555
+ company?: string;
556
+ line1: string;
557
+ line2?: string;
558
+ city: string;
559
+ region?: string;
560
+ postalCode: string;
561
+ country: string;
562
+ phone?: string;
563
+ }
564
+ interface SetBillingAddressDto extends SetShippingAddressDto {
565
+ sameAsShipping?: boolean;
566
+ }
567
+ interface SetShippingAddressResponse {
568
+ checkout: Checkout;
569
+ rates: ShippingRate[];
570
+ }
571
+ interface CompleteCheckoutResponse {
572
+ orderId: string;
573
+ }
574
+ interface WebhookEvent {
575
+ event: WebhookEventType;
576
+ storeId: string;
577
+ entityId: string;
578
+ platform: string;
579
+ data: unknown;
580
+ timestamp: string;
581
+ }
582
+ 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';
583
+ interface OmniSyncApiError {
584
+ statusCode: number;
585
+ message: string;
586
+ error?: string;
587
+ details?: unknown;
588
+ }
589
+
590
+ /**
591
+ * OmniSyncClient - SDK for integrating vibe coding stores with Omni-Sync Platform
592
+ *
593
+ * @example
594
+ * ```typescript
595
+ * const omni = new OmniSyncClient({
596
+ * apiKey: process.env.OMNI_SYNC_API_KEY!,
597
+ * });
598
+ *
599
+ * // Get products
600
+ * const products = await omni.getProducts();
601
+ *
602
+ * // Create an order
603
+ * const order = await omni.createOrder({
604
+ * items: [{ productId: 'prod_123', quantity: 2, price: 99.99 }],
605
+ * customer: { email: 'customer@example.com', name: 'John Doe' },
606
+ * totalAmount: 199.98,
607
+ * });
608
+ * ```
609
+ */
610
+ declare class OmniSyncClient {
611
+ private readonly apiKey;
612
+ private readonly baseUrl;
613
+ private readonly timeout;
614
+ constructor(options: OmniSyncClientOptions);
615
+ private request;
616
+ /**
617
+ * Get a list of products with pagination
618
+ */
619
+ getProducts(params?: ProductQueryParams): Promise<PaginatedResponse<Product>>;
620
+ /**
621
+ * Get a single product by ID
622
+ */
623
+ getProduct(productId: string): Promise<Product>;
624
+ /**
625
+ * Create a new product
626
+ */
627
+ createProduct(data: CreateProductDto): Promise<Product>;
628
+ /**
629
+ * Update an existing product
630
+ */
631
+ updateProduct(productId: string, data: UpdateProductDto): Promise<Product>;
632
+ /**
633
+ * Delete a product
634
+ */
635
+ deleteProduct(productId: string): Promise<void>;
636
+ /**
637
+ * Get a list of orders with pagination
638
+ */
639
+ getOrders(params?: OrderQueryParams): Promise<PaginatedResponse<Order>>;
640
+ /**
641
+ * Get a single order by ID
642
+ */
643
+ getOrder(orderId: string): Promise<Order>;
644
+ /**
645
+ * Create a new order
646
+ * This will automatically deduct inventory and sync to connected platforms
647
+ */
648
+ createOrder(data: CreateOrderDto): Promise<Order>;
649
+ /**
650
+ * Update an order (e.g., change status)
651
+ */
652
+ updateOrder(orderId: string, data: UpdateOrderDto): Promise<Order>;
653
+ /**
654
+ * Update inventory for a product
655
+ * This will sync inventory to all connected platforms
656
+ */
657
+ updateInventory(productId: string, data: UpdateInventoryDto): Promise<void>;
658
+ /**
659
+ * Get current inventory for a product
660
+ */
661
+ getInventory(productId: string): Promise<{
662
+ available: number;
663
+ reserved: number;
664
+ total: number;
665
+ }>;
666
+ /**
667
+ * Trigger a sync to a specific platform or all platforms
668
+ */
669
+ triggerSync(platform?: ConnectorPlatform): Promise<SyncJob>;
670
+ /**
671
+ * Get the status of a sync job
672
+ */
673
+ 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
+ /**
685
+ * Get a list of coupons with pagination
686
+ */
687
+ getCoupons(params?: CouponQueryParams): Promise<PaginatedResponse<Coupon>>;
688
+ /**
689
+ * Get a single coupon by ID
690
+ */
691
+ getCoupon(couponId: string): Promise<Coupon>;
692
+ /**
693
+ * Create a new coupon.
694
+ * Returns validation warnings if syncing to platforms that don't support certain features.
695
+ *
696
+ * @example
697
+ * ```typescript
698
+ * const coupon = await omni.createCoupon({
699
+ * code: 'SUMMER20',
700
+ * type: 'PERCENTAGE',
701
+ * value: 20,
702
+ * applicableCategories: ['cat_electronics'],
703
+ * excludedProducts: ['prod_clearance_item'],
704
+ * platforms: ['WOOCOMMERCE', 'SHOPIFY'],
705
+ * });
706
+ *
707
+ * // Check for platform limitations
708
+ * if (coupon.validationWarnings?.length) {
709
+ * console.warn('Some features not supported:', coupon.validationWarnings);
710
+ * }
711
+ * ```
712
+ */
713
+ createCoupon(data: CreateCouponDto): Promise<CouponCreateResponse>;
714
+ /**
715
+ * Update an existing coupon
716
+ */
717
+ updateCoupon(couponId: string, data: UpdateCouponDto): Promise<Coupon>;
718
+ /**
719
+ * Delete a coupon
720
+ */
721
+ deleteCoupon(couponId: string): Promise<void>;
722
+ /**
723
+ * Sync a coupon to all connected platforms.
724
+ * Returns a sync job that can be tracked with getSyncStatus().
725
+ */
726
+ syncCoupon(couponId: string): Promise<SyncJob>;
727
+ /**
728
+ * Publish a coupon to specific platforms.
729
+ * Use this for selective syncing instead of syncing to all platforms.
730
+ *
731
+ * @example
732
+ * ```typescript
733
+ * // Only sync to WooCommerce and Shopify
734
+ * await omni.publishCoupon('coupon_123', ['WOOCOMMERCE', 'SHOPIFY']);
735
+ * ```
736
+ */
737
+ publishCoupon(couponId: string, platforms: ConnectorPlatform[]): Promise<SyncJob>;
738
+ /**
739
+ * Get platform capabilities for coupon features.
740
+ * Use this to understand what features each platform supports.
741
+ *
742
+ * @example
743
+ * ```typescript
744
+ * const capabilities = await omni.getCouponPlatformCapabilities();
745
+ * if (!capabilities.SHOPIFY.supportsProductExclusions) {
746
+ * console.log('Shopify does not support product exclusions');
747
+ * }
748
+ * ```
749
+ */
750
+ getCouponPlatformCapabilities(): Promise<Record<string, PlatformCouponCapabilities>>;
751
+ /**
752
+ * Create a new customer
753
+ *
754
+ * @example
755
+ * ```typescript
756
+ * const customer = await omni.createCustomer({
757
+ * email: 'customer@example.com',
758
+ * firstName: 'John',
759
+ * lastName: 'Doe',
760
+ * acceptsMarketing: true,
761
+ * });
762
+ * ```
763
+ */
764
+ createCustomer(data: CreateCustomerDto): Promise<Customer>;
765
+ /**
766
+ * Get a customer by ID
767
+ */
768
+ getCustomer(customerId: string): Promise<Customer>;
769
+ /**
770
+ * Update a customer
771
+ */
772
+ updateCustomer(customerId: string, data: UpdateCustomerDto): Promise<Customer>;
773
+ /**
774
+ * Get a customer by email
775
+ */
776
+ getCustomerByEmail(email: string): Promise<Customer | null>;
777
+ /**
778
+ * Login an existing customer (returns JWT token)
779
+ *
780
+ * @example
781
+ * ```typescript
782
+ * const auth = await omni.loginCustomer('customer@example.com', 'password123');
783
+ * console.log('Customer logged in:', auth.customer.email);
784
+ * // Store auth.token for subsequent authenticated requests
785
+ * ```
786
+ */
787
+ loginCustomer(email: string, password: string): Promise<CustomerAuthResponse>;
788
+ /**
789
+ * Register a new customer with password (creates account)
790
+ *
791
+ * @example
792
+ * ```typescript
793
+ * const auth = await omni.registerCustomer({
794
+ * email: 'newcustomer@example.com',
795
+ * password: 'securepassword123',
796
+ * firstName: 'Jane',
797
+ * lastName: 'Doe',
798
+ * });
799
+ * ```
800
+ */
801
+ registerCustomer(data: RegisterCustomerDto): Promise<CustomerAuthResponse>;
802
+ /**
803
+ * Request a password reset email for a customer
804
+ */
805
+ forgotPassword(email: string): Promise<{
806
+ message: string;
807
+ }>;
808
+ /**
809
+ * Get all addresses for a customer
810
+ */
811
+ getCustomerAddresses(customerId: string): Promise<CustomerAddress[]>;
812
+ /**
813
+ * Add an address to a customer
814
+ *
815
+ * @example
816
+ * ```typescript
817
+ * const address = await omni.addCustomerAddress('cust_123', {
818
+ * firstName: 'John',
819
+ * lastName: 'Doe',
820
+ * line1: '123 Main St',
821
+ * city: 'New York',
822
+ * region: 'NY',
823
+ * postalCode: '10001',
824
+ * country: 'US',
825
+ * isDefault: true,
826
+ * });
827
+ * ```
828
+ */
829
+ addCustomerAddress(customerId: string, address: CreateAddressDto): Promise<CustomerAddress>;
830
+ /**
831
+ * Update a customer address
832
+ */
833
+ updateCustomerAddress(customerId: string, addressId: string, address: UpdateAddressDto): Promise<CustomerAddress>;
834
+ /**
835
+ * Delete a customer address
836
+ */
837
+ deleteCustomerAddress(customerId: string, addressId: string): Promise<void>;
838
+ /**
839
+ * Get orders for a customer
840
+ *
841
+ * @example
842
+ * ```typescript
843
+ * const orders = await omni.getCustomerOrders('cust_123', { page: 1, limit: 10 });
844
+ * console.log(`Customer has ${orders.meta.total} total orders`);
845
+ * ```
846
+ */
847
+ getCustomerOrders(customerId: string, params?: {
848
+ page?: number;
849
+ limit?: number;
850
+ }): Promise<PaginatedResponse<Order>>;
851
+ /**
852
+ * Create a new cart for a guest user
853
+ * Returns a cart with a sessionToken that identifies this cart
854
+ *
855
+ * @example
856
+ * ```typescript
857
+ * const cart = await omni.createCart();
858
+ * console.log('Cart session:', cart.sessionToken);
859
+ * // Store sessionToken in localStorage or cookie
860
+ * ```
861
+ */
862
+ createCart(): Promise<Cart>;
863
+ /**
864
+ * Get a cart by session token (for guest users)
865
+ *
866
+ * @example
867
+ * ```typescript
868
+ * const cart = await omni.getCartBySession('sess_abc123');
869
+ * console.log('Items in cart:', cart.itemCount);
870
+ * ```
871
+ */
872
+ getCartBySession(sessionToken: string): Promise<Cart>;
873
+ /**
874
+ * Get a cart by customer ID (for authenticated users)
875
+ *
876
+ * @example
877
+ * ```typescript
878
+ * const cart = await omni.getCartByCustomer('cust_123');
879
+ * console.log('Customer cart total:', cart.subtotal);
880
+ * ```
881
+ */
882
+ getCartByCustomer(customerId: string): Promise<Cart>;
883
+ /**
884
+ * Get a cart by ID
885
+ */
886
+ getCart(cartId: string): Promise<Cart>;
887
+ /**
888
+ * Add an item to the cart
889
+ *
890
+ * @example
891
+ * ```typescript
892
+ * const cart = await omni.addToCart('cart_123', {
893
+ * productId: 'prod_abc',
894
+ * quantity: 2,
895
+ * notes: 'Gift wrap please',
896
+ * });
897
+ * ```
898
+ */
899
+ addToCart(cartId: string, item: AddToCartDto): Promise<Cart>;
900
+ /**
901
+ * Update an item quantity in the cart
902
+ *
903
+ * @example
904
+ * ```typescript
905
+ * const cart = await omni.updateCartItem('cart_123', 'item_456', { quantity: 3 });
906
+ * ```
907
+ */
908
+ updateCartItem(cartId: string, itemId: string, data: UpdateCartItemDto): Promise<Cart>;
909
+ /**
910
+ * Remove an item from the cart
911
+ *
912
+ * @example
913
+ * ```typescript
914
+ * const cart = await omni.removeCartItem('cart_123', 'item_456');
915
+ * ```
916
+ */
917
+ removeCartItem(cartId: string, itemId: string): Promise<Cart>;
918
+ /**
919
+ * Clear all items from the cart
920
+ *
921
+ * @example
922
+ * ```typescript
923
+ * await omni.clearCart('cart_123');
924
+ * ```
925
+ */
926
+ clearCart(cartId: string): Promise<void>;
927
+ /**
928
+ * Apply a coupon to the cart
929
+ *
930
+ * @example
931
+ * ```typescript
932
+ * const cart = await omni.applyCoupon('cart_123', 'SAVE20');
933
+ * console.log('Discount:', cart.discountAmount);
934
+ * ```
935
+ */
936
+ applyCoupon(cartId: string, code: string): Promise<Cart>;
937
+ /**
938
+ * Remove a coupon from the cart
939
+ *
940
+ * @example
941
+ * ```typescript
942
+ * const cart = await omni.removeCoupon('cart_123');
943
+ * ```
944
+ */
945
+ removeCoupon(cartId: string): Promise<Cart>;
946
+ /**
947
+ * Merge a guest cart into a customer's cart (after login)
948
+ * The guest cart items are moved to the customer's cart
949
+ *
950
+ * @example
951
+ * ```typescript
952
+ * // After customer logs in, merge their guest cart
953
+ * const mergedCart = await omni.mergeCarts({
954
+ * sourceSessionToken: 'sess_guest_abc',
955
+ * targetCustomerId: 'cust_123',
956
+ * });
957
+ * ```
958
+ */
959
+ mergeCarts(data: MergeCartsDto): Promise<Cart>;
960
+ /**
961
+ * Create a checkout from a cart
962
+ * Starts the checkout process and returns checkout with available options
963
+ *
964
+ * @example
965
+ * ```typescript
966
+ * const checkout = await omni.createCheckout({ cartId: 'cart_123' });
967
+ * console.log('Checkout created:', checkout.id);
968
+ * ```
969
+ */
970
+ createCheckout(data: CreateCheckoutDto): Promise<Checkout>;
971
+ /**
972
+ * Get a checkout by ID
973
+ *
974
+ * @example
975
+ * ```typescript
976
+ * const checkout = await omni.getCheckout('checkout_123');
977
+ * console.log('Status:', checkout.status);
978
+ * ```
979
+ */
980
+ getCheckout(checkoutId: string): Promise<Checkout>;
981
+ /**
982
+ * Set customer information on checkout
983
+ *
984
+ * @example
985
+ * ```typescript
986
+ * const checkout = await omni.setCheckoutCustomer('checkout_123', {
987
+ * email: 'customer@example.com',
988
+ * firstName: 'John',
989
+ * lastName: 'Doe',
990
+ * });
991
+ * ```
992
+ */
993
+ setCheckoutCustomer(checkoutId: string, data: SetCheckoutCustomerDto): Promise<Checkout>;
994
+ /**
995
+ * Set shipping address on checkout
996
+ * Returns the checkout and available shipping rates for the address
997
+ *
998
+ * @example
999
+ * ```typescript
1000
+ * const { checkout, rates } = await omni.setShippingAddress('checkout_123', {
1001
+ * firstName: 'John',
1002
+ * lastName: 'Doe',
1003
+ * line1: '123 Main St',
1004
+ * city: 'New York',
1005
+ * region: 'NY',
1006
+ * postalCode: '10001',
1007
+ * country: 'US',
1008
+ * });
1009
+ * console.log('Available rates:', rates);
1010
+ * ```
1011
+ */
1012
+ setShippingAddress(checkoutId: string, address: SetShippingAddressDto): Promise<SetShippingAddressResponse>;
1013
+ /**
1014
+ * Get available shipping rates for a checkout
1015
+ * Requires shipping address to be set first
1016
+ *
1017
+ * @example
1018
+ * ```typescript
1019
+ * const rates = await omni.getShippingRates('checkout_123');
1020
+ * console.log('Shipping options:', rates);
1021
+ * ```
1022
+ */
1023
+ getShippingRates(checkoutId: string): Promise<ShippingRate[]>;
1024
+ /**
1025
+ * Select a shipping method for checkout
1026
+ *
1027
+ * @example
1028
+ * ```typescript
1029
+ * const checkout = await omni.selectShippingMethod('checkout_123', 'rate_express');
1030
+ * console.log('Shipping cost:', checkout.shippingAmount);
1031
+ * ```
1032
+ */
1033
+ selectShippingMethod(checkoutId: string, shippingRateId: string): Promise<Checkout>;
1034
+ /**
1035
+ * Set billing address on checkout
1036
+ * Can optionally use shipping address as billing address
1037
+ *
1038
+ * @example
1039
+ * ```typescript
1040
+ * // Use same as shipping
1041
+ * const checkout = await omni.setBillingAddress('checkout_123', {
1042
+ * ...shippingAddress,
1043
+ * sameAsShipping: true,
1044
+ * });
1045
+ *
1046
+ * // Or set different billing address
1047
+ * const checkout = await omni.setBillingAddress('checkout_123', {
1048
+ * firstName: 'John',
1049
+ * lastName: 'Doe',
1050
+ * line1: '456 Business Ave',
1051
+ * city: 'New York',
1052
+ * region: 'NY',
1053
+ * postalCode: '10002',
1054
+ * country: 'US',
1055
+ * });
1056
+ * ```
1057
+ */
1058
+ setBillingAddress(checkoutId: string, address: SetBillingAddressDto): Promise<Checkout>;
1059
+ /**
1060
+ * Complete the checkout and create an order
1061
+ * Requires customer email, shipping address, and shipping method to be set
1062
+ *
1063
+ * @example
1064
+ * ```typescript
1065
+ * const { orderId } = await omni.completeCheckout('checkout_123');
1066
+ * console.log('Order created:', orderId);
1067
+ * ```
1068
+ */
1069
+ completeCheckout(checkoutId: string): Promise<CompleteCheckoutResponse>;
1070
+ }
1071
+ /**
1072
+ * Custom error class for Omni-Sync API errors
1073
+ */
1074
+ declare class OmniSyncError extends Error {
1075
+ readonly statusCode: number;
1076
+ readonly details?: unknown;
1077
+ constructor(message: string, statusCode: number, details?: unknown);
1078
+ }
1079
+
1080
+ /**
1081
+ * Verify a webhook signature from Omni-Sync
1082
+ *
1083
+ * @param payload - The raw webhook payload (as string or object)
1084
+ * @param signature - The X-Omni-Signature header value
1085
+ * @param secret - Your webhook secret
1086
+ * @returns true if the signature is valid
1087
+ *
1088
+ * @example
1089
+ * ```typescript
1090
+ * import { verifyWebhook } from '@omni-sync/sdk';
1091
+ *
1092
+ * app.post('/webhooks/omni-sync', async (req, res) => {
1093
+ * const signature = req.headers['x-omni-signature'];
1094
+ * const isValid = verifyWebhook(req.body, signature, process.env.WEBHOOK_SECRET);
1095
+ *
1096
+ * if (!isValid) {
1097
+ * return res.status(401).send('Invalid signature');
1098
+ * }
1099
+ *
1100
+ * // Process webhook...
1101
+ * });
1102
+ * ```
1103
+ */
1104
+ declare function verifyWebhook(payload: string | object, signature: string | undefined | null, secret: string): boolean;
1105
+ /**
1106
+ * Parse a webhook payload into a typed WebhookEvent
1107
+ *
1108
+ * @param payload - The raw webhook payload
1109
+ * @returns Typed WebhookEvent object
1110
+ */
1111
+ declare function parseWebhookEvent(payload: unknown): WebhookEvent;
1112
+ /**
1113
+ * Type guard for checking webhook event type
1114
+ */
1115
+ declare function isWebhookEventType(event: WebhookEvent, type: WebhookEventType): boolean;
1116
+ /**
1117
+ * Create a webhook handler with typed event handlers
1118
+ *
1119
+ * @example
1120
+ * ```typescript
1121
+ * const handler = createWebhookHandler({
1122
+ * 'product.updated': async (event) => {
1123
+ * console.log('Product updated:', event.entityId);
1124
+ * await refreshProductCache(event.entityId);
1125
+ * },
1126
+ * 'inventory.updated': async (event) => {
1127
+ * console.log('Inventory changed for:', event.entityId);
1128
+ * },
1129
+ * });
1130
+ *
1131
+ * // In your API route
1132
+ * await handler(webhookPayload);
1133
+ * ```
1134
+ */
1135
+ declare function createWebhookHandler(handlers: Partial<Record<WebhookEventType, (event: WebhookEvent) => Promise<void>>>): (payload: unknown) => Promise<void>;
1136
+
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 };