oneentry 1.0.140 → 1.0.141

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 (149) hide show
  1. package/dist/admins/adminsApi.d.ts +50 -0
  2. package/dist/admins/adminsApi.js +65 -0
  3. package/dist/admins/adminsInterfaces.d.ts +99 -0
  4. package/dist/admins/adminsInterfaces.js +2 -0
  5. package/dist/admins/adminsSchemas.d.ts +30 -0
  6. package/dist/admins/adminsSchemas.js +27 -0
  7. package/dist/attribute-sets/attributeSetsApi.d.ts +63 -0
  8. package/dist/attribute-sets/attributeSetsApi.js +98 -0
  9. package/dist/attribute-sets/attributeSetsInterfaces.d.ts +187 -0
  10. package/dist/attribute-sets/attributeSetsInterfaces.js +2 -0
  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 +249 -0
  14. package/dist/auth-provider/authProviderApi.js +351 -0
  15. package/dist/auth-provider/authProviderSchemas.d.ts +131 -0
  16. package/dist/auth-provider/authProviderSchemas.js +82 -0
  17. package/dist/auth-provider/authProvidersInterfaces.d.ts +425 -0
  18. package/dist/auth-provider/authProvidersInterfaces.js +2 -0
  19. package/dist/base/asyncModules.d.ts +80 -0
  20. package/dist/base/asyncModules.js +440 -0
  21. package/dist/base/result.d.ts +39 -0
  22. package/dist/base/result.js +154 -0
  23. package/dist/base/stateModule.d.ts +41 -0
  24. package/dist/base/stateModule.js +128 -0
  25. package/dist/base/syncModules.d.ts +149 -0
  26. package/dist/base/syncModules.js +549 -0
  27. package/dist/base/utils.d.ts +197 -0
  28. package/dist/base/utils.js +2 -0
  29. package/dist/base/validation.d.ts +118 -0
  30. package/dist/base/validation.js +132 -0
  31. package/dist/blocks/blocksApi.d.ts +76 -0
  32. package/dist/blocks/blocksApi.js +188 -0
  33. package/dist/blocks/blocksInterfaces.d.ts +173 -0
  34. package/dist/blocks/blocksInterfaces.js +2 -0
  35. package/dist/blocks/blocksSchemas.d.ts +187 -0
  36. package/dist/blocks/blocksSchemas.js +43 -0
  37. package/dist/discounts/discountsApi.d.ts +56 -0
  38. package/dist/discounts/discountsApi.js +82 -0
  39. package/dist/discounts/discountsInterfaces.d.ts +145 -0
  40. package/dist/discounts/discountsInterfaces.js +2 -0
  41. package/dist/events/eventsApi.d.ts +60 -0
  42. package/dist/events/eventsApi.js +97 -0
  43. package/dist/events/eventsInterfaces.d.ts +87 -0
  44. package/dist/events/eventsInterfaces.js +2 -0
  45. package/dist/file-uploading/fileUploadingApi.d.ts +88 -0
  46. package/dist/file-uploading/fileUploadingApi.js +132 -0
  47. package/dist/file-uploading/fileUploadingInterfaces.d.ts +117 -0
  48. package/dist/file-uploading/fileUploadingInterfaces.js +2 -0
  49. package/dist/file-uploading/fileUploadingSchemas.d.ts +22 -0
  50. package/dist/file-uploading/fileUploadingSchemas.js +21 -0
  51. package/dist/forms/formsApi.d.ts +42 -0
  52. package/dist/forms/formsApi.js +57 -0
  53. package/dist/forms/formsInterfaces.d.ts +132 -0
  54. package/dist/forms/formsInterfaces.js +2 -0
  55. package/dist/forms/formsSchemas.d.ts +50 -0
  56. package/dist/forms/formsSchemas.js +31 -0
  57. package/dist/forms-data/formsDataApi.d.ts +106 -0
  58. package/dist/forms-data/formsDataApi.js +189 -0
  59. package/dist/forms-data/formsDataInterfaces.d.ts +525 -0
  60. package/dist/forms-data/formsDataInterfaces.js +2 -0
  61. package/dist/forms-data/formsDataSchemas.d.ts +115 -0
  62. package/dist/forms-data/formsDataSchemas.js +86 -0
  63. package/dist/general-types/generalTypesApi.d.ts +28 -0
  64. package/dist/general-types/generalTypesApi.js +38 -0
  65. package/dist/general-types/generalTypesInterfaces.d.ts +30 -0
  66. package/dist/general-types/generalTypesInterfaces.js +2 -0
  67. package/dist/general-types/generalTypesSchemas.d.ts +50 -0
  68. package/dist/general-types/generalTypesSchemas.js +35 -0
  69. package/dist/index.d.ts +100 -0
  70. package/dist/index.js +103 -0
  71. package/dist/integration-collections/integrationCollectionsApi.d.ts +173 -0
  72. package/dist/integration-collections/integrationCollectionsApi.js +220 -0
  73. package/dist/integration-collections/integrationCollectionsInterfaces.d.ts +313 -0
  74. package/dist/integration-collections/integrationCollectionsInterfaces.js +2 -0
  75. package/dist/integration-collections/integrationCollectionsSchemas.d.ts +80 -0
  76. package/dist/integration-collections/integrationCollectionsSchemas.js +61 -0
  77. package/dist/locales/localesApi.d.ts +27 -0
  78. package/dist/locales/localesApi.js +37 -0
  79. package/dist/locales/localesInterfaces.d.ts +41 -0
  80. package/dist/locales/localesInterfaces.js +2 -0
  81. package/dist/locales/localesSchemas.d.ts +32 -0
  82. package/dist/locales/localesSchemas.js +26 -0
  83. package/dist/menus/menusApi.d.ts +29 -0
  84. package/dist/menus/menusApi.js +39 -0
  85. package/dist/menus/menusInterfaces.d.ts +88 -0
  86. package/dist/menus/menusInterfaces.js +4 -0
  87. package/dist/menus/menusSchemas.d.ts +16 -0
  88. package/dist/menus/menusSchemas.js +28 -0
  89. package/dist/orders/ordersApi.d.ts +149 -0
  90. package/dist/orders/ordersApi.js +203 -0
  91. package/dist/orders/ordersInterfaces.d.ts +527 -0
  92. package/dist/orders/ordersInterfaces.js +2 -0
  93. package/dist/orders/ordersSchemas.d.ts +120 -0
  94. package/dist/orders/ordersSchemas.js +101 -0
  95. package/dist/pages/pagesApi.d.ts +151 -0
  96. package/dist/pages/pagesApi.js +390 -0
  97. package/dist/pages/pagesInterfaces.d.ts +292 -0
  98. package/dist/pages/pagesInterfaces.js +2 -0
  99. package/dist/pages/pagesSchemas.d.ts +85 -0
  100. package/dist/pages/pagesSchemas.js +46 -0
  101. package/dist/payments/paymentsApi.d.ts +82 -0
  102. package/dist/payments/paymentsApi.js +121 -0
  103. package/dist/payments/paymentsInterfaces.d.ts +206 -0
  104. package/dist/payments/paymentsInterfaces.js +2 -0
  105. package/dist/payments/paymentsSchemas.d.ts +100 -0
  106. package/dist/payments/paymentsSchemas.js +65 -0
  107. package/dist/product-statuses/productStatusesApi.d.ts +47 -0
  108. package/dist/product-statuses/productStatusesApi.js +70 -0
  109. package/dist/product-statuses/productStatusesInterfaces.d.ts +66 -0
  110. package/dist/product-statuses/productStatusesInterfaces.js +2 -0
  111. package/dist/product-statuses/productStatusesSchemas.d.ts +34 -0
  112. package/dist/product-statuses/productStatusesSchemas.js +30 -0
  113. package/dist/products/productsApi.d.ts +365 -0
  114. package/dist/products/productsApi.js +459 -0
  115. package/dist/products/productsInterfaces.d.ts +586 -0
  116. package/dist/products/productsInterfaces.js +2 -0
  117. package/dist/products/productsSchemas.d.ts +192 -0
  118. package/dist/products/productsSchemas.js +96 -0
  119. package/dist/sitemap/sitemapApi.d.ts +35 -0
  120. package/dist/sitemap/sitemapApi.js +45 -0
  121. package/dist/sitemap/sitemapInterfaces.d.ts +40 -0
  122. package/dist/sitemap/sitemapInterfaces.js +2 -0
  123. package/dist/system/systemApi.d.ts +43 -0
  124. package/dist/system/systemApi.js +58 -0
  125. package/dist/system/systemInterfaces.d.ts +31 -0
  126. package/dist/system/systemInterfaces.js +5 -0
  127. package/dist/templates/templatesApi.d.ts +49 -0
  128. package/dist/templates/templatesApi.js +75 -0
  129. package/dist/templates/templatesInterfaces.d.ts +70 -0
  130. package/dist/templates/templatesInterfaces.js +2 -0
  131. package/dist/templates/templatesSchemas.d.ts +48 -0
  132. package/dist/templates/templatesSchemas.js +31 -0
  133. package/dist/templates-preview/templatesPreviewApi.d.ts +38 -0
  134. package/dist/templates-preview/templatesPreviewApi.js +53 -0
  135. package/dist/templates-preview/templatesPreviewInterfaces.d.ts +121 -0
  136. package/dist/templates-preview/templatesPreviewInterfaces.js +2 -0
  137. package/dist/templates-preview/templatesPreviewSchemas.d.ts +83 -0
  138. package/dist/templates-preview/templatesPreviewSchemas.js +48 -0
  139. package/dist/users/usersApi.d.ts +143 -0
  140. package/dist/users/usersApi.js +173 -0
  141. package/dist/users/usersInterfaces.d.ts +235 -0
  142. package/dist/users/usersInterfaces.js +2 -0
  143. package/dist/users/usersSchemas.d.ts +38 -0
  144. package/dist/users/usersSchemas.js +28 -0
  145. package/dist/web-socket/wsApi.d.ts +25 -0
  146. package/dist/web-socket/wsApi.js +45 -0
  147. package/dist/web-socket/wsInterfaces.d.ts +17 -0
  148. package/dist/web-socket/wsInterfaces.js +2 -0
  149. package/package.json +3 -81
@@ -0,0 +1,50 @@
1
+ import AsyncModules from '../base/asyncModules';
2
+ import type StateModule from '../base/stateModule';
3
+ import type { AttributeType, IError } from '../base/utils';
4
+ import type { IAdminEntity, IAdmins } from './adminsInterfaces';
5
+ /**
6
+ * Controllers for working with users - admins.
7
+ * @class AdminsApi
8
+ * @augments AsyncModules
9
+ * @implements {IAdmins}
10
+ * @description This module provides methods for working with users - admins, including retrieving information about all admins.
11
+ */
12
+ export default class AdminsApi extends AsyncModules implements IAdmins {
13
+ protected state: StateModule;
14
+ protected _url: string;
15
+ /**
16
+ * Initializes the AdminsApi with the provided state module.
17
+ * @class
18
+ * @class AdminsApi
19
+ * @param {StateModule} state - The state module containing configuration data.
20
+ * @description Constructor initializes the AdminsApi with a given state.
21
+ */
22
+ constructor(state: StateModule);
23
+ /**
24
+ * Get all admins objects with filters.
25
+ * @handleName getAdminsInfo
26
+ * @param {AttributeType[]} [body] - Array of filter objects with search conditions. Default: [].
27
+ * @example
28
+ [
29
+ {
30
+ "attributeMarker": "num",
31
+ "conditionMarker": "mth",
32
+ "conditionValue": 1
33
+ },
34
+ {
35
+ "attributeMarker": "num",
36
+ "conditionMarker": "lth",
37
+ "conditionValue": 3
38
+ }
39
+ ]
40
+ * @param {string} [body.attributeMarker] - Text identifier (marker) of the attribute in the set. Example: "num".
41
+ * @param {string} [body.conditionMarker] - Text identifier (marker) of the condition in the set. Example: "mth".
42
+ * @param {string} [body.conditionValue] - Value of the condition. Example: 1.
43
+ * @param {string} [langCode] - Language code. Default: "en_US".
44
+ * @param {number} [offset] - Parameter for pagination. Default: 0.
45
+ * @param {number} [limit] - Parameter for pagination. Default: 30.
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
+ */
49
+ getAdminsInfo(body?: AttributeType[], langCode?: string, offset?: number, limit?: number): Promise<IAdminEntity[] | IError>;
50
+ }
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const asyncModules_1 = __importDefault(require("../base/asyncModules"));
7
+ const adminsSchemas_1 = require("./adminsSchemas");
8
+ /**
9
+ * Controllers for working with users - admins.
10
+ * @class AdminsApi
11
+ * @augments AsyncModules
12
+ * @implements {IAdmins}
13
+ * @description This module provides methods for working with users - admins, including retrieving information about all admins.
14
+ */
15
+ class AdminsApi extends asyncModules_1.default {
16
+ /**
17
+ * Initializes the AdminsApi with the provided state module.
18
+ * @class
19
+ * @class AdminsApi
20
+ * @param {StateModule} state - The state module containing configuration data.
21
+ * @description Constructor initializes the AdminsApi with a given state.
22
+ */
23
+ constructor(state) {
24
+ super(state);
25
+ this._url = state.url + '/api/content/admins/all';
26
+ }
27
+ /**
28
+ * Get all admins objects with filters.
29
+ * @handleName getAdminsInfo
30
+ * @param {AttributeType[]} [body] - Array of filter objects with search conditions. Default: [].
31
+ * @example
32
+ [
33
+ {
34
+ "attributeMarker": "num",
35
+ "conditionMarker": "mth",
36
+ "conditionValue": 1
37
+ },
38
+ {
39
+ "attributeMarker": "num",
40
+ "conditionMarker": "lth",
41
+ "conditionValue": 3
42
+ }
43
+ ]
44
+ * @param {string} [body.attributeMarker] - Text identifier (marker) of the attribute in the set. Example: "num".
45
+ * @param {string} [body.conditionMarker] - Text identifier (marker) of the condition in the set. Example: "mth".
46
+ * @param {string} [body.conditionValue] - Value of the condition. Example: 1.
47
+ * @param {string} [langCode] - Language code. Default: "en_US".
48
+ * @param {number} [offset] - Parameter for pagination. Default: 0.
49
+ * @param {number} [limit] - Parameter for pagination. Default: 30.
50
+ * @returns {Promise<IAdminEntity[] | IError>} Returns an array of admin objects.
51
+ * @throws {IError} When isShell=false and an error occurs during the fetch
52
+ */
53
+ async getAdminsInfo(body = [], langCode = this.state.lang, offset = 0, limit = 30) {
54
+ const query = {
55
+ langCode,
56
+ offset,
57
+ limit,
58
+ };
59
+ const response = await this._fetchPost(`?` + this._queryParamsToString(query), body);
60
+ // Validate response if validation is enabled
61
+ const validated = this._validateResponse(response, adminsSchemas_1.AdminsResponseSchema);
62
+ return this._normalizeData(validated, langCode);
63
+ }
64
+ }
65
+ exports.default = AdminsApi;
@@ -0,0 +1,99 @@
1
+ import type { AttributeType, IAttributeValues, IError } from '../base/utils';
2
+ /**
3
+ * @interface IAdmins
4
+ * @property {Function} getAdminsInfo - Method to retrieve all admin user objects.
5
+ * @description This interface defines the contract for any class that implements it
6
+ */
7
+ interface IAdmins {
8
+ /**
9
+ * Get all admins objects with filters.
10
+ * @handleName getAdminsInfo
11
+ * @param {AttributeType[]} [body] - Array of filter objects with search conditions. Default: [].
12
+ * @example
13
+ [
14
+ {
15
+ "attributeMarker": "num",
16
+ "conditionMarker": "mth",
17
+ "conditionValue": 1
18
+ },
19
+ {
20
+ "attributeMarker": "num",
21
+ "conditionMarker": "lth",
22
+ "conditionValue": 3
23
+ }
24
+ ]
25
+ * @param {string} [body.attributeMarker] - Text identifier (marker) of the attribute in the set. Example: "num".
26
+ * @param {string} [body.conditionMarker] - Text identifier (marker) of the condition in the set. Example: "mth".
27
+ * @param {string} [body.conditionValue] - Value of the condition. Example: 1.
28
+ * @param {string} [langCode] - Language code. Default: "en_US".
29
+ * @param {number} [offset] - Parameter for pagination. Default: 0.
30
+ * @param {number} [limit] - Parameter for pagination. Default: 30.
31
+ * @returns {IAdminEntity[]} Returns an array of admin objects.
32
+ * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
33
+ */
34
+ getAdminsInfo(body?: AttributeType[], langCode?: string, offset?: number, limit?: number): Promise<IAdminEntity[] | IError>;
35
+ }
36
+ /**
37
+ * Interface representing a Position entity.
38
+ * @interface IPosition
39
+ * @property {number} id - The unique identifier of the position. Example: 1764.
40
+ * @property {boolean} [isLocked] - Indicates whether the position is locked or not. Example: false.
41
+ * @property {number} objectId - The unique identifier of the object. Example: 120.
42
+ * @property {number} [objectCategoryId] - The unique identifier of the object's category. Example: 5.
43
+ * @property {string} objectType - The type of the object. Example: "admin".
44
+ * @property {number} position - The position of the object. Example: 192.
45
+ * @description This interface outlines the properties associated with a position within a system.
46
+ */
47
+ interface IPosition {
48
+ id: number;
49
+ isLocked?: boolean;
50
+ objectId: number;
51
+ objectCategoryId?: number;
52
+ objectType: string;
53
+ position: number;
54
+ }
55
+ /**
56
+ * Interface representing an Admin Entity.
57
+ * @interface IAdminEntity
58
+ * @property {number} id - The identifier of the object. Example: 1764.
59
+ * @property {number | null} attributeSetId - The identifier of the attribute set being used. Example: 120.
60
+ * @property {string} identifier - The textual identifier for the record field. Example: "admin1".
61
+ * @property {string | null} attributeSetIdentifier - The identifier of the attribute set. Example: "admins".
62
+ * @property {number | null} position - Position number (for sorting). Example: 1.
63
+ * @property {boolean} isSync - Page indexing flag (true or false). Example: true.
64
+ * @property {IAttributeValues} attributeValues - Array of attribute values from the index (presented as a pair of user attribute identifier: attribute value).
65
+ * @example
66
+ [
67
+ {
68
+ "marker": {
69
+ "type": "string",
70
+ "value": "Some value"
71
+ }
72
+ }
73
+ ]
74
+ * @description This interface captures the essential details and additional attributes of an admin entity.
75
+ */
76
+ interface IAdminEntity {
77
+ id: number;
78
+ attributeSetId: number | null;
79
+ identifier: string;
80
+ attributeSetIdentifier: string | null;
81
+ position: number | null;
82
+ isSync: boolean;
83
+ attributeValues: IAttributeValues;
84
+ [key: string]: any;
85
+ }
86
+ /**
87
+ * Interface representing a query for fetching admin data.
88
+ * @interface IAdminQuery
89
+ * @property {string} langCode - Language code. Default: "en_US".
90
+ * @property {number} limit - Parameter for pagination. Default: 30.
91
+ * @property {number} offset - Parameter for pagination. Default: 0.
92
+ * @description This interface defines the parameters required for querying admin data, including optional defaults.
93
+ */
94
+ interface IAdminQuery {
95
+ langCode: string;
96
+ limit: number;
97
+ offset: number;
98
+ }
99
+ export type { IAdminEntity, IAdminQuery, IAdmins, IPosition };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -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);
@@ -0,0 +1,63 @@
1
+ import AsyncModules from '../base/asyncModules';
2
+ import type StateModule from '../base/stateModule';
3
+ import type { IError } from '../base/utils';
4
+ import type { IAttributeSetsEntity, IAttributesSets, IAttributesSetsEntity, IAttributesSetsResponse } from './attributeSetsInterfaces';
5
+ /**
6
+ * Controllers for working with attributes - AttributesSetsApi.
7
+ * @class AttributesSetsApi
8
+ * @augments AsyncModules
9
+ * @implements {IAttributesSets}
10
+ * @description This class provides methods to interact with attribute sets, including fetching attributes, getting attributes by marker, and retrieving single attributes by marker and set.
11
+ */
12
+ export default class AttributesSetsApi extends AsyncModules implements IAttributesSets {
13
+ protected state: StateModule;
14
+ protected _url: string;
15
+ /**
16
+ * Initializes the AttributesSetsApi with the provided state module.
17
+ * @class
18
+ * @class AttributesSetsApi
19
+ * @param {StateModule} state - The state module containing configuration data.
20
+ * @description Constructor initializes the AttributesSetsApi with a given state.
21
+ */
22
+ constructor(state: StateModule);
23
+ /**
24
+ * Getting all attribute sets objects.
25
+ * @handleName getAttributes
26
+ * @param {string} [langCode] - Language code. Default: "en_US".
27
+ * @param {number} [offset] - parameter offset of record selection. Default: 0.
28
+ * @param {number} [limit] - parameter limiting the selection of records. Default: 30.
29
+ * @param {number} [typeId] - identifier of the attribute set type. Default: null.
30
+ * @param {string} [sortBy] - identifier of the attribute set type. Default: "id".
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
+ */
34
+ getAttributes(langCode?: string, offset?: number, limit?: number, typeId?: any, sortBy?: string): Promise<IAttributesSetsResponse | IError>;
35
+ /**
36
+ * Getting all attributes with data from the attribute set.
37
+ * @handleName getAttributesByMarker
38
+ * @param {string} marker - Attribute marker. Example: "productAttributes".
39
+ * @param {string} [langCode] - Language code. Default: "en_US".
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
+ */
43
+ getAttributesByMarker(marker: string, langCode?: string): Promise<IAttributeSetsEntity[] | IError>;
44
+ /**
45
+ * Get a single attribute with data from the attribute sets.
46
+ * @handleName getSingleAttributeByMarkerSet
47
+ * @param {string} setMarker - Text identifier (marker) of the attribute set. Example: "productAttributes".
48
+ * @param {string} attributeMarker - Text identifier (marker) of the attribute in the set. Example: "color".
49
+ * @param {string} [langCode] - Language code. Default: "en_US".
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
+ */
53
+ getSingleAttributeByMarkerSet(setMarker: string, attributeMarker: string, langCode?: string): Promise<IAttributesSetsEntity | IError>;
54
+ /**
55
+ * Getting a single object from a set of attributes by marker.
56
+ * @handleName getAttributeSetByMarker
57
+ * @param {string} marker - marker of the attribute set object. Example: "productAttributes".
58
+ * @param {string} [langCode] - Language code. Default: "en_US".
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
+ */
62
+ getAttributeSetByMarker(marker: string, langCode?: string): Promise<IAttributeSetsEntity | IError>;
63
+ }
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const asyncModules_1 = __importDefault(require("../base/asyncModules"));
7
+ const attributeSetsSchemas_1 = require("./attributeSetsSchemas");
8
+ /**
9
+ * Controllers for working with attributes - AttributesSetsApi.
10
+ * @class AttributesSetsApi
11
+ * @augments AsyncModules
12
+ * @implements {IAttributesSets}
13
+ * @description This class provides methods to interact with attribute sets, including fetching attributes, getting attributes by marker, and retrieving single attributes by marker and set.
14
+ */
15
+ class AttributesSetsApi extends asyncModules_1.default {
16
+ /**
17
+ * Initializes the AttributesSetsApi with the provided state module.
18
+ * @class
19
+ * @class AttributesSetsApi
20
+ * @param {StateModule} state - The state module containing configuration data.
21
+ * @description Constructor initializes the AttributesSetsApi with a given state.
22
+ */
23
+ constructor(state) {
24
+ super(state);
25
+ this._url = state.url + '/api/content/attributes-sets';
26
+ }
27
+ /**
28
+ * Getting all attribute sets objects.
29
+ * @handleName getAttributes
30
+ * @param {string} [langCode] - Language code. Default: "en_US".
31
+ * @param {number} [offset] - parameter offset of record selection. Default: 0.
32
+ * @param {number} [limit] - parameter limiting the selection of records. Default: 30.
33
+ * @param {number} [typeId] - identifier of the attribute set type. Default: null.
34
+ * @param {string} [sortBy] - identifier of the attribute set type. Default: "id".
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
37
+ */
38
+ async getAttributes(langCode = this.state.lang, offset = 0, limit = 30,
39
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
40
+ typeId = null, sortBy = 'id') {
41
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
42
+ const query = {
43
+ langCode,
44
+ offset,
45
+ limit,
46
+ typeId,
47
+ sortBy,
48
+ };
49
+ const result = await this._fetchGet(`?` + this._queryParamsToString(query));
50
+ // Validate response if validation is enabled
51
+ const validated = this._validateResponse(result, attributeSetsSchemas_1.AttributeSetsResponseSchema);
52
+ return this._dataPostProcess(validated, langCode);
53
+ }
54
+ /**
55
+ * Getting all attributes with data from the attribute set.
56
+ * @handleName getAttributesByMarker
57
+ * @param {string} marker - Attribute marker. Example: "productAttributes".
58
+ * @param {string} [langCode] - Language code. Default: "en_US".
59
+ * @returns {Promise<IAttributeSetsEntity[] | IError>} Returns an array of Attributes objects.
60
+ * @throws {IError} When isShell=false and an error occurs during the fetch
61
+ */
62
+ async getAttributesByMarker(marker, langCode = this.state.lang) {
63
+ const result = await this._fetchGet(`/${marker}/attributes?langCode=${langCode}`);
64
+ // Validate response if validation is enabled
65
+ const validated = this._validateResponse(result, attributeSetsSchemas_1.AttributesArrayResponseSchema);
66
+ return this._dataPostProcess(validated, langCode);
67
+ }
68
+ /**
69
+ * Get a single attribute with data from the attribute sets.
70
+ * @handleName getSingleAttributeByMarkerSet
71
+ * @param {string} setMarker - Text identifier (marker) of the attribute set. Example: "productAttributes".
72
+ * @param {string} attributeMarker - Text identifier (marker) of the attribute in the set. Example: "color".
73
+ * @param {string} [langCode] - Language code. Default: "en_US".
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
76
+ */
77
+ async getSingleAttributeByMarkerSet(setMarker, attributeMarker, langCode = this.state.lang) {
78
+ const result = await this._fetchGet(`/${setMarker}/attributes/${attributeMarker}?langCode=${langCode}`);
79
+ // Validate response if validation is enabled
80
+ const validated = this._validateResponse(result, attributeSetsSchemas_1.AttributeEntitySchema);
81
+ return this._dataPostProcess(validated, langCode);
82
+ }
83
+ /**
84
+ * Getting a single object from a set of attributes by marker.
85
+ * @handleName getAttributeSetByMarker
86
+ * @param {string} marker - marker of the attribute set object. Example: "productAttributes".
87
+ * @param {string} [langCode] - Language code. Default: "en_US".
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
90
+ */
91
+ async getAttributeSetByMarker(marker, langCode = this.state.lang) {
92
+ const result = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
93
+ // Validate response if validation is enabled
94
+ const validated = this._validateResponse(result, attributeSetsSchemas_1.AttributeSetEntitySchema);
95
+ return this._dataPostProcess(validated, langCode);
96
+ }
97
+ }
98
+ exports.default = AttributesSetsApi;
@@ -0,0 +1,187 @@
1
+ import type { IError, ILocalizeInfo } from '../base/utils';
2
+ /**
3
+ * Interface for retrieving attributes based on markers and language codes.
4
+ * @interface IAttributesSets
5
+ * @property {Function} getAttributesByMarker - Get all attributes with data from the attribute sets.
6
+ * @property {Function} getSingleAttributeByMarkerSet - Get a single attribute with data from the attribute sets.
7
+ * @description This interface defines methods for retrieving attributes based on markers and language codes.
8
+ */
9
+ interface IAttributesSets {
10
+ /**
11
+ * Fetches attributes by a specific marker.
12
+ * @handleName getAttributesByMarker
13
+ * @param {string} marker - The marker used to identify the attribute set. Example: "productAttributes".
14
+ * @param {string} [langCode] - The language code for localization purposes. Default: 'en_US'.
15
+ * @returns {IAttributeSetsEntity[]} A promise that resolves to an array of attribute set entities or an error.
16
+ * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
17
+ * @description This method fetches attributes by a specific marker.
18
+ */
19
+ getAttributesByMarker(marker: string, langCode: string): Promise<IAttributeSetsEntity[] | IError>;
20
+ /**
21
+ * Fetches a single attribute by its marker and the set marker.
22
+ * @handleName getSingleAttributeByMarkerSet
23
+ * @param {string} attributeMarker - The marker identifying the attribute. Example: "color".
24
+ * @param {string} setMarker - The marker identifying the attribute set. Example: "productAttributes".
25
+ * @param {string} [langCode] - The language code for localization purposes. Default: "en_US".
26
+ * @returns {IAttributesSetsEntity} A promise that resolves to an attribute set entity or an error.
27
+ * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
28
+ * @description This method fetches a single attribute by its marker and the set marker.
29
+ */
30
+ getSingleAttributeByMarkerSet(attributeMarker: string, setMarker: string, langCode: string): Promise<IAttributesSetsEntity | IError>;
31
+ }
32
+ /**
33
+ * Represents the structure of a list item.
34
+ * @interface IListTitle
35
+ * @property {string} title - The title or name associated with the list item. Example: "Item Name".
36
+ * @property {number | string} value - The value of the list item, which can be either a number or a string depending on the context. Example: 42.
37
+ * @property {string | number | null} position - The position of the list item, which can be represented as a string, number, or null if not applicable. Example: 1.
38
+ * @property {object} extended - An object containing additional properties or metadata related to the list item. This could include any extra details that extend the basic information.
39
+ * @property {string | null} extended.value - The extended value, which can be a string or null. Example: "extra_value".
40
+ * @property {string | null} extended.type - The type of the extended value, which can be a string or null. Example: "color".
41
+ * @description This interface defines the structure of a list item, which includes properties for the title, value, position, and extended information.
42
+ */
43
+ interface IListTitle {
44
+ title: string;
45
+ value: number | string;
46
+ position: string | number | null;
47
+ extended: {
48
+ value: string | null;
49
+ type: string | null;
50
+ };
51
+ }
52
+ /**
53
+ * Defines the possible values for attribute types used in the system.
54
+ * @type {AttributeType}
55
+ * @description This type defines the possible values for attribute types used in the system.
56
+ */
57
+ type AttributeType = 'string' | 'text' | 'textWithHeader' | 'integer' | 'real' | 'float' | 'dateTime' | 'date' | 'time' | 'file' | 'image' | 'groupOfImages' | 'radioButton' | 'list' | 'button';
58
+ /**
59
+ * Represents an attribute set entity.
60
+ * @interface IAttributesSetsEntity
61
+ * @property {AttributeType} type - Attribute type. Example: "string", "text", "integer", "etc".
62
+ * @property {any} [value] - Value of the attribute, which can be of any type.
63
+ * @property {any} initialValue - Initial value of the attribute.
64
+ * @property {string} marker - Textual identifier of the attribute (marker). Example: "color", "size", "etc".
65
+ * @property {number} position - Position number for sorting. Example: 1.
66
+ * @property {IListTitle[] | Record<string, any>} [listTitles] - Array of values (with extended data) for list and radioButton attributes.
67
+ * @example
68
+ [
69
+ {
70
+ "title": "red",
71
+ "value": 1,
72
+ "position": 1,
73
+ "extendedValue": null,
74
+ "extendedValueType": null
75
+ },
76
+ {
77
+ "title": "yellow",
78
+ "value": 2,
79
+ "position": 2,
80
+ "extendedValue": null,
81
+ "extendedValueType": null
82
+ }
83
+ ]
84
+ * @property {Record<string, any>} [validators] - Set of validators for validation.
85
+ * @example
86
+ {
87
+ "requiredValidator": {
88
+ "strict": true
89
+ },
90
+ "defaultValueValidator": {
91
+ "fieldDefaultValue": 11
92
+ }
93
+ }
94
+ * @property {ILocalizeInfo} localizeInfos - The name of the template, taking into account localization.
95
+ * @example
96
+ {
97
+ "title": "My attribute"
98
+ }
99
+ * @property {Record<string, any>} [additionalFields] - Additional fields for the attribute (optional).
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
+ */
102
+ interface IAttributesSetsEntity {
103
+ type: AttributeType;
104
+ value?: any;
105
+ initialValue: any;
106
+ marker: string;
107
+ position: number;
108
+ listTitles?: IListTitle[] | Record<string, any>;
109
+ validators?: Record<string, any>;
110
+ localizeInfos: ILocalizeInfo;
111
+ additionalFields?: Record<string, any>;
112
+ }
113
+ /**
114
+ * Represents an attribute set entity.
115
+ * @interface IAttributeSetsEntity
116
+ * @property {number} id - The unique identifier of the attribute set entity. Example: 123.
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
+ * @property {number} version - The version number of the attribute set, used for tracking changes or updates. Example: 1.
120
+ * @property {string} identifier - A string that uniquely identifies the attribute set. Example: "attributeSet1".
121
+ * @property {number} typeId - The numerical identifier representing the type of the attribute set. Example: 1.
122
+ * @property {string} title - The title or name of the attribute set. Example: "Product Attributes".
123
+ * @property {object} schema - The schema definition associated with the attribute set. This could represent the structure or rules for the data.
124
+ * @example
125
+ {
126
+ "attribute1": {
127
+ "id": 1,
128
+ "type": "string",
129
+ "isPrice": false,
130
+ "original": true,
131
+ "identifier": "string",
132
+ "localizeInfos": {
133
+ "en_US": { "title": "String" }
134
+ }
135
+ }
136
+ }
137
+ * @property {boolean} isVisible - Indicates whether the attribute set is visible or not. Example: true.
138
+ * @property {object} properties - Additional properties associated with the attribute set, which can be of any type.
139
+ * @example
140
+ {
141
+ "color": "red",
142
+ "size": "M"
143
+ }
144
+ * @property {string} type - The type of the attribute set, which could be a specific classification or category. Example: "product", "user", "etc".
145
+ * @property {number} position - The position number for sorting the attribute set. Example: 1.
146
+ * @description This interface defines the structure of an attribute set entity.
147
+ */
148
+ interface IAttributeSetsEntity {
149
+ id: number;
150
+ createdDate: string;
151
+ updatedDate: string;
152
+ version: number;
153
+ identifier: string;
154
+ typeId: number;
155
+ title: string;
156
+ schema: object;
157
+ isVisible: boolean;
158
+ properties: object;
159
+ type: {
160
+ id: number;
161
+ type: string;
162
+ };
163
+ position: number;
164
+ }
165
+ /**
166
+ * Represents the response structure for attribute sets.
167
+ * @interface IAttributesSetsResponse
168
+ * @property {number} total - Total items. Example: 100.
169
+ * @property {IAttributeSetsEntity[]} items - IAttributeSetsEntity array containing attribute set entities.
170
+ * @example
171
+ [
172
+ {
173
+ "id": 1,
174
+ "identifier": "set1"
175
+ },
176
+ {
177
+ "id": 2,
178
+ "identifier": "set2"
179
+ }
180
+ ]
181
+ * @description This interface defines the structure of a response object for attribute sets.
182
+ */
183
+ interface IAttributesSetsResponse {
184
+ total: number;
185
+ items: IAttributeSetsEntity[];
186
+ }
187
+ export type { AttributeType, IAttributeSetsEntity, IAttributesSets, IAttributesSetsEntity, IAttributesSetsResponse, IListTitle, };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });