@viu/emporix-sdk 2.37.0 → 2.38.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 (42) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/dist/availability.d.cts +1 -1
  3. package/dist/availability.d.ts +1 -1
  4. package/dist/cart.d.cts +1 -1
  5. package/dist/cart.d.ts +1 -1
  6. package/dist/category.d.cts +1 -1
  7. package/dist/category.d.ts +1 -1
  8. package/dist/checkout.d.cts +1 -1
  9. package/dist/checkout.d.ts +1 -1
  10. package/dist/companies.d.cts +1 -1
  11. package/dist/companies.d.ts +1 -1
  12. package/dist/contacts.d.cts +1 -1
  13. package/dist/contacts.d.ts +1 -1
  14. package/dist/{context-DK8jg6y5.d.cts → context-D64-B1Rz.d.cts} +13 -0
  15. package/dist/{context-DK8jg6y5.d.ts → context-D64-B1Rz.d.ts} +13 -0
  16. package/dist/{customer-groups-BfHDqExS.d.cts → customer-groups-B6xrwf59.d.cts} +1 -1
  17. package/dist/{customer-groups-Cs6-Cwzg.d.ts → customer-groups-YZg22bFc.d.ts} +1 -1
  18. package/dist/customer-groups.d.cts +2 -2
  19. package/dist/customer-groups.d.ts +2 -2
  20. package/dist/customer.d.cts +1 -1
  21. package/dist/customer.d.ts +1 -1
  22. package/dist/index.cjs +6 -1
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.cts +3 -3
  25. package/dist/index.d.ts +3 -3
  26. package/dist/index.js +6 -1
  27. package/dist/index.js.map +1 -1
  28. package/dist/locations.d.cts +1 -1
  29. package/dist/locations.d.ts +1 -1
  30. package/dist/media.d.cts +1 -1
  31. package/dist/media.d.ts +1 -1
  32. package/dist/orders.d.cts +1 -1
  33. package/dist/orders.d.ts +1 -1
  34. package/dist/payment.d.cts +1 -1
  35. package/dist/payment.d.ts +1 -1
  36. package/dist/price.d.cts +1 -1
  37. package/dist/price.d.ts +1 -1
  38. package/dist/product.d.cts +1 -1
  39. package/dist/product.d.ts +1 -1
  40. package/dist/segment.d.cts +1 -1
  41. package/dist/segment.d.ts +1 -1
  42. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
1
1
  # @viu/emporix-sdk
2
2
 
3
+ ## 2.38.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#294](https://github.com/viuteam/emporix-sdk/pull/294) [`ebf7e61`](https://github.com/viuteam/emporix-sdk/commit/ebf7e610f21c37e000e96fbe651902860bb0fce0) Thanks [@amnael1](https://github.com/amnael1)! - fix(sdk): send `Emporix-Tenant` on every request
8
+
9
+ The tenant is already in the path of nearly every endpoint, so this header looks
10
+ redundant. It is not: Emporix validates dashboard and IAM user tokens against it
11
+ and answers **401** without it, even when `Authorization: Bearer …` is correct.
12
+
13
+ Found while embedding the SDK in a Management Dashboard perspective. Every read
14
+ and write failed with 401 despite a valid host-supplied token, and nothing in
15
+ the request looked wrong — the header is simply absent from the SDK's
16
+ `buildHeaders`, which is not a diagnosable symptom.
17
+
18
+ `@emporix/api-calls`, the client library the Management Dashboard itself uses,
19
+ sets the header whenever a tenant is known — it is an Emporix convention, not a
20
+ dashboard-only quirk. So this is unconditional rather than opt-in: `HttpClient`
21
+ emits it whenever `tenant` is set, and `createCore` always passes it. Every
22
+ client built through `createEmporixClient` gets it.
23
+
24
+ **Behaviour change for every consumer.** Storefront traffic now carries one
25
+ extra header on each request. It is placed _before_ `RequestOptions.headers`, so
26
+ a caller can still override it per request — the same escape hatch
27
+ `Accept-Language` has. Only `Authorization` remains non-negotiable.
28
+
29
+ `HttpClientOptions.tenant` is optional so a bare `new HttpClient(...)` stays
30
+ constructible; the header is then omitted entirely, matching what
31
+ `@emporix/api-calls` does with an empty tenant.
32
+
33
+ Also covers `requestStream` — it shares `buildHeaders`. Token requests
34
+ (`core/auth.ts`) are unaffected, as with `EmporixConfig.fetch`.
35
+
3
36
  ## 2.37.0
4
37
 
5
38
  ### Minor Changes
@@ -1,4 +1,4 @@
1
- import { C as ClientContext, b as AuthContext, P as PaginatedItems } from './context-DK8jg6y5.cjs';
1
+ import { C as ClientContext, b as AuthContext, P as PaginatedItems } from './context-D64-B1Rz.cjs';
2
2
 
3
3
  type AvailabilityDto = {
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { C as ClientContext, b as AuthContext, P as PaginatedItems } from './context-DK8jg6y5.js';
1
+ import { C as ClientContext, b as AuthContext, P as PaginatedItems } from './context-D64-B1Rz.js';
2
2
 
3
3
  type AvailabilityDto = {
4
4
  /**
package/dist/cart.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { C as ClientContext, b as AuthContext } from './context-DK8jg6y5.cjs';
1
+ import { C as ClientContext, b as AuthContext } from './context-D64-B1Rz.cjs';
2
2
 
3
3
  /**
4
4
  * Access control identifier that determines who can view or manage the cart.
package/dist/cart.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { C as ClientContext, b as AuthContext } from './context-DK8jg6y5.js';
1
+ import { C as ClientContext, b as AuthContext } from './context-D64-B1Rz.js';
2
2
 
3
3
  /**
4
4
  * Access control identifier that determines who can view or manage the cart.
@@ -1,4 +1,4 @@
1
- import { C as ClientContext, b as AuthContext, P as PaginatedItems } from './context-DK8jg6y5.cjs';
1
+ import { C as ClientContext, b as AuthContext, P as PaginatedItems } from './context-D64-B1Rz.cjs';
2
2
  import { a as QueryFor } from './query-mLQs2WFr.cjs';
3
3
  import { Product } from './product.cjs';
4
4
 
@@ -1,4 +1,4 @@
1
- import { C as ClientContext, b as AuthContext, P as PaginatedItems } from './context-DK8jg6y5.js';
1
+ import { C as ClientContext, b as AuthContext, P as PaginatedItems } from './context-D64-B1Rz.js';
2
2
  import { a as QueryFor } from './query-mLQs2WFr.js';
3
3
  import { Product } from './product.js';
4
4
 
@@ -1,4 +1,4 @@
1
- import { C as ClientContext, b as AuthContext } from './context-DK8jg6y5.cjs';
1
+ import { C as ClientContext, b as AuthContext } from './context-D64-B1Rz.cjs';
2
2
 
3
3
  /**
4
4
  * Information about the customer's address.
@@ -1,4 +1,4 @@
1
- import { C as ClientContext, b as AuthContext } from './context-DK8jg6y5.js';
1
+ import { C as ClientContext, b as AuthContext } from './context-D64-B1Rz.js';
2
2
 
3
3
  /**
4
4
  * Information about the customer's address.
@@ -1,4 +1,4 @@
1
- import { C as ClientContext, b as AuthContext } from './context-DK8jg6y5.cjs';
1
+ import { C as ClientContext, b as AuthContext } from './context-D64-B1Rz.cjs';
2
2
  import { L as LegalEntity, e as LegalEntityCreate, f as LegalEntityUpdate } from './types.gen-fWB4nrso.cjs';
3
3
  export { A as AccountLimit, d as CustomerGroup, g as LegalInfo } from './types.gen-fWB4nrso.cjs';
4
4
 
@@ -1,4 +1,4 @@
1
- import { C as ClientContext, b as AuthContext } from './context-DK8jg6y5.js';
1
+ import { C as ClientContext, b as AuthContext } from './context-D64-B1Rz.js';
2
2
  import { L as LegalEntity, e as LegalEntityCreate, f as LegalEntityUpdate } from './types.gen-fWB4nrso.js';
3
3
  export { A as AccountLimit, d as CustomerGroup, g as LegalInfo } from './types.gen-fWB4nrso.js';
4
4
 
@@ -1,4 +1,4 @@
1
- import { C as ClientContext, b as AuthContext } from './context-DK8jg6y5.cjs';
1
+ import { C as ClientContext, b as AuthContext } from './context-D64-B1Rz.cjs';
2
2
  import { C as ContactAssignment, a as ContactAssignmentCreate, b as ContactAssignmentUpdate } from './types.gen-fWB4nrso.cjs';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { C as ClientContext, b as AuthContext } from './context-DK8jg6y5.js';
1
+ import { C as ClientContext, b as AuthContext } from './context-D64-B1Rz.js';
2
2
  import { C as ContactAssignment, a as ContactAssignmentCreate, b as ContactAssignmentUpdate } from './types.gen-fWB4nrso.js';
3
3
 
4
4
  /**
@@ -384,6 +384,19 @@ interface HttpResult<T> {
384
384
  /** Construction options for {@link HttpClient}. */
385
385
  interface HttpClientOptions {
386
386
  host: string;
387
+ /**
388
+ * Tenant, emitted as `Emporix-Tenant` on every request.
389
+ *
390
+ * The tenant is already in the path of nearly every endpoint, so this looks
391
+ * redundant — it is not. Emporix validates dashboard/IAM user tokens against
392
+ * this header and answers 401 without it, even when `Authorization` is
393
+ * correct. `@emporix/api-calls`, the client library the Management Dashboard
394
+ * itself uses, sets it whenever a tenant is known.
395
+ *
396
+ * Optional so a bare `new HttpClient(...)` stays constructible; every client
397
+ * built through `createCore` passes it.
398
+ */
399
+ tenant?: string;
387
400
  provider: TokenProvider;
388
401
  logger: Logger;
389
402
  retry: {
@@ -384,6 +384,19 @@ interface HttpResult<T> {
384
384
  /** Construction options for {@link HttpClient}. */
385
385
  interface HttpClientOptions {
386
386
  host: string;
387
+ /**
388
+ * Tenant, emitted as `Emporix-Tenant` on every request.
389
+ *
390
+ * The tenant is already in the path of nearly every endpoint, so this looks
391
+ * redundant — it is not. Emporix validates dashboard/IAM user tokens against
392
+ * this header and answers 401 without it, even when `Authorization` is
393
+ * correct. `@emporix/api-calls`, the client library the Management Dashboard
394
+ * itself uses, sets it whenever a tenant is known.
395
+ *
396
+ * Optional so a bare `new HttpClient(...)` stays constructible; every client
397
+ * built through `createCore` passes it.
398
+ */
399
+ tenant?: string;
387
400
  provider: TokenProvider;
388
401
  logger: Logger;
389
402
  retry: {
@@ -1,4 +1,4 @@
1
- import { C as ClientContext, b as AuthContext } from './context-DK8jg6y5.cjs';
1
+ import { C as ClientContext, b as AuthContext } from './context-D64-B1Rz.cjs';
2
2
 
3
3
  /**
4
4
  * Access control metadata.
@@ -1,4 +1,4 @@
1
- import { C as ClientContext, b as AuthContext } from './context-DK8jg6y5.js';
1
+ import { C as ClientContext, b as AuthContext } from './context-D64-B1Rz.js';
2
2
 
3
3
  /**
4
4
  * Access control metadata.
@@ -1,2 +1,2 @@
1
- export { g as CustomerGroupsService, j as IamGroup, c as IamGroupMemberAssignment } from './customer-groups-BfHDqExS.cjs';
2
- import './context-DK8jg6y5.cjs';
1
+ export { g as CustomerGroupsService, j as IamGroup, c as IamGroupMemberAssignment } from './customer-groups-B6xrwf59.cjs';
2
+ import './context-D64-B1Rz.cjs';
@@ -1,2 +1,2 @@
1
- export { g as CustomerGroupsService, j as IamGroup, c as IamGroupMemberAssignment } from './customer-groups-Cs6-Cwzg.js';
2
- import './context-DK8jg6y5.js';
1
+ export { g as CustomerGroupsService, j as IamGroup, c as IamGroupMemberAssignment } from './customer-groups-YZg22bFc.js';
2
+ import './context-D64-B1Rz.js';
@@ -1,4 +1,4 @@
1
- import { C as ClientContext, A as AnonymousSession, b as AuthContext } from './context-DK8jg6y5.cjs';
1
+ import { C as ClientContext, A as AnonymousSession, b as AuthContext } from './context-D64-B1Rz.cjs';
2
2
 
3
3
  type AccountId = {
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { C as ClientContext, A as AnonymousSession, b as AuthContext } from './context-DK8jg6y5.js';
1
+ import { C as ClientContext, A as AnonymousSession, b as AuthContext } from './context-D64-B1Rz.js';
2
2
 
3
3
  type AccountId = {
4
4
  /**
package/dist/index.cjs CHANGED
@@ -741,6 +741,10 @@ var HttpClient = class {
741
741
  doFetch;
742
742
  buildHeaders(o, token, isFormData) {
743
743
  return {
744
+ // Before `o.headers` on purpose: a caller may override the tenant for a
745
+ // single request, the way `Accept-Language` can be overridden. Only
746
+ // `Authorization` is non-negotiable.
747
+ ...this.opts.tenant !== void 0 ? { "Emporix-Tenant": this.opts.tenant } : {},
744
748
  ...this.opts.requestContext?.language ? { "Accept-Language": this.opts.requestContext.language } : {},
745
749
  ...o.headers ?? {},
746
750
  Authorization: `Bearer ${token}`,
@@ -995,7 +999,7 @@ var HttpClient = class {
995
999
  };
996
1000
 
997
1001
  // package.json
998
- var version = "2.37.0";
1002
+ var version = "2.38.0";
999
1003
 
1000
1004
  // src/version.ts
1001
1005
  var SDK_VERSION = version;
@@ -1029,6 +1033,7 @@ function createCore(config) {
1029
1033
  logger: root.child({ service }),
1030
1034
  http: new HttpClient({
1031
1035
  host: cfg.host,
1036
+ tenant: cfg.tenant,
1032
1037
  provider: tokenProvider,
1033
1038
  logger: root.child({ service: "http" }),
1034
1039
  retry: cfg.retry,