17 Commits

Author SHA1 Message Date
Blake Joynes
7f98a557dc remove commented tsconfig 2023-04-20 06:27:35 -04:00
Blake Joynes
9e54e26e87 run prettier 2023-04-20 06:26:53 -04:00
Blake Joynes
69a883e845 remove default exports
major version 1.x
2023-04-16 15:39:45 -04:00
Blake Joynes
de2f76d257 add nvmrc \n update packages 2023-04-16 11:27:36 -04:00
Blake
af7dc02a07 Merge pull request #26 from blakejoy/feat/publish-npm
Create npm-publish.yml
2023-04-15 14:52:19 -04:00
Blake
6e111921b5 Create npm-publish.yml 2023-04-15 14:51:27 -04:00
Blake
c95a66baae Merge pull request #23 from Der-Penz/refactor/parsing-options-superclass
Refactor/ moved parsing of parameters into superclass
2023-04-15 14:47:56 -04:00
DerPenz
f3f4868ef8 version: 0.2.0 2023-04-15 20:22:45 +02:00
DerPenz
6bcddc62f1 Merge branch 'master' into refactor/parsing-options-superclass 2023-04-15 18:38:17 +02:00
DerPenz
2b26b7b848 run npm format 2023-04-15 18:32:53 +02:00
DerPenz
6c361002bf Squashed commit of the following:
commit 5d38a76997
Merge: 7cccdb9 f160e23
Author: Blake <blakejoy@users.noreply.github.com>
Date:   Sat Apr 15 11:44:39 2023 -0400

    Merge pull request #22 from blakejoy/feat/add_linting

    feat - add linting and prettier

commit f160e2362c
Author: Blake Joynes <blakejoynes@gmail.com>
Date:   Sat Apr 15 11:44:00 2023 -0400

    add pre commit hook

commit 0fd8317884
Merge: bc91674 d1e87ba
Author: Blake Joynes <blakejoynes@gmail.com>
Date:   Sat Apr 15 11:41:28 2023 -0400

    add husky

commit bc91674c4b
Author: Blake Joynes <blakejoynes@gmail.com>
Date:   Sat Apr 15 11:39:24 2023 -0400

    add husky

commit d1e87ba7be
Author: Blake <blakejoy@users.noreply.github.com>
Date:   Fri Apr 14 08:48:33 2023 -0400

    Update .prettierrc

commit d064d4d86f
Author: Blake Joynes <blakejoynes@gmail.com>
Date:   Fri Apr 14 03:09:39 2023 -0400

    turn off linebreak rules

commit 06155bd323
Author: Blake Joynes <blakejoynes@gmail.com>
Date:   Thu Apr 13 21:58:41 2023 -0400

    add linting and prettier
2023-04-15 18:32:06 +02:00
Blake
6fd471b921 Merge pull request #24 from blakejoy/update_any_types
fix warnings for any type
2023-04-15 12:20:25 -04:00
Blake Joynes
60a2f8e00e update version 2023-04-15 12:17:50 -04:00
Blake Joynes
933ebf25a3 fix warnings for any type 2023-04-15 12:16:57 -04:00
Blake
5d38a76997 Merge pull request #22 from blakejoy/feat/add_linting
feat - add linting and prettier
2023-04-15 11:44:39 -04:00
DerPenz
562864a70f removed unused parameter parsing 2023-04-14 16:01:35 +02:00
DerPenz
1200064194 moved option parsing in superclass 'get' method 2023-04-14 15:54:27 +02:00
24 changed files with 368 additions and 231 deletions

33
.github/workflows/npm-publish.yml vendored Normal file
View File

@@ -0,0 +1,33 @@
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
name: Node.js Package
on:
release:
types: [created]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- run: npm ci
- run: npm test
publish-npm:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}

1
.nvmrc Normal file
View File

@@ -0,0 +1 @@
v18.16.0

292
package-lock.json generated
View File

@@ -1,18 +1,18 @@
{ {
"name": "tmdb-ts", "name": "tmdb-ts",
"version": "0.1.8", "version": "0.2.0",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "tmdb-ts", "name": "tmdb-ts",
"version": "0.1.8", "version": "0.2.0",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"cross-fetch": "^3.1.4" "cross-fetch": "^3.1.4"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^15.3.0", "@types/node": "^18.15.11",
"@types/node-fetch": "^2.5.10", "@types/node-fetch": "^2.5.10",
"@typescript-eslint/eslint-plugin": "^5.58.0", "@typescript-eslint/eslint-plugin": "^5.58.0",
"@typescript-eslint/parser": "^5.58.0", "@typescript-eslint/parser": "^5.58.0",
@@ -23,10 +23,22 @@
"eslint-plugin-prettier": "^4.2.1", "eslint-plugin-prettier": "^4.2.1",
"husky": "^8.0.3", "husky": "^8.0.3",
"prettier": "^2.8.7", "prettier": "^2.8.7",
"ts-node": "^9.1.1", "ts-node": "^10.9.1",
"typescript": "^4.9.5" "typescript": "^4.9.5"
} }
}, },
"node_modules/@cspotcode/source-map-support": {
"version": "0.8.1",
"resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz",
"integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==",
"dev": true,
"dependencies": {
"@jridgewell/trace-mapping": "0.3.9"
},
"engines": {
"node": ">=12"
}
},
"node_modules/@eslint-community/eslint-utils": { "node_modules/@eslint-community/eslint-utils": {
"version": "4.4.0", "version": "4.4.0",
"resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz",
@@ -143,6 +155,31 @@
"integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==",
"dev": true "dev": true
}, },
"node_modules/@jridgewell/resolve-uri": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz",
"integrity": "sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==",
"dev": true,
"engines": {
"node": ">=6.0.0"
}
},
"node_modules/@jridgewell/sourcemap-codec": {
"version": "1.4.15",
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz",
"integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==",
"dev": true
},
"node_modules/@jridgewell/trace-mapping": {
"version": "0.3.9",
"resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz",
"integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==",
"dev": true,
"dependencies": {
"@jridgewell/resolve-uri": "^3.0.3",
"@jridgewell/sourcemap-codec": "^1.4.10"
}
},
"node_modules/@nodelib/fs.scandir": { "node_modules/@nodelib/fs.scandir": {
"version": "2.1.5", "version": "2.1.5",
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
@@ -178,6 +215,30 @@
"node": ">= 8" "node": ">= 8"
} }
}, },
"node_modules/@tsconfig/node10": {
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz",
"integrity": "sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==",
"dev": true
},
"node_modules/@tsconfig/node12": {
"version": "1.0.11",
"resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz",
"integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==",
"dev": true
},
"node_modules/@tsconfig/node14": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz",
"integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==",
"dev": true
},
"node_modules/@tsconfig/node16": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.3.tgz",
"integrity": "sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ==",
"dev": true
},
"node_modules/@types/json-schema": { "node_modules/@types/json-schema": {
"version": "7.0.11", "version": "7.0.11",
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz",
@@ -192,9 +253,9 @@
"peer": true "peer": true
}, },
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "15.3.0", "version": "18.15.11",
"resolved": "https://registry.npmjs.org/@types/node/-/node-15.3.0.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.11.tgz",
"integrity": "sha512-8/bnjSZD86ZfpBsDlCIkNXIvm+h6wi9g7IqL+kmFkQ+Wvu3JrasgLElfiPgoo8V8vVfnEi0QVS12gbl94h9YsQ==", "integrity": "sha512-E5Kwq2n4SbMzQOn6wnmBjuK9ouqlURrcZDVfbo9ftDDTFt3nk7ZKK4GMOzoYgnpQJKcxwQw+lGaBvvlMo0qN/Q==",
"dev": true "dev": true
}, },
"node_modules/@types/node-fetch": { "node_modules/@types/node-fetch": {
@@ -411,11 +472,10 @@
} }
}, },
"node_modules/acorn": { "node_modules/acorn": {
"version": "7.4.1", "version": "8.8.2",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz",
"integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==", "integrity": "sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==",
"dev": true, "dev": true,
"peer": true,
"bin": { "bin": {
"acorn": "bin/acorn" "acorn": "bin/acorn"
}, },
@@ -432,6 +492,15 @@
"acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0"
} }
}, },
"node_modules/acorn-walk": {
"version": "8.2.0",
"resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz",
"integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==",
"dev": true,
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/ajv": { "node_modules/ajv": {
"version": "6.12.6", "version": "6.12.6",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz",
@@ -604,12 +673,6 @@
"node": ">=8" "node": ">=8"
} }
}, },
"node_modules/buffer-from": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz",
"integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==",
"dev": true
},
"node_modules/call-bind": { "node_modules/call-bind": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz",
@@ -1297,18 +1360,6 @@
"url": "https://opencollective.com/eslint" "url": "https://opencollective.com/eslint"
} }
}, },
"node_modules/espree/node_modules/acorn": {
"version": "8.8.2",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz",
"integrity": "sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==",
"dev": true,
"bin": {
"acorn": "bin/acorn"
},
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/esquery": { "node_modules/esquery": {
"version": "1.5.0", "version": "1.5.0",
"resolved": "https://registry.npmjs.org/esquery/-/esquery-1.5.0.tgz", "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.5.0.tgz",
@@ -2664,25 +2715,6 @@
"node": ">=8" "node": ">=8"
} }
}, },
"node_modules/source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"dev": true,
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/source-map-support": {
"version": "0.5.19",
"resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz",
"integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==",
"dev": true,
"dependencies": {
"buffer-from": "^1.0.0",
"source-map": "^0.6.0"
}
},
"node_modules/string.prototype.trim": { "node_modules/string.prototype.trim": {
"version": "1.2.7", "version": "1.2.7",
"resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.2.7.tgz", "resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.2.7.tgz",
@@ -2811,29 +2843,46 @@
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw=="
}, },
"node_modules/ts-node": { "node_modules/ts-node": {
"version": "9.1.1", "version": "10.9.1",
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-9.1.1.tgz", "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz",
"integrity": "sha512-hPlt7ZACERQGf03M253ytLY3dHbGNGrAq9qIHWUY9XHYl1z7wYngSr3OQ5xmui8o2AaxsONxIzjafLUiWBo1Fg==", "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@cspotcode/source-map-support": "^0.8.0",
"@tsconfig/node10": "^1.0.7",
"@tsconfig/node12": "^1.0.7",
"@tsconfig/node14": "^1.0.0",
"@tsconfig/node16": "^1.0.2",
"acorn": "^8.4.1",
"acorn-walk": "^8.1.1",
"arg": "^4.1.0", "arg": "^4.1.0",
"create-require": "^1.1.0", "create-require": "^1.1.0",
"diff": "^4.0.1", "diff": "^4.0.1",
"make-error": "^1.1.1", "make-error": "^1.1.1",
"source-map-support": "^0.5.17", "v8-compile-cache-lib": "^3.0.1",
"yn": "3.1.1" "yn": "3.1.1"
}, },
"bin": { "bin": {
"ts-node": "dist/bin.js", "ts-node": "dist/bin.js",
"ts-node-cwd": "dist/bin-cwd.js",
"ts-node-esm": "dist/bin-esm.js",
"ts-node-script": "dist/bin-script.js", "ts-node-script": "dist/bin-script.js",
"ts-node-transpile-only": "dist/bin-transpile.js", "ts-node-transpile-only": "dist/bin-transpile.js",
"ts-script": "dist/bin-script-deprecated.js" "ts-script": "dist/bin-script-deprecated.js"
}, },
"engines": {
"node": ">=10.0.0"
},
"peerDependencies": { "peerDependencies": {
"@swc/core": ">=1.2.50",
"@swc/wasm": ">=1.2.50",
"@types/node": "*",
"typescript": ">=2.7" "typescript": ">=2.7"
},
"peerDependenciesMeta": {
"@swc/core": {
"optional": true
},
"@swc/wasm": {
"optional": true
}
} }
}, },
"node_modules/tsconfig-paths": { "node_modules/tsconfig-paths": {
@@ -2945,6 +2994,12 @@
"punycode": "^2.1.0" "punycode": "^2.1.0"
} }
}, },
"node_modules/v8-compile-cache-lib": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz",
"integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==",
"dev": true
},
"node_modules/webidl-conversions": { "node_modules/webidl-conversions": {
"version": "3.0.1", "version": "3.0.1",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
@@ -3054,6 +3109,15 @@
} }
}, },
"dependencies": { "dependencies": {
"@cspotcode/source-map-support": {
"version": "0.8.1",
"resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz",
"integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==",
"dev": true,
"requires": {
"@jridgewell/trace-mapping": "0.3.9"
}
},
"@eslint-community/eslint-utils": { "@eslint-community/eslint-utils": {
"version": "4.4.0", "version": "4.4.0",
"resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz",
@@ -3138,6 +3202,28 @@
"integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==",
"dev": true "dev": true
}, },
"@jridgewell/resolve-uri": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz",
"integrity": "sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==",
"dev": true
},
"@jridgewell/sourcemap-codec": {
"version": "1.4.15",
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz",
"integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==",
"dev": true
},
"@jridgewell/trace-mapping": {
"version": "0.3.9",
"resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz",
"integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==",
"dev": true,
"requires": {
"@jridgewell/resolve-uri": "^3.0.3",
"@jridgewell/sourcemap-codec": "^1.4.10"
}
},
"@nodelib/fs.scandir": { "@nodelib/fs.scandir": {
"version": "2.1.5", "version": "2.1.5",
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
@@ -3164,6 +3250,30 @@
"fastq": "^1.6.0" "fastq": "^1.6.0"
} }
}, },
"@tsconfig/node10": {
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz",
"integrity": "sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==",
"dev": true
},
"@tsconfig/node12": {
"version": "1.0.11",
"resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz",
"integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==",
"dev": true
},
"@tsconfig/node14": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz",
"integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==",
"dev": true
},
"@tsconfig/node16": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.3.tgz",
"integrity": "sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ==",
"dev": true
},
"@types/json-schema": { "@types/json-schema": {
"version": "7.0.11", "version": "7.0.11",
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz",
@@ -3178,9 +3288,9 @@
"peer": true "peer": true
}, },
"@types/node": { "@types/node": {
"version": "15.3.0", "version": "18.15.11",
"resolved": "https://registry.npmjs.org/@types/node/-/node-15.3.0.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.11.tgz",
"integrity": "sha512-8/bnjSZD86ZfpBsDlCIkNXIvm+h6wi9g7IqL+kmFkQ+Wvu3JrasgLElfiPgoo8V8vVfnEi0QVS12gbl94h9YsQ==", "integrity": "sha512-E5Kwq2n4SbMzQOn6wnmBjuK9ouqlURrcZDVfbo9ftDDTFt3nk7ZKK4GMOzoYgnpQJKcxwQw+lGaBvvlMo0qN/Q==",
"dev": true "dev": true
}, },
"@types/node-fetch": { "@types/node-fetch": {
@@ -3307,11 +3417,10 @@
} }
}, },
"acorn": { "acorn": {
"version": "7.4.1", "version": "8.8.2",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz",
"integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==", "integrity": "sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==",
"dev": true, "dev": true
"peer": true
}, },
"acorn-jsx": { "acorn-jsx": {
"version": "5.3.2", "version": "5.3.2",
@@ -3320,6 +3429,12 @@
"dev": true, "dev": true,
"requires": {} "requires": {}
}, },
"acorn-walk": {
"version": "8.2.0",
"resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz",
"integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==",
"dev": true
},
"ajv": { "ajv": {
"version": "6.12.6", "version": "6.12.6",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz",
@@ -3446,12 +3561,6 @@
"fill-range": "^7.0.1" "fill-range": "^7.0.1"
} }
}, },
"buffer-from": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz",
"integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==",
"dev": true
},
"call-bind": { "call-bind": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz",
@@ -3969,14 +4078,6 @@
"acorn": "^8.8.0", "acorn": "^8.8.0",
"acorn-jsx": "^5.3.2", "acorn-jsx": "^5.3.2",
"eslint-visitor-keys": "^3.4.0" "eslint-visitor-keys": "^3.4.0"
},
"dependencies": {
"acorn": {
"version": "8.8.2",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz",
"integrity": "sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==",
"dev": true
}
} }
}, },
"esquery": { "esquery": {
@@ -4927,22 +5028,6 @@
"integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==",
"dev": true "dev": true
}, },
"source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"dev": true
},
"source-map-support": {
"version": "0.5.19",
"resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz",
"integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==",
"dev": true,
"requires": {
"buffer-from": "^1.0.0",
"source-map": "^0.6.0"
}
},
"string.prototype.trim": { "string.prototype.trim": {
"version": "1.2.7", "version": "1.2.7",
"resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.2.7.tgz", "resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.2.7.tgz",
@@ -5035,16 +5120,23 @@
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw=="
}, },
"ts-node": { "ts-node": {
"version": "9.1.1", "version": "10.9.1",
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-9.1.1.tgz", "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz",
"integrity": "sha512-hPlt7ZACERQGf03M253ytLY3dHbGNGrAq9qIHWUY9XHYl1z7wYngSr3OQ5xmui8o2AaxsONxIzjafLUiWBo1Fg==", "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==",
"dev": true, "dev": true,
"requires": { "requires": {
"@cspotcode/source-map-support": "^0.8.0",
"@tsconfig/node10": "^1.0.7",
"@tsconfig/node12": "^1.0.7",
"@tsconfig/node14": "^1.0.0",
"@tsconfig/node16": "^1.0.2",
"acorn": "^8.4.1",
"acorn-walk": "^8.1.1",
"arg": "^4.1.0", "arg": "^4.1.0",
"create-require": "^1.1.0", "create-require": "^1.1.0",
"diff": "^4.0.1", "diff": "^4.0.1",
"make-error": "^1.1.1", "make-error": "^1.1.1",
"source-map-support": "^0.5.17", "v8-compile-cache-lib": "^3.0.1",
"yn": "3.1.1" "yn": "3.1.1"
} }
}, },
@@ -5129,6 +5221,12 @@
"punycode": "^2.1.0" "punycode": "^2.1.0"
} }
}, },
"v8-compile-cache-lib": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz",
"integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==",
"dev": true
},
"webidl-conversions": { "webidl-conversions": {
"version": "3.0.1", "version": "3.0.1",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",

View File

@@ -1,6 +1,6 @@
{ {
"name": "tmdb-ts", "name": "tmdb-ts",
"version": "0.1.8", "version": "1.0.0",
"description": "TMDB v3 library wrapper", "description": "TMDB v3 library wrapper",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",
@@ -30,7 +30,7 @@
"author": "Blake Joynes", "author": "Blake Joynes",
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"@types/node": "^15.3.0", "@types/node": "^18.15.11",
"@types/node-fetch": "^2.5.10", "@types/node-fetch": "^2.5.10",
"@typescript-eslint/eslint-plugin": "^5.58.0", "@typescript-eslint/eslint-plugin": "^5.58.0",
"@typescript-eslint/parser": "^5.58.0", "@typescript-eslint/parser": "^5.58.0",
@@ -41,16 +41,16 @@
"eslint-plugin-prettier": "^4.2.1", "eslint-plugin-prettier": "^4.2.1",
"husky": "^8.0.3", "husky": "^8.0.3",
"prettier": "^2.8.7", "prettier": "^2.8.7",
"ts-node": "^9.1.1", "ts-node": "^10.9.1",
"typescript": "^4.9.5" "typescript": "^4.9.5"
}, },
"dependencies": { "dependencies": {
"cross-fetch": "^3.1.4" "cross-fetch": "^3.1.4"
}, },
"volta": { "volta": {
"node": "15.13.0", "node": "18.16.0",
"yarn": "1.19.2", "yarn": "1.22.4",
"npm": "7.12.1" "npm": "9.5.1"
}, },
"husky": { "husky": {
"hooks": { "hooks": {

View File

@@ -1,14 +1,16 @@
import fetch from 'cross-fetch'; import fetch from 'cross-fetch';
import { parseOptions } from './utils';
const BASE_URL_V3 = 'https://api.themoviedb.org/3'; const BASE_URL_V3 = 'https://api.themoviedb.org/3';
export default class Api { export class Api {
constructor(private accessToken: string) { constructor(private accessToken: string) {
this.accessToken = accessToken; this.accessToken = accessToken;
} }
async get<T>(path: string): Promise<T> { async get<T>(path: string, options?: Record<string, any>): Promise<T> {
const response = await fetch(`${BASE_URL_V3}${path}`, { const params = parseOptions(options);
const response = await fetch(`${BASE_URL_V3}${path}?${params}`, {
method: 'GET', method: 'GET',
headers: { headers: {
Authorization: `Bearer ${this.accessToken}`, Authorization: `Bearer ${this.accessToken}`,

View File

@@ -1,11 +1,12 @@
import { BaseEndpoint } from './base'; import { BaseEndpoint } from './base';
import { AccountDetails } from '../types/account';
export class AccountEndpoint extends BaseEndpoint { export class AccountEndpoint extends BaseEndpoint {
constructor(accessToken: string) { constructor(accessToken: string) {
super(accessToken); super(accessToken);
} }
async details(): Promise<any> { async details(): Promise<AccountDetails> {
return await this.api.get('/account'); return await this.api.get('/account');
} }
} }

View File

@@ -1,4 +1,4 @@
import Api from '../api'; import { Api } from '../api';
export class BaseEndpoint { export class BaseEndpoint {
protected api: Api; protected api: Api;

View File

@@ -1,6 +1,5 @@
import { BaseEndpoint } from './base'; import { BaseEndpoint } from './base';
import { ChangeOptions, Changes } from '../types/changes'; import { ChangeOptions, Changes } from '../types/changes';
import { parseOptions } from '../utils';
export class ChangeEndpoint extends BaseEndpoint { export class ChangeEndpoint extends BaseEndpoint {
constructor(protected readonly accessToken: string) { constructor(protected readonly accessToken: string) {
@@ -8,17 +7,14 @@ export class ChangeEndpoint extends BaseEndpoint {
} }
async movies(options?: ChangeOptions): Promise<Changes> { async movies(options?: ChangeOptions): Promise<Changes> {
const params = parseOptions(options); return await this.api.get<Changes>(`/movie/changes`, options);
return await this.api.get<Changes>(`/movie/changes?${params}`);
} }
async tvShows(options?: ChangeOptions): Promise<Changes> { async tvShows(options?: ChangeOptions): Promise<Changes> {
const params = parseOptions(options); return await this.api.get<Changes>(`/tv/changes`, options);
return await this.api.get<Changes>(`/tv/changes?${params}`);
} }
async person(options?: ChangeOptions): Promise<Changes> { async person(options?: ChangeOptions): Promise<Changes> {
const params = parseOptions(options); return await this.api.get<Changes>(`/person/change`, options);
return await this.api.get<Changes>(`/person/changes${params}`);
} }
} }

View File

@@ -4,7 +4,6 @@ import {
LanguageOption, LanguageOption,
Translations, Translations,
} from '../types'; } from '../types';
import { parseOptions } from '../utils';
import { BaseEndpoint } from './base'; import { BaseEndpoint } from './base';
const BASE_COLLECTION = '/collection'; const BASE_COLLECTION = '/collection';
@@ -18,16 +17,16 @@ export class CollectionsEndpoint extends BaseEndpoint {
id: number, id: number,
options?: LanguageOption options?: LanguageOption
): Promise<DetailedCollection> { ): Promise<DetailedCollection> {
const params = parseOptions(options);
return await this.api.get<DetailedCollection>( return await this.api.get<DetailedCollection>(
`${BASE_COLLECTION}/${id}?${params}` `${BASE_COLLECTION}/${id}`,
options
); );
} }
async images(id: number, options?: LanguageOption): Promise<ImageCollection> { async images(id: number, options?: LanguageOption): Promise<ImageCollection> {
const params = parseOptions(options);
return await this.api.get<ImageCollection>( return await this.api.get<ImageCollection>(
`${BASE_COLLECTION}/${id}/images?${params}` `${BASE_COLLECTION}/${id}/images`,
options
); );
} }
@@ -35,9 +34,9 @@ export class CollectionsEndpoint extends BaseEndpoint {
id: number, id: number,
options?: LanguageOption options?: LanguageOption
): Promise<Translations> { ): Promise<Translations> {
const params = parseOptions(options);
return await this.api.get<Translations>( return await this.api.get<Translations>(
`${BASE_COLLECTION}/${id}/translations?${params}` `${BASE_COLLECTION}/${id}/translations`,
options
); );
} }
} }

View File

@@ -3,7 +3,6 @@ import {
SortOption, SortOption,
TvShowDiscoverResult, TvShowDiscoverResult,
} from '../types'; } from '../types';
import { parseOptions } from '../utils';
import { BaseEndpoint } from './base'; import { BaseEndpoint } from './base';
const BASE_DISCOVER = '/discover'; const BASE_DISCOVER = '/discover';
@@ -70,16 +69,16 @@ export class DiscoverEndpoint extends BaseEndpoint {
} }
async movie(options?: MovieQueryOptions): Promise<MovieDiscoverResult> { async movie(options?: MovieQueryOptions): Promise<MovieDiscoverResult> {
const params = parseOptions(options);
return await this.api.get<MovieDiscoverResult>( return await this.api.get<MovieDiscoverResult>(
`${BASE_DISCOVER}/movie?${params}` `${BASE_DISCOVER}/movie`,
options
); );
} }
async tvShow(options?: TvShowQueryOptions): Promise<TvShowDiscoverResult> { async tvShow(options?: TvShowQueryOptions): Promise<TvShowDiscoverResult> {
const params = parseOptions(options);
return await this.api.get<TvShowDiscoverResult>( return await this.api.get<TvShowDiscoverResult>(
`${BASE_DISCOVER}/tv?${params}` `${BASE_DISCOVER}/tv`,
options
); );
} }
} }

View File

@@ -1,6 +1,5 @@
import { BaseEndpoint } from './base'; import { BaseEndpoint } from './base';
import { ExternalIdOptions, FindResult } from '../types'; import { ExternalIdOptions, FindResult } from '../types';
import { parseOptions } from '../utils';
export class FindEndpoint extends BaseEndpoint { export class FindEndpoint extends BaseEndpoint {
constructor(accessToken: string) { constructor(accessToken: string) {
@@ -11,7 +10,6 @@ export class FindEndpoint extends BaseEndpoint {
externalId: string, externalId: string,
options: ExternalIdOptions options: ExternalIdOptions
): Promise<FindResult> { ): Promise<FindResult> {
const params = parseOptions(options); return await this.api.get<FindResult>(`/find/${externalId}`, options);
return await this.api.get<FindResult>(`/find/${externalId}?${params}`);
} }
} }

View File

@@ -1,6 +1,5 @@
import { BaseEndpoint } from './base'; import { BaseEndpoint } from './base';
import { BelongingMovies, Keyword, KeywordsOptions } from '../types'; import { BelongingMovies, Keyword, KeywordsOptions } from '../types';
import { parseOptions } from '../utils';
const BASE_Keyword = '/keyword'; const BASE_Keyword = '/keyword';
@@ -17,9 +16,9 @@ export class KeywordsEndpoint extends BaseEndpoint {
keywordId: number, keywordId: number,
options?: KeywordsOptions options?: KeywordsOptions
): Promise<BelongingMovies> { ): Promise<BelongingMovies> {
const params = parseOptions(options);
return await this.api.get<BelongingMovies>( return await this.api.get<BelongingMovies>(
`${BASE_Keyword}/${keywordId}/movies?${params}` `${BASE_Keyword}/${keywordId}/movies`,
options
); );
} }
} }

View File

@@ -25,7 +25,6 @@ import {
Videos, Videos,
WatchProviders, WatchProviders,
} from '../types'; } from '../types';
import { parseOptions } from '../utils';
const BASE_MOVIE = '/movie'; const BASE_MOVIE = '/movie';
@@ -45,9 +44,9 @@ export class MoviesEndpoint extends BaseEndpoint {
} }
async changes(id: number, options?: ChangeOptions): Promise<MovieChanges> { async changes(id: number, options?: ChangeOptions): Promise<MovieChanges> {
const params = parseOptions(options);
return await this.api.get<MovieChanges>( return await this.api.get<MovieChanges>(
`${BASE_MOVIE}/${id}/changes?${params}` `${BASE_MOVIE}/${id}/changes`,
options
); );
} }
@@ -71,19 +70,16 @@ export class MoviesEndpoint extends BaseEndpoint {
id: number, id: number,
options?: LanguageOption | PageOption options?: LanguageOption | PageOption
): Promise<MovieLists> { ): Promise<MovieLists> {
const params = parseOptions(options); return await this.api.get<MovieLists>(`${BASE_MOVIE}/${id}/lists`, options);
return await this.api.get<MovieLists>(
`${BASE_MOVIE}/${id}/lists?${params}`
);
} }
async recommendations( async recommendations(
id: number, id: number,
options?: PageOption options?: PageOption
): Promise<Recommendations> { ): Promise<Recommendations> {
const params = parseOptions(options);
return await this.api.get<Recommendations>( return await this.api.get<Recommendations>(
`${BASE_MOVIE}/${id}/recommendations?${params}` `${BASE_MOVIE}/${id}/recommendations`,
options
); );
} }
@@ -94,14 +90,13 @@ export class MoviesEndpoint extends BaseEndpoint {
} }
async reviews(id: number, options?: PageOption): Promise<Reviews> { async reviews(id: number, options?: PageOption): Promise<Reviews> {
const params = parseOptions(options); return await this.api.get<Reviews>(`${BASE_MOVIE}/${id}/reviews`, options);
return await this.api.get<Reviews>(`${BASE_MOVIE}/${id}/reviews?${params}`);
} }
async similar(id: number, options?: PageOption): Promise<SimilarMovies> { async similar(id: number, options?: PageOption): Promise<SimilarMovies> {
const params = parseOptions(options);
return await this.api.get<SimilarMovies>( return await this.api.get<SimilarMovies>(
`${BASE_MOVIE}/${id}/similar?${params}` `${BASE_MOVIE}/${id}/similar`,
options
); );
} }
@@ -130,32 +125,31 @@ export class MoviesEndpoint extends BaseEndpoint {
async nowPlaying( async nowPlaying(
options?: PageOption & LanguageOption & RegionOption options?: PageOption & LanguageOption & RegionOption
): Promise<MoviesPlayingNow> { ): Promise<MoviesPlayingNow> {
const params = parseOptions(options);
return await this.api.get<MoviesPlayingNow>( return await this.api.get<MoviesPlayingNow>(
`${BASE_MOVIE}/now_playing?${params}` `${BASE_MOVIE}/now_playing`,
options
); );
} }
async popular(options?: PageOption): Promise<PopularMovies> { async popular(options?: PageOption): Promise<PopularMovies> {
const params = parseOptions(options); return await this.api.get<PopularMovies>(`${BASE_MOVIE}/popular`, options);
return await this.api.get<PopularMovies>(`${BASE_MOVIE}/popular?${params}`);
} }
async topRated( async topRated(
options?: PageOption & LanguageOption & RegionOption options?: PageOption & LanguageOption & RegionOption
): Promise<TopRatedMovies> { ): Promise<TopRatedMovies> {
const params = parseOptions(options);
return await this.api.get<TopRatedMovies>( return await this.api.get<TopRatedMovies>(
`${BASE_MOVIE}/top_rated?${params}` `${BASE_MOVIE}/top_rated`,
options
); );
} }
async upcoming( async upcoming(
options?: PageOption & LanguageOption & RegionOption options?: PageOption & LanguageOption & RegionOption
): Promise<UpcomingMovies> { ): Promise<UpcomingMovies> {
const params = parseOptions(options);
return await this.api.get<UpcomingMovies>( return await this.api.get<UpcomingMovies>(
`${BASE_MOVIE}/upcoming?${params}` `${BASE_MOVIE}/upcoming`,
options
); );
} }
} }

View File

@@ -12,7 +12,6 @@ import {
PopularPersons, PopularPersons,
TaggedImages, TaggedImages,
} from '../types'; } from '../types';
import { parseOptions } from '../utils';
import { BaseEndpoint } from './base'; import { BaseEndpoint } from './base';
const BASE_PERSON = '/person'; const BASE_PERSON = '/person';
@@ -27,9 +26,9 @@ export class PeopleEndpoint extends BaseEndpoint {
} }
async changes(id: number, options?: ChangeOptions): Promise<PersonChanges> { async changes(id: number, options?: ChangeOptions): Promise<PersonChanges> {
const params = parseOptions(options);
return await this.api.get<PersonChanges>( return await this.api.get<PersonChanges>(
`${BASE_PERSON}/${id}/changes?${params}` `${BASE_PERSON}/${id}/changes`,
options
); );
} }
@@ -62,9 +61,9 @@ export class PeopleEndpoint extends BaseEndpoint {
} }
async taggedImages(id: number, options?: PageOption): Promise<TaggedImages> { async taggedImages(id: number, options?: PageOption): Promise<TaggedImages> {
const params = parseOptions(options);
return await this.api.get<TaggedImages>( return await this.api.get<TaggedImages>(
`${BASE_PERSON}/${id}/tagged_images?${params}` `${BASE_PERSON}/${id}/tagged_images`,
options
); );
} }
@@ -79,9 +78,9 @@ export class PeopleEndpoint extends BaseEndpoint {
} }
async popular(options?: PageOption): Promise<PopularPersons> { async popular(options?: PageOption): Promise<PopularPersons> {
const params = parseOptions(options);
return await this.api.get<PopularPersons>( return await this.api.get<PopularPersons>(
`${BASE_PERSON}/popular?${params}` `${BASE_PERSON}/popular`,
options
); );
} }
} }

View File

@@ -1,7 +1,6 @@
import { BaseEndpoint } from './base'; import { BaseEndpoint } from './base';
import { Search } from '../types/search'; import { Search } from '../types/search';
import { Collection, Company, Movie, Person, TV } from '../types'; import { Collection, Company, Movie, Person, TV } from '../types';
import { parseOptions } from '../utils';
const BASE_SEARCH = '/search'; const BASE_SEARCH = '/search';
@@ -31,44 +30,39 @@ export class SearchEndpoint extends BaseEndpoint {
} }
async companies(options: SearchOptions): Promise<Search<Company>> { async companies(options: SearchOptions): Promise<Search<Company>> {
const params = parseOptions(options);
return await this.api.get<Search<Company>>( return await this.api.get<Search<Company>>(
`${BASE_SEARCH}/company?${params}` `${BASE_SEARCH}/company`,
options
); );
} }
async collections(options: SearchOptions): Promise<Search<Collection>> { async collections(options: SearchOptions): Promise<Search<Collection>> {
const params = parseOptions(options);
return await this.api.get<Search<Collection>>( return await this.api.get<Search<Collection>>(
`${BASE_SEARCH}/collection?${params}` `${BASE_SEARCH}/collection`,
options
); );
} }
async keywords( async keywords(
options: SearchOptions options: SearchOptions
): Promise<Search<{ id: string; name: string }>> { ): Promise<Search<{ id: string; name: string }>> {
const params = parseOptions(options);
return await this.api.get<Search<{ id: string; name: string }>>( return await this.api.get<Search<{ id: string; name: string }>>(
`${BASE_SEARCH}/keyword?${params}` `${BASE_SEARCH}/keyword`,
options
); );
} }
async movies(options: MovieSearchOptions): Promise<Search<Movie>> { async movies(options: MovieSearchOptions): Promise<Search<Movie>> {
const params = parseOptions(options); return await this.api.get<Search<Movie>>(`${BASE_SEARCH}/movie`, options);
return await this.api.get<Search<Movie>>(`${BASE_SEARCH}/movie?${params}`);
} }
async people(options: PeopleSearchOptions): Promise<Search<Person>> { async people(options: PeopleSearchOptions): Promise<Search<Person>> {
const params = parseOptions(options); return await this.api.get<Search<Person>>(`${BASE_SEARCH}/person`, options);
return await this.api.get<Search<Person>>(
`${BASE_SEARCH}/person?${params}`
);
} }
// TODO: Multi search // TODO: Multi search
async tvShows(options: TvSearchOptions): Promise<Search<TV>> { async tvShows(options: TvSearchOptions): Promise<Search<TV>> {
const params = parseOptions(options); return await this.api.get<Search<TV>>(`${BASE_SEARCH}/tv`, options);
return await this.api.get<Search<TV>>(`${BASE_SEARCH}/tv?${params}`);
} }
} }

View File

@@ -27,7 +27,6 @@ import {
Videos, Videos,
WatchProviders, WatchProviders,
} from '../types'; } from '../types';
import { parseOptions } from '../utils';
const BASE_TV = '/tv'; const BASE_TV = '/tv';
@@ -47,9 +46,9 @@ export class TvShowsEndpoint extends BaseEndpoint {
} }
async changes(id: number, options?: ChangeOptions): Promise<TvShowChanges> { async changes(id: number, options?: ChangeOptions): Promise<TvShowChanges> {
const params = parseOptions(options);
return await this.api.get<TvShowChanges>( return await this.api.get<TvShowChanges>(
`${BASE_TV}/${id}/changes?${params}` `${BASE_TV}/${id}/changes`,
options
); );
} }
@@ -89,15 +88,14 @@ export class TvShowsEndpoint extends BaseEndpoint {
id: number, id: number,
options?: PageOption options?: PageOption
): Promise<Recommendations> { ): Promise<Recommendations> {
const params = parseOptions(options);
return await this.api.get<Recommendations>( return await this.api.get<Recommendations>(
`${BASE_TV}/${id}/recommendations?${params}` `${BASE_TV}/${id}/recommendations`,
options
); );
} }
async reviews(id: number, options?: PageOption): Promise<Reviews> { async reviews(id: number, options?: PageOption): Promise<Reviews> {
const params = parseOptions(options); return await this.api.get<Reviews>(`${BASE_TV}/${id}/reviews`, options);
return await this.api.get<Reviews>(`${BASE_TV}/${id}/reviews?${params}`);
} }
async screenedTheatrically(id: number): Promise<ScreenedTheatrically> { async screenedTheatrically(id: number): Promise<ScreenedTheatrically> {
@@ -107,9 +105,9 @@ export class TvShowsEndpoint extends BaseEndpoint {
} }
async similar(id: number, options?: PageOption): Promise<SimilarTvShows> { async similar(id: number, options?: PageOption): Promise<SimilarTvShows> {
const params = parseOptions(options);
return await this.api.get<SimilarTvShows>( return await this.api.get<SimilarTvShows>(
`${BASE_TV}/${id}/similar?${params}` `${BASE_TV}/${id}/similar`,
options
); );
} }
@@ -142,25 +140,21 @@ export class TvShowsEndpoint extends BaseEndpoint {
async airingToday( async airingToday(
options?: PageOption & LanguageOption & RegionOption options?: PageOption & LanguageOption & RegionOption
): Promise<TvShowsAiringToday> { ): Promise<TvShowsAiringToday> {
const params = parseOptions(options);
return await this.api.get<TvShowsAiringToday>( return await this.api.get<TvShowsAiringToday>(
`${BASE_TV}/airing_today?${params}` `${BASE_TV}/airing_today`,
options
); );
} }
async popular( async popular(
options?: PageOption & LanguageOption & RegionOption options?: PageOption & LanguageOption & RegionOption
): Promise<PopularTvShows> { ): Promise<PopularTvShows> {
const params = parseOptions(options); return await this.api.get<PopularTvShows>(`${BASE_TV}/popular`, options);
return await this.api.get<PopularTvShows>(`${BASE_TV}/popular?${params}`);
} }
async topRated( async topRated(
options?: PageOption & LanguageOption & RegionOption options?: PageOption & LanguageOption & RegionOption
): Promise<TopRatedTvShows> { ): Promise<TopRatedTvShows> {
const params = parseOptions(options); return await this.api.get<TopRatedTvShows>(`${BASE_TV}/top_rated`, options);
return await this.api.get<TopRatedTvShows>(
`${BASE_TV}/top_rated?${params}`
);
} }
} }

View File

@@ -1,6 +1,6 @@
import TMDB from './tmdb'; import { TMDB } from './tmdb';
export * from './types'; export * from './types';
export * from './utils'; export * from './utils';
export default TMDB; export { TMDB };

View File

@@ -17,7 +17,7 @@ import {
CollectionsEndpoint, CollectionsEndpoint,
} from './endpoints'; } from './endpoints';
export default class TMDB { export class TMDB {
private readonly accessToken: string; private readonly accessToken: string;
constructor(accessToken: string) { constructor(accessToken: string) {

17
src/types/account.ts Normal file
View File

@@ -0,0 +1,17 @@
export interface Gravatar {
hash: string;
}
export interface Avatar {
gravatar: Gravatar;
}
export interface AccountDetails {
avatar: Avatar;
id: number;
include_adult: boolean;
iso_3166_1: string;
iso_639_1: string;
name: string;
username: string;
}

View File

@@ -134,14 +134,14 @@ export interface ContentRatingsResult {
export interface Recommendation { export interface Recommendation {
adult: boolean; adult: boolean;
backdrop_path?: any; backdrop_path?: string;
genre_ids: number[]; genre_ids: number[];
id: number; id: number;
original_language: string; original_language: string;
original_title: string; original_title: string;
overview: string; overview: string;
release_date: string; release_date: string;
poster_path?: any; poster_path?: string;
popularity: number; popularity: number;
title: string; title: string;
video: boolean; video: boolean;

View File

@@ -6,10 +6,17 @@ import {
SpokenLanguage, SpokenLanguage,
} from './'; } from './';
export interface BelongsToCollection {
id: number;
name: string;
poster_path: string;
backdrop_path: string;
}
export interface MovieDetails { export interface MovieDetails {
adult: boolean; adult: boolean;
backdrop_path: string; backdrop_path: string;
belongs_to_collection?: any; belongs_to_collection?: BelongsToCollection;
budget: number; budget: number;
genres: Genre[]; genres: Genre[];
homepage: string; homepage: string;
@@ -19,7 +26,7 @@ export interface MovieDetails {
original_title: string; original_title: string;
overview: string; overview: string;
popularity: number; popularity: number;
poster_path?: any; poster_path?: string;
production_companies: ProductionCompany[]; production_companies: ProductionCompany[];
production_countries: ProductionCountry[]; production_countries: ProductionCountry[];
release_date: string; release_date: string;
@@ -107,8 +114,8 @@ export interface MovieChanges {
export interface LatestMovie { export interface LatestMovie {
adult: boolean; adult: boolean;
backdrop_path?: any; backdrop_path?: string;
belongs_to_collection?: any; belongs_to_collection?: BelongsToCollection;
budget: number; budget: number;
genres: Genre[]; genres: Genre[];
homepage: string; homepage: string;
@@ -119,12 +126,12 @@ export interface LatestMovie {
overview: string; overview: string;
popularity: number; popularity: number;
poster_path: string; poster_path: string;
production_companies: any[]; production_companies: ProductionCompany[];
production_countries: any[]; production_countries: ProductionCountry[];
release_date: string; release_date: string;
revenue: number; revenue: number;
runtime: number; runtime: number;
spoken_languages: any[]; spoken_languages: SpokenLanguage[];
status: string; status: string;
tagline: string; tagline: string;
title: string; title: string;

View File

@@ -14,6 +14,21 @@ export interface CreatedBy {
profile_path: string; profile_path: string;
} }
export interface NextEpisodeToAir {
id: number;
name: string;
overview: string;
vote_average: number;
vote_count: number;
air_date: string;
episode_number: number;
production_code: string;
runtime: number;
season_number: number;
show_id: number;
still_path: string;
}
export interface LastEpisodeToAir { export interface LastEpisodeToAir {
air_date: string; air_date: string;
episode_number: number; episode_number: number;
@@ -57,7 +72,7 @@ export interface TvShowDetails {
last_air_date: string; last_air_date: string;
last_episode_to_air: LastEpisodeToAir; last_episode_to_air: LastEpisodeToAir;
name: string; name: string;
next_episode_to_air?: any; next_episode_to_air?: NextEpisodeToAir;
networks: Network[]; networks: Network[];
number_of_episodes: number; number_of_episodes: number;
number_of_seasons: number; number_of_seasons: number;
@@ -123,9 +138,9 @@ export interface TvShowItem {
id: string; id: string;
action: string; action: string;
time: string; time: string;
value: any; value: Array<number>;
iso_639_1: string; iso_639_1: string;
original_value: any; original_value: Array<number>;
} }
export interface TvShowChange { export interface TvShowChange {
@@ -194,8 +209,8 @@ export interface SimilarTvShows {
} }
export interface LatestTvShows { export interface LatestTvShows {
backdrop_path?: any; backdrop_path?: string;
created_by: any[]; created_by: CreatedBy[];
episode_run_time: number[]; episode_run_time: number[];
first_air_date: string; first_air_date: string;
genres: Genre[]; genres: Genre[];
@@ -211,10 +226,10 @@ export interface LatestTvShows {
origin_country: string[]; origin_country: string[];
original_language: string; original_language: string;
original_name: string; original_name: string;
overview?: any; overview?: string;
popularity: number; popularity: number;
poster_path?: any; poster_path?: string;
production_companies: any[]; production_companies: ProductionCompany[];
seasons: Season[]; seasons: Season[];
status: string; status: string;
type: string; type: string;

View File

@@ -1,3 +1,4 @@
export function parseOptions(options?: { [s: string]: any }): string { export function parseOptions(options?: Record<string, any>): string {
/* eslint-disable @typescript-eslint/no-explicit-any */
return options ? new URLSearchParams(Object.entries(options)).toString() : ''; return options ? new URLSearchParams(Object.entries(options)).toString() : '';
} }

View File

@@ -1,28 +1,18 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "es2020" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */, "target": "ES2022" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */,
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */, "module": "CommonJS" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
"moduleResolution": "node16",
"sourceMap": true /* Generates corresponding '.map' file. */, "sourceMap": true /* Generates corresponding '.map' file. */,
"outDir": "dist" /* Redirect output structure to the directory. */, "outDir": "dist" /* Redirect output structure to the directory. */,
"strict": true /* Enable all strict type-checking options. */, "strict": true /* Enable all strict type-checking options. */,
"allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"types": ["node"], "types": ["node"],
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */, "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
"experimentalDecorators": true /* Enables experimental support for ES7 decorators. */,
"emitDecoratorMetadata": true /* Enables experimental support for emitting type metadata for decorators. */,
"skipLibCheck": true /* Skip type checking of declaration files. */, "skipLibCheck": true /* Skip type checking of declaration files. */,
"forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */ "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */,
"typeRoots": [ "typeRoots": ["./src/types"]
"./src/types"
]
}, },
"types": ["node"], "types": ["node"],
"include": [ "include": ["src"],
"src" "exclude": ["node_modules", "dist", "./src/types/*.ts"]
],
"exclude": [
"node_modules",
"dist",
"./src/types/*.ts"
]
} }