From af4cc5da0020148c17981719bc6f5ec42860dc50 Mon Sep 17 00:00:00 2001 From: Rushikesh Argade Date: Tue, 4 Nov 2025 18:47:33 +0530 Subject: [PATCH] feat: add config support to search method for branch-specific searches - Add optional config parameter to search method with safe default - Support branch-specific searches via config.branch - Update JSDoc documentation for new parameter - Maintain backward compatibility with existing API - Follow consistent pattern with other stack methods --- src/stack/index.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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)