From 100a04eda6d8e948e3bf6f8b84ce0dccb55cbe9a Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Sat, 20 Sep 2025 02:26:54 -0700 Subject: [PATCH] Fix adapter field names and runed import - Update Party interface to use transformed field names (weapons/characters/summons) - Fix runed import to use useDebounce instead of debounced - Clean up debug logging --- src/lib/api/adapters/party.adapter.ts | 23 ++++++++++--------- .../resources/search.resource.svelte.ts | 12 +++++++--- src/routes/teams/[id]/+page.server.ts | 9 +------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/lib/api/adapters/party.adapter.ts b/src/lib/api/adapters/party.adapter.ts index 7d67af63..31e1fc58 100644 --- a/src/lib/api/adapters/party.adapter.ts +++ b/src/lib/api/adapters/party.adapter.ts @@ -46,9 +46,9 @@ export interface Party { name: Record } } - gridWeapons: GridWeapon[] - gridSummons: GridSummon[] - gridCharacters: GridCharacter[] + weapons: GridWeapon[] + summons: GridSummon[] + characters: GridCharacter[] guidebook?: { id: string title: string @@ -195,31 +195,30 @@ export interface GridUpdateResponse { */ export class PartyAdapter extends BaseAdapter { constructor(options?: AdapterOptions) { - super({ - ...options, - baseURL: options?.baseURL || '/api/v1' - }) + super(options) } /** * Creates a new party */ async create(params: CreatePartyParams): Promise { - return this.request('/parties', { + const response = await this.request<{ party: Party }>('/parties', { method: 'POST', body: { party: params } }) + return response.party } /** * Gets a party by shortcode */ async getByShortcode(shortcode: string): Promise { - return this.request(`/parties/${shortcode}`, { + const response = await this.request<{ party: Party }>(`/parties/${shortcode}`, { cacheTTL: 60000 // Cache for 1 minute }) + return response.party } /** @@ -227,12 +226,13 @@ export class PartyAdapter extends BaseAdapter { */ async update(params: UpdatePartyParams): Promise { const { shortcode, ...updateParams } = params - return this.request(`/parties/${shortcode}`, { + const response = await this.request<{ party: Party }>(`/parties/${shortcode}`, { method: 'PATCH', body: { party: updateParams } }) + return response.party } /** @@ -248,9 +248,10 @@ export class PartyAdapter extends BaseAdapter { * Creates a remix (copy) of an existing party */ async remix(shortcode: string): Promise { - return this.request(`/parties/${shortcode}/remix`, { + const response = await this.request<{ party: Party }>(`/parties/${shortcode}/remix`, { method: 'POST' }) + return response.party } /** diff --git a/src/lib/api/adapters/resources/search.resource.svelte.ts b/src/lib/api/adapters/resources/search.resource.svelte.ts index 1a1f11a7..8295c6a0 100644 --- a/src/lib/api/adapters/resources/search.resource.svelte.ts +++ b/src/lib/api/adapters/resources/search.resource.svelte.ts @@ -7,7 +7,7 @@ * @module adapters/resources/search */ -import { debounced } from 'runed' +import { useDebounce } from 'runed' import { SearchAdapter, searchAdapter, type SearchParams, type SearchResponse } from '../search.adapter' import type { AdapterError } from '../types' @@ -152,8 +152,14 @@ export class SearchResource { } } - // Return debounced version - return debounced(searchFn, this.debounceMs) + // Create a debounced wrapper using useDebounce + const debouncedSearch = useDebounce( + (params: SearchParams) => searchFn(params), + () => this.debounceMs + ) + + // Return a function that calls the debounced search + return (params: SearchParams) => debouncedSearch(params) } // Create debounced search methods diff --git a/src/routes/teams/[id]/+page.server.ts b/src/routes/teams/[id]/+page.server.ts index d16f0268..27877122 100644 --- a/src/routes/teams/[id]/+page.server.ts +++ b/src/routes/teams/[id]/+page.server.ts @@ -2,8 +2,6 @@ import type { PageServerLoad } from './$types' import { PartyService } from '$lib/services/party.service' export const load: PageServerLoad = async ({ params, fetch, locals }) => { - console.log('[p/[id]/+page.server.ts] Loading with id:', params.id) - // Get auth data directly from locals instead of parent() const authUserId = locals.session?.account?.userId @@ -17,17 +15,12 @@ export const load: PageServerLoad = async ({ params, fetch, locals }) => { try { // Fetch the party party = await partyService.getByShortcode(params.id) - console.log('[p/[id]] Successfully fetched party on server:', party.id, party.name) partyFound = true // Determine if user can edit - console.log('[p/[id]] Auth user ID:', authUserId) - console.log('[p/[id]] Party user ID:', party.user?.id) - console.log('[p/[id]] Party user:', party.user) canEdit = authUserId ? party.user?.id === authUserId : false - console.log('[p/[id]] Can edit?', canEdit) } catch (err) { - console.log('[p/[id]] Error fetching party (expected for test ids):', err) + // Error is expected for test/invalid IDs } // Return party data with explicit serialization