From 67583162763a32b9010928d25e067e6400b8d171 Mon Sep 17 00:00:00 2001 From: Jeevan Kishore Date: Mon, 3 Jun 2024 16:01:20 +0530 Subject: [PATCH] Updates --- AmpConfig.html | 6 +++--- global.html | 2 +- index.js.html | 33 +++++++++++++++++---------------- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/AmpConfig.html b/AmpConfig.html index bb5ae70..f396617 100644 --- a/AmpConfig.html +++ b/AmpConfig.html @@ -138,7 +138,7 @@

AmpConfig View Source - index.js, line 1136 + index.js, line 1137

@@ -311,7 +311,7 @@

Parameters:

View Source - index.js, line 1155 + index.js, line 1156

@@ -431,7 +431,7 @@

View Source - index.js, line 1142 + index.js, line 1143

diff --git a/global.html b/global.html index 0637550..91ef60f 100644 --- a/global.html +++ b/global.html @@ -364,7 +364,7 @@

Parameters:

View Source - index.js, line 1124 + index.js, line 1125

diff --git a/index.js.html b/index.js.html index 21a3fd8..ee80cac 100644 --- a/index.js.html +++ b/index.js.html @@ -90,7 +90,7 @@

index.js

const { createCache, memoryStore } = require("cache-manager"); const { DEFAULT_REQUEST_TIMEOUT, ENABLE_AXIOS } = require("./constants"); -const { CACHE_TIME, MAX_CACHE, ENABLE_TTL_CACHE } = require("./cache-constant"); +const { CACHE_TIME, MAX_CACHE, ENABLE_TTL_CACHE, BULK_REQ_TTL_CACHE } = require("./cache-constant"); const memoryStoreInit = memoryStore(); const memoryCache = createCache(memoryStoreInit, { @@ -407,8 +407,8 @@

index.js

- Cricket `(Level 3)` - Football `(Level 3)` - Tennis `(Level 3)` - In the above example with nestedCollectionLimit: {ThreeColGrid: [2, 3, 4]}, Cricket collection will fetch 2 items, Football will fetch 5 items and Tennis will fetch 4 items. (default: defaultNestedLimit || 40) - * @param {Object} options.collectionOfCollectionsIndexes It accepts array of indexes(collection's position) to fetch collection of collection of items when the depth is 1. (Ex: collectionOfCollectionsIndexes: [0, 4]). + In the above example with nestedCollectionLimit: {ThreeColGrid: [2, 3, 4]}, Cricket collection will fetch 2 items, Football will fetch 5 items and Tennis will fetch 4 items. (default: defaultNestedLimit || 40) + * @param {Object} options.collectionOfCollectionsIndexes It accepts array of indexes(collection's position) to fetch collection of collection of items when the depth is 1. (Ex: collectionOfCollectionsIndexes: [0, 4]). eg: - Home `(Level 1)` - Sports Row `(Level 2)` @@ -418,10 +418,10 @@

index.js

- Movie `(Level 3)` - Song `(Level 3)` In the above example if we need to fetch the stories from `Sports Row` child collection we need to pass collectionOfCollectionsIndexes : [0], where 0 is the position of collection Sports Row and stories from Cricket and Football will be fetched - * @param {Object} options.customLayouts It accepts an array of objects to fetch the custom storyLimit and custom nestedCollectionLimit of custom layouts. (Ex: customLayouts: [{layout: "ArrowThreeColGrid", storyLimit: 9}, {layout: "ArrowTwoColTenStories", storyLimit: 2, nestedCollectionLimit: [5,5]}]). - * @return {(Promise<Collection|null>)} - * @see {@link https://developers.quintype.com/swagger/#/collection/get_api_v1_collections__slug_ GET /api/v1/collections/:slug} API documentation for a list of parameters and fields - */ + * @param {Object} options.customLayouts It accepts an array of objects to fetch the custom storyLimit and custom nestedCollectionLimit of custom layouts. (Ex: customLayouts: [{layout: "ArrowThreeColGrid", storyLimit: 9}, {layout: "ArrowTwoColTenStories", storyLimit: 2, nestedCollectionLimit: [5,5]}]). + * @return {(Promise<Collection|null>)} + * @see {@link https://developers.quintype.com/swagger/#/collection/get_api_v1_collections__slug_ GET /api/v1/collections/:slug} API documentation for a list of parameters and fields + */ static getCollectionBySlug(client, slug, params, options = {}) { const { depth = DEFAULT_DEPTH, @@ -1120,10 +1120,6 @@

index.js

async getInBulk(requests) { const requestHash = hash(requests); - this._cachedPostBulkLocations[requestHash] = - this._cachedPostBulkLocations[requestHash] || - (await this._cachedPostBulkGate(requestHash, getBulkLocation.bind(this))); - return this.request(this._cachedPostBulkLocations[requestHash]); async function getBulkLocation() { const response = await this.request("/api/v1/bulk-request", { @@ -1136,15 +1132,20 @@

index.js

simple: false, resolveWithFullResponse: true }); - - if (ENABLE_AXIOS && response.statusCode === 200 && response.redirectCount > 0) { - return response.headers["content-location"]; - } else if (response.statusCode === 303 && response.caseless.get("Location")) { - return response.caseless.get("Location"); + if (response.statusCode === 303 && response.caseless.get("Location")) { + const contentLocation = response.caseless.get("Location"); + await memoryCache.set(requestHash, contentLocation, BULK_REQ_TTL_CACHE); + return contentLocation; } else { throw new Error(`Could Not Convert POST bulk to a get, got status ${response.statusCode}`); } } + + let cachedRequestHash = await memoryCache.get(requestHash); + if (!cachedRequestHash) { + cachedRequestHash = await getBulkLocation.bind(this)(); + } + return this.request(cachedRequestHash); } getAmpStoryBySlug(slug) {