-
Notifications
You must be signed in to change notification settings - Fork 4
Topcoder NestJS Autopilot Phase Transition Logic Optimization #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ import { | |
IsDateString, | ||
IsUUID, | ||
} from 'class-validator'; | ||
import { AutopilotOperator } from '../interfaces/autopilot.interface'; | ||
|
||
export class PhaseTransitionDto { | ||
@IsDateString() | ||
|
@@ -23,8 +24,8 @@ export class PhaseTransitionDto { | |
@IsEnum(['START', 'END']) | ||
state: 'START' | 'END'; | ||
|
||
@IsString() | ||
operator: string; | ||
@IsEnum(AutopilotOperator) | ||
operator: AutopilotOperator | string; | ||
|
||
@IsString() | ||
projectStatus: string; | ||
|
@@ -40,8 +41,8 @@ export class ChallengeUpdateDto { | |
@IsString() | ||
status: string; | ||
|
||
@IsString() | ||
operator: string; | ||
@IsEnum(AutopilotOperator) | ||
operator: AutopilotOperator | string; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider removing the |
||
} | ||
|
||
export class CommandDto { | ||
|
@@ -57,6 +58,6 @@ export class CommandDto { | |
@IsObject() | ||
parameters: Record<string, any>; | ||
|
||
@IsString() | ||
operator: string; | ||
@IsEnum(AutopilotOperator) | ||
operator: AutopilotOperator | string; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The type for |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,19 @@ | ||
export enum AutopilotOperator { | ||
// System operators for internal autopilot operations | ||
SYSTEM = 'system', | ||
SYSTEM_SCHEDULER = 'system-scheduler', | ||
SYSTEM_NEW_CHALLENGE = 'system-new-challenge', | ||
SYSTEM_RECOVERY = 'system-recovery', | ||
SYSTEM_SYNC = 'system-sync', | ||
SYSTEM_PHASE_CHAIN = 'system-phase-chain', | ||
|
||
// Administrative operators | ||
ADMIN = 'admin', | ||
|
||
// User operators (when operator comes from external sources) | ||
USER = 'user', | ||
} | ||
|
||
export interface BaseMessage { | ||
topic: string; | ||
originator: string; | ||
|
@@ -10,7 +26,7 @@ export interface PhaseTransitionPayload { | |
phaseId: string; // Changed from number to string to support UUIDs from the API | ||
phaseTypeName: string; | ||
state: 'START' | 'END'; | ||
operator: string; | ||
operator: AutopilotOperator | string; // Allow both enum and string for flexibility | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider documenting the |
||
projectStatus: string; | ||
date?: string; | ||
challengeId: string; // Changed to string to support UUIDs | ||
|
@@ -20,7 +36,7 @@ export interface ChallengeUpdatePayload { | |
projectId: number; | ||
challengeId: string; // Changed to string to support UUIDs | ||
status: string; | ||
operator: string; | ||
operator: AutopilotOperator | string; // Allow both enum and string for flexibility | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider documenting the |
||
date?: string; | ||
// This nested structure may be present in Kafka messages from the API | ||
phases?: { | ||
|
@@ -31,7 +47,7 @@ export interface ChallengeUpdatePayload { | |
|
||
export interface CommandPayload { | ||
command: string; | ||
operator: string; | ||
operator: AutopilotOperator | string; // Allow both enum and string for flexibility | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider documenting the |
||
projectId?: number; | ||
challengeId?: string; // Added challengeId for new command handling | ||
date?: string; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider removing the
| string
union type ifAutopilotOperator
already includes all possible string values foroperator
. This will ensure type safety and prevent any unexpected values.