Skip to content

Commit 7a5e905

Browse files
Merge pull request #350 from contentstack/Enh/dx-2922
Implemented preview token generation
2 parents 02afcaf + 64c04eb commit 7a5e905

File tree

6 files changed

+15
-8
lines changed

6 files changed

+15
-8
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",

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)