diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 4f827b78..94c94b3b 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -25,7 +25,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: - node-version: '12.x' + node-version: '20.x' registry-url: 'https://npm.pkg.github.com' scope: '@contentstack' - run: npm ci diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a34cb6a..5207ede5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,9 @@ # Changelog +## [v1.17.0](https://github.com/contentstack/contentstack-management-javascript/tree/v1.17.0) (2024-07-02) + - Enhancement + - Fixed package publish issue in github workflow + - Added Taxonomy permission roles test cases + - SNYK issues - Upgraded axios and slack/bolt packages version ## [v1.16.2](https://github.com/contentstack/contentstack-management-javascript/tree/v1.16.2) (2024-06-24) - Enhancement diff --git a/package-lock.json b/package-lock.json index f928afad..92afbfb1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,15 @@ { "name": "@contentstack/management", - "version": "1.16.2", + "version": "1.17.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@contentstack/management", - "version": "1.16.2", + "version": "1.17.0", "license": "MIT", "dependencies": { - "axios": "^1.6.8", + "axios": "^1.7.2", "form-data": "^3.0.1", "lodash": "^4.17.21", "qs": "^6.12.1" @@ -21,7 +21,7 @@ "@babel/preset-env": "^7.18.2", "@babel/register": "^7.17.7", "@babel/runtime": "^7.18.3", - "@slack/bolt": "^3.18.0", + "@slack/bolt": "^3.19.0", "@types/chai": "^4.3.11", "@types/jest": "^28.1.0", "@types/lodash": "^4.14.202", @@ -3154,9 +3154,9 @@ "license": "(Unlicense OR Apache-2.0)" }, "node_modules/@slack/bolt": { - "version": "3.18.0", - "resolved": "https://registry.npmjs.org/@slack/bolt/-/bolt-3.18.0.tgz", - "integrity": "sha512-A7bDi5kY50fS6/nsmURkQdO3iMxD8aX/rA+m1UXEM2ue2z4KijeQtx2sOZ4YkJQ/h7BsgTQM0CYh3qqmo+m5sQ==", + "version": "3.19.0", + "resolved": "https://registry.npmjs.org/@slack/bolt/-/bolt-3.19.0.tgz", + "integrity": "sha512-P5Yup/PbO8sE5xsuqkBkpSPkxEkfWZ6yo5ZlmBGxRhhoU1usUSU2w0bgZoiDX4WFm7ZX+3x2Dyf4VMa9kzfmVQ==", "dev": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index 2761f129..3ce9d10f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@contentstack/management", - "version": "1.16.2", + "version": "1.17.0", "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", @@ -52,7 +52,7 @@ "author": "Contentstack", "license": "MIT", "dependencies": { - "axios": "^1.6.8", + "axios": "^1.7.2", "form-data": "^3.0.1", "lodash": "^4.17.21", "qs": "^6.12.1" @@ -69,7 +69,7 @@ "@babel/preset-env": "^7.18.2", "@babel/register": "^7.17.7", "@babel/runtime": "^7.18.3", - "@slack/bolt": "^3.18.0", + "@slack/bolt": "^3.19.0", "@types/chai": "^4.3.11", "@types/jest": "^28.1.0", "@types/lodash": "^4.14.202", diff --git a/test/api/mock/role.js b/test/api/mock/role.js index 6d748215..ce81f195 100644 --- a/test/api/mock/role.js +++ b/test/api/mock/role.js @@ -14,6 +14,36 @@ const role = { module: 'locale', locales: [], acl: { read: true } + }, + { + module: "taxonomy", + taxonomies: ["taxonomy_testing1"], + terms: ["taxonomy_testing1.term_test1"], + content_types: [ + { + uid: "$all", + acl: { + read: true, + sub_acl: { + read: true, + create: true, + update: true, + delete: true, + publish: true + } + } + } + ], + acl: { + read: true, + sub_acl: { + read: true, + create: true, + update: true, + delete: true, + publish: true + } + } } ], uid: 'role_uid' diff --git a/test/sanity-check/api/contentType-test.js b/test/sanity-check/api/contentType-test.js index 27623ba5..12b0b54f 100644 --- a/test/sanity-check/api/contentType-test.js +++ b/test/sanity-check/api/contentType-test.js @@ -7,6 +7,7 @@ import { contentstackClient } from '../utility/ContentstackClient.js' let client = {} let multiPageCTUid = '' +let multiPageUpdateCTUid = 'multi_page' describe('Content Type api Test', () => { setup(() => { @@ -93,17 +94,17 @@ describe('Content Type api Test', () => { }) .catch(done) }) - // it('should update Multi page ContentType Schema without fetch', done => { - // makeContentType() - // .updateCT(multiPageCT) - // .then((contentType) => { - // multiPageCTUid = contentType.uid - // expect(contentType.uid).to.be.equal(multiPageCT.content_type.uid) - // expect(contentType.title).to.be.equal(multiPageCT.content_type.title) - // done() - // }) - // .catch(done) - // }) + + it('should update Multi page ContentType Schema without fetch', done => { + makeContentType(multiPageCT.content_type.uid) + .updateCT(multiPageCT) + .then((contentType) => { + expect(contentType.content_type.schema.length).to.be.equal(2) + done() + }) + .catch(done) + }) + it('should import content type', done => { makeContentType().import({ diff --git a/test/sanity-check/api/role-test.js b/test/sanity-check/api/role-test.js index d1a190c1..855db3c0 100644 --- a/test/sanity-check/api/role-test.js +++ b/test/sanity-check/api/role-test.js @@ -9,6 +9,19 @@ dotenv.config() let client = {} let roleUID = '' +const taxonomy = { + uid: 'taxonomy_testing1', + name: 'taxonomy testing1', + description: 'Description for Taxonomy testing' +} +const term = { + term: { + uid: 'term_test1', + name: 'Term test1', + parent_uid: null + } +} + describe('Role api test', () => { setup(() => { const user = jsonReader('loggedinuser.json') @@ -49,6 +62,19 @@ describe('Role api test', () => { .catch(done) }) + it('should create taxonomy', async () => { + await client.stack({ api_key: process.env.API_KEY }).taxonomy().create({ taxonomy }) + }) + + it('should create term', done => { + makeTerms(taxonomy.uid).create(term) + .then((response) => { + expect(response.uid).to.be.equal(term.term.uid) + done() + }) + .catch(done) + }) + it('should create new role in stack', done => { getRole() .create(role) @@ -141,8 +167,28 @@ describe('Role api test', () => { }) .catch(done) }) + it('should delete of the term uid passed', done => { + makeTerms(taxonomy.uid, term.term.uid).delete({ force: true }) + .then((response) => { + expect(response.status).to.be.equal(204) + done() + }) + .catch(done) + }) + + it('should delete taxonomy', async () => { + const taxonomyResponse = await client.stack({ api_key: process.env.API_KEY }).taxonomy(taxonomy.uid).delete({ force: true }) + expect(taxonomyResponse.status).to.be.equal(204) + }) + }) function getRole (uid = null) { return client.stack({ api_key: process.env.API_KEY }).role(uid) } + + +function makeTerms (taxonomyUid, termUid = null) { + return client.stack({ api_key: process.env.API_KEY }).taxonomy(taxonomyUid).terms(termUid) +} + diff --git a/test/sanity-check/mock/role.js b/test/sanity-check/mock/role.js index 343bec72..260b7d32 100644 --- a/test/sanity-check/mock/role.js +++ b/test/sanity-check/mock/role.js @@ -74,6 +74,36 @@ const role = { acl: { read: true } + }, + { + module: "taxonomy", + taxonomies: ["taxonomy_testing1"], + terms: ["taxonomy_testing1.term_test1"], + content_types: [ + { + uid: "$all", + acl: { + read: true, + sub_acl: { + read: true, + create: true, + update: true, + delete: true, + publish: true + } + } + } + ], + acl: { + read: true, + sub_acl: { + read: true, + create: true, + update: true, + delete: true, + publish: true + } + } } ] } diff --git a/test/unit/mock/objects.js b/test/unit/mock/objects.js index 5c44bad5..3f7a5ff1 100644 --- a/test/unit/mock/objects.js +++ b/test/unit/mock/objects.js @@ -143,6 +143,89 @@ const roleMock = { ...adminRoleMock, admin: false } +const roleMockWithTaxonomy = { + ...systemFieldsMock, + ...systemFieldsUserMock, + name: "Admin", + description: "Admin Role", + rules: [ + { + module: "branch", + branches: [ + "main" + ], + acl: { + read: true + } + }, + { + module: "environment", + environments: ["env_uid1", "env_uid2"], + acl: { + read: true + } + }, + { + module: "locale", + locales: ["locales"], + acl: { + read: true + } + }, + { + module: "taxonomy", + taxonomies: ["taxonomy_1"], + terms: ["taxonomy_1.term_1"], + content_types: [ + { + uid: "$all", + acl: { + read: true, + sub_acl: { + read: true, + create: true, + update: true, + delete: true, + publish: true + } + } + } + ], + acl: { + read: true, + sub_acl: { + read: true, + create: true, + update: true, + delete: true, + publish: true + } + } + }, + { + module: "content_type", + content_types: ["ct_1"], + acl: { + read: true, + sub_acl: { + read: true, + create: true, + update: true, + delete: true, + publish: true + } + } + } + ], + org_uid: "org_uid", + api_key: "api_key", + admin: false, + default: true, + users: [ + 'user_uid' + ] + } + const branchMock = { ...systemFieldsMock, ...systemFieldsUserMock, @@ -897,5 +980,6 @@ export { mockCollection, entryMockCollection, checkSystemFields, - managementTokenMock + managementTokenMock, + roleMockWithTaxonomy } diff --git a/test/unit/role-test.js b/test/unit/role-test.js index 0f11b949..c926650f 100644 --- a/test/unit/role-test.js +++ b/test/unit/role-test.js @@ -3,7 +3,7 @@ import { expect } from 'chai' import { describe, it } from 'mocha' import MockAdapter from 'axios-mock-adapter' import { Role, RoleCollection } from '../../lib/stack/roles' -import { systemUidMock, stackHeadersMock, roleMock, noticeMock } from './mock/objects' +import { systemUidMock, stackHeadersMock, roleMock, noticeMock, roleMockWithTaxonomy} from './mock/objects' describe('Contentstack Role test', () => { it('Role test without uid', done => { @@ -88,6 +88,22 @@ describe('Contentstack Role test', () => { .catch(done) }) + it('Role create test with taxonomy permission', done => { + var mock = new MockAdapter(Axios) + mock.onPost('/roles').reply(200, { + role: { + ...roleMockWithTaxonomy + } + }) + makeRole() + .create() + .then((role) => { + checkRole(role) + done() + }) + .catch(done) + }) + it('Role Fetch all without Stack Headers test', done => { var mock = new MockAdapter(Axios) mock.onGet('/roles').reply(200, {