dragon-item-parser: introduce item parser library
Some checks failed
Dragon Item Parser CI / build-and-test (push) Successful in 1m3s
pipeline / lint-and-format (push) Failing after 4m8s
pipeline / build-and-push-images (push) Has been skipped

This commit is contained in:
2026-04-25 19:48:06 +02:00
parent a98e3c6589
commit e82ad73de1
17 changed files with 7689 additions and 5022 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -14,6 +14,7 @@
"format:check": "prettier --check ."
},
"dependencies": {
"dragon-item-parser": "file:../dragon-item-parser",
"@nuxt/eslint": "^1.12.1",
"@nuxt/fonts": "^0.11.3",
"@nuxt/image": "^1.10.0",

View File

@@ -1,6 +1,7 @@
import { readFile, existsSync } from 'fs'
import { join } from 'path'
import { promisify } from 'util'
import { parseItemStats, type ItemStats } from 'dragon-item-parser'
const readFileAsync = promisify(readFile)
@@ -78,14 +79,20 @@ async function fetchFromCache<T>(
}
/**
* Get items data from cache
* Get items data from cache with parsed stats
*/
async function getItems(patch?: string): Promise<CDragonItem[]> {
return fetchFromCache<CDragonItem[]>(
async function getItems(patch?: string): Promise<CDragonItemWithStats[]> {
const items = await fetchFromCache<CDragonItem[]>(
'items.json',
'plugins/rcp-be-lol-game-data/global/default/v1/items.json',
{ patch }
)
// Parse stats from description for each item
return items.map(item => ({
...item,
stats: parseItemStats(item.description || '')
}))
}
/**
@@ -148,6 +155,10 @@ interface CDragonItem {
}
}
interface CDragonItemWithStats extends CDragonItem {
stats: ItemStats
}
interface CDragonPerk {
id: number
name: string
@@ -197,6 +208,7 @@ export {
export type {
CDragonItem,
CDragonItemWithStats,
CDragonPerk,
CDragonPerkStyle,
CDragonPerkStyles,

View File

@@ -1,3 +1,5 @@
import type { ItemStats } from 'dragon-item-parser'
declare global {
type ChampionsResponse = {
data: Ref<Array<Champion>>
@@ -29,6 +31,7 @@ declare global {
from?: number[]
price?: number
priceTotal?: number
stats?: ItemStats
}
type SummonerSpell = {
id: number