@viu/emporix-sdk 4.0.0 → 4.1.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 (58) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/dist/{chunk-QQMLN76U.js → chunk-2OTFVTG6.js} +7 -4
  3. package/dist/chunk-2OTFVTG6.js.map +1 -0
  4. package/dist/{chunk-CSYXGTOH.js → chunk-5MPL4XBD.js} +68 -4
  5. package/dist/chunk-5MPL4XBD.js.map +1 -0
  6. package/dist/{chunk-P3RANRGB.js → chunk-IYNT5BQW.js} +16 -2
  7. package/dist/chunk-IYNT5BQW.js.map +1 -0
  8. package/dist/{chunk-ZOFGDNSX.js → chunk-K4KXT6NX.js} +12 -6
  9. package/dist/chunk-K4KXT6NX.js.map +1 -0
  10. package/dist/{chunk-XJJDCK2Z.js → chunk-N2CE3J4M.js} +12 -7
  11. package/dist/chunk-N2CE3J4M.js.map +1 -0
  12. package/dist/{chunk-5XZ6MSXW.js → chunk-VXORPTMP.js} +19 -2
  13. package/dist/chunk-VXORPTMP.js.map +1 -0
  14. package/dist/chunk-ZWJUDXTK.js +15 -0
  15. package/dist/chunk-ZWJUDXTK.js.map +1 -0
  16. package/dist/companies.cjs +15 -2
  17. package/dist/companies.cjs.map +1 -1
  18. package/dist/companies.d.cts +5 -3
  19. package/dist/companies.d.ts +5 -3
  20. package/dist/companies.js +2 -1
  21. package/dist/customer-groups.cjs +17 -0
  22. package/dist/customer-groups.cjs.map +1 -1
  23. package/dist/customer-groups.js +1 -1
  24. package/dist/index.cjs +214 -58
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.d.cts +72 -21
  27. package/dist/index.d.ts +72 -21
  28. package/dist/index.js +97 -57
  29. package/dist/index.js.map +1 -1
  30. package/dist/media.cjs +66 -2
  31. package/dist/media.cjs.map +1 -1
  32. package/dist/media.d.cts +194 -15
  33. package/dist/media.d.ts +194 -15
  34. package/dist/media.js +1 -1
  35. package/dist/orders.cjs +14 -0
  36. package/dist/orders.cjs.map +1 -1
  37. package/dist/orders.d.cts +6 -0
  38. package/dist/orders.d.ts +6 -0
  39. package/dist/orders.js +1 -1
  40. package/dist/price.cjs +20 -4
  41. package/dist/price.cjs.map +1 -1
  42. package/dist/price.d.cts +12 -4
  43. package/dist/price.d.ts +12 -4
  44. package/dist/price.js +2 -1
  45. package/dist/search-DU6tE356.d.cts +15 -0
  46. package/dist/search-DU6tE356.d.ts +15 -0
  47. package/dist/segment.cjs +21 -5
  48. package/dist/segment.cjs.map +1 -1
  49. package/dist/segment.d.cts +16 -6
  50. package/dist/segment.d.ts +16 -6
  51. package/dist/segment.js +2 -1
  52. package/package.json +1 -1
  53. package/dist/chunk-5XZ6MSXW.js.map +0 -1
  54. package/dist/chunk-CSYXGTOH.js.map +0 -1
  55. package/dist/chunk-P3RANRGB.js.map +0 -1
  56. package/dist/chunk-QQMLN76U.js.map +0 -1
  57. package/dist/chunk-XJJDCK2Z.js.map +0 -1
  58. package/dist/chunk-ZOFGDNSX.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,17 +1,17 @@
1
1
  import { LocationsService } from './chunk-IAOWDMTA.js';
2
2
  export { LocationsService } from './chunk-IAOWDMTA.js';
3
- import { MediaService } from './chunk-CSYXGTOH.js';
4
- export { MediaService } from './chunk-CSYXGTOH.js';
5
- import { OrdersService, SalesOrdersService } from './chunk-P3RANRGB.js';
6
- export { OrdersService, SalesOrdersService } from './chunk-P3RANRGB.js';
3
+ import { MediaService } from './chunk-5MPL4XBD.js';
4
+ export { MediaService } from './chunk-5MPL4XBD.js';
5
+ import { OrdersService, SalesOrdersService } from './chunk-IYNT5BQW.js';
6
+ export { OrdersService, SalesOrdersService } from './chunk-IYNT5BQW.js';
7
7
  import { auth, resolveToken, DefaultTokenProvider, CustomerRefreshRegistry, PaymentGatewayService } from './chunk-4VRUMCS2.js';
8
8
  export { CustomerRefreshRegistry, DefaultTokenProvider, PaymentGatewayService, auth, resolveToken } from './chunk-4VRUMCS2.js';
9
- import { PriceService } from './chunk-ZOFGDNSX.js';
10
- export { PriceService } from './chunk-ZOFGDNSX.js';
9
+ import { PriceService } from './chunk-K4KXT6NX.js';
10
+ export { PriceService } from './chunk-K4KXT6NX.js';
11
11
  import { ProductService } from './chunk-2SHTDVOC.js';
12
12
  export { ProductService } from './chunk-2SHTDVOC.js';
13
- import { SegmentService } from './chunk-XJJDCK2Z.js';
14
- export { SegmentService } from './chunk-XJJDCK2Z.js';
13
+ import { SegmentService } from './chunk-N2CE3J4M.js';
14
+ export { SegmentService } from './chunk-N2CE3J4M.js';
15
15
  import { AvailabilityService } from './chunk-XQAOHHXL.js';
16
16
  export { AvailabilityService } from './chunk-XQAOHHXL.js';
17
17
  import { CartService } from './chunk-YVZ6GOLE.js';
@@ -24,12 +24,13 @@ export { resolveQuery } from './chunk-S5HEIQDK.js';
24
24
  import { requestPage } from './chunk-LKHKFF7B.js';
25
25
  import { CheckoutService } from './chunk-RYQVMR26.js';
26
26
  export { CheckoutService } from './chunk-RYQVMR26.js';
27
- import { CompaniesService } from './chunk-QQMLN76U.js';
28
- export { CompaniesService } from './chunk-QQMLN76U.js';
27
+ import { CompaniesService } from './chunk-2OTFVTG6.js';
28
+ export { CompaniesService } from './chunk-2OTFVTG6.js';
29
+ import { splitQuery, SEARCH_PAGING } from './chunk-ZWJUDXTK.js';
29
30
  import { ContactsService } from './chunk-27NLS646.js';
30
31
  export { ContactsService } from './chunk-27NLS646.js';
31
- import { CustomerGroupsService, IamService } from './chunk-5XZ6MSXW.js';
32
- export { CustomerGroupsService, IamService } from './chunk-5XZ6MSXW.js';
32
+ import { CustomerGroupsService, IamService } from './chunk-VXORPTMP.js';
33
+ export { CustomerGroupsService, IamService } from './chunk-VXORPTMP.js';
33
34
  import { CustomerService } from './chunk-UA4BM6OP.js';
34
35
  export { CustomerService } from './chunk-UA4BM6OP.js';
35
36
  import './chunk-3BDDYX3V.js';
@@ -945,7 +946,7 @@ var HttpClient = class {
945
946
  };
946
947
 
947
948
  // package.json
948
- var version = "4.0.0";
949
+ var version = "4.1.0";
949
950
 
950
951
  // src/version.ts
951
952
  var SDK_VERSION = version;
@@ -1388,6 +1389,21 @@ var ClientConfigService = class {
1388
1389
 
1389
1390
  // src/services/shopping-list.ts
1390
1391
  var RESERVED = /* @__PURE__ */ new Set(["customerId", "metadata"]);
1392
+ function toLists(env) {
1393
+ const out = [];
1394
+ for (const [key, value] of Object.entries(env)) {
1395
+ if (RESERVED.has(key) || value === null || typeof value !== "object") continue;
1396
+ const v = value;
1397
+ out.push({
1398
+ key,
1399
+ name: v.name ?? key,
1400
+ items: v.items ?? [],
1401
+ ...v.mixins ? { mixins: v.mixins } : {},
1402
+ ...v.metadata ? { metadata: v.metadata } : {}
1403
+ });
1404
+ }
1405
+ return out;
1406
+ }
1391
1407
  var ShoppingListService = class {
1392
1408
  constructor(ctx) {
1393
1409
  this.ctx = ctx;
@@ -1397,7 +1413,11 @@ var ShoppingListService = class {
1397
1413
  base() {
1398
1414
  return `/shoppinglist/${this.ctx.tenant}/shopping-lists`;
1399
1415
  }
1400
- /** The caller's lists (or, with employee scope, all), normalized to an array. */
1416
+ /**
1417
+ * The caller's lists, normalized to an array. With employee scope Emporix
1418
+ * returns **every customer's** lists and ignores `name` — read one customer's
1419
+ * with {@link getForCustomer} instead.
1420
+ */
1401
1421
  async list(auth2, opts = {}) {
1402
1422
  const envelopes = await this.ctx.http.request({
1403
1423
  method: "GET",
@@ -1405,21 +1425,20 @@ var ShoppingListService = class {
1405
1425
  auth: auth2,
1406
1426
  ...opts.name ? { query: { name: opts.name } } : {}
1407
1427
  });
1408
- const out = [];
1409
- for (const env of envelopes ?? []) {
1410
- for (const [key, value] of Object.entries(env)) {
1411
- if (RESERVED.has(key) || value === null || typeof value !== "object") continue;
1412
- const v = value;
1413
- out.push({
1414
- key,
1415
- name: v.name ?? key,
1416
- items: v.items ?? [],
1417
- ...v.mixins ? { mixins: v.mixins } : {},
1418
- ...v.metadata ? { metadata: v.metadata } : {}
1419
- });
1420
- }
1421
- }
1422
- return out;
1428
+ return (envelopes ?? []).flatMap(toLists);
1429
+ }
1430
+ /**
1431
+ * One customer's lists (`GET /shopping-lists/{customerId}`), normalized to an
1432
+ * array — the employee read; `name` narrows it to one list.
1433
+ */
1434
+ async getForCustomer(customerId, auth2, opts = {}) {
1435
+ const envelope = await this.ctx.http.request({
1436
+ method: "GET",
1437
+ path: `${this.base()}/${encodeURIComponent(customerId)}`,
1438
+ auth: auth2,
1439
+ ...opts.name ? { query: { name: opts.name } } : {}
1440
+ });
1441
+ return envelope ? toLists(envelope) : [];
1423
1442
  }
1424
1443
  /** Create a list; returns the new list id. */
1425
1444
  async create(draft, auth2) {
@@ -1448,8 +1467,8 @@ var ShoppingListService = class {
1448
1467
  ...opts.name ? { query: { name: opts.name } } : {}
1449
1468
  });
1450
1469
  }
1451
- async loadList(listName, auth2) {
1452
- const lists = await this.list(auth2, { name: listName });
1470
+ async loadList(customerId, listName, auth2) {
1471
+ const lists = auth2.kind === "service" ? await this.getForCustomer(customerId, auth2, { name: listName }) : await this.list(auth2, { name: listName });
1453
1472
  const found = lists.find((l) => l.name === listName);
1454
1473
  if (!found) throw new EmporixNotFoundError(`Shopping list "${listName}" not found`, 404);
1455
1474
  return found;
@@ -1463,20 +1482,20 @@ var ShoppingListService = class {
1463
1482
  }
1464
1483
  /** Add/replace an item by `productId` (read-modify-write, last-write-wins). */
1465
1484
  async addItem(customerId, listName, item, auth2) {
1466
- const list = await this.loadList(listName, auth2);
1485
+ const list = await this.loadList(customerId, listName, auth2);
1467
1486
  const items = [...list.items.filter((i) => i.productId !== item.productId), item];
1468
1487
  await this.put(customerId, list, items, auth2);
1469
1488
  }
1470
1489
  /** Remove an item by `productId` (no-op if absent). */
1471
1490
  async removeItem(customerId, listName, productId, auth2) {
1472
- const list = await this.loadList(listName, auth2);
1491
+ const list = await this.loadList(customerId, listName, auth2);
1473
1492
  const items = list.items.filter((i) => i.productId !== productId);
1474
1493
  await this.put(customerId, list, items, auth2);
1475
1494
  }
1476
1495
  /** Set an item's quantity; `quantity <= 0` removes it. Adds the item if absent. */
1477
1496
  async setItemQuantity(customerId, listName, productId, quantity, auth2) {
1478
1497
  if (quantity <= 0) return this.removeItem(customerId, listName, productId, auth2);
1479
- const list = await this.loadList(listName, auth2);
1498
+ const list = await this.loadList(customerId, listName, auth2);
1480
1499
  let items = list.items.map((i) => i.productId === productId ? { ...i, quantity } : i);
1481
1500
  if (!items.some((i) => i.productId === productId)) items = [...items, { productId, quantity }];
1482
1501
  await this.put(customerId, list, items, auth2);
@@ -1809,13 +1828,14 @@ var FeeService = class {
1809
1828
  * Finds item fees for several products on one site
1810
1829
  * (`POST /itemFees/searchByProductIds`). Note the upstream asymmetry:
1811
1830
  * `productIds` is a comma-separated **string** and `siteCode` is singular.
1831
+ * `siteFallback` goes in the query string, everything else in the body.
1812
1832
  */
1813
1833
  async searchItemFeesByProductIds(search, auth2 = SERVICE6) {
1814
1834
  return this.ctx.http.request({
1815
1835
  method: "POST",
1816
1836
  path: `${this.itemFeesBase()}/searchByProductIds`,
1817
1837
  auth: auth2,
1818
- body: search,
1838
+ ...splitQuery(search, ["siteFallback"]),
1819
1839
  idempotent: true
1820
1840
  // pure read over POST — safe to replay on 5xx/429
1821
1841
  });
@@ -2421,9 +2441,9 @@ var AgenticCrudResource = class {
2421
2441
  list(query = {}, auth2 = SERVICE9) {
2422
2442
  return this.ctx.http.request({ method: "GET", path: this.path, auth: auth2, query: { ...query } });
2423
2443
  }
2424
- /** Structured search (`POST {path}/search`). Body is `{ q? }`. */
2444
+ /** Structured search (`POST {path}/search`): `q` in the body, paging/sort/fields in the query. */
2425
2445
  search(query, auth2 = SERVICE9) {
2426
- return this.ctx.http.request({ method: "POST", path: `${this.path}/search`, auth: auth2, body: query });
2446
+ return this.ctx.http.request({ method: "POST", path: `${this.path}/search`, auth: auth2, ...splitQuery(query, SEARCH_PAGING) });
2427
2447
  }
2428
2448
  /** Retrieve one entry by id (`GET {path}/{id}`). */
2429
2449
  get(id, opts = {}, auth2 = SERVICE9) {
@@ -2473,7 +2493,7 @@ var JobsResource = class {
2473
2493
  }
2474
2494
  /** Structured job search (`POST /jobs/search`). */
2475
2495
  search(query, auth2 = SERVICE9) {
2476
- return this.ctx.http.request({ method: "POST", path: `${this.base}/jobs/search`, auth: auth2, body: query });
2496
+ return this.ctx.http.request({ method: "POST", path: `${this.base}/jobs/search`, auth: auth2, ...splitQuery(query, SEARCH_PAGING) });
2477
2497
  }
2478
2498
  /** Retrieve one job (`GET /jobs/{jobId}`). */
2479
2499
  get(jobId, auth2 = SERVICE9) {
@@ -2497,7 +2517,7 @@ var TemplatesResource = class {
2497
2517
  }
2498
2518
  /** Structured template search (`POST /agentic/templates/search`). */
2499
2519
  search(query, auth2 = SERVICE9) {
2500
- return this.ctx.http.request({ method: "POST", path: `${this.path}/search`, auth: auth2, body: query });
2520
+ return this.ctx.http.request({ method: "POST", path: `${this.path}/search`, auth: auth2, ...splitQuery(query, SEARCH_PAGING) });
2501
2521
  }
2502
2522
  /**
2503
2523
  * Instantiate a new agent from a template
@@ -2530,7 +2550,7 @@ var LogsResource = class {
2530
2550
  }
2531
2551
  /** Structured request-log search (`POST /agentic/logs/requests/search`). */
2532
2552
  searchRequests(query, auth2 = SERVICE9) {
2533
- return this.ctx.http.request({ method: "POST", path: `${this.path}/requests/search`, auth: auth2, body: query });
2553
+ return this.ctx.http.request({ method: "POST", path: `${this.path}/requests/search`, auth: auth2, ...splitQuery(query, SEARCH_PAGING) });
2534
2554
  }
2535
2555
  /** List session logs (`GET /agentic/logs/sessions`). */
2536
2556
  listSessions(query = {}, auth2 = SERVICE9) {
@@ -2542,7 +2562,7 @@ var LogsResource = class {
2542
2562
  }
2543
2563
  /** Structured session-log search (`POST /agentic/logs/sessions/search`). */
2544
2564
  searchSessions(query, auth2 = SERVICE9) {
2545
- return this.ctx.http.request({ method: "POST", path: `${this.path}/sessions/search`, auth: auth2, body: query });
2565
+ return this.ctx.http.request({ method: "POST", path: `${this.path}/sessions/search`, auth: auth2, ...splitQuery(query, SEARCH_PAGING) });
2546
2566
  }
2547
2567
  };
2548
2568
  var AnalyticsResource = class {
@@ -2574,6 +2594,10 @@ function assertChatOptions(opts, method) {
2574
2594
  function sessionHeader(opts) {
2575
2595
  return opts.sessionId ? { headers: { "session-id": opts.sessionId } } : {};
2576
2596
  }
2597
+ var AUTH_KINDS = /* @__PURE__ */ new Set(["service", "anonymous", "customer", "raw"]);
2598
+ function isAuthContext(value) {
2599
+ return AUTH_KINDS.has(String(value.kind));
2600
+ }
2577
2601
  var AiService = class {
2578
2602
  constructor(ctx) {
2579
2603
  this.ctx = ctx;
@@ -2642,12 +2666,13 @@ var AiService = class {
2642
2666
  body: input
2643
2667
  });
2644
2668
  }
2645
- /** List all agentic agents. */
2646
- async listAgents(auth2 = SERVICE10) {
2669
+ async listAgents(queryOrAuth = {}, auth2 = SERVICE10) {
2670
+ const [query, ctx] = isAuthContext(queryOrAuth) ? [{}, queryOrAuth] : [queryOrAuth, auth2];
2647
2671
  return this.ctx.http.request({
2648
2672
  method: "GET",
2649
2673
  path: `${this.base()}/agentic/agents`,
2650
- auth: auth2
2674
+ auth: ctx,
2675
+ query: { ...query }
2651
2676
  });
2652
2677
  }
2653
2678
  /** Retrieve one agent by id. */
@@ -2692,13 +2717,16 @@ var AiService = class {
2692
2717
  ...opts.force ? { query: { force: "true" } } : {}
2693
2718
  });
2694
2719
  }
2695
- /** Server-side agent search (`POST /agentic/agents/search`). */
2720
+ /**
2721
+ * Server-side agent search (`POST /agentic/agents/search`). `q` goes in the
2722
+ * body; `pageNumber`, `pageSize`, `sort` and `fields` in the query string.
2723
+ */
2696
2724
  async searchAgents(query, auth2 = SERVICE10) {
2697
2725
  return this.ctx.http.request({
2698
2726
  method: "POST",
2699
2727
  path: `${this.base()}/agentic/agents/search`,
2700
2728
  auth: auth2,
2701
- body: query
2729
+ ...splitQuery(query, SEARCH_PAGING)
2702
2730
  });
2703
2731
  }
2704
2732
  /**
@@ -2751,21 +2779,22 @@ var AiService = class {
2751
2779
  });
2752
2780
  for await (const ev of events) yield ev.data;
2753
2781
  }
2754
- /** List stored agentic conversations (`GET /agentic/conversations`). */
2755
- async listConversations(auth2 = SERVICE10) {
2782
+ async listConversations(queryOrAuth = {}, auth2 = SERVICE10) {
2783
+ const [query, ctx] = isAuthContext(queryOrAuth) ? [{}, queryOrAuth] : [queryOrAuth, auth2];
2756
2784
  return this.ctx.http.request({
2757
2785
  method: "GET",
2758
2786
  path: `${this.base()}/agentic/conversations`,
2759
- auth: auth2
2787
+ auth: ctx,
2788
+ query: { ...query }
2760
2789
  });
2761
2790
  }
2762
- /** Server-side conversation search (`POST /agentic/conversations/search`). */
2791
+ /** Server-side conversation search (`POST /agentic/conversations/search`), paged like {@link searchAgents}. */
2763
2792
  async searchConversations(query, auth2 = SERVICE10) {
2764
2793
  return this.ctx.http.request({
2765
2794
  method: "POST",
2766
2795
  path: `${this.base()}/agentic/conversations/search`,
2767
2796
  auth: auth2,
2768
- body: query
2797
+ ...splitQuery(query, SEARCH_PAGING)
2769
2798
  });
2770
2799
  }
2771
2800
  // --- Standalone agentic reads / bulk operations ------------------------
@@ -4961,14 +4990,17 @@ var VendorService = class {
4961
4990
  auth: auth2
4962
4991
  });
4963
4992
  }
4964
- /** Search vendors (`POST /vendors/search`). A built filter in `q` is resolved to a string. */
4993
+ /**
4994
+ * Search vendors (`POST /vendors/search`). A built filter in `q` is resolved to
4995
+ * a string; paging, sort and fields go in the query string.
4996
+ */
4965
4997
  async searchVendors(query, auth2 = SERVICE26) {
4966
- const body = query.q !== void 0 ? { ...query, q: resolveQuery(query.q, { compoundLogicalQuery: false }) } : query;
4998
+ const input = query.q !== void 0 ? { ...query, q: resolveQuery(query.q, { compoundLogicalQuery: false }) } : query;
4967
4999
  return this.ctx.http.request({
4968
5000
  method: "POST",
4969
5001
  path: `${this.base()}/vendors/search`,
4970
5002
  auth: auth2,
4971
- body
5003
+ ...splitQuery(input, SEARCH_PAGING)
4972
5004
  });
4973
5005
  }
4974
5006
  /** Create a vendor. */
@@ -5063,10 +5095,18 @@ var CustomerAdminService = class {
5063
5095
  ...Object.keys(query).length ? { query } : {}
5064
5096
  });
5065
5097
  }
5066
- /** Search customers (`POST /customers/search`). A built filter in `q` is resolved to a string. */
5098
+ /**
5099
+ * Search customers (`POST /customers/search`). A built filter in `q` is resolved
5100
+ * to a string; `pageNumber`, `pageSize`, `sort` and `expand` go in the query string.
5101
+ */
5067
5102
  async searchCustomers(query, auth2 = SERVICE27) {
5068
- const body = query.q !== void 0 ? { ...query, q: resolveQuery(query.q, { compoundLogicalQuery: false }) } : query;
5069
- return this.ctx.http.request({ method: "POST", path: `${this.base()}/search`, auth: auth2, body });
5103
+ const input = query.q !== void 0 ? { ...query, q: resolveQuery(query.q, { compoundLogicalQuery: false }) } : query;
5104
+ return this.ctx.http.request({
5105
+ method: "POST",
5106
+ path: `${this.base()}/search`,
5107
+ auth: auth2,
5108
+ ...splitQuery(input, ["pageNumber", "pageSize", "sort", "expand"])
5109
+ });
5070
5110
  }
5071
5111
  /** Retrieve a customer profile by number. */
5072
5112
  async getCustomer(customerNumber, auth2 = SERVICE27) {