import apiService from './api.service' export interface CompilationError { code: string message: string line: number column: number severity: string fileName?: string } export interface CompileResult { success: boolean errorMessage?: string errors?: CompilationError[] compilationTimeMs: number hasWarnings: boolean warnings?: string[] } export interface PublishResult { success: boolean errorMessage?: string appServiceId?: string swaggerUrl?: string generatedEndpoints?: string[] controllerName?: string } export interface DynamicServiceDto { id: string name: string displayName: string description: string code: string isActive: boolean compilationStatus: string lastCompilationError?: string lastSuccessfulCompilation?: string version: number codeHash?: string primaryEntityType?: string controllerName?: string creationTime: string } export interface TestCompileDto { code: string } export interface PublishDto { name: string code: string displayName?: string description?: string primaryEntityType?: string } export interface DynamicAppServiceListResult { items: DynamicServiceDto[] totalCount: number } export const postTestCompile = (input: TestCompileDto) => apiService.fetchData({ method: 'POST', url: `/api/app/dynamic-app-service/test-compile`, data: input as any, }) class DynamicServiceService { private readonly baseUrl = '/api/app/dynamic-app-service' /** * Tüm dynamic app service'leri listele */ async getList(): Promise { const response = await apiService.fetchData({ url: this.baseUrl, method: 'GET', }) return response.data } /** * ID'ye göre dynamic app service detayını getir */ async getById(id: string): Promise { const response = await apiService.fetchData({ url: `${this.baseUrl}/${id}`, method: 'GET', }) return response.data } /** * Yeni dynamic app service oluştur */ async create(data: DynamicServiceDto): Promise { const response = await apiService.fetchData({ url: this.baseUrl, method: 'POST', data: data as any, }) return response.data } /** * Dynamic app service güncelle */ async update(id: string, data: Partial): Promise { const response = await apiService.fetchData({ url: `${this.baseUrl}/${id}`, method: 'PUT', data: data as any, }) return response.data } /** * Dynamic app service sil */ async delete(id: string): Promise { await apiService.fetchData({ url: `${this.baseUrl}/${id}`, method: 'DELETE', }) } /** * Kodu test et (compile) */ async testCompile(data: TestCompileDto): Promise { console.log('DynamicServiceService.testCompile called with data:', data) const response = await apiService.fetchData({ url: `${this.baseUrl}/test-compile`, method: 'POST', data: data as any, }) return response.data } /** * Dynamic app service'i yayınla */ async publish(data: PublishDto): Promise { const response = await apiService.fetchData({ url: `${this.baseUrl}/publish`, method: 'POST', data: data as any, }) return response.data } /** * Dynamic app service'i aktif/pasif yap */ async toggleActive(id: string, isActive: boolean): Promise { await apiService.fetchData({ url: `${this.baseUrl}/${id}/toggle-active`, method: 'POST', data: { isActive } as any, }) } /** * Compilation durumunu getir */ async getCompilationStatus(id: string): Promise<{ status: string; error?: string }> { const response = await apiService.fetchData<{ status: string; error?: string }>({ url: `${this.baseUrl}/${id}/compilation-status`, method: 'GET', }) return response.data } } export const dynamicServiceService = new DynamicServiceService()