oneentry 1.0.155 → 1.0.157

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 (45) hide show
  1. package/README.md +19 -0
  2. package/changelog.md +154 -1
  3. package/dist/attribute-sets/attributeSetsApi.js +4 -4
  4. package/dist/attribute-sets/attributeSetsInterfaces.d.ts +1 -1
  5. package/dist/auth-provider/authProviderSchemas.d.ts +2 -0
  6. package/dist/auth-provider/authProviderSchemas.js +2 -0
  7. package/dist/auth-provider/authProvidersInterfaces.d.ts +4 -0
  8. package/dist/base/asyncModules.d.ts +18 -2
  9. package/dist/base/asyncModules.js +32 -8
  10. package/dist/base/syncModules.d.ts +41 -144
  11. package/dist/base/syncModules.js +67 -359
  12. package/dist/base/timeIntervals.d.ts +95 -0
  13. package/dist/base/timeIntervals.js +321 -0
  14. package/dist/base/utils.d.ts +65 -7
  15. package/dist/base/validation.js +0 -1
  16. package/dist/forms/formsApi.js +2 -2
  17. package/dist/forms/formsInterfaces.d.ts +3 -3
  18. package/dist/forms-data/formsDataApi.js +2 -2
  19. package/dist/forms-data/formsDataInterfaces.d.ts +4 -4
  20. package/dist/index.d.ts +3 -2
  21. package/dist/index.js +5 -0
  22. package/dist/integration-collections/integrationCollectionsApi.js +6 -6
  23. package/dist/integration-collections/integrationCollectionsInterfaces.d.ts +4 -0
  24. package/dist/integration-collections/integrationCollectionsSchemas.d.ts +4 -0
  25. package/dist/integration-collections/integrationCollectionsSchemas.js +2 -0
  26. package/dist/menus/menusApi.js +1 -1
  27. package/dist/orders/ordersInterfaces.d.ts +10 -0
  28. package/dist/orders/ordersSchemas.d.ts +10 -0
  29. package/dist/orders/ordersSchemas.js +12 -0
  30. package/dist/pages/pagesApi.d.ts +4 -4
  31. package/dist/pages/pagesApi.js +10 -9
  32. package/dist/pages/pagesInterfaces.d.ts +14 -4
  33. package/dist/pages/pagesSchemas.d.ts +15 -0
  34. package/dist/pages/pagesSchemas.js +13 -1
  35. package/dist/products/productsApi.d.ts +4 -4
  36. package/dist/products/productsApi.js +12 -10
  37. package/dist/products/productsInterfaces.d.ts +16 -4
  38. package/dist/products/productsSchemas.d.ts +17 -0
  39. package/dist/products/productsSchemas.js +14 -1
  40. package/dist/subscriptions/subscriptionsApi.d.ts +4 -4
  41. package/dist/subscriptions/subscriptionsApi.js +3 -3
  42. package/dist/subscriptions/subscriptionsInterfaces.d.ts +26 -5
  43. package/dist/subscriptions/subscriptionsSchemas.d.ts +27 -1
  44. package/dist/subscriptions/subscriptionsSchemas.js +20 -2
  45. package/package.json +1 -1
@@ -49,6 +49,8 @@ export declare const CollectionRowSchema: z.ZodObject<{
49
49
  entityType: z.ZodNullable<z.ZodString>;
50
50
  entityId: z.ZodNullable<z.ZodNumber>;
51
51
  attributeSetIdentifier: z.ZodOptional<z.ZodNullable<z.ZodString>>;
52
+ langCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
53
+ formIdentifier: z.ZodOptional<z.ZodNullable<z.ZodString>>;
52
54
  total: z.ZodOptional<z.ZodString>;
53
55
  }, z.core.$strip>;
54
56
  /**
@@ -68,6 +70,8 @@ export declare const CollectionRowsResponseSchema: z.ZodObject<{
68
70
  entityType: z.ZodNullable<z.ZodString>;
69
71
  entityId: z.ZodNullable<z.ZodNumber>;
70
72
  attributeSetIdentifier: z.ZodOptional<z.ZodNullable<z.ZodString>>;
73
+ langCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
74
+ formIdentifier: z.ZodOptional<z.ZodNullable<z.ZodString>>;
71
75
  total: z.ZodOptional<z.ZodString>;
72
76
  }, z.core.$strip>>;
73
77
  total: z.ZodNumber;
@@ -44,6 +44,8 @@ exports.CollectionRowSchema = zod_1.z.object({
44
44
  entityType: zod_1.z.string().nullable(),
45
45
  entityId: zod_1.z.number().nullable(),
46
46
  attributeSetIdentifier: zod_1.z.string().nullable().optional(),
47
+ langCode: zod_1.z.string().nullable().optional(),
48
+ formIdentifier: zod_1.z.string().nullable().optional(),
47
49
  total: zod_1.z.string().optional(),
48
50
  });
49
51
  /**
@@ -34,7 +34,7 @@ class MenusApi extends asyncModules_1.default {
34
34
  const result = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
35
35
  // Validate response if validation is enabled
36
36
  const validated = this._validateResponse(result, menusSchemas_1.MenuEntitySchema);
37
- return this._dataPostProcess(validated, langCode);
37
+ return this._normalizeData(validated, langCode);
38
38
  }
39
39
  }
40
40
  exports.default = MenusApi;
@@ -317,6 +317,7 @@ interface IOrderProductsData {
317
317
  * @property {string} totalSum - Total order amount. Example: "150".
318
318
  * @property {string} [createdDate] - Order creation date. Example: "2023-10-01T12:00:00Z".
319
319
  * @property {string} [statusIdentifier] - Text identifier of order status object (if not set, default status will be assigned). Example: "status-1".
320
+ * @property {ILocalizeInfo} [statusLocalizeInfos] - Localized status name assigned to the created/updated order.
320
321
  * @property {string} [couponCode] -
321
322
  * @property {string[]} [additionalDiscountsMarkers] -
322
323
  * @property {IOrderDiscountConfig} [discountConfig] - Resolved discount configuration applied to the order.
@@ -334,6 +335,7 @@ interface IBaseOrdersEntity {
334
335
  totalSum: string;
335
336
  createdDate?: string;
336
337
  statusIdentifier?: string;
338
+ statusLocalizeInfos?: ILocalizeInfo;
337
339
  couponCode?: string;
338
340
  additionalDiscountsMarkers?: string[];
339
341
  discountConfig?: IOrderDiscountConfig;
@@ -567,6 +569,10 @@ interface IOrderSplit {
567
569
  * @property {boolean | null} [isPartial] - Indicates that the order is partially paid; null on older orders where it was not tracked. Example: false.
568
570
  * @property {string} [paymentStrategy] - Payment strategy of the order. Example: "once".
569
571
  * @property {ILocalizeInfo} [statusLocalizeInfos] - Localized status name.
572
+ * @property {string | null} [fulfillmentStatusIdentifier] - Text identifier of the fulfillment (delivery) status; null while no fulfillment status is assigned. Example: "shipped".
573
+ * @property {ILocalizeInfo | null} [fulfillmentStatusLocalizeInfos] - Localized fulfillment status name; null while no fulfillment status is assigned.
574
+ * @property {string | null} [paymentStatusIdentifier] - Text identifier of the payment status; null while no payment status is assigned. Example: "inProgress-payment".
575
+ * @property {ILocalizeInfo | null} [paymentStatusLocalizeInfos] - Localized payment status name; null while no payment status is assigned.
570
576
  * @property {IOrderDiscountConfig | null} [discountConfig] - Resolved discount configuration applied to the order (orderDiscounts, productDiscounts, coupon, settings, bonus, totals); null on older orders without a resolved discount config.
571
577
  * @property {IOrderSplit} [split] - Split (staged) payment configuration; present on the by-id order endpoint.
572
578
  * @description Represents an order storage object created by the user.
@@ -590,6 +596,10 @@ interface IOrderByMarkerEntity {
590
596
  isPartial?: boolean | null;
591
597
  paymentStrategy?: string;
592
598
  statusLocalizeInfos?: ILocalizeInfo;
599
+ fulfillmentStatusIdentifier?: string | null;
600
+ fulfillmentStatusLocalizeInfos?: ILocalizeInfo | null;
601
+ paymentStatusIdentifier?: string | null;
602
+ paymentStatusLocalizeInfos?: ILocalizeInfo | null;
593
603
  discountConfig?: IOrderDiscountConfig | null;
594
604
  split?: IOrderSplit;
595
605
  }
@@ -69,6 +69,10 @@ export declare const OrderEntitySchema: z.ZodObject<{
69
69
  isPartial: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
70
70
  paymentStrategy: z.ZodOptional<z.ZodString>;
71
71
  statusLocalizeInfos: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
72
+ fulfillmentStatusIdentifier: z.ZodOptional<z.ZodNullable<z.ZodString>>;
73
+ fulfillmentStatusLocalizeInfos: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>>;
74
+ paymentStatusIdentifier: z.ZodOptional<z.ZodNullable<z.ZodString>>;
75
+ paymentStatusLocalizeInfos: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>>;
72
76
  discountConfig: z.ZodOptional<z.ZodNullable<z.ZodObject<{
73
77
  bonus: z.ZodOptional<z.ZodNullable<z.ZodObject<{
74
78
  availableBalance: z.ZodNumber;
@@ -133,6 +137,10 @@ export declare const OrdersResponseSchema: z.ZodObject<{
133
137
  isPartial: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
134
138
  paymentStrategy: z.ZodOptional<z.ZodString>;
135
139
  statusLocalizeInfos: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
140
+ fulfillmentStatusIdentifier: z.ZodOptional<z.ZodNullable<z.ZodString>>;
141
+ fulfillmentStatusLocalizeInfos: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>>;
142
+ paymentStatusIdentifier: z.ZodOptional<z.ZodNullable<z.ZodString>>;
143
+ paymentStatusLocalizeInfos: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>>;
136
144
  discountConfig: z.ZodOptional<z.ZodNullable<z.ZodObject<{
137
145
  bonus: z.ZodOptional<z.ZodNullable<z.ZodObject<{
138
146
  availableBalance: z.ZodNumber;
@@ -220,6 +228,7 @@ export declare const CreateOrderResponseSchema: z.ZodObject<{
220
228
  totalSum: z.ZodNumber;
221
229
  createdDate: z.ZodOptional<z.ZodString>;
222
230
  statusIdentifier: z.ZodOptional<z.ZodString>;
231
+ statusLocalizeInfos: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
223
232
  couponCode: z.ZodOptional<z.ZodString>;
224
233
  additionalDiscountsMarkers: z.ZodOptional<z.ZodArray<z.ZodString>>;
225
234
  discountConfig: z.ZodOptional<z.ZodObject<{
@@ -267,6 +276,7 @@ export declare const UpdateOrderResponseSchema: z.ZodObject<{
267
276
  totalSum: z.ZodNumber;
268
277
  createdDate: z.ZodOptional<z.ZodString>;
269
278
  statusIdentifier: z.ZodOptional<z.ZodString>;
279
+ statusLocalizeInfos: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
270
280
  couponCode: z.ZodOptional<z.ZodString>;
271
281
  additionalDiscountsMarkers: z.ZodOptional<z.ZodArray<z.ZodString>>;
272
282
  discountConfig: z.ZodOptional<z.ZodObject<{
@@ -75,6 +75,16 @@ exports.OrderEntitySchema = zod_1.z.object({
75
75
  isPartial: zod_1.z.boolean().nullable().optional(),
76
76
  paymentStrategy: zod_1.z.string().optional(),
77
77
  statusLocalizeInfos: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
78
+ fulfillmentStatusIdentifier: zod_1.z.string().nullable().optional(),
79
+ fulfillmentStatusLocalizeInfos: zod_1.z
80
+ .record(zod_1.z.string(), zod_1.z.any())
81
+ .nullable()
82
+ .optional(),
83
+ paymentStatusIdentifier: zod_1.z.string().nullable().optional(),
84
+ paymentStatusLocalizeInfos: zod_1.z
85
+ .record(zod_1.z.string(), zod_1.z.any())
86
+ .nullable()
87
+ .optional(),
78
88
  discountConfig: exports.OrderDiscountConfigSchema.nullable().optional(),
79
89
  split: zod_1.z
80
90
  .object({
@@ -132,6 +142,7 @@ exports.CreateOrderResponseSchema = zod_1.z.object({
132
142
  totalSum: zod_1.z.number(),
133
143
  createdDate: zod_1.z.string().optional(),
134
144
  statusIdentifier: zod_1.z.string().optional(),
145
+ statusLocalizeInfos: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
135
146
  couponCode: zod_1.z.string().optional(),
136
147
  additionalDiscountsMarkers: zod_1.z.array(zod_1.z.string()).optional(),
137
148
  discountConfig: exports.OrderDiscountConfigSchema.optional(),
@@ -153,6 +164,7 @@ exports.UpdateOrderResponseSchema = zod_1.z.object({
153
164
  totalSum: zod_1.z.number(),
154
165
  createdDate: zod_1.z.string().optional(),
155
166
  statusIdentifier: zod_1.z.string().optional(),
167
+ statusLocalizeInfos: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
156
168
  couponCode: zod_1.z.string().optional(),
157
169
  additionalDiscountsMarkers: zod_1.z.array(zod_1.z.string()).optional(),
158
170
  discountConfig: exports.OrderDiscountConfigSchema.optional(),
@@ -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 { IPageConfig, IPagesApi, IPagesEntity, IPositionBlock } from './pagesInterfaces';
4
+ import type { IPageConfig, IPagesApi, IPageSearchResult, IPagesEntity, IPositionBlock } from './pagesInterfaces';
5
5
  /**
6
6
  * Controllers for working with page objects, including catalog pages
7
7
  * @handle /api/content/pages
@@ -96,12 +96,12 @@ export default class PagesApi extends AsyncModules implements IPagesApi {
96
96
  * @param {string} name - Text for searching page objects (search is performed on the title field of the localizeInfos object with the language taken into account). Example: "About Us".
97
97
  * @param {string} [url] - Page URL. Example: "catalog".
98
98
  * @param {string} [langCode] - Language code. Default: "en_US".
99
- * @returns {Promise<IPagesEntity[] | IError>} Returns all created pages as an array of PageEntity objects or an empty array [] (if there is no data)
99
+ * @returns {Promise<IPagesEntity[] | IPageSearchResult[] | IError>} Returns found pages as an array of PageEntity objects, an array of short PageSearchResult cards when the traficLimit config option is enabled, or an empty array [] (if there is no data)
100
100
  * @throws {IError} When isShell=false and an error occurs during the fetch
101
- * @description Quick search for page objects with limited output.
101
+ * @description Quick search for page objects with limited output. The quick search endpoint returns short cards ({ id, title }); with traficLimit enabled they are returned as is, otherwise full page entities are fetched for the found ids.
102
102
  * @see {@link https://js-sdk.oneentry.cloud/docs/pages/searchPage searchPage} documentation.
103
103
  */
104
- searchPage(name: string, url?: string, langCode?: string): Promise<IPagesEntity[] | IError>;
104
+ searchPage(name: string, url?: string, langCode?: string): Promise<IPagesEntity[] | IPageSearchResult[] | IError>;
105
105
  /**
106
106
  * Add template data to pages
107
107
  * @handleName addTemplateToPages
@@ -201,16 +201,18 @@ class PagesApi extends asyncModules_1.default {
201
201
  * @param {string} name - Text for searching page objects (search is performed on the title field of the localizeInfos object with the language taken into account). Example: "About Us".
202
202
  * @param {string} [url] - Page URL. Example: "catalog".
203
203
  * @param {string} [langCode] - Language code. Default: "en_US".
204
- * @returns {Promise<IPagesEntity[] | IError>} Returns all created pages as an array of PageEntity objects or an empty array [] (if there is no data)
204
+ * @returns {Promise<IPagesEntity[] | IPageSearchResult[] | IError>} Returns found pages as an array of PageEntity objects, an array of short PageSearchResult cards when the traficLimit config option is enabled, or an empty array [] (if there is no data)
205
205
  * @throws {IError} When isShell=false and an error occurs during the fetch
206
- * @description Quick search for page objects with limited output.
206
+ * @description Quick search for page objects with limited output. The quick search endpoint returns short cards ({ id, title }); with traficLimit enabled they are returned as is, otherwise full page entities are fetched for the found ids.
207
207
  * @see {@link https://js-sdk.oneentry.cloud/docs/pages/searchPage searchPage} documentation.
208
208
  */
209
209
  async searchPage(name, url, langCode = this.state.lang) {
210
210
  // Fetch data from the server using a GET request to perform a quick search by page name and language code
211
211
  const urlPart = url ? `url=${encodeURIComponent(url)}&` : '';
212
- const data = await this._fetchGet(`/quick/search?${urlPart}lang=${encodeURIComponent(langCode)}&name=${encodeURIComponent(name)}`);
212
+ const searchPages = await this._fetchGet(`/quick/search?${urlPart}lang=${encodeURIComponent(langCode)}&name=${encodeURIComponent(name)}`);
213
213
  // /quick/search?url=catalog&langCode=en_US&name=cat
214
+ // Validate response if validation is enabled
215
+ const data = this._validateResponse(searchPages, pagesSchemas_1.PageSearchResponseSchema);
214
216
  // Check if there is no traffic limit set in the state
215
217
  if (!this.state.traficLimit && Array.isArray(data)) {
216
218
  // Initialize an empty array to store detailed page information
@@ -224,13 +226,12 @@ class PagesApi extends asyncModules_1.default {
224
226
  }));
225
227
  // Add templates to the fetched pages
226
228
  const withTemplate = await this.addTemplateToPages(pageList);
227
- // Post-process the data and return it; ensures consistent structure or handles errors
228
- return this._dataPostProcess(withTemplate, langCode);
229
+ // Normalize the data and return it; ensures consistent structure or handles errors
230
+ return this._normalizeData(withTemplate, langCode);
229
231
  }
230
- // If there is a traffic limit, add templates to the initially fetched data without fetching detailed information
231
- const withTemplate = await this.addTemplateToPages(data);
232
- // Normalize the data and return it; ensures consistent structure or handles errors
233
- return this._normalizeData(withTemplate, langCode);
232
+ // With a traffic limit (or on an API error) return the quick search response as is:
233
+ // short cards carry no templateIdentifier, so there is nothing to attach a template to
234
+ return this._normalizeData(data, langCode);
234
235
  }
235
236
  /**
236
237
  * Add template data to pages
@@ -81,11 +81,11 @@ interface IPagesApi {
81
81
  * @param {string} name - Text for searching page objects (search is performed on the title field of the localizeInfos object with the language taken into account). Example: "About Us".
82
82
  * @param {string} [url] - Optional page URL to filter search results. Example: "catalog".
83
83
  * @param {string} [langCode] - Language code. Default: "en_US".
84
- * @returns {IPagesEntity[]} Returns all created pages as an array of PageEntity objects or an empty array [] (if there is no data)
84
+ * @returns {IPagesEntity[] | IPageSearchResult[]} Returns found pages as an array of PageEntity objects, an array of short PageSearchResult cards when the traficLimit config option is enabled, or an empty array [] (if there is no data)
85
85
  * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
86
- * @description This method performs a quick search for page objects with limited output.
86
+ * @description This method performs a quick search for page objects with limited output. With traficLimit enabled the raw quick search response is returned as short cards; otherwise full page entities are fetched for the found ids.
87
87
  */
88
- searchPage(name: string, url?: string, langCode?: LangType): Promise<IPagesEntity[] | IError>;
88
+ searchPage(name: string, url?: string, langCode?: LangType): Promise<IPagesEntity[] | IPageSearchResult[] | IError>;
89
89
  }
90
90
  /**
91
91
  * @interface IPageConfig
@@ -294,4 +294,14 @@ interface IPagesEntity {
294
294
  total?: string;
295
295
  categoryPath?: string | null;
296
296
  }
297
- export type { IPageConfig, IPagesApi, IPagesEntity, IPositionBlock, IPositionForm, PageType, };
297
+ /**
298
+ * @interface IPageSearchResult
299
+ * @property {number} id - The identifier of the page. Example: 10.
300
+ * @property {string} title - Page title in the requested language. Example: "Catalog".
301
+ * @description This interface defines the short page card returned by the quick search endpoint when the traficLimit config option is enabled. It contains only identification fields, without attributeValues, localizeInfos, blocks and other fields of a full page entity.
302
+ */
303
+ interface IPageSearchResult {
304
+ id: number;
305
+ title: string;
306
+ }
307
+ export type { IPageConfig, IPagesApi, IPageSearchResult, IPagesEntity, IPositionBlock, IPositionForm, PageType, };
@@ -66,6 +66,21 @@ export declare const PagesResponseSchema: z.ZodArray<z.ZodObject<{
66
66
  total: z.ZodOptional<z.ZodString>;
67
67
  categoryPath: z.ZodOptional<z.ZodNullable<z.ZodString>>;
68
68
  }, z.core.$strip>>;
69
+ /**
70
+ * Page search result schema
71
+ * Short card returned by the quick search endpoint
72
+ */
73
+ export declare const PageSearchResultSchema: z.ZodObject<{
74
+ id: z.ZodNumber;
75
+ title: z.ZodString;
76
+ }, z.core.$strip>;
77
+ /**
78
+ * Page search response schema (array of short cards)
79
+ */
80
+ export declare const PageSearchResponseSchema: z.ZodArray<z.ZodObject<{
81
+ id: z.ZodNumber;
82
+ title: z.ZodString;
83
+ }, z.core.$strip>>;
69
84
  /**
70
85
  * Single page response schema
71
86
  */
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PageConfigSchema = exports.SinglePageSchema = exports.PagesResponseSchema = exports.PageEntitySchema = void 0;
3
+ exports.PageConfigSchema = exports.SinglePageSchema = exports.PageSearchResponseSchema = exports.PageSearchResultSchema = exports.PagesResponseSchema = exports.PageEntitySchema = void 0;
4
4
  /**
5
5
  * Validation schemas for Pages module
6
6
  * @description Zod schemas for validating pages-related API responses
@@ -38,6 +38,18 @@ exports.PageEntitySchema = zod_1.z.object({
38
38
  * Pages response schema (array of pages)
39
39
  */
40
40
  exports.PagesResponseSchema = zod_1.z.array(exports.PageEntitySchema);
41
+ /**
42
+ * Page search result schema
43
+ * Short card returned by the quick search endpoint
44
+ */
45
+ exports.PageSearchResultSchema = zod_1.z.object({
46
+ id: zod_1.z.number(),
47
+ title: zod_1.z.string(),
48
+ });
49
+ /**
50
+ * Page search response schema (array of short cards)
51
+ */
52
+ exports.PageSearchResponseSchema = zod_1.z.array(exports.PageSearchResultSchema);
41
53
  /**
42
54
  * Single page response schema
43
55
  */
@@ -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, IProductsByIdsQuery, IProductsCount, IProductsEntity, IProductsInfo, IProductsPriceQuery, IProductsQueryBase, IProductsRelatedQuery, IProductsResponse, IVectorSearchProducts } from './productsInterfaces';
4
+ import type { IAggregatedProductGroup, IFilterParams, IProductBlock, IProductsApi, IProductsByIdsQuery, IProductsCount, IProductSearchResult, IProductsEntity, IProductsInfo, IProductsPriceQuery, IProductsQueryBase, IProductsRelatedQuery, IProductsResponse, IVectorSearchProducts } from './productsInterfaces';
5
5
  /**
6
6
  * Controllers for working with product pages
7
7
  * @handle /api/content/products
@@ -267,12 +267,12 @@ export default class ProductsApi extends AsyncModules implements IProductsApi {
267
267
  * @handleName searchProduct
268
268
  * @param {string} name - Text to search product page objects (search is based on the title field of the localizeInfos object with language consideration). Example: "laminat".
269
269
  * @param {string} [langCode] - Language code. Default: "en_US".
270
- * @returns {Promise<IProductsEntity[] | IError>} Array with ProductEntity objects
270
+ * @returns {Promise<IProductsEntity[] | IProductSearchResult[] | IError>} Array with ProductEntity objects, or an array with short ProductSearchResult cards when the traficLimit config option is enabled
271
271
  * @throws {IError} When isShell=false and an error occurs during the fetch
272
- * @description Quick search for product page objects with limited output.
272
+ * @description Quick search for product page objects with limited output. The quick search endpoint returns short cards ({ id, title, pageId }); with traficLimit enabled they are returned as is, otherwise full product entities are fetched for the found ids.
273
273
  * @see {@link https://js-sdk.oneentry.cloud/docs/products/searchProduct searchProduct} documentation.
274
274
  */
275
- searchProduct(name: string, langCode?: string): Promise<IProductsEntity[] | IError>;
275
+ searchProduct(name: string, langCode?: string): Promise<IProductsEntity[] | IProductSearchResult[] | IError>;
276
276
  /**
277
277
  * Getting the number of products for the entire catalog.
278
278
  * @handleName getProductsCount
@@ -75,7 +75,7 @@ class ProductsApi extends asyncModules_1.default {
75
75
  const result = await this._fetchPost(`/all?` + this._queryParamsToString(query), { filter: body });
76
76
  // Validate response if validation is enabled
77
77
  const validated = this._validateResponse(result, productsSchemas_1.ProductsResponseSchema);
78
- return this._dataPostProcess(validated, langCode);
78
+ return this._normalizeData(validated, langCode);
79
79
  }
80
80
  /**
81
81
  * Search for all product page objects with pagination (and aggregation) that do not have a category.
@@ -150,7 +150,7 @@ class ProductsApi extends asyncModules_1.default {
150
150
  const result = await this._fetchPost(`/page/${id}?langCode=${langCode}&` + this._queryParamsToString(query), { filter: body });
151
151
  // Validate response if validation is enabled
152
152
  const validated = this._validateResponse(result, productsSchemas_1.ProductsResponseSchema);
153
- return this._dataPostProcess(validated, langCode);
153
+ return this._normalizeData(validated, langCode);
154
154
  }
155
155
  /**
156
156
  * Search for information about products and prices for the selected category.
@@ -229,7 +229,7 @@ class ProductsApi extends asyncModules_1.default {
229
229
  this._queryParamsToString(query), { filter: body });
230
230
  // Validate response if validation is enabled
231
231
  const validated = this._validateResponse(result, productsSchemas_1.ProductsResponseSchema);
232
- return this._dataPostProcess(validated, langCode);
232
+ return this._normalizeData(validated, langCode);
233
233
  }
234
234
  /**
235
235
  * Find all related product page objects.
@@ -261,7 +261,7 @@ class ProductsApi extends asyncModules_1.default {
261
261
  const result = await this._fetchGet(`/${id}/related?langCode=${langCode}&` + this._queryParamsToString(query));
262
262
  // Validate response if validation is enabled
263
263
  const validated = this._validateResponse(result, productsSchemas_1.ProductsResponseSchema);
264
- return this._dataPostProcess(validated, langCode);
264
+ return this._normalizeData(validated, langCode);
265
265
  }
266
266
  /**
267
267
  * Find products by its ids.
@@ -290,7 +290,7 @@ class ProductsApi extends asyncModules_1.default {
290
290
  ...userQuery,
291
291
  };
292
292
  const result = await this._fetchGet(`/ids?` + this._queryParamsToString(query));
293
- return this._dataPostProcess(result, langCode);
293
+ return this._normalizeData(result, langCode);
294
294
  }
295
295
  /**
296
296
  * Retrieve one product object.
@@ -310,7 +310,7 @@ class ProductsApi extends asyncModules_1.default {
310
310
  const result = await this._fetchGet(`/${id}?` + this._queryParamsToString(query));
311
311
  // Validate response if validation is enabled
312
312
  const validated = this._validateResponse(result, productsSchemas_1.ProductEntitySchema);
313
- return this._dataPostProcess(validated, langCode);
313
+ return this._normalizeData(validated, langCode);
314
314
  }
315
315
  /**
316
316
  * Getting a product block object by product id.
@@ -330,13 +330,15 @@ class ProductsApi extends asyncModules_1.default {
330
330
  * @handleName searchProduct
331
331
  * @param {string} name - Text to search product page objects (search is based on the title field of the localizeInfos object with language consideration). Example: "laminat".
332
332
  * @param {string} [langCode] - Language code. Default: "en_US".
333
- * @returns {Promise<IProductsEntity[] | IError>} Array with ProductEntity objects
333
+ * @returns {Promise<IProductsEntity[] | IProductSearchResult[] | IError>} Array with ProductEntity objects, or an array with short ProductSearchResult cards when the traficLimit config option is enabled
334
334
  * @throws {IError} When isShell=false and an error occurs during the fetch
335
- * @description Quick search for product page objects with limited output.
335
+ * @description Quick search for product page objects with limited output. The quick search endpoint returns short cards ({ id, title, pageId }); with traficLimit enabled they are returned as is, otherwise full product entities are fetched for the found ids.
336
336
  * @see {@link https://js-sdk.oneentry.cloud/docs/products/searchProduct searchProduct} documentation.
337
337
  */
338
338
  async searchProduct(name, langCode = this.state.lang) {
339
- const searchProducts = await this._fetchGet(`/quick/search?langCode=${encodeURIComponent(langCode)}&name=${encodeURIComponent(name)}`);
339
+ const result = await this._fetchGet(`/quick/search?langCode=${encodeURIComponent(langCode)}&name=${encodeURIComponent(name)}`);
340
+ // Validate response if validation is enabled
341
+ const searchProducts = this._validateResponse(result, productsSchemas_1.ProductSearchResponseSchema);
340
342
  if (!this.state.traficLimit && Array.isArray(searchProducts)) {
341
343
  if (searchProducts.length === 0)
342
344
  return searchProducts;
@@ -453,7 +455,7 @@ class ProductsApi extends asyncModules_1.default {
453
455
  limit,
454
456
  };
455
457
  const result = await this._fetchPost(`/vector/search?` + this._queryParamsToString(query), body);
456
- return this._dataPostProcess(result, langCode);
458
+ return this._normalizeData(result, langCode);
457
459
  }
458
460
  /**
459
461
  * Get products by page url.
@@ -189,11 +189,11 @@ interface IProductsApi {
189
189
  * @handleName searchProduct
190
190
  * @param {string} name - Text to search product page objects (search is based on the title field of the localizeInfos object with language consideration). Example: 'laminat'.
191
191
  * @param {string} [langCode] - Language code. Default: "en_US".
192
- * @returns {IProductsEntity[]} Array with ProductEntity objects
192
+ * @returns {IProductsEntity[] | IProductSearchResult[]} Array with ProductEntity objects, or an array with short ProductSearchResult cards when the traficLimit config option is enabled
193
193
  * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
194
- * @description This method performs a quick search for product page objects with limited output.
194
+ * @description This method performs a quick search for product page objects with limited output. With traficLimit enabled the raw quick search response is returned as short cards; otherwise full product entities are fetched for the found ids.
195
195
  */
196
- searchProduct(name: string, langCode?: string): Promise<IProductsEntity[] | IError>;
196
+ searchProduct(name: string, langCode?: string): Promise<IProductsEntity[] | IProductSearchResult[] | IError>;
197
197
  /**
198
198
  * Getting the number of products for the entire catalog.
199
199
  * @handleName getProductsCount
@@ -539,6 +539,18 @@ interface IProductsResponse {
539
539
  items: IProductsEntity[];
540
540
  total: number;
541
541
  }
542
+ /**
543
+ * @interface IProductSearchResult
544
+ * @property {number} id - The identifier of the product. Example: 2957.
545
+ * @property {string} title - Product title in the requested language. Example: "Cosmo".
546
+ * @property {number} pageId - The identifier of the catalog page the product is linked to. Example: 10.
547
+ * @description This interface defines the short product card returned by the quick search endpoint when the traficLimit config option is enabled. It contains only identification fields, without attributeValues, localizeInfos and other fields of a full product entity.
548
+ */
549
+ interface IProductSearchResult {
550
+ id: number;
551
+ title: string;
552
+ pageId: number;
553
+ }
542
554
  /**
543
555
  * @interface IProductsCount
544
556
  * @property {number} totalAll - The total number of products found. Example: 100.
@@ -700,4 +712,4 @@ interface IVectorSearchProducts {
700
712
  maxHits?: number;
701
713
  debug?: boolean;
702
714
  }
703
- export type { IAggregatedProductGroup, IFilterParams, IProductBlock, IProductInfo, IProductsApi, IProductsByIdsQuery, IProductsCount, IProductsEntity, IProductsInfo, IProductsPriceQuery, IProductsQuery, IProductsQueryBase, IProductsRelatedQuery, IProductsResponse, IVectorSearchProducts, };
715
+ export type { IAggregatedProductGroup, IFilterParams, IProductBlock, IProductInfo, IProductsApi, IProductsByIdsQuery, IProductsCount, IProductSearchResult, IProductsEntity, IProductsInfo, IProductsPriceQuery, IProductsQuery, IProductsQueryBase, IProductsRelatedQuery, IProductsResponse, IVectorSearchProducts, };
@@ -148,6 +148,23 @@ export declare const SingleProductSchema: z.ZodObject<{
148
148
  distance: z.ZodOptional<z.ZodNumber>;
149
149
  discountConfig: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
150
150
  }, z.core.$strip>;
151
+ /**
152
+ * Product search result schema
153
+ * Short card returned by the quick search endpoint
154
+ */
155
+ export declare const ProductSearchResultSchema: z.ZodObject<{
156
+ id: z.ZodNumber;
157
+ title: z.ZodString;
158
+ pageId: z.ZodNumber;
159
+ }, z.core.$strip>;
160
+ /**
161
+ * Product search response schema (array of short cards)
162
+ */
163
+ export declare const ProductSearchResponseSchema: z.ZodArray<z.ZodObject<{
164
+ id: z.ZodNumber;
165
+ title: z.ZodString;
166
+ pageId: z.ZodNumber;
167
+ }, z.core.$strip>>;
151
168
  /**
152
169
  * Products count schema
153
170
  */
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RelatedProductsSchema = exports.ProductBlockSchema = exports.ProductsCountSchema = exports.SingleProductSchema = exports.ProductsResponseSchema = exports.ProductEntitySchema = exports.ProductImageSchema = exports.ProductPriceSchema = void 0;
3
+ exports.RelatedProductsSchema = exports.ProductBlockSchema = exports.ProductsCountSchema = exports.ProductSearchResponseSchema = exports.ProductSearchResultSchema = exports.SingleProductSchema = exports.ProductsResponseSchema = exports.ProductEntitySchema = exports.ProductImageSchema = exports.ProductPriceSchema = void 0;
4
4
  /**
5
5
  * Validation schemas for Products module
6
6
  * @description Zod schemas for validating products-related API responses
@@ -79,6 +79,19 @@ exports.ProductsResponseSchema = zod_1.z.object({
79
79
  * Single product response schema
80
80
  */
81
81
  exports.SingleProductSchema = exports.ProductEntitySchema;
82
+ /**
83
+ * Product search result schema
84
+ * Short card returned by the quick search endpoint
85
+ */
86
+ exports.ProductSearchResultSchema = zod_1.z.object({
87
+ id: zod_1.z.number(),
88
+ title: zod_1.z.string(),
89
+ pageId: zod_1.z.number(),
90
+ });
91
+ /**
92
+ * Product search response schema (array of short cards)
93
+ */
94
+ exports.ProductSearchResponseSchema = zod_1.z.array(exports.ProductSearchResultSchema);
82
95
  /**
83
96
  * Products count schema
84
97
  */
@@ -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 { ICancelSubscription, ICreatedSubscription, ISubscribe, ISubscriptionsApi } from './subscriptionsInterfaces';
4
+ import type { ICancelSubscription, ICreatedSubscription, ISubscribe, ISubscriptionEntity, ISubscriptionsApi } from './subscriptionsInterfaces';
5
5
  /**
6
6
  * Controllers for working with paid subscriptions.
7
7
  * @handle /api/content/subscriptions
@@ -41,15 +41,15 @@ export default class SubscriptionsApi extends AsyncModules implements ISubscript
41
41
  */
42
42
  cancelSubscription(body: ICancelSubscription): Promise<boolean | IError>;
43
43
  /**
44
- * Get all available subscription markers.
44
+ * Get all available subscriptions.
45
45
  * @handleName getAllSubscriptions
46
- * @returns {Promise<string[] | IError>} Returns an array of available subscription markers.
46
+ * @returns {Promise<ISubscriptionEntity[] | IError>} Returns an array of available subscriptions.
47
47
  * @throws {IError} When isShell=false and an error occurs during the fetch
48
48
  * @description This method requires user authorization.
49
49
  * @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}.
50
50
  * @see {@link https://js-sdk.oneentry.cloud/docs/subscriptions/getAllSubscriptions getAllSubscriptions} documentation.
51
51
  */
52
- getAllSubscriptions(): Promise<string[] | IError>;
52
+ getAllSubscriptions(): Promise<ISubscriptionEntity[] | IError>;
53
53
  /**
54
54
  * Get markers of the user's active subscriptions.
55
55
  * @handleName getActiveSubscriptions
@@ -51,9 +51,9 @@ class SubscriptionsApi extends asyncModules_1.default {
51
51
  return this._fetchBoolean(() => this._fetchDelete(``, body));
52
52
  }
53
53
  /**
54
- * Get all available subscription markers.
54
+ * Get all available subscriptions.
55
55
  * @handleName getAllSubscriptions
56
- * @returns {Promise<string[] | IError>} Returns an array of available subscription markers.
56
+ * @returns {Promise<ISubscriptionEntity[] | IError>} Returns an array of available subscriptions.
57
57
  * @throws {IError} When isShell=false and an error occurs during the fetch
58
58
  * @description This method requires user authorization.
59
59
  * @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}.
@@ -61,7 +61,7 @@ class SubscriptionsApi extends asyncModules_1.default {
61
61
  */
62
62
  async getAllSubscriptions() {
63
63
  const data = await this._fetchGet(``);
64
- const validated = this._validateResponse(data, subscriptionsSchemas_1.SubscriptionMarkersSchema);
64
+ const validated = this._validateResponse(data, subscriptionsSchemas_1.SubscriptionsListSchema);
65
65
  return this._normalizeData(validated);
66
66
  }
67
67
  /**
@@ -1,4 +1,4 @@
1
- import type { IError } from '../base/utils';
1
+ import type { IError, ILocalizeInfo } from '../base/utils';
2
2
  /**
3
3
  * Interface for the Subscriptions API module.
4
4
  * @interface ISubscriptionsApi
@@ -26,14 +26,14 @@ interface ISubscriptionsApi {
26
26
  */
27
27
  cancelSubscription(body: ICancelSubscription): Promise<boolean | IError>;
28
28
  /**
29
- * Get all available subscription markers.
29
+ * Get all available subscriptions.
30
30
  * @handleName getAllSubscriptions
31
- * @returns {Promise<string[] | IError>} Returns an array of available subscription markers.
31
+ * @returns {Promise<ISubscriptionEntity[] | IError>} Returns an array of available subscriptions.
32
32
  * @throws {IError} When isShell=false and an error occurs during the fetch
33
33
  * @description This method requires user authorization.
34
34
  * @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}.
35
35
  */
36
- getAllSubscriptions(): Promise<string[] | IError>;
36
+ getAllSubscriptions(): Promise<ISubscriptionEntity[] | IError>;
37
37
  /**
38
38
  * Get markers of the user's active subscriptions.
39
39
  * @handleName getActiveSubscriptions
@@ -87,4 +87,25 @@ interface ICreatedSubscription {
87
87
  paymentUrl: string;
88
88
  status: string;
89
89
  }
90
- export type { ICancelSubscription, ICreatedSubscription, ISubscribe, ISubscriptionsApi, };
90
+ /**
91
+ * Available subscription.
92
+ * @interface ISubscriptionEntity
93
+ * @property {number} id - Subscription identifier. Example: 1.
94
+ * @property {string} identifier - Subscription textual identifier (marker). Example: "test_subscription".
95
+ * @property {ILocalizeInfo} localizeInfos - Localized subscription info for the current language. Example: `{ title: "Test subscription" }`.
96
+ * @property {number[]} productIds - Identifiers of the products included in the subscription. Example: [3445].
97
+ * @property {number} periodInDays - Subscription period in days. Example: 30.
98
+ * @property {number} paymentAccountId - Identifier of the payment account the subscription is billed through. Example: 1.
99
+ * @property {boolean} isUsed - Indicates whether the subscription is in use. Example: false.
100
+ * @description Subscription configured in the project, returned by getAllSubscriptions.
101
+ */
102
+ interface ISubscriptionEntity {
103
+ id: number;
104
+ identifier: string;
105
+ localizeInfos: ILocalizeInfo;
106
+ productIds: number[];
107
+ periodInDays: number;
108
+ paymentAccountId: number;
109
+ isUsed: boolean;
110
+ }
111
+ export type { ICancelSubscription, ICreatedSubscription, ISubscribe, ISubscriptionEntity, ISubscriptionsApi, };