mirror of
https://github.com/LukeHagar/plexjs.git
synced 2025-12-06 20:47:46 +00:00
Compare commits
86 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b07bac6999 | ||
|
|
dcddc72b18 | ||
|
|
591d498f7c | ||
|
|
b1b902eac3 | ||
|
|
ad603e2e66 | ||
|
|
e8423d9480 | ||
|
|
8783e65fd0 | ||
|
|
3a402640e1 | ||
|
|
387996f522 | ||
|
|
6589fbdcd1 | ||
|
|
97586f1313 | ||
|
|
041ff8984a | ||
|
|
925dd2419e | ||
|
|
3df6241d0b | ||
|
|
2178a02b6d | ||
|
|
c170ec368b | ||
|
|
f1f692b8c7 | ||
|
|
690a61d9c2 | ||
|
|
e1c8c15d05 | ||
|
|
c80882f3f7 | ||
|
|
1d2ad047bd | ||
|
|
bc1c4c63ec | ||
|
|
0eb55c9ca6 | ||
|
|
d5eaadc4dc | ||
|
|
eb0fd03f0d | ||
|
|
5dad6a62c6 | ||
|
|
3db513ac7d | ||
|
|
fe8f8f571b | ||
|
|
e65a0f1719 | ||
|
|
29ea6c0d75 | ||
|
|
c5d773bf41 | ||
|
|
35cf322f7b | ||
|
|
1d03f750b9 | ||
|
|
00eaf93095 | ||
|
|
d3a82b8467 | ||
|
|
85ce11cadc | ||
|
|
1b4f9dbf96 | ||
|
|
2f0a7b96d4 | ||
|
|
fa3519f1bb | ||
|
|
8afc3f323d | ||
|
|
7fd2b4ceda | ||
|
|
87bb486f1f | ||
|
|
18c735a920 | ||
|
|
331618b77a | ||
|
|
5f601ecf65 | ||
|
|
8eeef06c9c | ||
|
|
bc9335abcf | ||
|
|
792fedc759 | ||
|
|
e343455e77 | ||
|
|
7a7931b0d0 | ||
|
|
b3c26fd1a7 | ||
|
|
26fa0aef86 | ||
|
|
74ecefac8b | ||
|
|
8855195c09 | ||
|
|
227636620e | ||
|
|
5866739942 | ||
|
|
0eacb0e7c4 | ||
|
|
c0efb9a732 | ||
|
|
71484de76e | ||
|
|
be73efff0b | ||
|
|
a00c394526 | ||
|
|
3d57b22b26 | ||
|
|
995bbedbb6 | ||
|
|
d638acb5d2 | ||
|
|
f87006d3e8 | ||
|
|
fcab6f2532 | ||
|
|
4c552faaf5 | ||
|
|
7ea8776750 | ||
|
|
b9487a78df | ||
|
|
4addcb43e0 | ||
|
|
05444f54ad | ||
|
|
a7139cc510 | ||
|
|
ddbf96d1d1 | ||
|
|
a40e1f6ee9 | ||
|
|
b37ec6d21e | ||
|
|
b868a95db1 | ||
|
|
7d18553ff0 | ||
|
|
e83d09070a | ||
|
|
0794b8457e | ||
|
|
c6ba56222a | ||
|
|
e8f38b8d0a | ||
|
|
898fa0212d | ||
|
|
67a632bbc2 | ||
|
|
19c72dd7d3 | ||
|
|
f4e18606ce | ||
|
|
dfb04b01ca |
60
.github/workflows/bump_version.yml
vendored
60
.github/workflows/bump_version.yml
vendored
@@ -1,5 +1,7 @@
|
||||
name: "Update Typescript SDK Version"
|
||||
|
||||
run-name: Update Typescript SDK Version to ${{ github.event.inputs.version }}
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
@@ -53,22 +55,46 @@ jobs:
|
||||
- name: Update config files with new version
|
||||
id: updateVersion
|
||||
run: |
|
||||
yq -i '.npmVersion = "${{ github.event.inputs.version }}"' config.yaml
|
||||
yq -i '.npmVersion = "${{ github.event.inputs.version }}"' sdk-resources/pms-config.yaml
|
||||
yq -i '.npmVersion = "${{ github.event.inputs.version }}"' sdk-resources/plextv-config.yaml
|
||||
|
||||
- name: Build TS SDK
|
||||
id: buildTS
|
||||
## Update package.json file with new version
|
||||
- name: Update package.json version
|
||||
id: updatePackageJsonVersion
|
||||
if: steps.updateVersion.outcome == 'success'
|
||||
run: |
|
||||
rm -rf plexjs/
|
||||
java -jar openapi-generator-cli.jar generate -i api-specs/referenced/plex-api-spec.yaml -g typescript-axios -o plexjs/ --global-property skipFormModel=false --config config.yaml
|
||||
LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`)
|
||||
cd plexjs
|
||||
jq '.version = "${{ github.event.inputs.version }}"' package.json > package.json.tmp && mv package.json.tmp package.json
|
||||
|
||||
- name: Build PMS SDK
|
||||
id: buildPMS
|
||||
run: |
|
||||
rm -rf plexjs/pms
|
||||
java -jar openapi-generator-cli.jar generate -i api-specs/pms/pms-spec.yaml -g typescript-axios -o plexjs/pms --global-property skipFormModel=false --config sdk-resources/pms-config.yaml
|
||||
|
||||
- name: Build PTV SDK
|
||||
id: buildPTV
|
||||
if: steps.buildPMS.outcome == 'success'
|
||||
run: |
|
||||
rm -rf plexjs/plextv
|
||||
java -jar openapi-generator-cli.jar generate -i api-specs/plextv/plextv-spec.yaml -g typescript-axios -o plexjs/plextv --global-property skipFormModel=false --config sdk-resources/plextv-config.yaml
|
||||
|
||||
- name: After SDK Build
|
||||
id: buildSDK
|
||||
if: steps.buildTS.outcome == 'success'
|
||||
if: steps.buildPTV.outcome == 'success'
|
||||
run: |
|
||||
cd plexjs
|
||||
npm install
|
||||
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
|
||||
if: steps.buildSDK.outcome == 'success'
|
||||
uses: stefanzweifel/git-auto-commit-action@v4
|
||||
@@ -76,10 +102,6 @@ jobs:
|
||||
commit_message: Bump version to ${{ github.event.inputs.version }}
|
||||
tagging_message: ${{ github.event.inputs.version }}
|
||||
|
||||
release:
|
||||
name: Release Typescript SDK
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Create Release
|
||||
id: create_release
|
||||
uses: actions/create-release@v1
|
||||
@@ -90,21 +112,3 @@ jobs:
|
||||
release_name: ${{ github.event.inputs.version }}
|
||||
draft: false
|
||||
prerelease: false
|
||||
|
||||
publish:
|
||||
name: Publish Typescript SDK
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- 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
|
||||
|
||||
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
|
||||
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"
|
||||
}
|
||||
17353
examples/package-lock.json
generated
Normal file
17353
examples/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,15 +1,31 @@
|
||||
{
|
||||
"name": "examples",
|
||||
"name": "typescript-starter",
|
||||
"version": "1.0.0",
|
||||
"description": "Examples using the plexjs package",
|
||||
"description": "A basic typescript app starter for 2023.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"dev": "npx ts-node index.ts",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
"build": "rimraf ./build && tsc",
|
||||
"dev": "npx nodemon",
|
||||
"start": "npm run build && node build/index.js"
|
||||
},
|
||||
"author": "lukehagar",
|
||||
"license": "MIT",
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"@lukehagar/plexjs": "^0.0.7"
|
||||
"@lukehagar/plexjs": "^0.0.27",
|
||||
"@types/jest": "^29.5.3",
|
||||
"@types/node": "^20.4.2",
|
||||
"@typescript-eslint/eslint-plugin": "^6.1.0",
|
||||
"@typescript-eslint/parser": "^6.1.0",
|
||||
"dotenv": "^16.3.1",
|
||||
"nodemon": "^3.0.1",
|
||||
"onchange": "^7.1.0",
|
||||
"rimraf": "^5.0.1",
|
||||
"run-script-os": "^1.1.6",
|
||||
"ts-node": "^10.9.1",
|
||||
"typescript": "^5.1.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"jest-cucumber": "^3.0.1"
|
||||
}
|
||||
}
|
||||
|
||||
14
examples/src/index.ts
Normal file
14
examples/src/index.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { Configuration, ServerApi, PlexTvApi } from "@lukehagar/plexjs";
|
||||
import dotenv from "dotenv";
|
||||
dotenv.config();
|
||||
|
||||
const config = new Configuration({
|
||||
basePath: process.env.BASE_PATH,
|
||||
plexToken: process.env.PLEX_TOKEN,
|
||||
});
|
||||
|
||||
new ServerApi(config).getServerCapabilities().then((resp) => console.log(resp));
|
||||
|
||||
new PlexTvApi(config).getDevices().then((resp) => console.log(resp));
|
||||
|
||||
new PlexTvApi(config).getUserDetails().then((resp) => console.log(resp));
|
||||
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
|
||||
4351
examples/yarn.lock
4351
examples/yarn.lock
File diff suppressed because it is too large
Load Diff
@@ -1,45 +1,49 @@
|
||||
## plexjs@0.0.12
|
||||
# Plex API Client
|
||||
|
||||
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:
|
||||
[](https://discord.gg/HQTPSJnWhb)
|
||||
[](https://npmjs.com/package/@lukehagar/plexjs)
|
||||
[](https://GitHub.com/LukeHagar/plexjs/tags/)
|
||||
|
||||
Environment
|
||||
* Node.js
|
||||
* Webpack
|
||||
* Browserify
|
||||
## Description
|
||||
|
||||
Language level
|
||||
* ES5 - you must have a Promises/A+ library installed
|
||||
* ES6
|
||||
|
||||
Module system
|
||||
* CommonJS
|
||||
* ES6 module system
|
||||
|
||||
It can be used in both TypeScript and JavaScript. In TypeScript, the definition should be automatically resolved via `package.json`. ([Reference](http://www.typescriptlang.org/docs/handbook/typings-for-npm-packages.html))
|
||||
A typescript sdk for interacting with Plex.tv and Plex Media Server REST API's.
|
||||
|
||||
### Building
|
||||
Documentation for all of the available endpoints [can be found here](https://plexapi.dev/docs/plex)
|
||||
|
||||
To build and compile the typescript sources to javascript use:
|
||||
```
|
||||
npm install
|
||||
npm run build
|
||||
## Installation
|
||||
|
||||
npm
|
||||
```bash
|
||||
npm install @lukehagar/plexjs
|
||||
```
|
||||
|
||||
### Publishing
|
||||
|
||||
First build the package then run ```npm publish```
|
||||
|
||||
### Consuming
|
||||
|
||||
navigate to the folder of your consuming project and run one of the following commands.
|
||||
|
||||
_published:_
|
||||
|
||||
```
|
||||
npm install plexjs@0.0.12 --save
|
||||
yarn
|
||||
```bash
|
||||
yarn add @lukehagar/plexjs
|
||||
```
|
||||
|
||||
_unPublished (not recommended):_
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
import {
|
||||
Configuration,
|
||||
ServerApi,
|
||||
DevicesApi,
|
||||
UserApi,
|
||||
} from "@lukehagar/plexjs";
|
||||
import dotenv from "dotenv";
|
||||
dotenv.config();
|
||||
|
||||
const config = new Configuration({
|
||||
basePath: process.env.BASE_PATH,
|
||||
plexToken: process.env.PLEX_TOKEN,
|
||||
});
|
||||
|
||||
new ServerApi(config).getServerCapabilities().then((resp) => console.log(resp));
|
||||
|
||||
new DevicesApi(config).getDevices().then((resp) => console.log(resp));
|
||||
|
||||
new UserApi(config).getUserDetails().then((resp) => console.log(resp));
|
||||
```
|
||||
npm install PATH_TO_GENERATED_PACKAGE --save
|
||||
|
||||
@@ -14,14 +14,83 @@
|
||||
|
||||
import { IAxiosRetryConfig } from "axios-retry";
|
||||
|
||||
export interface ConfigurationParameters {
|
||||
|
||||
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
|
||||
export type ConfigurationParameters = {
|
||||
plexToken?: string;
|
||||
clientIdentifier?: string;
|
||||
device?: string;
|
||||
deviceName?: string;
|
||||
platform?: string;
|
||||
platformVersion?: string;
|
||||
product?: string;
|
||||
version?: string;
|
||||
basePath?: string;
|
||||
|
||||
}
|
||||
|
||||
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
|
||||
* @param name security name
|
||||
@@ -63,10 +132,42 @@ export class Configuration {
|
||||
retriesConfig?: IAxiosRetryConfig
|
||||
|
||||
constructor(param: ConfigurationParameters = {}) {
|
||||
this.plexToken = param.plexToken || "";
|
||||
this.clientIdentifier = param.clientIdentifier || "plexjs";
|
||||
this.device = param.device || "plexjs";
|
||||
this.deviceName = param.deviceName || "plexjs";
|
||||
this.platform = param.platform || "plexjs";
|
||||
this.platformVersion = param.platformVersion || "0.0.22";
|
||||
this.product = param.product || "plexjs";
|
||||
this.version = param.version || "0.0.22";
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public setAuthToken(token: string) {
|
||||
this.plexToken = token
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
export * from "./api";
|
||||
export * from "./configuration";
|
||||
|
||||
export * from "./plextv/api";
|
||||
export * from "./pms/api";
|
||||
export { Configuration, ConfigurationParameters } from "./configuration";
|
||||
|
||||
72
plexjs/package-lock.json
generated
72
plexjs/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@lukehagar/plexjs",
|
||||
"version": "0.0.12",
|
||||
"lockfileVersion": 2,
|
||||
"version": "0.0.29",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@lukehagar/plexjs",
|
||||
"version": "0.0.12",
|
||||
"version": "0.0.29",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"axios": "^0.26.1",
|
||||
@@ -18,9 +18,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@babel/runtime": {
|
||||
"version": "7.21.0",
|
||||
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.21.0.tgz",
|
||||
"integrity": "sha512-xwII0//EObnq89Ji5AKYQaRYiW/nZ3llSv29d49IuxPhKbtJoLP+9QUUZ4nVragQVtaVGeZrpB+ZtG/Pdy/POw==",
|
||||
"version": "7.22.6",
|
||||
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.22.6.tgz",
|
||||
"integrity": "sha512-wDb5pWm4WDdF6LFUde3Jl8WzPA+3ZbxYqkC6xAXuD3irdEHN1k0NfTRrJD8ZD378SJ61miMLCqIOXYhd8x+AJQ==",
|
||||
"dependencies": {
|
||||
"regenerator-runtime": "^0.13.11"
|
||||
},
|
||||
@@ -43,9 +43,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/axios-retry": {
|
||||
"version": "3.4.0",
|
||||
"resolved": "https://registry.npmjs.org/axios-retry/-/axios-retry-3.4.0.tgz",
|
||||
"integrity": "sha512-VdgaP+gHH4iQYCCNUWF2pcqeciVOdGrBBAYUfTY+wPcO5Ltvp/37MLFNCmJKo7Gj3SHvCSdL8ouI1qLYJN3liA==",
|
||||
"version": "3.5.1",
|
||||
"resolved": "https://registry.npmjs.org/axios-retry/-/axios-retry-3.5.1.tgz",
|
||||
"integrity": "sha512-mQRJ4IyAUnYig14BQ4MnnNHHuH1cNH7NW4JxEUD6mNJwK6pwOY66wKLCwZ6Y0o3POpfStalqRC+J4+Hnn6Om7w==",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.15.4",
|
||||
"is-retry-allowed": "^2.2.0"
|
||||
@@ -99,59 +99,5 @@
|
||||
"node": ">=4.2.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime": {
|
||||
"version": "7.21.0",
|
||||
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.21.0.tgz",
|
||||
"integrity": "sha512-xwII0//EObnq89Ji5AKYQaRYiW/nZ3llSv29d49IuxPhKbtJoLP+9QUUZ4nVragQVtaVGeZrpB+ZtG/Pdy/POw==",
|
||||
"requires": {
|
||||
"regenerator-runtime": "^0.13.11"
|
||||
}
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "12.20.55",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.55.tgz",
|
||||
"integrity": "sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==",
|
||||
"dev": true
|
||||
},
|
||||
"axios": {
|
||||
"version": "0.26.1",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-0.26.1.tgz",
|
||||
"integrity": "sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==",
|
||||
"requires": {
|
||||
"follow-redirects": "^1.14.8"
|
||||
}
|
||||
},
|
||||
"axios-retry": {
|
||||
"version": "3.4.0",
|
||||
"resolved": "https://registry.npmjs.org/axios-retry/-/axios-retry-3.4.0.tgz",
|
||||
"integrity": "sha512-VdgaP+gHH4iQYCCNUWF2pcqeciVOdGrBBAYUfTY+wPcO5Ltvp/37MLFNCmJKo7Gj3SHvCSdL8ouI1qLYJN3liA==",
|
||||
"requires": {
|
||||
"@babel/runtime": "^7.15.4",
|
||||
"is-retry-allowed": "^2.2.0"
|
||||
}
|
||||
},
|
||||
"follow-redirects": {
|
||||
"version": "1.15.2",
|
||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz",
|
||||
"integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA=="
|
||||
},
|
||||
"is-retry-allowed": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/is-retry-allowed/-/is-retry-allowed-2.2.0.tgz",
|
||||
"integrity": "sha512-XVm7LOeLpTW4jV19QSH38vkswxoLud8sQ57YwJVTPWdiaI9I8keEhGFpBlslyVsgdQy4Opg8QOLb8YRgsyZiQg=="
|
||||
},
|
||||
"regenerator-runtime": {
|
||||
"version": "0.13.11",
|
||||
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz",
|
||||
"integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg=="
|
||||
},
|
||||
"typescript": {
|
||||
"version": "4.9.5",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz",
|
||||
"integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
{
|
||||
"name": "@lukehagar/plexjs",
|
||||
"version": "0.0.12",
|
||||
"version": "0.0.29",
|
||||
"description": "Community Made Plex JS/TS Module",
|
||||
"author": "Luke Hagar",
|
||||
"type": "module",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/LukeHagar/plexjs.git"
|
||||
|
||||
23
plexjs/plextv/.openapi-generator-ignore
Normal file
23
plexjs/plextv/.openapi-generator-ignore
Normal file
@@ -0,0 +1,23 @@
|
||||
# OpenAPI Generator Ignore
|
||||
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
|
||||
|
||||
# Use this file to prevent files from being overwritten by the generator.
|
||||
# The patterns follow closely to .gitignore or .dockerignore.
|
||||
|
||||
# As an example, the C# client generator defines ApiClient.cs.
|
||||
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
|
||||
#ApiClient.cs
|
||||
|
||||
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||
#foo/*/qux
|
||||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||
|
||||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||
#foo/**/qux
|
||||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||
|
||||
# You can also negate patterns with an exclamation (!).
|
||||
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||
#docs/*.md
|
||||
# Then explicitly reverse the ignore rule for a single file:
|
||||
#!docs/README.md
|
||||
12
plexjs/plextv/.openapi-generator/FILES
Normal file
12
plexjs/plextv/.openapi-generator/FILES
Normal file
@@ -0,0 +1,12 @@
|
||||
.gitignore
|
||||
.npmignore
|
||||
.openapi-generator-ignore
|
||||
README.md
|
||||
api.ts
|
||||
base.ts
|
||||
common.ts
|
||||
configuration.ts
|
||||
git_push.sh
|
||||
index.ts
|
||||
package.json
|
||||
tsconfig.json
|
||||
1
plexjs/plextv/.openapi-generator/VERSION
Normal file
1
plexjs/plextv/.openapi-generator/VERSION
Normal file
@@ -0,0 +1 @@
|
||||
6.3.0
|
||||
45
plexjs/plextv/README.md
Normal file
45
plexjs/plextv/README.md
Normal file
@@ -0,0 +1,45 @@
|
||||
## plexjs@0.0.29
|
||||
|
||||
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:
|
||||
|
||||
Environment
|
||||
* Node.js
|
||||
* Webpack
|
||||
* Browserify
|
||||
|
||||
Language level
|
||||
* ES5 - you must have a Promises/A+ library installed
|
||||
* ES6
|
||||
|
||||
Module system
|
||||
* CommonJS
|
||||
* ES6 module system
|
||||
|
||||
It can be used in both TypeScript and JavaScript. In TypeScript, the definition should be automatically resolved via `package.json`. ([Reference](http://www.typescriptlang.org/docs/handbook/typings-for-npm-packages.html))
|
||||
|
||||
### Building
|
||||
|
||||
To build and compile the typescript sources to javascript use:
|
||||
```
|
||||
npm install
|
||||
npm run build
|
||||
```
|
||||
|
||||
### Publishing
|
||||
|
||||
First build the package then run ```npm publish```
|
||||
|
||||
### Consuming
|
||||
|
||||
navigate to the folder of your consuming project and run one of the following commands.
|
||||
|
||||
_published:_
|
||||
|
||||
```
|
||||
npm install plexjs@0.0.29 --save
|
||||
```
|
||||
|
||||
_unPublished (not recommended):_
|
||||
|
||||
```
|
||||
npm install PATH_TO_GENERATED_PACKAGE --save
|
||||
1127
plexjs/plextv/api.ts
Normal file
1127
plexjs/plextv/api.ts
Normal file
File diff suppressed because it is too large
Load Diff
71
plexjs/plextv/base.ts
Normal file
71
plexjs/plextv/base.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* Plex-API
|
||||
* An Open API Spec for interacting with Plex.tv
|
||||
*
|
||||
* The version of the OpenAPI document: 0.0.3
|
||||
* Contact: Lukeslakemail@gmail.com
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
import { Configuration } from "./configuration";
|
||||
// Some imports not used depending on template conditions
|
||||
// @ts-ignore
|
||||
import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios';
|
||||
|
||||
export const BASE_PATH = "https://plex.tv/api/v2".replace(/\/+$/, "");
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
*/
|
||||
export const COLLECTION_FORMATS = {
|
||||
csv: ",",
|
||||
ssv: " ",
|
||||
tsv: "\t",
|
||||
pipes: "|",
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
* @interface RequestArgs
|
||||
*/
|
||||
export interface RequestArgs {
|
||||
url: string;
|
||||
axiosOptions: AxiosRequestConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
* @class BaseAPI
|
||||
*/
|
||||
export class BaseAPI {
|
||||
protected configuration: Configuration | undefined;
|
||||
|
||||
constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) {
|
||||
if (configuration) {
|
||||
this.configuration = configuration;
|
||||
this.basePath = "https://plex.tv/api/v2" || this.basePath;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
* @class RequiredError
|
||||
* @extends {Error}
|
||||
*/
|
||||
export class RequiredError extends Error {
|
||||
name: "RequiredError" = "RequiredError";
|
||||
constructor(public field: string, msg?: string) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
105
plexjs/plextv/common.ts
Normal file
105
plexjs/plextv/common.ts
Normal file
@@ -0,0 +1,105 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* Plex-API
|
||||
* An Open API Spec for interacting with Plex.tv
|
||||
*
|
||||
* The version of the OpenAPI document: 0.0.3
|
||||
* Contact: Lukeslakemail@gmail.com
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
import { Configuration } from "./configuration";
|
||||
import { RequiredError, RequestArgs } from "./base";
|
||||
import { AxiosInstance, AxiosResponse } from 'axios';
|
||||
import axiosRetry from "axios-retry";
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
*/
|
||||
export const DUMMY_BASE_URL = 'https://example.com'
|
||||
|
||||
/**
|
||||
*
|
||||
* @throws {RequiredError}
|
||||
* @export
|
||||
*/
|
||||
export const assertParamExists = function (functionName: string, paramName: string, paramValue: unknown) {
|
||||
if (paramValue === null || paramValue === undefined) {
|
||||
throw new RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
*/
|
||||
export const setApiKeyToObject = async function (object: any, keyParamName: string, configuration?: Configuration) {
|
||||
if (configuration && configuration.apiKey) {
|
||||
const localVarApiKeyValue = typeof configuration.apiKey === 'function'
|
||||
? await configuration.apiKey(keyParamName)
|
||||
: await configuration.apiKey;
|
||||
object[keyParamName] = localVarApiKeyValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
*/
|
||||
export const setSearchParams = function (url: URL, ...objects: any[]) {
|
||||
const searchParams = new URLSearchParams(url.search);
|
||||
for (const object of objects) {
|
||||
for (const key in object) {
|
||||
if (Array.isArray(object[key])) {
|
||||
searchParams.delete(key);
|
||||
for (const item of object[key]) {
|
||||
searchParams.append(key, item);
|
||||
}
|
||||
} else {
|
||||
searchParams.set(key, object[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
url.search = searchParams.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
*/
|
||||
export const serializeDataIfNeeded = function (value: any, requestOptions: any, configuration?: Configuration) {
|
||||
const nonString = typeof value !== 'string';
|
||||
const needsSerialization = nonString && configuration && configuration.isJsonMime
|
||||
? configuration.isJsonMime(requestOptions.headers['Content-Type'])
|
||||
: nonString;
|
||||
return needsSerialization
|
||||
? JSON.stringify(value !== undefined ? value : {})
|
||||
: (value || "");
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
*/
|
||||
export const toPathString = function (url: URL) {
|
||||
return url.pathname + url.search + url.hash
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
*/
|
||||
export const createRequestFunction = function (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) {
|
||||
return <T = unknown, R = AxiosResponse<T>>(axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
|
||||
axiosRetry(globalAxios, configuration.retriesConfig)
|
||||
const axiosRequestArgs = {...axiosArgs.axiosOptions, url: (configuration?.basePath || basePath) + axiosArgs.url};
|
||||
return axios.request<T, R>(axiosRequestArgs);
|
||||
};
|
||||
}
|
||||
187
plexjs/plextv/configuration.ts
Normal file
187
plexjs/plextv/configuration.ts
Normal file
@@ -0,0 +1,187 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* Plex-API
|
||||
* An Open API Spec for interacting with Plex.tv
|
||||
*
|
||||
* The version of the OpenAPI document: 0.0.3
|
||||
* Contact: Lukeslakemail@gmail.com
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
import { IAxiosRetryConfig } from "axios-retry";
|
||||
|
||||
export type ConfigurationParameters = {
|
||||
plexToken?: string;
|
||||
clientIdentifier?: string;
|
||||
device?: string;
|
||||
deviceName?: string;
|
||||
platform?: string;
|
||||
platformVersion?: string;
|
||||
product?: string;
|
||||
version?: string;
|
||||
basePath?: string;
|
||||
}
|
||||
|
||||
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
|
||||
* @param name security name
|
||||
* @memberof Configuration
|
||||
*/
|
||||
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
|
||||
|
||||
/**
|
||||
* override base path
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
basePath?: string;
|
||||
|
||||
/**
|
||||
* base options for axios calls
|
||||
*
|
||||
* @type {any}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
baseOptions?: any;
|
||||
|
||||
/**
|
||||
* The FormData constructor that will be used to create multipart form data
|
||||
* requests. You can inject this here so that execution environments that
|
||||
* do not support the FormData class can still run the generated client.
|
||||
*
|
||||
* @type {new () => FormData}
|
||||
*/
|
||||
formDataCtor?: new () => any;
|
||||
|
||||
/**
|
||||
* axios retry configuration
|
||||
*
|
||||
* @type {IAxiosRetryConfig}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
retriesConfig?: IAxiosRetryConfig
|
||||
|
||||
constructor(param: ConfigurationParameters = {}) {
|
||||
this.plexToken = param.plexToken || "";
|
||||
this.clientIdentifier = param.clientIdentifier || "plexjs";
|
||||
this.device = param.device || "plexjs";
|
||||
this.deviceName = param.deviceName || "plexjs";
|
||||
this.platform = param.platform || "plexjs";
|
||||
this.platformVersion = param.platformVersion || "0.0.29";
|
||||
this.product = param.product || "plexjs";
|
||||
this.version = param.version || "0.0.29";
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public setAuthToken(token: string) {
|
||||
this.plexToken = token
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given MIME is a JSON MIME.
|
||||
* JSON MIME examples:
|
||||
* application/json
|
||||
* application/json; charset=UTF8
|
||||
* APPLICATION/JSON
|
||||
* application/vnd.company+json
|
||||
* @param mime - MIME (Multipurpose Internet Mail Extensions)
|
||||
* @return True if the given MIME is JSON, false otherwise.
|
||||
*/
|
||||
public isJsonMime(mime: string): boolean {
|
||||
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
|
||||
return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
|
||||
}
|
||||
}
|
||||
57
plexjs/plextv/git_push.sh
Normal file
57
plexjs/plextv/git_push.sh
Normal file
@@ -0,0 +1,57 @@
|
||||
#!/bin/sh
|
||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||
#
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com"
|
||||
|
||||
git_user_id=$1
|
||||
git_repo_id=$2
|
||||
release_note=$3
|
||||
git_host=$4
|
||||
|
||||
if [ "$git_host" = "" ]; then
|
||||
git_host="github.com"
|
||||
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
|
||||
fi
|
||||
|
||||
if [ "$git_user_id" = "" ]; then
|
||||
git_user_id="GIT_USER_ID"
|
||||
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
|
||||
fi
|
||||
|
||||
if [ "$git_repo_id" = "" ]; then
|
||||
git_repo_id="GIT_REPO_ID"
|
||||
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
|
||||
fi
|
||||
|
||||
if [ "$release_note" = "" ]; then
|
||||
release_note="Minor update"
|
||||
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
|
||||
fi
|
||||
|
||||
# Initialize the local directory as a Git repository
|
||||
git init
|
||||
|
||||
# Adds the files in the local repository and stages them for commit.
|
||||
git add .
|
||||
|
||||
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
||||
git commit -m "$release_note"
|
||||
|
||||
# Sets the new remote
|
||||
git_remote=$(git remote)
|
||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||
|
||||
if [ "$GIT_TOKEN" = "" ]; then
|
||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
else
|
||||
git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
git pull origin master
|
||||
|
||||
# Pushes (Forces) the changes in the local repository up to the remote repository
|
||||
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
|
||||
git push origin master 2>&1 | grep -v 'To https'
|
||||
18
plexjs/plextv/index.ts
Normal file
18
plexjs/plextv/index.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* Plex-API
|
||||
* An Open API Spec for interacting with Plex.tv
|
||||
*
|
||||
* The version of the OpenAPI document: 0.0.3
|
||||
* Contact: Lukeslakemail@gmail.com
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
export * from "./api";
|
||||
export {Configuration, ConfigurationParameters} from "./configuration";
|
||||
|
||||
38
plexjs/plextv/package.json
Normal file
38
plexjs/plextv/package.json
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"name": "@lukehagar/plexjs",
|
||||
"version": "0.0.29",
|
||||
"description": "Community Made Plex JS/TS Module",
|
||||
"author": "Luke Hagar",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/LukeHagar/plexjs.git"
|
||||
},
|
||||
"keywords": [
|
||||
"axios",
|
||||
"typescript",
|
||||
"openapi",
|
||||
"api",
|
||||
"plex",
|
||||
"plex media server",
|
||||
"pms",
|
||||
"plexjs"
|
||||
],
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/LukeHagar/plexjs/issues"
|
||||
},
|
||||
"main": "./dist/index.js",
|
||||
"typings": "./dist/index.d.ts",
|
||||
"scripts": {
|
||||
"build": "tsc --outDir ./dist",
|
||||
"prepare": "npm run build"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^0.26.1",
|
||||
"axios-retry": "^3.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^12.11.5",
|
||||
"typescript": "^4.0"
|
||||
}
|
||||
}
|
||||
23
plexjs/plextv/tsconfig.json
Normal file
23
plexjs/plextv/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"target": "ES5",
|
||||
"module": "CommonJS",
|
||||
"noImplicitAny": true,
|
||||
"outDir": "dist",
|
||||
"rootDir": ".",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"typeRoots": [
|
||||
"node_modules/@types"
|
||||
],
|
||||
"sourceMap": true
|
||||
},
|
||||
"exclude": [
|
||||
"dist",
|
||||
"node_modules",
|
||||
"./dist/**/*"
|
||||
]
|
||||
}
|
||||
4
plexjs/pms/.gitignore
vendored
Normal file
4
plexjs/pms/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
wwwroot/*.js
|
||||
node_modules
|
||||
typings
|
||||
dist
|
||||
1
plexjs/pms/.npmignore
Normal file
1
plexjs/pms/.npmignore
Normal file
@@ -0,0 +1 @@
|
||||
# empty npmignore to ensure all required files (e.g., in the dist folder) are published by npm
|
||||
23
plexjs/pms/.openapi-generator-ignore
Normal file
23
plexjs/pms/.openapi-generator-ignore
Normal file
@@ -0,0 +1,23 @@
|
||||
# OpenAPI Generator Ignore
|
||||
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
|
||||
|
||||
# Use this file to prevent files from being overwritten by the generator.
|
||||
# The patterns follow closely to .gitignore or .dockerignore.
|
||||
|
||||
# As an example, the C# client generator defines ApiClient.cs.
|
||||
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
|
||||
#ApiClient.cs
|
||||
|
||||
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||
#foo/*/qux
|
||||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||
|
||||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||
#foo/**/qux
|
||||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||
|
||||
# You can also negate patterns with an exclamation (!).
|
||||
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||
#docs/*.md
|
||||
# Then explicitly reverse the ignore rule for a single file:
|
||||
#!docs/README.md
|
||||
12
plexjs/pms/.openapi-generator/FILES
Normal file
12
plexjs/pms/.openapi-generator/FILES
Normal file
@@ -0,0 +1,12 @@
|
||||
.gitignore
|
||||
.npmignore
|
||||
.openapi-generator-ignore
|
||||
README.md
|
||||
api.ts
|
||||
base.ts
|
||||
common.ts
|
||||
configuration.ts
|
||||
git_push.sh
|
||||
index.ts
|
||||
package.json
|
||||
tsconfig.json
|
||||
1
plexjs/pms/.openapi-generator/VERSION
Normal file
1
plexjs/pms/.openapi-generator/VERSION
Normal file
@@ -0,0 +1 @@
|
||||
6.3.0
|
||||
45
plexjs/pms/README.md
Normal file
45
plexjs/pms/README.md
Normal file
@@ -0,0 +1,45 @@
|
||||
## plexjs@0.0.29
|
||||
|
||||
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:
|
||||
|
||||
Environment
|
||||
* Node.js
|
||||
* Webpack
|
||||
* Browserify
|
||||
|
||||
Language level
|
||||
* ES5 - you must have a Promises/A+ library installed
|
||||
* ES6
|
||||
|
||||
Module system
|
||||
* CommonJS
|
||||
* ES6 module system
|
||||
|
||||
It can be used in both TypeScript and JavaScript. In TypeScript, the definition should be automatically resolved via `package.json`. ([Reference](http://www.typescriptlang.org/docs/handbook/typings-for-npm-packages.html))
|
||||
|
||||
### Building
|
||||
|
||||
To build and compile the typescript sources to javascript use:
|
||||
```
|
||||
npm install
|
||||
npm run build
|
||||
```
|
||||
|
||||
### Publishing
|
||||
|
||||
First build the package then run ```npm publish```
|
||||
|
||||
### Consuming
|
||||
|
||||
navigate to the folder of your consuming project and run one of the following commands.
|
||||
|
||||
_published:_
|
||||
|
||||
```
|
||||
npm install plexjs@0.0.29 --save
|
||||
```
|
||||
|
||||
_unPublished (not recommended):_
|
||||
|
||||
```
|
||||
npm install PATH_TO_GENERATED_PACKAGE --save
|
||||
File diff suppressed because it is too large
Load Diff
187
plexjs/pms/configuration.ts
Normal file
187
plexjs/pms/configuration.ts
Normal file
@@ -0,0 +1,187 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* Plex-API
|
||||
* An Open API Spec for interacting with Plex.tv and Plex Servers
|
||||
*
|
||||
* The version of the OpenAPI document: 0.0.3
|
||||
* Contact: Lukeslakemail@gmail.com
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
import { IAxiosRetryConfig } from "axios-retry";
|
||||
|
||||
export type ConfigurationParameters = {
|
||||
plexToken?: string;
|
||||
clientIdentifier?: string;
|
||||
device?: string;
|
||||
deviceName?: string;
|
||||
platform?: string;
|
||||
platformVersion?: string;
|
||||
product?: string;
|
||||
version?: string;
|
||||
basePath?: string;
|
||||
}
|
||||
|
||||
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
|
||||
* @param name security name
|
||||
* @memberof Configuration
|
||||
*/
|
||||
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
|
||||
|
||||
/**
|
||||
* override base path
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
basePath?: string;
|
||||
|
||||
/**
|
||||
* base options for axios calls
|
||||
*
|
||||
* @type {any}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
baseOptions?: any;
|
||||
|
||||
/**
|
||||
* The FormData constructor that will be used to create multipart form data
|
||||
* requests. You can inject this here so that execution environments that
|
||||
* do not support the FormData class can still run the generated client.
|
||||
*
|
||||
* @type {new () => FormData}
|
||||
*/
|
||||
formDataCtor?: new () => any;
|
||||
|
||||
/**
|
||||
* axios retry configuration
|
||||
*
|
||||
* @type {IAxiosRetryConfig}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
retriesConfig?: IAxiosRetryConfig
|
||||
|
||||
constructor(param: ConfigurationParameters = {}) {
|
||||
this.plexToken = param.plexToken || "";
|
||||
this.clientIdentifier = param.clientIdentifier || "plexjs";
|
||||
this.device = param.device || "plexjs";
|
||||
this.deviceName = param.deviceName || "plexjs";
|
||||
this.platform = param.platform || "plexjs";
|
||||
this.platformVersion = param.platformVersion || "0.0.29";
|
||||
this.product = param.product || "plexjs";
|
||||
this.version = param.version || "0.0.29";
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public setAuthToken(token: string) {
|
||||
this.plexToken = token
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given MIME is a JSON MIME.
|
||||
* JSON MIME examples:
|
||||
* application/json
|
||||
* application/json; charset=UTF8
|
||||
* APPLICATION/JSON
|
||||
* application/vnd.company+json
|
||||
* @param mime - MIME (Multipurpose Internet Mail Extensions)
|
||||
* @return True if the given MIME is JSON, false otherwise.
|
||||
*/
|
||||
public isJsonMime(mime: string): boolean {
|
||||
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
|
||||
return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
|
||||
}
|
||||
}
|
||||
57
plexjs/pms/git_push.sh
Normal file
57
plexjs/pms/git_push.sh
Normal file
@@ -0,0 +1,57 @@
|
||||
#!/bin/sh
|
||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||
#
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com"
|
||||
|
||||
git_user_id=$1
|
||||
git_repo_id=$2
|
||||
release_note=$3
|
||||
git_host=$4
|
||||
|
||||
if [ "$git_host" = "" ]; then
|
||||
git_host="github.com"
|
||||
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
|
||||
fi
|
||||
|
||||
if [ "$git_user_id" = "" ]; then
|
||||
git_user_id="GIT_USER_ID"
|
||||
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
|
||||
fi
|
||||
|
||||
if [ "$git_repo_id" = "" ]; then
|
||||
git_repo_id="GIT_REPO_ID"
|
||||
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
|
||||
fi
|
||||
|
||||
if [ "$release_note" = "" ]; then
|
||||
release_note="Minor update"
|
||||
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
|
||||
fi
|
||||
|
||||
# Initialize the local directory as a Git repository
|
||||
git init
|
||||
|
||||
# Adds the files in the local repository and stages them for commit.
|
||||
git add .
|
||||
|
||||
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
||||
git commit -m "$release_note"
|
||||
|
||||
# Sets the new remote
|
||||
git_remote=$(git remote)
|
||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||
|
||||
if [ "$GIT_TOKEN" = "" ]; then
|
||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
else
|
||||
git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
git pull origin master
|
||||
|
||||
# Pushes (Forces) the changes in the local repository up to the remote repository
|
||||
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
|
||||
git push origin master 2>&1 | grep -v 'To https'
|
||||
18
plexjs/pms/index.ts
Normal file
18
plexjs/pms/index.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* Plex-API
|
||||
* An Open API Spec for interacting with Plex.tv and Plex Servers
|
||||
*
|
||||
* The version of the OpenAPI document: 0.0.3
|
||||
* Contact: Lukeslakemail@gmail.com
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
export * from "./api";
|
||||
export {Configuration, ConfigurationParameters} from "./configuration";
|
||||
|
||||
38
plexjs/pms/package.json
Normal file
38
plexjs/pms/package.json
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"name": "@lukehagar/plexjs",
|
||||
"version": "0.0.29",
|
||||
"description": "Community Made Plex JS/TS Module",
|
||||
"author": "Luke Hagar",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/LukeHagar/plexjs.git"
|
||||
},
|
||||
"keywords": [
|
||||
"axios",
|
||||
"typescript",
|
||||
"openapi",
|
||||
"api",
|
||||
"plex",
|
||||
"plex media server",
|
||||
"pms",
|
||||
"plexjs"
|
||||
],
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/LukeHagar/plexjs/issues"
|
||||
},
|
||||
"main": "./dist/index.js",
|
||||
"typings": "./dist/index.d.ts",
|
||||
"scripts": {
|
||||
"build": "tsc --outDir ./dist",
|
||||
"prepare": "npm run build"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^0.26.1",
|
||||
"axios-retry": "^3.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^12.11.5",
|
||||
"typescript": "^4.0"
|
||||
}
|
||||
}
|
||||
23
plexjs/pms/tsconfig.json
Normal file
23
plexjs/pms/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"target": "ES5",
|
||||
"module": "CommonJS",
|
||||
"noImplicitAny": true,
|
||||
"outDir": "dist",
|
||||
"rootDir": ".",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"typeRoots": [
|
||||
"node_modules/@types"
|
||||
],
|
||||
"sourceMap": true
|
||||
},
|
||||
"exclude": [
|
||||
"dist",
|
||||
"node_modules",
|
||||
"./dist/**/*"
|
||||
]
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
"target": "ES5",
|
||||
"module": "CommonJS",
|
||||
"noImplicitAny": true,
|
||||
"outDir": "./dist",
|
||||
"outDir": "dist",
|
||||
"rootDir": ".",
|
||||
"lib": [
|
||||
"es6",
|
||||
@@ -12,10 +12,12 @@
|
||||
],
|
||||
"typeRoots": [
|
||||
"node_modules/@types"
|
||||
]
|
||||
],
|
||||
"sourceMap": true
|
||||
},
|
||||
"exclude": [
|
||||
"dist",
|
||||
"node_modules"
|
||||
"node_modules",
|
||||
"./dist/**/*"
|
||||
]
|
||||
}
|
||||
|
||||
42
readme.md
42
readme.md
@@ -1,11 +1,49 @@
|
||||
# Plex API Client
|
||||
|
||||
[](https://discord.gg/HQTPSJnWhb)
|
||||
[](https://npmjs.com/package/@lukehagar/plexjs)
|
||||
[](https://GitHub.com/LukeHagar/plexjs/tags/)
|
||||
|
||||
## Description
|
||||
|
||||
A typescript sdk for accessing the Plex.tv and Plex Media Server REST API's.
|
||||
|
||||
|
||||
A typescript sdk for interacting with Plex.tv and Plex Media Server REST API's.
|
||||
|
||||
Documentation for all of the available endpoints [can be found here](https://plexapi.dev/docs/plex)
|
||||
|
||||
## Installation
|
||||
|
||||
npm
|
||||
```bash
|
||||
npm install plexjs
|
||||
npm install @lukehagar/plexjs
|
||||
```
|
||||
|
||||
yarn
|
||||
```bash
|
||||
yarn add @lukehagar/plexjs
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
import {
|
||||
Configuration,
|
||||
ServerApi,
|
||||
DevicesApi,
|
||||
UserApi,
|
||||
} from "@lukehagar/plexjs";
|
||||
import dotenv from "dotenv";
|
||||
dotenv.config();
|
||||
|
||||
const config = new Configuration({
|
||||
basePath: process.env.BASE_PATH,
|
||||
plexToken: process.env.PLEX_TOKEN,
|
||||
});
|
||||
|
||||
new ServerApi(config).getServerCapabilities().then((resp) => console.log(resp));
|
||||
|
||||
new DevicesApi(config).getDevices().then((resp) => console.log(resp));
|
||||
|
||||
new UserApi(config).getUserDetails().then((resp) => console.log(resp));
|
||||
```
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
{{>licenseInfo}}
|
||||
import { IAxiosRetryConfig } from "axios-retry";
|
||||
|
||||
export interface ConfigurationParameters {
|
||||
|
||||
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
|
||||
basePath?: string;
|
||||
|
||||
}
|
||||
|
||||
export class Configuration {
|
||||
/**
|
||||
* parameter for apiKey security
|
||||
* @param name security name
|
||||
* @memberof Configuration
|
||||
*/
|
||||
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
|
||||
|
||||
/**
|
||||
* override base path
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
basePath?: string;
|
||||
|
||||
/**
|
||||
* base options for axios calls
|
||||
*
|
||||
* @type {any}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
baseOptions?: any;
|
||||
|
||||
/**
|
||||
* The FormData constructor that will be used to create multipart form data
|
||||
* requests. You can inject this here so that execution environments that
|
||||
* do not support the FormData class can still run the generated client.
|
||||
*
|
||||
* @type {new () => FormData}
|
||||
*/
|
||||
formDataCtor?: new () => any;
|
||||
|
||||
/**
|
||||
* axios retry configuration
|
||||
*
|
||||
* @type {IAxiosRetryConfig}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
retriesConfig?: IAxiosRetryConfig
|
||||
|
||||
constructor(param: ConfigurationParameters = {}) {
|
||||
|
||||
this.apiKey = param.apiKey;
|
||||
this.basePath = param.basePath;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given MIME is a JSON MIME.
|
||||
* JSON MIME examples:
|
||||
* application/json
|
||||
* application/json; charset=UTF8
|
||||
* APPLICATION/JSON
|
||||
* application/vnd.company+json
|
||||
* @param mime - MIME (Multipurpose Internet Mail Extensions)
|
||||
* @return True if the given MIME is JSON, false otherwise.
|
||||
*/
|
||||
public isJsonMime(mime: string): boolean {
|
||||
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
|
||||
return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
|
||||
}
|
||||
}
|
||||
176
sdk-resources/plexjs-resources/configuration.mustache
Normal file
176
sdk-resources/plexjs-resources/configuration.mustache
Normal file
@@ -0,0 +1,176 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
{{>licenseInfo}}
|
||||
import { IAxiosRetryConfig } from "axios-retry";
|
||||
|
||||
export type ConfigurationParameters = {
|
||||
plexToken?: string;
|
||||
clientIdentifier?: string;
|
||||
device?: string;
|
||||
deviceName?: string;
|
||||
platform?: string;
|
||||
platformVersion?: string;
|
||||
product?: string;
|
||||
version?: string;
|
||||
basePath?: string;
|
||||
}
|
||||
|
||||
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
|
||||
* @param name security name
|
||||
* @memberof Configuration
|
||||
*/
|
||||
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
|
||||
|
||||
/**
|
||||
* override base path
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
basePath?: string;
|
||||
|
||||
/**
|
||||
* base options for axios calls
|
||||
*
|
||||
* @type {any}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
baseOptions?: any;
|
||||
|
||||
/**
|
||||
* The FormData constructor that will be used to create multipart form data
|
||||
* requests. You can inject this here so that execution environments that
|
||||
* do not support the FormData class can still run the generated client.
|
||||
*
|
||||
* @type {new () => FormData}
|
||||
*/
|
||||
formDataCtor?: new () => any;
|
||||
|
||||
/**
|
||||
* axios retry configuration
|
||||
*
|
||||
* @type {IAxiosRetryConfig}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
retriesConfig?: IAxiosRetryConfig
|
||||
|
||||
constructor(param: ConfigurationParameters = {}) {
|
||||
this.plexToken = param.plexToken || "";
|
||||
this.clientIdentifier = param.clientIdentifier || "{{npmName}}";
|
||||
this.device = param.device || "{{npmName}}";
|
||||
this.deviceName = param.deviceName || "{{npmName}}";
|
||||
this.platform = param.platform || "{{npmName}}";
|
||||
this.platformVersion = param.platformVersion || "{{npmVersion}}";
|
||||
this.product = param.product || "{{npmName}}";
|
||||
this.version = param.version || "{{npmVersion}}";
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public setAuthToken(token: string) {
|
||||
this.plexToken = token
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given MIME is a JSON MIME.
|
||||
* JSON MIME examples:
|
||||
* application/json
|
||||
* application/json; charset=UTF8
|
||||
* APPLICATION/JSON
|
||||
* application/vnd.company+json
|
||||
* @param mime - MIME (Multipurpose Internet Mail Extensions)
|
||||
* @return True if the given MIME is JSON, false otherwise.
|
||||
*/
|
||||
public isJsonMime(mime: string): boolean {
|
||||
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
|
||||
return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
|
||||
}
|
||||
}
|
||||
4
sdk-resources/plexjs-resources/gitignore
Normal file
4
sdk-resources/plexjs-resources/gitignore
Normal file
@@ -0,0 +1,4 @@
|
||||
wwwroot/*.js
|
||||
node_modules
|
||||
typings
|
||||
dist
|
||||
@@ -3,5 +3,5 @@
|
||||
{{>licenseInfo}}
|
||||
|
||||
export * from "./api";
|
||||
export * from "./configuration";
|
||||
export {Configuration, ConfigurationParameters} from "./configuration";
|
||||
{{#withSeparateModelsAndApi}}export * from "./{{tsModelPackage}}";{{/withSeparateModelsAndApi}}
|
||||
1
sdk-resources/plexjs-resources/npmignore
Normal file
1
sdk-resources/plexjs-resources/npmignore
Normal file
@@ -0,0 +1 @@
|
||||
# empty npmignore to ensure all required files (e.g., in the dist folder) are published by npm
|
||||
@@ -3,7 +3,6 @@
|
||||
"version": "{{npmVersion}}",
|
||||
"description": "Community Made Plex JS/TS Module",
|
||||
"author": "Luke Hagar",
|
||||
"type": "module",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/LukeHagar/plexjs.git"
|
||||
@@ -4,7 +4,7 @@
|
||||
"target": "{{#supportsES6}}ES6{{/supportsES6}}{{^supportsES6}}ES5{{/supportsES6}}",
|
||||
"module": "{{#supportsES6}}ES6{{/supportsES6}}{{^supportsES6}}CommonJS{{/supportsES6}}",
|
||||
"noImplicitAny": true,
|
||||
"outDir": "./dist",
|
||||
"outDir": "dist",
|
||||
"rootDir": ".",
|
||||
{{^supportsES6}}
|
||||
"lib": [
|
||||
@@ -14,10 +14,12 @@
|
||||
{{/supportsES6}}
|
||||
"typeRoots": [
|
||||
"node_modules/@types"
|
||||
]
|
||||
],
|
||||
"sourceMap": true
|
||||
},
|
||||
"exclude": [
|
||||
"dist",
|
||||
"node_modules"
|
||||
"node_modules",
|
||||
"./dist/**/*"
|
||||
]
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
templateDir: ./sdk-resources
|
||||
templateDir: ./sdk-resources/plextv-resources
|
||||
files:
|
||||
package.mustache:
|
||||
templateType: SupportingFiles
|
||||
destinationFilename: package.json
|
||||
npmName: plexjs
|
||||
npmRepository: lukehagar
|
||||
npmVersion: 0.0.12
|
||||
npmVersion: 0.0.29
|
||||
useSingleRequestParameter: true
|
||||
sortParamsByRequiredFlag: true
|
||||
gitUserID: lukehagar
|
||||
45
sdk-resources/plextv-resources/README.mustache
Normal file
45
sdk-resources/plextv-resources/README.mustache
Normal file
@@ -0,0 +1,45 @@
|
||||
## {{npmName}}@{{npmVersion}}
|
||||
|
||||
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:
|
||||
|
||||
Environment
|
||||
* Node.js
|
||||
* Webpack
|
||||
* Browserify
|
||||
|
||||
Language level
|
||||
* ES5 - you must have a Promises/A+ library installed
|
||||
* ES6
|
||||
|
||||
Module system
|
||||
* CommonJS
|
||||
* ES6 module system
|
||||
|
||||
It can be used in both TypeScript and JavaScript. In TypeScript, the definition should be automatically resolved via `package.json`. ([Reference](http://www.typescriptlang.org/docs/handbook/typings-for-npm-packages.html))
|
||||
|
||||
### Building
|
||||
|
||||
To build and compile the typescript sources to javascript use:
|
||||
```
|
||||
npm install
|
||||
npm run build
|
||||
```
|
||||
|
||||
### Publishing
|
||||
|
||||
First build the package then run ```npm publish```
|
||||
|
||||
### Consuming
|
||||
|
||||
navigate to the folder of your consuming project and run one of the following commands.
|
||||
|
||||
_published:_
|
||||
|
||||
```
|
||||
npm install {{npmName}}@{{npmVersion}} --save
|
||||
```
|
||||
|
||||
_unPublished (not recommended):_
|
||||
|
||||
```
|
||||
npm install PATH_TO_GENERATED_PACKAGE --save
|
||||
31
sdk-resources/plextv-resources/api.mustache
Normal file
31
sdk-resources/plextv-resources/api.mustache
Normal file
@@ -0,0 +1,31 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
{{>licenseInfo}}
|
||||
|
||||
{{^withSeparateModelsAndApi}}
|
||||
import { Configuration } from './configuration';
|
||||
import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios';
|
||||
{{#withNodeImports}}
|
||||
// URLSearchParams not necessarily used
|
||||
// @ts-ignore
|
||||
import { URL, URLSearchParams } from 'url';
|
||||
{{#multipartFormData}}
|
||||
import FormData from 'form-data'
|
||||
{{/multipartFormData}}
|
||||
{{/withNodeImports}}
|
||||
// Some imports not used depending on template conditions
|
||||
// @ts-ignore
|
||||
import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from './common';
|
||||
// @ts-ignore
|
||||
import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from './base';
|
||||
|
||||
{{#models}}
|
||||
{{#model}}{{#isEnum}}{{>modelEnum}}{{/isEnum}}{{#oneOf}}{{#-first}}{{>modelOneOf}}{{/-first}}{{/oneOf}}{{^isEnum}}{{^oneOf}}{{>modelGeneric}}{{/oneOf}}{{/isEnum}}{{/model}}
|
||||
{{/models}}
|
||||
{{#apiInfo}}{{#apis}}
|
||||
{{>apiInner}}
|
||||
{{/apis}}{{/apiInfo}}
|
||||
{{/withSeparateModelsAndApi}}{{#withSeparateModelsAndApi}}
|
||||
{{#apiInfo}}{{#apis}}{{#operations}}export * from './{{tsApiPackage}}/{{classFilename}}';
|
||||
{{/operations}}{{/apis}}{{/apiInfo}}
|
||||
{{/withSeparateModelsAndApi}}
|
||||
371
sdk-resources/plextv-resources/apiInner.mustache
Normal file
371
sdk-resources/plextv-resources/apiInner.mustache
Normal file
@@ -0,0 +1,371 @@
|
||||
{{#withSeparateModelsAndApi}}
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
{{>licenseInfo}}
|
||||
|
||||
import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios';
|
||||
import { Configuration } from '{{apiRelativeToRoot}}configuration';
|
||||
{{#withNodeImports}}
|
||||
// URLSearchParams not necessarily used
|
||||
// @ts-ignore
|
||||
import { URL, URLSearchParams } from 'url';
|
||||
{{#multipartFormData}}
|
||||
import FormData from 'form-data'
|
||||
{{/multipartFormData}}
|
||||
{{/withNodeImports}}
|
||||
// Some imports not used depending on template conditions
|
||||
// @ts-ignore
|
||||
import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from '{{apiRelativeToRoot}}common';
|
||||
// @ts-ignore
|
||||
import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '{{apiRelativeToRoot}}base';
|
||||
{{#imports}}
|
||||
// @ts-ignore
|
||||
import { {{classname}} } from '{{apiRelativeToRoot}}{{tsModelPackage}}';
|
||||
{{/imports}}
|
||||
{{/withSeparateModelsAndApi}}
|
||||
{{^withSeparateModelsAndApi}}
|
||||
{{/withSeparateModelsAndApi}}
|
||||
{{#operations}}
|
||||
/**
|
||||
* {{classname}} - axios parameter creator{{#description}}
|
||||
* {{&description}}{{/description}}
|
||||
* @export
|
||||
*/
|
||||
export const {{classname}}AxiosParamCreator = function (configuration?: Configuration) {
|
||||
return {
|
||||
{{#operation}}
|
||||
/**
|
||||
* {{¬es}}
|
||||
{{#summary}}
|
||||
* @summary {{&summary}}
|
||||
{{/summary}}
|
||||
{{#allParams}}
|
||||
* @param {{=<% %>=}}{<%&dataType%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}}
|
||||
{{/allParams}}
|
||||
* @param {*} [axiosOptions] Override http request option.{{#isDeprecated}}
|
||||
* @deprecated{{/isDeprecated}}
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
{{nickname}}: async ({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}axiosOptions: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||
{{#allParams}}
|
||||
{{#required}}
|
||||
// verify required parameter '{{paramName}}' is not null or undefined
|
||||
assertParamExists('{{nickname}}', '{{paramName}}', {{paramName}})
|
||||
{{/required}}
|
||||
{{/allParams}}
|
||||
const localVarPath = `{{{path}}}`{{#pathParams}}
|
||||
.replace(`{${"{{baseName}}"}}`, encodeURIComponent(String({{paramName}}))){{/pathParams}};
|
||||
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
||||
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
||||
let baseOptions;
|
||||
if (configuration) {
|
||||
baseOptions = configuration.baseOptions;
|
||||
}
|
||||
|
||||
const localVarRequestOptions = { method: '{{httpMethod}}', ...baseOptions, ...axiosOptions};
|
||||
const localVarHeaderParameter = {} as any;
|
||||
const localVarQueryParameter = {} as any;{{#vendorExtensions}}{{#hasFormParams}}
|
||||
const localVarFormParams = new {{^multipartFormData}}URLSearchParams(){{/multipartFormData}}{{#multipartFormData}}((configuration && configuration.formDataCtor) || FormData)(){{/multipartFormData}};{{/hasFormParams}}{{/vendorExtensions}}
|
||||
|
||||
{{#authMethods}}
|
||||
// authentication {{name}} required
|
||||
{{#isApiKey}}
|
||||
{{#isKeyInHeader}}
|
||||
await setApiKeyToObject(localVarHeaderParameter, "{{keyParamName}}", configuration)
|
||||
{{/isKeyInHeader}}
|
||||
{{#isKeyInQuery}}
|
||||
await setApiKeyToObject(localVarQueryParameter, "{{keyParamName}}", configuration)
|
||||
{{/isKeyInQuery}}
|
||||
{{/isApiKey}}
|
||||
{{#isBasicBasic}}
|
||||
// http basic authentication required
|
||||
setBasicAuthToObject(localVarRequestOptions, configuration)
|
||||
{{/isBasicBasic}}
|
||||
{{#isBasicBearer}}
|
||||
// http bearer authentication required
|
||||
await setBearerAuthToObject(localVarHeaderParameter, configuration)
|
||||
{{/isBasicBearer}}
|
||||
{{#isOAuth}}
|
||||
// oauth required
|
||||
await setOAuthToObject(localVarHeaderParameter, "{{name}}", [{{#scopes}}"{{{scope}}}"{{^-last}}, {{/-last}}{{/scopes}}], configuration)
|
||||
{{/isOAuth}}
|
||||
|
||||
{{/authMethods}}
|
||||
{{#queryParams}}
|
||||
{{#isArray}}
|
||||
if ({{paramName}}) {
|
||||
{{#isCollectionFormatMulti}}
|
||||
{{#uniqueItems}}
|
||||
localVarQueryParameter['{{baseName}}'] = Array.from({{paramName}});
|
||||
{{/uniqueItems}}
|
||||
{{^uniqueItems}}
|
||||
localVarQueryParameter['{{baseName}}'] = {{paramName}};
|
||||
{{/uniqueItems}}
|
||||
{{/isCollectionFormatMulti}}
|
||||
{{^isCollectionFormatMulti}}
|
||||
{{#uniqueItems}}
|
||||
localVarQueryParameter['{{baseName}}'] = Array.from({{paramName}}).join(COLLECTION_FORMATS.{{collectionFormat}});
|
||||
{{/uniqueItems}}
|
||||
{{^uniqueItems}}
|
||||
localVarQueryParameter['{{baseName}}'] = {{paramName}}.join(COLLECTION_FORMATS.{{collectionFormat}});
|
||||
{{/uniqueItems}}
|
||||
{{/isCollectionFormatMulti}}
|
||||
}
|
||||
{{/isArray}}
|
||||
{{^isArray}}
|
||||
if ({{paramName}} !== undefined) {
|
||||
{{#isDateTime}}
|
||||
localVarQueryParameter['{{baseName}}'] = ({{paramName}} as any instanceof Date) ?
|
||||
({{paramName}} as any).toISOString() :
|
||||
{{paramName}};
|
||||
{{/isDateTime}}
|
||||
{{^isDateTime}}
|
||||
{{#isDate}}
|
||||
localVarQueryParameter['{{baseName}}'] = ({{paramName}} as any instanceof Date) ?
|
||||
({{paramName}} as any).toISOString().substr(0,10) :
|
||||
{{paramName}};
|
||||
{{/isDate}}
|
||||
{{^isDate}}
|
||||
localVarQueryParameter['{{baseName}}'] = {{paramName}};
|
||||
{{/isDate}}
|
||||
{{/isDateTime}}
|
||||
}
|
||||
{{/isArray}}
|
||||
|
||||
{{/queryParams}}
|
||||
{{#headerParams}}
|
||||
{{#isArray}}
|
||||
if ({{paramName}}) {
|
||||
{{#uniqueItems}}
|
||||
let mapped = Array.from({{paramName}}).map(value => (<any>"{{{dataType}}}" !== "Set<string>") ? JSON.stringify(value) : (value || ""));
|
||||
{{/uniqueItems}}
|
||||
{{^uniqueItems}}
|
||||
let mapped = {{paramName}}.map(value => (<any>"{{{dataType}}}" !== "Array<string>") ? JSON.stringify(value) : (value || ""));
|
||||
{{/uniqueItems}}
|
||||
localVarHeaderParameter['{{baseName}}'] = mapped.join(COLLECTION_FORMATS["{{collectionFormat}}"]);
|
||||
}
|
||||
{{/isArray}}
|
||||
{{^isArray}}
|
||||
if ({{paramName}} !== undefined && {{paramName}} !== null) {
|
||||
{{#isString}}
|
||||
localVarHeaderParameter['{{baseName}}'] = String({{paramName}});
|
||||
{{/isString}}
|
||||
{{^isString}}
|
||||
localVarHeaderParameter['{{baseName}}'] = String(JSON.stringify({{paramName}}));
|
||||
{{/isString}}
|
||||
}
|
||||
{{/isArray}}
|
||||
|
||||
{{/headerParams}}
|
||||
{{#vendorExtensions}}
|
||||
{{#formParams}}
|
||||
{{#isArray}}
|
||||
if ({{paramName}}) {
|
||||
{{#isCollectionFormatMulti}}
|
||||
{{paramName}}.forEach((element) => {
|
||||
localVarFormParams.{{#multipartFormData}}append{{/multipartFormData}}{{^multipartFormData}}set{{/multipartFormData}}('{{baseName}}', element as any);
|
||||
})
|
||||
{{/isCollectionFormatMulti}}
|
||||
{{^isCollectionFormatMulti}}
|
||||
localVarFormParams.{{#multipartFormData}}append{{/multipartFormData}}{{^multipartFormData}}set{{/multipartFormData}}('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS.{{collectionFormat}}));
|
||||
{{/isCollectionFormatMulti}}
|
||||
}{{/isArray}}
|
||||
{{^isArray}}
|
||||
if ({{paramName}} !== undefined) { {{^multipartFormData}}
|
||||
localVarFormParams.set('{{baseName}}', {{paramName}} as any);{{/multipartFormData}}{{#multipartFormData}}{{#isPrimitiveType}}
|
||||
localVarFormParams.append('{{baseName}}', {{paramName}} as any);{{/isPrimitiveType}}{{^isPrimitiveType}}
|
||||
localVarFormParams.append('{{baseName}}', new Blob([JSON.stringify({{paramName}})], { type: "application/json", }));{{/isPrimitiveType}}{{/multipartFormData}}
|
||||
}{{/isArray}}
|
||||
{{/formParams}}{{/vendorExtensions}}
|
||||
{{#vendorExtensions}}{{#hasFormParams}}{{^multipartFormData}}
|
||||
localVarHeaderParameter['Content-Type'] = 'application/x-www-form-urlencoded';{{/multipartFormData}}{{#multipartFormData}}
|
||||
localVarHeaderParameter['Content-Type'] = 'multipart/form-data';{{/multipartFormData}}
|
||||
{{/hasFormParams}}{{/vendorExtensions}}
|
||||
{{#bodyParam}}
|
||||
{{^consumes}}
|
||||
localVarHeaderParameter['Content-Type'] = 'application/json';
|
||||
{{/consumes}}
|
||||
{{#consumes.0}}
|
||||
localVarHeaderParameter['Content-Type'] = '{{{mediaType}}}';
|
||||
{{/consumes.0}}
|
||||
|
||||
{{/bodyParam}}
|
||||
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
||||
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
||||
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions,{{#hasFormParams}}{{#multipartFormData}} ...(localVarFormParams as any).getHeaders?.(),{{/multipartFormData}}{{/hasFormParams}} ...axiosOptions.headers};
|
||||
{{#hasFormParams}}
|
||||
localVarRequestOptions.data = localVarFormParams{{#vendorExtensions}}{{^multipartFormData}}.toString(){{/multipartFormData}}{{/vendorExtensions}};
|
||||
{{/hasFormParams}}
|
||||
{{#bodyParam}}
|
||||
localVarRequestOptions.data = serializeDataIfNeeded({{paramName}}, localVarRequestOptions, configuration)
|
||||
{{/bodyParam}}
|
||||
|
||||
return {
|
||||
url: toPathString(localVarUrlObj),
|
||||
axiosOptions: localVarRequestOptions,
|
||||
};
|
||||
},
|
||||
{{/operation}}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* {{classname}} - functional programming interface{{#description}}
|
||||
* {{{.}}}{{/description}}
|
||||
* @export
|
||||
*/
|
||||
export const {{classname}}Fp = function(configuration?: Configuration) {
|
||||
const localVarAxiosParamCreator = {{classname}}AxiosParamCreator(configuration)
|
||||
return {
|
||||
{{#operation}}
|
||||
/**
|
||||
* {{¬es}}
|
||||
{{#summary}}
|
||||
* @summary {{&summary}}
|
||||
{{/summary}}
|
||||
{{#allParams}}
|
||||
* @param {{=<% %>=}}{<%&dataType%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}}
|
||||
{{/allParams}}
|
||||
* @param {*} [axiosOptions] Override http request option.{{#isDeprecated}}
|
||||
* @deprecated{{/isDeprecated}}
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
async {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}axiosOptions?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<{{{returnType}}}{{^returnType}}void{{/returnType}}>> {
|
||||
const localVarAxiosArgs = await localVarAxiosParamCreator.{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}axiosOptions);
|
||||
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
||||
},
|
||||
{{/operation}}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* {{classname}} - factory interface{{#description}}
|
||||
* {{&description}}{{/description}}
|
||||
* @export
|
||||
*/
|
||||
export const {{classname}}Factory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
|
||||
const localVarFp = {{classname}}Fp(configuration)
|
||||
return {
|
||||
{{#operation}}
|
||||
/**
|
||||
* {{¬es}}
|
||||
{{#summary}}
|
||||
* @summary {{&summary}}
|
||||
{{/summary}}
|
||||
{{#allParams}}
|
||||
* @param {{=<% %>=}}{<%&dataType%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}}
|
||||
{{/allParams}}
|
||||
* @param {*} [axiosOptions] Override http request option.{{#isDeprecated}}
|
||||
* @deprecated{{/isDeprecated}}
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
{{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}axiosOptions?: any): AxiosPromise<{{{returnType}}}{{^returnType}}void{{/returnType}}> {
|
||||
return localVarFp.{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}axiosOptions).then((request) => request(axios, basePath));
|
||||
},
|
||||
{{/operation}}
|
||||
};
|
||||
};
|
||||
|
||||
{{#withInterfaces}}
|
||||
/**
|
||||
* {{classname}} - interface{{#description}}
|
||||
* {{&description}}{{/description}}
|
||||
* @export
|
||||
* @interface {{classname}}
|
||||
*/
|
||||
export interface {{classname}}Interface {
|
||||
{{#operation}}
|
||||
/**
|
||||
* {{¬es}}
|
||||
{{#summary}}
|
||||
* @summary {{&summary}}
|
||||
{{/summary}}
|
||||
{{#allParams}}
|
||||
* @param {{=<% %>=}}{<%&dataType%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}}
|
||||
{{/allParams}}
|
||||
* @param {*} [axiosOptions] Override http request option.{{#isDeprecated}}
|
||||
* @deprecated{{/isDeprecated}}
|
||||
* @throws {RequiredError}
|
||||
* @memberof {{classname}}Interface
|
||||
*/
|
||||
{{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}axiosOptions?: AxiosRequestConfig): AxiosPromise<{{{returnType}}}{{^returnType}}void{{/returnType}}>;
|
||||
|
||||
{{/operation}}
|
||||
}
|
||||
|
||||
{{/withInterfaces}}
|
||||
{{#useSingleRequestParameter}}
|
||||
{{#operation}}
|
||||
{{#allParams.0}}
|
||||
/**
|
||||
* Request parameters for {{nickname}} operation in {{classname}}.
|
||||
* @export
|
||||
* @interface {{classname}}{{operationIdCamelCase}}Request
|
||||
*/
|
||||
export interface {{classname}}{{operationIdCamelCase}}Request {
|
||||
{{#allParams}}
|
||||
/**
|
||||
* {{description}}
|
||||
* @type {{=<% %>=}}{<%&dataType%>}<%={{ }}=%>
|
||||
* @memberof {{classname}}{{operationIdCamelCase}}
|
||||
*/
|
||||
readonly {{paramName}}{{^required}}?{{/required}}: {{{dataType}}}
|
||||
{{^-last}}
|
||||
|
||||
{{/-last}}
|
||||
{{/allParams}}
|
||||
}
|
||||
|
||||
{{/allParams.0}}
|
||||
{{/operation}}
|
||||
{{/useSingleRequestParameter}}
|
||||
/**
|
||||
* {{classname}} - object-oriented interface{{#description}}
|
||||
* {{{.}}}{{/description}}
|
||||
* @export
|
||||
* @class {{classname}}
|
||||
* @extends {BaseAPI}
|
||||
*/
|
||||
{{#withInterfaces}}
|
||||
export class {{classname}} extends BaseAPI implements {{classname}}Interface {
|
||||
{{/withInterfaces}}
|
||||
{{^withInterfaces}}
|
||||
export class {{classname}} extends BaseAPI {
|
||||
{{/withInterfaces}}
|
||||
{{#operation}}
|
||||
/**
|
||||
* {{¬es}}
|
||||
{{#summary}}
|
||||
* @summary {{&summary}}
|
||||
{{/summary}}
|
||||
{{#useSingleRequestParameter}}
|
||||
{{#allParams.0}}
|
||||
* @param {{=<% %>=}}{<%& classname %><%& operationIdCamelCase %>Request}<%={{ }}=%> requestParameters Request parameters.
|
||||
{{/allParams.0}}
|
||||
{{/useSingleRequestParameter}}
|
||||
{{^useSingleRequestParameter}}
|
||||
{{#allParams}}
|
||||
* @param {{=<% %>=}}{<%&dataType%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}}
|
||||
{{/allParams}}
|
||||
{{/useSingleRequestParameter}}
|
||||
* @param {*} [axiosOptions] Override http request option.{{#isDeprecated}}
|
||||
* @deprecated{{/isDeprecated}}
|
||||
* @throws {RequiredError}
|
||||
* @memberof {{classname}}
|
||||
*/
|
||||
{{#useSingleRequestParameter}}
|
||||
public {{nickname}}({{#allParams.0}}requestParameters: {{classname}}{{operationIdCamelCase}}Request{{^hasRequiredParams}} = {}{{/hasRequiredParams}}, {{/allParams.0}}axiosOptions?: AxiosRequestConfig) {
|
||||
return {{classname}}Fp(this.configuration).{{nickname}}({{#allParams.0}}{{#allParams}}requestParameters.{{paramName}}, {{/allParams}}{{/allParams.0}}axiosOptions).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
{{/useSingleRequestParameter}}
|
||||
{{^useSingleRequestParameter}}
|
||||
public {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}axiosOptions?: AxiosRequestConfig) {
|
||||
return {{classname}}Fp(this.configuration).{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}axiosOptions).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
{{/useSingleRequestParameter}}
|
||||
{{^-last}}
|
||||
|
||||
{{/-last}}
|
||||
{{/operation}}
|
||||
}
|
||||
{{/operations}}
|
||||
60
sdk-resources/plextv-resources/baseApi.mustache
Normal file
60
sdk-resources/plextv-resources/baseApi.mustache
Normal file
@@ -0,0 +1,60 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
{{>licenseInfo}}
|
||||
|
||||
import { Configuration } from "./configuration";
|
||||
// Some imports not used depending on template conditions
|
||||
// @ts-ignore
|
||||
import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios';
|
||||
|
||||
export const BASE_PATH = "{{{basePath}}}".replace(/\/+$/, "");
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
*/
|
||||
export const COLLECTION_FORMATS = {
|
||||
csv: ",",
|
||||
ssv: " ",
|
||||
tsv: "\t",
|
||||
pipes: "|",
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
* @interface RequestArgs
|
||||
*/
|
||||
export interface RequestArgs {
|
||||
url: string;
|
||||
axiosOptions: AxiosRequestConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
* @class BaseAPI
|
||||
*/
|
||||
export class BaseAPI {
|
||||
protected configuration: Configuration | undefined;
|
||||
|
||||
constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) {
|
||||
if (configuration) {
|
||||
this.configuration = configuration;
|
||||
this.basePath = "https://plex.tv/api/v2" || this.basePath;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
* @class RequiredError
|
||||
* @extends {Error}
|
||||
*/
|
||||
export class RequiredError extends Error {
|
||||
name: "RequiredError" = "RequiredError";
|
||||
constructor(public field: string, msg?: string) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
97
sdk-resources/plextv-resources/common.mustache
Normal file
97
sdk-resources/plextv-resources/common.mustache
Normal file
@@ -0,0 +1,97 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
{{>licenseInfo}}
|
||||
|
||||
import { Configuration } from "./configuration";
|
||||
import { RequiredError, RequestArgs } from "./base";
|
||||
import { AxiosInstance, AxiosResponse } from 'axios';
|
||||
import axiosRetry from "axios-retry";
|
||||
{{#withNodeImports}}
|
||||
import { URL, URLSearchParams } from 'url';
|
||||
{{/withNodeImports}}
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
*/
|
||||
export const DUMMY_BASE_URL = 'https://example.com'
|
||||
|
||||
/**
|
||||
*
|
||||
* @throws {RequiredError}
|
||||
* @export
|
||||
*/
|
||||
export const assertParamExists = function (functionName: string, paramName: string, paramValue: unknown) {
|
||||
if (paramValue === null || paramValue === undefined) {
|
||||
throw new RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
*/
|
||||
export const setApiKeyToObject = async function (object: any, keyParamName: string, configuration?: Configuration) {
|
||||
if (configuration && configuration.apiKey) {
|
||||
const localVarApiKeyValue = typeof configuration.apiKey === 'function'
|
||||
? await configuration.apiKey(keyParamName)
|
||||
: await configuration.apiKey;
|
||||
object[keyParamName] = localVarApiKeyValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
*/
|
||||
export const setSearchParams = function (url: URL, ...objects: any[]) {
|
||||
const searchParams = new URLSearchParams(url.search);
|
||||
for (const object of objects) {
|
||||
for (const key in object) {
|
||||
if (Array.isArray(object[key])) {
|
||||
searchParams.delete(key);
|
||||
for (const item of object[key]) {
|
||||
searchParams.append(key, item);
|
||||
}
|
||||
} else {
|
||||
searchParams.set(key, object[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
url.search = searchParams.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
*/
|
||||
export const serializeDataIfNeeded = function (value: any, requestOptions: any, configuration?: Configuration) {
|
||||
const nonString = typeof value !== 'string';
|
||||
const needsSerialization = nonString && configuration && configuration.isJsonMime
|
||||
? configuration.isJsonMime(requestOptions.headers['Content-Type'])
|
||||
: nonString;
|
||||
return needsSerialization
|
||||
? JSON.stringify(value !== undefined ? value : {})
|
||||
: (value || "");
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
*/
|
||||
export const toPathString = function (url: URL) {
|
||||
return url.pathname + url.search + url.hash
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
*/
|
||||
export const createRequestFunction = function (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) {
|
||||
return <T = unknown, R = AxiosResponse<T>>(axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
|
||||
axiosRetry(globalAxios, configuration.retriesConfig)
|
||||
const axiosRequestArgs = {...axiosArgs.axiosOptions, url: (configuration?.basePath || basePath) + axiosArgs.url};
|
||||
return axios.request<T, R>(axiosRequestArgs);
|
||||
};
|
||||
}
|
||||
176
sdk-resources/plextv-resources/configuration.mustache
Normal file
176
sdk-resources/plextv-resources/configuration.mustache
Normal file
@@ -0,0 +1,176 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
{{>licenseInfo}}
|
||||
import { IAxiosRetryConfig } from "axios-retry";
|
||||
|
||||
export type ConfigurationParameters = {
|
||||
plexToken?: string;
|
||||
clientIdentifier?: string;
|
||||
device?: string;
|
||||
deviceName?: string;
|
||||
platform?: string;
|
||||
platformVersion?: string;
|
||||
product?: string;
|
||||
version?: string;
|
||||
basePath?: string;
|
||||
}
|
||||
|
||||
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
|
||||
* @param name security name
|
||||
* @memberof Configuration
|
||||
*/
|
||||
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
|
||||
|
||||
/**
|
||||
* override base path
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
basePath?: string;
|
||||
|
||||
/**
|
||||
* base options for axios calls
|
||||
*
|
||||
* @type {any}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
baseOptions?: any;
|
||||
|
||||
/**
|
||||
* The FormData constructor that will be used to create multipart form data
|
||||
* requests. You can inject this here so that execution environments that
|
||||
* do not support the FormData class can still run the generated client.
|
||||
*
|
||||
* @type {new () => FormData}
|
||||
*/
|
||||
formDataCtor?: new () => any;
|
||||
|
||||
/**
|
||||
* axios retry configuration
|
||||
*
|
||||
* @type {IAxiosRetryConfig}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
retriesConfig?: IAxiosRetryConfig
|
||||
|
||||
constructor(param: ConfigurationParameters = {}) {
|
||||
this.plexToken = param.plexToken || "";
|
||||
this.clientIdentifier = param.clientIdentifier || "{{npmName}}";
|
||||
this.device = param.device || "{{npmName}}";
|
||||
this.deviceName = param.deviceName || "{{npmName}}";
|
||||
this.platform = param.platform || "{{npmName}}";
|
||||
this.platformVersion = param.platformVersion || "{{npmVersion}}";
|
||||
this.product = param.product || "{{npmName}}";
|
||||
this.version = param.version || "{{npmVersion}}";
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public setAuthToken(token: string) {
|
||||
this.plexToken = token
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given MIME is a JSON MIME.
|
||||
* JSON MIME examples:
|
||||
* application/json
|
||||
* application/json; charset=UTF8
|
||||
* APPLICATION/JSON
|
||||
* application/vnd.company+json
|
||||
* @param mime - MIME (Multipurpose Internet Mail Extensions)
|
||||
* @return True if the given MIME is JSON, false otherwise.
|
||||
*/
|
||||
public isJsonMime(mime: string): boolean {
|
||||
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
|
||||
return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
|
||||
}
|
||||
}
|
||||
57
sdk-resources/plextv-resources/git_push.sh.mustache
Normal file
57
sdk-resources/plextv-resources/git_push.sh.mustache
Normal file
@@ -0,0 +1,57 @@
|
||||
#!/bin/sh
|
||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||
#
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com"
|
||||
|
||||
git_user_id=$1
|
||||
git_repo_id=$2
|
||||
release_note=$3
|
||||
git_host=$4
|
||||
|
||||
if [ "$git_host" = "" ]; then
|
||||
git_host="{{{gitHost}}}"
|
||||
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
|
||||
fi
|
||||
|
||||
if [ "$git_user_id" = "" ]; then
|
||||
git_user_id="{{{gitUserId}}}"
|
||||
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
|
||||
fi
|
||||
|
||||
if [ "$git_repo_id" = "" ]; then
|
||||
git_repo_id="{{{gitRepoId}}}"
|
||||
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
|
||||
fi
|
||||
|
||||
if [ "$release_note" = "" ]; then
|
||||
release_note="{{{releaseNote}}}"
|
||||
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
|
||||
fi
|
||||
|
||||
# Initialize the local directory as a Git repository
|
||||
git init
|
||||
|
||||
# Adds the files in the local repository and stages them for commit.
|
||||
git add .
|
||||
|
||||
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
||||
git commit -m "$release_note"
|
||||
|
||||
# Sets the new remote
|
||||
git_remote=$(git remote)
|
||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||
|
||||
if [ "$GIT_TOKEN" = "" ]; then
|
||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
else
|
||||
git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
git pull origin master
|
||||
|
||||
# Pushes (Forces) the changes in the local repository up to the remote repository
|
||||
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
|
||||
git push origin master 2>&1 | grep -v 'To https'
|
||||
4
sdk-resources/plextv-resources/gitignore
Normal file
4
sdk-resources/plextv-resources/gitignore
Normal file
@@ -0,0 +1,4 @@
|
||||
wwwroot/*.js
|
||||
node_modules
|
||||
typings
|
||||
dist
|
||||
7
sdk-resources/plextv-resources/index.mustache
Normal file
7
sdk-resources/plextv-resources/index.mustache
Normal file
@@ -0,0 +1,7 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
{{>licenseInfo}}
|
||||
|
||||
export * from "./api";
|
||||
export {Configuration, ConfigurationParameters} from "./configuration";
|
||||
{{#withSeparateModelsAndApi}}export * from "./{{tsModelPackage}}";{{/withSeparateModelsAndApi}}
|
||||
11
sdk-resources/plextv-resources/licenseInfo.mustache
Normal file
11
sdk-resources/plextv-resources/licenseInfo.mustache
Normal file
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* {{{appName}}}
|
||||
* {{{appDescription}}}
|
||||
*
|
||||
* {{#version}}The version of the OpenAPI document: {{{.}}}{{/version}}
|
||||
* {{#infoEmail}}Contact: {{{.}}}{{/infoEmail}}
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
10
sdk-resources/plextv-resources/model.mustache
Normal file
10
sdk-resources/plextv-resources/model.mustache
Normal file
@@ -0,0 +1,10 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
{{>licenseInfo}}
|
||||
{{#withSeparateModelsAndApi}}{{#hasAllOf}}{{#allOf}}
|
||||
import { {{class}} } from './{{filename}}';{{/allOf}}{{/hasAllOf}}{{#hasOneOf}}{{#oneOf}}
|
||||
import { {{class}} } from './{{filename}}';{{/oneOf}}{{/hasOneOf}}{{^hasAllOf}}{{^hasOneOf}}{{#imports}}
|
||||
import { {{class}} } from './{{filename}}';{{/imports}}{{/hasOneOf}}{{/hasAllOf}}{{/withSeparateModelsAndApi}}
|
||||
{{#models}}{{#model}}
|
||||
{{#isEnum}}{{>modelEnum}}{{/isEnum}}{{#oneOf}}{{#-first}}{{>modelOneOf}}{{/-first}}{{/oneOf}}{{#allOf}}{{#-first}}{{>modelAllOf}}{{/-first}}{{/allOf}}{{^isEnum}}{{^oneOf}}{{^allOf}}{{>modelGeneric}}{{/allOf}}{{/oneOf}}{{/isEnum}}
|
||||
{{/model}}{{/models}}
|
||||
6
sdk-resources/plextv-resources/modelAllOf.mustache
Normal file
6
sdk-resources/plextv-resources/modelAllOf.mustache
Normal file
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* @type {{classname}}{{#description}}
|
||||
* {{{.}}}{{/description}}
|
||||
* @export
|
||||
*/
|
||||
export type {{classname}} = {{#allOf}}{{{.}}}{{^-last}} & {{/-last}}{{/allOf}};
|
||||
17
sdk-resources/plextv-resources/modelEnum.mustache
Normal file
17
sdk-resources/plextv-resources/modelEnum.mustache
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* {{{description}}}
|
||||
* @export
|
||||
* @enum {string}
|
||||
*/
|
||||
{{#isBoolean}}
|
||||
export type {{classname}} = {{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}} | {{/-last}}{{/enumVars}}{{/allowableValues}}
|
||||
{{/isBoolean}}
|
||||
|
||||
{{^isBoolean}}
|
||||
{{^stringEnums}}
|
||||
{{>modelObjectEnum}}
|
||||
{{/stringEnums}}
|
||||
{{#stringEnums}}
|
||||
{{>modelStringEnum}}
|
||||
{{/stringEnums}}
|
||||
{{/isBoolean}}
|
||||
62
sdk-resources/plextv-resources/modelGeneric.mustache
Normal file
62
sdk-resources/plextv-resources/modelGeneric.mustache
Normal file
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* {{{description}}}
|
||||
* @export
|
||||
* @interface {{classname}}
|
||||
*/
|
||||
export interface {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{
|
||||
{{#additionalPropertiesType}}
|
||||
[key: string]: {{{additionalPropertiesType}}}{{^additionalPropertiesIsAnyType}}{{#hasVars}} | any{{/hasVars}}{{/additionalPropertiesIsAnyType}};
|
||||
|
||||
{{/additionalPropertiesType}}
|
||||
{{#vars}}
|
||||
/**
|
||||
* {{{description}}}
|
||||
* @type {{=<% %>=}}{<%&datatype%>}<%={{ }}=%>
|
||||
* @memberof {{classname}}
|
||||
{{#deprecated}}
|
||||
* @deprecated
|
||||
{{/deprecated}}
|
||||
*/
|
||||
'{{baseName}}'{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}};
|
||||
{{/vars}}
|
||||
}{{#hasEnums}}
|
||||
|
||||
{{#vars}}
|
||||
{{#isEnum}}
|
||||
{{#stringEnums}}
|
||||
/**
|
||||
* @export
|
||||
* @enum {string}
|
||||
*/
|
||||
export enum {{enumName}} {
|
||||
{{#allowableValues}}
|
||||
{{#enumVars}}
|
||||
{{#enumDescription}}
|
||||
/**
|
||||
* {{.}}
|
||||
*/
|
||||
{{/enumDescription}}
|
||||
{{{name}}} = {{{value}}}{{^-last}},{{/-last}}
|
||||
{{/enumVars}}
|
||||
{{/allowableValues}}
|
||||
}
|
||||
{{/stringEnums}}
|
||||
{{^stringEnums}}
|
||||
export const {{enumName}} = {
|
||||
{{#allowableValues}}
|
||||
{{#enumVars}}
|
||||
{{#enumDescription}}
|
||||
/**
|
||||
* {{.}}
|
||||
*/
|
||||
{{/enumDescription}}
|
||||
{{{name}}}: {{{value}}}{{^-last}},{{/-last}}
|
||||
{{/enumVars}}
|
||||
{{/allowableValues}}
|
||||
} as const;
|
||||
|
||||
export type {{enumName}} = typeof {{enumName}}[keyof typeof {{enumName}}];
|
||||
{{/stringEnums}}
|
||||
{{/isEnum}}
|
||||
{{/vars}}
|
||||
{{/hasEnums}}
|
||||
2
sdk-resources/plextv-resources/modelIndex.mustache
Normal file
2
sdk-resources/plextv-resources/modelIndex.mustache
Normal file
@@ -0,0 +1,2 @@
|
||||
{{#models}}{{#model}}export * from './{{classFilename}}';{{/model}}
|
||||
{{/models}}
|
||||
14
sdk-resources/plextv-resources/modelObjectEnum.mustache
Normal file
14
sdk-resources/plextv-resources/modelObjectEnum.mustache
Normal file
@@ -0,0 +1,14 @@
|
||||
export const {{classname}} = {
|
||||
{{#allowableValues}}
|
||||
{{#enumVars}}
|
||||
{{#enumDescription}}
|
||||
/**
|
||||
* {{.}}
|
||||
*/
|
||||
{{/enumDescription}}
|
||||
{{{name}}}: {{{value}}}{{^-last}},{{/-last}}
|
||||
{{/enumVars}}
|
||||
{{/allowableValues}}
|
||||
} as const;
|
||||
|
||||
export type {{classname}} = typeof {{classname}}[keyof typeof {{classname}}];
|
||||
6
sdk-resources/plextv-resources/modelOneOf.mustache
Normal file
6
sdk-resources/plextv-resources/modelOneOf.mustache
Normal file
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* @type {{classname}}{{#description}}
|
||||
* {{{.}}}{{/description}}
|
||||
* @export
|
||||
*/
|
||||
export type {{classname}} = {{#oneOf}}{{{.}}}{{^-last}} | {{/-last}}{{/oneOf}};
|
||||
12
sdk-resources/plextv-resources/modelStringEnum.mustache
Normal file
12
sdk-resources/plextv-resources/modelStringEnum.mustache
Normal file
@@ -0,0 +1,12 @@
|
||||
export enum {{classname}} {
|
||||
{{#allowableValues}}
|
||||
{{#enumVars}}
|
||||
{{#enumDescription}}
|
||||
/**
|
||||
* {{.}}
|
||||
*/
|
||||
{{/enumDescription}}
|
||||
{{{name}}} = {{{value}}}{{^-last}},{{/-last}}
|
||||
{{/enumVars}}
|
||||
{{/allowableValues}}
|
||||
}
|
||||
1
sdk-resources/plextv-resources/npmignore
Normal file
1
sdk-resources/plextv-resources/npmignore
Normal file
@@ -0,0 +1 @@
|
||||
# empty npmignore to ensure all required files (e.g., in the dist folder) are published by npm
|
||||
38
sdk-resources/plextv-resources/package.mustache
Normal file
38
sdk-resources/plextv-resources/package.mustache
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"name": "@lukehagar/plexjs",
|
||||
"version": "{{npmVersion}}",
|
||||
"description": "Community Made Plex JS/TS Module",
|
||||
"author": "Luke Hagar",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/LukeHagar/plexjs.git"
|
||||
},
|
||||
"keywords": [
|
||||
"axios",
|
||||
"typescript",
|
||||
"openapi",
|
||||
"api",
|
||||
"plex",
|
||||
"plex media server",
|
||||
"pms",
|
||||
"{{npmName}}"
|
||||
],
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/LukeHagar/plexjs/issues"
|
||||
},
|
||||
"main": "./dist/index.js",
|
||||
"typings": "./dist/index.d.ts",
|
||||
"scripts": {
|
||||
"build": "tsc --outDir ./dist",
|
||||
"prepare": "npm run build"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^0.26.1",
|
||||
"axios-retry": "^3.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^12.11.5",
|
||||
"typescript": "^4.0"
|
||||
}
|
||||
}
|
||||
25
sdk-resources/plextv-resources/tsconfig.mustache
Normal file
25
sdk-resources/plextv-resources/tsconfig.mustache
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"target": "{{#supportsES6}}ES6{{/supportsES6}}{{^supportsES6}}ES5{{/supportsES6}}",
|
||||
"module": "{{#supportsES6}}ES6{{/supportsES6}}{{^supportsES6}}CommonJS{{/supportsES6}}",
|
||||
"noImplicitAny": true,
|
||||
"outDir": "dist",
|
||||
"rootDir": ".",
|
||||
{{^supportsES6}}
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
{{/supportsES6}}
|
||||
"typeRoots": [
|
||||
"node_modules/@types"
|
||||
],
|
||||
"sourceMap": true
|
||||
},
|
||||
"exclude": [
|
||||
"dist",
|
||||
"node_modules",
|
||||
"./dist/**/*"
|
||||
]
|
||||
}
|
||||
12
sdk-resources/pms-config.yaml
Normal file
12
sdk-resources/pms-config.yaml
Normal file
@@ -0,0 +1,12 @@
|
||||
templateDir: ./sdk-resources/plexjs-resources
|
||||
files:
|
||||
package.mustache:
|
||||
templateType: SupportingFiles
|
||||
destinationFilename: package.json
|
||||
npmName: plexjs
|
||||
npmRepository: lukehagar
|
||||
npmVersion: 0.0.29
|
||||
useSingleRequestParameter: true
|
||||
sortParamsByRequiredFlag: true
|
||||
gitUserID: lukehagar
|
||||
gitRepoID: plexjs
|
||||
Reference in New Issue
Block a user