@constructor-io/constructorio-node 4.3.0 → 4.4.0
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 +12 -4
- package/src/constructorio.js +1 -1
- package/src/modules/catalog.js +9 -9
- package/src/modules/quizzes.js +5 -4
- package/src/modules/tracker.js +22 -2
- package/src/types/autocomplete.d.ts +56 -0
- package/src/types/browse.d.ts +140 -0
- package/src/types/catalog.d.ts +535 -0
- package/src/types/constructorio.d.ts +34 -0
- package/src/types/index.d.ts +277 -0
- package/src/types/quizzes.d.ts +73 -0
- package/src/types/recommendations.d.ts +64 -0
- package/src/types/search.d.ts +98 -0
- package/src/types/tasks.d.ts +70 -0
- package/src/types/tests/autocomplete.test-d.ts +59 -0
- package/src/types/tests/browse.test-d.ts +120 -0
- package/src/types/tests/catalog.test-d.ts +109 -0
- package/src/types/tests/quizzes.test-d.ts +82 -0
- package/src/types/tests/recommedations.test-d.ts +45 -0
- package/src/types/tests/search.test-d.ts +124 -0
- package/src/types/tests/tasks.test-d.ts +40 -0
- package/src/types/tracker.d.ts +203 -0
package/package.json
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constructor-io/constructorio-node",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0",
|
|
4
4
|
"description": "Constructor.io Node.js client",
|
|
5
5
|
"main": "src/constructorio.js",
|
|
6
|
+
"types": "src/types/constructorio.d.ts",
|
|
6
7
|
"scripts": {
|
|
7
8
|
"version": "chmod +x ./scripts/verify-node-version.sh && ./scripts/verify-node-version.sh && npm run docs && git add ./docs/*",
|
|
8
9
|
"check-lisc": "license-checker --production --onlyAllow 'Apache-2.0;BSD-3-Clause;MIT'",
|
|
9
|
-
"lint": "eslint 'src/**/*.js' 'spec/**/*.js'",
|
|
10
|
+
"lint": "eslint 'src/**/*.js' 'spec/**/*.js' 'src/**/*.d.ts'",
|
|
10
11
|
"test:parallel": "mkdir -p test && cp -rf src/* test && mocha --parallel ./spec/*",
|
|
11
12
|
"test": "mkdir -p test && cp -rf src/* test && mocha ./spec/*",
|
|
13
|
+
"test:types": "tsd .",
|
|
12
14
|
"precoverage": "rm -rf ./coverage && rm -rf ./.nyc_output",
|
|
13
15
|
"coverage": "nyc --all --reporter=html npm run test:parallel",
|
|
14
16
|
"postcoverage": "open coverage/index.html && rm -rf test",
|
|
@@ -33,12 +35,14 @@
|
|
|
33
35
|
],
|
|
34
36
|
"devDependencies": {
|
|
35
37
|
"@cspell/eslint-plugin": "^6.8.2",
|
|
38
|
+
"@types/events": "^3.0.0",
|
|
39
|
+
"@typescript-eslint/eslint-plugin": "^5.46.1",
|
|
40
|
+
"@typescript-eslint/parser": "^5.46.1",
|
|
36
41
|
"chai": "^4.3.4",
|
|
37
42
|
"chai-as-promised": "^7.1.1",
|
|
38
43
|
"dotenv": "^8.6.0",
|
|
39
44
|
"eslint": "^8.2.0",
|
|
40
45
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
41
|
-
"eslint-plugin-import": "^2.24.2",
|
|
42
46
|
"husky": "^7.0.4",
|
|
43
47
|
"jsdoc": "^3.6.7",
|
|
44
48
|
"license-checker": "^25.0.1",
|
|
@@ -48,12 +52,16 @@
|
|
|
48
52
|
"nyc": "^15.1.0",
|
|
49
53
|
"sinon": "^7.5.0",
|
|
50
54
|
"sinon-chai": "^3.7.0",
|
|
55
|
+
"tsd": "^0.25.0",
|
|
51
56
|
"uuid": "^8.3.2"
|
|
52
57
|
},
|
|
53
58
|
"dependencies": {
|
|
54
59
|
"form-data": "^4.0.0",
|
|
55
60
|
"node-abort-controller": "^3.0.0",
|
|
56
|
-
"node-fetch": "^
|
|
61
|
+
"node-fetch": "^3.3.0",
|
|
57
62
|
"qs": "6.9.7"
|
|
63
|
+
},
|
|
64
|
+
"tsd": {
|
|
65
|
+
"directory": "src/types/tests"
|
|
58
66
|
}
|
|
59
67
|
}
|
package/src/constructorio.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable camelcase, no-unneeded-ternary, max-len */
|
|
2
|
-
const nodeFetch =
|
|
2
|
+
const nodeFetch = (...args) => import('node-fetch').then(({ default: fetch }) => fetch(...args));
|
|
3
3
|
|
|
4
4
|
// Modules
|
|
5
5
|
const Search = require('./modules/search');
|
package/src/modules/catalog.js
CHANGED
|
@@ -464,7 +464,6 @@ class Catalog {
|
|
|
464
464
|
signal,
|
|
465
465
|
}).then((response) => {
|
|
466
466
|
if (response.ok) {
|
|
467
|
-
|
|
468
467
|
return response.json();
|
|
469
468
|
}
|
|
470
469
|
|
|
@@ -802,6 +801,7 @@ class Catalog {
|
|
|
802
801
|
* @param {string} parameters.id - Item group ID
|
|
803
802
|
* @param {string} parameters.name - Item group name
|
|
804
803
|
* @param {string} [parameters.parent_id] - Item group parent ID
|
|
804
|
+
* @param {object} [parameters.data] - JSON object with custom metadata attached with the item group
|
|
805
805
|
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
806
806
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
807
807
|
* @returns {Promise}
|
|
@@ -1455,7 +1455,7 @@ class Catalog {
|
|
|
1455
1455
|
*
|
|
1456
1456
|
* @function addSynonymGroup
|
|
1457
1457
|
* @param {object} parameters - Additional parameters for synonym group details
|
|
1458
|
-
* @param {
|
|
1458
|
+
* @param {string[]} parameters.synonyms - Allows you to add synonyms to the newly created group
|
|
1459
1459
|
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
1460
1460
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
1461
1461
|
* @returns {Promise}
|
|
@@ -1503,7 +1503,7 @@ class Catalog {
|
|
|
1503
1503
|
* @function modifySynonymGroup
|
|
1504
1504
|
* @param {object} parameters - Additional parameters for synonym group details
|
|
1505
1505
|
* @param {number} parameters.id - Synonym group ID
|
|
1506
|
-
* @param {
|
|
1506
|
+
* @param {string[]} parameters.synonyms - Determines what phrases will be included in the final synonym group
|
|
1507
1507
|
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
1508
1508
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
1509
1509
|
* @returns {Promise}
|
|
@@ -1745,7 +1745,7 @@ class Catalog {
|
|
|
1745
1745
|
* @param {object[]} parameters.matches - List of match definitions
|
|
1746
1746
|
* @param {string} [parameters.start_time] - Time at which rule begins to apply (ISO8601 format preferred)
|
|
1747
1747
|
* @param {string} [parameters.end_time] - Time at which rule stops to apply (ISO8601 format preferred)
|
|
1748
|
-
* @param {
|
|
1748
|
+
* @param {string[]} [parameters.user_segments] - List of user segments
|
|
1749
1749
|
* @param {object} [parameters.metadata] - Object with arbitrary metadata
|
|
1750
1750
|
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
1751
1751
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
@@ -1808,7 +1808,7 @@ class Catalog {
|
|
|
1808
1808
|
* @param {object[]} parameters.matches - List of match definitions
|
|
1809
1809
|
* @param {string} [parameters.start_time] - Time at which rule begins to apply (ISO8601 format preferred)
|
|
1810
1810
|
* @param {string} [parameters.end_time] - Time at which rule stops to apply (ISO8601 format preferred)
|
|
1811
|
-
* @param {
|
|
1811
|
+
* @param {string[]} [parameters.user_segments] - List of user segments
|
|
1812
1812
|
* @param {object} [parameters.metadata] - Object with arbitrary metadata
|
|
1813
1813
|
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
1814
1814
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
@@ -1871,7 +1871,7 @@ class Catalog {
|
|
|
1871
1871
|
* @param {object[]} parameters.matches - List of match definitions
|
|
1872
1872
|
* @param {string} [parameters.start_time] - Time at which rule begins to apply (ISO8601 format preferred)
|
|
1873
1873
|
* @param {string} [parameters.end_time] - Time at which rule stops to apply (ISO8601 format preferred)
|
|
1874
|
-
* @param {
|
|
1874
|
+
* @param {string[]} [parameters.user_segments] - List of user segments
|
|
1875
1875
|
* @param {object} [parameters.metadata] - Object with arbitrary metadata
|
|
1876
1876
|
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
1877
1877
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
@@ -2400,7 +2400,7 @@ class Catalog {
|
|
|
2400
2400
|
* @param {string} [parameters.range_format] - Determine wether the range facet is configured to displayed as a slider (with min/max values) or as a list of buckets. Must be one of boundaries (for sliders) or options (for buckets).
|
|
2401
2401
|
* @param {string} [parameters.range_inclusive] - Used to create inclusive buckets. Must be one of above (options have no upper bound), below (no lower bound), or null (if range options should not be inclusive).
|
|
2402
2402
|
* @param {number} [parameters.bucket_size] - Specifies the size of generated buckets. Default is null. Either this or range_limits are required for facet type range, format options, and range_type static
|
|
2403
|
-
* @param {
|
|
2403
|
+
* @param {number[]} [parameters.range_limits] - Defines the cut-off points for generating static range buckets. Should be a list of sorted numbers (i.e. [10, 25, 40]). Default value is null.
|
|
2404
2404
|
* @param {string} [parameters.match_type] - Specifies the behavior of filters when multiple options of the same facet group are selected. Must be one of any, all, or none. Default value is any.
|
|
2405
2405
|
* @param {number} [parameters.position] - Slot facet groups to fixed positions. Default value is null.
|
|
2406
2406
|
* @param {boolean} [parameters.hidden] - Specifies whether the facet is hidden from users. Used for non-sensitive data that you don't want to show to end users. Default value is false.
|
|
@@ -2640,7 +2640,7 @@ class Catalog {
|
|
|
2640
2640
|
* @param {string} [parameters.range_format] - Determine wether the range facet is configured to displayed as a slider (with min/max values) or as a list of buckets. Must be one of boundaries (for sliders) or options (for buckets).
|
|
2641
2641
|
* @param {string} [parameters.range_inclusive] - Used to create inclusive buckets. Must be one of above (options have no upper bound), below (no lower bound), or null (if range options should not be inclusive).
|
|
2642
2642
|
* @param {number} [parameters.bucket_size] - Specifies the size of generated buckets. Default is null. Either this or range_limits are required for facet type range, format options, and range_type static
|
|
2643
|
-
* @param {
|
|
2643
|
+
* @param {number[]} [parameters.range_limits] - Defines the cut-off points for generating static range buckets. Should be a list of sorted numbers (i.e. [10, 25, 40]). Default value is null.
|
|
2644
2644
|
* @param {string} [parameters.match_type] - Specifies the behavior of filters when multiple options of the same facet group are selected. Must be one of any, all, or none. Default value is any.
|
|
2645
2645
|
* @param {number} [parameters.position] - Slot facet groups to fixed positions. Default value is null.
|
|
2646
2646
|
* @param {boolean} [parameters.hidden] - Specifies whether the facet is hidden from users. Used for non-sensitive data that you don't want to show to end users. Default value is false.
|
|
@@ -2712,7 +2712,7 @@ class Catalog {
|
|
|
2712
2712
|
* @param {string} [parameters.range_format] - Determine wether the range facet is configured to displayed as a slider (with min/max values) or as a list of buckets. Must be one of boundaries (for sliders) or options (for buckets).
|
|
2713
2713
|
* @param {string} [parameters.range_inclusive] - Used to create inclusive buckets. Must be one of above (options have no upper bound), below (no lower bound), or null (if range options should not be inclusive).
|
|
2714
2714
|
* @param {number} [parameters.bucket_size] - Specifies the size of generated buckets. Default is null. Either this or range_limits are required for facet type range, format options, and range_type static
|
|
2715
|
-
* @param {
|
|
2715
|
+
* @param {number[]} [parameters.range_limits] - Defines the cut-off points for generating static range buckets. Should be a list of sorted numbers (i.e. [10, 25, 40]). Default value is null.
|
|
2716
2716
|
* @param {string} [parameters.match_type] - Specifies the behavior of filters when multiple options of the same facet group are selected. Must be one of any, all, or none. Default value is any.
|
|
2717
2717
|
* @param {number} [parameters.position] - Slot facet groups to fixed positions. Default value is null.
|
|
2718
2718
|
* @param {boolean} [parameters.hidden] - Specifies whether the facet is hidden from users. Used for non-sensitive data that you don't want to show to end users. Default value is false.
|
package/src/modules/quizzes.js
CHANGED
|
@@ -111,7 +111,7 @@ class Quizzes {
|
|
|
111
111
|
* versionId: '123'
|
|
112
112
|
* });
|
|
113
113
|
*/
|
|
114
|
-
getQuizNextQuestion(
|
|
114
|
+
getQuizNextQuestion(id, parameters, userParameters = {}, networkParameters = {}) {
|
|
115
115
|
const headers = {};
|
|
116
116
|
let requestUrl;
|
|
117
117
|
const { fetch } = this.options;
|
|
@@ -119,7 +119,7 @@ class Quizzes {
|
|
|
119
119
|
const { signal } = controller;
|
|
120
120
|
|
|
121
121
|
try {
|
|
122
|
-
requestUrl = createQuizUrl(
|
|
122
|
+
requestUrl = createQuizUrl(id, parameters, userParameters, this.options, 'next');
|
|
123
123
|
} catch (e) {
|
|
124
124
|
return Promise.reject(e);
|
|
125
125
|
}
|
|
@@ -174,6 +174,7 @@ class Quizzes {
|
|
|
174
174
|
* @param {number} [userParameters.clientId] - Client ID, utilized to personalize results
|
|
175
175
|
* @param {string} [userParameters.userId] - User ID, utilized to personalize results
|
|
176
176
|
* @param {string} [userParameters.segments] - User segments
|
|
177
|
+
* @param {object} [userParameters.testCells] - User test cells
|
|
177
178
|
* @param {string} [userParameters.userIp] - Origin user IP, from client
|
|
178
179
|
* @param {string} [userParameters.userAgent] - Origin user agent, from client
|
|
179
180
|
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
@@ -187,7 +188,7 @@ class Quizzes {
|
|
|
187
188
|
* versionId: '123'
|
|
188
189
|
* });
|
|
189
190
|
*/
|
|
190
|
-
getQuizResults(
|
|
191
|
+
getQuizResults(id, parameters, userParameters = {}, networkParameters = {}) {
|
|
191
192
|
let requestUrl;
|
|
192
193
|
const headers = {};
|
|
193
194
|
const { fetch } = this.options;
|
|
@@ -195,7 +196,7 @@ class Quizzes {
|
|
|
195
196
|
const { signal } = controller;
|
|
196
197
|
|
|
197
198
|
try {
|
|
198
|
-
requestUrl = createQuizUrl(
|
|
199
|
+
requestUrl = createQuizUrl(id, parameters, userParameters, this.options, 'finalize');
|
|
199
200
|
} catch (e) {
|
|
200
201
|
return Promise.reject(e);
|
|
201
202
|
}
|
package/src/modules/tracker.js
CHANGED
|
@@ -622,6 +622,8 @@ class Tracker {
|
|
|
622
622
|
* @param {string} parameters.item_id - Product item unique identifier
|
|
623
623
|
* @param {string} [parameters.variation_id] - Product item variation unique identifier
|
|
624
624
|
* @param {string} [parameters.result_id] - Search result identifier (returned in response from Constructor)
|
|
625
|
+
* @param {string} [parameters.item_is_convertible] - Whether or not an item is available for a conversion
|
|
626
|
+
* @param {string} [parameters.section] - The section name for the item Ex. "Products"
|
|
625
627
|
* @param {object} userParameters - Parameters relevant to the user request
|
|
626
628
|
* @param {number} userParameters.sessionId - Session ID, utilized to personalize results
|
|
627
629
|
* @param {number} userParameters.clientId - Client ID, utilized to personalize results
|
|
@@ -661,7 +663,16 @@ class Tracker {
|
|
|
661
663
|
if (parameters && typeof parameters === 'object' && !Array.isArray(parameters)) {
|
|
662
664
|
const url = `${this.options.serviceUrl}/autocomplete/${helpers.encodeURIComponentRFC3986(helpers.trimNonBreakingSpaces(term))}/click_through?`;
|
|
663
665
|
const queryParams = {};
|
|
664
|
-
const {
|
|
666
|
+
const {
|
|
667
|
+
item_name,
|
|
668
|
+
name,
|
|
669
|
+
item_id,
|
|
670
|
+
customer_id,
|
|
671
|
+
variation_id,
|
|
672
|
+
result_id,
|
|
673
|
+
item_is_convertible,
|
|
674
|
+
section,
|
|
675
|
+
} = parameters;
|
|
665
676
|
|
|
666
677
|
// Ensure support for both item_name and name as parameters
|
|
667
678
|
if (item_name) {
|
|
@@ -685,6 +696,14 @@ class Tracker {
|
|
|
685
696
|
queryParams.result_id = result_id;
|
|
686
697
|
}
|
|
687
698
|
|
|
699
|
+
if (typeof item_is_convertible === 'boolean') {
|
|
700
|
+
queryParams.item_is_convertible = item_is_convertible;
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
if (section) {
|
|
704
|
+
queryParams.section = section;
|
|
705
|
+
}
|
|
706
|
+
|
|
688
707
|
const requestUrl = `${url}${applyParamsAsString(queryParams, userParameters, this.options)}`;
|
|
689
708
|
|
|
690
709
|
send.call(
|
|
@@ -931,6 +950,7 @@ class Tracker {
|
|
|
931
950
|
* @param {string} parameters.url - Current page URL
|
|
932
951
|
* @param {string} parameters.pod_id - Pod identifier
|
|
933
952
|
* @param {number} parameters.num_results_viewed - Number of results viewed
|
|
953
|
+
* @param {object[]} [parameters.items] - List of Product Item Objects
|
|
934
954
|
* @param {number} [parameters.result_count] - Total number of results
|
|
935
955
|
* @param {number} [parameters.result_page] - Page number of results
|
|
936
956
|
* @param {string} [parameters.result_id] - Recommendation result identifier (returned in response from Constructor)
|
|
@@ -1458,7 +1478,7 @@ class Tracker {
|
|
|
1458
1478
|
* @param {object} [userParameters] - Parameters relevant to the user request
|
|
1459
1479
|
* @param {number} userParameters.sessionId - Session ID, utilized to personalize results
|
|
1460
1480
|
* @param {number} userParameters.clientId - Client ID, utilized to personalize results
|
|
1461
|
-
* @param {string} userParameters.userId - User ID, utilized to personalize results
|
|
1481
|
+
* @param {string} [userParameters.userId] - User ID, utilized to personalize results
|
|
1462
1482
|
* @param {string} [userParameters.segments] - User segments
|
|
1463
1483
|
* @param {object} [userParameters.testCells] - User test cells
|
|
1464
1484
|
* @param {string} [userParameters.originReferrer] - Client page URL (including path)
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConstructorClientOptions,
|
|
3
|
+
NetworkParameters,
|
|
4
|
+
RequestFeature,
|
|
5
|
+
RequestFeatureVariant,
|
|
6
|
+
UserParameters,
|
|
7
|
+
} from '.';
|
|
8
|
+
|
|
9
|
+
export default Autocomplete;
|
|
10
|
+
|
|
11
|
+
export interface AutocompleteParameters {
|
|
12
|
+
numResults?: number;
|
|
13
|
+
filters?: Record<string, any>;
|
|
14
|
+
resultsPerSection?: Record<string, number>;
|
|
15
|
+
hiddenFields?: string[];
|
|
16
|
+
variationsMap?: Record<string, any>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare class Autocomplete {
|
|
20
|
+
constructor(options: ConstructorClientOptions);
|
|
21
|
+
|
|
22
|
+
options: ConstructorClientOptions;
|
|
23
|
+
|
|
24
|
+
getAutocompleteResults(
|
|
25
|
+
query: string,
|
|
26
|
+
parameters?: AutocompleteParameters,
|
|
27
|
+
userParameters?: UserParameters,
|
|
28
|
+
networkParameters?: NetworkParameters
|
|
29
|
+
): Promise<AutocompleteResponse>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/* Autocomplete results returned from server */
|
|
33
|
+
export interface AutocompleteResponse extends Record<string, any> {
|
|
34
|
+
request: Partial<AutocompleteRequestType>;
|
|
35
|
+
sections: Record<string, Section>;
|
|
36
|
+
result_id: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface AutocompleteRequestType extends Record<string, any> {
|
|
40
|
+
num_results: number;
|
|
41
|
+
term: string;
|
|
42
|
+
query: string;
|
|
43
|
+
features: Partial<RequestFeature>;
|
|
44
|
+
feature_variants: Partial<RequestFeatureVariant>;
|
|
45
|
+
searchandized_items: Record<string, any>;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export type Section = Partial<SectionItem>[];
|
|
49
|
+
|
|
50
|
+
export interface SectionItem extends Record<string, any> {
|
|
51
|
+
data: Record<string, any>;
|
|
52
|
+
is_slotted: boolean;
|
|
53
|
+
labels: Record<string, any>;
|
|
54
|
+
matched_terms: string[];
|
|
55
|
+
value: string;
|
|
56
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import {
|
|
2
|
+
NetworkParameters,
|
|
3
|
+
UserParameters,
|
|
4
|
+
Collection,
|
|
5
|
+
ConstructorClientOptions,
|
|
6
|
+
Facet,
|
|
7
|
+
Feature,
|
|
8
|
+
Group,
|
|
9
|
+
RequestFeature,
|
|
10
|
+
RequestFeatureVariant,
|
|
11
|
+
ResultSources,
|
|
12
|
+
SortOption,
|
|
13
|
+
FmtOptions,
|
|
14
|
+
} from '.';
|
|
15
|
+
|
|
16
|
+
export default Browse;
|
|
17
|
+
|
|
18
|
+
export interface BrowseParameters {
|
|
19
|
+
page?: number;
|
|
20
|
+
offset?: number;
|
|
21
|
+
resultsPerPage?: number;
|
|
22
|
+
filters?: Record<string, any>;
|
|
23
|
+
sortBy?: string;
|
|
24
|
+
sortOrder?: string;
|
|
25
|
+
section?: string;
|
|
26
|
+
fmtOptions?: FmtOptions;
|
|
27
|
+
hiddenFields?: string[];
|
|
28
|
+
hiddenFacets?: string[];
|
|
29
|
+
variationsMap?: Record<string, any>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
declare class Browse {
|
|
33
|
+
constructor(options: ConstructorClientOptions);
|
|
34
|
+
|
|
35
|
+
options: ConstructorClientOptions;
|
|
36
|
+
|
|
37
|
+
getBrowseResults(
|
|
38
|
+
filterName: string,
|
|
39
|
+
filterValue: string,
|
|
40
|
+
parameters?: BrowseParameters,
|
|
41
|
+
userParameters?: UserParameters,
|
|
42
|
+
networkParameters?: NetworkParameters
|
|
43
|
+
): Promise<GetBrowseResultsResponse>;
|
|
44
|
+
|
|
45
|
+
getBrowseResultsForItemIds(
|
|
46
|
+
itemIds: string[],
|
|
47
|
+
parameters?: BrowseParameters,
|
|
48
|
+
userParameters?: UserParameters,
|
|
49
|
+
networkParameters?: NetworkParameters
|
|
50
|
+
): Promise<GetBrowseResultsForItemIdsResponse>;
|
|
51
|
+
|
|
52
|
+
getBrowseGroups(
|
|
53
|
+
parameters?: Pick<BrowseParameters, 'filters' | 'section' | 'fmtOptions'>,
|
|
54
|
+
userParameters?: UserParameters,
|
|
55
|
+
networkParameters?: NetworkParameters
|
|
56
|
+
): Promise<GetBrowseGroupsResponse>;
|
|
57
|
+
|
|
58
|
+
getBrowseFacets(
|
|
59
|
+
parameters?: Pick<
|
|
60
|
+
BrowseParameters,
|
|
61
|
+
'page' | 'offset' | 'section' | 'fmtOptions' | 'resultsPerPage'
|
|
62
|
+
>,
|
|
63
|
+
userParameters?: UserParameters,
|
|
64
|
+
networkParameters?: NetworkParameters
|
|
65
|
+
): Promise<GetBrowseFacetsResponse>;
|
|
66
|
+
|
|
67
|
+
getBrowseFacetOptions(
|
|
68
|
+
facetName: string,
|
|
69
|
+
parameters?: Pick<BrowseParameters, 'section' | 'fmtOptions'>,
|
|
70
|
+
userParameters?: UserParameters,
|
|
71
|
+
networkParameters?: NetworkParameters
|
|
72
|
+
): Promise<GetBrowseFacetOptionsResponse>;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/* Browse results returned from server */
|
|
76
|
+
interface BrowseResponse<ResponseType> extends Record<string, any> {
|
|
77
|
+
request?: Partial<BrowseRequestType>;
|
|
78
|
+
response?: Partial<ResponseType>;
|
|
79
|
+
result_id?: string;
|
|
80
|
+
ad_based?: boolean;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export type GetBrowseResultsResponse =
|
|
84
|
+
BrowseResponse<GetBrowseResultsResponseData>;
|
|
85
|
+
export type GetBrowseResultsForItemIdsResponse =
|
|
86
|
+
BrowseResponse<GetBrowseResultsResponseData>;
|
|
87
|
+
export type GetBrowseGroupsResponse = BrowseResponse<
|
|
88
|
+
Pick<
|
|
89
|
+
GetBrowseResultsResponseData,
|
|
90
|
+
'result_sources' | 'groups' | 'refined_content'
|
|
91
|
+
>
|
|
92
|
+
>;
|
|
93
|
+
export type GetBrowseFacetsResponse = BrowseResponse<
|
|
94
|
+
Pick<GetBrowseResultsResponseData, 'facets' | 'total_num_results'>
|
|
95
|
+
>;
|
|
96
|
+
export type GetBrowseFacetOptionsResponse = BrowseResponse<
|
|
97
|
+
Pick<GetBrowseResultsResponseData, 'facets'>
|
|
98
|
+
>;
|
|
99
|
+
|
|
100
|
+
export interface GetBrowseResultsResponseData extends Record<string, any> {
|
|
101
|
+
result_sources: Partial<ResultSources>;
|
|
102
|
+
facets: Partial<Facet>[];
|
|
103
|
+
groups: Partial<Group>[];
|
|
104
|
+
results: Partial<BrowseResultData>[];
|
|
105
|
+
sort_options: Partial<SortOption>[];
|
|
106
|
+
refined_content: Record<string, any>[];
|
|
107
|
+
total_num_results: number;
|
|
108
|
+
features: Partial<Feature>[];
|
|
109
|
+
collection: Partial<Collection>;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface BrowseResultData extends Record<string, any> {
|
|
113
|
+
matched_terms: string[];
|
|
114
|
+
data: {
|
|
115
|
+
id: string;
|
|
116
|
+
[key: string]: any;
|
|
117
|
+
};
|
|
118
|
+
value: string;
|
|
119
|
+
is_slotted: false;
|
|
120
|
+
labels: Record<string, any>;
|
|
121
|
+
variations: Record<string, any>[];
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export interface BrowseRequestType extends Record<string, any> {
|
|
125
|
+
browse_filter_name: string;
|
|
126
|
+
browse_filter_value: string;
|
|
127
|
+
filter_match_types: Record<string, any>;
|
|
128
|
+
filters: Record<string, any>;
|
|
129
|
+
fmt_options: Record<string, any>;
|
|
130
|
+
num_results_per_page: number;
|
|
131
|
+
page: number;
|
|
132
|
+
section: string;
|
|
133
|
+
sort_by: string;
|
|
134
|
+
sort_order: string;
|
|
135
|
+
term: string;
|
|
136
|
+
query: string;
|
|
137
|
+
features: Partial<RequestFeature>;
|
|
138
|
+
feature_variants: Partial<RequestFeatureVariant>;
|
|
139
|
+
searchandized_items: Record<string, any>;
|
|
140
|
+
}
|