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

## [v1.15.5](https://github.com/contentstack/contentstack-management-javascript/tree/v1.15.4) (2024-04-02)
- Enhancement
- delete stack implemetation and test cases

## [v1.15.4](https://github.com/contentstack/contentstack-management-javascript/tree/v1.15.4) (2024-03-26)
- Fixes
- sanity test and dependency upgrades
Expand Down
19 changes: 17 additions & 2 deletions lib/stack/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import cloneDeep from 'lodash/cloneDeep'
import error from '../core/contentstackError'
import { UserCollection } from '../user/index'
import { Role } from './roles/index'
import { create, query, update, fetch } from '../entity'
import { create, query, update, fetch, deleteEntity } from '../entity'
import { ContentType } from './contentType/index'
import { GlobalField } from './globalField/index'
import { DeliveryToken } from './deliveryToken/index'
Expand Down Expand Up @@ -259,7 +259,7 @@ export function Stack (http, data) {
}

/**
* @description Management Tokens are tokens that provide you with read-write access to the content of your stack.
* @description Management Tokens are tokens that provide you with read-write access to the content of your stack.
* @param {String} managementTokenUid The UID of the Management Token field you want to get details.
* @returns {ManagementToken} Instance of ManagementToken.
* @example
Expand Down Expand Up @@ -730,6 +730,21 @@ export function Stack (http, data) {
}
return new Taxonomy(http, data)
}

/**
* @description The delete stack call lets you delete the stack.
* @memberof Stack
* @func delete
* @returns {Promise<Stack.Stack>} Promise for Stack instance
* @example
* import * as contentstack from '@contentstack/management'
* const client = contentstack.client()
*
* client.stack({ api_key: 'api_key'}).delete()
* .then((stack) => console.log(stack))
*
*/
this.delete = deleteEntity(http)
} else {
/**
* @description The Create stack call creates a new stack in your Contentstack account.
Expand Down
81 changes: 28 additions & 53 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.15.4",
"version": "1.15.5",
"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: 1 addition & 0 deletions test/sanity-check/api/asset-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ describe('Assets api Test', () => {
makeAsset().folder().create({ asset: { name: 'Sample Folder' } })
.then((asset) => {
folderUID = asset.uid
jsonWrite(asset, 'folder.json')
expect(asset.uid).to.be.not.equal(null)
expect(asset.name).to.be.equal('Sample Folder')
expect(asset.is_dir).to.be.equal(true)
Expand Down
23 changes: 23 additions & 0 deletions test/sanity-check/api/delete-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,25 @@ describe('Branch Alias delete api Test', () => {
})
})

describe('Delete Asset Folder api Test', () => {
let folderUid = ''
setup(() => {
const user = jsonReader('loggedinuser.json')
const folder = jsonReader('folder.json')
folderUid = folder.uid
client = contentstackClient(user.authtoken)
})
it('should delete an environment', done => {
makeAssetFolder(folderUid)
.delete()
.then((data) => {
expect(data.notice).to.be.equal('Folder deleted successfully.')
done()
})
.catch(done)
})
})

function makeEnvironment (uid = null) {
return client.stack({ api_key: process.env.API_KEY }).environment(uid)
}
Expand All @@ -138,3 +157,7 @@ function makeDeliveryToken (uid = null) {
function makeBranchAlias (uid = null) {
return client.stack({ api_key: process.env.API_KEY }).branchAlias(uid)
}

function makeAssetFolder (uid = null) {
return client.stack({ api_key: process.env.API_KEY }).asset().folder(uid)
}
10 changes: 10 additions & 0 deletions test/sanity-check/api/stack-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,16 @@ describe('Stack api Test', () => {
})
.catch(done)
})

it('should delete stack', done => {
client.stack({ api_key: stacks.api_key })
.delete()
.then((stack) => {
expect(stack.notice).to.be.equal('Stack deleted successfully!')
done()
})
.catch(done)
})
})

describe('Branch creation api Test', () => {
Expand Down