ux improved
This commit is contained in:
19
src/modules/0-ui/handlers/aliases.js
Normal file
19
src/modules/0-ui/handlers/aliases.js
Normal 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 };
|
||||
}
|
||||
@@ -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)" };
|
||||
}
|
||||
|
||||
|
||||
47
src/modules/0-ui/handlers/recommendations.js
Normal file
47
src/modules/0-ui/handlers/recommendations.js
Normal 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 };
|
||||
}
|
||||
Reference in New Issue
Block a user