@commercengine/storefront-sdk 0.13.1 → 0.13.3
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 +154 -64
- package/dist/index.iife.js +39 -9
- package/dist/index.iife.js.map +1 -1
- package/dist/index.mjs +39 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1365,19 +1365,15 @@ var CatalogClient = class extends StorefrontAPIClient {
|
|
|
1365
1365
|
/**
|
|
1366
1366
|
* Search for products
|
|
1367
1367
|
*
|
|
1368
|
-
* @param searchData - The search query and
|
|
1368
|
+
* @param searchData - The search query, filters, sort, and pagination options
|
|
1369
1369
|
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
1370
|
-
* @returns Promise with search results including
|
|
1370
|
+
* @returns Promise with search results including SKUs, facet distribution, facet stats, and pagination
|
|
1371
1371
|
*
|
|
1372
1372
|
* @example
|
|
1373
1373
|
* ```typescript
|
|
1374
|
+
* // Basic search
|
|
1374
1375
|
* const { data, error } = await sdk.catalog.searchProducts({
|
|
1375
1376
|
* query: "smartphone",
|
|
1376
|
-
* filters: {
|
|
1377
|
-
* category: ["electronics", "mobile"],
|
|
1378
|
-
* price_range: { min: 100, max: 1000 },
|
|
1379
|
-
* brand: ["Apple", "Samsung"] // facet names depend on product configuration
|
|
1380
|
-
* },
|
|
1381
1377
|
* page: 1,
|
|
1382
1378
|
* limit: 20
|
|
1383
1379
|
* });
|
|
@@ -1389,17 +1385,51 @@ var CatalogClient = class extends StorefrontAPIClient {
|
|
|
1389
1385
|
*
|
|
1390
1386
|
* console.log("Search results:", data.skus?.length || 0, "products found");
|
|
1391
1387
|
* console.log("Facet distribution:", data.facet_distribution);
|
|
1392
|
-
* console.log("
|
|
1388
|
+
* console.log("Facet stats:", data.facet_stats);
|
|
1389
|
+
* console.log("Pagination:", data.pagination);
|
|
1393
1390
|
*
|
|
1394
1391
|
* data.skus?.forEach(sku => {
|
|
1395
1392
|
* console.log(`Found: ${sku.product_name} - ${sku.pricing?.selling_price}`);
|
|
1396
1393
|
* });
|
|
1397
1394
|
*
|
|
1395
|
+
* // With filter (string expression — Meilisearch syntax)
|
|
1396
|
+
* const { data: filtered, error: filteredError } = await sdk.catalog.searchProducts({
|
|
1397
|
+
* query: "laptop",
|
|
1398
|
+
* filter: "pricing.selling_price 500 TO 2000 AND product_type = physical",
|
|
1399
|
+
* sort: ["pricing.selling_price:asc"],
|
|
1400
|
+
* facets: ["product_type", "categories.name", "tags"],
|
|
1401
|
+
* page: 1,
|
|
1402
|
+
* limit: 10
|
|
1403
|
+
* });
|
|
1404
|
+
*
|
|
1405
|
+
* // With filter (array of conditions — combined with AND)
|
|
1406
|
+
* const { data: arrayFiltered, error: arrayError } = await sdk.catalog.searchProducts({
|
|
1407
|
+
* query: "shoes",
|
|
1408
|
+
* filter: ["product_type = physical", "rating >= 4", "stock_available > 0"],
|
|
1409
|
+
* sort: ["rating:desc"],
|
|
1410
|
+
* facets: ["*"],
|
|
1411
|
+
* page: 1,
|
|
1412
|
+
* limit: 25
|
|
1413
|
+
* });
|
|
1414
|
+
*
|
|
1415
|
+
* // With filter (nested arrays — inner arrays use OR, outer uses AND)
|
|
1416
|
+
* const { data: nestedFiltered, error: nestedError } = await sdk.catalog.searchProducts({
|
|
1417
|
+
* query: "headphones",
|
|
1418
|
+
* filter: [
|
|
1419
|
+
* "pricing.selling_price 50 TO 300",
|
|
1420
|
+
* ["product_type = physical", "product_type = bundle"]
|
|
1421
|
+
* ],
|
|
1422
|
+
* page: 1,
|
|
1423
|
+
* limit: 25
|
|
1424
|
+
* });
|
|
1425
|
+
*
|
|
1398
1426
|
* // Override customer group ID for this specific request
|
|
1399
1427
|
* const { data: overrideData, error: overrideError } = await sdk.catalog.searchProducts(
|
|
1400
1428
|
* {
|
|
1401
1429
|
* query: "laptop",
|
|
1402
|
-
*
|
|
1430
|
+
* filter: "categories.name = computers",
|
|
1431
|
+
* page: 1,
|
|
1432
|
+
* limit: 20
|
|
1403
1433
|
* },
|
|
1404
1434
|
* {
|
|
1405
1435
|
* "x-customer-group-id": "01H9XYZ12345USERID" // Override default SDK config
|