fix: tighten public work type routing
This commit is contained in:
@@ -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';
|
||||
|
||||
72
packages/shared/src/contracts/playTypes.ts
Normal file
72
packages/shared/src/contracts/playTypes.ts
Normal 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}`);
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
import type { PublicWorkSourceType } from './playTypes';
|
||||
|
||||
export interface PublicWorkGalleryEntryResponse {
|
||||
sourceType: string;
|
||||
sourceType: PublicWorkSourceType;
|
||||
workId: string;
|
||||
profileId: string;
|
||||
sourceSessionId?: string | null;
|
||||
|
||||
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user