feat: enhancements (#2107)

* refactor
* fix
* update packages
This commit is contained in:
Philip Okugbe
2026-04-13 23:34:40 +01:00
committed by GitHub
parent bd68e47e03
commit 4056bd0104
18 changed files with 412 additions and 155 deletions
@@ -62,6 +62,39 @@ export class FavoriteRepo {
.execute();
}
async getFavoriteIds(
userId: string,
workspaceId: string,
type: FavoriteType,
): Promise<{ items: string[]; meta: any }> {
const idColumn =
type === FavoriteType.PAGE
? 'pageId'
: type === FavoriteType.SPACE
? 'spaceId'
: 'templateId';
const query = this.db
.selectFrom('favorites')
.select(['favorites.id', `favorites.${idColumn} as entityId`])
.where('userId', '=', userId)
.where('workspaceId', '=', workspaceId)
.where('type', '=', type);
const result = await executeWithCursorPagination(query, {
perPage: 250,
fields: [{ expression: 'favorites.id', direction: 'desc' }],
parseCursor: (cursor) => ({ id: cursor.id }),
});
return {
items: result.items
.map((r) => (r as any).entityId as string)
.filter(Boolean),
meta: result.meta,
};
}
async findUserFavorites(
userId: string,
workspaceId: string,
@@ -207,6 +207,22 @@ export class WatcherRepo {
.execute();
}
async getWatchedSpaceIds(userId: string, workspaceId: string) {
const query = this.db
.selectFrom('watchers')
.select(['watchers.id', 'watchers.spaceId'])
.where('userId', '=', userId)
.where('workspaceId', '=', workspaceId)
.where('pageId', 'is', null)
.where('type', '=', WatcherType.SPACE);
return executeWithCursorPagination(query, {
perPage: 250,
fields: [{ expression: 'watchers.id', direction: 'asc' }],
parseCursor: (cursor) => ({ id: cursor.id }),
});
}
async isWatchingSpace(userId: string, spaceId: string): Promise<boolean> {
const watcher = await this.db
.selectFrom('watchers')