feat: add automatic catalog organization for all imported furniture
Add a fully automatic "Organize all" action in the Studio that organizes the entire database into catalog pages: - Create a dedicated sub-page per furniture line (e.g. weebz, habbox) from FurnitureData.json, falling back to the auto-detected category. - Add missing purchasable items to the catalog on their line/category page. - Re-home and re-price existing catalog entries onto their correct page. - Pages are created automatically when missing; no manual selection needed. Includes the organizeCatalogAll service, a POST /api/admin/import/furni/organize endpoint, and the Studio button.
This commit is contained in:
1 parent
0b0cf4f37f
commit
bb7ec3db02
3 files changed
+321
No files matched your search
@@ -0,0 +1,42 @@
|
||||
import { withAdmin } from "@/lib/api-handler";
|
||||
import { apiError, apiOk } from "@/lib/api-response";
|
||||
import { PERMS } from "@/lib/permissions";
|
||||
import { logAudit } from "@/lib/services/audit";
|
||||
import { organizeCatalogAll } from "@/lib/services/catalog-repair";
|
||||
import { rcon } from "@/lib/services/rcon";
|
||||
|
||||
// ── Fully automatic catalog organization of the whole database ──────
|
||||
export const POST = withAdmin(
|
||||
{ permission: PERMS.ASSETS_IMPORT },
|
||||
async (_request, ctx) => {
|
||||
try {
|
||||
const result = await organizeCatalogAll();
|
||||
|
||||
// Refresh game server caches so the reorganized catalog shows up.
|
||||
try {
|
||||
await rcon.updateCatalog();
|
||||
} catch (err) {
|
||||
console.warn(
|
||||
"[organize-furni] RCON catalog refresh failed:",
|
||||
(err as Error).message,
|
||||
);
|
||||
}
|
||||
|
||||
logAudit({
|
||||
userId: ctx.session.user.id,
|
||||
action: "furni_organize",
|
||||
target: "CatalogItems",
|
||||
targetId: 0,
|
||||
after: {
|
||||
pagesCreated: result.pagesCreated,
|
||||
catalogAdded: result.catalogAdded,
|
||||
catalogRehomed: result.catalogRehomed,
|
||||
},
|
||||
});
|
||||
|
||||
return apiOk({ ...result });
|
||||
} catch (err) {
|
||||
return apiError((err as Error).message, 500);
|
||||
}
|
||||
},
|
||||
);
|
||||
Reference in new issue
Block a user