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/dist/blocks/blocksApi.js
CHANGED
|
@@ -60,7 +60,7 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
60
60
|
/**
|
|
61
61
|
* Get blocks by parameters.
|
|
62
62
|
* @handleName getBlocks
|
|
63
|
-
* @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: '
|
|
63
|
+
* @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'.
|
|
64
64
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
65
65
|
* @param {number} [offset] - Number of records to skip. Default: 0.
|
|
66
66
|
* @param {number} [limit] - Maximum number of records to return. Default: 30.
|
|
@@ -73,19 +73,22 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
73
73
|
// empty type value, so it must not be sent at all.
|
|
74
74
|
const query = this._queryParamsToString({ langCode, type, offset, limit });
|
|
75
75
|
const response = await this._fetchPost(`?${query}`);
|
|
76
|
+
// Display settings are lifted before validation: a strict schema drops
|
|
77
|
+
// `customSettings`, and with it `countElementsPerRow` and `quantity`
|
|
78
|
+
if (Array.isArray(response === null || response === void 0 ? void 0 : response.items)) {
|
|
79
|
+
response.items.forEach((block) => this._liftBlockSettings(block));
|
|
80
|
+
}
|
|
76
81
|
// Validate response if validation is enabled
|
|
77
82
|
const validated = await this._validateResponse(response, schema('BlocksResponseSchema'));
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
return normalizeResponse;
|
|
83
|
+
const normalizeResponse = this._normalizeData(validated, langCode);
|
|
84
|
+
// On API error responses (e.g. 403 without list permission, 422) the
|
|
85
|
+
// normalized value is an IError without `items` — return it as-is.
|
|
86
|
+
// `offset` and `limit` page the list of blocks, not the products inside
|
|
87
|
+
// each block: passed on, `offset: 5` emptied every block's products.
|
|
88
|
+
if (!this.state.traficLimit && Array.isArray(normalizeResponse.items)) {
|
|
89
|
+
await Promise.all(normalizeResponse.items.map((block) => this._loadBlockProducts(block, langCode)));
|
|
87
90
|
}
|
|
88
|
-
return
|
|
91
|
+
return normalizeResponse;
|
|
89
92
|
}
|
|
90
93
|
/**
|
|
91
94
|
* Get block by marker.
|
|
@@ -100,33 +103,29 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
100
103
|
* @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getBlockByMarker getBlockByMarker} documentation.
|
|
101
104
|
*/
|
|
102
105
|
async getBlockByMarker(marker, langCode = this.state.lang, offset = 0, limit = 30) {
|
|
103
|
-
const response = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
|
|
106
|
+
const response = await this._fetchGet(`/marker/${this._pathSegment(marker)}?langCode=${encodeURIComponent(langCode)}`);
|
|
107
|
+
if (response && !this._isErrorResponse(response)) {
|
|
108
|
+
this._liftBlockSettings(response);
|
|
109
|
+
}
|
|
104
110
|
// Validate response if validation is enabled
|
|
105
111
|
const validated = await this._validateResponse(response, schema('BlockEntitySchema'));
|
|
106
|
-
const normalizeResponse = this._normalizeData(validated);
|
|
107
|
-
|
|
112
|
+
const normalizeResponse = this._normalizeData(validated, langCode);
|
|
113
|
+
if (!this.state.traficLimit && !this._isErrorResponse(normalizeResponse)) {
|
|
114
|
+
await this._loadBlockProducts(normalizeResponse, langCode, offset, limit);
|
|
115
|
+
}
|
|
108
116
|
return normalizeResponse;
|
|
109
117
|
}
|
|
110
118
|
/**
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
* `
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
* @param {any} block - Normalized block to enrich (mutated in place).
|
|
119
|
-
* @param {string} langCode - Language code passed to product sub-requests.
|
|
120
|
-
* @param {number} offset - Pagination offset for product sub-requests.
|
|
121
|
-
* @param {number} limit - Pagination limit for product sub-requests.
|
|
122
|
-
* @param {boolean} loadProducts - Whether to fetch related products.
|
|
123
|
-
* @returns {Promise<void>} Resolves when enrichment (incl. sub-requests) is done.
|
|
119
|
+
* Lifts the product display settings of a block to top-level fields and drops internal ones.
|
|
120
|
+
* @param {any} block - A block as the API sent it.
|
|
121
|
+
* @description `customSettings.productConfig` holds `countElementsPerRow` and `quantity`
|
|
122
|
+
* as strings; they become numbers on the block. `customSettings`, `attributeSetIdentifier`
|
|
123
|
+
* and `productPageUrls` are internal and removed — in traffic-saving mode as well, which
|
|
124
|
+
* used to return them as they came; the set marker was misspelt (`attributesSetIdentifier`)
|
|
125
|
+
* and stayed in every block.
|
|
124
126
|
*/
|
|
125
|
-
|
|
126
|
-
const customSettings = block.customSettings;
|
|
127
|
-
// Если у блока есть настройки отображения товаров (productConfig) —
|
|
128
|
-
// переносим их на верхний уровень блока в числовом формате (в API значения
|
|
129
|
-
// хранятся строками, поэтому приводим через «+»).
|
|
127
|
+
_liftBlockSettings(block) {
|
|
128
|
+
const customSettings = block === null || block === void 0 ? void 0 : block.customSettings;
|
|
130
129
|
if (customSettings &&
|
|
131
130
|
Object.prototype.hasOwnProperty.call(customSettings, 'productConfig')) {
|
|
132
131
|
if (customSettings.productConfig.countElementsPerRow)
|
|
@@ -135,31 +134,43 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
135
134
|
if (customSettings.productConfig.quantity)
|
|
136
135
|
block.quantity = +customSettings.productConfig.quantity;
|
|
137
136
|
}
|
|
138
|
-
// Убираем служебные/внутренние поля из итогового объекта блока.
|
|
139
137
|
delete block.customSettings;
|
|
140
|
-
delete block.
|
|
138
|
+
delete block.attributeSetIdentifier;
|
|
141
139
|
delete block.productPageUrls;
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Attaches the products of a product or similar-products block.
|
|
143
|
+
* @param {any} block - A normalized block.
|
|
144
|
+
* @param {string} langCode - Language of the products.
|
|
145
|
+
* @param {number} [offset] - Products to skip.
|
|
146
|
+
* @param {number} [limit] - Products to return.
|
|
147
|
+
* @description A failed sub-request leaves an empty value of the declared type —
|
|
148
|
+
* `{ items: [], total: 0 }` for `similarProducts`, `[]` for `products` — instead of
|
|
149
|
+
* the error object or an array where a container is declared.
|
|
150
|
+
*/
|
|
151
|
+
async _loadBlockProducts(block, langCode, offset, limit) {
|
|
148
152
|
if (block.type === 'similar_products_block') {
|
|
153
|
+
let similar;
|
|
149
154
|
try {
|
|
150
|
-
|
|
155
|
+
similar = await this._asSubRequest().getSimilarProducts(block.identifier, langCode, offset, limit);
|
|
151
156
|
}
|
|
152
157
|
catch {
|
|
153
|
-
|
|
158
|
+
similar = null;
|
|
154
159
|
}
|
|
160
|
+
block.similarProducts =
|
|
161
|
+
similar && !this._isErrorResponse(similar)
|
|
162
|
+
? similar
|
|
163
|
+
: { items: [], total: 0 };
|
|
155
164
|
}
|
|
156
165
|
else if (block.type === 'product_block') {
|
|
166
|
+
let products;
|
|
157
167
|
try {
|
|
158
|
-
|
|
168
|
+
products = await this._asSubRequest().getProductsByBlockMarker(block.identifier, langCode, offset, limit);
|
|
159
169
|
}
|
|
160
170
|
catch {
|
|
161
|
-
|
|
171
|
+
products = null;
|
|
162
172
|
}
|
|
173
|
+
block.products = Array.isArray(products) ? products : [];
|
|
163
174
|
}
|
|
164
175
|
}
|
|
165
176
|
/**
|
|
@@ -174,7 +185,6 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
174
185
|
* @param {number} [productId] - Optional product id to find similar products for.
|
|
175
186
|
* @returns {Promise<IProductsResponse | IError>} Returns the total count and an array of product items in object by specified block marker.
|
|
176
187
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
177
|
-
* @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getSimilarProducts getSimilarProducts} documentation.
|
|
178
188
|
*/
|
|
179
189
|
async getSimilarProducts(marker, langCode = this.state.lang, offset = 0, limit = 30, signPrice, productId) {
|
|
180
190
|
const query = {
|
|
@@ -184,8 +194,9 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
184
194
|
signPrice,
|
|
185
195
|
productId,
|
|
186
196
|
};
|
|
187
|
-
const result = await this._fetchGet(`/${marker}/similar-products?` +
|
|
188
|
-
|
|
197
|
+
const result = await this._fetchGet(`/${this._pathSegment(marker)}/similar-products?` +
|
|
198
|
+
this._queryParamsToString(query));
|
|
199
|
+
return this._normalizeData(result, langCode);
|
|
189
200
|
}
|
|
190
201
|
/**
|
|
191
202
|
* Get products by block marker.
|
|
@@ -198,7 +209,6 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
198
209
|
* @see {@link https://js-sdk.oneentry.cloud/docs/blocks/#Fixing-the-price-signPrice Fixing the price} documentation.
|
|
199
210
|
* @returns {Promise<IProductsEntity[] | IError>} Return array of BlocksEntity object.
|
|
200
211
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
201
|
-
* @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getProductsByBlockMarker getProductsByBlockMarker} documentation.
|
|
202
212
|
*/
|
|
203
213
|
async getProductsByBlockMarker(marker, langCode = this.state.lang, offset = 0, limit = 30, signPrice) {
|
|
204
214
|
const query = {
|
|
@@ -207,13 +217,14 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
207
217
|
limit,
|
|
208
218
|
signPrice,
|
|
209
219
|
};
|
|
210
|
-
const result = await this._fetchGet(`/${marker}/products?` +
|
|
220
|
+
const result = await this._fetchGet(`/${this._pathSegment(marker)}/products?` +
|
|
221
|
+
this._queryParamsToString(query));
|
|
211
222
|
// On API error responses there is no `items` array — return the (normalized)
|
|
212
223
|
// error as-is instead of producing `undefined` from `result.items`.
|
|
213
224
|
if (!Array.isArray(result === null || result === void 0 ? void 0 : result.items)) {
|
|
214
|
-
return this._normalizeData(result);
|
|
225
|
+
return this._normalizeData(result, langCode);
|
|
215
226
|
}
|
|
216
|
-
return this._normalizeData(result.items);
|
|
227
|
+
return this._normalizeData(result.items, langCode);
|
|
217
228
|
}
|
|
218
229
|
/**
|
|
219
230
|
* Get frequently ordered products by block marker and product id.
|
|
@@ -234,9 +245,9 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
234
245
|
signPrice,
|
|
235
246
|
limit,
|
|
236
247
|
};
|
|
237
|
-
const data = await this._fetchGet(`/${marker}/products/${productId}/frequently-ordered?` +
|
|
248
|
+
const data = await this._fetchGet(`/${this._pathSegment(marker)}/products/${this._pathSegment(String(productId))}/frequently-ordered?` +
|
|
238
249
|
this._queryParamsToString(query));
|
|
239
|
-
return this._normalizeData(data);
|
|
250
|
+
return this._normalizeData(data, langCode);
|
|
240
251
|
}
|
|
241
252
|
/**
|
|
242
253
|
* Quick search for block objects with limited output.
|
|
@@ -267,8 +278,9 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
267
278
|
*/
|
|
268
279
|
async getCartComplement(marker, langCode = this.state.lang, signPrice, limit) {
|
|
269
280
|
const query = { langCode, signPrice, limit };
|
|
270
|
-
const data = await this._fetchGet(`/${marker}/cart-complement?` +
|
|
271
|
-
|
|
281
|
+
const data = await this._fetchGet(`/${this._pathSegment(marker)}/cart-complement?` +
|
|
282
|
+
this._queryParamsToString(query));
|
|
283
|
+
return this._normalizeData(data, langCode);
|
|
272
284
|
}
|
|
273
285
|
/**
|
|
274
286
|
* Get "complete your cart" products by an explicit list of productIds (POST body).
|
|
@@ -285,8 +297,11 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
285
297
|
* @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getCartComplementByProductIds getCartComplementByProductIds} documentation.
|
|
286
298
|
*/
|
|
287
299
|
async getCartComplementByProductIds(marker, body) {
|
|
288
|
-
|
|
289
|
-
|
|
300
|
+
var _a;
|
|
301
|
+
// An explicit `langCode: undefined` in the body used to override the default
|
|
302
|
+
const langCode = (_a = body.langCode) !== null && _a !== void 0 ? _a : this.state.lang;
|
|
303
|
+
const data = await this._fetchPost(`/${this._pathSegment(marker)}/cart-complement`, { ...body, langCode });
|
|
304
|
+
return this._normalizeData(data, langCode);
|
|
290
305
|
}
|
|
291
306
|
/**
|
|
292
307
|
* Get "similar to cart" products by the cart from context (auth user or guest).
|
|
@@ -302,8 +317,9 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
302
317
|
*/
|
|
303
318
|
async getCartSimilar(marker, langCode = this.state.lang, signPrice, limit) {
|
|
304
319
|
const query = { langCode, signPrice, limit };
|
|
305
|
-
const data = await this._fetchGet(`/${marker}/cart-similar?` +
|
|
306
|
-
|
|
320
|
+
const data = await this._fetchGet(`/${this._pathSegment(marker)}/cart-similar?` +
|
|
321
|
+
this._queryParamsToString(query));
|
|
322
|
+
return this._normalizeData(data, langCode);
|
|
307
323
|
}
|
|
308
324
|
/**
|
|
309
325
|
* Get "similar to cart" products by an explicit list of productIds (POST body).
|
|
@@ -320,8 +336,11 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
320
336
|
* @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getCartSimilarByProductIds getCartSimilarByProductIds} documentation.
|
|
321
337
|
*/
|
|
322
338
|
async getCartSimilarByProductIds(marker, body) {
|
|
323
|
-
|
|
324
|
-
|
|
339
|
+
var _a;
|
|
340
|
+
// An explicit `langCode: undefined` in the body used to override the default
|
|
341
|
+
const langCode = (_a = body.langCode) !== null && _a !== void 0 ? _a : this.state.lang;
|
|
342
|
+
const data = await this._fetchPost(`/${this._pathSegment(marker)}/cart-similar`, { ...body, langCode });
|
|
343
|
+
return this._normalizeData(data, langCode);
|
|
325
344
|
}
|
|
326
345
|
/**
|
|
327
346
|
* Get personal recommendations for the user.
|
|
@@ -337,8 +356,9 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
337
356
|
*/
|
|
338
357
|
async getPersonalRecommendations(marker, langCode = this.state.lang, signPrice, limit) {
|
|
339
358
|
const query = { langCode, signPrice, limit };
|
|
340
|
-
const data = await this._fetchGet(`/${marker}/personal-recommendations?` +
|
|
341
|
-
|
|
359
|
+
const data = await this._fetchGet(`/${this._pathSegment(marker)}/personal-recommendations?` +
|
|
360
|
+
this._queryParamsToString(query));
|
|
361
|
+
return this._normalizeData(data, langCode);
|
|
342
362
|
}
|
|
343
363
|
/**
|
|
344
364
|
* Get recently viewed products.
|
|
@@ -354,8 +374,9 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
354
374
|
*/
|
|
355
375
|
async getRecentlyViewed(marker, langCode = this.state.lang, signPrice, limit) {
|
|
356
376
|
const query = { langCode, signPrice, limit };
|
|
357
|
-
const data = await this._fetchGet(`/${marker}/recently-viewed?` +
|
|
358
|
-
|
|
377
|
+
const data = await this._fetchGet(`/${this._pathSegment(marker)}/recently-viewed?` +
|
|
378
|
+
this._queryParamsToString(query));
|
|
379
|
+
return this._normalizeData(data, langCode);
|
|
359
380
|
}
|
|
360
381
|
/**
|
|
361
382
|
* Get products for repeat purchase.
|
|
@@ -371,8 +392,9 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
371
392
|
*/
|
|
372
393
|
async getRepeatPurchase(marker, langCode = this.state.lang, signPrice, limit) {
|
|
373
394
|
const query = { langCode, signPrice, limit };
|
|
374
|
-
const data = await this._fetchGet(`/${marker}/repeat-purchase?` +
|
|
375
|
-
|
|
395
|
+
const data = await this._fetchGet(`/${this._pathSegment(marker)}/repeat-purchase?` +
|
|
396
|
+
this._queryParamsToString(query));
|
|
397
|
+
return this._normalizeData(data, langCode);
|
|
376
398
|
}
|
|
377
399
|
/**
|
|
378
400
|
* Get the block's slides tree as a flat pre-order array (slider_block only).
|
|
@@ -383,7 +405,7 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
383
405
|
* @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getSlides getSlides} documentation.
|
|
384
406
|
*/
|
|
385
407
|
async getSlides(marker) {
|
|
386
|
-
const data = await this._fetchGet(`/${marker}/slides`);
|
|
408
|
+
const data = await this._fetchGet(`/${this._pathSegment(marker)}/slides`);
|
|
387
409
|
return this._normalizeData(data);
|
|
388
410
|
}
|
|
389
411
|
/**
|
|
@@ -400,8 +422,9 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
400
422
|
*/
|
|
401
423
|
async getTrending(marker, langCode = this.state.lang, signPrice, limit) {
|
|
402
424
|
const query = { langCode, signPrice, limit };
|
|
403
|
-
const data = await this._fetchGet(`/${marker}/trending?` +
|
|
404
|
-
|
|
425
|
+
const data = await this._fetchGet(`/${this._pathSegment(marker)}/trending?` +
|
|
426
|
+
this._queryParamsToString(query));
|
|
427
|
+
return this._normalizeData(data, langCode);
|
|
405
428
|
}
|
|
406
429
|
/**
|
|
407
430
|
* Get "similar to wishlist" products by the wishlist from context (auth user or guest).
|
|
@@ -417,8 +440,9 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
417
440
|
*/
|
|
418
441
|
async getWishlistSimilar(marker, langCode = this.state.lang, signPrice, limit) {
|
|
419
442
|
const query = { langCode, signPrice, limit };
|
|
420
|
-
const data = await this._fetchGet(`/${marker}/wishlist-similar?` +
|
|
421
|
-
|
|
443
|
+
const data = await this._fetchGet(`/${this._pathSegment(marker)}/wishlist-similar?` +
|
|
444
|
+
this._queryParamsToString(query));
|
|
445
|
+
return this._normalizeData(data, langCode);
|
|
422
446
|
}
|
|
423
447
|
/**
|
|
424
448
|
* Get "similar to wishlist" products by an explicit list of productIds (POST body).
|
|
@@ -435,8 +459,11 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
435
459
|
* @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getWishlistSimilarByProductIds getWishlistSimilarByProductIds} documentation.
|
|
436
460
|
*/
|
|
437
461
|
async getWishlistSimilarByProductIds(marker, body) {
|
|
438
|
-
|
|
439
|
-
|
|
462
|
+
var _a;
|
|
463
|
+
// An explicit `langCode: undefined` in the body used to override the default
|
|
464
|
+
const langCode = (_a = body.langCode) !== null && _a !== void 0 ? _a : this.state.lang;
|
|
465
|
+
const data = await this._fetchPost(`/${this._pathSegment(marker)}/wishlist-similar`, { ...body, langCode });
|
|
466
|
+
return this._normalizeData(data, langCode);
|
|
440
467
|
}
|
|
441
468
|
}
|
|
442
469
|
exports.default = BlocksApi;
|
|
@@ -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';
|
|
|
3
3
|
import type { IError, IVectorSearchResponse } from '../base/utils';
|
|
4
4
|
import type { IBonusBalanceEntity, IBonusHistoryResponse, IBonusTransactionType, ICouponValidationResult, IDiscountsApi, IDiscountsEntity, IDiscountsResponse, IDiscountsVectorSearch, IDiscountType } from './discountsInterfaces';
|
|
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
|
|
@@ -5,12 +5,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const asyncModules_1 = __importDefault(require("../base/asyncModules"));
|
|
7
7
|
/**
|
|
8
|
-
* Controllers for working with
|
|
9
|
-
* @handle /api/content/
|
|
8
|
+
* Controllers for working with discounts, coupons and the bonus balance
|
|
9
|
+
* @handle /api/content/discounts
|
|
10
10
|
* @class DiscountsApi
|
|
11
11
|
* @augments AsyncModules
|
|
12
12
|
* @implements {IDiscountsApi}
|
|
13
|
-
* @description This class provides methods
|
|
13
|
+
* @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.
|
|
14
14
|
*/
|
|
15
15
|
class DiscountsApi extends asyncModules_1.default {
|
|
16
16
|
/**
|
|
@@ -45,12 +45,12 @@ class DiscountsApi extends asyncModules_1.default {
|
|
|
45
45
|
type,
|
|
46
46
|
};
|
|
47
47
|
const data = await this._fetchGet(`?` + this._queryParamsToString(query));
|
|
48
|
-
return this._normalizeData(data);
|
|
48
|
+
return this._normalizeData(data, langCode);
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
51
|
* Get discount by marker
|
|
52
52
|
* @handleName getDiscountByMarker
|
|
53
|
-
* @param {string} marker - Marker of the discount
|
|
53
|
+
* @param {string} marker - Marker of the discount. Example: "example_discount".
|
|
54
54
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
55
55
|
* @returns {Promise<IDiscountsEntity | IError>} Returns an object containing discount by marker or an error object if there was an issue.
|
|
56
56
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
@@ -58,12 +58,11 @@ class DiscountsApi extends asyncModules_1.default {
|
|
|
58
58
|
* @see {@link https://js-sdk.oneentry.cloud/docs/discounts/getDiscountByMarker getDiscountByMarker} documentation.
|
|
59
59
|
*/
|
|
60
60
|
async getDiscountByMarker(marker, langCode = this.state.lang) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return this._normalizeData(data);
|
|
61
|
+
// The marker goes in the path; an empty `marker=` used to be sent along
|
|
62
|
+
const query = { langCode };
|
|
63
|
+
const data = await this._fetchGet(`/marker/${this._pathSegment(marker)}?` +
|
|
64
|
+
this._queryParamsToString(query));
|
|
65
|
+
return this._normalizeData(data, langCode);
|
|
67
66
|
}
|
|
68
67
|
/**
|
|
69
68
|
* Get bonus balance of the current user.
|
|
@@ -80,16 +79,19 @@ class DiscountsApi extends asyncModules_1.default {
|
|
|
80
79
|
* Get bonus transaction history of the current user.
|
|
81
80
|
* @handleName getBonusHistory
|
|
82
81
|
* @param {IBonusTransactionType} [type] - Transaction type to filter by.
|
|
83
|
-
* @param {string} [dateFrom] - Start of the date range.
|
|
84
|
-
* @param {string} [dateTo] - End of the date range.
|
|
82
|
+
* @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`.
|
|
83
|
+
* @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`.
|
|
85
84
|
* @param {number} [discountId] - Return only transactions of this discount ID.
|
|
86
85
|
* @param {number} [moduleId] - Filter by module ID.
|
|
87
86
|
* @param {boolean} [isAdmin] - Filter by the transaction's `isAdmin` flag.
|
|
87
|
+
* @param {number} [offset] - Number of transactions to skip, `0` or more. Default: 0.
|
|
88
|
+
* @param {number} [limit] - Maximum number of transactions to return, `1` or more. Default: 30.
|
|
88
89
|
* @returns {Promise<IBonusHistoryResponse | IError>} Returns the container with the transactions and their total, or an error object.
|
|
89
90
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
90
91
|
* @see {@link https://js-sdk.oneentry.cloud/docs/discounts/getBonusHistory getBonusHistory} documentation.
|
|
91
92
|
*/
|
|
92
|
-
async getBonusHistory(type, dateFrom, dateTo, discountId, moduleId, isAdmin) {
|
|
93
|
+
async getBonusHistory(type, dateFrom, dateTo, discountId, moduleId, isAdmin, offset, limit) {
|
|
94
|
+
// The endpoint pages its answer; offset/limit were not reachable from the SDK
|
|
93
95
|
const query = {
|
|
94
96
|
type,
|
|
95
97
|
dateFrom,
|
|
@@ -97,6 +99,8 @@ class DiscountsApi extends asyncModules_1.default {
|
|
|
97
99
|
discountId,
|
|
98
100
|
moduleId,
|
|
99
101
|
isAdmin,
|
|
102
|
+
offset,
|
|
103
|
+
limit,
|
|
100
104
|
};
|
|
101
105
|
const data = await this._fetchGet(`/bonus-balance/history?` + this._queryParamsToString(query));
|
|
102
106
|
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
|