feat: 增加运行时工作空间契约

This commit is contained in:
que01 committed 2026-09-21 15:24:34 +08:00
1 parent 36f5415483
commit 549b488d51
3 files changed
+51 -4

No files matched your search

+32 -2
View File
@@ -128,7 +128,7 @@ export class PublicWorkspaceController {
@Get()
async get(): Promise<unknown> {
const brandId = process.env.DEFAULT_BRAND_ID ?? "00000000-0000-0000-0000-000000000001";
const [brand, modules, fields, offerings, inquiryForm] = await Promise.all([
const [brand, modules, fields, offerings, inquiryForm, installation] = await Promise.all([
this.prisma.brandProfile.findUnique({ where: { id: brandId } }),
this.prisma.brandModule.findMany({
where: { brandId, isEnabled: true },
@@ -146,8 +146,38 @@ export class PublicWorkspaceController {
where: { brandId, isEnabled: true },
orderBy: { updatedAt: "desc" },
}),
this.prisma.brandTemplateInstallation.findFirst({
where: { brandId },
orderBy: { updatedAt: "desc" },
}),
]);
return { brand, modules, fields, offerings, inquiryForm };
const templateKey = installation?.templateKey ?? brand?.templateKey ?? "personal";
const template = getBrandTemplate(templateKey);
const runtimeModules = modules.map((module) => ({
key: module.type,
type: module.type,
title: module.title,
schemaVersion: "1.0",
sortOrder: module.sortOrder,
config: module.config,
}));
return {
contractVersion: "1.0",
brand,
template: template
? {
key: template.key,
version: installation?.templateVersion ?? template.version,
name: template.name,
}
: null,
capabilities: template?.capabilities ?? [],
modules,
runtimeModules,
fields,
offerings,
inquiryForm,
};
}
}