omni-sync-sdk 0.18.3 → 0.18.5

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 CHANGED
@@ -117,6 +117,97 @@ const { data: products } = await omni.getProducts();
117
117
 
118
118
  ---
119
119
 
120
+ ## Common Mistakes to Avoid
121
+
122
+ > **AI Agents / Vibe-Coders:** Read this section carefully! These are common misunderstandings.
123
+
124
+ ### 1. All Types Are Exported - Don't Create Local Interfaces!
125
+
126
+ ```typescript
127
+ // ❌ WRONG - Don't create these locally
128
+ interface PaymentProvider { ... }
129
+ interface ProductSuggestion { ... }
130
+
131
+ // ✅ CORRECT - Import from SDK
132
+ import {
133
+ PaymentProvider, // or PaymentProviderConfig
134
+ ProductSuggestion,
135
+ CategorySuggestion,
136
+ SearchSuggestions,
137
+ } from 'omni-sync-sdk';
138
+ ```
139
+
140
+ ### 2. formatPrice Expects Options Object
141
+
142
+ ```typescript
143
+ // ❌ WRONG
144
+ formatPrice(amount, 'USD');
145
+
146
+ // ✅ CORRECT
147
+ formatPrice(amount, { currency: 'USD' });
148
+ ```
149
+
150
+ ### 3. Order Fields - Use Correct Names
151
+
152
+ ```typescript
153
+ // ❌ WRONG
154
+ order.total;
155
+ item.product.name;
156
+
157
+ // ✅ CORRECT
158
+ order.totalAmount; // or order.total (alias)
159
+ item.name; // flat, not nested
160
+ item.image; // flat, not nested
161
+ ```
162
+
163
+ ### 4. Payment Status is 'succeeded', not 'completed'
164
+
165
+ ```typescript
166
+ // ❌ WRONG
167
+ if (status.status === 'completed')
168
+
169
+ // ✅ CORRECT
170
+ if (status.status === 'succeeded')
171
+ ```
172
+
173
+ ### 5. ProductSuggestion vs Product - Different Types
174
+
175
+ `getSearchSuggestions()` returns `ProductSuggestion[]`, NOT `Product[]`.
176
+ This is intentional - suggestions are lightweight for autocomplete.
177
+
178
+ ```typescript
179
+ // ProductSuggestion has:
180
+ {
181
+ (id, name, slug, image, basePrice, salePrice, type);
182
+ }
183
+
184
+ // Product has many more fields
185
+ ```
186
+
187
+ ### 6. All Prices Are Strings - Use parseFloat()
188
+
189
+ ```typescript
190
+ // ❌ WRONG - assuming number
191
+ const total = item.price * quantity;
192
+
193
+ // ✅ CORRECT - parse first
194
+ const total = parseFloat(item.price) * quantity;
195
+
196
+ // Or use SDK helper
197
+ import { formatPrice } from 'omni-sync-sdk';
198
+ const display = formatPrice(item.price, { currency: 'USD' });
199
+ ```
200
+
201
+ ### 7. Variant Attributes Are `Record<string, string>`
202
+
203
+ ```typescript
204
+ // Accessing variant attributes:
205
+ const color = variant.attributes?.['Color']; // string
206
+ const size = variant.attributes?.['Size']; // string
207
+ ```
208
+
209
+ ---
210
+
120
211
  ## Checkout: Guest vs Logged-In Customer
121
212
 
122
213
  > **IMPORTANT:** There are TWO different checkout flows. You MUST use the correct one based on whether the customer is logged in or not.
package/dist/index.d.mts CHANGED
@@ -150,6 +150,10 @@ interface Product {
150
150
  /** Product status (active, draft, archived). Always returned by backend. */
151
151
  status: string;
152
152
  type: 'SIMPLE' | 'VARIABLE';
153
+ /**
154
+ * Whether product is downloadable/digital.
155
+ * @deprecated For read operations, check channels.WOOCOMMERCE.downloadable instead
156
+ */
153
157
  isDownloadable?: boolean;
154
158
  images?: ProductImage[];
155
159
  inventory?: InventoryInfo | null;
@@ -165,6 +169,8 @@ interface Product {
165
169
  name: string;
166
170
  }>;
167
171
  tags?: string[];
172
+ /** Array of attribute option IDs for global assignments (admin mode only) */
173
+ attributes?: string[];
168
174
  metafields?: ProductMetafield[];
169
175
  channels?: Record<string, Record<string, unknown>>;
170
176
  /** Shopify product ID (admin mode only) */
@@ -173,8 +179,8 @@ interface Product {
173
179
  woocommerceProductId?: string | null;
174
180
  /** Meta/Facebook Item Group ID (admin mode only) */
175
181
  metaItemGroupId?: string | null;
176
- /** Whether product needs sync to platforms (admin mode only) */
177
- needsSync?: boolean;
182
+ /** Whether product needs sync to platforms. Always returned by backend. */
183
+ needsSync: boolean;
178
184
  /** Last sync timestamp (admin mode only) */
179
185
  lastSyncedAt?: string | null;
180
186
  /** Menu/display order */
@@ -226,6 +232,8 @@ interface ProductImage {
226
232
  size?: number;
227
233
  /** MIME type (admin mode only) */
228
234
  mimeType?: string;
235
+ /** Creation timestamp (admin mode only) */
236
+ createdAt?: string;
229
237
  }
230
238
  interface ProductVariant {
231
239
  id: string;
@@ -238,7 +246,7 @@ interface ProductVariant {
238
246
  /** Variant sale price as string. Use parseFloat() for calculations. */
239
247
  salePrice?: string | null;
240
248
  /** Variant attributes (e.g., { "Color": "Red", "Size": "M" }) */
241
- attributes?: Record<string, unknown> | null;
249
+ attributes?: Record<string, string> | null;
242
250
  inventory?: InventoryInfo | null;
243
251
  /** Variant image URL or image object */
244
252
  image?: string | {
@@ -287,6 +295,8 @@ interface InventoryInfo {
287
295
  * false if trackingMode is DISABLED or if out of stock.
288
296
  */
289
297
  canPurchase: boolean;
298
+ /** Last inventory sync timestamp (admin mode only) */
299
+ lastInventorySyncAt?: string | null;
290
300
  }
291
301
  /**
292
302
  * Check if a product description contains HTML and should be rendered with dangerouslySetInnerHTML
@@ -672,6 +682,11 @@ interface Order {
672
682
  status: OrderStatus;
673
683
  /** Total amount as string (e.g., "99.99"). Use parseFloat() for calculations. */
674
684
  totalAmount: string;
685
+ /**
686
+ * Alias for totalAmount. Use parseFloat() for calculations.
687
+ * @example order.total || order.totalAmount
688
+ */
689
+ total?: string;
675
690
  /** Currency code (e.g., "USD", "ILS") */
676
691
  currency?: string;
677
692
  /** Customer info (may be null for guest orders) */
@@ -712,13 +727,15 @@ interface OrderItem {
712
727
  productId: string;
713
728
  variantId?: string;
714
729
  sku?: string;
730
+ /** Product name (flat, not nested under product object) */
715
731
  name?: string;
716
732
  quantity: number;
717
- /** Price per unit as number */
718
- price: number;
719
- /** Unit price as string (for consistency with Cart/Checkout) */
720
- unitPrice?: string;
721
- /** Product image URL */
733
+ /**
734
+ * Price per unit as string (e.g., "29.99").
735
+ * Use parseFloat() for calculations.
736
+ */
737
+ price: string;
738
+ /** Product image URL (flat, not nested under product object) */
722
739
  image?: string;
723
740
  }
724
741
  interface OrderQueryParams {
@@ -1794,7 +1811,7 @@ type VariantStatus = 'active' | 'draft';
1794
1811
  interface CreateVariantDto {
1795
1812
  sku?: string;
1796
1813
  name?: string;
1797
- attributes?: Record<string, unknown>;
1814
+ attributes?: Record<string, string>;
1798
1815
  price?: number;
1799
1816
  salePrice?: number;
1800
1817
  inventory?: number;
@@ -1805,7 +1822,7 @@ interface CreateVariantDto {
1805
1822
  interface UpdateVariantDto {
1806
1823
  sku?: string;
1807
1824
  name?: string;
1808
- attributes?: Record<string, unknown>;
1825
+ attributes?: Record<string, string>;
1809
1826
  price?: number;
1810
1827
  salePrice?: number;
1811
1828
  image?: string | unknown;
package/dist/index.d.ts CHANGED
@@ -150,6 +150,10 @@ interface Product {
150
150
  /** Product status (active, draft, archived). Always returned by backend. */
151
151
  status: string;
152
152
  type: 'SIMPLE' | 'VARIABLE';
153
+ /**
154
+ * Whether product is downloadable/digital.
155
+ * @deprecated For read operations, check channels.WOOCOMMERCE.downloadable instead
156
+ */
153
157
  isDownloadable?: boolean;
154
158
  images?: ProductImage[];
155
159
  inventory?: InventoryInfo | null;
@@ -165,6 +169,8 @@ interface Product {
165
169
  name: string;
166
170
  }>;
167
171
  tags?: string[];
172
+ /** Array of attribute option IDs for global assignments (admin mode only) */
173
+ attributes?: string[];
168
174
  metafields?: ProductMetafield[];
169
175
  channels?: Record<string, Record<string, unknown>>;
170
176
  /** Shopify product ID (admin mode only) */
@@ -173,8 +179,8 @@ interface Product {
173
179
  woocommerceProductId?: string | null;
174
180
  /** Meta/Facebook Item Group ID (admin mode only) */
175
181
  metaItemGroupId?: string | null;
176
- /** Whether product needs sync to platforms (admin mode only) */
177
- needsSync?: boolean;
182
+ /** Whether product needs sync to platforms. Always returned by backend. */
183
+ needsSync: boolean;
178
184
  /** Last sync timestamp (admin mode only) */
179
185
  lastSyncedAt?: string | null;
180
186
  /** Menu/display order */
@@ -226,6 +232,8 @@ interface ProductImage {
226
232
  size?: number;
227
233
  /** MIME type (admin mode only) */
228
234
  mimeType?: string;
235
+ /** Creation timestamp (admin mode only) */
236
+ createdAt?: string;
229
237
  }
230
238
  interface ProductVariant {
231
239
  id: string;
@@ -238,7 +246,7 @@ interface ProductVariant {
238
246
  /** Variant sale price as string. Use parseFloat() for calculations. */
239
247
  salePrice?: string | null;
240
248
  /** Variant attributes (e.g., { "Color": "Red", "Size": "M" }) */
241
- attributes?: Record<string, unknown> | null;
249
+ attributes?: Record<string, string> | null;
242
250
  inventory?: InventoryInfo | null;
243
251
  /** Variant image URL or image object */
244
252
  image?: string | {
@@ -287,6 +295,8 @@ interface InventoryInfo {
287
295
  * false if trackingMode is DISABLED or if out of stock.
288
296
  */
289
297
  canPurchase: boolean;
298
+ /** Last inventory sync timestamp (admin mode only) */
299
+ lastInventorySyncAt?: string | null;
290
300
  }
291
301
  /**
292
302
  * Check if a product description contains HTML and should be rendered with dangerouslySetInnerHTML
@@ -672,6 +682,11 @@ interface Order {
672
682
  status: OrderStatus;
673
683
  /** Total amount as string (e.g., "99.99"). Use parseFloat() for calculations. */
674
684
  totalAmount: string;
685
+ /**
686
+ * Alias for totalAmount. Use parseFloat() for calculations.
687
+ * @example order.total || order.totalAmount
688
+ */
689
+ total?: string;
675
690
  /** Currency code (e.g., "USD", "ILS") */
676
691
  currency?: string;
677
692
  /** Customer info (may be null for guest orders) */
@@ -712,13 +727,15 @@ interface OrderItem {
712
727
  productId: string;
713
728
  variantId?: string;
714
729
  sku?: string;
730
+ /** Product name (flat, not nested under product object) */
715
731
  name?: string;
716
732
  quantity: number;
717
- /** Price per unit as number */
718
- price: number;
719
- /** Unit price as string (for consistency with Cart/Checkout) */
720
- unitPrice?: string;
721
- /** Product image URL */
733
+ /**
734
+ * Price per unit as string (e.g., "29.99").
735
+ * Use parseFloat() for calculations.
736
+ */
737
+ price: string;
738
+ /** Product image URL (flat, not nested under product object) */
722
739
  image?: string;
723
740
  }
724
741
  interface OrderQueryParams {
@@ -1794,7 +1811,7 @@ type VariantStatus = 'active' | 'draft';
1794
1811
  interface CreateVariantDto {
1795
1812
  sku?: string;
1796
1813
  name?: string;
1797
- attributes?: Record<string, unknown>;
1814
+ attributes?: Record<string, string>;
1798
1815
  price?: number;
1799
1816
  salePrice?: number;
1800
1817
  inventory?: number;
@@ -1805,7 +1822,7 @@ interface CreateVariantDto {
1805
1822
  interface UpdateVariantDto {
1806
1823
  sku?: string;
1807
1824
  name?: string;
1808
- attributes?: Record<string, unknown>;
1825
+ attributes?: Record<string, string>;
1809
1826
  price?: number;
1810
1827
  salePrice?: number;
1811
1828
  image?: string | unknown;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omni-sync-sdk",
3
- "version": "0.18.3",
3
+ "version": "0.18.5",
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",