oneentry 1.0.176 → 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 +116 -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 +90 -23
- 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 +62 -1
- package/dist/base/asyncModules.js +219 -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 +82 -64
- package/dist/blocks/blocksInterfaces.d.ts +8 -8
- package/dist/discounts/discountsApi.d.ts +9 -7
- package/dist/discounts/discountsApi.js +16 -13
- package/dist/discounts/discountsInterfaces.d.ts +14 -10
- package/dist/events/eventsApi.d.ts +3 -3
- package/dist/events/eventsApi.js +3 -3
- 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 +16 -0
- package/dist/forms-data/formsDataApi.js +32 -5
- package/dist/forms-data/formsDataInterfaces.d.ts +17 -13
- 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 +41 -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 +21 -42
- 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 +3 -3
- 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 +90 -23
- 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 +62 -1
- package/esm/base/asyncModules.js +219 -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 +82 -64
- package/esm/blocks/blocksInterfaces.d.ts +8 -8
- package/esm/discounts/discountsApi.d.ts +9 -7
- package/esm/discounts/discountsApi.js +16 -13
- package/esm/discounts/discountsInterfaces.d.ts +14 -10
- package/esm/events/eventsApi.d.ts +3 -3
- package/esm/events/eventsApi.js +3 -3
- 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 +16 -0
- package/esm/forms-data/formsDataApi.js +32 -5
- package/esm/forms-data/formsDataInterfaces.d.ts +17 -13
- 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 +41 -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 +21 -42
- 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 +3 -3
- 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
|
*/
|
|
@@ -89,7 +89,7 @@ class SubscriptionsApi extends asyncModules_1.default {
|
|
|
89
89
|
* @handleName getAllSubscriptions
|
|
90
90
|
* @returns {Promise<ISubscriptionEntity[] | IError>} Returns an array of available subscriptions.
|
|
91
91
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
92
|
-
* @description
|
|
92
|
+
* @description Lists the plans available for subscription. It does not need a signed-in user: a guest gets the same list.
|
|
93
93
|
* @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}.
|
|
94
94
|
* @see {@link https://js-sdk.oneentry.cloud/docs/subscriptions/getAllSubscriptions getAllSubscriptions} documentation.
|
|
95
95
|
*/
|
|
@@ -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/dist/system/systemApi.js
CHANGED
|
@@ -26,6 +26,7 @@ class SystemApi extends asyncModules_1.default {
|
|
|
26
26
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
27
27
|
* @description This method is used to test the 404 error handling by sending a GET request to a specific endpoint.
|
|
28
28
|
* @see {@link https://js-sdk.oneentry.cloud/docs/system/test404 test404} documentation.
|
|
29
|
+
* @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.
|
|
29
30
|
*/
|
|
30
31
|
async test404() {
|
|
31
32
|
const result = await this._fetchGet('/test404');
|
|
@@ -38,6 +39,7 @@ class SystemApi extends asyncModules_1.default {
|
|
|
38
39
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
39
40
|
* @description This method is used to test the 500 error handling by sending a GET request to a specific endpoint.
|
|
40
41
|
* @see {@link https://js-sdk.oneentry.cloud/docs/system/test500 test500} documentation.
|
|
42
|
+
* @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.
|
|
41
43
|
*/
|
|
42
44
|
async test500() {
|
|
43
45
|
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';
|
|
|
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
|
|
@@ -46,7 +46,7 @@ const schema = (0, lazySchema_1.default)(() => Promise.resolve().then(() => __im
|
|
|
46
46
|
* @handle /api/content/templates
|
|
47
47
|
* @description This module provides a set of controllers for handling operations related to template objects.
|
|
48
48
|
*/
|
|
49
|
-
class
|
|
49
|
+
class TemplatesApi extends asyncModules_1.default {
|
|
50
50
|
/**
|
|
51
51
|
* Constructor for TemplatesApi class.
|
|
52
52
|
* @param {StateModule} state - The state module instance.
|
|
@@ -66,13 +66,14 @@ class TemplatesPreviewApi extends asyncModules_1.default {
|
|
|
66
66
|
* @see {@link https://js-sdk.oneentry.cloud/docs/templates/getAllTemplates getAllTemplates} documentation.
|
|
67
67
|
*/
|
|
68
68
|
async getAllTemplates(langCode = this.state.lang) {
|
|
69
|
-
const response = await this._fetchGet(`/all?langCode=${langCode}`);
|
|
69
|
+
const response = await this._fetchGet(`/all?langCode=${encodeURIComponent(langCode)}`);
|
|
70
70
|
// Validate response if validation is enabled
|
|
71
71
|
const validated = await this._validateResponse(response, schema('GroupedTemplatesResponseSchema'));
|
|
72
|
+
if (this._isErrorResponse(validated)) {
|
|
73
|
+
return validated;
|
|
74
|
+
}
|
|
72
75
|
const result = {};
|
|
73
|
-
if (validated &&
|
|
74
|
-
typeof validated === 'object' &&
|
|
75
|
-
!('statusCode' in validated)) {
|
|
76
|
+
if (validated && typeof validated === 'object') {
|
|
76
77
|
const grouped = validated;
|
|
77
78
|
// eslint-disable-next-line no-restricted-syntax
|
|
78
79
|
for (const item in grouped) {
|
|
@@ -84,7 +85,7 @@ class TemplatesPreviewApi extends asyncModules_1.default {
|
|
|
84
85
|
/**
|
|
85
86
|
* Get template objects by type.
|
|
86
87
|
* @handleName getTemplateByType
|
|
87
|
-
* @param {BlockType} type - Type of templates to fetch. Example: "
|
|
88
|
+
* @param {BlockType} type - Type of templates to fetch. Example: "product_block". A type with no templates gives an empty array.
|
|
88
89
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
89
90
|
* @returns {Promise<ITemplateEntity[] | IError>} Array of `ITemplateEntity` objects of the given type.
|
|
90
91
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
@@ -92,10 +93,10 @@ class TemplatesPreviewApi extends asyncModules_1.default {
|
|
|
92
93
|
* @see {@link https://js-sdk.oneentry.cloud/docs/templates/getTemplateByType getTemplateByType} documentation.
|
|
93
94
|
*/
|
|
94
95
|
async getTemplateByType(type, langCode = this.state.lang) {
|
|
95
|
-
const result = await this._fetchGet(`?type=${type}&langCode=${langCode}`);
|
|
96
|
+
const result = await this._fetchGet(`?type=${encodeURIComponent(type)}&langCode=${encodeURIComponent(langCode)}`);
|
|
96
97
|
// Validate response if validation is enabled
|
|
97
98
|
const validated = await this._validateResponse(result, schema('TemplatesResponseSchema'));
|
|
98
|
-
return this._normalizeData(validated);
|
|
99
|
+
return this._normalizeData(validated, langCode);
|
|
99
100
|
}
|
|
100
101
|
/**
|
|
101
102
|
* Get one template object by marker.
|
|
@@ -108,10 +109,10 @@ class TemplatesPreviewApi extends asyncModules_1.default {
|
|
|
108
109
|
* @see {@link https://js-sdk.oneentry.cloud/docs/templates/getTemplateByMarker getTemplateByMarker} documentation.
|
|
109
110
|
*/
|
|
110
111
|
async getTemplateByMarker(marker, langCode = this.state.lang) {
|
|
111
|
-
const result = await this._fetchGet(`/marker/${this._pathSegment(marker)}?langCode=${langCode}`);
|
|
112
|
+
const result = await this._fetchGet(`/marker/${this._pathSegment(marker)}?langCode=${encodeURIComponent(langCode)}`);
|
|
112
113
|
// Validate response if validation is enabled
|
|
113
114
|
const validated = await this._validateResponse(result, schema('TemplateEntitySchema'));
|
|
114
|
-
return this._normalizeData(validated);
|
|
115
|
+
return this._normalizeData(validated, langCode);
|
|
115
116
|
}
|
|
116
117
|
}
|
|
117
|
-
exports.default =
|
|
118
|
+
exports.default = TemplatesApi;
|
|
@@ -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
|
{
|
|
@@ -64,7 +64,7 @@ class TemplatePreviewsApi extends asyncModules_1.default {
|
|
|
64
64
|
* @see {@link https://js-sdk.oneentry.cloud/docs/templates-preview/getTemplatePreviews getTemplatePreviews} documentation.
|
|
65
65
|
*/
|
|
66
66
|
async getTemplatePreviews(langCode = this.state.lang) {
|
|
67
|
-
const result = await this._fetchGet(`?langCode=${langCode}`);
|
|
67
|
+
const result = await this._fetchGet(`?langCode=${encodeURIComponent(langCode)}`);
|
|
68
68
|
// Validate response if validation is enabled
|
|
69
69
|
const validated = await this._validateResponse(result, schema('TemplatePreviewsResponseSchema'));
|
|
70
70
|
return this._normalizeData(validated, langCode);
|
|
@@ -80,7 +80,7 @@ class TemplatePreviewsApi extends asyncModules_1.default {
|
|
|
80
80
|
* @see {@link https://js-sdk.oneentry.cloud/docs/templates-preview/getTemplatePreviewByMarker getTemplatePreviewByMarker} documentation.
|
|
81
81
|
*/
|
|
82
82
|
async getTemplatePreviewByMarker(marker, langCode = this.state.lang) {
|
|
83
|
-
const result = await this._fetchGet(`/marker/${this._pathSegment(marker)}?langCode=${langCode}`);
|
|
83
|
+
const result = await this._fetchGet(`/marker/${this._pathSegment(marker)}?langCode=${encodeURIComponent(langCode)}`);
|
|
84
84
|
// Validate response if validation is enabled
|
|
85
85
|
const validated = await this._validateResponse(result, schema('TemplatePreviewEntitySchema'));
|
|
86
86
|
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;
|
|
@@ -13,6 +13,7 @@ exports.ProportionSchema = zod_1.z.object({
|
|
|
13
13
|
width: zod_1.z.number().nullable(),
|
|
14
14
|
height: zod_1.z.number().nullable(),
|
|
15
15
|
alignmentType: zod_1.z.string(),
|
|
16
|
+
weight: zod_1.z.number().nullable().optional(),
|
|
16
17
|
});
|
|
17
18
|
/**
|
|
18
19
|
* Square schema
|
|
@@ -33,6 +34,7 @@ exports.TemplatePreviewEntitySchema = zod_1.z.object({
|
|
|
33
34
|
horizontal: exports.ProportionSchema.nullable(),
|
|
34
35
|
vertical: exports.ProportionSchema.nullable(),
|
|
35
36
|
square: exports.SquareSchema,
|
|
37
|
+
default: zod_1.z.boolean().optional(),
|
|
36
38
|
}),
|
|
37
39
|
}),
|
|
38
40
|
identifier: zod_1.z.string(),
|
|
@@ -72,7 +72,7 @@ class UserGroupsApi extends asyncModules_1.default {
|
|
|
72
72
|
* @see {@link https://js-sdk.oneentry.cloud/docs/user-groups/getUserGroups getUserGroups} documentation.
|
|
73
73
|
*/
|
|
74
74
|
async getUserGroups(langCode = this.state.lang) {
|
|
75
|
-
const result = await this._fetchGet(`/?langCode=${langCode}`);
|
|
75
|
+
const result = await this._fetchGet(`/?langCode=${encodeURIComponent(langCode)}`);
|
|
76
76
|
// Validate response if validation is enabled
|
|
77
77
|
const validated = await this._validateResponse(result, schema('UserGroupsResponseSchema'));
|
|
78
78
|
return this._normalizeData(validated, langCode);
|
|
@@ -87,7 +87,7 @@ class UserGroupsApi extends asyncModules_1.default {
|
|
|
87
87
|
* @see {@link https://js-sdk.oneentry.cloud/docs/user-groups/getRootUserGroups getRootUserGroups} documentation.
|
|
88
88
|
*/
|
|
89
89
|
async getRootUserGroups(langCode = this.state.lang) {
|
|
90
|
-
const result = await this._fetchGet(`/root?langCode=${langCode}`);
|
|
90
|
+
const result = await this._fetchGet(`/root?langCode=${encodeURIComponent(langCode)}`);
|
|
91
91
|
// Validate response if validation is enabled
|
|
92
92
|
const validated = await this._validateResponse(result, schema('UserGroupsResponseSchema'));
|
|
93
93
|
return this._normalizeData(validated, langCode);
|
|
@@ -103,7 +103,7 @@ class UserGroupsApi extends asyncModules_1.default {
|
|
|
103
103
|
* @see {@link https://js-sdk.oneentry.cloud/docs/user-groups/getUserGroupById getUserGroupById} documentation.
|
|
104
104
|
*/
|
|
105
105
|
async getUserGroupById(id, langCode = this.state.lang) {
|
|
106
|
-
const result = await this._fetchGet(`/${id}?langCode=${langCode}`);
|
|
106
|
+
const result = await this._fetchGet(`/${this._pathSegment(String(id))}?langCode=${encodeURIComponent(langCode)}`);
|
|
107
107
|
// Validate response if validation is enabled
|
|
108
108
|
const validated = await this._validateResponse(result, schema('UserGroupEntitySchema'));
|
|
109
109
|
return this._normalizeData(validated, langCode);
|
|
@@ -119,7 +119,7 @@ class UserGroupsApi extends asyncModules_1.default {
|
|
|
119
119
|
* @see {@link https://js-sdk.oneentry.cloud/docs/user-groups/getUserGroupByMarker getUserGroupByMarker} documentation.
|
|
120
120
|
*/
|
|
121
121
|
async getUserGroupByMarker(marker, langCode = this.state.lang) {
|
|
122
|
-
const result = await this._fetchGet(`/marker/${this._pathSegment(marker)}?langCode=${langCode}`);
|
|
122
|
+
const result = await this._fetchGet(`/marker/${this._pathSegment(marker)}?langCode=${encodeURIComponent(langCode)}`);
|
|
123
123
|
// Validate response if validation is enabled
|
|
124
124
|
const validated = await this._validateResponse(result, schema('UserGroupEntitySchema'));
|
|
125
125
|
return this._normalizeData(validated, langCode);
|
|
@@ -136,7 +136,7 @@ class UserGroupsApi extends asyncModules_1.default {
|
|
|
136
136
|
* @see {@link https://js-sdk.oneentry.cloud/docs/user-groups/getChildUserGroupsByMarker getChildUserGroupsByMarker} documentation.
|
|
137
137
|
*/
|
|
138
138
|
async getChildUserGroupsByMarker(marker, langCode = this.state.lang) {
|
|
139
|
-
const result = await this._fetchGet(`/marker/${this._pathSegment(marker)}/children?langCode=${langCode}`);
|
|
139
|
+
const result = await this._fetchGet(`/marker/${this._pathSegment(marker)}/children?langCode=${encodeURIComponent(langCode)}`);
|
|
140
140
|
// Validate response if validation is enabled
|
|
141
141
|
const validated = await this._validateResponse(result, schema('UserGroupsResponseSchema'));
|
|
142
142
|
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/dist/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/dist/users/usersApi.js
CHANGED
|
@@ -65,10 +65,21 @@ class UsersApi extends asyncModules_1.default {
|
|
|
65
65
|
* @see {@link https://js-sdk.oneentry.cloud/docs/users/getUser getUser} documentation.
|
|
66
66
|
*/
|
|
67
67
|
async getUser(langCode = this.state.lang) {
|
|
68
|
-
const result = await this._fetchGet(`/me?langCode=${langCode}`);
|
|
68
|
+
const result = await this._fetchGet(`/me?langCode=${encodeURIComponent(langCode)}`);
|
|
69
69
|
// Validate response if validation is enabled
|
|
70
70
|
const validated = await this._validateResponse(result, schema('UserResponseSchema'));
|
|
71
|
-
|
|
71
|
+
// `state` is the caller's own data, stored as written: the normalizer took a
|
|
72
|
+
// `{ en_US: … }` map in it for a localization and `{ type, value }` for an attribute.
|
|
73
|
+
// It is kept out of the normalization altogether — `{ attributes: { x: 's' } }`
|
|
74
|
+
// in it made `getUser` throw a TypeError.
|
|
75
|
+
if (validated &&
|
|
76
|
+
typeof validated === 'object' &&
|
|
77
|
+
!this._isErrorResponse(validated) &&
|
|
78
|
+
'state' in validated) {
|
|
79
|
+
const { state, ...rest } = validated;
|
|
80
|
+
return { ...this._normalizeData(rest, langCode), state };
|
|
81
|
+
}
|
|
82
|
+
return this._normalizeData(validated, langCode);
|
|
72
83
|
}
|
|
73
84
|
/**
|
|
74
85
|
* Updating a single user object.
|
|
@@ -101,7 +112,7 @@ class UsersApi extends asyncModules_1.default {
|
|
|
101
112
|
},
|
|
102
113
|
"state": {}
|
|
103
114
|
}
|
|
104
|
-
* @param {string} body.formIdentifier - Identifies the registration form being used. Example: "
|
|
115
|
+
* @param {string} body.formIdentifier - Identifies the registration form being used. Example: "reg".
|
|
105
116
|
* @param {string} body.authData - Contains authentication credentials for the user. Example:
|
|
106
117
|
* @example
|
|
107
118
|
[
|
|
@@ -149,8 +160,13 @@ class UsersApi extends asyncModules_1.default {
|
|
|
149
160
|
async updateUser(body, langCode = this.state.lang) {
|
|
150
161
|
// The language goes onto our own copy; the caller's body is left alone (CMS-909).
|
|
151
162
|
const payload = 'langCode' in body ? body : { ...body, langCode };
|
|
152
|
-
|
|
153
|
-
|
|
163
|
+
// formData is wrapped under the language of the body: a `langCode: 'ru_RU'` in the
|
|
164
|
+
// body used to be sent with the fields under `en_US`
|
|
165
|
+
const bodyLang = payload.langCode || langCode;
|
|
166
|
+
const result = await this._fetchPut('/me', this._normalizePostBody(payload, bodyLang));
|
|
167
|
+
// An empty 2xx body comes back as `{}`; the method declares `true`. Read before
|
|
168
|
+
// validation: in strict mode the boolean schema turned that success into a 422
|
|
169
|
+
const validated = await this._validateResponse(this._asBoolean(result), schema('UpdateUserResponseSchema'));
|
|
154
170
|
return validated;
|
|
155
171
|
}
|
|
156
172
|
/**
|
|
@@ -163,8 +179,8 @@ class UsersApi extends asyncModules_1.default {
|
|
|
163
179
|
* @see {@link https://js-sdk.oneentry.cloud/docs/users/archiveUser archiveUser} documentation.
|
|
164
180
|
*/
|
|
165
181
|
async archiveUser() {
|
|
166
|
-
|
|
167
|
-
return
|
|
182
|
+
// An empty 2xx body came back as `{}`; the method declares `true`
|
|
183
|
+
return this._fetchBoolean(() => this._fetchDelete('/me'));
|
|
168
184
|
}
|
|
169
185
|
/**
|
|
170
186
|
* Delete a single user.
|
|
@@ -176,8 +192,7 @@ class UsersApi extends asyncModules_1.default {
|
|
|
176
192
|
* @see {@link https://js-sdk.oneentry.cloud/docs/users/deleteUser deleteUser} documentation.
|
|
177
193
|
*/
|
|
178
194
|
async deleteUser() {
|
|
179
|
-
|
|
180
|
-
return result;
|
|
195
|
+
return this._fetchBoolean(() => this._fetchDelete('/me/account'));
|
|
181
196
|
}
|
|
182
197
|
/**
|
|
183
198
|
* Adds an FCM (Firebase Cloud Messaging) token for sending push notifications.
|
|
@@ -190,8 +205,7 @@ class UsersApi extends asyncModules_1.default {
|
|
|
190
205
|
* @see {@link https://js-sdk.oneentry.cloud/docs/users/addFCMToken addFCMToken} documentation.
|
|
191
206
|
*/
|
|
192
207
|
async addFCMToken(token) {
|
|
193
|
-
|
|
194
|
-
return result;
|
|
208
|
+
return this._fetchBoolean(() => this._fetchPost(`/me/fcm-token/${this._pathSegment(token)}`));
|
|
195
209
|
}
|
|
196
210
|
/**
|
|
197
211
|
* Deletes an FCM (Firebase Cloud Messaging) token.
|
|
@@ -204,8 +218,7 @@ class UsersApi extends asyncModules_1.default {
|
|
|
204
218
|
* @see {@link https://js-sdk.oneentry.cloud/docs/users/deleteFCMToken deleteFCMToken} documentation.
|
|
205
219
|
*/
|
|
206
220
|
async deleteFCMToken(token) {
|
|
207
|
-
|
|
208
|
-
return result;
|
|
221
|
+
return this._fetchBoolean(() => this._fetchDelete(`/me/fcm-token/${this._pathSegment(token)}`));
|
|
209
222
|
}
|
|
210
223
|
/**
|
|
211
224
|
* Get the current user's or guest's cart.
|
|
@@ -262,7 +275,7 @@ class UsersApi extends asyncModules_1.default {
|
|
|
262
275
|
* @see {@link https://js-sdk.oneentry.cloud/docs/users/removeCartItem removeCartItem} documentation.
|
|
263
276
|
*/
|
|
264
277
|
async removeCartItem(productId) {
|
|
265
|
-
const result = await this._fetchDelete(`/me/cart/items/${productId}`);
|
|
278
|
+
const result = await this._fetchDelete(`/me/cart/items/${this._pathSegment(String(productId))}`);
|
|
266
279
|
const validated = await this._validateResponse(result, schema('CartResponseSchema'));
|
|
267
280
|
return this._normalizeData(validated);
|
|
268
281
|
}
|
|
@@ -321,7 +334,7 @@ class UsersApi extends asyncModules_1.default {
|
|
|
321
334
|
* @see {@link https://js-sdk.oneentry.cloud/docs/users/removeWishlistItem removeWishlistItem} documentation.
|
|
322
335
|
*/
|
|
323
336
|
async removeWishlistItem(productId) {
|
|
324
|
-
const result = await this._fetchDelete(`/me/wishlist/items/${productId}`);
|
|
337
|
+
const result = await this._fetchDelete(`/me/wishlist/items/${this._pathSegment(String(productId))}`);
|
|
325
338
|
const validated = await this._validateResponse(result, schema('WishlistResponseSchema'));
|
|
326
339
|
return this._normalizeData(validated);
|
|
327
340
|
}
|
|
@@ -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>;
|