oneentry 1.0.143 → 1.0.145

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 (53) hide show
  1. package/configure.js +2 -2
  2. package/dist/admins/adminsInterfaces.d.ts +3 -0
  3. package/dist/admins/adminsSchemas.d.ts +2 -0
  4. package/dist/admins/adminsSchemas.js +2 -1
  5. package/dist/attribute-sets/attributeSetsSchemas.d.ts +0 -2
  6. package/dist/attribute-sets/attributeSetsSchemas.js +0 -3
  7. package/dist/auth-provider/authProviderSchemas.d.ts +27 -36
  8. package/dist/auth-provider/authProviderSchemas.js +17 -6
  9. package/dist/auth-provider/authProvidersInterfaces.d.ts +22 -15
  10. package/dist/base/syncModules.js +17 -5
  11. package/dist/base/utils.d.ts +1 -1
  12. package/dist/base/validation.d.ts +10 -30
  13. package/dist/base/validation.js +10 -17
  14. package/dist/blocks/blocksApi.d.ts +12 -0
  15. package/dist/blocks/blocksApi.js +19 -0
  16. package/dist/blocks/blocksInterfaces.d.ts +12 -1
  17. package/dist/blocks/blocksSchemas.d.ts +68 -100
  18. package/dist/discounts/discountsApi.d.ts +22 -2
  19. package/dist/discounts/discountsApi.js +34 -0
  20. package/dist/discounts/discountsInterfaces.d.ts +82 -6
  21. package/dist/forms/formsApi.d.ts +3 -3
  22. package/dist/forms/formsApi.js +1 -1
  23. package/dist/forms/formsInterfaces.d.ts +33 -7
  24. package/dist/forms/formsSchemas.d.ts +20 -14
  25. package/dist/forms/formsSchemas.js +6 -2
  26. package/dist/forms-data/formsDataInterfaces.d.ts +3 -3
  27. package/dist/forms-data/formsDataSchemas.d.ts +4 -12
  28. package/dist/forms-data/formsDataSchemas.js +3 -3
  29. package/dist/general-types/generalTypesSchemas.d.ts +2 -0
  30. package/dist/general-types/generalTypesSchemas.js +1 -0
  31. package/dist/index.d.ts +24 -0
  32. package/dist/orders/ordersApi.d.ts +27 -1
  33. package/dist/orders/ordersApi.js +44 -0
  34. package/dist/orders/ordersInterfaces.d.ts +78 -3
  35. package/dist/orders/ordersSchemas.d.ts +49 -34
  36. package/dist/orders/ordersSchemas.js +38 -29
  37. package/dist/pages/pagesInterfaces.d.ts +2 -0
  38. package/dist/pages/pagesSchemas.d.ts +7 -1
  39. package/dist/pages/pagesSchemas.js +5 -1
  40. package/dist/payments/paymentsSchemas.d.ts +4 -4
  41. package/dist/payments/paymentsSchemas.js +1 -1
  42. package/dist/products/productsApi.d.ts +6 -5
  43. package/dist/products/productsApi.js +11 -12
  44. package/dist/products/productsInterfaces.d.ts +19 -3
  45. package/dist/products/productsSchemas.d.ts +68 -100
  46. package/dist/products/productsSchemas.js +17 -19
  47. package/dist/system/systemApi.d.ts +2 -2
  48. package/dist/system/systemApi.js +2 -2
  49. package/dist/system/systemInterfaces.d.ts +1 -1
  50. package/dist/users/usersInterfaces.d.ts +2 -0
  51. package/dist/users/usersSchemas.d.ts +8 -14
  52. package/dist/users/usersSchemas.js +1 -4
  53. package/package.json +2 -2
package/configure.js CHANGED
@@ -145,7 +145,7 @@ function addOneEntryConfig(projectName, url, token) {
145
145
  const libDir = path.join(projectName, 'src', 'lib');
146
146
  fs.mkdirSync(libDir, { recursive: true });
147
147
 
148
- const tokenLine = token ? `\n token: process.env.ONEENTRY_TOKEN,` : '';
148
+ const tokenLine = token ? `\n token: process.env.NEXT_PUBLIC_ONEENTRY_TOKEN,` : '';
149
149
  const libContent = `import { defineOneEntry } from 'oneentry';
150
150
 
151
151
  const { Admins, Pages, Products } = defineOneEntry(
@@ -158,7 +158,7 @@ const { Admins, Pages, Products } = defineOneEntry(
158
158
  export { Admins, Pages, Products };
159
159
  `;
160
160
 
161
- const envContent = `NEXT_PUBLIC_ONEENTRY_URL=${url}\n${token ? `ONEENTRY_TOKEN=${token}\n` : ''}`;
161
+ const envContent = `NEXT_PUBLIC_ONEENTRY_URL=${url}\n${token ? `NEXT_PUBLIC_ONEENTRY_TOKEN=${token}\n` : ''}`;
162
162
 
163
163
  fs.writeFile(path.join(libDir, 'oneentry.ts'), libContent, (err) => {
164
164
  if (err) {
@@ -1,4 +1,5 @@
1
1
  import type { AttributeType, IAttributeValues, IError } from '../base/utils';
2
+ import type { IFormConfig } from '../forms/formsInterfaces';
2
3
  /**
3
4
  * @interface IAdmins
4
5
  * @description This interface defines the contract for any class that implements it
@@ -70,6 +71,7 @@ interface IPosition {
70
71
  }
71
72
  }
72
73
  ]
74
+ * @property {IFormConfig[]} [moduleFormConfigs] - Array of module form configurations associated with the admin.
73
75
  * @description This interface captures the essential details and additional attributes of an admin entity.
74
76
  */
75
77
  interface IAdminEntity {
@@ -80,6 +82,7 @@ interface IAdminEntity {
80
82
  position: number | null;
81
83
  isSync: boolean;
82
84
  attributeValues: IAttributeValues;
85
+ moduleFormConfigs?: IFormConfig[];
83
86
  [key: string]: unknown;
84
87
  }
85
88
  /**
@@ -15,6 +15,7 @@ export declare const AdminEntitySchema: z.ZodObject<{
15
15
  position: z.ZodNullable<z.ZodNumber>;
16
16
  isSync: z.ZodBoolean;
17
17
  attributeValues: z.ZodRecord<z.ZodString, z.ZodAny>;
18
+ moduleFormConfigs: z.ZodOptional<z.ZodArray<z.ZodAny>>;
18
19
  }, z.core.$catchall<z.ZodAny>>;
19
20
  /**
20
21
  * Admins response schema (array of admin entities)
@@ -27,4 +28,5 @@ export declare const AdminsResponseSchema: z.ZodArray<z.ZodObject<{
27
28
  position: z.ZodNullable<z.ZodNumber>;
28
29
  isSync: z.ZodBoolean;
29
30
  attributeValues: z.ZodRecord<z.ZodString, z.ZodAny>;
31
+ moduleFormConfigs: z.ZodOptional<z.ZodArray<z.ZodAny>>;
30
32
  }, z.core.$catchall<z.ZodAny>>>;
@@ -19,8 +19,9 @@ exports.AdminEntitySchema = zod_1.z
19
19
  position: zod_1.z.number().nullable(),
20
20
  isSync: zod_1.z.boolean(),
21
21
  attributeValues: zod_1.z.record(zod_1.z.string(), zod_1.z.any()),
22
+ moduleFormConfigs: zod_1.z.array(zod_1.z.any()).optional(),
22
23
  })
23
- .catchall(zod_1.z.any()); // Allow additional dynamic properties
24
+ .catchall(zod_1.z.any());
24
25
  /**
25
26
  * Admins response schema (array of admin entities)
26
27
  */
@@ -28,7 +28,6 @@ export declare const AttributeEntitySchema: z.ZodObject<{
28
28
  validators: z.ZodOptional<z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodArray<z.ZodAny>]>>;
29
29
  localizeInfos: z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodArray<z.ZodAny>]>;
30
30
  additionalFields: z.ZodOptional<z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodArray<z.ZodAny>]>>;
31
- settings: z.ZodOptional<z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodArray<z.ZodAny>]>>;
32
31
  }, z.core.$strip>;
33
32
  /**
34
33
  * Attribute set entity schema (attribute set object)
@@ -86,5 +85,4 @@ export declare const AttributesArrayResponseSchema: z.ZodArray<z.ZodObject<{
86
85
  validators: z.ZodOptional<z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodArray<z.ZodAny>]>>;
87
86
  localizeInfos: z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodArray<z.ZodAny>]>;
88
87
  additionalFields: z.ZodOptional<z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodArray<z.ZodAny>]>>;
89
- settings: z.ZodOptional<z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodArray<z.ZodAny>]>>;
90
88
  }, z.core.$strip>>;
@@ -37,9 +37,6 @@ exports.AttributeEntitySchema = zod_1.z.object({
37
37
  additionalFields: zod_1.z
38
38
  .union([zod_1.z.record(zod_1.z.string(), zod_1.z.any()), zod_1.z.array(zod_1.z.any())])
39
39
  .optional(),
40
- settings: zod_1.z
41
- .union([zod_1.z.record(zod_1.z.string(), zod_1.z.any()), zod_1.z.array(zod_1.z.any())])
42
- .optional(),
43
40
  });
44
41
  /**
45
42
  * Attribute set entity schema (attribute set object)
@@ -9,38 +9,33 @@ import { z } from 'zod';
9
9
  */
10
10
  export declare const SignUpResponseSchema: z.ZodObject<{
11
11
  id: z.ZodNumber;
12
- identifier: z.ZodOptional<z.ZodString>;
13
- email: z.ZodOptional<z.ZodString>;
14
- phoneMask: z.ZodOptional<z.ZodString>;
15
- phoneCode: z.ZodOptional<z.ZodString>;
16
- phoneNumber: z.ZodOptional<z.ZodString>;
17
- statusMarker: z.ZodOptional<z.ZodString>;
12
+ updatedDate: z.ZodString;
13
+ version: z.ZodNumber;
14
+ identifier: z.ZodString;
15
+ isActive: z.ZodBoolean;
16
+ formData: z.ZodUnion<readonly [z.ZodArray<z.ZodAny>, z.ZodRecord<z.ZodString, z.ZodAny>]>;
17
+ notificationData: z.ZodObject<{
18
+ email: z.ZodString;
19
+ phonePush: z.ZodArray<z.ZodString>;
20
+ phoneSMS: z.ZodOptional<z.ZodString>;
21
+ }, z.core.$strip>;
22
+ locale: z.ZodOptional<z.ZodString>;
23
+ createdDate: z.ZodOptional<z.ZodString>;
24
+ importId: z.ZodNullable<z.ZodOptional<z.ZodAny>>;
25
+ deletedAt: z.ZodNullable<z.ZodOptional<z.ZodString>>;
26
+ isDeleted: z.ZodOptional<z.ZodBoolean>;
27
+ state: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
28
+ rating: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
18
29
  }, z.core.$strip>;
19
30
  /**
20
31
  * Auth response schema (login/refresh)
21
32
  * @description Schema for validating auth response
22
33
  */
23
34
  export declare const AuthResponseSchema: z.ZodObject<{
35
+ userIdentifier: z.ZodString;
36
+ authProviderIdentifier: z.ZodString;
24
37
  accessToken: z.ZodString;
25
38
  refreshToken: z.ZodString;
26
- userIdentifier: z.ZodOptional<z.ZodString>;
27
- authProviderIdentifier: z.ZodOptional<z.ZodString>;
28
- user: z.ZodOptional<z.ZodObject<{
29
- id: z.ZodNumber;
30
- identifier: z.ZodOptional<z.ZodString>;
31
- email: z.ZodOptional<z.ZodString>;
32
- phoneMask: z.ZodOptional<z.ZodString>;
33
- phoneCode: z.ZodOptional<z.ZodString>;
34
- phoneNumber: z.ZodOptional<z.ZodString>;
35
- statusMarker: z.ZodOptional<z.ZodString>;
36
- formData: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodAny>, z.ZodRecord<z.ZodString, z.ZodAny>]>>;
37
- total: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
38
- authProviderIdentifier: z.ZodOptional<z.ZodString>;
39
- formIdentifier: z.ZodOptional<z.ZodString>;
40
- groups: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
41
- state: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
42
- moduleFormConfigs: z.ZodOptional<z.ZodArray<z.ZodAny>>;
43
- }, z.core.$strip>>;
44
39
  }, z.core.$strip>;
45
40
  /**
46
41
  * User response schema
@@ -48,19 +43,15 @@ export declare const AuthResponseSchema: z.ZodObject<{
48
43
  */
49
44
  export declare const UserResponseSchema: z.ZodObject<{
50
45
  id: z.ZodNumber;
51
- identifier: z.ZodOptional<z.ZodString>;
52
- email: z.ZodOptional<z.ZodString>;
53
- phoneMask: z.ZodOptional<z.ZodString>;
54
- phoneCode: z.ZodOptional<z.ZodString>;
55
- phoneNumber: z.ZodOptional<z.ZodString>;
56
- statusMarker: z.ZodOptional<z.ZodString>;
57
- formData: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodAny>, z.ZodRecord<z.ZodString, z.ZodAny>]>>;
58
- total: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
59
- authProviderIdentifier: z.ZodOptional<z.ZodString>;
60
- formIdentifier: z.ZodOptional<z.ZodString>;
61
- groups: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
62
- state: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
46
+ identifier: z.ZodString;
47
+ authProviderIdentifier: z.ZodString;
48
+ formData: z.ZodUnion<readonly [z.ZodArray<z.ZodAny>, z.ZodRecord<z.ZodString, z.ZodAny>]>;
49
+ formIdentifier: z.ZodString;
50
+ total: z.ZodString;
51
+ groups: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
52
+ state: z.ZodRecord<z.ZodString, z.ZodAny>;
63
53
  moduleFormConfigs: z.ZodOptional<z.ZodArray<z.ZodAny>>;
54
+ rating: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
64
55
  }, z.core.$strip>;
65
56
  /**
66
57
  * Auth provider entity schema
@@ -13,12 +13,23 @@ const validation_1 = require("../base/validation");
13
13
  */
14
14
  exports.SignUpResponseSchema = zod_1.z.object({
15
15
  id: zod_1.z.number(),
16
- identifier: zod_1.z.string().optional(),
17
- email: zod_1.z.string().email().optional(),
18
- phoneMask: zod_1.z.string().optional(),
19
- phoneCode: zod_1.z.string().optional(),
20
- phoneNumber: zod_1.z.string().optional(),
21
- statusMarker: zod_1.z.string().optional(),
16
+ updatedDate: zod_1.z.string(),
17
+ version: zod_1.z.number(),
18
+ identifier: zod_1.z.string(),
19
+ isActive: zod_1.z.boolean(),
20
+ formData: zod_1.z.union([zod_1.z.array(zod_1.z.any()), zod_1.z.record(zod_1.z.string(), zod_1.z.any())]),
21
+ notificationData: zod_1.z.object({
22
+ email: zod_1.z.string(),
23
+ phonePush: zod_1.z.array(zod_1.z.string()),
24
+ phoneSMS: zod_1.z.string().optional(),
25
+ }),
26
+ locale: zod_1.z.string().optional(),
27
+ createdDate: zod_1.z.string().optional(),
28
+ importId: zod_1.z.any().optional().nullable(),
29
+ deletedAt: zod_1.z.string().optional().nullable(),
30
+ isDeleted: zod_1.z.boolean().optional(),
31
+ state: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
32
+ rating: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
22
33
  });
23
34
  /**
24
35
  * Auth response schema (login/refresh)
@@ -241,18 +241,16 @@ interface IOauthData {
241
241
  * @property {number} version - The version number of the sign-up entity. Example: 1.
242
242
  * @property {string} identifier - A unique string that identifies the sign-up entity. Example: "signup_12345".
243
243
  * @property {boolean} isActive - Indicates whether the sign-up entity is active. Example: true.
244
- * @property {Array<object>} formData - An array of objects representing the form data, each containing a marker and its corresponding value.
244
+ * @property {Array<object> | Record<string, unknown>} formData - Form data, can be an array or a localized record.
245
245
  * @example
246
- [
247
- {
248
- "marker": "first_name",
249
- "value": "John"
250
- },
251
- {
252
- "marker": "last_name",
253
- "value": "Doe"
254
- }
255
- ]
246
+ {
247
+ "en_US": [
248
+ {
249
+ "marker": "first_name",
250
+ "value": "John"
251
+ }
252
+ ]
253
+ }
256
254
  * @property {object} notificationData - An object containing notification data, including email, phonePush, and phoneSMS.
257
255
  * @example
258
256
  {
@@ -261,6 +259,12 @@ interface IOauthData {
261
259
  "phoneSMS": "+99999999999"
262
260
  }
263
261
  * @property {string} [locale] - The locale or language code associated with the sign-up entity. Example: "en_US".
262
+ * @property {string} [createdDate] - The date when the sign-up entity was created. Example: "2023-10-01T12:00:00Z".
263
+ * @property {unknown} [importId] - Import identifier. Example: null.
264
+ * @property {string | null} [deletedAt] - Deletion date or null. Example: null.
265
+ * @property {boolean} [isDeleted] - Whether the entity is deleted. Example: false.
266
+ * @property {Record<string, unknown>} [state] - Additional state information. Example: {}.
267
+ * @property {Record<string, unknown>} [rating] - Rating data. Example: {}.
264
268
  * @description This interface defines the structure of a sign-up entity.
265
269
  */
266
270
  interface ISignUpEntity {
@@ -269,16 +273,19 @@ interface ISignUpEntity {
269
273
  version: number;
270
274
  identifier: string;
271
275
  isActive: boolean;
272
- formData: Array<{
273
- marker: string;
274
- value: string;
275
- }>;
276
+ formData: Array<Record<string, any>> | Record<string, any>;
276
277
  notificationData: {
277
278
  email: string;
278
279
  phonePush: Array<string>;
279
280
  phoneSMS?: string;
280
281
  };
281
282
  locale?: string;
283
+ createdDate?: string;
284
+ importId?: unknown;
285
+ deletedAt?: string | null;
286
+ isDeleted?: boolean;
287
+ state?: Record<string, any>;
288
+ rating?: Record<string, unknown>;
282
289
  }
283
290
  /**
284
291
  * Interface representing a code entity used for user registration or verification processes.
@@ -535,17 +535,24 @@ class SyncModules {
535
535
  attributeValues: this._sortAttributes(data.attributeValues),
536
536
  };
537
537
  }
538
+ const booleanFields = [
539
+ 'isLogin',
540
+ 'isSignUp',
541
+ 'isNotificationEmail',
542
+ 'isNotificationPhonePush',
543
+ 'isNotificationPhoneSMS',
544
+ ];
538
545
  // for forms attributes - forms attributes collections
539
546
  if ('attributes' in data) {
540
547
  const d = data.attributes;
541
548
  Object.keys(d).forEach((attr) => {
542
549
  var _a;
543
550
  this._normalizeAdditionalFields(d[attr]);
544
- // Normalize numbers
545
- // if (d[attr].type === 'integer' || d[attr].type === 'float') {
546
- // const numValue = Number(d[attr].value);
547
- // d[attr].value = isNaN(numValue) ? null : numValue;
548
- // }
551
+ for (const field of booleanFields) {
552
+ if (field in d[attr] && d[attr][field] === null) {
553
+ d[attr][field] = false;
554
+ }
555
+ }
549
556
  // Add time intervals
550
557
  if (d[attr].type === 'timeInterval') {
551
558
  const intervals = (_a = d[attr].localizeInfos) === null || _a === void 0 ? void 0 : _a.intervals;
@@ -561,6 +568,11 @@ class SyncModules {
561
568
  // For single attribute - for attribute sets
562
569
  if ('type' in data) {
563
570
  this._normalizeAdditionalFields(data);
571
+ for (const field of booleanFields) {
572
+ if (field in data && data[field] === null) {
573
+ data[field] = false;
574
+ }
575
+ }
564
576
  // Normalize numbers
565
577
  if (data.type === 'integer' || data.type === 'float') {
566
578
  const numValue = Number(data.value);
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @typedef {string} Types - Type of block.
3
3
  */
4
- type Types = 'product' | 'error_page' | 'catalog_page' | 'product_preview' | 'similar_products_block' | 'product_block' | 'form' | 'common_page' | 'common_block' | 'order' | 'service' | 'external_page' | 'discount' | 'none';
4
+ type Types = 'product' | 'error_page' | 'catalog_page' | 'product_preview' | 'similar_products_block' | 'product_block' | 'form' | 'common_page' | 'common_block' | 'order' | 'service' | 'external_page' | 'discount' | 'frequently_ordered_block' | 'none';
5
5
  /**
6
6
  * @property {string} [token] - If your project is protected by a token, specify this token in this parameter.
7
7
  * @property {string} [langCode] - specify the default language to avoid specifying it in every request.
@@ -41,19 +41,15 @@ export declare const AttributeSchema: z.ZodObject<{
41
41
  */
42
42
  export declare const UserEntitySchema: z.ZodObject<{
43
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>>;
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>;
56
51
  moduleFormConfigs: z.ZodOptional<z.ZodArray<z.ZodAny>>;
52
+ rating: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
57
53
  }, z.core.$strip>;
58
54
  /**
59
55
  * Auth entity schema
@@ -61,26 +57,10 @@ export declare const UserEntitySchema: z.ZodObject<{
61
57
  * userIdentifier and authProviderIdentifier are optional legacy fields
62
58
  */
63
59
  export declare const AuthEntitySchema: z.ZodObject<{
60
+ userIdentifier: z.ZodString;
61
+ authProviderIdentifier: z.ZodString;
64
62
  accessToken: z.ZodString;
65
63
  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
64
  }, z.core.$strip>;
85
65
  /**
86
66
  * Paginated response schema factory
@@ -45,21 +45,15 @@ exports.AttributeSchema = zod_1.z.object({
45
45
  */
46
46
  exports.UserEntitySchema = zod_1.z.object({
47
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(),
48
+ identifier: zod_1.z.string(),
49
+ authProviderIdentifier: zod_1.z.string(),
50
+ formData: zod_1.z.union([zod_1.z.array(zod_1.z.any()), zod_1.z.record(zod_1.z.string(), zod_1.z.any())]),
51
+ formIdentifier: zod_1.z.string(),
52
+ total: zod_1.z.string(),
53
+ groups: zod_1.z.array(zod_1.z.union([zod_1.z.string(), zod_1.z.number()])),
54
+ state: zod_1.z.record(zod_1.z.string(), zod_1.z.any()),
62
55
  moduleFormConfigs: zod_1.z.array(zod_1.z.any()).optional(),
56
+ rating: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
63
57
  });
64
58
  /**
65
59
  * Auth entity schema
@@ -67,11 +61,10 @@ exports.UserEntitySchema = zod_1.z.object({
67
61
  * userIdentifier and authProviderIdentifier are optional legacy fields
68
62
  */
69
63
  exports.AuthEntitySchema = zod_1.z.object({
64
+ userIdentifier: zod_1.z.string(),
65
+ authProviderIdentifier: zod_1.z.string(),
70
66
  accessToken: zod_1.z.string(),
71
67
  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
68
  });
76
69
  /**
77
70
  * Paginated response schema factory
@@ -1,6 +1,7 @@
1
1
  import AsyncModules from '../base/asyncModules';
2
2
  import type StateModule from '../base/stateModule';
3
3
  import type { IError } from '../base/utils';
4
+ import type { IProductsEntity } from '../products/productsInterfaces';
4
5
  import type { BlockType, IBlockEntity, IBlocks, IBlocksResponse, ISearchBlock } from './blocksInterfaces';
5
6
  /**
6
7
  * Controllers for working with blocks.
@@ -64,6 +65,17 @@ export default class BlocksApi extends AsyncModules implements IBlocks {
64
65
  * @throws {IError} When isShell=false and an error occurs during the fetch
65
66
  */
66
67
  private getProductsByBlockMarker;
68
+ /**
69
+ * Get frequently ordered products by block marker and product id.
70
+ * @handleName getFrequentlyOrderedProducts
71
+ * @param {number} productId - Product id. Example: 1.
72
+ * @param {string} marker - Block marker. Example: "frequently_ordered_block".
73
+ * @param {string} [langCode] - Language code. Default: "en_US".
74
+ * @param {string} [signPrice] - Sign price.
75
+ * @returns {Promise<IProductsEntity[] | IError>} Returns array of ProductEntity objects.
76
+ * @throws {IError} When isShell=false and an error occurs during the fetch
77
+ */
78
+ getFrequentlyOrderedProducts(productId: number, marker: string, langCode?: string, signPrice?: string): Promise<IProductsEntity[] | IError>;
67
79
  /**
68
80
  * Quick search for block objects with limited output.
69
81
  * @handleName searchBlock
@@ -170,6 +170,25 @@ class BlocksApi extends asyncModules_1.default {
170
170
  const result = await this._fetchGet(`/${marker}/products?` + this._queryParamsToString(query));
171
171
  return this._normalizeData(result.items);
172
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
+ }
173
192
  /**
174
193
  * Quick search for block objects with limited output.
175
194
  * @handleName searchBlock
@@ -40,6 +40,17 @@ interface IBlocks {
40
40
  * @description This method performs a quick search for block objects with limited output.
41
41
  */
42
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>;
43
54
  }
44
55
  /**
45
56
  * Represents a response from the blocks API.
@@ -164,5 +175,5 @@ interface ISearchBlock {
164
175
  * @type {BlockType}
165
176
  * @description This type defines the possible values for block types used in the system.
166
177
  */
167
- type BlockType = 'product' | 'error_page' | 'catalog_page' | 'product_preview' | 'similar_products_block' | 'product_block' | 'form' | 'common_page' | 'common_block' | 'order' | 'service' | 'external_page' | 'discount' | 'none';
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';
168
179
  export type { BlockType, IBlockEntity, IBlocks, IBlocksResponse, ISearchBlock };