From 585a18caa6f2c1e2366296aa338a0552c2f2b1e9 Mon Sep 17 00:00:00 2001 From: "harshitha.d" Date: Fri, 2 May 2025 14:52:20 +0530 Subject: [PATCH 1/5] Fixed unexpected fallback_locale behavior during direct locale updates. --- lib/entity.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/entity.js b/lib/entity.js index 6fcb22ff..def31ab3 100644 --- a/lib/entity.js +++ b/lib/entity.js @@ -155,7 +155,12 @@ export const update = (http, type, params = {}) => { delete json.deleted_at delete json.updated_at delete json.updated_by - delete json.updated_at + + // If param has data for this entity type, merge it with the json object + if (param && param[type]) { + Object.assign(json, param[type]) + } + if (type) { updateData[type] = json if (type === 'entry') updateData[type] = cleanAssets(updateData[type]) From e4a61c21dd080750f15a2b77fc72b631cf61beb8 Mon Sep 17 00:00:00 2001 From: "harshitha.d" Date: Fri, 2 May 2025 14:52:30 +0530 Subject: [PATCH 2/5] Update Hindi - India locale tests to include fallback locale updates --- test/sanity-check/api/locale-test.js | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/test/sanity-check/api/locale-test.js b/test/sanity-check/api/locale-test.js index 913a5188..024d3c7e 100644 --- a/test/sanity-check/api/locale-test.js +++ b/test/sanity-check/api/locale-test.js @@ -94,12 +94,12 @@ describe('Locale api Test', () => { .catch(done) }) - it('should get and update a language Hindi - India', done => { + it('should get and update a language Hindi - India with fallback locale en-at', done => { makeLocale('hi-in') .fetch() .then((locale) => { - locale.fallback_locale = 'en-at' - return locale.update() + // locale.fallback_locale = 'en-at' + return locale.update({locale:{ fallback_locale: 'en-at' }}) }) .then((locale) => { expect(locale.code).to.be.equal('hi-in') @@ -111,6 +111,23 @@ describe('Locale api Test', () => { .catch(done) }) + it('should get and update a language Hindi - India with fallback locale en-us', done => { + makeLocale('hi-in') + .fetch() + .then((locale) => { + locale.fallback_locale = 'en-us' + return locale.update() + }) + .then((locale) => { + expect(locale.code).to.be.equal('hi-in') + expect(locale.name).to.be.equal('Hindi - India') + expect(locale.fallback_locale).to.be.equal('en-us') + expect(locale.uid).to.be.not.equal(null) + done() + }) + .catch(done) + }) + it('should delete language: Hindi - India', done => { makeLocale('mr-in') .delete() From 76aa9d751c957798ac8f08fcef0556be0bb80cf9 Mon Sep 17 00:00:00 2001 From: "harshitha.d" Date: Fri, 2 May 2025 15:01:30 +0530 Subject: [PATCH 3/5] Update changelog for v1.21.1 and package files --- CHANGELOG.md | 4 ++++ package-lock.json | 4 ++-- package.json | 2 +- sanity-report.mjs | 4 ++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index adabd7d8..8d109585 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## [v1.21.1](https://github.com/contentstack/contentstack-management-javascript/tree/v1.21.1) (2025-05-12) + - Fix + - Fixed unexpected fallback_locale behavior during direct locale updates. + ## [v1.21.0](https://github.com/contentstack/contentstack-management-javascript/tree/v1.21.0) (2025-05-05) - Enhancement - Region support added diff --git a/package-lock.json b/package-lock.json index 50fa7f36..bb6d54f9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@contentstack/management", - "version": "1.21.0", + "version": "1.21.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@contentstack/management", - "version": "1.21.0", + "version": "1.21.1", "license": "MIT", "dependencies": { "assert": "^2.1.0", diff --git a/package.json b/package.json index 51587221..7c66afdd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@contentstack/management", - "version": "1.21.0", + "version": "1.21.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", diff --git a/sanity-report.mjs b/sanity-report.mjs index 2847a04d..8338e1a6 100644 --- a/sanity-report.mjs +++ b/sanity-report.mjs @@ -5,7 +5,7 @@ import fs from 'fs' dotenv.config() -const mochawesomeJsonOutput = fs.readFileSync('./mochawesome-report/mochawesome.json', 'utf-8') +const mochawesomeJsonOutput = fs.readFileSync('./mochawesome-report/mochawesome.json', 'utf8') const mochawesomeReport = JSON.parse(mochawesomeJsonOutput) const report = `./mochawesome-report/sanity-report.html` @@ -26,7 +26,7 @@ console.log(`Pending Tests: ${pendingTests}`) console.log(`Total Duration: ${durationInMinutes}m ${durationInSeconds.toFixed(2)}s`) const slackMessage = ` -*JavaScript CMA Report* +*JavaScript CMA Report DX-2896 (fallback locale update) * • Total Suites: *${totalSuites}* • Total Tests: *${totalTests}* • Passed Tests: *${passedTests}* From 31d9a159e83427dc475cc7ec376d09b501ca59bf Mon Sep 17 00:00:00 2001 From: "harshitha.d" Date: Mon, 5 May 2025 12:48:48 +0530 Subject: [PATCH 4/5] fix lint --- lib/entity.js | 4 ++-- test/sanity-check/api/locale-test.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/entity.js b/lib/entity.js index def31ab3..5fe29f3a 100644 --- a/lib/entity.js +++ b/lib/entity.js @@ -155,12 +155,12 @@ export const update = (http, type, params = {}) => { delete json.deleted_at delete json.updated_at delete json.updated_by - + // If param has data for this entity type, merge it with the json object if (param && param[type]) { Object.assign(json, param[type]) } - + if (type) { updateData[type] = json if (type === 'entry') updateData[type] = cleanAssets(updateData[type]) diff --git a/test/sanity-check/api/locale-test.js b/test/sanity-check/api/locale-test.js index 024d3c7e..7623c661 100644 --- a/test/sanity-check/api/locale-test.js +++ b/test/sanity-check/api/locale-test.js @@ -99,7 +99,7 @@ describe('Locale api Test', () => { .fetch() .then((locale) => { // locale.fallback_locale = 'en-at' - return locale.update({locale:{ fallback_locale: 'en-at' }}) + return locale.update({ locale: { fallback_locale: 'en-at' } }) }) .then((locale) => { expect(locale.code).to.be.equal('hi-in') From 284b5cfe0213d3c0c8ac37498d057aff618878df Mon Sep 17 00:00:00 2001 From: "harshitha.d" Date: Mon, 5 May 2025 16:31:01 +0530 Subject: [PATCH 5/5] update slack msg --- sanity-report.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sanity-report.mjs b/sanity-report.mjs index 8338e1a6..5732fc77 100644 --- a/sanity-report.mjs +++ b/sanity-report.mjs @@ -26,7 +26,7 @@ console.log(`Pending Tests: ${pendingTests}`) console.log(`Total Duration: ${durationInMinutes}m ${durationInSeconds.toFixed(2)}s`) const slackMessage = ` -*JavaScript CMA Report DX-2896 (fallback locale update) * +*JavaScript CMA Report* • Total Suites: *${totalSuites}* • Total Tests: *${totalTests}* • Passed Tests: *${passedTests}*