@constructor-io/constructorio-node 5.2.0 → 5.3.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 +1 -1
- package/src/modules/autocomplete.js +5 -1
- package/src/modules/browse.js +41 -23
- package/src/modules/quizzes.js +32 -28
- package/src/modules/recommendations.js +5 -1
- package/src/modules/search.js +10 -2
package/package.json
CHANGED
|
@@ -205,7 +205,7 @@ class Autocomplete {
|
|
|
205
205
|
// Handle network timeout if specified
|
|
206
206
|
helpers.applyNetworkTimeout(this.options, networkParameters, controller);
|
|
207
207
|
|
|
208
|
-
|
|
208
|
+
const promise = fetch(requestUrl, { headers, signal }).then((response) => {
|
|
209
209
|
if (response.ok) {
|
|
210
210
|
return response.json();
|
|
211
211
|
}
|
|
@@ -234,6 +234,10 @@ class Autocomplete {
|
|
|
234
234
|
|
|
235
235
|
throw new Error('getAutocompleteResults response data is malformed');
|
|
236
236
|
});
|
|
237
|
+
|
|
238
|
+
promise.requestUrl = requestUrl;
|
|
239
|
+
|
|
240
|
+
return promise;
|
|
237
241
|
}
|
|
238
242
|
}
|
|
239
243
|
|
package/src/modules/browse.js
CHANGED
|
@@ -295,7 +295,7 @@ class Browse {
|
|
|
295
295
|
// Handle network timeout if specified
|
|
296
296
|
helpers.applyNetworkTimeout(this.options, networkParameters, controller);
|
|
297
297
|
|
|
298
|
-
|
|
298
|
+
const promise = fetch(requestUrl, { headers, signal }).then((response) => {
|
|
299
299
|
if (response.ok) {
|
|
300
300
|
return response.json();
|
|
301
301
|
}
|
|
@@ -321,6 +321,10 @@ class Browse {
|
|
|
321
321
|
|
|
322
322
|
throw new Error('getBrowseResults response data is malformed');
|
|
323
323
|
});
|
|
324
|
+
|
|
325
|
+
promise.requestUrl = requestUrl;
|
|
326
|
+
|
|
327
|
+
return promise;
|
|
324
328
|
}
|
|
325
329
|
|
|
326
330
|
/**
|
|
@@ -375,27 +379,29 @@ class Browse {
|
|
|
375
379
|
// Handle network timeout if specified
|
|
376
380
|
helpers.applyNetworkTimeout(this.options, networkParameters, controller);
|
|
377
381
|
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
}
|
|
382
|
+
const promise = fetch(requestUrl, { headers, signal }).then((response) => {
|
|
383
|
+
if (response.ok) {
|
|
384
|
+
return response.json();
|
|
385
|
+
}
|
|
383
386
|
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
if (json.
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
});
|
|
394
|
-
}
|
|
395
|
-
return json;
|
|
387
|
+
return helpers.throwHttpErrorFromResponse(new Error(), response);
|
|
388
|
+
}).then((json) => {
|
|
389
|
+
if (json.response && json.response.results) {
|
|
390
|
+
if (json.result_id) {
|
|
391
|
+
// Append `result_id` to each result item
|
|
392
|
+
json.response.results.forEach((result) => {
|
|
393
|
+
// eslint-disable-next-line no-param-reassign
|
|
394
|
+
result.result_id = json.result_id;
|
|
395
|
+
});
|
|
396
396
|
}
|
|
397
|
-
|
|
398
|
-
}
|
|
397
|
+
return json;
|
|
398
|
+
}
|
|
399
|
+
throw new Error('getBrowseResultsForItemIds response data is malformed');
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
promise.requestUrl = requestUrl;
|
|
403
|
+
|
|
404
|
+
return promise;
|
|
399
405
|
}
|
|
400
406
|
|
|
401
407
|
/**
|
|
@@ -443,13 +449,17 @@ class Browse {
|
|
|
443
449
|
// Handle network timeout if specified
|
|
444
450
|
helpers.applyNetworkTimeout(this.options, networkParameters, controller);
|
|
445
451
|
|
|
446
|
-
|
|
452
|
+
const promise = fetch(requestUrl, { headers, signal }).then((response) => {
|
|
447
453
|
if (response.ok) {
|
|
448
454
|
return response.json();
|
|
449
455
|
}
|
|
450
456
|
|
|
451
457
|
return helpers.throwHttpErrorFromResponse(new Error(), response);
|
|
452
458
|
});
|
|
459
|
+
|
|
460
|
+
promise.requestUrl = requestUrl;
|
|
461
|
+
|
|
462
|
+
return promise;
|
|
453
463
|
}
|
|
454
464
|
|
|
455
465
|
/**
|
|
@@ -498,7 +508,7 @@ class Browse {
|
|
|
498
508
|
// Handle network timeout if specified
|
|
499
509
|
helpers.applyNetworkTimeout(this.options, networkParameters, controller);
|
|
500
510
|
|
|
501
|
-
|
|
511
|
+
const promise = fetch(requestUrl, {
|
|
502
512
|
headers: { ...headers, ...helpers.createAuthHeader(this.options) },
|
|
503
513
|
signal,
|
|
504
514
|
}).then((response) => {
|
|
@@ -508,6 +518,10 @@ class Browse {
|
|
|
508
518
|
|
|
509
519
|
return helpers.throwHttpErrorFromResponse(new Error(), response);
|
|
510
520
|
});
|
|
521
|
+
|
|
522
|
+
promise.requestUrl = requestUrl;
|
|
523
|
+
|
|
524
|
+
return promise;
|
|
511
525
|
}
|
|
512
526
|
|
|
513
527
|
/**
|
|
@@ -553,7 +567,7 @@ class Browse {
|
|
|
553
567
|
// Handle network timeout if specified
|
|
554
568
|
helpers.applyNetworkTimeout(this.options, networkParameters, controller);
|
|
555
569
|
|
|
556
|
-
|
|
570
|
+
const promise = fetch(requestUrl, {
|
|
557
571
|
headers: { ...headers, ...helpers.createAuthHeader(this.options) },
|
|
558
572
|
signal,
|
|
559
573
|
}).then((response) => {
|
|
@@ -563,6 +577,10 @@ class Browse {
|
|
|
563
577
|
|
|
564
578
|
return helpers.throwHttpErrorFromResponse(new Error(), response);
|
|
565
579
|
});
|
|
580
|
+
|
|
581
|
+
promise.requestUrl = requestUrl;
|
|
582
|
+
|
|
583
|
+
return promise;
|
|
566
584
|
}
|
|
567
585
|
}
|
|
568
586
|
|
package/src/modules/quizzes.js
CHANGED
|
@@ -162,21 +162,23 @@ class Quizzes {
|
|
|
162
162
|
// Handle network timeout if specified
|
|
163
163
|
helpers.applyNetworkTimeout(this.options, networkParameters, controller);
|
|
164
164
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
165
|
+
const promise = fetch(requestUrl, { headers, signal }).then((response) => {
|
|
166
|
+
if (response.ok) {
|
|
167
|
+
return response.json();
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return helpers.throwHttpErrorFromResponse(new Error(), response);
|
|
171
|
+
}).then((json) => {
|
|
172
|
+
if (json.quiz_version_id) {
|
|
173
|
+
return json;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
throw new Error('getQuizNextQuestion response data is malformed');
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
promise.requestUrl = requestUrl;
|
|
180
|
+
|
|
181
|
+
return promise;
|
|
180
182
|
}
|
|
181
183
|
|
|
182
184
|
/**
|
|
@@ -243,21 +245,23 @@ class Quizzes {
|
|
|
243
245
|
// Handle network timeout if specified
|
|
244
246
|
helpers.applyNetworkTimeout(this.options, networkParameters, controller);
|
|
245
247
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
}
|
|
248
|
+
const promise = fetch(requestUrl, { headers, signal }).then((response) => {
|
|
249
|
+
if (response.ok) {
|
|
250
|
+
return response.json();
|
|
251
|
+
}
|
|
251
252
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
}
|
|
253
|
+
return helpers.throwHttpErrorFromResponse(new Error(), response);
|
|
254
|
+
}).then((json) => {
|
|
255
|
+
if (json.quiz_version_id) {
|
|
256
|
+
return json;
|
|
257
|
+
}
|
|
258
258
|
|
|
259
|
-
|
|
260
|
-
|
|
259
|
+
throw new Error('getQuizResults response data is malformed');
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
promise.requestUrl = requestUrl;
|
|
263
|
+
|
|
264
|
+
return promise;
|
|
261
265
|
}
|
|
262
266
|
}
|
|
263
267
|
|
|
@@ -196,7 +196,7 @@ class Recommendations {
|
|
|
196
196
|
// Handle network timeout if specified
|
|
197
197
|
helpers.applyNetworkTimeout(this.options, networkParameters, controller);
|
|
198
198
|
|
|
199
|
-
|
|
199
|
+
const promise = fetch(requestUrl, { headers, signal }).then((response) => {
|
|
200
200
|
if (response.ok) {
|
|
201
201
|
return response.json();
|
|
202
202
|
}
|
|
@@ -222,6 +222,10 @@ class Recommendations {
|
|
|
222
222
|
|
|
223
223
|
throw new Error('getRecommendations response data is malformed');
|
|
224
224
|
});
|
|
225
|
+
|
|
226
|
+
promise.requestUrl = requestUrl;
|
|
227
|
+
|
|
228
|
+
return promise;
|
|
225
229
|
}
|
|
226
230
|
|
|
227
231
|
/**
|
package/src/modules/search.js
CHANGED
|
@@ -234,7 +234,7 @@ class Search {
|
|
|
234
234
|
// Handle network timeout if specified
|
|
235
235
|
helpers.applyNetworkTimeout(this.options, networkParameters, controller);
|
|
236
236
|
|
|
237
|
-
|
|
237
|
+
const promise = fetch(requestUrl, { headers, signal }).then((response) => {
|
|
238
238
|
if (response.ok) {
|
|
239
239
|
return response.json();
|
|
240
240
|
}
|
|
@@ -260,6 +260,10 @@ class Search {
|
|
|
260
260
|
|
|
261
261
|
throw new Error('getSearchResults response data is malformed');
|
|
262
262
|
});
|
|
263
|
+
|
|
264
|
+
promise.requestUrl = requestUrl;
|
|
265
|
+
|
|
266
|
+
return promise;
|
|
263
267
|
}
|
|
264
268
|
|
|
265
269
|
/**
|
|
@@ -334,7 +338,7 @@ class Search {
|
|
|
334
338
|
// Handle network timeout if specified
|
|
335
339
|
helpers.applyNetworkTimeout(this.options, networkParameters, controller);
|
|
336
340
|
|
|
337
|
-
|
|
341
|
+
const promise = fetch(requestUrl, { headers, signal }).then((response) => {
|
|
338
342
|
if (response.ok) {
|
|
339
343
|
return response.json();
|
|
340
344
|
}
|
|
@@ -360,6 +364,10 @@ class Search {
|
|
|
360
364
|
|
|
361
365
|
throw new Error('getVoiceSearchResults response data is malformed');
|
|
362
366
|
});
|
|
367
|
+
|
|
368
|
+
promise.requestUrl = requestUrl;
|
|
369
|
+
|
|
370
|
+
return promise;
|
|
363
371
|
}
|
|
364
372
|
}
|
|
365
373
|
|