feat: 按模板要求校验信任内容发布

This commit is contained in:
que01 committed 2026-09-27 13:57:16 +08:00
1 parent e3a4074d8e
commit 5ed06b1abe
10 files changed
+71 -16

No files matched your search

@@ -10,6 +10,7 @@
- Admin 信任内容页面改用通用中文类型和逐行填写说明,不再出现餐饮专属管理术语;演示 seed 与模板 sampleContent 已移除旧 `profile/portfolio` 类型。
- 模板 manifest 现在可以声明信任类型的行业化 label、help 和 placeholder;Admin 通过 workspace contract 消费这些声明,平台不再硬编码行业文案。
- 新增迁移,将历史 `profile/experience/portfolio/testimonial` 数据归一化到 `credential/case`。
- 模板信任类型支持 `required`;发布 readiness 对当前模板逐项检查必需类型,并给出模板声明的名称和说明。
## 验证
@@ -18,3 +19,5 @@
- typecheck、lint:通过。
- Admin typecheck、production build、template catalog validation:通过。
- API integration:37/37 通过,包含模板化信任类型声明和历史类型迁移。
- readiness 集成测试验证取消发布餐饮必需的 `schedule` 后无法通过发布检查。
- 全量 lint、Admin production build、Prisma validate、模板包验证:通过。
@@ -3,3 +3,4 @@ id,task,status,acceptance_criteria,validation_command,completed_at,retry_count,n
2,迁移阿成演示内容,DONE,阿成 seed fixture 使用通用信任类型且不依赖模板 sampleContent,pnpm --filter @personal-brand/api test:integration,2026-09-27,0,模板示例仍由 package registry 管理
3,改造阿成三个页面,DONE,首页、出摊服务、主理人页面按 trustItems 渲染且无数据时隐藏对应区块,pnpm --filter @personal-brand/miniapp test:visual-fixture,2026-09-27,0,多行 content 在 miniapp view model 拆分
4,固化模板与数据库边界,DONE,AGENTS.md 明确禁止将所有模板 sample data 写入全局 seed,pnpm typecheck && pnpm lint,2026-09-27,0,规则已落盘
5,按模板必需类型校验发布完整性,DONE,readiness 对 manifest 标记 required 的信任类型逐项检查且 API 测试覆盖缺项,pnpm --filter @personal-brand/api test:integration,2026-09-27,0,阿成 schedule coverage process 必需;林境 process credential 必需
1 id task status acceptance_criteria validation_command completed_at retry_count notes
3 2 迁移阿成演示内容 DONE 阿成 seed fixture 使用通用信任类型且不依赖模板 sampleContent pnpm --filter @personal-brand/api test:integration 2026-09-27 0 模板示例仍由 package registry 管理
4 3 改造阿成三个页面 DONE 首页、出摊服务、主理人页面按 trustItems 渲染且无数据时隐藏对应区块 pnpm --filter @personal-brand/miniapp test:visual-fixture 2026-09-27 0 多行 content 在 miniapp view model 拆分
5 4 固化模板与数据库边界 DONE AGENTS.md 明确禁止将所有模板 sample data 写入全局 seed pnpm typecheck && pnpm lint 2026-09-27 0 规则已落盘
6 5 按模板必需类型校验发布完整性 DONE readiness 对 manifest 标记 required 的信任类型逐项检查且 API 测试覆盖缺项 pnpm --filter @personal-brand/api test:integration 2026-09-27 0 阿成 schedule coverage process 必需;林境 process credential 必需
+18 -4
View File
@@ -69,7 +69,7 @@ export class BrandReleaseApiService {
: getDefaultVisualTemplateKey(brand?.templateKey ?? "personal");
const visual = getVisualTemplate(visualKey);
const packageManifest = getTemplatePackageManifestForVisualKey(visualKey);
const [offerings, forms, trust] = await Promise.all([
const [offerings, forms, trustItems] = await Promise.all([
database.offering.findMany({
where: { brandId, isEnabled: true },
select: { id: true, name: true, coverUrl: true, config: true },
@@ -78,7 +78,10 @@ export class BrandReleaseApiService {
where: { brandId, isEnabled: true },
select: { offeringId: true, fieldsSnapshot: true },
}),
database.trustContent.count({ where: { brandId, isPublished: true } }),
database.trustContent.findMany({
where: { brandId, isPublished: true },
select: { type: true },
}),
]);
const offeringIds = new Set(offerings.map((item) => item.id));
const usableForms = forms.filter(
@@ -129,10 +132,21 @@ export class BrandReleaseApiService {
{
key: "trust",
label: "至少需要一条已发布的信任内容",
passed: trust > 0,
passed: trustItems.length > 0,
destination: "/admin/trust",
},
];
const publishedTrustTypes = new Set(trustItems.map((item) => item.type));
for (const type of packageManifest?.trustContentTypes ?? []) {
if (type.required !== true) continue;
checks.push({
key: `trust:${type.type}`,
label: `请补充${type.label}`,
passed: publishedTrustTypes.has(type.type),
...(type.help ? { help: type.help } : {}),
destination: "/admin/trust",
});
}
const brandRecord = { ...this.jsonObject(brand), config };
for (const section of packageManifest?.admin.sections ?? []) {
for (const field of section.fields) {
@@ -166,7 +180,7 @@ export class BrandReleaseApiService {
? offerings.length > 0 && offerings.every((item) => Boolean(item.coverUrl?.trim()))
: slot.target === "brand"
? this.resolveBinding(slot.binding, { brand: brandRecord, offerings })
: trust > 0;
: trustItems.length > 0;
checks.push({
key: `asset:${String(slot.key)}`,
label: present ? `已添加${String(slot.label)}` : `请添加${String(slot.label)}`,
+24
View File
@@ -94,6 +94,30 @@ test("admin release lifecycle is authorized, brand-scoped, and versioned", async
data: { isEnabled: true },
});
}
const scheduleTrust = await prisma.trustContent.findFirst({
where: { brandId, type: "schedule", isPublished: true },
});
assert.ok(scheduleTrust);
await prisma.trustContent.update({
where: { id: scheduleTrust.id },
data: { isPublished: false },
});
try {
const missingTrust = await request("/admin/releases/readiness", {
headers: { authorization: `Bearer ${adminToken}` },
});
const missingTrustBody = JSON.parse(missingTrust.body);
assert.equal(missingTrustBody.ready, false);
assert.equal(
missingTrustBody.checks.find((check) => check.key === "trust:schedule")?.passed,
false,
);
} finally {
await prisma.trustContent.update({
where: { id: scheduleTrust.id },
data: { isPublished: true },
});
}
const originalBrand = await prisma.brandProfile.findUniqueOrThrow({ where: { id: brandId } });
const originalConfig = originalBrand.config;
const originalOffering = await prisma.offering.findFirstOrThrow({ where: { brandId } });
+7 -1
View File
@@ -87,7 +87,13 @@ export interface TemplateAdminSection {
export interface AdminTemplateContent {
displayName: string;
admin: { sections: TemplateAdminSection[] };
trustContentTypes?: Array<{ type: string; label: string; help?: string; placeholder?: string }>;
trustContentTypes?: Array<{
type: string;
label: string;
help?: string;
placeholder?: string;
required?: boolean;
}>;
assetSlots: Array<{
key: string;
binding: string;
@@ -293,19 +293,22 @@ export const generatedTemplatePackageRegistry = [
"type": "schedule",
"label": "出摊与营业安排",
"help": "说明固定出摊时间、临时营业安排或接受预订的时段。",
"placeholder": "例如:周一至周五 17:00 - 22:30"
"placeholder": "例如:周一至周五 17:00 - 22:30",
"required": true
},
{
"type": "coverage",
"label": "取餐与配送范围",
"help": "说明服务地点、取餐方式和可配送范围。",
"placeholder": "例如:支持校内宿舍楼下配送"
"placeholder": "例如:支持校内宿舍楼下配送",
"required": true
},
{
"type": "process",
"label": "定制餐品流程",
"help": "每行写一步,从提出需求到完成交付。",
"placeholder": "例如:提交需求\n确认菜单\n制作交付"
"placeholder": "例如:提交需求\n确认菜单\n制作交付",
"required": true
},
{
"type": "credential",
@@ -731,12 +734,14 @@ export const generatedTemplatePackageRegistry = [
"type": "process",
"label": "合作流程",
"help": "每行写一步,从初次沟通到交付完成。",
"placeholder": "例如:需求沟通\n方案确认\n落地交付"
"placeholder": "例如:需求沟通\n方案确认\n落地交付",
"required": true
},
{
"type": "credential",
"label": "专业资历与方法",
"help": "填写经验、资质、专业标准或工作方法。"
"help": "填写经验、资质、专业标准或工作方法。",
"required": true
},
{
"type": "case",
@@ -980,4 +985,4 @@ export const generatedTemplatePackageRegistry = [
}
];
export const generatedTemplatePackageRegistryHash =
"afbd1045ccdc7eda85bd9707ce27083ba699899f115a26a3c60459a88a5e5148";
"f7ba069156be4fdf8f21c6e600796082ff87d5c04b0ed2a07d3b7d4ca68817b5";
+1
View File
@@ -230,6 +230,7 @@ export interface TemplatePackageManifest {
label: string;
help?: string;
placeholder?: string;
required?: boolean;
}[];
sampleContent?: Partial<Record<BrandTemplateKey, TemplateSampleContent>>;
}
@@ -282,9 +282,9 @@
]
},
"trustContentTypes": [
{ "type": "schedule", "label": "出摊与营业安排", "help": "说明固定出摊时间、临时营业安排或接受预订的时段。", "placeholder": "例如:周一至周五 17:00 - 22:30" },
{ "type": "coverage", "label": "取餐与配送范围", "help": "说明服务地点、取餐方式和可配送范围。", "placeholder": "例如:支持校内宿舍楼下配送" },
{ "type": "process", "label": "定制餐品流程", "help": "每行写一步,从提出需求到完成交付。", "placeholder": "例如:提交需求\n确认菜单\n制作交付" },
{ "type": "schedule", "label": "出摊与营业安排", "help": "说明固定出摊时间、临时营业安排或接受预订的时段。", "placeholder": "例如:周一至周五 17:00 - 22:30", "required": true },
{ "type": "coverage", "label": "取餐与配送范围", "help": "说明服务地点、取餐方式和可配送范围。", "placeholder": "例如:支持校内宿舍楼下配送", "required": true },
{ "type": "process", "label": "定制餐品流程", "help": "每行写一步,从提出需求到完成交付。", "placeholder": "例如:提交需求\n确认菜单\n制作交付", "required": true },
{ "type": "credential", "label": "食品安全与制作标准", "help": "填写让顾客放心的资质、卫生或制作标准。" },
{ "type": "case", "label": "客户案例与反馈", "help": "填写代表性订单、活动案例或客户评价。" },
{ "type": "promise", "label": "回复与服务承诺", "help": "说明回复时间、退改规则或服务承诺。" }
+1
View File
@@ -69,6 +69,7 @@ export type TemplateTrustContentType = {
label: string;
help?: string;
placeholder?: string;
required?: boolean;
};
export type TemplateSampleContent = {
@@ -272,8 +272,8 @@
"trustContentTypes": [
{ "type": "schedule", "label": "服务与合作安排", "help": "说明可预约时间、服务周期或项目排期。" },
{ "type": "coverage", "label": "服务范围与适用对象", "help": "说明服务地区、项目类型或合作边界。" },
{ "type": "process", "label": "合作流程", "help": "每行写一步,从初次沟通到交付完成。", "placeholder": "例如:需求沟通\n方案确认\n落地交付" },
{ "type": "credential", "label": "专业资历与方法", "help": "填写经验、资质、专业标准或工作方法。" },
{ "type": "process", "label": "合作流程", "help": "每行写一步,从初次沟通到交付完成。", "placeholder": "例如:需求沟通\n方案确认\n落地交付", "required": true },
{ "type": "credential", "label": "专业资历与方法", "help": "填写经验、资质、专业标准或工作方法。", "required": true },
{ "type": "case", "label": "项目案例与客户反馈", "help": "填写代表性项目、成果或客户评价。" },
{ "type": "promise", "label": "合作预期与响应承诺", "help": "说明回复时间、合作边界和后续跟进方式。" }
],