oneentry 1.0.160 → 1.0.162

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 (238) hide show
  1. package/README.md +2 -0
  2. package/changelog.md +61 -0
  3. package/dist/admins/adminsApi.d.ts +15 -1
  4. package/dist/admins/adminsApi.js +29 -0
  5. package/dist/admins/adminsInterfaces.d.ts +39 -1
  6. package/dist/admins/adminsSchemas.d.ts +2 -0
  7. package/dist/admins/adminsSchemas.js +1 -0
  8. package/dist/attribute-sets/attributeSetsInterfaces.d.ts +2 -0
  9. package/dist/auth-provider/authProviderSchemas.d.ts +1 -0
  10. package/dist/base/lazySchema.d.ts +15 -0
  11. package/dist/base/lazySchema.js +20 -0
  12. package/dist/base/validation.d.ts +1 -0
  13. package/dist/base/validation.js +1 -0
  14. package/dist/blocks/blocksApi.d.ts +16 -8
  15. package/dist/blocks/blocksApi.js +24 -15
  16. package/dist/blocks/blocksInterfaces.d.ts +16 -8
  17. package/dist/discounts/discountsApi.d.ts +14 -1
  18. package/dist/discounts/discountsApi.js +21 -0
  19. package/dist/discounts/discountsInterfaces.d.ts +29 -1
  20. package/dist/filters/filtersInterfaces.d.ts +2 -2
  21. package/dist/filters/filtersSchemas.d.ts +1 -1
  22. package/dist/filters/filtersSchemas.js +4 -1
  23. package/dist/forms-data/formsDataApi.d.ts +14 -1
  24. package/dist/forms-data/formsDataApi.js +21 -0
  25. package/dist/forms-data/formsDataInterfaces.d.ts +78 -1
  26. package/dist/index.d.ts +4 -0
  27. package/dist/index.js +3 -0
  28. package/dist/menus/menusInterfaces.d.ts +4 -0
  29. package/dist/menus/menusSchemas.js +2 -0
  30. package/dist/orders/ordersApi.d.ts +15 -1
  31. package/dist/orders/ordersApi.js +22 -0
  32. package/dist/orders/ordersInterfaces.d.ts +29 -1
  33. package/dist/orders/ordersSchemas.d.ts +2 -0
  34. package/dist/orders/ordersSchemas.js +1 -0
  35. package/dist/pages/pagesApi.d.ts +14 -11
  36. package/dist/pages/pagesApi.js +21 -17
  37. package/dist/pages/pagesInterfaces.d.ts +37 -17
  38. package/dist/pages/pagesSchemas.d.ts +3 -7
  39. package/dist/pages/pagesSchemas.js +2 -8
  40. package/dist/payments/paymentsInterfaces.d.ts +2 -2
  41. package/dist/products/productsInterfaces.d.ts +1 -1
  42. package/dist/search/searchApi.d.ts +35 -0
  43. package/dist/search/searchApi.js +86 -0
  44. package/dist/search/searchInterfaces.d.ts +94 -0
  45. package/dist/search/searchInterfaces.js +2 -0
  46. package/dist/search/searchSchemas.d.ts +73 -0
  47. package/dist/search/searchSchemas.js +44 -0
  48. package/dist/templates-preview/templatesPreviewInterfaces.d.ts +0 -2
  49. package/dist/templates-preview/templatesPreviewSchemas.d.ts +0 -2
  50. package/dist/templates-preview/templatesPreviewSchemas.js +0 -1
  51. package/dist/types.d.ts +35 -0
  52. package/dist/types.js +2 -0
  53. package/dist/users/usersApi.d.ts +15 -1
  54. package/dist/users/usersApi.js +22 -0
  55. package/dist/users/usersInterfaces.d.ts +41 -1
  56. package/dist/users/usersSchemas.d.ts +1 -0
  57. package/dist/web-socket/lazySocket.d.ts +18 -0
  58. package/dist/web-socket/lazySocket.js +70 -0
  59. package/esm/admins/adminsApi.d.ts +66 -0
  60. package/esm/admins/adminsApi.js +90 -0
  61. package/esm/admins/adminsInterfaces.d.ts +139 -0
  62. package/esm/admins/adminsInterfaces.js +1 -0
  63. package/esm/admins/adminsSchemas.d.ts +50 -0
  64. package/esm/admins/adminsSchemas.js +32 -0
  65. package/esm/attribute-sets/attributeSetsApi.d.ts +67 -0
  66. package/esm/attribute-sets/attributeSetsApi.js +97 -0
  67. package/esm/attribute-sets/attributeSetsInterfaces.d.ts +287 -0
  68. package/esm/attribute-sets/attributeSetsInterfaces.js +1 -0
  69. package/esm/attribute-sets/attributeSetsSchemas.d.ts +84 -0
  70. package/esm/attribute-sets/attributeSetsSchemas.js +66 -0
  71. package/esm/auth-provider/authProviderApi.d.ts +262 -0
  72. package/esm/auth-provider/authProviderApi.js +362 -0
  73. package/esm/auth-provider/authProviderSchemas.d.ts +125 -0
  74. package/esm/auth-provider/authProviderSchemas.js +92 -0
  75. package/esm/auth-provider/authProvidersInterfaces.d.ts +430 -0
  76. package/esm/auth-provider/authProvidersInterfaces.js +1 -0
  77. package/esm/base/asyncModules.d.ts +123 -0
  78. package/esm/base/asyncModules.js +382 -0
  79. package/esm/base/lazySchema.d.ts +15 -0
  80. package/esm/base/lazySchema.js +17 -0
  81. package/esm/base/stateModule.d.ts +35 -0
  82. package/esm/base/stateModule.js +51 -0
  83. package/esm/base/syncModules.d.ts +245 -0
  84. package/esm/base/syncModules.js +555 -0
  85. package/esm/base/timeIntervals.d.ts +95 -0
  86. package/esm/base/timeIntervals.js +317 -0
  87. package/esm/base/utils.d.ts +354 -0
  88. package/esm/base/utils.js +1 -0
  89. package/esm/base/validation.d.ts +99 -0
  90. package/esm/base/validation.js +119 -0
  91. package/esm/blocks/blocksApi.d.ts +260 -0
  92. package/esm/blocks/blocksApi.js +403 -0
  93. package/esm/blocks/blocksInterfaces.d.ts +369 -0
  94. package/esm/blocks/blocksInterfaces.js +1 -0
  95. package/esm/blocks/blocksSchemas.d.ts +213 -0
  96. package/esm/blocks/blocksSchemas.js +40 -0
  97. package/esm/discounts/discountsApi.d.ts +94 -0
  98. package/esm/discounts/discountsApi.js +136 -0
  99. package/esm/discounts/discountsInterfaces.d.ts +295 -0
  100. package/esm/discounts/discountsInterfaces.js +1 -0
  101. package/esm/events/eventsApi.d.ts +108 -0
  102. package/esm/events/eventsApi.js +141 -0
  103. package/esm/events/eventsInterfaces.d.ts +176 -0
  104. package/esm/events/eventsInterfaces.js +1 -0
  105. package/esm/file-uploading/fileUploadingApi.d.ts +91 -0
  106. package/esm/file-uploading/fileUploadingApi.js +127 -0
  107. package/esm/file-uploading/fileUploadingInterfaces.d.ts +116 -0
  108. package/esm/file-uploading/fileUploadingInterfaces.js +1 -0
  109. package/esm/file-uploading/fileUploadingSchemas.d.ts +24 -0
  110. package/esm/file-uploading/fileUploadingSchemas.js +19 -0
  111. package/esm/filters/filtersApi.d.ts +32 -0
  112. package/esm/filters/filtersApi.js +36 -0
  113. package/esm/filters/filtersInterfaces.d.ts +56 -0
  114. package/esm/filters/filtersInterfaces.js +1 -0
  115. package/esm/filters/filtersSchemas.d.ts +32 -0
  116. package/esm/filters/filtersSchemas.js +29 -0
  117. package/esm/forms/formsApi.d.ts +44 -0
  118. package/esm/forms/formsApi.js +54 -0
  119. package/esm/forms/formsInterfaces.d.ts +237 -0
  120. package/esm/forms/formsInterfaces.js +1 -0
  121. package/esm/forms/formsSchemas.d.ts +56 -0
  122. package/esm/forms/formsSchemas.js +32 -0
  123. package/esm/forms-data/formsDataApi.d.ts +124 -0
  124. package/esm/forms-data/formsDataApi.js +210 -0
  125. package/esm/forms-data/formsDataInterfaces.d.ts +674 -0
  126. package/esm/forms-data/formsDataInterfaces.js +1 -0
  127. package/esm/forms-data/formsDataSchemas.d.ts +107 -0
  128. package/esm/forms-data/formsDataSchemas.js +83 -0
  129. package/esm/general-types/generalTypesApi.d.ts +29 -0
  130. package/esm/general-types/generalTypesApi.js +34 -0
  131. package/esm/general-types/generalTypesInterfaces.d.ts +29 -0
  132. package/esm/general-types/generalTypesInterfaces.js +1 -0
  133. package/esm/general-types/generalTypesSchemas.d.ts +68 -0
  134. package/esm/general-types/generalTypesSchemas.js +42 -0
  135. package/esm/index.d.ts +143 -0
  136. package/esm/index.js +124 -0
  137. package/esm/integration-collections/integrationCollectionsApi.d.ts +172 -0
  138. package/esm/integration-collections/integrationCollectionsApi.js +224 -0
  139. package/esm/integration-collections/integrationCollectionsInterfaces.d.ts +317 -0
  140. package/esm/integration-collections/integrationCollectionsInterfaces.js +1 -0
  141. package/esm/integration-collections/integrationCollectionsSchemas.d.ts +84 -0
  142. package/esm/integration-collections/integrationCollectionsSchemas.js +60 -0
  143. package/esm/locales/localesApi.d.ts +28 -0
  144. package/esm/locales/localesApi.js +33 -0
  145. package/esm/locales/localesInterfaces.d.ts +40 -0
  146. package/esm/locales/localesInterfaces.js +1 -0
  147. package/esm/locales/localesSchemas.d.ts +32 -0
  148. package/esm/locales/localesSchemas.js +23 -0
  149. package/esm/menus/menusApi.d.ts +30 -0
  150. package/esm/menus/menusApi.js +35 -0
  151. package/esm/menus/menusInterfaces.d.ts +91 -0
  152. package/esm/menus/menusInterfaces.js +2 -0
  153. package/esm/menus/menusSchemas.d.ts +16 -0
  154. package/esm/menus/menusSchemas.js +27 -0
  155. package/esm/orders/ordersApi.d.ts +213 -0
  156. package/esm/orders/ordersApi.js +288 -0
  157. package/esm/orders/ordersInterfaces.d.ts +765 -0
  158. package/esm/orders/ordersInterfaces.js +1 -0
  159. package/esm/orders/ordersSchemas.d.ts +314 -0
  160. package/esm/orders/ordersSchemas.js +172 -0
  161. package/esm/package.json +4 -0
  162. package/esm/pages/pagesApi.d.ts +163 -0
  163. package/esm/pages/pagesApi.js +397 -0
  164. package/esm/pages/pagesInterfaces.d.ts +327 -0
  165. package/esm/pages/pagesInterfaces.js +1 -0
  166. package/esm/pages/pagesSchemas.d.ts +117 -0
  167. package/esm/pages/pagesSchemas.js +54 -0
  168. package/esm/payments/paymentsApi.d.ts +88 -0
  169. package/esm/payments/paymentsApi.js +122 -0
  170. package/esm/payments/paymentsInterfaces.d.ts +189 -0
  171. package/esm/payments/paymentsInterfaces.js +1 -0
  172. package/esm/payments/paymentsSchemas.d.ts +94 -0
  173. package/esm/payments/paymentsSchemas.js +53 -0
  174. package/esm/product-statuses/productStatusesApi.d.ts +50 -0
  175. package/esm/product-statuses/productStatusesApi.js +68 -0
  176. package/esm/product-statuses/productStatusesInterfaces.d.ts +62 -0
  177. package/esm/product-statuses/productStatusesInterfaces.js +1 -0
  178. package/esm/product-statuses/productStatusesSchemas.d.ts +34 -0
  179. package/esm/product-statuses/productStatusesSchemas.js +27 -0
  180. package/esm/products/productsApi.d.ts +366 -0
  181. package/esm/products/productsApi.js +468 -0
  182. package/esm/products/productsInterfaces.d.ts +723 -0
  183. package/esm/products/productsInterfaces.js +1 -0
  184. package/esm/products/productsSchemas.d.ts +234 -0
  185. package/esm/products/productsSchemas.js +121 -0
  186. package/esm/search/searchApi.d.ts +35 -0
  187. package/esm/search/searchApi.js +47 -0
  188. package/esm/search/searchInterfaces.d.ts +94 -0
  189. package/esm/search/searchInterfaces.js +1 -0
  190. package/esm/search/searchSchemas.d.ts +73 -0
  191. package/esm/search/searchSchemas.js +41 -0
  192. package/esm/sitemap/sitemapApi.d.ts +37 -0
  193. package/esm/sitemap/sitemapApi.js +41 -0
  194. package/esm/sitemap/sitemapInterfaces.d.ts +51 -0
  195. package/esm/sitemap/sitemapInterfaces.js +1 -0
  196. package/esm/subscriptions/subscriptionsApi.d.ts +74 -0
  197. package/esm/subscriptions/subscriptionsApi.js +90 -0
  198. package/esm/subscriptions/subscriptionsInterfaces.d.ts +111 -0
  199. package/esm/subscriptions/subscriptionsInterfaces.js +1 -0
  200. package/esm/subscriptions/subscriptionsSchemas.d.ts +46 -0
  201. package/esm/subscriptions/subscriptionsSchemas.js +38 -0
  202. package/esm/system/systemApi.d.ts +46 -0
  203. package/esm/system/systemApi.js +53 -0
  204. package/esm/system/systemInterfaces.d.ts +29 -0
  205. package/esm/system/systemInterfaces.js +1 -0
  206. package/esm/templates/templatesApi.d.ts +53 -0
  207. package/esm/templates/templatesApi.js +78 -0
  208. package/esm/templates/templatesInterfaces.d.ts +68 -0
  209. package/esm/templates/templatesInterfaces.js +1 -0
  210. package/esm/templates/templatesSchemas.d.ts +48 -0
  211. package/esm/templates/templatesSchemas.js +28 -0
  212. package/esm/templates-preview/templatesPreviewApi.d.ts +40 -0
  213. package/esm/templates-preview/templatesPreviewApi.js +50 -0
  214. package/esm/templates-preview/templatesPreviewInterfaces.d.ts +129 -0
  215. package/esm/templates-preview/templatesPreviewInterfaces.js +1 -0
  216. package/esm/templates-preview/templatesPreviewSchemas.d.ts +79 -0
  217. package/esm/templates-preview/templatesPreviewSchemas.js +43 -0
  218. package/esm/types.d.ts +35 -0
  219. package/esm/types.js +1 -0
  220. package/esm/user-activity/userActivityApi.d.ts +31 -0
  221. package/esm/user-activity/userActivityApi.js +37 -0
  222. package/esm/user-activity/userActivityInterfaces.d.ts +42 -0
  223. package/esm/user-activity/userActivityInterfaces.js +1 -0
  224. package/esm/users/usersApi.d.ts +249 -0
  225. package/esm/users/usersApi.js +312 -0
  226. package/esm/users/usersInterfaces.d.ts +421 -0
  227. package/esm/users/usersInterfaces.js +1 -0
  228. package/esm/users/usersSchemas.d.ts +73 -0
  229. package/esm/users/usersSchemas.js +55 -0
  230. package/esm/web-socket/lazySocket.d.ts +18 -0
  231. package/esm/web-socket/lazySocket.js +67 -0
  232. package/esm/web-socket/wsApi.d.ts +27 -0
  233. package/esm/web-socket/wsApi.js +43 -0
  234. package/esm/web-socket/wsInterfaces.d.ts +16 -0
  235. package/esm/web-socket/wsInterfaces.js +1 -0
  236. package/package.json +5 -1
  237. package/types.d.ts +1 -0
  238. package/types.js +1 -0
@@ -0,0 +1,99 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Common validation schemas for API responses
4
+ * @description Base schemas that can be reused across different modules
5
+ */
6
+ /**
7
+ * Error response schema
8
+ */
9
+ export declare const ErrorSchema: z.ZodObject<{
10
+ statusCode: z.ZodNumber;
11
+ message: z.ZodString;
12
+ localizeMessage: z.ZodOptional<z.ZodString>;
13
+ }, z.core.$strip>;
14
+ /**
15
+ * Localize info schema
16
+ */
17
+ export declare const LocalizeInfoSchema: z.ZodObject<{
18
+ title: z.ZodString;
19
+ content: z.ZodOptional<z.ZodString>;
20
+ menuTitle: z.ZodOptional<z.ZodString>;
21
+ }, z.core.$strip>;
22
+ /**
23
+ * Attribute schema
24
+ */
25
+ export declare const AttributeSchema: z.ZodObject<{
26
+ id: z.ZodOptional<z.ZodNumber>;
27
+ marker: z.ZodString;
28
+ type: z.ZodString;
29
+ isVisible: z.ZodOptional<z.ZodBoolean>;
30
+ isRequired: z.ZodOptional<z.ZodBoolean>;
31
+ position: z.ZodOptional<z.ZodNumber>;
32
+ localizeInfos: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
33
+ title: z.ZodString;
34
+ content: z.ZodOptional<z.ZodString>;
35
+ menuTitle: z.ZodOptional<z.ZodString>;
36
+ }, z.core.$strip>>>;
37
+ value: z.ZodOptional<z.ZodAny>;
38
+ }, z.core.$strip>;
39
+ /**
40
+ * User entity schema
41
+ */
42
+ export declare const UserEntitySchema: z.ZodObject<{
43
+ id: z.ZodNumber;
44
+ identifier: z.ZodString;
45
+ authProviderIdentifier: z.ZodString;
46
+ formData: z.ZodUnion<readonly [z.ZodArray<z.ZodAny>, z.ZodRecord<z.ZodString, z.ZodAny>]>;
47
+ formIdentifier: z.ZodString;
48
+ total: z.ZodString;
49
+ groups: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
50
+ state: z.ZodRecord<z.ZodString, z.ZodAny>;
51
+ moduleFormConfigs: z.ZodOptional<z.ZodArray<z.ZodAny>>;
52
+ rating: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
53
+ distance: z.ZodOptional<z.ZodNumber>;
54
+ }, z.core.$strip>;
55
+ /**
56
+ * Auth entity schema
57
+ * API returns only accessToken and refreshToken
58
+ * userIdentifier and authProviderIdentifier are optional legacy fields
59
+ */
60
+ export declare const AuthEntitySchema: z.ZodObject<{
61
+ userIdentifier: z.ZodString;
62
+ authProviderIdentifier: z.ZodString;
63
+ accessToken: z.ZodString;
64
+ refreshToken: z.ZodString;
65
+ }, z.core.$strip>;
66
+ /**
67
+ * Paginated response schema factory
68
+ * @param {T} itemSchema - The schema for each item in the paginated response
69
+ * @returns {any} Paginated response schema
70
+ */
71
+ export declare function createPaginatedSchema<T extends z.ZodTypeAny>(itemSchema: T): any;
72
+ /**
73
+ * Validation helper function
74
+ * @param {z.ZodSchema<T>} schema - Zod schema to validate against
75
+ * @param {unknown} data - Data to validate
76
+ * @param {object} options - Validation options
77
+ * @param {boolean} options.strict - Whether to use strict mode
78
+ * @param {boolean} options.logErrors - Whether to log errors
79
+ * @returns {object} Validated data or error
80
+ */
81
+ export declare function validateResponse<T>(schema: z.ZodSchema<T>, data: unknown, options?: {
82
+ strict?: boolean;
83
+ logErrors?: boolean;
84
+ }): {
85
+ success: true;
86
+ data: T;
87
+ } | {
88
+ success: false;
89
+ error: z.ZodError;
90
+ };
91
+ /**
92
+ * Safe validation helper - returns data even if validation fails
93
+ * Used when strict mode is disabled
94
+ * @param {z.ZodSchema<T>} schema - Zod schema to validate against
95
+ * @param {unknown} data - Data to validate
96
+ * @param {boolean} logErrors - Whether to log errors
97
+ * @returns {T} Validated data or original data if validation fails in non-strict mode
98
+ */
99
+ export declare function validateResponseSafe<T>(schema: z.ZodSchema<T>, data: unknown, logErrors?: boolean): T;
@@ -0,0 +1,119 @@
1
+ /* eslint-disable jsdoc/reject-any-type */
2
+ import { z } from 'zod';
3
+ /**
4
+ * Common validation schemas for API responses
5
+ * @description Base schemas that can be reused across different modules
6
+ */
7
+ /**
8
+ * Error response schema
9
+ */
10
+ export const ErrorSchema = z.object({
11
+ statusCode: z.number(),
12
+ message: z.string(),
13
+ localizeMessage: z.string().optional(),
14
+ });
15
+ /**
16
+ * Localize info schema
17
+ */
18
+ export const LocalizeInfoSchema = z.object({
19
+ title: z.string(),
20
+ content: z.string().optional(),
21
+ menuTitle: z.string().optional(),
22
+ });
23
+ /**
24
+ * Attribute schema
25
+ */
26
+ export const AttributeSchema = z.object({
27
+ id: z.number().optional(),
28
+ marker: z.string(),
29
+ type: z.string(),
30
+ isVisible: z.boolean().optional(),
31
+ isRequired: z.boolean().optional(),
32
+ position: z.number().optional(),
33
+ localizeInfos: z.record(z.string(), LocalizeInfoSchema).optional(),
34
+ value: z.any().optional(),
35
+ });
36
+ /**
37
+ * User entity schema
38
+ */
39
+ export const UserEntitySchema = z.object({
40
+ id: z.number(),
41
+ identifier: z.string(),
42
+ authProviderIdentifier: z.string(),
43
+ formData: z.union([z.array(z.any()), z.record(z.string(), z.any())]),
44
+ formIdentifier: z.string(),
45
+ total: z.string(),
46
+ groups: z.array(z.union([z.string(), z.number()])),
47
+ state: z.record(z.string(), z.any()),
48
+ moduleFormConfigs: z.array(z.any()).optional(),
49
+ rating: z.record(z.string(), z.unknown()).optional(),
50
+ distance: z.number().optional(),
51
+ });
52
+ /**
53
+ * Auth entity schema
54
+ * API returns only accessToken and refreshToken
55
+ * userIdentifier and authProviderIdentifier are optional legacy fields
56
+ */
57
+ export const AuthEntitySchema = z.object({
58
+ userIdentifier: z.string(),
59
+ authProviderIdentifier: z.string(),
60
+ accessToken: z.string(),
61
+ refreshToken: z.string(),
62
+ });
63
+ /**
64
+ * Paginated response schema factory
65
+ * @param {T} itemSchema - The schema for each item in the paginated response
66
+ * @returns {any} Paginated response schema
67
+ */
68
+ export function createPaginatedSchema(itemSchema) {
69
+ return z.object({
70
+ items: z.array(itemSchema),
71
+ total: z.number(),
72
+ page: z.number().optional(),
73
+ limit: z.number().optional(),
74
+ });
75
+ }
76
+ /**
77
+ * Validation helper function
78
+ * @param {z.ZodSchema<T>} schema - Zod schema to validate against
79
+ * @param {unknown} data - Data to validate
80
+ * @param {object} options - Validation options
81
+ * @param {boolean} options.strict - Whether to use strict mode
82
+ * @param {boolean} options.logErrors - Whether to log errors
83
+ * @returns {object} Validated data or error
84
+ */
85
+ export function validateResponse(schema, data, options) {
86
+ try {
87
+ const validated = schema.parse(data);
88
+ return { success: true, data: validated };
89
+ }
90
+ catch (error) {
91
+ if (error instanceof z.ZodError) {
92
+ if (options === null || options === void 0 ? void 0 : options.logErrors) {
93
+ // eslint-disable-next-line no-undef, no-console
94
+ console.error('Validation error:', {
95
+ errors: error.issues,
96
+ data,
97
+ });
98
+ }
99
+ return { success: false, error };
100
+ }
101
+ throw error;
102
+ }
103
+ }
104
+ /**
105
+ * Safe validation helper - returns data even if validation fails
106
+ * Used when strict mode is disabled
107
+ * @param {z.ZodSchema<T>} schema - Zod schema to validate against
108
+ * @param {unknown} data - Data to validate
109
+ * @param {boolean} logErrors - Whether to log errors
110
+ * @returns {T} Validated data or original data if validation fails in non-strict mode
111
+ */
112
+ export function validateResponseSafe(schema, data, logErrors = false) {
113
+ const result = validateResponse(schema, data, { logErrors });
114
+ if (result.success) {
115
+ return result.data;
116
+ }
117
+ // Return original data if validation fails in non-strict mode
118
+ return data;
119
+ }
@@ -0,0 +1,260 @@
1
+ import AsyncModules from '../base/asyncModules.js';
2
+ import type StateModule from '../base/stateModule.js';
3
+ import type { IError } from '../base/utils.js';
4
+ import type { IProductsResponse } from '../products/productsInterfaces.js';
5
+ import type { BlockType, IBlockEntity, IBlockProductsLookup, IBlocks, IBlockSlidesResponse, IBlocksResponse, ISearchBlock } from './blocksInterfaces.js';
6
+ /**
7
+ * Controllers for working with blocks.
8
+ * @handle /api/content/blocks
9
+ * @class BlocksApi
10
+ * @augments AsyncModules
11
+ * @implements {IBlocks}
12
+ * @description This class provides methods to interact with blocks.
13
+ */
14
+ export default class BlocksApi extends AsyncModules implements IBlocks {
15
+ protected state: StateModule;
16
+ protected _url: string;
17
+ /**
18
+ * Constructor for BlocksApi class.
19
+ */
20
+ constructor(state: StateModule);
21
+ /**
22
+ * Get blocks by parameters.
23
+ * @handleName getBlocks
24
+ * @param {BlockType} [type] - Optional block type to filter by. Available values: "product" | "error_page" | "catalog_page" | "product_preview" | "similar_products_block" | "product_block" | "form" | "common_page" | "common_block" | "order" | "service" | "none". When omitted, blocks of all types are returned. Example: 'product'.
25
+ * @param {string} [langCode] - Language code. Default: "en_US".
26
+ * @param {number} [offset] - Parameter for pagination. Default: 0.
27
+ * @param {number} [limit] - Parameter for pagination. Default: 30.
28
+ * @returns {Promise<IBlocksResponse | IError>} Returns BlocksEntity object.
29
+ * @throws {IError} When isShell=false and an error occurs during the fetch
30
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getBlocks getBlocks} documentation.
31
+ */
32
+ getBlocks(type?: BlockType, langCode?: string, offset?: number, limit?: number): Promise<IBlocksResponse | IError>;
33
+ /**
34
+ * Get block by marker.
35
+ * @handleName getBlockByMarker
36
+ * @param {string} marker - Marker of Block. Example: "product_block".
37
+ * @param {string} [langCode] - Language code. Default: "en_US".
38
+ * @param {number} [offset] - Parameter for pagination. Default: 0.
39
+ * @param {number} [limit] - Parameter for pagination. Default: 30.
40
+ * @returns {Promise<IBlockEntity | IError>} - Returns a BlockEntity object.
41
+ * @throws {IError} When isShell=false and an error occurs during the fetch
42
+ * @description This method retrieves a block by its marker and includes additional information such as similar products or products associated with the block.
43
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getBlockByMarker getBlockByMarker} documentation.
44
+ */
45
+ getBlockByMarker(marker: string, langCode?: string, offset?: number, limit?: number): Promise<IBlockEntity | IError>;
46
+ /**
47
+ * Enrich a single block in place.
48
+ *
49
+ * Lifts product display settings from `customSettings.productConfig` to
50
+ * numeric top-level fields, strips internal-only fields, and — when
51
+ * `loadProducts` is true — fetches the related products for
52
+ * `similar_products_block` / `product_block` blocks. Shared by `getBlocks`
53
+ * (array) and `getBlockByMarker` (single block). Mutates `block` in place.
54
+ * @param {any} block - Normalized block to enrich (mutated in place).
55
+ * @param {string} langCode - Language code passed to product sub-requests.
56
+ * @param {number} offset - Pagination offset for product sub-requests.
57
+ * @param {number} limit - Pagination limit for product sub-requests.
58
+ * @param {boolean} loadProducts - Whether to fetch related products.
59
+ * @returns {Promise<void>} Resolves when enrichment (incl. sub-requests) is done.
60
+ */
61
+ private _enrichBlock;
62
+ /**
63
+ * Get similar products by block marker.
64
+ * @handleName getSimilarProducts
65
+ * @param {string} marker - Block identifier. Example: "similar_products_block".
66
+ * @param {string} [langCode] - Language code. Default: "en_US".
67
+ * @param {number} [offset] - Parameter for pagination. Default: 0.
68
+ * @param {number} [limit] - Parameter for pagination. Default: 30.
69
+ * @param {string} [signPrice] - Order storage marker for price fixing. If the parameter is set, the price is fixed for a certain time.
70
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/#Fixing-the-price-signPrice Fixing the price} documentation.
71
+ * @param {number} [productId] - Optional product id to find similar products for.
72
+ * @returns {Promise<IProductsResponse | IError>} Returns the total count and an array of product items in object by specified block marker.
73
+ * @throws {IError} When isShell=false and an error occurs during the fetch
74
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getSimilarProducts getSimilarProducts} documentation.
75
+ */
76
+ private getSimilarProducts;
77
+ /**
78
+ * Get products by block marker.
79
+ * @handleName getProductsByBlockMarker
80
+ * @param {string} marker - Block identifier. Example: "product_block".
81
+ * @param {string} [langCode] - Language code. Default: "en_US".
82
+ * @param {number} [offset] - Parameter for pagination. Default: 0.
83
+ * @param {number} [limit] - Parameter for pagination. Default: 30.
84
+ * @param {string} [signPrice] - Order storage marker for price fixing. If the parameter is set, the price is fixed for a certain time.
85
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/#Fixing-the-price-signPrice Fixing the price} documentation.
86
+ * @returns {Promise<IProductsEntity[] | IError>} Return array of BlocksEntity object.
87
+ * @throws {IError} When isShell=false and an error occurs during the fetch
88
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getProductsByBlockMarker getProductsByBlockMarker} documentation.
89
+ */
90
+ private getProductsByBlockMarker;
91
+ /**
92
+ * Get frequently ordered products by block marker and product id.
93
+ * @handleName getFrequentlyOrderedProducts
94
+ * @param {number} productId - Product id. Example: 1.
95
+ * @param {string} marker - Block marker. Example: "frequently_ordered_block".
96
+ * @param {string} [langCode] - Language code. Default: "en_US".
97
+ * @param {string} [signPrice] - Order storage marker for price fixing. If the parameter is set, the price is fixed for a certain time.
98
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/#Fixing-the-price-signPrice Fixing the price} documentation.
99
+ * @param {number} [limit] - Maximum number of products to return. When omitted, the block's own quantity setting applies. Example: 10.
100
+ * @returns {Promise<IProductsResponse | IError>} Returns a products response with items and total.
101
+ * @throws {IError} When isShell=false and an error occurs during the fetch
102
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getFrequentlyOrderedProducts getFrequentlyOrderedProducts} documentation.
103
+ */
104
+ getFrequentlyOrderedProducts(productId: number, marker: string, langCode?: string, signPrice?: string, limit?: number): Promise<IProductsResponse | IError>;
105
+ /**
106
+ * Quick search for block objects with limited output.
107
+ * @handleName searchBlock
108
+ * @param {string} name - Search string. Example: "product_block".
109
+ * @param {string} [langCode] - Language code. Default: "en_US".
110
+ * @returns {Promise<ISearchBlock[] | IError>} Returns an array of ISearchBlock objects.
111
+ * @throws {IError} When isShell=false and an error occurs during the fetch
112
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/searchBlock searchBlock} documentation.
113
+ */
114
+ searchBlock(name: string, langCode?: string): Promise<ISearchBlock[] | IError>;
115
+ /**
116
+ * Get "complete your cart" products by the cart from context (auth user or guest).
117
+ * @handleName getCartComplement
118
+ * @param {string} marker - Block marker. Example: "cart_complement_block".
119
+ * @param {string} [langCode] - Language code. Default: "en_US".
120
+ * @param {string} [signPrice] - Order storage marker for price fixing. If the parameter is set, the price is fixed for a certain time.
121
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/#Fixing-the-price-signPrice Fixing the price} documentation.
122
+ * @param {number} [limit] - Maximum number of products to return. When omitted, the block's own quantity setting applies. Example: 10.
123
+ * @returns {Promise<IProductsResponse | IError>} Returns an object with an array of products, total count and totalFound.
124
+ * @throws {IError} When isShell=false and an error occurs during the fetch
125
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getCartComplement getCartComplement} documentation.
126
+ */
127
+ getCartComplement(marker: string, langCode?: string, signPrice?: string, limit?: number): Promise<IProductsResponse | IError>;
128
+ /**
129
+ * Get "complete your cart" products by an explicit list of productIds (POST body).
130
+ * @handleName getCartComplementByProductIds
131
+ * @param {string} marker - Block marker. Example: "cart_complement_block".
132
+ * @param {IBlockProductsLookup} body - Lookup body.
133
+ * @example
134
+ {
135
+ "productIds": [1, 2],
136
+ "langCode": "en_US"
137
+ }
138
+ * @returns {Promise<IProductsResponse | IError>} Returns an object with an array of products, total count and totalFound.
139
+ * @throws {IError} When isShell=false and an error occurs during the fetch
140
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getCartComplementByProductIds getCartComplementByProductIds} documentation.
141
+ */
142
+ getCartComplementByProductIds(marker: string, body: IBlockProductsLookup): Promise<IProductsResponse | IError>;
143
+ /**
144
+ * Get "similar to cart" products by the cart from context (auth user or guest).
145
+ * @handleName getCartSimilar
146
+ * @param {string} marker - Block marker. Example: "cart_similar_block".
147
+ * @param {string} [langCode] - Language code. Default: "en_US".
148
+ * @param {string} [signPrice] - Order storage marker for price fixing. If the parameter is set, the price is fixed for a certain time.
149
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/#Fixing-the-price-signPrice Fixing the price} documentation.
150
+ * @param {number} [limit] - Maximum number of products to return. When omitted, the block's own quantity setting applies. Example: 10.
151
+ * @returns {Promise<IProductsResponse | IError>} Returns an object with an array of products, total count and totalFound.
152
+ * @throws {IError} When isShell=false and an error occurs during the fetch
153
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getCartSimilar getCartSimilar} documentation.
154
+ */
155
+ getCartSimilar(marker: string, langCode?: string, signPrice?: string, limit?: number): Promise<IProductsResponse | IError>;
156
+ /**
157
+ * Get "similar to cart" products by an explicit list of productIds (POST body).
158
+ * @handleName getCartSimilarByProductIds
159
+ * @param {string} marker - Block marker. Example: "cart_similar_block".
160
+ * @param {IBlockProductsLookup} body - Lookup body.
161
+ * @example
162
+ {
163
+ "productIds": [1, 2],
164
+ "langCode": "en_US"
165
+ }
166
+ * @returns {Promise<IProductsResponse | IError>} Returns an object with an array of products, total count and totalFound.
167
+ * @throws {IError} When isShell=false and an error occurs during the fetch
168
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getCartSimilarByProductIds getCartSimilarByProductIds} documentation.
169
+ */
170
+ getCartSimilarByProductIds(marker: string, body: IBlockProductsLookup): Promise<IProductsResponse | IError>;
171
+ /**
172
+ * Get personal recommendations for the user.
173
+ * @handleName getPersonalRecommendations
174
+ * @param {string} marker - Block marker. Example: "personal_recommendations_block".
175
+ * @param {string} [langCode] - Language code. Default: "en_US".
176
+ * @param {string} [signPrice] - Order storage marker for price fixing. If the parameter is set, the price is fixed for a certain time.
177
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/#Fixing-the-price-signPrice Fixing the price} documentation.
178
+ * @param {number} [limit] - Maximum number of products to return. When omitted, the block's own quantity setting applies. Example: 10.
179
+ * @returns {Promise<IProductsResponse | IError>} Returns an object with an array of products, total count and totalFound.
180
+ * @throws {IError} When isShell=false and an error occurs during the fetch
181
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getPersonalRecommendations getPersonalRecommendations} documentation.
182
+ */
183
+ getPersonalRecommendations(marker: string, langCode?: string, signPrice?: string, limit?: number): Promise<IProductsResponse | IError>;
184
+ /**
185
+ * Get recently viewed products.
186
+ * @handleName getRecentlyViewed
187
+ * @param {string} marker - Block marker. Example: "recently_viewed_block".
188
+ * @param {string} [langCode] - Language code. Default: "en_US".
189
+ * @param {string} [signPrice] - Order storage marker for price fixing. If the parameter is set, the price is fixed for a certain time.
190
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/#Fixing-the-price-signPrice Fixing the price} documentation.
191
+ * @param {number} [limit] - Maximum number of products to return. When omitted, the block's own quantity setting applies. Example: 10.
192
+ * @returns {Promise<IProductsResponse | IError>} Returns an object with an array of products, total count and totalFound.
193
+ * @throws {IError} When isShell=false and an error occurs during the fetch
194
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getRecentlyViewed getRecentlyViewed} documentation.
195
+ */
196
+ getRecentlyViewed(marker: string, langCode?: string, signPrice?: string, limit?: number): Promise<IProductsResponse | IError>;
197
+ /**
198
+ * Get products for repeat purchase.
199
+ * @handleName getRepeatPurchase
200
+ * @param {string} marker - Block marker. Example: "repeat_purchase_block".
201
+ * @param {string} [langCode] - Language code. Default: "en_US".
202
+ * @param {string} [signPrice] - Order storage marker for price fixing. If the parameter is set, the price is fixed for a certain time.
203
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/#Fixing-the-price-signPrice Fixing the price} documentation.
204
+ * @param {number} [limit] - Maximum number of products to return. When omitted, the block's own quantity setting applies. Example: 10.
205
+ * @returns {Promise<IProductsResponse | IError>} Returns an object with an array of products, total count and totalFound.
206
+ * @throws {IError} When isShell=false and an error occurs during the fetch
207
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getRepeatPurchase getRepeatPurchase} documentation.
208
+ */
209
+ getRepeatPurchase(marker: string, langCode?: string, signPrice?: string, limit?: number): Promise<IProductsResponse | IError>;
210
+ /**
211
+ * Get the block's slides tree as a flat pre-order array (slider_block only).
212
+ * @handleName getSlides
213
+ * @param {string} marker - Block marker. Example: "slider_block".
214
+ * @returns {Promise<IBlockSlidesResponse | IError>} Returns the slides response.
215
+ * @throws {IError} When isShell=false and an error occurs during the fetch
216
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getSlides getSlides} documentation.
217
+ */
218
+ getSlides(marker: string): Promise<IBlockSlidesResponse | IError>;
219
+ /**
220
+ * Get trending products of the block.
221
+ * @handleName getTrending
222
+ * @param {string} marker - Block marker. Example: "trending_block".
223
+ * @param {string} [langCode] - Language code. Default: "en_US".
224
+ * @param {string} [signPrice] - Order storage marker for price fixing. If the parameter is set, the price is fixed for a certain time.
225
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/#Fixing-the-price-signPrice Fixing the price} documentation.
226
+ * @param {number} [limit] - Maximum number of products to return. When omitted, the block's own quantity setting applies. Example: 10.
227
+ * @returns {Promise<IProductsResponse | IError>} Returns an object with an array of products, total count and totalFound.
228
+ * @throws {IError} When isShell=false and an error occurs during the fetch
229
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getTrending getTrending} documentation.
230
+ */
231
+ getTrending(marker: string, langCode?: string, signPrice?: string, limit?: number): Promise<IProductsResponse | IError>;
232
+ /**
233
+ * Get "similar to wishlist" products by the wishlist from context (auth user or guest).
234
+ * @handleName getWishlistSimilar
235
+ * @param {string} marker - Block marker. Example: "wishlist_similar_block".
236
+ * @param {string} [langCode] - Language code. Default: "en_US".
237
+ * @param {string} [signPrice] - Order storage marker for price fixing. If the parameter is set, the price is fixed for a certain time.
238
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/#Fixing-the-price-signPrice Fixing the price} documentation.
239
+ * @param {number} [limit] - Maximum number of products to return. When omitted, the block's own quantity setting applies. Example: 10.
240
+ * @returns {Promise<IProductsResponse | IError>} Returns an object with an array of products, total count and totalFound.
241
+ * @throws {IError} When isShell=false and an error occurs during the fetch
242
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getWishlistSimilar getWishlistSimilar} documentation.
243
+ */
244
+ getWishlistSimilar(marker: string, langCode?: string, signPrice?: string, limit?: number): Promise<IProductsResponse | IError>;
245
+ /**
246
+ * Get "similar to wishlist" products by an explicit list of productIds (POST body).
247
+ * @handleName getWishlistSimilarByProductIds
248
+ * @param {string} marker - Block marker. Example: "wishlist_similar_block".
249
+ * @param {IBlockProductsLookup} body - Lookup body.
250
+ * @example
251
+ {
252
+ "productIds": [1, 2],
253
+ "langCode": "en_US"
254
+ }
255
+ * @returns {Promise<IProductsResponse | IError>} Returns an object with an array of products, total count and totalFound.
256
+ * @throws {IError} When isShell=false and an error occurs during the fetch
257
+ * @see {@link https://js-sdk.oneentry.cloud/docs/blocks/getWishlistSimilarByProductIds getWishlistSimilarByProductIds} documentation.
258
+ */
259
+ getWishlistSimilarByProductIds(marker: string, body: IBlockProductsLookup): Promise<IProductsResponse | IError>;
260
+ }