Skip setup questions on the template path and collect name, photo, and description without recommendations.

Customize opens a dialog then walks the template decks; Use without changes lands on final review with Has Name Field. Template cards stay first, the engine is not called, and the catalog no longer shows a recommended tag.
This commit is contained in:
adilallo committed 2026-11-09 17:34:33 -07:00
1 parent 53d236d0d5
commit 6498d52541
37 files changed
+1450 -733

No files matched your search

-52
View File
@@ -15,18 +15,8 @@ export type RuleTemplateDto = {
type TemplatesResponse = {
templates?: RuleTemplateDto[];
scores?: Record<string, TemplateFacetScoreDto>;
};
function parseScoresPayload(
raw: unknown,
): Record<string, TemplateFacetScoreDto> {
if (raw && typeof raw === "object" && !Array.isArray(raw)) {
return raw as Record<string, TemplateFacetScoreDto>;
}
return {};
}
async function getTemplatesJson(
queryString: string,
signal: AbortSignal | undefined,
@@ -51,17 +41,6 @@ async function getTemplatesJson(
}
}
/** Matches `listRankedRuleTemplatesFromDb` / GET `/api/templates` with facet params. */
export type TemplateFacetScoreDto = {
score: number;
matchedFacets: string[];
};
export type RankedTemplatesFetchResult = {
templates: RuleTemplateDto[];
scores: Record<string, TemplateFacetScoreDto>;
};
export type FetchTemplatesOptions = {
signal?: AbortSignal;
};
@@ -100,37 +79,6 @@ export async function fetchTemplates(
return Array.isArray(data.templates) ? data.templates : [];
}
/**
* Facet-ranked list + per-template scores (CR-88). Query must be non-empty
* `facet.size=…&…` from {@link buildFacetQueryString}.
*/
export async function fetchRankedTemplatesByFacets(options: {
facetQuery: string;
signal?: AbortSignal;
}): Promise<RankedTemplatesFetchResult | { error: string }> {
if (options.facetQuery.length === 0) {
return { error: "Could not load templates" };
}
const got = await getTemplatesJson(options.facetQuery, options.signal);
if (got.ok === false) {
if (got.error === "aborted") {
throw new DOMException("Aborted", "AbortError");
}
return { error: "Could not load templates" };
}
const { data, statusOk } = got;
if (!statusOk) {
return {
error:
typeof data.error === "string"
? data.error
: "Could not load templates",
};
}
const templates = Array.isArray(data.templates) ? data.templates : [];
return { templates, scores: parseScoresPayload(data.scores) };
}
export type TemplateDetailDto = {
template: RuleTemplateDto;
methods: Array<{ section: string; slug: string }>;