oneentry 1.0.141 → 1.0.142

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 +107 -15
  2. package/package.json +81 -3
  3. package/dist/admins/adminsApi.d.ts +0 -50
  4. package/dist/admins/adminsApi.js +0 -65
  5. package/dist/admins/adminsInterfaces.d.ts +0 -99
  6. package/dist/admins/adminsInterfaces.js +0 -2
  7. package/dist/admins/adminsSchemas.d.ts +0 -30
  8. package/dist/admins/adminsSchemas.js +0 -27
  9. package/dist/attribute-sets/attributeSetsApi.d.ts +0 -63
  10. package/dist/attribute-sets/attributeSetsApi.js +0 -98
  11. package/dist/attribute-sets/attributeSetsInterfaces.d.ts +0 -187
  12. package/dist/attribute-sets/attributeSetsInterfaces.js +0 -2
  13. package/dist/attribute-sets/attributeSetsSchemas.d.ts +0 -90
  14. package/dist/attribute-sets/attributeSetsSchemas.js +0 -74
  15. package/dist/auth-provider/authProviderApi.d.ts +0 -249
  16. package/dist/auth-provider/authProviderApi.js +0 -351
  17. package/dist/auth-provider/authProviderSchemas.d.ts +0 -131
  18. package/dist/auth-provider/authProviderSchemas.js +0 -82
  19. package/dist/auth-provider/authProvidersInterfaces.d.ts +0 -425
  20. package/dist/auth-provider/authProvidersInterfaces.js +0 -2
  21. package/dist/base/asyncModules.d.ts +0 -80
  22. package/dist/base/asyncModules.js +0 -440
  23. package/dist/base/result.d.ts +0 -39
  24. package/dist/base/result.js +0 -154
  25. package/dist/base/stateModule.d.ts +0 -41
  26. package/dist/base/stateModule.js +0 -128
  27. package/dist/base/syncModules.d.ts +0 -149
  28. package/dist/base/syncModules.js +0 -549
  29. package/dist/base/utils.d.ts +0 -197
  30. package/dist/base/utils.js +0 -2
  31. package/dist/base/validation.d.ts +0 -118
  32. package/dist/base/validation.js +0 -132
  33. package/dist/blocks/blocksApi.d.ts +0 -76
  34. package/dist/blocks/blocksApi.js +0 -188
  35. package/dist/blocks/blocksInterfaces.d.ts +0 -173
  36. package/dist/blocks/blocksInterfaces.js +0 -2
  37. package/dist/blocks/blocksSchemas.d.ts +0 -187
  38. package/dist/blocks/blocksSchemas.js +0 -43
  39. package/dist/discounts/discountsApi.d.ts +0 -56
  40. package/dist/discounts/discountsApi.js +0 -82
  41. package/dist/discounts/discountsInterfaces.d.ts +0 -145
  42. package/dist/discounts/discountsInterfaces.js +0 -2
  43. package/dist/events/eventsApi.d.ts +0 -60
  44. package/dist/events/eventsApi.js +0 -97
  45. package/dist/events/eventsInterfaces.d.ts +0 -87
  46. package/dist/events/eventsInterfaces.js +0 -2
  47. package/dist/file-uploading/fileUploadingApi.d.ts +0 -88
  48. package/dist/file-uploading/fileUploadingApi.js +0 -132
  49. package/dist/file-uploading/fileUploadingInterfaces.d.ts +0 -117
  50. package/dist/file-uploading/fileUploadingInterfaces.js +0 -2
  51. package/dist/file-uploading/fileUploadingSchemas.d.ts +0 -22
  52. package/dist/file-uploading/fileUploadingSchemas.js +0 -21
  53. package/dist/forms/formsApi.d.ts +0 -42
  54. package/dist/forms/formsApi.js +0 -57
  55. package/dist/forms/formsInterfaces.d.ts +0 -132
  56. package/dist/forms/formsInterfaces.js +0 -2
  57. package/dist/forms/formsSchemas.d.ts +0 -50
  58. package/dist/forms/formsSchemas.js +0 -31
  59. package/dist/forms-data/formsDataApi.d.ts +0 -106
  60. package/dist/forms-data/formsDataApi.js +0 -189
  61. package/dist/forms-data/formsDataInterfaces.d.ts +0 -525
  62. package/dist/forms-data/formsDataInterfaces.js +0 -2
  63. package/dist/forms-data/formsDataSchemas.d.ts +0 -115
  64. package/dist/forms-data/formsDataSchemas.js +0 -86
  65. package/dist/general-types/generalTypesApi.d.ts +0 -28
  66. package/dist/general-types/generalTypesApi.js +0 -38
  67. package/dist/general-types/generalTypesInterfaces.d.ts +0 -30
  68. package/dist/general-types/generalTypesInterfaces.js +0 -2
  69. package/dist/general-types/generalTypesSchemas.d.ts +0 -50
  70. package/dist/general-types/generalTypesSchemas.js +0 -35
  71. package/dist/index.d.ts +0 -100
  72. package/dist/index.js +0 -103
  73. package/dist/integration-collections/integrationCollectionsApi.d.ts +0 -173
  74. package/dist/integration-collections/integrationCollectionsApi.js +0 -220
  75. package/dist/integration-collections/integrationCollectionsInterfaces.d.ts +0 -313
  76. package/dist/integration-collections/integrationCollectionsInterfaces.js +0 -2
  77. package/dist/integration-collections/integrationCollectionsSchemas.d.ts +0 -80
  78. package/dist/integration-collections/integrationCollectionsSchemas.js +0 -61
  79. package/dist/locales/localesApi.d.ts +0 -27
  80. package/dist/locales/localesApi.js +0 -37
  81. package/dist/locales/localesInterfaces.d.ts +0 -41
  82. package/dist/locales/localesInterfaces.js +0 -2
  83. package/dist/locales/localesSchemas.d.ts +0 -32
  84. package/dist/locales/localesSchemas.js +0 -26
  85. package/dist/menus/menusApi.d.ts +0 -29
  86. package/dist/menus/menusApi.js +0 -39
  87. package/dist/menus/menusInterfaces.d.ts +0 -88
  88. package/dist/menus/menusInterfaces.js +0 -4
  89. package/dist/menus/menusSchemas.d.ts +0 -16
  90. package/dist/menus/menusSchemas.js +0 -28
  91. package/dist/orders/ordersApi.d.ts +0 -149
  92. package/dist/orders/ordersApi.js +0 -203
  93. package/dist/orders/ordersInterfaces.d.ts +0 -527
  94. package/dist/orders/ordersInterfaces.js +0 -2
  95. package/dist/orders/ordersSchemas.d.ts +0 -120
  96. package/dist/orders/ordersSchemas.js +0 -101
  97. package/dist/pages/pagesApi.d.ts +0 -151
  98. package/dist/pages/pagesApi.js +0 -390
  99. package/dist/pages/pagesInterfaces.d.ts +0 -292
  100. package/dist/pages/pagesInterfaces.js +0 -2
  101. package/dist/pages/pagesSchemas.d.ts +0 -85
  102. package/dist/pages/pagesSchemas.js +0 -46
  103. package/dist/payments/paymentsApi.d.ts +0 -82
  104. package/dist/payments/paymentsApi.js +0 -121
  105. package/dist/payments/paymentsInterfaces.d.ts +0 -206
  106. package/dist/payments/paymentsInterfaces.js +0 -2
  107. package/dist/payments/paymentsSchemas.d.ts +0 -100
  108. package/dist/payments/paymentsSchemas.js +0 -65
  109. package/dist/product-statuses/productStatusesApi.d.ts +0 -47
  110. package/dist/product-statuses/productStatusesApi.js +0 -70
  111. package/dist/product-statuses/productStatusesInterfaces.d.ts +0 -66
  112. package/dist/product-statuses/productStatusesInterfaces.js +0 -2
  113. package/dist/product-statuses/productStatusesSchemas.d.ts +0 -34
  114. package/dist/product-statuses/productStatusesSchemas.js +0 -30
  115. package/dist/products/productsApi.d.ts +0 -365
  116. package/dist/products/productsApi.js +0 -459
  117. package/dist/products/productsInterfaces.d.ts +0 -586
  118. package/dist/products/productsInterfaces.js +0 -2
  119. package/dist/products/productsSchemas.d.ts +0 -192
  120. package/dist/products/productsSchemas.js +0 -96
  121. package/dist/sitemap/sitemapApi.d.ts +0 -35
  122. package/dist/sitemap/sitemapApi.js +0 -45
  123. package/dist/sitemap/sitemapInterfaces.d.ts +0 -40
  124. package/dist/sitemap/sitemapInterfaces.js +0 -2
  125. package/dist/system/systemApi.d.ts +0 -43
  126. package/dist/system/systemApi.js +0 -58
  127. package/dist/system/systemInterfaces.d.ts +0 -31
  128. package/dist/system/systemInterfaces.js +0 -5
  129. package/dist/templates/templatesApi.d.ts +0 -49
  130. package/dist/templates/templatesApi.js +0 -75
  131. package/dist/templates/templatesInterfaces.d.ts +0 -70
  132. package/dist/templates/templatesInterfaces.js +0 -2
  133. package/dist/templates/templatesSchemas.d.ts +0 -48
  134. package/dist/templates/templatesSchemas.js +0 -31
  135. package/dist/templates-preview/templatesPreviewApi.d.ts +0 -38
  136. package/dist/templates-preview/templatesPreviewApi.js +0 -53
  137. package/dist/templates-preview/templatesPreviewInterfaces.d.ts +0 -121
  138. package/dist/templates-preview/templatesPreviewInterfaces.js +0 -2
  139. package/dist/templates-preview/templatesPreviewSchemas.d.ts +0 -83
  140. package/dist/templates-preview/templatesPreviewSchemas.js +0 -48
  141. package/dist/users/usersApi.d.ts +0 -143
  142. package/dist/users/usersApi.js +0 -173
  143. package/dist/users/usersInterfaces.d.ts +0 -235
  144. package/dist/users/usersInterfaces.js +0 -2
  145. package/dist/users/usersSchemas.d.ts +0 -38
  146. package/dist/users/usersSchemas.js +0 -28
  147. package/dist/web-socket/wsApi.d.ts +0 -25
  148. package/dist/web-socket/wsApi.js +0 -45
  149. package/dist/web-socket/wsInterfaces.d.ts +0 -17
  150. package/dist/web-socket/wsInterfaces.js +0 -2
@@ -1,197 +0,0 @@
1
- /**
2
- * @typedef {string} Types - Type of block.
3
- */
4
- type Types = 'product' | 'error_page' | 'catalog_page' | 'product_preview' | 'similar_products_block' | 'product_block' | 'form' | 'common_page' | 'common_block' | 'order' | 'service' | 'none';
5
- /**
6
- * @property {string} [token] - If your project is protected by a token, specify this token in this parameter.
7
- * @property {string} [langCode] - specify the default language to avoid specifying it in every request.
8
- * @property {boolean} [traficLimit] - Some methods use multiple queries to make it easier to work with the API. Set this parameter to "false" to save traffic and decide for yourself what data you need.
9
- * @property {boolean} [rawData] - Set to true to receive raw API responses without any transformation.
10
- * @property {object} [validation] - Validation settings for API responses.
11
- * @property {boolean} [auth] - An object with authorization settings.
12
- * @property {boolean} [auth.customAuth] - Set this flag to true if you want to configure the authorization process yourself. Set the flag to false, or do not pass it at all to have automatic authorization and token renewal.
13
- * @property {boolean} [auth.refreshToken] - Transfer the refresh token here, for example from the local storage, to resume the user's session. Otherwise, the user will need to log in every time a new session is created.
14
- * @property {boolean} [auth.providerMarker] - The marker of the provider, for example, email, google, facebook, etc. Default 'email';
15
- * @property {boolean} [auth.saveFunction] - If you want to store the token between sessions, for example in local storage, create a custom function that takes refreshToken as a parameter and executes the necessary instructions. This function will be called every time the tokens are updated.
16
- * @property {object} [errors] - Error handling settings.
17
- * @example
18
- * ```ts
19
- * const saveToken = (token) => {
20
- * localStorage.setItem('refresh', token)
21
- * }
22
- *
23
- * const config = {
24
- * token: 'project.token.here',
25
- * langCode: 'en_US',
26
- * multipleRequests: true,
27
- * auth: {
28
- * customAuth: false,
29
- * refreshToken: 'user.refresh.token',
30
- * providerMarker: 'email',
31
- * saveFunction: saveToken
32
- * },
33
- * errors: {
34
- * isShell: true,
35
- * customErrors: {
36
- * '400': badRequestFunction,
37
- * '404': notFoundFunction,
38
- * '429': rateLimitFunction,
39
- * '500': serverErrorFunction,
40
- * '503': serviceUnavailableFunction
41
- * }
42
- * }
43
- * }
44
- * ```
45
- */
46
- interface IConfig {
47
- token?: string;
48
- langCode?: string;
49
- traficLimit?: boolean;
50
- rawData?: boolean;
51
- validation?: {
52
- enabled?: boolean;
53
- strictMode?: boolean;
54
- logErrors?: boolean;
55
- };
56
- auth?: {
57
- customAuth?: boolean;
58
- refreshToken?: string;
59
- providerMarker?: string;
60
- saveFunction?: (refreshToken: string) => void;
61
- };
62
- errors?: {
63
- isShell?: boolean;
64
- customErrors?: {
65
- 400?: (data?: IError) => any;
66
- 401?: (data?: IError) => any;
67
- 403?: (data?: IError) => any;
68
- 404?: (data?: IError) => any;
69
- 429?: (data?: IError) => any;
70
- 500?: (data?: IError) => any;
71
- 502?: (data?: IError) => any;
72
- 503?: (data?: IError) => any;
73
- 504?: (data?: IError) => any;
74
- };
75
- };
76
- }
77
- /**
78
- * @interface IAttributes
79
- * @property {Array<object>} listTitles - List of titles.
80
- * @property {ILocalizeInfo} localizeInfos - Localization information.
81
- * @property {string} marker - Attribute marker.
82
- * @property {number} position - Attribute position.
83
- * @property {boolean} isVisible - Indicates whether the attribute is visible.
84
- * @property {string} type - Attribute type.
85
- * @property {Record<string, any>} settings - Additional settings for the attribute.
86
- * @property {Record<string, any>} validators - Validators for the attribute.
87
- * @property {Record<string, any>} additionalFields - Additional fields for the attribute.
88
- * @description Interface for attributes.
89
- */
90
- interface IAttributes {
91
- listTitles: Array<{
92
- title: string;
93
- value: number | string | null;
94
- position: number;
95
- extended: {
96
- value: string | number | null;
97
- type: string | number | null;
98
- };
99
- }>;
100
- localizeInfos: ILocalizeInfo;
101
- marker: string;
102
- position: number;
103
- isVisible: boolean;
104
- type: string;
105
- settings?: Record<string, any>;
106
- validators: Record<string, any>;
107
- additionalFields?: any;
108
- [key: string]: any;
109
- }
110
- /**
111
- * @interface ILocalizeInfos
112
- * @property {Record<string, ILocalizeInfo>} - Localization information.
113
- * @description Interface for localization information.
114
- */
115
- interface ILocalizeInfos {
116
- [key: string]: ILocalizeInfo;
117
- }
118
- /**
119
- * Interface for localization information.
120
- * @property {Record<string, any>} - Localization information.
121
- * @description Interface for localization information.
122
- */
123
- interface ILocalizeInfo {
124
- [key: string]: any;
125
- }
126
- /**
127
- * @interface IAttributeValues
128
- * @property {Record<string, IAttributeValue>} - Attribute values.
129
- * @description Interface for attribute values.
130
- */
131
- interface IAttributeValues {
132
- [key: string]: IAttributeValue;
133
- }
134
- /**
135
- * @interface IAttributeValue
136
- * @property {Record<string, any>} - Attribute value.
137
- * @description Interface for attribute value.
138
- */
139
- interface IAttributeValue {
140
- [key: string]: any;
141
- }
142
- /**
143
- * @interface IError
144
- * @property {string} message - Error message.
145
- * @property {any} pageData - Page data.
146
- * @property {number} statusCode - Status code.
147
- * @property {string} timestamp - Timestamp.
148
- * @property {Record<string, any>} - Attribute value.
149
- * @description Interface for error.
150
- */
151
- interface IError {
152
- message: string;
153
- pageData: any;
154
- statusCode: number;
155
- timestamp: string;
156
- [key: string]: any;
157
- }
158
- /**
159
- * @interface IHttpHeaders
160
- * @property {string} [Content-Type] - Content type header
161
- * @property {string} [x-app-token] - App token header
162
- * @property {string} [x-device-metadata] - Device metadata header
163
- * @property {string} [Authorization] - Authorization header
164
- * @description Interface for HTTP headers
165
- */
166
- interface IHttpHeaders {
167
- 'Content-Type'?: string;
168
- 'x-app-token'?: string;
169
- 'x-device-metadata'?: string;
170
- Authorization?: string;
171
- [key: string]: string | undefined;
172
- }
173
- /**
174
- * @interface IHttpOptions
175
- * @property {string} method - HTTP method
176
- * @property {IHttpHeaders} headers - HTTP headers
177
- * @property {string | FormData | Blob} [body] - Request body
178
- * @description Interface for HTTP request options
179
- */
180
- interface IHttpOptions {
181
- method: string;
182
- headers: IHttpHeaders;
183
- body?: string | FormData | Blob;
184
- }
185
- /**
186
- * AttributeType
187
- */
188
- type AttributeType = IAttributeValue | IAttributeValues;
189
- /**
190
- * LangType
191
- */
192
- type LangType = string | Array<string>;
193
- /**
194
- * LocalizeType
195
- */
196
- type LocalizeType = ILocalizeInfos | ILocalizeInfo;
197
- export type { AttributeType, IAttributes, IAttributeValues, IConfig, IError, IHttpHeaders, IHttpOptions, ILocalizeInfo, ILocalizeInfos, LangType, LocalizeType, Types, };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,118 +0,0 @@
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.ZodOptional<z.ZodString>;
45
- email: z.ZodOptional<z.ZodString>;
46
- phoneMask: z.ZodOptional<z.ZodString>;
47
- phoneCode: z.ZodOptional<z.ZodString>;
48
- phoneNumber: z.ZodOptional<z.ZodString>;
49
- statusMarker: z.ZodOptional<z.ZodString>;
50
- formData: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodAny>, z.ZodRecord<z.ZodString, z.ZodAny>]>>;
51
- total: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
52
- authProviderIdentifier: z.ZodOptional<z.ZodString>;
53
- formIdentifier: z.ZodOptional<z.ZodString>;
54
- groups: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
55
- state: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
56
- moduleFormConfigs: z.ZodOptional<z.ZodArray<z.ZodAny>>;
57
- }, z.core.$strip>;
58
- /**
59
- * Auth entity schema
60
- * API returns only accessToken and refreshToken
61
- * userIdentifier and authProviderIdentifier are optional legacy fields
62
- */
63
- export declare const AuthEntitySchema: z.ZodObject<{
64
- accessToken: z.ZodString;
65
- refreshToken: z.ZodString;
66
- userIdentifier: z.ZodOptional<z.ZodString>;
67
- authProviderIdentifier: z.ZodOptional<z.ZodString>;
68
- user: z.ZodOptional<z.ZodObject<{
69
- id: z.ZodNumber;
70
- identifier: z.ZodOptional<z.ZodString>;
71
- email: z.ZodOptional<z.ZodString>;
72
- phoneMask: z.ZodOptional<z.ZodString>;
73
- phoneCode: z.ZodOptional<z.ZodString>;
74
- phoneNumber: z.ZodOptional<z.ZodString>;
75
- statusMarker: z.ZodOptional<z.ZodString>;
76
- formData: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodAny>, z.ZodRecord<z.ZodString, z.ZodAny>]>>;
77
- total: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
78
- authProviderIdentifier: z.ZodOptional<z.ZodString>;
79
- formIdentifier: z.ZodOptional<z.ZodString>;
80
- groups: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
81
- state: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
82
- moduleFormConfigs: z.ZodOptional<z.ZodArray<z.ZodAny>>;
83
- }, z.core.$strip>>;
84
- }, z.core.$strip>;
85
- /**
86
- * Paginated response schema factory
87
- * @param {T} itemSchema - The schema for each item in the paginated response
88
- * @returns {any} Paginated response schema
89
- */
90
- export declare function createPaginatedSchema<T extends z.ZodTypeAny>(itemSchema: T): any;
91
- /**
92
- * Validation helper function
93
- * @param {z.ZodSchema<T>} schema - Zod schema to validate against
94
- * @param {unknown} data - Data to validate
95
- * @param {object} options - Validation options
96
- * @param {boolean} options.strict - Whether to use strict mode
97
- * @param {boolean} options.logErrors - Whether to log errors
98
- * @returns {object} Validated data or error
99
- */
100
- export declare function validateResponse<T>(schema: z.ZodSchema<T>, data: unknown, options?: {
101
- strict?: boolean;
102
- logErrors?: boolean;
103
- }): {
104
- success: true;
105
- data: T;
106
- } | {
107
- success: false;
108
- error: z.ZodError;
109
- };
110
- /**
111
- * Safe validation helper - returns data even if validation fails
112
- * Used when strict mode is disabled
113
- * @param {z.ZodSchema<T>} schema - Zod schema to validate against
114
- * @param {unknown} data - Data to validate
115
- * @param {boolean} logErrors - Whether to log errors
116
- * @returns {T} Validated data or original data if validation fails in non-strict mode
117
- */
118
- export declare function validateResponseSafe<T>(schema: z.ZodSchema<T>, data: unknown, logErrors?: boolean): T;
@@ -1,132 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AuthEntitySchema = exports.UserEntitySchema = exports.AttributeSchema = exports.LocalizeInfoSchema = exports.ErrorSchema = void 0;
4
- exports.createPaginatedSchema = createPaginatedSchema;
5
- exports.validateResponse = validateResponse;
6
- exports.validateResponseSafe = validateResponseSafe;
7
- /* eslint-disable jsdoc/reject-any-type */
8
- /* eslint-disable jsdoc/no-undefined-types */
9
- const zod_1 = require("zod");
10
- /**
11
- * Common validation schemas for API responses
12
- * @description Base schemas that can be reused across different modules
13
- */
14
- /**
15
- * Error response schema
16
- */
17
- exports.ErrorSchema = zod_1.z.object({
18
- statusCode: zod_1.z.number(),
19
- message: zod_1.z.string(),
20
- localizeMessage: zod_1.z.string().optional(),
21
- });
22
- /**
23
- * Localize info schema
24
- */
25
- exports.LocalizeInfoSchema = zod_1.z.object({
26
- title: zod_1.z.string(),
27
- content: zod_1.z.string().optional(),
28
- menuTitle: zod_1.z.string().optional(),
29
- });
30
- /**
31
- * Attribute schema
32
- */
33
- exports.AttributeSchema = zod_1.z.object({
34
- id: zod_1.z.number().optional(),
35
- marker: zod_1.z.string(),
36
- type: zod_1.z.string(),
37
- isVisible: zod_1.z.boolean().optional(),
38
- isRequired: zod_1.z.boolean().optional(),
39
- position: zod_1.z.number().optional(),
40
- localizeInfos: zod_1.z.record(zod_1.z.string(), exports.LocalizeInfoSchema).optional(),
41
- value: zod_1.z.any().optional(),
42
- });
43
- /**
44
- * User entity schema
45
- */
46
- exports.UserEntitySchema = zod_1.z.object({
47
- id: zod_1.z.number(),
48
- identifier: zod_1.z.string().optional(),
49
- email: zod_1.z.string().email().optional(),
50
- phoneMask: zod_1.z.string().optional(),
51
- phoneCode: zod_1.z.string().optional(),
52
- phoneNumber: zod_1.z.string().optional(),
53
- statusMarker: zod_1.z.string().optional(),
54
- formData: zod_1.z
55
- .union([zod_1.z.array(zod_1.z.any()), zod_1.z.record(zod_1.z.string(), zod_1.z.any())])
56
- .optional(),
57
- total: zod_1.z.union([zod_1.z.number(), zod_1.z.string()]).optional(),
58
- authProviderIdentifier: zod_1.z.string().optional(),
59
- formIdentifier: zod_1.z.string().optional(),
60
- groups: zod_1.z.array(zod_1.z.number()).optional(),
61
- state: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
62
- moduleFormConfigs: zod_1.z.array(zod_1.z.any()).optional(),
63
- });
64
- /**
65
- * Auth entity schema
66
- * API returns only accessToken and refreshToken
67
- * userIdentifier and authProviderIdentifier are optional legacy fields
68
- */
69
- exports.AuthEntitySchema = zod_1.z.object({
70
- accessToken: zod_1.z.string(),
71
- refreshToken: zod_1.z.string(),
72
- userIdentifier: zod_1.z.string().optional(),
73
- authProviderIdentifier: zod_1.z.string().optional(),
74
- user: exports.UserEntitySchema.optional(),
75
- });
76
- /**
77
- * Paginated response schema factory
78
- * @param {T} itemSchema - The schema for each item in the paginated response
79
- * @returns {any} Paginated response schema
80
- */
81
- function createPaginatedSchema(itemSchema) {
82
- return zod_1.z.object({
83
- items: zod_1.z.array(itemSchema),
84
- total: zod_1.z.number(),
85
- page: zod_1.z.number().optional(),
86
- limit: zod_1.z.number().optional(),
87
- });
88
- }
89
- /**
90
- * Validation helper function
91
- * @param {z.ZodSchema<T>} schema - Zod schema to validate against
92
- * @param {unknown} data - Data to validate
93
- * @param {object} options - Validation options
94
- * @param {boolean} options.strict - Whether to use strict mode
95
- * @param {boolean} options.logErrors - Whether to log errors
96
- * @returns {object} Validated data or error
97
- */
98
- function validateResponse(schema, data, options) {
99
- try {
100
- const validated = schema.parse(data);
101
- return { success: true, data: validated };
102
- }
103
- catch (error) {
104
- if (error instanceof zod_1.z.ZodError) {
105
- if (options === null || options === void 0 ? void 0 : options.logErrors) {
106
- // eslint-disable-next-line no-undef, no-console
107
- console.error('Validation error:', {
108
- errors: error.issues,
109
- data,
110
- });
111
- }
112
- return { success: false, error };
113
- }
114
- throw error;
115
- }
116
- }
117
- /**
118
- * Safe validation helper - returns data even if validation fails
119
- * Used when strict mode is disabled
120
- * @param {z.ZodSchema<T>} schema - Zod schema to validate against
121
- * @param {unknown} data - Data to validate
122
- * @param {boolean} logErrors - Whether to log errors
123
- * @returns {T} Validated data or original data if validation fails in non-strict mode
124
- */
125
- function validateResponseSafe(schema, data, logErrors = false) {
126
- const result = validateResponse(schema, data, { logErrors });
127
- if (result.success) {
128
- return result.data;
129
- }
130
- // Return original data if validation fails in non-strict mode
131
- return data;
132
- }
@@ -1,76 +0,0 @@
1
- import AsyncModules from '../base/asyncModules';
2
- import type StateModule from '../base/stateModule';
3
- import type { IError } from '../base/utils';
4
- import type { BlockType, IBlockEntity, IBlocks, IBlocksResponse, ISearchBlock } from './blocksInterfaces';
5
- /**
6
- * Controllers for working with blocks.
7
- * @handle /api/content/blocks
8
- * @class BlocksApi
9
- * @augments AsyncModules
10
- * @implements {IBlocks}
11
- * @description This class provides methods to interact with blocks.
12
- */
13
- export default class BlocksApi extends AsyncModules implements IBlocks {
14
- protected state: StateModule;
15
- protected _url: string;
16
- /**
17
- * Constructor for BlocksApi class.
18
- */
19
- constructor(state: StateModule);
20
- /**
21
- * Get blocks by parameters.
22
- * @handleName getBlocks
23
- * @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'.
24
- * @param {string} [langCode] - Language code. Default: "en_US".
25
- * @param {number} [offset] - Parameter for pagination. Default: 0.
26
- * @param {number} [limit] - Parameter for pagination. Default: 30.
27
- * @returns {Promise<IBlocksResponse | IError>} Returns BlocksEntity object.
28
- * @throws {IError} When isShell=false and an error occurs during the fetch
29
- */
30
- getBlocks(type?: BlockType, langCode?: string, offset?: number, limit?: number): Promise<IBlocksResponse | IError>;
31
- /**
32
- * Get block by marker.
33
- * @handleName getBlockByMarker
34
- * @param {string} marker - Marker of Block. Example: "product_block".
35
- * @param {string} [langCode] - Language code. Default: "en_US".
36
- * @param {number} [offset] - Parameter for pagination. Default: 0.
37
- * @param {number} [limit] - Parameter for pagination. Default: 30.
38
- * @returns {Promise<IBlockEntity | IError>} - Returns a BlockEntity object.
39
- * @throws {IError} When isShell=false and an error occurs during the fetch
40
- * @description This method retrieves a block by its marker and includes additional information such as similar products or products associated with the block.
41
- */
42
- getBlockByMarker(marker: string, langCode?: string, offset?: number, limit?: number): Promise<IBlockEntity | IError>;
43
- /**
44
- * Get similar products by block marker.
45
- * @handleName getSimilarProducts
46
- * @param {string} marker - Block identifier. Example: "similar_products_block".
47
- * @param {string} [langCode] - Language code. Default: "en_US".
48
- * @param {number} [offset] - Parameter for pagination. Default: 0.
49
- * @param {number} [limit] - Parameter for pagination. Default: 30.
50
- * @param {string} [signPrice] - Sign price.
51
- * @returns {Promise<IProductsResponse | IError>} - Returns the total count and an array of product items in object by specified block marker.
52
- * @throws {IError} When isShell=false and an error occurs during the fetch
53
- */
54
- private getSimilarProducts;
55
- /**
56
- * Get products by block marker.
57
- * @handleName getProductsByBlockMarker
58
- * @param {string} marker - Block identifier. Example: "product_block".
59
- * @param {string} [langCode] - Language code. Default: "en_US".
60
- * @param {number} [offset] - Parameter for pagination. Default: 0.
61
- * @param {number} [limit] - Parameter for pagination. Default: 30.
62
- * @param {string} [signPrice] - Sign price.
63
- * @returns {Promise<IProductsEntity[] | IError>} Return array of BlocksEntity object.
64
- * @throws {IError} When isShell=false and an error occurs during the fetch
65
- */
66
- private getProductsByBlockMarker;
67
- /**
68
- * Quick search for block objects with limited output.
69
- * @handleName searchBlock
70
- * @param {string} name - Search string. Example: "product_block".
71
- * @param {string} [langCode] - Language code. Default: "en_US".
72
- * @returns {Promise<ISearchBlock[] | IError>} Returns an array of ISearchBlock objects.
73
- * @throws {IError} When isShell=false and an error occurs during the fetch
74
- */
75
- searchBlock(name: string, langCode?: string): Promise<ISearchBlock[] | IError>;
76
- }