Skip to content

Commit 45b3e76

Browse files
authored
Merge pull request #126 from contentstack/fix/CS-43764-Params-in-Taxonomy-export
Fix: params in taxonomy export CS-43764
2 parents 60c1b95 + 39f7b8d commit 45b3e76

File tree

7 files changed

+59
-39
lines changed

7 files changed

+59
-39
lines changed

.talismanrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
threshold: medium
22
fileignoreconfig:
33
- filename: package-lock.json
4-
checksum: 2a2327aabd3f6eacf41a8e8bb3dd5afdab892683cfd15aac308f43c14108b824
4+
checksum: 9d0340f9359927d477fe8ab4650642c068c592be63fb817651d866849e0dbbc2
55
version: ""

lib/stack/taxonomy/index.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,11 @@ export function Taxonomy (http, data = {}) {
8787
* .then((taxonomy) => console.log(taxonomy))
8888
*
8989
*/
90-
this.export = async () => {
90+
this.export = async (params = {}) => {
9191
try {
9292
const headers = {
93-
headers: { ...cloneDeep(this.stackHeaders) }
93+
headers: { ...cloneDeep(this.stackHeaders) },
94+
params
9495
}
9596
const response = await http.get(`${this.urlPath}/export`, headers)
9697
if (response.data) {
@@ -103,7 +104,6 @@ export function Taxonomy (http, data = {}) {
103104
}
104105
}
105106

106-
107107
this.terms = (uid = '') => {
108108
const data = { stackHeaders: this.stackHeaders }
109109
data.taxonomy_uid = this.uid
@@ -183,7 +183,6 @@ export function Taxonomy (http, data = {}) {
183183
throw error(err)
184184
}
185185
}
186-
187186
}
188187
}
189188
export function TaxonomyCollection (http, data) {
@@ -201,4 +200,4 @@ export function createFormData (data) {
201200
formData.append('taxonomy', uploadStream)
202201
return formData
203202
}
204-
}
203+
}

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@contentstack/management",
3-
"version": "1.15.1",
3+
"version": "1.15.2",
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",

test/api/taxonomy-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ describe('taxonomy api Test', () => {
3939
makeTaxonomy()
4040
.import(importTaxonomy)
4141
.then((taxonomyResponse) => {
42-
expect(taxonomyResponse.name).to.be.equal("name")
42+
expect(taxonomyResponse.name).to.be.equal('name')
4343
done()
4444
})
4545
.catch(done)
4646
})
4747

4848
it('Export taxonomy', done => {
4949
makeTaxonomy(taxonomyUID)
50-
.export()
50+
.export({})
5151
.then((taxonomyResponse) => {
5252
expect(taxonomyResponse.uid).to.be.equal(taxonomyUID)
5353
expect(taxonomyResponse.name).to.be.not.equal(null)

test/typescript/taxonomy.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,27 @@ export function testTaxonomy(stack: Stack) {
6464
})
6565
})
6666
})
67+
test('Import taxonomy', async () => {
68+
const taxonomyData = {
69+
"uid": "UID",
70+
"name": "name",
71+
"description": "test"
72+
}
73+
await stack.taxonomy()
74+
.import(taxonomyData)
75+
.then((taxonomyResponse) => {
76+
expect(taxonomyResponse.name).to.be.equal('name')
77+
})
78+
.catch(() => {});
79+
})
80+
test('Export taxonomy', async () => {
81+
await stack.taxonomy(taxonomyUID)
82+
.export({ format: 'json'})
83+
.then((taxonomyResponse) => {
84+
expect(taxonomyResponse.uid).to.be.equal(taxonomyUID)
85+
expect(taxonomyResponse.name).to.be.not.equal(null)
86+
})
87+
.catch(() => {});
88+
})
6789
})
6890
}

types/stack/taxonomy/index.d.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ import { Term, Terms } from "../taxonomy/terms"
55
export interface Taxonomy extends SystemFields, SystemFunction<Taxonomy> {
66
terms(): Terms
77
terms(uid: string): Term
8-
}
9-
10-
export interface Taxonomies extends Queryable<Taxonomy, {taxonomy: TaxonomyData}> {
8+
export(params?: any): Promise<AnyProperty>
119
}
1210

13-
export interface Taxonomies extends Creatable<Taxonomy, {taxonomy: TaxonomyData}> {
11+
export interface Taxonomies extends Creatable<Taxonomy, {taxonomy: TaxonomyData}>, Queryable<Taxonomy, {taxonomy: TaxonomyData}> {
12+
import(data: TaxonomyData, params?: any): Promise<Taxonomy>
1413
}
1514

1615
export interface TaxonomyData extends AnyProperty {

0 commit comments

Comments
 (0)