oneentry 1.0.175 → 1.0.177
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.
- package/README.md +12 -5
- package/changelog.md +140 -0
- package/dist/admins/adminsApi.js +2 -9
- package/dist/admins/adminsInterfaces.d.ts +5 -5
- package/dist/admins/adminsSchemas.d.ts +4 -4
- package/dist/admins/adminsSchemas.js +2 -2
- package/dist/attribute-sets/attributeSetsApi.d.ts +1 -1
- package/dist/attribute-sets/attributeSetsApi.js +4 -4
- package/dist/attribute-sets/attributeSetsInterfaces.d.ts +65 -14
- package/dist/attribute-sets/attributeSetsSchemas.d.ts +8 -6
- package/dist/attribute-sets/attributeSetsSchemas.js +6 -9
- package/dist/auth-provider/authProviderApi.d.ts +4 -4
- package/dist/auth-provider/authProviderApi.js +96 -29
- package/dist/auth-provider/authProviderSchemas.d.ts +1 -0
- package/dist/auth-provider/authProviderSchemas.js +1 -0
- package/dist/auth-provider/authProvidersInterfaces.d.ts +8 -6
- package/dist/base/asyncModules.d.ts +73 -1
- package/dist/base/asyncModules.js +233 -37
- package/dist/base/stateModule.d.ts +2 -0
- package/dist/base/stateModule.js +22 -12
- package/dist/base/syncModules.d.ts +18 -10
- package/dist/base/syncModules.js +100 -29
- package/dist/base/utils.d.ts +26 -21
- package/dist/base/validation.d.ts +3 -3
- package/dist/base/validation.js +6 -7
- package/dist/blocks/blocksApi.d.ts +20 -17
- package/dist/blocks/blocksApi.js +101 -74
- package/dist/blocks/blocksInterfaces.d.ts +8 -8
- package/dist/discounts/discountsApi.d.ts +9 -7
- package/dist/discounts/discountsApi.js +18 -14
- package/dist/discounts/discountsInterfaces.d.ts +14 -10
- package/dist/events/eventsApi.d.ts +3 -3
- package/dist/events/eventsApi.js +7 -7
- package/dist/events/eventsInterfaces.d.ts +10 -14
- package/dist/file-uploading/fileUploadingApi.d.ts +4 -4
- package/dist/file-uploading/fileUploadingApi.js +13 -5
- package/dist/file-uploading/fileUploadingInterfaces.d.ts +5 -6
- package/dist/filters/filtersApi.js +2 -2
- package/dist/forms/formsApi.js +2 -2
- package/dist/forms/formsInterfaces.d.ts +1 -3
- package/dist/forms/formsSchemas.d.ts +3 -6
- package/dist/forms/formsSchemas.js +2 -4
- package/dist/forms-data/formsDataApi.d.ts +26 -8
- package/dist/forms-data/formsDataApi.js +45 -14
- package/dist/forms-data/formsDataInterfaces.d.ts +91 -66
- package/dist/general-types/generalTypesInterfaces.d.ts +1 -1
- package/dist/index.d.ts +7 -6
- package/dist/index.js +50 -7
- package/dist/integration-collections/integrationCollectionsApi.d.ts +15 -4
- package/dist/integration-collections/integrationCollectionsApi.js +42 -14
- package/dist/integration-collections/integrationCollectionsInterfaces.d.ts +8 -9
- package/dist/integration-collections/integrationCollectionsSchemas.d.ts +0 -2
- package/dist/integration-collections/integrationCollectionsSchemas.js +0 -1
- package/dist/menus/menusApi.js +1 -1
- package/dist/orders/ordersApi.d.ts +1 -13
- package/dist/orders/ordersApi.js +24 -44
- package/dist/orders/ordersInterfaces.d.ts +21 -14
- package/dist/pages/pagesApi.d.ts +6 -5
- package/dist/pages/pagesApi.js +44 -31
- package/dist/pages/pagesInterfaces.d.ts +18 -15
- package/dist/pages/pagesSchemas.d.ts +0 -3
- package/dist/pages/pagesSchemas.js +0 -1
- package/dist/payments/paymentsApi.d.ts +10 -11
- package/dist/payments/paymentsApi.js +22 -18
- package/dist/payments/paymentsInterfaces.d.ts +12 -14
- package/dist/payments/paymentsSchemas.d.ts +21 -20
- package/dist/payments/paymentsSchemas.js +5 -8
- package/dist/product-statuses/productStatusesApi.d.ts +1 -1
- package/dist/product-statuses/productStatusesApi.js +4 -4
- package/dist/product-statuses/productStatusesInterfaces.d.ts +1 -4
- package/dist/products/productsApi.d.ts +38 -58
- package/dist/products/productsApi.js +59 -72
- package/dist/products/productsInterfaces.d.ts +48 -85
- package/dist/search/searchApi.d.ts +1 -1
- package/dist/search/searchApi.js +4 -3
- package/dist/sitemap/sitemapInterfaces.d.ts +10 -6
- package/dist/subscriptions/subscriptionsApi.d.ts +1 -1
- package/dist/subscriptions/subscriptionsApi.js +1 -1
- package/dist/subscriptions/subscriptionsInterfaces.d.ts +1 -1
- package/dist/system/systemApi.d.ts +2 -0
- package/dist/system/systemApi.js +2 -0
- package/dist/system/systemInterfaces.d.ts +2 -0
- package/dist/templates/templatesApi.d.ts +2 -2
- package/dist/templates/templatesApi.js +12 -11
- package/dist/templates/templatesInterfaces.d.ts +2 -2
- package/dist/templates-preview/templatesPreviewApi.js +2 -2
- package/dist/templates-preview/templatesPreviewInterfaces.d.ts +23 -13
- package/dist/templates-preview/templatesPreviewSchemas.d.ts +7 -0
- package/dist/templates-preview/templatesPreviewSchemas.js +2 -0
- package/dist/user-groups/userGroupsApi.js +5 -5
- package/dist/user-groups/userGroupsSchemas.d.ts +4 -4
- package/dist/users/usersApi.d.ts +1 -1
- package/dist/users/usersApi.js +28 -15
- package/dist/users/usersInterfaces.d.ts +2 -9
- package/dist/web-socket/lazySocket.d.ts +6 -5
- package/dist/web-socket/lazySocket.js +212 -15
- package/dist/web-socket/wsApi.d.ts +7 -4
- package/dist/web-socket/wsApi.js +49 -12
- package/dist/web-socket/wsInterfaces.d.ts +41 -4
- package/esm/admins/adminsApi.js +2 -9
- package/esm/admins/adminsInterfaces.d.ts +5 -5
- package/esm/admins/adminsSchemas.d.ts +4 -4
- package/esm/admins/adminsSchemas.js +2 -2
- package/esm/attribute-sets/attributeSetsApi.d.ts +1 -1
- package/esm/attribute-sets/attributeSetsApi.js +4 -4
- package/esm/attribute-sets/attributeSetsInterfaces.d.ts +65 -14
- package/esm/attribute-sets/attributeSetsSchemas.d.ts +8 -6
- package/esm/attribute-sets/attributeSetsSchemas.js +6 -9
- package/esm/auth-provider/authProviderApi.d.ts +4 -4
- package/esm/auth-provider/authProviderApi.js +96 -29
- package/esm/auth-provider/authProviderSchemas.d.ts +1 -0
- package/esm/auth-provider/authProviderSchemas.js +1 -0
- package/esm/auth-provider/authProvidersInterfaces.d.ts +8 -6
- package/esm/base/asyncModules.d.ts +73 -1
- package/esm/base/asyncModules.js +233 -37
- package/esm/base/stateModule.d.ts +2 -0
- package/esm/base/stateModule.js +22 -12
- package/esm/base/syncModules.d.ts +18 -10
- package/esm/base/syncModules.js +99 -29
- package/esm/base/utils.d.ts +26 -21
- package/esm/base/validation.d.ts +3 -3
- package/esm/base/validation.js +6 -7
- package/esm/blocks/blocksApi.d.ts +20 -17
- package/esm/blocks/blocksApi.js +101 -74
- package/esm/blocks/blocksInterfaces.d.ts +8 -8
- package/esm/discounts/discountsApi.d.ts +9 -7
- package/esm/discounts/discountsApi.js +18 -14
- package/esm/discounts/discountsInterfaces.d.ts +14 -10
- package/esm/events/eventsApi.d.ts +3 -3
- package/esm/events/eventsApi.js +7 -7
- package/esm/events/eventsInterfaces.d.ts +10 -14
- package/esm/file-uploading/fileUploadingApi.d.ts +4 -4
- package/esm/file-uploading/fileUploadingApi.js +13 -5
- package/esm/file-uploading/fileUploadingInterfaces.d.ts +5 -6
- package/esm/filters/filtersApi.js +2 -2
- package/esm/forms/formsApi.js +2 -2
- package/esm/forms/formsInterfaces.d.ts +1 -3
- package/esm/forms/formsSchemas.d.ts +3 -6
- package/esm/forms/formsSchemas.js +2 -4
- package/esm/forms-data/formsDataApi.d.ts +26 -8
- package/esm/forms-data/formsDataApi.js +45 -14
- package/esm/forms-data/formsDataInterfaces.d.ts +91 -66
- package/esm/general-types/generalTypesInterfaces.d.ts +1 -1
- package/esm/index.d.ts +7 -6
- package/esm/index.js +50 -7
- package/esm/integration-collections/integrationCollectionsApi.d.ts +15 -4
- package/esm/integration-collections/integrationCollectionsApi.js +42 -14
- package/esm/integration-collections/integrationCollectionsInterfaces.d.ts +8 -9
- package/esm/integration-collections/integrationCollectionsSchemas.d.ts +0 -2
- package/esm/integration-collections/integrationCollectionsSchemas.js +0 -1
- package/esm/menus/menusApi.js +1 -1
- package/esm/orders/ordersApi.d.ts +1 -13
- package/esm/orders/ordersApi.js +24 -44
- package/esm/orders/ordersInterfaces.d.ts +21 -14
- package/esm/pages/pagesApi.d.ts +6 -5
- package/esm/pages/pagesApi.js +44 -31
- package/esm/pages/pagesInterfaces.d.ts +18 -15
- package/esm/pages/pagesSchemas.d.ts +0 -3
- package/esm/pages/pagesSchemas.js +0 -1
- package/esm/payments/paymentsApi.d.ts +10 -11
- package/esm/payments/paymentsApi.js +22 -18
- package/esm/payments/paymentsInterfaces.d.ts +12 -14
- package/esm/payments/paymentsSchemas.d.ts +21 -20
- package/esm/payments/paymentsSchemas.js +5 -8
- package/esm/product-statuses/productStatusesApi.d.ts +1 -1
- package/esm/product-statuses/productStatusesApi.js +4 -4
- package/esm/product-statuses/productStatusesInterfaces.d.ts +1 -4
- package/esm/products/productsApi.d.ts +38 -58
- package/esm/products/productsApi.js +59 -72
- package/esm/products/productsInterfaces.d.ts +48 -85
- package/esm/search/searchApi.d.ts +1 -1
- package/esm/search/searchApi.js +4 -3
- package/esm/sitemap/sitemapInterfaces.d.ts +10 -6
- package/esm/subscriptions/subscriptionsApi.d.ts +1 -1
- package/esm/subscriptions/subscriptionsApi.js +1 -1
- package/esm/subscriptions/subscriptionsInterfaces.d.ts +1 -1
- package/esm/system/systemApi.d.ts +2 -0
- package/esm/system/systemApi.js +2 -0
- package/esm/system/systemInterfaces.d.ts +2 -0
- package/esm/templates/templatesApi.d.ts +2 -2
- package/esm/templates/templatesApi.js +11 -10
- package/esm/templates/templatesInterfaces.d.ts +2 -2
- package/esm/templates-preview/templatesPreviewApi.js +2 -2
- package/esm/templates-preview/templatesPreviewInterfaces.d.ts +23 -13
- package/esm/templates-preview/templatesPreviewSchemas.d.ts +7 -0
- package/esm/templates-preview/templatesPreviewSchemas.js +2 -0
- package/esm/user-groups/userGroupsApi.js +5 -5
- package/esm/user-groups/userGroupsSchemas.d.ts +4 -4
- package/esm/users/usersApi.d.ts +1 -1
- package/esm/users/usersApi.js +28 -15
- package/esm/users/usersInterfaces.d.ts +2 -9
- package/esm/web-socket/lazySocket.d.ts +6 -5
- package/esm/web-socket/lazySocket.js +212 -15
- package/esm/web-socket/wsApi.d.ts +7 -4
- package/esm/web-socket/wsApi.js +49 -12
- package/esm/web-socket/wsInterfaces.d.ts +41 -4
- package/package.json +2 -2
|
@@ -21,17 +21,21 @@ interface ISitemapApi {
|
|
|
21
21
|
/**
|
|
22
22
|
* Query parameters for sitemap requests.
|
|
23
23
|
* @interface ISitemapQuery
|
|
24
|
-
* @property {Record<string, string>}
|
|
25
|
-
* @property {string} [url] -
|
|
26
|
-
* @property {string} [lastmod] -
|
|
27
|
-
* @property {string} [changefreq] -
|
|
28
|
-
* @property {number} [priority] -
|
|
24
|
+
* @property {Record<string, string>} baseUrls - Base URL per active language, an absolute `http(s)://` address; the entry for the default language is required. Without it the API does not generate a sitemap. Example: `{ "en_US": "https://example.com/" }`.
|
|
25
|
+
* @property {string} [url] - Deprecated: ignored by the API.
|
|
26
|
+
* @property {string} [lastmod] - Deprecated: ignored by the API.
|
|
27
|
+
* @property {string} [changefreq] - Deprecated: ignored by the API.
|
|
28
|
+
* @property {number} [priority] - Deprecated: ignored by the API.
|
|
29
29
|
*/
|
|
30
30
|
interface ISitemapQuery {
|
|
31
|
-
baseUrls
|
|
31
|
+
baseUrls: Record<string, string>;
|
|
32
|
+
/** @deprecated Ignored by the API. */
|
|
32
33
|
url?: string;
|
|
34
|
+
/** @deprecated Ignored by the API. */
|
|
33
35
|
lastmod?: string;
|
|
36
|
+
/** @deprecated Ignored by the API. */
|
|
34
37
|
changefreq?: string;
|
|
38
|
+
/** @deprecated Ignored by the API. */
|
|
35
39
|
priority?: number;
|
|
36
40
|
}
|
|
37
41
|
/**
|
|
@@ -45,7 +45,7 @@ export default class SubscriptionsApi extends AsyncModules implements ISubscript
|
|
|
45
45
|
* @handleName getAllSubscriptions
|
|
46
46
|
* @returns {Promise<ISubscriptionEntity[] | IError>} Returns an array of available subscriptions.
|
|
47
47
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
48
|
-
* @description
|
|
48
|
+
* @description Lists the plans available for subscription. It does not need a signed-in user: a guest gets the same list.
|
|
49
49
|
* @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}.
|
|
50
50
|
* @see {@link https://js-sdk.oneentry.cloud/docs/subscriptions/getAllSubscriptions getAllSubscriptions} documentation.
|
|
51
51
|
*/
|
|
@@ -51,7 +51,7 @@ export default class SubscriptionsApi extends AsyncModules {
|
|
|
51
51
|
* @handleName getAllSubscriptions
|
|
52
52
|
* @returns {Promise<ISubscriptionEntity[] | IError>} Returns an array of available subscriptions.
|
|
53
53
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
54
|
-
* @description
|
|
54
|
+
* @description Lists the plans available for subscription. It does not need a signed-in user: a guest gets the same list.
|
|
55
55
|
* @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}.
|
|
56
56
|
* @see {@link https://js-sdk.oneentry.cloud/docs/subscriptions/getAllSubscriptions getAllSubscriptions} documentation.
|
|
57
57
|
*/
|
|
@@ -30,7 +30,7 @@ interface ISubscriptionsApi {
|
|
|
30
30
|
* @handleName getAllSubscriptions
|
|
31
31
|
* @returns {Promise<ISubscriptionEntity[] | IError>} Returns an array of available subscriptions.
|
|
32
32
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
33
|
-
* @description
|
|
33
|
+
* @description Lists the plans available for subscription. It does not need a signed-in user: a guest gets the same list.
|
|
34
34
|
* @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}.
|
|
35
35
|
*/
|
|
36
36
|
getAllSubscriptions(): Promise<ISubscriptionEntity[] | IError>;
|
|
@@ -23,6 +23,7 @@ export default class SystemApi extends AsyncModules implements ISystemApi {
|
|
|
23
23
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
24
24
|
* @description This method is used to test the 404 error handling by sending a GET request to a specific endpoint.
|
|
25
25
|
* @see {@link https://js-sdk.oneentry.cloud/docs/system/test404 test404} documentation.
|
|
26
|
+
* @deprecated The platform removed `/api/content/system/test404` (CMS-1056, 2026-10-29): the call answers `404 "Cannot GET /api/content/system/test404"`. Kept for compatibility and will be removed.
|
|
26
27
|
*/
|
|
27
28
|
test404(): Promise<unknown | IError>;
|
|
28
29
|
/**
|
|
@@ -32,6 +33,7 @@ export default class SystemApi extends AsyncModules implements ISystemApi {
|
|
|
32
33
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
33
34
|
* @description This method is used to test the 500 error handling by sending a GET request to a specific endpoint.
|
|
34
35
|
* @see {@link https://js-sdk.oneentry.cloud/docs/system/test500 test500} documentation.
|
|
36
|
+
* @deprecated The platform removed `/api/content/system/test500` (CMS-1056, 2026-10-29): the call answers `404 "Cannot GET /api/content/system/test500"`. Kept for compatibility and will be removed.
|
|
35
37
|
*/
|
|
36
38
|
test500(): Promise<unknown | IError>;
|
|
37
39
|
/**
|
package/esm/system/systemApi.js
CHANGED
|
@@ -21,6 +21,7 @@ export default class SystemApi extends AsyncModules {
|
|
|
21
21
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
22
22
|
* @description This method is used to test the 404 error handling by sending a GET request to a specific endpoint.
|
|
23
23
|
* @see {@link https://js-sdk.oneentry.cloud/docs/system/test404 test404} documentation.
|
|
24
|
+
* @deprecated The platform removed `/api/content/system/test404` (CMS-1056, 2026-10-29): the call answers `404 "Cannot GET /api/content/system/test404"`. Kept for compatibility and will be removed.
|
|
24
25
|
*/
|
|
25
26
|
async test404() {
|
|
26
27
|
const result = await this._fetchGet('/test404');
|
|
@@ -33,6 +34,7 @@ export default class SystemApi extends AsyncModules {
|
|
|
33
34
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
34
35
|
* @description This method is used to test the 500 error handling by sending a GET request to a specific endpoint.
|
|
35
36
|
* @see {@link https://js-sdk.oneentry.cloud/docs/system/test500 test500} documentation.
|
|
37
|
+
* @deprecated The platform removed `/api/content/system/test500` (CMS-1056, 2026-10-29): the call answers `404 "Cannot GET /api/content/system/test500"`. Kept for compatibility and will be removed.
|
|
36
38
|
*/
|
|
37
39
|
async test500() {
|
|
38
40
|
const result = await this._fetchGet('/test500');
|
|
@@ -9,6 +9,7 @@ interface ISystemApi {
|
|
|
9
9
|
* @handleName test404
|
|
10
10
|
* @returns {unknown} Returns a Promise that resolves with any data.
|
|
11
11
|
* @description This method tests 404 error.
|
|
12
|
+
* @deprecated The platform removed `/api/content/system/test404` (CMS-1056, 2026-10-29): the call answers `404 "Cannot GET /api/content/system/test404"`. Kept for compatibility and will be removed.
|
|
12
13
|
*/
|
|
13
14
|
test404(): Promise<unknown | IError>;
|
|
14
15
|
/**
|
|
@@ -16,6 +17,7 @@ interface ISystemApi {
|
|
|
16
17
|
* @handleName test500
|
|
17
18
|
* @returns {unknown} Returns a Promise that resolves with any data.
|
|
18
19
|
* @description This method tests 500 error.
|
|
20
|
+
* @deprecated The platform removed `/api/content/system/test500` (CMS-1056, 2026-10-29): the call answers `404 "Cannot GET /api/content/system/test500"`. Kept for compatibility and will be removed.
|
|
19
21
|
*/
|
|
20
22
|
test500(): Promise<unknown | IError>;
|
|
21
23
|
/**
|
|
@@ -9,7 +9,7 @@ import type { ITemplateEntity, ITemplatesApi } from './templatesInterfaces.js';
|
|
|
9
9
|
* @handle /api/content/templates
|
|
10
10
|
* @description This module provides a set of controllers for handling operations related to template objects.
|
|
11
11
|
*/
|
|
12
|
-
export default class
|
|
12
|
+
export default class TemplatesApi extends AsyncModules implements ITemplatesApi {
|
|
13
13
|
protected state: StateModule;
|
|
14
14
|
protected _url: string;
|
|
15
15
|
/**
|
|
@@ -31,7 +31,7 @@ export default class TemplatesPreviewApi extends AsyncModules implements ITempla
|
|
|
31
31
|
/**
|
|
32
32
|
* Get template objects by type.
|
|
33
33
|
* @handleName getTemplateByType
|
|
34
|
-
* @param {BlockType} type - Type of templates to fetch. Example: "
|
|
34
|
+
* @param {BlockType} type - Type of templates to fetch. Example: "product_block". A type with no templates gives an empty array.
|
|
35
35
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
36
36
|
* @returns {Promise<ITemplateEntity[] | IError>} Array of `ITemplateEntity` objects of the given type.
|
|
37
37
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
@@ -8,7 +8,7 @@ const schema = createSchemaLoader(() => import('./templatesSchemas.js'));
|
|
|
8
8
|
* @handle /api/content/templates
|
|
9
9
|
* @description This module provides a set of controllers for handling operations related to template objects.
|
|
10
10
|
*/
|
|
11
|
-
export default class
|
|
11
|
+
export default class TemplatesApi extends AsyncModules {
|
|
12
12
|
/**
|
|
13
13
|
* Constructor for TemplatesApi class.
|
|
14
14
|
* @param {StateModule} state - The state module instance.
|
|
@@ -28,13 +28,14 @@ export default class TemplatesPreviewApi extends AsyncModules {
|
|
|
28
28
|
* @see {@link https://js-sdk.oneentry.cloud/docs/templates/getAllTemplates getAllTemplates} documentation.
|
|
29
29
|
*/
|
|
30
30
|
async getAllTemplates(langCode = this.state.lang) {
|
|
31
|
-
const response = await this._fetchGet(`/all?langCode=${langCode}`);
|
|
31
|
+
const response = await this._fetchGet(`/all?langCode=${encodeURIComponent(langCode)}`);
|
|
32
32
|
// Validate response if validation is enabled
|
|
33
33
|
const validated = await this._validateResponse(response, schema('GroupedTemplatesResponseSchema'));
|
|
34
|
+
if (this._isErrorResponse(validated)) {
|
|
35
|
+
return validated;
|
|
36
|
+
}
|
|
34
37
|
const result = {};
|
|
35
|
-
if (validated &&
|
|
36
|
-
typeof validated === 'object' &&
|
|
37
|
-
!('statusCode' in validated)) {
|
|
38
|
+
if (validated && typeof validated === 'object') {
|
|
38
39
|
const grouped = validated;
|
|
39
40
|
// eslint-disable-next-line no-restricted-syntax
|
|
40
41
|
for (const item in grouped) {
|
|
@@ -46,7 +47,7 @@ export default class TemplatesPreviewApi extends AsyncModules {
|
|
|
46
47
|
/**
|
|
47
48
|
* Get template objects by type.
|
|
48
49
|
* @handleName getTemplateByType
|
|
49
|
-
* @param {BlockType} type - Type of templates to fetch. Example: "
|
|
50
|
+
* @param {BlockType} type - Type of templates to fetch. Example: "product_block". A type with no templates gives an empty array.
|
|
50
51
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
51
52
|
* @returns {Promise<ITemplateEntity[] | IError>} Array of `ITemplateEntity` objects of the given type.
|
|
52
53
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
@@ -54,10 +55,10 @@ export default class TemplatesPreviewApi extends AsyncModules {
|
|
|
54
55
|
* @see {@link https://js-sdk.oneentry.cloud/docs/templates/getTemplateByType getTemplateByType} documentation.
|
|
55
56
|
*/
|
|
56
57
|
async getTemplateByType(type, langCode = this.state.lang) {
|
|
57
|
-
const result = await this._fetchGet(`?type=${type}&langCode=${langCode}`);
|
|
58
|
+
const result = await this._fetchGet(`?type=${encodeURIComponent(type)}&langCode=${encodeURIComponent(langCode)}`);
|
|
58
59
|
// Validate response if validation is enabled
|
|
59
60
|
const validated = await this._validateResponse(result, schema('TemplatesResponseSchema'));
|
|
60
|
-
return this._normalizeData(validated);
|
|
61
|
+
return this._normalizeData(validated, langCode);
|
|
61
62
|
}
|
|
62
63
|
/**
|
|
63
64
|
* Get one template object by marker.
|
|
@@ -70,9 +71,9 @@ export default class TemplatesPreviewApi extends AsyncModules {
|
|
|
70
71
|
* @see {@link https://js-sdk.oneentry.cloud/docs/templates/getTemplateByMarker getTemplateByMarker} documentation.
|
|
71
72
|
*/
|
|
72
73
|
async getTemplateByMarker(marker, langCode = this.state.lang) {
|
|
73
|
-
const result = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
|
|
74
|
+
const result = await this._fetchGet(`/marker/${this._pathSegment(marker)}?langCode=${encodeURIComponent(langCode)}`);
|
|
74
75
|
// Validate response if validation is enabled
|
|
75
76
|
const validated = await this._validateResponse(result, schema('TemplateEntitySchema'));
|
|
76
|
-
return this._normalizeData(validated);
|
|
77
|
+
return this._normalizeData(validated, langCode);
|
|
77
78
|
}
|
|
78
79
|
}
|
|
@@ -17,7 +17,7 @@ interface ITemplatesApi {
|
|
|
17
17
|
/**
|
|
18
18
|
* Get template objects by type.
|
|
19
19
|
* @handleName getTemplateByType
|
|
20
|
-
* @param {BlockType} type - Type of templates to fetch. Example: "
|
|
20
|
+
* @param {BlockType} type - Type of templates to fetch. Example: "product_block". A type with no templates gives an empty array.
|
|
21
21
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
22
22
|
* @returns {ITemplateEntity[]} Array of `ITemplateEntity` objects of the given type.
|
|
23
23
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
@@ -44,7 +44,7 @@ interface ITemplatesApi {
|
|
|
44
44
|
* @property {number} generalTypeId - ID of the general type. Example: 67890.
|
|
45
45
|
* @property {string} identifier - Text identifier (marker) of the object. Example: "template_12345".
|
|
46
46
|
* @property {number} version - Version number of the object; changes with each update. Example: 1.
|
|
47
|
-
* @property {BlockType} generalTypeName - General type name. Example: "
|
|
47
|
+
* @property {BlockType} generalTypeName - General type name. Example: "product_block".
|
|
48
48
|
* @property {IAttributeValues} attributeValues - Attribute values keyed by marker; an empty object when there are none.
|
|
49
49
|
* @example
|
|
50
50
|
{
|
|
@@ -26,7 +26,7 @@ export default class TemplatePreviewsApi extends AsyncModules {
|
|
|
26
26
|
* @see {@link https://js-sdk.oneentry.cloud/docs/templates-preview/getTemplatePreviews getTemplatePreviews} documentation.
|
|
27
27
|
*/
|
|
28
28
|
async getTemplatePreviews(langCode = this.state.lang) {
|
|
29
|
-
const result = await this._fetchGet(`?langCode=${langCode}`);
|
|
29
|
+
const result = await this._fetchGet(`?langCode=${encodeURIComponent(langCode)}`);
|
|
30
30
|
// Validate response if validation is enabled
|
|
31
31
|
const validated = await this._validateResponse(result, schema('TemplatePreviewsResponseSchema'));
|
|
32
32
|
return this._normalizeData(validated, langCode);
|
|
@@ -42,7 +42,7 @@ export default class TemplatePreviewsApi extends AsyncModules {
|
|
|
42
42
|
* @see {@link https://js-sdk.oneentry.cloud/docs/templates-preview/getTemplatePreviewByMarker getTemplatePreviewByMarker} documentation.
|
|
43
43
|
*/
|
|
44
44
|
async getTemplatePreviewByMarker(marker, langCode = this.state.lang) {
|
|
45
|
-
const result = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
|
|
45
|
+
const result = await this._fetchGet(`/marker/${this._pathSegment(marker)}?langCode=${encodeURIComponent(langCode)}`);
|
|
46
46
|
// Validate response if validation is enabled
|
|
47
47
|
const validated = await this._validateResponse(result, schema('TemplatePreviewEntitySchema'));
|
|
48
48
|
return this._normalizeData(validated, langCode);
|
|
@@ -27,46 +27,52 @@ interface ITemplatesPreviewApi {
|
|
|
27
27
|
* @interface ITemplatesPreviewEntity
|
|
28
28
|
* @property {number} id - ID of the object. Example: 3.
|
|
29
29
|
* @property {string} title - Name of the preview template. Example: "Product Template".
|
|
30
|
-
* @property {object} proportions - Preview proportions: the horizontal, vertical and square variants
|
|
30
|
+
* @property {object} proportions - Preview proportions: the horizontal, vertical and square variants under `default`.
|
|
31
31
|
* @example
|
|
32
32
|
{
|
|
33
33
|
"default": {
|
|
34
34
|
"horizontal": {
|
|
35
35
|
"width": 234,
|
|
36
36
|
"height": 324,
|
|
37
|
-
"alignmentType": "middleBottom"
|
|
37
|
+
"alignmentType": "middleBottom",
|
|
38
|
+
"weight": 234
|
|
38
39
|
},
|
|
39
40
|
"vertical": {
|
|
40
41
|
"width": 2,
|
|
41
42
|
"height": 3,
|
|
42
|
-
"alignmentType": "leftTop"
|
|
43
|
+
"alignmentType": "leftTop",
|
|
44
|
+
"weight": 2
|
|
43
45
|
},
|
|
44
46
|
"square": {
|
|
45
|
-
"side":
|
|
46
|
-
"alignmentType": "
|
|
47
|
-
}
|
|
47
|
+
"side": 360,
|
|
48
|
+
"alignmentType": "middleMiddle"
|
|
49
|
+
},
|
|
50
|
+
"default": true
|
|
48
51
|
}
|
|
49
52
|
}
|
|
50
|
-
* @property {IProportion | null} proportions.horizontal - Horizontal proportion of the preview.
|
|
53
|
+
* @property {IProportion | null} proportions.default.horizontal - Horizontal proportion of the preview.
|
|
51
54
|
* @example
|
|
52
55
|
{
|
|
53
56
|
"width": 234,
|
|
54
57
|
"height": 324,
|
|
55
|
-
"alignmentType": "middleBottom"
|
|
58
|
+
"alignmentType": "middleBottom",
|
|
59
|
+
"weight": 234
|
|
56
60
|
}
|
|
57
|
-
* @property {IProportion | null} proportions.vertical - Vertical variant of the preview, or `null`.
|
|
61
|
+
* @property {IProportion | null} proportions.default.vertical - Vertical variant of the preview, or `null`.
|
|
58
62
|
* @example
|
|
59
63
|
{
|
|
60
64
|
"width": 2,
|
|
61
65
|
"height": 3,
|
|
62
|
-
"alignmentType": "leftTop"
|
|
66
|
+
"alignmentType": "leftTop",
|
|
67
|
+
"weight": 2
|
|
63
68
|
}
|
|
64
|
-
* @property {ISquare} proportions.square - Square variant of the preview.
|
|
69
|
+
* @property {ISquare} proportions.default.square - Square variant of the preview.
|
|
65
70
|
* @example
|
|
66
71
|
{
|
|
67
|
-
"side":
|
|
68
|
-
"alignmentType": "
|
|
72
|
+
"side": 360,
|
|
73
|
+
"alignmentType": "middleMiddle"
|
|
69
74
|
}
|
|
75
|
+
* @property {boolean} [proportions.default.default] - Whether these are the default proportions. Example: true.
|
|
70
76
|
* @property {string} identifier - Text identifier (marker) of the object. Example: "preview-templates"
|
|
71
77
|
* @property {number} version - Version number of the object; changes with each update. Example: 1.
|
|
72
78
|
* @property {number} position - Position of the object, used for sorting. Example: 1.
|
|
@@ -95,12 +101,14 @@ interface ITemplatesPreviewProportions {
|
|
|
95
101
|
* @property {IProportion | null} horizontal - Horizontal layout proportion, or null when not configured.
|
|
96
102
|
* @property {IProportion | null} vertical - Vertical layout proportion, or null when not configured.
|
|
97
103
|
* @property {ISquare} square - Square layout proportion.
|
|
104
|
+
* @property {boolean} [default] - Whether these are the default proportions. Example: true.
|
|
98
105
|
* @description Layout proportion variants of a template preview.
|
|
99
106
|
*/
|
|
100
107
|
interface ITemplatesPreviewProportionVariants {
|
|
101
108
|
horizontal: IProportion | null;
|
|
102
109
|
vertical: IProportion | null;
|
|
103
110
|
square: ISquare;
|
|
111
|
+
default?: boolean;
|
|
104
112
|
}
|
|
105
113
|
/**
|
|
106
114
|
* The `IProportion` interface defines the structure of a proportion object used in template previews.
|
|
@@ -108,12 +116,14 @@ interface ITemplatesPreviewProportionVariants {
|
|
|
108
116
|
* @property {string | number | null} width - Width of the preview. Example: 100.
|
|
109
117
|
* @property {string | number | null} height - Height of the preview. Example: 200.
|
|
110
118
|
* @property {string} alignmentType - Alignment of the preview, such as `center`. Example: "center".
|
|
119
|
+
* @property {number | null} [weight] - Weight of the proportion; the API sends the width value. Example: 234.
|
|
111
120
|
* @description Represents a proportion object used in template previews.
|
|
112
121
|
*/
|
|
113
122
|
interface IProportion {
|
|
114
123
|
width: number | null;
|
|
115
124
|
height: number | null;
|
|
116
125
|
alignmentType: string;
|
|
126
|
+
weight?: number | null;
|
|
117
127
|
}
|
|
118
128
|
/**
|
|
119
129
|
* The `ISquare` interface defines the structure of a square proportion object used in template previews.
|
|
@@ -10,6 +10,7 @@ export declare const ProportionSchema: z.ZodObject<{
|
|
|
10
10
|
width: z.ZodNullable<z.ZodNumber>;
|
|
11
11
|
height: z.ZodNullable<z.ZodNumber>;
|
|
12
12
|
alignmentType: z.ZodString;
|
|
13
|
+
weight: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
13
14
|
}, z.core.$strip>;
|
|
14
15
|
/**
|
|
15
16
|
* Square schema
|
|
@@ -31,16 +32,19 @@ export declare const TemplatePreviewEntitySchema: z.ZodObject<{
|
|
|
31
32
|
width: z.ZodNullable<z.ZodNumber>;
|
|
32
33
|
height: z.ZodNullable<z.ZodNumber>;
|
|
33
34
|
alignmentType: z.ZodString;
|
|
35
|
+
weight: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
34
36
|
}, z.core.$strip>>;
|
|
35
37
|
vertical: z.ZodNullable<z.ZodObject<{
|
|
36
38
|
width: z.ZodNullable<z.ZodNumber>;
|
|
37
39
|
height: z.ZodNullable<z.ZodNumber>;
|
|
38
40
|
alignmentType: z.ZodString;
|
|
41
|
+
weight: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
39
42
|
}, z.core.$strip>>;
|
|
40
43
|
square: z.ZodObject<{
|
|
41
44
|
side: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
|
|
42
45
|
alignmentType: z.ZodString;
|
|
43
46
|
}, z.core.$strip>;
|
|
47
|
+
default: z.ZodOptional<z.ZodBoolean>;
|
|
44
48
|
}, z.core.$strip>;
|
|
45
49
|
}, z.core.$strip>;
|
|
46
50
|
identifier: z.ZodString;
|
|
@@ -60,16 +64,19 @@ export declare const TemplatePreviewsResponseSchema: z.ZodArray<z.ZodObject<{
|
|
|
60
64
|
width: z.ZodNullable<z.ZodNumber>;
|
|
61
65
|
height: z.ZodNullable<z.ZodNumber>;
|
|
62
66
|
alignmentType: z.ZodString;
|
|
67
|
+
weight: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
63
68
|
}, z.core.$strip>>;
|
|
64
69
|
vertical: z.ZodNullable<z.ZodObject<{
|
|
65
70
|
width: z.ZodNullable<z.ZodNumber>;
|
|
66
71
|
height: z.ZodNullable<z.ZodNumber>;
|
|
67
72
|
alignmentType: z.ZodString;
|
|
73
|
+
weight: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
68
74
|
}, z.core.$strip>>;
|
|
69
75
|
square: z.ZodObject<{
|
|
70
76
|
side: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
|
|
71
77
|
alignmentType: z.ZodString;
|
|
72
78
|
}, z.core.$strip>;
|
|
79
|
+
default: z.ZodOptional<z.ZodBoolean>;
|
|
73
80
|
}, z.core.$strip>;
|
|
74
81
|
}, z.core.$strip>;
|
|
75
82
|
identifier: z.ZodString;
|
|
@@ -10,6 +10,7 @@ export const ProportionSchema = z.object({
|
|
|
10
10
|
width: z.number().nullable(),
|
|
11
11
|
height: z.number().nullable(),
|
|
12
12
|
alignmentType: z.string(),
|
|
13
|
+
weight: z.number().nullable().optional(),
|
|
13
14
|
});
|
|
14
15
|
/**
|
|
15
16
|
* Square schema
|
|
@@ -30,6 +31,7 @@ export const TemplatePreviewEntitySchema = z.object({
|
|
|
30
31
|
horizontal: ProportionSchema.nullable(),
|
|
31
32
|
vertical: ProportionSchema.nullable(),
|
|
32
33
|
square: SquareSchema,
|
|
34
|
+
default: z.boolean().optional(),
|
|
33
35
|
}),
|
|
34
36
|
}),
|
|
35
37
|
identifier: z.string(),
|
|
@@ -34,7 +34,7 @@ export default class UserGroupsApi extends AsyncModules {
|
|
|
34
34
|
* @see {@link https://js-sdk.oneentry.cloud/docs/user-groups/getUserGroups getUserGroups} documentation.
|
|
35
35
|
*/
|
|
36
36
|
async getUserGroups(langCode = this.state.lang) {
|
|
37
|
-
const result = await this._fetchGet(`/?langCode=${langCode}`);
|
|
37
|
+
const result = await this._fetchGet(`/?langCode=${encodeURIComponent(langCode)}`);
|
|
38
38
|
// Validate response if validation is enabled
|
|
39
39
|
const validated = await this._validateResponse(result, schema('UserGroupsResponseSchema'));
|
|
40
40
|
return this._normalizeData(validated, langCode);
|
|
@@ -49,7 +49,7 @@ export default class UserGroupsApi extends AsyncModules {
|
|
|
49
49
|
* @see {@link https://js-sdk.oneentry.cloud/docs/user-groups/getRootUserGroups getRootUserGroups} documentation.
|
|
50
50
|
*/
|
|
51
51
|
async getRootUserGroups(langCode = this.state.lang) {
|
|
52
|
-
const result = await this._fetchGet(`/root?langCode=${langCode}`);
|
|
52
|
+
const result = await this._fetchGet(`/root?langCode=${encodeURIComponent(langCode)}`);
|
|
53
53
|
// Validate response if validation is enabled
|
|
54
54
|
const validated = await this._validateResponse(result, schema('UserGroupsResponseSchema'));
|
|
55
55
|
return this._normalizeData(validated, langCode);
|
|
@@ -65,7 +65,7 @@ export default class UserGroupsApi extends AsyncModules {
|
|
|
65
65
|
* @see {@link https://js-sdk.oneentry.cloud/docs/user-groups/getUserGroupById getUserGroupById} documentation.
|
|
66
66
|
*/
|
|
67
67
|
async getUserGroupById(id, langCode = this.state.lang) {
|
|
68
|
-
const result = await this._fetchGet(`/${id}?langCode=${langCode}`);
|
|
68
|
+
const result = await this._fetchGet(`/${this._pathSegment(String(id))}?langCode=${encodeURIComponent(langCode)}`);
|
|
69
69
|
// Validate response if validation is enabled
|
|
70
70
|
const validated = await this._validateResponse(result, schema('UserGroupEntitySchema'));
|
|
71
71
|
return this._normalizeData(validated, langCode);
|
|
@@ -81,7 +81,7 @@ export default class UserGroupsApi extends AsyncModules {
|
|
|
81
81
|
* @see {@link https://js-sdk.oneentry.cloud/docs/user-groups/getUserGroupByMarker getUserGroupByMarker} documentation.
|
|
82
82
|
*/
|
|
83
83
|
async getUserGroupByMarker(marker, langCode = this.state.lang) {
|
|
84
|
-
const result = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
|
|
84
|
+
const result = await this._fetchGet(`/marker/${this._pathSegment(marker)}?langCode=${encodeURIComponent(langCode)}`);
|
|
85
85
|
// Validate response if validation is enabled
|
|
86
86
|
const validated = await this._validateResponse(result, schema('UserGroupEntitySchema'));
|
|
87
87
|
return this._normalizeData(validated, langCode);
|
|
@@ -98,7 +98,7 @@ export default class UserGroupsApi extends AsyncModules {
|
|
|
98
98
|
* @see {@link https://js-sdk.oneentry.cloud/docs/user-groups/getChildUserGroupsByMarker getChildUserGroupsByMarker} documentation.
|
|
99
99
|
*/
|
|
100
100
|
async getChildUserGroupsByMarker(marker, langCode = this.state.lang) {
|
|
101
|
-
const result = await this._fetchGet(`/marker/${marker}/children?langCode=${langCode}`);
|
|
101
|
+
const result = await this._fetchGet(`/marker/${this._pathSegment(marker)}/children?langCode=${encodeURIComponent(langCode)}`);
|
|
102
102
|
// Validate response if validation is enabled
|
|
103
103
|
const validated = await this._validateResponse(result, schema('UserGroupsResponseSchema'));
|
|
104
104
|
return this._normalizeData(validated, langCode);
|
|
@@ -17,11 +17,11 @@ export declare const UserGroupEntitySchema: z.ZodObject<{
|
|
|
17
17
|
localizeInfos: z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
18
18
|
title: z.ZodString;
|
|
19
19
|
content: z.ZodOptional<z.ZodString>;
|
|
20
|
-
menuTitle: z.ZodOptional<z.ZodString
|
|
20
|
+
menuTitle: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
21
21
|
}, z.core.$strip>>, z.ZodObject<{
|
|
22
22
|
title: z.ZodString;
|
|
23
23
|
content: z.ZodOptional<z.ZodString>;
|
|
24
|
-
menuTitle: z.ZodOptional<z.ZodString
|
|
24
|
+
menuTitle: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
25
25
|
}, z.core.$strip>]>;
|
|
26
26
|
isVisible: z.ZodBoolean;
|
|
27
27
|
childrenCount: z.ZodString;
|
|
@@ -40,11 +40,11 @@ export declare const UserGroupsResponseSchema: z.ZodArray<z.ZodObject<{
|
|
|
40
40
|
localizeInfos: z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
41
41
|
title: z.ZodString;
|
|
42
42
|
content: z.ZodOptional<z.ZodString>;
|
|
43
|
-
menuTitle: z.ZodOptional<z.ZodString
|
|
43
|
+
menuTitle: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
44
44
|
}, z.core.$strip>>, z.ZodObject<{
|
|
45
45
|
title: z.ZodString;
|
|
46
46
|
content: z.ZodOptional<z.ZodString>;
|
|
47
|
-
menuTitle: z.ZodOptional<z.ZodString
|
|
47
|
+
menuTitle: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
48
48
|
}, z.core.$strip>]>;
|
|
49
49
|
isVisible: z.ZodBoolean;
|
|
50
50
|
childrenCount: z.ZodString;
|
package/esm/users/usersApi.d.ts
CHANGED
|
@@ -58,7 +58,7 @@ export default class UsersApi extends AsyncModules implements IUsersApi {
|
|
|
58
58
|
},
|
|
59
59
|
"state": {}
|
|
60
60
|
}
|
|
61
|
-
* @param {string} body.formIdentifier - Identifies the registration form being used. Example: "
|
|
61
|
+
* @param {string} body.formIdentifier - Identifies the registration form being used. Example: "reg".
|
|
62
62
|
* @param {string} body.authData - Contains authentication credentials for the user. Example:
|
|
63
63
|
* @example
|
|
64
64
|
[
|
package/esm/users/usersApi.js
CHANGED
|
@@ -27,10 +27,21 @@ export default class UsersApi extends AsyncModules {
|
|
|
27
27
|
* @see {@link https://js-sdk.oneentry.cloud/docs/users/getUser getUser} documentation.
|
|
28
28
|
*/
|
|
29
29
|
async getUser(langCode = this.state.lang) {
|
|
30
|
-
const result = await this._fetchGet(`/me?langCode=${langCode}`);
|
|
30
|
+
const result = await this._fetchGet(`/me?langCode=${encodeURIComponent(langCode)}`);
|
|
31
31
|
// Validate response if validation is enabled
|
|
32
32
|
const validated = await this._validateResponse(result, schema('UserResponseSchema'));
|
|
33
|
-
|
|
33
|
+
// `state` is the caller's own data, stored as written: the normalizer took a
|
|
34
|
+
// `{ en_US: … }` map in it for a localization and `{ type, value }` for an attribute.
|
|
35
|
+
// It is kept out of the normalization altogether — `{ attributes: { x: 's' } }`
|
|
36
|
+
// in it made `getUser` throw a TypeError.
|
|
37
|
+
if (validated &&
|
|
38
|
+
typeof validated === 'object' &&
|
|
39
|
+
!this._isErrorResponse(validated) &&
|
|
40
|
+
'state' in validated) {
|
|
41
|
+
const { state, ...rest } = validated;
|
|
42
|
+
return { ...this._normalizeData(rest, langCode), state };
|
|
43
|
+
}
|
|
44
|
+
return this._normalizeData(validated, langCode);
|
|
34
45
|
}
|
|
35
46
|
/**
|
|
36
47
|
* Updating a single user object.
|
|
@@ -63,7 +74,7 @@ export default class UsersApi extends AsyncModules {
|
|
|
63
74
|
},
|
|
64
75
|
"state": {}
|
|
65
76
|
}
|
|
66
|
-
* @param {string} body.formIdentifier - Identifies the registration form being used. Example: "
|
|
77
|
+
* @param {string} body.formIdentifier - Identifies the registration form being used. Example: "reg".
|
|
67
78
|
* @param {string} body.authData - Contains authentication credentials for the user. Example:
|
|
68
79
|
* @example
|
|
69
80
|
[
|
|
@@ -111,8 +122,13 @@ export default class UsersApi extends AsyncModules {
|
|
|
111
122
|
async updateUser(body, langCode = this.state.lang) {
|
|
112
123
|
// The language goes onto our own copy; the caller's body is left alone (CMS-909).
|
|
113
124
|
const payload = 'langCode' in body ? body : { ...body, langCode };
|
|
114
|
-
|
|
115
|
-
|
|
125
|
+
// formData is wrapped under the language of the body: a `langCode: 'ru_RU'` in the
|
|
126
|
+
// body used to be sent with the fields under `en_US`
|
|
127
|
+
const bodyLang = payload.langCode || langCode;
|
|
128
|
+
const result = await this._fetchPut('/me', this._normalizePostBody(payload, bodyLang));
|
|
129
|
+
// An empty 2xx body comes back as `{}`; the method declares `true`. Read before
|
|
130
|
+
// validation: in strict mode the boolean schema turned that success into a 422
|
|
131
|
+
const validated = await this._validateResponse(this._asBoolean(result), schema('UpdateUserResponseSchema'));
|
|
116
132
|
return validated;
|
|
117
133
|
}
|
|
118
134
|
/**
|
|
@@ -125,8 +141,8 @@ export default class UsersApi extends AsyncModules {
|
|
|
125
141
|
* @see {@link https://js-sdk.oneentry.cloud/docs/users/archiveUser archiveUser} documentation.
|
|
126
142
|
*/
|
|
127
143
|
async archiveUser() {
|
|
128
|
-
|
|
129
|
-
return
|
|
144
|
+
// An empty 2xx body came back as `{}`; the method declares `true`
|
|
145
|
+
return this._fetchBoolean(() => this._fetchDelete('/me'));
|
|
130
146
|
}
|
|
131
147
|
/**
|
|
132
148
|
* Delete a single user.
|
|
@@ -138,8 +154,7 @@ export default class UsersApi extends AsyncModules {
|
|
|
138
154
|
* @see {@link https://js-sdk.oneentry.cloud/docs/users/deleteUser deleteUser} documentation.
|
|
139
155
|
*/
|
|
140
156
|
async deleteUser() {
|
|
141
|
-
|
|
142
|
-
return result;
|
|
157
|
+
return this._fetchBoolean(() => this._fetchDelete('/me/account'));
|
|
143
158
|
}
|
|
144
159
|
/**
|
|
145
160
|
* Adds an FCM (Firebase Cloud Messaging) token for sending push notifications.
|
|
@@ -152,8 +167,7 @@ export default class UsersApi extends AsyncModules {
|
|
|
152
167
|
* @see {@link https://js-sdk.oneentry.cloud/docs/users/addFCMToken addFCMToken} documentation.
|
|
153
168
|
*/
|
|
154
169
|
async addFCMToken(token) {
|
|
155
|
-
|
|
156
|
-
return result;
|
|
170
|
+
return this._fetchBoolean(() => this._fetchPost(`/me/fcm-token/${this._pathSegment(token)}`));
|
|
157
171
|
}
|
|
158
172
|
/**
|
|
159
173
|
* Deletes an FCM (Firebase Cloud Messaging) token.
|
|
@@ -166,8 +180,7 @@ export default class UsersApi extends AsyncModules {
|
|
|
166
180
|
* @see {@link https://js-sdk.oneentry.cloud/docs/users/deleteFCMToken deleteFCMToken} documentation.
|
|
167
181
|
*/
|
|
168
182
|
async deleteFCMToken(token) {
|
|
169
|
-
|
|
170
|
-
return result;
|
|
183
|
+
return this._fetchBoolean(() => this._fetchDelete(`/me/fcm-token/${this._pathSegment(token)}`));
|
|
171
184
|
}
|
|
172
185
|
/**
|
|
173
186
|
* Get the current user's or guest's cart.
|
|
@@ -224,7 +237,7 @@ export default class UsersApi extends AsyncModules {
|
|
|
224
237
|
* @see {@link https://js-sdk.oneentry.cloud/docs/users/removeCartItem removeCartItem} documentation.
|
|
225
238
|
*/
|
|
226
239
|
async removeCartItem(productId) {
|
|
227
|
-
const result = await this._fetchDelete(`/me/cart/items/${productId}`);
|
|
240
|
+
const result = await this._fetchDelete(`/me/cart/items/${this._pathSegment(String(productId))}`);
|
|
228
241
|
const validated = await this._validateResponse(result, schema('CartResponseSchema'));
|
|
229
242
|
return this._normalizeData(validated);
|
|
230
243
|
}
|
|
@@ -283,7 +296,7 @@ export default class UsersApi extends AsyncModules {
|
|
|
283
296
|
* @see {@link https://js-sdk.oneentry.cloud/docs/users/removeWishlistItem removeWishlistItem} documentation.
|
|
284
297
|
*/
|
|
285
298
|
async removeWishlistItem(productId) {
|
|
286
|
-
const result = await this._fetchDelete(`/me/wishlist/items/${productId}`);
|
|
299
|
+
const result = await this._fetchDelete(`/me/wishlist/items/${this._pathSegment(String(productId))}`);
|
|
287
300
|
const validated = await this._validateResponse(result, schema('WishlistResponseSchema'));
|
|
288
301
|
return this._normalizeData(validated);
|
|
289
302
|
}
|
|
@@ -49,7 +49,7 @@ interface IUsersApi {
|
|
|
49
49
|
},
|
|
50
50
|
"state": {}
|
|
51
51
|
}
|
|
52
|
-
* @param {string} body.formIdentifier - Identifies the registration form being used. Example: "
|
|
52
|
+
* @param {string} body.formIdentifier - Identifies the registration form being used. Example: "reg".
|
|
53
53
|
* @param {string} body.authData - Contains authentication credentials for the user. Example:
|
|
54
54
|
* @example
|
|
55
55
|
[
|
|
@@ -264,13 +264,7 @@ interface IUsersResponse {
|
|
|
264
264
|
}
|
|
265
265
|
]
|
|
266
266
|
* @property {string} formIdentifier - Marker of the form. Example: "form_12345".
|
|
267
|
-
* @property {string}
|
|
268
|
-
* @property {Array<string | number>} groups - User groups.
|
|
269
|
-
* @example
|
|
270
|
-
[
|
|
271
|
-
"group_1",
|
|
272
|
-
"group_2"
|
|
273
|
-
]
|
|
267
|
+
* @property {Array<string | number>} groups - IDs of the user groups the user belongs to (numbers on the API). Example: [1].
|
|
274
268
|
* @property {object} state - Custom key-value data stored with the user.
|
|
275
269
|
* @example
|
|
276
270
|
{
|
|
@@ -288,7 +282,6 @@ interface IUserEntity {
|
|
|
288
282
|
formData: FormDataType[];
|
|
289
283
|
formIdentifier: string;
|
|
290
284
|
/** @deprecated Service counter leaking into the response, always `"1"`; the field may disappear. */
|
|
291
|
-
total?: string;
|
|
292
285
|
groups: Array<string | number>;
|
|
293
286
|
state: Record<string, unknown>;
|
|
294
287
|
moduleFormConfigs?: Array<IFormConfig>;
|