fix: tighten public work type routing

This commit is contained in:
2026-06-07 14:49:36 +08:00
parent 8f460feb41
commit 8131894bb5
21 changed files with 611 additions and 228 deletions

View File

@@ -4,6 +4,7 @@ export type * from './hyper3d';
export type * from './jumpHop';
export type * from './puzzleCreativeTemplate';
export type * from './puzzleClear';
export * from './playTypes';
export type * from './publicWork';
export type * from './visualNovel';
export type * from './barkBattle';

View File

@@ -0,0 +1,72 @@
export const PLATFORM_CREATION_TYPE_IDS = [
'rpg',
'big-fish',
'puzzle',
'puzzle-clear',
'match3d',
'jump-hop',
'wooden-fish',
'square-hole',
'bark-battle',
'visual-novel',
'baby-object-match',
'creative-agent',
'airp',
] as const;
export type PlatformCreationTypeId =
(typeof PLATFORM_CREATION_TYPE_IDS)[number];
const PLATFORM_CREATION_TYPE_ID_SET: ReadonlySet<string> = new Set(
PLATFORM_CREATION_TYPE_IDS,
);
export function isPlatformCreationTypeId(
value: string,
): value is PlatformCreationTypeId {
return PLATFORM_CREATION_TYPE_ID_SET.has(value);
}
export function assertPlatformCreationTypeId(
value: string,
): PlatformCreationTypeId {
if (isPlatformCreationTypeId(value)) {
return value;
}
throw new Error(`未知创作类型:${value}`);
}
export const PUBLIC_WORK_SOURCE_TYPES = [
'custom-world',
'big-fish',
'puzzle',
'puzzle-clear',
'jump-hop',
'wooden-fish',
'match3d',
'square-hole',
'visual-novel',
'bark-battle',
'edutainment',
] as const;
export type PublicWorkSourceType = (typeof PUBLIC_WORK_SOURCE_TYPES)[number];
const PUBLIC_WORK_SOURCE_TYPE_SET: ReadonlySet<string> = new Set(
PUBLIC_WORK_SOURCE_TYPES,
);
export function isPublicWorkSourceType(
value: string,
): value is PublicWorkSourceType {
return PUBLIC_WORK_SOURCE_TYPE_SET.has(value);
}
export function assertPublicWorkSourceType(value: string): PublicWorkSourceType {
if (isPublicWorkSourceType(value)) {
return value;
}
throw new Error(`未知公开作品类型:${value}`);
}

View File

@@ -1,5 +1,7 @@
import type { PublicWorkSourceType } from './playTypes';
export interface PublicWorkGalleryEntryResponse {
sourceType: string;
sourceType: PublicWorkSourceType;
workId: string;
profileId: string;
sourceSessionId?: string | null;

View File

@@ -12,6 +12,7 @@ export type * from './contracts/hyper3d';
export * from './contracts/match3dAgent';
export * from './contracts/match3dRuntime';
export * from './contracts/match3dWorks';
export * from './contracts/playTypes';
export * from './contracts/puzzleAgentActions';
export * from './contracts/puzzleAgentDraft';
export * from './contracts/puzzleAgentSession';