mirror of
https://github.com/tcgdex/javascript-sdk.git
synced 2025-07-13 10:35:11 +00:00
Compare commits
40 Commits
v2.0.0-bet
...
v2.3.0-bet
Author | SHA1 | Date | |
---|---|---|---|
f19298e20d
|
|||
4789c15c7d
|
|||
f28fa11710
|
|||
95c48e530e
|
|||
c3791959be
|
|||
a3537a1af7 | |||
4da8131d11 | |||
8405302286 | |||
b1d97a4278 | |||
b004321f40 | |||
b3d34182a2 | |||
1b1bcfbb84 | |||
a593271aba | |||
6e93a70f1e | |||
fbf6f2e2cd | |||
8e3de78b00 | |||
b845e36784 | |||
23da33f81f | |||
f7010d5f93
|
|||
ed3fbcf5db
|
|||
f62615814d
|
|||
eec10c548a
|
|||
720bc6b43a
|
|||
3557334076
|
|||
a6e2ee60cc
|
|||
22589b0be5
|
|||
81d4447d27
|
|||
d7ba03749d
|
|||
6c5fc609ae
|
|||
4597476e6b
|
|||
2ac98526a1
|
|||
040cb4508a
|
|||
edbcf7f4da
|
|||
0cc19ec1f3
|
|||
551c3bbc6b
|
|||
4b644067fa
|
|||
41d105cda8
|
|||
73028f4803
|
|||
6d7381de7d
|
|||
00e61b370f
|
7
.gitignore
vendored
7
.gitignore
vendored
@ -1,7 +1,6 @@
|
||||
# Dev Files
|
||||
node_modules
|
||||
test.ts
|
||||
|
||||
# Dist files
|
||||
*.js
|
||||
*.d.ts
|
||||
!interfaces.d.ts
|
||||
test.ts
|
||||
dist
|
||||
|
@ -1,6 +1,8 @@
|
||||
src
|
||||
.editorconfig
|
||||
.gitignore
|
||||
.npmignore
|
||||
tsconfig.json
|
||||
*.ts
|
||||
webpack.config.js
|
||||
tsconfig.*
|
||||
yarn.lock
|
||||
CHANGELOG.md
|
||||
|
208
CHANGELOG.md
Normal file
208
CHANGELOG.md
Normal file
@ -0,0 +1,208 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [2.2.0] - 2021-06-19
|
||||
|
||||
### Added
|
||||
|
||||
- Added new fields
|
||||
|
||||
## [2.1.1] - 2021-05-31
|
||||
|
||||
### Fixed
|
||||
|
||||
- Package building in the wrong version of ECMAScript
|
||||
|
||||
## [2.1.0] - 2021-05-31
|
||||
|
||||
### Added
|
||||
|
||||
- new `fetch` function that manage all the API endpoints
|
||||
|
||||
## [2.0.2-2.0.3] - 2021-05-28
|
||||
|
||||
### Fixed
|
||||
|
||||
- `rotationMark` should have been named `regulationMark`
|
||||
|
||||
## [2.0.1] - 2021-05-28
|
||||
|
||||
### Changed
|
||||
|
||||
- Hardcoded string values are now strings as they depends on the language
|
||||
|
||||
## [2.0.0] - 2021-05-28
|
||||
|
||||
### Added
|
||||
|
||||
- simple string endpoint typing
|
||||
- Typing is exported through the main.d.ts file
|
||||
- `cardCount` field in the set interface
|
||||
- a `rotationMark` to the card interface
|
||||
|
||||
### Changed
|
||||
|
||||
- Support new incoming datas
|
||||
- Point the SDK to the new V2
|
||||
- Renamed `getExpansion(s)` to `getSerie(s)`
|
||||
- Typing for the new SDK
|
||||
- Functions now use `fetch` instead of `get` in their names
|
||||
- URL Normalization is now done by the SDK
|
||||
|
||||
### Fixed
|
||||
|
||||
- `getSerie(s)` now point to the correct endpoint
|
||||
|
||||
### Removed
|
||||
|
||||
- TranslationUtil as now translation are managed by the API
|
||||
- the interfaces folder as every interfaces are now in `interfaces.d.ts`
|
||||
- `this.gbu`
|
||||
- Translation files as they are now in the Compiler
|
||||
|
||||
## [1.7.0] - 2021-01-31
|
||||
|
||||
### Added
|
||||
|
||||
- new Rarities
|
||||
|
||||
## [1.6.1] - 2021-01-31
|
||||
|
||||
### Changed
|
||||
|
||||
- tags are now optionnal
|
||||
|
||||
## [1.6.0] - 2021-01-08
|
||||
|
||||
### Changed
|
||||
|
||||
- Errors are now handled to return `undefined`
|
||||
|
||||
### Removed
|
||||
|
||||
- console.warn when using `getCards`
|
||||
|
||||
## [1.5.0] - 2021-01-08
|
||||
|
||||
### Added
|
||||
|
||||
- getSet can now not transform the API Date to a Javascript Date
|
||||
|
||||
## [1.4.2] - 2021-01-08
|
||||
|
||||
### Added
|
||||
|
||||
- new Tags
|
||||
|
||||
### Changed
|
||||
|
||||
- rarities to have less strange rarities
|
||||
-
|
||||
|
||||
### Fixed
|
||||
|
||||
- CORS blocked
|
||||
|
||||
|
||||
## [1.4.1] - 2020-04-24
|
||||
|
||||
### Changed
|
||||
|
||||
- Changed API url to the new one
|
||||
|
||||
## [1.4.0] - 2020-03-25
|
||||
|
||||
### Added
|
||||
|
||||
- a `defaultLang` static field to customize the default lang
|
||||
- a `getLang` function to get the current lang for the SDK
|
||||
|
||||
### Fixed
|
||||
|
||||
- Warnings for translations
|
||||
|
||||
## [1.3.0] - 2020-03-18
|
||||
|
||||
### Added
|
||||
|
||||
- A cache system
|
||||
- some informations about differents tags on a card
|
||||
- lvl on the card interface
|
||||
|
||||
### Removed
|
||||
|
||||
- cardTypes on the card interface
|
||||
|
||||
## [1.2.1] - 2020-03-14
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix items datas not in the correct interface
|
||||
|
||||
## [1.2.0] - 2020-03-14
|
||||
|
||||
### Added
|
||||
|
||||
- Added The getCards endpoint to fetch the big list of card with an optionnal filter on the set
|
||||
- Added The getExpansions endpoint to fetch the list of expansions
|
||||
- Added Some informations about cardTypes
|
||||
- Updated DB to add support for items
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix translation not getting the correct file
|
||||
|
||||
|
||||
## [1.0.8] - 2020-03-11
|
||||
|
||||
### Changed
|
||||
|
||||
- Changed typing for some interfaces
|
||||
|
||||
## [1.0.1-1.0.7] - 2020-03-11
|
||||
|
||||
### Changed
|
||||
|
||||
- Renamed the class Name from `TCGDex` to `TCGdex`
|
||||
- lang argument is now public so it can be changed while the SDK is active
|
||||
|
||||
### Added
|
||||
|
||||
- some typing for getCard and translationUtil
|
||||
|
||||
## [1.0.0] - 2020-03-11
|
||||
|
||||
### Added
|
||||
|
||||
- the getCard function to use with the fetch a card with it's id
|
||||
- the getSet function to use with the fetch a set with it's id
|
||||
- the getExpansion function to use with the fetch an expansion with it's id
|
||||
- Constructor arg support for multiple langs
|
||||
- TranslationUtil to go from the SDK value to a text value
|
||||
|
||||
[Unreleased]: https://github.com/tcgdex/javascript-sdk/compare/v2.1.1...HEAD
|
||||
|
||||
[2.1.1]: https://github.com/tcgdex/javascript-sdk/releases/tag/v2.1.1
|
||||
[2.1.0]: https://github.com/tcgdex/javascript-sdk/releases/tag/v2.1.0
|
||||
[2.0.2-2.0.3]: https://github.com/tcgdex/javascript-sdk/releases/tag/v2.0.3
|
||||
[2.0.1]: https://github.com/tcgdex/javascript-sdk/releases/tag/v2.0.1
|
||||
[2.0.0]: https://github.com/tcgdex/javascript-sdk/releases/tag/v2.0.0
|
||||
[1.7.0]: https://github.com/tcgdex/javascript-sdk/releases/tag/v1.7.0
|
||||
[1.6.1]: https://github.com/tcgdex/javascript-sdk/releases/tag/v1.6.1
|
||||
[1.6.0]: https://github.com/tcgdex/javascript-sdk/releases/tag/1.6.0
|
||||
[1.5.0]: https://github.com/tcgdex/javascript-sdk/releases/tag/1.5.0
|
||||
[1.4.2]: https://github.com/tcgdex/javascript-sdk/releases/tag/1.4.2
|
||||
[1.4.1]: https://github.com/tcgdex/javascript-sdk/releases/tag/1.4.1
|
||||
[1.4.0]: https://github.com/tcgdex/javascript-sdk/releases/tag/1.4.0
|
||||
[1.3.0]: https://github.com/tcgdex/javascript-sdk/releases/tag/1.3.0
|
||||
[1.2.1]: https://github.com/tcgdex/javascript-sdk/releases/tag/1.2.1
|
||||
[1.2.0]: https://github.com/tcgdex/javascript-sdk/releases/tag/1.2.0
|
||||
[1.0.8]: https://github.com/tcgdex/javascript-sdk/releases/tag/1.0.8
|
||||
[1.0.1-1.0.7]: https://github.com/tcgdex/javascript-sdk/releases/tag/1.0.7
|
||||
[1.0.0]: https://github.com/tcgdex/javascript-sdk/releases/tag/v1.0.0
|
50
README.md
50
README.md
@ -1,14 +1,14 @@
|
||||
# TCGdex Javacript SDK
|
||||
# TCGdex JavaScript/TypeScript SDK
|
||||
|
||||
This is the SDK used to communicate with the Open source [TCGdex API](https://www.github.com/tcgdex/cards-database)
|
||||
|
||||
Full API/SDK documentation in progress at https://www.tcgdex.net/docs
|
||||
|
||||
## Install
|
||||
|
||||
### Yarn/npm
|
||||
|
||||
```bash
|
||||
yarn add @tcgdex/sdk
|
||||
```
|
||||
or with npm
|
||||
```bash
|
||||
# or
|
||||
npm install @tcgdex/sdk
|
||||
```
|
||||
|
||||
@ -18,27 +18,33 @@ _Note: a complete documentation is in progress_
|
||||
|
||||
```javascript
|
||||
import TCGdex from '@tcgdex/sdk'
|
||||
import TranslationUtil from '@tcgdex/sdk/TranslationUtil'
|
||||
import Tag from '@tcgdex/sdk/interfaces/Tag'
|
||||
|
||||
// init the class
|
||||
const tcgdex = new TCGdex("en") // Lang code (Optionnal) (See TranslationUtil.ts line 3)
|
||||
// initialize the SDK
|
||||
const tcgdex = new TCGdex('en') // Lang code (Optionnal) (See interfaces.d.ts line 1 for supported languages)
|
||||
|
||||
// change lang
|
||||
tcgdex.lang = "fr"
|
||||
// if you need to change the language
|
||||
tcgdex.lang = 'fr'
|
||||
|
||||
// get Card object wih global id
|
||||
await tcgdex.getCard("base1-1")
|
||||
// get a Card using its global ID
|
||||
await tcgdex.fetch('cards', 'base1-1')
|
||||
|
||||
// get Card object with local id and set
|
||||
await tcgdex.getCard(1, "base1")
|
||||
// fetch a Card using it's local id and set name/ID
|
||||
await tcgdex.fetch('sets', 'Base Set', 1)
|
||||
|
||||
// get Set informations
|
||||
await tcgdex.getSet("base1")
|
||||
// fetch a Set's informations using the set's name/ID
|
||||
await tcgdex.fetch('sets', 'Sword & Shield')
|
||||
|
||||
// get Expansion
|
||||
await tcgdex.getExpansion("base")
|
||||
// Fetch a serie using the serie's name/ID
|
||||
await tcgdex.fetch('series', 'Black & White')
|
||||
|
||||
// Translate information from code to the lang
|
||||
TranslationUtil.translate("tag", Tag.STAGE2, "en")
|
||||
// Fetch cards using other endpoints
|
||||
/**
|
||||
* categories => the the different cards categories
|
||||
* hp => fetch the different cards possible HPs
|
||||
* illustrators => fetch all the cards illustrators
|
||||
* rarities => fetch the cards rarities
|
||||
* retreats => fetch the cards using the retreat count
|
||||
* types => fetch the cards using the Pokémon type(s)
|
||||
**/
|
||||
await tcgdex.fetch('categories')
|
||||
```
|
||||
|
43
package.json
43
package.json
@ -1,25 +1,44 @@
|
||||
{
|
||||
"name": "@tcgdex/sdk",
|
||||
"version": "2.0.0-beta",
|
||||
"main": "./tcgdex.js",
|
||||
"types": "./tcgdex.d.ts",
|
||||
"version": "2.3.0-beta.1",
|
||||
"main": "./dist/cjs/tcgdex.js",
|
||||
"module": "./dist/modules/tcgdex.js",
|
||||
"types": "./dist/types/tcgdex.d.ts",
|
||||
"repository": "https://github.com/tcgdex/javascript-sdk.git",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/node-fetch": "2.5.7",
|
||||
"typescript": "^4.1.3"
|
||||
"@parcel/packager-ts": "2.0.0-beta.2",
|
||||
"@types/node-fetch": "^2.5.10",
|
||||
"awesome-typescript-loader": "^5.2.1",
|
||||
"ts-node": "^10.0.0",
|
||||
"typescript": "^4.1.3",
|
||||
"webpack": "^5.40.0",
|
||||
"webpack-nano": "^1.1.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"isomorphic-unfetch": "^3.1.0"
|
||||
"node-fetch": "^2.6.1",
|
||||
"unfetch": "^4.2.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc --project tsconfig.json",
|
||||
"build": "yarn build:cjs && yarn build:browser && yarn build:es2015",
|
||||
"build:cjs": "tsc --project tsconfig.json",
|
||||
"build:es2015": "tsc --project tsconfig.es2015.json",
|
||||
"build:browser": "wp --config webpack.config.js",
|
||||
"prepublishOnly": "yarn build"
|
||||
},
|
||||
"files": [
|
||||
"*.js",
|
||||
"*.d.ts",
|
||||
"**/*.js",
|
||||
"**/*.d.ts"
|
||||
]
|
||||
"dist"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"targets": {
|
||||
"browser": {
|
||||
"context": "browser",
|
||||
"engines": {
|
||||
"browsers": "since 2017-06"
|
||||
},
|
||||
"includeNodeModules": true,
|
||||
"optimize": false,
|
||||
"scopeHoist": false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import fetch from 'isomorphic-unfetch'
|
||||
import TCGdex from './tcgdex'
|
||||
|
||||
export default class RequestWrapper {
|
||||
private static cache: Array<Request<any>> = []
|
||||
@ -15,16 +15,17 @@ export default class RequestWrapper {
|
||||
|
||||
export class Request<T = any> {
|
||||
public static ttl = 1000 * 60 * 60 // 1 hour
|
||||
|
||||
private response?: T
|
||||
private fetched?: Date
|
||||
public url: string // url is public for quick url test
|
||||
|
||||
public constructor(url: string) {
|
||||
this.url = url
|
||||
}
|
||||
public constructor(
|
||||
public url: string // url is public for quick url test
|
||||
) {}
|
||||
|
||||
public async get(): Promise<T | undefined> {
|
||||
const now = new Date()
|
||||
// if reponse was already fetched and TTL was not passed
|
||||
if (
|
||||
this.fetched &&
|
||||
this.response &&
|
||||
@ -34,17 +35,17 @@ export class Request<T = any> {
|
||||
}
|
||||
|
||||
// Fetch Response
|
||||
const resp = await fetch(this.url, {
|
||||
const unfetch = TCGdex.fetch
|
||||
const resp = await unfetch(this.url, {
|
||||
headers: {
|
||||
"Content-Type": "text/plain"
|
||||
'user-agent': `@tcgdex/javascript-sdk/${TCGdex.VERSION}`
|
||||
}
|
||||
})
|
||||
if (resp.status !== 200) {
|
||||
return undefined
|
||||
}
|
||||
const response = await resp.json()
|
||||
this.response = response
|
||||
this.response = await resp.json()
|
||||
this.fetched = now
|
||||
return response
|
||||
return this.response
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@ export type SupportedLanguages = 'en' | 'fr'
|
||||
|
||||
export type Languages<T = string> = Partial<Record<SupportedLanguages, T>>
|
||||
|
||||
interface SerieResume {
|
||||
export interface SerieResume {
|
||||
id: string
|
||||
name: string
|
||||
}
|
||||
@ -18,23 +18,24 @@ interface variants {
|
||||
firstEdition?: boolean
|
||||
}
|
||||
|
||||
export type Types = 'Colorless' | 'Darkness' | 'Dragon' |
|
||||
'Fairy' | 'Fightning' | 'Fire' |
|
||||
'Grass' | 'Lightning' | 'Metal' |
|
||||
'Psychic' | 'Water'
|
||||
|
||||
export type SetList = Array<SetResume>
|
||||
export type SerieList = Array<SerieResume>
|
||||
export type CardList = Array<CardResume>
|
||||
|
||||
interface SetResume {
|
||||
export interface SetResume {
|
||||
id: string
|
||||
name: string
|
||||
logo?: string
|
||||
symbol?: string
|
||||
cardCount: {
|
||||
total: number
|
||||
official: number
|
||||
/**
|
||||
* total of number of cards
|
||||
*/
|
||||
total: number
|
||||
/**
|
||||
* number of cards officialy (on the bottom of each cards)
|
||||
*/
|
||||
official: number
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,15 +46,55 @@ export interface Set extends SetResume {
|
||||
|
||||
releaseDate: string
|
||||
|
||||
legal?: {
|
||||
/**
|
||||
* Designate if the set is usable in tournaments
|
||||
*
|
||||
* Note: this is specific to the set and if a
|
||||
* card is banned from the set it will still be true
|
||||
*/
|
||||
legal: {
|
||||
/**
|
||||
* Ability to play in standard tournaments
|
||||
*/
|
||||
standard: boolean
|
||||
|
||||
/**
|
||||
* Ability to play in expanded tournaments
|
||||
*/
|
||||
expanded: boolean
|
||||
}
|
||||
|
||||
cardCount: {
|
||||
/**
|
||||
* total of number of cards
|
||||
*/
|
||||
total: number
|
||||
/**
|
||||
* number of cards officialy (on the bottom of each cards)
|
||||
*/
|
||||
official: number
|
||||
/**
|
||||
* number of cards having a normal version
|
||||
*/
|
||||
normal: number
|
||||
/**
|
||||
* number of cards having an reverse version
|
||||
*/
|
||||
reverse: number
|
||||
/**
|
||||
* number of cards having an holo version
|
||||
*/
|
||||
holo: number
|
||||
/**
|
||||
* Number of possible cards
|
||||
*/
|
||||
firstEd?: number
|
||||
}
|
||||
|
||||
cards: CardList
|
||||
}
|
||||
|
||||
interface CardResume {
|
||||
export interface CardResume {
|
||||
id: string
|
||||
localId: string
|
||||
|
||||
@ -81,7 +122,7 @@ export interface Card<SetType extends SetResume = SetResume> extends CardResume
|
||||
* - Ultra Rare
|
||||
* - Secret Rare
|
||||
*/
|
||||
rarity: 'None' | 'Common'| 'Uncommon' | 'Rare' | 'Ultra Rare' | 'Secret Rare'
|
||||
rarity: string
|
||||
|
||||
/**
|
||||
* Card Category
|
||||
@ -90,7 +131,7 @@ export interface Card<SetType extends SetResume = SetResume> extends CardResume
|
||||
* - Trainer
|
||||
* - Energy
|
||||
*/
|
||||
category: 'Pokemon' | 'Trainer' | 'Energy'
|
||||
category: string
|
||||
|
||||
/**
|
||||
* Card Variants (Override Set Variants)
|
||||
@ -119,7 +160,7 @@ export interface Card<SetType extends SetResume = SetResume> extends CardResume
|
||||
/**
|
||||
* Pokemon Types
|
||||
*/
|
||||
types?: Array<Types> // ex for multiple https://www.tcgdex.net/database/ex/ex13/17
|
||||
types?: Array<string> // ex for multiple https://www.tcgdex.net/database/ex/ex13/17
|
||||
|
||||
/**
|
||||
* Pokemon Sub Evolution
|
||||
@ -155,7 +196,7 @@ export interface Card<SetType extends SetResume = SetResume> extends CardResume
|
||||
* - Stage2 https://www.tcgdex.net/database/xy/xy9/3
|
||||
* - VMAX https://www.tcgdex.net/database/swsh/swsh1/50
|
||||
*/
|
||||
stage?: 'Basic' | 'BREAK' | 'LEVEL-UP' | 'MEGA' | 'RESTORED' | 'Stage1' | 'Stage2' | 'VMAX'
|
||||
stage?: string
|
||||
|
||||
/**
|
||||
* Card Suffix
|
||||
@ -168,7 +209,7 @@ export interface Card<SetType extends SetResume = SetResume> extends CardResume
|
||||
* - SP https://www.tcgdex.net/database/pl/pl1/7
|
||||
* - TAG TEAM-GX https://www.tcgdex.net/database/sm/sm12/226
|
||||
*/
|
||||
suffix?: 'EX' | 'GX' | 'V' | 'Legend' | 'Prime' | 'SP' | 'TAG TEAM-GX'
|
||||
suffix?: string
|
||||
|
||||
/**
|
||||
* Pokemon Held Item
|
||||
@ -186,7 +227,7 @@ export interface Card<SetType extends SetResume = SetResume> extends CardResume
|
||||
* multi abilities ex https://www.tcgdex.net/database/ex/ex15/10
|
||||
*/
|
||||
abilities?: Array<{
|
||||
type: 'Pokemon Power' | 'Poke-BODY' | 'Poke-POWER' | 'Ability' | 'Ancient Trait'
|
||||
type: string
|
||||
name: string
|
||||
effect: string
|
||||
}>
|
||||
@ -195,7 +236,7 @@ export interface Card<SetType extends SetResume = SetResume> extends CardResume
|
||||
* Pokemon Attacks
|
||||
*/
|
||||
attacks?: Array<{
|
||||
cost?: Array<Types>
|
||||
cost?: Array<string>
|
||||
name: string
|
||||
effect?: string
|
||||
damage?: string | number
|
||||
@ -205,12 +246,12 @@ export interface Card<SetType extends SetResume = SetResume> extends CardResume
|
||||
* Pokemon Weaknesses
|
||||
*/
|
||||
weaknesses?: Array<{
|
||||
type: Types
|
||||
type: string
|
||||
value?: string
|
||||
}>
|
||||
|
||||
resistances?: Array<{
|
||||
type: Types
|
||||
type: string
|
||||
value?: string
|
||||
}>
|
||||
|
||||
@ -220,18 +261,32 @@ export interface Card<SetType extends SetResume = SetResume> extends CardResume
|
||||
effect?: string
|
||||
|
||||
// Trainer Only
|
||||
trainerType?: 'Supporter' | // https://www.tcgdex.net/database/ex/ex7/83
|
||||
'Item' | // https://www.tcgdex.net/database/ex/ex7/89
|
||||
'Stadium' | // https://www.tcgdex.net/database/ex/ex7/87
|
||||
'Tool' | // https://www.tcgdex.net/database/neo/neo1/93
|
||||
'Ace Spec' | // https://www.tcgdex.net/database/bw/bw7/139
|
||||
'Technical Machine' | // https://www.tcgdex.net/database/ecard/ecard1/144
|
||||
'Goldenred Game Corner' | // https://www.tcgdex.net/database/neo/neo1/83
|
||||
'Rocket\'s Secret Machine' // https://www.tcgdex.net/database/ex/ex7/84
|
||||
trainerType?: string
|
||||
|
||||
// Energy Only
|
||||
energyType?: 'Normal' | // https://www.tcgdex.net/database/ecard/ecard1/160
|
||||
'Special' // https://www.tcgdex.net/database/ecard/ecard1/158
|
||||
energyType?: string
|
||||
|
||||
/**
|
||||
* Define the rotation mark on cards >= Sword & Shield
|
||||
*/
|
||||
regulationMark?: string
|
||||
|
||||
/**
|
||||
* Card ability to be played in official tournaments
|
||||
*
|
||||
* Note: all cards are avaialable to play in unlimited tournaments
|
||||
*/
|
||||
legal: {
|
||||
/**
|
||||
* Ability to play in standard tournaments
|
||||
*/
|
||||
standard: boolean
|
||||
|
||||
/**
|
||||
* Ability to play in expanded tournaments
|
||||
*/
|
||||
expanded: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export type StringEndpointList = Array<string>
|
7
src/tcgdex.browser.ts
Normal file
7
src/tcgdex.browser.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import TCGdex from './tcgdex'
|
||||
import unfetch from 'unfetch'
|
||||
|
||||
TCGdex.fetch = unfetch as any
|
||||
|
||||
export default TCGdex
|
||||
export * from './tcgdex'
|
7
src/tcgdex.node.ts
Normal file
7
src/tcgdex.node.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import TCGdex from './tcgdex'
|
||||
import fetch from 'node-fetch'
|
||||
|
||||
TCGdex.fetch = fetch as any
|
||||
|
||||
export default TCGdex
|
||||
export * from './tcgdex'
|
177
src/tcgdex.ts
Normal file
177
src/tcgdex.ts
Normal file
@ -0,0 +1,177 @@
|
||||
import RequestWrapper from './Request'
|
||||
import { Serie, Set, Card, CardResume, SerieList, SetList, SupportedLanguages, StringEndpoint } from './interfaces'
|
||||
type Endpoint = 'cards' | 'categories' | 'hp' | 'illustrators' | 'rarities' | 'retreats' | 'series' | 'sets' | 'types'
|
||||
|
||||
const ENDPOINTS: Array<Endpoint> = ['cards', 'categories', 'hp', 'illustrators', 'rarities', 'retreats', 'series', 'sets', 'types']
|
||||
const BASE_URL = 'https://api.tcgdex.net/v2'
|
||||
export default class TCGdex {
|
||||
|
||||
|
||||
public static fetch: typeof fetch
|
||||
|
||||
public static readonly VERSION = "2.2.0"
|
||||
|
||||
/**
|
||||
* @deprecated to change the lang use `this.lang`
|
||||
*/
|
||||
public static defaultLang: SupportedLanguages = "en"
|
||||
|
||||
public constructor(public lang?: SupportedLanguages) {}
|
||||
|
||||
public getLang() {
|
||||
return this.lang ?? TCGdex.defaultLang ?? 'en'
|
||||
}
|
||||
|
||||
/**
|
||||
* Shortcut to easily fetch a card using both it's global id and it's local ID
|
||||
* @param id the card global/local ID
|
||||
* @param set the card set name/ID (optionnal)
|
||||
* @returns the card object
|
||||
*/
|
||||
public async fetchCard(id: string | number, set?: string): Promise<Card | undefined> {
|
||||
const path = set ? ['sets', set] : ['cards']
|
||||
// @ts-expect-error the base endpoint is 'sets' or 'cards'
|
||||
return this.fetch(...path, id)
|
||||
}
|
||||
|
||||
/**
|
||||
* Shortcut to easily fetch cards using an optionnal set name/ID
|
||||
* @param set the card set name/ID (optionnal)
|
||||
* @returns a card list
|
||||
*/
|
||||
public async fetchCards(set?: string): Promise<Array<CardResume> | undefined> {
|
||||
if (set) {
|
||||
const fSet = await this.fetch('sets', set)
|
||||
return fSet ? fSet.cards : undefined
|
||||
}
|
||||
return this.fetch('cards')
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use `this.fetch('sets', set)`
|
||||
*/
|
||||
public async fetchSet(set: string) {
|
||||
return this.fetch('sets', set)
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use `this.fetch('series', serie)`
|
||||
*/
|
||||
public async fetchSerie(serie: string): Promise<Serie | undefined> {
|
||||
return this.fetch('series', serie)
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use `this.fetch('series')`
|
||||
*/
|
||||
public async fetchSeries(): Promise<SerieList | undefined> {
|
||||
return this.fetch('series')
|
||||
}
|
||||
|
||||
/**
|
||||
* Shortcut to easily fetch sets using an optionnal serie name/ID
|
||||
* @param serie the card set name/ID (optionnal)
|
||||
* @returns a card list
|
||||
*/
|
||||
public async fetchSets(serie?: string): Promise<SetList | undefined> {
|
||||
if (serie) {
|
||||
const fSerie = await this.fetch('series', serie)
|
||||
return fSerie ? fSerie.sets : undefined
|
||||
}
|
||||
return this.fetch('sets')
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a card using its global id
|
||||
* @param endpoint_0 'cards'
|
||||
* @param endpoint_1 {string} the card global ID
|
||||
*/
|
||||
public async fetch(...type: ['cards', string]): Promise<Card | undefined>
|
||||
/**
|
||||
* Fetch every cards in the database
|
||||
* @param endpoint_0 'cards'
|
||||
*/
|
||||
public async fetch(type: 'cards'): Promise<Array<CardResume> | undefined>
|
||||
/**
|
||||
* Fetch a card using its local id and its set
|
||||
* @param endpoint_0 'sets'
|
||||
* @param endpoint_1 {string} the set name or ID
|
||||
* @param endpoint_2 {string} the card local ID
|
||||
*/
|
||||
public async fetch(...endpoint: ['sets', string, string]): Promise<Card | undefined>
|
||||
/**
|
||||
* Fetch a set
|
||||
* @param endpoint_0 'sets'
|
||||
* @param endpoint_1 {string} the set name or ID
|
||||
*/
|
||||
public async fetch(...endpoint: ['sets', string]): Promise<Set | undefined>
|
||||
/**
|
||||
* Fetch every sets
|
||||
* @param endpoint_0 'sets'
|
||||
*/
|
||||
public async fetch(endpoint: 'sets'): Promise<SetList | undefined>
|
||||
/**
|
||||
* Fetch a serie
|
||||
* @param endpoint_0 'series'
|
||||
* @param endpoint_1 {string} the serie name or ID
|
||||
*/
|
||||
public async fetch(...endpoint: ['series', string]): Promise<Serie | undefined>
|
||||
/**
|
||||
* Fetch every series
|
||||
* @param endpoint_0 'series'
|
||||
*/
|
||||
public async fetch(endpoint: 'series'): Promise<SerieList | undefined>
|
||||
/**
|
||||
* Fetch cards depending on a specific filter
|
||||
* @param endpoint_0 {'categories' | 'hp' | 'illustrators' | 'rarities' | 'retreats' | 'types'}
|
||||
* Possible value 'categories' | 'hp' | 'illustrators' | 'rarities' | 'retreats' | 'types'
|
||||
* @param endpoint_1 {string} the value set while fetching the index
|
||||
*/
|
||||
public async fetch(...endpoint: ['categories' | 'hp' | 'illustrators' | 'rarities' | 'retreats' | 'types', string]): Promise<StringEndpoint | undefined>
|
||||
/**
|
||||
* Fetch cards depending on a specific filter
|
||||
* @param endpoint_0 {'hp' | 'retreats' | 'categories' | 'illustrators' | 'rarities' | 'types'}
|
||||
* Possible value 'hp' | 'retreats' | 'categories' | 'illustrators' | 'rarities' | 'types'
|
||||
* @param endpoint_1 {string} Fetch the possible values to use depending on the endpoint
|
||||
*/
|
||||
public async fetch(endpoint: 'hp' | 'retreats' | 'categories' | 'illustrators' | 'rarities' | 'types'): Promise<Array<string> | undefined>
|
||||
/**
|
||||
* Fetch The differents endpoints depending on the first argument
|
||||
* @param endpoint_0 {'hp' | 'retreats' | 'categories' | 'illustrators' | 'rarities' | 'types'}
|
||||
* Possible value 'cards' | 'categories' | 'hp' | 'illustrators' | 'rarities' | 'retreats' | 'series' | 'sets' | 'types'
|
||||
* @param endpoint_1 {string} (Optionnal) some details to go from the index file to the item file (mostly the ID/name)
|
||||
* @param endpoint_2 {string} (Optionnal) only for sets the card local ID to fetch the card through the set
|
||||
*/
|
||||
public async fetch(...endpoint: Array<Endpoint | string>): Promise<any | undefined> {
|
||||
if (endpoint.length === 0) {
|
||||
throw new Error(`endpoint to fetch is empty!`)
|
||||
}
|
||||
// @ts-expect-error with the precedent check, we KNOW that type is not empty
|
||||
const baseEndpoint = endpoint.shift().toLowerCase() as Endpoint
|
||||
if (!ENDPOINTS.includes(baseEndpoint)) {
|
||||
throw new Error(`unknown endpoint to fetch! (${baseEndpoint})`)
|
||||
}
|
||||
return this.makeRequest(baseEndpoint, ...endpoint)
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to make the request and normalize the whole path
|
||||
*/
|
||||
private makeRequest<T = any>(...url: Array<string | number>) {
|
||||
// Normalize path
|
||||
const path = url.map((v) => encodeURI(
|
||||
v
|
||||
// Transform numbers to string
|
||||
.toString()
|
||||
// replace this special character with an escaped one
|
||||
.replace('?', '%3F')
|
||||
// normalize the string
|
||||
.normalize('NFC')
|
||||
// remove some special chars by nothing
|
||||
.replace(/["'\u0300-\u036f]/g, "")
|
||||
)).join('/')
|
||||
return RequestWrapper.getRequest<T>(`${BASE_URL}/${this.getLang()}/${path}`).get()
|
||||
}
|
||||
}
|
||||
|
||||
export * from './interfaces'
|
85
tcgdex.ts
85
tcgdex.ts
@ -1,85 +0,0 @@
|
||||
import RequestWrapper from './Request'
|
||||
import { Serie, Set, Card, CardResume, SerieList, SetList, SupportedLanguages } from './interfaces'
|
||||
export * from './interfaces'
|
||||
|
||||
export default class TCGdex {
|
||||
public static defaultLang: SupportedLanguages = "en"
|
||||
|
||||
public constructor(public lang?: SupportedLanguages) {}
|
||||
|
||||
public getLang() {
|
||||
return this.lang || TCGdex.defaultLang
|
||||
}
|
||||
|
||||
|
||||
private getBaseUrl() {
|
||||
return `https://api.tcgdex.net/v2/${this.getLang()}`
|
||||
}
|
||||
|
||||
private gbu() {
|
||||
return this.getBaseUrl()
|
||||
}
|
||||
|
||||
public async getCard(id: string|number, full: true, set?: string): Promise<Card<Set> | undefined>
|
||||
// @ts-expect-error Temporary while building it in the compiler
|
||||
public async getCard(id: string|number, full?: boolean, set?: string): Promise<Card | undefined> {
|
||||
const txt = set ? `sets/${set}` : "cards"
|
||||
const req = this.rwgr<Card>(`${this.gbu()}/${txt}/${id}/`)
|
||||
return req.get()
|
||||
}
|
||||
|
||||
public async getCards(set?: string): Promise<Array<CardResume> | undefined> {
|
||||
if (set) {
|
||||
const setSingle = await this.getSet(set)
|
||||
if (!setSingle) {
|
||||
return undefined
|
||||
}
|
||||
return setSingle.cards
|
||||
}
|
||||
const req = this.rwgr<Array<CardResume>>(`/cards/`)
|
||||
const resp = await req.get()
|
||||
if (!resp) {
|
||||
return undefined
|
||||
}
|
||||
return resp
|
||||
}
|
||||
|
||||
public async getSet(set: string): Promise<Set | undefined> {
|
||||
const req = this.rwgr<Set>(`/sets/${set}/`)
|
||||
const resp = await req.get()
|
||||
if (!resp) {
|
||||
return undefined
|
||||
}
|
||||
return resp
|
||||
}
|
||||
|
||||
public async getSerie(expansion: string): Promise<Serie | undefined> {
|
||||
const req = this.rwgr<Serie>(`/expansions/${expansion}/`)
|
||||
return req.get()
|
||||
}
|
||||
|
||||
public async getSeries(): Promise<SerieList | undefined> {
|
||||
const req = this.rwgr<SerieList>(`/expansions/`)
|
||||
return req.get()
|
||||
}
|
||||
|
||||
public async getSets(expansion?: string): Promise<SetList | undefined> {
|
||||
if (expansion) {
|
||||
const expansionSingle = await this.getSerie(expansion)
|
||||
if (!expansionSingle) {
|
||||
return undefined
|
||||
}
|
||||
return expansionSingle.sets
|
||||
}
|
||||
const req = this.rwgr<SetList>(`/sets/`)
|
||||
const list = await req.get()
|
||||
if (!list) {
|
||||
return undefined
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
private rwgr<T = any>(url: string) {
|
||||
return RequestWrapper.getRequest<T>(`${this.gbu()}${url}`)
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
import { translations } from "../TranslationUtil"
|
||||
|
||||
const translations: translations = {
|
||||
en: [
|
||||
"Poké-Body",
|
||||
"Poké-Power",
|
||||
"Ability",
|
||||
"Ancient Trait"
|
||||
],
|
||||
fr: [
|
||||
"Poké-Body",
|
||||
"Poké-Power",
|
||||
"Talent",
|
||||
"Trait Ancien"
|
||||
]
|
||||
}
|
||||
export default translations
|
@ -1,15 +0,0 @@
|
||||
import { translations } from "../TranslationUtil"
|
||||
|
||||
const translations: translations = {
|
||||
en: [
|
||||
"Pokémon",
|
||||
"Trainer",
|
||||
"Energy"
|
||||
],
|
||||
fr: [
|
||||
"Pokémon",
|
||||
"Dresseur",
|
||||
"Énergie"
|
||||
]
|
||||
}
|
||||
export default translations
|
@ -1,21 +0,0 @@
|
||||
import { translations } from "../TranslationUtil"
|
||||
|
||||
const translations: translations = {
|
||||
en: [
|
||||
"No rarity",
|
||||
"Common",
|
||||
"unCommon",
|
||||
"Rare",
|
||||
"Rare Ultra",
|
||||
"Ultra Rare",
|
||||
],
|
||||
fr: [
|
||||
"Sans rareté",
|
||||
"Commun",
|
||||
"Non Commun",
|
||||
"Rare",
|
||||
"Rare Ultra",
|
||||
"Ultra Rare",
|
||||
]
|
||||
}
|
||||
export default translations
|
@ -1,59 +0,0 @@
|
||||
import { translations } from "../TranslationUtil"
|
||||
|
||||
const translations: translations = {
|
||||
en: [
|
||||
"Basic Pokémon",
|
||||
"Basic Energy",
|
||||
"BREAK",
|
||||
"EX",
|
||||
"GX",
|
||||
"Item",
|
||||
"LEGEND",
|
||||
"Level-Up",
|
||||
"MEGA",
|
||||
"Restored",
|
||||
"Rocket's Secret Machine",
|
||||
"SP",
|
||||
"Special",
|
||||
"Stadium",
|
||||
"Stage 1",
|
||||
"Stage 2",
|
||||
"Supporter",
|
||||
"Tag Team",
|
||||
"Technical Machine",
|
||||
"Tool",
|
||||
"Pokémon V",
|
||||
"Pokémon VMAX",
|
||||
"Prime",
|
||||
"ACE",
|
||||
"Rainbow",
|
||||
],
|
||||
fr: [
|
||||
"Pokémon de base",
|
||||
"Energie de base",
|
||||
"TURBO",
|
||||
"EX",
|
||||
"GX",
|
||||
"Objet",
|
||||
"LÉGENDE",
|
||||
"Niveau Sup",
|
||||
"Méga",
|
||||
"Restauré",
|
||||
"Machine secrète dees Rocket",
|
||||
"SP",
|
||||
"Spéciale",
|
||||
"Stadium",
|
||||
"Niveau 1",
|
||||
"Niveau 2",
|
||||
"Supporter",
|
||||
"ESCOUADE",
|
||||
"Machine Technique",
|
||||
"Outil",
|
||||
"Pokémon V",
|
||||
"Pokémon VMAX",
|
||||
"Prime",
|
||||
"ACE",
|
||||
"Arc en ciel",
|
||||
]
|
||||
}
|
||||
export default translations
|
@ -1,32 +0,0 @@
|
||||
import { translations } from "../TranslationUtil";
|
||||
|
||||
const trans: translations = {
|
||||
en: [
|
||||
"Colorless",
|
||||
"Darkness",
|
||||
"Dragon",
|
||||
"Fairy",
|
||||
"Fighting",
|
||||
"Fire",
|
||||
"Grass",
|
||||
"Lightning",
|
||||
"Metal",
|
||||
"Psychic",
|
||||
"Water"
|
||||
],
|
||||
fr: [
|
||||
"Incolore",
|
||||
"Obscurité",
|
||||
"Dragon",
|
||||
"Fée",
|
||||
"Combat",
|
||||
"Feu",
|
||||
"Plante",
|
||||
"Électrique",
|
||||
"Métal",
|
||||
"Psy",
|
||||
"Eau"
|
||||
]
|
||||
}
|
||||
|
||||
export default trans
|
11
tsconfig.es2015.json
Normal file
11
tsconfig.es2015.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"include": ["./src/tcgdex.node.ts"],
|
||||
"compilerOptions": {
|
||||
"target": "ES2020", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
||||
"module": "ES2015", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
||||
"declaration": false, /* Generates corresponding '.d.ts' file. */
|
||||
"declarationDir": null,
|
||||
"outDir": "./dist/modules", /* Redirect output structure to the directory. */
|
||||
}
|
||||
}
|
118
tsconfig.json
118
tsconfig.json
@ -1,66 +1,66 @@
|
||||
{
|
||||
"include": ["**/*.ts"],
|
||||
"exclude": ["translations"],
|
||||
"include": ["./src/tcgdex.node.ts"],
|
||||
"compilerOptions": {
|
||||
/* Basic Options */
|
||||
// "incremental": true, /* Enable incremental compilation */
|
||||
"target": "ESNext", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
||||
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
||||
// "lib": [], /* Specify library files to be included in the compilation. */
|
||||
// "allowJs": true, /* Allow javascript files to be compiled. */
|
||||
// "checkJs": true, /* Report errors in .js files. */
|
||||
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
||||
"declaration": true, /* Generates corresponding '.d.ts' file. */
|
||||
// "declarationDir": "types", /* Folder where the declarations are*/
|
||||
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
||||
// "sourceMap": true, /* Generates corresponding '.map' file. */
|
||||
// "outFile": "./", /* Concatenate and emit output to single file. */
|
||||
// "outDir": "./", /* Redirect output structure to the directory. */
|
||||
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
||||
// "composite": true, /* Enable project compilation */
|
||||
// "tsBuildInfoFile": "", /* Specify file to store incremental compilation information */
|
||||
"removeComments": true, /* Do not emit comments to output. */
|
||||
// "noEmit": true, /* Do not emit outputs. */
|
||||
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
||||
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
||||
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
||||
/* Strict Type-Checking Options */
|
||||
"strict": true, /* Enable all strict type-checking options. */
|
||||
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
||||
// "strictNullChecks": true, /* Enable strict null checks. */
|
||||
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
||||
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
||||
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
||||
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
||||
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
||||
/* Basic Options */
|
||||
// "incremental": true, /* Enable incremental compilation */
|
||||
"target": "ES2020", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
||||
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
||||
// "lib": [], /* Specify library files to be included in the compilation. */
|
||||
// "allowJs": true, /* Allow javascript files to be compiled. */
|
||||
// "checkJs": true, /* Report errors in .js files. */
|
||||
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
||||
"declaration": true, /* Generates corresponding '.d.ts' file. */
|
||||
"declarationDir": "./dist/types", /* Folder where the declarations are*/
|
||||
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
||||
// "sourceMap": true, /* Generates corresponding '.map' file. */
|
||||
// "outFile": "./", /* Concatenate and emit output to single file. */
|
||||
"outDir": "./dist/cjs", /* Redirect output structure to the directory. */
|
||||
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
||||
// "composite": true, /* Enable project compilation */
|
||||
// "tsBuildInfoFile": "", /* Specify file to store incremental compilation information */
|
||||
// "removeComments": true, /* Do not emit comments to output. */
|
||||
// "noEmit": true, /* Do not emit outputs. */
|
||||
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
||||
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
||||
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
||||
/* Strict Type-Checking Options */
|
||||
"strict": true, /* Enable all strict type-checking options. */
|
||||
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
||||
"strictNullChecks": true, /* Enable strict null checks. */
|
||||
"strictFunctionTypes": true, /* Enable strict checking of function types. */
|
||||
"strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
||||
"strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
||||
"noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
||||
"alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
||||
|
||||
/* Additional Checks */
|
||||
"noUnusedLocals": true, /* Report errors on unused locals. */
|
||||
"noUnusedParameters": true, /* Report errors on unused parameters. */
|
||||
"noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
||||
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
/* Additional Checks */
|
||||
"noUnusedLocals": true, /* Report errors on unused locals. */
|
||||
"noUnusedParameters": true, /* Report errors on unused parameters. */
|
||||
"noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
||||
"noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
|
||||
/* Module Resolution Options */
|
||||
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
||||
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
||||
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
||||
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
||||
// "typeRoots": [], /* List of folders to include type definitions from. */
|
||||
// "types": [], /* Type declaration files to be included in compilation. */
|
||||
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
||||
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
||||
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
||||
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
||||
"resolveJsonModule": true,
|
||||
/* Module Resolution Options */
|
||||
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
||||
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
||||
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
||||
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
||||
// "typeRoots": [], /* List of folders to include type definitions from. */
|
||||
// "types": [], /* Type declaration files to be included in compilation. */
|
||||
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
||||
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
||||
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
||||
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
||||
|
||||
/* Source Map Options */
|
||||
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
|
||||
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
||||
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
|
||||
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
|
||||
/* Source Map Options */
|
||||
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
|
||||
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
||||
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
|
||||
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
|
||||
|
||||
/* Experimental Options */
|
||||
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
|
||||
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
||||
/* Experimental Options */
|
||||
"experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
|
||||
"emitDecoratorMetadata": true /* Enables experimental support for emitting type metadata for decorators. */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
31
webpack.config.js
Normal file
31
webpack.config.js
Normal file
@ -0,0 +1,31 @@
|
||||
const path = require('path')
|
||||
|
||||
module.exports = {
|
||||
mode: 'production',
|
||||
entry: './src/tcgdex.browser.ts',
|
||||
output: {
|
||||
path: path.resolve(__dirname, 'dist'),
|
||||
filename: 'tcgdex.browser.js',
|
||||
libraryTarget: 'umd',
|
||||
library: 'TCGdex',
|
||||
umdNamedDefine: true
|
||||
},
|
||||
resolve: {
|
||||
extensions: ['.ts']
|
||||
},
|
||||
optimization: {
|
||||
minimize: true
|
||||
},
|
||||
module: {
|
||||
rules: [{
|
||||
test: /\.ts$/,
|
||||
loader: 'awesome-typescript-loader',
|
||||
exclude: /node_modules/,
|
||||
options: {
|
||||
sourceMap: false,
|
||||
declarationDir: false,
|
||||
target: 'ES2016'
|
||||
}
|
||||
}]
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user