@viu/emporix-sdk 2.7.0 → 2.9.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.
Files changed (76) hide show
  1. package/CHANGELOG.md +75 -0
  2. package/dist/cart.cjs +9 -3
  3. package/dist/cart.cjs.map +1 -1
  4. package/dist/cart.d.cts +9 -2
  5. package/dist/cart.d.ts +9 -2
  6. package/dist/cart.js +1 -1
  7. package/dist/{chunk-5JHTZBOC.js → chunk-B4UOYJKW.js} +12 -2
  8. package/dist/chunk-B4UOYJKW.js.map +1 -0
  9. package/dist/{chunk-SCI7D74B.js → chunk-BK25FDTH.js} +17 -5
  10. package/dist/chunk-BK25FDTH.js.map +1 -0
  11. package/dist/{chunk-B56JZNI7.js → chunk-HAEVK6IS.js} +6 -3
  12. package/dist/chunk-HAEVK6IS.js.map +1 -0
  13. package/dist/{chunk-IEZHGU7F.js → chunk-I3YYGSN2.js} +11 -5
  14. package/dist/chunk-I3YYGSN2.js.map +1 -0
  15. package/dist/{chunk-6UNFMCHZ.js → chunk-KVBCTXVH.js} +2 -2
  16. package/dist/chunk-KVBCTXVH.js.map +1 -0
  17. package/dist/{chunk-NM7VDXBR.js → chunk-LGLFJL3S.js} +6 -3
  18. package/dist/chunk-LGLFJL3S.js.map +1 -0
  19. package/dist/chunk-LGOC5XOI.js +40 -0
  20. package/dist/chunk-LGOC5XOI.js.map +1 -0
  21. package/dist/{chunk-RXVVFNYN.js → chunk-MM6JF3Z7.js} +6 -3
  22. package/dist/chunk-MM6JF3Z7.js.map +1 -0
  23. package/dist/companies.cjs +4 -1
  24. package/dist/companies.cjs.map +1 -1
  25. package/dist/companies.d.cts +7 -4
  26. package/dist/companies.d.ts +7 -4
  27. package/dist/companies.js +1 -1
  28. package/dist/contacts.cjs +4 -1
  29. package/dist/contacts.cjs.map +1 -1
  30. package/dist/contacts.d.cts +6 -4
  31. package/dist/contacts.d.ts +6 -4
  32. package/dist/contacts.js +1 -1
  33. package/dist/customer-groups.cjs +17 -0
  34. package/dist/customer-groups.cjs.map +1 -1
  35. package/dist/customer-groups.d.cts +94 -21
  36. package/dist/customer-groups.d.ts +94 -21
  37. package/dist/customer-groups.js +1 -1
  38. package/dist/index.cjs +72 -10
  39. package/dist/index.cjs.map +1 -1
  40. package/dist/index.d.cts +13 -5
  41. package/dist/index.d.ts +13 -5
  42. package/dist/index.js +25 -18
  43. package/dist/index.js.map +1 -1
  44. package/dist/locations.cjs +4 -1
  45. package/dist/locations.cjs.map +1 -1
  46. package/dist/locations.d.cts +7 -4
  47. package/dist/locations.d.ts +7 -4
  48. package/dist/locations.js +1 -1
  49. package/dist/orders.cjs.map +1 -1
  50. package/dist/orders.d.cts +1726 -80
  51. package/dist/orders.d.ts +1726 -80
  52. package/dist/orders.js +1 -1
  53. package/dist/price.cjs +15 -3
  54. package/dist/price.cjs.map +1 -1
  55. package/dist/price.d.cts +23 -4
  56. package/dist/price.d.ts +23 -4
  57. package/dist/price.js +1 -1
  58. package/dist/product.cjs +10 -0
  59. package/dist/product.cjs.map +1 -1
  60. package/dist/product.d.cts +10 -0
  61. package/dist/product.d.ts +10 -0
  62. package/dist/product.js +1 -1
  63. package/dist/types.gen-C_wOXYZB.d.cts +455 -0
  64. package/dist/types.gen-C_wOXYZB.d.ts +455 -0
  65. package/package.json +1 -1
  66. package/dist/chunk-5JHTZBOC.js.map +0 -1
  67. package/dist/chunk-6UNFMCHZ.js.map +0 -1
  68. package/dist/chunk-B56JZNI7.js.map +0 -1
  69. package/dist/chunk-IEZHGU7F.js.map +0 -1
  70. package/dist/chunk-NM7VDXBR.js.map +0 -1
  71. package/dist/chunk-RXVVFNYN.js.map +0 -1
  72. package/dist/chunk-SCI7D74B.js.map +0 -1
  73. package/dist/chunk-SKX7KCMH.js +0 -23
  74. package/dist/chunk-SKX7KCMH.js.map +0 -1
  75. package/dist/types.gen-D1QuqPLs.d.cts +0 -166
  76. package/dist/types.gen-D1QuqPLs.d.ts +0 -166
package/dist/index.cjs CHANGED
@@ -1001,6 +1001,16 @@ var ProductService = class {
1001
1001
  });
1002
1002
  return { items, pageNumber, pageSize, hasNextPage: items.length === pageSize };
1003
1003
  }
1004
+ /**
1005
+ * Free-text product search by name. The product `q` is a `field:value` DSL,
1006
+ * so a bare term (e.g. "in time") 400s with "No value for key …". This builds
1007
+ * a `name:(~<term>)` regex filter (regex metacharacters escaped) and delegates
1008
+ * to {@link search}.
1009
+ */
1010
+ async searchByName(query, params = {}, auth2 = ANON) {
1011
+ const escaped = query.trim().replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1012
+ return this.search(`name:(~${escaped})`, params, auth2);
1013
+ }
1004
1014
  /**
1005
1015
  * Bulk fetch by id. POSTs `/products/search` with `q="id:(id1,id2,…)"`,
1006
1016
  * chunking when the list is larger than `options.chunkSize` (default
@@ -1302,13 +1312,19 @@ var CartService = class {
1302
1312
  body: items
1303
1313
  });
1304
1314
  }
1305
- /** Updates an item. */
1306
- async updateItem(cartId, itemId, patch, auth2) {
1315
+ /**
1316
+ * Updates an item. By default this is a **full replace** — the server expects
1317
+ * the complete item (e.g. `itemYrn` + the `price` row). Pass
1318
+ * `{ partial: true }` to send a **partial update** (`?partial=true`), e.g. a
1319
+ * quantity-only change with just `{ quantity }`.
1320
+ */
1321
+ async updateItem(cartId, itemId, patch, auth2, opts = {}) {
1307
1322
  return this.ctx.http.request({
1308
1323
  method: "PUT",
1309
1324
  path: `${this.base()}/${cartId}/items/${itemId}`,
1310
1325
  auth: requireCartAuth(auth2),
1311
- body: patch
1326
+ body: patch,
1327
+ ...opts.partial ? { query: { partial: "true" } } : {}
1312
1328
  });
1313
1329
  }
1314
1330
  /** Removes an item. */
@@ -1458,6 +1474,16 @@ var PaymentGatewayService = class {
1458
1474
  };
1459
1475
 
1460
1476
  // src/services/price.ts
1477
+ function normalizeMatch(raw) {
1478
+ const itemId = raw.itemId ?? raw.itemRef;
1479
+ const base = raw;
1480
+ if (!itemId) return base;
1481
+ const itemRef = {
1482
+ ...itemId.itemType !== void 0 ? { itemType: itemId.itemType } : {},
1483
+ ...itemId.id !== void 0 ? { id: itemId.id } : {}
1484
+ };
1485
+ return { ...base, itemId, itemRef };
1486
+ }
1461
1487
  var ANON3 = { kind: "anonymous" };
1462
1488
  var SERVICE = { kind: "service" };
1463
1489
  function requireContextAuth(auth2) {
@@ -1478,24 +1504,26 @@ var PriceService = class {
1478
1504
  * anonymous; pass a customer/raw context for personalized pricing.
1479
1505
  */
1480
1506
  async matchByContext(input, auth2) {
1481
- return this.ctx.http.request({
1507
+ const rows = await this.ctx.http.request({
1482
1508
  method: "POST",
1483
1509
  path: `/price/${this.ctx.tenant}/match-prices-by-context`,
1484
1510
  auth: requireContextAuth(auth2),
1485
1511
  body: input
1486
1512
  });
1513
+ return rows.map(normalizeMatch);
1487
1514
  }
1488
1515
  /**
1489
1516
  * Resolves prices from an explicit context. Default auth: service
1490
1517
  * (requires `price.price_read` / `price.price_manage`).
1491
1518
  */
1492
1519
  async match(input, auth2 = SERVICE) {
1493
- return this.ctx.http.request({
1520
+ const rows = await this.ctx.http.request({
1494
1521
  method: "POST",
1495
1522
  path: `/price/${this.ctx.tenant}/match-prices`,
1496
1523
  auth: auth2,
1497
1524
  body: input
1498
1525
  });
1526
+ return rows.map(normalizeMatch);
1499
1527
  }
1500
1528
  /**
1501
1529
  * Chunked variant of {@link matchByContext} for large `items` arrays. The
@@ -1508,7 +1536,7 @@ var PriceService = class {
1508
1536
  * `throwOnAnyChunkError: true` to reject on the first failure instead.
1509
1537
  *
1510
1538
  * **Result order is not guaranteed** — match entries back to your items by
1511
- * `priceId` / `itemRef.id`.
1539
+ * `priceId` / `itemId.id`.
1512
1540
  */
1513
1541
  async matchByContextChunked(input, opts = {}, auth2) {
1514
1542
  const chunkSize = opts.chunkSize ?? 50;
@@ -2058,7 +2086,10 @@ var CompaniesService = class {
2058
2086
  body: input
2059
2087
  });
2060
2088
  }
2061
- /** Patches a legal entity. */
2089
+ /**
2090
+ * Patches a legal entity. The endpoint is a PATCH, so the body is a partial
2091
+ * of the generated `LegalEntityUpdate` (full-replace) shape.
2092
+ */
2062
2093
  async update(legalEntityId, patch, auth2) {
2063
2094
  return this.ctx.http.request({
2064
2095
  method: "PATCH",
@@ -2104,7 +2135,10 @@ var ContactsService = class {
2104
2135
  body: input
2105
2136
  });
2106
2137
  }
2107
- /** Patches a contact assignment. */
2138
+ /**
2139
+ * Patches a contact assignment. PATCH endpoint, so the body is a partial of
2140
+ * the generated `ContactAssignmentUpdate` shape.
2141
+ */
2108
2142
  async update(contactAssignmentId, patch, auth2) {
2109
2143
  return this.ctx.http.request({
2110
2144
  method: "PATCH",
@@ -2158,7 +2192,10 @@ var LocationsService = class {
2158
2192
  body: input
2159
2193
  });
2160
2194
  }
2161
- /** Patches a location. */
2195
+ /**
2196
+ * Patches a location. PATCH endpoint, so the body is a partial of the
2197
+ * generated `LocationUpdate` shape.
2198
+ */
2162
2199
  async update(locationId, patch, auth2) {
2163
2200
  return this.ctx.http.request({
2164
2201
  method: "PATCH",
@@ -2195,6 +2232,23 @@ var CustomerGroupsService = class {
2195
2232
  auth: auth2
2196
2233
  });
2197
2234
  }
2235
+ /** Adds a user (customer or employee) to a group. */
2236
+ async addMember(groupId, member, auth2) {
2237
+ return this.ctx.http.request({
2238
+ method: "POST",
2239
+ path: `${this.base()}/${groupId}/users`,
2240
+ auth: auth2,
2241
+ body: member
2242
+ });
2243
+ }
2244
+ /** Removes a user from a group. */
2245
+ async removeMember(groupId, userId, auth2) {
2246
+ await this.ctx.http.request({
2247
+ method: "DELETE",
2248
+ path: `${this.base()}/${groupId}/users/${userId}`,
2249
+ auth: auth2
2250
+ });
2251
+ }
2198
2252
  };
2199
2253
 
2200
2254
  // src/services/orders.ts
@@ -5014,7 +5068,7 @@ var ApprovalService = class {
5014
5068
  };
5015
5069
 
5016
5070
  // package.json
5017
- var version = "2.7.0";
5071
+ var version = "2.9.0";
5018
5072
 
5019
5073
  // src/version.ts
5020
5074
  var SDK_VERSION = version;
@@ -5185,6 +5239,13 @@ var EmporixClient = class {
5185
5239
  }
5186
5240
  };
5187
5241
 
5242
+ // src/core/yrn.ts
5243
+ function productIdFromYrn(yrn) {
5244
+ if (!yrn) return "";
5245
+ const semi = yrn.lastIndexOf(";");
5246
+ return semi >= 0 ? yrn.slice(semi + 1) : "";
5247
+ }
5248
+
5188
5249
  exports.AiService = AiService;
5189
5250
  exports.ApprovalService = ApprovalService;
5190
5251
  exports.AvailabilityService = AvailabilityService;
@@ -5248,6 +5309,7 @@ exports.createConsoleLogger = createConsoleLogger;
5248
5309
  exports.createNoopLogger = createNoopLogger;
5249
5310
  exports.errorFromResponse = errorFromResponse;
5250
5311
  exports.iterateAll = iterateAll;
5312
+ exports.productIdFromYrn = productIdFromYrn;
5251
5313
  exports.redact = redact;
5252
5314
  exports.resolveToken = resolveToken;
5253
5315
  exports.validateConfig = validateConfig;