Compare commits

...

7 Commits

Author SHA1 Message Date
speakeasybot
eeadc8c329 ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.228.1 2024-03-29 16:38:38 +00:00
speakeasybot
dbe2e37bba ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.227.0 2024-03-27 00:27:27 +00:00
speakeasybot
6c314bea48 ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.213.0 2024-03-20 00:27:47 +00:00
speakeasybot
9e28d57f15 ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.209.3 2024-03-15 15:04:11 +00:00
Luke Hagar
9da9389549 migrated speakeasy to v15 2024-03-15 09:56:46 -05:00
speakeasy-github
fd886229c2 chore: update dependencies 2024-03-14 00:27:53 +00:00
speakeasybot
8a8615f241 ci: regenerated with OpenAPI Doc 0.0.3, Speakeasy CLI 1.209.2 2024-03-14 00:26:50 +00:00
91 changed files with 383 additions and 118 deletions

View File

@@ -15,15 +15,10 @@ permissions:
- cron: 0 0 * * * - cron: 0 0 * * *
jobs: jobs:
generate: generate:
uses: speakeasy-api/sdk-generation-action/.github/workflows/sdk-generation.yaml@v14 uses: speakeasy-api/sdk-generation-action/.github/workflows/workflow-executor.yaml@v15
with: with:
force: ${{ github.event.inputs.force }} force: ${{ github.event.inputs.force }}
languages: |
- typescript
mode: direct mode: direct
openapi_docs: |
- https://raw.githubusercontent.com/LukeHagar/plex-api-spec/main/plex-media-server-spec-dereferenced.yaml
publish_typescript: true
speakeasy_version: latest speakeasy_version: latest
secrets: secrets:
github_access_token: ${{ secrets.GITHUB_TOKEN }} github_access_token: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -1,12 +1,12 @@
lockVersion: 2.0.0 lockVersion: 2.0.0
id: 16f22cbf-f23f-4419-8924-3a4b06381947 id: 16f22cbf-f23f-4419-8924-3a4b06381947
management: management:
docChecksum: e34dac84738ebf2d447ea2b9055a6eeb docChecksum: a91eaf9ec1e6a3a6f4bf0571f5b18bae
docVersion: 0.0.3 docVersion: 0.0.3
speakeasyVersion: 1.207.1 speakeasyVersion: 1.228.1
generationVersion: 2.280.6 generationVersion: 2.292.0
releaseVersion: 0.10.1 releaseVersion: 0.12.0
configChecksum: 726b0f7d4f020a007a232a1cfe026ef0 configChecksum: 96c0b6a9e85b7682aef0863ada1e00a7
repoURL: https://github.com/LukeHagar/plexjs.git repoURL: https://github.com/LukeHagar/plexjs.git
repoSubDirectory: . repoSubDirectory: .
installationURL: https://github.com/LukeHagar/plexjs installationURL: https://github.com/LukeHagar/plexjs
@@ -14,13 +14,14 @@ management:
features: features:
typescript: typescript:
constsAndDefaults: 0.1.5 constsAndDefaults: 0.1.5
core: 3.6.1 core: 3.7.0
flattening: 2.81.1 flattening: 2.81.1
globalSecurity: 2.82.4 globalSecurity: 2.82.8
globalServerURLs: 2.82.4 globalServerURLs: 2.82.4
globals: 2.82.1
methodServerURLs: 2.82.1 methodServerURLs: 2.82.1
nameOverrides: 2.81.1 nameOverrides: 2.81.1
responseFormat: 0.2.1 responseFormat: 0.2.3
generatedFiles: generatedFiles:
- src/sdk/server.ts - src/sdk/server.ts
- src/sdk/media.ts - src/sdk/media.ts

12
.speakeasy/workflow.yaml Normal file
View File

@@ -0,0 +1,12 @@
workflowVersion: 1.0.0
sources:
my-source:
inputs:
- location: https://raw.githubusercontent.com/LukeHagar/plex-api-spec/main/plex-media-server-spec-dereferenced.yaml
targets:
plexjs:
target: typescript
source: my-source
publish:
npm:
token: $NPM_TOKEN

View File

@@ -34,6 +34,7 @@ import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const result = await sdk.server.getServerCapabilities(); const result = await sdk.server.getServerCapabilities();
@@ -176,6 +177,7 @@ import * as errors from "@lukehagar/plexjs/models/errors";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
let result; let result;
@@ -227,6 +229,7 @@ async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
serverIdx: 0, serverIdx: 0,
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const result = await sdk.server.getServerCapabilities(); const result = await sdk.server.getServerCapabilities();
@@ -257,6 +260,7 @@ async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
serverURL: "{protocol}://{ip}:{port}", serverURL: "{protocol}://{ip}:{port}",
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const result = await sdk.server.getServerCapabilities(); const result = await sdk.server.getServerCapabilities();
@@ -276,12 +280,14 @@ The server URL can also be overridden on a per-operation basis, provided a serve
import { PlexAPI } from "@lukehagar/plexjs"; import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI(); const sdk = new PlexAPI({
xPlexClientIdentifier: "<value>",
});
const xPlexClientIdentifier = "<value>";
const strong = false; const strong = false;
const xPlexClientIdentifier = "<value>";
const result = await sdk.plex.getPin(xPlexClientIdentifier, strong, { const result = await sdk.plex.getPin(strong, xPlexClientIdentifier, {
serverURL: "https://plex.tv/api/v2", serverURL: "https://plex.tv/api/v2",
}); });
@@ -361,6 +367,7 @@ import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const result = await sdk.server.getServerCapabilities(); const result = await sdk.server.getServerCapabilities();
@@ -380,6 +387,50 @@ run();
For supported JavaScript runtimes, please consult [RUNTIMES.md](RUNTIMES.md). For supported JavaScript runtimes, please consult [RUNTIMES.md](RUNTIMES.md).
<!-- End Requirements [requirements] --> <!-- End Requirements [requirements] -->
<!-- Start Global Parameters [global-parameters] -->
## Global Parameters
A parameter is configured globally. This parameter must be set on the SDK client instance itself during initialization. When configured as an option during SDK initialization, This global value will be used as the default on the operations that use it. When such operations are called, there is a place in each to override the global value, if needed.
For example, you can set `X-Plex-Client-Identifier` to `"<value>"` at SDK initialization and then you do not have to pass the same value on calls to operations like `getPin`. But if you want to do so you may, which will locally override the global setting. See the example code below for a demonstration.
### Available Globals
The following global parameter is available. The required parameter must be set when you initialize the SDK client.
| Name | Type | Required | Description |
| ---- | ---- |:--------:| ----------- |
| xPlexClientIdentifier | string | ✔️ | The unique identifier for the client application
This is used to track the client application and its usage
(UUID, serial number, or other number unique per device)
|
### Example
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
xPlexClientIdentifier: "<value>",
});
const strong = false;
const xPlexClientIdentifier = "<value>";
const result = await sdk.plex.getPin(strong, xPlexClientIdentifier);
// Handle the result
console.log(result);
}
run();
```
<!-- End Global Parameters [global-parameters] -->
<!-- Placeholder for Future Speakeasy SDK Sections --> <!-- Placeholder for Future Speakeasy SDK Sections -->
# Development # Development

View File

@@ -239,3 +239,53 @@ Based on:
- [typescript v0.10.1] . - [typescript v0.10.1] .
### Releases ### Releases
- [NPM v0.10.1] https://www.npmjs.com/package/@lukehagar/plexjs/v/0.10.1 - . - [NPM v0.10.1] https://www.npmjs.com/package/@lukehagar/plexjs/v/0.10.1 - .
## 2024-03-14 00:25:24
### Changes
Based on:
- OpenAPI Doc 0.0.3
- Speakeasy CLI 1.209.2 (2.281.2) https://github.com/speakeasy-api/speakeasy
### Generated
- [typescript v0.10.2] .
### Releases
- [NPM v0.10.2] https://www.npmjs.com/package/@lukehagar/plexjs/v/0.10.2 - .
## 2024-03-15 15:02:11
### Changes
Based on:
- OpenAPI Doc
- Speakeasy CLI 1.209.3 (2.281.2) https://github.com/speakeasy-api/speakeasy
### Generated
- [typescript v0.10.3] .
### Releases
- [NPM v0.10.3] https://www.npmjs.com/package/@lukehagar/plexjs/v/0.10.3 - .
## 2024-03-20 00:25:49
### Changes
Based on:
- OpenAPI Doc
- Speakeasy CLI 1.213.0 (2.283.1) https://github.com/speakeasy-api/speakeasy
### Generated
- [typescript v0.10.4] .
### Releases
- [NPM v0.10.4] https://www.npmjs.com/package/@lukehagar/plexjs/v/0.10.4 - .
## 2024-03-27 00:25:29
### Changes
Based on:
- OpenAPI Doc
- Speakeasy CLI 1.227.0 (2.291.0) https://github.com/speakeasy-api/speakeasy
### Generated
- [typescript v0.11.0] .
### Releases
- [NPM v0.11.0] https://www.npmjs.com/package/@lukehagar/plexjs/v/0.11.0 - .
## 2024-03-29 16:36:42
### Changes
Based on:
- OpenAPI Doc
- Speakeasy CLI 1.228.1 (2.292.0) https://github.com/speakeasy-api/speakeasy
### Generated
- [typescript v0.12.0] .
### Releases
- [NPM v0.12.0] https://www.npmjs.com/package/@lukehagar/plexjs/v/0.12.0 - .

View File

@@ -5,6 +5,7 @@ import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const result = await sdk.server.getServerCapabilities(); const result = await sdk.server.getServerCapabilities();

View File

@@ -5,5 +5,5 @@
| Field | Type | Required | Description | | Field | Type | Required | Description |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `xPlexClientIdentifier` | *string* | :heavy_check_mark: | The unique identifier for the client application<br/>This is used to track the client application and its usage<br/>(UUID, serial number, or other number unique per device)<br/> |
| `strong` | *boolean* | :heavy_minus_sign: | Determines the kind of code returned by the API call<br/>Strong codes are used for Pin authentication flows<br/>Non-Strong codes are used for `Plex.tv/link`<br/> | | `strong` | *boolean* | :heavy_minus_sign: | Determines the kind of code returned by the API call<br/>Strong codes are used for Pin authentication flows<br/>Non-Strong codes are used for `Plex.tv/link`<br/> |
| `xPlexClientIdentifier` | *string* | :heavy_minus_sign: | The unique identifier for the client application<br/>This is used to track the client application and its usage<br/>(UUID, serial number, or other number unique per device)<br/> |

View File

@@ -6,4 +6,4 @@
| Field | Type | Required | Description | | Field | Type | Required | Description |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `pinID` | *string* | :heavy_check_mark: | The PinID to retrieve an access token for | | `pinID` | *string* | :heavy_check_mark: | The PinID to retrieve an access token for |
| `xPlexClientIdentifier` | *string* | :heavy_check_mark: | The unique identifier for the client application<br/>This is used to track the client application and its usage<br/>(UUID, serial number, or other number unique per device)<br/> | | `xPlexClientIdentifier` | *string* | :heavy_minus_sign: | The unique identifier for the client application<br/>This is used to track the client application and its usage<br/>(UUID, serial number, or other number unique per device)<br/> |

View File

@@ -29,6 +29,7 @@ import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const result = await sdk.activities.getServerActivities(); const result = await sdk.activities.getServerActivities();
@@ -70,6 +71,7 @@ import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const activityUUID = "<value>"; const activityUUID = "<value>";

View File

@@ -25,6 +25,7 @@ import { GetTransientTokenQueryParamType, Scope } from "@lukehagar/plexjs/models
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const type = GetTransientTokenQueryParamType.Delegation; const type = GetTransientTokenQueryParamType.Delegation;
@@ -73,6 +74,7 @@ import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const source = "server://client-identifier"; const source = "server://client-identifier";

View File

@@ -26,6 +26,7 @@ import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const result = await sdk.butler.getButlerTasks(); const result = await sdk.butler.getButlerTasks();
@@ -72,6 +73,7 @@ import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const result = await sdk.butler.startAllTasks(); const result = await sdk.butler.startAllTasks();
@@ -114,6 +116,7 @@ import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const result = await sdk.butler.stopAllTasks(); const result = await sdk.butler.stopAllTasks();
@@ -161,6 +164,7 @@ import { TaskName } from "@lukehagar/plexjs/models/operations";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const taskName = TaskName.CleanOldBundles; const taskName = TaskName.CleanOldBundles;
@@ -207,6 +211,7 @@ import { PathParamTaskName } from "@lukehagar/plexjs/models/operations";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const taskName = PathParamTaskName.BackupDatabase; const taskName = PathParamTaskName.BackupDatabase;

View File

@@ -24,6 +24,7 @@ import { OnlyTransient } from "@lukehagar/plexjs/models/operations";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const count = 1262.49; const count = 1262.49;
@@ -72,6 +73,7 @@ import { QueryParamOnlyTransient } from "@lukehagar/plexjs/models/operations";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const sectionId = 6728.76; const sectionId = 6728.76;

View File

@@ -32,6 +32,7 @@ import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const url = "file://C:\Image.png&type=13"; const url = "file://C:\Image.png&type=13";
@@ -79,6 +80,7 @@ import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const result = await sdk.library.getRecentlyAdded(); const result = await sdk.library.getRecentlyAdded();
@@ -126,6 +128,7 @@ import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const result = await sdk.library.getLibraries(); const result = await sdk.library.getLibraries();
@@ -207,6 +210,7 @@ import { IncludeDetails } from "@lukehagar/plexjs/models/operations";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const sectionId = 1000; const sectionId = 1000;
@@ -253,6 +257,7 @@ import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const sectionId = 1000; const sectionId = 1000;
@@ -318,6 +323,7 @@ import { Tag } from "@lukehagar/plexjs/models/operations";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const sectionId = 451092; const sectionId = 451092;
@@ -364,6 +370,7 @@ import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const sectionId = 934.16; const sectionId = 934.16;
@@ -427,6 +434,7 @@ import { Type } from "@lukehagar/plexjs/models/operations";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const sectionId = 933505; const sectionId = 933505;
@@ -473,6 +481,7 @@ import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const ratingKey = 8382.31; const ratingKey = 8382.31;
@@ -518,6 +527,7 @@ import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const ratingKey = 1539.14; const ratingKey = 1539.14;
@@ -563,6 +573,7 @@ import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const result = await sdk.library.getOnDeck(); const result = await sdk.library.getOnDeck();

View File

@@ -26,6 +26,7 @@ import { Level } from "@lukehagar/plexjs/models/operations";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const level = Level.Three; const level = Level.Three;
@@ -95,6 +96,7 @@ import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const result = await sdk.log.logMultiLine("level=4&message=Test%20message%201&source=postman const result = await sdk.log.logMultiLine("level=4&message=Test%20message%201&source=postman
@@ -140,6 +142,7 @@ import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const result = await sdk.log.enablePaperTrail(); const result = await sdk.log.enablePaperTrail();

View File

@@ -24,6 +24,7 @@ import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const key = 59398; const key = 59398;
@@ -68,6 +69,7 @@ import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const key = 59398; const key = 59398;
@@ -113,6 +115,7 @@ import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const key = "<value>"; const key = "<value>";

View File

@@ -37,6 +37,7 @@ import { QueryParamType, Smart } from "@lukehagar/plexjs/models/operations";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const result = await sdk.playlists.createPlaylist({ const result = await sdk.playlists.createPlaylist({
@@ -85,6 +86,7 @@ import { PlaylistType, QueryParamSmart } from "@lukehagar/plexjs/models/operatio
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const playlistType = PlaylistType.Audio; const playlistType = PlaylistType.Audio;
@@ -133,6 +135,7 @@ import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const playlistID = 4109.48; const playlistID = 4109.48;
@@ -178,6 +181,7 @@ import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const playlistID = 216.22; const playlistID = 216.22;
@@ -223,6 +227,7 @@ import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const playlistID = 3915; const playlistID = 3915;
@@ -275,6 +280,7 @@ import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const playlistID = 5004.46; const playlistID = 5004.46;
@@ -322,6 +328,7 @@ import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const playlistID = 1893.18; const playlistID = 1893.18;
@@ -368,6 +375,7 @@ import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const playlistID = 8502.01; const playlistID = 8502.01;
@@ -418,6 +426,7 @@ import { Force } from "@lukehagar/plexjs/models/operations";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const path = "/home/barkley/playlist.m3u"; const path = "/home/barkley/playlist.m3u";

View File

@@ -21,12 +21,14 @@ Retrieve a Pin from Plex.tv for authentication flows
import { PlexAPI } from "@lukehagar/plexjs"; import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI(); const sdk = new PlexAPI({
xPlexClientIdentifier: "<value>",
});
const xPlexClientIdentifier = "<value>";
const strong = false; const strong = false;
const xPlexClientIdentifier = "<value>";
const result = await sdk.plex.getPin(xPlexClientIdentifier, strong); const result = await sdk.plex.getPin(strong, xPlexClientIdentifier);
// Handle the result // Handle the result
console.log(result) console.log(result)
@@ -39,8 +41,8 @@ run();
| Parameter | Type | Required | Description | | Parameter | Type | Required | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `xPlexClientIdentifier` | *string* | :heavy_check_mark: | The unique identifier for the client application<br/>This is used to track the client application and its usage<br/>(UUID, serial number, or other number unique per device)<br/> |
| `strong` | *boolean* | :heavy_minus_sign: | Determines the kind of code returned by the API call<br/>Strong codes are used for Pin authentication flows<br/>Non-Strong codes are used for `Plex.tv/link`<br/> | | `strong` | *boolean* | :heavy_minus_sign: | Determines the kind of code returned by the API call<br/>Strong codes are used for Pin authentication flows<br/>Non-Strong codes are used for `Plex.tv/link`<br/> |
| `xPlexClientIdentifier` | *string* | :heavy_minus_sign: | The unique identifier for the client application<br/>This is used to track the client application and its usage<br/>(UUID, serial number, or other number unique per device)<br/> |
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. | | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
| `options.serverURL` | *string* | :heavy_minus_sign: | An optional server URL to use. | | `options.serverURL` | *string* | :heavy_minus_sign: | An optional server URL to use. |
@@ -66,7 +68,9 @@ Retrieve an Access Token from Plex.tv after the Pin has already been authenticat
import { PlexAPI } from "@lukehagar/plexjs"; import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI(); const sdk = new PlexAPI({
xPlexClientIdentifier: "<value>",
});
const pinID = "<value>"; const pinID = "<value>";
const xPlexClientIdentifier = "<value>"; const xPlexClientIdentifier = "<value>";
@@ -85,7 +89,7 @@ run();
| Parameter | Type | Required | Description | | Parameter | Type | Required | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `pinID` | *string* | :heavy_check_mark: | The PinID to retrieve an access token for | | `pinID` | *string* | :heavy_check_mark: | The PinID to retrieve an access token for |
| `xPlexClientIdentifier` | *string* | :heavy_check_mark: | The unique identifier for the client application<br/>This is used to track the client application and its usage<br/>(UUID, serial number, or other number unique per device)<br/> | | `xPlexClientIdentifier` | *string* | :heavy_minus_sign: | The unique identifier for the client application<br/>This is used to track the client application and its usage<br/>(UUID, serial number, or other number unique per device)<br/> |
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. | | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
| `options.serverURL` | *string* | :heavy_minus_sign: | An optional server URL to use. | | `options.serverURL` | *string* | :heavy_minus_sign: | An optional server URL to use. |

View File

@@ -36,6 +36,7 @@ import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const query = "dylan"; const query = "dylan";
@@ -88,6 +89,7 @@ import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const query = "dead+poop"; const query = "dead+poop";
@@ -136,6 +138,7 @@ import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const query = "110"; const query = "110";

View File

@@ -29,6 +29,7 @@ import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const result = await sdk.server.getServerCapabilities(); const result = await sdk.server.getServerCapabilities();
@@ -70,6 +71,7 @@ import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const result = await sdk.server.getServerPreferences(); const result = await sdk.server.getServerPreferences();
@@ -111,6 +113,7 @@ import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const result = await sdk.server.getAvailableClients(); const result = await sdk.server.getAvailableClients();
@@ -152,6 +155,7 @@ import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const result = await sdk.server.getDevices(); const result = await sdk.server.getDevices();
@@ -193,6 +197,7 @@ import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const result = await sdk.server.getServerIdentity(); const result = await sdk.server.getServerIdentity();
@@ -234,6 +239,7 @@ import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const result = await sdk.server.getMyPlexAccount(); const result = await sdk.server.getMyPlexAccount();
@@ -277,6 +283,7 @@ import { MinSize, Upscale } from "@lukehagar/plexjs/models/operations";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const result = await sdk.server.getResizedPhoto({ const result = await sdk.server.getResizedPhoto({
@@ -327,6 +334,7 @@ import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const result = await sdk.server.getServerList(); const result = await sdk.server.getServerList();

View File

@@ -25,6 +25,7 @@ import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const result = await sdk.sessions.getSessions(); const result = await sdk.sessions.getSessions();
@@ -66,6 +67,7 @@ import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const result = await sdk.sessions.getSessionHistory(); const result = await sdk.sessions.getSessionHistory();
@@ -107,6 +109,7 @@ import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const result = await sdk.sessions.getTranscodeSessions(); const result = await sdk.sessions.getTranscodeSessions();
@@ -148,6 +151,7 @@ import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const sessionKey = "zz7llzqlx8w9vnrsbnwhbmep"; const sessionKey = "zz7llzqlx8w9vnrsbnwhbmep";

View File

@@ -22,6 +22,7 @@ import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const timespan = 411769; const timespan = 411769;

View File

@@ -25,6 +25,7 @@ import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const result = await sdk.updater.getUpdateStatus(); const result = await sdk.updater.getUpdateStatus();
@@ -67,6 +68,7 @@ import { Download } from "@lukehagar/plexjs/models/operations";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const download = Download.One; const download = Download.One;
@@ -113,6 +115,7 @@ import { Skip, Tonight } from "@lukehagar/plexjs/models/operations";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const tonight = Tonight.One; const tonight = Tonight.One;

View File

@@ -24,6 +24,7 @@ import { State } from "@lukehagar/plexjs/models/operations";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const result = await sdk.video.getTimeline({ const result = await sdk.video.getTimeline({
@@ -77,6 +78,7 @@ import { PlexAPI } from "@lukehagar/plexjs";
async function run() { async function run() {
const sdk = new PlexAPI({ const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>", accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "<value>",
}); });
const result = await sdk.video.startUniversalTranscode({ const result = await sdk.video.startUniversalTranscode({

View File

@@ -12,7 +12,7 @@ generation:
auth: auth:
oAuth2ClientCredentialsEnabled: false oAuth2ClientCredentialsEnabled: false
typescript: typescript:
version: 0.10.1 version: 0.12.0
additionalDependencies: additionalDependencies:
dependencies: {} dependencies: {}
devDependencies: {} devDependencies: {}

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "@lukehagar/plexjs", "name": "@lukehagar/plexjs",
"version": "0.10.1", "version": "0.12.0",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@lukehagar/plexjs", "name": "@lukehagar/plexjs",
"version": "0.10.1", "version": "0.12.0",
"devDependencies": { "devDependencies": {
"@types/jsonpath": "^0.2.4", "@types/jsonpath": "^0.2.4",
"@typescript-eslint/eslint-plugin": "^6.13.2", "@typescript-eslint/eslint-plugin": "^6.13.2",

View File

@@ -1,6 +1,6 @@
{ {
"name": "@lukehagar/plexjs", "name": "@lukehagar/plexjs",
"version": "0.10.1", "version": "0.12.0",
"author": "LukeHagar", "author": "LukeHagar",
"main": "./index.js", "main": "./index.js",
"sideEffects": false, "sideEffects": false,

View File

@@ -27,6 +27,11 @@ export enum ServerProtocol {
export type SDKOptions = { export type SDKOptions = {
accessToken?: string | (() => Promise<string>); accessToken?: string | (() => Promise<string>);
/**
* Allows setting the xPlexClientIdentifier parameter for all supported operations
*/
xPlexClientIdentifier?: string;
httpClient?: HTTPClient; httpClient?: HTTPClient;
/** /**
* Allows overriding the default server used by the SDK * Allows overriding the default server used by the SDK
@@ -82,7 +87,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
export const SDK_METADATA = Object.freeze({ export const SDK_METADATA = Object.freeze({
language: "typescript", language: "typescript",
openapiDocVersion: "0.0.3", openapiDocVersion: "0.0.3",
sdkVersion: "0.10.1", sdkVersion: "0.12.0",
genVersion: "2.280.6", genVersion: "2.292.0",
userAgent: "speakeasy-sdk/typescript 0.10.1 2.280.6 0.0.3 @lukehagar/plexjs", userAgent: "speakeasy-sdk/typescript 0.12.0 2.292.0 0.0.3 @lukehagar/plexjs",
}); });

View File

@@ -7,15 +7,17 @@ export type Fetcher = (
init?: RequestInit, init?: RequestInit,
) => Promise<Response>; ) => Promise<Response>;
type Awaitable<T> = T | Promise<T>;
const DEFAULT_FETCHER: Fetcher = (input, init) => fetch(input, init); const DEFAULT_FETCHER: Fetcher = (input, init) => fetch(input, init);
export interface HTTPClientOptions { export interface HTTPClientOptions {
fetcher?: Fetcher; fetcher?: Fetcher;
} }
type BeforeRequestHook = (req: Request) => Request | void; type BeforeRequestHook = (req: Request) => Awaitable<Request | void>;
type RequestErrorHook = (err: unknown, req: Request) => void; type RequestErrorHook = (err: unknown, req: Request) => Awaitable<void>;
type ResponseHook = (res: Response, req: Request) => void; type ResponseHook = (res: Response, req: Request) => Awaitable<void>;
export class HTTPClient { export class HTTPClient {
private fetcher: Fetcher; private fetcher: Fetcher;
@@ -28,17 +30,27 @@ export class HTTPClient {
} }
async request(request: Request): Promise<Response> { async request(request: Request): Promise<Response> {
const req = this.requestHooks.reduce((currentReq, fn) => { let req = request;
const nextRequest = fn(currentReq); for (const hook of this.requestHooks) {
return nextRequest || currentReq; const nextRequest = await hook(req);
}, request); if (nextRequest) {
req = nextRequest;
}
}
try { try {
const res = await this.fetcher(req); const res = await this.fetcher(req);
this.responseHooks.forEach((fn) => fn(res, req));
for (const hook of this.responseHooks) {
await hook(res, req);
}
return res; return res;
} catch (err) { } catch (err) {
this.requestErrorHooks.forEach((fn) => fn(err, req)); for (const hook of this.requestErrorHooks) {
await hook(err, req);
}
throw err; throw err;
} }
} }

View File

@@ -71,10 +71,10 @@ export class ClientSDK {
const headers = new Headers(opHeaders); const headers = new Headers(opHeaders);
const username = security?.basic.username || ""; const username = security?.basic.username;
const password = security?.basic.password || ""; const password = security?.basic.password;
if (username) { if (username != null || password != null) {
const encoded = stringToBase64([username, password].join(":")); const encoded = stringToBase64([username || "", password || ""].join(":"));
headers.set("Authorization", `Basic ${encoded}`); headers.set("Authorization", `Basic ${encoded}`);
} }

View File

@@ -30,21 +30,15 @@ export class SecurityError extends Error {
} }
export type SecurityState = { export type SecurityState = {
basic: { username: string; password?: string }; basic: { username?: string | undefined; password?: string | undefined };
headers: Record<string, string>; headers: Record<string, string>;
queryParams: Record<string, string>; queryParams: Record<string, string>;
cookies: Record<string, string>; cookies: Record<string, string>;
}; };
type SecurityInputBasicPacked = {
type: "http:basic";
value: { username: string; password?: string } | null | undefined;
};
type SecurityInputBasic = { type SecurityInputBasic = {
type: "http:basic"; type: "http:basic";
value: string | null | undefined; value: { username?: string | undefined; password?: string | undefined } | null | undefined;
fieldName: "username" | "password";
}; };
type SecurityInputBearer = { type SecurityInputBearer = {
@@ -79,7 +73,6 @@ type SecurityInputOAuth2ClientCredentials = {
export type SecurityInput = export type SecurityInput =
| SecurityInputBasic | SecurityInputBasic
| SecurityInputBasicPacked
| SecurityInputBearer | SecurityInputBearer
| SecurityInputAPIKey | SecurityInputAPIKey
| SecurityInputOAuth2 | SecurityInputOAuth2
@@ -94,7 +87,22 @@ export function resolveSecurity(...options: SecurityInput[][]): SecurityState |
cookies: {}, cookies: {},
}; };
const option = options.find((opts) => opts.every((o) => Boolean(o.value))); const option = options.find((opts) => {
return opts.every((o) => {
switch (true) {
case o.value == null:
return false;
case o.type === "http:basic":
return o.value.username != null || o.value.password != null;
case typeof o.value === "string":
return !!o.value;
default:
throw new Error(
`Unrecognized security type: ${o.type} (value type: ${typeof o.value})`
);
}
});
});
if (option == null) { if (option == null) {
return null; return null;
} }
@@ -139,16 +147,12 @@ export function resolveSecurity(...options: SecurityInput[][]): SecurityState |
return state; return state;
} }
function applyBasic(state: SecurityState, spec: SecurityInputBasic | SecurityInputBasicPacked) { function applyBasic(state: SecurityState, spec: SecurityInputBasic) {
if (spec.value == null) { if (spec.value == null) {
return; return;
} }
if ("fieldName" in spec) {
state.basic[spec.fieldName] = spec.value;
} else {
state.basic = spec.value; state.basic = spec.value;
}
} }
function applyBearer( function applyBearer(
@@ -168,6 +172,10 @@ function applyBearer(
} }
export function resolveGlobalSecurity(security: Partial<components.Security> | null | undefined) { export function resolveGlobalSecurity(security: Partial<components.Security> | null | undefined) {
return resolveSecurity([ return resolveSecurity([
{ value: security?.accessToken, fieldName: "X-Plex-Token", type: "apiKey:header" }, {
fieldName: "X-Plex-Token",
type: "apiKey:header",
value: security?.accessToken,
},
]); ]);
} }

View File

@@ -116,6 +116,7 @@ export namespace AddPlaylistContentsResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<AddPlaylistContentsErrors$.Outbound> | undefined; errors?: Array<AddPlaylistContentsErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -115,6 +115,7 @@ export namespace ApplyUpdatesResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<ApplyUpdatesErrors$.Outbound> | undefined; errors?: Array<ApplyUpdatesErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -119,6 +119,7 @@ export namespace CancelServerActivitiesResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<CancelServerActivitiesErrors$.Outbound> | undefined; errors?: Array<CancelServerActivitiesErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -115,6 +115,7 @@ export namespace CheckForUpdatesResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<CheckForUpdatesErrors$.Outbound> | undefined; errors?: Array<CheckForUpdatesErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -119,6 +119,7 @@ export namespace ClearPlaylistContentsResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<ClearPlaylistContentsErrors$.Outbound> | undefined; errors?: Array<ClearPlaylistContentsErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -115,6 +115,7 @@ export namespace CreatePlaylistResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<CreatePlaylistErrors$.Outbound> | undefined; errors?: Array<CreatePlaylistErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -115,6 +115,7 @@ export namespace DeleteLibraryResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<DeleteLibraryErrors$.Outbound> | undefined; errors?: Array<DeleteLibraryErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -115,6 +115,7 @@ export namespace DeletePlaylistResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<DeletePlaylistErrors$.Outbound> | undefined; errors?: Array<DeletePlaylistErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -115,6 +115,7 @@ export namespace EnablePaperTrailResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<EnablePaperTrailErrors$.Outbound> | undefined; errors?: Array<EnablePaperTrailErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -116,6 +116,7 @@ export namespace GetAvailableClientsResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<GetAvailableClientsErrors$.Outbound> | undefined; errors?: Array<GetAvailableClientsErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -115,6 +115,7 @@ export namespace GetButlerTasksResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<GetButlerTasksErrors$.Outbound> | undefined; errors?: Array<GetButlerTasksErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -115,6 +115,7 @@ export namespace GetDevicesResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<GetDevicesErrors$.Outbound> | undefined; errors?: Array<GetDevicesErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -115,6 +115,7 @@ export namespace GetFileHashResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<GetFileHashErrors$.Outbound> | undefined; errors?: Array<GetFileHashErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -115,6 +115,7 @@ export namespace GetGlobalHubsResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<GetGlobalHubsErrors$.Outbound> | undefined; errors?: Array<GetGlobalHubsErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -115,6 +115,7 @@ export namespace GetLibrariesResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<GetLibrariesErrors$.Outbound> | undefined; errors?: Array<GetLibrariesErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -115,6 +115,7 @@ export namespace GetLibraryResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<GetLibraryErrors$.Outbound> | undefined; errors?: Array<GetLibraryErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -115,6 +115,7 @@ export namespace GetLibraryHubsResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<GetLibraryHubsErrors$.Outbound> | undefined; errors?: Array<GetLibraryHubsErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -115,6 +115,7 @@ export namespace GetMetadataResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<GetMetadataErrors$.Outbound> | undefined; errors?: Array<GetMetadataErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -116,6 +116,7 @@ export namespace GetMetadataChildrenResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<GetMetadataChildrenErrors$.Outbound> | undefined; errors?: Array<GetMetadataChildrenErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -115,6 +115,7 @@ export namespace GetMyPlexAccountResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<GetMyPlexAccountErrors$.Outbound> | undefined; errors?: Array<GetMyPlexAccountErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -115,6 +115,7 @@ export namespace GetOnDeckResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<GetOnDeckErrors$.Outbound> | undefined; errors?: Array<GetOnDeckErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -115,6 +115,7 @@ export namespace GetPinResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<GetPinErrors$.Outbound> | undefined; errors?: Array<GetPinErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -115,6 +115,7 @@ export namespace GetPlaylistResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<GetPlaylistErrors$.Outbound> | undefined; errors?: Array<GetPlaylistErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -116,6 +116,7 @@ export namespace GetPlaylistContentsResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<GetPlaylistContentsErrors$.Outbound> | undefined; errors?: Array<GetPlaylistContentsErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -115,6 +115,7 @@ export namespace GetPlaylistsResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<GetPlaylistsErrors$.Outbound> | undefined; errors?: Array<GetPlaylistsErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -115,6 +115,7 @@ export namespace GetRecentlyAddedResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<GetRecentlyAddedErrors$.Outbound> | undefined; errors?: Array<GetRecentlyAddedErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -115,6 +115,7 @@ export namespace GetResizedPhotoResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<GetResizedPhotoErrors$.Outbound> | undefined; errors?: Array<GetResizedPhotoErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -115,6 +115,7 @@ export namespace GetSearchResultsResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<GetSearchResultsErrors$.Outbound> | undefined; errors?: Array<GetSearchResultsErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -116,6 +116,7 @@ export namespace GetServerActivitiesResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<GetServerActivitiesErrors$.Outbound> | undefined; errors?: Array<GetServerActivitiesErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -119,6 +119,7 @@ export namespace GetServerCapabilitiesResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<Errors$.Outbound> | undefined; errors?: Array<Errors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -115,6 +115,7 @@ export namespace GetServerIdentityResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<GetServerIdentityErrors$.Outbound> | undefined; errors?: Array<GetServerIdentityErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -115,6 +115,7 @@ export namespace GetServerListResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<GetServerListErrors$.Outbound> | undefined; errors?: Array<GetServerListErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -116,6 +116,7 @@ export namespace GetServerPreferencesResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<GetServerPreferencesErrors$.Outbound> | undefined; errors?: Array<GetServerPreferencesErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -115,6 +115,7 @@ export namespace GetSessionHistoryResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<GetSessionHistoryErrors$.Outbound> | undefined; errors?: Array<GetSessionHistoryErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -115,6 +115,7 @@ export namespace GetSessionsResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<GetSessionsErrors$.Outbound> | undefined; errors?: Array<GetSessionsErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -129,6 +129,7 @@ export namespace GetSourceConnectionInformationResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<GetSourceConnectionInformationErrors$.Outbound> | undefined; errors?: Array<GetSourceConnectionInformationErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -115,6 +115,7 @@ export namespace GetStatisticsResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<GetStatisticsErrors$.Outbound> | undefined; errors?: Array<GetStatisticsErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -115,6 +115,7 @@ export namespace GetTimelineResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<GetTimelineErrors$.Outbound> | undefined; errors?: Array<GetTimelineErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -115,6 +115,7 @@ export namespace GetTokenResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<GetTokenErrors$.Outbound> | undefined; errors?: Array<GetTokenErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -116,6 +116,7 @@ export namespace GetTranscodeSessionsResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<GetTranscodeSessionsErrors$.Outbound> | undefined; errors?: Array<GetTranscodeSessionsErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -115,6 +115,7 @@ export namespace GetTransientTokenResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<GetTransientTokenErrors$.Outbound> | undefined; errors?: Array<GetTransientTokenErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -115,6 +115,7 @@ export namespace GetUpdateStatusResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<GetUpdateStatusErrors$.Outbound> | undefined; errors?: Array<GetUpdateStatusErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -115,6 +115,7 @@ export namespace LogLineResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<LogLineErrors$.Outbound> | undefined; errors?: Array<LogLineErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -115,6 +115,7 @@ export namespace LogMultiLineResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<LogMultiLineErrors$.Outbound> | undefined; errors?: Array<LogMultiLineErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -115,6 +115,7 @@ export namespace MarkPlayedResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<MarkPlayedErrors$.Outbound> | undefined; errors?: Array<MarkPlayedErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -115,6 +115,7 @@ export namespace MarkUnplayedResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<MarkUnplayedErrors$.Outbound> | undefined; errors?: Array<MarkUnplayedErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -115,6 +115,7 @@ export namespace PerformSearchResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<PerformSearchErrors$.Outbound> | undefined; errors?: Array<PerformSearchErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -115,6 +115,7 @@ export namespace PerformVoiceSearchResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<PerformVoiceSearchErrors$.Outbound> | undefined; errors?: Array<PerformVoiceSearchErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -115,6 +115,7 @@ export namespace RefreshLibraryResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<RefreshLibraryErrors$.Outbound> | undefined; errors?: Array<RefreshLibraryErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -115,6 +115,7 @@ export namespace StartAllTasksResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<StartAllTasksErrors$.Outbound> | undefined; errors?: Array<StartAllTasksErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -115,6 +115,7 @@ export namespace StartTaskResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<StartTaskErrors$.Outbound> | undefined; errors?: Array<StartTaskErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -120,6 +120,7 @@ export namespace StartUniversalTranscodeResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<StartUniversalTranscodeErrors$.Outbound> | undefined; errors?: Array<StartUniversalTranscodeErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -115,6 +115,7 @@ export namespace StopAllTasksResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<StopAllTasksErrors$.Outbound> | undefined; errors?: Array<StopAllTasksErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -115,6 +115,7 @@ export namespace StopTaskResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<StopTaskErrors$.Outbound> | undefined; errors?: Array<StopTaskErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -116,6 +116,7 @@ export namespace StopTranscodeSessionResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<StopTranscodeSessionErrors$.Outbound> | undefined; errors?: Array<StopTranscodeSessionErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -115,6 +115,7 @@ export namespace UpdatePlaylistResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<UpdatePlaylistErrors$.Outbound> | undefined; errors?: Array<UpdatePlaylistErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -115,6 +115,7 @@ export namespace UpdatePlayProgressResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<UpdatePlayProgressErrors$.Outbound> | undefined; errors?: Array<UpdatePlayProgressErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -115,6 +115,7 @@ export namespace UploadPlaylistResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }), ...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
}); });
}); });
export type Outbound = { export type Outbound = {
errors?: Array<UploadPlaylistErrors$.Outbound> | undefined; errors?: Array<UploadPlaylistErrors$.Outbound> | undefined;
RawResponse?: never | undefined; RawResponse?: never | undefined;

View File

@@ -7,15 +7,6 @@ import * as z from "zod";
export const GetPinServerList = ["https://plex.tv/api/v2"] as const; export const GetPinServerList = ["https://plex.tv/api/v2"] as const;
export type GetPinRequest = { export type GetPinRequest = {
/**
* The unique identifier for the client application
*
* @remarks
* This is used to track the client application and its usage
* (UUID, serial number, or other number unique per device)
*
*/
xPlexClientIdentifier: string;
/** /**
* Determines the kind of code returned by the API call * Determines the kind of code returned by the API call
* *
@@ -25,6 +16,15 @@ export type GetPinRequest = {
* *
*/ */
strong?: boolean | undefined; strong?: boolean | undefined;
/**
* The unique identifier for the client application
*
* @remarks
* This is used to track the client application and its usage
* (UUID, serial number, or other number unique per device)
*
*/
xPlexClientIdentifier?: string | undefined;
}; };
export type Location = { export type Location = {
@@ -91,36 +91,40 @@ export type GetPinResponse = {
/** @internal */ /** @internal */
export namespace GetPinRequest$ { export namespace GetPinRequest$ {
export type Inbound = { export type Inbound = {
"X-Plex-Client-Identifier": string;
strong?: boolean | undefined; strong?: boolean | undefined;
"X-Plex-Client-Identifier"?: string | undefined;
}; };
export const inboundSchema: z.ZodType<GetPinRequest, z.ZodTypeDef, Inbound> = z export const inboundSchema: z.ZodType<GetPinRequest, z.ZodTypeDef, Inbound> = z
.object({ .object({
"X-Plex-Client-Identifier": z.string(),
strong: z.boolean().default(false), strong: z.boolean().default(false),
"X-Plex-Client-Identifier": z.string().optional(),
}) })
.transform((v) => { .transform((v) => {
return { return {
xPlexClientIdentifier: v["X-Plex-Client-Identifier"],
strong: v.strong, strong: v.strong,
...(v["X-Plex-Client-Identifier"] === undefined
? null
: { xPlexClientIdentifier: v["X-Plex-Client-Identifier"] }),
}; };
}); });
export type Outbound = { export type Outbound = {
"X-Plex-Client-Identifier": string;
strong: boolean; strong: boolean;
"X-Plex-Client-Identifier"?: string | undefined;
}; };
export const outboundSchema: z.ZodType<Outbound, z.ZodTypeDef, GetPinRequest> = z export const outboundSchema: z.ZodType<Outbound, z.ZodTypeDef, GetPinRequest> = z
.object({ .object({
xPlexClientIdentifier: z.string(),
strong: z.boolean().default(false), strong: z.boolean().default(false),
xPlexClientIdentifier: z.string().optional(),
}) })
.transform((v) => { .transform((v) => {
return { return {
"X-Plex-Client-Identifier": v.xPlexClientIdentifier,
strong: v.strong, strong: v.strong,
...(v.xPlexClientIdentifier === undefined
? null
: { "X-Plex-Client-Identifier": v.xPlexClientIdentifier }),
}; };
}); });
} }

View File

@@ -19,7 +19,7 @@ export type GetTokenRequest = {
* (UUID, serial number, or other number unique per device) * (UUID, serial number, or other number unique per device)
* *
*/ */
xPlexClientIdentifier: string; xPlexClientIdentifier?: string | undefined;
}; };
export type GetTokenResponse = { export type GetTokenResponse = {
@@ -41,35 +41,39 @@ export type GetTokenResponse = {
export namespace GetTokenRequest$ { export namespace GetTokenRequest$ {
export type Inbound = { export type Inbound = {
pinID: string; pinID: string;
"X-Plex-Client-Identifier": string; "X-Plex-Client-Identifier"?: string | undefined;
}; };
export const inboundSchema: z.ZodType<GetTokenRequest, z.ZodTypeDef, Inbound> = z export const inboundSchema: z.ZodType<GetTokenRequest, z.ZodTypeDef, Inbound> = z
.object({ .object({
pinID: z.string(), pinID: z.string(),
"X-Plex-Client-Identifier": z.string(), "X-Plex-Client-Identifier": z.string().optional(),
}) })
.transform((v) => { .transform((v) => {
return { return {
pinID: v.pinID, pinID: v.pinID,
xPlexClientIdentifier: v["X-Plex-Client-Identifier"], ...(v["X-Plex-Client-Identifier"] === undefined
? null
: { xPlexClientIdentifier: v["X-Plex-Client-Identifier"] }),
}; };
}); });
export type Outbound = { export type Outbound = {
pinID: string; pinID: string;
"X-Plex-Client-Identifier": string; "X-Plex-Client-Identifier"?: string | undefined;
}; };
export const outboundSchema: z.ZodType<Outbound, z.ZodTypeDef, GetTokenRequest> = z export const outboundSchema: z.ZodType<Outbound, z.ZodTypeDef, GetTokenRequest> = z
.object({ .object({
pinID: z.string(), pinID: z.string(),
xPlexClientIdentifier: z.string(), xPlexClientIdentifier: z.string().optional(),
}) })
.transform((v) => { .transform((v) => {
return { return {
pinID: v.pinID, pinID: v.pinID,
"X-Plex-Client-Identifier": v.xPlexClientIdentifier, ...(v.xPlexClientIdentifier === undefined
? null
: { "X-Plex-Client-Identifier": v.xPlexClientIdentifier }),
}; };
}); });
} }

View File

@@ -45,13 +45,13 @@ export class Plex extends ClientSDK {
* Retrieve a Pin from Plex.tv for authentication flows * Retrieve a Pin from Plex.tv for authentication flows
*/ */
async getPin( async getPin(
xPlexClientIdentifier: string,
strong?: boolean | undefined, strong?: boolean | undefined,
xPlexClientIdentifier?: string | undefined,
options?: RequestOptions & { serverURL?: string } options?: RequestOptions & { serverURL?: string }
): Promise<operations.GetPinResponse> { ): Promise<operations.GetPinResponse> {
const input$: operations.GetPinRequest = { const input$: operations.GetPinRequest = {
xPlexClientIdentifier: xPlexClientIdentifier,
strong: strong, strong: strong,
xPlexClientIdentifier: xPlexClientIdentifier,
}; };
const headers$ = new Headers(); const headers$ = new Headers();
headers$.set("user-agent", SDK_METADATA.userAgent); headers$.set("user-agent", SDK_METADATA.userAgent);
@@ -79,10 +79,11 @@ export class Plex extends ClientSDK {
headers$.set( headers$.set(
"X-Plex-Client-Identifier", "X-Plex-Client-Identifier",
enc$.encodeSimple("X-Plex-Client-Identifier", payload$["X-Plex-Client-Identifier"], { enc$.encodeSimple(
explode: false, "X-Plex-Client-Identifier",
charEncoding: "none", payload$["X-Plex-Client-Identifier"] ?? this.options$.xPlexClientIdentifier,
}) { explode: false, charEncoding: "none" }
)
); );
const context = { operationID: "getPin", oAuth2Scopes: [], securitySource: null }; const context = { operationID: "getPin", oAuth2Scopes: [], securitySource: null };
@@ -147,7 +148,7 @@ export class Plex extends ClientSDK {
*/ */
async getToken( async getToken(
pinID: string, pinID: string,
xPlexClientIdentifier: string, xPlexClientIdentifier?: string | undefined,
options?: RequestOptions & { serverURL?: string } options?: RequestOptions & { serverURL?: string }
): Promise<operations.GetTokenResponse> { ): Promise<operations.GetTokenResponse> {
const input$: operations.GetTokenRequest = { const input$: operations.GetTokenRequest = {
@@ -182,10 +183,11 @@ export class Plex extends ClientSDK {
headers$.set( headers$.set(
"X-Plex-Client-Identifier", "X-Plex-Client-Identifier",
enc$.encodeSimple("X-Plex-Client-Identifier", payload$["X-Plex-Client-Identifier"], { enc$.encodeSimple(
explode: false, "X-Plex-Client-Identifier",
charEncoding: "none", payload$["X-Plex-Client-Identifier"] ?? this.options$.xPlexClientIdentifier,
}) { explode: false, charEncoding: "none" }
)
); );
const context = { operationID: "getToken", oAuth2Scopes: [], securitySource: null }; const context = { operationID: "getToken", oAuth2Scopes: [], securitySource: null };