mirror of
https://github.com/LukeHagar/plexjs.git
synced 2025-12-06 12:37:46 +00:00
Compare commits
104 Commits
0.0.13
...
liblab-cod
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d62f9a10e4 | ||
|
|
0a07813e04 | ||
|
|
9ecba973b2 | ||
|
|
8f1f267eab | ||
|
|
6aae156cbf | ||
|
|
ec7ccb9cdf | ||
|
|
0bdcb1b09d | ||
|
|
889627a1fc | ||
|
|
6eaf9ce448 | ||
|
|
5cb5ef5c1e | ||
|
|
b2ea2bba7c | ||
|
|
7afaafe395 | ||
|
|
74ccf497a7 | ||
|
|
1ff8b0aa97 | ||
|
|
008c94be97 | ||
|
|
d2a1aac321 | ||
|
|
907cfca700 | ||
|
|
aeb70e35d0 | ||
|
|
87bdb7cd58 | ||
|
|
90dbe3183a | ||
|
|
ccff49c365 | ||
|
|
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 |
12
.devcontainer/devcontainer.json
Normal file
12
.devcontainer/devcontainer.json
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
|
||||||
|
// README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node
|
||||||
|
{
|
||||||
|
"name": "TypeScript SDK",
|
||||||
|
"image": "mcr.microsoft.com/devcontainers/typescript-node:1-20-bullseye",
|
||||||
|
"postCreateCommand": "cd examples && npm run setup",
|
||||||
|
"customizations": {
|
||||||
|
"codespaces":{
|
||||||
|
"openFiles": ["examples/src/index.ts", "README.md"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
50
.eslintrc.json
Normal file
50
.eslintrc.json
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
{
|
||||||
|
"env": {
|
||||||
|
"browser": true,
|
||||||
|
"commonjs": true,
|
||||||
|
"es2021": true
|
||||||
|
},
|
||||||
|
"extends": [
|
||||||
|
"airbnb-base",
|
||||||
|
"airbnb-typescript/base",
|
||||||
|
"prettier"
|
||||||
|
],
|
||||||
|
"parser": "@typescript-eslint/parser",
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": "latest",
|
||||||
|
"sourceType": "module",
|
||||||
|
"project": "./tsconfig.eslint.json"
|
||||||
|
},
|
||||||
|
"plugins": [
|
||||||
|
"@typescript-eslint",
|
||||||
|
"prettier"
|
||||||
|
],
|
||||||
|
"rules": {
|
||||||
|
"no-console": "off",
|
||||||
|
"max-len": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
"code": 150,
|
||||||
|
"ignoreComments": true,
|
||||||
|
"ignoreRegExpLiterals": true,
|
||||||
|
"ignoreStrings": true,
|
||||||
|
"ignoreTemplateLiterals": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"prettier/prettier": "error",
|
||||||
|
"@typescript-eslint/dot-notation": "off",
|
||||||
|
"import/prefer-default-export": "off"
|
||||||
|
},
|
||||||
|
"settings": {
|
||||||
|
"import/resolver": {
|
||||||
|
"node": {
|
||||||
|
"extensions": [
|
||||||
|
".js",
|
||||||
|
".jsx",
|
||||||
|
".ts",
|
||||||
|
".tsx"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
1
.github/PROTECTED_BRANCHES
vendored
Normal file
1
.github/PROTECTED_BRANCHES
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
main
|
||||||
35
.github/workflows/build-checks.yml
vendored
Normal file
35
.github/workflows/build-checks.yml
vendored
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
name: Release Checks
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
github-publish:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
|
||||||
|
- name: Checkout Repository & Submo
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
|
- name: Setup Node
|
||||||
|
uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: '16'
|
||||||
|
cache: 'npm'
|
||||||
|
cache-dependency-path: '**/package-lock.json'
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm install
|
||||||
|
|
||||||
|
# TODO: Finish fixing eslint issues
|
||||||
|
# - name: Run ESLint check
|
||||||
|
# run: npm run lint:ci
|
||||||
|
|
||||||
|
- name: Run Test & Coverage check
|
||||||
|
run: npm run test
|
||||||
|
|
||||||
24
.github/workflows/build_pr.yml
vendored
24
.github/workflows/build_pr.yml
vendored
@@ -27,16 +27,30 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
node-version: "16"
|
node-version: "16"
|
||||||
|
|
||||||
- name: Build TS SDK
|
- name: Build PMS SDK
|
||||||
id: buildTS
|
id: buildPMS
|
||||||
run: |
|
run: |
|
||||||
rm -rf plexjs/
|
rm -rf plexjs/pms
|
||||||
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
|
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: Run npm install and build Typescript SDK
|
- name: Run npm install and build Typescript SDK
|
||||||
id: buildSDK
|
id: buildSDK
|
||||||
if: steps.buildTS.outcome == 'success'
|
if: steps.buildPTV.outcome == 'success'
|
||||||
run: |
|
run: |
|
||||||
cd plexjs
|
cd plexjs
|
||||||
npm install
|
npm install
|
||||||
npm run build
|
npm run build
|
||||||
|
|
||||||
|
- name: Archive test build
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: PR-Build-${{ github.ref }}
|
||||||
|
path: |
|
||||||
|
plexjs
|
||||||
|
|||||||
52
.github/workflows/bump_version.yml
vendored
52
.github/workflows/bump_version.yml
vendored
@@ -1,5 +1,7 @@
|
|||||||
name: "Update Typescript SDK Version"
|
name: "Update Typescript SDK Version"
|
||||||
|
|
||||||
|
run-name: Update Typescript SDK Version to ${{ github.event.inputs.version }}
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
@@ -53,22 +55,46 @@ jobs:
|
|||||||
- name: Update config files with new version
|
- name: Update config files with new version
|
||||||
id: updateVersion
|
id: updateVersion
|
||||||
run: |
|
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
|
## Update package.json file with new version
|
||||||
id: buildTS
|
- name: Update package.json version
|
||||||
|
id: updatePackageJsonVersion
|
||||||
|
if: steps.updateVersion.outcome == 'success'
|
||||||
run: |
|
run: |
|
||||||
rm -rf plexjs/
|
LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`)
|
||||||
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
|
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
|
- name: After SDK Build
|
||||||
id: buildSDK
|
id: buildSDK
|
||||||
if: steps.buildTS.outcome == 'success'
|
if: steps.buildPTV.outcome == 'success'
|
||||||
run: |
|
run: |
|
||||||
cd plexjs
|
cd plexjs
|
||||||
npm install
|
npm install
|
||||||
npm run build
|
npm run build
|
||||||
|
|
||||||
|
- name: Publish to NPM
|
||||||
|
id: publish
|
||||||
|
uses: JS-DevTools/npm-publish@v1
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.NPM_TOKEN }}
|
||||||
|
package: ./plexjs/package.json
|
||||||
|
|
||||||
- name: Commit changes and create new version tag
|
- name: Commit changes and create new version tag
|
||||||
if: steps.buildSDK.outcome == 'success'
|
if: steps.buildSDK.outcome == 'success'
|
||||||
uses: stefanzweifel/git-auto-commit-action@v4
|
uses: stefanzweifel/git-auto-commit-action@v4
|
||||||
@@ -86,17 +112,3 @@ jobs:
|
|||||||
release_name: ${{ github.event.inputs.version }}
|
release_name: ${{ github.event.inputs.version }}
|
||||||
draft: false
|
draft: false
|
||||||
prerelease: false
|
prerelease: false
|
||||||
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- uses: actions/setup-node@v3
|
|
||||||
with:
|
|
||||||
node-version: 12
|
|
||||||
- run: |
|
|
||||||
cd plexjs
|
|
||||||
npm ci
|
|
||||||
|
|
||||||
- id: publish
|
|
||||||
uses: JS-DevTools/npm-publish@v1
|
|
||||||
with:
|
|
||||||
token: ${{ secrets.NPM_TOKEN }}
|
|
||||||
package: ./plexjs/package.json
|
|
||||||
|
|||||||
28
.github/workflows/pr-checks.yml
vendored
Normal file
28
.github/workflows/pr-checks.yml
vendored
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
name: Pull Request Checks
|
||||||
|
|
||||||
|
on: [pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
linting-and-testing:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Setup Node
|
||||||
|
uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: '16'
|
||||||
|
cache: 'npm'
|
||||||
|
cache-dependency-path: '**/package-lock.json'
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm install
|
||||||
|
|
||||||
|
# TODO: Finish fixing eslint issues
|
||||||
|
# - name: Run ESLint check
|
||||||
|
# run: npm run lint:ci
|
||||||
|
|
||||||
|
- name: Run Test & Coverage check
|
||||||
|
run: npm run test
|
||||||
32
.github/workflows/release-checks.yml
vendored
Normal file
32
.github/workflows/release-checks.yml
vendored
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
name: Release Checks
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [created]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: '16'
|
||||||
|
cache: 'npm'
|
||||||
|
- run: npm ci
|
||||||
|
- run: npm run test
|
||||||
|
|
||||||
|
npm-publish:
|
||||||
|
needs: build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: '16'
|
||||||
|
registry-url: https://registry.npmjs.org/
|
||||||
|
- run: npm ci
|
||||||
|
- run: npm publish
|
||||||
|
env:
|
||||||
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
|
|
||||||
73
.github/workflows/test-oag-ver.yml
vendored
Normal file
73
.github/workflows/test-oag-ver.yml
vendored
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
name: "Test open api generator version"
|
||||||
|
|
||||||
|
run-name: "Test open api generator version ${{ github.event.inputs.version }}"
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
version:
|
||||||
|
description: The version of the OpenAPI Generator to test
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
push_spec_workflow:
|
||||||
|
name: Build TypeScript SDK
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
# Checkout the master branch request to run rsync
|
||||||
|
- name: Checkout PR branch
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
ref: ${{ github.ref }}
|
||||||
|
|
||||||
|
# Checkout the main branch of api-specs
|
||||||
|
- name: Checkout API Specs Repo
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
repository: lukehagar/plex-api-spec
|
||||||
|
path: api-specs
|
||||||
|
ref: main
|
||||||
|
|
||||||
|
- name: Set up Node
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: "16"
|
||||||
|
|
||||||
|
- name: Install OpenAPI Generator
|
||||||
|
run: |
|
||||||
|
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/${{ github.event.inputs.version }}/openapi-generator-cli-${{ github.event.inputs.version }}.jar -O openapi-generator-cli.jar
|
||||||
|
|
||||||
|
- 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 --config sdk-resources/pms-config-test.yaml
|
||||||
|
|
||||||
|
- name: Build PTV SDK
|
||||||
|
id: buildPTV
|
||||||
|
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 --config sdk-resources/plextv-config-test.yaml
|
||||||
|
|
||||||
|
- name: Archive test build
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: OAG-${{ github.event.inputs.version }}-test-build
|
||||||
|
path: |
|
||||||
|
plexjs/pms
|
||||||
|
plexjs/plextv
|
||||||
|
|
||||||
|
- name: Run npm install and build Typescript SDK
|
||||||
|
id: testPMS
|
||||||
|
if: steps.buildPMS.outcome == 'success'
|
||||||
|
run: |
|
||||||
|
cd plexjs/pms
|
||||||
|
npm install
|
||||||
|
npm run build
|
||||||
|
|
||||||
|
- name: Run npm install and build Typescript SDK
|
||||||
|
id: testPTV
|
||||||
|
if: steps.buildPTV.outcome == 'success'
|
||||||
|
run: |
|
||||||
|
cd plexjs/plextv
|
||||||
|
npm install
|
||||||
|
npm run build
|
||||||
135
.gitignore
vendored
135
.gitignore
vendored
@@ -1,5 +1,132 @@
|
|||||||
node_modules
|
# Logs
|
||||||
build
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
.pnpm-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/
|
||||||
|
|
||||||
|
# Snowpack dependency directory (https://snowpack.dev/)
|
||||||
|
web_modules/
|
||||||
|
|
||||||
|
# TypeScript cache
|
||||||
|
*.tsbuildinfo
|
||||||
|
|
||||||
|
# Optional npm cache directory
|
||||||
|
.npm
|
||||||
|
|
||||||
|
# Optional eslint cache
|
||||||
|
.eslintcache
|
||||||
|
|
||||||
|
# Optional stylelint cache
|
||||||
|
.stylelintcache
|
||||||
|
|
||||||
|
# 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 variable files
|
||||||
|
.env
|
||||||
|
.env.development.local
|
||||||
|
.env.test.local
|
||||||
|
.env.production.local
|
||||||
|
.env.local
|
||||||
|
|
||||||
|
# parcel-bundler cache (https://parceljs.org/)
|
||||||
|
.cache
|
||||||
|
.parcel-cache
|
||||||
|
|
||||||
|
# Next.js build output
|
||||||
|
.next
|
||||||
|
out
|
||||||
|
|
||||||
|
# Nuxt.js build / generate output
|
||||||
|
.nuxt
|
||||||
dist
|
dist
|
||||||
api-specs
|
|
||||||
.env
|
# 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
|
||||||
|
|
||||||
|
# vuepress v2.x temp and cache directory
|
||||||
|
.temp
|
||||||
|
.cache
|
||||||
|
|
||||||
|
# Docusaurus cache and generated files
|
||||||
|
.docusaurus
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# yarn v2
|
||||||
|
.yarn/cache
|
||||||
|
.yarn/unplugged
|
||||||
|
.yarn/build-state.yml
|
||||||
|
.yarn/install-state.gz
|
||||||
|
.pnp.*
|
||||||
|
|
||||||
|
.parcel-cache
|
||||||
|
|||||||
26
.prettierrc.json
Normal file
26
.prettierrc.json
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"printWidth": 100,
|
||||||
|
"tabWidth": 2,
|
||||||
|
"useTabs": false,
|
||||||
|
"semi": true,
|
||||||
|
"singleQuote": true,
|
||||||
|
"quoteProps": "as-needed",
|
||||||
|
"jsxSingleQuote": false,
|
||||||
|
"trailingComma": "all",
|
||||||
|
"bracketSpacing": true,
|
||||||
|
"arrowParens": "always",
|
||||||
|
"overrides": [
|
||||||
|
{
|
||||||
|
"files": ".editorconfig",
|
||||||
|
"options": {
|
||||||
|
"parser": "yaml"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"files": "LICENSE",
|
||||||
|
"options": {
|
||||||
|
"parser": "markdown"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
19
LICENSE
Normal file
19
LICENSE
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
Copyright (c) 2023
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||||
|
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
|
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
|
||||||
|
OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
12
config.yaml
12
config.yaml
@@ -1,12 +0,0 @@
|
|||||||
templateDir: ./sdk-resources
|
|
||||||
files:
|
|
||||||
package.mustache:
|
|
||||||
templateType: SupportingFiles
|
|
||||||
destinationFilename: package.json
|
|
||||||
npmName: plexjs
|
|
||||||
npmRepository: lukehagar
|
|
||||||
npmVersion: 0.0.13
|
|
||||||
useSingleRequestParameter: true
|
|
||||||
sortParamsByRequiredFlag: true
|
|
||||||
gitUserID: lukehagar
|
|
||||||
gitRepoID: plexjs
|
|
||||||
1
examples/.env.example
Normal file
1
examples/.env.example
Normal file
@@ -0,0 +1 @@
|
|||||||
|
PLEXSDK_TOKEN=
|
||||||
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
|
||||||
23
examples/README.md
Normal file
23
examples/README.md
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# @lukehagar/plexjs-example
|
||||||
|
A basic example of how to use the @lukehagar/plexjs package.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
In the event `@lukehagar/plexjs` is not published to npm, you can install it locally by running the following command in the examples folder:
|
||||||
|
```sh
|
||||||
|
npm run setup
|
||||||
|
```
|
||||||
|
|
||||||
|
This will rebuild the parent package and install it locally.
|
||||||
|
|
||||||
|
Otherwise you can install it from npm:
|
||||||
|
```sh
|
||||||
|
npm install @lukehagar/plexjs
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
To run the example, run the following command in the examples folder:
|
||||||
|
```sh
|
||||||
|
npm run start
|
||||||
|
```
|
||||||
@@ -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,18 @@
|
|||||||
{
|
{
|
||||||
"name": "examples",
|
"name": "@lukehagar/plexjs-example",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "Examples using the plexjs package",
|
"private": true,
|
||||||
"main": "index.js",
|
"dependencies": {
|
||||||
"scripts": {
|
"@lukehagar/plexjs": "file:../"
|
||||||
"dev": "npx ts-node index.ts",
|
},
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"scripts": {
|
||||||
|
"setup": "npm --prefix ../ install && npm --prefix ../ run build && npm install",
|
||||||
|
"start": "tsc && node -r dotenv/config dist/index.js",
|
||||||
|
"dev": "ts-node src/index.ts"
|
||||||
},
|
},
|
||||||
"author": "lukehagar",
|
|
||||||
"license": "MIT",
|
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@lukehagar/plexjs": "^0.0.7"
|
"ts-node": "^10.9.1",
|
||||||
|
"typescript": "4.8.4",
|
||||||
|
"dotenv": "^8.2.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
8
examples/src/index.ts
Normal file
8
examples/src/index.ts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import { PlexSDK } from '@lukehagar/plexjs';
|
||||||
|
|
||||||
|
const sdk = new PlexSDK({ apiKey: process.env.PLEXSDK_API_KEY_TOKEN });
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
const result = await sdk.server.getServerCapabilities();
|
||||||
|
console.log(result.data);
|
||||||
|
})();
|
||||||
103
examples/tsconfig.json
Normal file
103
examples/tsconfig.json
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
/* Visit https://aka.ms/tsconfig to read more about this file */
|
||||||
|
|
||||||
|
/* Projects */
|
||||||
|
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
|
||||||
|
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
|
||||||
|
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
|
||||||
|
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
|
||||||
|
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
|
||||||
|
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
||||||
|
|
||||||
|
/* Language and Environment */
|
||||||
|
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
||||||
|
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
||||||
|
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
||||||
|
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
|
||||||
|
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
||||||
|
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
|
||||||
|
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
|
||||||
|
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
|
||||||
|
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
|
||||||
|
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
|
||||||
|
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
||||||
|
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
||||||
|
|
||||||
|
/* Modules */
|
||||||
|
"module": "commonjs", /* Specify what module code is generated. */
|
||||||
|
"rootDir": "./src", /* Specify the root folder within your source files. */
|
||||||
|
// "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
|
||||||
|
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
||||||
|
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
||||||
|
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
||||||
|
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
|
||||||
|
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
||||||
|
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
||||||
|
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
||||||
|
// "resolveJsonModule": true, /* Enable importing .json files. */
|
||||||
|
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
|
||||||
|
|
||||||
|
/* JavaScript Support */
|
||||||
|
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
|
||||||
|
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
|
||||||
|
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
||||||
|
|
||||||
|
/* Emit */
|
||||||
|
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
||||||
|
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
||||||
|
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
||||||
|
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
||||||
|
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
||||||
|
"outDir": "./dist", /* Specify an output folder for all emitted files. */
|
||||||
|
// "removeComments": true, /* Disable emitting comments. */
|
||||||
|
// "noEmit": true, /* Disable emitting files from a compilation. */
|
||||||
|
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
||||||
|
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
|
||||||
|
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
||||||
|
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
||||||
|
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
||||||
|
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
||||||
|
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
||||||
|
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
||||||
|
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
||||||
|
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
|
||||||
|
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
|
||||||
|
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
||||||
|
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
|
||||||
|
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
||||||
|
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
|
||||||
|
|
||||||
|
/* Interop Constraints */
|
||||||
|
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
||||||
|
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
||||||
|
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
|
||||||
|
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
||||||
|
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
|
||||||
|
|
||||||
|
/* Type Checking */
|
||||||
|
"strict": true, /* Enable all strict type-checking options. */
|
||||||
|
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
|
||||||
|
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
|
||||||
|
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
||||||
|
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
|
||||||
|
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
||||||
|
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
|
||||||
|
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
|
||||||
|
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
||||||
|
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
|
||||||
|
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
|
||||||
|
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
||||||
|
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
||||||
|
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
||||||
|
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
|
||||||
|
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
||||||
|
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
|
||||||
|
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
||||||
|
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
||||||
|
|
||||||
|
/* Completeness */
|
||||||
|
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
||||||
|
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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
2
install.sh
Normal file
2
install.sh
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
npm install
|
||||||
|
npm run test
|
||||||
4
jest.config.json
Normal file
4
jest.config.json
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"preset": "ts-jest",
|
||||||
|
"testEnvironment": "node"
|
||||||
|
}
|
||||||
Binary file not shown.
6197
package-lock.json
generated
Normal file
6197
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
57
package.json
Normal file
57
package.json
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
{
|
||||||
|
"source": "./src/index.ts",
|
||||||
|
"exports": {
|
||||||
|
"require": "./dist/commonjs/index.js",
|
||||||
|
"types": "./dist/commonjs/index.d.ts",
|
||||||
|
"default": "./dist/esm/index.js"
|
||||||
|
},
|
||||||
|
"main": "./dist/commonjs/index.js",
|
||||||
|
"module": "./dist/esm/index.js",
|
||||||
|
"browser": "./dist/index.umd.js",
|
||||||
|
"unpkg": "./dist/index.umd.js",
|
||||||
|
"types": "./dist/commonjs/index.d.ts",
|
||||||
|
"files": [
|
||||||
|
"dist",
|
||||||
|
"README.md"
|
||||||
|
],
|
||||||
|
"devDependencies": {
|
||||||
|
"@typescript-eslint/eslint-plugin": "^5.43.0",
|
||||||
|
"@typescript-eslint/parser": "^5.43.0",
|
||||||
|
"@types/node": "^17.0.23",
|
||||||
|
"@types/jest": "^29.5.6",
|
||||||
|
"eslint": "^8.20.0",
|
||||||
|
"eslint-config-airbnb-base": "^15.0.0",
|
||||||
|
"eslint-config-airbnb-typescript": "^17.0.0",
|
||||||
|
"eslint-config-prettier": "^8.5.0",
|
||||||
|
"eslint-plugin-import": "^2.26.0",
|
||||||
|
"eslint-plugin-prettier": "^4.2.1",
|
||||||
|
"jest": "^29.7.0",
|
||||||
|
"nock": "^13.2.4",
|
||||||
|
"prettier": "^2.6.2",
|
||||||
|
"ts-jest": "^29.1.1",
|
||||||
|
"typescript": "4.8.4"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"build": "npm run build:all",
|
||||||
|
"build:cjs": "tsc --module commonjs --outDir dist/commonjs",
|
||||||
|
"build:esm": "tsc --module esnext --outDir dist/esm",
|
||||||
|
"build:umd": "tsc --module umd --outDir dist/umd",
|
||||||
|
"build:all": "npm run build:cjs && npm run build:esm && npm run build:umd",
|
||||||
|
"lint": "eslint --ext .ts,.js ./src/ --resolve-plugins-relative-to .",
|
||||||
|
"lint:ci": "eslint --ext .ts,.js ./src/ --resolve-plugins-relative-to . --cache --quiet",
|
||||||
|
"lint:fix": "eslint --ext .ts,.js ./src/ --resolve-plugins-relative-to . --cache --fix",
|
||||||
|
"rebuild": "rm -rf dist/ && tsc",
|
||||||
|
"test": "jest --detectOpenHandles",
|
||||||
|
"watch": "rm -rf dist/ && tsc -w",
|
||||||
|
"version": "tsc --version",
|
||||||
|
"prepublishOnly": "npm run build"
|
||||||
|
},
|
||||||
|
"name": "@lukehagar/plexjs",
|
||||||
|
"description": "PlexSDK - An Open API Spec for interacting with Plex.tv and Plex Servers",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"author": "Luke Hagar <lukeslakemail@gmail.com>",
|
||||||
|
"dependencies": {
|
||||||
|
"axios": "^1.5.1"
|
||||||
|
},
|
||||||
|
"license": "MIT"
|
||||||
|
}
|
||||||
4
plexjs/.gitignore
vendored
4
plexjs/.gitignore
vendored
@@ -1,4 +0,0 @@
|
|||||||
wwwroot/*.js
|
|
||||||
node_modules
|
|
||||||
typings
|
|
||||||
dist
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
# empty npmignore to ensure all required files (e.g., in the dist folder) are published by npm
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
# 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
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
.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 +0,0 @@
|
|||||||
6.3.0
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
## plexjs@0.0.13
|
|
||||||
|
|
||||||
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.13 --save
|
|
||||||
```
|
|
||||||
|
|
||||||
_unPublished (not recommended):_
|
|
||||||
|
|
||||||
```
|
|
||||||
npm install PATH_TO_GENERATED_PACKAGE --save
|
|
||||||
5250
plexjs/api.ts
5250
plexjs/api.ts
File diff suppressed because it is too large
Load Diff
@@ -1,71 +0,0 @@
|
|||||||
/* 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 { Configuration } from "./configuration";
|
|
||||||
// Some imports not used depending on template conditions
|
|
||||||
// @ts-ignore
|
|
||||||
import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios';
|
|
||||||
|
|
||||||
export const BASE_PATH = "http://10.10.10.47:32400".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 = configuration.basePath || 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/common.ts
105
plexjs/common.ts
@@ -1,105 +0,0 @@
|
|||||||
/* 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 { 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);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,86 +0,0 @@
|
|||||||
/* 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 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');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
#!/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'
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
/* 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 * from "./configuration";
|
|
||||||
|
|
||||||
157
plexjs/package-lock.json
generated
157
plexjs/package-lock.json
generated
@@ -1,157 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "@lukehagar/plexjs",
|
|
||||||
"version": "0.0.13",
|
|
||||||
"lockfileVersion": 2,
|
|
||||||
"requires": true,
|
|
||||||
"packages": {
|
|
||||||
"": {
|
|
||||||
"name": "@lukehagar/plexjs",
|
|
||||||
"version": "0.0.13",
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"axios": "^0.26.1",
|
|
||||||
"axios-retry": "^3.4.0"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@types/node": "^12.11.5",
|
|
||||||
"typescript": "^4.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"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==",
|
|
||||||
"dependencies": {
|
|
||||||
"regenerator-runtime": "^0.13.11"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=6.9.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@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
|
|
||||||
},
|
|
||||||
"node_modules/axios": {
|
|
||||||
"version": "0.26.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/axios/-/axios-0.26.1.tgz",
|
|
||||||
"integrity": "sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==",
|
|
||||||
"dependencies": {
|
|
||||||
"follow-redirects": "^1.14.8"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"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==",
|
|
||||||
"dependencies": {
|
|
||||||
"@babel/runtime": "^7.15.4",
|
|
||||||
"is-retry-allowed": "^2.2.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/follow-redirects": {
|
|
||||||
"version": "1.15.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz",
|
|
||||||
"integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==",
|
|
||||||
"funding": [
|
|
||||||
{
|
|
||||||
"type": "individual",
|
|
||||||
"url": "https://github.com/sponsors/RubenVerborgh"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">=4.0"
|
|
||||||
},
|
|
||||||
"peerDependenciesMeta": {
|
|
||||||
"debug": {
|
|
||||||
"optional": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/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==",
|
|
||||||
"engines": {
|
|
||||||
"node": ">=10"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/sindresorhus"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/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=="
|
|
||||||
},
|
|
||||||
"node_modules/typescript": {
|
|
||||||
"version": "4.9.5",
|
|
||||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz",
|
|
||||||
"integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==",
|
|
||||||
"dev": true,
|
|
||||||
"bin": {
|
|
||||||
"tsc": "bin/tsc",
|
|
||||||
"tsserver": "bin/tsserver"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"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,39 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "@lukehagar/plexjs",
|
|
||||||
"version": "0.0.13",
|
|
||||||
"description": "Community Made Plex JS/TS Module",
|
|
||||||
"author": "Luke Hagar",
|
|
||||||
"type": "module",
|
|
||||||
"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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"declaration": true,
|
|
||||||
"target": "ES5",
|
|
||||||
"module": "CommonJS",
|
|
||||||
"noImplicitAny": true,
|
|
||||||
"outDir": "./dist",
|
|
||||||
"rootDir": ".",
|
|
||||||
"lib": [
|
|
||||||
"es6",
|
|
||||||
"dom"
|
|
||||||
],
|
|
||||||
"typeRoots": [
|
|
||||||
"node_modules/@types"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"exclude": [
|
|
||||||
"dist",
|
|
||||||
"node_modules"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
11
readme.md
11
readme.md
@@ -1,11 +0,0 @@
|
|||||||
# Plex API Client
|
|
||||||
|
|
||||||
## Description
|
|
||||||
|
|
||||||
A typescript sdk for accessing the Plex.tv and Plex Media Server REST API's.
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npm install plexjs
|
|
||||||
```
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
## {{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
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
/* 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}}
|
|
||||||
@@ -1,371 +0,0 @@
|
|||||||
{{#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}}
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
/* 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 = configuration.basePath || this.basePath;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @export
|
|
||||||
* @class RequiredError
|
|
||||||
* @extends {Error}
|
|
||||||
*/
|
|
||||||
export class RequiredError extends Error {
|
|
||||||
name: "RequiredError" = "RequiredError";
|
|
||||||
constructor(public field: string, msg?: string) {
|
|
||||||
super(msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,97 +0,0 @@
|
|||||||
/* 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);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -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');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
#!/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'
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
wwwroot/*.js
|
|
||||||
node_modules
|
|
||||||
typings
|
|
||||||
dist
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
{{>licenseInfo}}
|
|
||||||
|
|
||||||
export * from "./api";
|
|
||||||
export * from "./configuration";
|
|
||||||
{{#withSeparateModelsAndApi}}export * from "./{{tsModelPackage}}";{{/withSeparateModelsAndApi}}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
/**
|
|
||||||
* {{{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.
|
|
||||||
*/
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
/* 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}}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
/**
|
|
||||||
* @type {{classname}}{{#description}}
|
|
||||||
* {{{.}}}{{/description}}
|
|
||||||
* @export
|
|
||||||
*/
|
|
||||||
export type {{classname}} = {{#allOf}}{{{.}}}{{^-last}} & {{/-last}}{{/allOf}};
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
/**
|
|
||||||
* {{{description}}}
|
|
||||||
* @export
|
|
||||||
* @enum {string}
|
|
||||||
*/
|
|
||||||
{{#isBoolean}}
|
|
||||||
export type {{classname}} = {{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}} | {{/-last}}{{/enumVars}}{{/allowableValues}}
|
|
||||||
{{/isBoolean}}
|
|
||||||
|
|
||||||
{{^isBoolean}}
|
|
||||||
{{^stringEnums}}
|
|
||||||
{{>modelObjectEnum}}
|
|
||||||
{{/stringEnums}}
|
|
||||||
{{#stringEnums}}
|
|
||||||
{{>modelStringEnum}}
|
|
||||||
{{/stringEnums}}
|
|
||||||
{{/isBoolean}}
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
/**
|
|
||||||
* {{{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}}
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
{{#models}}{{#model}}export * from './{{classFilename}}';{{/model}}
|
|
||||||
{{/models}}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
export const {{classname}} = {
|
|
||||||
{{#allowableValues}}
|
|
||||||
{{#enumVars}}
|
|
||||||
{{#enumDescription}}
|
|
||||||
/**
|
|
||||||
* {{.}}
|
|
||||||
*/
|
|
||||||
{{/enumDescription}}
|
|
||||||
{{{name}}}: {{{value}}}{{^-last}},{{/-last}}
|
|
||||||
{{/enumVars}}
|
|
||||||
{{/allowableValues}}
|
|
||||||
} as const;
|
|
||||||
|
|
||||||
export type {{classname}} = typeof {{classname}}[keyof typeof {{classname}}];
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
/**
|
|
||||||
* @type {{classname}}{{#description}}
|
|
||||||
* {{{.}}}{{/description}}
|
|
||||||
* @export
|
|
||||||
*/
|
|
||||||
export type {{classname}} = {{#oneOf}}{{{.}}}{{^-last}} | {{/-last}}{{/oneOf}};
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
export enum {{classname}} {
|
|
||||||
{{#allowableValues}}
|
|
||||||
{{#enumVars}}
|
|
||||||
{{#enumDescription}}
|
|
||||||
/**
|
|
||||||
* {{.}}
|
|
||||||
*/
|
|
||||||
{{/enumDescription}}
|
|
||||||
{{{name}}} = {{{value}}}{{^-last}},{{/-last}}
|
|
||||||
{{/enumVars}}
|
|
||||||
{{/allowableValues}}
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
# empty npmignore to ensure all required files (e.g., in the dist folder) are published by npm
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "@lukehagar/plexjs",
|
|
||||||
"version": "{{npmVersion}}",
|
|
||||||
"description": "Community Made Plex JS/TS Module",
|
|
||||||
"author": "Luke Hagar",
|
|
||||||
"type": "module",
|
|
||||||
"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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
{
|
|
||||||
"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"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"exclude": [
|
|
||||||
"dist",
|
|
||||||
"node_modules"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
47
src/BaseService.ts
Normal file
47
src/BaseService.ts
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
import { Environment } from './http/Environment';
|
||||||
|
import HTTPLibrary from './http/HTTPLibrary';
|
||||||
|
import { Headers } from './http/HTTPClient';
|
||||||
|
|
||||||
|
export default class BaseService {
|
||||||
|
public baseUrl: string = Environment.DEFAULT;
|
||||||
|
|
||||||
|
public httpClient = new HTTPLibrary();
|
||||||
|
|
||||||
|
private apiKey: string = '';
|
||||||
|
|
||||||
|
private apiKeyHeader: string = 'X-Plex-Token';
|
||||||
|
|
||||||
|
setApiKey(key: string, header: string = 'X-Plex-Token'): void {
|
||||||
|
this.apiKey = key;
|
||||||
|
this.apiKeyHeader = header;
|
||||||
|
}
|
||||||
|
|
||||||
|
getAuthorizationHeader(): Headers {
|
||||||
|
const apiKeyAuth = { [this.apiKeyHeader]: this.apiKey };
|
||||||
|
|
||||||
|
return { ...apiKeyAuth };
|
||||||
|
}
|
||||||
|
|
||||||
|
setBaseUrl(url: string): void {
|
||||||
|
this.baseUrl = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(apiKey: string = '', apiKeyHeader: string = 'X-Plex-Token') {
|
||||||
|
this.setApiKey(apiKey, apiKeyHeader);
|
||||||
|
}
|
||||||
|
|
||||||
|
static patternMatching(value: string, pattern: string, variableName: string): string {
|
||||||
|
if (!value) {
|
||||||
|
throw new Error(`${variableName} cannot be null or undefined`);
|
||||||
|
}
|
||||||
|
if (!value.match(new RegExp(pattern))) {
|
||||||
|
throw new Error(`Invalid value for ${variableName}: must match ${pattern}`);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
static urlEncode = (input: { [key: string]: any }): string =>
|
||||||
|
Object.keys(input)
|
||||||
|
.map((key) => `${key}=${encodeURIComponent(input[key])}`)
|
||||||
|
.join('&');
|
||||||
|
}
|
||||||
28
src/hooks/Hook.ts
Normal file
28
src/hooks/Hook.ts
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
export interface Request {
|
||||||
|
method: string;
|
||||||
|
url: string;
|
||||||
|
input?: object;
|
||||||
|
headers: object;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Response {
|
||||||
|
data: object;
|
||||||
|
headers: object;
|
||||||
|
status: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Exception extends Error {
|
||||||
|
title: string;
|
||||||
|
type?: string;
|
||||||
|
detail?: string;
|
||||||
|
instance?: string;
|
||||||
|
statusCode: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Hook {
|
||||||
|
beforeRequest(request: Request): Promise<void>;
|
||||||
|
|
||||||
|
afterResponse(request: Request, response: Response): Promise<void>;
|
||||||
|
|
||||||
|
onError(error: Exception): Promise<void>;
|
||||||
|
}
|
||||||
3
src/http/Environment.ts
Normal file
3
src/http/Environment.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export enum Environment {
|
||||||
|
DEFAULT = 'http://10.10.10.47:32400',
|
||||||
|
}
|
||||||
12
src/http/HTTPClient.ts
Normal file
12
src/http/HTTPClient.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
export interface Headers extends Record<string, string> {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines the basic operations for an HTTP client.
|
||||||
|
*/
|
||||||
|
export default interface HTTPClient {
|
||||||
|
get(url: string, input: any, headers: Headers, retry?: boolean): Promise<any>;
|
||||||
|
post(url: string, input: any, headers: Headers, retry?: boolean): Promise<any>;
|
||||||
|
delete(url: string, input: any, headers: Headers, retry?: boolean): Promise<any>;
|
||||||
|
put(url: string, input: any, headers: Headers, retry?: boolean): Promise<any>;
|
||||||
|
patch(url: string, input: any, headers: Headers, retry?: boolean): Promise<any>;
|
||||||
|
}
|
||||||
161
src/http/HTTPLibrary.ts
Normal file
161
src/http/HTTPLibrary.ts
Normal file
@@ -0,0 +1,161 @@
|
|||||||
|
import axios, { AxiosError } from 'axios';
|
||||||
|
|
||||||
|
import HTTPClient, { Headers } from './HTTPClient';
|
||||||
|
import throwHttpError from './httpExceptions';
|
||||||
|
|
||||||
|
export default class HTTPLibrary implements HTTPClient {
|
||||||
|
readonly userAgentHeader: Headers = {
|
||||||
|
'User-Agent': 'liblab/0.1.25 PlexSDK/0.0.1 typescript/5.2.2',
|
||||||
|
};
|
||||||
|
|
||||||
|
readonly retryAttempts: number = 3;
|
||||||
|
|
||||||
|
readonly retryDelayMs: number = 150;
|
||||||
|
|
||||||
|
private static readonly responseMapper: Map<string, string> = new Map<string, string>([
|
||||||
|
['type', 'type_'],
|
||||||
|
['default', 'default_'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
private readonly requestMapper: Map<string, string> = new Map<string, string>([
|
||||||
|
['type_', 'type'],
|
||||||
|
['default_', 'default'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
async get(url: string, input: any, headers: Headers, retry: boolean = false): Promise<any> {
|
||||||
|
const request = () =>
|
||||||
|
axios.get(url, {
|
||||||
|
headers: { ...headers, ...this.getUserAgentHeader() },
|
||||||
|
data:
|
||||||
|
Object.keys(input).length > 0
|
||||||
|
? HTTPLibrary.convertKeysWithMapper(input, this.requestMapper)
|
||||||
|
: undefined,
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = retry
|
||||||
|
? await this.retry(this.retryAttempts, request, this.retryDelayMs)
|
||||||
|
: await request();
|
||||||
|
return HTTPLibrary.handleResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
async post(url: string, input: any, headers: Headers, retry: boolean = false): Promise<any> {
|
||||||
|
const request = () =>
|
||||||
|
axios.post(url, HTTPLibrary.convertKeysWithMapper(input, this.requestMapper), {
|
||||||
|
headers: { ...headers, ...this.getUserAgentHeader() },
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = retry
|
||||||
|
? await this.retry(this.retryAttempts, request, this.retryDelayMs)
|
||||||
|
: await request();
|
||||||
|
|
||||||
|
return HTTPLibrary.handleResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
async delete(url: string, input: any, headers: Headers, retry: boolean = false): Promise<any> {
|
||||||
|
const request = () =>
|
||||||
|
axios.delete(url, {
|
||||||
|
headers: { ...headers, ...this.getUserAgentHeader() },
|
||||||
|
data: HTTPLibrary.convertKeysWithMapper(input, this.requestMapper),
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = retry
|
||||||
|
? await this.retry(this.retryAttempts, request, this.retryDelayMs)
|
||||||
|
: await request();
|
||||||
|
|
||||||
|
return HTTPLibrary.handleResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
async put(url: string, input: any, headers: Headers, retry: boolean = false): Promise<any> {
|
||||||
|
const request = () =>
|
||||||
|
axios.put(url, HTTPLibrary.convertKeysWithMapper(input, this.requestMapper), {
|
||||||
|
headers: { ...headers, ...this.getUserAgentHeader() },
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = retry
|
||||||
|
? await this.retry(this.retryAttempts, request, this.retryDelayMs)
|
||||||
|
: await request();
|
||||||
|
|
||||||
|
return HTTPLibrary.handleResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
async patch(url: string, input: any, headers: Headers, retry: boolean = false): Promise<any> {
|
||||||
|
const request = () =>
|
||||||
|
axios.patch(url, HTTPLibrary.convertKeysWithMapper(input, this.requestMapper), {
|
||||||
|
headers: { ...headers, ...this.getUserAgentHeader() },
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = retry
|
||||||
|
? await this.retry(this.retryAttempts, request, this.retryDelayMs)
|
||||||
|
: await request();
|
||||||
|
|
||||||
|
return HTTPLibrary.handleResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
async retry(retries: number, callbackFn: () => any, delay: number): Promise<any> {
|
||||||
|
let result: any;
|
||||||
|
|
||||||
|
try {
|
||||||
|
result = await callbackFn();
|
||||||
|
} catch (e: any) {
|
||||||
|
if ((e as AxiosError).isAxiosError) {
|
||||||
|
if (e.response) {
|
||||||
|
if (![500, 503, 504].includes(e.response.status)) {
|
||||||
|
return e.response;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (retries > 1) {
|
||||||
|
// eslint-disable-next-line no-promise-executor-return
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, delay));
|
||||||
|
result = await this.retry(retries - 1, callbackFn, delay * 2);
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static handleResponse(response: any) {
|
||||||
|
if (response.status >= 400) {
|
||||||
|
throwHttpError(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
response.data = HTTPLibrary.convertKeysWithMapper(response.data, this.responseMapper);
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
private getUserAgentHeader(): Headers {
|
||||||
|
if (typeof window !== 'undefined') {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
return this.userAgentHeader;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*Converts keys in an object using a provided JSON mapper.
|
||||||
|
* @param {any} obj - The object to convert keys for.
|
||||||
|
* @param {Object} jsonMapper - The JSON mapper containing key mappings.
|
||||||
|
* @returns {any} - The object with converted keys.
|
||||||
|
*/
|
||||||
|
private static convertKeysWithMapper<T>(obj: T, jsonMapper: Map<string, string>): any {
|
||||||
|
if (!obj || typeof obj !== 'object') {
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Array.isArray(obj)) {
|
||||||
|
return obj.map((item) => HTTPLibrary.convertKeysWithMapper(item, jsonMapper));
|
||||||
|
}
|
||||||
|
|
||||||
|
const convertedObj: Record<string, any> = {};
|
||||||
|
Object.entries(obj).forEach(([key, value]) => {
|
||||||
|
if (value !== undefined) {
|
||||||
|
const convertedKey = jsonMapper.get(key) || key;
|
||||||
|
convertedObj[convertedKey] = HTTPLibrary.convertKeysWithMapper(value, jsonMapper);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return convertedObj;
|
||||||
|
}
|
||||||
|
}
|
||||||
82
src/http/QuerySerializer.ts
Normal file
82
src/http/QuerySerializer.ts
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
export type Explode = boolean;
|
||||||
|
export type QueryStyles = 'form' | 'spaceDelimited' | 'pipeDelimited' | 'deepObject';
|
||||||
|
export type PathStyles = 'simple' | 'label' | 'matrix';
|
||||||
|
|
||||||
|
const styleMethods: Record<string, Function> = {
|
||||||
|
simple: (value: unknown, explode: boolean) => {
|
||||||
|
// Check if the value is an array
|
||||||
|
if (Array.isArray(value)) {
|
||||||
|
return explode ? value.join(',') : value.join();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the value is an object
|
||||||
|
if (typeof value === 'object' && value !== null) {
|
||||||
|
if (explode) {
|
||||||
|
// Serialize object with exploded format: "key=value,key2=value2"
|
||||||
|
return Object.entries(value)
|
||||||
|
.map(([parameterName, parameterValue]) => `${parameterName}=${parameterValue}`)
|
||||||
|
.join(',');
|
||||||
|
}
|
||||||
|
// Serialize object with non-exploded format: "key,value,key2,value2"
|
||||||
|
return Object.entries(value)
|
||||||
|
.flatMap(([parameterName, parameterValue]) => [parameterName, parameterValue])
|
||||||
|
.join(',');
|
||||||
|
}
|
||||||
|
|
||||||
|
// For primitive values
|
||||||
|
return String(value);
|
||||||
|
},
|
||||||
|
|
||||||
|
form: (parameterName: string, parameterValue: unknown, explode: boolean) => {
|
||||||
|
// Check if the parameterValue is an array
|
||||||
|
if (Array.isArray(parameterValue)) {
|
||||||
|
return explode
|
||||||
|
? parameterValue.map((value) => `${parameterName}=${value}`).join('&')
|
||||||
|
: `${parameterName}=${parameterValue.join(',')}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the parameterValue is an object
|
||||||
|
if (typeof parameterValue === 'object' && parameterValue !== null) {
|
||||||
|
if (explode) {
|
||||||
|
// Serialize object with exploded format: "key1=value1&key2=value2"
|
||||||
|
return Object.entries(parameterValue)
|
||||||
|
.map(([name, value]) => `${name}=${value}`)
|
||||||
|
.join('&');
|
||||||
|
}
|
||||||
|
// Serialize object with non-exploded format: "key=key1,value1,key2,value2"
|
||||||
|
return `${parameterName}=${Object.entries(parameterValue)
|
||||||
|
.flatMap(([name, value]) => [name, value])
|
||||||
|
.join(',')}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// For primitive values
|
||||||
|
return `${parameterName}=${parameterValue}`;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export function serializeQuery(
|
||||||
|
style: QueryStyles,
|
||||||
|
explode: Explode,
|
||||||
|
key: string,
|
||||||
|
value: unknown,
|
||||||
|
): string {
|
||||||
|
const method = styleMethods[style];
|
||||||
|
if (!method) return '';
|
||||||
|
return method(key, value, explode);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function serializePath(
|
||||||
|
style: PathStyles,
|
||||||
|
explode: Explode,
|
||||||
|
value: unknown,
|
||||||
|
key?: string,
|
||||||
|
): string {
|
||||||
|
const method = styleMethods[style];
|
||||||
|
if (!method) return '';
|
||||||
|
// The `simple` and `label` styles do not require a `key`
|
||||||
|
if (!key) {
|
||||||
|
return method(value, explode);
|
||||||
|
} else {
|
||||||
|
return method(key, value, explode);
|
||||||
|
}
|
||||||
|
}
|
||||||
4
src/http/Response.ts
Normal file
4
src/http/Response.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
export default interface Response<T> {
|
||||||
|
data: T;
|
||||||
|
headers: Record<string, string>;
|
||||||
|
}
|
||||||
11
src/http/errors/BadGateway.ts
Normal file
11
src/http/errors/BadGateway.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import { BaseHTTPError } from './base';
|
||||||
|
|
||||||
|
export default class BadGateway extends BaseHTTPError {
|
||||||
|
statusCode = 502;
|
||||||
|
|
||||||
|
title = 'Bad Gateway';
|
||||||
|
|
||||||
|
constructor(detail: string = '') {
|
||||||
|
super(detail);
|
||||||
|
}
|
||||||
|
}
|
||||||
11
src/http/errors/BadRequest.ts
Normal file
11
src/http/errors/BadRequest.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import { BaseHTTPError } from './base';
|
||||||
|
|
||||||
|
export default class BadRequest extends BaseHTTPError {
|
||||||
|
statusCode = 400;
|
||||||
|
|
||||||
|
title = 'Bad Request';
|
||||||
|
|
||||||
|
constructor(detail: string = '') {
|
||||||
|
super(detail);
|
||||||
|
}
|
||||||
|
}
|
||||||
11
src/http/errors/Conflict.ts
Normal file
11
src/http/errors/Conflict.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import { BaseHTTPError } from './base';
|
||||||
|
|
||||||
|
export default class Conflict extends BaseHTTPError {
|
||||||
|
statusCode = 409;
|
||||||
|
|
||||||
|
title = 'Conflict';
|
||||||
|
|
||||||
|
constructor(detail: string = '') {
|
||||||
|
super(detail);
|
||||||
|
}
|
||||||
|
}
|
||||||
11
src/http/errors/ExpectationFailed.ts
Normal file
11
src/http/errors/ExpectationFailed.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import { BaseHTTPError } from './base';
|
||||||
|
|
||||||
|
export default class ExpectationFailed extends BaseHTTPError {
|
||||||
|
statusCode = 417;
|
||||||
|
|
||||||
|
title = 'Expectation Failed';
|
||||||
|
|
||||||
|
constructor(detail: string = '') {
|
||||||
|
super(detail);
|
||||||
|
}
|
||||||
|
}
|
||||||
11
src/http/errors/FailedDependency.ts
Normal file
11
src/http/errors/FailedDependency.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import { BaseHTTPError } from './base';
|
||||||
|
|
||||||
|
export default class FailedDependency extends BaseHTTPError {
|
||||||
|
statusCode = 424;
|
||||||
|
|
||||||
|
title = 'Failed Dependency';
|
||||||
|
|
||||||
|
constructor(detail: string = '') {
|
||||||
|
super(detail);
|
||||||
|
}
|
||||||
|
}
|
||||||
11
src/http/errors/Forbidden.ts
Normal file
11
src/http/errors/Forbidden.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import { BaseHTTPError } from './base';
|
||||||
|
|
||||||
|
export default class Forbidden extends BaseHTTPError {
|
||||||
|
statusCode = 403;
|
||||||
|
|
||||||
|
title = 'Forbidden';
|
||||||
|
|
||||||
|
constructor(detail: string = '') {
|
||||||
|
super(detail);
|
||||||
|
}
|
||||||
|
}
|
||||||
11
src/http/errors/GatewayTimeout.ts
Normal file
11
src/http/errors/GatewayTimeout.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import { BaseHTTPError } from './base';
|
||||||
|
|
||||||
|
export default class GatewayTimeout extends BaseHTTPError {
|
||||||
|
statusCode = 504;
|
||||||
|
|
||||||
|
title = 'Gateway Timeout';
|
||||||
|
|
||||||
|
constructor(detail: string = '') {
|
||||||
|
super(detail);
|
||||||
|
}
|
||||||
|
}
|
||||||
11
src/http/errors/Gone.ts
Normal file
11
src/http/errors/Gone.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import { BaseHTTPError } from './base';
|
||||||
|
|
||||||
|
export default class Gone extends BaseHTTPError {
|
||||||
|
statusCode = 410;
|
||||||
|
|
||||||
|
title = 'Gone';
|
||||||
|
|
||||||
|
constructor(detail: string = '') {
|
||||||
|
super(detail);
|
||||||
|
}
|
||||||
|
}
|
||||||
11
src/http/errors/HttpVersionNotSupported.ts
Normal file
11
src/http/errors/HttpVersionNotSupported.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import { BaseHTTPError } from './base';
|
||||||
|
|
||||||
|
export default class HttpVersionNotSupported extends BaseHTTPError {
|
||||||
|
statusCode = 505;
|
||||||
|
|
||||||
|
title = 'HTTP Version Not Supported';
|
||||||
|
|
||||||
|
constructor(detail: string = '') {
|
||||||
|
super(detail);
|
||||||
|
}
|
||||||
|
}
|
||||||
11
src/http/errors/InternalServerError.ts
Normal file
11
src/http/errors/InternalServerError.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import { BaseHTTPError } from './base';
|
||||||
|
|
||||||
|
export default class InternalServerError extends BaseHTTPError {
|
||||||
|
statusCode = 500;
|
||||||
|
|
||||||
|
title = 'Internal Server Error';
|
||||||
|
|
||||||
|
constructor(detail: string = '') {
|
||||||
|
super(detail);
|
||||||
|
}
|
||||||
|
}
|
||||||
11
src/http/errors/LengthRequired.ts
Normal file
11
src/http/errors/LengthRequired.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import { BaseHTTPError } from './base';
|
||||||
|
|
||||||
|
export default class LengthRequired extends BaseHTTPError {
|
||||||
|
statusCode = 411;
|
||||||
|
|
||||||
|
title = 'LengthRequired';
|
||||||
|
|
||||||
|
constructor(detail: string = '') {
|
||||||
|
super(detail);
|
||||||
|
}
|
||||||
|
}
|
||||||
11
src/http/errors/Locked.ts
Normal file
11
src/http/errors/Locked.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import { BaseHTTPError } from './base';
|
||||||
|
|
||||||
|
export default class Locked extends BaseHTTPError {
|
||||||
|
statusCode = 423;
|
||||||
|
|
||||||
|
title = 'Locked';
|
||||||
|
|
||||||
|
constructor(detail: string = '') {
|
||||||
|
super(detail);
|
||||||
|
}
|
||||||
|
}
|
||||||
11
src/http/errors/LoopDetected.ts
Normal file
11
src/http/errors/LoopDetected.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import { BaseHTTPError } from './base';
|
||||||
|
|
||||||
|
export default class LoopDetected extends BaseHTTPError {
|
||||||
|
statusCode = 508;
|
||||||
|
|
||||||
|
title = 'Loop Detected';
|
||||||
|
|
||||||
|
constructor(detail: string = '') {
|
||||||
|
super(detail);
|
||||||
|
}
|
||||||
|
}
|
||||||
14
src/http/errors/MethodNotAllowed.ts
Normal file
14
src/http/errors/MethodNotAllowed.ts
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import { BaseHTTPError } from './base';
|
||||||
|
|
||||||
|
export default class MethodNotAllowed extends BaseHTTPError {
|
||||||
|
statusCode = 405;
|
||||||
|
|
||||||
|
title = 'Method Not Allowed';
|
||||||
|
|
||||||
|
allow?: string[];
|
||||||
|
|
||||||
|
constructor(detail: string = '', allow?: string[]) {
|
||||||
|
super(detail);
|
||||||
|
this.allow = allow;
|
||||||
|
}
|
||||||
|
}
|
||||||
11
src/http/errors/MisdirectedRequest.ts
Normal file
11
src/http/errors/MisdirectedRequest.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import { BaseHTTPError } from './base';
|
||||||
|
|
||||||
|
export default class MisdirectedRequest extends BaseHTTPError {
|
||||||
|
statusCode = 421;
|
||||||
|
|
||||||
|
title = 'Misdirected Request';
|
||||||
|
|
||||||
|
constructor(detail: string = '') {
|
||||||
|
super(detail);
|
||||||
|
}
|
||||||
|
}
|
||||||
11
src/http/errors/NetworkAuthenticationRequired.ts
Normal file
11
src/http/errors/NetworkAuthenticationRequired.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import { BaseHTTPError } from './base';
|
||||||
|
|
||||||
|
export default class NetworkAuthenticationRequired extends BaseHTTPError {
|
||||||
|
statusCode = 511;
|
||||||
|
|
||||||
|
title = 'Network Authentication Required';
|
||||||
|
|
||||||
|
constructor(detail: string = '') {
|
||||||
|
super(detail);
|
||||||
|
}
|
||||||
|
}
|
||||||
11
src/http/errors/NotAcceptable.ts
Normal file
11
src/http/errors/NotAcceptable.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import { BaseHTTPError } from './base';
|
||||||
|
|
||||||
|
export default class NotAcceptable extends BaseHTTPError {
|
||||||
|
statusCode = 406;
|
||||||
|
|
||||||
|
title = 'Not Acceptable';
|
||||||
|
|
||||||
|
constructor(detail: string = '') {
|
||||||
|
super(detail);
|
||||||
|
}
|
||||||
|
}
|
||||||
11
src/http/errors/NotExtended.ts
Normal file
11
src/http/errors/NotExtended.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import { BaseHTTPError } from './base';
|
||||||
|
|
||||||
|
export default class NotExtended extends BaseHTTPError {
|
||||||
|
statusCode = 510;
|
||||||
|
|
||||||
|
title = 'Not Extended';
|
||||||
|
|
||||||
|
constructor(detail: string = '') {
|
||||||
|
super(detail);
|
||||||
|
}
|
||||||
|
}
|
||||||
11
src/http/errors/NotFound.ts
Normal file
11
src/http/errors/NotFound.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import { BaseHTTPError } from './base';
|
||||||
|
|
||||||
|
export default class NotFound extends BaseHTTPError {
|
||||||
|
statusCode = 404;
|
||||||
|
|
||||||
|
title = 'Not Found';
|
||||||
|
|
||||||
|
constructor(detail: string = '') {
|
||||||
|
super(detail);
|
||||||
|
}
|
||||||
|
}
|
||||||
11
src/http/errors/NotImplemented.ts
Normal file
11
src/http/errors/NotImplemented.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import { BaseHTTPError } from './base';
|
||||||
|
|
||||||
|
export default class NotImplemented extends BaseHTTPError {
|
||||||
|
statusCode = 501;
|
||||||
|
|
||||||
|
title = 'Not Implemented';
|
||||||
|
|
||||||
|
constructor(detail: string = '') {
|
||||||
|
super(detail);
|
||||||
|
}
|
||||||
|
}
|
||||||
14
src/http/errors/PayloadTooLarge.ts
Normal file
14
src/http/errors/PayloadTooLarge.ts
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import { BaseHTTPError } from './base';
|
||||||
|
|
||||||
|
export default class PayloadTooLarge extends BaseHTTPError {
|
||||||
|
statusCode = 413;
|
||||||
|
|
||||||
|
title = 'Payload Too Large';
|
||||||
|
|
||||||
|
retryAfter: number | null;
|
||||||
|
|
||||||
|
constructor(detail: string = '', retryAfter: number | null = null) {
|
||||||
|
super(detail);
|
||||||
|
this.retryAfter = retryAfter;
|
||||||
|
}
|
||||||
|
}
|
||||||
11
src/http/errors/PaymentRequired.ts
Normal file
11
src/http/errors/PaymentRequired.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import { BaseHTTPError } from './base';
|
||||||
|
|
||||||
|
export default class PaymentRequired extends BaseHTTPError {
|
||||||
|
statusCode = 402;
|
||||||
|
|
||||||
|
title = 'Payment Required';
|
||||||
|
|
||||||
|
constructor(detail: string = '') {
|
||||||
|
super(detail);
|
||||||
|
}
|
||||||
|
}
|
||||||
11
src/http/errors/PreconditionFailed.ts
Normal file
11
src/http/errors/PreconditionFailed.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import { BaseHTTPError } from './base';
|
||||||
|
|
||||||
|
export default class PreconditionFailed extends BaseHTTPError {
|
||||||
|
statusCode = 412;
|
||||||
|
|
||||||
|
title = 'PreconditionFailed';
|
||||||
|
|
||||||
|
constructor(detail: string = '') {
|
||||||
|
super(detail);
|
||||||
|
}
|
||||||
|
}
|
||||||
11
src/http/errors/PreconditionRequired.ts
Normal file
11
src/http/errors/PreconditionRequired.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import { BaseHTTPError } from './base';
|
||||||
|
|
||||||
|
export default class PreconditionRequired extends BaseHTTPError {
|
||||||
|
statusCode = 428;
|
||||||
|
|
||||||
|
title = 'Precondition Required';
|
||||||
|
|
||||||
|
constructor(detail: string = '') {
|
||||||
|
super(detail);
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user