From f65da55950eeeff70465d7557fd9011b47dac3b1 Mon Sep 17 00:00:00 2001 From: Aniket Shikhare <62753263+AniketDev7@users.noreply.github.com> Date: Wed, 7 May 2025 16:21:54 +0530 Subject: [PATCH 1/5] feat: update sanity suite name to SDK-JS-CMA --- sanity-report-dev11.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sanity-report-dev11.js b/sanity-report-dev11.js index 8a0f8bff..1a9e6042 100644 --- a/sanity-report-dev11.js +++ b/sanity-report-dev11.js @@ -38,7 +38,7 @@ let tagUsers = failedTests > 0 ? `<@${user1}> <@${user2}> <@${user3}> <@${user4}>` : ""; const slackMessage = { - text: `Dev11, SDK-CMA Sanity\n*Result:* ${resultMessage}. ${durationInMinutes}m ${durationInSeconds}s\n*Failed Tests:* ${failedTests}\n<${reportUrl}|View Report>\n${tagUsers}`, + text: `Dev11, SDK-JS-CMA Sanity\n*Result:* ${resultMessage}. ${durationInMinutes}m ${durationInSeconds}s\n*Failed Tests:* ${failedTests}\n<${reportUrl}|View Report>\n${tagUsers}`, }; const app = new App({ From d4638ef0e0a0e710e64a131496debf5024d3cf00 Mon Sep 17 00:00:00 2001 From: "harshitha.d" Date: Mon, 12 May 2025 19:21:56 +0530 Subject: [PATCH 2/5] fix: include region in Slack message header --- sanity-report.mjs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sanity-report.mjs b/sanity-report.mjs index 5732fc77..ee4efcc5 100644 --- a/sanity-report.mjs +++ b/sanity-report.mjs @@ -25,8 +25,16 @@ console.log(`Failed Tests: ${failedTests}`) console.log(`Pending Tests: ${pendingTests}`) console.log(`Total Duration: ${durationInMinutes}m ${durationInSeconds.toFixed(2)}s`) +const host = process.env.HOST || '' +let region = 'UNKNOWN REGION' + +const match = host.match(/^([^-]+(?:-[^-]+)*)-api/) +if (match && match[1]) { + region = match[1].toUpperCase() +} + const slackMessage = ` -*JavaScript CMA Report* +*JavaScript CMA Report - ${region}* • Total Suites: *${totalSuites}* • Total Tests: *${totalTests}* • Passed Tests: *${passedTests}* From b77bc00b831fd6dfe645c79d0b41f67f3389e6aa Mon Sep 17 00:00:00 2001 From: sunil-lakshman <104969541+sunil-lakshman@users.noreply.github.com> Date: Tue, 13 May 2025 17:10:31 +0530 Subject: [PATCH 3/5] Implemented preview token generation --- CHANGELOG.md | 3 +++ lib/entity.js | 12 ++++++++---- lib/stack/deliveryToken/index.js | 2 +- package-lock.json | 4 ++-- package.json | 2 +- test/sanity-check/api/deliveryToken-test.js | 2 ++ 6 files changed, 17 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d109585..726e69b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,7 @@ # Changelog +## [v1.21.2](https://github.com/contentstack/contentstack-management-javascript/tree/v1.21.2) (2025-05-19) + - Enhancement + - Added preview token generation. ## [v1.21.1](https://github.com/contentstack/contentstack-management-javascript/tree/v1.21.1) (2025-05-12) - Fix diff --git a/lib/entity.js b/lib/entity.js index 5fe29f3a..66cc5d2f 100644 --- a/lib/entity.js +++ b/lib/entity.js @@ -85,19 +85,23 @@ export const upload = async ({ http, urlPath, stackHeaders, formData, params, me } } -export const create = ({ http, params }) => { +// eslint-disable-next-line camelcase +export const create = ({ http, params = {}, create_with_preview_token = false }) => { return async function (data, param) { this.stackHeaders = { ...this.stackHeaders } + const queryParams = { + // eslint-disable-next-line camelcase + ...(create_with_preview_token ? { create_with_preview_token: true } : {}), + ...cloneDeep(param) // user param can override default + } const headers = { headers: { ...cloneDeep(params), ...cloneDeep(this.stackHeaders) }, - params: { - ...cloneDeep(param) - } + params: queryParams } || {} try { diff --git a/lib/stack/deliveryToken/index.js b/lib/stack/deliveryToken/index.js index b9117741..7e6fa709 100644 --- a/lib/stack/deliveryToken/index.js +++ b/lib/stack/deliveryToken/index.js @@ -84,7 +84,7 @@ export function DeliveryToken (http, data = {}) { * client.stack().deliveryToken().create({ token }) * .then((deliveryToken) => console.log(deliveryToken)) */ - this.create = create({ http: http }) + this.create = create({ http: http, create_with_preview_token: true }) /** * @description The ‘Get all deliveryToken’ request returns comprehensive information about all deliveryToken created in a stack. diff --git a/package-lock.json b/package-lock.json index bb6d54f9..82a6b51d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@contentstack/management", - "version": "1.21.1", + "version": "1.21.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@contentstack/management", - "version": "1.21.1", + "version": "1.21.2", "license": "MIT", "dependencies": { "assert": "^2.1.0", diff --git a/package.json b/package.json index 7c66afdd..0dba89bc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@contentstack/management", - "version": "1.21.1", + "version": "1.21.2", "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/test/sanity-check/api/deliveryToken-test.js b/test/sanity-check/api/deliveryToken-test.js index 98d6a233..cca8b813 100644 --- a/test/sanity-check/api/deliveryToken-test.js +++ b/test/sanity-check/api/deliveryToken-test.js @@ -24,6 +24,7 @@ describe('Delivery Token api Test', () => { expect(token.scope[0].environments[0].name).to.be.equal(createDeliveryToken.token.scope[0].environments[0]) expect(token.scope[0].module).to.be.equal(createDeliveryToken.token.scope[0].module) expect(token.uid).to.be.not.equal(null) + expect(token.preview_token).to.be.not.equal(null) done() }) .catch(done) @@ -39,6 +40,7 @@ describe('Delivery Token api Test', () => { expect(token.scope[0].environments[0].name).to.be.equal(createDeliveryToken2.token.scope[0].environments[0]) expect(token.scope[0].module).to.be.equal(createDeliveryToken2.token.scope[0].module) expect(token.uid).to.be.not.equal(null) + expect(token.preview_token).to.be.not.equal(null) done() }) .catch(done) From 64c04ebbcde6bbaa72889a80ef5ec8316ec34f2e Mon Sep 17 00:00:00 2001 From: sunil-lakshman <104969541+sunil-lakshman@users.noreply.github.com> Date: Wed, 14 May 2025 10:19:31 +0530 Subject: [PATCH 4/5] Fixed PR comments --- lib/entity.js | 6 ++---- lib/stack/deliveryToken/index.js | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/entity.js b/lib/entity.js index 66cc5d2f..266c10e2 100644 --- a/lib/entity.js +++ b/lib/entity.js @@ -85,15 +85,13 @@ export const upload = async ({ http, urlPath, stackHeaders, formData, params, me } } -// eslint-disable-next-line camelcase -export const create = ({ http, params = {}, create_with_preview_token = false }) => { +export const create = ({ http, params = {}, createWithPreviewToken = false }) => { return async function (data, param) { this.stackHeaders = { ...this.stackHeaders } const queryParams = { - // eslint-disable-next-line camelcase - ...(create_with_preview_token ? { create_with_preview_token: true } : {}), + ...(createWithPreviewToken ? { create_with_preview_token: true } : {}), ...cloneDeep(param) // user param can override default } const headers = { diff --git a/lib/stack/deliveryToken/index.js b/lib/stack/deliveryToken/index.js index 7e6fa709..763423c9 100644 --- a/lib/stack/deliveryToken/index.js +++ b/lib/stack/deliveryToken/index.js @@ -84,7 +84,7 @@ export function DeliveryToken (http, data = {}) { * client.stack().deliveryToken().create({ token }) * .then((deliveryToken) => console.log(deliveryToken)) */ - this.create = create({ http: http, create_with_preview_token: true }) + this.create = create({ http: http, createWithPreviewToken: true }) /** * @description The ‘Get all deliveryToken’ request returns comprehensive information about all deliveryToken created in a stack. From 203f4a2ac40daebe8cb12dc8251c6449e2a13396 Mon Sep 17 00:00:00 2001 From: "harshitha.d" Date: Thu, 15 May 2025 15:44:01 +0530 Subject: [PATCH 5/5] fix: update default region value from 'UNKNOWN REGION' to 'NA' --- sanity-report.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sanity-report.mjs b/sanity-report.mjs index ee4efcc5..cdc2b073 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 host = process.env.HOST || '' -let region = 'UNKNOWN REGION' +let region = 'NA' const match = host.match(/^([^-]+(?:-[^-]+)*)-api/) if (match && match[1]) {