@constructor-io/constructorio-node 4.2.1 → 4.3.1
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/.DS_Store +0 -0
- package/src/constructorio.js +2 -1
- package/src/modules/autocomplete.js +1 -2
- package/src/modules/browse.js +5 -6
- package/src/modules/catalog.js +62 -64
- package/src/modules/quizzes.js +7 -7
- package/src/modules/recommendations.js +2 -3
- package/src/modules/search.js +1 -2
- package/src/modules/tasks.js +2 -3
- package/src/modules/tracker.js +49 -13
- 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/src/modules/catalog.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/* eslint-disable camelcase */
|
|
2
2
|
/* eslint-disable object-curly-newline, no-underscore-dangle, max-len */
|
|
3
3
|
const qs = require('qs');
|
|
4
|
-
const nodeFetch = require('node-fetch').default;
|
|
5
4
|
const { AbortController } = require('node-abort-controller');
|
|
6
5
|
const FormData = require('form-data');
|
|
7
6
|
const fs = require('fs');
|
|
@@ -193,7 +192,7 @@ class Catalog {
|
|
|
193
192
|
*/
|
|
194
193
|
createOrReplaceItems(parameters = {}, networkParameters = {}) {
|
|
195
194
|
let requestUrl;
|
|
196
|
-
const fetch =
|
|
195
|
+
const { fetch } = this.options;
|
|
197
196
|
const controller = new AbortController();
|
|
198
197
|
const { signal } = controller;
|
|
199
198
|
const { items, section, force, notificationEmail } = parameters;
|
|
@@ -275,7 +274,7 @@ class Catalog {
|
|
|
275
274
|
*/
|
|
276
275
|
updateItems(parameters = {}, networkParameters = {}) {
|
|
277
276
|
let requestUrl;
|
|
278
|
-
const fetch =
|
|
277
|
+
const { fetch } = this.options;
|
|
279
278
|
const controller = new AbortController();
|
|
280
279
|
const { signal } = controller;
|
|
281
280
|
const { items, section, force, notificationEmail } = parameters;
|
|
@@ -347,7 +346,7 @@ class Catalog {
|
|
|
347
346
|
*/
|
|
348
347
|
deleteItems(parameters = {}, networkParameters = {}) {
|
|
349
348
|
let requestUrl;
|
|
350
|
-
const fetch =
|
|
349
|
+
const { fetch } = this.options;
|
|
351
350
|
const controller = new AbortController();
|
|
352
351
|
const { signal } = controller;
|
|
353
352
|
const { items, section, force, notificationEmail } = parameters;
|
|
@@ -425,7 +424,7 @@ class Catalog {
|
|
|
425
424
|
*/
|
|
426
425
|
retrieveItems(parameters = {}, networkParameters = {}) {
|
|
427
426
|
let requestUrl;
|
|
428
|
-
const fetch =
|
|
427
|
+
const { fetch } = this.options;
|
|
429
428
|
const controller = new AbortController();
|
|
430
429
|
const { signal } = controller;
|
|
431
430
|
const { ids, section, numResultsPerPage, page } = parameters;
|
|
@@ -465,7 +464,6 @@ class Catalog {
|
|
|
465
464
|
signal,
|
|
466
465
|
}).then((response) => {
|
|
467
466
|
if (response.ok) {
|
|
468
|
-
|
|
469
467
|
return response.json();
|
|
470
468
|
}
|
|
471
469
|
|
|
@@ -507,7 +505,7 @@ class Catalog {
|
|
|
507
505
|
*/
|
|
508
506
|
createOrReplaceVariations(parameters = {}, networkParameters = {}) {
|
|
509
507
|
let requestUrl;
|
|
510
|
-
const fetch =
|
|
508
|
+
const { fetch } = this.options;
|
|
511
509
|
const controller = new AbortController();
|
|
512
510
|
const { signal } = controller;
|
|
513
511
|
const { section, force, notificationEmail, variations } = parameters;
|
|
@@ -590,7 +588,7 @@ class Catalog {
|
|
|
590
588
|
*/
|
|
591
589
|
updateVariations(parameters = {}, networkParameters = {}) {
|
|
592
590
|
let requestUrl;
|
|
593
|
-
const fetch =
|
|
591
|
+
const { fetch } = this.options;
|
|
594
592
|
const controller = new AbortController();
|
|
595
593
|
const { signal } = controller;
|
|
596
594
|
const { section, force, notificationEmail, variations } = parameters;
|
|
@@ -663,7 +661,7 @@ class Catalog {
|
|
|
663
661
|
*/
|
|
664
662
|
deleteVariations(parameters = {}, networkParameters = {}) {
|
|
665
663
|
let requestUrl;
|
|
666
|
-
const fetch =
|
|
664
|
+
const { fetch } = this.options;
|
|
667
665
|
const controller = new AbortController();
|
|
668
666
|
const { signal } = controller;
|
|
669
667
|
const { section, force, notificationEmail, variations } = parameters;
|
|
@@ -743,7 +741,7 @@ class Catalog {
|
|
|
743
741
|
retrieveVariations(parameters = {}, networkParameters = {}) {
|
|
744
742
|
let queryParams = {};
|
|
745
743
|
let requestUrl;
|
|
746
|
-
const fetch =
|
|
744
|
+
const { fetch } = this.options;
|
|
747
745
|
const controller = new AbortController();
|
|
748
746
|
const { signal } = controller;
|
|
749
747
|
const { ids, itemId, section, numResultsPerPage, page } = parameters;
|
|
@@ -803,6 +801,7 @@ class Catalog {
|
|
|
803
801
|
* @param {string} parameters.id - Item group ID
|
|
804
802
|
* @param {string} parameters.name - Item group name
|
|
805
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
|
|
806
805
|
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
807
806
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
808
807
|
* @returns {Promise}
|
|
@@ -816,7 +815,7 @@ class Catalog {
|
|
|
816
815
|
*/
|
|
817
816
|
addItemGroup(parameters = {}, networkParameters = {}) {
|
|
818
817
|
let requestUrl;
|
|
819
|
-
const fetch =
|
|
818
|
+
const { fetch } = this.options;
|
|
820
819
|
const controller = new AbortController();
|
|
821
820
|
const { signal } = controller;
|
|
822
821
|
const { id, ...rest } = parameters;
|
|
@@ -874,7 +873,7 @@ class Catalog {
|
|
|
874
873
|
*/
|
|
875
874
|
addItemGroups(parameters = {}, networkParameters = {}) {
|
|
876
875
|
let requestUrl;
|
|
877
|
-
const fetch =
|
|
876
|
+
const { fetch } = this.options;
|
|
878
877
|
const controller = new AbortController();
|
|
879
878
|
const { signal } = controller;
|
|
880
879
|
|
|
@@ -921,7 +920,7 @@ class Catalog {
|
|
|
921
920
|
*/
|
|
922
921
|
getItemGroup(parameters = {}, networkParameters = {}) {
|
|
923
922
|
let requestUrl;
|
|
924
|
-
const fetch =
|
|
923
|
+
const { fetch } = this.options;
|
|
925
924
|
const controller = new AbortController();
|
|
926
925
|
const { signal } = controller;
|
|
927
926
|
|
|
@@ -963,7 +962,7 @@ class Catalog {
|
|
|
963
962
|
*/
|
|
964
963
|
getItemGroups(networkParameters = {}) {
|
|
965
964
|
let requestUrl;
|
|
966
|
-
const fetch =
|
|
965
|
+
const { fetch } = this.options;
|
|
967
966
|
const controller = new AbortController();
|
|
968
967
|
const { signal } = controller;
|
|
969
968
|
|
|
@@ -1019,7 +1018,7 @@ class Catalog {
|
|
|
1019
1018
|
*/
|
|
1020
1019
|
addOrUpdateItemGroups(parameters = {}, networkParameters = {}) {
|
|
1021
1020
|
let requestUrl;
|
|
1022
|
-
const fetch =
|
|
1021
|
+
const { fetch } = this.options;
|
|
1023
1022
|
const controller = new AbortController();
|
|
1024
1023
|
const { signal } = controller;
|
|
1025
1024
|
|
|
@@ -1074,7 +1073,7 @@ class Catalog {
|
|
|
1074
1073
|
*/
|
|
1075
1074
|
modifyItemGroup(parameters = {}, networkParameters = {}) {
|
|
1076
1075
|
let requestUrl;
|
|
1077
|
-
const fetch =
|
|
1076
|
+
const { fetch } = this.options;
|
|
1078
1077
|
const controller = new AbortController();
|
|
1079
1078
|
const { signal } = controller;
|
|
1080
1079
|
const { id, ...rest } = parameters;
|
|
@@ -1118,7 +1117,7 @@ class Catalog {
|
|
|
1118
1117
|
*/
|
|
1119
1118
|
removeItemGroups(networkParameters = {}) {
|
|
1120
1119
|
let requestUrl;
|
|
1121
|
-
const fetch =
|
|
1120
|
+
const { fetch } = this.options;
|
|
1122
1121
|
const controller = new AbortController();
|
|
1123
1122
|
const { signal } = controller;
|
|
1124
1123
|
|
|
@@ -1166,7 +1165,7 @@ class Catalog {
|
|
|
1166
1165
|
*/
|
|
1167
1166
|
addOneWaySynonym(parameters = {}, networkParameters = {}) {
|
|
1168
1167
|
let requestUrl;
|
|
1169
|
-
const fetch =
|
|
1168
|
+
const { fetch } = this.options;
|
|
1170
1169
|
const controller = new AbortController();
|
|
1171
1170
|
const { signal } = controller;
|
|
1172
1171
|
const { phrase, ...rest } = parameters;
|
|
@@ -1220,7 +1219,7 @@ class Catalog {
|
|
|
1220
1219
|
*/
|
|
1221
1220
|
modifyOneWaySynonym(parameters = {}, networkParameters = {}) {
|
|
1222
1221
|
let requestUrl;
|
|
1223
|
-
const fetch =
|
|
1222
|
+
const { fetch } = this.options;
|
|
1224
1223
|
const controller = new AbortController();
|
|
1225
1224
|
const { signal } = controller;
|
|
1226
1225
|
const { phrase, ...rest } = parameters;
|
|
@@ -1270,7 +1269,7 @@ class Catalog {
|
|
|
1270
1269
|
const { phrase } = parameters;
|
|
1271
1270
|
const queryParams = {};
|
|
1272
1271
|
let requestUrl;
|
|
1273
|
-
const fetch =
|
|
1272
|
+
const { fetch } = this.options;
|
|
1274
1273
|
const controller = new AbortController();
|
|
1275
1274
|
const { signal } = controller;
|
|
1276
1275
|
|
|
@@ -1319,7 +1318,7 @@ class Catalog {
|
|
|
1319
1318
|
getOneWaySynonyms(parameters = {}, networkParameters = {}) {
|
|
1320
1319
|
const queryParams = {};
|
|
1321
1320
|
let requestUrl;
|
|
1322
|
-
const fetch =
|
|
1321
|
+
const { fetch } = this.options;
|
|
1323
1322
|
const controller = new AbortController();
|
|
1324
1323
|
const { signal } = controller;
|
|
1325
1324
|
|
|
@@ -1380,7 +1379,7 @@ class Catalog {
|
|
|
1380
1379
|
removeOneWaySynonym(parameters = {}, networkParameters = {}) {
|
|
1381
1380
|
const { phrase } = parameters;
|
|
1382
1381
|
let requestUrl;
|
|
1383
|
-
const fetch =
|
|
1382
|
+
const { fetch } = this.options;
|
|
1384
1383
|
const controller = new AbortController();
|
|
1385
1384
|
const { signal } = controller;
|
|
1386
1385
|
|
|
@@ -1422,7 +1421,7 @@ class Catalog {
|
|
|
1422
1421
|
*/
|
|
1423
1422
|
removeOneWaySynonyms(networkParameters = {}) {
|
|
1424
1423
|
let requestUrl;
|
|
1425
|
-
const fetch =
|
|
1424
|
+
const { fetch } = this.options;
|
|
1426
1425
|
const controller = new AbortController();
|
|
1427
1426
|
const { signal } = controller;
|
|
1428
1427
|
|
|
@@ -1456,7 +1455,7 @@ class Catalog {
|
|
|
1456
1455
|
*
|
|
1457
1456
|
* @function addSynonymGroup
|
|
1458
1457
|
* @param {object} parameters - Additional parameters for synonym group details
|
|
1459
|
-
* @param {
|
|
1458
|
+
* @param {string[]} parameters.synonyms - Allows you to add synonyms to the newly created group
|
|
1460
1459
|
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
1461
1460
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
1462
1461
|
* @returns {Promise}
|
|
@@ -1468,7 +1467,7 @@ class Catalog {
|
|
|
1468
1467
|
*/
|
|
1469
1468
|
addSynonymGroup(parameters = {}, networkParameters = {}) {
|
|
1470
1469
|
let requestUrl;
|
|
1471
|
-
const fetch =
|
|
1470
|
+
const { fetch } = this.options;
|
|
1472
1471
|
const controller = new AbortController();
|
|
1473
1472
|
const { signal } = controller;
|
|
1474
1473
|
|
|
@@ -1504,7 +1503,7 @@ class Catalog {
|
|
|
1504
1503
|
* @function modifySynonymGroup
|
|
1505
1504
|
* @param {object} parameters - Additional parameters for synonym group details
|
|
1506
1505
|
* @param {number} parameters.id - Synonym group ID
|
|
1507
|
-
* @param {
|
|
1506
|
+
* @param {string[]} parameters.synonyms - Determines what phrases will be included in the final synonym group
|
|
1508
1507
|
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
1509
1508
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
1510
1509
|
* @returns {Promise}
|
|
@@ -1517,7 +1516,7 @@ class Catalog {
|
|
|
1517
1516
|
*/
|
|
1518
1517
|
modifySynonymGroup(parameters = {}, networkParameters = {}) {
|
|
1519
1518
|
let requestUrl;
|
|
1520
|
-
const fetch =
|
|
1519
|
+
const { fetch } = this.options;
|
|
1521
1520
|
const controller = new AbortController();
|
|
1522
1521
|
const { signal } = controller;
|
|
1523
1522
|
const { id, ...rest } = parameters;
|
|
@@ -1565,7 +1564,7 @@ class Catalog {
|
|
|
1565
1564
|
*/
|
|
1566
1565
|
getSynonymGroup(parameters = {}, networkParameters = {}) {
|
|
1567
1566
|
let requestUrl;
|
|
1568
|
-
const fetch =
|
|
1567
|
+
const { fetch } = this.options;
|
|
1569
1568
|
const controller = new AbortController();
|
|
1570
1569
|
const { signal } = controller;
|
|
1571
1570
|
|
|
@@ -1614,7 +1613,7 @@ class Catalog {
|
|
|
1614
1613
|
const queryParams = {};
|
|
1615
1614
|
const { phrase } = parameters;
|
|
1616
1615
|
let requestUrl;
|
|
1617
|
-
const fetch =
|
|
1616
|
+
const { fetch } = this.options;
|
|
1618
1617
|
const controller = new AbortController();
|
|
1619
1618
|
const { signal } = controller;
|
|
1620
1619
|
|
|
@@ -1671,7 +1670,7 @@ class Catalog {
|
|
|
1671
1670
|
*/
|
|
1672
1671
|
removeSynonymGroup(parameters = {}, networkParameters = {}) {
|
|
1673
1672
|
let requestUrl;
|
|
1674
|
-
const fetch =
|
|
1673
|
+
const { fetch } = this.options;
|
|
1675
1674
|
const controller = new AbortController();
|
|
1676
1675
|
const { signal } = controller;
|
|
1677
1676
|
const { id } = parameters;
|
|
@@ -1711,7 +1710,7 @@ class Catalog {
|
|
|
1711
1710
|
*/
|
|
1712
1711
|
removeSynonymGroups(networkParameters = {}) {
|
|
1713
1712
|
let requestUrl;
|
|
1714
|
-
const fetch =
|
|
1713
|
+
const { fetch } = this.options;
|
|
1715
1714
|
const controller = new AbortController();
|
|
1716
1715
|
const { signal } = controller;
|
|
1717
1716
|
|
|
@@ -1746,7 +1745,7 @@ class Catalog {
|
|
|
1746
1745
|
* @param {object[]} parameters.matches - List of match definitions
|
|
1747
1746
|
* @param {string} [parameters.start_time] - Time at which rule begins to apply (ISO8601 format preferred)
|
|
1748
1747
|
* @param {string} [parameters.end_time] - Time at which rule stops to apply (ISO8601 format preferred)
|
|
1749
|
-
* @param {
|
|
1748
|
+
* @param {string[]} [parameters.user_segments] - List of user segments
|
|
1750
1749
|
* @param {object} [parameters.metadata] - Object with arbitrary metadata
|
|
1751
1750
|
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
1752
1751
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
@@ -1769,7 +1768,7 @@ class Catalog {
|
|
|
1769
1768
|
*/
|
|
1770
1769
|
addRedirectRule(parameters = {}, networkParameters = {}) {
|
|
1771
1770
|
let requestUrl;
|
|
1772
|
-
const fetch =
|
|
1771
|
+
const { fetch } = this.options;
|
|
1773
1772
|
const controller = new AbortController();
|
|
1774
1773
|
const { signal } = controller;
|
|
1775
1774
|
|
|
@@ -1809,7 +1808,7 @@ class Catalog {
|
|
|
1809
1808
|
* @param {object[]} parameters.matches - List of match definitions
|
|
1810
1809
|
* @param {string} [parameters.start_time] - Time at which rule begins to apply (ISO8601 format preferred)
|
|
1811
1810
|
* @param {string} [parameters.end_time] - Time at which rule stops to apply (ISO8601 format preferred)
|
|
1812
|
-
* @param {
|
|
1811
|
+
* @param {string[]} [parameters.user_segments] - List of user segments
|
|
1813
1812
|
* @param {object} [parameters.metadata] - Object with arbitrary metadata
|
|
1814
1813
|
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
1815
1814
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
@@ -1831,7 +1830,7 @@ class Catalog {
|
|
|
1831
1830
|
*/
|
|
1832
1831
|
updateRedirectRule(parameters = {}, networkParameters = {}) {
|
|
1833
1832
|
let requestUrl;
|
|
1834
|
-
const fetch =
|
|
1833
|
+
const { fetch } = this.options;
|
|
1835
1834
|
const controller = new AbortController();
|
|
1836
1835
|
const { signal } = controller;
|
|
1837
1836
|
const { id, ...rest } = parameters;
|
|
@@ -1872,7 +1871,7 @@ class Catalog {
|
|
|
1872
1871
|
* @param {object[]} parameters.matches - List of match definitions
|
|
1873
1872
|
* @param {string} [parameters.start_time] - Time at which rule begins to apply (ISO8601 format preferred)
|
|
1874
1873
|
* @param {string} [parameters.end_time] - Time at which rule stops to apply (ISO8601 format preferred)
|
|
1875
|
-
* @param {
|
|
1874
|
+
* @param {string[]} [parameters.user_segments] - List of user segments
|
|
1876
1875
|
* @param {object} [parameters.metadata] - Object with arbitrary metadata
|
|
1877
1876
|
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
1878
1877
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
@@ -1891,7 +1890,7 @@ class Catalog {
|
|
|
1891
1890
|
*/
|
|
1892
1891
|
modifyRedirectRule(parameters = {}, networkParameters = {}) {
|
|
1893
1892
|
let requestUrl;
|
|
1894
|
-
const fetch =
|
|
1893
|
+
const { fetch } = this.options;
|
|
1895
1894
|
const controller = new AbortController();
|
|
1896
1895
|
const { signal } = controller;
|
|
1897
1896
|
const { id, ...rest } = parameters;
|
|
@@ -1939,7 +1938,7 @@ class Catalog {
|
|
|
1939
1938
|
*/
|
|
1940
1939
|
getRedirectRule(parameters = {}, networkParameters = {}) {
|
|
1941
1940
|
let requestUrl;
|
|
1942
|
-
const fetch =
|
|
1941
|
+
const { fetch } = this.options;
|
|
1943
1942
|
const controller = new AbortController();
|
|
1944
1943
|
const { signal } = controller;
|
|
1945
1944
|
|
|
@@ -1989,7 +1988,7 @@ class Catalog {
|
|
|
1989
1988
|
getRedirectRules(parameters = {}, networkParameters = {}) {
|
|
1990
1989
|
const queryParams = {};
|
|
1991
1990
|
let requestUrl;
|
|
1992
|
-
const fetch =
|
|
1991
|
+
const { fetch } = this.options;
|
|
1993
1992
|
const controller = new AbortController();
|
|
1994
1993
|
const { signal } = controller;
|
|
1995
1994
|
|
|
@@ -2056,7 +2055,7 @@ class Catalog {
|
|
|
2056
2055
|
*/
|
|
2057
2056
|
removeRedirectRule(parameters = {}, networkParameters = {}) {
|
|
2058
2057
|
let requestUrl;
|
|
2059
|
-
const fetch =
|
|
2058
|
+
const { fetch } = this.options;
|
|
2060
2059
|
const controller = new AbortController();
|
|
2061
2060
|
const { signal } = controller;
|
|
2062
2061
|
|
|
@@ -2108,7 +2107,7 @@ class Catalog {
|
|
|
2108
2107
|
*/
|
|
2109
2108
|
async replaceCatalog(parameters = {}, networkParameters = {}) {
|
|
2110
2109
|
try {
|
|
2111
|
-
const fetch =
|
|
2110
|
+
const { fetch } = this.options;
|
|
2112
2111
|
const controller = new AbortController();
|
|
2113
2112
|
const { signal } = controller;
|
|
2114
2113
|
const { queryParams, formData } = await createQueryParamsAndFormData(parameters);
|
|
@@ -2160,7 +2159,7 @@ class Catalog {
|
|
|
2160
2159
|
*/
|
|
2161
2160
|
async updateCatalog(parameters = {}, networkParameters = {}) {
|
|
2162
2161
|
try {
|
|
2163
|
-
const fetch =
|
|
2162
|
+
const { fetch } = this.options;
|
|
2164
2163
|
const controller = new AbortController();
|
|
2165
2164
|
const { signal } = controller;
|
|
2166
2165
|
const { queryParams, formData } = await createQueryParamsAndFormData(parameters);
|
|
@@ -2212,7 +2211,7 @@ class Catalog {
|
|
|
2212
2211
|
*/
|
|
2213
2212
|
async patchCatalog(parameters = {}, networkParameters = {}) {
|
|
2214
2213
|
try {
|
|
2215
|
-
const fetch =
|
|
2214
|
+
const { fetch } = this.options;
|
|
2216
2215
|
const controller = new AbortController();
|
|
2217
2216
|
const { signal } = controller;
|
|
2218
2217
|
const { queryParams, formData } = await createQueryParamsAndFormData(parameters);
|
|
@@ -2260,7 +2259,7 @@ class Catalog {
|
|
|
2260
2259
|
*/
|
|
2261
2260
|
async replaceCatalogUsingTarArchive(parameters = {}, networkParameters = {}) {
|
|
2262
2261
|
try {
|
|
2263
|
-
const fetch =
|
|
2262
|
+
const { fetch } = this.options;
|
|
2264
2263
|
const apiKey = this.options && this.options.apiKey;
|
|
2265
2264
|
const controller = new AbortController();
|
|
2266
2265
|
const { signal } = controller;
|
|
@@ -2309,7 +2308,7 @@ class Catalog {
|
|
|
2309
2308
|
*/
|
|
2310
2309
|
async updateCatalogUsingTarArchive(parameters = {}, networkParameters = {}) {
|
|
2311
2310
|
try {
|
|
2312
|
-
const fetch =
|
|
2311
|
+
const { fetch } = this.options;
|
|
2313
2312
|
const apiKey = this.options && this.options.apiKey;
|
|
2314
2313
|
const controller = new AbortController();
|
|
2315
2314
|
const { signal } = controller;
|
|
@@ -2359,7 +2358,7 @@ class Catalog {
|
|
|
2359
2358
|
*/
|
|
2360
2359
|
async patchCatalogUsingTarArchive(parameters = {}, networkParameters = {}) {
|
|
2361
2360
|
try {
|
|
2362
|
-
const fetch =
|
|
2361
|
+
const { fetch } = this.options;
|
|
2363
2362
|
const apiKey = this.options && this.options.apiKey;
|
|
2364
2363
|
const controller = new AbortController();
|
|
2365
2364
|
const { signal } = controller;
|
|
@@ -2401,7 +2400,7 @@ class Catalog {
|
|
|
2401
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).
|
|
2402
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).
|
|
2403
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
|
|
2404
|
-
* @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.
|
|
2405
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.
|
|
2406
2405
|
* @param {number} [parameters.position] - Slot facet groups to fixed positions. Default value is null.
|
|
2407
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.
|
|
@@ -2425,7 +2424,7 @@ class Catalog {
|
|
|
2425
2424
|
*/
|
|
2426
2425
|
addFacetConfiguration(parameters = {}, networkParameters = {}) {
|
|
2427
2426
|
let requestUrl;
|
|
2428
|
-
const fetch =
|
|
2427
|
+
const { fetch } = this.options;
|
|
2429
2428
|
const controller = new AbortController();
|
|
2430
2429
|
const { signal } = controller;
|
|
2431
2430
|
const { section, ...rest } = parameters;
|
|
@@ -2441,7 +2440,6 @@ class Catalog {
|
|
|
2441
2440
|
|
|
2442
2441
|
// Handle network timeout if specified
|
|
2443
2442
|
helpers.applyNetworkTimeout(this.options, networkParameters, controller);
|
|
2444
|
-
|
|
2445
2443
|
return fetch(requestUrl, {
|
|
2446
2444
|
method: 'POST',
|
|
2447
2445
|
body: JSON.stringify(rest),
|
|
@@ -2479,7 +2477,7 @@ class Catalog {
|
|
|
2479
2477
|
*/
|
|
2480
2478
|
getFacetConfigurations(parameters = {}, networkParameters = {}) {
|
|
2481
2479
|
let requestUrl;
|
|
2482
|
-
const fetch =
|
|
2480
|
+
const { fetch } = this.options;
|
|
2483
2481
|
const controller = new AbortController();
|
|
2484
2482
|
const { signal } = controller;
|
|
2485
2483
|
const additionalQueryParams = {
|
|
@@ -2529,7 +2527,7 @@ class Catalog {
|
|
|
2529
2527
|
*/
|
|
2530
2528
|
getFacetConfiguration(parameters = {}, networkParameters = {}) {
|
|
2531
2529
|
let requestUrl;
|
|
2532
|
-
const fetch =
|
|
2530
|
+
const { fetch } = this.options;
|
|
2533
2531
|
const controller = new AbortController();
|
|
2534
2532
|
const { signal } = controller;
|
|
2535
2533
|
const { section, name } = parameters;
|
|
@@ -2592,7 +2590,7 @@ class Catalog {
|
|
|
2592
2590
|
*/
|
|
2593
2591
|
modifyFacetConfigurations(parameters = {}, networkParameters = {}) {
|
|
2594
2592
|
let requestUrl;
|
|
2595
|
-
const fetch =
|
|
2593
|
+
const { fetch } = this.options;
|
|
2596
2594
|
const controller = new AbortController();
|
|
2597
2595
|
const { signal } = controller;
|
|
2598
2596
|
const { section, facetConfigurations } = parameters;
|
|
@@ -2642,7 +2640,7 @@ class Catalog {
|
|
|
2642
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).
|
|
2643
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).
|
|
2644
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
|
|
2645
|
-
* @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.
|
|
2646
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.
|
|
2647
2645
|
* @param {number} [parameters.position] - Slot facet groups to fixed positions. Default value is null.
|
|
2648
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.
|
|
@@ -2666,7 +2664,7 @@ class Catalog {
|
|
|
2666
2664
|
*/
|
|
2667
2665
|
replaceFacetConfiguration(parameters = {}, networkParameters = {}) {
|
|
2668
2666
|
let requestUrl;
|
|
2669
|
-
const fetch =
|
|
2667
|
+
const { fetch } = this.options;
|
|
2670
2668
|
const controller = new AbortController();
|
|
2671
2669
|
const { signal } = controller;
|
|
2672
2670
|
const { section, name, ...rest } = parameters;
|
|
@@ -2714,7 +2712,7 @@ class Catalog {
|
|
|
2714
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).
|
|
2715
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).
|
|
2716
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
|
|
2717
|
-
* @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.
|
|
2718
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.
|
|
2719
2717
|
* @param {number} [parameters.position] - Slot facet groups to fixed positions. Default value is null.
|
|
2720
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.
|
|
@@ -2738,7 +2736,7 @@ class Catalog {
|
|
|
2738
2736
|
*/
|
|
2739
2737
|
modifyFacetConfiguration(parameters = {}, networkParameters = {}) {
|
|
2740
2738
|
let requestUrl;
|
|
2741
|
-
const fetch =
|
|
2739
|
+
const { fetch } = this.options;
|
|
2742
2740
|
const controller = new AbortController();
|
|
2743
2741
|
const { signal } = controller;
|
|
2744
2742
|
const { section, name, ...rest } = parameters;
|
|
@@ -2792,7 +2790,7 @@ class Catalog {
|
|
|
2792
2790
|
*/
|
|
2793
2791
|
removeFacetConfiguration(parameters = {}, networkParameters = {}) {
|
|
2794
2792
|
let requestUrl;
|
|
2795
|
-
const fetch =
|
|
2793
|
+
const { fetch } = this.options;
|
|
2796
2794
|
const controller = new AbortController();
|
|
2797
2795
|
const { signal } = controller;
|
|
2798
2796
|
const { section, name } = parameters;
|
|
@@ -2850,7 +2848,7 @@ class Catalog {
|
|
|
2850
2848
|
*/
|
|
2851
2849
|
addFacetOptionConfiguration(parameters = {}, networkParameters = {}) {
|
|
2852
2850
|
let requestUrl;
|
|
2853
|
-
const fetch =
|
|
2851
|
+
const { fetch } = this.options;
|
|
2854
2852
|
const controller = new AbortController();
|
|
2855
2853
|
const { signal } = controller;
|
|
2856
2854
|
const { facetGroupName, section, ...rest } = parameters;
|
|
@@ -2915,7 +2913,7 @@ class Catalog {
|
|
|
2915
2913
|
*/
|
|
2916
2914
|
addOrModifyFacetOptionConfigurations(parameters = {}, networkParameters = {}) {
|
|
2917
2915
|
let requestUrl;
|
|
2918
|
-
const fetch =
|
|
2916
|
+
const { fetch } = this.options;
|
|
2919
2917
|
const controller = new AbortController();
|
|
2920
2918
|
const { signal } = controller;
|
|
2921
2919
|
const { facetGroupName, section, facetOptionConfigurations } = parameters;
|
|
@@ -2971,7 +2969,7 @@ class Catalog {
|
|
|
2971
2969
|
*/
|
|
2972
2970
|
getFacetOptionConfigurations(parameters = {}, networkParameters = {}) {
|
|
2973
2971
|
let requestUrl;
|
|
2974
|
-
const fetch =
|
|
2972
|
+
const { fetch } = this.options;
|
|
2975
2973
|
const controller = new AbortController();
|
|
2976
2974
|
const { signal } = controller;
|
|
2977
2975
|
const { facetGroupName, section } = parameters;
|
|
@@ -3024,7 +3022,7 @@ class Catalog {
|
|
|
3024
3022
|
*/
|
|
3025
3023
|
getFacetOptionConfiguration(parameters = {}, networkParameters = {}) {
|
|
3026
3024
|
let requestUrl;
|
|
3027
|
-
const fetch =
|
|
3025
|
+
const { fetch } = this.options;
|
|
3028
3026
|
const controller = new AbortController();
|
|
3029
3027
|
const { signal } = controller;
|
|
3030
3028
|
const { facetGroupName, value, section } = parameters;
|
|
@@ -3083,7 +3081,7 @@ class Catalog {
|
|
|
3083
3081
|
*/
|
|
3084
3082
|
replaceFacetOptionConfiguration(parameters = {}, networkParameters = {}) {
|
|
3085
3083
|
let requestUrl;
|
|
3086
|
-
const fetch =
|
|
3084
|
+
const { fetch } = this.options;
|
|
3087
3085
|
const controller = new AbortController();
|
|
3088
3086
|
const { signal } = controller;
|
|
3089
3087
|
const { facetGroupName, section, value, ...rest } = parameters;
|
|
@@ -3143,7 +3141,7 @@ class Catalog {
|
|
|
3143
3141
|
*/
|
|
3144
3142
|
modifyFacetOptionConfiguration(parameters = {}, networkParameters = {}) {
|
|
3145
3143
|
let requestUrl;
|
|
3146
|
-
const fetch =
|
|
3144
|
+
const { fetch } = this.options;
|
|
3147
3145
|
const controller = new AbortController();
|
|
3148
3146
|
const { signal } = controller;
|
|
3149
3147
|
const { facetGroupName, section, value, ...rest } = parameters;
|
|
@@ -3197,7 +3195,7 @@ class Catalog {
|
|
|
3197
3195
|
*/
|
|
3198
3196
|
removeFacetOptionConfiguration(parameters = {}, networkParameters = {}) {
|
|
3199
3197
|
let requestUrl;
|
|
3200
|
-
const fetch =
|
|
3198
|
+
const { fetch } = this.options;
|
|
3201
3199
|
const controller = new AbortController();
|
|
3202
3200
|
const { signal } = controller;
|
|
3203
3201
|
const { facetGroupName, value } = parameters;
|
package/src/modules/quizzes.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/* eslint-disable object-curly-newline, no-underscore-dangle */
|
|
2
2
|
const qs = require('qs');
|
|
3
|
-
const nodeFetch = require('node-fetch').default;
|
|
4
3
|
const helpers = require('../utils/helpers');
|
|
5
4
|
|
|
6
5
|
// Create URL from supplied quizId and parameters
|
|
@@ -112,15 +111,15 @@ class Quizzes {
|
|
|
112
111
|
* versionId: '123'
|
|
113
112
|
* });
|
|
114
113
|
*/
|
|
115
|
-
getQuizNextQuestion(
|
|
114
|
+
getQuizNextQuestion(id, parameters, userParameters = {}, networkParameters = {}) {
|
|
116
115
|
const headers = {};
|
|
117
116
|
let requestUrl;
|
|
118
|
-
const fetch =
|
|
117
|
+
const { fetch } = this.options;
|
|
119
118
|
const controller = new AbortController();
|
|
120
119
|
const { signal } = controller;
|
|
121
120
|
|
|
122
121
|
try {
|
|
123
|
-
requestUrl = createQuizUrl(
|
|
122
|
+
requestUrl = createQuizUrl(id, parameters, userParameters, this.options, 'next');
|
|
124
123
|
} catch (e) {
|
|
125
124
|
return Promise.reject(e);
|
|
126
125
|
}
|
|
@@ -175,6 +174,7 @@ class Quizzes {
|
|
|
175
174
|
* @param {number} [userParameters.clientId] - Client ID, utilized to personalize results
|
|
176
175
|
* @param {string} [userParameters.userId] - User ID, utilized to personalize results
|
|
177
176
|
* @param {string} [userParameters.segments] - User segments
|
|
177
|
+
* @param {object} [userParameters.testCells] - User test cells
|
|
178
178
|
* @param {string} [userParameters.userIp] - Origin user IP, from client
|
|
179
179
|
* @param {string} [userParameters.userAgent] - Origin user agent, from client
|
|
180
180
|
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
@@ -188,15 +188,15 @@ class Quizzes {
|
|
|
188
188
|
* versionId: '123'
|
|
189
189
|
* });
|
|
190
190
|
*/
|
|
191
|
-
getQuizResults(
|
|
191
|
+
getQuizResults(id, parameters, userParameters = {}, networkParameters = {}) {
|
|
192
192
|
let requestUrl;
|
|
193
193
|
const headers = {};
|
|
194
|
-
const fetch =
|
|
194
|
+
const { fetch } = this.options;
|
|
195
195
|
const controller = new AbortController();
|
|
196
196
|
const { signal } = controller;
|
|
197
197
|
|
|
198
198
|
try {
|
|
199
|
-
requestUrl = createQuizUrl(
|
|
199
|
+
requestUrl = createQuizUrl(id, parameters, userParameters, this.options, 'finalize');
|
|
200
200
|
} catch (e) {
|
|
201
201
|
return Promise.reject(e);
|
|
202
202
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/* eslint-disable object-curly-newline, no-param-reassign */
|
|
2
2
|
const qs = require('qs');
|
|
3
|
-
const nodeFetch = require('node-fetch').default;
|
|
4
3
|
const { AbortController } = require('node-abort-controller');
|
|
5
4
|
const helpers = require('../utils/helpers');
|
|
6
5
|
|
|
@@ -129,7 +128,7 @@ class Recommendations {
|
|
|
129
128
|
*/
|
|
130
129
|
getRecommendations(podId, parameters = {}, userParameters = {}, networkParameters = {}) {
|
|
131
130
|
let requestUrl;
|
|
132
|
-
const fetch =
|
|
131
|
+
const { fetch } = this.options;
|
|
133
132
|
const controller = new AbortController();
|
|
134
133
|
const { signal } = controller;
|
|
135
134
|
const headers = {};
|
|
@@ -205,7 +204,7 @@ class Recommendations {
|
|
|
205
204
|
apiKey,
|
|
206
205
|
serviceUrl,
|
|
207
206
|
} = this.options;
|
|
208
|
-
const fetch =
|
|
207
|
+
const { fetch } = this.options;
|
|
209
208
|
const controller = new AbortController();
|
|
210
209
|
const { signal } = controller;
|
|
211
210
|
const headers = {};
|
package/src/modules/search.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/* eslint-disable max-len */
|
|
2
2
|
/* eslint-disable object-curly-newline, no-underscore-dangle */
|
|
3
3
|
const qs = require('qs');
|
|
4
|
-
const nodeFetch = require('node-fetch').default;
|
|
5
4
|
const { AbortController } = require('node-abort-controller');
|
|
6
5
|
const helpers = require('../utils/helpers');
|
|
7
6
|
|
|
@@ -191,7 +190,7 @@ class Search {
|
|
|
191
190
|
|
|
192
191
|
getSearchResults(query, parameters = {}, userParameters = {}, networkParameters = {}) {
|
|
193
192
|
let requestUrl;
|
|
194
|
-
const fetch =
|
|
193
|
+
const { fetch } = this.options;
|
|
195
194
|
const controller = new AbortController();
|
|
196
195
|
const { signal } = controller;
|
|
197
196
|
const headers = {};
|