oneentry 1.0.138 → 1.0.140

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 (143) hide show
  1. package/README.md +16 -1
  2. package/configure.js +40 -21
  3. package/package.json +15 -12
  4. package/dist/admins/adminsApi.d.ts +0 -50
  5. package/dist/admins/adminsApi.js +0 -65
  6. package/dist/admins/adminsInterfaces.d.ts +0 -99
  7. package/dist/admins/adminsInterfaces.js +0 -2
  8. package/dist/admins/adminsSchemas.d.ts +0 -30
  9. package/dist/admins/adminsSchemas.js +0 -27
  10. package/dist/attribute-sets/attributeSetsApi.d.ts +0 -63
  11. package/dist/attribute-sets/attributeSetsApi.js +0 -98
  12. package/dist/attribute-sets/attributeSetsInterfaces.d.ts +0 -187
  13. package/dist/attribute-sets/attributeSetsInterfaces.js +0 -2
  14. package/dist/attribute-sets/attributeSetsSchemas.d.ts +0 -90
  15. package/dist/attribute-sets/attributeSetsSchemas.js +0 -74
  16. package/dist/auth-provider/authProviderApi.d.ts +0 -249
  17. package/dist/auth-provider/authProviderApi.js +0 -351
  18. package/dist/auth-provider/authProviderSchemas.d.ts +0 -137
  19. package/dist/auth-provider/authProviderSchemas.js +0 -85
  20. package/dist/auth-provider/authProvidersInterfaces.d.ts +0 -417
  21. package/dist/auth-provider/authProvidersInterfaces.js +0 -2
  22. package/dist/base/asyncModules.d.ts +0 -80
  23. package/dist/base/asyncModules.js +0 -440
  24. package/dist/base/result.d.ts +0 -39
  25. package/dist/base/result.js +0 -154
  26. package/dist/base/stateModule.d.ts +0 -41
  27. package/dist/base/stateModule.js +0 -128
  28. package/dist/base/syncModules.d.ts +0 -148
  29. package/dist/base/syncModules.js +0 -530
  30. package/dist/base/utils.d.ts +0 -197
  31. package/dist/base/utils.js +0 -2
  32. package/dist/base/validation.d.ts +0 -118
  33. package/dist/base/validation.js +0 -132
  34. package/dist/blocks/blocksApi.d.ts +0 -74
  35. package/dist/blocks/blocksApi.js +0 -184
  36. package/dist/blocks/blocksInterfaces.d.ts +0 -173
  37. package/dist/blocks/blocksInterfaces.js +0 -2
  38. package/dist/blocks/blocksSchemas.d.ts +0 -187
  39. package/dist/blocks/blocksSchemas.js +0 -43
  40. package/dist/events/eventsApi.d.ts +0 -60
  41. package/dist/events/eventsApi.js +0 -97
  42. package/dist/events/eventsInterfaces.d.ts +0 -87
  43. package/dist/events/eventsInterfaces.js +0 -2
  44. package/dist/file-uploading/fileUploadingApi.d.ts +0 -88
  45. package/dist/file-uploading/fileUploadingApi.js +0 -132
  46. package/dist/file-uploading/fileUploadingInterfaces.d.ts +0 -117
  47. package/dist/file-uploading/fileUploadingInterfaces.js +0 -2
  48. package/dist/file-uploading/fileUploadingSchemas.d.ts +0 -22
  49. package/dist/file-uploading/fileUploadingSchemas.js +0 -21
  50. package/dist/forms/formsApi.d.ts +0 -42
  51. package/dist/forms/formsApi.js +0 -57
  52. package/dist/forms/formsInterfaces.d.ts +0 -132
  53. package/dist/forms/formsInterfaces.js +0 -2
  54. package/dist/forms/formsSchemas.d.ts +0 -65
  55. package/dist/forms/formsSchemas.js +0 -36
  56. package/dist/forms-data/formsDataApi.d.ts +0 -106
  57. package/dist/forms-data/formsDataApi.js +0 -189
  58. package/dist/forms-data/formsDataInterfaces.d.ts +0 -525
  59. package/dist/forms-data/formsDataInterfaces.js +0 -2
  60. package/dist/forms-data/formsDataSchemas.d.ts +0 -115
  61. package/dist/forms-data/formsDataSchemas.js +0 -86
  62. package/dist/general-types/generalTypesApi.d.ts +0 -28
  63. package/dist/general-types/generalTypesApi.js +0 -38
  64. package/dist/general-types/generalTypesInterfaces.d.ts +0 -30
  65. package/dist/general-types/generalTypesInterfaces.js +0 -2
  66. package/dist/general-types/generalTypesSchemas.d.ts +0 -50
  67. package/dist/general-types/generalTypesSchemas.js +0 -35
  68. package/dist/index.d.ts +0 -94
  69. package/dist/index.js +0 -97
  70. package/dist/integration-collections/integrationCollectionsApi.d.ts +0 -173
  71. package/dist/integration-collections/integrationCollectionsApi.js +0 -220
  72. package/dist/integration-collections/integrationCollectionsInterfaces.d.ts +0 -313
  73. package/dist/integration-collections/integrationCollectionsInterfaces.js +0 -2
  74. package/dist/integration-collections/integrationCollectionsSchemas.d.ts +0 -84
  75. package/dist/integration-collections/integrationCollectionsSchemas.js +0 -63
  76. package/dist/locales/localesApi.d.ts +0 -27
  77. package/dist/locales/localesApi.js +0 -37
  78. package/dist/locales/localesInterfaces.d.ts +0 -41
  79. package/dist/locales/localesInterfaces.js +0 -2
  80. package/dist/locales/localesSchemas.d.ts +0 -32
  81. package/dist/locales/localesSchemas.js +0 -26
  82. package/dist/menus/menusApi.d.ts +0 -29
  83. package/dist/menus/menusApi.js +0 -39
  84. package/dist/menus/menusInterfaces.d.ts +0 -88
  85. package/dist/menus/menusInterfaces.js +0 -4
  86. package/dist/menus/menusSchemas.d.ts +0 -16
  87. package/dist/menus/menusSchemas.js +0 -28
  88. package/dist/orders/ordersApi.d.ts +0 -126
  89. package/dist/orders/ordersApi.js +0 -169
  90. package/dist/orders/ordersInterfaces.d.ts +0 -427
  91. package/dist/orders/ordersInterfaces.js +0 -2
  92. package/dist/orders/ordersSchemas.d.ts +0 -158
  93. package/dist/orders/ordersSchemas.js +0 -120
  94. package/dist/pages/pagesApi.d.ts +0 -151
  95. package/dist/pages/pagesApi.js +0 -390
  96. package/dist/pages/pagesInterfaces.d.ts +0 -292
  97. package/dist/pages/pagesInterfaces.js +0 -2
  98. package/dist/pages/pagesSchemas.d.ts +0 -85
  99. package/dist/pages/pagesSchemas.js +0 -46
  100. package/dist/payments/paymentsApi.d.ts +0 -82
  101. package/dist/payments/paymentsApi.js +0 -121
  102. package/dist/payments/paymentsInterfaces.d.ts +0 -206
  103. package/dist/payments/paymentsInterfaces.js +0 -2
  104. package/dist/payments/paymentsSchemas.d.ts +0 -137
  105. package/dist/payments/paymentsSchemas.js +0 -78
  106. package/dist/product-statuses/productStatusesApi.d.ts +0 -47
  107. package/dist/product-statuses/productStatusesApi.js +0 -70
  108. package/dist/product-statuses/productStatusesInterfaces.d.ts +0 -66
  109. package/dist/product-statuses/productStatusesInterfaces.js +0 -2
  110. package/dist/product-statuses/productStatusesSchemas.d.ts +0 -34
  111. package/dist/product-statuses/productStatusesSchemas.js +0 -30
  112. package/dist/products/productsApi.d.ts +0 -365
  113. package/dist/products/productsApi.js +0 -464
  114. package/dist/products/productsInterfaces.d.ts +0 -583
  115. package/dist/products/productsInterfaces.js +0 -2
  116. package/dist/products/productsSchemas.d.ts +0 -212
  117. package/dist/products/productsSchemas.js +0 -85
  118. package/dist/system/systemApi.d.ts +0 -65
  119. package/dist/system/systemApi.js +0 -82
  120. package/dist/system/systemInterfaces.d.ts +0 -23
  121. package/dist/system/systemInterfaces.js +0 -2
  122. package/dist/templates/templatesApi.d.ts +0 -49
  123. package/dist/templates/templatesApi.js +0 -75
  124. package/dist/templates/templatesInterfaces.d.ts +0 -70
  125. package/dist/templates/templatesInterfaces.js +0 -2
  126. package/dist/templates/templatesSchemas.d.ts +0 -48
  127. package/dist/templates/templatesSchemas.js +0 -31
  128. package/dist/templates-preview/templatesPreviewApi.d.ts +0 -38
  129. package/dist/templates-preview/templatesPreviewApi.js +0 -53
  130. package/dist/templates-preview/templatesPreviewInterfaces.d.ts +0 -121
  131. package/dist/templates-preview/templatesPreviewInterfaces.js +0 -2
  132. package/dist/templates-preview/templatesPreviewSchemas.d.ts +0 -83
  133. package/dist/templates-preview/templatesPreviewSchemas.js +0 -48
  134. package/dist/users/usersApi.d.ts +0 -143
  135. package/dist/users/usersApi.js +0 -174
  136. package/dist/users/usersInterfaces.d.ts +0 -235
  137. package/dist/users/usersInterfaces.js +0 -2
  138. package/dist/users/usersSchemas.d.ts +0 -38
  139. package/dist/users/usersSchemas.js +0 -28
  140. package/dist/web-socket/wsApi.d.ts +0 -25
  141. package/dist/web-socket/wsApi.js +0 -45
  142. package/dist/web-socket/wsInterfaces.d.ts +0 -17
  143. package/dist/web-socket/wsInterfaces.js +0 -2
@@ -1,57 +0,0 @@
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 formsSchemas_1 = require("./formsSchemas");
8
- /**
9
- * Controllers for forms objects
10
- * @class FormsApi
11
- * @augments AsyncModules
12
- * @implements {IForms}
13
- * @description This class provides methods to interact with forms, including retrieving all forms and getting a form by its marker.
14
- */
15
- class FormsApi extends asyncModules_1.default {
16
- /**
17
- * Initializes the FormsApi with the provided state module.
18
- * @class
19
- * @class FormsApi
20
- * @param {StateModule} state - The state module containing configuration data.
21
- * @description Constructor initializes the FormsApi with a given state.
22
- */
23
- constructor(state) {
24
- super(state);
25
- this._url = state.url + '/api/content/forms';
26
- }
27
- /**
28
- * Get all forms.
29
- * @handleName getAllForms
30
- * @param {string} [langCode] - Language code. Default: "en_US".
31
- * @param {number} [offset] - Parameter for pagination. Default: 0.
32
- * @param {number} [limit] - Parameter for pagination. Default: 30.
33
- * @returns {Promise<IFormsEntity[] | IError>} Returns array for all objects of type FormEntity.
34
- * @throws {IError} When isShell=false and an error occurs during the fetch
35
- */
36
- async getAllForms(langCode = this.state.lang, offset = 0, limit = 30) {
37
- const result = await this._fetchGet(`?langCode=${langCode}&offset=${offset}&limit=${limit}`);
38
- // Validate response if validation is enabled
39
- const validated = this._validateResponse(result, formsSchemas_1.FormsResponseSchema);
40
- return this._dataPostProcess(validated, langCode);
41
- }
42
- /**
43
- * Get one form by form marker.
44
- * @handleName getFormByMarker
45
- * @param {string} marker - Marker of form. Example: "contact_form".
46
- * @param {string} [langCode] - Language code. Default: "en_US".
47
- * @returns {Promise<IFormsEntity | IError>} Returns object of type FormEntity.
48
- * @throws {IError} When isShell=false and an error occurs during the fetch
49
- */
50
- async getFormByMarker(marker, langCode = this.state.lang) {
51
- const result = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
52
- // Validate response if validation is enabled
53
- const validated = this._validateResponse(result, formsSchemas_1.FormEntitySchema);
54
- return this._dataPostProcess(validated, langCode);
55
- }
56
- }
57
- exports.default = FormsApi;
@@ -1,132 +0,0 @@
1
- import type { IPosition } from '../admins/adminsInterfaces';
2
- import type { IAttributes, IError, ILocalizeInfo } from '../base/utils';
3
- /**
4
- * Interface for retrieving forms in the system.
5
- * @interface IForms
6
- * @property {Function} getAllForms - Get all forms in array.
7
- * @property {Function} getFormByMarker - Get one form by form marker.
8
- * @description This interface defines methods for retrieving forms in the system.
9
- */
10
- interface IForms {
11
- /**
12
- * Retrieves all forms in the system.
13
- * @handleName getAllForms
14
- * @param {string} [langCode] - The language code for localization. Default: "en_US".
15
- * @param {number} [offset] - Optional offset for pagination. Default: 0.
16
- * @param {number} [limit] - Optional limit for pagination. Default: 30.
17
- * @returns {IFormsEntity[]} A promise that resolves to an array of form entities or an error.
18
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
19
- * @description This method retrieves all forms in the system.
20
- */
21
- getAllForms(langCode?: string, offset?: number, limit?: number): Promise<IFormsEntity[] | IError>;
22
- /**
23
- * Retrieves a form by its marker.
24
- * @handleName getFormByMarker
25
- * @param {string} marker - The marker identifying the form. Example: "contact_form".
26
- * @param {string} [langCode] - The language code for localization. Default: "en_US".
27
- * @returns {IFormsEntity} A promise that resolves to a form entity or an error.
28
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
29
- * @description This method retrieves a form by its marker.
30
- */
31
- getFormByMarker(marker: string, langCode?: string): Promise<IFormsEntity | IError>;
32
- }
33
- /**
34
- * Represents the structure of a form page.
35
- * @interface IFromPages
36
- * @property {number} id - The unique identifier of the form page. Example: 123.
37
- * @property {number} pageId - The identifier of the page. Example: 12.
38
- * @property {number} formId - The identifier of the form. Example: 321.
39
- * @property {number} positionId - The identifier of the position. Example: 1.
40
- * @property {IPosition} position - The position object.
41
- * @example
42
- {
43
- "id": 1,
44
- "position": 1,
45
- "objectId": 2,
46
- "objectType": "admin",
47
- "isLocked": false,
48
- "objectCategoryId": 1
49
- }
50
- * @description This interface defines the structure of a form page.
51
- */
52
- interface IFromPages {
53
- id: number;
54
- pageId: number;
55
- formId: number;
56
- positionId: number;
57
- position: IPosition;
58
- }
59
- /**
60
- * Represents the structure of a form entity.
61
- * @interface IFormsEntity
62
- * @property {number} id - The identifier of the object. Example: 12345.
63
- * @property {number | null} attributeSetId - The identifier of the attribute set being used, or null if not applicable. Example: 1234.
64
- * @property {string | null} type - Form type. Example: "contact".
65
- * @property {ILocalizeInfo} localizeInfos - The name of the form, taking into account localization.
66
- * @example
67
- {
68
- "key": "value"
69
- }
70
- * @property {number} version - The version number of the object. Example: 1.
71
- * @property {number} position - The position of the object. Example: 1.
72
- * @property {string} identifier - The textual identifier for the record field. Example: "form_contact_us".
73
- * @property {string} processingType - Type of form processing. Example: "async".
74
- * @property {number | null} templateId - The identifier of the template used by the form, or null if no template is used. Example: 6789.
75
- * @property {IAttributes[] | Record<string, any>} attributes - The attributes of the form, which can be an array of attribute objects or a record of key-value pairs.
76
- * @example
77
- {
78
- "key": "value"
79
- }
80
- * @property {Array<IFormConfig>} [moduleFormConfigs] - Module form configurations linked to the form.
81
- * @description This interface defines the structure of a form entity, including its identifiers, attributes, and processing data.
82
- */
83
- interface IFormsEntity {
84
- id: number;
85
- attributeSetId: number | null;
86
- type: string | null;
87
- localizeInfos: ILocalizeInfo;
88
- version: number;
89
- position: number;
90
- identifier: string;
91
- processingType: string;
92
- templateId: number | null;
93
- attributes: IAttributes[] | Record<string, any>;
94
- moduleFormConfigs?: Array<IFormConfig>;
95
- }
96
- /**
97
- * Represents the structure of a form configuration.
98
- * @interface IFormConfig
99
- * @property {number} id - The identifier of the form configuration. Example: 123.
100
- * @property {string} [formIdentifier] - The form identifier (only in products/pages API). Example: "review".
101
- * @property {string} moduleIdentifier - The identifier of the module associated with the form configuration. Example: "module_identifier".
102
- * @property {boolean} isGlobal - Indicates whether the form configuration is global. Example: true.
103
- * @property {boolean} isClosed - Indicates whether the form configuration is closed. Example: true.
104
- * @property {boolean} [isModerate] - Indicates whether the form requires moderation (only in products/pages API). Example: false.
105
- * @property {boolean} [viewOnlyUserData] - Indicates whether the form configuration allows viewing user data (used in forms API). Example: true.
106
- * @property {boolean} [commentOnlyUserData] - Indicates whether the form configuration allows commenting on user data (used in forms API). Example: true.
107
- * @property {boolean} [viewOnlyMyData] - Indicates whether the form configuration allows viewing my data (used in products/pages API). Example: false.
108
- * @property {boolean} [commentOnlyMyData] - Indicates whether the form configuration allows commenting on my data (used in products/pages API). Example: false.
109
- * @property {object[]} entityIdentifiers - An array of entity identifiers associated with the form configuration.
110
- * @property {string} entityIdentifiers[].id - Entity identifier. Example: "catalog".
111
- * @property {boolean} entityIdentifiers[].isNested - Indicates if entity is nested. Example: false.
112
- * @property {string[]} [nestedEntityIdentifiers] - An array of nested entity identifier strings (only in products/pages API). Example: ["catalog"].
113
- * @description This interface defines the structure of a form configuration, including its identifiers, module association, and entity identifiers. Different APIs return different field variants.
114
- */
115
- interface IFormConfig {
116
- id: number;
117
- formIdentifier?: string;
118
- moduleIdentifier: string;
119
- isGlobal: boolean;
120
- isClosed: boolean;
121
- isModerate?: boolean;
122
- viewOnlyUserData?: boolean;
123
- commentOnlyUserData?: boolean;
124
- viewOnlyMyData?: boolean;
125
- commentOnlyMyData?: boolean;
126
- entityIdentifiers: {
127
- id: string;
128
- isNested: boolean;
129
- }[];
130
- nestedEntityIdentifiers?: string[];
131
- }
132
- export type { IFormConfig, IForms, IFormsEntity, IFromPages };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,65 +0,0 @@
1
- import { z } from 'zod';
2
- /**
3
- * Form entity schema
4
- * Includes all fields returned by the API
5
- */
6
- export declare const FormEntitySchema: z.ZodObject<{
7
- id: z.ZodNumber;
8
- identifier: z.ZodString;
9
- localizeInfos: z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodArray<z.ZodAny>]>;
10
- attributeValues: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
11
- version: z.ZodOptional<z.ZodNumber>;
12
- processingPersonalData: z.ZodOptional<z.ZodBoolean>;
13
- active: z.ZodOptional<z.ZodBoolean>;
14
- isAuthenticated: z.ZodOptional<z.ZodBoolean>;
15
- config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
16
- attributes: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodAny>, z.ZodRecord<z.ZodString, z.ZodAny>]>>;
17
- attributeSetId: z.ZodOptional<z.ZodNumber>;
18
- position: z.ZodOptional<z.ZodNumber>;
19
- processingType: z.ZodOptional<z.ZodString>;
20
- templateId: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
21
- type: z.ZodOptional<z.ZodString>;
22
- moduleFormConfigs: z.ZodOptional<z.ZodArray<z.ZodAny>>;
23
- }, z.core.$strip>;
24
- /**
25
- * Forms response schema (array of forms)
26
- */
27
- export declare const FormsResponseSchema: z.ZodArray<z.ZodObject<{
28
- id: z.ZodNumber;
29
- identifier: z.ZodString;
30
- localizeInfos: z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodArray<z.ZodAny>]>;
31
- attributeValues: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
32
- version: z.ZodOptional<z.ZodNumber>;
33
- processingPersonalData: z.ZodOptional<z.ZodBoolean>;
34
- active: z.ZodOptional<z.ZodBoolean>;
35
- isAuthenticated: z.ZodOptional<z.ZodBoolean>;
36
- config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
37
- attributes: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodAny>, z.ZodRecord<z.ZodString, z.ZodAny>]>>;
38
- attributeSetId: z.ZodOptional<z.ZodNumber>;
39
- position: z.ZodOptional<z.ZodNumber>;
40
- processingType: z.ZodOptional<z.ZodString>;
41
- templateId: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
42
- type: z.ZodOptional<z.ZodString>;
43
- moduleFormConfigs: z.ZodOptional<z.ZodArray<z.ZodAny>>;
44
- }, z.core.$strip>>;
45
- /**
46
- * Single form response schema
47
- */
48
- export declare const SingleFormSchema: z.ZodObject<{
49
- id: z.ZodNumber;
50
- identifier: z.ZodString;
51
- localizeInfos: z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodArray<z.ZodAny>]>;
52
- attributeValues: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
53
- version: z.ZodOptional<z.ZodNumber>;
54
- processingPersonalData: z.ZodOptional<z.ZodBoolean>;
55
- active: z.ZodOptional<z.ZodBoolean>;
56
- isAuthenticated: z.ZodOptional<z.ZodBoolean>;
57
- config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
58
- attributes: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodAny>, z.ZodRecord<z.ZodString, z.ZodAny>]>>;
59
- attributeSetId: z.ZodOptional<z.ZodNumber>;
60
- position: z.ZodOptional<z.ZodNumber>;
61
- processingType: z.ZodOptional<z.ZodString>;
62
- templateId: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
63
- type: z.ZodOptional<z.ZodString>;
64
- moduleFormConfigs: z.ZodOptional<z.ZodArray<z.ZodAny>>;
65
- }, z.core.$strip>;
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SingleFormSchema = exports.FormsResponseSchema = exports.FormEntitySchema = void 0;
4
- const zod_1 = require("zod");
5
- /**
6
- * Form entity schema
7
- * Includes all fields returned by the API
8
- */
9
- exports.FormEntitySchema = zod_1.z.object({
10
- id: zod_1.z.number(),
11
- identifier: zod_1.z.string(),
12
- 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())]),
13
- attributeValues: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
14
- version: zod_1.z.number().optional(),
15
- processingPersonalData: zod_1.z.boolean().optional(),
16
- active: zod_1.z.boolean().optional(),
17
- isAuthenticated: zod_1.z.boolean().optional(),
18
- config: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
19
- attributes: zod_1.z
20
- .union([zod_1.z.array(zod_1.z.any()), zod_1.z.record(zod_1.z.string(), zod_1.z.any())])
21
- .optional(),
22
- attributeSetId: zod_1.z.number().optional(),
23
- position: zod_1.z.number().optional(),
24
- processingType: zod_1.z.string().optional(),
25
- templateId: zod_1.z.number().nullable().optional(),
26
- type: zod_1.z.string().optional(),
27
- moduleFormConfigs: zod_1.z.array(zod_1.z.any()).optional(),
28
- });
29
- /**
30
- * Forms response schema (array of forms)
31
- */
32
- exports.FormsResponseSchema = zod_1.z.array(exports.FormEntitySchema);
33
- /**
34
- * Single form response schema
35
- */
36
- exports.SingleFormSchema = exports.FormEntitySchema;
@@ -1,106 +0,0 @@
1
- import AsyncModules from '../base/asyncModules';
2
- import type StateModule from '../base/stateModule';
3
- import type { IError } from '../base/utils';
4
- import type { IBodyPostFormData, IFormsByMarkerDataEntity, IFormsData, IPostFormResponse, IUpdateFormsData } from './formsDataInterfaces';
5
- /**
6
- * Controllers for working with form data
7
- * @handle /api/content/form-data
8
- * @class FormsDataApi
9
- * @augments AsyncModules
10
- * @implements {IFormsData}
11
- * @description This class provides methods to interact with form data, including retrieving all forms data, creating new form data entries, and fetching form data by marker.
12
- */
13
- export default class FormsDataApi extends AsyncModules implements IFormsData {
14
- protected state: StateModule;
15
- protected _url: string;
16
- /**
17
- * Constructor for FormsDataApi class.
18
- */
19
- constructor(state: StateModule);
20
- /**
21
- * Creating an object of data save information by form
22
- * @handleName postFormsData
23
- * @param {IBodyPostFormData} body - Request body.
24
- * @example
25
- {
26
- "formIdentifier": "test-form",
27
- "formModuleConfigId": 2,
28
- "moduleEntityIdentifier": "blog",
29
- "replayTo": null,
30
- "status": "sent",
31
- "formData": [
32
- {
33
- "marker": "name",
34
- "type": "string",
35
- "value": "Test"
36
- }
37
- ]
38
- }
39
- * @param {string} body.formIdentifier - The identifier for the form. Example: "form".
40
- * @param {number} body.formModuleConfigId - The ID of the form module configuration. Example: 2.
41
- * @param {string} body.moduleEntityIdentifier - The identifier of the module entity. Example: "form".
42
- * @param {string | null} [body.replayTo] - The email address to which the reply should be sent.
43
- * @param {string | null} [body.status] - The status of the form submission.
44
- * @param {FormDataType[]} body.formData - Form data.
45
- * @example
46
- [
47
- {
48
- "marker": "name",
49
- "type": "string",
50
- "value": "Jack"
51
- }
52
- ]
53
- * @param {string} body.formData[].marker - The marker identifying the form field. Example: "name".
54
- * @param {string} body.formData[].type - The type of the form field. Example: "string".
55
- * @param {string} body.formData[].value - The value of the form field. Example: "Jack".
56
- * @param {string} [langCode] - Language code. Default: "en_US".
57
- * @returns {Promise<IPostFormResponse | IError>} Returns an object containing the created form data entry and message.
58
- * @throws {IError} When isShell=false and an error occurs during the fetch
59
- */
60
- postFormsData(body: IBodyPostFormData, langCode?: string): Promise<IPostFormResponse | IError>;
61
- /**
62
- * Get one object of form data by marker.
63
- * @handleName getFormsDataByMarker
64
- * @param {string} marker - Marker of the form. Example: "contact_form".
65
- * @param {number} formModuleConfigId - Form module configuration ID. Example: 4.
66
- * @param {object} [body] - Request body.
67
- * @example
68
- {
69
- "entityIdentifier": 14,
70
- "entityparentIdentifier": 167,
71
- "userIdentifier": "",
72
- "status": ["new", "approved"],
73
- "dateFrom": "2025-01-01",
74
- "dateTo": ""
75
- }
76
- * @param {number} [isExtended] - Flag for getting additional fields. Example: 1.
77
- * @param {string} [langCode] - Language code. Default: "en_US".
78
- * @param {number} [offset] - Parameter for pagination. Default: 0.
79
- * @param {number} [limit] - Parameter for pagination. Default: 30.
80
- * @returns {Promise<IFormsByMarkerDataEntity | IError>} Returns an object containing the form data or an error object if there was an issue.
81
- * @throws {IError} When isShell=false and an error occurs during the fetch
82
- */
83
- getFormsDataByMarker(marker: string, formModuleConfigId: number, body?: object, isExtended?: number, langCode?: string, offset?: number, limit?: number): Promise<IFormsByMarkerDataEntity | IError>;
84
- /**
85
- * Update one object of form data by id. Requires user authentication.
86
- * @handleName updateFormsDataByid
87
- * @param {number} id - ID of the form data. Example: 1.
88
- * @returns {Promise<IUpdateFormsData | IError>} Returns an object containing the updated form data or an error object if there was an issue.
89
- */
90
- updateFormsDataByid(id: number, body?: object): Promise<IUpdateFormsData | IError>;
91
- /**
92
- * Update form data status by id. Requires user authentication.
93
- * @handleName updateFormsDataStatusByid
94
- * @param {number} id - ID of the form data. Example: 1.
95
- * @param {object} body - Request body.
96
- * @returns {Promise<boolean | IError>} Returns an object containing the updated form data or an error object if there was an issue.
97
- */
98
- updateFormsDataStatusByid(id: number, body?: object): Promise<boolean | IError>;
99
- /**
100
- * Delete one object of form data by id. Requires user authentication.
101
- * @handleName deleteFormsDataByid
102
- * @param {number} id - ID of the form data. Example: 1.
103
- * @returns {Promise<boolean | IError>} Returns an object containing the deleted form data or an error object if there was an issue.
104
- */
105
- deleteFormsDataByid(id: number): Promise<boolean | IError>;
106
- }
@@ -1,189 +0,0 @@
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
- /* eslint-disable @typescript-eslint/no-explicit-any */
7
- const asyncModules_1 = __importDefault(require("../base/asyncModules"));
8
- const fileUploadingApi_1 = __importDefault(require("../file-uploading/fileUploadingApi"));
9
- const formsDataSchemas_1 = require("./formsDataSchemas");
10
- /**
11
- * Controllers for working with form data
12
- * @handle /api/content/form-data
13
- * @class FormsDataApi
14
- * @augments AsyncModules
15
- * @implements {IFormsData}
16
- * @description This class provides methods to interact with form data, including retrieving all forms data, creating new form data entries, and fetching form data by marker.
17
- */
18
- class FormsDataApi extends asyncModules_1.default {
19
- /**
20
- * Constructor for FormsDataApi class.
21
- */
22
- constructor(state) {
23
- super(state);
24
- this._url = state.url + '/api/content/form-data';
25
- }
26
- /**
27
- * Creating an object of data save information by form
28
- * @handleName postFormsData
29
- * @param {IBodyPostFormData} body - Request body.
30
- * @example
31
- {
32
- "formIdentifier": "test-form",
33
- "formModuleConfigId": 2,
34
- "moduleEntityIdentifier": "blog",
35
- "replayTo": null,
36
- "status": "sent",
37
- "formData": [
38
- {
39
- "marker": "name",
40
- "type": "string",
41
- "value": "Test"
42
- }
43
- ]
44
- }
45
- * @param {string} body.formIdentifier - The identifier for the form. Example: "form".
46
- * @param {number} body.formModuleConfigId - The ID of the form module configuration. Example: 2.
47
- * @param {string} body.moduleEntityIdentifier - The identifier of the module entity. Example: "form".
48
- * @param {string | null} [body.replayTo] - The email address to which the reply should be sent.
49
- * @param {string | null} [body.status] - The status of the form submission.
50
- * @param {FormDataType[]} body.formData - Form data.
51
- * @example
52
- [
53
- {
54
- "marker": "name",
55
- "type": "string",
56
- "value": "Jack"
57
- }
58
- ]
59
- * @param {string} body.formData[].marker - The marker identifying the form field. Example: "name".
60
- * @param {string} body.formData[].type - The type of the form field. Example: "string".
61
- * @param {string} body.formData[].value - The value of the form field. Example: "Jack".
62
- * @param {string} [langCode] - Language code. Default: "en_US".
63
- * @returns {Promise<IPostFormResponse | IError>} Returns an object containing the created form data entry and message.
64
- * @throws {IError} When isShell=false and an error occurs during the fetch
65
- */
66
- async postFormsData(body, langCode = this.state.lang) {
67
- const formData = {};
68
- // filter spam and button fields, send file
69
- formData[langCode] = Array.isArray(body.formData)
70
- ? body.formData.filter((fd) => fd.type !== 'spam' && fd.type !== 'button')
71
- : [body.formData].filter((fd) => fd.type !== 'spam' && fd.type !== 'button');
72
- /**
73
- * Handle file uploads if fileQuery is present
74
- */
75
- // Check if there is any element in formData[langCode] that contains one of the specified types
76
- if (formData[langCode].find((fd) => ['file', 'image', 'groupOfImages'].includes(fd.type))) {
77
- // Create an instance of FileUploadingApi with the current state
78
- const fileUploader = new fileUploadingApi_1.default(this.state);
79
- // Process each element in formData[langCode] asynchronously
80
- formData[langCode] = await Promise.all(formData[langCode].map(async (fd) => {
81
- // Check if the type is one of the specified types
82
- if (['file', 'image', 'groupOfImages'].includes(fd.type)) {
83
- // If fileQuery does not exist, we create it and assign it to an object with the following properties:
84
- if (!fd.fileQuery) {
85
- const fileQuery = {
86
- type: 'page',
87
- entity: 'editor',
88
- // Generate a random 4-digit ID
89
- id: Number(Math.floor(Math.random() * 10000)
90
- .toString()
91
- .padStart(4, '0')),
92
- };
93
- fd.fileQuery = fileQuery;
94
- }
95
- // Convert fd.value to an array if it is a FileList, otherwise use it directly
96
- const filesArray = typeof FileList !== 'undefined' && fd.value instanceof FileList
97
- ? Array.from(fd.value)
98
- : fd.value;
99
- // If filesArray is an array, upload each file asynchronously
100
- if (Array.isArray(filesArray)) {
101
- const uploadPromises = filesArray.map((file) => fileUploader.upload(file, fd.fileQuery).catch((e) => e));
102
- fd.value = (await Promise.all(uploadPromises)).flat();
103
- }
104
- // If fd.value is a single File or Blob, upload it
105
- else if (fd.value instanceof File || fd.value instanceof Blob) {
106
- fd.value = await fileUploader
107
- .upload(fd.value, fd.fileQuery)
108
- .catch((e) => e); // Catch any errors during upload
109
- }
110
- // Remove the 'fileQuery' property from the object after processing
111
- delete fd.fileQuery;
112
- // Remove the 'contentType' property from the file object because it is not needed and not valid
113
- fd.value.map((file) => {
114
- delete file.contentType;
115
- });
116
- }
117
- // Return the processed form data element
118
- return fd;
119
- }));
120
- }
121
- body.formData = formData;
122
- const result = await this._fetchPost(``, body);
123
- // Validate response if validation is enabled
124
- const validated = this._validateResponse(result, formsDataSchemas_1.PostFormResponseSchema);
125
- return this._dataPostProcess(validated);
126
- }
127
- /**
128
- * Get one object of form data by marker.
129
- * @handleName getFormsDataByMarker
130
- * @param {string} marker - Marker of the form. Example: "contact_form".
131
- * @param {number} formModuleConfigId - Form module configuration ID. Example: 4.
132
- * @param {object} [body] - Request body.
133
- * @example
134
- {
135
- "entityIdentifier": 14,
136
- "entityparentIdentifier": 167,
137
- "userIdentifier": "",
138
- "status": ["new", "approved"],
139
- "dateFrom": "2025-01-01",
140
- "dateTo": ""
141
- }
142
- * @param {number} [isExtended] - Flag for getting additional fields. Example: 1.
143
- * @param {string} [langCode] - Language code. Default: "en_US".
144
- * @param {number} [offset] - Parameter for pagination. Default: 0.
145
- * @param {number} [limit] - Parameter for pagination. Default: 30.
146
- * @returns {Promise<IFormsByMarkerDataEntity | IError>} Returns an object containing the form data or an error object if there was an issue.
147
- * @throws {IError} When isShell=false and an error occurs during the fetch
148
- */
149
- async getFormsDataByMarker(marker, formModuleConfigId, body = {}, isExtended = 0, langCode = this.state.lang, offset = 0, limit = 30) {
150
- const result = await this._fetchPost(`/marker/${marker}?formModuleConfigId=${formModuleConfigId}&isExtended=${isExtended}&langCode=${langCode}&offset=${offset}&limit=${limit}`, body);
151
- // Validate response if validation is enabled
152
- const validated = this._validateResponse(result, formsDataSchemas_1.FormsByMarkerDataResponseSchema);
153
- return this._dataPostProcess(validated, langCode);
154
- }
155
- /**
156
- * Update one object of form data by id. Requires user authentication.
157
- * @handleName updateFormsDataByid
158
- * @param {number} id - ID of the form data. Example: 1.
159
- * @returns {Promise<IUpdateFormsData | IError>} Returns an object containing the updated form data or an error object if there was an issue.
160
- */
161
- async updateFormsDataByid(id, body = {}) {
162
- const result = await this._fetchPut(`/${id}`, body);
163
- // Validate response if validation is enabled
164
- const validated = this._validateResponse(result, formsDataSchemas_1.UpdateFormsDataSchema);
165
- return validated;
166
- }
167
- /**
168
- * Update form data status by id. Requires user authentication.
169
- * @handleName updateFormsDataStatusByid
170
- * @param {number} id - ID of the form data. Example: 1.
171
- * @param {object} body - Request body.
172
- * @returns {Promise<boolean | IError>} Returns an object containing the updated form data or an error object if there was an issue.
173
- */
174
- async updateFormsDataStatusByid(id, body = {}) {
175
- const result = await this._fetchPut(`/${id}/update-status`, body);
176
- return result;
177
- }
178
- /**
179
- * Delete one object of form data by id. Requires user authentication.
180
- * @handleName deleteFormsDataByid
181
- * @param {number} id - ID of the form data. Example: 1.
182
- * @returns {Promise<boolean | IError>} Returns an object containing the deleted form data or an error object if there was an issue.
183
- */
184
- async deleteFormsDataByid(id) {
185
- const result = await this._fetchDelete(`/${id}`);
186
- return result;
187
- }
188
- }
189
- exports.default = FormsDataApi;