aboutsummaryrefslogtreecommitdiffstats
path: root/packages/shared/search.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/shared/search.ts')
-rw-r--r--packages/shared/search.ts22
1 files changed, 19 insertions, 3 deletions
diff --git a/packages/shared/search.ts b/packages/shared/search.ts
index 5158f30f..d23ab29f 100644
--- a/packages/shared/search.ts
+++ b/packages/shared/search.ts
@@ -24,18 +24,34 @@ export const zBookmarkSearchDocument = z.object({
export type BookmarkSearchDocument = z.infer<typeof zBookmarkSearchDocument>;
+export type SortOrder = "asc" | "desc";
+export type SortableAttributes = "createdAt";
+
+export type FilterableAttributes = "userId" | "id";
+export type FilterQuery =
+ | {
+ type: "eq";
+ field: FilterableAttributes;
+ value: string;
+ }
+ | {
+ type: "in";
+ field: FilterableAttributes;
+ values: string[];
+ };
+
export interface SearchResult {
id: string;
score?: number;
}
export interface SearchOptions {
- // TODO: Make query, filter and sort strongly typed
query: string;
- filter?: string[];
+ // Diffeernt filters are ANDed together
+ filter?: FilterQuery[];
limit?: number;
offset?: number;
- sort?: string[];
+ sort?: { field: SortableAttributes; order: SortOrder }[];
}
export interface SearchResponse {