Skip to content

Commit

Permalink
Merge pull request #176 from internxt/feat/PB-250-global-drive-search
Browse files Browse the repository at this point in the history
[PB-250]: feat/add get global search items
  • Loading branch information
rafijv authored Oct 16, 2023
2 parents fbe422a + 2177f78 commit ffb5c30
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@internxt/sdk",
"version": "1.4.54",
"version": "1.4.55",
"description": "An sdk for interacting with Internxt's services",
"repository": {
"type": "git",
Expand Down
16 changes: 16 additions & 0 deletions src/drive/storage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
Thumbnail,
FetchPaginatedFolderContentResponse,
FileMeta,
SearchResultData,
} from './types';
import { ApiSecurity, ApiUrl, AppDetails } from '../../shared';
import { headersWithToken, addResourcesTokenToHeaders } from '../../shared/headers';
Expand Down Expand Up @@ -339,6 +340,21 @@ export class Storage {
return this.client.get('/limit', this.headers());
}

/**
* Get global search items.
*
* @param {string} search - The name of the item.
* @returns {[Promise<SearchResultData>, RequestCanceler]} An array containing a promise to get the API response and a function to cancel the request.
*/
public getGlobalSearchItems(search: string): [Promise<SearchResultData>, RequestCanceler] {
const { promise, requestCanceler } = this.client.getCancellable<SearchResultData>(
`fuzzy/${search}`,
this.headers(),
);

return [promise, requestCanceler];
}

/**
* Returns the needed headers for the module requests
* @private
Expand Down
21 changes: 21 additions & 0 deletions src/drive/storage/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,3 +262,24 @@ export interface FetchLimitResponse {
export interface AddItemsToTrashPayload {
items: Array<{ id: string; type: string }>;
}

export interface SearchResult {
id: string;
itemId: string;
itemType: string;
name: string;
rank: number;
similarity: number;
userId: string;
item: {
id: number;
bucket?: string;
fileId?: string;
plainName?: string;
size?: string;
type?: string;
};
}
export interface SearchResultData {
data: [SearchResult];
}

0 comments on commit ffb5c30

Please sign in to comment.