109 lines
2.3 KiB
TypeScript
109 lines
2.3 KiB
TypeScript
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
|
||
isActive?: boolean
|
||
}
|
||
|
||
class DynamicServiceService {
|
||
private readonly baseUrl = '/api/app/dynamic-app-service'
|
||
|
||
/**
|
||
* 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
|
||
}
|
||
|
||
/**
|
||
* 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> {
|
||
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
|
||
}
|
||
}
|
||
|
||
export const dynamicServiceService = new DynamicServiceService()
|