diff --git a/src/lib/api/adapters/artifact.adapter.ts b/src/lib/api/adapters/artifact.adapter.ts index b9a321b8..ed9e02f1 100644 --- a/src/lib/api/adapters/artifact.adapter.ts +++ b/src/lib/api/adapters/artifact.adapter.ts @@ -124,6 +124,44 @@ export class ArtifactAdapter extends BaseAdapter { return response.artifactSkills } + /** + * Gets a single artifact skill by ID + */ + async getSkill(id: string): Promise { + return this.request(`/artifact_skills/${id}`, { + method: 'GET', + cacheTime: 60 * 60 * 1000 // 1 hour + }) + } + + /** + * Updates an artifact skill + */ + async updateSkill( + id: string, + data: Partial<{ + name_en: string + name_jp: string + game_name_en: string + game_name_jp: string + skill_group: number + modifier: number + polarity: string + base_values: (number | null)[] + growth: number + suffix_en: string + suffix_jp: string + }> + ): Promise { + const response = await this.request(`/artifact_skills/${id}`, { + method: 'PATCH', + body: data + }) + this.clearCache('/artifact_skills') + this.clearCache(`/artifact_skills/${id}`) + return response + } + // ============================================ // Collection Artifacts // ============================================ diff --git a/src/lib/api/queries/artifact.queries.ts b/src/lib/api/queries/artifact.queries.ts index 471d9457..ed5aa4c2 100644 --- a/src/lib/api/queries/artifact.queries.ts +++ b/src/lib/api/queries/artifact.queries.ts @@ -104,6 +104,18 @@ export const artifactQueries = { gcTime: 1000 * 60 * 60 * 24 // 24 hours }), + /** + * Single artifact skill by ID + */ + skillById: (id: string) => + queryOptions({ + queryKey: ['artifacts', 'skills', 'detail', id] as const, + queryFn: () => artifactAdapter.getSkill(id), + enabled: !!id, + staleTime: 1000 * 60 * 60, // 1 hour + gcTime: 1000 * 60 * 60 * 24 // 24 hours + }), + /** * User's collection artifacts with infinite scroll * @@ -199,6 +211,9 @@ export const artifactKeys = { /** Skills for a specific slot */ skillsForSlot: (slot: number) => ['artifacts', 'skills', 'slot', slot] as const, + /** Single skill by ID */ + skillDetail: (id: string) => ['artifacts', 'skills', 'detail', id] as const, + /** Collection artifacts base key */ collectionBase: ['collection', 'artifacts'] as const, diff --git a/src/lib/types/api/artifact.ts b/src/lib/types/api/artifact.ts index 3fa78f04..6ab7420a 100644 --- a/src/lib/types/api/artifact.ts +++ b/src/lib/types/api/artifact.ts @@ -45,6 +45,8 @@ export interface Artifact { export interface ArtifactSkill { id: string name: LocalizedName + /** Game name used for import matching (may differ from display name) */ + gameName?: LocalizedName /** Which skill group this belongs to (determines valid slots) */ skillGroup: ArtifactSkillGroup /** Numeric modifier identifier */