omni-sync-sdk 0.1.1 → 0.2.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/dist/index.mjs CHANGED
@@ -38,9 +38,8 @@ var OmniSyncClient = class {
38
38
  headers: {
39
39
  Authorization: `Bearer ${this.apiKey}`,
40
40
  "Content-Type": "application/json",
41
- "X-SDK-Version": "0.1.0",
41
+ "X-SDK-Version": "0.1.1",
42
42
  "ngrok-skip-browser-warning": "true"
43
- // Skip ngrok warning page for dev tunnels
44
43
  },
45
44
  body: body ? JSON.stringify(body) : void 0,
46
45
  signal: controller.signal
@@ -110,6 +109,147 @@ var OmniSyncClient = class {
110
109
  async deleteProduct(productId) {
111
110
  await this.request("DELETE", `/api/v1/products/${productId}`);
112
111
  }
112
+ /**
113
+ * Convert a SIMPLE product to VARIABLE product
114
+ *
115
+ * @example
116
+ * ```typescript
117
+ * const product = await omni.convertToVariable('prod_123');
118
+ * console.log('Product type:', product.type); // 'VARIABLE'
119
+ * ```
120
+ */
121
+ async convertToVariable(productId) {
122
+ return this.request("PATCH", `/api/v1/products/${productId}/convert-to-variable`);
123
+ }
124
+ /**
125
+ * Convert a VARIABLE product to SIMPLE product
126
+ * Note: This will delete all variants
127
+ *
128
+ * @example
129
+ * ```typescript
130
+ * const product = await omni.convertToSimple('prod_123');
131
+ * console.log('Product type:', product.type); // 'SIMPLE'
132
+ * ```
133
+ */
134
+ async convertToSimple(productId) {
135
+ return this.request("PATCH", `/api/v1/products/${productId}/convert-to-simple`);
136
+ }
137
+ /**
138
+ * Publish a product to specific platforms
139
+ *
140
+ * @example
141
+ * ```typescript
142
+ * const result = await omni.publishProduct('prod_123', ['SHOPIFY', 'WOOCOMMERCE']);
143
+ * console.log('Publish results:', result.results);
144
+ * ```
145
+ */
146
+ async publishProduct(productId, platforms) {
147
+ return this.request("POST", `/api/v1/products/${productId}/publish`, {
148
+ platforms
149
+ });
150
+ }
151
+ // -------------------- Variants --------------------
152
+ /**
153
+ * Create a new variant for a product
154
+ *
155
+ * @example
156
+ * ```typescript
157
+ * const variant = await omni.createVariant('prod_123', {
158
+ * sku: 'PROD-SM-RED',
159
+ * name: 'Small / Red',
160
+ * attributes: { size: 'S', color: 'Red' },
161
+ * price: 29.99,
162
+ * inventory: 100,
163
+ * });
164
+ * ```
165
+ */
166
+ async createVariant(productId, data) {
167
+ return this.request("POST", `/api/v1/products/${productId}/variants`, data);
168
+ }
169
+ /**
170
+ * Bulk save variants (create, update, delete in one operation)
171
+ *
172
+ * @example
173
+ * ```typescript
174
+ * const result = await omni.bulkSaveVariants('prod_123', {
175
+ * variants: [
176
+ * { sku: 'SM-RED', attributes: { size: 'S', color: 'Red' }, stock: 10, isEnabled: true },
177
+ * { id: 'var_456', sku: 'MD-BLUE', attributes: { size: 'M', color: 'Blue' }, stock: 5, isEnabled: true },
178
+ * { id: 'var_789', sku: 'LG-GREEN', attributes: {}, stock: 0, isEnabled: false, isDeleted: true },
179
+ * ],
180
+ * });
181
+ * console.log(`Created: ${result.created}, Updated: ${result.updated}, Deleted: ${result.deleted}`);
182
+ * ```
183
+ */
184
+ async bulkSaveVariants(productId, data) {
185
+ return this.request(
186
+ "POST",
187
+ `/api/v1/products/${productId}/variants/bulk`,
188
+ data
189
+ );
190
+ }
191
+ /**
192
+ * Update a variant
193
+ *
194
+ * @example
195
+ * ```typescript
196
+ * const variant = await omni.updateVariant('prod_123', 'var_456', {
197
+ * price: 34.99,
198
+ * salePrice: 29.99,
199
+ * });
200
+ * ```
201
+ */
202
+ async updateVariant(productId, variantId, data) {
203
+ return this.request(
204
+ "PATCH",
205
+ `/api/v1/products/${productId}/variants/${variantId}`,
206
+ data
207
+ );
208
+ }
209
+ /**
210
+ * Delete a variant
211
+ *
212
+ * @example
213
+ * ```typescript
214
+ * await omni.deleteVariant('prod_123', 'var_456');
215
+ * ```
216
+ */
217
+ async deleteVariant(productId, variantId) {
218
+ await this.request("DELETE", `/api/v1/products/${productId}/variants/${variantId}`);
219
+ }
220
+ /**
221
+ * Get inventory for a specific variant
222
+ *
223
+ * @example
224
+ * ```typescript
225
+ * const inventory = await omni.getVariantInventory('prod_123', 'var_456');
226
+ * console.log('Available:', inventory.available);
227
+ * ```
228
+ */
229
+ async getVariantInventory(productId, variantId) {
230
+ return this.request(
231
+ "GET",
232
+ `/api/v1/products/${productId}/variants/${variantId}/inventory`
233
+ );
234
+ }
235
+ /**
236
+ * Update inventory for a specific variant
237
+ *
238
+ * @example
239
+ * ```typescript
240
+ * const inventory = await omni.updateVariantInventory('prod_123', 'var_456', {
241
+ * newTotal: 50,
242
+ * reason: 'Restocked from supplier',
243
+ * });
244
+ * ```
245
+ */
246
+ async updateVariantInventory(productId, variantId, data) {
247
+ return this.request(
248
+ "PATCH",
249
+ `/api/v1/products/${productId}/variants/${variantId}/inventory`,
250
+ data
251
+ );
252
+ }
113
253
  // -------------------- Orders --------------------
114
254
  /**
115
255
  * Get a list of orders with pagination
@@ -142,6 +282,209 @@ var OmniSyncClient = class {
142
282
  async updateOrder(orderId, data) {
143
283
  return this.request("PATCH", `/api/v1/orders/${orderId}`, data);
144
284
  }
285
+ /**
286
+ * Update order status
287
+ *
288
+ * @example
289
+ * ```typescript
290
+ * const order = await omni.updateOrderStatus('order_123', 'shipped');
291
+ * ```
292
+ */
293
+ async updateOrderStatus(orderId, status) {
294
+ return this.request("PATCH", `/api/v1/orders/${orderId}/status`, { status });
295
+ }
296
+ /**
297
+ * Update order payment method
298
+ * Note: Only WooCommerce supports syncing payment method changes back to platform
299
+ *
300
+ * @example
301
+ * ```typescript
302
+ * const order = await omni.updatePaymentMethod('order_123', 'credit_card');
303
+ * ```
304
+ */
305
+ async updatePaymentMethod(orderId, paymentMethod) {
306
+ return this.request("PATCH", `/api/v1/orders/${orderId}/payment-method`, {
307
+ paymentMethod
308
+ });
309
+ }
310
+ /**
311
+ * Update order notes
312
+ *
313
+ * @example
314
+ * ```typescript
315
+ * const order = await omni.updateOrderNotes('order_123', 'Customer requested gift wrapping');
316
+ * ```
317
+ */
318
+ async updateOrderNotes(orderId, notes) {
319
+ return this.request("PATCH", `/api/v1/orders/${orderId}/notes`, { notes });
320
+ }
321
+ /**
322
+ * Get refunds for an order
323
+ * Returns refunds from the source platform (Shopify/WooCommerce only)
324
+ *
325
+ * @example
326
+ * ```typescript
327
+ * const refunds = await omni.getOrderRefunds('order_123');
328
+ * console.log('Total refunds:', refunds.length);
329
+ * ```
330
+ */
331
+ async getOrderRefunds(orderId) {
332
+ return this.request("GET", `/api/v1/orders/${orderId}/refunds`);
333
+ }
334
+ /**
335
+ * Create a refund for an order
336
+ * Creates refund on the source platform (Shopify/WooCommerce only)
337
+ *
338
+ * @example
339
+ * ```typescript
340
+ * // Full refund
341
+ * const refund = await omni.createRefund('order_123', {
342
+ * type: 'full',
343
+ * restockInventory: true,
344
+ * notifyCustomer: true,
345
+ * reason: 'Customer request',
346
+ * });
347
+ *
348
+ * // Partial refund
349
+ * const partialRefund = await omni.createRefund('order_123', {
350
+ * type: 'partial',
351
+ * items: [
352
+ * { lineItemId: 'item_456', quantity: 1 },
353
+ * ],
354
+ * restockInventory: true,
355
+ * });
356
+ * ```
357
+ */
358
+ async createRefund(orderId, data) {
359
+ return this.request("POST", `/api/v1/orders/${orderId}/refunds`, data);
360
+ }
361
+ /**
362
+ * Update order shipping address
363
+ * Syncs to source platform (Shopify/WooCommerce only)
364
+ *
365
+ * @example
366
+ * ```typescript
367
+ * const order = await omni.updateOrderShipping('order_123', {
368
+ * firstName: 'John',
369
+ * lastName: 'Doe',
370
+ * line1: '456 New Address',
371
+ * city: 'Los Angeles',
372
+ * state: 'CA',
373
+ * country: 'US',
374
+ * postalCode: '90001',
375
+ * });
376
+ * ```
377
+ */
378
+ async updateOrderShipping(orderId, data) {
379
+ return this.request("PATCH", `/api/v1/orders/${orderId}/shipping`, data);
380
+ }
381
+ /**
382
+ * Cancel an order
383
+ * Works for Shopify and WooCommerce orders that haven't been fulfilled
384
+ *
385
+ * @example
386
+ * ```typescript
387
+ * const order = await omni.cancelOrder('order_123');
388
+ * console.log('Order status:', order.status); // 'cancelled'
389
+ * ```
390
+ */
391
+ async cancelOrder(orderId) {
392
+ return this.request("POST", `/api/v1/orders/${orderId}/cancel`);
393
+ }
394
+ /**
395
+ * Fulfill an order (mark as shipped)
396
+ * Works for Shopify and WooCommerce orders
397
+ *
398
+ * @example
399
+ * ```typescript
400
+ * const order = await omni.fulfillOrder('order_123', {
401
+ * trackingNumber: '1Z999AA10123456784',
402
+ * trackingCompany: 'UPS',
403
+ * notifyCustomer: true,
404
+ * });
405
+ * ```
406
+ */
407
+ async fulfillOrder(orderId, data) {
408
+ return this.request("POST", `/api/v1/orders/${orderId}/fulfill`, data || {});
409
+ }
410
+ /**
411
+ * Sync draft orders from connected platforms
412
+ *
413
+ * @example
414
+ * ```typescript
415
+ * const result = await omni.syncDraftOrders();
416
+ * console.log('Draft orders synced');
417
+ * ```
418
+ */
419
+ async syncDraftOrders() {
420
+ return this.request("POST", "/api/v1/orders/sync-drafts");
421
+ }
422
+ /**
423
+ * Complete a draft order (convert to regular order)
424
+ *
425
+ * @example
426
+ * ```typescript
427
+ * const order = await omni.completeDraftOrder('draft_123', {
428
+ * paymentPending: false,
429
+ * });
430
+ * ```
431
+ */
432
+ async completeDraftOrder(orderId, data) {
433
+ return this.request("POST", `/api/v1/orders/${orderId}/complete-draft`, data || {});
434
+ }
435
+ /**
436
+ * Send invoice for a draft order
437
+ *
438
+ * @example
439
+ * ```typescript
440
+ * await omni.sendDraftInvoice('draft_123', {
441
+ * to: 'customer@example.com',
442
+ * subject: 'Your Invoice',
443
+ * customMessage: 'Thank you for your order!',
444
+ * });
445
+ * ```
446
+ */
447
+ async sendDraftInvoice(orderId, data) {
448
+ return this.request(
449
+ "POST",
450
+ `/api/v1/orders/${orderId}/send-invoice`,
451
+ data || {}
452
+ );
453
+ }
454
+ /**
455
+ * Delete a draft order
456
+ *
457
+ * @example
458
+ * ```typescript
459
+ * await omni.deleteDraftOrder('draft_123');
460
+ * ```
461
+ */
462
+ async deleteDraftOrder(orderId) {
463
+ await this.request("DELETE", `/api/v1/orders/${orderId}/draft`);
464
+ }
465
+ /**
466
+ * Update a draft order
467
+ *
468
+ * @example
469
+ * ```typescript
470
+ * const order = await omni.updateDraftOrder('draft_123', {
471
+ * note: 'Updated customer note',
472
+ * email: 'newemail@example.com',
473
+ * shippingAddress: {
474
+ * firstName: 'John',
475
+ * lastName: 'Doe',
476
+ * address1: '123 Main St',
477
+ * city: 'New York',
478
+ * province: 'NY',
479
+ * country: 'US',
480
+ * zip: '10001',
481
+ * },
482
+ * });
483
+ * ```
484
+ */
485
+ async updateDraftOrder(orderId, data) {
486
+ return this.request("PATCH", `/api/v1/orders/${orderId}/draft`, data);
487
+ }
145
488
  // -------------------- Inventory --------------------
146
489
  /**
147
490
  * Update inventory for a product
@@ -154,7 +497,74 @@ var OmniSyncClient = class {
154
497
  * Get current inventory for a product
155
498
  */
156
499
  async getInventory(productId) {
157
- return this.request("GET", `/api/v1/products/${productId}/inventory`);
500
+ return this.request("GET", `/api/v1/inventory/${productId}`);
501
+ }
502
+ /**
503
+ * Edit inventory manually with reason for audit trail
504
+ *
505
+ * @example
506
+ * ```typescript
507
+ * const inventory = await omni.editInventory({
508
+ * productId: 'prod_123',
509
+ * newTotal: 100,
510
+ * reason: 'Restocked from warehouse',
511
+ * });
512
+ * ```
513
+ */
514
+ async editInventory(data) {
515
+ return this.request("POST", "/api/v1/inventory/edit", data);
516
+ }
517
+ /**
518
+ * Get inventory sync status for all products in the store
519
+ *
520
+ * @example
521
+ * ```typescript
522
+ * const status = await omni.getInventorySyncStatus();
523
+ * console.log(`${status.pending} products pending sync`);
524
+ * console.log(`Last sync: ${status.lastSyncAt}`);
525
+ * ```
526
+ */
527
+ async getInventorySyncStatus() {
528
+ return this.request("GET", "/api/v1/inventory/sync-status");
529
+ }
530
+ /**
531
+ * Get inventory for multiple products at once
532
+ *
533
+ * @example
534
+ * ```typescript
535
+ * const inventories = await omni.getBulkInventory(['prod_123', 'prod_456', 'prod_789']);
536
+ * inventories.forEach(inv => {
537
+ * console.log(`${inv.productId}: ${inv.available} available`);
538
+ * });
539
+ * ```
540
+ */
541
+ async getBulkInventory(productIds) {
542
+ return this.request("POST", "/api/v1/inventory/bulk", { productIds });
543
+ }
544
+ /**
545
+ * Reconcile inventory between OmniSync and connected platforms
546
+ * Detects and optionally fixes discrepancies
547
+ *
548
+ * @example
549
+ * ```typescript
550
+ * // Reconcile single product (dry run)
551
+ * const result = await omni.reconcileInventory({ productId: 'prod_123' });
552
+ *
553
+ * // Reconcile all products with auto-fix
554
+ * const summary = await omni.reconcileInventory({ autoFix: true });
555
+ * console.log(`Reconciled ${summary.reconciled} products`);
556
+ * ```
557
+ */
558
+ async reconcileInventory(options) {
559
+ const queryParams = {};
560
+ if (options?.productId) queryParams.productId = options.productId;
561
+ if (options?.autoFix) queryParams.autoFix = "true";
562
+ return this.request(
563
+ "POST",
564
+ "/api/v1/inventory/reconcile",
565
+ void 0,
566
+ queryParams
567
+ );
158
568
  }
159
569
  // -------------------- Sync --------------------
160
570
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omni-sync-sdk",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "SDK for integrating vibe coding stores with Omni-Sync Platform",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",