90 lines
2.3 KiB
TypeScript
90 lines
2.3 KiB
TypeScript
export const BABY_OBJECT_MATCH_TEMPLATE_ID = 'baby-object-match';
|
|
export const BABY_OBJECT_MATCH_TEMPLATE_NAME = '宝贝识物';
|
|
export const BABY_OBJECT_MATCH_EDUTAINMENT_TAG = '寓教于乐';
|
|
|
|
export type BabyObjectMatchTemplateId =
|
|
typeof BABY_OBJECT_MATCH_TEMPLATE_ID;
|
|
|
|
export type BabyObjectMatchAssetProvider =
|
|
| 'vector-engine-gpt-image-2'
|
|
| 'placeholder';
|
|
|
|
export type BabyObjectMatchPublicationStatus = 'draft' | 'published';
|
|
|
|
export type BabyObjectMatchItemAsset = {
|
|
itemId: string;
|
|
itemName: string;
|
|
imageSrc: string;
|
|
assetObjectId: string | null;
|
|
generationProvider: BabyObjectMatchAssetProvider;
|
|
prompt: string;
|
|
};
|
|
|
|
export type BabyObjectMatchDraft = {
|
|
draftId: string;
|
|
profileId: string;
|
|
templateId: BabyObjectMatchTemplateId;
|
|
templateName: typeof BABY_OBJECT_MATCH_TEMPLATE_NAME;
|
|
workTitle: string;
|
|
workDescription: string;
|
|
itemNames: [string, string];
|
|
itemAssets: [BabyObjectMatchItemAsset, BabyObjectMatchItemAsset];
|
|
themeTags: string[];
|
|
publicationStatus: BabyObjectMatchPublicationStatus;
|
|
createdAt: string;
|
|
updatedAt: string;
|
|
publishedAt: string | null;
|
|
};
|
|
|
|
export type CreateBabyObjectMatchDraftRequest = {
|
|
itemAName: string;
|
|
itemBName: string;
|
|
};
|
|
|
|
export type BabyObjectMatchDraftResponse = {
|
|
draft: BabyObjectMatchDraft;
|
|
};
|
|
|
|
export type SaveBabyObjectMatchDraftRequest = {
|
|
draft: BabyObjectMatchDraft;
|
|
};
|
|
|
|
export type BabyObjectMatchPublishRequest = {
|
|
draft: BabyObjectMatchDraft;
|
|
};
|
|
|
|
export type BabyObjectMatchPublishResponse = {
|
|
draft: BabyObjectMatchDraft;
|
|
publicWorkCode: string;
|
|
};
|
|
|
|
export function normalizeBabyObjectMatchItemName(value: string) {
|
|
return value.trim();
|
|
}
|
|
|
|
export function normalizeBabyObjectMatchTags(tags: string[]) {
|
|
return [
|
|
...new Set([
|
|
BABY_OBJECT_MATCH_EDUTAINMENT_TAG,
|
|
...tags.map((tag) => tag.trim()).filter(Boolean),
|
|
]),
|
|
];
|
|
}
|
|
|
|
export function hasBabyObjectMatchRequiredTag(tags: string[]) {
|
|
return tags.some((tag) => tag === BABY_OBJECT_MATCH_EDUTAINMENT_TAG);
|
|
}
|
|
|
|
export function validateBabyObjectMatchItemNames(
|
|
payload: CreateBabyObjectMatchDraftRequest,
|
|
) {
|
|
const itemAName = normalizeBabyObjectMatchItemName(payload.itemAName);
|
|
const itemBName = normalizeBabyObjectMatchItemName(payload.itemBName);
|
|
|
|
return {
|
|
itemAName,
|
|
itemBName,
|
|
valid: Boolean(itemAName && itemBName),
|
|
};
|
|
}
|