@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.js CHANGED
@@ -24,7 +24,7 @@ function normalizeClientOptions(options = {}) {
24
24
  }
25
25
 
26
26
  // src/version.ts
27
- var SDK_VERSION = "0.3.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() === "") {
@@ -580,37 +592,415 @@ var AnalyticsClient = class {
580
592
  }
581
593
  _http;
582
594
  /**
583
- * Get Sales Analytics
595
+ * Get Ads Analytics
596
+ *
597
+ * 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`.
598
+
599
+ Amounts are in `data.filters.currency`. The periods count back from the end of the range.
600
+ *
601
+ * `GET /api/v1/analytics/ads`
602
+ */
603
+ getAds(request = {}, requestOptions) {
604
+ const {
605
+ organizationId,
606
+ from,
607
+ to,
608
+ timeZone,
609
+ marketplace,
610
+ country,
611
+ store,
612
+ currency
613
+ } = request ?? {};
614
+ return this._http.request({
615
+ method: "GET",
616
+ path: "/api/v1/analytics/ads",
617
+ query: {
618
+ organizationId,
619
+ from,
620
+ to,
621
+ timeZone,
622
+ marketplace,
623
+ country,
624
+ store,
625
+ currency
626
+ },
627
+ body: void 0,
628
+ ...mergeRequestOptions(requestOptions)
629
+ });
630
+ }
631
+ /**
632
+ * Get AI Traffic Analytics
633
+ *
634
+ * 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`.
635
+
636
+ A range covers at most 365 days; a longer one is shortened to the last 365 days. Read the applied range from `data.filters`.
637
+ *
638
+ * `GET /api/v1/analytics/ai-traffic`
639
+ */
640
+ getAiTraffic(request = {}, requestOptions) {
641
+ const {
642
+ organizationId,
643
+ from,
644
+ to,
645
+ timeZone,
646
+ source,
647
+ trafficType,
648
+ route,
649
+ country
650
+ } = request ?? {};
651
+ return this._http.request({
652
+ method: "GET",
653
+ path: "/api/v1/analytics/ai-traffic",
654
+ query: {
655
+ organizationId,
656
+ from,
657
+ to,
658
+ timeZone,
659
+ source,
660
+ trafficType,
661
+ route,
662
+ country
663
+ },
664
+ body: void 0,
665
+ ...mergeRequestOptions(requestOptions)
666
+ });
667
+ }
668
+ /**
669
+ * Get Video and LIVE Analytics
670
+ *
671
+ * 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`.
672
+
673
+ Amounts are in `data.filters.currency`. Only orders in that currency are counted; nothing is converted. A range covers at most 366 days.
674
+ *
675
+ * `GET /api/v1/analytics/content`
676
+ */
677
+ getContent(request = {}, requestOptions) {
678
+ const {
679
+ organizationId,
680
+ from,
681
+ to,
682
+ timeZone,
683
+ marketplace,
684
+ country,
685
+ store,
686
+ currency
687
+ } = request ?? {};
688
+ return this._http.request({
689
+ method: "GET",
690
+ path: "/api/v1/analytics/content",
691
+ query: {
692
+ organizationId,
693
+ from,
694
+ to,
695
+ timeZone,
696
+ marketplace,
697
+ country,
698
+ store,
699
+ currency
700
+ },
701
+ body: void 0,
702
+ ...mergeRequestOptions(requestOptions)
703
+ });
704
+ }
705
+ /**
706
+ * Get Order Analytics
707
+ *
708
+ * 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`.
709
+
710
+ Amounts are in `data.filters.currency`. Only orders in that currency are counted; nothing is converted. A range covers at most 366 days.
711
+ *
712
+ * `GET /api/v1/analytics/orders`
713
+ */
714
+ getOrders(request = {}, requestOptions) {
715
+ const {
716
+ organizationId,
717
+ from,
718
+ to,
719
+ timeZone,
720
+ marketplace,
721
+ country,
722
+ store,
723
+ currency
724
+ } = request ?? {};
725
+ return this._http.request({
726
+ method: "GET",
727
+ path: "/api/v1/analytics/orders",
728
+ query: {
729
+ organizationId,
730
+ from,
731
+ to,
732
+ timeZone,
733
+ marketplace,
734
+ country,
735
+ store,
736
+ currency
737
+ },
738
+ body: void 0,
739
+ ...mergeRequestOptions(requestOptions)
740
+ });
741
+ }
742
+ /**
743
+ * Get Growth Overview
744
+ *
745
+ * 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`.
746
+
747
+ Amounts are in `data.filters.currency`. Only orders in that currency are counted; nothing is converted. A range covers at most 366 days.
748
+ *
749
+ * `GET /api/v1/analytics/overview`
750
+ */
751
+ getOverview(request = {}, requestOptions) {
752
+ const {
753
+ organizationId,
754
+ from,
755
+ to,
756
+ timeZone,
757
+ marketplace,
758
+ country,
759
+ store,
760
+ currency
761
+ } = request ?? {};
762
+ return this._http.request({
763
+ method: "GET",
764
+ path: "/api/v1/analytics/overview",
765
+ query: {
766
+ organizationId,
767
+ from,
768
+ to,
769
+ timeZone,
770
+ marketplace,
771
+ country,
772
+ store,
773
+ currency
774
+ },
775
+ body: void 0,
776
+ ...mergeRequestOptions(requestOptions)
777
+ });
778
+ }
779
+ /**
780
+ * Get Pricing Analytics
781
+ *
782
+ * Selling products with their margin, velocity, stock cover, prices, competitor median, and a pricing recommendation. Matches the Pricing page. Requires `analytics:read`.
783
+
784
+ Amounts are in `data.filters.currency`. Only orders in that currency are counted; nothing is converted. A range covers at most 366 days.
785
+ *
786
+ * `GET /api/v1/analytics/pricing`
787
+ */
788
+ getPricing(request = {}, requestOptions) {
789
+ const {
790
+ organizationId,
791
+ from,
792
+ to,
793
+ timeZone,
794
+ marketplace,
795
+ country,
796
+ store,
797
+ currency
798
+ } = request ?? {};
799
+ return this._http.request({
800
+ method: "GET",
801
+ path: "/api/v1/analytics/pricing",
802
+ query: {
803
+ organizationId,
804
+ from,
805
+ to,
806
+ timeZone,
807
+ marketplace,
808
+ country,
809
+ store,
810
+ currency
811
+ },
812
+ body: void 0,
813
+ ...mergeRequestOptions(requestOptions)
814
+ });
815
+ }
816
+ /**
817
+ * Get Product Analytics
818
+ *
819
+ * 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`.
820
+
821
+ Amounts are in `data.filters.currency`. Only orders in that currency are counted; nothing is converted. A range covers at most 366 days.
822
+ *
823
+ * `GET /api/v1/analytics/products`
824
+ */
825
+ getProducts(request = {}, requestOptions) {
826
+ const {
827
+ organizationId,
828
+ from,
829
+ to,
830
+ timeZone,
831
+ marketplace,
832
+ country,
833
+ store,
834
+ currency,
835
+ q,
836
+ productId,
837
+ limit
838
+ } = request ?? {};
839
+ return this._http.request({
840
+ method: "GET",
841
+ path: "/api/v1/analytics/products",
842
+ query: {
843
+ organizationId,
844
+ from,
845
+ to,
846
+ timeZone,
847
+ marketplace,
848
+ country,
849
+ store,
850
+ currency,
851
+ q,
852
+ productId,
853
+ limit
854
+ },
855
+ body: void 0,
856
+ ...mergeRequestOptions(requestOptions)
857
+ });
858
+ }
859
+ /**
860
+ * Get Profit Analytics
584
861
  *
585
- * 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`.
862
+ * 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`.
586
863
 
587
864
  Amounts are in `data.filters.currency`. Only orders in that currency are counted; nothing is converted. A range covers at most 366 days.
588
865
  *
589
- * `GET /api/v1/analytics/sales`
866
+ * `GET /api/v1/analytics/profit`
590
867
  */
591
- getSales(request = {}, requestOptions) {
868
+ getProfit(request = {}, requestOptions) {
592
869
  const {
593
870
  organizationId,
594
871
  from,
595
872
  to,
873
+ timeZone,
596
874
  marketplace,
597
875
  country,
598
876
  store,
599
877
  currency,
600
- timeZone
878
+ sku
601
879
  } = request ?? {};
602
880
  return this._http.request({
603
881
  method: "GET",
604
- path: "/api/v1/analytics/sales",
882
+ path: "/api/v1/analytics/profit",
605
883
  query: {
606
884
  organizationId,
607
885
  from,
608
886
  to,
887
+ timeZone,
609
888
  marketplace,
610
889
  country,
611
890
  store,
612
891
  currency,
613
- timeZone
892
+ sku
893
+ },
894
+ body: void 0,
895
+ ...mergeRequestOptions(requestOptions)
896
+ });
897
+ }
898
+ /**
899
+ * Get Business Report
900
+ *
901
+ * The management summary: headline KPIs, top products, sales by marketplace, alerts, settlement totals, and data quality. Matches the Business Reports page. Requires `analytics:read`.
902
+
903
+ Amounts are in `data.filters.currency`. Only orders in that currency are counted; nothing is converted. A range covers at most 366 days.
904
+ *
905
+ * `GET /api/v1/analytics/reports`
906
+ */
907
+ getReports(request = {}, requestOptions) {
908
+ const {
909
+ organizationId,
910
+ from,
911
+ to,
912
+ timeZone,
913
+ marketplace,
914
+ country,
915
+ store,
916
+ currency
917
+ } = request ?? {};
918
+ return this._http.request({
919
+ method: "GET",
920
+ path: "/api/v1/analytics/reports",
921
+ query: {
922
+ organizationId,
923
+ from,
924
+ to,
925
+ timeZone,
926
+ marketplace,
927
+ country,
928
+ store,
929
+ currency
930
+ },
931
+ body: void 0,
932
+ ...mergeRequestOptions(requestOptions)
933
+ });
934
+ }
935
+ /**
936
+ * Get Store Analytics
937
+ *
938
+ * 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`.
939
+
940
+ Amounts are in `data.filters.currency`. Only orders in that currency are counted; nothing is converted. A range covers at most 366 days.
941
+ *
942
+ * `GET /api/v1/analytics/stores`
943
+ */
944
+ getStores(request = {}, requestOptions) {
945
+ const {
946
+ organizationId,
947
+ from,
948
+ to,
949
+ timeZone,
950
+ marketplace,
951
+ country,
952
+ store,
953
+ currency
954
+ } = request ?? {};
955
+ return this._http.request({
956
+ method: "GET",
957
+ path: "/api/v1/analytics/stores",
958
+ query: {
959
+ organizationId,
960
+ from,
961
+ to,
962
+ timeZone,
963
+ marketplace,
964
+ country,
965
+ store,
966
+ currency
967
+ },
968
+ body: void 0,
969
+ ...mergeRequestOptions(requestOptions)
970
+ });
971
+ }
972
+ /**
973
+ * Get Traffic Analytics
974
+ *
975
+ * 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`.
976
+
977
+ Amounts are in `data.filters.currency`. Only orders in that currency are counted; nothing is converted. A range covers at most 366 days.
978
+ *
979
+ * `GET /api/v1/analytics/traffic`
980
+ */
981
+ getTraffic(request = {}, requestOptions) {
982
+ const {
983
+ organizationId,
984
+ from,
985
+ to,
986
+ timeZone,
987
+ marketplace,
988
+ country,
989
+ store,
990
+ currency
991
+ } = request ?? {};
992
+ return this._http.request({
993
+ method: "GET",
994
+ path: "/api/v1/analytics/traffic",
995
+ query: {
996
+ organizationId,
997
+ from,
998
+ to,
999
+ timeZone,
1000
+ marketplace,
1001
+ country,
1002
+ store,
1003
+ currency
614
1004
  },
615
1005
  body: void 0,
616
1006
  ...mergeRequestOptions(requestOptions)
@@ -708,44 +1098,6 @@ var AopClient = class {
708
1098
  });
709
1099
  }
710
1100
  };
711
- var ApiClient = class {
712
- constructor(_http) {
713
- this._http = _http;
714
- }
715
- _http;
716
- /**
717
- * API Root
718
- *
719
- * Public API discovery root. Merchant payments are handled by organization-scoped checkout session endpoints.
720
- *
721
- * `GET /api`
722
- */
723
- root(requestOptions) {
724
- return this._http.request({
725
- method: "GET",
726
- path: "/api",
727
- query: void 0,
728
- body: void 0,
729
- ...mergeRequestOptions(requestOptions)
730
- });
731
- }
732
- /**
733
- * API v1 Root
734
- *
735
- * Public API v1 discovery root. Merchant payments are handled by organization-scoped checkout session endpoints.
736
- *
737
- * `GET /api/v1`
738
- */
739
- v1(requestOptions) {
740
- return this._http.request({
741
- method: "GET",
742
- path: "/api/v1",
743
- query: void 0,
744
- body: void 0,
745
- ...mergeRequestOptions(requestOptions)
746
- });
747
- }
748
- };
749
1101
  var CampaignsClient = class {
750
1102
  constructor(_http) {
751
1103
  this._http = _http;
@@ -1066,6 +1418,48 @@ var DirectoryClient = class {
1066
1418
  });
1067
1419
  }
1068
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
+ };
1069
1463
  var EvaluateClient = class {
1070
1464
  constructor(_http) {
1071
1465
  this._http = _http;
@@ -1967,6 +2361,25 @@ var ProductsClient = class {
1967
2361
  ...mergeRequestOptions(requestOptions)
1968
2362
  });
1969
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
+ }
1970
2383
  /**
1971
2384
  * Update Product Inventory
1972
2385
  *
@@ -2296,17 +2709,19 @@ var PromotionsClient = class {
2296
2709
  });
2297
2710
  }
2298
2711
  /**
2299
- * Sync Promotion to Marketplaces
2300
- *
2301
- * Queue marketplace push for assigned products (Shopee promotion, Lazada Store Flash Sale/voucher/Flexicombo, TikTok activity, or Shopify discount). Requires `promotions:write`.
2302
- *
2303
- * `POST /api/v1/promotions/{promotionId}/sync`
2304
- */
2305
- 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) {
2306
2721
  const { promotionId, organizationId, ...body } = request ?? {};
2307
2722
  return this._http.request({
2308
2723
  method: "POST",
2309
- path: `/api/v1/promotions/${encodePathParam("promotionId", promotionId)}/sync`,
2724
+ path: `/api/v1/promotions/${encodePathParam("promotionId", promotionId)}/retry`,
2310
2725
  query: { organizationId },
2311
2726
  body,
2312
2727
  ...mergeRequestOptions(requestOptions)
@@ -2972,12 +3387,12 @@ var OmniGeneratedClient = class {
2972
3387
  this.agents = new AgentsClient(this._http);
2973
3388
  this.analytics = new AnalyticsClient(this._http);
2974
3389
  this.aop = new AopClient(this._http);
2975
- this.api = new ApiClient(this._http);
2976
3390
  this.campaigns = new CampaignsClient(this._http);
2977
3391
  this.catalog = new CatalogClient(this._http);
2978
3392
  this.checkoutSessions = new CheckoutSessionsClient(this._http);
2979
3393
  this.compare = new CompareClient(this._http);
2980
3394
  this.directory = new DirectoryClient(this._http);
3395
+ this.documents = new DocumentsClient(this._http);
2981
3396
  this.evaluate = new EvaluateClient(this._http);
2982
3397
  this.feed = new FeedClient(this._http);
2983
3398
  this.images = new ImagesClient(this._http);
@@ -3008,12 +3423,12 @@ var OmniGeneratedClient = class {
3008
3423
  agents;
3009
3424
  analytics;
3010
3425
  aop;
3011
- api;
3012
3426
  campaigns;
3013
3427
  catalog;
3014
3428
  checkoutSessions;
3015
3429
  compare;
3016
3430
  directory;
3431
+ documents;
3017
3432
  evaluate;
3018
3433
  feed;
3019
3434
  images;