add artifact skill api methods and types
- gameName field on ArtifactSkill type - getSkill and updateSkill adapter methods - skillById query and skillDetail key
This commit is contained in:
parent
e83650cb97
commit
1e1f4f9478
3 changed files with 55 additions and 0 deletions
|
|
@ -124,6 +124,44 @@ export class ArtifactAdapter extends BaseAdapter {
|
||||||
return response.artifactSkills
|
return response.artifactSkills
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a single artifact skill by ID
|
||||||
|
*/
|
||||||
|
async getSkill(id: string): Promise<ArtifactSkill> {
|
||||||
|
return this.request<ArtifactSkill>(`/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<ArtifactSkill> {
|
||||||
|
const response = await this.request<ArtifactSkill>(`/artifact_skills/${id}`, {
|
||||||
|
method: 'PATCH',
|
||||||
|
body: data
|
||||||
|
})
|
||||||
|
this.clearCache('/artifact_skills')
|
||||||
|
this.clearCache(`/artifact_skills/${id}`)
|
||||||
|
return response
|
||||||
|
}
|
||||||
|
|
||||||
// ============================================
|
// ============================================
|
||||||
// Collection Artifacts
|
// Collection Artifacts
|
||||||
// ============================================
|
// ============================================
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,18 @@ export const artifactQueries = {
|
||||||
gcTime: 1000 * 60 * 60 * 24 // 24 hours
|
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
|
* User's collection artifacts with infinite scroll
|
||||||
*
|
*
|
||||||
|
|
@ -199,6 +211,9 @@ export const artifactKeys = {
|
||||||
/** Skills for a specific slot */
|
/** Skills for a specific slot */
|
||||||
skillsForSlot: (slot: number) => ['artifacts', 'skills', 'slot', slot] as const,
|
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 */
|
/** Collection artifacts base key */
|
||||||
collectionBase: ['collection', 'artifacts'] as const,
|
collectionBase: ['collection', 'artifacts'] as const,
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,8 @@ export interface Artifact {
|
||||||
export interface ArtifactSkill {
|
export interface ArtifactSkill {
|
||||||
id: string
|
id: string
|
||||||
name: LocalizedName
|
name: LocalizedName
|
||||||
|
/** Game name used for import matching (may differ from display name) */
|
||||||
|
gameName?: LocalizedName
|
||||||
/** Which skill group this belongs to (determines valid slots) */
|
/** Which skill group this belongs to (determines valid slots) */
|
||||||
skillGroup: ArtifactSkillGroup
|
skillGroup: ArtifactSkillGroup
|
||||||
/** Numeric modifier identifier */
|
/** Numeric modifier identifier */
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue