feat: v2 rewrite — hexagonal arch, ActivityPub federation, NATS, deployment-ready #1

Merged
GKaszewski merged 334 commits from v2 into master 2026-05-16 09:42:43 +00:00
Showing only changes of commit 255ff549a4 - Show all commits

View File

@@ -243,8 +243,22 @@ export const deleteThought = (thoughtId: string, token: string) =>
export const getThoughtById = (thoughtId: string, token: string | null) =>
apiFetch(`/thoughts/${thoughtId}`, {}, ThoughtSchema, token);
export const getThoughtThread = (thoughtId: string, token: string | null) =>
apiFetch(`/thoughts/${thoughtId}/thread`, {}, ThoughtThreadSchema, token);
export const getThoughtThread = async (thoughtId: string, token: string | null): Promise<ThoughtThread> => {
const thoughts = await apiFetch(`/thoughts/${thoughtId}/thread`, {}, z.array(ThoughtSchema), token);
type T = z.infer<typeof ThoughtSchema>;
const repliesMap: Record<string, T[]> = {};
for (const t of thoughts) {
if (t.replyToId) {
(repliesMap[t.replyToId] ??= []).push(t);
}
}
function build(t: T): ThoughtThread {
return { ...t, replies: (repliesMap[t.id] ?? []).map(build) };
}
const root = thoughts.find((t) => t.id === thoughtId) ?? thoughts[0];
if (!root) throw new Error("Thread not found");
return build(root);
};
// ── Tags ──────────────────────────────────────────────────────────────────