@omni-commerce/sdk 0.3.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.cjs CHANGED
@@ -26,7 +26,7 @@ function normalizeClientOptions(options = {}) {
26
26
  }
27
27
 
28
28
  // src/version.ts
29
- var SDK_VERSION = "0.3.0";
29
+ var SDK_VERSION = "0.5.0";
30
30
  var SDK_USER_AGENT = `omnicommerce-js/${SDK_VERSION}`;
31
31
 
32
32
  // src/environments.ts
@@ -430,6 +430,18 @@ function sleep(ms) {
430
430
  return new Promise((resolve) => setTimeout(resolve, ms));
431
431
  }
432
432
 
433
+ // src/core/multipart.ts
434
+ function toMultipartBody(fields) {
435
+ const form = new FormData();
436
+ for (const [key, value] of Object.entries(fields)) {
437
+ if (value === void 0 || value === null) continue;
438
+ if (value instanceof Blob) form.append(key, value);
439
+ else if (typeof value === "object") form.append(key, JSON.stringify(value));
440
+ else form.append(key, String(value));
441
+ }
442
+ return form;
443
+ }
444
+
433
445
  // src/core/path.ts
434
446
  function encodePathParam(name, value) {
435
447
  if (typeof value !== "string" || value.trim() === "") {
@@ -582,37 +594,415 @@ var AnalyticsClient = class {
582
594
  }
583
595
  _http;
584
596
  /**
585
- * Get Sales Analytics
597
+ * Get Ads Analytics
598
+ *
599
+ * Ad spend, attributed sales, ROAS, and ACOS over the last 28 days, and per-product sales and ad metrics for today, yesterday, 7-day and 28-day averages, and the same day one and four weeks ago. Matches the Ads page. Requires `analytics:read`.
600
+
601
+ Amounts are in `data.filters.currency`. The periods count back from the end of the range.
602
+ *
603
+ * `GET /api/v1/analytics/ads`
604
+ */
605
+ getAds(request = {}, requestOptions) {
606
+ const {
607
+ organizationId,
608
+ from,
609
+ to,
610
+ timeZone,
611
+ marketplace,
612
+ country,
613
+ store,
614
+ currency
615
+ } = request ?? {};
616
+ return this._http.request({
617
+ method: "GET",
618
+ path: "/api/v1/analytics/ads",
619
+ query: {
620
+ organizationId,
621
+ from,
622
+ to,
623
+ timeZone,
624
+ marketplace,
625
+ country,
626
+ store,
627
+ currency
628
+ },
629
+ body: void 0,
630
+ ...mergeRequestOptions(requestOptions)
631
+ });
632
+ }
633
+ /**
634
+ * Get AI Traffic Analytics
635
+ *
636
+ * Visits and crawls from AI assistants and search engines: totals, a daily trend, breakdowns by source, route, country, and product, and recent events. Matches the AI Traffic page. Requires `analytics:read`.
637
+
638
+ A range covers at most 365 days; a longer one is shortened to the last 365 days. Read the applied range from `data.filters`.
639
+ *
640
+ * `GET /api/v1/analytics/ai-traffic`
641
+ */
642
+ getAiTraffic(request = {}, requestOptions) {
643
+ const {
644
+ organizationId,
645
+ from,
646
+ to,
647
+ timeZone,
648
+ source,
649
+ trafficType,
650
+ route,
651
+ country
652
+ } = request ?? {};
653
+ return this._http.request({
654
+ method: "GET",
655
+ path: "/api/v1/analytics/ai-traffic",
656
+ query: {
657
+ organizationId,
658
+ from,
659
+ to,
660
+ timeZone,
661
+ source,
662
+ trafficType,
663
+ route,
664
+ country
665
+ },
666
+ body: void 0,
667
+ ...mergeRequestOptions(requestOptions)
668
+ });
669
+ }
670
+ /**
671
+ * Get Video and LIVE Analytics
672
+ *
673
+ * Views, product clicks, orders, and GMV from shoppable videos and LIVE streams, by day, by content type, and per video. Matches the Video / LIVE page. Requires `analytics:read`.
674
+
675
+ Amounts are in `data.filters.currency`. Only orders in that currency are counted; nothing is converted. A range covers at most 366 days.
676
+ *
677
+ * `GET /api/v1/analytics/content`
678
+ */
679
+ getContent(request = {}, requestOptions) {
680
+ const {
681
+ organizationId,
682
+ from,
683
+ to,
684
+ timeZone,
685
+ marketplace,
686
+ country,
687
+ store,
688
+ currency
689
+ } = request ?? {};
690
+ return this._http.request({
691
+ method: "GET",
692
+ path: "/api/v1/analytics/content",
693
+ query: {
694
+ organizationId,
695
+ from,
696
+ to,
697
+ timeZone,
698
+ marketplace,
699
+ country,
700
+ store,
701
+ currency
702
+ },
703
+ body: void 0,
704
+ ...mergeRequestOptions(requestOptions)
705
+ });
706
+ }
707
+ /**
708
+ * Get Order Analytics
709
+ *
710
+ * Order KPIs with their change against the previous period, a daily trend, sales by order status and by marketplace, and the top products by net sales. Repeat buyers are counted but not listed. Matches the Orders analysis page. Requires `analytics:read`.
711
+
712
+ Amounts are in `data.filters.currency`. Only orders in that currency are counted; nothing is converted. A range covers at most 366 days.
713
+ *
714
+ * `GET /api/v1/analytics/orders`
715
+ */
716
+ getOrders(request = {}, requestOptions) {
717
+ const {
718
+ organizationId,
719
+ from,
720
+ to,
721
+ timeZone,
722
+ marketplace,
723
+ country,
724
+ store,
725
+ currency
726
+ } = request ?? {};
727
+ return this._http.request({
728
+ method: "GET",
729
+ path: "/api/v1/analytics/orders",
730
+ query: {
731
+ organizationId,
732
+ from,
733
+ to,
734
+ timeZone,
735
+ marketplace,
736
+ country,
737
+ store,
738
+ currency
739
+ },
740
+ body: void 0,
741
+ ...mergeRequestOptions(requestOptions)
742
+ });
743
+ }
744
+ /**
745
+ * Get Growth Overview
746
+ *
747
+ * Sales, traffic, and profit KPIs with their change against the previous period, a daily trend, the traffic funnel, sales by channel, top and lagging products, and ranked next actions. Matches the Growth Intelligence overview page. Requires `analytics:read`.
748
+
749
+ Amounts are in `data.filters.currency`. Only orders in that currency are counted; nothing is converted. A range covers at most 366 days.
750
+ *
751
+ * `GET /api/v1/analytics/overview`
752
+ */
753
+ getOverview(request = {}, requestOptions) {
754
+ const {
755
+ organizationId,
756
+ from,
757
+ to,
758
+ timeZone,
759
+ marketplace,
760
+ country,
761
+ store,
762
+ currency
763
+ } = request ?? {};
764
+ return this._http.request({
765
+ method: "GET",
766
+ path: "/api/v1/analytics/overview",
767
+ query: {
768
+ organizationId,
769
+ from,
770
+ to,
771
+ timeZone,
772
+ marketplace,
773
+ country,
774
+ store,
775
+ currency
776
+ },
777
+ body: void 0,
778
+ ...mergeRequestOptions(requestOptions)
779
+ });
780
+ }
781
+ /**
782
+ * Get Pricing Analytics
783
+ *
784
+ * Selling products with their margin, velocity, stock cover, prices, competitor median, and a pricing recommendation. Matches the Pricing page. Requires `analytics:read`.
785
+
786
+ Amounts are in `data.filters.currency`. Only orders in that currency are counted; nothing is converted. A range covers at most 366 days.
787
+ *
788
+ * `GET /api/v1/analytics/pricing`
789
+ */
790
+ getPricing(request = {}, requestOptions) {
791
+ const {
792
+ organizationId,
793
+ from,
794
+ to,
795
+ timeZone,
796
+ marketplace,
797
+ country,
798
+ store,
799
+ currency
800
+ } = request ?? {};
801
+ return this._http.request({
802
+ method: "GET",
803
+ path: "/api/v1/analytics/pricing",
804
+ query: {
805
+ organizationId,
806
+ from,
807
+ to,
808
+ timeZone,
809
+ marketplace,
810
+ country,
811
+ store,
812
+ currency
813
+ },
814
+ body: void 0,
815
+ ...mergeRequestOptions(requestOptions)
816
+ });
817
+ }
818
+ /**
819
+ * Get Product Analytics
820
+ *
821
+ * Per-product sales, traffic, price, stock, profit, and ad performance, ranked by net sales, with ranked insights. Pass `productId` for specific products, for example on a product page. Matches the Products page. Requires `analytics:read`.
822
+
823
+ Amounts are in `data.filters.currency`. Only orders in that currency are counted; nothing is converted. A range covers at most 366 days.
824
+ *
825
+ * `GET /api/v1/analytics/products`
826
+ */
827
+ getProducts(request = {}, requestOptions) {
828
+ const {
829
+ organizationId,
830
+ from,
831
+ to,
832
+ timeZone,
833
+ marketplace,
834
+ country,
835
+ store,
836
+ currency,
837
+ q,
838
+ productId,
839
+ limit
840
+ } = request ?? {};
841
+ return this._http.request({
842
+ method: "GET",
843
+ path: "/api/v1/analytics/products",
844
+ query: {
845
+ organizationId,
846
+ from,
847
+ to,
848
+ timeZone,
849
+ marketplace,
850
+ country,
851
+ store,
852
+ currency,
853
+ q,
854
+ productId,
855
+ limit
856
+ },
857
+ body: void 0,
858
+ ...mergeRequestOptions(requestOptions)
859
+ });
860
+ }
861
+ /**
862
+ * Get Profit Analytics
586
863
  *
587
- * Sales KPIs for a date range with the change against the previous period of equal length, a daily trend, sales by order status and by marketplace, and the top products by net sales. Matches the Orders analysis page. Requires `analytics:read`.
864
+ * Revenue, costs, fees, and profit with a waterfall, cost breakdowns, a daily trend, the most and least profitable products, and products missing a cost price. Session members also need finance access. Matches the P&L Analysis page. Requires `analytics:read`.
588
865
 
589
866
  Amounts are in `data.filters.currency`. Only orders in that currency are counted; nothing is converted. A range covers at most 366 days.
590
867
  *
591
- * `GET /api/v1/analytics/sales`
868
+ * `GET /api/v1/analytics/profit`
592
869
  */
593
- getSales(request = {}, requestOptions) {
870
+ getProfit(request = {}, requestOptions) {
594
871
  const {
595
872
  organizationId,
596
873
  from,
597
874
  to,
875
+ timeZone,
598
876
  marketplace,
599
877
  country,
600
878
  store,
601
879
  currency,
602
- timeZone
880
+ sku
603
881
  } = request ?? {};
604
882
  return this._http.request({
605
883
  method: "GET",
606
- path: "/api/v1/analytics/sales",
884
+ path: "/api/v1/analytics/profit",
607
885
  query: {
608
886
  organizationId,
609
887
  from,
610
888
  to,
889
+ timeZone,
611
890
  marketplace,
612
891
  country,
613
892
  store,
614
893
  currency,
615
- timeZone
894
+ sku
895
+ },
896
+ body: void 0,
897
+ ...mergeRequestOptions(requestOptions)
898
+ });
899
+ }
900
+ /**
901
+ * Get Business Report
902
+ *
903
+ * The management summary: headline KPIs, top products, sales by marketplace, alerts, settlement totals, and data quality. Matches the Business Reports page. Requires `analytics:read`.
904
+
905
+ Amounts are in `data.filters.currency`. Only orders in that currency are counted; nothing is converted. A range covers at most 366 days.
906
+ *
907
+ * `GET /api/v1/analytics/reports`
908
+ */
909
+ getReports(request = {}, requestOptions) {
910
+ const {
911
+ organizationId,
912
+ from,
913
+ to,
914
+ timeZone,
915
+ marketplace,
916
+ country,
917
+ store,
918
+ currency
919
+ } = request ?? {};
920
+ return this._http.request({
921
+ method: "GET",
922
+ path: "/api/v1/analytics/reports",
923
+ query: {
924
+ organizationId,
925
+ from,
926
+ to,
927
+ timeZone,
928
+ marketplace,
929
+ country,
930
+ store,
931
+ currency
932
+ },
933
+ body: void 0,
934
+ ...mergeRequestOptions(requestOptions)
935
+ });
936
+ }
937
+ /**
938
+ * Get Store Analytics
939
+ *
940
+ * Seller Centre shop metrics: visitors, page views, followers, the placed, paid, and confirmed buyer funnel, a daily trend, and the app and web split. Matches the Analytics (Seller Centre) page. Requires `analytics:read`.
941
+
942
+ Amounts are in `data.filters.currency`. Only orders in that currency are counted; nothing is converted. A range covers at most 366 days.
943
+ *
944
+ * `GET /api/v1/analytics/stores`
945
+ */
946
+ getStores(request = {}, requestOptions) {
947
+ const {
948
+ organizationId,
949
+ from,
950
+ to,
951
+ timeZone,
952
+ marketplace,
953
+ country,
954
+ store,
955
+ currency
956
+ } = request ?? {};
957
+ return this._http.request({
958
+ method: "GET",
959
+ path: "/api/v1/analytics/stores",
960
+ query: {
961
+ organizationId,
962
+ from,
963
+ to,
964
+ timeZone,
965
+ marketplace,
966
+ country,
967
+ store,
968
+ currency
969
+ },
970
+ body: void 0,
971
+ ...mergeRequestOptions(requestOptions)
972
+ });
973
+ }
974
+ /**
975
+ * Get Traffic Analytics
976
+ *
977
+ * Impressions, page views, visitors, add-to-cart, and conversion, with the funnel, a daily trend, products ranked by lost conversion, diagnostics, and the videos that drive traffic. Matches the Traffic page. Requires `analytics:read`.
978
+
979
+ Amounts are in `data.filters.currency`. Only orders in that currency are counted; nothing is converted. A range covers at most 366 days.
980
+ *
981
+ * `GET /api/v1/analytics/traffic`
982
+ */
983
+ getTraffic(request = {}, requestOptions) {
984
+ const {
985
+ organizationId,
986
+ from,
987
+ to,
988
+ timeZone,
989
+ marketplace,
990
+ country,
991
+ store,
992
+ currency
993
+ } = request ?? {};
994
+ return this._http.request({
995
+ method: "GET",
996
+ path: "/api/v1/analytics/traffic",
997
+ query: {
998
+ organizationId,
999
+ from,
1000
+ to,
1001
+ timeZone,
1002
+ marketplace,
1003
+ country,
1004
+ store,
1005
+ currency
616
1006
  },
617
1007
  body: void 0,
618
1008
  ...mergeRequestOptions(requestOptions)
@@ -710,44 +1100,6 @@ var AopClient = class {
710
1100
  });
711
1101
  }
712
1102
  };
713
- var ApiClient = class {
714
- constructor(_http) {
715
- this._http = _http;
716
- }
717
- _http;
718
- /**
719
- * API Root
720
- *
721
- * Public API discovery root. Merchant payments are handled by organization-scoped checkout session endpoints.
722
- *
723
- * `GET /api`
724
- */
725
- root(requestOptions) {
726
- return this._http.request({
727
- method: "GET",
728
- path: "/api",
729
- query: void 0,
730
- body: void 0,
731
- ...mergeRequestOptions(requestOptions)
732
- });
733
- }
734
- /**
735
- * API v1 Root
736
- *
737
- * Public API v1 discovery root. Merchant payments are handled by organization-scoped checkout session endpoints.
738
- *
739
- * `GET /api/v1`
740
- */
741
- v1(requestOptions) {
742
- return this._http.request({
743
- method: "GET",
744
- path: "/api/v1",
745
- query: void 0,
746
- body: void 0,
747
- ...mergeRequestOptions(requestOptions)
748
- });
749
- }
750
- };
751
1103
  var CampaignsClient = class {
752
1104
  constructor(_http) {
753
1105
  this._http = _http;
@@ -1068,6 +1420,48 @@ var DirectoryClient = class {
1068
1420
  });
1069
1421
  }
1070
1422
  };
1423
+ var DocumentsClient = class {
1424
+ constructor(_http) {
1425
+ this._http = _http;
1426
+ }
1427
+ _http;
1428
+ /**
1429
+ * Upload Document
1430
+ *
1431
+ * Upload one file to the knowledge base as multipart/form-data. Requires `documents:write`.
1432
+
1433
+ 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.
1434
+ *
1435
+ * `POST /api/v1/documents`
1436
+ */
1437
+ upload(request, requestOptions) {
1438
+ const { ...body } = request ?? {};
1439
+ return this._http.request({
1440
+ method: "POST",
1441
+ path: "/api/v1/documents",
1442
+ query: void 0,
1443
+ body: toMultipartBody(body),
1444
+ ...mergeRequestOptions(requestOptions)
1445
+ });
1446
+ }
1447
+ /**
1448
+ * Get Document
1449
+ *
1450
+ * Read one knowledge base document and its indexing status. Requires `documents:read`.
1451
+ *
1452
+ * `GET /api/v1/documents/{documentId}`
1453
+ */
1454
+ get(request, requestOptions) {
1455
+ const { documentId, organizationId } = request ?? {};
1456
+ return this._http.request({
1457
+ method: "GET",
1458
+ path: `/api/v1/documents/${encodePathParam("documentId", documentId)}`,
1459
+ query: { organizationId },
1460
+ body: void 0,
1461
+ ...mergeRequestOptions(requestOptions)
1462
+ });
1463
+ }
1464
+ };
1071
1465
  var EvaluateClient = class {
1072
1466
  constructor(_http) {
1073
1467
  this._http = _http;
@@ -1969,6 +2363,25 @@ var ProductsClient = class {
1969
2363
  ...mergeRequestOptions(requestOptions)
1970
2364
  });
1971
2365
  }
2366
+ /**
2367
+ * Upload Product Image
2368
+ *
2369
+ * Upload one image to a product's or variant's gallery as multipart/form-data. Requires `catalog:write`.
2370
+
2371
+ 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.
2372
+ *
2373
+ * `POST /api/v1/products/{productId}/images`
2374
+ */
2375
+ uploadImage(request, requestOptions) {
2376
+ const { productId, ...body } = request ?? {};
2377
+ return this._http.request({
2378
+ method: "POST",
2379
+ path: `/api/v1/products/${encodePathParam("productId", productId)}/images`,
2380
+ query: void 0,
2381
+ body: toMultipartBody(body),
2382
+ ...mergeRequestOptions(requestOptions)
2383
+ });
2384
+ }
1972
2385
  /**
1973
2386
  * Update Product Inventory
1974
2387
  *
@@ -2298,17 +2711,19 @@ var PromotionsClient = class {
2298
2711
  });
2299
2712
  }
2300
2713
  /**
2301
- * Sync Promotion to Marketplaces
2302
- *
2303
- * Queue marketplace push for assigned products (Shopee promotion, Lazada Store Flash Sale/voucher/Flexicombo, TikTok activity, or Shopify discount). Requires `promotions:write`.
2304
- *
2305
- * `POST /api/v1/promotions/{promotionId}/sync`
2306
- */
2307
- sync(request, requestOptions) {
2714
+ * Retry Marketplace Delivery
2715
+ *
2716
+ * Run marketplace delivery again after a failure, for example once a store is reconnected. Requires `promotions:write`.
2717
+
2718
+ 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.
2719
+ *
2720
+ * `POST /api/v1/promotions/{promotionId}/retry`
2721
+ */
2722
+ retry(request, requestOptions) {
2308
2723
  const { promotionId, organizationId, ...body } = request ?? {};
2309
2724
  return this._http.request({
2310
2725
  method: "POST",
2311
- path: `/api/v1/promotions/${encodePathParam("promotionId", promotionId)}/sync`,
2726
+ path: `/api/v1/promotions/${encodePathParam("promotionId", promotionId)}/retry`,
2312
2727
  query: { organizationId },
2313
2728
  body,
2314
2729
  ...mergeRequestOptions(requestOptions)
@@ -2974,12 +3389,12 @@ var OmniGeneratedClient = class {
2974
3389
  this.agents = new AgentsClient(this._http);
2975
3390
  this.analytics = new AnalyticsClient(this._http);
2976
3391
  this.aop = new AopClient(this._http);
2977
- this.api = new ApiClient(this._http);
2978
3392
  this.campaigns = new CampaignsClient(this._http);
2979
3393
  this.catalog = new CatalogClient(this._http);
2980
3394
  this.checkoutSessions = new CheckoutSessionsClient(this._http);
2981
3395
  this.compare = new CompareClient(this._http);
2982
3396
  this.directory = new DirectoryClient(this._http);
3397
+ this.documents = new DocumentsClient(this._http);
2983
3398
  this.evaluate = new EvaluateClient(this._http);
2984
3399
  this.feed = new FeedClient(this._http);
2985
3400
  this.images = new ImagesClient(this._http);
@@ -3010,12 +3425,12 @@ var OmniGeneratedClient = class {
3010
3425
  agents;
3011
3426
  analytics;
3012
3427
  aop;
3013
- api;
3014
3428
  campaigns;
3015
3429
  catalog;
3016
3430
  checkoutSessions;
3017
3431
  compare;
3018
3432
  directory;
3433
+ documents;
3019
3434
  evaluate;
3020
3435
  feed;
3021
3436
  images;