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
@@ -20,6 +20,14 @@ export declare const GeneralTypeEntitySchema: z.ZodObject<{
20
20
  similar_products_block: "similar_products_block";
21
21
  product_block: "product_block";
22
22
  frequently_ordered_block: "frequently_ordered_block";
23
+ trending_block: "trending_block";
24
+ recently_viewed_block: "recently_viewed_block";
25
+ repeat_purchase_block: "repeat_purchase_block";
26
+ slider_block: "slider_block";
27
+ personal_recommendations_block: "personal_recommendations_block";
28
+ cart_complement_block: "cart_complement_block";
29
+ cart_similar_block: "cart_similar_block";
30
+ wishlist_similar_block: "wishlist_similar_block";
23
31
  common_page: "common_page";
24
32
  common_block: "common_block";
25
33
  service: "service";
@@ -43,6 +51,14 @@ export declare const GeneralTypesResponseSchema: z.ZodArray<z.ZodObject<{
43
51
  similar_products_block: "similar_products_block";
44
52
  product_block: "product_block";
45
53
  frequently_ordered_block: "frequently_ordered_block";
54
+ trending_block: "trending_block";
55
+ recently_viewed_block: "recently_viewed_block";
56
+ repeat_purchase_block: "repeat_purchase_block";
57
+ slider_block: "slider_block";
58
+ personal_recommendations_block: "personal_recommendations_block";
59
+ cart_complement_block: "cart_complement_block";
60
+ cart_similar_block: "cart_similar_block";
61
+ wishlist_similar_block: "wishlist_similar_block";
46
62
  common_page: "common_page";
47
63
  common_block: "common_block";
48
64
  service: "service";
@@ -12,6 +12,7 @@ const zod_1 = require("zod");
12
12
  */
13
13
  exports.GeneralTypeEntitySchema = zod_1.z.object({
14
14
  id: zod_1.z.number(),
15
+ // Must stay in sync with BlockType in src/blocks/blocksInterfaces.ts
15
16
  type: zod_1.z.enum([
16
17
  'product',
17
18
  'error_page',
@@ -19,6 +20,15 @@ exports.GeneralTypeEntitySchema = zod_1.z.object({
19
20
  'product_preview',
20
21
  'similar_products_block',
21
22
  'product_block',
23
+ 'frequently_ordered_block',
24
+ 'trending_block',
25
+ 'recently_viewed_block',
26
+ 'repeat_purchase_block',
27
+ 'slider_block',
28
+ 'personal_recommendations_block',
29
+ 'cart_complement_block',
30
+ 'cart_similar_block',
31
+ 'wishlist_similar_block',
22
32
  'form',
23
33
  'common_page',
24
34
  'common_block',
@@ -26,7 +36,6 @@ exports.GeneralTypeEntitySchema = zod_1.z.object({
26
36
  'service',
27
37
  'external_page',
28
38
  'discount',
29
- 'frequently_ordered_block',
30
39
  'none',
31
40
  ]),
32
41
  });
package/dist/index.d.ts CHANGED
@@ -9,6 +9,7 @@ import BlocksApi from './blocks/blocksApi';
9
9
  import DiscountsApi from './discounts/discountsApi';
10
10
  import EventsApi from './events/eventsApi';
11
11
  import FileUploadingApi from './file-uploading/fileUploadingApi';
12
+ import FiltersApi from './filters/filtersApi';
12
13
  import FormsApi from './forms/formsApi';
13
14
  import FormsDataApi from './forms-data/formsDataApi';
14
15
  import GeneralTypesApi from './general-types/generalTypesApi';
@@ -21,9 +22,11 @@ import PaymentsApi from './payments/paymentsApi';
21
22
  import ProductStatusesApi from './product-statuses/productStatusesApi';
22
23
  import ProductsApi from './products/productsApi';
23
24
  import SitemapApi from './sitemap/sitemapApi';
25
+ import SubscriptionsApi from './subscriptions/subscriptionsApi';
24
26
  import SystemApi from './system/systemApi';
25
27
  import TemplatesApi from './templates/templatesApi';
26
28
  import TemplatePreviewsApi from './templates-preview/templatesPreviewApi';
29
+ import UserActivityApi from './user-activity/userActivityApi';
27
30
  import UsersApi from './users/usersApi';
28
31
  import WsApi from './web-socket/wsApi';
29
32
  /**
@@ -36,6 +39,7 @@ import WsApi from './web-socket/wsApi';
36
39
  * @property {EventsApi} Events - Events API module.
37
40
  * @property {DiscountsApi} Discounts - Discounts API module.
38
41
  * @property {FileUploadingApi} FileUploading - File uploading API module.
42
+ * @property {FiltersApi} Filters - Filters API module.
39
43
  * @property {FormsApi} Forms - Forms API module.
40
44
  * @property {FormsDataApi} FormData - Form data API module.
41
45
  * @property {GeneralTypesApi} GeneralTypes - General types API module.
@@ -48,9 +52,11 @@ import WsApi from './web-socket/wsApi';
48
52
  * @property {ProductsApi} Products - Products API module.
49
53
  * @property {ProductStatusesApi} ProductStatuses - Product statuses API module.
50
54
  * @property {SitemapApi} Sitemap - Sitemap API module.
55
+ * @property {SubscriptionsApi} Subscriptions - Subscriptions API module.
51
56
  * @property {SystemApi} System - System API module.
52
57
  * @property {TemplatesApi} Templates - Templates API module.
53
58
  * @property {TemplatePreviewsApi} TemplatePreviews - Template previews API module.
59
+ * @property {UserActivityApi} UserActivity - User activity API module.
54
60
  * @property {UsersApi} Users - Users API module.
55
61
  * @property {WsApi} WS - WebSocket API module.
56
62
  */
@@ -69,6 +75,8 @@ interface IDefineApi {
69
75
  Discounts: DiscountsApi;
70
76
  /** File upload helpers: createFileFromUrl */
71
77
  FileUploading: FileUploadingApi;
78
+ /** Content filters: getFilterByMarker */
79
+ Filters: FiltersApi;
72
80
  /** Form schemas: getFormByMarker — use for rendering dynamic forms */
73
81
  Forms: FormsApi;
74
82
  /** Submit form data: postFormsData */
@@ -93,12 +101,16 @@ interface IDefineApi {
93
101
  ProductStatuses: ProductStatusesApi;
94
102
  /** Sitemap generation */
95
103
  Sitemap: SitemapApi;
104
+ /** Paid subscriptions: subscribe, cancelSubscription, recoverSubscriptions, getAllSubscriptions, getActiveSubscriptions */
105
+ Subscriptions: SubscriptionsApi;
96
106
  /** System info */
97
107
  System: SystemApi;
98
108
  /** Page templates */
99
109
  Templates: TemplatesApi;
100
110
  /** Template previews */
101
111
  TemplatePreviews: TemplatePreviewsApi;
112
+ /** User/guest activity tracking: trackUserActivity */
113
+ UserActivity: UserActivityApi;
102
114
  /** Current authenticated user: getUser, updateUser */
103
115
  Users: UsersApi;
104
116
  /** WebSocket real-time updates */
@@ -110,6 +122,7 @@ interface IDefineApi {
110
122
  * @param {string} url - URl of your project.
111
123
  * @param {IConfig} config - Custom configuration settings
112
124
  * @param {string} [config.token] - Optional token parameter
125
+ * @param {string} [config.guestId] - Optional guest identifier sent as the `x-guest-id` header for guest cart/wishlist/activity flows (only while unauthenticated). In the browser, if omitted, a stable per-device id is generated and persisted in localStorage. On the server you MUST pass a per-visitor `guestId` (or call `setGuestId`): the SDK never auto-generates a server id, to avoid sharing one guest across visitors.
113
126
  * @param {string} [config.langCode] - Optional langCode parameter
114
127
  * @param {boolean} [config.traficLimit] - Some methods use multiple queries to make it easier to work with the API. Set this parameter to "false" to save traffic and decide for yourself what data you need.
115
128
  * @param {string} [config.auth] - An object with authorization settings.
package/dist/index.js CHANGED
@@ -15,6 +15,7 @@ const blocksApi_1 = __importDefault(require("./blocks/blocksApi"));
15
15
  const discountsApi_1 = __importDefault(require("./discounts/discountsApi"));
16
16
  const eventsApi_1 = __importDefault(require("./events/eventsApi"));
17
17
  const fileUploadingApi_1 = __importDefault(require("./file-uploading/fileUploadingApi"));
18
+ const filtersApi_1 = __importDefault(require("./filters/filtersApi"));
18
19
  const formsApi_1 = __importDefault(require("./forms/formsApi"));
19
20
  const formsDataApi_1 = __importDefault(require("./forms-data/formsDataApi"));
20
21
  const generalTypesApi_1 = __importDefault(require("./general-types/generalTypesApi"));
@@ -27,9 +28,11 @@ const paymentsApi_1 = __importDefault(require("./payments/paymentsApi"));
27
28
  const productStatusesApi_1 = __importDefault(require("./product-statuses/productStatusesApi"));
28
29
  const productsApi_1 = __importDefault(require("./products/productsApi"));
29
30
  const sitemapApi_1 = __importDefault(require("./sitemap/sitemapApi"));
31
+ const subscriptionsApi_1 = __importDefault(require("./subscriptions/subscriptionsApi"));
30
32
  const systemApi_1 = __importDefault(require("./system/systemApi"));
31
33
  const templatesApi_1 = __importDefault(require("./templates/templatesApi"));
32
34
  const templatesPreviewApi_1 = __importDefault(require("./templates-preview/templatesPreviewApi"));
35
+ const userActivityApi_1 = __importDefault(require("./user-activity/userActivityApi"));
33
36
  const usersApi_1 = __importDefault(require("./users/usersApi"));
34
37
  const wsApi_1 = __importDefault(require("./web-socket/wsApi"));
35
38
  /**
@@ -38,6 +41,7 @@ const wsApi_1 = __importDefault(require("./web-socket/wsApi"));
38
41
  * @param {string} url - URl of your project.
39
42
  * @param {IConfig} config - Custom configuration settings
40
43
  * @param {string} [config.token] - Optional token parameter
44
+ * @param {string} [config.guestId] - Optional guest identifier sent as the `x-guest-id` header for guest cart/wishlist/activity flows (only while unauthenticated). In the browser, if omitted, a stable per-device id is generated and persisted in localStorage. On the server you MUST pass a per-visitor `guestId` (or call `setGuestId`): the SDK never auto-generates a server id, to avoid sharing one guest across visitors.
41
45
  * @param {string} [config.langCode] - Optional langCode parameter
42
46
  * @param {boolean} [config.traficLimit] - Some methods use multiple queries to make it easier to work with the API. Set this parameter to "false" to save traffic and decide for yourself what data you need.
43
47
  * @param {string} [config.auth] - An object with authorization settings.
@@ -57,6 +61,7 @@ function defineOneEntry(url, config) {
57
61
  const Discounts = new discountsApi_1.default(stateModule);
58
62
  const Events = new eventsApi_1.default(stateModule);
59
63
  const FileUploading = new fileUploadingApi_1.default(stateModule);
64
+ const Filters = new filtersApi_1.default(stateModule);
60
65
  const Forms = new formsApi_1.default(stateModule);
61
66
  const FormData = new formsDataApi_1.default(stateModule);
62
67
  const GeneralTypes = new generalTypesApi_1.default(stateModule);
@@ -69,9 +74,11 @@ function defineOneEntry(url, config) {
69
74
  const Products = new productsApi_1.default(stateModule);
70
75
  const ProductStatuses = new productStatusesApi_1.default(stateModule);
71
76
  const Sitemap = new sitemapApi_1.default(stateModule);
77
+ const Subscriptions = new subscriptionsApi_1.default(stateModule);
72
78
  const System = new systemApi_1.default(stateModule);
73
79
  const Templates = new templatesApi_1.default(stateModule);
74
80
  const TemplatePreviews = new templatesPreviewApi_1.default(stateModule);
81
+ const UserActivity = new userActivityApi_1.default(stateModule);
75
82
  const Users = new usersApi_1.default(stateModule);
76
83
  const WS = new wsApi_1.default(stateModule);
77
84
  return {
@@ -82,6 +89,7 @@ function defineOneEntry(url, config) {
82
89
  Discounts,
83
90
  Events,
84
91
  FileUploading,
92
+ Filters,
85
93
  Forms,
86
94
  FormData,
87
95
  GeneralTypes,
@@ -94,9 +102,11 @@ function defineOneEntry(url, config) {
94
102
  Products,
95
103
  ProductStatuses,
96
104
  Sitemap,
105
+ Subscriptions,
97
106
  System,
98
107
  Templates,
99
108
  TemplatePreviews,
109
+ UserActivity,
100
110
  Users,
101
111
  WS,
102
112
  };
@@ -240,7 +240,7 @@ interface IPositionBlock {
240
240
  "productsPerRow": 1
241
241
  }
242
242
  * @property {number} [products] - The number of products linked to the page. Example: 0.
243
- * @property {string} [childrenCount] - Children count. Example: 1.
243
+ * @property {number} [childrenCount] - Children count. Example: 1.
244
244
  * @property {IBlockEntity[] | string[]} [blocks] - blocks.
245
245
  * @example
246
246
  {
@@ -279,7 +279,7 @@ interface IPagesEntity {
279
279
  position?: number;
280
280
  config?: Record<string, number>;
281
281
  products?: number;
282
- childrenCount?: string;
282
+ childrenCount?: number;
283
283
  total?: string;
284
284
  categoryPath?: string;
285
285
  }
@@ -26,7 +26,7 @@ export declare const PageEntitySchema: z.ZodObject<{
26
26
  position: z.ZodOptional<z.ZodNumber>;
27
27
  config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
28
28
  products: z.ZodOptional<z.ZodNumber>;
29
- childrenCount: z.ZodOptional<z.ZodString>;
29
+ childrenCount: z.ZodOptional<z.ZodNumber>;
30
30
  total: z.ZodOptional<z.ZodString>;
31
31
  categoryPath: z.ZodOptional<z.ZodString>;
32
32
  }, z.core.$strip>;
@@ -52,7 +52,7 @@ export declare const PagesResponseSchema: z.ZodArray<z.ZodObject<{
52
52
  position: z.ZodOptional<z.ZodNumber>;
53
53
  config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
54
54
  products: z.ZodOptional<z.ZodNumber>;
55
- childrenCount: z.ZodOptional<z.ZodString>;
55
+ childrenCount: z.ZodOptional<z.ZodNumber>;
56
56
  total: z.ZodOptional<z.ZodString>;
57
57
  categoryPath: z.ZodOptional<z.ZodString>;
58
58
  }, z.core.$strip>>;
@@ -78,7 +78,7 @@ export declare const SinglePageSchema: z.ZodObject<{
78
78
  position: z.ZodOptional<z.ZodNumber>;
79
79
  config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
80
80
  products: z.ZodOptional<z.ZodNumber>;
81
- childrenCount: z.ZodOptional<z.ZodString>;
81
+ childrenCount: z.ZodOptional<z.ZodNumber>;
82
82
  total: z.ZodOptional<z.ZodString>;
83
83
  categoryPath: z.ZodOptional<z.ZodString>;
84
84
  }, z.core.$strip>;
@@ -29,7 +29,7 @@ exports.PageEntitySchema = zod_1.z.object({
29
29
  position: zod_1.z.number().optional(),
30
30
  config: zod_1.z.record(zod_1.z.string(), zod_1.z.number()).optional(),
31
31
  products: zod_1.z.number().optional(),
32
- childrenCount: zod_1.z.string().optional(),
32
+ childrenCount: zod_1.z.number().optional(),
33
33
  total: zod_1.z.string().optional(),
34
34
  categoryPath: zod_1.z.string().optional(),
35
35
  });
@@ -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 { IAggregatedProductGroup, IFilterParams, IProductBlock, IProductsApi, IProductsCount, IProductsEntity, IProductsInfo, IProductsQuery, IProductsResponse } from './productsInterfaces';
4
+ import type { IAggregatedProductGroup, IFilterParams, IProductBlock, IProductsApi, IProductsCount, IProductsEntity, IProductsInfo, IProductsQuery, IProductsResponse, IVectorSearchProducts } from './productsInterfaces';
5
5
  /**
6
6
  * Controllers for working with product pages
7
7
  * @handle /api/content/products
@@ -369,5 +369,23 @@ export default class ProductsApi extends AsyncModules implements IProductsApi {
369
369
  * @throws {IError} When isShell=false and an error occurs during the fetch
370
370
  * @description This method calculates and returns the number of products available on a given catalog page, identified by its URL, with optional filtering.
371
371
  */
372
+ /**
373
+ * Semantic (vector) search for products.
374
+ * @handleName getProductsByVectorSearch
375
+ * @param {IVectorSearchProducts} body - Vector search body. Example: `{ queryText: "red running shoes" }`.
376
+ * @param {string} [langCode] - Language code. Default: "en_US".
377
+ * @param {number} [offset] - Parameter for pagination. Default: 0.
378
+ * @param {number} [limit] - Parameter for pagination. Default: 30.
379
+ * @returns {Promise<IProductsEntity[] | IError>} Array with ProductEntity objects.
380
+ * @throws {IError} When isShell=false and an error occurs during the fetch
381
+ * @description This method performs a semantic (vector) search for products.
382
+ */
383
+ getProductsByVectorSearch(body: IVectorSearchProducts, langCode?: string, offset?: number, limit?: number): Promise<IProductsEntity[] | IError>;
384
+ /**
385
+ * Get products by page url.
386
+ * @param {string} url - Page url.
387
+ * @param {any[]} body - Request body.
388
+ * @returns {IProductsEntity[] | IError} Returns an array of products or an error object.
389
+ */
372
390
  getProductsCountByPageUrl(url: string, body?: any[]): Promise<IProductsCount | IError>;
373
391
  }
@@ -367,13 +367,9 @@ class ProductsApi extends asyncModules_1.default {
367
367
  async searchProduct(name, langCode = this.state.lang) {
368
368
  const searchProducts = await this._fetchGet(`/quick/search?langCode=${langCode}&name=${name}`);
369
369
  if (!this.state.traficLimit && Array.isArray(searchProducts)) {
370
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
371
- const productsList = [];
372
- await Promise.all(searchProducts.map(async (product) => {
373
- await this.getProductById(product.id, langCode).then((result) => {
374
- productsList.push(result);
375
- });
376
- }));
370
+ // Promise.all preserves the input order, keeping the search relevance
371
+ // order from the API (manual push would reorder by completion time).
372
+ const productsList = await Promise.all(searchProducts.map((product) => this.getProductById(product.id, langCode)));
377
373
  return this._dataPostProcess(productsList, langCode);
378
374
  }
379
375
  return searchProducts;
@@ -455,6 +451,32 @@ class ProductsApi extends asyncModules_1.default {
455
451
  * @throws {IError} When isShell=false and an error occurs during the fetch
456
452
  * @description This method calculates and returns the number of products available on a given catalog page, identified by its URL, with optional filtering.
457
453
  */
454
+ /**
455
+ * Semantic (vector) search for products.
456
+ * @handleName getProductsByVectorSearch
457
+ * @param {IVectorSearchProducts} body - Vector search body. Example: `{ queryText: "red running shoes" }`.
458
+ * @param {string} [langCode] - Language code. Default: "en_US".
459
+ * @param {number} [offset] - Parameter for pagination. Default: 0.
460
+ * @param {number} [limit] - Parameter for pagination. Default: 30.
461
+ * @returns {Promise<IProductsEntity[] | IError>} Array with ProductEntity objects.
462
+ * @throws {IError} When isShell=false and an error occurs during the fetch
463
+ * @description This method performs a semantic (vector) search for products.
464
+ */
465
+ async getProductsByVectorSearch(body, langCode = this.state.lang, offset = 0, limit = 30) {
466
+ const query = {
467
+ langCode,
468
+ offset,
469
+ limit,
470
+ };
471
+ const result = await this._fetchPost(`/vector/search?` + this._queryParamsToString(query), body);
472
+ return this._dataPostProcess(result, langCode);
473
+ }
474
+ /**
475
+ * Get products by page url.
476
+ * @param {string} url - Page url.
477
+ * @param {any[]} body - Request body.
478
+ * @returns {IProductsEntity[] | IError} Returns an array of products or an error object.
479
+ */
458
480
  async getProductsCountByPageUrl(url,
459
481
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
460
482
  body = []) {
@@ -320,6 +320,18 @@ interface IProductsApi {
320
320
  * @description This method calculates and returns the number of products available on a given catalog page, identified by its URL, with optional filtering.
321
321
  */
322
322
  getProductsCountByPageUrl(url: string, body?: object[]): Promise<IProductsCount | IError>;
323
+ /**
324
+ * Semantic (vector) search for products.
325
+ * @handleName getProductsByVectorSearch
326
+ * @param {IVectorSearchProducts} body - Vector search body. Example: `{ queryText: "red running shoes" }`.
327
+ * @param {string} [langCode] - Language code. Default: "en_US".
328
+ * @param {number} [offset] - Parameter for pagination. Default: 0.
329
+ * @param {number} [limit] - Parameter for pagination. Default: 30.
330
+ * @returns {IProductsEntity[]} Array with ProductEntity objects.
331
+ * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
332
+ * @description This method performs a semantic (vector) search for products.
333
+ */
334
+ getProductsByVectorSearch(body: IVectorSearchProducts, langCode?: string, offset?: number, limit?: number): Promise<IProductsEntity[] | IError>;
323
335
  }
324
336
  /**
325
337
  * @interface IProductsQuery
@@ -454,6 +466,7 @@ interface IProductPageRef {
454
466
  67890
455
467
  ]
456
468
  * @property {unknown} [paymentStages] - Payment stages data (may be null). Example: null.
469
+ * @property {number} [distance] - Vector (semantic) search relevance distance. Present only in results of vector search. Example: 0.42.
457
470
  * @property {Record<string, unknown>} [discountConfig] - Discount configuration object. Example: {}.
458
471
  * @property {string | null} [templateIdentifier] - User id of the linked template. Example: "template_12345".
459
472
  * @property {string | null} [shortDescTemplateIdentifier] - User id of the linked template for a short description. Example: "short_desc_template_12345".
@@ -501,6 +514,7 @@ interface IProductsEntity {
501
514
  isPositionLocked?: boolean;
502
515
  relatedIds?: number[];
503
516
  paymentStages?: unknown;
517
+ distance?: number;
504
518
  discountConfig?: Record<string, unknown>;
505
519
  }
506
520
  /**
@@ -667,4 +681,19 @@ interface IAggregatedProductGroup {
667
681
  productIds: string[];
668
682
  total: number;
669
683
  }
670
- export type { IAggregatedProductGroup, IFilterParams, IProductBlock, IProductInfo, IProductsApi, IProductsCount, IProductsEntity, IProductsInfo, IProductsQuery, IProductsResponse, };
684
+ /**
685
+ * Body for semantic (vector) product search.
686
+ * @interface IVectorSearchProducts
687
+ * @property {string} queryText - Natural-language search query. Example: "red running shoes".
688
+ * @property {number} [vectorDistanceThreshold] - Max vector distance for a hit. Example: 0.5.
689
+ * @property {number} [maxHits] - Max number of hits to return. Example: 50.
690
+ * @property {boolean} [debug] - Include debug info in the response. Example: false.
691
+ * @description Body for the products vector/search endpoint.
692
+ */
693
+ interface IVectorSearchProducts {
694
+ queryText: string;
695
+ vectorDistanceThreshold?: number;
696
+ maxHits?: number;
697
+ debug?: boolean;
698
+ }
699
+ export type { IAggregatedProductGroup, IFilterParams, IProductBlock, IProductInfo, IProductsApi, IProductsCount, IProductsEntity, IProductsInfo, IProductsQuery, IProductsResponse, IVectorSearchProducts, };
@@ -60,6 +60,7 @@ export declare const ProductEntitySchema: z.ZodObject<{
60
60
  isPositionLocked: z.ZodOptional<z.ZodBoolean>;
61
61
  relatedIds: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
62
62
  paymentStages: z.ZodNullable<z.ZodOptional<z.ZodAny>>;
63
+ distance: z.ZodOptional<z.ZodNumber>;
63
64
  discountConfig: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
64
65
  }, z.core.$strip>;
65
66
  /**
@@ -101,6 +102,7 @@ export declare const ProductsResponseSchema: z.ZodObject<{
101
102
  isPositionLocked: z.ZodOptional<z.ZodBoolean>;
102
103
  relatedIds: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
103
104
  paymentStages: z.ZodNullable<z.ZodOptional<z.ZodAny>>;
105
+ distance: z.ZodOptional<z.ZodNumber>;
104
106
  discountConfig: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
105
107
  }, z.core.$strip>>;
106
108
  total: z.ZodNumber;
@@ -143,6 +145,7 @@ export declare const SingleProductSchema: 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
  /**
@@ -208,5 +211,6 @@ export declare const RelatedProductsSchema: z.ZodArray<z.ZodObject<{
208
211
  isPositionLocked: z.ZodOptional<z.ZodBoolean>;
209
212
  relatedIds: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
210
213
  paymentStages: z.ZodNullable<z.ZodOptional<z.ZodAny>>;
214
+ distance: z.ZodOptional<z.ZodNumber>;
211
215
  discountConfig: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
212
216
  }, z.core.$strip>>;
@@ -65,6 +65,7 @@ exports.ProductEntitySchema = zod_1.z.object({
65
65
  isPositionLocked: zod_1.z.boolean().optional(),
66
66
  relatedIds: zod_1.z.array(zod_1.z.number()).optional(),
67
67
  paymentStages: zod_1.z.any().optional().nullable(),
68
+ distance: zod_1.z.number().optional(),
68
69
  discountConfig: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
69
70
  });
70
71
  /**
@@ -0,0 +1,69 @@
1
+ import AsyncModules from '../base/asyncModules';
2
+ import type StateModule from '../base/stateModule';
3
+ import type { IError } from '../base/utils';
4
+ import type { ICancelSubscription, ICreatedSubscription, ISubscribe, ISubscriptionsApi } from './subscriptionsInterfaces';
5
+ /**
6
+ * Controllers for working with paid subscriptions.
7
+ * @handle /api/content/subscriptions
8
+ * @class SubscriptionsApi
9
+ * @augments AsyncModules
10
+ * @implements {ISubscriptionsApi}
11
+ * @description This class provides methods to interact with paid subscriptions: creating, cancelling, recovering, and listing available/active subscriptions.
12
+ */
13
+ export default class SubscriptionsApi extends AsyncModules implements ISubscriptionsApi {
14
+ protected state: StateModule;
15
+ protected _url: string;
16
+ /**
17
+ * Constructor for SubscriptionsApi class.
18
+ * @param {StateModule} state - The state module.
19
+ */
20
+ constructor(state: StateModule);
21
+ /**
22
+ * Create a new subscription and get a payment session for it.
23
+ * @handleName subscribe
24
+ * @param {ISubscribe} body - Subscription body. Example: `{ marker: "premium" }`.
25
+ * @returns {Promise<ICreatedSubscription | IError>} Returns the created payment session for the subscription.
26
+ * @throws {IError} When isShell=false and an error occurs during the fetch
27
+ * @description This method requires user authorization.
28
+ * @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}.
29
+ */
30
+ subscribe(body: ISubscribe): Promise<ICreatedSubscription | IError>;
31
+ /**
32
+ * Cancel a subscription.
33
+ * @handleName cancelSubscription
34
+ * @param {ICancelSubscription} body - Subscription body. Example: `{ marker: "premium" }`.
35
+ * @returns {Promise<boolean | IError>} Returns true if the subscription was cancelled, or an error object if there was an issue.
36
+ * @throws {IError} When isShell=false and an error occurs during the fetch
37
+ * @description This method requires user authorization.
38
+ * @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
39
+ */
40
+ cancelSubscription(body: ICancelSubscription): Promise<boolean | IError>;
41
+ /**
42
+ * Get all available subscription markers.
43
+ * @handleName getAllSubscriptions
44
+ * @returns {Promise<string[] | IError>} Returns an array of available subscription markers.
45
+ * @throws {IError} When isShell=false and an error occurs during the fetch
46
+ * @description This method requires user authorization.
47
+ * @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}.
48
+ */
49
+ getAllSubscriptions(): Promise<string[] | IError>;
50
+ /**
51
+ * Get markers of the user's active subscriptions.
52
+ * @handleName getActiveSubscriptions
53
+ * @returns {Promise<string[] | IError>} Returns an array of active subscription markers.
54
+ * @throws {IError} When isShell=false and an error occurs during the fetch
55
+ * @description 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
+ getActiveSubscriptions(): Promise<string[] | IError>;
59
+ /**
60
+ * Recover a subscription through the Stripe Billing Portal.
61
+ * @handleName recoverSubscriptions
62
+ * @param {ICancelSubscription} body - Subscription body. Example: `{ marker: "premium" }`.
63
+ * @returns {Promise<boolean | IError>} Returns true if the recovery request was accepted, or an error object if there was an issue.
64
+ * @throws {IError} When isShell=false and an error occurs during the fetch
65
+ * @description This method requires user authorization.
66
+ * @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}.
67
+ */
68
+ recoverSubscriptions(body: ICancelSubscription): Promise<boolean | IError>;
69
+ }
@@ -0,0 +1,102 @@
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 subscriptionsSchemas_1 = require("./subscriptionsSchemas");
8
+ /**
9
+ * Controllers for working with paid subscriptions.
10
+ * @handle /api/content/subscriptions
11
+ * @class SubscriptionsApi
12
+ * @augments AsyncModules
13
+ * @implements {ISubscriptionsApi}
14
+ * @description This class provides methods to interact with paid subscriptions: creating, cancelling, recovering, and listing available/active subscriptions.
15
+ */
16
+ class SubscriptionsApi extends asyncModules_1.default {
17
+ /**
18
+ * Constructor for SubscriptionsApi class.
19
+ * @param {StateModule} state - The state module.
20
+ */
21
+ constructor(state) {
22
+ super(state);
23
+ this._url = state.url + '/api/content/subscriptions';
24
+ }
25
+ /**
26
+ * Create a new subscription and get a payment session for it.
27
+ * @handleName subscribe
28
+ * @param {ISubscribe} body - Subscription body. Example: `{ marker: "premium" }`.
29
+ * @returns {Promise<ICreatedSubscription | IError>} Returns the created payment session for the subscription.
30
+ * @throws {IError} When isShell=false and an error occurs during the fetch
31
+ * @description This method requires user authorization.
32
+ * @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}.
33
+ */
34
+ async subscribe(body) {
35
+ const data = await this._fetchPost(``, body);
36
+ const validated = this._validateResponse(data, subscriptionsSchemas_1.CreatedSubscriptionSchema);
37
+ return this._normalizeData(validated);
38
+ }
39
+ /**
40
+ * Cancel a subscription.
41
+ * @handleName cancelSubscription
42
+ * @param {ICancelSubscription} body - Subscription body. Example: `{ marker: "premium" }`.
43
+ * @returns {Promise<boolean | IError>} Returns true if the subscription was cancelled, or an error object if there was an issue.
44
+ * @throws {IError} When isShell=false and an error occurs during the fetch
45
+ * @description This method requires user authorization.
46
+ * @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}.
47
+ */
48
+ async cancelSubscription(body) {
49
+ try {
50
+ await this._fetchDelete(``, body);
51
+ return true;
52
+ }
53
+ catch (e) {
54
+ return e;
55
+ }
56
+ }
57
+ /**
58
+ * Get all available subscription markers.
59
+ * @handleName getAllSubscriptions
60
+ * @returns {Promise<string[] | IError>} Returns an array of available subscription markers.
61
+ * @throws {IError} When isShell=false and an error occurs during the fetch
62
+ * @description This method requires user authorization.
63
+ * @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}.
64
+ */
65
+ async getAllSubscriptions() {
66
+ const data = await this._fetchGet(``);
67
+ const validated = this._validateResponse(data, subscriptionsSchemas_1.SubscriptionMarkersSchema);
68
+ return this._normalizeData(validated);
69
+ }
70
+ /**
71
+ * Get markers of the user's active subscriptions.
72
+ * @handleName getActiveSubscriptions
73
+ * @returns {Promise<string[] | IError>} Returns an array of active subscription markers.
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
+ async getActiveSubscriptions() {
79
+ const data = await this._fetchGet(`/active`);
80
+ const validated = this._validateResponse(data, subscriptionsSchemas_1.SubscriptionMarkersSchema);
81
+ return this._normalizeData(validated);
82
+ }
83
+ /**
84
+ * Recover a subscription through the Stripe Billing Portal.
85
+ * @handleName recoverSubscriptions
86
+ * @param {ICancelSubscription} body - Subscription body. Example: `{ marker: "premium" }`.
87
+ * @returns {Promise<boolean | IError>} Returns true if the recovery request was accepted, or an error object if there was an issue.
88
+ * @throws {IError} When isShell=false and an error occurs during the fetch
89
+ * @description This method requires user authorization.
90
+ * @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}.
91
+ */
92
+ async recoverSubscriptions(body) {
93
+ try {
94
+ await this._fetchPost(`/recover`, body);
95
+ return true;
96
+ }
97
+ catch (e) {
98
+ return e;
99
+ }
100
+ }
101
+ }
102
+ exports.default = SubscriptionsApi;