From 42409ac52add46f5eb059a9bddcb9c67c92e3eac Mon Sep 17 00:00:00 2001 From: naman-contentstack Date: Tue, 30 Sep 2025 17:35:22 +0530 Subject: [PATCH 1/9] feat: add delay config via interceptor --- lib/core/contentstackHTTPClient.js | 7 ++++++- types/contentstackClient.d.ts | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/core/contentstackHTTPClient.js b/lib/core/contentstackHTTPClient.js index c1e12770..14b39f3b 100644 --- a/lib/core/contentstackHTTPClient.js +++ b/lib/core/contentstackHTTPClient.js @@ -109,7 +109,12 @@ export default function contentstackHttpClient (options) { const instance = axios.create(axiosOptions) instance.httpClientParams = options instance.concurrencyQueue = new ConcurrencyQueue({ axios: instance, config }) - instance.interceptors.request.use((request) => { + instance.interceptors.request.use(async (request) => { + // Add configurable delay before making the request if specified + if (config?.delayMs > 0) { + await new Promise(resolve => setTimeout(resolve, config.delayMs)) + } + if (request.versioningStrategy && request.versioningStrategy === 'path') { request.baseURL = request.baseURL.replace('{api-version}', version) } else { diff --git a/types/contentstackClient.d.ts b/types/contentstackClient.d.ts index fc2c65d5..3d89f093 100644 --- a/types/contentstackClient.d.ts +++ b/types/contentstackClient.d.ts @@ -45,6 +45,7 @@ export interface ContentstackConfig extends AxiosRequestConfig, ContentstackToke logHandler?: (level: string, data: any) => void application?: string integration?: string + delayMs?: number } export interface LoginDetails { From 59813861951142bc26a9f922a5510c8b13b32b8e Mon Sep 17 00:00:00 2001 From: naman-contentstack Date: Tue, 30 Sep 2025 17:39:28 +0530 Subject: [PATCH 2/9] removed trailing spaces --- lib/core/contentstackHTTPClient.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/core/contentstackHTTPClient.js b/lib/core/contentstackHTTPClient.js index 14b39f3b..101b78df 100644 --- a/lib/core/contentstackHTTPClient.js +++ b/lib/core/contentstackHTTPClient.js @@ -114,7 +114,7 @@ export default function contentstackHttpClient (options) { if (config?.delayMs > 0) { await new Promise(resolve => setTimeout(resolve, config.delayMs)) } - + if (request.versioningStrategy && request.versioningStrategy === 'path') { request.baseURL = request.baseURL.replace('{api-version}', version) } else { From 30e05f7cf98065d0e8429913b1b47696e7e7edfe Mon Sep 17 00:00:00 2001 From: naman-contentstack Date: Wed, 1 Oct 2025 11:43:42 +0530 Subject: [PATCH 3/9] updated depedency --- .talismanrc | 2 +- package-lock.json | 6 ++++-- package.json | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.talismanrc b/.talismanrc index 32fad92e..984698d2 100644 --- a/.talismanrc +++ b/.talismanrc @@ -9,7 +9,7 @@ fileignoreconfig: ignore_detectors: - filecontent - filename: package-lock.json - checksum: c37956b0e6ccd5267dac7fd6f4347fbb5ad41defe1c42d39aaaeaf64d2cf8605 + checksum: 0c7d422e080dc20d4bac85d403f05cbb32bcf81789ccf52eb13306eb68d5b96d - filename: .husky/pre-commit checksum: 52a664f536cf5d1be0bea19cb6031ca6e8107b45b6314fe7d47b7fad7d800632 - filename: test/sanity-check/api/user-test.js diff --git a/package-lock.json b/package-lock.json index 52af398b..93f58215 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "MIT", "dependencies": { "assert": "^2.1.0", - "axios": "^1.11.0", + "axios": "^1.12.2", "buffer": "^6.0.3", "form-data": "^4.0.4", "husky": "^9.1.7", @@ -3747,7 +3747,9 @@ } }, "node_modules/axios": { - "version": "1.11.0", + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.12.2.tgz", + "integrity": "sha512-vMJzPewAlRyOgxV2dU0Cuz2O8zzzx9VYtbJOaBgXFeLc4IV/Eg50n4LowmehOOR61S8ZMpc2K5Sa7g6A4jfkUw==", "license": "MIT", "dependencies": { "follow-redirects": "^1.15.6", diff --git a/package.json b/package.json index 2e6cb22f..fdf8b8e2 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "license": "MIT", "dependencies": { "assert": "^2.1.0", - "axios": "^1.11.0", + "axios": "^1.12.2", "buffer": "^6.0.3", "form-data": "^4.0.4", "husky": "^9.1.7", From b0bdbffcb3ef87e593cf4078d99027348dacbb0d Mon Sep 17 00:00:00 2001 From: naman-contentstack Date: Wed, 1 Oct 2025 12:31:49 +0530 Subject: [PATCH 4/9] version bump --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 93f58215..2aea0186 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@contentstack/management", - "version": "1.25.0", + "version": "1.25.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@contentstack/management", - "version": "1.25.0", + "version": "1.25.1", "license": "MIT", "dependencies": { "assert": "^2.1.0", diff --git a/package.json b/package.json index fdf8b8e2..c80d580a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@contentstack/management", - "version": "1.25.0", + "version": "1.25.1", "description": "The Content Management API is used to manage the content of your Contentstack account", "main": "./dist/node/contentstack-management.js", "browser": "./dist/web/contentstack-management.js", From 48662dce0b22d5249668afef73177a011eb89704 Mon Sep 17 00:00:00 2001 From: naman-contentstack Date: Wed, 1 Oct 2025 15:11:42 +0530 Subject: [PATCH 5/9] updated the delay logic --- lib/core/concurrency-queue.js | 21 ++++++++++++++------- lib/core/contentstackHTTPClient.js | 7 +------ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/lib/core/concurrency-queue.js b/lib/core/concurrency-queue.js index 27c49364..c5290236 100644 --- a/lib/core/concurrency-queue.js +++ b/lib/core/concurrency-queue.js @@ -14,7 +14,8 @@ const defaultConfig = { retryOnHttpServerError: true, maxNetworkRetries: 3, networkRetryDelay: 100, // Base delay for network retries (ms) - networkBackoffStrategy: 'exponential' // 'exponential' or 'fixed' + networkBackoffStrategy: 'exponential', // 'exponential' or 'fixed' + delayMs: null // Delay in milliseconds before making each request } export function ConcurrencyQueue ({ axios, config }) { @@ -175,16 +176,22 @@ export function ConcurrencyQueue ({ axios, config }) { // Initial shift will check running request, // and adds request to running queue if max requests are not running - this.initialShift = () => { + this.initialShift = async () => { if (this.running.length < this.config.maxRequests && !this.paused) { - shift() + await shift() } } // INTERNAL: Shift the queued item to running queue - const shift = () => { + const shift = async () => { if (this.queue.length && !this.paused) { const queueItem = this.queue.shift() + + // Add configurable delay before making the request if specified + if (this.config.delayMs && this.config.delayMs > 0) { + await new Promise(resolve => setTimeout(resolve, this.config.delayMs)) + } + queueItem.resolve(queueItem.request) this.running.push(queueItem) } @@ -197,7 +204,7 @@ export function ConcurrencyQueue ({ axios, config }) { this.push = requestPromise => { this.queue.push(requestPromise) - this.initialShift() + this.initialShift().catch(console.error) } this.clear = () => { @@ -312,7 +319,7 @@ export function ConcurrencyQueue ({ axios, config }) { return refreshToken() } else { for (let i = 0; i < this.config.maxRequests; i++) { - this.initialShift() + this.initialShift().catch(console.error) } } }, time)) @@ -360,7 +367,7 @@ export function ConcurrencyQueue ({ axios, config }) { } }) for (let i = 0; i < this.config.maxRequests; i++) { - this.initialShift() + this.initialShift().catch(console.error) } }) } diff --git a/lib/core/contentstackHTTPClient.js b/lib/core/contentstackHTTPClient.js index 101b78df..c1e12770 100644 --- a/lib/core/contentstackHTTPClient.js +++ b/lib/core/contentstackHTTPClient.js @@ -109,12 +109,7 @@ export default function contentstackHttpClient (options) { const instance = axios.create(axiosOptions) instance.httpClientParams = options instance.concurrencyQueue = new ConcurrencyQueue({ axios: instance, config }) - instance.interceptors.request.use(async (request) => { - // Add configurable delay before making the request if specified - if (config?.delayMs > 0) { - await new Promise(resolve => setTimeout(resolve, config.delayMs)) - } - + instance.interceptors.request.use((request) => { if (request.versioningStrategy && request.versioningStrategy === 'path') { request.baseURL = request.baseURL.replace('{api-version}', version) } else { From 00ed97c3908ece96b183ffd64f6478e7150ffed6 Mon Sep 17 00:00:00 2001 From: naman-contentstack Date: Wed, 1 Oct 2025 15:14:13 +0530 Subject: [PATCH 6/9] fix linting --- lib/core/concurrency-queue.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/core/concurrency-queue.js b/lib/core/concurrency-queue.js index c5290236..747713d5 100644 --- a/lib/core/concurrency-queue.js +++ b/lib/core/concurrency-queue.js @@ -186,12 +186,12 @@ export function ConcurrencyQueue ({ axios, config }) { const shift = async () => { if (this.queue.length && !this.paused) { const queueItem = this.queue.shift() - + // Add configurable delay before making the request if specified if (this.config.delayMs && this.config.delayMs > 0) { await new Promise(resolve => setTimeout(resolve, this.config.delayMs)) } - + queueItem.resolve(queueItem.request) this.running.push(queueItem) } From cd39eb87e567074b3312dcb97078ad4c30d4169e Mon Sep 17 00:00:00 2001 From: harshithad0703 <104908717+harshithad0703@users.noreply.github.com> Date: Fri, 3 Oct 2025 10:56:59 +0530 Subject: [PATCH 7/9] Update checksum for package-lock.json in .talismanrc --- .talismanrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.talismanrc b/.talismanrc index 984698d2..83861a19 100644 --- a/.talismanrc +++ b/.talismanrc @@ -9,7 +9,7 @@ fileignoreconfig: ignore_detectors: - filecontent - filename: package-lock.json - checksum: 0c7d422e080dc20d4bac85d403f05cbb32bcf81789ccf52eb13306eb68d5b96d + checksum: bab53d56ce2609e960fdbbd1e87cc89915820e6761016ddd74ee57f931f4223d - filename: .husky/pre-commit checksum: 52a664f536cf5d1be0bea19cb6031ca6e8107b45b6314fe7d47b7fad7d800632 - filename: test/sanity-check/api/user-test.js From 48583ad0e1121ac73d08d72ff015c095eda91946 Mon Sep 17 00:00:00 2001 From: harshithad0703 <104908717+harshithad0703@users.noreply.github.com> Date: Fri, 3 Oct 2025 10:58:52 +0530 Subject: [PATCH 8/9] Update CHANGELOG for version 1.25.1 Updated changelog for version 1.25.1 with a fix related to delay handling. --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2571992b..38ad2ce4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## [v1.25.0](https://github.com/contentstack/contentstack-management-javascript/tree/v1.25.1) (2025-10-06) + - Fix + - Updated delay handling to use centralized external configuration in SDK interceptor + ## [v1.25.0](https://github.com/contentstack/contentstack-management-javascript/tree/v1.25.0) (2025-09-03) - Enhancement - Added publish_all_localized param in bulk publish/unpublish From 608c7ff139e913acbf623d2583b3e4973be39802 Mon Sep 17 00:00:00 2001 From: harshithad0703 <104908717+harshithad0703@users.noreply.github.com> Date: Fri, 3 Oct 2025 10:59:08 +0530 Subject: [PATCH 9/9] Bump version to v1.25.1 in CHANGELOG Updated version number from v1.25.0 to v1.25.1 in CHANGELOG. --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 38ad2ce4..02ef5456 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## [v1.25.0](https://github.com/contentstack/contentstack-management-javascript/tree/v1.25.1) (2025-10-06) +## [v1.25.1](https://github.com/contentstack/contentstack-management-javascript/tree/v1.25.1) (2025-10-06) - Fix - Updated delay handling to use centralized external configuration in SDK interceptor