feat(homepage): synchronize canvas layouts across devices (#1515)

This commit is contained in:
ZacharyZcR authored and GitHub committed 2026-09-30 09:47:08 -05:00
1 parent fdb2f74259
commit 7d06686f62
4 files changed
+145 -4

No files matched your search

+22
View File
@@ -1,3 +1,4 @@
import { mapLayoutItemIds } from "./layout-item-ids.js";
import type { Router } from "express";
import type { PluginContext } from "@termix/plugin-sdk/backend";
import {
@@ -45,6 +46,27 @@ export async function activate(ctx: PluginContext) {
order: 70,
});
ctx.sync.registerEntity({
type: "homepageLayouts",
table: layouts,
order: 81,
singleton: true,
serialize: async (row, resolveSyncId) => ({
...row,
layout: await mapLayoutItemIds(row.layout as string, async (id) =>
typeof id === "number" && Number.isInteger(id)
? resolveSyncId("homepageItems", id)
: null,
),
}),
deserialize: async (row, resolveId) => ({
...row,
layout: await mapLayoutItemIds(row.layout as string, async (id) =>
typeof id === "string" ? resolveId("homepageItems", id) : null,
),
}),
});
ctx.services.provide("homepage.items", createHomepageItemsService(ctx, repo));
ctx.log.info("Homepage routes mounted at /plugin-api/homepage");