feat: add auto furniture interaction detection
CI / check (push) Successful in 25s
CI / release (push) Skipped
CI / deploy (push) Successful in 59s

- New auto-interaction.ts: detects canSit/canLay/canStand from classname/name keywords
- Maps keywords to interaction types (bench, chair, bed, table, etc.)
- Returns clickLimit and interactionModesCount for proper click/interaction limits
- Nitro editor: added auto-detect button with preview of detected settings
- furni-import.ts: auto-sets interaction_modes_count during import
- upload-import.ts: auto-detects for direct insert and SQL migrations
- clone-import.ts: auto-detects when cloning from other hotels
This commit is contained in:
openhands committed 2026-08-18 22:33:40 +02:00
1 parent 0b4fc4559e
commit dee843106f
8 files changed
+596 -25

No files matched your search

+11 -4
View File
@@ -2,6 +2,7 @@ import { existsSync, promises as fs } from "node:fs";
import path from "node:path";
import { eq, sql } from "drizzle-orm";
import { db, ItemsBase } from "@/lib/db";
import { autoDetectInteraction } from "@/lib/furni/auto-interaction";
import { getFurniAssetWriteTargets } from "@/lib/services/furni-asset-dirs";
import { appendFurniEntry, buildFurniEntry } from "@/lib/services/furni-data";
import {
@@ -158,6 +159,7 @@ async function writeSqlMigration(params: {
customparams: string;
price: { credits: number; points: number; pointsType: number };
categoryKey: string;
interactionModesCount: number;
}): Promise<string> {
const num = await findNextMigrationNumber();
const padded = String(num).padStart(4, "0");
@@ -193,12 +195,12 @@ async function writeSqlMigration(params: {
"",
`INSERT INTO items_base`,
` (id, sprite_id, public_name, item_name, type, width, length, stack_height,`,
` allow_stack, allow_sit, allow_lay, allow_walk, interaction_type, customparams)`,
` allow_stack, allow_sit, allow_lay, allow_walk, interaction_type, interaction_modes_count, customparams)`,
`VALUES`,
` (@next_id, @next_id, ${escapeSql(params.name)}, ${escapeSql(params.classname)},`,
` ${escapeSql(params.itemType)}, ${params.xdim}, ${params.ydim}, ${params.stackHeight},`,
` ${params.allowStack}, ${params.cansiton ? "1" : "0"}, ${params.canlayon ? "1" : "0"}, ${params.canstandon ? "1" : "0"},`,
` ${escapeSql(params.interactionType)}, ${escapeSql(params.customparams)});`,
` ${escapeSql(params.interactionType)}, ${params.interactionModesCount}, ${escapeSql(params.customparams)});`,
"",
`INSERT INTO catalog_items`,
` (id, page_id, item_ids, catalog_name, cost_credits, cost_points, points_type, amount, order_number, offer_id, extradata)`,
@@ -328,16 +330,20 @@ export async function uploadSingleFurni(params: {
const price = autoPriceFurni(classname);
// Auto-detect interaction modes count from classname/name
const autoInteraction = autoDetectInteraction(classname, name);
const interactionModesCount = autoInteraction.interactionModesCount;
let newId: number;
try {
newId = await allocateItemsBaseId(async (nextId) => {
await db.execute(sql`
INSERT INTO items_base
(id, sprite_id, public_name, item_name, type, width, length, stack_height,
allow_stack, allow_sit, allow_lay, allow_walk, interaction_type, customparams)
allow_stack, allow_sit, allow_lay, allow_walk, interaction_type, interaction_modes_count, customparams)
VALUES
(${nextId}, ${nextId}, ${name}, ${classname}, ${itemType}, ${xdim}, ${ydim}, ${stackHeight},
${allowStack}, ${cansiton ? "1" : "0"}, ${canlayon ? "1" : "0"}, ${canstandon ? "1" : "0"}, ${userInteractionType}, ${customparams})`);
${allowStack}, ${cansiton ? "1" : "0"}, ${canlayon ? "1" : "0"}, ${canstandon ? "1" : "0"}, ${userInteractionType}, ${interactionModesCount}, ${customparams})`);
return nextId;
});
} catch (err) {
@@ -402,6 +408,7 @@ export async function uploadSingleFurni(params: {
customparams,
price,
categoryKey: classifyFurni(classname, itemType),
interactionModesCount,
});
warnings.push(`SQL migration written: ${sqlFile}`);
} catch (err) {