feat: 让模板声明信任内容编辑语义
This commit is contained in:
1 parent
6d7fae95b3
commit
e3a4074d8e
12 files changed
+159
-13
No files matched your search
@@ -64,6 +64,13 @@ export type TemplateAdminManifest = {
|
||||
sections: TemplateAdminSection[];
|
||||
};
|
||||
|
||||
export type TemplateTrustContentType = {
|
||||
type: "schedule" | "coverage" | "process" | "credential" | "case" | "promise" | (string & {});
|
||||
label: string;
|
||||
help?: string;
|
||||
placeholder?: string;
|
||||
};
|
||||
|
||||
export type TemplateSampleContent = {
|
||||
templateKey: string;
|
||||
offerings: Array<Record<string, unknown>>;
|
||||
@@ -96,6 +103,7 @@ export type TemplatePackageManifest = {
|
||||
dataSlots: TemplateDataSlot[];
|
||||
assetSlots: TemplateAssetSlot[];
|
||||
admin: TemplateAdminManifest;
|
||||
trustContentTypes?: TemplateTrustContentType[];
|
||||
sampleContent?: Record<string, TemplateSampleContent>;
|
||||
};
|
||||
|
||||
@@ -125,6 +133,22 @@ export function validateTemplatePackageManifest(value: unknown): string[] {
|
||||
errors.push("data slot source is invalid");
|
||||
}
|
||||
}
|
||||
if (manifest.trustContentTypes !== undefined) {
|
||||
if (!Array.isArray(manifest.trustContentTypes))
|
||||
errors.push("trustContentTypes must be an array");
|
||||
else {
|
||||
for (const [index, item] of manifest.trustContentTypes.entries()) {
|
||||
if (!item || typeof item !== "object") {
|
||||
errors.push(`trustContentTypes.${index} must be an object`);
|
||||
continue;
|
||||
}
|
||||
if (typeof item.type !== "string" || !item.type.trim())
|
||||
errors.push(`trustContentTypes.${index}.type is required`);
|
||||
if (typeof item.label !== "string" || !item.label.trim())
|
||||
errors.push(`trustContentTypes.${index}.label is required`);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!Array.isArray(manifest.assetSlots)) errors.push("assetSlots must be an array");
|
||||
else {
|
||||
for (const slot of manifest.assetSlots) {
|
||||
|
||||
Reference in new issue
Block a user