oneentry 1.0.142 → 1.0.144

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 (150) hide show
  1. package/configure.js +2 -2
  2. package/dist/admins/adminsApi.d.ts +50 -0
  3. package/dist/admins/adminsApi.js +65 -0
  4. package/dist/admins/adminsInterfaces.d.ts +98 -0
  5. package/dist/admins/adminsInterfaces.js +2 -0
  6. package/dist/admins/adminsSchemas.d.ts +30 -0
  7. package/dist/admins/adminsSchemas.js +27 -0
  8. package/dist/attribute-sets/attributeSetsApi.d.ts +63 -0
  9. package/dist/attribute-sets/attributeSetsApi.js +98 -0
  10. package/dist/attribute-sets/attributeSetsInterfaces.d.ts +185 -0
  11. package/dist/attribute-sets/attributeSetsInterfaces.js +2 -0
  12. package/dist/attribute-sets/attributeSetsSchemas.d.ts +90 -0
  13. package/dist/attribute-sets/attributeSetsSchemas.js +74 -0
  14. package/dist/auth-provider/authProviderApi.d.ts +249 -0
  15. package/dist/auth-provider/authProviderApi.js +354 -0
  16. package/dist/auth-provider/authProviderSchemas.d.ts +131 -0
  17. package/dist/auth-provider/authProviderSchemas.js +82 -0
  18. package/dist/auth-provider/authProvidersInterfaces.d.ts +412 -0
  19. package/dist/auth-provider/authProvidersInterfaces.js +2 -0
  20. package/dist/base/asyncModules.d.ts +80 -0
  21. package/dist/base/asyncModules.js +448 -0
  22. package/dist/base/result.d.ts +39 -0
  23. package/dist/base/result.js +154 -0
  24. package/dist/base/stateModule.d.ts +41 -0
  25. package/dist/base/stateModule.js +128 -0
  26. package/dist/base/syncModules.d.ts +286 -0
  27. package/dist/base/syncModules.js +716 -0
  28. package/dist/base/utils.d.ts +197 -0
  29. package/dist/base/utils.js +2 -0
  30. package/dist/base/validation.d.ts +118 -0
  31. package/dist/base/validation.js +132 -0
  32. package/dist/blocks/blocksApi.d.ts +88 -0
  33. package/dist/blocks/blocksApi.js +207 -0
  34. package/dist/blocks/blocksInterfaces.d.ts +179 -0
  35. package/dist/blocks/blocksInterfaces.js +2 -0
  36. package/dist/blocks/blocksSchemas.d.ts +195 -0
  37. package/dist/blocks/blocksSchemas.js +43 -0
  38. package/dist/discounts/discountsApi.d.ts +76 -0
  39. package/dist/discounts/discountsApi.js +116 -0
  40. package/dist/discounts/discountsInterfaces.d.ts +217 -0
  41. package/dist/discounts/discountsInterfaces.js +2 -0
  42. package/dist/events/eventsApi.d.ts +60 -0
  43. package/dist/events/eventsApi.js +97 -0
  44. package/dist/events/eventsInterfaces.d.ts +87 -0
  45. package/dist/events/eventsInterfaces.js +2 -0
  46. package/dist/file-uploading/fileUploadingApi.d.ts +88 -0
  47. package/dist/file-uploading/fileUploadingApi.js +129 -0
  48. package/dist/file-uploading/fileUploadingInterfaces.d.ts +114 -0
  49. package/dist/file-uploading/fileUploadingInterfaces.js +2 -0
  50. package/dist/file-uploading/fileUploadingSchemas.d.ts +22 -0
  51. package/dist/file-uploading/fileUploadingSchemas.js +21 -0
  52. package/dist/forms/formsApi.d.ts +42 -0
  53. package/dist/forms/formsApi.js +57 -0
  54. package/dist/forms/formsInterfaces.d.ts +144 -0
  55. package/dist/forms/formsInterfaces.js +2 -0
  56. package/dist/forms/formsSchemas.d.ts +53 -0
  57. package/dist/forms/formsSchemas.js +34 -0
  58. package/dist/forms-data/formsDataApi.d.ts +106 -0
  59. package/dist/forms-data/formsDataApi.js +189 -0
  60. package/dist/forms-data/formsDataInterfaces.d.ts +522 -0
  61. package/dist/forms-data/formsDataInterfaces.js +2 -0
  62. package/dist/forms-data/formsDataSchemas.d.ts +115 -0
  63. package/dist/forms-data/formsDataSchemas.js +86 -0
  64. package/dist/general-types/generalTypesApi.d.ts +28 -0
  65. package/dist/general-types/generalTypesApi.js +38 -0
  66. package/dist/general-types/generalTypesInterfaces.d.ts +29 -0
  67. package/dist/general-types/generalTypesInterfaces.js +2 -0
  68. package/dist/general-types/generalTypesSchemas.d.ts +52 -0
  69. package/dist/general-types/generalTypesSchemas.js +36 -0
  70. package/dist/index.d.ts +124 -0
  71. package/dist/index.js +103 -0
  72. package/dist/integration-collections/integrationCollectionsApi.d.ts +163 -0
  73. package/dist/integration-collections/integrationCollectionsApi.js +220 -0
  74. package/dist/integration-collections/integrationCollectionsInterfaces.d.ts +313 -0
  75. package/dist/integration-collections/integrationCollectionsInterfaces.js +2 -0
  76. package/dist/integration-collections/integrationCollectionsSchemas.d.ts +80 -0
  77. package/dist/integration-collections/integrationCollectionsSchemas.js +61 -0
  78. package/dist/locales/localesApi.d.ts +27 -0
  79. package/dist/locales/localesApi.js +37 -0
  80. package/dist/locales/localesInterfaces.d.ts +40 -0
  81. package/dist/locales/localesInterfaces.js +2 -0
  82. package/dist/locales/localesSchemas.d.ts +32 -0
  83. package/dist/locales/localesSchemas.js +26 -0
  84. package/dist/menus/menusApi.d.ts +29 -0
  85. package/dist/menus/menusApi.js +39 -0
  86. package/dist/menus/menusInterfaces.d.ts +87 -0
  87. package/dist/menus/menusInterfaces.js +3 -0
  88. package/dist/menus/menusSchemas.d.ts +16 -0
  89. package/dist/menus/menusSchemas.js +28 -0
  90. package/dist/orders/ordersApi.d.ts +175 -0
  91. package/dist/orders/ordersApi.js +247 -0
  92. package/dist/orders/ordersInterfaces.d.ts +593 -0
  93. package/dist/orders/ordersInterfaces.js +2 -0
  94. package/dist/orders/ordersSchemas.d.ts +120 -0
  95. package/dist/orders/ordersSchemas.js +101 -0
  96. package/dist/pages/pagesApi.d.ts +151 -0
  97. package/dist/pages/pagesApi.js +390 -0
  98. package/dist/pages/pagesInterfaces.d.ts +286 -0
  99. package/dist/pages/pagesInterfaces.js +2 -0
  100. package/dist/pages/pagesSchemas.d.ts +85 -0
  101. package/dist/pages/pagesSchemas.js +46 -0
  102. package/dist/payments/paymentsApi.d.ts +82 -0
  103. package/dist/payments/paymentsApi.js +121 -0
  104. package/dist/payments/paymentsInterfaces.d.ts +200 -0
  105. package/dist/payments/paymentsInterfaces.js +2 -0
  106. package/dist/payments/paymentsSchemas.d.ts +100 -0
  107. package/dist/payments/paymentsSchemas.js +65 -0
  108. package/dist/product-statuses/productStatusesApi.d.ts +47 -0
  109. package/dist/product-statuses/productStatusesApi.js +70 -0
  110. package/dist/product-statuses/productStatusesInterfaces.d.ts +62 -0
  111. package/dist/product-statuses/productStatusesInterfaces.js +2 -0
  112. package/dist/product-statuses/productStatusesSchemas.d.ts +34 -0
  113. package/dist/product-statuses/productStatusesSchemas.js +30 -0
  114. package/dist/products/productsApi.d.ts +366 -0
  115. package/dist/products/productsApi.js +458 -0
  116. package/dist/products/productsInterfaces.d.ts +593 -0
  117. package/dist/products/productsInterfaces.js +2 -0
  118. package/dist/products/productsSchemas.d.ts +200 -0
  119. package/dist/products/productsSchemas.js +98 -0
  120. package/dist/sitemap/sitemapApi.d.ts +35 -0
  121. package/dist/sitemap/sitemapApi.js +45 -0
  122. package/dist/sitemap/sitemapInterfaces.d.ts +40 -0
  123. package/dist/sitemap/sitemapInterfaces.js +2 -0
  124. package/dist/system/systemApi.d.ts +43 -0
  125. package/dist/system/systemApi.js +56 -0
  126. package/dist/system/systemInterfaces.d.ts +29 -0
  127. package/dist/system/systemInterfaces.js +2 -0
  128. package/dist/templates/templatesApi.d.ts +49 -0
  129. package/dist/templates/templatesApi.js +75 -0
  130. package/dist/templates/templatesInterfaces.d.ts +67 -0
  131. package/dist/templates/templatesInterfaces.js +2 -0
  132. package/dist/templates/templatesSchemas.d.ts +48 -0
  133. package/dist/templates/templatesSchemas.js +31 -0
  134. package/dist/templates-preview/templatesPreviewApi.d.ts +38 -0
  135. package/dist/templates-preview/templatesPreviewApi.js +53 -0
  136. package/dist/templates-preview/templatesPreviewInterfaces.d.ts +119 -0
  137. package/dist/templates-preview/templatesPreviewInterfaces.js +2 -0
  138. package/dist/templates-preview/templatesPreviewSchemas.d.ts +83 -0
  139. package/dist/templates-preview/templatesPreviewSchemas.js +48 -0
  140. package/dist/users/usersApi.d.ts +143 -0
  141. package/dist/users/usersApi.js +171 -0
  142. package/dist/users/usersInterfaces.d.ts +231 -0
  143. package/dist/users/usersInterfaces.js +2 -0
  144. package/dist/users/usersSchemas.d.ts +38 -0
  145. package/dist/users/usersSchemas.js +28 -0
  146. package/dist/web-socket/wsApi.d.ts +25 -0
  147. package/dist/web-socket/wsApi.js +45 -0
  148. package/dist/web-socket/wsInterfaces.d.ts +16 -0
  149. package/dist/web-socket/wsInterfaces.js +2 -0
  150. package/package.json +2 -80
@@ -0,0 +1,458 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ /* eslint-disable jsdoc/reject-any-type */
7
+ const asyncModules_1 = __importDefault(require("../base/asyncModules"));
8
+ const productsSchemas_1 = require("./productsSchemas");
9
+ /**
10
+ * Controllers for working with product pages
11
+ * @handle /api/content/products
12
+ * @description Controllers for working with product pages
13
+ */
14
+ class ProductsApi extends asyncModules_1.default {
15
+ /**
16
+ * Constructor
17
+ * @param {StateModule} state - StateModule instance
18
+ * @description Constructor initializes the ProductsApi with a given state.
19
+ */
20
+ constructor(state) {
21
+ super(state);
22
+ this._url = state.url + '/api/content/products';
23
+ }
24
+ /**
25
+ * Search for all products with pagination and filter.
26
+ * @handleName getProducts
27
+ * @param {IFilterParams[]} [body] - Request body. Default: [].
28
+ * @example
29
+ [
30
+ {
31
+ "attributeMarker": "price",
32
+ "conditionMarker": "mth",
33
+ "statusMarker": "waiting",
34
+ "conditionValue": 1,
35
+ "pageUrls": [
36
+ "23-laminat-floorwood-maxima"
37
+ ],
38
+ "isNested": false,
39
+ "title": ""
40
+ },
41
+ {
42
+ "attributeMarker": "price",
43
+ "conditionMarker": "lth",
44
+ "conditionValue": 3,
45
+ "pageUrls": [
46
+ "23-laminat-floorwood-maxima"
47
+ ],
48
+ "isNested": false,
49
+ "title": ""
50
+ }
51
+ ]
52
+ * @param {string} [langCode] - Language code. Default: "en_US".
53
+ * @param {IProductsQuery} [userQuery] - Optional set query parameters.
54
+ * @example
55
+ {
56
+ "signPrice": "orders",
57
+ "sortOrder": "DESC",
58
+ "sortKey": "id",
59
+ "limit": 30,
60
+ "offset": 0,
61
+ "statusId": 123,
62
+ "statusMarker": "in_stock",
63
+ "conditionValue": "new",
64
+ "conditionMarker": "equals",
65
+ "attributeMarker": "color"
66
+ }
67
+ * @returns {Promise<IProductsResponse | IError>} Products response, or IError when isShell=true
68
+ * @throws {IError} When isShell=false and an error occurs during the fetch
69
+ * @description Fetch products with optional filters and pagination.
70
+ */
71
+ async getProducts(body = [], langCode = this.state.lang, userQuery) {
72
+ const query = {
73
+ ...userQuery,
74
+ langCode,
75
+ };
76
+ const result = await this._fetchPost(`/all?` + this._queryParamsToString(query), { filter: body });
77
+ // Validate response if validation is enabled
78
+ const validated = this._validateResponse(result, productsSchemas_1.ProductsResponseSchema);
79
+ return this._dataPostProcess(validated, langCode);
80
+ }
81
+ /**
82
+ * Search for all product page objects with pagination (and aggregation) that do not have a category.
83
+ * @handleName getProductsEmptyPage
84
+ * @param {object} [body] - Request body. Default: {}.
85
+ * @param {string} [langCode] - Language code. Default: "en_US".
86
+ * @param {IProductsQuery} [userQuery] - Optional set query parameters.
87
+ * @example
88
+ {
89
+ "limit": 30,
90
+ "offset": 0,
91
+ "sortOrder": "DESC",
92
+ "sortKey": "id",
93
+ "statusId": 123,
94
+ "statusMarker": "in_stock",
95
+ "conditionValue": "new",
96
+ "conditionMarker": "equals",
97
+ "attributeMarker": "color"
98
+ }
99
+ * @returns {Promise<IAggregatedProductGroup[] | IError>} Array with AggregatedProductGroup objects.
100
+ * @throws {IError} When isShell=false and an error occurs during the fetch
101
+ * @description Search for all product page objects with pagination (and aggregation) that do not have a category.
102
+ */
103
+ async getProductsEmptyPage(body = {}, langCode = this.state.lang, userQuery) {
104
+ const query = { ...userQuery, langCode };
105
+ const result = await this._fetchPost(`/empty-page?` + this._queryParamsToString(query), body);
106
+ return this._normalizeData(result);
107
+ }
108
+ /**
109
+ * Search for all products with pagination for the selected category.
110
+ * @handleName getProductsByPageId
111
+ * @param {number} id - Page id. Example: 2492.
112
+ * @param {IFilterParams[]} [body] - Request body. Default: [].
113
+ * @example
114
+ [
115
+ {
116
+ "attributeMarker": "price",
117
+ "conditionMarker": "mth",
118
+ "statusMarker": "waiting",
119
+ "conditionValue": 1,
120
+ "pageUrls": [
121
+ "23-laminat-floorwood-maxima"
122
+ ],
123
+ "isNested": false,
124
+ "title": ""
125
+ },
126
+ {
127
+ "attributeMarker": "price",
128
+ "conditionMarker": "lth",
129
+ "conditionValue": 3,
130
+ "pageUrls": [
131
+ "23-laminat-floorwood-maxima"
132
+ ],
133
+ "isNested": false,
134
+ "title": ""
135
+ }
136
+ ]
137
+ * @param {string} [langCode] - Language code. Default: "en_US".
138
+ * @param {IProductsQuery} [userQuery] - Optional set query parameters.
139
+ * @example
140
+ {
141
+ "limit": 30,
142
+ "offset": 0,
143
+ "sortOrder": "DESC",
144
+ "sortKey": "id",
145
+ "statusId": 123,
146
+ "statusMarker": "in_stock",
147
+ "conditionValue": "new",
148
+ "conditionMarker": "equals",
149
+ "attributeMarker": "color"
150
+ }
151
+ * @returns {Promise<IProductsResponse | IError>} Array with ProductEntity objects
152
+ * @throws {IError} When isShell=false and an error occurs during the fetch
153
+ * @description Fetch products by page ID with optional filters and pagination.
154
+ */
155
+ async getProductsByPageId(id, body = [], langCode = this.state.lang, userQuery) {
156
+ const query = { ...userQuery };
157
+ const result = await this._fetchPost(`/page/${id}?langCode=${langCode}&` + this._queryParamsToString(query), { filter: body });
158
+ // Validate response if validation is enabled
159
+ const validated = this._validateResponse(result, productsSchemas_1.ProductsResponseSchema);
160
+ return this._dataPostProcess(validated, langCode);
161
+ }
162
+ /**
163
+ * Search for information about products and prices for the selected category.
164
+ * @handleName getProductsPriceByPageUrl
165
+ * @param {string} [url] - Page url. Example: "23-laminat-floorwood-maxima".
166
+ * @param {string} [langCode] - Language code. Default: "en_US".
167
+ * @param {IProductsQuery} [userQuery] - Optional set query parameters.
168
+ * @example
169
+ {
170
+ "limit": 30,
171
+ "offset": 0,
172
+ "sortOrder": "DESC",
173
+ "sortKey": "id",
174
+ "statusId": 123,
175
+ "statusMarker": "in_stock",
176
+ "conditionValue": "new",
177
+ "conditionMarker": "equals",
178
+ "attributeMarker": "color"
179
+ }
180
+ * @returns {Promise<IProductsInfo | IError>} Array with ProductInformation objects.
181
+ * @throws {IError} When isShell=false and an error occurs during the fetch
182
+ * @description Search for information about products and prices for the selected category.
183
+ */
184
+ async getProductsPriceByPageUrl(url, langCode = this.state.lang, userQuery) {
185
+ const query = {
186
+ ...userQuery,
187
+ langCode,
188
+ };
189
+ const result = await this._fetchGet(`/page/${url}/prices?` + this._queryParamsToString(query));
190
+ return result;
191
+ }
192
+ /**
193
+ * Search for all products with pagination for the selected category.
194
+ * @handleName getProductsByPageUrl
195
+ * @param {string} url - Page url. Example: "catalog".
196
+ * @param {IFilterParams[]} [body] - Request body. Default: [].
197
+ * @example
198
+ [
199
+ {
200
+ "attributeMarker": "price",
201
+ "conditionMarker": "mth",
202
+ "statusMarker": "waiting",
203
+ "conditionValue": 1,
204
+ "pageUrls": [
205
+ "23-laminat-floorwood-maxima"
206
+ ],
207
+ "isNested": false,
208
+ "title": ""
209
+ },
210
+ {
211
+ "attributeMarker": "price",
212
+ "conditionMarker": "lth",
213
+ "conditionValue": 3,
214
+ "pageUrls": [
215
+ "23-laminat-floorwood-maxima"
216
+ ],
217
+ "isNested": false,
218
+ "title": ""
219
+ }
220
+ ]
221
+ * @param {string} [langCode] - Language code. Default: "en_US".
222
+ * @param {IProductsQuery} [userQuery] - Optional set query parameters.
223
+ * @example
224
+ {
225
+ "limit": 30,
226
+ "offset": 0,
227
+ "sortOrder": "DESC",
228
+ "sortKey": "id",
229
+ "statusId": 123,
230
+ "statusMarker": "in_stock",
231
+ "conditionValue": "new",
232
+ "conditionMarker": "equals",
233
+ "attributeMarker": "color"
234
+ }
235
+ * @returns {Promise<IProductsResponse | IError>} Array with ProductEntity objects.
236
+ * @throws {IError} When isShell=false and an error occurs during the fetch
237
+ * @description Search for all products with pagination for the selected category.
238
+ */
239
+ async getProductsByPageUrl(url, body = [], langCode = this.state.lang, userQuery) {
240
+ const query = { ...userQuery };
241
+ const result = await this._fetchPost(`/page/url/${url}?langCode=${langCode}&` +
242
+ this._queryParamsToString(query), { filter: body });
243
+ // Validate response if validation is enabled
244
+ const validated = this._validateResponse(result, productsSchemas_1.ProductsResponseSchema);
245
+ return this._dataPostProcess(validated, langCode);
246
+ }
247
+ /**
248
+ * Find all related product page objects.
249
+ * @handleName getRelatedProductsById
250
+ * @param {number} [id] - Product page identifier for which to find relationship. Example: 12345.
251
+ * @param {string} [langCode] - Language code. Default: "en_US".
252
+ * @param {IProductsQuery} [userQuery] - Optional set query parameters.
253
+ * @example
254
+ {
255
+ "limit": 30,
256
+ "offset": 0,
257
+ "sortOrder": "DESC",
258
+ "sortKey": "id",
259
+ "statusId": 123,
260
+ "statusMarker": "in_stock",
261
+ "conditionValue": "new",
262
+ "conditionMarker": "equals",
263
+ "attributeMarker": "color"
264
+ }
265
+ * @param {number} [userQuery.limit] - Optional parameter for pagination. Default: 30.
266
+ * @param {number} [userQuery.offset] - Optional parameter for pagination. Default: 0.
267
+ * @param {string} [userQuery.sortOrder] - Optional sorting order "DESC" | "ASC". Example: "DESC".
268
+ * @param {string} [userQuery.sortKey] - Optional field to sort by ("id", "title", "date", "price", "position", "status"). Example: "id".
269
+ * @returns {Promise<IProductsResponse | IError>} Array with ProductEntity objects
270
+ * @throws {IError} When isShell=false and an error occurs during the fetch
271
+ * @description Find all related product page objects.
272
+ */
273
+ async getRelatedProductsById(id, langCode = this.state.lang, userQuery) {
274
+ const query = { ...userQuery };
275
+ const result = await this._fetchGet(`/${id}/related?langCode=${langCode}&` + this._queryParamsToString(query));
276
+ // Validate response if validation is enabled
277
+ const validated = this._validateResponse(result, productsSchemas_1.ProductsResponseSchema);
278
+ return this._dataPostProcess(validated, langCode);
279
+ }
280
+ /**
281
+ * Find products by its ids.
282
+ * @handleName getProductsByIds
283
+ * @param {string} ids - Product page identifiers for which to find relationships. Example: "12345,67890".
284
+ * @param {string} [langCode] - Language code. Default "en_US".
285
+ * @param {IProductsQuery} [userQuery] - Optional set query parameters.
286
+ * @example
287
+ {
288
+ "limit": 30,
289
+ "offset": 0,
290
+ "sortOrder": "DESC",
291
+ "sortKey": "id",
292
+ "statusId": 123,
293
+ "statusMarker": "in_stock",
294
+ "conditionValue": "new",
295
+ "conditionMarker": "equals",
296
+ "attributeMarker": "color"
297
+ }
298
+ * @param {number} [userQuery.limit] - Optional parameter for pagination. Default: 30.
299
+ * @param {number} [userQuery.offset] - Optional parameter for pagination. Default: 0.
300
+ * @param {string} [userQuery.sortOrder] - Optional sorting order "DESC" | "ASC". Example: "DESC".
301
+ * @param {string} [userQuery.sortKey] - Optional field to sort by ("id", "title", "date", "price", "position", "status"). Example: "id".
302
+ * @param {number} [userQuery.statusId] - Optional parameter - search by status id. Example: 123.
303
+ * @param {string} [userQuery.statusMarker] - Optional identifier of the product page status. Example: "in_stock".
304
+ * @param {string} [userQuery.conditionValue] - Optional value that is being searched. Example: "new".
305
+ * @param {string} [userQuery.conditionMarker] - Optional identifier of the filter condition by which values are filtered. Example: "equals".
306
+ * @param {string} [userQuery.attributeMarker] - Optional text identifier of the indexed attribute by which values are filtered. Example: "color".
307
+ * @returns {Promise<IProductsEntity[] | IError>} Array with ProductEntity objects
308
+ * @throws {IError} When isShell=false and an error occurs during the fetch
309
+ * @description Find products by its ids.
310
+ */
311
+ async getProductsByIds(ids, langCode = this.state.lang, userQuery) {
312
+ const query = {
313
+ ids,
314
+ langCode,
315
+ ...userQuery,
316
+ };
317
+ const result = await this._fetchGet(`/ids?` + this._queryParamsToString(query));
318
+ return this._dataPostProcess(result, langCode);
319
+ }
320
+ /**
321
+ * Retrieve one product object.
322
+ * @handleName getProductById
323
+ * @param {number} id - Product id. Example: 12345.
324
+ * @param {string} [langCode] - Language code. Default: "en_US".
325
+ * @param {boolean} [isNormalized] - If true, the product object will be normalized.
326
+ * @returns {Promise<IProductsEntity | IError>} ProductEntity object.
327
+ * @throws {IError} When isShell=false and an error occurs during the fetch
328
+ * @description Retrieve one product object.
329
+ */
330
+ async getProductById(id, langCode = this.state.lang, isNormalized) {
331
+ const query = { langCode };
332
+ if (isNormalized !== undefined)
333
+ query.isNormalized = isNormalized;
334
+ const result = await this._fetchGet(`/${id}?` + this._queryParamsToString(query));
335
+ // Validate response if validation is enabled
336
+ const validated = this._validateResponse(result, productsSchemas_1.ProductEntitySchema);
337
+ return this._dataPostProcess(validated, langCode);
338
+ }
339
+ /**
340
+ * Getting a product block object by product id.
341
+ * @handleName getProductBlockById
342
+ * @param {number} id - Product id. Example: 12345.
343
+ * @returns {Promise<IProductBlock | IError>} - Product block object.
344
+ * @throws {IError} When isShell=false and an error occurs during the fetch
345
+ * @description Getting a product block object by product id.
346
+ */
347
+ async getProductBlockById(id) {
348
+ const response = await this._fetchGet(`/${id}/blocks`);
349
+ return this._normalizeData(response);
350
+ }
351
+ /**
352
+ * Quick search for product page objects with limited output.
353
+ * @handleName searchProduct
354
+ * @param {string} name - Text to search product page objects (search is based on the title field of the localizeInfos object with language consideration). Example: "laminat".
355
+ * @param {string} [langCode] - Language code. Default: "en_US".
356
+ * @returns {Promise<IProductsEntity[] | IError>} Array with ProductEntity objects
357
+ * @throws {IError} When isShell=false and an error occurs during the fetch
358
+ * @description Quick search for product page objects with limited output.
359
+ */
360
+ async searchProduct(name, langCode = this.state.lang) {
361
+ const searchProducts = await this._fetchGet(`/quick/search?langCode=${langCode}&name=${name}`);
362
+ if (!this.state.traficLimit) {
363
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
364
+ const productsList = [];
365
+ await Promise.all(searchProducts.map(async (product) => {
366
+ await this.getProductById(product.id, langCode).then((result) => {
367
+ productsList.push(result);
368
+ });
369
+ }));
370
+ return this._dataPostProcess(productsList, langCode);
371
+ }
372
+ return searchProducts;
373
+ }
374
+ /**
375
+ * Getting the number of products for the entire catalog.
376
+ * @handleName getProductsCount
377
+ * @param {any[]} body - Body parameters for filter. Deault: [].
378
+ * @example
379
+ [
380
+ {
381
+ "attributeMarker": "price",
382
+ "conditionMarker": "in",
383
+ "statusMarker": "status_1",
384
+ "conditionValue": {},
385
+ "pageUrls": [
386
+ "23-laminat-floorwood-maxima"
387
+ ],
388
+ "title": "Iphone 17 Pro"
389
+ }
390
+ ]
391
+ * @returns {Promise<IProductsCount | IError>} Object with product items count.
392
+ * @throws {IError} When isShell=false and an error occurs during the fetch
393
+ * @description This method calculates and returns the total number of products present across the entire catalog, optionally applying specified filters.
394
+ */
395
+ async getProductsCount(
396
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
397
+ body = []) {
398
+ const result = await this._fetchPost(`/all/counts`, body);
399
+ return result;
400
+ }
401
+ /**
402
+ * Getting the number of products on a catalog page by page ID.
403
+ * @handleName getProductsCountByPageId
404
+ * @param {string} id - Page ID.
405
+ * @param {any[]} body - Body parameters for filter. Deault: [].
406
+ * @example
407
+ [
408
+ {
409
+ "attributeMarker": "price",
410
+ "conditionMarker": "in",
411
+ "statusMarker": "status_1",
412
+ "conditionValue": {},
413
+ "pageUrls": [
414
+ "23-laminat-floorwood-maxima"
415
+ ],
416
+ "title": "Iphone 17 Pro"
417
+ }
418
+ ]
419
+ * @returns {Promise<IProductsCount | IError>} Object with product items count.
420
+ * @throws {IError} When isShell=false and an error occurs during the fetch
421
+ * @description This method calculates and returns the number of products available on a given catalog page, identified by its page ID, with optional filtering.
422
+ */
423
+ async getProductsCountByPageId(id,
424
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
425
+ body = []) {
426
+ const result = await this._fetchPost(`/page/${id}/counts`, body);
427
+ return result;
428
+ }
429
+ /**
430
+ * Getting the number of products for the catalog page by page url.
431
+ * @handleName getProductsCountByPageUrl
432
+ * @param {string} url - Page url.
433
+ * @param {any[]} body - Body parameters for filter. Deault: [].
434
+ * @example
435
+ [
436
+ {
437
+ "attributeMarker": "price",
438
+ "conditionMarker": "in",
439
+ "statusMarker": "status_1",
440
+ "conditionValue": {},
441
+ "pageUrls": [
442
+ "23-laminat-floorwood-maxima"
443
+ ],
444
+ "title": "Iphone 17 Pro"
445
+ }
446
+ ]
447
+ * @returns {Promise<IProductsCount | IError>} Object with product items count.
448
+ * @throws {IError} When isShell=false and an error occurs during the fetch
449
+ * @description This method calculates and returns the number of products available on a given catalog page, identified by its URL, with optional filtering.
450
+ */
451
+ async getProductsCountByPageUrl(url,
452
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
453
+ body = []) {
454
+ const result = await this._fetchPost(`/page/url/${url}/counts`, body);
455
+ return result;
456
+ }
457
+ }
458
+ exports.default = ProductsApi;