Skip to content

Commit c7047f7

Browse files
sunil-lakshmannadeem-csishaileshmishraharshithad0703abhinav-from-contentstack
authored
Enh/dx 737 taxonomy permission (#161)
* chore: replaced uid and other data * refactor: adds and corrects types of ContentstackCollectin and marketplace functions * fix: credentials in response fix; bulkOperation types fixes; * test: ✅ improves code coverage * Revert "Feat: NRP support, Audit logs, Type correction for User and CScollection added" * fix: users, collection, other fixes, coverage improvements * build: updates package-lock file * chore: version changes in package file * ci: removed secrets-scan file and app tests changes * fix: type fix for environment param * fix: 🐛 handles the error in refreshtoken instead of throwing it * ci: 🔥 removed sast-scan yml file * fix: 🐛 handles workflow response in object format * feat: ✨ allows overwrite flag param in import of contenttype and global field * test: ✅ adds CT and GF import test for overwrite flag * refactor: ♻️ adds type support for overwrite flag param * chore: 📦 version changes and package updates * perf: 📦 packages update * docs: 📝 Updates README * feat: ✨ Taxonomy Implementation with docs, unit and api test cases * test: ✅ changes made in taxonomy function in stack class * test: uncommented 'detele' api test case * feat: ✨ create, fetch, find, update, delete , ancestors and descendants functions are added * test: ✅ added api test cases for terms implementation * feat: ✨ allows content-type for asset upload * test: ✅ unit test cases for terms implementation (except search and move) * changes done in passing data to create function in api test case * feat: ✨ added move and search functions for terms implementation * test: ✅ updated and added search and move unit test cases * test: ✅ updated and added search and move api test cases * docs: 📝 updated api reference docs for search, ancestors, descendants and move * build: 📦 updated axios module and version number * chore: 🔊 update changelog file * feat: ✨ taxonomy and terms implementation for typescript * fix: 🐛 taxonomy bug fix * feat: ✨ terms implementaion with descendants and move function * fix: 🐛 taxonomy bug fix in query unit test case * fix: taxonomy and terms fixes * fix: 🐛 error message fix on refresh token error * refactor: uncommented unit test cases * test: ✅ taxonomy API test cases * test: ✅ terms api test cases and search implementation * test: ✅ changes in search unit test in terms * changed default host name * added entry on changelog file and changed version * feat: ✨ teams implementation with unit and api tests * docs: added teams documentation * test: ✅ updated api and unit test cases for teams support * feat: ✨ teams users implementation and api test cases * test: ✅ added unit test cases for team users * feat: ✨ stackrolemapping implementation and api test cases * test: changes made in update implementation and its test case * test: update stackrolemapping implementation and api test cases * added assertions to check the response * added unit test cases for stack role mapping * replaced query with fetchAll function * changing folder name to be same as class name * ci: 💚 fix unit test github action * ci: fix unit test github action * feat: types support for teams * chore: ⬆️ update axios lib * added valid assertions for the test * teams test cases for types support * types support for team Users and api test cases * interface changed from User to TeamUser in types * types support for stackRoleMapping and test cases * stackRoleMapping test cases in types support * stackRoleMapping update test case on types support * docs: 📝 updated version and changeLog * test: added test cases to improve coverage report * feat: ✨ early access headers implementation * types support for earlyaccess and update changeLog * fix: 🐛 early_access made optional * fix: 🐛 added api_version param which is to be passed in headers * test: ✅ updated response fetchAll unit test case * fix: 🐛 create function response data update * refactor: ♻️ changes users in teams to teamUsers * fix: fixed issue while updating entries with assets * feat: added api test * fix: updated changelog and package lock file * Implemented Management token support (#99) * Implemented Management token support * Fixed PR Comments * test: added sanity tests for user and contenttype * added a script in package.json * Next (#97) * fix: fixed issue while updating entries with assets * feat: added api test * fix: updated changelog and package lock file * Implemented Management token support (#99) * Implemented Management token support * Fixed PR Comments * test: added sanity tests for user and contenttype * added a script in package.json --------- Co-authored-by: sunil-lakshman <[email protected]> Co-authored-by: harshithad0703 <[email protected]> Co-authored-by: harshithad0703 <[email protected]> * test: added entries, assets, organization and stack tests in sanity * changed the decription for it in testcases * test: added taxonomy and terms tests in sanity folder * removed const stack as the api is read from env * fix: changed the url in transferOwnership * test: removed the skipped test case from organization test suit * test: added branches and aliases test suits to sanity folder * test: commented out the test case instead or removing * test: updated url path in unit test case * test: added 1 more test case to branch test suit * test: added create branch test after stack creation test * fix: 📦 updates axios version * chore: update package version in package.json * chore: 🔨 updates prerelease hook script * chore: 📦 added a package for slack message integeration and script for same * chore: slack integeration for sending test report summary on the channel * test: added environment test to sanity and changes done in branch test * chore: 📦 updated slack/bolt package to devDependencies * Revert "chore: 📦 updated slack/bolt package to devDependencies" This reverts commit 0119e04. * updated slack/bolt package dependency * chore: added alldependencies required for slack/bolt package * chore: updates LICENSE file * test: Added locale test suit and delete test suit to sanity folder * chore: updated package-lock file * Added taxonomy import/export support (#112) Co-authored-by: Nadeem <[email protected]> * Validating the object when update the entries with assets (#114) Co-authored-by: Nadeem <[email protected]> * test: added delivery token test sanity folder * test: added extension test suit to sanity * test: updated test msg * Next (#115) * test: Added locale test suit and delete test suit to sanity folder * chore: updated package-lock file * Added taxonomy import/export support (#112) Co-authored-by: Nadeem <[email protected]> * Validating the object when update the entries with assets (#114) Co-authored-by: Nadeem <[email protected]> --------- Co-authored-by: harshithad0703 <[email protected]> Co-authored-by: harshithad0703 <[email protected]> Co-authored-by: Nadeem <[email protected]> * cleared assertion error * test: added assertions for failing tests * Feat/cs 43619 taxonomy import export testcases (#118) * Next (#115) * test: Added locale test suit and delete test suit to sanity folder * chore: updated package-lock file * Added taxonomy import/export support (#112) Co-authored-by: Nadeem <[email protected]> * Validating the object when update the entries with assets (#114) Co-authored-by: Nadeem <[email protected]> --------- Co-authored-by: harshithad0703 <[email protected]> Co-authored-by: harshithad0703 <[email protected]> Co-authored-by: Nadeem <[email protected]> * Added taxonomy import/export testcases. --------- Co-authored-by: Nadeem <[email protected]> Co-authored-by: harshithad0703 <[email protected]> Co-authored-by: harshithad0703 <[email protected]> * test: added global field test suit to sanity * test: add sanity test for label * Next (#119) * test: Added locale test suit and delete test suit to sanity folder * chore: updated package-lock file * Added taxonomy import/export support (#112) Co-authored-by: Nadeem <[email protected]> * Validating the object when update the entries with assets (#114) Co-authored-by: Nadeem <[email protected]> * test: added delivery token test sanity folder * test: added extension test suit to sanity * test: updated test msg * cleared assertion error * test: added assertions for failing tests * Feat/cs 43619 taxonomy import export testcases (#118) * Next (#115) * test: Added locale test suit and delete test suit to sanity folder * chore: updated package-lock file * Added taxonomy import/export support (#112) Co-authored-by: Nadeem <[email protected]> * Validating the object when update the entries with assets (#114) Co-authored-by: Nadeem <[email protected]> --------- Co-authored-by: harshithad0703 <[email protected]> Co-authored-by: harshithad0703 <[email protected]> Co-authored-by: Nadeem <[email protected]> * Added taxonomy import/export testcases. --------- Co-authored-by: Nadeem <[email protected]> Co-authored-by: harshithad0703 <[email protected]> Co-authored-by: harshithad0703 <[email protected]> * test: added global field test suit to sanity * test: add sanity test for label --------- Co-authored-by: harshithad0703 <[email protected]> Co-authored-by: harshithad0703 <[email protected]> Co-authored-by: Nadeem <[email protected]> * test: added sanity test for workflow-webhook-release * updated sanity.js file * test: added basic sanity for role * test: added basic sanity for management token test suit * fix: upgrade @slack/bolt from 3.17.0 to 3.17.1 Snyk has created this PR to upgrade @slack/bolt from 3.17.0 to 3.17.1. See this package in npm: https://www.npmjs.com/package/@slack/bolt See this project in Snyk: https://app.snyk.io/org/sunil-lakshman/project/d82509a3-a3c4-432f-b8d9-068ef2579b9b?utm_source=github&utm_medium=referral&page=upgrade-pr * feat: ✨ adds params support in taxonomy export function * test: added teams and stack share test suit to sanity * test: changed uids of branches and aliases * fix: fixed teams implementation according to the object received * changes the flow of sanity test * Update sca-scan.yml * fix: upgrade axios from 1.6.5 to 1.6.6 Snyk has created this PR to upgrade axios from 1.6.5 to 1.6.6. See this package in npm: https://www.npmjs.com/package/axios See this project in Snyk: https://app.snyk.io/org/sunil-lakshman/project/d82509a3-a3c4-432f-b8d9-068ef2579b9b?utm_source=github&utm_medium=referral&page=upgrade-pr * fix: 🐛 fixed update entry which was failing the function cleanAssets was checking with null value * test: removed organization name in assertion * chore: updated changeLog and version * fix: resolved undefined stack in error issue * test: sanity test for bulk operation * chore: 📦 update package version and changeLog * chore: 📦 upgraded axios package to 1.6.8 * fix: added delete stack method and test case * chore: updated changeLog and package version * chore: 📦 updated internal dependencies * chore: 📦 updated sdk version to 1.15.4 and changelog update * feat: ✨ get languages of an entry implementation * test: ✅ added unit and api test cases * docs: 📝 added docs for get locales * chore: updated package version and changeLog * feat: get locales types support * test: changes done in branches deletion error message * fix: added fix for missing fs error * fix: updated package version * fix: updated CHANGELOG.md * assertions corrections for webhooks sanity tests * build: upgraded qs package * test: changed the order of test suites in sanity * reorder test suites * reorder test suites * sca-scan.yml * jira.yml * sast-scan.yml * codeql-analysis.yml * fix: adding delay to check the issue with taxonomy for checking gocd pipeline * Added updateCT method for update an content type without fetch method (#157) * Added updateCT method for update an content type without fetch method * Updated node version * Fixed merge conflits * Added taxonomy permission test cases * Fixed merge conflits * Package publish issue fixed --------- Co-authored-by: Nadeem Patwekar <[email protected]> Co-authored-by: Nadeem <[email protected]> Co-authored-by: Shailesh Mishra <[email protected]> Co-authored-by: harshithad0703 <[email protected]> Co-authored-by: harshithad0703 <[email protected]> Co-authored-by: Abhinav Gupta <[email protected]> Co-authored-by: abhinav <[email protected]> Co-authored-by: snyk-bot <[email protected]> Co-authored-by: Aravind Kumar <[email protected]> Co-authored-by: Vikram Kalta <[email protected]> Co-authored-by: Vikram Kalta <[email protected]>
1 parent 559eedd commit c7047f7

File tree

10 files changed

+236
-24
lines changed

10 files changed

+236
-24
lines changed

.github/workflows/npm-publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- uses: actions/checkout@v3
2626
- uses: actions/setup-node@v3
2727
with:
28-
node-version: '12.x'
28+
node-version: '20.x'
2929
registry-url: 'https://npm.pkg.github.com'
3030
scope: '@contentstack'
3131
- run: npm ci

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
# Changelog
2+
## [v1.17.0](https://github.com/contentstack/contentstack-management-javascript/tree/v1.17.0) (2024-07-02)
3+
- Enhancement
4+
- Fixed package publish issue in github workflow
5+
- Added Taxonomy permission roles test cases
6+
- SNYK issues - Upgraded axios and slack/bolt packages version
27

38
## [v1.16.2](https://github.com/contentstack/contentstack-management-javascript/tree/v1.16.2) (2024-06-24)
49
- Enhancement

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@contentstack/management",
3-
"version": "1.16.2",
3+
"version": "1.17.0",
44
"description": "The Content Management API is used to manage the content of your Contentstack account",
55
"main": "./dist/node/contentstack-management.js",
66
"browser": "./dist/web/contentstack-management.js",
@@ -52,7 +52,7 @@
5252
"author": "Contentstack",
5353
"license": "MIT",
5454
"dependencies": {
55-
"axios": "^1.6.8",
55+
"axios": "^1.7.2",
5656
"form-data": "^3.0.1",
5757
"lodash": "^4.17.21",
5858
"qs": "^6.12.1"
@@ -69,7 +69,7 @@
6969
"@babel/preset-env": "^7.18.2",
7070
"@babel/register": "^7.17.7",
7171
"@babel/runtime": "^7.18.3",
72-
"@slack/bolt": "^3.18.0",
72+
"@slack/bolt": "^3.19.0",
7373
"@types/chai": "^4.3.11",
7474
"@types/jest": "^28.1.0",
7575
"@types/lodash": "^4.14.202",

test/api/mock/role.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,36 @@ const role = {
1414
module: 'locale',
1515
locales: [],
1616
acl: { read: true }
17+
},
18+
{
19+
module: "taxonomy",
20+
taxonomies: ["taxonomy_testing1"],
21+
terms: ["taxonomy_testing1.term_test1"],
22+
content_types: [
23+
{
24+
uid: "$all",
25+
acl: {
26+
read: true,
27+
sub_acl: {
28+
read: true,
29+
create: true,
30+
update: true,
31+
delete: true,
32+
publish: true
33+
}
34+
}
35+
}
36+
],
37+
acl: {
38+
read: true,
39+
sub_acl: {
40+
read: true,
41+
create: true,
42+
update: true,
43+
delete: true,
44+
publish: true
45+
}
46+
}
1747
}
1848
],
1949
uid: 'role_uid'

test/sanity-check/api/contentType-test.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { contentstackClient } from '../utility/ContentstackClient.js'
77

88
let client = {}
99
let multiPageCTUid = ''
10+
let multiPageUpdateCTUid = 'multi_page'
1011

1112
describe('Content Type api Test', () => {
1213
setup(() => {
@@ -93,17 +94,17 @@ describe('Content Type api Test', () => {
9394
})
9495
.catch(done)
9596
})
96-
// it('should update Multi page ContentType Schema without fetch', done => {
97-
// makeContentType()
98-
// .updateCT(multiPageCT)
99-
// .then((contentType) => {
100-
// multiPageCTUid = contentType.uid
101-
// expect(contentType.uid).to.be.equal(multiPageCT.content_type.uid)
102-
// expect(contentType.title).to.be.equal(multiPageCT.content_type.title)
103-
// done()
104-
// })
105-
// .catch(done)
106-
// })
97+
98+
it('should update Multi page ContentType Schema without fetch', done => {
99+
makeContentType(multiPageCT.content_type.uid)
100+
.updateCT(multiPageCT)
101+
.then((contentType) => {
102+
expect(contentType.content_type.schema.length).to.be.equal(2)
103+
done()
104+
})
105+
.catch(done)
106+
})
107+
107108

108109
it('should import content type', done => {
109110
makeContentType().import({

test/sanity-check/api/role-test.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,19 @@ dotenv.config()
99
let client = {}
1010
let roleUID = ''
1111

12+
const taxonomy = {
13+
uid: 'taxonomy_testing1',
14+
name: 'taxonomy testing1',
15+
description: 'Description for Taxonomy testing'
16+
}
17+
const term = {
18+
term: {
19+
uid: 'term_test1',
20+
name: 'Term test1',
21+
parent_uid: null
22+
}
23+
}
24+
1225
describe('Role api test', () => {
1326
setup(() => {
1427
const user = jsonReader('loggedinuser.json')
@@ -49,6 +62,19 @@ describe('Role api test', () => {
4962
.catch(done)
5063
})
5164

65+
it('should create taxonomy', async () => {
66+
await client.stack({ api_key: process.env.API_KEY }).taxonomy().create({ taxonomy })
67+
})
68+
69+
it('should create term', done => {
70+
makeTerms(taxonomy.uid).create(term)
71+
.then((response) => {
72+
expect(response.uid).to.be.equal(term.term.uid)
73+
done()
74+
})
75+
.catch(done)
76+
})
77+
5278
it('should create new role in stack', done => {
5379
getRole()
5480
.create(role)
@@ -141,8 +167,28 @@ describe('Role api test', () => {
141167
})
142168
.catch(done)
143169
})
170+
it('should delete of the term uid passed', done => {
171+
makeTerms(taxonomy.uid, term.term.uid).delete({ force: true })
172+
.then((response) => {
173+
expect(response.status).to.be.equal(204)
174+
done()
175+
})
176+
.catch(done)
177+
})
178+
179+
it('should delete taxonomy', async () => {
180+
const taxonomyResponse = await client.stack({ api_key: process.env.API_KEY }).taxonomy(taxonomy.uid).delete({ force: true })
181+
expect(taxonomyResponse.status).to.be.equal(204)
182+
})
183+
144184
})
145185

146186
function getRole (uid = null) {
147187
return client.stack({ api_key: process.env.API_KEY }).role(uid)
148188
}
189+
190+
191+
function makeTerms (taxonomyUid, termUid = null) {
192+
return client.stack({ api_key: process.env.API_KEY }).taxonomy(taxonomyUid).terms(termUid)
193+
}
194+

test/sanity-check/mock/role.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,36 @@ const role = {
7474
acl: {
7575
read: true
7676
}
77+
},
78+
{
79+
module: "taxonomy",
80+
taxonomies: ["taxonomy_testing1"],
81+
terms: ["taxonomy_testing1.term_test1"],
82+
content_types: [
83+
{
84+
uid: "$all",
85+
acl: {
86+
read: true,
87+
sub_acl: {
88+
read: true,
89+
create: true,
90+
update: true,
91+
delete: true,
92+
publish: true
93+
}
94+
}
95+
}
96+
],
97+
acl: {
98+
read: true,
99+
sub_acl: {
100+
read: true,
101+
create: true,
102+
update: true,
103+
delete: true,
104+
publish: true
105+
}
106+
}
77107
}
78108
]
79109
}

test/unit/mock/objects.js

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,89 @@ const roleMock = {
143143
...adminRoleMock,
144144
admin: false
145145
}
146+
const roleMockWithTaxonomy = {
147+
...systemFieldsMock,
148+
...systemFieldsUserMock,
149+
name: "Admin",
150+
description: "Admin Role",
151+
rules: [
152+
{
153+
module: "branch",
154+
branches: [
155+
"main"
156+
],
157+
acl: {
158+
read: true
159+
}
160+
},
161+
{
162+
module: "environment",
163+
environments: ["env_uid1", "env_uid2"],
164+
acl: {
165+
read: true
166+
}
167+
},
168+
{
169+
module: "locale",
170+
locales: ["locales"],
171+
acl: {
172+
read: true
173+
}
174+
},
175+
{
176+
module: "taxonomy",
177+
taxonomies: ["taxonomy_1"],
178+
terms: ["taxonomy_1.term_1"],
179+
content_types: [
180+
{
181+
uid: "$all",
182+
acl: {
183+
read: true,
184+
sub_acl: {
185+
read: true,
186+
create: true,
187+
update: true,
188+
delete: true,
189+
publish: true
190+
}
191+
}
192+
}
193+
],
194+
acl: {
195+
read: true,
196+
sub_acl: {
197+
read: true,
198+
create: true,
199+
update: true,
200+
delete: true,
201+
publish: true
202+
}
203+
}
204+
},
205+
{
206+
module: "content_type",
207+
content_types: ["ct_1"],
208+
acl: {
209+
read: true,
210+
sub_acl: {
211+
read: true,
212+
create: true,
213+
update: true,
214+
delete: true,
215+
publish: true
216+
}
217+
}
218+
}
219+
],
220+
org_uid: "org_uid",
221+
api_key: "api_key",
222+
admin: false,
223+
default: true,
224+
users: [
225+
'user_uid'
226+
]
227+
}
228+
146229
const branchMock = {
147230
...systemFieldsMock,
148231
...systemFieldsUserMock,
@@ -897,5 +980,6 @@ export {
897980
mockCollection,
898981
entryMockCollection,
899982
checkSystemFields,
900-
managementTokenMock
983+
managementTokenMock,
984+
roleMockWithTaxonomy
901985
}

test/unit/role-test.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { expect } from 'chai'
33
import { describe, it } from 'mocha'
44
import MockAdapter from 'axios-mock-adapter'
55
import { Role, RoleCollection } from '../../lib/stack/roles'
6-
import { systemUidMock, stackHeadersMock, roleMock, noticeMock } from './mock/objects'
6+
import { systemUidMock, stackHeadersMock, roleMock, noticeMock, roleMockWithTaxonomy} from './mock/objects'
77

88
describe('Contentstack Role test', () => {
99
it('Role test without uid', done => {
@@ -88,6 +88,22 @@ describe('Contentstack Role test', () => {
8888
.catch(done)
8989
})
9090

91+
it('Role create test with taxonomy permission', done => {
92+
var mock = new MockAdapter(Axios)
93+
mock.onPost('/roles').reply(200, {
94+
role: {
95+
...roleMockWithTaxonomy
96+
}
97+
})
98+
makeRole()
99+
.create()
100+
.then((role) => {
101+
checkRole(role)
102+
done()
103+
})
104+
.catch(done)
105+
})
106+
91107
it('Role Fetch all without Stack Headers test', done => {
92108
var mock = new MockAdapter(Axios)
93109
mock.onGet('/roles').reply(200, {

0 commit comments

Comments
 (0)