provider-video-sync.dto.ts 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
  2. import {
  3. IsBoolean,
  4. IsInt,
  5. IsObject,
  6. IsOptional,
  7. IsString,
  8. Max,
  9. Min,
  10. ValidateNested,
  11. } from 'class-validator';
  12. import { Type } from 'class-transformer';
  13. export class ProviderVideoSyncHistoryItemDto {
  14. @ApiProperty({ type: String, example: 'Provider Video Sync' })
  15. title!: string;
  16. @ApiPropertyOptional({
  17. type: Number,
  18. description: 'Epoch seconds for last run',
  19. })
  20. runAt?: number;
  21. @ApiPropertyOptional({
  22. type: Number,
  23. description: 'Epoch seconds for full sync completion',
  24. })
  25. completedAt?: number;
  26. @ApiPropertyOptional({
  27. type: Number,
  28. description: 'Known processed count (not stored yet)',
  29. })
  30. processedCount: null = null;
  31. @ApiPropertyOptional({
  32. type: String,
  33. description: 'Checkpoint cursor value stored in referId',
  34. })
  35. updatedAtCursor?: string;
  36. @ApiPropertyOptional({
  37. type: Number,
  38. description: 'syncState.updatedAt (epoch seconds)',
  39. })
  40. updatedAt?: number;
  41. }
  42. export class ProviderVideoSyncHistoryDataDto {
  43. @ApiProperty({
  44. type: [ProviderVideoSyncHistoryItemDto],
  45. description: 'Cursor records for provider sync',
  46. })
  47. list!: ProviderVideoSyncHistoryItemDto[];
  48. @ApiProperty({ type: Number, description: 'Total rows available' })
  49. total!: number;
  50. }
  51. export class ProviderVideoSyncHistoryResponseDto {
  52. @ApiProperty({
  53. type: ProviderVideoSyncHistoryDataDto,
  54. })
  55. data!: ProviderVideoSyncHistoryDataDto;
  56. }
  57. class ProviderVideoSyncParamDto {
  58. @IsOptional()
  59. @IsString()
  60. status?: string;
  61. /**
  62. * ISO string; provider filters "updated after"
  63. * Example: "2025-12-18T21:19:09.227Z"
  64. */
  65. @IsOptional()
  66. @IsString()
  67. updatedAt?: string;
  68. /**
  69. * Allow extra provider param keys without strict validation.
  70. * If you want to lock this down later, replace with explicit fields.
  71. */
  72. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  73. [k: string]: any;
  74. }
  75. export class ProviderVideoSyncRunDto {
  76. @IsOptional()
  77. @IsString()
  78. providerCode?: string;
  79. @IsOptional()
  80. @IsBoolean()
  81. fullSync?: boolean;
  82. @IsOptional()
  83. @IsBoolean()
  84. resetState?: boolean;
  85. /**
  86. * Optional override. In normal usage:
  87. * - fullSync: resumes from SyncState cursor
  88. * - incremental: pageNum is forced to 1
  89. */
  90. @IsOptional()
  91. @IsInt()
  92. @Min(1)
  93. pageNum?: number;
  94. /**
  95. * Default is handled by service; capped at 500 by service.
  96. */
  97. @IsOptional()
  98. @IsInt()
  99. @Min(1)
  100. @Max(15000)
  101. pageSize?: number;
  102. @IsOptional()
  103. @IsObject()
  104. @ValidateNested()
  105. @Type(() => ProviderVideoSyncParamDto)
  106. param?: ProviderVideoSyncParamDto;
  107. }