import { Injectable } from '@angular/core'; import { HttpClient, HttpParams } from '@angular/common/http'; import { Observable } from 'rxjs'; import { Artifact, ArtifactQuery, ApiInfo } from '../models/artifact.model'; @Injectable({ providedIn: 'root' }) export class ArtifactService { private apiUrl = '/api/v1/artifacts'; private baseUrl = '/api'; constructor(private http: HttpClient) {} getApiInfo(): Observable { return this.http.get(this.baseUrl); } listArtifacts(limit: number = 100, offset: number = 0): Observable { const params = new HttpParams() .set('limit', limit.toString()) .set('offset', offset.toString()); return this.http.get(this.apiUrl + '/', { params }); } getArtifact(id: number): Observable { return this.http.get(`${this.apiUrl}/${id}`); } queryArtifacts(query: ArtifactQuery): Observable { return this.http.post(`${this.apiUrl}/query`, query); } uploadArtifact(formData: FormData): Observable { return this.http.post(`${this.apiUrl}/upload`, formData); } downloadArtifact(id: number): Observable { return this.http.get(`${this.apiUrl}/${id}/download`, { responseType: 'blob' }); } deleteArtifact(id: number): Observable { return this.http.delete(`${this.apiUrl}/${id}`); } generateSeedData(count: number): Observable { return this.http.post(`/api/v1/seed/generate/${count}`, {}); } }