kintex/mobile/lib/types.ts
2026-07-13 05:16:35 +09:00

132 lines
3.4 KiB
TypeScript

/*
* 백엔드 API 계약 타입 (단일 출처: _workspace/01_backend_contracts.md · 04_backend_public_auth.md)
* ★ 백엔드 응답 shape과 정확히 일치해야 한다. 불일치 발견 시 _workspace/에 기록·보고.
*/
// ── 0-1 응답 봉투 ──
export interface ApiError {
code: ApiErrorCode;
message: string;
}
export interface ApiResponse<T> {
success: boolean;
data: T | null;
error: ApiError | null;
}
export interface PageResponse<T> {
items: T[];
page: number;
size: number;
total: number;
}
// ── 0-2 오류 코드 ──
export type ApiErrorCode =
| 'VALIDATION'
| 'UNAUTHORIZED'
| 'FORBIDDEN'
| 'NOT_FOUND'
| 'CONFLICT'
| 'EMAIL_TAKEN'
| 'COMPLIANCE_BLOCKED'
| 'RENDER_QUOTA_EXCEEDED'
| 'NOT_REGISTERED_COMPANY'
| 'NOT_IMPLEMENTED'
| 'ACCOUNT_LOCKED'
| 'OTP_REQUIRED'
| 'OTP_INVALID'
| 'INTERNAL';
// ── 0-5 역할 ──
export type EventRole = 'ORGANIZER' | 'EXHIBITOR' | 'CONTRACTOR' | 'HALL_MANAGER';
// ── 2. 인증·워크스페이스 (SCR-01) ──
export interface WorkspaceDto {
eventId: string;
eventName: string;
startDate: string;
endDate: string;
hallLabel: string;
myRole: EventRole;
dday: number;
}
export interface AuthUser {
userId: string;
displayName: string;
hallManager: boolean;
// 전역 역할(app_user.role_code — 'ADMIN' | 'MANAGER' | …). 공유 백엔드 /api/auth/login 이
// 웹과 동일하게 반환한다(웹 LoginResponse.user 와 동일 shape). 관람객 등 미지정 계정은 null/undefined.
// 역할별 랜딩 판정(roleTrack.resolveLandingTrack)이 admin/ops 우선순위 결정에 사용.
roleCode?: string | null;
}
export interface LoginResponse {
accessToken: string;
expiresInSeconds: number;
user: AuthUser;
workspaces: WorkspaceDto[];
}
// ── 공개 인증 (04_backend_public_auth.md) ──
export interface RegisterRequest {
email: string;
displayName: string;
password: string;
companyName?: string;
inviteCode?: string;
}
export interface RegisterResponse {
userId: string;
email: string;
displayName: string;
joinedEvent: string | null;
}
export interface MessageResponse {
message: string;
}
// ── 6. M5 나노바나나 RenderJob (SCR-06/12) ──
export type RenderJobStatus = 'QUEUED' | 'RUNNING' | 'DONE' | 'FAILED';
export interface RenderJobDto {
jobId: string;
boothId: string;
shotPreset: string; // S1..S7
status: RenderJobStatus;
imageUrl: string | null;
schemaHash: string | null;
modelVersion: string | null;
/** AI 생성 이미지 고지 — 항상 true (제거 불가). */
watermarkRequired: boolean;
watermarkText: string;
notice?: string;
createdAt?: string;
}
// ── 헬스체크 ──
export interface HealthDto {
status: string;
service: string;
time: string;
}
// ── 내정보(SCR-M 프로필) ──
// GET /api/auth/me → KintexPrincipal(백엔드 record). 이메일·부서·전화는 현 계약 미포함(백엔드 인계 대상).
export interface MePrincipal {
userId: string;
displayName: string;
eventRoles: Record<string, EventRole>;
hallManager: boolean;
roleCode: string | null;
tenantId: string | null;
}
// GET /api/auth/otp/status → { otpEnabled, verifyMethod }.
export interface OtpStatusDto {
otpEnabled: boolean;
verifyMethod: string;
}
/** 아바타 업로드 응답(제안 계약 — 백엔드 미구현 시 degrade). */
export interface AvatarUploadResponse {
photoUrl: string;
}