diff --git a/__test__/stack.test.ts b/__test__/stack.test.ts index c025698..d390fb2 100644 --- a/__test__/stack.test.ts +++ b/__test__/stack.test.ts @@ -188,18 +188,23 @@ describe("Stack", () => { }); it("getContentTypes", (done) => { - let params: { [key: string]: any } = { sample: "parameter" }; + let params: { [key: string]: any } = { sample: "parameter", branch: "sampleBranch" }; let query = { sample: "query" }; + let expectedParams = { sample: "parameter", query }; + stack.getContentTypes(query, params).then((data) => { - params.query = query; expect(data).toEqual({}); expect(connection.sendToParent).toHaveBeenCalledWith( "stackQuery", - { params, action: "getContentTypes" } + { + params: expectedParams, + action: "getContentTypes", + headers: { branch: "sampleBranch" } + } ); done(); }); - }); + }); it("getContentTypes error case", async () => { let newStack = new Stack( diff --git a/package-lock.json b/package-lock.json index 3a1b346..25a92c3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@contentstack/app-sdk", - "version": "2.1.3", + "version": "2.1.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@contentstack/app-sdk", - "version": "2.1.3", + "version": "2.1.0", "license": "MIT", "dependencies": { "loader-utils": "^3.2.1", diff --git a/package.json b/package.json index e2d5889..beaca31 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@contentstack/app-sdk", - "version": "2.1.3", + "version": "2.1.0", "types": "dist/src/index.d.ts", "description": "The Contentstack App SDK allows you to customize your Contentstack applications.", "main": "dist/index.js", diff --git a/src/stack/index.ts b/src/stack/index.ts index d4d0711..6535d21 100755 --- a/src/stack/index.ts +++ b/src/stack/index.ts @@ -145,9 +145,17 @@ class Stack { * @return {Object} A promise object which will be resolved with details of the content type. */ getContentTypes(query = {}, params: { [key: string]: any } = {}): Promise<{ [key: string]: any }> { - const optionParams = params; + const {branch, ...optionParams} = params; optionParams.query = query; - const options = { params: optionParams, action: 'getContentTypes' }; + + const options: any = { + params: optionParams, + action: 'getContentTypes', + }; + + if (branch) { + options.headers = { branch }; + } return this._connection.sendToParent('stackQuery', options).then(onData).catch(onError); }