mirror of
https://github.com/tcgdex/javascript-sdk.git
synced 2025-07-13 10:35:11 +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]
|
||||
|
||||
## 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
|
||||
|
||||
## 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
|
||||
- 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.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
|
||||
|
@ -11,7 +11,7 @@
|
||||
<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." />
|
||||
</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." />
|
||||
</a>
|
||||
<a href="https://discord.gg/NehYTAhsZE">
|
||||
@ -34,11 +34,17 @@ yarn add @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
|
||||
|
||||
_Note: a complete documentation is in progress_
|
||||
|
||||
```javascript
|
||||
// only if using with NPM/Yarn
|
||||
import TCGdex from '@tcgdex/sdk'
|
||||
|
||||
// initialize the SDK
|
||||
|
1277
package-lock.json
generated
1277
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
11
package.json
11
package.json
@ -1,7 +1,8 @@
|
||||
{
|
||||
"name": "@tcgdex/sdk",
|
||||
"version": "2.4.2",
|
||||
"version": "2.4.5",
|
||||
"main": "./dist/cjs/tcgdex.node.js",
|
||||
"module": "./dist/modules/tcgdex.node.js",
|
||||
"types": "./dist/types/tcgdex.d.ts",
|
||||
"description": "Communicate with the Open Source TCGdex API in Javascript/Typescript using the SDK",
|
||||
"repository": "https://github.com/tcgdex/javascript-sdk.git",
|
||||
@ -28,13 +29,11 @@
|
||||
"@types/node-fetch": "^2.5.10",
|
||||
"@typescript-eslint/eslint-plugin": "^4.28.0",
|
||||
"@typescript-eslint/parser": "^4.28.0",
|
||||
"esbuild": "^0.12.15",
|
||||
"eslint": "^7.29.0",
|
||||
"jest": "^27.0.5",
|
||||
"ts-loader": "^9.2.3",
|
||||
"ts-node": "^10.0.0",
|
||||
"typescript": "^4.1.3",
|
||||
"webpack": "^5.40.0",
|
||||
"webpack-nano": "^1.1.1"
|
||||
"typescript": "^4.1.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
@ -48,7 +47,7 @@
|
||||
"build": "npm run prebuild && npm run build:cjs && npm run build:browser && npm run build:es2015",
|
||||
"build:cjs": "tsc --project tsconfig.json",
|
||||
"build:es2015": "tsc --project tsconfig.es2015.json",
|
||||
"build:browser": "wp --config webpack.config.js",
|
||||
"build:browser": "esbuild ./src/tcgdex.browser.ts --bundle --minify --sourcemap --target=es2016,chrome90,firefox78,safari14,ios13,edge90 --outfile=dist/tcgdex.browser.js",
|
||||
"prepublishOnly": "npm run build",
|
||||
"lint": "eslint",
|
||||
"test": "jest --coverage"
|
||||
|
@ -8,6 +8,7 @@ export type Languages<T = string> = Partial<Record<SupportedLanguages, T>>
|
||||
export interface SerieResume {
|
||||
id: string
|
||||
name: string
|
||||
logo?: string
|
||||
}
|
||||
|
||||
export interface Serie extends SerieResume {
|
||||
|
@ -3,4 +3,4 @@ import unfetch from 'unfetch'
|
||||
|
||||
TCGdex.fetch = window.fetch ?? unfetch as any
|
||||
|
||||
module.exports = TCGdex
|
||||
(global ?? window).TCGdex = TCGdex
|
||||
|
@ -1,8 +1,8 @@
|
||||
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'
|
||||
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'
|
||||
export default class TCGdex {
|
||||
|
||||
@ -127,19 +127,19 @@ export default class TCGdex {
|
||||
|
||||
/**
|
||||
* 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_0 {'categories' | 'dex-ids' | 'energy-types' | 'hp' | 'illustrators' | 'rarities' | 'regulation-marks' | 'retreats' | 'stages' | 'suffixes' | 'trainer-types' | 'types' | 'variants'}
|
||||
* 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
|
||||
*/
|
||||
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
|
||||
* @param endpoint_0 {'hp' | 'retreats' | 'categories' | 'illustrators' | 'rarities' | 'types'}
|
||||
* Possible value '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 '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
|
||||
*/
|
||||
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
|
||||
|
@ -2,7 +2,7 @@
|
||||
"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'. */
|
||||
"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'. */
|
||||
"declaration": false, /* Generates corresponding '.d.ts' file. */
|
||||
"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