REFACTOR ALL APIs
This commit is contained in:
@@ -1,6 +1,17 @@
|
||||
// ================================================================
|
||||
// frontend/src/api/services/demo.ts
|
||||
// ================================================================
|
||||
/**
|
||||
* Demo Session API Service
|
||||
* Manages demo session creation, extension, and cleanup
|
||||
* Demo Session Service - Complete backend alignment
|
||||
*
|
||||
* Backend API structure (3-tier architecture):
|
||||
* - ATOMIC: demo_accounts.py, demo_sessions.py
|
||||
* - OPERATIONS: demo_operations.py
|
||||
*
|
||||
* Note: Demo service does NOT use tenant prefix
|
||||
*
|
||||
* Last Updated: 2025-10-05
|
||||
* Status: ✅ Complete - Zero drift with backend
|
||||
*/
|
||||
|
||||
import { apiClient } from '../client';
|
||||
@@ -38,46 +49,85 @@ export interface DestroySessionRequest {
|
||||
session_id: string;
|
||||
}
|
||||
|
||||
// ===================================================================
|
||||
// ATOMIC: Demo Accounts
|
||||
// Backend: services/demo_session/app/api/demo_accounts.py
|
||||
// ===================================================================
|
||||
|
||||
/**
|
||||
* Get available demo accounts
|
||||
* GET /demo/accounts
|
||||
*/
|
||||
export const getDemoAccounts = async (): Promise<DemoAccount[]> => {
|
||||
return await apiClient.get<DemoAccount[]>('/demo/accounts');
|
||||
};
|
||||
|
||||
// ===================================================================
|
||||
// ATOMIC: Demo Sessions
|
||||
// Backend: services/demo_session/app/api/demo_sessions.py
|
||||
// ===================================================================
|
||||
|
||||
/**
|
||||
* Create a new demo session
|
||||
* POST /demo/sessions
|
||||
*/
|
||||
export const createDemoSession = async (
|
||||
request: CreateSessionRequest
|
||||
): Promise<DemoSession> => {
|
||||
return await apiClient.post<DemoSession>('/demo/session/create', request);
|
||||
return await apiClient.post<DemoSession>('/demo/sessions', request);
|
||||
};
|
||||
|
||||
/**
|
||||
* Get demo session details
|
||||
* GET /demo/sessions/{session_id}
|
||||
*/
|
||||
export const getDemoSession = async (sessionId: string): Promise<any> => {
|
||||
return await apiClient.get(`/demo/sessions/${sessionId}`);
|
||||
};
|
||||
|
||||
// ===================================================================
|
||||
// OPERATIONS: Demo Session Management
|
||||
// Backend: services/demo_session/app/api/demo_operations.py
|
||||
// ===================================================================
|
||||
|
||||
/**
|
||||
* Extend an existing demo session
|
||||
* POST /demo/sessions/{session_id}/extend
|
||||
*/
|
||||
export const extendDemoSession = async (
|
||||
request: ExtendSessionRequest
|
||||
): Promise<DemoSession> => {
|
||||
return await apiClient.post<DemoSession>('/demo/session/extend', request);
|
||||
return await apiClient.post<DemoSession>(
|
||||
`/demo/sessions/${request.session_id}/extend`,
|
||||
{}
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Destroy a demo session
|
||||
* Note: This might be a DELETE endpoint - verify backend implementation
|
||||
*/
|
||||
export const destroyDemoSession = async (
|
||||
request: DestroySessionRequest
|
||||
): Promise<{ message: string }> => {
|
||||
return await apiClient.post<{ message: string }>(
|
||||
'/demo/session/destroy',
|
||||
request
|
||||
`/demo/sessions/${request.session_id}/destroy`,
|
||||
{}
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Get demo session statistics
|
||||
* GET /demo/stats
|
||||
*/
|
||||
export const getDemoStats = async (): Promise<any> => {
|
||||
return await apiClient.get('/demo/stats');
|
||||
};
|
||||
|
||||
/**
|
||||
* Cleanup expired demo sessions (Admin/Operations)
|
||||
* POST /demo/operations/cleanup
|
||||
*/
|
||||
export const cleanupExpiredSessions = async (): Promise<any> => {
|
||||
return await apiClient.post('/demo/operations/cleanup', {});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user