oneentry 1.0.136 → 1.0.138

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/README.md +15 -3
  2. package/configure.js +27 -3
  3. package/dist/admins/adminsApi.d.ts +2 -2
  4. package/dist/admins/adminsApi.js +6 -3
  5. package/dist/admins/adminsInterfaces.d.ts +2 -2
  6. package/dist/admins/adminsSchemas.d.ts +30 -0
  7. package/dist/admins/adminsSchemas.js +27 -0
  8. package/dist/attribute-sets/attributeSetsApi.d.ts +8 -8
  9. package/dist/attribute-sets/attributeSetsApi.js +21 -12
  10. package/dist/attribute-sets/attributeSetsInterfaces.d.ts +3 -3
  11. package/dist/attribute-sets/attributeSetsSchemas.d.ts +90 -0
  12. package/dist/attribute-sets/attributeSetsSchemas.js +74 -0
  13. package/dist/auth-provider/authProviderApi.d.ts +44 -41
  14. package/dist/auth-provider/authProviderApi.js +58 -48
  15. package/dist/auth-provider/authProviderSchemas.d.ts +137 -0
  16. package/dist/auth-provider/authProviderSchemas.js +85 -0
  17. package/dist/auth-provider/authProvidersInterfaces.d.ts +17 -67
  18. package/dist/base/asyncModules.d.ts +25 -15
  19. package/dist/base/asyncModules.js +65 -44
  20. package/dist/base/stateModule.d.ts +8 -0
  21. package/dist/base/stateModule.js +27 -11
  22. package/dist/base/syncModules.d.ts +18 -0
  23. package/dist/base/syncModules.js +93 -99
  24. package/dist/base/utils.d.ts +56 -10
  25. package/dist/base/validation.d.ts +118 -0
  26. package/dist/base/validation.js +132 -0
  27. package/dist/blocks/blocksApi.d.ts +10 -10
  28. package/dist/blocks/blocksApi.js +26 -21
  29. package/dist/blocks/blocksInterfaces.d.ts +2 -1
  30. package/dist/blocks/blocksSchemas.d.ts +187 -0
  31. package/dist/blocks/blocksSchemas.js +43 -0
  32. package/dist/events/eventsApi.d.ts +5 -5
  33. package/dist/events/eventsApi.js +5 -5
  34. package/dist/events/eventsInterfaces.d.ts +25 -15
  35. package/dist/file-uploading/fileUploadingApi.d.ts +6 -6
  36. package/dist/file-uploading/fileUploadingApi.js +10 -7
  37. package/dist/file-uploading/fileUploadingSchemas.d.ts +22 -0
  38. package/dist/file-uploading/fileUploadingSchemas.js +21 -0
  39. package/dist/forms/formsApi.d.ts +4 -4
  40. package/dist/forms/formsApi.js +11 -6
  41. package/dist/forms/formsInterfaces.d.ts +21 -8
  42. package/dist/forms/formsSchemas.d.ts +65 -0
  43. package/dist/forms/formsSchemas.js +36 -0
  44. package/dist/forms-data/formsDataApi.d.ts +10 -10
  45. package/dist/forms-data/formsDataApi.js +20 -13
  46. package/dist/forms-data/formsDataInterfaces.d.ts +26 -26
  47. package/dist/forms-data/formsDataSchemas.d.ts +115 -0
  48. package/dist/forms-data/formsDataSchemas.js +86 -0
  49. package/dist/general-types/generalTypesApi.d.ts +2 -2
  50. package/dist/general-types/generalTypesApi.js +6 -3
  51. package/dist/general-types/generalTypesSchemas.d.ts +50 -0
  52. package/dist/general-types/generalTypesSchemas.js +35 -0
  53. package/dist/index.d.ts +23 -1
  54. package/dist/integration-collections/integrationCollectionsApi.d.ts +17 -17
  55. package/dist/integration-collections/integrationCollectionsApi.js +42 -26
  56. package/dist/integration-collections/integrationCollectionsSchemas.d.ts +84 -0
  57. package/dist/integration-collections/integrationCollectionsSchemas.js +63 -0
  58. package/dist/locales/localesApi.d.ts +2 -2
  59. package/dist/locales/localesApi.js +6 -3
  60. package/dist/locales/localesSchemas.d.ts +32 -0
  61. package/dist/locales/localesSchemas.js +26 -0
  62. package/dist/menus/menusApi.d.ts +2 -2
  63. package/dist/menus/menusApi.js +6 -3
  64. package/dist/menus/menusInterfaces.d.ts +2 -2
  65. package/dist/menus/menusSchemas.d.ts +16 -0
  66. package/dist/menus/menusSchemas.js +28 -0
  67. package/dist/orders/ordersApi.d.ts +12 -12
  68. package/dist/orders/ordersApi.js +25 -16
  69. package/dist/orders/ordersInterfaces.d.ts +5 -4
  70. package/dist/orders/ordersSchemas.d.ts +158 -0
  71. package/dist/orders/ordersSchemas.js +120 -0
  72. package/dist/pages/pagesApi.d.ts +22 -21
  73. package/dist/pages/pagesApi.js +107 -54
  74. package/dist/pages/pagesInterfaces.d.ts +15 -11
  75. package/dist/pages/pagesSchemas.d.ts +85 -0
  76. package/dist/pages/pagesSchemas.js +46 -0
  77. package/dist/payments/paymentsApi.d.ts +13 -13
  78. package/dist/payments/paymentsApi.js +25 -16
  79. package/dist/payments/paymentsInterfaces.d.ts +11 -5
  80. package/dist/payments/paymentsSchemas.d.ts +137 -0
  81. package/dist/payments/paymentsSchemas.js +78 -0
  82. package/dist/product-statuses/productStatusesApi.d.ts +6 -6
  83. package/dist/product-statuses/productStatusesApi.js +19 -9
  84. package/dist/product-statuses/productStatusesSchemas.d.ts +34 -0
  85. package/dist/product-statuses/productStatusesSchemas.js +30 -0
  86. package/dist/products/productsApi.d.ts +29 -28
  87. package/dist/products/productsApi.js +50 -36
  88. package/dist/products/productsInterfaces.d.ts +27 -22
  89. package/dist/products/productsSchemas.d.ts +212 -0
  90. package/dist/products/productsSchemas.js +85 -0
  91. package/dist/system/systemApi.d.ts +10 -10
  92. package/dist/system/systemApi.js +10 -10
  93. package/dist/templates/templatesApi.d.ts +6 -6
  94. package/dist/templates/templatesApi.js +17 -10
  95. package/dist/templates/templatesSchemas.d.ts +48 -0
  96. package/dist/templates/templatesSchemas.js +31 -0
  97. package/dist/templates-preview/templatesPreviewApi.d.ts +3 -3
  98. package/dist/templates-preview/templatesPreviewApi.js +10 -5
  99. package/dist/templates-preview/templatesPreviewInterfaces.d.ts +1 -0
  100. package/dist/templates-preview/templatesPreviewSchemas.d.ts +83 -0
  101. package/dist/templates-preview/templatesPreviewSchemas.js +48 -0
  102. package/dist/users/usersApi.d.ts +18 -18
  103. package/dist/users/usersApi.js +26 -23
  104. package/dist/users/usersInterfaces.d.ts +10 -11
  105. package/dist/users/usersSchemas.d.ts +38 -0
  106. package/dist/users/usersSchemas.js +28 -0
  107. package/package.json +36 -12
  108. package/dist/config.d.ts +0 -13
  109. package/dist/config.js +0 -32
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CollectionIsValidSchema = exports.CollectionRowsResponseSchema = exports.CollectionRowSchema = exports.CollectionFormDataSchema = exports.CollectionsResponseSchema = exports.CollectionEntitySchema = void 0;
4
+ /**
5
+ * Validation schemas for IntegrationCollections module
6
+ * @description Zod schemas for validating integration collections-related API responses
7
+ */
8
+ const zod_1 = require("zod");
9
+ /**
10
+ * Collection entity schema
11
+ */
12
+ exports.CollectionEntitySchema = zod_1.z.object({
13
+ id: zod_1.z.number(),
14
+ identifier: zod_1.z.string().nullable(),
15
+ formId: zod_1.z.number().nullable(),
16
+ localizeInfos: zod_1.z.record(zod_1.z.string(), zod_1.z.any()),
17
+ attributeSetId: zod_1.z.string().nullable(),
18
+ selectedAttributeMarkers: zod_1.z.string().nullable(),
19
+ });
20
+ /**
21
+ * Collections response schema (array of collections)
22
+ */
23
+ exports.CollectionsResponseSchema = zod_1.z.array(exports.CollectionEntitySchema);
24
+ /**
25
+ * Collection form data schema
26
+ */
27
+ exports.CollectionFormDataSchema = zod_1.z.object({
28
+ marker: zod_1.z.string(),
29
+ type: zod_1.z.string(),
30
+ value: zod_1.z.string(),
31
+ });
32
+ /**
33
+ * Collection row schema
34
+ */
35
+ exports.CollectionRowSchema = zod_1.z.object({
36
+ id: zod_1.z.number(),
37
+ createdDate: zod_1.z.string(),
38
+ updatedDate: zod_1.z.string(),
39
+ collectionId: zod_1.z.number().nullable().optional(),
40
+ formData: zod_1.z.union([
41
+ zod_1.z.array(exports.CollectionFormDataSchema),
42
+ zod_1.z.record(zod_1.z.string(), zod_1.z.any()),
43
+ ]),
44
+ entityType: zod_1.z.string().nullable(),
45
+ entityId: zod_1.z.number().nullable(),
46
+ attributeSetIdentifier: zod_1.z.string().nullable().optional(),
47
+ total: zod_1.z.string().optional(),
48
+ langCode: zod_1.z.string().optional(),
49
+ formIdentifier: zod_1.z.string().optional(),
50
+ });
51
+ /**
52
+ * Collection rows response schema
53
+ */
54
+ exports.CollectionRowsResponseSchema = zod_1.z.object({
55
+ items: zod_1.z.array(exports.CollectionRowSchema),
56
+ total: zod_1.z.number(),
57
+ });
58
+ /**
59
+ * Collection is valid schema
60
+ */
61
+ exports.CollectionIsValidSchema = zod_1.z.object({
62
+ valid: zod_1.z.boolean(),
63
+ });
@@ -19,8 +19,8 @@ export default class LocalesApi extends AsyncModules implements ILocales {
19
19
  /**
20
20
  * Find all active language localization objects.
21
21
  * @handleName getLocales
22
- * @returns {ILocalEntity[]} Returns an array of LocaleEntity objects.
23
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
22
+ * @returns {Promise<ILocalEntity[] | IError>} Returns an array of LocaleEntity objects.
23
+ * @throws {IError} When isShell=false and an error occurs during the fetch
24
24
  * @description Find all active language localization objects.
25
25
  */
26
26
  getLocales(): Promise<Array<ILocalEntity> | IError>;
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const asyncModules_1 = __importDefault(require("../base/asyncModules"));
7
+ const localesSchemas_1 = require("./localesSchemas");
7
8
  /**
8
9
  * Controllers for working with localizations (content language)
9
10
  * @handle /api/content/locales
@@ -22,13 +23,15 @@ class LocalesApi extends asyncModules_1.default {
22
23
  /**
23
24
  * Find all active language localization objects.
24
25
  * @handleName getLocales
25
- * @returns {ILocalEntity[]} Returns an array of LocaleEntity objects.
26
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
26
+ * @returns {Promise<ILocalEntity[] | IError>} Returns an array of LocaleEntity objects.
27
+ * @throws {IError} When isShell=false and an error occurs during the fetch
27
28
  * @description Find all active language localization objects.
28
29
  */
29
30
  async getLocales() {
30
31
  const result = await this._fetchGet('/active/all');
31
- return result;
32
+ // Validate response if validation is enabled
33
+ const validated = this._validateResponse(result, localesSchemas_1.LocalesResponseSchema);
34
+ return validated;
32
35
  }
33
36
  }
34
37
  exports.default = LocalesApi;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Validation schemas for Locales module
3
+ * @description Zod schemas for validating locales-related API responses
4
+ */
5
+ import { z } from 'zod';
6
+ /**
7
+ * Locale entity schema
8
+ * Includes all fields returned by the API
9
+ */
10
+ export declare const LocaleEntitySchema: z.ZodObject<{
11
+ id: z.ZodNumber;
12
+ shortCode: z.ZodString;
13
+ code: z.ZodString;
14
+ name: z.ZodString;
15
+ nativeName: z.ZodString;
16
+ isActive: z.ZodBoolean;
17
+ image: z.ZodNullable<z.ZodString>;
18
+ position: z.ZodNumber;
19
+ }, z.core.$strip>;
20
+ /**
21
+ * Locales response schema (array of locales)
22
+ */
23
+ export declare const LocalesResponseSchema: z.ZodArray<z.ZodObject<{
24
+ id: z.ZodNumber;
25
+ shortCode: z.ZodString;
26
+ code: z.ZodString;
27
+ name: z.ZodString;
28
+ nativeName: z.ZodString;
29
+ isActive: z.ZodBoolean;
30
+ image: z.ZodNullable<z.ZodString>;
31
+ position: z.ZodNumber;
32
+ }, z.core.$strip>>;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LocalesResponseSchema = exports.LocaleEntitySchema = void 0;
4
+ /**
5
+ * Validation schemas for Locales module
6
+ * @description Zod schemas for validating locales-related API responses
7
+ */
8
+ const zod_1 = require("zod");
9
+ /**
10
+ * Locale entity schema
11
+ * Includes all fields returned by the API
12
+ */
13
+ exports.LocaleEntitySchema = zod_1.z.object({
14
+ id: zod_1.z.number(),
15
+ shortCode: zod_1.z.string(),
16
+ code: zod_1.z.string(),
17
+ name: zod_1.z.string(),
18
+ nativeName: zod_1.z.string(),
19
+ isActive: zod_1.z.boolean(),
20
+ image: zod_1.z.string().nullable(),
21
+ position: zod_1.z.number(),
22
+ });
23
+ /**
24
+ * Locales response schema (array of locales)
25
+ */
26
+ exports.LocalesResponseSchema = zod_1.z.array(exports.LocaleEntitySchema);
@@ -21,8 +21,8 @@ export default class MenusApi extends AsyncModules implements IMenus {
21
21
  * @handleName getMenusByMarker
22
22
  * @param {string} marker - Menu marker. Example: "main_menu".
23
23
  * @param {string} [langCode] - Language code. Default: "en_US".
24
- * @returns {IMenusEntity} Returns a single menu object as a ContentMenu object with included pages.
25
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
24
+ * @returns {Promise<IMenusEntity | IError>} Returns a single menu object as a ContentMenu object with included pages.
25
+ * @throws {IError} When isShell=false and an error occurs during the fetch
26
26
  * @description Get pages includes in menu by marker.
27
27
  */
28
28
  getMenusByMarker(marker: string, langCode?: string): Promise<IMenusEntity | IError>;
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const asyncModules_1 = __importDefault(require("../base/asyncModules"));
7
+ const menusSchemas_1 = require("./menusSchemas");
7
8
  /**
8
9
  * Controllers for working with menu objects
9
10
  * @handle /api/content/menus
@@ -24,13 +25,15 @@ class MenusApi extends asyncModules_1.default {
24
25
  * @handleName getMenusByMarker
25
26
  * @param {string} marker - Menu marker. Example: "main_menu".
26
27
  * @param {string} [langCode] - Language code. Default: "en_US".
27
- * @returns {IMenusEntity} Returns a single menu object as a ContentMenu object with included pages.
28
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
28
+ * @returns {Promise<IMenusEntity | IError>} Returns a single menu object as a ContentMenu object with included pages.
29
+ * @throws {IError} When isShell=false and an error occurs during the fetch
29
30
  * @description Get pages includes in menu by marker.
30
31
  */
31
32
  async getMenusByMarker(marker, langCode = this.state.lang) {
32
33
  const result = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
33
- return this._dataPostProcess(result, langCode);
34
+ // Validate response if validation is enabled
35
+ const validated = this._validateResponse(result, menusSchemas_1.MenuEntitySchema);
36
+ return this._dataPostProcess(validated, langCode);
34
37
  }
35
38
  }
36
39
  exports.default = MenusApi;
@@ -30,8 +30,8 @@ interface IMenus {
30
30
  "position": 1
31
31
  }
32
32
  ]
33
- * @property {number} id - The unique identifier of the menu. Example: 1.
34
- * @property {string} pageUrl - The page url string. Example: "about".
33
+ * @property {number | null} id - The unique identifier of the menu. Example: 1.
34
+ * @property {string | null} pageUrl - The page url string. Example: "about".
35
35
  * @property {ILocalizeInfo} localizeInfos - The menu data, taking into account localization.
36
36
  * @example
37
37
  {
@@ -0,0 +1,16 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Menu pages schema (recursive)
4
+ * Can have children that are also menu pages
5
+ */
6
+ export declare const MenusPagesSchema: z.ZodType<any>;
7
+ /**
8
+ * Menu entity schema
9
+ * Includes all fields returned by the API
10
+ */
11
+ export declare const MenuEntitySchema: z.ZodObject<{
12
+ id: z.ZodNumber;
13
+ identifier: z.ZodString;
14
+ localizeInfos: z.ZodRecord<z.ZodString, z.ZodAny>;
15
+ pages: z.ZodUnion<readonly [z.ZodArray<z.ZodType<any, unknown, z.core.$ZodTypeInternals<any, unknown>>>, z.ZodType<any, unknown, z.core.$ZodTypeInternals<any, unknown>>]>;
16
+ }, z.core.$strip>;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MenuEntitySchema = exports.MenusPagesSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ /**
6
+ * Menu pages schema (recursive)
7
+ * Can have children that are also menu pages
8
+ */
9
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
+ exports.MenusPagesSchema = zod_1.z.lazy(() => zod_1.z.object({
11
+ children: zod_1.z.union([zod_1.z.array(exports.MenusPagesSchema), exports.MenusPagesSchema]).optional(),
12
+ id: zod_1.z.number().nullable(),
13
+ pageUrl: zod_1.z.string().nullable(),
14
+ localizeInfos: zod_1.z.record(zod_1.z.string(), zod_1.z.any()),
15
+ attributeValues: zod_1.z.record(zod_1.z.string(), zod_1.z.any()),
16
+ position: zod_1.z.number(),
17
+ parentId: zod_1.z.number().nullable(),
18
+ }));
19
+ /**
20
+ * Menu entity schema
21
+ * Includes all fields returned by the API
22
+ */
23
+ exports.MenuEntitySchema = zod_1.z.object({
24
+ id: zod_1.z.number(),
25
+ identifier: zod_1.z.string(),
26
+ localizeInfos: zod_1.z.record(zod_1.z.string(), zod_1.z.any()),
27
+ pages: zod_1.z.union([zod_1.z.array(exports.MenusPagesSchema), exports.MenusPagesSchema]),
28
+ });
@@ -23,8 +23,8 @@ export default class OrdersApi extends AsyncModules implements IOrdersApi {
23
23
  * @param {string} [langCode] - Language code. Default: "en_US".
24
24
  * @param {number} [offset] - Optional parameter for pagination. Default: 0.
25
25
  * @param {number} [limit] - Optional parameter for pagination. Default: 30.
26
- * @returns {IOrdersEntity[]} Returns an array of order storage objects.
27
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
26
+ * @returns {Promise<IOrdersEntity[] | IError>} Returns an array of order storage objects.
27
+ * @throws {IError} When isShell=false and an error occurs during the fetch
28
28
  * @description This method requires user authorization.
29
29
  * @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}.
30
30
  */
@@ -36,8 +36,8 @@ export default class OrdersApi extends AsyncModules implements IOrdersApi {
36
36
  * @param {string} [langCode] - Language code. Default: "en_US".
37
37
  * @param {number} [offset] - Offset parameter. Default: 0.
38
38
  * @param {number} [limit] - Limit parameter. Default: 30.
39
- * @returns {IOrdersByMarkerEntity} Returns an object with the orders.
40
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
39
+ * @returns {Promise<IOrdersByMarkerEntity | IError>} Returns an object with the orders.
40
+ * @throws {IError} When isShell=false and an error occurs during the fetch
41
41
  * @description This method requires user authorization.
42
42
  * @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}.
43
43
  */
@@ -47,8 +47,8 @@ export default class OrdersApi extends AsyncModules implements IOrdersApi {
47
47
  * @handleName getOrderByMarker
48
48
  * @param {string} marker - Marker of the order object. Example: "order_storage_1".
49
49
  * @param {string} [langCode] - Language code. Default: "en_US".
50
- * @returns {IOrdersEntity} Return object of order information.
51
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
50
+ * @returns {Promise<IOrdersEntity | IError>} Return object of order information.
51
+ * @throws {IError} When isShell=false and an error occurs during the fetch
52
52
  * @description This method requires user authorization.
53
53
  * @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}.
54
54
  */
@@ -59,8 +59,8 @@ export default class OrdersApi extends AsyncModules implements IOrdersApi {
59
59
  * @param {string} marker - The text identifier of the order storage object. Example: "order_storage_1".
60
60
  * @param {number} id - ID of the order object. Example: 12345.
61
61
  * @param {string} [langCode] - Language code. Default: "en_US".
62
- * @returns {IOrderByMarkerEntity} Returns an object with the order.
63
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
62
+ * @returns {Promise<IOrderByMarkerEntity | IError>} Returns an object with the order.
63
+ * @throws {IError} When isShell=false and an error occurs during the fetch
64
64
  * @description This method requires user authorization.
65
65
  * @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}.
66
66
  */
@@ -87,8 +87,8 @@ export default class OrdersApi extends AsyncModules implements IOrdersApi {
87
87
  ]
88
88
  }
89
89
  * @param {string} [langCode] - Language code. Default: "en_US".
90
- * @returns {IBaseOrdersEntity} Returns an object with the created order.
91
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
90
+ * @returns {Promise<IBaseOrdersEntity | IError>} Returns an object with the created order.
91
+ * @throws {IError} When isShell=false and an error occurs during the fetch
92
92
  * @description This method requires user authorization.
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
  */
@@ -117,8 +117,8 @@ export default class OrdersApi extends AsyncModules implements IOrdersApi {
117
117
  "currency": "USD"
118
118
  }
119
119
  * @param {string} [langCode] - Language code. Default: "en_US".
120
- * @returns {IBaseOrdersEntity} Returns an object with the updated order.
121
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
120
+ * @returns {Promise<IBaseOrdersEntity | IError>} Returns an object with the updated order.
121
+ * @throws {IError} When isShell=false and an error occurs during the fetch
122
122
  * @description This method requires user authorization.
123
123
  * @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}.
124
124
  */
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const asyncModules_1 = __importDefault(require("../base/asyncModules"));
7
+ const ordersSchemas_1 = require("./ordersSchemas");
7
8
  /**
8
9
  * Controllers for working with orders.
9
10
  * @handle /api/content/orders-storage
@@ -26,8 +27,8 @@ class OrdersApi extends asyncModules_1.default {
26
27
  * @param {string} [langCode] - Language code. Default: "en_US".
27
28
  * @param {number} [offset] - Optional parameter for pagination. Default: 0.
28
29
  * @param {number} [limit] - Optional parameter for pagination. Default: 30.
29
- * @returns {IOrdersEntity[]} Returns an array of order storage objects.
30
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
30
+ * @returns {Promise<IOrdersEntity[] | IError>} Returns an array of order storage objects.
31
+ * @throws {IError} When isShell=false and an error occurs during the fetch
31
32
  * @description This method requires user authorization.
32
33
  * @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}.
33
34
  */
@@ -42,22 +43,24 @@ class OrdersApi extends asyncModules_1.default {
42
43
  * @param {string} [langCode] - Language code. Default: "en_US".
43
44
  * @param {number} [offset] - Offset parameter. Default: 0.
44
45
  * @param {number} [limit] - Limit parameter. Default: 30.
45
- * @returns {IOrdersByMarkerEntity} Returns an object with the orders.
46
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
46
+ * @returns {Promise<IOrdersByMarkerEntity | IError>} Returns an object with the orders.
47
+ * @throws {IError} When isShell=false and an error occurs during the fetch
47
48
  * @description This method requires user authorization.
48
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}.
49
50
  */
50
51
  async getAllOrdersByMarker(marker, langCode = this.state.lang, offset = 0, limit = 30) {
51
52
  const result = await this._fetchGet(`/marker/${marker}/orders?langCode=${langCode}&limit=${limit}&offset=${offset}`);
52
- return this._normalizeData(result);
53
+ // Validate response if validation is enabled
54
+ const validated = this._validateResponse(result, ordersSchemas_1.OrdersResponseSchema);
55
+ return this._normalizeData(validated);
53
56
  }
54
57
  /**
55
58
  * Retrieve one order storage object by marker.
56
59
  * @handleName getOrderByMarker
57
60
  * @param {string} marker - Marker of the order object. Example: "order_storage_1".
58
61
  * @param {string} [langCode] - Language code. Default: "en_US".
59
- * @returns {IOrdersEntity} Return object of order information.
60
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
62
+ * @returns {Promise<IOrdersEntity | IError>} Return object of order information.
63
+ * @throws {IError} When isShell=false and an error occurs during the fetch
61
64
  * @description This method requires user authorization.
62
65
  * @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}.
63
66
  */
@@ -71,14 +74,16 @@ class OrdersApi extends asyncModules_1.default {
71
74
  * @param {string} marker - The text identifier of the order storage object. Example: "order_storage_1".
72
75
  * @param {number} id - ID of the order object. Example: 12345.
73
76
  * @param {string} [langCode] - Language code. Default: "en_US".
74
- * @returns {IOrderByMarkerEntity} Returns an object with the order.
75
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
77
+ * @returns {Promise<IOrderByMarkerEntity | IError>} Returns an object with the order.
78
+ * @throws {IError} When isShell=false and an error occurs during the fetch
76
79
  * @description This method requires user authorization.
77
80
  * @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}.
78
81
  */
79
82
  async getOrderByMarkerAndId(marker, id, langCode = this.state.lang) {
80
83
  const result = await this._fetchGet(`/marker/${marker}/orders/${id}?langCode=${langCode}`);
81
- return this._normalizeData(result);
84
+ // Validate response if validation is enabled
85
+ const validated = this._validateResponse(result, ordersSchemas_1.OrderEntitySchema);
86
+ return this._normalizeData(validated);
82
87
  }
83
88
  /**
84
89
  * Creation of an order in the order storage.
@@ -102,8 +107,8 @@ class OrdersApi extends asyncModules_1.default {
102
107
  ]
103
108
  }
104
109
  * @param {string} [langCode] - Language code. Default: "en_US".
105
- * @returns {IBaseOrdersEntity} Returns an object with the created order.
106
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
110
+ * @returns {Promise<IBaseOrdersEntity | IError>} Returns an object with the created order.
111
+ * @throws {IError} When isShell=false and an error occurs during the fetch
107
112
  * @description This method requires user authorization.
108
113
  * @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}.
109
114
  */
@@ -115,7 +120,9 @@ class OrdersApi extends asyncModules_1.default {
115
120
  : [body.formData];
116
121
  body.formData = formData;
117
122
  const result = await this._fetchPost(`/marker/${marker}/orders`, body);
118
- return this._normalizeData(result);
123
+ // Validate response if validation is enabled
124
+ const validated = this._validateResponse(result, ordersSchemas_1.CreateOrderResponseSchema);
125
+ return this._normalizeData(validated);
119
126
  }
120
127
  /**
121
128
  * Changing an order in the orders storage
@@ -141,8 +148,8 @@ class OrdersApi extends asyncModules_1.default {
141
148
  "currency": "USD"
142
149
  }
143
150
  * @param {string} [langCode] - Language code. Default: "en_US".
144
- * @returns {IBaseOrdersEntity} Returns an object with the updated order.
145
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
151
+ * @returns {Promise<IBaseOrdersEntity | IError>} Returns an object with the updated order.
152
+ * @throws {IError} When isShell=false and an error occurs during the fetch
146
153
  * @description This method requires user authorization.
147
154
  * @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}.
148
155
  */
@@ -154,7 +161,9 @@ class OrdersApi extends asyncModules_1.default {
154
161
  : [body.formData];
155
162
  body.formData = formData;
156
163
  const result = await this._fetchPut(`/marker/${marker}/orders/${id}?langCode=${langCode}`, body);
157
- return this._normalizeData(result);
164
+ // Validate response if validation is enabled
165
+ const validated = this._validateResponse(result, ordersSchemas_1.UpdateOrderResponseSchema);
166
+ return this._normalizeData(validated);
158
167
  }
159
168
  }
160
169
  exports.default = OrdersApi;
@@ -86,7 +86,7 @@ interface IOrdersApi {
86
86
  * @description This method requires user authorization.
87
87
  * @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}.
88
88
  */
89
- createOrder(marker: string, body: IOrderData, langCode: string): Promise<IBaseOrdersEntity | IError>;
89
+ createOrder(marker: string, body: IOrderData, langCode?: string): Promise<IBaseOrdersEntity | IError>;
90
90
  /**
91
91
  * Changing an order in the orders storage
92
92
  * @handleName updateOrderByMarkerAndId
@@ -404,7 +404,8 @@ interface IOrderData {
404
404
  "quantity": 2
405
405
  }
406
406
  ]
407
- * @property {boolean} isCompleted - Indicates that the order has been completed. Example: true.
407
+ * @property {string | null} paymentUrl - Payment link. Example: "https://example.com/pay/123".
408
+ * @property {boolean | null} isCompleted - Indicates that the order has been completed. Example: true.
408
409
  * @description Represents an order storage object created by the user.
409
410
  */
410
411
  interface IOrderByMarkerEntity {
@@ -419,8 +420,8 @@ interface IOrderByMarkerEntity {
419
420
  currency: string;
420
421
  paymentAccountIdentifier?: string;
421
422
  paymentAccountLocalizeInfos?: Record<string, any>;
422
- paymentUrl: null | string;
423
+ paymentUrl: string | null;
423
424
  products: IOrderProducts[];
424
- isCompleted: null | boolean;
425
+ isCompleted: boolean | null;
425
426
  }
426
427
  export type { IBaseOrdersEntity, IBaseOrdersEntityResponse, IOrderByMarkerEntity, IOrderData, IOrderProductData, IOrderProducts, IOrdersApi, IOrdersByMarkerEntity, IOrdersEntity, IOrdersFormData, IPaymentAccountIdentifiers, IPicture, };
@@ -0,0 +1,158 @@
1
+ /**
2
+ * Validation schemas for Orders module
3
+ * @description Zod schemas for validating orders-related API responses
4
+ */
5
+ import { z } from 'zod';
6
+ /**
7
+ * Order item schema
8
+ * @description Order item schema for validating orders-related API responses
9
+ */
10
+ export declare const OrderItemSchema: z.ZodObject<{
11
+ id: z.ZodNumber;
12
+ productId: z.ZodNumber;
13
+ quantity: z.ZodNumber;
14
+ price: z.ZodNumber;
15
+ total: z.ZodNumber;
16
+ attributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
17
+ }, z.core.$strip>;
18
+ /**
19
+ * Order entity schema
20
+ * @description Order entity schema for validating orders-related API responses
21
+ */
22
+ export declare const OrderEntitySchema: z.ZodObject<{
23
+ id: z.ZodNumber;
24
+ identifier: z.ZodOptional<z.ZodString>;
25
+ statusMarker: z.ZodOptional<z.ZodString>;
26
+ statusIdentifier: z.ZodOptional<z.ZodString>;
27
+ userId: z.ZodOptional<z.ZodNumber>;
28
+ userIdentifier: z.ZodOptional<z.ZodString>;
29
+ total: z.ZodOptional<z.ZodNumber>;
30
+ totalSum: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
31
+ items: z.ZodOptional<z.ZodArray<z.ZodObject<{
32
+ id: z.ZodNumber;
33
+ productId: z.ZodNumber;
34
+ quantity: z.ZodNumber;
35
+ price: z.ZodNumber;
36
+ total: z.ZodNumber;
37
+ attributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
38
+ }, z.core.$strip>>>;
39
+ products: z.ZodOptional<z.ZodArray<z.ZodAny>>;
40
+ formData: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodAny>, z.ZodRecord<z.ZodString, z.ZodAny>]>>;
41
+ createdAt: z.ZodOptional<z.ZodString>;
42
+ createdDate: z.ZodOptional<z.ZodString>;
43
+ updatedAt: z.ZodOptional<z.ZodString>;
44
+ storageId: z.ZodOptional<z.ZodNumber>;
45
+ formIdentifier: z.ZodOptional<z.ZodString>;
46
+ attributeSetIdentifier: z.ZodOptional<z.ZodString>;
47
+ currency: z.ZodOptional<z.ZodString>;
48
+ paymentAccountIdentifier: z.ZodOptional<z.ZodString>;
49
+ paymentAccountLocalizeInfos: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
50
+ paymentUrl: z.ZodNullable<z.ZodOptional<z.ZodString>>;
51
+ isCompleted: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
52
+ }, z.core.$strip>;
53
+ /**
54
+ * Orders list response schema
55
+ * @returns Orders list response schema
56
+ */
57
+ export declare const OrdersResponseSchema: z.ZodObject<{
58
+ items: z.ZodArray<z.ZodObject<{
59
+ id: z.ZodNumber;
60
+ identifier: z.ZodOptional<z.ZodString>;
61
+ statusMarker: z.ZodOptional<z.ZodString>;
62
+ statusIdentifier: z.ZodOptional<z.ZodString>;
63
+ userId: z.ZodOptional<z.ZodNumber>;
64
+ userIdentifier: z.ZodOptional<z.ZodString>;
65
+ total: z.ZodOptional<z.ZodNumber>;
66
+ totalSum: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
67
+ items: z.ZodOptional<z.ZodArray<z.ZodObject<{
68
+ id: z.ZodNumber;
69
+ productId: z.ZodNumber;
70
+ quantity: z.ZodNumber;
71
+ price: z.ZodNumber;
72
+ total: z.ZodNumber;
73
+ attributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
74
+ }, z.core.$strip>>>;
75
+ products: z.ZodOptional<z.ZodArray<z.ZodAny>>;
76
+ formData: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodAny>, z.ZodRecord<z.ZodString, z.ZodAny>]>>;
77
+ createdAt: z.ZodOptional<z.ZodString>;
78
+ createdDate: z.ZodOptional<z.ZodString>;
79
+ updatedAt: z.ZodOptional<z.ZodString>;
80
+ storageId: z.ZodOptional<z.ZodNumber>;
81
+ formIdentifier: z.ZodOptional<z.ZodString>;
82
+ attributeSetIdentifier: z.ZodOptional<z.ZodString>;
83
+ currency: z.ZodOptional<z.ZodString>;
84
+ paymentAccountIdentifier: z.ZodOptional<z.ZodString>;
85
+ paymentAccountLocalizeInfos: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
86
+ paymentUrl: z.ZodNullable<z.ZodOptional<z.ZodString>>;
87
+ isCompleted: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
88
+ }, z.core.$strip>>;
89
+ total: z.ZodNumber;
90
+ }, z.core.$strip>;
91
+ /**
92
+ * Order storage schema
93
+ * @returns Order storage validation schema
94
+ */
95
+ export declare const OrderStorageSchema: z.ZodObject<{
96
+ id: z.ZodNumber;
97
+ marker: z.ZodString;
98
+ name: z.ZodString;
99
+ isActive: z.ZodBoolean;
100
+ position: z.ZodOptional<z.ZodNumber>;
101
+ statuses: z.ZodOptional<z.ZodArray<z.ZodObject<{
102
+ id: z.ZodNumber;
103
+ marker: z.ZodString;
104
+ name: z.ZodString;
105
+ position: z.ZodOptional<z.ZodNumber>;
106
+ }, z.core.$strip>>>;
107
+ }, z.core.$strip>;
108
+ /**
109
+ * Orders storage list response schema
110
+ * @returns Orders storage list response schema
111
+ */
112
+ export declare const OrdersStorageResponseSchema: z.ZodArray<z.ZodObject<{
113
+ id: z.ZodNumber;
114
+ marker: z.ZodString;
115
+ name: z.ZodString;
116
+ isActive: z.ZodBoolean;
117
+ position: z.ZodOptional<z.ZodNumber>;
118
+ statuses: z.ZodOptional<z.ZodArray<z.ZodObject<{
119
+ id: z.ZodNumber;
120
+ marker: z.ZodString;
121
+ name: z.ZodString;
122
+ position: z.ZodOptional<z.ZodNumber>;
123
+ }, z.core.$strip>>>;
124
+ }, z.core.$strip>>;
125
+ /**
126
+ * Create order response schema
127
+ * API returns a simplified order object after creation
128
+ * @returns Create order response schema
129
+ */
130
+ export declare const CreateOrderResponseSchema: z.ZodObject<{
131
+ id: z.ZodNumber;
132
+ identifier: z.ZodOptional<z.ZodString>;
133
+ statusMarker: z.ZodOptional<z.ZodString>;
134
+ total: z.ZodOptional<z.ZodNumber>;
135
+ totalSum: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
136
+ createdAt: z.ZodOptional<z.ZodString>;
137
+ createdDate: z.ZodOptional<z.ZodString>;
138
+ formIdentifier: z.ZodOptional<z.ZodString>;
139
+ paymentAccountIdentifier: z.ZodOptional<z.ZodString>;
140
+ formData: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodAny>, z.ZodRecord<z.ZodString, z.ZodAny>]>>;
141
+ products: z.ZodOptional<z.ZodArray<z.ZodAny>>;
142
+ currency: z.ZodOptional<z.ZodString>;
143
+ }, z.core.$strip>;
144
+ /**
145
+ * Update order response schema
146
+ * API returns the full order object after update
147
+ */
148
+ export declare const UpdateOrderResponseSchema: z.ZodObject<{
149
+ id: z.ZodNumber;
150
+ formIdentifier: z.ZodOptional<z.ZodString>;
151
+ paymentAccountIdentifier: z.ZodOptional<z.ZodString>;
152
+ formData: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodAny>, z.ZodRecord<z.ZodString, z.ZodAny>]>>;
153
+ products: z.ZodOptional<z.ZodArray<z.ZodAny>>;
154
+ currency: z.ZodOptional<z.ZodString>;
155
+ totalSum: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
156
+ success: z.ZodOptional<z.ZodBoolean>;
157
+ message: z.ZodOptional<z.ZodString>;
158
+ }, z.core.$strip>;