@viu/emporix-sdk 2.14.0 → 2.15.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 (128) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/availability.cjs +1 -0
  3. package/dist/availability.cjs.map +1 -1
  4. package/dist/availability.d.cts +1 -0
  5. package/dist/availability.d.ts +1 -0
  6. package/dist/availability.js +1 -1
  7. package/dist/cart.cjs +1 -0
  8. package/dist/cart.cjs.map +1 -1
  9. package/dist/cart.d.cts +1 -0
  10. package/dist/cart.d.ts +1 -0
  11. package/dist/cart.js +1 -1
  12. package/dist/category.cjs +1 -0
  13. package/dist/category.cjs.map +1 -1
  14. package/dist/category.d.cts +1 -0
  15. package/dist/category.d.ts +1 -0
  16. package/dist/category.js +1 -1
  17. package/dist/checkout.cjs +1 -0
  18. package/dist/checkout.cjs.map +1 -1
  19. package/dist/checkout.d.cts +1 -0
  20. package/dist/checkout.d.ts +1 -0
  21. package/dist/checkout.js +1 -1
  22. package/dist/{chunk-LGOC5XOI.js → chunk-3BTPX7IJ.js} +3 -2
  23. package/dist/chunk-3BTPX7IJ.js.map +1 -0
  24. package/dist/{chunk-MIUVJEGR.js → chunk-5VTBLBXJ.js} +3 -2
  25. package/dist/chunk-5VTBLBXJ.js.map +1 -0
  26. package/dist/{chunk-WW3H7VJ5.js → chunk-62PCCHZ2.js} +4 -2
  27. package/dist/chunk-62PCCHZ2.js.map +1 -0
  28. package/dist/{chunk-BDFOD7W3.js → chunk-A3LYJUD4.js} +3 -2
  29. package/dist/chunk-A3LYJUD4.js.map +1 -0
  30. package/dist/{chunk-MM6JF3Z7.js → chunk-BNX3JULF.js} +3 -2
  31. package/dist/chunk-BNX3JULF.js.map +1 -0
  32. package/dist/{chunk-LGLFJL3S.js → chunk-DUVIIWFG.js} +3 -2
  33. package/dist/chunk-DUVIIWFG.js.map +1 -0
  34. package/dist/{chunk-HAEVK6IS.js → chunk-EAWGUZHS.js} +3 -2
  35. package/dist/chunk-EAWGUZHS.js.map +1 -0
  36. package/dist/{chunk-WWCCB22A.js → chunk-GIZS4BY3.js} +3 -2
  37. package/dist/chunk-GIZS4BY3.js.map +1 -0
  38. package/dist/{chunk-BPVMQFO4.js → chunk-K3VQLW3P.js} +3 -2
  39. package/dist/chunk-K3VQLW3P.js.map +1 -0
  40. package/dist/{chunk-CR2JRH7T.js → chunk-NE7MIZPR.js} +4 -2
  41. package/dist/chunk-NE7MIZPR.js.map +1 -0
  42. package/dist/{chunk-UOBOFCFU.js → chunk-NEXUWPHW.js} +3 -2
  43. package/dist/chunk-NEXUWPHW.js.map +1 -0
  44. package/dist/{chunk-FU5WQALW.js → chunk-OTG2S2L4.js} +3 -2
  45. package/dist/chunk-OTG2S2L4.js.map +1 -0
  46. package/dist/{chunk-P3UHYMDH.js → chunk-PAT4CS36.js} +3 -2
  47. package/dist/chunk-PAT4CS36.js.map +1 -0
  48. package/dist/{chunk-XG2TKFY5.js → chunk-RYQVMR26.js} +3 -2
  49. package/dist/chunk-RYQVMR26.js.map +1 -0
  50. package/dist/{chunk-EINAVCV2.js → chunk-XEJPH6UN.js} +3 -2
  51. package/dist/chunk-XEJPH6UN.js.map +1 -0
  52. package/dist/companies.cjs +1 -0
  53. package/dist/companies.cjs.map +1 -1
  54. package/dist/companies.d.cts +1 -0
  55. package/dist/companies.d.ts +1 -0
  56. package/dist/companies.js +1 -1
  57. package/dist/contacts.cjs +1 -0
  58. package/dist/contacts.cjs.map +1 -1
  59. package/dist/contacts.d.cts +1 -0
  60. package/dist/contacts.d.ts +1 -0
  61. package/dist/contacts.js +1 -1
  62. package/dist/customer-groups.cjs +1 -0
  63. package/dist/customer-groups.cjs.map +1 -1
  64. package/dist/customer-groups.d.cts +1 -0
  65. package/dist/customer-groups.d.ts +1 -0
  66. package/dist/customer-groups.js +1 -1
  67. package/dist/customer.cjs +1 -0
  68. package/dist/customer.cjs.map +1 -1
  69. package/dist/customer.d.cts +1 -0
  70. package/dist/customer.d.ts +1 -0
  71. package/dist/customer.js +1 -1
  72. package/dist/index.cjs +197 -102
  73. package/dist/index.cjs.map +1 -1
  74. package/dist/index.d.cts +76 -4
  75. package/dist/index.d.ts +76 -4
  76. package/dist/index.js +210 -134
  77. package/dist/index.js.map +1 -1
  78. package/dist/locations.cjs +1 -0
  79. package/dist/locations.cjs.map +1 -1
  80. package/dist/locations.d.cts +1 -0
  81. package/dist/locations.d.ts +1 -0
  82. package/dist/locations.js +1 -1
  83. package/dist/media.cjs +1 -0
  84. package/dist/media.cjs.map +1 -1
  85. package/dist/media.d.cts +1 -0
  86. package/dist/media.d.ts +1 -0
  87. package/dist/media.js +1 -1
  88. package/dist/orders.cjs +2 -0
  89. package/dist/orders.cjs.map +1 -1
  90. package/dist/orders.d.cts +2 -0
  91. package/dist/orders.d.ts +2 -0
  92. package/dist/orders.js +1 -1
  93. package/dist/payment.cjs +1 -0
  94. package/dist/payment.cjs.map +1 -1
  95. package/dist/payment.d.cts +1 -0
  96. package/dist/payment.d.ts +1 -0
  97. package/dist/payment.js +1 -1
  98. package/dist/price.cjs +1 -0
  99. package/dist/price.cjs.map +1 -1
  100. package/dist/price.d.cts +1 -0
  101. package/dist/price.d.ts +1 -0
  102. package/dist/price.js +1 -1
  103. package/dist/product.cjs +1 -0
  104. package/dist/product.cjs.map +1 -1
  105. package/dist/product.d.cts +1 -0
  106. package/dist/product.d.ts +1 -0
  107. package/dist/product.js +1 -1
  108. package/dist/segment.cjs +2 -0
  109. package/dist/segment.cjs.map +1 -1
  110. package/dist/segment.d.cts +2 -0
  111. package/dist/segment.d.ts +2 -0
  112. package/dist/segment.js +1 -1
  113. package/package.json +2 -1
  114. package/dist/chunk-BDFOD7W3.js.map +0 -1
  115. package/dist/chunk-BPVMQFO4.js.map +0 -1
  116. package/dist/chunk-CR2JRH7T.js.map +0 -1
  117. package/dist/chunk-EINAVCV2.js.map +0 -1
  118. package/dist/chunk-FU5WQALW.js.map +0 -1
  119. package/dist/chunk-HAEVK6IS.js.map +0 -1
  120. package/dist/chunk-LGLFJL3S.js.map +0 -1
  121. package/dist/chunk-LGOC5XOI.js.map +0 -1
  122. package/dist/chunk-MIUVJEGR.js.map +0 -1
  123. package/dist/chunk-MM6JF3Z7.js.map +0 -1
  124. package/dist/chunk-P3UHYMDH.js.map +0 -1
  125. package/dist/chunk-UOBOFCFU.js.map +0 -1
  126. package/dist/chunk-WW3H7VJ5.js.map +0 -1
  127. package/dist/chunk-WWCCB22A.js.map +0 -1
  128. package/dist/chunk-XG2TKFY5.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,36 +1,36 @@
1
- import { LocationsService } from './chunk-LGLFJL3S.js';
2
- export { LocationsService } from './chunk-LGLFJL3S.js';
3
- import { MediaService } from './chunk-FU5WQALW.js';
4
- export { MediaService } from './chunk-FU5WQALW.js';
5
- import { OrdersService, SalesOrdersService } from './chunk-WW3H7VJ5.js';
6
- export { OrdersService, SalesOrdersService } from './chunk-WW3H7VJ5.js';
7
- import { PaymentGatewayService } from './chunk-EINAVCV2.js';
8
- export { PaymentGatewayService } from './chunk-EINAVCV2.js';
9
- import { PriceService } from './chunk-BDFOD7W3.js';
10
- export { PriceService } from './chunk-BDFOD7W3.js';
11
- import { ProductService } from './chunk-MIUVJEGR.js';
12
- export { ProductService } from './chunk-MIUVJEGR.js';
13
- import { SegmentService } from './chunk-CR2JRH7T.js';
14
- export { SegmentService } from './chunk-CR2JRH7T.js';
15
- import { AvailabilityService } from './chunk-BPVMQFO4.js';
16
- export { AvailabilityService } from './chunk-BPVMQFO4.js';
17
- import { CartService } from './chunk-P3UHYMDH.js';
18
- export { CartService } from './chunk-P3UHYMDH.js';
19
- import { CategoryService } from './chunk-WWCCB22A.js';
20
- export { CategoryService } from './chunk-WWCCB22A.js';
1
+ import { LocationsService } from './chunk-DUVIIWFG.js';
2
+ export { LocationsService } from './chunk-DUVIIWFG.js';
3
+ import { MediaService } from './chunk-OTG2S2L4.js';
4
+ export { MediaService } from './chunk-OTG2S2L4.js';
5
+ import { OrdersService, SalesOrdersService } from './chunk-62PCCHZ2.js';
6
+ export { OrdersService, SalesOrdersService } from './chunk-62PCCHZ2.js';
7
+ import { PaymentGatewayService } from './chunk-XEJPH6UN.js';
8
+ export { PaymentGatewayService } from './chunk-XEJPH6UN.js';
9
+ import { PriceService } from './chunk-A3LYJUD4.js';
10
+ export { PriceService } from './chunk-A3LYJUD4.js';
11
+ import { ProductService } from './chunk-5VTBLBXJ.js';
12
+ export { ProductService } from './chunk-5VTBLBXJ.js';
13
+ import { SegmentService } from './chunk-NE7MIZPR.js';
14
+ export { SegmentService } from './chunk-NE7MIZPR.js';
15
+ import { AvailabilityService } from './chunk-K3VQLW3P.js';
16
+ export { AvailabilityService } from './chunk-K3VQLW3P.js';
17
+ import { CartService } from './chunk-PAT4CS36.js';
18
+ export { CartService } from './chunk-PAT4CS36.js';
19
+ import { CategoryService } from './chunk-GIZS4BY3.js';
20
+ export { CategoryService } from './chunk-GIZS4BY3.js';
21
21
  export { iterateAll } from './chunk-GWJ2U2CP.js';
22
- import { CheckoutService } from './chunk-XG2TKFY5.js';
23
- export { CheckoutService } from './chunk-XG2TKFY5.js';
24
- import { CompaniesService } from './chunk-MM6JF3Z7.js';
25
- export { CompaniesService } from './chunk-MM6JF3Z7.js';
26
- import { ContactsService } from './chunk-HAEVK6IS.js';
27
- export { ContactsService } from './chunk-HAEVK6IS.js';
28
- import { CustomerGroupsService } from './chunk-LGOC5XOI.js';
29
- export { CustomerGroupsService } from './chunk-LGOC5XOI.js';
30
- import { CustomerService } from './chunk-UOBOFCFU.js';
31
- export { CustomerService } from './chunk-UOBOFCFU.js';
22
+ import { CheckoutService } from './chunk-RYQVMR26.js';
23
+ export { CheckoutService } from './chunk-RYQVMR26.js';
24
+ import { CompaniesService } from './chunk-BNX3JULF.js';
25
+ export { CompaniesService } from './chunk-BNX3JULF.js';
26
+ import { ContactsService } from './chunk-EAWGUZHS.js';
27
+ export { ContactsService } from './chunk-EAWGUZHS.js';
28
+ import { CustomerGroupsService } from './chunk-3BTPX7IJ.js';
29
+ export { CustomerGroupsService } from './chunk-3BTPX7IJ.js';
30
+ import { CustomerService } from './chunk-NEXUWPHW.js';
31
+ export { CustomerService } from './chunk-NEXUWPHW.js';
32
32
  import './chunk-3BDDYX3V.js';
33
- import { EmporixAuthError, EmporixTimeoutError, EmporixNetworkError, errorFromResponse, EmporixNotFoundError } from './chunk-UWGGF4MC.js';
33
+ import { EmporixAuthError, EmporixTimeoutError, EmporixNetworkError, errorFromResponse, EmporixNotFoundError, EmporixError } from './chunk-UWGGF4MC.js';
34
34
  export { EmporixAuthError, EmporixError, EmporixForbiddenError, EmporixInsufficientScopeError, EmporixNetworkError, EmporixNotFoundError, EmporixServerError, EmporixTimeoutError, EmporixValidationError, errorFromResponse } from './chunk-UWGGF4MC.js';
35
35
 
36
36
  // src/core/config.ts
@@ -728,6 +728,75 @@ var HttpClient = class {
728
728
  }
729
729
  };
730
730
 
731
+ // package.json
732
+ var version = "2.15.0";
733
+
734
+ // src/version.ts
735
+ var SDK_VERSION = version;
736
+
737
+ // src/core/create-core.ts
738
+ function createCore(config) {
739
+ const cfg = validateConfig(config);
740
+ let loggerObj = {};
741
+ let baseLogger;
742
+ if (cfg.logger === false) {
743
+ baseLogger = createNoopLogger();
744
+ } else if (cfg.logger && typeof cfg.logger.child === "function") {
745
+ baseLogger = cfg.logger;
746
+ } else if (cfg.logger) {
747
+ loggerObj = cfg.logger;
748
+ }
749
+ const resolver = new LevelResolver(loggerObj);
750
+ const root = baseLogger ?? createConsoleLogger(resolver, {
751
+ sdk: "emporix",
752
+ sdkVersion: SDK_VERSION,
753
+ tenant: cfg.tenant
754
+ });
755
+ const tokenProvider = cfg.tokenProvider ?? new DefaultTokenProvider(cfg);
756
+ const customerRefresh = new CustomerRefreshRegistry();
757
+ const requestContext = {
758
+ language: cfg.credentials.storefront?.context?.language
759
+ };
760
+ const mk = (service) => ({
761
+ tenant: cfg.tenant,
762
+ tokenProvider,
763
+ logger: root.child({ service }),
764
+ http: new HttpClient({
765
+ host: cfg.host,
766
+ provider: tokenProvider,
767
+ logger: root.child({ service: "http" }),
768
+ retry: cfg.retry,
769
+ timeouts: cfg.timeouts,
770
+ customerRefresh,
771
+ requestContext
772
+ })
773
+ });
774
+ return {
775
+ tenant: cfg.tenant,
776
+ config: cfg,
777
+ tokenProvider,
778
+ mk,
779
+ setStorefrontContext(ctx) {
780
+ if (ctx.language !== void 0) {
781
+ requestContext.language = ctx.language || void 0;
782
+ }
783
+ const { language: _language, ...priceContext } = ctx;
784
+ if (Object.keys(priceContext).length > 0) {
785
+ tokenProvider.setAnonymousContext?.(priceContext);
786
+ }
787
+ },
788
+ setLogLevel(level, opts = {}) {
789
+ resolver.set(level, opts.service, opts.force ?? false);
790
+ },
791
+ getLogLevel(service) {
792
+ return resolver.get(service);
793
+ },
794
+ setCustomerTokenRefresher(refresher) {
795
+ customerRefresh.set(refresher);
796
+ }
797
+ };
798
+ }
799
+
731
800
  // src/services/site.ts
732
801
  var ANON = auth.anonymous();
733
802
  var SiteService = class {
@@ -735,6 +804,7 @@ var SiteService = class {
735
804
  this.ctx = ctx;
736
805
  }
737
806
  ctx;
807
+ static channel = "site";
738
808
  /** Lists active sites. */
739
809
  async list(authCtx = ANON) {
740
810
  return this.ctx.http.request({
@@ -774,6 +844,7 @@ var SessionContextService = class {
774
844
  this.ctx = ctx;
775
845
  }
776
846
  ctx;
847
+ static channel = "session-context";
777
848
  /**
778
849
  * Retrieves the current session context, or `null` when the server returns
779
850
  * 404 (no session exists yet — the session-context is created server-side
@@ -837,6 +908,7 @@ var TenantConfigService = class {
837
908
  this.ctx = ctx;
838
909
  }
839
910
  ctx;
911
+ static channel = "configuration";
840
912
  base() {
841
913
  return `/configuration/${this.ctx.tenant}/configurations`;
842
914
  }
@@ -893,6 +965,7 @@ var ClientConfigService = class {
893
965
  this.ctx = ctx;
894
966
  }
895
967
  ctx;
968
+ static channel = "configuration";
896
969
  base(client) {
897
970
  return `/configuration/${this.ctx.tenant}/clients/${encodeURIComponent(client)}/configurations`;
898
971
  }
@@ -950,6 +1023,7 @@ var ShoppingListService = class {
950
1023
  this.ctx = ctx;
951
1024
  }
952
1025
  ctx;
1026
+ static channel = "shopping-list";
953
1027
  base() {
954
1028
  return `/shoppinglist/${this.ctx.tenant}/shopping-lists`;
955
1029
  }
@@ -1046,6 +1120,7 @@ var RagIndexerService = class {
1046
1120
  this.ctx = ctx;
1047
1121
  }
1048
1122
  ctx;
1123
+ static channel = "ai-rag-indexer";
1049
1124
  base(type) {
1050
1125
  return `/ai-rag-indexer/${this.ctx.tenant}/${encodeURIComponent(type)}`;
1051
1126
  }
@@ -1086,6 +1161,7 @@ var SequentialIdService = class {
1086
1161
  this.ctx = ctx;
1087
1162
  }
1088
1163
  ctx;
1164
+ static channel = "sequential-id";
1089
1165
  base() {
1090
1166
  return `/sequential-id/${this.ctx.tenant}/schemas`;
1091
1167
  }
@@ -1175,6 +1251,7 @@ var FeeService = class {
1175
1251
  this.ctx = ctx;
1176
1252
  }
1177
1253
  ctx;
1254
+ static channel = "fee";
1178
1255
  feesBase() {
1179
1256
  return `/fee/${this.ctx.tenant}/fees`;
1180
1257
  }
@@ -1334,6 +1411,7 @@ var CloudFunctionsService = class {
1334
1411
  this.ctx = ctx;
1335
1412
  }
1336
1413
  ctx;
1414
+ static channel = "cloud-functions";
1337
1415
  base() {
1338
1416
  return `/cloud-functions/${this.ctx.tenant}/functions`;
1339
1417
  }
@@ -1357,6 +1435,7 @@ var WebhookService = class {
1357
1435
  this.ctx = ctx;
1358
1436
  }
1359
1437
  ctx;
1438
+ static channel = "webhook";
1360
1439
  base() {
1361
1440
  return `/webhook/${this.ctx.tenant}`;
1362
1441
  }
@@ -1469,6 +1548,7 @@ var SchemaService = class {
1469
1548
  this.ctx = ctx;
1470
1549
  }
1471
1550
  ctx;
1551
+ static channel = "schema";
1472
1552
  schemasBase() {
1473
1553
  return `/schema/${this.ctx.tenant}/schemas`;
1474
1554
  }
@@ -1696,6 +1776,7 @@ var AiService = class {
1696
1776
  this.ctx = ctx;
1697
1777
  }
1698
1778
  ctx;
1779
+ static channel = "ai";
1699
1780
  base() {
1700
1781
  return `/ai-service/${this.ctx.tenant}`;
1701
1782
  }
@@ -1809,6 +1890,7 @@ var TaxService = class {
1809
1890
  this.ctx = ctx;
1810
1891
  }
1811
1892
  ctx;
1893
+ static channel = "tax";
1812
1894
  base() {
1813
1895
  return `/tax/${this.ctx.tenant}`;
1814
1896
  }
@@ -1878,6 +1960,7 @@ var CouponService = class {
1878
1960
  this.ctx = ctx;
1879
1961
  }
1880
1962
  ctx;
1963
+ static channel = "coupon";
1881
1964
  base() {
1882
1965
  return `/coupon/${this.ctx.tenant}`;
1883
1966
  }
@@ -2004,6 +2087,7 @@ var RewardPointsService = class {
2004
2087
  this.ctx = ctx;
2005
2088
  }
2006
2089
  ctx;
2090
+ static channel = "reward-points";
2007
2091
  /** Base without tenant (customer / public / batch endpoints). */
2008
2092
  base() {
2009
2093
  return `/reward-points`;
@@ -2158,6 +2242,7 @@ var BrandService = class {
2158
2242
  this.ctx = ctx;
2159
2243
  }
2160
2244
  ctx;
2245
+ static channel = "brand";
2161
2246
  base() {
2162
2247
  return `/brand/brands`;
2163
2248
  }
@@ -2222,6 +2307,7 @@ var LabelService = class {
2222
2307
  this.ctx = ctx;
2223
2308
  }
2224
2309
  ctx;
2310
+ static channel = "label";
2225
2311
  base() {
2226
2312
  return `/label/labels`;
2227
2313
  }
@@ -2286,6 +2372,7 @@ var CountryService = class {
2286
2372
  this.ctx = ctx;
2287
2373
  }
2288
2374
  ctx;
2375
+ static channel = "country";
2289
2376
  base() {
2290
2377
  return `/country/${this.ctx.tenant}`;
2291
2378
  }
@@ -2341,6 +2428,7 @@ var CurrencyService = class {
2341
2428
  this.ctx = ctx;
2342
2429
  }
2343
2430
  ctx;
2431
+ static channel = "currency";
2344
2432
  base() {
2345
2433
  return `/currency/${this.ctx.tenant}`;
2346
2434
  }
@@ -2441,6 +2529,7 @@ var ShippingService = class {
2441
2529
  this.ctx = ctx;
2442
2530
  }
2443
2531
  ctx;
2532
+ static channel = "shipping";
2444
2533
  base() {
2445
2534
  return `/shipping/${this.ctx.tenant}`;
2446
2535
  }
@@ -2855,6 +2944,7 @@ var ReturnsService = class {
2855
2944
  this.ctx = ctx;
2856
2945
  }
2857
2946
  ctx;
2947
+ static channel = "returns";
2858
2948
  base() {
2859
2949
  return `/return/${this.ctx.tenant}/returns`;
2860
2950
  }
@@ -2919,6 +3009,7 @@ var SepaExportService = class {
2919
3009
  this.ctx = ctx;
2920
3010
  }
2921
3011
  ctx;
3012
+ static channel = "sepa-export";
2922
3013
  base() {
2923
3014
  return `/sepa-export/${this.ctx.tenant}`;
2924
3015
  }
@@ -2959,6 +3050,7 @@ var IndexingService = class {
2959
3050
  this.ctx = ctx;
2960
3051
  }
2961
3052
  ctx;
3053
+ static channel = "indexing";
2962
3054
  base() {
2963
3055
  return `/indexing/${this.ctx.tenant}`;
2964
3056
  }
@@ -3025,6 +3117,7 @@ var UnitHandlingService = class {
3025
3117
  this.ctx = ctx;
3026
3118
  }
3027
3119
  ctx;
3120
+ static channel = "unit-handling";
3028
3121
  base() {
3029
3122
  return `/unit-handling/${this.ctx.tenant}`;
3030
3123
  }
@@ -3106,6 +3199,7 @@ var CatalogService = class {
3106
3199
  this.ctx = ctx;
3107
3200
  }
3108
3201
  ctx;
3202
+ static channel = "catalog";
3109
3203
  base() {
3110
3204
  return `/catalog/${this.ctx.tenant}/catalogs`;
3111
3205
  }
@@ -3173,6 +3267,7 @@ var VendorService = class {
3173
3267
  this.ctx = ctx;
3174
3268
  }
3175
3269
  ctx;
3270
+ static channel = "vendor";
3176
3271
  base() {
3177
3272
  return `/vendor/${this.ctx.tenant}`;
3178
3273
  }
@@ -3272,6 +3367,7 @@ var PickPackService = class {
3272
3367
  this.ctx = ctx;
3273
3368
  }
3274
3369
  ctx;
3370
+ static channel = "pick-pack";
3275
3371
  base() {
3276
3372
  return `/pick-pack/${this.ctx.tenant}`;
3277
3373
  }
@@ -3363,6 +3459,7 @@ var CustomerAdminService = class {
3363
3459
  this.ctx = ctx;
3364
3460
  }
3365
3461
  ctx;
3462
+ static channel = "customer-admin";
3366
3463
  base() {
3367
3464
  return `/customer/${this.ctx.tenant}/customers`;
3368
3465
  }
@@ -3467,6 +3564,7 @@ var ApprovalService = class {
3467
3564
  this.ctx = ctx;
3468
3565
  }
3469
3566
  ctx;
3567
+ static channel = "approval";
3470
3568
  base() {
3471
3569
  return `/approval/${this.ctx.tenant}`;
3472
3570
  }
@@ -3533,12 +3631,6 @@ var ApprovalService = class {
3533
3631
  }
3534
3632
  };
3535
3633
 
3536
- // package.json
3537
- var version = "2.14.0";
3538
-
3539
- // src/version.ts
3540
- var SDK_VERSION = version;
3541
-
3542
3634
  // src/client.ts
3543
3635
  var EmporixClient = class {
3544
3636
  customers;
@@ -3601,96 +3693,62 @@ var EmporixClient = class {
3601
3693
  * Provider tree. Treat as read-only.
3602
3694
  */
3603
3695
  config;
3604
- resolver;
3605
- customerRefresh;
3606
- requestContext;
3696
+ core;
3607
3697
  constructor(config) {
3608
- const cfg = validateConfig(config);
3609
- this.tenant = cfg.tenant;
3610
- this.config = cfg;
3611
- let loggerObj = {};
3612
- let baseLogger;
3613
- if (cfg.logger === false) {
3614
- baseLogger = createNoopLogger();
3615
- } else if (cfg.logger && typeof cfg.logger.child === "function") {
3616
- baseLogger = cfg.logger;
3617
- } else if (cfg.logger) {
3618
- loggerObj = cfg.logger;
3619
- }
3620
- this.resolver = new LevelResolver(loggerObj);
3621
- const root = baseLogger ?? createConsoleLogger(this.resolver, {
3622
- sdk: "emporix",
3623
- sdkVersion: SDK_VERSION,
3624
- tenant: cfg.tenant
3625
- });
3626
- const tokenProvider = cfg.tokenProvider ?? new DefaultTokenProvider(cfg);
3627
- this.tokenProvider = tokenProvider;
3628
- const customerRefresh = new CustomerRefreshRegistry();
3629
- this.customerRefresh = customerRefresh;
3630
- this.requestContext = { language: cfg.credentials.storefront?.context?.language };
3631
- const requestContext = this.requestContext;
3632
- const mk = (service) => ({
3633
- tenant: cfg.tenant,
3634
- tokenProvider,
3635
- logger: root.child({ service }),
3636
- http: new HttpClient({
3637
- host: cfg.host,
3638
- provider: tokenProvider,
3639
- logger: root.child({ service: "http" }),
3640
- retry: cfg.retry,
3641
- timeouts: cfg.timeouts,
3642
- customerRefresh,
3643
- requestContext
3644
- })
3645
- });
3646
- this.customers = new CustomerService(mk("customer"));
3647
- this.products = new ProductService(mk("product"));
3648
- this.categories = new CategoryService(mk("category"));
3649
- this.carts = new CartService(mk("cart"));
3650
- this.checkout = new CheckoutService(mk("checkout"));
3651
- this.payments = new PaymentGatewayService(mk("payment"));
3652
- this.prices = new PriceService(mk("price"));
3653
- this.media = new MediaService(mk("media"));
3654
- this.segments = new SegmentService(mk("segment"), {
3698
+ const core = createCore(config);
3699
+ this.core = core;
3700
+ this.tenant = core.tenant;
3701
+ this.config = core.config;
3702
+ this.tokenProvider = core.tokenProvider;
3703
+ const mk = core.mk;
3704
+ this.customers = new CustomerService(mk(CustomerService.channel));
3705
+ this.products = new ProductService(mk(ProductService.channel));
3706
+ this.categories = new CategoryService(mk(CategoryService.channel));
3707
+ this.carts = new CartService(mk(CartService.channel));
3708
+ this.checkout = new CheckoutService(mk(CheckoutService.channel));
3709
+ this.payments = new PaymentGatewayService(mk(PaymentGatewayService.channel));
3710
+ this.prices = new PriceService(mk(PriceService.channel));
3711
+ this.media = new MediaService(mk(MediaService.channel));
3712
+ this.segments = new SegmentService(mk(SegmentService.channel), {
3655
3713
  products: this.products,
3656
3714
  categories: this.categories
3657
3715
  });
3658
- this.sites = new SiteService(mk("site"));
3659
- this.sessionContext = new SessionContextService(mk("session-context"));
3660
- this.companies = new CompaniesService(mk("customer-management"));
3661
- this.contacts = new ContactsService(mk("customer-management"));
3662
- this.locations = new LocationsService(mk("customer-management"));
3663
- this.customerGroups = new CustomerGroupsService(mk("iam"));
3664
- this.orders = new OrdersService(mk("orders"));
3665
- this.salesOrders = new SalesOrdersService(mk("sales-orders"));
3666
- this.availability = new AvailabilityService(mk("availability"));
3667
- this.tenantConfig = new TenantConfigService(mk("configuration"));
3668
- this.clientConfig = new ClientConfigService(mk("configuration"));
3669
- this.shoppingLists = new ShoppingListService(mk("shopping-list"));
3670
- this.ragIndexer = new RagIndexerService(mk("ai-rag-indexer"));
3671
- this.sequentialIds = new SequentialIdService(mk("sequential-id"));
3672
- this.fees = new FeeService(mk("fee"));
3673
- this.cloudFunctions = new CloudFunctionsService(mk("cloud-functions"));
3674
- this.webhooks = new WebhookService(mk("webhook"));
3675
- this.schemas = new SchemaService(mk("schema"));
3676
- this.ai = new AiService(mk("ai"));
3677
- this.taxes = new TaxService(mk("tax"));
3678
- this.coupons = new CouponService(mk("coupon"));
3679
- this.rewardPoints = new RewardPointsService(mk("reward-points"));
3680
- this.brands = new BrandService(mk("brand"));
3681
- this.labels = new LabelService(mk("label"));
3682
- this.countries = new CountryService(mk("country"));
3683
- this.currencies = new CurrencyService(mk("currency"));
3684
- this.shipping = new ShippingService(mk("shipping"));
3685
- this.returns = new ReturnsService(mk("returns"));
3686
- this.sepaExport = new SepaExportService(mk("sepa-export"));
3687
- this.indexing = new IndexingService(mk("indexing"));
3688
- this.units = new UnitHandlingService(mk("unit-handling"));
3689
- this.catalogs = new CatalogService(mk("catalog"));
3690
- this.vendors = new VendorService(mk("vendor"));
3691
- this.pickPack = new PickPackService(mk("pick-pack"));
3692
- this.customerAdmin = new CustomerAdminService(mk("customer-admin"));
3693
- this.approvals = new ApprovalService(mk("approval"));
3716
+ this.sites = new SiteService(mk(SiteService.channel));
3717
+ this.sessionContext = new SessionContextService(mk(SessionContextService.channel));
3718
+ this.companies = new CompaniesService(mk(CompaniesService.channel));
3719
+ this.contacts = new ContactsService(mk(ContactsService.channel));
3720
+ this.locations = new LocationsService(mk(LocationsService.channel));
3721
+ this.customerGroups = new CustomerGroupsService(mk(CustomerGroupsService.channel));
3722
+ this.orders = new OrdersService(mk(OrdersService.channel));
3723
+ this.salesOrders = new SalesOrdersService(mk(SalesOrdersService.channel));
3724
+ this.availability = new AvailabilityService(mk(AvailabilityService.channel));
3725
+ this.tenantConfig = new TenantConfigService(mk(TenantConfigService.channel));
3726
+ this.clientConfig = new ClientConfigService(mk(ClientConfigService.channel));
3727
+ this.shoppingLists = new ShoppingListService(mk(ShoppingListService.channel));
3728
+ this.ragIndexer = new RagIndexerService(mk(RagIndexerService.channel));
3729
+ this.sequentialIds = new SequentialIdService(mk(SequentialIdService.channel));
3730
+ this.fees = new FeeService(mk(FeeService.channel));
3731
+ this.cloudFunctions = new CloudFunctionsService(mk(CloudFunctionsService.channel));
3732
+ this.webhooks = new WebhookService(mk(WebhookService.channel));
3733
+ this.schemas = new SchemaService(mk(SchemaService.channel));
3734
+ this.ai = new AiService(mk(AiService.channel));
3735
+ this.taxes = new TaxService(mk(TaxService.channel));
3736
+ this.coupons = new CouponService(mk(CouponService.channel));
3737
+ this.rewardPoints = new RewardPointsService(mk(RewardPointsService.channel));
3738
+ this.brands = new BrandService(mk(BrandService.channel));
3739
+ this.labels = new LabelService(mk(LabelService.channel));
3740
+ this.countries = new CountryService(mk(CountryService.channel));
3741
+ this.currencies = new CurrencyService(mk(CurrencyService.channel));
3742
+ this.shipping = new ShippingService(mk(ShippingService.channel));
3743
+ this.returns = new ReturnsService(mk(ReturnsService.channel));
3744
+ this.sepaExport = new SepaExportService(mk(SepaExportService.channel));
3745
+ this.indexing = new IndexingService(mk(IndexingService.channel));
3746
+ this.units = new UnitHandlingService(mk(UnitHandlingService.channel));
3747
+ this.catalogs = new CatalogService(mk(CatalogService.channel));
3748
+ this.vendors = new VendorService(mk(VendorService.channel));
3749
+ this.pickPack = new PickPackService(mk(PickPackService.channel));
3750
+ this.customerAdmin = new CustomerAdminService(mk(CustomerAdminService.channel));
3751
+ this.approvals = new ApprovalService(mk(ApprovalService.channel));
3694
3752
  }
3695
3753
  /**
3696
3754
  * Re-binds the storefront price context (currency / siteCode / targetLocation)
@@ -3703,21 +3761,15 @@ var EmporixClient = class {
3703
3761
  * read); a language-only change does NOT re-mint the token.
3704
3762
  */
3705
3763
  setStorefrontContext(ctx) {
3706
- if (ctx.language !== void 0) {
3707
- this.requestContext.language = ctx.language || void 0;
3708
- }
3709
- const { language: _language, ...priceContext } = ctx;
3710
- if (Object.keys(priceContext).length > 0) {
3711
- this.tokenProvider.setAnonymousContext?.(priceContext);
3712
- }
3764
+ this.core.setStorefrontContext(ctx);
3713
3765
  }
3714
3766
  /** Sets the runtime log level globally or for one service. */
3715
3767
  setLogLevel(level, opts = {}) {
3716
- this.resolver.set(level, opts.service, opts.force ?? false);
3768
+ this.core.setLogLevel(level, opts);
3717
3769
  }
3718
3770
  /** Returns the effective log level for a service. */
3719
3771
  getLogLevel(service) {
3720
- return this.resolver.get(service);
3772
+ return this.core.getLogLevel(service);
3721
3773
  }
3722
3774
  /**
3723
3775
  * Registers (or clears with `null`) a customer-token refresher. When set, a
@@ -3726,10 +3778,34 @@ var EmporixClient = class {
3726
3778
  * automatically via `autoRefreshCustomerToken`.
3727
3779
  */
3728
3780
  setCustomerTokenRefresher(refresher) {
3729
- this.customerRefresh.set(refresher);
3781
+ this.core.setCustomerTokenRefresher(refresher);
3730
3782
  }
3731
3783
  };
3732
3784
 
3785
+ // src/create-emporix-client.ts
3786
+ function createEmporixClient(config, services) {
3787
+ const { mk, ...core } = createCore(config);
3788
+ const built = {};
3789
+ const entries = Object.entries(services);
3790
+ for (const [key, Svc] of entries) {
3791
+ if (!Svc.deps?.length) built[key] = new Svc(mk(Svc.channel));
3792
+ }
3793
+ for (const [key, Svc] of entries) {
3794
+ if (!Svc.deps?.length) continue;
3795
+ const deps = {};
3796
+ for (const dep of Svc.deps) {
3797
+ if (!(dep in built)) {
3798
+ throw new EmporixError(
3799
+ `createEmporixClient: "${key}" requires "${dep}" in the services map`
3800
+ );
3801
+ }
3802
+ deps[dep] = built[dep];
3803
+ }
3804
+ built[key] = new Svc(mk(Svc.channel), deps);
3805
+ }
3806
+ return { ...core, ...built };
3807
+ }
3808
+
3733
3809
  // src/core/yrn.ts
3734
3810
  function productIdFromYrn(yrn) {
3735
3811
  if (!yrn) return "";
@@ -3737,6 +3813,6 @@ function productIdFromYrn(yrn) {
3737
3813
  return semi >= 0 ? yrn.slice(semi + 1) : "";
3738
3814
  }
3739
3815
 
3740
- export { AiService, ApprovalService, BrandService, CatalogService, ClientConfigService, CloudFunctionsService, CountryService, CouponService, CurrencyService, CustomerAdminService, CustomerRefreshRegistry, DEFAULT_HOST, DefaultTokenProvider, EmporixClient, FeeService, HttpClient, IndexingService, LEVEL, LabelService, LevelResolver, PickPackService, RagIndexerService, ReturnsService, RewardPointsService, SchemaService, SepaExportService, SequentialIdService, SessionContextService, ShippingService, ShoppingListService, SiteService, TaxService, TenantConfigService, UnitHandlingService, VendorService, WebhookService, auth, createConsoleLogger, createNoopLogger, productIdFromYrn, redact, resolveToken, validateConfig };
3816
+ export { AiService, ApprovalService, BrandService, CatalogService, ClientConfigService, CloudFunctionsService, CountryService, CouponService, CurrencyService, CustomerAdminService, CustomerRefreshRegistry, DEFAULT_HOST, DefaultTokenProvider, EmporixClient, FeeService, HttpClient, IndexingService, LEVEL, LabelService, LevelResolver, PickPackService, RagIndexerService, ReturnsService, RewardPointsService, SchemaService, SepaExportService, SequentialIdService, SessionContextService, ShippingService, ShoppingListService, SiteService, TaxService, TenantConfigService, UnitHandlingService, VendorService, WebhookService, auth, createConsoleLogger, createCore, createEmporixClient, createNoopLogger, productIdFromYrn, redact, resolveToken, validateConfig };
3741
3817
  //# sourceMappingURL=index.js.map
3742
3818
  //# sourceMappingURL=index.js.map