mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-30 15:15:24 +00:00
feat: finish the homepage plugin, move service links and canvas out of core (B19)
This commit is contained in:
1 parent
21937a6b02
commit
d4ec444558
256 files changed
+27365
-9077
No files matched your search
@@ -0,0 +1,27 @@
|
||||
import type { PluginContext } from "@termix/plugin-sdk/backend";
|
||||
import type { HomepageRepository } from "./repository.js";
|
||||
|
||||
/** The "homepage.items" service, version 1. Runs as the caller's user. */
|
||||
export interface HomepageItemsV1 {
|
||||
list: () => Promise<
|
||||
Array<{ id: number; typeId: string; title: string | null }>
|
||||
>;
|
||||
}
|
||||
|
||||
export function createHomepageItemsService(
|
||||
ctx: PluginContext,
|
||||
repo: HomepageRepository,
|
||||
): HomepageItemsV1 {
|
||||
return {
|
||||
list: async () => {
|
||||
const userId = ctx.currentActor();
|
||||
if (!userId) return [];
|
||||
const rows = await repo.listItemsByUser(userId);
|
||||
return rows.map((row) => ({
|
||||
id: row.id,
|
||||
typeId: row.typeId,
|
||||
title: row.title,
|
||||
}));
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user