diff --git a/__test__/entry.test.ts b/__test__/entry.test.ts index 2548935d..dfd3bc27 100644 --- a/__test__/entry.test.ts +++ b/__test__/entry.test.ts @@ -223,7 +223,7 @@ describe("Entry", () => { dataWithoutEntry.entry = {}; entry = new Entry(dataWithoutEntry, connection as any, emitter); expect(() => entry.getField("invaliduid")).toThrowError( - "The data is unsaved. Save the data before requesting the field." + "Invalid uid, Field not found" ); }); diff --git a/package-lock.json b/package-lock.json index 6506f14c..dcd22e01 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@contentstack/app-sdk", - "version": "2.3.3", + "version": "2.3.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@contentstack/app-sdk", - "version": "2.3.3", + "version": "2.3.4", "license": "MIT", "dependencies": { "axios": "^1.7.9", diff --git a/package.json b/package.json index 3af26daa..c1d68068 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@contentstack/app-sdk", - "version": "2.3.3", + "version": "2.3.4", "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/entry.ts b/src/entry.ts index 14ecd768..d56c45ba 100755 --- a/src/entry.ts +++ b/src/entry.ts @@ -154,14 +154,6 @@ class Entry { : this._data; let schema: Schema[0] = this.content_type.schema; - const isDataEmpty = Object.keys(value).length === 0; - - if (isDataEmpty) { - throw new Error( - "The data is unsaved. Save the data before requesting the field." - ); - } - try { let skipNext = false; let skipNextTwo = false; diff --git a/src/stack/index.ts b/src/stack/index.ts index 6535d214..a66d2ec6 100755 --- a/src/stack/index.ts +++ b/src/stack/index.ts @@ -113,10 +113,15 @@ class Stack { * Gets the results of the search based on user query * @param queries Array of key value pair of query parameters * @param apiKey API key of the stack + * @param config Optional configuration. Only pass this if you need to query a specific branch using `{ branch: 'branch-name' }. If not provided, queries the default branch.` * @returns Result of the query */ - search(queries: StackSearchQuery, apiKey: string | null = this._data.api_key) { - const options = { params: queries, api_key: apiKey, action: "search" }; + search(queries: StackSearchQuery, apiKey: string | null = this._data.api_key, config: { [key: string]: any } = {}) { + const { branch } = config; + const options: any = { params: queries, api_key: apiKey, action: "search" }; + if (branch) { + options.headers = { branch }; + } return this._connection .sendToParent("stackQuery", options) .then(onData)