From b28ba551de67710ca18a5fbbd7a560ff18b6fcf7 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Mon, 1 Dec 2025 23:40:55 -0800 Subject: [PATCH] add batch preview adapter methods --- src/lib/api/adapters/entity.adapter.ts | 242 +++++++++++++++++++++++++ 1 file changed, 242 insertions(+) diff --git a/src/lib/api/adapters/entity.adapter.ts b/src/lib/api/adapters/entity.adapter.ts index 44911b44..b44dbe43 100644 --- a/src/lib/api/adapters/entity.adapter.ts +++ b/src/lib/api/adapters/entity.adapter.ts @@ -411,6 +411,108 @@ export interface EntityRawData { gameRawJp: Record | null } +/** + * Suggestions for character fields parsed from wiki data + */ +export interface CharacterSuggestions { + nameEn?: string + nameJp?: string + granblueId?: string + characterId?: number[] + rarity?: number + element?: number + gender?: number + proficiency1?: number + proficiency2?: number + race1?: number + race2?: number + minHp?: number + maxHp?: number + maxHpFlb?: number + minAtk?: number + maxAtk?: number + maxAtkFlb?: number + flb?: boolean + ulb?: boolean + releaseDate?: string + flbDate?: string + ulbDate?: string + gamewith?: string + kamigame?: string +} + +/** + * Suggestions for weapon fields parsed from wiki data + */ +export interface WeaponSuggestions { + nameEn?: string + nameJp?: string + granblueId?: string + rarity?: number + element?: number + proficiency?: number + minHp?: number + maxHp?: number + maxHpFlb?: number + minAtk?: number + maxAtk?: number + maxAtkFlb?: number + flb?: boolean + ulb?: boolean + releaseDate?: string + flbDate?: string + ulbDate?: string + gamewith?: string + kamigame?: string + recruits?: string +} + +/** + * Suggestions for summon fields parsed from wiki data + */ +export interface SummonSuggestions { + nameEn?: string + nameJp?: string + granblueId?: string + rarity?: number + element?: number + minHp?: number + maxHp?: number + maxHpFlb?: number + minAtk?: number + maxAtk?: number + maxAtkFlb?: number + flb?: boolean + ulb?: boolean + subaura?: boolean + releaseDate?: string + flbDate?: string + ulbDate?: string + gamewith?: string + kamigame?: string +} + +/** + * Result from batch_preview for a single wiki page + */ +export interface BatchPreviewResult { + wikiPage: string + status: 'success' | 'error' + granblueId?: string + wikiRaw?: string + suggestions?: T + imageStatus?: 'pending' | 'exists' | 'error' | 'no_id' + error?: string + redirectedFrom?: string +} + +/** + * Response from batch_preview endpoint + */ +export interface BatchPreviewResponse { + results: BatchPreviewResult[] +} + /** * Entity adapter for accessing canonical game data */ @@ -585,6 +687,26 @@ export class EntityAdapter extends BaseAdapter { }) } + /** + * Downloads a single image for a character (synchronous) + * Requires editor role (>= 7) + * @param characterId - Character database ID + * @param size - Image size variant (main, grid, square, detail) + * @param transformation - Pose variant (01=Base, 02=MLB, 03=FLB, 04=Transcendence) + * @param force - Force re-download even if image exists + */ + async downloadCharacterImage( + characterId: string, + size: string, + transformation?: string, + force?: boolean + ): Promise<{ success: boolean; error?: string }> { + return this.request(`/characters/${characterId}/download_image`, { + method: 'POST', + body: { size, transformation, force } + }) + } + /** * Gets the status of an ongoing character image download * Requires editor role (>= 7) @@ -688,6 +810,26 @@ export class EntityAdapter extends BaseAdapter { }) } + /** + * Downloads a single image for a summon (synchronous) + * Requires editor role (>= 7) + * @param summonId - Summon database ID + * @param size - Image size variant (main, grid, wide, square, detail) + * @param transformation - Pose variant (empty=Base, 02=ULB, 03=Trans1, 04=Trans5) + * @param force - Force re-download even if image exists + */ + async downloadSummonImage( + summonId: string, + size: string, + transformation?: string, + force?: boolean + ): Promise<{ success: boolean; error?: string }> { + return this.request(`/summons/${summonId}/download_image`, { + method: 'POST', + body: { size, transformation, force } + }) + } + /** * Gets the status of an ongoing summon image download * Requires editor role (>= 7) @@ -791,6 +933,26 @@ export class EntityAdapter extends BaseAdapter { }) } + /** + * Downloads a single image for a weapon (synchronous) + * Requires editor role (>= 7) + * @param weaponId - Weapon database ID + * @param size - Image size variant (main, grid, square, base) + * @param transformation - Pose variant (empty=Base, 02=Trans1, 03=Trans5) + * @param force - Force re-download even if image exists + */ + async downloadWeaponImage( + weaponId: string, + size: string, + transformation?: string, + force?: boolean + ): Promise<{ success: boolean; error?: string }> { + return this.request(`/weapons/${weaponId}/download_image`, { + method: 'POST', + body: { size, transformation, force } + }) + } + /** * Gets the status of an ongoing weapon image download * Requires editor role (>= 7) @@ -868,6 +1030,86 @@ export class EntityAdapter extends BaseAdapter { return response } + + // ============================================ + // Wiki Fetch Methods (editor-only) + // ============================================ + + /** + * Fetches and stores wiki data for a character + * Requires editor role (>= 7) + */ + async fetchCharacterWiki(id: string): Promise { + return this.request(`/characters/${id}/fetch_wiki`, { + method: 'POST' + }) + } + + /** + * Fetches and stores wiki data for a weapon + * Requires editor role (>= 7) + */ + async fetchWeaponWiki(id: string): Promise { + return this.request(`/weapons/${id}/fetch_wiki`, { + method: 'POST' + }) + } + + /** + * Fetches and stores wiki data for a summon + * Requires editor role (>= 7) + */ + async fetchSummonWiki(id: string): Promise { + return this.request(`/summons/${id}/fetch_wiki`, { + method: 'POST' + }) + } + + // ============================================ + // Batch Preview Methods (for batch import) + // ============================================ + + /** + * Fetches wiki data and suggestions for multiple character wiki pages + * Requires editor role (>= 7) + * @param wikiPages - Array of wiki page names (max 10) + */ + async batchPreviewCharacters( + wikiPages: string[] + ): Promise> { + return this.request>('/characters/batch_preview', { + method: 'POST', + body: { wiki_pages: wikiPages } + }) + } + + /** + * Fetches wiki data and suggestions for multiple weapon wiki pages + * Requires editor role (>= 7) + * @param wikiPages - Array of wiki page names (max 10) + */ + async batchPreviewWeapons( + wikiPages: string[] + ): Promise> { + return this.request>('/weapons/batch_preview', { + method: 'POST', + body: { wiki_pages: wikiPages } + }) + } + + /** + * Fetches wiki data and suggestions for multiple summon wiki pages + * Requires editor role (>= 7) + * @param wikiPages - Array of wiki page names (max 10) + */ + async batchPreviewSummons( + wikiPages: string[] + ): Promise> { + return this.request>('/summons/batch_preview', { + method: 'POST', + body: { wiki_pages: wikiPages } + }) + } } /**