diff --git a/.talismanrc b/.talismanrc index ccaba411..6d3f969f 100644 --- a/.talismanrc +++ b/.talismanrc @@ -1,5 +1,5 @@ threshold: medium fileignoreconfig: - filename: package-lock.json - checksum: 2a2327aabd3f6eacf41a8e8bb3dd5afdab892683cfd15aac308f43c14108b824 + checksum: 9d0340f9359927d477fe8ab4650642c068c592be63fb817651d866849e0dbbc2 version: "" \ No newline at end of file diff --git a/lib/stack/taxonomy/index.js b/lib/stack/taxonomy/index.js index ccac2296..b2b83b4c 100644 --- a/lib/stack/taxonomy/index.js +++ b/lib/stack/taxonomy/index.js @@ -87,10 +87,11 @@ export function Taxonomy (http, data = {}) { * .then((taxonomy) => console.log(taxonomy)) * */ - this.export = async () => { + this.export = async (params = {}) => { try { const headers = { - headers: { ...cloneDeep(this.stackHeaders) } + headers: { ...cloneDeep(this.stackHeaders) }, + params } const response = await http.get(`${this.urlPath}/export`, headers) if (response.data) { @@ -103,7 +104,6 @@ export function Taxonomy (http, data = {}) { } } - this.terms = (uid = '') => { const data = { stackHeaders: this.stackHeaders } data.taxonomy_uid = this.uid @@ -183,7 +183,6 @@ export function Taxonomy (http, data = {}) { throw error(err) } } - } } export function TaxonomyCollection (http, data) { @@ -201,4 +200,4 @@ export function createFormData (data) { formData.append('taxonomy', uploadStream) return formData } -} \ No newline at end of file +} diff --git a/package-lock.json b/package-lock.json index e723019e..b02fe8b5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@contentstack/management", - "version": "1.14.1", + "version": "1.15.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@contentstack/management", - "version": "1.14.1", + "version": "1.15.2", "license": "MIT", "dependencies": { "@slack/bolt": "^3.17.0", @@ -2911,15 +2911,15 @@ "dev": true }, "node_modules/@slack/bolt": { - "version": "3.17.0", - "resolved": "https://registry.npmjs.org/@slack/bolt/-/bolt-3.17.0.tgz", - "integrity": "sha512-gxZygJj/wnrrSPCAlXO4D5FIYre2McPC+Vwrkq6CS74S4MI+0/gRvdUUXMHoF+oSGfsGs3ul6Fk+Bc/EE7Waig==", + "version": "3.17.1", + "resolved": "https://registry.npmjs.org/@slack/bolt/-/bolt-3.17.1.tgz", + "integrity": "sha512-N+4WxpkM59RXi7BL3IXUtENnn9cF7TOBn7ttaHpgvlnjUaro+yQyY60arXTlP4ytVDFJ1w0mSdfftcM17h+i2w==", "dependencies": { "@slack/logger": "^4.0.0", - "@slack/oauth": "^2.6.1", - "@slack/socket-mode": "^1.3.2", + "@slack/oauth": "^2.6.2", + "@slack/socket-mode": "^1.3.3", "@slack/types": "^2.11.0", - "@slack/web-api": "^6.11.0", + "@slack/web-api": "^6.11.2", "@types/express": "^4.16.1", "@types/promise.allsettled": "^1.0.3", "@types/tsscmp": "^1.0.0", @@ -3025,9 +3025,9 @@ } }, "node_modules/@slack/web-api": { - "version": "6.11.2", - "resolved": "https://registry.npmjs.org/@slack/web-api/-/web-api-6.11.2.tgz", - "integrity": "sha512-s4qCQGXasr8jpCf/+6+V/smq+Z2RX7EIBnJeO/xe7Luie1nyBihFMgjICNyvzWoWBdaGntSnn5CcZdFm4ItBWg==", + "version": "6.12.0", + "resolved": "https://registry.npmjs.org/@slack/web-api/-/web-api-6.12.0.tgz", + "integrity": "sha512-RPw6F8rWfGveGkZEJ4+4jUin5iazxRK2q3FpQDz/FvdgzC3nZmPyLx8WRzc6nh0w3MBjEbphNnp2VZksfhpBIQ==", "dependencies": { "@slack/logger": "^3.0.0", "@slack/types": "^2.11.0", @@ -3201,9 +3201,9 @@ } }, "node_modules/@types/express-serve-static-core": { - "version": "4.17.41", - "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.41.tgz", - "integrity": "sha512-OaJ7XLaelTgrvlZD8/aa0vvvxZdUmlCn6MtWeB7TkiKW70BQLc9XEPpDLPdbo52ZhXUCrznlWdCHWxJWtdyajA==", + "version": "4.17.42", + "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.42.tgz", + "integrity": "sha512-ckM3jm2bf/MfB3+spLPWYPUH573plBFwpOhqQ2WottxYV85j1HQFlxmnTq57X1yHY9awZPig06hL/cLMgNWHIQ==", "dependencies": { "@types/node": "*", "@types/qs": "*", @@ -15770,15 +15770,15 @@ "dev": true }, "@slack/bolt": { - "version": "3.17.0", - "resolved": "https://registry.npmjs.org/@slack/bolt/-/bolt-3.17.0.tgz", - "integrity": "sha512-gxZygJj/wnrrSPCAlXO4D5FIYre2McPC+Vwrkq6CS74S4MI+0/gRvdUUXMHoF+oSGfsGs3ul6Fk+Bc/EE7Waig==", + "version": "3.17.1", + "resolved": "https://registry.npmjs.org/@slack/bolt/-/bolt-3.17.1.tgz", + "integrity": "sha512-N+4WxpkM59RXi7BL3IXUtENnn9cF7TOBn7ttaHpgvlnjUaro+yQyY60arXTlP4ytVDFJ1w0mSdfftcM17h+i2w==", "requires": { "@slack/logger": "^4.0.0", - "@slack/oauth": "^2.6.1", - "@slack/socket-mode": "^1.3.2", + "@slack/oauth": "^2.6.2", + "@slack/socket-mode": "^1.3.3", "@slack/types": "^2.11.0", - "@slack/web-api": "^6.11.0", + "@slack/web-api": "^6.11.2", "@types/express": "^4.16.1", "@types/promise.allsettled": "^1.0.3", "@types/tsscmp": "^1.0.0", @@ -15862,9 +15862,9 @@ "integrity": "sha512-UlIrDWvuLaDly3QZhCPnwUSI/KYmV1N9LyhuH6EDKCRS1HWZhyTG3Ja46T3D0rYfqdltKYFXbJSSRPwZpwO0cQ==" }, "@slack/web-api": { - "version": "6.11.2", - "resolved": "https://registry.npmjs.org/@slack/web-api/-/web-api-6.11.2.tgz", - "integrity": "sha512-s4qCQGXasr8jpCf/+6+V/smq+Z2RX7EIBnJeO/xe7Luie1nyBihFMgjICNyvzWoWBdaGntSnn5CcZdFm4ItBWg==", + "version": "6.12.0", + "resolved": "https://registry.npmjs.org/@slack/web-api/-/web-api-6.12.0.tgz", + "integrity": "sha512-RPw6F8rWfGveGkZEJ4+4jUin5iazxRK2q3FpQDz/FvdgzC3nZmPyLx8WRzc6nh0w3MBjEbphNnp2VZksfhpBIQ==", "requires": { "@slack/logger": "^3.0.0", "@slack/types": "^2.11.0", @@ -16022,9 +16022,9 @@ } }, "@types/express-serve-static-core": { - "version": "4.17.41", - "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.41.tgz", - "integrity": "sha512-OaJ7XLaelTgrvlZD8/aa0vvvxZdUmlCn6MtWeB7TkiKW70BQLc9XEPpDLPdbo52ZhXUCrznlWdCHWxJWtdyajA==", + "version": "4.17.42", + "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.42.tgz", + "integrity": "sha512-ckM3jm2bf/MfB3+spLPWYPUH573plBFwpOhqQ2WottxYV85j1HQFlxmnTq57X1yHY9awZPig06hL/cLMgNWHIQ==", "requires": { "@types/node": "*", "@types/qs": "*", diff --git a/package.json b/package.json index ec1c5e7f..7681b86a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@contentstack/management", - "version": "1.15.1", + "version": "1.15.2", "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", diff --git a/test/api/taxonomy-test.js b/test/api/taxonomy-test.js index b8e331a6..e31c715b 100644 --- a/test/api/taxonomy-test.js +++ b/test/api/taxonomy-test.js @@ -39,7 +39,7 @@ describe('taxonomy api Test', () => { makeTaxonomy() .import(importTaxonomy) .then((taxonomyResponse) => { - expect(taxonomyResponse.name).to.be.equal("name") + expect(taxonomyResponse.name).to.be.equal('name') done() }) .catch(done) @@ -47,7 +47,7 @@ describe('taxonomy api Test', () => { it('Export taxonomy', done => { makeTaxonomy(taxonomyUID) - .export() + .export({}) .then((taxonomyResponse) => { expect(taxonomyResponse.uid).to.be.equal(taxonomyUID) expect(taxonomyResponse.name).to.be.not.equal(null) diff --git a/test/typescript/taxonomy.ts b/test/typescript/taxonomy.ts index adf200e1..901a5e6a 100644 --- a/test/typescript/taxonomy.ts +++ b/test/typescript/taxonomy.ts @@ -64,5 +64,27 @@ export function testTaxonomy(stack: Stack) { }) }) }) + test('Import taxonomy', async () => { + const taxonomyData = { + "uid": "UID", + "name": "name", + "description": "test" + } + await stack.taxonomy() + .import(taxonomyData) + .then((taxonomyResponse) => { + expect(taxonomyResponse.name).to.be.equal('name') + }) + .catch(() => {}); + }) + test('Export taxonomy', async () => { + await stack.taxonomy(taxonomyUID) + .export({ format: 'json'}) + .then((taxonomyResponse) => { + expect(taxonomyResponse.uid).to.be.equal(taxonomyUID) + expect(taxonomyResponse.name).to.be.not.equal(null) + }) + .catch(() => {}); + }) }) } diff --git a/types/stack/taxonomy/index.d.ts b/types/stack/taxonomy/index.d.ts index c0a23a22..bb9b0cea 100644 --- a/types/stack/taxonomy/index.d.ts +++ b/types/stack/taxonomy/index.d.ts @@ -5,12 +5,11 @@ import { Term, Terms } from "../taxonomy/terms" export interface Taxonomy extends SystemFields, SystemFunction { terms(): Terms terms(uid: string): Term -} - -export interface Taxonomies extends Queryable { + export(params?: any): Promise } -export interface Taxonomies extends Creatable { +export interface Taxonomies extends Creatable, Queryable { + import(data: TaxonomyData, params?: any): Promise } export interface TaxonomyData extends AnyProperty {