Skip to content

Commit

Permalink
Merge pull request #136 from contentstack/next
Browse files Browse the repository at this point in the history
sanity test and snyk issues
  • Loading branch information
abhinav-from-contentstack authored Mar 28, 2024
2 parents a96ec14 + 37998e0 commit e9788af
Show file tree
Hide file tree
Showing 14 changed files with 233 additions and 78 deletions.
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.4](https://github.com/contentstack/contentstack-management-javascript/tree/v1.15.4) (2024-03-28)
- Fixes and Enhancement
- delete stack implemetation and test cases
- sanity test and dependency upgrades
## [v1.15.3](https://github.com/contentstack/contentstack-management-javascript/tree/v1.15.3) (2024-02-16)
- Fix
- Fix for updating entry
Expand Down
3 changes: 2 additions & 1 deletion lib/core/concurrency-queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ export function ConcurrencyQueue ({ axios, config }) {
code: 'Unauthorized',
message: 'Unable to refresh token',
name: 'Token Error',
config: queueItem.request
config: queueItem.request,
stack: (error instanceof Error) ? error.stack : null,
})
})
this.queue = []
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
111 changes: 43 additions & 68 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@contentstack/management",
"version": "1.15.3",
"version": "1.15.4",
"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 Expand Up @@ -53,7 +53,7 @@
"license": "MIT",
"dependencies": {
"@slack/bolt": "^3.17.1",
"axios": "^1.6.5",
"axios": "^1.6.8",
"form-data": "^3.0.1",
"lodash": "^4.17.21",
"qs": "^6.11.2"
Expand Down
2 changes: 1 addition & 1 deletion sanity-report.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ console.log(`Pending Tests: ${pendingTests}`)
console.log(`Total Duration: ${durationInMinutes}m ${durationInSeconds.toFixed(2)}s`)

const slackMessage = `
*Test Summary*
*JavaScript CMA Report*
• Total Suites: *${totalSuites}*
• Total Tests: *${totalTests}*
• Passed Tests: *${passedTests}*
Expand Down
5 changes: 4 additions & 1 deletion test/sanity-check/api/asset-test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path from 'path'
import { expect } from 'chai'
import { describe, it, setup } from 'mocha'
import { jsonReader, writeDownloadedFile } from '../utility/fileOperations/readwrite'
import { jsonReader, jsonWrite, writeDownloadedFile } from '../utility/fileOperations/readwrite'
import { contentstackClient } from '../utility/ContentstackClient.js'

var client = {}
Expand All @@ -25,6 +25,7 @@ describe('Assets api Test', () => {
}
makeAsset().create(asset)
.then((asset) => {
jsonWrite(asset, 'publishAsset2.json')
assetUID = asset.uid
assetURL = asset.url
expect(asset.uid).to.be.not.equal(null)
Expand Down Expand Up @@ -58,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 All @@ -76,6 +78,7 @@ describe('Assets api Test', () => {
}
makeAsset().create(asset)
.then((asset) => {
jsonWrite(asset, 'publishAsset1.json')
publishAssetUID = asset.uid
expect(asset.uid).to.be.not.equal(null)
expect(asset.url).to.be.not.equal(null)
Expand Down
Loading

0 comments on commit e9788af

Please sign in to comment.