remove barrel files and update imports
This commit is contained in:
parent
4e206a75b4
commit
79c0de3128
14 changed files with 30 additions and 148 deletions
22
CLAUDE.md
22
CLAUDE.md
|
|
@ -197,6 +197,28 @@ src/
|
|||
- `$types` → `src/lib/types` (custom alias)
|
||||
- `$src` → `src/` (Vite alias)
|
||||
|
||||
7. **Import Patterns**:
|
||||
- **Prefer direct imports over re-exports** for better clarity and tree-shaking
|
||||
- Import types directly from their source files (e.g., `import type { Party } from '$lib/types/api/party'`)
|
||||
- Avoid creating barrel files (index.ts) that re-export from other modules
|
||||
- Exception: Generated code (like Paraglide messages) may use re-exports
|
||||
- This pattern improves TypeScript performance and makes dependencies explicit
|
||||
|
||||
**Correct Import Examples**:
|
||||
```typescript
|
||||
// ✅ Good - Direct imports
|
||||
import { partyAdapter } from '$lib/api/adapters/party.adapter'
|
||||
import { userAdapter } from '$lib/api/adapters/user.adapter'
|
||||
import { createSearchResource } from '$lib/api/adapters/resources/search.resource.svelte'
|
||||
import type { Party } from '$lib/types/api/party'
|
||||
import type { AdapterOptions } from '$lib/api/adapters/types'
|
||||
import { ApiError } from '$lib/api/adapters/errors'
|
||||
|
||||
// ❌ Bad - Barrel file imports
|
||||
import { partyAdapter, userAdapter } from '$lib/api/adapters'
|
||||
import type { Party } from '$lib/api/adapters'
|
||||
```
|
||||
|
||||
### Component Patterns
|
||||
|
||||
Components follow a consistent structure:
|
||||
|
|
|
|||
|
|
@ -1,62 +0,0 @@
|
|||
/**
|
||||
* Main export file for the adapter system
|
||||
*
|
||||
* This module re-exports all public APIs from the adapter system,
|
||||
* providing a single entry point for consumers.
|
||||
*
|
||||
* @module adapters
|
||||
*/
|
||||
|
||||
// Core exports
|
||||
export { BaseAdapter } from './base.adapter'
|
||||
export * from './types'
|
||||
export * from './errors'
|
||||
|
||||
// Resource-specific adapters
|
||||
export { SearchAdapter, searchAdapter } from './search.adapter'
|
||||
export type { SearchParams, SearchResult, SearchResponse } from './search.adapter'
|
||||
|
||||
export { PartyAdapter, partyAdapter } from './party.adapter'
|
||||
export type {
|
||||
Party,
|
||||
GridWeapon,
|
||||
GridSummon,
|
||||
GridCharacter,
|
||||
CreatePartyParams,
|
||||
UpdatePartyParams,
|
||||
ListUserPartiesParams,
|
||||
GridOperation,
|
||||
GridUpdateOptions,
|
||||
GridUpdateResponse
|
||||
} from './party.adapter'
|
||||
|
||||
export { GridAdapter, gridAdapter } from './grid.adapter'
|
||||
export type {
|
||||
GridWeapon,
|
||||
GridCharacter,
|
||||
GridSummon,
|
||||
CreateGridWeaponParams,
|
||||
CreateGridCharacterParams,
|
||||
CreateGridSummonParams,
|
||||
UpdateUncapParams,
|
||||
UpdatePositionParams,
|
||||
SwapPositionsParams,
|
||||
ResolveConflictParams
|
||||
} from './grid.adapter'
|
||||
|
||||
export { EntityAdapter, entityAdapter } from './entity.adapter'
|
||||
export type {
|
||||
Weapon,
|
||||
Character,
|
||||
Summon
|
||||
} from './entity.adapter'
|
||||
|
||||
export { UserAdapter, userAdapter } from './user.adapter'
|
||||
export type {
|
||||
UserInfo,
|
||||
UserProfile,
|
||||
UserProfileResponse
|
||||
} from './user.adapter'
|
||||
|
||||
// Reactive resources using Svelte 5 runes
|
||||
export * from './resources'
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
/**
|
||||
* Reactive Resources using Svelte 5 Runes
|
||||
*
|
||||
* This module exports reactive resources that provide
|
||||
* state management for API operations.
|
||||
*
|
||||
* @module adapters/resources
|
||||
*/
|
||||
|
||||
export { SearchResource, createSearchResource } from './search.resource.svelte'
|
||||
export type { SearchResourceOptions } from './search.resource.svelte'
|
||||
|
||||
export { PartyResource, createPartyResource } from './party.resource.svelte'
|
||||
export type { PartyResourceOptions } from './party.resource.svelte'
|
||||
|
||||
// Future resources will be added here
|
||||
// export { GridResource, createGridResource } from './grid.resource.svelte'
|
||||
// export { EntityResource, createEntityResource } from './entity.resource.svelte'
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
// UI Components barrel export
|
||||
export { default as Button } from './Button.svelte'
|
||||
export { default as Input } from './Input.svelte'
|
||||
export { default as Select } from './Select.svelte'
|
||||
|
||||
// Re-export existing UI components
|
||||
export { default as Dialog } from './Dialog.svelte'
|
||||
export { default as Tooltip } from './Tooltip.svelte'
|
||||
export { default as ContextMenu } from './ContextMenu.svelte'
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
export { default as SegmentedControl } from './SegmentedControl.svelte';
|
||||
export { default as Segment } from './Segment.svelte';
|
||||
49
src/lib/types/Party.d.ts
vendored
49
src/lib/types/Party.d.ts
vendored
|
|
@ -1,49 +0,0 @@
|
|||
export type JobSkillList = {
|
||||
[key: number]: JobSkill | undefined
|
||||
0: JobSkill | undefined
|
||||
1: JobSkill | undefined
|
||||
2: JobSkill | undefined
|
||||
3: JobSkill | undefined
|
||||
}
|
||||
|
||||
export type GuidebookList = {
|
||||
[key: number]: Guidebook | undefined
|
||||
0: Guidebook | undefined
|
||||
1: Guidebook | undefined
|
||||
2: Guidebook | undefined
|
||||
}
|
||||
|
||||
export interface Party {
|
||||
id: string
|
||||
name: string
|
||||
description: string
|
||||
raid: Raid
|
||||
full_auto: boolean
|
||||
auto_guard: boolean
|
||||
auto_summon: boolean
|
||||
charge_attack: boolean
|
||||
clear_time: number
|
||||
button_count?: number
|
||||
turn_count?: number
|
||||
chain_count?: number
|
||||
source_party?: Party
|
||||
job: Job
|
||||
master_level?: number
|
||||
ultimate_mastery?: number
|
||||
job_skills: JobSkillList
|
||||
accessory: JobAccessory
|
||||
shortcode: string
|
||||
extra: boolean
|
||||
guidebooks: GuidebookList
|
||||
favorited: boolean
|
||||
characters: Array<GridCharacter>
|
||||
weapons: Array<GridWeapon>
|
||||
summons: Array<GridSummon>
|
||||
user: User
|
||||
local_id?: string
|
||||
remix: boolean
|
||||
remixes: Party[]
|
||||
visibility: number
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import type { PageServerLoad } from './$types'
|
||||
import { error } from '@sveltejs/kit'
|
||||
import { userAdapter } from '$lib/api/adapters'
|
||||
import { userAdapter } from '$lib/api/adapters/user.adapter'
|
||||
import { parseParty } from '$lib/api/schemas/party'
|
||||
|
||||
export const load: PageServerLoad = async ({ params, url, depends, locals }) => {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
import InfiniteScroll from '$lib/components/InfiniteScroll.svelte'
|
||||
import ExploreGrid from '$lib/components/explore/ExploreGrid.svelte'
|
||||
import { createInfiniteScrollResource } from '$lib/api/adapters/resources/infiniteScroll.resource.svelte'
|
||||
import { userAdapter } from '$lib/api/adapters'
|
||||
import { userAdapter } from '$lib/api/adapters/user.adapter'
|
||||
import { getAvatarSrc, getAvatarSrcSet } from '$lib/utils/avatar'
|
||||
|
||||
const { data } = $props() as { data: PageData }
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import type { RequestHandler } from '@sveltejs/kit'
|
|||
import { json } from '@sveltejs/kit'
|
||||
import { z } from 'zod'
|
||||
import { passwordGrantLogin } from '$lib/auth/oauth'
|
||||
import { UserAdapter } from '$lib/api/adapters'
|
||||
import { UserAdapter } from '$lib/api/adapters/user.adapter'
|
||||
import { buildCookies } from '$lib/auth/map'
|
||||
import { setAccountCookie, setUserCookie, setRefreshCookie } from '$lib/auth/cookies'
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import type { PageServerLoad } from './$types'
|
||||
import { entityAdapter } from '$lib/api/adapters'
|
||||
import { entityAdapter } from '$lib/api/adapters/entity.adapter'
|
||||
import { error } from '@sveltejs/kit'
|
||||
|
||||
export const load: PageServerLoad = async ({ params, parent }) => {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import type { PageServerLoad } from './$types'
|
||||
import { entityAdapter } from '$lib/api/adapters'
|
||||
import { entityAdapter } from '$lib/api/adapters/entity.adapter'
|
||||
import { error } from '@sveltejs/kit'
|
||||
|
||||
export const load: PageServerLoad = async ({ params, parent }) => {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import type { PageServerLoad } from './$types'
|
||||
import { entityAdapter } from '$lib/api/adapters'
|
||||
import { entityAdapter } from '$lib/api/adapters/entity.adapter'
|
||||
import { error } from '@sveltejs/kit'
|
||||
|
||||
export const load: PageServerLoad = async ({ params, parent }) => {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import type { PageServerLoad } from './$types'
|
||||
import { error } from '@sveltejs/kit'
|
||||
import { partyAdapter } from '$lib/api/adapters'
|
||||
import { partyAdapter } from '$lib/api/adapters/party.adapter'
|
||||
|
||||
export const load: PageServerLoad = async ({ url, depends }) => {
|
||||
depends('app:parties:list')
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
import InfiniteScroll from '$lib/components/InfiniteScroll.svelte'
|
||||
import ExploreGrid from '$lib/components/explore/ExploreGrid.svelte'
|
||||
import { createInfiniteScrollResource } from '$lib/api/adapters/resources/infiniteScroll.resource.svelte'
|
||||
import { partyAdapter } from '$lib/api/adapters'
|
||||
import { partyAdapter } from '$lib/api/adapters/party.adapter'
|
||||
|
||||
const { data } = $props() as { data: PageData }
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue