diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 9310377d..1ff0feaf 100755 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -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.227.0 - generationVersion: 2.291.0 - releaseVersion: 0.11.0 - configChecksum: 8ed91aa4573f3ab00f3d32ae29436c8f + speakeasyVersion: 1.228.1 + generationVersion: 2.292.0 + releaseVersion: 0.12.0 + configChecksum: 96c0b6a9e85b7682aef0863ada1e00a7 repoURL: https://github.com/LukeHagar/plexjs.git repoSubDirectory: . installationURL: https://github.com/LukeHagar/plexjs @@ -18,9 +18,10 @@ features: flattening: 2.81.1 globalSecurity: 2.82.8 globalServerURLs: 2.82.4 + globals: 2.82.1 methodServerURLs: 2.82.1 nameOverrides: 2.81.1 - responseFormat: 0.2.2 + responseFormat: 0.2.3 generatedFiles: - src/sdk/server.ts - src/sdk/media.ts diff --git a/README.md b/README.md index 8371af97..a6605ca8 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ import { PlexAPI } from "@lukehagar/plexjs"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const result = await sdk.server.getServerCapabilities(); @@ -176,6 +177,7 @@ import * as errors from "@lukehagar/plexjs/models/errors"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); let result; @@ -227,6 +229,7 @@ async function run() { const sdk = new PlexAPI({ serverIdx: 0, accessToken: "", + xPlexClientIdentifier: "", }); const result = await sdk.server.getServerCapabilities(); @@ -257,6 +260,7 @@ async function run() { const sdk = new PlexAPI({ serverURL: "{protocol}://{ip}:{port}", accessToken: "", + xPlexClientIdentifier: "", }); 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"; async function run() { - const sdk = new PlexAPI(); + const sdk = new PlexAPI({ + xPlexClientIdentifier: "", + }); - const xPlexClientIdentifier = ""; const strong = false; + const xPlexClientIdentifier = ""; - const result = await sdk.plex.getPin(xPlexClientIdentifier, strong, { + const result = await sdk.plex.getPin(strong, xPlexClientIdentifier, { serverURL: "https://plex.tv/api/v2", }); @@ -361,6 +367,7 @@ import { PlexAPI } from "@lukehagar/plexjs"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const result = await sdk.server.getServerCapabilities(); @@ -380,6 +387,50 @@ run(); For supported JavaScript runtimes, please consult [RUNTIMES.md](RUNTIMES.md). + +## 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 `""` 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: "", + }); + + const strong = false; + const xPlexClientIdentifier = ""; + + const result = await sdk.plex.getPin(strong, xPlexClientIdentifier); + + // Handle the result + console.log(result); +} + +run(); + +``` + + # Development diff --git a/RELEASES.md b/RELEASES.md index 7b806075..02d8c155 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -278,4 +278,14 @@ Based on: ### Generated - [typescript v0.11.0] . ### Releases -- [NPM v0.11.0] https://www.npmjs.com/package/@lukehagar/plexjs/v/0.11.0 - . \ No newline at end of file +- [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 - . \ No newline at end of file diff --git a/USAGE.md b/USAGE.md index 0f07724d..f129be83 100644 --- a/USAGE.md +++ b/USAGE.md @@ -5,6 +5,7 @@ import { PlexAPI } from "@lukehagar/plexjs"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const result = await sdk.server.getServerCapabilities(); diff --git a/docs/models/operations/getpinrequest.md b/docs/models/operations/getpinrequest.md index ae9d24e8..be7db237 100644 --- a/docs/models/operations/getpinrequest.md +++ b/docs/models/operations/getpinrequest.md @@ -5,5 +5,5 @@ | Field | Type | Required | Description | | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `xPlexClientIdentifier` | *string* | :heavy_check_mark: | 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)
| -| `strong` | *boolean* | :heavy_minus_sign: | Determines the kind of code returned by the API call
Strong codes are used for Pin authentication flows
Non-Strong codes are used for `Plex.tv/link`
| \ No newline at end of file +| `strong` | *boolean* | :heavy_minus_sign: | Determines the kind of code returned by the API call
Strong codes are used for Pin authentication flows
Non-Strong codes are used for `Plex.tv/link`
| +| `xPlexClientIdentifier` | *string* | :heavy_minus_sign: | 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)
| \ No newline at end of file diff --git a/docs/models/operations/gettokenrequest.md b/docs/models/operations/gettokenrequest.md index d445f49b..7ed39c0b 100644 --- a/docs/models/operations/gettokenrequest.md +++ b/docs/models/operations/gettokenrequest.md @@ -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
This is used to track the client application and its usage
(UUID, serial number, or other number unique per device)
| \ No newline at end of file +| `xPlexClientIdentifier` | *string* | :heavy_minus_sign: | 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)
| \ No newline at end of file diff --git a/docs/sdks/activities/README.md b/docs/sdks/activities/README.md index 4bbe23a3..6f284960 100644 --- a/docs/sdks/activities/README.md +++ b/docs/sdks/activities/README.md @@ -29,6 +29,7 @@ import { PlexAPI } from "@lukehagar/plexjs"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const result = await sdk.activities.getServerActivities(); @@ -70,6 +71,7 @@ import { PlexAPI } from "@lukehagar/plexjs"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const activityUUID = ""; diff --git a/docs/sdks/authentication/README.md b/docs/sdks/authentication/README.md index 7e18a6fe..495c07f2 100644 --- a/docs/sdks/authentication/README.md +++ b/docs/sdks/authentication/README.md @@ -25,6 +25,7 @@ import { GetTransientTokenQueryParamType, Scope } from "@lukehagar/plexjs/models async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const type = GetTransientTokenQueryParamType.Delegation; @@ -73,6 +74,7 @@ import { PlexAPI } from "@lukehagar/plexjs"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const source = "server://client-identifier"; diff --git a/docs/sdks/butler/README.md b/docs/sdks/butler/README.md index 6ea31129..0aa5f6c8 100644 --- a/docs/sdks/butler/README.md +++ b/docs/sdks/butler/README.md @@ -26,6 +26,7 @@ import { PlexAPI } from "@lukehagar/plexjs"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const result = await sdk.butler.getButlerTasks(); @@ -72,6 +73,7 @@ import { PlexAPI } from "@lukehagar/plexjs"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const result = await sdk.butler.startAllTasks(); @@ -114,6 +116,7 @@ import { PlexAPI } from "@lukehagar/plexjs"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const result = await sdk.butler.stopAllTasks(); @@ -161,6 +164,7 @@ import { TaskName } from "@lukehagar/plexjs/models/operations"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const taskName = TaskName.CleanOldBundles; @@ -207,6 +211,7 @@ import { PathParamTaskName } from "@lukehagar/plexjs/models/operations"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const taskName = PathParamTaskName.BackupDatabase; diff --git a/docs/sdks/hubs/README.md b/docs/sdks/hubs/README.md index f1cd2067..2e14d336 100644 --- a/docs/sdks/hubs/README.md +++ b/docs/sdks/hubs/README.md @@ -24,6 +24,7 @@ import { OnlyTransient } from "@lukehagar/plexjs/models/operations"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const count = 1262.49; @@ -72,6 +73,7 @@ import { QueryParamOnlyTransient } from "@lukehagar/plexjs/models/operations"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const sectionId = 6728.76; diff --git a/docs/sdks/library/README.md b/docs/sdks/library/README.md index e4d4ee5c..5dd22cd5 100644 --- a/docs/sdks/library/README.md +++ b/docs/sdks/library/README.md @@ -32,6 +32,7 @@ import { PlexAPI } from "@lukehagar/plexjs"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const url = "file://C:\Image.png&type=13"; @@ -79,6 +80,7 @@ import { PlexAPI } from "@lukehagar/plexjs"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const result = await sdk.library.getRecentlyAdded(); @@ -126,6 +128,7 @@ import { PlexAPI } from "@lukehagar/plexjs"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const result = await sdk.library.getLibraries(); @@ -207,6 +210,7 @@ import { IncludeDetails } from "@lukehagar/plexjs/models/operations"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const sectionId = 1000; @@ -253,6 +257,7 @@ import { PlexAPI } from "@lukehagar/plexjs"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const sectionId = 1000; @@ -318,6 +323,7 @@ import { Tag } from "@lukehagar/plexjs/models/operations"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const sectionId = 451092; @@ -364,6 +370,7 @@ import { PlexAPI } from "@lukehagar/plexjs"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const sectionId = 934.16; @@ -427,6 +434,7 @@ import { Type } from "@lukehagar/plexjs/models/operations"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const sectionId = 933505; @@ -473,6 +481,7 @@ import { PlexAPI } from "@lukehagar/plexjs"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const ratingKey = 8382.31; @@ -518,6 +527,7 @@ import { PlexAPI } from "@lukehagar/plexjs"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const ratingKey = 1539.14; @@ -563,6 +573,7 @@ import { PlexAPI } from "@lukehagar/plexjs"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const result = await sdk.library.getOnDeck(); diff --git a/docs/sdks/log/README.md b/docs/sdks/log/README.md index 3983ff5f..fd46ab9b 100644 --- a/docs/sdks/log/README.md +++ b/docs/sdks/log/README.md @@ -26,6 +26,7 @@ import { Level } from "@lukehagar/plexjs/models/operations"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const level = Level.Three; @@ -95,6 +96,7 @@ import { PlexAPI } from "@lukehagar/plexjs"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); 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() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const result = await sdk.log.enablePaperTrail(); diff --git a/docs/sdks/media/README.md b/docs/sdks/media/README.md index 1eeb4bc5..fb20c2a6 100644 --- a/docs/sdks/media/README.md +++ b/docs/sdks/media/README.md @@ -24,6 +24,7 @@ import { PlexAPI } from "@lukehagar/plexjs"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const key = 59398; @@ -68,6 +69,7 @@ import { PlexAPI } from "@lukehagar/plexjs"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const key = 59398; @@ -113,6 +115,7 @@ import { PlexAPI } from "@lukehagar/plexjs"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const key = ""; diff --git a/docs/sdks/playlists/README.md b/docs/sdks/playlists/README.md index f2dd0a13..f5a38a55 100644 --- a/docs/sdks/playlists/README.md +++ b/docs/sdks/playlists/README.md @@ -37,6 +37,7 @@ import { QueryParamType, Smart } from "@lukehagar/plexjs/models/operations"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const result = await sdk.playlists.createPlaylist({ @@ -85,6 +86,7 @@ import { PlaylistType, QueryParamSmart } from "@lukehagar/plexjs/models/operatio async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const playlistType = PlaylistType.Audio; @@ -133,6 +135,7 @@ import { PlexAPI } from "@lukehagar/plexjs"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const playlistID = 4109.48; @@ -178,6 +181,7 @@ import { PlexAPI } from "@lukehagar/plexjs"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const playlistID = 216.22; @@ -223,6 +227,7 @@ import { PlexAPI } from "@lukehagar/plexjs"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const playlistID = 3915; @@ -275,6 +280,7 @@ import { PlexAPI } from "@lukehagar/plexjs"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const playlistID = 5004.46; @@ -322,6 +328,7 @@ import { PlexAPI } from "@lukehagar/plexjs"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const playlistID = 1893.18; @@ -368,6 +375,7 @@ import { PlexAPI } from "@lukehagar/plexjs"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const playlistID = 8502.01; @@ -418,6 +426,7 @@ import { Force } from "@lukehagar/plexjs/models/operations"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const path = "/home/barkley/playlist.m3u"; diff --git a/docs/sdks/plex/README.md b/docs/sdks/plex/README.md index c59db0a8..827cf4bc 100644 --- a/docs/sdks/plex/README.md +++ b/docs/sdks/plex/README.md @@ -21,12 +21,14 @@ Retrieve a Pin from Plex.tv for authentication flows import { PlexAPI } from "@lukehagar/plexjs"; async function run() { - const sdk = new PlexAPI(); + const sdk = new PlexAPI({ + xPlexClientIdentifier: "", + }); - const xPlexClientIdentifier = ""; const strong = false; + const xPlexClientIdentifier = ""; - const result = await sdk.plex.getPin(xPlexClientIdentifier, strong); + const result = await sdk.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
This is used to track the client application and its usage
(UUID, serial number, or other number unique per device)
| | `strong` | *boolean* | :heavy_minus_sign: | Determines the kind of code returned by the API call
Strong codes are used for Pin authentication flows
Non-Strong codes are used for `Plex.tv/link`
| +| `xPlexClientIdentifier` | *string* | :heavy_minus_sign: | 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)
| | `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. | @@ -66,7 +68,9 @@ Retrieve an Access Token from Plex.tv after the Pin has already been authenticat import { PlexAPI } from "@lukehagar/plexjs"; async function run() { - const sdk = new PlexAPI(); + const sdk = new PlexAPI({ + xPlexClientIdentifier: "", + }); const pinID = ""; const xPlexClientIdentifier = ""; @@ -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
This is used to track the client application and its usage
(UUID, serial number, or other number unique per device)
| +| `xPlexClientIdentifier` | *string* | :heavy_minus_sign: | 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)
| | `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. | diff --git a/docs/sdks/search/README.md b/docs/sdks/search/README.md index 50ee9a28..9e4123f2 100644 --- a/docs/sdks/search/README.md +++ b/docs/sdks/search/README.md @@ -36,6 +36,7 @@ import { PlexAPI } from "@lukehagar/plexjs"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const query = "dylan"; @@ -88,6 +89,7 @@ import { PlexAPI } from "@lukehagar/plexjs"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const query = "dead+poop"; @@ -136,6 +138,7 @@ import { PlexAPI } from "@lukehagar/plexjs"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const query = "110"; diff --git a/docs/sdks/server/README.md b/docs/sdks/server/README.md index 3c539c9a..ada05803 100644 --- a/docs/sdks/server/README.md +++ b/docs/sdks/server/README.md @@ -29,6 +29,7 @@ import { PlexAPI } from "@lukehagar/plexjs"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const result = await sdk.server.getServerCapabilities(); @@ -70,6 +71,7 @@ import { PlexAPI } from "@lukehagar/plexjs"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const result = await sdk.server.getServerPreferences(); @@ -111,6 +113,7 @@ import { PlexAPI } from "@lukehagar/plexjs"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const result = await sdk.server.getAvailableClients(); @@ -152,6 +155,7 @@ import { PlexAPI } from "@lukehagar/plexjs"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const result = await sdk.server.getDevices(); @@ -193,6 +197,7 @@ import { PlexAPI } from "@lukehagar/plexjs"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const result = await sdk.server.getServerIdentity(); @@ -234,6 +239,7 @@ import { PlexAPI } from "@lukehagar/plexjs"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const result = await sdk.server.getMyPlexAccount(); @@ -277,6 +283,7 @@ import { MinSize, Upscale } from "@lukehagar/plexjs/models/operations"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const result = await sdk.server.getResizedPhoto({ @@ -327,6 +334,7 @@ import { PlexAPI } from "@lukehagar/plexjs"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const result = await sdk.server.getServerList(); diff --git a/docs/sdks/sessions/README.md b/docs/sdks/sessions/README.md index aebc1ab4..ffcd3031 100644 --- a/docs/sdks/sessions/README.md +++ b/docs/sdks/sessions/README.md @@ -25,6 +25,7 @@ import { PlexAPI } from "@lukehagar/plexjs"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const result = await sdk.sessions.getSessions(); @@ -66,6 +67,7 @@ import { PlexAPI } from "@lukehagar/plexjs"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const result = await sdk.sessions.getSessionHistory(); @@ -107,6 +109,7 @@ import { PlexAPI } from "@lukehagar/plexjs"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const result = await sdk.sessions.getTranscodeSessions(); @@ -148,6 +151,7 @@ import { PlexAPI } from "@lukehagar/plexjs"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const sessionKey = "zz7llzqlx8w9vnrsbnwhbmep"; diff --git a/docs/sdks/statistics/README.md b/docs/sdks/statistics/README.md index cc2021cb..f27bba0e 100644 --- a/docs/sdks/statistics/README.md +++ b/docs/sdks/statistics/README.md @@ -22,6 +22,7 @@ import { PlexAPI } from "@lukehagar/plexjs"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const timespan = 411769; diff --git a/docs/sdks/updater/README.md b/docs/sdks/updater/README.md index 15d758ad..bc0f1bcf 100644 --- a/docs/sdks/updater/README.md +++ b/docs/sdks/updater/README.md @@ -25,6 +25,7 @@ import { PlexAPI } from "@lukehagar/plexjs"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const result = await sdk.updater.getUpdateStatus(); @@ -67,6 +68,7 @@ import { Download } from "@lukehagar/plexjs/models/operations"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const download = Download.One; @@ -113,6 +115,7 @@ import { Skip, Tonight } from "@lukehagar/plexjs/models/operations"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const tonight = Tonight.One; diff --git a/docs/sdks/video/README.md b/docs/sdks/video/README.md index 78f418f6..527021e4 100644 --- a/docs/sdks/video/README.md +++ b/docs/sdks/video/README.md @@ -24,6 +24,7 @@ import { State } from "@lukehagar/plexjs/models/operations"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const result = await sdk.video.getTimeline({ @@ -77,6 +78,7 @@ import { PlexAPI } from "@lukehagar/plexjs"; async function run() { const sdk = new PlexAPI({ accessToken: "", + xPlexClientIdentifier: "", }); const result = await sdk.video.startUniversalTranscode({ diff --git a/gen.yaml b/gen.yaml index 25556bbc..b3c09d1e 100755 --- a/gen.yaml +++ b/gen.yaml @@ -12,7 +12,7 @@ generation: auth: oAuth2ClientCredentialsEnabled: false typescript: - version: 0.11.0 + version: 0.12.0 additionalDependencies: dependencies: {} devDependencies: {} diff --git a/package-lock.json b/package-lock.json index 26a53326..7ab9900d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@lukehagar/plexjs", - "version": "0.11.0", + "version": "0.12.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@lukehagar/plexjs", - "version": "0.11.0", + "version": "0.12.0", "devDependencies": { "@types/jsonpath": "^0.2.4", "@typescript-eslint/eslint-plugin": "^6.13.2", diff --git a/package.json b/package.json index 6eff3623..e8e25909 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lukehagar/plexjs", - "version": "0.11.0", + "version": "0.12.0", "author": "LukeHagar", "main": "./index.js", "sideEffects": false, diff --git a/src/lib/config.ts b/src/lib/config.ts index 790b5aa7..f6a8139e 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -27,6 +27,11 @@ export enum ServerProtocol { export type SDKOptions = { accessToken?: string | (() => Promise); + /** + * 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.11.0", - genVersion: "2.291.0", - userAgent: "speakeasy-sdk/typescript 0.11.0 2.291.0 0.0.3 @lukehagar/plexjs", + sdkVersion: "0.12.0", + genVersion: "2.292.0", + userAgent: "speakeasy-sdk/typescript 0.12.0 2.292.0 0.0.3 @lukehagar/plexjs", }); diff --git a/src/models/operations/getpin.ts b/src/models/operations/getpin.ts index 956e5a5c..28175d50 100644 --- a/src/models/operations/getpin.ts +++ b/src/models/operations/getpin.ts @@ -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 = 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 = 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 }), }; }); } diff --git a/src/models/operations/gettoken.ts b/src/models/operations/gettoken.ts index 7155de2a..3daf9a19 100644 --- a/src/models/operations/gettoken.ts +++ b/src/models/operations/gettoken.ts @@ -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 = 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 = 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 }), }; }); } diff --git a/src/sdk/plex.ts b/src/sdk/plex.ts index c5c5ee59..ef565031 100644 --- a/src/sdk/plex.ts +++ b/src/sdk/plex.ts @@ -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 { 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 { 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 };