@reactionary/hcl 0.10.2 → 0.10.4

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Solteq
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -5,8 +5,7 @@ var __decorateClass = (decorators, target, key, kind) => {
5
5
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
6
  if (decorator = decorators[i])
7
7
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
- if (kind && result)
9
- __defProp(target, key, result);
8
+ if (kind && result) __defProp(target, key, result);
10
9
  return result;
11
10
  };
12
11
  import {
@@ -22,6 +21,8 @@ class HclAnalyticsCapability extends AnalyticsCapability {
22
21
  this.config = config;
23
22
  this.client = client;
24
23
  }
24
+ config;
25
+ client;
25
26
  async track(event) {
26
27
  return super.track(event);
27
28
  }
@@ -5,8 +5,7 @@ var __decorateClass = (decorators, target, key, kind) => {
5
5
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
6
  if (decorator = decorators[i])
7
7
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
- if (kind && result)
9
- __defProp(target, key, result);
8
+ if (kind && result) __defProp(target, key, result);
10
9
  return result;
11
10
  };
12
11
  import {
@@ -72,8 +71,7 @@ class HclCartCapability extends CartCapability {
72
71
  void 0,
73
72
  { allowUndefined: true }
74
73
  );
75
- if (!data)
76
- throw new HclCartNotFoundError();
74
+ if (!data) throw new HclCartNotFoundError();
77
75
  return data;
78
76
  }
79
77
  cartUrl() {
@@ -94,8 +92,7 @@ class HclCartCapability extends CartCapability {
94
92
  void 0,
95
93
  { allowUndefined: true }
96
94
  );
97
- if (!data)
98
- throw new HclCartNotFoundError();
95
+ if (!data) throw new HclCartNotFoundError();
99
96
  return data;
100
97
  }
101
98
  /** Fetch and parse the current cart via the factory. */
@@ -146,8 +143,7 @@ class HclCartCapability extends CartCapability {
146
143
  createOrderParams(description, currency) {
147
144
  const params = new URLSearchParams();
148
145
  params.set("description", description ?? "");
149
- if (currency)
150
- params.set("currency", currency);
146
+ if (currency) params.set("currency", currency);
151
147
  return params;
152
148
  }
153
149
  updateOrderDescriptionUrl() {
@@ -5,8 +5,7 @@ var __decorateClass = (decorators, target, key, kind) => {
5
5
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
6
  if (decorator = decorators[i])
7
7
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
- if (kind && result)
9
- __defProp(target, key, result);
8
+ if (kind && result) __defProp(target, key, result);
10
9
  return result;
11
10
  };
12
11
  import {
@@ -30,6 +29,9 @@ class HclCategoryCapability extends CategoryCapability {
30
29
  this.client = client;
31
30
  this.factory = factory;
32
31
  }
32
+ config;
33
+ client;
34
+ factory;
33
35
  async getById(payload) {
34
36
  const response = await this.client.callGet(
35
37
  this.getByIdUrl(payload),
@@ -187,16 +189,12 @@ class HclCategoryCapability extends CategoryCapability {
187
189
  const params = new URLSearchParams();
188
190
  params.set("storeId", query.storeId ?? this.config.storeId);
189
191
  const catalogId = query.catalogId ?? this.config.catalogId;
190
- if (catalogId)
191
- params.set("catalogId", catalogId);
192
+ if (catalogId) params.set("catalogId", catalogId);
192
193
  if (query.parentCategoryId)
193
194
  params.set("parentCategoryId", query.parentCategoryId);
194
- if (query.depthAndLimit)
195
- params.set("depthAndLimit", query.depthAndLimit);
196
- if (query.profileName)
197
- params.set("profileName", query.profileName);
198
- for (const id of query.id ?? [])
199
- params.append("id", id);
195
+ if (query.depthAndLimit) params.set("depthAndLimit", query.depthAndLimit);
196
+ if (query.profileName) params.set("profileName", query.profileName);
197
+ for (const id of query.id ?? []) params.append("id", id);
200
198
  for (const identifier of query.identifier ?? [])
201
199
  params.append("identifier", identifier);
202
200
  return params;
@@ -5,8 +5,7 @@ var __decorateClass = (decorators, target, key, kind) => {
5
5
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
6
  if (decorator = decorators[i])
7
7
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
- if (kind && result)
9
- __defProp(target, key, result);
8
+ if (kind && result) __defProp(target, key, result);
10
9
  return result;
11
10
  };
12
11
  import {
@@ -50,8 +49,7 @@ class HclCheckoutCapability extends CheckoutCapability {
50
49
  void 0,
51
50
  { allowUndefined: true }
52
51
  );
53
- if (!data)
54
- throw new HclCartNotFoundError();
52
+ if (!data) throw new HclCartNotFoundError();
55
53
  return data;
56
54
  }
57
55
  /** Fetch and parse the active cart as a Checkout. */
@@ -5,8 +5,7 @@ var __decorateClass = (decorators, target, key, kind) => {
5
5
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
6
  if (decorator = decorators[i])
7
7
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
- if (kind && result)
9
- __defProp(target, key, result);
8
+ if (kind && result) __defProp(target, key, result);
10
9
  return result;
11
10
  };
12
11
  import {
@@ -246,8 +245,7 @@ class HclCompanyCapability extends CompanyCapability {
246
245
  }
247
246
  async fetchOrganizationOrThrow(orgId) {
248
247
  const org = await this.fetchOrganization(orgId);
249
- if (!org)
250
- throw new Error(`Organization not found: ${orgId}`);
248
+ if (!org) throw new Error(`Organization not found: ${orgId}`);
251
249
  return org;
252
250
  }
253
251
  toOrgContact(address) {
@@ -5,8 +5,7 @@ var __decorateClass = (decorators, target, key, kind) => {
5
5
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
6
  if (decorator = decorators[i])
7
7
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
- if (kind && result)
9
- __defProp(target, key, result);
8
+ if (kind && result) __defProp(target, key, result);
10
9
  return result;
11
10
  };
12
11
  import {
@@ -5,8 +5,7 @@ var __decorateClass = (decorators, target, key, kind) => {
5
5
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
6
  if (decorator = decorators[i])
7
7
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
- if (kind && result)
9
- __defProp(target, key, result);
8
+ if (kind && result) __defProp(target, key, result);
10
9
  return result;
11
10
  };
12
11
  import {
@@ -24,6 +23,9 @@ class HclInventoryCapability extends InventoryCapability {
24
23
  this.client = client;
25
24
  this.factory = factory;
26
25
  }
26
+ config;
27
+ client;
28
+ factory;
27
29
  async getBySKU(payload) {
28
30
  const { sku } = payload.variant;
29
31
  const centreKey = payload.fulfilmentCenter.key;
@@ -59,8 +61,7 @@ class HclInventoryCapability extends InventoryCapability {
59
61
  getBySKUPayload(payload) {
60
62
  const params = new URLSearchParams();
61
63
  const centreKey = payload.fulfilmentCenter.key;
62
- if (centreKey)
63
- params.set("physicalStoreName", centreKey);
64
+ if (centreKey) params.set("physicalStoreName", centreKey);
64
65
  return params;
65
66
  }
66
67
  }
@@ -5,8 +5,7 @@ var __decorateClass = (decorators, target, key, kind) => {
5
5
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
6
  if (decorator = decorators[i])
7
7
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
- if (kind && result)
9
- __defProp(target, key, result);
8
+ if (kind && result) __defProp(target, key, result);
10
9
  return result;
11
10
  };
12
11
  import {
@@ -5,8 +5,7 @@ var __decorateClass = (decorators, target, key, kind) => {
5
5
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
6
  if (decorator = decorators[i])
7
7
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
- if (kind && result)
9
- __defProp(target, key, result);
8
+ if (kind && result) __defProp(target, key, result);
10
9
  return result;
11
10
  };
12
11
  import {
@@ -5,8 +5,7 @@ var __decorateClass = (decorators, target, key, kind) => {
5
5
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
6
  if (decorator = decorators[i])
7
7
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
- if (kind && result)
9
- __defProp(target, key, result);
8
+ if (kind && result) __defProp(target, key, result);
10
9
  return result;
11
10
  };
12
11
  import {
@@ -24,6 +23,9 @@ class HclPersonalizationProfileCapability extends PersonalizationProfileCapabili
24
23
  this.client = client;
25
24
  this.factory = factory;
26
25
  }
26
+ config;
27
+ client;
28
+ factory;
27
29
  async getPersonalizationProfile(_payload) {
28
30
  const personalizationId = this.context.session[SESSION_KEY_PERSONALIZATION_ID];
29
31
  if (!personalizationId) {
@@ -5,8 +5,7 @@ var __decorateClass = (decorators, target, key, kind) => {
5
5
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
6
  if (decorator = decorators[i])
7
7
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
- if (kind && result)
9
- __defProp(target, key, result);
8
+ if (kind && result) __defProp(target, key, result);
10
9
  return result;
11
10
  };
12
11
  import {
@@ -25,6 +24,9 @@ class HclPriceCapability extends PriceCapability {
25
24
  this.client = client;
26
25
  this.factory = factory;
27
26
  }
27
+ config;
28
+ client;
29
+ factory;
28
30
  async getListPrice(payload) {
29
31
  const sku = payload.variant.sku;
30
32
  const priceRuleId = this.context.session[SESSION_KEY_PRICE_RULE_ID];
@@ -5,8 +5,7 @@ var __decorateClass = (decorators, target, key, kind) => {
5
5
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
6
  if (decorator = decorators[i])
7
7
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
- if (kind && result)
9
- __defProp(target, key, result);
8
+ if (kind && result) __defProp(target, key, result);
10
9
  return result;
11
10
  };
12
11
  import {
@@ -26,6 +25,9 @@ class HclProductAssociationsCapability extends ProductAssociationsCapability {
26
25
  this.client = client;
27
26
  this.factory = factory;
28
27
  }
28
+ config;
29
+ client;
30
+ factory;
29
31
  async getAccessories(query) {
30
32
  const associations = await this.fetchAssociations(
31
33
  query.forProduct.key,
@@ -5,8 +5,7 @@ var __decorateClass = (decorators, target, key, kind) => {
5
5
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
6
  if (decorator = decorators[i])
7
7
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
- if (kind && result)
9
- __defProp(target, key, result);
8
+ if (kind && result) __defProp(target, key, result);
10
9
  return result;
11
10
  };
12
11
  import {
@@ -530,8 +529,7 @@ class HclProductListCapability extends ProductListCapability {
530
529
  }
531
530
  getUpdateWishlistBody(mutation) {
532
531
  const body = {};
533
- if (mutation.name !== void 0)
534
- body["descriptionName"] = mutation.name;
532
+ if (mutation.name !== void 0) body["descriptionName"] = mutation.name;
535
533
  if (mutation.description !== void 0) {
536
534
  body["description"] = encodeWishlistType(
537
535
  mutation.list.listType,
@@ -585,8 +583,7 @@ class HclProductListCapability extends ProductListCapability {
585
583
  }
586
584
  getUpdateRequisitionListBody(mutation) {
587
585
  const body = {};
588
- if (mutation.name !== void 0)
589
- body["name"] = mutation.name;
586
+ if (mutation.name !== void 0) body["name"] = mutation.name;
590
587
  if (mutation.description !== void 0)
591
588
  body["description"] = mutation.description;
592
589
  return body;
@@ -5,8 +5,7 @@ var __decorateClass = (decorators, target, key, kind) => {
5
5
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
6
  if (decorator = decorators[i])
7
7
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
- if (kind && result)
9
- __defProp(target, key, result);
8
+ if (kind && result) __defProp(target, key, result);
10
9
  return result;
11
10
  };
12
11
  import {
@@ -23,6 +22,9 @@ class HclProductRecommendationsCapability extends ProductRecommendationsCapabili
23
22
  this.client = client;
24
23
  this.factory = factory;
25
24
  }
25
+ config;
26
+ client;
27
+ factory;
26
28
  getRecommendations(...args) {
27
29
  return super.getRecommendations(...args);
28
30
  }
@@ -119,10 +121,8 @@ class HclProductRecommendationsCapability extends ProductRecommendationsCapabili
119
121
  getEspotParams(params) {
120
122
  const searchParams = new URLSearchParams();
121
123
  const count = params["count"];
122
- if (count)
123
- searchParams.set("DM_DisplayProducts", count);
124
- if (params["productId"])
125
- searchParams.set("productId", params["productId"]);
124
+ if (count) searchParams.set("DM_DisplayProducts", count);
125
+ if (params["productId"]) searchParams.set("productId", params["productId"]);
126
126
  if (params["categoryId"])
127
127
  searchParams.set("categoryId", params["categoryId"]);
128
128
  return searchParams;
@@ -5,8 +5,7 @@ var __decorateClass = (decorators, target, key, kind) => {
5
5
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
6
  if (decorator = decorators[i])
7
7
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
- if (kind && result)
9
- __defProp(target, key, result);
8
+ if (kind && result) __defProp(target, key, result);
10
9
  return result;
11
10
  };
12
11
  import {
@@ -25,6 +24,9 @@ class HclProductSearchCapability extends ProductSearchCapability {
25
24
  this.client = client;
26
25
  this.factory = factory;
27
26
  }
27
+ config;
28
+ client;
29
+ factory;
28
30
  queryByTermPayload(payload) {
29
31
  const { term, paginationOptions, categoryFilter, facets } = payload.search;
30
32
  const { pageNumber, pageSize } = paginationOptions;
@@ -77,28 +79,18 @@ class HclProductSearchCapability extends ProductSearchCapability {
77
79
  const params = new URLSearchParams();
78
80
  params.set("storeId", query.storeId ?? this.config.storeId);
79
81
  const catalogId = query.catalogId ?? this.config.catalogId;
80
- if (catalogId)
81
- params.set("catalogId", catalogId);
82
- if (query.categoryId)
83
- params.set("categoryId", query.categoryId);
84
- if (query.searchTerm)
85
- params.set("searchTerm", query.searchTerm);
86
- if (query.contractId)
87
- params.set("contractId", query.contractId);
88
- if (query.profileName)
89
- params.set("profileName", query.profileName);
90
- if (query.limit !== void 0)
91
- params.set("limit", String(query.limit));
92
- if (query.offset !== void 0)
93
- params.set("offset", String(query.offset));
82
+ if (catalogId) params.set("catalogId", catalogId);
83
+ if (query.categoryId) params.set("categoryId", query.categoryId);
84
+ if (query.searchTerm) params.set("searchTerm", query.searchTerm);
85
+ if (query.contractId) params.set("contractId", query.contractId);
86
+ if (query.profileName) params.set("profileName", query.profileName);
87
+ if (query.limit !== void 0) params.set("limit", String(query.limit));
88
+ if (query.offset !== void 0) params.set("offset", String(query.offset));
94
89
  if (query.checkEntitlement !== void 0)
95
90
  params.set("checkEntitlement", String(query.checkEntitlement));
96
- for (const id of query.id ?? [])
97
- params.append("id", id);
98
- for (const pn of query.partNumber ?? [])
99
- params.append("partNumber", pn);
100
- for (const facet of query.facets ?? [])
101
- params.append("facet", facet);
91
+ for (const id of query.id ?? []) params.append("id", id);
92
+ for (const pn of query.partNumber ?? []) params.append("partNumber", pn);
93
+ for (const facet of query.facets ?? []) params.append("facet", facet);
102
94
  return params;
103
95
  }
104
96
  categoriesUrl() {
@@ -108,16 +100,12 @@ class HclProductSearchCapability extends ProductSearchCapability {
108
100
  const params = new URLSearchParams();
109
101
  params.set("storeId", query.storeId ?? this.config.storeId);
110
102
  const catalogId = query.catalogId ?? this.config.catalogId;
111
- if (catalogId)
112
- params.set("catalogId", catalogId);
103
+ if (catalogId) params.set("catalogId", catalogId);
113
104
  if (query.parentCategoryId)
114
105
  params.set("parentCategoryId", query.parentCategoryId);
115
- if (query.depthAndLimit)
116
- params.set("depthAndLimit", query.depthAndLimit);
117
- if (query.profileName)
118
- params.set("profileName", query.profileName);
119
- for (const id of query.id ?? [])
120
- params.append("id", id);
106
+ if (query.depthAndLimit) params.set("depthAndLimit", query.depthAndLimit);
107
+ if (query.profileName) params.set("profileName", query.profileName);
108
+ for (const id of query.id ?? []) params.append("id", id);
121
109
  for (const identifier of query.identifier ?? [])
122
110
  params.append("identifier", identifier);
123
111
  return params;
@@ -5,8 +5,7 @@ var __decorateClass = (decorators, target, key, kind) => {
5
5
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
6
  if (decorator = decorators[i])
7
7
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
- if (kind && result)
9
- __defProp(target, key, result);
8
+ if (kind && result) __defProp(target, key, result);
10
9
  return result;
11
10
  };
12
11
  import {
@@ -26,6 +25,9 @@ class HclProductCapability extends ProductCapability {
26
25
  this.client = client;
27
26
  this.factory = factory;
28
27
  }
28
+ config;
29
+ client;
30
+ factory;
29
31
  async getById(payload) {
30
32
  const response = await this.client.callGet(
31
33
  this.getByIdUrl(payload),
@@ -107,8 +109,7 @@ class HclProductCapability extends ProductCapability {
107
109
  rawIds.map((p) => p.split("/").filter(Boolean).at(-1)).filter((id) => id !== void 0)
108
110
  )
109
111
  ];
110
- if (uniqueIds.length === 0)
111
- return data;
112
+ if (uniqueIds.length === 0) return data;
112
113
  const catResp = await this.client.callGet(
113
114
  this.categoriesUrl(),
114
115
  this.categoriesParams({ id: uniqueIds })
@@ -153,28 +154,18 @@ class HclProductCapability extends ProductCapability {
153
154
  const params = new URLSearchParams();
154
155
  params.set("storeId", query.storeId ?? this.config.storeId);
155
156
  const catalogId = query.catalogId ?? this.config.catalogId;
156
- if (catalogId)
157
- params.set("catalogId", catalogId);
158
- if (query.categoryId)
159
- params.set("categoryId", query.categoryId);
160
- if (query.searchTerm)
161
- params.set("searchTerm", query.searchTerm);
162
- if (query.contractId)
163
- params.set("contractId", query.contractId);
164
- if (query.profileName)
165
- params.set("profileName", query.profileName);
166
- if (query.limit !== void 0)
167
- params.set("limit", String(query.limit));
168
- if (query.offset !== void 0)
169
- params.set("offset", String(query.offset));
157
+ if (catalogId) params.set("catalogId", catalogId);
158
+ if (query.categoryId) params.set("categoryId", query.categoryId);
159
+ if (query.searchTerm) params.set("searchTerm", query.searchTerm);
160
+ if (query.contractId) params.set("contractId", query.contractId);
161
+ if (query.profileName) params.set("profileName", query.profileName);
162
+ if (query.limit !== void 0) params.set("limit", String(query.limit));
163
+ if (query.offset !== void 0) params.set("offset", String(query.offset));
170
164
  if (query.checkEntitlement !== void 0)
171
165
  params.set("checkEntitlement", String(query.checkEntitlement));
172
- for (const id of query.id ?? [])
173
- params.append("id", id);
174
- for (const pn of query.partNumber ?? [])
175
- params.append("partNumber", pn);
176
- for (const facet of query.facets ?? [])
177
- params.append("facet", facet);
166
+ for (const id of query.id ?? []) params.append("id", id);
167
+ for (const pn of query.partNumber ?? []) params.append("partNumber", pn);
168
+ for (const facet of query.facets ?? []) params.append("facet", facet);
178
169
  return params;
179
170
  }
180
171
  categoriesUrl() {
@@ -184,16 +175,12 @@ class HclProductCapability extends ProductCapability {
184
175
  const params = new URLSearchParams();
185
176
  params.set("storeId", query.storeId ?? this.config.storeId);
186
177
  const catalogId = query.catalogId ?? this.config.catalogId;
187
- if (catalogId)
188
- params.set("catalogId", catalogId);
178
+ if (catalogId) params.set("catalogId", catalogId);
189
179
  if (query.parentCategoryId)
190
180
  params.set("parentCategoryId", query.parentCategoryId);
191
- if (query.depthAndLimit)
192
- params.set("depthAndLimit", query.depthAndLimit);
193
- if (query.profileName)
194
- params.set("profileName", query.profileName);
195
- for (const id of query.id ?? [])
196
- params.append("id", id);
181
+ if (query.depthAndLimit) params.set("depthAndLimit", query.depthAndLimit);
182
+ if (query.profileName) params.set("profileName", query.profileName);
183
+ for (const id of query.id ?? []) params.append("id", id);
197
184
  for (const identifier of query.identifier ?? [])
198
185
  params.append("identifier", identifier);
199
186
  return params;
@@ -5,8 +5,7 @@ var __decorateClass = (decorators, target, key, kind) => {
5
5
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
6
  if (decorator = decorators[i])
7
7
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
- if (kind && result)
9
- __defProp(target, key, result);
8
+ if (kind && result) __defProp(target, key, result);
10
9
  return result;
11
10
  };
12
11
  import {
@@ -5,8 +5,7 @@ var __decorateClass = (decorators, target, key, kind) => {
5
5
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
6
  if (decorator = decorators[i])
7
7
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
- if (kind && result)
9
- __defProp(target, key, result);
8
+ if (kind && result) __defProp(target, key, result);
10
9
  return result;
11
10
  };
12
11
  import {
package/core/client.js CHANGED
@@ -24,6 +24,8 @@ class HclClient {
24
24
  this.catalogBaseUrl = `${searchOrigin}/search/resources`;
25
25
  this.transactionBaseUrl = `${origin}/wcs/resources/store/${config.storeId}`;
26
26
  }
27
+ config;
28
+ context;
27
29
  /** Base URL for the Query Service (catalog / search). */
28
30
  catalogBaseUrl;
29
31
  /** Base URL for the Transaction Service (WCS REST). */
@@ -35,8 +37,7 @@ class HclClient {
35
37
  method: "GET",
36
38
  headers: this.buildHeaders()
37
39
  });
38
- if (opts?.allowUndefined && response.status === 404)
39
- return void 0;
40
+ if (opts?.allowUndefined && response.status === 404) return void 0;
40
41
  if (!response.ok) {
41
42
  throw new Error(
42
43
  `HCL GET ${url} error ${response.status} ${response.statusText}`
@@ -96,10 +97,8 @@ class HclClient {
96
97
  * @see requiresGuestSession
97
98
  */
98
99
  async ensureGuestSession(url) {
99
- if (!this.requiresGuestSession(url))
100
- return;
101
- if (this.context.session[SESSION_KEY_WC_TOKEN])
102
- return;
100
+ if (!this.requiresGuestSession(url)) return;
101
+ if (this.context.session[SESSION_KEY_WC_TOKEN]) return;
103
102
  const guestUrl = `${this.transactionBaseUrl}/guestidentity`;
104
103
  const response = await fetch(guestUrl, {
105
104
  method: "POST",
@@ -141,8 +140,7 @@ class HclClient {
141
140
  * Override in project-specific subclasses to adjust the whitelist.
142
141
  */
143
142
  requiresGuestSession(url) {
144
- if (!url.startsWith(this.transactionBaseUrl))
145
- return false;
143
+ if (!url.startsWith(this.transactionBaseUrl)) return false;
146
144
  const path = url.slice(this.transactionBaseUrl.length);
147
145
  return path.startsWith("/cart") || path.startsWith("/order") || path.startsWith("/person");
148
146
  }
@@ -153,10 +151,8 @@ class HclClient {
153
151
  buildParams(params) {
154
152
  const merged = new URLSearchParams(params);
155
153
  const { langId, currency } = getLocaleParams(this.config, this.context);
156
- if (langId && !merged.has("langId"))
157
- merged.set("langId", langId);
158
- if (currency && !merged.has("currency"))
159
- merged.set("currency", currency);
154
+ if (langId && !merged.has("langId")) merged.set("langId", langId);
155
+ if (currency && !merged.has("currency")) merged.set("currency", currency);
160
156
  return merged;
161
157
  }
162
158
  buildHeaders() {
@@ -164,12 +160,9 @@ class HclClient {
164
160
  const token = this.context.session[SESSION_KEY_WC_TOKEN];
165
161
  const trustedToken = this.context.session[SESSION_KEY_WC_TRUSTED_TOKEN];
166
162
  const personalizationId = this.context.session[SESSION_KEY_PERSONALIZATION_ID];
167
- if (token)
168
- headers["WCToken"] = token;
169
- if (trustedToken)
170
- headers["WCTrustedToken"] = trustedToken;
171
- if (personalizationId)
172
- headers["WCPersonalization"] = personalizationId;
163
+ if (token) headers["WCToken"] = token;
164
+ if (trustedToken) headers["WCTrustedToken"] = trustedToken;
165
+ if (personalizationId) headers["WCPersonalization"] = personalizationId;
173
166
  return headers;
174
167
  }
175
168
  }
@@ -8,6 +8,9 @@ class HclCartFactory {
8
8
  this.cartIdentifierSchema = cartIdentifierSchema;
9
9
  this.cartPaginatedSearchResultSchema = cartPaginatedSearchResultSchema;
10
10
  }
11
+ cartSchema;
12
+ cartIdentifierSchema;
13
+ cartPaginatedSearchResultSchema;
11
14
  parseCart(context, data) {
12
15
  const cart = data;
13
16
  const currency = cart.totalProductPriceCurrency ?? cart.grandTotalCurrency ?? "USD";
@@ -8,6 +8,9 @@ class HclCheckoutFactory {
8
8
  this.shippingMethodSchema = shippingMethodSchema;
9
9
  this.paymentMethodSchema = paymentMethodSchema;
10
10
  }
11
+ checkoutSchema;
12
+ shippingMethodSchema;
13
+ paymentMethodSchema;
11
14
  parseCheckout(context, data) {
12
15
  const cart = data;
13
16
  const currency = cart.totalProductPriceCurrency ?? cart.grandTotalCurrency ?? "USD";
@@ -37,8 +40,7 @@ class HclCheckoutFactory {
37
40
  status: "pending"
38
41
  }));
39
42
  const parseAddress = (addr) => {
40
- if (!addr)
41
- return void 0;
43
+ if (!addr) return void 0;
42
44
  return {
43
45
  identifier: { key: addr.addressId ?? "" },
44
46
  firstName: addr.firstName ?? "",
@@ -59,8 +59,7 @@ function parseOptions(skus) {
59
59
  optionMap.set(attr.identifier, { name: attr.name, values: /* @__PURE__ */ new Map() });
60
60
  }
61
61
  const option = optionMap.get(attr.identifier);
62
- if (!option)
63
- continue;
62
+ if (!option) continue;
64
63
  for (const fv of flattenAttributeValues(attr)) {
65
64
  option.values.set(fv.key, { key: fv.key, label: fv.label });
66
65
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reactionary/hcl",
3
- "version": "0.10.2",
3
+ "version": "0.10.4",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "types": "./src/index.d.ts",
@@ -9,12 +9,11 @@
9
9
  "url": "git+https://github.com/Solteq/reactionary.git"
10
10
  },
11
11
  "dependencies": {
12
- "@reactionary/core": "0.10.2",
12
+ "@reactionary/core": "0.10.4",
13
13
  "debug": "^4.4.3",
14
14
  "zod": "4.1.9"
15
15
  },
16
16
  "devDependencies": {
17
- "@nx/vite": "22.4.5",
18
17
  "vitest": "^4.0.9"
19
18
  },
20
19
  "sideEffects": false