sozsoft-platform/ui/src/services/dynamicService.service.ts
2026-09-05 12:06:14 +03:00

109 lines
2.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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()