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

updated management token expiry value #227

Merged
merged 29 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ebd95f3
Merge pull request #194 from contentstack/next
aman19K Sep 26, 2024
f4c759f
Updated node version 22 support and fixed testcases (#195)
sunil-lakshman Sep 30, 2024
d37a183
Updated node version 22 support and fixed testcases (#195) (#196)
sunil-lakshman Oct 1, 2024
fc215bd
Updated testcases (#198)
sunil-lakshman Oct 1, 2024
164f2fb
Back merge (#199)
sunil-lakshman Oct 1, 2024
f584d37
Merge pull request #197 from contentstack/staging
cs-raj Oct 7, 2024
3f25c9f
Merge pull request #200 from contentstack/master
cs-raj Oct 7, 2024
a36da5e
fix: fixed delete config interface
Oct 8, 2024
db668e7
fix: updated version
Oct 10, 2024
b227bca
fix: npm script fix
Oct 14, 2024
9cb874a
Merge pull request #202 from contentstack/fix/DX-1407
netrajpatel Oct 15, 2024
39a6a6c
Merge branch 'staging' into development
cs-raj Oct 22, 2024
b21a4e6
version bump
cs-raj Oct 22, 2024
e7132a5
Merge pull request #203 from contentstack/fix/development
cs-raj Oct 22, 2024
6111815
Merge pull request #204 from contentstack/development
cs-raj Oct 22, 2024
6af858e
Merge pull request #206 from contentstack/staging
cs-raj Nov 8, 2024
1c56430
Merge pull request #211 from contentstack/master
cs-raj Nov 8, 2024
f57c0b2
Merge pull request #213 from contentstack/staging
cs-raj Nov 8, 2024
f8bfec6
Added support for returning response headers (#218)
sunil-lakshman Nov 19, 2024
8324295
lock-file update
cs-raj Nov 22, 2024
77ba933
Merge pull request #220 from contentstack/fix/dev3
cs-raj Nov 28, 2024
97eb667
version bump
cs-raj Nov 28, 2024
bd282d8
Merge pull request #223 from contentstack/fix/dev4
cs-raj Nov 28, 2024
c021cb0
Merge pull request #222 from contentstack/development
cs-raj Nov 28, 2024
b5aeab3
Merge pull request #224 from contentstack/staging
cs-raj Dec 5, 2024
be3c34a
Merge pull request #225 from contentstack/master
cs-raj Dec 5, 2024
0e5105b
Merge pull request #226 from contentstack/staging
cs-raj Dec 5, 2024
7e7c15e
updated management token expiry value
harshithad0703 Dec 11, 2024
62c5962
Merge branch 'development' into sanity/update-token-expiry
harshithad0703 Dec 11, 2024
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
4 changes: 2 additions & 2 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '20.x'
node-version: '22.x'
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm publish
Expand All @@ -25,7 +25,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '20.x'
node-version: '22.x'
registry-url: 'https://npm.pkg.github.com'
scope: '@contentstack'
- run: npm ci
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v2 # checkout the repo
- uses: actions/setup-node@v3
with:
node-version: '20.x'
node-version: '22.x'
registry-url: 'https://registry.npmjs.org'
- run: npm ci # install packages
- run: npm run test:unit:report:json # run tests (configured to use jest-junit reporter)
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
# 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
- Node v22 support
## [v1.18.1](https://github.com/contentstack/contentstack-management-javascript/tree/v1.18.1) (2024-09-27)
- 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
35 changes: 18 additions & 17 deletions lib/stack/variantGroup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,6 @@ export function VariantGroup (http, data = {}) {
*/
this.delete = deleteEntity(http)

/**
* @description The fetch VariantGroup call fetches VariantGroup details.
* @memberof VariantGroup
* @func fetch
* @returns {Promise<VariantGroup.VariantGroup>} Promise for VariantGroup instance
* @param {Int} version Enter the unique ID of the content type of which you want to retrieve the details. The UID is generated based on the title of the content type. The unique ID of a content type is unique across a stack.
* @example
* import * as contentstack from '@contentstack/management'
* const client = contentstack.client()
*
* client.stack({ api_key: 'api_key'}).VariantGroup('variant_group_uid').fetch()
* .then((variant_group) => console.log(variant_group))
*
*/
// this.fetch = fetch(http, 'variant_group')

/**
* @description Content type defines the structure or schema of a page or a section of your web or mobile property.
* @param {String} uid The UID of the ContentType you want to get details.
Expand Down Expand Up @@ -115,7 +99,24 @@ export function VariantGroup (http, data = {}) {
* client.stack().VariantGroup().create({ variant_group } )
* .then((variant_group) => console.log(variant_group))
*/
this.create = create({ http: http })
this.create = async (data) => {
try {
const response = await http.post(`${this.urlPath}`,
data ,
{
headers: {
...cloneDeep(this.stackHeaders)
}
})
if (response.data) {
return response.data
} else {
return error(response)
}
} catch (err) {
return error(err)
}
}

/**
* @description The Query on Variant Groups will allow to fetch details of all or specific Variant Groups
Expand Down
39 changes: 37 additions & 2 deletions lib/stack/variantGroup/variants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,25 @@ export function Variants(http, data = {}) {
* .then((variants) => console.log(variants))
*
*/
this.fetch = fetch(http, 'variants')
this.fetch = async (param = {}) => {
try {
const headers = {
headers: { ...cloneDeep(this.stackHeaders) },
params: {
...cloneDeep(param)
}
} || {}

const response = await http.get(this.urlPath, headers)
if (response.data) {
return response.data
} else {
throw error(response)
}
} catch (err) {
error(err)
}
}

/**
* @description The Delete Variant call is used to delete an existing Variant permanently from your Stack.
Expand Down Expand Up @@ -98,7 +116,24 @@ export function Variants(http, data = {}) {
* client.stack().VariantGroup('variant_group_uid').variants().create({ data } )
* .then((variants) => console.log(variants))
*/
this.create = create({ http: http })
this.create = async (data) => {
try {
const response = await http.post(`${this.urlPath}`,
data ,
{
headers: {
...cloneDeep(this.stackHeaders)
}
})
if (response.data) {
return response.data
} else {
return error(response)
}
} catch (err) {
return error(err)
}
}

/**
* @description The Query on Variant Groups will allow to fetch details of all or specific Variant Groups
Expand Down
39 changes: 37 additions & 2 deletions lib/stack/variants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,25 @@ export function Variants (http, data) {
* .then((variants) => console.log(variants))
*
*/
this.fetch = fetch(http, 'variants')
this.fetch = async (param = {}) => {
try {
const headers = {
headers: { ...cloneDeep(this.stackHeaders) },
params: {
...cloneDeep(param)
}
} || {}

const response = await http.get(this.urlPath, headers)
if (response.data) {
return response.data
} else {
throw error(response)
}
} catch (err) {
error(err)
}
}
} else {
/**
* @description The Create an variants call creates a new variants.
Expand All @@ -68,7 +86,24 @@ export function Variants (http, data) {
* client.stack().variants().create({ variants })
* .then((variants) => console.log(variants))
*/
this.create = create({ http })
this.create = async (data) => {
try {
const response = await http.post(`${this.urlPath}`,
data ,
{
headers: {
...cloneDeep(this.stackHeaders)
}
})
if (response.data) {
return response.data
} else {
return error(response)
}
} catch (err) {
return error(err)
}
}

/**
* @description The Query on Variants will allow to fetch details of all or specific Variants.
Expand Down
Loading
Loading