oneentry 1.0.142 → 1.0.144

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 (150) hide show
  1. package/configure.js +2 -2
  2. package/dist/admins/adminsApi.d.ts +50 -0
  3. package/dist/admins/adminsApi.js +65 -0
  4. package/dist/admins/adminsInterfaces.d.ts +98 -0
  5. package/dist/admins/adminsInterfaces.js +2 -0
  6. package/dist/admins/adminsSchemas.d.ts +30 -0
  7. package/dist/admins/adminsSchemas.js +27 -0
  8. package/dist/attribute-sets/attributeSetsApi.d.ts +63 -0
  9. package/dist/attribute-sets/attributeSetsApi.js +98 -0
  10. package/dist/attribute-sets/attributeSetsInterfaces.d.ts +185 -0
  11. package/dist/attribute-sets/attributeSetsInterfaces.js +2 -0
  12. package/dist/attribute-sets/attributeSetsSchemas.d.ts +90 -0
  13. package/dist/attribute-sets/attributeSetsSchemas.js +74 -0
  14. package/dist/auth-provider/authProviderApi.d.ts +249 -0
  15. package/dist/auth-provider/authProviderApi.js +354 -0
  16. package/dist/auth-provider/authProviderSchemas.d.ts +131 -0
  17. package/dist/auth-provider/authProviderSchemas.js +82 -0
  18. package/dist/auth-provider/authProvidersInterfaces.d.ts +412 -0
  19. package/dist/auth-provider/authProvidersInterfaces.js +2 -0
  20. package/dist/base/asyncModules.d.ts +80 -0
  21. package/dist/base/asyncModules.js +448 -0
  22. package/dist/base/result.d.ts +39 -0
  23. package/dist/base/result.js +154 -0
  24. package/dist/base/stateModule.d.ts +41 -0
  25. package/dist/base/stateModule.js +128 -0
  26. package/dist/base/syncModules.d.ts +286 -0
  27. package/dist/base/syncModules.js +716 -0
  28. package/dist/base/utils.d.ts +197 -0
  29. package/dist/base/utils.js +2 -0
  30. package/dist/base/validation.d.ts +118 -0
  31. package/dist/base/validation.js +132 -0
  32. package/dist/blocks/blocksApi.d.ts +88 -0
  33. package/dist/blocks/blocksApi.js +207 -0
  34. package/dist/blocks/blocksInterfaces.d.ts +179 -0
  35. package/dist/blocks/blocksInterfaces.js +2 -0
  36. package/dist/blocks/blocksSchemas.d.ts +195 -0
  37. package/dist/blocks/blocksSchemas.js +43 -0
  38. package/dist/discounts/discountsApi.d.ts +76 -0
  39. package/dist/discounts/discountsApi.js +116 -0
  40. package/dist/discounts/discountsInterfaces.d.ts +217 -0
  41. package/dist/discounts/discountsInterfaces.js +2 -0
  42. package/dist/events/eventsApi.d.ts +60 -0
  43. package/dist/events/eventsApi.js +97 -0
  44. package/dist/events/eventsInterfaces.d.ts +87 -0
  45. package/dist/events/eventsInterfaces.js +2 -0
  46. package/dist/file-uploading/fileUploadingApi.d.ts +88 -0
  47. package/dist/file-uploading/fileUploadingApi.js +129 -0
  48. package/dist/file-uploading/fileUploadingInterfaces.d.ts +114 -0
  49. package/dist/file-uploading/fileUploadingInterfaces.js +2 -0
  50. package/dist/file-uploading/fileUploadingSchemas.d.ts +22 -0
  51. package/dist/file-uploading/fileUploadingSchemas.js +21 -0
  52. package/dist/forms/formsApi.d.ts +42 -0
  53. package/dist/forms/formsApi.js +57 -0
  54. package/dist/forms/formsInterfaces.d.ts +144 -0
  55. package/dist/forms/formsInterfaces.js +2 -0
  56. package/dist/forms/formsSchemas.d.ts +53 -0
  57. package/dist/forms/formsSchemas.js +34 -0
  58. package/dist/forms-data/formsDataApi.d.ts +106 -0
  59. package/dist/forms-data/formsDataApi.js +189 -0
  60. package/dist/forms-data/formsDataInterfaces.d.ts +522 -0
  61. package/dist/forms-data/formsDataInterfaces.js +2 -0
  62. package/dist/forms-data/formsDataSchemas.d.ts +115 -0
  63. package/dist/forms-data/formsDataSchemas.js +86 -0
  64. package/dist/general-types/generalTypesApi.d.ts +28 -0
  65. package/dist/general-types/generalTypesApi.js +38 -0
  66. package/dist/general-types/generalTypesInterfaces.d.ts +29 -0
  67. package/dist/general-types/generalTypesInterfaces.js +2 -0
  68. package/dist/general-types/generalTypesSchemas.d.ts +52 -0
  69. package/dist/general-types/generalTypesSchemas.js +36 -0
  70. package/dist/index.d.ts +124 -0
  71. package/dist/index.js +103 -0
  72. package/dist/integration-collections/integrationCollectionsApi.d.ts +163 -0
  73. package/dist/integration-collections/integrationCollectionsApi.js +220 -0
  74. package/dist/integration-collections/integrationCollectionsInterfaces.d.ts +313 -0
  75. package/dist/integration-collections/integrationCollectionsInterfaces.js +2 -0
  76. package/dist/integration-collections/integrationCollectionsSchemas.d.ts +80 -0
  77. package/dist/integration-collections/integrationCollectionsSchemas.js +61 -0
  78. package/dist/locales/localesApi.d.ts +27 -0
  79. package/dist/locales/localesApi.js +37 -0
  80. package/dist/locales/localesInterfaces.d.ts +40 -0
  81. package/dist/locales/localesInterfaces.js +2 -0
  82. package/dist/locales/localesSchemas.d.ts +32 -0
  83. package/dist/locales/localesSchemas.js +26 -0
  84. package/dist/menus/menusApi.d.ts +29 -0
  85. package/dist/menus/menusApi.js +39 -0
  86. package/dist/menus/menusInterfaces.d.ts +87 -0
  87. package/dist/menus/menusInterfaces.js +3 -0
  88. package/dist/menus/menusSchemas.d.ts +16 -0
  89. package/dist/menus/menusSchemas.js +28 -0
  90. package/dist/orders/ordersApi.d.ts +175 -0
  91. package/dist/orders/ordersApi.js +247 -0
  92. package/dist/orders/ordersInterfaces.d.ts +593 -0
  93. package/dist/orders/ordersInterfaces.js +2 -0
  94. package/dist/orders/ordersSchemas.d.ts +120 -0
  95. package/dist/orders/ordersSchemas.js +101 -0
  96. package/dist/pages/pagesApi.d.ts +151 -0
  97. package/dist/pages/pagesApi.js +390 -0
  98. package/dist/pages/pagesInterfaces.d.ts +286 -0
  99. package/dist/pages/pagesInterfaces.js +2 -0
  100. package/dist/pages/pagesSchemas.d.ts +85 -0
  101. package/dist/pages/pagesSchemas.js +46 -0
  102. package/dist/payments/paymentsApi.d.ts +82 -0
  103. package/dist/payments/paymentsApi.js +121 -0
  104. package/dist/payments/paymentsInterfaces.d.ts +200 -0
  105. package/dist/payments/paymentsInterfaces.js +2 -0
  106. package/dist/payments/paymentsSchemas.d.ts +100 -0
  107. package/dist/payments/paymentsSchemas.js +65 -0
  108. package/dist/product-statuses/productStatusesApi.d.ts +47 -0
  109. package/dist/product-statuses/productStatusesApi.js +70 -0
  110. package/dist/product-statuses/productStatusesInterfaces.d.ts +62 -0
  111. package/dist/product-statuses/productStatusesInterfaces.js +2 -0
  112. package/dist/product-statuses/productStatusesSchemas.d.ts +34 -0
  113. package/dist/product-statuses/productStatusesSchemas.js +30 -0
  114. package/dist/products/productsApi.d.ts +366 -0
  115. package/dist/products/productsApi.js +458 -0
  116. package/dist/products/productsInterfaces.d.ts +593 -0
  117. package/dist/products/productsInterfaces.js +2 -0
  118. package/dist/products/productsSchemas.d.ts +200 -0
  119. package/dist/products/productsSchemas.js +98 -0
  120. package/dist/sitemap/sitemapApi.d.ts +35 -0
  121. package/dist/sitemap/sitemapApi.js +45 -0
  122. package/dist/sitemap/sitemapInterfaces.d.ts +40 -0
  123. package/dist/sitemap/sitemapInterfaces.js +2 -0
  124. package/dist/system/systemApi.d.ts +43 -0
  125. package/dist/system/systemApi.js +56 -0
  126. package/dist/system/systemInterfaces.d.ts +29 -0
  127. package/dist/system/systemInterfaces.js +2 -0
  128. package/dist/templates/templatesApi.d.ts +49 -0
  129. package/dist/templates/templatesApi.js +75 -0
  130. package/dist/templates/templatesInterfaces.d.ts +67 -0
  131. package/dist/templates/templatesInterfaces.js +2 -0
  132. package/dist/templates/templatesSchemas.d.ts +48 -0
  133. package/dist/templates/templatesSchemas.js +31 -0
  134. package/dist/templates-preview/templatesPreviewApi.d.ts +38 -0
  135. package/dist/templates-preview/templatesPreviewApi.js +53 -0
  136. package/dist/templates-preview/templatesPreviewInterfaces.d.ts +119 -0
  137. package/dist/templates-preview/templatesPreviewInterfaces.js +2 -0
  138. package/dist/templates-preview/templatesPreviewSchemas.d.ts +83 -0
  139. package/dist/templates-preview/templatesPreviewSchemas.js +48 -0
  140. package/dist/users/usersApi.d.ts +143 -0
  141. package/dist/users/usersApi.js +171 -0
  142. package/dist/users/usersInterfaces.d.ts +231 -0
  143. package/dist/users/usersInterfaces.js +2 -0
  144. package/dist/users/usersSchemas.d.ts +38 -0
  145. package/dist/users/usersSchemas.js +28 -0
  146. package/dist/web-socket/wsApi.d.ts +25 -0
  147. package/dist/web-socket/wsApi.js +45 -0
  148. package/dist/web-socket/wsInterfaces.d.ts +16 -0
  149. package/dist/web-socket/wsInterfaces.js +2 -0
  150. package/package.json +2 -80
@@ -0,0 +1,76 @@
1
+ import AsyncModules from '../base/asyncModules';
2
+ import type StateModule from '../base/stateModule';
3
+ import type { IError } from '../base/utils';
4
+ import type { BonusTransactionType, IBonusTransactionEntity, ICouponValidationResult, IDiscountsApi, IDiscountsEntity, IDiscountsResponse } from './discountsInterfaces';
5
+ /**
6
+ * Controllers for working with events
7
+ * @handle /api/content/events
8
+ * @class DiscountsApi
9
+ * @augments AsyncModules
10
+ * @implements {IDiscountsApi}
11
+ * @description This class provides methods to interact with events, including subscribing and unsubscribing to product events, and retrieving all subscriptions.
12
+ */
13
+ export default class DiscountsApi extends AsyncModules implements IDiscountsApi {
14
+ protected state: StateModule;
15
+ protected _url: string;
16
+ /**
17
+ * Initializes the Constructor for DiscountsApi class with the provided state module.
18
+ * @class DiscountsApi
19
+ * @augments AsyncModules
20
+ * @implements {DiscountsApi}
21
+ * @param {StateModule} state - The state module containing the base URL and other configurations.
22
+ * @description Initializes the DiscountsApi with the provided state module.
23
+ */
24
+ constructor(state: StateModule);
25
+ /**
26
+ * Return all discounts.
27
+ * @handleName getAllDiscounts
28
+ * @param {string} [langCode] - Language code. Default: "en_US".
29
+ * @param {number} [offset] - Optional parameter for pagination. Default: 0.
30
+ * @param {number} [limit] - Optional parameter for pagination. Default: 30.
31
+ * @param {string} [type] - Optional parameter to filter discounts by type.
32
+ * @returns {Promise<IDiscountsResponse | IError>} Returns an object containing all discounts or an error object if there was an issue.
33
+ * @throws {IError} When isShell=false and an error occurs during the fetch
34
+ * @description Fetches all discounts from the server.
35
+ */
36
+ getAllDiscounts(langCode?: string, offset?: number, limit?: number, type?: 'DISCOUNT' | 'BONUS' | 'PERSONAL_DISCOUNT'): Promise<IDiscountsResponse | IError>;
37
+ /**
38
+ * Get discount by marker
39
+ * @handleName getDiscountByMarker
40
+ * @param {string} marker - Textual identifier of the discount storage object. Example: "discount_storage".
41
+ * @param {string} [langCode] - Language code. Default: "en_US".
42
+ * @returns {Promise<IDiscountsEntity | IError>} Returns an object containing discount by marker or an error object if there was an issue.
43
+ * @throws {IError} When isShell=false and an error occurs during the fetch
44
+ * @description Fetches a discount by its marker.
45
+ */
46
+ getDiscountByMarker(marker: string, langCode?: string): Promise<IDiscountsEntity | IError>;
47
+ /**
48
+ * Get bonus balance of the current user.
49
+ * @handleName getBonusBalance
50
+ * @returns {Promise<IDiscountsEntity | IError>} Returns bonus balance or an error object.
51
+ * @throws {IError} When isShell=false and an error occurs during the fetch
52
+ */
53
+ getBonusBalance(): Promise<IDiscountsEntity | IError>;
54
+ /**
55
+ * Get bonus transaction history of the current user.
56
+ * @handleName getBonusHistory
57
+ * @param {BonusTransactionType} [type] - Transaction type filter.
58
+ * @param {string} [dateFrom] - Start date filter.
59
+ * @param {string} [dateTo] - End date filter.
60
+ * @param {number} [discountId] - Discount id filter.
61
+ * @param {number} [moduleId] - Module id filter.
62
+ * @param {boolean} [isAdmin] - Admin filter.
63
+ * @returns {Promise<IBonusTransactionEntity[] | IError>} Returns array of bonus transactions or an error object.
64
+ * @throws {IError} When isShell=false and an error occurs during the fetch
65
+ */
66
+ getBonusHistory(type?: BonusTransactionType, dateFrom?: string, dateTo?: string, discountId?: number, moduleId?: number, isAdmin?: boolean): Promise<IBonusTransactionEntity[] | IError>;
67
+ /**
68
+ * Validate discounts coupon
69
+ * @handleName validateDiscountsCoupon
70
+ * @param {string} code - The coupon code to validate.
71
+ * @returns {Promise<ICouponValidationResult | IError>} Returns an coupon validation result or an error object if there was an issue.
72
+ * @throws {IError} When isShell=false and an error occurs during the fetch
73
+ * @description This function validates a coupon code and returns the result.
74
+ */
75
+ validateDiscountsCoupon(code: string): Promise<ICouponValidationResult | IError>;
76
+ }
@@ -0,0 +1,116 @@
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
+ /**
8
+ * Controllers for working with events
9
+ * @handle /api/content/events
10
+ * @class DiscountsApi
11
+ * @augments AsyncModules
12
+ * @implements {IDiscountsApi}
13
+ * @description This class provides methods to interact with events, including subscribing and unsubscribing to product events, and retrieving all subscriptions.
14
+ */
15
+ class DiscountsApi extends asyncModules_1.default {
16
+ /**
17
+ * Initializes the Constructor for DiscountsApi class with the provided state module.
18
+ * @class DiscountsApi
19
+ * @augments AsyncModules
20
+ * @implements {DiscountsApi}
21
+ * @param {StateModule} state - The state module containing the base URL and other configurations.
22
+ * @description Initializes the DiscountsApi with the provided state module.
23
+ */
24
+ constructor(state) {
25
+ super(state);
26
+ this._url = state.url + '/api/content/discounts';
27
+ }
28
+ /**
29
+ * Return all discounts.
30
+ * @handleName getAllDiscounts
31
+ * @param {string} [langCode] - Language code. Default: "en_US".
32
+ * @param {number} [offset] - Optional parameter for pagination. Default: 0.
33
+ * @param {number} [limit] - Optional parameter for pagination. Default: 30.
34
+ * @param {string} [type] - Optional parameter to filter discounts by type.
35
+ * @returns {Promise<IDiscountsResponse | IError>} Returns an object containing all discounts or an error object if there was an issue.
36
+ * @throws {IError} When isShell=false and an error occurs during the fetch
37
+ * @description Fetches all discounts from the server.
38
+ */
39
+ async getAllDiscounts(langCode = this.state.lang, offset = 0, limit = 30, type) {
40
+ const query = {
41
+ langCode,
42
+ offset,
43
+ limit,
44
+ type,
45
+ };
46
+ const data = await this._fetchGet(`?` + this._queryParamsToString(query));
47
+ return this._normalizeData(data);
48
+ }
49
+ /**
50
+ * Get discount by marker
51
+ * @handleName getDiscountByMarker
52
+ * @param {string} marker - Textual identifier of the discount storage object. Example: "discount_storage".
53
+ * @param {string} [langCode] - Language code. Default: "en_US".
54
+ * @returns {Promise<IDiscountsEntity | IError>} Returns an object containing discount by marker or an error object if there was an issue.
55
+ * @throws {IError} When isShell=false and an error occurs during the fetch
56
+ * @description Fetches a discount by its marker.
57
+ */
58
+ async getDiscountByMarker(marker, langCode = this.state.lang) {
59
+ const query = {
60
+ marker: '',
61
+ langCode,
62
+ };
63
+ const data = await this._fetchGet(`/marker/${marker}?` + this._queryParamsToString(query));
64
+ return this._normalizeData(data);
65
+ }
66
+ /**
67
+ * Get bonus balance of the current user.
68
+ * @handleName getBonusBalance
69
+ * @returns {Promise<IDiscountsEntity | IError>} Returns bonus balance or an error object.
70
+ * @throws {IError} When isShell=false and an error occurs during the fetch
71
+ */
72
+ async getBonusBalance() {
73
+ const data = await this._fetchGet(`/bonus-balance`);
74
+ return this._normalizeData(data);
75
+ }
76
+ /**
77
+ * Get bonus transaction history of the current user.
78
+ * @handleName getBonusHistory
79
+ * @param {BonusTransactionType} [type] - Transaction type filter.
80
+ * @param {string} [dateFrom] - Start date filter.
81
+ * @param {string} [dateTo] - End date filter.
82
+ * @param {number} [discountId] - Discount id filter.
83
+ * @param {number} [moduleId] - Module id filter.
84
+ * @param {boolean} [isAdmin] - Admin filter.
85
+ * @returns {Promise<IBonusTransactionEntity[] | IError>} Returns array of bonus transactions or an error object.
86
+ * @throws {IError} When isShell=false and an error occurs during the fetch
87
+ */
88
+ async getBonusHistory(type, dateFrom, dateTo, discountId, moduleId, isAdmin) {
89
+ const query = {
90
+ type,
91
+ dateFrom,
92
+ dateTo,
93
+ discountId,
94
+ moduleId,
95
+ isAdmin,
96
+ };
97
+ const data = await this._fetchGet(`/bonus-balance/history?` + this._queryParamsToString(query));
98
+ return this._normalizeData(data);
99
+ }
100
+ /**
101
+ * Validate discounts coupon
102
+ * @handleName validateDiscountsCoupon
103
+ * @param {string} code - The coupon code to validate.
104
+ * @returns {Promise<ICouponValidationResult | IError>} Returns an coupon validation result or an error object if there was an issue.
105
+ * @throws {IError} When isShell=false and an error occurs during the fetch
106
+ * @description This function validates a coupon code and returns the result.
107
+ */
108
+ async validateDiscountsCoupon(code) {
109
+ const query = {
110
+ code,
111
+ };
112
+ const data = await this._fetchGet(`/coupons/validate?` + this._queryParamsToString(query));
113
+ return this._normalizeData(data);
114
+ }
115
+ }
116
+ exports.default = DiscountsApi;
@@ -0,0 +1,217 @@
1
+ import type { IError } from '../base/utils';
2
+ /**
3
+ * Interface for the Discounts API module.
4
+ * @interface IDiscountsApi
5
+ */
6
+ interface IDiscountsApi {
7
+ /**
8
+ * Return all discounts.
9
+ * @handleName getAllSubscriptions
10
+ * @param {string} [langCode] - Language code. Default: "en_US".
11
+ * @param {number} [offset] - Optional parameter for pagination. Default: 0.
12
+ * @param {number} [limit] - Optional parameter for pagination. Default: 30.
13
+ * @param {string} [type] - Optional parameter to filter discounts by type.
14
+ * @returns {Promise<IDiscountsResponse | IError>} Returns an object containing all discounts or an error object if there was an issue.
15
+ * @throws {IError} When isShell=false and an error occurs during the fetch
16
+ * @description Fetches all discounts from the server.
17
+ */
18
+ getAllDiscounts(langCode?: string, offset?: number, limit?: number, type?: 'DISCOUNT' | 'BONUS' | 'PERSONAL_DISCOUNT'): Promise<IDiscountsResponse | IError>;
19
+ /**
20
+ * Get discount by marker
21
+ * @handleName getDiscountByMarker
22
+ * @param {string} marker - Textual identifier of the discount storage object. Example: "discount_storage".
23
+ * @param {string} [langCode] - Language code. Default: "en_US".
24
+ * @returns {Promise<IDiscountsEntity | IError>} Returns an object containing discount by marker or an error object if there was an issue.
25
+ * @throws {IError} When isShell=false and an error occurs during the fetch
26
+ * @description Fetches a discount by its marker.
27
+ */
28
+ getDiscountByMarker(marker: string, langCode: string): Promise<IDiscountsEntity | IError>;
29
+ /**
30
+ * Validate discounts coupon
31
+ * @handleName validateDiscountsCoupon
32
+ * @param {string} code - The coupon code to validate.
33
+ * @returns {Promise<ICouponValidationResult | IError>} Returns an coupon validation result or an error object if there was an issue.
34
+ * @throws {IError} When isShell=false and an error occurs during the fetch
35
+ * @description This function validates a coupon code and returns the result.
36
+ */
37
+ validateDiscountsCoupon(code: string): Promise<ICouponValidationResult | IError>;
38
+ /**
39
+ * Get bonus balance of the current user.
40
+ * @handleName getBonusBalance
41
+ * @returns {Promise<IDiscountsEntity | IError>} Returns bonus balance or an error object.
42
+ * @throws {IError} When isShell=false and an error occurs during the fetch
43
+ */
44
+ getBonusBalance(): Promise<IDiscountsEntity | IError>;
45
+ /**
46
+ * Get bonus transaction history of the current user.
47
+ * @handleName getBonusHistory
48
+ * @param {string} [type] - Transaction type filter.
49
+ * @param {string} [dateFrom] - Start date filter.
50
+ * @param {string} [dateTo] - End date filter.
51
+ * @param {number} [discountId] - Discount id filter.
52
+ * @param {number} [moduleId] - Module id filter.
53
+ * @param {boolean} [isAdmin] - Admin filter.
54
+ * @returns {Promise<IBonusTransactionEntity[] | IError>} Returns array of bonus transactions or an error object.
55
+ * @throws {IError} When isShell=false and an error occurs during the fetch
56
+ */
57
+ getBonusHistory(type?: BonusTransactionType, dateFrom?: string, dateTo?: string, discountId?: number, moduleId?: number, isAdmin?: boolean): Promise<IBonusTransactionEntity[] | IError>;
58
+ }
59
+ /**
60
+ * Query parameters for fetching discounts.
61
+ * @interface IDiscountsQuery
62
+ * @property {'DISCOUNT' | 'BONUS' | 'PERSONAL_DISCOUNT'} [type] - Filter discounts by type.
63
+ * @property {string} langCode - The language code for localization. Example: "en_US".
64
+ * @property {number} [offset] - Offset for pagination. Default: 0.
65
+ * @property {number} [limit] - Limit for pagination. Default: 30.
66
+ */
67
+ interface IDiscountsQuery {
68
+ type?: 'DISCOUNT' | 'BONUS' | 'PERSONAL_DISCOUNT';
69
+ langCode: string;
70
+ offset?: number;
71
+ limit?: number;
72
+ }
73
+ /**
74
+ * Represents a discount condition.
75
+ * @interface IDiscountCondition
76
+ * @property {string} type - The type of discount condition.
77
+ * @property {string} [value] - The value associated with the discount condition.
78
+ */
79
+ interface IDiscountCondition {
80
+ type: 'PRODUCT' | 'CATEGORY' | 'ATTRIBUTE' | 'PRODUCT_IN_CART' | 'CATEGORY_IN_CART' | 'MIN_CART_AMOUNT' | 'USER_LTV' | 'USER_ATTRIBUTE';
81
+ value: string;
82
+ }
83
+ /**
84
+ * Represents a discount entity.
85
+ * @interface IDiscountsEntity
86
+ * @property {number} id - The unique identifier of the discount.
87
+ * @property {number} [attributeSetId] - The identifier of the discount.
88
+ * @property {object} [localizeInfos] - The name of the discount.
89
+ * @property {number} [version] - The version of the discount.
90
+ * @property {string} [identifier] - The identifier of the discount.
91
+ * @property {string} [type] - The type of the discount.
92
+ * @property {string} [startDate] - The start date of the discount.
93
+ * @property {string} [endDate] - The end date of the discount.
94
+ * @property {Record<string, unknown>} [discountValue] - The value of the discount.
95
+ * @property {string} [conditionLogic] - The logic of the discount. Possible values are "AND" | "OR".
96
+ * @property {IDiscountCondition[]} [conditions] - The conditions of the discount.
97
+ * @property {object} [exclusions] - The exclusions of the discount.
98
+ * @property {object} [gifts] - The gifts of the discount.
99
+ * @property {boolean} [giftsReplaceCartItems] - Whether the gifts replace cart items.
100
+ * @property {object} [userGroups] - The user groups of the discount.
101
+ * @property {object} [userExclusions] - The user exclusions of the discount.
102
+ * @property {object} [attributeValues] - The attribute values of the discount.
103
+ * @property {string} [attributeSetIdentifier] - The identifier of the attribute set.
104
+ * @property {Record<string, unknown>} [bonusEvent] - Bonus event configuration.
105
+ */
106
+ interface IDiscountsEntity {
107
+ id: number;
108
+ attributeSetId?: number;
109
+ localizeInfos?: object;
110
+ version?: number;
111
+ identifier?: string;
112
+ type: 'DISCOUNT' | 'BONUS' | 'PERSONAL_DISCOUNT';
113
+ startDate?: string;
114
+ endDate?: string;
115
+ discountValue?: Record<string, unknown>;
116
+ conditionLogic?: 'AND' | 'OR';
117
+ conditions?: IDiscountCondition[];
118
+ exclusions?: object;
119
+ gifts?: object;
120
+ giftsReplaceCartItems?: boolean;
121
+ userGroups?: object;
122
+ userExclusions?: object;
123
+ attributeValues?: object;
124
+ attributeSetIdentifier?: string;
125
+ bonusEvent?: Record<string, unknown>;
126
+ }
127
+ /**
128
+ * Paginated response for discounts list.
129
+ * @interface IDiscountsResponse
130
+ * @property {IDiscountsEntity[]} items - Array of discount entities.
131
+ * @property {number} total - Total number of discounts.
132
+ */
133
+ interface IDiscountsResponse {
134
+ items: IDiscountsEntity[];
135
+ total: number;
136
+ }
137
+ /**
138
+ * Request body for coupon validation.
139
+ * @interface IDiscountsValidateCoupon
140
+ * @property {string} code - The coupon code to validate.
141
+ */
142
+ interface IDiscountsValidateCoupon {
143
+ code: string;
144
+ }
145
+ /**
146
+ * Result of coupon validation.
147
+ * @interface ICouponValidationResult
148
+ * @property {boolean} valid - Whether the coupon is valid.
149
+ * @property {unknown} [coupon] - Coupon data if the coupon is valid.
150
+ * @property {string} [error] - Error message if the coupon is invalid.
151
+ */
152
+ interface ICouponValidationResult {
153
+ valid: boolean;
154
+ coupon?: unknown;
155
+ error?: string;
156
+ }
157
+ /**
158
+ * Query parameters for fetching a discount by marker.
159
+ * @interface IDiscountByMarkerQuery
160
+ * @property {string} langCode - The language code for localization. Example: "en_US".
161
+ * @property {string} marker - Textual identifier of the discount. Example: "example_discount".
162
+ */
163
+ interface IDiscountByMarkerQuery {
164
+ langCode: string;
165
+ marker: string;
166
+ }
167
+ /**
168
+ *
169
+ */
170
+ type BonusTransactionType = 'ACCRUAL' | 'USAGE' | 'REDUCE' | 'REVERSAL_ACCRUAL' | 'REVERSAL_USAGE' | 'EXPIRATION';
171
+ /**
172
+ * @interface IBonusHistoryQuery
173
+ * @property {BonusTransactionType} [type] - Transaction type filter.
174
+ * @property {string} [dateFrom] - Start date filter.
175
+ * @property {string} [dateTo] - End date filter.
176
+ * @property {number} [discountId] - Discount id filter.
177
+ * @property {number} [moduleId] - Module id filter.
178
+ * @property {boolean} [isAdmin] - Admin filter.
179
+ */
180
+ interface IBonusHistoryQuery {
181
+ type?: BonusTransactionType;
182
+ dateFrom?: string;
183
+ dateTo?: string;
184
+ discountId?: number;
185
+ moduleId?: number;
186
+ isAdmin?: boolean;
187
+ }
188
+ /**
189
+ * @interface IBonusTransactionEntity
190
+ * @property {number} balanceId - Balance id.
191
+ * @property {number} amount - Transaction amount.
192
+ * @property {BonusTransactionType} type - Transaction type.
193
+ * @property {number} [discountId] - Discount id.
194
+ * @property {number} [moduleId] - Module id.
195
+ * @property {string} [entityIdentifier] - Entity identifier.
196
+ * @property {string} [comment] - Comment.
197
+ * @property {boolean} isAdmin - Admin flag.
198
+ * @property {number} [remainingAmount] - Remaining amount.
199
+ * @property {'EVENT' | 'SCHEDULED'} [triggerType] - Trigger type.
200
+ * @property {string} [expiresAt] - Expiration date.
201
+ * @property {string} [createdAt] - Creation date.
202
+ */
203
+ interface IBonusTransactionEntity {
204
+ balanceId: number;
205
+ amount: number;
206
+ type: BonusTransactionType;
207
+ discountId?: number;
208
+ moduleId?: number;
209
+ entityIdentifier?: string;
210
+ comment?: string;
211
+ isAdmin: boolean;
212
+ remainingAmount?: number;
213
+ triggerType?: 'EVENT' | 'SCHEDULED';
214
+ expiresAt?: string;
215
+ createdAt?: string;
216
+ }
217
+ export type { BonusTransactionType, IBonusHistoryQuery, IBonusTransactionEntity, ICouponValidationResult, IDiscountByMarkerQuery, IDiscountCondition, IDiscountsApi, IDiscountsEntity, IDiscountsQuery, IDiscountsResponse, IDiscountsValidateCoupon, };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,60 @@
1
+ import AsyncModules from '../base/asyncModules';
2
+ import type StateModule from '../base/stateModule';
3
+ import type { IError } from '../base/utils';
4
+ import type { IEvents, ISubscriptions } from './eventsInterfaces';
5
+ /**
6
+ * Controllers for working with events
7
+ * @handle /api/content/events
8
+ * @class EventsApi
9
+ * @augments AsyncModules
10
+ * @implements {IEvents}
11
+ * @description This class provides methods to interact with events, including subscribing and unsubscribing to product events, and retrieving all subscriptions.
12
+ */
13
+ export default class EventsApi extends AsyncModules implements IEvents {
14
+ protected state: StateModule;
15
+ protected _url: string;
16
+ /**
17
+ * Initializes the EventsApi with the provided state module.
18
+ * @class EventsApi
19
+ * @augments AsyncModules
20
+ * @implements {IEvents}
21
+ * @param {StateModule} state - The state module containing the base URL and other configurations.
22
+ * @description Initializes the EventsApi with the provided state module.
23
+ */
24
+ constructor(state: StateModule);
25
+ /**
26
+ * Return all subscriptions to product.
27
+ * @handleName getAllSubscriptions
28
+ * @param {number} [offset] - Optional offset for pagination. Default: 0.
29
+ * @param {number} [limit] - Optional limit for pagination. Default: 30.
30
+ * @returns {Promise<ISubscriptions | IError>} Returns an object containing all subscriptions or an error object if there was an issue.
31
+ * @throws {IError} When isShell=false and an error occurs during the fetch
32
+ * @description This method requires user authorization.
33
+ * @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}.
34
+ */
35
+ getAllSubscriptions(offset?: number, limit?: number): Promise<ISubscriptions | IError>;
36
+ /**
37
+ * Subscribing to an event on a product.
38
+ * @handleName subscribeByMarker
39
+ * @param {string} marker - Event marker. Example: "product_price_change".
40
+ * @param {number} productId - Product id. Example: 12345.
41
+ * @param {string} [langCode] - Language code. Default: "en_US".=
42
+ * @returns {Promise<boolean | IError>} Returns true if subscription was successful, or an error object if there was an issue.
43
+ * @throws {IError} When isShell=false and an error occurs during the fetch
44
+ * @description This method requires user authorization.
45
+ * @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}.
46
+ */
47
+ subscribeByMarker(marker: string, productId: number, langCode?: string): Promise<boolean | IError>;
48
+ /**
49
+ * Unsubscribing to an event on a product.
50
+ * @handleName unsubscribeByMarker
51
+ * @param {string} marker - The marker of the event to unsubscribe from. Example: "product_price_change".
52
+ * @param {number} productId - The ID of the product to unsubscribe from. Example: 12345.
53
+ * @param {string} [langCode] - Language code. Default: "en_US".
54
+ * @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.
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
+ unsubscribeByMarker(marker: string, productId: number, langCode?: string): Promise<boolean | IError>;
60
+ }
@@ -0,0 +1,97 @@
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;
@@ -0,0 +1,87 @@
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 };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });