oneentry 1.0.153 → 1.0.155

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/dist/index.js CHANGED
@@ -42,6 +42,7 @@ const wsApi_1 = __importDefault(require("./web-socket/wsApi"));
42
42
  * @param {IConfig} config - Custom configuration settings
43
43
  * @param {string} [config.token] - Optional token parameter
44
44
  * @param {string} [config.guestId] - Optional guest identifier sent as the `x-guest-id` header for guest cart/wishlist/activity flows (only while unauthenticated). In the browser, if omitted, a stable per-device id is generated and persisted in localStorage. On the server you MUST pass a per-visitor `guestId` (or call `setGuestId`): the SDK never auto-generates a server id, to avoid sharing one guest across visitors.
45
+ * @param {string} [config.deviceMetadata] - Optional device-metadata string sent as the `x-device-metadata` header instead of the environment-derived fingerprint. Refresh tokens are bound to this header, so a server issuing tokens for a browser (OAuth code exchange) must pass the browser's string (from `getDeviceMetadata()`), or the token will not be refreshable from that browser.
45
46
  * @param {string} [config.langCode] - Optional langCode parameter
46
47
  * @param {boolean} [config.traficLimit] - Some methods use multiple queries to make it easier to work with the API. Set this parameter to "false" to save traffic and decide for yourself what data you need.
47
48
  * @param {string} [config.auth] - An object with authorization settings.
@@ -53,6 +54,18 @@ const wsApi_1 = __importDefault(require("./web-socket/wsApi"));
53
54
  * @description Define API.
54
55
  */
55
56
  function defineOneEntry(url, config) {
57
+ if (typeof url !== 'string' || url.trim() === '') {
58
+ throw new Error('OneEntry SDK: project URL is required to initialize the SDK. ' +
59
+ 'Pass a non-empty URL as the first argument of defineOneEntry, e.g. ' +
60
+ 'defineOneEntry("https://your-project.oneentry.cloud", { token: "your-app-token" }).');
61
+ }
62
+ if (!config ||
63
+ typeof config.token !== 'string' ||
64
+ config.token.trim() === '') {
65
+ throw new Error('OneEntry SDK: app token is required to initialize the SDK. ' +
66
+ 'Pass it via config, e.g. ' +
67
+ 'defineOneEntry("https://your-project.oneentry.cloud", { token: "your-app-token" }).');
68
+ }
56
69
  const stateModule = new stateModule_1.default(url.endsWith('/') ? url.slice(0, -1) : url, config);
57
70
  const Admins = new adminsApi_1.default(stateModule);
58
71
  const AttributesSets = new attributeSetsApi_1.default(stateModule);
@@ -267,6 +267,7 @@ interface IOrdersFormData {
267
267
  * @property {number} productId - Product identifier. Example: 1.
268
268
  * @property {number} quantity - Quantity of the product. Example: 2.
269
269
  * @property {string} [signedPrice] - The signed price of the product is obtained along with the product data when `signPrice` is set. Example: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...".
270
+ * @see {@link https://js-sdk.oneentry.cloud/docs/orders/#Fixed-product-price-signedPrice Fixed product price} documentation.
270
271
  * @description Represents a product data in an order.
271
272
  */
272
273
  interface IOrderProductData {
@@ -208,7 +208,8 @@ class PagesApi extends asyncModules_1.default {
208
208
  */
209
209
  async searchPage(name, url, langCode = this.state.lang) {
210
210
  // Fetch data from the server using a GET request to perform a quick search by page name and language code
211
- const data = await this._fetchGet(`/quick/search?${url && 'url=' + url}&lang=${langCode}&name=${name}`);
211
+ const urlPart = url ? `url=${encodeURIComponent(url)}&` : '';
212
+ const data = await this._fetchGet(`/quick/search?${urlPart}lang=${encodeURIComponent(langCode)}&name=${encodeURIComponent(name)}`);
212
213
  // /quick/search?url=catalog&langCode=en_US&name=cat
213
214
  // Check if there is no traffic limit set in the state
214
215
  if (!this.state.traficLimit && Array.isArray(data)) {
@@ -276,6 +277,12 @@ class PagesApi extends asyncModules_1.default {
276
277
  * For example, if 100 pages use 3 different templates, this method makes 3 requests instead of 100.
277
278
  */
278
279
  async addTemplateToPages(data) {
280
+ // On API error responses (e.g. 403 without list permission, 422) the value
281
+ // is an IError, not an array — return it as-is instead of calling array
282
+ // methods (.filter/.map) on it and throwing a TypeError.
283
+ if (!Array.isArray(data)) {
284
+ return data;
285
+ }
279
286
  // Step 1: Collect unique templateIdentifiers from all pages
280
287
  const uniqueIdentifiers = [
281
288
  ...new Set(data
@@ -380,6 +387,11 @@ class StaffModule extends asyncModules_1.default {
380
387
  async getProductsByBlockMarker(marker, langCode = this.state.lang, offset = 0, limit = 30) {
381
388
  // Fetch products from the server
382
389
  const result = await this._fetchGet(`/${marker}/products?langCode=${langCode}&offset=${offset}&limit=${limit}`);
390
+ // On API error responses there is no `items` array — return the (normalized)
391
+ // error as-is instead of producing `undefined` from `result.items`.
392
+ if (!Array.isArray(result === null || result === void 0 ? void 0 : result.items)) {
393
+ return this._normalizeData(result);
394
+ }
383
395
  return this._normalizeData(result.items);
384
396
  }
385
397
  }
@@ -1,7 +1,7 @@
1
1
  import AsyncModules from '../base/asyncModules';
2
2
  import type StateModule from '../base/stateModule';
3
3
  import type { IError } from '../base/utils';
4
- import type { IAggregatedProductGroup, IFilterParams, IProductBlock, IProductsApi, IProductsCount, IProductsEntity, IProductsInfo, IProductsQuery, IProductsResponse, IVectorSearchProducts } from './productsInterfaces';
4
+ import type { IAggregatedProductGroup, IFilterParams, IProductBlock, IProductsApi, IProductsByIdsQuery, IProductsCount, IProductsEntity, IProductsInfo, IProductsPriceQuery, IProductsQueryBase, IProductsRelatedQuery, IProductsResponse, IVectorSearchProducts } from './productsInterfaces';
5
5
  /**
6
6
  * Controllers for working with product pages
7
7
  * @handle /api/content/products
@@ -45,53 +45,44 @@ export default class ProductsApi extends AsyncModules implements IProductsApi {
45
45
  }
46
46
  ]
47
47
  * @param {string} [langCode] - Language code. Default: "en_US".
48
- * @param {IProductsQuery} [userQuery] - Optional set query parameters.
48
+ * @param {IProductsQueryBase} [userQuery] - Optional set query parameters.
49
49
  * @example
50
50
  {
51
51
  "limit": 30,
52
52
  "offset": 0,
53
53
  "sortOrder": "DESC",
54
54
  "sortKey": "id",
55
- "signPrice": "orders",
56
- "templateMarker": "template_12345",
57
- "statusMarker": "in_stock",
58
- "conditionValue": "new",
59
- "conditionMarker": "eq",
60
- "attributeMarker": "color"
55
+ "signPrice": "orders"
61
56
  }
62
- * @param {string} [userQuery.signPrice] - Order storage marker for price fixing.
57
+ * @param {string} [userQuery.signPrice] - Order storage marker for price fixing. If the parameter is set, the price is fixed for a certain time. Example: "orders_storage".
58
+ * @see {@link https://js-sdk.oneentry.cloud/docs/products/#Fixing-the-price-signPrice Fixing the price} documentation.
63
59
  * @param {string} [userQuery.sortOrder] - Sorting order parameter.
64
60
  * @returns {Promise<IProductsResponse | IError>} Products response, or IError when isShell=true
65
61
  * @throws {IError} When isShell=false and an error occurs during the fetch
66
62
  * @description Fetch products with optional filters and pagination.
67
63
  * @see {@link https://js-sdk.oneentry.cloud/docs/products/getProducts getProducts} documentation.
68
64
  */
69
- getProducts(body?: IFilterParams[], langCode?: string, userQuery?: IProductsQuery): Promise<IProductsResponse | IError>;
65
+ getProducts(body?: IFilterParams[], langCode?: string, userQuery?: IProductsQueryBase): Promise<IProductsResponse | IError>;
70
66
  /**
71
67
  * Search for all product page objects with pagination (and aggregation) that do not have a category.
72
68
  * @handleName getProductsEmptyPage
73
69
  * @param {object} [body] - Request body. Default: {}.
74
70
  * @param {string} [langCode] - Language code. Default: "en_US".
75
- * @param {IProductsQuery} [userQuery] - Optional set query parameters.
71
+ * @param {IProductsQueryBase} [userQuery] - Optional set query parameters.
76
72
  * @example
77
73
  {
78
74
  "limit": 30,
79
75
  "offset": 0,
80
76
  "sortOrder": "DESC",
81
77
  "sortKey": "id",
82
- "signPrice": "orders",
83
- "templateMarker": "template_12345",
84
- "statusMarker": "in_stock",
85
- "conditionValue": "new",
86
- "conditionMarker": "eq",
87
- "attributeMarker": "color"
78
+ "signPrice": "orders"
88
79
  }
89
80
  * @returns {Promise<IAggregatedProductGroup[] | IError>} Array with AggregatedProductGroup objects.
90
81
  * @throws {IError} When isShell=false and an error occurs during the fetch
91
82
  * @description Search for all product page objects with pagination (and aggregation) that do not have a category.
92
83
  * @see {@link https://js-sdk.oneentry.cloud/docs/products/getProductsEmptyPage getProductsEmptyPage} documentation.
93
84
  */
94
- getProductsEmptyPage(body?: object, langCode?: string, userQuery?: IProductsQuery): Promise<IAggregatedProductGroup[] | IError>;
85
+ getProductsEmptyPage(body?: object, langCode?: string, userQuery?: IProductsQueryBase): Promise<IAggregatedProductGroup[] | IError>;
95
86
  /**
96
87
  * Search for all products with pagination for the selected category.
97
88
  * @handleName getProductsByPageId
@@ -122,51 +113,41 @@ export default class ProductsApi extends AsyncModules implements IProductsApi {
122
113
  }
123
114
  ]
124
115
  * @param {string} [langCode] - Language code. Default: "en_US".
125
- * @param {IProductsQuery} [userQuery] - Optional set query parameters.
116
+ * @param {IProductsQueryBase} [userQuery] - Optional set query parameters.
126
117
  * @example
127
118
  {
128
119
  "limit": 30,
129
120
  "offset": 0,
130
121
  "sortOrder": "DESC",
131
122
  "sortKey": "id",
132
- "signPrice": "orders",
133
- "templateMarker": "template_12345",
134
- "statusMarker": "in_stock",
135
- "conditionValue": "new",
136
- "conditionMarker": "eq",
137
- "attributeMarker": "color"
123
+ "signPrice": "orders"
138
124
  }
139
125
  * @returns {Promise<IProductsResponse | IError>} Array with ProductEntity objects
140
126
  * @throws {IError} When isShell=false and an error occurs during the fetch
141
127
  * @description Fetch products by page ID with optional filters and pagination.
142
128
  * @see {@link https://js-sdk.oneentry.cloud/docs/products/getProductsByPageId getProductsByPageId} documentation.
143
129
  */
144
- getProductsByPageId(id: number, body?: IFilterParams[], langCode?: string, userQuery?: IProductsQuery): Promise<IProductsResponse | IError>;
130
+ getProductsByPageId(id: number, body?: IFilterParams[], langCode?: string, userQuery?: IProductsQueryBase): Promise<IProductsResponse | IError>;
145
131
  /**
146
132
  * Search for information about products and prices for the selected category.
147
133
  * @handleName getProductsPriceByPageUrl
148
134
  * @param {string} [url] - Page url. Example: "23-laminat-floorwood-maxima".
149
135
  * @param {string} [langCode] - Language code. Default: "en_US".
150
- * @param {IProductsQuery} [userQuery] - Optional set query parameters.
136
+ * @param {IProductsPriceQuery} [userQuery] - Optional set query parameters.
151
137
  * @example
152
138
  {
153
139
  "limit": 30,
154
140
  "offset": 0,
155
141
  "sortOrder": "DESC",
156
- "sortKey": "id",
157
142
  "signPrice": "orders",
158
- "templateMarker": "template_12345",
159
- "statusMarker": "in_stock",
160
- "conditionValue": "new",
161
- "conditionMarker": "eq",
162
- "attributeMarker": "color"
143
+ "statusMarker": "in_stock"
163
144
  }
164
145
  * @returns {Promise<IProductsInfo | IError>} Array with ProductInformation objects.
165
146
  * @throws {IError} When isShell=false and an error occurs during the fetch
166
147
  * @description Search for information about products and prices for the selected category.
167
148
  * @see {@link https://js-sdk.oneentry.cloud/docs/products/getProductsPriceByPageUrl getProductsPriceByPageUrl} documentation.
168
149
  */
169
- getProductsPriceByPageUrl(url: string, langCode?: string, userQuery?: IProductsQuery): Promise<IProductsInfo | IError>;
150
+ getProductsPriceByPageUrl(url: string, langCode?: string, userQuery?: IProductsPriceQuery): Promise<IProductsInfo | IError>;
170
151
  /**
171
152
  * Search for all products with pagination for the selected category.
172
153
  * @handleName getProductsByPageUrl
@@ -197,32 +178,27 @@ export default class ProductsApi extends AsyncModules implements IProductsApi {
197
178
  }
198
179
  ]
199
180
  * @param {string} [langCode] - Language code. Default: "en_US".
200
- * @param {IProductsQuery} [userQuery] - Optional set query parameters.
181
+ * @param {IProductsQueryBase} [userQuery] - Optional set query parameters.
201
182
  * @example
202
183
  {
203
184
  "limit": 30,
204
185
  "offset": 0,
205
186
  "sortOrder": "DESC",
206
187
  "sortKey": "id",
207
- "signPrice": "orders",
208
- "templateMarker": "template_12345",
209
- "statusMarker": "in_stock",
210
- "conditionValue": "new",
211
- "conditionMarker": "eq",
212
- "attributeMarker": "color"
188
+ "signPrice": "orders"
213
189
  }
214
190
  * @returns {Promise<IProductsResponse | IError>} Array with ProductEntity objects.
215
191
  * @throws {IError} When isShell=false and an error occurs during the fetch
216
192
  * @description Search for all products with pagination for the selected category.
217
193
  * @see {@link https://js-sdk.oneentry.cloud/docs/products/getProductsByPageUrl getProductsByPageUrl} documentation.
218
194
  */
219
- getProductsByPageUrl(url: string, body?: IFilterParams[], langCode?: string, userQuery?: IProductsQuery): Promise<IProductsResponse | IError>;
195
+ getProductsByPageUrl(url: string, body?: IFilterParams[], langCode?: string, userQuery?: IProductsQueryBase): Promise<IProductsResponse | IError>;
220
196
  /**
221
197
  * Find all related product page objects.
222
198
  * @handleName getRelatedProductsById
223
199
  * @param {number} [id] - Product page identifier for which to find relationship. Example: 12345.
224
200
  * @param {string} [langCode] - Language code. Default: "en_US".
225
- * @param {IProductsQuery} [userQuery] - Optional set query parameters.
201
+ * @param {IProductsRelatedQuery} [userQuery] - Optional set query parameters.
226
202
  * @example
227
203
  {
228
204
  "limit": 30,
@@ -230,11 +206,8 @@ export default class ProductsApi extends AsyncModules implements IProductsApi {
230
206
  "sortOrder": "DESC",
231
207
  "sortKey": "id",
232
208
  "signPrice": "orders",
233
- "templateMarker": "template_12345",
234
209
  "statusMarker": "in_stock",
235
- "conditionValue": "new",
236
- "conditionMarker": "eq",
237
- "attributeMarker": "color"
210
+ "templateMarker": "template_12345"
238
211
  }
239
212
  * @param {number} [userQuery.limit] - Optional parameter for pagination. Default: 30.
240
213
  * @param {number} [userQuery.offset] - Optional parameter for pagination. Default: 0.
@@ -245,40 +218,28 @@ export default class ProductsApi extends AsyncModules implements IProductsApi {
245
218
  * @description Find all related product page objects.
246
219
  * @see {@link https://js-sdk.oneentry.cloud/docs/products/getRelatedProductsById getRelatedProductsById} documentation.
247
220
  */
248
- getRelatedProductsById(id: number, langCode?: string, userQuery?: IProductsQuery): Promise<IProductsResponse | IError>;
221
+ getRelatedProductsById(id: number, langCode?: string, userQuery?: IProductsRelatedQuery): Promise<IProductsResponse | IError>;
249
222
  /**
250
223
  * Find products by its ids.
251
224
  * @handleName getProductsByIds
252
225
  * @param {string} ids - Product page identifiers for which to find relationships. Example: "12345,67890".
253
226
  * @param {string} [langCode] - Language code. Default "en_US".
254
- * @param {IProductsQuery} [userQuery] - Optional set query parameters.
227
+ * @param {IProductsByIdsQuery} [userQuery] - Optional set query parameters.
255
228
  * @example
256
229
  {
257
230
  "limit": 30,
258
231
  "offset": 0,
259
- "sortOrder": "DESC",
260
- "sortKey": "id",
261
- "signPrice": "orders",
262
- "templateMarker": "template_12345",
263
- "statusMarker": "in_stock",
264
- "conditionValue": "new",
265
- "conditionMarker": "eq",
266
- "attributeMarker": "color"
232
+ "signPrice": "orders"
267
233
  }
268
234
  * @param {number} [userQuery.limit] - Optional parameter for pagination. Default: 30.
269
235
  * @param {number} [userQuery.offset] - Optional parameter for pagination. Default: 0.
270
- * @param {string} [userQuery.sortOrder] - Optional sorting order "DESC" | "ASC". Example: "DESC".
271
- * @param {string} [userQuery.sortKey] - Optional field to sort by ("id", "title", "date", "price", "position", "status"). Example: "id".
272
- * @param {string} [userQuery.statusMarker] - Optional identifier of the product page status. Example: "in_stock".
273
- * @param {string} [userQuery.conditionValue] - Optional value that is being searched. Example: "new".
274
- * @param {string} [userQuery.conditionMarker] - Optional identifier of the filter condition by which values are filtered. Example: "eq".
275
- * @param {string} [userQuery.attributeMarker] - Optional text identifier of the indexed attribute by which values are filtered. Example: "color".
236
+ * @param {string} [userQuery.signPrice] - Order storage marker for price fixing.
276
237
  * @returns {Promise<IProductsEntity[] | IError>} Array with ProductEntity objects
277
238
  * @throws {IError} When isShell=false and an error occurs during the fetch
278
239
  * @description Find products by its ids.
279
240
  * @see {@link https://js-sdk.oneentry.cloud/docs/products/getProductsByIds getProductsByIds} documentation.
280
241
  */
281
- getProductsByIds(ids: string, langCode?: string, userQuery?: IProductsQuery): Promise<IProductsEntity[] | IError>;
242
+ getProductsByIds(ids: string, langCode?: string, userQuery?: IProductsByIdsQuery): Promise<IProductsEntity[] | IError>;
282
243
  /**
283
244
  * Retrieve one product object.
284
245
  * @handleName getProductById
@@ -50,21 +50,17 @@ class ProductsApi extends asyncModules_1.default {
50
50
  }
51
51
  ]
52
52
  * @param {string} [langCode] - Language code. Default: "en_US".
53
- * @param {IProductsQuery} [userQuery] - Optional set query parameters.
53
+ * @param {IProductsQueryBase} [userQuery] - Optional set query parameters.
54
54
  * @example
55
55
  {
56
56
  "limit": 30,
57
57
  "offset": 0,
58
58
  "sortOrder": "DESC",
59
59
  "sortKey": "id",
60
- "signPrice": "orders",
61
- "templateMarker": "template_12345",
62
- "statusMarker": "in_stock",
63
- "conditionValue": "new",
64
- "conditionMarker": "eq",
65
- "attributeMarker": "color"
60
+ "signPrice": "orders"
66
61
  }
67
- * @param {string} [userQuery.signPrice] - Order storage marker for price fixing.
62
+ * @param {string} [userQuery.signPrice] - Order storage marker for price fixing. If the parameter is set, the price is fixed for a certain time. Example: "orders_storage".
63
+ * @see {@link https://js-sdk.oneentry.cloud/docs/products/#Fixing-the-price-signPrice Fixing the price} documentation.
68
64
  * @param {string} [userQuery.sortOrder] - Sorting order parameter.
69
65
  * @returns {Promise<IProductsResponse | IError>} Products response, or IError when isShell=true
70
66
  * @throws {IError} When isShell=false and an error occurs during the fetch
@@ -86,19 +82,14 @@ class ProductsApi extends asyncModules_1.default {
86
82
  * @handleName getProductsEmptyPage
87
83
  * @param {object} [body] - Request body. Default: {}.
88
84
  * @param {string} [langCode] - Language code. Default: "en_US".
89
- * @param {IProductsQuery} [userQuery] - Optional set query parameters.
85
+ * @param {IProductsQueryBase} [userQuery] - Optional set query parameters.
90
86
  * @example
91
87
  {
92
88
  "limit": 30,
93
89
  "offset": 0,
94
90
  "sortOrder": "DESC",
95
91
  "sortKey": "id",
96
- "signPrice": "orders",
97
- "templateMarker": "template_12345",
98
- "statusMarker": "in_stock",
99
- "conditionValue": "new",
100
- "conditionMarker": "eq",
101
- "attributeMarker": "color"
92
+ "signPrice": "orders"
102
93
  }
103
94
  * @returns {Promise<IAggregatedProductGroup[] | IError>} Array with AggregatedProductGroup objects.
104
95
  * @throws {IError} When isShell=false and an error occurs during the fetch
@@ -140,19 +131,14 @@ class ProductsApi extends asyncModules_1.default {
140
131
  }
141
132
  ]
142
133
  * @param {string} [langCode] - Language code. Default: "en_US".
143
- * @param {IProductsQuery} [userQuery] - Optional set query parameters.
134
+ * @param {IProductsQueryBase} [userQuery] - Optional set query parameters.
144
135
  * @example
145
136
  {
146
137
  "limit": 30,
147
138
  "offset": 0,
148
139
  "sortOrder": "DESC",
149
140
  "sortKey": "id",
150
- "signPrice": "orders",
151
- "templateMarker": "template_12345",
152
- "statusMarker": "in_stock",
153
- "conditionValue": "new",
154
- "conditionMarker": "eq",
155
- "attributeMarker": "color"
141
+ "signPrice": "orders"
156
142
  }
157
143
  * @returns {Promise<IProductsResponse | IError>} Array with ProductEntity objects
158
144
  * @throws {IError} When isShell=false and an error occurs during the fetch
@@ -171,19 +157,14 @@ class ProductsApi extends asyncModules_1.default {
171
157
  * @handleName getProductsPriceByPageUrl
172
158
  * @param {string} [url] - Page url. Example: "23-laminat-floorwood-maxima".
173
159
  * @param {string} [langCode] - Language code. Default: "en_US".
174
- * @param {IProductsQuery} [userQuery] - Optional set query parameters.
160
+ * @param {IProductsPriceQuery} [userQuery] - Optional set query parameters.
175
161
  * @example
176
162
  {
177
163
  "limit": 30,
178
164
  "offset": 0,
179
165
  "sortOrder": "DESC",
180
- "sortKey": "id",
181
166
  "signPrice": "orders",
182
- "templateMarker": "template_12345",
183
- "statusMarker": "in_stock",
184
- "conditionValue": "new",
185
- "conditionMarker": "eq",
186
- "attributeMarker": "color"
167
+ "statusMarker": "in_stock"
187
168
  }
188
169
  * @returns {Promise<IProductsInfo | IError>} Array with ProductInformation objects.
189
170
  * @throws {IError} When isShell=false and an error occurs during the fetch
@@ -228,19 +209,14 @@ class ProductsApi extends asyncModules_1.default {
228
209
  }
229
210
  ]
230
211
  * @param {string} [langCode] - Language code. Default: "en_US".
231
- * @param {IProductsQuery} [userQuery] - Optional set query parameters.
212
+ * @param {IProductsQueryBase} [userQuery] - Optional set query parameters.
232
213
  * @example
233
214
  {
234
215
  "limit": 30,
235
216
  "offset": 0,
236
217
  "sortOrder": "DESC",
237
218
  "sortKey": "id",
238
- "signPrice": "orders",
239
- "templateMarker": "template_12345",
240
- "statusMarker": "in_stock",
241
- "conditionValue": "new",
242
- "conditionMarker": "eq",
243
- "attributeMarker": "color"
219
+ "signPrice": "orders"
244
220
  }
245
221
  * @returns {Promise<IProductsResponse | IError>} Array with ProductEntity objects.
246
222
  * @throws {IError} When isShell=false and an error occurs during the fetch
@@ -260,7 +236,7 @@ class ProductsApi extends asyncModules_1.default {
260
236
  * @handleName getRelatedProductsById
261
237
  * @param {number} [id] - Product page identifier for which to find relationship. Example: 12345.
262
238
  * @param {string} [langCode] - Language code. Default: "en_US".
263
- * @param {IProductsQuery} [userQuery] - Optional set query parameters.
239
+ * @param {IProductsRelatedQuery} [userQuery] - Optional set query parameters.
264
240
  * @example
265
241
  {
266
242
  "limit": 30,
@@ -268,11 +244,8 @@ class ProductsApi extends asyncModules_1.default {
268
244
  "sortOrder": "DESC",
269
245
  "sortKey": "id",
270
246
  "signPrice": "orders",
271
- "templateMarker": "template_12345",
272
247
  "statusMarker": "in_stock",
273
- "conditionValue": "new",
274
- "conditionMarker": "eq",
275
- "attributeMarker": "color"
248
+ "templateMarker": "template_12345"
276
249
  }
277
250
  * @param {number} [userQuery.limit] - Optional parameter for pagination. Default: 30.
278
251
  * @param {number} [userQuery.offset] - Optional parameter for pagination. Default: 0.
@@ -295,28 +268,16 @@ class ProductsApi extends asyncModules_1.default {
295
268
  * @handleName getProductsByIds
296
269
  * @param {string} ids - Product page identifiers for which to find relationships. Example: "12345,67890".
297
270
  * @param {string} [langCode] - Language code. Default "en_US".
298
- * @param {IProductsQuery} [userQuery] - Optional set query parameters.
271
+ * @param {IProductsByIdsQuery} [userQuery] - Optional set query parameters.
299
272
  * @example
300
273
  {
301
274
  "limit": 30,
302
275
  "offset": 0,
303
- "sortOrder": "DESC",
304
- "sortKey": "id",
305
- "signPrice": "orders",
306
- "templateMarker": "template_12345",
307
- "statusMarker": "in_stock",
308
- "conditionValue": "new",
309
- "conditionMarker": "eq",
310
- "attributeMarker": "color"
276
+ "signPrice": "orders"
311
277
  }
312
278
  * @param {number} [userQuery.limit] - Optional parameter for pagination. Default: 30.
313
279
  * @param {number} [userQuery.offset] - Optional parameter for pagination. Default: 0.
314
- * @param {string} [userQuery.sortOrder] - Optional sorting order "DESC" | "ASC". Example: "DESC".
315
- * @param {string} [userQuery.sortKey] - Optional field to sort by ("id", "title", "date", "price", "position", "status"). Example: "id".
316
- * @param {string} [userQuery.statusMarker] - Optional identifier of the product page status. Example: "in_stock".
317
- * @param {string} [userQuery.conditionValue] - Optional value that is being searched. Example: "new".
318
- * @param {string} [userQuery.conditionMarker] - Optional identifier of the filter condition by which values are filtered. Example: "eq".
319
- * @param {string} [userQuery.attributeMarker] - Optional text identifier of the indexed attribute by which values are filtered. Example: "color".
280
+ * @param {string} [userQuery.signPrice] - Order storage marker for price fixing.
320
281
  * @returns {Promise<IProductsEntity[] | IError>} Array with ProductEntity objects
321
282
  * @throws {IError} When isShell=false and an error occurs during the fetch
322
283
  * @description Find products by its ids.
@@ -375,16 +336,13 @@ class ProductsApi extends asyncModules_1.default {
375
336
  * @see {@link https://js-sdk.oneentry.cloud/docs/products/searchProduct searchProduct} documentation.
376
337
  */
377
338
  async searchProduct(name, langCode = this.state.lang) {
378
- const searchProducts = await this._fetchGet(`/quick/search?langCode=${langCode}&name=${name}`);
339
+ const searchProducts = await this._fetchGet(`/quick/search?langCode=${encodeURIComponent(langCode)}&name=${encodeURIComponent(name)}`);
379
340
  if (!this.state.traficLimit && Array.isArray(searchProducts)) {
380
341
  if (searchProducts.length === 0)
381
342
  return searchProducts;
382
343
  const ids = searchProducts.map((product) => product.id);
383
344
  // One /ids request instead of one getProductById per result.
384
- // limit is set to the number of ids so the default 30 does not truncate.
385
- const products = await this.getProductsByIds(ids.join(','), langCode, {
386
- limit: ids.length,
387
- });
345
+ const products = await this.getProductsByIds(ids.join(','), langCode);
388
346
  if (!Array.isArray(products))
389
347
  return products;
390
348
  // /ids re-sorts by id (DESC) by default, so restore the original