oneentry 1.0.140 → 1.0.141

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.
Files changed (149) hide show
  1. package/dist/admins/adminsApi.d.ts +50 -0
  2. package/dist/admins/adminsApi.js +65 -0
  3. package/dist/admins/adminsInterfaces.d.ts +99 -0
  4. package/dist/admins/adminsInterfaces.js +2 -0
  5. package/dist/admins/adminsSchemas.d.ts +30 -0
  6. package/dist/admins/adminsSchemas.js +27 -0
  7. package/dist/attribute-sets/attributeSetsApi.d.ts +63 -0
  8. package/dist/attribute-sets/attributeSetsApi.js +98 -0
  9. package/dist/attribute-sets/attributeSetsInterfaces.d.ts +187 -0
  10. package/dist/attribute-sets/attributeSetsInterfaces.js +2 -0
  11. package/dist/attribute-sets/attributeSetsSchemas.d.ts +90 -0
  12. package/dist/attribute-sets/attributeSetsSchemas.js +74 -0
  13. package/dist/auth-provider/authProviderApi.d.ts +249 -0
  14. package/dist/auth-provider/authProviderApi.js +351 -0
  15. package/dist/auth-provider/authProviderSchemas.d.ts +131 -0
  16. package/dist/auth-provider/authProviderSchemas.js +82 -0
  17. package/dist/auth-provider/authProvidersInterfaces.d.ts +425 -0
  18. package/dist/auth-provider/authProvidersInterfaces.js +2 -0
  19. package/dist/base/asyncModules.d.ts +80 -0
  20. package/dist/base/asyncModules.js +440 -0
  21. package/dist/base/result.d.ts +39 -0
  22. package/dist/base/result.js +154 -0
  23. package/dist/base/stateModule.d.ts +41 -0
  24. package/dist/base/stateModule.js +128 -0
  25. package/dist/base/syncModules.d.ts +149 -0
  26. package/dist/base/syncModules.js +549 -0
  27. package/dist/base/utils.d.ts +197 -0
  28. package/dist/base/utils.js +2 -0
  29. package/dist/base/validation.d.ts +118 -0
  30. package/dist/base/validation.js +132 -0
  31. package/dist/blocks/blocksApi.d.ts +76 -0
  32. package/dist/blocks/blocksApi.js +188 -0
  33. package/dist/blocks/blocksInterfaces.d.ts +173 -0
  34. package/dist/blocks/blocksInterfaces.js +2 -0
  35. package/dist/blocks/blocksSchemas.d.ts +187 -0
  36. package/dist/blocks/blocksSchemas.js +43 -0
  37. package/dist/discounts/discountsApi.d.ts +56 -0
  38. package/dist/discounts/discountsApi.js +82 -0
  39. package/dist/discounts/discountsInterfaces.d.ts +145 -0
  40. package/dist/discounts/discountsInterfaces.js +2 -0
  41. package/dist/events/eventsApi.d.ts +60 -0
  42. package/dist/events/eventsApi.js +97 -0
  43. package/dist/events/eventsInterfaces.d.ts +87 -0
  44. package/dist/events/eventsInterfaces.js +2 -0
  45. package/dist/file-uploading/fileUploadingApi.d.ts +88 -0
  46. package/dist/file-uploading/fileUploadingApi.js +132 -0
  47. package/dist/file-uploading/fileUploadingInterfaces.d.ts +117 -0
  48. package/dist/file-uploading/fileUploadingInterfaces.js +2 -0
  49. package/dist/file-uploading/fileUploadingSchemas.d.ts +22 -0
  50. package/dist/file-uploading/fileUploadingSchemas.js +21 -0
  51. package/dist/forms/formsApi.d.ts +42 -0
  52. package/dist/forms/formsApi.js +57 -0
  53. package/dist/forms/formsInterfaces.d.ts +132 -0
  54. package/dist/forms/formsInterfaces.js +2 -0
  55. package/dist/forms/formsSchemas.d.ts +50 -0
  56. package/dist/forms/formsSchemas.js +31 -0
  57. package/dist/forms-data/formsDataApi.d.ts +106 -0
  58. package/dist/forms-data/formsDataApi.js +189 -0
  59. package/dist/forms-data/formsDataInterfaces.d.ts +525 -0
  60. package/dist/forms-data/formsDataInterfaces.js +2 -0
  61. package/dist/forms-data/formsDataSchemas.d.ts +115 -0
  62. package/dist/forms-data/formsDataSchemas.js +86 -0
  63. package/dist/general-types/generalTypesApi.d.ts +28 -0
  64. package/dist/general-types/generalTypesApi.js +38 -0
  65. package/dist/general-types/generalTypesInterfaces.d.ts +30 -0
  66. package/dist/general-types/generalTypesInterfaces.js +2 -0
  67. package/dist/general-types/generalTypesSchemas.d.ts +50 -0
  68. package/dist/general-types/generalTypesSchemas.js +35 -0
  69. package/dist/index.d.ts +100 -0
  70. package/dist/index.js +103 -0
  71. package/dist/integration-collections/integrationCollectionsApi.d.ts +173 -0
  72. package/dist/integration-collections/integrationCollectionsApi.js +220 -0
  73. package/dist/integration-collections/integrationCollectionsInterfaces.d.ts +313 -0
  74. package/dist/integration-collections/integrationCollectionsInterfaces.js +2 -0
  75. package/dist/integration-collections/integrationCollectionsSchemas.d.ts +80 -0
  76. package/dist/integration-collections/integrationCollectionsSchemas.js +61 -0
  77. package/dist/locales/localesApi.d.ts +27 -0
  78. package/dist/locales/localesApi.js +37 -0
  79. package/dist/locales/localesInterfaces.d.ts +41 -0
  80. package/dist/locales/localesInterfaces.js +2 -0
  81. package/dist/locales/localesSchemas.d.ts +32 -0
  82. package/dist/locales/localesSchemas.js +26 -0
  83. package/dist/menus/menusApi.d.ts +29 -0
  84. package/dist/menus/menusApi.js +39 -0
  85. package/dist/menus/menusInterfaces.d.ts +88 -0
  86. package/dist/menus/menusInterfaces.js +4 -0
  87. package/dist/menus/menusSchemas.d.ts +16 -0
  88. package/dist/menus/menusSchemas.js +28 -0
  89. package/dist/orders/ordersApi.d.ts +149 -0
  90. package/dist/orders/ordersApi.js +203 -0
  91. package/dist/orders/ordersInterfaces.d.ts +527 -0
  92. package/dist/orders/ordersInterfaces.js +2 -0
  93. package/dist/orders/ordersSchemas.d.ts +120 -0
  94. package/dist/orders/ordersSchemas.js +101 -0
  95. package/dist/pages/pagesApi.d.ts +151 -0
  96. package/dist/pages/pagesApi.js +390 -0
  97. package/dist/pages/pagesInterfaces.d.ts +292 -0
  98. package/dist/pages/pagesInterfaces.js +2 -0
  99. package/dist/pages/pagesSchemas.d.ts +85 -0
  100. package/dist/pages/pagesSchemas.js +46 -0
  101. package/dist/payments/paymentsApi.d.ts +82 -0
  102. package/dist/payments/paymentsApi.js +121 -0
  103. package/dist/payments/paymentsInterfaces.d.ts +206 -0
  104. package/dist/payments/paymentsInterfaces.js +2 -0
  105. package/dist/payments/paymentsSchemas.d.ts +100 -0
  106. package/dist/payments/paymentsSchemas.js +65 -0
  107. package/dist/product-statuses/productStatusesApi.d.ts +47 -0
  108. package/dist/product-statuses/productStatusesApi.js +70 -0
  109. package/dist/product-statuses/productStatusesInterfaces.d.ts +66 -0
  110. package/dist/product-statuses/productStatusesInterfaces.js +2 -0
  111. package/dist/product-statuses/productStatusesSchemas.d.ts +34 -0
  112. package/dist/product-statuses/productStatusesSchemas.js +30 -0
  113. package/dist/products/productsApi.d.ts +365 -0
  114. package/dist/products/productsApi.js +459 -0
  115. package/dist/products/productsInterfaces.d.ts +586 -0
  116. package/dist/products/productsInterfaces.js +2 -0
  117. package/dist/products/productsSchemas.d.ts +192 -0
  118. package/dist/products/productsSchemas.js +96 -0
  119. package/dist/sitemap/sitemapApi.d.ts +35 -0
  120. package/dist/sitemap/sitemapApi.js +45 -0
  121. package/dist/sitemap/sitemapInterfaces.d.ts +40 -0
  122. package/dist/sitemap/sitemapInterfaces.js +2 -0
  123. package/dist/system/systemApi.d.ts +43 -0
  124. package/dist/system/systemApi.js +58 -0
  125. package/dist/system/systemInterfaces.d.ts +31 -0
  126. package/dist/system/systemInterfaces.js +5 -0
  127. package/dist/templates/templatesApi.d.ts +49 -0
  128. package/dist/templates/templatesApi.js +75 -0
  129. package/dist/templates/templatesInterfaces.d.ts +70 -0
  130. package/dist/templates/templatesInterfaces.js +2 -0
  131. package/dist/templates/templatesSchemas.d.ts +48 -0
  132. package/dist/templates/templatesSchemas.js +31 -0
  133. package/dist/templates-preview/templatesPreviewApi.d.ts +38 -0
  134. package/dist/templates-preview/templatesPreviewApi.js +53 -0
  135. package/dist/templates-preview/templatesPreviewInterfaces.d.ts +121 -0
  136. package/dist/templates-preview/templatesPreviewInterfaces.js +2 -0
  137. package/dist/templates-preview/templatesPreviewSchemas.d.ts +83 -0
  138. package/dist/templates-preview/templatesPreviewSchemas.js +48 -0
  139. package/dist/users/usersApi.d.ts +143 -0
  140. package/dist/users/usersApi.js +173 -0
  141. package/dist/users/usersInterfaces.d.ts +235 -0
  142. package/dist/users/usersInterfaces.js +2 -0
  143. package/dist/users/usersSchemas.d.ts +38 -0
  144. package/dist/users/usersSchemas.js +28 -0
  145. package/dist/web-socket/wsApi.d.ts +25 -0
  146. package/dist/web-socket/wsApi.js +45 -0
  147. package/dist/web-socket/wsInterfaces.d.ts +17 -0
  148. package/dist/web-socket/wsInterfaces.js +2 -0
  149. package/package.json +3 -81
@@ -0,0 +1,188 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ /* eslint-disable @typescript-eslint/no-explicit-any */
7
+ const asyncModules_1 = __importDefault(require("../base/asyncModules"));
8
+ const blocksSchemas_1 = require("./blocksSchemas");
9
+ /**
10
+ * Controllers for working with blocks.
11
+ * @handle /api/content/blocks
12
+ * @class BlocksApi
13
+ * @augments AsyncModules
14
+ * @implements {IBlocks}
15
+ * @description This class provides methods to interact with blocks.
16
+ */
17
+ class BlocksApi extends asyncModules_1.default {
18
+ /**
19
+ * Constructor for BlocksApi class.
20
+ */
21
+ constructor(state) {
22
+ super(state);
23
+ this._url = state.url + '/api/content/blocks';
24
+ }
25
+ /**
26
+ * Get blocks by parameters.
27
+ * @handleName getBlocks
28
+ * @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'.
29
+ * @param {string} [langCode] - Language code. Default: "en_US".
30
+ * @param {number} [offset] - Parameter for pagination. Default: 0.
31
+ * @param {number} [limit] - Parameter for pagination. Default: 30.
32
+ * @returns {Promise<IBlocksResponse | IError>} Returns BlocksEntity object.
33
+ * @throws {IError} When isShell=false and an error occurs during the fetch
34
+ */
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}`);
37
+ // Validate response if validation is enabled
38
+ const validated = this._validateResponse(response, blocksSchemas_1.BlocksResponseSchema);
39
+ if (!this.state.traficLimit) {
40
+ const normalizeResponse = this._normalizeData(validated);
41
+ await Promise.all(normalizeResponse.items.map(async (block) => {
42
+ const customSettings = block.customSettings;
43
+ if (customSettings &&
44
+ Object.prototype.hasOwnProperty.call(customSettings, 'productConfig')) {
45
+ if (customSettings.productConfig.countElementsPerRow)
46
+ block.countElementsPerRow =
47
+ +customSettings.productConfig.countElementsPerRow;
48
+ if (customSettings.productConfig.quantity)
49
+ block.quantity = +customSettings.productConfig.quantity;
50
+ }
51
+ delete block.customSettings;
52
+ delete block.attributesSetIdentifier;
53
+ delete block.productPageUrls;
54
+ if (block.type === 'similar_products_block') {
55
+ try {
56
+ await this.getSimilarProducts(block.identifier, langCode, offset, limit).then((result) => {
57
+ block.similarProducts = result;
58
+ });
59
+ }
60
+ catch {
61
+ block.similarProducts = [];
62
+ }
63
+ }
64
+ else if (block.type === 'product_block') {
65
+ try {
66
+ await this.getProductsByBlockMarker(block.identifier, langCode, offset, limit).then((result) => {
67
+ block.products = result;
68
+ });
69
+ }
70
+ catch {
71
+ block.products = [];
72
+ }
73
+ }
74
+ }));
75
+ return this._normalizeData(normalizeResponse);
76
+ }
77
+ return this._normalizeData(validated);
78
+ }
79
+ /**
80
+ * Get block by marker.
81
+ * @handleName getBlockByMarker
82
+ * @param {string} marker - Marker of Block. Example: "product_block".
83
+ * @param {string} [langCode] - Language code. Default: "en_US".
84
+ * @param {number} [offset] - Parameter for pagination. Default: 0.
85
+ * @param {number} [limit] - Parameter for pagination. Default: 30.
86
+ * @returns {Promise<IBlockEntity | IError>} - Returns a BlockEntity object.
87
+ * @throws {IError} When isShell=false and an error occurs during the fetch
88
+ * @description This method retrieves a block by its marker and includes additional information such as similar products or products associated with the block.
89
+ */
90
+ async getBlockByMarker(marker, langCode = this.state.lang, offset = 0, limit = 30) {
91
+ const response = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
92
+ // Validate response if validation is enabled
93
+ const validated = this._validateResponse(response, blocksSchemas_1.BlockEntitySchema);
94
+ const normalizeResponse = this._normalizeData(validated);
95
+ const customSettings = normalizeResponse.customSettings;
96
+ if (customSettings &&
97
+ Object.prototype.hasOwnProperty.call(customSettings, 'productConfig')) {
98
+ if (customSettings.productConfig.countElementsPerRow)
99
+ normalizeResponse.countElementsPerRow =
100
+ +customSettings.productConfig.countElementsPerRow;
101
+ if (customSettings.productConfig.quantity)
102
+ normalizeResponse.quantity = +customSettings.productConfig.quantity;
103
+ }
104
+ delete normalizeResponse.customSettings;
105
+ delete normalizeResponse.attributesSetIdentifier;
106
+ delete normalizeResponse.productPageUrls;
107
+ if (!this.state.traficLimit) {
108
+ if (normalizeResponse.type === 'similar_products_block') {
109
+ try {
110
+ await this.getSimilarProducts(normalizeResponse.identifier, langCode, offset, limit).then((result) => {
111
+ normalizeResponse.similarProducts = result;
112
+ });
113
+ }
114
+ catch {
115
+ normalizeResponse.similarProducts = [];
116
+ }
117
+ }
118
+ else if (normalizeResponse.type === 'product_block') {
119
+ try {
120
+ await this.getProductsByBlockMarker(normalizeResponse.identifier, langCode, offset, limit).then((result) => {
121
+ normalizeResponse.products = result;
122
+ });
123
+ }
124
+ catch {
125
+ normalizeResponse.products = [];
126
+ }
127
+ }
128
+ }
129
+ return this._normalizeData(normalizeResponse);
130
+ }
131
+ /**
132
+ * Get similar products by block marker.
133
+ * @handleName getSimilarProducts
134
+ * @param {string} marker - Block identifier. Example: "similar_products_block".
135
+ * @param {string} [langCode] - Language code. Default: "en_US".
136
+ * @param {number} [offset] - Parameter for pagination. Default: 0.
137
+ * @param {number} [limit] - Parameter for pagination. Default: 30.
138
+ * @param {string} [signPrice] - Sign price.
139
+ * @returns {Promise<IProductsResponse | IError>} - Returns the total count and an array of product items in object by specified block marker.
140
+ * @throws {IError} When isShell=false and an error occurs during the fetch
141
+ */
142
+ async getSimilarProducts(marker, langCode = this.state.lang, offset = 0, limit = 30, signPrice) {
143
+ const query = {
144
+ langCode,
145
+ offset,
146
+ limit,
147
+ signPrice,
148
+ };
149
+ const result = await this._fetchGet(`/${marker}/similar-products?` + this._queryParamsToString(query));
150
+ return this._normalizeData(result);
151
+ }
152
+ /**
153
+ * Get products by block marker.
154
+ * @handleName getProductsByBlockMarker
155
+ * @param {string} marker - Block identifier. Example: "product_block".
156
+ * @param {string} [langCode] - Language code. Default: "en_US".
157
+ * @param {number} [offset] - Parameter for pagination. Default: 0.
158
+ * @param {number} [limit] - Parameter for pagination. Default: 30.
159
+ * @param {string} [signPrice] - Sign price.
160
+ * @returns {Promise<IProductsEntity[] | IError>} Return array of BlocksEntity object.
161
+ * @throws {IError} When isShell=false and an error occurs during the fetch
162
+ */
163
+ async getProductsByBlockMarker(marker, langCode = this.state.lang, offset = 0, limit = 30, signPrice) {
164
+ const query = {
165
+ langCode,
166
+ offset,
167
+ limit,
168
+ signPrice,
169
+ };
170
+ const result = await this._fetchGet(`/${marker}/products?` + this._queryParamsToString(query));
171
+ return this._normalizeData(result.items);
172
+ }
173
+ /**
174
+ * Quick search for block objects with limited output.
175
+ * @handleName searchBlock
176
+ * @param {string} name - Search string. Example: "product_block".
177
+ * @param {string} [langCode] - Language code. Default: "en_US".
178
+ * @returns {Promise<ISearchBlock[] | IError>} Returns an array of ISearchBlock objects.
179
+ * @throws {IError} When isShell=false and an error occurs during the fetch
180
+ */
181
+ async searchBlock(name, langCode = this.state.lang) {
182
+ const result = await this._fetchGet(`/quick/search?langCode=${langCode}&name=${name}`);
183
+ // Validate response if validation is enabled
184
+ const validated = this._validateResponse(result, blocksSchemas_1.SearchBlocksResponseSchema);
185
+ return validated;
186
+ }
187
+ }
188
+ exports.default = BlocksApi;
@@ -0,0 +1,173 @@
1
+ import type { AttributeType, IError, ILocalizeInfo } from '../base/utils';
2
+ import type { IProductsEntity, IProductsResponse } from '../products/productsInterfaces';
3
+ /**
4
+ * Interface for managing and retrieving blocks in the system.
5
+ * @interface IBlocks
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.
11
+ * @description This interface defines methods for retrieving and managing blocks in the system.
12
+ */
13
+ interface IBlocks {
14
+ /**
15
+ * Retrieves all block objects of a specific type.
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.
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.
24
+ */
25
+ getBlocks(type: BlockType, langCode?: string, offset?: number, limit?: number): Promise<IBlocksResponse | IError>;
26
+ /**
27
+ * Retrieves a block object by its marker.
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.
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
+ */
37
+ getBlockByMarker(marker: string, langCode: string, offset?: number, limit?: number): Promise<IBlockEntity | IError>;
38
+ /**
39
+ * Performs a quick search for block objects with limited output.
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
+ * @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.
46
+ */
47
+ searchBlock(name: string, langCode?: string): Promise<ISearchBlock[] | IError>;
48
+ }
49
+ /**
50
+ * Represents a response from the blocks API.
51
+ * @interface IBlocksResponse
52
+ * @property {number} total - Total number of found records. Example: 100.
53
+ * @property {IBlockEntity[]} items - Array of block entities.
54
+ * @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.
85
+ */
86
+ interface IBlocksResponse {
87
+ items: IBlockEntity[];
88
+ total: number;
89
+ }
90
+ /**
91
+ * Represents a block entity with various attributes and properties.
92
+ * @interface IBlockEntity
93
+ * @property {AttributeType} attributeValues - Type of attributes used in the block.
94
+ * @example
95
+ {
96
+ "block-text": {
97
+ "type": "string",
98
+ "value": "some text",
99
+ "isIcon": false,
100
+ "position": 0,
101
+ "additionalFields": [],
102
+ "isProductPreview": false
103
+ }
104
+ }
105
+ * @property {number} id - Unique identifier of the block. Example: 1234.
106
+ * @property {ILocalizeInfo} localizeInfos - Localization information for the block.
107
+ * @example
108
+ {
109
+ "key": "value"
110
+ }
111
+ * @property {number} version - Version of the block entity. Example: 1.
112
+ * @property {string} identifier - Unique string identifier for the block. Example: "block1".
113
+ * @property {string} type - Type of the block, such as 'product', 'error_page', etc. Example: "product".
114
+ * @property {number} position - Position of the block for sorting. Example: 1.
115
+ * @property {string | null} templateIdentifier - Identifier for the template used by the block, or null if not applicable. Example: "template1".
116
+ * @property {boolean} isVisible - Indicates whether the block is visible. Example: true.
117
+ * @property {number} [countElementsPerRow] - Number of elements displayed per row in the block, if applicable. Example: 3.
118
+ * @property {number} [quantity] - Quantity of items in the block, if applicable. Example: 5.
119
+ * @property {IProductsResponse} [similarProducts] - Response containing similar products associated with the block.
120
+ * @example
121
+ {
122
+ "total": 10,
123
+ "items": []
124
+ }
125
+ * @property {IProductsEntity[]} [products] - Array of product entities associated with the block.
126
+ * @example
127
+ [
128
+ {
129
+ "id": 1,
130
+ "name": "Product 1"
131
+ },
132
+ {
133
+ "id": 2,
134
+ "name": "Product 2"
135
+ }
136
+ ]
137
+ * @description Represents a block entity with various attributes and properties.
138
+ */
139
+ interface IBlockEntity {
140
+ id: number;
141
+ localizeInfos: ILocalizeInfo;
142
+ version: number;
143
+ position: number;
144
+ identifier: string;
145
+ type: string;
146
+ templateIdentifier: string | null;
147
+ isVisible: boolean;
148
+ attributeValues: AttributeType;
149
+ similarProducts?: IProductsResponse;
150
+ countElementsPerRow?: number;
151
+ quantity?: number;
152
+ products?: IProductsEntity[];
153
+ }
154
+ /**
155
+ * Represents a search block entity with an identifier, name, and ID.
156
+ * @interface ISearchBlock
157
+ * @property {number} id - Unique identifier of the search block. Example: 1.
158
+ * @property {string} identifier - Unique string identifier for the search block. Example: "search_block_1".
159
+ * @property {string} name - Name of the search block. Example: "Search Block 1".
160
+ * @description Represents a search block entity with an identifier, name, and ID.
161
+ */
162
+ interface ISearchBlock {
163
+ id: number;
164
+ identifier: string;
165
+ name: string;
166
+ }
167
+ /**
168
+ * BlockType
169
+ * @type {BlockType}
170
+ * @description This type defines the possible values for block types used in the system.
171
+ */
172
+ type BlockType = 'product' | 'error_page' | 'catalog_page' | 'product_preview' | 'similar_products_block' | 'product_block' | 'form' | 'common_page' | 'common_block' | 'order' | 'service' | 'external_page' | 'discount' | 'none';
173
+ export type { BlockType, IBlockEntity, IBlocks, IBlocksResponse, ISearchBlock };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,187 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Block entity schema
4
+ * Includes all fields returned by the API
5
+ */
6
+ export declare const BlockEntitySchema: z.ZodObject<{
7
+ id: z.ZodNumber;
8
+ localizeInfos: z.ZodRecord<z.ZodString, z.ZodAny>;
9
+ version: z.ZodNumber;
10
+ position: z.ZodNumber;
11
+ identifier: z.ZodString;
12
+ type: z.ZodString;
13
+ templateIdentifier: z.ZodNullable<z.ZodString>;
14
+ isVisible: z.ZodBoolean;
15
+ attributeValues: z.ZodRecord<z.ZodString, z.ZodAny>;
16
+ similarProducts: z.ZodOptional<z.ZodObject<{
17
+ items: z.ZodArray<z.ZodObject<{
18
+ id: z.ZodNumber;
19
+ identifier: z.ZodNullable<z.ZodOptional<z.ZodString>>;
20
+ attributeSetIdentifier: z.ZodNullable<z.ZodOptional<z.ZodString>>;
21
+ localizeInfos: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
22
+ statusLocalizeInfos: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
23
+ isVisible: z.ZodOptional<z.ZodBoolean>;
24
+ statusIdentifier: z.ZodNullable<z.ZodOptional<z.ZodString>>;
25
+ position: z.ZodOptional<z.ZodNumber>;
26
+ isPositionLocked: z.ZodOptional<z.ZodBoolean>;
27
+ templateIdentifier: z.ZodNullable<z.ZodOptional<z.ZodString>>;
28
+ shortDescTemplateIdentifier: z.ZodNullable<z.ZodOptional<z.ZodString>>;
29
+ price: z.ZodNullable<z.ZodNumber>;
30
+ additional: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
31
+ sku: z.ZodNullable<z.ZodOptional<z.ZodString>>;
32
+ isSync: z.ZodOptional<z.ZodBoolean>;
33
+ categories: z.ZodOptional<z.ZodArray<z.ZodString>>;
34
+ attributeValues: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
35
+ productPages: z.ZodOptional<z.ZodArray<z.ZodAny>>;
36
+ blocks: z.ZodOptional<z.ZodArray<z.ZodString>>;
37
+ moduleFormConfigs: z.ZodOptional<z.ZodArray<z.ZodAny>>;
38
+ currency: z.ZodOptional<z.ZodString>;
39
+ images: z.ZodOptional<z.ZodArray<z.ZodObject<{
40
+ id: z.ZodNumber;
41
+ filename: z.ZodString;
42
+ url: z.ZodString;
43
+ size: z.ZodOptional<z.ZodNumber>;
44
+ type: z.ZodOptional<z.ZodString>;
45
+ }, z.core.$strip>>>;
46
+ relatedProducts: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
47
+ pageId: z.ZodOptional<z.ZodNumber>;
48
+ }, z.core.$strip>>;
49
+ total: z.ZodNumber;
50
+ }, z.core.$strip>>;
51
+ countElementsPerRow: z.ZodOptional<z.ZodNumber>;
52
+ quantity: z.ZodOptional<z.ZodNumber>;
53
+ products: z.ZodOptional<z.ZodArray<z.ZodObject<{
54
+ id: z.ZodNumber;
55
+ identifier: z.ZodNullable<z.ZodOptional<z.ZodString>>;
56
+ attributeSetIdentifier: z.ZodNullable<z.ZodOptional<z.ZodString>>;
57
+ localizeInfos: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
58
+ statusLocalizeInfos: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
59
+ isVisible: z.ZodOptional<z.ZodBoolean>;
60
+ statusIdentifier: z.ZodNullable<z.ZodOptional<z.ZodString>>;
61
+ position: z.ZodOptional<z.ZodNumber>;
62
+ isPositionLocked: z.ZodOptional<z.ZodBoolean>;
63
+ templateIdentifier: z.ZodNullable<z.ZodOptional<z.ZodString>>;
64
+ shortDescTemplateIdentifier: z.ZodNullable<z.ZodOptional<z.ZodString>>;
65
+ price: z.ZodNullable<z.ZodNumber>;
66
+ additional: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
67
+ sku: z.ZodNullable<z.ZodOptional<z.ZodString>>;
68
+ isSync: z.ZodOptional<z.ZodBoolean>;
69
+ categories: z.ZodOptional<z.ZodArray<z.ZodString>>;
70
+ attributeValues: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
71
+ productPages: z.ZodOptional<z.ZodArray<z.ZodAny>>;
72
+ blocks: z.ZodOptional<z.ZodArray<z.ZodString>>;
73
+ moduleFormConfigs: z.ZodOptional<z.ZodArray<z.ZodAny>>;
74
+ currency: z.ZodOptional<z.ZodString>;
75
+ images: z.ZodOptional<z.ZodArray<z.ZodObject<{
76
+ id: z.ZodNumber;
77
+ filename: z.ZodString;
78
+ url: z.ZodString;
79
+ size: z.ZodOptional<z.ZodNumber>;
80
+ type: z.ZodOptional<z.ZodString>;
81
+ }, z.core.$strip>>>;
82
+ relatedProducts: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
83
+ pageId: z.ZodOptional<z.ZodNumber>;
84
+ }, z.core.$strip>>>;
85
+ }, z.core.$strip>;
86
+ /**
87
+ * Blocks response schema
88
+ */
89
+ export declare const BlocksResponseSchema: z.ZodObject<{
90
+ items: z.ZodArray<z.ZodObject<{
91
+ id: z.ZodNumber;
92
+ localizeInfos: z.ZodRecord<z.ZodString, z.ZodAny>;
93
+ version: z.ZodNumber;
94
+ position: z.ZodNumber;
95
+ identifier: z.ZodString;
96
+ type: z.ZodString;
97
+ templateIdentifier: z.ZodNullable<z.ZodString>;
98
+ isVisible: z.ZodBoolean;
99
+ attributeValues: z.ZodRecord<z.ZodString, z.ZodAny>;
100
+ similarProducts: z.ZodOptional<z.ZodObject<{
101
+ items: z.ZodArray<z.ZodObject<{
102
+ id: z.ZodNumber;
103
+ identifier: z.ZodNullable<z.ZodOptional<z.ZodString>>;
104
+ attributeSetIdentifier: z.ZodNullable<z.ZodOptional<z.ZodString>>;
105
+ localizeInfos: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
106
+ statusLocalizeInfos: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
107
+ isVisible: z.ZodOptional<z.ZodBoolean>;
108
+ statusIdentifier: z.ZodNullable<z.ZodOptional<z.ZodString>>;
109
+ position: z.ZodOptional<z.ZodNumber>;
110
+ isPositionLocked: z.ZodOptional<z.ZodBoolean>;
111
+ templateIdentifier: z.ZodNullable<z.ZodOptional<z.ZodString>>;
112
+ shortDescTemplateIdentifier: z.ZodNullable<z.ZodOptional<z.ZodString>>;
113
+ price: z.ZodNullable<z.ZodNumber>;
114
+ additional: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
115
+ sku: z.ZodNullable<z.ZodOptional<z.ZodString>>;
116
+ isSync: z.ZodOptional<z.ZodBoolean>;
117
+ categories: z.ZodOptional<z.ZodArray<z.ZodString>>;
118
+ attributeValues: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
119
+ productPages: z.ZodOptional<z.ZodArray<z.ZodAny>>;
120
+ blocks: z.ZodOptional<z.ZodArray<z.ZodString>>;
121
+ moduleFormConfigs: z.ZodOptional<z.ZodArray<z.ZodAny>>;
122
+ currency: z.ZodOptional<z.ZodString>;
123
+ images: z.ZodOptional<z.ZodArray<z.ZodObject<{
124
+ id: z.ZodNumber;
125
+ filename: z.ZodString;
126
+ url: z.ZodString;
127
+ size: z.ZodOptional<z.ZodNumber>;
128
+ type: z.ZodOptional<z.ZodString>;
129
+ }, z.core.$strip>>>;
130
+ relatedProducts: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
131
+ pageId: z.ZodOptional<z.ZodNumber>;
132
+ }, z.core.$strip>>;
133
+ total: z.ZodNumber;
134
+ }, z.core.$strip>>;
135
+ countElementsPerRow: z.ZodOptional<z.ZodNumber>;
136
+ quantity: z.ZodOptional<z.ZodNumber>;
137
+ products: z.ZodOptional<z.ZodArray<z.ZodObject<{
138
+ id: z.ZodNumber;
139
+ identifier: z.ZodNullable<z.ZodOptional<z.ZodString>>;
140
+ attributeSetIdentifier: z.ZodNullable<z.ZodOptional<z.ZodString>>;
141
+ localizeInfos: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
142
+ statusLocalizeInfos: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
143
+ isVisible: z.ZodOptional<z.ZodBoolean>;
144
+ statusIdentifier: z.ZodNullable<z.ZodOptional<z.ZodString>>;
145
+ position: z.ZodOptional<z.ZodNumber>;
146
+ isPositionLocked: z.ZodOptional<z.ZodBoolean>;
147
+ templateIdentifier: z.ZodNullable<z.ZodOptional<z.ZodString>>;
148
+ shortDescTemplateIdentifier: z.ZodNullable<z.ZodOptional<z.ZodString>>;
149
+ price: z.ZodNullable<z.ZodNumber>;
150
+ additional: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
151
+ sku: z.ZodNullable<z.ZodOptional<z.ZodString>>;
152
+ isSync: z.ZodOptional<z.ZodBoolean>;
153
+ categories: z.ZodOptional<z.ZodArray<z.ZodString>>;
154
+ attributeValues: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
155
+ productPages: z.ZodOptional<z.ZodArray<z.ZodAny>>;
156
+ blocks: z.ZodOptional<z.ZodArray<z.ZodString>>;
157
+ moduleFormConfigs: z.ZodOptional<z.ZodArray<z.ZodAny>>;
158
+ currency: z.ZodOptional<z.ZodString>;
159
+ images: z.ZodOptional<z.ZodArray<z.ZodObject<{
160
+ id: z.ZodNumber;
161
+ filename: z.ZodString;
162
+ url: z.ZodString;
163
+ size: z.ZodOptional<z.ZodNumber>;
164
+ type: z.ZodOptional<z.ZodString>;
165
+ }, z.core.$strip>>>;
166
+ relatedProducts: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
167
+ pageId: z.ZodOptional<z.ZodNumber>;
168
+ }, z.core.$strip>>>;
169
+ }, z.core.$strip>>;
170
+ total: z.ZodNumber;
171
+ }, z.core.$strip>;
172
+ /**
173
+ * Search block schema
174
+ */
175
+ export declare const SearchBlockSchema: z.ZodObject<{
176
+ id: z.ZodNumber;
177
+ identifier: z.ZodString;
178
+ name: z.ZodString;
179
+ }, z.core.$strip>;
180
+ /**
181
+ * Search blocks response schema
182
+ */
183
+ export declare const SearchBlocksResponseSchema: z.ZodArray<z.ZodObject<{
184
+ id: z.ZodNumber;
185
+ identifier: z.ZodString;
186
+ name: z.ZodString;
187
+ }, z.core.$strip>>;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SearchBlocksResponseSchema = exports.SearchBlockSchema = exports.BlocksResponseSchema = exports.BlockEntitySchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const productsSchemas_1 = require("../products/productsSchemas");
6
+ /**
7
+ * Block entity schema
8
+ * Includes all fields returned by the API
9
+ */
10
+ exports.BlockEntitySchema = zod_1.z.object({
11
+ id: zod_1.z.number(),
12
+ localizeInfos: zod_1.z.record(zod_1.z.string(), zod_1.z.any()),
13
+ version: zod_1.z.number(),
14
+ position: zod_1.z.number(),
15
+ identifier: zod_1.z.string(),
16
+ type: zod_1.z.string(),
17
+ templateIdentifier: zod_1.z.string().nullable(),
18
+ isVisible: zod_1.z.boolean(),
19
+ attributeValues: zod_1.z.record(zod_1.z.string(), zod_1.z.any()),
20
+ similarProducts: productsSchemas_1.ProductsResponseSchema.optional(),
21
+ countElementsPerRow: zod_1.z.number().optional(),
22
+ quantity: zod_1.z.number().optional(),
23
+ products: zod_1.z.array(productsSchemas_1.ProductEntitySchema).optional(),
24
+ });
25
+ /**
26
+ * Blocks response schema
27
+ */
28
+ exports.BlocksResponseSchema = zod_1.z.object({
29
+ items: zod_1.z.array(exports.BlockEntitySchema),
30
+ total: zod_1.z.number(),
31
+ });
32
+ /**
33
+ * Search block schema
34
+ */
35
+ exports.SearchBlockSchema = zod_1.z.object({
36
+ id: zod_1.z.number(),
37
+ identifier: zod_1.z.string(),
38
+ name: zod_1.z.string(),
39
+ });
40
+ /**
41
+ * Search blocks response schema
42
+ */
43
+ exports.SearchBlocksResponseSchema = zod_1.z.array(exports.SearchBlockSchema);
@@ -0,0 +1,56 @@
1
+ import AsyncModules from '../base/asyncModules';
2
+ import type StateModule from '../base/stateModule';
3
+ import type { IError } from '../base/utils';
4
+ import type { ICouponValidationResult, IDiscountsApi, IDiscountsEntity, IDiscountsResponse } from './discountsInterfaces';
5
+ /**
6
+ * Controllers for working with events
7
+ * @handle /api/content/events
8
+ * @class DiscountsApi
9
+ * @augments AsyncModules
10
+ * @implements {IDiscountsApi}
11
+ * @description This class provides methods to interact with events, including subscribing and unsubscribing to product events, and retrieving all subscriptions.
12
+ */
13
+ export default class DiscountsApi extends AsyncModules implements IDiscountsApi {
14
+ protected state: StateModule;
15
+ protected _url: string;
16
+ /**
17
+ * Initializes the Constructor for DiscountsApi class with the provided state module.
18
+ * @class DiscountsApi
19
+ * @augments AsyncModules
20
+ * @implements {DiscountsApi}
21
+ * @param {StateModule} state - The state module containing the base URL and other configurations.
22
+ * @description Initializes the DiscountsApi with the provided state module.
23
+ */
24
+ constructor(state: StateModule);
25
+ /**
26
+ * Return all discounts.
27
+ * @handleName getAllDiscounts
28
+ * @param {string} [langCode] - Language code. Default: "en_US".
29
+ * @param {number} [offset] - Optional parameter for pagination. Default: 0.
30
+ * @param {number} [limit] - Optional parameter for pagination. Default: 30.
31
+ * @param {string} [type] - Optional parameter to filter discounts by type.
32
+ * @returns {Promise<IDiscountsResponse | IError>} Returns an object containing all discounts or an error object if there was an issue.
33
+ * @throws {IError} When isShell=false and an error occurs during the fetch
34
+ * @description Fetches all discounts from the server.
35
+ */
36
+ getAllDiscounts(langCode?: string, offset?: number, limit?: number, type?: 'DISCOUNT' | 'BONUS' | 'PERSONAL_DISCOUNT' | 'PERSONAL_BONUS'): Promise<IDiscountsResponse | IError>;
37
+ /**
38
+ * Get discount by marker
39
+ * @handleName getDiscountByMarker
40
+ * @param {string} marker - Textual identifier of the discount storage object. Example: "discount_storage".
41
+ * @param {string} [langCode] - Language code. Default: "en_US".
42
+ * @returns {Promise<IDiscountsEntity | IError>} Returns an object containing discount by marker or an error object if there was an issue.
43
+ * @throws {IError} When isShell=false and an error occurs during the fetch
44
+ * @description Fetches a discount by its marker.
45
+ */
46
+ getDiscountByMarker(marker: string, langCode?: string): Promise<IDiscountsEntity | IError>;
47
+ /**
48
+ * Validate discounts coupon
49
+ * @handleName validateDiscountsCoupon
50
+ * @param {string} code - The coupon code to validate.
51
+ * @returns {Promise<ICouponValidationResult | IError>} Returns an coupon validation result or an error object if there was an issue.
52
+ * @throws {IError} When isShell=false and an error occurs during the fetch
53
+ * @description This function validates a coupon code and returns the result.
54
+ */
55
+ validateDiscountsCoupon(code: string): Promise<ICouponValidationResult | IError>;
56
+ }