oneentry 1.0.156 → 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 (39) hide show
  1. package/changelog.md +89 -0
  2. package/dist/attribute-sets/attributeSetsApi.js +4 -4
  3. package/dist/attribute-sets/attributeSetsInterfaces.d.ts +1 -1
  4. package/dist/auth-provider/authProviderSchemas.d.ts +2 -0
  5. package/dist/auth-provider/authProviderSchemas.js +2 -0
  6. package/dist/auth-provider/authProvidersInterfaces.d.ts +4 -0
  7. package/dist/base/asyncModules.d.ts +18 -2
  8. package/dist/base/asyncModules.js +32 -8
  9. package/dist/base/syncModules.d.ts +36 -36
  10. package/dist/base/syncModules.js +60 -82
  11. package/dist/base/utils.d.ts +2 -2
  12. package/dist/forms/formsApi.js +2 -2
  13. package/dist/forms/formsInterfaces.d.ts +2 -2
  14. package/dist/forms-data/formsDataApi.js +2 -2
  15. package/dist/forms-data/formsDataInterfaces.d.ts +4 -4
  16. package/dist/integration-collections/integrationCollectionsApi.js +6 -6
  17. package/dist/integration-collections/integrationCollectionsInterfaces.d.ts +4 -0
  18. package/dist/integration-collections/integrationCollectionsSchemas.d.ts +4 -0
  19. package/dist/integration-collections/integrationCollectionsSchemas.js +2 -0
  20. package/dist/menus/menusApi.js +1 -1
  21. package/dist/orders/ordersInterfaces.d.ts +10 -0
  22. package/dist/orders/ordersSchemas.d.ts +10 -0
  23. package/dist/orders/ordersSchemas.js +12 -0
  24. package/dist/pages/pagesApi.d.ts +4 -4
  25. package/dist/pages/pagesApi.js +10 -9
  26. package/dist/pages/pagesInterfaces.d.ts +14 -4
  27. package/dist/pages/pagesSchemas.d.ts +15 -0
  28. package/dist/pages/pagesSchemas.js +13 -1
  29. package/dist/products/productsApi.d.ts +4 -4
  30. package/dist/products/productsApi.js +12 -10
  31. package/dist/products/productsInterfaces.d.ts +16 -4
  32. package/dist/products/productsSchemas.d.ts +17 -0
  33. package/dist/products/productsSchemas.js +14 -1
  34. package/dist/subscriptions/subscriptionsApi.d.ts +4 -4
  35. package/dist/subscriptions/subscriptionsApi.js +3 -3
  36. package/dist/subscriptions/subscriptionsInterfaces.d.ts +26 -5
  37. package/dist/subscriptions/subscriptionsSchemas.d.ts +27 -1
  38. package/dist/subscriptions/subscriptionsSchemas.js +20 -2
  39. package/package.json +1 -1
@@ -71,7 +71,7 @@ interface IFromPages {
71
71
  * @property {string} identifier - The textual identifier for the record field. Example: "form_contact_us".
72
72
  * @property {string} processingType - Type of form processing. Example: "async".
73
73
  * @property {number | null} templateId - The identifier of the template used by the form, or null if no template is used. Example: 6789.
74
- * @property {IFormAttribute[]} attributes - Form fields with their localization, validators and form-specific flags.
74
+ * @property {IFormAttribute[]} attributes - Form fields with their localization, validators and form-specific flags, sorted by `position`.
75
75
  * @property {number | string} [total] - Total count of related entries. Example: "1".
76
76
  * @property {IFormConfig[]} [moduleFormConfigs] - Array of module form configurations associated with the form.
77
77
  * @description This interface defines the structure of a form entity, including its identifiers, attributes, and processing data.
@@ -153,7 +153,7 @@ interface IFormAttribute {
153
153
  * @interface IFormAttributeAdditionalField
154
154
  * @property {string} marker - Marker of the additional field. Example: "additional_field".
155
155
  * @property {string} type - Type of the additional field. Example: "string".
156
- * @property {unknown} value - Value of the additional field. Example: "Additional field data".
156
+ * @property {unknown} value - Value of the additional field, normalized like any other attribute value: `number | null` for numeric types, the file object itself for a single-file `image`/`file`, `null` when empty. Example: "Additional field data".
157
157
  * @description A single nested entry inside {@link IFormAttribute}'s `additionalFields` map.
158
158
  */
159
159
  interface IFormAttributeAdditionalField {
@@ -123,7 +123,7 @@ class FormsDataApi extends asyncModules_1.default {
123
123
  const result = await this._fetchPost(``, body);
124
124
  // Validate response if validation is enabled
125
125
  const validated = this._validateResponse(result, formsDataSchemas_1.PostFormResponseSchema);
126
- return this._dataPostProcess(validated);
126
+ return this._normalizeData(validated);
127
127
  }
128
128
  /**
129
129
  * Get one object of form data by marker.
@@ -152,7 +152,7 @@ class FormsDataApi extends asyncModules_1.default {
152
152
  const result = await this._fetchPost(`/marker/${marker}?formModuleConfigId=${formModuleConfigId}&isExtended=${isExtended}&langCode=${langCode}&offset=${offset}&limit=${limit}`, body);
153
153
  // Validate response if validation is enabled
154
154
  const validated = this._validateResponse(result, formsDataSchemas_1.FormsByMarkerDataResponseSchema);
155
- return this._dataPostProcess(validated, langCode);
155
+ return this._normalizeData(validated, langCode);
156
156
  }
157
157
  /**
158
158
  * Update one object of form data by id. Requires user authentication.
@@ -346,13 +346,13 @@ interface IBodyPostFormData {
346
346
  * @interface IBodyTypeStringNumberFloat
347
347
  * @property {string} marker - marker name. Example: "some_marker".
348
348
  * @property {string} type - Type value. "string" | "number" | "float". Example: "string".
349
- * @property {string} value - Value of the form data entity, which can be a "string", "number", or "float". Example: "string".
349
+ * @property {string | number | null} value - Value of the form data entity. Send it as a string; in responses numeric fields come back normalized to `number`, or `null` when the field is empty. Example: "string".
350
350
  * @description Represents a form data entity with a marker, type, and value.
351
351
  */
352
352
  interface IBodyTypeStringNumberFloat {
353
353
  marker: string;
354
354
  type: 'string' | 'number' | 'float';
355
- value: string;
355
+ value: string | number | null;
356
356
  }
357
357
  /**
358
358
  * Represents a date/time form data entity.
@@ -520,7 +520,7 @@ interface IImageValue {
520
520
  * @interface IBodyTypeFile
521
521
  * @property {string} marker - marker name. Example: "picture".
522
522
  * @property {'file'} type - Type value. Example: "file".
523
- * @property {object} value - File Object. Contains file information.
523
+ * @property {object} value - File Object. Contains file information. A single attached file is returned as the object itself, several files as an array.
524
524
  * @example
525
525
  [
526
526
  {
@@ -534,7 +534,7 @@ interface IImageValue {
534
534
  interface IBodyTypeFile {
535
535
  marker: string;
536
536
  type: 'file';
537
- value: IFileValue;
537
+ value: IFileValue | IFileValue[];
538
538
  }
539
539
  /**
540
540
  * @interface IFileValue
@@ -52,7 +52,7 @@ class IntegrationCollectionsApi extends asyncModules_1.default {
52
52
  const result = await this._fetchGet(`?` + this._queryParamsToString(query));
53
53
  // Validate response if validation is enabled
54
54
  const validated = this._validateResponse(result, integrationCollectionsSchemas_1.CollectionsResponseSchema);
55
- return this._dataPostProcess(validated, langCode);
55
+ return this._normalizeData(validated, langCode);
56
56
  }
57
57
  /**
58
58
  * Get a single collection object by id.
@@ -67,7 +67,7 @@ class IntegrationCollectionsApi extends asyncModules_1.default {
67
67
  const result = await this._fetchGet(`/${id}?` + this._queryParamsToString({ langCode }));
68
68
  // Validate response if validation is enabled
69
69
  const validated = this._validateResponse(result, integrationCollectionsSchemas_1.CollectionEntitySchema);
70
- return this._dataPostProcess(validated, langCode);
70
+ return this._normalizeData(validated, langCode);
71
71
  }
72
72
  /**
73
73
  * Get all records belonging to the collection by collection id.
@@ -100,7 +100,7 @@ class IntegrationCollectionsApi extends asyncModules_1.default {
100
100
  }));
101
101
  // Validate response if validation is enabled
102
102
  const validated = this._validateResponse(result, integrationCollectionsSchemas_1.CollectionRowsResponseSchema);
103
- return this._dataPostProcess(validated, langCode);
103
+ return this._normalizeData(validated, langCode);
104
104
  }
105
105
  /**
106
106
  * Check for the existence of a text identifier (marker).
@@ -119,7 +119,7 @@ class IntegrationCollectionsApi extends asyncModules_1.default {
119
119
  const result = await this._fetchGet(`/marker-validation/${marker}`);
120
120
  // Validate response if validation is enabled
121
121
  const validated = this._validateResponse(result, integrationCollectionsSchemas_1.CollectionIsValidSchema);
122
- return this._dataPostProcess(validated);
122
+ return this._normalizeData(validated);
123
123
  }
124
124
  /**
125
125
  * Getting all records from the collection.
@@ -134,7 +134,7 @@ class IntegrationCollectionsApi extends asyncModules_1.default {
134
134
  const result = await this._fetchGet(`/marker/${marker}/rows?langCode=${langCode}`);
135
135
  // Validate response if validation is enabled
136
136
  const validated = this._validateResponse(result, integrationCollectionsSchemas_1.CollectionRowsResponseSchema);
137
- return this._dataPostProcess(validated, langCode);
137
+ return this._normalizeData(validated, langCode);
138
138
  }
139
139
  /**
140
140
  * Getting one record from the collection.
@@ -150,7 +150,7 @@ class IntegrationCollectionsApi extends asyncModules_1.default {
150
150
  const result = await this._fetchGet(`/marker/${marker}/rows/${id}?langCode=${langCode}`);
151
151
  // Validate response if validation is enabled
152
152
  const validated = this._validateResponse(result, integrationCollectionsSchemas_1.CollectionRowSchema);
153
- return this._dataPostProcess(validated, langCode);
153
+ return this._normalizeData(validated, langCode);
154
154
  }
155
155
  /**
156
156
  * Create a record in the collection.
@@ -244,6 +244,8 @@ interface ICollectionFormObject {
244
244
  * @property {string | null} entityType - Type of the entity associated with the collection row. Example: "product", "order", "etc".
245
245
  * @property {number | null} entityId - Identifier of the entity associated with the collection row. Example: 12345.
246
246
  * @property {string | null} [attributeSetIdentifier] - Identifier of the attribute set used by the form attached to the collection row, or null if not applicable. Example: "attributeSet1" or null.
247
+ * @property {string | null} [langCode] - Language code the row was stored under. Example: "en_US".
248
+ * @property {string | null} [formIdentifier] - Text identifier of the form the row was created from; returned by the create/update row endpoints. Example: "collection_form".
247
249
  * @property {string} total - Total count. Example: "1".
248
250
  * @description Represents a row in a collection, containing various properties such as identifiers, dates, form data, and an optional total value.
249
251
  */
@@ -256,6 +258,8 @@ interface ICollectionRow {
256
258
  entityType: string | null;
257
259
  entityId: number | null;
258
260
  attributeSetIdentifier?: string | null;
261
+ langCode?: string | null;
262
+ formIdentifier?: string | null;
259
263
  total?: string;
260
264
  }
261
265
  /**
@@ -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
  */