Skip to content

Commit

Permalink
feat: added pagination search and filter apis
Browse files Browse the repository at this point in the history
  • Loading branch information
andrepat0 committed Sep 24, 2024
1 parent 6fedc19 commit 419397e
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
60 changes: 60 additions & 0 deletions src/engine/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,66 @@ export default (apiUrl: string) => ({
matches: SearchMatches[];
}
>,


/**
*
* @param sessionId
* @param pageIndex
* @param pageSize
* @param query
* @returns
*/
searchMemoryPaginated: async (
sessionId: string,
pageIndex: number,
pageSize: number,
query?: SearchQuery
) =>
apiFetcher(`/Search/${sessionId}/${pageIndex}/${pageSize}`, {
method: 'POST',
body: query,
apiUrl,
}) as Promise<
ResponseSpec & {
count: number;
matches: SearchMatches[];
}
>,

/**
* Searches for matching Memory objects using the same algorithm employed in the Text Entered event of the R1 state of the Dialog State Machine.
* @param {string} sessionId The session ID
* @param {SearchQuery} query Search query params
*/
filterMemories: async (sessionId: string, query?: SearchQuery) =>
apiFetcher(`/FilterMemories/${sessionId}`, {
method: 'POST',
body: query,
apiUrl,
}) as Promise<
ResponseSpec & {
count: number;
matches: SearchMatches[];
}
>,

filterMemoriesPaginated: async (
sessionId: string,
pageIndex: number,
pageSize: number,
query?: SearchQuery,
) =>
apiFetcher(`/FilterMemories/${sessionId}/${pageIndex}/${pageSize}`, {
method: 'POST',
body: query,
apiUrl:,
}) as Promise<
ResponseSpec & {
count: number;
matches: SearchMatches[];
}
>,

/**
* Picks up to 5 random Memory objects using the same algorithm employed in the
Expand Down
9 changes: 9 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,9 @@ export declare type Asset = {
};

export type SearchQuery = {



/**
* @type {string}
* Search query. If omitted, either a Date or a Place must be set. Used only for Search, ignored for Random picking and Memory Hints.
Expand Down Expand Up @@ -602,6 +605,12 @@ export type SearchQuery = {
*/
excludedMemoryIDs?: string[];

/**
* @type {number=0}
* Index of the first Memory to return. Used for pagination.
*/
startFrom?: number;

/**
* @type {?number=5}
* Optional number of results. If omitted defaults to 5.
Expand Down

0 comments on commit 419397e

Please sign in to comment.