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,97 +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 jsdoc/reject-any-type */
7
- /* eslint-disable @typescript-eslint/no-explicit-any */
8
- const asyncModules_1 = __importDefault(require("../base/asyncModules"));
9
- /**
10
- * Controllers for working with events
11
- * @handle /api/content/events
12
- * @class EventsApi
13
- * @augments AsyncModules
14
- * @implements {IEvents}
15
- * @description This class provides methods to interact with events, including subscribing and unsubscribing to product events, and retrieving all subscriptions.
16
- */
17
- class EventsApi extends asyncModules_1.default {
18
- /**
19
- * Initializes the EventsApi with the provided state module.
20
- * @class EventsApi
21
- * @augments AsyncModules
22
- * @implements {IEvents}
23
- * @param {StateModule} state - The state module containing the base URL and other configurations.
24
- * @description Initializes the EventsApi with the provided state module.
25
- */
26
- constructor(state) {
27
- super(state);
28
- this._url = state.url + '/api/content/events';
29
- }
30
- /**
31
- * Return all subscriptions to product.
32
- * @handleName getAllSubscriptions
33
- * @param {number} [offset] - Optional offset for pagination. Default: 0.
34
- * @param {number} [limit] - Optional limit for pagination. Default: 30.
35
- * @returns {Promise<ISubscriptions | IError>} Returns an object containing all subscriptions or an error object if there was an issue.
36
- * @throws {IError} When isShell=false and an error occurs during the fetch
37
- * @description This method requires user authorization.
38
- * @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
39
- */
40
- async getAllSubscriptions(offset = 0, limit = 30) {
41
- const query = {
42
- offset,
43
- limit,
44
- };
45
- const result = await this._fetchGet(`/subscriptions?` + this._queryParamsToString(query));
46
- return result;
47
- }
48
- /**
49
- * Subscribing to an event on a product.
50
- * @handleName subscribeByMarker
51
- * @param {string} marker - Event marker. Example: "product_price_change".
52
- * @param {number} productId - Product id. Example: 12345.
53
- * @param {string} [langCode] - Language code. Default: "en_US".=
54
- * @returns {Promise<boolean | IError>} Returns true if subscription was successful, or an error object if there was an issue.
55
- * @throws {IError} When isShell=false and an error occurs during the fetch
56
- * @description This method requires user authorization.
57
- * @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
58
- */
59
- async subscribeByMarker(marker, productId, langCode = this.state.lang) {
60
- const body = {
61
- locale: langCode,
62
- productId,
63
- };
64
- try {
65
- await this._fetchPost(`/subscribe/marker/${marker}`, body);
66
- return true;
67
- }
68
- catch (e) {
69
- return e;
70
- }
71
- }
72
- /**
73
- * Unsubscribing to an event on a product.
74
- * @handleName unsubscribeByMarker
75
- * @param {string} marker - The marker of the event to unsubscribe from. Example: "product_price_change".
76
- * @param {number} productId - The ID of the product to unsubscribe from. Example: 12345.
77
- * @param {string} [langCode] - Language code. Default: "en_US".
78
- * @returns {Promise<any | IError>} - Returns a promise that resolves to the result of the unsubscription operation or an error object if there was an issue.
79
- * @throws {IError} When isShell=false and an error occurs during the fetch
80
- * @description This method requires user authorization.
81
- * @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
82
- */
83
- async unsubscribeByMarker(marker, productId, langCode = this.state.lang) {
84
- const body = {
85
- productId: productId,
86
- locale: langCode,
87
- };
88
- try {
89
- await this._fetchDelete(`/unsubscribe/marker/${marker}`, body);
90
- return true;
91
- }
92
- catch (e) {
93
- return e;
94
- }
95
- }
96
- }
97
- exports.default = EventsApi;
@@ -1,87 +0,0 @@
1
- import type { IError } from '../base/utils';
2
- /**
3
- * Interface for managing event subscriptions related to products.
4
- * @interface IEvents
5
- * @description This interface defines methods for managing event subscriptions related to products.
6
- */
7
- interface IEvents {
8
- /**
9
- * Retrieves all subscriptions to products.
10
- * @handleName getAllSubscriptions
11
- * @param {number} [offset] - Optional offset for pagination. Default: 0.
12
- * @param {number} [limit] - Optional limit for pagination. Default: 30.
13
- * @returns {Promise<ISubscriptions | IError>} A promise that resolves to a subscriptions object or an error.
14
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
15
- * @description This method retrieves all subscriptions to products.
16
- */
17
- getAllSubscriptions(offset?: number, limit?: number): Promise<ISubscriptions | IError>;
18
- /**
19
- * Subscribes to an event on a product by its marker.
20
- * @handleName subscribeByMarker
21
- * @param {string} marker - The marker identifying the event. Example: "product_price_change".
22
- * @param {number} productId - The ID of the product to subscribe to. Example: 12345.
23
- * @param {string} [langCode] - Optional language code for localization. Default: "en_US".
24
- * @returns {Promise<boolean | IError>} A promise that resolves to any type or an error.
25
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
26
- * @description This method subscribes to an event on a product by its marker.
27
- */
28
- subscribeByMarker(marker: string, productId: number, langCode?: string): Promise<boolean | IError>;
29
- /**
30
- * Unsubscribes from an event on a product by its marker.
31
- * @handleName unsubscribeByMarker
32
- * @param {string} marker - The marker identifying the event. Example: "product_price_change".
33
- * @param {number} productId - The ID of the product to unsubscribe from. Example: 12345.
34
- * @param {string} [langCode] - Optional language code for localization. Default: "en_US".
35
- * @returns {Promise<boolean | IError>} A promise that resolves to any type or an error.
36
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
37
- * @description This method unsubscribes from an event on a product by its marker.
38
- */
39
- unsubscribeByMarker(marker: string, productId: number, langCode?: string): Promise<boolean | IError>;
40
- }
41
- /**
42
- * Represents a response from the events API containing a total count and an array of subscription items.
43
- * @interface ISubscriptions
44
- * @property {number} total - Total number of found records. Example: 100.
45
- * @property {ISubscriptionItem[]} items - Array of subscription items, each containing an event marker and a product ID.
46
- * @example
47
- [
48
- {
49
- eventMarker: 'product_price_change',
50
- productId: 12345
51
- },
52
- {
53
- eventMarker: 'product_stock_update',
54
- productId: 67890
55
- }
56
- ]
57
- * @property { string } items.eventMarker - Event marker.
58
- * @property { number } items.productId - Product ID.
59
- * @description Represents a response from the events API containing a total count and an array of subscription items.
60
- */
61
- interface ISubscriptions {
62
- total: number;
63
- items: Array<ISubscriptionItem>;
64
- }
65
- /**
66
- * Represents item from the events API.
67
- * @interface ISubscriptionItem
68
- * @property { string } eventMarker -Event marker.
69
- * @property { number } productId - Product ID.
70
- * @description Represents item from the events API.
71
- */
72
- interface ISubscriptionItem {
73
- eventMarker: string;
74
- productId: number;
75
- }
76
- /**
77
- * Interface for the body of the subscribe methods.
78
- * @interface ISubscribeBody
79
- * @property {string} locale - Locale of the user. Example: "en_US".
80
- * @property {number} productId - Product ID. Example: 12345.
81
- * @description Represents a body for the subscribe methods, containing the locale and product ID.
82
- */
83
- interface ISubscribeBody {
84
- locale: string;
85
- productId: number;
86
- }
87
- export type { IEvents, ISubscribeBody, ISubscriptions };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,88 +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 { IFileUploading, IUploadingQuery, IUploadingReturn } from './fileUploadingInterfaces';
5
- /**
6
- * Controllers for working with file uploading
7
- * @handle /api/content/files
8
- * @class FileUploadingApi
9
- * @augments AsyncModules
10
- * @implements {IFileUploading}
11
- * @description This class provides methods to upload and delete files in a cloud file storage, as well as retrieve files by parameters.
12
- */
13
- export default class FileUploadingApi extends AsyncModules implements IFileUploading {
14
- protected state: StateModule;
15
- protected _url: string;
16
- /**
17
- * Constructs a new instance of the FileUploadingApi class.
18
- */
19
- constructor(state: StateModule);
20
- /** FileUploadingApi class */
21
- private _defaultQuery;
22
- /**
23
- * Upload file function.
24
- * @handleName upload
25
- * @param {File | Blob} file - File to upload. Example: `new File(["content"], "file.png", {"type": "image/png"})`
26
- * @param {IUploadingQuery} [fileQuery] - Optional set query parameters.
27
- * @example
28
- {
29
- "type": "page",
30
- "entity": "editor",
31
- "id": 3787,
32
- "width": 0,
33
- "height": 0,
34
- "compress": true,
35
- "template": 1
36
- }
37
- * @param {string} [fileQuery.type] - Type, determines the folder name in the storage. Example: "page".
38
- * @param {string} [fileQuery.entity] - Entity name from which the file is uploaded, determines the folder name in the storage. Example: "editor".
39
- * @param {number} [fileQuery.id] - Identifier of the object from which the file is uploaded, determines the folder name in the storage. Example: 3787.
40
- * @param {number} [fileQuery.width] - Optional width parameter. Example: 0.
41
- * @param {number} [fileQuery.height] - Optional height parameter. Example: 0.
42
- * @param {boolean} [fileQuery.compress] - Optional flag of optimization (compression) for images. Example: true.
43
- * @param {any} [fileQuery.template] - preview template identifier. Example: 1.
44
- * @returns {Promise<IUploadingReturn[] | IError>} Uploads a file to an Amazon S3-compatible cloud file storage.
45
- * @throws {IError} When isShell=false and an error occurs during the fetch
46
- */
47
- upload(file: File | Blob, fileQuery?: IUploadingQuery): Promise<IUploadingReturn[] | IError>;
48
- /**
49
- * Deletes a file from the cloud file storage.
50
- * @handleName delete
51
- * @param {string} filename - File name. Example: "file.png".
52
- * @param {IUploadingQuery} [fileQuery] - Optional set query parameters.
53
- * @example
54
- {
55
- "type": "page",
56
- "entity": "editor",
57
- "id": 3787,
58
- "template": 1
59
- }
60
- * @param {string} [fileQuery.type] - Type, determines the folder name in the storage. Example: "page".
61
- * @param {string} [fileQuery.entity] - Entity name from which the file is uploaded, determines the folder name in the storage. Example: "editor".
62
- * @param {number} [fileQuery.id] - Identifier of the object from which the file is uploaded, determines the folder name in the storage. Example: 3787.
63
- * @param {number} [fileQuery.template] - preview template identifier. Example: 1.
64
- * @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.
65
- * @throws {IError} When isShell=false and an error occurs during the fetch
66
- */
67
- delete(filename: string, fileQuery?: IUploadingQuery): Promise<any | IError>;
68
- /**
69
- * Create a File object from a URL.
70
- * @param {string} url - The URL to fetch the file from.
71
- * @param {string} filename - The name to give the created file.
72
- * @param {string} [mimeType] - Optional MIME type for the file.
73
- * @returns {Promise<File>} A promise that resolves to a File object.
74
- */
75
- createFileFromUrl(url: string, filename: string, mimeType?: string): Promise<File>;
76
- /**
77
- * Get file by parameters.
78
- * @handleName getFile
79
- * @param {number} id - Object identifier, from which the file is uploaded, determines the folder name in the storage. Example: 3787.
80
- * @param {string} type - Type, determines the folder name in the storage. Example: "page".
81
- * @param {string} entity - Entity name, from which the file is uploaded, determines the folder name in the storage. Example: "editor".
82
- * @param {string} filename - Filename. Example: "file.png".
83
- * @param {string} [template] - Preview template identifier. Example: 1.
84
- * @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.
85
- * @throws {IError} When isShell=false and an error occurs during the fetch
86
- */
87
- getFile(id: number, type: string, entity: string, filename: string, template?: string): Promise<any | IError>;
88
- }
@@ -1,132 +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 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;
@@ -1,117 +0,0 @@
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 };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,22 +0,0 @@
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>>;
@@ -1,21 +0,0 @@
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);
@@ -1,42 +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 { 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
- }