oneentry 1.0.126 → 1.0.127
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 +0 -2
- package/configure.js +25 -18
- package/dist/admins/adminsApi.d.ts +30 -25
- package/dist/admins/adminsApi.js +30 -25
- package/dist/admins/adminsInterfaces.d.ts +45 -54
- package/dist/attribute-sets/attributeSetsApi.d.ts +26 -27
- package/dist/attribute-sets/attributeSetsApi.js +26 -27
- package/dist/attribute-sets/attributeSetsInterfaces.d.ts +101 -109
- package/dist/auth-provider/authProviderApi.d.ts +132 -158
- package/dist/auth-provider/authProviderApi.js +131 -157
- package/dist/auth-provider/authProvidersInterfaces.d.ts +241 -237
- package/dist/base/asyncModules.d.ts +23 -21
- package/dist/base/asyncModules.js +30 -25
- package/dist/base/result.d.ts +31 -0
- package/dist/base/result.js +32 -1
- package/dist/base/stateModule.d.ts +10 -0
- package/dist/base/stateModule.js +50 -2
- package/dist/base/syncModules.d.ts +41 -49
- package/dist/base/syncModules.js +49 -48
- package/dist/base/utils.d.ts +38 -7
- package/dist/blocks/blocksApi.d.ts +27 -36
- package/dist/blocks/blocksApi.js +27 -36
- package/dist/blocks/blocksInterfaces.d.ts +92 -97
- package/dist/config.d.ts +13 -0
- package/dist/config.js +30 -0
- package/dist/events/eventsApi.d.ts +16 -33
- package/dist/events/eventsApi.js +32 -46
- package/dist/events/eventsInterfaces.d.ts +42 -37
- package/dist/file-uploading/fileUploadingApi.d.ts +42 -47
- package/dist/file-uploading/fileUploadingApi.js +44 -47
- package/dist/file-uploading/fileUploadingInterfaces.d.ts +49 -60
- package/dist/forms/formsApi.d.ts +15 -14
- package/dist/forms/formsApi.js +15 -14
- package/dist/forms/formsInterfaces.d.ts +36 -40
- package/dist/forms-data/formsDataApi.d.ts +40 -44
- package/dist/forms-data/formsDataApi.js +42 -44
- package/dist/forms-data/formsDataInterfaces.d.ts +231 -231
- package/dist/general-types/generalTypesApi.d.ts +5 -5
- package/dist/general-types/generalTypesApi.js +5 -5
- package/dist/general-types/generalTypesInterfaces.d.ts +6 -9
- package/dist/index.d.ts +12 -13
- package/dist/index.js +12 -13
- package/dist/integration-collections/integrationCollectionsApi.d.ts +84 -98
- package/dist/integration-collections/integrationCollectionsApi.js +86 -102
- package/dist/integration-collections/integrationCollectionsInterfaces.d.ts +177 -169
- package/dist/locales/localesApi.d.ts +7 -3
- package/dist/locales/localesApi.js +7 -3
- package/dist/locales/localesInterfaces.d.ts +14 -13
- package/dist/menus/menusApi.d.ts +9 -5
- package/dist/menus/menusApi.js +9 -5
- package/dist/menus/menusInterfaces.d.ts +43 -48
- package/dist/menus/menusInterfaces.js +1 -0
- package/dist/orders/ordersApi.d.ts +62 -70
- package/dist/orders/ordersApi.js +62 -71
- package/dist/orders/ordersInterfaces.d.ts +238 -203
- package/dist/pages/pagesApi.d.ts +67 -80
- package/dist/pages/pagesApi.js +71 -81
- package/dist/pages/pagesInterfaces.d.ts +164 -160
- package/dist/payments/paymentsApi.d.ts +24 -34
- package/dist/payments/paymentsApi.js +24 -38
- package/dist/payments/paymentsInterfaces.d.ts +82 -76
- package/dist/product-statuses/productStatusesApi.d.ts +13 -13
- package/dist/product-statuses/productStatusesApi.js +13 -13
- package/dist/product-statuses/productStatusesInterfaces.d.ts +29 -27
- package/dist/products/productsApi.d.ts +246 -267
- package/dist/products/productsApi.js +247 -267
- package/dist/products/productsInterfaces.d.ts +333 -339
- package/dist/system/systemApi.d.ts +19 -21
- package/dist/system/systemApi.js +20 -21
- package/dist/system/systemInterfaces.d.ts +14 -3
- package/dist/templates/templatesApi.d.ts +13 -16
- package/dist/templates/templatesApi.js +13 -16
- package/dist/templates/templatesInterfaces.d.ts +30 -29
- package/dist/templates-preview/templatesPreviewApi.d.ts +10 -11
- package/dist/templates-preview/templatesPreviewApi.js +10 -11
- package/dist/templates-preview/templatesPreviewInterfaces.d.ts +61 -64
- package/dist/users/usersApi.d.ts +36 -43
- package/dist/users/usersApi.js +36 -43
- package/dist/users/usersInterfaces.d.ts +92 -96
- package/dist/web-socket/wsApi.d.ts +5 -3
- package/dist/web-socket/wsApi.js +6 -3
- package/dist/web-socket/wsInterfaces.d.ts +7 -2
- package/package.json +16 -12
|
@@ -2,85 +2,84 @@ 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
5
|
* @interface IBlocks
|
|
7
|
-
*
|
|
8
|
-
* @property {
|
|
9
|
-
* @property {
|
|
10
|
-
* @property {
|
|
11
|
-
* @property {
|
|
12
|
-
* @property {function} searchBlock - Quick search for block objects with limited output.
|
|
6
|
+
* @property {Function} getBlocks - Get all Blocks objects.
|
|
7
|
+
* @property {Function} getBlockByMarker - Get Block object by marker.
|
|
8
|
+
* @property {Function} getSimilarProducts - Get Array of similar products from product-similar block.
|
|
9
|
+
* @property {Function} getProductsByBlockMarker - Get Array of products from product block.
|
|
10
|
+
* @property {Function} searchBlock - Quick search for block objects with limited output.
|
|
13
11
|
* @description This interface defines methods for retrieving and managing blocks in the system.
|
|
14
12
|
*/
|
|
15
13
|
interface IBlocks {
|
|
16
14
|
/**
|
|
17
15
|
* Retrieves all block objects of a specific type.
|
|
18
|
-
*
|
|
19
|
-
* @param
|
|
20
|
-
* @param
|
|
21
|
-
* @param
|
|
22
|
-
* @param
|
|
23
|
-
* @
|
|
16
|
+
* @handleName getBlocks
|
|
17
|
+
* @param {BlockType} type - The type of blocks to retrieve. Example: "product".
|
|
18
|
+
* @param {string} [langCode] - Optional language code for localization. Default: "en_US".
|
|
19
|
+
* @param {number} [offset] - Optional offset for pagination. Default: 0.
|
|
20
|
+
* @param {number} [limit] - Optional limit for pagination. Default: 30.
|
|
21
|
+
* @returns {IBlocksResponse} A promise that resolves to a blocks response or an error.
|
|
24
22
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
23
|
+
* @description This method retrieves all block objects of a specific type.
|
|
25
24
|
*/
|
|
26
25
|
getBlocks(type: BlockType, langCode?: string, offset?: number, limit?: number): Promise<IBlocksResponse | IError>;
|
|
27
26
|
/**
|
|
28
27
|
* Retrieves a block object by its marker.
|
|
29
|
-
*
|
|
30
|
-
* @param
|
|
31
|
-
* @param
|
|
32
|
-
* @param
|
|
33
|
-
* @param
|
|
34
|
-
* @
|
|
28
|
+
* @handleName getBlockByMarker
|
|
29
|
+
* @param {string} marker - The marker identifying the block. Example: "product_block".
|
|
30
|
+
* @param {string} langCode - Language code for localization. Default: "en_US".
|
|
31
|
+
* @param {number} [offset] - Optional offset for pagination. Default: 0.
|
|
32
|
+
* @param {number} [limit] - Optional limit for pagination. Default: 30.
|
|
33
|
+
* @returns {IBlockEntity} A promise that resolves to a block entity or an error.
|
|
35
34
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
35
|
+
* @description This method retrieves a block object by its marker.
|
|
36
36
|
*/
|
|
37
37
|
getBlockByMarker(marker: string, langCode: string, offset?: number, limit?: number): Promise<IBlockEntity | IError>;
|
|
38
38
|
/**
|
|
39
39
|
* Performs a quick search for block objects with limited output.
|
|
40
|
-
*
|
|
41
|
-
* @param
|
|
42
|
-
* @param
|
|
43
|
-
* @
|
|
40
|
+
* @handleName searchBlock
|
|
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
|
+
* @returns {ISearchBlock[]} A promise that resolves to an array of search blocks or an error.
|
|
44
44
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
45
|
+
* @description This method performs a quick search for block objects with limited output.
|
|
45
46
|
*/
|
|
46
47
|
searchBlock(name: string, langCode?: string): Promise<ISearchBlock[] | IError>;
|
|
47
48
|
}
|
|
48
49
|
/**
|
|
49
50
|
* Represents a response from the blocks API.
|
|
50
|
-
*
|
|
51
51
|
* @interface IBlocksResponse
|
|
52
|
-
*
|
|
53
|
-
* @property {number} total - Total number of found records. Example: 100.
|
|
52
|
+
* @property {number} total - Total number of found records. Example: 100.
|
|
54
53
|
* @property {IBlockEntity[]} items - Array of block entities. Example:
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
54
|
+
[
|
|
55
|
+
{
|
|
56
|
+
"attributeValues": [],
|
|
57
|
+
"id": 1,
|
|
58
|
+
"identifier": "block1",
|
|
59
|
+
"isVisible": true,
|
|
60
|
+
"localizeInfos": { "key": "value" },
|
|
61
|
+
"position": 1,
|
|
62
|
+
"templateIdentifier": null,
|
|
63
|
+
"type": "product",
|
|
64
|
+
"version": 1,
|
|
65
|
+
"countElementsPerRow": 3,
|
|
66
|
+
"quantity": 9,
|
|
67
|
+
"similarProducts": {
|
|
68
|
+
"total": 0,
|
|
69
|
+
"items": []
|
|
70
|
+
},
|
|
71
|
+
"products": [
|
|
72
|
+
{
|
|
73
|
+
"id": 1,
|
|
74
|
+
"name": "Product 1"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"id": 2,
|
|
78
|
+
"name": "Product 2"
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
}
|
|
82
|
+
]
|
|
84
83
|
* @description Represents a response from the blocks API containing a total count and an array of block entities.
|
|
85
84
|
*/
|
|
86
85
|
interface IBlocksResponse {
|
|
@@ -89,45 +88,43 @@ interface IBlocksResponse {
|
|
|
89
88
|
}
|
|
90
89
|
/**
|
|
91
90
|
* Represents a block entity with various attributes and properties.
|
|
92
|
-
*
|
|
93
91
|
* @interface IBlockEntity
|
|
94
|
-
*
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
* @property {
|
|
107
|
-
* @property {
|
|
108
|
-
* @property {
|
|
109
|
-
* @property {string}
|
|
110
|
-
* @property {string
|
|
111
|
-
* @property {
|
|
112
|
-
* @property {
|
|
113
|
-
* @property {number}
|
|
114
|
-
* @property {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
]
|
|
92
|
+
* @property {AttributeType} attributeValues - Type of attributes used in the block. Example:
|
|
93
|
+
{
|
|
94
|
+
"block-text": {
|
|
95
|
+
"type": "string",
|
|
96
|
+
"value": "some text",
|
|
97
|
+
"isIcon": false,
|
|
98
|
+
"position": 0,
|
|
99
|
+
"additionalFields": [],
|
|
100
|
+
"isProductPreview": false
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
* @property {number} id - Unique identifier of the block. Example: 1234.
|
|
104
|
+
* @property {ILocalizeInfo} localizeInfos - Localization information for the block. Example: {"key": "value"}
|
|
105
|
+
* @property {number} version - Version of the block entity. Example: 1.
|
|
106
|
+
* @property {string} identifier - Unique string identifier for the block. Example: "block1".
|
|
107
|
+
* @property {string} type - Type of the block, such as 'product', 'error_page', etc. Example: "product".
|
|
108
|
+
* @property {string | null} templateIdentifier - Identifier for the template used by the block, or null if not applicable. Example: "template1".
|
|
109
|
+
* @property {boolean} isVisible - Indicates whether the block is visible. Example: true.
|
|
110
|
+
* @property {number} [countElementsPerRow] - Number of elements displayed per row in the block, if applicable. Example: 3.
|
|
111
|
+
* @property {number} [quantity] - Quantity of items in the block, if applicable. Example: 5.
|
|
112
|
+
* @property {IProductsResponse} [similarProducts] - Response containing similar products associated with the block. Example:
|
|
113
|
+
{
|
|
114
|
+
"total": 10,
|
|
115
|
+
"items": []
|
|
116
|
+
}
|
|
117
|
+
* @property {IProductsEntity[]} [products] - Array of product entities associated with the block. Example:
|
|
118
|
+
[
|
|
119
|
+
{
|
|
120
|
+
"id": 1,
|
|
121
|
+
"name": "Product 1"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"id": 2,
|
|
125
|
+
"name": "Product 2"
|
|
126
|
+
}
|
|
127
|
+
]
|
|
131
128
|
* @description Represents a block entity with various attributes and properties.
|
|
132
129
|
*/
|
|
133
130
|
interface IBlockEntity {
|
|
@@ -147,12 +144,10 @@ interface IBlockEntity {
|
|
|
147
144
|
}
|
|
148
145
|
/**
|
|
149
146
|
* Represents a search block entity with an identifier, name, and ID.
|
|
150
|
-
*
|
|
151
147
|
* @interface ISearchBlock
|
|
152
|
-
*
|
|
153
|
-
* @property {number} id - Unique identifier of the search block. Example: 1.
|
|
148
|
+
* @property {number} id - Unique identifier of the search block. Example: 1.
|
|
154
149
|
* @property {string} identifier - Unique string identifier for the search block. Example: "search_block_1".
|
|
155
|
-
* @property {string} name
|
|
150
|
+
* @property {string} name - Name of the search block. Example: "Search Block 1".
|
|
156
151
|
* @description Represents a search block entity with an identifier, name, and ID.
|
|
157
152
|
*/
|
|
158
153
|
interface ISearchBlock {
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const projectUrl = "https://stage.oneentry.cloud";
|
|
2
|
+
export declare const projectToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiTlBNIiwic2VyaWFsTnVtYmVyIjozLCJpYXQiOjE3NDA1OTE0MzgsImV4cCI6MTc3MjEyNzQzMX0.MWbtBoXh-MqGTWgmiMTZSkfN8N-WYv3Cv2kSPhRpFlk";
|
|
3
|
+
/**
|
|
4
|
+
* authData
|
|
5
|
+
*/
|
|
6
|
+
export declare const authData: {
|
|
7
|
+
marker: string;
|
|
8
|
+
value: string;
|
|
9
|
+
}[];
|
|
10
|
+
export declare const authData2: {
|
|
11
|
+
marker: string;
|
|
12
|
+
value: string;
|
|
13
|
+
}[];
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.authData2 = exports.authData = exports.projectToken = exports.projectUrl = void 0;
|
|
4
|
+
exports.projectUrl = 'https://stage.oneentry.cloud';
|
|
5
|
+
exports.projectToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiTlBNIiwic2VyaWFsTnVtYmVyIjozLCJpYXQiOjE3NDA1OTE0MzgsImV4cCI6MTc3MjEyNzQzMX0.MWbtBoXh-MqGTWgmiMTZSkfN8N-WYv3Cv2kSPhRpFlk';
|
|
6
|
+
/**
|
|
7
|
+
* authData
|
|
8
|
+
*/
|
|
9
|
+
exports.authData = [
|
|
10
|
+
{
|
|
11
|
+
marker: 'email_reg',
|
|
12
|
+
value: 'test@test.ru',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
marker: 'password_reg',
|
|
16
|
+
// value: '12345',
|
|
17
|
+
value: '1-1',
|
|
18
|
+
},
|
|
19
|
+
];
|
|
20
|
+
exports.authData2 = [
|
|
21
|
+
{
|
|
22
|
+
marker: 'email_reg',
|
|
23
|
+
value: 'test2@test.ru',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
marker: 'password_reg',
|
|
27
|
+
// value: '12345',
|
|
28
|
+
value: '1-1',
|
|
29
|
+
},
|
|
30
|
+
];
|
|
@@ -4,12 +4,10 @@ import type { IError } from '../base/utils';
|
|
|
4
4
|
import type { IEvents, ISubscriptions } from './eventsInterfaces';
|
|
5
5
|
/**
|
|
6
6
|
* Controllers for working with events
|
|
7
|
-
*
|
|
8
7
|
* @handle /api/content/events
|
|
9
8
|
* @class EventsApi
|
|
10
|
-
* @
|
|
9
|
+
* @augments AsyncModules
|
|
11
10
|
* @implements {IEvents}
|
|
12
|
-
*
|
|
13
11
|
* @description This class provides methods to interact with events, including subscribing and unsubscribing to product events, and retrieving all subscriptions.
|
|
14
12
|
*/
|
|
15
13
|
export default class EventsApi extends AsyncModules implements IEvents {
|
|
@@ -17,58 +15,43 @@ export default class EventsApi extends AsyncModules implements IEvents {
|
|
|
17
15
|
protected _url: string;
|
|
18
16
|
/**
|
|
19
17
|
* Initializes the EventsApi with the provided state module.
|
|
20
|
-
*
|
|
21
|
-
* @
|
|
22
|
-
* @class - EventsApi
|
|
23
|
-
* @extends - AsyncModules
|
|
18
|
+
* @class EventsApi
|
|
19
|
+
* @augments AsyncModules
|
|
24
20
|
* @implements {IEvents}
|
|
25
|
-
*
|
|
26
21
|
* @param {StateModule} state - The state module containing the base URL and other configurations.
|
|
27
|
-
*
|
|
28
22
|
* @description Initializes the EventsApi with the provided state module.
|
|
29
23
|
*/
|
|
30
24
|
constructor(state: StateModule);
|
|
31
25
|
/**
|
|
32
26
|
* Return all subscriptions to product.
|
|
33
|
-
*
|
|
34
27
|
* @handleName getAllSubscriptions
|
|
35
|
-
*
|
|
36
|
-
* @param
|
|
37
|
-
* @
|
|
38
|
-
* @return {ISubscriptions} Returns an object containing all subscriptions or an error object if there was an issue.
|
|
28
|
+
* @param {number} [offset] - Optional offset for pagination. Default: 0.
|
|
29
|
+
* @param {number} [limit] - Optional limit for pagination. Default: 30.
|
|
30
|
+
* @returns {ISubscriptions} Returns an object containing all subscriptions or an error object if there was an issue.
|
|
39
31
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
40
|
-
*
|
|
41
32
|
* @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.
|
|
42
33
|
*/
|
|
43
34
|
getAllSubscriptions(offset?: number, limit?: number): Promise<ISubscriptions | IError>;
|
|
44
35
|
/**
|
|
45
36
|
* Subscribing to an event on a product.
|
|
46
|
-
*
|
|
47
37
|
* @handleName subscribeByMarker
|
|
48
|
-
*
|
|
49
|
-
* @param
|
|
50
|
-
* @param
|
|
51
|
-
* @
|
|
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.
|
|
38
|
+
* @param {string} marker - Event marker. Example: "product_price_change".
|
|
39
|
+
* @param {number} productId - Product id. Example: 12345.
|
|
40
|
+
* @param {string} [langCode] - Language code. Default: "en_US".=
|
|
41
|
+
* @returns {Promise<boolean | IError>} Returns true if subscription was successful, or an error object if there was an issue.
|
|
55
42
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
56
|
-
*
|
|
57
43
|
* @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.
|
|
58
44
|
*/
|
|
59
|
-
subscribeByMarker(marker: string, productId: number, langCode?: string
|
|
45
|
+
subscribeByMarker(marker: string, productId: number, langCode?: string): Promise<boolean | IError>;
|
|
60
46
|
/**
|
|
61
47
|
* Unsubscribing to an event on a product.
|
|
62
|
-
*
|
|
63
48
|
* @handleName unsubscribeByMarker
|
|
64
|
-
*
|
|
65
|
-
* @param
|
|
66
|
-
* @param
|
|
67
|
-
* @
|
|
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.
|
|
49
|
+
* @param {string} marker - The marker of the event to unsubscribe from. Example: "product_price_change".
|
|
50
|
+
* @param {number} productId - The ID of the product to unsubscribe from. Example: 12345.
|
|
51
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
52
|
+
* @returns {any} - Returns a promise that resolves to the result of the unsubscription operation or an error object if there was an issue.
|
|
70
53
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
71
54
|
* @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.
|
|
72
55
|
*/
|
|
73
|
-
unsubscribeByMarker(marker: string, productId: number, langCode?: string
|
|
56
|
+
unsubscribeByMarker(marker: string, productId: number, langCode?: string): Promise<boolean | IError>;
|
|
74
57
|
}
|
package/dist/events/eventsApi.js
CHANGED
|
@@ -3,29 +3,24 @@ 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 jsdoc/reject-any-type */
|
|
6
7
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
7
8
|
const asyncModules_1 = __importDefault(require("../base/asyncModules"));
|
|
8
9
|
/**
|
|
9
10
|
* Controllers for working with events
|
|
10
|
-
*
|
|
11
11
|
* @handle /api/content/events
|
|
12
12
|
* @class EventsApi
|
|
13
|
-
* @
|
|
13
|
+
* @augments AsyncModules
|
|
14
14
|
* @implements {IEvents}
|
|
15
|
-
*
|
|
16
15
|
* @description This class provides methods to interact with events, including subscribing and unsubscribing to product events, and retrieving all subscriptions.
|
|
17
16
|
*/
|
|
18
17
|
class EventsApi extends asyncModules_1.default {
|
|
19
18
|
/**
|
|
20
19
|
* Initializes the EventsApi with the provided state module.
|
|
21
|
-
*
|
|
22
|
-
* @
|
|
23
|
-
* @class - EventsApi
|
|
24
|
-
* @extends - AsyncModules
|
|
20
|
+
* @class EventsApi
|
|
21
|
+
* @augments AsyncModules
|
|
25
22
|
* @implements {IEvents}
|
|
26
|
-
*
|
|
27
23
|
* @param {StateModule} state - The state module containing the base URL and other configurations.
|
|
28
|
-
*
|
|
29
24
|
* @description Initializes the EventsApi with the provided state module.
|
|
30
25
|
*/
|
|
31
26
|
constructor(state) {
|
|
@@ -34,14 +29,11 @@ class EventsApi extends asyncModules_1.default {
|
|
|
34
29
|
}
|
|
35
30
|
/**
|
|
36
31
|
* Return all subscriptions to product.
|
|
37
|
-
*
|
|
38
32
|
* @handleName getAllSubscriptions
|
|
39
|
-
*
|
|
40
|
-
* @param
|
|
41
|
-
* @
|
|
42
|
-
* @return {ISubscriptions} Returns an object containing all subscriptions or an error object if there was an issue.
|
|
33
|
+
* @param {number} [offset] - Optional offset for pagination. Default: 0.
|
|
34
|
+
* @param {number} [limit] - Optional limit for pagination. Default: 30.
|
|
35
|
+
* @returns {ISubscriptions} Returns an object containing all subscriptions or an error object if there was an issue.
|
|
43
36
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
44
|
-
*
|
|
45
37
|
* @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.
|
|
46
38
|
*/
|
|
47
39
|
async getAllSubscriptions(offset = 0, limit = 30) {
|
|
@@ -54,55 +46,49 @@ class EventsApi extends asyncModules_1.default {
|
|
|
54
46
|
}
|
|
55
47
|
/**
|
|
56
48
|
* Subscribing to an event on a product.
|
|
57
|
-
*
|
|
58
49
|
* @handleName subscribeByMarker
|
|
59
|
-
*
|
|
60
|
-
* @param
|
|
61
|
-
* @param
|
|
62
|
-
* @
|
|
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.
|
|
50
|
+
* @param {string} marker - Event marker. Example: "product_price_change".
|
|
51
|
+
* @param {number} productId - Product id. Example: 12345.
|
|
52
|
+
* @param {string} [langCode] - Language code. Default: "en_US".=
|
|
53
|
+
* @returns {Promise<boolean | IError>} Returns true if subscription was successful, or an error object if there was an issue.
|
|
66
54
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
67
|
-
*
|
|
68
55
|
* @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.
|
|
69
56
|
*/
|
|
70
|
-
async subscribeByMarker(marker, productId, langCode = this.state.lang
|
|
71
|
-
|
|
72
|
-
const data = {
|
|
57
|
+
async subscribeByMarker(marker, productId, langCode = this.state.lang) {
|
|
58
|
+
const body = {
|
|
73
59
|
locale: langCode,
|
|
74
60
|
productId,
|
|
75
61
|
};
|
|
76
|
-
|
|
77
|
-
|
|
62
|
+
try {
|
|
63
|
+
await this._fetchPost(`/subscribe/marker/${marker}`, body);
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
catch (e) {
|
|
67
|
+
return e;
|
|
78
68
|
}
|
|
79
|
-
const result = await this._fetchPost(`/subscribe/marker/${marker}`, data);
|
|
80
|
-
return result;
|
|
81
69
|
}
|
|
82
70
|
/**
|
|
83
71
|
* Unsubscribing to an event on a product.
|
|
84
|
-
*
|
|
85
72
|
* @handleName unsubscribeByMarker
|
|
86
|
-
*
|
|
87
|
-
* @param
|
|
88
|
-
* @param
|
|
89
|
-
* @
|
|
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.
|
|
73
|
+
* @param {string} marker - The marker of the event to unsubscribe from. Example: "product_price_change".
|
|
74
|
+
* @param {number} productId - The ID of the product to unsubscribe from. Example: 12345.
|
|
75
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
76
|
+
* @returns {any} - Returns a promise that resolves to the result of the unsubscription operation or an error object if there was an issue.
|
|
92
77
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
93
78
|
* @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.
|
|
94
79
|
*/
|
|
95
|
-
async unsubscribeByMarker(marker, productId, langCode = this.state.lang
|
|
96
|
-
|
|
97
|
-
const data = {
|
|
98
|
-
locale: langCode,
|
|
80
|
+
async unsubscribeByMarker(marker, productId, langCode = this.state.lang) {
|
|
81
|
+
const body = {
|
|
99
82
|
productId: productId,
|
|
83
|
+
locale: langCode,
|
|
100
84
|
};
|
|
101
|
-
|
|
102
|
-
|
|
85
|
+
try {
|
|
86
|
+
await this._fetchDelete(`/unsubscribe/marker/${marker}`, body);
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
catch (e) {
|
|
90
|
+
return e;
|
|
103
91
|
}
|
|
104
|
-
const result = await this._fetchDelete(`/unsubscribe/marker/${marker}`, data);
|
|
105
|
-
return result;
|
|
106
92
|
}
|
|
107
93
|
}
|
|
108
94
|
exports.default = EventsApi;
|
|
@@ -1,64 +1,58 @@
|
|
|
1
1
|
import type { IError } from '../base/utils';
|
|
2
2
|
/**
|
|
3
3
|
* Interface for managing event subscriptions related to products.
|
|
4
|
-
*
|
|
5
4
|
* @interface IEvents
|
|
6
|
-
*
|
|
7
|
-
* @property {function} getAllSubscriptions - Return all subscriptions to product.
|
|
8
|
-
* @property {function} subscribeByMarker - Subscribing to an event on a product.
|
|
9
|
-
* @property {function} unsubscribeByMarker - Unsubscribing to an event on a product.
|
|
10
5
|
* @description This interface defines methods for managing event subscriptions related to products.
|
|
11
6
|
*/
|
|
12
7
|
interface IEvents {
|
|
13
8
|
/**
|
|
14
9
|
* Retrieves all subscriptions to products.
|
|
15
|
-
*
|
|
16
|
-
* @param
|
|
17
|
-
* @param
|
|
18
|
-
* @
|
|
10
|
+
* @handleName getAllSubscriptions
|
|
11
|
+
* @param {number} [offset] - Optional offset for pagination. Default: 0.
|
|
12
|
+
* @param {number} [limit] - Optional limit for pagination. Default: 30.
|
|
13
|
+
* @returns {ISubscriptions} A promise that resolves to a subscriptions object or an error.
|
|
19
14
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
15
|
+
* @description This method retrieves all subscriptions to products.
|
|
20
16
|
*/
|
|
21
17
|
getAllSubscriptions(offset?: number, limit?: number): Promise<ISubscriptions | IError>;
|
|
22
18
|
/**
|
|
23
19
|
* Subscribes to an event on a product by its marker.
|
|
24
|
-
*
|
|
25
|
-
* @param
|
|
26
|
-
* @param
|
|
27
|
-
* @param
|
|
28
|
-
* @
|
|
29
|
-
* @return {any} A promise that resolves to any type or an error.
|
|
20
|
+
* @handleName subscribeByMarker
|
|
21
|
+
* @param {string} marker - The marker identifying the event. Example: "product_price_change".
|
|
22
|
+
* @param {number} productId - The ID of the product to subscribe to. Example: 12345.
|
|
23
|
+
* @param {string} [langCode] - Optional language code for localization. Default: "en_US".
|
|
24
|
+
* @returns {boolean} A promise that resolves to any type or an error.
|
|
30
25
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
26
|
+
* @description This method subscribes to an event on a product by its marker.
|
|
31
27
|
*/
|
|
32
|
-
subscribeByMarker(marker: string, productId: number, langCode?: string
|
|
28
|
+
subscribeByMarker(marker: string, productId: number, langCode?: string): Promise<boolean | IError>;
|
|
33
29
|
/**
|
|
34
30
|
* Unsubscribes from an event on a product by its marker.
|
|
35
|
-
*
|
|
36
|
-
* @param
|
|
37
|
-
* @param
|
|
38
|
-
* @param
|
|
39
|
-
* @
|
|
40
|
-
* @returns {any} A promise that resolves to any type or an error.
|
|
31
|
+
* @handleName unsubscribeByMarker
|
|
32
|
+
* @param {string} marker - The marker identifying the event. Example: "product_price_change".
|
|
33
|
+
* @param {number} productId - The ID of the product to unsubscribe from. Example: 12345.
|
|
34
|
+
* @param {string} [langCode] - Optional language code for localization. Default: "en_US".
|
|
35
|
+
* @returns {boolean} A promise that resolves to any type or an error.
|
|
41
36
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
37
|
+
* @description This method unsubscribes from an event on a product by its marker.
|
|
42
38
|
*/
|
|
43
|
-
unsubscribeByMarker(marker: string, productId: number, langCode?: string
|
|
39
|
+
unsubscribeByMarker(marker: string, productId: number, langCode?: string): Promise<boolean | IError>;
|
|
44
40
|
}
|
|
45
41
|
/**
|
|
46
42
|
* Represents a response from the events API containing a total count and an array of subscription items.
|
|
47
|
-
*
|
|
48
43
|
* @interface ISubscriptions
|
|
49
|
-
*
|
|
50
|
-
* @property {number} total - Total number of found records. Example: 100.
|
|
44
|
+
* @property {number} total - Total number of found records. Example: 100.
|
|
51
45
|
* @property {{ eventMarker: string; productId: number }[]} items - Array of subscription items, each containing an event marker and a product ID. Example:
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
46
|
+
[
|
|
47
|
+
{
|
|
48
|
+
eventMarker: 'product_price_change',
|
|
49
|
+
productId: 12345
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
eventMarker: 'product_stock_update',
|
|
53
|
+
productId: 67890
|
|
54
|
+
}
|
|
55
|
+
]
|
|
62
56
|
* @description Represents a response from the events API containing a total count and an array of subscription items.
|
|
63
57
|
*/
|
|
64
58
|
interface ISubscriptions {
|
|
@@ -68,4 +62,15 @@ interface ISubscriptions {
|
|
|
68
62
|
productId: number;
|
|
69
63
|
}>;
|
|
70
64
|
}
|
|
71
|
-
|
|
65
|
+
/**
|
|
66
|
+
* Interface for the body of the subscribe methods.
|
|
67
|
+
* @interface ISubscribeBody
|
|
68
|
+
* @property {string} locale - Locale of the user. Example: "en_US".
|
|
69
|
+
* @property {number} productId - Product ID. Example: 12345.
|
|
70
|
+
* @description Represents a body for the subscribe methods, containing the locale and product ID.
|
|
71
|
+
*/
|
|
72
|
+
interface ISubscribeBody {
|
|
73
|
+
locale: string;
|
|
74
|
+
productId: number;
|
|
75
|
+
}
|
|
76
|
+
export type { IEvents, ISubscribeBody, ISubscriptions };
|