mirror of
https://github.com/tcgdex/compiler.git
synced 2025-07-28 23:19:50 +00:00
Add eslint (#12)
* Done ! Signed-off-by: Florian BOUILLON <florian.bouillon@delta-wings.net> * ACT doesn't wanna work so I push Signed-off-by: Florian BOUILLON <florian.bouillon@delta-wings.net> * Continued work on ESLint Signed-off-by: Florian BOUILLON <florian.bouillon@delta-wings.net> * Two files remaining Signed-off-by: Avior <github@avior.me> * Fixed set cards not found when using ids Signed-off-by: Avior <florian.bouillon@delta-wings.net>
This commit is contained in:
@ -3,24 +3,26 @@ import { Card, Languages } from '../db/interfaces'
|
||||
import { Endpoint } from '../interfaces'
|
||||
import { cardToCardSimple, cardToCardSingle, getCards } from '../utils/cardUtil'
|
||||
|
||||
export default class implements Endpoint<CardList, CardSingle, {}, Array<[string, Card]>> {
|
||||
export default class implements Endpoint<CardList, CardSingle, Record<string, unknown>, Array<[string, Card]>> {
|
||||
|
||||
public constructor(
|
||||
private lang: keyof Languages
|
||||
) {}
|
||||
|
||||
public async index(common: Array<[string, Card]>) {
|
||||
public async index(common: Array<[string, Card]>): Promise<CardList> {
|
||||
return Promise.all(common.map((c) => cardToCardSimple(c[0], c[1], this.lang)))
|
||||
}
|
||||
|
||||
public async item(common: Array<[string, Card]>) {
|
||||
public async item(common: Array<[string, Card]>): Promise<Record<string, CardSingle>> {
|
||||
const items: Record<string, CardSingle> = {}
|
||||
for (const card of common) {
|
||||
for await (const card of common) {
|
||||
items[`${card[1].set.id}-${card[0]}`] = await cardToCardSingle(card[0], card[1], this.lang)
|
||||
}
|
||||
return items
|
||||
}
|
||||
|
||||
public async common() {
|
||||
public async common(): Promise<Array<[string, Card]>> {
|
||||
return getCards(this.lang)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,32 +4,35 @@ import { Card, Languages } from '../db/interfaces'
|
||||
import { Endpoint } from '../interfaces'
|
||||
import { cardToCardSimple, getCards } from '../utils/cardUtil'
|
||||
|
||||
export default class implements Endpoint<StringEndpointList, StringEndpoint, {}, Record<string, Array<[string, Card]>>> {
|
||||
export default class implements Endpoint<StringEndpointList, StringEndpoint, Record<string, unknown>, Record<string, Array<[string, Card]>>> {
|
||||
|
||||
public constructor(
|
||||
private lang: keyof Languages
|
||||
) {}
|
||||
|
||||
public async index(common: Record<string, Array<[string, Card]>>) {
|
||||
public async index(common: Record<string, Array<[string, Card]>>): Promise<StringEndpointList> {
|
||||
return Object.keys(common)
|
||||
}
|
||||
|
||||
public async item(common: Record<string, Array<[string, Card]>>) {
|
||||
public async item(common: Record<string, Array<[string, Card]>>): Promise<Record<string, StringEndpoint>> {
|
||||
const items: Record<string, StringEndpoint> = {}
|
||||
for (const key of Object.keys(common)) {
|
||||
for await (const key of Object.keys(common)) {
|
||||
const val = common[key]
|
||||
const it = {
|
||||
name: key,
|
||||
cards: await Promise.all(val.map(([id, card]) => cardToCardSimple(id, card, this.lang)))
|
||||
cards: await Promise.all(val.map(([id, card]) => cardToCardSimple(id, card, this.lang))),
|
||||
name: key
|
||||
}
|
||||
items[key] = it
|
||||
}
|
||||
return items
|
||||
}
|
||||
|
||||
public async common() {
|
||||
public async common(): Promise<Record<string, Array<[string, Card]>>> {
|
||||
return (await getCards(this.lang)).reduce((p, c) => {
|
||||
const category = translate('category', c[1].category, this.lang)
|
||||
if (!category) return p
|
||||
if (!category) {
|
||||
return p
|
||||
}
|
||||
if (!p[category]) {
|
||||
p[category] = []
|
||||
}
|
||||
@ -37,4 +40,5 @@ export default class implements Endpoint<StringEndpointList, StringEndpoint, {},
|
||||
return p
|
||||
}, {} as Record<string, Array<[string, Card]>>)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,31 +3,34 @@ import { Card, Languages } from '../db/interfaces'
|
||||
import { Endpoint } from '../interfaces'
|
||||
import { cardToCardSimple, getCards } from '../utils/cardUtil'
|
||||
|
||||
export default class implements Endpoint<StringEndpointList, StringEndpoint, {}, Record<string, Array<[string, Card]>>> {
|
||||
export default class implements Endpoint<StringEndpointList, StringEndpoint, Record<string, unknown>, Record<string, Array<[string, Card]>>> {
|
||||
|
||||
public constructor(
|
||||
private lang: keyof Languages
|
||||
) {}
|
||||
|
||||
public async index(common: Record<string, Array<[string, Card]>>) {
|
||||
public async index(common: Record<string, Array<[string, Card]>>): Promise<StringEndpointList> {
|
||||
return Object.keys(common)
|
||||
}
|
||||
|
||||
public async item(common: Record<string, Array<[string, Card]>>) {
|
||||
public async item(common: Record<string, Array<[string, Card]>>): Promise<Record<string, StringEndpoint>> {
|
||||
const items: Record<string, StringEndpoint> = {}
|
||||
for (const key of Object.keys(common)) {
|
||||
const val = common[key]
|
||||
items[key] = {
|
||||
name: key,
|
||||
cards: await Promise.all(val.map(([id, card]) => cardToCardSimple(id, card, this.lang)))
|
||||
cards: await Promise.all(val.map(([id, card]) => cardToCardSimple(id, card, this.lang))),
|
||||
name: key
|
||||
}
|
||||
}
|
||||
return items
|
||||
}
|
||||
|
||||
public async common() {
|
||||
public async common(): Promise<Record<string, Array<[string, Card]>>> {
|
||||
return (await getCards(this.lang)).reduce((p, c) => {
|
||||
const hp = c[1].hp
|
||||
if (!hp) return p
|
||||
const { hp } = c[1]
|
||||
if (!hp) {
|
||||
return p
|
||||
}
|
||||
if (!p[hp]) {
|
||||
p[hp] = []
|
||||
}
|
||||
@ -35,4 +38,5 @@ export default class implements Endpoint<StringEndpointList, StringEndpoint, {},
|
||||
return p
|
||||
}, {} as Record<string, Array<[string, Card]>>)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,31 +3,34 @@ import { Card, Languages } from '../db/interfaces'
|
||||
import { Endpoint } from '../interfaces'
|
||||
import { cardToCardSimple, getCards } from '../utils/cardUtil'
|
||||
|
||||
export default class implements Endpoint<StringEndpointList, StringEndpoint, {}, Record<string, Array<[string, Card]>>> {
|
||||
export default class implements Endpoint<StringEndpointList, StringEndpoint, Record<string, unknown>, Record<string, Array<[string, Card]>>> {
|
||||
|
||||
public constructor(
|
||||
private lang: keyof Languages
|
||||
) {}
|
||||
|
||||
public async index(common: Record<string, Array<[string, Card]>>) {
|
||||
public async index(common: Record<string, Array<[string, Card]>>): Promise<StringEndpointList> {
|
||||
return Object.keys(common)
|
||||
}
|
||||
|
||||
public async item(common: Record<string, Array<[string, Card]>>) {
|
||||
public async item(common: Record<string, Array<[string, Card]>>): Promise<Record<string, StringEndpoint>> {
|
||||
const items: Record<string, StringEndpoint> = {}
|
||||
for (const key of Object.keys(common)) {
|
||||
for await (const key of Object.keys(common)) {
|
||||
const val = common[key]
|
||||
items[key] = {
|
||||
name: key,
|
||||
cards: await Promise.all(val.map(([id, card]) => cardToCardSimple(id, card, this.lang)))
|
||||
cards: await Promise.all(val.map(([id, card]) => cardToCardSimple(id, card, this.lang))),
|
||||
name: key
|
||||
}
|
||||
}
|
||||
return items
|
||||
}
|
||||
|
||||
public async common() {
|
||||
public async common(): Promise<Record<string, Array<[string, Card]>>> {
|
||||
return (await getCards(this.lang)).reduce((p, c) => {
|
||||
const illustrator = c[1].illustrator
|
||||
if (!illustrator) return p
|
||||
const { illustrator } = c[1]
|
||||
if (!illustrator) {
|
||||
return p
|
||||
}
|
||||
if (!p[illustrator]) {
|
||||
p[illustrator] = []
|
||||
}
|
||||
@ -35,4 +38,5 @@ export default class implements Endpoint<StringEndpointList, StringEndpoint, {},
|
||||
return p
|
||||
}, {} as Record<string, Array<[string, Card]>>)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,31 +4,34 @@ import { Card, Languages } from '../db/interfaces'
|
||||
import { Endpoint } from '../interfaces'
|
||||
import { cardToCardSimple, getCards } from '../utils/cardUtil'
|
||||
|
||||
export default class implements Endpoint<StringEndpointList, StringEndpoint, {}, Record<string, Array<[string, Card]>>> {
|
||||
export default class implements Endpoint<StringEndpointList, StringEndpoint, Record<string, unknown>, Record<string, Array<[string, Card]>>> {
|
||||
|
||||
public constructor(
|
||||
private lang: keyof Languages
|
||||
) {}
|
||||
|
||||
public async index(common: Record<string, Array<[string, Card]>>) {
|
||||
public async index(common: Record<string, Array<[string, Card]>>): Promise<StringEndpointList> {
|
||||
return Object.keys(common)
|
||||
}
|
||||
|
||||
public async item(common: Record<string, Array<[string, Card]>>) {
|
||||
public async item(common: Record<string, Array<[string, Card]>>): Promise<Record<string, StringEndpoint>> {
|
||||
const items: Record<string, StringEndpoint> = {}
|
||||
for (const key of Object.keys(common)) {
|
||||
for await (const key of Object.keys(common)) {
|
||||
const val = common[key]
|
||||
items[key] = {
|
||||
name: key,
|
||||
cards: await Promise.all(val.map(([id, card]) => cardToCardSimple(id, card, this.lang)))
|
||||
cards: await Promise.all(val.map(([id, card]) => cardToCardSimple(id, card, this.lang))),
|
||||
name: key
|
||||
}
|
||||
}
|
||||
return items
|
||||
}
|
||||
|
||||
public async common() {
|
||||
public async common(): Promise<Record<string, Array<[string, Card]>>> {
|
||||
return (await getCards(this.lang)).reduce((p, c) => {
|
||||
const rarity = translate('rarity', c[1].rarity, this.lang)
|
||||
if (!rarity) return p
|
||||
if (!rarity) {
|
||||
return p
|
||||
}
|
||||
if (!p[rarity]) {
|
||||
p[rarity] = []
|
||||
}
|
||||
@ -36,4 +39,5 @@ export default class implements Endpoint<StringEndpointList, StringEndpoint, {},
|
||||
return p
|
||||
}, {} as Record<string, Array<[string, Card]>>)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,31 +3,34 @@ import { Card, Languages } from '../db/interfaces'
|
||||
import { Endpoint } from '../interfaces'
|
||||
import { cardToCardSimple, getCards } from '../utils/cardUtil'
|
||||
|
||||
export default class implements Endpoint<StringEndpointList, StringEndpoint, {}, Record<string, Array<[string, Card]>>> {
|
||||
export default class implements Endpoint<StringEndpointList, StringEndpoint, Record<string, unknown>, Record<string, Array<[string, Card]>>> {
|
||||
|
||||
public constructor(
|
||||
private lang: keyof Languages
|
||||
) {}
|
||||
|
||||
public async index(common: Record<string, Array<[string, Card]>>) {
|
||||
public async index(common: Record<string, Array<[string, Card]>>): Promise<StringEndpointList> {
|
||||
return Object.keys(common)
|
||||
}
|
||||
|
||||
public async item(common: Record<string, Array<[string, Card]>>) {
|
||||
public async item(common: Record<string, Array<[string, Card]>>): Promise<Record<string, StringEndpoint>> {
|
||||
const items: Record<string, StringEndpoint> = {}
|
||||
for (const key of Object.keys(common)) {
|
||||
for await (const key of Object.keys(common)) {
|
||||
const val = common[key]
|
||||
items[key] = {
|
||||
name: key,
|
||||
cards: await Promise.all(val.map(([id, card]) => cardToCardSimple(id, card, this.lang)))
|
||||
cards: await Promise.all(val.map(([id, card]) => cardToCardSimple(id, card, this.lang))),
|
||||
name: key
|
||||
}
|
||||
}
|
||||
return items
|
||||
}
|
||||
|
||||
public async common() {
|
||||
public async common(): Promise<Record<string, Array<[string, Card]>>> {
|
||||
return (await getCards(this.lang)).reduce((p, c) => {
|
||||
const retreat = c[1].retreat
|
||||
if (!retreat) return p
|
||||
const { retreat } = c[1]
|
||||
if (!retreat) {
|
||||
return p
|
||||
}
|
||||
if (!p[retreat]) {
|
||||
p[retreat] = []
|
||||
}
|
||||
@ -35,4 +38,5 @@ export default class implements Endpoint<StringEndpointList, StringEndpoint, {},
|
||||
return p
|
||||
}, {} as Record<number, Array<[string, Card]>>)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,21 +1,21 @@
|
||||
import { Serie as SerieSingle, SerieList } from '@tcgdex/sdk/interfaces'
|
||||
import { Serie as SerieSingle, SerieList, SerieResume } from '@tcgdex/sdk/interfaces'
|
||||
import { Languages, Serie } from '../db/interfaces'
|
||||
import { Endpoint } from '../interfaces'
|
||||
import { getSeries, serieToSerieSimple, serieToSerieSingle } from '../utils/serieUtil'
|
||||
|
||||
export default class implements Endpoint<SerieList, SerieSingle, {}, Array<Serie>> {
|
||||
export default class implements Endpoint<SerieList, SerieSingle, Record<string, any>, Array<Serie>> {
|
||||
|
||||
public constructor(
|
||||
private lang: keyof Languages
|
||||
) {}
|
||||
|
||||
public async index(common: Array<Serie>) {
|
||||
public async index(common: Array<Serie>): Promise<Array<SerieResume>> {
|
||||
return Promise.all(common.map((s) => serieToSerieSimple(s, this.lang)))
|
||||
}
|
||||
|
||||
public async item(common: Array<Serie>) {
|
||||
public async item(common: Array<Serie>): Promise<Record<string, SerieSingle>> {
|
||||
const items: Record<string, SerieSingle> = {}
|
||||
for (let key = 0; key < common.length; key++) {
|
||||
const val = common[key];
|
||||
for await (const val of common) {
|
||||
const gen = await serieToSerieSingle(val, this.lang)
|
||||
const name = val.name[this.lang] as string
|
||||
items[name] = gen
|
||||
@ -24,7 +24,8 @@ export default class implements Endpoint<SerieList, SerieSingle, {}, Array<Serie
|
||||
return items
|
||||
}
|
||||
|
||||
public async common() {
|
||||
public async common(): Promise<Array<Serie>> {
|
||||
return getSeries(this.lang)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,15 +1,16 @@
|
||||
import { SetList, Set as SetSingle, Card as CardSingle } from '@tcgdex/sdk/interfaces'
|
||||
import { getSet, getSets, isSetAvailable, setToSetSimple, setToSetSingle } from "../utils/setUtil"
|
||||
import { getSets, isSetAvailable, setToSetSimple, setToSetSingle } from '../utils/setUtil'
|
||||
import { Languages, Set } from '../db/interfaces'
|
||||
import { Endpoint } from '../interfaces'
|
||||
import { cardToCardSingle, getCards } from '../utils/cardUtil'
|
||||
|
||||
export default class implements Endpoint<SetList, SetSingle, CardSingle, Array<Set>> {
|
||||
|
||||
public constructor(
|
||||
private lang: keyof Languages
|
||||
) {}
|
||||
|
||||
public async index(common: Array<Set>) {
|
||||
public async index(common: Array<Set>): Promise<SetList> {
|
||||
const sets = common
|
||||
.sort((a, b) => a.releaseDate > b.releaseDate ? 1 : -1)
|
||||
|
||||
@ -18,8 +19,8 @@ export default class implements Endpoint<SetList, SetSingle, CardSingle, Array<S
|
||||
return tmp
|
||||
}
|
||||
|
||||
public async item(common: Array<Set>) {
|
||||
const sets= await Promise.all(common
|
||||
public async item(common: Array<Set>): Promise<Record<string, SetSingle>> {
|
||||
const sets = await Promise.all(common
|
||||
.map((set) => setToSetSingle(set, this.lang)))
|
||||
const res: Record<string, SetSingle> = {}
|
||||
|
||||
@ -31,21 +32,24 @@ export default class implements Endpoint<SetList, SetSingle, CardSingle, Array<S
|
||||
return res
|
||||
}
|
||||
|
||||
public async common() {
|
||||
return (await getSets(undefined, this.lang))
|
||||
public async common(): Promise<Array<Set>> {
|
||||
return getSets(undefined, this.lang)
|
||||
}
|
||||
|
||||
public async sub(common: Array<Set>, item: string) {
|
||||
public async sub(common: Array<Set>, item: string): Promise<Record<string, CardSingle> | undefined> {
|
||||
const set = common.find((s) => s.name[this.lang] === item || s.id === item)
|
||||
|
||||
if (!set || !isSetAvailable(set, this.lang)) return undefined
|
||||
|
||||
const lit = await getCards(this.lang, set)
|
||||
const l: Record<string, CardSingle> = {}
|
||||
for (let i of lit) {
|
||||
l[i[0]] = await cardToCardSingle(i[0], i[1], this.lang)
|
||||
if (!set || !isSetAvailable(set, this.lang)) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
return l
|
||||
const lit = await getCards(this.lang, set)
|
||||
const list: Record<string, CardSingle> = {}
|
||||
for await (const card of lit) {
|
||||
list[card[0]] = await cardToCardSingle(card[0], card[1], this.lang)
|
||||
}
|
||||
|
||||
return list
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,31 +4,34 @@ import { Card, Languages } from '../db/interfaces'
|
||||
import { Endpoint } from '../interfaces'
|
||||
import { cardToCardSimple, getCards } from '../utils/cardUtil'
|
||||
|
||||
export default class implements Endpoint<StringEndpointList, StringEndpoint, {}, Record<string, Array<[string, Card]>>> {
|
||||
export default class implements Endpoint<StringEndpointList, StringEndpoint, Record<string, unknown>, Record<string, Array<[string, Card]>>> {
|
||||
|
||||
public constructor(
|
||||
private lang: keyof Languages
|
||||
) {}
|
||||
|
||||
public async index(common: Record<string, Array<[string, Card]>>) {
|
||||
public async index(common: Record<string, Array<[string, Card]>>): Promise<StringEndpointList> {
|
||||
return Object.keys(common)
|
||||
}
|
||||
|
||||
public async item(common: Record<string, Array<[string, Card]>>) {
|
||||
public async item(common: Record<string, Array<[string, Card]>>): Promise<Record<string, StringEndpoint>> {
|
||||
const items: Record<string, StringEndpoint> = {}
|
||||
for (const key of Object.keys(common)) {
|
||||
for await (const key of Object.keys(common)) {
|
||||
const val = common[key]
|
||||
items[key] = {
|
||||
name: key,
|
||||
cards: await Promise.all(val.map(([id, card]) => cardToCardSimple(id, card, this.lang)))
|
||||
cards: await Promise.all(val.map(([id, card]) => cardToCardSimple(id, card, this.lang))),
|
||||
name: key
|
||||
}
|
||||
}
|
||||
return items
|
||||
}
|
||||
|
||||
public async common() {
|
||||
public async common(): Promise<Record<string, Array<[string, Card]>>> {
|
||||
return (await getCards(this.lang)).reduce((p, c) => {
|
||||
const types = c[1].types?.map((t) => translate('types', t, this.lang) as string)
|
||||
if (!types) return p
|
||||
if (!types) {
|
||||
return p
|
||||
}
|
||||
for (const type of types) {
|
||||
if (!p[type]) {
|
||||
p[type] = []
|
||||
@ -38,4 +41,5 @@ export default class implements Endpoint<StringEndpointList, StringEndpoint, {},
|
||||
return p
|
||||
}, {} as Record<string, Array<[string, Card]>>)
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user