omni-sync-sdk 0.12.1 → 0.13.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/LICENSE ADDED
File without changes
package/dist/index.d.mts CHANGED
@@ -52,6 +52,26 @@ interface StoreInfo {
52
52
  name: string;
53
53
  currency: string;
54
54
  language: string;
55
+ /** Connection ID (vibe-coded mode only) */
56
+ connectionId?: string;
57
+ /** Store name (vibe-coded mode only - same as name) */
58
+ storeName?: string;
59
+ /** Connection status (vibe-coded mode only) */
60
+ status?: string;
61
+ /** Allowed API scopes (vibe-coded mode only) */
62
+ allowedScopes?: string[];
63
+ /** Whether orders can be created (vibe-coded mode only) */
64
+ ordersWriteEnabled?: boolean;
65
+ /** Whether guest checkout is tracked (vibe-coded mode only) */
66
+ guestCheckoutTracking?: boolean;
67
+ /**
68
+ * Whether new customer registrations require email verification.
69
+ * If true, your site MUST implement an email verification flow:
70
+ * 1. After registerCustomer(), check if response.requiresVerification is true
71
+ * 2. Show a verification code input to the user
72
+ * 3. Call verifyEmail(code) with the code they received via email
73
+ */
74
+ requireEmailVerification?: boolean;
55
75
  }
56
76
  interface CustomerProfile {
57
77
  id: string;
@@ -109,18 +129,61 @@ interface ProductVariant {
109
129
  }
110
130
  interface InventoryInfo {
111
131
  total: number;
112
- reserved: number;
132
+ reserved?: number;
113
133
  available: number;
134
+ /**
135
+ * Whether the item is in stock (available > 0)
136
+ * Always present in vibe-coded API responses
137
+ */
138
+ inStock?: boolean;
114
139
  }
140
+ /**
141
+ * Get a human-readable stock status string
142
+ * @param inventory - The inventory info object
143
+ * @param options - Optional configuration for the status text
144
+ * @returns A string like "In Stock", "Out of Stock", or "Low Stock"
145
+ *
146
+ * @example
147
+ * ```typescript
148
+ * const product = await omni.getProduct('prod_123');
149
+ * const status = getStockStatus(product.inventory);
150
+ * // Returns "In Stock" or "Out of Stock"
151
+ *
152
+ * // With custom threshold:
153
+ * const status = getStockStatus(product.inventory, { lowStockThreshold: 5 });
154
+ * // Returns "Low Stock" if available <= 5
155
+ * ```
156
+ */
157
+ declare function getStockStatus(inventory: InventoryInfo | null | undefined, options?: {
158
+ /** Threshold for "Low Stock" status. Set to 0 to disable. Default: 0 (disabled) */
159
+ lowStockThreshold?: number;
160
+ /** Custom text for in stock. Default: "In Stock" */
161
+ inStockText?: string;
162
+ /** Custom text for out of stock. Default: "Out of Stock" */
163
+ outOfStockText?: string;
164
+ /** Custom text for low stock. Default: "Low Stock" */
165
+ lowStockText?: string;
166
+ }): string;
115
167
  interface ProductQueryParams {
116
168
  page?: number;
117
169
  limit?: number;
118
170
  search?: string;
119
171
  status?: 'active' | 'draft' | 'archived';
172
+ /** Filter by category IDs (comma-separated or array) */
173
+ categories?: string | string[];
174
+ /** Filter by brand IDs (comma-separated or array) */
175
+ brands?: string | string[];
176
+ /** Filter by tag IDs (comma-separated or array) */
177
+ tags?: string | string[];
178
+ /** Minimum price filter */
179
+ minPrice?: number;
180
+ /** Maximum price filter */
181
+ maxPrice?: number;
182
+ /** Sort by field (default: menuOrder) */
183
+ sortBy?: 'name' | 'price' | 'createdAt';
184
+ sortOrder?: 'asc' | 'desc';
120
185
  type?: 'SIMPLE' | 'VARIABLE';
121
186
  isDownloadable?: boolean;
122
- sortBy?: 'name' | 'createdAt' | 'updatedAt' | 'basePrice';
123
- sortOrder?: 'asc' | 'desc';
124
187
  }
125
188
  /**
126
189
  * Product suggestion for autocomplete
@@ -1189,8 +1252,23 @@ declare class OmniSyncClient {
1189
1252
  */
1190
1253
  getStoreInfo(): Promise<StoreInfo>;
1191
1254
  /**
1192
- * Get a list of products with pagination
1255
+ * Get a list of products with pagination and filtering
1193
1256
  * Works in vibe-coded, storefront (public), and admin mode
1257
+ *
1258
+ * @example
1259
+ * ```typescript
1260
+ * // Basic usage
1261
+ * const products = await omni.getProducts({ page: 1, limit: 20 });
1262
+ *
1263
+ * // With filters (vibe-coded mode)
1264
+ * const filtered = await omni.getProducts({
1265
+ * categories: ['cat_123', 'cat_456'],
1266
+ * minPrice: 10,
1267
+ * maxPrice: 100,
1268
+ * sortBy: 'price',
1269
+ * sortOrder: 'asc'
1270
+ * });
1271
+ * ```
1194
1272
  */
1195
1273
  getProducts(params?: ProductQueryParams): Promise<PaginatedResponse<Product>>;
1196
1274
  /**
@@ -1198,6 +1276,56 @@ declare class OmniSyncClient {
1198
1276
  * Works in vibe-coded, storefront (public), and admin mode
1199
1277
  */
1200
1278
  getProduct(productId: string): Promise<Product>;
1279
+ /**
1280
+ * Get available categories for filtering products
1281
+ * Works in vibe-coded mode
1282
+ *
1283
+ * @example
1284
+ * ```typescript
1285
+ * const { categories } = await omni.getCategories();
1286
+ * // categories is a tree structure with children
1287
+ * ```
1288
+ */
1289
+ getCategories(): Promise<{
1290
+ categories: Array<{
1291
+ id: string;
1292
+ name: string;
1293
+ parentId?: string;
1294
+ children?: unknown[];
1295
+ }>;
1296
+ }>;
1297
+ /**
1298
+ * Get available brands for filtering products
1299
+ * Works in vibe-coded mode
1300
+ *
1301
+ * @example
1302
+ * ```typescript
1303
+ * const { brands } = await omni.getBrands();
1304
+ * // Use brand IDs in getProducts({ brands: ['brand_id'] })
1305
+ * ```
1306
+ */
1307
+ getBrands(): Promise<{
1308
+ brands: Array<{
1309
+ id: string;
1310
+ name: string;
1311
+ }>;
1312
+ }>;
1313
+ /**
1314
+ * Get available tags for filtering products
1315
+ * Works in vibe-coded mode
1316
+ *
1317
+ * @example
1318
+ * ```typescript
1319
+ * const { tags } = await omni.getTags();
1320
+ * // Use tag IDs in getProducts({ tags: ['tag_id'] })
1321
+ * ```
1322
+ */
1323
+ getTags(): Promise<{
1324
+ tags: Array<{
1325
+ id: string;
1326
+ name: string;
1327
+ }>;
1328
+ }>;
1201
1329
  /**
1202
1330
  * Get search suggestions for autocomplete
1203
1331
  * Returns matching products and categories for quick search UI
@@ -2608,4 +2736,4 @@ declare function isWebhookEventType(event: WebhookEvent, type: WebhookEventType)
2608
2736
  */
2609
2737
  declare function createWebhookHandler(handlers: Partial<Record<WebhookEventType, (event: WebhookEvent) => Promise<void>>>): (payload: unknown) => Promise<void>;
2610
2738
 
2611
- export { type AddToCartDto, type AppliedDiscount, type ApplyCouponDto, type BulkInventoryResponse, type BulkSaveVariantsDto, type BulkSaveVariantsResponse, type BulkVariantInput, type Cart, type CartItem, type CartStatus, type CategorySuggestion, type Checkout, type CheckoutAddress, type CheckoutLineItem, type CheckoutStatus, type CompleteCheckoutResponse, type CompleteDraftDto, type ConnectorPlatform, type Coupon, type CouponCreateResponse, type CouponQueryParams, type CouponStatus, type CouponType, type CouponValidationWarning, type CreateAddressDto, type CreateCheckoutDto, type CreateCouponDto, type CreateCustomApiDto, type CreateCustomerDto, type CreateGuestOrderDto, type CreateOrderDto, type CreateProductDto, type CreateRefundDto, type CreateVariantDto, type CustomApiAuthType, type CustomApiConnectionStatus, type CustomApiCredentials, type CustomApiIntegration, type CustomApiSyncConfig, type CustomApiSyncDirection, type CustomApiTestResult, type Customer, type CustomerAddress, type CustomerAuthResponse, type CustomerOAuthProvider, type CustomerProfile, type CustomerQueryParams, type DraftLineItem, type EditInventoryDto, type EmailVerificationResponse, type FulfillOrderDto, type GuestCheckoutStartResponse, type GuestOrderResponse, type InsufficientStockError, type InventoryInfo, type InventorySyncStatus, type LocalCart, type LocalCartItem, type MergeCartsDto, type OAuthAuthorizeResponse, type OAuthCallbackResponse, type OAuthConnection, type OAuthConnectionsResponse, type OAuthProvidersResponse, type OmniSyncApiError, OmniSyncClient, type OmniSyncClientOptions, OmniSyncError, type Order, type OrderAddress, type OrderCustomer, type OrderItem, type OrderQueryParams, type OrderStatus, type PaginatedResponse, type PlatformCouponCapabilities, type Product, type ProductAttributeInput, type ProductImage, type ProductQueryParams, type ProductSuggestion, type ProductVariant, type PublishProductResponse, type ReconcileInventoryResponse, type Refund, type RefundLineItem, type RefundLineItemResponse, type RefundType, type RegisterCustomerDto, type SearchSuggestions, type SelectShippingMethodDto, type SendInvoiceDto, type SetBillingAddressDto, type SetCheckoutCustomerDto, type SetShippingAddressDto, type SetShippingAddressResponse, type ShippingLine, type ShippingRate, type StockAvailabilityRequest, type StockAvailabilityResponse, type StockAvailabilityResult, type StoreInfo, type SyncJob, type UpdateAddressDto, type UpdateCartItemDto, type UpdateCouponDto, type UpdateCustomApiDto, type UpdateCustomerDto, type UpdateDraftDto, type UpdateInventoryDto, type UpdateOrderDto, type UpdateOrderShippingDto, type UpdateProductDto, type UpdateVariantDto, type UpdateVariantInventoryDto, type VariantInventoryResponse, type VariantPlatformOverlay, type VariantStatus, type WebhookEvent, type WebhookEventType, createWebhookHandler, isCouponApplicableToProduct, isWebhookEventType, parseWebhookEvent, verifyWebhook };
2739
+ export { type AddToCartDto, type AppliedDiscount, type ApplyCouponDto, type BulkInventoryResponse, type BulkSaveVariantsDto, type BulkSaveVariantsResponse, type BulkVariantInput, type Cart, type CartItem, type CartStatus, type CategorySuggestion, type Checkout, type CheckoutAddress, type CheckoutLineItem, type CheckoutStatus, type CompleteCheckoutResponse, type CompleteDraftDto, type ConnectorPlatform, type Coupon, type CouponCreateResponse, type CouponQueryParams, type CouponStatus, type CouponType, type CouponValidationWarning, type CreateAddressDto, type CreateCheckoutDto, type CreateCouponDto, type CreateCustomApiDto, type CreateCustomerDto, type CreateGuestOrderDto, type CreateOrderDto, type CreateProductDto, type CreateRefundDto, type CreateVariantDto, type CustomApiAuthType, type CustomApiConnectionStatus, type CustomApiCredentials, type CustomApiIntegration, type CustomApiSyncConfig, type CustomApiSyncDirection, type CustomApiTestResult, type Customer, type CustomerAddress, type CustomerAuthResponse, type CustomerOAuthProvider, type CustomerProfile, type CustomerQueryParams, type DraftLineItem, type EditInventoryDto, type EmailVerificationResponse, type FulfillOrderDto, type GuestCheckoutStartResponse, type GuestOrderResponse, type InsufficientStockError, type InventoryInfo, type InventorySyncStatus, type LocalCart, type LocalCartItem, type MergeCartsDto, type OAuthAuthorizeResponse, type OAuthCallbackResponse, type OAuthConnection, type OAuthConnectionsResponse, type OAuthProvidersResponse, type OmniSyncApiError, OmniSyncClient, type OmniSyncClientOptions, OmniSyncError, type Order, type OrderAddress, type OrderCustomer, type OrderItem, type OrderQueryParams, type OrderStatus, type PaginatedResponse, type PlatformCouponCapabilities, type Product, type ProductAttributeInput, type ProductImage, type ProductQueryParams, type ProductSuggestion, type ProductVariant, type PublishProductResponse, type ReconcileInventoryResponse, type Refund, type RefundLineItem, type RefundLineItemResponse, type RefundType, type RegisterCustomerDto, type SearchSuggestions, type SelectShippingMethodDto, type SendInvoiceDto, type SetBillingAddressDto, type SetCheckoutCustomerDto, type SetShippingAddressDto, type SetShippingAddressResponse, type ShippingLine, type ShippingRate, type StockAvailabilityRequest, type StockAvailabilityResponse, type StockAvailabilityResult, type StoreInfo, type SyncJob, type UpdateAddressDto, type UpdateCartItemDto, type UpdateCouponDto, type UpdateCustomApiDto, type UpdateCustomerDto, type UpdateDraftDto, type UpdateInventoryDto, type UpdateOrderDto, type UpdateOrderShippingDto, type UpdateProductDto, type UpdateVariantDto, type UpdateVariantInventoryDto, type VariantInventoryResponse, type VariantPlatformOverlay, type VariantStatus, type WebhookEvent, type WebhookEventType, createWebhookHandler, getStockStatus, isCouponApplicableToProduct, isWebhookEventType, parseWebhookEvent, verifyWebhook };
package/dist/index.d.ts CHANGED
@@ -52,6 +52,26 @@ interface StoreInfo {
52
52
  name: string;
53
53
  currency: string;
54
54
  language: string;
55
+ /** Connection ID (vibe-coded mode only) */
56
+ connectionId?: string;
57
+ /** Store name (vibe-coded mode only - same as name) */
58
+ storeName?: string;
59
+ /** Connection status (vibe-coded mode only) */
60
+ status?: string;
61
+ /** Allowed API scopes (vibe-coded mode only) */
62
+ allowedScopes?: string[];
63
+ /** Whether orders can be created (vibe-coded mode only) */
64
+ ordersWriteEnabled?: boolean;
65
+ /** Whether guest checkout is tracked (vibe-coded mode only) */
66
+ guestCheckoutTracking?: boolean;
67
+ /**
68
+ * Whether new customer registrations require email verification.
69
+ * If true, your site MUST implement an email verification flow:
70
+ * 1. After registerCustomer(), check if response.requiresVerification is true
71
+ * 2. Show a verification code input to the user
72
+ * 3. Call verifyEmail(code) with the code they received via email
73
+ */
74
+ requireEmailVerification?: boolean;
55
75
  }
56
76
  interface CustomerProfile {
57
77
  id: string;
@@ -109,18 +129,61 @@ interface ProductVariant {
109
129
  }
110
130
  interface InventoryInfo {
111
131
  total: number;
112
- reserved: number;
132
+ reserved?: number;
113
133
  available: number;
134
+ /**
135
+ * Whether the item is in stock (available > 0)
136
+ * Always present in vibe-coded API responses
137
+ */
138
+ inStock?: boolean;
114
139
  }
140
+ /**
141
+ * Get a human-readable stock status string
142
+ * @param inventory - The inventory info object
143
+ * @param options - Optional configuration for the status text
144
+ * @returns A string like "In Stock", "Out of Stock", or "Low Stock"
145
+ *
146
+ * @example
147
+ * ```typescript
148
+ * const product = await omni.getProduct('prod_123');
149
+ * const status = getStockStatus(product.inventory);
150
+ * // Returns "In Stock" or "Out of Stock"
151
+ *
152
+ * // With custom threshold:
153
+ * const status = getStockStatus(product.inventory, { lowStockThreshold: 5 });
154
+ * // Returns "Low Stock" if available <= 5
155
+ * ```
156
+ */
157
+ declare function getStockStatus(inventory: InventoryInfo | null | undefined, options?: {
158
+ /** Threshold for "Low Stock" status. Set to 0 to disable. Default: 0 (disabled) */
159
+ lowStockThreshold?: number;
160
+ /** Custom text for in stock. Default: "In Stock" */
161
+ inStockText?: string;
162
+ /** Custom text for out of stock. Default: "Out of Stock" */
163
+ outOfStockText?: string;
164
+ /** Custom text for low stock. Default: "Low Stock" */
165
+ lowStockText?: string;
166
+ }): string;
115
167
  interface ProductQueryParams {
116
168
  page?: number;
117
169
  limit?: number;
118
170
  search?: string;
119
171
  status?: 'active' | 'draft' | 'archived';
172
+ /** Filter by category IDs (comma-separated or array) */
173
+ categories?: string | string[];
174
+ /** Filter by brand IDs (comma-separated or array) */
175
+ brands?: string | string[];
176
+ /** Filter by tag IDs (comma-separated or array) */
177
+ tags?: string | string[];
178
+ /** Minimum price filter */
179
+ minPrice?: number;
180
+ /** Maximum price filter */
181
+ maxPrice?: number;
182
+ /** Sort by field (default: menuOrder) */
183
+ sortBy?: 'name' | 'price' | 'createdAt';
184
+ sortOrder?: 'asc' | 'desc';
120
185
  type?: 'SIMPLE' | 'VARIABLE';
121
186
  isDownloadable?: boolean;
122
- sortBy?: 'name' | 'createdAt' | 'updatedAt' | 'basePrice';
123
- sortOrder?: 'asc' | 'desc';
124
187
  }
125
188
  /**
126
189
  * Product suggestion for autocomplete
@@ -1189,8 +1252,23 @@ declare class OmniSyncClient {
1189
1252
  */
1190
1253
  getStoreInfo(): Promise<StoreInfo>;
1191
1254
  /**
1192
- * Get a list of products with pagination
1255
+ * Get a list of products with pagination and filtering
1193
1256
  * Works in vibe-coded, storefront (public), and admin mode
1257
+ *
1258
+ * @example
1259
+ * ```typescript
1260
+ * // Basic usage
1261
+ * const products = await omni.getProducts({ page: 1, limit: 20 });
1262
+ *
1263
+ * // With filters (vibe-coded mode)
1264
+ * const filtered = await omni.getProducts({
1265
+ * categories: ['cat_123', 'cat_456'],
1266
+ * minPrice: 10,
1267
+ * maxPrice: 100,
1268
+ * sortBy: 'price',
1269
+ * sortOrder: 'asc'
1270
+ * });
1271
+ * ```
1194
1272
  */
1195
1273
  getProducts(params?: ProductQueryParams): Promise<PaginatedResponse<Product>>;
1196
1274
  /**
@@ -1198,6 +1276,56 @@ declare class OmniSyncClient {
1198
1276
  * Works in vibe-coded, storefront (public), and admin mode
1199
1277
  */
1200
1278
  getProduct(productId: string): Promise<Product>;
1279
+ /**
1280
+ * Get available categories for filtering products
1281
+ * Works in vibe-coded mode
1282
+ *
1283
+ * @example
1284
+ * ```typescript
1285
+ * const { categories } = await omni.getCategories();
1286
+ * // categories is a tree structure with children
1287
+ * ```
1288
+ */
1289
+ getCategories(): Promise<{
1290
+ categories: Array<{
1291
+ id: string;
1292
+ name: string;
1293
+ parentId?: string;
1294
+ children?: unknown[];
1295
+ }>;
1296
+ }>;
1297
+ /**
1298
+ * Get available brands for filtering products
1299
+ * Works in vibe-coded mode
1300
+ *
1301
+ * @example
1302
+ * ```typescript
1303
+ * const { brands } = await omni.getBrands();
1304
+ * // Use brand IDs in getProducts({ brands: ['brand_id'] })
1305
+ * ```
1306
+ */
1307
+ getBrands(): Promise<{
1308
+ brands: Array<{
1309
+ id: string;
1310
+ name: string;
1311
+ }>;
1312
+ }>;
1313
+ /**
1314
+ * Get available tags for filtering products
1315
+ * Works in vibe-coded mode
1316
+ *
1317
+ * @example
1318
+ * ```typescript
1319
+ * const { tags } = await omni.getTags();
1320
+ * // Use tag IDs in getProducts({ tags: ['tag_id'] })
1321
+ * ```
1322
+ */
1323
+ getTags(): Promise<{
1324
+ tags: Array<{
1325
+ id: string;
1326
+ name: string;
1327
+ }>;
1328
+ }>;
1201
1329
  /**
1202
1330
  * Get search suggestions for autocomplete
1203
1331
  * Returns matching products and categories for quick search UI
@@ -2608,4 +2736,4 @@ declare function isWebhookEventType(event: WebhookEvent, type: WebhookEventType)
2608
2736
  */
2609
2737
  declare function createWebhookHandler(handlers: Partial<Record<WebhookEventType, (event: WebhookEvent) => Promise<void>>>): (payload: unknown) => Promise<void>;
2610
2738
 
2611
- export { type AddToCartDto, type AppliedDiscount, type ApplyCouponDto, type BulkInventoryResponse, type BulkSaveVariantsDto, type BulkSaveVariantsResponse, type BulkVariantInput, type Cart, type CartItem, type CartStatus, type CategorySuggestion, type Checkout, type CheckoutAddress, type CheckoutLineItem, type CheckoutStatus, type CompleteCheckoutResponse, type CompleteDraftDto, type ConnectorPlatform, type Coupon, type CouponCreateResponse, type CouponQueryParams, type CouponStatus, type CouponType, type CouponValidationWarning, type CreateAddressDto, type CreateCheckoutDto, type CreateCouponDto, type CreateCustomApiDto, type CreateCustomerDto, type CreateGuestOrderDto, type CreateOrderDto, type CreateProductDto, type CreateRefundDto, type CreateVariantDto, type CustomApiAuthType, type CustomApiConnectionStatus, type CustomApiCredentials, type CustomApiIntegration, type CustomApiSyncConfig, type CustomApiSyncDirection, type CustomApiTestResult, type Customer, type CustomerAddress, type CustomerAuthResponse, type CustomerOAuthProvider, type CustomerProfile, type CustomerQueryParams, type DraftLineItem, type EditInventoryDto, type EmailVerificationResponse, type FulfillOrderDto, type GuestCheckoutStartResponse, type GuestOrderResponse, type InsufficientStockError, type InventoryInfo, type InventorySyncStatus, type LocalCart, type LocalCartItem, type MergeCartsDto, type OAuthAuthorizeResponse, type OAuthCallbackResponse, type OAuthConnection, type OAuthConnectionsResponse, type OAuthProvidersResponse, type OmniSyncApiError, OmniSyncClient, type OmniSyncClientOptions, OmniSyncError, type Order, type OrderAddress, type OrderCustomer, type OrderItem, type OrderQueryParams, type OrderStatus, type PaginatedResponse, type PlatformCouponCapabilities, type Product, type ProductAttributeInput, type ProductImage, type ProductQueryParams, type ProductSuggestion, type ProductVariant, type PublishProductResponse, type ReconcileInventoryResponse, type Refund, type RefundLineItem, type RefundLineItemResponse, type RefundType, type RegisterCustomerDto, type SearchSuggestions, type SelectShippingMethodDto, type SendInvoiceDto, type SetBillingAddressDto, type SetCheckoutCustomerDto, type SetShippingAddressDto, type SetShippingAddressResponse, type ShippingLine, type ShippingRate, type StockAvailabilityRequest, type StockAvailabilityResponse, type StockAvailabilityResult, type StoreInfo, type SyncJob, type UpdateAddressDto, type UpdateCartItemDto, type UpdateCouponDto, type UpdateCustomApiDto, type UpdateCustomerDto, type UpdateDraftDto, type UpdateInventoryDto, type UpdateOrderDto, type UpdateOrderShippingDto, type UpdateProductDto, type UpdateVariantDto, type UpdateVariantInventoryDto, type VariantInventoryResponse, type VariantPlatformOverlay, type VariantStatus, type WebhookEvent, type WebhookEventType, createWebhookHandler, isCouponApplicableToProduct, isWebhookEventType, parseWebhookEvent, verifyWebhook };
2739
+ export { type AddToCartDto, type AppliedDiscount, type ApplyCouponDto, type BulkInventoryResponse, type BulkSaveVariantsDto, type BulkSaveVariantsResponse, type BulkVariantInput, type Cart, type CartItem, type CartStatus, type CategorySuggestion, type Checkout, type CheckoutAddress, type CheckoutLineItem, type CheckoutStatus, type CompleteCheckoutResponse, type CompleteDraftDto, type ConnectorPlatform, type Coupon, type CouponCreateResponse, type CouponQueryParams, type CouponStatus, type CouponType, type CouponValidationWarning, type CreateAddressDto, type CreateCheckoutDto, type CreateCouponDto, type CreateCustomApiDto, type CreateCustomerDto, type CreateGuestOrderDto, type CreateOrderDto, type CreateProductDto, type CreateRefundDto, type CreateVariantDto, type CustomApiAuthType, type CustomApiConnectionStatus, type CustomApiCredentials, type CustomApiIntegration, type CustomApiSyncConfig, type CustomApiSyncDirection, type CustomApiTestResult, type Customer, type CustomerAddress, type CustomerAuthResponse, type CustomerOAuthProvider, type CustomerProfile, type CustomerQueryParams, type DraftLineItem, type EditInventoryDto, type EmailVerificationResponse, type FulfillOrderDto, type GuestCheckoutStartResponse, type GuestOrderResponse, type InsufficientStockError, type InventoryInfo, type InventorySyncStatus, type LocalCart, type LocalCartItem, type MergeCartsDto, type OAuthAuthorizeResponse, type OAuthCallbackResponse, type OAuthConnection, type OAuthConnectionsResponse, type OAuthProvidersResponse, type OmniSyncApiError, OmniSyncClient, type OmniSyncClientOptions, OmniSyncError, type Order, type OrderAddress, type OrderCustomer, type OrderItem, type OrderQueryParams, type OrderStatus, type PaginatedResponse, type PlatformCouponCapabilities, type Product, type ProductAttributeInput, type ProductImage, type ProductQueryParams, type ProductSuggestion, type ProductVariant, type PublishProductResponse, type ReconcileInventoryResponse, type Refund, type RefundLineItem, type RefundLineItemResponse, type RefundType, type RegisterCustomerDto, type SearchSuggestions, type SelectShippingMethodDto, type SendInvoiceDto, type SetBillingAddressDto, type SetCheckoutCustomerDto, type SetShippingAddressDto, type SetShippingAddressResponse, type ShippingLine, type ShippingRate, type StockAvailabilityRequest, type StockAvailabilityResponse, type StockAvailabilityResult, type StoreInfo, type SyncJob, type UpdateAddressDto, type UpdateCartItemDto, type UpdateCouponDto, type UpdateCustomApiDto, type UpdateCustomerDto, type UpdateDraftDto, type UpdateInventoryDto, type UpdateOrderDto, type UpdateOrderShippingDto, type UpdateProductDto, type UpdateVariantDto, type UpdateVariantInventoryDto, type VariantInventoryResponse, type VariantPlatformOverlay, type VariantStatus, type WebhookEvent, type WebhookEventType, createWebhookHandler, getStockStatus, isCouponApplicableToProduct, isWebhookEventType, parseWebhookEvent, verifyWebhook };
package/dist/index.js CHANGED
@@ -23,6 +23,7 @@ __export(index_exports, {
23
23
  OmniSyncClient: () => OmniSyncClient,
24
24
  OmniSyncError: () => OmniSyncError,
25
25
  createWebhookHandler: () => createWebhookHandler,
26
+ getStockStatus: () => getStockStatus,
26
27
  isCouponApplicableToProduct: () => isCouponApplicableToProduct,
27
28
  isWebhookEventType: () => isWebhookEventType,
28
29
  parseWebhookEvent: () => parseWebhookEvent,
@@ -308,18 +309,42 @@ var OmniSyncClient = class {
308
309
  }
309
310
  // -------------------- Products --------------------
310
311
  /**
311
- * Get a list of products with pagination
312
+ * Get a list of products with pagination and filtering
312
313
  * Works in vibe-coded, storefront (public), and admin mode
314
+ *
315
+ * @example
316
+ * ```typescript
317
+ * // Basic usage
318
+ * const products = await omni.getProducts({ page: 1, limit: 20 });
319
+ *
320
+ * // With filters (vibe-coded mode)
321
+ * const filtered = await omni.getProducts({
322
+ * categories: ['cat_123', 'cat_456'],
323
+ * minPrice: 10,
324
+ * maxPrice: 100,
325
+ * sortBy: 'price',
326
+ * sortOrder: 'asc'
327
+ * });
328
+ * ```
313
329
  */
314
330
  async getProducts(params) {
331
+ const categories = Array.isArray(params?.categories) ? params.categories.join(",") : params?.categories;
332
+ const brands = Array.isArray(params?.brands) ? params.brands.join(",") : params?.brands;
333
+ const tags = Array.isArray(params?.tags) ? params.tags.join(",") : params?.tags;
315
334
  const queryParams = {
316
335
  page: params?.page,
317
336
  limit: params?.limit,
318
337
  search: params?.search,
319
338
  status: params?.status,
320
- type: params?.type,
339
+ categories,
340
+ brands,
341
+ tags,
342
+ minPrice: params?.minPrice,
343
+ maxPrice: params?.maxPrice,
321
344
  sortBy: params?.sortBy,
322
- sortOrder: params?.sortOrder
345
+ sortOrder: params?.sortOrder,
346
+ // Admin-only params
347
+ type: params?.type
323
348
  };
324
349
  if (this.isVibeCodedMode()) {
325
350
  return this.vibeCodedRequest(
@@ -357,6 +382,54 @@ var OmniSyncClient = class {
357
382
  }
358
383
  return this.adminRequest("GET", `/api/v1/products/${productId}`);
359
384
  }
385
+ /**
386
+ * Get available categories for filtering products
387
+ * Works in vibe-coded mode
388
+ *
389
+ * @example
390
+ * ```typescript
391
+ * const { categories } = await omni.getCategories();
392
+ * // categories is a tree structure with children
393
+ * ```
394
+ */
395
+ async getCategories() {
396
+ if (this.isVibeCodedMode()) {
397
+ return this.vibeCodedRequest("GET", "/categories");
398
+ }
399
+ throw new OmniSyncError("getCategories is only available in vibe-coded mode", 400);
400
+ }
401
+ /**
402
+ * Get available brands for filtering products
403
+ * Works in vibe-coded mode
404
+ *
405
+ * @example
406
+ * ```typescript
407
+ * const { brands } = await omni.getBrands();
408
+ * // Use brand IDs in getProducts({ brands: ['brand_id'] })
409
+ * ```
410
+ */
411
+ async getBrands() {
412
+ if (this.isVibeCodedMode()) {
413
+ return this.vibeCodedRequest("GET", "/brands");
414
+ }
415
+ throw new OmniSyncError("getBrands is only available in vibe-coded mode", 400);
416
+ }
417
+ /**
418
+ * Get available tags for filtering products
419
+ * Works in vibe-coded mode
420
+ *
421
+ * @example
422
+ * ```typescript
423
+ * const { tags } = await omni.getTags();
424
+ * // Use tag IDs in getProducts({ tags: ['tag_id'] })
425
+ * ```
426
+ */
427
+ async getTags() {
428
+ if (this.isVibeCodedMode()) {
429
+ return this.vibeCodedRequest("GET", "/tags");
430
+ }
431
+ throw new OmniSyncError("getTags is only available in vibe-coded mode", 400);
432
+ }
360
433
  /**
361
434
  * Get search suggestions for autocomplete
362
435
  * Returns matching products and categories for quick search UI
@@ -2684,6 +2757,21 @@ function createWebhookHandler(handlers) {
2684
2757
  }
2685
2758
 
2686
2759
  // src/types.ts
2760
+ function getStockStatus(inventory, options) {
2761
+ if (!inventory) {
2762
+ return options?.outOfStockText ?? "Out of Stock";
2763
+ }
2764
+ const available = inventory.available;
2765
+ const inStock = inventory.inStock ?? available > 0;
2766
+ const lowStockThreshold = options?.lowStockThreshold ?? 0;
2767
+ if (!inStock || available <= 0) {
2768
+ return options?.outOfStockText ?? "Out of Stock";
2769
+ }
2770
+ if (lowStockThreshold > 0 && available <= lowStockThreshold) {
2771
+ return options?.lowStockText ?? "Low Stock";
2772
+ }
2773
+ return options?.inStockText ?? "In Stock";
2774
+ }
2687
2775
  function isCouponApplicableToProduct(coupon, productId, productCategoryIds) {
2688
2776
  if (coupon.excludedProducts?.includes(productId)) {
2689
2777
  return false;
@@ -2708,6 +2796,7 @@ function isCouponApplicableToProduct(coupon, productId, productCategoryIds) {
2708
2796
  OmniSyncClient,
2709
2797
  OmniSyncError,
2710
2798
  createWebhookHandler,
2799
+ getStockStatus,
2711
2800
  isCouponApplicableToProduct,
2712
2801
  isWebhookEventType,
2713
2802
  parseWebhookEvent,
package/dist/index.mjs CHANGED
@@ -283,18 +283,42 @@ var OmniSyncClient = class {
283
283
  }
284
284
  // -------------------- Products --------------------
285
285
  /**
286
- * Get a list of products with pagination
286
+ * Get a list of products with pagination and filtering
287
287
  * Works in vibe-coded, storefront (public), and admin mode
288
+ *
289
+ * @example
290
+ * ```typescript
291
+ * // Basic usage
292
+ * const products = await omni.getProducts({ page: 1, limit: 20 });
293
+ *
294
+ * // With filters (vibe-coded mode)
295
+ * const filtered = await omni.getProducts({
296
+ * categories: ['cat_123', 'cat_456'],
297
+ * minPrice: 10,
298
+ * maxPrice: 100,
299
+ * sortBy: 'price',
300
+ * sortOrder: 'asc'
301
+ * });
302
+ * ```
288
303
  */
289
304
  async getProducts(params) {
305
+ const categories = Array.isArray(params?.categories) ? params.categories.join(",") : params?.categories;
306
+ const brands = Array.isArray(params?.brands) ? params.brands.join(",") : params?.brands;
307
+ const tags = Array.isArray(params?.tags) ? params.tags.join(",") : params?.tags;
290
308
  const queryParams = {
291
309
  page: params?.page,
292
310
  limit: params?.limit,
293
311
  search: params?.search,
294
312
  status: params?.status,
295
- type: params?.type,
313
+ categories,
314
+ brands,
315
+ tags,
316
+ minPrice: params?.minPrice,
317
+ maxPrice: params?.maxPrice,
296
318
  sortBy: params?.sortBy,
297
- sortOrder: params?.sortOrder
319
+ sortOrder: params?.sortOrder,
320
+ // Admin-only params
321
+ type: params?.type
298
322
  };
299
323
  if (this.isVibeCodedMode()) {
300
324
  return this.vibeCodedRequest(
@@ -332,6 +356,54 @@ var OmniSyncClient = class {
332
356
  }
333
357
  return this.adminRequest("GET", `/api/v1/products/${productId}`);
334
358
  }
359
+ /**
360
+ * Get available categories for filtering products
361
+ * Works in vibe-coded mode
362
+ *
363
+ * @example
364
+ * ```typescript
365
+ * const { categories } = await omni.getCategories();
366
+ * // categories is a tree structure with children
367
+ * ```
368
+ */
369
+ async getCategories() {
370
+ if (this.isVibeCodedMode()) {
371
+ return this.vibeCodedRequest("GET", "/categories");
372
+ }
373
+ throw new OmniSyncError("getCategories is only available in vibe-coded mode", 400);
374
+ }
375
+ /**
376
+ * Get available brands for filtering products
377
+ * Works in vibe-coded mode
378
+ *
379
+ * @example
380
+ * ```typescript
381
+ * const { brands } = await omni.getBrands();
382
+ * // Use brand IDs in getProducts({ brands: ['brand_id'] })
383
+ * ```
384
+ */
385
+ async getBrands() {
386
+ if (this.isVibeCodedMode()) {
387
+ return this.vibeCodedRequest("GET", "/brands");
388
+ }
389
+ throw new OmniSyncError("getBrands is only available in vibe-coded mode", 400);
390
+ }
391
+ /**
392
+ * Get available tags for filtering products
393
+ * Works in vibe-coded mode
394
+ *
395
+ * @example
396
+ * ```typescript
397
+ * const { tags } = await omni.getTags();
398
+ * // Use tag IDs in getProducts({ tags: ['tag_id'] })
399
+ * ```
400
+ */
401
+ async getTags() {
402
+ if (this.isVibeCodedMode()) {
403
+ return this.vibeCodedRequest("GET", "/tags");
404
+ }
405
+ throw new OmniSyncError("getTags is only available in vibe-coded mode", 400);
406
+ }
335
407
  /**
336
408
  * Get search suggestions for autocomplete
337
409
  * Returns matching products and categories for quick search UI
@@ -2659,6 +2731,21 @@ function createWebhookHandler(handlers) {
2659
2731
  }
2660
2732
 
2661
2733
  // src/types.ts
2734
+ function getStockStatus(inventory, options) {
2735
+ if (!inventory) {
2736
+ return options?.outOfStockText ?? "Out of Stock";
2737
+ }
2738
+ const available = inventory.available;
2739
+ const inStock = inventory.inStock ?? available > 0;
2740
+ const lowStockThreshold = options?.lowStockThreshold ?? 0;
2741
+ if (!inStock || available <= 0) {
2742
+ return options?.outOfStockText ?? "Out of Stock";
2743
+ }
2744
+ if (lowStockThreshold > 0 && available <= lowStockThreshold) {
2745
+ return options?.lowStockText ?? "Low Stock";
2746
+ }
2747
+ return options?.inStockText ?? "In Stock";
2748
+ }
2662
2749
  function isCouponApplicableToProduct(coupon, productId, productCategoryIds) {
2663
2750
  if (coupon.excludedProducts?.includes(productId)) {
2664
2751
  return false;
@@ -2682,6 +2769,7 @@ export {
2682
2769
  OmniSyncClient,
2683
2770
  OmniSyncError,
2684
2771
  createWebhookHandler,
2772
+ getStockStatus,
2685
2773
  isCouponApplicableToProduct,
2686
2774
  isWebhookEventType,
2687
2775
  parseWebhookEvent,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omni-sync-sdk",
3
- "version": "0.12.1",
3
+ "version": "0.13.0",
4
4
  "description": "Official SDK for building e-commerce storefronts with OmniSync Platform. Perfect for vibe-coded sites, AI-built stores (Cursor, Lovable, v0), and custom storefronts.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -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
+ }