ux improved

This commit is contained in:
Lucas Tettamanti
2026-01-17 04:13:35 -03:00
parent 98e3d78e3d
commit 63b9ecef61
35 changed files with 4266 additions and 75 deletions

View File

@@ -0,0 +1,19 @@
import { listAliases, insertAlias, updateAlias, deleteAlias } from "../db/repo.js";
export async function handleListAliases({ tenantId, q = "", woo_product_id = null, limit = 200 }) {
const items = await listAliases({ tenantId, q, woo_product_id, limit });
return { items };
}
export async function handleCreateAlias({ tenantId, alias, woo_product_id, boost = 0, category_hint = null, metadata = {} }) {
return insertAlias({ tenantId, alias, woo_product_id, boost, category_hint, metadata });
}
export async function handleUpdateAlias({ tenantId, alias, woo_product_id, boost = 0, category_hint = null, metadata = {} }) {
return updateAlias({ tenantId, alias, woo_product_id, boost, category_hint, metadata });
}
export async function handleDeleteAlias({ tenantId, alias }) {
const deleted = await deleteAlias({ tenantId, alias });
return { deleted };
}

View File

@@ -1,4 +1,5 @@
import { searchSnapshotItems } from "../../shared/wooSnapshot.js";
import { listProducts, getProductByWooId } from "../db/repo.js";
export async function handleSearchProducts({ tenantId, q = "", limit = "10", forceWoo = "0" }) {
const { items, source } = await searchSnapshotItems({
@@ -9,3 +10,18 @@ export async function handleSearchProducts({ tenantId, q = "", limit = "10", for
return { items, source };
}
export async function handleListProducts({ tenantId, q = "", limit = 2000, offset = 0 }) {
const items = await listProducts({ tenantId, q, limit, offset });
return { items };
}
export async function handleGetProduct({ tenantId, wooProductId }) {
return getProductByWooId({ tenantId, wooProductId });
}
export async function handleSyncProducts({ tenantId }) {
// This is a placeholder - actual sync would fetch from Woo API
// For now, just return success
return { ok: true, message: "Sync triggered (use import script for full sync)" };
}

View File

@@ -0,0 +1,47 @@
import {
listRecommendations,
getRecommendationById,
insertRecommendation,
updateRecommendation,
deleteRecommendation,
} from "../db/repo.js";
export async function handleListRecommendations({ tenantId, q = "", limit = 200 }) {
const items = await listRecommendations({ tenantId, q, limit });
return { items };
}
export async function handleGetRecommendation({ tenantId, id }) {
return getRecommendationById({ tenantId, id });
}
export async function handleCreateRecommendation({
tenantId,
rule_key,
trigger = {},
queries = [],
boosts = {},
ask_slots = [],
active = true,
priority = 100,
}) {
return insertRecommendation({ tenantId, rule_key, trigger, queries, boosts, ask_slots, active, priority });
}
export async function handleUpdateRecommendation({
tenantId,
id,
trigger,
queries,
boosts,
ask_slots,
active,
priority,
}) {
return updateRecommendation({ tenantId, id, trigger, queries, boosts, ask_slots, active, priority });
}
export async function handleDeleteRecommendation({ tenantId, id }) {
const deleted = await deleteRecommendation({ tenantId, id });
return { deleted };
}