oneentry 1.0.143 → 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.
- package/configure.js +2 -2
- package/dist/base/utils.d.ts +1 -1
- package/dist/blocks/blocksApi.d.ts +12 -0
- package/dist/blocks/blocksApi.js +19 -0
- package/dist/blocks/blocksInterfaces.d.ts +12 -1
- package/dist/discounts/discountsApi.d.ts +22 -2
- package/dist/discounts/discountsApi.js +34 -0
- package/dist/discounts/discountsInterfaces.d.ts +78 -6
- package/dist/forms/formsApi.d.ts +3 -3
- package/dist/forms/formsApi.js +1 -1
- package/dist/forms/formsInterfaces.d.ts +15 -5
- package/dist/forms/formsSchemas.d.ts +17 -14
- package/dist/forms/formsSchemas.js +5 -2
- package/dist/general-types/generalTypesSchemas.d.ts +2 -0
- package/dist/general-types/generalTypesSchemas.js +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/orders/ordersApi.d.ts +27 -1
- package/dist/orders/ordersApi.js +44 -0
- package/dist/orders/ordersInterfaces.d.ts +74 -1
- package/dist/pages/pagesInterfaces.d.ts +2 -0
- package/dist/products/productsApi.d.ts +6 -5
- package/dist/products/productsApi.js +11 -12
- package/dist/products/productsInterfaces.d.ts +19 -3
- package/dist/system/systemApi.d.ts +2 -2
- package/dist/system/systemApi.js +2 -2
- package/dist/system/systemInterfaces.d.ts +1 -1
- package/dist/users/usersInterfaces.d.ts +2 -0
- package/package.json +2 -2
package/configure.js
CHANGED
|
@@ -145,7 +145,7 @@ function addOneEntryConfig(projectName, url, token) {
|
|
|
145
145
|
const libDir = path.join(projectName, 'src', 'lib');
|
|
146
146
|
fs.mkdirSync(libDir, { recursive: true });
|
|
147
147
|
|
|
148
|
-
const tokenLine = token ? `\n token: process.env.
|
|
148
|
+
const tokenLine = token ? `\n token: process.env.NEXT_PUBLIC_ONEENTRY_TOKEN,` : '';
|
|
149
149
|
const libContent = `import { defineOneEntry } from 'oneentry';
|
|
150
150
|
|
|
151
151
|
const { Admins, Pages, Products } = defineOneEntry(
|
|
@@ -158,7 +158,7 @@ const { Admins, Pages, Products } = defineOneEntry(
|
|
|
158
158
|
export { Admins, Pages, Products };
|
|
159
159
|
`;
|
|
160
160
|
|
|
161
|
-
const envContent = `NEXT_PUBLIC_ONEENTRY_URL=${url}\n${token ? `
|
|
161
|
+
const envContent = `NEXT_PUBLIC_ONEENTRY_URL=${url}\n${token ? `NEXT_PUBLIC_ONEENTRY_TOKEN=${token}\n` : ''}`;
|
|
162
162
|
|
|
163
163
|
fs.writeFile(path.join(libDir, 'oneentry.ts'), libContent, (err) => {
|
|
164
164
|
if (err) {
|
package/dist/base/utils.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @typedef {string} Types - Type of block.
|
|
3
3
|
*/
|
|
4
|
-
type Types = 'product' | 'error_page' | 'catalog_page' | 'product_preview' | 'similar_products_block' | 'product_block' | 'form' | 'common_page' | 'common_block' | 'order' | 'service' | 'external_page' | 'discount' | 'none';
|
|
4
|
+
type Types = 'product' | 'error_page' | 'catalog_page' | 'product_preview' | 'similar_products_block' | 'product_block' | 'form' | 'common_page' | 'common_block' | 'order' | 'service' | 'external_page' | 'discount' | 'frequently_ordered_block' | 'none';
|
|
5
5
|
/**
|
|
6
6
|
* @property {string} [token] - If your project is protected by a token, specify this token in this parameter.
|
|
7
7
|
* @property {string} [langCode] - specify the default language to avoid specifying it in every request.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import AsyncModules from '../base/asyncModules';
|
|
2
2
|
import type StateModule from '../base/stateModule';
|
|
3
3
|
import type { IError } from '../base/utils';
|
|
4
|
+
import type { IProductsEntity } from '../products/productsInterfaces';
|
|
4
5
|
import type { BlockType, IBlockEntity, IBlocks, IBlocksResponse, ISearchBlock } from './blocksInterfaces';
|
|
5
6
|
/**
|
|
6
7
|
* Controllers for working with blocks.
|
|
@@ -64,6 +65,17 @@ export default class BlocksApi extends AsyncModules implements IBlocks {
|
|
|
64
65
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
65
66
|
*/
|
|
66
67
|
private getProductsByBlockMarker;
|
|
68
|
+
/**
|
|
69
|
+
* Get frequently ordered products by block marker and product id.
|
|
70
|
+
* @handleName getFrequentlyOrderedProducts
|
|
71
|
+
* @param {number} productId - Product id. Example: 1.
|
|
72
|
+
* @param {string} marker - Block marker. Example: "frequently_ordered_block".
|
|
73
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
74
|
+
* @param {string} [signPrice] - Sign price.
|
|
75
|
+
* @returns {Promise<IProductsEntity[] | IError>} Returns array of ProductEntity objects.
|
|
76
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
77
|
+
*/
|
|
78
|
+
getFrequentlyOrderedProducts(productId: number, marker: string, langCode?: string, signPrice?: string): Promise<IProductsEntity[] | IError>;
|
|
67
79
|
/**
|
|
68
80
|
* Quick search for block objects with limited output.
|
|
69
81
|
* @handleName searchBlock
|
package/dist/blocks/blocksApi.js
CHANGED
|
@@ -170,6 +170,25 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
170
170
|
const result = await this._fetchGet(`/${marker}/products?` + this._queryParamsToString(query));
|
|
171
171
|
return this._normalizeData(result.items);
|
|
172
172
|
}
|
|
173
|
+
/**
|
|
174
|
+
* Get frequently ordered products by block marker and product id.
|
|
175
|
+
* @handleName getFrequentlyOrderedProducts
|
|
176
|
+
* @param {number} productId - Product id. Example: 1.
|
|
177
|
+
* @param {string} marker - Block marker. Example: "frequently_ordered_block".
|
|
178
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
179
|
+
* @param {string} [signPrice] - Sign price.
|
|
180
|
+
* @returns {Promise<IProductsEntity[] | IError>} Returns array of ProductEntity objects.
|
|
181
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
182
|
+
*/
|
|
183
|
+
async getFrequentlyOrderedProducts(productId, marker, langCode = this.state.lang, signPrice) {
|
|
184
|
+
const query = {
|
|
185
|
+
langCode,
|
|
186
|
+
signPrice,
|
|
187
|
+
};
|
|
188
|
+
const data = await this._fetchGet(`/${marker}/products/${productId}/frequently-ordered?` +
|
|
189
|
+
this._queryParamsToString(query));
|
|
190
|
+
return this._normalizeData(data);
|
|
191
|
+
}
|
|
173
192
|
/**
|
|
174
193
|
* Quick search for block objects with limited output.
|
|
175
194
|
* @handleName searchBlock
|
|
@@ -40,6 +40,17 @@ interface IBlocks {
|
|
|
40
40
|
* @description This method performs a quick search for block objects with limited output.
|
|
41
41
|
*/
|
|
42
42
|
searchBlock(name: string, langCode?: string): Promise<ISearchBlock[] | IError>;
|
|
43
|
+
/**
|
|
44
|
+
* Get frequently ordered products by block marker and product id.
|
|
45
|
+
* @handleName getFrequentlyOrderedProducts
|
|
46
|
+
* @param {number} productId - Product id. Example: 1.
|
|
47
|
+
* @param {string} marker - Block marker. Example: "frequently_ordered_block".
|
|
48
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
49
|
+
* @param {string} [signPrice] - Sign price.
|
|
50
|
+
* @returns {IProductsEntity[]} A promise that resolves to an array of product entities or an error.
|
|
51
|
+
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
52
|
+
*/
|
|
53
|
+
getFrequentlyOrderedProducts(productId: number, marker: string, langCode?: string, signPrice?: string): Promise<IProductsEntity[] | IError>;
|
|
43
54
|
}
|
|
44
55
|
/**
|
|
45
56
|
* Represents a response from the blocks API.
|
|
@@ -164,5 +175,5 @@ interface ISearchBlock {
|
|
|
164
175
|
* @type {BlockType}
|
|
165
176
|
* @description This type defines the possible values for block types used in the system.
|
|
166
177
|
*/
|
|
167
|
-
type BlockType = 'product' | 'error_page' | 'catalog_page' | 'product_preview' | 'similar_products_block' | 'product_block' | 'form' | 'common_page' | 'common_block' | 'order' | 'service' | 'external_page' | 'discount' | 'none';
|
|
178
|
+
type BlockType = 'product' | 'error_page' | 'catalog_page' | 'product_preview' | 'similar_products_block' | 'product_block' | 'frequently_ordered_block' | 'form' | 'common_page' | 'common_block' | 'order' | 'service' | 'external_page' | 'discount' | 'none';
|
|
168
179
|
export type { BlockType, IBlockEntity, IBlocks, IBlocksResponse, ISearchBlock };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import AsyncModules from '../base/asyncModules';
|
|
2
2
|
import type StateModule from '../base/stateModule';
|
|
3
3
|
import type { IError } from '../base/utils';
|
|
4
|
-
import type { ICouponValidationResult, IDiscountsApi, IDiscountsEntity, IDiscountsResponse } from './discountsInterfaces';
|
|
4
|
+
import type { BonusTransactionType, IBonusTransactionEntity, ICouponValidationResult, IDiscountsApi, IDiscountsEntity, IDiscountsResponse } from './discountsInterfaces';
|
|
5
5
|
/**
|
|
6
6
|
* Controllers for working with events
|
|
7
7
|
* @handle /api/content/events
|
|
@@ -33,7 +33,7 @@ export default class DiscountsApi extends AsyncModules implements IDiscountsApi
|
|
|
33
33
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
34
34
|
* @description Fetches all discounts from the server.
|
|
35
35
|
*/
|
|
36
|
-
getAllDiscounts(langCode?: string, offset?: number, limit?: number, type?: 'DISCOUNT' | 'BONUS' | 'PERSONAL_DISCOUNT'
|
|
36
|
+
getAllDiscounts(langCode?: string, offset?: number, limit?: number, type?: 'DISCOUNT' | 'BONUS' | 'PERSONAL_DISCOUNT'): Promise<IDiscountsResponse | IError>;
|
|
37
37
|
/**
|
|
38
38
|
* Get discount by marker
|
|
39
39
|
* @handleName getDiscountByMarker
|
|
@@ -44,6 +44,26 @@ export default class DiscountsApi extends AsyncModules implements IDiscountsApi
|
|
|
44
44
|
* @description Fetches a discount by its marker.
|
|
45
45
|
*/
|
|
46
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>;
|
|
47
67
|
/**
|
|
48
68
|
* Validate discounts coupon
|
|
49
69
|
* @handleName validateDiscountsCoupon
|
|
@@ -63,6 +63,40 @@ class DiscountsApi extends asyncModules_1.default {
|
|
|
63
63
|
const data = await this._fetchGet(`/marker/${marker}?` + this._queryParamsToString(query));
|
|
64
64
|
return this._normalizeData(data);
|
|
65
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
|
+
}
|
|
66
100
|
/**
|
|
67
101
|
* Validate discounts coupon
|
|
68
102
|
* @handleName validateDiscountsCoupon
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IError } from 'base/utils';
|
|
1
|
+
import type { IError } from '../base/utils';
|
|
2
2
|
/**
|
|
3
3
|
* Interface for the Discounts API module.
|
|
4
4
|
* @interface IDiscountsApi
|
|
@@ -15,7 +15,7 @@ interface IDiscountsApi {
|
|
|
15
15
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
16
16
|
* @description Fetches all discounts from the server.
|
|
17
17
|
*/
|
|
18
|
-
getAllDiscounts(langCode?: string, offset?: number, limit?: number, type?: 'DISCOUNT' | 'BONUS' | 'PERSONAL_DISCOUNT'
|
|
18
|
+
getAllDiscounts(langCode?: string, offset?: number, limit?: number, type?: 'DISCOUNT' | 'BONUS' | 'PERSONAL_DISCOUNT'): Promise<IDiscountsResponse | IError>;
|
|
19
19
|
/**
|
|
20
20
|
* Get discount by marker
|
|
21
21
|
* @handleName getDiscountByMarker
|
|
@@ -35,17 +35,37 @@ interface IDiscountsApi {
|
|
|
35
35
|
* @description This function validates a coupon code and returns the result.
|
|
36
36
|
*/
|
|
37
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>;
|
|
38
58
|
}
|
|
39
59
|
/**
|
|
40
60
|
* Query parameters for fetching discounts.
|
|
41
61
|
* @interface IDiscountsQuery
|
|
42
|
-
* @property {'DISCOUNT' | 'BONUS' | 'PERSONAL_DISCOUNT'
|
|
62
|
+
* @property {'DISCOUNT' | 'BONUS' | 'PERSONAL_DISCOUNT'} [type] - Filter discounts by type.
|
|
43
63
|
* @property {string} langCode - The language code for localization. Example: "en_US".
|
|
44
64
|
* @property {number} [offset] - Offset for pagination. Default: 0.
|
|
45
65
|
* @property {number} [limit] - Limit for pagination. Default: 30.
|
|
46
66
|
*/
|
|
47
67
|
interface IDiscountsQuery {
|
|
48
|
-
type?: 'DISCOUNT' | 'BONUS' | 'PERSONAL_DISCOUNT'
|
|
68
|
+
type?: 'DISCOUNT' | 'BONUS' | 'PERSONAL_DISCOUNT';
|
|
49
69
|
langCode: string;
|
|
50
70
|
offset?: number;
|
|
51
71
|
limit?: number;
|
|
@@ -81,6 +101,7 @@ interface IDiscountCondition {
|
|
|
81
101
|
* @property {object} [userExclusions] - The user exclusions of the discount.
|
|
82
102
|
* @property {object} [attributeValues] - The attribute values of the discount.
|
|
83
103
|
* @property {string} [attributeSetIdentifier] - The identifier of the attribute set.
|
|
104
|
+
* @property {Record<string, unknown>} [bonusEvent] - Bonus event configuration.
|
|
84
105
|
*/
|
|
85
106
|
interface IDiscountsEntity {
|
|
86
107
|
id: number;
|
|
@@ -88,7 +109,7 @@ interface IDiscountsEntity {
|
|
|
88
109
|
localizeInfos?: object;
|
|
89
110
|
version?: number;
|
|
90
111
|
identifier?: string;
|
|
91
|
-
type: 'DISCOUNT' | 'BONUS' | 'PERSONAL_DISCOUNT'
|
|
112
|
+
type: 'DISCOUNT' | 'BONUS' | 'PERSONAL_DISCOUNT';
|
|
92
113
|
startDate?: string;
|
|
93
114
|
endDate?: string;
|
|
94
115
|
discountValue?: Record<string, unknown>;
|
|
@@ -101,6 +122,7 @@ interface IDiscountsEntity {
|
|
|
101
122
|
userExclusions?: object;
|
|
102
123
|
attributeValues?: object;
|
|
103
124
|
attributeSetIdentifier?: string;
|
|
125
|
+
bonusEvent?: Record<string, unknown>;
|
|
104
126
|
}
|
|
105
127
|
/**
|
|
106
128
|
* Paginated response for discounts list.
|
|
@@ -142,4 +164,54 @@ interface IDiscountByMarkerQuery {
|
|
|
142
164
|
langCode: string;
|
|
143
165
|
marker: string;
|
|
144
166
|
}
|
|
145
|
-
|
|
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, };
|
package/dist/forms/formsApi.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import AsyncModules from '../base/asyncModules';
|
|
2
2
|
import type StateModule from '../base/stateModule';
|
|
3
3
|
import type { IError } from '../base/utils';
|
|
4
|
-
import type { IForms, IFormsEntity } from './formsInterfaces';
|
|
4
|
+
import type { IForms, IFormsEntity, IFormsResponse } from './formsInterfaces';
|
|
5
5
|
/**
|
|
6
6
|
* Controllers for forms objects
|
|
7
7
|
* @class FormsApi
|
|
@@ -26,10 +26,10 @@ export default class FormsApi extends AsyncModules implements IForms {
|
|
|
26
26
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
27
27
|
* @param {number} [offset] - Parameter for pagination. Default: 0.
|
|
28
28
|
* @param {number} [limit] - Parameter for pagination. Default: 30.
|
|
29
|
-
* @returns {Promise<
|
|
29
|
+
* @returns {Promise<IFormsResponse | IError>} Returns paginated object with array of FormEntity and total count.
|
|
30
30
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
31
31
|
*/
|
|
32
|
-
getAllForms(langCode?: string, offset?: number, limit?: number): Promise<
|
|
32
|
+
getAllForms(langCode?: string, offset?: number, limit?: number): Promise<IFormsResponse | IError>;
|
|
33
33
|
/**
|
|
34
34
|
* Get one form by form marker.
|
|
35
35
|
* @handleName getFormByMarker
|
package/dist/forms/formsApi.js
CHANGED
|
@@ -30,7 +30,7 @@ class FormsApi extends asyncModules_1.default {
|
|
|
30
30
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
31
31
|
* @param {number} [offset] - Parameter for pagination. Default: 0.
|
|
32
32
|
* @param {number} [limit] - Parameter for pagination. Default: 30.
|
|
33
|
-
* @returns {Promise<
|
|
33
|
+
* @returns {Promise<IFormsResponse | IError>} Returns paginated object with array of FormEntity and total count.
|
|
34
34
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
35
35
|
*/
|
|
36
36
|
async getAllForms(langCode = this.state.lang, offset = 0, limit = 30) {
|
|
@@ -16,7 +16,7 @@ interface IForms {
|
|
|
16
16
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
17
17
|
* @description This method retrieves all forms in the system.
|
|
18
18
|
*/
|
|
19
|
-
getAllForms(langCode?: string, offset?: number, limit?: number): Promise<
|
|
19
|
+
getAllForms(langCode?: string, offset?: number, limit?: number): Promise<IFormsResponse | IError>;
|
|
20
20
|
/**
|
|
21
21
|
* Retrieves a form by its marker.
|
|
22
22
|
* @handleName getFormByMarker
|
|
@@ -75,13 +75,12 @@ interface IFromPages {
|
|
|
75
75
|
{
|
|
76
76
|
"key": "value"
|
|
77
77
|
}
|
|
78
|
-
* @property {Array<IFormConfig>} [moduleFormConfigs] - Module form configurations linked to the form.
|
|
79
78
|
* @description This interface defines the structure of a form entity, including its identifiers, attributes, and processing data.
|
|
80
79
|
*/
|
|
81
80
|
interface IFormsEntity {
|
|
82
81
|
id: number;
|
|
83
82
|
attributeSetId: number | null;
|
|
84
|
-
type:
|
|
83
|
+
type: 'order' | 'sing_in_up' | 'collection' | 'data' | 'rating' | null;
|
|
85
84
|
localizeInfos: ILocalizeInfo;
|
|
86
85
|
version: number;
|
|
87
86
|
position: number;
|
|
@@ -89,7 +88,6 @@ interface IFormsEntity {
|
|
|
89
88
|
processingType: string;
|
|
90
89
|
templateId: number | null;
|
|
91
90
|
attributes: IAttributes[] | Record<string, any>;
|
|
92
|
-
moduleFormConfigs?: Array<IFormConfig>;
|
|
93
91
|
}
|
|
94
92
|
/**
|
|
95
93
|
* Represents the structure of a form configuration.
|
|
@@ -108,6 +106,7 @@ interface IFormsEntity {
|
|
|
108
106
|
* @property {string} entityIdentifiers[].id - Entity identifier. Example: "catalog".
|
|
109
107
|
* @property {boolean} entityIdentifiers[].isNested - Indicates if entity is nested. Example: false.
|
|
110
108
|
* @property {string[]} [nestedEntityIdentifiers] - An array of nested entity identifier strings (only in products/pages API). Example: ["catalog"].
|
|
109
|
+
* @property {string[]} [exceptionIds] - An array of exception identifiers.
|
|
111
110
|
* @property {number} [formDataCount] - Total count of form data entries (only in products/pages API). Example: 306.
|
|
112
111
|
* @property {Record<string, number>} [entityFormDataCount] - Form data count per entity identifier (only in products/pages API). Example: {"catalog": 306}.
|
|
113
112
|
* @description This interface defines the structure of a form configuration, including its identifiers, module association, and entity identifiers. Different APIs return different field variants.
|
|
@@ -128,7 +127,18 @@ interface IFormConfig {
|
|
|
128
127
|
isNested: boolean;
|
|
129
128
|
}[];
|
|
130
129
|
nestedEntityIdentifiers?: string[];
|
|
130
|
+
exceptionIds?: string[];
|
|
131
131
|
formDataCount?: number;
|
|
132
132
|
entityFormDataCount?: Record<string, number>;
|
|
133
133
|
}
|
|
134
|
-
|
|
134
|
+
/**
|
|
135
|
+
* Represents the paginated response structure for forms.
|
|
136
|
+
* @interface IFormsResponse
|
|
137
|
+
* @property {number} total - Total items count.
|
|
138
|
+
* @property {IFormsEntity[]} items - Array of form entities.
|
|
139
|
+
*/
|
|
140
|
+
interface IFormsResponse {
|
|
141
|
+
total: number;
|
|
142
|
+
items: IFormsEntity[];
|
|
143
|
+
}
|
|
144
|
+
export type { IFormConfig, IForms, IFormsEntity, IFormsResponse, IFromPages };
|
|
@@ -17,21 +17,24 @@ export declare const FormEntitySchema: z.ZodObject<{
|
|
|
17
17
|
moduleFormConfigs: z.ZodOptional<z.ZodArray<z.ZodAny>>;
|
|
18
18
|
}, z.core.$strip>;
|
|
19
19
|
/**
|
|
20
|
-
* Forms response schema (
|
|
20
|
+
* Forms response schema (paginated)
|
|
21
21
|
*/
|
|
22
|
-
export declare const FormsResponseSchema: z.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
22
|
+
export declare const FormsResponseSchema: z.ZodObject<{
|
|
23
|
+
total: z.ZodNumber;
|
|
24
|
+
items: z.ZodArray<z.ZodObject<{
|
|
25
|
+
id: z.ZodNumber;
|
|
26
|
+
identifier: z.ZodString;
|
|
27
|
+
localizeInfos: z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodArray<z.ZodAny>]>;
|
|
28
|
+
version: z.ZodNumber;
|
|
29
|
+
position: z.ZodNumber;
|
|
30
|
+
processingType: z.ZodString;
|
|
31
|
+
type: z.ZodNullable<z.ZodString>;
|
|
32
|
+
attributeSetId: z.ZodNullable<z.ZodNumber>;
|
|
33
|
+
templateId: z.ZodNullable<z.ZodNumber>;
|
|
34
|
+
attributes: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodAny>, z.ZodRecord<z.ZodString, z.ZodAny>]>>;
|
|
35
|
+
moduleFormConfigs: z.ZodOptional<z.ZodArray<z.ZodAny>>;
|
|
36
|
+
}, z.core.$strip>>;
|
|
37
|
+
}, z.core.$strip>;
|
|
35
38
|
/**
|
|
36
39
|
* Single form response schema
|
|
37
40
|
*/
|
|
@@ -22,9 +22,12 @@ exports.FormEntitySchema = zod_1.z.object({
|
|
|
22
22
|
moduleFormConfigs: zod_1.z.array(zod_1.z.any()).optional(),
|
|
23
23
|
});
|
|
24
24
|
/**
|
|
25
|
-
* Forms response schema (
|
|
25
|
+
* Forms response schema (paginated)
|
|
26
26
|
*/
|
|
27
|
-
exports.FormsResponseSchema = zod_1.z.
|
|
27
|
+
exports.FormsResponseSchema = zod_1.z.object({
|
|
28
|
+
total: zod_1.z.number(),
|
|
29
|
+
items: zod_1.z.array(exports.FormEntitySchema),
|
|
30
|
+
});
|
|
28
31
|
/**
|
|
29
32
|
* Single form response schema
|
|
30
33
|
*/
|
|
@@ -24,6 +24,7 @@ export declare const GeneralTypeEntitySchema: z.ZodObject<{
|
|
|
24
24
|
service: "service";
|
|
25
25
|
external_page: "external_page";
|
|
26
26
|
discount: "discount";
|
|
27
|
+
frequently_ordered_block: "frequently_ordered_block";
|
|
27
28
|
}>;
|
|
28
29
|
}, z.core.$strip>;
|
|
29
30
|
/**
|
|
@@ -46,5 +47,6 @@ export declare const GeneralTypesResponseSchema: z.ZodArray<z.ZodObject<{
|
|
|
46
47
|
service: "service";
|
|
47
48
|
external_page: "external_page";
|
|
48
49
|
discount: "discount";
|
|
50
|
+
frequently_ordered_block: "frequently_ordered_block";
|
|
49
51
|
}>;
|
|
50
52
|
}, z.core.$strip>>;
|
package/dist/index.d.ts
CHANGED
|
@@ -55,29 +55,53 @@ import WsApi from './web-socket/wsApi';
|
|
|
55
55
|
* @property {WsApi} WS - WebSocket API module.
|
|
56
56
|
*/
|
|
57
57
|
interface IDefineApi {
|
|
58
|
+
/** Admin panel users management */
|
|
58
59
|
Admins: AdminsApi;
|
|
60
|
+
/** Attribute set schemas: getAttributesByMarker, getAttributeSetByMarker, getSingleAttributeByMarkerSet */
|
|
59
61
|
AttributesSets: AttributesSetsApi;
|
|
62
|
+
/** User registration, login, logout, OAuth, token refresh */
|
|
60
63
|
AuthProvider: AuthProviderApi;
|
|
64
|
+
/** Page blocks: getBlocksByPageUrl, getBlockByMarker */
|
|
61
65
|
Blocks: BlocksApi;
|
|
66
|
+
/** Subscription events: subscribe to real-time entity changes */
|
|
62
67
|
Events: EventsApi;
|
|
68
|
+
/** Discounts and promo codes */
|
|
63
69
|
Discounts: DiscountsApi;
|
|
70
|
+
/** File upload helpers: createFileFromUrl */
|
|
64
71
|
FileUploading: FileUploadingApi;
|
|
72
|
+
/** Form schemas: getFormByMarker — use for rendering dynamic forms */
|
|
65
73
|
Forms: FormsApi;
|
|
74
|
+
/** Submit form data: postFormsData */
|
|
66
75
|
FormData: FormsDataApi;
|
|
76
|
+
/** General types / custom types defined in admin panel */
|
|
67
77
|
GeneralTypes: GeneralTypesApi;
|
|
78
|
+
/** Integration collections */
|
|
68
79
|
IntegrationCollections: IntegrationCollectionsApi;
|
|
80
|
+
/** Project locales: getLocales */
|
|
69
81
|
Locales: LocalesApi;
|
|
82
|
+
/** Navigation menus: getMenusByMarker */
|
|
70
83
|
Menus: MenusApi;
|
|
84
|
+
/** Orders: createOrder, getAllOrdersByMarker, getAllOrdersStorage */
|
|
71
85
|
Orders: OrdersApi;
|
|
86
|
+
/** Pages: getPageByUrl, getPageById, getChildPages, getRootPages */
|
|
72
87
|
Pages: PagesApi;
|
|
88
|
+
/** Payments: createSession, getSessionByOrderId */
|
|
73
89
|
Payments: PaymentsApi;
|
|
90
|
+
/** Products: getProducts, getProductById, filterProducts, searchProducts */
|
|
74
91
|
Products: ProductsApi;
|
|
92
|
+
/** Product statuses: getProductStatuses */
|
|
75
93
|
ProductStatuses: ProductStatusesApi;
|
|
94
|
+
/** Sitemap generation */
|
|
76
95
|
Sitemap: SitemapApi;
|
|
96
|
+
/** System info */
|
|
77
97
|
System: SystemApi;
|
|
98
|
+
/** Page templates */
|
|
78
99
|
Templates: TemplatesApi;
|
|
100
|
+
/** Template previews */
|
|
79
101
|
TemplatePreviews: TemplatePreviewsApi;
|
|
102
|
+
/** Current authenticated user: getUser, updateUser */
|
|
80
103
|
Users: UsersApi;
|
|
104
|
+
/** WebSocket real-time updates */
|
|
81
105
|
WS: WsApi;
|
|
82
106
|
}
|
|
83
107
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import AsyncModules from '../base/asyncModules';
|
|
2
2
|
import type StateModule from '../base/stateModule';
|
|
3
3
|
import type { IError } from '../base/utils';
|
|
4
|
-
import type { IBaseOrdersEntity, ICreateOrderPreview, IOrderByMarkerEntity, IOrderData, IOrderPreviewResponse, IOrdersApi, IOrdersByMarkerEntity, IOrdersEntity, IOrderStatus } from './ordersInterfaces';
|
|
4
|
+
import type { IBaseOrdersEntity, ICreateOrderPreview, ICreateRefundRequest, IOrderByMarkerEntity, IOrderData, IOrderPreviewResponse, IOrdersApi, IOrdersByMarkerEntity, IOrdersEntity, IOrderStatus, IRefundRequest } from './ordersInterfaces';
|
|
5
5
|
/**
|
|
6
6
|
* Controllers for working with orders.
|
|
7
7
|
* @handle /api/content/orders-storage
|
|
@@ -11,6 +11,7 @@ import type { IBaseOrdersEntity, ICreateOrderPreview, IOrderByMarkerEntity, IOrd
|
|
|
11
11
|
export default class OrdersApi extends AsyncModules implements IOrdersApi {
|
|
12
12
|
protected state: StateModule;
|
|
13
13
|
protected _url: string;
|
|
14
|
+
private _ordersUrl;
|
|
14
15
|
/**
|
|
15
16
|
* Constructs an instance of the OrdersApi class.
|
|
16
17
|
* @param {StateModule} state - The state module containing the necessary information for making API calls.
|
|
@@ -146,4 +147,29 @@ export default class OrdersApi extends AsyncModules implements IOrdersApi {
|
|
|
146
147
|
* @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}.
|
|
147
148
|
*/
|
|
148
149
|
getAllStatusesByStorageMarker(marker: string, langCode?: string, offset?: number, limit?: number): Promise<IOrderStatus[] | IError>;
|
|
150
|
+
/**
|
|
151
|
+
* Get all refund requests for an order.
|
|
152
|
+
* @handleName getRefunds
|
|
153
|
+
* @param {number} id - Order id. Example: 1.
|
|
154
|
+
* @returns {Promise<IRefundRequest[] | IError>} Returns array of refund requests.
|
|
155
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
156
|
+
*/
|
|
157
|
+
getRefunds(id: number): Promise<IRefundRequest[] | IError>;
|
|
158
|
+
/**
|
|
159
|
+
* Create a refund request for an order.
|
|
160
|
+
* @handleName createRefundRequest
|
|
161
|
+
* @param {number} id - Order id. Example: 1.
|
|
162
|
+
* @param {ICreateRefundRequest} body - Refund request body.
|
|
163
|
+
* @returns {Promise<IOrdersEntity | IError>} Returns order entity.
|
|
164
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
165
|
+
*/
|
|
166
|
+
createRefundRequest(id: number, body: ICreateRefundRequest): Promise<IOrdersEntity | IError>;
|
|
167
|
+
/**
|
|
168
|
+
* Cancel a refund request for an order.
|
|
169
|
+
* @handleName cancelRefundRequest
|
|
170
|
+
* @param {number} id - Order id. Example: 1.
|
|
171
|
+
* @returns {Promise<IOrdersEntity | IError>} Returns order entity.
|
|
172
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
173
|
+
*/
|
|
174
|
+
cancelRefundRequest(id: number): Promise<IOrdersEntity | IError>;
|
|
149
175
|
}
|
package/dist/orders/ordersApi.js
CHANGED
|
@@ -20,6 +20,7 @@ class OrdersApi extends asyncModules_1.default {
|
|
|
20
20
|
constructor(state) {
|
|
21
21
|
super(state);
|
|
22
22
|
this._url = state.url + '/api/content/orders-storage';
|
|
23
|
+
this._ordersUrl = state.url + '/api/content/orders';
|
|
23
24
|
}
|
|
24
25
|
/**
|
|
25
26
|
* Getting all the order storage objects.
|
|
@@ -199,5 +200,48 @@ class OrdersApi extends asyncModules_1.default {
|
|
|
199
200
|
const data = await this._fetchGet(`/marker/${marker}/order-statuses?` + this._queryParamsToString(query));
|
|
200
201
|
return this._normalizeData(data);
|
|
201
202
|
}
|
|
203
|
+
/**
|
|
204
|
+
* Get all refund requests for an order.
|
|
205
|
+
* @handleName getRefunds
|
|
206
|
+
* @param {number} id - Order id. Example: 1.
|
|
207
|
+
* @returns {Promise<IRefundRequest[] | IError>} Returns array of refund requests.
|
|
208
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
209
|
+
*/
|
|
210
|
+
async getRefunds(id) {
|
|
211
|
+
const savedUrl = this._url;
|
|
212
|
+
this._url = this._ordersUrl;
|
|
213
|
+
const data = await this._fetchGet(`/${id}/refund`);
|
|
214
|
+
this._url = savedUrl;
|
|
215
|
+
return this._normalizeData(data);
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Create a refund request for an order.
|
|
219
|
+
* @handleName createRefundRequest
|
|
220
|
+
* @param {number} id - Order id. Example: 1.
|
|
221
|
+
* @param {ICreateRefundRequest} body - Refund request body.
|
|
222
|
+
* @returns {Promise<IOrdersEntity | IError>} Returns order entity.
|
|
223
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
224
|
+
*/
|
|
225
|
+
async createRefundRequest(id, body) {
|
|
226
|
+
const savedUrl = this._url;
|
|
227
|
+
this._url = this._ordersUrl;
|
|
228
|
+
const data = await this._fetchPost(`/${id}/refund`, body);
|
|
229
|
+
this._url = savedUrl;
|
|
230
|
+
return this._normalizeData(data);
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Cancel a refund request for an order.
|
|
234
|
+
* @handleName cancelRefundRequest
|
|
235
|
+
* @param {number} id - Order id. Example: 1.
|
|
236
|
+
* @returns {Promise<IOrdersEntity | IError>} Returns order entity.
|
|
237
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
238
|
+
*/
|
|
239
|
+
async cancelRefundRequest(id) {
|
|
240
|
+
const savedUrl = this._url;
|
|
241
|
+
this._url = this._ordersUrl;
|
|
242
|
+
const data = await this._fetchDelete(`/${id}/refund`);
|
|
243
|
+
this._url = savedUrl;
|
|
244
|
+
return this._normalizeData(data);
|
|
245
|
+
}
|
|
202
246
|
}
|
|
203
247
|
exports.default = OrdersApi;
|
|
@@ -133,6 +133,31 @@ interface IOrdersApi {
|
|
|
133
133
|
* @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}.
|
|
134
134
|
*/
|
|
135
135
|
getAllStatusesByStorageMarker(marker: string, langCode: string, offset?: number, limit?: number): Promise<IOrderStatus[] | IError>;
|
|
136
|
+
/**
|
|
137
|
+
* Get all refund requests for an order.
|
|
138
|
+
* @handleName getOrderRefunds
|
|
139
|
+
* @param {number} id - Order id.
|
|
140
|
+
* @returns {Promise<IRefundRequest[] | IError>} Returns array of refund requests.
|
|
141
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
142
|
+
*/
|
|
143
|
+
getRefunds(id: number): Promise<IRefundRequest[] | IError>;
|
|
144
|
+
/**
|
|
145
|
+
* Create a refund request for an order.
|
|
146
|
+
* @handleName createRefundRequest
|
|
147
|
+
* @param {number} id - Order id.
|
|
148
|
+
* @param {ICreateRefundRequest} body - Refund request body.
|
|
149
|
+
* @returns {Promise<IOrdersEntity | IError>} Returns order entity.
|
|
150
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
151
|
+
*/
|
|
152
|
+
createRefundRequest(id: number, body: ICreateRefundRequest): Promise<IOrdersEntity | IError>;
|
|
153
|
+
/**
|
|
154
|
+
* Cancel a refund request for an order.
|
|
155
|
+
* @handleName cancelRefundRequest
|
|
156
|
+
* @param {number} id - Order id.
|
|
157
|
+
* @returns {Promise<IOrdersEntity | IError>} Returns order entity.
|
|
158
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
159
|
+
*/
|
|
160
|
+
cancelRefundRequest(id: number): Promise<IOrdersEntity | IError>;
|
|
136
161
|
}
|
|
137
162
|
/**
|
|
138
163
|
* Interface for the orders storage object.
|
|
@@ -292,6 +317,9 @@ interface IOrderProductsData {
|
|
|
292
317
|
* @property {string} [couponCode] -
|
|
293
318
|
* @property {string[]} [additionalDiscountsMarkers] -
|
|
294
319
|
* @property {unknown} [discountConfig] -
|
|
320
|
+
* @property {number} [bonusAmount] - Bonus amount applied to the order.
|
|
321
|
+
* @property {number} [bonusApplied] - Bonus applied to the order.
|
|
322
|
+
* @property {number} [totalDue] - Total due after bonuses.
|
|
295
323
|
*/
|
|
296
324
|
interface IBaseOrdersEntity {
|
|
297
325
|
id: number;
|
|
@@ -306,6 +334,9 @@ interface IBaseOrdersEntity {
|
|
|
306
334
|
couponCode?: string;
|
|
307
335
|
additionalDiscountsMarkers?: string[];
|
|
308
336
|
discountConfig?: unknown;
|
|
337
|
+
bonusAmount?: number;
|
|
338
|
+
bonusApplied?: number;
|
|
339
|
+
totalDue?: number;
|
|
309
340
|
}
|
|
310
341
|
/**
|
|
311
342
|
* Interface representing a response from the order storage.
|
|
@@ -386,6 +417,7 @@ interface IPaymentAccountIdentifiers {
|
|
|
386
417
|
* @property {IOrderProductData[]} products - An array of ordered products. Example: [].
|
|
387
418
|
* @property {string} [couponCode] - Coupon code.
|
|
388
419
|
* @property {string[]} [additionalDiscountsMarkers] - Array of additional discount markers.
|
|
420
|
+
* @property {number} [bonusAmount] - Bonus amount to apply.
|
|
389
421
|
* @description Represents the data required to create or update an order in the order storage.
|
|
390
422
|
*/
|
|
391
423
|
interface IOrderData {
|
|
@@ -395,6 +427,7 @@ interface IOrderData {
|
|
|
395
427
|
products: IOrderProductData[];
|
|
396
428
|
couponCode?: string;
|
|
397
429
|
additionalDiscountsMarkers?: string[];
|
|
430
|
+
bonusAmount?: number;
|
|
398
431
|
}
|
|
399
432
|
/**
|
|
400
433
|
* Interface representing an order product data.
|
|
@@ -487,11 +520,13 @@ interface IPreviewOrderProduct {
|
|
|
487
520
|
* @property {IPreviewOrderProduct[]} [products] - Array of products to preview.
|
|
488
521
|
* @property {string} [couponCode] - Coupon code to apply.
|
|
489
522
|
* @property {string[]} [additionalDiscountsMarkers] - Array of additional discount markers.
|
|
523
|
+
* @property {number} [bonusAmount] - Bonus amount to apply.
|
|
490
524
|
*/
|
|
491
525
|
interface ICreateOrderPreview {
|
|
492
526
|
products?: IPreviewOrderProduct[];
|
|
493
527
|
couponCode?: string;
|
|
494
528
|
additionalDiscountsMarkers?: string[];
|
|
529
|
+
bonusAmount?: number;
|
|
495
530
|
[key: string]: unknown;
|
|
496
531
|
}
|
|
497
532
|
/**
|
|
@@ -509,6 +544,8 @@ interface IOrderPreviewItem {
|
|
|
509
544
|
* @property {unknown} discountConfig - Discount configuration applied to the order.
|
|
510
545
|
* @property {string} currency - Currency of the order. Example: "USD".
|
|
511
546
|
* @property {IOrderPreviewItem[]} orderPreview - Array of order preview items.
|
|
547
|
+
* @property {number} bonusApplied - Bonus applied to the order.
|
|
548
|
+
* @property {number} totalDue - Total due after bonuses.
|
|
512
549
|
*/
|
|
513
550
|
interface IOrderPreviewResponse {
|
|
514
551
|
totalSum: number;
|
|
@@ -516,5 +553,41 @@ interface IOrderPreviewResponse {
|
|
|
516
553
|
discountConfig: unknown;
|
|
517
554
|
currency: string;
|
|
518
555
|
orderPreview: IOrderPreviewItem[];
|
|
556
|
+
bonusApplied: number;
|
|
557
|
+
totalDue: number;
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* @interface IRefundRequest
|
|
561
|
+
* @property {number} id - Refund request id.
|
|
562
|
+
* @property {string} createdDate - Creation date.
|
|
563
|
+
* @property {string} status - Refund status.
|
|
564
|
+
* @property {number} amount - Refund amount.
|
|
565
|
+
* @property {string} note - Refund note.
|
|
566
|
+
* @property {Record<string, unknown>} products - Products for refund.
|
|
567
|
+
* @property {number} orderId - Order id.
|
|
568
|
+
* @property {number} orderStorageId - Order storage id.
|
|
569
|
+
* @property {number} userId - User id.
|
|
570
|
+
* @property {unknown} orderStorage - Order storage data.
|
|
571
|
+
* @property {unknown} user - User data.
|
|
572
|
+
*/
|
|
573
|
+
interface IRefundRequest {
|
|
574
|
+
id: number;
|
|
575
|
+
createdDate: string;
|
|
576
|
+
status: string;
|
|
577
|
+
amount: number;
|
|
578
|
+
note: string;
|
|
579
|
+
products: Record<string, unknown>;
|
|
580
|
+
orderId: number;
|
|
581
|
+
orderStorageId: number;
|
|
582
|
+
userId: number;
|
|
583
|
+
orderStorage: unknown;
|
|
584
|
+
user: unknown;
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* @interface ICreateRefundRequest
|
|
588
|
+
* @description Body for creating a refund request.
|
|
589
|
+
*/
|
|
590
|
+
interface ICreateRefundRequest {
|
|
591
|
+
[key: string]: unknown;
|
|
519
592
|
}
|
|
520
|
-
export type { IBaseOrdersEntity, IBaseOrdersEntityResponse, ICreateOrderPreview, IOrderByMarkerEntity, IOrderData, IOrderPreviewItem, IOrderPreviewResponse, IOrderProductData, IOrderProducts, IOrdersApi, IOrdersByMarkerEntity, IOrdersEntity, IOrdersFormData, IOrderStatus, IPaymentAccountIdentifiers, IPicture, IPreviewOrderProduct, };
|
|
593
|
+
export type { IBaseOrdersEntity, IBaseOrdersEntityResponse, ICreateOrderPreview, ICreateRefundRequest, IOrderByMarkerEntity, IOrderData, IOrderPreviewItem, IOrderPreviewResponse, IOrderProductData, IOrderProducts, IOrdersApi, IOrdersByMarkerEntity, IOrdersEntity, IOrdersFormData, IOrderStatus, IPaymentAccountIdentifiers, IPicture, IPreviewOrderProduct, IRefundRequest, };
|
|
@@ -255,6 +255,7 @@ interface IPositionBlock {
|
|
|
255
255
|
"position": 1
|
|
256
256
|
}
|
|
257
257
|
* @property {Array<IFormConfig>} [moduleFormConfigs] - Module form configurations linked to the page.
|
|
258
|
+
* @property {Record<string, unknown>} [rating] - Rating data.
|
|
258
259
|
* @property {string} [total] - Total number of products linked to the page. Example: "10".
|
|
259
260
|
* @property {string} [categoryPath] - Category path string. Example: "catalog".
|
|
260
261
|
* @description This interface defines the structure of a page entity, including its identifiers, attributes, and hierarchical relationships.
|
|
@@ -271,6 +272,7 @@ interface IPagesEntity {
|
|
|
271
272
|
attributeSetIdentifier: string | null;
|
|
272
273
|
attributeValues: AttributeType;
|
|
273
274
|
moduleFormConfigs?: IFormConfig[];
|
|
275
|
+
rating?: Record<string, unknown>;
|
|
274
276
|
isSync: boolean;
|
|
275
277
|
template?: ITemplateEntity;
|
|
276
278
|
blocks?: IBlockEntity[] | string[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import AsyncModules from '../base/asyncModules';
|
|
2
2
|
import type StateModule from '../base/stateModule';
|
|
3
3
|
import type { IError } from '../base/utils';
|
|
4
|
-
import type { IFilterParams, IProductBlock, IProductsApi, IProductsCount, IProductsEntity, IProductsInfo, IProductsQuery, IProductsResponse } from './productsInterfaces';
|
|
4
|
+
import type { IAggregatedProductGroup, IFilterParams, IProductBlock, IProductsApi, IProductsCount, IProductsEntity, IProductsInfo, IProductsQuery, IProductsResponse } from './productsInterfaces';
|
|
5
5
|
/**
|
|
6
6
|
* Controllers for working with product pages
|
|
7
7
|
* @handle /api/content/products
|
|
@@ -65,8 +65,9 @@ export default class ProductsApi extends AsyncModules implements IProductsApi {
|
|
|
65
65
|
*/
|
|
66
66
|
getProducts(body?: IFilterParams[], langCode?: string, userQuery?: IProductsQuery): Promise<IProductsResponse | IError>;
|
|
67
67
|
/**
|
|
68
|
-
* Search for all product page objects with pagination that do not have a category.
|
|
68
|
+
* Search for all product page objects with pagination (and aggregation) that do not have a category.
|
|
69
69
|
* @handleName getProductsEmptyPage
|
|
70
|
+
* @param {object} [body] - Request body. Default: {}.
|
|
70
71
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
71
72
|
* @param {IProductsQuery} [userQuery] - Optional set query parameters.
|
|
72
73
|
* @example
|
|
@@ -81,11 +82,11 @@ export default class ProductsApi extends AsyncModules implements IProductsApi {
|
|
|
81
82
|
"conditionMarker": "equals",
|
|
82
83
|
"attributeMarker": "color"
|
|
83
84
|
}
|
|
84
|
-
* @returns {Promise<
|
|
85
|
+
* @returns {Promise<IAggregatedProductGroup[] | IError>} Array with AggregatedProductGroup objects.
|
|
85
86
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
86
|
-
* @description Search for all product page objects with pagination that do not have a category.
|
|
87
|
+
* @description Search for all product page objects with pagination (and aggregation) that do not have a category.
|
|
87
88
|
*/
|
|
88
|
-
getProductsEmptyPage(langCode?: string, userQuery?: IProductsQuery): Promise<
|
|
89
|
+
getProductsEmptyPage(body?: object, langCode?: string, userQuery?: IProductsQuery): Promise<IAggregatedProductGroup[] | IError>;
|
|
89
90
|
/**
|
|
90
91
|
* Search for all products with pagination for the selected category.
|
|
91
92
|
* @handleName getProductsByPageId
|
|
@@ -73,14 +73,15 @@ class ProductsApi extends asyncModules_1.default {
|
|
|
73
73
|
...userQuery,
|
|
74
74
|
langCode,
|
|
75
75
|
};
|
|
76
|
-
const result = await this._fetchPost(`/all?` + this._queryParamsToString(query), body);
|
|
76
|
+
const result = await this._fetchPost(`/all?` + this._queryParamsToString(query), { filter: body });
|
|
77
77
|
// Validate response if validation is enabled
|
|
78
78
|
const validated = this._validateResponse(result, productsSchemas_1.ProductsResponseSchema);
|
|
79
79
|
return this._dataPostProcess(validated, langCode);
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
82
|
-
* Search for all product page objects with pagination that do not have a category.
|
|
82
|
+
* Search for all product page objects with pagination (and aggregation) that do not have a category.
|
|
83
83
|
* @handleName getProductsEmptyPage
|
|
84
|
+
* @param {object} [body] - Request body. Default: {}.
|
|
84
85
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
85
86
|
* @param {IProductsQuery} [userQuery] - Optional set query parameters.
|
|
86
87
|
* @example
|
|
@@ -95,16 +96,14 @@ class ProductsApi extends asyncModules_1.default {
|
|
|
95
96
|
"conditionMarker": "equals",
|
|
96
97
|
"attributeMarker": "color"
|
|
97
98
|
}
|
|
98
|
-
* @returns {Promise<
|
|
99
|
+
* @returns {Promise<IAggregatedProductGroup[] | IError>} Array with AggregatedProductGroup objects.
|
|
99
100
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
100
|
-
* @description Search for all product page objects with pagination that do not have a category.
|
|
101
|
+
* @description Search for all product page objects with pagination (and aggregation) that do not have a category.
|
|
101
102
|
*/
|
|
102
|
-
async getProductsEmptyPage(langCode = this.state.lang, userQuery) {
|
|
103
|
-
const query = { ...userQuery };
|
|
104
|
-
const result = await this.
|
|
105
|
-
|
|
106
|
-
const validated = this._validateResponse(result, productsSchemas_1.ProductsResponseSchema);
|
|
107
|
-
return this._dataPostProcess(validated, langCode);
|
|
103
|
+
async getProductsEmptyPage(body = {}, langCode = this.state.lang, userQuery) {
|
|
104
|
+
const query = { ...userQuery, langCode };
|
|
105
|
+
const result = await this._fetchPost(`/empty-page?` + this._queryParamsToString(query), body);
|
|
106
|
+
return this._normalizeData(result);
|
|
108
107
|
}
|
|
109
108
|
/**
|
|
110
109
|
* Search for all products with pagination for the selected category.
|
|
@@ -155,7 +154,7 @@ class ProductsApi extends asyncModules_1.default {
|
|
|
155
154
|
*/
|
|
156
155
|
async getProductsByPageId(id, body = [], langCode = this.state.lang, userQuery) {
|
|
157
156
|
const query = { ...userQuery };
|
|
158
|
-
const result = await this._fetchPost(`/page/${id}?langCode=${langCode}&` + this._queryParamsToString(query), body);
|
|
157
|
+
const result = await this._fetchPost(`/page/${id}?langCode=${langCode}&` + this._queryParamsToString(query), { filter: body });
|
|
159
158
|
// Validate response if validation is enabled
|
|
160
159
|
const validated = this._validateResponse(result, productsSchemas_1.ProductsResponseSchema);
|
|
161
160
|
return this._dataPostProcess(validated, langCode);
|
|
@@ -240,7 +239,7 @@ class ProductsApi extends asyncModules_1.default {
|
|
|
240
239
|
async getProductsByPageUrl(url, body = [], langCode = this.state.lang, userQuery) {
|
|
241
240
|
const query = { ...userQuery };
|
|
242
241
|
const result = await this._fetchPost(`/page/url/${url}?langCode=${langCode}&` +
|
|
243
|
-
this._queryParamsToString(query), body);
|
|
242
|
+
this._queryParamsToString(query), { filter: body });
|
|
244
243
|
// Validate response if validation is enabled
|
|
245
244
|
const validated = this._validateResponse(result, productsSchemas_1.ProductsResponseSchema);
|
|
246
245
|
return this._dataPostProcess(validated, langCode);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AttributeType, IError, ILocalizeInfo,
|
|
1
|
+
import type { AttributeType, IError, ILocalizeInfo, Types } from '../base/utils';
|
|
2
2
|
import type { IFormConfig } from '../forms/formsInterfaces';
|
|
3
3
|
/**
|
|
4
4
|
* @interface IProductsApi
|
|
@@ -54,6 +54,7 @@ interface IProductsApi {
|
|
|
54
54
|
/**
|
|
55
55
|
* Search for all product page objects with pagination that do not have a category.
|
|
56
56
|
* @handleName getProductsEmptyPage
|
|
57
|
+
* @param body
|
|
57
58
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
58
59
|
* @param {IProductsQuery} [userQuery] - Optional set query parameters.
|
|
59
60
|
* @example
|
|
@@ -72,7 +73,7 @@ interface IProductsApi {
|
|
|
72
73
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
73
74
|
* @description This method searches for all product page objects with pagination that do not have a category.
|
|
74
75
|
*/
|
|
75
|
-
getProductsEmptyPage(langCode?:
|
|
76
|
+
getProductsEmptyPage(body?: object, langCode?: string, userQuery?: IProductsQuery): Promise<IAggregatedProductGroup[] | IError>;
|
|
76
77
|
/**
|
|
77
78
|
* Search for all products with pagination for the selected category.
|
|
78
79
|
* @handleName getProductsByPageId
|
|
@@ -402,6 +403,7 @@ interface IFilterParams {
|
|
|
402
403
|
]
|
|
403
404
|
* @property {boolean} isVisible - A sign of page visibility. Example: true.
|
|
404
405
|
* @property {Array<IFormConfig>} [moduleFormConfigs] - Module form configurations (optional).
|
|
406
|
+
* @property {Record<string, unknown>} [rating] - Rating data.
|
|
405
407
|
* @property {boolean} isPositionLocked - Sorting position lock indicator (optional). Example: false.
|
|
406
408
|
* @property {number[]} relatedIds - Ids of related product pages.
|
|
407
409
|
* @example
|
|
@@ -443,6 +445,7 @@ interface IProductsEntity {
|
|
|
443
445
|
categories: string[];
|
|
444
446
|
isVisible: boolean;
|
|
445
447
|
moduleFormConfigs?: Array<IFormConfig>;
|
|
448
|
+
rating?: Record<string, unknown>;
|
|
446
449
|
templateIdentifier?: string | null;
|
|
447
450
|
shortDescTemplateIdentifier?: string | null;
|
|
448
451
|
signedPrice?: string;
|
|
@@ -574,4 +577,17 @@ interface IProductBlock {
|
|
|
574
577
|
isSync: boolean;
|
|
575
578
|
attributeValues: AttributeType;
|
|
576
579
|
}
|
|
577
|
-
|
|
580
|
+
/**
|
|
581
|
+
* @interface IAggregatedProductGroup
|
|
582
|
+
* @property {string} attrValue - Attribute value.
|
|
583
|
+
* @property {IProductsEntity[]} items - Array of product entities.
|
|
584
|
+
* @property {string[]} productIds - Array of product ids.
|
|
585
|
+
* @property {number} total - Total count.
|
|
586
|
+
*/
|
|
587
|
+
interface IAggregatedProductGroup {
|
|
588
|
+
attrValue: string;
|
|
589
|
+
items: IProductsEntity[];
|
|
590
|
+
productIds: string[];
|
|
591
|
+
total: number;
|
|
592
|
+
}
|
|
593
|
+
export type { IAggregatedProductGroup, IFilterParams, IProductBlock, IProductInfo, IProductsApi, IProductsCount, IProductsEntity, IProductsInfo, IProductsQuery, IProductsResponse, };
|
|
@@ -3,9 +3,9 @@ import type StateModule from '../base/stateModule';
|
|
|
3
3
|
import type { IError } from '../base/utils';
|
|
4
4
|
import type { ISystemApi } from './systemInterfaces';
|
|
5
5
|
/**
|
|
6
|
-
* Controllers for working with system
|
|
6
|
+
* Controllers for working with system components
|
|
7
7
|
* @handle /api/content/system
|
|
8
|
-
* @description Controllers for working with system
|
|
8
|
+
* @description Controllers for working with system components
|
|
9
9
|
*/
|
|
10
10
|
export default class SystemApi extends AsyncModules implements ISystemApi {
|
|
11
11
|
protected state: StateModule;
|
package/dist/system/systemApi.js
CHANGED
|
@@ -5,9 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const asyncModules_1 = __importDefault(require("../base/asyncModules"));
|
|
7
7
|
/**
|
|
8
|
-
* Controllers for working with system
|
|
8
|
+
* Controllers for working with system components
|
|
9
9
|
* @handle /api/content/system
|
|
10
|
-
* @description Controllers for working with system
|
|
10
|
+
* @description Controllers for working with system components
|
|
11
11
|
*/
|
|
12
12
|
class SystemApi extends asyncModules_1.default {
|
|
13
13
|
/**
|
|
@@ -161,6 +161,7 @@ interface IUsersApi {
|
|
|
161
161
|
"key": "value"
|
|
162
162
|
}
|
|
163
163
|
* @property {Array<IFormConfig>} [moduleFormConfigs] - Optional array of form configuration objects associated with the user.
|
|
164
|
+
* @property {Record<string, unknown>} [rating] - Rating data.
|
|
164
165
|
* @description Represents a user entity with various properties, including identifiers, form data, and user groups.
|
|
165
166
|
*/
|
|
166
167
|
interface IUserEntity {
|
|
@@ -173,6 +174,7 @@ interface IUserEntity {
|
|
|
173
174
|
groups: Array<string | number>;
|
|
174
175
|
state: Record<string, any>;
|
|
175
176
|
moduleFormConfigs?: Array<IFormConfig>;
|
|
177
|
+
rating?: Record<string, unknown>;
|
|
176
178
|
}
|
|
177
179
|
/**
|
|
178
180
|
* @interface IUserBody
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oneentry",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.144",
|
|
4
4
|
"description": "OneEntry NPM package",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"bin": {
|
|
11
11
|
"oneentry": "./configure.js"
|
|
12
12
|
},
|
|
13
|
-
"author": "ONEENTRY PORTAL
|
|
13
|
+
"author": "ONEENTRY PORTAL CO.",
|
|
14
14
|
"license": "ISC",
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"socket.io-client": "^4.8.3",
|