Skip to content

Commit

Permalink
Merge pull request #224 from contentstack/staging
Browse files Browse the repository at this point in the history
DX | 05-12-2024 | Release
  • Loading branch information
cs-raj authored Dec 5, 2024
2 parents 6af858e + c021cb0 commit b5aeab3
Show file tree
Hide file tree
Showing 5 changed files with 1,367 additions and 1,754 deletions.
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
Expand Down
6 changes: 6 additions & 0 deletions lib/contentstackCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
16 changes: 11 additions & 5 deletions lib/entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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
Expand All @@ -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
}

Expand Down Expand Up @@ -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)
}
Expand Down
Loading

0 comments on commit b5aeab3

Please sign in to comment.