Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## [v1.19.6](https://github.com/contentstack/contentstack-management-javascript/tree/v1.19.6) (2025-03-24)
- Fix
- Added stack headers in global fields response
## [v1.19.5](https://github.com/contentstack/contentstack-management-javascript/tree/v1.19.5) (2025-03-17)
- Fix
- Added AuditLog in the stack class
Expand Down
46 changes: 33 additions & 13 deletions lib/stack/globalField/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,12 @@ export function GlobalField (http, data = {}) {
if (this.apiVersion) {
delete this.stackHeaders.api_version
}
if (response.data) {
return response.data
const data = response.data
if (data) {
if (this.stackHeaders) {
data.stackHeaders = this.stackHeaders
}
return data
} else {
throw error(response)
}
Expand Down Expand Up @@ -105,8 +109,12 @@ export function GlobalField (http, data = {}) {
headers: { ...cloneDeep(this.stackHeaders) }
}
const response = await http.put(`${this.urlPath}`, config, headers)
if (response.data) {
return response.data
const data = response.data
if (data) {
if (this.stackHeaders) {
data.stackHeaders = this.stackHeaders
}
return data
} else {
throw error(response)
}
Expand Down Expand Up @@ -146,8 +154,12 @@ export function GlobalField (http, data = {}) {
if (this.apiVersion) {
delete this.stackHeaders.api_version
}
if (response.data) {
return response.data
const data = response.data
if (data) {
if (this.stackHeaders) {
data.stackHeaders = this.stackHeaders
}
return data
} else {
throw error(response)
}
Expand Down Expand Up @@ -183,8 +195,12 @@ export function GlobalField (http, data = {}) {
}
}
const response = await http.get(this.urlPath, headers)
if (response.data) {
return response.data
const data = response.data
if (data) {
if (this.stackHeaders) {
data.stackHeaders = this.stackHeaders
}
return data
} else {
throw error(response)
}
Expand Down Expand Up @@ -214,7 +230,7 @@ export function GlobalField (http, data = {}) {
* client.stack().globalField().create({ global_field })
* .then((globalField) => console.log(globalField))
*/
this.create = async (data) => {
this.create = async (payload) => {
try {
if (this.apiVersion) {
this.stackHeaders.api_version = this.apiVersion
Expand All @@ -224,11 +240,15 @@ export function GlobalField (http, data = {}) {
...cloneDeep(this.stackHeaders)
}
}
const response = await http.post(`${this.urlPath}`, data, headers)
if (response.data) {
return response.data
const response = await http.post(`${this.urlPath}`, payload, headers)
const data = response.data
if (data) {
if (this.stackHeaders) {
data.stackHeaders = this.stackHeaders
}
return data
} else {
return error(response)
throw error(response)
}
} catch (err) {
return error(err)
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@contentstack/management",
"version": "1.19.5",
"version": "1.19.6",
"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",
Expand Down
1 change: 0 additions & 1 deletion types/stack/globalField/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export interface GlobalField extends SystemFields, SystemFunction<GlobalField> {

export interface GlobalFields extends Queryable<GlobalField, {global_field: GlobalFieldData}> {
import(data: {global_field: string}, params?: any): Promise<GlobalField>
(globalFieldUidOrOptions: string | { api_version?: string }, options?: { api_version?: string }): GlobalField;
}

export interface GlobalFieldData extends AnyProperty {
Expand Down
10 changes: 6 additions & 4 deletions types/stack/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@ export interface Stack extends SystemFields {
contentType(): ContentTypes
contentType(uid: string): ContentType

globalField(): GlobalFields
globalField({}): GlobalFields
globalField(uid: string): GlobalField
globalField(uid: string, option: object): GlobalField
globalField(): GlobalFields;
globalField(uid: string, option?: object): GlobalField;
globalField(options: { api_version: string }): GlobalFields;
globalField(uidOrOptions?: string | { api_version: string }, option?: object): GlobalFields | GlobalField;



asset(): Assets
asset(uid: string): Asset
Expand Down
Loading