@commercengine/storefront-sdk 0.13.2 → 0.13.4
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.d.mts +160 -67
- package/dist/index.iife.js +64 -17
- package/dist/index.iife.js.map +1 -1
- package/dist/index.mjs +64 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.iife.js
CHANGED
|
@@ -1501,7 +1501,7 @@ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toString
|
|
|
1501
1501
|
/**
|
|
1502
1502
|
* Get details for a specific product
|
|
1503
1503
|
*
|
|
1504
|
-
* @param pathParams - The path parameters
|
|
1504
|
+
* @param pathParams - The path parameters. Accepts product ID or product slug.
|
|
1505
1505
|
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
1506
1506
|
* @returns Promise with product details
|
|
1507
1507
|
*
|
|
@@ -1509,7 +1509,7 @@ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toString
|
|
|
1509
1509
|
* ```typescript
|
|
1510
1510
|
* // Get product by ID
|
|
1511
1511
|
* const { data, error } = await sdk.catalog.getProductDetail(
|
|
1512
|
-
* {
|
|
1512
|
+
* { product_id: "prod_123" }
|
|
1513
1513
|
* );
|
|
1514
1514
|
*
|
|
1515
1515
|
* if (error) {
|
|
@@ -1521,14 +1521,15 @@ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toString
|
|
|
1521
1521
|
* console.log("Price:", data.product.pricing?.selling_price);
|
|
1522
1522
|
* console.log("Description:", data.product.short_description);
|
|
1523
1523
|
*
|
|
1524
|
-
* // Get product by slug
|
|
1524
|
+
* // Get product by slug (also accepted in place of product_id)
|
|
1525
1525
|
* const { data: slugData, error: slugError } = await sdk.catalog.getProductDetail({
|
|
1526
|
-
*
|
|
1526
|
+
* product_id: "detox-candy"
|
|
1527
1527
|
* });
|
|
1528
1528
|
*
|
|
1529
1529
|
* // Override customer group ID for this specific request
|
|
1530
1530
|
* const { data: overrideData, error: overrideError } = await sdk.catalog.getProductDetail(
|
|
1531
|
-
* {
|
|
1531
|
+
* { product_id: "detox-candy" },
|
|
1532
|
+
* undefined,
|
|
1532
1533
|
* {
|
|
1533
1534
|
* "x-customer-group-id": "premium_customers" // Override default SDK config
|
|
1534
1535
|
* }
|
|
@@ -1544,7 +1545,7 @@ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toString
|
|
|
1544
1545
|
*/
|
|
1545
1546
|
async getProductDetail(pathParams, options, headers) {
|
|
1546
1547
|
const mergedHeaders = this.mergeHeaders(headers);
|
|
1547
|
-
return this.executeRequest(() => this.client.GET("/catalog/products/{
|
|
1548
|
+
return this.executeRequest(() => this.client.GET("/catalog/products/{product_id}", { params: {
|
|
1548
1549
|
path: pathParams,
|
|
1549
1550
|
query: options,
|
|
1550
1551
|
header: mergedHeaders
|
|
@@ -1553,12 +1554,13 @@ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toString
|
|
|
1553
1554
|
/**
|
|
1554
1555
|
* List all variants for a specific product
|
|
1555
1556
|
*
|
|
1556
|
-
* @param pathParams - The path parameters
|
|
1557
|
+
* @param pathParams - The path parameters. Accepts product ID or product slug.
|
|
1557
1558
|
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
1558
1559
|
* @returns Promise with product variants and pagination info
|
|
1559
1560
|
*
|
|
1560
1561
|
* @example
|
|
1561
1562
|
* ```typescript
|
|
1563
|
+
* // By product ID
|
|
1562
1564
|
* const { data, error } = await sdk.catalog.listProductVariants(
|
|
1563
1565
|
* { product_id: "prod_123" }
|
|
1564
1566
|
* );
|
|
@@ -1574,9 +1576,15 @@ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toString
|
|
|
1574
1576
|
* console.log(`Variant: ${variant.name} - SKU: ${variant.sku} - Price: ${variant.pricing?.selling_price}`);
|
|
1575
1577
|
* });
|
|
1576
1578
|
*
|
|
1579
|
+
* // By product slug (also accepted in place of product_id)
|
|
1580
|
+
* const { data: slugData, error: slugError } = await sdk.catalog.listProductVariants(
|
|
1581
|
+
* { product_id: "detox-candy" }
|
|
1582
|
+
* );
|
|
1583
|
+
*
|
|
1577
1584
|
* // Override customer group ID for this specific request
|
|
1578
1585
|
* const { data: overrideData, error: overrideError } = await sdk.catalog.listProductVariants(
|
|
1579
1586
|
* { product_id: "prod_123" },
|
|
1587
|
+
* undefined,
|
|
1580
1588
|
* {
|
|
1581
1589
|
* "x-customer-group-id": "wholesale_customers" // Override default SDK config
|
|
1582
1590
|
* }
|
|
@@ -1594,12 +1602,13 @@ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toString
|
|
|
1594
1602
|
/**
|
|
1595
1603
|
* Get details for a specific product variant
|
|
1596
1604
|
*
|
|
1597
|
-
* @param pathParams - The path parameters
|
|
1605
|
+
* @param pathParams - The path parameters. Accepts product ID or slug for product_id, and variant ID or slug for variant_id.
|
|
1598
1606
|
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
1599
1607
|
* @returns Promise with variant details
|
|
1600
1608
|
*
|
|
1601
1609
|
* @example
|
|
1602
1610
|
* ```typescript
|
|
1611
|
+
* // By product ID and variant ID
|
|
1603
1612
|
* const { data, error } = await sdk.catalog.getVariantDetail(
|
|
1604
1613
|
* {
|
|
1605
1614
|
* product_id: "prod_123",
|
|
@@ -1616,6 +1625,14 @@ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toString
|
|
|
1616
1625
|
* console.log("SKU:", data.variant.sku);
|
|
1617
1626
|
* console.log("Price:", data.variant.pricing?.selling_price);
|
|
1618
1627
|
* console.log("Stock available:", data.variant.stock_available);
|
|
1628
|
+
*
|
|
1629
|
+
* // By product slug and variant slug (also accepted in place of IDs)
|
|
1630
|
+
* const { data: slugData, error: slugError } = await sdk.catalog.getVariantDetail(
|
|
1631
|
+
* {
|
|
1632
|
+
* product_id: "detox-candy",
|
|
1633
|
+
* variant_id: "detox-candy-100g"
|
|
1634
|
+
* }
|
|
1635
|
+
* );
|
|
1619
1636
|
* ```
|
|
1620
1637
|
*/
|
|
1621
1638
|
async getVariantDetail(pathParams, options, headers) {
|
|
@@ -1745,19 +1762,15 @@ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toString
|
|
|
1745
1762
|
/**
|
|
1746
1763
|
* Search for products
|
|
1747
1764
|
*
|
|
1748
|
-
* @param searchData - The search query and
|
|
1765
|
+
* @param searchData - The search query, filters, sort, and pagination options
|
|
1749
1766
|
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
1750
|
-
* @returns Promise with search results including
|
|
1767
|
+
* @returns Promise with search results including SKUs, facet distribution, facet stats, and pagination
|
|
1751
1768
|
*
|
|
1752
1769
|
* @example
|
|
1753
1770
|
* ```typescript
|
|
1771
|
+
* // Basic search
|
|
1754
1772
|
* const { data, error } = await sdk.catalog.searchProducts({
|
|
1755
1773
|
* query: "smartphone",
|
|
1756
|
-
* filters: {
|
|
1757
|
-
* category: ["electronics", "mobile"],
|
|
1758
|
-
* price_range: { min: 100, max: 1000 },
|
|
1759
|
-
* brand: ["Apple", "Samsung"] // facet names depend on product configuration
|
|
1760
|
-
* },
|
|
1761
1774
|
* page: 1,
|
|
1762
1775
|
* limit: 20
|
|
1763
1776
|
* });
|
|
@@ -1769,17 +1782,51 @@ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toString
|
|
|
1769
1782
|
*
|
|
1770
1783
|
* console.log("Search results:", data.skus?.length || 0, "products found");
|
|
1771
1784
|
* console.log("Facet distribution:", data.facet_distribution);
|
|
1772
|
-
* console.log("
|
|
1785
|
+
* console.log("Facet stats:", data.facet_stats);
|
|
1786
|
+
* console.log("Pagination:", data.pagination);
|
|
1773
1787
|
*
|
|
1774
1788
|
* data.skus?.forEach(sku => {
|
|
1775
1789
|
* console.log(`Found: ${sku.product_name} - ${sku.pricing?.selling_price}`);
|
|
1776
1790
|
* });
|
|
1777
1791
|
*
|
|
1792
|
+
* // With filter (string expression — Meilisearch syntax)
|
|
1793
|
+
* const { data: filtered, error: filteredError } = await sdk.catalog.searchProducts({
|
|
1794
|
+
* query: "laptop",
|
|
1795
|
+
* filter: "pricing.selling_price 500 TO 2000 AND product_type = physical",
|
|
1796
|
+
* sort: ["pricing.selling_price:asc"],
|
|
1797
|
+
* facets: ["product_type", "categories.name", "tags"],
|
|
1798
|
+
* page: 1,
|
|
1799
|
+
* limit: 10
|
|
1800
|
+
* });
|
|
1801
|
+
*
|
|
1802
|
+
* // With filter (array of conditions — combined with AND)
|
|
1803
|
+
* const { data: arrayFiltered, error: arrayError } = await sdk.catalog.searchProducts({
|
|
1804
|
+
* query: "shoes",
|
|
1805
|
+
* filter: ["product_type = physical", "rating >= 4", "stock_available > 0"],
|
|
1806
|
+
* sort: ["rating:desc"],
|
|
1807
|
+
* facets: ["*"],
|
|
1808
|
+
* page: 1,
|
|
1809
|
+
* limit: 25
|
|
1810
|
+
* });
|
|
1811
|
+
*
|
|
1812
|
+
* // With filter (nested arrays — inner arrays use OR, outer uses AND)
|
|
1813
|
+
* const { data: nestedFiltered, error: nestedError } = await sdk.catalog.searchProducts({
|
|
1814
|
+
* query: "headphones",
|
|
1815
|
+
* filter: [
|
|
1816
|
+
* "pricing.selling_price 50 TO 300",
|
|
1817
|
+
* ["product_type = physical", "product_type = bundle"]
|
|
1818
|
+
* ],
|
|
1819
|
+
* page: 1,
|
|
1820
|
+
* limit: 25
|
|
1821
|
+
* });
|
|
1822
|
+
*
|
|
1778
1823
|
* // Override customer group ID for this specific request
|
|
1779
1824
|
* const { data: overrideData, error: overrideError } = await sdk.catalog.searchProducts(
|
|
1780
1825
|
* {
|
|
1781
1826
|
* query: "laptop",
|
|
1782
|
-
*
|
|
1827
|
+
* filter: "categories.name = computers",
|
|
1828
|
+
* page: 1,
|
|
1829
|
+
* limit: 20
|
|
1783
1830
|
* },
|
|
1784
1831
|
* {
|
|
1785
1832
|
* "x-customer-group-id": "01H9XYZ12345USERID" // Override default SDK config
|