2026-02-24 20:44:16 +00:00
|
|
|
import { PagedResultDto } from '@/proxy'
|
|
|
|
|
import apiService from './api.service'
|
|
|
|
|
import {
|
|
|
|
|
CrudEndpoint,
|
|
|
|
|
CreateUpdateCrudEndpointDto,
|
|
|
|
|
CreateUpdateCustomComponentDto,
|
|
|
|
|
CustomComponent,
|
|
|
|
|
CustomComponentDto,
|
|
|
|
|
} from '@/proxy/developerKit/models'
|
|
|
|
|
|
|
|
|
|
class DeveloperKitService {
|
|
|
|
|
// Custom Component endpoints
|
|
|
|
|
async getCustomComponents(): Promise<PagedResultDto<CustomComponentDto>> {
|
|
|
|
|
const response = await apiService.fetchData<PagedResultDto<CustomComponentDto>>({
|
|
|
|
|
url: '/api/app/custom-component',
|
|
|
|
|
method: 'GET',
|
|
|
|
|
})
|
|
|
|
|
return response.data
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async getActiveCustomComponents(): Promise<PagedResultDto<CustomComponentDto>> {
|
|
|
|
|
const response = await apiService.fetchData<PagedResultDto<CustomComponentDto>>({
|
|
|
|
|
url: '/api/app/custom-component/active-components',
|
|
|
|
|
method: 'GET',
|
|
|
|
|
})
|
|
|
|
|
return response.data
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async getCustomComponent(id: string): Promise<CustomComponent> {
|
|
|
|
|
const response = await apiService.fetchData<CustomComponent>({
|
|
|
|
|
url: `/api/app/custom-component/${id}`,
|
|
|
|
|
method: 'GET',
|
|
|
|
|
})
|
|
|
|
|
return response.data
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async createCustomComponent(component: CreateUpdateCustomComponentDto): Promise<CustomComponent> {
|
|
|
|
|
const response = await apiService.fetchData<CustomComponent>({
|
|
|
|
|
url: '/api/app/custom-component',
|
|
|
|
|
method: 'POST',
|
|
|
|
|
data: component as any,
|
|
|
|
|
})
|
|
|
|
|
return response.data
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async updateCustomComponent(
|
|
|
|
|
id: string,
|
|
|
|
|
component: CreateUpdateCustomComponentDto,
|
|
|
|
|
): Promise<CustomComponent> {
|
|
|
|
|
const response = await apiService.fetchData<CustomComponent>({
|
|
|
|
|
url: `/api/app/custom-component/${id}`,
|
|
|
|
|
method: 'PUT',
|
|
|
|
|
data: component as any,
|
|
|
|
|
})
|
|
|
|
|
return response.data
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async deleteCustomComponent(id: string): Promise<void> {
|
|
|
|
|
await apiService.fetchData<void>({
|
|
|
|
|
url: `/api/app/custom-component/${id}`,
|
|
|
|
|
method: 'DELETE',
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Generated Endpoint endpoints
|
2026-03-02 21:34:19 +00:00
|
|
|
async getActiveGeneratedEndpoints(): Promise<PagedResultDto<CrudEndpoint>> {
|
2026-02-24 20:44:16 +00:00
|
|
|
const response = await apiService.fetchData<PagedResultDto<CrudEndpoint>>({
|
2026-03-02 21:34:19 +00:00
|
|
|
url: '/api/app/crud-endpoint-generate/active-endpoints',
|
2026-02-24 20:44:16 +00:00
|
|
|
method: 'GET',
|
|
|
|
|
})
|
|
|
|
|
return response.data
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-02 21:34:19 +00:00
|
|
|
async toggleGeneratedEndpoint(id: string): Promise<CrudEndpoint> {
|
|
|
|
|
const response = await apiService.fetchData<CrudEndpoint>({
|
|
|
|
|
url: `/api/app/crud-endpoint-generate/${id}/toggle`,
|
|
|
|
|
method: 'POST',
|
|
|
|
|
})
|
|
|
|
|
return response.data
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async generateCrudEndpoints(entityName: string): Promise<PagedResultDto<CrudEndpoint>> {
|
2026-02-24 20:44:16 +00:00
|
|
|
const response = await apiService.fetchData<PagedResultDto<CrudEndpoint>>({
|
2026-03-02 21:34:19 +00:00
|
|
|
url: `/api/app/crud-endpoint-generate/generate-crud-endpoints/${entityName}`,
|
|
|
|
|
method: 'POST',
|
2026-02-24 20:44:16 +00:00
|
|
|
})
|
|
|
|
|
return response.data
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-02 21:34:19 +00:00
|
|
|
async getGeneratedListEndpoints(): Promise<PagedResultDto<CrudEndpoint>> {
|
2026-02-24 20:44:16 +00:00
|
|
|
const response = await apiService.fetchData<PagedResultDto<CrudEndpoint>>({
|
2026-03-02 21:34:19 +00:00
|
|
|
url: '/api/app/crud-endpoint-generate',
|
2026-02-24 20:44:16 +00:00
|
|
|
method: 'GET',
|
|
|
|
|
})
|
|
|
|
|
return response.data
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async getGeneratedEndpoint(id: string): Promise<CrudEndpoint> {
|
|
|
|
|
const response = await apiService.fetchData<CrudEndpoint>({
|
|
|
|
|
url: `/api/app/crud-endpoint-generate/${id}`,
|
|
|
|
|
method: 'GET',
|
|
|
|
|
})
|
|
|
|
|
return response.data
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async createGeneratedEndpoint(data: CreateUpdateCrudEndpointDto): Promise<CrudEndpoint> {
|
|
|
|
|
const response = await apiService.fetchData<CrudEndpoint>({
|
|
|
|
|
url: '/api/app/crud-endpoint-generate',
|
|
|
|
|
method: 'POST',
|
|
|
|
|
data: data as any,
|
|
|
|
|
})
|
|
|
|
|
return response.data
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async updateGeneratedEndpoint(
|
|
|
|
|
id: string,
|
|
|
|
|
endpoint: CreateUpdateCrudEndpointDto,
|
|
|
|
|
): Promise<CrudEndpoint> {
|
|
|
|
|
const response = await apiService.fetchData<CrudEndpoint>({
|
|
|
|
|
url: `/api/app/crud-endpoint-generate/${id}`,
|
|
|
|
|
method: 'PUT',
|
|
|
|
|
data: endpoint as any,
|
|
|
|
|
})
|
|
|
|
|
return response.data
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async deleteGeneratedEndpoint(id: string): Promise<void> {
|
|
|
|
|
await apiService.fetchData<void>({
|
|
|
|
|
url: `/api/app/crud-endpoint-generate/${id}`,
|
|
|
|
|
method: 'DELETE',
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const developerKitService = new DeveloperKitService()
|