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,132 @@
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 jsdoc/reject-any-type */
7
+ /* eslint-disable @typescript-eslint/no-explicit-any */
8
+ /// <reference lib="dom" />
9
+ const asyncModules_1 = __importDefault(require("../base/asyncModules"));
10
+ // import { IFileEntity } from './fileUploadingInterfaces';
11
+ const fileUploadingSchemas_1 = require("./fileUploadingSchemas");
12
+ /**
13
+ * Controllers for working with file uploading
14
+ * @handle /api/content/files
15
+ * @class FileUploadingApi
16
+ * @augments AsyncModules
17
+ * @implements {IFileUploading}
18
+ * @description This class provides methods to upload and delete files in a cloud file storage, as well as retrieve files by parameters.
19
+ */
20
+ class FileUploadingApi extends asyncModules_1.default {
21
+ /**
22
+ * Constructs a new instance of the FileUploadingApi class.
23
+ */
24
+ constructor(state) {
25
+ super(state);
26
+ /** FileUploadingApi class */
27
+ this._defaultQuery = {
28
+ type: null,
29
+ entity: null,
30
+ id: null,
31
+ width: null,
32
+ height: null,
33
+ compress: null,
34
+ };
35
+ this._url = state.url + '/api/content/files';
36
+ }
37
+ /**
38
+ * Upload file function.
39
+ * @handleName upload
40
+ * @param {File | Blob} file - File to upload. Example: `new File(["content"], "file.png", {"type": "image/png"})`
41
+ * @param {IUploadingQuery} [fileQuery] - Optional set query parameters.
42
+ * @example
43
+ {
44
+ "type": "page",
45
+ "entity": "editor",
46
+ "id": 3787,
47
+ "width": 0,
48
+ "height": 0,
49
+ "compress": true,
50
+ "template": 1
51
+ }
52
+ * @param {string} [fileQuery.type] - Type, determines the folder name in the storage. Example: "page".
53
+ * @param {string} [fileQuery.entity] - Entity name from which the file is uploaded, determines the folder name in the storage. Example: "editor".
54
+ * @param {number} [fileQuery.id] - Identifier of the object from which the file is uploaded, determines the folder name in the storage. Example: 3787.
55
+ * @param {number} [fileQuery.width] - Optional width parameter. Example: 0.
56
+ * @param {number} [fileQuery.height] - Optional height parameter. Example: 0.
57
+ * @param {boolean} [fileQuery.compress] - Optional flag of optimization (compression) for images. Example: true.
58
+ * @param {any} [fileQuery.template] - preview template identifier. Example: 1.
59
+ * @returns {Promise<IUploadingReturn[] | IError>} Uploads a file to an Amazon S3-compatible cloud file storage.
60
+ * @throws {IError} When isShell=false and an error occurs during the fetch
61
+ */
62
+ async upload(file, fileQuery) {
63
+ const query = { ...this._defaultQuery, ...fileQuery };
64
+ const body = new FormData();
65
+ body.append('files', file);
66
+ const result = await this._fetchPost('?' + this._queryParamsToString(query), body);
67
+ // Validate response if validation is enabled
68
+ const validated = this._validateResponse(result, fileUploadingSchemas_1.UploadResponseSchema);
69
+ return validated;
70
+ }
71
+ /**
72
+ * Deletes a file from the cloud file storage.
73
+ * @handleName delete
74
+ * @param {string} filename - File name. Example: "file.png".
75
+ * @param {IUploadingQuery} [fileQuery] - Optional set query parameters.
76
+ * @example
77
+ {
78
+ "type": "page",
79
+ "entity": "editor",
80
+ "id": 3787,
81
+ "template": 1
82
+ }
83
+ * @param {string} [fileQuery.type] - Type, determines the folder name in the storage. Example: "page".
84
+ * @param {string} [fileQuery.entity] - Entity name from which the file is uploaded, determines the folder name in the storage. Example: "editor".
85
+ * @param {number} [fileQuery.id] - Identifier of the object from which the file is uploaded, determines the folder name in the storage. Example: 3787.
86
+ * @param {number} [fileQuery.template] - preview template identifier. Example: 1.
87
+ * @returns {Promise<any | IError>} Returns a promise that resolves to the result of the deletion operation or an error object if there was an issue.
88
+ * @throws {IError} When isShell=false and an error occurs during the fetch
89
+ */
90
+ async delete(filename, fileQuery) {
91
+ const query = { ...this._defaultQuery, ...fileQuery };
92
+ const result = await this._fetchDelete(`?filename=${filename}&` + this._queryParamsToString(query));
93
+ return result;
94
+ }
95
+ /**
96
+ * Create a File object from a URL.
97
+ * @param {string} url - The URL to fetch the file from.
98
+ * @param {string} filename - The name to give the created file.
99
+ * @param {string} [mimeType] - Optional MIME type for the file.
100
+ * @returns {Promise<File>} A promise that resolves to a File object.
101
+ */
102
+ async createFileFromUrl(url, filename, mimeType) {
103
+ // eslint-disable-next-line no-undef
104
+ const response = await fetch(url);
105
+ const blob = await response.blob();
106
+ const file = new File([blob], filename, { type: mimeType || blob.type });
107
+ return file;
108
+ }
109
+ /**
110
+ * Get file by parameters.
111
+ * @handleName getFile
112
+ * @param {number} id - Object identifier, from which the file is uploaded, determines the folder name in the storage. Example: 3787.
113
+ * @param {string} type - Type, determines the folder name in the storage. Example: "page".
114
+ * @param {string} entity - Entity name, from which the file is uploaded, determines the folder name in the storage. Example: "editor".
115
+ * @param {string} filename - Filename. Example: "file.png".
116
+ * @param {string} [template] - Preview template identifier. Example: 1.
117
+ * @returns {Promise<any | IError>} Returns a promise that resolves to a Blob object containing the file data or an error object if there was an issue.
118
+ * @throws {IError} When isShell=false and an error occurs during the fetch
119
+ */
120
+ async getFile(id, type, entity, filename, template) {
121
+ // eslint-disable-next-line no-undef
122
+ const response = await fetch(this._getFullPath(`?id=${id}&type=${type}&entity=${entity}${`&filename=${filename}`}${template ? `&template=${template}` : ''}`), {
123
+ method: 'GET',
124
+ headers: {
125
+ 'Content-Type': 'application/json',
126
+ 'x-app-token': this.state.token,
127
+ },
128
+ });
129
+ return response;
130
+ }
131
+ }
132
+ exports.default = FileUploadingApi;
@@ -0,0 +1,117 @@
1
+ import type { IError } from '../base/utils';
2
+ /**
3
+ * Interface for uploading, deleting, and retrieving files in the CMS.
4
+ * @interface IFileUploading
5
+ * @property {Function} upload - Upload file from CMS.
6
+ * @property {Function} delete - Delete file from CMS.
7
+ * @property {Function} getFile - Get file by parameters.
8
+ * @description This interface defines methods for uploading, deleting, and retrieving files in the CMS.
9
+ */
10
+ interface IFileUploading {
11
+ /**
12
+ * Create a File object from a URL.
13
+ * @param {string} url - The URL to fetch the file from.
14
+ * @param {string} filename - The name to give the created file.
15
+ * @param {string} [mimeType] - Optional MIME type for the file.
16
+ * @returns {Promise<File>} A promise that resolves to a File object.
17
+ */
18
+ createFileFromUrl(url: string, filename: string, mimeType?: string): Promise<File>;
19
+ /**
20
+ * Upload file function.
21
+ * @handleName upload
22
+ * @param {File | Blob} file - File to upload. Example: `new File(["content"], "file.png", {"type": "image/png"})`
23
+ * @param {IUploadingQuery} [fileQuery] - Optional set query parameters.
24
+ * @example
25
+ {
26
+ "type": "page",
27
+ "entity": "editor",
28
+ "id": 3787,
29
+ "width": 0,
30
+ "height": 0,
31
+ "compress": true,
32
+ "template": 1
33
+ }
34
+ * @param {string} [fileQuery.type] - Type, determines the folder name in the storage. Example: "page".
35
+ * @param {string} [fileQuery.entity] - Entity name from which the file is uploaded, determines the folder name in the storage. Example: "editor".
36
+ * @param {number} [fileQuery.id] - Identifier of the object from which the file is uploaded, determines the folder name in the storage. Example: 3787.
37
+ * @param {number} [fileQuery.width] - Optional width parameter. Example: 0.
38
+ * @param {number} [fileQuery.height] - Optional height parameter. Example: 0.
39
+ * @param {boolean} [fileQuery.compress] - Optional flag of optimization (compression) for images. Example: true.
40
+ * @param {any} [fileQuery.template] - preview template identifier. Example: 1.
41
+ * @returns {IUploadingReturn[]} Uploads a file to an Amazon S3-compatible cloud file storage.
42
+ * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
43
+ */
44
+ upload(file: File | Blob, fileQuery?: IUploadingQuery): Promise<IUploadingReturn[] | IError>;
45
+ /**
46
+ * Deletes a file from the cloud file storage.
47
+ * @handleName delete
48
+ * @param {string} [filename] - File name. Example: "file.png".
49
+ * @param {IUploadingQuery} [fileQuery] - Optional set query parameters.
50
+ * @example
51
+ {
52
+ "type": "page",
53
+ "entity": "editor",
54
+ "id": 3787,
55
+ "template": 1
56
+ }
57
+ * @param {string} [fileQuery.type] - Type, determines the folder name in the storage. Example: "page".
58
+ * @param {string} [fileQuery.entity] - Entity name from which the file is uploaded, determines the folder name in the storage. Example: "editor".
59
+ * @param {number} [fileQuery.id] - Identifier of the object from which the file is uploaded, determines the folder name in the storage. Example: 3787.
60
+ * @param {number} [fileQuery.template] - preview template identifier. Example: 1.
61
+ * @returns {any} Returns a promise that resolves to the result of the deletion operation or an error object if there was an issue.
62
+ * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
63
+ */
64
+ delete(filename: string, fileQuery?: IUploadingQuery): Promise<any | IError>;
65
+ /**
66
+ * Get file by parameters.
67
+ * @handleName getFile
68
+ * @param {number} id - Object identifier, from which the file is uploaded, determines the folder name in the storage. Example: 3787.
69
+ * @param {string} type - Type, determines the folder name in the storage. Example: "page".
70
+ * @param {string} entity - Entity name, from which the file is uploaded, determines the folder name in the storage. Example: "editor".
71
+ * @param {string} filename - Filename. Example: "file.png".
72
+ * @param {string} [template] - Preview template identifier. Example: 1.
73
+ * @returns {any} Returns a promise that resolves to a Blob object containing the file data or an error object if there was an issue.
74
+ * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
75
+ */
76
+ getFile(id: number, type: string, entity: string, filename: string, template?: string): Promise<any | IError>;
77
+ }
78
+ /**
79
+ * Represents a file entity that may contain a file object or a path as a string.
80
+ * @interface IFileEntity
81
+ * @property {File | string | null} file - File object or string representing the file path. Example: new File(["content"], "file.png", { "type": "image/png" }) or "/path/to/file.png".
82
+ * @description Represents a file entity that may contain a file object or a path as a string.
83
+ */
84
+ interface IFileEntity {
85
+ file: File | string | null;
86
+ }
87
+ /**
88
+ * Represents a query for uploading files, including type, entity, and optional parameters like width, height, and compression.
89
+ * @interface IUploadingQuery
90
+ * @property {string} type - Type, determines the folder name in the storage. Example: "page".
91
+ * @property {string} entity - Entity name from which the file is uploaded, determines the folder name in the storage. Example: "editor".
92
+ * @property {number} id - Identifier of the object from which the file is uploaded, determines the folder name in the storage. Example: 3787.
93
+ * @property {number} [width] - Width parameter. Example: 0.
94
+ * @property {number} [height] - Height parameter. Example: 0.
95
+ * @property {boolean} [compress] - Flag of optimization (compression) for images. Example: true.
96
+ * @description Represents a query for uploading files, including type, entity, and optional parameters like width, height, and compression.
97
+ */
98
+ interface IUploadingQuery {
99
+ type: string | null;
100
+ entity: string | null;
101
+ id: number | null;
102
+ [key: string]: string | number | boolean | null;
103
+ }
104
+ /**
105
+ * Represents the return value of an uploading operation, including the filename, download link, and file size.
106
+ * @interface IUploadingReturn
107
+ * @property {string} filename - Filename with relative path. Example: "uploads/file.png".
108
+ * @property {string} downloadLink - Link for downloading the file. Example: "https://example.com/uploads/file.png".
109
+ * @property {number} size - Size of the file in bytes. Example: 1024.
110
+ * @description Represents the return value of an uploading operation, including the filename, download link, and file size.
111
+ */
112
+ interface IUploadingReturn {
113
+ filename: string;
114
+ downloadLink: string;
115
+ size: number;
116
+ }
117
+ export type { IFileEntity, IFileUploading, IUploadingQuery, IUploadingReturn };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Validation schemas for FileUploading module
3
+ * @description Zod schemas for validating file uploading-related API responses
4
+ */
5
+ import { z } from 'zod';
6
+ /**
7
+ * Upload return schema
8
+ * Includes filename, downloadLink, and size
9
+ */
10
+ export declare const UploadingReturnSchema: z.ZodObject<{
11
+ filename: z.ZodString;
12
+ downloadLink: z.ZodString;
13
+ size: z.ZodNumber;
14
+ }, z.core.$strip>;
15
+ /**
16
+ * Upload response schema (array of upload results)
17
+ */
18
+ export declare const UploadResponseSchema: z.ZodArray<z.ZodObject<{
19
+ filename: z.ZodString;
20
+ downloadLink: z.ZodString;
21
+ size: z.ZodNumber;
22
+ }, z.core.$strip>>;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UploadResponseSchema = exports.UploadingReturnSchema = void 0;
4
+ /**
5
+ * Validation schemas for FileUploading module
6
+ * @description Zod schemas for validating file uploading-related API responses
7
+ */
8
+ const zod_1 = require("zod");
9
+ /**
10
+ * Upload return schema
11
+ * Includes filename, downloadLink, and size
12
+ */
13
+ exports.UploadingReturnSchema = zod_1.z.object({
14
+ filename: zod_1.z.string(),
15
+ downloadLink: zod_1.z.string(),
16
+ size: zod_1.z.number(),
17
+ });
18
+ /**
19
+ * Upload response schema (array of upload results)
20
+ */
21
+ exports.UploadResponseSchema = zod_1.z.array(exports.UploadingReturnSchema);
@@ -0,0 +1,42 @@
1
+ import AsyncModules from '../base/asyncModules';
2
+ import type StateModule from '../base/stateModule';
3
+ import type { IError } from '../base/utils';
4
+ import type { IForms, IFormsEntity } from './formsInterfaces';
5
+ /**
6
+ * Controllers for forms objects
7
+ * @class FormsApi
8
+ * @augments AsyncModules
9
+ * @implements {IForms}
10
+ * @description This class provides methods to interact with forms, including retrieving all forms and getting a form by its marker.
11
+ */
12
+ export default class FormsApi extends AsyncModules implements IForms {
13
+ protected state: StateModule;
14
+ protected _url: string;
15
+ /**
16
+ * Initializes the FormsApi with the provided state module.
17
+ * @class
18
+ * @class FormsApi
19
+ * @param {StateModule} state - The state module containing configuration data.
20
+ * @description Constructor initializes the FormsApi with a given state.
21
+ */
22
+ constructor(state: StateModule);
23
+ /**
24
+ * Get all forms.
25
+ * @handleName getAllForms
26
+ * @param {string} [langCode] - Language code. Default: "en_US".
27
+ * @param {number} [offset] - Parameter for pagination. Default: 0.
28
+ * @param {number} [limit] - Parameter for pagination. Default: 30.
29
+ * @returns {Promise<IFormsEntity[] | IError>} Returns array for all objects of type FormEntity.
30
+ * @throws {IError} When isShell=false and an error occurs during the fetch
31
+ */
32
+ getAllForms(langCode?: string, offset?: number, limit?: number): Promise<IFormsEntity[] | IError>;
33
+ /**
34
+ * Get one form by form marker.
35
+ * @handleName getFormByMarker
36
+ * @param {string} marker - Marker of form. Example: "contact_form".
37
+ * @param {string} [langCode] - Language code. Default: "en_US".
38
+ * @returns {Promise<IFormsEntity | IError>} Returns object of type FormEntity.
39
+ * @throws {IError} When isShell=false and an error occurs during the fetch
40
+ */
41
+ getFormByMarker(marker: string, langCode?: string): Promise<IFormsEntity | IError>;
42
+ }
@@ -0,0 +1,57 @@
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;
@@ -0,0 +1,132 @@
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 };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,50 @@
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
+ version: z.ZodNumber;
11
+ position: z.ZodNumber;
12
+ processingType: z.ZodString;
13
+ type: z.ZodNullable<z.ZodString>;
14
+ attributeSetId: z.ZodNullable<z.ZodNumber>;
15
+ templateId: z.ZodNullable<z.ZodNumber>;
16
+ attributes: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodAny>, z.ZodRecord<z.ZodString, z.ZodAny>]>>;
17
+ moduleFormConfigs: z.ZodOptional<z.ZodArray<z.ZodAny>>;
18
+ }, z.core.$strip>;
19
+ /**
20
+ * Forms response schema (array of forms)
21
+ */
22
+ export declare const FormsResponseSchema: z.ZodArray<z.ZodObject<{
23
+ id: z.ZodNumber;
24
+ identifier: z.ZodString;
25
+ localizeInfos: z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodArray<z.ZodAny>]>;
26
+ version: z.ZodNumber;
27
+ position: z.ZodNumber;
28
+ processingType: z.ZodString;
29
+ type: z.ZodNullable<z.ZodString>;
30
+ attributeSetId: z.ZodNullable<z.ZodNumber>;
31
+ templateId: z.ZodNullable<z.ZodNumber>;
32
+ attributes: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodAny>, z.ZodRecord<z.ZodString, z.ZodAny>]>>;
33
+ moduleFormConfigs: z.ZodOptional<z.ZodArray<z.ZodAny>>;
34
+ }, z.core.$strip>>;
35
+ /**
36
+ * Single form response schema
37
+ */
38
+ export declare const SingleFormSchema: z.ZodObject<{
39
+ id: z.ZodNumber;
40
+ identifier: z.ZodString;
41
+ localizeInfos: z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodArray<z.ZodAny>]>;
42
+ version: z.ZodNumber;
43
+ position: z.ZodNumber;
44
+ processingType: z.ZodString;
45
+ type: z.ZodNullable<z.ZodString>;
46
+ attributeSetId: z.ZodNullable<z.ZodNumber>;
47
+ templateId: z.ZodNullable<z.ZodNumber>;
48
+ attributes: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodAny>, z.ZodRecord<z.ZodString, z.ZodAny>]>>;
49
+ moduleFormConfigs: z.ZodOptional<z.ZodArray<z.ZodAny>>;
50
+ }, z.core.$strip>;
@@ -0,0 +1,31 @@
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
+ version: zod_1.z.number(),
14
+ position: zod_1.z.number(),
15
+ processingType: zod_1.z.string(),
16
+ type: zod_1.z.string().nullable(),
17
+ attributeSetId: zod_1.z.number().nullable(),
18
+ templateId: zod_1.z.number().nullable(),
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
+ moduleFormConfigs: zod_1.z.array(zod_1.z.any()).optional(),
23
+ });
24
+ /**
25
+ * Forms response schema (array of forms)
26
+ */
27
+ exports.FormsResponseSchema = zod_1.z.array(exports.FormEntitySchema);
28
+ /**
29
+ * Single form response schema
30
+ */
31
+ exports.SingleFormSchema = exports.FormEntitySchema;