mirror of
https://github.com/tcgdex/javascript-sdk.git
synced 2025-07-13 18:45:09 +00:00
Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
21088c4a02 | |||
4fdde0a962 | |||
02a8174509
|
|||
ac570459a3
|
|||
093df107d2 | |||
d166e0f5cf | |||
ef102dc433 | |||
324be2a410 | |||
ad4ad553a4 | |||
7c253c98d7 |
21
CHANGELOG.md
21
CHANGELOG.md
@ -7,6 +7,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## 2.4.3 - 2021-07-19
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- ESM exports are back
|
||||||
|
|
||||||
|
## 2.4.2 2021-07-11
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Downgraded to ES2015 to have better suport browsers
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Moved browser export from `Webpack` to `esbuild`
|
||||||
|
|
||||||
## 2.4.1 - 2021-07-11
|
## 2.4.1 - 2021-07-11
|
||||||
|
|
||||||
## Deprecated
|
## Deprecated
|
||||||
@ -211,8 +227,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Constructor arg support for multiple langs
|
- Constructor arg support for multiple langs
|
||||||
- TranslationUtil to go from the SDK value to a text value
|
- TranslationUtil to go from the SDK value to a text value
|
||||||
|
|
||||||
[Unreleased]: https://github.com/tcgdex/javascript-sdk/compare/v2.3.1...HEAD
|
[Unreleased]: https://github.com/tcgdex/javascript-sdk/compare/v2.4.3...HEAD
|
||||||
|
|
||||||
|
[2.4.3]: https://github.com/tcgdex/javascript-sdk/releases/tag/v2.4.3
|
||||||
|
[2.4.2]: https://github.com/tcgdex/javascript-sdk/releases/tag/v2.4.2
|
||||||
|
[2.4.1]: https://github.com/tcgdex/javascript-sdk/releases/tag/v2.4.1
|
||||||
[2.4.0]: https://github.com/tcgdex/javascript-sdk/releases/tag/v2.4.0
|
[2.4.0]: https://github.com/tcgdex/javascript-sdk/releases/tag/v2.4.0
|
||||||
[2.3.1]: https://github.com/tcgdex/javascript-sdk/releases/tag/v2.3.1
|
[2.3.1]: https://github.com/tcgdex/javascript-sdk/releases/tag/v2.3.1
|
||||||
[2.3.0]: https://github.com/tcgdex/javascript-sdk/releases/tag/v2.3.0
|
[2.3.0]: https://github.com/tcgdex/javascript-sdk/releases/tag/v2.3.0
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
<a href="https://github.com/tcgdex/javascript-sdk/blob/master/LICENSE.md">
|
<a href="https://github.com/tcgdex/javascript-sdk/blob/master/LICENSE.md">
|
||||||
<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." />
|
<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>
|
||||||
<a href="https://github.com/tcgdex/javascript-sdk/blob/master/LICENSE.md">
|
<a href="https://github.com/tcgdex/javascript-sdk/actions/workflows/build.yml">
|
||||||
<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." />
|
<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>
|
</a>
|
||||||
<a href="https://discord.gg/NehYTAhsZE">
|
<a href="https://discord.gg/NehYTAhsZE">
|
||||||
@ -34,11 +34,17 @@ yarn add @tcgdex/sdk
|
|||||||
npm install @tcgdex/sdk
|
npm install @tcgdex/sdk
|
||||||
```
|
```
|
||||||
|
|
||||||
|
or in the web browser
|
||||||
|
```html
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/@tcgdex/sdk@2/dist/tcgdex.browser.js"></script>
|
||||||
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
_Note: a complete documentation is in progress_
|
_Note: a complete documentation is in progress_
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
|
// only if using with NPM/Yarn
|
||||||
import TCGdex from '@tcgdex/sdk'
|
import TCGdex from '@tcgdex/sdk'
|
||||||
|
|
||||||
// initialize the SDK
|
// initialize the SDK
|
||||||
|
1277
package-lock.json
generated
1277
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
119
package.json
119
package.json
@ -1,60 +1,59 @@
|
|||||||
{
|
{
|
||||||
"name": "@tcgdex/sdk",
|
"name": "@tcgdex/sdk",
|
||||||
"version": "2.4.2",
|
"version": "2.4.5",
|
||||||
"main": "./dist/cjs/tcgdex.node.js",
|
"main": "./dist/cjs/tcgdex.node.js",
|
||||||
"types": "./dist/types/tcgdex.d.ts",
|
"module": "./dist/modules/tcgdex.node.js",
|
||||||
"description": "Communicate with the Open Source TCGdex API in Javascript/Typescript using the SDK",
|
"types": "./dist/types/tcgdex.d.ts",
|
||||||
"repository": "https://github.com/tcgdex/javascript-sdk.git",
|
"description": "Communicate with the Open Source TCGdex API in Javascript/Typescript using the SDK",
|
||||||
"homepage": "https://github.com/tcgdex/javascript-sdk",
|
"repository": "https://github.com/tcgdex/javascript-sdk.git",
|
||||||
"author": "Aviortheking",
|
"homepage": "https://github.com/tcgdex/javascript-sdk",
|
||||||
"keywords": [
|
"author": "Aviortheking",
|
||||||
"tcgdex",
|
"keywords": [
|
||||||
"pokemon",
|
"tcgdex",
|
||||||
"trading",
|
"pokemon",
|
||||||
"card",
|
"trading",
|
||||||
"tcg",
|
"card",
|
||||||
"sdk",
|
"tcg",
|
||||||
"api",
|
"sdk",
|
||||||
"typescript",
|
"api",
|
||||||
"javascript",
|
"typescript",
|
||||||
"typing"
|
"javascript",
|
||||||
],
|
"typing"
|
||||||
"license": "MIT",
|
],
|
||||||
"devDependencies": {
|
"license": "MIT",
|
||||||
"@babel/core": "^7.14.6",
|
"devDependencies": {
|
||||||
"@babel/preset-env": "^7.14.7",
|
"@babel/core": "^7.14.6",
|
||||||
"@babel/preset-typescript": "^7.14.5",
|
"@babel/preset-env": "^7.14.7",
|
||||||
"@dzeio/config": "^1.0.0",
|
"@babel/preset-typescript": "^7.14.5",
|
||||||
"@types/node-fetch": "^2.5.10",
|
"@dzeio/config": "^1.0.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^4.28.0",
|
"@types/node-fetch": "^2.5.10",
|
||||||
"@typescript-eslint/parser": "^4.28.0",
|
"@typescript-eslint/eslint-plugin": "^4.28.0",
|
||||||
"eslint": "^7.29.0",
|
"@typescript-eslint/parser": "^4.28.0",
|
||||||
"jest": "^27.0.5",
|
"esbuild": "^0.12.15",
|
||||||
"ts-loader": "^9.2.3",
|
"eslint": "^7.29.0",
|
||||||
"ts-node": "^10.0.0",
|
"jest": "^27.0.5",
|
||||||
"typescript": "^4.1.3",
|
"ts-node": "^10.0.0",
|
||||||
"webpack": "^5.40.0",
|
"typescript": "^4.1.3"
|
||||||
"webpack-nano": "^1.1.1"
|
},
|
||||||
},
|
"engines": {
|
||||||
"engines": {
|
"node": ">=12"
|
||||||
"node": ">=12"
|
},
|
||||||
},
|
"dependencies": {
|
||||||
"dependencies": {
|
"isomorphic-unfetch": "^3.1.0",
|
||||||
"isomorphic-unfetch": "^3.1.0",
|
"unfetch": "^4.2.0"
|
||||||
"unfetch": "^4.2.0"
|
},
|
||||||
},
|
"scripts": {
|
||||||
"scripts": {
|
"prebuild": "node scripts/export-version-number.js",
|
||||||
"prebuild": "node scripts/export-version-number.js",
|
"build": "npm run prebuild && npm run build:cjs && npm run build:browser && npm run build:es2015",
|
||||||
"build": "npm run prebuild && npm run build:cjs && npm run build:browser && npm run build:es2015",
|
"build:cjs": "tsc --project tsconfig.json",
|
||||||
"build:cjs": "tsc --project tsconfig.json",
|
"build:es2015": "tsc --project tsconfig.es2015.json",
|
||||||
"build:es2015": "tsc --project tsconfig.es2015.json",
|
"build:browser": "esbuild ./src/tcgdex.browser.ts --bundle --minify --sourcemap --target=es2016,chrome90,firefox78,safari14,ios13,edge90 --outfile=dist/tcgdex.browser.js",
|
||||||
"build:browser": "wp --config webpack.config.js",
|
"prepublishOnly": "npm run build",
|
||||||
"prepublishOnly": "npm run build",
|
"lint": "eslint",
|
||||||
"lint": "eslint",
|
"test": "jest --coverage"
|
||||||
"test": "jest --coverage"
|
},
|
||||||
},
|
"files": [
|
||||||
"files": [
|
"dist"
|
||||||
"dist"
|
],
|
||||||
],
|
"sideEffects": false
|
||||||
"sideEffects": false
|
}
|
||||||
}
|
|
||||||
|
@ -8,6 +8,7 @@ export type Languages<T = string> = Partial<Record<SupportedLanguages, T>>
|
|||||||
export interface SerieResume {
|
export interface SerieResume {
|
||||||
id: string
|
id: string
|
||||||
name: string
|
name: string
|
||||||
|
logo?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Serie extends SerieResume {
|
export interface Serie extends SerieResume {
|
||||||
|
@ -3,4 +3,4 @@ import unfetch from 'unfetch'
|
|||||||
|
|
||||||
TCGdex.fetch = window.fetch ?? unfetch as any
|
TCGdex.fetch = window.fetch ?? unfetch as any
|
||||||
|
|
||||||
module.exports = TCGdex
|
(global ?? window).TCGdex = TCGdex
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import RequestWrapper from './Request'
|
import RequestWrapper from './Request'
|
||||||
import { Serie, Set, Card, CardResume, SerieList, SetList, SupportedLanguages, StringEndpoint } from './interfaces'
|
import { Serie, Set, Card, CardResume, SerieList, SetList, SupportedLanguages, StringEndpoint } from './interfaces'
|
||||||
type Endpoint = 'cards' | 'categories' | 'hp' | 'illustrators' | 'rarities' | 'retreats' | 'series' | 'sets' | 'types'
|
type Endpoint = 'cards' | 'categories' | 'dex-ids' | 'energy-types' | 'hp' | 'illustrators' | 'rarities' | 'regulation-marks' | 'retreats' | 'series' | 'sets' | 'stages' | 'suffixes' | 'trainer-types' | 'types' | 'variants'
|
||||||
|
|
||||||
const ENDPOINTS: Array<Endpoint> = ['cards', 'categories', 'hp', 'illustrators', 'rarities', 'retreats', 'series', 'sets', 'types']
|
const ENDPOINTS: Array<Endpoint> = ['cards', 'categories', 'dex-ids', 'energy-types', 'hp', 'illustrators', 'rarities', 'regulation-marks', 'retreats', 'series', 'sets', 'stages', 'suffixes', 'trainer-types', 'types', 'variants']
|
||||||
const BASE_URL = 'https://api.tcgdex.net/v2'
|
const BASE_URL = 'https://api.tcgdex.net/v2'
|
||||||
export default class TCGdex {
|
export default class TCGdex {
|
||||||
|
|
||||||
@ -127,19 +127,19 @@ export default class TCGdex {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch cards depending on a specific filter
|
* Fetch cards depending on a specific filter
|
||||||
* @param endpoint_0 {'categories' | 'hp' | 'illustrators' | 'rarities' | 'retreats' | 'types'}
|
* @param endpoint_0 {'categories' | 'dex-ids' | 'energy-types' | 'hp' | 'illustrators' | 'rarities' | 'regulation-marks' | 'retreats' | 'stages' | 'suffixes' | 'trainer-types' | 'types' | 'variants'}
|
||||||
* Possible value 'categories' | 'hp' | 'illustrators' | 'rarities' | 'retreats' | 'types'
|
* Possible value 'categories' | 'dex-ids' | 'energy-types' | 'hp' | 'illustrators' | 'rarities' | 'regulation-marks' | 'retreats' | 'stages' | 'suffixes' | 'trainer-types' | 'types' | 'variants'
|
||||||
* @param endpoint_1 {string} the value set while fetching the index
|
* @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>
|
public async fetch(...endpoint: ['categories' | 'dex-ids' | 'energy-types' | 'hp' | 'illustrators' | 'rarities' | 'regulation-marks' | 'retreats' | 'stages' | 'suffixes' | 'trainer-types' | 'types' | 'variants', string]): Promise<StringEndpoint | undefined>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch cards depending on a specific filter
|
* Fetch cards depending on a specific filter
|
||||||
* @param endpoint_0 {'hp' | 'retreats' | 'categories' | 'illustrators' | 'rarities' | 'types'}
|
* @param endpoint_0 {'categories' | 'dex-ids' | 'energy-types' | 'hp' | 'illustrators' | 'rarities' | 'regulation-marks' | 'retreats' | 'stages' | 'suffixes' | 'trainer-types' | 'types' | 'variants'}
|
||||||
* Possible value 'hp' | 'retreats' | 'categories' | 'illustrators' | 'rarities' | 'types'
|
* Possible value 'categories' | 'dex-ids' | 'energy-types' | 'hp' | 'illustrators' | 'rarities' | 'regulation-marks' | 'retreats' | 'stages' | 'suffixes' | 'trainer-types' | 'types' | 'variants'
|
||||||
* @param endpoint_1 {string} Fetch the possible values to use depending on the endpoint
|
* @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>
|
public async fetch(endpoint: 'categories' | 'dex-ids' | 'energy-types' | 'hp' | 'illustrators' | 'rarities' | 'regulation-marks' | 'retreats' | 'stages' | 'suffixes' | 'trainer-types' | 'types' | 'variants'): Promise<Array<string> | undefined>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch The differents endpoints depending on the first argument
|
* Fetch The differents endpoints depending on the first argument
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"extends": "./tsconfig.json",
|
"extends": "./tsconfig.json",
|
||||||
"include": ["./src/tcgdex.node.ts"],
|
"include": ["./src/tcgdex.node.ts"],
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "ES2020", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
"target": "ES2015", /* 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'. */
|
"module": "ES2015", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
||||||
"declaration": false, /* Generates corresponding '.d.ts' file. */
|
"declaration": false, /* Generates corresponding '.d.ts' file. */
|
||||||
"declarationDir": null,
|
"declarationDir": null,
|
||||||
|
@ -1,34 +0,0 @@
|
|||||||
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: 'ts-loader',
|
|
||||||
exclude: /node_modules/,
|
|
||||||
options: {
|
|
||||||
compilerOptions: {
|
|
||||||
sourceMap: false,
|
|
||||||
declaration: false,
|
|
||||||
declarationDir: null,
|
|
||||||
target: 'ES2016'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user