@viu/emporix-sdk 2.31.1 → 2.33.1

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 (84) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/README.md +12 -0
  3. package/dist/availability.cjs +44 -10
  4. package/dist/availability.cjs.map +1 -1
  5. package/dist/availability.d.cts +2 -1
  6. package/dist/availability.d.ts +2 -1
  7. package/dist/availability.js +2 -1
  8. package/dist/cart.d.cts +1 -1
  9. package/dist/cart.d.ts +1 -1
  10. package/dist/category.cjs +82 -28
  11. package/dist/category.cjs.map +1 -1
  12. package/dist/category.d.cts +10 -1
  13. package/dist/category.d.ts +10 -1
  14. package/dist/category.js +3 -2
  15. package/dist/checkout.d.cts +1 -1
  16. package/dist/checkout.d.ts +1 -1
  17. package/dist/{chunk-W2KBVWJ2.js → chunk-3G5KROEC.js} +8 -2
  18. package/dist/chunk-3G5KROEC.js.map +1 -0
  19. package/dist/{chunk-7W22KLUL.js → chunk-JQWUGGRV.js} +32 -17
  20. package/dist/chunk-JQWUGGRV.js.map +1 -0
  21. package/dist/chunk-LKHKFF7B.js +30 -0
  22. package/dist/chunk-LKHKFF7B.js.map +1 -0
  23. package/dist/{chunk-D7HBM2DQ.js → chunk-MSQ3GEIW.js} +59 -31
  24. package/dist/chunk-MSQ3GEIW.js.map +1 -0
  25. package/dist/{chunk-P7G4LOOV.js → chunk-P3RANRGB.js} +47 -25
  26. package/dist/chunk-P3RANRGB.js.map +1 -0
  27. package/dist/{chunk-OTG2S2L4.js → chunk-TI56QENX.js} +14 -14
  28. package/dist/chunk-TI56QENX.js.map +1 -0
  29. package/dist/{chunk-GWJ2U2CP.js → chunk-W6SLZNRX.js} +2 -2
  30. package/dist/chunk-W6SLZNRX.js.map +1 -0
  31. package/dist/{chunk-V3275BA7.js → chunk-XQAOHHXL.js} +20 -12
  32. package/dist/chunk-XQAOHHXL.js.map +1 -0
  33. package/dist/companies.d.cts +1 -1
  34. package/dist/companies.d.ts +1 -1
  35. package/dist/contacts.d.cts +1 -1
  36. package/dist/contacts.d.ts +1 -1
  37. package/dist/{context-CpLIDl0P.d.cts → context-DK8jg6y5.d.cts} +48 -2
  38. package/dist/{context-CpLIDl0P.d.ts → context-DK8jg6y5.d.ts} +48 -2
  39. package/dist/{customer-groups-DJVbdrEP.d.cts → customer-groups-D0OCm8kJ.d.cts} +1 -1
  40. package/dist/{customer-groups-DhpCTCTg.d.ts → customer-groups-WSt4aT62.d.ts} +1 -1
  41. package/dist/customer-groups.d.cts +2 -2
  42. package/dist/customer-groups.d.ts +2 -2
  43. package/dist/customer.d.cts +1 -1
  44. package/dist/customer.d.ts +1 -1
  45. package/dist/index.cjs +343 -146
  46. package/dist/index.cjs.map +1 -1
  47. package/dist/index.d.cts +62 -7
  48. package/dist/index.d.ts +62 -7
  49. package/dist/index.js +169 -72
  50. package/dist/index.js.map +1 -1
  51. package/dist/locations.d.cts +1 -1
  52. package/dist/locations.d.ts +1 -1
  53. package/dist/media.cjs +38 -12
  54. package/dist/media.cjs.map +1 -1
  55. package/dist/media.d.cts +7 -2
  56. package/dist/media.d.ts +7 -2
  57. package/dist/media.js +2 -1
  58. package/dist/orders.cjs +71 -23
  59. package/dist/orders.cjs.map +1 -1
  60. package/dist/orders.d.cts +7 -1
  61. package/dist/orders.d.ts +7 -1
  62. package/dist/orders.js +2 -1
  63. package/dist/payment.d.cts +1 -1
  64. package/dist/payment.d.ts +1 -1
  65. package/dist/price.d.cts +1 -1
  66. package/dist/price.d.ts +1 -1
  67. package/dist/product.cjs +55 -14
  68. package/dist/product.cjs.map +1 -1
  69. package/dist/product.d.cts +4 -1
  70. package/dist/product.d.ts +4 -1
  71. package/dist/product.js +3 -2
  72. package/dist/segment.cjs +6 -0
  73. package/dist/segment.cjs.map +1 -1
  74. package/dist/segment.d.cts +1 -1
  75. package/dist/segment.d.ts +1 -1
  76. package/dist/segment.js +1 -1
  77. package/package.json +1 -1
  78. package/dist/chunk-7W22KLUL.js.map +0 -1
  79. package/dist/chunk-D7HBM2DQ.js.map +0 -1
  80. package/dist/chunk-GWJ2U2CP.js.map +0 -1
  81. package/dist/chunk-OTG2S2L4.js.map +0 -1
  82. package/dist/chunk-P7G4LOOV.js.map +0 -1
  83. package/dist/chunk-V3275BA7.js.map +0 -1
  84. package/dist/chunk-W2KBVWJ2.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,26 +1,27 @@
1
1
  import { LocationsService } from './chunk-IAOWDMTA.js';
2
2
  export { LocationsService } from './chunk-IAOWDMTA.js';
3
- import { MediaService } from './chunk-OTG2S2L4.js';
4
- export { MediaService } from './chunk-OTG2S2L4.js';
5
- import { OrdersService, SalesOrdersService } from './chunk-P7G4LOOV.js';
6
- export { OrdersService, SalesOrdersService } from './chunk-P7G4LOOV.js';
3
+ import { MediaService } from './chunk-TI56QENX.js';
4
+ export { MediaService } from './chunk-TI56QENX.js';
5
+ import { OrdersService, SalesOrdersService } from './chunk-P3RANRGB.js';
6
+ export { OrdersService, SalesOrdersService } from './chunk-P3RANRGB.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
9
  import { PriceService } from './chunk-ZOFGDNSX.js';
10
10
  export { PriceService } from './chunk-ZOFGDNSX.js';
11
- import { ProductService } from './chunk-7W22KLUL.js';
12
- export { ProductService } from './chunk-7W22KLUL.js';
13
- import { SegmentService } from './chunk-W2KBVWJ2.js';
14
- export { SegmentService } from './chunk-W2KBVWJ2.js';
15
- import { AvailabilityService } from './chunk-V3275BA7.js';
16
- export { AvailabilityService } from './chunk-V3275BA7.js';
11
+ import { ProductService } from './chunk-JQWUGGRV.js';
12
+ export { ProductService } from './chunk-JQWUGGRV.js';
13
+ import { SegmentService } from './chunk-3G5KROEC.js';
14
+ export { SegmentService } from './chunk-3G5KROEC.js';
15
+ import { AvailabilityService } from './chunk-XQAOHHXL.js';
16
+ export { AvailabilityService } from './chunk-XQAOHHXL.js';
17
17
  import { CartService } from './chunk-YVZ6GOLE.js';
18
18
  export { CartService } from './chunk-YVZ6GOLE.js';
19
- import { CategoryService } from './chunk-D7HBM2DQ.js';
20
- export { CategoryService } from './chunk-D7HBM2DQ.js';
21
- export { iterateAll } from './chunk-GWJ2U2CP.js';
19
+ import { CategoryService } from './chunk-MSQ3GEIW.js';
20
+ export { CategoryService } from './chunk-MSQ3GEIW.js';
21
+ export { iterateAll } from './chunk-W6SLZNRX.js';
22
22
  import { resolveQuery } from './chunk-S5HEIQDK.js';
23
23
  export { resolveQuery } from './chunk-S5HEIQDK.js';
24
+ import { requestPage } from './chunk-LKHKFF7B.js';
24
25
  import { CheckoutService } from './chunk-RYQVMR26.js';
25
26
  export { CheckoutService } from './chunk-RYQVMR26.js';
26
27
  import { CompaniesService } from './chunk-QQMLN76U.js';
@@ -439,7 +440,25 @@ var HttpClient = class {
439
440
  ...o.body !== void 0 && !isFormData ? { "Content-Type": "application/json" } : {}
440
441
  };
441
442
  }
443
+ /**
444
+ * Issues a request and returns the parsed body. Retries 5xx/429 on idempotent
445
+ * methods and re-auths once on a 401 — see {@link send}.
446
+ */
442
447
  async request(o) {
448
+ return (await this.send(o)).data;
449
+ }
450
+ /**
451
+ * Like {@link request}, but also hands back the response headers.
452
+ *
453
+ * Emporix puts pagination metadata there — `X-Total-Count` and, on the schema
454
+ * service's custom instances, `X-Next-Cursor` / `X-Prev-Cursor`. Facades
455
+ * should reach for `core/paged.ts`'s `requestPage` rather than calling this
456
+ * directly; it exists for metadata that does not fit the paginated shape.
457
+ */
458
+ async requestWithMeta(o) {
459
+ return this.send(o);
460
+ }
461
+ async send(o) {
443
462
  const requestId = `req-${++requestSeq}`;
444
463
  const log = this.opts.logger.child({ requestId });
445
464
  const url = new URL(this.opts.host + o.path);
@@ -506,7 +525,7 @@ var HttpClient = class {
506
525
  const parsed = text ? safeJson(text) : void 0;
507
526
  if (res.ok) {
508
527
  log.debug("http ok", { status: res.status });
509
- return parsed;
528
+ return { data: parsed, headers: res.headers };
510
529
  }
511
530
  if (res.status === 401) {
512
531
  if (sdkManaged && !reauthed) {
@@ -667,7 +686,7 @@ var HttpClient = class {
667
686
  };
668
687
 
669
688
  // package.json
670
- var version = "2.31.1";
689
+ var version = "2.33.1";
671
690
 
672
691
  // src/version.ts
673
692
  var SDK_VERSION = version;
@@ -1364,13 +1383,17 @@ var FeeService = class {
1364
1383
  async list(query = {}, auth2 = SERVICE6) {
1365
1384
  const pageNumber = query.pageNumber ?? 1;
1366
1385
  const pageSize = query.pageSize ?? 60;
1367
- const items = await this.ctx.http.request({
1368
- method: "GET",
1369
- path: this.feesBase(),
1370
- auth: auth2,
1371
- query: { ...query, pageNumber, pageSize }
1372
- });
1373
- return { items, pageNumber, pageSize, hasNextPage: items.length === pageSize };
1386
+ const { totalCount, ...rest } = query;
1387
+ return requestPage(
1388
+ this.ctx.http,
1389
+ {
1390
+ method: "GET",
1391
+ path: this.feesBase(),
1392
+ auth: auth2,
1393
+ query: { ...rest, pageNumber, pageSize }
1394
+ },
1395
+ { pageNumber, pageSize, ...totalCount === void 0 ? {} : { totalCount } }
1396
+ );
1374
1397
  }
1375
1398
  /** Retrieve one fee definition by id. */
1376
1399
  async get(id, auth2 = SERVICE6) {
@@ -1711,13 +1734,20 @@ var SchemaService = class {
1711
1734
  const q = { pageNumber, pageSize };
1712
1735
  if (query.q) q.q = query.q;
1713
1736
  if (query.type) q.type = query.type;
1714
- const items = await this.ctx.http.request({
1715
- method: "GET",
1716
- path: this.schemasBase(),
1717
- auth: auth2,
1718
- query: q
1719
- });
1720
- return { items, pageNumber, pageSize, hasNextPage: items.length === pageSize };
1737
+ return requestPage(
1738
+ this.ctx.http,
1739
+ {
1740
+ method: "GET",
1741
+ path: this.schemasBase(),
1742
+ auth: auth2,
1743
+ query: q
1744
+ },
1745
+ {
1746
+ pageNumber,
1747
+ pageSize,
1748
+ ...query.totalCount === void 0 ? {} : { totalCount: query.totalCount }
1749
+ }
1750
+ );
1721
1751
  }
1722
1752
  /** Retrieve one schema by id. */
1723
1753
  async getSchema(id, auth2 = SERVICE8) {
@@ -1843,13 +1873,41 @@ var SchemaService = class {
1843
1873
  async listInstances(type, query = {}, auth2 = SERVICE8) {
1844
1874
  const pageNumber = query.pageNumber ?? 1;
1845
1875
  const pageSize = query.pageSize ?? 60;
1846
- const items = await this.ctx.http.request({
1847
- method: "GET",
1848
- path: this.instancesBase(type),
1849
- auth: auth2,
1850
- query: { ...query, pageNumber, pageSize }
1851
- });
1852
- return { items, pageNumber, pageSize, hasNextPage: items.length === pageSize };
1876
+ const { totalCount, ...rest } = query;
1877
+ return requestPage(
1878
+ this.ctx.http,
1879
+ {
1880
+ method: "GET",
1881
+ path: this.instancesBase(type),
1882
+ auth: auth2,
1883
+ query: { ...rest, pageNumber, pageSize }
1884
+ },
1885
+ { pageNumber, pageSize, ...totalCount === void 0 ? {} : { totalCount } }
1886
+ );
1887
+ }
1888
+ /**
1889
+ * Async-iterates every instance of a type.
1890
+ *
1891
+ * Not built on `iterateAll`: that helper drives pagination by page number, and
1892
+ * the server ignores `pageNumber` the moment a cursor is in play. This follows
1893
+ * `nextCursor` while the server offers one and falls back to `pageNumber + 1`
1894
+ * when it does not — so it is correct whether or not the tenant's deployment
1895
+ * emits cursor headers on a request that carries no cursor.
1896
+ */
1897
+ async *listAllInstances(type, query = {}, auth2 = SERVICE8) {
1898
+ let cursor;
1899
+ let pageNumber = 1;
1900
+ for (; ; ) {
1901
+ const page = await this.listInstances(
1902
+ type,
1903
+ { ...query, pageNumber, ...cursor === void 0 ? {} : { next: cursor } },
1904
+ auth2
1905
+ );
1906
+ for (const item of page.items) yield item;
1907
+ if (!page.hasNextPage) return;
1908
+ cursor = page.nextCursor;
1909
+ if (cursor === void 0) pageNumber += 1;
1910
+ }
1853
1911
  }
1854
1912
  /** Retrieve one instance by id. */
1855
1913
  async getInstance(type, id, auth2 = SERVICE8) {
@@ -1983,15 +2041,26 @@ var SchemaService = class {
1983
2041
  /**
1984
2042
  * Structured search over a custom entity's instances
1985
2043
  * (`POST /instances/search`), wrapped in {@link PaginatedItems}.
2044
+ *
2045
+ * The `query` parameter is third and `auth` fourth. This used to forward no
2046
+ * query parameters at all and report a hard-coded `hasNextPage: false`, so a
2047
+ * search could only ever return the server's default first page.
1986
2048
  */
1987
- async searchInstances(type, body, auth2 = SERVICE8) {
1988
- const items = await this.ctx.http.request({
1989
- method: "POST",
1990
- path: `${this.instancesBase(type)}/search`,
1991
- auth: auth2,
1992
- body
1993
- });
1994
- return { items, pageNumber: 1, pageSize: items.length, hasNextPage: false };
2049
+ async searchInstances(type, body, query = {}, auth2 = SERVICE8) {
2050
+ const pageNumber = query.pageNumber ?? 1;
2051
+ const pageSize = query.pageSize ?? 60;
2052
+ const { totalCount, ...rest } = query;
2053
+ return requestPage(
2054
+ this.ctx.http,
2055
+ {
2056
+ method: "POST",
2057
+ path: `${this.instancesBase(type)}/search`,
2058
+ auth: auth2,
2059
+ body,
2060
+ query: { ...rest, pageNumber, pageSize }
2061
+ },
2062
+ { pageNumber, pageSize, ...totalCount === void 0 ? {} : { totalCount } }
2063
+ );
1995
2064
  }
1996
2065
  // --- (E) References ------------------------------------------------------
1997
2066
  /**
@@ -2012,13 +2081,20 @@ var SchemaService = class {
2012
2081
  if (query.q) q.q = query.q;
2013
2082
  if (query.fields) q.fields = query.fields;
2014
2083
  if (query.type) q.type = query.type;
2015
- const items = await this.ctx.http.request({
2016
- method: "GET",
2017
- path: this.referencesBase(),
2018
- auth: auth2,
2019
- query: q
2020
- });
2021
- return { items, pageNumber, pageSize, hasNextPage: items.length === pageSize };
2084
+ return requestPage(
2085
+ this.ctx.http,
2086
+ {
2087
+ method: "GET",
2088
+ path: this.referencesBase(),
2089
+ auth: auth2,
2090
+ query: q
2091
+ },
2092
+ {
2093
+ pageNumber,
2094
+ pageSize,
2095
+ ...query.totalCount === void 0 ? {} : { totalCount: query.totalCount }
2096
+ }
2097
+ );
2022
2098
  },
2023
2099
  /** Retrieve one reference by id. */
2024
2100
  get: async (id, auth2 = SERVICE8) => this.ctx.http.request({
@@ -3583,13 +3659,20 @@ var QuoteService = class {
3583
3659
  const q = { pageNumber, pageSize };
3584
3660
  if (query.q) q.q = query.q;
3585
3661
  if (query.sort) q.sort = query.sort;
3586
- const items = await this.ctx.http.request({
3587
- method: "GET",
3588
- path: this.quotesBase(),
3589
- auth: auth2,
3590
- query: q
3591
- });
3592
- return { items, pageNumber, pageSize, hasNextPage: items.length === pageSize };
3662
+ return requestPage(
3663
+ this.ctx.http,
3664
+ {
3665
+ method: "GET",
3666
+ path: this.quotesBase(),
3667
+ auth: auth2,
3668
+ query: q
3669
+ },
3670
+ {
3671
+ pageNumber,
3672
+ pageSize,
3673
+ ...query.totalCount === void 0 ? {} : { totalCount: query.totalCount }
3674
+ }
3675
+ );
3593
3676
  }
3594
3677
  /** Create a quote (`POST /quotes`, 201). */
3595
3678
  async create(draft, auth2) {
@@ -3659,13 +3742,20 @@ var QuoteReasonsResource = class {
3659
3742
  async list(query, auth2) {
3660
3743
  const pageNumber = query.pageNumber ?? 1;
3661
3744
  const pageSize = query.pageSize ?? 60;
3662
- const items = await this.ctx.http.request({
3663
- method: "GET",
3664
- path: this.base(),
3665
- auth: auth2,
3666
- query: { pageNumber, pageSize }
3667
- });
3668
- return { items, pageNumber, pageSize, hasNextPage: items.length === pageSize };
3745
+ return requestPage(
3746
+ this.ctx.http,
3747
+ {
3748
+ method: "GET",
3749
+ path: this.base(),
3750
+ auth: auth2,
3751
+ query: { pageNumber, pageSize }
3752
+ },
3753
+ {
3754
+ pageNumber,
3755
+ pageSize,
3756
+ ...query.totalCount === void 0 ? {} : { totalCount: query.totalCount }
3757
+ }
3758
+ );
3669
3759
  }
3670
3760
  /** Retrieve one reason by id. */
3671
3761
  async get(reasonId, auth2) {
@@ -3893,13 +3983,20 @@ var IndexingService = class {
3893
3983
  const pageSize = opts.pageSize ?? 50;
3894
3984
  const query = { pageNumber, pageSize };
3895
3985
  if (opts.q !== void 0) query.q = opts.q;
3896
- const items = await this.ctx.http.request({
3897
- method: "GET",
3898
- path: `${this.base()}/reindex-jobs`,
3899
- query,
3900
- auth: auth2
3901
- });
3902
- return { items, pageNumber, pageSize, hasNextPage: items.length === pageSize };
3986
+ return requestPage(
3987
+ this.ctx.http,
3988
+ {
3989
+ method: "GET",
3990
+ path: `${this.base()}/reindex-jobs`,
3991
+ query,
3992
+ auth: auth2
3993
+ },
3994
+ {
3995
+ pageNumber,
3996
+ pageSize,
3997
+ ...opts.totalCount === void 0 ? {} : { totalCount: opts.totalCount }
3998
+ }
3999
+ );
3903
4000
  }
3904
4001
  /** Fetch one reindex job by id. */
3905
4002
  async getReindexJob(reindexJobId, auth2 = SERVICE22) {