refactor: 统一模板契约并修复预览版本
This commit is contained in:
1 parent
cd2992c00a
commit
50b87e48de
56 files changed
+7849
-5756
No files matched your search
@@ -8,6 +8,7 @@
|
|||||||
- The food template is supported, but it is an example template rather than the product definition.
|
- The food template is supported, but it is an example template rather than the product definition.
|
||||||
- Backend configuration is the source of truth for brand content, services, template selection, trust-building content, and industry-specific fields. The mini program only renders configuration and submits user input.
|
- Backend configuration is the source of truth for brand content, services, template selection, trust-building content, and industry-specific fields. The mini program only renders configuration and submits user input.
|
||||||
- Template packages are the source of truth for template manifests, visual structure, default/sample content, field declarations, assets, and capabilities. Do not copy every template's sample data into Prisma seed or global database tables. A template's sample content may be copied into the database only when an administrator explicitly imports it for one specific brand; the resulting rows are brand content, not template registration.
|
- Template packages are the source of truth for template manifests, visual structure, default/sample content, field declarations, assets, and capabilities. Do not copy every template's sample data into Prisma seed or global database tables. A template's sample content may be copied into the database only when an administrator explicitly imports it for one specific brand; the resulting rows are brand content, not template registration.
|
||||||
|
- Templates have exactly one active package manifest/runtime contract. Do not add legacy readers, dual-write paths, inferred defaults, aliases, or silent fallbacks. Convert existing persisted data with a one-time, auditable migration that fails on ambiguity, then remove the old representation.
|
||||||
- `apps/api/prisma/seed.ts` may contain a small, explicit development fixture for the seeded demo brands, but it must never become the catalog of all templates or require one seed block per production template. New templates must be discoverable and validated from their package manifest without editing global seed data.
|
- `apps/api/prisma/seed.ts` may contain a small, explicit development fixture for the seeded demo brands, but it must never become the catalog of all templates or require one seed block per production template. New templates must be discoverable and validated from their package manifest without editing global seed data.
|
||||||
- Any delivered backend endpoint must have an automated test covering its authorization and successful behavior before it is considered complete.
|
- Any delivered backend endpoint must have an automated test covering its authorization and successful behavior before it is considered complete.
|
||||||
- Keep personal-brand trust details explicit: biography, positioning, credentials, portfolio/proof, process, expectations, availability, contact methods, and clear follow-up status.
|
- Keep personal-brand trust details explicit: biography, positioning, credentials, portfolio/proof, process, expectations, availability, contact methods, and clear follow-up status.
|
||||||
|
|||||||
@@ -17,11 +17,7 @@ function pageContent({ workspace, page }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function resolveTemplateRenderer(workspace) {
|
export function resolveTemplateRenderer(workspace) {
|
||||||
const config = workspace?.brand?.config;
|
const key = workspace?.visualTemplate?.key;
|
||||||
const key =
|
|
||||||
config && typeof config === "object" && !Array.isArray(config)
|
|
||||||
? config.visualTemplateKey
|
|
||||||
: undefined;
|
|
||||||
if (typeof key !== "string") return null;
|
if (typeof key !== "string") return null;
|
||||||
if (resolvedRenderers.has(key)) return resolvedRenderers.get(key);
|
if (resolvedRenderers.has(key)) return resolvedRenderers.get(key);
|
||||||
const suffix = `/template-${key}/taro/index.tsx`;
|
const suffix = `/template-${key}/taro/index.tsx`;
|
||||||
|
|||||||
@@ -111,8 +111,6 @@ export function useBrandSaveMutation({
|
|||||||
return useMutation({
|
return useMutation({
|
||||||
mutationFn: (values: PresentationValues) => {
|
mutationFn: (values: PresentationValues) => {
|
||||||
const nextConfig = applyPresentationValues(config, sections, values);
|
const nextConfig = applyPresentationValues(config, sections, values);
|
||||||
const contentConfig = { ...nextConfig };
|
|
||||||
delete contentConfig.visualTemplateKey;
|
|
||||||
const standard = applyStandardBrandValues(
|
const standard = applyStandardBrandValues(
|
||||||
brand as unknown as Record<string, unknown>,
|
brand as unknown as Record<string, unknown>,
|
||||||
sections,
|
sections,
|
||||||
@@ -124,7 +122,7 @@ export function useBrandSaveMutation({
|
|||||||
key !== "config" && value !== (brand as unknown as Record<string, unknown>)[key],
|
key !== "config" && value !== (brand as unknown as Record<string, unknown>)[key],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
return createApiClient().updateAdminBrand({ ...changed, config: contentConfig });
|
return createApiClient().updateAdminBrand({ ...changed, config: nextConfig });
|
||||||
},
|
},
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
onSaved();
|
onSaved();
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ export function PublicationPage({ canManageTemplate }: { canManageTemplate: bool
|
|||||||
};
|
};
|
||||||
const mutations = usePublicationMutations({
|
const mutations = usePublicationMutations({
|
||||||
refresh,
|
refresh,
|
||||||
brandConfig: brand.data?.config,
|
currentTemplatePackageVersionId: workspace.data?.installations[0]?.templatePackageVersionId,
|
||||||
onInstallClose: () => setIndustryTarget(null),
|
onInstallClose: () => setIndustryTarget(null),
|
||||||
onPublishClose: () => setConfirmAction(null),
|
onPublishClose: () => setConfirmAction(null),
|
||||||
onNoteClear: () => setNote(""),
|
onNoteClear: () => setNote(""),
|
||||||
@@ -104,16 +104,14 @@ export function PublicationPage({ canManageTemplate }: { canManageTemplate: bool
|
|||||||
workspace.data?.installations[0]?.templateKey ??
|
workspace.data?.installations[0]?.templateKey ??
|
||||||
workspace.data?.brand?.templateKey ??
|
workspace.data?.brand?.templateKey ??
|
||||||
brand.data?.templateKey ??
|
brand.data?.templateKey ??
|
||||||
catalog.data?.industries[0]?.key ??
|
|
||||||
null;
|
null;
|
||||||
const visuals = (catalog.data?.visuals ?? []).filter(
|
const selectablePackageVersions = (queries.packages.data?.items ?? []).filter(
|
||||||
(item) =>
|
(item) =>
|
||||||
typeof industryKey === "string" && item.supportedIndustryTemplates.includes(industryKey),
|
item.status === "published" &&
|
||||||
|
typeof industryKey === "string" &&
|
||||||
|
item.manifestSummary?.supportedIndustryTemplates.includes(industryKey),
|
||||||
);
|
);
|
||||||
const visualKey =
|
const visualKey = workspace.data?.installations[0]?.visualTemplateKey ?? null;
|
||||||
typeof brand.data?.config?.visualTemplateKey === "string"
|
|
||||||
? brand.data.config.visualTemplateKey
|
|
||||||
: (visuals[0]?.key ?? null);
|
|
||||||
const currentRelease = releases.data?.find((item) => item.status === "published");
|
const currentRelease = releases.data?.find((item) => item.status === "published");
|
||||||
const publishedHistory = (releases.data ?? []).filter(
|
const publishedHistory = (releases.data ?? []).filter(
|
||||||
(item) => item.status === "published" || item.status === "superseded",
|
(item) => item.status === "published" || item.status === "superseded",
|
||||||
@@ -182,8 +180,11 @@ export function PublicationPage({ canManageTemplate }: { canManageTemplate: bool
|
|||||||
value={visualKey}
|
value={visualKey}
|
||||||
disabled={!canManageTemplate}
|
disabled={!canManageTemplate}
|
||||||
loading={selectVisual.isPending}
|
loading={selectVisual.isPending}
|
||||||
options={visuals.map((item) => ({ value: item.key, label: item.name }))}
|
options={selectablePackageVersions.map((item) => ({
|
||||||
onChange={(key) => selectVisual.mutate(key)}
|
value: item.id,
|
||||||
|
label: `${item.displayName} · ${item.version}`,
|
||||||
|
}))}
|
||||||
|
onChange={(versionId) => selectVisual.mutate(versionId)}
|
||||||
/>
|
/>
|
||||||
</Space>
|
</Space>
|
||||||
{industryKey ? (
|
{industryKey ? (
|
||||||
@@ -350,9 +351,7 @@ export function PublicationPage({ canManageTemplate }: { canManageTemplate: bool
|
|||||||
{sample.data && !sample.data.alreadyImported && (
|
{sample.data && !sample.data.alreadyImported && (
|
||||||
<p className="admin-section-description admin-offset-top-sm">
|
<p className="admin-section-description admin-offset-top-sm">
|
||||||
来源:{sample.data.source.packageKey}@{sample.data.source.version}
|
来源:{sample.data.source.packageKey}@{sample.data.source.version}
|
||||||
{sample.data.source.contentChecksum
|
(checksum {(sample.data.source.contentChecksum ?? "").slice(0, 12)})
|
||||||
? `(checksum ${sample.data.source.contentChecksum.slice(0, 12)})`
|
|
||||||
: "(兼容 registry 来源)"}
|
|
||||||
。将向草稿添加{" "}
|
。将向草稿添加{" "}
|
||||||
{Object.entries(sample.data.counts)
|
{Object.entries(sample.data.counts)
|
||||||
.map(([key, count]) => `${key} ${count} 项`)
|
.map(([key, count]) => `${key} ${count} 项`)
|
||||||
@@ -589,7 +588,15 @@ export function PublicationPage({ canManageTemplate }: { canManageTemplate: bool
|
|||||||
title="确认安装行业模板"
|
title="确认安装行业模板"
|
||||||
open={industryTarget !== null}
|
open={industryTarget !== null}
|
||||||
onCancel={() => setIndustryTarget(null)}
|
onCancel={() => setIndustryTarget(null)}
|
||||||
onOk={() => industryTarget && install.mutate({ key: industryTarget })}
|
okButtonProps={{ disabled: !templatePreview.data?.targetPackageVersionId }}
|
||||||
|
onOk={() =>
|
||||||
|
industryTarget &&
|
||||||
|
templatePreview.data?.targetPackageVersionId &&
|
||||||
|
install.mutate({
|
||||||
|
key: industryTarget,
|
||||||
|
versionId: templatePreview.data.targetPackageVersionId,
|
||||||
|
})
|
||||||
|
}
|
||||||
confirmLoading={install.isPending}
|
confirmLoading={install.isPending}
|
||||||
>
|
>
|
||||||
模板会更新当前品牌的草稿结构,不会立即改变已发布的小程序。请安装后核对业务内容与视觉模板。
|
模板会更新当前品牌的草稿结构,不会立即改变已发布的小程序。请安装后核对业务内容与视觉模板。
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ const client = createApiClient();
|
|||||||
|
|
||||||
interface MutationOptions {
|
interface MutationOptions {
|
||||||
refresh: () => void;
|
refresh: () => void;
|
||||||
brandConfig: Record<string, unknown> | null | undefined;
|
currentTemplatePackageVersionId: string | null | undefined;
|
||||||
onInstallClose: () => void;
|
onInstallClose: () => void;
|
||||||
onPublishClose: () => void;
|
onPublishClose: () => void;
|
||||||
onNoteClear: () => void;
|
onNoteClear: () => void;
|
||||||
@@ -20,11 +20,11 @@ export function usePublicationMutations({
|
|||||||
onPublishClose,
|
onPublishClose,
|
||||||
onNoteClear,
|
onNoteClear,
|
||||||
onRollbackClose,
|
onRollbackClose,
|
||||||
brandConfig,
|
currentTemplatePackageVersionId,
|
||||||
}: MutationOptions) {
|
}: MutationOptions) {
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const install = useMutation({
|
const install = useMutation({
|
||||||
mutationFn: ({ key, versionId }: { key: BrandTemplateKey; versionId?: string }) =>
|
mutationFn: ({ key, versionId }: { key: BrandTemplateKey; versionId: string }) =>
|
||||||
client.installAdminTemplate(key, versionId),
|
client.installAdminTemplate(key, versionId),
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
onInstallClose();
|
onInstallClose();
|
||||||
@@ -55,12 +55,16 @@ export function usePublicationMutations({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
const selectVisual = useMutation({
|
const selectVisual = useMutation({
|
||||||
mutationFn: (key: string) =>
|
mutationFn: (templatePackageVersionId: string) =>
|
||||||
client.updateAdminBrand({
|
client.selectAdminTemplateVersion({
|
||||||
config: { ...(brandConfig ?? {}), visualTemplateKey: key },
|
templatePackageVersionId,
|
||||||
|
...(currentTemplatePackageVersionId !== undefined
|
||||||
|
? { expectedCurrentPackageVersionId: currentTemplatePackageVersionId }
|
||||||
|
: {}),
|
||||||
|
confirm: true,
|
||||||
}),
|
}),
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
message.success("视觉模板已保存到草稿");
|
message.success("模板版本已切换");
|
||||||
refresh();
|
refresh();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -24,6 +24,10 @@ export function usePublicationQueries(
|
|||||||
queryKey: ["publication-catalog"],
|
queryKey: ["publication-catalog"],
|
||||||
queryFn: () => client.listPublicTemplates(),
|
queryFn: () => client.listPublicTemplates(),
|
||||||
});
|
});
|
||||||
|
const packages = useQuery<Awaited<ReturnType<typeof client.listAdminTemplatePackages>>>({
|
||||||
|
queryKey: ["publication-template-packages"],
|
||||||
|
queryFn: () => client.listAdminTemplatePackages({ page: 1, pageSize: 100 }),
|
||||||
|
});
|
||||||
const sample = useQuery<Awaited<ReturnType<typeof client.previewAdminSampleContent>>>({
|
const sample = useQuery<Awaited<ReturnType<typeof client.previewAdminSampleContent>>>({
|
||||||
queryKey: ["publication-sample", workspace.data?.installations[0]?.templatePackageVersionId],
|
queryKey: ["publication-sample", workspace.data?.installations[0]?.templatePackageVersionId],
|
||||||
queryFn: () =>
|
queryFn: () =>
|
||||||
@@ -82,6 +86,7 @@ export function usePublicationQueries(
|
|||||||
brand,
|
brand,
|
||||||
workspace,
|
workspace,
|
||||||
catalog,
|
catalog,
|
||||||
|
packages,
|
||||||
readiness,
|
readiness,
|
||||||
releases,
|
releases,
|
||||||
miniAppReleases,
|
miniAppReleases,
|
||||||
@@ -91,6 +96,7 @@ export function usePublicationQueries(
|
|||||||
brand,
|
brand,
|
||||||
workspace,
|
workspace,
|
||||||
catalog,
|
catalog,
|
||||||
|
packages,
|
||||||
readiness,
|
readiness,
|
||||||
releases,
|
releases,
|
||||||
miniAppReleases,
|
miniAppReleases,
|
||||||
@@ -100,6 +106,7 @@ export function usePublicationQueries(
|
|||||||
void brand.refetch();
|
void brand.refetch();
|
||||||
void workspace.refetch();
|
void workspace.refetch();
|
||||||
void catalog.refetch();
|
void catalog.refetch();
|
||||||
|
void packages.refetch();
|
||||||
void readiness.refetch();
|
void readiness.refetch();
|
||||||
void releases.refetch();
|
void releases.refetch();
|
||||||
void miniAppReleases.refetch();
|
void miniAppReleases.refetch();
|
||||||
@@ -110,6 +117,7 @@ export function usePublicationQueries(
|
|||||||
brand,
|
brand,
|
||||||
workspace,
|
workspace,
|
||||||
catalog,
|
catalog,
|
||||||
|
packages,
|
||||||
sample,
|
sample,
|
||||||
readiness,
|
readiness,
|
||||||
releases,
|
releases,
|
||||||
|
|||||||
+107
@@ -0,0 +1,107 @@
|
|||||||
|
DO $$
|
||||||
|
BEGIN
|
||||||
|
IF EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM "BrandTemplateInstallation"
|
||||||
|
GROUP BY "brandId"
|
||||||
|
HAVING COUNT(*) > 1
|
||||||
|
) THEN
|
||||||
|
RAISE EXCEPTION 'Template contract migration stopped: a brand has multiple template installations';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
IF EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM "BrandTemplateInstallation" installation
|
||||||
|
LEFT JOIN "TemplatePackageVersion" package_version
|
||||||
|
ON package_version."id" = installation."templatePackageVersionId"
|
||||||
|
WHERE installation."templatePackageVersionId" IS NULL
|
||||||
|
OR package_version."id" IS NULL
|
||||||
|
OR package_version."status" <> 'published'
|
||||||
|
) THEN
|
||||||
|
RAISE EXCEPTION 'Template contract migration stopped: an installation has no exact package version';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
IF EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM "BrandTemplateInstallation" installation
|
||||||
|
JOIN "TemplatePackageVersion" package_version
|
||||||
|
ON package_version."id" = installation."templatePackageVersionId"
|
||||||
|
JOIN "BrandProfile" brand ON brand."id" = installation."brandId"
|
||||||
|
WHERE installation."visualTemplateKey" IS DISTINCT FROM package_version."visualTemplateKey"
|
||||||
|
OR package_version."visualTemplateKey" IS DISTINCT FROM package_version."packageKey"
|
||||||
|
OR package_version."manifestSnapshot"->>'visualTemplateKey' IS DISTINCT FROM package_version."visualTemplateKey"
|
||||||
|
OR package_version."manifestSnapshot"->>'packageKey' IS DISTINCT FROM package_version."packageKey"
|
||||||
|
OR package_version."manifestSnapshot"->>'version' IS DISTINCT FROM package_version."version"
|
||||||
|
OR NOT COALESCE(package_version."manifestSnapshot"->'supportedIndustryTemplates' ? brand."templateKey", false)
|
||||||
|
OR installation."templateKey" IS DISTINCT FROM brand."templateKey"
|
||||||
|
OR (installation."contentChecksum" IS NOT NULL AND installation."contentChecksum" IS DISTINCT FROM package_version."contentChecksum")
|
||||||
|
) THEN
|
||||||
|
RAISE EXCEPTION 'Template contract migration stopped: installation, brand, package row, or manifest disagree';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
IF EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM "BrandProfile" brand
|
||||||
|
LEFT JOIN "BrandTemplateInstallation" installation ON installation."brandId" = brand."id"
|
||||||
|
WHERE installation."id" IS NULL
|
||||||
|
) THEN
|
||||||
|
RAISE EXCEPTION 'Template contract migration stopped: a brand has no explicit template installation';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
IF EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM "BrandProfile" brand
|
||||||
|
JOIN "BrandTemplateInstallation" installation ON installation."brandId" = brand."id"
|
||||||
|
JOIN "TemplatePackageVersion" package_version
|
||||||
|
ON package_version."id" = installation."templatePackageVersionId"
|
||||||
|
WHERE brand."config" ? 'visualTemplateKey'
|
||||||
|
AND brand."config"->>'visualTemplateKey' IS DISTINCT FROM package_version."visualTemplateKey"
|
||||||
|
) THEN
|
||||||
|
RAISE EXCEPTION 'Template contract migration stopped: brand config visualTemplateKey conflicts with its installation';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
IF EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM "BrandProfile" brand
|
||||||
|
LEFT JOIN "BrandTemplateInstallation" installation ON installation."brandId" = brand."id"
|
||||||
|
WHERE brand."config" ? 'visualTemplateKey'
|
||||||
|
AND installation."id" IS NULL
|
||||||
|
) THEN
|
||||||
|
RAISE EXCEPTION 'Template contract migration stopped: brand config visualTemplateKey has no installation to verify against';
|
||||||
|
END IF;
|
||||||
|
END $$;
|
||||||
|
|
||||||
|
DO $$
|
||||||
|
BEGIN
|
||||||
|
IF EXISTS (
|
||||||
|
SELECT 1 FROM "TemplatePackageVersion" package_version
|
||||||
|
WHERE package_version."visualTemplateKey" IS DISTINCT FROM package_version."packageKey"
|
||||||
|
OR package_version."manifestSnapshot"->>'visualTemplateKey' IS DISTINCT FROM package_version."packageKey"
|
||||||
|
OR package_version."manifestSnapshot"->>'packageKey' IS DISTINCT FROM package_version."packageKey"
|
||||||
|
OR package_version."manifestSnapshot"->>'version' IS DISTINCT FROM package_version."version"
|
||||||
|
) THEN
|
||||||
|
RAISE EXCEPTION 'Template contract migration stopped: package metadata conflicts with its manifest';
|
||||||
|
END IF;
|
||||||
|
END $$;
|
||||||
|
|
||||||
|
UPDATE "BrandTemplateInstallation" installation
|
||||||
|
SET "templateVersion" = package_version."version",
|
||||||
|
"contentChecksum" = package_version."contentChecksum"
|
||||||
|
FROM "TemplatePackageVersion" package_version
|
||||||
|
WHERE package_version."id" = installation."templatePackageVersionId";
|
||||||
|
|
||||||
|
UPDATE "BrandProfile"
|
||||||
|
SET "config" = "config" - 'visualTemplateKey'
|
||||||
|
WHERE "config" ? 'visualTemplateKey';
|
||||||
|
|
||||||
|
ALTER TABLE "BrandTemplateInstallation"
|
||||||
|
DROP CONSTRAINT "BrandTemplateInstallation_templatePackageVersionId_fkey",
|
||||||
|
DROP COLUMN "visualTemplateKey",
|
||||||
|
ALTER COLUMN "templatePackageVersionId" SET NOT NULL,
|
||||||
|
ADD CONSTRAINT "BrandTemplateInstallation_templatePackageVersionId_fkey"
|
||||||
|
FOREIGN KEY ("templatePackageVersionId") REFERENCES "TemplatePackageVersion"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
ALTER TABLE "TemplatePackageVersion" DROP COLUMN "visualTemplateKey";
|
||||||
|
|
||||||
|
DROP INDEX "BrandTemplateInstallation_brandId_templateKey_key";
|
||||||
|
CREATE UNIQUE INDEX "BrandTemplateInstallation_brandId_key" ON "BrandTemplateInstallation"("brandId");
|
||||||
@@ -223,22 +223,19 @@ model CapabilityAuditLog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
model BrandTemplateInstallation {
|
model BrandTemplateInstallation {
|
||||||
id String @id @default(uuid())
|
id String @id @default(uuid())
|
||||||
brandId String
|
brandId String @unique
|
||||||
brand BrandProfile @relation(fields: [brandId], references: [id], onDelete: Cascade)
|
brand BrandProfile @relation(fields: [brandId], references: [id], onDelete: Cascade)
|
||||||
templateKey String
|
templateKey String
|
||||||
templateVersion String @default("1.0.0")
|
templateVersion String @default("1.0.0")
|
||||||
visualTemplateKey String?
|
templatePackageVersionId String
|
||||||
templatePackageVersionId String?
|
templatePackageVersion TemplatePackageVersion @relation("BrandTemplateInstallationPackageVersion", fields: [templatePackageVersionId], references: [id], onDelete: Restrict)
|
||||||
templatePackageVersion TemplatePackageVersion? @relation("BrandTemplateInstallationPackageVersion", fields: [templatePackageVersionId], references: [id], onDelete: SetNull)
|
|
||||||
contentChecksum String?
|
contentChecksum String?
|
||||||
configSnapshot Json
|
configSnapshot Json
|
||||||
previousSnapshots Json @default("[]")
|
previousSnapshots Json @default("[]")
|
||||||
installedAt DateTime @default(now())
|
installedAt DateTime @default(now())
|
||||||
updatedAt DateTime @updatedAt
|
updatedAt DateTime @updatedAt
|
||||||
|
|
||||||
@@unique([brandId, templateKey])
|
|
||||||
@@index([brandId])
|
|
||||||
@@index([templatePackageVersionId])
|
@@index([templatePackageVersionId])
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -484,7 +481,6 @@ model TemplatePackageVersion {
|
|||||||
packageKey String
|
packageKey String
|
||||||
version String
|
version String
|
||||||
displayName String
|
displayName String
|
||||||
visualTemplateKey String?
|
|
||||||
status TemplatePackageVersionStatus @default(imported)
|
status TemplatePackageVersionStatus @default(imported)
|
||||||
manifestSnapshot Json
|
manifestSnapshot Json
|
||||||
validationReport Json
|
validationReport Json
|
||||||
|
|||||||
+52
-41
@@ -1,10 +1,5 @@
|
|||||||
import { PrismaClient, type Prisma } from "@prisma/client";
|
import { PrismaClient, type Prisma } from "@prisma/client";
|
||||||
import {
|
import type { TemplatePackageManifest } from "@personal-brand/config";
|
||||||
getBrandTemplate,
|
|
||||||
getDefaultVisualTemplateKey,
|
|
||||||
getTemplatePackageManifestForVisualKey,
|
|
||||||
getVisualTemplateManifest,
|
|
||||||
} from "@personal-brand/config";
|
|
||||||
import bcrypt from "bcryptjs";
|
import bcrypt from "bcryptjs";
|
||||||
import { buildBrandReleaseSnapshot } from "../src/brand-release.service.js";
|
import { buildBrandReleaseSnapshot } from "../src/brand-release.service.js";
|
||||||
|
|
||||||
@@ -28,6 +23,7 @@ type OfferingKind = "service" | "product" | "package" | "subscription";
|
|||||||
|
|
||||||
interface RuntimeSeedTemplate {
|
interface RuntimeSeedTemplate {
|
||||||
templateKey: "personal" | "food" | "doors";
|
templateKey: "personal" | "food" | "doors";
|
||||||
|
visualTemplateKey: string;
|
||||||
brandConfig: Record<string, unknown>;
|
brandConfig: Record<string, unknown>;
|
||||||
retiredOfferingNames?: string[];
|
retiredOfferingNames?: string[];
|
||||||
offerings: Array<{
|
offerings: Array<{
|
||||||
@@ -52,8 +48,8 @@ interface RuntimeSeedTemplate {
|
|||||||
const runtimeSeedTemplates: Record<"personal" | "food" | "doors", RuntimeSeedTemplate> = {
|
const runtimeSeedTemplates: Record<"personal" | "food" | "doors", RuntimeSeedTemplate> = {
|
||||||
personal: {
|
personal: {
|
||||||
templateKey: "personal",
|
templateKey: "personal",
|
||||||
|
visualTemplateKey: "linjing-editorial",
|
||||||
brandConfig: {
|
brandConfig: {
|
||||||
visualTemplateKey: "linjing-editorial",
|
|
||||||
templateData: { designPhilosophy: "先厘清问题,再设计表达" },
|
templateData: { designPhilosophy: "先厘清问题,再设计表达" },
|
||||||
title: "品牌策略顾问",
|
title: "品牌策略顾问",
|
||||||
slogan: "用清晰的定位与可执行的表达,让专业被看见。",
|
slogan: "用清晰的定位与可执行的表达,让专业被看见。",
|
||||||
@@ -166,8 +162,8 @@ const runtimeSeedTemplates: Record<"personal" | "food" | "doors", RuntimeSeedTem
|
|||||||
},
|
},
|
||||||
food: {
|
food: {
|
||||||
templateKey: "food",
|
templateKey: "food",
|
||||||
|
visualTemplateKey: "acheng-campus-food",
|
||||||
brandConfig: {
|
brandConfig: {
|
||||||
visualTemplateKey: "acheng-campus-food",
|
|
||||||
founder: "阿成",
|
founder: "阿成",
|
||||||
title: "私房菜主理人",
|
title: "私房菜主理人",
|
||||||
slogan: "认真做好每一顿家常饭。",
|
slogan: "认真做好每一顿家常饭。",
|
||||||
@@ -293,9 +289,9 @@ const runtimeSeedTemplates: Record<"personal" | "food" | "doors", RuntimeSeedTem
|
|||||||
},
|
},
|
||||||
doors: {
|
doors: {
|
||||||
templateKey: "doors",
|
templateKey: "doors",
|
||||||
|
visualTemplateKey: "linjing-editorial",
|
||||||
retiredOfferingNames: ["别墅入户大门", "院门与围合系统", "室内户内门系统"],
|
retiredOfferingNames: ["别墅入户大门", "院门与围合系统", "室内户内门系统"],
|
||||||
brandConfig: {
|
brandConfig: {
|
||||||
visualTemplateKey: "linjing-editorial",
|
|
||||||
templateData: { designPhilosophy: "让门与空间建立长期、克制的关系" },
|
templateData: { designPhilosophy: "让门与空间建立长期、克制的关系" },
|
||||||
founder: "林叙安 (Lin XUAN)",
|
founder: "林叙安 (Lin XUAN)",
|
||||||
title: "高端门系统建筑研造主理人",
|
title: "高端门系统建筑研造主理人",
|
||||||
@@ -645,11 +641,22 @@ const runtimeSeedTemplates: Record<"personal" | "food" | "doors", RuntimeSeedTem
|
|||||||
async function ensureRuntimeContent(brandId: string, template: RuntimeSeedTemplate): Promise<void> {
|
async function ensureRuntimeContent(brandId: string, template: RuntimeSeedTemplate): Promise<void> {
|
||||||
// 这里只初始化明确的开发演示品牌;业务内容统一来自视觉包 sampleContent,
|
// 这里只初始化明确的开发演示品牌;业务内容统一来自视觉包 sampleContent,
|
||||||
// 新增生产模板无需添加 seed 分支,品牌样例内容仍须由管理员显式导入。
|
// 新增生产模板无需添加 seed 分支,品牌样例内容仍须由管理员显式导入。
|
||||||
const visualKey = template.templateKey === "food" ? "acheng-campus-food" : "linjing-editorial";
|
const installation = await prisma.brandTemplateInstallation.findFirst({
|
||||||
const packageSample =
|
where: { brandId },
|
||||||
getTemplatePackageManifestForVisualKey(visualKey)?.sampleContent?.[template.templateKey];
|
include: { templatePackageVersion: true },
|
||||||
if (!packageSample)
|
});
|
||||||
throw new Error(`Development sample is missing for ${visualKey}/${template.templateKey}`);
|
const manifest = installation?.templatePackageVersion?.manifestSnapshot as unknown as
|
||||||
|
TemplatePackageManifest | undefined;
|
||||||
|
const packageSample = manifest?.sampleContent?.[template.templateKey];
|
||||||
|
if (
|
||||||
|
!installation?.templatePackageVersion ||
|
||||||
|
manifest?.visualTemplateKey !== template.visualTemplateKey ||
|
||||||
|
manifest.packageKey !== template.visualTemplateKey ||
|
||||||
|
!packageSample
|
||||||
|
)
|
||||||
|
throw new Error(
|
||||||
|
`Development package sample is missing for ${template.visualTemplateKey}/${template.templateKey}`,
|
||||||
|
);
|
||||||
const offerings = packageSample.offerings.map((item) => ({
|
const offerings = packageSample.offerings.map((item) => ({
|
||||||
name: item.name,
|
name: item.name,
|
||||||
summary: item.summary,
|
summary: item.summary,
|
||||||
@@ -787,36 +794,40 @@ async function ensureSeedRelease(brandId: string, actorId: string): Promise<void
|
|||||||
async function ensureTemplateInstallation(brandId: string): Promise<void> {
|
async function ensureTemplateInstallation(brandId: string): Promise<void> {
|
||||||
const brand = await prisma.brandProfile.findUniqueOrThrow({
|
const brand = await prisma.brandProfile.findUniqueOrThrow({
|
||||||
where: { id: brandId },
|
where: { id: brandId },
|
||||||
select: { templateKey: true, config: true },
|
select: { templateKey: true },
|
||||||
|
});
|
||||||
|
const template = runtimeSeedTemplates[brand.templateKey as keyof typeof runtimeSeedTemplates];
|
||||||
|
if (!template) throw new Error("Development brand has no explicit template fixture");
|
||||||
|
const visualKey = template.visualTemplateKey;
|
||||||
|
const existing = await prisma.brandTemplateInstallation.findUnique({
|
||||||
|
where: { brandId },
|
||||||
|
include: { templatePackageVersion: true },
|
||||||
});
|
});
|
||||||
const template = getBrandTemplate(brand.templateKey);
|
|
||||||
if (!template) throw new Error("Development brand has an unknown industry template");
|
|
||||||
const config =
|
|
||||||
brand.config && typeof brand.config === "object" && !Array.isArray(brand.config)
|
|
||||||
? (brand.config as Record<string, unknown>)
|
|
||||||
: {};
|
|
||||||
const configuredVisual =
|
|
||||||
typeof config.visualTemplateKey === "string" ? config.visualTemplateKey : undefined;
|
|
||||||
const visualKey = configuredVisual ?? getDefaultVisualTemplateKey(template.key);
|
|
||||||
if (!getVisualTemplateManifest(visualKey))
|
|
||||||
throw new Error("Development brand has an unknown visual template");
|
|
||||||
const configSnapshot = {
|
|
||||||
schemaVersion: "1.0",
|
|
||||||
version: template.version,
|
|
||||||
industryTemplate: template,
|
|
||||||
visualTemplate: getVisualTemplateManifest(visualKey),
|
|
||||||
capabilities: template.capabilities,
|
|
||||||
} as unknown as Prisma.InputJsonValue;
|
|
||||||
const existing = await prisma.brandTemplateInstallation.findFirst({ where: { brandId } });
|
|
||||||
if (existing) {
|
if (existing) {
|
||||||
await prisma.brandTemplateInstallation.update({
|
if (
|
||||||
where: { id: existing.id },
|
existing.templateKey !== template.templateKey ||
|
||||||
data: { templateKey: template.key, templateVersion: template.version, configSnapshot },
|
!existing.templatePackageVersionId ||
|
||||||
});
|
!existing.templatePackageVersion
|
||||||
|
)
|
||||||
|
throw new Error("Development brand installation does not satisfy the template contract");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const packageVersion = await prisma.templatePackageVersion.findFirst({
|
||||||
|
where: { packageKey: visualKey, status: "published" },
|
||||||
|
orderBy: { importedAt: "desc" },
|
||||||
|
});
|
||||||
|
if (!packageVersion)
|
||||||
|
throw new Error(`Development brand requires a published package version: ${visualKey}`);
|
||||||
|
const configSnapshot = packageVersion.manifestSnapshot as Prisma.InputJsonValue;
|
||||||
await prisma.brandTemplateInstallation.create({
|
await prisma.brandTemplateInstallation.create({
|
||||||
data: { brandId, templateKey: template.key, templateVersion: template.version, configSnapshot },
|
data: {
|
||||||
|
brandId,
|
||||||
|
templateKey: template.templateKey,
|
||||||
|
templateVersion: packageVersion.version,
|
||||||
|
templatePackageVersionId: packageVersion.id,
|
||||||
|
contentChecksum: packageVersion.contentChecksum,
|
||||||
|
configSnapshot,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -846,8 +857,8 @@ async function main(): Promise<void> {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
await ensureRuntimeContent(brand.id, runtimeSeedTemplates.food);
|
|
||||||
await ensureTemplateInstallation(brand.id);
|
await ensureTemplateInstallation(brand.id);
|
||||||
|
await ensureRuntimeContent(brand.id, runtimeSeedTemplates.food);
|
||||||
|
|
||||||
for (const name of ["普通套餐", "私厨", "配送", "自取", "熟客", "重点跟进"]) {
|
for (const name of ["普通套餐", "私厨", "配送", "自取", "熟客", "重点跟进"]) {
|
||||||
await prisma.tag.upsert({
|
await prisma.tag.upsert({
|
||||||
@@ -904,8 +915,8 @@ async function main(): Promise<void> {
|
|||||||
update: { isEnabled: true, role: "owner" },
|
update: { isEnabled: true, role: "owner" },
|
||||||
create: { adminUserId: admin.id, brandId: doorsBrand.id, role: "owner" },
|
create: { adminUserId: admin.id, brandId: doorsBrand.id, role: "owner" },
|
||||||
});
|
});
|
||||||
await ensureRuntimeContent(doorsBrand.id, runtimeSeedTemplates.doors);
|
|
||||||
await ensureTemplateInstallation(doorsBrand.id);
|
await ensureTemplateInstallation(doorsBrand.id);
|
||||||
|
await ensureRuntimeContent(doorsBrand.id, runtimeSeedTemplates.doors);
|
||||||
await ensureSeedRelease(brand.id, admin.id);
|
await ensureSeedRelease(brand.id, admin.id);
|
||||||
await ensureSeedRelease(doorsBrand.id, admin.id);
|
await ensureSeedRelease(doorsBrand.id, admin.id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
|
import { getTemplatePackageManifestForVisualKey } from "@personal-brand/config";
|
||||||
import { PrismaService } from "../dist/prisma.service.js";
|
import { PrismaService } from "../dist/prisma.service.js";
|
||||||
import { TemplateWorkspaceService } from "../dist/template-workspace.service.js";
|
import { TemplateWorkspaceService } from "../dist/template-workspace.service.js";
|
||||||
|
|
||||||
@@ -19,18 +20,12 @@ try {
|
|||||||
let current = await tx.brandProfile.findUnique({ where: { slug } });
|
let current = await tx.brandProfile.findUnique({ where: { slug } });
|
||||||
if (current) {
|
if (current) {
|
||||||
assert.equal(current.templateKey, "personal", "Existing brand has a different industry");
|
assert.equal(current.templateKey, "personal", "Existing brand has a different industry");
|
||||||
assert.equal(
|
|
||||||
current.config?.visualTemplateKey,
|
|
||||||
"atelier-solopreneur",
|
|
||||||
"Existing brand has a different visual template",
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
current = await tx.brandProfile.create({
|
current = await tx.brandProfile.create({
|
||||||
data: {
|
data: {
|
||||||
slug,
|
slug,
|
||||||
name: "独立工坊 · 品牌小程序",
|
name: "独立工坊 · 品牌小程序",
|
||||||
templateKey: "personal",
|
templateKey: "personal",
|
||||||
config: { visualTemplateKey: "atelier-solopreneur" },
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -41,8 +36,31 @@ try {
|
|||||||
});
|
});
|
||||||
return current;
|
return current;
|
||||||
});
|
});
|
||||||
if (!(await prisma.brandTemplateInstallation.findFirst({ where: { brandId: brand.id } }))) {
|
const manifest = getTemplatePackageManifestForVisualKey("atelier-solopreneur");
|
||||||
await new TemplateWorkspaceService(prisma).install(brand.id, "personal");
|
if (!manifest) throw new Error("atelier-solopreneur package manifest is unavailable");
|
||||||
|
const version = await prisma.templatePackageVersion.findUnique({
|
||||||
|
where: {
|
||||||
|
templatePackageId_version: {
|
||||||
|
templatePackageId: (
|
||||||
|
await prisma.templatePackage.findUniqueOrThrow({
|
||||||
|
where: { packageKey: "atelier-solopreneur" },
|
||||||
|
select: { id: true },
|
||||||
|
})
|
||||||
|
).id,
|
||||||
|
version: manifest.version,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (!version || version.status !== "published")
|
||||||
|
throw new Error(`Published package version not found: atelier-solopreneur@${manifest.version}`);
|
||||||
|
const installation = await prisma.brandTemplateInstallation.findUnique({
|
||||||
|
where: { brandId: brand.id },
|
||||||
|
include: { templatePackageVersion: true },
|
||||||
|
});
|
||||||
|
if (installation) {
|
||||||
|
assert.equal(installation.templatePackageVersionId, version.id);
|
||||||
|
} else {
|
||||||
|
await new TemplateWorkspaceService(prisma).install(brand.id, "personal", version.id);
|
||||||
}
|
}
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
await prisma.brandProfile.findMany({ where: { slug: { not: slug } }, orderBy: { id: "asc" } }),
|
await prisma.brandProfile.findMany({ where: { slug: { not: slug } }, orderBy: { id: "asc" } }),
|
||||||
|
|||||||
@@ -10,8 +10,14 @@ const prisma = new PrismaClient();
|
|||||||
const note = "餐饮主理人原型视觉槽位迁移 v1";
|
const note = "餐饮主理人原型视觉槽位迁移 v1";
|
||||||
try {
|
try {
|
||||||
const brand = await prisma.brandProfile.findUniqueOrThrow({ where: { slug: "default-brand" } });
|
const brand = await prisma.brandProfile.findUniqueOrThrow({ where: { slug: "default-brand" } });
|
||||||
const config = (brand.config ?? {}) as Record<string, unknown>;
|
const installation = await prisma.brandTemplateInstallation.findUnique({
|
||||||
if (brand.templateKey !== "food" || config.visualTemplateKey !== "acheng-campus-food")
|
where: { brandId: brand.id },
|
||||||
|
include: { templatePackageVersion: true },
|
||||||
|
});
|
||||||
|
if (
|
||||||
|
brand.templateKey !== "food" ||
|
||||||
|
installation?.templatePackageVersion?.packageKey !== "acheng-campus-food"
|
||||||
|
)
|
||||||
throw new Error("Migration is restricted to the development food brand");
|
throw new Error("Migration is restricted to the development food brand");
|
||||||
const previous = await prisma.brandRelease.findFirst({
|
const previous = await prisma.brandRelease.findFirst({
|
||||||
where: { brandId: brand.id },
|
where: { brandId: brand.id },
|
||||||
|
|||||||
@@ -106,7 +106,13 @@ export class UpdateBookingTagsDto {
|
|||||||
export class InstallTemplateDto {
|
export class InstallTemplateDto {
|
||||||
@IsIn(brandTemplateKeys)
|
@IsIn(brandTemplateKeys)
|
||||||
templateKey!: BrandTemplateKey;
|
templateKey!: BrandTemplateKey;
|
||||||
@IsOptional() @IsUUID() templatePackageVersionId?: string;
|
@IsUUID() templatePackageVersionId!: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class SelectTemplateVersionDto {
|
||||||
|
@IsUUID() templatePackageVersionId!: string;
|
||||||
|
@IsOptional() @IsUUID() expectedCurrentPackageVersionId?: string | null;
|
||||||
|
@IsBoolean() confirm!: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class UpgradeTemplateDto {
|
export class UpgradeTemplateDto {
|
||||||
|
|||||||
@@ -6,12 +6,9 @@ import {
|
|||||||
} from "@nestjs/common";
|
} from "@nestjs/common";
|
||||||
import { Prisma } from "@prisma/client";
|
import { Prisma } from "@prisma/client";
|
||||||
import {
|
import {
|
||||||
defaultBrandTemplateKey,
|
|
||||||
getBrandTemplate,
|
getBrandTemplate,
|
||||||
getVisualTemplate,
|
getVisualTemplate,
|
||||||
isVisualTemplateCompatible,
|
isVisualTemplateCompatible,
|
||||||
getDefaultVisualTemplateKey,
|
|
||||||
getTemplatePackageManifestForVisualKey,
|
|
||||||
validateTemplatePackageManifest,
|
validateTemplatePackageManifest,
|
||||||
type TemplatePackageManifest,
|
type TemplatePackageManifest,
|
||||||
} from "@personal-brand/config";
|
} from "@personal-brand/config";
|
||||||
@@ -61,9 +58,8 @@ export class BrandReleaseApiService {
|
|||||||
where: { id: brandId },
|
where: { id: brandId },
|
||||||
select: { name: true, tagline: true, description: true, templateKey: true, config: true },
|
select: { name: true, tagline: true, description: true, templateKey: true, config: true },
|
||||||
});
|
});
|
||||||
const installation = await database.brandTemplateInstallation.findFirst({
|
const installation = await database.brandTemplateInstallation.findUnique({
|
||||||
where: { brandId },
|
where: { brandId },
|
||||||
orderBy: { updatedAt: "desc" },
|
|
||||||
});
|
});
|
||||||
const packageVersion = installation?.templatePackageVersionId
|
const packageVersion = installation?.templatePackageVersionId
|
||||||
? await database.templatePackageVersion.findUnique({
|
? await database.templatePackageVersion.findUnique({
|
||||||
@@ -71,36 +67,30 @@ export class BrandReleaseApiService {
|
|||||||
select: {
|
select: {
|
||||||
packageKey: true,
|
packageKey: true,
|
||||||
version: true,
|
version: true,
|
||||||
visualTemplateKey: true,
|
|
||||||
status: true,
|
status: true,
|
||||||
contentChecksum: true,
|
contentChecksum: true,
|
||||||
manifestSnapshot: true,
|
manifestSnapshot: true,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
: null;
|
: null;
|
||||||
const template = getBrandTemplate(installation?.templateKey ?? brand?.templateKey ?? "");
|
const template = getBrandTemplate(brand?.templateKey ?? "");
|
||||||
const config = this.jsonObject(brand?.config);
|
const storedManifest = packageVersion?.manifestSnapshot as TemplatePackageManifest | undefined;
|
||||||
const visualKey =
|
const visualKey = storedManifest?.visualTemplateKey ?? "";
|
||||||
typeof config.visualTemplateKey === "string"
|
|
||||||
? config.visualTemplateKey
|
|
||||||
: getDefaultVisualTemplateKey(brand?.templateKey ?? defaultBrandTemplateKey);
|
|
||||||
const visual = getVisualTemplate(visualKey);
|
const visual = getVisualTemplate(visualKey);
|
||||||
const storedManifest = packageVersion?.manifestSnapshot as unknown as
|
const packageManifest = storedManifest;
|
||||||
TemplatePackageManifest | undefined;
|
const packageVersionValid = Boolean(
|
||||||
const packageManifest = storedManifest ?? getTemplatePackageManifestForVisualKey(visualKey);
|
installation?.templatePackageVersionId &&
|
||||||
const packageVersionValid =
|
packageVersion &&
|
||||||
!installation?.templatePackageVersionId ||
|
packageVersion.status === "published" &&
|
||||||
Boolean(
|
/^[a-f0-9]{64}$/.test(packageVersion.contentChecksum) &&
|
||||||
packageVersion &&
|
packageVersion.packageKey === (storedManifest?.packageKey ?? "") &&
|
||||||
packageVersion.status === "published" &&
|
packageVersion.version === (storedManifest?.version ?? "") &&
|
||||||
/^[a-f0-9]{64}$/.test(packageVersion.contentChecksum) &&
|
packageVersion.packageKey === storedManifest?.packageKey &&
|
||||||
packageVersion.packageKey === (storedManifest?.packageKey ?? "") &&
|
packageVersion.packageKey === storedManifest?.visualTemplateKey &&
|
||||||
packageVersion.version === (storedManifest?.version ?? "") &&
|
storedManifest?.supportedIndustryTemplates.includes(brand?.templateKey ?? "") &&
|
||||||
(packageVersion.visualTemplateKey ?? packageVersion.packageKey) ===
|
validateTemplatePackageManifest(storedManifest).length === 0,
|
||||||
(storedManifest?.visualTemplateKey ?? packageVersion.packageKey) &&
|
);
|
||||||
storedManifest?.supportedIndustryTemplates.includes(brand?.templateKey ?? "") &&
|
const config = this.jsonObject(brand?.config);
|
||||||
validateTemplatePackageManifest(storedManifest).length === 0,
|
|
||||||
);
|
|
||||||
const [offerings, forms, trustItems] = await Promise.all([
|
const [offerings, forms, trustItems] = await Promise.all([
|
||||||
database.offering.findMany({
|
database.offering.findMany({
|
||||||
where: { brandId, isEnabled: true },
|
where: { brandId, isEnabled: true },
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
import { Injectable } from "@nestjs/common";
|
import { Injectable } from "@nestjs/common";
|
||||||
import { Prisma } from "@prisma/client";
|
import { Prisma } from "@prisma/client";
|
||||||
import {
|
import {
|
||||||
defaultBrandTemplateKey,
|
|
||||||
getBrandTemplate,
|
getBrandTemplate,
|
||||||
getVisualTemplate,
|
getVisualTemplate,
|
||||||
getVisualTemplateManifest,
|
getVisualTemplateManifest,
|
||||||
getDefaultVisualTemplateKey,
|
|
||||||
getTemplatePackageManifestForVisualKey,
|
|
||||||
} from "@personal-brand/config";
|
} from "@personal-brand/config";
|
||||||
import type { TemplatePackageManifest } from "@personal-brand/config";
|
import type { TemplatePackageManifest } from "@personal-brand/config";
|
||||||
import { PrismaService } from "./prisma.service.js";
|
import { PrismaService } from "./prisma.service.js";
|
||||||
@@ -35,9 +32,8 @@ export async function buildBrandReleaseSnapshot(
|
|||||||
const [brand, installation, fields, offerings, forms, trustContents, capabilities] =
|
const [brand, installation, fields, offerings, forms, trustContents, capabilities] =
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
database.brandProfile.findUnique({ where: { id: brandId } }),
|
database.brandProfile.findUnique({ where: { id: brandId } }),
|
||||||
database.brandTemplateInstallation.findFirst({
|
database.brandTemplateInstallation.findUnique({
|
||||||
where: { brandId },
|
where: { brandId },
|
||||||
orderBy: { updatedAt: "desc" },
|
|
||||||
include: { templatePackageVersion: true },
|
include: { templatePackageVersion: true },
|
||||||
}),
|
}),
|
||||||
database.brandFieldDefinition.findMany({ where: { brandId }, orderBy: { sortOrder: "asc" } }),
|
database.brandFieldDefinition.findMany({ where: { brandId }, orderBy: { sortOrder: "asc" } }),
|
||||||
@@ -46,15 +42,14 @@ export async function buildBrandReleaseSnapshot(
|
|||||||
database.trustContent.findMany({ where: { brandId }, orderBy: { sortOrder: "asc" } }),
|
database.trustContent.findMany({ where: { brandId }, orderBy: { sortOrder: "asc" } }),
|
||||||
database.capabilityInstallation.findMany({ where: { brandId } }),
|
database.capabilityInstallation.findMany({ where: { brandId } }),
|
||||||
]);
|
]);
|
||||||
const templateKey = brand?.templateKey ?? installation?.templateKey ?? defaultBrandTemplateKey;
|
if (!brand) throw new Error("品牌不存在,不能生成发布快照");
|
||||||
const config =
|
if (!installation?.templatePackageVersion) throw new Error("品牌安装没有锁定精确视觉模板包版本");
|
||||||
brand?.config && typeof brand.config === "object" && !Array.isArray(brand.config)
|
const templateKey = brand.templateKey;
|
||||||
? (brand.config as Record<string, unknown>)
|
const packageManifest = installation.templatePackageVersion.manifestSnapshot as unknown as
|
||||||
: {};
|
TemplatePackageManifest | undefined;
|
||||||
const visualKey =
|
const visualKey = packageManifest?.visualTemplateKey;
|
||||||
typeof config.visualTemplateKey === "string"
|
if (!packageManifest || typeof visualKey !== "string")
|
||||||
? config.visualTemplateKey
|
throw new Error("品牌安装与模板包 manifest 不一致");
|
||||||
: getDefaultVisualTemplateKey(brand?.templateKey ?? defaultBrandTemplateKey);
|
|
||||||
const jsonObject = (value: object): Record<string, unknown> =>
|
const jsonObject = (value: object): Record<string, unknown> =>
|
||||||
JSON.parse(JSON.stringify(value)) as Record<string, unknown>;
|
JSON.parse(JSON.stringify(value)) as Record<string, unknown>;
|
||||||
return {
|
return {
|
||||||
@@ -64,11 +59,7 @@ export async function buildBrandReleaseSnapshot(
|
|||||||
templateDefinition: getBrandTemplate(templateKey) ?? null,
|
templateDefinition: getBrandTemplate(templateKey) ?? null,
|
||||||
visualTemplateDefinition: getVisualTemplate(visualKey) ?? null,
|
visualTemplateDefinition: getVisualTemplate(visualKey) ?? null,
|
||||||
visualTemplateManifest: getVisualTemplateManifest(visualKey) ?? null,
|
visualTemplateManifest: getVisualTemplateManifest(visualKey) ?? null,
|
||||||
templatePackageManifest:
|
templatePackageManifest: packageManifest,
|
||||||
(installation?.templatePackageVersion?.manifestSnapshot as unknown as
|
|
||||||
TemplatePackageManifest | undefined) ??
|
|
||||||
getTemplatePackageManifestForVisualKey(visualKey) ??
|
|
||||||
null,
|
|
||||||
brand: brand ? jsonObject(brand) : null,
|
brand: brand ? jsonObject(brand) : null,
|
||||||
installation: installation ? jsonObject(installation) : null,
|
installation: installation ? jsonObject(installation) : null,
|
||||||
fields: fields.map((item) => jsonObject(item)),
|
fields: fields.map((item) => jsonObject(item)),
|
||||||
|
|||||||
@@ -1,23 +1,11 @@
|
|||||||
import { BadRequestException, Injectable } from "@nestjs/common";
|
import { BadRequestException, Injectable } from "@nestjs/common";
|
||||||
import { Prisma } from "@prisma/client";
|
import { Prisma } from "@prisma/client";
|
||||||
import {
|
|
||||||
defaultVisualTemplateKey,
|
|
||||||
getBrandTemplate,
|
|
||||||
getDefaultVisualTemplateKey,
|
|
||||||
getVisualTemplate,
|
|
||||||
isVisualTemplateCompatible,
|
|
||||||
listVisualTemplateKeys,
|
|
||||||
} from "@personal-brand/config";
|
|
||||||
import { PrismaService } from "../../prisma.service.js";
|
import { PrismaService } from "../../prisma.service.js";
|
||||||
import { TemplateWorkspaceService } from "../../template-workspace.service.js";
|
|
||||||
import type { UpdateBrandDto, UpdateBrandPresentationDto } from "../../admin.dto.js";
|
import type { UpdateBrandDto, UpdateBrandPresentationDto } from "../../admin.dto.js";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AdminBrandConfigService {
|
export class AdminBrandConfigService {
|
||||||
constructor(
|
constructor(private readonly prisma: PrismaService) {}
|
||||||
private readonly prisma: PrismaService,
|
|
||||||
private readonly templateWorkspace: TemplateWorkspaceService,
|
|
||||||
) {}
|
|
||||||
|
|
||||||
getBrand(brandId: string) {
|
getBrand(brandId: string) {
|
||||||
return this.prisma.brandProfile.findUnique({ where: { id: brandId } });
|
return this.prisma.brandProfile.findUnique({ where: { id: brandId } });
|
||||||
@@ -27,56 +15,28 @@ export class AdminBrandConfigService {
|
|||||||
const { config, ...fields } = body;
|
const { config, ...fields } = body;
|
||||||
const current = await this.prisma.brandProfile.findUnique({
|
const current = await this.prisma.brandProfile.findUnique({
|
||||||
where: { id: brandId },
|
where: { id: brandId },
|
||||||
select: { config: true },
|
select: { config: true, templateKey: true },
|
||||||
});
|
});
|
||||||
|
if (!current) throw new BadRequestException("品牌不存在");
|
||||||
const currentConfig = this.jsonObject(current?.config);
|
const currentConfig = this.jsonObject(current?.config);
|
||||||
|
if (config && Object.hasOwn(config, "visualTemplateKey"))
|
||||||
|
throw new BadRequestException("模板选择必须通过精确模板包版本操作");
|
||||||
|
const configFields = config ?? {};
|
||||||
const nextConfig = {
|
const nextConfig = {
|
||||||
...currentConfig,
|
...currentConfig,
|
||||||
...(config ?? {}),
|
...configFields,
|
||||||
...(fields.description !== undefined && config?.slogan === undefined
|
...(fields.description !== undefined && configFields.slogan === undefined
|
||||||
? { slogan: fields.description }
|
? { slogan: fields.description }
|
||||||
: {}),
|
: {}),
|
||||||
};
|
};
|
||||||
if (config?.visualTemplateKey && config.visualTemplateKey !== currentConfig.visualTemplateKey) {
|
return this.prisma.$transaction(async (tx) => {
|
||||||
const templateKey = await this.templateWorkspace.getEffectiveTemplateKey(brandId);
|
return tx.brandProfile.update({
|
||||||
const visualTemplate =
|
where: { id: brandId },
|
||||||
typeof config.visualTemplateKey === "string"
|
data: {
|
||||||
? getVisualTemplate(config.visualTemplateKey)
|
...fields,
|
||||||
: undefined;
|
...(Object.keys(nextConfig).length ? { config: nextConfig } : {}),
|
||||||
if (
|
},
|
||||||
!visualTemplate ||
|
|
||||||
!getBrandTemplate(templateKey) ||
|
|
||||||
!isVisualTemplateCompatible(visualTemplate, templateKey)
|
|
||||||
)
|
|
||||||
throw new BadRequestException("当前视觉模板不适配该行业模板");
|
|
||||||
const installation = await this.prisma.brandTemplateInstallation.findFirst({
|
|
||||||
where: { brandId },
|
|
||||||
});
|
});
|
||||||
if (installation) {
|
|
||||||
const history = Array.isArray(installation.previousSnapshots)
|
|
||||||
? installation.previousSnapshots
|
|
||||||
: [];
|
|
||||||
await this.prisma.brandTemplateInstallation.update({
|
|
||||||
where: { id: installation.id },
|
|
||||||
data: {
|
|
||||||
previousSnapshots: [
|
|
||||||
...history,
|
|
||||||
{
|
|
||||||
visualTemplateKey:
|
|
||||||
currentConfig.visualTemplateKey ?? getDefaultVisualTemplateKey(templateKey),
|
|
||||||
savedAt: new Date().toISOString(),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this.prisma.brandProfile.update({
|
|
||||||
where: { id: brandId },
|
|
||||||
data: {
|
|
||||||
...fields,
|
|
||||||
...(Object.keys(nextConfig).length ? { config: nextConfig } : {}),
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,91 +90,6 @@ export class AdminBrandConfigService {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async visualTemplateHistory(brandId: string) {
|
|
||||||
const installation = await this.prisma.brandTemplateInstallation.findFirst({
|
|
||||||
where: { brandId },
|
|
||||||
select: { previousSnapshots: true },
|
|
||||||
});
|
|
||||||
return {
|
|
||||||
history: Array.isArray(installation?.previousSnapshots)
|
|
||||||
? installation.previousSnapshots.filter(
|
|
||||||
(item) =>
|
|
||||||
item &&
|
|
||||||
typeof item === "object" &&
|
|
||||||
!Array.isArray(item) &&
|
|
||||||
"visualTemplateKey" in item,
|
|
||||||
)
|
|
||||||
: [],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
async rollbackVisualTemplate(brandId: string) {
|
|
||||||
const [brand, installation] = await Promise.all([
|
|
||||||
this.prisma.brandProfile.findUnique({ where: { id: brandId }, select: { config: true } }),
|
|
||||||
this.prisma.brandTemplateInstallation.findFirst({ where: { brandId } }),
|
|
||||||
]);
|
|
||||||
const config = this.jsonObject(brand?.config);
|
|
||||||
const history = Array.isArray(installation?.previousSnapshots)
|
|
||||||
? installation.previousSnapshots
|
|
||||||
: [];
|
|
||||||
const index = [...history]
|
|
||||||
.map((item, i) => ({ item, i }))
|
|
||||||
.reverse()
|
|
||||||
.find(
|
|
||||||
({ item }) =>
|
|
||||||
item && typeof item === "object" && !Array.isArray(item) && "visualTemplateKey" in item,
|
|
||||||
)?.i;
|
|
||||||
const previous =
|
|
||||||
index === undefined ? undefined : (history[index] as { visualTemplateKey?: unknown });
|
|
||||||
if (!previous || typeof previous.visualTemplateKey !== "string")
|
|
||||||
throw new BadRequestException("没有可回滚的视觉模板版本");
|
|
||||||
await this.prisma.$transaction([
|
|
||||||
this.prisma.brandProfile.update({
|
|
||||||
where: { id: brandId },
|
|
||||||
data: {
|
|
||||||
config: {
|
|
||||||
...config,
|
|
||||||
visualTemplateKey: previous.visualTemplateKey,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
...(installation
|
|
||||||
? [
|
|
||||||
this.prisma.brandTemplateInstallation.update({
|
|
||||||
where: { id: installation.id },
|
|
||||||
data: { previousSnapshots: history.slice(0, index) },
|
|
||||||
}),
|
|
||||||
]
|
|
||||||
: []),
|
|
||||||
]);
|
|
||||||
return { visualTemplateKey: previous.visualTemplateKey, rolledBack: true };
|
|
||||||
}
|
|
||||||
|
|
||||||
async visualTemplatePreview(brandId: string) {
|
|
||||||
const brand = await this.prisma.brandProfile.findUnique({
|
|
||||||
where: { id: brandId },
|
|
||||||
select: { config: true },
|
|
||||||
});
|
|
||||||
const config = this.jsonObject(brand?.config);
|
|
||||||
const currentKey =
|
|
||||||
typeof config.visualTemplateKey === "string"
|
|
||||||
? config.visualTemplateKey
|
|
||||||
: defaultVisualTemplateKey;
|
|
||||||
const current = getVisualTemplate(currentKey);
|
|
||||||
return {
|
|
||||||
current: current
|
|
||||||
? {
|
|
||||||
key: current.key,
|
|
||||||
version: current.version,
|
|
||||||
name: current.name,
|
|
||||||
theme: current.theme,
|
|
||||||
variants: current.variants,
|
|
||||||
}
|
|
||||||
: null,
|
|
||||||
available: listVisualTemplateKeys(),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private jsonObject(value: unknown): Record<string, unknown> {
|
private jsonObject(value: unknown): Record<string, unknown> {
|
||||||
return value && typeof value === "object" && !Array.isArray(value)
|
return value && typeof value === "object" && !Array.isArray(value)
|
||||||
? (value as Record<string, unknown>)
|
? (value as Record<string, unknown>)
|
||||||
|
|||||||
@@ -60,10 +60,6 @@ export class AdminConfigController {
|
|||||||
@Body() body: UpdateBrandDto,
|
@Body() body: UpdateBrandDto,
|
||||||
): Promise<unknown> {
|
): Promise<unknown> {
|
||||||
this.requireAdmin(request);
|
this.requireAdmin(request);
|
||||||
const { config } = body;
|
|
||||||
if (config?.visualTemplateKey !== undefined) {
|
|
||||||
await this.access.requireRole(request, ["owner", "admin", "platform-admin"]);
|
|
||||||
}
|
|
||||||
return this.brandConfig.updateBrand(this.brandId(request), body);
|
return this.brandConfig.updateBrand(this.brandId(request), body);
|
||||||
}
|
}
|
||||||
@Patch("presentation")
|
@Patch("presentation")
|
||||||
@@ -75,21 +71,6 @@ export class AdminConfigController {
|
|||||||
const brandId = this.brandId(request);
|
const brandId = this.brandId(request);
|
||||||
return this.brandConfig.updatePresentation(brandId, body);
|
return this.brandConfig.updatePresentation(brandId, body);
|
||||||
}
|
}
|
||||||
@Get("visual-template/history")
|
|
||||||
getVisualTemplateHistory(@Req() request: FastifyRequest): unknown {
|
|
||||||
this.requireAdmin(request);
|
|
||||||
return this.brandConfig.visualTemplateHistory(this.brandId(request));
|
|
||||||
}
|
|
||||||
@Post("visual-template/rollback")
|
|
||||||
async rollbackVisualTemplate(@Req() request: FastifyRequest): Promise<unknown> {
|
|
||||||
this.requireAdmin(request);
|
|
||||||
return this.brandConfig.rollbackVisualTemplate(this.brandId(request));
|
|
||||||
}
|
|
||||||
@Get("visual-template/preview")
|
|
||||||
getVisualTemplatePreview(@Req() request: FastifyRequest): unknown {
|
|
||||||
this.requireAdmin(request);
|
|
||||||
return this.brandConfig.visualTemplatePreview(this.brandId(request));
|
|
||||||
}
|
|
||||||
@Get("trust-content")
|
@Get("trust-content")
|
||||||
listTrustContent(@Req() request: FastifyRequest): Promise<unknown> {
|
listTrustContent(@Req() request: FastifyRequest): Promise<unknown> {
|
||||||
this.requireAdmin(request);
|
this.requireAdmin(request);
|
||||||
|
|||||||
@@ -26,9 +26,9 @@ type Manifest = {
|
|||||||
packageKey: string;
|
packageKey: string;
|
||||||
version: string;
|
version: string;
|
||||||
displayName: string;
|
displayName: string;
|
||||||
visualTemplateKey?: string;
|
visualTemplateKey: string;
|
||||||
supportedIndustryTemplates?: string[];
|
supportedIndustryTemplates: string[];
|
||||||
previewFixture?: Prisma.InputJsonValue;
|
previewFixture: Prisma.InputJsonValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
type ChecksumFile = {
|
type ChecksumFile = {
|
||||||
@@ -146,7 +146,6 @@ export class AdminTemplatePackageService {
|
|||||||
packageKey: true,
|
packageKey: true,
|
||||||
version: true,
|
version: true,
|
||||||
displayName: true,
|
displayName: true,
|
||||||
visualTemplateKey: true,
|
|
||||||
status: true,
|
status: true,
|
||||||
contentChecksum: true,
|
contentChecksum: true,
|
||||||
archiveChecksum: true,
|
archiveChecksum: true,
|
||||||
@@ -302,7 +301,6 @@ export class AdminTemplatePackageService {
|
|||||||
packageKey,
|
packageKey,
|
||||||
version: manifest.version,
|
version: manifest.version,
|
||||||
displayName: manifest.displayName,
|
displayName: manifest.displayName,
|
||||||
visualTemplateKey: manifest.visualTemplateKey ?? null,
|
|
||||||
manifestSnapshot: manifest,
|
manifestSnapshot: manifest,
|
||||||
validationReport: {
|
validationReport: {
|
||||||
formatVersion: "1",
|
formatVersion: "1",
|
||||||
@@ -495,7 +493,6 @@ export class AdminTemplatePackageService {
|
|||||||
packageKey: string;
|
packageKey: string;
|
||||||
version: string;
|
version: string;
|
||||||
displayName: string;
|
displayName: string;
|
||||||
visualTemplateKey: string | null;
|
|
||||||
status: string;
|
status: string;
|
||||||
contentChecksum: string;
|
contentChecksum: string;
|
||||||
archiveChecksum: string;
|
archiveChecksum: string;
|
||||||
@@ -506,7 +503,6 @@ export class AdminTemplatePackageService {
|
|||||||
packageKey: version.packageKey,
|
packageKey: version.packageKey,
|
||||||
version: version.version,
|
version: version.version,
|
||||||
displayName: version.displayName,
|
displayName: version.displayName,
|
||||||
visualTemplateKey: version.visualTemplateKey,
|
|
||||||
status: version.status,
|
status: version.status,
|
||||||
contentChecksum: version.contentChecksum,
|
contentChecksum: version.contentChecksum,
|
||||||
archiveChecksum: version.archiveChecksum,
|
archiveChecksum: version.archiveChecksum,
|
||||||
|
|||||||
@@ -184,22 +184,25 @@ export class AdminTemplatePreviewService {
|
|||||||
|
|
||||||
const rawManifest = record(version.manifestSnapshot);
|
const rawManifest = record(version.manifestSnapshot);
|
||||||
const packageKey = version.packageKey;
|
const packageKey = version.packageKey;
|
||||||
const visualTemplateKey =
|
const visualTemplateKey = rawManifest.visualTemplateKey as string;
|
||||||
typeof rawManifest.visualTemplateKey === "string"
|
const manifest = rawManifest as unknown as TemplatePackageManifest;
|
||||||
? rawManifest.visualTemplateKey
|
let manifestIssues: string[];
|
||||||
: packageKey;
|
|
||||||
const manifest = {
|
|
||||||
...rawManifest,
|
|
||||||
visualTemplateKey,
|
|
||||||
} as unknown as TemplatePackageManifest;
|
|
||||||
try {
|
try {
|
||||||
if (validateTemplatePackageManifest(manifest).length || !hasPreviewStructure(rawManifest)) {
|
manifestIssues = validateTemplatePackageManifest(manifest);
|
||||||
throw new Error("Invalid manifest");
|
|
||||||
}
|
|
||||||
} catch {
|
} catch {
|
||||||
throw new BadRequestException("模板版本的 manifest 不符合预览契约");
|
throw new BadRequestException("模板版本的 manifest 不符合预览契约");
|
||||||
}
|
}
|
||||||
if (manifest.packageKey !== packageKey || manifest.version !== version.version)
|
if (manifestIssues.length)
|
||||||
|
throw new BadRequestException(
|
||||||
|
`模板版本的 manifest 不符合预览契约:${manifestIssues.join(";")}`,
|
||||||
|
);
|
||||||
|
if (!hasPreviewStructure(rawManifest))
|
||||||
|
throw new BadRequestException("模板版本的 manifest 不符合预览契约");
|
||||||
|
if (
|
||||||
|
manifest.packageKey !== packageKey ||
|
||||||
|
manifest.version !== version.version ||
|
||||||
|
manifest.packageKey !== manifest.visualTemplateKey
|
||||||
|
)
|
||||||
throw new BadRequestException("模板版本与 manifest 元数据不一致");
|
throw new BadRequestException("模板版本与 manifest 元数据不一致");
|
||||||
const industryTemplate = getBrandTemplate(industry);
|
const industryTemplate = getBrandTemplate(industry);
|
||||||
const blockers: string[] = [];
|
const blockers: string[] = [];
|
||||||
@@ -235,20 +238,14 @@ export class AdminTemplatePreviewService {
|
|||||||
}
|
}
|
||||||
if (blockers.length) throw new BadRequestException(`模板预览被阻断:${blockers.join(";")}`);
|
if (blockers.length) throw new BadRequestException(`模板预览被阻断:${blockers.join(";")}`);
|
||||||
|
|
||||||
const fixtureDeclared = rawManifest.previewFixture !== undefined;
|
|
||||||
const fixture = record(rawManifest.previewFixture)[industry] as
|
const fixture = record(rawManifest.previewFixture)[industry] as
|
||||||
TemplatePreviewFixture | undefined;
|
TemplatePreviewFixture | undefined;
|
||||||
if (fixtureDeclared) {
|
const fixtureIssues = validateTemplatePreviewFixture(fixture);
|
||||||
const issues = validateTemplatePreviewFixture(fixture);
|
if (fixtureIssues.length)
|
||||||
if (issues.length)
|
throw new BadRequestException(
|
||||||
throw new BadRequestException(
|
`模板 previewFixture 不符合预览契约:${fixtureIssues.map((issue) => `${issue.path}: ${issue.message}`).join(";")}`,
|
||||||
`模板 previewFixture 不符合预览契约:${issues.map((issue) => `${issue.path}: ${issue.message}`).join(";")}`,
|
);
|
||||||
);
|
const sample = fixture!.content as TemplateSampleContent;
|
||||||
}
|
|
||||||
// 一旦包声明独立 fixture,缺失或无效时禁止偷偷回退到 bootstrap sample。
|
|
||||||
const sample = fixtureDeclared
|
|
||||||
? fixture!.content
|
|
||||||
: (record(rawManifest.sampleContent)[industry] as TemplateSampleContent | undefined);
|
|
||||||
const missingSampleSlots = this.missingSampleSlots(manifest, sample);
|
const missingSampleSlots = this.missingSampleSlots(manifest, sample);
|
||||||
if (missingSampleSlots.length)
|
if (missingSampleSlots.length)
|
||||||
blockers.push(`preview sample 缺少必需数据:${missingSampleSlots.join("、")}`);
|
blockers.push(`preview sample 缺少必需数据:${missingSampleSlots.join("、")}`);
|
||||||
@@ -331,26 +328,13 @@ export class AdminTemplatePreviewService {
|
|||||||
},
|
},
|
||||||
preview: {
|
preview: {
|
||||||
assetFiles: resources.files,
|
assetFiles: resources.files,
|
||||||
fixtureSource: fixtureDeclared
|
fixtureSource: "previewFixture" as const,
|
||||||
? ("previewFixture" as const)
|
|
||||||
: ("legacy-sampleContent" as const),
|
|
||||||
safety: {
|
safety: {
|
||||||
submissions: "disabled" as const,
|
submissions: "disabled" as const,
|
||||||
customerRecords: "disabled" as const,
|
customerRecords: "disabled" as const,
|
||||||
contactActions: "disabled" as const,
|
contactActions: "disabled" as const,
|
||||||
},
|
},
|
||||||
diagnostics: [
|
diagnostics: resources.diagnostics,
|
||||||
...resources.diagnostics,
|
|
||||||
...(fixtureDeclared
|
|
||||||
? []
|
|
||||||
: [
|
|
||||||
{
|
|
||||||
code: "LEGACY_PREVIEW_SAMPLE",
|
|
||||||
severity: "warning" as const,
|
|
||||||
message: "该版本尚未提供独立预览数据,当前兼容使用品牌起始内容。",
|
|
||||||
},
|
|
||||||
]),
|
|
||||||
],
|
|
||||||
pages: Object.keys(manifest.entrypoints).map((page) => ({
|
pages: Object.keys(manifest.entrypoints).map((page) => ({
|
||||||
key: page,
|
key: page,
|
||||||
modules: manifest.admin.sections
|
modules: manifest.admin.sections
|
||||||
@@ -463,7 +447,7 @@ export class AdminTemplatePreviewService {
|
|||||||
deliveryNote: identity?.deliveryNote ?? "预览模式不会提交咨询或创建客户记录。",
|
deliveryNote: identity?.deliveryNote ?? "预览模式不会提交咨询或创建客户记录。",
|
||||||
contactPhone: null,
|
contactPhone: null,
|
||||||
contactWechat: null,
|
contactWechat: null,
|
||||||
config: { ...brandConfig, visualTemplateKey },
|
config: brandConfig,
|
||||||
};
|
};
|
||||||
const snapshot: BrandReleaseSnapshot = {
|
const snapshot: BrandReleaseSnapshot = {
|
||||||
schemaVersion: "1.0.0",
|
schemaVersion: "1.0.0",
|
||||||
@@ -477,6 +461,7 @@ export class AdminTemplatePreviewService {
|
|||||||
installation: {
|
installation: {
|
||||||
templateKey: industryTemplate.key,
|
templateKey: industryTemplate.key,
|
||||||
templateVersion: industryTemplate.version,
|
templateVersion: industryTemplate.version,
|
||||||
|
visualTemplateKey,
|
||||||
},
|
},
|
||||||
fields: [],
|
fields: [],
|
||||||
offerings: sample.offerings.map((item, sortOrder) => ({
|
offerings: sample.offerings.map((item, sortOrder) => ({
|
||||||
|
|||||||
@@ -3,13 +3,7 @@ import type { Prisma } from "@prisma/client";
|
|||||||
import {
|
import {
|
||||||
capabilityMetadata,
|
capabilityMetadata,
|
||||||
capabilityPlugins,
|
capabilityPlugins,
|
||||||
defaultBrandTemplateKey,
|
|
||||||
type BrandTemplateKey,
|
type BrandTemplateKey,
|
||||||
getBrandTemplate,
|
|
||||||
getDefaultVisualTemplateKey,
|
|
||||||
getTemplatePackageManifestForVisualKey,
|
|
||||||
getVisualTemplate,
|
|
||||||
getVisualTemplateManifest,
|
|
||||||
resolveCapabilities,
|
resolveCapabilities,
|
||||||
} from "@personal-brand/config";
|
} from "@personal-brand/config";
|
||||||
import type { RuntimeTrustItem, RuntimeWorkspace } from "@personal-brand/types";
|
import type { RuntimeTrustItem, RuntimeWorkspace } from "@personal-brand/types";
|
||||||
@@ -94,12 +88,8 @@ export function assemblePublicWorkspace(input: {
|
|||||||
(item) => asRecord(item).isPublished === true,
|
(item) => asRecord(item).isPublished === true,
|
||||||
) as Array<Record<string, unknown>>;
|
) as Array<Record<string, unknown>>;
|
||||||
const installationData = asRecord(releaseSnapshot.installation);
|
const installationData = asRecord(releaseSnapshot.installation);
|
||||||
const templateKey =
|
const templateKey = asString(releaseSnapshot.templateKey);
|
||||||
asString(brandData.templateKey) ||
|
const template = releaseSnapshot.templateDefinition;
|
||||||
asString(releaseSnapshot.templateKey) ||
|
|
||||||
asString(installationData.templateKey) ||
|
|
||||||
defaultBrandTemplateKey;
|
|
||||||
const template = releaseSnapshot.templateDefinition ?? getBrandTemplate(templateKey);
|
|
||||||
const capabilityData = asArray(releaseSnapshot.capabilities) as Array<Record<string, unknown>>;
|
const capabilityData = asArray(releaseSnapshot.capabilities) as Array<Record<string, unknown>>;
|
||||||
const capabilityRecord = (item: Record<string, unknown>, fallbackVersion = "1.0.0") => {
|
const capabilityRecord = (item: Record<string, unknown>, fallbackVersion = "1.0.0") => {
|
||||||
const key = asString(item.capabilityKey) || asString(item.key);
|
const key = asString(item.capabilityKey) || asString(item.key);
|
||||||
@@ -120,15 +110,19 @@ export function assemblePublicWorkspace(input: {
|
|||||||
)
|
)
|
||||||
: [];
|
: [];
|
||||||
const brandConfig = asRecord(brandData.config);
|
const brandConfig = asRecord(brandData.config);
|
||||||
const visualTemplateKey =
|
const visualTemplate = releaseSnapshot.visualTemplateDefinition;
|
||||||
asString(brandConfig.visualTemplateKey) || getDefaultVisualTemplateKey(templateKey);
|
const visualTemplateManifest = releaseSnapshot.visualTemplateManifest;
|
||||||
const visualTemplate =
|
const templatePackageManifest = releaseSnapshot.templatePackageManifest;
|
||||||
releaseSnapshot.visualTemplateDefinition ?? getVisualTemplate(visualTemplateKey);
|
const visualTemplateKey = asString(templatePackageManifest?.visualTemplateKey);
|
||||||
const visualTemplateManifest =
|
if (
|
||||||
releaseSnapshot.visualTemplateManifest ?? getVisualTemplateManifest(visualTemplateKey);
|
!templateKey ||
|
||||||
const templatePackageManifest =
|
!visualTemplateKey ||
|
||||||
releaseSnapshot.templatePackageManifest ??
|
!templatePackageManifest ||
|
||||||
getTemplatePackageManifestForVisualKey(visualTemplateKey);
|
!template ||
|
||||||
|
!visualTemplate ||
|
||||||
|
!visualTemplateManifest
|
||||||
|
)
|
||||||
|
throw new Error("发布快照缺少统一模板契约字段");
|
||||||
const categoryOptions = new Map(
|
const categoryOptions = new Map(
|
||||||
(templatePackageManifest?.admin.sections ?? [])
|
(templatePackageManifest?.admin.sections ?? [])
|
||||||
.filter((section) => section.target === "offering")
|
.filter((section) => section.target === "offering")
|
||||||
@@ -192,10 +186,8 @@ export function assemblePublicWorkspace(input: {
|
|||||||
status: "enabled" as const,
|
status: "enabled" as const,
|
||||||
config: capabilities.find((capability) => capability.key === plugin.key)?.config ?? {},
|
config: capabilities.find((capability) => capability.key === plugin.key)?.config ?? {},
|
||||||
})),
|
})),
|
||||||
theme: visualTemplate?.theme ?? {
|
theme: visualTemplate.theme,
|
||||||
colors: { background: "#F7F5F1", foreground: "#252525", accent: "#8A6846" },
|
...(visualTemplate.layout ? { layout: visualTemplate.layout } : {}),
|
||||||
},
|
|
||||||
...(visualTemplate?.layout ? { layout: visualTemplate.layout } : {}),
|
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
...runtimeWorkspace,
|
...runtimeWorkspace,
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ import { BadRequestException, Controller, Get, Param, Query } from "@nestjs/comm
|
|||||||
import { PublicBrandContextService } from "./public-brand-context.service.js";
|
import { PublicBrandContextService } from "./public-brand-context.service.js";
|
||||||
import { BrandReleaseService } from "../../brand-release.service.js";
|
import { BrandReleaseService } from "../../brand-release.service.js";
|
||||||
import {
|
import {
|
||||||
defaultBrandTemplateKey,
|
|
||||||
defaultVisualTemplateKey,
|
|
||||||
brandTemplateKeys,
|
brandTemplateKeys,
|
||||||
getBrandTemplate,
|
getBrandTemplate,
|
||||||
getVisualTemplate,
|
getVisualTemplate,
|
||||||
@@ -82,10 +80,7 @@ export class PublicTemplateController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Get("preview")
|
@Get("preview")
|
||||||
preview(
|
preview(@Query("industry") industry: string, @Query("visual") visual: string): unknown {
|
||||||
@Query("industry") industry = defaultBrandTemplateKey,
|
|
||||||
@Query("visual") visual = defaultVisualTemplateKey,
|
|
||||||
): unknown {
|
|
||||||
const industryTemplate = getBrandTemplate(industry);
|
const industryTemplate = getBrandTemplate(industry);
|
||||||
const visualTemplate = getVisualTemplate(visual);
|
const visualTemplate = getVisualTemplate(visual);
|
||||||
if (!industryTemplate || !visualTemplate) throw new BadRequestException("模板组合不存在");
|
if (!industryTemplate || !visualTemplate) throw new BadRequestException("模板组合不存在");
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
import { BadRequestException, Injectable, NotFoundException } from "@nestjs/common";
|
import { BadRequestException, Injectable, NotFoundException } from "@nestjs/common";
|
||||||
import { Prisma, type TemplatePackageVersion } from "@prisma/client";
|
import { Prisma, type TemplatePackageVersion } from "@prisma/client";
|
||||||
import {
|
import {
|
||||||
getDefaultVisualTemplateKey,
|
|
||||||
getTemplatePackageManifestForVisualKey,
|
|
||||||
getTemplateSampleContent,
|
|
||||||
getVisualTemplate,
|
getVisualTemplate,
|
||||||
isVisualTemplateCompatible,
|
isVisualTemplateCompatible,
|
||||||
validateTemplatePackageManifest,
|
validateTemplatePackageManifest,
|
||||||
@@ -15,10 +12,10 @@ import { PrismaService } from "../../prisma.service.js";
|
|||||||
import { TemplateWorkspaceService } from "../../template-workspace.service.js";
|
import { TemplateWorkspaceService } from "../../template-workspace.service.js";
|
||||||
|
|
||||||
type BootstrapSource = {
|
type BootstrapSource = {
|
||||||
kind: "package_version" | "registry";
|
kind: "package_version";
|
||||||
manifest: TemplatePackageManifest;
|
manifest: TemplatePackageManifest;
|
||||||
sample: TemplateSampleContent;
|
sample: TemplateSampleContent;
|
||||||
version?: TemplatePackageVersion;
|
version: TemplatePackageVersion;
|
||||||
};
|
};
|
||||||
|
|
||||||
type Counts = {
|
type Counts = {
|
||||||
@@ -111,8 +108,6 @@ export class AdminSampleContentService {
|
|||||||
throw new BadRequestException("当前只支持 missing_only 导入策略");
|
throw new BadRequestException("当前只支持 missing_only 导入策略");
|
||||||
|
|
||||||
const { brand, source } = await this.resolveSource(brandId, body.templatePackageVersionId);
|
const { brand, source } = await this.resolveSource(brandId, body.templatePackageVersionId);
|
||||||
if (!source.version)
|
|
||||||
throw new BadRequestException("品牌尚未安装可追溯的已发布模板包版本,不能导入示例内容");
|
|
||||||
const plan = await this.buildPlan(brandId, brand.config, source);
|
const plan = await this.buildPlan(brandId, brand.config, source);
|
||||||
const priorImport = await this.prisma.templateBootstrapImport.findFirst({
|
const priorImport = await this.prisma.templateBootstrapImport.findFirst({
|
||||||
where: {
|
where: {
|
||||||
@@ -263,50 +258,35 @@ export class AdminSampleContentService {
|
|||||||
select: { templateKey: true, config: true },
|
select: { templateKey: true, config: true },
|
||||||
});
|
});
|
||||||
if (!brand) throw new NotFoundException("品牌不存在");
|
if (!brand) throw new NotFoundException("品牌不存在");
|
||||||
const config = record(brand.config);
|
|
||||||
const visualTemplateKey =
|
|
||||||
typeof config.visualTemplateKey === "string"
|
|
||||||
? config.visualTemplateKey
|
|
||||||
: getDefaultVisualTemplateKey(brand.templateKey);
|
|
||||||
const installation = requestedVersionId
|
const installation = requestedVersionId
|
||||||
? null
|
? null
|
||||||
: await this.prisma.brandTemplateInstallation.findFirst({
|
: await this.prisma.brandTemplateInstallation.findUnique({
|
||||||
where: { brandId },
|
where: { brandId },
|
||||||
orderBy: { updatedAt: "desc" },
|
|
||||||
select: { templatePackageVersionId: true },
|
select: { templatePackageVersionId: true },
|
||||||
});
|
});
|
||||||
const versionId = requestedVersionId ?? installation?.templatePackageVersionId ?? undefined;
|
const versionId = requestedVersionId ?? installation?.templatePackageVersionId ?? undefined;
|
||||||
let source: BootstrapSource;
|
if (!versionId) throw new BadRequestException("品牌没有精确模板包安装版本,必须先完成模板安装");
|
||||||
if (versionId) {
|
const version = await this.prisma.templatePackageVersion.findUnique({
|
||||||
const version = await this.prisma.templatePackageVersion.findUnique({
|
where: { id: versionId },
|
||||||
where: { id: versionId },
|
});
|
||||||
});
|
if (!version) throw new BadRequestException("指定的模板包版本不存在");
|
||||||
if (!version) throw new BadRequestException("指定的模板包版本不存在");
|
if (version.status !== "published")
|
||||||
if (version.status !== "published")
|
throw new BadRequestException("只有已发布的模板包版本可用于 bootstrap");
|
||||||
throw new BadRequestException("只有已发布的模板包版本可用于 bootstrap");
|
const manifest = version.manifestSnapshot as unknown as TemplatePackageManifest;
|
||||||
const manifest = version.manifestSnapshot as unknown as TemplatePackageManifest;
|
const issues = validateTemplatePackageManifest(manifest);
|
||||||
const issues = validateTemplatePackageManifest(manifest);
|
if (issues.length) throw new BadRequestException(`模板包 manifest 无效:${issues.join(";")}`);
|
||||||
if (issues.length)
|
if (
|
||||||
throw new BadRequestException(`模板包 manifest 无效:${issues.join(";")}`);
|
manifest.packageKey !== version.packageKey ||
|
||||||
if (
|
manifest.version !== version.version ||
|
||||||
manifest.packageKey !== version.packageKey ||
|
manifest.packageKey !== manifest.visualTemplateKey ||
|
||||||
manifest.version !== version.version ||
|
!/^[a-f0-9]{64}$/.test(version.contentChecksum) ||
|
||||||
!/^[a-f0-9]{64}$/.test(version.contentChecksum) ||
|
!manifest.supportedIndustryTemplates.includes(brand.templateKey)
|
||||||
(version.visualTemplateKey ?? version.packageKey) !==
|
)
|
||||||
(manifest.visualTemplateKey ?? version.packageKey) ||
|
throw new BadRequestException("模板包版本与品牌行业或版本台账不匹配");
|
||||||
!manifest.supportedIndustryTemplates.includes(brand.templateKey)
|
const sample = manifest.sampleContent?.[brand.templateKey];
|
||||||
)
|
if (!sample) throw new BadRequestException("该模板包没有当前行业的 bootstrap sampleContent");
|
||||||
throw new BadRequestException("模板包版本与品牌行业或版本台账不匹配");
|
const source: BootstrapSource = { kind: "package_version", version, manifest, sample };
|
||||||
const sample = manifest.sampleContent?.[brand.templateKey];
|
const visualTemplateKey = manifest.visualTemplateKey;
|
||||||
if (!sample) throw new BadRequestException("该模板包没有当前行业的 bootstrap sampleContent");
|
|
||||||
source = { kind: "package_version", version, manifest, sample };
|
|
||||||
} else {
|
|
||||||
const manifest = getTemplatePackageManifestForVisualKey(visualTemplateKey);
|
|
||||||
const sample = getTemplateSampleContent(brand.templateKey, visualTemplateKey);
|
|
||||||
if (!manifest || !sample || requestedVersionId)
|
|
||||||
throw new BadRequestException("当前模板没有可用的 bootstrap sampleContent");
|
|
||||||
source = { kind: "registry", manifest, sample };
|
|
||||||
}
|
|
||||||
const visual = getVisualTemplate(visualTemplateKey);
|
const visual = getVisualTemplate(visualTemplateKey);
|
||||||
if (!visual || !isVisualTemplateCompatible(visual, brand.templateKey))
|
if (!visual || !isVisualTemplateCompatible(visual, brand.templateKey))
|
||||||
throw new BadRequestException("当前视觉模板与品牌行业不兼容");
|
throw new BadRequestException("当前视觉模板与品牌行业不兼容");
|
||||||
@@ -417,8 +397,8 @@ export class AdminSampleContentService {
|
|||||||
kind: source.kind,
|
kind: source.kind,
|
||||||
packageKey: source.manifest.packageKey,
|
packageKey: source.manifest.packageKey,
|
||||||
version: source.manifest.version,
|
version: source.manifest.version,
|
||||||
contentChecksum: source.version?.contentChecksum ?? null,
|
contentChecksum: source.version.contentChecksum,
|
||||||
...(source.version ? { templatePackageVersionId: source.version.id } : {}),
|
templatePackageVersionId: source.version.id,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Controller, Get, Post, Body, Req } from "@nestjs/common";
|
import { Controller, Get, Post, Body, Req } from "@nestjs/common";
|
||||||
import type { FastifyRequest } from "fastify";
|
import type { FastifyRequest } from "fastify";
|
||||||
import { InstallTemplateDto } from "../../admin.dto.js";
|
import { InstallTemplateDto, SelectTemplateVersionDto } from "../../admin.dto.js";
|
||||||
import { TemplateWorkspaceService } from "../../template-workspace.service.js";
|
import { TemplateWorkspaceService } from "../../template-workspace.service.js";
|
||||||
import { requireAdminIdentity } from "./admin-access.identity.js";
|
import { requireAdminIdentity } from "./admin-access.identity.js";
|
||||||
import { AdminWorkspaceService } from "./admin-workspace.service.js";
|
import { AdminWorkspaceService } from "./admin-workspace.service.js";
|
||||||
@@ -52,6 +52,21 @@ class AdminWorkspacePreviewController {
|
|||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Post("template/select-version")
|
||||||
|
async selectVersion(
|
||||||
|
@Req() request: FastifyRequest,
|
||||||
|
@Body() body: SelectTemplateVersionDto,
|
||||||
|
): Promise<unknown> {
|
||||||
|
const identity = requireAdminIdentity(request);
|
||||||
|
const requestId = request.headers["x-request-id"]?.toString() ?? request.id;
|
||||||
|
return this.templateWorkspace.selectVersion(
|
||||||
|
identity.brandId,
|
||||||
|
body,
|
||||||
|
identity.subject,
|
||||||
|
requestId,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { AdminWorkspacePreviewController };
|
export { AdminWorkspacePreviewController };
|
||||||
@@ -1,10 +1,5 @@
|
|||||||
import { Injectable } from "@nestjs/common";
|
import { BadRequestException, Injectable } from "@nestjs/common";
|
||||||
import { PrismaService } from "../../prisma.service.js";
|
import { PrismaService } from "../../prisma.service.js";
|
||||||
import {
|
|
||||||
defaultBrandTemplateKey,
|
|
||||||
getDefaultVisualTemplateKey,
|
|
||||||
getTemplatePackageManifestForVisualKey,
|
|
||||||
} from "@personal-brand/config";
|
|
||||||
import { PublicWorkspaceService } from "../public/public-workspace.service.js";
|
import { PublicWorkspaceService } from "../public/public-workspace.service.js";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@@ -15,11 +10,11 @@ export class AdminWorkspaceService {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
async get(brandId: string): Promise<unknown> {
|
async get(brandId: string): Promise<unknown> {
|
||||||
const [brand, installations, fields, offerings, forms] = await Promise.all([
|
const [brand, installation, fields, offerings, forms] = await Promise.all([
|
||||||
this.prisma.brandProfile.findUnique({ where: { id: brandId } }),
|
this.prisma.brandProfile.findUnique({ where: { id: brandId } }),
|
||||||
this.prisma.brandTemplateInstallation.findMany({
|
this.prisma.brandTemplateInstallation.findUnique({
|
||||||
where: { brandId },
|
where: { brandId },
|
||||||
orderBy: { updatedAt: "desc" },
|
include: { templatePackageVersion: true },
|
||||||
}),
|
}),
|
||||||
this.prisma.brandFieldDefinition.findMany({
|
this.prisma.brandFieldDefinition.findMany({
|
||||||
where: { brandId },
|
where: { brandId },
|
||||||
@@ -28,36 +23,50 @@ export class AdminWorkspaceService {
|
|||||||
this.prisma.offering.findMany({ where: { brandId }, orderBy: { sortOrder: "asc" } }),
|
this.prisma.offering.findMany({ where: { brandId }, orderBy: { sortOrder: "asc" } }),
|
||||||
this.prisma.inquiryForm.findMany({ where: { brandId }, orderBy: { updatedAt: "desc" } }),
|
this.prisma.inquiryForm.findMany({ where: { brandId }, orderBy: { updatedAt: "desc" } }),
|
||||||
]);
|
]);
|
||||||
const config = this.jsonObject(brand?.config);
|
if (!installation?.templatePackageVersion)
|
||||||
const templateKey =
|
throw new BadRequestException("品牌没有锁定精确视觉模板包版本");
|
||||||
typeof config.visualTemplateKey === "string"
|
const manifest = installation.templatePackageVersion.manifestSnapshot as {
|
||||||
? config.visualTemplateKey
|
visualTemplateKey: string;
|
||||||
: getDefaultVisualTemplateKey(brand?.templateKey ?? defaultBrandTemplateKey);
|
displayName: string;
|
||||||
const manifest = getTemplatePackageManifestForVisualKey(templateKey);
|
admin: unknown;
|
||||||
|
navigation: Array<{ key: string; label: string; page: string }>;
|
||||||
|
templateFields?: Array<Record<string, unknown> & { key: string; binding?: string }>;
|
||||||
|
assetSlots: unknown[];
|
||||||
|
trustContentTypes?: unknown[];
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
brand,
|
brand,
|
||||||
installations,
|
installations: [
|
||||||
|
{
|
||||||
|
...installation,
|
||||||
|
visualTemplateKey: manifest.visualTemplateKey,
|
||||||
|
},
|
||||||
|
],
|
||||||
fields,
|
fields,
|
||||||
offerings,
|
offerings,
|
||||||
forms,
|
forms,
|
||||||
templateContent: manifest
|
templateContent: {
|
||||||
? {
|
displayName: manifest.displayName,
|
||||||
displayName: manifest.displayName,
|
admin: manifest.admin,
|
||||||
admin: manifest.admin,
|
navigation: manifest.navigation.map(({ key, label, page }) => ({ key, label, page })),
|
||||||
navigation: manifest.navigation.map(({ key, label, page }) => ({ key, label, page })),
|
templateFields: (manifest.templateFields ?? []).map((field) => ({
|
||||||
templateFields: (manifest.templateFields ?? []).map((field) => ({
|
...field,
|
||||||
...field,
|
binding: field.binding ?? `brand.config.templateData.${field.key}`,
|
||||||
binding: field.binding ?? `brand.config.templateData.${field.key}`,
|
})),
|
||||||
})),
|
assetSlots: manifest.assetSlots,
|
||||||
assetSlots: manifest.assetSlots,
|
trustContentTypes: manifest.trustContentTypes ?? [],
|
||||||
trustContentTypes: manifest.trustContentTypes ?? [],
|
},
|
||||||
}
|
|
||||||
: null,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
getPreview(brandId: string): Promise<unknown> {
|
async getPreview(brandId: string): Promise<unknown> {
|
||||||
|
const installation = await this.prisma.brandTemplateInstallation.findUnique({
|
||||||
|
where: { brandId },
|
||||||
|
select: { templatePackageVersionId: true },
|
||||||
|
});
|
||||||
|
if (!installation?.templatePackageVersionId)
|
||||||
|
throw new BadRequestException("品牌没有锁定精确模板包版本");
|
||||||
return this.publicWorkspace.getForBrandId(brandId, true);
|
return this.publicWorkspace.getForBrandId(brandId, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,45 +1,35 @@
|
|||||||
import { BadRequestException, ConflictException, Injectable } from "@nestjs/common";
|
import { BadRequestException, ConflictException, Injectable } from "@nestjs/common";
|
||||||
import type { TemplatePackageVersion } from "@prisma/client";
|
import type { TemplatePackageVersion } from "@prisma/client";
|
||||||
import { Prisma } from "@prisma/client";
|
import { Prisma } from "@prisma/client";
|
||||||
import { execFile } from "node:child_process";
|
|
||||||
import { promisify } from "node:util";
|
|
||||||
import {
|
import {
|
||||||
type BrandTemplateKey,
|
type BrandTemplateKey,
|
||||||
defaultBrandTemplateKey,
|
|
||||||
getBrandTemplate,
|
getBrandTemplate,
|
||||||
getVisualTemplate,
|
getVisualTemplate,
|
||||||
getVisualTemplateManifest,
|
getVisualTemplateManifest,
|
||||||
getDefaultVisualTemplateKey,
|
|
||||||
getTemplatePackageManifestForVisualKey,
|
|
||||||
isVisualTemplateCompatible,
|
isVisualTemplateCompatible,
|
||||||
|
validateTemplatePackageManifest,
|
||||||
} from "@personal-brand/config";
|
} from "@personal-brand/config";
|
||||||
|
import type { TemplatePackageManifest } from "@personal-brand/config";
|
||||||
import type { CreateTrustContentDto, UpdateTrustContentDto } from "./admin.dto.js";
|
import type { CreateTrustContentDto, UpdateTrustContentDto } from "./admin.dto.js";
|
||||||
import type { RollbackTemplateDto, UpgradeTemplateDto } from "./admin.dto.js";
|
import type { RollbackTemplateDto, UpgradeTemplateDto } from "./admin.dto.js";
|
||||||
import { PrismaService } from "./prisma.service.js";
|
import { PrismaService } from "./prisma.service.js";
|
||||||
|
|
||||||
const execFileAsync = promisify(execFile);
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class TemplateWorkspaceService {
|
export class TemplateWorkspaceService {
|
||||||
constructor(private readonly prisma: PrismaService) {}
|
constructor(private readonly prisma: PrismaService) {}
|
||||||
async getTrustContentTypes(brandId: string): Promise<string[]> {
|
async getTrustContentTypes(brandId: string): Promise<string[]> {
|
||||||
const brand = await this.prisma.brandProfile.findUnique({
|
const installation = await this.prisma.brandTemplateInstallation.findUnique({
|
||||||
where: { id: brandId },
|
where: { brandId },
|
||||||
select: { templateKey: true, config: true },
|
include: { templatePackageVersion: true },
|
||||||
});
|
});
|
||||||
const config =
|
if (!installation?.templatePackageVersion)
|
||||||
brand?.config && typeof brand.config === "object" && !Array.isArray(brand.config)
|
throw new BadRequestException("品牌没有锁定精确视觉模板包版本");
|
||||||
? (brand.config as Record<string, unknown>)
|
const manifest = record(
|
||||||
: {};
|
installation.templatePackageVersion.manifestSnapshot,
|
||||||
const visualKey =
|
) as unknown as TemplatePackageManifest;
|
||||||
typeof config.visualTemplateKey === "string"
|
if (validateTemplatePackageManifest(manifest as unknown as TemplatePackageManifest).length)
|
||||||
? config.visualTemplateKey
|
throw new BadRequestException("当前安装的模板包不符合统一模板契约");
|
||||||
: getDefaultVisualTemplateKey(brand?.templateKey ?? defaultBrandTemplateKey);
|
return manifest.trustContentTypes?.map((item) => item.type) ?? [];
|
||||||
return (
|
|
||||||
getTemplatePackageManifestForVisualKey(visualKey)?.trustContentTypes?.map(
|
|
||||||
(item) => item.type,
|
|
||||||
) ?? []
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
async createTrustContent(brandId: string, body: CreateTrustContentDto) {
|
async createTrustContent(brandId: string, body: CreateTrustContentDto) {
|
||||||
if (!(await this.getTrustContentTypes(brandId)).includes(body.type))
|
if (!(await this.getTrustContentTypes(brandId)).includes(body.type))
|
||||||
@@ -87,28 +77,25 @@ export class TemplateWorkspaceService {
|
|||||||
where: { id: brandId },
|
where: { id: brandId },
|
||||||
select: { templateKey: true },
|
select: { templateKey: true },
|
||||||
}),
|
}),
|
||||||
this.prisma.brandTemplateInstallation.findFirst({
|
this.prisma.brandTemplateInstallation.findUnique({
|
||||||
where: { brandId },
|
where: { brandId },
|
||||||
orderBy: { updatedAt: "desc" },
|
|
||||||
select: { templateKey: true },
|
select: { templateKey: true },
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
// BrandProfile.templateKey 是「品牌使用哪个行业模板」的唯一真相;
|
const template = brand?.templateKey ? getBrandTemplate(brand.templateKey) : undefined;
|
||||||
// 安装记录只是同一模板的版本台账,缺失时不能反过来改写品牌身份。
|
if (!template) throw new BadRequestException("品牌没有有效的行业模型声明");
|
||||||
for (const candidate of [brand?.templateKey, installation?.templateKey]) {
|
if (installation && installation.templateKey !== template.key)
|
||||||
const template = candidate ? getBrandTemplate(candidate) : undefined;
|
throw new BadRequestException("品牌行业模型与模板安装不一致,请修复安装数据");
|
||||||
if (template) return template.key;
|
return template.key;
|
||||||
}
|
|
||||||
return defaultBrandTemplateKey;
|
|
||||||
}
|
}
|
||||||
async install(brandId: string, templateKey: BrandTemplateKey, templatePackageVersionId?: string) {
|
async install(brandId: string, templateKey: BrandTemplateKey, templatePackageVersionId: string) {
|
||||||
const template = getBrandTemplate(templateKey);
|
const template = getBrandTemplate(templateKey);
|
||||||
if (!template) throw new BadRequestException("行业模板不存在");
|
if (!template) throw new BadRequestException("行业模板不存在");
|
||||||
const [existing, brand] = await Promise.all([
|
const [existing, brand] = await Promise.all([
|
||||||
this.prisma.brandTemplateInstallation.findFirst({ where: { brandId } }),
|
this.prisma.brandTemplateInstallation.findUnique({ where: { brandId } }),
|
||||||
this.prisma.brandProfile.findUnique({
|
this.prisma.brandProfile.findUnique({
|
||||||
where: { id: brandId },
|
where: { id: brandId },
|
||||||
select: { config: true, templateKey: true },
|
select: { templateKey: true },
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
// 一个品牌只使用一个行业模板(BrandProfile.templateKey 即身份)。安装只允许补建当前模板的版本台账,
|
// 一个品牌只使用一个行业模板(BrandProfile.templateKey 即身份)。安装只允许补建当前模板的版本台账,
|
||||||
@@ -118,20 +105,13 @@ export class TemplateWorkspaceService {
|
|||||||
throw new BadRequestException(
|
throw new BadRequestException(
|
||||||
`当前品牌已在使用「${currentTemplate.name}」行业模板,更换行业模板不在本版本范围内`,
|
`当前品牌已在使用「${currentTemplate.name}」行业模板,更换行业模板不在本版本范围内`,
|
||||||
);
|
);
|
||||||
if (existing && existing.templateKey === templateKey)
|
if (existing) throw new BadRequestException("品牌已经安装模板包,请使用明确的升级流程");
|
||||||
throw new BadRequestException("该模板已经安装");
|
const packageVersion = await this.resolveInstallablePackageVersion(
|
||||||
const brandConfig =
|
templateKey,
|
||||||
brand?.config && typeof brand.config === "object" && !Array.isArray(brand.config)
|
templatePackageVersionId,
|
||||||
? (brand.config as Record<string, unknown>)
|
);
|
||||||
: {};
|
const packageManifest = packageVersion.manifestSnapshot as unknown as TemplatePackageManifest;
|
||||||
const configuredVisualTemplateKey =
|
const visualTemplateKey = packageManifest.visualTemplateKey;
|
||||||
typeof brandConfig.visualTemplateKey === "string" ? brandConfig.visualTemplateKey : undefined;
|
|
||||||
const visualTemplateKey =
|
|
||||||
configuredVisualTemplateKey &&
|
|
||||||
getVisualTemplate(configuredVisualTemplateKey) &&
|
|
||||||
isVisualTemplateCompatible(getVisualTemplate(configuredVisualTemplateKey)!, templateKey)
|
|
||||||
? configuredVisualTemplateKey
|
|
||||||
: getDefaultVisualTemplateKey(templateKey);
|
|
||||||
const visualManifest = getVisualTemplateManifest(visualTemplateKey);
|
const visualManifest = getVisualTemplateManifest(visualTemplateKey);
|
||||||
const visualTemplate = getVisualTemplate(visualTemplateKey);
|
const visualTemplate = getVisualTemplate(visualTemplateKey);
|
||||||
if (
|
if (
|
||||||
@@ -140,39 +120,19 @@ export class TemplateWorkspaceService {
|
|||||||
!isVisualTemplateCompatible(visualTemplate, templateKey)
|
!isVisualTemplateCompatible(visualTemplate, templateKey)
|
||||||
)
|
)
|
||||||
throw new BadRequestException("当前视觉模板不适配行业模板");
|
throw new BadRequestException("当前视觉模板不适配行业模板");
|
||||||
const templatePackageSnapshot = {
|
|
||||||
schemaVersion: "1.0",
|
|
||||||
version: template.version,
|
|
||||||
industryTemplate: template,
|
|
||||||
visualTemplate: visualManifest,
|
|
||||||
capabilities: template.capabilities,
|
|
||||||
};
|
|
||||||
const packageVersion = await this.resolveInstallablePackageVersion(
|
|
||||||
templateKey,
|
|
||||||
visualTemplateKey,
|
|
||||||
templatePackageVersionId,
|
|
||||||
);
|
|
||||||
return this.prisma.$transaction(async (tx) => {
|
return this.prisma.$transaction(async (tx) => {
|
||||||
// 安装记录与品牌身份必须同时落库,否则会出现「品牌在跑 A 模板、台账记的是 B」的漂移。
|
|
||||||
// 已经自定义过视觉模板的品牌,补建台账时保留原选择,只把行业模板身份写回。
|
|
||||||
const nextConfig = (
|
|
||||||
brandConfig.visualTemplateKey === undefined
|
|
||||||
? { ...brandConfig, visualTemplateKey }
|
|
||||||
: brandConfig
|
|
||||||
) as Prisma.InputJsonValue;
|
|
||||||
await tx.brandProfile.update({
|
await tx.brandProfile.update({
|
||||||
where: { id: brandId },
|
where: { id: brandId },
|
||||||
data: { templateKey, config: nextConfig },
|
data: { templateKey },
|
||||||
});
|
});
|
||||||
const installation = await tx.brandTemplateInstallation.create({
|
const installation = await tx.brandTemplateInstallation.create({
|
||||||
data: {
|
data: {
|
||||||
brandId,
|
brandId,
|
||||||
templateKey,
|
templateKey,
|
||||||
templateVersion: template.version,
|
templateVersion: template.version,
|
||||||
visualTemplateKey,
|
templatePackageVersionId: packageVersion.id,
|
||||||
templatePackageVersionId: packageVersion?.id ?? null,
|
contentChecksum: packageVersion.contentChecksum,
|
||||||
contentChecksum: packageVersion?.contentChecksum ?? null,
|
configSnapshot: packageVersion.manifestSnapshot as Prisma.InputJsonValue,
|
||||||
configSnapshot: templatePackageSnapshot as unknown as Prisma.InputJsonValue,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
await tx.brandFieldDefinition.createMany({
|
await tx.brandFieldDefinition.createMany({
|
||||||
@@ -192,42 +152,112 @@ export class TemplateWorkspaceService {
|
|||||||
}
|
}
|
||||||
private async resolveInstallablePackageVersion(
|
private async resolveInstallablePackageVersion(
|
||||||
templateKey: BrandTemplateKey,
|
templateKey: BrandTemplateKey,
|
||||||
visualTemplateKey: string,
|
templatePackageVersionId: string,
|
||||||
templatePackageVersionId?: string,
|
): Promise<TemplatePackageVersion> {
|
||||||
): Promise<TemplatePackageVersion | null> {
|
const version = await this.prisma.templatePackageVersion.findUnique({
|
||||||
const version = templatePackageVersionId
|
where: { id: templatePackageVersionId },
|
||||||
? await this.prisma.templatePackageVersion.findUnique({
|
});
|
||||||
where: { id: templatePackageVersionId },
|
if (!version) throw new BadRequestException("指定的模板包版本不存在");
|
||||||
})
|
|
||||||
: await this.prisma.templatePackageVersion.findFirst({
|
|
||||||
where: { packageKey: visualTemplateKey, status: "published" },
|
|
||||||
orderBy: { importedAt: "desc" },
|
|
||||||
});
|
|
||||||
if (!version) {
|
|
||||||
if (templatePackageVersionId) throw new BadRequestException("指定的模板包版本不存在");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (version.status !== "published")
|
if (version.status !== "published")
|
||||||
throw new BadRequestException("只有已发布的模板包版本可以安装到品牌");
|
throw new BadRequestException("只有已发布的模板包版本可以安装到品牌");
|
||||||
const manifest = record(version.manifestSnapshot);
|
const manifest = record(version.manifestSnapshot);
|
||||||
const manifestVisualTemplateKey =
|
|
||||||
typeof manifest.visualTemplateKey === "string"
|
|
||||||
? manifest.visualTemplateKey
|
|
||||||
: version.packageKey;
|
|
||||||
if (
|
if (
|
||||||
manifest.packageKey !== version.packageKey ||
|
manifest.packageKey !== version.packageKey ||
|
||||||
manifest.version !== version.version ||
|
manifest.version !== version.version ||
|
||||||
manifestVisualTemplateKey !== visualTemplateKey ||
|
typeof manifest.visualTemplateKey !== "string" ||
|
||||||
|
manifest.packageKey !== manifest.visualTemplateKey ||
|
||||||
!Array.isArray(manifest.supportedIndustryTemplates) ||
|
!Array.isArray(manifest.supportedIndustryTemplates) ||
|
||||||
!manifest.supportedIndustryTemplates.includes(templateKey)
|
!manifest.supportedIndustryTemplates.includes(templateKey)
|
||||||
) {
|
) {
|
||||||
throw new BadRequestException("模板包版本与行业或视觉模板不匹配");
|
throw new BadRequestException("模板包版本与行业或视觉模板不匹配");
|
||||||
}
|
}
|
||||||
|
if (validateTemplatePackageManifest(manifest as unknown as TemplatePackageManifest).length)
|
||||||
|
throw new BadRequestException("模板包版本不符合统一模板契约");
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async selectVersion(
|
||||||
|
brandId: string,
|
||||||
|
body: {
|
||||||
|
templatePackageVersionId: string;
|
||||||
|
expectedCurrentPackageVersionId?: string | null;
|
||||||
|
confirm: boolean;
|
||||||
|
},
|
||||||
|
actorId: string,
|
||||||
|
requestId?: string,
|
||||||
|
) {
|
||||||
|
if (!body.confirm) throw new BadRequestException("选择模板版本必须显式确认");
|
||||||
|
const [installation, brand, target] = await Promise.all([
|
||||||
|
this.installation(brandId),
|
||||||
|
this.prisma.brandProfile.findUnique({
|
||||||
|
where: { id: brandId },
|
||||||
|
select: { templateKey: true },
|
||||||
|
}),
|
||||||
|
this.prisma.templatePackageVersion.findUnique({
|
||||||
|
where: { id: body.templatePackageVersionId },
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
if (!brand) throw new BadRequestException("品牌不存在");
|
||||||
|
if (body.expectedCurrentPackageVersionId !== installation.templatePackageVersionId)
|
||||||
|
throw new ConflictException("当前模板版本已变化,请刷新后重试");
|
||||||
|
if (!target || target.status !== "published")
|
||||||
|
throw new BadRequestException("指定模板包版本不存在或未发布");
|
||||||
|
const manifest = record(target.manifestSnapshot) as unknown as TemplatePackageManifest;
|
||||||
|
if (
|
||||||
|
target.packageKey !== manifest.packageKey ||
|
||||||
|
target.version !== manifest.version ||
|
||||||
|
manifest.packageKey !== manifest.visualTemplateKey ||
|
||||||
|
!manifest.supportedIndustryTemplates?.includes(brand.templateKey) ||
|
||||||
|
validateTemplatePackageManifest(manifest).length
|
||||||
|
)
|
||||||
|
throw new BadRequestException("指定模板包版本不符合当前品牌的统一模板契约");
|
||||||
|
if (target.id === installation.templatePackageVersionId)
|
||||||
|
return { installation, unchanged: true };
|
||||||
|
const history = Array.isArray(installation.previousSnapshots)
|
||||||
|
? installation.previousSnapshots
|
||||||
|
: [];
|
||||||
|
const updated = await this.prisma.$transaction(async (tx) => {
|
||||||
|
const changed = await tx.brandTemplateInstallation.updateMany({
|
||||||
|
where: {
|
||||||
|
id: installation.id,
|
||||||
|
templatePackageVersionId: installation.templatePackageVersionId,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
templatePackageVersionId: target.id,
|
||||||
|
templateVersion: target.version,
|
||||||
|
contentChecksum: target.contentChecksum,
|
||||||
|
configSnapshot: manifest as unknown as Prisma.InputJsonValue,
|
||||||
|
previousSnapshots: [...history, installation.configSnapshot],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (changed.count !== 1) throw new ConflictException("当前模板版本已变化,请刷新后重试");
|
||||||
|
await tx.templatePackageAuditLog.create({
|
||||||
|
data: {
|
||||||
|
templatePackageVersionId: target.id,
|
||||||
|
actorId,
|
||||||
|
action: "brand_template_selected",
|
||||||
|
...(requestId ? { requestId } : {}),
|
||||||
|
metadata: {
|
||||||
|
brandId,
|
||||||
|
fromVersionId: installation.templatePackageVersionId,
|
||||||
|
toVersionId: target.id,
|
||||||
|
contentChecksum: target.contentChecksum,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return tx.brandTemplateInstallation.findUniqueOrThrow({
|
||||||
|
where: { id: installation.id },
|
||||||
|
include: { templatePackageVersion: true },
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return { installation: updated, unchanged: false };
|
||||||
|
}
|
||||||
|
|
||||||
private async installation(brandId: string) {
|
private async installation(brandId: string) {
|
||||||
const item = await this.prisma.brandTemplateInstallation.findFirst({ where: { brandId } });
|
const item = await this.prisma.brandTemplateInstallation.findUnique({
|
||||||
|
where: { brandId },
|
||||||
|
include: { templatePackageVersion: true },
|
||||||
|
});
|
||||||
if (!item) throw new BadRequestException("尚未安装行业模板");
|
if (!item) throw new BadRequestException("尚未安装行业模板");
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
@@ -235,30 +265,37 @@ export class TemplateWorkspaceService {
|
|||||||
const templateKey = await this.getEffectiveTemplateKey(brandId);
|
const templateKey = await this.getEffectiveTemplateKey(brandId);
|
||||||
const template = getBrandTemplate(templateKey);
|
const template = getBrandTemplate(templateKey);
|
||||||
if (!template) throw new BadRequestException("当前行业模板不存在");
|
if (!template) throw new BadRequestException("当前行业模板不存在");
|
||||||
const [installation, brand] = await Promise.all([
|
const installation = await this.installation(brandId);
|
||||||
this.prisma.brandTemplateInstallation.findFirst({ where: { brandId } }),
|
const brand = await this.prisma.brandProfile.findUnique({
|
||||||
this.prisma.brandProfile.findUnique({ where: { id: brandId }, select: { config: true } }),
|
where: { id: brandId },
|
||||||
]);
|
select: { config: true },
|
||||||
// 品牌一直有行业模板,但版本台账可能还没建立;此时以模板目录的版本为准,不报错。
|
});
|
||||||
const currentVersion = installation?.templateVersion ?? template.version;
|
|
||||||
const config = record(brand?.config);
|
const config = record(brand?.config);
|
||||||
const visualTemplateKey =
|
if (!installation.templatePackageVersion || !installation.templatePackageVersionId)
|
||||||
installation?.visualTemplateKey ??
|
throw new BadRequestException("品牌安装没有锁定精确视觉模板包版本");
|
||||||
(typeof config.visualTemplateKey === "string" ? config.visualTemplateKey : undefined) ??
|
const currentVersion = installation.templateVersion;
|
||||||
getDefaultVisualTemplateKey(templateKey);
|
const visualTemplateKey = record(
|
||||||
const currentPackage = installation?.templatePackageVersionId
|
installation.templatePackageVersion.manifestSnapshot,
|
||||||
? await this.prisma.templatePackageVersion.findUnique({
|
).visualTemplateKey;
|
||||||
where: { id: installation.templatePackageVersionId },
|
if (typeof visualTemplateKey !== "string")
|
||||||
})
|
throw new BadRequestException("已安装模板版本缺少 visualTemplateKey 声明");
|
||||||
: null;
|
const [currentPackage, targetPackage] = await Promise.all([
|
||||||
const targetPackage = visualTemplateKey
|
this.prisma.templatePackageVersion.findUnique({
|
||||||
? await this.prisma.templatePackageVersion.findFirst({
|
where: { id: installation.templatePackageVersionId },
|
||||||
where: { packageKey: visualTemplateKey, status: "published" },
|
}),
|
||||||
orderBy: { importedAt: "desc" },
|
this.prisma.templatePackageVersion.findFirst({
|
||||||
})
|
where: { packageKey: visualTemplateKey, status: "published" },
|
||||||
: null;
|
orderBy: { importedAt: "desc" },
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
if (!currentPackage) throw new BadRequestException("当前安装引用的模板包版本不存在");
|
||||||
|
if (
|
||||||
|
currentPackage.packageKey !== visualTemplateKey ||
|
||||||
|
record(currentPackage.manifestSnapshot).visualTemplateKey !== visualTemplateKey
|
||||||
|
)
|
||||||
|
throw new BadRequestException("品牌安装与模板包视觉声明不一致");
|
||||||
const targetManifest = record(targetPackage?.manifestSnapshot);
|
const targetManifest = record(targetPackage?.manifestSnapshot);
|
||||||
const currentManifest = record(currentPackage?.manifestSnapshot);
|
const currentManifest = record(currentPackage.manifestSnapshot);
|
||||||
const currentDeclarations = manifestRecords(currentManifest.templateFields);
|
const currentDeclarations = manifestRecords(currentManifest.templateFields);
|
||||||
const targetDeclarations = manifestRecords(targetManifest.templateFields);
|
const targetDeclarations = manifestRecords(targetManifest.templateFields);
|
||||||
const currentByKey = new Map(currentDeclarations.map((item) => [String(item.key), item]));
|
const currentByKey = new Map(currentDeclarations.map((item) => [String(item.key), item]));
|
||||||
@@ -316,12 +353,11 @@ export class TemplateWorkspaceService {
|
|||||||
templateKey,
|
templateKey,
|
||||||
currentVersion,
|
currentVersion,
|
||||||
latestVersion: targetPackage?.version ?? template.version,
|
latestVersion: targetPackage?.version ?? template.version,
|
||||||
currentPackageVersionId: currentPackage?.id ?? null,
|
currentPackageVersionId: currentPackage.id,
|
||||||
currentContentChecksum:
|
currentContentChecksum: currentPackage.contentChecksum,
|
||||||
currentPackage?.contentChecksum ?? installation?.contentChecksum ?? null,
|
|
||||||
targetPackageVersionId: targetPackage?.id ?? null,
|
targetPackageVersionId: targetPackage?.id ?? null,
|
||||||
targetContentChecksum: targetPackage?.contentChecksum ?? null,
|
targetContentChecksum: targetPackage?.contentChecksum ?? null,
|
||||||
canUpgrade: Boolean(targetPackage && targetPackage.id !== currentPackage?.id),
|
canUpgrade: Boolean(targetPackage && targetPackage.id !== currentPackage.id),
|
||||||
canRollback:
|
canRollback:
|
||||||
Array.isArray(installation?.previousSnapshots) && installation.previousSnapshots.length > 0,
|
Array.isArray(installation?.previousSnapshots) && installation.previousSnapshots.length > 0,
|
||||||
changes: {
|
changes: {
|
||||||
@@ -404,7 +440,8 @@ export class TemplateWorkspaceService {
|
|||||||
throw new ConflictException("冲突处理与当前预览不一致,请重新预览并逐项确认");
|
throw new ConflictException("冲突处理与当前预览不一致,请重新预览并逐项确认");
|
||||||
const manifest = record(target.manifestSnapshot);
|
const manifest = record(target.manifestSnapshot);
|
||||||
if (
|
if (
|
||||||
target.packageKey !== installation.visualTemplateKey ||
|
target.packageKey !==
|
||||||
|
record(installation.templatePackageVersion?.manifestSnapshot).visualTemplateKey ||
|
||||||
manifest.packageKey !== target.packageKey ||
|
manifest.packageKey !== target.packageKey ||
|
||||||
manifest.version !== target.version ||
|
manifest.version !== target.version ||
|
||||||
!Array.isArray(manifest.supportedIndustryTemplates) ||
|
!Array.isArray(manifest.supportedIndustryTemplates) ||
|
||||||
@@ -474,12 +511,15 @@ export class TemplateWorkspaceService {
|
|||||||
where: { packageKey: previousManifest.packageKey, version },
|
where: { packageKey: previousManifest.packageKey, version },
|
||||||
})
|
})
|
||||||
: null;
|
: null;
|
||||||
|
if (!previousPackage)
|
||||||
|
throw new BadRequestException("历史模板包版本不存在,不能回滚到未锁定版本");
|
||||||
if (
|
if (
|
||||||
previousPackage &&
|
previousPackage.packageKey !==
|
||||||
(previousPackage.packageKey !== installation.visualTemplateKey ||
|
record(installation.templatePackageVersion?.manifestSnapshot).visualTemplateKey ||
|
||||||
!stringList(record(previousPackage.manifestSnapshot).supportedIndustryTemplates).includes(
|
previousPackage.packageKey !== record(previousPackage.manifestSnapshot).visualTemplateKey ||
|
||||||
installation.templateKey,
|
!stringList(record(previousPackage.manifestSnapshot).supportedIndustryTemplates).includes(
|
||||||
))
|
installation.templateKey,
|
||||||
|
)
|
||||||
)
|
)
|
||||||
throw new BadRequestException("上一版模板包与当前品牌行业或视觉模板不兼容");
|
throw new BadRequestException("上一版模板包与当前品牌行业或视觉模板不兼容");
|
||||||
const updated = await this.prisma.$transaction(async (tx) => {
|
const updated = await this.prisma.$transaction(async (tx) => {
|
||||||
@@ -491,8 +531,8 @@ export class TemplateWorkspaceService {
|
|||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
templateVersion: version,
|
templateVersion: version,
|
||||||
templatePackageVersionId: previousPackage?.id ?? null,
|
templatePackageVersionId: previousPackage.id,
|
||||||
contentChecksum: previousPackage?.contentChecksum ?? null,
|
contentChecksum: previousPackage.contentChecksum,
|
||||||
configSnapshot: previous,
|
configSnapshot: previous,
|
||||||
previousSnapshots: history.slice(0, -1),
|
previousSnapshots: history.slice(0, -1),
|
||||||
},
|
},
|
||||||
@@ -509,7 +549,7 @@ export class TemplateWorkspaceService {
|
|||||||
brandId,
|
brandId,
|
||||||
fromVersionId: installation.templatePackageVersionId,
|
fromVersionId: installation.templatePackageVersionId,
|
||||||
fromVersion: installation.templateVersion,
|
fromVersion: installation.templateVersion,
|
||||||
toVersionId: previousPackage?.id ?? null,
|
toVersionId: previousPackage.id,
|
||||||
toVersion: version,
|
toVersion: version,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -525,28 +565,9 @@ export class TemplateWorkspaceService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function readPackageFiles(
|
async function readPackageFiles(
|
||||||
version: Pick<
|
version: Pick<TemplatePackageVersion, "validationReport">,
|
||||||
TemplatePackageVersion,
|
|
||||||
"artifactPath" | "validationReport" | "packageKey" | "version"
|
|
||||||
>,
|
|
||||||
): Promise<Record<string, unknown>[]> {
|
): Promise<Record<string, unknown>[]> {
|
||||||
const stored = manifestRecords(record(version.validationReport).files);
|
return manifestRecords(record(version.validationReport).files);
|
||||||
if (stored.length) return stored;
|
|
||||||
const root = `${version.packageKey}-${version.version}`;
|
|
||||||
const checksumEntry = `${root}/checksums.json`;
|
|
||||||
if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(version.packageKey) || root.includes("/")) return [];
|
|
||||||
try {
|
|
||||||
const { stdout: entries } = await execFileAsync("tar", ["-tzf", version.artifactPath], {
|
|
||||||
maxBuffer: 4 * 1024 * 1024,
|
|
||||||
});
|
|
||||||
if (!entries.split("\n").some((entry) => entry === checksumEntry)) return [];
|
|
||||||
const { stdout } = await execFileAsync("tar", ["-xOzf", version.artifactPath, checksumEntry], {
|
|
||||||
maxBuffer: 4 * 1024 * 1024,
|
|
||||||
});
|
|
||||||
return manifestRecords(record(JSON.parse(stdout)).files);
|
|
||||||
} catch {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function record(value: unknown): Record<string, unknown> {
|
function record(value: unknown): Record<string, unknown> {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ const expectedRoutes = new Set([
|
|||||||
"GET /admin/workspace/template/preview",
|
"GET /admin/workspace/template/preview",
|
||||||
"POST /admin/workspace/template/upgrade",
|
"POST /admin/workspace/template/upgrade",
|
||||||
"POST /admin/workspace/template/rollback",
|
"POST /admin/workspace/template/rollback",
|
||||||
|
"POST /admin/workspace/template/select-version",
|
||||||
"GET /admin/workspace/capabilities",
|
"GET /admin/workspace/capabilities",
|
||||||
"GET /admin/workspace/sample-content/preview",
|
"GET /admin/workspace/sample-content/preview",
|
||||||
"POST /admin/workspace/sample-content/import",
|
"POST /admin/workspace/sample-content/import",
|
||||||
|
|||||||
@@ -66,11 +66,22 @@ function createTemplateArchive(template = "acheng-campus-food", mutateManifest)
|
|||||||
mutateManifest(manifest);
|
mutateManifest(manifest);
|
||||||
const content = Buffer.from(JSON.stringify(manifest));
|
const content = Buffer.from(JSON.stringify(manifest));
|
||||||
writeFileSync(manifestPath, content);
|
writeFileSync(manifestPath, content);
|
||||||
|
const packageJsonPath = path.join(directory, "package.json");
|
||||||
|
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
|
||||||
|
packageJson.version = manifest.version;
|
||||||
|
const packageContent = Buffer.from(JSON.stringify(packageJson));
|
||||||
|
writeFileSync(packageJsonPath, packageContent);
|
||||||
const checksumPath = path.join(directory, "checksums.json");
|
const checksumPath = path.join(directory, "checksums.json");
|
||||||
const checksums = JSON.parse(readFileSync(checksumPath, "utf8"));
|
const checksums = JSON.parse(readFileSync(checksumPath, "utf8"));
|
||||||
|
checksums.version = manifest.version;
|
||||||
const entry = checksums.files.find((item) => item.path === "template.json");
|
const entry = checksums.files.find((item) => item.path === "template.json");
|
||||||
entry.bytes = content.length;
|
entry.bytes = content.length;
|
||||||
entry.sha256 = createHash("sha256").update(content).digest("hex");
|
entry.sha256 = createHash("sha256").update(content).digest("hex");
|
||||||
|
const packageEntry = checksums.files.find((item) => item.path === "package.json");
|
||||||
|
if (packageEntry) {
|
||||||
|
packageEntry.bytes = packageContent.length;
|
||||||
|
packageEntry.sha256 = createHash("sha256").update(packageContent).digest("hex");
|
||||||
|
}
|
||||||
const canonicalEntries = checksums.files.map((item) => ({
|
const canonicalEntries = checksums.files.map((item) => ({
|
||||||
bytes: item.bytes,
|
bytes: item.bytes,
|
||||||
path: item.path,
|
path: item.path,
|
||||||
@@ -122,16 +133,30 @@ test("模板目录只允许平台模板管理员访问,并支持安全、幂
|
|||||||
const headers = { authorization: `Bearer ${JSON.parse(login.body).token}` };
|
const headers = { authorization: `Bearer ${JSON.parse(login.body).token}` };
|
||||||
const empty = await request("/admin/templates", { headers });
|
const empty = await request("/admin/templates", { headers });
|
||||||
assert.equal(empty.statusCode, 200);
|
assert.equal(empty.statusCode, 200);
|
||||||
assert.deepEqual(JSON.parse(empty.body).items, []);
|
const baseline = JSON.parse(empty.body);
|
||||||
assert.equal(JSON.parse(empty.body).total, 0);
|
assert.deepEqual(baseline.items.map((item) => item.packageKey).sort(), [
|
||||||
|
"acheng-campus-food",
|
||||||
|
"linjing-editorial",
|
||||||
|
]);
|
||||||
|
const linjingVersion = baseline.items.find((item) => item.packageKey === "linjing-editorial");
|
||||||
|
assert.ok(linjingVersion);
|
||||||
|
assert.equal(linjingVersion.version, "1.0.5");
|
||||||
|
const linjingPreview = await request(
|
||||||
|
`/admin/templates/${linjingVersion.id}/preview?industry=doors`,
|
||||||
|
{ headers },
|
||||||
|
);
|
||||||
|
assert.equal(linjingPreview.statusCode, 200, linjingPreview.body);
|
||||||
|
assert.equal(JSON.parse(linjingPreview.body).compatibility.renderer.key, "linjing-editorial");
|
||||||
|
|
||||||
const archive = createTemplateArchive();
|
const archive = createTemplateArchive("atelier-solopreneur", (manifest) => {
|
||||||
|
manifest.version = "99.0.0";
|
||||||
|
});
|
||||||
const imported = await request("/admin/templates/import", {
|
const imported = await request("/admin/templates/import", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { ...headers, ...multipartArchive(archive).headers },
|
headers: { ...headers, ...multipartArchive(archive).headers },
|
||||||
rawPayload: multipartArchive(archive).payload,
|
rawPayload: multipartArchive(archive).payload,
|
||||||
});
|
});
|
||||||
assert.equal(imported.statusCode, 201);
|
assert.equal(imported.statusCode, 201, imported.body);
|
||||||
assert.equal(JSON.parse(imported.body).imported, true);
|
assert.equal(JSON.parse(imported.body).imported, true);
|
||||||
const repeated = await request("/admin/templates/import", {
|
const repeated = await request("/admin/templates/import", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@@ -142,9 +167,13 @@ test("模板目录只允许平台模板管理员访问,并支持安全、幂
|
|||||||
assert.equal(JSON.parse(repeated.body).idempotent, true);
|
assert.equal(JSON.parse(repeated.body).idempotent, true);
|
||||||
const listed = await request("/admin/templates", { headers });
|
const listed = await request("/admin/templates", { headers });
|
||||||
const listedBody = JSON.parse(listed.body);
|
const listedBody = JSON.parse(listed.body);
|
||||||
assert.equal(listedBody.items.length, 1);
|
assert.equal(listedBody.items.length, baseline.items.length + 1);
|
||||||
assert.equal(listedBody.items[0].status, "imported");
|
const newVersion = listedBody.items.find(
|
||||||
const versionId = listedBody.items[0].id;
|
(item) => item.packageKey === "atelier-solopreneur" && item.version === "99.0.0",
|
||||||
|
);
|
||||||
|
assert.ok(newVersion);
|
||||||
|
assert.equal(newVersion.status, "imported");
|
||||||
|
const versionId = newVersion.id;
|
||||||
const importedVersion = await prisma.templatePackageVersion.findUniqueOrThrow({
|
const importedVersion = await prisma.templatePackageVersion.findUniqueOrThrow({
|
||||||
where: { id: versionId },
|
where: { id: versionId },
|
||||||
});
|
});
|
||||||
@@ -349,7 +378,7 @@ test("平台模板管理员可以按行业预览版本,且预览不写入品
|
|||||||
assert.match(body.workspace.brand.id, /^template-preview:/);
|
assert.match(body.workspace.brand.id, /^template-preview:/);
|
||||||
assert.equal(body.workspace.offerings.length > 0, true);
|
assert.equal(body.workspace.offerings.length > 0, true);
|
||||||
assert.equal(body.workspace.inquiryForms.length, 1);
|
assert.equal(body.workspace.inquiryForms.length, 1);
|
||||||
assert.equal(body.workspace.brand.config.visualTemplateKey, "atelier-solopreneur");
|
assert.equal(Object.hasOwn(body.workspace.brand.config ?? {}, "visualTemplateKey"), false);
|
||||||
assert.equal(body.template.pages.includes("profile"), true);
|
assert.equal(body.template.pages.includes("profile"), true);
|
||||||
assert.equal(body.template.pages.includes("inquiry"), true);
|
assert.equal(body.template.pages.includes("inquiry"), true);
|
||||||
assert.equal(body.preview.fixtureSource, "previewFixture");
|
assert.equal(body.preview.fixtureSource, "previewFixture");
|
||||||
@@ -483,10 +512,10 @@ test("平台模板管理员可以按行业预览版本,且预览不写入品
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
/所属行业/,
|
/所属行业|must match its key/,
|
||||||
],
|
],
|
||||||
[{ ...stored.manifestSnapshot, requiredCapabilities: ["unknown"] }, /未注册的 capability/],
|
[{ ...stored.manifestSnapshot, requiredCapabilities: ["unknown"] }, /未注册的 capability/],
|
||||||
[{ ...stored.manifestSnapshot, visualTemplateKey: "unknown" }, /renderer/],
|
[{ ...stored.manifestSnapshot, visualTemplateKey: "unknown" }, /元数据/],
|
||||||
[{ ...stored.manifestSnapshot, runtimeContract: "9.0" }, /契约/],
|
[{ ...stored.manifestSnapshot, runtimeContract: "9.0" }, /契约/],
|
||||||
[{ ...stored.manifestSnapshot, dataSlots: [null] }, /契约/],
|
[{ ...stored.manifestSnapshot, dataSlots: [null] }, /契约/],
|
||||||
[{ ...stored.manifestSnapshot, navigation: [null] }, /契约/],
|
[{ ...stored.manifestSnapshot, navigation: [null] }, /契约/],
|
||||||
@@ -508,7 +537,7 @@ test("平台模板管理员可以按行业预览版本,且预览不写入品
|
|||||||
where: { id: versionId },
|
where: { id: versionId },
|
||||||
data: { archiveChecksum: stored.archiveChecksum },
|
data: { archiveChecksum: stored.archiveChecksum },
|
||||||
});
|
});
|
||||||
// 独立演示内容不依赖 bootstrap;旧包则显式标明兼容来源。
|
// 独立演示内容不依赖 bootstrap sampleContent。
|
||||||
await prisma.templatePackageVersion.update({
|
await prisma.templatePackageVersion.update({
|
||||||
where: { id: versionId },
|
where: { id: versionId },
|
||||||
data: { manifestSnapshot: { ...stored.manifestSnapshot, sampleContent: {} } },
|
data: { manifestSnapshot: { ...stored.manifestSnapshot, sampleContent: {} } },
|
||||||
@@ -527,9 +556,8 @@ test("平台模板管理员可以按行业预览版本,且预览不写入品
|
|||||||
const legacy = await request(`/admin/templates/${versionId}/preview?industry=personal`, {
|
const legacy = await request(`/admin/templates/${versionId}/preview?industry=personal`, {
|
||||||
headers,
|
headers,
|
||||||
});
|
});
|
||||||
assert.equal(legacy.statusCode, 200, legacy.body);
|
assert.equal(legacy.statusCode, 400, legacy.body);
|
||||||
assert.equal(JSON.parse(legacy.body).preview.fixtureSource, "legacy-sampleContent");
|
assert.match(JSON.parse(legacy.body).error.message, /previewFixture/);
|
||||||
assert.equal(JSON.parse(legacy.body).preview.diagnostics[0].code, "LEGACY_PREVIEW_SAMPLE");
|
|
||||||
for (const [manifestSnapshot, reason] of failures) {
|
for (const [manifestSnapshot, reason] of failures) {
|
||||||
await prisma.templatePackageVersion.update({
|
await prisma.templatePackageVersion.update({
|
||||||
where: { id: versionId },
|
where: { id: versionId },
|
||||||
@@ -1848,7 +1876,7 @@ test("health and public content are available without authentication", async ()
|
|||||||
assert.equal(missingSlug.statusCode, 404);
|
assert.equal(missingSlug.statusCode, 404);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("visual template compatibility is enforced by catalog, preview, and brand switching", async () => {
|
test("visual template compatibility is enforced by catalog, preview, and version selection", async () => {
|
||||||
const catalog = await request("/public/templates");
|
const catalog = await request("/public/templates");
|
||||||
assert.equal(catalog.statusCode, 200);
|
assert.equal(catalog.statusCode, 200);
|
||||||
const visuals = JSON.parse(catalog.body).visuals;
|
const visuals = JSON.parse(catalog.body).visuals;
|
||||||
@@ -1875,12 +1903,20 @@ test("visual template compatibility is enforced by catalog, preview, and brand s
|
|||||||
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
||||||
});
|
});
|
||||||
const token = JSON.parse(login.body).data?.token ?? JSON.parse(login.body).token;
|
const token = JSON.parse(login.body).data?.token ?? JSON.parse(login.body).token;
|
||||||
const compatibleSwitch = await request("/admin/config/brand", {
|
const installation = await prisma.brandTemplateInstallation.findUniqueOrThrow({
|
||||||
method: "PATCH",
|
where: { brandId },
|
||||||
headers: { authorization: `Bearer ${token}` },
|
|
||||||
payload: { config: { visualTemplateKey: "acheng-campus-food" } },
|
|
||||||
});
|
});
|
||||||
assert.equal(compatibleSwitch.statusCode, 200);
|
const compatibleSwitch = await request("/admin/workspace/template/select-version", {
|
||||||
|
method: "POST",
|
||||||
|
headers: { authorization: `Bearer ${token}` },
|
||||||
|
payload: {
|
||||||
|
templatePackageVersionId: installation.templatePackageVersionId,
|
||||||
|
expectedCurrentPackageVersionId: installation.templatePackageVersionId,
|
||||||
|
confirm: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
assert.equal(compatibleSwitch.statusCode, 201);
|
||||||
|
assert.equal(JSON.parse(compatibleSwitch.body).unchanged, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("industry template state has a single source of truth", async () => {
|
test("industry template state has a single source of truth", async () => {
|
||||||
@@ -1890,11 +1926,16 @@ test("industry template state has a single source of truth", async () => {
|
|||||||
});
|
});
|
||||||
assert.ok(brand);
|
assert.ok(brand);
|
||||||
const templateKey = brand.templateKey;
|
const templateKey = brand.templateKey;
|
||||||
const visualTemplateKey = brand.config?.visualTemplateKey;
|
assert.equal(Object.hasOwn(brand.config ?? {}, "visualTemplateKey"), false);
|
||||||
const installationBefore = await prisma.brandTemplateInstallation.findFirst({
|
const installation = await prisma.brandTemplateInstallation.findUnique({
|
||||||
where: { brandId },
|
where: { brandId },
|
||||||
});
|
});
|
||||||
const fieldsBefore = await prisma.brandFieldDefinition.findMany({ where: { brandId } });
|
assert.ok(installation?.templatePackageVersionId);
|
||||||
|
const packageVersion = await prisma.templatePackageVersion.findUniqueOrThrow({
|
||||||
|
where: { id: installation.templatePackageVersionId },
|
||||||
|
});
|
||||||
|
assert.equal(packageVersion.version, installation.templateVersion);
|
||||||
|
assert.equal(packageVersion.packageKey, installation.configSnapshot.packageKey);
|
||||||
|
|
||||||
const unauthorized = await request("/admin/workspace/template/preview");
|
const unauthorized = await request("/admin/workspace/template/preview");
|
||||||
assert.equal(unauthorized.statusCode, 401);
|
assert.equal(unauthorized.statusCode, 401);
|
||||||
@@ -1912,22 +1953,24 @@ test("industry template state has a single source of truth", async () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 品牌身份来自 BrandProfile.templateKey;即使版本台账缺失,预览也必须可用而不是 400。
|
|
||||||
const preview = await request("/admin/workspace/template/preview", { headers });
|
const preview = await request("/admin/workspace/template/preview", { headers });
|
||||||
assert.equal(preview.statusCode, 200);
|
assert.equal(preview.statusCode, 200);
|
||||||
const previewBody = JSON.parse(preview.body);
|
const previewBody = JSON.parse(preview.body);
|
||||||
assert.equal(previewBody.templateKey, templateKey);
|
assert.equal(previewBody.templateKey, templateKey);
|
||||||
assert.equal(previewBody.currentVersion, previewBody.latestVersion);
|
assert.equal(previewBody.currentVersion, previewBody.latestVersion);
|
||||||
assert.equal(previewBody.canUpgrade, false);
|
assert.equal(previewBody.canUpgrade, false);
|
||||||
assert.equal(previewBody.canRollback, Boolean(installationBefore?.previousSnapshots?.length));
|
assert.equal(previewBody.canRollback, Boolean(installation.previousSnapshots?.length));
|
||||||
|
|
||||||
const otherKey = templateKey === "personal" ? "food" : "personal";
|
const otherKey = templateKey === "personal" ? "food" : "personal";
|
||||||
|
|
||||||
// 安装其他行业模板必须被拒绝,且不能改写品牌身份或视觉模板。
|
// 安装其他行业模板必须被拒绝,且不能改写品牌身份或版本引用。
|
||||||
const rejected = await request("/admin/workspace/install", {
|
const rejected = await request("/admin/workspace/install", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers,
|
headers,
|
||||||
payload: { templateKey: otherKey },
|
payload: {
|
||||||
|
templateKey: otherKey,
|
||||||
|
templatePackageVersionId: installation.templatePackageVersionId,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
assert.equal(rejected.statusCode, 400);
|
assert.equal(rejected.statusCode, 400);
|
||||||
assert.match(errorMessage(rejected.body), /更换行业模板不在本版本范围内/);
|
assert.match(errorMessage(rejected.body), /更换行业模板不在本版本范围内/);
|
||||||
@@ -1936,58 +1979,17 @@ test("industry template state has a single source of truth", async () => {
|
|||||||
select: { templateKey: true, config: true },
|
select: { templateKey: true, config: true },
|
||||||
});
|
});
|
||||||
assert.equal(afterRejected.templateKey, templateKey);
|
assert.equal(afterRejected.templateKey, templateKey);
|
||||||
assert.equal(afterRejected.config?.visualTemplateKey, visualTemplateKey);
|
assert.equal(Object.hasOwn(afterRejected.config ?? {}, "visualTemplateKey"), false);
|
||||||
|
|
||||||
// 台账已存在时重复安装当前模板应被拒绝。
|
const repeated = await request("/admin/workspace/install", {
|
||||||
if (installationBefore) {
|
method: "POST",
|
||||||
const repeated = await request("/admin/workspace/install", {
|
headers,
|
||||||
method: "POST",
|
payload: { templateKey, templatePackageVersionId: installation.templatePackageVersionId },
|
||||||
headers,
|
|
||||||
payload: { templateKey },
|
|
||||||
});
|
|
||||||
assert.equal(repeated.statusCode, 400);
|
|
||||||
assert.match(errorMessage(repeated.body), /已经安装/);
|
|
||||||
|
|
||||||
// 缺失的版本台账可以由安装补齐,且不改动品牌身份与视觉模板。
|
|
||||||
await prisma.brandTemplateInstallation.deleteMany({ where: { brandId } });
|
|
||||||
const repaired = await request("/admin/workspace/install", {
|
|
||||||
method: "POST",
|
|
||||||
headers,
|
|
||||||
payload: { templateKey },
|
|
||||||
});
|
|
||||||
assert.equal(repaired.statusCode, 201, repaired.body);
|
|
||||||
const installationAfter = await prisma.brandTemplateInstallation.findFirst({
|
|
||||||
where: { brandId },
|
|
||||||
});
|
|
||||||
assert.equal(installationAfter.templateKey, templateKey);
|
|
||||||
const afterRepair = await prisma.brandProfile.findUnique({
|
|
||||||
where: { id: brandId },
|
|
||||||
select: { templateKey: true, config: true },
|
|
||||||
});
|
|
||||||
assert.equal(afterRepair.templateKey, templateKey);
|
|
||||||
assert.equal(afterRepair.config?.visualTemplateKey, visualTemplateKey);
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
const createdFieldIds = (await prisma.brandFieldDefinition.findMany({ where: { brandId } }))
|
|
||||||
.filter((item) => !fieldsBefore.some((current) => current.id === item.id))
|
|
||||||
.map((item) => item.id);
|
|
||||||
if (createdFieldIds.length)
|
|
||||||
await prisma.brandFieldDefinition.deleteMany({ where: { id: { in: createdFieldIds } } });
|
|
||||||
await prisma.brandTemplateInstallation.deleteMany({ where: { brandId } });
|
|
||||||
if (installationBefore) {
|
|
||||||
await prisma.brandTemplateInstallation.create({
|
|
||||||
data: {
|
|
||||||
brandId,
|
|
||||||
templateKey: installationBefore.templateKey,
|
|
||||||
templateVersion: installationBefore.templateVersion,
|
|
||||||
configSnapshot: installationBefore.configSnapshot,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
await prisma.brandProfile.update({
|
|
||||||
where: { id: brandId },
|
|
||||||
data: { templateKey, config: brand.config },
|
|
||||||
});
|
});
|
||||||
|
assert.equal(repeated.statusCode, 400);
|
||||||
|
assert.match(errorMessage(repeated.body), /已经安装/);
|
||||||
|
} finally {
|
||||||
|
await prisma.brandTemplateInstallation.findUniqueOrThrow({ where: { brandId } });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -2158,16 +2160,12 @@ test("editor membership can manage brand content but cannot change system settin
|
|||||||
headers: { authorization: `Bearer ${token}` },
|
headers: { authorization: `Bearer ${token}` },
|
||||||
});
|
});
|
||||||
assert.equal(capabilities.statusCode, 403);
|
assert.equal(capabilities.statusCode, 403);
|
||||||
const visualHistory = await request("/admin/config/visual-template/history", {
|
|
||||||
headers: { authorization: `Bearer ${token}` },
|
|
||||||
});
|
|
||||||
assert.equal(visualHistory.statusCode, 403);
|
|
||||||
const visualUpdate = await request("/admin/config/brand", {
|
const visualUpdate = await request("/admin/config/brand", {
|
||||||
method: "PATCH",
|
method: "PATCH",
|
||||||
headers: { authorization: `Bearer ${token}` },
|
headers: { authorization: `Bearer ${token}` },
|
||||||
payload: { config: { visualTemplateKey: "unknown-visual" } },
|
payload: { config: { visualTemplateKey: "unknown-visual" } },
|
||||||
});
|
});
|
||||||
assert.equal(visualUpdate.statusCode, 403);
|
assert.equal(visualUpdate.statusCode, 400);
|
||||||
} finally {
|
} finally {
|
||||||
await prisma.brandMembership.update({
|
await prisma.brandMembership.update({
|
||||||
where: { id: membership.id },
|
where: { id: membership.id },
|
||||||
@@ -2352,10 +2350,9 @@ test("admin capability list includes template defaults and brand overrides", asy
|
|||||||
|
|
||||||
test("installing another industry template is rejected without drifting brand identity", async () => {
|
test("installing another industry template is rejected without drifting brand identity", async () => {
|
||||||
const originalBrand = await prisma.brandProfile.findUniqueOrThrow({ where: { id: brandId } });
|
const originalBrand = await prisma.brandProfile.findUniqueOrThrow({ where: { id: brandId } });
|
||||||
await prisma.inquirySubmission.deleteMany({ where: { brandId } });
|
const installationBefore = await prisma.brandTemplateInstallation.findUniqueOrThrow({
|
||||||
await prisma.inquiryForm.deleteMany({ where: { brandId } });
|
where: { brandId },
|
||||||
await prisma.brandFieldDefinition.deleteMany({ where: { brandId } });
|
});
|
||||||
await prisma.brandTemplateInstallation.deleteMany({ where: { brandId } });
|
|
||||||
const login = await request("/admin/session/login", {
|
const login = await request("/admin/session/login", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
||||||
@@ -2367,16 +2364,22 @@ test("installing another industry template is rejected without drifting brand id
|
|||||||
const installed = await request("/admin/workspace/install", {
|
const installed = await request("/admin/workspace/install", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers,
|
headers,
|
||||||
payload: { templateKey: "doors" },
|
payload: {
|
||||||
|
templateKey: "doors",
|
||||||
|
templatePackageVersionId: installationBefore.templatePackageVersionId,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
assert.equal(installed.statusCode, 400, installed.body);
|
assert.equal(installed.statusCode, 400, installed.body);
|
||||||
assert.match(errorMessage(installed.body), /更换行业模板不在本版本范围内/);
|
assert.match(errorMessage(installed.body), /更换行业模板不在本版本范围内/);
|
||||||
|
|
||||||
// 拒绝之后不能留下任何漂移:品牌身份、视觉模板、台账都不变。
|
// 拒绝之后品牌身份和 package version 引用保持不变。
|
||||||
const brandAfter = await prisma.brandProfile.findUniqueOrThrow({ where: { id: brandId } });
|
const brandAfter = await prisma.brandProfile.findUniqueOrThrow({ where: { id: brandId } });
|
||||||
assert.equal(brandAfter.templateKey, originalBrand.templateKey);
|
assert.equal(brandAfter.templateKey, originalBrand.templateKey);
|
||||||
assert.deepEqual(brandAfter.config, originalBrand.config);
|
assert.equal(Object.hasOwn(brandAfter.config ?? {}, "visualTemplateKey"), false);
|
||||||
assert.equal(await prisma.brandTemplateInstallation.count({ where: { brandId } }), 0);
|
assert.deepEqual(
|
||||||
|
await prisma.brandTemplateInstallation.findUniqueOrThrow({ where: { brandId } }),
|
||||||
|
installationBefore,
|
||||||
|
);
|
||||||
|
|
||||||
// 公开运行时仍按品牌身份走 food 模板,没有被 doors 污染。
|
// 公开运行时仍按品牌身份走 food 模板,没有被 doors 污染。
|
||||||
const workspace = await request("/public/workspace");
|
const workspace = await request("/public/workspace");
|
||||||
@@ -2389,28 +2392,17 @@ test("installing another industry template is rejected without drifting brand id
|
|||||||
assert.equal(samplePreview.statusCode, 200);
|
assert.equal(samplePreview.statusCode, 200);
|
||||||
assert.equal(JSON.parse(samplePreview.body).templateKey, originalBrand.templateKey);
|
assert.equal(JSON.parse(samplePreview.body).templateKey, originalBrand.templateKey);
|
||||||
} finally {
|
} finally {
|
||||||
await prisma.brandFieldDefinition.deleteMany({ where: { brandId } });
|
assert.equal(
|
||||||
await prisma.brandTemplateInstallation.deleteMany({ where: { brandId } });
|
(await prisma.brandProfile.findUniqueOrThrow({ where: { id: brandId } })).templateKey,
|
||||||
await prisma.brandProfile.update({
|
originalBrand.templateKey,
|
||||||
where: { id: brandId },
|
);
|
||||||
data: { templateKey: originalBrand.templateKey, config: originalBrand.config },
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test("cross template requests are rejected even when a drifted ledger already exists", async () => {
|
test("cross template requests are rejected without creating a drifted installation", async () => {
|
||||||
const originalBrand = await prisma.brandProfile.findUniqueOrThrow({ where: { id: brandId } });
|
const originalBrand = await prisma.brandProfile.findUniqueOrThrow({ where: { id: brandId } });
|
||||||
await prisma.inquirySubmission.deleteMany({ where: { brandId } });
|
const installationBefore = await prisma.brandTemplateInstallation.findUniqueOrThrow({
|
||||||
await prisma.inquiryForm.deleteMany({ where: { brandId } });
|
where: { brandId },
|
||||||
await prisma.brandFieldDefinition.deleteMany({ where: { brandId } });
|
|
||||||
await prisma.brandTemplateInstallation.deleteMany({ where: { brandId } });
|
|
||||||
await prisma.brandTemplateInstallation.create({
|
|
||||||
data: {
|
|
||||||
brandId,
|
|
||||||
templateKey: "doors",
|
|
||||||
templateVersion: "1.0.0",
|
|
||||||
configSnapshot: { schemaVersion: "1.0" },
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
const login = await request("/admin/session/login", {
|
const login = await request("/admin/session/login", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@@ -2423,36 +2415,44 @@ test("cross template requests are rejected even when a drifted ledger already ex
|
|||||||
const rejected = await request("/admin/workspace/install", {
|
const rejected = await request("/admin/workspace/install", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers,
|
headers,
|
||||||
payload: { templateKey: "doors" },
|
payload: {
|
||||||
|
templateKey: "doors",
|
||||||
|
templatePackageVersionId: installationBefore.templatePackageVersionId,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
assert.equal(rejected.statusCode, 400, rejected.body);
|
assert.equal(rejected.statusCode, 400, rejected.body);
|
||||||
assert.match(errorMessage(rejected.body), /更换行业模板不在本版本范围内/);
|
assert.match(errorMessage(rejected.body), /更换行业模板不在本版本范围内/);
|
||||||
|
|
||||||
const brandAfter = await prisma.brandProfile.findUniqueOrThrow({ where: { id: brandId } });
|
const brandAfter = await prisma.brandProfile.findUniqueOrThrow({ where: { id: brandId } });
|
||||||
assert.equal(brandAfter.templateKey, originalBrand.templateKey);
|
assert.equal(brandAfter.templateKey, originalBrand.templateKey);
|
||||||
assert.equal(await prisma.brandTemplateInstallation.count({ where: { brandId } }), 1);
|
assert.deepEqual(
|
||||||
|
await prisma.brandTemplateInstallation.findUniqueOrThrow({ where: { brandId } }),
|
||||||
|
installationBefore,
|
||||||
|
);
|
||||||
|
|
||||||
const workspace = await request("/public/workspace");
|
const workspace = await request("/public/workspace");
|
||||||
assert.equal(workspace.statusCode, 200);
|
assert.equal(workspace.statusCode, 200);
|
||||||
assert.equal(JSON.parse(workspace.body).template.key, originalBrand.templateKey);
|
assert.equal(JSON.parse(workspace.body).template.key, originalBrand.templateKey);
|
||||||
} finally {
|
} finally {
|
||||||
await prisma.brandFieldDefinition.deleteMany({ where: { brandId } });
|
assert.equal(
|
||||||
await prisma.brandTemplateInstallation.deleteMany({ where: { brandId } });
|
(await prisma.brandProfile.findUniqueOrThrow({ where: { id: brandId } })).templateKey,
|
||||||
await prisma.brandProfile.update({
|
originalBrand.templateKey,
|
||||||
where: { id: brandId },
|
);
|
||||||
data: { templateKey: originalBrand.templateKey, config: originalBrand.config },
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test("admin can preview and import sample content idempotently", async () => {
|
test("admin can preview and import sample content idempotently", async () => {
|
||||||
const originalBrand = await prisma.brandProfile.findUnique({ where: { id: brandId } });
|
const originalBrand = await prisma.brandProfile.findUnique({ where: { id: brandId } });
|
||||||
|
const originalInstallation = await prisma.brandTemplateInstallation.findUniqueOrThrow({
|
||||||
|
where: { brandId },
|
||||||
|
});
|
||||||
const originalForms = await prisma.inquiryForm.findMany({ where: { brandId } });
|
const originalForms = await prisma.inquiryForm.findMany({ where: { brandId } });
|
||||||
const originalSampleTrust = await prisma.trustContent.findMany({
|
const originalSampleTrust = await prisma.trustContent.findMany({
|
||||||
where: { brandId, content: "示例内容,待品牌主理人完善。" },
|
where: { brandId, content: "示例内容,待品牌主理人完善。" },
|
||||||
});
|
});
|
||||||
await prisma.brandProfile.update({ where: { id: brandId }, data: { templateKey: "doors" } });
|
assert.equal(originalBrand?.templateKey, "food");
|
||||||
await prisma.brandTemplateInstallation.deleteMany({ where: { brandId } });
|
const packageVersionId = originalInstallation.templatePackageVersionId;
|
||||||
|
assert.ok(packageVersionId);
|
||||||
await prisma.offering.deleteMany({
|
await prisma.offering.deleteMany({
|
||||||
where: {
|
where: {
|
||||||
brandId,
|
brandId,
|
||||||
@@ -2463,53 +2463,23 @@ test("admin can preview and import sample content idempotently", async () => {
|
|||||||
where: { brandId, content: "示例内容,待品牌主理人完善。" },
|
where: { brandId, content: "示例内容,待品牌主理人完善。" },
|
||||||
});
|
});
|
||||||
await prisma.brandFieldDefinition.deleteMany({ where: { brandId, source: "sample" } });
|
await prisma.brandFieldDefinition.deleteMany({ where: { brandId, source: "sample" } });
|
||||||
if (!originalForms.some((item) => item.isEnabled)) {
|
await prisma.inquiryForm.create({
|
||||||
await prisma.inquiryForm.create({
|
data: {
|
||||||
data: {
|
brandId,
|
||||||
brandId,
|
name: "现有客户表单",
|
||||||
name: "现有客户表单",
|
fieldsSnapshot: [{ key: "phone", label: "联系电话", type: "tel", required: true }],
|
||||||
fieldsSnapshot: [{ key: "phone", label: "联系电话", type: "tel", required: true }],
|
},
|
||||||
},
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
const login = await request("/admin/session/login", {
|
const login = await request("/admin/session/login", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
||||||
});
|
});
|
||||||
const token = JSON.parse(login.body).data?.token ?? JSON.parse(login.body).token;
|
const token = JSON.parse(login.body).data?.token ?? JSON.parse(login.body).token;
|
||||||
const headers = { authorization: `Bearer ${token}` };
|
const headers = { authorization: `Bearer ${token}` };
|
||||||
const archive = createTemplateArchive("acheng-campus-food");
|
const preview = await request(
|
||||||
const uploaded = multipartArchive(archive);
|
`/admin/workspace/sample-content/preview?templatePackageVersionId=${packageVersionId}`,
|
||||||
const importedPackage = await request("/admin/templates/import", {
|
{ headers },
|
||||||
method: "POST",
|
);
|
||||||
headers: { ...headers, ...uploaded.headers },
|
|
||||||
rawPayload: uploaded.payload,
|
|
||||||
});
|
|
||||||
assert.equal(importedPackage.statusCode, 201, importedPackage.body);
|
|
||||||
const packageVersionId = JSON.parse(importedPackage.body).version.id;
|
|
||||||
const publishedPackage = await request(`/admin/templates/${packageVersionId}/publish`, {
|
|
||||||
method: "POST",
|
|
||||||
headers,
|
|
||||||
});
|
|
||||||
assert.equal(publishedPackage.statusCode, 201, publishedPackage.body);
|
|
||||||
await prisma.brandProfile.update({
|
|
||||||
where: { id: brandId },
|
|
||||||
data: { templateKey: "food", config: { visualTemplateKey: "acheng-campus-food" } },
|
|
||||||
});
|
|
||||||
await prisma.brandTemplateInstallation.create({
|
|
||||||
data: {
|
|
||||||
brandId,
|
|
||||||
templateKey: "food",
|
|
||||||
visualTemplateKey: "acheng-campus-food",
|
|
||||||
templatePackageVersionId: packageVersionId,
|
|
||||||
contentChecksum: JSON.parse(importedPackage.body).version.contentChecksum,
|
|
||||||
templateVersion: JSON.parse(importedPackage.body).version.version,
|
|
||||||
configSnapshot: { schemaVersion: "1.0" },
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const preview = await request("/admin/workspace/sample-content/preview", {
|
|
||||||
headers,
|
|
||||||
});
|
|
||||||
assert.equal(preview.statusCode, 200);
|
assert.equal(preview.statusCode, 200);
|
||||||
assert.equal(JSON.parse(preview.body).source.templatePackageVersionId, packageVersionId);
|
assert.equal(JSON.parse(preview.body).source.templatePackageVersionId, packageVersionId);
|
||||||
assert.equal(JSON.parse(preview.body).source.kind, "package_version");
|
assert.equal(JSON.parse(preview.body).source.kind, "package_version");
|
||||||
@@ -2566,6 +2536,7 @@ test("admin can preview and import sample content idempotently", async () => {
|
|||||||
}
|
}
|
||||||
await prisma.brandFieldDefinition.deleteMany({ where: { brandId, source: "sample" } });
|
await prisma.brandFieldDefinition.deleteMany({ where: { brandId, source: "sample" } });
|
||||||
await prisma.inquiryForm.deleteMany({ where: { brandId, name: "门系统咨询表单" } });
|
await prisma.inquiryForm.deleteMany({ where: { brandId, name: "门系统咨询表单" } });
|
||||||
|
await prisma.inquiryForm.deleteMany({ where: { brandId, name: "现有客户表单" } });
|
||||||
if (originalForms.length) {
|
if (originalForms.length) {
|
||||||
await prisma.inquiryForm.createMany({
|
await prisma.inquiryForm.createMany({
|
||||||
data: originalForms.map(
|
data: originalForms.map(
|
||||||
@@ -2575,12 +2546,10 @@ test("admin can preview and import sample content idempotently", async () => {
|
|||||||
}
|
}
|
||||||
await prisma.capabilityAuditLog.deleteMany({ where: { brandId, capabilityKey: "doors" } });
|
await prisma.capabilityAuditLog.deleteMany({ where: { brandId, capabilityKey: "doors" } });
|
||||||
await prisma.templateBootstrapImport.deleteMany({ where: { brandId } });
|
await prisma.templateBootstrapImport.deleteMany({ where: { brandId } });
|
||||||
await prisma.brandTemplateInstallation.deleteMany({ where: { brandId } });
|
assert.deepEqual(
|
||||||
await prisma.templatePackageAuditLog.deleteMany({
|
await prisma.brandTemplateInstallation.findUniqueOrThrow({ where: { brandId } }),
|
||||||
where: { templatePackageVersionId: packageVersionId },
|
originalInstallation,
|
||||||
});
|
);
|
||||||
await prisma.templatePackageVersion.delete({ where: { id: packageVersionId } });
|
|
||||||
await prisma.templatePackage.deleteMany({ where: { packageKey: "acheng-campus-food" } });
|
|
||||||
await prisma.brandProfile.update({
|
await prisma.brandProfile.update({
|
||||||
where: { id: brandId },
|
where: { id: brandId },
|
||||||
data: { templateKey: originalBrand?.templateKey ?? "food", config: originalBrand?.config },
|
data: { templateKey: originalBrand?.templateKey ?? "food", config: originalBrand?.config },
|
||||||
@@ -2588,6 +2557,9 @@ test("admin can preview and import sample content idempotently", async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("template ledger install, upgrade preview, and rollback stay brand-scoped", async () => {
|
test("template ledger install, upgrade preview, and rollback stay brand-scoped", async () => {
|
||||||
|
const originalInstallation = await prisma.brandTemplateInstallation.findUniqueOrThrow({
|
||||||
|
where: { brandId },
|
||||||
|
});
|
||||||
await prisma.inquirySubmission.deleteMany({ where: { brandId } });
|
await prisma.inquirySubmission.deleteMany({ where: { brandId } });
|
||||||
await prisma.inquiryForm.deleteMany({ where: { brandId } });
|
await prisma.inquiryForm.deleteMany({ where: { brandId } });
|
||||||
await prisma.brandFieldDefinition.deleteMany({ where: { brandId } });
|
await prisma.brandFieldDefinition.deleteMany({ where: { brandId } });
|
||||||
@@ -2611,13 +2583,19 @@ test("template ledger install, upgrade preview, and rollback stay brand-scoped",
|
|||||||
const crossTemplate = await request("/admin/workspace/install", {
|
const crossTemplate = await request("/admin/workspace/install", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { authorization: `Bearer ${token}` },
|
headers: { authorization: `Bearer ${token}` },
|
||||||
payload: { templateKey: currentTemplateKey === "personal" ? "food" : "personal" },
|
payload: {
|
||||||
|
templateKey: currentTemplateKey === "personal" ? "food" : "personal",
|
||||||
|
templatePackageVersionId: originalInstallation.templatePackageVersionId,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
assert.equal(crossTemplate.statusCode, 400, crossTemplate.body);
|
assert.equal(crossTemplate.statusCode, 400, crossTemplate.body);
|
||||||
const installed = await request("/admin/workspace/install", {
|
const installed = await request("/admin/workspace/install", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { authorization: `Bearer ${token}` },
|
headers: { authorization: `Bearer ${token}` },
|
||||||
payload: { templateKey: currentTemplateKey },
|
payload: {
|
||||||
|
templateKey: currentTemplateKey,
|
||||||
|
templatePackageVersionId: originalInstallation.templatePackageVersionId,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
assert.equal(installed.statusCode, 201, installed.body);
|
assert.equal(installed.statusCode, 201, installed.body);
|
||||||
assert.equal(JSON.parse(installed.body).template.key, currentTemplateKey);
|
assert.equal(JSON.parse(installed.body).template.key, currentTemplateKey);
|
||||||
@@ -2627,7 +2605,10 @@ test("template ledger install, upgrade preview, and rollback stay brand-scoped",
|
|||||||
),
|
),
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
assert.equal(JSON.parse(installed.body).installation.configSnapshot.schemaVersion, "1.0");
|
assert.equal(
|
||||||
|
JSON.parse(installed.body).installation.configSnapshot.packageKey,
|
||||||
|
originalInstallation.configSnapshot.packageKey,
|
||||||
|
);
|
||||||
const installedRecord = JSON.parse(installed.body).installation;
|
const installedRecord = JSON.parse(installed.body).installation;
|
||||||
const createdVersionIds = [];
|
const createdVersionIds = [];
|
||||||
let historicalReleaseId;
|
let historicalReleaseId;
|
||||||
@@ -2681,7 +2662,10 @@ test("template ledger install, upgrade preview, and rollback stay brand-scoped",
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
historicalSubmissionId = historicalSubmission.id;
|
historicalSubmissionId = historicalSubmission.id;
|
||||||
const packageKey = installedRecord.visualTemplateKey;
|
const installedPackageVersion = await prisma.templatePackageVersion.findUniqueOrThrow({
|
||||||
|
where: { id: originalInstallation.templatePackageVersionId },
|
||||||
|
});
|
||||||
|
const packageKey = installedPackageVersion.packageKey;
|
||||||
const packageVersion = `9.${Date.now()}.0`;
|
const packageVersion = `9.${Date.now()}.0`;
|
||||||
const initialPackageVersion = "1.0.0-phase6-test";
|
const initialPackageVersion = "1.0.0-phase6-test";
|
||||||
const templatePackage = await prisma.templatePackage.upsert({
|
const templatePackage = await prisma.templatePackage.upsert({
|
||||||
@@ -2689,23 +2673,22 @@ test("template ledger install, upgrade preview, and rollback stay brand-scoped",
|
|||||||
create: { packageKey },
|
create: { packageKey },
|
||||||
update: {},
|
update: {},
|
||||||
});
|
});
|
||||||
|
const initialManifest = structuredClone(installedPackageVersion.manifestSnapshot);
|
||||||
|
initialManifest.version = initialPackageVersion;
|
||||||
|
initialManifest.templateFields = [
|
||||||
|
{ key: "founder", binding: "brand.config.founder", label: "主理人" },
|
||||||
|
];
|
||||||
|
initialManifest.entrypoints = { home: "pages/index/index" };
|
||||||
|
initialManifest.assetSlots = [{ key: "brand.logo", binding: "brand.avatarUrl" }];
|
||||||
|
initialManifest.requiredCapabilities = ["offerings"];
|
||||||
const initialPackageVersionRecord = await prisma.templatePackageVersion.create({
|
const initialPackageVersionRecord = await prisma.templatePackageVersion.create({
|
||||||
data: {
|
data: {
|
||||||
templatePackageId: templatePackage.id,
|
templatePackageId: templatePackage.id,
|
||||||
packageKey,
|
packageKey,
|
||||||
version: initialPackageVersion,
|
version: initialPackageVersion,
|
||||||
displayName: "集成测试基线包",
|
displayName: "集成测试基线包",
|
||||||
visualTemplateKey: packageKey,
|
|
||||||
status: "published",
|
status: "published",
|
||||||
manifestSnapshot: {
|
manifestSnapshot: initialManifest,
|
||||||
packageKey,
|
|
||||||
version: initialPackageVersion,
|
|
||||||
supportedIndustryTemplates: [currentTemplateKey],
|
|
||||||
requiredCapabilities: ["offerings"],
|
|
||||||
templateFields: [{ key: "founder", binding: "brand.config.founder", label: "主理人" }],
|
|
||||||
entrypoints: { home: "pages/index/index" },
|
|
||||||
assetSlots: [{ key: "brand.logo", binding: "brand.avatarUrl" }],
|
|
||||||
},
|
|
||||||
validationReport: {},
|
validationReport: {},
|
||||||
contentChecksum: `checksum-${initialPackageVersion}`,
|
contentChecksum: `checksum-${initialPackageVersion}`,
|
||||||
archiveChecksum: `archive-${initialPackageVersion}`,
|
archiveChecksum: `archive-${initialPackageVersion}`,
|
||||||
@@ -2730,28 +2713,28 @@ test("template ledger install, upgrade preview, and rollback stay brand-scoped",
|
|||||||
configSnapshot: initialPackageVersionRecord.manifestSnapshot,
|
configSnapshot: initialPackageVersionRecord.manifestSnapshot,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
const targetManifest = structuredClone(initialManifest);
|
||||||
|
targetManifest.version = packageVersion;
|
||||||
|
targetManifest.templateFields = [
|
||||||
|
{ key: "founder", binding: "brand.config.founder", label: "品牌主理人" },
|
||||||
|
];
|
||||||
|
targetManifest.entrypoints = {
|
||||||
|
home: "pages/home/index",
|
||||||
|
profile: "pages/profile/index",
|
||||||
|
};
|
||||||
|
targetManifest.assetSlots = [
|
||||||
|
{ key: "brand.logo", binding: "brand.avatarUrl" },
|
||||||
|
{ key: "home.hero", binding: "brand.config.heroImage" },
|
||||||
|
];
|
||||||
|
targetManifest.requiredCapabilities = [];
|
||||||
const packageVersionRecord = await prisma.templatePackageVersion.create({
|
const packageVersionRecord = await prisma.templatePackageVersion.create({
|
||||||
data: {
|
data: {
|
||||||
templatePackageId: templatePackage.id,
|
templatePackageId: templatePackage.id,
|
||||||
packageKey,
|
packageKey,
|
||||||
version: packageVersion,
|
version: packageVersion,
|
||||||
displayName: "集成测试升级包",
|
displayName: "集成测试升级包",
|
||||||
visualTemplateKey: packageKey,
|
|
||||||
status: "published",
|
status: "published",
|
||||||
manifestSnapshot: {
|
manifestSnapshot: targetManifest,
|
||||||
packageKey,
|
|
||||||
version: packageVersion,
|
|
||||||
supportedIndustryTemplates: [currentTemplateKey],
|
|
||||||
requiredCapabilities: [],
|
|
||||||
templateFields: [
|
|
||||||
{ key: "founder", binding: "brand.config.founder", label: "品牌主理人" },
|
|
||||||
],
|
|
||||||
entrypoints: { home: "pages/home/index", profile: "pages/profile/index" },
|
|
||||||
assetSlots: [
|
|
||||||
{ key: "brand.logo", binding: "brand.avatarUrl" },
|
|
||||||
{ key: "home.hero", binding: "brand.config.heroImage" },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
validationReport: {},
|
validationReport: {},
|
||||||
contentChecksum: `checksum-${packageVersion}`,
|
contentChecksum: `checksum-${packageVersion}`,
|
||||||
archiveChecksum: `archive-${packageVersion}`,
|
archiveChecksum: `archive-${packageVersion}`,
|
||||||
@@ -2913,7 +2896,6 @@ test("template ledger install, upgrade preview, and rollback stay brand-scoped",
|
|||||||
assert.equal(operationAudit[0].metadata.brandId, brandId);
|
assert.equal(operationAudit[0].metadata.brandId, brandId);
|
||||||
assert.equal(operationAudit[0].metadata.contentChecksum, packageVersionRecord.contentChecksum);
|
assert.equal(operationAudit[0].metadata.contentChecksum, packageVersionRecord.contentChecksum);
|
||||||
assert.ok(operationAudit[0].requestId);
|
assert.ok(operationAudit[0].requestId);
|
||||||
await prisma.templatePackageVersion.deleteMany({ where: { id: { in: createdVersionIds } } });
|
|
||||||
const workspace = await request("/admin/workspace", {
|
const workspace = await request("/admin/workspace", {
|
||||||
headers: { authorization: `Bearer ${token}` },
|
headers: { authorization: `Bearer ${token}` },
|
||||||
});
|
});
|
||||||
@@ -2964,6 +2946,17 @@ test("template ledger install, upgrade preview, and rollback stay brand-scoped",
|
|||||||
await prisma.brandFieldDefinition.deleteMany({ where: { brandId } });
|
await prisma.brandFieldDefinition.deleteMany({ where: { brandId } });
|
||||||
await prisma.brandTemplateInstallation.deleteMany({ where: { brandId } });
|
await prisma.brandTemplateInstallation.deleteMany({ where: { brandId } });
|
||||||
await prisma.templatePackageVersion.deleteMany({ where: { id: { in: createdVersionIds } } });
|
await prisma.templatePackageVersion.deleteMany({ where: { id: { in: createdVersionIds } } });
|
||||||
|
await prisma.brandTemplateInstallation.create({
|
||||||
|
data: {
|
||||||
|
brandId,
|
||||||
|
templateKey: originalInstallation.templateKey,
|
||||||
|
templateVersion: originalInstallation.templateVersion,
|
||||||
|
templatePackageVersionId: originalInstallation.templatePackageVersionId,
|
||||||
|
contentChecksum: originalInstallation.contentChecksum,
|
||||||
|
configSnapshot: originalInstallation.configSnapshot,
|
||||||
|
previousSnapshots: originalInstallation.previousSnapshots,
|
||||||
|
},
|
||||||
|
});
|
||||||
await prisma.brandProfile.update({
|
await prisma.brandProfile.update({
|
||||||
where: { id: brandId },
|
where: { id: brandId },
|
||||||
data: { templateKey: originalBrand.templateKey, config: originalBrand.config },
|
data: { templateKey: originalBrand.templateKey, config: originalBrand.config },
|
||||||
@@ -2994,13 +2987,12 @@ test("admin preview workspace is authorized and brand-scoped draft runtime", asy
|
|||||||
workspace.brand.slug,
|
workspace.brand.slug,
|
||||||
(await prisma.brandProfile.findUniqueOrThrow({ where: { id: brandId } })).slug,
|
(await prisma.brandProfile.findUniqueOrThrow({ where: { id: brandId } })).slug,
|
||||||
);
|
);
|
||||||
assert.equal(workspace.brand.visualTemplateKey, "acheng-campus-food");
|
assert.equal(workspace.visualTemplate.key, "acheng-campus-food");
|
||||||
const unpublishedBrand = await prisma.brandProfile.create({
|
const unpublishedBrand = await prisma.brandProfile.create({
|
||||||
data: {
|
data: {
|
||||||
slug: "unpublished-preview-fixture",
|
slug: "unpublished-preview-fixture",
|
||||||
name: "未发布预览品牌",
|
name: "未发布预览品牌",
|
||||||
templateKey: "personal",
|
templateKey: "personal",
|
||||||
config: { visualTemplateKey: "linjing-editorial" },
|
|
||||||
adminMemberships: { create: { adminUserId: user.id, role: "owner" } },
|
adminMemberships: { create: { adminUserId: user.id, role: "owner" } },
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -3013,9 +3005,7 @@ test("admin preview workspace is authorized and brand-scoped draft runtime", asy
|
|||||||
const draft = await request("/admin/workspace/preview", {
|
const draft = await request("/admin/workspace/preview", {
|
||||||
headers: { authorization: `Bearer ${draftToken}` },
|
headers: { authorization: `Bearer ${draftToken}` },
|
||||||
});
|
});
|
||||||
assert.equal(draft.statusCode, 200);
|
assert.equal(draft.statusCode, 400);
|
||||||
assert.equal(JSON.parse(draft.body).brand.slug, unpublishedBrand.slug);
|
|
||||||
assert.equal(JSON.parse(draft.body).publication.status, "draft");
|
|
||||||
const publicResult = await request("/public/workspace?brandSlug=" + unpublishedBrand.slug);
|
const publicResult = await request("/public/workspace?brandSlug=" + unpublishedBrand.slug);
|
||||||
assert.equal(JSON.parse(publicResult.body).publication.status, "unpublished");
|
assert.equal(JSON.parse(publicResult.body).publication.status, "unpublished");
|
||||||
assert.equal(JSON.parse(publicResult.body).brand, null);
|
assert.equal(JSON.parse(publicResult.body).brand, null);
|
||||||
@@ -3026,18 +3016,11 @@ test("admin preview workspace is authorized and brand-scoped draft runtime", asy
|
|||||||
|
|
||||||
test("admin can customize workspace fields with brand isolation", async () => {
|
test("admin can customize workspace fields with brand isolation", async () => {
|
||||||
await prisma.brandFieldDefinition.deleteMany({ where: { brandId } });
|
await prisma.brandFieldDefinition.deleteMany({ where: { brandId } });
|
||||||
await prisma.brandTemplateInstallation.deleteMany({ where: { brandId } });
|
|
||||||
const login = await request("/admin/session/login", {
|
const login = await request("/admin/session/login", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
||||||
});
|
});
|
||||||
const token = JSON.parse(login.body).data?.token ?? JSON.parse(login.body).token;
|
const token = JSON.parse(login.body).data?.token ?? JSON.parse(login.body).token;
|
||||||
const install = await request("/admin/workspace/install", {
|
|
||||||
method: "POST",
|
|
||||||
headers: { authorization: `Bearer ${token}` },
|
|
||||||
payload: { templateKey: "food" },
|
|
||||||
});
|
|
||||||
assert.equal(install.statusCode, 201);
|
|
||||||
const workspace = await request("/admin/workspace", {
|
const workspace = await request("/admin/workspace", {
|
||||||
headers: { authorization: `Bearer ${token}` },
|
headers: { authorization: `Bearer ${token}` },
|
||||||
});
|
});
|
||||||
@@ -3074,45 +3057,37 @@ test("admin can customize workspace fields with brand isolation", async () => {
|
|||||||
assert.equal(deletedField.statusCode, 200);
|
assert.equal(deletedField.statusCode, 200);
|
||||||
} finally {
|
} finally {
|
||||||
await prisma.brandFieldDefinition.deleteMany({ where: { brandId } });
|
await prisma.brandFieldDefinition.deleteMany({ where: { brandId } });
|
||||||
await prisma.brandTemplateInstallation.deleteMany({ where: { brandId } });
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test("admin visual template selection is reflected in public runtime workspace", async () => {
|
test("selected package version is reflected in public runtime workspace", async () => {
|
||||||
const login = await request("/admin/session/login", {
|
const login = await request("/admin/session/login", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
||||||
});
|
});
|
||||||
const token = JSON.parse(login.body).data?.token ?? JSON.parse(login.body).token;
|
const token = JSON.parse(login.body).data?.token ?? JSON.parse(login.body).token;
|
||||||
const before = await request("/public/workspace");
|
const installation = await prisma.brandTemplateInstallation.findUniqueOrThrow({
|
||||||
assert.equal(before.statusCode, 200);
|
where: { brandId },
|
||||||
const updated = await request("/admin/config/brand", {
|
|
||||||
method: "PATCH",
|
|
||||||
headers: { authorization: `Bearer ${token}` },
|
|
||||||
payload: { config: { visualTemplateKey: "acheng-campus-food" } },
|
|
||||||
});
|
});
|
||||||
assert.equal(updated.statusCode, 200);
|
const selectedVersion = await prisma.templatePackageVersion.findUniqueOrThrow({
|
||||||
try {
|
where: { id: installation.templatePackageVersionId },
|
||||||
const runtime = await request("/public/workspace");
|
});
|
||||||
assert.equal(runtime.statusCode, 200);
|
const updated = await request("/admin/workspace/template/select-version", {
|
||||||
const body = JSON.parse(runtime.body);
|
method: "POST",
|
||||||
assert.equal(body.visualTemplate.key, "acheng-campus-food");
|
headers: { authorization: `Bearer ${token}` },
|
||||||
assert.equal(body.visualTemplate.version, "1.0.0");
|
payload: {
|
||||||
assert.equal(body.theme.colors.accent, "#E87532");
|
templatePackageVersionId: installation.templatePackageVersionId,
|
||||||
assert.equal(body.visualTemplate.variants.hero, "stall-board");
|
expectedCurrentPackageVersionId: installation.templatePackageVersionId,
|
||||||
assert.equal(body.visualTemplateManifest.key, "acheng-campus-food");
|
confirm: true,
|
||||||
assert.equal(body.visualTemplateManifest.brandFirst, true);
|
},
|
||||||
assert.deepEqual(
|
});
|
||||||
body.visualTemplateManifest.pages.map((page) => page.key),
|
assert.equal(updated.statusCode, 201);
|
||||||
["home", "offerings", "detail", "inquiry", "success", "records", "profile"],
|
assert.equal(JSON.parse(updated.body).unchanged, true);
|
||||||
);
|
const runtime = await request("/public/workspace");
|
||||||
} finally {
|
assert.equal(runtime.statusCode, 200);
|
||||||
await request("/admin/config/brand", {
|
const body = JSON.parse(runtime.body);
|
||||||
method: "PATCH",
|
assert.equal(body.visualTemplate.key, selectedVersion.manifestSnapshot.visualTemplateKey);
|
||||||
headers: { authorization: `Bearer ${token}` },
|
assert.equal(body.visualTemplateManifest.key, selectedVersion.manifestSnapshot.visualTemplateKey);
|
||||||
payload: { config: JSON.parse(before.body).brand?.config ?? {} },
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("public workspace exposes declared brand and trust presentation data", async () => {
|
test("public workspace exposes declared brand and trust presentation data", async () => {
|
||||||
@@ -4445,7 +4420,6 @@ test("atelier template imports selected package and preserves draft publication
|
|||||||
tagline: "独立开发者 · 品牌小程序构建",
|
tagline: "独立开发者 · 品牌小程序构建",
|
||||||
description: "专注个人品牌表达、内容管理与咨询承接。",
|
description: "专注个人品牌表达、内容管理与咨询承接。",
|
||||||
config: {
|
config: {
|
||||||
visualTemplateKey: "linjing-editorial",
|
|
||||||
founder: "验收主理人",
|
founder: "验收主理人",
|
||||||
title: "产品设计 / 全栈开发",
|
title: "产品设计 / 全栈开发",
|
||||||
visualPresentation: { home: { subtitle: "保留已有品牌说明" } },
|
visualPresentation: { home: { subtitle: "保留已有品牌说明" } },
|
||||||
@@ -4478,11 +4452,20 @@ test("atelier template imports selected package and preserves draft publication
|
|||||||
403,
|
403,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
await json("/admin/config/brand", {
|
const rejectSelectVersion = async (requestHeaders, expectedStatus) => {
|
||||||
method: "PATCH",
|
const response = await request("/admin/workspace/template/select-version", {
|
||||||
headers,
|
method: "POST",
|
||||||
payload: { config: { visualTemplateKey: "atelier-solopreneur" } },
|
headers: requestHeaders,
|
||||||
});
|
payload: {
|
||||||
|
templatePackageVersionId: "00000000-0000-4000-8000-000000000001",
|
||||||
|
confirm: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
assert.equal(response.statusCode, expectedStatus);
|
||||||
|
};
|
||||||
|
await rejectSelectVersion({}, 401);
|
||||||
|
await rejectSelectVersion({ authorization: "Bearer invalid" }, 401);
|
||||||
|
await rejectSelectVersion({ authorization: `Bearer ${customerToken}` }, 403);
|
||||||
const packageArchive = multipartArchive(createTemplateArchive("atelier-solopreneur"));
|
const packageArchive = multipartArchive(createTemplateArchive("atelier-solopreneur"));
|
||||||
const importedPackage = await request("/admin/templates/import", {
|
const importedPackage = await request("/admin/templates/import", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@@ -4503,6 +4486,18 @@ test("atelier template imports selected package and preserves draft publication
|
|||||||
});
|
});
|
||||||
assert.equal(installation.visualTemplate.key, "atelier-solopreneur");
|
assert.equal(installation.visualTemplate.key, "atelier-solopreneur");
|
||||||
assert.equal(installation.visualTemplate.tokens.colors.accent, "#1f3a5f");
|
assert.equal(installation.visualTemplate.tokens.colors.accent, "#1f3a5f");
|
||||||
|
const selectedAgain = await json("/admin/workspace/template/select-version", {
|
||||||
|
method: "POST",
|
||||||
|
headers,
|
||||||
|
payload: {
|
||||||
|
templatePackageVersionId: selectedPackage.id,
|
||||||
|
expectedCurrentPackageVersionId: selectedPackage.id,
|
||||||
|
confirm: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
assert.equal(selectedAgain.unchanged, true);
|
||||||
|
const selectedBrand = await json("/admin/config/brand", { headers });
|
||||||
|
assert.equal(Object.hasOwn(selectedBrand.config ?? {}, "visualTemplateKey"), false);
|
||||||
const preview = await json("/admin/workspace/sample-content/preview", { headers });
|
const preview = await json("/admin/workspace/sample-content/preview", { headers });
|
||||||
assert.equal(preview.counts.fields, 5);
|
assert.equal(preview.counts.fields, 5);
|
||||||
await json("/admin/workspace/sample-content/import", {
|
await json("/admin/workspace/sample-content/import", {
|
||||||
|
|||||||
@@ -0,0 +1,106 @@
|
|||||||
|
import assert from "node:assert/strict";
|
||||||
|
import { spawnSync } from "node:child_process";
|
||||||
|
import { mkdtempSync, readdirSync, readFileSync, rmSync } from "node:fs";
|
||||||
|
import os from "node:os";
|
||||||
|
import path from "node:path";
|
||||||
|
import bcrypt from "bcryptjs";
|
||||||
|
import { PrismaClient } from "@prisma/client";
|
||||||
|
import { createApp } from "../dist/main.js";
|
||||||
|
import { signIdentity } from "../dist/auth.js";
|
||||||
|
|
||||||
|
const prisma = new PrismaClient();
|
||||||
|
const packageKeys = ["acheng-campus-food", "linjing-editorial"];
|
||||||
|
|
||||||
|
function run(command, args, options = {}) {
|
||||||
|
const result = spawnSync(command, args, { stdio: "inherit", ...options });
|
||||||
|
if (result.error) throw result.error;
|
||||||
|
if (result.status !== 0) throw new Error(`${command} exited with ${result.status}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
function archiveFor(packageKey) {
|
||||||
|
const output = mkdtempSync(path.join(os.tmpdir(), "pb-template-integration-"));
|
||||||
|
const repositoryRoot = path.resolve(process.cwd(), "../..");
|
||||||
|
run(
|
||||||
|
"node",
|
||||||
|
[
|
||||||
|
path.join(repositoryRoot, "scripts/template-pack.cjs"),
|
||||||
|
"--template",
|
||||||
|
packageKey,
|
||||||
|
"--out",
|
||||||
|
output,
|
||||||
|
],
|
||||||
|
{ cwd: repositoryRoot },
|
||||||
|
);
|
||||||
|
const filename = readdirSync(output).find((item) => item.endsWith(".tar.gz"));
|
||||||
|
assert.ok(filename, `template pack did not produce an archive for ${packageKey}`);
|
||||||
|
return {
|
||||||
|
directory: output,
|
||||||
|
filename,
|
||||||
|
content: readFileSync(path.join(output, filename)),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
async function importPackage(app, token, archive) {
|
||||||
|
const boundary = `----pb-integration-${Date.now()}`;
|
||||||
|
const payload = Buffer.concat([
|
||||||
|
Buffer.from(
|
||||||
|
`--${boundary}\r\nContent-Disposition: form-data; name="archive"; filename="${archive.filename}"\r\nContent-Type: application/gzip\r\n\r\n`,
|
||||||
|
),
|
||||||
|
archive.content,
|
||||||
|
Buffer.from(`\r\n--${boundary}--\r\n`),
|
||||||
|
]);
|
||||||
|
const response = await app.inject({
|
||||||
|
method: "POST",
|
||||||
|
url: "/admin/templates/import",
|
||||||
|
headers: {
|
||||||
|
authorization: `Bearer ${token}`,
|
||||||
|
"content-type": `multipart/form-data; boundary=${boundary}`,
|
||||||
|
},
|
||||||
|
payload,
|
||||||
|
});
|
||||||
|
assert.equal(response.statusCode, 201, response.body);
|
||||||
|
const imported = response.json().version;
|
||||||
|
const publish = await app.inject({
|
||||||
|
method: "POST",
|
||||||
|
url: `/admin/templates/${imported.id}/publish`,
|
||||||
|
headers: { authorization: `Bearer ${token}` },
|
||||||
|
});
|
||||||
|
assert.equal(publish.statusCode, 201, publish.body);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const actor = await prisma.adminUser.upsert({
|
||||||
|
where: { username: "integration-template-admin" },
|
||||||
|
update: {
|
||||||
|
isEnabled: true,
|
||||||
|
mustChangePassword: false,
|
||||||
|
platformTemplateRole: "template_admin",
|
||||||
|
},
|
||||||
|
create: {
|
||||||
|
username: "integration-template-admin",
|
||||||
|
passwordHash: await bcrypt.hash("integration-only-password", 4),
|
||||||
|
displayName: "Integration Template Admin",
|
||||||
|
platformTemplateRole: "template_admin",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const token = signIdentity({ subject: actor.id, brandId: "integration", role: "admin" });
|
||||||
|
const app = await createApp();
|
||||||
|
const archives = [];
|
||||||
|
try {
|
||||||
|
await app.init();
|
||||||
|
for (const packageKey of packageKeys) {
|
||||||
|
const archive = archiveFor(packageKey);
|
||||||
|
archives.push(archive.directory);
|
||||||
|
await importPackage(app, token, archive);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
await app.close();
|
||||||
|
for (const directory of archives) rmSync(directory, { recursive: true, force: true });
|
||||||
|
await prisma.$disconnect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
main().catch((error) => {
|
||||||
|
console.error(error);
|
||||||
|
process.exitCode = 1;
|
||||||
|
});
|
||||||
@@ -26,6 +26,8 @@ async function main() {
|
|||||||
await administrator.$executeRawUnsafe(`CREATE SCHEMA "${schema}"`);
|
await administrator.$executeRawUnsafe(`CREATE SCHEMA "${schema}"`);
|
||||||
created = true;
|
created = true;
|
||||||
if (run("pnpm", ["exec", "prisma", "migrate", "deploy"]) !== 0) return status;
|
if (run("pnpm", ["exec", "prisma", "migrate", "deploy"]) !== 0) return status;
|
||||||
|
if (run(process.execPath, ["test/prepare-integration-template-packages.mjs"]) !== 0)
|
||||||
|
return status;
|
||||||
if (run("pnpm", ["db:seed"]) !== 0) return status;
|
if (run("pnpm", ["db:seed"]) !== 0) return status;
|
||||||
const initialTrustCount = await fixtureDatabase.trustContent.count();
|
const initialTrustCount = await fixtureDatabase.trustContent.count();
|
||||||
const initialFormCount = await fixtureDatabase.inquiryForm.count();
|
const initialFormCount = await fixtureDatabase.inquiryForm.count();
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ test("template preview matrix keeps every deployed package, industry, and versio
|
|||||||
packageKey: fixture.manifest.packageKey,
|
packageKey: fixture.manifest.packageKey,
|
||||||
version: fixture.manifest.version,
|
version: fixture.manifest.version,
|
||||||
displayName: fixture.manifest.displayName,
|
displayName: fixture.manifest.displayName,
|
||||||
|
visualTemplateKey: fixture.manifest.visualTemplateKey,
|
||||||
status: "imported" as const,
|
status: "imported" as const,
|
||||||
manifestSnapshot: fixture.manifest,
|
manifestSnapshot: fixture.manifest,
|
||||||
contentChecksum: fixture.contentChecksum,
|
contentChecksum: fixture.contentChecksum,
|
||||||
@@ -148,10 +149,7 @@ test("template preview matrix keeps every deployed package, industry, and versio
|
|||||||
assert.equal(firstPreview.template.packageKey, fixture.manifest.packageKey);
|
assert.equal(firstPreview.template.packageKey, fixture.manifest.packageKey);
|
||||||
assert.equal(firstPreview.industry.key, industry);
|
assert.equal(firstPreview.industry.key, industry);
|
||||||
assert.equal(firstPreview.workspace.brand.templateKey, industry);
|
assert.equal(firstPreview.workspace.brand.templateKey, industry);
|
||||||
assert.equal(
|
assert.equal(firstPreview.compatibility.renderer.key, fixture.manifest.visualTemplateKey);
|
||||||
firstPreview.compatibility.renderer.key,
|
|
||||||
fixture.manifest.visualTemplateKey ?? fixture.manifest.packageKey,
|
|
||||||
);
|
|
||||||
assert.equal(firstPreview.preview.safety.submissions, "disabled");
|
assert.equal(firstPreview.preview.safety.submissions, "disabled");
|
||||||
assert.ok(firstPreview.workspace.offerings.length > 0);
|
assert.ok(firstPreview.workspace.offerings.length > 0);
|
||||||
|
|
||||||
@@ -163,16 +161,8 @@ test("template preview matrix keeps every deployed package, industry, and versio
|
|||||||
firstPreview.preview.assets.map((item) => item.status),
|
firstPreview.preview.assets.map((item) => item.status),
|
||||||
fixture.manifest.assetSlots.map(() => "ready"),
|
fixture.manifest.assetSlots.map(() => "ready"),
|
||||||
);
|
);
|
||||||
assert.deepEqual(
|
assert.deepEqual(firstPreview.preview.diagnostics, []);
|
||||||
firstPreview.preview.diagnostics.filter((item) => item.code !== "LEGACY_PREVIEW_SAMPLE"),
|
assert.equal(firstPreview.preview.fixtureSource, "previewFixture");
|
||||||
[],
|
|
||||||
);
|
|
||||||
assert.equal(
|
|
||||||
firstPreview.preview.fixtureSource,
|
|
||||||
fixture.manifest.packageKey === "atelier-solopreneur"
|
|
||||||
? "previewFixture"
|
|
||||||
: "legacy-sampleContent",
|
|
||||||
);
|
|
||||||
|
|
||||||
// 版本 ID 进入模拟品牌 ID,不同版本不会共享同一模拟品牌身份。
|
// 版本 ID 进入模拟品牌 ID,不同版本不会共享同一模拟品牌身份。
|
||||||
assert.match(firstPreview.workspace.brand.id, new RegExp(`^template-preview:${first.id}`));
|
assert.match(firstPreview.workspace.brand.id, new RegExp(`^template-preview:${first.id}`));
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
export function resolvePreviewRenderer<T>(
|
export function resolvePreviewRenderer<T>(
|
||||||
modules: Record<string, T>,
|
modules: Record<string, T>,
|
||||||
config: unknown,
|
workspace: unknown,
|
||||||
): T | undefined {
|
): T | undefined {
|
||||||
if (!config || typeof config !== "object" || Array.isArray(config)) return undefined;
|
if (!workspace || typeof workspace !== "object" || Array.isArray(workspace)) return undefined;
|
||||||
const key = (config as Record<string, unknown>).visualTemplateKey;
|
const visualTemplate = (workspace as Record<string, unknown>).visualTemplate;
|
||||||
|
if (!visualTemplate || typeof visualTemplate !== "object" || Array.isArray(visualTemplate))
|
||||||
|
return undefined;
|
||||||
|
const key = (visualTemplate as Record<string, unknown>).key;
|
||||||
if (typeof key !== "string" || !key) return undefined;
|
if (typeof key !== "string" || !key) return undefined;
|
||||||
const suffix = `/template-${key}/taro/index.tsx`;
|
const suffix = `/template-${key}/taro/index.tsx`;
|
||||||
return Object.entries(modules).find(([path]) => path.endsWith(suffix))?.[1];
|
return Object.entries(modules).find(([path]) => path.endsWith(suffix))?.[1];
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ const renderers = import.meta.glob<{
|
|||||||
}>("../../../../packages/template-*/taro/index.tsx", { eager: true });
|
}>("../../../../packages/template-*/taro/index.tsx", { eager: true });
|
||||||
|
|
||||||
export function TemplatePage(props: TemplateProps) {
|
export function TemplatePage(props: TemplateProps) {
|
||||||
const rendererModule = resolvePreviewRenderer(renderers, props.workspace.brand.config);
|
const rendererModule = resolvePreviewRenderer(renderers, props.workspace);
|
||||||
if (!rendererModule)
|
if (!rendererModule)
|
||||||
return <div className="runtime-state">当前模板没有可用的 H5 预览 renderer</div>;
|
return <div className="runtime-state">当前模板没有可用的 H5 预览 renderer</div>;
|
||||||
const Renderer = rendererModule.TemplatePage;
|
const Renderer = rendererModule.TemplatePage;
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ const brand = {
|
|||||||
contactPhone: "13800138000",
|
contactPhone: "13800138000",
|
||||||
contactWechat: "food-example",
|
contactWechat: "food-example",
|
||||||
config: {
|
config: {
|
||||||
visualTemplateKey: "acheng-campus-food",
|
|
||||||
founder: "测试主理人",
|
founder: "测试主理人",
|
||||||
title: "私房菜主理人",
|
title: "私房菜主理人",
|
||||||
heroImage: "",
|
heroImage: "",
|
||||||
@@ -56,7 +55,11 @@ const runtimeWorkspace = {
|
|||||||
founder: brand.config.founder,
|
founder: brand.config.founder,
|
||||||
title: brand.config.title,
|
title: brand.config.title,
|
||||||
visualPresentation: {},
|
visualPresentation: {},
|
||||||
visualTemplateKey: brand.config.visualTemplateKey,
|
},
|
||||||
|
visualTemplate: {
|
||||||
|
key: "acheng-campus-food",
|
||||||
|
version: "1.0.2",
|
||||||
|
name: "阿成校园餐",
|
||||||
},
|
},
|
||||||
templateData: {},
|
templateData: {},
|
||||||
navigation: { tabs: [] },
|
navigation: { tabs: [] },
|
||||||
|
|||||||
@@ -15,24 +15,27 @@ const modules = Object.fromEntries(
|
|||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
|
|
||||||
test("多模板预览随当前品牌配置切换所有真实模板,重复切换不保留旧 renderer", () => {
|
test("多模板预览随 Runtime 模板声明切换所有真实 renderer", () => {
|
||||||
for (const manifest of [...manifests, ...manifests.reverse()]) {
|
for (const manifest of [...manifests, ...manifests.reverse()]) {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
resolvePreviewRenderer(modules, { visualTemplateKey: manifest.packageKey })?.key,
|
resolvePreviewRenderer(modules, {
|
||||||
|
visualTemplate: { key: manifest.visualTemplateKey },
|
||||||
|
})?.key,
|
||||||
manifest.packageKey,
|
manifest.packageKey,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test("缺少或未知模板时不回落到首个模板", () => {
|
test("缺少或未知 Runtime 模板声明时不回落到首个模板", () => {
|
||||||
for (const config of [
|
for (const workspace of [
|
||||||
undefined,
|
undefined,
|
||||||
null,
|
null,
|
||||||
[],
|
[],
|
||||||
{},
|
{},
|
||||||
{ visualTemplateKey: "missing" },
|
{ brand: { config: { visualTemplateKey: "acheng-campus-food" } } },
|
||||||
{ visualTemplateKey: 1 },
|
{ visualTemplate: { key: "missing" } },
|
||||||
|
{ visualTemplate: { key: 1 } },
|
||||||
]) {
|
]) {
|
||||||
assert.equal(resolvePreviewRenderer(modules, config), undefined);
|
assert.equal(resolvePreviewRenderer(modules, workspace), undefined);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -6,7 +6,9 @@
|
|||||||
|
|
||||||
## Decision
|
## Decision
|
||||||
|
|
||||||
示例预览和导入先读取当前品牌的 `templateKey`,再从 `getTemplateSampleContent` 选择对应注册表内容。个人品牌、餐饮、门窗均提供基础示例包。
|
> 本 ADR 已被 [ADR 0031:模板只维护一套正式契约](0031-single-template-contract.md) 取代。以下内容仅保留历史决策记录,不再作为实现依据。
|
||||||
|
|
||||||
|
历史方案曾让示例预览和导入从 `getTemplateSampleContent` 的全局注册表读取内容;该注册表与 manifest 重复,现已禁止继续作为模板事实来源。
|
||||||
|
|
||||||
## Consequences
|
## Consequences
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
# 0031 模板只维护一套正式契约
|
||||||
|
|
||||||
|
## 状态
|
||||||
|
|
||||||
|
已采纳
|
||||||
|
|
||||||
|
## 背景
|
||||||
|
|
||||||
|
模板运行时逐步积累了默认行业映射、品牌 config 与安装台账双读、旧注册表 sample fallback、旧包 manifest 推断和聚合发布状态等路径。它们允许契约外的数据继续运行,使模板选择的事实来源不确定,也让每次修改都必须同时维护新旧行为。产品要求模板只维护一套契约,不建设长期兼容层。
|
||||||
|
|
||||||
|
## 决策
|
||||||
|
|
||||||
|
- 所有模板包必须通过唯一的 `TemplatePackageManifest` 契约及其 `runtimeContract` 校验。契约外字段、缺失字段、未知 renderer 或不匹配的行业声明均明确失败,不推断、不静默回退。
|
||||||
|
- 品牌当前使用的模板方案必须有明确、持久化的唯一安装记录,并锁定一个已发布的 `TemplatePackageVersion`。package key、版本、视觉 renderer key 和 checksum 只由该版本的 package manifest 与不可变归档确定;数据库不重复存 renderer key。运行时不得从品牌行业、全局默认值或本地注册表推测视觉模板。
|
||||||
|
- 模板 manifest 是模板结构、资源、编辑绑定、能力声明、preview fixture 和 bootstrap sample 的唯一事实来源。删除包外的重复 sample 注册表和 fallback。
|
||||||
|
- `BrandProfile.templateKey` 表示行业模型,不是视觉模板;模板版本选择只由正式安装记录的精确 package version 引用表达。视觉 renderer key 只存在于 package manifest。禁止在 `BrandProfile.config.visualTemplateKey` 或安装/版本表再存一份副本。
|
||||||
|
- 预览 fixture 与显式 bootstrap sample 是同一 manifest 契约中的不同用途;不为旧字段提供静默替代。必需声明缺失时阻断导入或操作。
|
||||||
|
- 不保留旧运行时读路径、双写、兼容窗口、字段别名或格式推断。现存数据库状态通过一次性、可审计、失败即停止的 migration 转成正式状态;迁移完成后删除旧列/JSON 键和旧代码路径。
|
||||||
|
- 不可变包版本、发布快照、显式升级和回滚属于当前契约下的正常生命周期能力,不属于兼容层。
|
||||||
|
- Web API、Admin Client、数据库模型和 package manifest 是同一契约的边界。任一形状变更必须在同一变更中更新生产者、消费者、迁移和测试,不另设旧格式分支。
|
||||||
|
|
||||||
|
## 考虑过的方案
|
||||||
|
|
||||||
|
- 长期双读并在缺字段时 fallback:拒绝。它保留歧义并使旧数据问题无法暴露。
|
||||||
|
- 先新增新模型并永久保留旧模型:拒绝。模型迁移必须有明确的切换和旧字段删除步骤。
|
||||||
|
- 一次性数据转换:采用。转换可保留既有品牌内容,但所有无法无歧义映射的记录必须报告并阻断,不能猜值。
|
||||||
|
- 删除所有历史模板版本:拒绝。历史版本可留作审计或回滚,但每个版本都必须满足同一 manifest 契约。
|
||||||
|
|
||||||
|
## 后果
|
||||||
|
|
||||||
|
- 缺少安装或包版本的品牌会显式报错,直到完成一次性数据迁移;不再被默认视觉模板掩盖。
|
||||||
|
- 需要清理重复的视觉模板状态、包外 sample registry、旧 manifest 推断、聚合状态读写和相应文档。
|
||||||
|
- 数据迁移需先生成只读差异报告;遇到缺失、冲突或未知 key 时停止,不覆盖品牌编辑内容。
|
||||||
|
- 模板包契约的 breaking change 必须通过一次整体迁移升级所有仓库包,不维护多份 runtime parser。
|
||||||
|
|
||||||
|
## 迁移计划
|
||||||
|
|
||||||
|
1. 盘点品牌行业、config 视觉键、安装行、包版本和发布快照,输出只读不一致报告。
|
||||||
|
2. 对存在唯一明确来源的品牌,迁移为每品牌唯一安装行,并绑定已发布 package version、版本与 checksum;无法唯一映射的品牌保持不变并列为阻断项。
|
||||||
|
3. 在失败即停迁移中校验一品牌一安装、精确版本引用、package key/version/checksum/行业声明及旧视觉键一致;成功后删除 config JSON 键及安装/版本表重复 renderer 列,并约束一品牌唯一安装。
|
||||||
|
4. 将 API、Admin、Runtime、发布快照、bootstrap 和构建路径切换到安装记录;缺失/损坏状态显式失败。
|
||||||
|
5. 删除默认映射、包外 sample fallback、旧格式推断和聚合字段兼容读写,补授权、成功和失败集成测试。
|
||||||
|
6. 运行 template doctor、数据库迁移、API integration、Admin production build、Taro 双端构建及完整格式/类型门禁。
|
||||||
@@ -4,14 +4,14 @@ This document records where template-controlled content is stored and how it rea
|
|||||||
|
|
||||||
## Storage And Runtime Mapping
|
## Storage And Runtime Mapping
|
||||||
|
|
||||||
| Content | Template declaration | Brand-scoped storage | Admin editor | Published runtime |
|
| Content | Template declaration | Brand-scoped storage | Admin editor | Published runtime |
|
||||||
| -------------------------------- | ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
|
| -------------------------------- | ------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| Brand identity and contact facts | `admin.sections` bindings such as `brand.config.founder`; platform identity fields are shared | `BrandProfile` columns and `BrandProfile.config` JSON | Brand profile and page configuration | Brand data is copied into `BrandRelease.snapshot`; public workspace merges the brand config into `RuntimeWorkspace.brand` |
|
| Brand identity and contact facts | `admin.sections` bindings such as `brand.config.founder`; platform identity fields are shared | `BrandProfile` columns and `BrandProfile.config` JSON | Brand profile and page configuration | Brand data is copied into `BrandRelease.snapshot`; public workspace merges the brand config into `RuntimeWorkspace.brand` |
|
||||||
| Page copy and presentation | `admin.sections` with exact page binding | `BrandProfile.config.visualPresentation` and related config objects | Template-driven page editor | Public workspace exposes the saved config; Mini Program renderers consume the matching page fields |
|
| Page copy and presentation | `admin.sections` with exact page binding | `BrandProfile.config.visualPresentation` and related config objects | Template-driven page editor | Public workspace exposes the saved config; Mini Program renderers consume the matching page fields |
|
||||||
| Offerings and details | Offering-target `admin.sections` | `Offering` columns and `Offering.config` JSON | Services editor | Release snapshot offerings are normalized by public workspace; disabled offerings are filtered |
|
| Offerings and details | Offering-target `admin.sections` | `Offering` columns and `Offering.config` JSON | Services editor | Release snapshot offerings are normalized by public workspace; disabled offerings are filtered |
|
||||||
| Trust content | `trustContentTypes`, including page destinations and Admin labels for `title`, `summary`, and `content` | Brand-scoped `TrustContent` rows | Trust content editor; form labels/options come from the selected template manifest | Only published rows are copied to public runtime; template pages render declared types |
|
| Trust content | `trustContentTypes`, including page destinations and Admin labels for `title`, `summary`, and `content` | Brand-scoped `TrustContent` rows | Trust content editor; form labels/options come from the selected template manifest | Only published rows are copied to public runtime; template pages render declared types |
|
||||||
| Inquiry forms | The template package provides an explicit sample form name and sample fields | Brand-scoped `InquiryForm.fieldsSnapshot`; submissions keep their own snapshots | Workspace form editor; explicit sample import creates a form only when no enabled form exists | Release snapshot forms are normalized into `RuntimeWorkspace.inquiryForms` |
|
| Inquiry forms | The template package provides an explicit sample form name and sample fields | Brand-scoped `InquiryForm.fieldsSnapshot`; submissions keep their own snapshots | Workspace form editor; explicit sample import creates a form only when no enabled form exists | Release snapshot forms are normalized into `RuntimeWorkspace.inquiryForms` |
|
||||||
| Template and visual selection | Package manifest and visual template manifest | `BrandTemplateInstallation` snapshot plus `BrandProfile.templateKey/config.visualTemplateKey` | Workspace/template selection | Release snapshot pins package and visual manifest versions |
|
| Template and visual selection | Exact published package version and its manifest | `BrandTemplateInstallation.templatePackageVersionId`; `BrandProfile.templateKey` identifies the industry model | Workspace selects an explicit package version | Release snapshot pins the package manifest and visual manifest versions |
|
||||||
|
|
||||||
## Food Schedule Example
|
## Food Schedule Example
|
||||||
|
|
||||||
|
|||||||
@@ -59,6 +59,7 @@
|
|||||||
- 不把所有模板 sample content 复制进 Prisma seed,也不把 seed 当成模板目录;
|
- 不把所有模板 sample content 复制进 Prisma seed,也不把 seed 当成模板目录;
|
||||||
- 不把品牌 owner 的权限扩展为平台模板管理员权限;
|
- 不把品牌 owner 的权限扩展为平台模板管理员权限;
|
||||||
- 不把一次性的线上修复脚本当成模板安装能力;
|
- 不把一次性的线上修复脚本当成模板安装能力;
|
||||||
|
- 不建设模板兼容层:运行时只读唯一正式 manifest/runtime contract;历史数据通过失败即停止的一次性迁移转换,不能保留双读、双写、默认映射或旧格式 fallback;
|
||||||
- 不在同一阶段长期维护两套业务 renderer。Taro 是统一的双端业务 renderer,旧原生实现只作为迁移和回滚基线;
|
- 不在同一阶段长期维护两套业务 renderer。Taro 是统一的双端业务 renderer,旧原生实现只作为迁移和回滚基线;
|
||||||
- 不承诺第一阶段可以导入任意全新 renderer 源码后立即运行。第一阶段只接收声明式 manifest、资源、演示数据和已部署的受信 renderer 引用;
|
- 不承诺第一阶段可以导入任意全新 renderer 源码后立即运行。第一阶段只接收声明式 manifest、资源、演示数据和已部署的受信 renderer 引用;
|
||||||
- 不把生成一张预览图、静态文件存在或页面能打开当成模板交付完成。
|
- 不把生成一张预览图、静态文件存在或页面能打开当成模板交付完成。
|
||||||
@@ -67,16 +68,16 @@
|
|||||||
|
|
||||||
## 3. 当前状态和目标状态
|
## 3. 当前状态和目标状态
|
||||||
|
|
||||||
| 领域 | 当前状态 | 目标状态 | 进入目标状态的证据 |
|
| 领域 | 当前状态 | 目标状态 | 进入目标状态的证据 |
|
||||||
| ------------ | ------------------------------------------------------------------ | -------------------------------------------------------------- | --------------------------------------------------- |
|
| ------------ | ------------------------------------------------------------------ | -------------------------------------------------------------- | ------------------------------------------------------ |
|
||||||
| 模板发现 | packages/config 有生成注册表,文档注册表仍是手工清单 | 所有可用版本由可校验包 manifest 发现,生成注册表只作为构建产物 | 包发现测试、目录接口测试、无手工重复定义 |
|
| 模板发现 | packages/config 有生成注册表,文档注册表仍是手工清单 | 所有可用版本由可校验包 manifest 发现,生成注册表只作为构建产物 | 包发现测试、目录接口测试、无手工重复定义 |
|
||||||
| 版本 | 当前模板包 metadata 已与 manifest 对齐,导入 checksum 闭环尚未实现 | key + version + checksum 唯一且不可变 | 导出 checksum、重复导入、冲突导入测试 |
|
| 版本 | 当前模板包 metadata 已与 manifest 对齐,导入 checksum 闭环尚未实现 | key + version + checksum 唯一且不可变 | 导出 checksum、重复导入、冲突导入测试 |
|
||||||
| 行业与视觉 | 行业安装和视觉选择已有部分能力,但没有完整版本化目录 | 行业兼容性、视觉包版本、renderer contract 一起校验 | 组合矩阵、安装快照和跨行业测试 |
|
| 行业与视觉 | 行业安装和视觉选择已有部分能力,但没有完整版本化目录 | 行业兼容性、视觉包版本、renderer contract 一起校验 | 组合矩阵、安装快照和跨行业测试 |
|
||||||
| 示例内容 | 包内 sample 可用于部分预览和显式导入 | preview fixture、bootstrap 内容、品牌真实数据严格分离 | 预览无品牌写入、显式导入审计、缺失值规则测试 |
|
| 示例内容 | 包内 sample 可用于部分预览和显式导入 | preview fixture、bootstrap 内容、品牌真实数据严格分离 | 预览无品牌写入、显式导入审计、缺失值规则测试 |
|
||||||
| 模板管理页面 | 现有工作台可以选择部分已注册模板 | 独立 /admin/templates 管理导入、校验、预览、发布和版本 | 页面状态测试、API 权限测试、错误重试测试 |
|
| 模板管理页面 | 现有工作台可以选择部分已注册模板 | 独立 /admin/templates 管理导入、校验、预览、发布和版本 | 页面状态测试、API 权限测试、错误重试测试 |
|
||||||
| 安装和升级 | BrandTemplateInstallation 主要承担行业安装 | 行业安装、视觉包安装、样例导入、升级计划和发布快照各有边界 | schema 迁移、旧数据回填、升级/回滚 integration test |
|
| 安装和升级 | 品牌配置、行业安装和视觉选择存在重复来源 | 唯一安装记录锁定行业模型与精确视觉包版本 | 一次性数据转换、唯一性约束、升级/回滚 integration test |
|
||||||
| 构建发布 | 构建、上传和发布曾共用状态,容易死锁或误报 | build、upload、review、publish 分层,attempt/lease/产物隔离 | 并发、重启、超时、错误收敛、真实参数产物测试 |
|
| 构建发布 | 构建、上传和发布曾共用状态,容易死锁或误报 | build、upload、review、publish 分层,attempt/lease/产物隔离 | 并发、重启、超时、错误收敛、真实参数产物测试 |
|
||||||
| 版本事实 | atelier-solopreneur 的 manifest 和 package metadata 已统一为 1.1.0 | 包内版本字段和导出元数据在导出前强一致 | validate:templates 的版本一致性检查 |
|
| 版本事实 | atelier-solopreneur 的 manifest 和 package metadata 已统一为 1.1.0 | 包内版本字段和导出元数据在导出前强一致 | validate:templates 的版本一致性检查 |
|
||||||
|
|
||||||
当前存在的 Runtime Workspace、模板 manifest、样例导入和 Taro 构建能力是基础组件,不代表本任务已完成。实施进度必须引用本文的阶段和证据。
|
当前存在的 Runtime Workspace、模板 manifest、样例导入和 Taro 构建能力是基础组件,不代表本任务已完成。实施进度必须引用本文的阶段和证据。
|
||||||
|
|
||||||
@@ -251,15 +252,15 @@ admin.sections 和 renderer 必须互相校验:每个可见、可编辑的品
|
|||||||
| TemplateUpgradePlan | from/to、差异、冲突、用户确认和执行结果 | 支持 dry-run、重试和回滚 |
|
| TemplateUpgradePlan | from/to、差异、冲突、用户确认和执行结果 | 支持 dry-run、重试和回滚 |
|
||||||
| TemplateOperationJob | 导入、校验、资源处理、build/upload 的 attempt 和 lease | 支持重启恢复和终态收敛 |
|
| TemplateOperationJob | 导入、校验、资源处理、build/upload 的 attempt 和 lease | 支持重启恢复和终态收敛 |
|
||||||
|
|
||||||
现有 BrandTemplateInstallation 当前主要承担行业模板安装记录,不能直接把它改成视觉包版本记录并破坏旧快照。实施前先盘点其查询、发布快照和旧回滚行为;优先新增边界清晰的模型或新增可为空字段,完成兼容读取后再考虑收敛。
|
BrandTemplateInstallation 必须收敛为品牌唯一的当前模板安装,记录行业模型及精确视觉包版本。先只读盘点数据,再以一次性事务迁移完成无歧义映射;迁移后删除重复状态和旧字段,不保留兼容读取窗口。发布历史通过不可变 release snapshot 保留,不依赖旧安装形状。
|
||||||
|
|
||||||
数据库迁移必须遵循以下顺序:
|
数据库迁移必须遵循以下顺序:
|
||||||
|
|
||||||
1. 备份并记录当前 schema、模板安装、品牌配置和发布快照数量;
|
1. 备份并记录当前 schema、模板安装、品牌配置和发布快照数量;
|
||||||
2. 先增加可为空的新字段或新表,不改变旧读路径;
|
2. 先增加可为空的新字段或新表,不改变旧读路径;
|
||||||
3. 回填只写可从旧数据确定推导出的值,不能猜测版本、checksum 或样例来源;
|
3. 回填只写可从旧数据确定推导出的值,不能猜测版本、checksum 或样例来源;
|
||||||
4. 双读对比旧路径和新路径,记录不一致;
|
4. 生成新旧数据的只读差异报告;有歧义时停止迁移并修正数据;
|
||||||
5. 切换写入,再保留旧读兼容窗口;
|
5. 执行一次性事务迁移,校验唯一安装及 package/version/checksum/industry 一致后删除旧表示;
|
||||||
6. 清理旧字段前提供备份、回滚脚本和历史快照验证;
|
6. 清理旧字段前提供备份、回滚脚本和历史快照验证;
|
||||||
7. 重复执行迁移和导入不得生成重复安装、重复 offering、重复 inquiry form 或重复审计。
|
7. 重复执行迁移和导入不得生成重复安装、重复 offering、重复 inquiry form 或重复审计。
|
||||||
|
|
||||||
@@ -419,7 +420,7 @@ Phase 3 初版实现(提交 `6edde5a`,2026-10-16):
|
|||||||
Phase 3 独立 fixture 与资源进展(2026-10-16):
|
Phase 3 独立 fixture 与资源进展(2026-10-16):
|
||||||
|
|
||||||
- 新增 `previewFixture.<industry>`:`schemaVersion: "1"`、身份白名单 `brand`、独立 `content` 和固定禁用策略 `safety`;使用 `packages/validation` 的同一 Zod 规则校验本地包和线上导入,不引入新校验体系。声明 fixture 的包必须覆盖全部兼容行业;无效声明不能回退到 `sampleContent`。
|
- 新增 `previewFixture.<industry>`:`schemaVersion: "1"`、身份白名单 `brand`、独立 `content` 和固定禁用策略 `safety`;使用 `packages/validation` 的同一 Zod 规则校验本地包和线上导入,不引入新校验体系。声明 fixture 的包必须覆盖全部兼容行业;无效声明不能回退到 `sampleContent`。
|
||||||
- atelier 升为 `1.2.0`,保持旧版本不可变;预览主理人和品牌身份单独声明,`sampleContent` 仍只用于品牌起始内容,不修改 seed 或自动安装到现有品牌。尚未迁移的旧包走明确标注的兼容路径。
|
- atelier 升为 `1.2.0`,保持不可变版本;预览主理人和品牌身份单独声明,`sampleContent` 只用于显式品牌起始内容。所有可发布包必须满足同一 manifest 契约;不提供旧包运行兼容路径。
|
||||||
- 管理页展示当前页面的 Admin 模块声明顺序、字段 binding、资源配置数量和缺失状态。这是声明诊断,不代表已经验证 renderer 的实际视觉顺序或全部字段消费。
|
- 管理页展示当前页面的 Admin 模块声明顺序、字段 binding、资源配置数量和缺失状态。这是声明诊断,不代表已经验证 renderer 的实际视觉顺序或全部字段消费。
|
||||||
- 预览读取已导入 archive,核对 archive/content checksum 及逐图片 SHA-256,校验实际图片格式后以内嵌 data URL 提供给画布;不执行源码、不解压到公共目录、不回退到当前部署的同名图片。每图最多 2 MiB、总图片最多 8 MiB、最多 128 张,超出限额返回明确诊断;外链图片仍为待验证。
|
- 预览读取已导入 archive,核对 archive/content checksum 及逐图片 SHA-256,校验实际图片格式后以内嵌 data URL 提供给画布;不执行源码、不解压到公共目录、不回退到当前部署的同名图片。每图最多 2 MiB、总图片最多 8 MiB、最多 128 张,超出限额返回明确诊断;外链图片仍为待验证。
|
||||||
- 同一预览响应同时包含版本 checksum、Runtime 和图片映射,切换版本/行业不会复用另一份图片;当前实现尚不包含可公开访问的资源 URL、远程资源探测或 CDN 缓存。
|
- 同一预览响应同时包含版本 checksum、Runtime 和图片映射,切换版本/行业不会复用另一份图片;当前实现尚不包含可公开访问的资源 URL、远程资源探测或 CDN 缓存。
|
||||||
@@ -442,7 +443,7 @@ Phase 3 现场验收纠偏(2026-10-16):
|
|||||||
- 现场核对发现旧模板 `sampleContent` 只有少量业务数据,`brandConfig` 和媒体槽位为空,导致 food/linjing 预览像缺数据。已为 `acheng-campus-food@1.0.1`、`linjing-editorial@1.0.3` 补齐包内演示主图、头像、封面和视觉文案;旧版本保持 immutable 并撤回。
|
- 现场核对发现旧模板 `sampleContent` 只有少量业务数据,`brandConfig` 和媒体槽位为空,导致 food/linjing 预览像缺数据。已为 `acheng-campus-food@1.0.1`、`linjing-editorial@1.0.3` 补齐包内演示主图、头像、封面和视觉文案;旧版本保持 immutable 并撤回。
|
||||||
- atelier 独立 fixture 也没有头像。已升为 `atelier-solopreneur@1.3.0`,在 `previewFixture.personal.brand` 中加入包内头像,继续保持预览数据与 bootstrap sample 分离。
|
- atelier 独立 fixture 也没有头像。已升为 `atelier-solopreneur@1.3.0`,在 `previewFixture.personal.brand` 中加入包内头像,继续保持预览数据与 bootstrap sample 分离。
|
||||||
- 修复 Admin 导入包预览中 food renderer 的资源 key 前缀映射:包内 `/assets/service/*.png` 等图标现在可从 archive 校验后的 data URL 渲染,不回退到本地部署资源。
|
- 修复 Admin 导入包预览中 food renderer 的资源 key 前缀映射:包内 `/assets/service/*.png` 等图标现在可从 archive 校验后的 data URL 渲染,不回退到本地部署资源。
|
||||||
- 矩阵 API 回归新增断言:每个支持行业的主理人身份非空、头像指向包内资源、所有 asset slot 都是 `ready`、除 `LEGACY_PREVIEW_SAMPLE` 外没有诊断。
|
- 矩阵 API 回归新增断言:每个支持行业的主理人身份非空、头像指向包内资源、所有 asset slot 都是 `ready`、没有诊断。
|
||||||
- 新增 Playwright 媒体矩阵:覆盖 `acheng/food`、`atelier/personal`、`linjing/personal`、`linjing/doors`,使用真实 `template:pack` 产物和 API preview service;验证失败重试、founder 可见、所有 `data:` 图像 `naturalWidth > 0`、无“内容缺失”、无真实写入请求。四张截图已人工检查。
|
- 新增 Playwright 媒体矩阵:覆盖 `acheng/food`、`atelier/personal`、`linjing/personal`、`linjing/doors`,使用真实 `template:pack` 产物和 API preview service;验证失败重试、founder 可见、所有 `data:` 图像 `naturalWidth > 0`、无“内容缺失”、无真实写入请求。四张截图已人工检查。
|
||||||
- 本轮本地目录以最新已发布版本为准:`acheng-campus-food@1.0.1`、`atelier-solopreneur@1.3.0`、`linjing-editorial@1.0.3`;被取代的旧演示版本进入 retired。
|
- 本轮本地目录以最新已发布版本为准:`acheng-campus-food@1.0.1`、`atelier-solopreneur@1.3.0`、`linjing-editorial@1.0.3`;被取代的旧演示版本进入 retired。
|
||||||
|
|
||||||
@@ -466,15 +467,15 @@ Phase 3 隔离、导航和矩阵收口(2026-10-16):
|
|||||||
- [x] 通过 shared client、Admin 页面和 API integration test 验证跨品牌隔离;
|
- [x] 通过 shared client、Admin 页面和 API integration test 验证跨品牌隔离;
|
||||||
- [x] 验证模板安装不自动导入未确认的身份、背书、案例和咨询数据。
|
- [x] 验证模板安装不自动导入未确认的身份、背书、案例和咨询数据。
|
||||||
|
|
||||||
当前进展:安装台账已保存 `templatePackageVersionId`、视觉 key 和 `contentChecksum`;bootstrap 只读取已发布 package version 的 `manifestSnapshot.sampleContent`,preview 只 dry-run,import 必须显式传入 `strategy: "missing_only"` 和 `confirm: true`。已有品牌值(包括显式空值)、同名 offering、相同 `type + title` 的 trust content、相同 inquiry field,以及已启用表单都会被保留;重复导入按品牌、版本和 checksum 幂等返回,并写入 `TemplateBootstrapImport` 和 capability audit。
|
当前进展:安装台账只引用精确的 `templatePackageVersionId` 并记录 `contentChecksum`;renderer key 只从该版本的 package manifest 读取。bootstrap 只读取已发布 package version 的 `manifestSnapshot.sampleContent`,preview 只 dry-run,import 必须显式传入 `strategy: "missing_only"` 和 `confirm: true`。已有品牌值(包括显式空值)、同名 offering、相同 `type + title` 的 trust content、相同 inquiry field,以及已启用表单都会被保留;重复导入按品牌、版本和 checksum 幂等返回,并写入 `TemplateBootstrapImport` 和 capability audit。
|
||||||
|
|
||||||
seed 边界已收口:`ensureRuntimeContent` 写入的 offerings、trust content、inquiry fields、表单名称和模板品牌样例均来自对应 package 的 `sampleContent`,food、doors 的媒体和结构化展示字段已通过真实公开 workspace 验证;`runtimeSeedTemplates` 仅保留明确的开发演示品牌 profile 以及旧 offering 停用兼容 fixture,不作为模板目录或业务样例来源。新增模板不需要修改全局 seed;没有 package version 台账的历史 seed 品牌继续使用 registry 兼容路径,新安装品牌必须使用精确已发布版本。
|
seed 边界已收口:`ensureRuntimeContent` 写入的 offerings、trust content、inquiry fields、表单名称和模板品牌样例均来自对应 package 的 `sampleContent`,food、doors 的媒体和结构化展示字段已通过真实公开 workspace 验证;`runtimeSeedTemplates` 仅保留明确的开发演示品牌 profile,不作为模板目录或业务样例来源。新增模板不需要修改全局 seed;每个运行品牌都必须有精确已发布 package version 安装,缺失时启动/操作明确失败,不走 registry fallback。
|
||||||
|
|
||||||
退出门禁:干净品牌可以通过安装和显式导入完成编辑发布;已有用户值、主动清空值和历史发布快照均不被覆盖;错误请求不会改变表单。
|
退出门禁:干净品牌可以通过安装和显式导入完成编辑发布;已有用户值、主动清空值和历史发布快照均不被覆盖;错误请求不会改变表单。
|
||||||
|
|
||||||
### Phase 5:构建、上传和线上发布闭环
|
### Phase 5:构建、上传和线上发布闭环
|
||||||
|
|
||||||
- [x] 将 build、upload、review 状态拆分,并为构建/上传增加持久化 attempt 和 lease;旧聚合 `status` 暂时保留兼容;
|
- [x] 将 build、upload、review 状态拆分,并为构建/上传增加持久化 attempt 和 lease;
|
||||||
- [x] 产物路径包含品牌 slug、模板 key、模板包精确版本和 build attempt id;
|
- [x] 产物路径包含品牌 slug、模板 key、模板包精确版本和 build attempt id;
|
||||||
- [x] 生产依赖闭包通过 Node 24 release package、干净 `--prod --frozen-lockfile` 安装、Prisma Client generate、API runtime import 和 production API health check 验证;API app 重建后的 attempt 恢复由真实 Prisma integration 覆盖;
|
- [x] 生产依赖闭包通过 Node 24 release package、干净 `--prod --frozen-lockfile` 安装、Prisma Client generate、API runtime import 和 production API health check 验证;API app 重建后的 attempt 恢复由真实 Prisma integration 覆盖;
|
||||||
- [x] 构建失败、上传失败、超时、进程退出、重试和恢复有自动化测试;覆盖 build worker 非零退出/watchdog kill、失败构建、上传子进程超时、attempt lease 竞争/接管、真实 Prisma/API app 重建恢复;本机 Node 24 production bundle 已启动、停止并重启验证;生产机 PM2/主机重启仍属于部署环境验收;
|
- [x] 构建失败、上传失败、超时、进程退出、重试和恢复有自动化测试;覆盖 build worker 非零退出/watchdog kill、失败构建、上传子进程超时、attempt lease 竞争/接管、真实 Prisma/API app 重建恢复;本机 Node 24 production bundle 已启动、停止并重启验证;生产机 PM2/主机重启仍属于部署环境验收;
|
||||||
@@ -528,7 +529,7 @@ Phase 7 进展记录(2026-10-17):
|
|||||||
- 新增 `pnpm template:compatibility`,通过 TypeScript AST 读取行业、能力和视觉注册表,自动发现所有 package manifest;比较平台视觉 renderer、Admin glob、Taro renderer 导出、行业 capability 和 package/platform Taro/React 依赖主次版本,支持 JSON 报告。
|
- 新增 `pnpm template:compatibility`,通过 TypeScript AST 读取行业、能力和视觉注册表,自动发现所有 package manifest;比较平台视觉 renderer、Admin glob、Taro renderer 导出、行业 capability 和 package/platform Taro/React 依赖主次版本,支持 JSON 报告。
|
||||||
- API 模板预览矩阵自动扫描真实 manifest,逐个验证声明行业、版本隔离、品牌隔离和归档资源;CI 静态 job 显式执行 package validation、compatibility、API matrix 和 conformance。CI browser job 已执行真实包 fixture 的页面/资源/编辑回归截图。
|
- API 模板预览矩阵自动扫描真实 manifest,逐个验证声明行业、版本隔离、品牌隔离和归档资源;CI 静态 job 显式执行 package validation、compatibility、API matrix 和 conformance。CI browser job 已执行真实包 fixture 的页面/资源/编辑回归截图。
|
||||||
- 自动化验证:`pnpm template:check` 通过(contract `22/22`、scaffold/compatibility `3/3`、pack `3/3`、conformance `1/1`、compiler `10/10`、miniapp fixture `3/3`);API matrix `2/2`;compatibility 报告有 4 个支持组合;API unit `65/65`、HTTP integration `54/54`、upload integration `2/2`、API Client `8/8`、Admin `6/6`;API/API Client/Admin typecheck、Admin production build、Prettier 和 `git diff --check` 通过。
|
- 自动化验证:`pnpm template:check` 通过(contract `22/22`、scaffold/compatibility `3/3`、pack `3/3`、conformance `1/1`、compiler `10/10`、miniapp fixture `3/3`);API matrix `2/2`;compatibility 报告有 4 个支持组合;API unit `65/65`、HTTP integration `54/54`、upload integration `2/2`、API Client `8/8`、Admin `6/6`;API/API Client/Admin typecheck、Admin production build、Prettier 和 `git diff --check` 通过。
|
||||||
- 剩余:指标已有统一持久化和平台管理员查询接口,但定期审阅流程仍需运营安排;旧 renderer/默认行业映射仍有兼容职责,暂不能删除。模板 doctor 的真实品牌编辑保存重载发布与原型视觉证据仍为 `unverified`,不能以 CI smoke 代替;因此 Phase 7 整体继续进行。
|
- 剩余:指标已有统一持久化和平台管理员查询接口,但定期审阅流程仍需运营安排;模板运行时仍有旧 renderer/默认行业映射等兼容路径待移除。模板 doctor 的真实品牌编辑保存重载发布与原型视觉证据仍为 `unverified`,不能以 CI smoke 代替;因此 Phase 7 整体继续进行。
|
||||||
|
|
||||||
运营指标说明:新增 `TemplateOperationFailureEvent` 记录导入、预览、安装/冲突、升级和回滚失败;构建/上传从已有 release attempt 聚合。事件只保留 action、稳定 `HTTP_*` resultCode、可选实体标识和 requestId,查询只返回类别/数量;按 180 天 best-effort 清理,不回填历史失败数。定期审阅仍需运营流程和负责人。
|
运营指标说明:新增 `TemplateOperationFailureEvent` 记录导入、预览、安装/冲突、升级和回滚失败;构建/上传从已有 release attempt 聚合。事件只保留 action、稳定 `HTTP_*` resultCode、可选实体标识和 requestId,查询只返回类别/数量;按 180 天 best-effort 清理,不回填历史失败数。定期审阅仍需运营流程和负责人。
|
||||||
|
|
||||||
@@ -541,7 +542,7 @@ Phase 7 进展记录(2026-10-17):
|
|||||||
- [ ] 使用真实部署参数完成 H5 和 weapp 构建,检查 AppID、API 地址、媒体地址、模板版本和产物路径;
|
- [ ] 使用真实部署参数完成 H5 和 weapp 构建,检查 AppID、API 地址、媒体地址、模板版本和产物路径;
|
||||||
- [ ] 在微信开发者工具或真机完成 request、media、拨号、复制、表单提交和安全区验证;外部上传、审核、发布结果单独归档;
|
- [ ] 在微信开发者工具或真机完成 request、media、拨号、复制、表单提交和安全区验证;外部上传、审核、发布结果单独归档;
|
||||||
- [ ] 由平台模板管理员执行一次失败指标审阅,确认高频问题、负责人和后续动作,形成审阅记录;
|
- [ ] 由平台模板管理员执行一次失败指标审阅,确认高频问题、负责人和后续动作,形成审阅记录;
|
||||||
- [ ] 基于实际迁移证据决定旧 registry/default mapping 是否可以逐项下线;未完成历史品牌回填和兼容验证前不得删除兼容层。
|
- [ ] 完成一次性品牌安装与 package version 数据转换,之后删除旧 registry/default mapping 和所有模板兼容读写;迁移歧义必须阻断,不得延长兼容窗口。
|
||||||
|
|
||||||
Phase 8 启动记录(2026-10-17):
|
Phase 8 启动记录(2026-10-17):
|
||||||
|
|
||||||
@@ -559,9 +560,9 @@ Phase 8 自动化持久化与兼容审查(2026-10-17):
|
|||||||
|
|
||||||
- API unit `65/65`、API Client `8/8`、Admin `6/6`、发布验证/部署测试 `8/8` 通过;隔离 PostgreSQL schema 中执行完整 `pnpm --filter @personal-brand/api test:integration`,HTTP integration `54/54`、upload integration `2/2` 通过,schema migration 与重复 seed 幂等性通过;
|
- API unit `65/65`、API Client `8/8`、Admin `6/6`、发布验证/部署测试 `8/8` 通过;隔离 PostgreSQL schema 中执行完整 `pnpm --filter @personal-brand/api test:integration`,HTTP integration `54/54`、upload integration `2/2` 通过,schema migration 与重复 seed 幂等性通过;
|
||||||
- 隔离 integration 中真实 manifest bindings 经数据库持久化、草稿预览和发布快照测试通过(193 个 manifest bindings);这证明自动化数据链,不等价于人工在 Admin 实际点选编辑,也不替代独立模板视觉审查;
|
- 隔离 integration 中真实 manifest bindings 经数据库持久化、草稿预览和发布快照测试通过(193 个 manifest bindings);这证明自动化数据链,不等价于人工在 Admin 实际点选编辑,也不替代独立模板视觉审查;
|
||||||
- 旧默认视觉映射仍被 seed、草稿/公开 Runtime、release snapshot 和显式 bootstrap 调用。当前没有完整的历史品牌回填与双读/回滚机制,故不能安全删除;后续应先为现有品牌持久化明确 visual package version/checksum,再验证旧行兼容读取,最后分批移除 fallback。
|
- 旧默认视觉映射仍被 seed、草稿/公开 Runtime、release snapshot 和显式 bootstrap 调用,违反单一契约决策。必须先输出只读迁移报告,将每个运行品牌明确绑定到已发布 visual package version/checksum;无法唯一映射时阻断。完成一次性转换后删除所有 fallback,不提供双读或兼容窗口。
|
||||||
|
|
||||||
退出门禁:真实品牌保存重载发布、视觉证据、双端外部验证和运营审阅记录全部归档;旧兼容层只有在历史品牌迁移验证后才允许删除。
|
退出门禁:真实品牌保存重载发布、视觉证据、双端外部验证和运营审阅记录全部归档;历史品牌通过一次性迁移满足唯一模板契约,所有兼容层和旧字段已删除。
|
||||||
|
|
||||||
Phase 8 编辑闭环回归(2026-10-18):
|
Phase 8 编辑闭环回归(2026-10-18):
|
||||||
|
|
||||||
@@ -647,16 +648,16 @@ Phase 8 编辑闭环回归(2026-10-18):
|
|||||||
|
|
||||||
以下问题必须在对应阶段开始前作出可审阅决定,不允许用临时默认值带过:
|
以下问题必须在对应阶段开始前作出可审阅决定,不允许用临时默认值带过:
|
||||||
|
|
||||||
| 问题 | 推荐方向 | 最晚决定阶段 |
|
| 问题 | 推荐方向 | 最晚决定阶段 |
|
||||||
| ----------------------------------------------- | ------------------------------------------------------------------- | ------------ |
|
| ----------------------------------------------- | ------------------------------------------------------------------------ | ------------ |
|
||||||
| 平台模板管理员角色名称和权限来源 | 独立于品牌 owner 的平台级权限,所有操作审计 | Phase 0 |
|
| 平台模板管理员角色名称和权限来源 | 独立于品牌 owner 的平台级权限,所有操作审计 | Phase 0 |
|
||||||
| artifact 存储 | 版本化对象存储或受控 release 目录,按 checksum/版本寻址 | Phase 2 |
|
| artifact 存储 | 版本化对象存储或受控 release 目录,按 checksum/版本寻址 | Phase 2 |
|
||||||
| preview session 存储 | 第一阶段使用短期 token + 服务端受控数据;需要审计时再持久化 session | Phase 3 |
|
| preview session 存储 | 第一阶段使用短期 token + 服务端受控数据;需要审计时再持久化 session | Phase 3 |
|
||||||
| 视觉安装模型 | 新增清晰的视觉包安装边界,兼容读取旧行业安装 | Phase 4 |
|
| 视觉安装模型 | 唯一品牌安装记录锁定行业模型和精确视觉包版本,完成一次性迁移并删除旧状态 | Phase 4 |
|
||||||
| renderer 分发 | 第一阶段只引用预部署 renderer;任意新 renderer 走独立可信构建方案 | Phase 1 |
|
| renderer 分发 | 第一阶段只引用预部署 renderer;任意新 renderer 走独立可信构建方案 | Phase 1 |
|
||||||
| 包签名 | 内网 MVP 先 checksum,跨环境或第三方来源前增加签名和信任根 | Phase 2 |
|
| 包签名 | 内网 MVP 先 checksum,跨环境或第三方来源前增加签名和信任根 | Phase 2 |
|
||||||
| 目录可见性 | 未发布版本只给平台管理员,已发布版本才给品牌管理员 | Phase 2 |
|
| 目录可见性 | 未发布版本只给平台管理员,已发布版本才给品牌管理员 | Phase 2 |
|
||||||
| template package version 与 npm package version | 导出前强制一致,若不一致直接阻断 | Phase 1 |
|
| template package version 与 npm package version | 导出前强制一致,若不一致直接阻断 | Phase 1 |
|
||||||
|
|
||||||
## 17. 可观察性和风险
|
## 17. 可观察性和风险
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
- [x] 版本导出、导入、checksum 幂等、目录发布/撤回与审计已由 template pack 和管理 API 实现;
|
- [x] 版本导出、导入、checksum 幂等、目录发布/撤回与审计已由 template pack 和管理 API 实现;
|
||||||
- [x] `/admin/templates` 覆盖导入、校验、预览、发布、撤回和审计;
|
- [x] `/admin/templates` 覆盖导入、校验、预览、发布、撤回和审计;
|
||||||
- [x] 行业安装与视觉包精确版本通过兼容读取和不可变版本台账关联;新安装保存 package version/checksum;
|
- [ ] 品牌安装统一锁定行业模型与精确视觉包版本;当前兼容读取及多处视觉选择状态待由一次性数据迁移收敛后删除;
|
||||||
- [x] 预览 fixture 与显式 bootstrap 内容分离,预览不写入品牌;
|
- [x] 预览 fixture 与显式 bootstrap 内容分离,预览不写入品牌;
|
||||||
- [x] `pnpm template:compatibility` 自动检查 package、行业、平台视觉 manifest、Taro renderer 和 Admin renderer discovery;Runtime contract 及 package schema 由 `pnpm validate:templates` 校验;toolchain 产物由 `pnpm template:conformance` 验证;
|
- [x] `pnpm template:compatibility` 自动检查 package、行业、平台视觉 manifest、Taro renderer 和 Admin renderer discovery;Runtime contract 及 package schema 由 `pnpm validate:templates` 校验;toolchain 产物由 `pnpm template:conformance` 验证;
|
||||||
- [x] atelier-solopreneur 的 manifest/package metadata 版本已统一,并由 validate:templates 阻断后续漂移;
|
- [x] atelier-solopreneur 的 manifest/package metadata 版本已统一,并由 validate:templates 阻断后续漂移;
|
||||||
|
|||||||
@@ -193,15 +193,6 @@ export class ApiClient
|
|||||||
this.resources.brand.createAdminMember(...arguments_);
|
this.resources.brand.createAdminMember(...arguments_);
|
||||||
updateAdminMember = (...arguments_: Parameters<BrandMethods["updateAdminMember"]>) =>
|
updateAdminMember = (...arguments_: Parameters<BrandMethods["updateAdminMember"]>) =>
|
||||||
this.resources.brand.updateAdminMember(...arguments_);
|
this.resources.brand.updateAdminMember(...arguments_);
|
||||||
getAdminVisualTemplatePreview = (
|
|
||||||
...arguments_: Parameters<BrandMethods["getAdminVisualTemplatePreview"]>
|
|
||||||
) => this.resources.brand.getAdminVisualTemplatePreview(...arguments_);
|
|
||||||
getAdminVisualTemplateHistory = (
|
|
||||||
...arguments_: Parameters<BrandMethods["getAdminVisualTemplateHistory"]>
|
|
||||||
) => this.resources.brand.getAdminVisualTemplateHistory(...arguments_);
|
|
||||||
rollbackAdminVisualTemplate = (
|
|
||||||
...arguments_: Parameters<BrandMethods["rollbackAdminVisualTemplate"]>
|
|
||||||
) => this.resources.brand.rollbackAdminVisualTemplate(...arguments_);
|
|
||||||
updateAdminBrand = (...arguments_: Parameters<BrandMethods["updateAdminBrand"]>) =>
|
updateAdminBrand = (...arguments_: Parameters<BrandMethods["updateAdminBrand"]>) =>
|
||||||
this.resources.brand.updateAdminBrand(...arguments_);
|
this.resources.brand.updateAdminBrand(...arguments_);
|
||||||
updateAdminBrandPresentation = (
|
updateAdminBrandPresentation = (
|
||||||
@@ -270,6 +261,9 @@ export class ApiClient
|
|||||||
) => this.resources.template.getAdminPreviewWorkspace(...arguments_);
|
) => this.resources.template.getAdminPreviewWorkspace(...arguments_);
|
||||||
installAdminTemplate = (...arguments_: Parameters<TemplateMethods["installAdminTemplate"]>) =>
|
installAdminTemplate = (...arguments_: Parameters<TemplateMethods["installAdminTemplate"]>) =>
|
||||||
this.resources.template.installAdminTemplate(...arguments_);
|
this.resources.template.installAdminTemplate(...arguments_);
|
||||||
|
selectAdminTemplateVersion = (
|
||||||
|
...arguments_: Parameters<TemplateMethods["selectAdminTemplateVersion"]>
|
||||||
|
) => this.resources.template.selectAdminTemplateVersion(...arguments_);
|
||||||
listAdminCapabilities = (...arguments_: Parameters<TemplateMethods["listAdminCapabilities"]>) =>
|
listAdminCapabilities = (...arguments_: Parameters<TemplateMethods["listAdminCapabilities"]>) =>
|
||||||
this.resources.template.listAdminCapabilities(...arguments_);
|
this.resources.template.listAdminCapabilities(...arguments_);
|
||||||
updateAdminCapability = (...arguments_: Parameters<TemplateMethods["updateAdminCapability"]>) =>
|
updateAdminCapability = (...arguments_: Parameters<TemplateMethods["updateAdminCapability"]>) =>
|
||||||
|
|||||||
@@ -27,20 +27,6 @@ export interface BrandMethods {
|
|||||||
id: string,
|
id: string,
|
||||||
body: Partial<Pick<AdminBrandMember, "role" | "isEnabled">>,
|
body: Partial<Pick<AdminBrandMember, "role" | "isEnabled">>,
|
||||||
): Promise<AdminBrandMember>;
|
): Promise<AdminBrandMember>;
|
||||||
getAdminVisualTemplatePreview(): Promise<{
|
|
||||||
current: {
|
|
||||||
key: string;
|
|
||||||
version: string;
|
|
||||||
name: string;
|
|
||||||
theme: { colors: Record<string, string> };
|
|
||||||
variants: Record<string, string>;
|
|
||||||
} | null;
|
|
||||||
available: string[];
|
|
||||||
}>;
|
|
||||||
getAdminVisualTemplateHistory(): Promise<{
|
|
||||||
history: Array<{ visualTemplateKey: string; savedAt: string }>;
|
|
||||||
}>;
|
|
||||||
rollbackAdminVisualTemplate(): Promise<{ visualTemplateKey: string; rolledBack: boolean }>;
|
|
||||||
updateAdminBrand(body: BrandUpdate): Promise<BrandProfile>;
|
updateAdminBrand(body: BrandUpdate): Promise<BrandProfile>;
|
||||||
updateAdminBrandPresentation(body: BrandPresentationUpdate): Promise<{
|
updateAdminBrandPresentation(body: BrandPresentationUpdate): Promise<{
|
||||||
visualPresentation: Record<string, Record<string, string>>;
|
visualPresentation: Record<string, Record<string, string>>;
|
||||||
@@ -97,10 +83,6 @@ export function brandMethods({ request }: { request: RequestFn }): BrandMethods
|
|||||||
method: "PATCH",
|
method: "PATCH",
|
||||||
body,
|
body,
|
||||||
}),
|
}),
|
||||||
getAdminVisualTemplatePreview: () => request("/admin/config/visual-template/preview"),
|
|
||||||
getAdminVisualTemplateHistory: () => request("/admin/config/visual-template/history"),
|
|
||||||
rollbackAdminVisualTemplate: () =>
|
|
||||||
request("/admin/config/visual-template/rollback", { method: "POST" }),
|
|
||||||
updateAdminBrand: (body) => request("/admin/config/brand", { method: "PATCH", body }),
|
updateAdminBrand: (body) => request("/admin/config/brand", { method: "PATCH", body }),
|
||||||
updateAdminBrandPresentation: (body) =>
|
updateAdminBrandPresentation: (body) =>
|
||||||
request("/admin/config/presentation", { method: "PATCH", body }),
|
request("/admin/config/presentation", { method: "PATCH", body }),
|
||||||
|
|||||||
@@ -67,9 +67,9 @@ export interface TemplateMethods {
|
|||||||
id: string;
|
id: string;
|
||||||
templateKey: BrandTemplateKey;
|
templateKey: BrandTemplateKey;
|
||||||
templateVersion: string;
|
templateVersion: string;
|
||||||
visualTemplateKey: string | null;
|
visualTemplateKey: string;
|
||||||
templatePackageVersionId: string | null;
|
templatePackageVersionId: string;
|
||||||
contentChecksum: string | null;
|
contentChecksum: string;
|
||||||
}>;
|
}>;
|
||||||
fields: BrandFieldDefinition[];
|
fields: BrandFieldDefinition[];
|
||||||
offerings: Offering[];
|
offerings: Offering[];
|
||||||
@@ -80,8 +80,13 @@ export interface TemplateMethods {
|
|||||||
getAdminPreviewWorkspace(): Promise<RuntimeWorkspace>;
|
getAdminPreviewWorkspace(): Promise<RuntimeWorkspace>;
|
||||||
installAdminTemplate(
|
installAdminTemplate(
|
||||||
templateKey: BrandTemplateKey,
|
templateKey: BrandTemplateKey,
|
||||||
templatePackageVersionId?: string,
|
templatePackageVersionId: string,
|
||||||
): Promise<unknown>;
|
): Promise<unknown>;
|
||||||
|
selectAdminTemplateVersion(input: {
|
||||||
|
templatePackageVersionId: string;
|
||||||
|
expectedCurrentPackageVersionId?: string | null;
|
||||||
|
confirm: true;
|
||||||
|
}): Promise<unknown>;
|
||||||
listAdminCapabilities(): Promise<CapabilityWithMetadata[]>;
|
listAdminCapabilities(): Promise<CapabilityWithMetadata[]>;
|
||||||
updateAdminCapability(
|
updateAdminCapability(
|
||||||
key: string,
|
key: string,
|
||||||
@@ -97,11 +102,11 @@ export interface TemplateMethods {
|
|||||||
templateKey: string;
|
templateKey: string;
|
||||||
visualTemplateKey: string;
|
visualTemplateKey: string;
|
||||||
source: {
|
source: {
|
||||||
kind: "package_version" | "registry";
|
kind: "package_version";
|
||||||
packageKey: string;
|
packageKey: string;
|
||||||
version: string;
|
version: string;
|
||||||
contentChecksum: string | null;
|
contentChecksum: string;
|
||||||
templatePackageVersionId?: string;
|
templatePackageVersionId: string;
|
||||||
};
|
};
|
||||||
alreadyImported: boolean;
|
alreadyImported: boolean;
|
||||||
counts: Record<
|
counts: Record<
|
||||||
@@ -124,11 +129,11 @@ export interface TemplateMethods {
|
|||||||
imported: boolean;
|
imported: boolean;
|
||||||
alreadyImported: boolean;
|
alreadyImported: boolean;
|
||||||
source: {
|
source: {
|
||||||
kind: "package_version" | "registry";
|
kind: "package_version";
|
||||||
packageKey: string;
|
packageKey: string;
|
||||||
version: string;
|
version: string;
|
||||||
contentChecksum: string | null;
|
contentChecksum: string;
|
||||||
templatePackageVersionId?: string;
|
templatePackageVersionId: string;
|
||||||
};
|
};
|
||||||
counts: Record<string, number>;
|
counts: Record<string, number>;
|
||||||
}>;
|
}>;
|
||||||
@@ -201,7 +206,6 @@ export interface TemplatePackageVersion {
|
|||||||
packageKey: string;
|
packageKey: string;
|
||||||
version: string;
|
version: string;
|
||||||
displayName: string;
|
displayName: string;
|
||||||
visualTemplateKey: string | null;
|
|
||||||
status: "imported" | "published" | "retired" | "disabled";
|
status: "imported" | "published" | "retired" | "disabled";
|
||||||
contentChecksum: string;
|
contentChecksum: string;
|
||||||
archiveChecksum: string;
|
archiveChecksum: string;
|
||||||
@@ -235,7 +239,7 @@ export interface TemplatePackagePreview {
|
|||||||
workspace: RuntimeWorkspace;
|
workspace: RuntimeWorkspace;
|
||||||
preview: {
|
preview: {
|
||||||
assetFiles: Record<string, { sha256: string; dataUrl: string }>;
|
assetFiles: Record<string, { sha256: string; dataUrl: string }>;
|
||||||
fixtureSource: "previewFixture" | "legacy-sampleContent";
|
fixtureSource: "previewFixture";
|
||||||
safety: { submissions: "disabled"; customerRecords: "disabled"; contactActions: "disabled" };
|
safety: { submissions: "disabled"; customerRecords: "disabled"; contactActions: "disabled" };
|
||||||
session: { token: string; expiresAt: string };
|
session: { token: string; expiresAt: string };
|
||||||
diagnostics: Array<{ code: string; severity: "warning"; message: string }>;
|
diagnostics: Array<{ code: string; severity: "warning"; message: string }>;
|
||||||
@@ -270,7 +274,6 @@ export interface TemplatePackageActionResult {
|
|||||||
| "packageKey"
|
| "packageKey"
|
||||||
| "version"
|
| "version"
|
||||||
| "displayName"
|
| "displayName"
|
||||||
| "visualTemplateKey"
|
|
||||||
| "status"
|
| "status"
|
||||||
| "contentChecksum"
|
| "contentChecksum"
|
||||||
| "archiveChecksum"
|
| "archiveChecksum"
|
||||||
@@ -298,7 +301,6 @@ export interface TemplatePackageImportResult {
|
|||||||
| "packageKey"
|
| "packageKey"
|
||||||
| "version"
|
| "version"
|
||||||
| "displayName"
|
| "displayName"
|
||||||
| "visualTemplateKey"
|
|
||||||
| "status"
|
| "status"
|
||||||
| "contentChecksum"
|
| "contentChecksum"
|
||||||
| "archiveChecksum"
|
| "archiveChecksum"
|
||||||
@@ -375,8 +377,10 @@ export function templateMethods({ request }: { request: RequestFn }): TemplateMe
|
|||||||
installAdminTemplate: (templateKey, templatePackageVersionId) =>
|
installAdminTemplate: (templateKey, templatePackageVersionId) =>
|
||||||
request("/admin/workspace/install", {
|
request("/admin/workspace/install", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: { templateKey, ...(templatePackageVersionId ? { templatePackageVersionId } : {}) },
|
body: { templateKey, templatePackageVersionId },
|
||||||
}),
|
}),
|
||||||
|
selectAdminTemplateVersion: (input) =>
|
||||||
|
request("/admin/workspace/template/select-version", { method: "POST", body: input }),
|
||||||
listAdminCapabilities: () => request("/admin/workspace/capabilities"),
|
listAdminCapabilities: () => request("/admin/workspace/capabilities"),
|
||||||
updateAdminCapability: (key, body) =>
|
updateAdminCapability: (key, body) =>
|
||||||
request(`/admin/workspace/capabilities/${encodeURIComponent(key)}`, {
|
request(`/admin/workspace/capabilities/${encodeURIComponent(key)}`, {
|
||||||
|
|||||||
@@ -8,6 +8,9 @@
|
|||||||
"import": "./dist/index.js"
|
"import": "./dist/index.js"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@personal-brand/template-contract": "workspace:^"
|
||||||
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc -p tsconfig.json",
|
"build": "tsc -p tsconfig.json",
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
@@ -147,5 +147,5 @@ export interface TemplatePackageManifest {
|
|||||||
}[];
|
}[];
|
||||||
overrides?: readonly string[];
|
overrides?: readonly string[];
|
||||||
sampleContent?: Partial<Record<BrandTemplateKey, TemplateSampleContent>>;
|
sampleContent?: Partial<Record<BrandTemplateKey, TemplateSampleContent>>;
|
||||||
previewFixture?: Partial<Record<BrandTemplateKey, TemplatePreviewFixture>>;
|
previewFixture: Readonly<Partial<Record<BrandTemplateKey, TemplatePreviewFixture>>>;
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import { generatedTemplatePackageRegistry } from "./generated-template-packages.js";
|
import { generatedTemplatePackageRegistry } from "./generated-template-packages.js";
|
||||||
import type { TemplatePackageManifest } from "./template-package-manifest.js";
|
import type { TemplatePackageManifest } from "./template-package-manifest.js";
|
||||||
|
export { validateTemplatePackageManifest } from "@personal-brand/template-contract";
|
||||||
|
|
||||||
export const templatePackageRegistry: readonly TemplatePackageManifest[] =
|
export const templatePackageRegistry: readonly TemplatePackageManifest[] =
|
||||||
generatedTemplatePackageRegistry;
|
generatedTemplatePackageRegistry;
|
||||||
@@ -13,24 +14,3 @@ export function getTemplatePackageManifestForVisualKey(
|
|||||||
): TemplatePackageManifest | undefined {
|
): TemplatePackageManifest | undefined {
|
||||||
return templatePackageRegistry.find((item) => item.visualTemplateKey === visualTemplateKey);
|
return templatePackageRegistry.find((item) => item.visualTemplateKey === visualTemplateKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function validateTemplatePackageManifest(manifest: TemplatePackageManifest): string[] {
|
|
||||||
const errors: string[] = [];
|
|
||||||
if (!manifest.packageKey.trim()) errors.push("packageKey is required");
|
|
||||||
if (!manifest.version.trim()) errors.push("version is required");
|
|
||||||
if (manifest.runtimeContract !== "1.0") errors.push("unsupported runtimeContract");
|
|
||||||
if (!manifest.supportedIndustryTemplates.length)
|
|
||||||
errors.push("supportedIndustryTemplates must not be empty");
|
|
||||||
for (const page of [
|
|
||||||
"home",
|
|
||||||
"offerings",
|
|
||||||
"detail",
|
|
||||||
"inquiry",
|
|
||||||
"success",
|
|
||||||
"records",
|
|
||||||
"profile",
|
|
||||||
] as const) {
|
|
||||||
if (!manifest.entrypoints[page]?.trim()) errors.push(`entrypoints.${page} is required`);
|
|
||||||
}
|
|
||||||
return errors;
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,4 @@
|
|||||||
import type { BrandTemplateKey } from "./template-keys.js";
|
import type { BrandTemplateKey } from "./template-keys.js";
|
||||||
import { getDefaultVisualTemplateKey } from "./visual-templates.js";
|
|
||||||
import { templatePackageRegistry } from "./template-packages.js";
|
|
||||||
|
|
||||||
export interface TemplateSampleContent {
|
export interface TemplateSampleContent {
|
||||||
templateKey: BrandTemplateKey;
|
templateKey: BrandTemplateKey;
|
||||||
@@ -33,132 +31,3 @@ export interface TemplateSampleContent {
|
|||||||
}>;
|
}>;
|
||||||
capabilityKey: string;
|
capabilityKey: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const doorsSampleContent: TemplateSampleContent = {
|
|
||||||
templateKey: "doors",
|
|
||||||
inquiryFormName: "门系统咨询表单",
|
|
||||||
offerings: [
|
|
||||||
{
|
|
||||||
kind: "product",
|
|
||||||
name: "序章·入户门",
|
|
||||||
summary: "为别墅入口定制的整樘门系统",
|
|
||||||
categoryKey: "entrance-door",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
kind: "product",
|
|
||||||
name: "庭院·边界门",
|
|
||||||
summary: "连接建筑与庭院的定制门",
|
|
||||||
categoryKey: "garden-door",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
kind: "product",
|
|
||||||
name: "室内·静谧门",
|
|
||||||
summary: "统一室内空间秩序的户内门",
|
|
||||||
categoryKey: "interior-door",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
kind: "service",
|
|
||||||
name: "一对一门系统设计咨询",
|
|
||||||
summary: "从现场到方案的完整设计沟通",
|
|
||||||
categoryKey: "custom",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
trustContent: [
|
|
||||||
{ type: "credential", title: "主理人的门作观", content: "示例内容,待品牌主理人完善。" },
|
|
||||||
{ type: "case", title: "别墅门系统案例", content: "示例内容,待品牌主理人完善。" },
|
|
||||||
{ type: "process", title: "从测量到交付", content: "示例内容,待品牌主理人完善。" },
|
|
||||||
{ type: "credential", title: "材料与工艺标准", content: "示例内容,待品牌主理人完善。" },
|
|
||||||
],
|
|
||||||
fields: [
|
|
||||||
{ key: "projectType", label: "项目类型", type: "select", required: false },
|
|
||||||
{ key: "projectStage", label: "项目阶段", type: "select", required: false },
|
|
||||||
{ key: "siteDescription", label: "项目概况", type: "textarea", required: false },
|
|
||||||
{ key: "phone", label: "联系方式", type: "phone", required: true },
|
|
||||||
],
|
|
||||||
capabilityKey: "doors",
|
|
||||||
};
|
|
||||||
|
|
||||||
const foodSampleContent: TemplateSampleContent = {
|
|
||||||
templateKey: "food",
|
|
||||||
inquiryFormName: "餐品预订与定制表单",
|
|
||||||
offerings: [
|
|
||||||
{
|
|
||||||
kind: "package",
|
|
||||||
name: "示例·今日套餐",
|
|
||||||
summary: "现做家常套餐示例内容。",
|
|
||||||
categoryKey: "set-meal",
|
|
||||||
priceAmount: 2800,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
kind: "service",
|
|
||||||
name: "示例·聚餐定制",
|
|
||||||
summary: "按人数和口味沟通定制餐品。",
|
|
||||||
categoryKey: "private-chef",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
trustContent: [
|
|
||||||
{ type: "credential", title: "关于主理人", content: "示例内容,待品牌主理人完善。" },
|
|
||||||
{ type: "process", title: "从预订到取餐", content: "示例内容,待品牌主理人完善。" },
|
|
||||||
],
|
|
||||||
fields: [
|
|
||||||
{ key: "date", label: "用餐日期", type: "date", required: true },
|
|
||||||
{ key: "number", label: "用餐人数", type: "number", required: true },
|
|
||||||
{ key: "phone", label: "联系方式", type: "phone", required: true },
|
|
||||||
],
|
|
||||||
capabilityKey: "booking",
|
|
||||||
};
|
|
||||||
|
|
||||||
const personalSampleContent: TemplateSampleContent = {
|
|
||||||
templateKey: "personal",
|
|
||||||
inquiryFormName: "合作咨询表单",
|
|
||||||
offerings: [
|
|
||||||
{
|
|
||||||
kind: "service",
|
|
||||||
name: "示例·品牌定位咨询",
|
|
||||||
summary: "梳理品牌定位与下一步行动。",
|
|
||||||
categoryKey: "consulting",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
kind: "service",
|
|
||||||
name: "示例·长期顾问支持",
|
|
||||||
summary: "围绕表达和转化提供持续支持。",
|
|
||||||
categoryKey: "advisory",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
trustContent: [
|
|
||||||
{ type: "credential", title: "关于主理人", content: "示例内容,待品牌主理人完善。" },
|
|
||||||
{ type: "process", title: "合作方法", content: "示例内容,待品牌主理人完善。" },
|
|
||||||
],
|
|
||||||
fields: [
|
|
||||||
{ key: "name", label: "您的称呼", type: "text", required: true },
|
|
||||||
{ key: "phone", label: "联系方式", type: "phone", required: true },
|
|
||||||
{ key: "remark", label: "合作需求", type: "textarea", required: true },
|
|
||||||
],
|
|
||||||
capabilityKey: "inquiry",
|
|
||||||
};
|
|
||||||
|
|
||||||
export const templateSampleContent = {
|
|
||||||
personal: personalSampleContent,
|
|
||||||
food: foodSampleContent,
|
|
||||||
doors: doorsSampleContent,
|
|
||||||
} as const;
|
|
||||||
|
|
||||||
export function getTemplateSampleContent(
|
|
||||||
templateKey: string,
|
|
||||||
visualTemplateKey?: string,
|
|
||||||
): TemplateSampleContent | undefined {
|
|
||||||
const selected = visualTemplateKey
|
|
||||||
? templatePackageRegistry.find(
|
|
||||||
(item) =>
|
|
||||||
item.packageKey === visualTemplateKey &&
|
|
||||||
item.supportedIndustryTemplates.includes(templateKey),
|
|
||||||
)
|
|
||||||
: undefined;
|
|
||||||
if (selected) return selected.sampleContent?.[templateKey];
|
|
||||||
const packageSample = templatePackageRegistry.find(
|
|
||||||
(item) =>
|
|
||||||
item.packageKey === getDefaultVisualTemplateKey(templateKey) &&
|
|
||||||
item.supportedIndustryTemplates.includes(templateKey),
|
|
||||||
)?.sampleContent?.[templateKey];
|
|
||||||
return packageSample ?? templateSampleContent[templateKey as keyof typeof templateSampleContent];
|
|
||||||
}
|
|
||||||
@@ -67,13 +67,3 @@ export const visualTemplateKeys = listVisualTemplateKeys();
|
|||||||
export function getVisualTemplate(key: string): VisualTemplateDefinition | undefined {
|
export function getVisualTemplate(key: string): VisualTemplateDefinition | undefined {
|
||||||
return visualTemplates[key];
|
return visualTemplates[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getDefaultVisualTemplateKey(industryTemplateKey: string): VisualTemplateKey {
|
|
||||||
return (
|
|
||||||
listVisualTemplateKeys().find((key) =>
|
|
||||||
getVisualTemplate(key)?.supportedIndustryTemplates.includes(industryTemplateKey),
|
|
||||||
) ?? defaultVisualTemplateKey
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export const defaultVisualTemplateKey = "linjing-editorial" satisfies VisualTemplateKey;
|
|
||||||
@@ -1539,7 +1539,6 @@
|
|||||||
],
|
],
|
||||||
"capabilityKey": "booking",
|
"capabilityKey": "booking",
|
||||||
"brandConfig": {
|
"brandConfig": {
|
||||||
"visualTemplateKey": "acheng-campus-food",
|
|
||||||
"founder": "阿成",
|
"founder": "阿成",
|
||||||
"title": "私房菜主理人",
|
"title": "私房菜主理人",
|
||||||
"slogan": "认真做好每一顿家常饭。",
|
"slogan": "认真做好每一顿家常饭。",
|
||||||
@@ -1615,5 +1614,394 @@
|
|||||||
"pages/stall-service/index",
|
"pages/stall-service/index",
|
||||||
"pages/bookings/index"
|
"pages/bookings/index"
|
||||||
],
|
],
|
||||||
"overrides": ["pages/inquiry", "pages/inquiry-success", "pages/offering", "pages/records"]
|
"overrides": ["pages/inquiry", "pages/inquiry-success", "pages/offering", "pages/records"],
|
||||||
|
"visualTemplateKey": "acheng-campus-food",
|
||||||
|
"previewFixture": {
|
||||||
|
"food": {
|
||||||
|
"schemaVersion": "1",
|
||||||
|
"brand": {
|
||||||
|
"name": "阿成校园餐 · 预览",
|
||||||
|
"tagline": "用于独立预览的模板演示内容",
|
||||||
|
"description": "此内容仅用于平台模板预览,不代表真实品牌或客户案例。",
|
||||||
|
"deliveryNote": "演示预览已禁用真实咨询和联系操作。"
|
||||||
|
},
|
||||||
|
"content": {
|
||||||
|
"templateKey": "food",
|
||||||
|
"inquiryFormName": "餐品预订与定制表单",
|
||||||
|
"offerings": [
|
||||||
|
{
|
||||||
|
"kind": "package",
|
||||||
|
"name": "示例·今日套餐",
|
||||||
|
"summary": "现做家常套餐示例内容。",
|
||||||
|
"categoryKey": "set-meal",
|
||||||
|
"coverUrl": "/assets/content/package-01.jpg",
|
||||||
|
"priceText": "¥28 起 / 份",
|
||||||
|
"config": {
|
||||||
|
"media": [
|
||||||
|
{
|
||||||
|
"url": "/assets/content/package-01.jpg",
|
||||||
|
"alt": "",
|
||||||
|
"type": "image"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "service",
|
||||||
|
"name": "示例·聚餐定制",
|
||||||
|
"summary": "按人数和口味沟通定制餐品。",
|
||||||
|
"categoryKey": "private-chef",
|
||||||
|
"coverUrl": "/assets/content/private-chef.jpg",
|
||||||
|
"priceText": "按人数和菜单确认",
|
||||||
|
"config": {
|
||||||
|
"media": [
|
||||||
|
{
|
||||||
|
"url": "/assets/content/private-chef.jpg",
|
||||||
|
"alt": "",
|
||||||
|
"type": "image"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "service",
|
||||||
|
"name": "示例·团体餐定制",
|
||||||
|
"summary": "为社团、活动和小型聚会提供批量餐品定制。",
|
||||||
|
"categoryKey": "group-meal",
|
||||||
|
"coverUrl": "/assets/content/private-chef.jpg",
|
||||||
|
"priceText": "按人数和菜单确认",
|
||||||
|
"config": {
|
||||||
|
"media": [
|
||||||
|
{
|
||||||
|
"url": "/assets/content/private-chef.jpg",
|
||||||
|
"alt": "",
|
||||||
|
"type": "image"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"trustContent": [
|
||||||
|
{
|
||||||
|
"type": "schedule",
|
||||||
|
"title": "每周出摊固定日程",
|
||||||
|
"content": "",
|
||||||
|
"config": {
|
||||||
|
"status": "准时出摊",
|
||||||
|
"weekdayLabel": "周一至周五(晚餐 + 夜宵档)",
|
||||||
|
"weekdayTag": "常规固定点",
|
||||||
|
"weekdayDetail": "地点:二号校门外小吃商业街 #07 号铺位",
|
||||||
|
"weekdayHours": "营业:17:00 - 22:30(下雨搭防雨防风棚正常营业)",
|
||||||
|
"weekendLabel": "周六、周日(全天接团体单 + 夜市流动)",
|
||||||
|
"weekendTag": "活动专车",
|
||||||
|
"weekendDetail": "白天专供:球赛、班级春游、社团集训、答辩餐",
|
||||||
|
"weekendHours": "晚间:18:00 - 23:00 体育馆南侧流动出摊"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "coverage",
|
||||||
|
"title": "取餐与配送范围",
|
||||||
|
"content": "",
|
||||||
|
"config": {
|
||||||
|
"pickupTitle": "摊位现场自取",
|
||||||
|
"pickupDetail": "小程序提前留餐,报手机尾号即拿,附赠特制加厚保温袋,不用排长龙。",
|
||||||
|
"deliveryTitle": "校内楼下配送",
|
||||||
|
"deliveryDetail": "满 3 份即可送至宿舍楼栋或实验楼门前,阿成骑专用恒温保温箱电动车直送。"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "process",
|
||||||
|
"title": "定制餐品 4 步流程",
|
||||||
|
"content": "",
|
||||||
|
"config": {
|
||||||
|
"intro": "专为班长、社长、活动干事设计的极简排菜流程",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"title": "提交基本需求",
|
||||||
|
"detail": "选择活动类型(如生日会、社团换届、答辩加餐)、预估人数与预算。"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "15 分钟内核算菜单",
|
||||||
|
"detail": "阿成微信直接联系,提供荤素搭配明细与个性化需求(免辣、清真配料等)。"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "当日新鲜烹饪打包",
|
||||||
|
"detail": "提前 2 小时生鲜采买,铁锅现炒,独立封盒并标注姓名 / 楼栋。"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "保温直达交付",
|
||||||
|
"detail": "约定时间准时送抵指定场地,确认菜品温度与数量无误后结算。"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"minimumNote": "起订门槛:6 份起",
|
||||||
|
"refundNote": "退改:出餐前 2 小时全退"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "credential",
|
||||||
|
"title": "食品安全与制作标准",
|
||||||
|
"content": "示例内容,请根据实际资质和制作标准完善。",
|
||||||
|
"config": {
|
||||||
|
"standards": [
|
||||||
|
{
|
||||||
|
"title": "当天采购",
|
||||||
|
"detail": "按当天需求采买"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "现做现出餐",
|
||||||
|
"detail": "按约定时间制作"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "食具清洁消毒",
|
||||||
|
"detail": "每日清洁与消毒"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "case",
|
||||||
|
"title": "他们都在阿成这订过餐",
|
||||||
|
"summary": "感谢大学城各学院与社团伙伴的信任",
|
||||||
|
"content": "校街舞社年度专场 · 52 人份\n信息学院科创竞赛 · 连签 5 天\n7 号楼庆功宴 · 8 人定制",
|
||||||
|
"config": {
|
||||||
|
"entries": [
|
||||||
|
{
|
||||||
|
"badge": "舞",
|
||||||
|
"title": "校街舞社年度专场(52 人份)",
|
||||||
|
"detail": "保温箱直达大礼堂后台,贴名分装",
|
||||||
|
"result": "零延误签收"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"badge": "科",
|
||||||
|
"title": "信息学院科创竞赛封闭备赛",
|
||||||
|
"detail": "每日荤素轮换,附赠每日滋补老汤",
|
||||||
|
"result": "连签 5 天"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"badge": "寝",
|
||||||
|
"title": "7 号楼庆功宴(8 人定制)",
|
||||||
|
"detail": "定制双拼厚肉饭",
|
||||||
|
"result": "定制餐品"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "promise",
|
||||||
|
"title": "阿成的真实回复承诺",
|
||||||
|
"content": "备料期 15 分钟内联系,出摊高峰 1 小时内回复。",
|
||||||
|
"config": {
|
||||||
|
"commitments": [
|
||||||
|
{
|
||||||
|
"label": "非出摊备料期",
|
||||||
|
"detail": "提交咨询后通过微信或电话沟通。",
|
||||||
|
"highlight": "15 分钟内"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "出摊晚高峰",
|
||||||
|
"detail": "正在出餐,稍有延迟,会抽空回复。",
|
||||||
|
"highlight": "1 小时内"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"key": "type",
|
||||||
|
"label": "咨询类型",
|
||||||
|
"type": "select",
|
||||||
|
"required": true,
|
||||||
|
"options": [
|
||||||
|
{
|
||||||
|
"label": "日常留餐",
|
||||||
|
"value": "日常留餐"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "宿舍开黑餐",
|
||||||
|
"value": "宿舍开黑餐"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "社团 / 班级活动",
|
||||||
|
"value": "社团 / 班级活动"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "生日聚会",
|
||||||
|
"value": "生日聚会"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "考试周加餐",
|
||||||
|
"value": "考试周加餐"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "其他需求",
|
||||||
|
"value": "其他需求"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "people",
|
||||||
|
"label": "用餐人数",
|
||||||
|
"type": "select",
|
||||||
|
"required": true,
|
||||||
|
"options": [
|
||||||
|
{
|
||||||
|
"label": "1 人(单点)",
|
||||||
|
"value": "1 人(单点)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "2-4 人(寝室小聚)",
|
||||||
|
"value": "2-4 人(寝室小聚)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "5-10 人(部门小聚)",
|
||||||
|
"value": "5-10 人(部门小聚)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "10-30 人(社团活动)",
|
||||||
|
"value": "10-30 人(社团活动)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "30 人以上(大型活动)",
|
||||||
|
"value": "30 人以上(大型活动)"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "date",
|
||||||
|
"label": "用餐日期",
|
||||||
|
"type": "date",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "budget",
|
||||||
|
"label": "人均预算",
|
||||||
|
"type": "select",
|
||||||
|
"required": false,
|
||||||
|
"options": [
|
||||||
|
{
|
||||||
|
"label": "15 元左右 / 人(实惠)",
|
||||||
|
"value": "15 元左右 / 人(实惠)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "18-22 元 / 人(荤素双拼)",
|
||||||
|
"value": "18-22 元 / 人(荤素双拼)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "25 元以上 / 人(高规格定制)",
|
||||||
|
"value": "25 元以上 / 人(高规格定制)"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "delivery",
|
||||||
|
"label": "取餐 / 配送方式",
|
||||||
|
"type": "select",
|
||||||
|
"required": false,
|
||||||
|
"options": [
|
||||||
|
{
|
||||||
|
"label": "摊位自取(报手机尾号即拿)",
|
||||||
|
"value": "摊位自取(报手机尾号即拿)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "送至宿舍楼下(满 3 份)",
|
||||||
|
"value": "送至宿舍楼下(满 3 份)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "送至指定教室 / 场地",
|
||||||
|
"value": "送至指定教室 / 场地"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "remark",
|
||||||
|
"label": "餐品 / 口味 / 忌口备注",
|
||||||
|
"type": "textarea",
|
||||||
|
"required": false,
|
||||||
|
"placeholder": "例:现炒牛肉饭 1 份,微辣多浇卤汁,不要香菜"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "phone",
|
||||||
|
"label": "联系手机",
|
||||||
|
"type": "phone",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"capabilityKey": "booking",
|
||||||
|
"brandConfig": {
|
||||||
|
"founder": "阿成",
|
||||||
|
"title": "私房菜主理人",
|
||||||
|
"slogan": "认真做好每一顿家常饭。",
|
||||||
|
"phone": "",
|
||||||
|
"wechat": "",
|
||||||
|
"studioAddress": "大学城生活区东门附近",
|
||||||
|
"avatarUrl": "/assets/owner/portrait.jpg",
|
||||||
|
"heroImage": "/assets/content/package-01.jpg",
|
||||||
|
"visualPresentation": {
|
||||||
|
"home": {
|
||||||
|
"stallTitle": "服务地点",
|
||||||
|
"primaryAction": "咨询 / 预订",
|
||||||
|
"secondaryAction": "查看菜单",
|
||||||
|
"worksEyebrow": "今日推荐",
|
||||||
|
"worksTitle": "热门套餐",
|
||||||
|
"worksAction": "查看全部 →",
|
||||||
|
"manifestoTitle": "我们的服务承诺"
|
||||||
|
},
|
||||||
|
"offerings": {
|
||||||
|
"title": "餐品与定制",
|
||||||
|
"subtitle": "现做家常餐、团体餐和活动定制",
|
||||||
|
"materialLabel": "包含:",
|
||||||
|
"hardwareLabel": "定制说明:",
|
||||||
|
"detailAction": "查看详情 →",
|
||||||
|
"inquiryAction": "预订 / 咨询"
|
||||||
|
},
|
||||||
|
"detail": {
|
||||||
|
"priceLabel": "价格参考",
|
||||||
|
"spaceLabel": "适合场景",
|
||||||
|
"backgroundTitle": "餐品说明",
|
||||||
|
"conceptTitle": "备餐方式",
|
||||||
|
"craftsTitle": "服务内容",
|
||||||
|
"materialsTitle": "交付说明",
|
||||||
|
"inquiryAction": "预订 / 咨询",
|
||||||
|
"inquiryHint": "提交后会由主理人与你确认时间、数量和地点。"
|
||||||
|
},
|
||||||
|
"profile": {
|
||||||
|
"phoneLabel": "联系电话",
|
||||||
|
"wechatLabel": "微信",
|
||||||
|
"addressLabel": "服务地点",
|
||||||
|
"callAction": "呼叫",
|
||||||
|
"copyAction": "复制",
|
||||||
|
"recordsTitle": "我的订单与咨询",
|
||||||
|
"recordsCountUnit": "条记录"
|
||||||
|
},
|
||||||
|
"inquiry": {
|
||||||
|
"eyebrow": "ORDER",
|
||||||
|
"title": "餐品预订",
|
||||||
|
"subtitle": "留下用餐时间和人数,我会尽快确认。",
|
||||||
|
"submitLabel": "提交预订需求"
|
||||||
|
},
|
||||||
|
"success": {
|
||||||
|
"eyebrow": "ORDER",
|
||||||
|
"title": "已收到你的需求",
|
||||||
|
"intro": "确认备餐时间和数量后,我会尽快回复。",
|
||||||
|
"recordsAction": "查看咨询记录",
|
||||||
|
"homeAction": "返回首页"
|
||||||
|
},
|
||||||
|
"records": {
|
||||||
|
"title": "我的咨询记录",
|
||||||
|
"createAction": "新增咨询",
|
||||||
|
"emptyTitle": "还没有咨询记录",
|
||||||
|
"emptyDescription": "提交一次需求,开始与主理人沟通。",
|
||||||
|
"emptyAction": "开始咨询"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"safety": {
|
||||||
|
"submissions": "disabled",
|
||||||
|
"customerRecords": "disabled",
|
||||||
|
"contactActions": "disabled"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+24
@@ -2,6 +2,7 @@
|
|||||||
"packageKey": "drill-consultant",
|
"packageKey": "drill-consultant",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"displayName": "咨询师演练模板",
|
"displayName": "咨询师演练模板",
|
||||||
|
"visualTemplateKey": "drill-consultant",
|
||||||
"defaultBrandSlug": "drill-consultant",
|
"defaultBrandSlug": "drill-consultant",
|
||||||
"runtimeContract": "1.0",
|
"runtimeContract": "1.0",
|
||||||
"supportedIndustryTemplates": ["consulting"],
|
"supportedIndustryTemplates": ["consulting"],
|
||||||
@@ -54,5 +55,28 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"previewFixture": {
|
||||||
|
"consulting": {
|
||||||
|
"schemaVersion": "1",
|
||||||
|
"brand": {
|
||||||
|
"name": "咨询师演练",
|
||||||
|
"tagline": "用于编译器测试的虚构品牌",
|
||||||
|
"description": "此内容仅用于模板编译器测试。"
|
||||||
|
},
|
||||||
|
"content": {
|
||||||
|
"templateKey": "consulting",
|
||||||
|
"inquiryFormName": "演练咨询表单",
|
||||||
|
"capabilityKey": "inquiry",
|
||||||
|
"offerings": [],
|
||||||
|
"trustContent": [],
|
||||||
|
"fields": []
|
||||||
|
},
|
||||||
|
"safety": {
|
||||||
|
"submissions": "disabled",
|
||||||
|
"customerRecords": "disabled",
|
||||||
|
"contactActions": "disabled"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -137,6 +137,7 @@ export type TemplatePackageManifest = {
|
|||||||
packageKey: string;
|
packageKey: string;
|
||||||
version: string;
|
version: string;
|
||||||
displayName: string;
|
displayName: string;
|
||||||
|
visualTemplateKey: string;
|
||||||
runtimeContract: typeof TEMPLATE_RUNTIME_CONTRACT;
|
runtimeContract: typeof TEMPLATE_RUNTIME_CONTRACT;
|
||||||
supportedIndustryTemplates: string[];
|
supportedIndustryTemplates: string[];
|
||||||
entrypoints: Record<string, string>;
|
entrypoints: Record<string, string>;
|
||||||
@@ -160,22 +161,21 @@ export type TemplatePackageManifest = {
|
|||||||
admin: TemplateAdminManifest;
|
admin: TemplateAdminManifest;
|
||||||
trustContentTypes?: TemplateTrustContentType[];
|
trustContentTypes?: TemplateTrustContentType[];
|
||||||
sampleContent?: Record<string, TemplateSampleContent>;
|
sampleContent?: Record<string, TemplateSampleContent>;
|
||||||
previewFixture?: Record<string, unknown>;
|
previewFixture: Record<string, unknown>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function validateTemplatePackageManifest(value: unknown): string[] {
|
export function validateTemplatePackageManifest(value: unknown): string[] {
|
||||||
const errors: string[] = [];
|
const errors: string[] = [];
|
||||||
if (!value || typeof value !== "object") return ["manifest must be an object"];
|
if (!value || typeof value !== "object") return ["manifest must be an object"];
|
||||||
const manifest = value as Partial<TemplatePackageManifest>;
|
const manifest = value as Partial<TemplatePackageManifest>;
|
||||||
if (manifest.previewFixture !== undefined) {
|
for (const issue of validateTemplatePreviewFixtures(
|
||||||
for (const issue of validateTemplatePreviewFixtures(
|
manifest.previewFixture,
|
||||||
manifest.previewFixture,
|
manifest.supportedIndustryTemplates ?? [],
|
||||||
manifest.supportedIndustryTemplates ?? [],
|
))
|
||||||
))
|
errors.push(`previewFixture.${issue.path}: ${issue.message}`);
|
||||||
errors.push(`previewFixture.${issue.path}: ${issue.message}`);
|
|
||||||
}
|
|
||||||
if (!manifest.packageKey?.trim()) errors.push("packageKey is required");
|
if (!manifest.packageKey?.trim()) errors.push("packageKey is required");
|
||||||
if (!manifest.version?.trim()) errors.push("version is required");
|
if (!manifest.version?.trim()) errors.push("version is required");
|
||||||
|
if (!manifest.visualTemplateKey?.trim()) errors.push("visualTemplateKey is required");
|
||||||
if (manifest.runtimeContract !== TEMPLATE_RUNTIME_CONTRACT)
|
if (manifest.runtimeContract !== TEMPLATE_RUNTIME_CONTRACT)
|
||||||
errors.push(`runtimeContract must be ${TEMPLATE_RUNTIME_CONTRACT}`);
|
errors.push(`runtimeContract must be ${TEMPLATE_RUNTIME_CONTRACT}`);
|
||||||
if (!manifest.displayName?.trim()) errors.push("displayName is required");
|
if (!manifest.displayName?.trim()) errors.push("displayName is required");
|
||||||
|
|||||||
@@ -58,6 +58,14 @@ for (const key of ["acheng-campus-food", "linjing-editorial"]) {
|
|||||||
test("template contract rejects technical or incomplete admin declarations", () => {
|
test("template contract rejects technical or incomplete admin declarations", () => {
|
||||||
const manifestPath = path.join(packageRoot, "template-acheng-campus-food/template.json");
|
const manifestPath = path.join(packageRoot, "template-acheng-campus-food/template.json");
|
||||||
const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
|
const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
|
||||||
|
const previewFixture = structuredClone(manifest.previewFixture);
|
||||||
|
delete manifest.previewFixture;
|
||||||
|
assert.ok(
|
||||||
|
validateTemplatePackageManifest(manifest).some((message) =>
|
||||||
|
message.startsWith("previewFixture"),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
manifest.previewFixture = previewFixture;
|
||||||
manifest.admin.sections[0].fields[0].label = "";
|
manifest.admin.sections[0].fields[0].label = "";
|
||||||
manifest.assetSlots[0].help = "";
|
manifest.assetSlots[0].help = "";
|
||||||
assert.deepEqual(validateTemplatePackageManifest(manifest), [
|
assert.deepEqual(validateTemplatePackageManifest(manifest), [
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@personal-brand/template-linjing-editorial",
|
"name": "@personal-brand/template-linjing-editorial",
|
||||||
"version": "1.0.4",
|
"version": "1.0.5",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"files": [
|
"files": [
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"packageKey": "linjing-editorial",
|
"packageKey": "linjing-editorial",
|
||||||
"version": "1.0.4",
|
"version": "1.0.5",
|
||||||
"displayName": "林境建筑画册",
|
"displayName": "林境建筑画册",
|
||||||
"defaultBrandSlug": "linjing-doors",
|
"defaultBrandSlug": "linjing-doors",
|
||||||
"runtimeContract": "1.0",
|
"runtimeContract": "1.0",
|
||||||
@@ -1336,8 +1336,14 @@
|
|||||||
"hardware": "德国 dormakaba 重型地弹簧 + 定制实心锻铜一体式长执手",
|
"hardware": "德国 dormakaba 重型地弹簧 + 定制实心锻铜一体式长执手",
|
||||||
"details": {
|
"details": {
|
||||||
"materialsList": [
|
"materialsList": [
|
||||||
{ "name": "门扇主体", "spec": "航空铝蜂窝 + 防暴钢板 + 黑胡桃" },
|
{
|
||||||
{ "name": "承重结构", "spec": "不锈钢重型天地偏心轴" }
|
"name": "门扇主体",
|
||||||
|
"spec": "航空铝蜂窝 + 防暴钢板 + 黑胡桃"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "承重结构",
|
||||||
|
"spec": "不锈钢重型天地偏心轴"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"media": [
|
"media": [
|
||||||
@@ -1361,8 +1367,14 @@
|
|||||||
"hardware": "意大利全隐形地埋式液压自闭器 + 静音电控锁",
|
"hardware": "意大利全隐形地埋式液压自闭器 + 静音电控锁",
|
||||||
"details": {
|
"details": {
|
||||||
"materialsList": [
|
"materialsList": [
|
||||||
{ "name": "户外木种", "spec": "高油脂老料缅甸柚木" },
|
{
|
||||||
{ "name": "骨架型材", "spec": "高强度航空铝镁合金" }
|
"name": "户外木种",
|
||||||
|
"spec": "高油脂老料缅甸柚木"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "骨架型材",
|
||||||
|
"spec": "高强度航空铝镁合金"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"media": [
|
"media": [
|
||||||
@@ -1386,8 +1398,14 @@
|
|||||||
"hardware": "意大利 AGB 磁吸静音门锁 + 隐藏式暗铰链",
|
"hardware": "意大利 AGB 磁吸静音门锁 + 隐藏式暗铰链",
|
||||||
"details": {
|
"details": {
|
||||||
"materialsList": [
|
"materialsList": [
|
||||||
{ "name": "抗弯核心", "spec": "双组份碳纤维预应力防变形拉力杆" },
|
{
|
||||||
{ "name": "吸音内衬", "spec": "德国均质空心桥洞力学板" }
|
"name": "抗弯核心",
|
||||||
|
"spec": "双组份碳纤维预应力防变形拉力杆"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "吸音内衬",
|
||||||
|
"spec": "德国均质空心桥洞力学板"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"media": [
|
"media": [
|
||||||
@@ -1411,8 +1429,14 @@
|
|||||||
"hardware": "感应式电动自开闭装置或碰珠反弹器",
|
"hardware": "感应式电动自开闭装置或碰珠反弹器",
|
||||||
"details": {
|
"details": {
|
||||||
"materialsList": [
|
"materialsList": [
|
||||||
{ "name": "表面饰材", "spec": "意大利雪山银狐超薄天然大理石" },
|
{
|
||||||
{ "name": "驱动系统", "spec": "低噪步进电机伺服闭门器" }
|
"name": "表面饰材",
|
||||||
|
"spec": "意大利雪山银狐超薄天然大理石"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "驱动系统",
|
||||||
|
"spec": "低噪步进电机伺服闭门器"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"media": [
|
"media": [
|
||||||
@@ -1432,10 +1456,26 @@
|
|||||||
"content": "国家注册高级室内建筑师,专注高定大门及私宅空间门类系统研发 14 年。",
|
"content": "国家注册高级室内建筑师,专注高定大门及私宅空间门类系统研发 14 年。",
|
||||||
"config": {
|
"config": {
|
||||||
"stats": [
|
"stats": [
|
||||||
{ "value": "14年", "label": "高端门系深化经验", "sub": "历经百项严苛私宅考验" },
|
{
|
||||||
{ "value": "260+", "label": "落地庄园实景案例", "sub": "全实景图库,可预约探访" },
|
"value": "14年",
|
||||||
{ "value": "100%", "label": "主理人全案跟进", "sub": "量房 / 出图 / 选料 / 试装" },
|
"label": "高端门系深化经验",
|
||||||
{ "value": "10年", "label": "结构主轴质保承诺", "sub": "终生五金润滑维保机制" }
|
"sub": "历经百项严苛私宅考验"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "260+",
|
||||||
|
"label": "落地庄园实景案例",
|
||||||
|
"sub": "全实景图库,可预约探访"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "100%",
|
||||||
|
"label": "主理人全案跟进",
|
||||||
|
"sub": "量房 / 出图 / 选料 / 试装"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "10年",
|
||||||
|
"label": "结构主轴质保承诺",
|
||||||
|
"sub": "终生五金润滑维保机制"
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"pillars": [
|
"pillars": [
|
||||||
{
|
{
|
||||||
@@ -1452,12 +1492,36 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"serviceFlow": [
|
"serviceFlow": [
|
||||||
{ "step": "01", "name": "私享沟通", "desc": "厘清生活动线与风候环境" },
|
{
|
||||||
{ "step": "02", "name": "上门实测", "desc": "复核门洞公差与地平基准" },
|
"step": "01",
|
||||||
{ "step": "03", "name": "构造出图", "desc": "输出结构图与材质节点方案" },
|
"name": "私享沟通",
|
||||||
{ "step": "04", "name": "实样工坊确认", "desc": "确认木样、锻铜样与密封节点" },
|
"desc": "厘清生活动线与风候环境"
|
||||||
{ "step": "05", "name": "工坊试装交付", "desc": "试装调试后专车直运现场" },
|
},
|
||||||
{ "step": "06", "name": "终生私属维护", "desc": "建立一门一档数字化档案" }
|
{
|
||||||
|
"step": "02",
|
||||||
|
"name": "上门实测",
|
||||||
|
"desc": "复核门洞公差与地平基准"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"step": "03",
|
||||||
|
"name": "构造出图",
|
||||||
|
"desc": "输出结构图与材质节点方案"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"step": "04",
|
||||||
|
"name": "实样工坊确认",
|
||||||
|
"desc": "确认木样、锻铜样与密封节点"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"step": "05",
|
||||||
|
"name": "工坊试装交付",
|
||||||
|
"desc": "试装调试后专车直运现场"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"step": "06",
|
||||||
|
"name": "终生私属维护",
|
||||||
|
"desc": "建立一门一档数字化档案"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -1592,7 +1656,6 @@
|
|||||||
],
|
],
|
||||||
"capabilityKey": "inquiry",
|
"capabilityKey": "inquiry",
|
||||||
"brandConfig": {
|
"brandConfig": {
|
||||||
"visualTemplateKey": "linjing-editorial",
|
|
||||||
"templateData": {
|
"templateData": {
|
||||||
"designPhilosophy": "先厘清问题,再设计表达"
|
"designPhilosophy": "先厘清问题,再设计表达"
|
||||||
},
|
},
|
||||||
@@ -1756,7 +1819,6 @@
|
|||||||
],
|
],
|
||||||
"capabilityKey": "inquiry",
|
"capabilityKey": "inquiry",
|
||||||
"brandConfig": {
|
"brandConfig": {
|
||||||
"visualTemplateKey": "linjing-editorial",
|
|
||||||
"templateData": {
|
"templateData": {
|
||||||
"designPhilosophy": "先厘清问题,再设计表达"
|
"designPhilosophy": "先厘清问题,再设计表达"
|
||||||
},
|
},
|
||||||
@@ -1830,5 +1892,607 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"pages": ["pages/index/index", "pages/services/index", "pages/bookings/index"]
|
"pages": ["pages/index/index", "pages/services/index", "pages/bookings/index"],
|
||||||
|
"visualTemplateKey": "linjing-editorial",
|
||||||
|
"previewFixture": {
|
||||||
|
"doors": {
|
||||||
|
"schemaVersion": "1",
|
||||||
|
"brand": {
|
||||||
|
"name": "林境建筑画册 · 预览",
|
||||||
|
"tagline": "用于独立预览的模板演示内容",
|
||||||
|
"description": "此内容仅用于平台模板预览,不代表真实品牌或客户案例。",
|
||||||
|
"deliveryNote": "演示预览已禁用真实咨询和联系操作。"
|
||||||
|
},
|
||||||
|
"content": {
|
||||||
|
"templateKey": "doors",
|
||||||
|
"inquiryFormName": "门系统咨询表单",
|
||||||
|
"offerings": [
|
||||||
|
{
|
||||||
|
"kind": "product",
|
||||||
|
"name": "序章·入户门",
|
||||||
|
"summary": "为别墅入口定制的整樘门系统",
|
||||||
|
"categoryKey": "entrance-door",
|
||||||
|
"coverUrl": "/assets/content/doors-hero.jpg",
|
||||||
|
"priceText": "按项目确认",
|
||||||
|
"config": {
|
||||||
|
"series": "「万籁」重型天地轴入户系统",
|
||||||
|
"hardware": "德国 dormakaba 重型地弹簧 + 定制实心锻铜一体式长执手",
|
||||||
|
"details": {
|
||||||
|
"materialsList": [
|
||||||
|
{
|
||||||
|
"name": "门扇主体",
|
||||||
|
"spec": "航空铝蜂窝 + 防暴钢板 + 黑胡桃"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "承重结构",
|
||||||
|
"spec": "不锈钢重型天地偏心轴"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"media": [
|
||||||
|
{
|
||||||
|
"url": "/assets/content/doors-hero.jpg",
|
||||||
|
"alt": "",
|
||||||
|
"type": "image"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "product",
|
||||||
|
"name": "庭院·边界门",
|
||||||
|
"summary": "连接建筑与庭院的定制门",
|
||||||
|
"categoryKey": "garden-door",
|
||||||
|
"coverUrl": "/assets/content/doors-yard-gate.jpg",
|
||||||
|
"priceText": "按项目确认",
|
||||||
|
"config": {
|
||||||
|
"series": "「虚实」透光私家庭院门",
|
||||||
|
"hardware": "意大利全隐形地埋式液压自闭器 + 静音电控锁",
|
||||||
|
"details": {
|
||||||
|
"materialsList": [
|
||||||
|
{
|
||||||
|
"name": "户外木种",
|
||||||
|
"spec": "高油脂老料缅甸柚木"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "骨架型材",
|
||||||
|
"spec": "高强度航空铝镁合金"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"media": [
|
||||||
|
{
|
||||||
|
"url": "/assets/content/doors-yard-gate.jpg",
|
||||||
|
"alt": "",
|
||||||
|
"type": "image"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "product",
|
||||||
|
"name": "室内·静谧门",
|
||||||
|
"summary": "统一室内空间秩序的户内门",
|
||||||
|
"categoryKey": "interior-door",
|
||||||
|
"coverUrl": "/assets/content/doors-room-door.jpg",
|
||||||
|
"priceText": "按项目确认",
|
||||||
|
"config": {
|
||||||
|
"series": "「空灵」2.8m - 3.2m 满高通顶系统",
|
||||||
|
"hardware": "意大利 AGB 磁吸静音门锁 + 隐藏式暗铰链",
|
||||||
|
"details": {
|
||||||
|
"materialsList": [
|
||||||
|
{
|
||||||
|
"name": "抗弯核心",
|
||||||
|
"spec": "双组份碳纤维预应力防变形拉力杆"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "吸音内衬",
|
||||||
|
"spec": "德国均质空心桥洞力学板"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"media": [
|
||||||
|
{
|
||||||
|
"url": "/assets/content/doors-room-door.jpg",
|
||||||
|
"alt": "",
|
||||||
|
"type": "image"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "service",
|
||||||
|
"name": "一对一门系统设计咨询",
|
||||||
|
"summary": "从现场到方案的完整设计沟通",
|
||||||
|
"categoryKey": "custom",
|
||||||
|
"coverUrl": "/assets/content/personal-consulting.jpg",
|
||||||
|
"priceText": "按项目确认",
|
||||||
|
"config": {
|
||||||
|
"series": "「无垠」密室及背景墙融合门",
|
||||||
|
"hardware": "感应式电动自开闭装置或碰珠反弹器",
|
||||||
|
"details": {
|
||||||
|
"materialsList": [
|
||||||
|
{
|
||||||
|
"name": "表面饰材",
|
||||||
|
"spec": "意大利雪山银狐超薄天然大理石"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "驱动系统",
|
||||||
|
"spec": "低噪步进电机伺服闭门器"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"media": [
|
||||||
|
{
|
||||||
|
"url": "/assets/content/personal-consulting.jpg",
|
||||||
|
"alt": "",
|
||||||
|
"type": "image"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"trustContent": [
|
||||||
|
{
|
||||||
|
"type": "credential",
|
||||||
|
"title": "主理人的门作观",
|
||||||
|
"content": "国家注册高级室内建筑师,专注高定大门及私宅空间门类系统研发 14 年。",
|
||||||
|
"config": {
|
||||||
|
"stats": [
|
||||||
|
{
|
||||||
|
"value": "14年",
|
||||||
|
"label": "高端门系深化经验",
|
||||||
|
"sub": "历经百项严苛私宅考验"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "260+",
|
||||||
|
"label": "落地庄园实景案例",
|
||||||
|
"sub": "全实景图库,可预约探访"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "100%",
|
||||||
|
"label": "主理人全案跟进",
|
||||||
|
"sub": "量房 / 出图 / 选料 / 试装"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "10年",
|
||||||
|
"label": "结构主轴质保承诺",
|
||||||
|
"sub": "终生五金润滑维保机制"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"pillars": [
|
||||||
|
{
|
||||||
|
"title": "天然厚板与古铜锻打",
|
||||||
|
"desc": "精选天然木材与手工冷锻紫铜,构建长期耐用的门体结构。"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "微米级红外高精量房",
|
||||||
|
"desc": "通过 3D 空间激光扫描复核门洞公差与建筑墙体垂直度。"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "隐匿式重型五金系统",
|
||||||
|
"desc": "使用可调静音承重铰链,让重型门体开合轻盈安静。"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"serviceFlow": [
|
||||||
|
{
|
||||||
|
"step": "01",
|
||||||
|
"name": "私享沟通",
|
||||||
|
"desc": "厘清生活动线与风候环境"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"step": "02",
|
||||||
|
"name": "上门实测",
|
||||||
|
"desc": "复核门洞公差与地平基准"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"step": "03",
|
||||||
|
"name": "构造出图",
|
||||||
|
"desc": "输出结构图与材质节点方案"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"step": "04",
|
||||||
|
"name": "实样工坊确认",
|
||||||
|
"desc": "确认木样、锻铜样与密封节点"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"step": "05",
|
||||||
|
"name": "工坊试装交付",
|
||||||
|
"desc": "试装调试后专车直运现场"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"step": "06",
|
||||||
|
"name": "终生私属维护",
|
||||||
|
"desc": "建立一门一档数字化档案"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "case",
|
||||||
|
"title": "别墅门系统案例",
|
||||||
|
"content": "示例内容,待品牌主理人完善。"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "process",
|
||||||
|
"title": "从测量到交付",
|
||||||
|
"content": "示例内容,待品牌主理人完善。"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"key": "doorType",
|
||||||
|
"label": "期望定制的门类型",
|
||||||
|
"type": "select",
|
||||||
|
"required": true,
|
||||||
|
"options": [
|
||||||
|
{
|
||||||
|
"label": "入户大门(防暴铸铜 / 实木)",
|
||||||
|
"value": "entry"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "庭院围墙门(耐候格栅 / 对开)",
|
||||||
|
"value": "yard"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "全屋室内门系统(通顶隐形)",
|
||||||
|
"value": "interior"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "背景墙一体门 / 密室门",
|
||||||
|
"value": "wall"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "整栋别墅门系统全案一体化",
|
||||||
|
"value": "whole-home"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "cityArea",
|
||||||
|
"label": "房屋 / 别墅所在城市与楼盘",
|
||||||
|
"type": "text",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "projectStage",
|
||||||
|
"label": "项目阶段",
|
||||||
|
"type": "select",
|
||||||
|
"required": true,
|
||||||
|
"options": [
|
||||||
|
{
|
||||||
|
"label": "土建结构阶段(适合预埋加固)",
|
||||||
|
"value": "structure"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "水电木工阶段(适合精确测距)",
|
||||||
|
"value": "rough-in"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "硬装收尾阶段",
|
||||||
|
"value": "finishing"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "旧宅门体翻新改造",
|
||||||
|
"value": "renovation"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "budgetRange",
|
||||||
|
"label": "预估门系统投资预算",
|
||||||
|
"type": "select",
|
||||||
|
"required": false,
|
||||||
|
"options": [
|
||||||
|
{
|
||||||
|
"label": "5 万 - 10 万",
|
||||||
|
"value": "50k-100k"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "10 万 - 20 万",
|
||||||
|
"value": "100k-200k"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "20 万 - 50 万(全宅全案)",
|
||||||
|
"value": "200k-500k"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "50 万以上(顶级孤品定制)",
|
||||||
|
"value": "500k-plus"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "needMeasure",
|
||||||
|
"label": "是否需要主理人上门现场量房",
|
||||||
|
"type": "radio",
|
||||||
|
"required": true,
|
||||||
|
"options": [
|
||||||
|
{
|
||||||
|
"label": "需要(预约排期现场勘测)",
|
||||||
|
"value": "需要(预约排期现场勘测)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "暂不需要(先发图纸在线深化评估)",
|
||||||
|
"value": "暂不需要(先发图纸在线深化评估)"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "contactName",
|
||||||
|
"label": "贵姓称谓",
|
||||||
|
"type": "text",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "contactPhone",
|
||||||
|
"label": "联系手机号(微信同号)",
|
||||||
|
"type": "tel",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "specialNote",
|
||||||
|
"label": "空间想法或特殊需求描述",
|
||||||
|
"type": "textarea",
|
||||||
|
"required": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"capabilityKey": "inquiry",
|
||||||
|
"brandConfig": {
|
||||||
|
"templateData": {
|
||||||
|
"designPhilosophy": "先厘清问题,再设计表达"
|
||||||
|
},
|
||||||
|
"title": "高端门系统建筑研造主理人",
|
||||||
|
"slogan": "为当代别墅空间,定制有秩序感与呼吸感的门",
|
||||||
|
"phone": "186-0218-9908",
|
||||||
|
"wechat": "LIN-ATELIER-2024",
|
||||||
|
"studioAddress": "上海市静安区威海路设计中心 A 座 / 杭州良渚研造工坊",
|
||||||
|
"avatarUrl": "/assets/content/personal-avatar.jpg",
|
||||||
|
"heroImage": "/assets/content/doors-hero.jpg",
|
||||||
|
"visualPresentation": {
|
||||||
|
"home": {
|
||||||
|
"founderBadge": "接受项目沟通",
|
||||||
|
"proofEyebrow": "专业经验与合作成果",
|
||||||
|
"proofTitle": "14 年,只做门与空间的关系",
|
||||||
|
"manifestoEyebrow": "工作原则",
|
||||||
|
"manifestoTitle": "先厘清问题,再设计表达",
|
||||||
|
"worksEyebrow": "项目案例",
|
||||||
|
"worksTitle": "门系统项目",
|
||||||
|
"worksAction": "查看全部 →"
|
||||||
|
},
|
||||||
|
"offerings": {
|
||||||
|
"title": "门系统项目",
|
||||||
|
"subtitle": "从入户门到室内门的一体化设计",
|
||||||
|
"materialLabel": "包含:",
|
||||||
|
"hardwareLabel": "定制说明:",
|
||||||
|
"detailAction": "查看详情 →",
|
||||||
|
"inquiryAction": "发起咨询"
|
||||||
|
},
|
||||||
|
"detail": {
|
||||||
|
"priceLabel": "价格参考",
|
||||||
|
"spaceLabel": "适合场景",
|
||||||
|
"backgroundTitle": "项目背景",
|
||||||
|
"conceptTitle": "设计思路",
|
||||||
|
"craftsTitle": "交付要点",
|
||||||
|
"materialsTitle": "材料与说明",
|
||||||
|
"inquiryAction": "发起咨询",
|
||||||
|
"inquiryHint": "提交信息后由主理人与您沟通。"
|
||||||
|
},
|
||||||
|
"profile": {
|
||||||
|
"phoneLabel": "联系电话",
|
||||||
|
"wechatLabel": "微信",
|
||||||
|
"addressLabel": "工作地点",
|
||||||
|
"callAction": "呼叫",
|
||||||
|
"copyAction": "复制",
|
||||||
|
"recordsTitle": "我的咨询记录",
|
||||||
|
"recordsCountUnit": "条记录"
|
||||||
|
},
|
||||||
|
"inquiry": {
|
||||||
|
"eyebrow": "COLLABORATION",
|
||||||
|
"title": "合作咨询",
|
||||||
|
"subtitle": "留下你的需求与目标,主理人会尽快联系。",
|
||||||
|
"submitLabel": "提交量房与定制评估需求"
|
||||||
|
},
|
||||||
|
"success": {
|
||||||
|
"eyebrow": "COLLABORATION",
|
||||||
|
"title": "已收到你的咨询",
|
||||||
|
"intro": "主理人会尽快与你联系。",
|
||||||
|
"recordsAction": "查看咨询记录",
|
||||||
|
"homeAction": "返回首页"
|
||||||
|
},
|
||||||
|
"records": {
|
||||||
|
"title": "我的咨询记录",
|
||||||
|
"createAction": "新增咨询",
|
||||||
|
"emptyTitle": "还没有咨询记录",
|
||||||
|
"emptyDescription": "提交一次咨询,开始与你的主理人沟通。",
|
||||||
|
"emptyAction": "开始咨询"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"founder": "林叙安 (Lin XUAN)",
|
||||||
|
"profilePresentation": {
|
||||||
|
"coverage": [
|
||||||
|
{
|
||||||
|
"title": "直派核心圈",
|
||||||
|
"content": "上海、杭州、宁波、苏州、无锡、南京及深圳、广州。主理人及资深装配总工亲赴现场。"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "全国其他城市私邸",
|
||||||
|
"content": "接受建筑设计师联合委托,安排远程 3D 激光测绘支持与专用物流直运安装。"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"warranty": [
|
||||||
|
"门体内部防变形航空合金骨架承诺 10 年结构质保;",
|
||||||
|
"重型天地轴、进口地弹簧及磁吸五金 5 年免费维护;",
|
||||||
|
"每樘门出厂前进行 5000 次启闭校正;",
|
||||||
|
"原木天然肌理享有首年 2 次木蜡油保养服务。"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"safety": {
|
||||||
|
"submissions": "disabled",
|
||||||
|
"customerRecords": "disabled",
|
||||||
|
"contactActions": "disabled"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"personal": {
|
||||||
|
"schemaVersion": "1",
|
||||||
|
"brand": {
|
||||||
|
"name": "林境建筑画册 · 预览",
|
||||||
|
"tagline": "用于独立预览的模板演示内容",
|
||||||
|
"description": "此内容仅用于平台模板预览,不代表真实品牌或客户案例。",
|
||||||
|
"deliveryNote": "演示预览已禁用真实咨询和联系操作。"
|
||||||
|
},
|
||||||
|
"content": {
|
||||||
|
"templateKey": "personal",
|
||||||
|
"inquiryFormName": "合作咨询表单",
|
||||||
|
"offerings": [
|
||||||
|
{
|
||||||
|
"kind": "service",
|
||||||
|
"name": "示例·品牌定位咨询",
|
||||||
|
"summary": "梳理品牌定位与下一步行动。",
|
||||||
|
"categoryKey": "consulting",
|
||||||
|
"coverUrl": "/assets/content/personal-consulting.jpg",
|
||||||
|
"priceText": "按需求确认",
|
||||||
|
"config": {
|
||||||
|
"media": [
|
||||||
|
{
|
||||||
|
"url": "/assets/content/personal-consulting.jpg",
|
||||||
|
"alt": "",
|
||||||
|
"type": "image"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "service",
|
||||||
|
"name": "示例·长期顾问支持",
|
||||||
|
"summary": "围绕表达和转化提供持续支持。",
|
||||||
|
"categoryKey": "advisory",
|
||||||
|
"coverUrl": "/assets/content/personal-advisory.jpg",
|
||||||
|
"priceText": "按服务周期确认",
|
||||||
|
"config": {
|
||||||
|
"media": [
|
||||||
|
{
|
||||||
|
"url": "/assets/content/personal-advisory.jpg",
|
||||||
|
"alt": "",
|
||||||
|
"type": "image"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"trustContent": [
|
||||||
|
{
|
||||||
|
"type": "credential",
|
||||||
|
"title": "关于主理人",
|
||||||
|
"content": "示例内容,待品牌主理人完善。"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "process",
|
||||||
|
"title": "合作方法",
|
||||||
|
"content": "示例内容,待品牌主理人完善。"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"key": "name",
|
||||||
|
"label": "您的称呼",
|
||||||
|
"type": "text",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "phone",
|
||||||
|
"label": "联系方式",
|
||||||
|
"type": "phone",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "remark",
|
||||||
|
"label": "合作需求",
|
||||||
|
"type": "textarea",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"capabilityKey": "inquiry",
|
||||||
|
"brandConfig": {
|
||||||
|
"templateData": {
|
||||||
|
"designPhilosophy": "先厘清问题,再设计表达"
|
||||||
|
},
|
||||||
|
"title": "品牌策略顾问",
|
||||||
|
"slogan": "用清晰的定位与可执行的表达,让专业被看见。",
|
||||||
|
"phone": "",
|
||||||
|
"wechat": "",
|
||||||
|
"studioAddress": "上海市徐汇区创意园区",
|
||||||
|
"avatarUrl": "/assets/content/personal-avatar.jpg",
|
||||||
|
"heroImage": "/assets/content/personal-consulting.jpg",
|
||||||
|
"visualPresentation": {
|
||||||
|
"home": {
|
||||||
|
"founderBadge": "接受项目沟通",
|
||||||
|
"proofEyebrow": "专业经验与合作成果",
|
||||||
|
"proofTitle": "经验与方法",
|
||||||
|
"manifestoEyebrow": "工作原则",
|
||||||
|
"manifestoTitle": "先厘清问题,再设计表达",
|
||||||
|
"worksEyebrow": "合作方式",
|
||||||
|
"worksTitle": "品牌策略与顾问服务",
|
||||||
|
"worksAction": "查看全部 →"
|
||||||
|
},
|
||||||
|
"offerings": {
|
||||||
|
"title": "合作方式",
|
||||||
|
"subtitle": "围绕定位、表达与业务转化,选择适合当前阶段的支持。",
|
||||||
|
"materialLabel": "包含:",
|
||||||
|
"hardwareLabel": "定制说明:",
|
||||||
|
"detailAction": "查看详情 →",
|
||||||
|
"inquiryAction": "发起咨询"
|
||||||
|
},
|
||||||
|
"detail": {
|
||||||
|
"priceLabel": "价格参考",
|
||||||
|
"spaceLabel": "适合场景",
|
||||||
|
"backgroundTitle": "项目背景",
|
||||||
|
"conceptTitle": "设计思路",
|
||||||
|
"craftsTitle": "交付要点",
|
||||||
|
"materialsTitle": "材料与说明",
|
||||||
|
"inquiryAction": "发起咨询",
|
||||||
|
"inquiryHint": "提交信息后由主理人与您沟通。"
|
||||||
|
},
|
||||||
|
"profile": {
|
||||||
|
"phoneLabel": "联系电话",
|
||||||
|
"wechatLabel": "微信",
|
||||||
|
"addressLabel": "工作地点",
|
||||||
|
"callAction": "呼叫",
|
||||||
|
"copyAction": "复制",
|
||||||
|
"recordsTitle": "我的咨询记录",
|
||||||
|
"recordsCountUnit": "条记录"
|
||||||
|
},
|
||||||
|
"inquiry": {
|
||||||
|
"eyebrow": "COLLABORATION",
|
||||||
|
"title": "合作咨询",
|
||||||
|
"subtitle": "留下你的需求与目标,主理人会尽快联系。",
|
||||||
|
"submitLabel": "提交咨询"
|
||||||
|
},
|
||||||
|
"success": {
|
||||||
|
"eyebrow": "COLLABORATION",
|
||||||
|
"title": "已收到你的咨询",
|
||||||
|
"intro": "主理人会尽快与你联系。",
|
||||||
|
"recordsAction": "查看咨询记录",
|
||||||
|
"homeAction": "返回首页"
|
||||||
|
},
|
||||||
|
"records": {
|
||||||
|
"title": "我的咨询记录",
|
||||||
|
"createAction": "新增咨询",
|
||||||
|
"emptyTitle": "还没有咨询记录",
|
||||||
|
"emptyDescription": "提交一次咨询,开始与你的主理人沟通。",
|
||||||
|
"emptyAction": "开始咨询"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"founder": "示例主理人"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"safety": {
|
||||||
|
"submissions": "disabled",
|
||||||
|
"customerRecords": "disabled",
|
||||||
|
"contactActions": "disabled"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Generated
+5
-1
@@ -224,7 +224,11 @@ importers:
|
|||||||
|
|
||||||
packages/capability-booking: {}
|
packages/capability-booking: {}
|
||||||
|
|
||||||
packages/config: {}
|
packages/config:
|
||||||
|
dependencies:
|
||||||
|
'@personal-brand/template-contract':
|
||||||
|
specifier: workspace:^
|
||||||
|
version: link:../template-contract
|
||||||
|
|
||||||
packages/template-acheng-campus-food:
|
packages/template-acheng-campus-food:
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ const templates = fs
|
|||||||
const manifest = JSON.parse(
|
const manifest = JSON.parse(
|
||||||
fs.readFileSync(path.join(packageRoot, entry.name, "template.json"), "utf8"),
|
fs.readFileSync(path.join(packageRoot, entry.name, "template.json"), "utf8"),
|
||||||
);
|
);
|
||||||
return { ...manifest, visualTemplateKey: manifest.packageKey };
|
return manifest;
|
||||||
})
|
})
|
||||||
.sort((left, right) => left.packageKey.localeCompare(right.packageKey));
|
.sort((left, right) => left.packageKey.localeCompare(right.packageKey));
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ const fingerprint = crypto
|
|||||||
.createHash("sha256")
|
.createHash("sha256")
|
||||||
.update(JSON.stringify(canonical(templates)))
|
.update(JSON.stringify(canonical(templates)))
|
||||||
.digest("hex");
|
.digest("hex");
|
||||||
const content = `// prettier-ignore\nimport type { TemplatePackageManifest } from "./index.js";\n\nexport const generatedTemplatePackageRegistry: readonly TemplatePackageManifest[] = ${JSON.stringify(templates, null, 2)};\nexport const generatedTemplatePackageRegistryHash =\n "${fingerprint}";\n`;
|
const content = `import type { TemplatePackageManifest } from "./index.js";\n\n// prettier-ignore\nexport const generatedTemplatePackageRegistry: readonly TemplatePackageManifest[] = ${JSON.stringify(templates, null, 2)};\nexport const generatedTemplatePackageRegistryHash =\n "${fingerprint}";\n`;
|
||||||
const write = process.argv.includes("--write");
|
const write = process.argv.includes("--write");
|
||||||
if (write) {
|
if (write) {
|
||||||
fs.writeFileSync(outputPath, content);
|
fs.writeFileSync(outputPath, content);
|
||||||
|
|||||||
@@ -109,8 +109,8 @@ for (const { directory, manifest, package: packageMetadata } of packages) {
|
|||||||
const packageIndustries = Array.isArray(manifest.supportedIndustryTemplates)
|
const packageIndustries = Array.isArray(manifest.supportedIndustryTemplates)
|
||||||
? manifest.supportedIndustryTemplates
|
? manifest.supportedIndustryTemplates
|
||||||
: [];
|
: [];
|
||||||
const visualKey = manifest.visualTemplateKey ?? key;
|
const visualKey = manifest.visualTemplateKey;
|
||||||
const visualRegistered = visualKeys.includes(visualKey);
|
const visualRegistered = typeof visualKey === "string" && visualKeys.includes(visualKey);
|
||||||
const rendererPath = `${directory}/taro/index.tsx`;
|
const rendererPath = `${directory}/taro/index.tsx`;
|
||||||
const rendererExists = fs.existsSync(path.join(packagesRoot, rendererPath));
|
const rendererExists = fs.existsSync(path.join(packagesRoot, rendererPath));
|
||||||
const rendererExport = rendererExists
|
const rendererExport = rendererExists
|
||||||
@@ -141,6 +141,7 @@ for (const { directory, manifest, package: packageMetadata } of packages) {
|
|||||||
errors.push("No capability definitions found in capability-contracts.ts");
|
errors.push("No capability definitions found in capability-contracts.ts");
|
||||||
if (!rendererGlob) errors.push("Admin renderer package glob is not discoverable");
|
if (!rendererGlob) errors.push("Admin renderer package glob is not discoverable");
|
||||||
if (!packageIndustries.length) errors.push(`${key}: supportedIndustryTemplates is empty`);
|
if (!packageIndustries.length) errors.push(`${key}: supportedIndustryTemplates is empty`);
|
||||||
|
if (!visualRegistered) errors.push(`${key}: visualTemplateKey is missing or unknown`);
|
||||||
if (unknownCapabilities.length)
|
if (unknownCapabilities.length)
|
||||||
errors.push(`${key}: unknown capabilities ${unknownCapabilities.join(", ")}`);
|
errors.push(`${key}: unknown capabilities ${unknownCapabilities.join(", ")}`);
|
||||||
if (!toolchainCompatible)
|
if (!toolchainCompatible)
|
||||||
|
|||||||
Reference in new issue
Block a user