oneentry 1.0.123 → 1.0.125
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 +24 -22
- package/dist/admins/adminsApi.d.ts +30 -9
- package/dist/admins/adminsApi.js +30 -9
- package/dist/admins/adminsInterfaces.d.ts +77 -32
- package/dist/attribute-sets/attributeSetsApi.d.ts +36 -22
- package/dist/attribute-sets/attributeSetsApi.js +41 -25
- package/dist/attribute-sets/attributeSetsInterfaces.d.ts +133 -39
- package/dist/auth-provider/authProviderApi.d.ts +209 -88
- package/dist/auth-provider/authProviderApi.js +226 -87
- package/dist/auth-provider/authProvidersInterfaces.d.ts +345 -18
- package/dist/base/asyncModules.d.ts +38 -28
- package/dist/base/asyncModules.js +178 -47
- package/dist/base/result.js +23 -0
- package/dist/base/syncModules.d.ts +48 -44
- package/dist/base/syncModules.js +84 -64
- package/dist/base/utils.d.ts +1 -1
- package/dist/blocks/blocksApi.d.ts +48 -27
- package/dist/blocks/blocksApi.js +48 -27
- package/dist/blocks/blocksInterfaces.d.ts +126 -32
- package/dist/events/eventsApi.d.ts +45 -12
- package/dist/events/eventsApi.js +47 -12
- package/dist/events/eventsInterfaces.d.ts +50 -3
- package/dist/file-uploading/fileUploadingApi.d.ts +57 -29
- package/dist/file-uploading/fileUploadingApi.js +57 -30
- package/dist/file-uploading/fileUploadingInterfaces.d.ts +90 -17
- package/dist/forms/formsApi.d.ts +20 -9
- package/dist/forms/formsApi.js +19 -8
- package/dist/forms/formsInterfaces.d.ts +86 -23
- package/dist/formsData/formsDataApi.d.ts +33 -21
- package/dist/formsData/formsDataApi.js +33 -21
- package/dist/formsData/formsDataInterfaces.d.ts +212 -41
- package/dist/general-types/generalTypesApi.d.ts +11 -2
- package/dist/general-types/generalTypesApi.js +10 -1
- package/dist/general-types/generalTypesInterfaces.d.ts +17 -6
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/integration-collections/integrationCollectionsApi.d.ts +134 -81
- package/dist/integration-collections/integrationCollectionsApi.js +135 -83
- package/dist/integration-collections/integrationCollectionsInterfaces.d.ts +246 -43
- package/dist/locales/localesApi.d.ts +5 -1
- package/dist/locales/localesApi.js +5 -1
- package/dist/locales/localesInterfaces.d.ts +19 -12
- package/dist/menus/menusApi.d.ts +6 -3
- package/dist/menus/menusApi.js +6 -3
- package/dist/menus/menusInterfaces.d.ts +60 -21
- package/dist/orders/ordersApi.d.ts +84 -66
- package/dist/orders/ordersApi.js +91 -71
- package/dist/orders/ordersInterfaces.d.ts +282 -86
- package/dist/pages/pagesApi.d.ts +101 -42
- package/dist/pages/pagesApi.js +93 -39
- package/dist/pages/pagesInterfaces.d.ts +218 -75
- package/dist/payments/paymentsApi.d.ts +53 -39
- package/dist/payments/paymentsApi.js +55 -40
- package/dist/payments/paymentsInterfaces.d.ts +121 -56
- package/dist/product-statuses/productStatusesApi.d.ts +17 -17
- package/dist/product-statuses/productStatusesApi.js +16 -19
- package/dist/product-statuses/productStatusesInterfaces.d.ts +43 -14
- package/dist/products/productsApi.d.ts +309 -177
- package/dist/products/productsApi.js +313 -167
- package/dist/products/productsInterfaces.d.ts +447 -81
- package/dist/system/systemApi.d.ts +42 -12
- package/dist/system/systemApi.js +43 -10
- package/dist/system/systemInterfaces.d.ts +7 -0
- package/dist/templates/templatesApi.d.ts +24 -20
- package/dist/templates/templatesApi.js +22 -21
- package/dist/templates/templatesInterfaces.d.ts +48 -22
- package/dist/templates-preview/templatesPreviewApi.d.ts +17 -17
- package/dist/templates-preview/templatesPreviewApi.js +16 -19
- package/dist/templates-preview/templatesPreviewInterfaces.d.ts +85 -32
- package/dist/users/usersApi.d.ts +59 -35
- package/dist/users/usersApi.js +62 -35
- package/dist/users/usersInterfaces.d.ts +136 -14
- package/dist/web-socket/wsApi.d.ts +4 -5
- package/dist/web-socket/wsApi.js +4 -5
- package/dist/web-socket/wsInterfaces.d.ts +2 -1
- package/package.json +20 -18
package/dist/blocks/blocksApi.js
CHANGED
|
@@ -5,8 +5,14 @@ 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 blocks
|
|
8
|
+
* Controllers for working with blocks.
|
|
9
|
+
*
|
|
9
10
|
* @handle /api/content/blocks
|
|
11
|
+
* @class BlocksApi
|
|
12
|
+
* @extends AsyncModules
|
|
13
|
+
* @implements {IBlocks}
|
|
14
|
+
*
|
|
15
|
+
* @description This class provides methods to interact with blocks.
|
|
10
16
|
*/
|
|
11
17
|
class BlocksApi extends asyncModules_1.default {
|
|
12
18
|
constructor(state) {
|
|
@@ -16,15 +22,18 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
16
22
|
/**
|
|
17
23
|
* Get blocks by parameters.
|
|
18
24
|
*
|
|
19
|
-
* @
|
|
20
|
-
* @param {string} [langCode] - Language code. Default "en_US"
|
|
21
|
-
* @param {number} [offset] - Parameter for pagination. Default 0
|
|
22
|
-
* @param {number} [limit] - Parameter for pagination. Default 30
|
|
25
|
+
* @handleName getBlocks
|
|
23
26
|
*
|
|
24
|
-
* @
|
|
27
|
+
* @param {BlockType} type - Available values: "product" | "error_page" | "catalog_page" | "product_preview" | "similar_products_block" | "product_block" | "form" | "common_page" | "common_block" | "order" | "service" | "none". Example: 'product'.
|
|
28
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
29
|
+
* @param {number} [offset] - Parameter for pagination. Default: 0.
|
|
30
|
+
* @param {number} [limit] - Parameter for pagination. Default: 30.
|
|
31
|
+
* @return {IBlocksResponse} Returns BlocksEntity object.
|
|
32
|
+
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
33
|
+
* @description This method requires user authorization. For more information about configuring the authorization module, see the documentation in the configuration settings section of the SDK.
|
|
25
34
|
*/
|
|
26
|
-
async getBlocks(type, langCode = this.state.lang, offset = 0, limit = 30) {
|
|
27
|
-
const response = await this.
|
|
35
|
+
async getBlocks(type = '', langCode = this.state.lang, offset = 0, limit = 30) {
|
|
36
|
+
const response = await this._fetchPost(`?langCode=${langCode}&type=${type}&offset=${offset}&limit=${limit}`);
|
|
28
37
|
if (!this.state.traficLimit) {
|
|
29
38
|
const normalizeResponse = this._normalizeData(response);
|
|
30
39
|
await Promise.all(
|
|
@@ -71,12 +80,15 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
71
80
|
/**
|
|
72
81
|
* Get block by marker.
|
|
73
82
|
*
|
|
74
|
-
* @
|
|
75
|
-
* @param {string} [langCode] - Language code. Default "en_US"
|
|
76
|
-
* @param {number} [offset] - Parameter for pagination. Default 0
|
|
77
|
-
* @param {number} [limit] - Parameter for pagination. Default 30
|
|
83
|
+
* @handleName getBlockByMarker
|
|
78
84
|
*
|
|
79
|
-
* @
|
|
85
|
+
* @param {string} marker - Marker of Block. Example: "product_block".
|
|
86
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
87
|
+
* @param {number} [offset] - Parameter for pagination. Default: 0.
|
|
88
|
+
* @param {number} [limit] - Parameter for pagination. Default: 30.
|
|
89
|
+
* @return {IBlockEntity} - Returns a BlockEntity object.
|
|
90
|
+
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
91
|
+
* @description This method retrieves a block by its marker and includes additional information such as similar products or products associated with the block.
|
|
80
92
|
*/
|
|
81
93
|
async getBlockByMarker(marker, langCode = this.state.lang, offset = 0, limit = 30) {
|
|
82
94
|
const response = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
|
|
@@ -120,12 +132,15 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
120
132
|
/**
|
|
121
133
|
* Get similar products by block marker.
|
|
122
134
|
*
|
|
123
|
-
* @
|
|
124
|
-
* @param {string} [langCode] - Language code. Default "en_US"
|
|
125
|
-
* @param {number} [offset] - Parameter for pagination. Default 0
|
|
126
|
-
* @param {number} [limit] - Parameter for pagination. Default 30
|
|
135
|
+
* @handleName getSimilarProducts
|
|
127
136
|
*
|
|
128
|
-
* @
|
|
137
|
+
* @param {string} marker - Block identifier. Example: "similar_products_block".
|
|
138
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
139
|
+
* @param {number} [offset] - Parameter for pagination. Default: 0.
|
|
140
|
+
* @param {number} [limit] - Parameter for pagination. Default: 30.
|
|
141
|
+
* @return {IProductsResponse} - Returns the total count and an array of product items in object by specified block marker.
|
|
142
|
+
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
143
|
+
* @description This method requires user authorization. For more information about configuring the authorization module, see the documentation in the configuration settings section of the SDK.
|
|
129
144
|
*/
|
|
130
145
|
async getSimilarProducts(marker, langCode = this.state.lang, offset = 0, limit = 30) {
|
|
131
146
|
const query = {
|
|
@@ -139,12 +154,15 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
139
154
|
/**
|
|
140
155
|
* Get products by block marker.
|
|
141
156
|
*
|
|
142
|
-
* @
|
|
143
|
-
* @param {string} [langCode] - Language code. Default "en_US"
|
|
144
|
-
* @param {number} [offset] - Parameter for pagination. Default 0
|
|
145
|
-
* @param {number} [limit] - Parameter for pagination. Default 30
|
|
157
|
+
* @handleName getProductsByBlockMarker
|
|
146
158
|
*
|
|
147
|
-
* @
|
|
159
|
+
* @param {string} marker - Block identifier. Example: "product_block".
|
|
160
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
161
|
+
* @param {number} [offset] - Parameter for pagination. Default: 0.
|
|
162
|
+
* @param {number} [limit] - Parameter for pagination. Default: 30.
|
|
163
|
+
* @return {IProductsEntity[]} Return array of BlocksEntity object.
|
|
164
|
+
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
165
|
+
* @description This method requires user authorization. For more information about configuring the authorization module, see the documentation in the configuration settings section of the SDK.
|
|
148
166
|
*/
|
|
149
167
|
async getProductsByBlockMarker(marker, langCode = this.state.lang, offset = 0, limit = 30) {
|
|
150
168
|
const query = {
|
|
@@ -156,12 +174,15 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
156
174
|
return this._normalizeData(result.items);
|
|
157
175
|
}
|
|
158
176
|
/**
|
|
159
|
-
* Quick search for block objects with limited output
|
|
177
|
+
* Quick search for block objects with limited output.
|
|
160
178
|
*
|
|
161
|
-
* @
|
|
162
|
-
* @param {string} [langCode] - Language code. Default "en_US"
|
|
179
|
+
* @handleName searchBlock
|
|
163
180
|
*
|
|
164
|
-
* @
|
|
181
|
+
* @param {string} name - Search string. Example: "product_block".
|
|
182
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
183
|
+
* @return {ISearchBlock[]} Returns an array of ISearchBlock objects.
|
|
184
|
+
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
185
|
+
* @description This method requires user authorization. For more information about configuring the authorization module, see the documentation in the configuration settings section of the SDK.
|
|
165
186
|
*/
|
|
166
187
|
async searchBlock(name, langCode = this.state.lang) {
|
|
167
188
|
const result = await this._fetchGet(`/quick/search?langCode=${langCode}&name=${name}`);
|
|
@@ -1,75 +1,169 @@
|
|
|
1
1
|
import type { AttributeType, IError, ILocalizeInfo } from '../base/utils';
|
|
2
2
|
import type { IProductsEntity, IProductsResponse } from '../products/productsInterfaces';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Interface for managing and retrieving blocks in the system.
|
|
5
|
+
*
|
|
6
|
+
* @interface IBlocks
|
|
5
7
|
*
|
|
6
8
|
* @property {function} getBlocks - Get all Blocks objects.
|
|
7
9
|
* @property {function} getBlockByMarker - Get Block object by marker.
|
|
8
10
|
* @property {function} getSimilarProducts - Get Array of similar products from product-similar block.
|
|
9
11
|
* @property {function} getProductsByBlockMarker - Get Array of products from product block.
|
|
10
12
|
* @property {function} searchBlock - Quick search for block objects with limited output.
|
|
13
|
+
* @description This interface defines methods for retrieving and managing blocks in the system.
|
|
11
14
|
*/
|
|
12
15
|
interface IBlocks {
|
|
16
|
+
/**
|
|
17
|
+
* Retrieves all block objects of a specific type.
|
|
18
|
+
*
|
|
19
|
+
* @param {BlockType} type - The type of blocks to retrieve. Example: "product".
|
|
20
|
+
* @param {string} [langCode] - Optional language code for localization. Default: "en_US".
|
|
21
|
+
* @param {number} [offset] - Optional offset for pagination. Default: 0.
|
|
22
|
+
* @param {number} [limit] - Optional limit for pagination. Default: 30.
|
|
23
|
+
* @return {IBlocksResponse} A promise that resolves to a blocks response or an error.
|
|
24
|
+
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
25
|
+
*/
|
|
13
26
|
getBlocks(type: BlockType, langCode?: string, offset?: number, limit?: number): Promise<IBlocksResponse | IError>;
|
|
27
|
+
/**
|
|
28
|
+
* Retrieves a block object by its marker.
|
|
29
|
+
*
|
|
30
|
+
* @param {string} marker - The marker identifying the block. Example: "product_block".
|
|
31
|
+
* @param {string} langCode - Language code for localization. Default: "en_US".
|
|
32
|
+
* @param {number} [offset] - Optional offset for pagination. Default: 0.
|
|
33
|
+
* @param {number} [limit] - Optional limit for pagination. Default: 30.
|
|
34
|
+
* @return {IBlockEntity} A promise that resolves to a block entity or an error.
|
|
35
|
+
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
36
|
+
*/
|
|
14
37
|
getBlockByMarker(marker: string, langCode: string, offset?: number, limit?: number): Promise<IBlockEntity | IError>;
|
|
15
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Performs a quick search for block objects with limited output.
|
|
40
|
+
*
|
|
41
|
+
* @param {string} name - The name to search for. Example: "product_block".
|
|
42
|
+
* @param {string} [langCode] - Optional language code for localization. Default: "en_US".
|
|
43
|
+
* @return {ISearchBlock[]} A promise that resolves to an array of search blocks or an error.
|
|
44
|
+
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
45
|
+
*/
|
|
46
|
+
searchBlock(name: string, langCode?: string): Promise<ISearchBlock[] | IError>;
|
|
16
47
|
}
|
|
17
48
|
/**
|
|
18
|
-
*
|
|
49
|
+
* Represents a response from the blocks API.
|
|
50
|
+
*
|
|
51
|
+
* @interface IBlocksResponse
|
|
19
52
|
*
|
|
20
|
-
* @property {number} total -
|
|
21
|
-
* @property {
|
|
53
|
+
* @property {number} total - Total number of found records. Example: 100.
|
|
54
|
+
* @property {IBlockEntity[]} items - Array of block entities. Example:
|
|
55
|
+
[
|
|
56
|
+
{
|
|
57
|
+
"attributeValues": [],
|
|
58
|
+
"id": 1,
|
|
59
|
+
"identifier": "block1",
|
|
60
|
+
"isVisible": true,
|
|
61
|
+
"localizeInfos": { "key": "value" },
|
|
62
|
+
"position": 1,
|
|
63
|
+
"templateIdentifier": null,
|
|
64
|
+
"type": "product",
|
|
65
|
+
"version": 1,
|
|
66
|
+
"countElementsPerRow": 3,
|
|
67
|
+
"quantity": 9,
|
|
68
|
+
"similarProducts": {
|
|
69
|
+
"total": 0,
|
|
70
|
+
"items": []
|
|
71
|
+
},
|
|
72
|
+
"products": [
|
|
73
|
+
{
|
|
74
|
+
"id": 1,
|
|
75
|
+
"name": "Product 1"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"id": 2,
|
|
79
|
+
"name": "Product 2"
|
|
80
|
+
}
|
|
81
|
+
]
|
|
82
|
+
}
|
|
83
|
+
]
|
|
84
|
+
* @description Represents a response from the blocks API containing a total count and an array of block entities.
|
|
22
85
|
*/
|
|
23
86
|
interface IBlocksResponse {
|
|
87
|
+
items: IBlockEntity[];
|
|
24
88
|
total: number;
|
|
25
|
-
items: Array<IBlockEntity>;
|
|
26
89
|
}
|
|
27
90
|
/**
|
|
28
|
-
*
|
|
91
|
+
* Represents a block entity with various attributes and properties.
|
|
92
|
+
*
|
|
93
|
+
* @interface IBlockEntity
|
|
29
94
|
*
|
|
30
|
-
* @property {AttributeType} attributeValues -
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
* @property {
|
|
42
|
-
* @property {
|
|
95
|
+
* @property {AttributeType} attributeValues - Type of attributes used in the block. Example:
|
|
96
|
+
{
|
|
97
|
+
"block-text": {
|
|
98
|
+
"type": "string",
|
|
99
|
+
"value": "some text",
|
|
100
|
+
"isIcon": false,
|
|
101
|
+
"position": 0,
|
|
102
|
+
"additionalFields": [],
|
|
103
|
+
"isProductPreview": false
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
* @property {number} id - Unique identifier of the block. Example: 1234.
|
|
107
|
+
* @property {ILocalizeInfo} localizeInfos - Localization information for the block. Example: {"key": "value"}
|
|
108
|
+
* @property {number} version - Version of the block entity. Example: 1.
|
|
109
|
+
* @property {string} identifier - Unique string identifier for the block. Example: "block1".
|
|
110
|
+
* @property {string} type - Type of the block, such as 'product', 'error_page', etc. Example: "product".
|
|
111
|
+
* @property {string | null} templateIdentifier - Identifier for the template used by the block, or null if not applicable. Example: "template1".
|
|
112
|
+
* @property {boolean} isVisible - Indicates whether the block is visible. Example: true.
|
|
113
|
+
* @property {number} [countElementsPerRow] - Number of elements displayed per row in the block, if applicable. Example: 3.
|
|
114
|
+
* @property {number} [quantity] - Quantity of items in the block, if applicable. Example: 5.
|
|
115
|
+
* @property {IProductsResponse} [similarProducts] - Response containing similar products associated with the block. Example:
|
|
116
|
+
{
|
|
117
|
+
"total": 10,
|
|
118
|
+
"items": []
|
|
119
|
+
}
|
|
120
|
+
* @property {IProductsEntity[]} [products] - Array of product entities associated with the block. Example:
|
|
121
|
+
[
|
|
122
|
+
{
|
|
123
|
+
"id": 1,
|
|
124
|
+
"name": "Product 1"
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"id": 2,
|
|
128
|
+
"name": "Product 2"
|
|
129
|
+
}
|
|
130
|
+
]
|
|
131
|
+
* @description Represents a block entity with various attributes and properties.
|
|
43
132
|
*/
|
|
44
133
|
interface IBlockEntity {
|
|
45
|
-
attributeValues: AttributeType;
|
|
46
134
|
id: number;
|
|
47
|
-
identifier: string;
|
|
48
|
-
isVisible: boolean;
|
|
49
135
|
localizeInfos: ILocalizeInfo;
|
|
136
|
+
version: number;
|
|
50
137
|
position: number;
|
|
51
|
-
|
|
138
|
+
identifier: string;
|
|
52
139
|
type: string;
|
|
53
|
-
|
|
140
|
+
templateIdentifier: string | null;
|
|
141
|
+
isVisible: boolean;
|
|
142
|
+
attributeValues: AttributeType;
|
|
143
|
+
similarProducts?: IProductsResponse;
|
|
54
144
|
countElementsPerRow?: number;
|
|
55
145
|
quantity?: number;
|
|
56
|
-
|
|
57
|
-
products?: Array<IProductsEntity>;
|
|
146
|
+
products?: IProductsEntity[];
|
|
58
147
|
}
|
|
59
148
|
/**
|
|
60
|
-
*
|
|
149
|
+
* Represents a search block entity with an identifier, name, and ID.
|
|
150
|
+
*
|
|
151
|
+
* @interface ISearchBlock
|
|
61
152
|
*
|
|
62
|
-
* @property {number} id -
|
|
63
|
-
* @property {string}
|
|
64
|
-
* @property {string}
|
|
153
|
+
* @property {number} id - Unique identifier of the search block. Example: 1.
|
|
154
|
+
* @property {string} identifier - Unique string identifier for the search block. Example: "search_block_1".
|
|
155
|
+
* @property {string} name - Name of the search block. Example: "Search Block 1".
|
|
156
|
+
* @description Represents a search block entity with an identifier, name, and ID.
|
|
65
157
|
*/
|
|
66
158
|
interface ISearchBlock {
|
|
67
159
|
id: number;
|
|
68
|
-
name: string;
|
|
69
160
|
identifier: string;
|
|
161
|
+
name: string;
|
|
70
162
|
}
|
|
71
163
|
/**
|
|
72
164
|
* BlockType
|
|
165
|
+
* @type {BlockType}
|
|
166
|
+
* @description This type defines the possible values for block types used in the system.
|
|
73
167
|
*/
|
|
74
168
|
type BlockType = 'product' | 'error_page' | 'catalog_page' | 'product_preview' | 'similar_products_block' | 'product_block' | 'form' | 'common_page' | 'common_block' | 'order' | 'service' | 'none';
|
|
75
169
|
export type { BlockType, IBlockEntity, IBlocks, IBlocksResponse, ISearchBlock };
|
|
@@ -1,41 +1,74 @@
|
|
|
1
1
|
import AsyncModules from '../base/asyncModules';
|
|
2
2
|
import type StateModule from '../base/stateModule';
|
|
3
3
|
import type { IError } from '../base/utils';
|
|
4
|
-
import type { IEvents } from './eventsInterfaces';
|
|
5
|
-
import type { ISubscriptions } from './eventsInterfaces';
|
|
4
|
+
import type { IEvents, ISubscriptions } from './eventsInterfaces';
|
|
6
5
|
/**
|
|
7
6
|
* Controllers for working with events
|
|
7
|
+
*
|
|
8
8
|
* @handle /api/content/events
|
|
9
|
+
* @class EventsApi
|
|
10
|
+
* @extends AsyncModules
|
|
11
|
+
* @implements {IEvents}
|
|
12
|
+
*
|
|
13
|
+
* @description This class provides methods to interact with events, including subscribing and unsubscribing to product events, and retrieving all subscriptions.
|
|
9
14
|
*/
|
|
10
15
|
export default class EventsApi extends AsyncModules implements IEvents {
|
|
11
16
|
protected state: StateModule;
|
|
12
17
|
protected _url: string;
|
|
18
|
+
/**
|
|
19
|
+
* Initializes the EventsApi with the provided state module.
|
|
20
|
+
*
|
|
21
|
+
* @constructor
|
|
22
|
+
* @class - EventsApi
|
|
23
|
+
* @extends - AsyncModules
|
|
24
|
+
* @implements {IEvents}
|
|
25
|
+
*
|
|
26
|
+
* @param {StateModule} state - The state module containing the base URL and other configurations.
|
|
27
|
+
*
|
|
28
|
+
* @description Initializes the EventsApi with the provided state module.
|
|
29
|
+
*/
|
|
13
30
|
constructor(state: StateModule);
|
|
14
31
|
/**
|
|
15
32
|
* Return all subscriptions to product.
|
|
16
33
|
*
|
|
17
|
-
* @
|
|
18
|
-
*
|
|
34
|
+
* @handleName getAllSubscriptions
|
|
35
|
+
*
|
|
36
|
+
* @param {number} [offset] - Optional offset for pagination. Default: 0.
|
|
37
|
+
* @param {number} [limit] - Optional limit for pagination. Default: 30.
|
|
38
|
+
* @return {ISubscriptions} Returns an object containing all subscriptions or an error object if there was an issue.
|
|
39
|
+
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
40
|
+
*
|
|
41
|
+
* @description This method requires user authorization. For more information about configuring the authorization module, see the documentation in the configuration settings section of the SDK.
|
|
19
42
|
*/
|
|
20
43
|
getAllSubscriptions(offset?: number, limit?: number): Promise<ISubscriptions | IError>;
|
|
21
44
|
/**
|
|
22
45
|
* Subscribing to an event on a product.
|
|
23
46
|
*
|
|
47
|
+
* @handleName subscribeByMarker
|
|
48
|
+
*
|
|
49
|
+
* @param {string} marker - Event marker. Example: "product_price_change".
|
|
50
|
+
* @param {string} productId - Product id. Example: 12345.
|
|
51
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
52
|
+
* @param {number} [threshold] - Threshold value for comparing numerical value. Default: 0.
|
|
53
|
+
*
|
|
54
|
+
* @return {any} Returns a promise that resolves to the result of the subscription operation or an error object if there was an issue.
|
|
55
|
+
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
56
|
+
*
|
|
24
57
|
* @description This method requires user authorization. For more information about configuring the authorization module, see the documentation in the configuration settings section of the SDK.
|
|
25
|
-
* @param {string} [marker] - Event marker.
|
|
26
|
-
* @param {string} [productId] - Product id.
|
|
27
|
-
* @param {string} [langCode] - Language code.
|
|
28
|
-
* @param {number} [threshold] - Threshold value for comparing numerical value.
|
|
29
58
|
*/
|
|
30
59
|
subscribeByMarker(marker: string, productId: number, langCode?: string, threshold?: number): Promise<any | IError>;
|
|
31
60
|
/**
|
|
32
61
|
* Unsubscribing to an event on a product.
|
|
33
62
|
*
|
|
63
|
+
* @handleName unsubscribeByMarker
|
|
64
|
+
*
|
|
65
|
+
* @param {string} marker - The marker of the event to unsubscribe from. Example: "product_price_change".
|
|
66
|
+
* @param {number} productId - The ID of the product to unsubscribe from. Example: 12345.
|
|
67
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
68
|
+
* @param {number} [threshold] - The threshold value for comparing numerical values. Default: 0.
|
|
69
|
+
* @return {any} - Returns a promise that resolves to the result of the unsubscription operation or an error object if there was an issue.
|
|
70
|
+
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
34
71
|
* @description This method requires user authorization. For more information about configuring the authorization module, see the documentation in the configuration settings section of the SDK.
|
|
35
|
-
* @param {string} [marker] - Event marker.
|
|
36
|
-
* @param {string} [productId] - Product id.
|
|
37
|
-
* @param {number} [langCode] - Language code.
|
|
38
|
-
* @param {number} [threshold] - Threshold value for comparing numerical value.
|
|
39
72
|
*/
|
|
40
73
|
unsubscribeByMarker(marker: string, productId: number, langCode?: string, threshold?: number): Promise<any | IError>;
|
|
41
74
|
}
|
package/dist/events/eventsApi.js
CHANGED
|
@@ -3,14 +3,31 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
7
6
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
8
7
|
const asyncModules_1 = __importDefault(require("../base/asyncModules"));
|
|
9
8
|
/**
|
|
10
9
|
* Controllers for working with events
|
|
10
|
+
*
|
|
11
11
|
* @handle /api/content/events
|
|
12
|
+
* @class EventsApi
|
|
13
|
+
* @extends AsyncModules
|
|
14
|
+
* @implements {IEvents}
|
|
15
|
+
*
|
|
16
|
+
* @description This class provides methods to interact with events, including subscribing and unsubscribing to product events, and retrieving all subscriptions.
|
|
12
17
|
*/
|
|
13
18
|
class EventsApi extends asyncModules_1.default {
|
|
19
|
+
/**
|
|
20
|
+
* Initializes the EventsApi with the provided state module.
|
|
21
|
+
*
|
|
22
|
+
* @constructor
|
|
23
|
+
* @class - EventsApi
|
|
24
|
+
* @extends - AsyncModules
|
|
25
|
+
* @implements {IEvents}
|
|
26
|
+
*
|
|
27
|
+
* @param {StateModule} state - The state module containing the base URL and other configurations.
|
|
28
|
+
*
|
|
29
|
+
* @description Initializes the EventsApi with the provided state module.
|
|
30
|
+
*/
|
|
14
31
|
constructor(state) {
|
|
15
32
|
super(state);
|
|
16
33
|
this._url = state.url + '/api/content/events';
|
|
@@ -18,27 +35,40 @@ class EventsApi extends asyncModules_1.default {
|
|
|
18
35
|
/**
|
|
19
36
|
* Return all subscriptions to product.
|
|
20
37
|
*
|
|
21
|
-
* @
|
|
22
|
-
*
|
|
38
|
+
* @handleName getAllSubscriptions
|
|
39
|
+
*
|
|
40
|
+
* @param {number} [offset] - Optional offset for pagination. Default: 0.
|
|
41
|
+
* @param {number} [limit] - Optional limit for pagination. Default: 30.
|
|
42
|
+
* @return {ISubscriptions} Returns an object containing all subscriptions or an error object if there was an issue.
|
|
43
|
+
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
44
|
+
*
|
|
45
|
+
* @description This method requires user authorization. For more information about configuring the authorization module, see the documentation in the configuration settings section of the SDK.
|
|
23
46
|
*/
|
|
24
47
|
async getAllSubscriptions(offset = 0, limit = 30) {
|
|
25
48
|
const query = {
|
|
26
49
|
offset,
|
|
27
50
|
limit,
|
|
28
51
|
};
|
|
29
|
-
const result = await this._fetchGet(`/subscriptions
|
|
52
|
+
const result = await this._fetchGet(`/subscriptions?` + this._queryParamsToString(query));
|
|
30
53
|
return result;
|
|
31
54
|
}
|
|
32
55
|
/**
|
|
33
56
|
* Subscribing to an event on a product.
|
|
34
57
|
*
|
|
58
|
+
* @handleName subscribeByMarker
|
|
59
|
+
*
|
|
60
|
+
* @param {string} marker - Event marker. Example: "product_price_change".
|
|
61
|
+
* @param {string} productId - Product id. Example: 12345.
|
|
62
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
63
|
+
* @param {number} [threshold] - Threshold value for comparing numerical value. Default: 0.
|
|
64
|
+
*
|
|
65
|
+
* @return {any} Returns a promise that resolves to the result of the subscription operation or an error object if there was an issue.
|
|
66
|
+
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
67
|
+
*
|
|
35
68
|
* @description This method requires user authorization. For more information about configuring the authorization module, see the documentation in the configuration settings section of the SDK.
|
|
36
|
-
* @param {string} [marker] - Event marker.
|
|
37
|
-
* @param {string} [productId] - Product id.
|
|
38
|
-
* @param {string} [langCode] - Language code.
|
|
39
|
-
* @param {number} [threshold] - Threshold value for comparing numerical value.
|
|
40
69
|
*/
|
|
41
70
|
async subscribeByMarker(marker, productId, langCode = this.state.lang, threshold = 0) {
|
|
71
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
42
72
|
const data = {
|
|
43
73
|
locale: langCode,
|
|
44
74
|
productId,
|
|
@@ -52,13 +82,18 @@ class EventsApi extends asyncModules_1.default {
|
|
|
52
82
|
/**
|
|
53
83
|
* Unsubscribing to an event on a product.
|
|
54
84
|
*
|
|
85
|
+
* @handleName unsubscribeByMarker
|
|
86
|
+
*
|
|
87
|
+
* @param {string} marker - The marker of the event to unsubscribe from. Example: "product_price_change".
|
|
88
|
+
* @param {number} productId - The ID of the product to unsubscribe from. Example: 12345.
|
|
89
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
90
|
+
* @param {number} [threshold] - The threshold value for comparing numerical values. Default: 0.
|
|
91
|
+
* @return {any} - Returns a promise that resolves to the result of the unsubscription operation or an error object if there was an issue.
|
|
92
|
+
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
55
93
|
* @description This method requires user authorization. For more information about configuring the authorization module, see the documentation in the configuration settings section of the SDK.
|
|
56
|
-
* @param {string} [marker] - Event marker.
|
|
57
|
-
* @param {string} [productId] - Product id.
|
|
58
|
-
* @param {number} [langCode] - Language code.
|
|
59
|
-
* @param {number} [threshold] - Threshold value for comparing numerical value.
|
|
60
94
|
*/
|
|
61
95
|
async unsubscribeByMarker(marker, productId, langCode = this.state.lang, threshold = 0) {
|
|
96
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
62
97
|
const data = {
|
|
63
98
|
locale: langCode,
|
|
64
99
|
productId: productId,
|
|
@@ -1,18 +1,65 @@
|
|
|
1
1
|
import type { IError } from '../base/utils';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Interface for managing event subscriptions related to products.
|
|
4
|
+
*
|
|
5
|
+
* @interface IEvents
|
|
4
6
|
*
|
|
5
7
|
* @property {function} getAllSubscriptions - Return all subscriptions to product.
|
|
6
8
|
* @property {function} subscribeByMarker - Subscribing to an event on a product.
|
|
7
9
|
* @property {function} unsubscribeByMarker - Unsubscribing to an event on a product.
|
|
10
|
+
* @description This interface defines methods for managing event subscriptions related to products.
|
|
8
11
|
*/
|
|
9
12
|
interface IEvents {
|
|
10
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Retrieves all subscriptions to products.
|
|
15
|
+
*
|
|
16
|
+
* @param {number} [offset] - Optional offset for pagination. Default: 0.
|
|
17
|
+
* @param {number} [limit] - Optional limit for pagination. Default: 30.
|
|
18
|
+
* @return {ISubscriptions} A promise that resolves to a subscriptions object or an error.
|
|
19
|
+
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
20
|
+
*/
|
|
21
|
+
getAllSubscriptions(offset?: number, limit?: number): Promise<ISubscriptions | IError>;
|
|
22
|
+
/**
|
|
23
|
+
* Subscribes to an event on a product by its marker.
|
|
24
|
+
*
|
|
25
|
+
* @param {string} marker - The marker identifying the event. Example: "product_price_change".
|
|
26
|
+
* @param {number} productId - The ID of the product to subscribe to. Example: 12345.
|
|
27
|
+
* @param {string} [langCode] - Optional language code for localization. Default: "en_US".
|
|
28
|
+
* @param {number} [threshold] - Optional threshold value for the subscription. Default: 0.
|
|
29
|
+
* @return {any} A promise that resolves to any type or an error.
|
|
30
|
+
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
31
|
+
*/
|
|
11
32
|
subscribeByMarker(marker: string, productId: number, langCode?: string, threshold?: number): Promise<any | IError>;
|
|
33
|
+
/**
|
|
34
|
+
* Unsubscribes from an event on a product by its marker.
|
|
35
|
+
*
|
|
36
|
+
* @param {string} marker - The marker identifying the event. Example: "product_price_change".
|
|
37
|
+
* @param {number} productId - The ID of the product to unsubscribe from. Example: 12345.
|
|
38
|
+
* @param {string} [langCode] - Optional language code for localization. Default: "en_US".
|
|
39
|
+
* @param {number} [threshold] - Optional threshold value for the unsubscription. Default: 0.
|
|
40
|
+
* @returns {any} A promise that resolves to any type or an error.
|
|
41
|
+
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
42
|
+
*/
|
|
12
43
|
unsubscribeByMarker(marker: string, productId: number, langCode?: string, threshold?: number): Promise<any | IError>;
|
|
13
44
|
}
|
|
14
45
|
/**
|
|
15
|
-
*
|
|
46
|
+
* Represents a response from the events API containing a total count and an array of subscription items.
|
|
47
|
+
*
|
|
48
|
+
* @interface ISubscriptions
|
|
49
|
+
*
|
|
50
|
+
* @property {number} total - Total number of found records. Example: 100.
|
|
51
|
+
* @property {{ eventMarker: string; productId: number }[]} items - Array of subscription items, each containing an event marker and a product ID. Example:
|
|
52
|
+
[
|
|
53
|
+
{
|
|
54
|
+
eventMarker: 'product_price_change',
|
|
55
|
+
productId: 12345
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
eventMarker: 'product_stock_update',
|
|
59
|
+
productId: 67890
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
* @description Represents a response from the events API containing a total count and an array of subscription items.
|
|
16
63
|
*/
|
|
17
64
|
interface ISubscriptions {
|
|
18
65
|
total: number;
|