oneentry 1.0.176 → 1.0.178
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 +116 -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 +90 -23
- 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 +62 -1
- package/dist/base/asyncModules.js +219 -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 +82 -64
- package/dist/blocks/blocksInterfaces.d.ts +8 -8
- package/dist/discounts/discountsApi.d.ts +9 -7
- package/dist/discounts/discountsApi.js +16 -13
- package/dist/discounts/discountsInterfaces.d.ts +14 -10
- package/dist/events/eventsApi.d.ts +3 -3
- package/dist/events/eventsApi.js +3 -3
- 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 +27 -1
- package/dist/forms-data/formsDataApi.js +119 -68
- package/dist/forms-data/formsDataInterfaces.d.ts +17 -13
- 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 +41 -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 +21 -42
- package/dist/orders/ordersInterfaces.d.ts +21 -14
- package/dist/pages/pagesApi.d.ts +8 -6
- package/dist/pages/pagesApi.js +48 -33
- package/dist/pages/pagesInterfaces.d.ts +20 -16
- 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 +3 -3
- package/dist/product-statuses/productStatusesInterfaces.d.ts +1 -4
- package/dist/products/productsApi.d.ts +50 -64
- package/dist/products/productsApi.js +79 -80
- package/dist/products/productsInterfaces.d.ts +59 -90
- package/dist/search/searchApi.d.ts +3 -2
- package/dist/search/searchApi.js +7 -4
- package/dist/search/searchInterfaces.d.ts +2 -1
- 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 +90 -23
- 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 +62 -1
- package/esm/base/asyncModules.js +219 -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 +82 -64
- package/esm/blocks/blocksInterfaces.d.ts +8 -8
- package/esm/discounts/discountsApi.d.ts +9 -7
- package/esm/discounts/discountsApi.js +16 -13
- package/esm/discounts/discountsInterfaces.d.ts +14 -10
- package/esm/events/eventsApi.d.ts +3 -3
- package/esm/events/eventsApi.js +3 -3
- 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 +27 -1
- package/esm/forms-data/formsDataApi.js +119 -68
- package/esm/forms-data/formsDataInterfaces.d.ts +17 -13
- 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 +41 -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 +21 -42
- package/esm/orders/ordersInterfaces.d.ts +21 -14
- package/esm/pages/pagesApi.d.ts +8 -6
- package/esm/pages/pagesApi.js +48 -33
- package/esm/pages/pagesInterfaces.d.ts +20 -16
- 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 +3 -3
- package/esm/product-statuses/productStatusesInterfaces.d.ts +1 -4
- package/esm/products/productsApi.d.ts +50 -64
- package/esm/products/productsApi.js +79 -80
- package/esm/products/productsInterfaces.d.ts +59 -90
- package/esm/search/searchApi.d.ts +3 -2
- package/esm/search/searchApi.js +7 -4
- package/esm/search/searchInterfaces.d.ts +2 -1
- 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/${this._pathSegment(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 = {
|
|
@@ -186,7 +196,7 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
186
196
|
};
|
|
187
197
|
const result = await this._fetchGet(`/${this._pathSegment(marker)}/similar-products?` +
|
|
188
198
|
this._queryParamsToString(query));
|
|
189
|
-
return this._normalizeData(result);
|
|
199
|
+
return this._normalizeData(result, langCode);
|
|
190
200
|
}
|
|
191
201
|
/**
|
|
192
202
|
* Get products by block marker.
|
|
@@ -199,7 +209,6 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
199
209
|
* @see {@link https://js-sdk.oneentry.cloud/docs/blocks/#Fixing-the-price-signPrice Fixing the price} documentation.
|
|
200
210
|
* @returns {Promise<IProductsEntity[] | IError>} Return array of BlocksEntity object.
|
|
201
211
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
202
|
-
* @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getProductsByBlockMarker getProductsByBlockMarker} documentation.
|
|
203
212
|
*/
|
|
204
213
|
async getProductsByBlockMarker(marker, langCode = this.state.lang, offset = 0, limit = 30, signPrice) {
|
|
205
214
|
const query = {
|
|
@@ -213,9 +222,9 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
213
222
|
// On API error responses there is no `items` array — return the (normalized)
|
|
214
223
|
// error as-is instead of producing `undefined` from `result.items`.
|
|
215
224
|
if (!Array.isArray(result === null || result === void 0 ? void 0 : result.items)) {
|
|
216
|
-
return this._normalizeData(result);
|
|
225
|
+
return this._normalizeData(result, langCode);
|
|
217
226
|
}
|
|
218
|
-
return this._normalizeData(result.items);
|
|
227
|
+
return this._normalizeData(result.items, langCode);
|
|
219
228
|
}
|
|
220
229
|
/**
|
|
221
230
|
* Get frequently ordered products by block marker and product id.
|
|
@@ -236,9 +245,9 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
236
245
|
signPrice,
|
|
237
246
|
limit,
|
|
238
247
|
};
|
|
239
|
-
const data = await this._fetchGet(`/${this._pathSegment(marker)}/products/${productId}/frequently-ordered?` +
|
|
248
|
+
const data = await this._fetchGet(`/${this._pathSegment(marker)}/products/${this._pathSegment(String(productId))}/frequently-ordered?` +
|
|
240
249
|
this._queryParamsToString(query));
|
|
241
|
-
return this._normalizeData(data);
|
|
250
|
+
return this._normalizeData(data, langCode);
|
|
242
251
|
}
|
|
243
252
|
/**
|
|
244
253
|
* Quick search for block objects with limited output.
|
|
@@ -271,7 +280,7 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
271
280
|
const query = { langCode, signPrice, limit };
|
|
272
281
|
const data = await this._fetchGet(`/${this._pathSegment(marker)}/cart-complement?` +
|
|
273
282
|
this._queryParamsToString(query));
|
|
274
|
-
return this._normalizeData(data);
|
|
283
|
+
return this._normalizeData(data, langCode);
|
|
275
284
|
}
|
|
276
285
|
/**
|
|
277
286
|
* Get "complete your cart" products by an explicit list of productIds (POST body).
|
|
@@ -288,8 +297,11 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
288
297
|
* @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getCartComplementByProductIds getCartComplementByProductIds} documentation.
|
|
289
298
|
*/
|
|
290
299
|
async getCartComplementByProductIds(marker, body) {
|
|
291
|
-
|
|
292
|
-
|
|
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);
|
|
293
305
|
}
|
|
294
306
|
/**
|
|
295
307
|
* Get "similar to cart" products by the cart from context (auth user or guest).
|
|
@@ -307,7 +319,7 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
307
319
|
const query = { langCode, signPrice, limit };
|
|
308
320
|
const data = await this._fetchGet(`/${this._pathSegment(marker)}/cart-similar?` +
|
|
309
321
|
this._queryParamsToString(query));
|
|
310
|
-
return this._normalizeData(data);
|
|
322
|
+
return this._normalizeData(data, langCode);
|
|
311
323
|
}
|
|
312
324
|
/**
|
|
313
325
|
* Get "similar to cart" products by an explicit list of productIds (POST body).
|
|
@@ -324,8 +336,11 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
324
336
|
* @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getCartSimilarByProductIds getCartSimilarByProductIds} documentation.
|
|
325
337
|
*/
|
|
326
338
|
async getCartSimilarByProductIds(marker, body) {
|
|
327
|
-
|
|
328
|
-
|
|
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);
|
|
329
344
|
}
|
|
330
345
|
/**
|
|
331
346
|
* Get personal recommendations for the user.
|
|
@@ -343,7 +358,7 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
343
358
|
const query = { langCode, signPrice, limit };
|
|
344
359
|
const data = await this._fetchGet(`/${this._pathSegment(marker)}/personal-recommendations?` +
|
|
345
360
|
this._queryParamsToString(query));
|
|
346
|
-
return this._normalizeData(data);
|
|
361
|
+
return this._normalizeData(data, langCode);
|
|
347
362
|
}
|
|
348
363
|
/**
|
|
349
364
|
* Get recently viewed products.
|
|
@@ -361,7 +376,7 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
361
376
|
const query = { langCode, signPrice, limit };
|
|
362
377
|
const data = await this._fetchGet(`/${this._pathSegment(marker)}/recently-viewed?` +
|
|
363
378
|
this._queryParamsToString(query));
|
|
364
|
-
return this._normalizeData(data);
|
|
379
|
+
return this._normalizeData(data, langCode);
|
|
365
380
|
}
|
|
366
381
|
/**
|
|
367
382
|
* Get products for repeat purchase.
|
|
@@ -379,7 +394,7 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
379
394
|
const query = { langCode, signPrice, limit };
|
|
380
395
|
const data = await this._fetchGet(`/${this._pathSegment(marker)}/repeat-purchase?` +
|
|
381
396
|
this._queryParamsToString(query));
|
|
382
|
-
return this._normalizeData(data);
|
|
397
|
+
return this._normalizeData(data, langCode);
|
|
383
398
|
}
|
|
384
399
|
/**
|
|
385
400
|
* Get the block's slides tree as a flat pre-order array (slider_block only).
|
|
@@ -409,7 +424,7 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
409
424
|
const query = { langCode, signPrice, limit };
|
|
410
425
|
const data = await this._fetchGet(`/${this._pathSegment(marker)}/trending?` +
|
|
411
426
|
this._queryParamsToString(query));
|
|
412
|
-
return this._normalizeData(data);
|
|
427
|
+
return this._normalizeData(data, langCode);
|
|
413
428
|
}
|
|
414
429
|
/**
|
|
415
430
|
* Get "similar to wishlist" products by the wishlist from context (auth user or guest).
|
|
@@ -427,7 +442,7 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
427
442
|
const query = { langCode, signPrice, limit };
|
|
428
443
|
const data = await this._fetchGet(`/${this._pathSegment(marker)}/wishlist-similar?` +
|
|
429
444
|
this._queryParamsToString(query));
|
|
430
|
-
return this._normalizeData(data);
|
|
445
|
+
return this._normalizeData(data, langCode);
|
|
431
446
|
}
|
|
432
447
|
/**
|
|
433
448
|
* Get "similar to wishlist" products by an explicit list of productIds (POST body).
|
|
@@ -444,8 +459,11 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
444
459
|
* @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getWishlistSimilarByProductIds getWishlistSimilarByProductIds} documentation.
|
|
445
460
|
*/
|
|
446
461
|
async getWishlistSimilarByProductIds(marker, body) {
|
|
447
|
-
|
|
448
|
-
|
|
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);
|
|
449
467
|
}
|
|
450
468
|
}
|
|
451
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,13 +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
|
-
langCode,
|
|
64
|
-
};
|
|
61
|
+
// The marker goes in the path; an empty `marker=` used to be sent along
|
|
62
|
+
const query = { langCode };
|
|
65
63
|
const data = await this._fetchGet(`/marker/${this._pathSegment(marker)}?` +
|
|
66
64
|
this._queryParamsToString(query));
|
|
67
|
-
return this._normalizeData(data);
|
|
65
|
+
return this._normalizeData(data, langCode);
|
|
68
66
|
}
|
|
69
67
|
/**
|
|
70
68
|
* Get bonus balance of the current user.
|
|
@@ -81,16 +79,19 @@ class DiscountsApi extends asyncModules_1.default {
|
|
|
81
79
|
* Get bonus transaction history of the current user.
|
|
82
80
|
* @handleName getBonusHistory
|
|
83
81
|
* @param {IBonusTransactionType} [type] - Transaction type to filter by.
|
|
84
|
-
* @param {string} [dateFrom] - Start of the date range.
|
|
85
|
-
* @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`.
|
|
86
84
|
* @param {number} [discountId] - Return only transactions of this discount ID.
|
|
87
85
|
* @param {number} [moduleId] - Filter by module ID.
|
|
88
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.
|
|
89
89
|
* @returns {Promise<IBonusHistoryResponse | IError>} Returns the container with the transactions and their total, or an error object.
|
|
90
90
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
91
91
|
* @see {@link https://js-sdk.oneentry.cloud/docs/discounts/getBonusHistory getBonusHistory} documentation.
|
|
92
92
|
*/
|
|
93
|
-
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
|
|
94
95
|
const query = {
|
|
95
96
|
type,
|
|
96
97
|
dateFrom,
|
|
@@ -98,6 +99,8 @@ class DiscountsApi extends asyncModules_1.default {
|
|
|
98
99
|
discountId,
|
|
99
100
|
moduleId,
|
|
100
101
|
isAdmin,
|
|
102
|
+
offset,
|
|
103
|
+
limit,
|
|
101
104
|
};
|
|
102
105
|
const data = await this._fetchGet(`/bonus-balance/history?` + this._queryParamsToString(query));
|
|
103
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
|
|
@@ -39,7 +39,7 @@ export default class EventsApi extends AsyncModules implements IEvents {
|
|
|
39
39
|
* @handleName subscribeByMarker
|
|
40
40
|
* @param {string} marker - Marker of the event. Example: "product_price_change".
|
|
41
41
|
* @param {number} productId - Product ID. Example: 12345.
|
|
42
|
-
* @param {string} [langCode] - Language code. Default:
|
|
42
|
+
* @param {string} [langCode] - Language code. Default: the client's language.
|
|
43
43
|
* @returns {Promise<boolean | IError>} Returns true if subscription was successful, or an error object if there was an issue.
|
|
44
44
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
45
45
|
* @description This method requires user authorization.
|
|
@@ -52,7 +52,7 @@ export default class EventsApi extends AsyncModules implements IEvents {
|
|
|
52
52
|
* @handleName unsubscribeByMarker
|
|
53
53
|
* @param {string} marker - Marker of the event to unsubscribe from. Example: "product_price_change".
|
|
54
54
|
* @param {number} productId - ID of the product to unsubscribe from. Example: 12345.
|
|
55
|
-
* @param {string} [langCode] - Language code. Default:
|
|
55
|
+
* @param {string} [langCode] - Language code. Default: the client's language.
|
|
56
56
|
* @returns {Promise<boolean | IError>} - Returns true if the unsubscription succeeded, or an error object if there was an issue.
|
|
57
57
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
58
58
|
* @description This method requires user authorization.
|
|
@@ -65,7 +65,7 @@ export default class EventsApi extends AsyncModules implements IEvents {
|
|
|
65
65
|
* @handleName getAllEvents
|
|
66
66
|
* @returns {Promise<IContentApiEvent[] | IError>} Returns an array of available events.
|
|
67
67
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
68
|
-
* @description This method returns all available events.
|
|
68
|
+
* @description This method returns all available events. This method requires user authorization — without it the API answers `401 Unauthorized`.
|
|
69
69
|
* @see {@link https://js-sdk.oneentry.cloud/docs/events/getAllEvents getAllEvents} documentation.
|
|
70
70
|
*/
|
|
71
71
|
getAllEvents(): Promise<IContentApiEvent[] | IError>;
|
package/dist/events/eventsApi.js
CHANGED
|
@@ -50,7 +50,7 @@ class EventsApi extends asyncModules_1.default {
|
|
|
50
50
|
* @handleName subscribeByMarker
|
|
51
51
|
* @param {string} marker - Marker of the event. Example: "product_price_change".
|
|
52
52
|
* @param {number} productId - Product ID. Example: 12345.
|
|
53
|
-
* @param {string} [langCode] - Language code. Default:
|
|
53
|
+
* @param {string} [langCode] - Language code. Default: the client's language.
|
|
54
54
|
* @returns {Promise<boolean | IError>} Returns true if subscription was successful, or an error object if there was an issue.
|
|
55
55
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
56
56
|
* @description This method requires user authorization.
|
|
@@ -69,7 +69,7 @@ class EventsApi extends asyncModules_1.default {
|
|
|
69
69
|
* @handleName unsubscribeByMarker
|
|
70
70
|
* @param {string} marker - Marker of the event to unsubscribe from. Example: "product_price_change".
|
|
71
71
|
* @param {number} productId - ID of the product to unsubscribe from. Example: 12345.
|
|
72
|
-
* @param {string} [langCode] - Language code. Default:
|
|
72
|
+
* @param {string} [langCode] - Language code. Default: the client's language.
|
|
73
73
|
* @returns {Promise<boolean | IError>} - Returns true if the unsubscription succeeded, or an error object if there was an issue.
|
|
74
74
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
75
75
|
* @description This method requires user authorization.
|
|
@@ -88,7 +88,7 @@ class EventsApi extends asyncModules_1.default {
|
|
|
88
88
|
* @handleName getAllEvents
|
|
89
89
|
* @returns {Promise<IContentApiEvent[] | IError>} Returns an array of available events.
|
|
90
90
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
91
|
-
* @description This method returns all available events.
|
|
91
|
+
* @description This method returns all available events. This method requires user authorization — without it the API answers `401 Unauthorized`.
|
|
92
92
|
* @see {@link https://js-sdk.oneentry.cloud/docs/events/getAllEvents getAllEvents} documentation.
|
|
93
93
|
*/
|
|
94
94
|
async getAllEvents() {
|