oneentry 1.0.136 → 1.0.137

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 (83) hide show
  1. package/README.md +15 -3
  2. package/configure.js +27 -3
  3. package/dist/admins/adminsApi.js +4 -1
  4. package/dist/admins/adminsInterfaces.d.ts +1 -1
  5. package/dist/admins/adminsSchemas.d.ts +30 -0
  6. package/dist/admins/adminsSchemas.js +27 -0
  7. package/dist/attribute-sets/attributeSetsApi.js +13 -4
  8. package/dist/attribute-sets/attributeSetsSchemas.d.ts +90 -0
  9. package/dist/attribute-sets/attributeSetsSchemas.js +74 -0
  10. package/dist/auth-provider/authProviderApi.d.ts +11 -8
  11. package/dist/auth-provider/authProviderApi.js +25 -15
  12. package/dist/auth-provider/authProviderSchemas.d.ts +137 -0
  13. package/dist/auth-provider/authProviderSchemas.js +85 -0
  14. package/dist/auth-provider/authProvidersInterfaces.d.ts +6 -6
  15. package/dist/base/asyncModules.d.ts +25 -15
  16. package/dist/base/asyncModules.js +91 -24
  17. package/dist/base/stateModule.d.ts +7 -0
  18. package/dist/base/stateModule.js +26 -11
  19. package/dist/base/syncModules.d.ts +12 -0
  20. package/dist/base/syncModules.js +45 -94
  21. package/dist/base/utils.d.ts +41 -2
  22. package/dist/base/validation.d.ts +118 -0
  23. package/dist/base/validation.js +132 -0
  24. package/dist/blocks/blocksApi.js +16 -11
  25. package/dist/blocks/blocksInterfaces.d.ts +1 -1
  26. package/dist/blocks/blocksSchemas.d.ts +187 -0
  27. package/dist/blocks/blocksSchemas.js +43 -0
  28. package/dist/config.d.ts +10 -2
  29. package/dist/config.js +20 -4
  30. package/dist/file-uploading/fileUploadingApi.js +4 -1
  31. package/dist/file-uploading/fileUploadingSchemas.d.ts +22 -0
  32. package/dist/file-uploading/fileUploadingSchemas.js +21 -0
  33. package/dist/forms/formsApi.js +7 -2
  34. package/dist/forms/formsInterfaces.d.ts +20 -8
  35. package/dist/forms/formsSchemas.d.ts +65 -0
  36. package/dist/forms/formsSchemas.js +36 -0
  37. package/dist/forms-data/formsDataApi.js +10 -3
  38. package/dist/forms-data/formsDataInterfaces.d.ts +2 -2
  39. package/dist/forms-data/formsDataSchemas.d.ts +107 -0
  40. package/dist/forms-data/formsDataSchemas.js +83 -0
  41. package/dist/general-types/generalTypesApi.js +4 -1
  42. package/dist/general-types/generalTypesSchemas.d.ts +50 -0
  43. package/dist/general-types/generalTypesSchemas.js +35 -0
  44. package/dist/integration-collections/integrationCollectionsApi.js +25 -9
  45. package/dist/integration-collections/integrationCollectionsSchemas.d.ts +84 -0
  46. package/dist/integration-collections/integrationCollectionsSchemas.js +63 -0
  47. package/dist/locales/localesApi.js +4 -1
  48. package/dist/locales/localesSchemas.d.ts +32 -0
  49. package/dist/locales/localesSchemas.js +26 -0
  50. package/dist/menus/menusApi.js +4 -1
  51. package/dist/menus/menusSchemas.d.ts +16 -0
  52. package/dist/menus/menusSchemas.js +28 -0
  53. package/dist/orders/ordersApi.js +13 -4
  54. package/dist/orders/ordersInterfaces.d.ts +3 -3
  55. package/dist/orders/ordersSchemas.d.ts +158 -0
  56. package/dist/orders/ordersSchemas.js +120 -0
  57. package/dist/pages/pagesApi.d.ts +2 -1
  58. package/dist/pages/pagesApi.js +87 -34
  59. package/dist/pages/pagesInterfaces.d.ts +6 -5
  60. package/dist/pages/pagesSchemas.d.ts +85 -0
  61. package/dist/pages/pagesSchemas.js +46 -0
  62. package/dist/payments/paymentsApi.js +13 -4
  63. package/dist/payments/paymentsInterfaces.d.ts +3 -3
  64. package/dist/payments/paymentsSchemas.d.ts +121 -0
  65. package/dist/payments/paymentsSchemas.js +75 -0
  66. package/dist/product-statuses/productStatusesApi.js +13 -3
  67. package/dist/product-statuses/productStatusesSchemas.d.ts +34 -0
  68. package/dist/product-statuses/productStatusesSchemas.js +30 -0
  69. package/dist/products/productsApi.js +19 -6
  70. package/dist/products/productsInterfaces.d.ts +4 -4
  71. package/dist/products/productsSchemas.d.ts +212 -0
  72. package/dist/products/productsSchemas.js +85 -0
  73. package/dist/templates/templatesApi.js +11 -4
  74. package/dist/templates/templatesSchemas.d.ts +48 -0
  75. package/dist/templates/templatesSchemas.js +31 -0
  76. package/dist/templates-preview/templatesPreviewApi.js +7 -2
  77. package/dist/templates-preview/templatesPreviewSchemas.d.ts +83 -0
  78. package/dist/templates-preview/templatesPreviewSchemas.js +48 -0
  79. package/dist/users/usersApi.js +8 -5
  80. package/dist/users/usersInterfaces.d.ts +2 -1
  81. package/dist/users/usersSchemas.d.ts +38 -0
  82. package/dist/users/usersSchemas.js +28 -0
  83. package/package.json +5 -4
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';
@@ -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
@@ -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.
@@ -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);
@@ -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
@@ -46,7 +47,9 @@ 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.
@@ -58,7 +61,9 @@ class AttributesSetsApi extends asyncModules_1.default {
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.
@@ -71,7 +76,9 @@ class AttributesSetsApi extends asyncModules_1.default {
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.
@@ -83,7 +90,9 @@ class AttributesSetsApi extends asyncModules_1.default {
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;
@@ -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);
@@ -1,7 +1,7 @@
1
1
  import AsyncModules from '../base/asyncModules';
2
2
  import type StateModule from '../base/stateModule';
3
3
  import type { IError } from '../base/utils';
4
- import type { IActiveSession, IAuthEntity, IAuthPostBody, IAuthProvider, IAuthProvidersEntity, IOAuthSignUpData, ISignUpData, ISignUpEntity } from './authProvidersInterfaces';
4
+ import type { IActiveSession, IAuthEntity, IAuthPostBody, IAuthProvider, IAuthProvidersEntity, IOauthData, ISignUpData, ISignUpEntity } from './authProvidersInterfaces';
5
5
  /**
6
6
  * Controllers for working with auth services.
7
7
  * @handle /api/content/users-auth-providers
@@ -75,6 +75,9 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
75
75
  "phonePush": ["+99999999999"],
76
76
  "phoneSMS": "+99999999999"
77
77
  }
78
+ * @param {string} body.notificationData.email - The email address to which the notification will be sent.
79
+ * @param {Array<string>} [body.notificationData.phonePush] - An array of phone numbers for push notifications. Optional.
80
+ * @param {string} [body.notificationData.phoneSMS] - The phone number for SMS notifications. Optional.
78
81
  * @param {string} [langCode] - Language code. Default: "en_US".
79
82
  * @returns {ISignUpEntity} Returns a user object.
80
83
  * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
@@ -124,12 +127,12 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
124
127
  {
125
128
  "authData": [
126
129
  {
127
- "marker": "login",
128
- "value": "example@oneentry.cloud"
130
+ "marker": "login",
131
+ "value": "example@oneentry.cloud"
129
132
  },
130
133
  {
131
- "marker": "password",
132
- "value": "12345"
134
+ "marker": "password",
135
+ "value": "12345"
133
136
  }
134
137
  ]
135
138
  }
@@ -226,9 +229,9 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
226
229
  getActiveSessionsByMarker(marker: string): Promise<IActiveSession[] | IError>;
227
230
  /**
228
231
  * User registration (authorization) via OAUTH.
229
- * @handleName oauthSignUp
232
+ * @handleName oauth
230
233
  * @param {string} marker - The text identifier of the authorization provider. Example: "email".
231
- * @param {IOAuthSignUpData} body - Object contains OAuth information for registration.
234
+ * @param {IOauthData} body - Object contains OAuth information for registration.
232
235
  * @example
233
236
  {
234
237
  "client_id": "34346983-luuct343473qdkqidjopdfp3eb3k4thp.apps.googleusercontent.com",
@@ -242,5 +245,5 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
242
245
  * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
243
246
  * @description User registration (authorization) via OAUTH.
244
247
  */
245
- oauthSignUp(marker: string, body: IOAuthSignUpData, langCode?: string): Promise<IAuthEntity | IError>;
248
+ oauth(marker: string, body: IOauthData, langCode?: string): Promise<IAuthEntity | IError>;
246
249
  }
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  /* eslint-disable jsdoc/no-undefined-types */
7
7
  const asyncModules_1 = __importDefault(require("../base/asyncModules"));
8
+ const authProviderSchemas_1 = require("./authProviderSchemas");
8
9
  /**
9
10
  * Controllers for working with auth services.
10
11
  * @handle /api/content/users-auth-providers
@@ -79,6 +80,9 @@ class AuthProviderApi extends asyncModules_1.default {
79
80
  "phonePush": ["+99999999999"],
80
81
  "phoneSMS": "+99999999999"
81
82
  }
83
+ * @param {string} body.notificationData.email - The email address to which the notification will be sent.
84
+ * @param {Array<string>} [body.notificationData.phonePush] - An array of phone numbers for push notifications. Optional.
85
+ * @param {string} [body.notificationData.phoneSMS] - The phone number for SMS notifications. Optional.
82
86
  * @param {string} [langCode] - Language code. Default: "en_US".
83
87
  * @returns {ISignUpEntity} Returns a user object.
84
88
  * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
@@ -87,7 +91,9 @@ class AuthProviderApi extends asyncModules_1.default {
87
91
  async signUp(marker, body, langCode = this.state.lang) {
88
92
  body['langCode'] = langCode;
89
93
  const result = await this._fetchPost(`/marker/${marker}/users/sign-up`, this._normalizePostBody(body, langCode));
90
- return this._normalizeData(result);
94
+ // Validate response if validation is enabled
95
+ const validated = this._validateResponse(result, authProviderSchemas_1.SignUpResponseSchema);
96
+ return this._normalizeData(validated);
91
97
  }
92
98
  /**
93
99
  * Getting a user activation code. The code is returned via the appropriate user notification method.
@@ -154,12 +160,12 @@ class AuthProviderApi extends asyncModules_1.default {
154
160
  {
155
161
  "authData": [
156
162
  {
157
- "marker": "login",
158
- "value": "example@oneentry.cloud"
163
+ "marker": "login",
164
+ "value": "example@oneentry.cloud"
159
165
  },
160
166
  {
161
- "marker": "password",
162
- "value": "12345"
167
+ "marker": "password",
168
+ "value": "12345"
163
169
  }
164
170
  ]
165
171
  }
@@ -179,13 +185,15 @@ class AuthProviderApi extends asyncModules_1.default {
179
185
  */
180
186
  async auth(marker, body) {
181
187
  const result = await this._fetchPost(`/marker/${marker}/users/auth`, body);
182
- this.state.accessToken = result.accessToken;
183
- this.state.refreshToken = result.refreshToken;
184
- // console.log(result);
185
- if (this.state.saveFunction) {
186
- this.state.saveFunction(result.refreshToken);
188
+ // Validate response if validation is enabled
189
+ const validated = this._validateResponse(result, authProviderSchemas_1.AuthResponseSchema);
190
+ this.state.accessToken = validated.accessToken;
191
+ this.state.refreshToken = validated.refreshToken;
192
+ // console.log(validated);
193
+ if (this.state.saveFunction && validated.refreshToken) {
194
+ this.state.saveFunction(validated.refreshToken);
187
195
  }
188
- return result;
196
+ return validated;
189
197
  }
190
198
  /**
191
199
  * Refresh token.
@@ -288,7 +296,9 @@ class AuthProviderApi extends asyncModules_1.default {
288
296
  */
289
297
  async getAuthProviders(langCode = this.state.lang, offset = 0, limit = 30) {
290
298
  const result = await this._fetchGet(`?langCode=${langCode}&offset=${offset}&limit=${limit}`);
291
- return this._normalizeData(result);
299
+ // Validate response if validation is enabled
300
+ const validated = this._validateResponse(result, authProviderSchemas_1.AuthProvidersResponseSchema);
301
+ return this._normalizeData(validated);
292
302
  }
293
303
  /**
294
304
  * Get one auth provider object by marker.
@@ -317,9 +327,9 @@ class AuthProviderApi extends asyncModules_1.default {
317
327
  }
318
328
  /**
319
329
  * User registration (authorization) via OAUTH.
320
- * @handleName oauthSignUp
330
+ * @handleName oauth
321
331
  * @param {string} marker - The text identifier of the authorization provider. Example: "email".
322
- * @param {IOAuthSignUpData} body - Object contains OAuth information for registration.
332
+ * @param {IOauthData} body - Object contains OAuth information for registration.
323
333
  * @example
324
334
  {
325
335
  "client_id": "34346983-luuct343473qdkqidjopdfp3eb3k4thp.apps.googleusercontent.com",
@@ -333,7 +343,7 @@ class AuthProviderApi extends asyncModules_1.default {
333
343
  * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
334
344
  * @description User registration (authorization) via OAUTH.
335
345
  */
336
- async oauthSignUp(marker, body, langCode = this.state.lang) {
346
+ async oauth(marker, body, langCode = this.state.lang) {
337
347
  const result = await this._fetchPost(`/marker/${marker}/oauth`, this._normalizePostBody(body, langCode));
338
348
  return result;
339
349
  }
@@ -0,0 +1,137 @@
1
+ /**
2
+ * Validation schemas for Auth Provider module
3
+ * @description Zod schemas for validating auth-related API responses
4
+ */
5
+ import { z } from 'zod';
6
+ /**
7
+ * Sign up response schema
8
+ * @description Schema for validating sign up response
9
+ */
10
+ export declare const SignUpResponseSchema: z.ZodObject<{
11
+ id: z.ZodNumber;
12
+ identifier: z.ZodOptional<z.ZodString>;
13
+ email: z.ZodOptional<z.ZodString>;
14
+ phoneMask: z.ZodOptional<z.ZodString>;
15
+ phoneCode: z.ZodOptional<z.ZodString>;
16
+ phoneNumber: z.ZodOptional<z.ZodString>;
17
+ statusMarker: z.ZodOptional<z.ZodString>;
18
+ }, z.core.$strip>;
19
+ /**
20
+ * Auth response schema (login/refresh)
21
+ * @description Schema for validating auth response
22
+ */
23
+ export declare const AuthResponseSchema: z.ZodObject<{
24
+ accessToken: z.ZodString;
25
+ refreshToken: z.ZodString;
26
+ userIdentifier: z.ZodOptional<z.ZodString>;
27
+ authProviderIdentifier: z.ZodOptional<z.ZodString>;
28
+ user: z.ZodOptional<z.ZodObject<{
29
+ id: z.ZodNumber;
30
+ identifier: z.ZodOptional<z.ZodString>;
31
+ email: z.ZodOptional<z.ZodString>;
32
+ phoneMask: z.ZodOptional<z.ZodString>;
33
+ phoneCode: z.ZodOptional<z.ZodString>;
34
+ phoneNumber: z.ZodOptional<z.ZodString>;
35
+ statusMarker: z.ZodOptional<z.ZodString>;
36
+ formData: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodAny>, z.ZodRecord<z.ZodString, z.ZodAny>]>>;
37
+ total: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
38
+ authProviderIdentifier: z.ZodOptional<z.ZodString>;
39
+ formIdentifier: z.ZodOptional<z.ZodString>;
40
+ groups: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
41
+ state: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
42
+ moduleFormConfigs: z.ZodOptional<z.ZodArray<z.ZodAny>>;
43
+ }, z.core.$strip>>;
44
+ }, z.core.$strip>;
45
+ /**
46
+ * User response schema
47
+ * @description Schema for validating user response
48
+ */
49
+ export declare const UserResponseSchema: z.ZodObject<{
50
+ id: z.ZodNumber;
51
+ identifier: z.ZodOptional<z.ZodString>;
52
+ email: z.ZodOptional<z.ZodString>;
53
+ phoneMask: z.ZodOptional<z.ZodString>;
54
+ phoneCode: z.ZodOptional<z.ZodString>;
55
+ phoneNumber: z.ZodOptional<z.ZodString>;
56
+ statusMarker: z.ZodOptional<z.ZodString>;
57
+ formData: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodAny>, z.ZodRecord<z.ZodString, z.ZodAny>]>>;
58
+ total: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
59
+ authProviderIdentifier: z.ZodOptional<z.ZodString>;
60
+ formIdentifier: z.ZodOptional<z.ZodString>;
61
+ groups: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
62
+ state: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
63
+ moduleFormConfigs: z.ZodOptional<z.ZodArray<z.ZodAny>>;
64
+ }, z.core.$strip>;
65
+ /**
66
+ * Auth provider entity schema
67
+ * @description Schema for validating auth provider entity
68
+ * Includes all fields returned by the API
69
+ */
70
+ export declare const AuthProviderEntitySchema: z.ZodObject<{
71
+ id: z.ZodNumber;
72
+ identifier: z.ZodString;
73
+ type: z.ZodOptional<z.ZodString>;
74
+ formIdentifier: z.ZodOptional<z.ZodString>;
75
+ userGroupIdentifier: z.ZodOptional<z.ZodString>;
76
+ isActive: z.ZodBoolean;
77
+ isCheckCode: z.ZodOptional<z.ZodBoolean>;
78
+ version: z.ZodOptional<z.ZodNumber>;
79
+ localizeInfos: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
80
+ config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
81
+ marker: z.ZodOptional<z.ZodString>;
82
+ name: z.ZodOptional<z.ZodString>;
83
+ position: z.ZodOptional<z.ZodNumber>;
84
+ }, z.core.$strip>;
85
+ /**
86
+ * Auth providers list response schema
87
+ * @description Schema for validating auth providers list response
88
+ */
89
+ export declare const AuthProvidersResponseSchema: z.ZodArray<z.ZodObject<{
90
+ id: z.ZodNumber;
91
+ identifier: z.ZodString;
92
+ type: z.ZodOptional<z.ZodString>;
93
+ formIdentifier: z.ZodOptional<z.ZodString>;
94
+ userGroupIdentifier: z.ZodOptional<z.ZodString>;
95
+ isActive: z.ZodBoolean;
96
+ isCheckCode: z.ZodOptional<z.ZodBoolean>;
97
+ version: z.ZodOptional<z.ZodNumber>;
98
+ localizeInfos: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
99
+ config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
100
+ marker: z.ZodOptional<z.ZodString>;
101
+ name: z.ZodOptional<z.ZodString>;
102
+ position: z.ZodOptional<z.ZodNumber>;
103
+ }, z.core.$strip>>;
104
+ /**
105
+ * Generate code response schema
106
+ * @description Schema for validating generate code response
107
+ */
108
+ export declare const GenerateCodeResponseSchema: z.ZodObject<{
109
+ success: z.ZodBoolean;
110
+ message: z.ZodOptional<z.ZodString>;
111
+ }, z.core.$strip>;
112
+ /**
113
+ * Logout response schema
114
+ * @description Schema for validating logout response
115
+ */
116
+ export declare const LogoutResponseSchema: z.ZodObject<{
117
+ success: z.ZodBoolean;
118
+ message: z.ZodOptional<z.ZodString>;
119
+ }, z.core.$strip>;
120
+ /**
121
+ * Active sessions response schema
122
+ * @description Schema for validating active sessions response
123
+ */
124
+ export declare const ActiveSessionSchema: z.ZodObject<{
125
+ id: z.ZodString;
126
+ deviceInfo: z.ZodOptional<z.ZodString>;
127
+ ipAddress: z.ZodOptional<z.ZodString>;
128
+ lastActive: z.ZodOptional<z.ZodString>;
129
+ createdAt: z.ZodString;
130
+ }, z.core.$strip>;
131
+ export declare const ActiveSessionsResponseSchema: z.ZodArray<z.ZodObject<{
132
+ id: z.ZodString;
133
+ deviceInfo: z.ZodOptional<z.ZodString>;
134
+ ipAddress: z.ZodOptional<z.ZodString>;
135
+ lastActive: z.ZodOptional<z.ZodString>;
136
+ createdAt: z.ZodString;
137
+ }, z.core.$strip>>;