@viu/emporix-sdk 2.28.0 → 2.28.2

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
@@ -890,7 +890,7 @@ var HttpClient = class {
890
890
  };
891
891
 
892
892
  // package.json
893
- var version = "2.28.0";
893
+ var version = "2.28.2";
894
894
 
895
895
  // src/version.ts
896
896
  var SDK_VERSION = version;
@@ -1320,9 +1320,28 @@ var ProductService = class {
1320
1320
  * so a bare term (e.g. "in time") 400s with "No value for key …". This builds
1321
1321
  * a `name:(~<term>)` regex filter (regex metacharacters escaped) and delegates
1322
1322
  * to {@link search}.
1323
+ *
1324
+ * Safe for text a shopper typed: `( ) "` are **removed** rather than escaped,
1325
+ * because Emporix parses the filter's own structure before it looks at the
1326
+ * regex. `name:(~a \()` is rejected with «Missing closing parenthesis in value»
1327
+ * even though the paren is escaped, so a search box would 400 on an opening
1328
+ * bracket. Measured against a live tenant on 2026-08-03: of every regex
1329
+ * metacharacter only those three break; the rest survive escaping.
1330
+ *
1331
+ * A query consisting solely of those characters leaves nothing to search for and
1332
+ * returns an empty page without a request — `name:(~)` is a 400.
1323
1333
  */
1324
1334
  async searchByName(query, params = {}, auth2 = ANON) {
1325
- const escaped = query.trim().replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1335
+ const term = query.replace(/[()"]/g, " ").replace(/\s+/g, " ").trim();
1336
+ if (term === "") {
1337
+ return {
1338
+ items: [],
1339
+ pageNumber: params.pageNumber ?? 1,
1340
+ pageSize: params.pageSize ?? 50,
1341
+ hasNextPage: false
1342
+ };
1343
+ }
1344
+ const escaped = term.replace(/[.*+?^${}|[\]\\]/g, "\\$&");
1326
1345
  return this.search(`name:(~${escaped})`, params, auth2);
1327
1346
  }
1328
1347
  /**
@@ -1662,8 +1681,22 @@ var CategoryService = class {
1662
1681
  }
1663
1682
  /**
1664
1683
  * The catalogue's **root categories** — the published category trees
1665
- * (`GET /category-trees`). Use these for top-level storefront navigation;
1666
- * drill into a node's children with {@link subcategories}.
1684
+ * (`GET /category-trees`).
1685
+ *
1686
+ * Returns `CategoryNode[]` (the generated `CategoryTree`), not `Category[]`.
1687
+ * The two differ: `Category` carries `parentId` and no `subcategories`,
1688
+ * `CategoryTree` the reverse, and this endpoint answers with the latter.
1689
+ * Measured against a live tenant on 2026-08-04 — every node had
1690
+ * `subcategories` or nothing, none had `parentId`.
1691
+ *
1692
+ * **Children arrive inline in `subcategories`.** Do not reach for
1693
+ * {@link subcategories} to drill down: that method reads category-to-category
1694
+ * *assignments* (`/categories/{id}/assignments`, filtered to
1695
+ * `ref.type === "CATEGORY"`), which is a different feature — on the tenant this
1696
+ * was measured on, that filter answered empty for every category while the
1697
+ * `"PRODUCT"` filter behind {@link productsIn} worked fine.
1698
+ * {@link childCategories} hits `/categories/{id}/subcategories` and answers
1699
+ * **404** for a tree root. One call gives you the whole hierarchy.
1667
1700
  */
1668
1701
  async tree(auth2 = ANON2) {
1669
1702
  return this.ctx.http.request({