oneentry 1.0.142 → 1.0.143
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.
- package/dist/admins/adminsApi.d.ts +50 -0
- package/dist/admins/adminsApi.js +65 -0
- package/dist/admins/adminsInterfaces.d.ts +98 -0
- package/dist/admins/adminsInterfaces.js +2 -0
- package/dist/admins/adminsSchemas.d.ts +30 -0
- package/dist/admins/adminsSchemas.js +27 -0
- package/dist/attribute-sets/attributeSetsApi.d.ts +63 -0
- package/dist/attribute-sets/attributeSetsApi.js +98 -0
- package/dist/attribute-sets/attributeSetsInterfaces.d.ts +185 -0
- package/dist/attribute-sets/attributeSetsInterfaces.js +2 -0
- package/dist/attribute-sets/attributeSetsSchemas.d.ts +90 -0
- package/dist/attribute-sets/attributeSetsSchemas.js +74 -0
- package/dist/auth-provider/authProviderApi.d.ts +249 -0
- package/dist/auth-provider/authProviderApi.js +354 -0
- package/dist/auth-provider/authProviderSchemas.d.ts +131 -0
- package/dist/auth-provider/authProviderSchemas.js +82 -0
- package/dist/auth-provider/authProvidersInterfaces.d.ts +412 -0
- package/dist/auth-provider/authProvidersInterfaces.js +2 -0
- package/dist/base/asyncModules.d.ts +80 -0
- package/dist/base/asyncModules.js +448 -0
- package/dist/base/result.d.ts +39 -0
- package/dist/base/result.js +154 -0
- package/dist/base/stateModule.d.ts +41 -0
- package/dist/base/stateModule.js +128 -0
- package/dist/base/syncModules.d.ts +286 -0
- package/dist/base/syncModules.js +716 -0
- package/dist/base/utils.d.ts +197 -0
- package/dist/base/utils.js +2 -0
- package/dist/base/validation.d.ts +118 -0
- package/dist/base/validation.js +132 -0
- package/dist/blocks/blocksApi.d.ts +76 -0
- package/dist/blocks/blocksApi.js +188 -0
- package/dist/blocks/blocksInterfaces.d.ts +168 -0
- package/dist/blocks/blocksInterfaces.js +2 -0
- package/dist/blocks/blocksSchemas.d.ts +195 -0
- package/dist/blocks/blocksSchemas.js +43 -0
- package/dist/discounts/discountsApi.d.ts +56 -0
- package/dist/discounts/discountsApi.js +82 -0
- package/dist/discounts/discountsInterfaces.d.ts +145 -0
- package/dist/discounts/discountsInterfaces.js +2 -0
- package/dist/events/eventsApi.d.ts +60 -0
- package/dist/events/eventsApi.js +97 -0
- package/dist/events/eventsInterfaces.d.ts +87 -0
- package/dist/events/eventsInterfaces.js +2 -0
- package/dist/file-uploading/fileUploadingApi.d.ts +88 -0
- package/dist/file-uploading/fileUploadingApi.js +129 -0
- package/dist/file-uploading/fileUploadingInterfaces.d.ts +114 -0
- package/dist/file-uploading/fileUploadingInterfaces.js +2 -0
- package/dist/file-uploading/fileUploadingSchemas.d.ts +22 -0
- package/dist/file-uploading/fileUploadingSchemas.js +21 -0
- package/dist/forms/formsApi.d.ts +42 -0
- package/dist/forms/formsApi.js +57 -0
- package/dist/forms/formsInterfaces.d.ts +134 -0
- package/dist/forms/formsInterfaces.js +2 -0
- package/dist/forms/formsSchemas.d.ts +50 -0
- package/dist/forms/formsSchemas.js +31 -0
- package/dist/forms-data/formsDataApi.d.ts +106 -0
- package/dist/forms-data/formsDataApi.js +189 -0
- package/dist/forms-data/formsDataInterfaces.d.ts +522 -0
- package/dist/forms-data/formsDataInterfaces.js +2 -0
- package/dist/forms-data/formsDataSchemas.d.ts +115 -0
- package/dist/forms-data/formsDataSchemas.js +86 -0
- package/dist/general-types/generalTypesApi.d.ts +28 -0
- package/dist/general-types/generalTypesApi.js +38 -0
- package/dist/general-types/generalTypesInterfaces.d.ts +29 -0
- package/dist/general-types/generalTypesInterfaces.js +2 -0
- package/dist/general-types/generalTypesSchemas.d.ts +50 -0
- package/dist/general-types/generalTypesSchemas.js +35 -0
- package/dist/index.d.ts +100 -0
- package/dist/index.js +103 -0
- package/dist/integration-collections/integrationCollectionsApi.d.ts +163 -0
- package/dist/integration-collections/integrationCollectionsApi.js +220 -0
- package/dist/integration-collections/integrationCollectionsInterfaces.d.ts +313 -0
- package/dist/integration-collections/integrationCollectionsInterfaces.js +2 -0
- package/dist/integration-collections/integrationCollectionsSchemas.d.ts +80 -0
- package/dist/integration-collections/integrationCollectionsSchemas.js +61 -0
- package/dist/locales/localesApi.d.ts +27 -0
- package/dist/locales/localesApi.js +37 -0
- package/dist/locales/localesInterfaces.d.ts +40 -0
- package/dist/locales/localesInterfaces.js +2 -0
- package/dist/locales/localesSchemas.d.ts +32 -0
- package/dist/locales/localesSchemas.js +26 -0
- package/dist/menus/menusApi.d.ts +29 -0
- package/dist/menus/menusApi.js +39 -0
- package/dist/menus/menusInterfaces.d.ts +87 -0
- package/dist/menus/menusInterfaces.js +3 -0
- package/dist/menus/menusSchemas.d.ts +16 -0
- package/dist/menus/menusSchemas.js +28 -0
- package/dist/orders/ordersApi.d.ts +149 -0
- package/dist/orders/ordersApi.js +203 -0
- package/dist/orders/ordersInterfaces.d.ts +520 -0
- package/dist/orders/ordersInterfaces.js +2 -0
- package/dist/orders/ordersSchemas.d.ts +120 -0
- package/dist/orders/ordersSchemas.js +101 -0
- package/dist/pages/pagesApi.d.ts +151 -0
- package/dist/pages/pagesApi.js +390 -0
- package/dist/pages/pagesInterfaces.d.ts +284 -0
- package/dist/pages/pagesInterfaces.js +2 -0
- package/dist/pages/pagesSchemas.d.ts +85 -0
- package/dist/pages/pagesSchemas.js +46 -0
- package/dist/payments/paymentsApi.d.ts +82 -0
- package/dist/payments/paymentsApi.js +121 -0
- package/dist/payments/paymentsInterfaces.d.ts +200 -0
- package/dist/payments/paymentsInterfaces.js +2 -0
- package/dist/payments/paymentsSchemas.d.ts +100 -0
- package/dist/payments/paymentsSchemas.js +65 -0
- package/dist/product-statuses/productStatusesApi.d.ts +47 -0
- package/dist/product-statuses/productStatusesApi.js +70 -0
- package/dist/product-statuses/productStatusesInterfaces.d.ts +62 -0
- package/dist/product-statuses/productStatusesInterfaces.js +2 -0
- package/dist/product-statuses/productStatusesSchemas.d.ts +34 -0
- package/dist/product-statuses/productStatusesSchemas.js +30 -0
- package/dist/products/productsApi.d.ts +365 -0
- package/dist/products/productsApi.js +459 -0
- package/dist/products/productsInterfaces.d.ts +577 -0
- package/dist/products/productsInterfaces.js +2 -0
- package/dist/products/productsSchemas.d.ts +200 -0
- package/dist/products/productsSchemas.js +98 -0
- package/dist/sitemap/sitemapApi.d.ts +35 -0
- package/dist/sitemap/sitemapApi.js +45 -0
- package/dist/sitemap/sitemapInterfaces.d.ts +40 -0
- package/dist/sitemap/sitemapInterfaces.js +2 -0
- package/dist/system/systemApi.d.ts +43 -0
- package/dist/system/systemApi.js +56 -0
- package/dist/system/systemInterfaces.d.ts +29 -0
- package/dist/system/systemInterfaces.js +2 -0
- package/dist/templates/templatesApi.d.ts +49 -0
- package/dist/templates/templatesApi.js +75 -0
- package/dist/templates/templatesInterfaces.d.ts +67 -0
- package/dist/templates/templatesInterfaces.js +2 -0
- package/dist/templates/templatesSchemas.d.ts +48 -0
- package/dist/templates/templatesSchemas.js +31 -0
- package/dist/templates-preview/templatesPreviewApi.d.ts +38 -0
- package/dist/templates-preview/templatesPreviewApi.js +53 -0
- package/dist/templates-preview/templatesPreviewInterfaces.d.ts +119 -0
- package/dist/templates-preview/templatesPreviewInterfaces.js +2 -0
- package/dist/templates-preview/templatesPreviewSchemas.d.ts +83 -0
- package/dist/templates-preview/templatesPreviewSchemas.js +48 -0
- package/dist/users/usersApi.d.ts +143 -0
- package/dist/users/usersApi.js +171 -0
- package/dist/users/usersInterfaces.d.ts +229 -0
- package/dist/users/usersInterfaces.js +2 -0
- package/dist/users/usersSchemas.d.ts +38 -0
- package/dist/users/usersSchemas.js +28 -0
- package/dist/web-socket/wsApi.d.ts +25 -0
- package/dist/web-socket/wsApi.js +45 -0
- package/dist/web-socket/wsInterfaces.d.ts +16 -0
- package/dist/web-socket/wsInterfaces.js +2 -0
- package/package.json +3 -81
|
@@ -0,0 +1,82 @@
|
|
|
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
|
+
* Validate discounts coupon
|
|
68
|
+
* @handleName validateDiscountsCoupon
|
|
69
|
+
* @param {string} code - The coupon code to validate.
|
|
70
|
+
* @returns {Promise<ICouponValidationResult | IError>} Returns an coupon validation result or an error object if there was an issue.
|
|
71
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
72
|
+
* @description This function validates a coupon code and returns the result.
|
|
73
|
+
*/
|
|
74
|
+
async validateDiscountsCoupon(code) {
|
|
75
|
+
const query = {
|
|
76
|
+
code,
|
|
77
|
+
};
|
|
78
|
+
const data = await this._fetchGet(`/coupons/validate?` + this._queryParamsToString(query));
|
|
79
|
+
return this._normalizeData(data);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.default = DiscountsApi;
|
|
@@ -0,0 +1,145 @@
|
|
|
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' | 'PERSONAL_BONUS'): 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
|
+
/**
|
|
40
|
+
* Query parameters for fetching discounts.
|
|
41
|
+
* @interface IDiscountsQuery
|
|
42
|
+
* @property {'DISCOUNT' | 'BONUS' | 'PERSONAL_DISCOUNT' | 'PERSONAL_BONUS'} [type] - Filter discounts by type.
|
|
43
|
+
* @property {string} langCode - The language code for localization. Example: "en_US".
|
|
44
|
+
* @property {number} [offset] - Offset for pagination. Default: 0.
|
|
45
|
+
* @property {number} [limit] - Limit for pagination. Default: 30.
|
|
46
|
+
*/
|
|
47
|
+
interface IDiscountsQuery {
|
|
48
|
+
type?: 'DISCOUNT' | 'BONUS' | 'PERSONAL_DISCOUNT' | 'PERSONAL_BONUS';
|
|
49
|
+
langCode: string;
|
|
50
|
+
offset?: number;
|
|
51
|
+
limit?: number;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Represents a discount condition.
|
|
55
|
+
* @interface IDiscountCondition
|
|
56
|
+
* @property {string} type - The type of discount condition.
|
|
57
|
+
* @property {string} [value] - The value associated with the discount condition.
|
|
58
|
+
*/
|
|
59
|
+
interface IDiscountCondition {
|
|
60
|
+
type: 'PRODUCT' | 'CATEGORY' | 'ATTRIBUTE' | 'PRODUCT_IN_CART' | 'CATEGORY_IN_CART' | 'MIN_CART_AMOUNT' | 'USER_LTV' | 'USER_ATTRIBUTE';
|
|
61
|
+
value: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Represents a discount entity.
|
|
65
|
+
* @interface IDiscountsEntity
|
|
66
|
+
* @property {number} id - The unique identifier of the discount.
|
|
67
|
+
* @property {number} [attributeSetId] - The identifier of the discount.
|
|
68
|
+
* @property {object} [localizeInfos] - The name of the discount.
|
|
69
|
+
* @property {number} [version] - The version of the discount.
|
|
70
|
+
* @property {string} [identifier] - The identifier of the discount.
|
|
71
|
+
* @property {string} [type] - The type of the discount.
|
|
72
|
+
* @property {string} [startDate] - The start date of the discount.
|
|
73
|
+
* @property {string} [endDate] - The end date of the discount.
|
|
74
|
+
* @property {Record<string, unknown>} [discountValue] - The value of the discount.
|
|
75
|
+
* @property {string} [conditionLogic] - The logic of the discount. Possible values are "AND" | "OR".
|
|
76
|
+
* @property {IDiscountCondition[]} [conditions] - The conditions of the discount.
|
|
77
|
+
* @property {object} [exclusions] - The exclusions of the discount.
|
|
78
|
+
* @property {object} [gifts] - The gifts of the discount.
|
|
79
|
+
* @property {boolean} [giftsReplaceCartItems] - Whether the gifts replace cart items.
|
|
80
|
+
* @property {object} [userGroups] - The user groups of the discount.
|
|
81
|
+
* @property {object} [userExclusions] - The user exclusions of the discount.
|
|
82
|
+
* @property {object} [attributeValues] - The attribute values of the discount.
|
|
83
|
+
* @property {string} [attributeSetIdentifier] - The identifier of the attribute set.
|
|
84
|
+
*/
|
|
85
|
+
interface IDiscountsEntity {
|
|
86
|
+
id: number;
|
|
87
|
+
attributeSetId?: number;
|
|
88
|
+
localizeInfos?: object;
|
|
89
|
+
version?: number;
|
|
90
|
+
identifier?: string;
|
|
91
|
+
type: 'DISCOUNT' | 'BONUS' | 'PERSONAL_DISCOUNT' | 'PERSONAL_BONUS';
|
|
92
|
+
startDate?: string;
|
|
93
|
+
endDate?: string;
|
|
94
|
+
discountValue?: Record<string, unknown>;
|
|
95
|
+
conditionLogic?: 'AND' | 'OR';
|
|
96
|
+
conditions?: IDiscountCondition[];
|
|
97
|
+
exclusions?: object;
|
|
98
|
+
gifts?: object;
|
|
99
|
+
giftsReplaceCartItems?: boolean;
|
|
100
|
+
userGroups?: object;
|
|
101
|
+
userExclusions?: object;
|
|
102
|
+
attributeValues?: object;
|
|
103
|
+
attributeSetIdentifier?: string;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Paginated response for discounts list.
|
|
107
|
+
* @interface IDiscountsResponse
|
|
108
|
+
* @property {IDiscountsEntity[]} items - Array of discount entities.
|
|
109
|
+
* @property {number} total - Total number of discounts.
|
|
110
|
+
*/
|
|
111
|
+
interface IDiscountsResponse {
|
|
112
|
+
items: IDiscountsEntity[];
|
|
113
|
+
total: number;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Request body for coupon validation.
|
|
117
|
+
* @interface IDiscountsValidateCoupon
|
|
118
|
+
* @property {string} code - The coupon code to validate.
|
|
119
|
+
*/
|
|
120
|
+
interface IDiscountsValidateCoupon {
|
|
121
|
+
code: string;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Result of coupon validation.
|
|
125
|
+
* @interface ICouponValidationResult
|
|
126
|
+
* @property {boolean} valid - Whether the coupon is valid.
|
|
127
|
+
* @property {unknown} [coupon] - Coupon data if the coupon is valid.
|
|
128
|
+
* @property {string} [error] - Error message if the coupon is invalid.
|
|
129
|
+
*/
|
|
130
|
+
interface ICouponValidationResult {
|
|
131
|
+
valid: boolean;
|
|
132
|
+
coupon?: unknown;
|
|
133
|
+
error?: string;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Query parameters for fetching a discount by marker.
|
|
137
|
+
* @interface IDiscountByMarkerQuery
|
|
138
|
+
* @property {string} langCode - The language code for localization. Example: "en_US".
|
|
139
|
+
* @property {string} marker - Textual identifier of the discount. Example: "example_discount".
|
|
140
|
+
*/
|
|
141
|
+
interface IDiscountByMarkerQuery {
|
|
142
|
+
langCode: string;
|
|
143
|
+
marker: string;
|
|
144
|
+
}
|
|
145
|
+
export type { ICouponValidationResult, IDiscountByMarkerQuery, IDiscountCondition, IDiscountsApi, IDiscountsEntity, IDiscountsQuery, IDiscountsResponse, IDiscountsValidateCoupon, };
|
|
@@ -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,88 @@
|
|
|
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 {string | number} [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<boolean | 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<boolean | 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<Response | IError>} Returns a promise that resolves to a Response 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<Response | IError>;
|
|
88
|
+
}
|