oneentry 1.0.149 → 1.0.151
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/README.md +8 -0
- package/changelog.md +453 -0
- package/dist/base/asyncModules.js +13 -0
- package/dist/base/stateModule.d.ts +1 -0
- package/dist/base/stateModule.js +3 -0
- package/dist/base/syncModules.d.ts +30 -1
- package/dist/base/syncModules.js +102 -30
- package/dist/base/utils.d.ts +4 -1
- package/dist/blocks/blocksApi.d.ts +124 -3
- package/dist/blocks/blocksApi.js +169 -4
- package/dist/blocks/blocksInterfaces.d.ts +177 -4
- package/dist/blocks/blocksSchemas.d.ts +4 -0
- package/dist/events/eventsApi.d.ts +42 -1
- package/dist/events/eventsApi.js +67 -0
- package/dist/events/eventsInterfaces.d.ts +79 -1
- package/dist/file-uploading/fileUploadingInterfaces.d.ts +2 -0
- package/dist/file-uploading/fileUploadingSchemas.d.ts +2 -0
- package/dist/file-uploading/fileUploadingSchemas.js +1 -0
- package/dist/filters/filtersApi.d.ts +31 -0
- package/dist/filters/filtersApi.js +40 -0
- package/dist/filters/filtersInterfaces.d.ts +56 -0
- package/dist/filters/filtersInterfaces.js +2 -0
- package/dist/filters/filtersSchemas.d.ts +32 -0
- package/dist/filters/filtersSchemas.js +29 -0
- package/dist/forms-data/formsDataInterfaces.d.ts +2 -2
- package/dist/forms-data/formsDataSchemas.d.ts +1 -1
- package/dist/forms-data/formsDataSchemas.js +1 -1
- package/dist/general-types/generalTypesSchemas.d.ts +16 -0
- package/dist/general-types/generalTypesSchemas.js +10 -1
- package/dist/index.d.ts +13 -0
- package/dist/index.js +10 -0
- package/dist/orders/ordersInterfaces.d.ts +51 -3
- package/dist/orders/ordersSchemas.d.ts +127 -31
- package/dist/orders/ordersSchemas.js +53 -30
- package/dist/pages/pagesInterfaces.d.ts +14 -8
- package/dist/pages/pagesSchemas.d.ts +24 -9
- package/dist/pages/pagesSchemas.js +4 -3
- package/dist/products/productsApi.d.ts +19 -1
- package/dist/products/productsApi.js +42 -8
- package/dist/products/productsInterfaces.d.ts +35 -6
- package/dist/products/productsSchemas.d.ts +4 -0
- package/dist/products/productsSchemas.js +1 -0
- package/dist/subscriptions/subscriptionsApi.d.ts +69 -0
- package/dist/subscriptions/subscriptionsApi.js +102 -0
- package/dist/subscriptions/subscriptionsInterfaces.d.ts +90 -0
- package/dist/subscriptions/subscriptionsInterfaces.js +2 -0
- package/dist/subscriptions/subscriptionsSchemas.d.ts +20 -0
- package/dist/subscriptions/subscriptionsSchemas.js +23 -0
- package/dist/user-activity/userActivityApi.d.ts +30 -0
- package/dist/user-activity/userActivityApi.js +42 -0
- package/dist/user-activity/userActivityInterfaces.d.ts +42 -0
- package/dist/user-activity/userActivityInterfaces.js +2 -0
- package/dist/users/usersApi.d.ts +79 -1
- package/dist/users/usersApi.js +110 -0
- package/dist/users/usersInterfaces.d.ts +155 -1
- package/dist/users/usersSchemas.d.ts +40 -0
- package/dist/users/usersSchemas.js +34 -1
- package/package.json +3 -2
|
@@ -9,7 +9,7 @@ interface IBlocks {
|
|
|
9
9
|
/**
|
|
10
10
|
* Retrieves all block objects of a specific type.
|
|
11
11
|
* @handleName getBlocks
|
|
12
|
-
* @param {BlockType} type -
|
|
12
|
+
* @param {BlockType} [type] - Optional type of blocks to retrieve. When omitted, blocks of all types are returned. Example: "product".
|
|
13
13
|
* @param {string} [langCode] - Optional language code for localization. Default: "en_US".
|
|
14
14
|
* @param {number} [offset] - Optional offset for pagination. Default: 0.
|
|
15
15
|
* @param {number} [limit] - Optional limit for pagination. Default: 30.
|
|
@@ -17,7 +17,7 @@ interface IBlocks {
|
|
|
17
17
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
18
18
|
* @description This method retrieves all block objects of a specific type.
|
|
19
19
|
*/
|
|
20
|
-
getBlocks(type
|
|
20
|
+
getBlocks(type?: BlockType, langCode?: string, offset?: number, limit?: number): Promise<IBlocksResponse | IError>;
|
|
21
21
|
/**
|
|
22
22
|
* Retrieves a block object by its marker.
|
|
23
23
|
* @handleName getBlockByMarker
|
|
@@ -51,6 +51,126 @@ interface IBlocks {
|
|
|
51
51
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
52
52
|
*/
|
|
53
53
|
getFrequentlyOrderedProducts(productId: number, marker: string, langCode?: string, signPrice?: string): Promise<IProductsResponse | IError>;
|
|
54
|
+
/**
|
|
55
|
+
* Get "complete your cart" products by the cart from context (auth user or guest).
|
|
56
|
+
* @handleName getCartComplement
|
|
57
|
+
* @param {string} marker - Block marker. Example: "cart_complement_block".
|
|
58
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
59
|
+
* @param {string} [signPrice] - Sign price.
|
|
60
|
+
* @returns {IProductsEntity[]} A promise that resolves to an array of products or an error.
|
|
61
|
+
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
62
|
+
*/
|
|
63
|
+
getCartComplement(marker: string, langCode?: string, signPrice?: string): Promise<IProductsEntity[] | IError>;
|
|
64
|
+
/**
|
|
65
|
+
* Get "complete your cart" products by an explicit list of productIds (POST body).
|
|
66
|
+
* @handleName getCartComplementByProductIds
|
|
67
|
+
* @param {string} marker - Block marker. Example: "cart_complement_block".
|
|
68
|
+
* @param {IBlockProductsLookup} body - Lookup body.
|
|
69
|
+
* @example
|
|
70
|
+
{
|
|
71
|
+
"productIds": [1, 2],
|
|
72
|
+
"langCode": "en_US"
|
|
73
|
+
}
|
|
74
|
+
* @returns {IProductsEntity[]} A promise that resolves to an array of products or an error.
|
|
75
|
+
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
76
|
+
*/
|
|
77
|
+
getCartComplementByProductIds(marker: string, body: IBlockProductsLookup): Promise<IProductsEntity[] | IError>;
|
|
78
|
+
/**
|
|
79
|
+
* Get "similar to cart" products by the cart from context (auth user or guest).
|
|
80
|
+
* @handleName getCartSimilar
|
|
81
|
+
* @param {string} marker - Block marker. Example: "cart_similar_block".
|
|
82
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
83
|
+
* @param {string} [signPrice] - Sign price.
|
|
84
|
+
* @returns {IProductsEntity[]} A promise that resolves to an array of products or an error.
|
|
85
|
+
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
86
|
+
*/
|
|
87
|
+
getCartSimilar(marker: string, langCode?: string, signPrice?: string): Promise<IProductsEntity[] | IError>;
|
|
88
|
+
/**
|
|
89
|
+
* Get "similar to cart" products by an explicit list of productIds (POST body).
|
|
90
|
+
* @handleName getCartSimilarByProductIds
|
|
91
|
+
* @param {string} marker - Block marker. Example: "cart_similar_block".
|
|
92
|
+
* @param {IBlockProductsLookup} body - Lookup body.
|
|
93
|
+
* @example
|
|
94
|
+
{
|
|
95
|
+
"productIds": [1, 2],
|
|
96
|
+
"langCode": "en_US"
|
|
97
|
+
}
|
|
98
|
+
* @returns {IProductsEntity[]} A promise that resolves to an array of products or an error.
|
|
99
|
+
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
100
|
+
*/
|
|
101
|
+
getCartSimilarByProductIds(marker: string, body: IBlockProductsLookup): Promise<IProductsEntity[] | IError>;
|
|
102
|
+
/**
|
|
103
|
+
* Get personal recommendations for the user.
|
|
104
|
+
* @handleName getPersonalRecommendations
|
|
105
|
+
* @param {string} marker - Block marker. Example: "personal_recommendations_block".
|
|
106
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
107
|
+
* @param {string} [signPrice] - Sign price.
|
|
108
|
+
* @returns {IProductsEntity[]} A promise that resolves to an array of products or an error.
|
|
109
|
+
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
110
|
+
*/
|
|
111
|
+
getPersonalRecommendations(marker: string, langCode?: string, signPrice?: string): Promise<IProductsEntity[] | IError>;
|
|
112
|
+
/**
|
|
113
|
+
* Get recently viewed products.
|
|
114
|
+
* @handleName getRecentlyViewed
|
|
115
|
+
* @param {string} marker - Block marker. Example: "recently_viewed_block".
|
|
116
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
117
|
+
* @param {string} [signPrice] - Sign price.
|
|
118
|
+
* @returns {IProductsEntity[]} A promise that resolves to an array of products or an error.
|
|
119
|
+
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
120
|
+
*/
|
|
121
|
+
getRecentlyViewed(marker: string, langCode?: string, signPrice?: string): Promise<IProductsEntity[] | IError>;
|
|
122
|
+
/**
|
|
123
|
+
* Get products for repeat purchase.
|
|
124
|
+
* @handleName getRepeatPurchase
|
|
125
|
+
* @param {string} marker - Block marker. Example: "repeat_purchase_block".
|
|
126
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
127
|
+
* @param {string} [signPrice] - Sign price.
|
|
128
|
+
* @returns {IProductsEntity[]} A promise that resolves to an array of products or an error.
|
|
129
|
+
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
130
|
+
*/
|
|
131
|
+
getRepeatPurchase(marker: string, langCode?: string, signPrice?: string): Promise<IProductsEntity[] | IError>;
|
|
132
|
+
/**
|
|
133
|
+
* Get the block's slides tree as a flat pre-order array (slider_block only).
|
|
134
|
+
* @handleName getSlides
|
|
135
|
+
* @param {string} marker - Block marker. Example: "slider_block".
|
|
136
|
+
* @returns {IBlockSlidesResponse} A promise that resolves to the slides response or an error.
|
|
137
|
+
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
138
|
+
*/
|
|
139
|
+
getSlides(marker: string): Promise<IBlockSlidesResponse | IError>;
|
|
140
|
+
/**
|
|
141
|
+
* Get trending products of the block.
|
|
142
|
+
* @handleName getTrending
|
|
143
|
+
* @param {string} marker - Block marker. Example: "trending_block".
|
|
144
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
145
|
+
* @param {string} [signPrice] - Sign price.
|
|
146
|
+
* @returns {IProductsEntity[]} A promise that resolves to an array of products or an error.
|
|
147
|
+
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
148
|
+
*/
|
|
149
|
+
getTrending(marker: string, langCode?: string, signPrice?: string): Promise<IProductsEntity[] | IError>;
|
|
150
|
+
/**
|
|
151
|
+
* Get "similar to wishlist" products by the wishlist from context (auth user or guest).
|
|
152
|
+
* @handleName getWishlistSimilar
|
|
153
|
+
* @param {string} marker - Block marker. Example: "wishlist_similar_block".
|
|
154
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
155
|
+
* @param {string} [signPrice] - Sign price.
|
|
156
|
+
* @returns {IProductsEntity[]} A promise that resolves to an array of products or an error.
|
|
157
|
+
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
158
|
+
*/
|
|
159
|
+
getWishlistSimilar(marker: string, langCode?: string, signPrice?: string): Promise<IProductsEntity[] | IError>;
|
|
160
|
+
/**
|
|
161
|
+
* Get "similar to wishlist" products by an explicit list of productIds (POST body).
|
|
162
|
+
* @handleName getWishlistSimilarByProductIds
|
|
163
|
+
* @param {string} marker - Block marker. Example: "wishlist_similar_block".
|
|
164
|
+
* @param {IBlockProductsLookup} body - Lookup body.
|
|
165
|
+
* @example
|
|
166
|
+
{
|
|
167
|
+
"productIds": [1, 2],
|
|
168
|
+
"langCode": "en_US"
|
|
169
|
+
}
|
|
170
|
+
* @returns {IProductsEntity[]} A promise that resolves to an array of products or an error.
|
|
171
|
+
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
172
|
+
*/
|
|
173
|
+
getWishlistSimilarByProductIds(marker: string, body: IBlockProductsLookup): Promise<IProductsEntity[] | IError>;
|
|
54
174
|
}
|
|
55
175
|
/**
|
|
56
176
|
* Represents a response from the blocks API.
|
|
@@ -175,5 +295,58 @@ interface ISearchBlock {
|
|
|
175
295
|
* @type {BlockType}
|
|
176
296
|
* @description This type defines the possible values for block types used in the system.
|
|
177
297
|
*/
|
|
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';
|
|
179
|
-
|
|
298
|
+
type BlockType = 'product' | 'error_page' | 'catalog_page' | 'product_preview' | 'similar_products_block' | 'product_block' | 'frequently_ordered_block' | 'trending_block' | 'recently_viewed_block' | 'repeat_purchase_block' | 'slider_block' | 'personal_recommendations_block' | 'cart_complement_block' | 'cart_similar_block' | 'wishlist_similar_block' | 'form' | 'common_page' | 'common_block' | 'order' | 'service' | 'external_page' | 'discount' | 'none';
|
|
299
|
+
/**
|
|
300
|
+
* Lookup body for block product endpoints by explicit productIds.
|
|
301
|
+
* @interface IBlockProductsLookup
|
|
302
|
+
* @property {number[]} productIds - Product identifiers to look up. Example: [1, 2, 3].
|
|
303
|
+
* @property {string} [langCode] - Language code. Default: "en_US".
|
|
304
|
+
* @property {number} [limit] - Max number of products to return. Example: 10.
|
|
305
|
+
* @property {string} [signPrice] - Sign price.
|
|
306
|
+
* @description Body for the POST block product endpoints (cart-complement / cart-similar / wishlist-similar) that accept an explicit list of productIds.
|
|
307
|
+
*/
|
|
308
|
+
interface IBlockProductsLookup {
|
|
309
|
+
productIds: number[];
|
|
310
|
+
langCode?: string;
|
|
311
|
+
limit?: number;
|
|
312
|
+
signPrice?: string;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* A single slide item of a slider block (flat pre-order tree node).
|
|
316
|
+
* @interface IBlockSlideItem
|
|
317
|
+
* @property {number} id - Slide identifier. Example: 1.
|
|
318
|
+
* @property {number | null} [parentId] - Parent slide identifier, or null for root slides. Example: null.
|
|
319
|
+
* @property {number} depth - Depth of the slide in the tree. Example: 0.
|
|
320
|
+
* @property {number} position - Position of the slide among its siblings. Example: 1.
|
|
321
|
+
* @property {boolean} visible - Whether the slide is visible. Example: true.
|
|
322
|
+
* @property {number} [time] - Display time for the slide. Example: 5.
|
|
323
|
+
* @property {'sec' | 'ms'} [timeInterval] - Unit of the time field. Example: "sec".
|
|
324
|
+
* @property {IAttributeValues} attributeValues - Map of attribute values keyed by marker.
|
|
325
|
+
* @description A single slide item returned in the slides flat pre-order array.
|
|
326
|
+
*/
|
|
327
|
+
interface IBlockSlideItem {
|
|
328
|
+
id: number;
|
|
329
|
+
parentId?: number | null;
|
|
330
|
+
depth: number;
|
|
331
|
+
position: number;
|
|
332
|
+
visible: boolean;
|
|
333
|
+
time?: number;
|
|
334
|
+
timeInterval?: 'sec' | 'ms';
|
|
335
|
+
attributeValues: IAttributeValues;
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Slides response for a slider block.
|
|
339
|
+
* @interface IBlockSlidesResponse
|
|
340
|
+
* @property {number} total - Total number of slides. Example: 3.
|
|
341
|
+
* @property {number} [time] - Default display time for slides. Example: 5.
|
|
342
|
+
* @property {'sec' | 'ms'} [timeInterval] - Unit of the time field. Example: "sec".
|
|
343
|
+
* @property {IBlockSlideItem[]} items - Flat pre-order array of slide items.
|
|
344
|
+
* @description Response of the block slides endpoint (slider_block only).
|
|
345
|
+
*/
|
|
346
|
+
interface IBlockSlidesResponse {
|
|
347
|
+
total: number;
|
|
348
|
+
time?: number;
|
|
349
|
+
timeInterval?: 'sec' | 'ms';
|
|
350
|
+
items: IBlockSlideItem[];
|
|
351
|
+
}
|
|
352
|
+
export type { BlockType, IBlockEntity, IBlockProductsLookup, IBlocks, IBlockSlideItem, IBlockSlidesResponse, IBlocksResponse, ISearchBlock, };
|
|
@@ -49,6 +49,7 @@ export declare const BlockEntitySchema: z.ZodObject<{
|
|
|
49
49
|
isPositionLocked: z.ZodOptional<z.ZodBoolean>;
|
|
50
50
|
relatedIds: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
51
51
|
paymentStages: z.ZodNullable<z.ZodOptional<z.ZodAny>>;
|
|
52
|
+
distance: z.ZodOptional<z.ZodNumber>;
|
|
52
53
|
discountConfig: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
53
54
|
}, z.core.$strip>>;
|
|
54
55
|
total: z.ZodNumber;
|
|
@@ -90,6 +91,7 @@ export declare const BlockEntitySchema: z.ZodObject<{
|
|
|
90
91
|
isPositionLocked: z.ZodOptional<z.ZodBoolean>;
|
|
91
92
|
relatedIds: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
92
93
|
paymentStages: z.ZodNullable<z.ZodOptional<z.ZodAny>>;
|
|
94
|
+
distance: z.ZodOptional<z.ZodNumber>;
|
|
93
95
|
discountConfig: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
94
96
|
}, z.core.$strip>>>;
|
|
95
97
|
}, z.core.$strip>;
|
|
@@ -143,6 +145,7 @@ export declare const BlocksResponseSchema: z.ZodObject<{
|
|
|
143
145
|
isPositionLocked: z.ZodOptional<z.ZodBoolean>;
|
|
144
146
|
relatedIds: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
145
147
|
paymentStages: z.ZodNullable<z.ZodOptional<z.ZodAny>>;
|
|
148
|
+
distance: z.ZodOptional<z.ZodNumber>;
|
|
146
149
|
discountConfig: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
147
150
|
}, z.core.$strip>>;
|
|
148
151
|
total: z.ZodNumber;
|
|
@@ -184,6 +187,7 @@ export declare const BlocksResponseSchema: z.ZodObject<{
|
|
|
184
187
|
isPositionLocked: z.ZodOptional<z.ZodBoolean>;
|
|
185
188
|
relatedIds: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
186
189
|
paymentStages: z.ZodNullable<z.ZodOptional<z.ZodAny>>;
|
|
190
|
+
distance: z.ZodOptional<z.ZodNumber>;
|
|
187
191
|
discountConfig: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
188
192
|
}, z.core.$strip>>>;
|
|
189
193
|
}, z.core.$strip>>;
|
|
@@ -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 { IEvents, ISubscriptions } from './eventsInterfaces';
|
|
4
|
+
import type { IContentApiEvent, IEvents, IListFormSubscription, ISubscribeFormEvent, ISubscriptions } from './eventsInterfaces';
|
|
5
5
|
/**
|
|
6
6
|
* Controllers for working with events
|
|
7
7
|
* @handle /api/content/events
|
|
@@ -57,4 +57,45 @@ export default class EventsApi extends AsyncModules implements IEvents {
|
|
|
57
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
58
|
*/
|
|
59
59
|
unsubscribeByMarker(marker: string, productId: number, langCode?: string): Promise<boolean | IError>;
|
|
60
|
+
/**
|
|
61
|
+
* Returns all available events.
|
|
62
|
+
* @handleName getAllEvents
|
|
63
|
+
* @returns {Promise<IContentApiEvent[] | IError>} Returns an array of available events.
|
|
64
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
65
|
+
* @description This method returns all available events.
|
|
66
|
+
*/
|
|
67
|
+
getAllEvents(): Promise<IContentApiEvent[] | IError>;
|
|
68
|
+
/**
|
|
69
|
+
* Subscribe to a form event by marker.
|
|
70
|
+
* @handleName subscribeToForm
|
|
71
|
+
* @param {string} marker - Event marker. Example: "form_marker".
|
|
72
|
+
* @param {ISubscribeFormEvent} body - Subscription body. Example: `{ formDataId: 123 }`.
|
|
73
|
+
* @returns {Promise<boolean | IError>} Returns true if the subscription was successful, or an error object.
|
|
74
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
75
|
+
* @description This method requires user authorization.
|
|
76
|
+
* @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}.
|
|
77
|
+
*/
|
|
78
|
+
subscribeToForm(marker: string, body: ISubscribeFormEvent): Promise<boolean | IError>;
|
|
79
|
+
/**
|
|
80
|
+
* Returns all form subscriptions.
|
|
81
|
+
* @handleName getFormSubscriptions
|
|
82
|
+
* @param {number} [offset] - Optional offset for pagination. Default: 0.
|
|
83
|
+
* @param {number} [limit] - Optional limit for pagination. Default: 30.
|
|
84
|
+
* @returns {Promise<IListFormSubscription[] | IError>} Returns an array of form subscriptions.
|
|
85
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
86
|
+
* @description This method requires user authorization.
|
|
87
|
+
* @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}.
|
|
88
|
+
*/
|
|
89
|
+
getFormSubscriptions(offset?: number, limit?: number): Promise<IListFormSubscription[] | IError>;
|
|
90
|
+
/**
|
|
91
|
+
* Unsubscribe from form notifications by marker.
|
|
92
|
+
* @handleName unsubscribeFromForm
|
|
93
|
+
* @param {string} marker - Event marker. Example: "form_marker".
|
|
94
|
+
* @param {ISubscribeFormEvent} body - Subscription body. Example: `{ formDataId: 123 }`.
|
|
95
|
+
* @returns {Promise<boolean | IError>} Returns true if the unsubscription was successful, or an error object.
|
|
96
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
97
|
+
* @description This method requires user authorization.
|
|
98
|
+
* @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}.
|
|
99
|
+
*/
|
|
100
|
+
unsubscribeFromForm(marker: string, body: ISubscribeFormEvent): Promise<boolean | IError>;
|
|
60
101
|
}
|
package/dist/events/eventsApi.js
CHANGED
|
@@ -93,5 +93,72 @@ class EventsApi extends asyncModules_1.default {
|
|
|
93
93
|
return e;
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Returns all available events.
|
|
98
|
+
* @handleName getAllEvents
|
|
99
|
+
* @returns {Promise<IContentApiEvent[] | IError>} Returns an array of available events.
|
|
100
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
101
|
+
* @description This method returns all available events.
|
|
102
|
+
*/
|
|
103
|
+
async getAllEvents() {
|
|
104
|
+
const data = await this._fetchGet(`/all`);
|
|
105
|
+
return this._normalizeData(data);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Subscribe to a form event by marker.
|
|
109
|
+
* @handleName subscribeToForm
|
|
110
|
+
* @param {string} marker - Event marker. Example: "form_marker".
|
|
111
|
+
* @param {ISubscribeFormEvent} body - Subscription body. Example: `{ formDataId: 123 }`.
|
|
112
|
+
* @returns {Promise<boolean | IError>} Returns true if the subscription was successful, or an error object.
|
|
113
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
114
|
+
* @description This method requires user authorization.
|
|
115
|
+
* @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}.
|
|
116
|
+
*/
|
|
117
|
+
async subscribeToForm(marker, body) {
|
|
118
|
+
try {
|
|
119
|
+
await this._fetchPost(`/forms/subscribe/marker/${marker}`, body);
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
catch (e) {
|
|
123
|
+
return e;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Returns all form subscriptions.
|
|
128
|
+
* @handleName getFormSubscriptions
|
|
129
|
+
* @param {number} [offset] - Optional offset for pagination. Default: 0.
|
|
130
|
+
* @param {number} [limit] - Optional limit for pagination. Default: 30.
|
|
131
|
+
* @returns {Promise<IListFormSubscription[] | IError>} Returns an array of form subscriptions.
|
|
132
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
133
|
+
* @description This method requires user authorization.
|
|
134
|
+
* @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}.
|
|
135
|
+
*/
|
|
136
|
+
async getFormSubscriptions(offset = 0, limit = 30) {
|
|
137
|
+
const query = {
|
|
138
|
+
offset,
|
|
139
|
+
limit,
|
|
140
|
+
};
|
|
141
|
+
const data = await this._fetchGet(`/forms/subscriptions?` + this._queryParamsToString(query));
|
|
142
|
+
return this._normalizeData(data);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Unsubscribe from form notifications by marker.
|
|
146
|
+
* @handleName unsubscribeFromForm
|
|
147
|
+
* @param {string} marker - Event marker. Example: "form_marker".
|
|
148
|
+
* @param {ISubscribeFormEvent} body - Subscription body. Example: `{ formDataId: 123 }`.
|
|
149
|
+
* @returns {Promise<boolean | IError>} Returns true if the unsubscription was successful, or an error object.
|
|
150
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
151
|
+
* @description This method requires user authorization.
|
|
152
|
+
* @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}.
|
|
153
|
+
*/
|
|
154
|
+
async unsubscribeFromForm(marker, body) {
|
|
155
|
+
try {
|
|
156
|
+
await this._fetchDelete(`/forms/unsubscribe/marker/${marker}`, body);
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
159
|
+
catch (e) {
|
|
160
|
+
return e;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
96
163
|
}
|
|
97
164
|
exports.default = EventsApi;
|
|
@@ -37,6 +37,47 @@ interface IEvents {
|
|
|
37
37
|
* @description This method unsubscribes from an event on a product by its marker.
|
|
38
38
|
*/
|
|
39
39
|
unsubscribeByMarker(marker: string, productId: number, langCode?: string): Promise<boolean | IError>;
|
|
40
|
+
/**
|
|
41
|
+
* Returns all available events.
|
|
42
|
+
* @handleName getAllEvents
|
|
43
|
+
* @returns {Promise<IContentApiEvent[] | IError>} A promise that resolves to an array of events or an error.
|
|
44
|
+
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
45
|
+
* @description This method returns all available events.
|
|
46
|
+
*/
|
|
47
|
+
getAllEvents(): Promise<IContentApiEvent[] | IError>;
|
|
48
|
+
/**
|
|
49
|
+
* Subscribe to a form event by marker.
|
|
50
|
+
* @handleName subscribeToForm
|
|
51
|
+
* @param {string} marker - Event marker. Example: "form_marker".
|
|
52
|
+
* @param {ISubscribeFormEvent} body - Subscription body. Example: `{ formDataId: 123 }`.
|
|
53
|
+
* @returns {Promise<boolean | IError>} A promise that resolves to true on success, or an error.
|
|
54
|
+
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
55
|
+
* @description This method subscribes to a form event by marker. This method requires user authorization.
|
|
56
|
+
* @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}.
|
|
57
|
+
*/
|
|
58
|
+
subscribeToForm(marker: string, body: ISubscribeFormEvent): Promise<boolean | IError>;
|
|
59
|
+
/**
|
|
60
|
+
* Returns all form subscriptions.
|
|
61
|
+
* @handleName getFormSubscriptions
|
|
62
|
+
* @param {number} [offset] - Optional offset for pagination. Default: 0.
|
|
63
|
+
* @param {number} [limit] - Optional limit for pagination. Default: 30.
|
|
64
|
+
* @returns {Promise<IListFormSubscription[] | IError>} A promise that resolves to an array of form subscriptions or an error.
|
|
65
|
+
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
66
|
+
* @description This method returns all form subscriptions. This method requires user authorization.
|
|
67
|
+
* @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}.
|
|
68
|
+
*/
|
|
69
|
+
getFormSubscriptions(offset?: number, limit?: number): Promise<IListFormSubscription[] | IError>;
|
|
70
|
+
/**
|
|
71
|
+
* Unsubscribe from form notifications by marker.
|
|
72
|
+
* @handleName unsubscribeFromForm
|
|
73
|
+
* @param {string} marker - Event marker. Example: "form_marker".
|
|
74
|
+
* @param {ISubscribeFormEvent} body - Subscription body. Example: `{ formDataId: 123 }`.
|
|
75
|
+
* @returns {Promise<boolean | IError>} A promise that resolves to true on success, or an error.
|
|
76
|
+
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
77
|
+
* @description This method unsubscribes from form notifications by marker. This method requires user authorization.
|
|
78
|
+
* @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}.
|
|
79
|
+
*/
|
|
80
|
+
unsubscribeFromForm(marker: string, body: ISubscribeFormEvent): Promise<boolean | IError>;
|
|
40
81
|
}
|
|
41
82
|
/**
|
|
42
83
|
* Represents a response from the events API containing a total count and an array of subscription items.
|
|
@@ -84,4 +125,41 @@ interface ISubscribeBody {
|
|
|
84
125
|
locale: string;
|
|
85
126
|
productId: number;
|
|
86
127
|
}
|
|
87
|
-
|
|
128
|
+
/**
|
|
129
|
+
* Represents an event returned by the events API.
|
|
130
|
+
* @interface IContentApiEvent
|
|
131
|
+
* @property {number} id - Event identifier. Example: 1.
|
|
132
|
+
* @property {string} identifier - Event text identifier. Example: "price_change".
|
|
133
|
+
* @property {Record<string, unknown>} localizeInfos - Localized info of the event.
|
|
134
|
+
* @property {string} module - Module the event belongs to. Example: "catalog".
|
|
135
|
+
* @description Represents a single available event.
|
|
136
|
+
*/
|
|
137
|
+
interface IContentApiEvent {
|
|
138
|
+
id: number;
|
|
139
|
+
identifier: string;
|
|
140
|
+
localizeInfos: Record<string, unknown>;
|
|
141
|
+
module: string;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Represents a form subscription item.
|
|
145
|
+
* @interface IListFormSubscription
|
|
146
|
+
* @property {string} eventMarker - Event marker. Example: "form_marker".
|
|
147
|
+
* @property {number} formDataId - Form data identifier. Example: 123.
|
|
148
|
+
* @description Represents a single form subscription.
|
|
149
|
+
*/
|
|
150
|
+
interface IListFormSubscription {
|
|
151
|
+
eventMarker: string;
|
|
152
|
+
formDataId: number;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Body for subscribing to / unsubscribing from a form event.
|
|
156
|
+
* @interface ISubscribeFormEvent
|
|
157
|
+
* @property {number} formDataId - Form data identifier. Example: 123.
|
|
158
|
+
* @property {string} [status] - Optional subscription status.
|
|
159
|
+
* @description Body for the form subscribe/unsubscribe methods.
|
|
160
|
+
*/
|
|
161
|
+
interface ISubscribeFormEvent {
|
|
162
|
+
formDataId: number;
|
|
163
|
+
status?: string;
|
|
164
|
+
}
|
|
165
|
+
export type { IContentApiEvent, IEvents, IListFormSubscription, ISubscribeBody, ISubscribeFormEvent, ISubscriptions, };
|
|
@@ -104,11 +104,13 @@ interface IUploadingQuery {
|
|
|
104
104
|
* @property {string} filename - Filename with relative path. Example: "uploads/file.png".
|
|
105
105
|
* @property {string} downloadLink - Link for downloading the file. Example: "https://example.com/uploads/file.png".
|
|
106
106
|
* @property {number} size - Size of the file in bytes. Example: 1024.
|
|
107
|
+
* @property {string} contentType - MIME type of the uploaded file. Example: "image/png".
|
|
107
108
|
* @description Represents the return value of an uploading operation, including the filename, download link, and file size.
|
|
108
109
|
*/
|
|
109
110
|
interface IUploadingReturn {
|
|
110
111
|
filename: string;
|
|
111
112
|
downloadLink: string;
|
|
112
113
|
size: number;
|
|
114
|
+
contentType: string;
|
|
113
115
|
}
|
|
114
116
|
export type { IFileEntity, IFileUploading, IUploadingQuery, IUploadingReturn };
|
|
@@ -11,6 +11,7 @@ export declare const UploadingReturnSchema: z.ZodObject<{
|
|
|
11
11
|
filename: z.ZodString;
|
|
12
12
|
downloadLink: z.ZodString;
|
|
13
13
|
size: z.ZodNumber;
|
|
14
|
+
contentType: z.ZodString;
|
|
14
15
|
}, z.core.$strip>;
|
|
15
16
|
/**
|
|
16
17
|
* Upload response schema (array of upload results)
|
|
@@ -19,4 +20,5 @@ export declare const UploadResponseSchema: z.ZodArray<z.ZodObject<{
|
|
|
19
20
|
filename: z.ZodString;
|
|
20
21
|
downloadLink: z.ZodString;
|
|
21
22
|
size: z.ZodNumber;
|
|
23
|
+
contentType: z.ZodString;
|
|
22
24
|
}, z.core.$strip>>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import AsyncModules from '../base/asyncModules';
|
|
2
|
+
import type StateModule from '../base/stateModule';
|
|
3
|
+
import type { IError } from '../base/utils';
|
|
4
|
+
import type { IContentFilter, IFiltersApi } from './filtersInterfaces';
|
|
5
|
+
/**
|
|
6
|
+
* Controllers for working with content filters.
|
|
7
|
+
* @handle /api/content/filters
|
|
8
|
+
* @class FiltersApi
|
|
9
|
+
* @augments AsyncModules
|
|
10
|
+
* @implements {IFiltersApi}
|
|
11
|
+
* @description This class provides methods to retrieve content filters.
|
|
12
|
+
*/
|
|
13
|
+
export default class FiltersApi extends AsyncModules implements IFiltersApi {
|
|
14
|
+
protected state: StateModule;
|
|
15
|
+
protected _url: string;
|
|
16
|
+
/**
|
|
17
|
+
* Constructor for FiltersApi class.
|
|
18
|
+
* @param {StateModule} state - The state module.
|
|
19
|
+
*/
|
|
20
|
+
constructor(state: StateModule);
|
|
21
|
+
/**
|
|
22
|
+
* Get a filter by its marker (tree of items).
|
|
23
|
+
* @handleName getFilterByMarker
|
|
24
|
+
* @param {string} marker - Filter marker. Example: "main".
|
|
25
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
26
|
+
* @returns {Promise<IContentFilter | IError>} Returns the filter with its items tree.
|
|
27
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
28
|
+
* @description Retrieves a single content filter by marker.
|
|
29
|
+
*/
|
|
30
|
+
getFilterByMarker(marker: string, langCode?: string): Promise<IContentFilter | IError>;
|
|
31
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const asyncModules_1 = __importDefault(require("../base/asyncModules"));
|
|
7
|
+
const filtersSchemas_1 = require("./filtersSchemas");
|
|
8
|
+
/**
|
|
9
|
+
* Controllers for working with content filters.
|
|
10
|
+
* @handle /api/content/filters
|
|
11
|
+
* @class FiltersApi
|
|
12
|
+
* @augments AsyncModules
|
|
13
|
+
* @implements {IFiltersApi}
|
|
14
|
+
* @description This class provides methods to retrieve content filters.
|
|
15
|
+
*/
|
|
16
|
+
class FiltersApi extends asyncModules_1.default {
|
|
17
|
+
/**
|
|
18
|
+
* Constructor for FiltersApi class.
|
|
19
|
+
* @param {StateModule} state - The state module.
|
|
20
|
+
*/
|
|
21
|
+
constructor(state) {
|
|
22
|
+
super(state);
|
|
23
|
+
this._url = state.url + '/api/content/filters';
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Get a filter by its marker (tree of items).
|
|
27
|
+
* @handleName getFilterByMarker
|
|
28
|
+
* @param {string} marker - Filter marker. Example: "main".
|
|
29
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
30
|
+
* @returns {Promise<IContentFilter | IError>} Returns the filter with its items tree.
|
|
31
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
32
|
+
* @description Retrieves a single content filter by marker.
|
|
33
|
+
*/
|
|
34
|
+
async getFilterByMarker(marker, langCode = this.state.lang) {
|
|
35
|
+
const data = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
|
|
36
|
+
const validated = this._validateResponse(data, filtersSchemas_1.ContentFilterSchema);
|
|
37
|
+
return this._normalizeData(validated);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.default = FiltersApi;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { IError, ILocalizeInfo } from '../base/utils';
|
|
2
|
+
/**
|
|
3
|
+
* Interface for the Filters API module.
|
|
4
|
+
* @interface IFiltersApi
|
|
5
|
+
* @description This interface defines methods for retrieving content filters.
|
|
6
|
+
*/
|
|
7
|
+
interface IFiltersApi {
|
|
8
|
+
/**
|
|
9
|
+
* Get a filter by its marker (tree of items).
|
|
10
|
+
* @handleName getFilterByMarker
|
|
11
|
+
* @param {string} marker - Filter marker. Example: "main".
|
|
12
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
13
|
+
* @returns {Promise<IContentFilter | IError>} Returns the filter with its items tree.
|
|
14
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
15
|
+
* @description Retrieves a single content filter by marker.
|
|
16
|
+
*/
|
|
17
|
+
getFilterByMarker(marker: string, langCode?: string): Promise<IContentFilter | IError>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Type of a filter item tree node.
|
|
21
|
+
* @description Type of a filter item tree node (including `custom` for custom entries).
|
|
22
|
+
*/
|
|
23
|
+
type TContentFilterItemType = 'page' | 'product' | 'admin' | 'attribute' | 'discount' | 'personal-discount' | 'bonus' | 'payment-method' | 'custom';
|
|
24
|
+
/**
|
|
25
|
+
* Content filter item (tree node).
|
|
26
|
+
* @interface IContentFilterItem
|
|
27
|
+
* @property {TContentFilterItemType} type - Tree node type. Example: "page".
|
|
28
|
+
* @property {string | null} [marker] - Marker of the linked entity, or null for type=page. Example: "about".
|
|
29
|
+
* @property {string | null} [url] - Page URL (only for type=page; null otherwise). Example: "about".
|
|
30
|
+
* @property {ILocalizeInfo} [localizeInfos] - Localized info of the linked entity in the requested locale.
|
|
31
|
+
* @property {string | null} [value] - Unified node value (e.g. discount value, attribute title); null otherwise. Example: "10".
|
|
32
|
+
* @property {number} [position] - Numeric position (per-level). Example: 1.
|
|
33
|
+
* @property {IContentFilterItem[]} [children] - Nested tree nodes (regular and custom items in a single array).
|
|
34
|
+
* @description A single node of a content filter items tree.
|
|
35
|
+
*/
|
|
36
|
+
interface IContentFilterItem {
|
|
37
|
+
type: TContentFilterItemType;
|
|
38
|
+
marker?: string | null;
|
|
39
|
+
url?: string | null;
|
|
40
|
+
localizeInfos?: ILocalizeInfo;
|
|
41
|
+
value?: string | null;
|
|
42
|
+
position?: number;
|
|
43
|
+
children?: IContentFilterItem[];
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Content filter.
|
|
47
|
+
* @interface IContentFilter
|
|
48
|
+
* @property {ILocalizeInfo} localizeInfos - Localized info of the filter in the requested locale.
|
|
49
|
+
* @property {IContentFilterItem[]} [items] - Filter items tree (regular items + custom items in a single array).
|
|
50
|
+
* @description A content filter with its localized info and items tree.
|
|
51
|
+
*/
|
|
52
|
+
interface IContentFilter {
|
|
53
|
+
localizeInfos: ILocalizeInfo;
|
|
54
|
+
items?: IContentFilterItem[];
|
|
55
|
+
}
|
|
56
|
+
export type { IContentFilter, IContentFilterItem, IFiltersApi, TContentFilterItemType, };
|