mirror of
https://github.com/tcgdex/compiler.git
synced 2025-07-28 23:19:50 +00:00
Updated to V2 :D
Signed-off-by: Avior <florian.bouillon@delta-wings.net>
This commit is contained in:
@ -1,11 +1,7 @@
|
||||
import { CardList, Card as CardSingle } from '@tcgdex/sdk/interfaces'
|
||||
import { Card, Languages } from '../db/interfaces'
|
||||
import { Endpoint } from '../interfaces'
|
||||
import Logger from '@dzeio/logger'
|
||||
import { cardToCardSimple, cardToCardSingle, getCards } from '../utils/cardUtil'
|
||||
import { basename } from 'path'
|
||||
|
||||
const logger = new Logger(basename(__filename))
|
||||
|
||||
export default class implements Endpoint<CardList, CardSingle, {}, Array<[string, Card]>> {
|
||||
public constructor(
|
||||
@ -25,6 +21,6 @@ export default class implements Endpoint<CardList, CardSingle, {}, Array<[string
|
||||
}
|
||||
|
||||
public async common() {
|
||||
return getCards()
|
||||
return getCards(this.lang)
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,8 @@
|
||||
import { CardList, Card as CardSingle, StringEndpointList, StringEndpoint } from '@tcgdex/sdk/interfaces'
|
||||
import { StringEndpointList, StringEndpoint } from '@tcgdex/sdk/interfaces'
|
||||
import translate from '../utils/translationUtil'
|
||||
import { Card, Languages } from '../db/interfaces'
|
||||
import { Endpoint } from '../interfaces'
|
||||
import Logger from '@dzeio/logger'
|
||||
import { cardToCardSimple, cardToCardSingle, getCards } from '../utils/cardUtil'
|
||||
import { basename } from 'path'
|
||||
|
||||
const logger = new Logger(basename(__filename))
|
||||
import { cardToCardSimple, getCards } from '../utils/cardUtil'
|
||||
|
||||
export default class implements Endpoint<StringEndpointList, StringEndpoint, {}, Record<string, Array<[string, Card]>>> {
|
||||
public constructor(
|
||||
@ -30,8 +27,8 @@ export default class implements Endpoint<StringEndpointList, StringEndpoint, {},
|
||||
}
|
||||
|
||||
public async common() {
|
||||
return (await getCards()).reduce((p, c) => {
|
||||
const category = c[1].category
|
||||
return (await getCards(this.lang)).reduce((p, c) => {
|
||||
const category = translate('category', c[1].category, this.lang)
|
||||
if (!category) return p
|
||||
if (!p[category]) {
|
||||
p[category] = []
|
||||
|
@ -1,13 +1,7 @@
|
||||
import { StringEndpointList, StringEndpoint } from '@tcgdex/sdk/interfaces'
|
||||
import { getSet, getSets, isSetAvailable, setToSetSimple, setToSetSingle } from "../utils/setUtil"
|
||||
import { Card, Languages, Set } from '../db/interfaces'
|
||||
import { Card, Languages } from '../db/interfaces'
|
||||
import { Endpoint } from '../interfaces'
|
||||
import Logger from '@dzeio/logger'
|
||||
import { cardToCardSimple, cardToCardSingle, getCards } from '../utils/cardUtil'
|
||||
import { basename } from 'path'
|
||||
import { objectLoop } from '@dzeio/object-util'
|
||||
|
||||
const logger = new Logger(basename(__filename))
|
||||
import { cardToCardSimple, getCards } from '../utils/cardUtil'
|
||||
|
||||
export default class implements Endpoint<StringEndpointList, StringEndpoint, {}, Record<string, Array<[string, Card]>>> {
|
||||
public constructor(
|
||||
@ -31,7 +25,7 @@ export default class implements Endpoint<StringEndpointList, StringEndpoint, {},
|
||||
}
|
||||
|
||||
public async common() {
|
||||
return (await getCards()).reduce((p, c) => {
|
||||
return (await getCards(this.lang)).reduce((p, c) => {
|
||||
const hp = c[1].hp
|
||||
if (!hp) return p
|
||||
if (!p[hp]) {
|
||||
|
@ -1,13 +1,7 @@
|
||||
import { StringEndpointList, StringEndpoint } from '@tcgdex/sdk/interfaces'
|
||||
import { getSet, getSets, isSetAvailable, setToSetSimple, setToSetSingle } from "../utils/setUtil"
|
||||
import { Card, Languages, Set } from '../db/interfaces'
|
||||
import { Card, Languages } from '../db/interfaces'
|
||||
import { Endpoint } from '../interfaces'
|
||||
import Logger from '@dzeio/logger'
|
||||
import { cardToCardSimple, cardToCardSingle, getCards } from '../utils/cardUtil'
|
||||
import { basename } from 'path'
|
||||
import { objectLoop } from '@dzeio/object-util'
|
||||
|
||||
const logger = new Logger(basename(__filename))
|
||||
import { cardToCardSimple, getCards } from '../utils/cardUtil'
|
||||
|
||||
export default class implements Endpoint<StringEndpointList, StringEndpoint, {}, Record<string, Array<[string, Card]>>> {
|
||||
public constructor(
|
||||
@ -31,7 +25,7 @@ export default class implements Endpoint<StringEndpointList, StringEndpoint, {},
|
||||
}
|
||||
|
||||
public async common() {
|
||||
return (await getCards()).reduce((p, c) => {
|
||||
return (await getCards(this.lang)).reduce((p, c) => {
|
||||
const illustrator = c[1].illustrator
|
||||
if (!illustrator) return p
|
||||
if (!p[illustrator]) {
|
||||
|
@ -1,13 +1,8 @@
|
||||
import { StringEndpointList, StringEndpoint } from '@tcgdex/sdk/interfaces'
|
||||
import { getSet, getSets, isSetAvailable, setToSetSimple, setToSetSingle } from "../utils/setUtil"
|
||||
import { Card, Languages, Set } from '../db/interfaces'
|
||||
import translate from '../utils/translationUtil'
|
||||
import { Card, Languages } from '../db/interfaces'
|
||||
import { Endpoint } from '../interfaces'
|
||||
import Logger from '@dzeio/logger'
|
||||
import { cardToCardSimple, cardToCardSingle, getCards } from '../utils/cardUtil'
|
||||
import { basename } from 'path'
|
||||
import { objectLoop } from '@dzeio/object-util'
|
||||
|
||||
const logger = new Logger(basename(__filename))
|
||||
import { cardToCardSimple, getCards } from '../utils/cardUtil'
|
||||
|
||||
export default class implements Endpoint<StringEndpointList, StringEndpoint, {}, Record<string, Array<[string, Card]>>> {
|
||||
public constructor(
|
||||
@ -31,8 +26,8 @@ export default class implements Endpoint<StringEndpointList, StringEndpoint, {},
|
||||
}
|
||||
|
||||
public async common() {
|
||||
return (await getCards()).reduce((p, c) => {
|
||||
const rarity = c[1].rarity // TODO: translate using this.lang
|
||||
return (await getCards(this.lang)).reduce((p, c) => {
|
||||
const rarity = translate('rarity', c[1].rarity, this.lang)
|
||||
if (!rarity) return p
|
||||
if (!p[rarity]) {
|
||||
p[rarity] = []
|
||||
|
@ -1,11 +1,7 @@
|
||||
import { StringEndpointList, StringEndpoint } from '@tcgdex/sdk/interfaces'
|
||||
import { Card, Languages } from '../db/interfaces'
|
||||
import { Endpoint } from '../interfaces'
|
||||
import Logger from '@dzeio/logger'
|
||||
import { cardToCardSimple, getCards } from '../utils/cardUtil'
|
||||
import { basename } from 'path'
|
||||
|
||||
const logger = new Logger(basename(__filename))
|
||||
|
||||
export default class implements Endpoint<StringEndpointList, StringEndpoint, {}, Record<string, Array<[string, Card]>>> {
|
||||
public constructor(
|
||||
@ -29,7 +25,7 @@ export default class implements Endpoint<StringEndpointList, StringEndpoint, {},
|
||||
}
|
||||
|
||||
public async common() {
|
||||
return (await getCards()).reduce((p, c) => {
|
||||
return (await getCards(this.lang)).reduce((p, c) => {
|
||||
const retreat = c[1].retreat
|
||||
if (!retreat) return p
|
||||
if (!p[retreat]) {
|
||||
|
@ -1,13 +1,8 @@
|
||||
import { Serie as SerieSingle, StringEndpoint, SerieList } from '@tcgdex/sdk/interfaces'
|
||||
import { Card, Languages, Serie } from '../db/interfaces'
|
||||
import { Serie as SerieSingle, SerieList } from '@tcgdex/sdk/interfaces'
|
||||
import { Languages, Serie } from '../db/interfaces'
|
||||
import { Endpoint } from '../interfaces'
|
||||
import Logger from '@dzeio/logger'
|
||||
import { cardToCardSimple, cardToCardSingle, getCards } from '../utils/cardUtil'
|
||||
import { basename } from 'path'
|
||||
import { getSeries, serieToSerieSimple, serieToSerieSingle } from '../utils/serieUtil'
|
||||
|
||||
const logger = new Logger(basename(__filename))
|
||||
|
||||
export default class implements Endpoint<SerieList, SerieSingle, {}, Array<Serie>> {
|
||||
public constructor(
|
||||
private lang: keyof Languages
|
||||
@ -21,7 +16,12 @@ export default class implements Endpoint<SerieList, SerieSingle, {}, Array<Serie
|
||||
const items: Record<string, SerieSingle> = {}
|
||||
for (let key = 0; key < common.length; key++) {
|
||||
const val = common[key];
|
||||
items[key] = await serieToSerieSingle(val, this.lang)
|
||||
const gen = await serieToSerieSingle(val, this.lang)
|
||||
const name = val.name[this.lang]
|
||||
if (name) {
|
||||
items[name] = gen
|
||||
}
|
||||
items[key] = gen
|
||||
}
|
||||
return items
|
||||
}
|
||||
|
@ -2,11 +2,7 @@ import { SetList, Set as SetSingle, Card as CardSingle } from '@tcgdex/sdk/inter
|
||||
import { getSet, getSets, isSetAvailable, setToSetSimple, setToSetSingle } from "../utils/setUtil"
|
||||
import { Languages, Set } from '../db/interfaces'
|
||||
import { Endpoint } from '../interfaces'
|
||||
import Logger from '@dzeio/logger'
|
||||
import { cardToCardSingle, getCards } from '../utils/cardUtil'
|
||||
import { basename } from 'path'
|
||||
|
||||
const logger = new Logger(basename(__filename))
|
||||
|
||||
export default class implements Endpoint<SetList, SetSingle, CardSingle, Array<Set>> {
|
||||
public constructor(
|
||||
@ -41,11 +37,11 @@ export default class implements Endpoint<SetList, SetSingle, CardSingle, Array<S
|
||||
}
|
||||
|
||||
public async sub(common: Array<Set>, item: string) {
|
||||
const set = await getSet(item)
|
||||
const set = common.find((s) => s.name[this.lang] === item)
|
||||
|
||||
if (!isSetAvailable(set, this.lang)) return undefined
|
||||
if (!set || !isSetAvailable(set, this.lang)) return undefined
|
||||
|
||||
const lit = await getCards(set)
|
||||
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)
|
||||
|
@ -1,13 +1,8 @@
|
||||
import { StringEndpointList, StringEndpoint } from '@tcgdex/sdk/interfaces'
|
||||
import { getSet, getSets, isSetAvailable, setToSetSimple, setToSetSingle } from "../utils/setUtil"
|
||||
import { Card, Languages, Set } from '../db/interfaces'
|
||||
import translate from '../utils/translationUtil'
|
||||
import { Card, Languages } from '../db/interfaces'
|
||||
import { Endpoint } from '../interfaces'
|
||||
import Logger from '@dzeio/logger'
|
||||
import { cardToCardSimple, cardToCardSingle, getCards } from '../utils/cardUtil'
|
||||
import { basename } from 'path'
|
||||
import { objectLoop } from '@dzeio/object-util'
|
||||
|
||||
const logger = new Logger(basename(__filename))
|
||||
import { cardToCardSimple, getCards } from '../utils/cardUtil'
|
||||
|
||||
export default class implements Endpoint<StringEndpointList, StringEndpoint, {}, Record<string, Array<[string, Card]>>> {
|
||||
public constructor(
|
||||
@ -31,8 +26,8 @@ export default class implements Endpoint<StringEndpointList, StringEndpoint, {},
|
||||
}
|
||||
|
||||
public async common() {
|
||||
return (await getCards()).reduce((p, c) => {
|
||||
const types = c[1].types
|
||||
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
|
||||
for (const type of types) {
|
||||
if (!p[type]) {
|
||||
|
Reference in New Issue
Block a user