feat(sync): cn event coverage, bootstrap and outbox sender
Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
// services/api/src/sync/dto.ts —— 内部同步端点请求 DTO(P2 Task 3)。
|
||||
// 契约权威:openapi.yaml [internal](syncBootstrap/syncReconcile)。
|
||||
// 经全局 ValidationPipe(whitelist)剥离未知字段;校验失败 400 VALIDATION_FAILED。
|
||||
import {
|
||||
IsIn,
|
||||
IsInt,
|
||||
IsOptional,
|
||||
IsString,
|
||||
Max,
|
||||
Min,
|
||||
} from 'class-validator';
|
||||
|
||||
/** 契约 SyncEntityType(slot-state 预留——与 openapi enum 同步)。 */
|
||||
export const SYNC_ENTITY_TYPES = [
|
||||
'album',
|
||||
'category',
|
||||
'photo',
|
||||
'asset',
|
||||
'slot-state',
|
||||
] as const;
|
||||
|
||||
/** 契约 BootstrapRequest:albumId 缺省 = 全部相册。 */
|
||||
export class BootstrapRequestDto {
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
albumId?: string;
|
||||
}
|
||||
|
||||
/** 契约 ReconcileRequest:必填 entityType/sinceVersion/limit。 */
|
||||
export class ReconcileRequestDto {
|
||||
@IsIn(SYNC_ENTITY_TYPES)
|
||||
entityType!: (typeof SYNC_ENTITY_TYPES)[number];
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
albumId?: string;
|
||||
|
||||
@IsInt()
|
||||
@Min(0)
|
||||
sinceVersion!: number;
|
||||
|
||||
@IsInt()
|
||||
@Min(1)
|
||||
@Max(1000)
|
||||
limit!: number;
|
||||
}
|
||||
Reference in New Issue
Block a user