part #2
This commit is contained in:
@@ -7,6 +7,10 @@
|
||||
"target": "https://localhost:10010",
|
||||
"secure": false
|
||||
},
|
||||
"/api/v1/setup": {
|
||||
"target": "https://localhost:10010",
|
||||
"secure": false
|
||||
},
|
||||
"/authority": {
|
||||
"target": "https://localhost:10020",
|
||||
"secure": false
|
||||
|
||||
@@ -47,16 +47,33 @@ export interface ApiResponse<T> {
|
||||
cacheHit?: boolean;
|
||||
}
|
||||
|
||||
/** Setup session response from backend */
|
||||
export interface SetupSessionResponse {
|
||||
/** Step state as returned by the backend */
|
||||
export interface BackendStepState {
|
||||
stepId: string;
|
||||
status: string;
|
||||
completedAtUtc?: string | null;
|
||||
skippedAtUtc?: string | null;
|
||||
skippedReason?: string | null;
|
||||
checkResults: unknown[];
|
||||
errorMessage?: string | null;
|
||||
}
|
||||
|
||||
/** Backend session object (inside the response envelope) */
|
||||
export interface BackendSession {
|
||||
sessionId: string;
|
||||
startedAt: string;
|
||||
expiresAt?: string;
|
||||
completedSteps: SetupStepId[];
|
||||
skippedSteps: SetupStepId[];
|
||||
configValues: Record<string, string>;
|
||||
currentStep?: SetupStepId;
|
||||
metadata?: Record<string, string>;
|
||||
tenantId: string;
|
||||
status: string;
|
||||
steps: BackendStepState[];
|
||||
createdAtUtc: string;
|
||||
updatedAtUtc: string;
|
||||
createdBy?: string;
|
||||
updatedBy?: string;
|
||||
dataAsOfUtc?: string;
|
||||
}
|
||||
|
||||
/** Setup session response from backend — envelope is { session: ... } */
|
||||
export interface SetupSessionResponse {
|
||||
session: BackendSession;
|
||||
}
|
||||
|
||||
/** Step execution response from backend */
|
||||
@@ -146,9 +163,9 @@ export class SetupWizardApiService {
|
||||
*/
|
||||
createSession(): Observable<SetupSession> {
|
||||
return this.http
|
||||
.post<ApiResponse<SetupSessionResponse>>(`${this.setupBaseUrl}/sessions`, {})
|
||||
.post<SetupSessionResponse>(`${this.setupBaseUrl}/sessions`, {})
|
||||
.pipe(
|
||||
map(response => this.mapSessionResponse(response.data)),
|
||||
map(response => this.mapSessionResponse(response)),
|
||||
catchError(error => this.handleError(error))
|
||||
);
|
||||
}
|
||||
@@ -158,9 +175,9 @@ export class SetupWizardApiService {
|
||||
*/
|
||||
resumeSession(sessionId: string): Observable<SetupSession | null> {
|
||||
return this.http
|
||||
.get<ApiResponse<SetupSessionResponse>>(`${this.setupBaseUrl}/sessions/${sessionId}`)
|
||||
.get<SetupSessionResponse>(`${this.setupBaseUrl}/sessions/${sessionId}`)
|
||||
.pipe(
|
||||
map(response => this.mapSessionResponse(response.data)),
|
||||
map(response => this.mapSessionResponse(response)),
|
||||
catchError(error => {
|
||||
if (error.status === 404) {
|
||||
return of(null);
|
||||
@@ -175,9 +192,9 @@ export class SetupWizardApiService {
|
||||
*/
|
||||
getCurrentSession(): Observable<SetupSession | null> {
|
||||
return this.http
|
||||
.get<ApiResponse<SetupSessionResponse>>(`${this.setupBaseUrl}/sessions/current`)
|
||||
.get<SetupSessionResponse>(`${this.setupBaseUrl}/sessions/current`)
|
||||
.pipe(
|
||||
map(response => this.mapSessionResponse(response.data)),
|
||||
map(response => this.mapSessionResponse(response)),
|
||||
catchError(error => {
|
||||
if (error.status === 404) {
|
||||
return of(null);
|
||||
@@ -454,16 +471,54 @@ export class SetupWizardApiService {
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
|
||||
private mapSessionResponse(response: SetupSessionResponse): SetupSession {
|
||||
const s = response.session;
|
||||
|
||||
// Derive completedSteps and skippedSteps from the steps array
|
||||
const completedSteps = s.steps
|
||||
.filter(step => step.status === 'Passed')
|
||||
.map(step => this.mapStepId(step.stepId));
|
||||
|
||||
const skippedSteps = s.steps
|
||||
.filter(step => step.status === 'Skipped')
|
||||
.map(step => this.mapStepId(step.stepId));
|
||||
|
||||
// Find the current step (status === 'Current')
|
||||
const currentBackendStep = s.steps.find(step => step.status === 'Current');
|
||||
|
||||
return {
|
||||
sessionId: response.sessionId,
|
||||
startedAt: response.startedAt,
|
||||
completedSteps: response.completedSteps,
|
||||
skippedSteps: response.skippedSteps,
|
||||
configValues: response.configValues,
|
||||
currentStep: response.currentStep,
|
||||
sessionId: s.sessionId,
|
||||
startedAt: s.createdAtUtc,
|
||||
completedSteps,
|
||||
skippedSteps,
|
||||
configValues: {},
|
||||
currentStep: currentBackendStep
|
||||
? this.mapStepId(currentBackendStep.stepId)
|
||||
: undefined,
|
||||
};
|
||||
}
|
||||
|
||||
/** Maps backend PascalCase step ID to frontend lowercase step ID */
|
||||
private mapStepId(backendId: string): SetupStepId {
|
||||
const mapping: Record<string, SetupStepId> = {
|
||||
Database: 'database',
|
||||
Valkey: 'cache',
|
||||
Migrations: 'migrations',
|
||||
Admin: 'authority',
|
||||
Crypto: 'crypto',
|
||||
Vault: 'vault',
|
||||
Scm: 'scm',
|
||||
Sources: 'sources',
|
||||
Notifications: 'notify',
|
||||
Environments: 'environments',
|
||||
Agents: 'agents',
|
||||
Registry: 'registry',
|
||||
Telemetry: 'telemetry',
|
||||
Llm: 'llm',
|
||||
SettingsStore: 'settingsstore',
|
||||
};
|
||||
return mapping[backendId] ?? (backendId.toLowerCase() as SetupStepId);
|
||||
}
|
||||
|
||||
private mapStepResult(response: ExecuteStepResponse): SetupStepResult {
|
||||
return {
|
||||
stepId: response.stepId,
|
||||
|
||||
Reference in New Issue
Block a user