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
package/README.md CHANGED
@@ -155,6 +155,12 @@ const api = defineOneEntry('your-url', {
155
155
  })
156
156
  ```
157
157
 
158
+ ## Optional Features
159
+
160
+ ### API Response Validation
161
+
162
+ OneEntry SDK supports optional validation of API responses using Zod. This feature is disabled by default and can be enabled for development or critical operations.
163
+
158
164
  ### Errors
159
165
 
160
166
  If you want to escape errors inside the sc, leave the "errors" property by default.
@@ -174,9 +180,15 @@ const api = defineOneEntry('your-url', {
174
180
  errors: {
175
181
  isShell: false,
176
182
  customErrors: {
177
- 400: (error) => console.error(error.message),
178
- 404: (error) => console.error(error.message),
179
- 500: (error) => console.error(error.message),
183
+ 400: (error) => console.error('Bad Request:', error.message),
184
+ 401: (error) => console.error('Unauthorized:', error.message),
185
+ 403: (error) => console.error('Forbidden:', error.message),
186
+ 404: (error) => console.error('Not Found:', error.message),
187
+ 429: (error) => console.error('Rate Limit Exceeded:', error.message),
188
+ 500: (error) => console.error('Server Error:', error.message),
189
+ 502: (error) => console.error('Bad Gateway:', error.message),
190
+ 503: (error) => console.error('Service Unavailable:', error.message),
191
+ 504: (error) => console.error('Gateway Timeout:', error.message),
180
192
  },
181
193
  },
182
194
  })
package/configure.js CHANGED
@@ -1,3 +1,23 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * OneEntry SDK Configuration Tool
5
+ *
6
+ * Interactive CLI tool for initial SDK setup. Prompts the user for:
7
+ * - Project URL (must include https://)
8
+ * - Authentication token
9
+ *
10
+ * Generates an example.ts file with a TypeScript interface template
11
+ * containing the provided configuration values.
12
+ *
13
+ * Usage:
14
+ * npx oneentry
15
+ * or
16
+ * oneentry (if installed globally)
17
+ *
18
+ * @see {@link https://github.com/OneEntry/oneentry-sdk} for more information
19
+ */
20
+
1
21
  /* eslint-disable no-undef */
2
22
  /* eslint-disable @typescript-eslint/no-require-imports */
3
23
 
@@ -19,9 +39,13 @@ rl.question('Enter project name with https://... : ', (name) => {
19
39
  });
20
40
 
21
41
  /**
22
- * Create interface
23
- * @param {*} name name
24
- * @param {*} token token
42
+ * Creates an example TypeScript interface file with SDK configuration
43
+ *
44
+ * Generates an example.ts file containing a BuildInterface type and
45
+ * IAttributesList interface with the provided project name and token.
46
+ *
47
+ * @param {string} name - Project URL with https:// (e.g., "https://example.oneentry.cloud")
48
+ * @param {string} token - Authentication token for API access
25
49
  */
26
50
  function createInterface(name, token) {
27
51
  const filePath = 'example.ts';
@@ -43,8 +43,8 @@ export default class AdminsApi extends AsyncModules implements IAdmins {
43
43
  * @param {string} [langCode] - Language code. Default: "en_US".
44
44
  * @param {number} [offset] - Parameter for pagination. Default: 0.
45
45
  * @param {number} [limit] - Parameter for pagination. Default: 30.
46
- * @returns {IAdminEntity[]} Returns an array of admin objects.
47
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
46
+ * @returns {Promise<IAdminEntity[] | IError>} Returns an array of admin objects.
47
+ * @throws {IError} When isShell=false and an error occurs during the fetch
48
48
  */
49
49
  getAdminsInfo(body?: AttributeType[], langCode?: string, offset?: number, limit?: number): Promise<IAdminEntity[] | IError>;
50
50
  }
@@ -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 adminsSchemas_1 = require("./adminsSchemas");
7
8
  /**
8
9
  * Controllers for working with users - admins.
9
10
  * @class AdminsApi
@@ -46,8 +47,8 @@ class AdminsApi extends asyncModules_1.default {
46
47
  * @param {string} [langCode] - Language code. Default: "en_US".
47
48
  * @param {number} [offset] - Parameter for pagination. Default: 0.
48
49
  * @param {number} [limit] - Parameter for pagination. Default: 30.
49
- * @returns {IAdminEntity[]} Returns an array of admin objects.
50
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
50
+ * @returns {Promise<IAdminEntity[] | IError>} Returns an array of admin objects.
51
+ * @throws {IError} When isShell=false and an error occurs during the fetch
51
52
  */
52
53
  async getAdminsInfo(body = [], langCode = this.state.lang, offset = 0, limit = 30) {
53
54
  const query = {
@@ -56,7 +57,9 @@ class AdminsApi extends asyncModules_1.default {
56
57
  limit,
57
58
  };
58
59
  const response = await this._fetchPost(`?` + this._queryParamsToString(query), body);
59
- return this._normalizeData(response, langCode);
60
+ // Validate response if validation is enabled
61
+ const validated = this._validateResponse(response, adminsSchemas_1.AdminsResponseSchema);
62
+ return this._normalizeData(validated, langCode);
60
63
  }
61
64
  }
62
65
  exports.default = AdminsApi;
@@ -31,7 +31,7 @@ interface IAdmins {
31
31
  * @returns {IAdminEntity[]} Returns an array of admin objects.
32
32
  * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
33
33
  */
34
- getAdminsInfo(body: AttributeType[], langCode: string, offset: number, limit: number): Promise<IAdminEntity[] | IError>;
34
+ getAdminsInfo(body?: AttributeType[], langCode?: string, offset?: number, limit?: number): Promise<IAdminEntity[] | IError>;
35
35
  }
36
36
  /**
37
37
  * Interface representing a Position entity.
@@ -55,7 +55,7 @@ interface IPosition {
55
55
  /**
56
56
  * Interface representing an Admin Entity.
57
57
  * @interface IAdminEntity
58
- * @property {number | null} id - The identifier of the object. Example: 1764.
58
+ * @property {number} id - The identifier of the object. Example: 1764.
59
59
  * @property {number | null} attributeSetId - The identifier of the attribute set being used. Example: 120.
60
60
  * @property {string} identifier - The textual identifier for the record field. Example: "admin1".
61
61
  * @property {string | null} attributeSetIdentifier - The identifier of the attribute set. Example: "admins".
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Validation schemas for Admins module
3
+ * @description Zod schemas for validating admins-related API responses
4
+ */
5
+ import { z } from 'zod';
6
+ /**
7
+ * Admin entity schema
8
+ * Includes all fields returned by the API
9
+ */
10
+ export declare const AdminEntitySchema: z.ZodObject<{
11
+ id: z.ZodNumber;
12
+ attributeSetId: z.ZodNullable<z.ZodNumber>;
13
+ identifier: z.ZodString;
14
+ attributeSetIdentifier: z.ZodNullable<z.ZodString>;
15
+ position: z.ZodNullable<z.ZodNumber>;
16
+ isSync: z.ZodBoolean;
17
+ attributeValues: z.ZodRecord<z.ZodString, z.ZodAny>;
18
+ }, z.core.$catchall<z.ZodAny>>;
19
+ /**
20
+ * Admins response schema (array of admin entities)
21
+ */
22
+ export declare const AdminsResponseSchema: z.ZodArray<z.ZodObject<{
23
+ id: z.ZodNumber;
24
+ attributeSetId: z.ZodNullable<z.ZodNumber>;
25
+ identifier: z.ZodString;
26
+ attributeSetIdentifier: z.ZodNullable<z.ZodString>;
27
+ position: z.ZodNullable<z.ZodNumber>;
28
+ isSync: z.ZodBoolean;
29
+ attributeValues: z.ZodRecord<z.ZodString, z.ZodAny>;
30
+ }, z.core.$catchall<z.ZodAny>>>;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AdminsResponseSchema = exports.AdminEntitySchema = void 0;
4
+ /**
5
+ * Validation schemas for Admins module
6
+ * @description Zod schemas for validating admins-related API responses
7
+ */
8
+ const zod_1 = require("zod");
9
+ /**
10
+ * Admin entity schema
11
+ * Includes all fields returned by the API
12
+ */
13
+ exports.AdminEntitySchema = zod_1.z
14
+ .object({
15
+ id: zod_1.z.number(),
16
+ attributeSetId: zod_1.z.number().nullable(),
17
+ identifier: zod_1.z.string(),
18
+ attributeSetIdentifier: zod_1.z.string().nullable(),
19
+ position: zod_1.z.number().nullable(),
20
+ isSync: zod_1.z.boolean(),
21
+ attributeValues: zod_1.z.record(zod_1.z.string(), zod_1.z.any()),
22
+ })
23
+ .catchall(zod_1.z.any()); // Allow additional dynamic properties
24
+ /**
25
+ * Admins response schema (array of admin entities)
26
+ */
27
+ exports.AdminsResponseSchema = zod_1.z.array(exports.AdminEntitySchema);
@@ -28,8 +28,8 @@ export default class AttributesSetsApi extends AsyncModules implements IAttribut
28
28
  * @param {number} [limit] - parameter limiting the selection of records. Default: 30.
29
29
  * @param {number} [typeId] - identifier of the attribute set type. Default: null.
30
30
  * @param {string} [sortBy] - identifier of the attribute set type. Default: "id".
31
- * @returns {IAttributesSetsResponse} Returns object with array of IAttributeSetsEntity and total items count.
32
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
31
+ * @returns {Promise<IAttributesSetsResponse | IError>} Returns object with array of IAttributeSetsEntity and total items count.
32
+ * @throws {IError} When isShell=false and an error occurs during the fetch
33
33
  */
34
34
  getAttributes(langCode?: string, offset?: number, limit?: number, typeId?: any, sortBy?: string): Promise<IAttributesSetsResponse | IError>;
35
35
  /**
@@ -37,8 +37,8 @@ export default class AttributesSetsApi extends AsyncModules implements IAttribut
37
37
  * @handleName getAttributesByMarker
38
38
  * @param {string} marker - Attribute marker. Example: "productAttributes".
39
39
  * @param {string} [langCode] - Language code. Default: "en_US".
40
- * @returns {IAttributeSetsEntity[]} Returns an array of Attributes objects.
41
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
40
+ * @returns {Promise<IAttributeSetsEntity[] | IError>} Returns an array of Attributes objects.
41
+ * @throws {IError} When isShell=false and an error occurs during the fetch
42
42
  */
43
43
  getAttributesByMarker(marker: string, langCode?: string): Promise<IAttributeSetsEntity[] | IError>;
44
44
  /**
@@ -47,8 +47,8 @@ export default class AttributesSetsApi extends AsyncModules implements IAttribut
47
47
  * @param {string} setMarker - Text identifier (marker) of the attribute set. Example: "productAttributes".
48
48
  * @param {string} attributeMarker - Text identifier (marker) of the attribute in the set. Example: "color".
49
49
  * @param {string} [langCode] - Language code. Default: "en_US".
50
- * @returns {IAttributesSetsEntity} Returns a single attribute object from the attribute set.
51
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
50
+ * @returns {Promise<IAttributesSetsEntity | IError>} Returns a single attribute object from the attribute set.
51
+ * @throws {IError} When isShell=false and an error occurs during the fetch
52
52
  */
53
53
  getSingleAttributeByMarkerSet(setMarker: string, attributeMarker: string, langCode?: string): Promise<IAttributesSetsEntity | IError>;
54
54
  /**
@@ -56,8 +56,8 @@ export default class AttributesSetsApi extends AsyncModules implements IAttribut
56
56
  * @handleName getAttributeSetByMarker
57
57
  * @param {string} marker - marker of the attribute set object. Example: "productAttributes".
58
58
  * @param {string} [langCode] - Language code. Default: "en_US".
59
- * @returns {IAttributeSetsEntity} Returns one object of the attribute set.
60
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
59
+ * @returns {Promise<IAttributeSetsEntity | IError>} Returns one object of the attribute set.
60
+ * @throws {IError} When isShell=false and an error occurs during the fetch
61
61
  */
62
62
  getAttributeSetByMarker(marker: string, langCode?: string): Promise<IAttributeSetsEntity | IError>;
63
63
  }
@@ -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 attributeSetsSchemas_1 = require("./attributeSetsSchemas");
7
8
  /**
8
9
  * Controllers for working with attributes - AttributesSetsApi.
9
10
  * @class AttributesSetsApi
@@ -31,8 +32,8 @@ class AttributesSetsApi extends asyncModules_1.default {
31
32
  * @param {number} [limit] - parameter limiting the selection of records. Default: 30.
32
33
  * @param {number} [typeId] - identifier of the attribute set type. Default: null.
33
34
  * @param {string} [sortBy] - identifier of the attribute set type. Default: "id".
34
- * @returns {IAttributesSetsResponse} Returns object with array of IAttributeSetsEntity and total items count.
35
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
35
+ * @returns {Promise<IAttributesSetsResponse | IError>} Returns object with array of IAttributeSetsEntity and total items count.
36
+ * @throws {IError} When isShell=false and an error occurs during the fetch
36
37
  */
37
38
  async getAttributes(langCode = this.state.lang, offset = 0, limit = 30,
38
39
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -46,19 +47,23 @@ class AttributesSetsApi extends asyncModules_1.default {
46
47
  sortBy,
47
48
  };
48
49
  const result = await this._fetchGet(`?` + this._queryParamsToString(query));
49
- return this._dataPostProcess(result, langCode);
50
+ // Validate response if validation is enabled
51
+ const validated = this._validateResponse(result, attributeSetsSchemas_1.AttributeSetsResponseSchema);
52
+ return this._dataPostProcess(validated, langCode);
50
53
  }
51
54
  /**
52
55
  * Getting all attributes with data from the attribute set.
53
56
  * @handleName getAttributesByMarker
54
57
  * @param {string} marker - Attribute marker. Example: "productAttributes".
55
58
  * @param {string} [langCode] - Language code. Default: "en_US".
56
- * @returns {IAttributeSetsEntity[]} Returns an array of Attributes objects.
57
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
59
+ * @returns {Promise<IAttributeSetsEntity[] | IError>} Returns an array of Attributes objects.
60
+ * @throws {IError} When isShell=false and an error occurs during the fetch
58
61
  */
59
62
  async getAttributesByMarker(marker, langCode = this.state.lang) {
60
63
  const result = await this._fetchGet(`/${marker}/attributes?langCode=${langCode}`);
61
- return this._dataPostProcess(result, langCode);
64
+ // Validate response if validation is enabled
65
+ const validated = this._validateResponse(result, attributeSetsSchemas_1.AttributesArrayResponseSchema);
66
+ return this._dataPostProcess(validated, langCode);
62
67
  }
63
68
  /**
64
69
  * Get a single attribute with data from the attribute sets.
@@ -66,24 +71,28 @@ class AttributesSetsApi extends asyncModules_1.default {
66
71
  * @param {string} setMarker - Text identifier (marker) of the attribute set. Example: "productAttributes".
67
72
  * @param {string} attributeMarker - Text identifier (marker) of the attribute in the set. Example: "color".
68
73
  * @param {string} [langCode] - Language code. Default: "en_US".
69
- * @returns {IAttributesSetsEntity} Returns a single attribute object from the attribute set.
70
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
74
+ * @returns {Promise<IAttributesSetsEntity | IError>} Returns a single attribute object from the attribute set.
75
+ * @throws {IError} When isShell=false and an error occurs during the fetch
71
76
  */
72
77
  async getSingleAttributeByMarkerSet(setMarker, attributeMarker, langCode = this.state.lang) {
73
78
  const result = await this._fetchGet(`/${setMarker}/attributes/${attributeMarker}?langCode=${langCode}`);
74
- return this._dataPostProcess(result, langCode);
79
+ // Validate response if validation is enabled
80
+ const validated = this._validateResponse(result, attributeSetsSchemas_1.AttributeEntitySchema);
81
+ return this._dataPostProcess(validated, langCode);
75
82
  }
76
83
  /**
77
84
  * Getting a single object from a set of attributes by marker.
78
85
  * @handleName getAttributeSetByMarker
79
86
  * @param {string} marker - marker of the attribute set object. Example: "productAttributes".
80
87
  * @param {string} [langCode] - Language code. Default: "en_US".
81
- * @returns {IAttributeSetsEntity} Returns one object of the attribute set.
82
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
88
+ * @returns {Promise<IAttributeSetsEntity | IError>} Returns one object of the attribute set.
89
+ * @throws {IError} When isShell=false and an error occurs during the fetch
83
90
  */
84
91
  async getAttributeSetByMarker(marker, langCode = this.state.lang) {
85
92
  const result = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
86
- return this._dataPostProcess(result, langCode);
93
+ // Validate response if validation is enabled
94
+ const validated = this._validateResponse(result, attributeSetsSchemas_1.AttributeSetEntitySchema);
95
+ return this._dataPostProcess(validated, langCode);
87
96
  }
88
97
  }
89
98
  exports.default = AttributesSetsApi;
@@ -60,6 +60,7 @@ type AttributeType = 'string' | 'text' | 'textWithHeader' | 'integer' | 'real' |
60
60
  * @interface IAttributesSetsEntity
61
61
  * @property {AttributeType} type - Attribute type. Example: "string", "text", "integer", "etc".
62
62
  * @property {any} [value] - Value of the attribute, which can be of any type.
63
+ * @property {any} initialValue - Initial value of the attribute.
63
64
  * @property {string} marker - Textual identifier of the attribute (marker). Example: "color", "size", "etc".
64
65
  * @property {number} position - Position number for sorting. Example: 1.
65
66
  * @property {IListTitle[] | Record<string, any>} [listTitles] - Array of values (with extended data) for list and radioButton attributes.
@@ -96,7 +97,6 @@ type AttributeType = 'string' | 'text' | 'textWithHeader' | 'integer' | 'real' |
96
97
  "title": "My attribute"
97
98
  }
98
99
  * @property {Record<string, any>} [additionalFields] - Additional fields for the attribute (optional).
99
- * @property {Record<string, any>} [settings] - Additional attribute settings (optional).
100
100
  * @description This interface defines the structure of an attribute set entity, including its type, marker, position, validators, localization information, list titles, additional fields, and settings.
101
101
  */
102
102
  interface IAttributesSetsEntity {
@@ -109,13 +109,13 @@ interface IAttributesSetsEntity {
109
109
  validators?: Record<string, any>;
110
110
  localizeInfos: ILocalizeInfo;
111
111
  additionalFields?: Record<string, any>;
112
- settings?: Record<string, any>;
113
112
  }
114
113
  /**
115
114
  * Represents an attribute set entity.
116
115
  * @interface IAttributeSetsEntity
117
116
  * @property {number} id - The unique identifier of the attribute set entity. Example: 123.
118
- * @property {string} updatedDate - The date when the attribute set was last updated, represented as a string. Example: "2023-10-01T12:00:00Z".
117
+ * @property {string} createdDate - The date when the attribute set was created. Example: "2023-10-01T12:00:00Z".
118
+ * @property {string} updatedDate - The date when the attribute set was last updated. Example: "2023-10-01T12:00:00Z".
119
119
  * @property {number} version - The version number of the attribute set, used for tracking changes or updates. Example: 1.
120
120
  * @property {string} identifier - A string that uniquely identifies the attribute set. Example: "attributeSet1".
121
121
  * @property {number} typeId - The numerical identifier representing the type of the attribute set. Example: 1.
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Validation schemas for AttributeSets module
3
+ * @description Zod schemas for validating attribute sets-related API responses
4
+ */
5
+ import { z } from 'zod';
6
+ /**
7
+ * List title schema for list and radioButton attributes
8
+ */
9
+ export declare const ListTitleSchema: z.ZodObject<{
10
+ title: z.ZodString;
11
+ value: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
12
+ position: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>;
13
+ extended: z.ZodObject<{
14
+ value: z.ZodNullable<z.ZodString>;
15
+ type: z.ZodNullable<z.ZodString>;
16
+ }, z.core.$strip>;
17
+ }, z.core.$strip>;
18
+ /**
19
+ * Attribute entity schema (single attribute from a set)
20
+ */
21
+ export declare const AttributeEntitySchema: z.ZodObject<{
22
+ type: z.ZodString;
23
+ value: z.ZodOptional<z.ZodAny>;
24
+ initialValue: z.ZodAny;
25
+ marker: z.ZodString;
26
+ position: z.ZodNumber;
27
+ listTitles: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodAny>, z.ZodRecord<z.ZodString, z.ZodAny>]>>;
28
+ validators: z.ZodOptional<z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodArray<z.ZodAny>]>>;
29
+ localizeInfos: z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodArray<z.ZodAny>]>;
30
+ additionalFields: z.ZodOptional<z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodArray<z.ZodAny>]>>;
31
+ settings: z.ZodOptional<z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodArray<z.ZodAny>]>>;
32
+ }, z.core.$strip>;
33
+ /**
34
+ * Attribute set entity schema (attribute set object)
35
+ */
36
+ export declare const AttributeSetEntitySchema: z.ZodObject<{
37
+ id: z.ZodNumber;
38
+ createdDate: z.ZodString;
39
+ updatedDate: z.ZodString;
40
+ version: z.ZodNumber;
41
+ identifier: z.ZodString;
42
+ typeId: z.ZodNumber;
43
+ title: z.ZodString;
44
+ schema: z.ZodObject<{}, z.core.$loose>;
45
+ isVisible: z.ZodBoolean;
46
+ properties: z.ZodObject<{}, z.core.$loose>;
47
+ type: z.ZodObject<{
48
+ id: z.ZodNumber;
49
+ type: z.ZodString;
50
+ }, z.core.$strip>;
51
+ position: z.ZodNumber;
52
+ }, z.core.$strip>;
53
+ /**
54
+ * Attributes response schema (for getAttributes method)
55
+ */
56
+ export declare const AttributeSetsResponseSchema: z.ZodObject<{
57
+ total: z.ZodNumber;
58
+ items: z.ZodArray<z.ZodObject<{
59
+ id: z.ZodNumber;
60
+ createdDate: z.ZodString;
61
+ updatedDate: z.ZodString;
62
+ version: z.ZodNumber;
63
+ identifier: z.ZodString;
64
+ typeId: z.ZodNumber;
65
+ title: z.ZodString;
66
+ schema: z.ZodObject<{}, z.core.$loose>;
67
+ isVisible: z.ZodBoolean;
68
+ properties: z.ZodObject<{}, z.core.$loose>;
69
+ type: z.ZodObject<{
70
+ id: z.ZodNumber;
71
+ type: z.ZodString;
72
+ }, z.core.$strip>;
73
+ position: z.ZodNumber;
74
+ }, z.core.$strip>>;
75
+ }, z.core.$strip>;
76
+ /**
77
+ * Attributes array response schema (for getAttributesByMarker method)
78
+ */
79
+ export declare const AttributesArrayResponseSchema: z.ZodArray<z.ZodObject<{
80
+ type: z.ZodString;
81
+ value: z.ZodOptional<z.ZodAny>;
82
+ initialValue: z.ZodAny;
83
+ marker: z.ZodString;
84
+ position: z.ZodNumber;
85
+ listTitles: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodAny>, z.ZodRecord<z.ZodString, z.ZodAny>]>>;
86
+ validators: z.ZodOptional<z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodArray<z.ZodAny>]>>;
87
+ localizeInfos: z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodArray<z.ZodAny>]>;
88
+ additionalFields: z.ZodOptional<z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodArray<z.ZodAny>]>>;
89
+ settings: z.ZodOptional<z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodArray<z.ZodAny>]>>;
90
+ }, z.core.$strip>>;
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AttributesArrayResponseSchema = exports.AttributeSetsResponseSchema = exports.AttributeSetEntitySchema = exports.AttributeEntitySchema = exports.ListTitleSchema = void 0;
4
+ /**
5
+ * Validation schemas for AttributeSets module
6
+ * @description Zod schemas for validating attribute sets-related API responses
7
+ */
8
+ const zod_1 = require("zod");
9
+ /**
10
+ * List title schema for list and radioButton attributes
11
+ */
12
+ exports.ListTitleSchema = zod_1.z.object({
13
+ title: zod_1.z.string(),
14
+ value: zod_1.z.union([zod_1.z.number(), zod_1.z.string()]),
15
+ position: zod_1.z.union([zod_1.z.string(), zod_1.z.number(), zod_1.z.null()]),
16
+ extended: zod_1.z.object({
17
+ value: zod_1.z.string().nullable(),
18
+ type: zod_1.z.string().nullable(),
19
+ }),
20
+ });
21
+ /**
22
+ * Attribute entity schema (single attribute from a set)
23
+ */
24
+ exports.AttributeEntitySchema = zod_1.z.object({
25
+ type: zod_1.z.string(),
26
+ value: zod_1.z.any().optional(),
27
+ initialValue: zod_1.z.any(),
28
+ marker: zod_1.z.string(),
29
+ position: zod_1.z.number(),
30
+ listTitles: zod_1.z
31
+ .union([zod_1.z.array(zod_1.z.any()), zod_1.z.record(zod_1.z.string(), zod_1.z.any())])
32
+ .optional(),
33
+ validators: zod_1.z
34
+ .union([zod_1.z.record(zod_1.z.string(), zod_1.z.any()), zod_1.z.array(zod_1.z.any())])
35
+ .optional(),
36
+ localizeInfos: zod_1.z.union([zod_1.z.record(zod_1.z.string(), zod_1.z.any()), zod_1.z.array(zod_1.z.any())]),
37
+ additionalFields: zod_1.z
38
+ .union([zod_1.z.record(zod_1.z.string(), zod_1.z.any()), zod_1.z.array(zod_1.z.any())])
39
+ .optional(),
40
+ settings: zod_1.z
41
+ .union([zod_1.z.record(zod_1.z.string(), zod_1.z.any()), zod_1.z.array(zod_1.z.any())])
42
+ .optional(),
43
+ });
44
+ /**
45
+ * Attribute set entity schema (attribute set object)
46
+ */
47
+ exports.AttributeSetEntitySchema = zod_1.z.object({
48
+ id: zod_1.z.number(),
49
+ createdDate: zod_1.z.string(),
50
+ updatedDate: zod_1.z.string(),
51
+ version: zod_1.z.number(),
52
+ identifier: zod_1.z.string(),
53
+ typeId: zod_1.z.number(),
54
+ title: zod_1.z.string(),
55
+ schema: zod_1.z.object({}).passthrough(),
56
+ isVisible: zod_1.z.boolean(),
57
+ properties: zod_1.z.object({}).passthrough(),
58
+ type: zod_1.z.object({
59
+ id: zod_1.z.number(),
60
+ type: zod_1.z.string(),
61
+ }),
62
+ position: zod_1.z.number(),
63
+ });
64
+ /**
65
+ * Attributes response schema (for getAttributes method)
66
+ */
67
+ exports.AttributeSetsResponseSchema = zod_1.z.object({
68
+ total: zod_1.z.number(),
69
+ items: zod_1.z.array(exports.AttributeSetEntitySchema),
70
+ });
71
+ /**
72
+ * Attributes array response schema (for getAttributesByMarker method)
73
+ */
74
+ exports.AttributesArrayResponseSchema = zod_1.z.array(exports.AttributeEntitySchema);