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