Skip to content

Commit 29972b9

Browse files
Merge pull request #353 from contentstack/staging
Merge pull request #348 from contentstack/master
2 parents 87a6958 + d869539 commit 29972b9

File tree

8 files changed

+25
-10
lines changed

8 files changed

+25
-10
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# Changelog
2+
## [v1.21.2](https://github.com/contentstack/contentstack-management-javascript/tree/v1.21.2) (2025-05-19)
3+
- Enhancement
4+
- Added preview token generation.
25

36
## [v1.21.1](https://github.com/contentstack/contentstack-management-javascript/tree/v1.21.1) (2025-05-12)
47
- Fix

lib/entity.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,19 +85,21 @@ export const upload = async ({ http, urlPath, stackHeaders, formData, params, me
8585
}
8686
}
8787

88-
export const create = ({ http, params }) => {
88+
export const create = ({ http, params = {}, createWithPreviewToken = false }) => {
8989
return async function (data, param) {
9090
this.stackHeaders = {
9191
...this.stackHeaders
9292
}
93+
const queryParams = {
94+
...(createWithPreviewToken ? { create_with_preview_token: true } : {}),
95+
...cloneDeep(param) // user param can override default
96+
}
9397
const headers = {
9498
headers: {
9599
...cloneDeep(params),
96100
...cloneDeep(this.stackHeaders)
97101
},
98-
params: {
99-
...cloneDeep(param)
100-
}
102+
params: queryParams
101103
} || {}
102104

103105
try {

lib/stack/deliveryToken/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export function DeliveryToken (http, data = {}) {
8484
* client.stack().deliveryToken().create({ token })
8585
* .then((deliveryToken) => console.log(deliveryToken))
8686
*/
87-
this.create = create({ http: http })
87+
this.create = create({ http: http, createWithPreviewToken: true })
8888

8989
/**
9090
* @description The ‘Get all deliveryToken’ request returns comprehensive information about all deliveryToken created in a stack.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@contentstack/management",
3-
"version": "1.21.1",
3+
"version": "1.21.2",
44
"description": "The Content Management API is used to manage the content of your Contentstack account",
55
"main": "./dist/node/contentstack-management.js",
66
"browser": "./dist/web/contentstack-management.js",

sanity-report-dev11.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ let tagUsers =
3838
failedTests > 0 ? `<@${user1}> <@${user2}> <@${user3}> <@${user4}>` : "";
3939

4040
const slackMessage = {
41-
text: `Dev11, SDK-CMA Sanity\n*Result:* ${resultMessage}. ${durationInMinutes}m ${durationInSeconds}s\n*Failed Tests:* ${failedTests}\n<${reportUrl}|View Report>\n${tagUsers}`,
41+
text: `Dev11, SDK-JS-CMA Sanity\n*Result:* ${resultMessage}. ${durationInMinutes}m ${durationInSeconds}s\n*Failed Tests:* ${failedTests}\n<${reportUrl}|View Report>\n${tagUsers}`,
4242
};
4343

4444
const app = new App({

sanity-report.mjs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,16 @@ console.log(`Failed Tests: ${failedTests}`)
2525
console.log(`Pending Tests: ${pendingTests}`)
2626
console.log(`Total Duration: ${durationInMinutes}m ${durationInSeconds.toFixed(2)}s`)
2727

28+
const host = process.env.HOST || ''
29+
let region = 'NA'
30+
31+
const match = host.match(/^([^-]+(?:-[^-]+)*)-api/)
32+
if (match && match[1]) {
33+
region = match[1].toUpperCase()
34+
}
35+
2836
const slackMessage = `
29-
*JavaScript CMA Report*
37+
*JavaScript CMA Report - ${region}*
3038
• Total Suites: *${totalSuites}*
3139
• Total Tests: *${totalTests}*
3240
• Passed Tests: *${passedTests}*

test/sanity-check/api/deliveryToken-test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ describe('Delivery Token api Test', () => {
2424
expect(token.scope[0].environments[0].name).to.be.equal(createDeliveryToken.token.scope[0].environments[0])
2525
expect(token.scope[0].module).to.be.equal(createDeliveryToken.token.scope[0].module)
2626
expect(token.uid).to.be.not.equal(null)
27+
expect(token.preview_token).to.be.not.equal(null)
2728
done()
2829
})
2930
.catch(done)
@@ -39,6 +40,7 @@ describe('Delivery Token api Test', () => {
3940
expect(token.scope[0].environments[0].name).to.be.equal(createDeliveryToken2.token.scope[0].environments[0])
4041
expect(token.scope[0].module).to.be.equal(createDeliveryToken2.token.scope[0].module)
4142
expect(token.uid).to.be.not.equal(null)
43+
expect(token.preview_token).to.be.not.equal(null)
4244
done()
4345
})
4446
.catch(done)

0 commit comments

Comments
 (0)