From d3d26c5e9cc219135f5a1c4f58f67dee81154fd4 Mon Sep 17 00:00:00 2001 From: "harshitha.d" Date: Mon, 17 Mar 2025 15:31:15 +0530 Subject: [PATCH 1/5] fix: update copyright year in README.md to 2025 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9ae2fe35..921f2a1b 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,7 @@ contentstackClient.stack({ api_key: 'API_KEY' }).asset().create({ asset }) - [Content Management API Docs](https://www.contentstack.com/docs/developers/apis/content-management-api) ### The MIT License (MIT) -Copyright © 2012-2024 [Contentstack](https://www.contentstack.com/). All Rights Reserved +Copyright © 2012-2025 [Contentstack](https://www.contentstack.com/). All Rights Reserved Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: From e004efbba50cc90b8bcef324303a1de870812e7b Mon Sep 17 00:00:00 2001 From: sunil-lakshman <104969541+sunil-lakshman@users.noreply.github.com> Date: Tue, 18 Mar 2025 22:42:08 +0530 Subject: [PATCH 2/5] Fixed CLI error issue --- lib/stack/globalField/index.js | 43 ++++++++++++++++++++++-------- types/stack/globalField/index.d.ts | 1 - types/stack/index.d.ts | 10 ++++--- 3 files changed, 38 insertions(+), 16 deletions(-) diff --git a/lib/stack/globalField/index.js b/lib/stack/globalField/index.js index 682902ff..769fd0a7 100644 --- a/lib/stack/globalField/index.js +++ b/lib/stack/globalField/index.js @@ -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) } @@ -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) } @@ -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) } @@ -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) } @@ -224,11 +240,16 @@ export function GlobalField (http, data = {}) { ...cloneDeep(this.stackHeaders) } } + const response = await http.post(`${this.urlPath}`, data, headers) - if (response.data) { - return response.data + let 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) diff --git a/types/stack/globalField/index.d.ts b/types/stack/globalField/index.d.ts index c3c0bb36..70a4ab8b 100644 --- a/types/stack/globalField/index.d.ts +++ b/types/stack/globalField/index.d.ts @@ -8,7 +8,6 @@ export interface GlobalField extends SystemFields, SystemFunction { export interface GlobalFields extends Queryable { import(data: {global_field: string}, params?: any): Promise - (globalFieldUidOrOptions: string | { api_version?: string }, options?: { api_version?: string }): GlobalField; } export interface GlobalFieldData extends AnyProperty { diff --git a/types/stack/index.d.ts b/types/stack/index.d.ts index 2ee9d273..f0344b38 100644 --- a/types/stack/index.d.ts +++ b/types/stack/index.d.ts @@ -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 From eb1d48f7e9362e9ac68112a37c51a6c1050fbc0c Mon Sep 17 00:00:00 2001 From: sunil-lakshman <104969541+sunil-lakshman@users.noreply.github.com> Date: Tue, 18 Mar 2025 22:46:21 +0530 Subject: [PATCH 3/5] Fixed lint errors --- lib/stack/globalField/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/stack/globalField/index.js b/lib/stack/globalField/index.js index 769fd0a7..36b92944 100644 --- a/lib/stack/globalField/index.js +++ b/lib/stack/globalField/index.js @@ -240,9 +240,8 @@ export function GlobalField (http, data = {}) { ...cloneDeep(this.stackHeaders) } } - const response = await http.post(`${this.urlPath}`, data, headers) - let data = response.data + const data = response.data if (data) { if (this.stackHeaders) { data.stackHeaders = this.stackHeaders From 9a8bdcf0ae28022a7fa956ee57837059f0776786 Mon Sep 17 00:00:00 2001 From: sunil-lakshman <104969541+sunil-lakshman@users.noreply.github.com> Date: Tue, 18 Mar 2025 22:50:25 +0530 Subject: [PATCH 4/5] Fixed linting errors --- lib/stack/globalField/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/stack/globalField/index.js b/lib/stack/globalField/index.js index 36b92944..3f36cc82 100644 --- a/lib/stack/globalField/index.js +++ b/lib/stack/globalField/index.js @@ -230,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 @@ -240,7 +240,7 @@ export function GlobalField (http, data = {}) { ...cloneDeep(this.stackHeaders) } } - const response = await http.post(`${this.urlPath}`, data, headers) + const response = await http.post(`${this.urlPath}`, payload, headers) const data = response.data if (data) { if (this.stackHeaders) { From 76c65a5fbca963e934076f172922b0c6e1da5fd0 Mon Sep 17 00:00:00 2001 From: sunil-lakshman <104969541+sunil-lakshman@users.noreply.github.com> Date: Wed, 19 Mar 2025 14:56:56 +0530 Subject: [PATCH 5/5] Added version and changelog file --- CHANGELOG.md | 3 +++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 08500cf7..a704c532 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/package-lock.json b/package-lock.json index 4f66bd64..a7aea494 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@contentstack/management", - "version": "1.19.5", + "version": "1.19.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@contentstack/management", - "version": "1.19.5", + "version": "1.19.6", "license": "MIT", "dependencies": { "axios": "^1.8.2", diff --git a/package.json b/package.json index 691d9447..a60e84eb 100644 --- a/package.json +++ b/package.json @@ -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",