feat: ship Wave 5-6 multi-surface hygiene, optimization, and bug fixes

This commit is contained in:
Yun Chan 2026-11-14 11:51:41 +09:00
parent 01ef3293cf
commit 66b6b45ba9
399 changed files with 17828 additions and 11330 deletions

View file

@ -1,3 +1,5 @@
import { isRecord, isUuid } from './core-contract.generated.ts'
export const CONTENT_REPORT_REASONS = [
'harmful',
'sexual',
@ -44,7 +46,6 @@ export interface ContentReportRpcError {
code: string
}
const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i
const REASON_SET = new Set<string>(CONTENT_REPORT_REASONS)
const SOURCE_TYPE_SET = new Set<string>(CONTENT_REPORT_SOURCE_TYPES)
@ -58,9 +59,6 @@ export class ContentReportRequestError extends Error {
}
}
function isRecord(value: unknown): value is Record<string, unknown> {
return typeof value === 'object' && value !== null && !Array.isArray(value)
}
function codePointLength(value: string): number {
return Array.from(value).length
@ -84,7 +82,7 @@ function assertExactKeys(
function requireUuid(value: unknown): string {
if (typeof value !== 'string') throw new ContentReportRequestError('invalid_request')
const normalized = value.trim().toLowerCase()
if (!UUID_PATTERN.test(normalized)) throw new ContentReportRequestError('invalid_request')
if (!isUuid(normalized)) throw new ContentReportRequestError('invalid_request')
return normalized
}
@ -137,7 +135,7 @@ export function parseContentReportReceipt(value: unknown): ContentReportReceipt
if (
!isRecord(value)
|| typeof value.reportId !== 'string'
|| !UUID_PATTERN.test(value.reportId)
|| !isUuid(value.reportId)
|| value.status !== 'submitted'
|| typeof value.idempotent !== 'boolean'
|| typeof value.createdAt !== 'string'