Skip to content

Commit b77bc00

Browse files
Implemented preview token generation
1 parent 02afcaf commit b77bc00

File tree

6 files changed

+17
-8
lines changed

6 files changed

+17
-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: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,19 +85,23 @@ export const upload = async ({ http, urlPath, stackHeaders, formData, params, me
8585
}
8686
}
8787

88-
export const create = ({ http, params }) => {
88+
// eslint-disable-next-line camelcase
89+
export const create = ({ http, params = {}, create_with_preview_token = false }) => {
8990
return async function (data, param) {
9091
this.stackHeaders = {
9192
...this.stackHeaders
9293
}
94+
const queryParams = {
95+
// eslint-disable-next-line camelcase
96+
...(create_with_preview_token ? { create_with_preview_token: true } : {}),
97+
...cloneDeep(param) // user param can override default
98+
}
9399
const headers = {
94100
headers: {
95101
...cloneDeep(params),
96102
...cloneDeep(this.stackHeaders)
97103
},
98-
params: {
99-
...cloneDeep(param)
100-
}
104+
params: queryParams
101105
} || {}
102106

103107
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, create_with_preview_token: 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)