@constructor-io/constructorio-node 4.5.0 → 4.5.2
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/package.json +1 -1
- package/src/modules/browse.js +7 -0
- package/src/modules/search.js +8 -0
- package/src/types/browse.d.ts +2 -1
- package/src/types/index.d.ts +4 -9
- package/src/types/recommendations.d.ts +23 -0
- package/src/types/search.d.ts +4 -3
- package/src/types/tests/recommedations.test-d.ts +29 -0
- package/src/types/tracker.d.ts +2 -2
package/package.json
CHANGED
package/src/modules/browse.js
CHANGED
|
@@ -37,6 +37,7 @@ function createQueryParams(parameters, userParameters, options) {
|
|
|
37
37
|
hiddenFacets,
|
|
38
38
|
variationsMap,
|
|
39
39
|
preFilterExpression,
|
|
40
|
+
qsParam,
|
|
40
41
|
} = parameters;
|
|
41
42
|
|
|
42
43
|
// Pull page from parameters
|
|
@@ -105,6 +106,11 @@ function createQueryParams(parameters, userParameters, options) {
|
|
|
105
106
|
if (preFilterExpression) {
|
|
106
107
|
queryParams.pre_filter_expression = JSON.stringify(preFilterExpression);
|
|
107
108
|
}
|
|
109
|
+
|
|
110
|
+
// Pull qs param from parameters
|
|
111
|
+
if (qsParam) {
|
|
112
|
+
queryParams.qs = JSON.stringify(qsParam);
|
|
113
|
+
}
|
|
108
114
|
}
|
|
109
115
|
|
|
110
116
|
// Pull test cells from options
|
|
@@ -252,6 +258,7 @@ class Browse {
|
|
|
252
258
|
* @param {string[]} [parameters.hiddenFacets] - Hidden facet fields to return
|
|
253
259
|
* @param {object} [parameters.variationsMap] - The variations map object to aggregate variations. Please refer to https://docs.constructor.io/rest_api/variations_mapping for details
|
|
254
260
|
* @param {object} [parameters.preFilterExpression] - Faceting expression to scope search results. Please refer to https://docs.constructor.io/rest_api/collections/#add-items-dynamically for details
|
|
261
|
+
* @param {object} [parameters.qsParam] - Parameters listed above can be serialized into a JSON object and parsed through this parameter. Please refer to https://docs.constructor.io/rest_api/browse/queries for details
|
|
255
262
|
* @param {object} [userParameters] - Parameters relevant to the user request
|
|
256
263
|
* @param {number} [userParameters.sessionId] - Session ID, utilized to personalize results
|
|
257
264
|
* @param {number} [userParameters.clientId] - Client ID, utilized to personalize results
|
package/src/modules/search.js
CHANGED
|
@@ -61,6 +61,7 @@ function createSearchUrl(query, parameters, userParameters, options, isVoiceSear
|
|
|
61
61
|
hiddenFacets,
|
|
62
62
|
variationsMap,
|
|
63
63
|
preFilterExpression,
|
|
64
|
+
qsParam,
|
|
64
65
|
} = parameters;
|
|
65
66
|
|
|
66
67
|
// Pull page from parameters
|
|
@@ -130,6 +131,11 @@ function createSearchUrl(query, parameters, userParameters, options, isVoiceSear
|
|
|
130
131
|
if (preFilterExpression) {
|
|
131
132
|
queryParams.pre_filter_expression = JSON.stringify(preFilterExpression);
|
|
132
133
|
}
|
|
134
|
+
|
|
135
|
+
// Pull qs param from parameters
|
|
136
|
+
if (qsParam) {
|
|
137
|
+
queryParams.qs = JSON.stringify(qsParam);
|
|
138
|
+
}
|
|
133
139
|
}
|
|
134
140
|
|
|
135
141
|
queryParams._dt = Date.now();
|
|
@@ -172,6 +178,7 @@ class Search {
|
|
|
172
178
|
* @param {string[]} [parameters.hiddenFacets] - Hidden facet fields to return
|
|
173
179
|
* @param {object} [parameters.variationsMap] - The variations map object to aggregate variations. Please refer to https://docs.constructor.io/rest_api/variations_mapping for details
|
|
174
180
|
* @param {object} [parameters.preFilterExpression] - Faceting expression to scope search results. Please refer to https://docs.constructor.io/rest_api/collections/#add-items-dynamically for details
|
|
181
|
+
* @param {object} [parameters.qsParam] - Parameters listed above can be serialized into a JSON object and parsed through this parameter. Please refer to https://docs.constructor.io/rest_api/search/queries for details
|
|
175
182
|
* @param {object} [userParameters] - Parameters relevant to the user request
|
|
176
183
|
* @param {number} [userParameters.sessionId] - Session ID, utilized to personalize results
|
|
177
184
|
* @param {number} [userParameters.clientId] - Client ID, utilized to personalize results
|
|
@@ -273,6 +280,7 @@ class Search {
|
|
|
273
280
|
* @param {string[]} [parameters.hiddenFacets] - Hidden facet fields to return
|
|
274
281
|
* @param {object} [parameters.variationsMap] - The variations map object to aggregate variations. Please refer to https://docs.constructor.io/rest_api/variations_mapping for details
|
|
275
282
|
* @param {object} [parameters.preFilterExpression] - Faceting expression to scope search results. Please refer to https://docs.constructor.io/rest_api/collections/#add-items-dynamically for details
|
|
283
|
+
* @param {object} [parameters.qsParam] - Parameters listed above can be serialized into a JSON object and parsed through this parameter. Please refer to https://docs.constructor.io/rest_api/search/queries for details
|
|
276
284
|
* @param {object} [userParameters] - Parameters relevant to the user request
|
|
277
285
|
* @param {number} [userParameters.sessionId] - Session ID, utilized to personalize results
|
|
278
286
|
* @param {number} [userParameters.clientId] - Client ID, utilized to personalize results
|
package/src/types/browse.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ export interface BrowseParameters {
|
|
|
29
29
|
hiddenFields?: string[];
|
|
30
30
|
hiddenFacets?: string[];
|
|
31
31
|
variationsMap?: Record<string, any>;
|
|
32
|
+
qsParam?: Record<string, any>;
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
declare class Browse {
|
|
@@ -46,7 +47,7 @@ declare class Browse {
|
|
|
46
47
|
|
|
47
48
|
getBrowseResultsForItemIds(
|
|
48
49
|
itemIds: string[],
|
|
49
|
-
parameters?: BrowseParameters,
|
|
50
|
+
parameters?: Omit<BrowseParameters, 'preFilterExpression' | 'qsParam'>,
|
|
50
51
|
userParameters?: UserParameters,
|
|
51
52
|
networkParameters?: NetworkParameters
|
|
52
53
|
): Promise<GetBrowseResultsForItemIdsResponse>;
|
package/src/types/index.d.ts
CHANGED
|
@@ -22,8 +22,8 @@ export interface ConstructorClientOptions {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export interface UserParameters {
|
|
25
|
-
sessionId?:
|
|
26
|
-
clientId?:
|
|
25
|
+
sessionId?: number;
|
|
26
|
+
clientId?: string;
|
|
27
27
|
userId?: string;
|
|
28
28
|
segments?: string;
|
|
29
29
|
testCells?: Record<string, any>;
|
|
@@ -32,8 +32,8 @@ export interface UserParameters {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
export interface FmtOptions extends Record<string, any> {
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
groups_max_depth?: number;
|
|
36
|
+
groups_start?: 'current' | 'top';
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
export interface RequestFeature extends Record<string, any> {
|
|
@@ -80,11 +80,6 @@ export interface Feature extends Record<string, any> {
|
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
export interface FmtOption extends Record<string, any> {
|
|
84
|
-
groups_start: string;
|
|
85
|
-
groups_max_depth: number;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
83
|
export type Facet = RangeFacet | OptionFacet;
|
|
89
84
|
|
|
90
85
|
export interface BaseFacet extends Record<string, any> {
|
|
@@ -22,6 +22,10 @@ declare class Recommendations {
|
|
|
22
22
|
userParameters?: UserParameters,
|
|
23
23
|
networkParameters?: NetworkParameters
|
|
24
24
|
): Promise<RecommendationsResponse>;
|
|
25
|
+
|
|
26
|
+
getRecommendationPods(
|
|
27
|
+
networkParameters?: NetworkParameters
|
|
28
|
+
): Promise<RecommendationPodsResponse>;
|
|
25
29
|
}
|
|
26
30
|
|
|
27
31
|
/* Recommendations results returned from server */
|
|
@@ -62,3 +66,22 @@ export interface RecommendationsResultType extends Record<string, any> {
|
|
|
62
66
|
[key: string]: any;
|
|
63
67
|
};
|
|
64
68
|
}
|
|
69
|
+
|
|
70
|
+
export interface RecommendationPodsResponse extends Record<string, any> {
|
|
71
|
+
pods: RecommendationPod[];
|
|
72
|
+
total_count: number;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface PodStrategy extends Record<string, any> {
|
|
76
|
+
id: string;
|
|
77
|
+
display_name: string;
|
|
78
|
+
}
|
|
79
|
+
export interface RecommendationPod extends Record<string, any> {
|
|
80
|
+
strategy: PodStrategy;
|
|
81
|
+
id: string;
|
|
82
|
+
display_name: string;
|
|
83
|
+
name: string;
|
|
84
|
+
created_at: string;
|
|
85
|
+
updated_at: string;
|
|
86
|
+
metadata_json: Record<string, any>;
|
|
87
|
+
}
|
package/src/types/search.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
Facet,
|
|
4
4
|
Feature,
|
|
5
5
|
FilterExpression,
|
|
6
|
-
|
|
6
|
+
FmtOptions,
|
|
7
7
|
Group,
|
|
8
8
|
NetworkParameters,
|
|
9
9
|
RequestFeature,
|
|
@@ -22,11 +22,12 @@ export interface SearchParameters {
|
|
|
22
22
|
sortBy?: string;
|
|
23
23
|
sortOrder?: string;
|
|
24
24
|
section?: string;
|
|
25
|
-
fmtOptions?:
|
|
25
|
+
fmtOptions?: FmtOptions;
|
|
26
26
|
preFilterExpression?: FilterExpression;
|
|
27
27
|
hiddenFields?: string[];
|
|
28
28
|
hiddenFacets?: string[];
|
|
29
29
|
variationsMap?: Record<string, any>;
|
|
30
|
+
qsParam?: Record<string, any>;
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
declare class Search {
|
|
@@ -73,8 +74,8 @@ export interface SearchRequestType extends Record<string, any> {
|
|
|
73
74
|
section: string;
|
|
74
75
|
blacklist_rules: boolean;
|
|
75
76
|
term: string;
|
|
77
|
+
fmt_options: FmtOptions;
|
|
76
78
|
original_query?: string;
|
|
77
|
-
fmt_options: Partial<FmtOption>;
|
|
78
79
|
sort_by: string;
|
|
79
80
|
sort_order: string;
|
|
80
81
|
features: Partial<RequestFeature>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { expectAssignable } from 'tsd';
|
|
2
|
+
import { RecommendationPodsResponse } from '..';
|
|
2
3
|
import { RecommendationsResponse } from '../recommendations.d';
|
|
3
4
|
|
|
4
5
|
expectAssignable<RecommendationsResponse>({
|
|
@@ -43,3 +44,31 @@ expectAssignable<RecommendationsResponse>({
|
|
|
43
44
|
},
|
|
44
45
|
result_id: '618c2aa1-b851-451f-b228-61d02bf7e3c5',
|
|
45
46
|
});
|
|
47
|
+
|
|
48
|
+
expectAssignable<RecommendationPodsResponse>({
|
|
49
|
+
pods: [
|
|
50
|
+
{
|
|
51
|
+
strategy: {
|
|
52
|
+
id: 'recently_viewed_items', display_name: 'Recently Viewed',
|
|
53
|
+
},
|
|
54
|
+
id: 'recently-viewed',
|
|
55
|
+
display_name: 'Recently Viewed',
|
|
56
|
+
name: 'Recently viewed',
|
|
57
|
+
created_at: '2023-03-24T20:00:12',
|
|
58
|
+
updated_at: '2023-03-24T20:00:12',
|
|
59
|
+
metadata_json: {},
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
strategy: {
|
|
63
|
+
id: 'recently_viewed_items', display_name: 'Recently Viewed',
|
|
64
|
+
},
|
|
65
|
+
id: 'you-may-also-like',
|
|
66
|
+
display_name: 'You May Also Like',
|
|
67
|
+
name: 'You may also like',
|
|
68
|
+
created_at: '2023-03-23T15:25:59',
|
|
69
|
+
updated_at: '2023-03-23T15:32:48',
|
|
70
|
+
metadata_json: {},
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
total_count: 2,
|
|
74
|
+
});
|
package/src/types/tracker.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ import { ConstructorClientOptions, NetworkParameters } from '.';
|
|
|
4
4
|
export default Tracker;
|
|
5
5
|
|
|
6
6
|
export interface TrackerUserParameters {
|
|
7
|
-
sessionId:
|
|
8
|
-
clientId:
|
|
7
|
+
sessionId: number;
|
|
8
|
+
clientId: string;
|
|
9
9
|
userId?: string;
|
|
10
10
|
segments?: string;
|
|
11
11
|
testCells?: Record<string, any>;
|