Skip to content

Commit b5aeab3

Browse files
authored
Merge pull request #224 from contentstack/staging
DX | 05-12-2024 | Release
2 parents 6af858e + c021cb0 commit b5aeab3

File tree

5 files changed

+1367
-1754
lines changed

5 files changed

+1367
-1754
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
# Changelog
2+
## [v1.18.4](https://github.com/contentstack/contentstack-management-javascript/tree/v1.18.4) (2024-11-22)
3+
- Enhancement
4+
- Added support for response headers.
5+
## [v1.18.3](https://github.com/contentstack/contentstack-management-javascript/tree/v1.18.3) (2024-11-8)
6+
- Fix
7+
- Fixed incorrect input type for bulk delete operation
28
## [v1.18.2](https://github.com/contentstack/contentstack-management-javascript/tree/v1.18.2) (2024-10-3)
39
- Fix
410
- Variants testcases Added

lib/contentstackCollection.js

+6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ export default class ContentstackCollection {
77
if (stackHeaders) {
88
data.stackHeaders = stackHeaders
99
}
10+
if (http?.httpClientParams?.headers?.includeResHeaders === true) {
11+
data.stackHeaders = {
12+
...data.stackHeaders,
13+
responseHeaders: response.headers,
14+
};
15+
}
1016
if (wrapperCollection) {
1117
this.items = wrapperCollection(http, data)
1218
}

lib/entity.js

+11-5
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export const create = ({ http, params }) => {
8484
try {
8585
const response = await http.post(this.urlPath, data, headers)
8686
if (response.data) {
87-
return new this.constructor(http, parseData(response, this.stackHeaders, this.content_type_uid, this.taxonomy_uid))
87+
return new this.constructor(http, parseData(response, this.stackHeaders, this.content_type_uid, this.taxonomy_uid, http))
8888
} else {
8989
if (response.status >= 200 && response.status < 300) {
9090
return {
@@ -152,7 +152,7 @@ export const update = (http, type, params = {}) => {
152152
}
153153
})
154154
if (response.data) {
155-
return new this.constructor(http, parseData(response, this.stackHeaders, this.content_type_uid, this.taxonomy_uid))
155+
return new this.constructor(http, parseData(response, this.stackHeaders, this.content_type_uid, this.taxonomy_uid, http))
156156
} else {
157157
throw error(response)
158158
}
@@ -211,7 +211,7 @@ export const fetch = (http, type, params = {}) => {
211211
response.data[type]['content_type'] = response.data['content_type']
212212
response.data[type]['schema'] = response.data['schema']
213213
}
214-
return new this.constructor(http, parseData(response, this.stackHeaders, this.content_type_uid, this.taxonomy_uid))
214+
return new this.constructor(http, parseData(response, this.stackHeaders, this.content_type_uid, this.taxonomy_uid, http))
215215
} else {
216216
throw error(response)
217217
}
@@ -242,7 +242,7 @@ export const fetchAll = (http, wrapperCollection, params = {}) => {
242242
}
243243
}
244244

245-
export function parseData (response, stackHeaders, contentTypeUID, taxonomy_uid) {
245+
export function parseData (response, stackHeaders, contentTypeUID, taxonomy_uid, http) {
246246
const data = response.data || {}
247247
if (stackHeaders) {
248248
data.stackHeaders = stackHeaders
@@ -253,6 +253,12 @@ export function parseData (response, stackHeaders, contentTypeUID, taxonomy_uid)
253253
if (taxonomy_uid) {
254254
data.taxonomy_uid = taxonomy_uid
255255
}
256+
if (http?.httpClientParams?.headers?.includeResHeaders === true) {
257+
data.stackHeaders = {
258+
...data.stackHeaders,
259+
responseHeaders: response.headers,
260+
};
261+
}
256262
return data
257263
}
258264

@@ -300,7 +306,7 @@ export const move = (http, type, force = false, params = {}) => {
300306
}
301307
const response = await http.put(`${this.urlPath}/move`, updateData, headers)
302308
if (response.data) {
303-
return new this.constructor(http, parseData(response, this.stackHeaders, this.content_type_uid, this.taxonomy_uid))
309+
return new this.constructor(http, parseData(response, this.stackHeaders, this.content_type_uid, this.taxonomy_uid, http))
304310
} else {
305311
throw error(response)
306312
}

0 commit comments

Comments
 (0)