Commit graph

104 commits

Author SHA1 Message Date
f4d04a7073 gw event page improvements
- total honors instead of total score
- muted style for players with existing scores
- by-event score endpoints
2025-12-04 03:02:58 -08:00
43f9f37ccc add sync mutations for grid items 2025-12-03 22:52:31 -08:00
48121612fc add collection refs and sync methods to frontend types and adapters 2025-12-03 22:51:23 -08:00
eaae29f007 simplify artifact mutation, remove optimistic update 2025-12-03 20:51:58 -08:00
e595196172 clean up debug logs from skill filtering investigation 2025-12-03 17:14:05 -08:00
a29cdbb454 fix cache key to include query params
was generating same cache key for /artifact_skills and
/artifact_skills?group=group_i causing filtered requests
to return cached unfiltered results
2025-12-03 17:13:54 -08:00
52660f3fb1 add collection artifact feature (cards, rows, pane, route)
- CollectionArtifactCard for grid view
- CollectionArtifactRow for list view
- CollectionArtifactPane for sidebar details
- artifacts collection page with filters and infinite scroll
- getArtifactImage util
- update collection layout for artifacts tab
2025-12-03 16:17:15 -08:00
ab1243190b add artifact queries and mutations
- artifactQueries: reference data (cached 1hr), collection infinite, skills by slot
- artifactKeys: cache invalidation helpers
- mutations: collection CRUD, grid CRUD, equip, and grading
2025-12-03 15:59:19 -08:00
1e708e1064 add artifact adapter for API communication
covers reference data, collection artifacts, grid artifacts,
and stateless grading endpoints.
2025-12-03 15:57:29 -08:00
0259a8ad68 update test mocks to use WeaponSeriesRef 2025-12-03 11:59:40 -08:00
c5f6963ca7 update search and party schemas for weapon series objects 2025-12-03 11:59:12 -08:00
23a2481190 update entity adapter to use seriesSlug, add weapon series CRUD methods 2025-12-03 11:59:07 -08:00
e0a41102fd fix infinite scroll pagination in collection queries
use pageParam instead of response.page (which was undefined)
2025-12-03 09:03:52 -08:00
debf502a6c use batch endpoints for collection add operations
single request instead of one per item
2025-12-03 09:03:47 -08:00
c37c4f0101 fix request cancellation issue in batch add weapons/summons
The addWeapons/addSummons methods were using Promise.all with Array.fill()
which created arrays where all elements referenced the same object. This
caused the request deduplication logic in BaseAdapter to cancel previous
requests since they all had the same body/requestId.

Fix:
- Use Array.from() with spread to create unique object instances
- Execute requests sequentially to avoid deduplication conflicts
- Improve error handling in AddToCollectionModal to filter CancelledErrors
2025-12-03 07:37:03 -08:00
957dd16e5e add quantity counter and selectable components for weapons/summons
- QuantityCounter: +/- buttons for multi-copy selection
- SelectableWeaponCard/Row: weapon selection with quantity
- SelectableSummonCard/Row: summon selection with quantity
- AddToCollectionModal: support entityType prop, Map for quantities
- CollectionFilters: entityType-aware filter visibility
2025-12-03 07:19:04 -08:00
13a3905776 add batch weapon/summon methods to collection adapter and mutations 2025-12-03 07:14:30 -08:00
b8a48771dd update collection adapter/queries for unified api
- add userId param to list methods
- remove public collection methods (now unified)
- update query keys to include userId
2025-12-02 15:31:46 -08:00
491026399f fix search api: wrap body in search key, use X-Per-Page header, 50 per page 2025-12-02 15:06:38 -08:00
7808c75452 fix cache key generation for POST requests with object bodies 2025-12-02 15:06:33 -08:00
60ac5d4ab2 add collection API layer
Types, adapter, queries, and mutations for managing user collections
(characters, weapons, summons, job accessories). Supports both private
collection management and public collection viewing with privacy.
2025-12-02 09:28:22 -08:00
be92eba4aa fix user settings API to match rails backend params 2025-12-02 08:51:57 -08:00
f26d3e3883 add season, series, promotions filters to search adapter 2025-12-02 05:25:29 -08:00
67b87c7d1b add season, series, promotions to entity types 2025-12-02 05:25:23 -08:00
afb81e0f55 add nicknames, links sections to entity detail pages; show recruits in weapon metadata 2025-12-02 02:15:03 -08:00
6683a9e53a import pages: add wiki_raw to payload, misc fixes 2025-12-02 01:25:28 -08:00
b28ba551de add batch preview adapter methods 2025-12-01 23:40:55 -08:00
1cbcd91f94 entity adapter: add raw data fetch methods 2025-12-01 09:54:39 -08:00
179cc13725 adapters: add update methods for characters, weapons, and summons
Add updateCharacter(), updateSummon(), and updateWeapon() methods to
entity adapter. Each method uses PATCH and clears the entity cache
after successful update.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 03:24:15 -08:00
0d0163edec characters: add nicknames to creation page
Backfill nicknames support to character creation page:
- Add nicknamesEn and nicknamesJp fields to editData
- Import and use TagInput component for nickname entry
- Add nicknames section to form UI
- Update CreateCharacterPayload interface with nickname fields

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 03:10:31 -08:00
901fd5a157 weapons: add frontend adapter methods and interfaces
Add weapon creation infrastructure to entity adapter:
- WeaponValidationResult interface for validation response
- CreateWeaponPayload interface for weapon creation
- WeaponDownloadStatus interface for download status
- validateWeaponGranblueId() method
- createWeapon() method
- downloadWeaponImages() method
- getWeaponDownloadStatus() method

Also add getWeaponSeriesOptions() utility function.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 03:06:04 -08:00
4973643ee6 entity adapter: add summon creation methods
- SummonValidationResult, CreateSummonPayload, SummonDownloadStatus types
- validateSummonGranblueId(), createSummon(), downloadSummonImages(), getSummonDownloadStatus()
- Matches character creation pattern

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 02:44:45 -08:00
e9463ae5ba api config: add getImageBaseUrl, fix api path for prod/dev 2025-12-01 02:26:16 -08:00
220432b40a entity adapter: expand CreateCharacterPayload with all fields 2025-12-01 02:25:52 -08:00
5f5b579ff0 add /database/characters/new page + API methods
- new page with granblue_id validation
- role check (>= 7) on server
- API methods: validate, create, download images
- permanent edit mode with create button
2025-12-01 00:55:53 -08:00
a262388fc7 fix api path for prod (/v1) vs dev (/api/v1) 2025-11-30 23:34:32 -08:00
c3ed9b2885 api: update entity adapter and queries 2025-11-30 20:06:40 -08:00
5df563198b fix: render related characters 2025-11-30 14:57:43 -08:00
8b078cdfd8 feat: add conflict dialog for duplicate characters/weapons 2025-11-30 02:32:03 -08:00
18328e2d38 fix: party mutation parameter types
- favorite/unfavorite take shortcode string directly
- delete takes {id, shortcode} since API expects UUID
- remix takes shortcode string directly
- update spreads updates at top level
2025-11-30 02:31:42 -08:00
f346a73b61 fix: handle 204 No Content responses in base adapter 2025-11-30 02:31:37 -08:00
2275daec61 fix: PartySegmentedControl rep components now update reactively
The WeaponRep (and other rep components) weren't visually updating when
new items were added to the party. The issue was that Svelte's reactivity
wasn't properly propagating through the {#each} blocks.

Changes:
- PartySegmentedControl: Add derived values for party sub-properties to
  ensure reactivity propagates through snippet boundaries
- WeaponRep: Pre-compute rows as explicit $derived value and use keyed
  {#each} blocks for proper change detection

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-30 00:23:44 -08:00
f457343e26
Complete TanStack Query v6 migration (#445)
## Overview

Complete migration from service layer to TanStack Query v6 with
mutations, queries, and automatic cache management.

## What Was Completed

### Phase 1: Entity Queries & Database Pages 
- Created `entity.queries.ts` with query options for weapons,
characters, and summons
- Migrated all database detail pages to use TanStack Query with
`withInitialData()` pattern
- SSR with client-side hydration working correctly

### Phase 2: Server Load Cleanup 
- Removed PartyService dependency from teams detail server load
- Server loads now use adapters directly instead of service layer
- Cleaner separation of concerns

### Phase 3: Party.svelte Refactoring 
- Removed all PartyService, GridService, and ConflictService
dependencies
- Migrated to TanStack Query mutations for all operations:
  - Grid operations: create, update, delete, swap, move
  - Party operations: update, delete, remix, favorite, unfavorite
- Added swap/move mutations for drag-and-drop operations
- Automatic cache invalidation and query refetching

### Phase 4: Service Layer Removal 
- Deleted all service layer files (~1,345 lines removed):
  - `party.service.ts` (620 lines)
  - `grid.service.ts` (450 lines)
  - `conflict.service.ts` (120 lines)
  - `gridOperations.ts` (unused utility)
- Deleted empty `services/` directory
- Created utility functions for cross-cutting concerns:
  - `localId.ts`: Anonymous user local ID management
  - `editKeys.ts`: Edit key management for anonymous editing
  - `party-context.ts`: Extracted PartyContext type

### Phase 5: /teams/new Migration 
- Migrated party creation wizard to use TanStack Query mutations
- Replaced all direct adapter calls with mutations (7 locations)
- Maintains existing behavior and flow
- Automatic cache invalidation for newly created parties

## Benefits

### Performance
- Automatic request deduplication
- Better cache utilization across pages
- Background refetching for fresh data
- Optimistic updates for instant UI feedback

### Developer Experience
- Single source of truth for data fetching
- Consistent patterns across entire app
- Query devtools for debugging
- Less boilerplate code

### Code Quality
- ~1,088 net lines removed
- Simpler mental model (no service layer)
- Better TypeScript inference
- Easier to test

### Architecture
- **100% TanStack Query coverage** - no service layer, no direct adapter
calls
- Clear separation: UI ← Queries/Mutations ← Adapters ← API
- Automatic cache management
- Consistent mutation patterns everywhere

## Testing

All features verified:
- Party creation (anonymous & authenticated)
- Grid operations (add, remove, update, swap, move)
- Party operations (update, delete, remix, favorite)
- Cache invalidation across tabs
- Error handling and rollback
- SSR with hydration

## Files Modified

### Created (3)
- `src/lib/types/party-context.ts`
- `src/lib/utils/editKeys.ts`
- `src/lib/utils/localId.ts`

### Deleted (4)
- `src/lib/services/party.service.ts`
- `src/lib/services/grid.service.ts`
- `src/lib/services/conflict.service.ts`
- `src/lib/utils/gridOperations.ts`

### Modified (13)
- `src/lib/api/mutations/grid.mutations.ts`
- `src/lib/components/grids/CharacterGrid.svelte`
- `src/lib/components/grids/SummonGrid.svelte`
- `src/lib/components/grids/WeaponGrid.svelte`
- `src/lib/components/party/Party.svelte`
- `src/routes/teams/new/+page.svelte`
- Database entity pages (characters, weapons, summons)
- Other supporting files

## Migration Complete

This PR completes the TanStack Query migration. The entire application
now uses TanStack Query v6 for all data fetching and mutations, with
zero remaining service layer code.

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-11-29 22:32:15 -08:00
6ad3b65f7f chore: remove unused resource pattern files (Phase 3)
removed ~27kb of completely unused code:
- search.resource.svelte.ts and test (custom query pattern)
- party.resource.svelte.ts (deprecated, unused)
- job.resource.svelte.ts (unused)
- CLEANUP_PLAN.md (outdated)

all functionality replaced by TanStack Query patterns in phases 1 & 2
2025-11-29 03:39:50 -08:00
devin-ai-integration[bot]
5764161803
feat: add TanStack Query v6 integration with SSR support (#441)
## Summary

This PR establishes the foundation for migrating from custom Svelte 5
resource classes to TanStack Query v6 for server state management. It
adds:

**Query Options Factories** (in `src/lib/api/queries/`):
- `party.queries.ts` - Party fetching with infinite scroll support
- `job.queries.ts` - Job and skill queries with pagination
- `user.queries.ts` - User profile, parties, and favorites queries

**Mutation Configurations** (in `src/lib/api/mutations/`):
- `party.mutations.ts` - Party CRUD with cache invalidation
- `grid.mutations.ts` - Weapon/character/summon mutations with
optimistic updates
- `job.mutations.ts` - Job and skill update mutations

**Deprecation Notices**:
- Added `@deprecated` JSDoc to `search.resource.svelte.ts` and
`party.resource.svelte.ts` with migration examples

**SSR Integration** (Phase 4):
- Created `+layout.ts` to initialize QueryClient for SSR support
- Updated `+layout.svelte` to receive QueryClient from load function
- Added SSR utilities in `src/lib/query/ssr.ts`:
  - `withInitialData()` - for pages using +page.server.ts
- `prefetchQuery()` / `prefetchInfiniteQuery()` - for pages using
+page.ts
  - `setQueryData()` - for direct cache population
- Added documentation in `src/lib/query/README.md`

**Component Wiring Examples** (Phase 5):
- `JobSelectionSidebar.svelte` - Migrated from `createJobResource()` to
`createQuery(() => jobQueries.list())`. Demonstrates client-side query
pattern with automatic loading/error states.
- `teams/[id]/+page.svelte` - Added `withInitialData()` pattern for SSR
integration. Server-fetched party data is used as initial cache value
with background refetching support.

**Migration Guide**:
- Added `src/lib/query/MIGRATION.md` with follow-up prompts for
remaining component migrations (JobSkillSelectionSidebar, search modal,
user profile, teams explore, Party mutations, resource class removal)

## Updates Since Last Revision

Fixed TypeScript type errors in the TanStack Query integration:
- `party.queries.ts`: Made `total` and `perPage` optional in
`PartyPageResult` interface to match adapter return type
- `ssr.ts`: Fixed `withInitialData` to properly handle null values using
`NonNullable<TData>` return type
- `job.mutations.ts`: Fixed slot indexing by casting through `unknown`
to `keyof typeof updatedSkills`

Type checks now pass for all files modified in this PR (16 remaining
errors are pre-existing project issues unrelated to this PR - paraglide
modules not generated, hooks.ts implicit anys).

## Review & Testing Checklist for Human

- [ ] **Verify app loads correctly**: The `+layout.ts` and
`+layout.svelte` changes are critical path - confirm the app still
renders
- [ ] **Test JobSelectionSidebar**: Open job selection sidebar and
verify jobs load correctly, search/filter works, and retry button works
on error
- [ ] **Test teams/[id] page**: Navigate to a party detail page and
verify it renders without loading flash (SSR data should be immediate)
- [ ] **Review type casts**: Check `job.mutations.ts:135` - the `as
unknown as keyof typeof` cast for slot indexing is a workaround for
jobSkills having string literal keys ('0', '1', '2', '3') while slot is
a number
- [ ] **Verify withInitialData behavior**: The `NonNullable<TData>`
return type change in `ssr.ts` should work correctly with `data.party`
which can be `Party | null`

**Recommended test plan**: 
1. Run `pnpm install` to ensure dependencies are up to date
2. Start dev server and verify the app loads without errors
3. Navigate to a party detail page (`/teams/[shortcode]`) - should
render immediately without loading state
4. Open job selection sidebar (click job icon on a party you can edit) -
verify jobs load and filtering works
5. Test error handling by temporarily breaking network - verify retry
button appears

### Notes


- Pre-existing project issues remain (paraglide modules not generated,
hooks.ts implicit anys) - these are unrelated to this PR
- Local testing could not run due to missing node_modules (vite not
found) - project setup issue
- TanStack Query devtools installation was skipped due to Storybook
version conflicts
- The existing `search.queries.ts` file was used as the pattern
reference for new query factories
- SSR approach uses hybrid pattern: existing `+page.server.ts` files
work with `withInitialData()`, while new pages can use `prefetchQuery()`
in `+page.ts`
- Migration guide includes 6 follow-up prompts for completing the
remaining component migrations

**Link to Devin run**:
https://app.devin.ai/sessions/33e97a98ae3e415aa4dc35378cad3a2b
**Requested by**: Justin Edmund (justin@jedmund.com) / @jedmund

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Justin Edmund <justin@jedmund.com>
2025-11-29 00:36:59 -08:00
c074ea8bda refactor: unify visibility types to string literals
Changed from numeric (0/1/2) to string literals ('public'/'private'/'unlisted')
- Created PartyVisibility type with const assertion
- Updated Party and PartyPreview interfaces
- Updated PartyUpdatePayload interface
- Updated Zod schemas for validation
- Updated test mocks to use string literals
- Added deprecated conversion helpers for backward compat

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 21:43:55 -08:00
009758a997 fix: API adapters and type mapping
- transform job skills pagination meta to include page/perPage
- fix UserInfo avatar type (optional properties -> required when present)
- add visibility number-to-string mapping in party service (0=public, 1=private, 2=unlisted)
- change mapToApiPayload return type from Partial<Party> to CreatePartyParams
- fix raid/job mapping to use IDs instead of nested objects
- add generic type argument to RestDataProvider<any>
- add type assertion in optionalProps (value as T[keyof T])
2025-11-28 21:04:51 -08:00
c821873ac6 fix: test fixtures and awakening type issues
- remove recruits property from Character test mock (doesn't exist in type)
- add missing subaura property to Summon test mocks
- consolidate Awakening imports to use entities source
- make awakening type/level optional in GridWeapon/GridSummon
- fix null handling in AwakeningDisplay (null -> undefined)
2025-11-28 21:04:26 -08:00
6dc10ce414 fix: Phase 8 - fix test fixture and adapter issues (24 -> 22 errors)
Fixed remaining test mock data to match actual type schemas.

Changes:
1. entity.adapter.test.ts:
   - Removed invalid maxLevel property from Character mock
   - Character interface doesn't have maxLevel

2. grid.adapter.test.ts:
   - Added missing required properties to Weapon mock:
     - maxSkillLevel: 15
     - maxAwakeningLevel: 5
     - ax: true
     - axType: 1
   - Removed invalid series property from Summon mock
     - Summon interface doesn't have series property

3. settings/+page.svelte:
   - Fixed users.update call (removed extra fetch parameter)

All test mocks now match their corresponding type definitions from
entities.ts, ensuring tests can compile and run correctly.

Result: 24 → 22 errors (-2)

Overall progress: 53 → 22 errors (58% reduction)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 20:07:34 -08:00
e0810781f4 fix: Phase 7d - fix null/undefined handling (28 -> 24 errors)
Fixed multiple null/undefined type errors by adding proper null checks
and default values.

Changes:
1. CharacterRep.svelte:
   - Changed import from '$lib/types/enums' to '$lib/utils/element'
   - getElementClass in utils/element accepts undefined, enums version doesn't

2. ItemHeader.svelte:
   - Convert null to undefined for gridUncapLevel and gridTranscendence
   - getCharacterPose expects 'number | undefined', not 'number | null | undefined'

3. UncapStatusDisplay.svelte:
   - Added null coalescing for transcendenceStep check
   - Changed from `transcendenceStep > 0` to `(transcendenceStep ?? 0) > 0`

4. base.adapter.ts:
   - Provide default no-op function for optional onError callback
   - Required<AdapterOptions> needs all properties defined

Result: 28 → 24 errors (-4)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 20:04:02 -08:00