mirror of
https://github.com/LukeHagar/plexjs.git
synced 2025-12-06 12:37:46 +00:00
Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d638acb5d2 | ||
|
|
f87006d3e8 | ||
|
|
fcab6f2532 | ||
|
|
4c552faaf5 | ||
|
|
7ea8776750 | ||
|
|
b9487a78df | ||
|
|
4addcb43e0 | ||
|
|
05444f54ad | ||
|
|
a7139cc510 | ||
|
|
ddbf96d1d1 | ||
|
|
a40e1f6ee9 | ||
|
|
b37ec6d21e | ||
|
|
b868a95db1 | ||
|
|
7d18553ff0 | ||
|
|
e83d09070a | ||
|
|
0794b8457e | ||
|
|
c6ba56222a | ||
|
|
e8f38b8d0a | ||
|
|
898fa0212d | ||
|
|
67a632bbc2 |
21
.github/workflows/bump_version.yml
vendored
21
.github/workflows/bump_version.yml
vendored
@@ -69,6 +69,13 @@ jobs:
|
|||||||
npm install
|
npm install
|
||||||
npm run build
|
npm run build
|
||||||
|
|
||||||
|
- name: Publish to NPM
|
||||||
|
id: publish
|
||||||
|
uses: JS-DevTools/npm-publish@v1
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.NPM_TOKEN }}
|
||||||
|
package: ./plexjs/package.json
|
||||||
|
|
||||||
- name: Commit changes and create new version tag
|
- name: Commit changes and create new version tag
|
||||||
if: steps.buildSDK.outcome == 'success'
|
if: steps.buildSDK.outcome == 'success'
|
||||||
uses: stefanzweifel/git-auto-commit-action@v4
|
uses: stefanzweifel/git-auto-commit-action@v4
|
||||||
@@ -86,17 +93,3 @@ jobs:
|
|||||||
release_name: ${{ github.event.inputs.version }}
|
release_name: ${{ github.event.inputs.version }}
|
||||||
draft: false
|
draft: false
|
||||||
prerelease: false
|
prerelease: false
|
||||||
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- uses: actions/setup-node@v3
|
|
||||||
with:
|
|
||||||
node-version: 12
|
|
||||||
- run: |
|
|
||||||
cd plexjs
|
|
||||||
npm ci
|
|
||||||
|
|
||||||
- id: publish
|
|
||||||
uses: JS-DevTools/npm-publish@v1
|
|
||||||
with:
|
|
||||||
token: ${{ secrets.NPM_TOKEN }}
|
|
||||||
package: ./plexjs/package.json
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ files:
|
|||||||
destinationFilename: package.json
|
destinationFilename: package.json
|
||||||
npmName: plexjs
|
npmName: plexjs
|
||||||
npmRepository: lukehagar
|
npmRepository: lukehagar
|
||||||
npmVersion: 0.0.13
|
npmVersion: 0.0.20
|
||||||
useSingleRequestParameter: true
|
useSingleRequestParameter: true
|
||||||
sortParamsByRequiredFlag: true
|
sortParamsByRequiredFlag: true
|
||||||
gitUserID: lukehagar
|
gitUserID: lukehagar
|
||||||
|
|||||||
6
examples/.eslintignore
Normal file
6
examples/.eslintignore
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
# don't ever lint node_modules
|
||||||
|
node_modules
|
||||||
|
# don't lint build output (make sure it's set to your correct build folder name)
|
||||||
|
build
|
||||||
|
# don't lint nyc coverage output
|
||||||
|
coverage
|
||||||
19
examples/.eslintrc
Normal file
19
examples/.eslintrc
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"root": true,
|
||||||
|
"parser": "@typescript-eslint/parser",
|
||||||
|
"plugins": ["@typescript-eslint", "prettier", "jest"],
|
||||||
|
"extends": [
|
||||||
|
"eslint:recommended",
|
||||||
|
"plugin:@typescript-eslint/recommended",
|
||||||
|
"prettier"
|
||||||
|
],
|
||||||
|
"rules": {
|
||||||
|
"no-console": 1,
|
||||||
|
"prettier/prettier": 2
|
||||||
|
},
|
||||||
|
"env": {
|
||||||
|
"browser": true,
|
||||||
|
"node": true,
|
||||||
|
"jest/globals": true
|
||||||
|
}
|
||||||
|
}
|
||||||
107
examples/.gitignore
vendored
Normal file
107
examples/.gitignore
vendored
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
|
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||||
|
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||||
|
|
||||||
|
# Runtime data
|
||||||
|
pids
|
||||||
|
*.pid
|
||||||
|
*.seed
|
||||||
|
*.pid.lock
|
||||||
|
|
||||||
|
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||||
|
lib-cov
|
||||||
|
|
||||||
|
# Coverage directory used by tools like istanbul
|
||||||
|
coverage
|
||||||
|
*.lcov
|
||||||
|
|
||||||
|
# nyc test coverage
|
||||||
|
.nyc_output
|
||||||
|
|
||||||
|
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||||
|
.grunt
|
||||||
|
|
||||||
|
# Bower dependency directory (https://bower.io/)
|
||||||
|
bower_components
|
||||||
|
|
||||||
|
# node-waf configuration
|
||||||
|
.lock-wscript
|
||||||
|
|
||||||
|
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||||
|
build/Release
|
||||||
|
|
||||||
|
# Dependency directories
|
||||||
|
node_modules/
|
||||||
|
jspm_packages/
|
||||||
|
|
||||||
|
# TypeScript v1 declaration files
|
||||||
|
typings/
|
||||||
|
|
||||||
|
# TypeScript cache
|
||||||
|
*.tsbuildinfo
|
||||||
|
|
||||||
|
# Optional npm cache directory
|
||||||
|
.npm
|
||||||
|
|
||||||
|
# Optional eslint cache
|
||||||
|
.eslintcache
|
||||||
|
|
||||||
|
# Microbundle cache
|
||||||
|
.rpt2_cache/
|
||||||
|
.rts2_cache_cjs/
|
||||||
|
.rts2_cache_es/
|
||||||
|
.rts2_cache_umd/
|
||||||
|
|
||||||
|
# Optional REPL history
|
||||||
|
.node_repl_history
|
||||||
|
|
||||||
|
# Output of 'npm pack'
|
||||||
|
*.tgz
|
||||||
|
|
||||||
|
# Yarn Integrity file
|
||||||
|
.yarn-integrity
|
||||||
|
|
||||||
|
# dotenv environment variables file
|
||||||
|
.env
|
||||||
|
.env.test
|
||||||
|
|
||||||
|
# parcel-bundler cache (https://parceljs.org/)
|
||||||
|
.cache
|
||||||
|
|
||||||
|
# Next.js build output
|
||||||
|
.next
|
||||||
|
|
||||||
|
# Nuxt.js build / generate output
|
||||||
|
.nuxt
|
||||||
|
dist
|
||||||
|
|
||||||
|
# Gatsby files
|
||||||
|
.cache/
|
||||||
|
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||||
|
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||||
|
# public
|
||||||
|
|
||||||
|
# vuepress build output
|
||||||
|
.vuepress/dist
|
||||||
|
|
||||||
|
# Serverless directories
|
||||||
|
.serverless/
|
||||||
|
|
||||||
|
# FuseBox cache
|
||||||
|
.fusebox/
|
||||||
|
|
||||||
|
# DynamoDB Local files
|
||||||
|
.dynamodb/
|
||||||
|
|
||||||
|
# TernJS port file
|
||||||
|
.tern-port
|
||||||
|
|
||||||
|
# Stores VSCode versions used for testing VSCode extensions
|
||||||
|
.vscode-test
|
||||||
5
examples/.prettierrc
Normal file
5
examples/.prettierrc
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"trailingComma": "all",
|
||||||
|
"singleQuote": true,
|
||||||
|
"printWidth": 80
|
||||||
|
}
|
||||||
43
examples/README.md
Normal file
43
examples/README.md
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
# 🧰 Simple TypeScript Starter | 2022
|
||||||
|
|
||||||
|
> We talk about a lot of **advanced Node.js and TypeScript** concepts on [the blog](https://khalilstemmler.com), particularly focused around Domain-Driven Design and large-scale enterprise application patterns. However, I received a few emails from readers that were interested in seeing what a basic TypeScript starter project looks like. So I've put together just that.
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
- Minimal
|
||||||
|
- TypeScript v4
|
||||||
|
- Testing with Jest
|
||||||
|
- Linting with Eslint and Prettier
|
||||||
|
- Pre-commit hooks with Husky
|
||||||
|
- VS Code debugger scripts
|
||||||
|
- Local development with Nodemon
|
||||||
|
|
||||||
|
### Scripts
|
||||||
|
|
||||||
|
#### `npm run start:dev`
|
||||||
|
|
||||||
|
Starts the application in development using `nodemon` and `ts-node` to do hot reloading.
|
||||||
|
|
||||||
|
#### `npm run start`
|
||||||
|
|
||||||
|
Starts the app in production by first building the project with `npm run build`, and then executing the compiled JavaScript at `build/index.js`.
|
||||||
|
|
||||||
|
#### `npm run build`
|
||||||
|
|
||||||
|
Builds the app at `build`, cleaning the folder first.
|
||||||
|
|
||||||
|
#### `npm run test`
|
||||||
|
|
||||||
|
Runs the `jest` tests once.
|
||||||
|
|
||||||
|
#### `npm run test:dev`
|
||||||
|
|
||||||
|
Run the `jest` tests in watch mode, waiting for file changes.
|
||||||
|
|
||||||
|
#### `npm run prettier-format`
|
||||||
|
|
||||||
|
Format your code.
|
||||||
|
|
||||||
|
#### `npm run prettier-watch`
|
||||||
|
|
||||||
|
Format your code in watch mode, waiting for file changes.
|
||||||
@@ -1 +0,0 @@
|
|||||||
import { Configuration } from "@lukehagar/plexjs";
|
|
||||||
6
examples/nodemon.json
Normal file
6
examples/nodemon.json
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"watch": ["src"],
|
||||||
|
"ext": ".ts,.js",
|
||||||
|
"ignore": [],
|
||||||
|
"exec": "npx ts-node ./src/index.ts"
|
||||||
|
}
|
||||||
17904
examples/package-lock.json
generated
Normal file
17904
examples/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,15 +1,35 @@
|
|||||||
{
|
{
|
||||||
"name": "examples",
|
"name": "typescript-starter",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "Examples using the plexjs package",
|
"description": "A basic typescript app starter for 2023.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "npx ts-node index.ts",
|
"build": "rimraf ./build && tsc",
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"start:dev": "npx nodemon",
|
||||||
|
"start": "npm run build && node build/index.js"
|
||||||
},
|
},
|
||||||
"author": "lukehagar",
|
"keywords": [],
|
||||||
"license": "MIT",
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@lukehagar/plexjs": "^0.0.7"
|
"@lukehagar/plexjs": "^0.0.19",
|
||||||
|
"@types/jest": "^29.5.0",
|
||||||
|
"@types/node": "^18.6.1",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^5.31.0",
|
||||||
|
"@typescript-eslint/parser": "^5.31.0",
|
||||||
|
"eslint": "^8.20.0",
|
||||||
|
"eslint-config-prettier": "^8.5.0",
|
||||||
|
"eslint-plugin-jest": "^27.2.1",
|
||||||
|
"eslint-plugin-prettier": "^4.2.1",
|
||||||
|
"nodemon": "^2.0.19",
|
||||||
|
"onchange": "^7.1.0",
|
||||||
|
"prettier": "^2.7.1",
|
||||||
|
"rimraf": "^5.0.0",
|
||||||
|
"run-script-os": "^1.1.6",
|
||||||
|
"ts-node": "^10.9.1",
|
||||||
|
"typescript": "^5.0.4"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"jest-cucumber": "^3.0.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
9
examples/src/index.ts
Normal file
9
examples/src/index.ts
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
// eslint-disable-next-line no-console
|
||||||
|
import { Configuration, ServerApi } from '@lukehagar/plexjs';
|
||||||
|
|
||||||
|
const config = new Configuration({ basePath: 'http://10.10.10.47:32400' });
|
||||||
|
const api = new ServerApi(config);
|
||||||
|
|
||||||
|
api.getServerCapabilities();
|
||||||
|
|
||||||
|
console.log('Hello world!');
|
||||||
16
examples/tsconfig.json
Normal file
16
examples/tsconfig.json
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "es5",
|
||||||
|
"module": "commonjs",
|
||||||
|
"lib": ["es6"],
|
||||||
|
"allowJs": true,
|
||||||
|
"outDir": "build",
|
||||||
|
"rootDir": "src",
|
||||||
|
"strict": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"types": ["node", "jest"],
|
||||||
|
"skipLibCheck": true
|
||||||
|
},
|
||||||
|
"include": ["src/**/*"],
|
||||||
|
"exclude": ["src/**/*.spec.ts"]
|
||||||
|
}
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
Arguments:
|
|
||||||
C:\Program Files\nodejs\node.exe C:\Users\Luke\AppData\Roaming\npm\node_modules\yarn\bin\yarn.js add --dev plexjs
|
|
||||||
|
|
||||||
PATH:
|
|
||||||
C:\Python311\Scripts\;C:\Python311\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\nodejs\;C:\ProgramData\chocolatey\bin;C:\Program Files\Git\cmd;C:\Program Files\Docker\Docker\resources\bin;C:\Program Files\Go\bin;C:\Users\Luke\.console-ninja\.bin;C:\Users\Luke\AppData\Local\Microsoft\WindowsApps;C:\Users\Luke\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\Luke\AppData\Local\GitHubDesktop\bin;C:\Users\Luke\go\bin;C:\Users\Luke\AppData\Roaming\npm;C:\Users\Luke\go\bin
|
|
||||||
|
|
||||||
Yarn version:
|
|
||||||
1.22.19
|
|
||||||
|
|
||||||
Node version:
|
|
||||||
18.14.2
|
|
||||||
|
|
||||||
Platform:
|
|
||||||
win32 x64
|
|
||||||
|
|
||||||
Trace:
|
|
||||||
Error: https://registry.yarnpkg.com/plexjs: Not found
|
|
||||||
at params.callback [as _callback] (C:\Users\Luke\AppData\Roaming\npm\node_modules\yarn\lib\cli.js:66145:18)
|
|
||||||
at self.callback (C:\Users\Luke\AppData\Roaming\npm\node_modules\yarn\lib\cli.js:140890:22)
|
|
||||||
at Request.emit (node:events:513:28)
|
|
||||||
at Request.<anonymous> (C:\Users\Luke\AppData\Roaming\npm\node_modules\yarn\lib\cli.js:141862:10)
|
|
||||||
at Request.emit (node:events:513:28)
|
|
||||||
at IncomingMessage.<anonymous> (C:\Users\Luke\AppData\Roaming\npm\node_modules\yarn\lib\cli.js:141784:12)
|
|
||||||
at Object.onceWrapper (node:events:627:28)
|
|
||||||
at IncomingMessage.emit (node:events:525:35)
|
|
||||||
at endReadableNT (node:internal/streams/readable:1359:12)
|
|
||||||
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
|
|
||||||
|
|
||||||
npm manifest:
|
|
||||||
{
|
|
||||||
"name": "examples",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"description": "Examples using the plexjs package",
|
|
||||||
"main": "index.js",
|
|
||||||
"scripts": {
|
|
||||||
"dev": "npx ts-node index.ts",
|
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
|
||||||
},
|
|
||||||
"author": "lukehagar",
|
|
||||||
"license": "MIT"
|
|
||||||
}
|
|
||||||
|
|
||||||
yarn manifest:
|
|
||||||
No manifest
|
|
||||||
|
|
||||||
Lockfile:
|
|
||||||
No lockfile
|
|
||||||
5402
examples/yarn.lock
5402
examples/yarn.lock
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
|||||||
## plexjs@0.0.13
|
## plexjs@0.0.20
|
||||||
|
|
||||||
This generator creates TypeScript/JavaScript client that utilizes [axios](https://github.com/axios/axios). The generated Node module can be used in the following environments:
|
This generator creates TypeScript/JavaScript client that utilizes [axios](https://github.com/axios/axios). The generated Node module can be used in the following environments:
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ navigate to the folder of your consuming project and run one of the following co
|
|||||||
_published:_
|
_published:_
|
||||||
|
|
||||||
```
|
```
|
||||||
npm install plexjs@0.0.13 --save
|
npm install plexjs@0.0.20 --save
|
||||||
```
|
```
|
||||||
|
|
||||||
_unPublished (not recommended):_
|
_unPublished (not recommended):_
|
||||||
|
|||||||
630
plexjs/api.ts
630
plexjs/api.ts
File diff suppressed because it is too large
Load Diff
@@ -15,13 +15,82 @@
|
|||||||
import { IAxiosRetryConfig } from "axios-retry";
|
import { IAxiosRetryConfig } from "axios-retry";
|
||||||
|
|
||||||
export interface ConfigurationParameters {
|
export interface ConfigurationParameters {
|
||||||
|
plexToken?: string;
|
||||||
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
|
clientIdentifier?: string;
|
||||||
|
device?: string;
|
||||||
|
deviceName?: string;
|
||||||
|
platform?: string;
|
||||||
|
platformVersion?: string;
|
||||||
|
product?: string;
|
||||||
|
version?: string;
|
||||||
basePath?: string;
|
basePath?: string;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Configuration {
|
export class Configuration {
|
||||||
|
/**
|
||||||
|
* Plex Media Server or Plex.TV Authentication token
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof Configuration
|
||||||
|
*/
|
||||||
|
plexToken?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UUID, serial number, or other number unique per device
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof Configuration
|
||||||
|
*/
|
||||||
|
clientIdentifier?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Device name and model number, eg iPhone3,2, Motorola XOOM™, LG5200TV
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof Configuration
|
||||||
|
*/
|
||||||
|
device?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Customized Device Name
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof Configuration
|
||||||
|
*/
|
||||||
|
deviceName?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Platform name, eg iOS, MacOSX, Android, LG, etc
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof Configuration
|
||||||
|
*/
|
||||||
|
platform?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Operating system version, eg 4.3.1, 10.6.7, 3.2
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof Configuration
|
||||||
|
*/
|
||||||
|
platformVersion?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plex application name, eg Laika, Plex Media Server, Media Link
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof Configuration
|
||||||
|
*/
|
||||||
|
product?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plex application version number
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof Configuration
|
||||||
|
*/
|
||||||
|
version?: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* parameter for apiKey security
|
* parameter for apiKey security
|
||||||
* @param name security name
|
* @param name security name
|
||||||
@@ -63,10 +132,42 @@ export class Configuration {
|
|||||||
retriesConfig?: IAxiosRetryConfig
|
retriesConfig?: IAxiosRetryConfig
|
||||||
|
|
||||||
constructor(param: ConfigurationParameters = {}) {
|
constructor(param: ConfigurationParameters = {}) {
|
||||||
|
this.plexToken = param.plexToken;
|
||||||
|
this.clientIdentifier = param.clientIdentifier || "Plexjs";
|
||||||
|
this.device = param.device || "Unspecified";
|
||||||
|
this.deviceName = param.deviceName || "Unspecified";
|
||||||
|
this.platform = param.platform || "Plexjs";
|
||||||
|
this.platformVersion = param.platformVersion || process.env.npm_package_version;
|
||||||
|
this.product = param.product || "Plexjs";
|
||||||
|
this.version = param.version || process.env.npm_package_version;
|
||||||
|
|
||||||
this.apiKey = param.apiKey;
|
this.apiKey = (header: string) => {
|
||||||
|
switch (header) {
|
||||||
|
case "X-Plex-Token":
|
||||||
|
return this.plexToken
|
||||||
|
case "X-Plex-Client-Identifier":
|
||||||
|
return this.clientIdentifier
|
||||||
|
case "X-Plex-Device-Name":
|
||||||
|
return this.deviceName
|
||||||
|
case "X-Plex-Device":
|
||||||
|
return this.device
|
||||||
|
case "X-Plex-Platform-Version":
|
||||||
|
return this.platformVersion
|
||||||
|
case "X-Plex-Platform":
|
||||||
|
return this.platform
|
||||||
|
case "X-Plex-Product":
|
||||||
|
return this.product
|
||||||
|
case "X-Plex-Version":
|
||||||
|
return this.version
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
this.basePath = param.basePath;
|
this.basePath = param.basePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public setAuthToken(token: string) {
|
||||||
|
this.plexToken = token
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -14,5 +14,5 @@
|
|||||||
|
|
||||||
|
|
||||||
export * from "./api";
|
export * from "./api";
|
||||||
export * from "./configuration";
|
export {Configuration, ConfigurationParameters} from "./configuration";
|
||||||
|
|
||||||
|
|||||||
4
plexjs/package-lock.json
generated
4
plexjs/package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@lukehagar/plexjs",
|
"name": "@lukehagar/plexjs",
|
||||||
"version": "0.0.13",
|
"version": "0.0.20",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@lukehagar/plexjs",
|
"name": "@lukehagar/plexjs",
|
||||||
"version": "0.0.13",
|
"version": "0.0.20",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^0.26.1",
|
"axios": "^0.26.1",
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@lukehagar/plexjs",
|
"name": "@lukehagar/plexjs",
|
||||||
"version": "0.0.13",
|
"version": "0.0.20",
|
||||||
"description": "Community Made Plex JS/TS Module",
|
"description": "Community Made Plex JS/TS Module",
|
||||||
"author": "Luke Hagar",
|
"author": "Luke Hagar",
|
||||||
"type": "module",
|
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/LukeHagar/plexjs.git"
|
"url": "https://github.com/LukeHagar/plexjs.git"
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
"target": "ES5",
|
"target": "ES5",
|
||||||
"module": "CommonJS",
|
"module": "CommonJS",
|
||||||
"noImplicitAny": true,
|
"noImplicitAny": true,
|
||||||
"outDir": "./dist",
|
"outDir": "dist",
|
||||||
"rootDir": ".",
|
"rootDir": ".",
|
||||||
"lib": [
|
"lib": [
|
||||||
"es6",
|
"es6",
|
||||||
@@ -12,10 +12,12 @@
|
|||||||
],
|
],
|
||||||
"typeRoots": [
|
"typeRoots": [
|
||||||
"node_modules/@types"
|
"node_modules/@types"
|
||||||
]
|
],
|
||||||
|
"sourceMap": true
|
||||||
},
|
},
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"dist",
|
"dist",
|
||||||
"node_modules"
|
"node_modules",
|
||||||
|
"./dist/**/*"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,13 +4,82 @@
|
|||||||
import { IAxiosRetryConfig } from "axios-retry";
|
import { IAxiosRetryConfig } from "axios-retry";
|
||||||
|
|
||||||
export interface ConfigurationParameters {
|
export interface ConfigurationParameters {
|
||||||
|
plexToken?: string;
|
||||||
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
|
clientIdentifier?: string;
|
||||||
|
device?: string;
|
||||||
|
deviceName?: string;
|
||||||
|
platform?: string;
|
||||||
|
platformVersion?: string;
|
||||||
|
product?: string;
|
||||||
|
version?: string;
|
||||||
basePath?: string;
|
basePath?: string;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Configuration {
|
export class Configuration {
|
||||||
|
/**
|
||||||
|
* Plex Media Server or Plex.TV Authentication token
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof Configuration
|
||||||
|
*/
|
||||||
|
plexToken?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UUID, serial number, or other number unique per device
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof Configuration
|
||||||
|
*/
|
||||||
|
clientIdentifier?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Device name and model number, eg iPhone3,2, Motorola XOOM™, LG5200TV
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof Configuration
|
||||||
|
*/
|
||||||
|
device?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Customized Device Name
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof Configuration
|
||||||
|
*/
|
||||||
|
deviceName?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Platform name, eg iOS, MacOSX, Android, LG, etc
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof Configuration
|
||||||
|
*/
|
||||||
|
platform?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Operating system version, eg 4.3.1, 10.6.7, 3.2
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof Configuration
|
||||||
|
*/
|
||||||
|
platformVersion?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plex application name, eg Laika, Plex Media Server, Media Link
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof Configuration
|
||||||
|
*/
|
||||||
|
product?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plex application version number
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof Configuration
|
||||||
|
*/
|
||||||
|
version?: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* parameter for apiKey security
|
* parameter for apiKey security
|
||||||
* @param name security name
|
* @param name security name
|
||||||
@@ -52,10 +121,42 @@ export class Configuration {
|
|||||||
retriesConfig?: IAxiosRetryConfig
|
retriesConfig?: IAxiosRetryConfig
|
||||||
|
|
||||||
constructor(param: ConfigurationParameters = {}) {
|
constructor(param: ConfigurationParameters = {}) {
|
||||||
|
this.plexToken = param.plexToken;
|
||||||
|
this.clientIdentifier = param.clientIdentifier || "Plexjs";
|
||||||
|
this.device = param.device || "Unspecified";
|
||||||
|
this.deviceName = param.deviceName || "Unspecified";
|
||||||
|
this.platform = param.platform || "Plexjs";
|
||||||
|
this.platformVersion = param.platformVersion || process.env.npm_package_version;
|
||||||
|
this.product = param.product || "Plexjs";
|
||||||
|
this.version = param.version || process.env.npm_package_version;
|
||||||
|
|
||||||
this.apiKey = param.apiKey;
|
this.apiKey = (header: string) => {
|
||||||
|
switch (header) {
|
||||||
|
case "X-Plex-Token":
|
||||||
|
return this.plexToken
|
||||||
|
case "X-Plex-Client-Identifier":
|
||||||
|
return this.clientIdentifier
|
||||||
|
case "X-Plex-Device-Name":
|
||||||
|
return this.deviceName
|
||||||
|
case "X-Plex-Device":
|
||||||
|
return this.device
|
||||||
|
case "X-Plex-Platform-Version":
|
||||||
|
return this.platformVersion
|
||||||
|
case "X-Plex-Platform":
|
||||||
|
return this.platform
|
||||||
|
case "X-Plex-Product":
|
||||||
|
return this.product
|
||||||
|
case "X-Plex-Version":
|
||||||
|
return this.version
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
this.basePath = param.basePath;
|
this.basePath = param.basePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public setAuthToken(token: string) {
|
||||||
|
this.plexToken = token
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3,5 +3,5 @@
|
|||||||
{{>licenseInfo}}
|
{{>licenseInfo}}
|
||||||
|
|
||||||
export * from "./api";
|
export * from "./api";
|
||||||
export * from "./configuration";
|
export {Configuration, ConfigurationParameters} from "./configuration";
|
||||||
{{#withSeparateModelsAndApi}}export * from "./{{tsModelPackage}}";{{/withSeparateModelsAndApi}}
|
{{#withSeparateModelsAndApi}}export * from "./{{tsModelPackage}}";{{/withSeparateModelsAndApi}}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
"version": "{{npmVersion}}",
|
"version": "{{npmVersion}}",
|
||||||
"description": "Community Made Plex JS/TS Module",
|
"description": "Community Made Plex JS/TS Module",
|
||||||
"author": "Luke Hagar",
|
"author": "Luke Hagar",
|
||||||
"type": "module",
|
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/LukeHagar/plexjs.git"
|
"url": "https://github.com/LukeHagar/plexjs.git"
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
"target": "{{#supportsES6}}ES6{{/supportsES6}}{{^supportsES6}}ES5{{/supportsES6}}",
|
"target": "{{#supportsES6}}ES6{{/supportsES6}}{{^supportsES6}}ES5{{/supportsES6}}",
|
||||||
"module": "{{#supportsES6}}ES6{{/supportsES6}}{{^supportsES6}}CommonJS{{/supportsES6}}",
|
"module": "{{#supportsES6}}ES6{{/supportsES6}}{{^supportsES6}}CommonJS{{/supportsES6}}",
|
||||||
"noImplicitAny": true,
|
"noImplicitAny": true,
|
||||||
"outDir": "./dist",
|
"outDir": "dist",
|
||||||
"rootDir": ".",
|
"rootDir": ".",
|
||||||
{{^supportsES6}}
|
{{^supportsES6}}
|
||||||
"lib": [
|
"lib": [
|
||||||
@@ -14,10 +14,12 @@
|
|||||||
{{/supportsES6}}
|
{{/supportsES6}}
|
||||||
"typeRoots": [
|
"typeRoots": [
|
||||||
"node_modules/@types"
|
"node_modules/@types"
|
||||||
]
|
],
|
||||||
|
"sourceMap": true
|
||||||
},
|
},
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"dist",
|
"dist",
|
||||||
"node_modules"
|
"node_modules",
|
||||||
|
"./dist/**/*"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user