oneentry 1.0.159 → 1.0.161

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 (222) hide show
  1. package/README.md +2 -0
  2. package/changelog.md +56 -1
  3. package/dist/admins/adminsApi.d.ts +15 -1
  4. package/dist/admins/adminsApi.js +29 -0
  5. package/dist/admins/adminsInterfaces.d.ts +37 -1
  6. package/dist/base/lazySchema.d.ts +15 -0
  7. package/dist/base/lazySchema.js +20 -0
  8. package/dist/discounts/discountsApi.d.ts +14 -1
  9. package/dist/discounts/discountsApi.js +21 -0
  10. package/dist/discounts/discountsInterfaces.d.ts +27 -1
  11. package/dist/filters/filtersInterfaces.d.ts +2 -2
  12. package/dist/filters/filtersSchemas.d.ts +1 -1
  13. package/dist/filters/filtersSchemas.js +4 -1
  14. package/dist/forms-data/formsDataApi.d.ts +14 -1
  15. package/dist/forms-data/formsDataApi.js +21 -0
  16. package/dist/forms-data/formsDataInterfaces.d.ts +74 -1
  17. package/dist/index.d.ts +4 -0
  18. package/dist/index.js +3 -0
  19. package/dist/orders/ordersApi.d.ts +15 -1
  20. package/dist/orders/ordersApi.js +22 -0
  21. package/dist/orders/ordersInterfaces.d.ts +27 -1
  22. package/dist/pages/pagesApi.d.ts +14 -1
  23. package/dist/pages/pagesApi.js +21 -0
  24. package/dist/pages/pagesInterfaces.d.ts +38 -1
  25. package/dist/payments/paymentsInterfaces.d.ts +2 -2
  26. package/dist/products/productsInterfaces.d.ts +1 -1
  27. package/dist/search/searchApi.d.ts +35 -0
  28. package/dist/search/searchApi.js +86 -0
  29. package/dist/search/searchInterfaces.d.ts +94 -0
  30. package/dist/search/searchInterfaces.js +2 -0
  31. package/dist/search/searchSchemas.d.ts +73 -0
  32. package/dist/search/searchSchemas.js +44 -0
  33. package/dist/templates-preview/templatesPreviewInterfaces.d.ts +0 -2
  34. package/dist/templates-preview/templatesPreviewSchemas.d.ts +0 -2
  35. package/dist/templates-preview/templatesPreviewSchemas.js +0 -1
  36. package/dist/types.d.ts +35 -0
  37. package/dist/types.js +2 -0
  38. package/dist/users/usersApi.d.ts +15 -1
  39. package/dist/users/usersApi.js +22 -0
  40. package/dist/users/usersInterfaces.d.ts +39 -1
  41. package/dist/web-socket/lazySocket.d.ts +18 -0
  42. package/dist/web-socket/lazySocket.js +70 -0
  43. package/esm/admins/adminsApi.d.ts +66 -0
  44. package/esm/admins/adminsApi.js +90 -0
  45. package/esm/admins/adminsInterfaces.d.ts +137 -0
  46. package/esm/admins/adminsInterfaces.js +1 -0
  47. package/esm/admins/adminsSchemas.d.ts +48 -0
  48. package/esm/admins/adminsSchemas.js +31 -0
  49. package/esm/attribute-sets/attributeSetsApi.d.ts +67 -0
  50. package/esm/attribute-sets/attributeSetsApi.js +97 -0
  51. package/esm/attribute-sets/attributeSetsInterfaces.d.ts +285 -0
  52. package/esm/attribute-sets/attributeSetsInterfaces.js +1 -0
  53. package/esm/attribute-sets/attributeSetsSchemas.d.ts +84 -0
  54. package/esm/attribute-sets/attributeSetsSchemas.js +66 -0
  55. package/esm/auth-provider/authProviderApi.d.ts +262 -0
  56. package/esm/auth-provider/authProviderApi.js +362 -0
  57. package/esm/auth-provider/authProviderSchemas.d.ts +124 -0
  58. package/esm/auth-provider/authProviderSchemas.js +92 -0
  59. package/esm/auth-provider/authProvidersInterfaces.d.ts +430 -0
  60. package/esm/auth-provider/authProvidersInterfaces.js +1 -0
  61. package/esm/base/asyncModules.d.ts +123 -0
  62. package/esm/base/asyncModules.js +382 -0
  63. package/esm/base/lazySchema.d.ts +15 -0
  64. package/esm/base/lazySchema.js +17 -0
  65. package/esm/base/stateModule.d.ts +35 -0
  66. package/esm/base/stateModule.js +51 -0
  67. package/esm/base/syncModules.d.ts +245 -0
  68. package/esm/base/syncModules.js +555 -0
  69. package/esm/base/timeIntervals.d.ts +95 -0
  70. package/esm/base/timeIntervals.js +317 -0
  71. package/esm/base/utils.d.ts +354 -0
  72. package/esm/base/utils.js +1 -0
  73. package/esm/base/validation.d.ts +98 -0
  74. package/esm/base/validation.js +118 -0
  75. package/esm/blocks/blocksApi.d.ts +252 -0
  76. package/esm/blocks/blocksApi.js +394 -0
  77. package/esm/blocks/blocksInterfaces.d.ts +361 -0
  78. package/esm/blocks/blocksInterfaces.js +1 -0
  79. package/esm/blocks/blocksSchemas.d.ts +213 -0
  80. package/esm/blocks/blocksSchemas.js +40 -0
  81. package/esm/discounts/discountsApi.d.ts +94 -0
  82. package/esm/discounts/discountsApi.js +136 -0
  83. package/esm/discounts/discountsInterfaces.d.ts +293 -0
  84. package/esm/discounts/discountsInterfaces.js +1 -0
  85. package/esm/events/eventsApi.d.ts +108 -0
  86. package/esm/events/eventsApi.js +141 -0
  87. package/esm/events/eventsInterfaces.d.ts +176 -0
  88. package/esm/events/eventsInterfaces.js +1 -0
  89. package/esm/file-uploading/fileUploadingApi.d.ts +91 -0
  90. package/esm/file-uploading/fileUploadingApi.js +127 -0
  91. package/esm/file-uploading/fileUploadingInterfaces.d.ts +116 -0
  92. package/esm/file-uploading/fileUploadingInterfaces.js +1 -0
  93. package/esm/file-uploading/fileUploadingSchemas.d.ts +24 -0
  94. package/esm/file-uploading/fileUploadingSchemas.js +19 -0
  95. package/esm/filters/filtersApi.d.ts +32 -0
  96. package/esm/filters/filtersApi.js +36 -0
  97. package/esm/filters/filtersInterfaces.d.ts +56 -0
  98. package/esm/filters/filtersInterfaces.js +1 -0
  99. package/esm/filters/filtersSchemas.d.ts +32 -0
  100. package/esm/filters/filtersSchemas.js +29 -0
  101. package/esm/forms/formsApi.d.ts +44 -0
  102. package/esm/forms/formsApi.js +54 -0
  103. package/esm/forms/formsInterfaces.d.ts +237 -0
  104. package/esm/forms/formsInterfaces.js +1 -0
  105. package/esm/forms/formsSchemas.d.ts +56 -0
  106. package/esm/forms/formsSchemas.js +32 -0
  107. package/esm/forms-data/formsDataApi.d.ts +124 -0
  108. package/esm/forms-data/formsDataApi.js +210 -0
  109. package/esm/forms-data/formsDataInterfaces.d.ts +670 -0
  110. package/esm/forms-data/formsDataInterfaces.js +1 -0
  111. package/esm/forms-data/formsDataSchemas.d.ts +107 -0
  112. package/esm/forms-data/formsDataSchemas.js +83 -0
  113. package/esm/general-types/generalTypesApi.d.ts +29 -0
  114. package/esm/general-types/generalTypesApi.js +34 -0
  115. package/esm/general-types/generalTypesInterfaces.d.ts +29 -0
  116. package/esm/general-types/generalTypesInterfaces.js +1 -0
  117. package/esm/general-types/generalTypesSchemas.d.ts +68 -0
  118. package/esm/general-types/generalTypesSchemas.js +42 -0
  119. package/esm/index.d.ts +143 -0
  120. package/esm/index.js +124 -0
  121. package/esm/integration-collections/integrationCollectionsApi.d.ts +172 -0
  122. package/esm/integration-collections/integrationCollectionsApi.js +224 -0
  123. package/esm/integration-collections/integrationCollectionsInterfaces.d.ts +317 -0
  124. package/esm/integration-collections/integrationCollectionsInterfaces.js +1 -0
  125. package/esm/integration-collections/integrationCollectionsSchemas.d.ts +84 -0
  126. package/esm/integration-collections/integrationCollectionsSchemas.js +60 -0
  127. package/esm/locales/localesApi.d.ts +28 -0
  128. package/esm/locales/localesApi.js +33 -0
  129. package/esm/locales/localesInterfaces.d.ts +40 -0
  130. package/esm/locales/localesInterfaces.js +1 -0
  131. package/esm/locales/localesSchemas.d.ts +32 -0
  132. package/esm/locales/localesSchemas.js +23 -0
  133. package/esm/menus/menusApi.d.ts +30 -0
  134. package/esm/menus/menusApi.js +35 -0
  135. package/esm/menus/menusInterfaces.d.ts +87 -0
  136. package/esm/menus/menusInterfaces.js +2 -0
  137. package/esm/menus/menusSchemas.d.ts +16 -0
  138. package/esm/menus/menusSchemas.js +25 -0
  139. package/esm/orders/ordersApi.d.ts +213 -0
  140. package/esm/orders/ordersApi.js +288 -0
  141. package/esm/orders/ordersInterfaces.d.ts +763 -0
  142. package/esm/orders/ordersInterfaces.js +1 -0
  143. package/esm/orders/ordersSchemas.d.ts +312 -0
  144. package/esm/orders/ordersSchemas.js +171 -0
  145. package/esm/package.json +4 -0
  146. package/esm/pages/pagesApi.d.ts +173 -0
  147. package/esm/pages/pagesApi.js +414 -0
  148. package/esm/pages/pagesInterfaces.d.ts +344 -0
  149. package/esm/pages/pagesInterfaces.js +1 -0
  150. package/esm/pages/pagesSchemas.d.ts +121 -0
  151. package/esm/pages/pagesSchemas.js +60 -0
  152. package/esm/payments/paymentsApi.d.ts +88 -0
  153. package/esm/payments/paymentsApi.js +122 -0
  154. package/esm/payments/paymentsInterfaces.d.ts +189 -0
  155. package/esm/payments/paymentsInterfaces.js +1 -0
  156. package/esm/payments/paymentsSchemas.d.ts +94 -0
  157. package/esm/payments/paymentsSchemas.js +53 -0
  158. package/esm/product-statuses/productStatusesApi.d.ts +50 -0
  159. package/esm/product-statuses/productStatusesApi.js +68 -0
  160. package/esm/product-statuses/productStatusesInterfaces.d.ts +62 -0
  161. package/esm/product-statuses/productStatusesInterfaces.js +1 -0
  162. package/esm/product-statuses/productStatusesSchemas.d.ts +34 -0
  163. package/esm/product-statuses/productStatusesSchemas.js +27 -0
  164. package/esm/products/productsApi.d.ts +366 -0
  165. package/esm/products/productsApi.js +468 -0
  166. package/esm/products/productsInterfaces.d.ts +723 -0
  167. package/esm/products/productsInterfaces.js +1 -0
  168. package/esm/products/productsSchemas.d.ts +234 -0
  169. package/esm/products/productsSchemas.js +121 -0
  170. package/esm/search/searchApi.d.ts +35 -0
  171. package/esm/search/searchApi.js +47 -0
  172. package/esm/search/searchInterfaces.d.ts +94 -0
  173. package/esm/search/searchInterfaces.js +1 -0
  174. package/esm/search/searchSchemas.d.ts +73 -0
  175. package/esm/search/searchSchemas.js +41 -0
  176. package/esm/sitemap/sitemapApi.d.ts +37 -0
  177. package/esm/sitemap/sitemapApi.js +41 -0
  178. package/esm/sitemap/sitemapInterfaces.d.ts +51 -0
  179. package/esm/sitemap/sitemapInterfaces.js +1 -0
  180. package/esm/subscriptions/subscriptionsApi.d.ts +74 -0
  181. package/esm/subscriptions/subscriptionsApi.js +90 -0
  182. package/esm/subscriptions/subscriptionsInterfaces.d.ts +111 -0
  183. package/esm/subscriptions/subscriptionsInterfaces.js +1 -0
  184. package/esm/subscriptions/subscriptionsSchemas.d.ts +46 -0
  185. package/esm/subscriptions/subscriptionsSchemas.js +38 -0
  186. package/esm/system/systemApi.d.ts +46 -0
  187. package/esm/system/systemApi.js +53 -0
  188. package/esm/system/systemInterfaces.d.ts +29 -0
  189. package/esm/system/systemInterfaces.js +1 -0
  190. package/esm/templates/templatesApi.d.ts +53 -0
  191. package/esm/templates/templatesApi.js +78 -0
  192. package/esm/templates/templatesInterfaces.d.ts +68 -0
  193. package/esm/templates/templatesInterfaces.js +1 -0
  194. package/esm/templates/templatesSchemas.d.ts +48 -0
  195. package/esm/templates/templatesSchemas.js +28 -0
  196. package/esm/templates-preview/templatesPreviewApi.d.ts +40 -0
  197. package/esm/templates-preview/templatesPreviewApi.js +50 -0
  198. package/esm/templates-preview/templatesPreviewInterfaces.d.ts +129 -0
  199. package/esm/templates-preview/templatesPreviewInterfaces.js +1 -0
  200. package/esm/templates-preview/templatesPreviewSchemas.d.ts +79 -0
  201. package/esm/templates-preview/templatesPreviewSchemas.js +43 -0
  202. package/esm/types.d.ts +35 -0
  203. package/esm/types.js +1 -0
  204. package/esm/user-activity/userActivityApi.d.ts +31 -0
  205. package/esm/user-activity/userActivityApi.js +37 -0
  206. package/esm/user-activity/userActivityInterfaces.d.ts +42 -0
  207. package/esm/user-activity/userActivityInterfaces.js +1 -0
  208. package/esm/users/usersApi.d.ts +249 -0
  209. package/esm/users/usersApi.js +312 -0
  210. package/esm/users/usersInterfaces.d.ts +419 -0
  211. package/esm/users/usersInterfaces.js +1 -0
  212. package/esm/users/usersSchemas.d.ts +72 -0
  213. package/esm/users/usersSchemas.js +55 -0
  214. package/esm/web-socket/lazySocket.d.ts +18 -0
  215. package/esm/web-socket/lazySocket.js +67 -0
  216. package/esm/web-socket/wsApi.d.ts +27 -0
  217. package/esm/web-socket/wsApi.js +43 -0
  218. package/esm/web-socket/wsInterfaces.d.ts +16 -0
  219. package/esm/web-socket/wsInterfaces.js +1 -0
  220. package/package.json +47 -2
  221. package/types.d.ts +1 -0
  222. package/types.js +1 -0
@@ -0,0 +1,312 @@
1
+ import AsyncModules from '../base/asyncModules.js';
2
+ import createSchemaLoader from '../base/lazySchema.js';
3
+ const schema = createSchemaLoader(() => import('./usersSchemas.js'));
4
+ /**
5
+ * Controllers for working with users
6
+ * @handle /api/content/users
7
+ * @description This module provides various methods to manage users, including creating, retrieving, updating, and deleting user data. It requires proper authorization to access these endpoints.
8
+ */
9
+ export default class UsersApi extends AsyncModules {
10
+ /**
11
+ * Constructor for UsersApi class.
12
+ * @param {StateModule} state - The state module containing necessary information for API calls.
13
+ * @description Initializes the UsersApi class with the provided state module.
14
+ */
15
+ constructor(state) {
16
+ super(state);
17
+ this._url = state.url + '/api/content/users';
18
+ }
19
+ /**
20
+ * Getting the data of an authorized user.
21
+ * @handleName getUser
22
+ * @param {string} [langCode] - Language code. Default: "en_US".
23
+ * @returns {Promise<IUserEntity | IError>} Returns a promise that resolves to the user entity object if successful; otherwise, returns an error object.
24
+ * @throws {IError} When isShell=false and an error occurs during the fetch
25
+ * @description This method requires user authorization.
26
+ * @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
27
+ * @see {@link https://js-sdk.oneentry.cloud/docs/users/getUser getUser} documentation.
28
+ */
29
+ async getUser(langCode = this.state.lang) {
30
+ const result = await this._fetchGet(`/me?langCode=${langCode}`);
31
+ // Validate response if validation is enabled
32
+ const validated = await this._validateResponse(result, schema('UserResponseSchema'));
33
+ return this._normalizeData(validated);
34
+ }
35
+ /**
36
+ * Updating a single user object.
37
+ * @handleName updateUser
38
+ * @param {IUserBody} body - Request body.
39
+ * @example
40
+ {
41
+ "formIdentifier": "reg",
42
+ "authData": [
43
+ {
44
+ "marker": "email_reg",
45
+ "value": "your-email@oneentery.cloud"
46
+ },
47
+ {
48
+ "marker": "password_reg",
49
+ "value": "12345"
50
+ }
51
+ ],
52
+ "formData": [
53
+ {
54
+ "marker": "last_name",
55
+ "type": "string",
56
+ "value": "Username"
57
+ }
58
+ ],
59
+ "notificationData": {
60
+ "email": "example@oneentry.cloud",
61
+ "phonePush": ["+99999999999"],
62
+ "phoneSMS": "+99999999999"
63
+ },
64
+ "state": {}
65
+ }
66
+ * @param {string} body.formIdentifier - Identifies the registration form being used. Example: "reg_form".
67
+ * @param {string} body.authData - Contains authentication credentials for the user. Example:
68
+ * @example
69
+ [
70
+ {
71
+ "marker": "email_reg",
72
+ "value": "example@oneentry.cloud"
73
+ },
74
+ {
75
+ "marker": "password_reg",
76
+ "value": "password"
77
+ }
78
+ ]
79
+ * @param {string} body.authData[].marker - Identifies the field being used. Example: "email_reg".
80
+ * @param {string} body.authData[].value - Contains the value of the field. Example: "example@oneentry.cloud".
81
+ * @param {string} body.formData - Contains additional data for the user.
82
+ * @example
83
+ [
84
+ {
85
+ "marker": "last_name",
86
+ "type": "string",
87
+ "value": "Username"
88
+ }
89
+ ]
90
+ * @param {string} body.formData[].marker - The marker of the field. Example: "last_name".
91
+ * @param {string} body.formData[].type - The type of the field. Example: "string".
92
+ * @param {string} body.formData[].value - The value of the field. Example: "Username".
93
+ * @param {string} body.notificationData - The notification data.
94
+ * @example
95
+ {
96
+ "email": "example@oneentry.cloud",
97
+ "phonePush": ["+99999999999"],
98
+ "phoneSMS": "+99999999999"
99
+ }
100
+ * @param {string} body.notificationData.email - The email address of the user. Example: "example@oneentry.cloud".
101
+ * @param {string} body.notificationData.phonePush - An array of phone numbers for push notifications. Example: ["+99999999999"].
102
+ * @param {string} body.notificationData.phoneSMS - The phone number for SMS notifications. Example: "+99999999999".
103
+ * @param {string} [langCode] - Language code. Default: "en_US".
104
+ * @returns {Promise<boolean | IError>} Returns `true` if the user object was successfully updated; otherwise, returns an error object.
105
+ * @throws {IError} When isShell=false and an error occurs during the fetch
106
+ * @description This method updates the user's data. This method requires user authorization.
107
+ * @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
108
+ * @see For more information about {@link https://doc.oneentry.cloud/docs/forms/create-form registration forms}, see the documentation in the {@link https://doc.oneentry.cloud/docs/forms/create-form forms configuration section}.
109
+ * @see {@link https://js-sdk.oneentry.cloud/docs/users/updateUser updateUser} documentation.
110
+ */
111
+ async updateUser(body, langCode = this.state.lang) {
112
+ if (!('langCode' in body))
113
+ body['langCode'] = langCode;
114
+ const result = await this._fetchPut('/me', this._normalizePostBody(body, langCode));
115
+ const validated = await this._validateResponse(result, schema('UpdateUserResponseSchema'));
116
+ return validated;
117
+ }
118
+ /**
119
+ * Archiving one user object (marked for deletion).
120
+ * @handleName archiveUser
121
+ * @returns {Promise<boolean | IError>} Returns `true` if the user was successfully deleted; otherwise, returns an error object.
122
+ * @throws {IError} When isShell=false and an error occurs during the fetch
123
+ * @description This method archives a user object (marks it for deletion). This method requires user authorization.
124
+ * @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/auth-provider/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
125
+ * @see {@link https://js-sdk.oneentry.cloud/docs/users/archiveUser archiveUser} documentation.
126
+ */
127
+ async archiveUser() {
128
+ const result = await this._fetchDelete('/me');
129
+ return result;
130
+ }
131
+ /**
132
+ * Delete a single user.
133
+ * @handleName deleteUser
134
+ * @returns {Promise<boolean | IError>} Returns `true` if the user was successfully deleted; otherwise, returns an error object.
135
+ * @throws {IError} When isShell=false and an error occurs during the fetch
136
+ * @description This method deletes the user from the system. This method requires user authorization.
137
+ * @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
138
+ * @see {@link https://js-sdk.oneentry.cloud/docs/users/deleteUser deleteUser} documentation.
139
+ */
140
+ async deleteUser() {
141
+ const result = await this._fetchDelete('/me/account');
142
+ return result;
143
+ }
144
+ /**
145
+ * Adds an FCM (Firebase Cloud Messaging) token for sending push notifications.
146
+ * @handleName addFCMToken
147
+ * @param {string} token - The cloud messaging token to be added. This token is used to identify the user's device for push notifications. Example: "fcm_token_1234567890abcdefg".
148
+ * @returns {Promise<boolean | IError>} Returns `true` if the token was successfully added; otherwise, returns an error object.
149
+ * @throws {IError} When isShell=false and an error occurs during the fetch
150
+ * @description This method adds an FCM token for sending push notifications. This method requires user authorization.
151
+ * @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
152
+ * @see {@link https://js-sdk.oneentry.cloud/docs/users/addFCMToken addFCMToken} documentation.
153
+ */
154
+ async addFCMToken(token) {
155
+ const result = await this._fetchPost(`/me/fcm-token/${token}`);
156
+ return result;
157
+ }
158
+ /**
159
+ * Deletes an FCM (Firebase Cloud Messaging) token.
160
+ * @handleName deleteFCMToken
161
+ * @param {string} token - The cloud messaging token to be deleted. This token is used to identify the user's device for push notifications and will be removed. Example: "fcm_token_1234567890abcdefg".
162
+ * @returns {Promise<boolean | IError>} Returns `true` if the token was successfully deleted; otherwise, returns an error object.
163
+ * @throws {IError} When isShell=false and an error occurs during the fetch
164
+ * @description This method deletes an existing FCM token. This method requires user authorization.
165
+ * @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
166
+ * @see {@link https://js-sdk.oneentry.cloud/docs/users/deleteFCMToken deleteFCMToken} documentation.
167
+ */
168
+ async deleteFCMToken(token) {
169
+ const result = await this._fetchDelete(`/me/fcm-token/${token}`);
170
+ return result;
171
+ }
172
+ /**
173
+ * Get the current user's or guest's cart.
174
+ * @handleName getCart
175
+ * @returns {Promise<ICartResponse | IError>} Returns the cart with its items and total.
176
+ * @throws {IError} When isShell=false and an error occurs during the fetch
177
+ * @description This method requires user authorization (or a guest context).
178
+ * @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
179
+ * @see {@link https://js-sdk.oneentry.cloud/docs/users/getCart getCart} documentation.
180
+ */
181
+ async getCart() {
182
+ const result = await this._fetchGet('/me/cart');
183
+ const validated = await this._validateResponse(result, schema('CartResponseSchema'));
184
+ return this._normalizeData(validated);
185
+ }
186
+ /**
187
+ * Replace the current user's or guest's cart.
188
+ * @handleName setCart
189
+ * @param {ICartSet} body - New cart contents. Example: `{ items: [{ productId: 1, qty: 2 }] }`.
190
+ * @returns {Promise<ICartResponse | IError>} Returns the updated cart.
191
+ * @throws {IError} When isShell=false and an error occurs during the fetch
192
+ * @description This method requires user authorization (or a guest context).
193
+ * @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
194
+ * @see {@link https://js-sdk.oneentry.cloud/docs/users/setCart setCart} documentation.
195
+ */
196
+ async setCart(body) {
197
+ const result = await this._fetchPut('/me/cart', body);
198
+ const validated = await this._validateResponse(result, schema('CartResponseSchema'));
199
+ return this._normalizeData(validated);
200
+ }
201
+ /**
202
+ * Add an item to the cart (or update qty of an existing one).
203
+ * @handleName addCartItem
204
+ * @param {ICartAddItem} body - Item to add. Example: `{ productId: 1, qty: 2 }`.
205
+ * @returns {Promise<ICartResponse | IError>} Returns the updated cart.
206
+ * @throws {IError} When isShell=false and an error occurs during the fetch
207
+ * @description This method requires user authorization (or a guest context).
208
+ * @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
209
+ * @see {@link https://js-sdk.oneentry.cloud/docs/users/addCartItem addCartItem} documentation.
210
+ */
211
+ async addCartItem(body) {
212
+ const result = await this._fetchPost('/me/cart/items', body);
213
+ const validated = await this._validateResponse(result, schema('CartResponseSchema'));
214
+ return this._normalizeData(validated);
215
+ }
216
+ /**
217
+ * Remove an item from the cart.
218
+ * @handleName removeCartItem
219
+ * @param {number} productId - Product identifier. Example: 12345.
220
+ * @returns {Promise<ICartResponse | IError>} Returns the updated cart.
221
+ * @throws {IError} When isShell=false and an error occurs during the fetch
222
+ * @description This method requires user authorization (or a guest context).
223
+ * @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
224
+ * @see {@link https://js-sdk.oneentry.cloud/docs/users/removeCartItem removeCartItem} documentation.
225
+ */
226
+ async removeCartItem(productId) {
227
+ const result = await this._fetchDelete(`/me/cart/items/${productId}`);
228
+ const validated = await this._validateResponse(result, schema('CartResponseSchema'));
229
+ return this._normalizeData(validated);
230
+ }
231
+ /**
232
+ * Get the current user's or guest's wishlist.
233
+ * @handleName getWishlist
234
+ * @returns {Promise<IWishlistResponse | IError>} Returns the wishlist with its items and total.
235
+ * @throws {IError} When isShell=false and an error occurs during the fetch
236
+ * @description This method requires user authorization (or a guest context).
237
+ * @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
238
+ * @see {@link https://js-sdk.oneentry.cloud/docs/users/getWishlist getWishlist} documentation.
239
+ */
240
+ async getWishlist() {
241
+ const result = await this._fetchGet('/me/wishlist');
242
+ const validated = await this._validateResponse(result, schema('WishlistResponseSchema'));
243
+ return this._normalizeData(validated);
244
+ }
245
+ /**
246
+ * Replace the current user's or guest's wishlist.
247
+ * @handleName setWishlist
248
+ * @param {IWishlistSet} body - New wishlist contents. Example: `{ items: [{ productId: 1 }] }`.
249
+ * @returns {Promise<IWishlistResponse | IError>} Returns the updated wishlist.
250
+ * @throws {IError} When isShell=false and an error occurs during the fetch
251
+ * @description This method requires user authorization (or a guest context).
252
+ * @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
253
+ * @see {@link https://js-sdk.oneentry.cloud/docs/users/setWishlist setWishlist} documentation.
254
+ */
255
+ async setWishlist(body) {
256
+ const result = await this._fetchPut('/me/wishlist', body);
257
+ const validated = await this._validateResponse(result, schema('WishlistResponseSchema'));
258
+ return this._normalizeData(validated);
259
+ }
260
+ /**
261
+ * Add an item to the wishlist.
262
+ * @handleName addWishlistItem
263
+ * @param {IWishlistAddItem} body - Item to add. Example: `{ productId: 1 }`.
264
+ * @returns {Promise<IWishlistResponse | IError>} Returns the updated wishlist.
265
+ * @throws {IError} When isShell=false and an error occurs during the fetch
266
+ * @description This method requires user authorization (or a guest context).
267
+ * @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
268
+ * @see {@link https://js-sdk.oneentry.cloud/docs/users/addWishlistItem addWishlistItem} documentation.
269
+ */
270
+ async addWishlistItem(body) {
271
+ const result = await this._fetchPost('/me/wishlist/items', body);
272
+ const validated = await this._validateResponse(result, schema('WishlistResponseSchema'));
273
+ return this._normalizeData(validated);
274
+ }
275
+ /**
276
+ * Remove an item from the wishlist.
277
+ * @handleName removeWishlistItem
278
+ * @param {number} productId - Product identifier. Example: 12345.
279
+ * @returns {Promise<IWishlistResponse | IError>} Returns the updated wishlist.
280
+ * @throws {IError} When isShell=false and an error occurs during the fetch
281
+ * @description This method requires user authorization (or a guest context).
282
+ * @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
283
+ * @see {@link https://js-sdk.oneentry.cloud/docs/users/removeWishlistItem removeWishlistItem} documentation.
284
+ */
285
+ async removeWishlistItem(productId) {
286
+ const result = await this._fetchDelete(`/me/wishlist/items/${productId}`);
287
+ const validated = await this._validateResponse(result, schema('WishlistResponseSchema'));
288
+ return this._normalizeData(validated);
289
+ }
290
+ /**
291
+ * Semantic (vector) search for users.
292
+ * @handleName getUsersByVectorSearch
293
+ * @param {IUsersVectorSearch} body - Vector search body. Example: `{ queryText: "john" }`.
294
+ * @param {string} [langCode] - Language code. Default: "en_US".
295
+ * @param {number} [offset] - Parameter for pagination. Default: 0.
296
+ * @param {number} [limit] - Parameter for pagination. Default: 30.
297
+ * @returns {Promise<IUsersResponse | IError>} Returns an object with an array of found users and total count.
298
+ * @throws {IError} When isShell=false and an error occurs during the fetch
299
+ * @description This method performs a semantic (vector) search for users. It requires user authorization.
300
+ * @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
301
+ * @see {@link https://js-sdk.oneentry.cloud/docs/users/getUsersByVectorSearch getUsersByVectorSearch} documentation.
302
+ */
303
+ async getUsersByVectorSearch(body, langCode = this.state.lang, offset = 0, limit = 30) {
304
+ const query = {
305
+ langCode,
306
+ offset,
307
+ limit,
308
+ };
309
+ const result = await this._fetchPost(`/vector/search?` + this._queryParamsToString(query), body);
310
+ return this._normalizeData(result, langCode);
311
+ }
312
+ }