oneentry 1.0.148 → 1.0.150

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +8 -0
  2. package/changelog.md +431 -0
  3. package/dist/base/asyncModules.js +13 -0
  4. package/dist/base/stateModule.d.ts +1 -0
  5. package/dist/base/stateModule.js +3 -0
  6. package/dist/base/syncModules.d.ts +30 -1
  7. package/dist/base/syncModules.js +102 -30
  8. package/dist/base/utils.d.ts +4 -1
  9. package/dist/blocks/blocksApi.d.ts +108 -2
  10. package/dist/blocks/blocksApi.js +148 -1
  11. package/dist/blocks/blocksInterfaces.d.ts +160 -2
  12. package/dist/blocks/blocksSchemas.d.ts +4 -0
  13. package/dist/events/eventsApi.d.ts +42 -1
  14. package/dist/events/eventsApi.js +67 -0
  15. package/dist/events/eventsInterfaces.d.ts +79 -1
  16. package/dist/filters/filtersApi.d.ts +31 -0
  17. package/dist/filters/filtersApi.js +40 -0
  18. package/dist/filters/filtersInterfaces.d.ts +56 -0
  19. package/dist/filters/filtersInterfaces.js +2 -0
  20. package/dist/filters/filtersSchemas.d.ts +32 -0
  21. package/dist/filters/filtersSchemas.js +29 -0
  22. package/dist/forms-data/formsDataApi.js +4 -4
  23. package/dist/general-types/generalTypesSchemas.d.ts +16 -0
  24. package/dist/general-types/generalTypesSchemas.js +10 -1
  25. package/dist/index.d.ts +13 -0
  26. package/dist/index.js +10 -0
  27. package/dist/pages/pagesInterfaces.d.ts +2 -2
  28. package/dist/pages/pagesSchemas.d.ts +3 -3
  29. package/dist/pages/pagesSchemas.js +1 -1
  30. package/dist/products/productsApi.d.ts +19 -1
  31. package/dist/products/productsApi.js +29 -7
  32. package/dist/products/productsInterfaces.d.ts +30 -1
  33. package/dist/products/productsSchemas.d.ts +4 -0
  34. package/dist/products/productsSchemas.js +1 -0
  35. package/dist/subscriptions/subscriptionsApi.d.ts +69 -0
  36. package/dist/subscriptions/subscriptionsApi.js +102 -0
  37. package/dist/subscriptions/subscriptionsInterfaces.d.ts +90 -0
  38. package/dist/subscriptions/subscriptionsInterfaces.js +2 -0
  39. package/dist/subscriptions/subscriptionsSchemas.d.ts +20 -0
  40. package/dist/subscriptions/subscriptionsSchemas.js +23 -0
  41. package/dist/user-activity/userActivityApi.d.ts +30 -0
  42. package/dist/user-activity/userActivityApi.js +42 -0
  43. package/dist/user-activity/userActivityInterfaces.d.ts +42 -0
  44. package/dist/user-activity/userActivityInterfaces.js +2 -0
  45. package/dist/users/usersApi.d.ts +79 -1
  46. package/dist/users/usersApi.js +110 -0
  47. package/dist/users/usersInterfaces.d.ts +155 -1
  48. package/dist/users/usersSchemas.d.ts +40 -0
  49. package/dist/users/usersSchemas.js +34 -1
  50. package/package.json +3 -2
@@ -51,6 +51,111 @@ 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. Example: `{ productIds: [1, 2], langCode: "en_US" }`.
69
+ * @returns {IProductsEntity[]} A promise that resolves to an array of products or an error.
70
+ * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
71
+ */
72
+ getCartComplementByProductIds(marker: string, body: IBlockProductsLookup): Promise<IProductsEntity[] | IError>;
73
+ /**
74
+ * Get "similar to cart" products by the cart from context (auth user or guest).
75
+ * @handleName getCartSimilar
76
+ * @param {string} marker - Block marker. Example: "cart_similar_block".
77
+ * @param {string} [langCode] - Language code. Default: "en_US".
78
+ * @param {string} [signPrice] - Sign price.
79
+ * @returns {IProductsEntity[]} A promise that resolves to an array of products or an error.
80
+ * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
81
+ */
82
+ getCartSimilar(marker: string, langCode?: string, signPrice?: string): Promise<IProductsEntity[] | IError>;
83
+ /**
84
+ * Get "similar to cart" products by an explicit list of productIds (POST body).
85
+ * @handleName getCartSimilarByProductIds
86
+ * @param {string} marker - Block marker. Example: "cart_similar_block".
87
+ * @param {IBlockProductsLookup} body - Lookup body. Example: `{ productIds: [1, 2], langCode: "en_US" }`.
88
+ * @returns {IProductsEntity[]} A promise that resolves to an array of products or an error.
89
+ * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
90
+ */
91
+ getCartSimilarByProductIds(marker: string, body: IBlockProductsLookup): Promise<IProductsEntity[] | IError>;
92
+ /**
93
+ * Get personal recommendations for the user.
94
+ * @handleName getPersonalRecommendations
95
+ * @param {string} marker - Block marker. Example: "personal_recommendations_block".
96
+ * @param {string} [langCode] - Language code. Default: "en_US".
97
+ * @param {string} [signPrice] - Sign price.
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
+ getPersonalRecommendations(marker: string, langCode?: string, signPrice?: string): Promise<IProductsEntity[] | IError>;
102
+ /**
103
+ * Get recently viewed products.
104
+ * @handleName getRecentlyViewed
105
+ * @param {string} marker - Block marker. Example: "recently_viewed_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
+ getRecentlyViewed(marker: string, langCode?: string, signPrice?: string): Promise<IProductsEntity[] | IError>;
112
+ /**
113
+ * Get products for repeat purchase.
114
+ * @handleName getRepeatPurchase
115
+ * @param {string} marker - Block marker. Example: "repeat_purchase_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
+ getRepeatPurchase(marker: string, langCode?: string, signPrice?: string): Promise<IProductsEntity[] | IError>;
122
+ /**
123
+ * Get the block's slides tree as a flat pre-order array (slider_block only).
124
+ * @handleName getSlides
125
+ * @param {string} marker - Block marker. Example: "slider_block".
126
+ * @returns {IBlockSlidesResponse} A promise that resolves to the slides response or an error.
127
+ * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
128
+ */
129
+ getSlides(marker: string): Promise<IBlockSlidesResponse | IError>;
130
+ /**
131
+ * Get trending products of the block.
132
+ * @handleName getTrending
133
+ * @param {string} marker - Block marker. Example: "trending_block".
134
+ * @param {string} [langCode] - Language code. Default: "en_US".
135
+ * @param {string} [signPrice] - Sign price.
136
+ * @returns {IProductsEntity[]} A promise that resolves to an array of products or an error.
137
+ * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
138
+ */
139
+ getTrending(marker: string, langCode?: string, signPrice?: string): Promise<IProductsEntity[] | IError>;
140
+ /**
141
+ * Get "similar to wishlist" products by the wishlist from context (auth user or guest).
142
+ * @handleName getWishlistSimilar
143
+ * @param {string} marker - Block marker. Example: "wishlist_similar_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
+ getWishlistSimilar(marker: string, langCode?: string, signPrice?: string): Promise<IProductsEntity[] | IError>;
150
+ /**
151
+ * Get "similar to wishlist" products by an explicit list of productIds (POST body).
152
+ * @handleName getWishlistSimilarByProductIds
153
+ * @param {string} marker - Block marker. Example: "wishlist_similar_block".
154
+ * @param {IBlockProductsLookup} body - Lookup body. Example: `{ productIds: [1, 2], langCode: "en_US" }`.
155
+ * @returns {IProductsEntity[]} A promise that resolves to an array of products or an error.
156
+ * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
157
+ */
158
+ getWishlistSimilarByProductIds(marker: string, body: IBlockProductsLookup): Promise<IProductsEntity[] | IError>;
54
159
  }
55
160
  /**
56
161
  * Represents a response from the blocks API.
@@ -175,5 +280,58 @@ interface ISearchBlock {
175
280
  * @type {BlockType}
176
281
  * @description This type defines the possible values for block types used in the system.
177
282
  */
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
- export type { BlockType, IBlockEntity, IBlocks, IBlocksResponse, ISearchBlock };
283
+ 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';
284
+ /**
285
+ * Lookup body for block product endpoints by explicit productIds.
286
+ * @interface IBlockProductsLookup
287
+ * @property {number[]} productIds - Product identifiers to look up. Example: [1, 2, 3].
288
+ * @property {string} [langCode] - Language code. Default: "en_US".
289
+ * @property {number} [limit] - Max number of products to return. Example: 10.
290
+ * @property {string} [signPrice] - Sign price.
291
+ * @description Body for the POST block product endpoints (cart-complement / cart-similar / wishlist-similar) that accept an explicit list of productIds.
292
+ */
293
+ interface IBlockProductsLookup {
294
+ productIds: number[];
295
+ langCode?: string;
296
+ limit?: number;
297
+ signPrice?: string;
298
+ }
299
+ /**
300
+ * A single slide item of a slider block (flat pre-order tree node).
301
+ * @interface IBlockSlideItem
302
+ * @property {number} id - Slide identifier. Example: 1.
303
+ * @property {number | null} [parentId] - Parent slide identifier, or null for root slides. Example: null.
304
+ * @property {number} depth - Depth of the slide in the tree. Example: 0.
305
+ * @property {number} position - Position of the slide among its siblings. Example: 1.
306
+ * @property {boolean} visible - Whether the slide is visible. Example: true.
307
+ * @property {number} [time] - Display time for the slide. Example: 5.
308
+ * @property {'sec' | 'ms'} [timeInterval] - Unit of the time field. Example: "sec".
309
+ * @property {IAttributeValues} attributeValues - Map of attribute values keyed by marker.
310
+ * @description A single slide item returned in the slides flat pre-order array.
311
+ */
312
+ interface IBlockSlideItem {
313
+ id: number;
314
+ parentId?: number | null;
315
+ depth: number;
316
+ position: number;
317
+ visible: boolean;
318
+ time?: number;
319
+ timeInterval?: 'sec' | 'ms';
320
+ attributeValues: IAttributeValues;
321
+ }
322
+ /**
323
+ * Slides response for a slider block.
324
+ * @interface IBlockSlidesResponse
325
+ * @property {number} total - Total number of slides. Example: 3.
326
+ * @property {number} [time] - Default display time for slides. Example: 5.
327
+ * @property {'sec' | 'ms'} [timeInterval] - Unit of the time field. Example: "sec".
328
+ * @property {IBlockSlideItem[]} items - Flat pre-order array of slide items.
329
+ * @description Response of the block slides endpoint (slider_block only).
330
+ */
331
+ interface IBlockSlidesResponse {
332
+ total: number;
333
+ time?: number;
334
+ timeInterval?: 'sec' | 'ms';
335
+ items: IBlockSlideItem[];
336
+ }
337
+ 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
  }
@@ -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
- export type { IEvents, ISubscribeBody, ISubscriptions };
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, };
@@ -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, };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Validation schemas for Filters module
3
+ * @description Zod schemas for validating filters-related API responses (raw API data, before normalization)
4
+ */
5
+ import { z } from 'zod';
6
+ /**
7
+ * Raw content filter item shape (before normalization), used to type the recursive schema.
8
+ * @description Raw filter item tree node as returned by the API (localizeInfos kept as a locale map).
9
+ */
10
+ type IContentFilterItemRaw = {
11
+ type: string;
12
+ marker?: string | null;
13
+ url?: string | null;
14
+ localizeInfos?: Record<string, unknown>;
15
+ value?: string | null;
16
+ position?: number;
17
+ children?: IContentFilterItemRaw[];
18
+ };
19
+ /**
20
+ * Content filter item schema (recursive)
21
+ * @description Schema for a single filter item tree node; `children` recurses into the same schema
22
+ */
23
+ export declare const ContentFilterItemSchema: z.ZodType<IContentFilterItemRaw>;
24
+ /**
25
+ * Content filter schema
26
+ * @description Schema for a content filter returned by getFilterByMarker
27
+ */
28
+ export declare const ContentFilterSchema: z.ZodObject<{
29
+ localizeInfos: z.ZodRecord<z.ZodString, z.ZodUnknown>;
30
+ items: z.ZodOptional<z.ZodArray<z.ZodType<IContentFilterItemRaw, unknown, z.core.$ZodTypeInternals<IContentFilterItemRaw, unknown>>>>;
31
+ }, z.core.$strip>;
32
+ export {};
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ContentFilterSchema = exports.ContentFilterItemSchema = void 0;
4
+ /**
5
+ * Validation schemas for Filters module
6
+ * @description Zod schemas for validating filters-related API responses (raw API data, before normalization)
7
+ */
8
+ const zod_1 = require("zod");
9
+ /**
10
+ * Content filter item schema (recursive)
11
+ * @description Schema for a single filter item tree node; `children` recurses into the same schema
12
+ */
13
+ exports.ContentFilterItemSchema = zod_1.z.lazy(() => zod_1.z.object({
14
+ type: zod_1.z.string(),
15
+ marker: zod_1.z.string().nullable().optional(),
16
+ url: zod_1.z.string().nullable().optional(),
17
+ localizeInfos: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
18
+ value: zod_1.z.string().nullable().optional(),
19
+ position: zod_1.z.number().optional(),
20
+ children: zod_1.z.array(exports.ContentFilterItemSchema).optional(),
21
+ }));
22
+ /**
23
+ * Content filter schema
24
+ * @description Schema for a content filter returned by getFilterByMarker
25
+ */
26
+ exports.ContentFilterSchema = zod_1.z.object({
27
+ localizeInfos: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()),
28
+ items: zod_1.z.array(exports.ContentFilterItemSchema).optional(),
29
+ });
@@ -65,14 +65,14 @@ class FormsDataApi extends asyncModules_1.default {
65
65
  */
66
66
  async postFormsData(body, langCode = this.state.lang) {
67
67
  const formData = {};
68
- // filter spam and button fields, send file
68
+ // filter button fields; keep spam fields so the captcha token in their `value` reaches the server
69
69
  formData[langCode] = Array.isArray(body.formData)
70
- ? body.formData.filter((fd) => fd.type !== 'spam' && fd.type !== 'button')
71
- : [body.formData].filter((fd) => fd.type !== 'spam' && fd.type !== 'button');
70
+ ? body.formData.filter((fd) => fd.type !== 'button')
71
+ : [body.formData].filter((fd) => fd.type !== 'button');
72
72
  /**
73
73
  * Handle file uploads if fileQuery is present
74
+ * Check if there is any element in formData[langCode] that contains one of the specified types
74
75
  */
75
- // Check if there is any element in formData[langCode] that contains one of the specified types
76
76
  if (formData[langCode].find((fd) => ['file', 'image', 'groupOfImages'].includes(fd.type))) {
77
77
  // Create an instance of FileUploadingApi with the current state
78
78
  const fileUploader = new fileUploadingApi_1.default(this.state);