Skip to content

Commit

Permalink
Merge branch 'add_pagination_memories'
Browse files Browse the repository at this point in the history
  • Loading branch information
nzambello committed Sep 25, 2024
2 parents 6559d24 + 95bcf01 commit 5bc4027
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
65 changes: 65 additions & 0 deletions src/engine/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,71 @@ export default (apiUrl: string) => ({
}
>,

/**
* 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 {number} pageIndex The page index
* @param {number} pageSize The page size
* @param {SearchQuery} query Search query params
*/
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[];
}
>,

/**
* Filters Memory objects
* @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[];
}
>,

/**
* Filters Memory objects, with pagination
* @param {string} sessionId The session ID
* @param {number} pageIndex The page index
* @param {number} pageSize The page size
* @param {SearchQuery} query Search query params
*/
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
* Timeout event of the R1 state of the Dialog State Machine.
Expand Down
9 changes: 9 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,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 @@ -664,6 +667,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 5bc4027

Please sign in to comment.