Updated documents

Signed-off-by: Avior <florian.bouillon@delta-wings.net>
This commit is contained in:
Florian Bouillon 2021-06-22 21:33:19 +02:00
parent 8a0dac5e27
commit f858bd5c79
Signed by: Florian Bouillon
GPG Key ID: 50BD648F12C86AB6
3 changed files with 344 additions and 301 deletions

View File

@ -1,208 +1,217 @@
# Changelog # Changelog
All notable changes to this project will be documented in this file. 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/), 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). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased] ## [Unreleased]
## [2.2.0] - 2021-06-19 ## 2.3.0 - 2021-06-22
### Added ### Added
- Added new fields - Browser specialized build
- [#9](https://github.com/tcgdex/javascript-sdk/pull/9) Build/Unit/ESLint tests and coverage with Codecov using Github Action
## [2.1.1] - 2021-05-31
### Changed
### Fixed
- [#10](https://github.com/tcgdex/javascript-sdk/pull/10) Simplified Request/Cache manager
- Package building in the wrong version of ECMAScript
## [2.2.0] - 2021-06-19
## [2.1.0] - 2021-05-31
### Added
### Added
- Added new fields
- new `fetch` function that manage all the API endpoints
## [2.1.1] - 2021-05-31
## [2.0.2-2.0.3] - 2021-05-28
### Fixed
### Fixed
- Package building in the wrong version of ECMAScript
- `rotationMark` should have been named `regulationMark`
## [2.1.0] - 2021-05-31
## [2.0.1] - 2021-05-28
### Added
### Changed
- new `fetch` function that manage all the API endpoints
- Hardcoded string values are now strings as they depends on the language
## [2.0.2-2.0.3] - 2021-05-28
## [2.0.0] - 2021-05-28
### Fixed
### Added
- `rotationMark` should have been named `regulationMark`
- simple string endpoint typing
- Typing is exported through the main.d.ts file ## [2.0.1] - 2021-05-28
- `cardCount` field in the set interface
- a `rotationMark` to the card interface ### Changed
### Changed - Hardcoded string values are now strings as they depends on the language
- Support new incoming datas ## [2.0.0] - 2021-05-28
- Point the SDK to the new V2
- Renamed `getExpansion(s)` to `getSerie(s)` ### Added
- Typing for the new SDK
- Functions now use `fetch` instead of `get` in their names - simple string endpoint typing
- URL Normalization is now done by the SDK - Typing is exported through the main.d.ts file
- `cardCount` field in the set interface
### Fixed - a `rotationMark` to the card interface
- `getSerie(s)` now point to the correct endpoint ### Changed
### Removed - Support new incoming datas
- Point the SDK to the new V2
- TranslationUtil as now translation are managed by the API - Renamed `getExpansion(s)` to `getSerie(s)`
- the interfaces folder as every interfaces are now in `interfaces.d.ts` - Typing for the new SDK
- `this.gbu` - Functions now use `fetch` instead of `get` in their names
- Translation files as they are now in the Compiler - URL Normalization is now done by the SDK
## [1.7.0] - 2021-01-31 ### Removed
### Added - TranslationUtil as now translation are managed by the API
- the interfaces folder as every interfaces are now in `interfaces.d.ts`
- new Rarities - `this.gbu`
- Translation files as they are now in the Compiler
## [1.6.1] - 2021-01-31
## [1.7.0] - 2021-01-31
### Changed
### Added
- tags are now optionnal
- new Rarities
## [1.6.0] - 2021-01-08
## [1.6.1] - 2021-01-31
### Changed
### Changed
- Errors are now handled to return `undefined`
- tags are now optionnal
### Removed
## [1.6.0] - 2021-01-08
- console.warn when using `getCards`
### Changed
## [1.5.0] - 2021-01-08
- Errors are now handled to return `undefined`
### Added
### Removed
- getSet can now not transform the API Date to a Javascript Date
- console.warn when using `getCards`
## [1.4.2] - 2021-01-08
## [1.5.0] - 2021-01-08
### Added
### Added
- new Tags
- getSet can now not transform the API Date to a Javascript Date
### Changed
## [1.4.2] - 2021-01-08
- rarities to have less strange rarities
- ### Added
### Fixed - new Tags
- CORS blocked ### Changed
- rarities to have less strange rarities
## [1.4.1] - 2020-04-24 -
### Changed ### Fixed
- Changed API url to the new one - CORS blocked
## [1.4.0] - 2020-03-25
## [1.4.1] - 2020-04-24
### Added
### Changed
- a `defaultLang` static field to customize the default lang
- a `getLang` function to get the current lang for the SDK - Changed API url to the new one
### Fixed ## [1.4.0] - 2020-03-25
- Warnings for translations ### Added
## [1.3.0] - 2020-03-18 - a `defaultLang` static field to customize the default lang
- a `getLang` function to get the current lang for the SDK
### Added
### Fixed
- A cache system
- some informations about differents tags on a card - Warnings for translations
- lvl on the card interface
## [1.3.0] - 2020-03-18
### Removed
### Added
- cardTypes on the card interface
- A cache system
## [1.2.1] - 2020-03-14 - some informations about differents tags on a card
- lvl on the card interface
### Fixed
### Removed
- Fix items datas not in the correct interface
- cardTypes on the card interface
## [1.2.0] - 2020-03-14
## [1.2.1] - 2020-03-14
### Added
### Fixed
- 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 - Fix items datas not in the correct interface
- Added Some informations about cardTypes
- Updated DB to add support for items ## [1.2.0] - 2020-03-14
### Fixed ### Added
- Fix translation not getting the correct file - 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
## [1.0.8] - 2020-03-11 - Updated DB to add support for items
### Changed ### Fixed
- Changed typing for some interfaces - Fix translation not getting the correct file
## [1.0.1-1.0.7] - 2020-03-11
## [1.0.8] - 2020-03-11
### Changed
### Changed
- Renamed the class Name from `TCGDex` to `TCGdex`
- lang argument is now public so it can be changed while the SDK is active - Changed typing for some interfaces
### Added ## [1.0.1-1.0.7] - 2020-03-11
- some typing for getCard and translationUtil ### Changed
## [1.0.0] - 2020-03-11 - Renamed the class Name from `TCGDex` to `TCGdex`
- lang argument is now public so it can be changed while the SDK is active
### Added
### 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 - some typing for getCard and translationUtil
- the getExpansion function to use with the fetch an expansion with it's id
- Constructor arg support for multiple langs ## [1.0.0] - 2020-03-11
- TranslationUtil to go from the SDK value to a text value
### Added
[Unreleased]: https://github.com/tcgdex/javascript-sdk/compare/v2.1.1...HEAD
- the getCard function to use with the fetch a card with it's id
[2.1.1]: https://github.com/tcgdex/javascript-sdk/releases/tag/v2.1.1 - the getSet function to use with the fetch a set with it's id
[2.1.0]: https://github.com/tcgdex/javascript-sdk/releases/tag/v2.1.0 - the getExpansion function to use with the fetch an expansion with it's id
[2.0.2-2.0.3]: https://github.com/tcgdex/javascript-sdk/releases/tag/v2.0.3 - Constructor arg support for multiple langs
[2.0.1]: https://github.com/tcgdex/javascript-sdk/releases/tag/v2.0.1 - TranslationUtil to go from the SDK value to a text value
[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 [Unreleased]: https://github.com/tcgdex/javascript-sdk/compare/v2.3.0...HEAD
[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 [2.3.0]: https://github.com/tcgdex/javascript-sdk/releases/tag/v2.3.0
[1.5.0]: https://github.com/tcgdex/javascript-sdk/releases/tag/1.5.0 [2.2.0]: https://github.com/tcgdex/javascript-sdk/releases/tag/v2.2.0
[1.4.2]: https://github.com/tcgdex/javascript-sdk/releases/tag/1.4.2 [2.1.1]: https://github.com/tcgdex/javascript-sdk/releases/tag/v2.1.1
[1.4.1]: https://github.com/tcgdex/javascript-sdk/releases/tag/1.4.1 [2.1.0]: https://github.com/tcgdex/javascript-sdk/releases/tag/v2.1.0
[1.4.0]: https://github.com/tcgdex/javascript-sdk/releases/tag/1.4.0 [2.0.2-2.0.3]: https://github.com/tcgdex/javascript-sdk/releases/tag/v2.0.3
[1.3.0]: https://github.com/tcgdex/javascript-sdk/releases/tag/1.3.0 [2.0.1]: https://github.com/tcgdex/javascript-sdk/releases/tag/v2.0.1
[1.2.1]: https://github.com/tcgdex/javascript-sdk/releases/tag/1.2.1 [2.0.0]: https://github.com/tcgdex/javascript-sdk/releases/tag/v2.0.0
[1.2.0]: https://github.com/tcgdex/javascript-sdk/releases/tag/1.2.0 [1.7.0]: https://github.com/tcgdex/javascript-sdk/releases/tag/v1.7.0
[1.0.8]: https://github.com/tcgdex/javascript-sdk/releases/tag/1.0.8 [1.6.1]: https://github.com/tcgdex/javascript-sdk/releases/tag/v1.6.1
[1.0.1-1.0.7]: https://github.com/tcgdex/javascript-sdk/releases/tag/1.0.7 [1.6.0]: https://github.com/tcgdex/javascript-sdk/releases/tag/1.6.0
[1.0.0]: https://github.com/tcgdex/javascript-sdk/releases/tag/v1.0.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

120
README.md
View File

@ -1,50 +1,70 @@
# TCGdex JavaScript/TypeScript SDK <p align="center">
<a href="http://npmjs.com/@tcgdex/sdk">
This is the SDK used to communicate with the Open source [TCGdex API](https://www.github.com/tcgdex/cards-database) <img src="https://img.shields.io/npm/v/@tcgdex/sdk?style=flat-square" alt="NOM Version">
</a>
Full API/SDK documentation in progress at https://www.tcgdex.net/docs <a href="http://npmjs.com/@tcgdex/sdk">
<img src="https://img.shields.io/npm/dw/@tcgdex/sdk?style=flat-square" alt="NPM Downloads">
## Install </a>
<a href="https://app.codecov.io/gh/tcgdex/javascript-sdk/">
```bash <img src="https://img.shields.io/codecov/c/github/tcgdex/javascript-sdk?style=flat-square&token=FR4BI94N4Q" alt="npm version">
yarn add @tcgdex/sdk </a>
# or <a href="https://github.com/tcgdex/javascript-sdk/blob/master/LICENSE.md">
npm install @tcgdex/sdk <img src="https://img.shields.io/github/license/tcgdex/javascript-sdk?style=flat-square" alt="the TCGdex JAvascript SDK is released under the MIT license." />
``` </a>
<a href="https://github.com/tcgdex/javascript-sdk/blob/master/LICENSE.md">
## Usage <img src="https://img.shields.io/github/workflow/status/tcgdex/javascript-sdk/Build%20&%20Test?style=flat-square" alt="the TCGdex JAvascript SDK is released under the MIT license." />
</a>
_Note: a complete documentation is in progress_
</p>
```javascript
import TCGdex from '@tcgdex/sdk' # TCGdex JavaScript/TypeScript SDK
// initialize the SDK Communicate with the Open Source TCGdex API in Javascript/Typescript using the SDK
const tcgdex = new TCGdex('en') // Lang code (Optionnal) (See interfaces.d.ts line 1 for supported languages)
Full API/SDK documentation in progress at https://www.tcgdex.net/docs
// if you need to change the language
tcgdex.lang = 'fr' ## Getting Started
// get a Card using its global ID Install the SDK using:
await tcgdex.fetch('cards', 'base1-1') ```bash
yarn add @tcgdex/sdk
// fetch a Card using it's local id and set name/ID # or
await tcgdex.fetch('sets', 'Base Set', 1) npm install @tcgdex/sdk
```
// fetch a Set's informations using the set's name/ID
await tcgdex.fetch('sets', 'Sword & Shield') ## Usage
// Fetch a serie using the serie's name/ID _Note: a complete documentation is in progress_
await tcgdex.fetch('series', 'Black & White')
```javascript
// Fetch cards using other endpoints import TCGdex from '@tcgdex/sdk'
/**
* categories => the the different cards categories // initialize the SDK
* hp => fetch the different cards possible HPs const tcgdex = new TCGdex('en') // Lang code (Optionnal) (See interfaces.ts line 1 for supported languages)
* illustrators => fetch all the cards illustrators
* rarities => fetch the cards rarities // if you need to change the language
* retreats => fetch the cards using the retreat count tcgdex.lang = 'fr'
* types => fetch the cards using the Pokémon type(s)
**/ // get a Card using its global ID
await tcgdex.fetch('categories') await tcgdex.fetch('cards', 'base1-1')
```
// fetch a Card using it's local id and set name/ID
await tcgdex.fetch('sets', 'Base Set', 1)
// fetch a Set's informations using the set's name/ID
await tcgdex.fetch('sets', 'Sword & Shield')
// Fetch a serie using the serie's name/ID
await tcgdex.fetch('series', 'Black & White')
// 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')
```

View File

@ -1,43 +1,57 @@
{ {
"name": "@tcgdex/sdk", "name": "@tcgdex/sdk",
"version": "2.3.0-beta.2", "version": "2.3.0-beta.2",
"main": "./dist/cjs/tcgdex.node.js", "main": "./dist/cjs/tcgdex.node.js",
"types": "./dist/types/tcgdex.d.ts", "types": "./dist/types/tcgdex.d.ts",
"repository": "https://github.com/tcgdex/javascript-sdk.git", "repository": "https://github.com/tcgdex/javascript-sdk.git",
"license": "MIT", "homepage": "https://github.com/tcgdex/javascript-sdk",
"devDependencies": { "author": "Aviortheking",
"@babel/core": "^7.14.6", "keywords": [
"@babel/preset-env": "^7.14.7", "tcgdex",
"@babel/preset-typescript": "^7.14.5", "pokemon",
"@types/node-fetch": "^2.5.10", "trading",
"@typescript-eslint/eslint-plugin": "^4.28.0", "card",
"@typescript-eslint/parser": "^4.28.0", "tcg",
"eslint": "^7.29.0", "sdk",
"jest": "^27.0.5", "api",
"ts-loader": "^9.2.3", "typescript",
"ts-node": "^10.0.0", "javascript",
"typescript": "^4.1.3", "typing"
"webpack": "^5.40.0", ],
"webpack-nano": "^1.1.1" "license": "MIT",
}, "devDependencies": {
"engines": { "@babel/core": "^7.14.6",
"node": ">=12" "@babel/preset-env": "^7.14.7",
}, "@babel/preset-typescript": "^7.14.5",
"dependencies": { "@types/node-fetch": "^2.5.10",
"isomorphic-unfetch": "^3.1.0", "@typescript-eslint/eslint-plugin": "^4.28.0",
"unfetch": "^4.2.0" "@typescript-eslint/parser": "^4.28.0",
}, "eslint": "^7.29.0",
"scripts": { "jest": "^27.0.5",
"build": "yarn build:cjs && yarn build:browser && yarn build:es2015", "ts-loader": "^9.2.3",
"build:cjs": "tsc --project tsconfig.json", "ts-node": "^10.0.0",
"build:es2015": "tsc --project tsconfig.es2015.json", "typescript": "^4.1.3",
"build:browser": "wp --config webpack.config.js", "webpack": "^5.40.0",
"prepublishOnly": "yarn build", "webpack-nano": "^1.1.1"
"lint": "eslint", },
"test": "jest --coverage" "engines": {
}, "node": ">=12"
"files": [ },
"dist" "dependencies": {
], "isomorphic-unfetch": "^3.1.0",
"sideEffects": false "unfetch": "^4.2.0"
} },
"scripts": {
"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",
"lint": "eslint",
"test": "jest --coverage"
},
"files": [
"dist"
],
"sideEffects": false
}