@omni-commerce/sdk 0.4.0 → 0.5.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.js CHANGED
@@ -24,7 +24,7 @@ function normalizeClientOptions(options = {}) {
24
24
  }
25
25
 
26
26
  // src/version.ts
27
- var SDK_VERSION = "0.4.0";
27
+ var SDK_VERSION = "0.5.0";
28
28
  var SDK_USER_AGENT = `omnicommerce-js/${SDK_VERSION}`;
29
29
 
30
30
  // src/environments.ts
@@ -428,6 +428,18 @@ function sleep(ms) {
428
428
  return new Promise((resolve) => setTimeout(resolve, ms));
429
429
  }
430
430
 
431
+ // src/core/multipart.ts
432
+ function toMultipartBody(fields) {
433
+ const form = new FormData();
434
+ for (const [key, value] of Object.entries(fields)) {
435
+ if (value === void 0 || value === null) continue;
436
+ if (value instanceof Blob) form.append(key, value);
437
+ else if (typeof value === "object") form.append(key, JSON.stringify(value));
438
+ else form.append(key, String(value));
439
+ }
440
+ return form;
441
+ }
442
+
431
443
  // src/core/path.ts
432
444
  function encodePathParam(name, value) {
433
445
  if (typeof value !== "string" || value.trim() === "") {
@@ -1406,6 +1418,48 @@ var DirectoryClient = class {
1406
1418
  });
1407
1419
  }
1408
1420
  };
1421
+ var DocumentsClient = class {
1422
+ constructor(_http) {
1423
+ this._http = _http;
1424
+ }
1425
+ _http;
1426
+ /**
1427
+ * Upload Document
1428
+ *
1429
+ * Upload one file to the knowledge base as multipart/form-data. Requires `documents:write`.
1430
+
1431
+ Accepted: PDF up to 20 MB, Excel (.xlsx/.xlsm) up to 10 MB, images up to 8 MB, CSV and Markdown up to 2 MB. PDFs, Markdown, and images are indexed in the background; poll `GET /api/v1/documents/{documentId}` until `status` is `completed`. CSV and Excel are stored for agents to read but are not indexed.
1432
+ *
1433
+ * `POST /api/v1/documents`
1434
+ */
1435
+ upload(request, requestOptions) {
1436
+ const { ...body } = request ?? {};
1437
+ return this._http.request({
1438
+ method: "POST",
1439
+ path: "/api/v1/documents",
1440
+ query: void 0,
1441
+ body: toMultipartBody(body),
1442
+ ...mergeRequestOptions(requestOptions)
1443
+ });
1444
+ }
1445
+ /**
1446
+ * Get Document
1447
+ *
1448
+ * Read one knowledge base document and its indexing status. Requires `documents:read`.
1449
+ *
1450
+ * `GET /api/v1/documents/{documentId}`
1451
+ */
1452
+ get(request, requestOptions) {
1453
+ const { documentId, organizationId } = request ?? {};
1454
+ return this._http.request({
1455
+ method: "GET",
1456
+ path: `/api/v1/documents/${encodePathParam("documentId", documentId)}`,
1457
+ query: { organizationId },
1458
+ body: void 0,
1459
+ ...mergeRequestOptions(requestOptions)
1460
+ });
1461
+ }
1462
+ };
1409
1463
  var EvaluateClient = class {
1410
1464
  constructor(_http) {
1411
1465
  this._http = _http;
@@ -2307,6 +2361,25 @@ var ProductsClient = class {
2307
2361
  ...mergeRequestOptions(requestOptions)
2308
2362
  });
2309
2363
  }
2364
+ /**
2365
+ * Upload Product Image
2366
+ *
2367
+ * Upload one image to a product's or variant's gallery as multipart/form-data. Requires `catalog:write`.
2368
+
2369
+ JPEG, PNG, WebP, AVIF, or HEIC up to 8 MB; WebP, AVIF, and HEIC are stored as JPEG. The image is added at `position`, or at the end. Publish the product to send the new gallery to marketplaces.
2370
+ *
2371
+ * `POST /api/v1/products/{productId}/images`
2372
+ */
2373
+ uploadImage(request, requestOptions) {
2374
+ const { productId, ...body } = request ?? {};
2375
+ return this._http.request({
2376
+ method: "POST",
2377
+ path: `/api/v1/products/${encodePathParam("productId", productId)}/images`,
2378
+ query: void 0,
2379
+ body: toMultipartBody(body),
2380
+ ...mergeRequestOptions(requestOptions)
2381
+ });
2382
+ }
2310
2383
  /**
2311
2384
  * Update Product Inventory
2312
2385
  *
@@ -2636,17 +2709,19 @@ var PromotionsClient = class {
2636
2709
  });
2637
2710
  }
2638
2711
  /**
2639
- * Sync Promotion to Marketplaces
2640
- *
2641
- * Queue marketplace push for assigned products (Shopee promotion, Lazada Store Flash Sale/voucher/Flexicombo, TikTok activity, or Shopify discount). Requires `promotions:write`.
2642
- *
2643
- * `POST /api/v1/promotions/{promotionId}/sync`
2644
- */
2645
- sync(request, requestOptions) {
2712
+ * Retry Marketplace Delivery
2713
+ *
2714
+ * Run marketplace delivery again after a failure, for example once a store is reconnected. Requires `promotions:write`.
2715
+
2716
+ You do not need this to publish a promotion: creating or activating it, editing it while active or scheduled, and assigning products already deliver it, and pausing, ending, or archiving removes it. A retry brings each marketplace back in line with the promotion's current status.
2717
+ *
2718
+ * `POST /api/v1/promotions/{promotionId}/retry`
2719
+ */
2720
+ retry(request, requestOptions) {
2646
2721
  const { promotionId, organizationId, ...body } = request ?? {};
2647
2722
  return this._http.request({
2648
2723
  method: "POST",
2649
- path: `/api/v1/promotions/${encodePathParam("promotionId", promotionId)}/sync`,
2724
+ path: `/api/v1/promotions/${encodePathParam("promotionId", promotionId)}/retry`,
2650
2725
  query: { organizationId },
2651
2726
  body,
2652
2727
  ...mergeRequestOptions(requestOptions)
@@ -3317,6 +3392,7 @@ var OmniGeneratedClient = class {
3317
3392
  this.checkoutSessions = new CheckoutSessionsClient(this._http);
3318
3393
  this.compare = new CompareClient(this._http);
3319
3394
  this.directory = new DirectoryClient(this._http);
3395
+ this.documents = new DocumentsClient(this._http);
3320
3396
  this.evaluate = new EvaluateClient(this._http);
3321
3397
  this.feed = new FeedClient(this._http);
3322
3398
  this.images = new ImagesClient(this._http);
@@ -3352,6 +3428,7 @@ var OmniGeneratedClient = class {
3352
3428
  checkoutSessions;
3353
3429
  compare;
3354
3430
  directory;
3431
+ documents;
3355
3432
  evaluate;
3356
3433
  feed;
3357
3434
  images;