oneentry 1.0.142 → 1.0.144

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 (150) hide show
  1. package/configure.js +2 -2
  2. package/dist/admins/adminsApi.d.ts +50 -0
  3. package/dist/admins/adminsApi.js +65 -0
  4. package/dist/admins/adminsInterfaces.d.ts +98 -0
  5. package/dist/admins/adminsInterfaces.js +2 -0
  6. package/dist/admins/adminsSchemas.d.ts +30 -0
  7. package/dist/admins/adminsSchemas.js +27 -0
  8. package/dist/attribute-sets/attributeSetsApi.d.ts +63 -0
  9. package/dist/attribute-sets/attributeSetsApi.js +98 -0
  10. package/dist/attribute-sets/attributeSetsInterfaces.d.ts +185 -0
  11. package/dist/attribute-sets/attributeSetsInterfaces.js +2 -0
  12. package/dist/attribute-sets/attributeSetsSchemas.d.ts +90 -0
  13. package/dist/attribute-sets/attributeSetsSchemas.js +74 -0
  14. package/dist/auth-provider/authProviderApi.d.ts +249 -0
  15. package/dist/auth-provider/authProviderApi.js +354 -0
  16. package/dist/auth-provider/authProviderSchemas.d.ts +131 -0
  17. package/dist/auth-provider/authProviderSchemas.js +82 -0
  18. package/dist/auth-provider/authProvidersInterfaces.d.ts +412 -0
  19. package/dist/auth-provider/authProvidersInterfaces.js +2 -0
  20. package/dist/base/asyncModules.d.ts +80 -0
  21. package/dist/base/asyncModules.js +448 -0
  22. package/dist/base/result.d.ts +39 -0
  23. package/dist/base/result.js +154 -0
  24. package/dist/base/stateModule.d.ts +41 -0
  25. package/dist/base/stateModule.js +128 -0
  26. package/dist/base/syncModules.d.ts +286 -0
  27. package/dist/base/syncModules.js +716 -0
  28. package/dist/base/utils.d.ts +197 -0
  29. package/dist/base/utils.js +2 -0
  30. package/dist/base/validation.d.ts +118 -0
  31. package/dist/base/validation.js +132 -0
  32. package/dist/blocks/blocksApi.d.ts +88 -0
  33. package/dist/blocks/blocksApi.js +207 -0
  34. package/dist/blocks/blocksInterfaces.d.ts +179 -0
  35. package/dist/blocks/blocksInterfaces.js +2 -0
  36. package/dist/blocks/blocksSchemas.d.ts +195 -0
  37. package/dist/blocks/blocksSchemas.js +43 -0
  38. package/dist/discounts/discountsApi.d.ts +76 -0
  39. package/dist/discounts/discountsApi.js +116 -0
  40. package/dist/discounts/discountsInterfaces.d.ts +217 -0
  41. package/dist/discounts/discountsInterfaces.js +2 -0
  42. package/dist/events/eventsApi.d.ts +60 -0
  43. package/dist/events/eventsApi.js +97 -0
  44. package/dist/events/eventsInterfaces.d.ts +87 -0
  45. package/dist/events/eventsInterfaces.js +2 -0
  46. package/dist/file-uploading/fileUploadingApi.d.ts +88 -0
  47. package/dist/file-uploading/fileUploadingApi.js +129 -0
  48. package/dist/file-uploading/fileUploadingInterfaces.d.ts +114 -0
  49. package/dist/file-uploading/fileUploadingInterfaces.js +2 -0
  50. package/dist/file-uploading/fileUploadingSchemas.d.ts +22 -0
  51. package/dist/file-uploading/fileUploadingSchemas.js +21 -0
  52. package/dist/forms/formsApi.d.ts +42 -0
  53. package/dist/forms/formsApi.js +57 -0
  54. package/dist/forms/formsInterfaces.d.ts +144 -0
  55. package/dist/forms/formsInterfaces.js +2 -0
  56. package/dist/forms/formsSchemas.d.ts +53 -0
  57. package/dist/forms/formsSchemas.js +34 -0
  58. package/dist/forms-data/formsDataApi.d.ts +106 -0
  59. package/dist/forms-data/formsDataApi.js +189 -0
  60. package/dist/forms-data/formsDataInterfaces.d.ts +522 -0
  61. package/dist/forms-data/formsDataInterfaces.js +2 -0
  62. package/dist/forms-data/formsDataSchemas.d.ts +115 -0
  63. package/dist/forms-data/formsDataSchemas.js +86 -0
  64. package/dist/general-types/generalTypesApi.d.ts +28 -0
  65. package/dist/general-types/generalTypesApi.js +38 -0
  66. package/dist/general-types/generalTypesInterfaces.d.ts +29 -0
  67. package/dist/general-types/generalTypesInterfaces.js +2 -0
  68. package/dist/general-types/generalTypesSchemas.d.ts +52 -0
  69. package/dist/general-types/generalTypesSchemas.js +36 -0
  70. package/dist/index.d.ts +124 -0
  71. package/dist/index.js +103 -0
  72. package/dist/integration-collections/integrationCollectionsApi.d.ts +163 -0
  73. package/dist/integration-collections/integrationCollectionsApi.js +220 -0
  74. package/dist/integration-collections/integrationCollectionsInterfaces.d.ts +313 -0
  75. package/dist/integration-collections/integrationCollectionsInterfaces.js +2 -0
  76. package/dist/integration-collections/integrationCollectionsSchemas.d.ts +80 -0
  77. package/dist/integration-collections/integrationCollectionsSchemas.js +61 -0
  78. package/dist/locales/localesApi.d.ts +27 -0
  79. package/dist/locales/localesApi.js +37 -0
  80. package/dist/locales/localesInterfaces.d.ts +40 -0
  81. package/dist/locales/localesInterfaces.js +2 -0
  82. package/dist/locales/localesSchemas.d.ts +32 -0
  83. package/dist/locales/localesSchemas.js +26 -0
  84. package/dist/menus/menusApi.d.ts +29 -0
  85. package/dist/menus/menusApi.js +39 -0
  86. package/dist/menus/menusInterfaces.d.ts +87 -0
  87. package/dist/menus/menusInterfaces.js +3 -0
  88. package/dist/menus/menusSchemas.d.ts +16 -0
  89. package/dist/menus/menusSchemas.js +28 -0
  90. package/dist/orders/ordersApi.d.ts +175 -0
  91. package/dist/orders/ordersApi.js +247 -0
  92. package/dist/orders/ordersInterfaces.d.ts +593 -0
  93. package/dist/orders/ordersInterfaces.js +2 -0
  94. package/dist/orders/ordersSchemas.d.ts +120 -0
  95. package/dist/orders/ordersSchemas.js +101 -0
  96. package/dist/pages/pagesApi.d.ts +151 -0
  97. package/dist/pages/pagesApi.js +390 -0
  98. package/dist/pages/pagesInterfaces.d.ts +286 -0
  99. package/dist/pages/pagesInterfaces.js +2 -0
  100. package/dist/pages/pagesSchemas.d.ts +85 -0
  101. package/dist/pages/pagesSchemas.js +46 -0
  102. package/dist/payments/paymentsApi.d.ts +82 -0
  103. package/dist/payments/paymentsApi.js +121 -0
  104. package/dist/payments/paymentsInterfaces.d.ts +200 -0
  105. package/dist/payments/paymentsInterfaces.js +2 -0
  106. package/dist/payments/paymentsSchemas.d.ts +100 -0
  107. package/dist/payments/paymentsSchemas.js +65 -0
  108. package/dist/product-statuses/productStatusesApi.d.ts +47 -0
  109. package/dist/product-statuses/productStatusesApi.js +70 -0
  110. package/dist/product-statuses/productStatusesInterfaces.d.ts +62 -0
  111. package/dist/product-statuses/productStatusesInterfaces.js +2 -0
  112. package/dist/product-statuses/productStatusesSchemas.d.ts +34 -0
  113. package/dist/product-statuses/productStatusesSchemas.js +30 -0
  114. package/dist/products/productsApi.d.ts +366 -0
  115. package/dist/products/productsApi.js +458 -0
  116. package/dist/products/productsInterfaces.d.ts +593 -0
  117. package/dist/products/productsInterfaces.js +2 -0
  118. package/dist/products/productsSchemas.d.ts +200 -0
  119. package/dist/products/productsSchemas.js +98 -0
  120. package/dist/sitemap/sitemapApi.d.ts +35 -0
  121. package/dist/sitemap/sitemapApi.js +45 -0
  122. package/dist/sitemap/sitemapInterfaces.d.ts +40 -0
  123. package/dist/sitemap/sitemapInterfaces.js +2 -0
  124. package/dist/system/systemApi.d.ts +43 -0
  125. package/dist/system/systemApi.js +56 -0
  126. package/dist/system/systemInterfaces.d.ts +29 -0
  127. package/dist/system/systemInterfaces.js +2 -0
  128. package/dist/templates/templatesApi.d.ts +49 -0
  129. package/dist/templates/templatesApi.js +75 -0
  130. package/dist/templates/templatesInterfaces.d.ts +67 -0
  131. package/dist/templates/templatesInterfaces.js +2 -0
  132. package/dist/templates/templatesSchemas.d.ts +48 -0
  133. package/dist/templates/templatesSchemas.js +31 -0
  134. package/dist/templates-preview/templatesPreviewApi.d.ts +38 -0
  135. package/dist/templates-preview/templatesPreviewApi.js +53 -0
  136. package/dist/templates-preview/templatesPreviewInterfaces.d.ts +119 -0
  137. package/dist/templates-preview/templatesPreviewInterfaces.js +2 -0
  138. package/dist/templates-preview/templatesPreviewSchemas.d.ts +83 -0
  139. package/dist/templates-preview/templatesPreviewSchemas.js +48 -0
  140. package/dist/users/usersApi.d.ts +143 -0
  141. package/dist/users/usersApi.js +171 -0
  142. package/dist/users/usersInterfaces.d.ts +231 -0
  143. package/dist/users/usersInterfaces.js +2 -0
  144. package/dist/users/usersSchemas.d.ts +38 -0
  145. package/dist/users/usersSchemas.js +28 -0
  146. package/dist/web-socket/wsApi.d.ts +25 -0
  147. package/dist/web-socket/wsApi.js +45 -0
  148. package/dist/web-socket/wsInterfaces.d.ts +16 -0
  149. package/dist/web-socket/wsInterfaces.js +2 -0
  150. package/package.json +2 -80
@@ -0,0 +1,207 @@
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
+ * Get frequently ordered products by block marker and product id.
175
+ * @handleName getFrequentlyOrderedProducts
176
+ * @param {number} productId - Product id. Example: 1.
177
+ * @param {string} marker - Block marker. Example: "frequently_ordered_block".
178
+ * @param {string} [langCode] - Language code. Default: "en_US".
179
+ * @param {string} [signPrice] - Sign price.
180
+ * @returns {Promise<IProductsEntity[] | IError>} Returns array of ProductEntity objects.
181
+ * @throws {IError} When isShell=false and an error occurs during the fetch
182
+ */
183
+ async getFrequentlyOrderedProducts(productId, marker, langCode = this.state.lang, signPrice) {
184
+ const query = {
185
+ langCode,
186
+ signPrice,
187
+ };
188
+ const data = await this._fetchGet(`/${marker}/products/${productId}/frequently-ordered?` +
189
+ this._queryParamsToString(query));
190
+ return this._normalizeData(data);
191
+ }
192
+ /**
193
+ * Quick search for block objects with limited output.
194
+ * @handleName searchBlock
195
+ * @param {string} name - Search string. Example: "product_block".
196
+ * @param {string} [langCode] - Language code. Default: "en_US".
197
+ * @returns {Promise<ISearchBlock[] | IError>} Returns an array of ISearchBlock objects.
198
+ * @throws {IError} When isShell=false and an error occurs during the fetch
199
+ */
200
+ async searchBlock(name, langCode = this.state.lang) {
201
+ const result = await this._fetchGet(`/quick/search?langCode=${langCode}&name=${name}`);
202
+ // Validate response if validation is enabled
203
+ const validated = this._validateResponse(result, blocksSchemas_1.SearchBlocksResponseSchema);
204
+ return validated;
205
+ }
206
+ }
207
+ exports.default = BlocksApi;
@@ -0,0 +1,179 @@
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
+ * @description This interface defines methods for retrieving and managing blocks in the system.
7
+ */
8
+ interface IBlocks {
9
+ /**
10
+ * Retrieves all block objects of a specific type.
11
+ * @handleName getBlocks
12
+ * @param {BlockType} type - The type of blocks to retrieve. Example: "product".
13
+ * @param {string} [langCode] - Optional language code for localization. Default: "en_US".
14
+ * @param {number} [offset] - Optional offset for pagination. Default: 0.
15
+ * @param {number} [limit] - Optional limit for pagination. Default: 30.
16
+ * @returns {IBlocksResponse} A promise that resolves to a blocks response or an error.
17
+ * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
18
+ * @description This method retrieves all block objects of a specific type.
19
+ */
20
+ getBlocks(type: BlockType, langCode?: string, offset?: number, limit?: number): Promise<IBlocksResponse | IError>;
21
+ /**
22
+ * Retrieves a block object by its marker.
23
+ * @handleName getBlockByMarker
24
+ * @param {string} marker - The marker identifying the block. Example: "product_block".
25
+ * @param {string} langCode - Language code for localization. Default: "en_US".
26
+ * @param {number} [offset] - Optional offset for pagination. Default: 0.
27
+ * @param {number} [limit] - Optional limit for pagination. Default: 30.
28
+ * @returns {IBlockEntity} A promise that resolves to a block entity or an error.
29
+ * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
30
+ * @description This method retrieves a block object by its marker.
31
+ */
32
+ getBlockByMarker(marker: string, langCode: string, offset?: number, limit?: number): Promise<IBlockEntity | IError>;
33
+ /**
34
+ * Performs a quick search for block objects with limited output.
35
+ * @handleName searchBlock
36
+ * @param {string} name - The name to search for. Example: "product_block".
37
+ * @param {string} [langCode] - Optional language code for localization. Default: "en_US".
38
+ * @returns {ISearchBlock[]} A promise that resolves to an array of search blocks or an error.
39
+ * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
40
+ * @description This method performs a quick search for block objects with limited output.
41
+ */
42
+ searchBlock(name: string, langCode?: string): Promise<ISearchBlock[] | IError>;
43
+ /**
44
+ * Get frequently ordered products by block marker and product id.
45
+ * @handleName getFrequentlyOrderedProducts
46
+ * @param {number} productId - Product id. Example: 1.
47
+ * @param {string} marker - Block marker. Example: "frequently_ordered_block".
48
+ * @param {string} [langCode] - Language code. Default: "en_US".
49
+ * @param {string} [signPrice] - Sign price.
50
+ * @returns {IProductsEntity[]} A promise that resolves to an array of product entities or an error.
51
+ * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
52
+ */
53
+ getFrequentlyOrderedProducts(productId: number, marker: string, langCode?: string, signPrice?: string): Promise<IProductsEntity[] | IError>;
54
+ }
55
+ /**
56
+ * Represents a response from the blocks API.
57
+ * @interface IBlocksResponse
58
+ * @property {number} total - Total number of found records. Example: 100.
59
+ * @property {IBlockEntity[]} items - Array of block entities.
60
+ * @example
61
+ [
62
+ {
63
+ "attributeValues": [],
64
+ "id": 1,
65
+ "identifier": "block1",
66
+ "isVisible": true,
67
+ "localizeInfos": { "key": "value" },
68
+ "position": 1,
69
+ "templateIdentifier": null,
70
+ "type": "product",
71
+ "version": 1,
72
+ "countElementsPerRow": 3,
73
+ "quantity": 9,
74
+ "similarProducts": {
75
+ "total": 0,
76
+ "items": []
77
+ },
78
+ "products": [
79
+ {
80
+ "id": 1,
81
+ "name": "Product 1"
82
+ },
83
+ {
84
+ "id": 2,
85
+ "name": "Product 2"
86
+ }
87
+ ]
88
+ }
89
+ ]
90
+ * @description Represents a response from the blocks API containing a total count and an array of block entities.
91
+ */
92
+ interface IBlocksResponse {
93
+ items: IBlockEntity[];
94
+ total: number;
95
+ }
96
+ /**
97
+ * Represents a block entity with various attributes and properties.
98
+ * @interface IBlockEntity
99
+ * @property {AttributeType} attributeValues - Type of attributes used in the block.
100
+ * @example
101
+ {
102
+ "block-text": {
103
+ "type": "string",
104
+ "value": "some text",
105
+ "isIcon": false,
106
+ "position": 0,
107
+ "additionalFields": [],
108
+ "isProductPreview": false
109
+ }
110
+ }
111
+ * @property {number} id - Unique identifier of the block. Example: 1234.
112
+ * @property {ILocalizeInfo} localizeInfos - Localization information for the block.
113
+ * @example
114
+ {
115
+ "key": "value"
116
+ }
117
+ * @property {number} version - Version of the block entity. Example: 1.
118
+ * @property {string} identifier - Unique string identifier for the block. Example: "block1".
119
+ * @property {string} type - Type of the block, such as 'product', 'error_page', etc. Example: "product".
120
+ * @property {number} position - Position of the block for sorting. Example: 1.
121
+ * @property {string | null} templateIdentifier - Identifier for the template used by the block, or null if not applicable. Example: "template1".
122
+ * @property {boolean} isVisible - Indicates whether the block is visible. Example: true.
123
+ * @property {number} [countElementsPerRow] - Number of elements displayed per row in the block, if applicable. Example: 3.
124
+ * @property {number} [quantity] - Quantity of items in the block, if applicable. Example: 5.
125
+ * @property {IProductsResponse} [similarProducts] - Response containing similar products associated with the block.
126
+ * @example
127
+ {
128
+ "total": 10,
129
+ "items": []
130
+ }
131
+ * @property {IProductsEntity[]} [products] - Array of product entities associated with the block.
132
+ * @example
133
+ [
134
+ {
135
+ "id": 1,
136
+ "name": "Product 1"
137
+ },
138
+ {
139
+ "id": 2,
140
+ "name": "Product 2"
141
+ }
142
+ ]
143
+ * @description Represents a block entity with various attributes and properties.
144
+ */
145
+ interface IBlockEntity {
146
+ id: number;
147
+ localizeInfos: ILocalizeInfo;
148
+ version: number;
149
+ position: number;
150
+ identifier: string;
151
+ type: string;
152
+ templateIdentifier: string | null;
153
+ isVisible: boolean;
154
+ attributeValues: AttributeType;
155
+ similarProducts?: IProductsResponse;
156
+ countElementsPerRow?: number;
157
+ quantity?: number;
158
+ products?: IProductsEntity[];
159
+ }
160
+ /**
161
+ * Represents a search block entity with an identifier, name, and ID.
162
+ * @interface ISearchBlock
163
+ * @property {number} id - Unique identifier of the search block. Example: 1.
164
+ * @property {string} identifier - Unique string identifier for the search block. Example: "search_block_1".
165
+ * @property {string} name - Name of the search block. Example: "Search Block 1".
166
+ * @description Represents a search block entity with an identifier, name, and ID.
167
+ */
168
+ interface ISearchBlock {
169
+ id: number;
170
+ identifier: string;
171
+ name: string;
172
+ }
173
+ /**
174
+ * BlockType
175
+ * @type {BlockType}
176
+ * @description This type defines the possible values for block types used in the system.
177
+ */
178
+ type BlockType = 'product' | 'error_page' | 'catalog_page' | 'product_preview' | 'similar_products_block' | 'product_block' | 'frequently_ordered_block' | 'form' | 'common_page' | 'common_block' | 'order' | 'service' | 'external_page' | 'discount' | 'none';
179
+ export type { BlockType, IBlockEntity, IBlocks, IBlocksResponse, ISearchBlock };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,195 @@
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
+ paymentStages: z.ZodNullable<z.ZodOptional<z.ZodAny>>;
49
+ discountConfig: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
50
+ }, z.core.$strip>>;
51
+ total: z.ZodNumber;
52
+ }, z.core.$strip>>;
53
+ countElementsPerRow: z.ZodOptional<z.ZodNumber>;
54
+ quantity: z.ZodOptional<z.ZodNumber>;
55
+ products: z.ZodOptional<z.ZodArray<z.ZodObject<{
56
+ id: z.ZodNumber;
57
+ identifier: z.ZodNullable<z.ZodOptional<z.ZodString>>;
58
+ attributeSetIdentifier: z.ZodNullable<z.ZodOptional<z.ZodString>>;
59
+ localizeInfos: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
60
+ statusLocalizeInfos: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
61
+ isVisible: z.ZodOptional<z.ZodBoolean>;
62
+ statusIdentifier: z.ZodNullable<z.ZodOptional<z.ZodString>>;
63
+ position: z.ZodOptional<z.ZodNumber>;
64
+ isPositionLocked: z.ZodOptional<z.ZodBoolean>;
65
+ templateIdentifier: z.ZodNullable<z.ZodOptional<z.ZodString>>;
66
+ shortDescTemplateIdentifier: z.ZodNullable<z.ZodOptional<z.ZodString>>;
67
+ price: z.ZodNullable<z.ZodNumber>;
68
+ additional: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
69
+ sku: z.ZodNullable<z.ZodOptional<z.ZodString>>;
70
+ isSync: z.ZodOptional<z.ZodBoolean>;
71
+ categories: z.ZodOptional<z.ZodArray<z.ZodString>>;
72
+ attributeValues: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
73
+ productPages: z.ZodOptional<z.ZodArray<z.ZodAny>>;
74
+ blocks: z.ZodOptional<z.ZodArray<z.ZodString>>;
75
+ moduleFormConfigs: z.ZodOptional<z.ZodArray<z.ZodAny>>;
76
+ currency: z.ZodOptional<z.ZodString>;
77
+ images: z.ZodOptional<z.ZodArray<z.ZodObject<{
78
+ id: z.ZodNumber;
79
+ filename: z.ZodString;
80
+ url: z.ZodString;
81
+ size: z.ZodOptional<z.ZodNumber>;
82
+ type: z.ZodOptional<z.ZodString>;
83
+ }, z.core.$strip>>>;
84
+ relatedProducts: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
85
+ pageId: z.ZodOptional<z.ZodNumber>;
86
+ paymentStages: z.ZodNullable<z.ZodOptional<z.ZodAny>>;
87
+ discountConfig: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
88
+ }, z.core.$strip>>>;
89
+ }, z.core.$strip>;
90
+ /**
91
+ * Blocks response schema
92
+ */
93
+ export declare const BlocksResponseSchema: z.ZodObject<{
94
+ items: z.ZodArray<z.ZodObject<{
95
+ id: z.ZodNumber;
96
+ localizeInfos: z.ZodRecord<z.ZodString, z.ZodAny>;
97
+ version: z.ZodNumber;
98
+ position: z.ZodNumber;
99
+ identifier: z.ZodString;
100
+ type: z.ZodString;
101
+ templateIdentifier: z.ZodNullable<z.ZodString>;
102
+ isVisible: z.ZodBoolean;
103
+ attributeValues: z.ZodRecord<z.ZodString, z.ZodAny>;
104
+ similarProducts: z.ZodOptional<z.ZodObject<{
105
+ items: z.ZodArray<z.ZodObject<{
106
+ id: z.ZodNumber;
107
+ identifier: z.ZodNullable<z.ZodOptional<z.ZodString>>;
108
+ attributeSetIdentifier: z.ZodNullable<z.ZodOptional<z.ZodString>>;
109
+ localizeInfos: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
110
+ statusLocalizeInfos: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
111
+ isVisible: z.ZodOptional<z.ZodBoolean>;
112
+ statusIdentifier: z.ZodNullable<z.ZodOptional<z.ZodString>>;
113
+ position: z.ZodOptional<z.ZodNumber>;
114
+ isPositionLocked: z.ZodOptional<z.ZodBoolean>;
115
+ templateIdentifier: z.ZodNullable<z.ZodOptional<z.ZodString>>;
116
+ shortDescTemplateIdentifier: z.ZodNullable<z.ZodOptional<z.ZodString>>;
117
+ price: z.ZodNullable<z.ZodNumber>;
118
+ additional: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
119
+ sku: z.ZodNullable<z.ZodOptional<z.ZodString>>;
120
+ isSync: z.ZodOptional<z.ZodBoolean>;
121
+ categories: z.ZodOptional<z.ZodArray<z.ZodString>>;
122
+ attributeValues: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
123
+ productPages: z.ZodOptional<z.ZodArray<z.ZodAny>>;
124
+ blocks: z.ZodOptional<z.ZodArray<z.ZodString>>;
125
+ moduleFormConfigs: z.ZodOptional<z.ZodArray<z.ZodAny>>;
126
+ currency: z.ZodOptional<z.ZodString>;
127
+ images: z.ZodOptional<z.ZodArray<z.ZodObject<{
128
+ id: z.ZodNumber;
129
+ filename: z.ZodString;
130
+ url: z.ZodString;
131
+ size: z.ZodOptional<z.ZodNumber>;
132
+ type: z.ZodOptional<z.ZodString>;
133
+ }, z.core.$strip>>>;
134
+ relatedProducts: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
135
+ pageId: z.ZodOptional<z.ZodNumber>;
136
+ paymentStages: z.ZodNullable<z.ZodOptional<z.ZodAny>>;
137
+ discountConfig: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
138
+ }, z.core.$strip>>;
139
+ total: z.ZodNumber;
140
+ }, z.core.$strip>>;
141
+ countElementsPerRow: z.ZodOptional<z.ZodNumber>;
142
+ quantity: z.ZodOptional<z.ZodNumber>;
143
+ products: z.ZodOptional<z.ZodArray<z.ZodObject<{
144
+ id: z.ZodNumber;
145
+ identifier: z.ZodNullable<z.ZodOptional<z.ZodString>>;
146
+ attributeSetIdentifier: z.ZodNullable<z.ZodOptional<z.ZodString>>;
147
+ localizeInfos: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
148
+ statusLocalizeInfos: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
149
+ isVisible: z.ZodOptional<z.ZodBoolean>;
150
+ statusIdentifier: z.ZodNullable<z.ZodOptional<z.ZodString>>;
151
+ position: z.ZodOptional<z.ZodNumber>;
152
+ isPositionLocked: z.ZodOptional<z.ZodBoolean>;
153
+ templateIdentifier: z.ZodNullable<z.ZodOptional<z.ZodString>>;
154
+ shortDescTemplateIdentifier: z.ZodNullable<z.ZodOptional<z.ZodString>>;
155
+ price: z.ZodNullable<z.ZodNumber>;
156
+ additional: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
157
+ sku: z.ZodNullable<z.ZodOptional<z.ZodString>>;
158
+ isSync: z.ZodOptional<z.ZodBoolean>;
159
+ categories: z.ZodOptional<z.ZodArray<z.ZodString>>;
160
+ attributeValues: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
161
+ productPages: z.ZodOptional<z.ZodArray<z.ZodAny>>;
162
+ blocks: z.ZodOptional<z.ZodArray<z.ZodString>>;
163
+ moduleFormConfigs: z.ZodOptional<z.ZodArray<z.ZodAny>>;
164
+ currency: z.ZodOptional<z.ZodString>;
165
+ images: z.ZodOptional<z.ZodArray<z.ZodObject<{
166
+ id: z.ZodNumber;
167
+ filename: z.ZodString;
168
+ url: z.ZodString;
169
+ size: z.ZodOptional<z.ZodNumber>;
170
+ type: z.ZodOptional<z.ZodString>;
171
+ }, z.core.$strip>>>;
172
+ relatedProducts: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
173
+ pageId: z.ZodOptional<z.ZodNumber>;
174
+ paymentStages: z.ZodNullable<z.ZodOptional<z.ZodAny>>;
175
+ discountConfig: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
176
+ }, z.core.$strip>>>;
177
+ }, z.core.$strip>>;
178
+ total: z.ZodNumber;
179
+ }, z.core.$strip>;
180
+ /**
181
+ * Search block schema
182
+ */
183
+ export declare const SearchBlockSchema: z.ZodObject<{
184
+ id: z.ZodNumber;
185
+ identifier: z.ZodString;
186
+ name: z.ZodString;
187
+ }, z.core.$strip>;
188
+ /**
189
+ * Search blocks response schema
190
+ */
191
+ export declare const SearchBlocksResponseSchema: z.ZodArray<z.ZodObject<{
192
+ id: z.ZodNumber;
193
+ identifier: z.ZodString;
194
+ name: z.ZodString;
195
+ }, 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);