oneentry 1.0.149 → 1.0.151
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/changelog.md +453 -0
- package/dist/base/asyncModules.js +13 -0
- package/dist/base/stateModule.d.ts +1 -0
- package/dist/base/stateModule.js +3 -0
- package/dist/base/syncModules.d.ts +30 -1
- package/dist/base/syncModules.js +102 -30
- package/dist/base/utils.d.ts +4 -1
- package/dist/blocks/blocksApi.d.ts +124 -3
- package/dist/blocks/blocksApi.js +169 -4
- package/dist/blocks/blocksInterfaces.d.ts +177 -4
- package/dist/blocks/blocksSchemas.d.ts +4 -0
- package/dist/events/eventsApi.d.ts +42 -1
- package/dist/events/eventsApi.js +67 -0
- package/dist/events/eventsInterfaces.d.ts +79 -1
- package/dist/file-uploading/fileUploadingInterfaces.d.ts +2 -0
- package/dist/file-uploading/fileUploadingSchemas.d.ts +2 -0
- package/dist/file-uploading/fileUploadingSchemas.js +1 -0
- package/dist/filters/filtersApi.d.ts +31 -0
- package/dist/filters/filtersApi.js +40 -0
- package/dist/filters/filtersInterfaces.d.ts +56 -0
- package/dist/filters/filtersInterfaces.js +2 -0
- package/dist/filters/filtersSchemas.d.ts +32 -0
- package/dist/filters/filtersSchemas.js +29 -0
- package/dist/forms-data/formsDataInterfaces.d.ts +2 -2
- package/dist/forms-data/formsDataSchemas.d.ts +1 -1
- package/dist/forms-data/formsDataSchemas.js +1 -1
- package/dist/general-types/generalTypesSchemas.d.ts +16 -0
- package/dist/general-types/generalTypesSchemas.js +10 -1
- package/dist/index.d.ts +13 -0
- package/dist/index.js +10 -0
- package/dist/orders/ordersInterfaces.d.ts +51 -3
- package/dist/orders/ordersSchemas.d.ts +127 -31
- package/dist/orders/ordersSchemas.js +53 -30
- package/dist/pages/pagesInterfaces.d.ts +14 -8
- package/dist/pages/pagesSchemas.d.ts +24 -9
- package/dist/pages/pagesSchemas.js +4 -3
- package/dist/products/productsApi.d.ts +19 -1
- package/dist/products/productsApi.js +42 -8
- package/dist/products/productsInterfaces.d.ts +35 -6
- package/dist/products/productsSchemas.d.ts +4 -0
- package/dist/products/productsSchemas.js +1 -0
- package/dist/subscriptions/subscriptionsApi.d.ts +69 -0
- package/dist/subscriptions/subscriptionsApi.js +102 -0
- package/dist/subscriptions/subscriptionsInterfaces.d.ts +90 -0
- package/dist/subscriptions/subscriptionsInterfaces.js +2 -0
- package/dist/subscriptions/subscriptionsSchemas.d.ts +20 -0
- package/dist/subscriptions/subscriptionsSchemas.js +23 -0
- package/dist/user-activity/userActivityApi.d.ts +30 -0
- package/dist/user-activity/userActivityApi.js +42 -0
- package/dist/user-activity/userActivityInterfaces.d.ts +42 -0
- package/dist/user-activity/userActivityInterfaces.js +2 -0
- package/dist/users/usersApi.d.ts +79 -1
- package/dist/users/usersApi.js +110 -0
- package/dist/users/usersInterfaces.d.ts +155 -1
- package/dist/users/usersSchemas.d.ts +40 -0
- package/dist/users/usersSchemas.js +34 -1
- package/package.json +3 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UpdateOrderResponseSchema = exports.CreateOrderResponseSchema = exports.
|
|
3
|
+
exports.UpdateOrderResponseSchema = exports.CreateOrderResponseSchema = exports.OrdersStorageResponseSchema = exports.OrderStorageSchema = exports.OrdersResponseSchema = exports.OrderEntitySchema = exports.OrderDiscountConfigSchema = exports.OrderItemSchema = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Validation schemas for Orders module
|
|
6
6
|
* @description Zod schemas for validating orders-related API responses
|
|
@@ -18,6 +18,40 @@ exports.OrderItemSchema = zod_1.z.object({
|
|
|
18
18
|
total: zod_1.z.number(),
|
|
19
19
|
attributes: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
|
|
20
20
|
});
|
|
21
|
+
/**
|
|
22
|
+
* Order discount config schema
|
|
23
|
+
* @description Resolved discount configuration returned with an order or order preview.
|
|
24
|
+
*/
|
|
25
|
+
exports.OrderDiscountConfigSchema = zod_1.z.object({
|
|
26
|
+
bonus: zod_1.z
|
|
27
|
+
.object({
|
|
28
|
+
availableBalance: zod_1.z.number(),
|
|
29
|
+
bonusApplied: zod_1.z.number(),
|
|
30
|
+
maxBonusDiscount: zod_1.z.number(),
|
|
31
|
+
minBonusAmount: zod_1.z.number().nullable(),
|
|
32
|
+
minOrderAmountForBonus: zod_1.z.number().nullable(),
|
|
33
|
+
})
|
|
34
|
+
.nullable()
|
|
35
|
+
.optional(),
|
|
36
|
+
coupon: zod_1.z.unknown().nullable(),
|
|
37
|
+
orderDiscounts: zod_1.z.array(zod_1.z.unknown()),
|
|
38
|
+
productDiscounts: zod_1.z.array(zod_1.z.unknown()),
|
|
39
|
+
settings: zod_1.z.object({
|
|
40
|
+
allowGiftStacking: zod_1.z.boolean(),
|
|
41
|
+
allowStacking: zod_1.z.boolean(),
|
|
42
|
+
maxDiscountValue: zod_1.z.number().nullable(),
|
|
43
|
+
giftRefundPolicy: zod_1.z.string().optional(),
|
|
44
|
+
maxBonusPaymentPercent: zod_1.z.number().nullable().optional(),
|
|
45
|
+
minBonusAmount: zod_1.z.number().nullable().optional(),
|
|
46
|
+
minOrderAmountForBonus: zod_1.z.number().nullable().optional(),
|
|
47
|
+
}),
|
|
48
|
+
additionalDiscountsMarkers: zod_1.z.array(zod_1.z.string()).optional(),
|
|
49
|
+
bonusApplied: zod_1.z.number().optional(),
|
|
50
|
+
excludedGiftProductIds: zod_1.z.array(zod_1.z.string()).optional(),
|
|
51
|
+
totalDue: zod_1.z.number().optional(),
|
|
52
|
+
totalRaw: zod_1.z.number().optional(),
|
|
53
|
+
totalSumWithDiscount: zod_1.z.number().optional(),
|
|
54
|
+
});
|
|
21
55
|
/**
|
|
22
56
|
* Order entity schema
|
|
23
57
|
* @description Order entity schema for validating orders-related API responses
|
|
@@ -31,13 +65,31 @@ exports.OrderEntitySchema = zod_1.z.object({
|
|
|
31
65
|
formData: zod_1.z.union([zod_1.z.array(zod_1.z.any()), zod_1.z.record(zod_1.z.string(), zod_1.z.any())]),
|
|
32
66
|
attributeSetIdentifier: zod_1.z.string().optional(),
|
|
33
67
|
totalSum: zod_1.z.string(),
|
|
68
|
+
totalSumRaw: zod_1.z.string().optional(),
|
|
34
69
|
currency: zod_1.z.string(),
|
|
35
70
|
paymentAccountIdentifier: zod_1.z.string().optional(),
|
|
36
71
|
paymentAccountLocalizeInfos: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
|
|
37
72
|
paymentUrl: zod_1.z.string().nullable(),
|
|
38
73
|
products: zod_1.z.array(zod_1.z.any()),
|
|
39
74
|
isCompleted: zod_1.z.boolean().nullable(),
|
|
75
|
+
isPartial: zod_1.z.boolean().nullable().optional(),
|
|
76
|
+
paymentStrategy: zod_1.z.string().optional(),
|
|
40
77
|
statusLocalizeInfos: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
|
|
78
|
+
discountConfig: exports.OrderDiscountConfigSchema.nullable().optional(),
|
|
79
|
+
split: zod_1.z
|
|
80
|
+
.object({
|
|
81
|
+
completed: zod_1.z.boolean(),
|
|
82
|
+
partial: zod_1.z.boolean(),
|
|
83
|
+
stages: zod_1.z.array(zod_1.z.object({
|
|
84
|
+
marker: zod_1.z.string(),
|
|
85
|
+
sessionId: zod_1.z.string().nullable(),
|
|
86
|
+
productId: zod_1.z.number(),
|
|
87
|
+
title: zod_1.z.string(),
|
|
88
|
+
value: zod_1.z.number(),
|
|
89
|
+
status: zod_1.z.string(),
|
|
90
|
+
})),
|
|
91
|
+
})
|
|
92
|
+
.optional(),
|
|
41
93
|
});
|
|
42
94
|
/**
|
|
43
95
|
* Orders list response schema
|
|
@@ -65,35 +117,6 @@ exports.OrderStorageSchema = zod_1.z.object({
|
|
|
65
117
|
* @returns Orders storage list response schema
|
|
66
118
|
*/
|
|
67
119
|
exports.OrdersStorageResponseSchema = zod_1.z.array(exports.OrderStorageSchema);
|
|
68
|
-
/**
|
|
69
|
-
* Order discount config schema
|
|
70
|
-
* @description Resolved discount configuration returned with an order or order preview.
|
|
71
|
-
*/
|
|
72
|
-
exports.OrderDiscountConfigSchema = zod_1.z.object({
|
|
73
|
-
bonus: zod_1.z
|
|
74
|
-
.object({
|
|
75
|
-
availableBalance: zod_1.z.number(),
|
|
76
|
-
bonusApplied: zod_1.z.number(),
|
|
77
|
-
maxBonusDiscount: zod_1.z.number(),
|
|
78
|
-
minBonusAmount: zod_1.z.number().nullable(),
|
|
79
|
-
minOrderAmountForBonus: zod_1.z.number().nullable(),
|
|
80
|
-
})
|
|
81
|
-
.nullable(),
|
|
82
|
-
coupon: zod_1.z.unknown().nullable(),
|
|
83
|
-
orderDiscounts: zod_1.z.array(zod_1.z.unknown()),
|
|
84
|
-
productDiscounts: zod_1.z.array(zod_1.z.unknown()),
|
|
85
|
-
settings: zod_1.z.object({
|
|
86
|
-
allowGiftStacking: zod_1.z.boolean(),
|
|
87
|
-
allowStacking: zod_1.z.boolean(),
|
|
88
|
-
maxDiscountValue: zod_1.z.number().nullable(),
|
|
89
|
-
}),
|
|
90
|
-
additionalDiscountsMarkers: zod_1.z.array(zod_1.z.string()).optional(),
|
|
91
|
-
bonusApplied: zod_1.z.number().optional(),
|
|
92
|
-
excludedGiftProductIds: zod_1.z.array(zod_1.z.string()).optional(),
|
|
93
|
-
totalDue: zod_1.z.number().optional(),
|
|
94
|
-
totalRaw: zod_1.z.number().optional(),
|
|
95
|
-
totalSumWithDiscount: zod_1.z.number().optional(),
|
|
96
|
-
});
|
|
97
120
|
/**
|
|
98
121
|
* Create order response schema
|
|
99
122
|
* API returns a simplified order object after creation
|
|
@@ -169,7 +169,7 @@ interface IPositionForm {
|
|
|
169
169
|
* @property {number} version - The version number of the object. Example: 0.
|
|
170
170
|
* @property {number} position - The position of the object. Example: 1.
|
|
171
171
|
* @property {string} identifier - The textual identifier for the record field. Example: "product_block".
|
|
172
|
-
* @property {BlockType} type -
|
|
172
|
+
* @property {BlockType} type - Block type. Example: "product".
|
|
173
173
|
* @property {string | null} templateIdentifier - User id of the linked template. Example: null.
|
|
174
174
|
* @property {boolean} isVisible - A sign of page visibility. Example: true.
|
|
175
175
|
* @property {boolean} isSync - Indication of page indexing. Example: false.
|
|
@@ -202,6 +202,12 @@ interface IPositionBlock {
|
|
|
202
202
|
countElementsPerRow?: number;
|
|
203
203
|
quantity?: number;
|
|
204
204
|
}
|
|
205
|
+
/**
|
|
206
|
+
* PageType
|
|
207
|
+
* @type {PageType}
|
|
208
|
+
* @description This type defines the possible values for page types used in the system. It is a page-specific subset of {@link BlockType}.
|
|
209
|
+
*/
|
|
210
|
+
type PageType = 'catalog_page' | 'common_page' | 'error_page' | 'external_page';
|
|
205
211
|
/**
|
|
206
212
|
* @interface IPagesEntity
|
|
207
213
|
* @property {number} id - The identifier of the object. Example: 8.
|
|
@@ -217,7 +223,7 @@ interface IPositionBlock {
|
|
|
217
223
|
"plainContent": ""
|
|
218
224
|
}
|
|
219
225
|
* @property {boolean} isVisible - A sign of page visibility. Example: true.
|
|
220
|
-
* @property {
|
|
226
|
+
* @property {PageType} type - Page type. Example: "common_page".
|
|
221
227
|
* @property {string | null} templateIdentifier - User id of the linked template. Example: "template".
|
|
222
228
|
* @property {string | null} attributeSetIdentifier - Set of attributes id. Example: "page".
|
|
223
229
|
* @property {IAttributeValues} attributeValues - Map of attribute values keyed by marker; empty object when none.
|
|
@@ -240,7 +246,7 @@ interface IPositionBlock {
|
|
|
240
246
|
"productsPerRow": 1
|
|
241
247
|
}
|
|
242
248
|
* @property {number} [products] - The number of products linked to the page. Example: 0.
|
|
243
|
-
* @property {
|
|
249
|
+
* @property {number} [childrenCount] - Children count. Example: 1.
|
|
244
250
|
* @property {IBlockEntity[] | string[]} [blocks] - blocks.
|
|
245
251
|
* @example
|
|
246
252
|
{
|
|
@@ -257,7 +263,7 @@ interface IPositionBlock {
|
|
|
257
263
|
* @property {Array<IFormConfig>} [moduleFormConfigs] - Module form configurations linked to the page.
|
|
258
264
|
* @property {IRating} [rating] - Rating data.
|
|
259
265
|
* @property {string} [total] - Total number of products linked to the page. Example: "10".
|
|
260
|
-
* @property {string} [categoryPath] - Category path string. Example: "catalog".
|
|
266
|
+
* @property {string | null} [categoryPath] - Category path string; null for nested pages that have no own category path. Example: "catalog".
|
|
261
267
|
* @description This interface defines the structure of a page entity, including its identifiers, attributes, and hierarchical relationships.
|
|
262
268
|
*/
|
|
263
269
|
interface IPagesEntity {
|
|
@@ -267,7 +273,7 @@ interface IPagesEntity {
|
|
|
267
273
|
depth: number;
|
|
268
274
|
localizeInfos: ILocalizeInfo;
|
|
269
275
|
isVisible: boolean;
|
|
270
|
-
type:
|
|
276
|
+
type: PageType;
|
|
271
277
|
templateIdentifier: string | null;
|
|
272
278
|
attributeSetIdentifier: string | null;
|
|
273
279
|
attributeValues: IAttributeValues;
|
|
@@ -279,8 +285,8 @@ interface IPagesEntity {
|
|
|
279
285
|
position?: number;
|
|
280
286
|
config?: Record<string, number>;
|
|
281
287
|
products?: number;
|
|
282
|
-
childrenCount?:
|
|
288
|
+
childrenCount?: number;
|
|
283
289
|
total?: string;
|
|
284
|
-
categoryPath?: string;
|
|
290
|
+
categoryPath?: string | null;
|
|
285
291
|
}
|
|
286
|
-
export type { IPageConfig, IPagesApi, IPagesEntity, IPositionBlock, IPositionForm, };
|
|
292
|
+
export type { IPageConfig, IPagesApi, IPagesEntity, IPositionBlock, IPositionForm, PageType, };
|
|
@@ -14,7 +14,12 @@ export declare const PageEntitySchema: z.ZodObject<{
|
|
|
14
14
|
depth: z.ZodNumber;
|
|
15
15
|
localizeInfos: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
16
16
|
isVisible: z.ZodBoolean;
|
|
17
|
-
type: z.
|
|
17
|
+
type: z.ZodEnum<{
|
|
18
|
+
error_page: "error_page";
|
|
19
|
+
catalog_page: "catalog_page";
|
|
20
|
+
common_page: "common_page";
|
|
21
|
+
external_page: "external_page";
|
|
22
|
+
}>;
|
|
18
23
|
templateIdentifier: z.ZodNullable<z.ZodString>;
|
|
19
24
|
attributeSetIdentifier: z.ZodNullable<z.ZodString>;
|
|
20
25
|
attributeValues: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
@@ -26,9 +31,9 @@ export declare const PageEntitySchema: z.ZodObject<{
|
|
|
26
31
|
position: z.ZodOptional<z.ZodNumber>;
|
|
27
32
|
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
28
33
|
products: z.ZodOptional<z.ZodNumber>;
|
|
29
|
-
childrenCount: z.ZodOptional<z.
|
|
34
|
+
childrenCount: z.ZodOptional<z.ZodNumber>;
|
|
30
35
|
total: z.ZodOptional<z.ZodString>;
|
|
31
|
-
categoryPath: z.ZodOptional<z.ZodString
|
|
36
|
+
categoryPath: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
32
37
|
}, z.core.$strip>;
|
|
33
38
|
/**
|
|
34
39
|
* Pages response schema (array of pages)
|
|
@@ -40,7 +45,12 @@ export declare const PagesResponseSchema: z.ZodArray<z.ZodObject<{
|
|
|
40
45
|
depth: z.ZodNumber;
|
|
41
46
|
localizeInfos: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
42
47
|
isVisible: z.ZodBoolean;
|
|
43
|
-
type: z.
|
|
48
|
+
type: z.ZodEnum<{
|
|
49
|
+
error_page: "error_page";
|
|
50
|
+
catalog_page: "catalog_page";
|
|
51
|
+
common_page: "common_page";
|
|
52
|
+
external_page: "external_page";
|
|
53
|
+
}>;
|
|
44
54
|
templateIdentifier: z.ZodNullable<z.ZodString>;
|
|
45
55
|
attributeSetIdentifier: z.ZodNullable<z.ZodString>;
|
|
46
56
|
attributeValues: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
@@ -52,9 +62,9 @@ export declare const PagesResponseSchema: z.ZodArray<z.ZodObject<{
|
|
|
52
62
|
position: z.ZodOptional<z.ZodNumber>;
|
|
53
63
|
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
54
64
|
products: z.ZodOptional<z.ZodNumber>;
|
|
55
|
-
childrenCount: z.ZodOptional<z.
|
|
65
|
+
childrenCount: z.ZodOptional<z.ZodNumber>;
|
|
56
66
|
total: z.ZodOptional<z.ZodString>;
|
|
57
|
-
categoryPath: z.ZodOptional<z.ZodString
|
|
67
|
+
categoryPath: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
58
68
|
}, z.core.$strip>>;
|
|
59
69
|
/**
|
|
60
70
|
* Single page response schema
|
|
@@ -66,7 +76,12 @@ export declare const SinglePageSchema: z.ZodObject<{
|
|
|
66
76
|
depth: z.ZodNumber;
|
|
67
77
|
localizeInfos: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
68
78
|
isVisible: z.ZodBoolean;
|
|
69
|
-
type: z.
|
|
79
|
+
type: z.ZodEnum<{
|
|
80
|
+
error_page: "error_page";
|
|
81
|
+
catalog_page: "catalog_page";
|
|
82
|
+
common_page: "common_page";
|
|
83
|
+
external_page: "external_page";
|
|
84
|
+
}>;
|
|
70
85
|
templateIdentifier: z.ZodNullable<z.ZodString>;
|
|
71
86
|
attributeSetIdentifier: z.ZodNullable<z.ZodString>;
|
|
72
87
|
attributeValues: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
@@ -78,9 +93,9 @@ export declare const SinglePageSchema: z.ZodObject<{
|
|
|
78
93
|
position: z.ZodOptional<z.ZodNumber>;
|
|
79
94
|
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
80
95
|
products: z.ZodOptional<z.ZodNumber>;
|
|
81
|
-
childrenCount: z.ZodOptional<z.
|
|
96
|
+
childrenCount: z.ZodOptional<z.ZodNumber>;
|
|
82
97
|
total: z.ZodOptional<z.ZodString>;
|
|
83
|
-
categoryPath: z.ZodOptional<z.ZodString
|
|
98
|
+
categoryPath: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
84
99
|
}, z.core.$strip>;
|
|
85
100
|
/**
|
|
86
101
|
* Page config schema
|
|
@@ -17,7 +17,8 @@ exports.PageEntitySchema = zod_1.z.object({
|
|
|
17
17
|
depth: zod_1.z.number(),
|
|
18
18
|
localizeInfos: zod_1.z.record(zod_1.z.string(), zod_1.z.any()),
|
|
19
19
|
isVisible: zod_1.z.boolean(),
|
|
20
|
-
|
|
20
|
+
// Must stay in sync with PageType in src/pages/pagesInterfaces.ts
|
|
21
|
+
type: zod_1.z.enum(['catalog_page', 'common_page', 'error_page', 'external_page']),
|
|
21
22
|
templateIdentifier: zod_1.z.string().nullable(),
|
|
22
23
|
attributeSetIdentifier: zod_1.z.string().nullable(),
|
|
23
24
|
attributeValues: zod_1.z.record(zod_1.z.string(), zod_1.z.any()),
|
|
@@ -29,9 +30,9 @@ exports.PageEntitySchema = zod_1.z.object({
|
|
|
29
30
|
position: zod_1.z.number().optional(),
|
|
30
31
|
config: zod_1.z.record(zod_1.z.string(), zod_1.z.number()).optional(),
|
|
31
32
|
products: zod_1.z.number().optional(),
|
|
32
|
-
childrenCount: zod_1.z.
|
|
33
|
+
childrenCount: zod_1.z.number().optional(),
|
|
33
34
|
total: zod_1.z.string().optional(),
|
|
34
|
-
categoryPath: zod_1.z.string().optional(),
|
|
35
|
+
categoryPath: zod_1.z.string().nullable().optional(),
|
|
35
36
|
});
|
|
36
37
|
/**
|
|
37
38
|
* Pages response schema (array of pages)
|
|
@@ -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,14 +367,22 @@ 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
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
370
|
+
if (searchProducts.length === 0)
|
|
371
|
+
return searchProducts;
|
|
372
|
+
const ids = searchProducts.map((product) => product.id);
|
|
373
|
+
// One /ids request instead of one getProductById per result.
|
|
374
|
+
// limit is set to the number of ids so the default 30 does not truncate.
|
|
375
|
+
const products = await this.getProductsByIds(ids.join(','), langCode, {
|
|
376
|
+
limit: ids.length,
|
|
377
|
+
});
|
|
378
|
+
if (!Array.isArray(products))
|
|
379
|
+
return products;
|
|
380
|
+
// /ids re-sorts by id (DESC) by default, so restore the original
|
|
381
|
+
// search relevance order from the quick search response.
|
|
382
|
+
const byId = new Map(products.map((product) => [product.id, product]));
|
|
383
|
+
return ids
|
|
384
|
+
.map((id) => byId.get(id))
|
|
385
|
+
.filter((product) => product !== undefined);
|
|
378
386
|
}
|
|
379
387
|
return searchProducts;
|
|
380
388
|
}
|
|
@@ -455,6 +463,32 @@ class ProductsApi extends asyncModules_1.default {
|
|
|
455
463
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
456
464
|
* @description This method calculates and returns the number of products available on a given catalog page, identified by its URL, with optional filtering.
|
|
457
465
|
*/
|
|
466
|
+
/**
|
|
467
|
+
* Semantic (vector) search for products.
|
|
468
|
+
* @handleName getProductsByVectorSearch
|
|
469
|
+
* @param {IVectorSearchProducts} body - Vector search body. Example: `{ queryText: "red running shoes" }`.
|
|
470
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
471
|
+
* @param {number} [offset] - Parameter for pagination. Default: 0.
|
|
472
|
+
* @param {number} [limit] - Parameter for pagination. Default: 30.
|
|
473
|
+
* @returns {Promise<IProductsEntity[] | IError>} Array with ProductEntity objects.
|
|
474
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
475
|
+
* @description This method performs a semantic (vector) search for products.
|
|
476
|
+
*/
|
|
477
|
+
async getProductsByVectorSearch(body, langCode = this.state.lang, offset = 0, limit = 30) {
|
|
478
|
+
const query = {
|
|
479
|
+
langCode,
|
|
480
|
+
offset,
|
|
481
|
+
limit,
|
|
482
|
+
};
|
|
483
|
+
const result = await this._fetchPost(`/vector/search?` + this._queryParamsToString(query), body);
|
|
484
|
+
return this._dataPostProcess(result, langCode);
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Get products by page url.
|
|
488
|
+
* @param {string} url - Page url.
|
|
489
|
+
* @param {any[]} body - Request body.
|
|
490
|
+
* @returns {IProductsEntity[] | IError} Returns an array of products or an error object.
|
|
491
|
+
*/
|
|
458
492
|
async getProductsCountByPageUrl(url,
|
|
459
493
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
460
494
|
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
|
|
@@ -420,12 +432,12 @@ interface IProductPageRef {
|
|
|
420
432
|
* @property {number | null} price - The value of the product page price taken from the index. Example: 150.00.
|
|
421
433
|
* @property {object} additional - Additional value from the index.
|
|
422
434
|
* @example
|
|
423
|
-
|
|
424
|
-
prices: {
|
|
425
|
-
min: 5
|
|
426
|
-
max: 150
|
|
435
|
+
{
|
|
436
|
+
"prices": {
|
|
437
|
+
"min": 5,
|
|
438
|
+
"max": 150
|
|
427
439
|
}
|
|
428
|
-
}
|
|
440
|
+
}
|
|
429
441
|
* @property {string | null} sku - Product SKU (Stock Keeping Unit), may be null. Example: "SKU_12345".
|
|
430
442
|
* @property {boolean} isSync - Indication of page indexing. Example: true.
|
|
431
443
|
* @property {IAttributeValues} attributeValues - Array of attribute values from the index, represented.
|
|
@@ -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
|
-
|
|
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
|
+
}
|