2025-11-04 22:08:36 +00:00
|
|
|
|
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
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-05 11:48:08 +00:00
|
|
|
|
export const postTestCompile = (input: TestCompileDto) =>
|
2025-11-04 22:08:36 +00:00
|
|
|
|
apiService.fetchData<CompileResult>({
|
|
|
|
|
|
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<DynamicAppServiceListResult> {
|
|
|
|
|
|
const response = await apiService.fetchData<DynamicAppServiceListResult>({
|
|
|
|
|
|
url: this.baseUrl,
|
|
|
|
|
|
method: 'GET',
|
|
|
|
|
|
})
|
|
|
|
|
|
return response.data
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* ID'ye göre dynamic app service detayını getir
|
|
|
|
|
|
*/
|
|
|
|
|
|
async getById(id: string): Promise<DynamicServiceDto> {
|
|
|
|
|
|
const response = await apiService.fetchData<DynamicServiceDto>({
|
|
|
|
|
|
url: `${this.baseUrl}/${id}`,
|
|
|
|
|
|
method: 'GET',
|
|
|
|
|
|
})
|
|
|
|
|
|
return response.data
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Yeni dynamic app service oluştur
|
|
|
|
|
|
*/
|
|
|
|
|
|
async create(data: DynamicServiceDto): Promise<DynamicServiceDto> {
|
|
|
|
|
|
const response = await apiService.fetchData<DynamicServiceDto>({
|
|
|
|
|
|
url: this.baseUrl,
|
|
|
|
|
|
method: 'POST',
|
|
|
|
|
|
data: data as any,
|
|
|
|
|
|
})
|
|
|
|
|
|
return response.data
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Dynamic app service güncelle
|
|
|
|
|
|
*/
|
|
|
|
|
|
async update(id: string, data: Partial<DynamicServiceDto>): Promise<DynamicServiceDto> {
|
|
|
|
|
|
const response = await apiService.fetchData<DynamicServiceDto>({
|
|
|
|
|
|
url: `${this.baseUrl}/${id}`,
|
|
|
|
|
|
method: 'PUT',
|
|
|
|
|
|
data: data as any,
|
|
|
|
|
|
})
|
|
|
|
|
|
return response.data
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Dynamic app service sil
|
|
|
|
|
|
*/
|
|
|
|
|
|
async delete(id: string): Promise<void> {
|
|
|
|
|
|
await apiService.fetchData<void>({
|
|
|
|
|
|
url: `${this.baseUrl}/${id}`,
|
|
|
|
|
|
method: 'DELETE',
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Kodu test et (compile)
|
|
|
|
|
|
*/
|
|
|
|
|
|
async testCompile(data: TestCompileDto): Promise<CompileResult> {
|
|
|
|
|
|
console.log('DynamicServiceService.testCompile called with data:', data)
|
|
|
|
|
|
const response = await apiService.fetchData<CompileResult>({
|
|
|
|
|
|
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<PublishResult> {
|
|
|
|
|
|
const response = await apiService.fetchData<PublishResult>({
|
|
|
|
|
|
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<void> {
|
|
|
|
|
|
await apiService.fetchData<void>({
|
|
|
|
|
|
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()
|