oneentry 1.0.175 → 1.0.177
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 +12 -5
- package/changelog.md +140 -0
- package/dist/admins/adminsApi.js +2 -9
- package/dist/admins/adminsInterfaces.d.ts +5 -5
- package/dist/admins/adminsSchemas.d.ts +4 -4
- package/dist/admins/adminsSchemas.js +2 -2
- package/dist/attribute-sets/attributeSetsApi.d.ts +1 -1
- package/dist/attribute-sets/attributeSetsApi.js +4 -4
- package/dist/attribute-sets/attributeSetsInterfaces.d.ts +65 -14
- package/dist/attribute-sets/attributeSetsSchemas.d.ts +8 -6
- package/dist/attribute-sets/attributeSetsSchemas.js +6 -9
- package/dist/auth-provider/authProviderApi.d.ts +4 -4
- package/dist/auth-provider/authProviderApi.js +96 -29
- package/dist/auth-provider/authProviderSchemas.d.ts +1 -0
- package/dist/auth-provider/authProviderSchemas.js +1 -0
- package/dist/auth-provider/authProvidersInterfaces.d.ts +8 -6
- package/dist/base/asyncModules.d.ts +73 -1
- package/dist/base/asyncModules.js +233 -37
- package/dist/base/stateModule.d.ts +2 -0
- package/dist/base/stateModule.js +22 -12
- package/dist/base/syncModules.d.ts +18 -10
- package/dist/base/syncModules.js +100 -29
- package/dist/base/utils.d.ts +26 -21
- package/dist/base/validation.d.ts +3 -3
- package/dist/base/validation.js +6 -7
- package/dist/blocks/blocksApi.d.ts +20 -17
- package/dist/blocks/blocksApi.js +101 -74
- package/dist/blocks/blocksInterfaces.d.ts +8 -8
- package/dist/discounts/discountsApi.d.ts +9 -7
- package/dist/discounts/discountsApi.js +18 -14
- package/dist/discounts/discountsInterfaces.d.ts +14 -10
- package/dist/events/eventsApi.d.ts +3 -3
- package/dist/events/eventsApi.js +7 -7
- package/dist/events/eventsInterfaces.d.ts +10 -14
- package/dist/file-uploading/fileUploadingApi.d.ts +4 -4
- package/dist/file-uploading/fileUploadingApi.js +13 -5
- package/dist/file-uploading/fileUploadingInterfaces.d.ts +5 -6
- package/dist/filters/filtersApi.js +2 -2
- package/dist/forms/formsApi.js +2 -2
- package/dist/forms/formsInterfaces.d.ts +1 -3
- package/dist/forms/formsSchemas.d.ts +3 -6
- package/dist/forms/formsSchemas.js +2 -4
- package/dist/forms-data/formsDataApi.d.ts +26 -8
- package/dist/forms-data/formsDataApi.js +45 -14
- package/dist/forms-data/formsDataInterfaces.d.ts +91 -66
- package/dist/general-types/generalTypesInterfaces.d.ts +1 -1
- package/dist/index.d.ts +7 -6
- package/dist/index.js +50 -7
- package/dist/integration-collections/integrationCollectionsApi.d.ts +15 -4
- package/dist/integration-collections/integrationCollectionsApi.js +42 -14
- package/dist/integration-collections/integrationCollectionsInterfaces.d.ts +8 -9
- package/dist/integration-collections/integrationCollectionsSchemas.d.ts +0 -2
- package/dist/integration-collections/integrationCollectionsSchemas.js +0 -1
- package/dist/menus/menusApi.js +1 -1
- package/dist/orders/ordersApi.d.ts +1 -13
- package/dist/orders/ordersApi.js +24 -44
- package/dist/orders/ordersInterfaces.d.ts +21 -14
- package/dist/pages/pagesApi.d.ts +6 -5
- package/dist/pages/pagesApi.js +44 -31
- package/dist/pages/pagesInterfaces.d.ts +18 -15
- package/dist/pages/pagesSchemas.d.ts +0 -3
- package/dist/pages/pagesSchemas.js +0 -1
- package/dist/payments/paymentsApi.d.ts +10 -11
- package/dist/payments/paymentsApi.js +22 -18
- package/dist/payments/paymentsInterfaces.d.ts +12 -14
- package/dist/payments/paymentsSchemas.d.ts +21 -20
- package/dist/payments/paymentsSchemas.js +5 -8
- package/dist/product-statuses/productStatusesApi.d.ts +1 -1
- package/dist/product-statuses/productStatusesApi.js +4 -4
- package/dist/product-statuses/productStatusesInterfaces.d.ts +1 -4
- package/dist/products/productsApi.d.ts +38 -58
- package/dist/products/productsApi.js +59 -72
- package/dist/products/productsInterfaces.d.ts +48 -85
- package/dist/search/searchApi.d.ts +1 -1
- package/dist/search/searchApi.js +4 -3
- package/dist/sitemap/sitemapInterfaces.d.ts +10 -6
- package/dist/subscriptions/subscriptionsApi.d.ts +1 -1
- package/dist/subscriptions/subscriptionsApi.js +1 -1
- package/dist/subscriptions/subscriptionsInterfaces.d.ts +1 -1
- package/dist/system/systemApi.d.ts +2 -0
- package/dist/system/systemApi.js +2 -0
- package/dist/system/systemInterfaces.d.ts +2 -0
- package/dist/templates/templatesApi.d.ts +2 -2
- package/dist/templates/templatesApi.js +12 -11
- package/dist/templates/templatesInterfaces.d.ts +2 -2
- package/dist/templates-preview/templatesPreviewApi.js +2 -2
- package/dist/templates-preview/templatesPreviewInterfaces.d.ts +23 -13
- package/dist/templates-preview/templatesPreviewSchemas.d.ts +7 -0
- package/dist/templates-preview/templatesPreviewSchemas.js +2 -0
- package/dist/user-groups/userGroupsApi.js +5 -5
- package/dist/user-groups/userGroupsSchemas.d.ts +4 -4
- package/dist/users/usersApi.d.ts +1 -1
- package/dist/users/usersApi.js +28 -15
- package/dist/users/usersInterfaces.d.ts +2 -9
- package/dist/web-socket/lazySocket.d.ts +6 -5
- package/dist/web-socket/lazySocket.js +212 -15
- package/dist/web-socket/wsApi.d.ts +7 -4
- package/dist/web-socket/wsApi.js +49 -12
- package/dist/web-socket/wsInterfaces.d.ts +41 -4
- package/esm/admins/adminsApi.js +2 -9
- package/esm/admins/adminsInterfaces.d.ts +5 -5
- package/esm/admins/adminsSchemas.d.ts +4 -4
- package/esm/admins/adminsSchemas.js +2 -2
- package/esm/attribute-sets/attributeSetsApi.d.ts +1 -1
- package/esm/attribute-sets/attributeSetsApi.js +4 -4
- package/esm/attribute-sets/attributeSetsInterfaces.d.ts +65 -14
- package/esm/attribute-sets/attributeSetsSchemas.d.ts +8 -6
- package/esm/attribute-sets/attributeSetsSchemas.js +6 -9
- package/esm/auth-provider/authProviderApi.d.ts +4 -4
- package/esm/auth-provider/authProviderApi.js +96 -29
- package/esm/auth-provider/authProviderSchemas.d.ts +1 -0
- package/esm/auth-provider/authProviderSchemas.js +1 -0
- package/esm/auth-provider/authProvidersInterfaces.d.ts +8 -6
- package/esm/base/asyncModules.d.ts +73 -1
- package/esm/base/asyncModules.js +233 -37
- package/esm/base/stateModule.d.ts +2 -0
- package/esm/base/stateModule.js +22 -12
- package/esm/base/syncModules.d.ts +18 -10
- package/esm/base/syncModules.js +99 -29
- package/esm/base/utils.d.ts +26 -21
- package/esm/base/validation.d.ts +3 -3
- package/esm/base/validation.js +6 -7
- package/esm/blocks/blocksApi.d.ts +20 -17
- package/esm/blocks/blocksApi.js +101 -74
- package/esm/blocks/blocksInterfaces.d.ts +8 -8
- package/esm/discounts/discountsApi.d.ts +9 -7
- package/esm/discounts/discountsApi.js +18 -14
- package/esm/discounts/discountsInterfaces.d.ts +14 -10
- package/esm/events/eventsApi.d.ts +3 -3
- package/esm/events/eventsApi.js +7 -7
- package/esm/events/eventsInterfaces.d.ts +10 -14
- package/esm/file-uploading/fileUploadingApi.d.ts +4 -4
- package/esm/file-uploading/fileUploadingApi.js +13 -5
- package/esm/file-uploading/fileUploadingInterfaces.d.ts +5 -6
- package/esm/filters/filtersApi.js +2 -2
- package/esm/forms/formsApi.js +2 -2
- package/esm/forms/formsInterfaces.d.ts +1 -3
- package/esm/forms/formsSchemas.d.ts +3 -6
- package/esm/forms/formsSchemas.js +2 -4
- package/esm/forms-data/formsDataApi.d.ts +26 -8
- package/esm/forms-data/formsDataApi.js +45 -14
- package/esm/forms-data/formsDataInterfaces.d.ts +91 -66
- package/esm/general-types/generalTypesInterfaces.d.ts +1 -1
- package/esm/index.d.ts +7 -6
- package/esm/index.js +50 -7
- package/esm/integration-collections/integrationCollectionsApi.d.ts +15 -4
- package/esm/integration-collections/integrationCollectionsApi.js +42 -14
- package/esm/integration-collections/integrationCollectionsInterfaces.d.ts +8 -9
- package/esm/integration-collections/integrationCollectionsSchemas.d.ts +0 -2
- package/esm/integration-collections/integrationCollectionsSchemas.js +0 -1
- package/esm/menus/menusApi.js +1 -1
- package/esm/orders/ordersApi.d.ts +1 -13
- package/esm/orders/ordersApi.js +24 -44
- package/esm/orders/ordersInterfaces.d.ts +21 -14
- package/esm/pages/pagesApi.d.ts +6 -5
- package/esm/pages/pagesApi.js +44 -31
- package/esm/pages/pagesInterfaces.d.ts +18 -15
- package/esm/pages/pagesSchemas.d.ts +0 -3
- package/esm/pages/pagesSchemas.js +0 -1
- package/esm/payments/paymentsApi.d.ts +10 -11
- package/esm/payments/paymentsApi.js +22 -18
- package/esm/payments/paymentsInterfaces.d.ts +12 -14
- package/esm/payments/paymentsSchemas.d.ts +21 -20
- package/esm/payments/paymentsSchemas.js +5 -8
- package/esm/product-statuses/productStatusesApi.d.ts +1 -1
- package/esm/product-statuses/productStatusesApi.js +4 -4
- package/esm/product-statuses/productStatusesInterfaces.d.ts +1 -4
- package/esm/products/productsApi.d.ts +38 -58
- package/esm/products/productsApi.js +59 -72
- package/esm/products/productsInterfaces.d.ts +48 -85
- package/esm/search/searchApi.d.ts +1 -1
- package/esm/search/searchApi.js +4 -3
- package/esm/sitemap/sitemapInterfaces.d.ts +10 -6
- package/esm/subscriptions/subscriptionsApi.d.ts +1 -1
- package/esm/subscriptions/subscriptionsApi.js +1 -1
- package/esm/subscriptions/subscriptionsInterfaces.d.ts +1 -1
- package/esm/system/systemApi.d.ts +2 -0
- package/esm/system/systemApi.js +2 -0
- package/esm/system/systemInterfaces.d.ts +2 -0
- package/esm/templates/templatesApi.d.ts +2 -2
- package/esm/templates/templatesApi.js +11 -10
- package/esm/templates/templatesInterfaces.d.ts +2 -2
- package/esm/templates-preview/templatesPreviewApi.js +2 -2
- package/esm/templates-preview/templatesPreviewInterfaces.d.ts +23 -13
- package/esm/templates-preview/templatesPreviewSchemas.d.ts +7 -0
- package/esm/templates-preview/templatesPreviewSchemas.js +2 -0
- package/esm/user-groups/userGroupsApi.js +5 -5
- package/esm/user-groups/userGroupsSchemas.d.ts +4 -4
- package/esm/users/usersApi.d.ts +1 -1
- package/esm/users/usersApi.js +28 -15
- package/esm/users/usersInterfaces.d.ts +2 -9
- package/esm/web-socket/lazySocket.d.ts +6 -5
- package/esm/web-socket/lazySocket.js +212 -15
- package/esm/web-socket/wsApi.d.ts +7 -4
- package/esm/web-socket/wsApi.js +49 -12
- package/esm/web-socket/wsInterfaces.d.ts +41 -4
- package/package.json +2 -2
package/esm/blocks/blocksApi.js
CHANGED
|
@@ -22,7 +22,7 @@ export default class BlocksApi extends AsyncModules {
|
|
|
22
22
|
/**
|
|
23
23
|
* Get blocks by parameters.
|
|
24
24
|
* @handleName getBlocks
|
|
25
|
-
* @param {BlockType} [type] - Optional block type to filter by. Available values: "product" | "error_page" | "catalog_page" | "product_preview" | "similar_products_block" | "product_block" | "frequently_ordered_block" | "trending_block" | "recently_viewed_block" | "repeat_purchase_block" | "slider_block" | "personal_recommendations_block" | "cart_complement_block" | "cart_similar_block" | "wishlist_similar_block" | "form" | "common_page" | "common_block" | "order" | "service" | "external_page" | "discount" (see BlockType). When omitted, blocks of all types are returned. Example: '
|
|
25
|
+
* @param {BlockType} [type] - Optional block type to filter by. Available values: "product" | "error_page" | "catalog_page" | "product_preview" | "similar_products_block" | "product_block" | "frequently_ordered_block" | "trending_block" | "recently_viewed_block" | "repeat_purchase_block" | "slider_block" | "personal_recommendations_block" | "cart_complement_block" | "cart_similar_block" | "wishlist_similar_block" | "form" | "common_page" | "common_block" | "order" | "service" | "external_page" | "discount" (see BlockType). When omitted, blocks of all types are returned. A type no block has (e.g. "product", which is a product type, not a block type) gives an empty list, not an error. Example: 'product_block'.
|
|
26
26
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
27
27
|
* @param {number} [offset] - Number of records to skip. Default: 0.
|
|
28
28
|
* @param {number} [limit] - Maximum number of records to return. Default: 30.
|
|
@@ -35,19 +35,22 @@ export default class BlocksApi extends AsyncModules {
|
|
|
35
35
|
// empty type value, so it must not be sent at all.
|
|
36
36
|
const query = this._queryParamsToString({ langCode, type, offset, limit });
|
|
37
37
|
const response = await this._fetchPost(`?${query}`);
|
|
38
|
+
// Display settings are lifted before validation: a strict schema drops
|
|
39
|
+
// `customSettings`, and with it `countElementsPerRow` and `quantity`
|
|
40
|
+
if (Array.isArray(response === null || response === void 0 ? void 0 : response.items)) {
|
|
41
|
+
response.items.forEach((block) => this._liftBlockSettings(block));
|
|
42
|
+
}
|
|
38
43
|
// Validate response if validation is enabled
|
|
39
44
|
const validated = await this._validateResponse(response, schema('BlocksResponseSchema'));
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
return normalizeResponse;
|
|
45
|
+
const normalizeResponse = this._normalizeData(validated, langCode);
|
|
46
|
+
// On API error responses (e.g. 403 without list permission, 422) the
|
|
47
|
+
// normalized value is an IError without `items` — return it as-is.
|
|
48
|
+
// `offset` and `limit` page the list of blocks, not the products inside
|
|
49
|
+
// each block: passed on, `offset: 5` emptied every block's products.
|
|
50
|
+
if (!this.state.traficLimit && Array.isArray(normalizeResponse.items)) {
|
|
51
|
+
await Promise.all(normalizeResponse.items.map((block) => this._loadBlockProducts(block, langCode)));
|
|
49
52
|
}
|
|
50
|
-
return
|
|
53
|
+
return normalizeResponse;
|
|
51
54
|
}
|
|
52
55
|
/**
|
|
53
56
|
* Get block by marker.
|
|
@@ -62,33 +65,29 @@ export default class BlocksApi extends AsyncModules {
|
|
|
62
65
|
* @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getBlockByMarker getBlockByMarker} documentation.
|
|
63
66
|
*/
|
|
64
67
|
async getBlockByMarker(marker, langCode = this.state.lang, offset = 0, limit = 30) {
|
|
65
|
-
const response = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
|
|
68
|
+
const response = await this._fetchGet(`/marker/${this._pathSegment(marker)}?langCode=${encodeURIComponent(langCode)}`);
|
|
69
|
+
if (response && !this._isErrorResponse(response)) {
|
|
70
|
+
this._liftBlockSettings(response);
|
|
71
|
+
}
|
|
66
72
|
// Validate response if validation is enabled
|
|
67
73
|
const validated = await this._validateResponse(response, schema('BlockEntitySchema'));
|
|
68
|
-
const normalizeResponse = this._normalizeData(validated);
|
|
69
|
-
|
|
74
|
+
const normalizeResponse = this._normalizeData(validated, langCode);
|
|
75
|
+
if (!this.state.traficLimit && !this._isErrorResponse(normalizeResponse)) {
|
|
76
|
+
await this._loadBlockProducts(normalizeResponse, langCode, offset, limit);
|
|
77
|
+
}
|
|
70
78
|
return normalizeResponse;
|
|
71
79
|
}
|
|
72
80
|
/**
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* `
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* @param {any} block - Normalized block to enrich (mutated in place).
|
|
81
|
-
* @param {string} langCode - Language code passed to product sub-requests.
|
|
82
|
-
* @param {number} offset - Pagination offset for product sub-requests.
|
|
83
|
-
* @param {number} limit - Pagination limit for product sub-requests.
|
|
84
|
-
* @param {boolean} loadProducts - Whether to fetch related products.
|
|
85
|
-
* @returns {Promise<void>} Resolves when enrichment (incl. sub-requests) is done.
|
|
81
|
+
* Lifts the product display settings of a block to top-level fields and drops internal ones.
|
|
82
|
+
* @param {any} block - A block as the API sent it.
|
|
83
|
+
* @description `customSettings.productConfig` holds `countElementsPerRow` and `quantity`
|
|
84
|
+
* as strings; they become numbers on the block. `customSettings`, `attributeSetIdentifier`
|
|
85
|
+
* and `productPageUrls` are internal and removed — in traffic-saving mode as well, which
|
|
86
|
+
* used to return them as they came; the set marker was misspelt (`attributesSetIdentifier`)
|
|
87
|
+
* and stayed in every block.
|
|
86
88
|
*/
|
|
87
|
-
|
|
88
|
-
const customSettings = block.customSettings;
|
|
89
|
-
// Если у блока есть настройки отображения товаров (productConfig) —
|
|
90
|
-
// переносим их на верхний уровень блока в числовом формате (в API значения
|
|
91
|
-
// хранятся строками, поэтому приводим через «+»).
|
|
89
|
+
_liftBlockSettings(block) {
|
|
90
|
+
const customSettings = block === null || block === void 0 ? void 0 : block.customSettings;
|
|
92
91
|
if (customSettings &&
|
|
93
92
|
Object.prototype.hasOwnProperty.call(customSettings, 'productConfig')) {
|
|
94
93
|
if (customSettings.productConfig.countElementsPerRow)
|
|
@@ -97,31 +96,43 @@ export default class BlocksApi extends AsyncModules {
|
|
|
97
96
|
if (customSettings.productConfig.quantity)
|
|
98
97
|
block.quantity = +customSettings.productConfig.quantity;
|
|
99
98
|
}
|
|
100
|
-
// Убираем служебные/внутренние поля из итогового объекта блока.
|
|
101
99
|
delete block.customSettings;
|
|
102
|
-
delete block.
|
|
100
|
+
delete block.attributeSetIdentifier;
|
|
103
101
|
delete block.productPageUrls;
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Attaches the products of a product or similar-products block.
|
|
105
|
+
* @param {any} block - A normalized block.
|
|
106
|
+
* @param {string} langCode - Language of the products.
|
|
107
|
+
* @param {number} [offset] - Products to skip.
|
|
108
|
+
* @param {number} [limit] - Products to return.
|
|
109
|
+
* @description A failed sub-request leaves an empty value of the declared type —
|
|
110
|
+
* `{ items: [], total: 0 }` for `similarProducts`, `[]` for `products` — instead of
|
|
111
|
+
* the error object or an array where a container is declared.
|
|
112
|
+
*/
|
|
113
|
+
async _loadBlockProducts(block, langCode, offset, limit) {
|
|
110
114
|
if (block.type === 'similar_products_block') {
|
|
115
|
+
let similar;
|
|
111
116
|
try {
|
|
112
|
-
|
|
117
|
+
similar = await this._asSubRequest().getSimilarProducts(block.identifier, langCode, offset, limit);
|
|
113
118
|
}
|
|
114
119
|
catch {
|
|
115
|
-
|
|
120
|
+
similar = null;
|
|
116
121
|
}
|
|
122
|
+
block.similarProducts =
|
|
123
|
+
similar && !this._isErrorResponse(similar)
|
|
124
|
+
? similar
|
|
125
|
+
: { items: [], total: 0 };
|
|
117
126
|
}
|
|
118
127
|
else if (block.type === 'product_block') {
|
|
128
|
+
let products;
|
|
119
129
|
try {
|
|
120
|
-
|
|
130
|
+
products = await this._asSubRequest().getProductsByBlockMarker(block.identifier, langCode, offset, limit);
|
|
121
131
|
}
|
|
122
132
|
catch {
|
|
123
|
-
|
|
133
|
+
products = null;
|
|
124
134
|
}
|
|
135
|
+
block.products = Array.isArray(products) ? products : [];
|
|
125
136
|
}
|
|
126
137
|
}
|
|
127
138
|
/**
|
|
@@ -136,7 +147,6 @@ export default class BlocksApi extends AsyncModules {
|
|
|
136
147
|
* @param {number} [productId] - Optional product id to find similar products for.
|
|
137
148
|
* @returns {Promise<IProductsResponse | IError>} Returns the total count and an array of product items in object by specified block marker.
|
|
138
149
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
139
|
-
* @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getSimilarProducts getSimilarProducts} documentation.
|
|
140
150
|
*/
|
|
141
151
|
async getSimilarProducts(marker, langCode = this.state.lang, offset = 0, limit = 30, signPrice, productId) {
|
|
142
152
|
const query = {
|
|
@@ -146,8 +156,9 @@ export default class BlocksApi extends AsyncModules {
|
|
|
146
156
|
signPrice,
|
|
147
157
|
productId,
|
|
148
158
|
};
|
|
149
|
-
const result = await this._fetchGet(`/${marker}/similar-products?` +
|
|
150
|
-
|
|
159
|
+
const result = await this._fetchGet(`/${this._pathSegment(marker)}/similar-products?` +
|
|
160
|
+
this._queryParamsToString(query));
|
|
161
|
+
return this._normalizeData(result, langCode);
|
|
151
162
|
}
|
|
152
163
|
/**
|
|
153
164
|
* Get products by block marker.
|
|
@@ -160,7 +171,6 @@ export default class BlocksApi extends AsyncModules {
|
|
|
160
171
|
* @see {@link https://js-sdk.oneentry.cloud/docs/blocks/#Fixing-the-price-signPrice Fixing the price} documentation.
|
|
161
172
|
* @returns {Promise<IProductsEntity[] | IError>} Return array of BlocksEntity object.
|
|
162
173
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
163
|
-
* @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getProductsByBlockMarker getProductsByBlockMarker} documentation.
|
|
164
174
|
*/
|
|
165
175
|
async getProductsByBlockMarker(marker, langCode = this.state.lang, offset = 0, limit = 30, signPrice) {
|
|
166
176
|
const query = {
|
|
@@ -169,13 +179,14 @@ export default class BlocksApi extends AsyncModules {
|
|
|
169
179
|
limit,
|
|
170
180
|
signPrice,
|
|
171
181
|
};
|
|
172
|
-
const result = await this._fetchGet(`/${marker}/products?` +
|
|
182
|
+
const result = await this._fetchGet(`/${this._pathSegment(marker)}/products?` +
|
|
183
|
+
this._queryParamsToString(query));
|
|
173
184
|
// On API error responses there is no `items` array — return the (normalized)
|
|
174
185
|
// error as-is instead of producing `undefined` from `result.items`.
|
|
175
186
|
if (!Array.isArray(result === null || result === void 0 ? void 0 : result.items)) {
|
|
176
|
-
return this._normalizeData(result);
|
|
187
|
+
return this._normalizeData(result, langCode);
|
|
177
188
|
}
|
|
178
|
-
return this._normalizeData(result.items);
|
|
189
|
+
return this._normalizeData(result.items, langCode);
|
|
179
190
|
}
|
|
180
191
|
/**
|
|
181
192
|
* Get frequently ordered products by block marker and product id.
|
|
@@ -196,9 +207,9 @@ export default class BlocksApi extends AsyncModules {
|
|
|
196
207
|
signPrice,
|
|
197
208
|
limit,
|
|
198
209
|
};
|
|
199
|
-
const data = await this._fetchGet(`/${marker}/products/${productId}/frequently-ordered?` +
|
|
210
|
+
const data = await this._fetchGet(`/${this._pathSegment(marker)}/products/${this._pathSegment(String(productId))}/frequently-ordered?` +
|
|
200
211
|
this._queryParamsToString(query));
|
|
201
|
-
return this._normalizeData(data);
|
|
212
|
+
return this._normalizeData(data, langCode);
|
|
202
213
|
}
|
|
203
214
|
/**
|
|
204
215
|
* Quick search for block objects with limited output.
|
|
@@ -229,8 +240,9 @@ export default class BlocksApi extends AsyncModules {
|
|
|
229
240
|
*/
|
|
230
241
|
async getCartComplement(marker, langCode = this.state.lang, signPrice, limit) {
|
|
231
242
|
const query = { langCode, signPrice, limit };
|
|
232
|
-
const data = await this._fetchGet(`/${marker}/cart-complement?` +
|
|
233
|
-
|
|
243
|
+
const data = await this._fetchGet(`/${this._pathSegment(marker)}/cart-complement?` +
|
|
244
|
+
this._queryParamsToString(query));
|
|
245
|
+
return this._normalizeData(data, langCode);
|
|
234
246
|
}
|
|
235
247
|
/**
|
|
236
248
|
* Get "complete your cart" products by an explicit list of productIds (POST body).
|
|
@@ -247,8 +259,11 @@ export default class BlocksApi extends AsyncModules {
|
|
|
247
259
|
* @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getCartComplementByProductIds getCartComplementByProductIds} documentation.
|
|
248
260
|
*/
|
|
249
261
|
async getCartComplementByProductIds(marker, body) {
|
|
250
|
-
|
|
251
|
-
|
|
262
|
+
var _a;
|
|
263
|
+
// An explicit `langCode: undefined` in the body used to override the default
|
|
264
|
+
const langCode = (_a = body.langCode) !== null && _a !== void 0 ? _a : this.state.lang;
|
|
265
|
+
const data = await this._fetchPost(`/${this._pathSegment(marker)}/cart-complement`, { ...body, langCode });
|
|
266
|
+
return this._normalizeData(data, langCode);
|
|
252
267
|
}
|
|
253
268
|
/**
|
|
254
269
|
* Get "similar to cart" products by the cart from context (auth user or guest).
|
|
@@ -264,8 +279,9 @@ export default class BlocksApi extends AsyncModules {
|
|
|
264
279
|
*/
|
|
265
280
|
async getCartSimilar(marker, langCode = this.state.lang, signPrice, limit) {
|
|
266
281
|
const query = { langCode, signPrice, limit };
|
|
267
|
-
const data = await this._fetchGet(`/${marker}/cart-similar?` +
|
|
268
|
-
|
|
282
|
+
const data = await this._fetchGet(`/${this._pathSegment(marker)}/cart-similar?` +
|
|
283
|
+
this._queryParamsToString(query));
|
|
284
|
+
return this._normalizeData(data, langCode);
|
|
269
285
|
}
|
|
270
286
|
/**
|
|
271
287
|
* Get "similar to cart" products by an explicit list of productIds (POST body).
|
|
@@ -282,8 +298,11 @@ export default class BlocksApi extends AsyncModules {
|
|
|
282
298
|
* @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getCartSimilarByProductIds getCartSimilarByProductIds} documentation.
|
|
283
299
|
*/
|
|
284
300
|
async getCartSimilarByProductIds(marker, body) {
|
|
285
|
-
|
|
286
|
-
|
|
301
|
+
var _a;
|
|
302
|
+
// An explicit `langCode: undefined` in the body used to override the default
|
|
303
|
+
const langCode = (_a = body.langCode) !== null && _a !== void 0 ? _a : this.state.lang;
|
|
304
|
+
const data = await this._fetchPost(`/${this._pathSegment(marker)}/cart-similar`, { ...body, langCode });
|
|
305
|
+
return this._normalizeData(data, langCode);
|
|
287
306
|
}
|
|
288
307
|
/**
|
|
289
308
|
* Get personal recommendations for the user.
|
|
@@ -299,8 +318,9 @@ export default class BlocksApi extends AsyncModules {
|
|
|
299
318
|
*/
|
|
300
319
|
async getPersonalRecommendations(marker, langCode = this.state.lang, signPrice, limit) {
|
|
301
320
|
const query = { langCode, signPrice, limit };
|
|
302
|
-
const data = await this._fetchGet(`/${marker}/personal-recommendations?` +
|
|
303
|
-
|
|
321
|
+
const data = await this._fetchGet(`/${this._pathSegment(marker)}/personal-recommendations?` +
|
|
322
|
+
this._queryParamsToString(query));
|
|
323
|
+
return this._normalizeData(data, langCode);
|
|
304
324
|
}
|
|
305
325
|
/**
|
|
306
326
|
* Get recently viewed products.
|
|
@@ -316,8 +336,9 @@ export default class BlocksApi extends AsyncModules {
|
|
|
316
336
|
*/
|
|
317
337
|
async getRecentlyViewed(marker, langCode = this.state.lang, signPrice, limit) {
|
|
318
338
|
const query = { langCode, signPrice, limit };
|
|
319
|
-
const data = await this._fetchGet(`/${marker}/recently-viewed?` +
|
|
320
|
-
|
|
339
|
+
const data = await this._fetchGet(`/${this._pathSegment(marker)}/recently-viewed?` +
|
|
340
|
+
this._queryParamsToString(query));
|
|
341
|
+
return this._normalizeData(data, langCode);
|
|
321
342
|
}
|
|
322
343
|
/**
|
|
323
344
|
* Get products for repeat purchase.
|
|
@@ -333,8 +354,9 @@ export default class BlocksApi extends AsyncModules {
|
|
|
333
354
|
*/
|
|
334
355
|
async getRepeatPurchase(marker, langCode = this.state.lang, signPrice, limit) {
|
|
335
356
|
const query = { langCode, signPrice, limit };
|
|
336
|
-
const data = await this._fetchGet(`/${marker}/repeat-purchase?` +
|
|
337
|
-
|
|
357
|
+
const data = await this._fetchGet(`/${this._pathSegment(marker)}/repeat-purchase?` +
|
|
358
|
+
this._queryParamsToString(query));
|
|
359
|
+
return this._normalizeData(data, langCode);
|
|
338
360
|
}
|
|
339
361
|
/**
|
|
340
362
|
* Get the block's slides tree as a flat pre-order array (slider_block only).
|
|
@@ -345,7 +367,7 @@ export default class BlocksApi extends AsyncModules {
|
|
|
345
367
|
* @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getSlides getSlides} documentation.
|
|
346
368
|
*/
|
|
347
369
|
async getSlides(marker) {
|
|
348
|
-
const data = await this._fetchGet(`/${marker}/slides`);
|
|
370
|
+
const data = await this._fetchGet(`/${this._pathSegment(marker)}/slides`);
|
|
349
371
|
return this._normalizeData(data);
|
|
350
372
|
}
|
|
351
373
|
/**
|
|
@@ -362,8 +384,9 @@ export default class BlocksApi extends AsyncModules {
|
|
|
362
384
|
*/
|
|
363
385
|
async getTrending(marker, langCode = this.state.lang, signPrice, limit) {
|
|
364
386
|
const query = { langCode, signPrice, limit };
|
|
365
|
-
const data = await this._fetchGet(`/${marker}/trending?` +
|
|
366
|
-
|
|
387
|
+
const data = await this._fetchGet(`/${this._pathSegment(marker)}/trending?` +
|
|
388
|
+
this._queryParamsToString(query));
|
|
389
|
+
return this._normalizeData(data, langCode);
|
|
367
390
|
}
|
|
368
391
|
/**
|
|
369
392
|
* Get "similar to wishlist" products by the wishlist from context (auth user or guest).
|
|
@@ -379,8 +402,9 @@ export default class BlocksApi extends AsyncModules {
|
|
|
379
402
|
*/
|
|
380
403
|
async getWishlistSimilar(marker, langCode = this.state.lang, signPrice, limit) {
|
|
381
404
|
const query = { langCode, signPrice, limit };
|
|
382
|
-
const data = await this._fetchGet(`/${marker}/wishlist-similar?` +
|
|
383
|
-
|
|
405
|
+
const data = await this._fetchGet(`/${this._pathSegment(marker)}/wishlist-similar?` +
|
|
406
|
+
this._queryParamsToString(query));
|
|
407
|
+
return this._normalizeData(data, langCode);
|
|
384
408
|
}
|
|
385
409
|
/**
|
|
386
410
|
* Get "similar to wishlist" products by an explicit list of productIds (POST body).
|
|
@@ -397,7 +421,10 @@ export default class BlocksApi extends AsyncModules {
|
|
|
397
421
|
* @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getWishlistSimilarByProductIds getWishlistSimilarByProductIds} documentation.
|
|
398
422
|
*/
|
|
399
423
|
async getWishlistSimilarByProductIds(marker, body) {
|
|
400
|
-
|
|
401
|
-
|
|
424
|
+
var _a;
|
|
425
|
+
// An explicit `langCode: undefined` in the body used to override the default
|
|
426
|
+
const langCode = (_a = body.langCode) !== null && _a !== void 0 ? _a : this.state.lang;
|
|
427
|
+
const data = await this._fetchPost(`/${this._pathSegment(marker)}/wishlist-similar`, { ...body, langCode });
|
|
428
|
+
return this._normalizeData(data, langCode);
|
|
402
429
|
}
|
|
403
430
|
}
|
|
@@ -9,7 +9,7 @@ interface IBlocks {
|
|
|
9
9
|
/**
|
|
10
10
|
* Retrieves all block objects of a specific type.
|
|
11
11
|
* @handleName getBlocks
|
|
12
|
-
* @param {BlockType} [type] - Optional type of blocks to retrieve. When omitted, blocks of all types are returned. Example: "
|
|
12
|
+
* @param {BlockType} [type] - Optional type of blocks to retrieve. When omitted, blocks of all types are returned. A type no block has (e.g. "product") gives an empty list, not an error. Example: "product_block".
|
|
13
13
|
* @param {string} [langCode] - Optional language code for localization. Default: "en_US".
|
|
14
14
|
* @param {number} [offset] - Number of records to skip. Default: 0.
|
|
15
15
|
* @param {number} [limit] - Maximum number of records to return. Default: 30.
|
|
@@ -203,7 +203,7 @@ interface IBlocks {
|
|
|
203
203
|
"localizeInfos": { "key": "value" },
|
|
204
204
|
"position": 1,
|
|
205
205
|
"templateIdentifier": null,
|
|
206
|
-
"type": "
|
|
206
|
+
"type": "product_block",
|
|
207
207
|
"version": 1,
|
|
208
208
|
"countElementsPerRow": 3,
|
|
209
209
|
"quantity": 9,
|
|
@@ -214,11 +214,11 @@ interface IBlocks {
|
|
|
214
214
|
"products": [
|
|
215
215
|
{
|
|
216
216
|
"id": 1,
|
|
217
|
-
"
|
|
217
|
+
"localizeInfos": { "title": "Product 1" }
|
|
218
218
|
},
|
|
219
219
|
{
|
|
220
220
|
"id": 2,
|
|
221
|
-
"
|
|
221
|
+
"localizeInfos": { "title": "Product 2" }
|
|
222
222
|
}
|
|
223
223
|
]
|
|
224
224
|
}
|
|
@@ -252,7 +252,7 @@ interface IBlocksResponse {
|
|
|
252
252
|
}
|
|
253
253
|
* @property {number} version - Version number of the block. Example: 1.
|
|
254
254
|
* @property {string} identifier - Marker of the block. Example: "block1".
|
|
255
|
-
* @property {BlockType} type - Type of the block. Example: "
|
|
255
|
+
* @property {BlockType} type - Type of the block. Example: "product_block".
|
|
256
256
|
* @property {number} position - Position of the block, used for sorting. Example: 1.
|
|
257
257
|
* @property {string | null} templateIdentifier - Marker of the template used by the block, or `null`. Example: "template1".
|
|
258
258
|
* @property {boolean} isVisible - Whether the block is visible. Example: true.
|
|
@@ -269,11 +269,11 @@ interface IBlocksResponse {
|
|
|
269
269
|
[
|
|
270
270
|
{
|
|
271
271
|
"id": 1,
|
|
272
|
-
"
|
|
272
|
+
"localizeInfos": { "title": "Product 1" }
|
|
273
273
|
},
|
|
274
274
|
{
|
|
275
275
|
"id": 2,
|
|
276
|
-
"
|
|
276
|
+
"localizeInfos": { "title": "Product 2" }
|
|
277
277
|
}
|
|
278
278
|
]
|
|
279
279
|
* @description Represents a block entity with various attributes and properties.
|
|
@@ -311,7 +311,7 @@ interface ISearchBlock {
|
|
|
311
311
|
* @type {BlockType}
|
|
312
312
|
* @description This type defines the possible values for block types used in the system: the types `GET /api/content/general-types` returns.
|
|
313
313
|
* `'none'` was dropped — the platform has no such type and a filter by it answers `400 type must be a valid enum value`.
|
|
314
|
-
* `'service'` is the platform's own name for the type
|
|
314
|
+
* `'service'` is the platform's own name for the type; the `type` filter of getBlocks and getTemplateByType takes it in lower case.
|
|
315
315
|
*/
|
|
316
316
|
type BlockType = 'product' | 'error_page' | 'catalog_page' | 'product_preview' | 'similar_products_block' | 'product_block' | 'frequently_ordered_block' | 'trending_block' | 'recently_viewed_block' | 'repeat_purchase_block' | 'slider_block' | 'personal_recommendations_block' | 'cart_complement_block' | 'cart_similar_block' | 'wishlist_similar_block' | 'form' | 'common_page' | 'common_block' | 'order' | 'service' | 'external_page' | 'discount';
|
|
317
317
|
/**
|
|
@@ -3,12 +3,12 @@ import type StateModule from '../base/stateModule.js';
|
|
|
3
3
|
import type { IError, IVectorSearchResponse } from '../base/utils.js';
|
|
4
4
|
import type { IBonusBalanceEntity, IBonusHistoryResponse, IBonusTransactionType, ICouponValidationResult, IDiscountsApi, IDiscountsEntity, IDiscountsResponse, IDiscountsVectorSearch, IDiscountType } from './discountsInterfaces.js';
|
|
5
5
|
/**
|
|
6
|
-
* Controllers for working with
|
|
7
|
-
* @handle /api/content/
|
|
6
|
+
* Controllers for working with discounts, coupons and the bonus balance
|
|
7
|
+
* @handle /api/content/discounts
|
|
8
8
|
* @class DiscountsApi
|
|
9
9
|
* @augments AsyncModules
|
|
10
10
|
* @implements {IDiscountsApi}
|
|
11
|
-
* @description This class provides methods
|
|
11
|
+
* @description This class provides methods for discounts: the list and one discount by marker, coupon validation, the bonus balance and its history, and vector search.
|
|
12
12
|
*/
|
|
13
13
|
export default class DiscountsApi extends AsyncModules implements IDiscountsApi {
|
|
14
14
|
protected state: StateModule;
|
|
@@ -38,7 +38,7 @@ export default class DiscountsApi extends AsyncModules implements IDiscountsApi
|
|
|
38
38
|
/**
|
|
39
39
|
* Get discount by marker
|
|
40
40
|
* @handleName getDiscountByMarker
|
|
41
|
-
* @param {string} marker - Marker of the discount
|
|
41
|
+
* @param {string} marker - Marker of the discount. Example: "example_discount".
|
|
42
42
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
43
43
|
* @returns {Promise<IDiscountsEntity | IError>} Returns an object containing discount by marker or an error object if there was an issue.
|
|
44
44
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
@@ -58,16 +58,18 @@ export default class DiscountsApi extends AsyncModules implements IDiscountsApi
|
|
|
58
58
|
* Get bonus transaction history of the current user.
|
|
59
59
|
* @handleName getBonusHistory
|
|
60
60
|
* @param {IBonusTransactionType} [type] - Transaction type to filter by.
|
|
61
|
-
* @param {string} [dateFrom] - Start of the date range.
|
|
62
|
-
* @param {string} [dateTo] - End of the date range.
|
|
61
|
+
* @param {string} [dateFrom] - Start of the date range. Full ISO date-time (`2026-01-01T00:00:00.000Z`); a bare date answers `400 dateFrom must be a ISOString`.
|
|
62
|
+
* @param {string} [dateTo] - End of the date range. Full ISO date-time (`2026-12-31T00:00:00.000Z`); a bare date answers `400 dateTo must be a ISOString`.
|
|
63
63
|
* @param {number} [discountId] - Return only transactions of this discount ID.
|
|
64
64
|
* @param {number} [moduleId] - Filter by module ID.
|
|
65
65
|
* @param {boolean} [isAdmin] - Filter by the transaction's `isAdmin` flag.
|
|
66
|
+
* @param {number} [offset] - Number of transactions to skip, `0` or more. Default: 0.
|
|
67
|
+
* @param {number} [limit] - Maximum number of transactions to return, `1` or more. Default: 30.
|
|
66
68
|
* @returns {Promise<IBonusHistoryResponse | IError>} Returns the container with the transactions and their total, or an error object.
|
|
67
69
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
68
70
|
* @see {@link https://js-sdk.oneentry.cloud/docs/discounts/getBonusHistory getBonusHistory} documentation.
|
|
69
71
|
*/
|
|
70
|
-
getBonusHistory(type?: IBonusTransactionType, dateFrom?: string, dateTo?: string, discountId?: number, moduleId?: number, isAdmin?: boolean): Promise<IBonusHistoryResponse | IError>;
|
|
72
|
+
getBonusHistory(type?: IBonusTransactionType, dateFrom?: string, dateTo?: string, discountId?: number, moduleId?: number, isAdmin?: boolean, offset?: number, limit?: number): Promise<IBonusHistoryResponse | IError>;
|
|
71
73
|
/**
|
|
72
74
|
* Validate discounts coupon
|
|
73
75
|
* @handleName validateDiscountsCoupon
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import AsyncModules from '../base/asyncModules.js';
|
|
2
2
|
/**
|
|
3
|
-
* Controllers for working with
|
|
4
|
-
* @handle /api/content/
|
|
3
|
+
* Controllers for working with discounts, coupons and the bonus balance
|
|
4
|
+
* @handle /api/content/discounts
|
|
5
5
|
* @class DiscountsApi
|
|
6
6
|
* @augments AsyncModules
|
|
7
7
|
* @implements {IDiscountsApi}
|
|
8
|
-
* @description This class provides methods
|
|
8
|
+
* @description This class provides methods for discounts: the list and one discount by marker, coupon validation, the bonus balance and its history, and vector search.
|
|
9
9
|
*/
|
|
10
10
|
export default class DiscountsApi extends AsyncModules {
|
|
11
11
|
/**
|
|
@@ -40,12 +40,12 @@ export default class DiscountsApi extends AsyncModules {
|
|
|
40
40
|
type,
|
|
41
41
|
};
|
|
42
42
|
const data = await this._fetchGet(`?` + this._queryParamsToString(query));
|
|
43
|
-
return this._normalizeData(data);
|
|
43
|
+
return this._normalizeData(data, langCode);
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
46
|
* Get discount by marker
|
|
47
47
|
* @handleName getDiscountByMarker
|
|
48
|
-
* @param {string} marker - Marker of the discount
|
|
48
|
+
* @param {string} marker - Marker of the discount. Example: "example_discount".
|
|
49
49
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
50
50
|
* @returns {Promise<IDiscountsEntity | IError>} Returns an object containing discount by marker or an error object if there was an issue.
|
|
51
51
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
@@ -53,12 +53,11 @@ export default class DiscountsApi extends AsyncModules {
|
|
|
53
53
|
* @see {@link https://js-sdk.oneentry.cloud/docs/discounts/getDiscountByMarker getDiscountByMarker} documentation.
|
|
54
54
|
*/
|
|
55
55
|
async getDiscountByMarker(marker, langCode = this.state.lang) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return this._normalizeData(data);
|
|
56
|
+
// The marker goes in the path; an empty `marker=` used to be sent along
|
|
57
|
+
const query = { langCode };
|
|
58
|
+
const data = await this._fetchGet(`/marker/${this._pathSegment(marker)}?` +
|
|
59
|
+
this._queryParamsToString(query));
|
|
60
|
+
return this._normalizeData(data, langCode);
|
|
62
61
|
}
|
|
63
62
|
/**
|
|
64
63
|
* Get bonus balance of the current user.
|
|
@@ -75,16 +74,19 @@ export default class DiscountsApi extends AsyncModules {
|
|
|
75
74
|
* Get bonus transaction history of the current user.
|
|
76
75
|
* @handleName getBonusHistory
|
|
77
76
|
* @param {IBonusTransactionType} [type] - Transaction type to filter by.
|
|
78
|
-
* @param {string} [dateFrom] - Start of the date range.
|
|
79
|
-
* @param {string} [dateTo] - End of the date range.
|
|
77
|
+
* @param {string} [dateFrom] - Start of the date range. Full ISO date-time (`2026-01-01T00:00:00.000Z`); a bare date answers `400 dateFrom must be a ISOString`.
|
|
78
|
+
* @param {string} [dateTo] - End of the date range. Full ISO date-time (`2026-12-31T00:00:00.000Z`); a bare date answers `400 dateTo must be a ISOString`.
|
|
80
79
|
* @param {number} [discountId] - Return only transactions of this discount ID.
|
|
81
80
|
* @param {number} [moduleId] - Filter by module ID.
|
|
82
81
|
* @param {boolean} [isAdmin] - Filter by the transaction's `isAdmin` flag.
|
|
82
|
+
* @param {number} [offset] - Number of transactions to skip, `0` or more. Default: 0.
|
|
83
|
+
* @param {number} [limit] - Maximum number of transactions to return, `1` or more. Default: 30.
|
|
83
84
|
* @returns {Promise<IBonusHistoryResponse | IError>} Returns the container with the transactions and their total, or an error object.
|
|
84
85
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
85
86
|
* @see {@link https://js-sdk.oneentry.cloud/docs/discounts/getBonusHistory getBonusHistory} documentation.
|
|
86
87
|
*/
|
|
87
|
-
async getBonusHistory(type, dateFrom, dateTo, discountId, moduleId, isAdmin) {
|
|
88
|
+
async getBonusHistory(type, dateFrom, dateTo, discountId, moduleId, isAdmin, offset, limit) {
|
|
89
|
+
// The endpoint pages its answer; offset/limit were not reachable from the SDK
|
|
88
90
|
const query = {
|
|
89
91
|
type,
|
|
90
92
|
dateFrom,
|
|
@@ -92,6 +94,8 @@ export default class DiscountsApi extends AsyncModules {
|
|
|
92
94
|
discountId,
|
|
93
95
|
moduleId,
|
|
94
96
|
isAdmin,
|
|
97
|
+
offset,
|
|
98
|
+
limit,
|
|
95
99
|
};
|
|
96
100
|
const data = await this._fetchGet(`/bonus-balance/history?` + this._queryParamsToString(query));
|
|
97
101
|
return this._normalizeData(data);
|
|
@@ -10,7 +10,7 @@ type IDiscountType = 'DISCOUNT' | 'BONUS' | 'PERSONAL_DISCOUNT';
|
|
|
10
10
|
interface IDiscountsApi {
|
|
11
11
|
/**
|
|
12
12
|
* Return all discounts.
|
|
13
|
-
* @handleName
|
|
13
|
+
* @handleName getAllDiscounts
|
|
14
14
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
15
15
|
* @param {number} [offset] - Number of records to skip. Default: 0.
|
|
16
16
|
* @param {number} [limit] - Maximum number of records to return. Default: 30.
|
|
@@ -23,7 +23,7 @@ interface IDiscountsApi {
|
|
|
23
23
|
/**
|
|
24
24
|
* Get discount by marker
|
|
25
25
|
* @handleName getDiscountByMarker
|
|
26
|
-
* @param {string} marker - Marker of the discount
|
|
26
|
+
* @param {string} marker - Marker of the discount. Example: "example_discount".
|
|
27
27
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
28
28
|
* @returns {Promise<IDiscountsEntity | IError>} Returns an object containing discount by marker or an error object if there was an issue.
|
|
29
29
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
@@ -50,15 +50,17 @@ interface IDiscountsApi {
|
|
|
50
50
|
* Get bonus transaction history of the current user.
|
|
51
51
|
* @handleName getBonusHistory
|
|
52
52
|
* @param {string} [type] - Transaction type to filter by.
|
|
53
|
-
* @param {string} [dateFrom] - Start of the date range.
|
|
54
|
-
* @param {string} [dateTo] - End of the date range.
|
|
53
|
+
* @param {string} [dateFrom] - Start of the date range. Full ISO date-time (`2026-01-01T00:00:00.000Z`); a bare date answers `400 dateFrom must be a ISOString`.
|
|
54
|
+
* @param {string} [dateTo] - End of the date range. Full ISO date-time (`2026-12-31T00:00:00.000Z`); a bare date answers `400 dateTo must be a ISOString`.
|
|
55
55
|
* @param {number} [discountId] - Return only transactions of this discount ID.
|
|
56
56
|
* @param {number} [moduleId] - Filter by module ID.
|
|
57
57
|
* @param {boolean} [isAdmin] - Filter by the transaction's `isAdmin` flag.
|
|
58
|
+
* @param {number} [offset] - Number of transactions to skip, `0` or more. Default: 0.
|
|
59
|
+
* @param {number} [limit] - Maximum number of transactions to return, `1` or more. Default: 30.
|
|
58
60
|
* @returns {Promise<IBonusHistoryResponse | IError>} Returns the container with the transactions and their total, or an error object.
|
|
59
61
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
60
62
|
*/
|
|
61
|
-
getBonusHistory(type?: IBonusTransactionType, dateFrom?: string, dateTo?: string, discountId?: number, moduleId?: number, isAdmin?: boolean): Promise<IBonusHistoryResponse | IError>;
|
|
63
|
+
getBonusHistory(type?: IBonusTransactionType, dateFrom?: string, dateTo?: string, discountId?: number, moduleId?: number, isAdmin?: boolean, offset?: number, limit?: number): Promise<IBonusHistoryResponse | IError>;
|
|
62
64
|
/**
|
|
63
65
|
* Semantic (vector) search for discounts.
|
|
64
66
|
* @handleName getDiscountsByVectorSearch
|
|
@@ -133,7 +135,6 @@ interface IDiscountCondition {
|
|
|
133
135
|
* @property {string} [attributeSetIdentifier] - Marker of the attribute set.
|
|
134
136
|
* @property {Record<string, unknown>} [bonusEvent] - Bonus event configuration.
|
|
135
137
|
* @property {number} [position] - Position used for sorting. Example: 1.
|
|
136
|
-
* @property {number | string} [total] - Total count of related entries. Example: "1".
|
|
137
138
|
* @property {number} [distance] - Cosine distance to the query. Returned only by the semantic (vector) search endpoint when `debug: true` is passed in the search body. Example: 0.12.
|
|
138
139
|
*/
|
|
139
140
|
interface IDiscountsEntity {
|
|
@@ -157,7 +158,6 @@ interface IDiscountsEntity {
|
|
|
157
158
|
attributeSetIdentifier?: string;
|
|
158
159
|
bonusEvent?: Record<string, unknown> | null;
|
|
159
160
|
position?: number;
|
|
160
|
-
total?: number | string;
|
|
161
161
|
distance?: number;
|
|
162
162
|
}
|
|
163
163
|
/**
|
|
@@ -235,17 +235,19 @@ interface IDiscountByMarkerQuery {
|
|
|
235
235
|
marker: string;
|
|
236
236
|
}
|
|
237
237
|
/**
|
|
238
|
-
*
|
|
238
|
+
* Type of a bonus balance transaction: accrual, usage, reduction, the reversal of an accrual or a usage, or expiration.
|
|
239
239
|
*/
|
|
240
240
|
type IBonusTransactionType = 'ACCRUAL' | 'USAGE' | 'REDUCE' | 'REVERSAL_ACCRUAL' | 'REVERSAL_USAGE' | 'EXPIRATION';
|
|
241
241
|
/**
|
|
242
242
|
* @interface IBonusHistoryQuery
|
|
243
243
|
* @property {IBonusTransactionType} [type] - Transaction type to filter by.
|
|
244
|
-
* @property {string} [dateFrom] - Start of the date range.
|
|
245
|
-
* @property {string} [dateTo] - End of the date range.
|
|
244
|
+
* @property {string} [dateFrom] - Start of the date range. Full ISO date-time (`2026-01-01T00:00:00.000Z`); a bare date answers `400 dateFrom must be a ISOString`.
|
|
245
|
+
* @property {string} [dateTo] - End of the date range. Full ISO date-time (`2026-12-31T00:00:00.000Z`); a bare date answers `400 dateTo must be a ISOString`.
|
|
246
246
|
* @property {number} [discountId] - Return only transactions of this discount ID.
|
|
247
247
|
* @property {number} [moduleId] - Filter by module ID.
|
|
248
248
|
* @property {boolean} [isAdmin] - Filter by the transaction's `isAdmin` flag.
|
|
249
|
+
* @property {number} [offset] - Number of transactions to skip. Default: 0.
|
|
250
|
+
* @property {number} [limit] - Maximum number of transactions to return. Default: 30.
|
|
249
251
|
*/
|
|
250
252
|
interface IBonusHistoryQuery {
|
|
251
253
|
type?: IBonusTransactionType;
|
|
@@ -254,6 +256,8 @@ interface IBonusHistoryQuery {
|
|
|
254
256
|
discountId?: number;
|
|
255
257
|
moduleId?: number;
|
|
256
258
|
isAdmin?: boolean;
|
|
259
|
+
offset?: number;
|
|
260
|
+
limit?: number;
|
|
257
261
|
}
|
|
258
262
|
/**
|
|
259
263
|
* @interface IBonusTransactionEntity
|