Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DX | 05-12-2024 | Release #222

Merged
merged 6 commits into from
Nov 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# Changelog
## [v1.18.4](https://github.com/contentstack/contentstack-management-javascript/tree/v1.18.4) (2024-11-22)
- Enhancement
- Added support for response headers.
## [v1.18.3](https://github.com/contentstack/contentstack-management-javascript/tree/v1.18.3) (2024-11-8)
- Fix
- Fixed incorrect input type for bulk delete operation
## [v1.18.2](https://github.com/contentstack/contentstack-management-javascript/tree/v1.18.2) (2024-10-3)
- Fix
- Variants testcases Added
6 changes: 6 additions & 0 deletions lib/contentstackCollection.js
Original file line number Diff line number Diff line change
@@ -7,6 +7,12 @@ export default class ContentstackCollection {
if (stackHeaders) {
data.stackHeaders = stackHeaders
}
if (http?.httpClientParams?.headers?.includeResHeaders === true) {
data.stackHeaders = {
...data.stackHeaders,
responseHeaders: response.headers,
};
}
if (wrapperCollection) {
this.items = wrapperCollection(http, data)
}
16 changes: 11 additions & 5 deletions lib/entity.js
Original file line number Diff line number Diff line change
@@ -84,7 +84,7 @@ export const create = ({ http, params }) => {
try {
const response = await http.post(this.urlPath, data, headers)
if (response.data) {
return new this.constructor(http, parseData(response, this.stackHeaders, this.content_type_uid, this.taxonomy_uid))
return new this.constructor(http, parseData(response, this.stackHeaders, this.content_type_uid, this.taxonomy_uid, http))
} else {
if (response.status >= 200 && response.status < 300) {
return {
@@ -152,7 +152,7 @@ export const update = (http, type, params = {}) => {
}
})
if (response.data) {
return new this.constructor(http, parseData(response, this.stackHeaders, this.content_type_uid, this.taxonomy_uid))
return new this.constructor(http, parseData(response, this.stackHeaders, this.content_type_uid, this.taxonomy_uid, http))
} else {
throw error(response)
}
@@ -211,7 +211,7 @@ export const fetch = (http, type, params = {}) => {
response.data[type]['content_type'] = response.data['content_type']
response.data[type]['schema'] = response.data['schema']
}
return new this.constructor(http, parseData(response, this.stackHeaders, this.content_type_uid, this.taxonomy_uid))
return new this.constructor(http, parseData(response, this.stackHeaders, this.content_type_uid, this.taxonomy_uid, http))
} else {
throw error(response)
}
@@ -242,7 +242,7 @@ export const fetchAll = (http, wrapperCollection, params = {}) => {
}
}

export function parseData (response, stackHeaders, contentTypeUID, taxonomy_uid) {
export function parseData (response, stackHeaders, contentTypeUID, taxonomy_uid, http) {
const data = response.data || {}
if (stackHeaders) {
data.stackHeaders = stackHeaders
@@ -253,6 +253,12 @@ export function parseData (response, stackHeaders, contentTypeUID, taxonomy_uid)
if (taxonomy_uid) {
data.taxonomy_uid = taxonomy_uid
}
if (http?.httpClientParams?.headers?.includeResHeaders === true) {
data.stackHeaders = {
...data.stackHeaders,
responseHeaders: response.headers,
};
}
return data
}

@@ -300,7 +306,7 @@ export const move = (http, type, force = false, params = {}) => {
}
const response = await http.put(`${this.urlPath}/move`, updateData, headers)
if (response.data) {
return new this.constructor(http, parseData(response, this.stackHeaders, this.content_type_uid, this.taxonomy_uid))
return new this.constructor(http, parseData(response, this.stackHeaders, this.content_type_uid, this.taxonomy_uid, http))
} else {
throw error(response)
}
3,067 changes: 1,331 additions & 1,736 deletions package-lock.json

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@contentstack/management",
"version": "1.18.3",
"version": "1.18.4",
"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",
@@ -52,27 +52,27 @@
"author": "Contentstack",
"license": "MIT",
"dependencies": {
"axios": "^1.7.4",
"form-data": "^3.0.1",
"axios": "^1.7.8",
"form-data": "^3.0.2",
"lodash": "^4.17.21",
"qs": "^6.13.0"
"qs": "^6.13.1"
},
"keywords": [
"contentstack management api",
"contentstack",
"management api"
],
"devDependencies": {
"@babel/cli": "^7.25.7",
"@babel/core": "^7.25.8",
"@babel/plugin-transform-runtime": "^7.25.7",
"@babel/preset-env": "^7.25.8",
"@babel/register": "^7.25.7",
"@babel/runtime": "^7.25.7",
"@babel/cli": "^7.25.9",
"@babel/core": "^7.26.0",
"@babel/plugin-transform-runtime": "^7.25.9",
"@babel/preset-env": "^7.26.0",
"@babel/register": "^7.25.9",
"@babel/runtime": "^7.26.0",
"@slack/bolt": "^3.22.0",
"@types/chai": "^4.3.20",
"@types/jest": "^28.1.8",
"@types/lodash": "^4.17.12",
"@types/lodash": "^4.17.13",
"@types/mocha": "^7.0.2",
"axios-mock-adapter": "^1.22.0",
"babel-loader": "^8.4.1",
@@ -104,9 +104,9 @@
"string-replace-loader": "^3.1.0",
"ts-jest": "^28.0.8",
"typescript": "^4.9.5",
"webpack": "^5.95.0",
"webpack": "^5.96.1",
"webpack-cli": "^4.10.0",
"webpack-merge": "4.1.5",
"webpack-merge": "4.2.2",
"@slack/bolt": "^3.22.0"
},
"homepage": "https://www.contentstack.com"