Compare commits

..

10 Commits

Author SHA1 Message Date
speakeasybot
242d7d78f2 ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.257.1 2024-04-18 00:28:19 +00:00
speakeasybot
779aa2dc9e ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.252.0 2024-04-13 00:26:21 +00:00
speakeasybot
0d73a769fb ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.231.1 2024-04-02 00:28:18 +00:00
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
92 changed files with 764 additions and 447 deletions

View File

@@ -15,15 +15,10 @@ permissions:
- cron: 0 0 * * *
jobs:
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:
force: ${{ github.event.inputs.force }}
languages: |
- typescript
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
secrets:
github_access_token: ${{ secrets.GITHUB_TOKEN }}

View File

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

21
.speakeasy/workflow.lock Normal file
View File

@@ -0,0 +1,21 @@
speakeasyVersion: 1.257.1
sources:
my-source: {}
targets:
plexjs:
source: my-source
outLocation: /github/workspace/repo
workflow:
workflowVersion: 1.0.0
speakeasyVersion: latest
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

13
.speakeasy/workflow.yaml Normal file
View File

@@ -0,0 +1,13 @@
workflowVersion: 1.0.0
speakeasyVersion: latest
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

@@ -31,12 +31,13 @@ yarn add @lukehagar/plexjs
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
const result = await sdk.server.getServerCapabilities();
async function run() {
const result = await plexAPI.server.getServerCapabilities();
// Handle the result
console.log(result);
@@ -173,14 +174,15 @@ Validation errors can also occur when either method arguments or data returned f
import { PlexAPI } from "@lukehagar/plexjs";
import * as errors from "@lukehagar/plexjs/models/errors";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
async function run() {
let result;
try {
result = await sdk.server.getServerCapabilities();
result = await plexAPI.server.getServerCapabilities();
} catch (err) {
switch (true) {
case err instanceof errors.SDKValidationError: {
@@ -223,13 +225,14 @@ You can override the default server globally by passing a server index to the `s
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
serverIdx: 0,
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
const result = await sdk.server.getServerCapabilities();
async function run() {
const result = await plexAPI.server.getServerCapabilities();
// Handle the result
console.log(result);
@@ -253,13 +256,14 @@ The default server can also be overridden globally by passing a URL to the `serv
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
serverURL: "{protocol}://{ip}:{port}",
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
const result = await sdk.server.getServerCapabilities();
async function run() {
const result = await plexAPI.server.getServerCapabilities();
// Handle the result
console.log(result);
@@ -275,13 +279,15 @@ The server URL can also be overridden on a per-operation basis, provided a serve
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
const plexAPI = new PlexAPI({
xPlexClientIdentifier: "<value>",
});
async function run() {
const sdk = new PlexAPI();
const xPlexClientIdentifier = "<value>";
const strong = false;
const xPlexClientIdentifier = "<value>";
const result = await sdk.plex.getPin(xPlexClientIdentifier, strong, {
const result = await plexAPI.plex.getPin(strong, xPlexClientIdentifier, {
serverURL: "https://plex.tv/api/v2",
});
@@ -358,12 +364,13 @@ To authenticate with the API the `accessToken` parameter must be set when initia
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
const result = await sdk.server.getServerCapabilities();
async function run() {
const result = await plexAPI.server.getServerCapabilities();
// Handle the result
console.log(result);
@@ -380,6 +387,50 @@ run();
For supported JavaScript runtimes, please consult [RUNTIMES.md](RUNTIMES.md).
<!-- 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";
const plexAPI = new PlexAPI({
xPlexClientIdentifier: "<value>",
});
async function run() {
const strong = false;
const xPlexClientIdentifier = "<value>";
const result = await plexAPI.plex.getPin(strong, xPlexClientIdentifier);
// Handle the result
console.log(result);
}
run();
```
<!-- End Global Parameters [global-parameters] -->
<!-- Placeholder for Future Speakeasy SDK Sections -->
# Development

View File

@@ -239,3 +239,83 @@ Based on:
- [typescript v0.10.1] .
### Releases
- [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 - .
## 2024-04-02 00:26:20
### Changes
Based on:
- OpenAPI Doc
- Speakeasy CLI 1.231.1 (2.295.1) https://github.com/speakeasy-api/speakeasy
### Generated
- [typescript v0.12.1] .
### Releases
- [NPM v0.12.1] https://www.npmjs.com/package/@lukehagar/plexjs/v/0.12.1 - .
## 2024-04-13 00:23:00
### Changes
Based on:
- OpenAPI Doc
- Speakeasy CLI 1.252.0 (2.306.0) https://github.com/speakeasy-api/speakeasy
### Generated
- [typescript v0.12.2] .
### Releases
- [NPM v0.12.2] https://www.npmjs.com/package/@lukehagar/plexjs/v/0.12.2 - .
## 2024-04-18 00:26:16
### Changes
Based on:
- OpenAPI Doc
- Speakeasy CLI 1.257.1 (2.308.2) https://github.com/speakeasy-api/speakeasy
### Generated
- [typescript v0.12.3] .
### Releases
- [NPM v0.12.3] https://www.npmjs.com/package/@lukehagar/plexjs/v/0.12.3 - .

View File

@@ -2,12 +2,13 @@
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
const result = await sdk.server.getServerCapabilities();
async function run() {
const result = await plexAPI.server.getServerCapabilities();
// Handle the result
console.log(result);

View File

@@ -5,5 +5,5 @@
| 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/> |
| `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 |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `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

@@ -26,12 +26,13 @@ Get Server Activities
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
const result = await sdk.activities.getServerActivities();
async function run() {
const result = await plexAPI.activities.getServerActivities();
// Handle the result
console.log(result)
@@ -67,14 +68,15 @@ Cancel Server Activities
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
async function run() {
const activityUUID = "<value>";
const result = await sdk.activities.cancelServerActivities(activityUUID);
const result = await plexAPI.activities.cancelServerActivities(activityUUID);
// Handle the result
console.log(result)

View File

@@ -22,15 +22,16 @@ This endpoint provides the caller with a temporary token with the same access le
import { PlexAPI } from "@lukehagar/plexjs";
import { GetTransientTokenQueryParamType, Scope } from "@lukehagar/plexjs/models/operations";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
async function run() {
const type = GetTransientTokenQueryParamType.Delegation;
const scope = Scope.All;
const result = await sdk.authentication.getTransientToken(type, scope);
const result = await plexAPI.authentication.getTransientToken(type, scope);
// Handle the result
console.log(result)
@@ -70,14 +71,15 @@ Note: requires Plex Media Server >= 1.15.4.
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
async function run() {
const source = "server://client-identifier";
const result = await sdk.authentication.getSourceConnectionInformation(source);
const result = await plexAPI.authentication.getSourceConnectionInformation(source);
// Handle the result
console.log(result)

View File

@@ -23,12 +23,13 @@ Returns a list of butler tasks
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
const result = await sdk.butler.getButlerTasks();
async function run() {
const result = await plexAPI.butler.getButlerTasks();
// Handle the result
console.log(result)
@@ -69,12 +70,13 @@ This endpoint will attempt to start all Butler tasks that are enabled in the set
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
const result = await sdk.butler.startAllTasks();
async function run() {
const result = await plexAPI.butler.startAllTasks();
// Handle the result
console.log(result)
@@ -111,12 +113,13 @@ This endpoint will stop all currently running tasks and remove any scheduled tas
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
const result = await sdk.butler.stopAllTasks();
async function run() {
const result = await plexAPI.butler.stopAllTasks();
// Handle the result
console.log(result)
@@ -158,14 +161,15 @@ This endpoint will attempt to start a single Butler task that is enabled in the
import { PlexAPI } from "@lukehagar/plexjs";
import { TaskName } from "@lukehagar/plexjs/models/operations";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
async function run() {
const taskName = TaskName.CleanOldBundles;
const result = await sdk.butler.startTask(taskName);
const result = await plexAPI.butler.startTask(taskName);
// Handle the result
console.log(result)
@@ -204,14 +208,15 @@ This endpoint will stop a currently running task by name, or remove it from the
import { PlexAPI } from "@lukehagar/plexjs";
import { PathParamTaskName } from "@lukehagar/plexjs/models/operations";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
async function run() {
const taskName = PathParamTaskName.BackupDatabase;
const result = await sdk.butler.stopTask(taskName);
const result = await plexAPI.butler.stopTask(taskName);
// Handle the result
console.log(result)

View File

@@ -21,15 +21,16 @@ Get Global Hubs filtered by the parameters provided.
import { PlexAPI } from "@lukehagar/plexjs";
import { OnlyTransient } from "@lukehagar/plexjs/models/operations";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
async function run() {
const count = 1262.49;
const onlyTransient = OnlyTransient.One;
const result = await sdk.hubs.getGlobalHubs(count, onlyTransient);
const result = await plexAPI.hubs.getGlobalHubs(count, onlyTransient);
// Handle the result
console.log(result)
@@ -69,16 +70,17 @@ This endpoint will return a list of library specific hubs
import { PlexAPI } from "@lukehagar/plexjs";
import { QueryParamOnlyTransient } from "@lukehagar/plexjs/models/operations";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
async function run() {
const sectionId = 6728.76;
const count = 9010.22;
const onlyTransient = QueryParamOnlyTransient.Zero;
const result = await sdk.hubs.getLibraryHubs(sectionId, count, onlyTransient);
const result = await plexAPI.hubs.getLibraryHubs(sectionId, count, onlyTransient);
// Handle the result
console.log(result)

View File

@@ -29,15 +29,16 @@ This resource returns hash values for local files
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
async function run() {
const url = "file://C:\Image.png&type=13";
const type = 4462.17;
const result = await sdk.library.getFileHash(url, type);
const result = await plexAPI.library.getFileHash(url, type);
// Handle the result
console.log(result)
@@ -76,12 +77,13 @@ This endpoint will return the recently added content.
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
const result = await sdk.library.getRecentlyAdded();
async function run() {
const result = await plexAPI.library.getRecentlyAdded();
// Handle the result
console.log(result)
@@ -123,12 +125,13 @@ This allows a client to provide a rich interface around the media (e.g. allow so
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
const result = await sdk.library.getLibraries();
async function run() {
const result = await plexAPI.library.getLibraries();
// Handle the result
console.log(result)
@@ -204,15 +207,16 @@ Each type in the library comes with a set of filters and sorts, aiding in buildi
import { PlexAPI } from "@lukehagar/plexjs";
import { IncludeDetails } from "@lukehagar/plexjs/models/operations";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
async function run() {
const sectionId = 1000;
const includeDetails = IncludeDetails.Zero;
const result = await sdk.library.getLibrary(sectionId, includeDetails);
const result = await plexAPI.library.getLibrary(sectionId, includeDetails);
// Handle the result
console.log(result)
@@ -250,14 +254,15 @@ Delate a library using a specific section
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
async function run() {
const sectionId = 1000;
const result = await sdk.library.deleteLibrary(sectionId);
const result = await plexAPI.library.deleteLibrary(sectionId);
// Handle the result
console.log(result)
@@ -315,15 +320,16 @@ Fetches details from a specific section of the library identified by a section k
import { PlexAPI } from "@lukehagar/plexjs";
import { Tag } from "@lukehagar/plexjs/models/operations";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
async function run() {
const sectionId = 451092;
const tag = Tag.Unwatched;
const result = await sdk.library.getLibraryItems(sectionId, tag);
const result = await plexAPI.library.getLibraryItems(sectionId, tag);
// Handle the result
console.log(result)
@@ -361,14 +367,15 @@ This endpoint Refreshes the library.
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
async function run() {
const sectionId = 934.16;
const result = await sdk.library.refreshLibrary(sectionId);
const result = await plexAPI.library.refreshLibrary(sectionId);
// Handle the result
console.log(result)
@@ -424,15 +431,16 @@ Each type in the library comes with a set of filters and sorts, aiding in buildi
import { PlexAPI } from "@lukehagar/plexjs";
import { Type } from "@lukehagar/plexjs/models/operations";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
async function run() {
const sectionId = 933505;
const type = Type.Four;
const result = await sdk.library.searchLibrary(sectionId, type);
const result = await plexAPI.library.searchLibrary(sectionId, type);
// Handle the result
console.log(result)
@@ -470,14 +478,15 @@ This endpoint will return the metadata of a library item specified with the rati
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
async function run() {
const ratingKey = 8382.31;
const result = await sdk.library.getMetadata(ratingKey);
const result = await plexAPI.library.getMetadata(ratingKey);
// Handle the result
console.log(result)
@@ -515,14 +524,15 @@ This endpoint will return the children of of a library item specified with the r
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
async function run() {
const ratingKey = 1539.14;
const result = await sdk.library.getMetadataChildren(ratingKey);
const result = await plexAPI.library.getMetadataChildren(ratingKey);
// Handle the result
console.log(result)
@@ -560,12 +570,13 @@ This endpoint will return the on deck content.
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
const result = await sdk.library.getOnDeck();
async function run() {
const result = await plexAPI.library.getOnDeck();
// Handle the result
console.log(result)

View File

@@ -23,16 +23,17 @@ This endpoint will write a single-line log message, including a level and source
import { PlexAPI } from "@lukehagar/plexjs";
import { Level } from "@lukehagar/plexjs/models/operations";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
async function run() {
const level = Level.Three;
const message = "Test log message";
const source = "Postman";
const result = await sdk.log.logLine(level, message, source);
const result = await plexAPI.log.logLine(level, message, source);
// Handle the result
console.log(result)
@@ -92,12 +93,13 @@ Ensure each parameter is properly URL-encoded to avoid interpretation issues.
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
const result = await sdk.log.logMultiLine("level=4&message=Test%20message%201&source=postman
async function run() {
const result = await plexAPI.log.logMultiLine("level=4&message=Test%20message%201&source=postman
level=3&message=Test%20message%202&source=postman
level=1&message=Test%20message%203&source=postman");
@@ -137,12 +139,13 @@ This endpoint will enable all Plex Media Serverlogs to be sent to the Papertrail
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
const result = await sdk.log.enablePaperTrail();
async function run() {
const result = await plexAPI.log.enablePaperTrail();
// Handle the result
console.log(result)

View File

@@ -21,14 +21,15 @@ This will mark the provided media key as Played.
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
async function run() {
const key = 59398;
const result = await sdk.media.markPlayed(key);
const result = await plexAPI.media.markPlayed(key);
// Handle the result
console.log(result)
@@ -65,14 +66,15 @@ This will mark the provided media key as Unplayed.
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
async function run() {
const key = 59398;
const result = await sdk.media.markUnplayed(key);
const result = await plexAPI.media.markUnplayed(key);
// Handle the result
console.log(result)
@@ -110,16 +112,17 @@ This API command can be used to update the play progress of a media item.
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
async function run() {
const key = "<value>";
const time = 6900.91;
const state = "<value>";
const result = await sdk.media.updatePlayProgress(key, time, state);
const result = await plexAPI.media.updatePlayProgress(key, time, state);
// Handle the result
console.log(result)

View File

@@ -34,12 +34,13 @@ Create a new playlist. By default the playlist is blank. To create a playlist al
import { PlexAPI } from "@lukehagar/plexjs";
import { QueryParamType, Smart } from "@lukehagar/plexjs/models/operations";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
const result = await sdk.playlists.createPlaylist({
async function run() {
const result = await plexAPI.playlists.createPlaylist({
title: "<value>",
type: QueryParamType.Photo,
smart: Smart.One,
@@ -82,15 +83,16 @@ Get All Playlists given the specified filters.
import { PlexAPI } from "@lukehagar/plexjs";
import { PlaylistType, QueryParamSmart } from "@lukehagar/plexjs/models/operations";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
async function run() {
const playlistType = PlaylistType.Audio;
const smart = QueryParamSmart.Zero;
const result = await sdk.playlists.getPlaylists(playlistType, smart);
const result = await plexAPI.playlists.getPlaylists(playlistType, smart);
// Handle the result
console.log(result)
@@ -130,14 +132,15 @@ Smart playlist details contain the `content` attribute. This is the content URI
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
async function run() {
const playlistID = 4109.48;
const result = await sdk.playlists.getPlaylist(playlistID);
const result = await plexAPI.playlists.getPlaylist(playlistID);
// Handle the result
console.log(result)
@@ -175,14 +178,15 @@ This endpoint will delete a playlist
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
async function run() {
const playlistID = 216.22;
const result = await sdk.playlists.deletePlaylist(playlistID);
const result = await plexAPI.playlists.deletePlaylist(playlistID);
// Handle the result
console.log(result)
@@ -220,16 +224,17 @@ From PMS version 1.9.1 clients can also edit playlist metadata using this endpoi
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
async function run() {
const playlistID = 3915;
const title = "<value>";
const summary = "<value>";
const result = await sdk.playlists.updatePlaylist(playlistID, title, summary);
const result = await plexAPI.playlists.updatePlaylist(playlistID, title, summary);
// Handle the result
console.log(result)
@@ -272,15 +277,16 @@ Note that for dumb playlists, items have a `playlistItemID` attribute which is u
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
async function run() {
const playlistID = 5004.46;
const type = 9403.59;
const result = await sdk.playlists.getPlaylistContents(playlistID, type);
const result = await plexAPI.playlists.getPlaylistContents(playlistID, type);
// Handle the result
console.log(result)
@@ -319,14 +325,15 @@ Clears a playlist, only works with dumb playlists. Returns the playlist.
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
async function run() {
const playlistID = 1893.18;
const result = await sdk.playlists.clearPlaylistContents(playlistID);
const result = await plexAPI.playlists.clearPlaylistContents(playlistID);
// Handle the result
console.log(result)
@@ -365,16 +372,17 @@ With a smart playlist, passing a new `uri` parameter replaces the rules for the
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
async function run() {
const playlistID = 8502.01;
const uri = "server://12345/com.plexapp.plugins.library/library/metadata/1";
const playQueueID = 123;
const result = await sdk.playlists.addPlaylistContents(playlistID, uri, playQueueID);
const result = await plexAPI.playlists.addPlaylistContents(playlistID, uri, playQueueID);
// Handle the result
console.log(result)
@@ -415,15 +423,16 @@ Imports m3u playlists by passing a path on the server to scan for m3u-formatted
import { PlexAPI } from "@lukehagar/plexjs";
import { Force } from "@lukehagar/plexjs/models/operations";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
async function run() {
const path = "/home/barkley/playlist.m3u";
const force = Force.Zero;
const result = await sdk.playlists.uploadPlaylist(path, force);
const result = await plexAPI.playlists.uploadPlaylist(path, force);
// Handle the result
console.log(result)

View File

@@ -20,13 +20,15 @@ Retrieve a Pin from Plex.tv for authentication flows
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
const plexAPI = new PlexAPI({
xPlexClientIdentifier: "<value>",
});
async function run() {
const sdk = new PlexAPI();
const xPlexClientIdentifier = "<value>";
const strong = false;
const xPlexClientIdentifier = "<value>";
const result = await sdk.plex.getPin(xPlexClientIdentifier, strong);
const result = await plexAPI.plex.getPin(strong, xPlexClientIdentifier);
// Handle the result
console.log(result)
@@ -39,8 +41,8 @@ run();
| 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/> |
| `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.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. |
@@ -65,13 +67,15 @@ Retrieve an Access Token from Plex.tv after the Pin has already been authenticat
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI();
const plexAPI = new PlexAPI({
xPlexClientIdentifier: "<value>",
});
async function run() {
const pinID = "<value>";
const xPlexClientIdentifier = "<value>";
const result = await sdk.plex.getToken(pinID, xPlexClientIdentifier);
const result = await plexAPI.plex.getToken(pinID, xPlexClientIdentifier);
// Handle the result
console.log(result)
@@ -85,7 +89,7 @@ run();
| Parameter | Type | Required | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `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.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. |

View File

@@ -33,16 +33,17 @@ This request is intended to be very fast, and called as the user types.
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
async function run() {
const query = "dylan";
const sectionId = 1516.53;
const limit = 5;
const result = await sdk.search.performSearch(query, sectionId, limit);
const result = await plexAPI.search.performSearch(query, sectionId, limit);
// Handle the result
console.log(result)
@@ -85,16 +86,17 @@ Results, as well as their containing per-type hubs, contain a `distance` attribu
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
async function run() {
const query = "dead+poop";
const sectionId = 4094.8;
const limit = 5;
const result = await sdk.search.performVoiceSearch(query, sectionId, limit);
const result = await plexAPI.search.performVoiceSearch(query, sectionId, limit);
// Handle the result
console.log(result)
@@ -133,14 +135,15 @@ This will search the database for the string provided.
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
async function run() {
const query = "110";
const result = await sdk.search.getSearchResults(query);
const result = await plexAPI.search.getSearchResults(query);
// Handle the result
console.log(result)

View File

@@ -26,12 +26,13 @@ Server Capabilities
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
const result = await sdk.server.getServerCapabilities();
async function run() {
const result = await plexAPI.server.getServerCapabilities();
// Handle the result
console.log(result)
@@ -67,12 +68,13 @@ Get Server Preferences
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
const result = await sdk.server.getServerPreferences();
async function run() {
const result = await plexAPI.server.getServerPreferences();
// Handle the result
console.log(result)
@@ -108,12 +110,13 @@ Get Available Clients
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
const result = await sdk.server.getAvailableClients();
async function run() {
const result = await plexAPI.server.getAvailableClients();
// Handle the result
console.log(result)
@@ -149,12 +152,13 @@ Get Devices
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
const result = await sdk.server.getDevices();
async function run() {
const result = await plexAPI.server.getDevices();
// Handle the result
console.log(result)
@@ -190,12 +194,13 @@ Get Server Identity
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
const result = await sdk.server.getServerIdentity();
async function run() {
const result = await plexAPI.server.getServerIdentity();
// Handle the result
console.log(result)
@@ -231,12 +236,13 @@ Returns MyPlex Account Information
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
const result = await sdk.server.getMyPlexAccount();
async function run() {
const result = await plexAPI.server.getMyPlexAccount();
// Handle the result
console.log(result)
@@ -274,12 +280,13 @@ Plex's Photo transcoder is used throughout the service to serve images at specif
import { PlexAPI } from "@lukehagar/plexjs";
import { MinSize, Upscale } from "@lukehagar/plexjs/models/operations";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
const result = await sdk.server.getResizedPhoto({
async function run() {
const result = await plexAPI.server.getResizedPhoto({
width: 110,
height: 165,
opacity: 100,
@@ -324,12 +331,13 @@ Get Server List
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
const result = await sdk.server.getServerList();
async function run() {
const result = await plexAPI.server.getServerList();
// Handle the result
console.log(result)

View File

@@ -22,12 +22,13 @@ This will retrieve the "Now Playing" Information of the PMS.
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
const result = await sdk.sessions.getSessions();
async function run() {
const result = await plexAPI.sessions.getSessions();
// Handle the result
console.log(result)
@@ -63,12 +64,13 @@ This will Retrieve a listing of all history views.
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
const result = await sdk.sessions.getSessionHistory();
async function run() {
const result = await plexAPI.sessions.getSessionHistory();
// Handle the result
console.log(result)
@@ -104,12 +106,13 @@ Get Transcode Sessions
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
const result = await sdk.sessions.getTranscodeSessions();
async function run() {
const result = await plexAPI.sessions.getTranscodeSessions();
// Handle the result
console.log(result)
@@ -145,14 +148,15 @@ Stop a Transcode Session
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
async function run() {
const sessionKey = "zz7llzqlx8w9vnrsbnwhbmep";
const result = await sdk.sessions.stopTranscodeSession(sessionKey);
const result = await plexAPI.sessions.stopTranscodeSession(sessionKey);
// Handle the result
console.log(result)

View File

@@ -19,14 +19,15 @@ This will return the media statistics for the server
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
async function run() {
const timespan = 411769;
const result = await sdk.statistics.getStatistics(timespan);
const result = await plexAPI.statistics.getStatistics(timespan);
// Handle the result
console.log(result)

View File

@@ -22,12 +22,13 @@ Querying status of updates
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
const result = await sdk.updater.getUpdateStatus();
async function run() {
const result = await plexAPI.updater.getUpdateStatus();
// Handle the result
console.log(result)
@@ -64,14 +65,15 @@ Checking for updates
import { PlexAPI } from "@lukehagar/plexjs";
import { Download } from "@lukehagar/plexjs/models/operations";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
async function run() {
const download = Download.One;
const result = await sdk.updater.checkForUpdates(download);
const result = await plexAPI.updater.checkForUpdates(download);
// Handle the result
console.log(result)
@@ -110,15 +112,16 @@ Note that these two parameters are effectively mutually exclusive. The `tonight`
import { PlexAPI } from "@lukehagar/plexjs";
import { Skip, Tonight } from "@lukehagar/plexjs/models/operations";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
async function run() {
const tonight = Tonight.One;
const skip = Skip.Zero;
const result = await sdk.updater.applyUpdates(tonight, skip);
const result = await plexAPI.updater.applyUpdates(tonight, skip);
// Handle the result
console.log(result)

View File

@@ -21,12 +21,13 @@ Get the timeline for a media item
import { PlexAPI } from "@lukehagar/plexjs";
import { State } from "@lukehagar/plexjs/models/operations";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
const result = await sdk.video.getTimeline({
async function run() {
const result = await plexAPI.video.getTimeline({
ratingKey: 716.56,
key: "<key>",
state: State.Paused,
@@ -74,12 +75,13 @@ Begin a Universal Transcode Session
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
xPlexClientIdentifier: "<value>",
});
const result = await sdk.video.startUniversalTranscode({
async function run() {
const result = await plexAPI.video.startUniversalTranscode({
hasMDE: 8924.99,
path: "/etc/mail",
mediaIndex: 9962.95,

View File

@@ -12,13 +12,15 @@ generation:
auth:
oAuth2ClientCredentialsEnabled: false
typescript:
version: 0.10.1
version: 0.12.3
additionalDependencies:
dependencies: {}
devDependencies: {}
peerDependencies: {}
additionalPackageJSON: {}
author: LukeHagar
clientServerStatusCodesAsErrors: true
enumFormat: enum
flattenGlobalSecurity: true
imports:
option: openapi

4
package-lock.json generated
View File

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

View File

@@ -1,6 +1,6 @@
{
"name": "@lukehagar/plexjs",
"version": "0.10.1",
"version": "0.12.3",
"author": "LukeHagar",
"main": "./index.js",
"sideEffects": false,
@@ -14,7 +14,6 @@
"build": "tsc",
"prepare": "npm run build"
},
"keywords": [],
"peerDependencies": {
"zod": ">= 3"
},

View File

@@ -27,6 +27,11 @@ export enum ServerProtocol {
export type SDKOptions = {
accessToken?: string | (() => Promise<string>);
/**
* Allows setting the xPlexClientIdentifier parameter for all supported operations
*/
xPlexClientIdentifier?: string;
httpClient?: HTTPClient;
/**
* 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({
language: "typescript",
openapiDocVersion: "0.0.3",
sdkVersion: "0.10.1",
genVersion: "2.280.6",
userAgent: "speakeasy-sdk/typescript 0.10.1 2.280.6 0.0.3 @lukehagar/plexjs",
sdkVersion: "0.12.3",
genVersion: "2.308.2",
userAgent: "speakeasy-sdk/typescript 0.12.3 2.308.2 0.0.3 @lukehagar/plexjs",
});

View File

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

View File

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

View File

@@ -30,21 +30,15 @@ export class SecurityError extends Error {
}
export type SecurityState = {
basic: { username: string; password?: string };
basic: { username?: string | undefined; password?: string | undefined };
headers: Record<string, string>;
queryParams: Record<string, string>;
cookies: Record<string, string>;
};
type SecurityInputBasicPacked = {
type: "http:basic";
value: { username: string; password?: string } | null | undefined;
};
type SecurityInputBasic = {
type: "http:basic";
value: string | null | undefined;
fieldName: "username" | "password";
value: { username?: string | undefined; password?: string | undefined } | null | undefined;
};
type SecurityInputBearer = {
@@ -79,7 +73,6 @@ type SecurityInputOAuth2ClientCredentials = {
export type SecurityInput =
| SecurityInputBasic
| SecurityInputBasicPacked
| SecurityInputBearer
| SecurityInputAPIKey
| SecurityInputOAuth2
@@ -94,7 +87,21 @@ export function resolveSecurity(...options: SecurityInput[][]): SecurityState |
cookies: {},
};
const option = options.find((opts) => opts.every((o) => Boolean(o.value)));
const option = options.find((opts) => {
return opts.every((o) => {
if (o.value == null) {
return false;
} else if (o.type === "http:basic") {
return o.value.username != null || o.value.password != null;
} else if (typeof o.value === "string") {
return !!o.value;
} else {
throw new Error(
`Unrecognized security type: ${o.type} (value type: ${typeof o.value})`
);
}
});
});
if (option == null) {
return null;
}
@@ -139,16 +146,12 @@ export function resolveSecurity(...options: SecurityInput[][]): SecurityState |
return state;
}
function applyBasic(state: SecurityState, spec: SecurityInputBasic | SecurityInputBasicPacked) {
function applyBasic(state: SecurityState, spec: SecurityInputBasic) {
if (spec.value == null) {
return;
}
if ("fieldName" in spec) {
state.basic[spec.fieldName] = spec.value;
} else {
state.basic = spec.value;
}
}
function applyBearer(
@@ -168,6 +171,10 @@ function applyBearer(
}
export function resolveGlobalSecurity(security: Partial<components.Security> | null | undefined) {
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 }),
});
});
export type Outbound = {
errors?: Array<AddPlaylistContentsErrors$.Outbound> | undefined;
RawResponse?: never | undefined;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -115,6 +115,7 @@ export namespace UploadPlaylistResponseBody$ {
...(v.RawResponse === undefined ? null : { rawResponse: v.RawResponse }),
});
});
export type Outbound = {
errors?: Array<UploadPlaylistErrors$.Outbound> | 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 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
*
@@ -25,6 +16,15 @@ export type GetPinRequest = {
*
*/
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 = {
@@ -91,36 +91,40 @@ export type GetPinResponse = {
/** @internal */
export namespace GetPinRequest$ {
export type Inbound = {
"X-Plex-Client-Identifier": string;
strong?: boolean | undefined;
"X-Plex-Client-Identifier"?: string | undefined;
};
export const inboundSchema: z.ZodType<GetPinRequest, z.ZodTypeDef, Inbound> = z
.object({
"X-Plex-Client-Identifier": z.string(),
strong: z.boolean().default(false),
"X-Plex-Client-Identifier": z.string().optional(),
})
.transform((v) => {
return {
xPlexClientIdentifier: v["X-Plex-Client-Identifier"],
strong: v.strong,
...(v["X-Plex-Client-Identifier"] === undefined
? null
: { xPlexClientIdentifier: v["X-Plex-Client-Identifier"] }),
};
});
export type Outbound = {
"X-Plex-Client-Identifier": string;
strong: boolean;
"X-Plex-Client-Identifier"?: string | undefined;
};
export const outboundSchema: z.ZodType<Outbound, z.ZodTypeDef, GetPinRequest> = z
.object({
xPlexClientIdentifier: z.string(),
strong: z.boolean().default(false),
xPlexClientIdentifier: z.string().optional(),
})
.transform((v) => {
return {
"X-Plex-Client-Identifier": v.xPlexClientIdentifier,
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)
*
*/
xPlexClientIdentifier: string;
xPlexClientIdentifier?: string | undefined;
};
export type GetTokenResponse = {
@@ -41,35 +41,39 @@ export type GetTokenResponse = {
export namespace GetTokenRequest$ {
export type Inbound = {
pinID: string;
"X-Plex-Client-Identifier": string;
"X-Plex-Client-Identifier"?: string | undefined;
};
export const inboundSchema: z.ZodType<GetTokenRequest, z.ZodTypeDef, Inbound> = z
.object({
pinID: z.string(),
"X-Plex-Client-Identifier": z.string(),
"X-Plex-Client-Identifier": z.string().optional(),
})
.transform((v) => {
return {
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 = {
pinID: string;
"X-Plex-Client-Identifier": string;
"X-Plex-Client-Identifier"?: string | undefined;
};
export const outboundSchema: z.ZodType<Outbound, z.ZodTypeDef, GetTokenRequest> = z
.object({
pinID: z.string(),
xPlexClientIdentifier: z.string(),
xPlexClientIdentifier: z.string().optional(),
})
.transform((v) => {
return {
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
*/
async getPin(
xPlexClientIdentifier: string,
strong?: boolean | undefined,
xPlexClientIdentifier?: string | undefined,
options?: RequestOptions & { serverURL?: string }
): Promise<operations.GetPinResponse> {
const input$: operations.GetPinRequest = {
xPlexClientIdentifier: xPlexClientIdentifier,
strong: strong,
xPlexClientIdentifier: xPlexClientIdentifier,
};
const headers$ = new Headers();
headers$.set("user-agent", SDK_METADATA.userAgent);
@@ -79,10 +79,11 @@ export class Plex extends ClientSDK {
headers$.set(
"X-Plex-Client-Identifier",
enc$.encodeSimple("X-Plex-Client-Identifier", payload$["X-Plex-Client-Identifier"], {
explode: false,
charEncoding: "none",
})
enc$.encodeSimple(
"X-Plex-Client-Identifier",
payload$["X-Plex-Client-Identifier"] ?? this.options$.xPlexClientIdentifier,
{ explode: false, charEncoding: "none" }
)
);
const context = { operationID: "getPin", oAuth2Scopes: [], securitySource: null };
@@ -147,7 +148,7 @@ export class Plex extends ClientSDK {
*/
async getToken(
pinID: string,
xPlexClientIdentifier: string,
xPlexClientIdentifier?: string | undefined,
options?: RequestOptions & { serverURL?: string }
): Promise<operations.GetTokenResponse> {
const input$: operations.GetTokenRequest = {
@@ -182,10 +183,11 @@ export class Plex extends ClientSDK {
headers$.set(
"X-Plex-Client-Identifier",
enc$.encodeSimple("X-Plex-Client-Identifier", payload$["X-Plex-Client-Identifier"], {
explode: false,
charEncoding: "none",
})
enc$.encodeSimple(
"X-Plex-Client-Identifier",
payload$["X-Plex-Client-Identifier"] ?? this.options$.xPlexClientIdentifier,
{ explode: false, charEncoding: "none" }
)
);
const context = { operationID: "getToken", oAuth2Scopes: [], securitySource: null };